~ubuntu-branches/ubuntu/wily/postbooks-schema-empty/wily

« back to all changes in this revision

Viewing changes to postbooks_empty-4.7.0.sql

  • Committer: Package Import Robot
  • Author(s): Daniel Pocock
  • Date: 2015-10-03 08:58:13 UTC
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: package-import@ubuntu.com-20151003085813-5yqa63dxunjde60u
Tags: upstream-4.9.2
ImportĀ upstreamĀ versionĀ 4.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--
2
 
--
3
 
 
4
 
SET statement_timeout = 0;
5
 
SET client_encoding = 'UTF8';
6
 
SET standard_conforming_strings = on;
7
 
SET check_function_bodies = false;
8
 
SET client_min_messages = warning;
9
 
 
10
 
--
11
 
--
12
 
 
13
 
CREATE SCHEMA api;
14
 
 
15
 
 
16
 
ALTER SCHEMA api OWNER TO admin;
17
 
 
18
 
--
19
 
--
20
 
 
21
 
CREATE SCHEMA fixcountry;
22
 
 
23
 
 
24
 
ALTER SCHEMA fixcountry OWNER TO admin;
25
 
 
26
 
--
27
 
--
28
 
 
29
 
COMMENT ON SCHEMA fixcountry IS 'Schema to hold contents of fixcountry';
30
 
 
31
 
 
32
 
--
33
 
--
34
 
 
35
 
CREATE SCHEMA te;
36
 
 
37
 
 
38
 
ALTER SCHEMA te OWNER TO admin;
39
 
 
40
 
--
41
 
--
42
 
 
43
 
COMMENT ON SCHEMA te IS 'This file is part of the xTuple ERP: PostBooks Edition, a free and open source Enterprise Resource Planning software suite, Copyright (c) 1999-2010 by OpenMFG LLC, d/b/a xTuple. It is licensed to you under the Common Public Attribution License version 1.0, the full text of which (including xTuple-specific Exhibits) is available at www.xtuple.com/CPAL.  By using this software, you agree to be bound by its terms.';
44
 
 
45
 
 
46
 
--
47
 
--
48
 
 
49
 
CREATE SCHEMA xt;
50
 
 
51
 
 
52
 
ALTER SCHEMA xt OWNER TO admin;
53
 
 
54
 
--
55
 
--
56
 
 
57
 
CREATE SCHEMA xtdesktop;
58
 
 
59
 
 
60
 
ALTER SCHEMA xtdesktop OWNER TO admin;
61
 
 
62
 
--
63
 
--
64
 
 
65
 
COMMENT ON SCHEMA xtdesktop IS 'Schema to hold contents of xtdesktop';
66
 
 
67
 
 
68
 
--
69
 
--
70
 
 
71
 
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
72
 
 
73
 
 
74
 
--
75
 
--
76
 
 
77
 
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
78
 
 
79
 
 
80
 
SET search_path = public, pg_catalog;
81
 
 
82
 
--
83
 
--
84
 
 
85
 
CREATE TYPE achline AS (
86
 
        achline_checkhead_id integer,
87
 
        achline_batch text,
88
 
        achline_type text,
89
 
        achline_value text
90
 
);
91
 
 
92
 
 
93
 
ALTER TYPE public.achline OWNER TO admin;
94
 
 
95
 
--
96
 
--
97
 
 
98
 
CREATE TYPE apaging AS (
99
 
        apaging_docdate text,
100
 
        apaging_duedate date,
101
 
        apaging_ponumber text,
102
 
        apaging_reference text,
103
 
        apaging_invcnumber text,
104
 
        apaging_docnumber text,
105
 
        apaging_doctype text,
106
 
        apaging_vend_id integer,
107
 
        apaging_vend_number text,
108
 
        apaging_vend_name text,
109
 
        apaging_vend_vendtype_id integer,
110
 
        apaging_vendtype_code text,
111
 
        apaging_terms_descrip text,
112
 
        apaging_apopen_amount numeric,
113
 
        apaging_cur_val numeric,
114
 
        apaging_thirty_val numeric,
115
 
        apaging_sixty_val numeric,
116
 
        apaging_ninety_val numeric,
117
 
        apaging_plus_val numeric,
118
 
        apaging_total_val numeric,
119
 
        apaging_discdate date,
120
 
        apaging_disc_val numeric,
121
 
        apaging_discdays numeric,
122
 
        apaging_discprcnt numeric
123
 
);
124
 
 
125
 
 
126
 
ALTER TYPE public.apaging OWNER TO admin;
127
 
 
128
 
--
129
 
--
130
 
 
131
 
CREATE TYPE araging AS (
132
 
        araging_docdate date,
133
 
        araging_duedate date,
134
 
        araging_ponumber text,
135
 
        araging_docnumber text,
136
 
        araging_doctype text,
137
 
        araging_cust_id integer,
138
 
        araging_cust_number text,
139
 
        araging_cust_name text,
140
 
        araging_cust_custtype_id integer,
141
 
        araging_custtype_code text,
142
 
        araging_terms_descrip text,
143
 
        araging_aropen_amount numeric,
144
 
        araging_cur_val numeric,
145
 
        araging_thirty_val numeric,
146
 
        araging_sixty_val numeric,
147
 
        araging_ninety_val numeric,
148
 
        araging_plus_val numeric,
149
 
        araging_total_val numeric
150
 
);
151
 
 
152
 
 
153
 
ALTER TYPE public.araging OWNER TO admin;
154
 
 
155
 
--
156
 
--
157
 
 
158
 
CREATE TYPE bomdata AS (
159
 
        bomdata_bomwork_id integer,
160
 
        bomdata_bomwork_parent_id integer,
161
 
        bomdata_bomwork_level integer,
162
 
        bomdata_bomwork_seqnumber integer,
163
 
        bomdata_bomitem_id integer,
164
 
        bomdata_item_id integer,
165
 
        bomdata_item_number text,
166
 
        bomdata_uom_name text,
167
 
        bomdata_item_descrip1 text,
168
 
        bomdata_item_descrip2 text,
169
 
        bomdata_itemdescription text,
170
 
        bomdata_batchsize numeric,
171
 
        bomdata_qtyfxd numeric,
172
 
        bomdata_qtyper numeric,
173
 
        bomdata_qtyreq numeric,
174
 
        bomdata_scrap numeric,
175
 
        bomdata_createchild boolean,
176
 
        bomdata_issuemethod text,
177
 
        bomdata_effective date,
178
 
        bomdata_expires date,
179
 
        bomdata_expired boolean,
180
 
        bomdata_future boolean,
181
 
        bomdata_actunitcost numeric,
182
 
        bomdata_stdunitcost numeric,
183
 
        bomdata_actextendedcost numeric,
184
 
        bomdata_stdextendedcost numeric,
185
 
        bomdata_ecn text,
186
 
        bomdata_char_id integer,
187
 
        bomdata_value text,
188
 
        bomdata_notes text,
189
 
        bomdata_ref text
190
 
);
191
 
 
192
 
 
193
 
ALTER TYPE public.bomdata OWNER TO admin;
194
 
 
195
 
--
196
 
--
197
 
 
198
 
CREATE TYPE checkdata AS (
199
 
        checkdata_page integer,
200
 
        checkdata_checknumber text,
201
 
        checkdata_checkwords text,
202
 
        checkdata_checkdate text,
203
 
        checkdata_checkamount text,
204
 
        checkdata_checkcurrsymbol text,
205
 
        checkdata_checkcurrabbr text,
206
 
        checkdata_checkcurrname text,
207
 
        checkdata_checkpayto text,
208
 
        checkdata_checkaddress text,
209
 
        checkdata_checkmemo text,
210
 
        checkdata_docnumber text,
211
 
        checkdata_docreference text,
212
 
        checkdata_docdate text,
213
 
        checkdata_docamount text,
214
 
        checkdata_docdiscount text,
215
 
        checkdata_docnetamount text
216
 
);
217
 
 
218
 
 
219
 
ALTER TYPE public.checkdata OWNER TO admin;
220
 
 
221
 
--
222
 
--
223
 
 
224
 
CREATE TYPE cntctdup AS (
225
 
        cntct_id integer,
226
 
        cntct_crmacct_id integer,
227
 
        cntct_addr_id integer,
228
 
        cntct_first_name text,
229
 
        cntct_last_name text,
230
 
        cntct_honorific text,
231
 
        cntct_initials text,
232
 
        cntct_active boolean,
233
 
        cntct_phone text,
234
 
        cntct_phone2 text,
235
 
        cntct_fax text,
236
 
        cntct_email text,
237
 
        cntct_webaddr text,
238
 
        cntct_notes text,
239
 
        cntct_title text,
240
 
        cntct_number text,
241
 
        cntct_middle text,
242
 
        cntct_suffix text,
243
 
        cntct_owner_username text,
244
 
        cntct_name text,
245
 
        crmacct_number text,
246
 
        crmacct_name text,
247
 
        addr_id integer,
248
 
        addr_active boolean,
249
 
        addr_line1 text,
250
 
        addr_line2 text,
251
 
        addr_line3 text,
252
 
        addr_city text,
253
 
        addr_state text,
254
 
        addr_postalcode text,
255
 
        addr_country text,
256
 
        addr_notes text,
257
 
        addr_number text,
258
 
        cntctdup_level integer
259
 
);
260
 
 
261
 
 
262
 
ALTER TYPE public.cntctdup OWNER TO admin;
263
 
 
264
 
--
265
 
--
266
 
 
267
 
CREATE TYPE flcoldata AS (
268
 
        flcoldata_column integer,
269
 
        flcoldata_start date,
270
 
        flcoldata_end date
271
 
);
272
 
 
273
 
 
274
 
ALTER TYPE public.flcoldata OWNER TO admin;
275
 
 
276
 
--
277
 
--
278
 
 
279
 
CREATE TYPE flstmthead AS (
280
 
        flstmthead_flhead_id integer,
281
 
        flstmthead_flcol_id integer,
282
 
        flstmthead_period_id integer,
283
 
        flstmthead_username text,
284
 
        flstmthead_typedescrip1 text,
285
 
        flstmthead_typedescrip2 text,
286
 
        flstmthead_flhead_name text,
287
 
        flstmthead_flcol_name text,
288
 
        flstmthead_month text,
289
 
        flstmthead_qtr text,
290
 
        flstmthead_year text,
291
 
        flstmthead_prmonth text,
292
 
        flstmthead_prqtr text,
293
 
        flstmthead_pryear text
294
 
);
295
 
 
296
 
 
297
 
ALTER TYPE public.flstmthead OWNER TO admin;
298
 
 
299
 
--
300
 
--
301
 
 
302
 
CREATE TYPE flstmtitem AS (
303
 
        flstmtitem_flhead_id integer,
304
 
        flstmtitem_period_id integer,
305
 
        flstmtitem_username text,
306
 
        flstmtitem_order integer,
307
 
        flstmtitem_level integer,
308
 
        flstmtitem_subgrp integer,
309
 
        flstmtitem_type text,
310
 
        flstmtitem_type_id integer,
311
 
        flstmtitem_parent_id integer,
312
 
        flstmtitem_accnt_id integer,
313
 
        flstmtitem_name text,
314
 
        flstmtitem_month numeric,
315
 
        flstmtitem_monthdb numeric,
316
 
        flstmtitem_monthcr numeric,
317
 
        flstmtitem_monthprcnt numeric,
318
 
        flstmtitem_monthbudget numeric,
319
 
        flstmtitem_monthbudgetprcnt numeric,
320
 
        flstmtitem_monthbudgetdiff numeric,
321
 
        flstmtitem_monthbudgetdiffprcnt numeric,
322
 
        flstmtitem_qtr numeric,
323
 
        flstmtitem_qtrdb numeric,
324
 
        flstmtitem_qtrcr numeric,
325
 
        flstmtitem_qtrprcnt numeric,
326
 
        flstmtitem_qtrbudget numeric,
327
 
        flstmtitem_qtrbudgetprcnt numeric,
328
 
        flstmtitem_qtrbudgetdiff numeric,
329
 
        flstmtitem_qtrbudgetdiffprcnt numeric,
330
 
        flstmtitem_year numeric,
331
 
        flstmtitem_yeardb numeric,
332
 
        flstmtitem_yearcr numeric,
333
 
        flstmtitem_yearprcnt numeric,
334
 
        flstmtitem_yearbudget numeric,
335
 
        flstmtitem_yearbudgetprcnt numeric,
336
 
        flstmtitem_yearbudgetdiff numeric,
337
 
        flstmtitem_yearbudgetdiffprcnt numeric,
338
 
        flstmtitem_prmonth numeric,
339
 
        flstmtitem_prmonthprcnt numeric,
340
 
        flstmtitem_prmonthdiff numeric,
341
 
        flstmtitem_prmonthdiffprcnt numeric,
342
 
        flstmtitem_prqtr numeric,
343
 
        flstmtitem_prqtrprcnt numeric,
344
 
        flstmtitem_prqtrdiff numeric,
345
 
        flstmtitem_prqtrdiffprcnt numeric,
346
 
        flstmtitem_pryear numeric,
347
 
        flstmtitem_pryearprcnt numeric,
348
 
        flstmtitem_pryeardiff numeric,
349
 
        flstmtitem_pryeardiffprcnt numeric
350
 
);
351
 
 
352
 
 
353
 
ALTER TYPE public.flstmtitem OWNER TO admin;
354
 
 
355
 
--
356
 
--
357
 
 
358
 
CREATE TYPE fltrendhead AS (
359
 
        fltrendhead_flhead_id integer,
360
 
        fltrendhead_username text,
361
 
        fltrendhead_typedescrip text,
362
 
        fltrendhead_flhead_name text,
363
 
        fltrendhead_fld1 text,
364
 
        fltrendhead_fld2 text,
365
 
        fltrendhead_fld3 text,
366
 
        fltrendhead_fld4 text,
367
 
        fltrendhead_fld5 text,
368
 
        fltrendhead_fld6 text,
369
 
        fltrendhead_fld7 text,
370
 
        fltrendhead_fld8 text,
371
 
        fltrendhead_fld9 text,
372
 
        fltrendhead_fld10 text,
373
 
        fltrendhead_fld11 text,
374
 
        fltrendhead_fld12 text,
375
 
        fltrendhead_grndttl text
376
 
);
377
 
 
378
 
 
379
 
ALTER TYPE public.fltrendhead OWNER TO admin;
380
 
 
381
 
--
382
 
--
383
 
 
384
 
CREATE TYPE fltrenditem AS (
385
 
        fltrenditem_flhead_id integer,
386
 
        fltrenditem_username text,
387
 
        fltrenditem_order integer,
388
 
        fltrenditem_level integer,
389
 
        fltrenditem_subgrp integer,
390
 
        fltrenditem_type text,
391
 
        fltrenditem_type_id integer,
392
 
        fltrenditem_parent_id integer,
393
 
        fltrenditem_accnt_id integer,
394
 
        fltrenditem_name text,
395
 
        fltrenditem_fld1 text,
396
 
        fltrenditem_fld2 text,
397
 
        fltrenditem_fld3 text,
398
 
        fltrenditem_fld4 text,
399
 
        fltrenditem_fld5 text,
400
 
        fltrenditem_fld6 text,
401
 
        fltrenditem_fld7 text,
402
 
        fltrenditem_fld8 text,
403
 
        fltrenditem_fld9 text,
404
 
        fltrenditem_fld10 text,
405
 
        fltrenditem_fld11 text,
406
 
        fltrenditem_fld12 text,
407
 
        fltrenditem_grndttl text
408
 
);
409
 
 
410
 
 
411
 
ALTER TYPE public.fltrenditem OWNER TO admin;
412
 
 
413
 
--
414
 
--
415
 
 
416
 
CREATE TYPE freightdata AS (
417
 
        freightdata_schedule text,
418
 
        freightdata_from text,
419
 
        freightdata_to text,
420
 
        freightdata_shipvia text,
421
 
        freightdata_freightclass text,
422
 
        freightdata_weight numeric,
423
 
        freightdata_uom text,
424
 
        freightdata_price numeric,
425
 
        freightdata_type text,
426
 
        freightdata_total numeric,
427
 
        freightdata_currency text
428
 
);
429
 
 
430
 
 
431
 
ALTER TYPE public.freightdata OWNER TO admin;
432
 
 
433
 
--
434
 
--
435
 
 
436
 
CREATE TYPE itemprice AS (
437
 
        itemprice_price numeric,
438
 
        itemprice_type character(1)
439
 
);
440
 
 
441
 
 
442
 
ALTER TYPE public.itemprice OWNER TO admin;
443
 
 
444
 
--
445
 
--
446
 
 
447
 
CREATE TYPE orderitemtype AS (
448
 
        orderitem_id integer,
449
 
        orderitem_orderhead_type text,
450
 
        orderitem_orderhead_id integer,
451
 
        orderitem_linenumber integer,
452
 
        orderitem_status text,
453
 
        orderitem_itemsite_id integer,
454
 
        orderitem_scheddate date,
455
 
        orderitem_qty_ordered numeric,
456
 
        orderitem_qty_shipped numeric,
457
 
        orderitem_qty_received numeric,
458
 
        orderitem_qty_uom_id integer,
459
 
        orderitem_qty_invuomratio numeric,
460
 
        orderitem_unitcost numeric,
461
 
        orderitem_unitcost_curr_id integer,
462
 
        orderitem_freight numeric,
463
 
        orderitem_freight_received numeric,
464
 
        orderitem_freight_curr_id integer
465
 
);
466
 
 
467
 
 
468
 
ALTER TYPE public.orderitemtype OWNER TO admin;
469
 
 
470
 
--
471
 
--
472
 
 
473
 
CREATE TYPE ordhead AS (
474
 
        orderhead_id integer,
475
 
        orderhead_type text,
476
 
        orderhead_number text,
477
 
        orderhead_status text,
478
 
        orderhead_orderdate date,
479
 
        orderhead_linecount integer,
480
 
        orderhead_from_id integer,
481
 
        orderhead_from text,
482
 
        orderhead_to_id integer,
483
 
        orderhead_to text,
484
 
        orderhead_curr_id integer,
485
 
        orderhead_agent_username text,
486
 
        orderhead_shipvia text
487
 
);
488
 
 
489
 
 
490
 
ALTER TYPE public.ordhead OWNER TO admin;
491
 
 
492
 
--
493
 
--
494
 
 
495
 
CREATE TYPE orditem AS (
496
 
        orderitem_id integer,
497
 
        orderitem_orderhead_type text,
498
 
        orderitem_orderhead_id integer,
499
 
        orderitem_linenumber integer,
500
 
        orderitem_status text,
501
 
        orderitem_itemsite_id integer,
502
 
        orderitem_scheddate date,
503
 
        orderitem_qty_ordered numeric,
504
 
        orderitem_qty_shipped numeric,
505
 
        orderitem_qty_received numeric,
506
 
        orderitem_qty_uom_id integer,
507
 
        orderitem_qty_invuomratio numeric,
508
 
        orderitem_unitcost numeric,
509
 
        orderitem_unitcost_curr_id integer,
510
 
        orderitem_freight numeric,
511
 
        orderitem_freight_received numeric,
512
 
        orderitem_freight_curr_id integer
513
 
);
514
 
 
515
 
 
516
 
ALTER TYPE public.orditem OWNER TO admin;
517
 
 
518
 
--
519
 
--
520
 
 
521
 
CREATE TYPE reordlvl AS (
522
 
        reordlvl_itemsite_id integer,
523
 
        reordlvl_item_id integer,
524
 
        reordlvl_warehous_code text,
525
 
        reordlvl_item_number text,
526
 
        reordlvl_item_descrip text,
527
 
        reordlvl_leadtime integer,
528
 
        reordlvl_daysofstock integer,
529
 
        reordlvl_curr_level numeric,
530
 
        reordlvl_total_days numeric,
531
 
        reordlvl_total_usage numeric,
532
 
        reordlvl_calc_level integer
533
 
);
534
 
 
535
 
 
536
 
ALTER TYPE public.reordlvl OWNER TO admin;
537
 
 
538
 
--
539
 
--
540
 
 
541
 
CREATE TYPE seqiss AS (
542
 
        seqiss_number integer,
543
 
        seqiss_time timestamp with time zone
544
 
);
545
 
 
546
 
 
547
 
ALTER TYPE public.seqiss OWNER TO admin;
548
 
 
549
 
--
550
 
--
551
 
 
552
 
CREATE TYPE subtax AS (
553
 
        subtax_taxcode_id integer,
554
 
        subtax_taxcode_code text,
555
 
        subtax_taxcode_descrip text,
556
 
        subtax_taxcode_level integer
557
 
);
558
 
 
559
 
 
560
 
ALTER TYPE public.subtax OWNER TO admin;
561
 
 
562
 
--
563
 
--
564
 
 
565
 
CREATE TYPE taxassign AS (
566
 
        taxassign_taxzone_id integer,
567
 
        taxassign_taxtype_id integer,
568
 
        taxassign_level integer,
569
 
        taxassign_zone_code text,
570
 
        taxassign_type_descrip text,
571
 
        taxassign_taxclass_code text,
572
 
        taxassign_taxclass_sequence integer
573
 
);
574
 
 
575
 
 
576
 
ALTER TYPE public.taxassign OWNER TO admin;
577
 
 
578
 
--
579
 
--
580
 
 
581
 
CREATE TYPE taxdetail AS (
582
 
        taxdetail_tax_id integer,
583
 
        taxdetail_tax_code text,
584
 
        taxdetail_tax_descrip text,
585
 
        taxdetail_tax_basis_tax_id integer,
586
 
        taxdetail_taxrate_percent numeric(10,6),
587
 
        taxdetail_taxrate_amount numeric(16,2),
588
 
        taxdetail_level integer,
589
 
        taxdetail_taxclass_id integer,
590
 
        taxdetail_taxclass_code text,
591
 
        taxdetail_taxclass_sequence integer,
592
 
        taxdetail_tax numeric(16,6),
593
 
        taxdetail_curr_id integer,
594
 
        taxdetail_curr_abbr text
595
 
);
596
 
 
597
 
 
598
 
ALTER TYPE public.taxdetail OWNER TO admin;
599
 
 
600
 
--
601
 
--
602
 
 
603
 
CREATE TYPE wodata AS (
604
 
        wodata_id integer,
605
 
        wodata_id_type integer,
606
 
        wodata_number integer,
607
 
        wodata_subnumber integer,
608
 
        wodata_itemnumber text,
609
 
        wodata_descrip text,
610
 
        wodata_status character(1),
611
 
        wodata_startdate date,
612
 
        wodata_duedate date,
613
 
        wodata_adhoc boolean,
614
 
        wodata_itemsite_id integer,
615
 
        wodata_listprice numeric,
616
 
        wodata_custprice numeric,
617
 
        wodata_qoh numeric,
618
 
        wodata_short numeric,
619
 
        wodata_qtyper numeric,
620
 
        wodata_qtyiss numeric,
621
 
        wodata_qtyrcv numeric,
622
 
        wodata_qtyordreq numeric,
623
 
        wodata_qtyuom text,
624
 
        wodata_scrap numeric,
625
 
        wodata_setup numeric,
626
 
        wodata_run numeric,
627
 
        wodata_notes text,
628
 
        wodata_ref text,
629
 
        wodata_level integer
630
 
);
631
 
 
632
 
 
633
 
ALTER TYPE public.wodata OWNER TO admin;
634
 
 
635
 
--
636
 
--
637
 
 
638
 
CREATE TYPE woinvav AS (
639
 
        woinvav_itemsite_id integer,
640
 
        woinvav_womatl_id integer,
641
 
        woinvav_type character(1),
642
 
        woinvav_item_wo_number text,
643
 
        woinvav_descrip text,
644
 
        woinvav_uomname text,
645
 
        woinvav_qoh numeric,
646
 
        woinvav_balance numeric,
647
 
        woinvav_allocated numeric,
648
 
        woinvav_ordered numeric,
649
 
        woinvav_woavail numeric,
650
 
        woinvav_totalavail numeric,
651
 
        woinvav_reorderlevel numeric,
652
 
        woinvav_level integer
653
 
);
654
 
 
655
 
 
656
 
ALTER TYPE public.woinvav OWNER TO admin;
657
 
 
658
 
SET search_path = xtdesktop, pg_catalog;
659
 
 
660
 
--
661
 
--
662
 
 
663
 
CREATE TYPE usersonline AS (
664
 
        usr_id integer,
665
 
        usr_username text,
666
 
        usr_propername text,
667
 
        usr_email text,
668
 
        client_start timestamp with time zone,
669
 
        query_start timestamp with time zone,
670
 
        cnt_internal bigint,
671
 
        cnt_external bigint,
672
 
        client_addr inet
673
 
);
674
 
 
675
 
 
676
 
ALTER TYPE xtdesktop.usersonline OWNER TO admin;
677
 
 
678
 
SET search_path = api, pg_catalog;
679
 
 
680
 
--
681
 
--
682
 
 
683
 
CREATE FUNCTION getcustnumberfrominfo(text, text, text, text, text, boolean) RETURNS text
684
 
    LANGUAGE plpgsql
685
 
    AS $_$
686
 
DECLARE
687
 
  _email        TEXT    := COALESCE(UPPER($1), '');
688
 
  _company      TEXT    := COALESCE(UPPER($2), '');
689
 
  _first        TEXT    := COALESCE(UPPER($3), '');
690
 
  _last         TEXT    := COALESCE(UPPER($4), '');
691
 
  _fullname     TEXT    := COALESCE(UPPER($5), TRIM(_first || ' ' || _last));
692
 
  _generate     BOOLEAN := COALESCE($6, FALSE);
693
 
  _counter      INTEGER;
694
 
  _custcount    INTEGER := 0;
695
 
  _custnumber   TEXT;
696
 
  _candidate    TEXT    := '';
697
 
  _loopmax      INTEGER := 0;
698
 
  _minlength    INTEGER := 5;
699
 
  _maxlength    INTEGER := 8;
700
 
  _numformat    TEXT    := '';
701
 
  _testme       TEXT;
702
 
BEGIN
703
 
  IF (_email != '') THEN
704
 
    SELECT count(*), cust_number INTO _custcount, _custnumber
705
 
    FROM custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)
706
 
    WHERE (UPPER(cntct_email)=_email)
707
 
    GROUP BY cust_number;
708
 
    IF (NOT FOUND) THEN
709
 
      _custcount := 0;
710
 
    ELSIF(_custcount = 1) THEN
711
 
      RETURN _custnumber;
712
 
    END IF;
713
 
  END IF;
714
 
 
715
 
  IF (_company != '') THEN
716
 
    SELECT count(*), cust_number INTO _custcount, _custnumber
717
 
    FROM custinfo
718
 
    WHERE (UPPER(cust_name)=_company)
719
 
    GROUP BY cust_number;
720
 
    IF (NOT FOUND) THEN
721
 
      _custcount := 0;
722
 
    ELSIF(_custcount = 1) THEN
723
 
      RETURN _custnumber;
724
 
    END IF;
725
 
  END IF;
726
 
 
727
 
  IF (_fullname = '' AND (_first != '' OR _last != '')) THEN
728
 
    _fullname := TRIM(_first || ' ' || _last);
729
 
  END IF;
730
 
 
731
 
  IF (_custcount <= 0 AND _fullname != '') THEN
732
 
    SELECT count(*), cust_number INTO _custcount, _custnumber
733
 
    FROM custinfo
734
 
    WHERE (UPPER(cust_name)=_fullname)
735
 
    GROUP BY cust_number;
736
 
    IF (NOT FOUND) THEN
737
 
      _custcount := 0;
738
 
    ELSIF(_custcount = 1) THEN
739
 
      RETURN _custnumber;
740
 
    END IF;
741
 
  END IF;
742
 
 
743
 
  IF (_custcount > 1) THEN
744
 
    RAISE EXCEPTION 'Found % possible Customers for % and % and %',
745
 
                    _custcount, _email, _company, _fullname;
746
 
  END IF;
747
 
 
748
 
  IF (_custcount <= 0 AND _generate) THEN
749
 
    IF (_maxlength < _minlength) THEN
750
 
      RAISE EXCEPTION 'Fix getCustNumberFromInfo: max length < min length';
751
 
    END IF;
752
 
 
753
 
    IF (_company != '') THEN
754
 
      _candidate := _company;
755
 
    ELSIF (_email != '') THEN
756
 
      _candidate := SUBSTRING(_email FOR POSITION('@' IN _email) - 1);
757
 
    ELSIF (_last != '') THEN
758
 
      _candidate := _last;
759
 
      IF (_first != '') THEN
760
 
        _candidate := _candidate || _first;
761
 
      END IF;
762
 
    ELSIF (_fullname != '' AND (POSITION(' ' IN _fullname) > 0)) THEN
763
 
      _candidate := SUBSTRING(_fullname FROM POSITION(' ' IN _fullname) + 1) ||
764
 
                    SUBSTRING(_fullname FOR  POSITION(' ' IN _fullname) - 1);
765
 
    END IF;
766
 
    WHILE (POSITION(' ' IN _candidate) > 0) LOOP
767
 
      _candidate := SUBSTRING(_candidate FOR  POSITION(' ' IN _candidate) - 1) ||
768
 
                    SUBSTRING(_candidate FROM POSITION(' ' IN _candidate) + 1);
769
 
    END LOOP;
770
 
    FOR _counter IN _minlength.._maxlength LOOP
771
 
      _testme := SUBSTRING(_candidate FOR _counter);
772
 
      IF (NOT EXISTS(SELECT cust_number
773
 
                     FROM custinfo
774
 
                     WHERE (cust_number=_testme))) THEN
775
 
        _custnumber := _testme;
776
 
        EXIT;
777
 
      END IF;
778
 
    END LOOP;
779
 
    IF (_custnumber IS NULL OR _custnumber = '') THEN
780
 
      IF (LENGTH(_candidate) < _minlength) THEN
781
 
        _minlength := LENGTH(_candidate);
782
 
      END IF;
783
 
      FOR _counter IN _minlength.._maxlength LOOP
784
 
        _loopmax := _loopmax * 10 + 9;
785
 
        _numformat := _numformat || '0';
786
 
      END LOOP;
787
 
      FOR _counter IN 1.._loopmax LOOP
788
 
        _testme := SUBSTRING(_candidate FOR _minlength) ||
789
 
                   TRIM(TO_CHAR(_counter, _numformat));
790
 
        IF (NOT EXISTS(SELECT cust_number
791
 
                       FROM custinfo
792
 
                       WHERE (cust_number=_testme))) THEN
793
 
          _custnumber := _testme;
794
 
          EXIT;
795
 
        END IF;
796
 
      END LOOP;
797
 
    END IF;
798
 
    IF (_custnumber IS NULL OR _custnumber = '') THEN
799
 
      RAISE EXCEPTION 'Could not generate a new Customer Number';
800
 
    END IF;
801
 
  END IF;
802
 
 
803
 
  IF (_custnumber IS NULL OR _custnumber = '') THEN
804
 
    RAISE EXCEPTION 'Could not find Customer Number for % and % and %',
805
 
                    _email, _company, _fullname;
806
 
  END IF;
807
 
 
808
 
  RETURN _custnumber;
809
 
END;
810
 
$_$;
811
 
 
812
 
 
813
 
ALTER FUNCTION api.getcustnumberfrominfo(text, text, text, text, text, boolean) OWNER TO admin;
814
 
 
815
 
SET search_path = public, pg_catalog;
816
 
 
817
 
--
818
 
--
819
 
 
820
 
CREATE FUNCTION formatlocationname(integer) RETURNS text
821
 
    LANGUAGE plpgsql IMMUTABLE
822
 
    AS $_$
823
 
DECLARE
824
 
  pLocationid ALIAS FOR $1;
825
 
  _name TEXT;
826
 
  _r RECORD;
827
 
 
828
 
BEGIN
829
 
 
830
 
  SELECT location_aisle, location_rack,
831
 
         location_bin, location_name INTO _r
832
 
  FROM location
833
 
  WHERE (location_id=pLocationid);
834
 
  IF (FOUND) THEN
835
 
    IF (_r.location_aisle IS NOT NULL) THEN
836
 
      _name := _r.location_aisle;
837
 
    ELSE
838
 
      _name := '';
839
 
    END IF;
840
 
 
841
 
    IF (_r.location_rack IS NOT NULL) THEN
842
 
      _name := (_name || _r.location_rack);
843
 
    END IF;
844
 
 
845
 
    IF (_r.location_bin IS NOT NULL) THEN
846
 
      _name := (_name || _r.location_bin);
847
 
    END IF;
848
 
 
849
 
    IF (_r.location_name IS NOT NULL) THEN
850
 
      _name := (_name || _r.location_name);
851
 
    END IF;
852
 
 
853
 
    RETURN _name;
854
 
  ELSE
855
 
    RETURN 'N/A';
856
 
  END IF;
857
 
 
858
 
END;
859
 
$_$;
860
 
 
861
 
 
862
 
ALTER FUNCTION public.formatlocationname(integer) OWNER TO admin;
863
 
 
864
 
SET default_tablespace = '';
865
 
 
866
 
SET default_with_oids = false;
867
 
 
868
 
--
869
 
--
870
 
 
871
 
CREATE TABLE cntslip (
872
 
    cntslip_id integer DEFAULT nextval(('"cntslip_cntslip_id_seq"'::text)::regclass) NOT NULL,
873
 
    cntslip_cnttag_id integer,
874
 
    cntslip_entered timestamp with time zone,
875
 
    cntslip_posted boolean,
876
 
    cntslip_number text,
877
 
    cntslip_qty numeric(18,6),
878
 
    cntslip_comments text,
879
 
    cntslip_location_id integer,
880
 
    cntslip_lotserial text,
881
 
    cntslip_lotserial_expiration date,
882
 
    cntslip_lotserial_warrpurc date,
883
 
    cntslip_username text
884
 
);
885
 
 
886
 
 
887
 
ALTER TABLE public.cntslip OWNER TO admin;
888
 
 
889
 
--
890
 
--
891
 
 
892
 
COMMENT ON TABLE cntslip IS 'Count Slip information';
893
 
 
894
 
 
895
 
--
896
 
--
897
 
 
898
 
CREATE TABLE invcnt (
899
 
    invcnt_id integer DEFAULT nextval(('invcnt_invcnt_id_seq'::text)::regclass) NOT NULL,
900
 
    invcnt_itemsite_id integer,
901
 
    invcnt_tagdate timestamp with time zone,
902
 
    invcnt_cntdate timestamp with time zone,
903
 
    invcnt_qoh_before numeric(18,6),
904
 
    invcnt_qoh_after numeric(18,6),
905
 
    invcnt_matcost numeric(16,6),
906
 
    invcnt_posted boolean,
907
 
    invcnt_postdate timestamp with time zone,
908
 
    invcnt_comments text,
909
 
    invcnt_priority boolean,
910
 
    invcnt_tagnumber text,
911
 
    invcnt_invhist_id integer,
912
 
    invcnt_location_id integer,
913
 
    invcnt_cnt_username text,
914
 
    invcnt_post_username text,
915
 
    invcnt_tag_username text
916
 
);
917
 
 
918
 
 
919
 
ALTER TABLE public.invcnt OWNER TO admin;
920
 
 
921
 
--
922
 
--
923
 
 
924
 
COMMENT ON TABLE invcnt IS 'Count Tag information';
925
 
 
926
 
 
927
 
--
928
 
--
929
 
 
930
 
CREATE TABLE item (
931
 
    item_id integer DEFAULT nextval(('item_item_id_seq'::text)::regclass) NOT NULL,
932
 
    item_number text NOT NULL,
933
 
    item_descrip1 text NOT NULL,
934
 
    item_descrip2 text NOT NULL,
935
 
    item_classcode_id integer NOT NULL,
936
 
    item_picklist boolean DEFAULT true NOT NULL,
937
 
    item_comments text,
938
 
    item_sold boolean NOT NULL,
939
 
    item_fractional boolean NOT NULL,
940
 
    item_active boolean NOT NULL,
941
 
    item_type character(1) DEFAULT 'R'::bpchar NOT NULL,
942
 
    item_prodweight numeric(16,2) DEFAULT 0 NOT NULL,
943
 
    item_packweight numeric(16,2) DEFAULT 0 NOT NULL,
944
 
    item_prodcat_id integer NOT NULL,
945
 
    item_exclusive boolean DEFAULT false NOT NULL,
946
 
    item_listprice numeric(16,4) NOT NULL,
947
 
    item_config boolean DEFAULT false,
948
 
    item_extdescrip text,
949
 
    item_upccode text,
950
 
    item_maxcost numeric(16,6) DEFAULT 0 NOT NULL,
951
 
    item_inv_uom_id integer NOT NULL,
952
 
    item_price_uom_id integer NOT NULL,
953
 
    item_warrdays integer DEFAULT 0,
954
 
    item_freightclass_id integer,
955
 
    item_tax_recoverable boolean DEFAULT false NOT NULL,
956
 
    item_listcost numeric(16,6) DEFAULT 0.0 NOT NULL,
957
 
    CONSTRAINT item_item_number_check CHECK ((item_number <> ''::text)),
958
 
    CONSTRAINT item_item_type_check CHECK (((((((((((((item_type = 'P'::bpchar) OR (item_type = 'M'::bpchar)) OR (item_type = 'F'::bpchar)) OR (item_type = 'O'::bpchar)) OR (item_type = 'R'::bpchar)) OR (item_type = 'S'::bpchar)) OR (item_type = 'T'::bpchar)) OR (item_type = 'B'::bpchar)) OR (item_type = 'L'::bpchar)) OR (item_type = 'Y'::bpchar)) OR (item_type = 'C'::bpchar)) OR (item_type = 'K'::bpchar))),
959
 
    CONSTRAINT item_sold_check CHECK ((NOT (item_sold AND (item_prodcat_id = (-1)))))
960
 
);
961
 
 
962
 
 
963
 
ALTER TABLE public.item OWNER TO admin;
964
 
 
965
 
--
966
 
--
967
 
 
968
 
COMMENT ON TABLE item IS 'Item information';
969
 
 
970
 
 
971
 
--
972
 
--
973
 
 
974
 
COMMENT ON COLUMN item.item_maxcost IS 'Maximum cost for item.  Used to constrain purchase order price.';
975
 
 
976
 
 
977
 
--
978
 
--
979
 
 
980
 
COMMENT ON COLUMN item.item_listcost IS 'List cost for item.  Basis for markup pricing.';
981
 
 
982
 
 
983
 
--
984
 
--
985
 
 
986
 
CREATE TABLE itemsite (
987
 
    itemsite_id integer DEFAULT nextval(('itemsite_itemsite_id_seq'::text)::regclass) NOT NULL,
988
 
    itemsite_item_id integer NOT NULL,
989
 
    itemsite_warehous_id integer,
990
 
    itemsite_qtyonhand numeric(18,6) NOT NULL,
991
 
    itemsite_reorderlevel numeric(18,6) NOT NULL,
992
 
    itemsite_ordertoqty numeric(18,6) NOT NULL,
993
 
    itemsite_cyclecountfreq integer NOT NULL,
994
 
    itemsite_datelastcount date,
995
 
    itemsite_datelastused date,
996
 
    itemsite_loccntrl boolean NOT NULL,
997
 
    itemsite_safetystock numeric(18,6) NOT NULL,
998
 
    itemsite_minordqty numeric(18,6) NOT NULL,
999
 
    itemsite_multordqty numeric(18,6) NOT NULL,
1000
 
    itemsite_leadtime integer NOT NULL,
1001
 
    itemsite_abcclass character(1),
1002
 
    itemsite_issuemethod character(1),
1003
 
    itemsite_controlmethod character(1),
1004
 
    itemsite_active boolean NOT NULL,
1005
 
    itemsite_plancode_id integer NOT NULL,
1006
 
    itemsite_costcat_id integer NOT NULL,
1007
 
    itemsite_eventfence integer NOT NULL,
1008
 
    itemsite_sold boolean NOT NULL,
1009
 
    itemsite_stocked boolean NOT NULL,
1010
 
    itemsite_freeze boolean DEFAULT false NOT NULL,
1011
 
    itemsite_location_id integer NOT NULL,
1012
 
    itemsite_useparams boolean NOT NULL,
1013
 
    itemsite_useparamsmanual boolean NOT NULL,
1014
 
    itemsite_soldranking integer DEFAULT 1,
1015
 
    itemsite_createpr boolean,
1016
 
    itemsite_location text,
1017
 
    itemsite_location_comments text,
1018
 
    itemsite_notes text,
1019
 
    itemsite_perishable boolean NOT NULL,
1020
 
    itemsite_autoabcclass boolean NOT NULL,
1021
 
    itemsite_ordergroup integer DEFAULT 1 NOT NULL,
1022
 
    itemsite_disallowblankwip boolean DEFAULT false NOT NULL,
1023
 
    itemsite_maxordqty numeric(18,6) DEFAULT 0.0 NOT NULL,
1024
 
    itemsite_mps_timefence integer DEFAULT 0 NOT NULL,
1025
 
    itemsite_createwo boolean DEFAULT false NOT NULL,
1026
 
    itemsite_warrpurc boolean DEFAULT false NOT NULL,
1027
 
    itemsite_autoreg boolean DEFAULT false,
1028
 
    itemsite_costmethod character(1) NOT NULL,
1029
 
    itemsite_value numeric(12,2) NOT NULL,
1030
 
    itemsite_ordergroup_first boolean DEFAULT false NOT NULL,
1031
 
    itemsite_supply_itemsite_id integer,
1032
 
    itemsite_planning_type character(1) DEFAULT 'M'::bpchar NOT NULL,
1033
 
    itemsite_wosupply boolean DEFAULT false NOT NULL,
1034
 
    itemsite_posupply boolean DEFAULT false NOT NULL,
1035
 
    itemsite_lsseq_id integer,
1036
 
    itemsite_cosdefault character(1),
1037
 
    itemsite_createsopr boolean DEFAULT false,
1038
 
    itemsite_createsopo boolean DEFAULT false,
1039
 
    itemsite_dropship boolean DEFAULT false,
1040
 
    itemsite_recvlocation_id integer DEFAULT (-1) NOT NULL,
1041
 
    itemsite_issuelocation_id integer DEFAULT (-1) NOT NULL,
1042
 
    itemsite_location_dist boolean DEFAULT false NOT NULL,
1043
 
    itemsite_recvlocation_dist boolean DEFAULT false NOT NULL,
1044
 
    itemsite_issuelocation_dist boolean DEFAULT false NOT NULL,
1045
 
    CONSTRAINT itemsite_itemsite_abcclass_check CHECK (((((itemsite_abcclass = 'A'::bpchar) OR (itemsite_abcclass = 'B'::bpchar)) OR (itemsite_abcclass = 'C'::bpchar)) OR (itemsite_abcclass = 'T'::bpchar))),
1046
 
    CONSTRAINT itemsite_itemsite_controlmethod_check CHECK (((((itemsite_controlmethod = 'N'::bpchar) OR (itemsite_controlmethod = 'R'::bpchar)) OR (itemsite_controlmethod = 'S'::bpchar)) OR (itemsite_controlmethod = 'L'::bpchar))),
1047
 
    CONSTRAINT itemsite_itemsite_costmethod_check CHECK (((((itemsite_costmethod = 'N'::bpchar) OR (itemsite_costmethod = 'A'::bpchar)) OR (itemsite_costmethod = 'S'::bpchar)) OR (itemsite_costmethod = 'J'::bpchar))),
1048
 
    CONSTRAINT itemsite_itemsite_ordergroup_check CHECK ((itemsite_ordergroup > 0))
1049
 
);
1050
 
 
1051
 
 
1052
 
ALTER TABLE public.itemsite OWNER TO admin;
1053
 
 
1054
 
--
1055
 
--
1056
 
 
1057
 
COMMENT ON TABLE itemsite IS 'Item Site information';
1058
 
 
1059
 
 
1060
 
--
1061
 
--
1062
 
 
1063
 
COMMENT ON COLUMN itemsite.itemsite_lsseq_id IS 'Foreign key reference for automatic lot/serial numbering';
1064
 
 
1065
 
 
1066
 
--
1067
 
--
1068
 
 
1069
 
COMMENT ON COLUMN itemsite.itemsite_createsopr IS 'Used to flag Sales items that create P/Rs';
1070
 
 
1071
 
 
1072
 
--
1073
 
--
1074
 
 
1075
 
COMMENT ON COLUMN itemsite.itemsite_createsopo IS 'Used to flag Sales items that create P/Os';
1076
 
 
1077
 
 
1078
 
--
1079
 
--
1080
 
 
1081
 
COMMENT ON COLUMN itemsite.itemsite_dropship IS 'Used to flag Sales items to drop ship';
1082
 
 
1083
 
 
1084
 
--
1085
 
--
1086
 
 
1087
 
CREATE TABLE whsinfo (
1088
 
    warehous_id integer DEFAULT nextval(('warehous_warehous_id_seq'::text)::regclass) NOT NULL,
1089
 
    warehous_code text NOT NULL,
1090
 
    warehous_descrip text,
1091
 
    warehous_fob text,
1092
 
    warehous_active boolean,
1093
 
    warehous_counttag_prefix text,
1094
 
    warehous_counttag_number integer,
1095
 
    warehous_bol_prefix text,
1096
 
    warehous_bol_number integer,
1097
 
    warehous_shipping boolean,
1098
 
    warehous_useslips boolean,
1099
 
    warehous_usezones boolean,
1100
 
    warehous_aislesize integer,
1101
 
    warehous_aislealpha boolean,
1102
 
    warehous_racksize integer,
1103
 
    warehous_rackalpha boolean,
1104
 
    warehous_binsize integer,
1105
 
    warehous_binalpha boolean,
1106
 
    warehous_locationsize integer,
1107
 
    warehous_locationalpha boolean,
1108
 
    warehous_enforcearbl boolean,
1109
 
    warehous_default_accnt_id integer,
1110
 
    warehous_shipping_commission numeric(8,4) DEFAULT 0.00,
1111
 
    warehous_cntct_id integer,
1112
 
    warehous_addr_id integer,
1113
 
    warehous_transit boolean DEFAULT false NOT NULL,
1114
 
    warehous_shipform_id integer,
1115
 
    warehous_shipvia_id integer,
1116
 
    warehous_shipcomments text,
1117
 
    warehous_costcat_id integer,
1118
 
    warehous_sitetype_id integer,
1119
 
    warehous_taxzone_id integer,
1120
 
    warehous_sequence integer DEFAULT 0 NOT NULL,
1121
 
    CONSTRAINT whsinfo_check CHECK (((warehous_transit AND (warehous_costcat_id IS NOT NULL)) OR (NOT warehous_transit))),
1122
 
    CONSTRAINT whsinfo_warehous_code_check CHECK ((warehous_code <> ''::text))
1123
 
);
1124
 
 
1125
 
 
1126
 
ALTER TABLE public.whsinfo OWNER TO admin;
1127
 
 
1128
 
--
1129
 
--
1130
 
 
1131
 
COMMENT ON TABLE whsinfo IS 'Warehouse information';
1132
 
 
1133
 
 
1134
 
SET search_path = api, pg_catalog;
1135
 
 
1136
 
--
1137
 
--
1138
 
 
1139
 
CREATE VIEW physinvcount AS
1140
 
    SELECT whsinfo.warehous_code AS site, item.item_number, invcnt.invcnt_tagnumber AS tag_number, cntslip.cntslip_qty AS quantity, public.formatlocationname(cntslip.cntslip_location_id) AS location, cntslip.cntslip_lotserial AS lotserial, cntslip.cntslip_comments AS comment FROM ((((public.invcnt JOIN public.itemsite ON ((itemsite.itemsite_id = invcnt.invcnt_itemsite_id))) JOIN public.whsinfo ON ((whsinfo.warehous_id = itemsite.itemsite_warehous_id))) JOIN public.item ON ((item.item_id = itemsite.itemsite_item_id))) LEFT JOIN public.cntslip ON ((cntslip.cntslip_cnttag_id = invcnt.invcnt_id)));
1141
 
 
1142
 
 
1143
 
ALTER TABLE api.physinvcount OWNER TO admin;
1144
 
 
1145
 
--
1146
 
--
1147
 
 
1148
 
COMMENT ON VIEW physinvcount IS 'Physical Inventory Count Tag and Slip';
1149
 
 
1150
 
 
1151
 
--
1152
 
--
1153
 
 
1154
 
CREATE FUNCTION insertphysinvcount(physinvcount) RETURNS boolean
1155
 
    LANGUAGE plpgsql
1156
 
    AS $_$
1157
 
DECLARE
1158
 
  pNEW ALIAS FOR $1;
1159
 
  _itemid INTEGER;
1160
 
  _type TEXT;
1161
 
  _siteid INTEGER;
1162
 
  _itemsiteid INTEGER;
1163
 
  _controlmethod TEXT;
1164
 
  _loccntrl BOOLEAN;
1165
 
  _locationid INTEGER;
1166
 
  _lsid INTEGER;
1167
 
  _invcntid INTEGER;
1168
 
  _cntslipid INTEGER;
1169
 
  _result INTEGER;
1170
 
 
1171
 
BEGIN
1172
 
 
1173
 
  -- Check Item
1174
 
  SELECT item_id, item_type INTO _itemid, _type
1175
 
  FROM item
1176
 
  WHERE (item_number=UPPER(pNEW.item_number));
1177
 
  IF (NOT FOUND OR _type IN ('F', 'R', 'L','J', 'K')) THEN
1178
 
    SELECT item_id, item_type INTO _itemid, _type
1179
 
    FROM item
1180
 
    WHERE (item_upccode=pNEW.item_number);
1181
 
    IF (NOT FOUND OR _type IN ('F', 'R', 'L','J', 'K')) THEN
1182
 
      RAISE EXCEPTION 'Function insertPhysInvCount failed because Item % not found or invalid type', pNEW.item_number;
1183
 
    END IF;
1184
 
  END IF;
1185
 
 
1186
 
  -- Check Site
1187
 
  SELECT warehous_id INTO _siteid
1188
 
  FROM whsinfo
1189
 
  WHERE (warehous_code=COALESCE(pNEW.site, (SELECT warehous_code
1190
 
                                            FROM usrpref,whsinfo
1191
 
                                            WHERE (usrpref_username=getEffectiveXtUser())
1192
 
                                              AND (usrpref_name='PreferredWarehouse')
1193
 
                                              AND (warehous_id=CAST(usrpref_value AS INTEGER)))));
1194
 
  IF (NOT FOUND) THEN
1195
 
    RAISE EXCEPTION 'Function insertPhysInvCount failed because Site % not found', pNEW.site;
1196
 
  END IF;
1197
 
 
1198
 
  -- Check Itemsite
1199
 
  SELECT itemsite_id, itemsite_controlmethod, itemsite_loccntrl INTO _itemsiteid, _controlmethod, _loccntrl
1200
 
  FROM itemsite
1201
 
  WHERE (itemsite_item_id=_itemid)
1202
 
    AND (itemsite_warehous_id=_siteid);
1203
 
  IF (NOT FOUND) THEN
1204
 
    RAISE EXCEPTION 'Function insertPhysInvCount failed because Itemsite %, % not found', pNEW.site, pNEW.item_number;
1205
 
  END IF;
1206
 
  IF (_controlmethod = 'N') THEN
1207
 
    RAISE EXCEPTION 'Function insertPhysInvCount failed because Itemsite %, % not inventory control method', pNEW.site, pNEW.item_number;
1208
 
  END IF;
1209
 
  IF (_controlmethod IN ('L', 'S') AND COALESCE(pNEW.lotserial, '') = '') THEN
1210
 
    RAISE EXCEPTION 'Function insertPhysInvCount failed because Itemsite %, % lot/serial controlled and lotserial not provided', pNEW.site, pNEW.item_number;
1211
 
  END IF;
1212
 
  IF (_controlmethod = 'S') THEN
1213
 
    -- Check for unique serial id
1214
 
    SELECT ls_id INTO _lsid
1215
 
    FROM ls
1216
 
    WHERE (ls_number=pNEW.lotserial);
1217
 
    IF (FOUND) THEN
1218
 
      RAISE EXCEPTION 'Function insertPhysInvCount failed because Serial %, %, % not unique', pNEW.site, pNEW.item_number, pNEW.lotserial;
1219
 
    END IF;
1220
 
  END IF;
1221
 
  IF (_loccntrl) THEN
1222
 
    IF (pNEW.location IS NULL) THEN
1223
 
      RAISE EXCEPTION 'Function insertPhysInvCount failed because Itemsite %, % multi location and location not provided', pNEW.site, pNEW.item_number;
1224
 
    ELSE
1225
 
      -- Check Location
1226
 
      SELECT location_id INTO _locationid
1227
 
      FROM location
1228
 
      WHERE (location_id=getLocationId(pNEW.site, pNEW.location));
1229
 
      IF (NOT FOUND) THEN
1230
 
        RAISE EXCEPTION 'Function insertPhysInvCount failed because Location %, % not found', pNEW.site, pNEW.location;
1231
 
      END IF;
1232
 
    END IF;
1233
 
  END IF;
1234
 
 
1235
 
  -- Create Count Tag
1236
 
  SELECT CreateCountTag(_itemsiteid, pNEW.comment, FALSE, FALSE) INTO _invcntid;
1237
 
  IF (_invcntid <= 0) THEN
1238
 
    RAISE EXCEPTION 'Function insertPhysInvCount failed because CreateCountTag failed for Itemsite %, %', pNEW.site, pNEW.item_number;
1239
 
  END IF;
1240
 
 
1241
 
  -- Create Count Slip
1242
 
  INSERT INTO cntslip
1243
 
  ( cntslip_cnttag_id,
1244
 
    cntslip_username, cntslip_entered, cntslip_posted,
1245
 
    cntslip_number, cntslip_qty,
1246
 
    cntslip_location_id, cntslip_lotserial,
1247
 
    cntslip_lotserial_expiration,
1248
 
    cntslip_lotserial_warrpurc,
1249
 
    cntslip_comments )
1250
 
  VALUES
1251
 
  ( _invcntid,
1252
 
    getEffectiveXtUser(), CURRENT_TIMESTAMP, FALSE,
1253
 
    'N/A', pNEW.quantity,
1254
 
    COALESCE(_locationid, -1), pNEW.lotserial,
1255
 
    NULL,
1256
 
    NULL,
1257
 
    pNEW.comment )
1258
 
  RETURNING cntslip_id INTO _cntslipid;
1259
 
 
1260
 
  -- Post Count Slip
1261
 
  SELECT postCountSlip(_cntslipid) INTO _result;
1262
 
  IF (_result < 0) THEN
1263
 
    RAISE EXCEPTION 'Function insertPhysInvCount failed because postCountSlip failed for Itemsite %, %, %', pNEW.site, pNEW.item_number, _result;
1264
 
  END IF;
1265
 
 
1266
 
  RETURN TRUE;
1267
 
END;
1268
 
$_$;
1269
 
 
1270
 
 
1271
 
ALTER FUNCTION api.insertphysinvcount(physinvcount) OWNER TO admin;
1272
 
 
1273
 
SET search_path = public, pg_catalog;
1274
 
 
1275
 
--
1276
 
--
1277
 
 
1278
 
CREATE FUNCTION basecurrid() RETURNS integer
1279
 
    LANGUAGE plpgsql IMMUTABLE
1280
 
    AS $$
1281
 
DECLARE
1282
 
  returnVal INTEGER;
1283
 
BEGIN
1284
 
  SELECT curr_id INTO returnVal
1285
 
    FROM curr_symbol
1286
 
   WHERE curr_base = TRUE;
1287
 
  IF NOT FOUND THEN
1288
 
    RAISE EXCEPTION 'No base currency found';
1289
 
  END IF;
1290
 
  RETURN returnVal;
1291
 
END;
1292
 
$$;
1293
 
 
1294
 
 
1295
 
ALTER FUNCTION public.basecurrid() OWNER TO admin;
1296
 
 
1297
 
--
1298
 
--
1299
 
 
1300
 
CREATE FUNCTION formatglaccount(integer) RETURNS text
1301
 
    LANGUAGE plpgsql IMMUTABLE
1302
 
    AS $_$
1303
 
DECLARE
1304
 
  pAccntid ALIAS FOR $1;
1305
 
  _accnt RECORD;
1306
 
 
1307
 
BEGIN
1308
 
 
1309
 
  SELECT COALESCE(accnt_company, '') AS accnt_company,
1310
 
         COALESCE(accnt_profit, '') AS accnt_profit,
1311
 
         accnt_number,
1312
 
         COALESCE(accnt_sub, '') AS accnt_sub INTO _accnt
1313
 
  FROM accnt
1314
 
  WHERE (accnt_id=pAccntid);
1315
 
 
1316
 
  IF (NOT FOUND) THEN
1317
 
    RETURN 'Error';
1318
 
  END IF;
1319
 
 
1320
 
  RETURN formatGlAccount(_accnt.accnt_company, _accnt.accnt_profit, _accnt.accnt_number, _accnt.accnt_sub);
1321
 
 
1322
 
END;
1323
 
$_$;
1324
 
 
1325
 
 
1326
 
ALTER FUNCTION public.formatglaccount(integer) OWNER TO admin;
1327
 
 
1328
 
--
1329
 
--
1330
 
 
1331
 
CREATE FUNCTION formatsolinenumber(integer) RETURNS text
1332
 
    LANGUAGE plpgsql
1333
 
    AS $_$
1334
 
DECLARE
1335
 
  pSoitemid ALIAS FOR $1;
1336
 
  _r RECORD;
1337
 
 
1338
 
BEGIN
1339
 
 
1340
 
  SELECT coitem_linenumber, coitem_subnumber
1341
 
    INTO _r
1342
 
    FROM coitem
1343
 
   WHERE(coitem_id=pSoitemid);
1344
 
 
1345
 
  IF(NOT FOUND) THEN
1346
 
    RETURN NULL;
1347
 
  END IF;
1348
 
 
1349
 
  IF(COALESCE(_r.coitem_subnumber, 0) > 0) THEN
1350
 
    RETURN _r.coitem_linenumber || '.' || _r.coitem_subnumber;
1351
 
  END IF;
1352
 
 
1353
 
  RETURN _r.coitem_linenumber; 
1354
 
END;
1355
 
$_$;
1356
 
 
1357
 
 
1358
 
ALTER FUNCTION public.formatsolinenumber(integer) OWNER TO admin;
1359
 
 
1360
 
--
1361
 
--
1362
 
 
1363
 
CREATE FUNCTION geteffectivextuser() RETURNS text
1364
 
    LANGUAGE plpgsql STABLE
1365
 
    AS $$
1366
 
BEGIN
1367
 
/*
1368
 
  The default return value of this function is simply
1369
 
  the user currently connected.
1370
 
  
1371
 
  Overload this function from another schema 
1372
 
  to implement specific user handling from an external 
1373
 
  application that uses connection pooling. 
1374
 
  Use setEffectiveXtUser(text) to create a temporary table that 
1375
 
  inserts user data that can in turn be used as a lookup 
1376
 
  reference for an over loaded version of this function like so:
1377
 
  
1378
 
  SELECT effective_value
1379
 
  FROM effective_user
1380
 
  WHERE effective_key = 'username'
1381
 
*/
1382
 
 
1383
 
  RETURN CURRENT_USER;
1384
 
 
1385
 
END;
1386
 
$$;
1387
 
 
1388
 
 
1389
 
ALTER FUNCTION public.geteffectivextuser() OWNER TO admin;
1390
 
 
1391
 
--
1392
 
--
1393
 
 
1394
 
CREATE FUNCTION getitemtaxtype(integer, integer) RETURNS integer
1395
 
    LANGUAGE plpgsql
1396
 
    AS $_$
1397
 
DECLARE
1398
 
  pItemid ALIAS FOR $1;
1399
 
  pTaxzoneid ALIAS FOR $2;
1400
 
  _taxtypeid INTEGER;
1401
 
BEGIN
1402
 
  SELECT itemtax_taxtype_id
1403
 
    INTO _taxtypeid
1404
 
    FROM itemtax
1405
 
   WHERE ((itemtax_item_id=pItemid)
1406
 
     AND  (itemtax_taxzone_id=pTaxzoneid));
1407
 
  IF (NOT FOUND) THEN
1408
 
    SELECT itemtax_taxtype_id
1409
 
      INTO _taxtypeid
1410
 
      FROM itemtax
1411
 
     WHERE ((itemtax_item_id=pItemid)
1412
 
       AND  (itemtax_taxzone_id IS NULL));
1413
 
    IF (NOT FOUND) THEN
1414
 
      RETURN NULL;
1415
 
    END IF;
1416
 
  END IF;
1417
 
 
1418
 
  RETURN _taxtypeid;
1419
 
END;
1420
 
$_$;
1421
 
 
1422
 
 
1423
 
ALTER FUNCTION public.getitemtaxtype(integer, integer) OWNER TO admin;
1424
 
 
1425
 
--
1426
 
--
1427
 
 
1428
 
CREATE TABLE cohead (
1429
 
    cohead_id integer DEFAULT nextval(('cohead_cohead_id_seq'::text)::regclass) NOT NULL,
1430
 
    cohead_number text NOT NULL,
1431
 
    cohead_cust_id integer NOT NULL,
1432
 
    cohead_custponumber text,
1433
 
    cohead_type character(1),
1434
 
    cohead_orderdate date,
1435
 
    cohead_warehous_id integer,
1436
 
    cohead_shipto_id integer,
1437
 
    cohead_shiptoname text,
1438
 
    cohead_shiptoaddress1 text,
1439
 
    cohead_shiptoaddress2 text,
1440
 
    cohead_shiptoaddress3 text,
1441
 
    cohead_shiptoaddress4 text,
1442
 
    cohead_shiptoaddress5 text,
1443
 
    cohead_salesrep_id integer NOT NULL,
1444
 
    cohead_terms_id integer NOT NULL,
1445
 
    cohead_fob text,
1446
 
    cohead_shipvia text,
1447
 
    cohead_shiptocity text,
1448
 
    cohead_shiptostate text,
1449
 
    cohead_shiptozipcode text,
1450
 
    cohead_freight numeric(16,4) NOT NULL,
1451
 
    cohead_misc numeric(16,4) DEFAULT 0 NOT NULL,
1452
 
    cohead_imported boolean DEFAULT false,
1453
 
    cohead_ordercomments text,
1454
 
    cohead_shipcomments text,
1455
 
    cohead_shiptophone text,
1456
 
    cohead_shipchrg_id integer,
1457
 
    cohead_shipform_id integer,
1458
 
    cohead_billtoname text,
1459
 
    cohead_billtoaddress1 text,
1460
 
    cohead_billtoaddress2 text,
1461
 
    cohead_billtoaddress3 text,
1462
 
    cohead_billtocity text,
1463
 
    cohead_billtostate text,
1464
 
    cohead_billtozipcode text,
1465
 
    cohead_misc_accnt_id integer,
1466
 
    cohead_misc_descrip text,
1467
 
    cohead_commission numeric(16,4),
1468
 
    cohead_miscdate date,
1469
 
    cohead_holdtype character(1),
1470
 
    cohead_packdate date,
1471
 
    cohead_prj_id integer,
1472
 
    cohead_wasquote boolean DEFAULT false NOT NULL,
1473
 
    cohead_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL,
1474
 
    cohead_shipcomplete boolean DEFAULT false NOT NULL,
1475
 
    cohead_created timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone,
1476
 
    cohead_creator text DEFAULT geteffectivextuser(),
1477
 
    cohead_quote_number text,
1478
 
    cohead_billtocountry text,
1479
 
    cohead_shiptocountry text,
1480
 
    cohead_curr_id integer DEFAULT basecurrid(),
1481
 
    cohead_calcfreight boolean DEFAULT false NOT NULL,
1482
 
    cohead_shipto_cntct_id integer,
1483
 
    cohead_shipto_cntct_honorific text,
1484
 
    cohead_shipto_cntct_first_name text,
1485
 
    cohead_shipto_cntct_middle text,
1486
 
    cohead_shipto_cntct_last_name text,
1487
 
    cohead_shipto_cntct_suffix text,
1488
 
    cohead_shipto_cntct_phone text,
1489
 
    cohead_shipto_cntct_title text,
1490
 
    cohead_shipto_cntct_fax text,
1491
 
    cohead_shipto_cntct_email text,
1492
 
    cohead_billto_cntct_id integer,
1493
 
    cohead_billto_cntct_honorific text,
1494
 
    cohead_billto_cntct_first_name text,
1495
 
    cohead_billto_cntct_middle text,
1496
 
    cohead_billto_cntct_last_name text,
1497
 
    cohead_billto_cntct_suffix text,
1498
 
    cohead_billto_cntct_phone text,
1499
 
    cohead_billto_cntct_title text,
1500
 
    cohead_billto_cntct_fax text,
1501
 
    cohead_billto_cntct_email text,
1502
 
    cohead_taxzone_id integer,
1503
 
    cohead_taxtype_id integer,
1504
 
    cohead_ophead_id integer,
1505
 
    cohead_status character(1) DEFAULT 'O'::bpchar NOT NULL,
1506
 
    cohead_saletype_id integer,
1507
 
    cohead_shipzone_id integer,
1508
 
    CONSTRAINT cohead_check CHECK (((cohead_misc = (0)::numeric) OR ((cohead_misc <> (0)::numeric) AND (cohead_misc_accnt_id IS NOT NULL)))),
1509
 
    CONSTRAINT cohead_cohead_number_check CHECK ((cohead_number <> ''::text))
1510
 
);
1511
 
 
1512
 
 
1513
 
ALTER TABLE public.cohead OWNER TO admin;
1514
 
 
1515
 
--
1516
 
--
1517
 
 
1518
 
COMMENT ON TABLE cohead IS 'Sales Order header information';
1519
 
 
1520
 
 
1521
 
--
1522
 
--
1523
 
 
1524
 
COMMENT ON COLUMN cohead.cohead_saletype_id IS 'Associated sale type for sales order.';
1525
 
 
1526
 
 
1527
 
--
1528
 
--
1529
 
 
1530
 
COMMENT ON COLUMN cohead.cohead_shipzone_id IS 'Associated shipping zone for sales order.';
1531
 
 
1532
 
 
1533
 
--
1534
 
--
1535
 
 
1536
 
CREATE TABLE coitem (
1537
 
    coitem_id integer DEFAULT nextval(('coitem_coitem_id_seq'::text)::regclass) NOT NULL,
1538
 
    coitem_cohead_id integer,
1539
 
    coitem_linenumber integer NOT NULL,
1540
 
    coitem_itemsite_id integer,
1541
 
    coitem_status character(1),
1542
 
    coitem_scheddate date,
1543
 
    coitem_promdate date,
1544
 
    coitem_qtyord numeric(18,6) NOT NULL,
1545
 
    coitem_unitcost numeric(16,6) NOT NULL,
1546
 
    coitem_price numeric(16,4) NOT NULL,
1547
 
    coitem_custprice numeric(16,4) NOT NULL,
1548
 
    coitem_qtyshipped numeric(18,6) NOT NULL,
1549
 
    coitem_order_id integer,
1550
 
    coitem_memo text,
1551
 
    coitem_imported boolean DEFAULT false,
1552
 
    coitem_qtyreturned numeric(18,6),
1553
 
    coitem_closedate timestamp with time zone,
1554
 
    coitem_custpn text,
1555
 
    coitem_order_type character(1),
1556
 
    coitem_close_username text,
1557
 
    coitem_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL,
1558
 
    coitem_substitute_item_id integer,
1559
 
    coitem_created timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone,
1560
 
    coitem_creator text DEFAULT geteffectivextuser(),
1561
 
    coitem_prcost numeric(16,6),
1562
 
    coitem_qty_uom_id integer NOT NULL,
1563
 
    coitem_qty_invuomratio numeric(20,10) NOT NULL,
1564
 
    coitem_price_uom_id integer NOT NULL,
1565
 
    coitem_price_invuomratio numeric(20,10) NOT NULL,
1566
 
    coitem_warranty boolean DEFAULT false NOT NULL,
1567
 
    coitem_cos_accnt_id integer,
1568
 
    coitem_qtyreserved numeric(18,6) DEFAULT 0.0 NOT NULL,
1569
 
    coitem_subnumber integer DEFAULT 0 NOT NULL,
1570
 
    coitem_firm boolean DEFAULT false NOT NULL,
1571
 
    coitem_taxtype_id integer,
1572
 
    coitem_rev_accnt_id integer,
1573
 
    coitem_pricemode character(1) DEFAULT 'D'::bpchar NOT NULL,
1574
 
    CONSTRAINT coitem_coitem_status_check CHECK ((((coitem_status = 'O'::bpchar) OR (coitem_status = 'C'::bpchar)) OR (coitem_status = 'X'::bpchar))),
1575
 
    CONSTRAINT valid_coitem_pricemode CHECK ((coitem_pricemode = ANY (ARRAY['D'::bpchar, 'M'::bpchar])))
1576
 
);
1577
 
 
1578
 
 
1579
 
ALTER TABLE public.coitem OWNER TO admin;
1580
 
 
1581
 
--
1582
 
--
1583
 
 
1584
 
COMMENT ON TABLE coitem IS 'Sales Order Line Item information';
1585
 
 
1586
 
 
1587
 
--
1588
 
--
1589
 
 
1590
 
COMMENT ON COLUMN coitem.coitem_pricemode IS 'Pricing mode for sales order item.  Valid values are D-discount, and M-markup';
1591
 
 
1592
 
 
1593
 
--
1594
 
--
1595
 
 
1596
 
CREATE TABLE pohead (
1597
 
    pohead_id integer DEFAULT nextval(('pohead_pohead_id_seq'::text)::regclass) NOT NULL,
1598
 
    pohead_status character(1),
1599
 
    pohead_number text NOT NULL,
1600
 
    pohead_orderdate date,
1601
 
    pohead_vend_id integer,
1602
 
    pohead_fob text,
1603
 
    pohead_shipvia text,
1604
 
    pohead_comments text,
1605
 
    pohead_freight numeric(16,2) DEFAULT 0,
1606
 
    pohead_printed boolean DEFAULT false,
1607
 
    pohead_terms_id integer,
1608
 
    pohead_warehous_id integer,
1609
 
    pohead_vendaddr_id integer,
1610
 
    pohead_agent_username text,
1611
 
    pohead_curr_id integer DEFAULT basecurrid(),
1612
 
    pohead_saved boolean DEFAULT true NOT NULL,
1613
 
    pohead_taxzone_id integer,
1614
 
    pohead_taxtype_id integer,
1615
 
    pohead_dropship boolean DEFAULT false,
1616
 
    pohead_vend_cntct_id integer,
1617
 
    pohead_vend_cntct_honorific text,
1618
 
    pohead_vend_cntct_first_name text,
1619
 
    pohead_vend_cntct_middle text,
1620
 
    pohead_vend_cntct_last_name text,
1621
 
    pohead_vend_cntct_suffix text,
1622
 
    pohead_vend_cntct_phone text,
1623
 
    pohead_vend_cntct_title text,
1624
 
    pohead_vend_cntct_fax text,
1625
 
    pohead_vend_cntct_email text,
1626
 
    pohead_vendaddress1 text,
1627
 
    pohead_vendaddress2 text,
1628
 
    pohead_vendaddress3 text,
1629
 
    pohead_vendcity text,
1630
 
    pohead_vendstate text,
1631
 
    pohead_vendzipcode text,
1632
 
    pohead_vendcountry text,
1633
 
    pohead_shipto_cntct_id integer,
1634
 
    pohead_shipto_cntct_honorific text,
1635
 
    pohead_shipto_cntct_first_name text,
1636
 
    pohead_shipto_cntct_middle text,
1637
 
    pohead_shipto_cntct_last_name text,
1638
 
    pohead_shipto_cntct_suffix text,
1639
 
    pohead_shipto_cntct_phone text,
1640
 
    pohead_shipto_cntct_title text,
1641
 
    pohead_shipto_cntct_fax text,
1642
 
    pohead_shipto_cntct_email text,
1643
 
    pohead_shiptoaddress_id integer,
1644
 
    pohead_shiptoaddress1 text,
1645
 
    pohead_shiptoaddress2 text,
1646
 
    pohead_shiptoaddress3 text,
1647
 
    pohead_shiptocity text,
1648
 
    pohead_shiptostate text,
1649
 
    pohead_shiptozipcode text,
1650
 
    pohead_shiptocountry text,
1651
 
    pohead_cohead_id integer,
1652
 
    pohead_released date,
1653
 
    pohead_shiptoname text,
1654
 
    CONSTRAINT pohead_pohead_number_check CHECK ((pohead_number <> ''::text)),
1655
 
    CONSTRAINT pohead_pohead_status_check CHECK ((((pohead_status = 'U'::bpchar) OR (pohead_status = 'O'::bpchar)) OR (pohead_status = 'C'::bpchar)))
1656
 
);
1657
 
 
1658
 
 
1659
 
ALTER TABLE public.pohead OWNER TO admin;
1660
 
 
1661
 
--
1662
 
--
1663
 
 
1664
 
COMMENT ON TABLE pohead IS 'Purchase Order header information';
1665
 
 
1666
 
 
1667
 
--
1668
 
--
1669
 
 
1670
 
CREATE TABLE poitem (
1671
 
    poitem_id integer DEFAULT nextval(('poitem_poitem_id_seq'::text)::regclass) NOT NULL,
1672
 
    poitem_status character(1),
1673
 
    poitem_pohead_id integer,
1674
 
    poitem_linenumber integer,
1675
 
    poitem_duedate date,
1676
 
    poitem_itemsite_id integer,
1677
 
    poitem_vend_item_descrip text,
1678
 
    poitem_vend_uom text,
1679
 
    poitem_invvenduomratio numeric(20,10),
1680
 
    poitem_qty_ordered numeric(18,6) NOT NULL,
1681
 
    poitem_qty_received numeric(18,6) DEFAULT 0.0 NOT NULL,
1682
 
    poitem_qty_returned numeric(18,6) DEFAULT 0.0 NOT NULL,
1683
 
    poitem_qty_vouchered numeric(18,6) DEFAULT 0.0 NOT NULL,
1684
 
    poitem_unitprice numeric(16,6),
1685
 
    poitem_vend_item_number text,
1686
 
    poitem_comments text,
1687
 
    poitem_qty_toreceive numeric(18,6),
1688
 
    poitem_expcat_id integer,
1689
 
    poitem_itemsrc_id integer,
1690
 
    poitem_freight numeric(16,4) DEFAULT 0.0 NOT NULL,
1691
 
    poitem_freight_received numeric(16,4) DEFAULT 0.0 NOT NULL,
1692
 
    poitem_freight_vouchered numeric(16,4) DEFAULT 0.0 NOT NULL,
1693
 
    poitem_prj_id integer,
1694
 
    poitem_stdcost numeric(16,6),
1695
 
    poitem_bom_rev_id integer,
1696
 
    poitem_boo_rev_id integer,
1697
 
    poitem_manuf_name text,
1698
 
    poitem_manuf_item_number text,
1699
 
    poitem_manuf_item_descrip text,
1700
 
    poitem_taxtype_id integer,
1701
 
    poitem_tax_recoverable boolean DEFAULT true NOT NULL,
1702
 
    poitem_rlsd_duedate date,
1703
 
    poitem_order_id integer,
1704
 
    poitem_order_type character(1),
1705
 
    CONSTRAINT poitem_poitem_status_check CHECK ((((poitem_status = 'U'::bpchar) OR (poitem_status = 'O'::bpchar)) OR (poitem_status = 'C'::bpchar)))
1706
 
);
1707
 
 
1708
 
 
1709
 
ALTER TABLE public.poitem OWNER TO admin;
1710
 
 
1711
 
--
1712
 
--
1713
 
 
1714
 
COMMENT ON TABLE poitem IS 'Purchase Order Line Item information';
1715
 
 
1716
 
 
1717
 
--
1718
 
--
1719
 
 
1720
 
CREATE TABLE taxtype (
1721
 
    taxtype_id integer NOT NULL,
1722
 
    taxtype_name text NOT NULL,
1723
 
    taxtype_descrip text,
1724
 
    taxtype_sys boolean DEFAULT false NOT NULL,
1725
 
    CONSTRAINT taxtype_taxtype_name_check CHECK ((taxtype_name <> ''::text))
1726
 
);
1727
 
 
1728
 
 
1729
 
ALTER TABLE public.taxtype OWNER TO admin;
1730
 
 
1731
 
--
1732
 
--
1733
 
 
1734
 
COMMENT ON TABLE taxtype IS 'The list of Tax Types';
1735
 
 
1736
 
 
1737
 
--
1738
 
--
1739
 
 
1740
 
CREATE TABLE uom (
1741
 
    uom_id integer NOT NULL,
1742
 
    uom_name text NOT NULL,
1743
 
    uom_descrip text,
1744
 
    uom_item_weight boolean DEFAULT false NOT NULL,
1745
 
    CONSTRAINT uom_uom_name_check CHECK ((uom_name <> ''::text))
1746
 
);
1747
 
 
1748
 
 
1749
 
ALTER TABLE public.uom OWNER TO admin;
1750
 
 
1751
 
--
1752
 
--
1753
 
 
1754
 
COMMENT ON TABLE uom IS 'Unit of Measure information';
1755
 
 
1756
 
 
1757
 
SET search_path = api, pg_catalog;
1758
 
 
1759
 
--
1760
 
--
1761
 
 
1762
 
CREATE VIEW salesline AS
1763
 
    SELECT (cohead.cohead_number)::character varying AS order_number, (public.formatsolinenumber(coitem.coitem_id))::character varying AS line_number, l.item_number, coitem.coitem_custpn AS customer_pn, s.item_number AS substitute_for, whsinfo.warehous_code AS sold_from_site, coitem.coitem_status AS status, coitem.coitem_qtyord AS qty_ordered, q.uom_name AS qty_uom, coitem.coitem_price AS net_unit_price, p.uom_name AS price_uom, coitem.coitem_scheddate AS scheduled_date, coitem.coitem_promdate AS promise_date, coitem.coitem_warranty AS warranty, COALESCE((SELECT taxtype.taxtype_name FROM public.taxtype WHERE (taxtype.taxtype_id = public.getitemtaxtype(l.item_id, cohead.cohead_taxzone_id))), 'None'::text) AS tax_type, CASE WHEN (coitem.coitem_price = (0)::numeric) THEN '100'::text WHEN (coitem.coitem_custprice = (0)::numeric) THEN 'N/A'::text ELSE (round((((1)::numeric - (coitem.coitem_price / coitem.coitem_custprice)) * (100)::numeric), 4))::text END AS discount_pct_from_list, CASE WHEN (coitem.coitem_order_id = (-1)) THEN false ELSE true END AS create_order, CASE WHEN (coitem.coitem_order_id = (-1)) THEN ''::text ELSE ((pohead.pohead_number || '-'::text) || poitem.poitem_linenumber) END AS create_po, coitem.coitem_prcost AS overwrite_po_price, coitem.coitem_memo AS notes, CASE WHEN (coitem.coitem_cos_accnt_id IS NOT NULL) THEN public.formatglaccount(coitem.coitem_cos_accnt_id) ELSE NULL::text END AS alternate_cos_account, CASE WHEN (coitem.coitem_rev_accnt_id IS NOT NULL) THEN public.formatglaccount(coitem.coitem_rev_accnt_id) ELSE NULL::text END AS alternate_rev_account FROM public.cohead, (((public.coitem LEFT JOIN public.itemsite isb ON ((coitem.coitem_substitute_item_id = isb.itemsite_id))) LEFT JOIN public.item s ON ((isb.itemsite_item_id = s.item_id))) LEFT JOIN (public.poitem JOIN public.pohead ON ((poitem.poitem_pohead_id = pohead.pohead_id))) ON ((poitem.poitem_id = coitem.coitem_order_id))), public.itemsite il, public.item l, public.whsinfo, public.uom q, public.uom p WHERE ((((((cohead.cohead_id = coitem.coitem_cohead_id) AND (coitem.coitem_itemsite_id = il.itemsite_id)) AND (il.itemsite_item_id = l.item_id)) AND (il.itemsite_warehous_id = whsinfo.warehous_id)) AND (coitem.coitem_qty_uom_id = q.uom_id)) AND (coitem.coitem_price_uom_id = p.uom_id)) ORDER BY cohead.cohead_number, coitem.coitem_linenumber, coitem.coitem_subnumber;
1764
 
 
1765
 
 
1766
 
ALTER TABLE api.salesline OWNER TO admin;
1767
 
 
1768
 
--
1769
 
--
1770
 
 
1771
 
COMMENT ON VIEW salesline IS 'Sales Order Line Item';
1772
 
 
1773
 
 
1774
 
--
1775
 
--
1776
 
 
1777
 
CREATE FUNCTION insertsalesline(salesline) RETURNS boolean
1778
 
    LANGUAGE plpgsql
1779
 
    AS $_$
1780
 
DECLARE
1781
 
  pNEW ALIAS FOR $1;
1782
 
  _r RECORD;
1783
 
 
1784
 
BEGIN
1785
 
 
1786
 
  IF (NOT EXISTS (SELECT cohead_id FROM cohead WHERE cohead_number=pNEW.order_number)) THEN
1787
 
    RAISE EXCEPTION 'Function insertSalesLine failed because Sales Order % not found', pNEW.order_number;
1788
 
  END IF;
1789
 
 
1790
 
  IF (NOT EXISTS (SELECT item_id FROM item WHERE item_number=pNEW.item_number)) THEN
1791
 
    RAISE EXCEPTION 'Function insertSalesLine failed because Item Number % not found', pNEW.item_number;
1792
 
  END IF;
1793
 
 
1794
 
  SELECT * INTO _r
1795
 
  FROM cohead, itemsite, item, whsinfo
1796
 
  WHERE ((cohead_number=pNEW.order_number)
1797
 
  AND (itemsite_warehous_id=warehous_id
1798
 
  AND (itemsite_item_id=item_id)
1799
 
  AND (itemsite_active)
1800
 
  AND (item_number=pNEW.item_number)
1801
 
  AND (warehous_active)
1802
 
  AND (warehous_id=COALESCE(getWarehousId(pNEW.sold_from_site,'ALL'),cohead_warehous_id,fetchprefwarehousid()))));
1803
 
 
1804
 
  IF (NOT FOUND) THEN
1805
 
    RAISE EXCEPTION 'Function insertSalesLine failed with unknown failure to retrieve Sales Order';
1806
 
  END IF;
1807
 
 
1808
 
  INSERT INTO coitem (
1809
 
    coitem_cohead_id,
1810
 
    coitem_linenumber,
1811
 
    coitem_itemsite_id,
1812
 
    coitem_status,
1813
 
    coitem_scheddate,
1814
 
    coitem_promdate,
1815
 
    coitem_qtyord,
1816
 
    coitem_qty_uom_id,
1817
 
    coitem_qty_invuomratio,
1818
 
    coitem_qtyshipped,
1819
 
    coitem_unitcost,
1820
 
    coitem_price,
1821
 
    coitem_price_uom_id,
1822
 
    coitem_price_invuomratio,
1823
 
    coitem_custprice,
1824
 
    coitem_order_id,
1825
 
    coitem_memo,
1826
 
    coitem_imported,
1827
 
    coitem_qtyreturned,
1828
 
    coitem_custpn,
1829
 
    coitem_order_type,
1830
 
    coitem_substitute_item_id,
1831
 
    coitem_prcost,
1832
 
    coitem_taxtype_id,
1833
 
    coitem_warranty,
1834
 
    coitem_cos_accnt_id,
1835
 
    coitem_rev_accnt_id)
1836
 
  VALUES (
1837
 
    _r.cohead_id,
1838
 
    pNEW.line_number::INTEGER,
1839
 
    _r.itemsite_id,
1840
 
    pNEW.status,
1841
 
    pNEW.scheduled_date,
1842
 
    pNEW.promise_date,
1843
 
    pNEW.qty_ordered,
1844
 
    COALESCE(getUomId(pNEW.qty_uom),_r.item_inv_uom_id),
1845
 
    itemuomtouomratio(_r.item_id,COALESCE(getUomId(pNEW.qty_uom),_r.item_inv_uom_id),_r.item_inv_uom_id),
1846
 
    0,
1847
 
    stdCost(_r.item_id),
1848
 
    COALESCE(pNEW.net_unit_price,itemPrice(_r.item_id,_r.cohead_cust_id,
1849
 
             _r.cohead_shipto_id,pNEW.qty_ordered,_r.cohead_curr_id,_r.cohead_orderdate)),
1850
 
    COALESCE(getUomId(pNEW.price_uom),_r.item_price_uom_id),
1851
 
    itemuomtouomratio(_r.item_id,COALESCE(getUomId(pNEW.price_uom),_r.item_price_uom_id),_r.item_price_uom_id),
1852
 
    itemPrice(_r.item_id, _r.cohead_cust_id, _r.cohead_shipto_id,
1853
 
              pNEW.qty_ordered, _r.item_inv_uom_id, _r.item_price_uom_id,
1854
 
              _r.cohead_curr_id,_r.cohead_orderdate,
1855
 
              CASE WHEN (fetchMetricText('soPriceEffective') = 'ScheduleDate') THEN pNEW.scheduled_date
1856
 
                   WHEN (fetchMetricText('soPriceEffective') = 'OrderDate') THEN _r.cohead_orderdate
1857
 
                   ELSE CURRENT_DATE END,
1858
 
              NULL)
1859
 
    -1,
1860
 
    pNEW.notes,
1861
 
    true,
1862
 
    0,
1863
 
    pNEW.customer_pn,
1864
 
    CASE
1865
 
      WHEN ((pNEW.create_order  AND (_r.item_type = 'M')) OR
1866
 
           ((pNEW.create_order IS NULL) AND _r.itemsite_createwo) AND (NOT _r.itemsite_stocked)) THEN
1867
 
        'W'
1868
 
      WHEN ((pNEW.create_order AND (_r.item_type = 'P')) OR
1869
 
           ((pNEW.create_order IS NULL) AND _r.itemsite_createsopr) AND (NOT _r.itemsite_stocked)) THEN
1870
 
        'R'
1871
 
      WHEN ((pNEW.create_order AND (_r.item_type = 'P') AND (_r.itemsite_createsopo)) OR
1872
 
           ((pNEW.create_order IS NULL) AND _r.itemsite_createsopo) AND (NOT _r.itemsite_stocked)) THEN
1873
 
        'P'
1874
 
    END,
1875
 
    getitemid(pNEW.substitute_for),
1876
 
    pNEW.overwrite_po_price,
1877
 
    COALESCE(getTaxTypeId(pNEW.tax_type), getItemTaxType(_r.itemsite_item_id, _r.cohead_taxzone_id)),
1878
 
    pNEW.warranty,
1879
 
    getGlAccntId(pNEW.alternate_cos_account),
1880
 
    getGlAccntId(pNEW.alternate_rev_account)
1881
 
    );
1882
 
 
1883
 
  RETURN TRUE;
1884
 
END;
1885
 
$_$;
1886
 
 
1887
 
 
1888
 
ALTER FUNCTION api.insertsalesline(salesline) OWNER TO admin;
1889
 
 
1890
 
SET search_path = public, pg_catalog;
1891
 
 
1892
 
--
1893
 
--
1894
 
 
1895
 
CREATE FUNCTION _accntdeletetrigger() RETURNS trigger
1896
 
    LANGUAGE plpgsql
1897
 
    AS $$
1898
 
DECLARE
1899
 
  _accntnum     TEXT := formatGLAccount(OLD.accnt_id);
1900
 
  _check INTEGER;
1901
 
BEGIN
1902
 
 
1903
 
  SELECT costcat_id INTO _check
1904
 
  FROM costcat
1905
 
  WHERE ( (costcat_asset_accnt_id=OLD.accnt_id)
1906
 
     OR   (costcat_liability_accnt_id=OLD.accnt_id)
1907
 
     OR   (costcat_adjustment_accnt_id=OLD.accnt_id)
1908
 
     OR   (costcat_purchprice_accnt_id=OLD.accnt_id)
1909
 
     OR   (costcat_laboroverhead_accnt_id=OLD.accnt_id)
1910
 
     OR   (costcat_scrap_accnt_id=OLD.accnt_id)
1911
 
     OR   (costcat_invcost_accnt_id=OLD.accnt_id)
1912
 
     OR   (costcat_wip_accnt_id=OLD.accnt_id)
1913
 
     OR   (costcat_shipasset_accnt_id=OLD.accnt_id)
1914
 
     OR   (costcat_mfgscrap_accnt_id=OLD.accnt_id)
1915
 
     OR   (costcat_transform_accnt_id=OLD.accnt_id)
1916
 
     OR   (costcat_freight_accnt_id=OLD.accnt_id) )
1917
 
  LIMIT 1;
1918
 
  IF (FOUND) THEN
1919
 
    RAISE EXCEPTION 'Can not delete, used in Cost Category';
1920
 
  END IF;
1921
 
 
1922
 
  SELECT salesaccnt_id INTO _check
1923
 
  FROM salesaccnt
1924
 
  WHERE ( (salesaccnt_sales_accnt_id=OLD.accnt_id)
1925
 
     OR   (salesaccnt_credit_accnt_id=OLD.accnt_id)
1926
 
     OR   (salesaccnt_cos_accnt_id=OLD.accnt_id) )
1927
 
  LIMIT 1;
1928
 
  IF (FOUND) THEN
1929
 
    RAISE EXCEPTION 'Can not delete, used in Sales Account Assignment';
1930
 
  END IF;
1931
 
 
1932
 
  SELECT araccnt_id INTO _check
1933
 
  FROM araccnt
1934
 
  WHERE ( (araccnt_freight_accnt_id=OLD.accnt_id)
1935
 
     OR   (araccnt_ar_accnt_id=OLD.accnt_id)
1936
 
     OR   (araccnt_prepaid_accnt_id=OLD.accnt_id) )
1937
 
  LIMIT 1;
1938
 
  IF (FOUND) THEN
1939
 
    RAISE EXCEPTION 'Can not delete, used in A/R Account Assignment';
1940
 
  END IF;
1941
 
 
1942
 
  SELECT warehous_id INTO _check
1943
 
  FROM whsinfo
1944
 
  WHERE (warehous_default_accnt_id=OLD.accnt_id)
1945
 
  LIMIT 1;
1946
 
  IF (FOUND) THEN
1947
 
    RAISE EXCEPTION 'Can not delete, used in Site';
1948
 
  END IF;
1949
 
 
1950
 
  SELECT bankaccnt_id INTO _check
1951
 
  FROM bankaccnt
1952
 
  WHERE (bankaccnt_accnt_id=OLD.accnt_id)
1953
 
  LIMIT 1;
1954
 
  IF (FOUND) THEN
1955
 
    RAISE EXCEPTION 'Can not delete, used in Bank Account';
1956
 
  END IF;
1957
 
 
1958
 
  SELECT expcat_id INTO _check
1959
 
  FROM expcat
1960
 
  WHERE ( (expcat_exp_accnt_id=OLD.accnt_id)
1961
 
     OR   (expcat_liability_accnt_id=OLD.accnt_id)
1962
 
     OR   (expcat_purchprice_accnt_id=OLD.accnt_id)
1963
 
     OR   (expcat_freight_accnt_id=OLD.accnt_id) )
1964
 
  LIMIT 1;
1965
 
  IF (FOUND) THEN
1966
 
    RAISE EXCEPTION 'Can not delete, used in Expense Category';
1967
 
  END IF;
1968
 
 
1969
 
  SELECT tax_id INTO _check
1970
 
  FROM tax
1971
 
  WHERE (tax_sales_accnt_id=OLD.accnt_id)
1972
 
  LIMIT 1;
1973
 
  IF (FOUND) THEN
1974
 
    RAISE EXCEPTION 'Can not delete, used in Tax Code';
1975
 
  END IF;
1976
 
 
1977
 
  SELECT stdjrnlitem_id INTO _check
1978
 
  FROM stdjrnlitem
1979
 
  WHERE (stdjrnlitem_accnt_id=OLD.accnt_id)
1980
 
  LIMIT 1;
1981
 
  IF (FOUND) THEN
1982
 
    RAISE EXCEPTION 'Can not delete, used in Standard Journal Item';
1983
 
  END IF;
1984
 
 
1985
 
  SELECT apaccnt_ap_accnt_id INTO _check
1986
 
  FROM apaccnt
1987
 
  WHERE ( (apaccnt_ap_accnt_id=OLD.accnt_id)
1988
 
     OR   (apaccnt_prepaid_accnt_id=OLD.accnt_id)
1989
 
     OR   (apaccnt_discount_accnt_id=OLD.accnt_id) )
1990
 
  LIMIT 1;
1991
 
  IF (FOUND) THEN
1992
 
    RAISE EXCEPTION 'Can not delete, used in A/P Account Assignment';
1993
 
  END IF;
1994
 
 
1995
 
  SELECT aropen_accnt_id INTO _check
1996
 
    FROM aropen
1997
 
   WHERE (aropen_accnt_id=OLD.accnt_id)
1998
 
   LIMIT 1;
1999
 
  IF (FOUND) THEN
2000
 
    RAISE EXCEPTION 'Can not delete, used in A/R Open Item';
2001
 
  END IF;
2002
 
 
2003
 
  SELECT gltrans_accnt_id INTO _check
2004
 
  FROM gltrans
2005
 
  WHERE (gltrans_accnt_id=OLD.accnt_id)
2006
 
  LIMIT 1;
2007
 
  IF (FOUND) THEN
2008
 
    RAISE EXCEPTION 'Can not delete, used in G/L Transaction';
2009
 
  END IF;
2010
 
 
2011
 
  SELECT sltrans_accnt_id INTO _check
2012
 
  FROM sltrans
2013
 
  WHERE (sltrans_accnt_id=OLD.accnt_id)
2014
 
  LIMIT 1;
2015
 
  IF (FOUND) THEN
2016
 
    RAISE EXCEPTION 'Can not delete, used in G/L Journal Transaction';
2017
 
  END IF;
2018
 
 
2019
 
  SELECT glseries_accnt_id INTO _check
2020
 
  FROM glseries
2021
 
  WHERE (glseries_accnt_id=OLD.accnt_id)
2022
 
  LIMIT 1;
2023
 
  IF (FOUND) THEN
2024
 
    RAISE EXCEPTION 'Can not delete, used in G/L Series';
2025
 
  END IF;
2026
 
 
2027
 
  SELECT trialbal_accnt_id INTO _check
2028
 
  FROM trialbal
2029
 
  WHERE (trialbal_accnt_id=OLD.accnt_id)
2030
 
    AND (trialbal_beginning != 0 OR trialbal_ending != 0)
2031
 
  LIMIT 1;
2032
 
  IF (FOUND) THEN
2033
 
    RAISE EXCEPTION 'Can not delete, used in Trial Balance';
2034
 
  END IF;
2035
 
 
2036
 
  SELECT cashrcptmisc_accnt_id INTO _check
2037
 
  FROM cashrcptmisc
2038
 
  WHERE (cashrcptmisc_accnt_id=OLD.accnt_id)
2039
 
  LIMIT 1;
2040
 
  IF (FOUND) THEN
2041
 
    RAISE EXCEPTION 'Can not delete, used in Cash Receipt Misc. Application';
2042
 
  END IF;
2043
 
 
2044
 
  -- TODO: everything above here should be replaced by fkeys
2045
 
  IF (OLD.accnt_id = fetchMetricValue('DefaultAPAccount')) THEN
2046
 
    RAISE EXCEPTION 'Cannot delete the default A/P Account [xtuple: accnt, -1, %]',
2047
 
                    _accntnum;
2048
 
  ELSIF (OLD.accnt_id = fetchMetricValue('DefaultARAccount')) THEN
2049
 
    RAISE EXCEPTION 'Cannot delete the default A/R Account [xtuple: accnt, -2, %]',
2050
 
                    _accntnum;
2051
 
  END IF;
2052
 
 
2053
 
  RETURN OLD;
2054
 
END;
2055
 
$$;
2056
 
 
2057
 
 
2058
 
ALTER FUNCTION public._accntdeletetrigger() OWNER TO admin;
2059
 
 
2060
 
--
2061
 
--
2062
 
 
2063
 
CREATE FUNCTION _accnttrigger() RETURNS trigger
2064
 
    LANGUAGE plpgsql
2065
 
    AS $$
2066
 
DECLARE
2067
 
  ffSub BOOLEAN;
2068
 
  ffProfit BOOLEAN;
2069
 
  result INTEGER;
2070
 
BEGIN
2071
 
  SELECT (metric_value='t')
2072
 
    INTO ffSub
2073
 
    FROM metric
2074
 
   WHERE(metric_name='GLFFSubaccounts')
2075
 
   LIMIT 1;
2076
 
  ffSub := COALESCE(ffSub, false);
2077
 
 
2078
 
  SELECT (metric_value='t')
2079
 
    INTO ffProfit
2080
 
    FROM metric
2081
 
   WHERE(metric_name='GLFFProfitCenters')
2082
 
   LIMIT 1;
2083
 
  ffProfit := COALESCE(ffProfit, false);
2084
 
 
2085
 
  IF (NEW.accnt_sub IS NOT NULL AND ffSub = false) THEN
2086
 
    SELECT subaccnt_id
2087
 
      INTO result
2088
 
      FROM subaccnt
2089
 
     WHERE(subaccnt_number=NEW.accnt_sub)
2090
 
     LIMIT 1;
2091
 
    IF (NOT FOUND) THEN
2092
 
      RAISE EXCEPTION 'You must supply a valid Sub Account Number.';
2093
 
    END IF;
2094
 
  END IF;
2095
 
 
2096
 
  IF (NEW.accnt_profit IS NOT NULL AND ffProfit = false) THEN
2097
 
    SELECT prftcntr_id
2098
 
      INTO result
2099
 
      FROM prftcntr
2100
 
     WHERE(prftcntr_number=NEW.accnt_profit)
2101
 
     LIMIT 1;
2102
 
    IF (NOT FOUND) THEN
2103
 
      RAISE EXCEPTION 'You must supply a valid Profit Center Number.';
2104
 
    END IF;
2105
 
  END IF;
2106
 
 
2107
 
  IF (TG_OP = 'UPDATE') THEN
2108
 
    IF ((NEW.accnt_type != OLD.accnt_type) AND
2109
 
        (SELECT (count(*) > 0) FROM gltrans WHERE (gltrans_accnt_id=NEW.accnt_id))) THEN
2110
 
      RAISE EXCEPTION 'You may not change the account type of an account that has transaction history';
2111
 
    END IF;
2112
 
  END IF;
2113
 
 
2114
 
  NEW.accnt_name := formatGlAccount(NEW.accnt_company, NEW.accnt_profit, NEW.accnt_number, NEW.accnt_sub);
2115
 
 
2116
 
  RETURN NEW;
2117
 
END;
2118
 
$$;
2119
 
 
2120
 
 
2121
 
ALTER FUNCTION public._accnttrigger() OWNER TO admin;
2122
 
 
2123
 
--
2124
 
--
2125
 
 
2126
 
CREATE FUNCTION _accntuniquetrigger() RETURNS trigger
2127
 
    LANGUAGE plpgsql
2128
 
    AS $$
2129
 
DECLARE
2130
 
BEGIN
2131
 
  -- This trigger is to protect against id collision on inherited tables since there is no way 
2132
 
  -- to enforce that with regular constraints.  It should be applied to accnt and any table that 
2133
 
  -- inherits accnt.
2134
 
  IF (SELECT (count(accnt_id) > 0) FROM accnt WHERE (accnt_id = NEW.accnt_id)) THEN
2135
 
    RAISE EXCEPTION 'Can not create record on account with duplicate key %.', NEW.accnt_id;
2136
 
  END IF;
2137
 
  
2138
 
  RETURN NEW;
2139
 
END;
2140
 
$$;
2141
 
 
2142
 
 
2143
 
ALTER FUNCTION public._accntuniquetrigger() OWNER TO admin;
2144
 
 
2145
 
--
2146
 
--
2147
 
 
2148
 
CREATE FUNCTION _addrtrigger() RETURNS trigger
2149
 
    LANGUAGE plpgsql
2150
 
    AS $$
2151
 
  DECLARE
2152
 
    _uses       INTEGER := 0;
2153
 
 
2154
 
  BEGIN
2155
 
 
2156
 
    IF (TG_OP = 'INSERT') THEN
2157
 
      --- clear the number from the issue cache
2158
 
      PERFORM clearNumberIssue('AddressNumber', NEW.addr_number);
2159
 
    ELSE
2160
 
      SELECT count(*) INTO _uses
2161
 
      FROM cntct
2162
 
      WHERE ((cntct_addr_id=OLD.addr_id)
2163
 
        AND   cntct_active);
2164
 
    END IF;
2165
 
 
2166
 
    IF (TG_OP = 'UPDATE') THEN
2167
 
      IF (OLD.addr_active AND NOT NEW.addr_active AND _uses > 0) THEN
2168
 
        RAISE EXCEPTION 'Cannot inactivate Address with Active Contacts (%)',
2169
 
                        _uses;
2170
 
      END IF;
2171
 
    ELSIF (TG_OP = 'DELETE') THEN
2172
 
      IF (_uses > 0) THEN
2173
 
        RAISE EXCEPTION 'Cannot Delete Address with Active Contacts (%)',
2174
 
                        _uses;
2175
 
      END IF;
2176
 
 
2177
 
      UPDATE cntct SET cntct_addr_id = NULL
2178
 
      WHERE ((cntct_addr_id=OLD.addr_id)
2179
 
        AND  (NOT cntct_active));
2180
 
 
2181
 
      RETURN OLD;
2182
 
    END IF;
2183
 
 
2184
 
    RETURN NEW;
2185
 
  END;
2186
 
$$;
2187
 
 
2188
 
 
2189
 
ALTER FUNCTION public._addrtrigger() OWNER TO admin;
2190
 
 
2191
 
--
2192
 
--
2193
 
 
2194
 
CREATE FUNCTION _alarmbeforetrigger() RETURNS trigger
2195
 
    LANGUAGE plpgsql
2196
 
    AS $$
2197
 
  BEGIN
2198
 
    PERFORM clearNumberIssue('AlarmNumber', NEW.alarm_number);
2199
 
 
2200
 
    RETURN NEW;
2201
 
  END;
2202
 
$$;
2203
 
 
2204
 
 
2205
 
ALTER FUNCTION public._alarmbeforetrigger() OWNER TO admin;
2206
 
 
2207
 
--
2208
 
--
2209
 
 
2210
 
CREATE FUNCTION _apapplytrigger() RETURNS trigger
2211
 
    LANGUAGE plpgsql
2212
 
    AS $$
2213
 
DECLARE
2214
 
  _tpaid NUMERIC;
2215
 
 
2216
 
BEGIN
2217
 
 
2218
 
  IF (TG_OP = 'INSERT') THEN
2219
 
    SELECT currtocurr(NEW.apapply_curr_id,apopen_curr_id,NEW.apapply_amount,NEW.apapply_postdate) 
2220
 
      INTO _tpaid
2221
 
    FROM apopen
2222
 
    WHERE ( apopen_id=NEW.apapply_target_apopen_id );
2223
 
    IF (FOUND) THEN
2224
 
      NEW.apapply_target_paid := _tpaid;
2225
 
    ELSE
2226
 
      RAISE EXCEPTION 'Error calculating paid amount on application';
2227
 
    END IF;
2228
 
  END IF;
2229
 
 
2230
 
  RETURN NEW;
2231
 
 
2232
 
END;
2233
 
 
2234
 
$$;
2235
 
 
2236
 
 
2237
 
ALTER FUNCTION public._apapplytrigger() OWNER TO admin;
2238
 
 
2239
 
--
2240
 
--
2241
 
 
2242
 
CREATE FUNCTION _apopentrigger() RETURNS trigger
2243
 
    LANGUAGE plpgsql
2244
 
    AS $$
2245
 
DECLARE
2246
 
  _currrate NUMERIC;
2247
 
 
2248
 
BEGIN
2249
 
 
2250
 
  IF (TG_OP = 'INSERT' AND NEW.apopen_curr_rate IS NULL) THEN
2251
 
    SELECT curr_rate INTO _currrate
2252
 
    FROM curr_rate
2253
 
    WHERE ( (NEW.apopen_curr_id=curr_id)
2254
 
    AND ( NEW.apopen_docdate BETWEEN curr_effective 
2255
 
                                 AND curr_expires) );
2256
 
    IF (FOUND) THEN
2257
 
      NEW.apopen_curr_rate := _currrate;
2258
 
    ELSE
2259
 
      RAISE EXCEPTION 'Currency exchange rate not found';
2260
 
    END IF;
2261
 
  END IF;
2262
 
 
2263
 
  NEW.apopen_open := NEW.apopen_amount > NEW.apopen_paid;
2264
 
 
2265
 
  IF (TG_OP = 'INSERT') THEN
2266
 
    IF (NEW.apopen_open=FALSE) THEN
2267
 
      NEW.apopen_status='C';
2268
 
    ELSE
2269
 
      NEW.apopen_status='O';
2270
 
    END IF;
2271
 
 
2272
 
     --- clear the number from the issue cache
2273
 
    PERFORM clearNumberIssue('APMemoNumber', NEW.apopen_docnumber);
2274
 
  END IF;
2275
 
  
2276
 
  IF (TG_OP = 'UPDATE') THEN
2277
 
    IF ((OLD.apopen_open=TRUE) AND (NEW.apopen_open=FALSE)) THEN
2278
 
      NEW.apopen_status='C';
2279
 
      IF (NEW.apopen_closedate IS NULL) THEN
2280
 
        NEW.apopen_closedate=CURRENT_DATE;
2281
 
      END IF;
2282
 
    END IF;
2283
 
    
2284
 
    IF ((OLD.apopen_open=FALSE) AND (NEW.apopen_open=TRUE)) THEN
2285
 
      NEW.apopen_status='O';
2286
 
      NEW.apopen_closedate=NULL;
2287
 
    END IF;
2288
 
  END IF;
2289
 
 
2290
 
  RETURN NEW;
2291
 
 
2292
 
END;
2293
 
 
2294
 
$$;
2295
 
 
2296
 
 
2297
 
ALTER FUNCTION public._apopentrigger() OWNER TO admin;
2298
 
 
2299
 
--
2300
 
--
2301
 
 
2302
 
CREATE FUNCTION _arapplytrigger() RETURNS trigger
2303
 
    LANGUAGE plpgsql
2304
 
    AS $$
2305
 
DECLARE
2306
 
  _tpaid NUMERIC;
2307
 
 
2308
 
BEGIN
2309
 
 
2310
 
  IF (TG_OP = 'INSERT') THEN
2311
 
    IF (NEW.arapply_target_doctype != 'K') THEN 
2312
 
      SELECT round(currtocurr(NEW.arapply_curr_id,aropen_curr_id,NEW.arapply_applied,NEW.arapply_postdate),2) 
2313
 
        INTO NEW.arapply_target_paid
2314
 
      FROM aropen
2315
 
      WHERE ( aropen_id=NEW.arapply_target_aropen_id );
2316
 
    ELSE
2317
 
      SELECT round(currtocurr(NEW.arapply_curr_id,aropen_curr_id,NEW.arapply_applied,NEW.arapply_postdate),2) 
2318
 
        INTO NEW.arapply_target_paid
2319
 
      FROM aropen
2320
 
      WHERE ( aropen_id=NEW.arapply_source_aropen_id );
2321
 
    END IF;
2322
 
    IF NOT FOUND THEN
2323
 
      NEW.arapply_target_paid := NEW.arapply_applied;
2324
 
    END IF;
2325
 
  END IF;
2326
 
 
2327
 
  RETURN NEW;
2328
 
 
2329
 
END;
2330
 
 
2331
 
$$;
2332
 
 
2333
 
 
2334
 
ALTER FUNCTION public._arapplytrigger() OWNER TO admin;
2335
 
 
2336
 
--
2337
 
--
2338
 
 
2339
 
CREATE FUNCTION _aropenaftertrigger() RETURNS trigger
2340
 
    LANGUAGE plpgsql
2341
 
    AS $$
2342
 
DECLARE
2343
 
  _openAmount NUMERIC;
2344
 
  _lateCount INTEGER := 0;
2345
 
  _graceDays INTEGER;
2346
 
  _checkLate BOOLEAN := false;
2347
 
  _checkLimit BOOLEAN := false;
2348
 
  _id INTEGER;
2349
 
BEGIN
2350
 
 
2351
 
  IF (TG_OP = 'INSERT') THEN
2352
 
    _id := NEW.aropen_id;
2353
 
  ELSE
2354
 
    _id := OLD.aropen_id;
2355
 
  END IF;
2356
 
  IF (fetchMetricBool('AutoCloseARIncident')) THEN
2357
 
    IF (NEW.aropen_open = FALSE) THEN
2358
 
      UPDATE incdt SET incdt_status='L' WHERE (incdt_aropen_id=_id);
2359
 
    END IF;
2360
 
  END IF;
2361
 
 
2362
 
  RETURN NEW;
2363
 
 
2364
 
END;
2365
 
$$;
2366
 
 
2367
 
 
2368
 
ALTER FUNCTION public._aropenaftertrigger() OWNER TO admin;
2369
 
 
2370
 
--
2371
 
--
2372
 
 
2373
 
CREATE FUNCTION _aropentrigger() RETURNS trigger
2374
 
    LANGUAGE plpgsql
2375
 
    AS $$
2376
 
DECLARE
2377
 
  _openAmount NUMERIC;
2378
 
  _p RECORD;
2379
 
  _lateCount INTEGER := 0;
2380
 
  _graceDays INTEGER;
2381
 
  _checkLate BOOLEAN := false;
2382
 
  _checkLimit BOOLEAN := false;
2383
 
  _id INTEGER;
2384
 
  _currRate NUMERIC;
2385
 
BEGIN
2386
 
  -- Checks
2387
 
  -- Start with privileges
2388
 
  IF ( (NOT checkPrivilege('MaintainARMemos')) AND
2389
 
       (NOT checkPrivilege('PostMiscInvoices')) AND
2390
 
       (NOT checkPrivilege('PostARDocuments')) ) THEN
2391
 
    RAISE EXCEPTION 'You do not have privileges to maintain A/R Memos.';
2392
 
  END IF;
2393
 
 
2394
 
  IF ( (NEW.aropen_docnumber IS NULL) OR (LENGTH(NEW.aropen_docnumber) = 0) ) THEN
2395
 
    RAISE EXCEPTION 'You must enter a valid Document # for this A/R Memo.';
2396
 
  END IF;
2397
 
 
2398
 
  IF ( (NEW.aropen_amount IS NOT NULL) AND (NEW.aropen_amount < 0) ) THEN
2399
 
    RAISE EXCEPTION 'You must enter a positive Amount for this A/R Memo.';
2400
 
  END IF;
2401
 
 
2402
 
  IF (TG_OP IN ('INSERT', 'UPDATE') AND NEW.aropen_cust_id < 0) THEN
2403
 
    RAISE NOTICE 'Fixing deprecated use of negative aropen_cust_id';
2404
 
    NEW.aropen_cust_id := NULL;
2405
 
  END IF;
2406
 
 
2407
 
  IF (TG_OP IN ('INSERT', 'UPDATE') AND NEW.aropen_salesrep_id < 0) THEN
2408
 
    RAISE NOTICE 'Fixing deprecated use of negative aropen_salesrep_id';
2409
 
    NEW.aropen_salesrep_id := NULL;
2410
 
  END IF;
2411
 
 
2412
 
  IF (TG_OP = 'INSERT') THEN
2413
 
    SELECT aropen_id INTO _id
2414
 
    FROM aropen
2415
 
    WHERE ( (aropen_doctype=NEW.aropen_doctype)
2416
 
      AND   (aropen_docnumber=NEW.aropen_docnumber) )
2417
 
    LIMIT 1;
2418
 
    IF (FOUND) THEN
2419
 
      RAISE EXCEPTION 'This Document Type/Number already exists. You may not enter a duplicate A/R Memo.';
2420
 
    END IF;
2421
 
 
2422
 
    --- clear the number from the issue cache if applicable
2423
 
    PERFORM clearNumberIssue('ARMemoNumber', NEW.aropen_docnumber);
2424
 
  END IF;
2425
 
 
2426
 
  IF ( SELECT (metric_value='t')
2427
 
         FROM metric
2428
 
        WHERE(metric_name='AutoCreditWarnLateCustomers')) THEN
2429
 
    _checkLate := true;
2430
 
 
2431
 
    SELECT COALESCE(metric_value::integer, _graceDays)
2432
 
      INTO _graceDays
2433
 
      FROM metric
2434
 
     WHERE(metric_name='DefaultAutoCreditWarnGraceDays');
2435
 
    IF (NOT FOUND) THEN
2436
 
      _graceDays := 30;
2437
 
    END IF;
2438
 
    SELECT COALESCE(cust_gracedays, _graceDays)
2439
 
      INTO _graceDays
2440
 
      FROM custinfo
2441
 
     WHERE(cust_id=NEW.aropen_cust_id);
2442
 
    IF (NOT FOUND) THEN
2443
 
      _graceDays := 30;
2444
 
    END IF;
2445
 
 
2446
 
    SELECT count(aropen_id)
2447
 
      INTO _lateCount
2448
 
      FROM aropen
2449
 
     WHERE((NEW.aropen_cust_id = aropen_cust_id)
2450
 
       AND (aropen_open)
2451
 
       AND (aropen_amount > aropen_paid)
2452
 
       AND (aropen_doctype IN ('I', 'D'))
2453
 
       AND (aropen_duedate < (CURRENT_DATE - _graceDays)));
2454
 
 
2455
 
  --  Adjust _lateCount if late invoice being paid
2456
 
    IF ( (NEW.aropen_paid = NEW.aropen_amount)
2457
 
     AND (NEW.aropen_doctype IN ('I', 'D'))
2458
 
     AND (NEW.aropen_duedate < (CURRENT_DATE - _graceDays))) THEN
2459
 
      _lateCount := _lateCount - 1;
2460
 
    END IF;
2461
 
  END IF;
2462
 
 
2463
 
  IF (TG_OP = 'INSERT' AND NEW.aropen_curr_rate IS NULL) THEN
2464
 
    SELECT curr_rate INTO _currrate
2465
 
      FROM curr_rate
2466
 
    WHERE ( (NEW.aropen_curr_id=curr_id)
2467
 
      AND ( NEW.aropen_docdate BETWEEN curr_effective
2468
 
                                   AND curr_expires) );
2469
 
    IF (FOUND) THEN
2470
 
      NEW.aropen_curr_rate := _currrate;
2471
 
    ELSE
2472
 
      RAISE EXCEPTION 'Currency exchange rate not found';
2473
 
    END IF;
2474
 
  END IF;
2475
 
 
2476
 
  IF (NEW.aropen_paid = NEW.aropen_amount) THEN
2477
 
    NEW.aropen_open=FALSE;
2478
 
 
2479
 
    DELETE FROM aropenalloc WHERE (aropenalloc_aropen_id=NEW.aropen_id);
2480
 
  END IF;
2481
 
 
2482
 
  IF (TG_OP = 'INSERT') THEN
2483
 
    IF (NEW.aropen_open=FALSE)
2484
 
    AND (NEW.aropen_closedate IS NULL) THEN
2485
 
      NEW.aropen_closedate=current_date;
2486
 
    END IF;
2487
 
  END IF;
2488
 
 
2489
 
  IF (TG_OP = 'UPDATE') THEN
2490
 
    IF ((OLD.aropen_open=TRUE)
2491
 
    AND (NEW.aropen_open=FALSE)
2492
 
    AND (NEW.aropen_closedate IS NULL)) THEN
2493
 
      NEW.aropen_closedate=current_date;
2494
 
    END IF;
2495
 
  END IF;
2496
 
 
2497
 
  SELECT cust_id, cust_creditlmt, cust_creditstatus,
2498
 
         cust_autoupdatestatus, cust_autoholdorders INTO _p
2499
 
  FROM custinfo
2500
 
  WHERE (cust_id=NEW.aropen_cust_id);
2501
 
  IF (_p.cust_creditlmt > 0) THEN
2502
 
    _checkLimit := true;
2503
 
 
2504
 
    SELECT COALESCE(SUM( CASE WHEN (aropen_doctype IN ('I', 'D')) THEN (aropen_amount - aropen_paid)
2505
 
                     ELSE ((aropen_amount - aropen_paid) * -1)
2506
 
                END ), 0.0) INTO _openAmount
2507
 
    FROM aropen AS current
2508
 
    WHERE ( (current.aropen_cust_id=NEW.aropen_cust_id)
2509
 
     AND (current.aropen_open)
2510
 
     AND (current.aropen_id <> NEW.aropen_id) );
2511
 
 
2512
 
    IF (NEW.aropen_doctype IN ('I', 'D')) THEN
2513
 
      _openAmount := (_openAmount + (NEW.aropen_amount - NEW.aropen_paid));
2514
 
    ELSE
2515
 
      _openAmount := (_openAmount - (NEW.aropen_amount - NEW.aropen_paid));
2516
 
    END IF;
2517
 
  ELSE
2518
 
    _openAmount := 0;
2519
 
  END IF;
2520
 
 
2521
 
  IF (_checkLimit OR _checkLate) THEN
2522
 
    IF ((_p.cust_creditlmt >= _openAmount) AND (_lateCount <= 0)) THEN
2523
 
 
2524
 
      IF ( (_p.cust_autoupdatestatus) AND (_p.cust_creditstatus='W') ) THEN
2525
 
        UPDATE custinfo
2526
 
        SET cust_creditstatus='G'
2527
 
        WHERE (cust_id=NEW.aropen_cust_id);
2528
 
      END IF;
2529
 
 
2530
 
      IF (_p.cust_autoholdorders) THEN
2531
 
        UPDATE cohead
2532
 
        SET cohead_holdtype='N'
2533
 
        FROM coitem
2534
 
        WHERE ( (coitem_cohead_id=cohead_id)
2535
 
         AND (cohead_holdtype='C')
2536
 
         AND (coitem_status='O')
2537
 
         AND (cohead_cust_id=_p.cust_id) );
2538
 
      END IF;
2539
 
 
2540
 
    ELSIF ((_p.cust_creditlmt < _openAmount) OR (_lateCount > 0)) THEN
2541
 
 
2542
 
      IF ( (_p.cust_autoupdatestatus) AND (_p.cust_creditstatus = 'G') ) THEN
2543
 
        UPDATE custinfo
2544
 
        SET cust_creditstatus='W'
2545
 
        WHERE (cust_id=NEW.aropen_cust_id);
2546
 
      END IF;
2547
 
 
2548
 
      IF (_p.cust_autoholdorders) THEN
2549
 
        UPDATE cohead
2550
 
        SET cohead_holdtype='C'
2551
 
        FROM coitem
2552
 
        WHERE ( (coitem_cohead_id=cohead_id)
2553
 
         AND (cohead_holdtype='N')
2554
 
         AND (coitem_status='O')
2555
 
         AND (cohead_cust_id=_p.cust_id) );
2556
 
      END IF;
2557
 
 
2558
 
    END IF;
2559
 
 
2560
 
  END IF;
2561
 
 
2562
 
  RETURN NEW;
2563
 
 
2564
 
END;
2565
 
$$;
2566
 
 
2567
 
 
2568
 
ALTER FUNCTION public._aropentrigger() OWNER TO admin;
2569
 
 
2570
 
--
2571
 
--
2572
 
 
2573
 
CREATE FUNCTION _bomheadtrigger() RETURNS trigger
2574
 
    LANGUAGE plpgsql
2575
 
    AS $$
2576
 
DECLARE
2577
 
  _revid INTEGER;
2578
 
  _check TEXT;
2579
 
BEGIN
2580
 
  IF (NOT checkPrivilege('MaintainBOMs')) THEN
2581
 
    RAISE EXCEPTION 'You do not have privileges to maintain Bills of Material.';
2582
 
  END IF;
2583
 
 
2584
 
  RETURN NEW;
2585
 
END;
2586
 
$$;
2587
 
 
2588
 
 
2589
 
ALTER FUNCTION public._bomheadtrigger() OWNER TO admin;
2590
 
 
2591
 
--
2592
 
--
2593
 
 
2594
 
CREATE FUNCTION _bomitemaftertrigger() RETURNS trigger
2595
 
    LANGUAGE plpgsql
2596
 
    AS $$
2597
 
DECLARE
2598
 
 
2599
 
BEGIN
2600
 
 
2601
 
  IF ( SELECT fetchMetricBool('ItemChangeLog') ) THEN
2602
 
    IF (TG_OP = 'INSERT') THEN
2603
 
      PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, ('Created BOM Item Sequence ' || NEW.bomitem_seqnumber::TEXT));
2604
 
 
2605
 
    ELSIF (TG_OP = 'UPDATE') THEN
2606
 
      IF (NEW.bomitem_effective <> OLD.bomitem_effective) THEN
2607
 
        PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id,
2608
 
                             ( 'Effective Date Changed from ' || formatDate(OLD.bomitem_effective, 'Always') ||
2609
 
                               ' to ' || formatDate(NEW.bomitem_effective, 'Always' ) ) );
2610
 
      END IF;
2611
 
 
2612
 
      IF (NEW.bomitem_expires <> OLD.bomitem_expires) THEN
2613
 
        PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id,
2614
 
                             ( 'Expiration Date Changed from ' || formatDate(OLD.bomitem_expires, 'Never') ||
2615
 
                               ' to ' || formatDate(NEW.bomitem_expires, 'Never' ) ) );
2616
 
      END IF;
2617
 
 
2618
 
      IF (NEW.bomitem_qtyfxd <> OLD.bomitem_qtyfxd) THEN
2619
 
        PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id,
2620
 
                             ( 'Fixed Qty. Changed from ' || formatQtyPer(OLD.bomitem_qtyfxd) ||
2621
 
                               ' to ' || formatQtyPer(NEW.bomitem_qtyfxd ) ) );
2622
 
      END IF;
2623
 
 
2624
 
      IF (NEW.bomitem_qtyper <> OLD.bomitem_qtyper) THEN
2625
 
        PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id,
2626
 
                             ( 'Qty. Per Changed from ' || formatQtyPer(OLD.bomitem_qtyper) ||
2627
 
                               ' to ' || formatQtyPer(NEW.bomitem_qtyper ) ) );
2628
 
      END IF;
2629
 
 
2630
 
      IF (NEW.bomitem_scrap <> OLD.bomitem_scrap) THEN
2631
 
        PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id,
2632
 
                             ( 'Scrap % Changed from ' || formatPrcnt(OLD.bomitem_scrap) ||
2633
 
                               ' to ' || formatPrcnt(NEW.bomitem_scrap ) ) );
2634
 
      END IF;
2635
 
 
2636
 
      IF (NEW.bomitem_issuemethod <> OLD.bomitem_issuemethod) THEN
2637
 
        PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id,
2638
 
                             ( 'Issue Method Changed from ' || (CASE WHEN(OLD.bomitem_issuemethod='S') THEN 'Push'
2639
 
                                                                     WHEN(OLD.bomitem_issuemethod='L') THEN 'Pull'
2640
 
                                                                     WHEN(OLD.bomitem_issuemethod='M') THEN 'Mixed'
2641
 
                                                                     ELSE OLD.bomitem_issuemethod END) ||
2642
 
                               ' to ' || (CASE WHEN(NEW.bomitem_issuemethod='S') THEN 'Push'
2643
 
                                               WHEN(NEW.bomitem_issuemethod='L') THEN 'Pull'
2644
 
                                               WHEN(NEW.bomitem_issuemethod='M') THEN 'Mixed'
2645
 
                                               ELSE NEW.bomitem_issuemethod END) ) );
2646
 
      END IF;
2647
 
 
2648
 
      IF (NEW.bomitem_ecn <> OLD.bomitem_ecn) THEN
2649
 
        PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id,
2650
 
                             ( 'ECN Changed from ' || OLD.bomitem_ecn ||
2651
 
                               ' to ' || NEW.bomitem_ecn ) );
2652
 
      END IF;
2653
 
 
2654
 
      IF (OLD.bomitem_createwo <> NEW.bomitem_createwo) THEN
2655
 
        IF (NEW.bomitem_createwo) THEN
2656
 
          PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, 'Create Child W/O activated');
2657
 
        ELSE
2658
 
          PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, 'Create Child W/O deactivated');
2659
 
        END IF;
2660
 
      END IF;
2661
 
 
2662
 
      IF (OLD.bomitem_issuewo <> NEW.bomitem_issuewo) THEN
2663
 
        IF (NEW.bomitem_issuewo) THEN
2664
 
          PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, 'Issue Child W/O activated');
2665
 
        ELSE
2666
 
          PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, 'Issue Child W/O deactivated');
2667
 
        END IF;
2668
 
      END IF;
2669
 
 
2670
 
    END IF;
2671
 
  END IF;
2672
 
 
2673
 
  IF (TG_OP = 'DELETE') THEN
2674
 
    DELETE FROM comment
2675
 
     WHERE ( (comment_source='BMI')
2676
 
       AND   (comment_source_id=OLD.bomitem_id) );
2677
 
 
2678
 
    RETURN OLD;
2679
 
  END IF;
2680
 
 
2681
 
  RETURN NEW;
2682
 
END;
2683
 
$$;
2684
 
 
2685
 
 
2686
 
ALTER FUNCTION public._bomitemaftertrigger() OWNER TO admin;
2687
 
 
2688
 
--
2689
 
--
2690
 
 
2691
 
CREATE FUNCTION _bomitembeforedeletetrigger() RETURNS trigger
2692
 
    LANGUAGE plpgsql
2693
 
    AS $$
2694
 
DECLARE
2695
 
BEGIN
2696
 
 
2697
 
  DELETE FROM comment
2698
 
   WHERE ( (comment_source='BMI')
2699
 
     AND   (comment_source_id=OLD.bomitem_id) );
2700
 
 
2701
 
  RETURN OLD;
2702
 
END;
2703
 
$$;
2704
 
 
2705
 
 
2706
 
ALTER FUNCTION public._bomitembeforedeletetrigger() OWNER TO admin;
2707
 
 
2708
 
--
2709
 
--
2710
 
 
2711
 
CREATE FUNCTION _bomitembeforetrigger() RETURNS trigger
2712
 
    LANGUAGE plpgsql
2713
 
    AS $$
2714
 
DECLARE
2715
 
  _bomworksetid INTEGER;
2716
 
  _bomworkid INTEGER;
2717
 
  _seqNumber INTEGER;
2718
 
  _parentItem RECORD;
2719
 
BEGIN
2720
 
 
2721
 
  -- Privilege Checks
2722
 
  IF (NOT checkPrivilege('MaintainBOMs')) THEN
2723
 
    RAISE EXCEPTION 'You do not have privileges to maintain Bills of Material.';
2724
 
  END IF;
2725
 
 
2726
 
  -- Cache Parent Item
2727
 
   SELECT * INTO _parentItem
2728
 
   FROM item
2729
 
   WHERE (item_id=NEW.bomitem_parent_item_id);
2730
 
 
2731
 
  IF (TG_OP = 'INSERT') THEN
2732
 
    --  Make sure that the parent and component are not the same
2733
 
    IF (NEW.bomitem_parent_item_id = NEW.bomitem_item_id) THEN
2734
 
      RAISE EXCEPTION 'BOM Item Parent and Component Item cannot be the same. [xtuple: createBOMItem, -1]';
2735
 
    END IF;
2736
 
 
2737
 
    --  Make sure that the parent is not used in the component at some level
2738
 
    SELECT indentedWhereUsed(NEW.bomitem_parent_item_id) INTO _bomworksetid;
2739
 
    SELECT bomwork_id INTO _bomworkid
2740
 
    FROM bomwork
2741
 
    WHERE ((bomwork_set_id=_bomworksetid)
2742
 
      AND  (bomwork_item_id=NEW.bomitem_item_id))
2743
 
    LIMIT 1;
2744
 
    IF (FOUND) THEN
2745
 
      PERFORM deleteBOMWorkset(_bomworksetid);
2746
 
      RAISE EXCEPTION 'BOM Item Parent is used by Component, BOM is recursive. [xtuple: createBOMItem, -2]';
2747
 
    END IF;
2748
 
 
2749
 
    PERFORM deleteBOMWorkset(_bomworksetid);
2750
 
 
2751
 
    -- Set defaults
2752
 
    NEW.bomitem_rev_id := COALESCE(NEW.bomitem_rev_id, -1);
2753
 
    NEW.bomitem_booitem_seq_id := COALESCE(NEW.bomitem_booitem_seq_id, -1);
2754
 
    NEW.bomitem_schedatwooper := COALESCE(NEW.bomitem_schedatwooper, FALSE);
2755
 
    IF (NEW.bomitem_seqnumber IS NULL) THEN
2756
 
      --  Grab the next Sequence Number, if any
2757
 
      SELECT MAX(bomitem_seqnumber) INTO _seqNumber
2758
 
      FROM bomitem(NEW.bomitem_parent_item_id,NEW.bomitem_rev_id);
2759
 
      IF (_seqNumber IS NOT NULL) THEN
2760
 
        NEW.bomitem_seqnumber := (_seqNumber + 10);
2761
 
      ELSE
2762
 
        NEW.bomitem_seqnumber := 10;
2763
 
      END IF;
2764
 
    END IF;
2765
 
  END IF; -- end Insert specific
2766
 
 
2767
 
  IF (TG_OP = 'UPDATE') THEN
2768
 
    -- Disallow changes that would compromise revision control integrity
2769
 
    IF (NEW.bomitem_parent_item_id != OLD.bomitem_parent_item_id) THEN
2770
 
      RAISE EXCEPTION 'Parent Item ID may not be changed.';
2771
 
    END IF;
2772
 
 
2773
 
    IF (NEW.bomitem_item_id != OLD.bomitem_item_id) THEN
2774
 
      RAISE EXCEPTION 'Item ID may not be changed.';
2775
 
    END IF;
2776
 
 
2777
 
    IF ((fetchMetricBool('RevControl')) AND (OLD.bomitem_rev_id > -1)) THEN
2778
 
      IF (SELECT (rev_status = 'I') FROM rev WHERE (rev_id=OLD.bomitem_rev_id)) THEN
2779
 
        RAISE EXCEPTION 'Bill of material is Inactive and may not be modified';
2780
 
      END IF;
2781
 
    END IF;
2782
 
  END IF; -- end Update specific
2783
 
 
2784
 
  -- Check for valid UOM
2785
 
  IF (SELECT (count(*) != 1)
2786
 
      FROM
2787
 
             (SELECT uom_id
2788
 
                FROM item JOIN uom ON (item_inv_uom_id=uom_id)
2789
 
                WHERE(item_id=NEW.bomitem_item_id)
2790
 
              UNION 
2791
 
              SELECT uom_id
2792
 
                FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id)
2793
 
                          JOIN uom ON (itemuomconv_to_uom_id=uom_id),
2794
 
                     itemuom, uomtype 
2795
 
               WHERE((itemuomconv_from_uom_id=item_inv_uom_id)
2796
 
                 AND (item_id=NEW.bomitem_item_id) 
2797
 
                 AND (itemuom_itemuomconv_id=itemuomconv_id) 
2798
 
                 AND (uomtype_id=itemuom_uomtype_id) 
2799
 
                 AND (uomtype_name='MaterialIssue'))
2800
 
              UNION 
2801
 
              SELECT uom_id
2802
 
                FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id)
2803
 
                          JOIN uom ON (itemuomconv_from_uom_id=uom_id),
2804
 
                     itemuom, uomtype 
2805
 
               WHERE((itemuomconv_to_uom_id=item_inv_uom_id)
2806
 
                 AND (item_id=NEW.bomitem_item_id) 
2807
 
                 AND (itemuom_itemuomconv_id=itemuomconv_id) 
2808
 
                 AND (uomtype_id=itemuom_uomtype_id) 
2809
 
                 AND (uomtype_name='MaterialIssue'))) AS data
2810
 
        WHERE (uom_id=NEW.bomitem_uom_id)) THEN
2811
 
    RAISE EXCEPTION 'Unit of Measure Invalid for Material Issue.';
2812
 
  END IF;
2813
 
 
2814
 
   IF (NEW.bomitem_char_id IS NOT NULL) THEN
2815
 
     IF (NOT _parentItem.item_config) THEN
2816
 
       RAISE EXCEPTION 'Configuration characteristics may only be defined for Configured Items';
2817
 
     END IF;
2818
 
   END IF;
2819
 
 
2820
 
  -- Kit items must be sold and not kits themselves
2821
 
  IF (_parentItem.item_type = 'K') THEN
2822
 
    IF (SELECT (COUNT(item_id) = 0)
2823
 
          FROM item
2824
 
         WHERE ((item_id=NEW.bomitem_item_id)
2825
 
           AND (item_sold)
2826
 
           AND (item_type != 'K'))) THEN
2827
 
       RAISE EXCEPTION 'Bill of Material Items for kits must be sold and not kits themselves';
2828
 
     END IF;
2829
 
   END IF;
2830
 
 
2831
 
  -- Over ride logic to disallow invalid data
2832
 
  IF (NEW.bomitem_createwo) THEN
2833
 
    IF (SELECT (item_type != 'M') 
2834
 
          FROM item 
2835
 
         WHERE (item_id=NEW.bomitem_item_id)) THEN
2836
 
      NEW.bomitem_createwo := FALSE;
2837
 
    END IF;
2838
 
    IF (NEW.bomitem_booitem_seq_id = -1) THEN
2839
 
      NEW.bomitem_schedatwooper := FALSE;
2840
 
    END IF;
2841
 
  END IF;
2842
 
 
2843
 
  NEW.bomitem_moddate := COALESCE(NEW.bomitem_moddate, CURRENT_DATE);
2844
 
 
2845
 
  RETURN NEW;
2846
 
END;
2847
 
$$;
2848
 
 
2849
 
 
2850
 
ALTER FUNCTION public._bomitembeforetrigger() OWNER TO admin;
2851
 
 
2852
 
--
2853
 
--
2854
 
 
2855
 
CREATE FUNCTION _bomitemsubtrigger() RETURNS trigger
2856
 
    LANGUAGE plpgsql
2857
 
    AS $$
2858
 
BEGIN
2859
 
 
2860
 
  IF (NOT checkPrivilege('MaintainBOMs')) THEN
2861
 
    RAISE EXCEPTION 'You do not have privileges to maintain Bills of Material.';
2862
 
  END IF;
2863
 
 
2864
 
  IF (TG_OP = 'DELETE') THEN
2865
 
    RETURN OLD;
2866
 
  ELSE
2867
 
    RETURN NEW;
2868
 
  END IF;
2869
 
 
2870
 
END;
2871
 
$$;
2872
 
 
2873
 
 
2874
 
ALTER FUNCTION public._bomitemsubtrigger() OWNER TO admin;
2875
 
 
2876
 
--
2877
 
--
2878
 
 
2879
 
CREATE FUNCTION _cashrcptitemaftertrigger() RETURNS trigger
2880
 
    LANGUAGE plpgsql
2881
 
    AS $$
2882
 
DECLARE
2883
 
  _total      NUMERIC;
2884
 
 
2885
 
BEGIN
2886
 
 
2887
 
  -- Checks
2888
 
  -- Total Over Application Warning
2889
 
  SELECT (cashrcpt_amount - SUM(COALESCE(cashrcptitem_amount, 0))) INTO _total
2890
 
  FROM cashrcptitem JOIN cashrcpt ON (cashrcpt_id=cashrcptitem_cashrcpt_id)
2891
 
  WHERE (cashrcptitem_cashrcpt_id=NEW.cashrcptitem_cashrcpt_id)
2892
 
  GROUP BY cashrcpt_amount;
2893
 
  IF (_total < 0.0) THEN
2894
 
    RAISE WARNING 'Warning -- the Cash Receipt has been over applied.';
2895
 
  END IF;
2896
 
  
2897
 
  RETURN NEW;
2898
 
 
2899
 
END;
2900
 
$$;
2901
 
 
2902
 
 
2903
 
ALTER FUNCTION public._cashrcptitemaftertrigger() OWNER TO admin;
2904
 
 
2905
 
--
2906
 
--
2907
 
 
2908
 
CREATE FUNCTION _cashrcptitemtrigger() RETURNS trigger
2909
 
    LANGUAGE plpgsql
2910
 
    AS $$
2911
 
DECLARE
2912
 
  _check      BOOLEAN;
2913
 
  _openAmount NUMERIC;
2914
 
 
2915
 
BEGIN
2916
 
 
2917
 
  -- Checks
2918
 
  -- Start with Privileges
2919
 
  IF (TG_OP = 'INSERT') THEN
2920
 
    SELECT checkPrivilege('MaintainCashReceipts') INTO _check;
2921
 
    IF NOT (_check) THEN
2922
 
      RAISE EXCEPTION 'You do not have privileges to add a new Cash Receipt Application.';
2923
 
    END IF;
2924
 
  ELSE
2925
 
    SELECT checkPrivilege('MaintainCashReceipts') INTO _check;
2926
 
    IF NOT (_check) THEN
2927
 
      RAISE EXCEPTION 'You do not have privileges to alter a Cash Receipt Application.';
2928
 
    END IF;
2929
 
  END IF;
2930
 
 
2931
 
  -- Over Application
2932
 
  SELECT round(currToCurr(aropen_curr_id, cashrcpt_curr_id,
2933
 
               aropen_amount - aropen_paid, cashrcpt_distdate) -
2934
 
               COALESCE((SELECT SUM(cashrcptitem_amount)
2935
 
                           FROM cashrcptitem, cashrcpt
2936
 
                           WHERE ((cashrcpt_id=cashrcptitem_cashrcpt_id)
2937
 
                             AND  (NOT cashrcpt_void)
2938
 
                             AND  (NOT cashrcpt_posted)
2939
 
                             AND  (cashrcpt_id != NEW.cashrcptitem_cashrcpt_id)
2940
 
                             AND  (cashrcptitem_aropen_id=NEW.cashrcptitem_aropen_id))), 0),2) INTO _openAmount
2941
 
  FROM aropen, cashrcpt
2942
 
  WHERE ( (aropen_id=NEW.cashrcptitem_aropen_id)
2943
 
    AND   (cashrcpt_id=NEW.cashrcptitem_cashrcpt_id) );
2944
 
  IF (NEW.cashrcptitem_amount > _openAmount) THEN
2945
 
    RAISE EXCEPTION 'You may not apply more than the balance of this item.';
2946
 
  END IF;
2947
 
 
2948
 
 
2949
 
  RETURN NEW;
2950
 
 
2951
 
END;
2952
 
$$;
2953
 
 
2954
 
 
2955
 
ALTER FUNCTION public._cashrcptitemtrigger() OWNER TO admin;
2956
 
 
2957
 
--
2958
 
--
2959
 
 
2960
 
CREATE FUNCTION _cashrcptmisctrigger() RETURNS trigger
2961
 
    LANGUAGE plpgsql
2962
 
    AS $$
2963
 
DECLARE
2964
 
  _check      BOOLEAN;
2965
 
 
2966
 
BEGIN
2967
 
 
2968
 
  -- Checks
2969
 
  -- Start with Privileges
2970
 
  IF (TG_OP = 'INSERT') THEN
2971
 
    SELECT checkPrivilege('MaintainCashReceipts') INTO _check;
2972
 
    IF NOT (_check) THEN
2973
 
      RAISE EXCEPTION 'You do not have privileges to add a new Cash Receipt Misc. Application.';
2974
 
    END IF;
2975
 
  ELSE
2976
 
    SELECT checkPrivilege('MaintainCashReceipts') INTO _check;
2977
 
    IF NOT (_check) THEN
2978
 
      RAISE EXCEPTION 'You do not have privileges to alter a Cash Receipt Misc. Application.';
2979
 
    END IF;
2980
 
  END IF;
2981
 
 
2982
 
  -- Account is required
2983
 
  IF (NEW.cashrcptmisc_accnt_id IS NULL) THEN
2984
 
    RAISE EXCEPTION 'You must supply a valid GL Account.';
2985
 
  END IF;
2986
 
 
2987
 
  -- Amount is required
2988
 
  IF (COALESCE(NEW.cashrcptmisc_amount, 0) = 0) THEN
2989
 
    RAISE EXCEPTION 'You must supply a valid Amount.';
2990
 
  END IF;
2991
 
 
2992
 
  RETURN NEW;
2993
 
 
2994
 
END;
2995
 
$$;
2996
 
 
2997
 
 
2998
 
ALTER FUNCTION public._cashrcptmisctrigger() OWNER TO admin;
2999
 
 
3000
 
--
3001
 
--
3002
 
 
3003
 
CREATE FUNCTION _cashrcpttrigger() RETURNS trigger
3004
 
    LANGUAGE plpgsql
3005
 
    AS $$
3006
 
DECLARE
3007
 
  _check      BOOLEAN;
3008
 
  _checkId    INTEGER;
3009
 
  _currId     INTEGER;
3010
 
  _bankCurrId INTEGER;
3011
 
  _currrate   NUMERIC;
3012
 
 
3013
 
BEGIN
3014
 
 
3015
 
  -- Checks
3016
 
  -- Start with privileges
3017
 
  IF (TG_OP = 'INSERT') THEN
3018
 
    SELECT checkPrivilege('MaintainCashReceipts') INTO _check;
3019
 
    IF NOT (_check) THEN
3020
 
      RAISE EXCEPTION 'You do not have privileges to add new Cash Receipts.';
3021
 
    END IF;
3022
 
  ELSE
3023
 
    SELECT checkPrivilege('MaintainCashReceipts') INTO _check;
3024
 
    IF NOT (_check) THEN
3025
 
      RAISE EXCEPTION 'You do not have privileges to alter a Cash Receipt.';
3026
 
    END IF;
3027
 
  END IF;
3028
 
 
3029
 
  -- Currency must be same as Bank Currency
3030
 
  IF (TG_OP = 'INSERT') THEN
3031
 
    _currId = COALESCE(NEW.cashrcpt_curr_id, basecurrid());
3032
 
 
3033
 
     --- clear the number from the issue cache
3034
 
    PERFORM clearNumberIssue('CashRcptNumber', NEW.cashrcpt_number);
3035
 
  ELSE
3036
 
    _currId = NEW.cashrcpt_curr_id;
3037
 
  END IF;
3038
 
 
3039
 
  IF (NEW.cashrcpt_curr_rate IS NULL) THEN
3040
 
    SELECT curr_rate INTO _currrate
3041
 
    FROM curr_rate
3042
 
    WHERE ( (NEW.cashrcpt_curr_id=curr_id)
3043
 
      AND ( NEW.cashrcpt_distdate BETWEEN curr_effective 
3044
 
                                 AND curr_expires) );
3045
 
    IF (FOUND) THEN
3046
 
      NEW.cashrcpt_curr_rate := _currrate;
3047
 
    ELSE
3048
 
      RAISE EXCEPTION 'Currency exchange rate not found';
3049
 
    END IF;
3050
 
  END IF;
3051
 
 
3052
 
  -- Create CashReceiptPosted Event
3053
 
  IF (TG_OP = 'UPDATE') THEN
3054
 
    IF (OLD.cashrcpt_posted=FALSE AND NEW.cashrcpt_posted=TRUE) THEN
3055
 
      PERFORM postEvent('CashReceiptPosted', NULL, NEW.cashrcpt_id,
3056
 
                        NULL,
3057
 
                        (cust_number || '-' ||
3058
 
                        NEW.cashrcpt_docnumber || ' ' ||
3059
 
                        currConcat(NEW.cashrcpt_curr_id) ||
3060
 
                        formatMoney(NEW.cashrcpt_amount)),
3061
 
                        NULL, NULL, NULL, NULL)
3062
 
      FROM custinfo
3063
 
      WHERE (cust_id=NEW.cashrcpt_cust_id);
3064
 
    END IF;
3065
 
  END IF;
3066
 
 
3067
 
  RETURN NEW;
3068
 
 
3069
 
END;
3070
 
$$;
3071
 
 
3072
 
 
3073
 
ALTER FUNCTION public._cashrcpttrigger() OWNER TO admin;
3074
 
 
3075
 
--
3076
 
--
3077
 
 
3078
 
CREATE FUNCTION _ccardtrigger() RETURNS trigger
3079
 
    LANGUAGE plpgsql
3080
 
    AS $$
3081
 
DECLARE
3082
 
 
3083
 
BEGIN
3084
 
 
3085
 
  New.ccard_lastupdated := current_timestamp;
3086
 
  New.ccard_last_updated_by_username := getEffectiveXtUser();
3087
 
 
3088
 
  IF (TG_OP = 'UPDATE') THEN
3089
 
    INSERT INTO ccardaud
3090
 
         VALUES (nextval('ccardaud_ccardaud_id_seq'), NEW.ccard_id,
3091
 
                 OLD.ccard_seq, NEW.ccard_seq, OLD.ccard_cust_id, NEW.ccard_cust_id,
3092
 
                 OLD.ccard_active, NEW.ccard_active, OLD.ccard_name, NEW.ccard_name,
3093
 
                 OLD.ccard_address1, NEW.ccard_address1, OLD.ccard_address2,
3094
 
                 NEW.ccard_address2, OLD.ccard_city, NEW.ccard_city, OLD.ccard_state,
3095
 
                 NEW.ccard_state, OLD.ccard_zip, NEW.ccard_zip, OLD.ccard_country,
3096
 
                 NEW.ccard_country, OLD.ccard_number, NEW.ccard_number, OLD.ccard_debit,
3097
 
                 NEW.ccard_debit, OLD.ccard_month_expired, NEW.ccard_month_expired,
3098
 
                 OLD.ccard_year_expired, NEW.ccard_year_expired, OLD.ccard_type, NEW.ccard_type);
3099
 
  ELSE
3100
 
    INSERT INTO ccardaud
3101
 
         VALUES (nextval('ccardaud_ccardaud_id_seq'), NEW.ccard_id,
3102
 
                 NULL, NEW.ccard_seq, NULL, NEW.ccard_cust_id, NULL,
3103
 
                 NEW.ccard_active, NULL, NEW.ccard_name, NULL,
3104
 
                 NEW.ccard_address1, NULL, NEW.ccard_address2, NULL,
3105
 
                 NEW.ccard_city, NULL, NEW.ccard_state, NULL,
3106
 
                 NEW.ccard_zip, NULL, NEW.ccard_country, NULL,
3107
 
                 NEW.ccard_number, NULL, NEW.ccard_debit, NULL,
3108
 
                 NEW.ccard_month_expired, NULL, NEW.ccard_year_expired, NULL,
3109
 
                 NEW.ccard_type);
3110
 
  END IF;
3111
 
 
3112
 
  RETURN NEW;
3113
 
 
3114
 
END;
3115
 
$$;
3116
 
 
3117
 
 
3118
 
ALTER FUNCTION public._ccardtrigger() OWNER TO admin;
3119
 
 
3120
 
--
3121
 
--
3122
 
 
3123
 
CREATE FUNCTION _ccpaybeforetrigger() RETURNS trigger
3124
 
    LANGUAGE plpgsql
3125
 
    AS $$
3126
 
DECLARE
3127
 
  _cardType TEXT;
3128
 
 
3129
 
BEGIN
3130
 
  IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN
3131
 
    -- If ccpay_ccard_id is set, we don't care if ccpay_card_type is set,
3132
 
    -- we want to get the Card Type from ccard.
3133
 
    IF (NEW.ccpay_ccard_id IS NOT NULL) THEN
3134
 
      SELECT ccard_type INTO _cardType
3135
 
      FROM ccard
3136
 
      WHERE ccard_id = NEW.ccpay_ccard_id;
3137
 
 
3138
 
      IF (_cardType IS NOT NULL) THEN
3139
 
        NEW.ccpay_card_type = _cardType;
3140
 
      END IF;
3141
 
    END IF;
3142
 
  END IF;
3143
 
 
3144
 
  RETURN NEW;
3145
 
END;
3146
 
$$;
3147
 
 
3148
 
 
3149
 
ALTER FUNCTION public._ccpaybeforetrigger() OWNER TO admin;
3150
 
 
3151
 
--
3152
 
--
3153
 
 
3154
 
CREATE FUNCTION _charasshistorytrigger() RETURNS trigger
3155
 
    LANGUAGE plpgsql
3156
 
    AS $$
3157
 
BEGIN
3158
 
  IF(TG_OP = 'DELETE') THEN
3159
 
    IF (OLD.charass_target_type = 'INCDT') THEN
3160
 
      INSERT INTO incdthist
3161
 
            (incdthist_incdt_id, incdthist_descrip)
3162
 
      VALUES(OLD.charass_target_id,
3163
 
             ('Characteristic ' || 
3164
 
               COALESCE((SELECT char_name 
3165
 
                           FROM char
3166
 
                          WHERE (char_id=OLD.charass_char_id)), '')
3167
 
              || ' Deleted: "' || 
3168
 
              COALESCE(OLD.charass_value,'')
3169
 
              || '"') );
3170
 
    END IF;
3171
 
    RETURN OLD;
3172
 
  ELSIF (NEW.charass_target_type = 'INCDT') THEN
3173
 
    IF (TG_OP = 'INSERT') THEN
3174
 
      INSERT INTO incdthist
3175
 
            (incdthist_incdt_id, incdthist_descrip)
3176
 
      VALUES(NEW.charass_target_id,
3177
 
             ('Characteristic ' || 
3178
 
               COALESCE((SELECT char_name 
3179
 
                           FROM char
3180
 
                          WHERE (char_id=NEW.charass_char_id)), '')
3181
 
              || ' Added: "' || 
3182
 
              COALESCE(NEW.charass_value,'')
3183
 
              || '"') );
3184
 
    ELSIF (TG_OP = 'UPDATE') THEN
3185
 
      IF (COALESCE(NEW.charass_value,'') <> COALESCE(OLD.charass_value,'')) THEN
3186
 
        INSERT INTO incdthist
3187
 
              (incdthist_incdt_id, incdthist_descrip)
3188
 
        VALUES(NEW.charass_target_id,
3189
 
               ('Characteristic ' || 
3190
 
                 COALESCE((SELECT char_name 
3191
 
                             FROM char
3192
 
                            WHERE (char_id=NEW.charass_char_id)), '')
3193
 
                || ' Changed: "' || 
3194
 
                COALESCE(OLD.charass_value,'')
3195
 
                || '" -> "' ||
3196
 
                COALESCE(NEW.charass_value,'')
3197
 
                || '"') );
3198
 
      END IF;
3199
 
    END IF;
3200
 
  END IF;
3201
 
  RETURN NEW;
3202
 
END;
3203
 
$$;
3204
 
 
3205
 
 
3206
 
ALTER FUNCTION public._charasshistorytrigger() OWNER TO admin;
3207
 
 
3208
 
--
3209
 
--
3210
 
 
3211
 
CREATE FUNCTION _charasstrigger() RETURNS trigger
3212
 
    LANGUAGE plpgsql
3213
 
    AS $$
3214
 
BEGIN
3215
 
 
3216
 
   IF (NEW.charass_target_type = 'I' AND NOT checkPrivilege('MaintainItemMasters')) THEN
3217
 
     RAISE EXCEPTION 'You do not have privileges to maintain Items.';
3218
 
   END IF;
3219
 
 
3220
 
   IF (NEW.charass_target_type = 'C' AND NOT checkPrivilege('MaintainCustomerMasters')) THEN
3221
 
     RAISE EXCEPTION 'You do not have privileges to maintain Customers.';
3222
 
   END IF;
3223
 
 
3224
 
  IF (NEW.charass_char_id IS NULL) THEN
3225
 
        RAISE EXCEPTION 'You must supply a valid Characteristic ID.';
3226
 
  END IF;
3227
 
 
3228
 
  IF (NEW.charass_default) THEN
3229
 
    UPDATE charass
3230
 
    SET charass_default = false 
3231
 
    WHERE ((charass_target_id=NEW.charass_target_id)
3232
 
    AND  (charass_target_type=NEW.charass_target_type)
3233
 
    AND  (charass_char_id=NEW.charass_char_id)
3234
 
    AND  (charass_id <> NEW.charass_ID));
3235
 
  END IF;
3236
 
 
3237
 
  IF (NEW.charass_target_type = 'INCDT') THEN
3238
 
    UPDATE incdt SET incdt_updated = now() WHERE incdt_id = NEW.charass_target_id;
3239
 
  END IF;
3240
 
  
3241
 
  RETURN NEW;
3242
 
END;
3243
 
$$;
3244
 
 
3245
 
 
3246
 
ALTER FUNCTION public._charasstrigger() OWNER TO admin;
3247
 
 
3248
 
--
3249
 
--
3250
 
 
3251
 
CREATE FUNCTION _charbeforetrigger() RETURNS trigger
3252
 
    LANGUAGE plpgsql
3253
 
    AS $$
3254
 
BEGIN
3255
 
  IF (NOT checkPrivilege('MaintainCharacteristics')) THEN
3256
 
    RAISE EXCEPTION 'You do not have privileges to maintain Characteristics.';
3257
 
  END IF;
3258
 
 
3259
 
  RETURN NEW;
3260
 
END;
3261
 
$$;
3262
 
 
3263
 
 
3264
 
ALTER FUNCTION public._charbeforetrigger() OWNER TO admin;
3265
 
 
3266
 
--
3267
 
--
3268
 
 
3269
 
CREATE FUNCTION _charopttrigger() RETURNS trigger
3270
 
    LANGUAGE plpgsql
3271
 
    AS $$
3272
 
BEGIN
3273
 
  IF (NOT checkPrivilege('MaintainCharacteristics')) THEN
3274
 
    RAISE EXCEPTION 'You do not have privileges to maintain Characteristic options.';
3275
 
  END IF;
3276
 
 
3277
 
  IF (TG_OP = 'UPDATE') THEN
3278
 
    UPDATE charass SET
3279
 
      charass_value = NEW.charopt_value
3280
 
    WHERE ((charass_char_id=NEW.charopt_char_id)
3281
 
      AND (charass_value=OLD.charopt_value));
3282
 
  END IF;
3283
 
 
3284
 
  IF (TG_OP = 'DELETE') THEN
3285
 
    IF (SELECT (count(charass_id) > 0)
3286
 
        FROM charass
3287
 
        WHERE ((charass_char_id=OLD.charopt_char_id)
3288
 
         AND (charass_value=OLD.charopt_value))) THEN
3289
 
       RAISE EXCEPTION 'This characteristic option value is in use and can not be deleted.';
3290
 
    END IF;
3291
 
  END IF;
3292
 
  
3293
 
  RETURN NEW;
3294
 
END;
3295
 
$$;
3296
 
 
3297
 
 
3298
 
ALTER FUNCTION public._charopttrigger() OWNER TO admin;
3299
 
 
3300
 
--
3301
 
--
3302
 
 
3303
 
CREATE FUNCTION _checkheadbeforetrigger() RETURNS trigger
3304
 
    LANGUAGE plpgsql
3305
 
    AS $$
3306
 
DECLARE 
3307
 
  _amount NUMERIC;
3308
 
  _currrate NUMERIC;
3309
 
 
3310
 
BEGIN
3311
 
 
3312
 
  IF (TG_OP = 'INSERT' AND NEW.checkhead_curr_rate IS NULL) THEN
3313
 
    SELECT curr_rate INTO _currrate
3314
 
    FROM curr_rate
3315
 
    WHERE ( (NEW.checkhead_curr_id=curr_id)
3316
 
      AND ( NEW.checkhead_checkdate BETWEEN curr_effective 
3317
 
                                   AND curr_expires) );
3318
 
    IF (FOUND) THEN
3319
 
      NEW.checkhead_curr_rate := _currrate;
3320
 
    ELSE
3321
 
      RAISE EXCEPTION 'Currency exchange rate not found';
3322
 
    END IF;
3323
 
  END IF;
3324
 
 
3325
 
  IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN
3326
 
    IF (NOT EXISTS (SELECT checkrecip_id
3327
 
                    FROM checkrecip
3328
 
                    WHERE ((checkrecip_type=NEW.checkhead_recip_type)
3329
 
                      AND  (checkrecip_id=NEW.checkhead_recip_id)) )) THEN
3330
 
      RAISE EXCEPTION 'Cannot verify recipient for check % (type %  id %)',
3331
 
                      NEW.checkhead_number, NEW.checkhead_recip_type,
3332
 
                      NEW.checkhead_recip_id;
3333
 
    END IF;
3334
 
 
3335
 
    IF (NEW.checkhead_journalnumber IS NOT NULL
3336
 
        AND NOT EXISTS (SELECT jrnluse_number
3337
 
                        FROM jrnluse
3338
 
                        WHERE (jrnluse_number=NEW.checkhead_journalnumber))
3339
 
        ) THEN
3340
 
      RAISE EXCEPTION 'Journal Number % does not exist and cannot be used for check %.',
3341
 
                      NEW.checkhead_journalnumber, NEW.checkhead_number;
3342
 
    END IF;
3343
 
  END IF;
3344
 
 
3345
 
  RETURN NEW;
3346
 
END;
3347
 
$$;
3348
 
 
3349
 
 
3350
 
ALTER FUNCTION public._checkheadbeforetrigger() OWNER TO admin;
3351
 
 
3352
 
--
3353
 
--
3354
 
 
3355
 
CREATE FUNCTION _cmheadbeforetrigger() RETURNS trigger
3356
 
    LANGUAGE plpgsql
3357
 
    AS $$
3358
 
DECLARE
3359
 
  _check BOOLEAN;
3360
 
  _id INTEGER;
3361
 
BEGIN
3362
 
  -- Checks
3363
 
  -- Start with privileges
3364
 
  SELECT checkPrivilege('MaintainCreditMemos') INTO _check;
3365
 
  IF ( (TG_OP = 'INSERT') OR (TG_OP = 'DELETE') ) THEN
3366
 
    IF NOT (_check) THEN
3367
 
      RAISE EXCEPTION 'You do not have privileges to maintain Credit Memos.';
3368
 
    END IF;
3369
 
  END IF;
3370
 
  IF (TG_OP = 'UPDATE') THEN
3371
 
    IF ((OLD.cmhead_printed = NEW.cmhead_printed) AND NOT (_check) ) THEN
3372
 
      RAISE EXCEPTION 'You do not have privileges to maintain Credit Memos.';
3373
 
    END IF;
3374
 
  END IF;
3375
 
 
3376
 
  IF (TG_OP = 'DELETE') THEN
3377
 
    DELETE FROM cmheadtax
3378
 
    WHERE (taxhist_parent_id=OLD.cmhead_id);
3379
 
 
3380
 
    RETURN OLD;
3381
 
  END IF;
3382
 
 
3383
 
  IF ( (NEW.cmhead_number IS NULL) OR (LENGTH(NEW.cmhead_number) = 0) ) THEN
3384
 
    RAISE EXCEPTION 'You must enter a valid Memo # for this Credit Memo.';
3385
 
  END IF;
3386
 
 
3387
 
  IF (TG_OP = 'INSERT') THEN
3388
 
    SELECT cmhead_id INTO _id
3389
 
    FROM cmhead
3390
 
    WHERE (cmhead_number=NEW.cmhead_number);
3391
 
    IF (FOUND) THEN
3392
 
      RAISE EXCEPTION 'The Memo # is already in use.';
3393
 
    END IF;
3394
 
 
3395
 
    IF (fetchMetricText('CMNumberGeneration') IN ('A','O')) THEN
3396
 
      --- clear the number from the issue cache
3397
 
      PERFORM clearNumberIssue('CmNumber', NEW.cmhead_number);
3398
 
    ELSIF (fetchMetricText('CMNumberGeneration') = 'S') THEN
3399
 
      --- clear the number from the issue cache
3400
 
      PERFORM clearNumberIssue('SoNumber', NEW.cmhead_number);
3401
 
    END IF;
3402
 
  END IF;
3403
 
 
3404
 
  IF (NEW.cmhead_cust_id IS NOT NULL) THEN
3405
 
    SELECT cust_id INTO _id
3406
 
    FROM custinfo
3407
 
    WHERE (cust_id=NEW.cmhead_cust_id);
3408
 
    IF (NOT FOUND) THEN
3409
 
      RAISE EXCEPTION 'You must enter a valid Customer # for this Credit Memo.';
3410
 
    END IF;
3411
 
  END IF;
3412
 
 
3413
 
  IF ( (NEW.cmhead_misc > 0) AND (NEW.cmhead_misc_accnt_id = -1) ) THEN
3414
 
    RAISE EXCEPTION 'You may not enter a Misc. Charge without indicating the G/L Sales Account.';
3415
 
  END IF;
3416
 
 
3417
 
  RETURN NEW;
3418
 
END;
3419
 
$$;
3420
 
 
3421
 
 
3422
 
ALTER FUNCTION public._cmheadbeforetrigger() OWNER TO admin;
3423
 
 
3424
 
--
3425
 
--
3426
 
 
3427
 
CREATE FUNCTION _cmheadtrigger() RETURNS trigger
3428
 
    LANGUAGE plpgsql
3429
 
    AS $$
3430
 
BEGIN
3431
 
  IF (TG_OP = 'DELETE') THEN
3432
 
    -- If this was created by a return, then reset the return
3433
 
    IF (OLD.cmhead_rahead_id IS NOT NULL) THEN
3434
 
      UPDATE rahead SET
3435
 
        rahead_headcredited=false
3436
 
      WHERE (rahead_id=OLD.cmhead_rahead_id);
3437
 
      DELETE FROM rahist
3438
 
      WHERE ((rahist_rahead_id=OLD.cmhead_rahead_id)
3439
 
      AND (rahist_source='CM')
3440
 
      AND (rahist_source_id=OLD.cmhead_id));
3441
 
    END IF;
3442
 
    RETURN OLD;
3443
 
  END IF;
3444
 
 
3445
 
  IF (TG_OP = 'INSERT') THEN
3446
 
 
3447
 
  -- Calculate Freight Tax
3448
 
    IF (NEW.cmhead_freight <> 0) THEN
3449
 
      PERFORM calculateTaxHist( 'cmheadtax',
3450
 
                                NEW.cmhead_id,
3451
 
                                NEW.cmhead_taxzone_id,
3452
 
                                getFreightTaxtypeId(),
3453
 
                                NEW.cmhead_docdate,
3454
 
                                NEW.cmhead_curr_id,
3455
 
                                NEW.cmhead_freight * -1 );
3456
 
    END IF;
3457
 
  END IF;
3458
 
 
3459
 
  IF (TG_OP = 'UPDATE') THEN
3460
 
 
3461
 
    IF ( (NEW.cmhead_freight <> OLD.cmhead_freight) OR
3462
 
         (COALESCE(NEW.cmhead_taxzone_id,-1) <> COALESCE(OLD.cmhead_taxzone_id,-1)) OR
3463
 
         (NEW.cmhead_docdate <> OLD.cmhead_docdate) OR
3464
 
         (NEW.cmhead_curr_id <> OLD.cmhead_curr_id) ) THEN
3465
 
  -- Calculate cmhead Tax
3466
 
      PERFORM calculateTaxHist( 'cmheadtax',
3467
 
                                NEW.cmhead_id,
3468
 
                                NEW.cmhead_taxzone_id,
3469
 
                                getFreightTaxtypeId(),
3470
 
                                NEW.cmhead_docdate,
3471
 
                                NEW.cmhead_curr_id,
3472
 
                                NEW.cmhead_freight * -1 );
3473
 
    END IF;
3474
 
 
3475
 
    IF ( (COALESCE(NEW.cmhead_taxzone_id,-1) <> COALESCE(OLD.cmhead_taxzone_id,-1)) OR
3476
 
         (NEW.cmhead_docdate <> OLD.cmhead_docdate) OR
3477
 
         (NEW.cmhead_curr_id <> OLD.cmhead_curr_id) ) THEN
3478
 
  -- Calculate cmitem Tax
3479
 
      IF (COALESCE(NEW.cmhead_taxzone_id,-1) <> COALESCE(OLD.cmhead_taxzone_id,-1)) THEN
3480
 
    -- Cmitem trigger will calculate tax
3481
 
        UPDATE cmitem SET cmitem_taxtype_id=getItemTaxType(itemsite_item_id,NEW.cmhead_taxzone_id)
3482
 
        FROM itemsite 
3483
 
        WHERE ((itemsite_id=cmitem_itemsite_id)
3484
 
          AND (cmitem_cmhead_id=NEW.cmhead_id));
3485
 
      ELSE
3486
 
        PERFORM calculateTaxHist( 'cmitemtax',
3487
 
                                  cmitem_id,
3488
 
                                  NEW.cmhead_taxzone_id,
3489
 
                                  cmitem_taxtype_id,
3490
 
                                  NEW.cmhead_docdate,
3491
 
                                  NEW.cmhead_curr_id,
3492
 
                                  (cmitem_qtycredit * cmitem_qty_invuomratio) *
3493
 
                                  (cmitem_unitprice / cmitem_price_invuomratio) * -1)
3494
 
        FROM cmitem
3495
 
        WHERE (cmitem_cmhead_id = NEW.cmhead_id);
3496
 
      END IF;
3497
 
    END IF;
3498
 
 
3499
 
  END IF;
3500
 
 
3501
 
 
3502
 
  RETURN NEW;
3503
 
END;
3504
 
$$;
3505
 
 
3506
 
 
3507
 
ALTER FUNCTION public._cmheadtrigger() OWNER TO admin;
3508
 
 
3509
 
--
3510
 
--
3511
 
 
3512
 
CREATE FUNCTION _cmitembeforetrigger() RETURNS trigger
3513
 
    LANGUAGE plpgsql
3514
 
    AS $$
3515
 
DECLARE
3516
 
  _check BOOLEAN;
3517
 
  _id INTEGER;
3518
 
BEGIN
3519
 
  -- Checks
3520
 
  -- Start with privileges
3521
 
  SELECT checkPrivilege('MaintainCreditMemos') INTO _check;
3522
 
  IF NOT (_check) THEN
3523
 
    RAISE EXCEPTION 'You do not have privileges to maintain Credit Memos.';
3524
 
  END IF;
3525
 
 
3526
 
  IF (TG_OP = 'DELETE') THEN
3527
 
    DELETE FROM cmitemtax
3528
 
    WHERE (taxhist_parent_id=OLD.cmitem_id);
3529
 
 
3530
 
    RETURN OLD;
3531
 
  END IF;
3532
 
 
3533
 
  IF (TG_OP = 'INSERT') THEN
3534
 
    IF ( (NEW.cmitem_qtycredit IS NULL) OR (NEW.cmitem_qtycredit = 0) ) THEN
3535
 
      RAISE EXCEPTION 'Quantity to Credit must be greater than zero.';
3536
 
    END IF;
3537
 
    SELECT cmitem_id INTO _id
3538
 
    FROM cmitem
3539
 
    WHERE ( (cmitem_cmhead_id=NEW.cmitem_cmhead_id) AND (cmitem_linenumber=NEW.cmitem_linenumber) );
3540
 
    IF (FOUND) THEN
3541
 
      RAISE EXCEPTION 'The Memo Line Number is already in use.';
3542
 
    END IF;
3543
 
  END IF;
3544
 
 
3545
 
  RETURN NEW;
3546
 
END;
3547
 
$$;
3548
 
 
3549
 
 
3550
 
ALTER FUNCTION public._cmitembeforetrigger() OWNER TO admin;
3551
 
 
3552
 
--
3553
 
--
3554
 
 
3555
 
CREATE FUNCTION _cmitemtrigger() RETURNS trigger
3556
 
    LANGUAGE plpgsql
3557
 
    AS $$
3558
 
DECLARE
3559
 
  _ext NUMERIC;
3560
 
  _r RECORD;
3561
 
 
3562
 
BEGIN
3563
 
  IF (TG_OP = 'DELETE') THEN
3564
 
 
3565
 
    IF (OLD.cmitem_raitem_id) IS NOT NULL THEN
3566
 
      _ext := ROUND((OLD.cmitem_qtycredit * OLD.cmitem_qty_invuomratio) *  (OLD.cmitem_unitprice / OLD.cmitem_price_invuomratio),2);
3567
 
      UPDATE raitem SET
3568
 
        raitem_status = 'O',
3569
 
        raitem_qtycredited = raitem_qtycredited-OLD.cmitem_qtycredit,
3570
 
        raitem_amtcredited = raitem_amtcredited-_ext
3571
 
      WHERE (raitem_id=OLD.cmitem_raitem_id);
3572
 
    END IF;
3573
 
    RETURN OLD;
3574
 
  END IF;
3575
 
 
3576
 
  SELECT * INTO _r
3577
 
  FROM cmhead
3578
 
  WHERE (cmhead_id=NEW.cmitem_cmhead_id);
3579
 
  IF (NOT FOUND) THEN
3580
 
    RAISE EXCEPTION 'Credit Memo head not found';
3581
 
  END IF;
3582
 
 
3583
 
  IF (TG_OP = 'INSERT') THEN
3584
 
 
3585
 
  -- Calculate Tax
3586
 
      PERFORM calculateTaxHist( 'cmitemtax',
3587
 
                                NEW.cmitem_id,
3588
 
                                COALESCE(_r.cmhead_taxzone_id, -1),
3589
 
                                NEW.cmitem_taxtype_id,
3590
 
                                COALESCE(_r.cmhead_docdate, CURRENT_DATE),
3591
 
                                COALESCE(_r.cmhead_curr_id, -1),
3592
 
                                (NEW.cmitem_qtycredit * NEW.cmitem_qty_invuomratio) *
3593
 
                                (NEW.cmitem_unitprice / NEW.cmitem_price_invuomratio) * -1);
3594
 
  END IF;
3595
 
 
3596
 
  IF (TG_OP = 'UPDATE') THEN
3597
 
 
3598
 
  -- Calculate Tax
3599
 
    IF ( (NEW.cmitem_qtycredit <> OLD.cmitem_qtycredit) OR
3600
 
         (NEW.cmitem_qty_invuomratio <> OLD.cmitem_qty_invuomratio) OR
3601
 
         (NEW.cmitem_unitprice <> OLD.cmitem_unitprice) OR
3602
 
         (NEW.cmitem_price_invuomratio <> OLD.cmitem_price_invuomratio) OR
3603
 
         (COALESCE(NEW.cmitem_taxtype_id, -1) <> COALESCE(OLD.cmitem_taxtype_id, -1)) ) THEN
3604
 
      PERFORM calculateTaxHist( 'cmitemtax',
3605
 
                                NEW.cmitem_id,
3606
 
                                COALESCE(_r.cmhead_taxzone_id, -1),
3607
 
                                NEW.cmitem_taxtype_id,
3608
 
                                COALESCE(_r.cmhead_docdate, CURRENT_DATE),
3609
 
                                COALESCE(_r.cmhead_curr_id, -1),
3610
 
                                (NEW.cmitem_qtycredit * NEW.cmitem_qty_invuomratio) *
3611
 
                                (NEW.cmitem_unitprice / NEW.cmitem_price_invuomratio) * -1);
3612
 
    END IF;
3613
 
  END IF;
3614
 
 
3615
 
 
3616
 
  RETURN NEW;
3617
 
END;
3618
 
$$;
3619
 
 
3620
 
 
3621
 
ALTER FUNCTION public._cmitemtrigger() OWNER TO admin;
3622
 
 
3623
 
--
3624
 
--
3625
 
 
3626
 
CREATE FUNCTION _cntcttrigger() RETURNS trigger
3627
 
    LANGUAGE plpgsql
3628
 
    AS $$
3629
 
BEGIN
3630
 
 
3631
 
  NEW.cntct_name := formatCntctName(NULL, NEW.cntct_first_name, NEW.cntct_middle, NEW.cntct_last_name, NEW.cntct_suffix);
3632
 
  NEW.cntct_email := lower(NEW.cntct_email);
3633
 
 
3634
 
  IF (TG_OP = 'INSERT') THEN
3635
 
    --- clear the number from the issue cache
3636
 
    PERFORM clearNumberIssue('ContactNumber', NEW.cntct_number);
3637
 
  END IF;
3638
 
  
3639
 
  RETURN NEW;
3640
 
END;
3641
 
$$;
3642
 
 
3643
 
 
3644
 
ALTER FUNCTION public._cntcttrigger() OWNER TO admin;
3645
 
 
3646
 
--
3647
 
--
3648
 
 
3649
 
CREATE FUNCTION _cntcttriggerafter() RETURNS trigger
3650
 
    LANGUAGE plpgsql
3651
 
    AS $$
3652
 
DECLARE
3653
 
  _cntctemlid INTEGER;
3654
 
  _rows INTEGER;
3655
 
BEGIN
3656
 
  IF (TG_OP = 'INSERT') THEN
3657
 
    IF(length(coalesce(NEW.cntct_email,'')) > 0) THEN
3658
 
      INSERT INTO cntcteml (
3659
 
        cntcteml_cntct_id, cntcteml_primary, cntcteml_email )
3660
 
      VALUES (
3661
 
        NEW.cntct_id, true, NEW.cntct_email );
3662
 
    END IF;
3663
 
    PERFORM postComment('ChangeLog', 'T', NEW.cntct_id,
3664
 
                        ('Created by ' || getEffectiveXtUser()));
3665
 
  ELSIF (TG_OP = 'UPDATE') THEN
3666
 
    IF (OLD.cntct_email != NEW.cntct_email) THEN
3667
 
      SELECT cntcteml_id INTO _cntctemlid
3668
 
      FROM cntcteml
3669
 
      WHERE ((cntcteml_cntct_id=NEW.cntct_id)
3670
 
        AND (cntcteml_email=NEW.cntct_email));
3671
 
 
3672
 
      GET DIAGNOSTICS _rows = ROW_COUNT;
3673
 
      IF (_rows = 0) THEN
3674
 
        UPDATE cntcteml SET
3675
 
          cntcteml_primary=false
3676
 
        WHERE ((cntcteml_cntct_id=NEW.cntct_id)
3677
 
         AND (cntcteml_primary=true));
3678
 
       
3679
 
        INSERT INTO cntcteml (
3680
 
          cntcteml_cntct_id, cntcteml_primary, cntcteml_email )
3681
 
        VALUES (
3682
 
          NEW.cntct_id, true, NEW.cntct_email ); 
3683
 
      ELSE
3684
 
        UPDATE cntcteml SET
3685
 
          cntcteml_primary=false
3686
 
        WHERE ((cntcteml_cntct_id=NEW.cntct_id)
3687
 
         AND (cntcteml_primary=true));
3688
 
 
3689
 
        UPDATE cntcteml SET
3690
 
          cntcteml_primary=true
3691
 
        WHERE (cntcteml_id=_cntctemlid);
3692
 
      END IF;
3693
 
    END IF;
3694
 
  ELSIF (TG_OP = 'DELETE') THEN
3695
 
      DELETE FROM comment
3696
 
       WHERE (comment_source_id=OLD.cntct_id AND comment_source = 'T');
3697
 
      DELETE FROM docass
3698
 
       WHERE (docass_source_id=OLD.cntct_id AND docass_source_type = 'T')
3699
 
          OR (docass_target_id=OLD.cntct_id AND docass_target_type = 'T');
3700
 
      
3701
 
      RETURN OLD;
3702
 
  END IF;
3703
 
 
3704
 
  RETURN NEW;
3705
 
END;
3706
 
$$;
3707
 
 
3708
 
 
3709
 
ALTER FUNCTION public._cntcttriggerafter() OWNER TO admin;
3710
 
 
3711
 
--
3712
 
--
3713
 
 
3714
 
CREATE FUNCTION _cntcttriggerbeforedelete() RETURNS trigger
3715
 
    LANGUAGE plpgsql
3716
 
    AS $$
3717
 
BEGIN
3718
 
  IF (TG_OP = 'DELETE') THEN
3719
 
    DELETE FROM cntctaddr WHERE cntctaddr_cntct_id=OLD.cntct_id;
3720
 
    DELETE FROM cntctdata WHERE cntctdata_cntct_id=OLD.cntct_id;
3721
 
    DELETE FROM cntcteml  WHERE cntcteml_cntct_id=OLD.cntct_id;
3722
 
    DELETE FROM docass WHERE docass_source_id = OLD.cntct_id AND docass_source_type = 'T';
3723
 
    DELETE FROM docass WHERE docass_target_id = OLD.cntct_id AND docass_target_type = 'T';
3724
 
 
3725
 
    -- these have denormalized cntct info so it should be ok to update them
3726
 
    UPDATE cohead SET cohead_billto_cntct_id=NULL
3727
 
     WHERE cohead_billto_cntct_id=OLD.cntct_id;
3728
 
    UPDATE cohead SET cohead_shipto_cntct_id=NULL
3729
 
     WHERE cohead_shipto_cntct_id=OLD.cntct_id;
3730
 
 
3731
 
    UPDATE pohead SET pohead_vend_cntct_id=NULL
3732
 
     WHERE pohead_vend_cntct_id=OLD.cntct_id;
3733
 
    UPDATE pohead SET pohead_shipto_cntct_id=NULL
3734
 
     WHERE pohead_shipto_cntct_id=OLD.cntct_id;
3735
 
 
3736
 
    UPDATE quhead SET quhead_billto_cntct_id=NULL
3737
 
     WHERE quhead_billto_cntct_id=OLD.cntct_id;
3738
 
    UPDATE quhead SET quhead_shipto_cntct_id=NULL
3739
 
     WHERE quhead_shipto_cntct_id=OLD.cntct_id;
3740
 
 
3741
 
    IF (fetchMetricBool('MultiWhs')) THEN
3742
 
      UPDATE tohead SET tohead_destcntct_id=NULL
3743
 
       WHERE tohead_destcntct_id=OLD.cntct_id;
3744
 
      UPDATE tohead SET tohead_srccntct_id=NULL
3745
 
       WHERE tohead_srccntct_id=OLD.cntct_id;
3746
 
    END IF;
3747
 
 
3748
 
  END IF;
3749
 
  RETURN OLD;
3750
 
END;
3751
 
$$;
3752
 
 
3753
 
 
3754
 
ALTER FUNCTION public._cntcttriggerbeforedelete() OWNER TO admin;
3755
 
 
3756
 
--
3757
 
--
3758
 
 
3759
 
CREATE FUNCTION _cntsliptrigger() RETURNS trigger
3760
 
    LANGUAGE plpgsql
3761
 
    AS $$
3762
 
DECLARE
3763
 
  _p RECORD;
3764
 
  _comments TEXT;
3765
 
  _temp TEXT;
3766
 
 
3767
 
BEGIN
3768
 
  IF (TG_OP = 'DELETE') THEN
3769
 
    SELECT itemsite_loccntrl, itemsite_controlmethod,
3770
 
           cntslip_posted, cntslip_lotserial, cntslip_comments,
3771
 
           cntslip_number, cntslip_qty INTO _p
3772
 
      FROM cntslip, invcnt, itemsite
3773
 
     WHERE ( (cntslip_cnttag_id=invcnt_id)
3774
 
       AND   (invcnt_itemsite_id=itemsite_id)
3775
 
       AND   (cntslip_id=OLD.cntslip_id) );
3776
 
 
3777
 
    IF(_p.cntslip_posted) THEN
3778
 
      SELECT ( '
3779
 
Count Slip #' || _p.cntslip_number ||
3780
 
             ' deleted ' || formatQty(_p.cntslip_qty) ) INTO _comments;
3781
 
 
3782
 
      IF (_p.itemsite_loccntrl) THEN
3783
 
        SELECT ( ', Location:' || location_name ) INTO _temp
3784
 
          FROM location, cntslip
3785
 
         WHERE ( (cntslip_location_id=location_id)
3786
 
           AND   (cntslip_id=OLD.cntslip_id) );
3787
 
 
3788
 
        _comments := (_comments || _temp);
3789
 
      END IF;
3790
 
 
3791
 
      IF (_p.itemsite_controlmethod = 'L') THEN
3792
 
        _comments := (_comments || ( ', Lot #:' || _p.cntslip_lotserial));
3793
 
      ELSIF (_p.itemsite_controlmethod = 'S') THEN
3794
 
        _comments := (_comments || ( ', Serial #:' || _p.cntslip_lotserial));
3795
 
      END IF;
3796
 
 
3797
 
      _comments := (_comments || ' ' || _p.cntslip_comments);
3798
 
 
3799
 
      UPDATE invcnt
3800
 
         SET invcnt_qoh_after = ( COALESCE(invcnt_qoh_after, 0) - cntslip_qty),
3801
 
             invcnt_comments = (invcnt_comments || _comments)
3802
 
        FROM cntslip
3803
 
       WHERE ( (cntslip_cnttag_id=invcnt_id)
3804
 
         AND   (NOT invcnt_posted)
3805
 
         AND   (cntslip_id=OLD.cntslip_id) );
3806
 
 
3807
 
    END IF;
3808
 
 
3809
 
    RETURN OLD;
3810
 
  END IF;
3811
 
 
3812
 
  RETURN NEW;
3813
 
END;
3814
 
$$;
3815
 
 
3816
 
 
3817
 
ALTER FUNCTION public._cntsliptrigger() OWNER TO admin;
3818
 
 
3819
 
--
3820
 
--
3821
 
 
3822
 
CREATE FUNCTION _cobillbeforetrigger() RETURNS trigger
3823
 
    LANGUAGE plpgsql
3824
 
    AS $$
3825
 
DECLARE
3826
 
 
3827
 
BEGIN
3828
 
  IF (TG_OP = 'DELETE') THEN
3829
 
    DELETE FROM cobilltax
3830
 
    WHERE (taxhist_parent_id=OLD.cobill_id);
3831
 
 
3832
 
    RETURN OLD;
3833
 
  END IF;
3834
 
 
3835
 
  RETURN NEW;
3836
 
END;
3837
 
$$;
3838
 
 
3839
 
 
3840
 
ALTER FUNCTION public._cobillbeforetrigger() OWNER TO admin;
3841
 
 
3842
 
--
3843
 
--
3844
 
 
3845
 
CREATE FUNCTION _cobilltrigger() RETURNS trigger
3846
 
    LANGUAGE plpgsql
3847
 
    AS $$
3848
 
DECLARE
3849
 
  _r RECORD;
3850
 
 
3851
 
BEGIN
3852
 
  IF (TG_OP = 'DELETE') THEN
3853
 
    RETURN OLD;
3854
 
  END IF;
3855
 
 
3856
 
  SELECT * INTO _r
3857
 
  FROM cobmisc
3858
 
  WHERE (cobmisc_id=NEW.cobill_cobmisc_id);
3859
 
  IF (NOT FOUND) THEN
3860
 
    RAISE EXCEPTION 'Billing head not found';
3861
 
  END IF;
3862
 
 
3863
 
  IF (TG_OP = 'INSERT') THEN
3864
 
 
3865
 
  -- Calculate Tax
3866
 
      PERFORM calculateTaxHist( 'cobilltax',
3867
 
                                NEW.cobill_id,
3868
 
                                COALESCE(_r.cobmisc_taxzone_id, -1),
3869
 
                                NEW.cobill_taxtype_id,
3870
 
                                COALESCE(_r.cobmisc_shipdate, CURRENT_DATE),
3871
 
                                COALESCE(_r.cobmisc_curr_id, -1),
3872
 
                                (NEW.cobill_qty * coitem_qty_invuomratio) *
3873
 
                                (coitem_price / coitem_price_invuomratio) )
3874
 
      FROM coitem
3875
 
      WHERE (coitem_id=NEW.cobill_coitem_id);
3876
 
  END IF;
3877
 
 
3878
 
  IF (TG_OP = 'UPDATE') THEN
3879
 
 
3880
 
  -- Calculate Tax
3881
 
    IF ( (NEW.cobill_qty <> OLD.cobill_qty) OR
3882
 
         (NEW.cobill_taxtype_id <> OLD.cobill_taxtype_id) ) THEN
3883
 
      PERFORM calculateTaxHist( 'cobilltax',
3884
 
                                NEW.cobill_id,
3885
 
                                COALESCE(_r.cobmisc_taxzone_id, -1),
3886
 
                                NEW.cobill_taxtype_id,
3887
 
                                COALESCE(_r.cobmisc_shipdate, CURRENT_DATE),
3888
 
                                COALESCE(_r.cobmisc_curr_id, -1),
3889
 
                                (NEW.cobill_qty * coitem_qty_invuomratio) *
3890
 
                                (coitem_price / coitem_price_invuomratio) )
3891
 
      FROM coitem
3892
 
      WHERE (coitem_id=NEW.cobill_coitem_id);
3893
 
    END IF;
3894
 
  END IF;
3895
 
 
3896
 
  RETURN NEW;
3897
 
END;
3898
 
$$;
3899
 
 
3900
 
 
3901
 
ALTER FUNCTION public._cobilltrigger() OWNER TO admin;
3902
 
 
3903
 
--
3904
 
--
3905
 
 
3906
 
CREATE FUNCTION _cobmiscbeforetrigger() RETURNS trigger
3907
 
    LANGUAGE plpgsql
3908
 
    AS $$
3909
 
DECLARE
3910
 
 
3911
 
BEGIN
3912
 
  IF (TG_OP = 'DELETE') THEN
3913
 
    DELETE FROM cobmisctax
3914
 
    WHERE (taxhist_parent_id=OLD.cobmisc_id);
3915
 
 
3916
 
    RETURN OLD;
3917
 
  END IF;
3918
 
 
3919
 
  RETURN NEW;
3920
 
END;
3921
 
$$;
3922
 
 
3923
 
 
3924
 
ALTER FUNCTION public._cobmiscbeforetrigger() OWNER TO admin;
3925
 
 
3926
 
--
3927
 
--
3928
 
 
3929
 
CREATE FUNCTION _cobmisctrigger() RETURNS trigger
3930
 
    LANGUAGE plpgsql
3931
 
    AS $$
3932
 
BEGIN
3933
 
  IF (TG_OP = 'DELETE') THEN
3934
 
    -- Something can go here
3935
 
    RETURN OLD;
3936
 
  END IF;
3937
 
 
3938
 
  IF (TG_OP = 'INSERT') THEN
3939
 
 
3940
 
  -- Calculate Freight Tax
3941
 
    IF (NEW.cobmisc_freight <> 0) THEN
3942
 
      PERFORM calculateTaxHist( 'cobmisctax',
3943
 
                                NEW.cobmisc_id,
3944
 
                                NEW.cobmisc_taxzone_id,
3945
 
                                getFreightTaxtypeId(),
3946
 
                                NEW.cobmisc_invcdate,
3947
 
                                NEW.cobmisc_curr_id,
3948
 
                                NEW.cobmisc_freight );
3949
 
    END IF;
3950
 
  END IF;
3951
 
 
3952
 
  IF (TG_OP = 'UPDATE') THEN
3953
 
 
3954
 
  -- Calculate Tax
3955
 
    IF (COALESCE(NEW.cobmisc_taxzone_id,-1) <> COALESCE(OLD.cobmisc_taxzone_id,-1)) THEN
3956
 
      UPDATE cobill SET cobill_taxtype_id=getItemTaxType(itemsite_item_id,NEW.cobmisc_taxzone_id)
3957
 
      FROM coitem
3958
 
        JOIN itemsite ON (coitem_itemsite_id=itemsite_id)
3959
 
      WHERE ((coitem_id=cobill_coitem_id)
3960
 
       AND (cobill_cobmisc_id=NEW.cobmisc_id));
3961
 
    END IF;
3962
 
    
3963
 
    IF ( (NEW.cobmisc_freight <> OLD.cobmisc_freight) OR
3964
 
         (COALESCE(NEW.cobmisc_taxzone_id,-1) <> COALESCE(OLD.cobmisc_taxzone_id,-1)) OR
3965
 
         (NEW.cobmisc_invcdate <> OLD.cobmisc_invcdate) OR
3966
 
         (NEW.cobmisc_curr_id <> OLD.cobmisc_curr_id) ) THEN
3967
 
      PERFORM calculateTaxHist( 'cobmisctax',
3968
 
                                NEW.cobmisc_id,
3969
 
                                NEW.cobmisc_taxzone_id,
3970
 
                                getFreightTaxtypeId(),
3971
 
                                NEW.cobmisc_invcdate,
3972
 
                                NEW.cobmisc_curr_id,
3973
 
                                NEW.cobmisc_freight );
3974
 
      PERFORM calculateTaxHist( 'cobilltax',
3975
 
                                cobill_id,
3976
 
                                NEW.cobmisc_taxzone_id,
3977
 
                                cobill_taxtype_id,
3978
 
                                NEW.cobmisc_invcdate,
3979
 
                                NEW.cobmisc_curr_id,
3980
 
                                (cobill_qty * coitem_qty_invuomratio) *
3981
 
                                (coitem_price / coitem_price_invuomratio) )
3982
 
      FROM cobill JOIN coitem ON (coitem_id = cobill_coitem_id)
3983
 
      WHERE (cobill_cobmisc_id = NEW.cobmisc_id);
3984
 
    END IF;
3985
 
  END IF;
3986
 
 
3987
 
  RETURN NEW;
3988
 
END;
3989
 
$$;
3990
 
 
3991
 
 
3992
 
ALTER FUNCTION public._cobmisctrigger() OWNER TO admin;
3993
 
 
3994
 
--
3995
 
--
3996
 
 
3997
 
CREATE FUNCTION _commenttrigger() RETURNS trigger
3998
 
    LANGUAGE plpgsql
3999
 
    AS $$
4000
 
BEGIN
4001
 
  IF (NEW.comment_cmnttype_id IS NULL) THEN
4002
 
        RAISE EXCEPTION 'You must supply a valid Comment Type ID.';
4003
 
  ELSIF (NEW.comment_source = 'INCDT') THEN
4004
 
    UPDATE incdt SET incdt_updated = now() WHERE incdt_id = NEW.comment_source_id;
4005
 
  END IF;
4006
 
 
4007
 
  RETURN NEW;
4008
 
END;
4009
 
$$;
4010
 
 
4011
 
 
4012
 
ALTER FUNCTION public._commenttrigger() OWNER TO admin;
4013
 
 
4014
 
--
4015
 
--
4016
 
 
4017
 
CREATE FUNCTION _companytrigger() RETURNS trigger
4018
 
    LANGUAGE plpgsql
4019
 
    AS $$
4020
 
DECLARE
4021
 
  _used BOOLEAN := false;
4022
 
 
4023
 
BEGIN
4024
 
  IF (NEW.company_external AND NOT OLD.company_external) THEN
4025
 
    IF EXISTS(SELECT accnt_id
4026
 
              FROM accnt, company, (
4027
 
                  SELECT DISTINCT apaccnt_ap_accnt_id AS test_accnt_id FROM apaccnt
4028
 
                  UNION SELECT DISTINCT apaccnt_discount_accnt_id FROM apaccnt
4029
 
                  UNION SELECT DISTINCT apaccnt_prepaid_accnt_id FROM apaccnt
4030
 
                  UNION SELECT DISTINCT apopen_accnt_id FROM apopen
4031
 
                  UNION SELECT DISTINCT araccnt_ar_accnt_id FROM araccnt
4032
 
                  UNION SELECT DISTINCT araccnt_deferred_accnt_id FROM araccnt
4033
 
                  UNION SELECT DISTINCT araccnt_freight_accnt_id FROM araccnt
4034
 
                  UNION SELECT DISTINCT araccnt_prepaid_accnt_id FROM araccnt
4035
 
                  UNION SELECT DISTINCT aropen_accnt_id FROM aropen
4036
 
                  UNION SELECT DISTINCT bankaccnt_accnt_id FROM bankaccnt
4037
 
                  UNION SELECT DISTINCT bankaccnt_rec_accnt_id FROM bankaccnt
4038
 
                  UNION SELECT DISTINCT budgitem_accnt_id FROM budgitem
4039
 
                  UNION SELECT DISTINCT cashrcptmisc_accnt_id FROM cashrcptmisc
4040
 
                  UNION SELECT DISTINCT cmhead_misc_accnt_id FROM cmhead
4041
 
                  UNION SELECT DISTINCT cobmisc_misc_accnt_id FROM cobmisc
4042
 
                  UNION SELECT DISTINCT cohead_misc_accnt_id FROM cohead
4043
 
                  UNION SELECT DISTINCT coitem_cos_accnt_id FROM coitem
4044
 
                  UNION SELECT DISTINCT costcat_adjustment_accnt_id FROM costcat
4045
 
                  UNION SELECT DISTINCT costcat_asset_accnt_id FROM costcat
4046
 
                  UNION SELECT DISTINCT costcat_freight_accnt_id FROM costcat
4047
 
                  UNION SELECT DISTINCT costcat_invcost_accnt_id FROM costcat
4048
 
                  UNION SELECT DISTINCT costcat_laboroverhead_accnt_id FROM costcat
4049
 
                  UNION SELECT DISTINCT costcat_liability_accnt_id FROM costcat
4050
 
                  UNION SELECT DISTINCT costcat_matusage_accnt_id FROM costcat
4051
 
                  UNION SELECT DISTINCT costcat_mfgscrap_accnt_id FROM costcat
4052
 
                  UNION SELECT DISTINCT costcat_purchprice_accnt_id FROM costcat
4053
 
                  UNION SELECT DISTINCT costcat_scrap_accnt_id FROM costcat
4054
 
                  UNION SELECT DISTINCT costcat_shipasset_accnt_id FROM costcat
4055
 
                  UNION SELECT DISTINCT costcat_toliability_accnt_id FROM costcat
4056
 
                  UNION SELECT DISTINCT costcat_transform_accnt_id FROM costcat
4057
 
                  UNION SELECT DISTINCT costcat_wip_accnt_id FROM costcat
4058
 
                  UNION SELECT DISTINCT costelem_exp_accnt_id FROM costelem
4059
 
                  UNION SELECT DISTINCT expcat_exp_accnt_id FROM expcat
4060
 
                  UNION SELECT DISTINCT expcat_freight_accnt_id FROM expcat
4061
 
                  UNION SELECT DISTINCT expcat_liability_accnt_id FROM expcat
4062
 
                  UNION SELECT DISTINCT expcat_purchprice_accnt_id FROM expcat
4063
 
                  UNION SELECT DISTINCT glseries_accnt_id FROM glseries
4064
 
                  UNION SELECT DISTINCT gltrans_accnt_id FROM gltrans
4065
 
                  UNION SELECT DISTINCT invchead_misc_accnt_id FROM invchead
4066
 
                  UNION SELECT DISTINCT quhead_misc_accnt_id FROM quhead
4067
 
                  UNION SELECT DISTINCT salesaccnt_cor_accnt_id FROM salesaccnt
4068
 
                  UNION SELECT DISTINCT salesaccnt_cos_accnt_id FROM salesaccnt
4069
 
                  UNION SELECT DISTINCT salesaccnt_cow_accnt_id FROM salesaccnt
4070
 
                  UNION SELECT DISTINCT salesaccnt_credit_accnt_id FROM salesaccnt
4071
 
                  UNION SELECT DISTINCT salesaccnt_returns_accnt_id FROM salesaccnt
4072
 
                  UNION SELECT DISTINCT salesaccnt_sales_accnt_id FROM salesaccnt
4073
 
                  UNION SELECT DISTINCT salescat_ar_accnt_id FROM salescat
4074
 
                  UNION SELECT DISTINCT salescat_prepaid_accnt_id FROM salescat
4075
 
                  UNION SELECT DISTINCT salescat_sales_accnt_id FROM salescat
4076
 
                  UNION SELECT DISTINCT stdjrnlitem_accnt_id FROM stdjrnlitem
4077
 
                  UNION SELECT DISTINCT tax_sales_accnt_id FROM tax
4078
 
                  UNION SELECT DISTINCT taxauth_accnt_id FROM taxauth
4079
 
                  UNION SELECT DISTINCT vodist_accnt_id FROM vodist
4080
 
                  UNION SELECT DISTINCT warehous_default_accnt_id FROM whsinfo
4081
 
                ) AS dummy
4082
 
              WHERE ((accnt_id=test_accnt_id)
4083
 
                AND  (accnt_company=company_number)
4084
 
                AND  (accnt_company=NEW.company_number))
4085
 
    ) THEN
4086
 
      RAISE EXCEPTION 'Cannot make Company % External because it is used in the local database.',
4087
 
                      NEW.company_number;
4088
 
    ELSIF (fetchMetricBool('EnableReturnAuth')) THEN
4089
 
      IF EXISTS(SELECT accnt_id
4090
 
              FROM accnt, company, (
4091
 
                  SELECT DISTINCT rahead_misc_accnt_id AS test_accnt_id FROM rahead
4092
 
                  UNION SELECT DISTINCT raitem_cos_accnt_id FROM raitem
4093
 
                ) AS dummy
4094
 
              WHERE ((accnt_id=test_accnt_id)
4095
 
                AND  (accnt_company=company_number)
4096
 
                AND  (accnt_company=NEW.company_number))
4097
 
      ) THEN
4098
 
        RAISE EXCEPTION 'Cannot make Company % External because it is used in the local database.',
4099
 
                        NEW.company_number;
4100
 
      END IF;
4101
 
    END IF;
4102
 
  END IF;
4103
 
 
4104
 
  RETURN NEW;
4105
 
END;
4106
 
$$;
4107
 
 
4108
 
 
4109
 
ALTER FUNCTION public._companytrigger() OWNER TO admin;
4110
 
 
4111
 
--
4112
 
--
4113
 
 
4114
 
CREATE FUNCTION _contrctaftertrigger() RETURNS trigger
4115
 
    LANGUAGE plpgsql
4116
 
    AS $$
4117
 
DECLARE
4118
 
 
4119
 
BEGIN
4120
 
 
4121
 
  -- synchronize contract effectivity with item source effectivity
4122
 
  IF (NEW.contrct_effective <> OLD.contrct_effective) THEN
4123
 
    UPDATE itemsrc SET itemsrc_effective=NEW.contrct_effective
4124
 
    WHERE itemsrc_contrct_id=NEW.contrct_id;
4125
 
  END IF;
4126
 
 
4127
 
  IF (NEW.contrct_expires <> OLD.contrct_expires) THEN
4128
 
    UPDATE itemsrc SET itemsrc_expires=NEW.contrct_expires
4129
 
    WHERE itemsrc_contrct_id=NEW.contrct_id;
4130
 
  END IF;
4131
 
 
4132
 
  RETURN NEW;
4133
 
END;
4134
 
$$;
4135
 
 
4136
 
 
4137
 
ALTER FUNCTION public._contrctaftertrigger() OWNER TO admin;
4138
 
 
4139
 
--
4140
 
--
4141
 
 
4142
 
CREATE FUNCTION _crmacctaftertrigger() RETURNS trigger
4143
 
    LANGUAGE plpgsql
4144
 
    AS $$
4145
 
DECLARE
4146
 
  _cmnttypeid INTEGER;
4147
 
  _gotpriv    BOOLEAN;
4148
 
 
4149
 
BEGIN
4150
 
  /* update _number and _name separately to propagate just what changed.
4151
 
     the priv manipulation allows targeted updates of crmaccount-maintained data
4152
 
     (note: grantPriv() == false if the user already had the priv, true if this
4153
 
     call granted the priv).
4154
 
   */
4155
 
  IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN
4156
 
    IF (NEW.crmacct_cust_id IS NOT NULL) THEN
4157
 
      _gotpriv := grantPriv(getEffectiveXtUser(), 'MaintainCustomerMasters');
4158
 
      UPDATE custinfo SET cust_number = NEW.crmacct_number
4159
 
      WHERE ((cust_id=NEW.crmacct_cust_id)
4160
 
        AND  (cust_number!=NEW.crmacct_number));
4161
 
      UPDATE custinfo SET cust_name = NEW.crmacct_name
4162
 
      WHERE ((cust_id=NEW.crmacct_cust_id)
4163
 
        AND  (cust_name!=NEW.crmacct_name));
4164
 
      IF (_gotpriv) THEN
4165
 
        PERFORM revokePriv(getEffectiveXtUser(), 'MaintainCustomerMasters');
4166
 
      END IF;
4167
 
    END IF;
4168
 
 
4169
 
    IF (NEW.crmacct_emp_id IS NOT NULL) THEN
4170
 
      _gotpriv := grantPriv(getEffectiveXtUser(), 'MaintainEmployees');
4171
 
      UPDATE emp SET emp_code = NEW.crmacct_number
4172
 
      WHERE ((emp_id=NEW.crmacct_emp_id)
4173
 
        AND  (emp_code!=NEW.crmacct_number));
4174
 
      UPDATE emp SET emp_name = NEW.crmacct_name
4175
 
      WHERE ((emp_id=NEW.crmacct_emp_id)
4176
 
        AND  (emp_name!=NEW.crmacct_name));
4177
 
      IF (_gotpriv) THEN
4178
 
        PERFORM revokePriv(getEffectiveXtUser(), 'MaintainEmployees');
4179
 
      END IF;
4180
 
    END IF;
4181
 
 
4182
 
    IF (NEW.crmacct_prospect_id IS NOT NULL) THEN
4183
 
      _gotpriv := grantPriv(getEffectiveXtUser(), 'MaintainProspectMasters');
4184
 
      UPDATE prospect SET prospect_number = NEW.crmacct_number
4185
 
      WHERE ((prospect_id=NEW.crmacct_prospect_id)
4186
 
        AND  (prospect_number!=NEW.crmacct_number));
4187
 
      UPDATE prospect SET prospect_name = NEW.crmacct_name
4188
 
      WHERE ((prospect_id=NEW.crmacct_prospect_id)
4189
 
        AND  (prospect_name!=NEW.crmacct_name));
4190
 
      IF (_gotpriv) THEN
4191
 
        PERFORM revokePriv(getEffectiveXtUser(), 'MaintainProspectMasters');
4192
 
      END IF;
4193
 
    END IF;
4194
 
 
4195
 
    IF (NEW.crmacct_salesrep_id IS NOT NULL) THEN
4196
 
      _gotpriv := grantPriv(getEffectiveXtUser(), 'MaintainSalesReps');
4197
 
      UPDATE salesrep SET salesrep_number = NEW.crmacct_number
4198
 
      WHERE ((salesrep_id=NEW.crmacct_salesrep_id)
4199
 
        AND  (salesrep_number!=NEW.crmacct_number));
4200
 
      UPDATE salesrep SET salesrep_name = NEW.crmacct_name
4201
 
      WHERE ((salesrep_id=NEW.crmacct_salesrep_id)
4202
 
        AND  (salesrep_name!=NEW.crmacct_name));
4203
 
      IF (_gotpriv) THEN
4204
 
        PERFORM revokePriv(getEffectiveXtUser(), 'MaintainSalesReps');
4205
 
      END IF;
4206
 
    END IF;
4207
 
 
4208
 
    IF (NEW.crmacct_taxauth_id IS NOT NULL) THEN
4209
 
      _gotpriv := grantPriv(getEffectiveXtUser(), 'MaintainTaxAuthorities');
4210
 
      UPDATE taxauth SET taxauth_code = NEW.crmacct_number
4211
 
      WHERE ((taxauth_id=NEW.crmacct_taxauth_id)
4212
 
        AND  (taxauth_code!=NEW.crmacct_number));
4213
 
      UPDATE taxauth SET taxauth_name = NEW.crmacct_name
4214
 
      WHERE ((taxauth_id=NEW.crmacct_taxauth_id)
4215
 
        AND  (taxauth_name!=NEW.crmacct_name));
4216
 
      IF (_gotpriv) THEN
4217
 
        PERFORM revokePriv(getEffectiveXtUser(), 'MaintainTaxAuthorities');
4218
 
      END IF;
4219
 
    END IF;
4220
 
 
4221
 
    IF (NEW.crmacct_vend_id IS NOT NULL) THEN
4222
 
      _gotpriv := grantPriv(getEffectiveXtUser(), 'MaintainVendors');
4223
 
      UPDATE vendinfo SET vend_number = NEW.crmacct_number
4224
 
      WHERE ((vend_id=NEW.crmacct_vend_id)
4225
 
        AND  (vend_number!=NEW.crmacct_number));
4226
 
      UPDATE vendinfo SET vend_name = NEW.crmacct_name
4227
 
      WHERE ((vend_id=NEW.crmacct_vend_id)
4228
 
        AND  (vend_name!=NEW.crmacct_name));
4229
 
      IF (_gotpriv) THEN
4230
 
        PERFORM revokePriv(getEffectiveXtUser(), 'MaintainVendors');
4231
 
      END IF;
4232
 
    END IF;
4233
 
 
4234
 
    -- Link Primary and Secondary Contacts to this Account if they are not already
4235
 
    IF (NEW.crmacct_cntct_id_1 IS NOT NULL) THEN
4236
 
      _gotpriv := grantPriv(getEffectiveXtUser(), 'MaintainAllContacts');
4237
 
      UPDATE cntct SET cntct_crmacct_id = NEW.crmacct_id
4238
 
       WHERE cntct_id=NEW.crmacct_cntct_id_1;
4239
 
      IF (_gotpriv) THEN
4240
 
        PERFORM revokePriv(getEffectiveXtUser(), 'MaintainAllContacts');
4241
 
      END IF;
4242
 
    END IF;
4243
 
 
4244
 
    IF (NEW.crmacct_cntct_id_2 IS NOT NULL) THEN
4245
 
      _gotpriv := grantPriv(getEffectiveXtUser(), 'MaintainAllContacts');
4246
 
      UPDATE cntct SET cntct_crmacct_id = NEW.crmacct_id
4247
 
       WHERE cntct_id=NEW.crmacct_cntct_id_2;
4248
 
      IF (_gotpriv) THEN
4249
 
        PERFORM revokePriv(getEffectiveXtUser(), 'MaintainAllContacts');
4250
 
      END IF;
4251
 
    END IF;
4252
 
 
4253
 
    -- cannot have fkey references to system catalogs so enforce them here
4254
 
    IF (NEW.crmacct_usr_username IS NOT NULL) THEN
4255
 
      IF (NOT EXISTS(SELECT usr_username
4256
 
                       FROM usr
4257
 
                      WHERE usr_username=NEW.crmacct_usr_username)) THEN
4258
 
        RAISE EXCEPTION 'User % does not exist so this CRM Account Number is invalid.',
4259
 
                        NEW.crmacct_usr_username;
4260
 
      END IF;
4261
 
      IF (TG_OP = 'UPDATE') THEN
4262
 
        -- reminder: this evaluates to false if either is NULL
4263
 
        IF (NEW.crmacct_usr_username != OLD.crmacct_usr_username) THEN
4264
 
          RAISE EXCEPTION 'Cannot change the user name for %',
4265
 
                          OLD.crmacct_usr_username;
4266
 
        END IF;
4267
 
      END IF;
4268
 
      UPDATE usrpref SET usrpref_value = NEW.crmacct_name
4269
 
      WHERE ((usrpref_username=NEW.crmacct_usr_username)
4270
 
        AND  (usrpref_name='propername')
4271
 
        AND  (usrpref_value!=NEW.crmacct_name));
4272
 
    END IF;
4273
 
 
4274
 
  ELSIF (TG_OP = 'DELETE') THEN
4275
 
    IF (OLD.crmacct_cust_id IS NOT NULL) THEN
4276
 
      RAISE EXCEPTION 'Cannot delete CRM Account because it is a Customer [xtuple: deleteCrmAccount, -1]';
4277
 
    END IF;
4278
 
 
4279
 
    IF (OLD.crmacct_emp_id IS NOT NULL) THEN
4280
 
      RAISE EXCEPTION 'Cannot delete CRM Account because it is an Employee [xtuple: deleteCrmAccount, -7]';
4281
 
    END IF;
4282
 
 
4283
 
    IF (OLD.crmacct_prospect_id IS NOT NULL) THEN
4284
 
      RAISE EXCEPTION 'Cannot delete CRM Account because it is a Prospect [xtuple: deleteCrmAccount, -3]';
4285
 
    END IF;
4286
 
 
4287
 
    DELETE FROM salesrep WHERE salesrep_id  = OLD.crmacct_salesrep_id;
4288
 
    IF (OLD.crmacct_salesrep_id IS NOT NULL) THEN
4289
 
      RAISE EXCEPTION 'Cannot delete CRM Account because it is a Sales Rep [xtuple: deleteCrmAccount, -6]';
4290
 
    END IF;
4291
 
 
4292
 
    IF (OLD.crmacct_taxauth_id IS NOT NULL) THEN
4293
 
      RAISE EXCEPTION 'Cannot delete CRM Account because it is a Tax Authority [xtuple: deleteCrmAccount, -5]';
4294
 
    END IF;
4295
 
 
4296
 
    IF (EXISTS(SELECT usename
4297
 
                 FROM pg_user
4298
 
                WHERE usename=OLD.crmacct_usr_username)) THEN
4299
 
      RAISE EXCEPTION 'Cannot delete CRM Account because it is a User [xtuple: deleteCrmAccount, -8]';
4300
 
    END IF;
4301
 
 
4302
 
    IF (OLD.crmacct_vend_id IS NOT NULL) THEN
4303
 
      RAISE EXCEPTION 'Cannot delete CRM Account because it is a Vendor [xtuple: deleteCrmAccount, -2]';
4304
 
    END IF;
4305
 
 
4306
 
    DELETE FROM imageass
4307
 
     WHERE (imageass_source_id=OLD.crmacct_id) AND (imageass_source='CRMA');
4308
 
    DELETE FROM url
4309
 
     WHERE (url_source_id=OLD.crmacct_id)      AND (url_source='CRMA');
4310
 
 
4311
 
  END IF;
4312
 
 
4313
 
  SELECT cmnttype_id INTO _cmnttypeid
4314
 
    FROM cmnttype
4315
 
   WHERE (cmnttype_name='ChangeLog');
4316
 
  IF (_cmnttypeid IS NOT NULL) THEN
4317
 
    IF (TG_OP = 'INSERT') THEN
4318
 
      PERFORM postComment(_cmnttypeid, 'CRMA', NEW.crmacct_id,
4319
 
                          ('Created by ' || getEffectiveXtUser()));
4320
 
 
4321
 
    ELSIF (TG_OP = 'DELETE') THEN
4322
 
      PERFORM postComment(_cmnttypeid, 'CRMA', OLD.crmacct_id,
4323
 
                          'Deleted "' || OLD.crmacct_number || '"');
4324
 
    END IF;
4325
 
  END IF;
4326
 
 
4327
 
  IF (TG_OP = 'DELETE') THEN
4328
 
    RETURN OLD;
4329
 
  END IF;
4330
 
 
4331
 
  RETURN NEW;
4332
 
END;
4333
 
$$;
4334
 
 
4335
 
 
4336
 
ALTER FUNCTION public._crmacctaftertrigger() OWNER TO admin;
4337
 
 
4338
 
--
4339
 
--
4340
 
 
4341
 
CREATE FUNCTION _crmacctbeforetrigger() RETURNS trigger
4342
 
    LANGUAGE plpgsql
4343
 
    AS $$
4344
 
DECLARE
4345
 
  _count        INTEGER;
4346
 
BEGIN
4347
 
  -- disallow reusing crmacct_numbers
4348
 
  IF (TG_OP IN ('INSERT', 'UPDATE')) THEN
4349
 
    IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN
4350
 
      PERFORM clearNumberIssue('CRMAccountNumber', NEW.crmacct_number);
4351
 
    END IF;
4352
 
 
4353
 
    NEW.crmacct_usr_username := LOWER(TRIM(NEW.crmacct_usr_username));
4354
 
    IF (NEW.crmacct_usr_username = '') THEN
4355
 
      NEW.crmacct_usr_username = NULL;
4356
 
    END IF;
4357
 
 
4358
 
    NEW.crmacct_owner_username := LOWER(TRIM(NEW.crmacct_owner_username));
4359
 
    IF (COALESCE(NEW.crmacct_owner_username, '') = '') THEN
4360
 
      NEW.crmacct_owner_username = getEffectiveXtUser();
4361
 
    END IF;
4362
 
 
4363
 
    IF (NEW.crmacct_competitor_id < 0) THEN
4364
 
      NEW.crmacct_competitor_id := NULL;
4365
 
    END IF;
4366
 
    IF (NEW.crmacct_partner_id < 0) THEN
4367
 
      NEW.crmacct_partner_id := NULL;
4368
 
    END IF;
4369
 
 
4370
 
    NEW.crmacct_number = UPPER(NEW.crmacct_number);
4371
 
 
4372
 
    IF (TG_OP = 'UPDATE') THEN
4373
 
      -- TODO: why not ALTER USER OLD.crmacct_number RENAME TO LOWER(NEW.crmacct_number)?
4374
 
      IF (NEW.crmacct_number != UPPER(OLD.crmacct_number) AND
4375
 
          NEW.crmacct_usr_username IS NOT NULL            AND
4376
 
          UPPER(NEW.crmacct_usr_username) != NEW.crmacct_number) THEN
4377
 
        RAISE EXCEPTION 'The CRM Account % is associated with a system User so the number cannot be changed.',
4378
 
                        NEW.crmacct_number;
4379
 
      END IF;
4380
 
    END IF;
4381
 
 
4382
 
  ELSIF (TG_OP = 'DELETE') THEN
4383
 
    UPDATE cntct SET cntct_crmacct_id = NULL
4384
 
     WHERE cntct_crmacct_id = OLD.crmacct_id;
4385
 
 
4386
 
    DELETE FROM docass WHERE docass_source_id = OLD.crmacct_id AND docass_source_type = 'CRMA';
4387
 
    DELETE FROM docass WHERE docass_target_id = OLD.crmacct_id AND docass_target_type = 'CRMA';
4388
 
 
4389
 
    GET DIAGNOSTICS _count = ROW_COUNT;
4390
 
    RAISE DEBUG 'updated % contacts', _count;
4391
 
 
4392
 
    RETURN OLD;
4393
 
 
4394
 
  END IF;
4395
 
 
4396
 
  RETURN NEW;
4397
 
END;
4398
 
$$;
4399
 
 
4400
 
 
4401
 
ALTER FUNCTION public._crmacctbeforetrigger() OWNER TO admin;
4402
 
 
4403
 
--
4404
 
--
4405
 
 
4406
 
CREATE FUNCTION _custaftertrigger() RETURNS trigger
4407
 
    LANGUAGE plpgsql
4408
 
    AS $$
4409
 
DECLARE
4410
 
  _cmnttypeid INTEGER;
4411
 
  _whsId      INTEGER := -1;
4412
 
 
4413
 
BEGIN
4414
 
 
4415
 
  IF (TG_OP = 'INSERT') THEN
4416
 
    -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE
4417
 
    LOOP
4418
 
      UPDATE crmacct SET crmacct_cust_id=NEW.cust_id,
4419
 
                         crmacct_name=NEW.cust_name,
4420
 
                         crmacct_prospect_id=NULL
4421
 
      WHERE crmacct_number=NEW.cust_number;
4422
 
      IF (FOUND) THEN
4423
 
        DELETE FROM prospect WHERE prospect_id=NEW.cust_id;
4424
 
        EXIT;
4425
 
      END IF;
4426
 
      BEGIN
4427
 
        INSERT INTO crmacct(crmacct_number,  crmacct_name,    crmacct_active,
4428
 
                            crmacct_type,    crmacct_cust_id, crmacct_cntct_id_1,
4429
 
                            crmacct_cntct_id_2
4430
 
                  ) VALUES (NEW.cust_number, NEW.cust_name,   NEW.cust_active,
4431
 
                            'O',             NEW.cust_id,     NEW.cust_cntct_id,
4432
 
                            NEW.cust_corrcntct_id);
4433
 
        EXIT;
4434
 
      EXCEPTION WHEN unique_violation THEN
4435
 
            -- do nothing, and loop to try the UPDATE again
4436
 
      END;
4437
 
    END LOOP;
4438
 
 
4439
 
    PERFORM updateCharAssignment('C', NEW.cust_id, char_id, charass_value)
4440
 
       FROM custtype
4441
 
       JOIN charass ON (custtype_id=charass_target_id AND charass_target_type='CT')
4442
 
       JOIN char ON (charass_char_id=char_id)
4443
 
       WHERE ((custtype_id=NEW.cust_custtype_id)
4444
 
          AND (custtype_char)
4445
 
          AND (charass_default));
4446
 
 
4447
 
  ELSIF (TG_OP = 'UPDATE') THEN
4448
 
    UPDATE crmacct SET crmacct_number = NEW.cust_number
4449
 
    WHERE ((crmacct_cust_id=NEW.cust_id)
4450
 
      AND  (crmacct_number!=NEW.cust_number));
4451
 
 
4452
 
    UPDATE crmacct SET crmacct_name = NEW.cust_name
4453
 
    WHERE ((crmacct_cust_id=NEW.cust_id)
4454
 
      AND  (crmacct_name!=NEW.cust_name));
4455
 
  END IF;
4456
 
 
4457
 
  IF (TG_OP = 'INSERT') THEN
4458
 
    PERFORM postEvent('NewCustomer', 'C', NEW.cust_id,
4459
 
                      NULL, NEW.cust_number,
4460
 
                      NULL, NULL, NULL, NULL);
4461
 
  END IF;
4462
 
 
4463
 
  IF (fetchMetricBool('CustomerChangeLog')) THEN
4464
 
    SELECT cmnttype_id INTO _cmnttypeid
4465
 
      FROM cmnttype
4466
 
     WHERE (cmnttype_name='ChangeLog');
4467
 
 
4468
 
    IF (_cmnttypeid IS NOT NULL) THEN
4469
 
      IF (TG_OP = 'INSERT') THEN
4470
 
        PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, 'Created');
4471
 
 
4472
 
      ELSIF (TG_OP = 'UPDATE') THEN
4473
 
 
4474
 
        IF (OLD.cust_number <> NEW.cust_number) THEN
4475
 
          PERFORM postComment( _cmnttypeid, 'C', NEW.cust_id,
4476
 
                              ('Number changed from "' || OLD.cust_number ||
4477
 
                               '" to "' || NEW.cust_number || '"') );
4478
 
        END IF;
4479
 
 
4480
 
        IF (OLD.cust_name <> NEW.cust_name) THEN
4481
 
          PERFORM postComment( _cmnttypeid, 'C', NEW.cust_id,
4482
 
                              ('Name changed from "' || OLD.cust_name ||
4483
 
                               '" to "' || NEW.cust_name || '"') );
4484
 
        END IF;
4485
 
 
4486
 
        IF (OLD.cust_active <> NEW.cust_active) THEN
4487
 
          PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id,
4488
 
                              CASE WHEN NEW.cust_active THEN 'Activated'
4489
 
                                   ELSE 'Deactivated' END);
4490
 
        END IF;
4491
 
 
4492
 
        IF (OLD.cust_discntprcnt <> NEW.cust_discntprcnt) THEN
4493
 
          PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id,
4494
 
                              ('Discount changed from "' ||
4495
 
                               formatprcnt(OLD.cust_discntprcnt) || '%" to "' ||
4496
 
                               formatprcnt(NEW.cust_discntprcnt) || '%"') );
4497
 
        END IF;
4498
 
 
4499
 
        IF (OLD.cust_creditlmt <> NEW.cust_creditlmt) THEN
4500
 
          PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id,
4501
 
                              ('Credit Limit changed from ' || formatMoney(OLD.cust_creditlmt) ||
4502
 
                               ' to ' || formatMoney(NEW.cust_creditlmt)));
4503
 
        END IF;
4504
 
 
4505
 
        IF (OLD.cust_creditstatus <> NEW.cust_creditstatus) THEN
4506
 
          PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id,
4507
 
                              ('Credit Status Changed from "' ||
4508
 
                               CASE OLD.cust_creditstatus
4509
 
                                    WHEN 'G' THEN 'In Good Standing'
4510
 
                                    WHEN 'W' THEN 'Credit Warning'
4511
 
                                    WHEN 'H' THEN 'Credit Hold'
4512
 
                                    ELSE 'Unknown/Error'
4513
 
                               END || '" to "' ||
4514
 
                               CASE NEW.cust_creditstatus
4515
 
                                    WHEN 'G' THEN 'In Good Standing'
4516
 
                                    WHEN 'W' THEN 'Credit Warning'
4517
 
                                    WHEN 'H' THEN 'Credit Hold'
4518
 
                                    ELSE 'Unknown/Error'
4519
 
                               END || '"') );
4520
 
        END IF;
4521
 
 
4522
 
        IF (OLD.cust_custtype_id <> NEW.cust_custtype_id) THEN
4523
 
          PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id,
4524
 
                              ('Customer type changed from "' ||
4525
 
                               (SELECT custtype_code FROM custtype
4526
 
                                 WHERE custtype_id = OLD.cust_custtype_id) || '" to "' ||
4527
 
                               (SELECT custtype_code FROM custtype
4528
 
                                 WHERE custtype_id = NEW.cust_custtype_id) || '"') );
4529
 
        END IF;
4530
 
 
4531
 
        IF (COALESCE(OLD.cust_gracedays,-1) <> COALESCE(NEW.cust_gracedays,-1)) THEN
4532
 
          PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id,
4533
 
                              ('Grace Days changed from "' ||
4534
 
                               COALESCE(TEXT(OLD.cust_gracedays), 'Default') ||
4535
 
                               '" to "' ||
4536
 
                               COALESCE(TEXT(NEW.cust_gracedays), 'Default') || '"'));
4537
 
        END IF;
4538
 
 
4539
 
        IF (OLD.cust_terms_id <> NEW.cust_terms_id) THEN
4540
 
          PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id,
4541
 
                              ('Terms changed from "' ||
4542
 
                               (SELECT terms_code FROM terms
4543
 
                                 WHERE terms_id = OLD.cust_terms_id) || '" to "' ||
4544
 
                               (SELECT terms_code FROM terms
4545
 
                                 WHERE terms_id = NEW.cust_terms_id) || '"'));
4546
 
        END IF;
4547
 
 
4548
 
      END IF;
4549
 
    END IF;
4550
 
  END IF;
4551
 
 
4552
 
  RETURN NEW;
4553
 
END;
4554
 
$$;
4555
 
 
4556
 
 
4557
 
ALTER FUNCTION public._custaftertrigger() OWNER TO admin;
4558
 
 
4559
 
--
4560
 
--
4561
 
 
4562
 
CREATE FUNCTION _custinfoafterdeletetrigger() RETURNS trigger
4563
 
    LANGUAGE plpgsql
4564
 
    AS $$
4565
 
BEGIN
4566
 
  -- handle transitory state when converting customer to prospect
4567
 
  IF EXISTS(SELECT quhead_id
4568
 
              FROM quhead
4569
 
             WHERE (quhead_cust_id=OLD.cust_id) AND
4570
 
     NOT EXISTS(SELECT prospect_id
4571
 
                  FROM prospect
4572
 
                 WHERE prospect_id=OLD.cust_id)) THEN
4573
 
    RAISE EXCEPTION '[xtuple: deleteCustomer, -8]';
4574
 
  END IF;
4575
 
 
4576
 
  IF EXISTS(SELECT invchead_id
4577
 
              FROM invchead
4578
 
             WHERE (invchead_cust_id=OLD.cust_id)) THEN
4579
 
    RAISE EXCEPTION '[xtuple: deleteCustomer, -7]';
4580
 
  END IF;
4581
 
  -- end TODO
4582
 
 
4583
 
  IF EXISTS(SELECT checkhead_recip_id
4584
 
              FROM checkhead
4585
 
             WHERE ((checkhead_recip_id=OLD.cust_id)
4586
 
               AND  (checkhead_recip_type='C'))) THEN
4587
 
    RAISE EXCEPTION '[xtuple: deleteCustomer, -6]';
4588
 
  END IF;
4589
 
 
4590
 
  DELETE FROM taxreg
4591
 
   WHERE ((taxreg_rel_type='C')
4592
 
     AND  (taxreg_rel_id=OLD.cust_id));
4593
 
 
4594
 
  DELETE FROM ipsass
4595
 
   WHERE (ipsass_cust_id=OLD.cust_id);
4596
 
 
4597
 
  DELETE FROM docass WHERE docass_source_id = OLD.cust_id AND docass_source_type = 'C';
4598
 
  DELETE FROM docass WHERE docass_target_id = OLD.cust_id AND docass_target_type = 'C';
4599
 
 
4600
 
  IF (fetchMetricBool('CustomerChangeLog')) THEN
4601
 
    PERFORM postComment(cmnttype_id, 'C', OLD.cust_id,
4602
 
                        ('Deleted "' || OLD.cust_number || '"'))
4603
 
      FROM cmnttype
4604
 
     WHERE (cmnttype_name='ChangeLog');
4605
 
  END IF;
4606
 
 
4607
 
  RETURN OLD;
4608
 
END;
4609
 
$$;
4610
 
 
4611
 
 
4612
 
ALTER FUNCTION public._custinfoafterdeletetrigger() OWNER TO admin;
4613
 
 
4614
 
--
4615
 
--
4616
 
 
4617
 
CREATE FUNCTION _custinfobeforedeletetrigger() RETURNS trigger
4618
 
    LANGUAGE plpgsql
4619
 
    AS $$
4620
 
BEGIN
4621
 
  IF NOT (checkPrivilege('MaintainCustomerMasters')) THEN
4622
 
    RAISE EXCEPTION 'You do not have privileges to maintain Customers.';
4623
 
  END IF;
4624
 
 
4625
 
  UPDATE crmacct SET crmacct_cust_id = NULL
4626
 
   WHERE crmacct_cust_id = OLD.cust_id;
4627
 
 
4628
 
  RETURN OLD;
4629
 
END;
4630
 
$$;
4631
 
 
4632
 
 
4633
 
ALTER FUNCTION public._custinfobeforedeletetrigger() OWNER TO admin;
4634
 
 
4635
 
--
4636
 
--
4637
 
 
4638
 
CREATE FUNCTION _custtrigger() RETURNS trigger
4639
 
    LANGUAGE plpgsql
4640
 
    AS $$
4641
 
BEGIN
4642
 
  IF NOT (checkPrivilege('MaintainCustomerMasters') OR
4643
 
          checkPrivilege('PostMiscInvoices')) THEN
4644
 
    RAISE EXCEPTION 'You do not have privileges to maintain Customers.';
4645
 
  END IF;
4646
 
 
4647
 
  IF (NEW.cust_number IS NULL) THEN
4648
 
        RAISE EXCEPTION 'You must supply a valid Customer Number.';
4649
 
  END IF;
4650
 
 
4651
 
  IF (LENGTH(COALESCE(NEW.cust_name,''))=0) THEN
4652
 
        RAISE EXCEPTION 'You must supply a valid Customer Name.';
4653
 
  END IF;
4654
 
 
4655
 
  IF (NEW.cust_custtype_id IS NULL) THEN
4656
 
        RAISE EXCEPTION 'You must supply a valid Customer Type ID.';
4657
 
  END IF;
4658
 
 
4659
 
  IF (NEW.cust_salesrep_id IS NULL) THEN
4660
 
        RAISE EXCEPTION 'You must supply a valid Sales Rep ID.';
4661
 
  END IF;
4662
 
 
4663
 
  IF (NEW.cust_terms_id IS NULL) THEN
4664
 
        RAISE EXCEPTION 'You must supply a valid Terms Code ID.';
4665
 
  END IF;
4666
 
 
4667
 
  IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN
4668
 
    PERFORM clearNumberIssue('CRMAccountNumber', NEW.cust_number);
4669
 
  END IF;
4670
 
 
4671
 
  NEW.cust_number := UPPER(NEW.cust_number);
4672
 
 
4673
 
  RETURN NEW;
4674
 
END;
4675
 
$$;
4676
 
 
4677
 
 
4678
 
ALTER FUNCTION public._custtrigger() OWNER TO admin;
4679
 
 
4680
 
--
4681
 
--
4682
 
 
4683
 
CREATE FUNCTION _custtypeafterdeletetrigger() RETURNS trigger
4684
 
    LANGUAGE plpgsql
4685
 
    AS $$
4686
 
BEGIN
4687
 
  IF (SELECT fetchMetricValue('DefaultCustType') = OLD.custtype_id) THEN
4688
 
    RAISE EXCEPTION 'Cannot delete the default Customer Type [xtuple: custtype, -1, %]',
4689
 
                    OLD.custtype_code;
4690
 
  END IF;
4691
 
 
4692
 
  RETURN OLD;
4693
 
END;
4694
 
$$;
4695
 
 
4696
 
 
4697
 
ALTER FUNCTION public._custtypeafterdeletetrigger() OWNER TO admin;
4698
 
 
4699
 
--
4700
 
--
4701
 
 
4702
 
CREATE FUNCTION _custtypetrigger() RETURNS trigger
4703
 
    LANGUAGE plpgsql
4704
 
    AS $$
4705
 
DECLARE
4706
 
  _check      BOOLEAN;
4707
 
  _code       TEXT;
4708
 
 
4709
 
BEGIN
4710
 
 
4711
 
  IF (TG_OP IN ('INSERT','UPDATE')) THEN
4712
 
 
4713
 
    IF (LENGTH(COALESCE(NEW.custtype_code, ''))=0) THEN
4714
 
      RAISE EXCEPTION 'You must supply a valid Customer Type Code.';
4715
 
    END IF;
4716
 
 
4717
 
    SELECT custtype_code INTO _code
4718
 
    FROM custtype
4719
 
    WHERE ( (UPPER(custtype_code)=UPPER(NEW.custtype_code))
4720
 
      AND (custtype_id<>NEW.custtype_id) );
4721
 
    IF (FOUND) THEN
4722
 
      RAISE EXCEPTION 'The Customer Type Code entered cannot be used as it is in use.';
4723
 
    END IF;
4724
 
 
4725
 
  END IF;
4726
 
 
4727
 
  RETURN NEW;
4728
 
END;
4729
 
$$;
4730
 
 
4731
 
 
4732
 
ALTER FUNCTION public._custtypetrigger() OWNER TO admin;
4733
 
 
4734
 
--
4735
 
--
4736
 
 
4737
 
CREATE FUNCTION _docasstrigger() RETURNS trigger
4738
 
    LANGUAGE plpgsql
4739
 
    AS $$
4740
 
BEGIN
4741
 
  IF (NEW.docass_source_type = 'INCDT') THEN
4742
 
    UPDATE incdt SET incdt_updated = now() WHERE incdt_id = NEW.docass_source_id;
4743
 
  END IF;
4744
 
 
4745
 
  RETURN NEW;
4746
 
END;
4747
 
$$;
4748
 
 
4749
 
 
4750
 
ALTER FUNCTION public._docasstrigger() OWNER TO admin;
4751
 
 
4752
 
--
4753
 
--
4754
 
 
4755
 
CREATE FUNCTION _empafterdeletetrigger() RETURNS trigger
4756
 
    LANGUAGE plpgsql
4757
 
    AS $$
4758
 
BEGIN
4759
 
  IF (fetchMetricBool('EmployeeChangeLog')) THEN
4760
 
    PERFORM postComment(cmnttype_id, 'EMP', OLD.emp_id,
4761
 
                        ('Deleted "' || OLD.emp_code || '"'))
4762
 
      FROM cmnttype
4763
 
     WHERE (cmnttype_name='ChangeLog');
4764
 
  END IF;
4765
 
 
4766
 
  RETURN OLD;
4767
 
END;
4768
 
$$;
4769
 
 
4770
 
 
4771
 
ALTER FUNCTION public._empafterdeletetrigger() OWNER TO admin;
4772
 
 
4773
 
--
4774
 
--
4775
 
 
4776
 
CREATE FUNCTION _empaftertrigger() RETURNS trigger
4777
 
    LANGUAGE plpgsql
4778
 
    AS $$
4779
 
DECLARE
4780
 
  _cmnttypeid     INTEGER;
4781
 
  _newcrmacctname TEXT;
4782
 
 
4783
 
BEGIN
4784
 
 
4785
 
  IF (TG_OP = 'INSERT') THEN
4786
 
    -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE
4787
 
    LOOP
4788
 
      UPDATE crmacct SET crmacct_emp_id=NEW.emp_id,
4789
 
                         crmacct_name=NEW.emp_name
4790
 
       WHERE crmacct_number=NEW.emp_code;
4791
 
      IF (FOUND) THEN
4792
 
        EXIT;
4793
 
      END IF;
4794
 
      BEGIN
4795
 
        INSERT INTO crmacct(crmacct_number,  crmacct_name,    crmacct_active,
4796
 
                            crmacct_type,    crmacct_emp_id,  crmacct_cntct_id_1
4797
 
                  ) VALUES (NEW.emp_code,    NEW.emp_name,    NEW.emp_active, 
4798
 
                            'I',             NEW.emp_id,      NEW.emp_cntct_id);
4799
 
        EXIT;
4800
 
      EXCEPTION WHEN unique_violation THEN
4801
 
            -- do nothing, and loop to try the UPDATE again
4802
 
      END;
4803
 
    END LOOP;
4804
 
 
4805
 
    /* TODO: default characteristic assignments based on empgrp? */
4806
 
 
4807
 
  ELSIF (TG_OP = 'UPDATE') THEN
4808
 
    UPDATE crmacct SET crmacct_number = NEW.emp_code
4809
 
    WHERE ((crmacct_emp_id=NEW.emp_id)
4810
 
      AND  (crmacct_number!=NEW.emp_code));
4811
 
 
4812
 
    UPDATE crmacct SET crmacct_name = NEW.emp_name
4813
 
    WHERE ((crmacct_emp_id=NEW.emp_id)
4814
 
      AND  (crmacct_name!=NEW.emp_name));
4815
 
  END IF;
4816
 
 
4817
 
  IF (fetchMetricBool('EmployeeChangeLog')) THEN
4818
 
    SELECT cmnttype_id INTO _cmnttypeid
4819
 
      FROM cmnttype
4820
 
     WHERE (cmnttype_name='ChangeLog');
4821
 
 
4822
 
    IF (_cmnttypeid IS NOT NULL) THEN
4823
 
      IF (TG_OP = 'INSERT') THEN
4824
 
        PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id, 'Created');
4825
 
 
4826
 
      ELSIF (TG_OP = 'UPDATE') THEN
4827
 
 
4828
 
        IF (OLD.emp_number <> NEW.emp_number) THEN
4829
 
          PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id,
4830
 
                              ('Number Changed from "' || OLD.emp_number ||
4831
 
                               '" to "' || NEW.emp_number || '"'));
4832
 
        END IF;
4833
 
 
4834
 
        IF (OLD.emp_code <> NEW.emp_code) THEN
4835
 
          PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id,
4836
 
                              ('Code Changed from "' || OLD.emp_code ||
4837
 
                               '" to "' || NEW.emp_code || '"'));
4838
 
        END IF;
4839
 
 
4840
 
        IF (OLD.emp_active <> NEW.emp_active) THEN
4841
 
          PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id,
4842
 
                              CASE WHEN NEW.emp_active THEN 'Activated'
4843
 
                                   ELSE 'Deactivated' END);
4844
 
        END IF;
4845
 
 
4846
 
        IF (COALESCE(OLD.emp_dept_id, -1) <> COALESCE(NEW.emp_dept_id, -1)) THEN
4847
 
          PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id,
4848
 
                              ('Department Changed from "' ||
4849
 
                               COALESCE((SELECT dept_number FROM dept
4850
 
                                          WHERE dept_id=OLD.emp_dept_id), '')
4851
 
                               || '" to "' ||
4852
 
                               COALESCE((SELECT dept_number FROM dept
4853
 
                                          WHERE dept_id=NEW.emp_dept_id), '') || '"'));
4854
 
        END IF;
4855
 
 
4856
 
        IF (COALESCE(OLD.emp_shift_id, -1) <> COALESCE(NEW.emp_shift_id, -1)) THEN
4857
 
          PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id,
4858
 
                              ('Shift Changed from "' ||
4859
 
                               COALESCE((SELECT shift_number FROM shift
4860
 
                                          WHERE shift_id=OLD.emp_shift_id), '')
4861
 
                               || '" to "' ||
4862
 
                               COALESCE((SELECT shift_number FROM shift
4863
 
                                          WHERE shift_id=NEW.emp_shift_id), '') || '"'));
4864
 
        END IF;
4865
 
 
4866
 
      END IF;
4867
 
    END IF;
4868
 
  END IF;
4869
 
 
4870
 
  RETURN NEW;
4871
 
END;
4872
 
$$;
4873
 
 
4874
 
 
4875
 
ALTER FUNCTION public._empaftertrigger() OWNER TO admin;
4876
 
 
4877
 
--
4878
 
--
4879
 
 
4880
 
CREATE FUNCTION _empbeforedeletetrigger() RETURNS trigger
4881
 
    LANGUAGE plpgsql
4882
 
    AS $$
4883
 
BEGIN
4884
 
  IF NOT (checkPrivilege('MaintainEmployees')) THEN
4885
 
    RAISE EXCEPTION 'You do not have privileges to maintain Employees.';
4886
 
  END IF;
4887
 
 
4888
 
  UPDATE crmacct SET crmacct_emp_id = NULL
4889
 
   WHERE crmacct_emp_id = OLD.emp_id;
4890
 
 
4891
 
  UPDATE salesrep SET salesrep_emp_id = NULL
4892
 
   WHERE salesrep_emp_id = OLD.emp_id;
4893
 
 
4894
 
  DELETE FROM docass WHERE docass_source_id = OLD.emp_id AND docass_source_type = 'EMP';
4895
 
  DELETE FROM docass WHERE docass_target_id = OLD.emp_id AND docass_target_type = 'EMP';
4896
 
 
4897
 
  RETURN OLD;
4898
 
END;
4899
 
$$;
4900
 
 
4901
 
 
4902
 
ALTER FUNCTION public._empbeforedeletetrigger() OWNER TO admin;
4903
 
 
4904
 
--
4905
 
--
4906
 
 
4907
 
CREATE FUNCTION _empbeforetrigger() RETURNS trigger
4908
 
    LANGUAGE plpgsql
4909
 
    AS $$
4910
 
BEGIN
4911
 
 
4912
 
  IF NOT (checkPrivilege('MaintainEmployees')) THEN
4913
 
    RAISE EXCEPTION 'You do not have privileges to maintain Employees.';
4914
 
  END IF;
4915
 
 
4916
 
  IF (NEW.emp_code IS NULL) THEN
4917
 
    RAISE EXCEPTION 'You must supply a valid Employee Code.';
4918
 
  END IF;
4919
 
 
4920
 
  IF (NEW.emp_number IS NULL) THEN
4921
 
    RAISE EXCEPTION 'You must supply a valid Employee Number.';
4922
 
  END IF;
4923
 
 
4924
 
  IF (NEW.emp_id = NEW.emp_mgr_emp_id) THEN
4925
 
    RAISE EXCEPTION 'An Employee may not be his or her own Manager.';
4926
 
  END IF;
4927
 
 
4928
 
  -- ERROR:  cannot use column references in default expression
4929
 
  IF (NEW.emp_name IS NULL) THEN
4930
 
    NEW.emp_name = COALESCE(formatCntctName(NEW.emp_cntct_id), NEW.emp_number);
4931
 
  END IF;
4932
 
 
4933
 
  IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN
4934
 
    PERFORM clearNumberIssue('CRMAccountNumber', NEW.emp_number);
4935
 
  END IF;
4936
 
 
4937
 
  NEW.emp_code := UPPER(NEW.emp_code);
4938
 
 
4939
 
  -- deprecated column emp_username
4940
 
  IF (TG_OP = 'UPDATE' AND
4941
 
      LOWER(NEW.emp_username) != LOWER(NEW.emp_code) AND
4942
 
      EXISTS(SELECT 1
4943
 
               FROM crmacct
4944
 
              WHERE crmacct_emp_id = NEW.emp_id
4945
 
                AND crmacct_usr_username IS NOT NULL)) THEN
4946
 
    NEW.emp_username = LOWER(NEW.emp_code);
4947
 
  END IF;
4948
 
 
4949
 
  RETURN NEW;
4950
 
END;
4951
 
$$;
4952
 
 
4953
 
 
4954
 
ALTER FUNCTION public._empbeforetrigger() OWNER TO admin;
4955
 
 
4956
 
--
4957
 
--
4958
 
 
4959
 
CREATE FUNCTION _evntlogafterinserttrigger() RETURNS trigger
4960
 
    LANGUAGE plpgsql
4961
 
    AS $$
4962
 
DECLARE
4963
 
  _r RECORD;
4964
 
 
4965
 
BEGIN
4966
 
 
4967
 
  IF (NEW.evntlog_username = 'autopilot') THEN
4968
 
    SELECT * INTO _r FROM evnttype WHERE (evnttype_id=NEW.evntlog_evnttype_id);
4969
 
    IF (_r.evnttype_name = 'SoCreated') THEN
4970
 
      PERFORM createPrjToSale(NEW.evntlog_ord_id);
4971
 
    END IF;
4972
 
  END IF;
4973
 
 
4974
 
  RETURN NEW;
4975
 
END;
4976
 
$$;
4977
 
 
4978
 
 
4979
 
ALTER FUNCTION public._evntlogafterinserttrigger() OWNER TO admin;
4980
 
 
4981
 
--
4982
 
--
4983
 
 
4984
 
CREATE FUNCTION _gltransaltertrigger() RETURNS trigger
4985
 
    LANGUAGE plpgsql
4986
 
    AS $$
4987
 
DECLARE
4988
 
  _externalCompany      BOOLEAN := false;
4989
 
  _updated BOOLEAN := false;
4990
 
BEGIN
4991
 
  IF(TG_OP='DELETE') THEN
4992
 
    RAISE EXCEPTION 'You may not delete G/L Transactions once they have been created.';
4993
 
  ELSIF (TG_OP = 'UPDATE') THEN
4994
 
    SELECT company_external INTO _externalCompany
4995
 
    FROM company JOIN accnt ON (company_number=accnt_company)
4996
 
    WHERE (accnt_id=NEW.gltrans_accnt_id);
4997
 
    IF (_externalCompany) THEN
4998
 
      RAISE EXCEPTION 'Transactions are not allowed for G/L Accounts with External Company segments.';
4999
 
    END IF;
5000
 
 
5001
 
    IF(OLD.gltrans_id != NEW.gltrans_id) THEN
5002
 
      _updated := true;
5003
 
    ELSIF(OLD.gltrans_date != NEW.gltrans_date) THEN
5004
 
      _updated := true;
5005
 
    ELSIF(OLD.gltrans_accnt_id != NEW.gltrans_accnt_id) THEN
5006
 
      _updated := true;
5007
 
    ELSIF(OLD.gltrans_amount != NEW.gltrans_amount) THEN
5008
 
      _updated := true;
5009
 
    ELSIF(OLD.gltrans_username != NEW.gltrans_username) THEN
5010
 
      _updated := true;
5011
 
    ELSIF( (OLD.gltrans_sequence IS NULL     AND NEW.gltrans_sequence IS NOT NULL)
5012
 
        OR (OLD.gltrans_sequence IS NOT NULL AND NEW.gltrans_sequence IS NULL)
5013
 
        OR (COALESCE(OLD.gltrans_sequence,0) != COALESCE(NEW.gltrans_sequence,0)) ) THEN
5014
 
      _updated := true;
5015
 
    ELSIF( (OLD.gltrans_created IS NULL     AND NEW.gltrans_created IS NOT NULL)
5016
 
        OR (OLD.gltrans_created IS NOT NULL AND NEW.gltrans_created IS NULL)
5017
 
        OR (COALESCE(OLD.gltrans_created,now()) != COALESCE(NEW.gltrans_created,now())) ) THEN
5018
 
      _updated := true;
5019
 
    ELSIF( (OLD.gltrans_source IS NULL     AND NEW.gltrans_source IS NOT NULL)
5020
 
        OR (OLD.gltrans_source IS NOT NULL AND NEW.gltrans_source IS NULL)
5021
 
        OR (COALESCE(OLD.gltrans_source,'') != COALESCE(NEW.gltrans_source,'')) ) THEN
5022
 
      _updated := true;
5023
 
    ELSIF( (OLD.gltrans_docnumber IS NULL     AND NEW.gltrans_docnumber IS NOT NULL)
5024
 
        OR (OLD.gltrans_docnumber IS NOT NULL AND NEW.gltrans_docnumber IS NULL)
5025
 
        OR (COALESCE(OLD.gltrans_docnumber,'') != COALESCE(NEW.gltrans_docnumber,'')) ) THEN
5026
 
      _updated := true;
5027
 
    ELSIF( (OLD.gltrans_doctype IS NULL     AND NEW.gltrans_doctype IS NOT NULL)
5028
 
        OR (OLD.gltrans_doctype IS NOT NULL AND NEW.gltrans_doctype IS NULL)
5029
 
        OR (COALESCE(OLD.gltrans_doctype,'') != COALESCE(NEW.gltrans_doctype,'')) ) THEN
5030
 
      _updated := true;
5031
 
    END IF;
5032
 
 
5033
 
    IF(_updated) THEN
5034
 
      RAISE EXCEPTION 'You may not alter some G/L Transaction fields once they have been created.';
5035
 
    END IF;
5036
 
  ELSE
5037
 
    RAISE EXCEPTION 'trigger for gltrans table called in unexpected state.';
5038
 
  END IF;
5039
 
  RETURN NEW;
5040
 
END;
5041
 
$$;
5042
 
 
5043
 
 
5044
 
ALTER FUNCTION public._gltransaltertrigger() OWNER TO admin;
5045
 
 
5046
 
--
5047
 
--
5048
 
 
5049
 
CREATE FUNCTION _gltransinserttrigger() RETURNS trigger
5050
 
    LANGUAGE plpgsql
5051
 
    AS $$
5052
 
DECLARE
5053
 
  _reqNotes BOOLEAN;
5054
 
  _externalCompany      BOOLEAN := false;
5055
 
BEGIN
5056
 
  -- Checks
5057
 
  -- Start with privileges
5058
 
  IF ((NEW.gltrans_doctype='JE') AND (NOT checkPrivilege('PostJournalEntries'))) THEN
5059
 
      RAISE EXCEPTION 'You do not have privileges to create a Journal Entry.';
5060
 
  END IF;
5061
 
 
5062
 
  SELECT company_external INTO _externalCompany
5063
 
  FROM company JOIN accnt ON (company_number=accnt_company)
5064
 
  WHERE (accnt_id=NEW.gltrans_accnt_id);
5065
 
  IF (_externalCompany) THEN
5066
 
    RAISE EXCEPTION 'Transactions are not allowed for G/L Accounts with External Company segments.';
5067
 
  END IF;
5068
 
  -- RAISE NOTICE '_gltransInsertTrigger(): company_external = %', _externalCompany;
5069
 
 
5070
 
  SELECT metric_value='t'
5071
 
    INTO _reqNotes
5072
 
    FROM metric
5073
 
   WHERE(metric_name='MandatoryGLEntryNotes');
5074
 
  IF (_reqNotes IS NULL) THEN
5075
 
    _reqNotes := false;
5076
 
  END IF;
5077
 
  IF ((NEW.gltrans_doctype='JE') AND _reqNotes AND (TRIM(BOTH FROM COALESCE(NEW.gltrans_notes,''))='')) THEN
5078
 
      RAISE EXCEPTION 'Notes are required for Journal Entries.';
5079
 
  END IF;
5080
 
  
5081
 
  RETURN NEW;
5082
 
END;
5083
 
$$;
5084
 
 
5085
 
 
5086
 
ALTER FUNCTION public._gltransinserttrigger() OWNER TO admin;
5087
 
 
5088
 
--
5089
 
--
5090
 
 
5091
 
CREATE FUNCTION _grpprivtrigger() RETURNS trigger
5092
 
    LANGUAGE plpgsql
5093
 
    AS $$
5094
 
DECLARE
5095
 
  _check BOOLEAN;
5096
 
  _returnVal INTEGER;
5097
 
BEGIN
5098
 
  -- This looks like a candidate for a foreign key but isn't.
5099
 
  -- fkeys don't work if the foreign key value resides in a child of the 
5100
 
  -- table and not the table itself.
5101
 
  IF ((TG_OP = 'UPDATE' OR TG_OP = 'INSERT') AND
5102
 
      (NOT EXISTS(SELECT priv_id
5103
 
                  FROM priv
5104
 
                  WHERE (priv_id=NEW.grppriv_priv_id)))) THEN
5105
 
    RAISE EXCEPTION 'Privilege id % does not exist or is part of a disabled package.',
5106
 
                NEW.grppriv_priv_id;
5107
 
    RETURN OLD;
5108
 
 
5109
 
  ELSIF (TG_OP = 'DELETE') THEN
5110
 
    RETURN OLD;
5111
 
  END IF;
5112
 
 
5113
 
  RETURN NEW;
5114
 
END;
5115
 
$$;
5116
 
 
5117
 
 
5118
 
ALTER FUNCTION public._grpprivtrigger() OWNER TO admin;
5119
 
 
5120
 
--
5121
 
--
5122
 
 
5123
 
CREATE FUNCTION _imageasstrigger() RETURNS trigger
5124
 
    LANGUAGE plpgsql
5125
 
    AS $$
5126
 
BEGIN
5127
 
  IF (NEW.imageass_source = 'INCDT') THEN
5128
 
    UPDATE incdt SET incdt_updated = now() WHERE incdt_id = NEW.imageass_source_id;
5129
 
  END IF;
5130
 
 
5131
 
  RETURN NEW;
5132
 
END;
5133
 
$$;
5134
 
 
5135
 
 
5136
 
ALTER FUNCTION public._imageasstrigger() OWNER TO admin;
5137
 
 
5138
 
--
5139
 
--
5140
 
 
5141
 
CREATE FUNCTION _incdtbeforedeletetrigger() RETURNS trigger
5142
 
    LANGUAGE plpgsql
5143
 
    AS $$
5144
 
DECLARE
5145
 
  _recurid     INTEGER;
5146
 
  _newparentid INTEGER;
5147
 
BEGIN
5148
 
  IF (TG_OP = 'DELETE') THEN
5149
 
    SELECT recur_id INTO _recurid
5150
 
      FROM recur
5151
 
     WHERE ((recur_parent_id=OLD.incdt_id)
5152
 
        AND (recur_parent_type='INCDT'));
5153
 
 
5154
 
     IF (_recurid IS NOT NULL) THEN
5155
 
       SELECT MIN(incdt_id) INTO _newparentid
5156
 
         FROM incdt
5157
 
        WHERE ((incdt_recurring_incdt_id=OLD.inctd_id)
5158
 
           AND (incdt_id!=OLD.incdt_id));
5159
 
 
5160
 
      -- client is responsible for warning about deleting a recurring incdt
5161
 
      IF (_newparentid IS NULL) THEN
5162
 
        DELETE FROM recur WHERE recur_id=_recurid;
5163
 
      ELSE
5164
 
        UPDATE recur SET recur_parent_id=_newparentid
5165
 
         WHERE recur_id=_recurid;
5166
 
      END IF;
5167
 
    END IF;
5168
 
 
5169
 
    RETURN OLD;
5170
 
  END IF;
5171
 
 
5172
 
  RETURN NEW;
5173
 
END;
5174
 
$$;
5175
 
 
5176
 
 
5177
 
ALTER FUNCTION public._incdtbeforedeletetrigger() OWNER TO admin;
5178
 
 
5179
 
--
5180
 
--
5181
 
 
5182
 
CREATE FUNCTION _incdtbeforetrigger() RETURNS trigger
5183
 
    LANGUAGE plpgsql
5184
 
    AS $$
5185
 
DECLARE
5186
 
  _rec          RECORD;
5187
 
  _check        BOOLEAN;
5188
 
  _crmacct      INTEGER;
5189
 
 
5190
 
BEGIN
5191
 
 
5192
 
  IF(TG_OP = 'DELETE') THEN
5193
 
    _rec := OLD;
5194
 
  ELSE
5195
 
    _rec := NEW;
5196
 
  END IF;
5197
 
 
5198
 
  -- Set the incident number if blank
5199
 
  IF (TG_OP = 'INSERT') THEN
5200
 
    IF (NEW.incdt_number IS NULL) THEN
5201
 
      SELECT fetchIncidentNumber() INTO NEW.incdt_number;
5202
 
    END IF;
5203
 
 
5204
 
    --- clear the number from the issue cache
5205
 
    PERFORM clearNumberIssue('IncidentNumber', NEW.incdt_number);
5206
 
  END IF;
5207
 
 
5208
 
  -- Description is required
5209
 
  IF (LENGTH(COALESCE(NEW.incdt_summary,''))=0) THEN
5210
 
    RAISE EXCEPTION 'You must supply a valid Incident Description.';
5211
 
  END IF;
5212
 
  
5213
 
  -- CRM Account is required
5214
 
  IF (NEW.incdt_crmacct_id IS NULL) THEN
5215
 
    RAISE EXCEPTION 'You must supply a valid CRM Account.';
5216
 
  END IF;
5217
 
 
5218
 
  -- Contact is required
5219
 
  IF (NEW.incdt_cntct_id IS NULL) THEN
5220
 
    RAISE EXCEPTION 'You must supply a valid Contact.';
5221
 
  END IF;
5222
 
 
5223
 
  NEW.incdt_updated := now();
5224
 
 
5225
 
  RETURN NEW;
5226
 
END;
5227
 
$$;
5228
 
 
5229
 
 
5230
 
ALTER FUNCTION public._incdtbeforetrigger() OWNER TO admin;
5231
 
 
5232
 
--
5233
 
--
5234
 
 
5235
 
CREATE FUNCTION _incdttrigger() RETURNS trigger
5236
 
    LANGUAGE plpgsql
5237
 
    AS $$
5238
 
DECLARE
5239
 
  _r            RECORD;
5240
 
  _counter      INTEGER :=  0;
5241
 
  _whsId        INTEGER := -1;
5242
 
  _evntType     TEXT;
5243
 
  _cmnttypeid   INTEGER := -1;
5244
 
  _cmntid       INTEGER := -1;
5245
 
BEGIN
5246
 
 
5247
 
  SELECT cmnttype_id INTO _cmnttypeid
5248
 
    FROM cmnttype
5249
 
    WHERE (cmnttype_name='Notes to Comment');
5250
 
  IF NOT FOUND OR _cmnttypeid IS NULL THEN
5251
 
    _cmnttypeid := -1;
5252
 
  END IF;
5253
 
 
5254
 
  IF (TG_OP = 'DELETE') THEN
5255
 
    RETURN OLD;
5256
 
  ELSIF (TG_OP = 'INSERT') THEN
5257
 
    INSERT INTO incdthist
5258
 
          (incdthist_incdt_id,
5259
 
           incdthist_change, incdthist_target_id,
5260
 
           incdthist_descrip)
5261
 
    VALUES(NEW.incdt_id,
5262
 
           'N', NULL,
5263
 
           'Incident Added');
5264
 
 
5265
 
    _evntType = 'NewIncident';
5266
 
 
5267
 
    IF (_cmnttypeid <> -1 AND COALESCE(NEW.incdt_descrip, '') <> '') THEN
5268
 
      PERFORM postComment(_cmnttypeid, 'INCDT', NEW.incdt_id, NEW.incdt_descrip);
5269
 
    END IF;
5270
 
  ELSIF (TG_OP = 'UPDATE') THEN
5271
 
    _evntType = 'UpdatedIncident';
5272
 
 
5273
 
    IF (COALESCE(NEW.incdt_cntct_id,-1) <> COALESCE(OLD.incdt_cntct_id,-1)) THEN
5274
 
      INSERT INTO incdthist
5275
 
            (incdthist_incdt_id,
5276
 
             incdthist_change, incdthist_target_id,
5277
 
             incdthist_descrip)
5278
 
      VALUES(NEW.incdt_id,
5279
 
             'C', NEW.incdt_cntct_id,
5280
 
             ('Contact Changed: "' ||
5281
 
               COALESCE((SELECT cntct_first_name || ' ' || cntct_last_name
5282
 
                           FROM cntct
5283
 
                          WHERE (cntct_id=OLD.incdt_cntct_id)), '')
5284
 
              || '" -> "' ||
5285
 
               COALESCE((SELECT cntct_first_name || ' ' || cntct_last_name
5286
 
                           FROM cntct
5287
 
                          WHERE (cntct_id=NEW.incdt_cntct_id)), '')
5288
 
              || '"') );
5289
 
    END IF;
5290
 
 
5291
 
    IF (COALESCE(NEW.incdt_summary,'') <> COALESCE(OLD.incdt_summary,'')) THEN
5292
 
      INSERT INTO incdthist
5293
 
            (incdthist_incdt_id,
5294
 
             incdthist_descrip)
5295
 
      VALUES(NEW.incdt_id,
5296
 
             ('Description Updated: "' ||
5297
 
               COALESCE(OLD.incdt_summary, '') ||
5298
 
              '" -> "' ||
5299
 
               COALESCE(NEW.incdt_summary, '') ||
5300
 
              '"') );
5301
 
    END IF;
5302
 
 
5303
 
    IF (COALESCE(NEW.incdt_descrip,'') <> COALESCE(OLD.incdt_descrip,'')) THEN
5304
 
      INSERT INTO incdthist
5305
 
            (incdthist_incdt_id,
5306
 
             incdthist_descrip)
5307
 
      VALUES(NEW.incdt_id,
5308
 
             ('Notes Updated: "' ||
5309
 
               substr(COALESCE(OLD.incdt_descrip, ''), 1, 20) ||
5310
 
              '..." -> "' ||
5311
 
               substr(COALESCE(NEW.incdt_descrip, ''), 1, 20) ||
5312
 
              '..."') );
5313
 
 
5314
 
      IF (_cmnttypeid <> -1) THEN
5315
 
        -- find an existing comment
5316
 
        SELECT comment_id
5317
 
          INTO _cmntid
5318
 
          FROM comment
5319
 
         WHERE comment_source = 'INCDT'
5320
 
           AND comment_source_id = NEW.incdt_id
5321
 
           -- back out change for 21068
5322
 
           -- AND comment_user = getEffectiveXtUser()
5323
 
           AND comment_cmnttype_id = _cmnttypeid;
5324
 
        IF FOUND THEN
5325
 
          UPDATE comment SET comment_text = NEW.incdt_descrip
5326
 
          WHERE comment_id = _cmntid;
5327
 
        ELSE
5328
 
          PERFORM postComment(_cmnttypeid, 'INCDT', NEW.incdt_id, NEW.incdt_descrip);
5329
 
        END IF;
5330
 
      END IF;
5331
 
    END IF;
5332
 
 
5333
 
    IF (NEW.incdt_status <> OLD.incdt_status) THEN
5334
 
      INSERT INTO incdthist
5335
 
            (incdthist_incdt_id,
5336
 
             incdthist_change, incdthist_target_id,
5337
 
             incdthist_descrip)
5338
 
      VALUES(NEW.incdt_id,
5339
 
             'S', NULL,
5340
 
             ('Status Changed: ' ||
5341
 
              CASE WHEN(OLD.incdt_status='N') THEN 'New'
5342
 
                   WHEN(OLD.incdt_status='F') THEN 'Feedback'
5343
 
                   WHEN(OLD.incdt_status='C') THEN 'Confirmed'
5344
 
                   WHEN(OLD.incdt_status='A') THEN 'Assigned'
5345
 
                   WHEN(OLD.incdt_status='R') THEN 'Resolved'
5346
 
                   WHEN(OLD.incdt_status='L') THEN 'Closed'
5347
 
                   ELSE OLD.incdt_status
5348
 
              END
5349
 
              || ' -> ' ||
5350
 
              CASE WHEN(NEW.incdt_status='N') THEN 'New'
5351
 
                   WHEN(NEW.incdt_status='F') THEN 'Feedback'
5352
 
                   WHEN(NEW.incdt_status='C') THEN 'Confirmed'
5353
 
                   WHEN(NEW.incdt_status='A') THEN 'Assigned'
5354
 
                   WHEN(NEW.incdt_status='R') THEN 'Resolved'
5355
 
                   WHEN(NEW.incdt_status='L') THEN 'Closed'
5356
 
                   ELSE NEW.incdt_status
5357
 
              END
5358
 
              ) );
5359
 
      IF (NEW.incdt_status = 'L') THEN
5360
 
        _evntType = 'ClosedIncident';
5361
 
      ELSIF (OLD.incdt_status = 'L') THEN
5362
 
        _evntType = 'ReopenedIncident';
5363
 
      END IF;
5364
 
    END IF;
5365
 
 
5366
 
    IF (COALESCE(NEW.incdt_assigned_username,'') <> COALESCE(OLD.incdt_assigned_username,'')) THEN
5367
 
      INSERT INTO incdthist
5368
 
            (incdthist_incdt_id,
5369
 
             incdthist_change, incdthist_target_id,
5370
 
             incdthist_descrip)
5371
 
      VALUES(NEW.incdt_id,
5372
 
             'A', NULL,
5373
 
             ('Assigned to: "' ||
5374
 
               COALESCE(OLD.incdt_assigned_username, '') ||
5375
 
              '" -> "' ||
5376
 
               COALESCE(NEW.incdt_assigned_username, '') ||
5377
 
              '"') );
5378
 
    END IF;
5379
 
 
5380
 
    IF (COALESCE(NEW.incdt_incdtcat_id,-1) <> COALESCE(OLD.incdt_incdtcat_id,-1)) THEN
5381
 
      INSERT INTO incdthist
5382
 
            (incdthist_incdt_id,
5383
 
             incdthist_change, incdthist_target_id,
5384
 
             incdthist_descrip)
5385
 
      VALUES(NEW.incdt_id,
5386
 
             'T', NEW.incdt_incdtcat_id,
5387
 
             ('Category Changed: ' ||
5388
 
               COALESCE((SELECT incdtcat_name
5389
 
                           FROM incdtcat
5390
 
                          WHERE (incdtcat_id=OLD.incdt_incdtcat_id)), '')
5391
 
              || ' -> ' ||
5392
 
               COALESCE((SELECT incdtcat_name
5393
 
                           FROM incdtcat
5394
 
                          WHERE (incdtcat_id=NEW.incdt_incdtcat_id)), '')
5395
 
              || '') );
5396
 
    END IF;
5397
 
 
5398
 
    IF (COALESCE(NEW.incdt_incdtseverity_id,-1) <> COALESCE(OLD.incdt_incdtseverity_id,-1)) THEN
5399
 
      INSERT INTO incdthist
5400
 
            (incdthist_incdt_id,
5401
 
             incdthist_change, incdthist_target_id,
5402
 
             incdthist_descrip)
5403
 
      VALUES(NEW.incdt_id,
5404
 
             'V', NEW.incdt_incdtseverity_id,
5405
 
             ('Severity Changed: ' ||
5406
 
               COALESCE((SELECT incdtseverity_name
5407
 
                           FROM incdtseverity
5408
 
                          WHERE (incdtseverity_id=OLD.incdt_incdtseverity_id)), '')
5409
 
              || ' -> ' ||
5410
 
               COALESCE((SELECT incdtseverity_name
5411
 
                           FROM incdtseverity
5412
 
                          WHERE (incdtseverity_id=NEW.incdt_incdtseverity_id)), '')
5413
 
              || '') );
5414
 
    END IF;
5415
 
 
5416
 
    IF (COALESCE(NEW.incdt_incdtpriority_id,-1) <> COALESCE(OLD.incdt_incdtpriority_id,-1)) THEN
5417
 
      INSERT INTO incdthist
5418
 
            (incdthist_incdt_id,
5419
 
             incdthist_change, incdthist_target_id,
5420
 
             incdthist_descrip)
5421
 
      VALUES(NEW.incdt_id,
5422
 
             'P', NEW.incdt_incdtpriority_id,
5423
 
             ('Priority Changed: ' ||
5424
 
               COALESCE((SELECT incdtpriority_name
5425
 
                           FROM incdtpriority
5426
 
                          WHERE (incdtpriority_id=OLD.incdt_incdtpriority_id)), '')
5427
 
              || ' -> ' ||
5428
 
               COALESCE((SELECT incdtpriority_name
5429
 
                           FROM incdtpriority
5430
 
                          WHERE (incdtpriority_id=NEW.incdt_incdtpriority_id)), '')
5431
 
              || '') );
5432
 
    END IF;
5433
 
 
5434
 
    IF (COALESCE(NEW.incdt_incdtresolution_id,-1) <> COALESCE(OLD.incdt_incdtresolution_id,-1)) THEN
5435
 
      INSERT INTO incdthist
5436
 
            (incdthist_incdt_id,
5437
 
             incdthist_change, incdthist_target_id,
5438
 
             incdthist_descrip)
5439
 
      VALUES(NEW.incdt_id,
5440
 
             'E', NEW.incdt_incdtresolution_id,
5441
 
             ('Resolution Changed: ' ||
5442
 
               COALESCE((SELECT incdtresolution_name
5443
 
                           FROM incdtresolution
5444
 
                          WHERE (incdtresolution_id=OLD.incdt_incdtresolution_id)), '')
5445
 
              || ' -> ' ||
5446
 
               COALESCE((SELECT incdtresolution_name
5447
 
                           FROM incdtresolution
5448
 
                          WHERE (incdtresolution_id=NEW.incdt_incdtresolution_id)), '')
5449
 
              || '') );
5450
 
    END IF;
5451
 
  END IF;
5452
 
 
5453
 
    PERFORM postEvent(_evntType, 'IC', NEW.incdt_id,
5454
 
                      NULL, NEW.incdt_number::TEXT,
5455
 
                      NULL, NULL, NULL, NULL);
5456
 
 
5457
 
  RETURN NEW;
5458
 
  END;
5459
 
$$;
5460
 
 
5461
 
 
5462
 
ALTER FUNCTION public._incdttrigger() OWNER TO admin;
5463
 
 
5464
 
--
5465
 
--
5466
 
 
5467
 
CREATE FUNCTION _invcheadaftertrigger() RETURNS trigger
5468
 
    LANGUAGE plpgsql
5469
 
    AS $$
5470
 
  DECLARE
5471
 
    _cmnttypeid INTEGER;
5472
 
    _cohead_id INTEGER;
5473
 
 
5474
 
  BEGIN
5475
 
 
5476
 
    SELECT cmnttype_id INTO _cmnttypeid
5477
 
    FROM cmnttype
5478
 
    WHERE (cmnttype_name='ChangeLog');
5479
 
    IF (FOUND) THEN
5480
 
      IF (TG_OP = 'UPDATE') THEN
5481
 
        IF ((OLD.invchead_posted != NEW.invchead_posted) AND NEW.invchead_posted) THEN
5482
 
          SELECT cohead_id INTO _cohead_id
5483
 
          FROM cohead
5484
 
          WHERE (cohead_number = OLD.invchead_ordernumber);
5485
 
          IF (FOUND) THEN
5486
 
            PERFORM postComment( _cmnttypeid, 'S', _cohead_id,
5487
 
                                 ('Invoice, ' || NEW.invchead_invcnumber || ', posted for this order') );
5488
 
          END IF;
5489
 
        END IF;
5490
 
      END IF;
5491
 
    END IF;
5492
 
  RETURN NEW;
5493
 
  END;
5494
 
$$;
5495
 
 
5496
 
 
5497
 
ALTER FUNCTION public._invcheadaftertrigger() OWNER TO admin;
5498
 
 
5499
 
--
5500
 
--
5501
 
 
5502
 
CREATE FUNCTION _invcheadbeforetrigger() RETURNS trigger
5503
 
    LANGUAGE plpgsql
5504
 
    AS $$
5505
 
DECLARE
5506
 
  _recurid     INTEGER;
5507
 
  _newparentid INTEGER;
5508
 
 
5509
 
BEGIN
5510
 
  IF (TG_OP = 'UPDATE') THEN
5511
 
    IF (OLD.invchead_posted
5512
 
      AND ((OLD.invchead_invcnumber != NEW.invchead_invcnumber)
5513
 
        OR (OLD.invchead_invcdate != NEW.invchead_invcdate)
5514
 
        OR (OLD.invchead_terms_id != NEW.invchead_terms_id)
5515
 
        OR (OLD.invchead_salesrep_id != NEW.invchead_salesrep_id)
5516
 
        OR (OLD.invchead_commission != NEW.invchead_commission)
5517
 
        OR (OLD.invchead_taxzone_id != NEW.invchead_taxzone_id)
5518
 
        OR (OLD.invchead_shipchrg_id != NEW.invchead_shipchrg_id)
5519
 
        OR (OLD.invchead_prj_id != NEW.invchead_prj_id)
5520
 
        OR (OLD.invchead_misc_accnt_id != NEW.invchead_misc_accnt_id)
5521
 
        OR (OLD.invchead_misc_amount != NEW.invchead_misc_amount)
5522
 
        OR (OLD.invchead_freight != NEW.invchead_freight))) THEN
5523
 
      RAISE EXCEPTION 'Edit not allow on Posted Invoice.';
5524
 
    END IF;
5525
 
  END IF;
5526
 
  
5527
 
  IF (TG_OP = 'DELETE') THEN
5528
 
    DELETE FROM invcheadtax
5529
 
    WHERE (taxhist_parent_id=OLD.invchead_id);
5530
 
 
5531
 
    SELECT recur_id INTO _recurid
5532
 
      FROM recur
5533
 
     WHERE ((recur_parent_id=OLD.invchead_id)
5534
 
        AND (recur_parent_type='I'));
5535
 
    IF (_recurid IS NOT NULL) THEN
5536
 
      SELECT invchead_id INTO _newparentid
5537
 
        FROM invchead
5538
 
       WHERE ((invchead_recurring_invchead_id=OLD.invchead_id)
5539
 
          AND (invchead_id!=OLD.invchead_id))
5540
 
       ORDER BY invchead_invcdate
5541
 
       LIMIT 1;
5542
 
 
5543
 
      IF (_newparentid IS NULL) THEN
5544
 
        DELETE FROM recur WHERE recur_id=_recurid;
5545
 
      ELSE
5546
 
        UPDATE recur SET recur_parent_id=_newparentid
5547
 
         WHERE recur_id=_recurid;
5548
 
        UPDATE invchead SET invchead_recurring_invchead_id=_newparentid
5549
 
         WHERE invchead_recurring_invchead_id=OLD.invchead_id
5550
 
           AND invchead_id!=OLD.invchead_id;
5551
 
      END IF;
5552
 
    END IF;
5553
 
 
5554
 
    RETURN OLD;
5555
 
  END IF;
5556
 
 
5557
 
  RETURN NEW;
5558
 
END;
5559
 
$$;
5560
 
 
5561
 
 
5562
 
ALTER FUNCTION public._invcheadbeforetrigger() OWNER TO admin;
5563
 
 
5564
 
--
5565
 
--
5566
 
 
5567
 
CREATE FUNCTION _invcheadtrigger() RETURNS trigger
5568
 
    LANGUAGE plpgsql
5569
 
    AS $$
5570
 
BEGIN
5571
 
  IF (TG_OP = 'DELETE') THEN
5572
 
    -- Something can go here
5573
 
    RETURN OLD;
5574
 
  END IF;
5575
 
 
5576
 
  IF (TG_OP = 'INSERT') THEN
5577
 
 
5578
 
  -- Calculate Freight Tax
5579
 
    IF (NEW.invchead_freight <> 0) THEN
5580
 
      PERFORM calculateTaxHist( 'invcheadtax',
5581
 
                                NEW.invchead_id,
5582
 
                                NEW.invchead_taxzone_id,
5583
 
                                getFreightTaxtypeId(),
5584
 
                                NEW.invchead_invcdate,
5585
 
                                NEW.invchead_curr_id,
5586
 
                                NEW.invchead_freight );
5587
 
    END IF;
5588
 
 
5589
 
    --- clear the number from the issue cache
5590
 
    PERFORM clearNumberIssue('InvcNumber', NEW.invchead_invcnumber);
5591
 
  END IF;
5592
 
 
5593
 
  IF (TG_OP = 'UPDATE') THEN
5594
 
 
5595
 
    IF ( (NEW.invchead_freight <> OLD.invchead_freight) OR
5596
 
         (COALESCE(NEW.invchead_taxzone_id,-1) <> COALESCE(OLD.invchead_taxzone_id,-1)) OR
5597
 
         (NEW.invchead_invcdate <> OLD.invchead_invcdate) OR
5598
 
         (NEW.invchead_curr_id <> OLD.invchead_curr_id) ) THEN
5599
 
  -- Calculate invchead Tax
5600
 
      PERFORM calculateTaxHist( 'invcheadtax',
5601
 
                                NEW.invchead_id,
5602
 
                                NEW.invchead_taxzone_id,
5603
 
                                getFreightTaxtypeId(),
5604
 
                                NEW.invchead_invcdate,
5605
 
                                NEW.invchead_curr_id,
5606
 
                                NEW.invchead_freight );
5607
 
    END IF;
5608
 
 
5609
 
    IF ( (COALESCE(NEW.invchead_taxzone_id,-1) <> COALESCE(OLD.invchead_taxzone_id,-1)) OR
5610
 
         (NEW.invchead_invcdate <> OLD.invchead_invcdate) OR
5611
 
         (NEW.invchead_curr_id <> OLD.invchead_curr_id) ) THEN
5612
 
  -- Calculate invcitem Tax
5613
 
      IF (COALESCE(NEW.invchead_taxzone_id,-1) <> COALESCE(OLD.invchead_taxzone_id,-1)) THEN
5614
 
 
5615
 
        UPDATE invcitem SET invcitem_taxtype_id=getItemTaxType(invcitem_item_id,NEW.invchead_taxzone_id)
5616
 
        WHERE (invcitem_invchead_id=NEW.invchead_id);
5617
 
 
5618
 
        PERFORM calculateTaxHist( 'invcitemtax',
5619
 
                                  invcitem_id,
5620
 
                                  NEW.invchead_taxzone_id,
5621
 
                                  invcitem_taxtype_id,
5622
 
                                  NEW.invchead_invcdate,
5623
 
                                  NEW.invchead_curr_id,
5624
 
                                  (invcitem_billed * invcitem_qty_invuomratio) *
5625
 
                                  (invcitem_price / invcitem_price_invuomratio) )
5626
 
        FROM invcitem
5627
 
        WHERE (invcitem_invchead_id = NEW.invchead_id);
5628
 
      END IF;
5629
 
    END IF;
5630
 
 
5631
 
  END IF;
5632
 
 
5633
 
  RETURN NEW;
5634
 
END;
5635
 
$$;
5636
 
 
5637
 
 
5638
 
ALTER FUNCTION public._invcheadtrigger() OWNER TO admin;
5639
 
 
5640
 
--
5641
 
--
5642
 
 
5643
 
CREATE FUNCTION _invcitembeforetrigger() RETURNS trigger
5644
 
    LANGUAGE plpgsql
5645
 
    AS $$
5646
 
DECLARE
5647
 
  _itemfractional BOOLEAN;
5648
 
 
5649
 
BEGIN
5650
 
  IF (TG_OP = 'DELETE') THEN
5651
 
    DELETE FROM invcitemtax
5652
 
    WHERE (taxhist_parent_id=OLD.invcitem_id);
5653
 
 
5654
 
    RETURN OLD;
5655
 
  END IF;
5656
 
 
5657
 
  IF (TG_OP IN ('UPDATE','DELETE')) THEN
5658
 
    IF (SELECT COUNT(invchead_id) > 0
5659
 
        FROM invchead
5660
 
        WHERE ((invchead_id=OLD.invcitem_invchead_id)
5661
 
          AND (invchead_posted))) THEN
5662
 
      RAISE EXCEPTION 'Edit not allowed on Posted Invoices.';
5663
 
    END IF;
5664
 
  END IF;
5665
 
 
5666
 
  -- If regular Item then enforce item_fractional
5667
 
  IF (COALESCE(NEW.invcitem_item_id, -1) <> -1) THEN
5668
 
    SELECT itemuomfractionalbyuom(NEW.invcitem_item_id, NEW.invcitem_qty_uom_id) INTO _itemfractional;
5669
 
    IF (NOT _itemfractional) THEN
5670
 
      IF (TRUNC(NEW.invcitem_ordered) <> NEW.invcitem_ordered) THEN
5671
 
        RAISE EXCEPTION 'Item does not support fractional quantities';
5672
 
      END IF;
5673
 
      IF (TRUNC(NEW.invcitem_billed) <> NEW.invcitem_billed) THEN
5674
 
        RAISE EXCEPTION 'Item does not support fractional quantities';
5675
 
      END IF;
5676
 
    END IF;
5677
 
  END IF;
5678
 
 
5679
 
  RETURN NEW;
5680
 
END;
5681
 
$$;
5682
 
 
5683
 
 
5684
 
ALTER FUNCTION public._invcitembeforetrigger() OWNER TO admin;
5685
 
 
5686
 
--
5687
 
--
5688
 
 
5689
 
CREATE FUNCTION _invcitemtrigger() RETURNS trigger
5690
 
    LANGUAGE plpgsql
5691
 
    AS $$
5692
 
DECLARE
5693
 
  _r RECORD;
5694
 
 
5695
 
BEGIN
5696
 
  IF (TG_OP = 'DELETE') THEN
5697
 
    RETURN OLD;
5698
 
  END IF;
5699
 
 
5700
 
  SELECT * INTO _r
5701
 
  FROM invchead
5702
 
  WHERE (invchead_id=NEW.invcitem_invchead_id);
5703
 
  IF (NOT FOUND) THEN
5704
 
    RAISE EXCEPTION 'Invoice head not found';
5705
 
  END IF;
5706
 
 
5707
 
  IF (TG_OP = 'INSERT') THEN
5708
 
 
5709
 
  -- Calculate Tax
5710
 
      PERFORM calculateTaxHist( 'invcitemtax',
5711
 
                                NEW.invcitem_id,
5712
 
                                COALESCE(_r.invchead_taxzone_id, -1),
5713
 
                                NEW.invcitem_taxtype_id,
5714
 
                                COALESCE(_r.invchead_invcdate, CURRENT_DATE),
5715
 
                                COALESCE(_r.invchead_curr_id, -1),
5716
 
                                (NEW.invcitem_billed * NEW.invcitem_qty_invuomratio) *
5717
 
                                (NEW.invcitem_price / NEW.invcitem_price_invuomratio) );
5718
 
  END IF;
5719
 
 
5720
 
  IF (TG_OP = 'UPDATE') THEN
5721
 
 
5722
 
  -- Calculate Tax
5723
 
    IF ( (NEW.invcitem_billed <> OLD.invcitem_billed) OR
5724
 
         (NEW.invcitem_qty_invuomratio <> OLD.invcitem_qty_invuomratio) OR
5725
 
         (NEW.invcitem_price <> OLD.invcitem_price) OR
5726
 
         (NEW.invcitem_price_invuomratio <> OLD.invcitem_price_invuomratio) OR
5727
 
         (COALESCE(NEW.invcitem_taxtype_id, -1) <> COALESCE(OLD.invcitem_taxtype_id, -1)) ) THEN
5728
 
      PERFORM calculateTaxHist( 'invcitemtax',
5729
 
                                NEW.invcitem_id,
5730
 
                                COALESCE(_r.invchead_taxzone_id, -1),
5731
 
                                NEW.invcitem_taxtype_id,
5732
 
                                COALESCE(_r.invchead_invcdate, CURRENT_DATE),
5733
 
                                COALESCE(_r.invchead_curr_id, -1),
5734
 
                                (NEW.invcitem_billed * NEW.invcitem_qty_invuomratio) *
5735
 
                                (NEW.invcitem_price / NEW.invcitem_price_invuomratio) );
5736
 
    END IF;
5737
 
  END IF;
5738
 
 
5739
 
  RETURN NEW;
5740
 
END;
5741
 
$$;
5742
 
 
5743
 
 
5744
 
ALTER FUNCTION public._invcitemtrigger() OWNER TO admin;
5745
 
 
5746
 
--
5747
 
--
5748
 
 
5749
 
CREATE FUNCTION _ipsassbeforetrigger() RETURNS trigger
5750
 
    LANGUAGE plpgsql
5751
 
    AS $$
5752
 
BEGIN
5753
 
 
5754
 
  --  Checks
5755
 
  IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN
5756
 
    RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.';
5757
 
  END IF;
5758
 
 
5759
 
  -- Business logic, disallow invalid combinations
5760
 
  IF (TG_OP IN ('INSERT','UPDATE')) THEN
5761
 
    IF (LENGTH(COALESCE(NEW.ipsass_custtype_pattern,'')) != 0) THEN
5762
 
      new.ipsass_cust_id                =       -1;
5763
 
      new.ipsass_custtype_id            =       -1;
5764
 
      new.ipsass_shipto_id              =       -1;
5765
 
      new.ipsass_shipto_pattern =       '';
5766
 
    ELSIF (COALESCE(NEW.ipsass_custtype_id,-1) > -1) THEN
5767
 
      new.ipsass_cust_id                =       -1;
5768
 
      new.ipsass_shipto_id              =       -1;
5769
 
      new.ipsass_shipto_pattern =       '';
5770
 
      new.ipsass_custtype_pattern       =       '';
5771
 
    ELSIF (LENGTH(COALESCE(NEW.ipsass_shipto_pattern,'')) != 0) THEN
5772
 
      new.ipsass_custtype_id            =       -1;
5773
 
      new.ipsass_shipto_id              =       -1;
5774
 
      new.ipsass_custtype_pattern       =       '';
5775
 
    ELSE
5776
 
      new.ipsass_shipto_id              =       COALESCE(NEW.ipsass_shipto_id,-1);
5777
 
      new.ipsass_custtype_id            =       -1;
5778
 
      new.ipsass_shipto_pattern =       '';
5779
 
      new.ipsass_custtype_pattern       =       '';
5780
 
    END IF;
5781
 
 
5782
 
    RETURN NEW;
5783
 
  ELSE
5784
 
    RETURN OLD;
5785
 
  END IF;
5786
 
  
5787
 
END;
5788
 
$$;
5789
 
 
5790
 
 
5791
 
ALTER FUNCTION public._ipsassbeforetrigger() OWNER TO admin;
5792
 
 
5793
 
--
5794
 
--
5795
 
 
5796
 
CREATE FUNCTION _ipsheadbeforetrigger() RETURNS trigger
5797
 
    LANGUAGE plpgsql
5798
 
    AS $$
5799
 
BEGIN
5800
 
 
5801
 
  --  Checks
5802
 
  IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN
5803
 
    RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.';
5804
 
  END IF;
5805
 
 
5806
 
  IF (TG_OP IN ('INSERT','UPDATE')) THEN
5807
 
    RETURN NEW;
5808
 
  ELSE
5809
 
    RETURN OLD;
5810
 
  END IF;
5811
 
END;
5812
 
$$;
5813
 
 
5814
 
 
5815
 
ALTER FUNCTION public._ipsheadbeforetrigger() OWNER TO admin;
5816
 
 
5817
 
--
5818
 
--
5819
 
 
5820
 
CREATE FUNCTION _ipsitemcharbeforetrigger() RETURNS trigger
5821
 
    LANGUAGE plpgsql
5822
 
    AS $$
5823
 
BEGIN
5824
 
 
5825
 
  --  Checks
5826
 
  IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN
5827
 
    RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.';
5828
 
  END IF;
5829
 
  
5830
 
  IF (TG_OP IN ('INSERT','UPDATE')) THEN
5831
 
    IF (SELECT (COUNT(item_id)=0)
5832
 
        FROM ipsiteminfo JOIN item ON (item_id=ipsitem_item_id) 
5833
 
        WHERE ((ipsitem_id=NEW.ipsitemchar_ipsitem_id)
5834
 
        AND (item_config))) THEN
5835
 
      RAISE EXCEPTION 'Characteristic prices may only be set on configured items.';
5836
 
    ELSIF (SELECT (COUNT(item_id)=0)
5837
 
        FROM ipsiteminfo JOIN item ON (item_id=ipsitem_item_id)
5838
 
                         JOIN charass ON (charass_target_id=item_id AND charass_target_type='I') 
5839
 
        WHERE ((ipsitem_id=NEW.ipsitemchar_ipsitem_id)
5840
 
        AND (charass_char_id=NEW.ipsitemchar_char_id)
5841
 
        AND (charass_value=NEW.ipsitemchar_value))) THEN
5842
 
      RAISE EXCEPTION 'No characteristic with matching value exists for this item.';
5843
 
    END IF;
5844
 
    RETURN NEW;
5845
 
  ELSE
5846
 
    RETURN OLD;
5847
 
  END IF;
5848
 
END;
5849
 
$$;
5850
 
 
5851
 
 
5852
 
ALTER FUNCTION public._ipsitemcharbeforetrigger() OWNER TO admin;
5853
 
 
5854
 
--
5855
 
--
5856
 
 
5857
 
CREATE FUNCTION _ipsiteminfobeforetrigger() RETURNS trigger
5858
 
    LANGUAGE plpgsql
5859
 
    AS $$
5860
 
BEGIN
5861
 
 
5862
 
  --  Checks
5863
 
  IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN
5864
 
    RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.';
5865
 
  END IF;
5866
 
  
5867
 
  IF (TG_OP IN ('INSERT','UPDATE')) THEN
5868
 
    RETURN NEW;
5869
 
  ELSE
5870
 
    RETURN OLD;
5871
 
  END IF;
5872
 
END;
5873
 
$$;
5874
 
 
5875
 
 
5876
 
ALTER FUNCTION public._ipsiteminfobeforetrigger() OWNER TO admin;
5877
 
 
5878
 
--
5879
 
--
5880
 
 
5881
 
CREATE FUNCTION _itemaftertrigger() RETURNS trigger
5882
 
    LANGUAGE plpgsql
5883
 
    AS $$
5884
 
DECLARE
5885
 
  _cmnttypeid INTEGER;
5886
 
 
5887
 
BEGIN
5888
 
   IF (NOT checkPrivilege('MaintainItemMasters')) THEN
5889
 
     RAISE EXCEPTION 'You do not have privileges to maintain Items.';
5890
 
   END IF;
5891
 
 
5892
 
  IF (TG_OP = 'UPDATE') THEN
5893
 
    IF ((OLD.item_type <> NEW.item_type) AND (NEW.item_type = 'L')) THEN
5894
 
      IF (SELECT COUNT(*) != 0 FROM bomitem WHERE (bomitem_item_id = OLD.item_id)) THEN
5895
 
        RAISE EXCEPTION 'This item is part of one or more Bills of Materials and cannot be a Planning Item.';
5896
 
      END IF;
5897
 
    END IF;
5898
 
 
5899
 
    IF ((OLD.item_type <> NEW.item_type) AND
5900
 
       (NEW.item_type IN ('R','S','T'))) THEN
5901
 
      IF (SELECT COUNT(*) != 0
5902
 
        FROM itemsite
5903
 
        WHERE ((itemsite_item_id=OLD.item_id)
5904
 
        AND (itemsite_qtyonhand + qtyallocated(itemsite_id,startoftime(),endoftime()) +
5905
 
           qtyordered(itemsite_id,startoftime(),endoftime()) > 0 ))) THEN
5906
 
          RAISE EXCEPTION 'Item type not allowed when there are itemsites with quantities with on hand quantities or pending inventory activity for this item.';
5907
 
      END IF;
5908
 
    END IF;
5909
 
    IF (NEW.item_type <> OLD.item_type) THEN
5910
 
      PERFORM updateCost(itemcost_id, 0) FROM itemcost WHERE (itemcost_item_id=OLD.item_id);
5911
 
      UPDATE itemsite SET itemsite_active=false WHERE (itemsite_item_id=OLD.item_id);
5912
 
      IF (NEW.item_type = 'R') THEN
5913
 
        UPDATE itemsite SET itemsite_controlmethod='N' WHERE (itemsite_item_id=OLD.item_id);
5914
 
      END IF;
5915
 
    END IF;
5916
 
  END IF;
5917
 
 
5918
 
  IF ( SELECT (metric_value='t')
5919
 
       FROM metric
5920
 
       WHERE (metric_name='ItemChangeLog') ) THEN
5921
 
 
5922
 
    SELECT cmnttype_id INTO _cmnttypeid
5923
 
    FROM cmnttype
5924
 
    WHERE (cmnttype_name='ChangeLog');
5925
 
    IF (FOUND) THEN
5926
 
      IF (TG_OP = 'INSERT') THEN
5927
 
        PERFORM postComment(_cmnttypeid, 'I', NEW.item_id, 'Created');
5928
 
 
5929
 
      ELSIF (TG_OP = 'UPDATE') THEN
5930
 
        IF (OLD.item_active <> NEW.item_active) THEN
5931
 
          IF (NEW.item_active) THEN
5932
 
            PERFORM postComment(_cmnttypeid, 'I', NEW.item_id, 'Activated');
5933
 
          ELSE
5934
 
            PERFORM postComment(_cmnttypeid, 'I', NEW.item_id, 'Deactivated');
5935
 
          END IF;
5936
 
        END IF;
5937
 
 
5938
 
        IF (OLD.item_descrip1 <> NEW.item_descrip1) THEN
5939
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
5940
 
                               ( 'Description 1 Changed from "' || OLD.item_descrip1 ||
5941
 
                                 '" to "' || NEW.item_descrip1 || '"' ) );
5942
 
        END IF;
5943
 
 
5944
 
        IF (OLD.item_descrip2 <> NEW.item_descrip2) THEN
5945
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
5946
 
                               ( 'Description 2 Changed from "' || OLD.item_descrip2 ||
5947
 
                                 '" to "' || NEW.item_descrip2 || '"' ) );
5948
 
        END IF;
5949
 
 
5950
 
        IF (OLD.item_inv_uom_id <> NEW.item_inv_uom_id) THEN
5951
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
5952
 
                               ( 'Inventory UOM Changed from "' ||
5953
 
                                 (SELECT uom_name FROM uom WHERE uom_id=OLD.item_inv_uom_id) ||
5954
 
                                 '" (' || CAST(OLD.item_inv_uom_id AS TEXT) ||
5955
 
                                 ') to "' ||
5956
 
                                 (SELECT uom_name FROM uom WHERE uom_id=NEW.item_inv_uom_id) ||
5957
 
                                 '" (' || CAST(NEW.item_inv_uom_id AS TEXT) || ')' ) );
5958
 
        END IF;
5959
 
 
5960
 
        IF (OLD.item_sold <> NEW.item_sold) THEN
5961
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
5962
 
                               CASE WHEN (NEW.item_sold) THEN 'Sold Changed from FALSE to TRUE'
5963
 
                                    ELSE 'Sold Changed from TRUE to FALSE'
5964
 
                               END );
5965
 
        END IF;
5966
 
 
5967
 
        IF (OLD.item_picklist <> NEW.item_picklist) THEN
5968
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
5969
 
                               CASE WHEN (NEW.item_picklist) THEN 'Pick List Changed from FALSE to TRUE'
5970
 
                                    ELSE 'Pick List Changed from TRUE to FALSE'
5971
 
                               END );
5972
 
        END IF;
5973
 
 
5974
 
        IF (OLD.item_fractional <> NEW.item_fractional) THEN
5975
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
5976
 
                               CASE WHEN (NEW.item_fractional) THEN 'Fractional Changed from FALSE to TRUE'
5977
 
                                    ELSE 'Fractional Changed from TRUE to FALSE'
5978
 
                               END );
5979
 
        END IF;
5980
 
 
5981
 
        IF (OLD.item_exclusive <> NEW.item_exclusive) THEN
5982
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
5983
 
                               CASE WHEN (NEW.item_exclusive) THEN 'Exclusive Changed from FALSE to TRUE'
5984
 
                                    ELSE 'Exclusive Changed from TRUE to FALSE'
5985
 
                               END );
5986
 
        END IF;
5987
 
        IF (OLD.item_config <> NEW.item_config) THEN
5988
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
5989
 
                               CASE WHEN (NEW.item_config) THEN 'Configured Changed from FALSE to TRUE'
5990
 
                                    ELSE 'Configured Changed from TRUE to FALSE'
5991
 
                               END );
5992
 
        END IF;
5993
 
 
5994
 
        IF (OLD.item_listprice <> NEW.item_listprice) THEN
5995
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
5996
 
                               ( 'List Price Changed from "' || formatSalesPrice(OLD.item_listprice) ||
5997
 
                                 '" to "' || formatSalesPrice(NEW.item_listprice) || '"' ) );
5998
 
        END IF;
5999
 
 
6000
 
 
6001
 
        IF (OLD.item_type <> NEW.item_type) THEN
6002
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
6003
 
                               ( 'Type Changed from "' || OLD.item_type ||
6004
 
                                 '" to "' || NEW.item_type || '"' ) );
6005
 
        END IF;
6006
 
 
6007
 
        IF (OLD.item_price_uom_id <> NEW.item_price_uom_id) THEN
6008
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
6009
 
                               ( 'Price UOM Changed from "' ||
6010
 
                                 (SELECT uom_name FROM uom WHERE uom_id=OLD.item_price_uom_id) ||
6011
 
                                 '" (' || CAST(OLD.item_price_uom_id AS TEXT) ||
6012
 
                                 ') to "' ||
6013
 
                                 (SELECT uom_name FROM uom WHERE uom_id=NEW.item_price_uom_id) ||
6014
 
                                 '" (' || CAST(NEW.item_price_uom_id AS TEXT) || ')' ) );
6015
 
        END IF;
6016
 
 
6017
 
        IF (OLD.item_classcode_id <> NEW.item_classcode_id) THEN
6018
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
6019
 
                               ( 'Class Code Changed from "' ||
6020
 
                                 (SELECT classcode_code || '-' || classcode_descrip FROM classcode WHERE classcode_id=OLD.item_classcode_id) ||
6021
 
                                 '" (' || CAST(OLD.item_classcode_id AS TEXT) ||
6022
 
                                 ') to "' ||
6023
 
                                 (SELECT classcode_code || '-' || classcode_descrip FROM classcode WHERE classcode_id=NEW.item_classcode_id) ||
6024
 
                                 '" (' || CAST(NEW.item_classcode_id AS TEXT) || ')' ) );
6025
 
        END IF;
6026
 
 
6027
 
        IF (OLD.item_freightclass_id <> NEW.item_freightclass_id) THEN
6028
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
6029
 
                               ( 'Freight Class Changed from "' ||
6030
 
                                 (SELECT freightclass_code || '-' || freightclass_descrip FROM freightclass WHERE freightclass_id=OLD.item_freightclass_id) ||
6031
 
                                 '" (' || CAST(OLD.item_freightclass_id AS TEXT) ||
6032
 
                                 ') to "' ||
6033
 
                                 (SELECT freightclass_code || '-' || freightclass_descrip FROM freightclass WHERE freightclass_id=NEW.item_freightclass_id) ||
6034
 
                                 '" (' || CAST(NEW.item_freightclass_id AS TEXT) || ')' ) );
6035
 
        END IF;
6036
 
 
6037
 
        IF (OLD.item_prodcat_id <> NEW.item_prodcat_id) THEN
6038
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
6039
 
                               ( 'Product Category Changed from "' ||
6040
 
                                 (SELECT prodcat_code || '-' || prodcat_descrip FROM prodcat WHERE prodcat_id=OLD.item_prodcat_id) ||
6041
 
                                 '" (' || CAST(OLD.item_prodcat_id AS TEXT) ||
6042
 
                                 ') to "' ||
6043
 
                                 (SELECT prodcat_code || '-' || prodcat_descrip FROM prodcat WHERE prodcat_id=NEW.item_prodcat_id) ||
6044
 
                                 '" (' || CAST(NEW.item_prodcat_id AS TEXT) || ')' ) );
6045
 
        END IF;
6046
 
 
6047
 
        IF (OLD.item_upccode <> NEW.item_upccode) THEN
6048
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
6049
 
                               ( 'UPC Code Changed from "' || OLD.item_upccode ||
6050
 
                                 '" to "' || NEW.item_upccode || '"' ) );
6051
 
        END IF;
6052
 
 
6053
 
        IF (OLD.item_prodweight <> NEW.item_prodweight) THEN
6054
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
6055
 
                               ( 'Product Weight Changed from "' || formatWeight(OLD.item_prodweight) ||
6056
 
                                 '" to "' || formatWeight(NEW.item_prodweight) || '"' ) );
6057
 
        END IF;
6058
 
 
6059
 
        IF (OLD.item_packweight <> NEW.item_packweight) THEN
6060
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
6061
 
                               ( 'Packaging Weight Changed from "' || formatWeight(OLD.item_packweight) ||
6062
 
                                 '" to "' || formatWeight(NEW.item_packweight) || '"' ) );
6063
 
        END IF;
6064
 
 
6065
 
        IF (OLD.item_maxcost <> NEW.item_maxcost) THEN
6066
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
6067
 
                               ( 'Maximum Desired Cost Changed from "' || formatCost(OLD.item_maxcost) ||
6068
 
                                 '" to "' || formatCost(NEW.item_maxcost) || '"' ) );
6069
 
        END IF;
6070
 
 
6071
 
        IF (OLD.item_listcost <> NEW.item_listcost) THEN
6072
 
          PERFORM postComment( _cmnttypeid, 'I', NEW.item_id,
6073
 
                               ( 'List Cost Changed from "' || formatCost(OLD.item_listcost) ||
6074
 
                                 '" to "' || formatCost(NEW.item_listcost) || '"' ) );
6075
 
        END IF;
6076
 
 
6077
 
      END IF;
6078
 
    END IF;
6079
 
  END IF;
6080
 
 
6081
 
  IF (TG_OP = 'DELETE') THEN
6082
 
    DELETE FROM imageass WHERE ((imageass_source_id=OLD.item_id) AND (imageass_source='I'));
6083
 
    DELETE FROM url WHERE ((url_source_id=OLD.item_id) AND (url_source='I'));
6084
 
    DELETE FROM docass WHERE docass_source_id = OLD.item_id AND docass_source_type = 'I';
6085
 
    DELETE FROM docass WHERE docass_target_id = OLD.item_id AND docass_target_type = 'I';
6086
 
 
6087
 
    RETURN OLD;
6088
 
  END IF;
6089
 
 
6090
 
  RETURN NEW;
6091
 
 
6092
 
END;
6093
 
$$;
6094
 
 
6095
 
 
6096
 
ALTER FUNCTION public._itemaftertrigger() OWNER TO admin;
6097
 
 
6098
 
--
6099
 
--
6100
 
 
6101
 
CREATE FUNCTION _itemaliastrigger() RETURNS trigger
6102
 
    LANGUAGE plpgsql
6103
 
    AS $$
6104
 
BEGIN
6105
 
 
6106
 
   IF (NOT checkPrivilege('MaintainItemMasters')) THEN
6107
 
     RAISE EXCEPTION 'You do not have privileges to maintain Item Aliases.';
6108
 
   END IF;
6109
 
  
6110
 
  RETURN NEW;
6111
 
END;
6112
 
$$;
6113
 
 
6114
 
 
6115
 
ALTER FUNCTION public._itemaliastrigger() OWNER TO admin;
6116
 
 
6117
 
--
6118
 
--
6119
 
 
6120
 
CREATE FUNCTION _itemcostaftertrigger() RETURNS trigger
6121
 
    LANGUAGE plpgsql
6122
 
    AS $$
6123
 
DECLARE
6124
 
  _itemNumber TEXT;
6125
 
  _maxCost NUMERIC;
6126
 
  _oldStdCost NUMERIC;
6127
 
  _oldActCost NUMERIC;
6128
 
  _actualCost NUMERIC;
6129
 
  _standardCost NUMERIC;
6130
 
 
6131
 
BEGIN
6132
 
 
6133
 
 
6134
 
IF NOT EXISTS(SELECT 1
6135
 
     FROM evntnot
6136
 
       JOIN evnttype ON (evnttype_id = evntnot_evnttype_id)
6137
 
       JOIN usrpref ON (evntnot_username = usrpref_username)
6138
 
     WHERE
6139
 
          evnttype_name = 'CostExceedsMaxDesired'
6140
 
          AND usrpref_name = 'active'
6141
 
          AND usrpref_value = 't')
6142
 
   THEN
6143
 
     RETURN NEW;
6144
 
END IF;
6145
 
 
6146
 
  SELECT item_number, item_maxcost, actcost(item_id), stdcost(item_id) INTO _itemNumber, _maxCost, _actualCost, _standardCost
6147
 
  FROM item
6148
 
  WHERE (item_id=NEW.itemcost_item_id);
6149
 
 
6150
 
  IF (_maxCost > 0.0) THEN
6151
 
   -- IF (_standardCost > _maxCost)
6152
 
      IF NOT EXISTS(SELECT 1 --COUNT(evntlog_id)
6153
 
                    FROM
6154
 
                      evntlog, evnttype
6155
 
                      WHERE evntlog_evnttype_id = evnttype_id
6156
 
                      AND evntlog_number LIKE
6157
 
                          (_itemNumber || ' -Standard- New:' || '%')
6158
 
 
6159
 
                      AND (evntlog_dispatched IS NULL)
6160
 
                      AND CAST(evntlog_evnttime AS DATE) = current_date
6161
 
 
6162
 
                      )
6163
 
                      AND (_standardCost > _maxCost) THEN
6164
 
 
6165
 
 
6166
 
      IF (TG_OP = 'INSERT') THEN
6167
 
        _oldStdCost := 0;
6168
 
        _oldActCost := 0;
6169
 
      ELSE
6170
 
        _oldStdCost := OLD.itemcost_stdcost;
6171
 
        _oldActCost := OLD.itemcost_stdcost;
6172
 
      END IF;
6173
 
      PERFORM postEvent('CostExceedsMaxDesired', NULL, NEW.itemcost_item_id,
6174
 
                        itemsite_warehous_id,
6175
 
                        (_itemNumber || ' -Standard- ' ||
6176
 
                         'New: ' || formatCost(_standardCost) ||
6177
 
                         ' Max: '|| formatCost(_MaxCost)),
6178
 
                        NEW.itemcost_stdcost, _oldStdCost,
6179
 
                        NULL, NULL)
6180
 
      FROM itemsite
6181
 
      WHERE (itemsite_item_id=NEW.itemcost_item_id);
6182
 
    END IF;
6183
 
       IF NOT EXISTS(
6184
 
                     SELECT 1 FROM
6185
 
                      evntlog, evnttype
6186
 
                      WHERE evntlog_evnttype_id = evnttype_id
6187
 
                      AND evntlog_number LIKE
6188
 
                          (_itemNumber || ' -Actual- New:' || '%')
6189
 
 
6190
 
                      AND (evntlog_dispatched IS NULL)
6191
 
                      AND CAST(evntlog_evnttime AS DATE) = current_date
6192
 
                      )
6193
 
 
6194
 
                 AND  (_actualCost > _maxCost)
6195
 
          THEN
6196
 
 
6197
 
      PERFORM postEvent('CostExceedsMaxDesired', NULL, NEW.itemcost_item_id,
6198
 
                        itemsite_warehous_id,
6199
 
                        (_itemNumber || ' -Actual- ' ||
6200
 
                         'New: ' || formatCost(_actualCost) ||
6201
 
                         ' Max: '|| formatCost(_MaxCost)),
6202
 
                        NEW.itemcost_actcost, _oldActCost,
6203
 
                        NULL, NULL)
6204
 
      FROM itemsite
6205
 
      WHERE (itemsite_item_id=NEW.itemcost_item_id);
6206
 
    END IF;
6207
 
  END IF;
6208
 
 
6209
 
  RETURN NEW;
6210
 
 
6211
 
END;
6212
 
$$;
6213
 
 
6214
 
 
6215
 
ALTER FUNCTION public._itemcostaftertrigger() OWNER TO admin;
6216
 
 
6217
 
--
6218
 
--
6219
 
 
6220
 
CREATE FUNCTION _itemcosttrigger() RETURNS trigger
6221
 
    LANGUAGE plpgsql
6222
 
    AS $$
6223
 
BEGIN
6224
 
 
6225
 
  --Privilege Checks
6226
 
  IF ( (TG_OP = 'INSERT') AND (NOT checkPrivilege('CreateCosts')) AND (NOT checkPrivilege('PostVouchers')) ) THEN
6227
 
    RAISE EXCEPTION 'You do not have privileges to enter Item Costs.';
6228
 
  END IF;
6229
 
 
6230
 
  IF ( (TG_OP = 'UPDATE') AND (NOT checkPrivilege('EnterActualCosts')) AND (NOT checkPrivilege('PostVouchers')) AND (NOT checkPrivilege('UpdateActualCosts')) AND (NOT checkPrivilege('PostActualCosts')) AND (NOT checkPrivilege('PostStandardCosts')) ) THEN
6231
 
    RAISE EXCEPTION 'You do not have privileges to update Item Costs.';
6232
 
  END IF;
6233
 
 
6234
 
  IF ( (TG_OP = 'DELETE') AND (NOT checkPrivilege('DeleteCosts')) ) THEN
6235
 
    RAISE EXCEPTION 'You do not have privileges to delete Item Costs.';
6236
 
  END IF;
6237
 
 
6238
 
  IF (TG_OP = 'UPDATE') THEN
6239
 
    IF (NEW.itemcost_actcost <> OLD.itemcost_actcost OR
6240
 
        NEW.itemcost_curr_id <> OLD.itemcost_curr_id) THEN
6241
 
      INSERT INTO costhist
6242
 
      ( costhist_item_id, costhist_costelem_id, costhist_type,
6243
 
        costhist_lowlevel, costhist_username, costhist_date,
6244
 
        costhist_oldcost, costhist_newcost,
6245
 
        costhist_oldcurr_id, costhist_newcurr_id )
6246
 
      VALUES
6247
 
      ( NEW.itemcost_item_id, NEW.itemcost_costelem_id, 'A',
6248
 
        NEW.itemcost_lowlevel, getEffectiveXtUser(), CURRENT_TIMESTAMP,
6249
 
        OLD.itemcost_actcost, NEW.itemcost_actcost,
6250
 
        OLD.itemcost_curr_id, NEW.itemcost_curr_id );
6251
 
    END IF;
6252
 
 
6253
 
    IF (NEW.itemcost_stdcost <> OLD.itemcost_stdcost) THEN
6254
 
      INSERT INTO costhist
6255
 
      ( costhist_item_id, costhist_costelem_id, costhist_type,
6256
 
        costhist_lowlevel, costhist_username, costhist_date,
6257
 
        costhist_oldcost, costhist_newcost,
6258
 
        costhist_oldcurr_id, costhist_newcurr_id )
6259
 
      VALUES
6260
 
      ( NEW.itemcost_item_id, NEW.itemcost_costelem_id, 'S',
6261
 
        NEW.itemcost_lowlevel, getEffectiveXtUser(), CURRENT_TIMESTAMP,
6262
 
        OLD.itemcost_stdcost, NEW.itemcost_stdcost,
6263
 
        baseCurrId(), baseCurrId() );
6264
 
    END IF;
6265
 
 
6266
 
    RETURN NEW;
6267
 
 
6268
 
  ELSIF (TG_OP = 'INSERT') THEN
6269
 
    INSERT INTO costhist
6270
 
    ( costhist_item_id, costhist_costelem_id, costhist_type,
6271
 
      costhist_lowlevel, costhist_username, costhist_date,
6272
 
      costhist_oldcost, costhist_newcost,
6273
 
      costhist_oldcurr_id, costhist_newcurr_id )
6274
 
    VALUES
6275
 
    ( NEW.itemcost_item_id, NEW.itemcost_costelem_id, 'N',
6276
 
      NEW.itemcost_lowlevel, getEffectiveXtUser(), CURRENT_TIMESTAMP,
6277
 
      0, NEW.itemcost_actcost,
6278
 
      baseCurrId(), NEW.itemcost_curr_id );
6279
 
 
6280
 
    RETURN NEW;
6281
 
 
6282
 
  ELSIF (TG_OP = 'DELETE') THEN
6283
 
    INSERT INTO costhist
6284
 
    ( costhist_item_id, costhist_costelem_id, costhist_type,
6285
 
      costhist_lowlevel, costhist_username, costhist_date,
6286
 
      costhist_oldcost, costhist_newcost,
6287
 
      costhist_oldcurr_id, costhist_newcurr_id )
6288
 
    VALUES
6289
 
    ( OLD.itemcost_item_id, OLD.itemcost_costelem_id, 'D',
6290
 
      OLD.itemcost_lowlevel, getEffectiveXtUser(), CURRENT_TIMESTAMP,
6291
 
      OLD.itemcost_stdcost, 0,
6292
 
      OLD.itemcost_curr_id, baseCurrId() );
6293
 
 
6294
 
    RETURN OLD;
6295
 
  END IF;
6296
 
 
6297
 
END;
6298
 
$$;
6299
 
 
6300
 
 
6301
 
ALTER FUNCTION public._itemcosttrigger() OWNER TO admin;
6302
 
 
6303
 
--
6304
 
--
6305
 
 
6306
 
CREATE FUNCTION _itemsiteaftertrigger() RETURNS trigger
6307
 
    LANGUAGE plpgsql
6308
 
    AS $$
6309
 
DECLARE
6310
 
  _state INTEGER;
6311
 
  _wasLocationControl BOOLEAN;
6312
 
  _isLocationControl BOOLEAN;
6313
 
  _wasLotSerial BOOLEAN;
6314
 
  _isLotSerial BOOLEAN;
6315
 
  _wasPerishable BOOLEAN;
6316
 
  _isPerishable BOOLEAN;
6317
 
  _qty NUMERIC;
6318
 
  _maint BOOLEAN;
6319
 
  _cost NUMERIC;
6320
 
  _variance NUMERIC;
6321
 
  _application TEXT;
6322
 
 
6323
 
BEGIN
6324
 
  SELECT fetchMetricText('Application') INTO _application;
6325
 
 
6326
 
  IF (TG_OP = 'INSERT') THEN
6327
 
    _maint := TRUE;
6328
 
  ELSIF (TG_OP = 'UPDATE') THEN
6329
 
    IF ((OLD.itemsite_item_id           != NEW.itemsite_item_id)
6330
 
     OR (OLD.itemsite_warehous_id       != NEW.itemsite_warehous_id)
6331
 
     OR (OLD.itemsite_reorderlevel      != NEW.itemsite_reorderlevel)
6332
 
     OR (OLD.itemsite_ordertoqty        != NEW.itemsite_ordertoqty)
6333
 
     OR (OLD.itemsite_cyclecountfreq    != NEW.itemsite_cyclecountfreq)
6334
 
     OR (OLD.itemsite_planning_type     != NEW.itemsite_planning_type)
6335
 
     OR (OLD.itemsite_posupply          != NEW.itemsite_posupply)
6336
 
     OR (OLD.itemsite_wosupply          != NEW.itemsite_wosupply)
6337
 
     OR (OLD.itemsite_loccntrl          != NEW.itemsite_loccntrl)
6338
 
     OR (OLD.itemsite_safetystock       != NEW.itemsite_safetystock)
6339
 
     OR (OLD.itemsite_minordqty         != NEW.itemsite_minordqty)
6340
 
     OR (OLD.itemsite_multordqty        != NEW.itemsite_multordqty)
6341
 
     OR (OLD.itemsite_leadtime          != NEW.itemsite_leadtime)
6342
 
     OR (OLD.itemsite_abcclass          != NEW.itemsite_abcclass)
6343
 
     OR (OLD.itemsite_controlmethod     != NEW.itemsite_controlmethod)
6344
 
     OR (OLD.itemsite_active            != NEW.itemsite_active)
6345
 
     OR (OLD.itemsite_plancode_id       != NEW.itemsite_plancode_id)
6346
 
     OR (OLD.itemsite_costcat_id        != NEW.itemsite_costcat_id)
6347
 
     OR (OLD.itemsite_eventfence        != NEW.itemsite_eventfence)
6348
 
     OR (OLD.itemsite_sold              != NEW.itemsite_sold)
6349
 
     OR (OLD.itemsite_stocked           != NEW.itemsite_stocked)
6350
 
     OR (OLD.itemsite_location_id       != NEW.itemsite_location_id)
6351
 
     OR (OLD.itemsite_recvlocation_id   != NEW.itemsite_recvlocation_id)
6352
 
     OR (OLD.itemsite_issuelocation_id  != NEW.itemsite_issuelocation_id)
6353
 
     OR (OLD.itemsite_location_dist     != NEW.itemsite_location_dist)
6354
 
     OR (OLD.itemsite_recvlocation_dist != NEW.itemsite_recvlocation_dist)
6355
 
     OR (OLD.itemsite_issuelocation_dist != NEW.itemsite_issuelocation_dist)
6356
 
     OR (OLD.itemsite_useparams         != NEW.itemsite_useparams)
6357
 
     OR (OLD.itemsite_useparamsmanual   != NEW.itemsite_useparamsmanual)
6358
 
     OR (OLD.itemsite_soldranking       != NEW.itemsite_soldranking)
6359
 
     OR (OLD.itemsite_createpr          != NEW.itemsite_createpr)
6360
 
     OR (OLD.itemsite_location          != NEW.itemsite_location)
6361
 
     OR (OLD.itemsite_location_comments != NEW.itemsite_location_comments)
6362
 
     OR (OLD.itemsite_notes             != NEW.itemsite_notes)
6363
 
     OR (OLD.itemsite_perishable        != NEW.itemsite_perishable)
6364
 
     OR (OLD.itemsite_autoabcclass      != NEW.itemsite_autoabcclass)
6365
 
     OR (OLD.itemsite_ordergroup        != NEW.itemsite_ordergroup)
6366
 
     OR (OLD.itemsite_disallowblankwip  != NEW.itemsite_disallowblankwip)
6367
 
     OR (OLD.itemsite_maxordqty         != NEW.itemsite_maxordqty)
6368
 
     OR (OLD.itemsite_mps_timefence     != NEW.itemsite_mps_timefence)
6369
 
     OR (OLD.itemsite_createwo          != NEW.itemsite_createwo)
6370
 
     OR (OLD.itemsite_warrpurc          != NEW.itemsite_warrpurc)
6371
 
     OR (OLD.itemsite_costmethod        != NEW.itemsite_costmethod)
6372
 
     OR (OLD.itemsite_autoreg           != NEW.itemsite_autoreg)
6373
 
     OR (OLD.itemsite_lsseq_id          != NEW.itemsite_lsseq_id) ) THEN
6374
 
      IF (OLD.itemsite_item_id != NEW.itemsite_item_id) THEN
6375
 
        RAISE EXCEPTION 'The item number on an itemsite may not be changed.';
6376
 
      ELSIF (OLD.itemsite_warehous_id != NEW.itemsite_warehous_id) THEN
6377
 
        RAISE EXCEPTION 'The warehouse code on an itemsite may not be changed.';
6378
 
      END IF;
6379
 
      _maint := TRUE;
6380
 
    END IF;
6381
 
  ELSE
6382
 
    _maint := FALSE;
6383
 
  END IF;
6384
 
 
6385
 
  IF (_maint) THEN -- Begin Maintenance
6386
 
    IF ( NOT checkPrivilege('MaintainItemSites') ) THEN
6387
 
       RAISE EXCEPTION 'You do not have privileges to maintain Item Sites.';
6388
 
    END IF;
6389
 
    
6390
 
    IF (NOT NEW.itemsite_posupply) THEN
6391
 
      UPDATE itemsite SET
6392
 
        itemsite_createpr = FALSE
6393
 
      WHERE (itemsite_id=NEW.itemsite_id);
6394
 
    END IF;
6395
 
    IF (NOT NEW.itemsite_wosupply) THEN
6396
 
      UPDATE itemsite SET
6397
 
        itemsite_createwo = FALSE
6398
 
      WHERE (itemsite_id=NEW.itemsite_id);
6399
 
    END IF;
6400
 
 
6401
 
    IF (NEW.itemsite_controlmethod NOT IN ('S','L')) THEN
6402
 
      UPDATE itemsite SET
6403
 
        itemsite_perishable = FALSE,
6404
 
        itemsite_warrpurc = FALSE,
6405
 
        itemsite_autoreg = FALSE,
6406
 
        itemsite_lsseq_id = NULL
6407
 
      WHERE (itemsite_id=NEW.itemsite_id);
6408
 
    END IF;
6409
 
 
6410
 
    IF (NOT NEW.itemsite_loccntrl) THEN
6411
 
      UPDATE itemsite SET
6412
 
        itemsite_disallowblankwip = FALSE
6413
 
      WHERE (itemsite_id=NEW.itemsite_id);
6414
 
    END IF;
6415
 
 
6416
 
    IF (NOT NEW.itemsite_useparams) THEN
6417
 
      UPDATE itemsite SET
6418
 
        itemsite_reorderlevel    = 0,
6419
 
        itemsite_ordertoqty      = 0,
6420
 
        itemsite_minordqty       = 0,
6421
 
        itemsite_maxordqty       = 0,
6422
 
        itemsite_multordqty      = 0,
6423
 
        itemsite_useparamsmanual = FALSE
6424
 
      WHERE (itemsite_id = NEW.itemsite_id);
6425
 
    END IF;
6426
 
    
6427
 
 
6428
 
    -- Both insert and update
6429
 
    IF ( (NEW.itemsite_controlmethod IN ('S', 'L')) AND
6430
 
         (NEW.itemsite_location_dist OR NEW.itemsite_recvlocation_dist OR NEW.itemsite_issuelocation_dist) ) THEN
6431
 
      RAISE EXCEPTION 'You cannot auto-distribute Lot/Serial controlled Item Sites.';
6432
 
    END IF;
6433
 
 
6434
 
    IF (TG_OP = 'INSERT') THEN
6435
 
      -- Handle MLC logic
6436
 
      IF ( (NEW.itemsite_loccntrl) AND (NEW.itemsite_warehous_id IS NOT NULL) ) THEN
6437
 
        IF (SELECT count(*)=0
6438
 
            FROM location
6439
 
            WHERE ((location_warehous_id=NEW.itemsite_warehous_id)
6440
 
            AND ( (NOT location_restrict) OR
6441
 
                ( (location_restrict) AND
6442
 
                (location_id IN ( SELECT locitem_location_id
6443
 
                                  FROM locitem
6444
 
                                  WHERE (locitem_item_id=NEW.itemsite_item_id) ) ) ) ))) THEN
6445
 
          RAISE EXCEPTION 'You must first create at least one valid
6446
 
                          Location for this Item Site before it may be
6447
 
                          multiply located.';
6448
 
        END IF;
6449
 
      END IF;
6450
 
 
6451
 
      --This could be made a table constraint later, but do not want to create a big problem
6452
 
      --for users with problematic legacy data over a relatively trivial problem for now,
6453
 
      --so we will just check moving forword.
6454
 
      IF (NEW.itemsite_stocked AND NEW.itemsite_reorderlevel<=0) THEN
6455
 
        RAISE EXCEPTION 'Stocked items must have postive reorder level specified.';
6456
 
      END IF;
6457
 
    END IF;
6458
 
 
6459
 
    IF (TG_OP = 'UPDATE') THEN
6460
 
      --This could be made a table constraint later, but do not want to create a big problem
6461
 
      --for users with problematic legacy data over a relatively trivial problem for now,
6462
 
      --so we will just check moving forword.
6463
 
      IF ((NEW.itemsite_stocked)
6464
 
        AND (NEW.itemsite_stocked != OLD.itemsite_stocked) --Avoid checking unless explicitly changed
6465
 
        AND (NEW.itemsite_reorderlevel<=0)) THEN
6466
 
        RAISE EXCEPTION 'Stocked items must have postive reorder level specified.';
6467
 
      END IF;
6468
 
    END IF;
6469
 
  
6470
 
    IF (TG_OP = 'UPDATE') THEN
6471
 
  
6472
 
      IF (NOT OLD.itemsite_loccntrl AND NEW.itemsite_loccntrl) THEN
6473
 
        IF (SELECT count(*)=0
6474
 
          FROM location
6475
 
          WHERE ((location_warehous_id=NEW.itemsite_warehous_id)
6476
 
          AND ( (NOT location_restrict) OR
6477
 
              ( (location_restrict) AND
6478
 
              (location_id IN ( SELECT locitem_location_id
6479
 
                                FROM locitem
6480
 
                                WHERE (locitem_item_id=NEW.itemsite_item_id) ) ) ) ))) THEN
6481
 
           RAISE EXCEPTION 'You must first create at least one valid
6482
 
                          Location for this Item Site before it may be
6483
 
                          multiply located.';
6484
 
        END IF;
6485
 
      END IF;
6486
 
   
6487
 
      _wasLocationControl := OLD.itemsite_loccntrl;
6488
 
      _isLocationControl := NEW.itemsite_loccntrl;
6489
 
      _wasLotSerial := OLD.itemsite_controlmethod IN ('S','L');
6490
 
      _isLotSerial := NEW.itemsite_controlmethod IN ('S','L'); 
6491
 
      _wasPerishable := OLD.itemsite_perishable;
6492
 
      _isPerishable := NEW.itemsite_perishable;
6493
 
      _state := 0;
6494
 
    
6495
 
      IF ( (_wasLocationControl) AND (_isLocationControl) ) THEN
6496
 
        _state := 10;
6497
 
      ELSIF ( (NOT _wasLocationControl) AND (NOT _isLocationControl) ) THEN
6498
 
        _state := 20;
6499
 
      ELSIF ( (NOT _wasLocationControl) AND (_isLocationControl) ) THEN
6500
 
        _state := 30;
6501
 
      ELSIF ( (_wasLocationControl) AND (NOT _isLocationControl) ) THEN
6502
 
        _state := 40;
6503
 
      END IF;
6504
 
 
6505
 
      IF ( (_wasLotSerial) AND (_isLotSerial) ) THEN
6506
 
        _state := _state + 1;
6507
 
      ELSIF ( (NOT _wasLotSerial) AND (NOT _isLotSerial) ) THEN
6508
 
        _state := _state + 2;
6509
 
      ELSIF ( (NOT _wasLotSerial) AND (_isLotSerial) ) THEN
6510
 
        _state := _state + 3;
6511
 
      ELSIF ( (_wasLotSerial) AND (NOT _isLotSerial) ) THEN
6512
 
        _state := _state + 4;
6513
 
      END IF;
6514
 
 
6515
 
      IF ( (_application = 'Standard') AND (_state IN (41, 43, 14, 34, 24, 42, 44)) ) THEN
6516
 
        -- Check for Reservations
6517
 
        IF (SELECT COUNT(*) > 0
6518
 
            FROM itemloc JOIN reserve ON (reserve_supply_id=itemloc_id AND reserve_supply_type='I')
6519
 
            WHERE (itemloc_itemsite_id=OLD.itemsite_id)) THEN
6520
 
          RAISE EXCEPTION 'Sales Order Reservations by Location exist for this Item Site';
6521
 
        END IF;
6522
 
      END IF;
6523
 
 
6524
 
      IF (_state IN (41, 43)) THEN
6525
 
        PERFORM consolidateLotSerial(OLD.itemsite_id);
6526
 
      ELSIF (_state IN (14, 34)) THEN
6527
 
        PERFORM consolidateLocations(OLD.itemsite_id);
6528
 
      ELSIF (_state IN (24, 42, 44)) THEN
6529
 
 
6530
 
        RAISE NOTICE 'Deleting item site detail records,';
6531
 
 
6532
 
        DELETE FROM itemloc
6533
 
        WHERE (itemloc_itemsite_id=OLD.itemsite_id);
6534
 
      END IF;
6535
 
 
6536
 
     IF (NEW.itemsite_qtyonhand != 0) THEN
6537
 
       IF (_state IN (23, 32, 33)) THEN
6538
 
          INSERT INTO itemloc 
6539
 
            ( itemloc_itemsite_id, itemloc_location_id,
6540
 
              itemloc_expiration, itemloc_qty )
6541
 
            VALUES
6542
 
            ( NEW.itemsite_id, -1,
6543
 
              endOfTime(), NEW.itemsite_qtyonhand );
6544
 
        END IF;
6545
 
 
6546
 
        IF (_state IN (31, 32, 33, 34)) THEN
6547
 
          IF (SELECT (COUNT(*)=1)
6548
 
              FROM location
6549
 
              WHERE ((location_id=NEW.itemsite_location_id)
6550
 
              AND (location_warehous_id=NEW.itemsite_warehous_id)
6551
 
              AND ( (NOT location_restrict) OR
6552
 
                  ( (location_restrict) AND
6553
 
                  (location_id IN ( SELECT locitem_location_id
6554
 
                                    FROM locitem
6555
 
                                    WHERE (locitem_item_id=NEW.itemsite_item_id) ) ) ) ))) THEN
6556
 
           PERFORM initialDistribution(NEW.itemsite_id, NEW.itemsite_location_id);
6557
 
          ELSE
6558
 
            RAISE EXCEPTION 'A valid default location must be selected to distribute existing inventory to.';
6559
 
          END IF;
6560
 
        END IF;
6561
 
 
6562
 
        IF ( (_state = 13) OR (_state = 23) OR (_state = 33) OR (_state = 43) ) THEN
6563
 
          RAISE NOTICE 'You should now use the Reassign Lot/Serial # window to assign Lot/Serial #s.';
6564
 
        END IF;
6565
 
      END IF;  
6566
 
      IF (OLD.itemsite_costmethod='A' AND NEW.itemsite_costmethod='S') THEN
6567
 
        -- TODO: Average costing cost method change
6568
 
        SELECT stdcost(NEW.itemsite_item_id) * NEW.itemsite_qtyonhand
6569
 
          INTO _cost;
6570
 
        _variance := _cost - NEW.itemsite_value;
6571
 
        NEW.itemsite_value := _cost;
6572
 
        IF(_variance <> 0.0) THEN
6573
 
          PERFORM insertGLTransaction( 'P/D', '', '', 'Itemsite converted from Average to Standard cost.',
6574
 
                                       costcat_invcost_accnt_id, costcat_asset_accnt_id, NEW.itemsite_id,
6575
 
                                      _variance, CURRENT_DATE )
6576
 
             FROM costcat
6577
 
            WHERE(costcat_id=NEW.itemsite_costcat_id);
6578
 
          UPDATE itemsite SET itemsite_value = _cost WHERE (itemsite_id = NEW.itemsite_id);
6579
 
        END IF;
6580
 
      END IF;
6581
 
    END IF;
6582
 
 
6583
 
    IF ( (_application = 'Standard') AND (_wasPerishable) AND (NOT _isPerishable) ) THEN
6584
 
      UPDATE itemloc SET itemloc_expiration = endOfTime()
6585
 
      WHERE (itemloc_itemsite_id = OLD.itemsite_id);
6586
 
      PERFORM consolidateLotSerial(OLD.itemsite_id);
6587
 
    END IF;
6588
 
 
6589
 
    IF ( (_application = 'Standard') AND (TG_OP = 'UPDATE') ) THEN
6590
 
      IF (NEW.itemsite_planning_type = 'N' AND OLD.itemsite_planning_type <> 'N') THEN
6591
 
        PERFORM deletePlannedOrder(planord_id, TRUE)
6592
 
        FROM planord
6593
 
        WHERE (planord_itemsite_id=NEW.itemsite_id);
6594
 
      END IF;
6595
 
    END IF;
6596
 
    
6597
 
  END IF;  -- End Maintenance
6598
 
 
6599
 
  RETURN NEW;
6600
 
 
6601
 
END;
6602
 
$$;
6603
 
 
6604
 
 
6605
 
ALTER FUNCTION public._itemsiteaftertrigger() OWNER TO admin;
6606
 
 
6607
 
--
6608
 
--
6609
 
 
6610
 
CREATE FUNCTION _itemsitetrigger() RETURNS trigger
6611
 
    LANGUAGE plpgsql
6612
 
    AS $$
6613
 
DECLARE
6614
 
  _cmnttypeid INTEGER;
6615
 
  _r RECORD;
6616
 
 
6617
 
BEGIN
6618
 
 
6619
 
  -- Cache some information
6620
 
  -- Added item_number as part of feature request 21645
6621
 
  SELECT item_type, item_number INTO _r
6622
 
  FROM item
6623
 
  WHERE (item_id=NEW.itemsite_item_id);
6624
 
 
6625
 
  IF (_r.item_type IN ('J','R','S')) THEN
6626
 
    NEW.itemsite_planning_type := 'N';
6627
 
  END IF;
6628
 
 
6629
 
  IF (_r.item_type = 'L') THEN
6630
 
    NEW.itemsite_planning_type := 'S';
6631
 
  END IF;
6632
 
 
6633
 
  IF (TG_OP = 'UPDATE') THEN
6634
 
    IF ( (NEW.itemsite_qtyonhand <> OLD.itemsite_qtyonhand) ) THEN
6635
 
      IF (OLD.itemsite_freeze) THEN
6636
 
        NEW.itemsite_qtyonhand := OLD.itemsite_qtyonhand;
6637
 
      ELSE
6638
 
        NEW.itemsite_datelastused := CURRENT_DATE;
6639
 
      END IF;
6640
 
 
6641
 
      IF ( (NEW.itemsite_qtyonhand < 0) AND (OLD.itemsite_qtyonhand >= 0) AND (NEW.itemsite_eventfence > 0) ) THEN
6642
 
        PERFORM postEvent('QOHBelowZero', 'I', NEW.itemsite_id,
6643
 
                          warehous_id,
6644
 
                          (item_number || '/' || warehous_code),
6645
 
                          NULL, NULL, NULL, NULL)
6646
 
        FROM item, whsinfo
6647
 
        WHERE (item_id=NEW.itemsite_item_id)
6648
 
          AND (warehous_id=NEW.itemsite_warehous_id);
6649
 
      END IF;
6650
 
    END IF;
6651
 
    IF ( (NEW.itemsite_value <> OLD.itemsite_value) AND (OLD.itemsite_freeze) ) THEN
6652
 
      NEW.itemsite_value := OLD.itemsite_value;
6653
 
    END IF;
6654
 
  END IF;
6655
 
 
6656
 
  IF (NEW.itemsite_qtyonhand < 0 AND NEW.itemsite_costmethod = 'A') THEN
6657
 
    RAISE EXCEPTION 'Itemsite (%) is set to use average costing and is not allowed to have a negative quantity on hand.', 'ID: ' || NEW.itemsite_id || ', Item: ' || _r.item_number;
6658
 
  ELSIF (NEW.itemsite_value < 0 AND NEW.itemsite_costmethod = 'A') THEN
6659
 
    RAISE EXCEPTION 'This transaction results in a negative itemsite value.  Itemsite (%) is set to use average costing and is not allowed to have a negative value.', 'ID: ' || NEW.itemsite_id || ', Item: ' || _r.item_number;  END IF;
6660
 
 
6661
 
  IF ( SELECT (metric_value='t')
6662
 
       FROM metric
6663
 
       WHERE (metric_name='ItemSiteChangeLog') ) THEN
6664
 
 
6665
 
    SELECT cmnttype_id INTO _cmnttypeid
6666
 
    FROM cmnttype
6667
 
    WHERE (cmnttype_name='ChangeLog');
6668
 
    IF (FOUND) THEN
6669
 
      IF (TG_OP = 'INSERT') THEN
6670
 
        PERFORM postComment(_cmnttypeid, 'IS', NEW.itemsite_id, 'Created');
6671
 
 
6672
 
      ELSIF (TG_OP = 'UPDATE') THEN
6673
 
 
6674
 
        IF (OLD.itemsite_plancode_id <> NEW.itemsite_plancode_id) THEN
6675
 
          PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id,
6676
 
                               ( 'Planner Code Changed from "' || oldplancode.plancode_code ||
6677
 
                                 '" to "' || newplancode.plancode_code || '"' ) )
6678
 
          FROM plancode AS oldplancode, plancode AS newplancode
6679
 
          WHERE ( (oldplancode.plancode_id=OLD.itemsite_plancode_id)
6680
 
           AND (newplancode.plancode_id=NEW.itemsite_plancode_id) );
6681
 
        END IF;
6682
 
 
6683
 
        IF (NEW.itemsite_reorderlevel <> OLD.itemsite_reorderlevel) THEN
6684
 
          PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id,
6685
 
                               ( 'Reorder Level Changed from ' || formatQty(OLD.itemsite_reorderlevel) ||
6686
 
                                 ' to ' || formatQty(NEW.itemsite_reorderlevel ) ) );
6687
 
        END IF;
6688
 
 
6689
 
        IF (NEW.itemsite_ordertoqty <> OLD.itemsite_ordertoqty) THEN
6690
 
          PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id,
6691
 
                               ( 'Order Up To Changed from ' || formatQty(OLD.itemsite_ordertoqty) ||
6692
 
                                 ' to ' || formatQty(NEW.itemsite_ordertoqty ) ) );
6693
 
        END IF;
6694
 
 
6695
 
        IF (NEW.itemsite_leadtime <> OLD.itemsite_leadtime) THEN
6696
 
          PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id,
6697
 
                               ( 'Itemsite Leadtime Changed from ' || formatQty(OLD.itemsite_leadtime) ||
6698
 
                                 ' to ' || formatQty(NEW.itemsite_leadtime ) ) );
6699
 
        END IF;
6700
 
 
6701
 
        IF (NEW.itemsite_abcclass <> OLD.itemsite_abcclass) THEN
6702
 
          PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id,
6703
 
                               ( 'Itemsite ABC Class Changed from ' || COALESCE(OLD.itemsite_abcclass, 'None') ||
6704
 
                                 ' to ' || COALESCE(NEW.itemsite_abcclass,'None') ) );
6705
 
        END IF;
6706
 
 
6707
 
        IF (NEW.itemsite_controlmethod <> OLD.itemsite_controlmethod) THEN
6708
 
          PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id,
6709
 
                               ( 'Itemsite Control Method Changed from ' || COALESCE(OLD.itemsite_controlmethod,'None') ||
6710
 
                                 ' to ' || COALESCE(NEW.itemsite_controlmethod,'None') ) );
6711
 
        END IF;
6712
 
 
6713
 
        IF (OLD.itemsite_sold <> NEW.itemsite_sold) THEN
6714
 
          PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id,
6715
 
            CASE WHEN (NEW.itemsite_sold) THEN 'Sold Changed from FALSE to TRUE'
6716
 
                                          ELSE 'Sold Changed from TRUE to FALSE'
6717
 
            END );
6718
 
        END IF;
6719
 
 
6720
 
        IF (OLD.itemsite_active <> NEW.itemsite_active) THEN
6721
 
          IF (NEW.itemsite_active) THEN
6722
 
            PERFORM postComment(_cmnttypeid, 'IS', NEW.itemsite_id, 'Activated');
6723
 
          ELSE
6724
 
            PERFORM postComment(_cmnttypeid, 'IS', NEW.itemsite_id, 'Deactivated');
6725
 
          END IF;
6726
 
        END IF;
6727
 
 
6728
 
      END IF;
6729
 
    END IF;
6730
 
  END IF;
6731
 
 
6732
 
  RETURN NEW;
6733
 
 
6734
 
END;
6735
 
$$;
6736
 
 
6737
 
 
6738
 
ALTER FUNCTION public._itemsitetrigger() OWNER TO admin;
6739
 
 
6740
 
--
6741
 
--
6742
 
 
6743
 
CREATE FUNCTION _itemsrcaftertrigger() RETURNS trigger
6744
 
    LANGUAGE plpgsql
6745
 
    AS $$
6746
 
BEGIN
6747
 
 
6748
 
  IF (NOT checkPrivilege('MaintainItemSources')) THEN
6749
 
    RAISE EXCEPTION 'You do not have privileges to maintain Item Sources.';
6750
 
  END IF;
6751
 
 
6752
 
  IF (COALESCE(NEW.itemsrc_default, FALSE) = TRUE) THEN
6753
 
    UPDATE itemsrc SET itemsrc_default = FALSE
6754
 
    WHERE ( (itemsrc_item_id = NEW.itemsrc_item_id)
6755
 
      AND (itemsrc_id <> NEW.itemsrc_id) );
6756
 
  END IF;
6757
 
 
6758
 
  RETURN NEW;
6759
 
END;
6760
 
$$;
6761
 
 
6762
 
 
6763
 
ALTER FUNCTION public._itemsrcaftertrigger() OWNER TO admin;
6764
 
 
6765
 
--
6766
 
--
6767
 
 
6768
 
CREATE FUNCTION _itemsrcptrigger() RETURNS trigger
6769
 
    LANGUAGE plpgsql
6770
 
    AS $$
6771
 
BEGIN
6772
 
 
6773
 
   IF (NOT checkPrivilege('MaintainItemSources')) THEN
6774
 
     RAISE EXCEPTION 'You do not have privileges to maintain Item Sources.';
6775
 
   END IF;
6776
 
 
6777
 
   NEW.itemsrcp_curr_id := COALESCE(NEW.itemsrcp_curr_id,basecurrid());
6778
 
  
6779
 
  RETURN NEW;
6780
 
END;
6781
 
$$;
6782
 
 
6783
 
 
6784
 
ALTER FUNCTION public._itemsrcptrigger() OWNER TO admin;
6785
 
 
6786
 
--
6787
 
--
6788
 
 
6789
 
CREATE FUNCTION _itemsrctrigger() RETURNS trigger
6790
 
    LANGUAGE plpgsql
6791
 
    AS $$
6792
 
BEGIN
6793
 
 
6794
 
   IF (NOT checkPrivilege('MaintainItemSources')) THEN
6795
 
     RAISE EXCEPTION 'You do not have privileges to maintain Item Sources.';
6796
 
   END IF;
6797
 
 
6798
 
   NEW.itemsrc_invvendoruomratio        := COALESCE(NEW.itemsrc_invvendoruomratio,1);
6799
 
   NEW.itemsrc_minordqty                := COALESCE(NEW.itemsrc_minordqty,0);
6800
 
   NEW.itemsrc_multordqty               := COALESCE(NEW.itemsrc_multordqty,0);
6801
 
   NEW.itemsrc_active                   := COALESCE(NEW.itemsrc_active,true);
6802
 
   NEW.itemsrc_leadtime                 := COALESCE(NEW.itemsrc_leadtime,0);
6803
 
   NEW.itemsrc_ranking                  := COALESCE(NEW.itemsrc_ranking,1);
6804
 
  
6805
 
  RETURN NEW;
6806
 
END;
6807
 
$$;
6808
 
 
6809
 
 
6810
 
ALTER FUNCTION public._itemsrctrigger() OWNER TO admin;
6811
 
 
6812
 
--
6813
 
--
6814
 
 
6815
 
CREATE FUNCTION _itemsubtrigger() RETURNS trigger
6816
 
    LANGUAGE plpgsql
6817
 
    AS $$
6818
 
BEGIN
6819
 
 
6820
 
   IF (NOT checkPrivilege('MaintainItemMasters')) THEN
6821
 
     RAISE EXCEPTION 'You do not have privileges to maintain Item Substitutes.';
6822
 
   END IF;
6823
 
 
6824
 
  RETURN NEW;
6825
 
END;
6826
 
$$;
6827
 
 
6828
 
 
6829
 
ALTER FUNCTION public._itemsubtrigger() OWNER TO admin;
6830
 
 
6831
 
--
6832
 
--
6833
 
 
6834
 
CREATE FUNCTION _itemtaxtrigger() RETURNS trigger
6835
 
    LANGUAGE plpgsql
6836
 
    AS $$
6837
 
BEGIN
6838
 
 
6839
 
   IF (NOT checkPrivilege('MaintainItemMasters')) THEN
6840
 
     RAISE EXCEPTION 'You do not have privileges to maintain Items.';
6841
 
   END IF;
6842
 
 
6843
 
  RETURN NEW;
6844
 
END;
6845
 
$$;
6846
 
 
6847
 
 
6848
 
ALTER FUNCTION public._itemtaxtrigger() OWNER TO admin;
6849
 
 
6850
 
--
6851
 
--
6852
 
 
6853
 
CREATE FUNCTION _itemtrigger() RETURNS trigger
6854
 
    LANGUAGE plpgsql
6855
 
    AS $$
6856
 
BEGIN
6857
 
 
6858
 
  IF (NEW.item_type IN ('R','S','O','L','B')) THEN
6859
 
    NEW.item_picklist := FALSE;
6860
 
  END IF;
6861
 
 
6862
 
  IF (NEW.item_type IN ('F','S','O','L','B')) THEN
6863
 
    NEW.item_picklist := FALSE;
6864
 
    NEW.item_sold := FALSE;
6865
 
    NEW.item_prodcat_id := -1;
6866
 
    NEW.item_exclusive := false;
6867
 
    NEW.item_listprice := 0;
6868
 
    NEW.item_upccode := '';
6869
 
    NEW.item_prodweight := 0;
6870
 
    NEW.item_packweight := 0;
6871
 
  END IF;
6872
 
 
6873
 
  IF (NEW.item_type NOT IN ('M','R')) THEN
6874
 
    NEW.item_config := false;
6875
 
  END IF;
6876
 
 
6877
 
  RETURN NEW;
6878
 
 
6879
 
END;
6880
 
$$;
6881
 
 
6882
 
 
6883
 
ALTER FUNCTION public._itemtrigger() OWNER TO admin;
6884
 
 
6885
 
--
6886
 
--
6887
 
 
6888
 
CREATE FUNCTION _itemuomconvtrigger() RETURNS trigger
6889
 
    LANGUAGE plpgsql
6890
 
    AS $$
6891
 
BEGIN
6892
 
 
6893
 
   IF (NOT checkPrivilege('MaintainItemMasters')) THEN
6894
 
     RAISE EXCEPTION 'You do not have privileges to maintain Items.';
6895
 
   END IF;
6896
 
 
6897
 
  RETURN NEW;
6898
 
END;
6899
 
$$;
6900
 
 
6901
 
 
6902
 
ALTER FUNCTION public._itemuomconvtrigger() OWNER TO admin;
6903
 
 
6904
 
--
6905
 
--
6906
 
 
6907
 
CREATE FUNCTION _locationaftertrigger() RETURNS trigger
6908
 
    LANGUAGE plpgsql
6909
 
    AS $$
6910
 
DECLARE
6911
 
  _itemloc    RECORD;
6912
 
 
6913
 
BEGIN
6914
 
 
6915
 
  RETURN NEW;
6916
 
 
6917
 
END;
6918
 
$$;
6919
 
 
6920
 
 
6921
 
ALTER FUNCTION public._locationaftertrigger() OWNER TO admin;
6922
 
 
6923
 
--
6924
 
--
6925
 
 
6926
 
CREATE FUNCTION _locationtrigger() RETURNS trigger
6927
 
    LANGUAGE plpgsql
6928
 
    AS $$
6929
 
DECLARE
6930
 
  _check      BOOLEAN;
6931
 
  _checkId    INTEGER;
6932
 
 
6933
 
BEGIN
6934
 
 
6935
 
  -- Checks
6936
 
  -- Start with privileges
6937
 
  IF (TG_OP = 'INSERT') THEN
6938
 
    SELECT checkPrivilege('MaintainLocations') INTO _check;
6939
 
    IF NOT (_check) THEN
6940
 
      RAISE EXCEPTION 'You do not have privileges to add new Locations.';
6941
 
    END IF;
6942
 
  ELSE
6943
 
    SELECT checkPrivilege('MaintainLocations') INTO _check;
6944
 
    IF NOT (_check) THEN
6945
 
      RAISE EXCEPTION 'You do not have privileges to alter a Location.';
6946
 
    END IF;
6947
 
  END IF;
6948
 
 
6949
 
  -- Code is required
6950
 
  IF ( (LENGTH(COALESCE(NEW.location_name,''))=0) AND
6951
 
       (LENGTH(COALESCE(NEW.location_aisle,''))=0) AND
6952
 
       (LENGTH(COALESCE(NEW.location_rack,''))=0) AND
6953
 
       (LENGTH(COALESCE(NEW.location_bin,''))=0) ) THEN
6954
 
    RAISE EXCEPTION 'You must supply a valid Location Identifier.';
6955
 
  END IF;
6956
 
  
6957
 
  -- Site is required
6958
 
  IF (NEW.location_warehous_id IS NULL) THEN
6959
 
    RAISE EXCEPTION 'You must supply a valid Site.';
6960
 
  END IF;
6961
 
 
6962
 
  -- Location Identifier must be unique
6963
 
  SELECT location_id INTO _checkId
6964
 
  FROM location
6965
 
  WHERE ( (UPPER(location_name)=UPPER(NEW.location_name))
6966
 
    AND   (UPPER(location_aisle)=UPPER(NEW.location_aisle))
6967
 
    AND   (UPPER(location_rack)=UPPER(NEW.location_rack))
6968
 
    AND   (UPPER(location_bin)=UPPER(NEW.location_bin))
6969
 
    AND   (location_warehous_id=NEW.location_warehous_id)
6970
 
    AND   (location_id<>NEW.location_id) );
6971
 
  IF (FOUND) THEN
6972
 
    RAISE EXCEPTION 'You must supply a unique Location Identifier for this Site.';
6973
 
  END IF;
6974
 
 
6975
 
  -- Populate formatted name
6976
 
  IF (NEW.location_aisle IS NOT NULL) THEN
6977
 
    NEW.location_formatname := NEW.location_aisle;
6978
 
  ELSE
6979
 
    NEW.location_formatname := '';
6980
 
  END IF;
6981
 
 
6982
 
  IF (NEW.location_rack IS NOT NULL) THEN
6983
 
    NEW.location_formatname := (NEW.location_formatname || NEW.location_rack);
6984
 
  END IF;
6985
 
 
6986
 
  IF (NEW.location_bin IS NOT NULL) THEN
6987
 
    NEW.location_formatname := (NEW.location_formatname || NEW.location_bin);
6988
 
  END IF;
6989
 
 
6990
 
  IF (NEW.location_name IS NOT NULL) THEN
6991
 
    NEW.location_formatname := (NEW.location_formatname || NEW.location_name);
6992
 
  END IF;
6993
 
  
6994
 
  RETURN NEW;
6995
 
 
6996
 
END;
6997
 
$$;
6998
 
 
6999
 
 
7000
 
ALTER FUNCTION public._locationtrigger() OWNER TO admin;
7001
 
 
7002
 
--
7003
 
--
7004
 
 
7005
 
CREATE FUNCTION _metasqlaltertrigger() RETURNS trigger
7006
 
    LANGUAGE plpgsql
7007
 
    AS $$
7008
 
BEGIN
7009
 
  IF (NOT (isDBA() OR checkPrivilege('MaintainMetaSQL'))) THEN
7010
 
    RAISE EXCEPTION '% does not have privileges to maintain MetaSQL statements in %.%',
7011
 
                getEffectiveXtUser(), TG_TABLE_SCHEMA, TG_TABLE_NAME;
7012
 
  END IF;
7013
 
 
7014
 
  IF ((TG_OP = 'UPDATE' OR TG_OP = 'DELETE')
7015
 
      AND NEW.metasql_grade <= 0
7016
 
      AND NOT isDBA()) THEN
7017
 
    RAISE EXCEPTION 'You may not alter grade 0 metasql queries except using the xTuple Updater utility';
7018
 
  END IF;
7019
 
 
7020
 
  IF (TG_OP = 'DELETE') THEN
7021
 
    RETURN OLD;
7022
 
  END IF;
7023
 
 
7024
 
  RETURN NEW;
7025
 
END;
7026
 
 
7027
 
$$;
7028
 
 
7029
 
 
7030
 
ALTER FUNCTION public._metasqlaltertrigger() OWNER TO admin;
7031
 
 
7032
 
--
7033
 
--
7034
 
 
7035
 
CREATE FUNCTION _metasqltrigger() RETURNS trigger
7036
 
    LANGUAGE plpgsql
7037
 
    AS $$
7038
 
BEGIN
7039
 
 
7040
 
  NEW.metasql_lastuser          := getEffectiveXtUser();
7041
 
  NEW.metasql_lastupdate        := current_date;
7042
 
  RETURN NEW;
7043
 
 
7044
 
END;
7045
 
 
7046
 
$$;
7047
 
 
7048
 
 
7049
 
ALTER FUNCTION public._metasqltrigger() OWNER TO admin;
7050
 
 
7051
 
--
7052
 
--
7053
 
 
7054
 
CREATE FUNCTION _opheadaftertrigger() RETURNS trigger
7055
 
    LANGUAGE plpgsql
7056
 
    AS $$
7057
 
DECLARE
7058
 
  _cmnttypeid INTEGER;
7059
 
BEGIN
7060
 
  IF (TG_OP = 'DELETE') THEN
7061
 
    DELETE FROM docass WHERE docass_source_id = OLD.ophead_id AND docass_source_type = 'OPP';
7062
 
    DELETE FROM docass WHERE docass_target_id = OLD.ophead_id AND docass_target_type = 'OPP';
7063
 
  END IF;
7064
 
  
7065
 
  --  Comments
7066
 
  IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='OpportunityChangeLog') ) THEN
7067
 
 
7068
 
    --  Cache the cmnttype_id for ChangeLog
7069
 
    SELECT cmnttype_id INTO _cmnttypeid
7070
 
    FROM cmnttype
7071
 
    WHERE (cmnttype_name='ChangeLog');
7072
 
    IF (FOUND) THEN
7073
 
      IF (TG_OP = 'INSERT') THEN
7074
 
        PERFORM postComment(_cmnttypeid, 'OPP', NEW.ophead_id, 'Created');
7075
 
 
7076
 
        --- clear the number from the issue cache
7077
 
        PERFORM clearNumberIssue('OpportunityNumber', NEW.ophead_number);
7078
 
      ELSIF (TG_OP = 'UPDATE') THEN
7079
 
        IF (OLD.ophead_active <> NEW.ophead_active) THEN
7080
 
          IF (NEW.ophead_active) THEN
7081
 
            PERFORM postComment(_cmnttypeid, 'OPP', NEW.ophead_id, 'Activated');
7082
 
          ELSE
7083
 
            PERFORM postComment(_cmnttypeid, 'OPP', NEW.ophead_id, 'Deactivated');
7084
 
          END IF;
7085
 
        END IF;
7086
 
 
7087
 
        IF (OLD.ophead_name <> NEW.ophead_name) THEN
7088
 
          PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id,
7089
 
                               ( 'Name Changed from "' || OLD.ophead_name ||
7090
 
                                 '" to "' || NEW.ophead_name || '"' ) );
7091
 
        END IF;
7092
 
 
7093
 
        IF (OLD.ophead_owner_username <> NEW.ophead_owner_username) THEN
7094
 
          PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id,
7095
 
                               ( 'Owner Name Changed from "' || OLD.ophead_owner_username ||
7096
 
                                 '" to "' || NEW.ophead_owner_username || '"' ) );
7097
 
        END IF;
7098
 
 
7099
 
        IF (OLD.ophead_probability_prcnt <> NEW.ophead_probability_prcnt) THEN
7100
 
          PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id,
7101
 
                               ( 'Probability % Changed from "' || OLD.ophead_probability_prcnt ||
7102
 
                                 '" to "' || NEW.ophead_probability_prcnt || '"' ) );
7103
 
        END IF;
7104
 
 
7105
 
        IF (OLD.ophead_amount <> NEW.ophead_amount) THEN
7106
 
          PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id,
7107
 
                               ( 'Amount Changed from "' || OLD.ophead_amount ||
7108
 
                                 '" to "' || NEW.ophead_amount || '"' ) );
7109
 
        END IF;
7110
 
 
7111
 
        IF (OLD.ophead_target_date <> NEW.ophead_target_date) THEN
7112
 
          PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id,
7113
 
                               ( 'Target Date Changed from "' || OLD.ophead_target_date ||
7114
 
                                 '" to "' || NEW.ophead_target_date || '"' ) );
7115
 
        END IF;
7116
 
 
7117
 
        IF (OLD.ophead_actual_date <> NEW.ophead_actual_date) THEN
7118
 
          PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id,
7119
 
                               ( 'Actual Date Changed from "' || OLD.ophead_actual_date ||
7120
 
                                 '" to "' || NEW.ophead_actual_date || '"' ) );
7121
 
        END IF;
7122
 
 
7123
 
        IF (OLD.ophead_crmacct_id <> NEW.ophead_crmacct_id) THEN
7124
 
          PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id,
7125
 
                               ( 'CRM Account Changed from "' ||
7126
 
                                 (SELECT crmacct_name FROM crmacct WHERE crmacct_id=OLD.ophead_crmacct_id) ||
7127
 
                                 '" (' || OLD.ophead_crmacct_id ||
7128
 
                                 ') to "' ||
7129
 
                                 (SELECT crmacct_name FROM crmacct WHERE crmacct_id=NEW.ophead_crmacct_id) ||
7130
 
                                 '" (' || NEW.ophead_crmacct_id || ')' ) );
7131
 
        END IF;
7132
 
 
7133
 
        IF (OLD.ophead_curr_id <> NEW.ophead_curr_id) THEN
7134
 
          PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id,
7135
 
                               ( 'Currency Changed from "' ||
7136
 
                                 (SELECT curr_name FROM curr_symbol WHERE curr_id=OLD.ophead_curr_id) ||
7137
 
                                 '" (' || OLD.ophead_curr_id ||
7138
 
                                 ') to "' ||
7139
 
                                 (SELECT curr_name FROM curr_symbol WHERE curr_id=NEW.ophead_curr_id) ||
7140
 
                                 '" (' || NEW.ophead_curr_id || ')' ) );
7141
 
        END IF;
7142
 
 
7143
 
        IF (OLD.ophead_opstage_id <> NEW.ophead_opstage_id) THEN
7144
 
          PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id,
7145
 
                               ( 'Stage Changed from "' ||
7146
 
                                 (SELECT opstage_name FROM opstage WHERE opstage_id=OLD.ophead_opstage_id) ||
7147
 
                                 '" (' || OLD.ophead_opstage_id ||
7148
 
                                 ') to "' ||
7149
 
                                 (SELECT opstage_name FROM opstage WHERE opstage_id=NEW.ophead_opstage_id) ||
7150
 
                                 '" (' || NEW.ophead_opstage_id || ')' ) );
7151
 
        END IF;
7152
 
 
7153
 
        IF (OLD.ophead_opsource_id <> NEW.ophead_opsource_id) THEN
7154
 
          PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id,
7155
 
                               ( 'Source Changed from "' ||
7156
 
                                 (SELECT opsource_name FROM opsource WHERE opsource_id=OLD.ophead_opsource_id) ||
7157
 
                                 '" (' || OLD.ophead_opsource_id ||
7158
 
                                 ') to "' ||
7159
 
                                 (SELECT opsource_name FROM opsource WHERE opsource_id=NEW.ophead_opsource_id) ||
7160
 
                                 '" (' || NEW.ophead_opsource_id || ')' ) );
7161
 
        END IF;
7162
 
 
7163
 
        IF (OLD.ophead_optype_id <> NEW.ophead_optype_id) THEN
7164
 
          PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id,
7165
 
                               ( 'Type Changed from "' ||
7166
 
                                 (SELECT optype_name FROM optype WHERE optype_id=OLD.ophead_optype_id) ||
7167
 
                                 '" (' || OLD.ophead_optype_id ||
7168
 
                                 ') to "' ||
7169
 
                                 (SELECT optype_name FROM optype WHERE optype_id=NEW.ophead_optype_id) ||
7170
 
                                 '" (' || NEW.ophead_optype_id || ')' ) );
7171
 
        END IF;
7172
 
 
7173
 
      END IF;
7174
 
    END IF;
7175
 
  END IF;
7176
 
 
7177
 
  RETURN NEW;
7178
 
END;
7179
 
$$;
7180
 
 
7181
 
 
7182
 
ALTER FUNCTION public._opheadaftertrigger() OWNER TO admin;
7183
 
 
7184
 
--
7185
 
--
7186
 
 
7187
 
CREATE FUNCTION _opheadbeforetrigger() RETURNS trigger
7188
 
    LANGUAGE plpgsql
7189
 
    AS $$
7190
 
DECLARE
7191
 
  _rec record;
7192
 
  _check boolean;
7193
 
  _test text;
7194
 
BEGIN
7195
 
 
7196
 
  IF(TG_OP = 'DELETE') THEN
7197
 
    _rec := OLD;
7198
 
  ELSE
7199
 
    _rec := NEW;
7200
 
  END IF;
7201
 
 
7202
 
  --  Auto inactivate
7203
 
  IF (TG_OP = 'UPDATE') THEN
7204
 
    IF ( (NEW.ophead_opstage_id != OLD.ophead_opstage_id) AND
7205
 
         (SELECT opstage_opinactive FROM opstage WHERE opstage_id=NEW.ophead_opstage_id) ) THEN
7206
 
      NEW.ophead_active := FALSE;
7207
 
    END IF;
7208
 
  END IF;
7209
 
 
7210
 
  IF (TG_OP = 'INSERT') THEN
7211
 
    IF (SELECT opstage_opinactive FROM opstage WHERE opstage_id=NEW.ophead_opstage_id) THEN
7212
 
      NEW.ophead_active := FALSE;
7213
 
    END IF;
7214
 
  END IF;
7215
 
 
7216
 
  RETURN NEW;
7217
 
END;
7218
 
$$;
7219
 
 
7220
 
 
7221
 
ALTER FUNCTION public._opheadbeforetrigger() OWNER TO admin;
7222
 
 
7223
 
--
7224
 
--
7225
 
 
7226
 
CREATE FUNCTION _packbeforetrigger() RETURNS trigger
7227
 
    LANGUAGE plpgsql
7228
 
    AS $$
7229
 
DECLARE
7230
 
  _cmnttypeid INTEGER;
7231
 
BEGIN
7232
 
  SELECT cmnttype_id INTO _cmnttypeid
7233
 
    FROM cmnttype
7234
 
    WHERE (cmnttype_name='ChangeLog');
7235
 
  IF (FOUND) THEN
7236
 
    IF ((TG_OP = 'INSERT') AND (NEW.pack_head_id) IS NOT NULL)THEN
7237
 
      PERFORM postComment(_cmnttypeid, 'S', NEW.pack_head_id, 'Added to Packing List Batch');
7238
 
    END IF;
7239
 
  END IF;
7240
 
  IF ((TG_OP = 'INSERT') OR (TG_OP = 'UPDATE')) THEN
7241
 
    IF (NEW.pack_shiphead_id IS NOT NULL
7242
 
         AND NEW.pack_shiphead_id NOT IN (SELECT shiphead_id
7243
 
                               FROM shiphead
7244
 
                               WHERE (shiphead_order_id=NEW.pack_head_id)
7245
 
                                 AND (shiphead_order_type=NEW.pack_head_type))) THEN
7246
 
      RAISE EXCEPTION 'Shipment does not exist for % id %',
7247
 
                      NEW.pack_head_type, NEW.pack_head_id;
7248
 
      RETURN OLD;
7249
 
    END IF;
7250
 
 
7251
 
    IF (NEW.pack_head_type = 'SO'
7252
 
        AND NEW.pack_head_id   IN (SELECT cohead_id FROM cohead)) THEN
7253
 
      RETURN NEW;
7254
 
 
7255
 
    ELSEIF (NEW.pack_head_type = 'TO') THEN
7256
 
      IF (NOT fetchMetricBool('MultiWhs')) THEN
7257
 
        RAISE EXCEPTION 'Transfer Orders are not supported by this version of the application';
7258
 
      ELSEIF (NEW.pack_head_id IN (SELECT tohead_id FROM tohead)) THEN
7259
 
        RETURN NEW;
7260
 
      END IF;
7261
 
    END IF;
7262
 
 
7263
 
    RAISE EXCEPTION '% with id % does not exist',
7264
 
                    NEW.pack_head_type, NEW.pack_head_id;
7265
 
    RETURN OLD;
7266
 
 
7267
 
  END IF;
7268
 
 
7269
 
  RETURN NEW;
7270
 
END;
7271
 
$$;
7272
 
 
7273
 
 
7274
 
ALTER FUNCTION public._packbeforetrigger() OWNER TO admin;
7275
 
 
7276
 
--
7277
 
--
7278
 
 
7279
 
CREATE FUNCTION _periodaftertrigger() RETURNS trigger
7280
 
    LANGUAGE plpgsql
7281
 
    AS $$
7282
 
DECLARE
7283
 
  _idoffirst INTEGER;
7284
 
  _test      INTEGER;
7285
 
BEGIN
7286
 
  -- This trigger can easily cause an infinite loop
7287
 
  -- because of this we have to be very careful to not
7288
 
  -- do an update on the period table if no updates
7289
 
  -- are absolutely needed so we don't just keep
7290
 
  -- trigger ourselves again and again
7291
 
 
7292
 
  -- Figure out which period is the first one
7293
 
  SELECT period_id
7294
 
    INTO _idoffirst
7295
 
    FROM period
7296
 
   ORDER BY period_start
7297
 
   LIMIT 1;
7298
 
 
7299
 
  -- If we didn't find anything there is nothing to do
7300
 
  IF( NOT FOUND ) THEN
7301
 
    RETURN NEW;
7302
 
  END IF;
7303
 
 
7304
 
  -- do a select to see if there is at least one record that needs to be
7305
 
  -- updated. If we do not find any then we can just leave without
7306
 
  -- causing a retrigger of ourselves
7307
 
  SELECT period_id
7308
 
    INTO _test
7309
 
    FROM period
7310
 
   WHERE((COALESCE(period_initial, true) AND (NOT period_id=_idoffirst))
7311
 
      OR ((NOT COALESCE(period_initial, false)) AND (period_id=_idoffirst)))
7312
 
   LIMIT 1;
7313
 
 
7314
 
  -- Nothing to update - get out of here
7315
 
  IF( NOT FOUND ) THEN
7316
 
    RETURN NEW;
7317
 
  END IF;
7318
 
 
7319
 
  -- Update all the period records that already have the initial flag
7320
 
  -- set and the one that we know should be the first.
7321
 
  -- We don't have to be as careful here since we have already ruled
7322
 
  -- out if don't need to update already.
7323
 
  UPDATE period
7324
 
     SET period_initial = (_idoffirst=period_id)
7325
 
   WHERE((COALESCE(period_initial, true))
7326
 
      OR (period_id=_idoffirst));
7327
 
 
7328
 
  RETURN NEW;
7329
 
 
7330
 
END;
7331
 
$$;
7332
 
 
7333
 
 
7334
 
ALTER FUNCTION public._periodaftertrigger() OWNER TO admin;
7335
 
 
7336
 
--
7337
 
--
7338
 
 
7339
 
CREATE FUNCTION _pkgcmdaftertrigger() RETURNS trigger
7340
 
    LANGUAGE plpgsql
7341
 
    AS $$
7342
 
BEGIN
7343
 
  IF (TG_OP = 'DELETE') THEN
7344
 
    RETURN OLD;
7345
 
  END IF;
7346
 
 
7347
 
  RETURN NEW;
7348
 
END;
7349
 
$$;
7350
 
 
7351
 
 
7352
 
ALTER FUNCTION public._pkgcmdaftertrigger() OWNER TO admin;
7353
 
 
7354
 
--
7355
 
--
7356
 
 
7357
 
CREATE FUNCTION _pkgcmdaltertrigger() RETURNS trigger
7358
 
    LANGUAGE plpgsql
7359
 
    AS $$
7360
 
BEGIN
7361
 
  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
7362
 
    IF (TG_OP = 'DELETE') THEN
7363
 
      RETURN OLD;
7364
 
    ELSE
7365
 
      RETURN NEW;
7366
 
    END IF;
7367
 
  END IF;
7368
 
 
7369
 
  IF (TG_OP = 'INSERT') THEN
7370
 
    RAISE EXCEPTION 'You may not create custom commands in packages except using the xTuple Updater utility';
7371
 
 
7372
 
  ELSIF (TG_OP = 'UPDATE') THEN
7373
 
    RAISE EXCEPTION 'You may not alter custom commands in packages except using the xTuple Updater utility';
7374
 
 
7375
 
  ELSIF (TG_OP = 'DELETE') THEN
7376
 
    RAISE EXCEPTION 'You may not delete custom commands from packages. Try deleting or disabling the package.';
7377
 
 
7378
 
  END IF;
7379
 
 
7380
 
  RETURN NEW;
7381
 
END;
7382
 
 
7383
 
$$;
7384
 
 
7385
 
 
7386
 
ALTER FUNCTION public._pkgcmdaltertrigger() OWNER TO admin;
7387
 
 
7388
 
--
7389
 
--
7390
 
 
7391
 
CREATE FUNCTION _pkgcmdargaftertrigger() RETURNS trigger
7392
 
    LANGUAGE plpgsql
7393
 
    AS $$
7394
 
BEGIN
7395
 
  IF (TG_OP = 'DELETE') THEN
7396
 
    RETURN OLD;
7397
 
  END IF;
7398
 
  RETURN NEW;
7399
 
END;
7400
 
$$;
7401
 
 
7402
 
 
7403
 
ALTER FUNCTION public._pkgcmdargaftertrigger() OWNER TO admin;
7404
 
 
7405
 
--
7406
 
--
7407
 
 
7408
 
CREATE FUNCTION _pkgcmdargaltertrigger() RETURNS trigger
7409
 
    LANGUAGE plpgsql
7410
 
    AS $$
7411
 
BEGIN
7412
 
  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
7413
 
    IF (TG_OP = 'DELETE') THEN
7414
 
      RETURN OLD;
7415
 
    ELSE
7416
 
      RETURN NEW;
7417
 
    END IF;
7418
 
  END IF;
7419
 
 
7420
 
  IF (TG_OP = 'INSERT') THEN
7421
 
    RAISE EXCEPTION 'You may not create command arguments in packages except using the xTuple Updater utility';
7422
 
 
7423
 
  ELSIF (TG_OP = 'UPDATE') THEN
7424
 
    RAISE EXCEPTION 'You may not alter command arguments in packages except using the xTuple Updater utility';
7425
 
 
7426
 
  ELSIF (TG_OP = 'DELETE') THEN
7427
 
    RAISE EXCEPTION 'You may not delete command arguments from packages. Try deleting or disabling the package.';
7428
 
 
7429
 
  END IF;
7430
 
 
7431
 
  RETURN NEW;
7432
 
END;
7433
 
 
7434
 
$$;
7435
 
 
7436
 
 
7437
 
ALTER FUNCTION public._pkgcmdargaltertrigger() OWNER TO admin;
7438
 
 
7439
 
--
7440
 
--
7441
 
 
7442
 
CREATE FUNCTION _pkgcmdargbeforetrigger() RETURNS trigger
7443
 
    LANGUAGE plpgsql
7444
 
    AS $$
7445
 
DECLARE
7446
 
  _cmdargid     INTEGER;
7447
 
  _debug        BOOL := false;
7448
 
 
7449
 
BEGIN
7450
 
  IF (TG_OP = 'UPDATE') THEN
7451
 
    RETURN NEW;
7452
 
 
7453
 
  ELSIF (TG_OP = 'INSERT') THEN
7454
 
    RETURN NEW;
7455
 
 
7456
 
  ELSIF (TG_OP = 'DELETE') THEN
7457
 
    RETURN OLD;
7458
 
  END IF;
7459
 
 
7460
 
  RETURN NEW;
7461
 
END;
7462
 
$$;
7463
 
 
7464
 
 
7465
 
ALTER FUNCTION public._pkgcmdargbeforetrigger() OWNER TO admin;
7466
 
 
7467
 
--
7468
 
--
7469
 
 
7470
 
CREATE FUNCTION _pkgcmdbeforetrigger() RETURNS trigger
7471
 
    LANGUAGE plpgsql
7472
 
    AS $$
7473
 
DECLARE
7474
 
  _cmdid       INTEGER;
7475
 
  _debug        BOOL := false;
7476
 
 
7477
 
BEGIN
7478
 
    IF (TG_OP = 'UPDATE') THEN
7479
 
      IF (_debug) THEN
7480
 
        RAISE NOTICE 'OLD.cmd_name %, NEW.cmd_name %',
7481
 
                     OLD.cmd_name, NEW.cmd_name;
7482
 
      END IF;
7483
 
 
7484
 
      IF (NEW.cmd_name != OLD.cmd_name) THEN
7485
 
        SELECT cmd_id INTO _cmdid FROM cmd WHERE cmd_name=NEW.cmd_name;
7486
 
        IF (FOUND) THEN
7487
 
          RAISE EXCEPTION 'Cannot change command name % because another command with that name already exists.', NEW.cmd_name;
7488
 
        END IF;
7489
 
      END IF;
7490
 
 
7491
 
    ELSIF (TG_OP = 'INSERT') THEN
7492
 
      IF (_debug) THEN
7493
 
        RAISE NOTICE 'inserting NEW.cmd_name %', NEW.cmd_name;
7494
 
      END IF;
7495
 
      SELECT cmd_id INTO _cmdid FROM cmd WHERE cmd_name=NEW.cmd_name;
7496
 
      IF (FOUND) THEN
7497
 
        RAISE EXCEPTION 'Cannot create new command % because another command with that name already exists.', NEW.cmd_name;
7498
 
      END IF;
7499
 
 
7500
 
    ELSIF (TG_OP = 'DELETE') THEN
7501
 
      DELETE FROM cmdarg WHERE cmdarg_cmd_id=OLD.cmd_id;
7502
 
 
7503
 
      RETURN OLD;
7504
 
    END IF;
7505
 
 
7506
 
    RETURN NEW;
7507
 
  END;
7508
 
$$;
7509
 
 
7510
 
 
7511
 
ALTER FUNCTION public._pkgcmdbeforetrigger() OWNER TO admin;
7512
 
 
7513
 
--
7514
 
--
7515
 
 
7516
 
CREATE FUNCTION _pkgheadbeforetrigger() RETURNS trigger
7517
 
    LANGUAGE plpgsql
7518
 
    AS $$
7519
 
  DECLARE
7520
 
    _r    RECORD;
7521
 
 
7522
 
  BEGIN
7523
 
    IF (TG_OP = 'UPDATE') THEN
7524
 
      NEW.pkghead_created := OLD.pkghead_created;
7525
 
      NEW.pkghead_updated := CURRENT_TIMESTAMP;
7526
 
      IF (NEW.pkghead_indev AND NOT userCanCreateUsers(getEffectiveXtUser())) THEN
7527
 
        NEW.pkghead_indev = FALSE;
7528
 
      END IF;
7529
 
 
7530
 
    ELSIF (TG_OP = 'INSERT') THEN
7531
 
      NEW.pkghead_created := CURRENT_TIMESTAMP;
7532
 
      NEW.pkghead_updated := NEW.pkghead_created;
7533
 
      IF (NEW.pkghead_indev AND NOT userCanCreateUsers(getEffectiveXtUser())) THEN
7534
 
        NEW.pkghead_indev = FALSE;
7535
 
      END IF;
7536
 
 
7537
 
    ELSIF (TG_OP = 'DELETE') THEN
7538
 
      DELETE FROM pkgdep WHERE pkgdep_pkghead_id=OLD.pkghead_id;
7539
 
 
7540
 
      EXECUTE 'DROP SCHEMA ' || OLD.pkghead_name || ' CASCADE';
7541
 
 
7542
 
      RETURN OLD;
7543
 
    END IF;
7544
 
 
7545
 
    RETURN NEW;
7546
 
  END;
7547
 
$$;
7548
 
 
7549
 
 
7550
 
ALTER FUNCTION public._pkgheadbeforetrigger() OWNER TO admin;
7551
 
 
7552
 
--
7553
 
--
7554
 
 
7555
 
CREATE FUNCTION _pkgimageaftertrigger() RETURNS trigger
7556
 
    LANGUAGE plpgsql
7557
 
    AS $$
7558
 
BEGIN
7559
 
  IF (TG_OP = 'DELETE') THEN
7560
 
    RETURN OLD;
7561
 
  END IF;
7562
 
 
7563
 
  RETURN NEW;
7564
 
END;
7565
 
$$;
7566
 
 
7567
 
 
7568
 
ALTER FUNCTION public._pkgimageaftertrigger() OWNER TO admin;
7569
 
 
7570
 
--
7571
 
--
7572
 
 
7573
 
CREATE FUNCTION _pkgimagealtertrigger() RETURNS trigger
7574
 
    LANGUAGE plpgsql
7575
 
    AS $$
7576
 
BEGIN
7577
 
  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
7578
 
    IF (TG_OP = 'DELETE') THEN
7579
 
      RETURN OLD;
7580
 
    ELSE
7581
 
      RETURN NEW;
7582
 
    END IF;
7583
 
  END IF;
7584
 
 
7585
 
  IF (TG_OP = 'INSERT') THEN
7586
 
    RAISE EXCEPTION 'You may not create images in packages except using the xTuple Updater utility';
7587
 
 
7588
 
  ELSIF (TG_OP = 'UPDATE') THEN
7589
 
    RAISE EXCEPTION 'You may not alter images in packages except using the xTuple Updater utility';
7590
 
 
7591
 
  ELSIF (TG_OP = 'DELETE') THEN
7592
 
    RAISE EXCEPTION 'You may not delete images from packages. Try deleting or disabling the package.';
7593
 
 
7594
 
  END IF;
7595
 
 
7596
 
  RETURN NEW;
7597
 
END;
7598
 
$$;
7599
 
 
7600
 
 
7601
 
ALTER FUNCTION public._pkgimagealtertrigger() OWNER TO admin;
7602
 
 
7603
 
--
7604
 
--
7605
 
 
7606
 
CREATE FUNCTION _pkgimagebeforetrigger() RETURNS trigger
7607
 
    LANGUAGE plpgsql
7608
 
    AS $$
7609
 
DECLARE
7610
 
  _imageid     INTEGER;
7611
 
  _debug       BOOL := false;
7612
 
 
7613
 
BEGIN
7614
 
  IF (TG_OP = 'UPDATE') THEN
7615
 
    IF (_debug) THEN
7616
 
      RAISE NOTICE 'OLD.image_name %, NEW.image_name %',
7617
 
                   OLD.image_name, NEW.image_name;
7618
 
    END IF;
7619
 
 
7620
 
    IF (NEW.image_name != OLD.image_name) THEN
7621
 
      SELECT image_id INTO _imageid FROM image WHERE image_name=NEW.image_name;
7622
 
      IF (FOUND) THEN
7623
 
        RAISE EXCEPTION 'Cannot change image named % because another image with that name already exists.', NEW.image_name;
7624
 
      END IF;
7625
 
    END IF;
7626
 
 
7627
 
  ELSIF (TG_OP = 'INSERT') THEN
7628
 
    IF (_debug) THEN
7629
 
      RAISE NOTICE 'inserting NEW.image_name %', NEW.image_name;
7630
 
    END IF;
7631
 
    SELECT image_id INTO _imageid FROM image WHERE image_name=NEW.image_name;
7632
 
    IF (FOUND) THEN
7633
 
      RAISE EXCEPTION 'Cannot create new image % because another image with that name already exists.', NEW.image_name;
7634
 
    END IF;
7635
 
 
7636
 
  ELSIF (TG_OP = 'DELETE') THEN
7637
 
    RETURN OLD;
7638
 
 
7639
 
  END IF;
7640
 
 
7641
 
  RETURN NEW;
7642
 
END;
7643
 
$$;
7644
 
 
7645
 
 
7646
 
ALTER FUNCTION public._pkgimagebeforetrigger() OWNER TO admin;
7647
 
 
7648
 
--
7649
 
--
7650
 
 
7651
 
CREATE FUNCTION _pkgitembeforetrigger() RETURNS trigger
7652
 
    LANGUAGE plpgsql
7653
 
    AS $$
7654
 
  DECLARE
7655
 
    _functionargs TEXT;
7656
 
    _group        TEXT;
7657
 
    _object       TEXT;
7658
 
    _schema       TEXT;
7659
 
    _debug        BOOL := false;
7660
 
  BEGIN
7661
 
    IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN
7662
 
      _object = NEW.pkgitem_name;
7663
 
 
7664
 
      SELECT LOWER(pkghead_name) INTO _schema
7665
 
      FROM pkghead
7666
 
      WHERE (pkghead_id=NEW.pkgitem_pkghead_id);
7667
 
      IF (NOT FOUND) THEN
7668
 
        _schema := 'public';
7669
 
      END IF;
7670
 
 
7671
 
      IF (NEW.pkgitem_type = 'F') THEN
7672
 
        _object := SPLIT_PART(_object, '(', 1);
7673
 
      ELSIF (NEW.pkgitem_type = 'M') THEN
7674
 
        _group  := SPLIT_PART(_object, '-', 1);
7675
 
        _object := SPLIT_PART(_object, '-', 2);
7676
 
      END IF;
7677
 
      IF _debug THEN
7678
 
        RAISE NOTICE '_schema % and _object %', _schema, _object;
7679
 
      END IF;
7680
 
 
7681
 
      IF (NEW.pkgitem_type = 'C') THEN
7682
 
        IF (NOT EXISTS(SELECT script_id
7683
 
                       FROM script
7684
 
                       WHERE ((script_id=NEW.pkgitem_item_id)
7685
 
                          AND (script_name=NEW.pkgitem_name)))) THEN
7686
 
          RAISE EXCEPTION 'Cannot create Script % as a Package Item without a corresponding script record.',
7687
 
            NEW.pkgitem_name;
7688
 
        END IF;
7689
 
 
7690
 
      ELSIF (NEW.pkgitem_type = 'D') THEN
7691
 
        IF (NOT EXISTS(SELECT cmd_id
7692
 
                       FROM cmd
7693
 
                       WHERE ((cmd_id=NEW.pkgitem_item_id)
7694
 
                          AND (cmd_name=NEW.pkgitem_name)))) THEN
7695
 
          RAISE EXCEPTION 'Cannot create Custom Command % as a Package Item without a corresponding cmd record.',
7696
 
            NEW.pkgitem_name;
7697
 
        END IF;
7698
 
 
7699
 
      ELSIF (NEW.pkgitem_type = 'F') THEN
7700
 
        IF (NOT EXISTS(SELECT pg_proc.oid
7701
 
                       FROM pg_proc, pg_namespace
7702
 
                       WHERE ((pg_proc.oid=NEW.pkgitem_item_id)
7703
 
                          AND (proname = (_object))
7704
 
                          AND (pronamespace=pg_namespace.oid)
7705
 
                          AND (nspname=_schema)) )) THEN
7706
 
          RAISE EXCEPTION 'Cannot create Function % (oid %) as a Package Item without a corresponding function in the database.',
7707
 
                          NEW.pkgitem_name, NEW.pkgitem_item_id;
7708
 
        END IF;
7709
 
 
7710
 
      ELSIF (NEW.pkgitem_type = 'G') THEN
7711
 
        IF (NOT EXISTS(SELECT pg_class.oid
7712
 
                     FROM pg_trigger, pg_class, pg_namespace
7713
 
                     WHERE ((tgname=_object)
7714
 
                        AND (tgrelid=pg_class.oid)
7715
 
                        AND (relnamespace=pg_namespace.oid)
7716
 
                        AND (nspname=_schema)))) THEN
7717
 
          RAISE EXCEPTION 'Cannot create Trigger % as a Package Item without a corresponding trigger in the database.',
7718
 
            NEW.pkgitem_name;
7719
 
        END IF;
7720
 
 
7721
 
      ELSIF (NEW.pkgitem_type = 'I') THEN
7722
 
        IF (NOT EXISTS(SELECT image_id
7723
 
                       FROM image
7724
 
                       WHERE ((image_id=NEW.pkgitem_item_id)
7725
 
                          AND (image_name=NEW.pkgitem_name)))) THEN
7726
 
          RAISE EXCEPTION 'Cannot create Image % as a Package Item without a corresponding image record.',
7727
 
            NEW.pkgitem_name;
7728
 
        END IF;
7729
 
 
7730
 
      ELSIF (NEW.pkgitem_type = 'M') THEN
7731
 
        IF (NOT EXISTS(SELECT metasql_id
7732
 
                       FROM metasql
7733
 
                       WHERE ((metasql_id=NEW.pkgitem_item_id)
7734
 
                          AND (metasql_group=_group)
7735
 
                          AND (metasql_name=_object)))) THEN
7736
 
          RAISE EXCEPTION 'Cannot create MetaSQL statement % as a Package Item without a corresponding metasql record.',
7737
 
            NEW.pkgitem_name;
7738
 
        END IF;
7739
 
 
7740
 
      ELSIF (NEW.pkgitem_type = 'P') THEN
7741
 
        IF (NOT EXISTS(SELECT priv_id
7742
 
                       FROM priv
7743
 
                       WHERE ((priv_id=NEW.pkgitem_item_id)
7744
 
                          AND (priv_name=NEW.pkgitem_name)))) THEN
7745
 
          RAISE EXCEPTION 'Cannot create Privilege % as a Package Item without a corresponding priv record.',
7746
 
            NEW.pkgitem_name;
7747
 
        END IF;
7748
 
 
7749
 
      ELSIF (NEW.pkgitem_type = 'R') THEN
7750
 
        IF (NOT EXISTS(SELECT report_id
7751
 
                       FROM report
7752
 
                       WHERE ((report_id=NEW.pkgitem_item_id)
7753
 
                          AND (report_name=NEW.pkgitem_name)))) THEN
7754
 
          RAISE EXCEPTION 'Cannot create Report % as a Package Item without a corresponding report record.',
7755
 
            NEW.pkgitem_name;
7756
 
        END IF;
7757
 
 
7758
 
      ELSIF (NEW.pkgitem_type = 'S') THEN
7759
 
        IF (NOT EXISTS(SELECT oid
7760
 
                       FROM pg_namespace
7761
 
                       WHERE (LOWER(nspname)=LOWER(NEW.pkgitem_name)))) THEN
7762
 
          RAISE EXCEPTION 'Cannot create Schema % as a Package Item without a corresponding schema in the database.',
7763
 
            NEW.pkgitem_name;
7764
 
        END IF;
7765
 
 
7766
 
      ELSIF (NEW.pkgitem_type = 'T') THEN
7767
 
        IF (NOT EXISTS(SELECT pg_class.oid
7768
 
                     FROM pg_class, pg_namespace
7769
 
                     WHERE ((relname=_object)
7770
 
                        AND (relnamespace=pg_namespace.oid)
7771
 
                        AND (relkind='r')
7772
 
                        AND (nspname=_schema)))) THEN
7773
 
          RAISE EXCEPTION 'Cannot create Table % as a Package Item without a corresponding table in the database.',
7774
 
            NEW.pkgitem_name;
7775
 
        END IF;
7776
 
 
7777
 
      ELSIF (NEW.pkgitem_type = 'U') THEN
7778
 
        IF (NOT EXISTS(SELECT uiform_id
7779
 
                       FROM uiform
7780
 
                       WHERE ((uiform_id=NEW.pkgitem_item_id)
7781
 
                          AND (uiform_name=NEW.pkgitem_name)))) THEN
7782
 
          RAISE EXCEPTION 'Cannot create User Interface Form % as a Package Item without a corresponding uiform record.',
7783
 
            NEW.pkgitem_name;
7784
 
        END IF;
7785
 
 
7786
 
      ELSIF (NEW.pkgitem_type = 'V') THEN
7787
 
        IF (NOT EXISTS(SELECT pg_class.oid
7788
 
                     FROM pg_class, pg_namespace
7789
 
                     WHERE ((relname=_object)
7790
 
                        AND (relnamespace=pg_namespace.oid)
7791
 
                        AND (relkind='v')
7792
 
                        AND (nspname=_schema)))) THEN
7793
 
          RAISE EXCEPTION 'Cannot create View % as a Package Item without a corresponding view in the database.',
7794
 
            NEW.pkgitem_name;
7795
 
        END IF;
7796
 
 
7797
 
      ELSE
7798
 
        RAISE EXCEPTION '"%" is not a valid type of package item.',
7799
 
          NEW.pkgitem_type;
7800
 
      END IF;
7801
 
 
7802
 
    ELSIF (TG_OP = 'DELETE') THEN
7803
 
      IF _debug THEN RAISE NOTICE 'Deleting % % %', OLD.pkgitem_item_id, OLD.pkgitem_name, OLD.pkgitem_type; END IF;
7804
 
 
7805
 
      _object = OLD.pkgitem_name;
7806
 
 
7807
 
      SELECT pkghead_name INTO _schema
7808
 
      FROM pkghead
7809
 
      WHERE (pkghead_id=OLD.pkgitem_pkghead_id);
7810
 
      IF (NOT FOUND) THEN
7811
 
        _schema := 'public';
7812
 
      END IF;
7813
 
 
7814
 
      IF (OLD.pkgitem_type = 'F') THEN
7815
 
        _object := SPLIT_PART(_object, '(', 1);
7816
 
      ELSIF (OLD.pkgitem_type = 'M') THEN
7817
 
        _group  := SPLIT_PART(_object, '-', 1);
7818
 
        _object := SPLIT_PART(_object, '-', 2);
7819
 
      END IF;
7820
 
      IF _debug THEN
7821
 
        RAISE NOTICE '_schema % and _object %', _schema, _object;
7822
 
      END IF;
7823
 
 
7824
 
      IF (OLD.pkgitem_type = 'C') THEN
7825
 
        DELETE FROM script WHERE ((script_id=OLD.pkgitem_item_id)
7826
 
                              AND (script_name=OLD.pkgitem_name));
7827
 
 
7828
 
      ELSIF (OLD.pkgitem_type = 'D') THEN
7829
 
        DELETE FROM cmd
7830
 
          WHERE ((cmd_id=OLD.pkgitem_item_id)
7831
 
            AND  (cmd_name=OLD.pkgitem_name));
7832
 
 
7833
 
      ELSIF (OLD.pkgitem_type = 'F') THEN
7834
 
        -- SELECT dropIfExists('FUNCTION', CAST (oid::regprocedure AS TEXT), _schema)
7835
 
        PERFORM dropIfExists('FUNCTION',
7836
 
                            proname || '(' ||
7837
 
                            oidvectortypes(proargtypes) || ')',
7838
 
                            _schema)
7839
 
        FROM pg_proc
7840
 
        WHERE (oid=OLD.pkgitem_item_id);
7841
 
 
7842
 
      ELSIF (OLD.pkgitem_type = 'G') THEN
7843
 
        PERFORM dropIfExists('TRIGGER', _object, _schema);
7844
 
 
7845
 
      ELSIF (OLD.pkgitem_type = 'I') THEN
7846
 
        DELETE FROM image WHERE ((image_id=OLD.pkgitem_item_id)
7847
 
                             AND (image_name=OLD.pkgitem_name));
7848
 
 
7849
 
      ELSIF (OLD.pkgitem_type = 'M') THEN
7850
 
        DELETE FROM metasql WHERE ((metasql_id=OLD.pkgitem_item_id)
7851
 
                               AND (metasql_group=_group)
7852
 
                               AND (metasql_name=_object));
7853
 
 
7854
 
      ELSIF (OLD.pkgitem_type = 'P') THEN
7855
 
        DELETE FROM priv
7856
 
        WHERE ((priv_id=OLD.pkgitem_item_id) 
7857
 
           AND (priv_name=OLD.pkgitem_name));
7858
 
 
7859
 
      ELSIF (OLD.pkgitem_type = 'R') THEN
7860
 
        DELETE FROM report
7861
 
        WHERE ((report_id=OLD.pkgitem_item_id)
7862
 
           AND (report_name=OLD.pkgitem_name));
7863
 
 
7864
 
      ELSIF (OLD.pkgitem_type = 'S') THEN
7865
 
        PERFORM dropIfExists('SCHEMA', OLD.pkgitem_name, OLD.pkgitem_name);
7866
 
 
7867
 
      ELSIF (OLD.pkgitem_type = 'T') THEN
7868
 
        PERFORM dropIfExists('TABLE', _object, _schema, true);
7869
 
 
7870
 
      ELSIF (OLD.pkgitem_type = 'U') THEN
7871
 
        DELETE FROM uiform
7872
 
        WHERE ((uiform_id=OLD.pkgitem_item_id)
7873
 
           AND (uiform_name=OLD.pkgitem_name));
7874
 
 
7875
 
      ELSIF (OLD.pkgitem_type = 'V') THEN
7876
 
        PERFORM dropIfExists('VIEW', _object, _schema, true);
7877
 
 
7878
 
      ELSE
7879
 
        RAISE EXCEPTION '"%" is not a valid type of package item.',
7880
 
          OLD.pkgitem_type;
7881
 
      END IF;
7882
 
      RETURN OLD;
7883
 
    END IF;
7884
 
 
7885
 
    RETURN NEW;
7886
 
  END;
7887
 
$$;
7888
 
 
7889
 
 
7890
 
ALTER FUNCTION public._pkgitembeforetrigger() OWNER TO admin;
7891
 
 
7892
 
--
7893
 
--
7894
 
 
7895
 
CREATE FUNCTION _pkgmetasqlaftertrigger() RETURNS trigger
7896
 
    LANGUAGE plpgsql
7897
 
    AS $$
7898
 
BEGIN
7899
 
  IF (TG_OP = 'DELETE') THEN
7900
 
    RETURN OLD;
7901
 
  END IF;
7902
 
 
7903
 
  RETURN NEW;
7904
 
END;
7905
 
$$;
7906
 
 
7907
 
 
7908
 
ALTER FUNCTION public._pkgmetasqlaftertrigger() OWNER TO admin;
7909
 
 
7910
 
--
7911
 
--
7912
 
 
7913
 
CREATE FUNCTION _pkgmetasqlaltertrigger() RETURNS trigger
7914
 
    LANGUAGE plpgsql
7915
 
    AS $$
7916
 
BEGIN
7917
 
  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
7918
 
    IF (TG_OP = 'DELETE') THEN
7919
 
      RETURN OLD;
7920
 
    ELSE
7921
 
      RETURN NEW;
7922
 
    END IF;
7923
 
  END IF;
7924
 
 
7925
 
  -- cannot combine IF's because plpgsql does not always evaluate left-to-right
7926
 
  IF (TG_OP = 'INSERT') THEN
7927
 
    IF (NEW.metasql_grade <= 0 AND NOT _isdba) THEN
7928
 
      RAISE EXCEPTION 'You may not create grade 0 MetaSQL statements in packages except using the xTuple Updater utility';
7929
 
    END IF;
7930
 
 
7931
 
  ELSIF (TG_OP = 'UPDATE') THEN
7932
 
    IF (NEW.metasql_grade <= 0 AND NOT _isdba) THEN
7933
 
      RAISE EXCEPTION 'You may not alter grade 0 MetaSQL statements in packages except using the xTuple Updater utility';
7934
 
    END IF;
7935
 
 
7936
 
  ELSIF (TG_OP = 'DELETE') THEN
7937
 
    IF (OLD.metasql_grade <= 0 AND NOT _isdba) THEN
7938
 
      RAISE EXCEPTION 'You may not delete grade 0 MetaSQL statements from packages. Try deleting or disabling the package.';
7939
 
    ELSE
7940
 
      RETURN OLD;
7941
 
    END IF;
7942
 
 
7943
 
  END IF;
7944
 
 
7945
 
  RETURN NEW;
7946
 
END;
7947
 
$$;
7948
 
 
7949
 
 
7950
 
ALTER FUNCTION public._pkgmetasqlaltertrigger() OWNER TO admin;
7951
 
 
7952
 
--
7953
 
--
7954
 
 
7955
 
CREATE FUNCTION _pkgmetasqlbeforetrigger() RETURNS trigger
7956
 
    LANGUAGE plpgsql
7957
 
    AS $$
7958
 
DECLARE
7959
 
  _metasqlid    INTEGER;
7960
 
  _isdba        BOOLEAN := false;
7961
 
 
7962
 
BEGIN
7963
 
  SELECT rolsuper INTO _isdba FROM pg_roles WHERE (rolname=getEffectiveXtUser());
7964
 
 
7965
 
  IF (NOT (_isdba OR checkPrivilege('MaintainMetaSQL'))) THEN
7966
 
    RAISE EXCEPTION '% does not have privileges to maintain MetaSQL statements in %.% (DBA=%)',
7967
 
                getEffectiveXtUser(), TG_TABLE_SCHEMA, TG_TABLE_NAME, _isdba;
7968
 
  END IF;
7969
 
 
7970
 
  IF (TG_OP = 'UPDATE') THEN
7971
 
    RAISE DEBUG 'update OLD %-%-%, NEW %-%-%',
7972
 
                 OLD.metasql_group, OLD.metasql_name, OLD.metasql_grade,
7973
 
                 NEW.metasql_group, NEW.metasql_name, NEW.metasql_grade;
7974
 
 
7975
 
    IF (NEW.metasql_name != OLD.metasql_name OR NEW.metasql_group != OLD.metasql_group OR NEW.metasql_grade != OLD.metasql_grade) THEN
7976
 
      SELECT metasql_id INTO _metasqlid
7977
 
      FROM metasql
7978
 
      WHERE metasql_name=NEW.metasql_name AND metasql_group=NEW.metasql_group AND metasql_grade=NEW.metasql_grade;
7979
 
      IF (FOUND) THEN
7980
 
        RAISE EXCEPTION 'Cannot change the MetaSQL statement named %-%-% because another MetaSQL statement with that group, name and grade already exists.', NEW.metasql_group, NEW.metasql_name, NEW.metasql_grade;
7981
 
      END IF;
7982
 
    END IF;
7983
 
 
7984
 
  ELSIF (TG_OP = 'INSERT') THEN
7985
 
    RAISE DEBUG 'insert NEW %-% %',
7986
 
                 NEW.metasql_group, NEW.metasql_name, NEW.metasql_grade;
7987
 
    SELECT metasql_id INTO _metasqlid
7988
 
    FROM metasql
7989
 
    WHERE metasql_name=NEW.metasql_name AND metasql_group=NEW.metasql_group AND metasql_grade=NEW.metasql_grade;
7990
 
    IF (FOUND) THEN
7991
 
      RAISE EXCEPTION 'The new MetaSQL statement %-% % conflicts with an existing statement.',
7992
 
                      NEW.metasql_group, NEW.metasql_name, NEW.metasql_grade;
7993
 
    END IF;
7994
 
 
7995
 
  ELSIF (TG_OP = 'DELETE') THEN
7996
 
    RETURN OLD;
7997
 
  END IF;
7998
 
 
7999
 
  RETURN NEW;
8000
 
END;
8001
 
$$;
8002
 
 
8003
 
 
8004
 
ALTER FUNCTION public._pkgmetasqlbeforetrigger() OWNER TO admin;
8005
 
 
8006
 
--
8007
 
--
8008
 
 
8009
 
CREATE FUNCTION _pkgprivaftertrigger() RETURNS trigger
8010
 
    LANGUAGE plpgsql
8011
 
    AS $$
8012
 
BEGIN
8013
 
  IF (TG_OP = 'DELETE') THEN
8014
 
    RETURN OLD;
8015
 
  END IF;
8016
 
 
8017
 
  RETURN NEW;
8018
 
END;
8019
 
$$;
8020
 
 
8021
 
 
8022
 
ALTER FUNCTION public._pkgprivaftertrigger() OWNER TO admin;
8023
 
 
8024
 
--
8025
 
--
8026
 
 
8027
 
CREATE FUNCTION _pkgprivaltertrigger() RETURNS trigger
8028
 
    LANGUAGE plpgsql
8029
 
    AS $$
8030
 
BEGIN
8031
 
  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
8032
 
    IF (TG_OP = 'DELETE') THEN
8033
 
      RETURN OLD;
8034
 
    ELSE
8035
 
      RETURN NEW;
8036
 
    END IF;
8037
 
  END IF;
8038
 
 
8039
 
  IF (TG_OP = 'INSERT') THEN
8040
 
    RAISE EXCEPTION 'You may not create privileges in packages except using the xTuple Updater utility';
8041
 
 
8042
 
  ELSIF (TG_OP = 'UPDATE') THEN
8043
 
    RAISE EXCEPTION 'You may not alter privileges in packages except using the xTuple Updater utility';
8044
 
 
8045
 
  ELSIF (TG_OP = 'DELETE') THEN
8046
 
    RAISE EXCEPTION 'You may not delete privileges from packages. Try deleting or disabling the package.';
8047
 
 
8048
 
  END IF;
8049
 
 
8050
 
  RETURN NEW;
8051
 
END;
8052
 
 
8053
 
$$;
8054
 
 
8055
 
 
8056
 
ALTER FUNCTION public._pkgprivaltertrigger() OWNER TO admin;
8057
 
 
8058
 
--
8059
 
--
8060
 
 
8061
 
CREATE FUNCTION _pkgprivbeforetrigger() RETURNS trigger
8062
 
    LANGUAGE plpgsql
8063
 
    AS $$
8064
 
DECLARE
8065
 
  _privid       INTEGER;
8066
 
  _debug        BOOL := false;
8067
 
 
8068
 
BEGIN
8069
 
  IF (TG_OP = 'UPDATE') THEN
8070
 
    IF (_debug) THEN
8071
 
      RAISE NOTICE 'OLD.priv_name %, NEW.priv_name %',
8072
 
                   OLD.priv_name, NEW.priv_name;
8073
 
    END IF;
8074
 
 
8075
 
    IF (NEW.priv_name != OLD.priv_name) THEN
8076
 
      SELECT priv_id INTO _privid FROM priv WHERE priv_name=NEW.priv_name;
8077
 
      IF (FOUND) THEN
8078
 
        RAISE EXCEPTION 'Cannot change privilege name % because another privilege with that name already exists.', NEW.priv_name;
8079
 
      END IF;
8080
 
    END IF;
8081
 
 
8082
 
  ELSIF (TG_OP = 'INSERT') THEN
8083
 
    IF (_debug) THEN
8084
 
      RAISE NOTICE 'inserting NEW.priv_name %', NEW.priv_name;
8085
 
    END IF;
8086
 
    SELECT priv_id INTO _privid FROM priv WHERE priv_name=NEW.priv_name;
8087
 
    IF (FOUND) THEN
8088
 
      RAISE EXCEPTION 'Cannot create new privilege % because another privilege with that name already exists.', NEW.priv_name;
8089
 
    END IF;
8090
 
 
8091
 
  ELSIF (TG_OP = 'DELETE') THEN
8092
 
    IF (_debug) THEN RAISE NOTICE 'deleting pkgpriv_id %', OLD.priv_id; END IF;
8093
 
    DELETE FROM usrpriv WHERE usrpriv_priv_id=OLD.priv_id;
8094
 
    DELETE FROM grppriv WHERE grppriv_priv_id=OLD.priv_id;
8095
 
 
8096
 
    RETURN OLD;
8097
 
  END IF;
8098
 
 
8099
 
  RETURN NEW;
8100
 
END;
8101
 
$$;
8102
 
 
8103
 
 
8104
 
ALTER FUNCTION public._pkgprivbeforetrigger() OWNER TO admin;
8105
 
 
8106
 
--
8107
 
--
8108
 
 
8109
 
CREATE FUNCTION _pkgreportaftertrigger() RETURNS trigger
8110
 
    LANGUAGE plpgsql
8111
 
    AS $$
8112
 
BEGIN
8113
 
  IF (TG_OP = 'DELETE') THEN
8114
 
    RETURN OLD;
8115
 
  END IF;
8116
 
 
8117
 
  RETURN NEW;
8118
 
END;
8119
 
$$;
8120
 
 
8121
 
 
8122
 
ALTER FUNCTION public._pkgreportaftertrigger() OWNER TO admin;
8123
 
 
8124
 
--
8125
 
--
8126
 
 
8127
 
CREATE FUNCTION _pkgreportaltertrigger() RETURNS trigger
8128
 
    LANGUAGE plpgsql
8129
 
    AS $$
8130
 
BEGIN
8131
 
  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
8132
 
    IF (TG_OP = 'DELETE') THEN
8133
 
      RETURN OLD;
8134
 
    ELSE
8135
 
      RETURN NEW;
8136
 
    END IF;
8137
 
  END IF;
8138
 
 
8139
 
  IF (TG_OP = 'INSERT') THEN
8140
 
    RAISE EXCEPTION 'You may not create report definitions in packages except using the xTuple Updater utility';
8141
 
 
8142
 
  ELSIF (TG_OP = 'UPDATE') THEN
8143
 
    RAISE EXCEPTION 'You may not alter report definitions in packages except using the xTuple Updater utility';
8144
 
 
8145
 
  ELSIF (TG_OP = 'DELETE') THEN
8146
 
    RAISE EXCEPTION 'You may not delete report definitions from packages. Try deleting or disabling the package.';
8147
 
 
8148
 
  END IF;
8149
 
 
8150
 
  RETURN NEW;
8151
 
END;
8152
 
$$;
8153
 
 
8154
 
 
8155
 
ALTER FUNCTION public._pkgreportaltertrigger() OWNER TO admin;
8156
 
 
8157
 
--
8158
 
--
8159
 
 
8160
 
CREATE FUNCTION _pkgreportbeforetrigger() RETURNS trigger
8161
 
    LANGUAGE plpgsql
8162
 
    AS $$
8163
 
DECLARE
8164
 
  _reportid     INTEGER;
8165
 
  _debug        BOOL := false;
8166
 
 
8167
 
BEGIN
8168
 
  IF (TG_OP = 'UPDATE') THEN
8169
 
    IF (_debug) THEN
8170
 
      RAISE NOTICE 'update OLD % %, NEW % %',
8171
 
                   OLD.report_name, OLD.report_grade, NEW.report_name, NEW.report_grade;
8172
 
    END IF;
8173
 
 
8174
 
    IF (NEW.report_name != OLD.report_name) THEN
8175
 
      SELECT report_id INTO _reportid
8176
 
      FROM report
8177
 
      WHERE ((report_name=NEW.report_name)
8178
 
        AND  (report_grade=NEW.report_grade));
8179
 
      IF (FOUND) THEN
8180
 
        RAISE EXCEPTION 'Cannot change report % % because another report with that name and grade already exists.', NEW.report_name, NEW.report_grade;
8181
 
      END IF;
8182
 
    END IF;
8183
 
 
8184
 
  ELSIF (TG_OP = 'INSERT') THEN
8185
 
    IF (_debug) THEN
8186
 
      RAISE NOTICE 'insert NEW % %', NEW.report_name, NEW.report_grade;
8187
 
    END IF;
8188
 
    SELECT report_id INTO _reportid
8189
 
    FROM report
8190
 
    WHERE ((report_name=NEW.report_name)
8191
 
      AND  (report_grade=NEW.report_grade));
8192
 
    IF (FOUND) THEN
8193
 
      RAISE EXCEPTION 'Cannot create new report % % because another report with that name and grade already exists.', NEW.report_name, NEW.report_grade;
8194
 
    END IF;
8195
 
 
8196
 
  ELSIF (TG_OP = 'DELETE') THEN
8197
 
 
8198
 
    RETURN OLD;
8199
 
  END IF;
8200
 
 
8201
 
  RETURN NEW;
8202
 
END;
8203
 
$$;
8204
 
 
8205
 
 
8206
 
ALTER FUNCTION public._pkgreportbeforetrigger() OWNER TO admin;
8207
 
 
8208
 
--
8209
 
--
8210
 
 
8211
 
CREATE FUNCTION _pkgscriptaftertrigger() RETURNS trigger
8212
 
    LANGUAGE plpgsql
8213
 
    AS $$
8214
 
BEGIN
8215
 
  IF (TG_OP = 'DELETE') THEN
8216
 
    RETURN OLD;
8217
 
  END IF;
8218
 
 
8219
 
  RETURN NEW;
8220
 
END;
8221
 
$$;
8222
 
 
8223
 
 
8224
 
ALTER FUNCTION public._pkgscriptaftertrigger() OWNER TO admin;
8225
 
 
8226
 
--
8227
 
--
8228
 
 
8229
 
CREATE FUNCTION _pkgscriptaltertrigger() RETURNS trigger
8230
 
    LANGUAGE plpgsql
8231
 
    AS $$
8232
 
BEGIN
8233
 
  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
8234
 
    IF (TG_OP = 'DELETE') THEN
8235
 
      RETURN OLD;
8236
 
    ELSE
8237
 
      RETURN NEW;
8238
 
    END IF;
8239
 
  END IF;
8240
 
 
8241
 
  IF (TG_OP = 'INSERT') THEN
8242
 
    RAISE EXCEPTION 'You may not create scripts in packages except using the xTuple Updater utility';
8243
 
 
8244
 
  ELSIF (TG_OP = 'UPDATE') THEN
8245
 
    RAISE EXCEPTION 'You may not alter scripts in packages except using the xTuple Updater utility';
8246
 
 
8247
 
  ELSIF (TG_OP = 'DELETE') THEN
8248
 
    RAISE EXCEPTION 'You may not delete scripts from packages. Try deleting or disabling the package.';
8249
 
 
8250
 
  END IF;
8251
 
 
8252
 
  RETURN NEW;
8253
 
END;
8254
 
$$;
8255
 
 
8256
 
 
8257
 
ALTER FUNCTION public._pkgscriptaltertrigger() OWNER TO admin;
8258
 
 
8259
 
--
8260
 
--
8261
 
 
8262
 
CREATE FUNCTION _pkgscriptbeforetrigger() RETURNS trigger
8263
 
    LANGUAGE plpgsql
8264
 
    AS $$
8265
 
DECLARE
8266
 
  _scriptid     INTEGER;
8267
 
  _debug        BOOL := false;
8268
 
 
8269
 
BEGIN
8270
 
  IF (TG_OP = 'UPDATE') THEN
8271
 
    RETURN NEW;
8272
 
 
8273
 
  ELSIF (TG_OP = 'INSERT') THEN
8274
 
    RETURN NEW;
8275
 
 
8276
 
  ELSIF (TG_OP = 'DELETE') THEN
8277
 
    RETURN OLD;
8278
 
  END IF;
8279
 
 
8280
 
  RETURN NEW;
8281
 
END;
8282
 
$$;
8283
 
 
8284
 
 
8285
 
ALTER FUNCTION public._pkgscriptbeforetrigger() OWNER TO admin;
8286
 
 
8287
 
--
8288
 
--
8289
 
 
8290
 
CREATE FUNCTION _pkguiformaftertrigger() RETURNS trigger
8291
 
    LANGUAGE plpgsql
8292
 
    AS $$
8293
 
BEGIN
8294
 
  IF (TG_OP = 'DELETE') THEN
8295
 
    RETURN OLD;
8296
 
  END IF;
8297
 
 
8298
 
  RETURN NEW;
8299
 
END;
8300
 
$$;
8301
 
 
8302
 
 
8303
 
ALTER FUNCTION public._pkguiformaftertrigger() OWNER TO admin;
8304
 
 
8305
 
--
8306
 
--
8307
 
 
8308
 
CREATE FUNCTION _pkguiformaltertrigger() RETURNS trigger
8309
 
    LANGUAGE plpgsql
8310
 
    AS $$
8311
 
BEGIN
8312
 
  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
8313
 
    IF (TG_OP = 'DELETE') THEN
8314
 
      RETURN OLD;
8315
 
    ELSE
8316
 
      RETURN NEW;
8317
 
    END IF;
8318
 
  END IF;
8319
 
 
8320
 
  IF (TG_OP = 'INSERT') THEN
8321
 
    RAISE EXCEPTION 'You may not create forms in packages except using the xTuple Updater utility';
8322
 
 
8323
 
  ELSIF (TG_OP = 'UPDATE') THEN
8324
 
    RAISE EXCEPTION 'You may not alter forms in packages except using the xTuple Updater utility';
8325
 
 
8326
 
  ELSIF (TG_OP = 'DELETE') THEN
8327
 
    RAISE EXCEPTION 'You may not delete forms from packages. Try deleting or disabling the package.';
8328
 
 
8329
 
  END IF;
8330
 
 
8331
 
  RETURN NEW;
8332
 
END;
8333
 
 
8334
 
$$;
8335
 
 
8336
 
 
8337
 
ALTER FUNCTION public._pkguiformaltertrigger() OWNER TO admin;
8338
 
 
8339
 
--
8340
 
--
8341
 
 
8342
 
CREATE FUNCTION _pkguiformbeforetrigger() RETURNS trigger
8343
 
    LANGUAGE plpgsql
8344
 
    AS $$
8345
 
DECLARE
8346
 
  _uiformid     INTEGER;
8347
 
  _debug        BOOL := false;
8348
 
 
8349
 
BEGIN
8350
 
  IF (TG_OP = 'UPDATE') THEN
8351
 
    RETURN NEW;
8352
 
 
8353
 
  ELSIF (TG_OP = 'INSERT') THEN
8354
 
    RETURN NEW;
8355
 
 
8356
 
  ELSIF (TG_OP = 'DELETE') THEN
8357
 
    RETURN OLD;
8358
 
  END IF;
8359
 
 
8360
 
  RETURN NEW;
8361
 
END;
8362
 
$$;
8363
 
 
8364
 
 
8365
 
ALTER FUNCTION public._pkguiformbeforetrigger() OWNER TO admin;
8366
 
 
8367
 
--
8368
 
--
8369
 
 
8370
 
CREATE FUNCTION _poheadtrigger() RETURNS trigger
8371
 
    LANGUAGE plpgsql
8372
 
    AS $$
8373
 
DECLARE
8374
 
  _cmnttypeid   INTEGER;
8375
 
  _check        BOOLEAN;
8376
 
  _maint        BOOLEAN := TRUE;
8377
 
 
8378
 
BEGIN
8379
 
 
8380
 
  IF (TG_OP = 'UPDATE') THEN
8381
 
    IF ( (OLD.pohead_status           != NEW.pohead_status) OR
8382
 
         (OLD.pohead_printed          != NEW.pohead_printed) ) THEN
8383
 
      _maint := FALSE;
8384
 
    END IF;
8385
 
  END IF;
8386
 
 
8387
 
  -- Check
8388
 
  IF ( (NOT _maint) AND (NOT checkPrivilege('MaintainPurchaseOrders'))
8389
 
                    AND (NOT checkPrivilege('PostPurchaseOrders'))
8390
 
                    AND (NOT checkPrivilege('PrintPurchaseOrders'))
8391
 
                    AND (NOT checkPrivilege('PostVouchers')) ) THEN
8392
 
    RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.';
8393
 
  END IF;
8394
 
 
8395
 
  IF ( _maint AND (NOT checkPrivilege('MaintainPurchaseOrders')) ) THEN
8396
 
    RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.';
8397
 
  END IF;
8398
 
 
8399
 
  IF (TG_OP = 'INSERT') THEN
8400
 
    --- clear the number from the issue cache
8401
 
    PERFORM clearNumberIssue('PoNumber', NEW.pohead_number);
8402
 
  END IF;
8403
 
 
8404
 
  IF ( (TG_OP = 'INSERT') OR (TG_op = 'UPDATE') ) THEN
8405
 
    IF (NOT ISNUMERIC(NEW.pohead_number) AND NEW.pohead_saved) THEN
8406
 
      RAISE EXCEPTION 'Purchase Order Number must be numeric.';
8407
 
    END IF;
8408
 
  END IF;
8409
 
 
8410
 
  IF ( SELECT (metric_value='t')
8411
 
       FROM metric
8412
 
       WHERE (metric_name='POChangeLog') ) THEN
8413
 
 
8414
 
    SELECT cmnttype_id INTO _cmnttypeid
8415
 
    FROM cmnttype
8416
 
    WHERE (cmnttype_name='ChangeLog');
8417
 
    IF (FOUND) THEN
8418
 
      IF (TG_OP = 'INSERT') THEN
8419
 
        PERFORM postComment(_cmnttypeid, 'P', NEW.pohead_id, 'Created');
8420
 
 
8421
 
      ELSIF (TG_OP = 'UPDATE') THEN
8422
 
        IF (OLD.pohead_terms_id <> NEW.pohead_terms_id) THEN
8423
 
          PERFORM postComment( _cmnttypeid, 'P', NEW.pohead_id,
8424
 
                               ('Terms Changed from "' || oldterms.terms_code || '" to "' || newterms.terms_code || '"') )
8425
 
          FROM terms AS oldterms, terms AS newterms
8426
 
          WHERE ( (oldterms.terms_id=OLD.pohead_terms_id)
8427
 
           AND (newterms.terms_id=NEW.pohead_terms_id) );
8428
 
        END IF;
8429
 
 
8430
 
      ELSIF (TG_OP = 'DELETE') THEN
8431
 
        DELETE FROM docass WHERE docass_source_id = OLD.pohead_id AND docass_source_type = 'P';
8432
 
        DELETE FROM docass WHERE docass_target_id = OLD.pohead_id AND docass_target_type = 'P';
8433
 
 
8434
 
        DELETE FROM comment
8435
 
        WHERE ( (comment_source='P')
8436
 
         AND (comment_source_id=OLD.pohead_id) );
8437
 
      END IF;
8438
 
    END IF;
8439
 
  END IF;
8440
 
 
8441
 
  IF (TG_OP = 'DELETE') THEN
8442
 
    RETURN OLD;
8443
 
  ELSE
8444
 
    RETURN NEW;
8445
 
  END IF;
8446
 
 
8447
 
END;
8448
 
$$;
8449
 
 
8450
 
 
8451
 
ALTER FUNCTION public._poheadtrigger() OWNER TO admin;
8452
 
 
8453
 
--
8454
 
--
8455
 
 
8456
 
CREATE FUNCTION _poheadtriggerafter() RETURNS trigger
8457
 
    LANGUAGE plpgsql
8458
 
    AS $$
8459
 
BEGIN
8460
 
  IF (COALESCE(NEW.pohead_taxzone_id,-1) <> COALESCE(OLD.pohead_taxzone_id,-1)) THEN
8461
 
    UPDATE poitem SET poitem_taxtype_id=getItemTaxType(itemsite_item_id,NEW.pohead_taxzone_id)
8462
 
    FROM itemsite
8463
 
    WHERE ((itemsite_id=poitem_itemsite_id)
8464
 
     AND (poitem_pohead_id=NEW.pohead_id));
8465
 
  END IF;
8466
 
 
8467
 
  -- Do not update closed poitems
8468
 
  IF (TG_OP = 'UPDATE') THEN
8469
 
    IF (OLD.pohead_status != NEW.pohead_status) THEN
8470
 
      UPDATE poitem
8471
 
      SET poitem_status=NEW.pohead_status
8472
 
      WHERE ( (poitem_pohead_id=NEW.pohead_id)
8473
 
        AND   (poitem_status <> 'C') );
8474
 
    END IF;
8475
 
  END IF;
8476
 
 
8477
 
  RETURN NEW;
8478
 
END;
8479
 
$$;
8480
 
 
8481
 
 
8482
 
ALTER FUNCTION public._poheadtriggerafter() OWNER TO admin;
8483
 
 
8484
 
--
8485
 
--
8486
 
 
8487
 
CREATE FUNCTION _poitemafterdeletetrigger() RETURNS trigger
8488
 
    LANGUAGE plpgsql
8489
 
    AS $$
8490
 
DECLARE
8491
 
  _changelog BOOLEAN := FALSE;
8492
 
BEGIN
8493
 
 
8494
 
  IF (OLD.poitem_status = 'O') THEN
8495
 
    IF ( (SELECT (count(*) < 1)
8496
 
            FROM poitem
8497
 
           WHERE ((poitem_pohead_id=OLD.poitem_pohead_id)
8498
 
             AND  (poitem_id != OLD.poitem_id)
8499
 
             AND  (poitem_status <> 'C')) ) ) THEN
8500
 
      UPDATE pohead SET pohead_status = 'C'
8501
 
       WHERE ((pohead_id=OLD.poitem_pohead_id)
8502
 
         AND  (pohead_status='O'));
8503
 
    END IF;
8504
 
  END IF;
8505
 
 
8506
 
  IF ( SELECT fetchMetricBool('POChangeLog') ) THEN
8507
 
    _changelog := TRUE;
8508
 
  END IF;
8509
 
 
8510
 
  IF ( _changelog ) THEN
8511
 
    PERFORM postComment('ChangeLog', 'P', OLD.poitem_pohead_id, ('Deleted Line #' || OLD.poitem_linenumber::TEXT));
8512
 
  END IF;
8513
 
 
8514
 
  RETURN OLD;
8515
 
END;
8516
 
$$;
8517
 
 
8518
 
 
8519
 
ALTER FUNCTION public._poitemafterdeletetrigger() OWNER TO admin;
8520
 
 
8521
 
--
8522
 
--
8523
 
 
8524
 
CREATE FUNCTION _poitemaftertrigger() RETURNS trigger
8525
 
    LANGUAGE plpgsql
8526
 
    AS $$
8527
 
DECLARE
8528
 
  _changelog BOOLEAN := FALSE;
8529
 
BEGIN
8530
 
 
8531
 
  IF (TG_OP = 'UPDATE') THEN
8532
 
    IF (OLD.poitem_status <> NEW.poitem_status) THEN
8533
 
      IF ( (SELECT (count(*) < 1)
8534
 
              FROM poitem
8535
 
             WHERE ((poitem_pohead_id=NEW.poitem_pohead_id)
8536
 
               AND  (poitem_id != NEW.poitem_id)
8537
 
               AND  (poitem_status<>'C')) ) AND (NEW.poitem_status='C') ) THEN
8538
 
        UPDATE pohead SET pohead_status = 'C'
8539
 
         WHERE ((pohead_id=NEW.poitem_pohead_id)
8540
 
           AND  (pohead_status='O'));
8541
 
      ELSE
8542
 
        UPDATE pohead SET pohead_status = 'O'
8543
 
         WHERE ((pohead_id=NEW.poitem_pohead_id)
8544
 
           AND  (pohead_status='C'));
8545
 
      END IF;
8546
 
    END IF;
8547
 
  END IF;
8548
 
 
8549
 
  IF (TG_OP = 'INSERT') THEN
8550
 
    PERFORM postEvent('POitemCreate', 'P', NEW.poitem_id,
8551
 
                      itemsite_warehous_id,
8552
 
                      (pohead_number || '-' || NEW.poitem_linenumber || ': ' || item_number),
8553
 
                      NULL, NULL, NULL, NULL)
8554
 
    FROM pohead JOIN itemsite ON (itemsite_id=NEW.poitem_itemsite_id)
8555
 
                JOIN item ON (item_id=itemsite_item_id)
8556
 
    WHERE (pohead_id=NEW.poitem_pohead_id)
8557
 
      AND (NEW.poitem_duedate <= (CURRENT_DATE + itemsite_eventfence));
8558
 
  END IF;
8559
 
 
8560
 
  IF ( SELECT fetchMetricBool('POChangeLog') ) THEN
8561
 
    _changelog := TRUE;
8562
 
  END IF;
8563
 
 
8564
 
  IF ( _changelog ) THEN
8565
 
    IF (TG_OP = 'INSERT') THEN
8566
 
      PERFORM postComment('ChangeLog', 'P', NEW.poitem_pohead_id, ('Created Line #' || NEW.poitem_linenumber::TEXT));
8567
 
      PERFORM postComment('ChangeLog', 'PI', NEW.poitem_id, 'Created');
8568
 
 
8569
 
    ELSIF (TG_OP = 'UPDATE') THEN
8570
 
      IF (NEW.poitem_qty_ordered <> OLD.poitem_qty_ordered) THEN
8571
 
        PERFORM postComment( 'ChangeLog', 'PI', NEW.poitem_id,
8572
 
                             ( 'Qty. Ordered Changed from ' || formatQty(OLD.poitem_qty_ordered) ||
8573
 
                               ' to ' || formatQty(NEW.poitem_qty_ordered ) ) );
8574
 
      END IF;
8575
 
      IF (NEW.poitem_unitprice <> OLD.poitem_unitprice) THEN
8576
 
        PERFORM postComment( 'ChangeLog', 'PI', NEW.poitem_id,
8577
 
                             ( 'Unit Price Changed from ' || formatPurchPrice(OLD.poitem_unitprice) ||
8578
 
                               ' to ' || formatPurchPrice(NEW.poitem_unitprice ) ) );
8579
 
      END IF;
8580
 
      IF (NEW.poitem_duedate <> OLD.poitem_duedate) THEN
8581
 
        PERFORM postComment( 'ChangeLog', 'PI', NEW.poitem_id,
8582
 
                             ( 'Due Date Changed from ' || formatDate(OLD.poitem_duedate) ||
8583
 
                               ' to ' || formatDate(NEW.poitem_duedate ) ) );
8584
 
      END IF;
8585
 
      IF (COALESCE(OLD.poitem_taxtype_id, -1) <> COALESCE(NEW.poitem_taxtype_id, -1)) THEN
8586
 
        PERFORM postComment( 'ChangeLog', 'PI', NEW.poitem_id,
8587
 
                             ( 'Tax Type Changed from "' ||
8588
 
                               COALESCE((SELECT taxtype_name FROM taxtype WHERE taxtype_id=OLD.poitem_taxtype_id), 'None') ||
8589
 
                               '" (' || COALESCE(OLD.poitem_taxtype_id, 0) ||
8590
 
                               ') to "' ||
8591
 
                               COALESCE((SELECT taxtype_name FROM taxtype WHERE taxtype_id=NEW.poitem_taxtype_id), 'None') ||
8592
 
                               '" (' || COALESCE(NEW.poitem_taxtype_id, 0) || ')' ) );
8593
 
      END IF;
8594
 
      IF (NEW.poitem_status <> OLD.poitem_status) THEN
8595
 
        IF (NEW.poitem_status = 'C') THEN
8596
 
          PERFORM postComment('ChangeLog', 'PI', NEW.poitem_id, 'Closed');
8597
 
        ELSIF (NEW.poitem_status = 'O') THEN
8598
 
          PERFORM postComment('ChangeLog', 'PI', NEW.poitem_id, 'Opened');
8599
 
        END IF;
8600
 
      END IF;
8601
 
 
8602
 
    END IF;
8603
 
  END IF;
8604
 
 
8605
 
  RETURN NEW;
8606
 
 
8607
 
END;
8608
 
$$;
8609
 
 
8610
 
 
8611
 
ALTER FUNCTION public._poitemaftertrigger() OWNER TO admin;
8612
 
 
8613
 
--
8614
 
--
8615
 
 
8616
 
CREATE FUNCTION _poitemdeletetrigger() RETURNS trigger
8617
 
    LANGUAGE plpgsql
8618
 
    AS $$
8619
 
DECLARE
8620
 
BEGIN
8621
 
 
8622
 
  IF (NOT checkPrivilege('MaintainPurchaseOrders')) THEN
8623
 
    RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.';
8624
 
  END IF;
8625
 
 
8626
 
  IF (EXISTS(SELECT recv_id
8627
 
             FROM recv
8628
 
             WHERE ((recv_order_type='PO')
8629
 
                AND (recv_orderitem_id=OLD.poitem_id)
8630
 
                AND (recv_qty>0)))) THEN
8631
 
    RAISE EXCEPTION 'Cannot delete an P/O Item which has been received';
8632
 
  END IF;
8633
 
 
8634
 
  DELETE FROM comment
8635
 
   WHERE ( (comment_source='PI')
8636
 
     AND   (comment_source_id=OLD.poitem_id) );
8637
 
 
8638
 
  DELETE FROM charass
8639
 
   WHERE ((charass_target_type='PI')
8640
 
     AND  (charass_target_id=OLD.poitem_id));
8641
 
 
8642
 
  RETURN OLD;
8643
 
 
8644
 
END;
8645
 
$$;
8646
 
 
8647
 
 
8648
 
ALTER FUNCTION public._poitemdeletetrigger() OWNER TO admin;
8649
 
 
8650
 
--
8651
 
--
8652
 
 
8653
 
CREATE FUNCTION _poitemtrigger() RETURNS trigger
8654
 
    LANGUAGE plpgsql
8655
 
    AS $$
8656
 
DECLARE
8657
 
  _cmnttypeid   INTEGER;
8658
 
  _status       CHAR(1);
8659
 
  _check        BOOLEAN;
8660
 
  _cnt          INTEGER;
8661
 
  _s            RECORD;
8662
 
BEGIN
8663
 
 
8664
 
  -- Check
8665
 
  IF ( (TG_OP = 'UPDATE') AND
8666
 
       (NOT checkPrivilege('MaintainPurchaseOrders')) AND
8667
 
       (NOT checkPrivilege('ChangePurchaseOrderQty')) AND
8668
 
       (NOT checkPrivilege('EnterReceipts')) AND
8669
 
       (NOT checkPrivilege('PostVouchers')) ) THEN
8670
 
    RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.';
8671
 
  END IF;
8672
 
  IF ( (TG_OP = 'INSERT') AND (NOT checkPrivilege('MaintainPurchaseOrders')) ) THEN
8673
 
    RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.';
8674
 
  END IF;
8675
 
 
8676
 
  IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN
8677
 
    SELECT pohead_status INTO _status
8678
 
    FROM pohead
8679
 
    WHERE (pohead_id=NEW.poitem_pohead_id);
8680
 
 
8681
 
    IF (NEW.poitem_itemsite_id=-1) THEN
8682
 
      NEW.poitem_itemsite_id := NULL;
8683
 
    END IF;
8684
 
    IF (NEW.poitem_expcat_id=-1) THEN
8685
 
      NEW.poitem_expcat_id := NULL;
8686
 
    END IF;
8687
 
 
8688
 
    IF (NEW.poitem_itemsite_id IS NOT NULL AND NEW.poitem_expcat_id IS NOT NULL) THEN
8689
 
      RAISE EXCEPTION 'A purchase order line may not include both an inventory and non-inventory item';
8690
 
    ELSIF (NEW.poitem_itemsite_id IS NULL AND NEW.poitem_expcat_id IS NULL) THEN
8691
 
      RAISE EXCEPTION 'A purchase order line must specify either an inventory item or a non-inventory expense category';
8692
 
    ELSIF (NEW.poitem_qty_ordered IS NULL) THEN
8693
 
      RAISE EXCEPTION 'A purchase order line must specify a quantity';
8694
 
    ELSIF (COALESCE(NEW.poitem_itemsite_id,-1) != -1) THEN
8695
 
      SELECT (COUNT(item_id)=1) INTO _check
8696
 
      FROM itemsite, item
8697
 
      WHERE ((itemsite_id=NEW.poitem_itemsite_id)
8698
 
      AND (itemsite_item_id=item_id)
8699
 
      AND (item_type IN ('P','O','M','T')));
8700
 
      IF NOT (_check) THEN
8701
 
        RAISE EXCEPTION 'The item is not a purchasable item type';
8702
 
      END IF;
8703
 
    END IF;
8704
 
  END IF;
8705
 
 
8706
 
  IF (TG_OP = 'INSERT') THEN
8707
 
    IF (_status='C') THEN
8708
 
      RAISE EXCEPTION 'New lines may not be inserted into a closed purchase order';
8709
 
    END IF;
8710
 
    
8711
 
    --Fetch and apply default item source data if applicable    
8712
 
    IF ((NEW.poitem_itemsrc_id IS NULL) AND (NEW.poitem_itemsite_id IS NOT NULL)) THEN
8713
 
      IF (NEW.poitem_itemsrc_id IS NULL) THEN
8714
 
        SELECT COUNT(itemsrc_id)  INTO _cnt
8715
 
        FROM pohead,itemsrc,itemsite
8716
 
        WHERE ((pohead_id=NEW.poitem_pohead_id)
8717
 
        AND (pohead_vend_id=itemsrc_vend_id)
8718
 
        AND (itemsite_id=NEW.poitem_itemsite_id)
8719
 
        AND (itemsite_item_id=itemsrc_item_id));
8720
 
 
8721
 
        IF (_cnt = 1) THEN
8722
 
          -- We found the one and only item source, so populate data for it
8723
 
          SELECT itemsrc.* INTO _s
8724
 
          FROM pohead,itemsrc,itemsite
8725
 
          WHERE ((pohead_id=NEW.poitem_pohead_id)
8726
 
          AND (pohead_vend_id=itemsrc_vend_id)
8727
 
          AND (itemsite_id=NEW.poitem_itemsite_id)
8728
 
          AND (itemsite_item_id=itemsrc_item_id));
8729
 
          IF (FOUND) THEN
8730
 
            NEW.poitem_itemsrc_id               := _s.itemsrc_id;
8731
 
            NEW.poitem_vend_uom                 := _s.itemsrc_vend_uom;
8732
 
            NEW.poitem_invvenduomratio          := _s.itemsrc_invvendoruomratio;
8733
 
            NEW.poitem_duedate                  := COALESCE(NEW.poitem_duedate, CURRENT_DATE + _s.itemsrc_leadtime);
8734
 
            NEW.poitem_vend_item_number         := COALESCE(NEW.poitem_vend_item_number,_s.itemsrc_vend_item_number);
8735
 
            NEW.poitem_vend_item_descrip        := COALESCE(NEW.poitem_vend_item_descrip,_s.itemsrc_vend_item_descrip);
8736
 
            NEW.poitem_manuf_name               := COALESCE(NEW.poitem_manuf_name,_s.itemsrc_manuf_name);
8737
 
            NEW.poitem_manuf_item_number        := COALESCE(NEW.poitem_manuf_item_number, _s.itemsrc_manuf_item_number);
8738
 
            NEW.poitem_manuf_item_descrip       := COALESCE(NEW.poitem_manuf_item_descrip, _s.itemsrc_manuf_item_descrip);
8739
 
          END IF;
8740
 
        ELSIF (_cnt > 1) THEN
8741
 
          -- There are multiple sources, see if there is an exact match with provided vendor info.
8742
 
          SELECT itemsrc.* INTO _s
8743
 
          FROM pohead,itemsrc,itemsite
8744
 
          WHERE ((pohead_id=NEW.poitem_pohead_id)
8745
 
          AND (pohead_vend_id=itemsrc_vend_id)
8746
 
          AND (itemsite_id=NEW.poitem_itemsite_id)
8747
 
          AND (itemsite_item_id=itemsrc_item_id)
8748
 
          AND (NEW.poitem_vend_item_number=itemsrc_vend_item_number)
8749
 
          AND (COALESCE(NEW.poitem_manuf_name,'')=COALESCE(itemsrc_manuf_name,''))
8750
 
          AND (COALESCE(NEW.poitem_manuf_item_number,'')=COALESCE(itemsrc_manuf_item_number,'')));
8751
 
          IF (FOUND) THEN
8752
 
            NEW.poitem_itemsrc_id               := _s.itemsrc_id;
8753
 
            NEW.poitem_vend_uom                 := _s.itemsrc_vend_uom;
8754
 
            NEW.poitem_invvenduomratio          := _s.itemsrc_invvendoruomratio;
8755
 
            NEW.poitem_duedate                  := COALESCE(NEW.poitem_duedate, CURRENT_DATE + _s.itemsrc_leadtime);
8756
 
            NEW.poitem_vend_item_descrip        := COALESCE(NEW.poitem_vend_item_descrip,_s.itemsrc_vend_item_descrip);
8757
 
            NEW.poitem_manuf_item_descrip       := COALESCE(NEW.poitem_manuf_item_descrip, _s.itemsrc_manuf_item_descrip);
8758
 
          END IF;
8759
 
        END IF;
8760
 
      END IF;
8761
 
    END IF;
8762
 
 
8763
 
    IF (NEW.poitem_duedate IS NULL) THEN
8764
 
      RAISE EXCEPTION  'A due date is required';
8765
 
    END IF;
8766
 
    
8767
 
    --Set defaults
8768
 
    NEW.poitem_linenumber               := COALESCE(NEW.poitem_linenumber,(
8769
 
                                                SELECT COALESCE(MAX(poitem_linenumber),0) + 1
8770
 
                                                FROM poitem
8771
 
                                                WHERE (poitem_pohead_id=NEW.poitem_pohead_id)));
8772
 
    NEW.poitem_status                  := _status;
8773
 
    NEW.poitem_invvenduomratio  := COALESCE(NEW.poitem_invvenduomratio,1);
8774
 
    IF (NEW.poitem_invvenduomratio = 0.0) THEN
8775
 
      NEW.poitem_invvenduomratio = 1.0;
8776
 
    END IF;
8777
 
    NEW.poitem_vend_item_number         := COALESCE(NEW.poitem_vend_item_number,'');
8778
 
    NEW.poitem_vend_item_descrip        := COALESCE(NEW.poitem_vend_item_descrip,'');
8779
 
    NEW.poitem_unitprice        := COALESCE(NEW.poitem_unitprice,(
8780
 
                                                SELECT itemsrcPrice(NEW.poitem_itemsrc_id, COALESCE(itemsite_warehous_id, -1), pohead_dropship,
8781
 
                                                       NEW.poitem_qty_ordered, pohead_curr_id, CURRENT_DATE)
8782
 
                                                FROM itemsite, pohead
8783
 
                                                WHERE ( (itemsite_id=NEW.poitem_itemsite_id)
8784
 
                                                AND (pohead_id=NEW.poitem_pohead_id) )), 0.0);
8785
 
    NEW.poitem_stdcost                  := COALESCE(NEW.poitem_stdcost,(
8786
 
                                                SELECT stdcost(itemsite_item_id)
8787
 
                                                FROM itemsite
8788
 
                                                WHERE (itemsite_id=NEW.poitem_itemsite_id)));
8789
 
    NEW.poitem_bom_rev_id               := COALESCE(NEW.poitem_bom_rev_id,(
8790
 
                                                SELECT getActiveRevId('BOM',itemsite_item_id)
8791
 
                                                FROM itemsite
8792
 
                                                WHERE (itemsite_id=NEW.poitem_itemsite_id)));
8793
 
    NEW.poitem_boo_rev_id               := COALESCE(NEW.poitem_boo_rev_id,(
8794
 
                                                SELECT getActiveRevId('BOO',itemsite_item_id)
8795
 
                                                FROM itemsite
8796
 
                                                WHERE (itemsite_id=NEW.poitem_itemsite_id)));
8797
 
    NEW.poitem_comments         := COALESCE(NEW.poitem_comments,'');
8798
 
    NEW.poitem_freight                  := COALESCE(NEW.poitem_freight,0);
8799
 
    NEW.poitem_qty_received             := 0;
8800
 
    NEW.poitem_qty_returned             := 0;
8801
 
    NEW.poitem_qty_vouchered            := 0;
8802
 
      
8803
 
  END IF;
8804
 
 
8805
 
  IF (TG_OP = 'UPDATE') THEN
8806
 
    IF (NEW.poitem_itemsite_id != OLD.poitem_itemsite_id) THEN
8807
 
      RAISE EXCEPTION 'You may not change the item site for a line item.';
8808
 
    ELSIF (NEW.poitem_expcat_id != OLD.poitem_expcat_id) THEN
8809
 
      RAISE EXCEPTION 'You may not change the expense category for a line item.';
8810
 
    END IF;
8811
 
  END IF;
8812
 
 
8813
 
  RETURN NEW;
8814
 
 
8815
 
END;
8816
 
$$;
8817
 
 
8818
 
 
8819
 
ALTER FUNCTION public._poitemtrigger() OWNER TO admin;
8820
 
 
8821
 
--
8822
 
--
8823
 
 
8824
 
CREATE FUNCTION _prjaftertrigger() RETURNS trigger
8825
 
    LANGUAGE plpgsql
8826
 
    AS $$
8827
 
DECLARE
8828
 
  _cmnttypeid INTEGER;
8829
 
BEGIN
8830
 
 
8831
 
  SELECT cmnttype_id INTO _cmnttypeid
8832
 
  FROM cmnttype
8833
 
  WHERE (cmnttype_name='ChangeLog');
8834
 
  IF (NOT FOUND) THEN
8835
 
    RAISE EXCEPTION 'Comment type ChangeLog not found';
8836
 
  END IF;
8837
 
 
8838
 
  IF (TG_OP = 'INSERT') THEN
8839
 
    PERFORM postComment(_cmnttypeid, 'J', NEW.prj_id, 'Created');
8840
 
  ELSIF (TG_OP = 'UPDATE') THEN
8841
 
    IF (OLD.prj_start_date <> NEW.prj_start_date) THEN
8842
 
      PERFORM postComment( _cmnttypeid, 'J', NEW.prj_id,
8843
 
                           ('Start Date Changed from ' || formatDate(OLD.prj_start_date) || ' to ' || formatDate(NEW.prj_start_date)) );
8844
 
    END IF;
8845
 
    IF (OLD.prj_due_date <> NEW.prj_due_date) THEN
8846
 
      PERFORM postComment( _cmnttypeid, 'J', NEW.prj_id,
8847
 
                           ('Due Date Changed from ' || formatDate(OLD.prj_due_date) || ' to ' || formatDate(NEW.prj_due_date)) );
8848
 
    END IF;
8849
 
    IF (OLD.prj_assigned_date <> NEW.prj_assigned_date) THEN
8850
 
      PERFORM postComment( _cmnttypeid, 'J', NEW.prj_id,
8851
 
                           ('Assigned Date Changed from ' || formatDate(OLD.prj_assigned_date) || ' to ' || formatDate(NEW.prj_assigned_date)) );
8852
 
    END IF;
8853
 
    IF (OLD.prj_completed_date <> NEW.prj_completed_date) THEN
8854
 
      PERFORM postComment( _cmnttypeid, 'J', NEW.prj_id,
8855
 
                           ('Completed Date Changed from ' || formatDate(OLD.prj_completed_date) || ' to ' || formatDate(NEW.prj_completed_date)) );
8856
 
    END IF;
8857
 
 
8858
 
  END IF;
8859
 
 
8860
 
  RETURN NEW;
8861
 
END;
8862
 
$$;
8863
 
 
8864
 
 
8865
 
ALTER FUNCTION public._prjaftertrigger() OWNER TO admin;
8866
 
 
8867
 
--
8868
 
--
8869
 
 
8870
 
CREATE FUNCTION _prjbeforedeletetrigger() RETURNS trigger
8871
 
    LANGUAGE plpgsql
8872
 
    AS $$
8873
 
DECLARE
8874
 
  _recurid     INTEGER;
8875
 
  _newparentid INTEGER;
8876
 
BEGIN
8877
 
 
8878
 
  IF (TG_OP = 'DELETE') THEN
8879
 
    DELETE FROM docass WHERE docass_source_id = OLD.prj_id AND docass_source_type = 'J';
8880
 
    DELETE FROM docass WHERE docass_target_id = OLD.prj_id AND docass_target_type = 'J';
8881
 
    
8882
 
    SELECT recur_id INTO _recurid
8883
 
      FROM recur
8884
 
     WHERE ((recur_parent_id=OLD.prj_id)
8885
 
        AND (recur_parent_type='J'));
8886
 
 
8887
 
    IF (_recurid IS NOT NULL) THEN
8888
 
      SELECT MIN(prj_id) INTO _newparentid
8889
 
        FROM prj
8890
 
       WHERE ((prj_recurring_prj_id=OLD.prj_id)
8891
 
          AND (prj_id!=OLD.prj_id));
8892
 
 
8893
 
      -- client is responsible for warning about deleting a recurring prj
8894
 
      IF (_newparentid IS NULL) THEN
8895
 
        DELETE FROM recur WHERE recur_id=_recurid;
8896
 
      ELSE
8897
 
        UPDATE recur SET recur_parent_id=_newparentid
8898
 
         WHERE recur_id=_recurid;
8899
 
      END IF;
8900
 
 
8901
 
    END IF;
8902
 
 
8903
 
    RETURN OLD;
8904
 
  END IF;
8905
 
 
8906
 
  RETURN NEW;
8907
 
END;
8908
 
$$;
8909
 
 
8910
 
 
8911
 
ALTER FUNCTION public._prjbeforedeletetrigger() OWNER TO admin;
8912
 
 
8913
 
--
8914
 
--
8915
 
 
8916
 
CREATE FUNCTION _prjtaskaftertrigger() RETURNS trigger
8917
 
    LANGUAGE plpgsql
8918
 
    AS $$
8919
 
DECLARE
8920
 
  _cmnttypeid INTEGER;
8921
 
BEGIN
8922
 
 
8923
 
  SELECT cmnttype_id INTO _cmnttypeid
8924
 
  FROM cmnttype
8925
 
  WHERE (cmnttype_name='ChangeLog');
8926
 
  IF (NOT FOUND) THEN
8927
 
    RAISE EXCEPTION 'Comment type ChangeLog not found';
8928
 
  END IF;
8929
 
 
8930
 
  IF (TG_OP = 'INSERT') THEN
8931
 
    PERFORM postComment(_cmnttypeid, 'TA', NEW.prjtask_id, 'Created');
8932
 
 
8933
 
  ELSIF (TG_OP = 'UPDATE') THEN
8934
 
    IF (OLD.prjtask_start_date <> NEW.prjtask_start_date) THEN
8935
 
      PERFORM postComment( _cmnttypeid, 'TA', NEW.prjtask_id,
8936
 
                           ('Start Date Changed from ' || formatDate(OLD.prjtask_start_date) || ' to ' || formatDate(NEW.prjtask_start_date)) );
8937
 
    END IF;
8938
 
    IF (OLD.prjtask_due_date <> NEW.prjtask_due_date) THEN
8939
 
      PERFORM postComment( _cmnttypeid, 'TA', NEW.prjtask_id,
8940
 
                           ('Due Date Changed from ' || formatDate(OLD.prjtask_due_date) || ' to ' || formatDate(NEW.prjtask_due_date)) );
8941
 
    END IF;
8942
 
    IF (OLD.prjtask_assigned_date <> NEW.prjtask_assigned_date) THEN
8943
 
      PERFORM postComment( _cmnttypeid, 'TA', NEW.prjtask_id,
8944
 
                           ('Assigned Date Changed from ' || formatDate(OLD.prjtask_assigned_date) || ' to ' || formatDate(NEW.prjtask_assigned_date)) );
8945
 
    END IF;
8946
 
    IF (OLD.prjtask_completed_date <> NEW.prjtask_completed_date) THEN
8947
 
      PERFORM postComment( _cmnttypeid, 'TA', NEW.prjtask_id,
8948
 
                           ('Completed Date Changed from ' || formatDate(OLD.prjtask_completed_date) || ' to ' || formatDate(NEW.prjtask_completed_date)) );
8949
 
    END IF;
8950
 
    IF (OLD.prjtask_hours_actual != NEW.prjtask_hours_actual) THEN
8951
 
      PERFORM postComment(_cmnttypeid, 'TA', NEW.prjtask_id, 
8952
 
          'Actual Hours changed from ' || formatQty(OLD.prjtask_hours_actual) || ' to ' || formatQty(NEW.prjtask_hours_actual));
8953
 
    END IF;
8954
 
    IF (OLD.prjtask_exp_actual != NEW.prjtask_exp_actual) THEN
8955
 
      PERFORM postComment(_cmnttypeid, 'TA', NEW.prjtask_id, 
8956
 
          'Actual Expense changed from ' || formatQty(OLD.prjtask_exp_actual) || ' to ' || formatQty(NEW.prjtask_exp_actual));
8957
 
    END IF;
8958
 
 
8959
 
  END IF;
8960
 
  
8961
 
  RETURN NEW;
8962
 
END;
8963
 
$$;
8964
 
 
8965
 
 
8966
 
ALTER FUNCTION public._prjtaskaftertrigger() OWNER TO admin;
8967
 
 
8968
 
--
8969
 
--
8970
 
 
8971
 
CREATE FUNCTION _prjtasktrigger() RETURNS trigger
8972
 
    LANGUAGE plpgsql
8973
 
    AS $$
8974
 
BEGIN
8975
 
 
8976
 
  --  Checks
8977
 
  IF (NEW.prjtask_owner_username=getEffectiveXtUser()) THEN
8978
 
    IF (NOT checkPrivilege('MaintainAllProjects') AND NOT checkPrivilege('MaintainPersonalProjects')) THEN
8979
 
      RAISE EXCEPTION 'You do not have privileges to maintain Projects.';
8980
 
    END IF;
8981
 
  ELSIF (NOT checkPrivilege('MaintainAllProjects')) THEN
8982
 
    RAISE EXCEPTION 'You do not have privileges to maintain Projects.';
8983
 
  ELSIF (LENGTH(COALESCE(NEW.prjtask_number,'')) = 0) THEN
8984
 
    RAISE EXCEPTION 'You must ender a valid number.';
8985
 
  ELSIF (LENGTH(COALESCE(NEW.prjtask_name,'')) = 0) THEN
8986
 
    RAISE EXCEPTION 'You must ender a valid name.';     
8987
 
  END IF;
8988
 
 
8989
 
  RETURN NEW;
8990
 
END;
8991
 
$$;
8992
 
 
8993
 
 
8994
 
ALTER FUNCTION public._prjtasktrigger() OWNER TO admin;
8995
 
 
8996
 
--
8997
 
--
8998
 
 
8999
 
CREATE FUNCTION _prospectafterdeletetrigger() RETURNS trigger
9000
 
    LANGUAGE plpgsql
9001
 
    AS $$
9002
 
BEGIN
9003
 
  IF EXISTS(SELECT 1 FROM quhead WHERE quhead_cust_id = OLD.prospect_id) AND
9004
 
     NOT EXISTS (SELECT 1 FROM custinfo WHERE cust_id = OLD.prospect_id) THEN
9005
 
    RAISE EXCEPTION '[xtuple: deleteProspect, -1]';
9006
 
  END IF;
9007
 
 
9008
 
  IF (fetchMetricBool('ProspectChangeLog')) THEN
9009
 
    PERFORM postComment(cmnttype_id, 'PSPCT', OLD.prospect_id,
9010
 
                        'Deleted "' || OLD.prospect_number || '"')
9011
 
      FROM cmnttype
9012
 
     WHERE (cmnttype_name='ChangeLog');
9013
 
  END IF;
9014
 
 
9015
 
  RETURN OLD;
9016
 
END;
9017
 
$$;
9018
 
 
9019
 
 
9020
 
ALTER FUNCTION public._prospectafterdeletetrigger() OWNER TO admin;
9021
 
 
9022
 
--
9023
 
--
9024
 
 
9025
 
CREATE FUNCTION _prospectaftertrigger() RETURNS trigger
9026
 
    LANGUAGE plpgsql
9027
 
    AS $$
9028
 
DECLARE
9029
 
  _cmnttypeid   INTEGER;
9030
 
  _custid       INTEGER;
9031
 
  _prospectid   INTEGER;
9032
 
 
9033
 
BEGIN
9034
 
 
9035
 
  IF (TG_OP = 'INSERT') THEN
9036
 
    SELECT crmacct_cust_id, crmacct_prospect_id INTO _custid, _prospectid
9037
 
      FROM crmacct
9038
 
     WHERE crmacct_number=NEW.prospect_number;
9039
 
 
9040
 
    IF (_custid > 0 AND _custid != _prospectid) THEN
9041
 
      RAISE EXCEPTION '[xtuple: createProspect, -2]';
9042
 
    END IF;
9043
 
 
9044
 
    IF (_prospectid > 0) THEN
9045
 
      RAISE EXCEPTION '[xtuple: createProspect, -3]';
9046
 
    END IF;
9047
 
 
9048
 
    -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE
9049
 
    LOOP
9050
 
      UPDATE crmacct SET crmacct_prospect_id=NEW.prospect_id,
9051
 
                         crmacct_cust_id=NULL,
9052
 
                         crmacct_name=NEW.prospect_name
9053
 
       WHERE crmacct_number=NEW.prospect_number;
9054
 
      IF (FOUND) THEN
9055
 
        EXIT;
9056
 
      END IF;
9057
 
      BEGIN
9058
 
        INSERT INTO crmacct(crmacct_number,      crmacct_name,
9059
 
                            crmacct_active,      crmacct_type,
9060
 
                            crmacct_prospect_id, crmacct_cntct_id_1
9061
 
                  ) VALUES (NEW.prospect_number, NEW.prospect_name,
9062
 
                            NEW.prospect_active, 'O',
9063
 
                            NEW.prospect_id,     NEW.prospect_cntct_id);
9064
 
        EXIT;
9065
 
      EXCEPTION WHEN unique_violation THEN
9066
 
            -- do nothing, and loop to try the UPDATE again
9067
 
      END;
9068
 
    END LOOP;
9069
 
 
9070
 
    /* TODO: default characteristic assignments based on what? */
9071
 
 
9072
 
  ELSIF (TG_OP = 'UPDATE') THEN
9073
 
    UPDATE crmacct SET crmacct_number = NEW.prospect_number
9074
 
    WHERE ((crmacct_prospect_id=NEW.prospect_id)
9075
 
      AND  (crmacct_number!=NEW.prospect_number));
9076
 
 
9077
 
    UPDATE crmacct SET crmacct_name = NEW.prospect_name
9078
 
    WHERE ((crmacct_prospect_id=NEW.prospect_id)
9079
 
      AND  (crmacct_name!=NEW.prospect_name));
9080
 
 
9081
 
  END IF;
9082
 
 
9083
 
  IF (fetchMetricBool('ProspectChangeLog')) THEN
9084
 
    SELECT cmnttype_id INTO _cmnttypeid
9085
 
      FROM cmnttype
9086
 
     WHERE (cmnttype_name='ChangeLog');
9087
 
 
9088
 
    IF (_cmnttypeid IS NOT NULL) THEN
9089
 
      IF (TG_OP = 'INSERT') THEN
9090
 
        PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Created');
9091
 
 
9092
 
      ELSIF (TG_OP = 'UPDATE') THEN
9093
 
        IF (OLD.prospect_active <> NEW.prospect_active) THEN
9094
 
          PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id,
9095
 
                              CASE WHEN NEW.prospect_active THEN 'Activated'
9096
 
                                   ELSE 'Deactivated' END);
9097
 
        END IF;
9098
 
 
9099
 
        IF (OLD.prospect_number <> NEW.prospect_number) THEN
9100
 
          PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id,
9101
 
                              'Number changed from "' || OLD.prospect_number ||
9102
 
                              '" to "' || NEW.prospect_number || '"');
9103
 
        END IF;
9104
 
 
9105
 
        IF (OLD.prospect_name <> NEW.prospect_name) THEN
9106
 
          PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id,
9107
 
                              'Name changed from "' || OLD.prospect_name ||
9108
 
                              '" to "' || NEW.prospect_name || '"');
9109
 
        END IF;
9110
 
 
9111
 
        IF (OLD.prospect_cntct_id <> NEW.prospect_cntct_id) THEN
9112
 
          PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id,
9113
 
                              'Contact changed from "' ||
9114
 
                              formatCntctName(OLD.prospect_cntct_id) || '" to "' ||
9115
 
                              formatCntctName(NEW.prospect_cntct_id) || '"');
9116
 
        END IF;
9117
 
 
9118
 
        IF (OLD.prospect_taxauth_id <> NEW.prospect_taxauth_id) THEN
9119
 
          PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id,
9120
 
                              'Tax Authority changed from "' ||
9121
 
                              (SELECT taxauth_code FROM taxauth
9122
 
                                WHERE taxauth_id=OLD.prospect_taxauth_id) ||
9123
 
                              '" to "' ||
9124
 
                              (SELECT taxauth_code FROM taxauth
9125
 
                                WHERE taxauth_id=NEW.prospect_taxauth_id) || '"');
9126
 
        END IF;
9127
 
 
9128
 
        IF (OLD.prospect_salesrep_id <> NEW.prospect_salesrep_id) THEN
9129
 
          PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id,
9130
 
                              'Sales Rep changed from "' ||
9131
 
                              (SELECT salesrep_number FROM salesrep
9132
 
                               WHERE salesrep_id=OLD.prospect_salesrep_id) ||
9133
 
                              '" to "' ||
9134
 
                              (SELECT salesrep_number FROM salesrep
9135
 
                               WHERE salesrep_id=NEW.prospect_salesrep_id) || '"');
9136
 
        END IF;
9137
 
 
9138
 
        IF (OLD.prospect_warehous_id <> NEW.prospect_warehous_id) THEN
9139
 
          PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id,
9140
 
                              'Warehouse changed from "' ||
9141
 
                              (SELECT warehous_code FROM whsinfo
9142
 
                                WHERE warehous_id=OLD.prospect_warehous_id) ||
9143
 
                              '" to "' ||
9144
 
                              (SELECT warehous_code FROM whsinfo
9145
 
                                WHERE warehous_id=NEW.prospect_warehous_id) || '"');
9146
 
        END IF;
9147
 
 
9148
 
        IF (OLD.prospect_taxzone_id <> NEW.prospect_taxzone_id) THEN
9149
 
          PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id,
9150
 
                              'Tax Zone changed from "' ||
9151
 
                              (SELECT taxzone_code FROM taxzone
9152
 
                                WHERE taxzone_id=OLD.prospect_taxzone_id) || '" to "' ||
9153
 
                              (SELECT taxzone_code FROM taxzone
9154
 
                                WHERE taxzone_id=NEW.prospect_taxzone_id) || '"');
9155
 
        END IF;
9156
 
 
9157
 
      END IF;
9158
 
    END IF;
9159
 
  END IF;
9160
 
 
9161
 
  RETURN NEW;
9162
 
END;
9163
 
$$;
9164
 
 
9165
 
 
9166
 
ALTER FUNCTION public._prospectaftertrigger() OWNER TO admin;
9167
 
 
9168
 
--
9169
 
--
9170
 
 
9171
 
CREATE FUNCTION _prospectbeforedeletetrigger() RETURNS trigger
9172
 
    LANGUAGE plpgsql
9173
 
    AS $$
9174
 
BEGIN
9175
 
  IF (NOT checkPrivilege('MaintainProspectMasters')) THEN
9176
 
    RAISE EXCEPTION 'You do not have privileges to maintain Prospects.';
9177
 
  END IF;
9178
 
 
9179
 
  UPDATE crmacct SET crmacct_prospect_id = NULL
9180
 
   WHERE crmacct_prospect_id = OLD.prospect_id;
9181
 
 
9182
 
  RETURN OLD;
9183
 
END;
9184
 
$$;
9185
 
 
9186
 
 
9187
 
ALTER FUNCTION public._prospectbeforedeletetrigger() OWNER TO admin;
9188
 
 
9189
 
--
9190
 
--
9191
 
 
9192
 
CREATE FUNCTION _prospecttrigger() RETURNS trigger
9193
 
    LANGUAGE plpgsql
9194
 
    AS $$
9195
 
BEGIN
9196
 
  IF (NOT checkPrivilege('MaintainProspectMasters')) THEN
9197
 
    RAISE EXCEPTION 'You do not have privileges to maintain Prospects.';
9198
 
  END IF;
9199
 
 
9200
 
  IF (NEW.prospect_number IS NULL) THEN
9201
 
    RAISE EXCEPTION 'You must supply a valid Prospect Number.';
9202
 
  END IF;
9203
 
 
9204
 
  NEW.prospect_number := UPPER(NEW.prospect_number);
9205
 
 
9206
 
  RETURN NEW;
9207
 
END;
9208
 
$$;
9209
 
 
9210
 
 
9211
 
ALTER FUNCTION public._prospecttrigger() OWNER TO admin;
9212
 
 
9213
 
--
9214
 
--
9215
 
 
9216
 
CREATE FUNCTION _prtrigger() RETURNS trigger
9217
 
    LANGUAGE plpgsql
9218
 
    AS $$
9219
 
BEGIN
9220
 
  --- clear the number from the issue cache
9221
 
  PERFORM clearNumberIssue('PrNumber', NEW.pr_number);
9222
 
 
9223
 
  RETURN NEW;
9224
 
END;
9225
 
$$;
9226
 
 
9227
 
 
9228
 
ALTER FUNCTION public._prtrigger() OWNER TO admin;
9229
 
 
9230
 
--
9231
 
--
9232
 
 
9233
 
CREATE FUNCTION _quheadtrigger() RETURNS trigger
9234
 
    LANGUAGE plpgsql
9235
 
    AS $$
9236
 
DECLARE
9237
 
  _cmnttypeid INTEGER;
9238
 
  _oldHoldType TEXT;
9239
 
  _newHoldType TEXT;
9240
 
  _p RECORD;
9241
 
  _a RECORD;
9242
 
  _w RECORD;
9243
 
  _shiptoId INTEGER;
9244
 
  _addrId INTEGER;
9245
 
  _prjId INTEGER;
9246
 
  _check BOOLEAN;
9247
 
  _numGen CHAR(1);
9248
 
 
9249
 
BEGIN
9250
 
 
9251
 
  --  Checks
9252
 
  SELECT checkPrivilege('MaintainQuotes') INTO _check;
9253
 
  IF NOT (_check) THEN
9254
 
    RAISE EXCEPTION 'You do not have privileges to maintain Quotes.';
9255
 
  END IF;
9256
 
 
9257
 
  -- If this is imported, check the quote number
9258
 
  IF (TG_OP = 'INSERT') THEN
9259
 
    IF (NEW.quhead_imported) THEN
9260
 
      SELECT fetchMetricText('QUNumberGeneration') INTO _numGen;
9261
 
      IF ((NEW.quhead_number IS NULL) AND (_numGen='M')) THEN
9262
 
        RAISE EXCEPTION 'You must supply a Quote Number.';
9263
 
      ELSE
9264
 
        IF ((NEW.quhead_number IS NOT NULL) AND (_numGen='A')) THEN
9265
 
          RAISE EXCEPTION 'You may not supply a new Quote Number xTuple will generate the number.';
9266
 
        ELSE
9267
 
          IF ((NEW.quhead_number IS NULL) AND (_numGen='O')) THEN
9268
 
            SELECT fetchqunumber() INTO NEW.quhead_number;
9269
 
          ELSE
9270
 
            IF (NEW.quhead_number IS NULL) THEN
9271
 
              SELECT fetchsonumber() INTO NEW.quhead_number;
9272
 
            END IF;
9273
 
          END IF;
9274
 
        END IF;
9275
 
      END IF;
9276
 
    END IF;
9277
 
 
9278
 
    IF (fetchMetricText('QUNumberGeneration') IN ('A','O')) THEN
9279
 
      --- clear the number from the issue cache
9280
 
      PERFORM clearNumberIssue('QuNumber', NEW.quhead_number);
9281
 
    ELSIF (fetchMetricText('QUNumberGeneration') = 'S') THEN
9282
 
      --- clear the number from the issue cache
9283
 
      PERFORM clearNumberIssue('SoNumber', NEW.quhead_number);
9284
 
    END IF;
9285
 
 
9286
 
  ELSE
9287
 
    IF (TG_OP = 'UPDATE') THEN
9288
 
       IF (NEW.quhead_number <> OLD.quhead_number) THEN
9289
 
         RAISE EXCEPTION 'The order number may not be changed.';
9290
 
       END IF;
9291
 
    END IF;
9292
 
  END IF;
9293
 
 
9294
 
  IF (TG_OP IN ('INSERT','UPDATE')) THEN
9295
 
    -- Get Customer data
9296
 
    IF (NEW.quhead_shipto_id IS NULL) THEN
9297
 
      SELECT * INTO _p FROM (
9298
 
      SELECT cust_number,cust_usespos,cust_blanketpos,cust_ffbillto,
9299
 
             cust_ffshipto,cust_name,cust_salesrep_id,cust_terms_id,cust_shipvia,
9300
 
             cust_commprcnt,cust_curr_id,cust_taxzone_id,
9301
 
             addr_line1,addr_line2,addr_line3,addr_city,addr_state,addr_postalcode,addr_country,
9302
 
             shipto_id,shipto_addr_id,shipto_name,shipto_salesrep_id,shipto_shipvia,
9303
 
             shipto_shipchrg_id,shipto_shipform_id,shipto_commission,shipto_taxzone_id
9304
 
      FROM custinfo
9305
 
        LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)
9306
 
        LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)
9307
 
        LEFT OUTER JOIN shiptoinfo ON ((cust_id=shipto_cust_id) AND shipto_default)
9308
 
      WHERE (cust_id=NEW.quhead_cust_id)
9309
 
      UNION
9310
 
      SELECT prospect_number,false,false,true,
9311
 
             true,prospect_name,prospect_salesrep_id,null,null,
9312
 
             null,null,prospect_taxzone_id,
9313
 
             addr_line1,addr_line2,addr_line3,addr_city,addr_state,addr_postalcode,addr_country,
9314
 
             null,null,null,null,null,
9315
 
             null,null,null,null
9316
 
      FROM prospect
9317
 
        LEFT OUTER JOIN cntct ON (prospect_cntct_id=cntct_id)
9318
 
        LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)
9319
 
      WHERE (prospect_id=NEW.quhead_cust_id)) AS data;
9320
 
    ELSE
9321
 
      SELECT cust_creditstatus,cust_number,cust_usespos,cust_blanketpos,cust_ffbillto,
9322
 
             cust_ffshipto,cust_name,cust_salesrep_id,cust_terms_id,cust_shipvia,
9323
 
             cust_shipchrg_id,cust_shipform_id,cust_commprcnt,cust_curr_id,cust_taxzone_id,
9324
 
             addr_line1,addr_line2,addr_line3,addr_city,addr_state,addr_postalcode,addr_country,
9325
 
             shipto_id,shipto_addr_id,shipto_name,shipto_salesrep_id,shipto_shipvia,
9326
 
             shipto_shipchrg_id,shipto_shipform_id,shipto_commission,shipto_taxzone_id INTO _p
9327
 
      FROM shiptoinfo,custinfo
9328
 
        LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)
9329
 
        LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)
9330
 
      WHERE ((cust_id=NEW.quhead_cust_id)
9331
 
      AND (shipto_id=shipto_id));
9332
 
    END IF;
9333
 
 
9334
 
    -- If there is customer data, then we can get to work
9335
 
    IF (FOUND) THEN
9336
 
      -- Only check PO number for imports because UI checks when whole quote is saved
9337
 
      IF (TG_OP = 'INSERT') THEN
9338
 
          -- Set to defaults if values not provided
9339
 
          NEW.quhead_shipto_id          := COALESCE(NEW.quhead_shipto_id,_p.shipto_id);
9340
 
          NEW.quhead_salesrep_id        := COALESCE(NEW.quhead_salesrep_id,_p.shipto_salesrep_id,_p.cust_salesrep_id);
9341
 
          NEW.quhead_terms_id           := COALESCE(NEW.quhead_terms_id,_p.cust_terms_id);
9342
 
          NEW.quhead_shipvia            := COALESCE(NEW.quhead_shipvia,_p.shipto_shipvia,_p.cust_shipvia);
9343
 
          NEW.quhead_commission         := COALESCE(NEW.quhead_commission,_p.shipto_commission,_p.cust_commprcnt);
9344
 
          NEW.quhead_quotedate          := COALESCE(NEW.quhead_quotedate,current_date);
9345
 
          NEW.quhead_packdate           := COALESCE(NEW.quhead_packdate,NEW.quhead_quotedate);
9346
 
          NEW.quhead_curr_id            := COALESCE(NEW.quhead_curr_id,_p.cust_curr_id,basecurrid());
9347
 
          NEW.quhead_taxzone_id         := COALESCE(NEW.quhead_taxzone_id,_p.shipto_taxzone_id,_p.cust_taxzone_id);
9348
 
          NEW.quhead_freight            := COALESCE(NEW.quhead_freight,0);
9349
 
          NEW.quhead_custponumber       := COALESCE(NEW.quhead_custponumber,'');
9350
 
          NEW.quhead_ordercomments      := COALESCE(NEW.quhead_ordercomments,'');
9351
 
          NEW.quhead_shipcomments       := COALESCE(NEW.quhead_shipcomments,'');
9352
 
          NEW.quhead_shiptophone        := COALESCE(NEW.quhead_shiptophone,'');
9353
 
          NEW.quhead_misc               := COALESCE(NEW.quhead_misc,0);
9354
 
          NEW.quhead_misc_descrip       := COALESCE(NEW.quhead_misc_descrip,'');
9355
 
 
9356
 
          IF ((NEW.quhead_warehous_id IS NULL) OR (NEW.quhead_fob IS NULL)) THEN
9357
 
            IF (NEW.quhead_warehous_id IS NULL) THEN
9358
 
              SELECT warehous_id,warehous_fob INTO _w
9359
 
              FROM usrpref, whsinfo
9360
 
              WHERE ((warehous_id=CAST(usrpref_value AS INTEGER))
9361
 
                AND (warehous_shipping)
9362
 
                AND (warehous_active)
9363
 
                AND (usrpref_username=getEffectiveXtUser())
9364
 
                AND (usrpref_name='PreferredWarehouse'));
9365
 
            ELSE
9366
 
              SELECT warehous_id,warehous_fob INTO _w
9367
 
              FROM whsinfo
9368
 
              WHERE (warehous_id=NEW.quhead_warehous_id);
9369
 
            END IF;
9370
 
 
9371
 
            IF (FOUND) THEN
9372
 
              NEW.quhead_warehous_id    := COALESCE(NEW.quhead_warehous_id,_w.warehous_id);
9373
 
              NEW.quhead_fob            := COALESCE(NEW.quhead_fob,_w.warehous_fob);
9374
 
            END IF;
9375
 
          END IF;
9376
 
      END IF;
9377
 
 
9378
 
      --Auto create project if applicable
9379
 
      IF ((TG_OP = 'INSERT') AND (COALESCE(NEW.quhead_prj_id,-1)=-1)) THEN
9380
 
        SELECT fetchMetricBool('AutoCreateProjectsForOrders') INTO _check;
9381
 
        IF (_check) THEN
9382
 
          SELECT NEXTVAL('prj_prj_id_seq') INTO _prjId;
9383
 
          NEW.quhead_prj_id := _prjId;
9384
 
          INSERT INTO prj (prj_id, prj_number, prj_name, prj_descrip,
9385
 
                           prj_status, prj_so, prj_wo, prj_po,
9386
 
                           prj_owner_username, prj_start_date, prj_due_date,
9387
 
                           prj_assigned_date, prj_completed_date, prj_username,
9388
 
                           prj_recurring_prj_id, prj_crmacct_id,
9389
 
                           prj_cntct_id, prj_prjtype_id)
9390
 
          SELECT _prjId, NEW.quhead_number, NEW.quhead_number, 'Auto Generated Project from Quote.',
9391
 
                 'O', TRUE, TRUE, TRUE,
9392
 
                 getEffectiveXTUser(), NEW.quhead_quotedate, NEW.quhead_packdate,
9393
 
                 NEW.quhead_quotedate, NULL, getEffectiveXTUser(),
9394
 
                 NULL, crmacct_id,
9395
 
                 NEW.quhead_billto_cntct_id, NULL
9396
 
          FROM crmacct
9397
 
          WHERE (crmacct_cust_id=NEW.quhead_cust_id)
9398
 
             OR (crmacct_prospect_id=NEW.quhead_cust_id)
9399
 
          LIMIT 1;
9400
 
        END IF;
9401
 
      END IF;
9402
 
 
9403
 
      -- Deal with Billing Address
9404
 
      IF (TG_OP = 'INSERT') THEN
9405
 
        IF (_p.cust_ffbillto) THEN
9406
 
          -- If they didn't supply data, we'll put in the bill to address
9407
 
          NEW.quhead_billtoname=COALESCE(NEW.quhead_billtoname,_p.cust_name,'');
9408
 
          NEW.quhead_billtoaddress1=COALESCE(NEW.quhead_billtoaddress1,_p.addr_line1,'');
9409
 
          NEW.quhead_billtoaddress2=COALESCE(NEW.quhead_billtoaddress2,_p.addr_line2,'');
9410
 
          NEW.quhead_billtoaddress3=COALESCE(NEW.quhead_billtoaddress3,_p.addr_line3,'');
9411
 
          NEW.quhead_billtocity=COALESCE(NEW.quhead_billtocity,_p.addr_city,'');
9412
 
          NEW.quhead_billtostate=COALESCE(NEW.quhead_billtostate,_p.addr_state,'');
9413
 
          NEW.quhead_billtozip=COALESCE(NEW.quhead_billtozip,_p.addr_postalcode,'');
9414
 
          NEW.quhead_billtocountry=COALESCE(NEW.quhead_billtocountry,_p.addr_country,'');
9415
 
        ELSE
9416
 
          -- Free form not allowed, we're going to put in the address regardless
9417
 
          NEW.quhead_billtoname=COALESCE(_p.cust_name,'');
9418
 
          NEW.quhead_billtoaddress1=COALESCE(_p.addr_line1,'');
9419
 
          NEW.quhead_billtoaddress2=COALESCE(_p.addr_line2,'');
9420
 
          NEW.quhead_billtoaddress3=COALESCE(_p.addr_line3,'');
9421
 
          NEW.quhead_billtocity=COALESCE(_p.addr_city,'');
9422
 
          NEW.quhead_billtostate=COALESCE(_p.addr_state,'');
9423
 
          NEW.quhead_billtozip=COALESCE(_p.addr_postalcode,'');
9424
 
          NEW.quhead_billtocountry=COALESCE(_p.addr_country,'');
9425
 
        END IF;
9426
 
      END IF;
9427
 
 
9428
 
      -- Now let's look at Shipto Address
9429
 
      -- If there's nothing in the address fields and there is a shipto id
9430
 
      -- or there is a default address available, let's put in some shipto address data
9431
 
      IF ((TG_OP = 'INSERT')
9432
 
       AND NOT ((NEW.quhead_shipto_id IS NULL) AND NOT _p.cust_ffshipto)
9433
 
       AND (NEW.quhead_shiptoname IS NULL)
9434
 
       AND (NEW.quhead_shiptoaddress1 IS NULL)
9435
 
       AND (NEW.quhead_shiptoaddress2 IS NULL)
9436
 
       AND (NEW.quhead_shiptoaddress3 IS NULL)
9437
 
       AND (NEW.quhead_shiptocity IS NULL)
9438
 
       AND (NEW.quhead_shiptostate IS NULL)
9439
 
       AND (NEW.quhead_shiptocountry IS NULL)) THEN
9440
 
        IF ((NEW.quhead_shipto_id IS NULL) AND (_p.shipto_id IS NOT NULL)) THEN
9441
 
          _shiptoId := _p.shipto_addr_id;
9442
 
        ELSE
9443
 
          _shiptoId := NEW.quhead_shipto_id;
9444
 
        END IF;
9445
 
 
9446
 
        SELECT * INTO _a
9447
 
        FROM shiptoinfo, addr
9448
 
        WHERE ((shipto_id=_shiptoId)
9449
 
        AND (addr_id=shipto_addr_id));
9450
 
 
9451
 
        NEW.quhead_shiptoname := COALESCE(_p.shipto_name,'');
9452
 
        NEW.quhead_shiptoaddress1 := COALESCE(_a.addr_line1,'');
9453
 
        NEW.quhead_shiptoaddress2 := COALESCE(_a.addr_line2,'');
9454
 
        NEW.quhead_shiptoaddress3 := COALESCE(_a.addr_line3,'');
9455
 
        NEW.quhead_shiptocity := COALESCE(_a.addr_city,'');
9456
 
        NEW.quhead_shiptostate := COALESCE(_a.addr_state,'');
9457
 
        NEW.quhead_shiptozipcode := COALESCE(_a.addr_postalcode,'');
9458
 
        NEW.quhead_shiptocountry := COALESCE(_a.addr_country,'');
9459
 
      ELSE
9460
 
        IF (_p.cust_ffshipto) THEN
9461
 
          -- Use Address Save function to see if the new address entered matches
9462
 
          -- data for the shipto number.  If not that will insert new address for CRM
9463
 
          SELECT SaveAddr(
9464
 
            NULL,
9465
 
            NULL,
9466
 
            NEW.quhead_shiptoaddress1,
9467
 
            NEW.quhead_shiptoaddress2,
9468
 
            NEW.quhead_shiptoaddress3,
9469
 
            NEW.quhead_shiptocity,
9470
 
            NEW.quhead_shiptostate,
9471
 
            NEW.quhead_shiptozipcode,
9472
 
            NEW.quhead_shiptocountry,
9473
 
            'CHANGEONE') INTO _addrId;
9474
 
          SELECT shipto_addr_id INTO _shiptoid FROM shiptoinfo WHERE (shipto_id=NEW.quhead_shipto_id);
9475
 
           -- If the address passed doesn't match shipto address, then it's something else
9476
 
           IF (_shiptoid <> _addrId) THEN
9477
 
             NEW.quhead_shipto_id := NULL;
9478
 
           END IF;
9479
 
        ELSE
9480
 
          SELECT quhead_shipto_id INTO _shiptoid FROM quhead WHERE (quhead_id=NEW.quhead_id);
9481
 
          -- Get the shipto address
9482
 
            IF (COALESCE(NEW.quhead_shipto_id,-1) <> COALESCE(_shiptoid,-1)) THEN
9483
 
            SELECT * INTO _a
9484
 
            FROM shiptoinfo
9485
 
            LEFT OUTER JOIN cntct ON (shipto_cntct_id=cntct_id)
9486
 
            LEFT OUTER JOIN addr ON (shipto_addr_id=addr_id)
9487
 
            WHERE (shipto_id=NEW.quhead_shipto_id);
9488
 
            IF (FOUND) THEN
9489
 
              -- Free form not allowed so we're going to make sure address matches Shipto data
9490
 
              NEW.quhead_shiptoname := COALESCE(_a.shipto_name,'');
9491
 
              NEW.quhead_shiptophone := COALESCE(_a.cntct_phone,'');
9492
 
              NEW.quhead_shiptoaddress1 := COALESCE(_a.addr_line1,'');
9493
 
              NEW.quhead_shiptoaddress2 := COALESCE(_a.addr_line2,'');
9494
 
              NEW.quhead_shiptoaddress3 := COALESCE(_a.addr_line3,'');
9495
 
              NEW.quhead_shiptocity := COALESCE(_a.addr_city,'');
9496
 
              NEW.quhead_shiptostate := COALESCE(_a.addr_state,'');
9497
 
              NEW.quhead_shiptozipcode := COALESCE(_a.addr_postalcode,'');
9498
 
              NEW.quhead_shiptocountry := COALESCE(_a.addr_country,'');
9499
 
            ELSE
9500
 
              -- If no shipto data and free form not allowed, this won't work
9501
 
              RAISE EXCEPTION 'Free form Shipto is not allowed on this Customer. You must supply a valid Shipto ID.';
9502
 
            END IF;
9503
 
          END IF;
9504
 
        END IF;
9505
 
      END IF;
9506
 
    END IF;
9507
 
  END IF;
9508
 
 
9509
 
  IF ( SELECT (metric_value='t')
9510
 
       FROM metric
9511
 
       WHERE (metric_name='SalesOrderChangeLog') ) THEN
9512
 
 
9513
 
    SELECT cmnttype_id INTO _cmnttypeid
9514
 
    FROM cmnttype
9515
 
    WHERE (cmnttype_name='ChangeLog');
9516
 
    IF (FOUND) THEN
9517
 
      IF (TG_OP = 'INSERT') THEN
9518
 
        PERFORM postComment(_cmnttypeid, 'Q', NEW.quhead_id, 'Created');
9519
 
 
9520
 
      ELSIF (TG_OP = 'UPDATE') THEN
9521
 
 
9522
 
        IF (OLD.quhead_terms_id <> NEW.quhead_terms_id) THEN
9523
 
          PERFORM postComment( _cmnttypeid, 'Q', NEW.quhead_id,
9524
 
                               ('Terms Changed from "' || oldterms.terms_code || '" to "' || newterms.terms_code || '"') )
9525
 
          FROM terms AS oldterms, terms AS newterms
9526
 
          WHERE ( (oldterms.terms_id=OLD.quhead_terms_id)
9527
 
           AND (newterms.terms_id=NEW.quhead_terms_id) );
9528
 
        END IF;
9529
 
 
9530
 
      ELSIF (TG_OP = 'DELETE') THEN
9531
 
        DELETE FROM comment
9532
 
        WHERE ( (comment_source='Q')
9533
 
         AND (comment_source_id=OLD.quhead_id) );
9534
 
      END IF;
9535
 
    END IF;
9536
 
  END IF;
9537
 
 
9538
 
  IF (TG_OP = 'DELETE') THEN
9539
 
    RETURN OLD;
9540
 
  ELSE
9541
 
    RETURN NEW;
9542
 
  END IF;
9543
 
 
9544
 
END;
9545
 
$$;
9546
 
 
9547
 
 
9548
 
ALTER FUNCTION public._quheadtrigger() OWNER TO admin;
9549
 
 
9550
 
--
9551
 
--
9552
 
 
9553
 
CREATE FUNCTION _quitemaftertrigger() RETURNS trigger
9554
 
    LANGUAGE plpgsql
9555
 
    AS $$
9556
 
DECLARE
9557
 
  _check NUMERIC;
9558
 
BEGIN
9559
 
 
9560
 
  --If auto calculate freight, recalculate quhead_freight
9561
 
  IF (SELECT quhead_calcfreight FROM quhead WHERE (quhead_id=NEW.quitem_quhead_id)) THEN
9562
 
    UPDATE quhead SET quhead_freight =
9563
 
      (SELECT SUM(freightdata_total) FROM freightDetail('QU',
9564
 
                                                        quhead_id,
9565
 
                                                        quhead_cust_id,
9566
 
                                                        quhead_shipto_id,
9567
 
                                                        quhead_quotedate,
9568
 
                                                        quhead_shipvia,
9569
 
                                                        quhead_curr_id))
9570
 
    WHERE quhead_id=NEW.quitem_quhead_id;
9571
 
  END IF;
9572
 
 
9573
 
  RETURN NEW;
9574
 
END;
9575
 
$$;
9576
 
 
9577
 
 
9578
 
ALTER FUNCTION public._quitemaftertrigger() OWNER TO admin;
9579
 
 
9580
 
--
9581
 
--
9582
 
 
9583
 
CREATE FUNCTION _quitembeforetrigger() RETURNS trigger
9584
 
    LANGUAGE plpgsql
9585
 
    AS $$
9586
 
DECLARE
9587
 
  _check NUMERIC;
9588
 
  _itemNumber TEXT;
9589
 
BEGIN
9590
 
  -- Check
9591
 
  IF (NEW.quitem_scheddate IS NULL) THEN
9592
 
        RAISE EXCEPTION 'A schedule date is required.';
9593
 
  END IF;
9594
 
 
9595
 
  -- If this is imported, go ahead and insert default characteristics
9596
 
   IF ((TG_OP = 'INSERT') AND NEW.quitem_imported) THEN
9597
 
     PERFORM updateCharAssignment('SI', NEW.quitem_id, char_id, charass_value)
9598
 
     FROM (
9599
 
       SELECT DISTINCT char_id, char_name, charass_value
9600
 
       FROM charass, char, itemsite, item
9601
 
       WHERE ((itemsite_id=NEW.quitem_itemsite_id)
9602
 
       AND (itemsite_item_id=item_id)
9603
 
       AND (charass_target_type='I')
9604
 
       AND (charass_target_id=item_id)
9605
 
       AND (charass_default)
9606
 
       AND (char_id=charass_char_id))
9607
 
       ORDER BY char_name) AS data;
9608
 
   END IF;
9609
 
 
9610
 
  RETURN NEW;
9611
 
END;
9612
 
$$;
9613
 
 
9614
 
 
9615
 
ALTER FUNCTION public._quitembeforetrigger() OWNER TO admin;
9616
 
 
9617
 
--
9618
 
--
9619
 
 
9620
 
CREATE FUNCTION _quitemtrigger() RETURNS trigger
9621
 
    LANGUAGE plpgsql
9622
 
    AS $$
9623
 
DECLARE
9624
 
  _changelog BOOLEAN := FALSE;
9625
 
  _check BOOLEAN;
9626
 
 
9627
 
BEGIN
9628
 
  --  Checks
9629
 
  SELECT checkPrivilege('MaintainQuotes') INTO _check;
9630
 
  IF NOT (_check) THEN
9631
 
    RAISE EXCEPTION 'You do not have privileges to maintain Quotes.';
9632
 
  END IF;
9633
 
 
9634
 
  IF ( SELECT fetchMetricBool('SalesOrderChangeLog') ) THEN
9635
 
    _changelog := TRUE;
9636
 
  END IF;
9637
 
 
9638
 
  IF (TG_OP = 'INSERT') THEN
9639
 
    IF (_changelog) THEN
9640
 
      PERFORM postComment('ChangeLog', 'QI', NEW.quitem_id, 'Created');
9641
 
    END IF;
9642
 
 
9643
 
    RETURN NEW;
9644
 
  END IF;
9645
 
 
9646
 
  IF (TG_OP = 'DELETE') THEN
9647
 
    DELETE FROM comment
9648
 
    WHERE ( (comment_source='QI')
9649
 
     AND (comment_source_id=OLD.quitem_id) );
9650
 
 
9651
 
    DELETE FROM charass
9652
 
     WHERE ((charass_target_type='QI')
9653
 
       AND  (charass_target_id=OLD.quitem_id));
9654
 
 
9655
 
    RETURN OLD;
9656
 
  END IF;
9657
 
 
9658
 
  IF (TG_OP = 'UPDATE') THEN
9659
 
    IF (_changelog) THEN
9660
 
      IF (NEW.quitem_qtyord <> OLD.quitem_qtyord) THEN
9661
 
        PERFORM postComment( 'ChangeLog', 'QI', NEW.quitem_id,
9662
 
                             ( 'Changed Qty. Ordered from ' || formatQty(OLD.quitem_qtyord) ||
9663
 
                               ' to ' || formatQty(NEW.quitem_qtyord) ) );
9664
 
      END IF;
9665
 
 
9666
 
      IF (NEW.quitem_price <> OLD.quitem_price) THEN
9667
 
        PERFORM postComment( 'ChangeLog', 'QI', NEW.quitem_id,
9668
 
                             ( 'Changed Unit Price from ' || formatPrice(OLD.quitem_price) ||
9669
 
                               ' to ' || formatPrice(NEW.quitem_price) ) );
9670
 
      END IF;
9671
 
 
9672
 
      IF (NEW.quitem_scheddate <> OLD.quitem_scheddate) THEN
9673
 
        PERFORM postComment( 'ChangeLog', 'QI', NEW.quitem_id,
9674
 
                             ( 'Changed Sched. Date from ' || formatDate(OLD.quitem_scheddate) ||
9675
 
                               ' to ' || formatDate(NEW.quitem_scheddate)) );
9676
 
      END IF;
9677
 
    END IF;
9678
 
  END IF;
9679
 
 
9680
 
 
9681
 
  RETURN NEW;
9682
 
 
9683
 
END;
9684
 
$$;
9685
 
 
9686
 
 
9687
 
ALTER FUNCTION public._quitemtrigger() OWNER TO admin;
9688
 
 
9689
 
--
9690
 
--
9691
 
 
9692
 
CREATE FUNCTION _recuraftertrigger() RETURNS trigger
9693
 
    LANGUAGE plpgsql
9694
 
    AS $$
9695
 
DECLARE
9696
 
  _parentid   INTEGER;
9697
 
  _parenttype TEXT;
9698
 
BEGIN
9699
 
  IF (TG_OP = 'DELETE') THEN
9700
 
    IF (UPPER(OLD.recur_parent_type) = 'TODO') THEN
9701
 
      UPDATE todoitem SET todoitem_recurring_todoitem_id=NULL
9702
 
       WHERE (todoitem_recurring_todoitem_id=OLD.recur_parent_id);
9703
 
    END IF;
9704
 
 
9705
 
    RETURN OLD;
9706
 
  END IF;
9707
 
 
9708
 
  RETURN NEW;
9709
 
END;
9710
 
$$;
9711
 
 
9712
 
 
9713
 
ALTER FUNCTION public._recuraftertrigger() OWNER TO admin;
9714
 
 
9715
 
--
9716
 
--
9717
 
 
9718
 
CREATE FUNCTION _reporttrigger() RETURNS trigger
9719
 
    LANGUAGE plpgsql
9720
 
    AS $$
9721
 
BEGIN
9722
 
 
9723
 
  NEW.report_loaddate = CURRENT_TIMESTAMP;
9724
 
  RETURN NEW;
9725
 
 
9726
 
END;
9727
 
$$;
9728
 
 
9729
 
 
9730
 
ALTER FUNCTION public._reporttrigger() OWNER TO admin;
9731
 
 
9732
 
--
9733
 
--
9734
 
 
9735
 
CREATE FUNCTION _salesrepafterdeletetrigger() RETURNS trigger
9736
 
    LANGUAGE plpgsql
9737
 
    AS $$
9738
 
BEGIN
9739
 
  IF (SELECT fetchMetricValue('DefaultSalesRep') = OLD.salesrep_id) THEN
9740
 
    RAISE EXCEPTION 'Cannot delete the default Sales Rep [xtuple: salesrep, -1, %]',
9741
 
                    OLD.salesrep_number;
9742
 
  END IF;
9743
 
 
9744
 
  PERFORM postComment('ChangeLog', 'SR', OLD.salesrep_id,
9745
 
                      'Deleted "' || OLD.salesrep_number || '"');
9746
 
 
9747
 
  RETURN OLD;
9748
 
END;
9749
 
$$;
9750
 
 
9751
 
 
9752
 
ALTER FUNCTION public._salesrepafterdeletetrigger() OWNER TO admin;
9753
 
 
9754
 
--
9755
 
--
9756
 
 
9757
 
CREATE FUNCTION _salesrepaftertrigger() RETURNS trigger
9758
 
    LANGUAGE plpgsql
9759
 
    AS $$
9760
 
DECLARE
9761
 
 
9762
 
BEGIN
9763
 
 
9764
 
  IF (TG_OP = 'INSERT') THEN
9765
 
    -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE
9766
 
    LOOP
9767
 
      UPDATE crmacct SET crmacct_salesrep_id=NEW.salesrep_id,
9768
 
                         crmacct_name=NEW.salesrep_name
9769
 
      WHERE crmacct_number=NEW.salesrep_number;
9770
 
      IF (FOUND) THEN
9771
 
        EXIT;
9772
 
      END IF;
9773
 
      BEGIN
9774
 
        INSERT INTO crmacct(crmacct_number,      crmacct_name,      crmacct_active,
9775
 
                            crmacct_type,        crmacct_salesrep_id
9776
 
                  ) VALUES (NEW.salesrep_number, NEW.salesrep_name, NEW.salesrep_active,
9777
 
                            'I',                 NEW.salesrep_id);
9778
 
        EXIT;
9779
 
      EXCEPTION WHEN unique_violation THEN
9780
 
            -- do nothing, and loop to try the UPDATE again
9781
 
      END;
9782
 
    END LOOP;
9783
 
 
9784
 
    -- TODO: default characteristic assignments?
9785
 
 
9786
 
  ELSIF (TG_OP = 'UPDATE') THEN
9787
 
    UPDATE crmacct SET crmacct_number = NEW.salesrep_number
9788
 
    WHERE ((crmacct_salesrep_id=NEW.salesrep_id)
9789
 
      AND  (crmacct_number!=NEW.salesrep_number));
9790
 
 
9791
 
    UPDATE crmacct SET crmacct_name = NEW.salesrep_name
9792
 
    WHERE ((crmacct_salesrep_id=NEW.salesrep_id)
9793
 
      AND  (crmacct_name!=NEW.salesrep_name));
9794
 
  END IF;
9795
 
 
9796
 
  IF (fetchMetricBool('SalesRepChangeLog')) THEN
9797
 
      IF (TG_OP = 'INSERT') THEN
9798
 
        PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id, 'Created');
9799
 
 
9800
 
      ELSIF (TG_OP = 'UPDATE') THEN
9801
 
        IF (OLD.salesrep_active <> NEW.salesrep_active) THEN
9802
 
          PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id,
9803
 
                              CASE WHEN NEW.salesrep_active THEN 'Activated'
9804
 
                                   ELSE 'Deactivated' END);
9805
 
        END IF;
9806
 
 
9807
 
        IF (OLD.salesrep_number <> NEW.salesrep_number) THEN
9808
 
          PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id,
9809
 
                              'Number changed from "' || OLD.salesrep_number ||
9810
 
                              '" to "' || NEW.salesrep_number || '"');
9811
 
        END IF;
9812
 
 
9813
 
        IF (OLD.salesrep_name <> NEW.salesrep_name) THEN
9814
 
          PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id,
9815
 
                              'Name changed from "' || OLD.salesrep_name ||
9816
 
                              '" to "' || NEW.salesrep_name || '"');
9817
 
        END IF;
9818
 
 
9819
 
        IF (OLD.salesrep_commission <> NEW.salesrep_commission) THEN
9820
 
          PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id,
9821
 
                              'Commission changed from "' || OLD.salesrep_commission ||
9822
 
                              '" to "' || NEW.salesrep_commission || '"');
9823
 
        END IF;
9824
 
 
9825
 
        IF (OLD.salesrep_method <> NEW.salesrep_method) THEN
9826
 
          PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id,
9827
 
                              'Method changed from "' || OLD.salesrep_method ||
9828
 
                              '" to "' || NEW.salesrep_method || '"');
9829
 
        END IF;
9830
 
 
9831
 
    END IF;
9832
 
  END IF;
9833
 
 
9834
 
  RETURN NEW;
9835
 
END;
9836
 
$$;
9837
 
 
9838
 
 
9839
 
ALTER FUNCTION public._salesrepaftertrigger() OWNER TO admin;
9840
 
 
9841
 
--
9842
 
--
9843
 
 
9844
 
CREATE FUNCTION _salesrepbeforetrigger() RETURNS trigger
9845
 
    LANGUAGE plpgsql
9846
 
    AS $$
9847
 
BEGIN
9848
 
 
9849
 
  IF NOT (checkPrivilege('MaintainSalesReps')) THEN
9850
 
    RAISE EXCEPTION 'You do not have privileges to maintain Sales Reps.';
9851
 
  END IF;
9852
 
 
9853
 
  IF (TG_OP IN ('INSERT', 'UPDATE')) THEN
9854
 
    IF (NEW.salesrep_number IS NULL) THEN
9855
 
      RAISE EXCEPTION 'You must supply a valid Sales Rep Number.';
9856
 
    END IF;
9857
 
 
9858
 
    IF (NEW.salesrep_commission IS NULL) THEN
9859
 
      RAISE EXCEPTION 'You must supply a Commission Rate for this Sales Rep.';
9860
 
    END IF;
9861
 
 
9862
 
    IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O') AND isNumeric(NEW.salesrep_number)) THEN
9863
 
      --- clear the number from the issue cache
9864
 
      PERFORM clearNumberIssue('CRMAccountNumber', NEW.salesrep_number);
9865
 
    END IF;
9866
 
 
9867
 
    NEW.salesrep_number = UPPER(NEW.salesrep_number);
9868
 
 
9869
 
    -- deprecated column salesrep_emp_id
9870
 
    -- TODO: will this prevent breaking the crmacct-emp relationship?
9871
 
    IF (TG_OP = 'UPDATE') THEN
9872
 
      SELECT crmacct_emp_id INTO NEW.salesrep_emp_id
9873
 
        FROM crmacct
9874
 
       WHERE crmacct_salesrep_id = NEW.salesrep_id;
9875
 
    END IF;
9876
 
 
9877
 
  ELSIF (TG_OP = 'DELETE') THEN
9878
 
    UPDATE crmacct SET crmacct_salesrep_id = NULL
9879
 
     WHERE crmacct_salesrep_id = OLD.salesrep_id;
9880
 
    RETURN OLD;
9881
 
  END IF;
9882
 
 
9883
 
  RETURN NEW;
9884
 
END;
9885
 
$$;
9886
 
 
9887
 
 
9888
 
ALTER FUNCTION public._salesrepbeforetrigger() OWNER TO admin;
9889
 
 
9890
 
--
9891
 
--
9892
 
 
9893
 
CREATE FUNCTION _saletypebeforedeletetrigger() RETURNS trigger
9894
 
    LANGUAGE plpgsql
9895
 
    AS $$
9896
 
DECLARE
9897
 
  _check TEXT;
9898
 
 
9899
 
BEGIN
9900
 
  SELECT cohead_number INTO _check
9901
 
  FROM cohead
9902
 
  WHERE (cohead_saletype_id=OLD.saletype_id)
9903
 
  LIMIT 1;
9904
 
  IF (FOUND) THEN
9905
 
    RAISE EXCEPTION 'Assigned to Sales Order % and possibly more. [xtuple: deletesaletype, -1]', _check;
9906
 
  END IF;
9907
 
 
9908
 
  SELECT quhead_number INTO _check
9909
 
  FROM quhead
9910
 
  WHERE (quhead_saletype_id=OLD.saletype_id)
9911
 
  LIMIT 1;
9912
 
  IF (FOUND) THEN
9913
 
    RAISE EXCEPTION 'Assigned to Quote % and possibly more. [xtuple: deletesaletype, -2]', _check;
9914
 
  END IF;
9915
 
 
9916
 
  SELECT invchead_invcnumber INTO _check
9917
 
  FROM invchead
9918
 
  WHERE (invchead_saletype_id=OLD.saletype_id)
9919
 
  LIMIT 1;
9920
 
  IF (FOUND) THEN
9921
 
    RAISE EXCEPTION 'Assigned to Invoice % and possibly more. [xtuple: deletesaletype, -3]', _check;
9922
 
  END IF;
9923
 
 
9924
 
  SELECT cmhead_number INTO _check
9925
 
  FROM cmhead
9926
 
  WHERE (cmhead_saletype_id=OLD.saletype_id)
9927
 
  LIMIT 1;
9928
 
  IF (FOUND) THEN
9929
 
    RAISE EXCEPTION 'Assigned to Credit Memo % and possibly more. [xtuple: deletesaletype, -4]', _check;
9930
 
  END IF;
9931
 
 
9932
 
  IF (fetchMetricBool('EnableReturnAuth')) THEN
9933
 
    SELECT rahead_number INTO _check
9934
 
    FROM rahead
9935
 
    WHERE (rahead_saletype_id=OLD.saletype_id)
9936
 
    LIMIT 1;
9937
 
    IF (FOUND) THEN
9938
 
      RAISE EXCEPTION 'Assigned to Return Authorization % and possibly more returns. [xtuple: deleteSaleType, -5]', _check;
9939
 
    END IF;
9940
 
  END IF;
9941
 
 
9942
 
  RETURN OLD;
9943
 
END;
9944
 
$$;
9945
 
 
9946
 
 
9947
 
ALTER FUNCTION public._saletypebeforedeletetrigger() OWNER TO admin;
9948
 
 
9949
 
--
9950
 
--
9951
 
 
9952
 
CREATE FUNCTION _shipdatasumtrigger() RETURNS trigger
9953
 
    LANGUAGE plpgsql
9954
 
    AS $$
9955
 
BEGIN
9956
 
 
9957
 
  IF (LENGTH(TRIM(NEW.shipdatasum_shiphead_number)) = 0) THEN
9958
 
    NEW.shipdatasum_shiphead_number = NULL;
9959
 
  END IF;
9960
 
 
9961
 
  RETURN NEW;
9962
 
 
9963
 
END;
9964
 
$$;
9965
 
 
9966
 
 
9967
 
ALTER FUNCTION public._shipdatasumtrigger() OWNER TO admin;
9968
 
 
9969
 
--
9970
 
--
9971
 
 
9972
 
CREATE FUNCTION _shipdatatrigger() RETURNS trigger
9973
 
    LANGUAGE plpgsql
9974
 
    AS $$
9975
 
DECLARE
9976
 
  _newShipdata_cohead_number    INTEGER;
9977
 
  _shipdatasum_shipper          TEXT;
9978
 
  _rows                         INTEGER;
9979
 
  _cohead_id                    INTEGER;
9980
 
  _shiphead_number              TEXT;
9981
 
  _headcount                    INTEGER;
9982
 
 
9983
 
BEGIN
9984
 
  --  This is where the shipper is identified and may need to be changed
9985
 
  NEW.shipdata_cohead_number := TRIM(NEW.shipdata_cohead_number);
9986
 
 
9987
 
  IF (substring(NEW.shipdata_cosmisc_tracknum from 1 for 2) = '1Z') THEN
9988
 
    _shipdatasum_shipper := 'UPS';
9989
 
  ELSE
9990
 
    _shipdatasum_shipper := 'UNKNOWN';
9991
 
  END IF;
9992
 
 
9993
 
  IF (LENGTH(TRIM(NEW.shipdata_shiphead_number)) = 0) THEN
9994
 
    NEW.shipdata_shiphead_number := NULL;
9995
 
  END IF;
9996
 
 
9997
 
  IF (NEW.shipdata_cosmisc_tracknum = NEW.shipdata_cosmisc_packnum_tracknum) THEN
9998
 
    IF (NEW.shipdata_void_ind = 'Y') THEN
9999
 
      --  Delete the current shipdatasum
10000
 
      DELETE FROM shipdatasum
10001
 
      WHERE ((shipdatasum_cohead_number = NEW.shipdata_cohead_number)
10002
 
        AND  (shipdatasum_cosmisc_tracknum = NEW.shipdata_cosmisc_tracknum));
10003
 
 
10004
 
    ELSIF (TG_OP = 'INSERT') THEN
10005
 
 
10006
 
      IF (NEW.shipdata_shiphead_number IS NULL) THEN
10007
 
        SELECT cohead_id INTO _cohead_id FROM cohead WHERE cohead_number = NEW.shipdata_cohead_number;
10008
 
 
10009
 
        IF (FOUND) THEN
10010
 
 
10011
 
          SELECT count(shiphead_order_id), MAX(shiphead_number) INTO _headcount, _shiphead_number 
10012
 
          FROM shiphead 
10013
 
          WHERE ((shiphead_tracknum IS NULL OR shiphead_tracknum = '') 
10014
 
          AND ( shiphead_order_type = 'SO' and shiphead_order_id = _cohead_id) );
10015
 
          
10016
 
          IF (_headcount = 1) THEN
10017
 
            NEW.shipdata_shiphead_number = _shiphead_number;
10018
 
            
10019
 
          ELSIF (_headcount > 1) THEN
10020
 
            -- Trap for potential workflow problem.  Can only infer shiphead from sales order number 
10021
 
            -- if shipping one at a time
10022
 
            RAISE EXCEPTION 'Multiple shipments exist for this order.  Please provide a specific a shipment number.';
10023
 
          END IF;
10024
 
        END IF;
10025
 
      END IF;
10026
 
 
10027
 
      INSERT INTO shipdatasum
10028
 
              (shipdatasum_cohead_number, shipdatasum_cosmisc_tracknum,
10029
 
               shipdatasum_cosmisc_packnum_tracknum, shipdatasum_weight,
10030
 
               shipdatasum_base_freight, shipdatasum_total_freight,
10031
 
               shipdatasum_base_freight_curr_id, shipdatasum_total_freight_curr_id,
10032
 
               shipdatasum_shipper, shipdatasum_billing_option,
10033
 
               shipdatasum_package_type, shipdatasum_shiphead_number)
10034
 
       VALUES (NEW.shipdata_cohead_number, NEW.shipdata_cosmisc_tracknum,
10035
 
               NEW.shipdata_cosmisc_packnum_tracknum, NEW.shipdata_weight,
10036
 
               NEW.shipdata_base_freight, NEW.shipdata_total_freight,
10037
 
               NEW.shipdata_base_freight_curr_id, NEW.shipdata_total_freight_curr_id,
10038
 
               _shipdatasum_shipper, NEW.shipdata_billing_option,
10039
 
               NEW.shipdata_package_type, NEW.shipdata_shiphead_number);
10040
 
 
10041
 
    ELSIF (TG_OP = 'UPDATE') THEN
10042
 
       UPDATE shipdatasum SET
10043
 
              shipdatasum_cohead_number=NEW.shipdata_cohead_number,
10044
 
              shipdatasum_cosmisc_tracknum=NEW.shipdata_cosmisc_tracknum,
10045
 
              shipdatasum_cosmisc_packnum_tracknum=NEW.shipdata_cosmisc_packnum_tracknum,
10046
 
              shipdatasum_weight=NEW.shipdata_weight,
10047
 
              shipdatasum_base_freight=NEW.shipdata_base_freight,
10048
 
              shipdatasum_total_freight=NEW.shipdata_total_freight,
10049
 
              shipdatasum_base_freight_curr_id=NEW.shipdata_base_freight_curr_id,
10050
 
              shipdatasum_total_freight_curr_id=NEW.shipdata_total_freight_curr_id,
10051
 
              shipdatasum_shipper=_shipdatasum_shipper,
10052
 
              shipdatasum_billing_option=NEW.shipdata_billing_option,
10053
 
              shipdatasum_package_type=NEW.shipdata_package_type,
10054
 
              shipdatasum_shiphead_number=NEW.shipdata_shiphead_number
10055
 
       WHERE ((TRIM(shipdatasum_cohead_number)=TRIM(OLD.shipdata_cohead_number))
10056
 
          AND (TRIM(shipdatasum_cosmisc_tracknum)=TRIM(OLD.shipdata_cosmisc_tracknum))
10057
 
          AND (TRIM(shipdatasum_cosmisc_packnum_tracknum)=TRIM(OLD.shipdata_cosmisc_packnum_tracknum)));
10058
 
 
10059
 
       GET DIAGNOSTICS _rows = ROW_COUNT;
10060
 
       IF (_rows <= 0) THEN
10061
 
         INSERT INTO shipdatasum
10062
 
                (shipdatasum_cohead_number, shipdatasum_cosmisc_tracknum,
10063
 
                 shipdatasum_cosmisc_packnum_tracknum, shipdatasum_weight,
10064
 
                 shipdatasum_base_freight, shipdatasum_total_freight,
10065
 
                 shipdatasum_base_freight_curr_id, shipdatasum_total_freight_curr_id,
10066
 
                 shipdatasum_shipper, shipdatasum_billing_option,
10067
 
                 shipdatasum_package_type, shipdatasum_shiphead_number)
10068
 
         VALUES (NEW.shipdata_cohead_number, NEW.shipdata_cosmisc_tracknum,
10069
 
                 NEW.shipdata_cosmisc_packnum_tracknum, NEW.shipdata_weight,
10070
 
                 NEW.shipdata_base_freight, NEW.shipdata_total_freight,
10071
 
                 NEW.shipdata_base_freight_curr_id, NEW.shipdata_total_freight_curr_id,
10072
 
                 _shipdatasum_shipper, NEW.shipdata_billing_option,
10073
 
                 NEW.shipdata_package_type, NEW.shipdata_shiphead_number);
10074
 
       END IF;
10075
 
    END IF;
10076
 
  END IF;
10077
 
 
10078
 
  RETURN NEW;
10079
 
 
10080
 
END;
10081
 
$$;
10082
 
 
10083
 
 
10084
 
ALTER FUNCTION public._shipdatatrigger() OWNER TO admin;
10085
 
 
10086
 
--
10087
 
--
10088
 
 
10089
 
CREATE FUNCTION _shipformafterdeletetrigger() RETURNS trigger
10090
 
    LANGUAGE plpgsql
10091
 
    AS $$
10092
 
BEGIN
10093
 
  IF (fetchMetricValue('DefaultShipFormId') = OLD.shipform_id) THEN
10094
 
    RAISE EXCEPTION 'Cannot delete the default Shipping Form [xtuple: shipform, -1, %, %]',
10095
 
                    OLD.shipform_name, OLD.shipform_report_name;
10096
 
  END IF;
10097
 
 
10098
 
  RETURN OLD;
10099
 
END;
10100
 
$$;
10101
 
 
10102
 
 
10103
 
ALTER FUNCTION public._shipformafterdeletetrigger() OWNER TO admin;
10104
 
 
10105
 
--
10106
 
--
10107
 
 
10108
 
CREATE FUNCTION _shipheadbeforetrigger() RETURNS trigger
10109
 
    LANGUAGE plpgsql
10110
 
    AS $$
10111
 
BEGIN
10112
 
  IF ((TG_OP = 'INSERT') OR (TG_OP = 'UPDATE')) THEN
10113
 
 
10114
 
    IF (NEW.shiphead_order_type = 'SO'
10115
 
        AND NEW.shiphead_order_id   IN (SELECT cohead_id FROM cohead)) THEN
10116
 
      RETURN NEW;
10117
 
 
10118
 
    ELSEIF (NEW.shiphead_order_type = 'TO'
10119
 
        AND NEW.shiphead_order_id   IN (SELECT tohead_id FROM tohead)) THEN
10120
 
      RETURN NEW;
10121
 
 
10122
 
    END IF;
10123
 
 
10124
 
    RAISE EXCEPTION '% with id % does not exist',
10125
 
                    NEW.shiphead_order_type, NEW.shiphead_order_id;
10126
 
    RETURN OLD;
10127
 
 
10128
 
  END IF;
10129
 
 
10130
 
  RETURN NEW;
10131
 
END;
10132
 
$$;
10133
 
 
10134
 
 
10135
 
ALTER FUNCTION public._shipheadbeforetrigger() OWNER TO admin;
10136
 
 
10137
 
--
10138
 
--
10139
 
 
10140
 
CREATE FUNCTION _shiptoinfoaftertrigger() RETURNS trigger
10141
 
    LANGUAGE plpgsql
10142
 
    AS $$
10143
 
DECLARE
10144
 
  _cmnttypeid INTEGER;
10145
 
 
10146
 
BEGIN
10147
 
  IF (NEW.shipto_default) THEN
10148
 
    UPDATE shiptoinfo
10149
 
    SET shipto_default = false
10150
 
    WHERE ((shipto_cust_id=NEW.shipto_cust_id)
10151
 
    AND (shipto_id <> NEW.shipto_id));
10152
 
  END IF;
10153
 
 
10154
 
  IF (SELECT fetchMetricBool('CustomerChangeLog')) THEN
10155
 
    SELECT cmnttype_id INTO _cmnttypeid
10156
 
    FROM cmnttype
10157
 
    WHERE (cmnttype_name='ChangeLog');
10158
 
    IF (FOUND) THEN
10159
 
      IF (TG_OP = 'INSERT') THEN
10160
 
        PERFORM postComment(_cmnttypeid, 'C', NEW.shipto_cust_id, 'Created');
10161
 
 
10162
 
      ELSIF (TG_OP = 'UPDATE') THEN
10163
 
        IF (OLD.shipto_name <> NEW.shipto_name) THEN
10164
 
          PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id,
10165
 
                               ( NEW.shipto_name || ': Ship To Name Changed from "' || COALESCE(OLD.shipto_name, '') ||
10166
 
                                 '" to "' || COALESCE(NEW.shipto_name, '') || '"' ) );
10167
 
        END IF;
10168
 
        IF (OLD.shipto_shipvia <> NEW.shipto_shipvia) THEN
10169
 
          PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id,
10170
 
                               ( NEW.shipto_name || ': Ship To ShipVia Changed from "' || COALESCE(OLD.shipto_shipvia, '') ||
10171
 
                                 '" to "' || COALESCE(NEW.shipto_shipvia, '') || '"' ) );
10172
 
        END IF;
10173
 
        IF (COALESCE(OLD.shipto_taxzone_id, -1) <> COALESCE(NEW.shipto_taxzone_id, -1)) THEN
10174
 
          PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id,
10175
 
                               ( NEW.shipto_name || ': Ship To Tax Zone Changed from "' || COALESCE((SELECT taxzone_code
10176
 
                                                                                            FROM taxzone
10177
 
                                                                                            WHERE taxzone_id=OLD.shipto_taxzone_id), 'None') ||
10178
 
                                 '" to "' || COALESCE((SELECT taxzone_code
10179
 
                                              FROM taxzone
10180
 
                                              WHERE taxzone_id=NEW.shipto_taxzone_id), 'None') || '"' ) );
10181
 
        END IF;
10182
 
        IF (OLD.shipto_shipzone_id <> NEW.shipto_shipzone_id) THEN
10183
 
          PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id,
10184
 
                               ( NEW.shipto_name || ': Ship To Shipping Zone Changed from "' || (SELECT shipzone_name
10185
 
                                                                                                 FROM shipzone
10186
 
                                                                                                 WHERE shipzone_id=OLD.shipto_shipzone_id) ||
10187
 
                                 '" to "' || (SELECT shipzone_name
10188
 
                                              FROM shipzone
10189
 
                                              WHERE shipzone_id=NEW.shipto_shipzone_id) || '"' ) );
10190
 
        END IF;
10191
 
        IF (OLD.shipto_salesrep_id <> NEW.shipto_salesrep_id) THEN
10192
 
          PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id,
10193
 
                               ( NEW.shipto_name || ': Ship To Sales Rep Changed from "' || (SELECT salesrep_name
10194
 
                                                                                             FROM salesrep
10195
 
                                                                                             WHERE salesrep_id=OLD.shipto_salesrep_id) ||
10196
 
                                 '" to "' || (SELECT salesrep_name
10197
 
                                              FROM salesrep
10198
 
                                              WHERE salesrep_id=NEW.shipto_salesrep_id) || '"' ) );
10199
 
        END IF;
10200
 
        IF (OLD.shipto_active <> NEW.shipto_active) THEN
10201
 
          IF (NEW.shipto_active) THEN
10202
 
            PERFORM postComment(_cmnttypeid, 'C', NEW.shipto_cust_id, (NEW.shipto_name || ': Ship To Activated'));
10203
 
          ELSE
10204
 
            PERFORM postComment(_cmnttypeid, 'C', NEW.shipto_cust_id, (NEW.shipto_name || ': Ship To Deactivated'));
10205
 
          END IF;
10206
 
        END IF;
10207
 
      END IF;
10208
 
    END IF;
10209
 
  END IF;
10210
 
 
10211
 
  RETURN NEW;
10212
 
END;
10213
 
$$;
10214
 
 
10215
 
 
10216
 
ALTER FUNCTION public._shiptoinfoaftertrigger() OWNER TO admin;
10217
 
 
10218
 
--
10219
 
--
10220
 
 
10221
 
CREATE FUNCTION _shipviaafterdeletetrigger() RETURNS trigger
10222
 
    LANGUAGE plpgsql
10223
 
    AS $$
10224
 
BEGIN
10225
 
  IF (SELECT fetchMetricValue('DefaultShipViaId') = OLD.shipvia_id) THEN
10226
 
    RAISE EXCEPTION 'Cannot delete the default Ship-Via [xtuple: shipvia, -1, %]',
10227
 
                    OLD.shipvia_code;
10228
 
  END IF;
10229
 
 
10230
 
  RETURN OLD;
10231
 
END;
10232
 
$$;
10233
 
 
10234
 
 
10235
 
ALTER FUNCTION public._shipviaafterdeletetrigger() OWNER TO admin;
10236
 
 
10237
 
--
10238
 
--
10239
 
 
10240
 
CREATE FUNCTION _sltransaltertrigger() RETURNS trigger
10241
 
    LANGUAGE plpgsql
10242
 
    AS $$
10243
 
DECLARE
10244
 
  _externalCompany      BOOLEAN := false;
10245
 
  _updated BOOLEAN := false;
10246
 
BEGIN
10247
 
  IF(TG_OP='DELETE') THEN
10248
 
    RAISE EXCEPTION 'You may not delete Journal Transactions once they have been created.';
10249
 
  ELSIF (TG_OP = 'UPDATE') THEN 
10250
 
    IF(OLD.sltrans_id != NEW.sltrans_id) THEN
10251
 
      _updated := true;
10252
 
    ELSIF(OLD.sltrans_date != NEW.sltrans_date) THEN
10253
 
      _updated := true;
10254
 
    ELSIF(OLD.sltrans_accnt_id != NEW.sltrans_accnt_id) THEN
10255
 
      _updated := true;
10256
 
    ELSIF(OLD.sltrans_amount != NEW.sltrans_amount) THEN
10257
 
      _updated := true;
10258
 
    ELSIF(OLD.sltrans_username != NEW.sltrans_username) THEN
10259
 
      _updated := true;
10260
 
    ELSIF( (OLD.sltrans_sequence IS NULL     AND NEW.sltrans_sequence IS NOT NULL)
10261
 
        OR (OLD.sltrans_sequence IS NOT NULL AND NEW.sltrans_sequence IS NULL)
10262
 
        OR (COALESCE(OLD.sltrans_sequence,0) != COALESCE(NEW.sltrans_sequence,0)) ) THEN
10263
 
      _updated := true;
10264
 
    ELSIF( (OLD.sltrans_created IS NULL     AND NEW.sltrans_created IS NOT NULL)
10265
 
        OR (OLD.sltrans_created IS NOT NULL AND NEW.sltrans_created IS NULL)
10266
 
        OR (COALESCE(OLD.sltrans_created,now()) != COALESCE(NEW.sltrans_created,now())) ) THEN
10267
 
      _updated := true;
10268
 
    ELSIF( (OLD.sltrans_source IS NULL     AND NEW.sltrans_source IS NOT NULL)
10269
 
        OR (OLD.sltrans_source IS NOT NULL AND NEW.sltrans_source IS NULL)
10270
 
        OR (COALESCE(OLD.sltrans_source,'') != COALESCE(NEW.sltrans_source,'')) ) THEN
10271
 
      _updated := true;
10272
 
    ELSIF( (OLD.sltrans_docnumber IS NULL     AND NEW.sltrans_docnumber IS NOT NULL)
10273
 
        OR (OLD.sltrans_docnumber IS NOT NULL AND NEW.sltrans_docnumber IS NULL)
10274
 
        OR (COALESCE(OLD.sltrans_docnumber,'') != COALESCE(NEW.sltrans_docnumber,'')) ) THEN
10275
 
      _updated := true;
10276
 
    ELSIF( (OLD.sltrans_doctype IS NULL     AND NEW.sltrans_doctype IS NOT NULL)
10277
 
        OR (OLD.sltrans_doctype IS NOT NULL AND NEW.sltrans_doctype IS NULL)
10278
 
        OR (COALESCE(OLD.sltrans_doctype,'') != COALESCE(NEW.sltrans_doctype,'')) ) THEN
10279
 
      _updated := true;
10280
 
    END IF;
10281
 
 
10282
 
    IF(_updated) THEN
10283
 
      RAISE EXCEPTION 'You may not alter some Journal Transaction fields once they have been created.';
10284
 
    END IF;
10285
 
  ELSE
10286
 
    RAISE EXCEPTION 'trigger for sltrans table called in unexpected state.';
10287
 
  END IF;
10288
 
  RETURN NEW;
10289
 
END;
10290
 
$$;
10291
 
 
10292
 
 
10293
 
ALTER FUNCTION public._sltransaltertrigger() OWNER TO admin;
10294
 
 
10295
 
--
10296
 
--
10297
 
 
10298
 
CREATE FUNCTION _sltransinserttrigger() RETURNS trigger
10299
 
    LANGUAGE plpgsql
10300
 
    AS $$
10301
 
DECLARE
10302
 
  _reqNotes BOOLEAN;
10303
 
  _externalCompany      BOOLEAN := false;
10304
 
BEGIN
10305
 
  -- Checks
10306
 
  SELECT company_external INTO _externalCompany
10307
 
  FROM company JOIN accnt ON (company_number=accnt_company)
10308
 
  WHERE (accnt_id=NEW.sltrans_accnt_id);
10309
 
  IF (_externalCompany) THEN
10310
 
    RAISE EXCEPTION 'Transactions are not allowed for G/L Accounts with External Company segments.';
10311
 
  END IF;
10312
 
  
10313
 
  RETURN NEW;
10314
 
END;
10315
 
$$;
10316
 
 
10317
 
 
10318
 
ALTER FUNCTION public._sltransinserttrigger() OWNER TO admin;
10319
 
 
10320
 
--
10321
 
--
10322
 
 
10323
 
CREATE FUNCTION _soheadtrigger() RETURNS trigger
10324
 
    LANGUAGE plpgsql
10325
 
    AS $$
10326
 
DECLARE
10327
 
  _p RECORD;
10328
 
  _a RECORD;
10329
 
  _w RECORD;
10330
 
  _shiptoId INTEGER;
10331
 
  _addrId INTEGER;
10332
 
  _prjId INTEGER;
10333
 
  _check BOOLEAN;
10334
 
  _numGen CHAR(1);
10335
 
 
10336
 
BEGIN
10337
 
 
10338
 
  -- Checks
10339
 
  -- Start with privileges
10340
 
  IF (TG_OP = 'INSERT') THEN
10341
 
    IF ( (NOT checkPrivilege('MaintainSalesOrders')) AND
10342
 
       (NOT checkPrivilege('EnterReceipts')) ) THEN
10343
 
      RAISE EXCEPTION 'You do not have privileges to create a Sales Order.';
10344
 
    END IF;
10345
 
  ELSIF (TG_OP = 'UPDATE') THEN
10346
 
    IF ( (NOT checkPrivilege('MaintainSalesOrders')) AND
10347
 
         (NOT checkPrivilege('IssueStockToShipping')) AND
10348
 
         (NEW.cohead_holdtype = OLD.cohead_holdtype) ) THEN
10349
 
      RAISE EXCEPTION 'You do not have privileges to alter a Sales Order.';
10350
 
    END IF;
10351
 
  ELSE
10352
 
    IF ( (NOT checkPrivilege('MaintainSalesOrders')) AND
10353
 
         (NOT checkPrivilege('IssueStockToShipping')) ) THEN
10354
 
      RAISE EXCEPTION 'You do not have privileges to alter a Sales Order.';
10355
 
    END IF;
10356
 
  END IF;
10357
 
 
10358
 
  -- If this is imported, check the order number
10359
 
  IF (TG_OP = 'INSERT') THEN
10360
 
    IF (NEW.cohead_imported) THEN
10361
 
      SELECT fetchMetricText('CONumberGeneration') INTO _numGen;
10362
 
      IF ((NEW.cohead_number IS NULL) AND (_numGen='M')) THEN
10363
 
        RAISE EXCEPTION 'You must supply an Order Number.';
10364
 
      ELSE
10365
 
        IF (NEW.cohead_number IS NULL) THEN
10366
 
          SELECT fetchsonumber() INTO NEW.cohead_number;
10367
 
        END IF;
10368
 
      END IF;
10369
 
    END IF;
10370
 
 
10371
 
    IF (fetchMetricText('CONumberGeneration') IN ('A','O')) THEN
10372
 
      --- clear the number from the issue cache
10373
 
      PERFORM clearNumberIssue('SoNumber', NEW.cohead_number);
10374
 
    END IF;
10375
 
  ELSE
10376
 
    IF (TG_OP = 'UPDATE') THEN
10377
 
      IF (NEW.cohead_number <> OLD.cohead_number) THEN
10378
 
        RAISE EXCEPTION 'The order number may not be changed.';
10379
 
      END IF;
10380
 
    END IF;
10381
 
  END IF;
10382
 
 
10383
 
  IF (TG_OP IN ('INSERT','UPDATE')) THEN
10384
 
 
10385
 
    -- Get Customer data
10386
 
    IF (NEW.cohead_shipto_id IS NULL) THEN
10387
 
      SELECT cust_creditstatus,cust_number,cust_usespos,cust_blanketpos,cust_ffbillto,
10388
 
             cust_ffshipto,cust_name,cust_salesrep_id,cust_terms_id,cust_shipvia,
10389
 
             cust_shipchrg_id,cust_shipform_id,cust_commprcnt,cust_curr_id,cust_taxzone_id,
10390
 
             cntct.*,addr.*,
10391
 
             shipto_id,shipto_addr_id,shipto_name,shipto_salesrep_id,shipto_shipvia,
10392
 
             shipto_shipchrg_id,shipto_shipform_id,shipto_commission,shipto_taxzone_id INTO _p
10393
 
      FROM custinfo
10394
 
        LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)
10395
 
        LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)
10396
 
        LEFT OUTER JOIN shiptoinfo ON ((cust_id=shipto_cust_id) AND shipto_default)
10397
 
      WHERE (cust_id=NEW.cohead_cust_id);
10398
 
    ELSE
10399
 
      SELECT cust_creditstatus,cust_number,cust_usespos,cust_blanketpos,cust_ffbillto,
10400
 
             cust_ffshipto,cust_name,cust_salesrep_id,cust_terms_id,cust_shipvia,
10401
 
             cust_shipchrg_id,cust_shipform_id,cust_commprcnt,cust_curr_id,cust_taxzone_id,
10402
 
             cntct.*,addr.*,
10403
 
             shipto_id,shipto_addr_id,shipto_name,shipto_salesrep_id,shipto_shipvia,
10404
 
             shipto_shipchrg_id,shipto_shipform_id,shipto_commission,shipto_taxzone_id INTO _p
10405
 
      FROM shiptoinfo,custinfo
10406
 
        LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)
10407
 
        LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)
10408
 
      WHERE ((cust_id=NEW.cohead_cust_id)
10409
 
        AND  (shipto_id=NEW.cohead_shipto_id));
10410
 
    END IF;
10411
 
 
10412
 
    -- If there is customer data, then we can get to work
10413
 
    IF (FOUND) THEN
10414
 
 
10415
 
      -- Check Credit
10416
 
      IF (TG_OP = 'INSERT') THEN
10417
 
          IF (_p.cust_creditstatus = 'H') THEN
10418
 
            SELECT checkPrivilege('CreateSOForHoldCustomer') INTO _check;
10419
 
            IF NOT (_check) THEN
10420
 
              RAISE EXCEPTION 'Customer % has been placed
10421
 
                               on a Credit Hold and you do not have
10422
 
                               privilege to create Sales Orders for
10423
 
                               Customers on Credit Hold.  The selected
10424
 
                               Customer must be taken off of Credit Hold
10425
 
                               before you may create a new Sales Order
10426
 
                               for the Customer.',_p.cust_number;
10427
 
            ELSE
10428
 
              NEW.cohead_holdtype='C';
10429
 
            END IF;
10430
 
          END IF;
10431
 
          IF (_p.cust_creditstatus = 'W') THEN
10432
 
            SELECT checkPrivilege('CreateSOForWarnCustomer') INTO _check;
10433
 
            IF NOT (_check) THEN
10434
 
              RAISE EXCEPTION 'Customer % has been placed on
10435
 
                              a Credit Warning and you do not have
10436
 
                              privilege to create Sales Orders for
10437
 
                              Customers on Credit Warning.  The
10438
 
                              selected Customer must be taken off of
10439
 
                              Credit Warning before you may create a
10440
 
                              new Sales Order for the Customer.',_p.cust_number;
10441
 
            ELSE
10442
 
              NEW.cohead_holdtype='C';
10443
 
            END IF;
10444
 
          END IF;
10445
 
 
10446
 
          -- Set to defaults if values not provided
10447
 
          NEW.cohead_shipto_id  := COALESCE(NEW.cohead_shipto_id,_p.shipto_id);
10448
 
          NEW.cohead_terms_id           := COALESCE(NEW.cohead_terms_id,_p.cust_terms_id);
10449
 
          NEW.cohead_orderdate          := COALESCE(NEW.cohead_orderdate,current_date);
10450
 
          NEW.cohead_packdate           := COALESCE(NEW.cohead_packdate,NEW.cohead_orderdate);
10451
 
          NEW.cohead_curr_id            := COALESCE(NEW.cohead_curr_id,_p.cust_curr_id,basecurrid());
10452
 
          NEW.cohead_freight            := COALESCE(NEW.cohead_freight,0);
10453
 
          NEW.cohead_custponumber       := COALESCE(NEW.cohead_custponumber,'');
10454
 
          NEW.cohead_ordercomments      := COALESCE(NEW.cohead_ordercomments,'');
10455
 
          NEW.cohead_shipcomments       := COALESCE(NEW.cohead_shipcomments,'');
10456
 
          NEW.cohead_shiptophone        := COALESCE(NEW.cohead_shiptophone,'');
10457
 
          NEW.cohead_misc               := COALESCE(NEW.cohead_misc,0);
10458
 
          NEW.cohead_misc_descrip       := COALESCE(NEW.cohead_misc_descrip,'');
10459
 
          NEW.cohead_shipcomplete       := COALESCE(NEW.cohead_shipcomplete,false);
10460
 
 
10461
 
          IF (_p.shipto_id IS NOT NULL) THEN -- Pull in over ride values
10462
 
            NEW.cohead_salesrep_id      := COALESCE(NEW.cohead_salesrep_id,_p.shipto_salesrep_id);
10463
 
            NEW.cohead_shipvia          := COALESCE(NEW.cohead_shipvia,_p.shipto_shipvia);
10464
 
            NEW.cohead_shipchrg_id      := COALESCE(NEW.cohead_shipchrg_id,_p.shipto_shipchrg_id);
10465
 
            NEW.cohead_shipform_id      := COALESCE(NEW.cohead_shipform_id,_p.shipto_shipform_id);
10466
 
            NEW.cohead_commission       := COALESCE(NEW.cohead_commission,_p.shipto_commission);
10467
 
            IF (NEW.cohead_taxzone_id=-1) THEN
10468
 
              NEW.cohead_taxzone_id     := NULL;
10469
 
            ELSE
10470
 
              NEW.cohead_taxzone_id     := COALESCE(NEW.cohead_taxzone_id,_p.shipto_taxzone_id);
10471
 
            END IF;
10472
 
          ELSE
10473
 
            NEW.cohead_salesrep_id      := COALESCE(NEW.cohead_salesrep_id,_p.cust_salesrep_id);
10474
 
            NEW.cohead_shipvia          := COALESCE(NEW.cohead_shipvia,_p.cust_shipvia);
10475
 
            NEW.cohead_shipchrg_id      := COALESCE(NEW.cohead_shipchrg_id,_p.cust_shipchrg_id);
10476
 
            NEW.cohead_shipform_id      := COALESCE(NEW.cohead_shipform_id,_p.cust_shipform_id);
10477
 
            NEW.cohead_commission       := COALESCE(NEW.cohead_commission,_p.cust_commprcnt);
10478
 
            IF (NEW.cohead_taxzone_id=-1) THEN
10479
 
              NEW.cohead_taxzone_id     := NULL;
10480
 
            ELSE
10481
 
              NEW.cohead_taxzone_id     := COALESCE(NEW.cohead_taxzone_id,_p.cust_taxzone_id);
10482
 
            END IF;
10483
 
          END IF;
10484
 
 
10485
 
          IF ((NEW.cohead_warehous_id IS NULL) OR (NEW.cohead_fob IS NULL)) THEN
10486
 
            IF (NEW.cohead_warehous_id IS NULL) THEN
10487
 
              SELECT warehous_id,warehous_fob INTO _w
10488
 
              FROM usrpref, whsinfo
10489
 
              WHERE ((warehous_id=CAST(usrpref_value AS INTEGER))
10490
 
                AND (warehous_shipping)
10491
 
                AND (warehous_active)
10492
 
                AND (usrpref_username=getEffectiveXtUser())
10493
 
                AND (usrpref_name='PreferredWarehouse'));
10494
 
            ELSE
10495
 
              SELECT warehous_id,warehous_fob INTO _w
10496
 
              FROM whsinfo
10497
 
              WHERE (warehous_id=NEW.cohead_warehous_id);
10498
 
            END IF;
10499
 
 
10500
 
            IF (FOUND) THEN
10501
 
              NEW.cohead_warehous_id    := COALESCE(NEW.cohead_warehous_id,_w.warehous_id);
10502
 
              NEW.cohead_fob            := COALESCE(NEW.cohead_fob,_w.warehous_fob);
10503
 
            END IF;
10504
 
          END IF;
10505
 
 
10506
 
      END IF;
10507
 
 
10508
 
      -- Only Check P/O logic for imports, because UI checks when entire order is saved
10509
 
      IF (NEW.cohead_imported) THEN
10510
 
 
10511
 
        -- Check for required Purchase Order
10512
 
        IF (_p.cust_usespos AND ((NEW.cohead_custponumber IS NULL) OR (TRIM(BOTH FROM NEW.cohead_custponumber)=''))) THEN
10513
 
            RAISE EXCEPTION 'You must enter a Customer P/O for this Sales Order.';
10514
 
        END IF;
10515
 
 
10516
 
        -- Check for duplicate Purchase Orders if not allowed
10517
 
        IF (_p.cust_usespos AND NOT (_p.cust_blanketpos)) THEN
10518
 
          SELECT cohead_id INTO _a
10519
 
          FROM cohead
10520
 
          WHERE ((cohead_cust_id=NEW.cohead_cust_id)
10521
 
          AND  (cohead_id<>NEW.cohead_id)
10522
 
          AND  (UPPER(cohead_custponumber) = UPPER(NEW.cohead_custponumber)) )
10523
 
          UNION
10524
 
          SELECT quhead_id
10525
 
          FROM quhead
10526
 
          WHERE ((quhead_cust_id=NEW.cohead_cust_id)
10527
 
          AND  (quhead_id<>NEW.cohead_id)
10528
 
          AND  (UPPER(quhead_custponumber) = UPPER(NEW.cohead_custponumber)) );
10529
 
          IF (FOUND) THEN
10530
 
            RAISE EXCEPTION 'This Customer does not use Blanket P/O
10531
 
                            Numbers and the P/O Number you entered has
10532
 
                            already been used for another Sales Order.
10533
 
                            Please verify the P/O Number and either
10534
 
                            enter a new P/O Number or add to the
10535
 
                            existing Sales Order.';
10536
 
         END IF;
10537
 
        END IF;
10538
 
      END IF;
10539
 
 
10540
 
      --Auto create project if applicable
10541
 
      IF ((TG_OP = 'INSERT') AND (COALESCE(NEW.cohead_prj_id,-1)=-1)) THEN
10542
 
        SELECT fetchMetricBool('AutoCreateProjectsForOrders') INTO _check;
10543
 
        IF (_check) THEN
10544
 
          SELECT NEXTVAL('prj_prj_id_seq') INTO _prjId;
10545
 
          NEW.cohead_prj_id := _prjId;
10546
 
          INSERT INTO prj (prj_id, prj_number, prj_name, prj_descrip,
10547
 
                           prj_status, prj_so, prj_wo, prj_po,
10548
 
                           prj_owner_username, prj_start_date, prj_due_date,
10549
 
                           prj_assigned_date, prj_completed_date, prj_username,
10550
 
                           prj_recurring_prj_id, prj_crmacct_id,
10551
 
                           prj_cntct_id, prj_prjtype_id)
10552
 
          SELECT _prjId, NEW.cohead_number, NEW.cohead_number, 'Auto Generated Project from Sales Order.',
10553
 
                 'O', TRUE, TRUE, TRUE,
10554
 
                 getEffectiveXTUser(), NEW.cohead_orderdate, NEW.cohead_packdate,
10555
 
                 NEW.cohead_orderdate, NULL, getEffectiveXTUser(),
10556
 
                 NULL, crmacct_id,
10557
 
                 NEW.cohead_billto_cntct_id, NULL
10558
 
          FROM crmacct
10559
 
          WHERE (crmacct_cust_id=NEW.cohead_cust_id);
10560
 
        END IF;
10561
 
      END IF;
10562
 
 
10563
 
      IF (TG_OP = 'UPDATE') THEN
10564
 
        SELECT true INTO _check
10565
 
        FROM coitem
10566
 
        WHERE ( (coitem_status='C')
10567
 
        AND (coitem_cohead_id=NEW.cohead_id) )
10568
 
        LIMIT 1;
10569
 
 
10570
 
        IF (NOT FOUND) THEN
10571
 
 
10572
 
        --Update project references on supply
10573
 
        UPDATE pr SET pr_prj_id=NEW.cohead_prj_id
10574
 
                   FROM coitem
10575
 
                   WHERE ((coitem_cohead_id=NEW.cohead_id)
10576
 
                   AND  (coitem_order_type='R')
10577
 
                   AND  (coitem_order_id=pr_id));
10578
 
 
10579
 
        PERFORM changeWoProject(coitem_order_id, NEW.cohead_prj_id, TRUE)
10580
 
                    FROM coitem
10581
 
                    WHERE ((coitem_cohead_id=NEW.cohead_id)
10582
 
                    AND  (coitem_order_type='W'));
10583
 
        ELSE
10584
 
          IF NEW.cohead_prj_id <> COALESCE(OLD.cohead_prj_id,-1) THEN
10585
 
            RAISE EXCEPTION 'You can not change the project ID on orders with closed lines.';
10586
 
          END IF;
10587
 
        END IF;
10588
 
      END IF;
10589
 
 
10590
 
      -- Deal with Billing Address
10591
 
      IF (TG_OP = 'INSERT') THEN
10592
 
        IF (_p.cust_ffbillto) THEN
10593
 
          -- If they didn't supply data, we'll put in the bill to contact and address
10594
 
          NEW.cohead_billto_cntct_id=COALESCE(NEW.cohead_billto_cntct_id,_p.cntct_id);
10595
 
          NEW.cohead_billto_cntct_honorific=COALESCE(NEW.cohead_billto_cntct_honorific,_p.cntct_honorific,'');
10596
 
          NEW.cohead_billto_cntct_first_name=COALESCE(NEW.cohead_billto_cntct_first_name,_p.cntct_first_name,'');
10597
 
          NEW.cohead_billto_cntct_middle=COALESCE(NEW.cohead_billto_cntct_middle,_p.cntct_middle,'');
10598
 
          NEW.cohead_billto_cntct_last_name=COALESCE(NEW.cohead_billto_cntct_last_name,_p.cntct_last_name,'');
10599
 
          NEW.cohead_billto_cntct_phone=COALESCE(NEW.cohead_billto_cntct_phone,_p.cntct_phone,'');
10600
 
          NEW.cohead_billto_cntct_title=COALESCE(NEW.cohead_billto_cntct_title,_p.cntct_title,'');
10601
 
          NEW.cohead_billto_cntct_fax=COALESCE(NEW.cohead_billto_cntct_fax,_p.cntct_fax,'');
10602
 
          NEW.cohead_billto_cntct_email=COALESCE(NEW.cohead_billto_cntct_email,_p.cntct_email,'');
10603
 
          NEW.cohead_billtoname=COALESCE(NEW.cohead_billtoname,_p.cust_name,'');
10604
 
          NEW.cohead_billtoaddress1=COALESCE(NEW.cohead_billtoaddress1,_p.addr_line1,'');
10605
 
          NEW.cohead_billtoaddress2=COALESCE(NEW.cohead_billtoaddress2,_p.addr_line2,'');
10606
 
          NEW.cohead_billtoaddress3=COALESCE(NEW.cohead_billtoaddress3,_p.addr_line3,'');
10607
 
          NEW.cohead_billtocity=COALESCE(NEW.cohead_billtocity,_p.addr_city,'');
10608
 
          NEW.cohead_billtostate=COALESCE(NEW.cohead_billtostate,_p.addr_state,'');
10609
 
          NEW.cohead_billtozipcode=COALESCE(NEW.cohead_billtozipcode,_p.addr_postalcode,'');
10610
 
          NEW.cohead_billtocountry=COALESCE(NEW.cohead_billtocountry,_p.addr_country,'');
10611
 
        ELSE
10612
 
          -- Free form not allowed, we're going to put in the address regardless
10613
 
          NEW.cohead_billto_cntct_id=_p.cntct_id;
10614
 
          NEW.cohead_billto_cntct_honorific=COALESCE(_p.cntct_honorific,'');
10615
 
          NEW.cohead_billto_cntct_first_name=COALESCE(_p.cntct_first_name,'');
10616
 
          NEW.cohead_billto_cntct_middle=COALESCE(_p.cntct_middle,'');
10617
 
          NEW.cohead_billto_cntct_last_name=COALESCE(_p.cntct_last_name,'');
10618
 
          NEW.cohead_billto_cntct_phone=COALESCE(_p.cntct_phone,'');
10619
 
          NEW.cohead_billto_cntct_title=COALESCE(_p.cntct_title,'');
10620
 
          NEW.cohead_billto_cntct_fax=COALESCE(_p.cntct_fax,'');
10621
 
          NEW.cohead_billto_cntct_email=COALESCE(_p.cntct_email,'');
10622
 
          NEW.cohead_billtoname=COALESCE(_p.cust_name,'');
10623
 
          NEW.cohead_billtoaddress1=COALESCE(_p.addr_line1,'');
10624
 
          NEW.cohead_billtoaddress2=COALESCE(_p.addr_line2,'');
10625
 
          NEW.cohead_billtoaddress3=COALESCE(_p.addr_line3,'');
10626
 
          NEW.cohead_billtocity=COALESCE(_p.addr_city,'');
10627
 
          NEW.cohead_billtostate=COALESCE(_p.addr_state,'');
10628
 
          NEW.cohead_billtozipcode=COALESCE(_p.addr_postalcode,'');
10629
 
          NEW.cohead_billtocountry=COALESCE(_p.addr_country,'');
10630
 
        END IF;
10631
 
      END IF;
10632
 
 
10633
 
      -- Now let's look at Shipto Address
10634
 
      -- If there's nothing in the address fields and there is a shipto id
10635
 
      -- or there is a default address available, let's put in some shipto address data
10636
 
      IF ((TG_OP = 'INSERT')
10637
 
        AND NOT ((NEW.cohead_shipto_id IS NULL) AND NOT _p.cust_ffshipto)
10638
 
        AND (NEW.cohead_shipto_cntct_id IS NULL)
10639
 
        AND (NEW.cohead_shipto_cntct_honorific IS NULL)
10640
 
        AND (NEW.cohead_shipto_cntct_first_name IS NULL)
10641
 
        AND (NEW.cohead_shipto_cntct_middle IS NULL)
10642
 
        AND (NEW.cohead_shipto_cntct_last_name IS NULL)
10643
 
        AND (NEW.cohead_shipto_cntct_suffix IS NULL)
10644
 
        AND (NEW.cohead_shipto_cntct_phone IS NULL)
10645
 
        AND (NEW.cohead_shipto_cntct_title IS NULL)
10646
 
        AND (NEW.cohead_shipto_cntct_fax IS NULL)
10647
 
        AND (NEW.cohead_shipto_cntct_email IS NULL)
10648
 
        AND (NEW.cohead_shiptoname IS NULL)
10649
 
        AND (NEW.cohead_shiptoaddress1 IS NULL)
10650
 
        AND (NEW.cohead_shiptoaddress2 IS NULL)
10651
 
        AND (NEW.cohead_shiptoaddress3 IS NULL)
10652
 
        AND (NEW.cohead_shiptocity IS NULL)
10653
 
        AND (NEW.cohead_shiptostate IS NULL)
10654
 
        AND (NEW.cohead_shiptocountry IS NULL)) THEN
10655
 
        IF ((NEW.cohead_shipto_id IS NULL) AND (_p.shipto_id IS NOT NULL)) THEN
10656
 
          _shiptoId := _p.shipto_addr_id;
10657
 
        ELSE
10658
 
          _shiptoId := NEW.cohead_shipto_id;
10659
 
        END IF;
10660
 
 
10661
 
        SELECT * INTO _a
10662
 
        FROM shiptoinfo
10663
 
          LEFT OUTER JOIN addr ON (addr_id=shipto_addr_id)
10664
 
          LEFT OUTER JOIN cntct ON (cntct_id=shipto_cntct_id)
10665
 
        WHERE (shipto_id=_shiptoId);
10666
 
 
10667
 
        NEW.cohead_shipto_cntct_id := _a.cntct_id;
10668
 
        NEW.cohead_shipto_cntct_honorific := COALESCE(_a.cntct_honorific,'');
10669
 
        NEW.cohead_shipto_cntct_first_name := COALESCE(_a.cntct_first_name,'');
10670
 
        NEW.cohead_shipto_cntct_middle := COALESCE(_a.cntct_middle,'');
10671
 
        NEW.cohead_shipto_cntct_last_name := COALESCE(_a.cntct_last_name,'');
10672
 
        NEW.cohead_shipto_cntct_suffix := COALESCE(_a.cntct_suffix,'');
10673
 
        NEW.cohead_shipto_cntct_phone := COALESCE(_a.cntct_phone,'');
10674
 
        NEW.cohead_shipto_cntct_title := COALESCE(_a.cntct_title,'');
10675
 
        NEW.cohead_shipto_cntct_fax := COALESCE(_a.cntct_fax,'');
10676
 
        NEW.cohead_shipto_cntct_email := COALESCE(_a.cntct_email,'');
10677
 
        NEW.cohead_shiptoname := COALESCE(_p.shipto_name,'');
10678
 
        NEW.cohead_shiptoaddress1 := COALESCE(_a.addr_line1,'');
10679
 
        NEW.cohead_shiptoaddress2 := COALESCE(_a.addr_line2,'');
10680
 
        NEW.cohead_shiptoaddress3 := COALESCE(_a.addr_line3,'');
10681
 
        NEW.cohead_shiptocity := COALESCE(_a.addr_city,'');
10682
 
        NEW.cohead_shiptostate := COALESCE(_a.addr_state,'');
10683
 
        NEW.cohead_shiptozipcode := COALESCE(_a.addr_postalcode,'');
10684
 
        NEW.cohead_shiptocountry := COALESCE(_a.addr_country,'');
10685
 
      ELSE
10686
 
        IF (_p.cust_ffshipto) THEN
10687
 
          -- Use Address Save function to see if the new address entered matches
10688
 
          -- data for the shipto number.  If not that will insert new address for CRM
10689
 
          SELECT SaveAddr(
10690
 
            NULL,
10691
 
            NULL,
10692
 
            NEW.cohead_shiptoaddress1,
10693
 
            NEW.cohead_shiptoaddress2,
10694
 
            NEW.cohead_shiptoaddress3,
10695
 
            NEW.cohead_shiptocity,
10696
 
            NEW.cohead_shiptostate,
10697
 
            NEW.cohead_shiptozipcode,
10698
 
            NEW.cohead_shiptocountry,
10699
 
            'CHANGEONE') INTO _addrId;
10700
 
          SELECT shipto_addr_id INTO _shiptoid FROM shiptoinfo WHERE (shipto_id=NEW.cohead_shipto_id);
10701
 
          -- If the address passed doesn't match shipto address, then it's something else
10702
 
          IF (_shiptoid <> _addrId) THEN
10703
 
            NEW.cohead_shipto_id := NULL;
10704
 
          END IF;
10705
 
        ELSE
10706
 
          SELECT cohead_shipto_id INTO _shiptoid FROM cohead WHERE (cohead_id=NEW.cohead_id);
10707
 
          -- Get the shipto address
10708
 
          IF (COALESCE(NEW.cohead_shipto_id,-1) <> COALESCE(_shiptoid,-1)) THEN
10709
 
            SELECT * INTO _a
10710
 
            FROM shiptoinfo
10711
 
              LEFT OUTER JOIN cntct ON (shipto_cntct_id=cntct_id)
10712
 
              LEFT OUTER JOIN addr ON (shipto_addr_id=addr_id)
10713
 
            WHERE (shipto_id=NEW.cohead_shipto_id);
10714
 
            IF (FOUND) THEN
10715
 
              -- Free form not allowed so we're going to make sure address matches Shipto data
10716
 
              NEW.cohead_shipto_cntct_id=_a.cntct_id;
10717
 
              NEW.cohead_shipto_cntct_honorific=COALESCE(_a.cntct_honorific,'');
10718
 
              NEW.cohead_shipto_cntct_first_name=COALESCE(_a.cntct_first_name,'');
10719
 
              NEW.cohead_shipto_cntct_middle=COALESCE(_a.cntct_middle,'');
10720
 
              NEW.cohead_shipto_cntct_last_name=COALESCE(_a.cntct_last_name,'');
10721
 
              NEW.cohead_shipto_cntct_phone=COALESCE(_a.cntct_phone,'');
10722
 
              NEW.cohead_shipto_cntct_title=COALESCE(_a.cntct_title,'');
10723
 
              NEW.cohead_shipto_cntct_fax=COALESCE(_a.cntct_fax,'');
10724
 
              NEW.cohead_shipto_cntct_email=COALESCE(_a.cntct_email,'');
10725
 
              NEW.cohead_shiptoname := COALESCE(_a.shipto_name,'');
10726
 
              NEW.cohead_shiptophone := COALESCE(_a.cntct_phone,'');
10727
 
              NEW.cohead_shiptoaddress1 := COALESCE(_a.addr_line1,'');
10728
 
              NEW.cohead_shiptoaddress2 := COALESCE(_a.addr_line2,'');
10729
 
              NEW.cohead_shiptoaddress3 := COALESCE(_a.addr_line3,'');
10730
 
              NEW.cohead_shiptocity := COALESCE(_a.addr_city,'');
10731
 
              NEW.cohead_shiptostate := COALESCE(_a.addr_state,'');
10732
 
              NEW.cohead_shiptozipcode := COALESCE(_a.addr_postalcode,'');
10733
 
              NEW.cohead_shiptocountry := COALESCE(_a.addr_country,'');
10734
 
            ELSE
10735
 
              -- If no shipto data and free form not allowed, this won't work
10736
 
              RAISE EXCEPTION 'Free form Shipto is not allowed on this Customer. You must supply a valid Shipto ID.';
10737
 
            END IF;
10738
 
          END IF;
10739
 
        END IF;
10740
 
      END IF;
10741
 
    END IF;
10742
 
  END IF;
10743
 
 
10744
 
  IF ( SELECT (metric_value='t')
10745
 
       FROM metric
10746
 
       WHERE (metric_name='SalesOrderChangeLog') ) THEN
10747
 
 
10748
 
    IF (TG_OP = 'INSERT') THEN
10749
 
      PERFORM postComment('ChangeLog', 'S', NEW.cohead_id, 'Created');
10750
 
 
10751
 
    ELSIF (TG_OP = 'UPDATE') THEN
10752
 
 
10753
 
      IF ( (OLD.cohead_terms_id <> NEW.cohead_terms_id) AND
10754
 
           (OLD.cohead_cust_id = NEW.cohead_cust_id) ) THEN
10755
 
        PERFORM postComment( 'ChangeLog', 'S', NEW.cohead_id,
10756
 
                             ('Terms Changed from "' || oldterms.terms_code || '" to "' || newterms.terms_code || '"') )
10757
 
        FROM terms AS oldterms, terms AS newterms
10758
 
        WHERE ( (oldterms.terms_id=OLD.cohead_terms_id)
10759
 
         AND (newterms.terms_id=NEW.cohead_terms_id) );
10760
 
      END IF;
10761
 
 
10762
 
      IF ( (OLD.cohead_shipvia <> NEW.cohead_shipvia) AND
10763
 
           (OLD.cohead_cust_id = NEW.cohead_cust_id) ) THEN
10764
 
        PERFORM postComment ('ChangeLog', 'S', New.cohead_id, ('Shipvia Changed from "' || OLD.cohead_shipvia || '" to "' || NEW.cohead_shipvia || '"'));
10765
 
      END IF;
10766
 
 
10767
 
      IF (OLD.cohead_holdtype <> NEW.cohead_holdtype) THEN
10768
 
        PERFORM postComment( 'ChangeLog', 'S', NEW.cohead_id,
10769
 
                             ( 'Hold Type Changed from ' || (CASE OLD.cohead_holdtype WHEN('N') THEN 'No Hold'
10770
 
                                                                                      WHEN('C') THEN 'Credit Hold'
10771
 
                                                                                      WHEN('P') THEN 'Packing Hold'
10772
 
                                                                                      WHEN('S') THEN 'Shipping Hold'
10773
 
                                                                                      ELSE 'Unknown/Error' END) ||
10774
 
                               ' to ' || (CASE NEW.cohead_holdtype WHEN('N') THEN 'No Hold'
10775
 
                                                                   WHEN('C') THEN 'Credit Hold'
10776
 
                                                                   WHEN('P') THEN 'Packing Hold'
10777
 
                                                                   WHEN('S') THEN 'Shipping Hold'
10778
 
                                                                   ELSE 'Unknown/Error' END) ) );
10779
 
      END IF;
10780
 
 
10781
 
    ELSIF (TG_OP = 'DELETE') THEN
10782
 
      DELETE FROM docass WHERE docass_source_id = OLD.cohead_id AND docass_source_type = 'S';
10783
 
      DELETE FROM docass WHERE docass_target_id = OLD.cohead_id AND docass_target_type = 'S';
10784
 
 
10785
 
      DELETE FROM comment
10786
 
      WHERE ( (comment_source='S')
10787
 
       AND (comment_source_id=OLD.cohead_id) );
10788
 
    END IF;
10789
 
  END IF;
10790
 
 
10791
 
  IF (TG_OP = 'UPDATE') THEN
10792
 
    IF ( (NOT (OLD.cohead_holdtype = 'N')) AND
10793
 
         (NEW.cohead_holdtype='N') ) THEN
10794
 
      PERFORM postEvent('SoReleased', 'S', NEW.cohead_id,
10795
 
                        NEW.cohead_warehous_id, NEW.cohead_number,
10796
 
                        NULL, NULL, NULL, NULL);
10797
 
    END IF;
10798
 
 
10799
 
    IF (OLD.cohead_ordercomments <> NEW.cohead_ordercomments) THEN
10800
 
      PERFORM postEvent('SoNotesChanged', 'S', NEW.cohead_id,
10801
 
                        NEW.cohead_warehous_id, NEW.cohead_number,
10802
 
                        NULL, NULL, NULL, NULL);
10803
 
    END IF;
10804
 
 
10805
 
    IF ((OLD.cohead_shipchrg_id != NEW.cohead_shipchrg_id)
10806
 
        OR (OLD.cohead_freight != NEW.cohead_freight)
10807
 
        OR (OLD.cohead_shipvia != NEW.cohead_shipvia)) THEN
10808
 
      UPDATE shiphead SET
10809
 
        shiphead_shipchrg_id=
10810
 
             CASE WHEN (NEW.cohead_shipchrg_id <= 0) THEN NULL
10811
 
                  ELSE NEW.cohead_shipchrg_id
10812
 
             END,
10813
 
        shiphead_freight=NEW.cohead_freight,
10814
 
        shiphead_shipvia=NEW.cohead_shipvia
10815
 
      WHERE ((shiphead_order_type='SO')
10816
 
      AND  (shiphead_order_id=NEW.cohead_id)
10817
 
      AND  (NOT shiphead_shipped));
10818
 
    END IF;
10819
 
  END IF;
10820
 
 
10821
 
  IF (TG_OP = 'DELETE') THEN
10822
 
    RETURN OLD;
10823
 
  ELSE
10824
 
    NEW.cohead_lastupdated = CURRENT_TIMESTAMP;
10825
 
 
10826
 
    RETURN NEW;
10827
 
  END IF;
10828
 
 
10829
 
END;
10830
 
$$;
10831
 
 
10832
 
 
10833
 
ALTER FUNCTION public._soheadtrigger() OWNER TO admin;
10834
 
 
10835
 
--
10836
 
--
10837
 
 
10838
 
CREATE FUNCTION _soheadtriggerafter() RETURNS trigger
10839
 
    LANGUAGE plpgsql
10840
 
    AS $$
10841
 
BEGIN
10842
 
  IF (COALESCE(NEW.cohead_taxzone_id,-1) <> COALESCE(OLD.cohead_taxzone_id,-1)) THEN
10843
 
    UPDATE coitem SET coitem_taxtype_id=getItemTaxType(itemsite_item_id,NEW.cohead_taxzone_id)
10844
 
    FROM itemsite
10845
 
    WHERE ((itemsite_id=coitem_itemsite_id)
10846
 
     AND (coitem_cohead_id=NEW.cohead_id));
10847
 
  END IF;
10848
 
 
10849
 
  -- update comments on any associated drop ship POs
10850
 
  IF (COALESCE(NEW.cohead_shipcomments, TEXT('')) <> COALESCE(OLD.cohead_shipcomments, TEXT(''))) THEN
10851
 
    UPDATE pohead SET pohead_comments=NEW.cohead_shipcomments
10852
 
    FROM poitem JOIN coitem ON (coitem_cohead_id=NEW.cohead_id AND coitem_order_type='P' AND coitem_order_id=poitem_id)
10853
 
    WHERE (pohead_id=poitem_pohead_id);
10854
 
  END IF;
10855
 
 
10856
 
  RETURN NEW;
10857
 
END;
10858
 
$$;
10859
 
 
10860
 
 
10861
 
ALTER FUNCTION public._soheadtriggerafter() OWNER TO admin;
10862
 
 
10863
 
--
10864
 
--
10865
 
 
10866
 
CREATE FUNCTION _soitemafterdeletetrigger() RETURNS trigger
10867
 
    LANGUAGE plpgsql
10868
 
    AS $$
10869
 
DECLARE
10870
 
 
10871
 
BEGIN
10872
 
 
10873
 
  IF (OLD.coitem_status = 'O') THEN
10874
 
    IF ( (SELECT (count(*) < 1)
10875
 
            FROM coitem
10876
 
           WHERE ((coitem_cohead_id=OLD.coitem_cohead_id)
10877
 
             AND  (coitem_id != OLD.coitem_id)
10878
 
             AND  (coitem_status = 'O')) ) ) THEN
10879
 
      UPDATE cohead SET cohead_status = 'C'
10880
 
       WHERE ((cohead_id=OLD.coitem_cohead_id)
10881
 
         AND  (cohead_status='O'));
10882
 
    END IF;
10883
 
  END IF;
10884
 
 
10885
 
  RETURN OLD;
10886
 
END;
10887
 
$$;
10888
 
 
10889
 
 
10890
 
ALTER FUNCTION public._soitemafterdeletetrigger() OWNER TO admin;
10891
 
 
10892
 
--
10893
 
--
10894
 
 
10895
 
CREATE FUNCTION _soitemaftertrigger() RETURNS trigger
10896
 
    LANGUAGE plpgsql
10897
 
    AS $$
10898
 
DECLARE
10899
 
  _check NUMERIC;
10900
 
  _r RECORD;
10901
 
  _kit BOOLEAN;
10902
 
  _fractional BOOLEAN;
10903
 
  _rec RECORD;
10904
 
  _kstat TEXT;
10905
 
  _pstat TEXT;
10906
 
  _result INTEGER;
10907
 
  _coitemid INTEGER;
10908
 
  _itemsrcid INTEGER;
10909
 
  _orderid INTEGER;
10910
 
 
10911
 
BEGIN
10912
 
 
10913
 
  _rec := NEW;
10914
 
 
10915
 
  --Cache some information
10916
 
  SELECT * INTO _r
10917
 
  FROM cohead
10918
 
  WHERE (cohead_id=_rec.coitem_cohead_id);
10919
 
 
10920
 
  --Determine if this is a kit for later processing
10921
 
  SELECT COALESCE(item_type,'')='K', item_fractional
10922
 
    INTO _kit, _fractional
10923
 
    FROM itemsite, item
10924
 
   WHERE((itemsite_item_id=item_id)
10925
 
     AND (itemsite_id=_rec.coitem_itemsite_id));
10926
 
  _kit := COALESCE(_kit, false);
10927
 
  _fractional := COALESCE(_fractional, false);
10928
 
 
10929
 
  IF (_kit) THEN
10930
 
  -- Kit Processing
10931
 
    IF (TG_OP = 'INSERT') THEN
10932
 
  -- Create Sub Lines for Kit Components
10933
 
      PERFORM explodeKit(NEW.coitem_cohead_id, NEW.coitem_linenumber, 0, NEW.coitem_itemsite_id,
10934
 
                         NEW.coitem_qtyord, NEW.coitem_scheddate, NEW.coitem_promdate, NEW.coitem_memo);
10935
 
      IF (fetchMetricBool('KitComponentInheritCOS')) THEN
10936
 
  -- Update kit line item COS
10937
 
        UPDATE coitem
10938
 
        SET coitem_cos_accnt_id = CASE WHEN (COALESCE(NEW.coitem_cos_accnt_id, -1) != -1)
10939
 
                                         THEN NEW.coitem_cos_accnt_id
10940
 
                                       WHEN (NEW.coitem_warranty)
10941
 
                                         THEN resolveCOWAccount(NEW.coitem_itemsite_id, _r.cohead_cust_id, _r.cohead_saletype_id, _r.cohead_shipzone_id)
10942
 
                                       ELSE resolveCOSAccount(NEW.coitem_itemsite_id, _r.cohead_cust_id, _r.cohead_saletype_id, _r.cohead_shipzone_id)
10943
 
                                  END
10944
 
        WHERE((coitem_cohead_id=NEW.coitem_cohead_id)
10945
 
          AND (coitem_linenumber = NEW.coitem_linenumber)
10946
 
          AND (coitem_subnumber > 0));
10947
 
      END IF;
10948
 
    END IF;
10949
 
    IF (TG_OP = 'UPDATE') THEN
10950
 
      IF (NEW.coitem_qtyord <> OLD.coitem_qtyord) THEN
10951
 
  -- Recreate Sub Lines for Kit Components
10952
 
      FOR _coitemid IN
10953
 
        SELECT coitem_id
10954
 
        FROM coitem
10955
 
        WHERE ( (coitem_cohead_id=OLD.coitem_cohead_id)
10956
 
          AND   (coitem_linenumber=OLD.coitem_linenumber)
10957
 
          AND   (coitem_subnumber > 0) )
10958
 
        LOOP
10959
 
          SELECT deleteSoItem(_coitemid) INTO _result;
10960
 
          IF (_result < 0) THEN
10961
 
             RAISE EXCEPTION 'Error deleting kit components: deleteSoItem(integer) Error:%', _result;
10962
 
          END IF;
10963
 
        END LOOP;
10964
 
 
10965
 
        PERFORM explodeKit(NEW.coitem_cohead_id, NEW.coitem_linenumber, 0, NEW.coitem_itemsite_id,
10966
 
                           NEW.coitem_qtyord, NEW.coitem_scheddate, NEW.coitem_promdate);
10967
 
      END IF;
10968
 
      IF ( (NEW.coitem_qtyord <> OLD.coitem_qtyord) OR
10969
 
           (NEW.coitem_cos_accnt_id <> OLD.coitem_cos_accnt_id) ) THEN
10970
 
        IF (fetchMetricBool('KitComponentInheritCOS')) THEN
10971
 
  -- Update kit line item COS
10972
 
          UPDATE coitem
10973
 
          SET coitem_cos_accnt_id = CASE WHEN (COALESCE(NEW.coitem_cos_accnt_id, -1) != -1)
10974
 
                                           THEN NEW.coitem_cos_accnt_id
10975
 
                                         WHEN (NEW.coitem_warranty)
10976
 
                                           THEN resolveCOWAccount(NEW.coitem_itemsite_id, _r.cohead_cust_id, _r.cohead_saletype_id, _r.cohead_shipzone_id)
10977
 
                                         ELSE resolveCOSAccount(NEW.coitem_itemsite_id, _r.cohead_cust_id, _r.cohead_saletype_id, _r.cohead_shipzone_id)
10978
 
                                    END
10979
 
          WHERE((coitem_cohead_id=NEW.coitem_cohead_id)
10980
 
            AND (coitem_linenumber = NEW.coitem_linenumber)
10981
 
            AND (coitem_subnumber > 0));
10982
 
        END IF;
10983
 
      END IF;
10984
 
      IF (NEW.coitem_scheddate <> OLD.coitem_scheddate) THEN
10985
 
  -- Update kit line item Schedule Date
10986
 
        UPDATE coitem
10987
 
        SET coitem_scheddate = NEW.coitem_scheddate
10988
 
        WHERE((coitem_cohead_id=NEW.coitem_cohead_id)
10989
 
          AND (coitem_linenumber = NEW.coitem_linenumber)
10990
 
          AND (coitem_subnumber > 0));
10991
 
      END IF;
10992
 
    END IF;
10993
 
  END IF;
10994
 
 
10995
 
  IF (TG_OP = 'INSERT') THEN
10996
 
    -- Create Purchase Request if flagged to do so
10997
 
    IF ((NEW.coitem_order_type='R') AND (NEW.coitem_order_id=-1)) THEN
10998
 
      SELECT createPR(CAST(cohead_number AS INTEGER), 'S', NEW.coitem_id) INTO _orderid
10999
 
      FROM cohead
11000
 
      WHERE (cohead_id=NEW.coitem_cohead_id);
11001
 
      IF (_orderid > 0) THEN
11002
 
        UPDATE coitem SET coitem_order_id=_orderid
11003
 
        WHERE (coitem_id=NEW.coitem_id);
11004
 
      ELSE
11005
 
        RAISE EXCEPTION 'CreatePR failed, result=%', _orderid;
11006
 
      END IF;
11007
 
    END IF;
11008
 
 
11009
 
    -- Create Purchase Order if flagged to do so
11010
 
    IF ((NEW.coitem_order_type='P') AND (NEW.coitem_order_id=-1)) THEN
11011
 
      SELECT itemsrc_id INTO _itemsrcid
11012
 
      FROM itemsite JOIN itemsrc ON (itemsrc_item_id=itemsite_item_id AND itemsrc_default)
11013
 
      WHERE (itemsite_id=NEW.coitem_itemsite_id)
11014
 
        AND (NOT itemsite_stocked);
11015
 
      IF (FOUND) THEN
11016
 
        SELECT createPurchaseToSale(NEW.coitem_id,
11017
 
                                    _itemsrcid,
11018
 
                                    itemsite_dropship,
11019
 
                                    CASE WHEN (NEW.coitem_prcost=0.0) THEN NULL
11020
 
                                         ELSE NEW.coitem_prcost
11021
 
                                    END) INTO _orderid
11022
 
        FROM itemsite
11023
 
        WHERE (itemsite_id=NEW.coitem_itemsite_id);
11024
 
        IF (_orderid > 0) THEN
11025
 
          UPDATE coitem SET coitem_order_id=_orderid
11026
 
          WHERE (coitem_id=NEW.coitem_id);
11027
 
        ELSE
11028
 
          RAISE EXCEPTION 'CreatePurchaseToSale failed, result=%', _orderid;
11029
 
        END IF;
11030
 
      END IF;
11031
 
    END IF;
11032
 
 
11033
 
    -- Update Purchase Order comments
11034
 
    IF (NEW.coitem_order_type='P') THEN
11035
 
      UPDATE poitem SET poitem_comments=NEW.coitem_memo
11036
 
      WHERE ((poitem_order_id=NEW.coitem_id) AND (poitem_order_type='S'));
11037
 
    END IF;
11038
 
  END IF;
11039
 
 
11040
 
  IF (TG_OP = 'UPDATE') THEN
11041
 
    IF (NEW.coitem_order_type = 'P') THEN
11042
 
      --If soitem is cancelled
11043
 
      IF ((NEW.coitem_status = 'X') AND (OLD.coitem_status <> 'X')) THEN
11044
 
        PERFORM postEvent('PoItemSoCancelled', 'P', poitem_id,
11045
 
                          itemsite_warehous_id,
11046
 
                          (pohead_number || '-' || poitem_linenumber || ':' || item_number),
11047
 
                          NULL, NULL, NULL, NULL)
11048
 
        FROM poitem JOIN itemsite ON (itemsite_id=poitem_itemsite_id)
11049
 
                    JOIN item ON (item_id=itemsite_item_id)
11050
 
                    JOIN pohead ON (pohead_id=poitem_pohead_id)
11051
 
        WHERE ( (poitem_id=OLD.coitem_order_id)
11052
 
          AND   (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)) );
11053
 
      --If soitem notes changed
11054
 
      ELSIF (NEW.coitem_memo <> OLD.coitem_memo) THEN 
11055
 
        UPDATE poitem SET poitem_comments=NEW.coitem_memo
11056
 
        WHERE ((poitem_order_id=NEW.coitem_id) AND (poitem_order_type='S'));
11057
 
      END IF;
11058
 
    END IF;
11059
 
  END IF;
11060
 
 
11061
 
  IF (_rec.coitem_subnumber > 0) THEN
11062
 
    SELECT coitem_status
11063
 
      INTO _kstat
11064
 
      FROM coitem
11065
 
     WHERE((coitem_cohead_id=_rec.coitem_cohead_id)
11066
 
       AND (coitem_linenumber=_rec.coitem_linenumber)
11067
 
       AND (coitem_subnumber = 0));
11068
 
    IF ((SELECT count(*)
11069
 
           FROM coitem
11070
 
          WHERE((coitem_cohead_id=_rec.coitem_cohead_id)
11071
 
            AND (coitem_linenumber=_rec.coitem_linenumber)
11072
 
            AND (coitem_subnumber <> _rec.coitem_subnumber)
11073
 
            AND (coitem_subnumber > 0)
11074
 
            AND (coitem_status = 'O'))) > 0) THEN
11075
 
      _pstat := 'O';
11076
 
    ELSE
11077
 
      _pstat := _rec.coitem_status;
11078
 
    END IF;
11079
 
  END IF;
11080
 
 
11081
 
  IF(TG_OP = 'INSERT') THEN
11082
 
    IF (_rec.coitem_subnumber > 0 AND _rec.coitem_status = 'O') THEN
11083
 
      _pstat := 'O';
11084
 
    END IF;
11085
 
  ELSIF (TG_OP = 'UPDATE') THEN
11086
 
    IF (_rec.coitem_subnumber > 0 AND _rec.coitem_status = 'O') THEN
11087
 
      _pstat := 'O';
11088
 
    END IF;
11089
 
 
11090
 
    IF ((NEW.coitem_status = 'C') AND (OLD.coitem_status <> 'C')) THEN
11091
 
      IF(_kit) THEN
11092
 
        UPDATE coitem
11093
 
           SET coitem_status='C'
11094
 
         WHERE((coitem_cohead_id=OLD.coitem_cohead_id)
11095
 
           AND (coitem_linenumber=OLD.coitem_linenumber)
11096
 
           AND (coitem_status='O')
11097
 
           AND (coitem_subnumber > 0));
11098
 
      END IF;
11099
 
    END IF;
11100
 
 
11101
 
    IF ((NEW.coitem_status = 'X') AND (OLD.coitem_status <> 'X')) THEN
11102
 
      IF(_kit) THEN
11103
 
        UPDATE coitem
11104
 
           SET coitem_status='X'
11105
 
         WHERE((coitem_cohead_id=OLD.coitem_cohead_id)
11106
 
           AND (coitem_linenumber=OLD.coitem_linenumber)
11107
 
           AND (coitem_status='O')
11108
 
           AND (coitem_subnumber > 0));
11109
 
      END IF;
11110
 
    END IF;
11111
 
 
11112
 
    IF(NEW.coitem_status = 'O' AND OLD.coitem_status <> 'O') THEN
11113
 
      IF(_kit) THEN
11114
 
        UPDATE coitem
11115
 
           SET coitem_status='O'
11116
 
         WHERE((coitem_cohead_id=OLD.coitem_cohead_id)
11117
 
           AND (coitem_linenumber=OLD.coitem_linenumber)
11118
 
           AND ((coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) > 0)
11119
 
           AND (coitem_subnumber > 0));
11120
 
      END IF;
11121
 
    END IF;
11122
 
 
11123
 
  END IF;
11124
 
 
11125
 
  IF ((_kstat IS NOT NULL) AND (_pstat IS NOT NULL) AND (_rec.coitem_subnumber > 0) AND (_kstat <> _pstat)) THEN
11126
 
    UPDATE coitem
11127
 
       SET coitem_status = _pstat
11128
 
     WHERE((coitem_cohead_id=_rec.coitem_cohead_id)
11129
 
       AND (coitem_linenumber=_rec.coitem_linenumber)
11130
 
       AND (coitem_subnumber = 0));
11131
 
  END IF;
11132
 
 
11133
 
  --If auto calculate freight, recalculate cohead_freight
11134
 
  IF (SELECT cohead_calcfreight FROM cohead WHERE (cohead_id=NEW.coitem_cohead_id)) THEN
11135
 
    UPDATE cohead SET cohead_freight = COALESCE(
11136
 
      (SELECT SUM(freightdata_total) FROM freightDetail('SO',
11137
 
                                                        cohead_id,
11138
 
                                                        cohead_cust_id,
11139
 
                                                        cohead_shipto_id,
11140
 
                                                        cohead_orderdate,
11141
 
                                                        cohead_shipvia,
11142
 
                                                        cohead_curr_id)), 0)
11143
 
    WHERE cohead_id=NEW.coitem_cohead_id;
11144
 
  END IF;
11145
 
 
11146
 
  RETURN NEW;
11147
 
END;
11148
 
$$;
11149
 
 
11150
 
 
11151
 
ALTER FUNCTION public._soitemaftertrigger() OWNER TO admin;
11152
 
 
11153
 
--
11154
 
--
11155
 
 
11156
 
CREATE FUNCTION _soitembeforedeletetrigger() RETURNS trigger
11157
 
    LANGUAGE plpgsql
11158
 
    AS $$
11159
 
DECLARE
11160
 
 
11161
 
  _r              RECORD;
11162
 
  _kit            BOOLEAN := FALSE;
11163
 
  _shipped        BOOLEAN := FALSE;
11164
 
  _coitemid       INTEGER := 0;
11165
 
  _result         INTEGER := 0;
11166
 
 
11167
 
BEGIN
11168
 
 
11169
 
  -- Check Priv
11170
 
  IF NOT (checkPrivilege('MaintainSalesOrders')) THEN
11171
 
    RAISE EXCEPTION 'You do not have privileges to alter a Sales Order.';
11172
 
  END IF;
11173
 
 
11174
 
  -- Cache some information
11175
 
  SELECT * INTO _r
11176
 
    FROM cohead, itemsite, item
11177
 
   WHERE ( (cohead_id=OLD.coitem_cohead_id)
11178
 
     AND   (itemsite_id=OLD.coitem_itemsite_id)
11179
 
     AND   (item_id=itemsite_item_id) );
11180
 
 
11181
 
  _kit := (COALESCE(_r.item_type,'')='K');
11182
 
 
11183
 
  -- Check for shipped kit components
11184
 
  IF(_kit AND OLD.coitem_status <> 'C' AND OLD.coitem_status <> 'X') THEN
11185
 
    IF (EXISTS (SELECT coitem_id
11186
 
                  FROM coitem JOIN shipitem ON (shipitem_orderitem_id=coitem_id)
11187
 
                              JOIN shiphead ON (shiphead_id=shipitem_shiphead_id AND shiphead_order_type='SO')
11188
 
                 WHERE ((coitem_cohead_id=OLD.coitem_cohead_id)
11189
 
                   AND  (coitem_linenumber=OLD.coitem_linenumber)
11190
 
                   AND (coitem_subnumber > 0))
11191
 
              GROUP BY coitem_id
11192
 
                HAVING (SUM(shipitem_qty) > 0)
11193
 
                 LIMIT 1) ) THEN
11194
 
      _shipped := TRUE;
11195
 
    END IF;
11196
 
  END IF;
11197
 
 
11198
 
  IF(_kit AND _shipped) THEN
11199
 
    RAISE EXCEPTION 'You can not delete this Sales Order Line as it has several sub components that have already been shipped.';
11200
 
  END IF;
11201
 
 
11202
 
  DELETE FROM comment
11203
 
   WHERE ( (comment_source='SI')
11204
 
     AND   (comment_source_id=OLD.coitem_id) );
11205
 
 
11206
 
  DELETE FROM charass
11207
 
   WHERE ((charass_target_type='SI')
11208
 
     AND  (charass_target_id=OLD.coitem_id));
11209
 
 
11210
 
  -- Delete Sub Lines for Kit Components
11211
 
  IF (OLD.coitem_subnumber = 0) THEN
11212
 
    FOR _coitemid IN
11213
 
      SELECT coitem_id
11214
 
        FROM coitem
11215
 
       WHERE ( (coitem_cohead_id=OLD.coitem_cohead_id)
11216
 
         AND   (coitem_linenumber=OLD.coitem_linenumber)
11217
 
         AND   (coitem_subnumber > 0) )
11218
 
      LOOP
11219
 
      SELECT deleteSoItem(_coitemid) INTO _result;
11220
 
      IF (_result < 0) THEN
11221
 
        IF NOT (_r.itemsite_createsopo AND (_result = -10 OR _result = -20)) THEN
11222
 
          RAISE EXCEPTION 'Error deleting kit components: deleteSoItem(integer) Error:%', _result;
11223
 
        END IF;
11224
 
      END IF;
11225
 
    END LOOP;
11226
 
  END IF;
11227
 
 
11228
 
  IF (OLD.coitem_scheddate <= (CURRENT_DATE + _r.itemsite_eventfence)) THEN
11229
 
    PERFORM postEvent('SoitemCancelled', 'S', OLD.coitem_id,
11230
 
                      _r.itemsite_warehous_id, (_r.cohead_number || '-' || OLD.coitem_linenumber),
11231
 
                      NULL, NULL, NULL, NULL);
11232
 
  END IF;
11233
 
 
11234
 
  RETURN OLD;
11235
 
END;
11236
 
$$;
11237
 
 
11238
 
 
11239
 
ALTER FUNCTION public._soitembeforedeletetrigger() OWNER TO admin;
11240
 
 
11241
 
--
11242
 
--
11243
 
 
11244
 
CREATE FUNCTION _soitembeforetrigger() RETURNS trigger
11245
 
    LANGUAGE plpgsql
11246
 
    AS $$
11247
 
DECLARE
11248
 
  _check NUMERIC;
11249
 
  _itemNumber TEXT;
11250
 
  _r RECORD;
11251
 
  _kit BOOLEAN;
11252
 
 
11253
 
BEGIN
11254
 
 
11255
 
  --Determine if this is a kit for later processing
11256
 
  SELECT COALESCE(item_type,'')='K'
11257
 
  INTO _kit
11258
 
  FROM itemsite, item
11259
 
  WHERE((itemsite_item_id=item_id)
11260
 
  AND (itemsite_id=NEW.coitem_itemsite_id));
11261
 
  _kit := COALESCE(_kit, false);
11262
 
  
11263
 
  IF (TG_OP = 'INSERT') THEN
11264
 
 
11265
 
    -- If this is imported, go ahead and insert default characteristics
11266
 
    IF (NEW.coitem_imported) THEN
11267
 
      INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_price)
11268
 
      SELECT 'SI', NEW.coitem_id, char_id, charass_value,
11269
 
             itemcharprice(item_id,char_id,charass_value,cohead_cust_id,cohead_shipto_id,NEW.coitem_qtyord,cohead_curr_id,cohead_orderdate) 
11270
 
        FROM (
11271
 
           SELECT DISTINCT char_id, char_name, charass_value, item_id, cohead_cust_id, cohead_shipto_id, cohead_curr_id, cohead_orderdate
11272
 
             FROM cohead, charass, char, itemsite, item
11273
 
            WHERE((itemsite_id=NEW.coitem_itemsite_id)
11274
 
              AND (itemsite_item_id=item_id)
11275
 
              AND (charass_target_type='I') 
11276
 
              AND (charass_target_id=item_id)
11277
 
              AND (charass_default)
11278
 
              AND (char_id=charass_char_id)
11279
 
              AND (cohead_id=NEW.coitem_cohead_id))
11280
 
           ORDER BY char_name) AS data;
11281
 
    END IF;
11282
 
  END IF;
11283
 
 
11284
 
  -- Create work order and process if flagged to do so
11285
 
  IF ((NEW.coitem_order_type='W') AND (NEW.coitem_order_id=-1)) THEN
11286
 
    SELECT createwo(CAST(cohead_number AS INTEGER),
11287
 
                    NEW.coitem_itemsite_id,
11288
 
                    1, -- priority
11289
 
                    validateOrderQty(NEW.coitem_itemsite_id, NEW.coitem_qtyord, TRUE),
11290
 
                    itemsite_leadtime,
11291
 
                    NEW.coitem_scheddate,
11292
 
                    NEW.coitem_memo,
11293
 
                    'S',
11294
 
                    NEW.coitem_id,
11295
 
                    cohead_prj_id) INTO NEW.coitem_order_id
11296
 
    FROM cohead, itemsite 
11297
 
    WHERE ((cohead_id=NEW.coitem_cohead_id)
11298
 
    AND (itemsite_id=NEW.coitem_itemsite_id));
11299
 
 
11300
 
    INSERT INTO charass
11301
 
      (charass_target_type, charass_target_id,
11302
 
       charass_char_id, charass_value) 
11303
 
       SELECT 'W', NEW.coitem_order_id, charass_char_id, charass_value
11304
 
       FROM charass
11305
 
       WHERE ((charass_target_type='SI')
11306
 
       AND  (charass_target_id=NEW.coitem_id));
11307
 
  END IF;
11308
 
   
11309
 
  IF (TG_OP = 'UPDATE') THEN
11310
 
 
11311
 
    IF (NEW.coitem_scheddate <> OLD.coitem_scheddate AND NEW.coitem_order_type='R' AND NEW.coitem_order_id > 1) THEN
11312
 
      UPDATE pr SET pr_duedate = NEW.coitem_scheddate WHERE (pr_order_id=NEW.coitem_id AND pr_order_type='S');
11313
 
    END IF;
11314
 
    
11315
 
    IF ((NEW.coitem_status = 'C' AND OLD.coitem_status <> 'C')
11316
 
     OR (NEW.coitem_status = 'X' AND OLD.coitem_status <> 'X'))
11317
 
     AND (OLD.coitem_order_id > -1) THEN
11318
 
 
11319
 
      SELECT wo_id, wo_wipvalue INTO _r
11320
 
       FROM wo,itemsite,item
11321
 
      WHERE ((wo_ordtype='S')
11322
 
      AND (wo_ordid=OLD.coitem_id)
11323
 
      AND (itemsite_id=wo_itemsite_id)
11324
 
      AND (item_id=itemsite_item_id)
11325
 
      AND (itemsite_costmethod = 'J'));
11326
 
 
11327
 
      IF (FOUND) THEN
11328
 
        IF (_r.wo_wipvalue > 0) THEN
11329
 
        --  Distribute to G/L, debit Cost of Sales, credit WIP
11330
 
          PERFORM MIN(insertGLTransaction( 'W/O', 'WO', formatWoNumber(NEW.coitem_order_id), 'Job Closed Incomplete',
11331
 
                                           costcat_wip_accnt_id,
11332
 
                                           CASE WHEN (COALESCE(NEW.coitem_cos_accnt_id, -1) != -1)
11333
 
                                                  THEN NEW.coitem_cos_accnt_id
11334
 
                                                WHEN (NEW.coitem_warranty=TRUE)
11335
 
                                                  THEN resolveCOWAccount(itemsite_id, cohead_cust_id, cohead_saletype_id, cohead_shipzone_id)
11336
 
                                                ELSE resolveCOSAccount(itemsite_id, cohead_cust_id, cohead_saletype_id, cohead_shipzone_id)
11337
 
                                           END,
11338
 
                                           -1,  _r.wo_wipvalue, current_date ))
11339
 
          FROM itemsite, costcat, cohead
11340
 
          WHERE ((itemsite_id=NEW.coitem_itemsite_id)
11341
 
           AND (itemsite_costcat_id=costcat_id)
11342
 
           AND (cohead_id=NEW.coitem_cohead_id));
11343
 
        END IF;
11344
 
 
11345
 
        UPDATE wo SET
11346
 
          wo_status = 'C',
11347
 
          wo_wipvalue = 0
11348
 
        WHERE (wo_id = _r.wo_id);
11349
 
 
11350
 
      END IF;
11351
 
    END IF;
11352
 
 
11353
 
    IF ((NEW.coitem_status != 'C' AND OLD.coitem_status = 'C')
11354
 
     OR (NEW.coitem_status != 'X' AND OLD.coitem_status = 'X'))
11355
 
     AND (OLD.coitem_order_id > -1) THEN
11356
 
        UPDATE wo SET
11357
 
          wo_status = 'I'
11358
 
        FROM itemsite, item
11359
 
        WHERE ((wo_ordtype = 'S')
11360
 
         AND (wo_ordid=NEW.coitem_id)
11361
 
         AND (wo_itemsite_id=itemsite_id)
11362
 
         AND (itemsite_item_id=item_id)
11363
 
         AND (itemsite_costmethod='J'));
11364
 
    END IF;
11365
 
 
11366
 
    IF (fetchMetricBool('EnableReturnAuth')) THEN 
11367
 
      SELECT * INTO _r 
11368
 
      FROM raitem,rahead 
11369
 
      WHERE ((raitem_new_coitem_id=NEW.coitem_id)
11370
 
      AND (rahead_id=raitem_rahead_id));
11371
 
      IF (FOUND) THEN
11372
 
        IF ((_r.raitem_qtyauthorized <> NEW.coitem_qtyord OR
11373
 
            _r.raitem_qty_uom_id <> NEW.coitem_qty_uom_id OR
11374
 
            _r.raitem_qty_invuomratio <> NEW.coitem_qty_invuomratio OR
11375
 
            _r.raitem_price_uom_id <> NEW.coitem_price_uom_id OR
11376
 
            _r.raitem_price_invuomratio <> NEW.coitem_price_invuomratio)
11377
 
            AND NOT (NEW.coitem_status = 'X' AND _r.raitem_qtyauthorized = 0)) THEN
11378
 
          RAISE EXCEPTION 'Quantities for line item % may only be changed on the Return Authorization that created it.',NEW.coitem_linenumber;
11379
 
        END IF;
11380
 
        IF (OLD.coitem_warranty <> NEW.coitem_warranty) THEN
11381
 
          UPDATE raitem SET raitem_warranty = NEW.coitem_warranty
11382
 
           WHERE((raitem_new_coitem_id=NEW.coitem_id)
11383
 
             AND (raitem_warranty != NEW.coitem_warranty));
11384
 
        END IF;
11385
 
        IF (OLD.coitem_cos_accnt_id <> NEW.coitem_cos_accnt_id) THEN
11386
 
          UPDATE raitem SET raitem_cos_accnt_id = NEW.coitem_cos_accnt_id
11387
 
           WHERE((raitem_new_coitem_id=NEW.coitem_id)
11388
 
             AND (COALESCE(raitem_cos_accnt_id,-1) != COALESCE(NEW.coitem_cos_accnt_id,-1)));
11389
 
        END IF;
11390
 
        IF (OLD.coitem_taxtype_id <> NEW.coitem_taxtype_id) THEN
11391
 
          UPDATE raitem SET raitem_taxtype_id = NEW.coitem_taxtype_id
11392
 
           WHERE((raitem_new_coitem_id=NEW.coitem_id)
11393
 
             AND (COALESCE(raitem_taxtype_id,-1) != COALESCE(NEW.coitem_taxtype_id,-1)));
11394
 
        END IF;
11395
 
        IF (OLD.coitem_scheddate <> NEW.coitem_scheddate) THEN
11396
 
          UPDATE raitem SET raitem_scheddate = NEW.coitem_scheddate
11397
 
           WHERE((raitem_new_coitem_id=NEW.coitem_id)
11398
 
             AND (raitem_scheddate != NEW.coitem_scheddate));
11399
 
        END IF;
11400
 
        IF (OLD.coitem_memo <> NEW.coitem_memo) THEN
11401
 
          UPDATE raitem SET raitem_notes = NEW.coitem_memo
11402
 
           WHERE((raitem_new_coitem_id=NEW.coitem_id)
11403
 
             AND (raitem_notes != NEW.coitem_memo));
11404
 
        END IF;
11405
 
        IF ((OLD.coitem_qtyshipped <> NEW.coitem_qtyshipped) AND 
11406
 
           (NEW.coitem_qtyshipped >= _r.raitem_qtyauthorized) AND
11407
 
           ((_r.raitem_disposition = 'S') OR
11408
 
           (_r.raitem_status = 'O') AND
11409
 
           (_r.raitem_disposition IN ('P','V')) AND
11410
 
           (_r.raitem_qtyreceived >= _r.raitem_qtyauthorized))) THEN
11411
 
          UPDATE raitem SET raitem_status = 'C' 
11412
 
          WHERE (raitem_new_coitem_id=NEW.coitem_id);
11413
 
        END IF;
11414
 
      END IF;
11415
 
    END IF; 
11416
 
  END IF; 
11417
 
 
11418
 
  RETURN NEW;
11419
 
END;
11420
 
$$;
11421
 
 
11422
 
 
11423
 
ALTER FUNCTION public._soitembeforetrigger() OWNER TO admin;
11424
 
 
11425
 
--
11426
 
--
11427
 
 
11428
 
CREATE FUNCTION _soitemtrigger() RETURNS trigger
11429
 
    LANGUAGE plpgsql
11430
 
    AS $$
11431
 
DECLARE
11432
 
  _changelog BOOLEAN := FALSE;
11433
 
  _check BOOLEAN;
11434
 
  _kit BOOLEAN;
11435
 
  _shipped BOOLEAN;
11436
 
  _atShipping NUMERIC;
11437
 
  _tmp INTEGER;
11438
 
  _rec RECORD;
11439
 
BEGIN
11440
 
  -- Check
11441
 
  SELECT checkPrivilege('MaintainSalesOrders') OR checkPrivilege('ShipOrders') OR checkPrivilege('IssueStockToShipping') INTO _check;
11442
 
  IF NOT (_check) THEN
11443
 
    RAISE EXCEPTION 'You do not have privileges to alter a Sales Order.';
11444
 
  END IF;
11445
 
 
11446
 
  IF ( SELECT fetchMetricBool('SalesOrderChangeLog') ) THEN
11447
 
    _changelog := TRUE;
11448
 
  END IF;
11449
 
 
11450
 
  IF (TG_OP IN ('INSERT','UPDATE')) THEN
11451
 
    IF (NEW.coitem_scheddate IS NULL) THEN
11452
 
      IF (fetchmetricbool('AllowASAPShipSchedules')) THEN
11453
 
        NEW.coitem_scheddate := current_date;
11454
 
      ELSE
11455
 
        RAISE EXCEPTION 'A schedule date is required.';
11456
 
      END IF;
11457
 
    END IF;
11458
 
  END IF;
11459
 
 
11460
 
  _rec := NEW;
11461
 
 
11462
 
  SELECT COALESCE(item_type,'')='K'
11463
 
    INTO _kit
11464
 
    FROM itemsite, item
11465
 
   WHERE((itemsite_item_id=item_id)
11466
 
     AND (itemsite_id=_rec.coitem_itemsite_id));
11467
 
  _kit := COALESCE(_kit, false);
11468
 
  _shipped := false;
11469
 
  IF(_kit AND _rec.coitem_status <> 'C' AND _rec.coitem_status <> 'X') THEN
11470
 
    SELECT coitem_id
11471
 
      INTO _tmp
11472
 
      FROM coitem JOIN shipitem ON (shipitem_orderitem_id=coitem_id)
11473
 
                  JOIN shiphead ON (shiphead_id=shipitem_shiphead_id AND shiphead_order_type='SO')
11474
 
     WHERE((coitem_cohead_id=_rec.coitem_cohead_id)
11475
 
       AND (coitem_linenumber=_rec.coitem_linenumber)
11476
 
       AND (coitem_subnumber > 0))
11477
 
     GROUP BY coitem_id
11478
 
    HAVING (SUM(shipitem_qty) > 0)
11479
 
     LIMIT 1;
11480
 
    IF (FOUND) THEN
11481
 
      _shipped := true;
11482
 
    END IF;
11483
 
  END IF;
11484
 
  
11485
 
  IF (TG_OP ='UPDATE') THEN
11486
 
    IF ((OLD.coitem_status <> 'C') AND (NEW.coitem_status = 'C')) THEN
11487
 
      SELECT qtyAtShipping(NEW.coitem_id) INTO _atShipping;
11488
 
      IF (_atShipping > 0) THEN
11489
 
        RAISE EXCEPTION 'Line % cannot be Closed at this time as there is inventory at shipping.',NEW.coitem_linenumber;
11490
 
      END IF;
11491
 
    END IF;
11492
 
  END IF;
11493
 
 
11494
 
  IF (TG_OP = 'INSERT') THEN
11495
 
    PERFORM postEvent('SoitemCreated', 'S', NEW.coitem_id,
11496
 
                      itemsite_warehous_id, (cohead_number || '-' || NEW.coitem_linenumber),
11497
 
                      NULL, NULL, NULL, NULL)
11498
 
    FROM cohead, itemsite
11499
 
    WHERE ( (cohead_id=NEW.coitem_cohead_id)
11500
 
      AND   (itemsite_id=NEW.coitem_itemsite_id)
11501
 
      AND   (NEW.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) );
11502
 
 
11503
 
    IF (_changelog) THEN
11504
 
      PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Created');
11505
 
    END IF;
11506
 
 
11507
 
    --Set defaults if no values passed
11508
 
    NEW.coitem_linenumber       := COALESCE(NEW.coitem_linenumber,
11509
 
                                          (SELECT (COALESCE(MAX(coitem_linenumber), 0) + 1)
11510
 
                                           FROM coitem
11511
 
                                           WHERE (coitem_cohead_id=NEW.coitem_cohead_id)));
11512
 
    NEW.coitem_status           := COALESCE(NEW.coitem_status,'O');
11513
 
    NEW.coitem_scheddate        := COALESCE(NEW.coitem_scheddate,
11514
 
                                           (SELECT MIN(coitem_scheddate)
11515
 
                                            FROM coitem
11516
 
                                            WHERE (coitem_cohead_id=NEW.coitem_cohead_id)));
11517
 
    NEW.coitem_memo             := COALESCE(NEW.coitem_memo,'');
11518
 
    NEW.coitem_prcost           := COALESCE(NEW.coitem_prcost,0);
11519
 
    NEW.coitem_warranty := COALESCE(NEW.coitem_warranty,false);
11520
 
 
11521
 
    IF (NEW.coitem_status='O') THEN
11522
 
      UPDATE cohead SET cohead_status = 'O'
11523
 
       WHERE ((cohead_id=NEW.coitem_cohead_id)
11524
 
         AND  (cohead_status='C'));
11525
 
    END IF;
11526
 
 
11527
 
    RETURN NEW;
11528
 
 
11529
 
  ELSIF (TG_OP = 'UPDATE') THEN
11530
 
    IF (NEW.coitem_qtyord <> OLD.coitem_qtyord) THEN
11531
 
      IF(_kit) THEN
11532
 
        IF(_shipped) THEN
11533
 
          RAISE EXCEPTION 'You can not change the qty ordered for a Kit item when one or more of its components have shipped inventory.';
11534
 
        END IF;
11535
 
      END IF;
11536
 
      PERFORM postEvent('SoitemQtyChanged', 'S', NEW.coitem_id,
11537
 
                        itemsite_warehous_id, (cohead_number || '-' || NEW.coitem_linenumber),
11538
 
                        NEW.coitem_qtyord, OLD.coitem_qtyord, NULL, NULL)
11539
 
      FROM cohead, itemsite
11540
 
      WHERE ( (cohead_id=NEW.coitem_cohead_id)
11541
 
        AND   (itemsite_id=NEW.coitem_itemsite_id)
11542
 
        AND   ( (NEW.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence))
11543
 
         OR     (OLD.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) ) );
11544
 
 
11545
 
      IF (_changelog) THEN
11546
 
        PERFORM postComment( 'ChangeLog', 'SI', NEW.coitem_id,
11547
 
                             ( 'Changed Qty. Ordered from ' || formatQty(OLD.coitem_qtyord) ||
11548
 
                               ' to ' || formatQty(NEW.coitem_qtyord) ) );
11549
 
      END IF;
11550
 
 
11551
 
    END IF;
11552
 
 
11553
 
    IF (NEW.coitem_price <> OLD.coitem_price) THEN
11554
 
      IF (_changelog) THEN
11555
 
        PERFORM postComment( 'ChangeLog', 'SI', NEW.coitem_id,
11556
 
                             ( 'Changed Unit Price from ' || formatPrice(OLD.coitem_price) ||
11557
 
                               ' to ' || formatPrice(NEW.coitem_price) ) );
11558
 
      END IF;
11559
 
 
11560
 
    END IF;
11561
 
 
11562
 
    IF (NEW.coitem_scheddate <> OLD.coitem_scheddate) THEN
11563
 
      PERFORM postEvent('SoitemSchedDateChanged', 'S', NEW.coitem_id,
11564
 
                        itemsite_warehous_id, (cohead_number || '-' || NEW.coitem_linenumber),
11565
 
                        NULL, NULL, NEW.coitem_scheddate, OLD.coitem_scheddate)
11566
 
      FROM cohead, itemsite
11567
 
      WHERE ( (cohead_id=NEW.coitem_cohead_id)
11568
 
        AND   (itemsite_id=NEW.coitem_itemsite_id)
11569
 
        AND   ( (NEW.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence))
11570
 
         OR     (OLD.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) ) );
11571
 
 
11572
 
      IF (_changelog) THEN
11573
 
        PERFORM postComment( 'ChangeLog', 'SI', NEW.coitem_id,
11574
 
                             ( 'Changed Sched. Date from ' || formatDate(OLD.coitem_scheddate) ||
11575
 
                               ' to ' || formatDate(NEW.coitem_scheddate)) );
11576
 
      END IF;
11577
 
 
11578
 
    END IF;
11579
 
 
11580
 
    IF ((NEW.coitem_status = 'C') AND (OLD.coitem_status <> 'C')) THEN
11581
 
      NEW.coitem_closedate = CURRENT_TIMESTAMP;
11582
 
      NEW.coitem_close_username = getEffectiveXtUser();
11583
 
      NEW.coitem_qtyreserved := 0;
11584
 
 
11585
 
      IF (_changelog) THEN
11586
 
        PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Closed');
11587
 
      END IF;
11588
 
    END IF;
11589
 
 
11590
 
    IF ((NEW.coitem_status <> 'C') AND (OLD.coitem_status = 'C')) THEN
11591
 
      NEW.coitem_closedate = NULL;
11592
 
      NEW.coitem_close_username = NULL;
11593
 
 
11594
 
      IF (_changelog) THEN
11595
 
        PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Reopened');
11596
 
      END IF;
11597
 
    END IF;
11598
 
 
11599
 
    IF ((NEW.coitem_status = 'X') AND (OLD.coitem_status <> 'X')) THEN
11600
 
      IF ((OLD.coitem_order_type = 'W') AND
11601
 
          (SELECT wo_status IN ('O', 'E', 'R')
11602
 
            FROM wo
11603
 
            WHERE (wo_id=OLD.coitem_order_id))) THEN
11604
 
      -- Close any associated W/O
11605
 
        PERFORM closeWo(OLD.coitem_order_id, FALSE, CURRENT_DATE);
11606
 
      ELSIF (OLD.coitem_order_type = 'R') THEN 
11607
 
      -- Delete any associated P/R
11608
 
        PERFORM deletePr(OLD.coitem_order_id);
11609
 
      END IF;
11610
 
 
11611
 
      NEW.coitem_qtyreserved := 0;
11612
 
 
11613
 
      IF (_changelog) THEN
11614
 
        PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Canceled');
11615
 
        PERFORM postComment('ChangeLog', 'S', NEW.coitem_cohead_id, 'Line # '|| NEW.coitem_linenumber ||' Canceled');
11616
 
      END IF;
11617
 
 
11618
 
      PERFORM postEvent('SoitemCancelled', 'S', OLD.coitem_id,
11619
 
                        itemsite_warehous_id, (cohead_number || '-' || OLD.coitem_linenumber),
11620
 
                        NULL, NULL, NULL, NULL)
11621
 
      FROM cohead, itemsite
11622
 
      WHERE ( (cohead_id=OLD.coitem_cohead_id)
11623
 
        AND   (itemsite_id=OLD.coitem_itemsite_id)
11624
 
        AND   (OLD.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) );
11625
 
 
11626
 
    END IF;
11627
 
 
11628
 
    IF ((NEW.coitem_qtyreserved <> OLD.coitem_qtyreserved) AND (_changelog)) THEN
11629
 
      PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Changed Qty Reserved to '|| NEW.coitem_qtyreserved);
11630
 
    END IF;
11631
 
 
11632
 
  END IF;
11633
 
 
11634
 
  NEW.coitem_lastupdated = CURRENT_TIMESTAMP;
11635
 
 
11636
 
  -- Handle status for header
11637
 
  IF (TG_OP = 'UPDATE') THEN
11638
 
    IF (OLD.coitem_status <> NEW.coitem_status) THEN
11639
 
      IF ( (SELECT (count(*) < 1)
11640
 
              FROM coitem
11641
 
             WHERE ((coitem_cohead_id=NEW.coitem_cohead_id)
11642
 
               AND  (coitem_id != NEW.coitem_id)
11643
 
               AND  (coitem_status='O')) ) AND (NEW.coitem_status<>'O') ) THEN
11644
 
        UPDATE cohead SET cohead_status = 'C'
11645
 
         WHERE ((cohead_id=NEW.coitem_cohead_id)
11646
 
           AND  (cohead_status='O'));
11647
 
      ELSE
11648
 
        UPDATE cohead SET cohead_status = 'O'
11649
 
         WHERE ((cohead_id=NEW.coitem_cohead_id)
11650
 
           AND  (cohead_status='C'));
11651
 
      END IF;
11652
 
    END IF;
11653
 
  END IF;
11654
 
 
11655
 
  RETURN NEW;
11656
 
 
11657
 
END;
11658
 
$$;
11659
 
 
11660
 
 
11661
 
ALTER FUNCTION public._soitemtrigger() OWNER TO admin;
11662
 
 
11663
 
--
11664
 
--
11665
 
 
11666
 
CREATE FUNCTION _taxauthafterdeletetrigger() RETURNS trigger
11667
 
    LANGUAGE plpgsql
11668
 
    AS $$
11669
 
BEGIN
11670
 
  IF (EXISTS(SELECT 1
11671
 
               FROM checkhead
11672
 
              WHERE checkhead_recip_id = OLD.taxauth_id
11673
 
                AND checkhead_recip_type='T')) THEN
11674
 
    RAISE EXCEPTION 'Cannot delete the tax authority % because checks have been written to it [xtuple: deleteTaxAuthority, -7, %]',
11675
 
                    OLD.taxauth_number, OLD.taxauth_number;
11676
 
  END IF;
11677
 
 
11678
 
  IF (fetchMetricValue('DefaultTaxAuthority') = OLD.taxauth_id) THEN
11679
 
    RAISE EXCEPTION 'Cannot delete the default Tax Authority [xtuple: deleteTaxAuthority, -8, %]',
11680
 
                    OLD.taxauth_code;
11681
 
  END IF;
11682
 
 
11683
 
  IF (fetchMetricBool('TaxAuthChangeLog')) THEN
11684
 
    PERFORM postComment(cmnttype_id, 'TAXAUTH', OLD.taxauth_id,
11685
 
                        'Deleted "' || OLD.taxauth_number || '"')
11686
 
      FROM cmnttype
11687
 
     WHERE (cmnttype_name='ChangeLog');
11688
 
  END IF;
11689
 
 
11690
 
  RETURN OLD;
11691
 
END;
11692
 
$$;
11693
 
 
11694
 
 
11695
 
ALTER FUNCTION public._taxauthafterdeletetrigger() OWNER TO admin;
11696
 
 
11697
 
--
11698
 
--
11699
 
 
11700
 
CREATE FUNCTION _taxauthaftertrigger() RETURNS trigger
11701
 
    LANGUAGE plpgsql
11702
 
    AS $$
11703
 
DECLARE
11704
 
  _cmnttypeid INTEGER;
11705
 
 
11706
 
BEGIN
11707
 
  IF (TG_OP = 'INSERT') THEN
11708
 
    -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE
11709
 
    LOOP
11710
 
      UPDATE crmacct SET crmacct_taxauth_id=NEW.taxauth_id,
11711
 
                         crmacct_name=NEW.taxauth_name
11712
 
       WHERE crmacct_number=NEW.taxauth_code;
11713
 
      IF (FOUND) THEN
11714
 
        EXIT;
11715
 
      END IF;
11716
 
      BEGIN
11717
 
        INSERT INTO crmacct(crmacct_number,   crmacct_name,     crmacct_active,
11718
 
                            crmacct_type,     crmacct_taxauth_id
11719
 
                  ) VALUES (NEW.taxauth_code, NEW.taxauth_name, TRUE, 
11720
 
                            'O',              NEW.taxauth_id);
11721
 
        EXIT;
11722
 
      EXCEPTION WHEN unique_violation THEN
11723
 
            -- do nothing, and loop to try the UPDATE again
11724
 
      END;
11725
 
    END LOOP;
11726
 
 
11727
 
    /* TODO: default characteristic assignments based on what? */
11728
 
 
11729
 
  ELSIF (TG_OP = 'UPDATE') THEN
11730
 
    UPDATE crmacct SET crmacct_number = NEW.taxauth_code
11731
 
    WHERE ((crmacct_taxauth_id=NEW.taxauth_id)
11732
 
      AND  (crmacct_number!=NEW.taxauth_code));
11733
 
 
11734
 
    UPDATE crmacct SET crmacct_name = NEW.taxauth_name
11735
 
    WHERE ((crmacct_taxauth_id=NEW.taxauth_id)
11736
 
      AND  (crmacct_name!=NEW.taxauth_name));
11737
 
 
11738
 
  END IF;
11739
 
 
11740
 
  IF (fetchMetricBool('TaxAuthChangeLog')) THEN
11741
 
    SELECT cmnttype_id INTO _cmnttypeid
11742
 
      FROM cmnttype
11743
 
     WHERE (cmnttype_name='ChangeLog');
11744
 
 
11745
 
    IF (_cmnttypeid IS NOT NULL) THEN
11746
 
      IF (TG_OP = 'INSERT') THEN
11747
 
        PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'Created');
11748
 
 
11749
 
      ELSIF (TG_OP = 'UPDATE') THEN
11750
 
        IF (OLD.taxauth_code <> NEW.taxauth_code) THEN
11751
 
          PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id,
11752
 
                              'Code changed from "' || OLD.taxauth_code ||
11753
 
                              '" to "' || NEW.taxauth_code || '"');
11754
 
        END IF;
11755
 
 
11756
 
        IF (OLD.taxauth_name <> NEW.taxauth_name) THEN
11757
 
          PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id,
11758
 
                              'Name changed from "' || OLD.taxauth_name ||
11759
 
                              '" to "' || NEW.taxauth_name || '"');
11760
 
        END IF;
11761
 
 
11762
 
        IF (OLD.taxauth_extref <> NEW.taxauth_extref) THEN
11763
 
          PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id,
11764
 
                              'External Ref. changed from "' || OLD.taxauth_extref ||
11765
 
                              '" to "' || NEW.taxauth_extref || '"');
11766
 
        END IF;
11767
 
 
11768
 
        IF (OLD.taxauth_addr_id <> NEW.taxauth_addr_id) THEN
11769
 
          PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id,
11770
 
                              'Address changed from ' || formatAddr(OLD.taxauth_addr_id)
11771
 
                              || ' to ' || formatAddr(NEW.taxauth_addr_id));
11772
 
        END IF;
11773
 
 
11774
 
        IF (OLD.taxauth_curr_id <> NEW.taxauth_curr_id) THEN
11775
 
          PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id,
11776
 
                              'Currency changed from "' ||
11777
 
                              currConcat(OLD.taxauth_curr_id) || '" to "' ||
11778
 
                              currConcat(NEW.taxauth_curr_id) || '"');
11779
 
        END IF;
11780
 
 
11781
 
        IF (OLD.taxauth_county <> NEW.taxauth_county) THEN
11782
 
          PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id,
11783
 
                              'County changed from "' || OLD.taxauth_county ||
11784
 
                              '" to "' || NEW.taxauth_county || '"');
11785
 
        END IF;
11786
 
 
11787
 
        IF (OLD.taxauth_accnt_id <> NEW.taxauth_accnt_id) THEN
11788
 
          PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id,
11789
 
                              'Account changed from "' ||
11790
 
                              formatGLAccount(OLD.taxauth_accnt_id) || '" to "' ||
11791
 
                              formatGLAccount(NEW.taxauth_accnt_id) || '"');
11792
 
        END IF;
11793
 
 
11794
 
      END IF;
11795
 
    END IF;
11796
 
  END IF;
11797
 
 
11798
 
  RETURN NEW;
11799
 
END;
11800
 
$$;
11801
 
 
11802
 
 
11803
 
ALTER FUNCTION public._taxauthaftertrigger() OWNER TO admin;
11804
 
 
11805
 
--
11806
 
--
11807
 
 
11808
 
CREATE FUNCTION _taxauthbeforedeletetrigger() RETURNS trigger
11809
 
    LANGUAGE plpgsql
11810
 
    AS $$
11811
 
BEGIN
11812
 
  IF (NOT checkPrivilege('MaintainTaxAuthorities')) THEN
11813
 
    RAISE EXCEPTION 'You do not have privileges to maintain Tax Authorities.';
11814
 
  END IF;
11815
 
 
11816
 
  UPDATE crmacct SET crmacct_taxauth_id = NULL
11817
 
   WHERE crmacct_taxauth_id = OLD.taxauth_id;
11818
 
 
11819
 
  RETURN OLD;
11820
 
END;
11821
 
$$;
11822
 
 
11823
 
 
11824
 
ALTER FUNCTION public._taxauthbeforedeletetrigger() OWNER TO admin;
11825
 
 
11826
 
--
11827
 
--
11828
 
 
11829
 
CREATE FUNCTION _taxauthbeforetrigger() RETURNS trigger
11830
 
    LANGUAGE plpgsql
11831
 
    AS $$
11832
 
BEGIN
11833
 
  IF (NOT checkPrivilege('MaintainTaxAuthorities')) THEN
11834
 
    RAISE EXCEPTION 'You do not have privileges to maintain Tax Authorities.';
11835
 
  END IF;
11836
 
 
11837
 
  IF (NEW.taxauth_code IS NULL) THEN
11838
 
    RAISE EXCEPTION 'You must supply a Tax Authority Code.';
11839
 
  END IF;
11840
 
 
11841
 
  IF (TG_OP = 'INSERT' AND
11842
 
      fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN
11843
 
    PERFORM clearNumberIssue('CRMAccountNumber', NEW.taxauth_code);
11844
 
  END IF;
11845
 
 
11846
 
  NEW.taxauth_code := UPPER(NEW.taxauth_code);
11847
 
 
11848
 
  RETURN NEW;
11849
 
END;
11850
 
$$;
11851
 
 
11852
 
 
11853
 
ALTER FUNCTION public._taxauthbeforetrigger() OWNER TO admin;
11854
 
 
11855
 
--
11856
 
--
11857
 
 
11858
 
CREATE FUNCTION _termsafterdeletetrigger() RETURNS trigger
11859
 
    LANGUAGE plpgsql
11860
 
    AS $$
11861
 
BEGIN
11862
 
  IF (fetchMetricValue('DefaultTerms') = OLD.terms_id) THEN
11863
 
    RAISE EXCEPTION 'Cannot delete the default Terms [xtuple: terms, -1, %]',
11864
 
                    OLD.terms_code;
11865
 
  END IF;
11866
 
 
11867
 
  RETURN OLD;
11868
 
END;
11869
 
$$;
11870
 
 
11871
 
 
11872
 
ALTER FUNCTION public._termsafterdeletetrigger() OWNER TO admin;
11873
 
 
11874
 
--
11875
 
--
11876
 
 
11877
 
CREATE FUNCTION _todoitemtrigger() RETURNS trigger
11878
 
    LANGUAGE plpgsql
11879
 
    AS $$
11880
 
DECLARE
11881
 
  _recurid     INTEGER;
11882
 
  _newparentid INTEGER;
11883
 
 
11884
 
BEGIN
11885
 
  IF (TG_OP = 'DELETE') THEN
11886
 
    SELECT recur_id INTO _recurid
11887
 
      FROM recur
11888
 
     WHERE ((recur_parent_id=OLD.todoitem_id)
11889
 
       AND  (recur_parent_type='TODO'));
11890
 
 
11891
 
    IF (_recurid IS NOT NULL) THEN
11892
 
      RAISE DEBUG 'recur_id for deleted todoitem = %', _recurid;
11893
 
 
11894
 
      SELECT todoitem_id INTO _newparentid
11895
 
        FROM todoitem
11896
 
       WHERE ((todoitem_recurring_todoitem_id=OLD.todoitem_id)
11897
 
          AND (todoitem_id!=OLD.todoitem_id))
11898
 
       ORDER BY todoitem_due_date
11899
 
       LIMIT 1;
11900
 
 
11901
 
      RAISE DEBUG '_newparentid for deleted todoitem = %', COALESCE(_newparentid, NULL);
11902
 
 
11903
 
      -- client is responsible for warning about deleting a recurring todoitem
11904
 
      IF (_newparentid IS NULL) THEN
11905
 
        DELETE FROM recur WHERE recur_id=_recurid;
11906
 
      ELSE
11907
 
        UPDATE recur SET recur_parent_id=_newparentid
11908
 
         WHERE recur_id=_recurid;
11909
 
 
11910
 
        UPDATE todoitem SET todoitem_recurring_todoitem_id=_newparentid
11911
 
         WHERE todoitem_recurring_todoitem_id=OLD.todoitem_id
11912
 
           AND todoitem_id != OLD.todoitem_id;
11913
 
 
11914
 
        RAISE DEBUG 'reparented recurrence';
11915
 
      END IF;
11916
 
    END IF;
11917
 
 
11918
 
    DELETE FROM alarm
11919
 
     WHERE ((alarm_source='TODO')
11920
 
        AND (alarm_source_id=OLD.todoitem_id));
11921
 
 
11922
 
    DELETE FROM docass WHERE docass_source_id = OLD.todoitem_id AND docass_source_type = 'TODO';
11923
 
    DELETE FROM docass WHERE docass_target_id = OLD.todoitem_id AND docass_target_type = 'TODO';
11924
 
 
11925
 
    RETURN OLD;
11926
 
  END IF;
11927
 
 
11928
 
  RETURN NEW;
11929
 
END;
11930
 
$$;
11931
 
 
11932
 
 
11933
 
ALTER FUNCTION public._todoitemtrigger() OWNER TO admin;
11934
 
 
11935
 
--
11936
 
--
11937
 
 
11938
 
CREATE FUNCTION _uomconvupdate() RETURNS trigger
11939
 
    LANGUAGE plpgsql
11940
 
    AS $$
11941
 
BEGIN
11942
 
 
11943
 
  UPDATE itemuomconv
11944
 
  SET itemuomconv_to_value = NEW.uomconv_to_value,
11945
 
  itemuomconv_from_value = NEW.uomconv_from_value,
11946
 
  itemuomconv_fractional = NEW.uomconv_fractional
11947
 
  WHERE((itemuomconv_from_uom_id = NEW.uomconv_from_uom_id)
11948
 
  AND (itemuomconv_to_uom_id = NEW.uomconv_to_uom_id));
11949
 
 
11950
 
RETURN NEW;
11951
 
 
11952
 
END; 
11953
 
$$;
11954
 
 
11955
 
 
11956
 
ALTER FUNCTION public._uomconvupdate() OWNER TO admin;
11957
 
 
11958
 
--
11959
 
--
11960
 
 
11961
 
CREATE FUNCTION _usrprefaftertrigger() RETURNS trigger
11962
 
    LANGUAGE plpgsql
11963
 
    AS $$
11964
 
BEGIN
11965
 
 
11966
 
  IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN
11967
 
    -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE
11968
 
    IF (NEW.usrpref_name='active') THEN
11969
 
      LOOP
11970
 
        UPDATE crmacct SET crmacct_usr_username=NEW.usrpref_username
11971
 
         WHERE crmacct_number=UPPER(NEW.usrpref_username);
11972
 
        IF (FOUND) THEN
11973
 
          EXIT;
11974
 
        END IF;
11975
 
        BEGIN
11976
 
          INSERT INTO crmacct(crmacct_number,        crmacct_active,
11977
 
                              crmacct_type,          crmacct_usr_username
11978
 
                    ) VALUES (NEW.usrpref_username,  NEW.usrpref_value::BOOL,
11979
 
                              'I',                   NEW.usrpref_username);
11980
 
          EXIT;
11981
 
        EXCEPTION WHEN unique_violation THEN
11982
 
            -- do nothing, and loop to try the UPDATE again
11983
 
        END;
11984
 
      END LOOP;
11985
 
 
11986
 
    ELSIF (NEW.usrpref_name='propername') THEN
11987
 
      LOOP
11988
 
        UPDATE crmacct SET crmacct_name=NEW.usrpref_value
11989
 
         WHERE crmacct_number=UPPER(NEW.usrpref_username);
11990
 
        IF (FOUND) THEN
11991
 
          EXIT;
11992
 
        END IF;
11993
 
        BEGIN
11994
 
          INSERT INTO crmacct(crmacct_number,        crmacct_active,
11995
 
                              crmacct_name,
11996
 
                              crmacct_type,          crmacct_usr_username
11997
 
                    ) VALUES (UPPER(NEW.usrpref_username), TRUE,
11998
 
                              NEW.usrpref_value,
11999
 
                              'I',                   NEW.usrpref_username);
12000
 
          EXIT;
12001
 
        EXCEPTION WHEN unique_violation THEN
12002
 
            -- do nothing, and loop to try the UPDATE again
12003
 
        END;
12004
 
      END LOOP;
12005
 
 
12006
 
    END IF;
12007
 
 
12008
 
  ELSIF (TG_OP = 'DELETE') THEN
12009
 
    RETURN OLD;
12010
 
  END IF;
12011
 
 
12012
 
  RETURN NEW;
12013
 
END;
12014
 
$$;
12015
 
 
12016
 
 
12017
 
ALTER FUNCTION public._usrprefaftertrigger() OWNER TO admin;
12018
 
 
12019
 
--
12020
 
--
12021
 
 
12022
 
CREATE FUNCTION _usrprefbeforetrigger() RETURNS trigger
12023
 
    LANGUAGE plpgsql
12024
 
    AS $$
12025
 
BEGIN
12026
 
  IF NOT (checkPrivilege('MaintainUsers') OR
12027
 
          checkPrivilege('MaintainPreferencesOthers') OR
12028
 
          (checkPrivilege('MaintainPreferencesSelf'))) THEN
12029
 
    -- 2 IFs because plpgsql doesn't always evaluate boolean exprs left-to-right
12030
 
    IF (TG_OP = 'DELETE') THEN
12031
 
      IF NOT (OLD.usrpref_name LIKE '%/checked' OR OLD.usrpref_name LIKE '%/columnsShown') THEN
12032
 
        RAISE EXCEPTION 'You do not have privileges to change this User Preference.';
12033
 
      END IF;
12034
 
    ELSIF (NEW.usrpref_username = getEffectiveXtUser()) THEN
12035
 
      IF NOT (NEW.usrpref_name LIKE '%/checked' OR NEW.usrpref_name LIKE '%/columnsShown') THEN
12036
 
        RAISE EXCEPTION 'You do not have privileges to change this User Preference.';
12037
 
      END IF;
12038
 
    END IF;
12039
 
  END IF;
12040
 
 
12041
 
  IF (TG_OP IN ('INSERT', 'UPDATE')) THEN
12042
 
    IF (NEW.usrpref_name = 'locale') THEN
12043
 
      IF NOT EXISTS(SELECT locale_id
12044
 
                      FROM locale
12045
 
                     WHERE locale_id = NEW.usrpref_value::INTEGER) THEN
12046
 
        RAISE EXCEPTION 'You must supply a valid Locale.';
12047
 
      END IF;
12048
 
 
12049
 
    ELSIF (NEW.usrpref_name IN ('agent', 'active')) THEN
12050
 
      IF (NEW.usrpref_value NOT IN ('t', 'f')) THEN
12051
 
        RAISE EXCEPTION '% must be either "t" or "f"', NEW.usrpref_name;
12052
 
      END IF;
12053
 
    END IF;
12054
 
 
12055
 
  ELSIF (TG_OP = 'DELETE') THEN
12056
 
    RETURN OLD;
12057
 
  END IF;
12058
 
 
12059
 
  RETURN NEW;
12060
 
END;
12061
 
$$;
12062
 
 
12063
 
 
12064
 
ALTER FUNCTION public._usrprefbeforetrigger() OWNER TO admin;
12065
 
 
12066
 
--
12067
 
--
12068
 
 
12069
 
CREATE FUNCTION _usrprivtrigger() RETURNS trigger
12070
 
    LANGUAGE plpgsql
12071
 
    AS $$
12072
 
DECLARE
12073
 
  _check BOOLEAN;
12074
 
  _returnVal INTEGER;
12075
 
BEGIN
12076
 
  -- This looks like a candidate for a foreign key but isn't.
12077
 
  -- fkeys don't work if the foreign key value resides in a child of the 
12078
 
  -- table and not the table itself.
12079
 
  IF (NOT EXISTS(SELECT usrpriv_id 
12080
 
                 FROM usrpriv, priv  
12081
 
                 WHERE ((usrpriv_priv_id=priv_id) AND (priv_name ='MaintainUsers')
12082
 
                        AND (usrpriv_username=geteffectivextuser())))) THEN
12083
 
    RAISE EXCEPTION 'User have no privileges to modify user privileges.';
12084
 
  END IF;                
12085
 
 
12086
 
  IF ((TG_OP = 'UPDATE' OR TG_OP = 'INSERT') AND
12087
 
      (NOT EXISTS(SELECT priv_id
12088
 
                  FROM priv
12089
 
                  WHERE (priv_id=NEW.usrpriv_priv_id)))) THEN
12090
 
    RAISE EXCEPTION 'Privilege id % does not exist or is part of a disabled package.',
12091
 
                NEW.usrpriv_priv_id;
12092
 
    RETURN OLD;
12093
 
 
12094
 
  ELSIF (TG_OP = 'DELETE') THEN
12095
 
    RETURN OLD;
12096
 
  END IF;
12097
 
 
12098
 
  RETURN NEW;
12099
 
END;
12100
 
$$;
12101
 
 
12102
 
 
12103
 
ALTER FUNCTION public._usrprivtrigger() OWNER TO admin;
12104
 
 
12105
 
--
12106
 
--
12107
 
 
12108
 
CREATE FUNCTION _vendaddrtrigger() RETURNS trigger
12109
 
    LANGUAGE plpgsql
12110
 
    AS $$
12111
 
DECLARE
12112
 
  _check      BOOLEAN;
12113
 
  _vendname   TEXT;
12114
 
 
12115
 
BEGIN
12116
 
 
12117
 
  SELECT checkPrivilege('MaintainVendors') INTO _check;
12118
 
  IF NOT (_check) THEN
12119
 
    RAISE EXCEPTION 'You do not have privileges to maintain Vendors.';
12120
 
  END IF;
12121
 
 
12122
 
  IF (TG_OP IN ('INSERT','UPDATE')) THEN
12123
 
 
12124
 
    IF (LENGTH(COALESCE(NEW.vendaddr_code, ''))=0) THEN
12125
 
      RAISE EXCEPTION 'You must supply a valid Vendor Address Number.';
12126
 
    END IF;
12127
 
 
12128
 
    IF (LENGTH(COALESCE(NEW.vendaddr_name, ''))=0) THEN
12129
 
      RAISE EXCEPTION 'You must supply a valid Vendor Address Name.';
12130
 
    END IF;
12131
 
 
12132
 
    IF (NEW.vendaddr_vend_id IS NULL) THEN
12133
 
      RAISE EXCEPTION 'You must supply a valid Vendor ID.';
12134
 
    END IF;
12135
 
 
12136
 
    SELECT vendaddr_code INTO _vendname
12137
 
    FROM vendaddrinfo
12138
 
    WHERE ( (vendaddr_vend_id=NEW.vendaddr_vend_id)
12139
 
      AND (UPPER(vendaddr_code)=UPPER(NEW.vendaddr_code))
12140
 
      AND (vendaddr_id<>NEW.vendaddr_id) );
12141
 
    IF (FOUND) THEN
12142
 
      RAISE EXCEPTION 'The Vendor Address Number entered cannot be used as it is in use.';
12143
 
    END IF;
12144
 
 
12145
 
  END IF;
12146
 
  
12147
 
  IF (TG_OP = 'DELETE') THEN
12148
 
    RETURN OLD;
12149
 
  END IF;
12150
 
 
12151
 
  RETURN NEW;
12152
 
END;
12153
 
$$;
12154
 
 
12155
 
 
12156
 
ALTER FUNCTION public._vendaddrtrigger() OWNER TO admin;
12157
 
 
12158
 
--
12159
 
--
12160
 
 
12161
 
CREATE FUNCTION _vendaftertrigger() RETURNS trigger
12162
 
    LANGUAGE plpgsql
12163
 
    AS $$
12164
 
DECLARE
12165
 
  _cmnttypeid   INTEGER;
12166
 
 
12167
 
BEGIN
12168
 
 
12169
 
  IF (TG_OP = 'INSERT') THEN
12170
 
    -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE
12171
 
    LOOP
12172
 
      UPDATE crmacct SET crmacct_vend_id=NEW.vend_id,
12173
 
                         crmacct_name=NEW.vend_name
12174
 
       WHERE crmacct_number=NEW.vend_number;
12175
 
      IF (FOUND) THEN
12176
 
        EXIT;
12177
 
      END IF;
12178
 
      BEGIN
12179
 
        INSERT INTO crmacct(crmacct_number,     crmacct_name,    crmacct_active,
12180
 
                            crmacct_type,       crmacct_vend_id,
12181
 
                            crmacct_cntct_id_1, crmacct_cntct_id_2
12182
 
                  ) VALUES (NEW.vend_number,    NEW.vend_name,   NEW.vend_active,
12183
 
                            'O',                NEW.vend_id,
12184
 
                            NEW.vend_cntct1_id, NEW.vend_cntct2_id);
12185
 
        EXIT;
12186
 
      EXCEPTION WHEN unique_violation THEN
12187
 
            -- do nothing, and loop to try the UPDATE again
12188
 
      END;
12189
 
    END LOOP;
12190
 
 
12191
 
    /* TODO: default characteristic assignments based on vendgrp? */
12192
 
 
12193
 
  ELSIF (TG_OP = 'UPDATE') THEN
12194
 
    UPDATE crmacct SET crmacct_number = NEW.vend_number
12195
 
    WHERE ((crmacct_vend_id=NEW.vend_id)
12196
 
      AND  (crmacct_number!=NEW.vend_number));
12197
 
 
12198
 
    UPDATE crmacct SET crmacct_name = NEW.vend_name
12199
 
    WHERE ((crmacct_vend_id=NEW.vend_id)
12200
 
      AND  (crmacct_name!=NEW.vend_name));
12201
 
 
12202
 
  END IF;
12203
 
 
12204
 
  IF (fetchMetricBool('VendorChangeLog')) THEN
12205
 
    SELECT cmnttype_id INTO _cmnttypeid
12206
 
      FROM cmnttype
12207
 
     WHERE (cmnttype_name='ChangeLog');
12208
 
 
12209
 
    IF (_cmnttypeid IS NOT NULL) THEN
12210
 
      IF (TG_OP = 'INSERT') THEN
12211
 
        PERFORM postComment(_cmnttypeid, 'V', NEW.vend_id, 'Created');
12212
 
 
12213
 
      ELSIF (TG_OP = 'UPDATE') THEN
12214
 
 
12215
 
        IF (OLD.vend_number <> NEW.vend_number) THEN
12216
 
          PERFORM postComment(_cmnttypeid, 'V', NEW.vend_id,
12217
 
                              ('Number Changed from "' || OLD.vend_number ||
12218
 
                               '" to "' || NEW.vend_number || '"') );
12219
 
        END IF;
12220
 
 
12221
 
        IF (OLD.vend_name <> NEW.vend_name) THEN
12222
 
          PERFORM postComment( _cmnttypeid, 'V', NEW.vend_id,
12223
 
                              ('Name Changed from "' || OLD.vend_name ||
12224
 
                               '" to "' || NEW.vend_name || '"') );
12225
 
        END IF;
12226
 
 
12227
 
        IF (OLD.vend_active <> NEW.vend_active) THEN
12228
 
          PERFORM postComment(_cmnttypeid, 'V', NEW.vend_id,
12229
 
                              CASE WHEN NEW.vend_active THEN 'Activated'
12230
 
                                   ELSE 'Deactivated' END);
12231
 
        END IF;
12232
 
 
12233
 
      END IF;
12234
 
    END IF;
12235
 
  END IF;
12236
 
 
12237
 
  RETURN NEW;
12238
 
END;
12239
 
$$;
12240
 
 
12241
 
 
12242
 
ALTER FUNCTION public._vendaftertrigger() OWNER TO admin;
12243
 
 
12244
 
--
12245
 
--
12246
 
 
12247
 
CREATE FUNCTION _vendinfoafterdeletetrigger() RETURNS trigger
12248
 
    LANGUAGE plpgsql
12249
 
    AS $$
12250
 
BEGIN
12251
 
  IF EXISTS(SELECT 1
12252
 
              FROM checkhead
12253
 
             WHERE ((checkhead_recip_id=OLD.vend_id)
12254
 
                AND (checkhead_recip_type='V'))) THEN
12255
 
    RAISE EXCEPTION '[xtuple: deleteVendor, -7]';
12256
 
  END IF;
12257
 
 
12258
 
  DELETE FROM taxreg
12259
 
   WHERE ((taxreg_rel_type='V')
12260
 
      AND (taxreg_rel_id=OLD.vend_id));
12261
 
 
12262
 
  IF (fetchMetricBool('VendorChangeLog')) THEN
12263
 
    PERFORM postComment(cmnttype_id, 'V', OLD.vend_id,
12264
 
                        ('Deleted "' || OLD.vend_number || '"'))
12265
 
      FROM cmnttype
12266
 
     WHERE (cmnttype_name='ChangeLog');
12267
 
  END IF;
12268
 
 
12269
 
  RETURN OLD;
12270
 
END;
12271
 
$$;
12272
 
 
12273
 
 
12274
 
ALTER FUNCTION public._vendinfoafterdeletetrigger() OWNER TO admin;
12275
 
 
12276
 
--
12277
 
--
12278
 
 
12279
 
CREATE FUNCTION _vendinfobeforedeletetrigger() RETURNS trigger
12280
 
    LANGUAGE plpgsql
12281
 
    AS $$
12282
 
BEGIN
12283
 
  IF NOT (checkPrivilege('MaintainVendors')) THEN
12284
 
    RAISE EXCEPTION 'You do not have privileges to maintain Vendors.';
12285
 
  END IF;
12286
 
 
12287
 
  DELETE FROM itemsrcp
12288
 
   WHERE itemsrcp_itemsrc_id IN (SELECT itemsrc_id
12289
 
                                   FROM itemsrc
12290
 
                                  WHERE itemsrc_vend_id=OLD.vend_id);
12291
 
 
12292
 
  DELETE FROM itemsrc WHERE (itemsrc_vend_id=OLD.vend_id);
12293
 
 
12294
 
  DELETE FROM vendaddrinfo WHERE (vendaddr_vend_id=OLD.vend_id);
12295
 
 
12296
 
  DELETE FROM docass WHERE docass_source_id = OLD.vend_id AND docass_source_type = 'V';
12297
 
  DELETE FROM docass WHERE docass_target_id = OLD.vend_id AND docass_target_type = 'V';
12298
 
 
12299
 
  UPDATE crmacct SET crmacct_vend_id = NULL
12300
 
   WHERE crmacct_vend_id = OLD.vend_id;
12301
 
  RETURN OLD;
12302
 
END;
12303
 
$$;
12304
 
 
12305
 
 
12306
 
ALTER FUNCTION public._vendinfobeforedeletetrigger() OWNER TO admin;
12307
 
 
12308
 
--
12309
 
--
12310
 
 
12311
 
CREATE FUNCTION _vendtrigger() RETURNS trigger
12312
 
    LANGUAGE plpgsql
12313
 
    AS $$
12314
 
BEGIN
12315
 
 
12316
 
  IF NOT (checkPrivilege('MaintainVendors')) THEN
12317
 
    RAISE EXCEPTION 'You do not have privileges to maintain Vendors.';
12318
 
  END IF;
12319
 
 
12320
 
  IF (LENGTH(COALESCE(NEW.vend_number, ''))=0) THEN
12321
 
    RAISE EXCEPTION 'You must supply a valid Vendor Number.';
12322
 
  END IF;
12323
 
 
12324
 
  IF (LENGTH(COALESCE(NEW.vend_name, ''))=0) THEN
12325
 
    RAISE EXCEPTION 'You must supply a valid Vendor Name.';
12326
 
  END IF;
12327
 
 
12328
 
  IF (NEW.vend_vendtype_id IS NULL) THEN
12329
 
    RAISE EXCEPTION 'You must supply a valid Vendor Type ID.';
12330
 
  END IF;
12331
 
 
12332
 
  IF (NEW.vend_terms_id IS NULL) THEN
12333
 
    RAISE EXCEPTION 'You must supply a valid Terms Code ID.';
12334
 
  END IF;
12335
 
 
12336
 
  IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN
12337
 
    PERFORM clearNumberIssue('CRMAccountNumber', NEW.vend_number);
12338
 
  END IF;
12339
 
 
12340
 
  NEW.vend_number := UPPER(NEW.vend_number);
12341
 
 
12342
 
  RETURN NEW;
12343
 
END;
12344
 
$$;
12345
 
 
12346
 
 
12347
 
ALTER FUNCTION public._vendtrigger() OWNER TO admin;
12348
 
 
12349
 
--
12350
 
--
12351
 
 
12352
 
CREATE FUNCTION _vodistaftertrigger() RETURNS trigger
12353
 
    LANGUAGE plpgsql
12354
 
    AS $$
12355
 
DECLARE
12356
 
  _r RECORD;
12357
 
 
12358
 
BEGIN
12359
 
  IF ( (TG_OP = 'UPDATE') OR (TG_OP = 'DELETE') ) THEN
12360
 
    IF (OLD.vodist_tax_id <> -1) THEN
12361
 
    -- Delete any existing voheadtax adjustment records
12362
 
      DELETE FROM voheadtax
12363
 
      WHERE ( (taxhist_parent_id=OLD.vodist_vohead_id)
12364
 
        AND   (taxhist_tax_id=OLD.vodist_tax_id)
12365
 
        AND   (taxhist_taxtype_id=getAdjustmentTaxTypeId()) );
12366
 
    END IF;
12367
 
  END IF;
12368
 
 
12369
 
  IF (TG_OP = 'DELETE') THEN
12370
 
    RETURN OLD;
12371
 
  END IF;
12372
 
 
12373
 
  SELECT * INTO _r
12374
 
  FROM vohead
12375
 
  WHERE (vohead_id=NEW.vodist_vohead_id);
12376
 
  IF (NOT FOUND) THEN
12377
 
    RAISE EXCEPTION 'Voucher head not found';
12378
 
  END IF;
12379
 
 
12380
 
  IF (NEW.vodist_tax_id <> -1) THEN
12381
 
  -- Insert adjustment voheadtax
12382
 
    INSERT INTO voheadtax
12383
 
      ( taxhist_parent_id,
12384
 
        taxhist_taxtype_id,
12385
 
        taxhist_tax_id,
12386
 
        taxhist_basis,
12387
 
        taxhist_basis_tax_id,
12388
 
        taxhist_sequence,
12389
 
        taxhist_percent,
12390
 
        taxhist_amount,
12391
 
        taxhist_tax,
12392
 
        taxhist_docdate )
12393
 
    VALUES
12394
 
      ( NEW.vodist_vohead_id,
12395
 
        getAdjustmentTaxTypeId(),
12396
 
        NEW.vodist_tax_id,
12397
 
        0,
12398
 
        NULL,
12399
 
        1,
12400
 
        0,
12401
 
        0,
12402
 
        (NEW.vodist_amount * -1),
12403
 
        _r.vohead_docdate );
12404
 
  END IF;
12405
 
 
12406
 
  RETURN NEW;
12407
 
END;
12408
 
$$;
12409
 
 
12410
 
 
12411
 
ALTER FUNCTION public._vodistaftertrigger() OWNER TO admin;
12412
 
 
12413
 
--
12414
 
--
12415
 
 
12416
 
CREATE FUNCTION _vodistbeforetrigger() RETURNS trigger
12417
 
    LANGUAGE plpgsql
12418
 
    AS $$
12419
 
DECLARE
12420
 
 
12421
 
BEGIN
12422
 
  IF (TG_OP = 'DELETE') THEN
12423
 
    IF (OLD.vodist_tax_id <> -1) THEN
12424
 
    -- Delete any existing voheadtax adjustment records
12425
 
      DELETE FROM voheadtax
12426
 
      WHERE ( (taxhist_parent_id=OLD.vodist_vohead_id)
12427
 
        AND   (taxhist_tax_id=OLD.vodist_tax_id)
12428
 
        AND   (taxhist_taxtype_id=getAdjustmentTaxTypeId()) );
12429
 
    END IF;
12430
 
 
12431
 
    RETURN OLD;
12432
 
  END IF;
12433
 
 
12434
 
  RETURN NEW;
12435
 
END;
12436
 
$$;
12437
 
 
12438
 
 
12439
 
ALTER FUNCTION public._vodistbeforetrigger() OWNER TO admin;
12440
 
 
12441
 
--
12442
 
--
12443
 
 
12444
 
CREATE FUNCTION _voheadaftertrigger() RETURNS trigger
12445
 
    LANGUAGE plpgsql
12446
 
    AS $$
12447
 
BEGIN
12448
 
  IF (TG_OP = 'DELETE') THEN
12449
 
    PERFORM releaseVoNumber(CAST(OLD.vohead_number AS INTEGER));
12450
 
    RETURN OLD;
12451
 
  END IF;
12452
 
 
12453
 
  IF (TG_OP = 'INSERT') THEN
12454
 
    PERFORM clearNumberIssue('VcNumber', NEW.vohead_number);
12455
 
    RETURN NEW;
12456
 
  END IF;
12457
 
 
12458
 
  IF (TG_OP = 'UPDATE') THEN
12459
 
    IF ( (COALESCE(NEW.vohead_taxzone_id,-1) <> COALESCE(OLD.vohead_taxzone_id,-1)) OR
12460
 
         (NEW.vohead_docdate <> OLD.vohead_docdate) OR
12461
 
         (NEW.vohead_curr_id <> OLD.vohead_curr_id) ) THEN
12462
 
      PERFORM calculateTaxHist( 'voitemtax',
12463
 
                                voitem_id,
12464
 
                                NEW.vohead_taxzone_id,
12465
 
                                voitem_taxtype_id,
12466
 
                                NEW.vohead_docdate,
12467
 
                                NEW.vohead_curr_id,
12468
 
                                (vodist_amount * -1) )
12469
 
      FROM voitem JOIN vodist ON ( (vodist_vohead_id=voitem_vohead_id) AND
12470
 
                                   (vodist_poitem_id=voitem_poitem_id) )
12471
 
      WHERE (voitem_vohead_id = NEW.vohead_id);
12472
 
    END IF;
12473
 
 
12474
 
    -- Touch any Misc Tax Distributions so voheadtax is recalculated
12475
 
    IF (NEW.vohead_docdate <> OLD.vohead_docdate) THEN
12476
 
      UPDATE vodist SET vodist_vohead_id=NEW.vohead_id
12477
 
      WHERE ( (vodist_vohead_id=OLD.vohead_id)
12478
 
        AND   (vodist_tax_id <> -1) );
12479
 
    END IF;
12480
 
  END IF;
12481
 
 
12482
 
  RETURN NEW;
12483
 
END;
12484
 
$$;
12485
 
 
12486
 
 
12487
 
ALTER FUNCTION public._voheadaftertrigger() OWNER TO admin;
12488
 
 
12489
 
--
12490
 
--
12491
 
 
12492
 
CREATE FUNCTION _voheadbeforetrigger() RETURNS trigger
12493
 
    LANGUAGE plpgsql
12494
 
    AS $$
12495
 
DECLARE
12496
 
  _recurid     INTEGER;
12497
 
  _newparentid INTEGER;
12498
 
 
12499
 
BEGIN
12500
 
  IF (TG_OP = 'DELETE') THEN
12501
 
    IF (OLD.vohead_posted) THEN
12502
 
      -- Cannot delete a posted voucher
12503
 
      RAISE EXCEPTION 'Cannot delete a posted voucher';
12504
 
    END IF;
12505
 
 
12506
 
    /* TODO: is setting recv_invoiced and poreject_invoiced to FALSE correct?
12507
 
             this behavior is inherited from the now-defunct deleteVoucher.
12508
 
     */
12509
 
    UPDATE recv SET recv_vohead_id = NULL,
12510
 
                    recv_voitem_id = NULL,
12511
 
                    recv_invoiced  = FALSE
12512
 
     WHERE recv_vohead_id = OLD.vohead_id;
12513
 
 
12514
 
    UPDATE poreject SET poreject_vohead_id = NULL,
12515
 
                        poreject_voitem_id = NULL,
12516
 
                        poreject_invoiced  = FALSE
12517
 
     WHERE poreject_vohead_id = OLD.vohead_id;
12518
 
 
12519
 
    DELETE FROM vodist    WHERE vodist_vohead_id  = OLD.vohead_id;
12520
 
    DELETE FROM voheadtax WHERE taxhist_parent_id = OLD.vohead_id;
12521
 
    DELETE FROM voitem    WHERE voitem_vohead_id  = OLD.vohead_id;
12522
 
 
12523
 
    SELECT recur_id INTO _recurid
12524
 
      FROM recur
12525
 
     WHERE ((recur_parent_id=OLD.vohead_id)
12526
 
        AND (recur_parent_type='V'));
12527
 
    IF (_recurid IS NOT NULL) THEN
12528
 
      SELECT vohead_id INTO _newparentid
12529
 
        FROM vohead
12530
 
       WHERE ((vohead_recurring_vohead_id=OLD.vohead_id)
12531
 
          AND (vohead_id!=OLD.vohead_id))
12532
 
       ORDER BY vohead_docdate
12533
 
       LIMIT 1;
12534
 
 
12535
 
      IF (_newparentid IS NULL) THEN
12536
 
        DELETE FROM recur WHERE recur_id=_recurid;
12537
 
      ELSE
12538
 
        UPDATE recur SET recur_parent_id=_newparentid
12539
 
         WHERE recur_id=_recurid;
12540
 
        UPDATE vohead SET vohead_recurring_vohead_id=_newparentid
12541
 
         WHERE vohead_recurring_vohead_id=OLD.vohead_id
12542
 
           AND vohead_id!=OLD.vohead_id;
12543
 
      END IF;
12544
 
    END IF;
12545
 
 
12546
 
    RETURN OLD;
12547
 
  END IF;
12548
 
 
12549
 
  RETURN NEW;
12550
 
END;
12551
 
$$;
12552
 
 
12553
 
 
12554
 
ALTER FUNCTION public._voheadbeforetrigger() OWNER TO admin;
12555
 
 
12556
 
--
12557
 
--
12558
 
 
12559
 
CREATE FUNCTION _voitemaftertrigger() RETURNS trigger
12560
 
    LANGUAGE plpgsql
12561
 
    AS $$
12562
 
DECLARE
12563
 
  _r RECORD;
12564
 
 
12565
 
BEGIN
12566
 
  IF (TG_OP = 'DELETE') THEN
12567
 
    RETURN OLD;
12568
 
  END IF;
12569
 
 
12570
 
  SELECT * INTO _r
12571
 
  FROM vohead
12572
 
  WHERE (vohead_id=NEW.voitem_vohead_id);
12573
 
  IF (NOT FOUND) THEN
12574
 
    RAISE EXCEPTION 'Voucher head not found';
12575
 
  END IF;
12576
 
 
12577
 
  PERFORM calculateTaxHist( 'voitemtax',
12578
 
                            NEW.voitem_id,
12579
 
                            COALESCE(_r.vohead_taxzone_id, -1),
12580
 
                            NEW.voitem_taxtype_id,
12581
 
                            COALESCE(_r.vohead_docdate, CURRENT_DATE),
12582
 
                            COALESCE(_r.vohead_curr_id, -1),
12583
 
                            COALESCE(SUM(vodist_amount * -1), 0) )
12584
 
  FROM vodist
12585
 
  WHERE ( (vodist_vohead_id=_r.vohead_id)
12586
 
    AND   (vodist_poitem_id=NEW.voitem_poitem_id) );
12587
 
 
12588
 
  RETURN NEW;
12589
 
END;
12590
 
$$;
12591
 
 
12592
 
 
12593
 
ALTER FUNCTION public._voitemaftertrigger() OWNER TO admin;
12594
 
 
12595
 
--
12596
 
--
12597
 
 
12598
 
CREATE FUNCTION _voitembeforetrigger() RETURNS trigger
12599
 
    LANGUAGE plpgsql
12600
 
    AS $$
12601
 
DECLARE
12602
 
 
12603
 
BEGIN
12604
 
  IF (TG_OP = 'DELETE') THEN
12605
 
    DELETE FROM voitemtax
12606
 
    WHERE (taxhist_parent_id=OLD.voitem_id);
12607
 
 
12608
 
    RETURN OLD;
12609
 
  END IF;
12610
 
 
12611
 
  RETURN NEW;
12612
 
END;
12613
 
$$;
12614
 
 
12615
 
 
12616
 
ALTER FUNCTION public._voitembeforetrigger() OWNER TO admin;
12617
 
 
12618
 
--
12619
 
--
12620
 
 
12621
 
CREATE FUNCTION _warehoustrigger() RETURNS trigger
12622
 
    LANGUAGE plpgsql
12623
 
    AS $$
12624
 
DECLARE
12625
 
  _cmnttypeid INTEGER;
12626
 
  _check      BOOLEAN;
12627
 
  _checkId    INTEGER;
12628
 
 
12629
 
BEGIN
12630
 
 
12631
 
  -- Checks
12632
 
  -- Start with privileges
12633
 
  IF (TG_OP = 'INSERT') THEN
12634
 
    SELECT checkPrivilege('MaintainWarehouses') INTO _check;
12635
 
    IF NOT (_check) THEN
12636
 
      RAISE EXCEPTION 'You do not have privileges to add new Sites.';
12637
 
    END IF;
12638
 
  ELSE
12639
 
    SELECT checkPrivilege('MaintainWarehouses') OR checkPrivilege('IssueCountTags') INTO _check;
12640
 
    IF NOT (_check) THEN
12641
 
      RAISE EXCEPTION 'You do not have privileges to alter a Site.';
12642
 
    END IF;
12643
 
  END IF;
12644
 
 
12645
 
  -- Code is required
12646
 
  IF (LENGTH(COALESCE(NEW.warehous_code,''))=0) THEN
12647
 
    RAISE EXCEPTION 'You must supply a valid Site Code.';
12648
 
  END IF;
12649
 
 
12650
 
  -- Sitetype is required
12651
 
  IF (NEW.warehous_sitetype_id IS NULL) THEN
12652
 
    RAISE EXCEPTION 'You must supply a valid Site Type.';
12653
 
  END IF;
12654
 
 
12655
 
  -- Cost Category is required for Transit types
12656
 
  IF ((NEW.warehous_transit) AND (NEW.warehous_costcat_id IS NULL)) THEN
12657
 
    RAISE EXCEPTION 'You must supply a valid Cost Category for Transit Sites.';
12658
 
  END IF;
12659
 
 
12660
 
  -- Code must be unique
12661
 
  SELECT warehous_id INTO _checkId
12662
 
  FROM whsinfo
12663
 
  WHERE ( (UPPER(warehous_code)=UPPER(NEW.warehous_code))
12664
 
    AND   (warehous_id<>NEW.warehous_id) );
12665
 
  IF (FOUND) THEN
12666
 
    RAISE EXCEPTION 'You must supply a unique Site Code.';
12667
 
  END IF;
12668
 
 
12669
 
  -- Count Tag Prefix must be unique
12670
 
  IF (TG_OP = 'INSERT') THEN
12671
 
    SELECT warehous_id INTO _checkId
12672
 
    FROM whsinfo
12673
 
    WHERE (warehous_counttag_prefix=NEW.warehous_counttag_prefix);
12674
 
  ELSE
12675
 
    SELECT warehous_id INTO _checkId
12676
 
    FROM whsinfo
12677
 
    WHERE ( (warehous_counttag_prefix=NEW.warehous_counttag_prefix)
12678
 
      AND   (warehous_id<>NEW.warehous_id) );
12679
 
  END IF;
12680
 
  IF (FOUND) THEN
12681
 
    RAISE EXCEPTION 'You must supply a unique Count Tag Prefix.';
12682
 
  END IF;
12683
 
 
12684
 
  -- Check Complete
12685
 
  -- Change Log
12686
 
  IF ( SELECT (metric_value='t')
12687
 
       FROM metric
12688
 
       WHERE (metric_name='WarehouseChangeLog') ) THEN
12689
 
 
12690
 
    SELECT cmnttype_id INTO _cmnttypeid
12691
 
    FROM cmnttype
12692
 
    WHERE (cmnttype_name='ChangeLog');
12693
 
    IF (FOUND) THEN
12694
 
      IF (TG_OP = 'INSERT') THEN
12695
 
        PERFORM postComment(_cmnttypeid, 'WH', NEW.warehous_id, 'Created');
12696
 
 
12697
 
      ELSIF (TG_OP = 'UPDATE') THEN
12698
 
        IF (OLD.warehous_code <> NEW.warehous_code) THEN
12699
 
          PERFORM postComment( _cmnttypeid, 'WH', NEW.warehous_id,
12700
 
                               ('Code Changed from "' || OLD.warehous_code || '" to "' || NEW.warehous_code || '"') );
12701
 
        END IF;
12702
 
 
12703
 
        IF (OLD.warehous_descrip <> NEW.warehous_descrip) THEN
12704
 
          PERFORM postComment( _cmnttypeid, 'WH', NEW.warehous_id,
12705
 
                               ( 'Description Changed from "' || OLD.warehous_descrip ||
12706
 
                                 '" to "' || NEW.warehous_descrip || '"' ) );
12707
 
        END IF;
12708
 
 
12709
 
        IF (OLD.warehous_active <> NEW.warehous_active) THEN
12710
 
          IF (NEW.warehous_active) THEN
12711
 
            PERFORM postComment(_cmnttypeid, 'WH', NEW.warehous_id, 'Activated');
12712
 
          ELSE
12713
 
            PERFORM postComment(_cmnttypeid, 'WH', NEW.warehous_id, 'Deactivated');
12714
 
          END IF;
12715
 
        END IF;
12716
 
 
12717
 
      END IF;
12718
 
    END IF;
12719
 
  END IF;
12720
 
 
12721
 
  RETURN NEW;
12722
 
 
12723
 
END;
12724
 
$$;
12725
 
 
12726
 
 
12727
 
ALTER FUNCTION public._warehoustrigger() OWNER TO admin;
12728
 
 
12729
 
--
12730
 
--
12731
 
 
12732
 
CREATE FUNCTION _whsezonetrigger() RETURNS trigger
12733
 
    LANGUAGE plpgsql
12734
 
    AS $$
12735
 
DECLARE
12736
 
  _check      BOOLEAN;
12737
 
  _checkId    INTEGER;
12738
 
 
12739
 
BEGIN
12740
 
 
12741
 
  -- Checks
12742
 
  -- Start with privileges
12743
 
  IF (TG_OP = 'INSERT') THEN
12744
 
    SELECT checkPrivilege('MaintainWarehouses') INTO _check;
12745
 
    IF NOT (_check) THEN
12746
 
      RAISE EXCEPTION 'You do not have privileges to add new Site Zones.';
12747
 
    END IF;
12748
 
  ELSE
12749
 
    SELECT checkPrivilege('MaintainWarehouses') INTO _check;
12750
 
    IF NOT (_check) THEN
12751
 
      RAISE EXCEPTION 'You do not have privileges to alter a Site Zone.';
12752
 
    END IF;
12753
 
  END IF;
12754
 
 
12755
 
  -- Name is required
12756
 
  IF (LENGTH(COALESCE(NEW.whsezone_name,''))=0) THEN
12757
 
    RAISE EXCEPTION 'You must supply a valid Site Zone Name.';
12758
 
  END IF;
12759
 
  
12760
 
  -- Site is required
12761
 
  IF (NEW.whsezone_warehous_id IS NULL) THEN
12762
 
    RAISE EXCEPTION 'You must supply a valid Site.';
12763
 
  END IF;
12764
 
 
12765
 
  RETURN NEW;
12766
 
 
12767
 
END;
12768
 
$$;
12769
 
 
12770
 
 
12771
 
ALTER FUNCTION public._whsezonetrigger() OWNER TO admin;
12772
 
 
12773
 
--
12774
 
--
12775
 
 
12776
 
CREATE FUNCTION _womatlaftertrigger() RETURNS trigger
12777
 
    LANGUAGE plpgsql
12778
 
    AS $$
12779
 
DECLARE
12780
 
 
12781
 
BEGIN
12782
 
 
12783
 
  IF (TG_OP = 'INSERT') THEN
12784
 
 
12785
 
  --  Create any required P/R's
12786
 
    PERFORM createPr('W', NEW.womatl_id)
12787
 
       FROM itemsite 
12788
 
      WHERE ((itemsite_id=NEW.womatl_itemsite_id)
12789
 
        AND  (itemsite_createpr));
12790
 
 
12791
 
  END IF;
12792
 
 
12793
 
  RETURN NEW;
12794
 
 
12795
 
END;
12796
 
$$;
12797
 
 
12798
 
 
12799
 
ALTER FUNCTION public._womatlaftertrigger() OWNER TO admin;
12800
 
 
12801
 
--
12802
 
--
12803
 
 
12804
 
CREATE FUNCTION _wotrigger() RETURNS trigger
12805
 
    LANGUAGE plpgsql
12806
 
    AS $$
12807
 
DECLARE
12808
 
 
12809
 
BEGIN
12810
 
 
12811
 
  IF (TG_OP = 'INSERT') THEN
12812
 
    PERFORM postEvent('WoCreated', 'W', NEW.wo_id,
12813
 
                      itemsite_warehous_id,
12814
 
                      (NEW.wo_number || '-' || NEW.wo_subnumber),
12815
 
                      NULL, NULL, NULL, NULL)
12816
 
    FROM itemsite
12817
 
    WHERE (itemsite_id=NEW.wo_itemsite_id)
12818
 
      AND (NEW.wo_duedate <= (CURRENT_DATE + itemsite_eventfence));
12819
 
 
12820
 
    PERFORM postComment('ChangeLog', 'W', NEW.wo_id, 'Created');
12821
 
 
12822
 
    IF (fetchMetricText('WONumberGeneration') IN ('A','O')) THEN
12823
 
      --- clear the number from the issue cache
12824
 
      PERFORM clearNumberIssue('WoNumber', NEW.wo_number);
12825
 
    END IF;
12826
 
 
12827
 
    RETURN NEW;
12828
 
 
12829
 
  ELSE
12830
 
      IF (TG_OP = 'DELETE') THEN
12831
 
      PERFORM postEvent('WoCancelled', 'W', OLD.wo_id,
12832
 
                        itemsite_warehous_id,
12833
 
                        (OLD.wo_number || '-' || OLD.wo_subnumber),
12834
 
                        NULL, NULL, NULL, NULL)
12835
 
      FROM itemsite
12836
 
      WHERE (itemsite_id=OLD.wo_itemsite_id)
12837
 
        AND (OLD.wo_duedate <= (CURRENT_DATE + itemsite_eventfence));
12838
 
 
12839
 
      DELETE FROM docass WHERE docass_source_id = OLD.wo_id AND docass_source_type = 'W';
12840
 
      DELETE FROM docass WHERE docass_target_id = OLD.wo_id AND docass_target_type = 'W';
12841
 
 
12842
 
      DELETE FROM comment
12843
 
      WHERE ( (comment_source='W')
12844
 
       AND (comment_source_id=OLD.wo_id) );
12845
 
 
12846
 
      DELETE FROM charass
12847
 
       WHERE ((charass_target_type='W')
12848
 
         AND  (charass_target_id=OLD.wo_id));
12849
 
 
12850
 
       RETURN OLD;
12851
 
 
12852
 
    ELSE
12853
 
      IF (TG_OP = 'UPDATE') THEN
12854
 
 
12855
 
        IF (NEW.wo_qtyord <> OLD.wo_qtyord) THEN
12856
 
          PERFORM postEvent('WoQtyChanged', 'W', NEW.wo_id,
12857
 
                            itemsite_warehous_id,
12858
 
                            (NEW.wo_number || '-' || NEW.wo_subnumber),
12859
 
                            NEW.wo_qtyord, OLD.wo_qtyord, NULL, NULL)
12860
 
          FROM itemsite
12861
 
          WHERE (itemsite_id=NEW.wo_itemsite_id)
12862
 
            AND ( (NEW.wo_duedate <= (CURRENT_DATE + itemsite_eventfence))
12863
 
             OR   (OLD.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)) );
12864
 
 
12865
 
          PERFORM postComment( 'ChangeLog', 'W', NEW.wo_id,
12866
 
                               ( 'Qty. Ordered Changed from ' || formatQty(OLD.wo_qtyord) ||
12867
 
                                 ' to ' || formatQty(NEW.wo_qtyord ) ) );
12868
 
        END IF;
12869
 
 
12870
 
        IF (NEW.wo_duedate <> OLD.wo_duedate) THEN
12871
 
          PERFORM postEvent('WoDueDateChanged', 'W', NEW.wo_id,
12872
 
                            itemsite_warehous_id,
12873
 
                            (NEW.wo_number || '-' || NEW.wo_subnumber),
12874
 
                            NULL, NULL, NEW.wo_duedate, OLD.wo_duedate)
12875
 
          FROM itemsite
12876
 
          WHERE (itemsite_id=NEW.wo_itemsite_id)
12877
 
            AND ( (NEW.wo_duedate <= (CURRENT_DATE + itemsite_eventfence))
12878
 
             OR   (OLD.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)) );
12879
 
 
12880
 
          PERFORM postComment( 'ChangeLog', 'W', NEW.wo_id,
12881
 
                               ( 'Due Date Changed from ' || formatDate(OLD.wo_duedate) ||
12882
 
                                 ' to ' || formatDate(NEW.wo_duedate ) ) );
12883
 
        END IF;
12884
 
 
12885
 
        IF (NEW.wo_status <> OLD.wo_status) THEN
12886
 
          PERFORM postComment( 'ChangeLog', 'W', NEW.wo_id,
12887
 
                               ('Status Changed from ' || OLD.wo_status || ' to ' || NEW.wo_status) );
12888
 
        END IF;
12889
 
 
12890
 
      END IF;
12891
 
    END IF;
12892
 
  END IF;
12893
 
 
12894
 
  IF (TG_OP = 'UPDATE') THEN
12895
 
    IF (NEW.wo_prj_id <> OLD.wo_prj_id) THEN
12896
 
      UPDATE wo SET wo_prj_id=NEW.wo_prj_id
12897
 
      WHERE (wo_ordtype='W')
12898
 
        AND (wo_ordid=NEW.wo_id);
12899
 
    END IF;
12900
 
  END IF;
12901
 
 
12902
 
  RETURN NEW;
12903
 
 
12904
 
END;
12905
 
$$;
12906
 
 
12907
 
 
12908
 
ALTER FUNCTION public._wotrigger() OWNER TO admin;
12909
 
 
12910
 
--
12911
 
--
12912
 
 
12913
 
CREATE FUNCTION acknowledgemessage(integer) RETURNS boolean
12914
 
    LANGUAGE plpgsql
12915
 
    AS $_$
12916
 
DECLARE
12917
 
  pMsgid ALIAS FOR $1;
12918
 
 
12919
 
BEGIN
12920
 
 
12921
 
  UPDATE msguser
12922
 
  SET msguser_viewed=CURRENT_TIMESTAMP
12923
 
  WHERE ( (msguser_msg_id=pMsgid)
12924
 
   AND (msguser_username=getEffectiveXtUser()) );
12925
 
 
12926
 
  RETURN TRUE;
12927
 
 
12928
 
END;
12929
 
$_$;
12930
 
 
12931
 
 
12932
 
ALTER FUNCTION public.acknowledgemessage(integer) OWNER TO admin;
12933
 
 
12934
 
--
12935
 
--
12936
 
 
12937
 
CREATE FUNCTION actcost(integer) RETURNS numeric
12938
 
    LANGUAGE plpgsql
12939
 
    AS $_$
12940
 
BEGIN
12941
 
  RETURN actCost($1, NULL, baseCurrId());
12942
 
END;
12943
 
$_$;
12944
 
 
12945
 
 
12946
 
ALTER FUNCTION public.actcost(integer) OWNER TO admin;
12947
 
 
12948
 
--
12949
 
--
12950
 
 
12951
 
CREATE FUNCTION actcost(integer, integer) RETURNS numeric
12952
 
    LANGUAGE plpgsql
12953
 
    AS $_$
12954
 
BEGIN
12955
 
  RETURN actCost($1, $2, baseCurrId());
12956
 
END;
12957
 
$_$;
12958
 
 
12959
 
 
12960
 
ALTER FUNCTION public.actcost(integer, integer) OWNER TO admin;
12961
 
 
12962
 
--
12963
 
--
12964
 
 
12965
 
CREATE FUNCTION actcost(integer, integer, integer) RETURNS numeric
12966
 
    LANGUAGE plpgsql
12967
 
    AS $_$
12968
 
DECLARE
12969
 
  pItemid ALIAS FOR $1;
12970
 
  pBomitemid ALIAS FOR $2;
12971
 
  pCurrid ALIAS FOR $3;
12972
 
  _cost NUMERIC;
12973
 
 
12974
 
BEGIN
12975
 
 
12976
 
  -- Return actual cost in the given currency at the current conversion rate
12977
 
  SELECT SUM(CASE WHEN (bomitemcost_id IS NOT NULL) THEN
12978
 
                  ROUND(currToCurr(bomitemcost_curr_id, pCurrid, bomitemcost_actcost, CURRENT_DATE), 6)
12979
 
                  ELSE
12980
 
                  ROUND(currToCurr(itemcost_curr_id, pCurrid, itemcost_actcost, CURRENT_DATE), 6)
12981
 
             END) INTO _cost
12982
 
  FROM itemcost
12983
 
    LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=pBomitemid AND bomitemcost_costelem_id=itemcost_costelem_id)
12984
 
  WHERE (itemcost_item_id=pItemid);
12985
 
 
12986
 
  IF (_cost IS NULL) THEN
12987
 
    RETURN 0;
12988
 
  ELSE
12989
 
    RETURN _cost;
12990
 
  END IF;
12991
 
 
12992
 
END;
12993
 
$_$;
12994
 
 
12995
 
 
12996
 
ALTER FUNCTION public.actcost(integer, integer, integer) OWNER TO admin;
12997
 
 
12998
 
--
12999
 
--
13000
 
 
13001
 
CREATE FUNCTION addrusecount(integer) RETURNS integer
13002
 
    LANGUAGE plpgsql STABLE
13003
 
    AS $_$
13004
 
DECLARE
13005
 
  pAddrId ALIAS FOR $1;
13006
 
  _fk RECORD;
13007
 
  _r RECORD;
13008
 
  _seq INTEGER;
13009
 
  _col TEXT;
13010
 
  _qry TEXT;
13011
 
  _count INTEGER = 0;
13012
 
 
13013
 
BEGIN
13014
 
  -- Determine where this address is used by analyzing foreign key linkages
13015
 
  -- TO DO: Can this be rationalized with cntctused(int)?
13016
 
  FOR _fk IN
13017
 
    SELECT pg_namespace.nspname AS schemaname, con.relname AS tablename, conkey AS seq, conrelid AS class_id 
13018
 
    FROM pg_constraint, pg_class f, pg_class con, pg_namespace
13019
 
    WHERE confrelid=f.oid
13020
 
    AND conrelid=con.oid
13021
 
    AND f.relname = 'addr'
13022
 
    AND con.relnamespace=pg_namespace.oid
13023
 
    AND con.relname NOT IN ('pohead') -- exception(s) where address key doesn't actually drive document information
13024
 
  LOOP
13025
 
    -- Validate
13026
 
    IF (ARRAY_UPPER(_fk.seq,1) > 1) THEN
13027
 
      RAISE EXCEPTION 'Checks to tables where the address is one of multiple foreign key columns is not supported. Error on Table: %',
13028
 
        pg_namespace.nspname || '.' || con.relname;
13029
 
    END IF;
13030
 
    
13031
 
    _seq := _fk.seq[1];
13032
 
 
13033
 
    -- Get the specific column name
13034
 
    SELECT attname INTO _col
13035
 
    FROM pg_attribute, pg_class
13036
 
    WHERE ((attrelid=pg_class.oid)
13037
 
    AND (pg_class.oid=_fk.class_id)
13038
 
    AND (attnum=_seq));
13039
 
 
13040
 
    -- See if there are dependencies
13041
 
    _qry := 'SELECT * 
13042
 
            FROM ' || _fk.schemaname || '.' || _fk.tablename || '
13043
 
            WHERE ('|| _col || '=' || pAddrId || ');';
13044
 
 
13045
 
    FOR _r IN 
13046
 
      EXECUTE _qry
13047
 
    LOOP
13048
 
      _count := _count + 1;
13049
 
    END LOOP;
13050
 
         
13051
 
  END LOOP;
13052
 
 
13053
 
  RETURN _count;
13054
 
 
13055
 
END;
13056
 
$_$;
13057
 
 
13058
 
 
13059
 
ALTER FUNCTION public.addrusecount(integer) OWNER TO admin;
13060
 
 
13061
 
--
13062
 
--
13063
 
 
13064
 
CREATE FUNCTION addtaxtoglseries(integer, text, text, text, integer, date, date, text, integer, text) RETURNS numeric
13065
 
    LANGUAGE plpgsql
13066
 
    AS $_$
13067
 
DECLARE
13068
 
  pSequence     ALIAS FOR $1;
13069
 
  pSource       ALIAS FOR $2;
13070
 
  pDocType      ALIAS FOR $3;
13071
 
  pDocNumber    ALIAS FOR $4;
13072
 
  pCurrId     ALIAS FOR $5;
13073
 
  pExchDate     ALIAS FOR $6;
13074
 
  pDistDate     ALIAS FOR $7;
13075
 
  pTableName    ALIAS FOR $8;
13076
 
  pParentId     ALIAS FOR $9;
13077
 
  pNotes        ALIAS FOR $10;
13078
 
 
13079
 
  _count        INTEGER := 0;
13080
 
  _baseTax      NUMERIC := 0;
13081
 
  _returnVal    NUMERIC := 0;
13082
 
  _t            RECORD;
13083
 
  _test INTEGER := 0;
13084
 
 
13085
 
BEGIN
13086
 
 
13087
 
 
13088
 
  FOR _t IN SELECT *
13089
 
            FROM taxhist JOIN tax ON (tax_id = taxhist_tax_id)
13090
 
                         JOIN pg_class ON (pg_class.oid = taxhist.tableoid)
13091
 
            WHERE ( (taxhist_parent_id = pParentId)
13092
 
              AND   (relname = pTableName) ) LOOP
13093
 
 
13094
 
    _count := _count + 1;
13095
 
    _baseTax := currToBase(pCurrId, _t.taxhist_tax, pExchDate);
13096
 
    _returnVal := _returnVal + _baseTax;
13097
 
    PERFORM insertIntoGLSeries( pSequence, pSource, pDocType, pDocNumber,
13098
 
                                _t.tax_sales_accnt_id, _baseTax,
13099
 
                                pDistDate, pNotes );
13100
 
                                
13101
 
    UPDATE taxhist SET 
13102
 
      taxhist_docdate=pExchDate,
13103
 
      taxhist_distdate=pDistDate,
13104
 
      taxhist_curr_id=pCurrId,
13105
 
      taxhist_curr_rate=curr_rate
13106
 
    FROM curr_rate
13107
 
    WHERE ((taxhist_id=_t.taxhist_id)
13108
 
      AND (pCurrId=curr_id)
13109
 
      AND ( pExchDate BETWEEN curr_effective 
13110
 
                          AND curr_expires) );
13111
 
 
13112
 
  END LOOP;
13113
 
 
13114
 
  RETURN _returnVal;
13115
 
END;
13116
 
$_$;
13117
 
 
13118
 
 
13119
 
ALTER FUNCTION public.addtaxtoglseries(integer, text, text, text, integer, date, date, text, integer, text) OWNER TO admin;
13120
 
 
13121
 
--
13122
 
--
13123
 
 
13124
 
CREATE FUNCTION addtopackinglistbatch(integer) RETURNS integer
13125
 
    LANGUAGE plpgsql
13126
 
    AS $_$
13127
 
DECLARE
13128
 
  pSoheadid     ALIAS FOR $1;
13129
 
  returnVal     INTEGER;
13130
 
BEGIN
13131
 
 
13132
 
  -- MIN because error codes are negative
13133
 
  SELECT MIN(addToPackingListBatch('SO', pSoheadid, shiphead_id)) INTO returnVal
13134
 
  FROM shiphead
13135
 
  WHERE ((shiphead_order_id=pSoheadid)
13136
 
    AND  (NOT shiphead_shipped)
13137
 
    AND  (shiphead_order_type='SO'));
13138
 
  IF (NOT FOUND OR returnVal IS NULL) THEN
13139
 
    returnVal := addToPackingListBatch('SO', pSoheadid, NULL);
13140
 
  END IF;
13141
 
 
13142
 
  RETURN returnVal;
13143
 
END;
13144
 
$_$;
13145
 
 
13146
 
 
13147
 
ALTER FUNCTION public.addtopackinglistbatch(integer) OWNER TO admin;
13148
 
 
13149
 
--
13150
 
--
13151
 
 
13152
 
CREATE FUNCTION addtopackinglistbatch(integer, integer) RETURNS integer
13153
 
    LANGUAGE plpgsql
13154
 
    AS $_$
13155
 
BEGIN
13156
 
  RETURN addToPackingListBatch('SO', $1, $2);
13157
 
END;
13158
 
$_$;
13159
 
 
13160
 
 
13161
 
ALTER FUNCTION public.addtopackinglistbatch(integer, integer) OWNER TO admin;
13162
 
 
13163
 
--
13164
 
--
13165
 
 
13166
 
CREATE FUNCTION addtopackinglistbatch(text, integer) RETURNS integer
13167
 
    LANGUAGE plpgsql
13168
 
    AS $_$
13169
 
DECLARE
13170
 
  pheadtype     ALIAS FOR $1;
13171
 
  pheadid       ALIAS FOR $2;
13172
 
  returnVal     INTEGER;
13173
 
BEGIN
13174
 
  -- MIN because error codes are negative
13175
 
  SELECT MIN(addToPackingListBatch(pheadtype, pheadid, shiphead_id)) INTO returnVal
13176
 
  FROM shiphead
13177
 
  WHERE ((shiphead_order_id=pheadid)
13178
 
    AND  (NOT shiphead_shipped)
13179
 
    AND  (shiphead_order_type=pheadtype));
13180
 
 
13181
 
  IF (NOT FOUND OR returnVal IS NULL) THEN
13182
 
    returnVal := addToPackingListBatch(pheadtype, pheadid, NULL);
13183
 
  END IF;
13184
 
 
13185
 
  RETURN returnVal;
13186
 
END;
13187
 
$_$;
13188
 
 
13189
 
 
13190
 
ALTER FUNCTION public.addtopackinglistbatch(text, integer) OWNER TO admin;
13191
 
 
13192
 
--
13193
 
--
13194
 
 
13195
 
CREATE FUNCTION addtopackinglistbatch(text, integer, integer) RETURNS integer
13196
 
    LANGUAGE plpgsql
13197
 
    AS $_$
13198
 
DECLARE
13199
 
  pheadtype     ALIAS FOR $1;
13200
 
  pheadid       ALIAS FOR $2;
13201
 
  pshipheadid   ALIAS FOR $3;
13202
 
  _check INTEGER;
13203
 
 
13204
 
BEGIN
13205
 
  SELECT pack_id INTO _check
13206
 
  FROM pack
13207
 
  WHERE ((pack_head_id=pheadid)
13208
 
    AND  ((pack_shiphead_id=pshipheadid) OR 
13209
 
          (pshipheadid IS NULL AND pack_shiphead_id IS NULL))
13210
 
    AND  (pack_head_type=pheadtype)
13211
 
        );
13212
 
 
13213
 
  IF (NOT FOUND) THEN
13214
 
    INSERT INTO pack
13215
 
    ( pack_head_type, pack_head_id, pack_shiphead_id, pack_printed )
13216
 
    VALUES
13217
 
    ( pheadtype, pheadid, pshipheadid, FALSE );
13218
 
    -- Auto Firm Sales Orders conditionally based on metric
13219
 
    IF ( (pheadtype = 'SO') AND (fetchMetricBool('FirmSalesOrderPackingList')) ) THEN
13220
 
      UPDATE coitem SET coitem_firm=TRUE
13221
 
      WHERE (coitem_cohead_id=pheadid);
13222
 
    END IF; 
13223
 
  END IF;
13224
 
 
13225
 
  RETURN pheadid;
13226
 
 
13227
 
END;
13228
 
$_$;
13229
 
 
13230
 
 
13231
 
ALTER FUNCTION public.addtopackinglistbatch(text, integer, integer) OWNER TO admin;
13232
 
 
13233
 
--
13234
 
--
13235
 
 
13236
 
CREATE FUNCTION addtopackinglistbatch(integer, text, integer) RETURNS integer
13237
 
    LANGUAGE plpgsql
13238
 
    AS $_$
13239
 
DECLARE
13240
 
  pwarehousid   ALIAS FOR $1;
13241
 
  pheadtype     ALIAS FOR $2;
13242
 
  pheadid       ALIAS FOR $3;
13243
 
  returnVal     INTEGER;
13244
 
BEGIN
13245
 
  -- MIN because error codes are negative
13246
 
  SELECT MIN(addToPackingListBatch(pheadtype, pheadid,
13247
 
                                   getOpenShipmentId(pheadtype, pheadid, pwarehousid))) INTO returnVal;
13248
 
 
13249
 
  IF (NOT FOUND OR returnVal IS NULL) THEN
13250
 
    returnVal := addToPackingListBatch(pheadtype, pheadid, NULL);
13251
 
  END IF;
13252
 
 
13253
 
  RETURN returnVal;
13254
 
END;
13255
 
$_$;
13256
 
 
13257
 
 
13258
 
ALTER FUNCTION public.addtopackinglistbatch(integer, text, integer) OWNER TO admin;
13259
 
 
13260
 
--
13261
 
--
13262
 
 
13263
 
CREATE FUNCTION adjustinvvalue(integer, numeric, integer) RETURNS integer
13264
 
    LANGUAGE plpgsql
13265
 
    AS $_$
13266
 
DECLARE
13267
 
  pItemsiteid     ALIAS FOR $1;
13268
 
  pNewValue       ALIAS FOR $2;
13269
 
  pAccountid      ALIAS FOR $3;
13270
 
  _delta          NUMERIC;
13271
 
  _glreturn       INTEGER;
13272
 
  _invhistid      INTEGER;
13273
 
  _itemlocSeries  INTEGER;
13274
 
 
13275
 
BEGIN
13276
 
 
13277
 
  SELECT pNewValue - itemsite_value INTO _delta
13278
 
  FROM itemsite
13279
 
  WHERE (itemsite_id=pItemsiteid)
13280
 
  FOR UPDATE;
13281
 
 
13282
 
  IF (NOT FOUND) THEN
13283
 
    RETURN -1;
13284
 
  END IF;
13285
 
 
13286
 
  SELECT insertGLTransaction('I/M', '', 'Post Value',
13287
 
         'Inventory Value Adjustment for ' || item_number,
13288
 
         COALESCE (pAccountid, costcat_adjustment_accnt_id),
13289
 
         costcat_asset_accnt_id, -1,
13290
 
         _delta, CURRENT_DATE) INTO _glreturn
13291
 
  FROM itemsite
13292
 
   JOIN costcat ON (itemsite_costcat_id=costcat_id)
13293
 
   JOIN item ON (itemsite_item_id=item_id)
13294
 
  WHERE (itemsite_id=pItemsiteid);
13295
 
 
13296
 
  INSERT INTO invhist
13297
 
   ( invhist_itemsite_id,
13298
 
     invhist_transdate, invhist_transtype, invhist_invqty,
13299
 
     invhist_qoh_before, invhist_qoh_after,
13300
 
     invhist_docnumber, invhist_comments,
13301
 
     invhist_invuom, invhist_unitcost, invhist_hasdetail,
13302
 
     invhist_costmethod, invhist_value_before, invhist_value_after,
13303
 
     invhist_series )
13304
 
  SELECT itemsite_id,
13305
 
         CURRENT_TIMESTAMP, 'AD', 0.0,
13306
 
         itemsite_qtyonhand, itemsite_qtyonhand,
13307
 
         '', 'Inventory Value Adjustment',
13308
 
         uom_name, _delta, FALSE,
13309
 
         itemsite_costmethod, itemsite_value, pNewValue,
13310
 
         0
13311
 
  FROM itemsite, item, uom
13312
 
  WHERE ( (itemsite_item_id=item_id)
13313
 
   AND (item_inv_uom_id=uom_id)
13314
 
   AND (itemsite_id=pItemsiteid) );
13315
 
 
13316
 
  UPDATE itemsite SET itemsite_value=pNewValue
13317
 
  WHERE (itemsite_id=pItemsiteid);
13318
 
 
13319
 
  RETURN 0;
13320
 
 
13321
 
END;
13322
 
$_$;
13323
 
 
13324
 
 
13325
 
ALTER FUNCTION public.adjustinvvalue(integer, numeric, integer) OWNER TO admin;
13326
 
 
13327
 
--
13328
 
--
13329
 
 
13330
 
CREATE FUNCTION adjustments(text) RETURNS boolean
13331
 
    LANGUAGE plpgsql
13332
 
    AS $_$
13333
 
DECLARE
13334
 
  pTransType ALIAS FOR $1;
13335
 
 
13336
 
BEGIN
13337
 
  IF (pTransType IN ('CC', 'AD')) THEN
13338
 
    RETURN TRUE;
13339
 
  ELSE
13340
 
    RETURN FALSE;
13341
 
  END IF;
13342
 
 
13343
 
END;
13344
 
$_$;
13345
 
 
13346
 
 
13347
 
ALTER FUNCTION public.adjustments(text) OWNER TO admin;
13348
 
 
13349
 
--
13350
 
--
13351
 
 
13352
 
CREATE FUNCTION allocatedforso(integer, date) RETURNS numeric
13353
 
    LANGUAGE plpgsql STABLE
13354
 
    AS $_$
13355
 
DECLARE
13356
 
  pItemsiteid ALIAS FOR $1;
13357
 
  pDate ALIAS FOR $2;
13358
 
 
13359
 
BEGIN
13360
 
 
13361
 
  RETURN allocatedForSo(pItemsiteid, startOfTime(), pDate);
13362
 
 
13363
 
END;
13364
 
$_$;
13365
 
 
13366
 
 
13367
 
ALTER FUNCTION public.allocatedforso(integer, date) OWNER TO admin;
13368
 
 
13369
 
--
13370
 
--
13371
 
 
13372
 
CREATE FUNCTION allocatedforso(integer, integer) RETURNS numeric
13373
 
    LANGUAGE plpgsql STABLE
13374
 
    AS $_$
13375
 
DECLARE
13376
 
  pItemsiteid ALIAS FOR $1;
13377
 
  pDate ALIAS FOR $2;
13378
 
 
13379
 
BEGIN
13380
 
 
13381
 
  RETURN allocatedForSo(pItemsiteid, startOfTime(), (CURRENT_DATE + pDate));
13382
 
 
13383
 
END;
13384
 
$_$;
13385
 
 
13386
 
 
13387
 
ALTER FUNCTION public.allocatedforso(integer, integer) OWNER TO admin;
13388
 
 
13389
 
--
13390
 
--
13391
 
 
13392
 
CREATE FUNCTION allocatedforso(integer, date, date) RETURNS numeric
13393
 
    LANGUAGE plpgsql STABLE
13394
 
    AS $_$
13395
 
DECLARE
13396
 
  pItemsiteid ALIAS FOR $1;
13397
 
  pStartDate ALIAS FOR $2;
13398
 
  pEndDate ALIAS FOR $3;
13399
 
  _qty NUMERIC;
13400
 
 
13401
 
BEGIN
13402
 
 
13403
 
  SELECT COALESCE(SUM(noNeg(itemuomtouom(itemsite_item_id, coitem_qty_uom_id, NULL, coitem_qtyord - (coitem_qtyshipped + qtyAtShipping(coitem_id)) + coitem_qtyreturned))), 0.0) INTO _qty
13404
 
  FROM coitem, itemsite, item
13405
 
  WHERE ( (coitem_itemsite_id=itemsite_id)
13406
 
    AND (itemsite_item_id=item_id)
13407
 
    AND (coitem_status='O')
13408
 
    AND (coitem_itemsite_id=pItemsiteid)
13409
 
    AND (coitem_scheddate BETWEEN pStartDate AND pEndDate) );
13410
 
 
13411
 
  RETURN _qty;
13412
 
 
13413
 
END;
13414
 
$_$;
13415
 
 
13416
 
 
13417
 
ALTER FUNCTION public.allocatedforso(integer, date, date) OWNER TO admin;
13418
 
 
13419
 
--
13420
 
--
13421
 
 
13422
 
CREATE FUNCTION allocatedforwo(integer, date) RETURNS numeric
13423
 
    LANGUAGE plpgsql STABLE
13424
 
    AS $_$
13425
 
DECLARE
13426
 
  pItemsiteid ALIAS FOR $1;
13427
 
  pDate ALIAS FOR $2;
13428
 
 
13429
 
BEGIN
13430
 
 
13431
 
  RETURN allocatedForWo(pItemsiteid, startOfTime(), pDate);
13432
 
 
13433
 
END;
13434
 
$_$;
13435
 
 
13436
 
 
13437
 
ALTER FUNCTION public.allocatedforwo(integer, date) OWNER TO admin;
13438
 
 
13439
 
--
13440
 
--
13441
 
 
13442
 
CREATE FUNCTION allocatedforwo(integer, integer) RETURNS numeric
13443
 
    LANGUAGE plpgsql STABLE
13444
 
    AS $_$
13445
 
DECLARE
13446
 
  pItemsiteid ALIAS FOR $1;
13447
 
  pLookAheadDays ALIAS FOR $2;
13448
 
 
13449
 
BEGIN
13450
 
 
13451
 
  RETURN allocatedForWo(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookaheadDays));
13452
 
 
13453
 
END;
13454
 
$_$;
13455
 
 
13456
 
 
13457
 
ALTER FUNCTION public.allocatedforwo(integer, integer) OWNER TO admin;
13458
 
 
13459
 
--
13460
 
--
13461
 
 
13462
 
CREATE FUNCTION allocatedforwo(integer, date, date) RETURNS numeric
13463
 
    LANGUAGE plpgsql STABLE
13464
 
    AS $_$
13465
 
DECLARE
13466
 
  pItemsiteid ALIAS FOR $1;
13467
 
  pStartDate ALIAS FOR $2;
13468
 
  pEndDate ALIAS FOR $3;
13469
 
  _itemtype TEXT;
13470
 
  _qty NUMERIC;
13471
 
 
13472
 
BEGIN
13473
 
 
13474
 
  SELECT item_type INTO _itemtype
13475
 
  FROM itemsite JOIN item ON (item_id=itemsite_item_id)
13476
 
  WHERE (itemsite_id=pItemsiteid);
13477
 
 
13478
 
  IF (_itemtype != 'T') THEN
13479
 
    SELECT
13480
 
      COALESCE(SUM(noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq - womatl_qtyiss))), 0.0) INTO _qty
13481
 
    FROM womatl JOIN wo ON (wo_id=womatl_wo_id AND wo_status IN ('E','I','R'))
13482
 
                JOIN itemsite ON (itemsite_id=womatl_itemsite_id)
13483
 
    WHERE (womatl_itemsite_id=pItemsiteid)
13484
 
      AND (womatl_duedate BETWEEN pStartDate AND pEndDate);
13485
 
  ELSE
13486
 
    SELECT
13487
 
      COALESCE(SUM(noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq))), 0.0)  -
13488
 
        (
13489
 
                SELECT COALESCE(SUM(invhist_invqty),0) 
13490
 
                FROM itemsite, item, wo, womatl
13491
 
                        LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)
13492
 
                        LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id)
13493
 
                            AND (invhist_invqty > 0))
13494
 
                WHERE ( (womatl_itemsite_id=pItemsiteid)
13495
 
                AND (womatl_itemsite_id=itemsite_id)
13496
 
                AND (itemsite_item_id=item_id)
13497
 
                AND (womatl_duedate BETWEEN pStartDate AND pEndDate) 
13498
 
                AND (wo_id=womatl_wo_id)
13499
 
                AND (wo_status IN ('E','I','R')) )
13500
 
        ) INTO _qty
13501
 
    FROM womatl JOIN wo ON (wo_id=womatl_wo_id AND wo_status IN ('E','I','R'))
13502
 
                JOIN itemsite ON (itemsite_id=womatl_itemsite_id)
13503
 
    WHERE (womatl_itemsite_id=pItemsiteid)
13504
 
      AND (womatl_duedate BETWEEN pStartDate AND pEndDate);
13505
 
  END IF;
13506
 
 
13507
 
  RETURN COALESCE(_qty,0);
13508
 
 
13509
 
END;
13510
 
$_$;
13511
 
 
13512
 
 
13513
 
ALTER FUNCTION public.allocatedforwo(integer, date, date) OWNER TO admin;
13514
 
 
13515
 
--
13516
 
--
13517
 
 
13518
 
CREATE FUNCTION alterencrypt(text, text) RETURNS integer
13519
 
    LANGUAGE plpgsql
13520
 
    AS $_$
13521
 
DECLARE
13522
 
  pOldKey ALIAS FOR $1;
13523
 
  pNewKey ALIAS FOR $2;
13524
 
  _cc RECORD;
13525
 
  _ccaud RECORD;
13526
 
  _metricenc RECORD;
13527
 
  num_updated INTEGER;
13528
 
 
13529
 
BEGIN
13530
 
 
13531
 
  num_updated := 0;
13532
 
 
13533
 
 
13534
 
  FOR _cc IN SELECT ccard_id, 
13535
 
             decrypt(setbytea(ccard_name), setbytea(pOldKey), 'bf') AS ccard_name,
13536
 
             decrypt(setbytea(ccard_address1), setbytea(pOldKey), 'bf') AS ccard_address1,
13537
 
             decrypt(setbytea(ccard_address2), setbytea(pOldKey), 'bf') AS ccard_address2,
13538
 
             decrypt(setbytea(ccard_city), setbytea(pOldKey), 'bf') AS ccard_city,
13539
 
             decrypt(setbytea(ccard_state), setbytea(pOldKey), 'bf') AS ccard_state,
13540
 
             decrypt(setbytea(ccard_zip), setbytea(pOldKey), 'bf') AS ccard_zip,
13541
 
             decrypt(setbytea(ccard_country), setbytea(pOldKey), 'bf') AS ccard_country,
13542
 
             decrypt(setbytea(ccard_number), setbytea(pOldKey), 'bf') AS ccard_number,
13543
 
             decrypt(setbytea(ccard_month_expired), setbytea(pOldKey), 'bf') AS ccard_month_expired,
13544
 
             decrypt(setbytea(ccard_year_expired), setbytea(pOldKey), 'bf') AS ccard_year_expired
13545
 
      FROM ccard LOOP
13546
 
 
13547
 
      UPDATE ccard
13548
 
             set ccard_name = encrypt(setbytea(_cc.ccard_name), setbytea(pNewKey), 'bf'),
13549
 
                 ccard_address1 = encrypt(setbytea(_cc.ccard_address1), setbytea(pNewKey), 'bf'),
13550
 
                 ccard_address2 = encrypt(setbytea(_cc.ccard_address2), setbytea(pNewKey), 'bf'),
13551
 
                 ccard_city = encrypt(setbytea(_cc.ccard_city), setbytea(pNewKey), 'bf'),
13552
 
                 ccard_state = encrypt(setbytea(_cc.ccard_state), setbytea(pNewKey), 'bf'),
13553
 
                 ccard_zip = encrypt(setbytea(_cc.ccard_zip), setbytea(pNewKey), 'bf'),
13554
 
                 ccard_country = encrypt(setbytea(_cc.ccard_country), setbytea(pNewKey), 'bf'),
13555
 
                 ccard_number = encrypt(setbytea(_cc.ccard_number), setbytea(pNewKey), 'bf'),
13556
 
                 ccard_month_expired = encrypt(setbytea(_cc.ccard_month_expired), setbytea(pNewKey), 'bf'),
13557
 
                 ccard_year_expired = encrypt(setbytea(_cc.ccard_year_expired), setbytea(pNewKey), 'bf')
13558
 
      WHERE ccard_id = _cc.ccard_id;
13559
 
 
13560
 
      num_updated := num_updated + 1;
13561
 
 
13562
 
  END LOOP;
13563
 
 
13564
 
 
13565
 
  FOR _ccaud IN SELECT ccardaud_id, 
13566
 
             decrypt(setbytea(ccardaud_ccard_name_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_name_old,
13567
 
             decrypt(setbytea(ccardaud_ccard_name_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_name_new,
13568
 
             decrypt(setbytea(ccardaud_ccard_address1_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_address1_old,
13569
 
             decrypt(setbytea(ccardaud_ccard_address1_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_address1_new,
13570
 
             decrypt(setbytea(ccardaud_ccard_address2_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_address2_old,
13571
 
             decrypt(setbytea(ccardaud_ccard_address2_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_address2_new,
13572
 
             decrypt(setbytea(ccardaud_ccard_city_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_city_old,
13573
 
             decrypt(setbytea(ccardaud_ccard_city_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_city_new,
13574
 
             decrypt(setbytea(ccardaud_ccard_state_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_state_old,
13575
 
             decrypt(setbytea(ccardaud_ccard_state_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_state_new,
13576
 
             decrypt(setbytea(ccardaud_ccard_zip_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_zip_old,
13577
 
             decrypt(setbytea(ccardaud_ccard_zip_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_zip_new,
13578
 
             decrypt(setbytea(ccardaud_ccard_country_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_country_old,
13579
 
             decrypt(setbytea(ccardaud_ccard_country_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_country_new,
13580
 
             decrypt(setbytea(ccardaud_ccard_number_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_number_old,
13581
 
             decrypt(setbytea(ccardaud_ccard_number_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_number_new,
13582
 
             decrypt(setbytea(ccardaud_ccard_month_expired_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_month_expired_old,
13583
 
             decrypt(setbytea(ccardaud_ccard_month_expired_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_month_expired_new,
13584
 
             decrypt(setbytea(ccardaud_ccard_year_expired_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_year_expired_old,
13585
 
             decrypt(setbytea(ccardaud_ccard_year_expired_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_year_expired_new
13586
 
      FROM ccardaud LOOP
13587
 
 
13588
 
      UPDATE ccardaud
13589
 
             set ccardaud_ccard_name_old = encrypt(setbytea(_ccaud.ccardaud_ccard_name_old), setbytea(pNewKey), 'bf'),
13590
 
                 ccardaud_ccard_name_new = encrypt(setbytea(_ccaud.ccardaud_ccard_name_new), setbytea(pNewKey), 'bf'),
13591
 
                 ccardaud_ccard_address1_old = encrypt(setbytea(_ccaud.ccardaud_ccard_address1_old), setbytea(pNewKey), 'bf'),
13592
 
                 ccardaud_ccard_address1_new = encrypt(setbytea(_ccaud.ccardaud_ccard_address1_new), setbytea(pNewKey), 'bf'),
13593
 
                 ccardaud_ccard_address2_old = encrypt(setbytea(_ccaud.ccardaud_ccard_address2_old), setbytea(pNewKey), 'bf'),
13594
 
                 ccardaud_ccard_address2_new = encrypt(setbytea(_ccaud.ccardaud_ccard_address2_new), setbytea(pNewKey), 'bf'),
13595
 
                 ccardaud_ccard_city_old = encrypt(setbytea(_ccaud.ccardaud_ccard_city_old), setbytea(pNewKey), 'bf'),
13596
 
                 ccardaud_ccard_city_new = encrypt(setbytea(_ccaud.ccardaud_ccard_city_new), setbytea(pNewKey), 'bf'),
13597
 
                 ccardaud_ccard_state_old = encrypt(setbytea(_ccaud.ccardaud_ccard_state_old), setbytea(pNewKey), 'bf'),
13598
 
                 ccardaud_ccard_state_new = encrypt(setbytea(_ccaud.ccardaud_ccard_state_new), setbytea(pNewKey), 'bf'),
13599
 
                 ccardaud_ccard_zip_old = encrypt(setbytea(_ccaud.ccardaud_ccard_zip_old), setbytea(pNewKey), 'bf'),
13600
 
                 ccardaud_ccard_zip_new = encrypt(setbytea(_ccaud.ccardaud_ccard_zip_new), setbytea(pNewKey), 'bf'),
13601
 
                 ccardaud_ccard_country_old = encrypt(setbytea(_ccaud.ccardaud_ccard_country_old), setbytea(pNewKey), 'bf'),
13602
 
                 ccardaud_ccard_country_new = encrypt(setbytea(_ccaud.ccardaud_ccard_country_new), setbytea(pNewKey), 'bf'),
13603
 
                 ccardaud_ccard_number_old = encrypt(setbytea(_ccaud.ccardaud_ccard_number_old), setbytea(pNewKey), 'bf'),
13604
 
                 ccardaud_ccard_number_new = encrypt(setbytea(_ccaud.ccardaud_ccard_number_new), setbytea(pNewKey), 'bf'),
13605
 
                 ccardaud_ccard_month_expired_old = encrypt(setbytea(_ccaud.ccardaud_ccard_month_expired_old), setbytea(pNewKey), 'bf'),
13606
 
                 ccardaud_ccard_month_expired_new = encrypt(setbytea(_ccaud.ccardaud_ccard_month_expired_new), setbytea(pNewKey), 'bf'),
13607
 
                 ccardaud_ccard_year_expired_old = encrypt(setbytea(_ccaud.ccardaud_ccard_year_expired_old), setbytea(pNewKey), 'bf'),
13608
 
                 ccardaud_ccard_year_expired_new = encrypt(setbytea(_ccaud.ccardaud_ccard_year_expired_new), setbytea(pNewKey), 'bf')
13609
 
      WHERE ccardaud_id = _ccaud.ccardaud_id;
13610
 
 
13611
 
      num_updated := num_updated + 1;
13612
 
 
13613
 
  END LOOP;
13614
 
 
13615
 
 
13616
 
  FOR _metricenc IN SELECT metricenc_id, 
13617
 
             decrypt(setbytea(metricenc_value), setbytea(pOldKey), 'bf') AS metricenc_value
13618
 
      FROM metricenc LOOP
13619
 
 
13620
 
      UPDATE metricenc
13621
 
             set metricenc_value = encrypt(setbytea(_metricenc.metricenc_value), setbytea(pNewKey), 'bf')
13622
 
      WHERE metricenc_id = _metricenc.metricenc_id;
13623
 
 
13624
 
      num_updated := num_updated + 1;
13625
 
 
13626
 
  END LOOP;
13627
 
 
13628
 
 
13629
 
  RETURN num_updated;
13630
 
 
13631
 
END;
13632
 
$_$;
13633
 
 
13634
 
 
13635
 
ALTER FUNCTION public.alterencrypt(text, text) OWNER TO admin;
13636
 
 
13637
 
--
13638
 
--
13639
 
 
13640
 
CREATE FUNCTION apaging(date, boolean) RETURNS SETOF apaging
13641
 
    LANGUAGE plpgsql
13642
 
    AS $_$
13643
 
DECLARE
13644
 
  pAsOfDate ALIAS FOR $1;
13645
 
  pUseDocDate ALIAS FOR $2;
13646
 
  _row apaging%ROWTYPE;
13647
 
  _x RECORD;
13648
 
  _returnVal INTEGER;
13649
 
  _asOfDate DATE;
13650
 
BEGIN
13651
 
 
13652
 
  _asOfDate := COALESCE(pAsOfDate,current_date);
13653
 
 
13654
 
  FOR _x IN
13655
 
        SELECT
13656
 
        --report uses currency rate snapshot to convert all amounts to base based on apopen_docdate to ensure the same exchange rate
13657
 
 
13658
 
        --today and greater base:
13659
 
        CASE WHEN((apopen.apopen_duedate >= DATE(_asOfDate)))
13660
 
        THEN (((apopen.apopen_amount - apopen.apopen_paid +
13661
 
                COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate *
13662
 
                CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS cur_val,
13663
 
 
13664
 
        --0 to 30 base
13665
 
        CASE WHEN((apopen.apopen_duedate >= DATE(_asOfDate)-30) AND (apopen.apopen_duedate < DATE(_asOfDate)))
13666
 
        THEN (((apopen.apopen_amount - apopen.apopen_paid +
13667
 
                COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate *
13668
 
                CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS thirty_val,
13669
 
 
13670
 
        --30-60 base
13671
 
        CASE WHEN((apopen.apopen_duedate >= DATE(_asOfDate)-60) AND (apopen.apopen_duedate < DATE(_asOfDate) - 30 ))
13672
 
        THEN (((apopen.apopen_amount - apopen.apopen_paid +
13673
 
                COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate *
13674
 
                CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS sixty_val,
13675
 
 
13676
 
        --60-90 base
13677
 
        CASE WHEN((apopen.apopen_duedate >= DATE(_asOfDate)-90) AND (apopen.apopen_duedate < DATE(_asOfDate) - 60))
13678
 
        THEN (((apopen.apopen_amount - apopen.apopen_paid +
13679
 
                COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate *
13680
 
                CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS ninety_val,
13681
 
 
13682
 
        --greater than 90 base:
13683
 
        CASE WHEN((apopen.apopen_duedate > DATE(_asOfDate)-10000) AND (apopen.apopen_duedate < DATE(_asOfDate) - 90))
13684
 
        THEN (((apopen.apopen_amount - apopen.apopen_paid +
13685
 
                COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate *
13686
 
                CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS plus_val,
13687
 
 
13688
 
        --total amount base:
13689
 
        CASE WHEN((apopen.apopen_duedate > DATE(_asOfDate)-10000))
13690
 
        THEN (((apopen.apopen_amount - apopen.apopen_paid +
13691
 
                COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate *
13692
 
                CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS total_val,
13693
 
 
13694
 
        --AP Open Amount base
13695
 
        CASE WHEN apopen.apopen_doctype IN ('C', 'R') 
13696
 
        THEN (apopen.apopen_amount / apopen.apopen_curr_rate * -1.0)
13697
 
        ELSE (apopen.apopen_amount / apopen.apopen_curr_rate) END AS apopen_amount,
13698
 
        
13699
 
        apopen.apopen_docdate,
13700
 
        apopen.apopen_duedate,
13701
 
        apopen.apopen_ponumber,
13702
 
        apopen.apopen_invcnumber,
13703
 
        apopen.apopen_docnumber,
13704
 
        apopen.apopen_doctype,
13705
 
        vend_id,
13706
 
        vend_name,
13707
 
        vend_number,
13708
 
        vend_vendtype_id,
13709
 
        vendtype_code,
13710
 
        terms_descrip,
13711
 
        determineDiscountDate(terms_id, apopen.apopen_docdate) AS discdate,
13712
 
        noNeg(apopen.apopen_discountable_amount *
13713
 
                     CASE WHEN (CURRENT_DATE <= determineDiscountDate(terms_id, apopen.apopen_docdate)) THEN terms_discprcnt
13714
 
                     ELSE 0.0 END) AS disc_val,
13715
 
        terms_discdays AS discdays,
13716
 
        (terms_discprcnt * 100.0) AS discprcnt
13717
 
 
13718
 
        FROM vendinfo, vendtype, apopen
13719
 
          LEFT OUTER JOIN terms ON (apopen_terms_id=terms_id)
13720
 
          LEFT OUTER JOIN apapply ON (((apopen_id=apapply_target_apopen_id)
13721
 
                                    OR (apopen_id=apapply_source_apopen_id))
13722
 
                                   AND (apapply_postdate >_asOfDate))
13723
 
          LEFT OUTER JOIN apopen target ON (target.apopen_id=apapply_target_apopen_id)
13724
 
        WHERE ( (apopen.apopen_vend_id = vend_id)
13725
 
        AND (vend_vendtype_id=vendtype_id)
13726
 
        AND (CASE WHEN (pUseDocDate) THEN apopen.apopen_docdate ELSE apopen.apopen_distdate END <= _asOfDate)
13727
 
        AND (COALESCE(apopen.apopen_closedate,_asOfDate+1)>_asOfDate) )
13728
 
        GROUP BY apopen.apopen_id,apopen.apopen_docdate,apopen.apopen_duedate,apopen.apopen_ponumber,
13729
 
                 apopen.apopen_invcnumber,apopen.apopen_docnumber,apopen.apopen_doctype,apopen.apopen_paid,
13730
 
                 apopen.apopen_curr_id,apopen.apopen_amount,vend_id,vend_name,vend_number,vend_vendtype_id,vendtype_code,terms_descrip,
13731
 
                 apopen.apopen_curr_rate, terms_id, terms_discdays, terms_discprcnt, apopen.apopen_discountable_amount
13732
 
        ORDER BY vend_number, apopen.apopen_duedate
13733
 
  LOOP
13734
 
        _row.apaging_docdate := _x.apopen_docdate;
13735
 
        _row.apaging_duedate := _x.apopen_duedate;
13736
 
        _row.apaging_ponumber := _x.apopen_ponumber;
13737
 
        _row.apaging_invcnumber := _x.apopen_invcnumber;
13738
 
        _row.apaging_docnumber := _x.apopen_docnumber;
13739
 
        _row.apaging_doctype := _x.apopen_doctype;
13740
 
        _row.apaging_vend_id := _x.vend_id;
13741
 
        _row.apaging_vend_number := _x.vend_number;
13742
 
        _row.apaging_vend_name := _x.vend_name;
13743
 
        _row.apaging_vend_vendtype_id := _x.vend_vendtype_id;
13744
 
        _row.apaging_vendtype_code := _x.vendtype_code;
13745
 
        _row.apaging_terms_descrip := _x.terms_descrip;
13746
 
        _row.apaging_apopen_amount := _x.apopen_amount;
13747
 
        _row.apaging_cur_val := _x.cur_val;
13748
 
        _row.apaging_thirty_val := _x.thirty_val;
13749
 
        _row.apaging_sixty_val := _x.sixty_val;
13750
 
        _row.apaging_ninety_val := _x.ninety_val;
13751
 
        _row.apaging_plus_val := _x.plus_val;
13752
 
        _row.apaging_total_val := _x.total_val;
13753
 
        _row.apaging_discdate := _x.discdate;
13754
 
        _row.apaging_disc_val := _x.disc_val;
13755
 
        _row.apaging_discdays := _x.discdays;
13756
 
        _row.apaging_discprcnt := _x.discprcnt;
13757
 
        RETURN NEXT _row;
13758
 
  END LOOP;
13759
 
  RETURN;
13760
 
END;
13761
 
$_$;
13762
 
 
13763
 
 
13764
 
ALTER FUNCTION public.apaging(date, boolean) OWNER TO admin;
13765
 
 
13766
 
--
13767
 
--
13768
 
 
13769
 
CREATE FUNCTION apapplied(integer, date) RETURNS numeric
13770
 
    LANGUAGE plpgsql
13771
 
    AS $_$
13772
 
DECLARE
13773
 
  pApopenid ALIAS FOR $1;
13774
 
  pDate ALIAS FOR $2;
13775
 
  _amount NUMERIC;
13776
 
 
13777
 
BEGIN
13778
 
 
13779
 
  -- Return amount applied to an apopen in base currency as of apapply_postdate
13780
 
  SELECT SUM(currtobase(apapply_curr_id,apapply_amount,apapply_postdate)) INTO _amount
13781
 
  FROM apapply
13782
 
  WHERE (((apapply_target_apopen_id = pApopenid) OR (apapply_source_apopen_id = pApopenid))
13783
 
  AND (((apapply_journalnumber=0) AND (apapply_postdate <= pDate))
13784
 
  OR EXISTS(SELECT * 
13785
 
             FROM gltrans 
13786
 
             WHERE ((gltrans_journalnumber=apapply_journalnumber)
13787
 
             AND (gltrans_date <= pDate)))));
13788
 
 
13789
 
  IF (_amount IS NULL) THEN
13790
 
    RETURN 0;
13791
 
  ELSE
13792
 
    RETURN _amount;
13793
 
  END IF;
13794
 
 
13795
 
END;
13796
 
$_$;
13797
 
 
13798
 
 
13799
 
ALTER FUNCTION public.apapplied(integer, date) OWNER TO admin;
13800
 
 
13801
 
--
13802
 
--
13803
 
 
13804
 
CREATE FUNCTION apcheckpending(integer) RETURNS numeric
13805
 
    LANGUAGE plpgsql STABLE
13806
 
    AS $_$
13807
 
DECLARE
13808
 
  pApopenid     ALIAS FOR $1;
13809
 
  _qty NUMERIC  := 0.0;
13810
 
 
13811
 
BEGIN
13812
 
 
13813
 
  SELECT SUM(checkitem_amount + checkitem_discount) INTO _qty
13814
 
    FROM checkitem JOIN checkhead ON (checkitem_checkhead_id=checkhead_id)
13815
 
   WHERE ((checkitem_apopen_id=pApopenid)
13816
 
     AND (NOT checkhead_deleted)
13817
 
     AND (NOT checkhead_replaced)
13818
 
     AND (NOT checkhead_void)
13819
 
     AND (NOT checkhead_posted));
13820
 
 
13821
 
  RETURN COALESCE(_qty, 0.0);
13822
 
 
13823
 
END;
13824
 
$_$;
13825
 
 
13826
 
 
13827
 
ALTER FUNCTION public.apcheckpending(integer) OWNER TO admin;
13828
 
 
13829
 
--
13830
 
--
13831
 
 
13832
 
CREATE FUNCTION apcurrgain(integer, integer, numeric, date) RETURNS numeric
13833
 
    LANGUAGE plpgsql
13834
 
    AS $_$
13835
 
DECLARE
13836
 
  pApopenId ALIAS FOR $1;
13837
 
  pCurrId ALIAS FOR $2;
13838
 
  pValue ALIAS FOR $3;
13839
 
  pDate ALIAS FOR $4;
13840
 
  _start DATE;
13841
 
  _end DATE;
13842
 
  _gain NUMERIC;
13843
 
  _r RECORD;
13844
 
 
13845
 
BEGIN
13846
 
  IF (pApopenId IS NULL OR pValue = 0) THEN
13847
 
    RETURN 0;
13848
 
  END IF;
13849
 
 
13850
 
  SELECT apopen_docdate, apopen_curr_rate
13851
 
    INTO _r
13852
 
  FROM apopen
13853
 
  WHERE (apopen_id=pApopenId);
13854
 
 
13855
 
  IF (_r.apopen_docdate > pDate) THEN
13856
 
    _gain := (currToBase(pCurrId, pValue, pDate) - (pValue / _r.apopen_curr_rate)) * -1;
13857
 
  ELSE
13858
 
    _gain := (pValue / _r.apopen_curr_rate) - currToBase(pCurrId, pValue, pDate);
13859
 
  END IF;
13860
 
  
13861
 
  IF (_gain IS NULL) THEN
13862
 
    RAISE EXCEPTION 'Error processing currency gain/loss.';
13863
 
  END IF;
13864
 
 
13865
 
  RETURN _gain;
13866
 
END;
13867
 
$_$;
13868
 
 
13869
 
 
13870
 
ALTER FUNCTION public.apcurrgain(integer, integer, numeric, date) OWNER TO admin;
13871
 
 
13872
 
--
13873
 
--
13874
 
 
13875
 
CREATE FUNCTION applyapcreditmemotobalance(integer) RETURNS integer
13876
 
    LANGUAGE plpgsql
13877
 
    AS $_$
13878
 
DECLARE
13879
 
  pApopenid ALIAS FOR $1;
13880
 
  _amount NUMERIC;
13881
 
  _curr_id INTEGER;
13882
 
  _curr_rate NUMERIC;
13883
 
  _docdate DATE;
13884
 
  _applyAmount NUMERIC;
13885
 
  _r RECORD;
13886
 
  _p RECORD;
13887
 
 
13888
 
BEGIN
13889
 
 
13890
 
  SELECT (apopen_amount - apopen_paid - COALESCE(prepared,0.0) - COALESCE(selected,0.0) - COALESCE(SUM(currToCurr(apcreditapply_curr_id,
13891
 
                                                  apopen_curr_id,
13892
 
                                                  apcreditapply_amount,
13893
 
                                                  apopen_docdate)), 0)),
13894
 
          apopen_curr_id, apopen_curr_rate, apopen_docdate INTO _amount, _curr_id, _curr_rate, _docdate
13895
 
  FROM apopen 
13896
 
    LEFT OUTER JOIN apcreditapply ON (apcreditapply_source_apopen_id=apopen_id)
13897
 
    LEFT OUTER JOIN (SELECT apopen_id AS selected_apopen_id,
13898
 
                       SUM(currToCurr(apselect_curr_id, apopen_curr_id, apselect_amount + apselect_discount, apselect_date)) AS selected
13899
 
                     FROM apselect JOIN apopen ON (apselect_apopen_id=apopen_id)
13900
 
                     GROUP BY apopen_id) AS sub1 ON (apopen_id=selected_apopen_id)
13901
 
    LEFT OUTER JOIN (SELECT apopen_id AS prepared_apopen_id,
13902
 
                       SUM(checkitem_amount + checkitem_discount) AS prepared
13903
 
                     FROM checkhead 
13904
 
                       JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)
13905
 
                       JOIN apopen ON (checkitem_apopen_id=apopen_id)
13906
 
                     WHERE ((NOT checkhead_posted)
13907
 
                       AND  (NOT checkhead_void))
13908
 
                     GROUP BY apopen_id) AS sub2 ON (prepared_apopen_id=apopen_id)
13909
 
  WHERE (apopen_id=pApopenid)
13910
 
  GROUP BY apopen_amount, apopen_paid, apopen_curr_id, apopen_curr_rate, apopen_docdate, prepared, selected;
13911
 
 
13912
 
  IF (_amount < 0) THEN
13913
 
    RETURN -1;
13914
 
  END IF;
13915
 
 
13916
 
  FOR _r IN SELECT target.apopen_id AS apopenid,
13917
 
                   currToCurr(target.apopen_curr_id,source.apopen_curr_id, 
13918
 
                     target.apopen_amount - target.apopen_paid - COALESCE(prepared,0.0) - COALESCE(selected,0.0) - COALESCE(applied,0.0),
13919
 
                     current_date) AS balance
13920
 
           FROM apopen AS source, apopen AS target
13921
 
             LEFT OUTER JOIN (SELECT apcreditapply_target_apopen_id AS applied_apopen_id,
13922
 
                                     SUM(currToCurr(apcreditapply_curr_id, apopen_curr_id, apcreditapply_amount, apopen_docdate)) AS applied
13923
 
                              FROM apcreditapply JOIN apopen ON (apopen_id=apcreditapply_source_apopen_id)
13924
 
                              GROUP BY apcreditapply_target_apopen_id) AS sub3
13925
 
                              ON (target.apopen_id=applied_apopen_id)
13926
 
             LEFT OUTER JOIN (SELECT apopen_id AS selected_apopen_id,
13927
 
                                SUM(currToCurr(apselect_curr_id, apopen_curr_id, apselect_amount + apselect_discount, apselect_date)) AS selected
13928
 
                                    FROM apselect JOIN apopen ON (apselect_apopen_id=apopen_id)
13929
 
                                GROUP BY apopen_id) AS sub1
13930
 
                                ON (target.apopen_id=selected_apopen_id)
13931
 
             LEFT OUTER JOIN (SELECT apopen_id AS prepared_apopen_id,
13932
 
                                SUM(checkitem_amount + checkitem_discount) AS prepared
13933
 
                              FROM checkhead 
13934
 
                                JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)
13935
 
                                JOIN apopen ON (checkitem_apopen_id=apopen_id)
13936
 
                              WHERE ((NOT checkhead_posted)
13937
 
                               AND  (NOT checkhead_void))
13938
 
                              GROUP BY apopen_id) AS sub2 ON (prepared_apopen_id=target.apopen_id)
13939
 
            WHERE ( (source.apopen_vend_id=target.apopen_vend_id)
13940
 
             AND (target.apopen_doctype IN ('V', 'D'))
13941
 
             AND (target.apopen_open)
13942
 
             AND (source.apopen_id=pApopenid) )
13943
 
            ORDER BY target.apopen_duedate, (target.apopen_amount - target.apopen_paid) LOOP
13944
 
 
13945
 
    IF (_r.balance <= 0.0) THEN
13946
 
      CONTINUE;
13947
 
    ELSEIF (_r.balance > _amount) THEN
13948
 
      _applyAmount := _amount;
13949
 
    ELSE
13950
 
      _applyAmount := _r.balance;
13951
 
    END IF;
13952
 
 
13953
 
    SELECT apcreditapply_id, 
13954
 
              apcreditapply_amount * _curr_rate / 
13955
 
                 currRate(apcreditapply_curr_id,_docdate) AS apcreditapply_amount
13956
 
      INTO _p
13957
 
    FROM apcreditapply
13958
 
    WHERE ( (apcreditapply_target_apopen_id=_r.apopenid)
13959
 
     AND (apcreditapply_source_apopen_id=pApopenid) );
13960
 
 
13961
 
    IF (FOUND) THEN
13962
 
 
13963
 
 
13964
 
      CONTINUE;
13965
 
    ELSE
13966
 
      INSERT INTO apcreditapply
13967
 
      ( apcreditapply_source_apopen_id, apcreditapply_target_apopen_id,
13968
 
        apcreditapply_amount, apcreditapply_curr_id )
13969
 
      VALUES
13970
 
      ( pApopenid, _r.apopenid, _applyAmount, _curr_id );
13971
 
    END IF;
13972
 
 
13973
 
    _amount := (_amount - _applyAmount);
13974
 
    IF (_amount = 0) THEN
13975
 
      EXIT;
13976
 
    END IF;
13977
 
 
13978
 
  END LOOP;
13979
 
 
13980
 
  RETURN 1;
13981
 
 
13982
 
END;
13983
 
$_$;
13984
 
 
13985
 
 
13986
 
ALTER FUNCTION public.applyapcreditmemotobalance(integer) OWNER TO admin;
13987
 
 
13988
 
--
13989
 
--
13990
 
 
13991
 
CREATE FUNCTION applyapcredits(integer) RETURNS integer
13992
 
    LANGUAGE plpgsql
13993
 
    AS $_$
13994
 
DECLARE
13995
 
  pVendId   ALIAS FOR $1;
13996
 
  _result   INTEGER;
13997
 
  _apopenid INTEGER;
13998
 
  _r        RECORD;
13999
 
 
14000
 
BEGIN
14001
 
 
14002
 
  -- Fetch credit memo(s) for the vendor
14003
 
  FOR _r IN SELECT apopen_id, apopen_duedate
14004
 
            FROM apopen JOIN vendinfo ON (apopen_vend_id = vend_id)
14005
 
            WHERE ((apopen_doctype = 'C')
14006
 
               AND (apopen_status = 'O')
14007
 
               AND (vend_id = pVendId))
14008
 
            ORDER BY apopen_duedate
14009
 
  LOOP
14010
 
    -- Apply credit memo(s) according to due date
14011
 
    SELECT applyapcreditmemotobalance(_r.apopen_id) INTO _result;
14012
 
 
14013
 
    -- Post the credit memo if applied
14014
 
    IF (_result = 1) THEN
14015
 
      SELECT postapcreditmemoapplication(_r.apopen_id) INTO _apopenid;
14016
 
      IF (_apopenid < 0) THEN
14017
 
        RETURN -1;
14018
 
      END IF;
14019
 
    ELSE
14020
 
      RETURN -1;
14021
 
    END IF;
14022
 
 
14023
 
  END LOOP;
14024
 
 
14025
 
RETURN 1;
14026
 
 
14027
 
END;
14028
 
$_$;
14029
 
 
14030
 
 
14031
 
ALTER FUNCTION public.applyapcredits(integer) OWNER TO admin;
14032
 
 
14033
 
--
14034
 
--
14035
 
 
14036
 
CREATE FUNCTION applyarcreditmemotobalance(integer) RETURNS integer
14037
 
    LANGUAGE plpgsql
14038
 
    AS $_$
14039
 
DECLARE
14040
 
  pAropenid ALIAS FOR $1;
14041
 
 
14042
 
BEGIN
14043
 
 
14044
 
  RETURN applyARCreditMemoToBalance(pAropenid, NULL);
14045
 
 
14046
 
END;
14047
 
$_$;
14048
 
 
14049
 
 
14050
 
ALTER FUNCTION public.applyarcreditmemotobalance(integer) OWNER TO admin;
14051
 
 
14052
 
--
14053
 
--
14054
 
 
14055
 
CREATE FUNCTION applyarcreditmemotobalance(integer, integer) RETURNS integer
14056
 
    LANGUAGE plpgsql
14057
 
    AS $_$
14058
 
DECLARE
14059
 
  pSourceAropenid ALIAS FOR $1;
14060
 
  pTargetAropenid ALIAS FOR $2;
14061
 
  _amount NUMERIC;
14062
 
  _amountcurrid INTEGER;
14063
 
  _applyAmount NUMERIC;
14064
 
  _applycurrid  INTEGER;
14065
 
  _curr_rate NUMERIC;
14066
 
  _r RECORD;
14067
 
  _p RECORD;
14068
 
 
14069
 
BEGIN
14070
 
 
14071
 
  SELECT (aropen_amount - COALESCE(SUM(currToCurr(arcreditapply_curr_id,
14072
 
                                                  aropen_curr_id,
14073
 
                                                  arcreditapply_amount,
14074
 
                                                  aropen_docdate)), 0) - aropen_paid - COALESCE(prepared,0.0) - COALESCE(cashapplied,0.0)),
14075
 
         aropen_curr_id, aropen_curr_rate INTO _amount, _amountcurrid, _curr_rate
14076
 
  FROM aropen LEFT OUTER JOIN arcreditapply ON (arcreditapply_source_aropen_id=aropen_id)
14077
 
              LEFT OUTER JOIN (SELECT aropen_id AS prepared_aropen_id,
14078
 
                                SUM(checkitem_amount + checkitem_discount) AS prepared
14079
 
                               FROM checkhead JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)
14080
 
                                              JOIN aropen ON (checkitem_aropen_id=aropen_id)
14081
 
                               WHERE ((NOT checkhead_posted)
14082
 
                                AND  (NOT checkhead_void))
14083
 
                               GROUP BY aropen_id) AS sub1
14084
 
                      ON (prepared_aropen_id=aropen_id)
14085
 
             LEFT OUTER JOIN (SELECT aropen_id AS cash_aropen_id,
14086
 
                                     SUM(cashrcptitem_amount + cashrcptitem_discount) * -1.0 AS cashapplied
14087
 
                                FROM cashrcpt JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id)
14088
 
                                              JOIN aropen ON (cashrcptitem_aropen_id=aropen_id)
14089
 
                               WHERE (NOT cashrcpt_posted) AND (NOT cashrcpt_void)
14090
 
                               GROUP BY aropen_id ) AS sub2
14091
 
                      ON (cash_aropen_id=aropen_id)
14092
 
  WHERE (aropen_id=pSourceAropenid)
14093
 
  GROUP BY aropen_amount, aropen_paid, aropen_curr_id, aropen_curr_rate, prepared, cashapplied;
14094
 
 
14095
 
  IF (_amount < 0) THEN
14096
 
    RETURN -1;
14097
 
  END IF;
14098
 
 
14099
 
  FOR _r IN SELECT target.aropen_id AS aropenid,
14100
 
                   currToCurr(target.aropen_curr_id,source.aropen_curr_id,
14101
 
                              (target.aropen_amount - target.aropen_paid - calcpendingarapplications(target.aropen_id)),
14102
 
                              current_date) AS balance,
14103
 
                   target.aropen_curr_id AS curr_id,
14104
 
                   target.aropen_docdate AS docdate
14105
 
            FROM aropen AS target, aropen AS source
14106
 
            WHERE ( (source.aropen_cust_id=target.aropen_cust_id)
14107
 
             AND (target.aropen_doctype IN ('D', 'I'))
14108
 
             AND (target.aropen_open)
14109
 
             AND (source.aropen_id=pSourceAropenid)
14110
 
             AND ((pTargetAropenid IS NULL) OR (target.aropen_id=pTargetAropenid)) )
14111
 
            ORDER BY target.aropen_duedate, target.aropen_docnumber LOOP
14112
 
 
14113
 
    IF (_r.balance > _amount) THEN
14114
 
      _applyAmount := _amount;
14115
 
    ELSE
14116
 
      _applyAmount := _r.balance;
14117
 
    END IF;
14118
 
    _applycurrid := _amountcurrid;
14119
 
 
14120
 
    SELECT arcreditapply_id,
14121
 
           arcreditapply_amount,
14122
 
           arcreditapply_amount * _curr_rate / 
14123
 
                 currRate(arcreditapply_curr_id,_r.docdate) AS
14124
 
                      arcreditapply_amount_applycurr INTO _p
14125
 
    FROM arcreditapply
14126
 
    WHERE ( (arcreditapply_target_aropen_id=_r.aropenid)
14127
 
     AND (arcreditapply_source_aropen_id=pSourceAropenid) );
14128
 
 
14129
 
    IF (FOUND) THEN
14130
 
      _applyAmount := (_applyAmount - _p.arcreditapply_amount_applycurr);
14131
 
      IF (_applyAmount < 0) THEN
14132
 
        _applyAmount := 0;
14133
 
      END IF;
14134
 
 
14135
 
      UPDATE arcreditapply
14136
 
      SET arcreditapply_amount = (arcreditapply_amount + 
14137
 
          _applyAmount *  currRate(arcreditapply_curr_id,_r.docdate) / _curr_rate)
14138
 
      WHERE (arcreditapply_id=_p.arcreditapply_id);
14139
 
 
14140
 
    ELSE
14141
 
      INSERT INTO arcreditapply
14142
 
      ( arcreditapply_source_aropen_id, arcreditapply_target_aropen_id,
14143
 
        arcreditapply_amount, arcreditapply_curr_id )
14144
 
      VALUES
14145
 
      ( pSourceAropenid, _r.aropenid, _applyAmount, _applycurrid );
14146
 
    END IF;
14147
 
 
14148
 
    _amount := _amount - currToCurr(_applycurrid, _amountcurrid, _applyAmount, _r.docdate);
14149
 
    IF (_amount = 0) THEN
14150
 
      EXIT;
14151
 
    END IF;
14152
 
 
14153
 
  END LOOP;
14154
 
 
14155
 
  RETURN 1;
14156
 
 
14157
 
END;
14158
 
$_$;
14159
 
 
14160
 
 
14161
 
ALTER FUNCTION public.applyarcreditmemotobalance(integer, integer) OWNER TO admin;
14162
 
 
14163
 
--
14164
 
--
14165
 
 
14166
 
CREATE FUNCTION applycashreceiptlinebalance(integer, integer, numeric, integer) RETURNS numeric
14167
 
    LANGUAGE plpgsql
14168
 
    AS $_$
14169
 
DECLARE
14170
 
  pCashrcptId ALIAS FOR $1;
14171
 
  pAropenid ALIAS FOR $2;
14172
 
  pAmount ALIAS FOR $3;
14173
 
  pCurrId ALIAS FOR $4;
14174
 
  _balance NUMERIC;
14175
 
  _amount NUMERIC;
14176
 
  _applyAmount NUMERIC := 0;
14177
 
  _discount NUMERIC := 0;
14178
 
  _discprct NUMERIC;
14179
 
  _docDate DATE;
14180
 
  _r RECORD;
14181
 
  _doctype CHAR(1);
14182
 
 
14183
 
BEGIN
14184
 
 
14185
 
 
14186
 
  DELETE FROM cashrcptitem WHERE ((cashrcptitem_cashrcpt_id=pCashrcptId) AND (cashrcptitem_aropen_id=pAropenId));
14187
 
 
14188
 
  SELECT (pAmount - (COALESCE(SUM(cashrcptitem_amount), 0) ) ),
14189
 
    COALESCE(cashrcpt_docdate, current_date)
14190
 
    INTO _amount, _docDate
14191
 
  FROM cashrcpt LEFT OUTER JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id = cashrcpt_id)
14192
 
  WHERE (cashrcpt_id=pCashrcptid)
14193
 
  GROUP BY cashrcpt_curr_id, cashrcpt_distdate, cashrcpt_docdate;
14194
 
 
14195
 
  SELECT (_amount - COALESCE(SUM(cashrcptmisc_amount), 0)) INTO _amount
14196
 
  FROM cashrcptmisc
14197
 
  WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid);
14198
 
 
14199
 
  SELECT aropen_doctype INTO _doctype
14200
 
  FROM aropen
14201
 
  WHERE (aropen_id=pAropenId);
14202
 
  
14203
 
  RAISE DEBUG 'Amount (%) DocType (%)', _amount, _doctype;
14204
 
 
14205
 
  IF (_amount <= 0 AND _doctype IN ('I','D')) THEN
14206
 
    RETURN 0;
14207
 
  END IF;
14208
 
 
14209
 
  SELECT currToCurr(aropen_curr_id, cashrcpt_curr_id,
14210
 
         aropen_amount - aropen_paid, cashrcpt_distdate) -
14211
 
         COALESCE((SELECT (SUM(cashrcptitem_amount) + SUM(cashrcptitem_discount))
14212
 
                   FROM cashrcptitem, cashrcpt
14213
 
                   WHERE ((cashrcpt_id=cashrcptitem_cashrcpt_id)
14214
 
                     AND  (NOT cashrcpt_void)
14215
 
                     AND  (NOT cashrcpt_posted)
14216
 
                     AND  (cashrcpt_id != pCashrcptId)
14217
 
                     AND  (cashrcptitem_aropen_id=pAropenId))), 0)
14218
 
         INTO _balance
14219
 
         FROM aropen, cashrcpt
14220
 
           WHERE ((aropen_id=pAropenId)
14221
 
           AND (cashrcpt_id=pCashrcptId));
14222
 
 
14223
 
  RAISE DEBUG 'Balance (%)', _balance;
14224
 
            
14225
 
  IF (_doctype IN ('I','D')) THEN
14226
 
    SELECT  round(noNeg(_balance * 
14227
 
            CASE WHEN (_docDate <= determineDiscountDate(terms_id, aropen_docdate)) THEN COALESCE(terms_discprcnt, 0.0) 
14228
 
            ELSE 0.00 END - applied),2),
14229
 
            CASE WHEN (_docDate <= determineDiscountDate(terms_id, aropen_docdate)) THEN COALESCE(terms_discprcnt, 0.0) 
14230
 
            ELSE 0.00 END INTO _discount, _discprct
14231
 
    FROM aropen LEFT OUTER JOIN terms ON (terms_id=aropen_terms_id), 
14232
 
         (SELECT COALESCE(SUM(arapply_applied), 0.00) AS applied  
14233
 
          FROM arapply, aropen 
14234
 
          WHERE ((arapply_target_aropen_id=pAropenId) 
14235
 
           AND (arapply_source_aropen_id=pAropenId) 
14236
 
           AND  (aropen_discount) )
14237
 
             ) AS data 
14238
 
    WHERE (aropen_id=pAropenId);
14239
 
 
14240
 
    IF (_balance <= _amount + _discount) THEN
14241
 
      _applyAmount := _balance - _discount;
14242
 
    ELSE
14243
 
      _discount := round((_amount / (1 - _discprct)) - _amount, 2);
14244
 
      _applyAmount := _amount;
14245
 
    END IF;
14246
 
  ELSIF (_doctype IN ('C', 'R')) THEN
14247
 
  -- Handle Credits, discounts don't apply here
14248
 
    _applyAmount := _balance * -1;
14249
 
  ELSE
14250
 
    _applyAmount := _amount;
14251
 
  END IF;
14252
 
 
14253
 
  IF (_applyAmount != 0) THEN
14254
 
      INSERT INTO cashrcptitem
14255
 
      ( cashrcptitem_aropen_id, cashrcptitem_cashrcpt_id,
14256
 
        cashrcptitem_amount,cashrcptitem_discount )
14257
 
      VALUES
14258
 
      ( pAropenid, pCashrcptid, round(_applyAmount, 2), round(_discount, 2) );
14259
 
  END IF;
14260
 
 
14261
 
  RETURN abs(_applyAmount);
14262
 
 
14263
 
END;
14264
 
$_$;
14265
 
 
14266
 
 
14267
 
ALTER FUNCTION public.applycashreceiptlinebalance(integer, integer, numeric, integer) OWNER TO admin;
14268
 
 
14269
 
--
14270
 
--
14271
 
 
14272
 
CREATE FUNCTION applycashreceipttobalance(integer, numeric) RETURNS integer
14273
 
    LANGUAGE plpgsql
14274
 
    AS $_$
14275
 
DECLARE
14276
 
  pCashrcptid ALIAS FOR $1;
14277
 
  pAmount ALIAS FOR $2;
14278
 
 
14279
 
BEGIN
14280
 
  RETURN applyCashReceiptToBalance(pCashrcptid, pAmount, baseCurrId() );
14281
 
END;
14282
 
$_$;
14283
 
 
14284
 
 
14285
 
ALTER FUNCTION public.applycashreceipttobalance(integer, numeric) OWNER TO admin;
14286
 
 
14287
 
--
14288
 
--
14289
 
 
14290
 
CREATE FUNCTION applycashreceipttobalance(integer, numeric, integer) RETURNS integer
14291
 
    LANGUAGE plpgsql
14292
 
    AS $_$
14293
 
DECLARE
14294
 
  pCashrcptid ALIAS FOR $1;
14295
 
  pAmount ALIAS FOR $2;
14296
 
  pCurrId ALIAS FOR $3;
14297
 
 
14298
 
BEGIN
14299
 
 
14300
 
  RETURN applyCashReceiptToBalance(pCashrcptid, pAmount, pCurrId, false);
14301
 
 
14302
 
END;
14303
 
$_$;
14304
 
 
14305
 
 
14306
 
ALTER FUNCTION public.applycashreceipttobalance(integer, numeric, integer) OWNER TO admin;
14307
 
 
14308
 
--
14309
 
--
14310
 
 
14311
 
CREATE FUNCTION applycashreceipttobalance(integer, numeric, integer, boolean) RETURNS integer
14312
 
    LANGUAGE plpgsql
14313
 
    AS $_$
14314
 
DECLARE
14315
 
  pCashrcptid ALIAS FOR $1;
14316
 
  pAmount ALIAS FOR $2;
14317
 
  pCurrId ALIAS FOR $3;
14318
 
  pInclCredits ALIAS FOR $4;
14319
 
  _amount NUMERIC;
14320
 
  _applied NUMERIC := 0;
14321
 
  _applyAmount NUMERIC;
14322
 
  _discount NUMERIC;
14323
 
  _discprct NUMERIC;
14324
 
  _docDate DATE;
14325
 
  _r RECORD;
14326
 
  _toApply NUMERIC;
14327
 
 
14328
 
BEGIN
14329
 
 
14330
 
  IF (pInclCredits) THEN
14331
 
    -- First find total debits unaccounted for by this receipt so we can apply as much credit 
14332
 
    -- as possible to clear, but no more
14333
 
    SELECT coalesce(noNeg(sum(currToCurr(aropen_curr_id, cashrcpt_curr_id,
14334
 
         aropen_amount - aropen_paid, cashrcpt_distdate) -
14335
 
         COALESCE((SELECT (SUM(cashrcptitem_amount) + SUM(cashrcptitem_discount))
14336
 
                   FROM cashrcptitem, cashrcpt
14337
 
                   WHERE ((cashrcpt_id=cashrcptitem_cashrcpt_id)
14338
 
                     AND  (NOT cashrcpt_void)
14339
 
                     AND  (NOT cashrcpt_posted)
14340
 
                     AND  (cashrcpt_id != pCashrcptid)
14341
 
                     AND  (cashrcptitem_aropen_id=aropen_id))), 0)) - pAmount),0)
14342
 
    INTO _toApply
14343
 
    FROM cashrcpt
14344
 
      JOIN custinfo ON (cashrcpt_cust_id=cust_id)
14345
 
      JOIN aropen ON (cust_id=aropen_cust_id)
14346
 
    WHERE ((cashrcpt_id=pCashrcptid)
14347
 
      AND (aropen_open)
14348
 
      AND (aropen_doctype IN ('I','D')));
14349
 
           
14350
 
    -- Loop through and apply credits until we account for all remaining debits we can
14351
 
    FOR _r IN 
14352
 
      SELECT aropen_id
14353
 
      FROM cashrcpt
14354
 
        JOIN custinfo ON (cashrcpt_cust_id=cust_id)
14355
 
        JOIN aropen ON (cust_id=aropen_cust_id)
14356
 
      WHERE ((cashrcpt_id=pCashrcptid)
14357
 
        AND (aropen_open)
14358
 
        AND (aropen_doctype IN ('C','R')))
14359
 
      ORDER BY aropen_duedate, aropen_docnumber
14360
 
    LOOP
14361
 
     EXIT WHEN _toApply <= 0;
14362
 
      _toApply := _toApply - applyCashReceiptLineBalance(pCashrcptid, _r.aropen_id, _toApply, pCurrId);
14363
 
    END LOOP;
14364
 
  END IF;
14365
 
 
14366
 
  SELECT (currToCurr(pCurrId, cashrcpt_curr_id, pAmount, cashrcpt_distdate) -
14367
 
              (COALESCE(SUM(cashrcptitem_amount), 0) ) ),
14368
 
              COALESCE(cashrcpt_docdate, current_date) 
14369
 
              INTO _amount, _docDate
14370
 
  FROM cashrcpt LEFT OUTER JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id = cashrcpt_id)
14371
 
  WHERE (cashrcpt_id=pCashrcptid)
14372
 
  GROUP BY cashrcpt_curr_id, cashrcpt_distdate, cashrcpt_docdate;
14373
 
 
14374
 
  SELECT (_amount - COALESCE(SUM(cashrcptmisc_amount), 0)) INTO _amount
14375
 
  FROM cashrcptmisc
14376
 
  WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid);
14377
 
 
14378
 
  IF (_amount = 0) THEN
14379
 
    RETURN 1;
14380
 
  END IF;
14381
 
 
14382
 
  FOR _r IN SELECT aropen_id,
14383
 
               currToCurr(aropen_curr_id, cashrcpt_curr_id,
14384
 
               aropen_amount - aropen_paid, cashrcpt_distdate) -
14385
 
               COALESCE((SELECT SUM(cashrcptitem_amount) + SUM(cashrcptitem_discount)
14386
 
                           FROM cashrcptitem, cashrcpt
14387
 
                           WHERE ((cashrcpt_id=cashrcptitem_cashrcpt_id)
14388
 
                             AND  (NOT cashrcpt_void)
14389
 
                             AND  (NOT cashrcpt_posted)
14390
 
                             AND  (cashrcpt_id != pCashrcptId)
14391
 
                             AND  (cashrcptitem_aropen_id=aropen_id))), 0) AS balance,
14392
 
                   s.cashrcptitem_id AS cashrcptitem_id
14393
 
            FROM cashrcpt, aropen LEFT OUTER JOIN
14394
 
                 cashrcptitem s ON (s.cashrcptitem_aropen_id=aropen_id AND s.cashrcptitem_cashrcpt_id=pCashrcptId)
14395
 
                 LEFT OUTER JOIN terms ON (aropen_terms_id=terms_id),
14396
 
                 (SELECT COALESCE(SUM(arapply_applied), 0.00) AS applied  
14397
 
                  FROM arapply, aropen 
14398
 
                  WHERE ((arapply_target_aropen_id=aropen_id) 
14399
 
                    AND (arapply_source_aropen_id=aropen_id) 
14400
 
                    AND  (aropen_discount) )
14401
 
                 ) AS data
14402
 
 
14403
 
            WHERE ( (aropen_cust_id=cashrcpt_cust_id)
14404
 
             AND (aropen_doctype IN ('I', 'D'))
14405
 
             AND (aropen_open)
14406
 
             AND (cashrcpt_id=pCashrcptid) )
14407
 
            ORDER BY aropen_duedate, aropen_amount, balance LOOP
14408
 
 
14409
 
    SELECT  round(noNeg(_r.balance * 
14410
 
            CASE WHEN (_docDate <= determineDiscountDate(terms_id, aropen_docdate)) THEN terms_discprcnt 
14411
 
            ELSE 0.00 END - applied),2),
14412
 
            CASE WHEN (_docDate <= determineDiscountDate(terms_id, aropen_docdate)) THEN terms_discprcnt 
14413
 
            ELSE 0.00 END INTO _discount, _discprct
14414
 
            FROM aropen LEFT OUTER JOIN terms ON (terms_id=aropen_terms_id), 
14415
 
                 (SELECT COALESCE(SUM(arapply_applied), 0.00) AS applied  
14416
 
                          FROM arapply, aropen 
14417
 
                  WHERE ((arapply_target_aropen_id=_r.aropen_id) 
14418
 
                  AND (arapply_source_aropen_id=_r.aropen_id) 
14419
 
                  AND  (aropen_discount) )
14420
 
                 ) AS data 
14421
 
            WHERE (aropen_id=_r.aropen_id);
14422
 
 
14423
 
    IF (_r.balance <= _amount + _discount) THEN
14424
 
      _applyAmount := _r.balance - _discount;
14425
 
    ELSE
14426
 
      _discount := round((_amount / (1 - _discprct)) - _amount, 2);
14427
 
      _applyAmount := _amount;
14428
 
    END IF;
14429
 
 
14430
 
    IF (_applyAmount > 0) THEN
14431
 
      IF (_r.cashrcptitem_id IS NOT NULL) THEN
14432
 
        UPDATE cashrcptitem
14433
 
        SET cashrcptitem_amount = round(cashrcptitem_amount + _applyAmount, 2),
14434
 
            cashrcptitem_discount = round(_discount, 2)
14435
 
        WHERE (cashrcptitem_id=_r.cashrcptitem_id);
14436
 
      ELSE
14437
 
        INSERT INTO cashrcptitem
14438
 
        ( cashrcptitem_aropen_id, cashrcptitem_cashrcpt_id,
14439
 
          cashrcptitem_amount, cashrcptitem_discount )
14440
 
        VALUES
14441
 
        ( _r.aropen_id, pCashrcptid, round(_applyAmount, 2), round(_discount, 2) );
14442
 
      END IF;
14443
 
 
14444
 
      _amount := (_amount - _applyAmount);
14445
 
      IF (round(_amount, 2) = 0) THEN
14446
 
        EXIT;
14447
 
      END IF;
14448
 
 
14449
 
    END IF;
14450
 
  END LOOP;
14451
 
 
14452
 
  RETURN 1;
14453
 
 
14454
 
END;
14455
 
$_$;
14456
 
 
14457
 
 
14458
 
ALTER FUNCTION public.applycashreceipttobalance(integer, numeric, integer, boolean) OWNER TO admin;
14459
 
 
14460
 
--
14461
 
--
14462
 
 
14463
 
CREATE FUNCTION araging(date, boolean) RETURNS SETOF araging
14464
 
    LANGUAGE plpgsql
14465
 
    AS $_$
14466
 
DECLARE
14467
 
  pAsOfDate ALIAS FOR $1;
14468
 
  pUseDocDate ALIAS FOR $2;
14469
 
  _row araging%ROWTYPE;
14470
 
 
14471
 
BEGIN
14472
 
 
14473
 
  FOR _row IN SELECT *
14474
 
            FROM araging(pAsOfDate, pUseDocDate, true)
14475
 
  LOOP
14476
 
    RETURN NEXT _row;
14477
 
  END LOOP;
14478
 
 
14479
 
  RETURN;
14480
 
END;
14481
 
$_$;
14482
 
 
14483
 
 
14484
 
ALTER FUNCTION public.araging(date, boolean) OWNER TO admin;
14485
 
 
14486
 
--
14487
 
--
14488
 
 
14489
 
CREATE FUNCTION araging(date, boolean, boolean) RETURNS SETOF araging
14490
 
    LANGUAGE plpgsql
14491
 
    AS $_$
14492
 
DECLARE
14493
 
  pAsOfDate ALIAS FOR $1;
14494
 
  pUseDocDate ALIAS FOR $2;
14495
 
  pConvBaseCurr ALIAS FOR $3;
14496
 
  _row araging%ROWTYPE;
14497
 
  _x RECORD;
14498
 
  _returnVal INTEGER;
14499
 
  _asOfDate DATE;
14500
 
BEGIN
14501
 
 
14502
 
  _asOfDate := COALESCE(pAsOfDate,current_date);
14503
 
 
14504
 
  FOR _x IN
14505
 
        SELECT
14506
 
        aropen_docdate,
14507
 
        aropen_duedate,
14508
 
        aropen_ponumber,
14509
 
        aropen_docnumber,
14510
 
        aropen_doctype,
14511
 
        cust_id,
14512
 
        cust_name,
14513
 
        cust_number,
14514
 
        cust_custtype_id,
14515
 
        custtype_code,
14516
 
        terms_descrip,
14517
 
 
14518
 
        --if pConvBaseCurr is true then use currtobase to convert all amounts to base based on aropen_docdate to ensure the same exchange rate
14519
 
        --otherwise use currtocurr to convert all amounts to customer's currency based on aropen_docdate to ensure the same exchange rate
14520
 
 
14521
 
        --today and greater:
14522
 
        CASE WHEN((aropen_duedate >= DATE(_asOfDate))) THEN balance
14523
 
             ELSE 0.0 END AS cur_val,
14524
 
 
14525
 
        --0 to 30
14526
 
        CASE WHEN((aropen_duedate >= DATE(_asOfDate)-30) AND (aropen_duedate < DATE(_asOfDate))) THEN balance
14527
 
             ELSE 0.0 END AS thirty_val,
14528
 
 
14529
 
        --30-60
14530
 
        CASE WHEN((aropen_duedate >= DATE(_asOfDate)-60) AND (aropen_duedate < DATE(_asOfDate) - 30 )) THEN balance
14531
 
             ELSE 0.0 END AS sixty_val,
14532
 
 
14533
 
        --60-90
14534
 
        CASE WHEN((aropen_duedate >= DATE(_asOfDate)-90) AND (aropen_duedate < DATE(_asOfDate) - 60)) THEN balance
14535
 
             ELSE 0.0 END AS ninety_val,
14536
 
 
14537
 
        --greater than 90:
14538
 
        CASE WHEN((aropen_duedate > DATE(_asOfDate)-10000) AND (aropen_duedate < DATE(_asOfDate) - 90)) THEN balance
14539
 
             ELSE 0.0 END AS plus_val,
14540
 
 
14541
 
        --total amount:
14542
 
        CASE WHEN((aropen_duedate > DATE(_asOfDate)-10000)) THEN balance
14543
 
             ELSE 0.0 END AS total_val,
14544
 
 
14545
 
        --AR Open Amount base
14546
 
        aropen_amount
14547
 
 
14548
 
        FROM (
14549
 
          SELECT
14550
 
          (((aropen_amount - aropen_paid + COALESCE(SUM(arapply_target_paid),0))) /
14551
 
             CASE WHEN (pConvBaseCurr) THEN aropen_curr_rate
14552
 
                  ELSE currRate(aropen_curr_id, cust_curr_id, aropen_docdate)
14553
 
             END *
14554
 
             CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1.0
14555
 
                  ELSE 1.0
14556
 
             END) AS balance,
14557
 
          ((aropen_amount) /
14558
 
             CASE WHEN (pConvBaseCurr) THEN aropen_curr_rate
14559
 
                  ELSE currRate(aropen_curr_id, cust_curr_id, aropen_docdate)
14560
 
             END *
14561
 
             CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1.0
14562
 
                  ELSE 1.0
14563
 
             END) AS aropen_amount,
14564
 
          aropen_docdate,
14565
 
          aropen_duedate,
14566
 
          aropen_ponumber,
14567
 
          aropen_docnumber,
14568
 
          aropen_doctype,
14569
 
          cust_id,
14570
 
          cust_name,
14571
 
          cust_number,
14572
 
          cust_custtype_id,
14573
 
          custtype_code,
14574
 
          COALESCE(arterms.terms_descrip, custterms.terms_descrip, '') AS terms_descrip
14575
 
 
14576
 
          FROM aropen
14577
 
            JOIN custinfo ON (cust_id=aropen_cust_id)
14578
 
            JOIN custtype ON (custtype_id=cust_custtype_id)
14579
 
            LEFT OUTER JOIN terms arterms ON (arterms.terms_id=aropen_terms_id)
14580
 
            LEFT OUTER JOIN terms custterms ON (custterms.terms_id=cust_terms_id)
14581
 
            LEFT OUTER JOIN arapply ON (((aropen_id=arapply_target_aropen_id)
14582
 
                                      OR (aropen_id=arapply_source_aropen_id))
14583
 
                                     AND (arapply_distdate>_asOfDate))
14584
 
          WHERE ( (CASE WHEN (pUseDocDate) THEN aropen_docdate ELSE aropen_distdate END <= _asOfDate)
14585
 
          AND (COALESCE(aropen_closedate,_asOfDate+1)>_asOfDate) )
14586
 
          GROUP BY aropen_id,aropen_docdate,aropen_duedate,aropen_ponumber,aropen_docnumber,aropen_doctype,aropen_paid,
14587
 
                   aropen_curr_id,aropen_amount,cust_id,cust_name,cust_number,cust_custtype_id,custtype_code,
14588
 
                   arterms.terms_descrip,custterms.terms_descrip, aropen_curr_rate, aropen_curr_id, cust_curr_id
14589
 
          ORDER BY cust_number, aropen_duedate ) AS data
14590
 
  LOOP
14591
 
        _row.araging_docdate := _x.aropen_docdate;
14592
 
        _row.araging_duedate := _x.aropen_duedate;
14593
 
        _row.araging_ponumber := _x.aropen_ponumber;
14594
 
        _row.araging_docnumber := _x.aropen_docnumber;
14595
 
        _row.araging_doctype := _x.aropen_doctype;
14596
 
        _row.araging_cust_id := _x.cust_id;
14597
 
        _row.araging_cust_number := _x.cust_number;
14598
 
        _row.araging_cust_name := _x.cust_name;
14599
 
        _row.araging_cust_custtype_id := _x.cust_custtype_id;
14600
 
        _row.araging_custtype_code := _x.custtype_code;
14601
 
        _row.araging_terms_descrip := _x.terms_descrip;
14602
 
        _row.araging_aropen_amount := _x.aropen_amount;
14603
 
        _row.araging_cur_val := _x.cur_val;
14604
 
        _row.araging_thirty_val := _x.thirty_val;
14605
 
        _row.araging_sixty_val := _x.sixty_val;
14606
 
        _row.araging_ninety_val := _x.ninety_val;
14607
 
        _row.araging_plus_val := _x.plus_val;
14608
 
        _row.araging_total_val := _x.total_val;
14609
 
        RETURN NEXT _row;
14610
 
  END LOOP;
14611
 
  RETURN;
14612
 
END;
14613
 
$_$;
14614
 
 
14615
 
 
14616
 
ALTER FUNCTION public.araging(date, boolean, boolean) OWNER TO admin;
14617
 
 
14618
 
--
14619
 
--
14620
 
 
14621
 
CREATE FUNCTION arapplied(integer, date) RETURNS numeric
14622
 
    LANGUAGE plpgsql
14623
 
    AS $_$
14624
 
DECLARE
14625
 
  pAropenid ALIAS FOR $1;
14626
 
  pDate ALIAS FOR $2;
14627
 
  _amount NUMERIC;
14628
 
 
14629
 
BEGIN
14630
 
 
14631
 
  -- Return amount applied to an aropen in base currency item as of the parameter date
14632
 
  SELECT SUM(currtobase(arapply_curr_id,arapply_applied,pDate)) INTO _amount
14633
 
  FROM arapply
14634
 
  WHERE (((arapply_target_aropen_id = pAropenid) OR (arapply_source_aropen_id = pAropenid))
14635
 
  AND (((arapply_journalnumber=0) AND (arapply_postdate <= pDate))
14636
 
  OR EXISTS(SELECT * 
14637
 
             FROM gltrans 
14638
 
             WHERE ((gltrans_journalnumber=arapply_journalnumber)
14639
 
             AND (gltrans_date <= pDate)))));
14640
 
 
14641
 
  IF (_amount IS NULL) THEN
14642
 
    RETURN 0;
14643
 
  ELSE
14644
 
    RETURN _amount;
14645
 
  END IF;
14646
 
 
14647
 
END;
14648
 
$_$;
14649
 
 
14650
 
 
14651
 
ALTER FUNCTION public.arapplied(integer, date) OWNER TO admin;
14652
 
 
14653
 
--
14654
 
--
14655
 
 
14656
 
CREATE FUNCTION archivesaleshistory(integer) RETURNS integer
14657
 
    LANGUAGE plpgsql
14658
 
    AS $_$
14659
 
DECLARE
14660
 
  pSohistid ALIAS FOR $1;
14661
 
 
14662
 
BEGIN
14663
 
 
14664
 
  INSERT INTO asohist ( asohist_id,
14665
 
                        asohist_cust_id,
14666
 
                        asohist_itemsite_id,
14667
 
                        asohist_shipdate,
14668
 
                        asohist_invcdate,
14669
 
                        asohist_duedate,
14670
 
                        asohist_promisedate,
14671
 
                        asohist_ordernumber,
14672
 
                        asohist_invcnumber,
14673
 
                        asohist_qtyshipped,
14674
 
                        asohist_unitprice,
14675
 
                        asohist_unitcost,
14676
 
                        asohist_billtoname,
14677
 
                        asohist_billtoaddress1,
14678
 
                        asohist_billtoaddress2,
14679
 
                        asohist_billtoaddress3,
14680
 
                        asohist_billtocity,
14681
 
                        asohist_billtostate,
14682
 
                        asohist_billtozip,
14683
 
                        asohist_shiptoname,
14684
 
                        asohist_shiptoaddress1,
14685
 
                        asohist_shiptoaddress2,
14686
 
                        asohist_shiptoaddress3,
14687
 
                        asohist_shiptocity,
14688
 
                        asohist_shiptostate,
14689
 
                        asohist_shiptozip,
14690
 
                        asohist_shipto_id,
14691
 
                        asohist_shipvia,
14692
 
                        asohist_salesrep_id,
14693
 
                        asohist_misc_type,
14694
 
                        asohist_misc_descrip,
14695
 
                        asohist_misc_id,
14696
 
                        asohist_commission,
14697
 
                        asohist_commissionpaid,
14698
 
                        asohist_doctype,
14699
 
                        asohist_orderdate,
14700
 
                        asohist_imported,
14701
 
                        asohist_ponumber,
14702
 
                        asohist_curr_id,
14703
 
                        asohist_taxtype_id,
14704
 
                        asohist_taxzone_id )
14705
 
  SELECT cohist_id,
14706
 
         cohist_cust_id,
14707
 
         cohist_itemsite_id,
14708
 
         cohist_shipdate,
14709
 
         cohist_invcdate,
14710
 
         cohist_duedate,
14711
 
         cohist_promisedate,
14712
 
         cohist_ordernumber,
14713
 
         cohist_invcnumber,
14714
 
         cohist_qtyshipped,
14715
 
         cohist_unitprice,
14716
 
         cohist_unitcost,
14717
 
         cohist_billtoname,
14718
 
         cohist_billtoaddress1,
14719
 
         cohist_billtoaddress2,
14720
 
         cohist_billtoaddress3,
14721
 
         cohist_billtocity,
14722
 
         cohist_billtostate,
14723
 
         cohist_billtozip,
14724
 
         cohist_shiptoname,
14725
 
         cohist_shiptoaddress1,
14726
 
         cohist_shiptoaddress2,
14727
 
         cohist_shiptoaddress3,
14728
 
         cohist_shiptocity,
14729
 
         cohist_shiptostate,
14730
 
         cohist_shiptozip,
14731
 
         cohist_shipto_id,
14732
 
         cohist_shipvia,
14733
 
         cohist_salesrep_id,
14734
 
         cohist_misc_type,
14735
 
         cohist_misc_descrip,
14736
 
         cohist_misc_id,
14737
 
         cohist_commission,
14738
 
         cohist_commissionpaid,
14739
 
         cohist_doctype,
14740
 
         cohist_orderdate,
14741
 
         cohist_imported,
14742
 
         cohist_ponumber,
14743
 
         cohist_curr_id,
14744
 
         cohist_taxtype_id,
14745
 
         cohist_taxzone_id
14746
 
  FROM cohist
14747
 
  WHERE (cohist_id=pSohistid);
14748
 
 
14749
 
  INSERT INTO asohisttax ( taxhist_id,
14750
 
                           taxhist_parent_id,
14751
 
                           taxhist_taxtype_id,
14752
 
                           taxhist_tax_id,
14753
 
                           taxhist_basis,
14754
 
                           taxhist_basis_tax_id,
14755
 
                           taxhist_sequence,
14756
 
                           taxhist_percent,
14757
 
                           taxhist_amount,
14758
 
                           taxhist_tax,
14759
 
                           taxhist_docdate,
14760
 
                           taxhist_distdate,
14761
 
                           taxhist_curr_id,
14762
 
                           taxhist_curr_rate,
14763
 
                           taxhist_journalnumber )
14764
 
  SELECT taxhist_id,
14765
 
         taxhist_parent_id,
14766
 
         taxhist_taxtype_id,
14767
 
         taxhist_tax_id,
14768
 
         taxhist_basis,
14769
 
         taxhist_basis_tax_id,
14770
 
         taxhist_sequence,
14771
 
         taxhist_percent,
14772
 
         taxhist_amount,
14773
 
         taxhist_tax,
14774
 
         taxhist_docdate,
14775
 
         taxhist_distdate,
14776
 
         taxhist_curr_id,
14777
 
         taxhist_curr_rate,
14778
 
         taxhist_journalnumber
14779
 
  FROM cohisttax
14780
 
  WHERE (taxhist_parent_id=pSohistid);
14781
 
 
14782
 
  DELETE FROM cohisttax
14783
 
  WHERE (taxhist_parent_id=pSohistid);
14784
 
 
14785
 
  DELETE FROM cohist
14786
 
  WHERE (cohist_id=pSohistid);
14787
 
 
14788
 
  RETURN pSohistid;
14789
 
 
14790
 
END;
14791
 
$_$;
14792
 
 
14793
 
 
14794
 
ALTER FUNCTION public.archivesaleshistory(integer) OWNER TO admin;
14795
 
 
14796
 
--
14797
 
--
14798
 
 
14799
 
CREATE FUNCTION arcurrgain(integer, integer, numeric, date) RETURNS numeric
14800
 
    LANGUAGE plpgsql
14801
 
    AS $_$
14802
 
DECLARE
14803
 
  pAropenId ALIAS FOR $1;
14804
 
  pCurrId ALIAS FOR $2;
14805
 
  pValue ALIAS FOR $3;
14806
 
  pDate ALIAS FOR $4;
14807
 
  _start DATE;
14808
 
  _end DATE;
14809
 
  _gain NUMERIC;
14810
 
  _r RECORD;
14811
 
 
14812
 
BEGIN
14813
 
  IF (pAropenId IS NULL OR pValue = 0) THEN
14814
 
    RETURN 0;
14815
 
  END IF;
14816
 
 
14817
 
  SELECT aropen_docdate, aropen_curr_id, aropen_curr_rate
14818
 
    INTO _r
14819
 
  FROM aropen
14820
 
  WHERE (aropen_id=pAropenId);
14821
 
 
14822
 
  IF (_r.aropen_docdate > pDate) THEN
14823
 
    _gain := (currToBase(pCurrId, pValue, pDate) - currToCurr(pCurrId,_r.aropen_curr_id, pValue, pDate) / _r.aropen_curr_rate) * -1;
14824
 
  ELSE
14825
 
    _gain := currToCurr(pCurrId,_r.aropen_curr_id, pValue, pDate) / _r.aropen_curr_rate - currToBase(pCurrId, pValue, pDate);
14826
 
  END IF;
14827
 
 
14828
 
  IF (_gain IS NULL) THEN
14829
 
    RAISE EXCEPTION 'Error processing currency gain/loss.';
14830
 
  END IF;
14831
 
 
14832
 
  RETURN _gain;
14833
 
END;
14834
 
$_$;
14835
 
 
14836
 
 
14837
 
ALTER FUNCTION public.arcurrgain(integer, integer, numeric, date) OWNER TO admin;
14838
 
 
14839
 
--
14840
 
--
14841
 
 
14842
 
CREATE FUNCTION armor(bytea) RETURNS text
14843
 
    LANGUAGE c IMMUTABLE STRICT
14844
 
    AS '$libdir/pgcrypto', 'pg_armor';
14845
 
 
14846
 
 
14847
 
ALTER FUNCTION public.armor(bytea) OWNER TO admin;
14848
 
 
14849
 
--
14850
 
--
14851
 
 
14852
 
CREATE TABLE invbal (
14853
 
    invbal_id integer NOT NULL,
14854
 
    invbal_period_id integer,
14855
 
    invbal_itemsite_id integer,
14856
 
    invbal_qoh_beginning numeric(18,6) NOT NULL,
14857
 
    invbal_qoh_ending numeric(18,6) NOT NULL,
14858
 
    invbal_qty_in numeric(18,6) NOT NULL,
14859
 
    invbal_qty_out numeric(18,6) NOT NULL,
14860
 
    invbal_value_beginning numeric(12,2) NOT NULL,
14861
 
    invbal_value_ending numeric(12,2) NOT NULL,
14862
 
    invbal_value_in numeric(12,2) NOT NULL,
14863
 
    invbal_value_out numeric(12,2) NOT NULL,
14864
 
    invbal_nn_beginning numeric(18,6) NOT NULL,
14865
 
    invbal_nn_ending numeric(18,6) NOT NULL,
14866
 
    invbal_nn_in numeric(18,6) NOT NULL,
14867
 
    invbal_nn_out numeric(18,6) NOT NULL,
14868
 
    invbal_nnval_beginning numeric(12,2) NOT NULL,
14869
 
    invbal_nnval_ending numeric(12,2) NOT NULL,
14870
 
    invbal_nnval_in numeric(12,2) NOT NULL,
14871
 
    invbal_nnval_out numeric(12,2) NOT NULL,
14872
 
    invbal_dirty boolean DEFAULT true NOT NULL
14873
 
);
14874
 
 
14875
 
 
14876
 
ALTER TABLE public.invbal OWNER TO admin;
14877
 
 
14878
 
--
14879
 
--
14880
 
 
14881
 
CREATE FUNCTION asofinvbal(integer, date) RETURNS SETOF invbal
14882
 
    LANGUAGE plpgsql STABLE
14883
 
    AS $_$
14884
 
DECLARE
14885
 
  pItemsiteId ALIAS FOR $1;
14886
 
  pAsofDate ALIAS FOR $2;
14887
 
  _result invbal%ROWTYPE;
14888
 
  _i RECORD;
14889
 
  _h RECORD;
14890
 
  _r RECORD;
14891
 
  _prevCostmethod TEXT := 'A';
14892
 
  _prevDate TIMESTAMP WITH TIME ZONE;
14893
 
  _runningQty NUMERIC := 0;
14894
 
  _runningNn NUMERIC := 0;
14895
 
  _runningValue NUMERIC := 0;
14896
 
  _runningNnval NUMERIC := 0;
14897
 
 
14898
 
BEGIN
14899
 
  /* This is a base function to gather data.  Because it is STABLE it should only need
14900
 
  to be calculated once, even though it is likely to be called several times by other
14901
 
  functions in parent query to present the various data.
14902
 
  */
14903
 
  
14904
 
  -- First make sure inventory balance is forward updated
14905
 
  PERFORM forwardUpdateItemsite(pItemsiteId);
14906
 
 
14907
 
  -- Next find the previous period balace to use as a starting point
14908
 
  SELECT invbal.*, period_start, itemsite_costmethod INTO _i
14909
 
  FROM invbal 
14910
 
    JOIN itemsite ON (invbal_itemsite_id=itemsite_id) 
14911
 
    JOIN period ON (invbal_period_id=period_id)
14912
 
  WHERE ((invbal_itemsite_id=pItemsiteId)
14913
 
    AND  (pAsofDate >= period_start))
14914
 
  ORDER BY period_start DESC
14915
 
  LIMIT 1;
14916
 
 
14917
 
  _runningQty := _i.invbal_qoh_beginning;
14918
 
  _runningNn := _i.invbal_nn_beginning;
14919
 
  _runningValue := _i.invbal_value_beginning;
14920
 
  _runningNnval := _i.invbal_nnval_beginning;
14921
 
  _prevDate := _i.period_start;
14922
 
  _prevCostmethod := _i.itemsite_costmethod;
14923
 
 
14924
 
  FOR _r IN 
14925
 
    SELECT invhist_id, invhist_created, invhist_invqty, invhist_transtype, invhist_unitcost,
14926
 
      invhist_costmethod, itemsite_item_id, invhistSense(invhist_id) AS sense
14927
 
    FROM invhist
14928
 
      JOIN itemsite ON (itemsite_id=invhist_itemsite_id)
14929
 
    WHERE ((invhist_itemsite_id=pItemsiteId)
14930
 
    AND (invhist_transdate::date BETWEEN _i.period_start AND pAsofdate))
14931
 
    ORDER BY invhist_created, invhist_id
14932
 
  LOOP
14933
 
    -- Update balances changed by any standard cost update between transactions
14934
 
    IF (_prevCostmethod = 'S' AND _runningQty != 0) THEN
14935
 
      FOR _h IN
14936
 
        SELECT costhist_oldcost, costhist_newcost
14937
 
        FROM costhist
14938
 
          JOIN item ON (costhist_item_id=item_id)
14939
 
          JOIN itemsite ON (itemsite_item_id=item_id)
14940
 
        WHERE ((itemsite_id=pItemsiteId)
14941
 
          AND (costhist_date BETWEEN _prevDate AND _r.invhist_created)
14942
 
          AND (costhist_type IN ('S','D')))
14943
 
      LOOP
14944
 
        _runningValue := _runningValue + round((_h.costhist_newcost-_h.costhist_oldcost) * _runningQty,2);
14945
 
        _runningNnval := _runningNnval + round((_h.costhist_newcost-_h.costhist_oldcost) * _runningNn,2);
14946
 
      END LOOP;
14947
 
    END IF;
14948
 
 
14949
 
    _prevDate := _r.invhist_created;
14950
 
    _prevCostmethod := _r.invhist_costmethod;
14951
 
    _runningQty := _runningQty + _r.invhist_invqty * _r.sense;
14952
 
    _runningValue := _runningValue + round( _r.invhist_invqty * _r.sense * _r.invhist_unitcost,2);
14953
 
    IF (_r.invhist_transtype = 'NN') THEN
14954
 
      _runningNn := _runningNn + _r.invhist_invqty * -1;
14955
 
      _runningNnval := _runningNnval + round( _r.invhist_invqty * -1 * _r.invhist_unitcost,2);
14956
 
    END IF;
14957
 
    
14958
 
  END LOOP;
14959
 
 
14960
 
  _prevDate := COALESCE(_prevDate, _i.period_start);
14961
 
  _prevCostmethod := COALESCE(_r.invhist_costmethod, _i.itemsite_costmethod);
14962
 
  
14963
 
  IF (_prevCostmethod = 'S' AND _runningQty != 0) THEN
14964
 
    FOR _h IN
14965
 
      SELECT costhist_oldcost, costhist_newcost
14966
 
      FROM costhist
14967
 
        JOIN item ON (costhist_item_id=item_id)
14968
 
        JOIN itemsite ON (itemsite_item_id=item_id)
14969
 
      WHERE ((itemsite_id=pItemsiteId)
14970
 
        AND (costhist_date BETWEEN _prevDate AND CAST(pAsofDate + 1 AS TIMESTAMP WITH TIME ZONE))
14971
 
        AND (costhist_type IN ('S','D')))
14972
 
    LOOP
14973
 
      _runningValue := _runningValue + round((_h.costhist_newcost-_h.costhist_oldcost) * _runningQty,2);
14974
 
      _runningNnval := _runningNnval + round((_h.costhist_newcost-_h.costhist_oldcost) * _runningNn,2);
14975
 
    END LOOP;
14976
 
  END IF;
14977
 
 
14978
 
  _result := _i;
14979
 
  _result.invbal_qoh_ending := _runningQty;
14980
 
  _result.invbal_value_ending := _runningValue;
14981
 
  _result.invbal_nn_ending := _runningNn;
14982
 
  _result.invbal_nnval_ending := _runningNnval;
14983
 
 
14984
 
  RETURN NEXT _result;
14985
 
 
14986
 
  RETURN;
14987
 
  
14988
 
END;
14989
 
$_$;
14990
 
 
14991
 
 
14992
 
ALTER FUNCTION public.asofinvbal(integer, date) OWNER TO admin;
14993
 
 
14994
 
--
14995
 
--
14996
 
 
14997
 
CREATE FUNCTION asofinvnn(integer, date) RETURNS numeric
14998
 
    LANGUAGE plpgsql STABLE
14999
 
    AS $_$
15000
 
DECLARE
15001
 
  pItemsiteId ALIAS FOR $1;
15002
 
  pAsofDate ALIAS FOR $2;
15003
 
  _result NUMERIC;
15004
 
 
15005
 
BEGIN
15006
 
 
15007
 
  SELECT invbal_nn_ending INTO _result
15008
 
  FROM asofinvbal(pItemsiteId, pAsofDate);
15009
 
 
15010
 
  RETURN COALESCE(_result, 0);
15011
 
  
15012
 
END;
15013
 
$_$;
15014
 
 
15015
 
 
15016
 
ALTER FUNCTION public.asofinvnn(integer, date) OWNER TO admin;
15017
 
 
15018
 
--
15019
 
--
15020
 
 
15021
 
CREATE FUNCTION asofinvqty(integer, date) RETURNS numeric
15022
 
    LANGUAGE plpgsql STABLE
15023
 
    AS $_$
15024
 
DECLARE
15025
 
  pItemsiteId ALIAS FOR $1;
15026
 
  pAsofDate ALIAS FOR $2;
15027
 
  _result NUMERIC;
15028
 
 
15029
 
BEGIN
15030
 
 
15031
 
  SELECT invbal_qoh_ending INTO _result
15032
 
  FROM asofinvbal(pItemsiteId, pAsofDate);
15033
 
 
15034
 
  RETURN COALESCE(_result, 0);
15035
 
  
15036
 
END;
15037
 
$_$;
15038
 
 
15039
 
 
15040
 
ALTER FUNCTION public.asofinvqty(integer, date) OWNER TO admin;
15041
 
 
15042
 
--
15043
 
--
15044
 
 
15045
 
CREATE FUNCTION assessfinancecharge(paropenid integer, passessdate date, passessamount numeric) RETURNS integer
15046
 
    LANGUAGE plpgsql
15047
 
    AS $$
15048
 
DECLARE
15049
 
  _fc           RECORD;
15050
 
  _ar           RECORD;
15051
 
  _invcheadid   INTEGER;
15052
 
 
15053
 
BEGIN
15054
 
 
15055
 
  -- cache some information
15056
 
  SELECT * INTO _fc FROM fincharg;
15057
 
  IF (NOT FOUND) THEN
15058
 
    RAISE EXCEPTION 'assessFinanceCharge, configuration not set.';
15059
 
  END IF;
15060
 
 
15061
 
  SELECT * INTO _ar FROM aropen WHERE (aropen_id=pAropenid);
15062
 
  IF (NOT FOUND) THEN
15063
 
    RAISE EXCEPTION 'assessFinanceCharge, aropen not found.';
15064
 
  END IF;
15065
 
 
15066
 
  -- create invoice head
15067
 
  INSERT INTO invchead
15068
 
    ( invchead_cust_id,
15069
 
      invchead_shipto_id,
15070
 
      invchead_ordernumber,
15071
 
      invchead_orderdate,
15072
 
      invchead_posted,
15073
 
      invchead_printed,
15074
 
      invchead_invcnumber,
15075
 
      invchead_invcdate,
15076
 
      invchead_shipdate,
15077
 
      invchead_ponumber,
15078
 
      invchead_shipvia,
15079
 
      invchead_fob,
15080
 
      invchead_billto_name,
15081
 
      invchead_billto_address1,
15082
 
      invchead_billto_address2,
15083
 
      invchead_billto_address3,
15084
 
      invchead_billto_city,
15085
 
      invchead_billto_state,
15086
 
      invchead_billto_zipcode,
15087
 
      invchead_billto_phone,
15088
 
      invchead_shipto_name,
15089
 
      invchead_shipto_address1,
15090
 
      invchead_shipto_address2,
15091
 
      invchead_shipto_address3,
15092
 
      invchead_shipto_city,
15093
 
      invchead_shipto_state,
15094
 
      invchead_shipto_zipcode,
15095
 
      invchead_shipto_phone,
15096
 
      invchead_salesrep_id,
15097
 
      invchead_commission,
15098
 
      invchead_terms_id,
15099
 
      invchead_freight,
15100
 
      invchead_misc_amount,
15101
 
      invchead_misc_descrip,
15102
 
      invchead_misc_accnt_id,
15103
 
      invchead_payment,
15104
 
      invchead_paymentref,
15105
 
      invchead_notes,
15106
 
      invchead_billto_country,
15107
 
      invchead_shipto_country,
15108
 
      invchead_prj_id,
15109
 
      invchead_curr_id,
15110
 
      invchead_gldistdate,
15111
 
      invchead_recurring,
15112
 
      invchead_recurring_interval,
15113
 
      invchead_recurring_type,
15114
 
      invchead_recurring_until,
15115
 
      invchead_recurring_invchead_id,
15116
 
      invchead_shipchrg_id,
15117
 
      invchead_taxzone_id,
15118
 
      invchead_void,
15119
 
      invchead_saletype_id,
15120
 
      invchead_shipzone_id )
15121
 
  SELECT
15122
 
      invchead_cust_id,
15123
 
      invchead_shipto_id,
15124
 
      invchead_ordernumber,
15125
 
      invchead_orderdate,
15126
 
      FALSE,
15127
 
      FALSE,
15128
 
      fetchInvcNumber(),
15129
 
      pAssessDate,
15130
 
      invchead_shipdate,
15131
 
      invchead_ponumber,
15132
 
      invchead_shipvia,
15133
 
      invchead_fob,
15134
 
      invchead_billto_name,
15135
 
      invchead_billto_address1,
15136
 
      invchead_billto_address2,
15137
 
      invchead_billto_address3,
15138
 
      invchead_billto_city,
15139
 
      invchead_billto_state,
15140
 
      invchead_billto_zipcode,
15141
 
      invchead_billto_phone,
15142
 
      invchead_shipto_name,
15143
 
      invchead_shipto_address1,
15144
 
      invchead_shipto_address2,
15145
 
      invchead_shipto_address3,
15146
 
      invchead_shipto_city,
15147
 
      invchead_shipto_state,
15148
 
      invchead_shipto_zipcode,
15149
 
      invchead_shipto_phone,
15150
 
      invchead_salesrep_id,
15151
 
      0.0,
15152
 
      invchead_terms_id,
15153
 
      0.0,
15154
 
      0.0,
15155
 
      NULL,
15156
 
      NULL,
15157
 
      0.0,
15158
 
      NULL,
15159
 
      '',
15160
 
      invchead_billto_country,
15161
 
      invchead_shipto_country,
15162
 
      invchead_prj_id,
15163
 
      invchead_curr_id,
15164
 
      NULL,
15165
 
      FALSE,
15166
 
      NULL,
15167
 
      NULL,
15168
 
      NULL,
15169
 
      NULL,
15170
 
      invchead_shipchrg_id,
15171
 
      invchead_taxzone_id,
15172
 
      invchead_void,
15173
 
      invchead_saletype_id,
15174
 
      invchead_shipzone_id
15175
 
  FROM invchead
15176
 
  WHERE (invchead_invcnumber=_ar.aropen_docnumber)
15177
 
  RETURNING invchead_id INTO _invcheadid;
15178
 
 
15179
 
  -- create invoice item
15180
 
  INSERT INTO invcitem
15181
 
    ( invcitem_invchead_id,
15182
 
      invcitem_linenumber,
15183
 
      invcitem_item_id,
15184
 
      invcitem_warehous_id,
15185
 
      invcitem_custpn,
15186
 
      invcitem_number,
15187
 
      invcitem_descrip,
15188
 
      invcitem_ordered,
15189
 
      invcitem_billed,
15190
 
      invcitem_custprice,
15191
 
      invcitem_price,
15192
 
      invcitem_notes,
15193
 
      invcitem_salescat_id,
15194
 
      invcitem_taxtype_id,
15195
 
      invcitem_qty_uom_id,
15196
 
      invcitem_qty_invuomratio,
15197
 
      invcitem_price_uom_id,
15198
 
      invcitem_price_invuomratio,
15199
 
      invcitem_coitem_id,
15200
 
      invcitem_updateinv,
15201
 
      invcitem_rev_accnt_id )
15202
 
  VALUES
15203
 
    ( _invcheadid,
15204
 
      1,
15205
 
      -1,
15206
 
      -1,
15207
 
      NULL,
15208
 
      _fc.fincharg_markoninvoice,
15209
 
      'Finance Charge Assessment - Invoice Number ' || _ar.aropen_docnumber || ' - Past Due Balance ' || (_ar.aropen_amount - _ar.aropen_paid) || ' Due Date - ' || _ar.aropen_duedate,
15210
 
      1.0,
15211
 
      1.0,
15212
 
      pAssessAmount,
15213
 
      pAssessAmount,
15214
 
      '',
15215
 
      _fc.fincharg_salescat_id,
15216
 
      NULL,
15217
 
      NULL,
15218
 
      1.0,
15219
 
      NULL,
15220
 
      1.0,
15221
 
      NULL,
15222
 
      FALSE,
15223
 
      _fc.fincharg_accnt_id );
15224
 
 
15225
 
  -- update aropen
15226
 
  UPDATE aropen SET aropen_fincharg_date = pAssessDate,
15227
 
                    aropen_fincharg_amount = COALESCE(aropen_fincharg_amount, 0.0) + pAssessAmount
15228
 
  WHERE (aropen_id=pAropenid);
15229
 
 
15230
 
 
15231
 
  RETURN 0;
15232
 
 
15233
 
END;
15234
 
$$;
15235
 
 
15236
 
 
15237
 
ALTER FUNCTION public.assessfinancecharge(paropenid integer, passessdate date, passessamount numeric) OWNER TO admin;
15238
 
 
15239
 
--
15240
 
--
15241
 
 
15242
 
CREATE FUNCTION attachcontact(integer, integer) RETURNS integer
15243
 
    LANGUAGE plpgsql
15244
 
    AS $_$
15245
 
DECLARE
15246
 
  pcntctId    ALIAS FOR $1;
15247
 
  pcrmacctId  ALIAS FOR $2;
15248
 
BEGIN
15249
 
  UPDATE cntct SET cntct_crmacct_id = pcrmacctId
15250
 
  WHERE cntct_id = pcntctId;
15251
 
 
15252
 
  RETURN 0;
15253
 
END;
15254
 
$_$;
15255
 
 
15256
 
 
15257
 
ALTER FUNCTION public.attachcontact(integer, integer) OWNER TO admin;
15258
 
 
15259
 
--
15260
 
--
15261
 
 
15262
 
CREATE FUNCTION attachquotetoopportunity(integer, integer) RETURNS integer
15263
 
    LANGUAGE plpgsql
15264
 
    AS $_$
15265
 
DECLARE
15266
 
  pQuheadid     ALIAS FOR $1;
15267
 
  pOpheadid     ALIAS FOR $2;
15268
 
BEGIN
15269
 
 
15270
 
  IF (NOT EXISTS(SELECT quhead_id
15271
 
                 FROM quhead
15272
 
                 WHERE (quhead_id=pQuheadid))) THEN
15273
 
    RETURN -1;
15274
 
  END IF;
15275
 
 
15276
 
  IF (NOT EXISTS(SELECT ophead_id
15277
 
                 FROM ophead
15278
 
                 WHERE (ophead_id=pOpheadid))) THEN
15279
 
    RETURN -2;
15280
 
  END IF;
15281
 
 
15282
 
  IF (EXISTS(SELECT quhead_id
15283
 
             FROM quhead
15284
 
             WHERE ((quhead_id=pQuheadid)
15285
 
               AND  (quhead_ophead_id IS NOT NULL)))) THEN
15286
 
    RETURN -3;
15287
 
  END IF;
15288
 
 
15289
 
  UPDATE quhead SET quhead_ophead_id=pOpheadid
15290
 
  WHERE (quhead_id=pQuheadid);
15291
 
 
15292
 
  RETURN 0;
15293
 
 
15294
 
END;
15295
 
$_$;
15296
 
 
15297
 
 
15298
 
ALTER FUNCTION public.attachquotetoopportunity(integer, integer) OWNER TO admin;
15299
 
 
15300
 
--
15301
 
--
15302
 
 
15303
 
CREATE FUNCTION attachsalesordertoopportunity(integer, integer) RETURNS integer
15304
 
    LANGUAGE plpgsql
15305
 
    AS $_$
15306
 
DECLARE
15307
 
  pSoheadid     ALIAS FOR $1;
15308
 
  pOpheadid     ALIAS FOR $2;
15309
 
BEGIN
15310
 
 
15311
 
  IF (NOT EXISTS(SELECT cohead_id
15312
 
                 FROM cohead
15313
 
                 WHERE (cohead_id=pSoheadid))) THEN
15314
 
    RETURN -1;
15315
 
  END IF;
15316
 
 
15317
 
  IF (NOT EXISTS(SELECT ophead_id
15318
 
                 FROM ophead
15319
 
                 WHERE (ophead_id=pOpheadid))) THEN
15320
 
    RETURN -2;
15321
 
  END IF;
15322
 
 
15323
 
  IF (EXISTS(SELECT cohead_id
15324
 
             FROM cohead
15325
 
             WHERE ((cohead_id=pSoheadid)
15326
 
               AND  (cohead_ophead_id IS NOT NULL)))) THEN
15327
 
    RETURN -3;
15328
 
  END IF;
15329
 
 
15330
 
  UPDATE cohead SET cohead_ophead_id=pOpheadid
15331
 
  WHERE (cohead_id=pSoheadid);
15332
 
 
15333
 
  RETURN 0;
15334
 
 
15335
 
END;
15336
 
$_$;
15337
 
 
15338
 
 
15339
 
ALTER FUNCTION public.attachsalesordertoopportunity(integer, integer) OWNER TO admin;
15340
 
 
15341
 
--
15342
 
--
15343
 
 
15344
 
CREATE FUNCTION averagesalesprice(integer, date, date) RETURNS numeric
15345
 
    LANGUAGE plpgsql
15346
 
    AS $_$
15347
 
DECLARE
15348
 
  pItemsiteid ALIAS FOR $1;
15349
 
  pStartDate ALIAS FOR $2;
15350
 
  pEndDate ALIAS FOR $3;
15351
 
  _p RECORD;
15352
 
 
15353
 
BEGIN
15354
 
  SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitprice,
15355
 
                                            cohist_shipdate)) AS totalsales,
15356
 
         SUM(cohist_qtyshipped) AS totalship INTO _p
15357
 
  FROM cohist
15358
 
  WHERE ( (cohist_itemsite_id=pItemsiteid)
15359
 
   AND (cohist_invcdate BETWEEN pStartDate AND pEndDate) );
15360
 
 
15361
 
  IF ( (_p.totalship IS NULL) OR
15362
 
       (_p.totalship = 0) ) THEN
15363
 
    RETURN 0;
15364
 
  ELSE
15365
 
    RETURN (_p.totalsales / _p.totalship);
15366
 
  END IF;
15367
 
 
15368
 
END;
15369
 
$_$;
15370
 
 
15371
 
 
15372
 
ALTER FUNCTION public.averagesalesprice(integer, date, date) OWNER TO admin;
15373
 
 
15374
 
--
15375
 
--
15376
 
 
15377
 
CREATE FUNCTION avgcost(pitemsiteid integer) RETURNS numeric
15378
 
    LANGUAGE plpgsql
15379
 
    AS $$
15380
 
DECLARE
15381
 
  _value NUMERIC;
15382
 
  _qoh NUMERIC;
15383
 
BEGIN
15384
 
  SELECT itemsite_value, itemsite_qtyonhand
15385
 
    INTO _value, _qoh
15386
 
    FROM itemsite
15387
 
   WHERE(itemsite_id=pItemsiteid);
15388
 
  IF (_qoh = 0.0) THEN
15389
 
    RETURN 0.0;
15390
 
  END IF;
15391
 
  RETURN _value / _qoh;
15392
 
END;
15393
 
$$;
15394
 
 
15395
 
 
15396
 
ALTER FUNCTION public.avgcost(pitemsiteid integer) OWNER TO admin;
15397
 
 
15398
 
--
15399
 
--
15400
 
 
15401
 
CREATE FUNCTION balanceitemsite(pitemsiteid integer) RETURNS integer
15402
 
    LANGUAGE plpgsql
15403
 
    AS $$
15404
 
DECLARE
15405
 
  _itemlocseries INTEGER;
15406
 
  _balanced NUMERIC;
15407
 
  _qoh NUMERIC;
15408
 
 
15409
 
BEGIN
15410
 
 
15411
 
  IF ( ( SELECT (NOT ( (itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S')) ))
15412
 
         FROM itemsite
15413
 
         WHERE (itemsite_id=pItemsiteid) ) ) THEN
15414
 
    RETURN 0;
15415
 
  END IF;
15416
 
 
15417
 
  IF ( ( SELECT itemsite_freeze
15418
 
           FROM itemsite
15419
 
          WHERE(itemsite_id=pItemsiteid) ) ) THEN
15420
 
    RETURN -1;
15421
 
  END IF;
15422
 
 
15423
 
  SELECT COALESCE(SUM(itemloc_qty), 0) INTO _balanced
15424
 
  FROM itemloc
15425
 
  WHERE (itemloc_itemsite_id=pItemsiteid);
15426
 
 
15427
 
  SELECT invAdjustment( itemsite_id, (_balanced - itemsite_qtyonhand),
15428
 
                        'Balance', 'Inventory Balance' ) INTO _itemlocseries
15429
 
  FROM itemsite
15430
 
  WHERE (itemsite_id=pItemsiteid);
15431
 
 
15432
 
  PERFORM postItemlocSeries(_itemlocseries);
15433
 
 
15434
 
  DELETE FROM itemlocdist
15435
 
  WHERE (itemlocdist_series=_itemlocseries);
15436
 
 
15437
 
  RETURN 1;
15438
 
 
15439
 
END;
15440
 
$$;
15441
 
 
15442
 
 
15443
 
ALTER FUNCTION public.balanceitemsite(pitemsiteid integer) OWNER TO admin;
15444
 
 
15445
 
--
15446
 
--
15447
 
 
15448
 
CREATE FUNCTION bankreconciliation(pbankrecid integer, ptask text) RETURNS integer
15449
 
    LANGUAGE plpgsql
15450
 
    AS $$
15451
 
DECLARE
15452
 
  _accntid      INTEGER;
15453
 
  _bankrecid    INTEGER;
15454
 
  _gltransid    INTEGER;
15455
 
  _post         BOOLEAN;
15456
 
  _r            RECORD;
15457
 
  _result       INTEGER;
15458
 
  _sequence     INTEGER;
15459
 
  _sign         INTEGER := 1;
15460
 
  _tax          RECORD;
15461
 
 
15462
 
BEGIN
15463
 
 
15464
 
  CASE lower(pTask)
15465
 
    WHEN 'post'   THEN _post = TRUE;
15466
 
    WHEN 'reopen' THEN _post = FALSE;
15467
 
    ELSE RAISE EXCEPTION
15468
 
          'bankReconciliation got an invalid task %1 [xtuple: bankReconciliation, -2, %2]',
15469
 
          pTask, pTask;
15470
 
  END CASE;
15471
 
 
15472
 
  -- Check the accnt information to make sure it is valid
15473
 
  SELECT accnt_id INTO _accntid
15474
 
    FROM bankrec
15475
 
    JOIN bankaccnt ON (bankrec_bankaccnt_id=bankaccnt_id)
15476
 
    JOIN accnt     ON (bankaccnt_accnt_id=accnt_id)
15477
 
   WHERE (bankrec_id=pBankrecid);
15478
 
  IF ( NOT FOUND ) THEN
15479
 
    RAISE EXCEPTION 'bankReconciliation %1 %2 did not find the bank''s G/L account [xtuple: bankReconciliation, -1, %3, %4]',
15480
 
                    pTask, pBankrecid, pTask, pBankrecid;
15481
 
  END IF;
15482
 
 
15483
 
  IF _post THEN
15484
 
    DELETE FROM bankrecitem
15485
 
     WHERE ( (NOT bankrecitem_cleared)
15486
 
       AND   (bankrecitem_bankrec_id=pBankrecid) );
15487
 
 
15488
 
    -- Post any cleared bankadj items and convert the bankrecitem
15489
 
    FOR _r IN SELECT bankrecitem_id, bankrecitem_source_id
15490
 
                FROM bankrecitem, bankadj
15491
 
               WHERE ( (bankrecitem_source = 'AD')
15492
 
                 AND   (bankrecitem_source_id=bankadj_id)
15493
 
                 AND   (bankrecitem_cleared)
15494
 
                 AND   (NOT bankadj_posted)
15495
 
                 AND   (bankrecitem_bankrec_id=pBankrecid) ) LOOP
15496
 
 
15497
 
      _sequence := postBankAdjustment(_r.bankrecitem_source_id);
15498
 
 
15499
 
      IF (_sequence < 0) THEN
15500
 
        RAISE EXCEPTION 'postBankAdjustment %1 %2 failed during bankReconciliation [xtuple: postBankAdjustment, -10, %3, %4, %5]',
15501
 
                         pTask, pBankrecid, pTask, pBankrecid, _sequence;
15502
 
      END IF;
15503
 
 
15504
 
      SELECT gltrans_id INTO _gltransid
15505
 
        FROM gltrans
15506
 
       WHERE ( (gltrans_sequence=_sequence)
15507
 
         AND   (gltrans_accnt_id=_accntid) );
15508
 
      IF ( NOT FOUND ) THEN
15509
 
        RAISE EXCEPTION 'bankReconciliation %1 %2 did not find exactly one gltrans record for %3 [xtuple: bankReconciliation, -11, %4, %5, %6]',
15510
 
                        pTask, pBankrecid, _sequence, pTask, pBankrecid, _sequence;
15511
 
      END IF;
15512
 
 
15513
 
      UPDATE bankrecitem
15514
 
         SET bankrecitem_source = 'GL',
15515
 
             bankrecitem_source_id=_gltransid
15516
 
       WHERE (bankrecitem_id=_r.bankrecitem_id);
15517
 
 
15518
 
    END LOOP;
15519
 
 
15520
 
  ELSE -- NOT _post, therefore must be reopen
15521
 
    _sign := -1;
15522
 
    SELECT bankrec_id INTO _bankrecid
15523
 
      FROM bankrec
15524
 
     WHERE (NOT bankrec_posted);
15525
 
    IF (FOUND) THEN
15526
 
      -- Delete any bankrecitem records for unposted periods
15527
 
      DELETE FROM bankrecitem
15528
 
       WHERE (bankrecitem_bankrec_id=_bankrecid);
15529
 
      -- Delete any bankrec records for unposted period
15530
 
      DELETE FROM bankrec
15531
 
       WHERE (bankrec_id=_bankrecid);
15532
 
    END IF;
15533
 
  END IF;
15534
 
 
15535
 
  IF (fetchMetricBool('CashBasedTax')) THEN
15536
 
    -- Cash based tax distributions
15537
 
    -- GL Transactions
15538
 
    SELECT fetchGLSequence() INTO _sequence;
15539
 
    FOR _r IN SELECT *
15540
 
              FROM bankrecitem
15541
 
             WHERE ( (bankrecitem_cleared)
15542
 
               AND   (bankrecitem_bankrec_id=pBankrecid) ) LOOP
15543
 
      -- first, debit the tax liability clearing account
15544
 
      -- and credit the tax liability distribution account
15545
 
      -- for each tax code
15546
 
      FOR _tax IN SELECT docnumber, custname, distdate, source, doctype,
15547
 
                         tax_sales_accnt_id, tax_dist_accnt_id,
15548
 
                         ROUND(currToBase(currid, ROUND(SUM(taxhist_tax),2), taxhist_docdate) * percentpaid, 2) AS taxbasevalue
15549
 
                  FROM (
15550
 
                        -- Cash receipt, gltrans
15551
 
                        SELECT aropen_docnumber AS docnumber, cust_name AS custname,
15552
 
                               aropen_curr_id AS currid, gltrans_date AS distdate,
15553
 
                               (cashrcptitem_amount / aropen_amount) AS percentpaid,
15554
 
                               gltrans_source AS source, gltrans_doctype AS doctype,
15555
 
                               tax_sales_accnt_id, tax_dist_accnt_id,
15556
 
                               taxhist_tax, taxhist_docdate
15557
 
                        FROM gltrans JOIN cashrcpt  ON ((gltrans_source='A/R')
15558
 
                                                    AND (gltrans_doctype='CR')
15559
 
                                                    AND (gltrans_misc_id=cashrcpt_id))
15560
 
                                     JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id)
15561
 
                                     JOIN aropen ON (aropen_id=cashrcptitem_aropen_id)
15562
 
                                     JOIN custinfo ON (cust_id=aropen_cust_id)
15563
 
                                     JOIN cohist ON (cohist_invcnumber=aropen_docnumber AND cohist_doctype=aropen_doctype)
15564
 
                                     JOIN cohisttax ON (taxhist_parent_id=cohist_id)
15565
 
                                     JOIN tax ON (tax_id=taxhist_tax_id)
15566
 
                        WHERE (gltrans_id=_r.bankrecitem_source_id)
15567
 
                        -- Cash receipt, sltrans
15568
 
                        UNION
15569
 
                        SELECT aropen_docnumber AS docnumber, cust_name AS custname,
15570
 
                               aropen_curr_id AS currid, sltrans_date AS distdate,
15571
 
                               (cashrcptitem_amount / aropen_amount) AS percentpaid,
15572
 
                               sltrans_source AS source, sltrans_doctype AS doctype,
15573
 
                               tax_sales_accnt_id, tax_dist_accnt_id,
15574
 
                               taxhist_tax, taxhist_docdate
15575
 
                        FROM sltrans JOIN cashrcpt  ON ((sltrans_source='A/R')
15576
 
                                                    AND (sltrans_doctype='CR')
15577
 
                                                    AND (sltrans_misc_id=cashrcpt_id))
15578
 
                                     JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id)
15579
 
                                     JOIN aropen ON (aropen_id=cashrcptitem_aropen_id)
15580
 
                                     JOIN custinfo ON (cust_id=aropen_cust_id)
15581
 
                                     JOIN cohist ON (cohist_invcnumber=aropen_docnumber AND cohist_doctype=aropen_doctype)
15582
 
                                     JOIN cohisttax ON (taxhist_parent_id=cohist_id)
15583
 
                                     JOIN tax ON (tax_id=taxhist_tax_id)
15584
 
                        WHERE (sltrans_id=_r.bankrecitem_source_id)
15585
 
                        -- Cash payment, gltrans
15586
 
                        UNION
15587
 
                        SELECT apopen_docnumber AS docnumber, vend_name AS vendname,
15588
 
                               apopen_curr_id AS currid, gltrans_date AS distdate,
15589
 
                               (vohead_amount / apopen_amount) AS percentpaid,
15590
 
                               gltrans_source AS source, gltrans_doctype AS doctype,
15591
 
                               tax_sales_accnt_id, tax_dist_accnt_id,
15592
 
                               taxhist_tax, taxhist_docdate
15593
 
                        FROM gltrans JOIN checkhead ON ((gltrans_source='A/P')
15594
 
                                                    AND (gltrans_doctype='CK')
15595
 
                                                    AND (gltrans_misc_id=checkhead_id))
15596
 
                                     JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)
15597
 
                                     JOIN apopen ON (apopen_id=checkitem_apopen_id)
15598
 
                                     JOIN vohead ON (vohead_number=apopen_docnumber)
15599
 
                                     JOIN vendinfo ON (vend_id=apopen_vend_id)
15600
 
                                     JOIN voheadtax ON (taxhist_parent_id=vohead_id)
15601
 
                                     JOIN tax ON (tax_id=taxhist_tax_id)
15602
 
                        WHERE (gltrans_id=_r.bankrecitem_source_id)
15603
 
                        UNION
15604
 
                        SELECT apopen_docnumber AS docnumber, vend_name AS vendname,
15605
 
                               apopen_curr_id AS currid, gltrans_date AS distdate,
15606
 
                               (vohead_amount / apopen_amount) AS percentpaid,
15607
 
                               gltrans_source AS source, gltrans_doctype AS doctype,
15608
 
                               tax_sales_accnt_id, tax_dist_accnt_id,
15609
 
                               taxhist_tax, taxhist_docdate
15610
 
                        FROM gltrans JOIN checkhead ON ((gltrans_source='A/P')
15611
 
                                                    AND (gltrans_doctype='CK')
15612
 
                                                    AND (gltrans_misc_id=checkhead_id))
15613
 
                                     JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)
15614
 
                                     JOIN apopen ON (apopen_id=checkitem_apopen_id)
15615
 
                                     JOIN vohead ON (vohead_number=apopen_docnumber)
15616
 
                                     JOIN vendinfo ON (vend_id=apopen_vend_id)
15617
 
                                     JOIN voitem ON (voitem_vohead_id=vohead_id)
15618
 
                                     JOIN voitemtax ON (taxhist_parent_id=voitem_id)
15619
 
                                     JOIN tax ON (tax_id=taxhist_tax_id)
15620
 
                        WHERE (gltrans_id=_r.bankrecitem_source_id)
15621
 
                        -- Cash payment, sltrans
15622
 
                        UNION
15623
 
                        SELECT apopen_docnumber AS docnumber, vend_name AS vendname,
15624
 
                               apopen_curr_id AS currid, sltrans_date AS distdate,
15625
 
                               (vohead_amount / apopen_amount) AS percentpaid,
15626
 
                               sltrans_source AS source, sltrans_doctype AS doctype,
15627
 
                               tax_sales_accnt_id, tax_dist_accnt_id,
15628
 
                               taxhist_tax, taxhist_docdate
15629
 
                        FROM sltrans JOIN checkhead ON ((sltrans_source='A/P')
15630
 
                                                    AND (sltrans_doctype='CK')
15631
 
                                                    AND (sltrans_misc_id=checkhead_id))
15632
 
                                     JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)
15633
 
                                     JOIN apopen ON (apopen_id=checkitem_apopen_id)
15634
 
                                     JOIN vohead ON (vohead_number=apopen_docnumber)
15635
 
                                     JOIN vendinfo ON (vend_id=apopen_vend_id)
15636
 
                                     JOIN voheadtax ON (taxhist_parent_id=vohead_id)
15637
 
                                     JOIN tax ON (tax_id=taxhist_tax_id)
15638
 
                        WHERE (sltrans_id=_r.bankrecitem_source_id)
15639
 
                        UNION
15640
 
                        SELECT apopen_docnumber AS docnumber, vend_name AS vendname,
15641
 
                               apopen_curr_id AS currid, sltrans_date AS distdate,
15642
 
                               (vohead_amount / apopen_amount) AS percentpaid,
15643
 
                               sltrans_source AS source, sltrans_doctype AS doctype,
15644
 
                               tax_sales_accnt_id, tax_dist_accnt_id,
15645
 
                               taxhist_tax, taxhist_docdate
15646
 
                        FROM sltrans JOIN checkhead ON ((sltrans_source='A/P')
15647
 
                                                    AND (sltrans_doctype='CK')
15648
 
                                                    AND (sltrans_misc_id=checkhead_id))
15649
 
                                     JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)
15650
 
                                     JOIN apopen ON (apopen_id=checkitem_apopen_id)
15651
 
                                     JOIN vohead ON (vohead_number=apopen_docnumber)
15652
 
                                     JOIN vendinfo ON (vend_id=apopen_vend_id)
15653
 
                                     JOIN voitem ON (voitem_vohead_id=vohead_id)
15654
 
                                     JOIN voitemtax ON (taxhist_parent_id=voitem_id)
15655
 
                                     JOIN tax ON (tax_id=taxhist_tax_id)
15656
 
                        WHERE (sltrans_id=_r.bankrecitem_source_id)
15657
 
                       ) AS data
15658
 
                  GROUP BY docnumber, custname, currid, distdate, percentpaid,
15659
 
                           source, doctype,
15660
 
                           tax_sales_accnt_id, tax_dist_accnt_id, taxhist_docdate
15661
 
      LOOP
15662
 
        SELECT insertIntoGLSeries( _sequence, _tax.source, _tax.doctype, _tax.docnumber,
15663
 
                                   _tax.tax_dist_accnt_id, 
15664
 
                                   _tax.taxbasevalue * _sign,
15665
 
                                   COALESCE(_r.bankrecitem_effdate, _tax.distdate), _tax.custname ) INTO _result;
15666
 
        IF (_result < 0) THEN
15667
 
          RAISE EXCEPTION 'insertIntoGLSeries failed, result=%', _result;
15668
 
        END IF;
15669
 
        SELECT insertIntoGLSeries( _sequence, _tax.source, _tax.doctype, _tax.docnumber,
15670
 
                                   _tax.tax_sales_accnt_id, 
15671
 
                                   (_tax.taxbasevalue * -1.0 * _sign),
15672
 
                                   COALESCE(_r.bankrecitem_effdate, _tax.distdate), _tax.custname ) INTO _result;
15673
 
        IF (_result < 0) THEN
15674
 
          RAISE EXCEPTION 'insertIntoGLSeries failed, result=%', _result;
15675
 
        END IF;
15676
 
      END LOOP;
15677
 
 
15678
 
      -- second, create a taxpay row for each taxhist
15679
 
      FOR _tax IN SELECT taxhist_id, applyid, distdate,
15680
 
                         ROUND(taxhist_tax * percentpaid, 2) AS taxpaid
15681
 
                  FROM (
15682
 
                        -- Cash receipt, gltrans
15683
 
                        SELECT taxhist_id, aropen_id AS applyid, gltrans_date AS distdate, taxhist_tax,
15684
 
                               (cashrcptitem_amount / aropen_amount) AS percentpaid
15685
 
                          FROM gltrans JOIN cashrcpt  ON ((gltrans_source='A/R')
15686
 
                                                      AND (gltrans_doctype='CR')
15687
 
                                                      AND (gltrans_misc_id=cashrcpt_id))
15688
 
                                       JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id)
15689
 
                                       JOIN aropen ON (aropen_id=cashrcptitem_aropen_id)
15690
 
                                       JOIN cohist ON (cohist_invcnumber=aropen_docnumber AND cohist_doctype=aropen_doctype)
15691
 
                                       JOIN cohisttax ON (taxhist_parent_id=cohist_id)
15692
 
                          WHERE (gltrans_id=_r.bankrecitem_source_id)
15693
 
                        -- Cash receipt, sltrans
15694
 
                        UNION
15695
 
                        SELECT taxhist_id, aropen_id AS applyid, sltrans_date AS distdate, taxhist_tax,
15696
 
                               (cashrcptitem_amount / aropen_amount) AS percentpaid
15697
 
                          FROM sltrans JOIN cashrcpt  ON ((sltrans_source='A/R')
15698
 
                                                      AND (sltrans_doctype='CR')
15699
 
                                                      AND (sltrans_misc_id=cashrcpt_id))
15700
 
                                       JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id)
15701
 
                                       JOIN aropen ON (aropen_id=cashrcptitem_aropen_id)
15702
 
                                       JOIN cohist ON (cohist_invcnumber=aropen_docnumber AND cohist_doctype=aropen_doctype)
15703
 
                                       JOIN cohisttax ON (taxhist_parent_id=cohist_id)
15704
 
                          WHERE (sltrans_id=_r.bankrecitem_source_id)
15705
 
                        -- Cash payment, gltrans
15706
 
                        UNION
15707
 
                        SELECT taxhist_id, apopen_id AS applyid, gltrans_date AS distdate, taxhist_tax,
15708
 
                               (checkitem_amount / apopen_amount) AS percentpaid
15709
 
                          FROM gltrans JOIN checkhead  ON ((gltrans_source='A/P')
15710
 
                                                       AND (gltrans_doctype='CK')
15711
 
                                                       AND (gltrans_misc_id=checkhead_id))
15712
 
                                       JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)
15713
 
                                       JOIN apopen ON (apopen_id=checkitem_apopen_id)
15714
 
                                       JOIN vohead ON (vohead_number=apopen_docnumber)
15715
 
                                       JOIN voheadtax ON (taxhist_parent_id=vohead_id)
15716
 
                          WHERE (gltrans_id=_r.bankrecitem_source_id)
15717
 
                        UNION
15718
 
                        SELECT taxhist_id, apopen_id AS applyid, gltrans_date AS distdate, taxhist_tax,
15719
 
                               (checkitem_amount / apopen_amount) AS percentpaid
15720
 
                          FROM gltrans JOIN checkhead  ON ((gltrans_source='A/P')
15721
 
                                                       AND (gltrans_doctype='CK')
15722
 
                                                       AND (gltrans_misc_id=checkhead_id))
15723
 
                                       JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)
15724
 
                                       JOIN apopen ON (apopen_id=checkitem_apopen_id)
15725
 
                                       JOIN vohead ON (vohead_number=apopen_docnumber)
15726
 
                                       JOIN voitem ON (voitem_vohead_id=vohead_id)
15727
 
                                       JOIN voitemtax ON (taxhist_parent_id=voitem_id)
15728
 
                          WHERE (gltrans_id=_r.bankrecitem_source_id)
15729
 
                        -- Cash payment, sltrans
15730
 
                        UNION
15731
 
                        SELECT taxhist_id, apopen_id AS applyid, sltrans_date AS distdate, taxhist_tax,
15732
 
                               (checkitem_amount / apopen_amount) AS percentpaid
15733
 
                          FROM sltrans JOIN checkhead  ON ((sltrans_source='A/P')
15734
 
                                                       AND (sltrans_doctype='CK')
15735
 
                                                       AND (sltrans_misc_id=checkhead_id))
15736
 
                                       JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)
15737
 
                                       JOIN apopen ON (apopen_id=checkitem_apopen_id)
15738
 
                                       JOIN vohead ON (vohead_number=apopen_docnumber)
15739
 
                                       JOIN voheadtax ON (taxhist_parent_id=vohead_id)
15740
 
                          WHERE (sltrans_id=_r.bankrecitem_source_id)
15741
 
                        UNION
15742
 
                        SELECT taxhist_id, apopen_id AS applyid, sltrans_date AS distdate, taxhist_tax,
15743
 
                               (checkitem_amount / apopen_amount) AS percentpaid
15744
 
                          FROM sltrans JOIN checkhead  ON ((sltrans_source='A/P')
15745
 
                                                       AND (sltrans_doctype='CK')
15746
 
                                                       AND (sltrans_misc_id=checkhead_id))
15747
 
                                       JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)
15748
 
                                       JOIN apopen ON (apopen_id=checkitem_apopen_id)
15749
 
                                       JOIN vohead ON (vohead_number=apopen_docnumber)
15750
 
                                       JOIN voitem ON (voitem_vohead_id=vohead_id)
15751
 
                                       JOIN voitemtax ON (taxhist_parent_id=voitem_id)
15752
 
                          WHERE (sltrans_id=_r.bankrecitem_source_id)
15753
 
                       ) AS data
15754
 
      LOOP
15755
 
        IF _post THEN
15756
 
          INSERT INTO taxpay
15757
 
          ( taxpay_taxhist_id, taxpay_apply_id, taxpay_distdate, taxpay_tax )
15758
 
          VALUES
15759
 
          ( _tax.taxhist_id, _tax.applyid, COALESCE(_r.bankrecitem_effdate, _tax.distdate), _tax.taxpaid );
15760
 
        ELSE
15761
 
          DELETE FROM taxpay
15762
 
          WHERE ((taxpay_taxhist_id=_tax.taxhist_id)
15763
 
             AND (taxpay_apply_id=_tax.applyid)
15764
 
             AND (taxpay_distdate=COALESCE(_r.bankrecitem_effdate, _tax.distdate))
15765
 
             AND (taxpay_tax=_tax.taxpaid));
15766
 
        END IF;
15767
 
      END LOOP;
15768
 
 
15769
 
    END LOOP;
15770
 
 
15771
 
    SELECT postGLSeries(_sequence, fetchJournalNumber('GL-MISC')) INTO _result;
15772
 
    IF (_result < 0) THEN
15773
 
      RAISE EXCEPTION 'postGLSeries failed, result=%', _result;
15774
 
    END IF;
15775
 
 
15776
 
  END IF;
15777
 
 
15778
 
  UPDATE gltrans
15779
 
     SET gltrans_rec = _post
15780
 
   WHERE ( (gltrans_id IN (SELECT bankrecitem_source_id
15781
 
                             FROM bankrecitem
15782
 
                            WHERE ((bankrecitem_source = 'GL')
15783
 
                              AND  (bankrecitem_cleared)
15784
 
                              AND  (bankrecitem_bankrec_id=pBankrecid) ) ) )
15785
 
     AND   (gltrans_accnt_id=_accntid) ) ;
15786
 
 
15787
 
  UPDATE sltrans
15788
 
     SET sltrans_rec = _post
15789
 
   WHERE ( (sltrans_id IN (SELECT bankrecitem_source_id
15790
 
                             FROM bankrecitem
15791
 
                            WHERE ((bankrecitem_source = 'SL')
15792
 
                              AND  (bankrecitem_cleared)
15793
 
                              AND  (bankrecitem_bankrec_id=pBankrecid) ) ) )
15794
 
     AND   (sltrans_accnt_id=_accntid) ) ;
15795
 
 
15796
 
  UPDATE bankrec SET 
15797
 
    bankrec_posted = _post,
15798
 
    bankrec_postdate = CASE _post WHEN TRUE THEN now() ELSE NULL END
15799
 
   WHERE (bankrec_id=pBankrecid);
15800
 
 
15801
 
  RETURN pBankrecid;
15802
 
END;
15803
 
$$;
15804
 
 
15805
 
 
15806
 
ALTER FUNCTION public.bankreconciliation(pbankrecid integer, ptask text) OWNER TO admin;
15807
 
 
15808
 
--
15809
 
--
15810
 
 
15811
 
CREATE FUNCTION bomcontains(integer, integer) RETURNS boolean
15812
 
    LANGUAGE plpgsql
15813
 
    AS $_$
15814
 
DECLARE
15815
 
  pparentitemid ALIAS FOR $1;
15816
 
  pchilditemid  ALIAS FOR $2;
15817
 
  _bomworksetid INTEGER;
15818
 
  _result       BOOLEAN;
15819
 
 
15820
 
BEGIN
15821
 
  _bomworksetid := indentedWhereUsed(pchilditemid);
15822
 
  _result := EXISTS(SELECT bomwork_id
15823
 
                    FROM bomwork
15824
 
                    WHERE ((bomwork_set_id=_bomworksetid)
15825
 
                      AND  (bomwork_item_id=pparentitemid) ));
15826
 
 
15827
 
  PERFORM deleteBOMWorkset(_bomworksetid);
15828
 
 
15829
 
  RETURN _result;
15830
 
END;
15831
 
$_$;
15832
 
 
15833
 
 
15834
 
ALTER FUNCTION public.bomcontains(integer, integer) OWNER TO admin;
15835
 
 
15836
 
--
15837
 
--
15838
 
 
15839
 
CREATE FUNCTION bomhistsequence(integer) RETURNS text
15840
 
    LANGUAGE plpgsql
15841
 
    AS $_$
15842
 
DECLARE
15843
 
  pHistid ALIAS FOR $1;
15844
 
  _wid INTEGER;
15845
 
  _seqnum TEXT;
15846
 
  _bomhist RECORD;
15847
 
 
15848
 
BEGIN
15849
 
  _wid := pHistid;
15850
 
 
15851
 
  SELECT bomhist_parent_id AS parent,
15852
 
         to_char(bomhist_seqnumber, '00009') AS seq INTO _bomhist
15853
 
    FROM bomhist
15854
 
   WHERE bomhist_seq_id=_wid;
15855
 
 
15856
 
  IF (FOUND) THEN
15857
 
    _seqnum := _bomhist.seq;
15858
 
    _wid := _bomhist.parent;
15859
 
 
15860
 
    WHILE (_wid != -1) LOOP
15861
 
      SELECT bomhist_parent_id AS parent,
15862
 
             to_char(bomhist_seqnumber, '00009') AS seq INTO _bomhist
15863
 
      FROM bomhist
15864
 
      WHERE bomhist_seq_id=_wid;
15865
 
 
15866
 
      IF (FOUND) THEN
15867
 
        _seqnum := _bomhist.seq || '-' || _seqnum;
15868
 
        _wid    := _bomhist.parent;
15869
 
      ELSE
15870
 
        _wid := -1;
15871
 
      END IF;
15872
 
    END LOOP;
15873
 
  ELSE
15874
 
    _seqnum := ''::TEXT;
15875
 
  END IF;
15876
 
 
15877
 
  RETURN _seqnum;
15878
 
END;
15879
 
$_$;
15880
 
 
15881
 
 
15882
 
ALTER FUNCTION public.bomhistsequence(integer) OWNER TO admin;
15883
 
 
15884
 
--
15885
 
--
15886
 
 
15887
 
CREATE TABLE bomitem (
15888
 
    bomitem_id integer DEFAULT nextval(('bomitem_bomitem_id_seq'::text)::regclass) NOT NULL,
15889
 
    bomitem_parent_item_id integer NOT NULL,
15890
 
    bomitem_seqnumber integer,
15891
 
    bomitem_item_id integer NOT NULL,
15892
 
    bomitem_qtyper numeric(20,8) NOT NULL,
15893
 
    bomitem_scrap numeric(8,4) NOT NULL,
15894
 
    bomitem_status character(1),
15895
 
    bomitem_effective date NOT NULL,
15896
 
    bomitem_expires date NOT NULL,
15897
 
    bomitem_createwo boolean NOT NULL,
15898
 
    bomitem_issuemethod character(1) NOT NULL,
15899
 
    bomitem_schedatwooper boolean NOT NULL,
15900
 
    bomitem_ecn text,
15901
 
    bomitem_moddate date,
15902
 
    bomitem_subtype character(1) NOT NULL,
15903
 
    bomitem_uom_id integer NOT NULL,
15904
 
    bomitem_rev_id integer DEFAULT (-1),
15905
 
    bomitem_booitem_seq_id integer DEFAULT (-1),
15906
 
    bomitem_char_id integer,
15907
 
    bomitem_value text,
15908
 
    bomitem_notes text,
15909
 
    bomitem_ref text,
15910
 
    bomitem_qtyfxd numeric(20,8) DEFAULT 0 NOT NULL,
15911
 
    bomitem_issuewo boolean DEFAULT false NOT NULL,
15912
 
    CONSTRAINT bomitem_bomitem_issuemethod_check CHECK ((((bomitem_issuemethod = 'M'::bpchar) OR (bomitem_issuemethod = 'S'::bpchar)) OR (bomitem_issuemethod = 'L'::bpchar))),
15913
 
    CONSTRAINT bomitem_bomitem_subtype_check CHECK ((((bomitem_subtype = 'N'::bpchar) OR (bomitem_subtype = 'I'::bpchar)) OR (bomitem_subtype = 'B'::bpchar)))
15914
 
);
15915
 
 
15916
 
 
15917
 
ALTER TABLE public.bomitem OWNER TO admin;
15918
 
 
15919
 
--
15920
 
--
15921
 
 
15922
 
COMMENT ON TABLE bomitem IS 'Bill of Materials (BOM) component Items information';
15923
 
 
15924
 
 
15925
 
--
15926
 
--
15927
 
 
15928
 
COMMENT ON COLUMN bomitem.bomitem_qtyfxd IS 'The fixed quantity required';
15929
 
 
15930
 
 
15931
 
--
15932
 
--
15933
 
 
15934
 
CREATE FUNCTION bomitem(integer) RETURNS SETOF bomitem
15935
 
    LANGUAGE sql
15936
 
    AS $_$
15937
 
  SELECT * FROM bomitem WHERE ((bomitem_parent_item_id=$1) AND (bomitem_rev_id=getActiveRevId('BOM',$1)));
15938
 
$_$;
15939
 
 
15940
 
 
15941
 
ALTER FUNCTION public.bomitem(integer) OWNER TO admin;
15942
 
 
15943
 
--
15944
 
--
15945
 
 
15946
 
CREATE FUNCTION bomitem(integer, integer) RETURNS SETOF bomitem
15947
 
    LANGUAGE sql
15948
 
    AS $_$
15949
 
  SELECT * FROM bomitem WHERE ((bomitem_parent_item_id=$1) AND (bomitem_rev_id=$2));
15950
 
$_$;
15951
 
 
15952
 
 
15953
 
ALTER FUNCTION public.bomitem(integer, integer) OWNER TO admin;
15954
 
 
15955
 
--
15956
 
--
15957
 
 
15958
 
CREATE FUNCTION bomlevelbyitem(integer) RETURNS integer
15959
 
    LANGUAGE plpgsql
15960
 
    AS $_$
15961
 
DECLARE
15962
 
  pItemid ALIAS FOR $1;
15963
 
  _cnt INTEGER;
15964
 
  _result INTEGER;
15965
 
  _bomitem RECORD;
15966
 
 
15967
 
BEGIN
15968
 
  _cnt := 0;
15969
 
 
15970
 
  BEGIN
15971
 
  FOR _bomitem IN SELECT bomitem_parent_item_id
15972
 
                    FROM bomitem
15973
 
                   WHERE ((bomitem_item_id=pItemid)
15974
 
                     AND  (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id))
15975
 
                     AND  (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1)))
15976
 
  LOOP
15977
 
    SELECT bomLevelByItem(_bomitem.bomitem_parent_item_id) + 1 INTO _result;
15978
 
    IF (_result > _cnt) THEN
15979
 
      _cnt := _result;
15980
 
    END IF;
15981
 
  END LOOP;
15982
 
  EXCEPTION WHEN statement_too_complex THEN
15983
 
      RAISE EXCEPTION 'potential recursive BOM found for item_id %', pItemid;
15984
 
  END;
15985
 
 
15986
 
  return _cnt;
15987
 
END;
15988
 
$_$;
15989
 
 
15990
 
 
15991
 
ALTER FUNCTION public.bomlevelbyitem(integer) OWNER TO admin;
15992
 
 
15993
 
--
15994
 
--
15995
 
 
15996
 
CREATE FUNCTION bomlevelbyitem(integer, integer) RETURNS integer
15997
 
    LANGUAGE plpgsql
15998
 
    AS $_$
15999
 
DECLARE
16000
 
  pItemid ALIAS FOR $1;
16001
 
  pBomrevid ALIAS FOR $2;
16002
 
  _cnt INTEGER;
16003
 
  _result INTEGER;
16004
 
  _bomitem RECORD;
16005
 
 
16006
 
BEGIN
16007
 
  _cnt := 0;
16008
 
 
16009
 
  BEGIN
16010
 
  FOR _bomitem IN SELECT bomitem_parent_item_id
16011
 
                    FROM bomitem
16012
 
                   WHERE ((bomitem_item_id=pItemid)
16013
 
                     AND  (bomitem_rev_id=pBomrevid)
16014
 
                     AND  (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1)))
16015
 
  LOOP
16016
 
    SELECT bomLevelByItem(_bomitem.bomitem_parent_item_id, pBomrevid) + 1 INTO _result;
16017
 
    IF (_result > _cnt) THEN
16018
 
      _cnt := _result;
16019
 
    END IF;
16020
 
  END LOOP;
16021
 
  EXCEPTION WHEN statement_too_complex THEN
16022
 
      RAISE EXCEPTION 'potential recursive BOM found for item_id %', pItemid;
16023
 
  END;
16024
 
 
16025
 
  return _cnt;
16026
 
END;
16027
 
$_$;
16028
 
 
16029
 
 
16030
 
ALTER FUNCTION public.bomlevelbyitem(integer, integer) OWNER TO admin;
16031
 
 
16032
 
--
16033
 
--
16034
 
 
16035
 
CREATE FUNCTION bomworkeffective(integer, date) RETURNS boolean
16036
 
    LANGUAGE plpgsql
16037
 
    AS $_$
16038
 
DECLARE
16039
 
    workid ALIAS FOR $1;
16040
 
    effdate ALIAS FOR $2;
16041
 
    _wid INTEGER;
16042
 
    _bomwork RECORD;
16043
 
BEGIN
16044
 
    _wid := workid;
16045
 
    WHILE (_wid != -1) LOOP
16046
 
        SELECT bomwork_parent_id AS parent,
16047
 
               bomwork_effective AS effective
16048
 
          INTO _bomwork
16049
 
          FROM bomwork
16050
 
         WHERE bomwork_id=_wid;
16051
 
 
16052
 
         IF (FOUND) THEN
16053
 
             _wid := _bomwork.parent;
16054
 
             IF (_bomwork.effective > effdate) THEN
16055
 
                 RETURN FALSE;
16056
 
             END IF;
16057
 
         ELSE
16058
 
             _wid := -1;
16059
 
         END IF;
16060
 
    END LOOP;
16061
 
    RETURN TRUE;
16062
 
END;
16063
 
$_$;
16064
 
 
16065
 
 
16066
 
ALTER FUNCTION public.bomworkeffective(integer, date) OWNER TO admin;
16067
 
 
16068
 
--
16069
 
--
16070
 
 
16071
 
CREATE FUNCTION bomworkexpired(integer, date) RETURNS boolean
16072
 
    LANGUAGE plpgsql
16073
 
    AS $_$
16074
 
DECLARE
16075
 
    workid ALIAS FOR $1;
16076
 
    expdate ALIAS FOR $2;
16077
 
    _wid INTEGER;
16078
 
    _bomwork RECORD;
16079
 
BEGIN
16080
 
    _wid := workid;
16081
 
    WHILE (_wid != -1) LOOP
16082
 
        SELECT bomwork_parent_id AS parent,
16083
 
               bomwork_expires AS expires
16084
 
          INTO _bomwork
16085
 
          FROM bomwork
16086
 
         WHERE bomwork_id=_wid;
16087
 
 
16088
 
         IF (FOUND) THEN
16089
 
             _wid := _bomwork.parent;
16090
 
             IF (_bomwork.expires <= expdate) THEN
16091
 
                 RETURN TRUE;
16092
 
             END IF;
16093
 
         ELSE
16094
 
             _wid := -1;
16095
 
         END IF;
16096
 
    END LOOP;
16097
 
    RETURN FALSE;
16098
 
END;
16099
 
$_$;
16100
 
 
16101
 
 
16102
 
ALTER FUNCTION public.bomworkexpired(integer, date) OWNER TO admin;
16103
 
 
16104
 
--
16105
 
--
16106
 
 
16107
 
CREATE FUNCTION bomworkitemsequence(integer) RETURNS text
16108
 
    LANGUAGE plpgsql
16109
 
    AS $_$
16110
 
DECLARE
16111
 
  pWorkid ALIAS FOR $1;
16112
 
  _wid INTEGER;
16113
 
  _seqnum TEXT;
16114
 
  _bomwork RECORD;
16115
 
 
16116
 
BEGIN
16117
 
  _wid := pWorkid;
16118
 
 
16119
 
  SELECT bomwork_parent_id AS parent,
16120
 
         item_number AS seq INTO _bomwork
16121
 
    FROM bomwork, item
16122
 
   WHERE ((bomwork_id=_wid)
16123
 
   AND (bomwork_item_id=item_id));
16124
 
 
16125
 
  IF (FOUND) THEN
16126
 
    _seqnum := _bomwork.seq;
16127
 
    _wid := _bomwork.parent;
16128
 
 
16129
 
    WHILE (_wid != -1) LOOP
16130
 
      SELECT bomwork_parent_id AS parent,
16131
 
             item_number AS seq INTO _bomwork
16132
 
      FROM bomwork, item
16133
 
      WHERE ((bomwork_id=_wid)
16134
 
      AND (bomwork_item_id=item_id));
16135
 
 
16136
 
      IF (FOUND) THEN
16137
 
        _seqnum := _bomwork.seq || '-' || _seqnum;
16138
 
        _wid    := _bomwork.parent;
16139
 
      ELSE
16140
 
        _wid := -1;
16141
 
      END IF;
16142
 
    END LOOP;
16143
 
  ELSE
16144
 
    _seqnum := ''::TEXT;
16145
 
  END IF;
16146
 
 
16147
 
  RETURN _seqnum;
16148
 
END;
16149
 
$_$;
16150
 
 
16151
 
 
16152
 
ALTER FUNCTION public.bomworkitemsequence(integer) OWNER TO admin;
16153
 
 
16154
 
--
16155
 
--
16156
 
 
16157
 
CREATE FUNCTION bomworksequence(integer) RETURNS text
16158
 
    LANGUAGE plpgsql
16159
 
    AS $_$
16160
 
DECLARE
16161
 
  pWorkid ALIAS FOR $1;
16162
 
  _wid INTEGER;
16163
 
  _seqnum TEXT;
16164
 
  _bomwork RECORD;
16165
 
 
16166
 
BEGIN
16167
 
  _wid := pWorkid;
16168
 
 
16169
 
  SELECT bomwork_parent_id AS parent,
16170
 
         to_char(bomwork_seqnumber, '00009') AS seq INTO _bomwork
16171
 
    FROM bomwork
16172
 
   WHERE bomwork_id=_wid;
16173
 
 
16174
 
  IF (FOUND) THEN
16175
 
    _seqnum := _bomwork.seq;
16176
 
    _wid := _bomwork.parent;
16177
 
 
16178
 
    WHILE (_wid != -1) LOOP
16179
 
      SELECT bomwork_parent_id AS parent,
16180
 
             to_char(bomwork_seqnumber, '00009') AS seq INTO _bomwork
16181
 
      FROM bomwork
16182
 
      WHERE bomwork_id=_wid;
16183
 
 
16184
 
      IF (FOUND) THEN
16185
 
        _seqnum := _bomwork.seq || '-' || _seqnum;
16186
 
        _wid    := _bomwork.parent;
16187
 
      ELSE
16188
 
        _wid := -1;
16189
 
      END IF;
16190
 
    END LOOP;
16191
 
  ELSE
16192
 
    _seqnum := ''::TEXT;
16193
 
  END IF;
16194
 
 
16195
 
  RETURN _seqnum;
16196
 
END;
16197
 
$_$;
16198
 
 
16199
 
 
16200
 
ALTER FUNCTION public.bomworksequence(integer) OWNER TO admin;
16201
 
 
16202
 
--
16203
 
--
16204
 
 
16205
 
CREATE FUNCTION buildinvbal(integer) RETURNS integer
16206
 
    LANGUAGE plpgsql
16207
 
    AS $_$
16208
 
DECLARE
16209
 
  pItemsiteId ALIAS FOR $1;
16210
 
  _r RECORD;
16211
 
  _prevCostmethod TEXT := 'A';
16212
 
  _prevDate TIMESTAMP WITH TIME ZONE;
16213
 
  _runningQty NUMERIC := 0;
16214
 
  _runningNn NUMERIC := 0;
16215
 
 
16216
 
BEGIN
16217
 
  -- Validate
16218
 
  IF (SELECT (count(invhist_id) > 0)
16219
 
      FROM invhist
16220
 
      WHERE ((invhist_itemsite_id=pItemsiteId)
16221
 
      AND (NOT invhist_posted))) THEN
16222
 
 
16223
 
    SELECT item_number, warehous_code INTO _r
16224
 
    FROM itemsite
16225
 
      JOIN item ON (item_id=itemsite_item_id)
16226
 
      JOIN whsinfo ON (itemsite_warehous_id=warehous_id)
16227
 
    WHERE (itemsite_id=pItemsiteId);
16228
 
    
16229
 
    RAISE EXCEPTION 'Unposted inventory transactions exist for % at % [xtuple: buildInvBal, -1, %, %]',
16230
 
                    _r.item_number, _r.warehous_code,
16231
 
                    _r.item_number, _r.warehous_code;
16232
 
  END IF;
16233
 
 
16234
 
  -- Remove any old records
16235
 
  DELETE FROM invbal WHERE invbal_itemsite_id=pItemsiteId;
16236
 
 
16237
 
  FOR _r IN 
16238
 
    SELECT invhist.*,
16239
 
      itemsite_item_id, invhistSense(invhist_id) AS sense,
16240
 
      item_number, warehous_code
16241
 
    FROM invhist
16242
 
      JOIN itemsite ON (itemsite_id=invhist_itemsite_id)
16243
 
      JOIN item ON (itemsite_item_id=item_id)
16244
 
      JOIN whsinfo ON (itemsite_warehous_id=warehous_id)
16245
 
    WHERE (invhist_itemsite_id=pItemsiteId)
16246
 
    ORDER BY invhist_created, invhist_id
16247
 
  LOOP
16248
 
    RAISE NOTICE 'Calculating balances for Item % at Site % against transaction %, transtype %, sense %, qty %, %', _r.item_number, _r.warehous_code, _r.invhist_id, _r.invhist_transtype, _r.sense, _r.invhist_invqty, _r.invhist_comments;
16249
 
    -- Update balances changed by any standard cost update between transactions
16250
 
    IF (_prevCostmethod = 'S' AND _runningQty != 0) THEN
16251
 
      PERFORM postValueintoInvBalance(pItemsiteid, costhist_date::date, _runningQty, _runningNn, costhist_oldcost, costhist_newcost )
16252
 
      FROM costhist
16253
 
      WHERE ((costhist_item_id=_r.itemsite_item_id)
16254
 
        AND (costhist_date BETWEEN _prevDate AND _r.invhist_created)
16255
 
        AND (costhist_type IN ('S','D')));
16256
 
    END IF;
16257
 
 
16258
 
    -- Post transaction into inventory balance table
16259
 
    PERFORM postIntoInvBalance(_r.invhist_id);
16260
 
 
16261
 
    _prevDate := _r.invhist_created;
16262
 
    _prevCostmethod := _r.invhist_costmethod;
16263
 
    _runningQty := _runningQty + _r.invhist_invqty * _r.sense;
16264
 
    IF (_r.invhist_transtype = 'NN') THEN
16265
 
      _runningNn := _runningNn + _r.invhist_invqty * -1;
16266
 
    END IF;
16267
 
    
16268
 
  END LOOP;
16269
 
 
16270
 
  -- Update balances changed by any standard cost since last transaction
16271
 
  IF (_prevCostmethod = 'S' AND _runningQty != 0) THEN
16272
 
    PERFORM postValueintoInvBalance(pItemsiteid, costhist_date::date, _runningQty, _runningNn, costhist_oldcost, costhist_newcost )
16273
 
    FROM costhist
16274
 
    WHERE ((costhist_item_id=_r.itemsite_item_id)
16275
 
      AND (costhist_date > _prevDate)
16276
 
      AND (costhist_type IN ('S','D')));
16277
 
  END IF;
16278
 
 
16279
 
  -- Forward update changes through all the balances
16280
 
  PERFORM forwardupdateitemsite(pItemsiteId);
16281
 
  
16282
 
  RETURN 1;
16283
 
END;
16284
 
$_$;
16285
 
 
16286
 
 
16287
 
ALTER FUNCTION public.buildinvbal(integer) OWNER TO admin;
16288
 
 
16289
 
--
16290
 
--
16291
 
 
16292
 
CREATE FUNCTION buildsearchpath() RETURNS text
16293
 
    LANGUAGE plpgsql
16294
 
    AS $_$
16295
 
DECLARE
16296
 
  _path   TEXT    := '';
16297
 
  _schema TEXT;
16298
 
  _seq    INTEGER;
16299
 
BEGIN
16300
 
  -- get the schemas as ordered by the administrator
16301
 
  SELECT concatagg(quote_ident(schemaord_name) || ',') INTO _path
16302
 
    FROM (SELECT schemaord_name
16303
 
            FROM schemaord
16304
 
            LEFT OUTER JOIN pkghead ON (schemaord_name=pkghead_name)
16305
 
           WHERE (pkghead_id IS NULL
16306
 
               OR (pkghead_id IS NOT NULL AND packageisenabled(pkghead_id)))
16307
 
           ORDER BY schemaord_order
16308
 
         ) AS xtspq;
16309
 
 
16310
 
  -- add others that we think/know we need
16311
 
  -- TODO: is there a reason not to include public, api, or packages?
16312
 
  FOR _schema, _seq IN
16313
 
      SELECT pkghead_name AS schema, 0 AS seq
16314
 
        FROM pkghead
16315
 
       WHERE packageisenabled(pkghead_id)
16316
 
      UNION ALL
16317
 
      SELECT 'public', 1
16318
 
      UNION ALL
16319
 
      SELECT 'api', 2
16320
 
      ORDER BY seq, schema
16321
 
  LOOP
16322
 
    IF (_path !~* (E'(^|\\W)' || _schema || E'(\\W|$)')) THEN
16323
 
      _path := _path || ',' || quote_ident(_schema);
16324
 
    END IF;
16325
 
  END LOOP;
16326
 
 
16327
 
  -- remove extraneous spaces and commas
16328
 
  _path = BTRIM(REGEXP_REPLACE(_path, '( ?, ?)+', ',', 'g'),
16329
 
                ', ');
16330
 
 
16331
 
  RAISE DEBUG 'buildSearchPath() returning %', _path;
16332
 
 
16333
 
  RETURN _path;
16334
 
END;
16335
 
$_$;
16336
 
 
16337
 
 
16338
 
ALTER FUNCTION public.buildsearchpath() OWNER TO admin;
16339
 
 
16340
 
--
16341
 
--
16342
 
 
16343
 
COMMENT ON FUNCTION buildsearchpath() IS 'buildSearchPath() examines the schemaord and pkghead tables to build a search
16344
 
path string. It ensures that public, api, and all enabled packages are included
16345
 
even if they are not listed in the schemaord table.
16346
 
It returns the constructed search_path but does not set it.';
16347
 
 
16348
 
 
16349
 
--
16350
 
--
16351
 
 
16352
 
CREATE FUNCTION calccashbudget(integer, integer, character) RETURNS numeric
16353
 
    LANGUAGE plpgsql
16354
 
    AS $_$
16355
 
DECLARE
16356
 
  pAccntId ALIAS FOR $1;
16357
 
  pPeriodId ALIAS FOR $2;
16358
 
  pInterval ALIAS FOR $3;
16359
 
  _accntType CHAR;
16360
 
  _currentBudget NUMERIC;
16361
 
  _priorBudget NUMERIC;
16362
 
  _result NUMERIC;
16363
 
BEGIN
16364
 
 
16365
 
        SELECT accnt_type INTO _accntType
16366
 
        FROM accnt
16367
 
        WHERE (accnt_id=pAccntId);
16368
 
 
16369
 
        SELECT COALESCE(SUM(budget_amount),0) INTO _currentBudget
16370
 
        FROM budget
16371
 
        WHERE ((budget_accnt_id=pAccntId)
16372
 
        AND (budget_period_id=pPeriodId));
16373
 
 
16374
 
        IF (pInterval='M') THEN
16375
 
        SELECT (COALESCE(SUM(budget_amount),0)) INTO _priorBudget
16376
 
                FROM budget,
16377
 
                (SELECT COALESCE(pp.period_id,-1) AS prior_period_id
16378
 
                        FROM period cp, period pp
16379
 
                        WHERE ((cp.period_id=pPeriodId)
16380
 
                        AND (cp.period_start > pp.period_start))
16381
 
                        ORDER BY pp.period_start DESC LIMIT 1) AS data
16382
 
                WHERE ((budget_accnt_id=pAccntId)
16383
 
                AND (budget_period_id=prior_period_id));
16384
 
 
16385
 
                ELSE IF (pInterval='Q') THEN
16386
 
                        SELECT (COALESCE(SUM(budget_amount),0)) INTO _priorBudget
16387
 
                        FROM budget,
16388
 
                                (SELECT COALESCE(pp.period_id,-1) AS prior_period_id
16389
 
                                FROM period cp, period pp
16390
 
                                WHERE ((cp.period_id=pPeriodId)
16391
 
                                AND (cp.period_start > pp.period_start)
16392
 
                                AND (pp.period_quarter=
16393
 
                                CASE WHEN cp.period_quarter > 1 THEN
16394
 
                                        cp.period_quarter - 1
16395
 
                                ELSE 4 END)
16396
 
                                AND (pp.period_start >= cp.period_start - interval '1 year'))
16397
 
                                ORDER BY pp.period_start DESC LIMIT 1) AS data
16398
 
                        WHERE ((budget_accnt_id=pAccntId)
16399
 
                        AND (budget_period_id=prior_period_id));
16400
 
 
16401
 
 
16402
 
                ELSE
16403
 
                        SELECT (COALESCE(SUM(budget_amount),0)) INTO _priorBudget
16404
 
                        FROM budget,
16405
 
                                (SELECT pp.period_id AS prior_period_id
16406
 
                        FROM period cp, period pp, yearperiod cy, yearperiod py
16407
 
                        WHERE ((cp.period_id=pPeriodId)
16408
 
                        AND (cp.period_yearperiod_id=cy.yearperiod_id)
16409
 
                        AND (pp.period_yearperiod_id=py.yearperiod_id)
16410
 
                        AND (cy.yearperiod_start > py.yearperiod_start))
16411
 
                        ORDER BY pp.period_start DESC LIMIT 1) AS data
16412
 
                        WHERE ((budget_accnt_id=pAccntId)
16413
 
                        AND (budget_period_id=prior_period_id));
16414
 
 
16415
 
                END IF;
16416
 
        END IF;
16417
 
 
16418
 
        IF _accntType='A' THEN
16419
 
                _result := ((_priorBudget-_currentBudget) * -1 );
16420
 
 
16421
 
        ELSE IF (_accntType IN ('L','Q')) THEN
16422
 
                _result := ((_priorBudget-_currentBudget) *-1);
16423
 
 
16424
 
        ELSE RETURN -1;
16425
 
        END IF;
16426
 
  END IF;
16427
 
 
16428
 
 
16429
 
  RETURN _result;
16430
 
 
16431
 
 
16432
 
END;
16433
 
$_$;
16434
 
 
16435
 
 
16436
 
ALTER FUNCTION public.calccashbudget(integer, integer, character) OWNER TO admin;
16437
 
 
16438
 
--
16439
 
--
16440
 
 
16441
 
CREATE FUNCTION calccmheadamt(integer) RETURNS numeric
16442
 
    LANGUAGE plpgsql
16443
 
    AS $_$
16444
 
DECLARE
16445
 
  pCmheadid ALIAS FOR $1;
16446
 
  _amount NUMERIC := 0;
16447
 
 
16448
 
BEGIN
16449
 
 
16450
 
  SELECT SUM(COALESCE(extprice, 0)) INTO _amount
16451
 
  FROM cmhead JOIN creditmemoitem ON (cmhead_id=cmitem_cmhead_id)
16452
 
  WHERE (cmhead_id=pCmheadid);
16453
 
 
16454
 
  RETURN _amount;
16455
 
 
16456
 
END;
16457
 
$_$;
16458
 
 
16459
 
 
16460
 
ALTER FUNCTION public.calccmheadamt(integer) OWNER TO admin;
16461
 
 
16462
 
--
16463
 
--
16464
 
 
16465
 
CREATE FUNCTION calccmheadtax(integer) RETURNS numeric
16466
 
    LANGUAGE plpgsql
16467
 
    AS $_$
16468
 
DECLARE
16469
 
  pCmheadid ALIAS FOR $1;
16470
 
  _headamount NUMERIC := 0;
16471
 
  _itemamount NUMERIC := 0;
16472
 
  _amount NUMERIC := 0;
16473
 
 
16474
 
BEGIN
16475
 
 
16476
 
  SELECT COALESCE(SUM(taxhist_tax), 0) INTO _headamount
16477
 
  FROM cmhead JOIN cmheadtax ON (taxhist_parent_id=cmhead_id)
16478
 
  WHERE (cmhead_id=pCmheadid);
16479
 
 
16480
 
  SELECT SUM(COALESCE(tax, 0)) INTO _itemamount
16481
 
  FROM cmhead JOIN creditmemoitem ON (cmhead_id=cmitem_cmhead_id)
16482
 
  WHERE (cmhead_id=pCmheadid);
16483
 
 
16484
 
  _amount := _headamount + _itemamount;
16485
 
  RETURN (_amount * -1.0);
16486
 
 
16487
 
END;
16488
 
$_$;
16489
 
 
16490
 
 
16491
 
ALTER FUNCTION public.calccmheadtax(integer) OWNER TO admin;
16492
 
 
16493
 
--
16494
 
--
16495
 
 
16496
 
CREATE FUNCTION calccobillamt(integer) RETURNS numeric
16497
 
    LANGUAGE plpgsql
16498
 
    AS $_$
16499
 
DECLARE
16500
 
  pCobillid ALIAS FOR $1;
16501
 
  _amount NUMERIC := 0;
16502
 
 
16503
 
BEGIN
16504
 
 
16505
 
  SELECT COALESCE(round((cobill_qty * coitem_qty_invuomratio) *
16506
 
                        (coitem_price / coitem_price_invuomratio), 2), 0) INTO _amount
16507
 
  FROM cobill JOIN coitem ON (coitem_id=cobill_coitem_id)
16508
 
  WHERE (cobill_id=pCobillid);
16509
 
 
16510
 
  RETURN _amount;
16511
 
 
16512
 
END;
16513
 
$_$;
16514
 
 
16515
 
 
16516
 
ALTER FUNCTION public.calccobillamt(integer) OWNER TO admin;
16517
 
 
16518
 
--
16519
 
--
16520
 
 
16521
 
CREATE FUNCTION calccobilltax(integer) RETURNS numeric
16522
 
    LANGUAGE plpgsql
16523
 
    AS $_$
16524
 
DECLARE
16525
 
  pCobillid ALIAS FOR $1;
16526
 
  _amount NUMERIC := 0;
16527
 
 
16528
 
BEGIN
16529
 
 
16530
 
  SELECT COALESCE(calculateTax(cobmisc_taxzone_id,
16531
 
                               cobill_taxtype_id,
16532
 
                               cobmisc_shipdate,
16533
 
                               cobmisc_curr_id,
16534
 
                               calcCobillAmt(cobill_id)), 0) INTO _amount
16535
 
  FROM cobill JOIN coitem ON (coitem_id=cobill_coitem_id)
16536
 
              JOIN cobmisc ON (cobmisc_id=cobill_cobmisc_id)
16537
 
  WHERE (cobill_id=pCobillid);
16538
 
 
16539
 
  RETURN _amount;
16540
 
 
16541
 
END;
16542
 
$_$;
16543
 
 
16544
 
 
16545
 
ALTER FUNCTION public.calccobilltax(integer) OWNER TO admin;
16546
 
 
16547
 
--
16548
 
--
16549
 
 
16550
 
CREATE FUNCTION calccobmiscamt(integer) RETURNS numeric
16551
 
    LANGUAGE plpgsql
16552
 
    AS $_$
16553
 
DECLARE
16554
 
  pCobmiscid ALIAS FOR $1;
16555
 
  _amount NUMERIC := 0;
16556
 
 
16557
 
BEGIN
16558
 
 
16559
 
  SELECT SUM(COALESCE(calcCobillAmt(cobill_id), 0)) INTO _amount
16560
 
  FROM cobmisc JOIN cobill ON (cobmisc_id=cobill_cobmisc_id)
16561
 
  WHERE (cobmisc_id=pCobmiscid);
16562
 
 
16563
 
  RETURN _amount;
16564
 
 
16565
 
END;
16566
 
$_$;
16567
 
 
16568
 
 
16569
 
ALTER FUNCTION public.calccobmiscamt(integer) OWNER TO admin;
16570
 
 
16571
 
--
16572
 
--
16573
 
 
16574
 
CREATE FUNCTION calccobmisctax(integer) RETURNS numeric
16575
 
    LANGUAGE plpgsql
16576
 
    AS $_$
16577
 
DECLARE
16578
 
  pCobmiscid ALIAS FOR $1;
16579
 
  _amount NUMERIC := 0;
16580
 
 
16581
 
BEGIN
16582
 
 
16583
 
  SELECT SUM(
16584
 
         COALESCE(calculateTax(cobmisc_taxzone_id,
16585
 
                               cobill_taxtype_id,
16586
 
                               cobmisc_shipdate,
16587
 
                               cobmisc_curr_id,
16588
 
                               COALESCE(round((cobill_qty * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio), 2), 0))
16589
 
                 , 0)
16590
 
            ) INTO _amount
16591
 
  FROM cobmisc JOIN cobill ON (cobmisc_id=cobill_cobmisc_id)
16592
 
               JOIN coitem ON (coitem_id=cobill_coitem_id)
16593
 
  WHERE (cobmisc_id=pCobmiscid);
16594
 
 
16595
 
  RETURN _amount;
16596
 
 
16597
 
END;
16598
 
$_$;
16599
 
 
16600
 
 
16601
 
ALTER FUNCTION public.calccobmisctax(integer) OWNER TO admin;
16602
 
 
16603
 
--
16604
 
--
16605
 
 
16606
 
CREATE FUNCTION calcinvoiceamt(pinvcheadid integer) RETURNS numeric
16607
 
    LANGUAGE plpgsql STABLE
16608
 
    AS $$
16609
 
BEGIN
16610
 
 
16611
 
  RETURN calcInvoiceAmt(pInvcheadid, 'T');
16612
 
 
16613
 
END;
16614
 
$$;
16615
 
 
16616
 
 
16617
 
ALTER FUNCTION public.calcinvoiceamt(pinvcheadid integer) OWNER TO admin;
16618
 
 
16619
 
--
16620
 
--
16621
 
 
16622
 
CREATE FUNCTION calcinvoiceamt(pinvcheadid integer, ptype text) RETURNS numeric
16623
 
    LANGUAGE plpgsql STABLE
16624
 
    AS $$
16625
 
DECLARE
16626
 
  _subtotal NUMERIC := 0.0;
16627
 
  _cost NUMERIC := 0.0;
16628
 
  _tax NUMERIC := 0.0;
16629
 
  _freight NUMERIC := 0.0;
16630
 
  _misc NUMERIC := 0.0;
16631
 
  _amount NUMERIC := 0.0;
16632
 
 
16633
 
BEGIN
16634
 
 
16635
 
  -- pType: S = line item subtotal
16636
 
  --        T = total
16637
 
  --        X = tax
16638
 
  --        M = margin
16639
 
 
16640
 
  SELECT COALESCE(SUM(ROUND((invcitem_billed * invcitem_qty_invuomratio) *
16641
 
                            (invcitem_price / COALESCE(invcitem_price_invuomratio, 1.0)), 2)), 0.0),
16642
 
         COALESCE(SUM(ROUND((invcitem_billed * invcitem_qty_invuomratio) *
16643
 
                            COALESCE(coitem_unitcost, itemCost(itemsite_id), 0.0), 2)), 0.0)
16644
 
         INTO _subtotal, _cost
16645
 
  FROM invcitem LEFT OUTER JOIN coitem ON (coitem_id=invcitem_coitem_id)
16646
 
                LEFT OUTER JOIN itemsite ON (itemsite_item_id=invcitem_item_id AND itemsite_warehous_id=invcitem_warehous_id)
16647
 
  WHERE (invcitem_invchead_id=pInvcheadid);
16648
 
 
16649
 
  IF (pType IN ('T', 'X')) THEN
16650
 
    SELECT COALESCE(SUM(tax), 0.0) INTO _tax
16651
 
    FROM (SELECT COALESCE(ROUND(SUM(taxdetail_tax), 2), 0.0) AS tax
16652
 
          FROM tax
16653
 
               JOIN calculateTaxDetailSummary('I', pInvcheadid, 'T')ON (taxdetail_tax_id=tax_id)
16654
 
          GROUP BY tax_id) AS data;
16655
 
  END IF;
16656
 
 
16657
 
  IF (pType = 'T') THEN
16658
 
    SELECT COALESCE(invchead_freight, 0), COALESCE(invchead_misc_amount, 0)
16659
 
           INTO _freight, _misc
16660
 
    FROM invchead
16661
 
    WHERE (invchead_id=pinvcheadid);
16662
 
  END IF;
16663
 
 
16664
 
  _amount := CASE pType WHEN 'S' THEN (_subtotal)
16665
 
                        WHEN 'T' THEN (_subtotal + _tax + _freight + _misc)
16666
 
                        WHEN 'X' THEN (_tax)
16667
 
                        WHEN 'M' THEN (_subtotal - _cost)
16668
 
                        ELSE 0.0
16669
 
             END;
16670
 
 
16671
 
  RETURN _amount;
16672
 
 
16673
 
END;
16674
 
$$;
16675
 
 
16676
 
 
16677
 
ALTER FUNCTION public.calcinvoiceamt(pinvcheadid integer, ptype text) OWNER TO admin;
16678
 
 
16679
 
--
16680
 
--
16681
 
 
16682
 
CREATE FUNCTION calcpendingarapplications(integer) RETURNS numeric
16683
 
    LANGUAGE plpgsql STABLE
16684
 
    AS $_$
16685
 
DECLARE
16686
 
  paropenid     ALIAS FOR $1;
16687
 
  _arcreditsum  NUMERIC;
16688
 
  _aropencurrid INTEGER;
16689
 
  _cashrcptsum  NUMERIC;
16690
 
  _sense INTEGER;
16691
 
 
16692
 
BEGIN
16693
 
  SELECT aropen_curr_id,
16694
 
    (CASE WHEN aropen_doctype IN ('I','D') THEN 1 ELSE -1 END) 
16695
 
    INTO _aropencurrid, _sense
16696
 
  FROM aropen
16697
 
  WHERE (aropen_id=paropenid);
16698
 
 
16699
 
  SELECT SUM(currToCurr(cashrcpt_curr_id, _aropencurrid,
16700
 
                        cashrcptitem_amount + cashrcptitem_discount, coalesce(cashrcpt_applydate, cashrcpt_distdate))) * _sense INTO _cashrcptsum
16701
 
  FROM cashrcptitem, cashrcpt
16702
 
  WHERE ((cashrcptitem_cashrcpt_id=cashrcpt_id)
16703
 
    AND  (NOT cashrcpt_posted)
16704
 
    AND  (NOT cashrcpt_void)
16705
 
    AND  (cashrcptitem_aropen_id=paropenid)
16706
 
    );
16707
 
 
16708
 
  SELECT SUM(currToCurr(arcreditapply_curr_id, _aropencurrid,
16709
 
                        arcreditapply_amount, CURRENT_DATE)) INTO _arcreditsum
16710
 
  FROM arcreditapply
16711
 
  WHERE ((arcreditapply_target_aropen_id=paropenid)
16712
 
    );
16713
 
 
16714
 
  RETURN round(COALESCE(_cashrcptsum, 0) + COALESCE(_arcreditsum, 0),2);
16715
 
END;
16716
 
$_$;
16717
 
 
16718
 
 
16719
 
ALTER FUNCTION public.calcpendingarapplications(integer) OWNER TO admin;
16720
 
 
16721
 
--
16722
 
--
16723
 
 
16724
 
CREATE FUNCTION calcpurchaseorderamt(ppoheadid integer) RETURNS numeric
16725
 
    LANGUAGE plpgsql
16726
 
    AS $$
16727
 
BEGIN
16728
 
 
16729
 
  RETURN calcPurchaseOrderAmt(pPoheadid, 'T');
16730
 
 
16731
 
END;
16732
 
$$;
16733
 
 
16734
 
 
16735
 
ALTER FUNCTION public.calcpurchaseorderamt(ppoheadid integer) OWNER TO admin;
16736
 
 
16737
 
--
16738
 
--
16739
 
 
16740
 
CREATE FUNCTION calcpurchaseorderamt(ppoheadid integer, ptype text) RETURNS numeric
16741
 
    LANGUAGE plpgsql
16742
 
    AS $$
16743
 
DECLARE
16744
 
  _subtotal NUMERIC := 0;
16745
 
  _freightsub NUMERIC := 0;
16746
 
  _tax NUMERIC := 0;
16747
 
  _freight NUMERIC := 0;
16748
 
  _currid INTEGER := 0;
16749
 
  _effdate DATE := CURRENT_DATE;
16750
 
  _amount NUMERIC := 0;
16751
 
 
16752
 
BEGIN
16753
 
 
16754
 
  -- pType: S = line item subtotal
16755
 
  --        T = total
16756
 
  --        X = tax
16757
 
 
16758
 
  SELECT COALESCE(SUM(ROUND(poitem_qty_ordered * poitem_unitprice, 2)), 0),
16759
 
         COALESCE(SUM(ROUND(poitem_freight, 2)), 0)
16760
 
         INTO _subtotal, _freightsub
16761
 
  FROM poitem
16762
 
  WHERE (poitem_pohead_id=pPoheadid);
16763
 
 
16764
 
  SELECT COALESCE(SUM(tax), 0) INTO _tax
16765
 
  FROM ( SELECT COALESCE(ROUND(SUM(taxdetail_tax), 2), 0.0) AS tax
16766
 
         FROM tax JOIN calculateTaxDetailSummary('PO', pPoheadid, 'T') ON (taxdetail_tax_id=tax_id)
16767
 
         GROUP BY tax_id ) AS data;
16768
 
 
16769
 
  SELECT COALESCE(pohead_freight, 0), pohead_curr_id, pohead_orderdate
16770
 
         INTO _freight, _currid, _effdate
16771
 
  FROM pohead
16772
 
  WHERE (pohead_id=pPoheadid);
16773
 
 
16774
 
  _amount := currToBase(_currid,
16775
 
                        CASE pType WHEN 'S' THEN (_subtotal)
16776
 
                                   WHEN 'T' THEN (_subtotal + _tax + _freight + _freightsub)
16777
 
                                   WHEN 'X' THEN (_tax)
16778
 
                                   ELSE 0.0
16779
 
                        END,
16780
 
                        _effdate);
16781
 
 
16782
 
  RETURN _amount;
16783
 
 
16784
 
END;
16785
 
$$;
16786
 
 
16787
 
 
16788
 
ALTER FUNCTION public.calcpurchaseorderamt(ppoheadid integer, ptype text) OWNER TO admin;
16789
 
 
16790
 
--
16791
 
--
16792
 
 
16793
 
CREATE FUNCTION calcpurchaseorderduedate(ppoheadid integer) RETURNS date
16794
 
    LANGUAGE plpgsql
16795
 
    AS $$
16796
 
DECLARE
16797
 
  _result DATE;
16798
 
BEGIN
16799
 
 
16800
 
  SELECT MIN(poitem_duedate) INTO _result
16801
 
  FROM poitem
16802
 
  WHERE (poitem_pohead_id=pPoheadid);
16803
 
 
16804
 
  RETURN _result;
16805
 
 
16806
 
END;
16807
 
$$;
16808
 
 
16809
 
 
16810
 
ALTER FUNCTION public.calcpurchaseorderduedate(ppoheadid integer) OWNER TO admin;
16811
 
 
16812
 
--
16813
 
--
16814
 
 
16815
 
CREATE FUNCTION calcquoteamt(pquheadid integer) RETURNS numeric
16816
 
    LANGUAGE plpgsql STABLE
16817
 
    AS $$
16818
 
BEGIN
16819
 
 
16820
 
  RETURN calcQuoteAmt(pQuheadid, 'T');
16821
 
 
16822
 
END;
16823
 
$$;
16824
 
 
16825
 
 
16826
 
ALTER FUNCTION public.calcquoteamt(pquheadid integer) OWNER TO admin;
16827
 
 
16828
 
--
16829
 
--
16830
 
 
16831
 
CREATE FUNCTION calcquoteamt(pquheadid integer, ptype text) RETURNS numeric
16832
 
    LANGUAGE plpgsql STABLE
16833
 
    AS $$
16834
 
DECLARE
16835
 
  _subtotal NUMERIC := 0.0;
16836
 
  _cost NUMERIC := 0.0;
16837
 
  _tax NUMERIC := 0.0;
16838
 
  _freight NUMERIC := 0.0;
16839
 
  _misc NUMERIC := 0.0;
16840
 
  _amount NUMERIC := 0.0;
16841
 
 
16842
 
BEGIN
16843
 
 
16844
 
  -- pType: S = line item subtotal
16845
 
  --        T = total
16846
 
  --        X = tax
16847
 
  --        M = margin
16848
 
 
16849
 
  SELECT COALESCE(SUM(ROUND((quitem_qtyord * quitem_qty_invuomratio) *
16850
 
                            (quitem_price / quitem_price_invuomratio), 2)), 0.0),
16851
 
         COALESCE(SUM(ROUND((quitem_qtyord * quitem_qty_invuomratio) *
16852
 
                            (quitem_unitcost / quitem_price_invuomratio), 2)), 0.0)
16853
 
         INTO _subtotal, _cost
16854
 
  FROM quitem
16855
 
  WHERE (quitem_quhead_id=pQuheadid);
16856
 
 
16857
 
  IF (pType IN ('T', 'X')) THEN
16858
 
    SELECT SUM(tax) INTO _tax
16859
 
    FROM (SELECT COALESCE(ROUND(SUM(taxdetail_tax), 2), 0.0) AS tax
16860
 
          FROM tax
16861
 
               JOIN calculateTaxDetailSummary('Q', pQuheadid, 'T')ON (taxdetail_tax_id=tax_id)
16862
 
          GROUP BY tax_id) AS data;
16863
 
  END IF;
16864
 
 
16865
 
  IF (pType = 'T') THEN
16866
 
    SELECT COALESCE(quhead_freight, 0), COALESCE(quhead_misc, 0) INTO _freight, _misc
16867
 
    FROM quhead
16868
 
    WHERE (quhead_id=pQuheadid);
16869
 
  END IF;
16870
 
 
16871
 
  _amount := CASE pType WHEN 'S' THEN (_subtotal)
16872
 
                        WHEN 'T' THEN (_subtotal + _tax + _freight + _misc)
16873
 
                        WHEN 'X' THEN (_tax)
16874
 
                        WHEN 'M' THEN (_subtotal - _cost)
16875
 
                        ELSE 0.0
16876
 
             END;
16877
 
 
16878
 
  RETURN _amount;
16879
 
 
16880
 
END;
16881
 
$$;
16882
 
 
16883
 
 
16884
 
ALTER FUNCTION public.calcquoteamt(pquheadid integer, ptype text) OWNER TO admin;
16885
 
 
16886
 
--
16887
 
--
16888
 
 
16889
 
CREATE FUNCTION calcsalesorderamt(pcoheadid integer) RETURNS numeric
16890
 
    LANGUAGE plpgsql STABLE
16891
 
    AS $$
16892
 
BEGIN
16893
 
 
16894
 
  RETURN calcSalesOrderAmt(pCoheadid, 'T');
16895
 
 
16896
 
END;
16897
 
$$;
16898
 
 
16899
 
 
16900
 
ALTER FUNCTION public.calcsalesorderamt(pcoheadid integer) OWNER TO admin;
16901
 
 
16902
 
--
16903
 
--
16904
 
 
16905
 
CREATE FUNCTION calcsalesorderamt(pcoheadid integer, ptype text) RETURNS numeric
16906
 
    LANGUAGE plpgsql STABLE
16907
 
    AS $$
16908
 
DECLARE
16909
 
  _subtotal NUMERIC := 0.0;
16910
 
  _cost NUMERIC := 0.0;
16911
 
  _tax NUMERIC := 0.0;
16912
 
  _freight NUMERIC := 0.0;
16913
 
  _misc NUMERIC := 0.0;
16914
 
  _credit NUMERIC := 0.0;
16915
 
  _amount NUMERIC := 0.0;
16916
 
 
16917
 
BEGIN
16918
 
 
16919
 
  -- pType: S = line item subtotal
16920
 
  --        T = total
16921
 
  --        B = balance due
16922
 
  --        C = allocated credits
16923
 
  --        X = tax
16924
 
  --        M = margin
16925
 
 
16926
 
  SELECT COALESCE(SUM(ROUND((coitem_qtyord * coitem_qty_invuomratio) *
16927
 
                            (coitem_price / coitem_price_invuomratio), 2)), 0.0),
16928
 
         COALESCE(SUM(ROUND((coitem_qtyord * coitem_qty_invuomratio) *
16929
 
                            (CASE WHEN (coitem_subnumber > 0) THEN 0.0 ELSE coitem_unitcost END
16930
 
                             / coitem_price_invuomratio), 2)), 0.0)
16931
 
         INTO _subtotal, _cost
16932
 
  FROM coitem
16933
 
  WHERE (coitem_cohead_id=pCoheadid)
16934
 
    AND (coitem_status != 'X');
16935
 
 
16936
 
  IF (pType IN ('T', 'B', 'X')) THEN
16937
 
    SELECT COALESCE(SUM(tax), 0.0) INTO _tax
16938
 
    FROM (SELECT COALESCE(ROUND(SUM(taxdetail_tax), 2), 0.0) AS tax
16939
 
          FROM tax
16940
 
               JOIN calculateTaxDetailSummary('S', pCoheadid, 'T')ON (taxdetail_tax_id=tax_id)
16941
 
          GROUP BY tax_id) AS data;
16942
 
  END IF;
16943
 
 
16944
 
  IF (pType IN ('T', 'B', 'C')) THEN
16945
 
    SELECT COALESCE(cohead_freight, 0), COALESCE(cohead_misc, 0),
16946
 
           COALESCE(SUM(currToCurr(aropenalloc_curr_id, cohead_curr_id,
16947
 
                                   aropenalloc_amount, CURRENT_DATE)),0)
16948
 
           INTO _freight, _misc, _credit
16949
 
    FROM cohead
16950
 
         LEFT OUTER JOIN aropenalloc ON (aropenalloc_doctype='S' AND aropenalloc_doc_id=cohead_id)
16951
 
    WHERE (cohead_id=pCoheadid)
16952
 
    GROUP BY cohead_freight, cohead_misc, cohead_curr_id;
16953
 
  END IF;
16954
 
 
16955
 
  _amount := CASE pType WHEN 'S' THEN (_subtotal)
16956
 
                        WHEN 'T' THEN (_subtotal + _tax + _freight + _misc)
16957
 
                        WHEN 'B' THEN (_subtotal + _tax + _freight + _misc - _credit)
16958
 
                        WHEN 'C' THEN (_credit)
16959
 
                        WHEN 'X' THEN (_tax)
16960
 
                        WHEN 'M' THEN (_subtotal - _cost)
16961
 
                        ELSE 0.0
16962
 
             END;
16963
 
 
16964
 
  RETURN _amount;
16965
 
 
16966
 
END;
16967
 
$$;
16968
 
 
16969
 
 
16970
 
ALTER FUNCTION public.calcsalesorderamt(pcoheadid integer, ptype text) OWNER TO admin;
16971
 
 
16972
 
--
16973
 
--
16974
 
 
16975
 
CREATE FUNCTION calcshipfreight(integer) RETURNS numeric
16976
 
    LANGUAGE plpgsql
16977
 
    AS $_$
16978
 
DECLARE
16979
 
  pShipheadId ALIAS FOR $1;
16980
 
  _result NUMERIC := 0;
16981
 
  _order RECORD;
16982
 
  _shipment RECORD;
16983
 
  _weights RECORD;
16984
 
  _price RECORD;
16985
 
  _sales RECORD;
16986
 
  _freightid INTEGER;
16987
 
  _totalprice NUMERIC;
16988
 
  _includepkgweight BOOLEAN := FALSE;
16989
 
  _freight RECORD;
16990
 
  _debug BOOLEAN := false;
16991
 
BEGIN
16992
 
  --Get shipment
16993
 
  SELECT shiphead_order_id, shiphead_order_type, shiphead_freight 
16994
 
  INTO _shipment
16995
 
  FROM shiphead
16996
 
  WHERE (shiphead_id=pShipheadId);
16997
 
 
16998
 
  IF (NOT FOUND) THEN
16999
 
    RAISE EXCEPTION 'Shipment not found';
17000
 
  END IF;
17001
 
 
17002
 
  IF (_shipment.shiphead_order_type = 'SO') THEN
17003
 
  --Sales Orders
17004
 
  
17005
 
  --Get the order header information
17006
 
    SELECT cust_id AS cust_id,
17007
 
           custtype_id,
17008
 
           custtype_code,
17009
 
           shipto_id,
17010
 
           shipto_num,
17011
 
           cohead_orderdate AS orderdate,
17012
 
           cohead_shipvia AS shipvia,
17013
 
           shipto_shipzone_id AS shipzone_id,
17014
 
           cohead_curr_id AS curr_id,
17015
 
           currConcat(cohead_curr_id) AS currAbbr,
17016
 
           cohead_calcfreight,
17017
 
           cohead_freight
17018
 
    INTO _order
17019
 
    FROM cohead 
17020
 
      JOIN custinfo ON (cust_id=cohead_cust_id)
17021
 
      JOIN custtype ON (custtype_id=cust_custtype_id)
17022
 
      LEFT OUTER JOIN shiptoinfo ON (shipto_id=cohead_shipto_id)
17023
 
    WHERE (cohead_id=_shipment.shiphead_order_id);
17024
 
 
17025
 
    IF (NOT FOUND) THEN
17026
 
      RAISE EXCEPTION 'Order not found';
17027
 
    END IF;
17028
 
 
17029
 
    IF (_debug) THEN
17030
 
      RAISE NOTICE 'cust_id = %', _order.cust_id;
17031
 
      RAISE NOTICE 'custtype_id = %', _order.custtype_id;
17032
 
      RAISE NOTICE 'shipto_id = %', _order.shipto_id;
17033
 
      RAISE NOTICE 'shipto_num = %', _order.shipto_num;
17034
 
      RAISE NOTICE 'orderdate = %', _order.orderdate;
17035
 
      RAISE NOTICE 'shipvia = %', _order.shipvia;
17036
 
      RAISE NOTICE 'shipzone_id = %', _order.shipzone_id;
17037
 
      RAISE NOTICE 'curr_id = %', _order.curr_id;
17038
 
      RAISE NOTICE 'currAbbr = %', _order.currAbbr;
17039
 
      RAISE NOTICE 'calcfreight = %', _order.cohead_calcfreight;
17040
 
      RAISE NOTICE 'freight = %', _order.cohead_freight;
17041
 
    END IF;
17042
 
 
17043
 
    IF (NOT _order.cohead_calcfreight) THEN
17044
 
      SELECT noNeg( _order.cohead_freight -
17045
 
                    COALESCE((SELECT SUM(shiphead_freight)
17046
 
                              FROM shiphead
17047
 
                              WHERE (shiphead_order_id = _shipment.shiphead_order_id)
17048
 
                                AND (shiphead_shipped='true')), 0) ) INTO _result;
17049
 
      RETURN _result;
17050
 
    END IF;
17051
 
 
17052
 
    SELECT fetchMetricBool('IncludePackageWeight') INTO _includepkgweight;
17053
 
 
17054
 
    --Calculate Sales Order freight
17055
 
    --Get a list of aggregated weights from sites and
17056
 
    --freight classes used on order lines
17057
 
    FOR _weights IN
17058
 
      SELECT CASE WHEN (_includePkgWeight) THEN
17059
 
                        SUM(shipitem_qty * (item_prodweight + item_packweight))
17060
 
                  ELSE  SUM(shipitem_qty * item_prodweight)
17061
 
             END AS weight,
17062
 
             itemsite_warehous_id, item_freightclass_id
17063
 
      FROM shiphead
17064
 
        JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)
17065
 
        JOIN coitem ON (shipitem_orderitem_id=coitem_id)
17066
 
        JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
17067
 
        JOIN item ON (item_id=itemsite_item_id)
17068
 
      WHERE ( (shiphead_id=pShipheadId)
17069
 
        AND   (item_freightclass_id IS NOT NULL) )
17070
 
      GROUP BY itemsite_warehous_id, item_freightclass_id LOOP
17071
 
 
17072
 
    IF (_debug) THEN
17073
 
      RAISE NOTICE '_weights.weight - %', _weights.weight;
17074
 
      RAISE NOTICE '_weights.itemsite_warehous_id = %', _weights.itemsite_warehous_id;
17075
 
      RAISE NOTICE '_weights.item_freightclass_id = %', _weights.item_freightclass_id;
17076
 
    END IF;
17077
 
 
17078
 
    -- First get a sales price if any so we when we find other prices
17079
 
    -- we can determine if we want that price or this price.
17080
 
    --  Check for a Sale Price
17081
 
    SELECT ipsfreight_id,
17082
 
           CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id,
17083
 
                                                           ipsfreight_price, _order.orderdate)
17084
 
                ELSE currToCurr(ipshead_curr_id, _order.curr_id,
17085
 
                                (_weights.weight * ipsfreight_price), _order.orderdate)
17086
 
           END AS price
17087
 
           INTO _sales
17088
 
    FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id)
17089
 
                    JOIN sale ON (sale_ipshead_id=ipshead_id)
17090
 
    WHERE ( (ipsfreight_qtybreak <= _weights.weight)
17091
 
      AND   ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id))
17092
 
      AND   ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id))
17093
 
      AND   ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id))
17094
 
      AND   ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia))
17095
 
      AND   (CURRENT_DATE BETWEEN sale_startdate AND sale_enddate) )
17096
 
    ORDER BY ipsfreight_qtybreak DESC, price ASC
17097
 
    LIMIT 1;
17098
 
 
17099
 
    IF (_debug) THEN
17100
 
      IF (_sales.price IS NOT NULL) THEN
17101
 
        RAISE NOTICE 'Sales Price found, %', _sales.price;
17102
 
      END IF;
17103
 
    END IF;
17104
 
 
17105
 
    --  Check for a Customer Shipto Price
17106
 
    SELECT ipsfreight_id,
17107
 
           CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id,
17108
 
                                                           ipsfreight_price, _order.orderdate)
17109
 
                ELSE currToCurr(ipshead_curr_id, _order.curr_id,
17110
 
                                (_weights.weight * ipsfreight_price), _order.orderdate)
17111
 
           END AS price
17112
 
           INTO _price
17113
 
    FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id)
17114
 
                    JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
17115
 
    WHERE ( (ipsfreight_qtybreak <= _weights.weight)
17116
 
      AND   ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id))
17117
 
      AND   ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id))
17118
 
      AND   ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id))
17119
 
      AND   ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia))
17120
 
      AND   (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1))
17121
 
      AND   (ipsass_cust_id=_order.cust_id)
17122
 
      AND   (ipsass_shipto_id != -1)
17123
 
      AND   (ipsass_shipto_id=_order.shipto_id) )
17124
 
    ORDER BY ipsfreight_qtybreak DESC, price ASC
17125
 
    LIMIT 1;
17126
 
 
17127
 
    IF (_debug) THEN
17128
 
      IF (_price.price IS NOT NULL) THEN
17129
 
        RAISE NOTICE 'Customer Shipto Price found, %', _price.price;
17130
 
      END IF;
17131
 
    END IF;
17132
 
 
17133
 
    IF (_price.price IS NULL) THEN
17134
 
    --  Check for a Customer Shipto Pattern Price
17135
 
      SELECT ipsfreight_id,
17136
 
             CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id,
17137
 
                                                             ipsfreight_price, _order.orderdate)
17138
 
                  ELSE currToCurr(ipshead_curr_id, _order.curr_id,
17139
 
                                  (_weights.weight * ipsfreight_price), _order.orderdate)
17140
 
             END AS price
17141
 
             INTO _price
17142
 
      FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id)
17143
 
                      JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
17144
 
      WHERE ( (ipsfreight_qtybreak <= _weights.weight)
17145
 
        AND   (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1))
17146
 
        AND   (ipsass_cust_id=_order.cust_id)
17147
 
        AND   (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0)
17148
 
        AND   (_order.shipto_num ~ ipsass_shipto_pattern)
17149
 
        AND   ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id))
17150
 
        AND   ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id))
17151
 
        AND   ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id))
17152
 
        AND   ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia)) )
17153
 
      ORDER BY ipsfreight_qtybreak DESC, price ASC
17154
 
      LIMIT 1;
17155
 
 
17156
 
      IF (_debug) THEN
17157
 
        IF (_price.price IS NOT NULL) THEN
17158
 
          RAISE NOTICE 'Customer Shipto Pattern Price found, %', _price.price;
17159
 
        END IF;
17160
 
      END IF;
17161
 
 
17162
 
    END IF;
17163
 
 
17164
 
    IF (_price.price IS NULL) THEN
17165
 
    --  Check for a Customer Price
17166
 
      SELECT ipsfreight_id,
17167
 
             CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id,
17168
 
                                                             ipsfreight_price, _order.orderdate)
17169
 
                  ELSE currToCurr(ipshead_curr_id, _order.curr_id,
17170
 
                                  (_weights.weight * ipsfreight_price), _order.orderdate)
17171
 
             END AS price
17172
 
             INTO _price
17173
 
      FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id)
17174
 
                      JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
17175
 
      WHERE ( (ipsfreight_qtybreak <= _weights.weight)
17176
 
        AND   ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id))
17177
 
        AND   ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id))
17178
 
        AND   ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id))
17179
 
        AND   ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia))
17180
 
        AND   (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1))
17181
 
        AND   (ipsass_cust_id=_order.cust_id)
17182
 
        AND   (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0) )
17183
 
      ORDER BY ipsfreight_qtybreak DESC, price ASC
17184
 
      LIMIT 1;
17185
 
 
17186
 
      IF (_debug) THEN
17187
 
        IF (_price.price IS NOT NULL) THEN
17188
 
          RAISE NOTICE 'Customer Price found, %', _price.price;
17189
 
        END IF;
17190
 
      END IF;
17191
 
 
17192
 
    END IF;
17193
 
 
17194
 
    IF (_price.price IS NULL) THEN
17195
 
    --  Check for a Customer Type Price
17196
 
      SELECT ipsfreight_id,
17197
 
             CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id,
17198
 
                                                             ipsfreight_price, _order.orderdate)
17199
 
                  ELSE currToCurr(ipshead_curr_id, _order.curr_id,
17200
 
                                  (_weights.weight * ipsfreight_price), _order.orderdate)
17201
 
             END AS price
17202
 
             INTO _price
17203
 
      FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id)
17204
 
                      JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
17205
 
      WHERE ( (ipsfreight_qtybreak <= _weights.weight)
17206
 
        AND   ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id))
17207
 
        AND   ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id))
17208
 
        AND   ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id))
17209
 
        AND   ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia))
17210
 
        AND   (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1))
17211
 
        AND   (ipsass_custtype_id=_order.custtype_id) )
17212
 
      ORDER BY ipsfreight_qtybreak DESC, price ASC
17213
 
      LIMIT 1;
17214
 
 
17215
 
      IF (_debug) THEN
17216
 
        IF (_price.price IS NOT NULL) THEN
17217
 
          RAISE NOTICE 'Customer Type Price found, %', _price.price;
17218
 
        END IF;
17219
 
      END IF;
17220
 
 
17221
 
    END IF;
17222
 
 
17223
 
    IF (_price.price IS NULL) THEN
17224
 
    --  Check for a Customer Type Pattern Price
17225
 
      SELECT ipsfreight_id,
17226
 
             CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id,
17227
 
                                                             ipsfreight_price, _order.orderdate)
17228
 
                  ELSE currToCurr(ipshead_curr_id, _order.curr_id,
17229
 
                                  (_weights.weight * ipsfreight_price), _order.orderdate)
17230
 
             END AS price
17231
 
             INTO _price
17232
 
      FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id)
17233
 
                      JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
17234
 
      WHERE ( (ipsfreight_qtybreak <= _weights.weight)
17235
 
        AND   ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id))
17236
 
        AND   ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id))
17237
 
        AND   ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id))
17238
 
        AND   ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia))
17239
 
        AND   (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1))
17240
 
        AND   (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0)
17241
 
        AND   (_order.custtype_code ~ ipsass_custtype_pattern) )
17242
 
      ORDER BY ipsfreight_qtybreak DESC, price ASC
17243
 
      LIMIT 1;
17244
 
 
17245
 
      IF (_debug) THEN
17246
 
        IF (_price.price IS NOT NULL) THEN
17247
 
          RAISE NOTICE 'Customer Type Pattern Price found, %', _price.price;
17248
 
        END IF;
17249
 
      END IF;
17250
 
 
17251
 
    END IF;
17252
 
 
17253
 
    -- Select the lowest price  
17254
 
    IF ( (_price.price IS NOT NULL) AND ((_sales.price IS NULL) OR (_price.price < _sales.price)) ) THEN
17255
 
      _freightid := _price.ipsfreight_id;
17256
 
      _totalprice := _price.price;
17257
 
    ELSE
17258
 
      IF ( (_sales.price IS NOT NULL) AND ((_price.price IS NULL) OR (_sales.price <= _price.price)) ) THEN
17259
 
        _freightid := _sales.ipsfreight_id;
17260
 
        _totalprice := _sales.price;
17261
 
      END IF;
17262
 
    END IF;
17263
 
 
17264
 
    -- Total
17265
 
    IF (_freightid IS NOT NULL) THEN
17266
 
      _result := _result + _totalprice;
17267
 
    END IF;
17268
 
 
17269
 
    END LOOP;
17270
 
    RETURN ROUND(_result,2);
17271
 
  END IF;
17272
 
 
17273
 
  IF (_shipment.shiphead_order_type = 'TO') THEN
17274
 
  --Transfer Orders
17275
 
  
17276
 
    SELECT noNeg( (SELECT SUM(toitem_freight) + tohead_freight
17277
 
                   FROM tohead, toitem
17278
 
                   WHERE (toitem_tohead_id=tohead_id)
17279
 
                     AND (tohead_id = _shipment.shiphead_order_id)
17280
 
                   GROUP BY tohead_freight) -
17281
 
                  COALESCE((SELECT SUM(shiphead_freight)
17282
 
                            FROM shiphead
17283
 
                            WHERE (shiphead_order_id = _shipment.shiphead_order_id)
17284
 
                              AND (shiphead_shipped='true')), 0) ) INTO _result;
17285
 
    RETURN _result;
17286
 
  END IF;
17287
 
 
17288
 
  RETURN _result;
17289
 
 
17290
 
END;
17291
 
$_$;
17292
 
 
17293
 
 
17294
 
ALTER FUNCTION public.calcshipfreight(integer) OWNER TO admin;
17295
 
 
17296
 
--
17297
 
--
17298
 
 
17299
 
CREATE FUNCTION calctotalslipqty(integer) RETURNS numeric
17300
 
    LANGUAGE plpgsql
17301
 
    AS $_$
17302
 
DECLARE
17303
 
  pTagid ALIAS FOR $1;
17304
 
  _qty NUMERIC := 0;
17305
 
 
17306
 
BEGIN
17307
 
 
17308
 
  SELECT SUM(COALESCE(cntslip_qty, 0.0)) INTO _qty
17309
 
  FROM cntslip
17310
 
  WHERE (cntslip_cnttag_id=pTagid);
17311
 
 
17312
 
  RETURN _qty;
17313
 
 
17314
 
END;
17315
 
$_$;
17316
 
 
17317
 
 
17318
 
ALTER FUNCTION public.calctotalslipqty(integer) OWNER TO admin;
17319
 
 
17320
 
--
17321
 
--
17322
 
 
17323
 
CREATE FUNCTION calculatefreightdetail(integer, integer, text, integer, integer, text, date, text, integer, character varying, integer, integer, numeric) RETURNS SETOF freightdata
17324
 
    LANGUAGE plpgsql
17325
 
    AS $_$
17326
 
DECLARE
17327
 
  pCustId ALIAS FOR $1;
17328
 
  pCustTypeId ALIAS FOR $2;
17329
 
  pCustTypeCode ALIAS FOR $3;
17330
 
  pShiptoId ALIAS FOR $4;
17331
 
  pShipZoneId ALIAS FOR $5;
17332
 
  pShiptoNum ALIAS FOR $6;
17333
 
  pOrderDate ALIAS FOR $7;
17334
 
  pShipVia ALIAS FOR $8;
17335
 
  pCurrId ALIAS FOR $9;
17336
 
  pCurrAbbr ALIAS FOR $10;
17337
 
  pItemSiteWhsId ALIAS FOR $11;
17338
 
  pItemFreightclassId ALIAS FOR $12;
17339
 
  pWeight ALIAS FOR $13;
17340
 
 
17341
 
  _row freightData%ROWTYPE;
17342
 
  _price RECORD;
17343
 
  _sales RECORD;
17344
 
  _freightid INTEGER;
17345
 
  _totalprice NUMERIC;
17346
 
  _asof DATE;
17347
 
  _debug BOOLEAN := FALSE;
17348
 
 
17349
 
BEGIN
17350
 
 
17351
 
  --Get pricing effectivity metric
17352
 
  IF (SELECT fetchMetricText('soPriceEffective') = 'OrderDate') THEN
17353
 
    _asof := pOrderDate;
17354
 
  ELSE
17355
 
    _asof := CURRENT_DATE;
17356
 
  END IF;
17357
 
 
17358
 
  _freightid := NULL;
17359
 
  _totalprice := 0.0;
17360
 
 
17361
 
  IF (_debug) THEN
17362
 
    RAISE NOTICE 'pWeight - %', pWeight;
17363
 
    RAISE NOTICE 'pItemSiteWhsId = %', pItemSiteWhsId;
17364
 
    RAISE NOTICE 'pItemFreightclassId = %', pItemFreightclassId;
17365
 
  END IF;
17366
 
 
17367
 
  SELECT ipsfreight_id,
17368
 
    CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId,
17369
 
        ipsfreight_price, pOrderDate)
17370
 
      ELSE currToCurr(ipshead_curr_id, pCurrId,
17371
 
        (pWeight * ipsfreight_price), pOrderDate)
17372
 
    END AS price
17373
 
  INTO _sales
17374
 
  FROM ipsfreight
17375
 
  JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id)
17376
 
  JOIN sale ON (sale_ipshead_id=ipshead_id)
17377
 
  WHERE ( (ipsfreight_qtybreak <= pWeight)
17378
 
    AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId))
17379
 
    AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId))
17380
 
    AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId))
17381
 
    AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia))
17382
 
    AND (_asof BETWEEN sale_startdate AND sale_enddate)
17383
 
    AND (pCustId IS NOT NULL) )
17384
 
  ORDER BY ipsfreight_qtybreak DESC, price ASC
17385
 
  LIMIT 1;
17386
 
 
17387
 
  IF (_debug) THEN
17388
 
    IF (_sales.price IS NOT NULL) THEN
17389
 
      RAISE NOTICE 'Sales Price found, %', _sales.price;
17390
 
    END IF;
17391
 
  END IF;
17392
 
 
17393
 
  SELECT ipsfreight_id,
17394
 
    CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId,
17395
 
        ipsfreight_price, pOrderDate)
17396
 
      ELSE currToCurr(ipshead_curr_id, pCurrId,
17397
 
        (pWeight * ipsfreight_price), pOrderDate)
17398
 
    END AS price
17399
 
  INTO _price
17400
 
  FROM ipsfreight
17401
 
  JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id)
17402
 
  JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
17403
 
  WHERE ( (ipsfreight_qtybreak <= pWeight)
17404
 
    AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId))
17405
 
    AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId))
17406
 
    AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId))
17407
 
    AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia))
17408
 
    AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1))
17409
 
    AND   (ipsass_shipto_id != -1)
17410
 
    AND   (ipsass_shipto_id=pShiptoId) )
17411
 
  ORDER BY ipsfreight_qtybreak DESC, price ASC
17412
 
  LIMIT 1;
17413
 
 
17414
 
  IF (_debug) THEN
17415
 
    IF (_price.price IS NOT NULL) THEN
17416
 
      RAISE NOTICE 'Customer Shipto Price found, %', _price.price;
17417
 
    END IF;
17418
 
  END IF;
17419
 
 
17420
 
  IF (_price.price IS NULL) THEN
17421
 
  SELECT ipsfreight_id,
17422
 
    CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId,
17423
 
        ipsfreight_price, pOrderDate)
17424
 
      ELSE currToCurr(ipshead_curr_id, pCurrId,
17425
 
        (pWeight * ipsfreight_price), pOrderDate)
17426
 
    END AS price
17427
 
  INTO _price
17428
 
  FROM ipsfreight
17429
 
  JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id)
17430
 
  JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
17431
 
  WHERE ( (ipsfreight_qtybreak <= pWeight)
17432
 
    AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1))
17433
 
    AND (ipsass_cust_id=pCustId)
17434
 
    AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0)
17435
 
    AND (pShiptoNum ~ ipsass_shipto_pattern)
17436
 
    AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId))
17437
 
    AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId))
17438
 
    AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId))
17439
 
    AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia)) )
17440
 
  ORDER BY ipsfreight_qtybreak DESC, price ASC
17441
 
  LIMIT 1;
17442
 
 
17443
 
  IF (_debug) THEN
17444
 
    IF (_price.price IS NOT NULL) THEN
17445
 
      RAISE NOTICE 'Customer Shipto Pattern Price found, %', _price.price;
17446
 
    END IF;
17447
 
  END IF;
17448
 
 
17449
 
  END IF;
17450
 
 
17451
 
  IF (_price.price IS NULL) THEN
17452
 
  SELECT ipsfreight_id,
17453
 
    CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId,
17454
 
        ipsfreight_price, pOrderDate)
17455
 
      ELSE currToCurr(ipshead_curr_id, pCurrId,
17456
 
        (pWeight * ipsfreight_price), pOrderDate)
17457
 
    END AS price
17458
 
  INTO _price
17459
 
  FROM ipsfreight
17460
 
  JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id)
17461
 
  JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
17462
 
  WHERE ( (ipsfreight_qtybreak <= pWeight)
17463
 
    AND((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId))
17464
 
    AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId))
17465
 
    AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId))
17466
 
    AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia))
17467
 
    AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1))
17468
 
    AND (ipsass_cust_id=pCustId)
17469
 
    AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0) )
17470
 
  ORDER BY ipsfreight_qtybreak DESC, price ASC
17471
 
  LIMIT 1;
17472
 
 
17473
 
  IF (_debug) THEN
17474
 
    IF (_price.price IS NOT NULL) THEN
17475
 
      RAISE NOTICE 'Customer Price found, %', _price.price;
17476
 
    END IF;
17477
 
  END IF;
17478
 
 
17479
 
  END IF;
17480
 
 
17481
 
  IF (_price.price IS NULL) THEN
17482
 
  SELECT ipsfreight_id,
17483
 
    CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId,
17484
 
        ipsfreight_price, pOrderDate)
17485
 
      ELSE currToCurr(ipshead_curr_id, pCurrId,
17486
 
        (pWeight * ipsfreight_price), pOrderDate)
17487
 
    END AS price
17488
 
  INTO _price
17489
 
  FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id)
17490
 
                  JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
17491
 
  WHERE ( (ipsfreight_qtybreak <= pWeight)
17492
 
    AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId))
17493
 
    AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId))
17494
 
    AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId))
17495
 
    AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia))
17496
 
    AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1))
17497
 
    AND (ipsass_custtype_id=pCustTypeId) )
17498
 
  ORDER BY ipsfreight_qtybreak DESC, price ASC
17499
 
  LIMIT 1;
17500
 
 
17501
 
  IF (_debug) THEN
17502
 
    IF (_price.price IS NOT NULL) THEN
17503
 
      RAISE NOTICE 'Customer Type Price found, %', _price.price;
17504
 
    END IF;
17505
 
  END IF;
17506
 
 
17507
 
  END IF;
17508
 
 
17509
 
  IF (_price.price IS NULL) THEN
17510
 
  SELECT ipsfreight_id,
17511
 
    CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId,
17512
 
        ipsfreight_price, pOrderDate)
17513
 
      ELSE currToCurr(ipshead_curr_id, pCurrId,
17514
 
        (pWeight * ipsfreight_price), pOrderDate)
17515
 
    END AS price
17516
 
  INTO _price
17517
 
  FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id)
17518
 
                  JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
17519
 
  WHERE ( (ipsfreight_qtybreak <= pWeight)
17520
 
    AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId))
17521
 
    AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId))
17522
 
    AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId))
17523
 
    AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia))
17524
 
    AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1))
17525
 
    AND (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0)
17526
 
    AND (pCustTypeCode ~ ipsass_custtype_pattern) )
17527
 
  ORDER BY ipsfreight_qtybreak DESC, price ASC
17528
 
  LIMIT 1;
17529
 
 
17530
 
  IF (_debug) THEN
17531
 
    IF (_price.price IS NOT NULL) THEN
17532
 
      RAISE NOTICE 'Customer Type Pattern Price found, %', _price.price;
17533
 
    END IF;
17534
 
  END IF;
17535
 
 
17536
 
  END IF;
17537
 
 
17538
 
  -- Select the lowest price
17539
 
  IF ( (_price.price IS NOT NULL) AND ((_sales.price IS NULL) OR (_price.price < _sales.price)) ) THEN
17540
 
    _freightid := _price.ipsfreight_id;
17541
 
    _totalprice := _price.price;
17542
 
  ELSE
17543
 
    IF ( (_sales.price IS NOT NULL) AND ((_price.price IS NULL) OR (_sales.price <= _price.price)) ) THEN
17544
 
      _freightid := _sales.ipsfreight_id;
17545
 
      _totalprice := _sales.price;
17546
 
    END IF;
17547
 
  END IF;
17548
 
 
17549
 
  IF (_debug) THEN
17550
 
    RAISE NOTICE '_freightid = %', _freightid;
17551
 
    RAISE NOTICE '_totalprice = %', _totalprice;
17552
 
  END IF;
17553
 
 
17554
 
  -- Get information for the selected ipsfreight
17555
 
  -- and return
17556
 
  IF (_freightid IS NULL) THEN
17557
 
    _row.freightdata_schedule := 'N/A';
17558
 
    _row.freightdata_from := '';
17559
 
    _row.freightdata_to := '';
17560
 
    _row.freightdata_shipvia := '';
17561
 
    _row.freightdata_freightclass := '';
17562
 
    _row.freightdata_weight := 0;
17563
 
    _row.freightdata_uom := '';
17564
 
    _row.freightdata_price := 0;
17565
 
    _row.freightdata_type := '';
17566
 
    _row.freightdata_total := 0;
17567
 
    _row.freightdata_currency := '';
17568
 
    RETURN NEXT _row;
17569
 
  ELSE
17570
 
    SELECT ipshead_name AS freightdata_schedule,
17571
 
      COALESCE(warehous_code, 'Any') AS freightdata_from,
17572
 
      COALESCE(shipzone_name, 'Any') AS freightdata_to,
17573
 
      COALESCE(ipsfreight_shipvia, 'Any') AS freightdata_shipvia,
17574
 
      COALESCE(freightclass_code, 'Any') AS freightdata_freightclass,
17575
 
      pWeight AS freightdata_weight,
17576
 
      uom_name AS freightdata_uom,
17577
 
      currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) AS freightdata_price,
17578
 
      CASE WHEN (ipsfreight_type='F') THEN 'Flat Rate'
17579
 
        ELSE 'Per UOM'
17580
 
      END AS freightdata_type,
17581
 
      _totalprice AS freightdata_total,
17582
 
      pCurrAbbr AS freightdata_currency
17583
 
    INTO _row
17584
 
    FROM ipsfreight
17585
 
      JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id)
17586
 
      LEFT OUTER JOIN uom ON (uom_item_weight)
17587
 
      LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)
17588
 
      LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)
17589
 
      LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)
17590
 
    WHERE (ipsfreight_id=_freightid);
17591
 
 
17592
 
    RETURN NEXT _row;
17593
 
  END IF;
17594
 
 
17595
 
  RETURN;
17596
 
END;
17597
 
$_$;
17598
 
 
17599
 
 
17600
 
ALTER FUNCTION public.calculatefreightdetail(integer, integer, text, integer, integer, text, date, text, integer, character varying, integer, integer, numeric) OWNER TO admin;
17601
 
 
17602
 
--
17603
 
--
17604
 
 
17605
 
CREATE FUNCTION calculatesubtax(integer, date, integer, numeric, integer) RETURNS SETOF taxdetail
17606
 
    LANGUAGE plpgsql
17607
 
    AS $_$
17608
 
DECLARE
17609
 
  pTaxCodeId ALIAS FOR $1;
17610
 
  pDate ALIAS FOR $2;
17611
 
  pCurrId ALIAS FOR $3;
17612
 
  pAmount ALIAS FOR $4;
17613
 
  pLevel ALIAS FOR $5;
17614
 
  _row taxdetail%ROWTYPE;
17615
 
  _rownumber INTEGER := 1;
17616
 
  _calc_tax Numeric :=0;
17617
 
  _x RECORD;
17618
 
  _y RECORD;
17619
 
 
17620
 
BEGIN
17621
 
  FOR _x IN 
17622
 
 
17623
 
  SELECT tax_id, tax_code, tax_descrip, tax_basis_tax_id,
17624
 
    taxrate_id, taxrate_percent, taxrate_curr_id, taxrate_amount,  
17625
 
    taxclass_id, taxclass_code, COALESCE(taxclass_sequence,0) AS taxclass_sequence,
17626
 
    curr_id, curr_abbr
17627
 
  FROM tax, taxrate, taxclass, curr_symbol
17628
 
  WHERE ((tax_id = taxrate_tax_id)
17629
 
  AND (tax_taxclass_id = taxclass_id)
17630
 
  AND (taxrate_curr_id = curr_id)
17631
 
  AND (tax_basis_tax_id = pTaxCodeId)
17632
 
  AND (pDate BETWEEN taxrate_effective AND taxrate_expires)
17633
 
  AND (taxrate_curr_id = pCurrId))
17634
 
  
17635
 
  LOOP
17636
 
    SELECT 
17637
 
      ROUND((_x.taxrate_percent * pAmount + currToCurr(_x.curr_id, pCurrId, _x.taxrate_amount, pDate)), 6) 
17638
 
    INTO _calc_tax;
17639
 
 
17640
 
    _row.taxdetail_tax_id = _x.tax_id;
17641
 
    _row.taxdetail_tax_code = _x.tax_code;
17642
 
    _row.taxdetail_tax_descrip = _x.tax_descrip;
17643
 
    _row.taxdetail_tax_basis_tax_id = _x.tax_basis_tax_id ;
17644
 
    _row.taxdetail_taxrate_percent = _x.taxrate_percent;
17645
 
    _row.taxdetail_taxrate_amount = _x.taxrate_amount;
17646
 
    _row.taxdetail_level = pLevel + 1;
17647
 
    _row.taxdetail_taxclass_id = _x.taxclass_id ; 
17648
 
    _row.taxdetail_taxclass_code = _x.taxclass_code;
17649
 
    _row.taxdetail_taxclass_sequence = _x.taxclass_sequence;
17650
 
    _row.taxdetail_tax = _calc_tax;
17651
 
    _row.taxdetail_curr_id = _x.curr_id;
17652
 
    _row.taxdetail_curr_abbr = _x.curr_abbr;
17653
 
 
17654
 
    RETURN NEXT _row;
17655
 
    _rownumber := _rownumber + 1;
17656
 
 
17657
 
    FOR _y IN  
17658
 
    SELECT * 
17659
 
    FROM calculateSubTax( _x.tax_id, pDate, pCurrId, _calc_tax, pLevel + 1)
17660
 
    LOOP
17661
 
      _row.taxdetail_tax_id = _y.taxdetail_tax_id;
17662
 
      _row.taxdetail_tax_code = _y.taxdetail_tax_code;
17663
 
      _row.taxdetail_tax_descrip = _y.taxdetail_tax_descrip;
17664
 
      _row.taxdetail_tax_basis_tax_id = _y.taxdetail_tax_basis_tax_id ;
17665
 
      _row.taxdetail_taxrate_percent = _y.taxdetail_taxrate_percent;
17666
 
      _row.taxdetail_taxrate_amount = _y.taxdetail_taxrate_amount;
17667
 
      _row.taxdetail_level = _y.taxdetail_level + 1;
17668
 
      _row.taxdetail_taxclass_id = _y.taxdetail_taxclass_id ; 
17669
 
      _row.taxdetail_taxclass_code = _y.taxdetail_taxclass_code;
17670
 
      _row.taxdetail_taxclass_sequence = _y.taxdetail_taxclass_sequence;
17671
 
      _row.taxdetail_tax = _y.taxdetail_tax;
17672
 
      _row.taxdetail_curr_id = _y.taxdetail_curr_id;
17673
 
      _row.taxdetail_curr_abbr = _y.taxdetail_curr_abbr;
17674
 
      
17675
 
      RETURN NEXT _row;
17676
 
      _rownumber := _rownumber + 1;
17677
 
 
17678
 
    END LOOP;
17679
 
 
17680
 
  END LOOP;
17681
 
 
17682
 
END;
17683
 
$_$;
17684
 
 
17685
 
 
17686
 
ALTER FUNCTION public.calculatesubtax(integer, date, integer, numeric, integer) OWNER TO admin;
17687
 
 
17688
 
--
17689
 
--
17690
 
 
17691
 
CREATE FUNCTION calculatetax(integer, integer, date, integer, numeric) RETURNS numeric
17692
 
    LANGUAGE plpgsql
17693
 
    AS $_$
17694
 
DECLARE
17695
 
  pTaxZoneId ALIAS FOR  $1;
17696
 
  pTaxTypeId ALIAS FOR  $2;
17697
 
  pDate ALIAS FOR  $3;
17698
 
  pCurrId ALIAS FOR $4;
17699
 
  pAmount ALIAS FOR $5;
17700
 
  _tottax numeric := 0;  -- total tax
17701
 
  
17702
 
BEGIN
17703
 
 
17704
 
  SELECT COALESCE(ROUND(SUM(taxdetail_tax),6),0)
17705
 
    INTO _tottax 
17706
 
  FROM calculateTaxDetail(pTaxZoneId, pTaxTypeId, pDate, pCurrId, pAmount);
17707
 
 
17708
 
  RETURN _tottax;
17709
 
  
17710
 
END;
17711
 
$_$;
17712
 
 
17713
 
 
17714
 
ALTER FUNCTION public.calculatetax(integer, integer, date, integer, numeric) OWNER TO admin;
17715
 
 
17716
 
--
17717
 
--
17718
 
 
17719
 
CREATE FUNCTION calculatetaxdetail(integer, integer, date, integer, numeric) RETURNS SETOF taxdetail
17720
 
    LANGUAGE plpgsql
17721
 
    AS $_$
17722
 
DECLARE
17723
 
  pTaxZoneId ALIAS FOR  $1;
17724
 
  pTaxTypeId ALIAS FOR  $2;
17725
 
  pDate ALIAS FOR  $3;
17726
 
  pCurrId ALIAS FOR $4;
17727
 
  pAmount ALIAS FOR $5;
17728
 
  _row taxdetail%ROWTYPE;
17729
 
  _x RECORD;
17730
 
  _y RECORD;
17731
 
  _z RECORD;
17732
 
  _currcum numeric := 0;  -- Current cumulative tax
17733
 
  _currseq numeric := 0;  -- Current group sequence
17734
 
  _prevcum numeric := 0;  -- Previous cumulative tax
17735
 
  _tax numeric := 0;      -- Calculated tax amount
17736
 
  _taxbasis numeric := 0;  -- Used for calculating sub taxes
17737
 
 
17738
 
BEGIN
17739
 
 
17740
 
  IF ((COALESCE(pTaxTypeId,-1) = -1) OR (COALESCE(pTaxZoneId,-1) = -1)) THEN
17741
 
    RETURN;
17742
 
  END IF;
17743
 
 
17744
 
  SELECT DISTINCT
17745
 
    COALESCE(taxass_taxzone_id, -1) AS taxzone_id,
17746
 
    COALESCE(taxass_taxtype_id, -1) AS taxtype_id,
17747
 
    taxass_tax_id,
17748
 
    CASE
17749
 
      WHEN ((taxass_taxzone_id IS NOT NULL) AND (taxass_taxtype_id IS NOT NULL)) THEN
17750
 
        0
17751
 
      WHEN ((taxass_taxzone_id IS NOT NULL) AND (taxass_taxtype_id IS NULL)) THEN
17752
 
        1
17753
 
      WHEN ((taxass_taxzone_id IS NULL) AND (taxass_taxtype_id IS NOT NULL)) THEN
17754
 
        2
17755
 
      ELSE
17756
 
        3
17757
 
    END AS sequence
17758
 
    INTO _x
17759
 
  FROM taxass
17760
 
  WHERE  ((COALESCE(taxass_taxzone_id, pTaxZoneId, -1) = COALESCE(pTaxZoneId,-1))
17761
 
  AND    (COALESCE(taxass_taxtype_id, pTaxTypeId, -1) = COALESCE(pTaxTypeId,-1)))
17762
 
  ORDER BY sequence LIMIT 1;
17763
 
 
17764
 
  --Now loop through each tax detail record and return calculated result
17765
 
  FOR _y IN
17766
 
    SELECT  --the data required by taxdetail type.  Coalesce group sequence to 0 if no class.
17767
 
    tax_id
17768
 
    ,tax_code
17769
 
    ,tax_descrip
17770
 
    ,tax_basis_tax_id
17771
 
    ,taxrate_percent
17772
 
    ,taxrate_amount
17773
 
    ,0 as taxdetail_level 
17774
 
    ,taxclass_id
17775
 
    ,taxclass_code
17776
 
    ,COALESCE(taxclass_sequence, 0) AS taxclass_sequence
17777
 
    ,0 as taxdetail_tax
17778
 
    ,curr_id
17779
 
    ,curr_abbr  
17780
 
    FROM taxass, taxclass RIGHT OUTER JOIN tax  
17781
 
      LEFT OUTER JOIN taxrate ON (taxrate_tax_id=tax_id)
17782
 
    ON (tax_taxclass_id=taxclass_id),
17783
 
    curr_symbol 
17784
 
    WHERE 
17785
 
    taxass_tax_id=tax_id
17786
 
    AND taxrate_curr_id=curr_id
17787
 
    AND COALESCE(taxass_taxzone_id, -1) = _x.taxzone_id
17788
 
    AND COALESCE(taxass_taxtype_id, -1) = _x.taxtype_id
17789
 
    AND pDate BETWEEN COALESCE(taxrate_effective, startoftime()) AND COALESCE(taxrate_expires, endoftime())
17790
 
    ORDER BY COALESCE(taxclass_sequence, 0)
17791
 
  LOOP
17792
 
    -- If sequence has changed, cache the previous cumulative tax
17793
 
    IF (_currseq != _x.sequence) THEN
17794
 
      _prevcum := _currcum;
17795
 
    END IF;
17796
 
 
17797
 
    -- Calculate the tax amount.  Convert currency for flat rate amounts
17798
 
    SELECT 
17799
 
    ROUND((_y.taxrate_percent * (pAmount + _prevcum) + currToCurr(_y.curr_id, pCurrId, _y.taxrate_amount, pDate)), 6) 
17800
 
    INTO _tax
17801
 
    FROM tax JOIN  taxrate ON (tax_id = taxrate_tax_id)
17802
 
    WHERE (tax_id=_x.taxass_tax_id)
17803
 
    AND (pDate BETWEEN COALESCE(taxrate_effective, startoftime()) AND COALESCE(taxrate_expires, endoftime()));
17804
 
 
17805
 
    --Map fields to _row
17806
 
 
17807
 
    _row.taxdetail_tax_id := _y.tax_id;
17808
 
    _row.taxdetail_tax_code := _y.tax_code;
17809
 
    _row.taxdetail_tax_descrip := _y.tax_descrip;
17810
 
    _row.taxdetail_tax_basis_tax_id := _y.tax_basis_tax_id;
17811
 
    _row.taxdetail_taxrate_percent := _y.taxrate_percent;
17812
 
    _row.taxdetail_taxrate_amount := _y.taxrate_amount;
17813
 
    _row.taxdetail_level := _y.taxdetail_level;
17814
 
    _row.taxdetail_taxclass_id := _y.taxclass_id;
17815
 
    _row.taxdetail_taxclass_code := _y.taxclass_code;
17816
 
    _row.taxdetail_taxclass_sequence := _y.taxclass_sequence;
17817
 
    _row.taxdetail_tax := _tax;
17818
 
    _row.taxdetail_curr_id := _y.curr_id;
17819
 
    _row.taxdetail_curr_abbr := _y.curr_abbr;
17820
 
  
17821
 
    RETURN NEXT _row;
17822
 
 
17823
 
    -- Increment cumulative balance and sequence number
17824
 
    IF(_y.taxclass_sequence <> 0) THEN
17825
 
      _currcum := _currcum + _tax;
17826
 
    END IF;
17827
 
    _currseq := _y.taxclass_sequence;
17828
 
 
17829
 
    -- Loop to Calculate sub taxes
17830
 
    FOR _z IN
17831
 
    SELECT *
17832
 
    FROM calculateSubTax(_y.tax_id,pDate, pCurrId, _tax, 0)
17833
 
    LOOP
17834
 
     --Mapping of data
17835
 
    _row.taxdetail_tax_id := _z.taxdetail_tax_id;
17836
 
    _row.taxdetail_tax_code := _z.taxdetail_tax_code;
17837
 
    _row.taxdetail_tax_descrip := _z.taxdetail_tax_descrip;
17838
 
    _row.taxdetail_tax_basis_tax_id := _z.taxdetail_tax_basis_tax_id;
17839
 
    _row.taxdetail_taxrate_percent := _z.taxdetail_taxrate_percent;
17840
 
    _row.taxdetail_taxrate_amount := _z.taxdetail_taxrate_amount;
17841
 
    _row.taxdetail_level := _z.taxdetail_level;
17842
 
    _row.taxdetail_taxclass_id := _z.taxdetail_taxclass_id;
17843
 
    _row.taxdetail_taxclass_code := _z.taxdetail_taxclass_code;
17844
 
    _row.taxdetail_taxclass_sequence := _z.taxdetail_taxclass_sequence;
17845
 
    _row.taxdetail_tax := _z.taxdetail_tax;
17846
 
    _row.taxdetail_curr_id := _z.taxdetail_curr_id;
17847
 
    _row.taxdetail_curr_abbr := _z.taxdetail_curr_abbr;
17848
 
 
17849
 
     RETURN NEXT _row;
17850
 
     --Add to cumulative counter (_curcum)
17851
 
     _currcum := _currcum + _z.taxdetail_tax ;
17852
 
 
17853
 
    END LOOP;
17854
 
 
17855
 
   END LOOP;
17856
 
 
17857
 
END;
17858
 
 $_$;
17859
 
 
17860
 
 
17861
 
ALTER FUNCTION public.calculatetaxdetail(integer, integer, date, integer, numeric) OWNER TO admin;
17862
 
 
17863
 
--
17864
 
--
17865
 
 
17866
 
CREATE FUNCTION calculatetaxdetailline(text, integer) RETURNS SETOF taxdetail
17867
 
    LANGUAGE plpgsql
17868
 
    AS $_$
17869
 
DECLARE
17870
 
  pOrderType ALIAS FOR $1;
17871
 
  pOrderId ALIAS FOR $2;
17872
 
  _row taxdetail%ROWTYPE;
17873
 
  _qry text;
17874
 
  _totaltax numeric;
17875
 
  _y RECORD;
17876
 
  _table text;
17877
 
 
17878
 
BEGIN
17879
 
   _totaltax=0.0;
17880
 
 
17881
 
   IF pOrderType = 'II' THEN
17882
 
     _table := 'invcitemtax';
17883
 
   ELSIF pOrderType = 'BI' THEN
17884
 
     _table := 'cobilltax';
17885
 
   ELSIF pOrderType = 'CI' THEN
17886
 
     _table := 'cmitemtax';
17887
 
   ELSIF pOrderType = 'VI' THEN
17888
 
     _table := 'voitemtax';
17889
 
   ELSIF pOrderType = 'TI' THEN
17890
 
     _table := 'toitemtax';
17891
 
   ELSIF pOrderType = 'AR' THEN
17892
 
     _table := 'aropentax';
17893
 
   ELSIF pOrderType = 'AP' THEN
17894
 
     _table := 'apopentax';
17895
 
   END IF;
17896
 
 
17897
 
   _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, COALESCE(taxhist_sequence,0) AS taxhist_sequence
17898
 
            FROM ' || _table || '
17899
 
             JOIN tax ON (taxhist_tax_id=tax_id)
17900
 
            WHERE ( (taxhist_parent_id = ' || pOrderId || ') );';
17901
 
 
17902
 
   FOR _y IN  EXECUTE _qry
17903
 
   LOOP
17904
 
     _row.taxdetail_tax_id=_y.tax_id;
17905
 
     _row.taxdetail_tax_code = _y.tax_code;
17906
 
     _row.taxdetail_tax_descrip = _y.tax_descrip;
17907
 
     _row.taxdetail_tax = _y.taxhist_tax;
17908
 
     _row.taxdetail_level= 0 ;
17909
 
     _row.taxdetail_taxclass_sequence= _y.taxhist_sequence;
17910
 
     _totaltax = _totaltax + _y.taxhist_tax;
17911
 
     RETURN NEXT _row;
17912
 
   END LOOP;
17913
 
 END;
17914
 
$_$;
17915
 
 
17916
 
 
17917
 
ALTER FUNCTION public.calculatetaxdetailline(text, integer) OWNER TO admin;
17918
 
 
17919
 
--
17920
 
--
17921
 
 
17922
 
CREATE FUNCTION calculatetaxdetailsummary(text, integer, text) RETURNS SETOF taxdetail
17923
 
    LANGUAGE plpgsql
17924
 
    AS $_$
17925
 
DECLARE
17926
 
  pOrderType ALIAS FOR $1;
17927
 
  pOrderId ALIAS FOR $2;
17928
 
  pDisplayType ALIAS FOR $3;
17929
 
  _row taxdetail%ROWTYPE;
17930
 
  _qry text := '';
17931
 
  _qry1 text;
17932
 
  _totaltax numeric;
17933
 
  _x RECORD;
17934
 
  _y RECORD;
17935
 
  _table text;
17936
 
 
17937
 
BEGIN
17938
 
 _totaltax=0.0;
17939
 
 IF pOrderType IN ('S','Q','RA','PO') THEN
17940
 
 
17941
 
   IF pOrderType = 'S' THEN
17942
 
     _qry := 'SELECT ' || 'COALESCE(cohead_taxzone_id, -1) AS taxzone_id, cohead_orderdate AS order_date,
17943
 
                cohead_curr_id AS curr_id, COALESCE(coitem_taxtype_id, -1) AS taxtype_id,
17944
 
                ROUND((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio),2) AS amount
17945
 
              FROM cohead, coitem
17946
 
              WHERE ( (coitem_cohead_id = ' || pOrderId || ')
17947
 
               AND (' || 'cohead_id = coitem_cohead_id)
17948
 
               AND ( coitem_status != ''X'') )';
17949
 
   ELSEIF  pOrderType = 'Q' THEN
17950
 
     _qry := 'SELECT ' || 'COALESCE(quhead_taxzone_id, -1) AS taxzone_id, quhead_quotedate AS order_date,
17951
 
                quhead_curr_id AS curr_id, COALESCE(quitem_taxtype_id, -1) AS taxtype_id,
17952
 
                ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio),2) AS amount
17953
 
              FROM quhead, quitem
17954
 
              WHERE ( (quitem_quhead_id = ' || pOrderId || ')
17955
 
               AND (quhead_id = quitem_quhead_id) )';
17956
 
   ELSEIF  pOrderType = 'RA' THEN
17957
 
     _qry := 'SELECT ' || 'COALESCE(rahead_taxzone_id, -1) AS taxzone_id, rahead_authdate AS order_date,
17958
 
                rahead_curr_id AS curr_id, COALESCE(raitem_taxtype_id, -1) AS taxtype_id,
17959
 
                ROUND((raitem_qtyauthorized * raitem_qty_invuomratio) * (raitem_unitprice / raitem_price_invuomratio),2) AS amount
17960
 
              FROM rahead, raitem
17961
 
              WHERE ( (raitem_rahead_id = ' || pOrderId || ')
17962
 
               AND (rahead_id = raitem_rahead_id) )';
17963
 
   ELSEIF  pOrderType = 'PO' THEN
17964
 
     _qry := 'SELECT ' || 'COALESCE(pohead_taxzone_id, -1) AS taxzone_id, pohead_orderdate AS order_date,
17965
 
                pohead_curr_id AS curr_id, COALESCE(poitem_taxtype_id, -1) AS taxtype_id,
17966
 
                ROUND(poitem_qty_ordered * poitem_unitprice, 2) AS amount
17967
 
              FROM pohead, poitem
17968
 
              WHERE ( (poitem_pohead_id = ' || pOrderId || ')
17969
 
               AND (pohead_id = poitem_pohead_id) )';
17970
 
  END IF;
17971
 
 
17972
 
  FOR _x IN EXECUTE _qry
17973
 
  LOOP
17974
 
    _qry1 := 'SELECT * from calculatetaxdetail(' || _x.taxzone_id || ',' || _x.taxtype_id || ',''' || _x.order_date || ''',' || _x.curr_id  || ',' || _x.amount || ')';
17975
 
    FOR _y IN  EXECUTE _qry1
17976
 
    LOOP
17977
 
      _row.taxdetail_tax_id=_y.taxdetail_tax_id;
17978
 
      _row.taxdetail_tax_code = _y.taxdetail_tax_code;
17979
 
      _row.taxdetail_tax_descrip = _y.taxdetail_tax_descrip;
17980
 
      _row.taxdetail_tax = _y.taxdetail_tax;
17981
 
      _row.taxdetail_level=_y.taxdetail_level;
17982
 
      _row.taxdetail_taxclass_sequence= _y.taxdetail_taxclass_sequence;
17983
 
      _totaltax = _totaltax + _y.taxdetail_tax;
17984
 
      RETURN NEXT _row;
17985
 
    END LOOP;
17986
 
  END LOOP;
17987
 
 
17988
 
  IF pDisplayType = 'T' AND pOrderType <> 'PO' THEN
17989
 
   IF pOrderType = 'S' THEN
17990
 
    _qry := 'SELECT COALESCE(cohead_taxzone_id, -1) AS taxzone_id, cohead_orderdate AS order_date,
17991
 
               cohead_curr_id AS curr_id, cohead_freight AS freight
17992
 
             FROM cohead WHERE cohead_id = ' || pOrderId ;
17993
 
   ELSEIF  pOrderType = 'Q' THEN
17994
 
    _qry := 'SELECT COALESCE(quhead_taxzone_id, -1) AS taxzone_id, quhead_quotedate AS order_date,
17995
 
               quhead_curr_id AS curr_id, COALESCE(quhead_freight,0) AS freight
17996
 
             FROM quhead WHERE quhead_id = ' || pOrderId;
17997
 
   ELSEIF pOrderType = 'RA' THEN
17998
 
    _qry := 'SELECT COALESCE(rahead_taxzone_id, -1) AS taxzone_id, COALESCE(rahead_authdate,CURRENT_DATE) AS order_date,
17999
 
               rahead_curr_id AS curr_id, COALESCE(rahead_freight,0) AS freight
18000
 
             FROM rahead WHERE rahead_id = ' || pOrderId;
18001
 
   END IF;
18002
 
 
18003
 
  FOR _x IN EXECUTE _qry
18004
 
  LOOP
18005
 
     _qry1 := 'SELECT * from calculatetaxdetail(' || _x.taxzone_id || ', getfreighttaxtypeid(),''' || _x.order_date || ''',' || _x.curr_id  || ',' || _x.freight || ')';
18006
 
    FOR _y IN  EXECUTE _qry1
18007
 
    LOOP
18008
 
       _row.taxdetail_tax_id=_y.taxdetail_tax_id;
18009
 
       _row.taxdetail_tax_code = _y.taxdetail_tax_code;
18010
 
       _row.taxdetail_tax_descrip = _y.taxdetail_tax_descrip;
18011
 
       _row.taxdetail_tax = _y.taxdetail_tax;
18012
 
       _row.taxdetail_level=_y.taxdetail_level;
18013
 
       _row.taxdetail_taxclass_sequence= _y.taxdetail_taxclass_sequence;
18014
 
       _totaltax = _totaltax + _y.taxdetail_tax;
18015
 
       RETURN NEXT _row;
18016
 
     END LOOP;
18017
 
   END LOOP;
18018
 
  END IF;
18019
 
 
18020
 
 ELSEIF pOrderType IN ('I','B','CM', 'VO','TO') THEN
18021
 
   IF (pOrderType='I') THEN
18022
 
     _table := 'invcheadtax';
18023
 
   ELSIF (pOrderType='B') THEN
18024
 
     _table := 'cobmisctax';
18025
 
   ELSIF (pOrderType='CM') THEN
18026
 
     _table := 'cmheadtax';
18027
 
   ELSIF (pOrderType='VO') THEN
18028
 
     _table := 'voheadtax';
18029
 
   ELSIF (pOrderType='TO') THEN
18030
 
     _table := 'tohead';
18031
 
   END IF;
18032
 
 
18033
 
   IF pOrderType = 'I' AND (pDisplayType IN ('L','T')) THEN
18034
 
     _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence
18035
 
              FROM invchead, invcitemtax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id)
18036
 
               LEFT OUTER JOIN invcitem ON (invcitem_id=taxhist_parent_id)
18037
 
              WHERE invcitem_invchead_id = ' || pOrderId || '
18038
 
               AND invchead_id = invcitem_invchead_id ';
18039
 
   ELSIF pOrderType = 'B' AND (pDisplayType IN ('L','T')) THEN
18040
 
    _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence
18041
 
             FROM cobmisc, cobilltax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id)
18042
 
             LEFT OUTER JOIN cobill ON (cobill_id=taxhist_parent_id)
18043
 
             WHERE cobill_cobmisc_id = ' || pOrderId || '
18044
 
             AND cobmisc_id = cobill_cobmisc_id ';
18045
 
   ELSIF pOrderType = 'CM' AND (pDisplayType IN ('L','T')) THEN
18046
 
    _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence
18047
 
             FROM cmhead, cmitemtax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id)
18048
 
             LEFT OUTER JOIN cmitem ON (cmitem_id=taxhist_parent_id)
18049
 
             WHERE cmitem_cmhead_id = ' || pOrderId || '
18050
 
             AND cmhead_id = cmitem_cmhead_id ';
18051
 
   ELSIF pOrderType = 'VO' AND (pDisplayType IN ('L','T')) THEN
18052
 
    _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence
18053
 
             FROM vohead, voitemtax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id)
18054
 
             LEFT OUTER JOIN voitem ON (voitem_id=taxhist_parent_id)
18055
 
             WHERE voitem_vohead_id = ' || pOrderId || '
18056
 
             AND vohead_id = voitem_vohead_id ';
18057
 
   ELSIF pOrderType = 'TO' AND (pDisplayType IN ('L','T')) THEN
18058
 
    _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence
18059
 
             FROM tohead, toitemtax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id)
18060
 
             LEFT OUTER JOIN toitem ON (toitem_id=taxhist_parent_id)
18061
 
             WHERE toitem_tohead_id = ' || pOrderId || '
18062
 
             AND tohead_id = toitem_tohead_id ';
18063
 
   END IF;
18064
 
   IF pDisplayType IN ('F','T') AND pOrderType <> 'VO' THEN
18065
 
     IF (length(_qry) > 0) THEN
18066
 
       _qry := _qry || ' UNION ALL ';
18067
 
     END IF;
18068
 
     _qry := _qry || 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence
18069
 
              FROM ' || _table || '
18070
 
               JOIN tax ON (taxhist_tax_id=tax_id)
18071
 
              WHERE ( (taxhist_parent_id = ' || pOrderId || ')
18072
 
               AND (taxhist_taxtype_id=getfreighttaxtypeid()) )';
18073
 
   END IF;
18074
 
   IF pDisplayType IN ('A','T') THEN
18075
 
     IF (length(_qry) > 0) THEN
18076
 
       _qry := _qry || ' UNION ALL ';
18077
 
     END IF;
18078
 
     _qry := _qry || 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence
18079
 
              FROM ' || _table || '
18080
 
               JOIN tax ON (taxhist_tax_id=tax_id)
18081
 
              WHERE ( (taxhist_parent_id = ' || pOrderId || ')
18082
 
               AND (taxhist_taxtype_id=getadjustmenttaxtypeid()) )';
18083
 
 
18084
 
   END IF;
18085
 
   FOR _y IN  EXECUTE _qry
18086
 
   LOOP
18087
 
     _row.taxdetail_tax_id=_y.tax_id;
18088
 
     _row.taxdetail_tax_code = _y.tax_code;
18089
 
     _row.taxdetail_tax_descrip = _y.tax_descrip;
18090
 
     _row.taxdetail_tax = _y.taxhist_tax;
18091
 
     _row.taxdetail_level= 0 ;
18092
 
     _row.taxdetail_taxclass_sequence= COALESCE(_y.taxhist_sequence,0);
18093
 
     _totaltax = _totaltax + _y.taxhist_tax;
18094
 
     RETURN NEXT _row;
18095
 
   END LOOP;
18096
 
 END IF;
18097
 
 END;
18098
 
$_$;
18099
 
 
18100
 
 
18101
 
ALTER FUNCTION public.calculatetaxdetailsummary(text, integer, text) OWNER TO admin;
18102
 
 
18103
 
--
18104
 
--
18105
 
 
18106
 
CREATE FUNCTION calculatetaxhist(text, integer, integer, integer, date, integer, numeric) RETURNS boolean
18107
 
    LANGUAGE plpgsql
18108
 
    AS $_$
18109
 
DECLARE
18110
 
  pTableName ALIAS FOR $1;
18111
 
  pParentId  ALIAS FOR $2;
18112
 
  pTaxZoneId ALIAS FOR $3;
18113
 
  pTaxTypeId ALIAS FOR $4;
18114
 
  pDate      ALIAS FOR $5;
18115
 
  pCurrId    ALIAS FOR $6;
18116
 
  pAmount    ALIAS FOR $7;
18117
 
  _qry TEXT;
18118
 
  
18119
 
BEGIN
18120
 
  IF (pTableName IS NULL) THEN
18121
 
    RAISE EXCEPTION 'A table name is required to calculate tax history';
18122
 
  ELSEIF (pParentId IS NULL) THEN
18123
 
    RAISE EXCEPTION 'A parent ID is required to calculate tax history';
18124
 
  ELSEIF (pDate IS NULL) THEN
18125
 
    RAISE EXCEPTION 'A date is required to calculate tax history';
18126
 
  ELSEIF (pAmount IS NULL) THEN
18127
 
     RAISE EXCEPTION 'An amount is required to calculate tax history';
18128
 
  END IF;
18129
 
 
18130
 
  -- Build a query that deletes any previous tax history for this document record
18131
 
  _qry := 'DELETE FROM ' || pTableName || ' WHERE taxhist_parent_id = ' || pParentId || ' AND taxhist_taxtype_id <> getadjustmenttaxtypeid();';
18132
 
  EXECUTE _qry;
18133
 
 
18134
 
  -- Next, build and execute query that inserts new rows.
18135
 
  _qry := 'INSERT INTO ' || pTableName || ' (
18136
 
             taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis,
18137
 
             taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, 
18138
 
             taxhist_amount, taxhist_tax, taxhist_docdate)
18139
 
           SELECT ' || pParentId || ',';
18140
 
  IF (pTaxTypeId IS NULL) THEN
18141
 
    _qry := _qry || 'NULL';
18142
 
  ELSE
18143
 
    _qry := _qry || pTaxTypeId;
18144
 
  END If;
18145
 
  _qry := _qry || ', taxdetail_tax_id,' || pAmount || ', 
18146
 
             taxdetail_tax_basis_tax_id, taxdetail_taxclass_sequence, taxdetail_taxrate_percent,
18147
 
             taxdetail_taxrate_amount, taxdetail_tax, ''' || pDate || '''
18148
 
           FROM calculatetaxdetail(' || COALESCE(pTaxZoneId,-1) || ',' || COALESCE(pTaxTypeId,-1) ||',''' || pDate || ''',' || pCurrId || ',' || pAmount || ');';
18149
 
  EXECUTE _qry;
18150
 
 
18151
 
  RETURN true;
18152
 
END;
18153
 
$_$;
18154
 
 
18155
 
 
18156
 
ALTER FUNCTION public.calculatetaxhist(text, integer, integer, integer, date, integer, numeric) OWNER TO admin;
18157
 
 
18158
 
--
18159
 
--
18160
 
 
18161
 
CREATE FUNCTION calcvoucheramt(integer) RETURNS numeric
18162
 
    LANGUAGE plpgsql
18163
 
    AS $_$
18164
 
DECLARE
18165
 
  pVoucherid ALIAS FOR $1;
18166
 
  _amount NUMERIC := 0;
18167
 
 
18168
 
BEGIN
18169
 
 
18170
 
  SELECT SUM(COALESCE(vodist_amount, 0)) INTO _amount
18171
 
  FROM vodist
18172
 
  WHERE (vodist_vohead_id=pVoucherid);
18173
 
 
18174
 
  RETURN _amount;
18175
 
 
18176
 
END;
18177
 
$_$;
18178
 
 
18179
 
 
18180
 
ALTER FUNCTION public.calcvoucheramt(integer) OWNER TO admin;
18181
 
 
18182
 
--
18183
 
--
18184
 
 
18185
 
CREATE FUNCTION calcvoucherfreight(integer) RETURNS numeric
18186
 
    LANGUAGE plpgsql
18187
 
    AS $_$
18188
 
DECLARE
18189
 
  pVoucherid ALIAS FOR $1;
18190
 
  _amount NUMERIC := 0;
18191
 
 
18192
 
BEGIN
18193
 
 
18194
 
  SELECT SUM(COALESCE(voitem_freight, 0)) INTO _amount
18195
 
  FROM voitem
18196
 
  WHERE (voitem_vohead_id=pVoucherid);
18197
 
 
18198
 
  RETURN _amount;
18199
 
 
18200
 
END;
18201
 
$_$;
18202
 
 
18203
 
 
18204
 
ALTER FUNCTION public.calcvoucherfreight(integer) OWNER TO admin;
18205
 
 
18206
 
--
18207
 
--
18208
 
 
18209
 
CREATE FUNCTION calcvouchertax(integer) RETURNS numeric
18210
 
    LANGUAGE plpgsql
18211
 
    AS $_$
18212
 
DECLARE
18213
 
  pVoucherid ALIAS FOR $1;
18214
 
  _amount NUMERIC := 0;
18215
 
 
18216
 
BEGIN
18217
 
 
18218
 
  SELECT COALESCE(calculateTax(vohead_taxzone_id,
18219
 
                               vohead_taxtype_id,
18220
 
                               vohead_docdate,
18221
 
                               vohead_curr_id,
18222
 
                               calcVoucherAmt(vohead_id)), 0) INTO _amount
18223
 
  FROM vohead
18224
 
  WHERE (vohead_id=pVoucherid);
18225
 
 
18226
 
  RETURN _amount;
18227
 
 
18228
 
END;
18229
 
$_$;
18230
 
 
18231
 
 
18232
 
ALTER FUNCTION public.calcvouchertax(integer) OWNER TO admin;
18233
 
 
18234
 
--
18235
 
--
18236
 
 
18237
 
CREATE FUNCTION calcwooperstartstub(integer, integer) RETURNS date
18238
 
    LANGUAGE plpgsql
18239
 
    AS $_$
18240
 
DECLARE
18241
 
  pWoId         ALIAS FOR $1;
18242
 
  pBooitemSeqId ALIAS FOR $2;
18243
 
  _result       DATE;
18244
 
BEGIN
18245
 
 
18246
 
  IF ( SELECT ((metric_value='t') AND packageIsEnabled('xtmfg'))
18247
 
         FROM metric
18248
 
        WHERE(metric_name='Routings') ) THEN
18249
 
    RETURN xtmfg.calcWooperStart(pWoId, pBooitemSeqId);
18250
 
  END IF;
18251
 
  RETURN null;
18252
 
END;
18253
 
$_$;
18254
 
 
18255
 
 
18256
 
ALTER FUNCTION public.calcwooperstartstub(integer, integer) OWNER TO admin;
18257
 
 
18258
 
--
18259
 
--
18260
 
 
18261
 
CREATE FUNCTION cancelbillingselection(integer) RETURNS integer
18262
 
    LANGUAGE plpgsql
18263
 
    AS $_$
18264
 
DECLARE
18265
 
  pCobmiscid ALIAS FOR $1;
18266
 
 
18267
 
BEGIN
18268
 
 
18269
 
  IF ( ( SELECT cobmisc_posted
18270
 
         FROM cobmisc
18271
 
         WHERE (cobmisc_id=pCobmiscid) ) ) THEN
18272
 
    RETURN -1;
18273
 
  END IF;
18274
 
 
18275
 
  DELETE FROM cobill
18276
 
  WHERE (cobill_cobmisc_id=pCobmiscid); 
18277
 
 
18278
 
  DELETE FROM cobmisc
18279
 
  WHERE (cobmisc_id=pCobmiscid);
18280
 
 
18281
 
  RETURN 1;
18282
 
 
18283
 
END;
18284
 
$_$;
18285
 
 
18286
 
 
18287
 
ALTER FUNCTION public.cancelbillingselection(integer) OWNER TO admin;
18288
 
 
18289
 
--
18290
 
--
18291
 
 
18292
 
CREATE FUNCTION changeaccountingperioddates(integer, date, date) RETURNS integer
18293
 
    LANGUAGE plpgsql
18294
 
    AS $_$
18295
 
DECLARE
18296
 
  pPeriodid ALIAS FOR $1;
18297
 
  pStartDate ALIAS FOR $2;
18298
 
  pEndDate ALIAS FOR $3;
18299
 
  _check INTEGER;
18300
 
  _r RECORD;
18301
 
 
18302
 
BEGIN
18303
 
 
18304
 
  IF ( ( SELECT period_closed
18305
 
         FROM period
18306
 
         WHERE (period_id=pPeriodid) ) ) THEN
18307
 
    RETURN -1;
18308
 
  END IF;
18309
 
 
18310
 
  SELECT period_id INTO _check
18311
 
  FROM period
18312
 
  WHERE ( (pStartDate BETWEEN period_start AND period_end)
18313
 
    AND (period_id <> pPeriodid) )
18314
 
  LIMIT 1;
18315
 
  IF (FOUND) THEN
18316
 
    RETURN -2;
18317
 
  END IF;
18318
 
 
18319
 
  SELECT period_id INTO _check
18320
 
  FROM period
18321
 
  WHERE ( (pEndDate BETWEEN period_start AND period_end)
18322
 
    AND (period_id <> pPeriodid) )
18323
 
  LIMIT 1;
18324
 
  IF (FOUND) THEN
18325
 
    RETURN -3;
18326
 
  END IF;
18327
 
 
18328
 
  SELECT gltrans_id INTO _check
18329
 
  FROM gltrans, period
18330
 
  WHERE ( (gltrans_date BETWEEN period_start AND period_end)
18331
 
   AND (gltrans_posted)
18332
 
   AND (NOT (gltrans_date BETWEEN pStartDate AND pEndDate))
18333
 
   AND (period_id=pPeriodid) )
18334
 
  LIMIT 1;
18335
 
  IF (FOUND) THEN
18336
 
    RETURN -4;
18337
 
  END IF;
18338
 
 
18339
 
  UPDATE period
18340
 
  SET period_start=pStartDate, period_end=pEndDate
18341
 
  WHERE (period_id=pPeriodid);
18342
 
 
18343
 
  FOR _r IN SELECT DISTINCT gltrans_sequence
18344
 
            FROM gltrans
18345
 
            WHERE ( (NOT gltrans_posted)
18346
 
             AND (gltrans_date BETWEEN pStartDate AND pEndDate) ) LOOP
18347
 
    PERFORM postIntoTrialBalance(_r.gltrans_sequence);
18348
 
  END LOOP;
18349
 
 
18350
 
  RETURN 1;
18351
 
 
18352
 
END;
18353
 
$_$;
18354
 
 
18355
 
 
18356
 
ALTER FUNCTION public.changeaccountingperioddates(integer, date, date) OWNER TO admin;
18357
 
 
18358
 
--
18359
 
--
18360
 
 
18361
 
CREATE FUNCTION changeaccountingyearperioddates(integer, date, date) RETURNS integer
18362
 
    LANGUAGE plpgsql
18363
 
    AS $_$
18364
 
DECLARE
18365
 
  pPeriodid ALIAS FOR $1;
18366
 
  pStartDate ALIAS FOR $2;
18367
 
  pEndDate ALIAS FOR $3;
18368
 
  _check INTEGER;
18369
 
  _checkBool BOOLEAN;
18370
 
  _r RECORD;
18371
 
 
18372
 
BEGIN
18373
 
 
18374
 
  IF ( ( SELECT yearperiod_closed
18375
 
         FROM yearperiod
18376
 
         WHERE (yearperiod_id=pPeriodid) ) ) THEN
18377
 
    RETURN -1;
18378
 
  END IF;
18379
 
 
18380
 
  SELECT yearperiod_id INTO _check
18381
 
  FROM yearperiod
18382
 
  WHERE ( (pStartDate BETWEEN yearperiod_start AND yearperiod_end)
18383
 
    AND (yearperiod_id <> pPeriodid) )
18384
 
  LIMIT 1;
18385
 
  IF (FOUND) THEN
18386
 
    RETURN -2;
18387
 
  END IF;
18388
 
 
18389
 
  SELECT yearperiod_id INTO _check
18390
 
  FROM yearperiod
18391
 
  WHERE ( (pEndDate BETWEEN yearperiod_start AND yearperiod_end)
18392
 
    AND (yearperiod_id <> pPeriodid) )
18393
 
  LIMIT 1;
18394
 
  IF (FOUND) THEN
18395
 
    RETURN -3;
18396
 
  END IF;
18397
 
 
18398
 
  IF ( ( SELECT (count(period_id) > 0)
18399
 
         FROM period
18400
 
         WHERE ((period_yearperiod_id=pPeriodid)
18401
 
          AND (period_start < pStartDate OR period_end > pEndDate)) ) ) THEN
18402
 
    RETURN -4;
18403
 
  END IF;
18404
 
 
18405
 
  SELECT (pStartDate > pEndDate) INTO _checkBool;
18406
 
  IF (_checkBool) THEN
18407
 
    RETURN -5;
18408
 
  END IF;
18409
 
 
18410
 
 
18411
 
  UPDATE yearperiod
18412
 
  SET yearperiod_start=pStartDate, yearperiod_end=pEndDate
18413
 
  WHERE (yearperiod_id=pPeriodid);
18414
 
 
18415
 
  RETURN 1;
18416
 
 
18417
 
END;
18418
 
$_$;
18419
 
 
18420
 
 
18421
 
ALTER FUNCTION public.changeaccountingyearperioddates(integer, date, date) OWNER TO admin;
18422
 
 
18423
 
--
18424
 
--
18425
 
 
18426
 
CREATE FUNCTION changefkeypointers(text, text, integer, integer, text[], boolean) RETURNS integer
18427
 
    LANGUAGE plpgsql
18428
 
    AS $_$
18429
 
DECLARE
18430
 
  pSchema       ALIAS FOR $1;
18431
 
  pTable        ALIAS FOR $2;
18432
 
  pSourceId     ALIAS FOR $3;
18433
 
  pTargetId     ALIAS FOR $4;
18434
 
  pIgnore       ALIAS FOR $5;
18435
 
  _purge        BOOLEAN := COALESCE($6, FALSE);
18436
 
 
18437
 
  _counter      INTEGER := 0;
18438
 
  _count1       INTEGER := 0;
18439
 
  _fk           RECORD;
18440
 
  _pk           TEXT[];
18441
 
 
18442
 
BEGIN
18443
 
  -- for all foreign keys that point to pSchema.pTable
18444
 
  FOR _fk IN
18445
 
    EXECUTE 'SELECT fkeyns.nspname AS schemaname, fkeytab.relname AS tablename,
18446
 
                    conkey, attname, typname
18447
 
               FROM pg_constraint
18448
 
               JOIN pg_class     basetab ON (confrelid=basetab.oid)
18449
 
               JOIN pg_namespace basens  ON (basetab.relnamespace=basens.oid)
18450
 
               JOIN pg_class     fkeytab ON (conrelid=fkeytab.oid)
18451
 
               JOIN pg_namespace fkeyns  ON (fkeytab.relnamespace=fkeyns.oid)
18452
 
               JOIN pg_attribute         ON (attrelid=conrelid AND attnum=conkey[1])
18453
 
               JOIN pg_type              ON (atttypid=pg_type.oid)
18454
 
              WHERE basetab.relname = ' || quote_literal(pTable)  || '
18455
 
                AND basens.nspname  = ' || quote_literal(pSchema) || '
18456
 
                AND fkeytab.relname NOT IN (''' || ARRAY_TO_STRING(pIgnore, ''', ''') || ''')'
18457
 
  LOOP
18458
 
    IF (ARRAY_UPPER(_fk.conkey, 1) > 1) THEN
18459
 
      RAISE EXCEPTION 'Cannot change the foreign key in %.% that refers to %.% because the foreign key constraint has multiple columns. [xtuple: changefkeypointers, -1, %.%, %.%]',
18460
 
        _fk.schemaname, _fk.tablename, pSchema, pTable,
18461
 
        _fk.schemaname, _fk.tablename, pSchema, pTable;
18462
 
    END IF;
18463
 
    
18464
 
    -- optionally make a backup copy of the data
18465
 
    IF (NOT _purge) THEN
18466
 
      -- determine the primary key column of the fkey table
18467
 
      _pk := primaryKeyFields(_fk.schemaname, _fk.tablename);
18468
 
      IF (ARRAY_UPPER(_pk, 1) > 1) THEN
18469
 
        RAISE EXCEPTION 'Cannot change foreign key references in %.% because it has a composite primary key. Try setting the purge option. [xtuple: changefkeypointers, -4, %.%]',
18470
 
                        _fk.schemaname, _fk.tablename, _fk.schemaname, _fk.tablename;
18471
 
      END IF;
18472
 
 
18473
 
      -- make the backup copy
18474
 
      EXECUTE 'INSERT INTO mrgundo (
18475
 
                     mrgundo_schema,      mrgundo_table,
18476
 
                     mrgundo_pkey_col,    mrgundo_pkey_id,
18477
 
                     mrgundo_col,         mrgundo_value,      mrgundo_type,
18478
 
                     mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id
18479
 
             ) SELECT ' || quote_literal(_fk.schemaname) || ', '
18480
 
                        || quote_literal(_fk.tablename)  || ', '
18481
 
                        || quote_literal(_pk[1])         || ', ' 
18482
 
                        || _pk[1]                        || ', '
18483
 
                        || quote_literal(_fk.attname)    || ', ' 
18484
 
                        || _fk.attname                   || ', ' 
18485
 
                        || quote_literal(_fk.typname)    || ', '
18486
 
                        || quote_literal(pSchema)        || ', '
18487
 
                        || quote_literal(pTable)         || ', '
18488
 
                        || pTargetId                     || '
18489
 
                 FROM ' || _fk.schemaname || '.' || _fk.tablename ||
18490
 
              ' WHERE ('|| _fk.attname    || '=' || pSourceId || ');';
18491
 
    END IF;
18492
 
 
18493
 
    -- actually change the foreign keys to point to the desired base table record
18494
 
    EXECUTE 'UPDATE '  || _fk.schemaname || '.' || _fk.tablename ||
18495
 
              ' SET '  || _fk.attname    || '=' || pTargetId ||
18496
 
            ' WHERE (' || _fk.attname    || '=' || pSourceId || ');';
18497
 
 
18498
 
    GET DIAGNOSTICS _count1 = ROW_COUNT;
18499
 
    _counter := _counter + _count1;
18500
 
  END LOOP;
18501
 
 
18502
 
  RETURN _counter;
18503
 
END;
18504
 
$_$;
18505
 
 
18506
 
 
18507
 
ALTER FUNCTION public.changefkeypointers(text, text, integer, integer, text[], boolean) OWNER TO admin;
18508
 
 
18509
 
--
18510
 
--
18511
 
 
18512
 
COMMENT ON FUNCTION changefkeypointers(text, text, integer, integer, text[], boolean) IS 'Change the data in all tables with foreign key relationships so they point to the pSchema.pTable record with primary key pTargetId instead of the record with primary key pSourceId. Ignore any tables listed in pIgnore. If the final arg is TRUE, make a backup copy of the original data in the mrgundo table.';
18513
 
 
18514
 
 
18515
 
--
18516
 
--
18517
 
 
18518
 
CREATE FUNCTION changepoitemduedate(ppoitemid integer, pdate date) RETURNS integer
18519
 
    LANGUAGE plpgsql
18520
 
    AS $$
18521
 
BEGIN
18522
 
 
18523
 
  RETURN changePoitemDueDate(pPoitemid, pDate, false);
18524
 
 
18525
 
END;
18526
 
$$;
18527
 
 
18528
 
 
18529
 
ALTER FUNCTION public.changepoitemduedate(ppoitemid integer, pdate date) OWNER TO admin;
18530
 
 
18531
 
--
18532
 
--
18533
 
 
18534
 
CREATE FUNCTION changepoitemduedate(ppoitemid integer, pdate date, pbyso boolean) RETURNS integer
18535
 
    LANGUAGE plpgsql
18536
 
    AS $$
18537
 
BEGIN
18538
 
 
18539
 
  IF ( ( SELECT (poitem_status IN ('C'))
18540
 
         FROM poitem
18541
 
         WHERE (poitem_id=pPoitemid) ) ) THEN
18542
 
    RETURN -1;
18543
 
  END IF;
18544
 
 
18545
 
  UPDATE poitem
18546
 
  SET poitem_duedate=pDate
18547
 
  WHERE (poitem_id=pPoitemid);
18548
 
 
18549
 
  IF (pBySO) THEN
18550
 
    --Generate the PoItemUpdatedBySo event
18551
 
    PERFORM postEvent('PoItemUpdatedBySo', 'P', poitem_id,
18552
 
                      itemsite_warehous_id,
18553
 
                      (pohead_number || '-'|| poitem_linenumber || ': ' || item_number),
18554
 
                      NULL, NULL, NULL, NULL)
18555
 
    FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id)
18556
 
                JOIN itemsite ON (itemsite_id=poitem_itemsite_id)
18557
 
                JOIN item ON (item_id=itemsite_item_id)
18558
 
    WHERE (poitem_id=pPoitemid)
18559
 
      AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence));
18560
 
  END IF;
18561
 
 
18562
 
  RETURN pPoitemid;
18563
 
 
18564
 
END;
18565
 
$$;
18566
 
 
18567
 
 
18568
 
ALTER FUNCTION public.changepoitemduedate(ppoitemid integer, pdate date, pbyso boolean) OWNER TO admin;
18569
 
 
18570
 
--
18571
 
--
18572
 
 
18573
 
CREATE FUNCTION changepoitemqty(ppoitemid integer, pqty numeric) RETURNS integer
18574
 
    LANGUAGE plpgsql
18575
 
    AS $$
18576
 
BEGIN
18577
 
 
18578
 
  RETURN changePoitemQty(pPoitemid, pQty, false);
18579
 
 
18580
 
END;
18581
 
$$;
18582
 
 
18583
 
 
18584
 
ALTER FUNCTION public.changepoitemqty(ppoitemid integer, pqty numeric) OWNER TO admin;
18585
 
 
18586
 
--
18587
 
--
18588
 
 
18589
 
CREATE FUNCTION changepoitemqty(ppoitemid integer, pqty numeric, pbyso boolean) RETURNS integer
18590
 
    LANGUAGE plpgsql
18591
 
    AS $$
18592
 
DECLARE
18593
 
 
18594
 
BEGIN
18595
 
 
18596
 
  IF ( ( SELECT (poitem_status IN ('C'))
18597
 
         FROM poitem
18598
 
         WHERE (poitem_id=pPoitemid) ) ) THEN
18599
 
    RETURN -1;
18600
 
  END IF;
18601
 
 
18602
 
  UPDATE poitem
18603
 
  SET poitem_qty_ordered=pQty
18604
 
  WHERE (poitem_id=pPoitemid);
18605
 
 
18606
 
  IF (pBySO) THEN
18607
 
    --Generate the PoItemUpdatedBySo event
18608
 
    PERFORM postEvent('PoItemUpdatedBySo', 'P', poitem_id,
18609
 
                      itemsite_warehous_id,
18610
 
                      (pohead_number || '-'|| poitem_linenumber || ': ' || item_number),
18611
 
                      NULL, NULL, NULL, NULL)
18612
 
    FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id)
18613
 
                JOIN itemsite ON (itemsite_id=poitem_itemsite_id)
18614
 
                JOIN item ON (item_id=itemsite_item_id)
18615
 
    WHERE (poitem_id=pPoitemid)
18616
 
      AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence));
18617
 
  END IF;
18618
 
 
18619
 
  RETURN pPoitemid;
18620
 
 
18621
 
END;
18622
 
$$;
18623
 
 
18624
 
 
18625
 
ALTER FUNCTION public.changepoitemqty(ppoitemid integer, pqty numeric, pbyso boolean) OWNER TO admin;
18626
 
 
18627
 
--
18628
 
--
18629
 
 
18630
 
CREATE FUNCTION changeprdate(integer, date) RETURNS integer
18631
 
    LANGUAGE plpgsql
18632
 
    AS $_$
18633
 
DECLARE
18634
 
  pPrid ALIAS FOR $1;
18635
 
  pDueDate ALIAS FOR $2;
18636
 
 
18637
 
BEGIN
18638
 
 
18639
 
  UPDATE pr
18640
 
  SET pr_duedate=pDueDate
18641
 
  WHERE (pr_id=pPrid);
18642
 
 
18643
 
  RETURN 0;
18644
 
 
18645
 
END;
18646
 
$_$;
18647
 
 
18648
 
 
18649
 
ALTER FUNCTION public.changeprdate(integer, date) OWNER TO admin;
18650
 
 
18651
 
--
18652
 
--
18653
 
 
18654
 
CREATE FUNCTION changeprqty(integer, numeric) RETURNS boolean
18655
 
    LANGUAGE plpgsql
18656
 
    AS $_$
18657
 
DECLARE
18658
 
  pPrid ALIAS FOR $1;
18659
 
  pQty ALIAS FOR $2;
18660
 
 
18661
 
BEGIN
18662
 
 
18663
 
  UPDATE pr
18664
 
  SET pr_qtyreq=pQty
18665
 
  WHERE (pr_id=pPrid);
18666
 
 
18667
 
  RETURN TRUE;
18668
 
 
18669
 
END;
18670
 
$_$;
18671
 
 
18672
 
 
18673
 
ALTER FUNCTION public.changeprqty(integer, numeric) OWNER TO admin;
18674
 
 
18675
 
--
18676
 
--
18677
 
 
18678
 
CREATE FUNCTION changeprqty(integer, date) RETURNS integer
18679
 
    LANGUAGE plpgsql
18680
 
    AS $_$
18681
 
DECLARE
18682
 
  pPrid ALIAS FOR $1;
18683
 
  pDueDate ALIAS FOR $2;
18684
 
 
18685
 
BEGIN
18686
 
 
18687
 
  UPDATE pr
18688
 
  SET pr_duedate=pDueDate
18689
 
  WHERE (pr_id=pPrid);
18690
 
 
18691
 
  RETURN 0;
18692
 
 
18693
 
END;
18694
 
$_$;
18695
 
 
18696
 
 
18697
 
ALTER FUNCTION public.changeprqty(integer, date) OWNER TO admin;
18698
 
 
18699
 
--
18700
 
--
18701
 
 
18702
 
CREATE FUNCTION changepseudofkeypointers(text, text, text, integer, text, text, integer, text, text, boolean) RETURNS integer
18703
 
    LANGUAGE plpgsql
18704
 
    AS $_$
18705
 
DECLARE
18706
 
  pSchema       ALIAS FOR $1;
18707
 
  pTable        ALIAS FOR $2;
18708
 
  pFkeyCol      ALIAS FOR $3;
18709
 
  pSourceId     ALIAS FOR $4;
18710
 
  pBaseSchema   ALIAS FOR $5;
18711
 
  pBaseTable    ALIAS FOR $6;
18712
 
  pTargetId     ALIAS FOR $7;
18713
 
  pTypeCol      ALIAS FOR $8;
18714
 
  pType         ALIAS FOR $9;
18715
 
  _purge        BOOLEAN := COALESCE($10, FALSE);
18716
 
 
18717
 
  _counter      INTEGER := 0;
18718
 
  _coltype      TEXT;
18719
 
  _pk           TEXT[];
18720
 
 
18721
 
BEGIN
18722
 
  IF (NOT _purge) THEN
18723
 
    EXECUTE 'SELECT typname
18724
 
               FROM pg_type
18725
 
               JOIN pg_attribute ON (pg_type.oid=atttypid)
18726
 
               JOIN pg_class     ON (attrelid=pg_class.oid)
18727
 
               JOIN pg_namespace ON (relnamespace=pg_namespace.oid)
18728
 
              WHERE (relname=' || quote_literal(pTable)   || ')
18729
 
                AND (nspname=' || quote_literal(pSchema)  || ')
18730
 
                AND (attname=' || quote_literal(pFkeyCol) || ')' INTO _coltype;
18731
 
 
18732
 
    _pk := primaryKeyFields(pSchema, pTable);
18733
 
    IF (ARRAY_UPPER(_pk, 1) > 1) THEN
18734
 
       RAISE EXCEPTION 'Cannot change pseudo-foreign key references in %.% because it has a composite primary key. Try setting the purge option. [xtuple: changepseudofkeypointers, -1, %.%',
18735
 
                        pSchema, pTable, pSchema, pTable;
18736
 
    END IF;
18737
 
 
18738
 
    EXECUTE 'INSERT INTO mrgundo (
18739
 
                     mrgundo_schema,      mrgundo_table,
18740
 
                     mrgundo_pkey_col,    mrgundo_pkey_id,
18741
 
                     mrgundo_col,         mrgundo_value,      mrgundo_type,
18742
 
                     mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id
18743
 
           ) SELECT ' || quote_literal(pSchema)     || ', '
18744
 
                      || quote_literal(pTable)      || ', '
18745
 
                      || quote_literal(_pk[1])      || ', ' 
18746
 
                      || quote_ident(_pk[1])        || ', '
18747
 
                      || quote_literal(pFkeyCol)    || ', ' 
18748
 
                      || quote_ident(pFkeyCol)      || ', ' 
18749
 
                      || quote_literal(_coltype)    || ', '
18750
 
                      || quote_literal(pBaseSchema) || ', '
18751
 
                      || quote_literal(pBaseTable)  || ', '
18752
 
                      || pTargetId                  || '
18753
 
               FROM '  || quote_ident(pSchema)  || '.' || quote_ident(pTable) || '
18754
 
              WHERE (('|| quote_ident(pFkeyCol) || '=' || pSourceId || ')
18755
 
                 AND ('|| quote_ident(pTypeCol) || '=' || quote_literal(pType) || '));';
18756
 
  END IF;
18757
 
 
18758
 
  -- actually change the foreign keys to point to the desired base table record
18759
 
  EXECUTE 'UPDATE '  || quote_ident(pSchema)  || '.' || quote_ident(pTable) ||
18760
 
            ' SET '  || quote_ident(pFkeyCol) || '=' || pTargetId ||
18761
 
          ' WHERE ((' || quote_ident(pFkeyCol) || '=' || pSourceId || ')
18762
 
               AND (' || quote_ident(pTypeCol) || '=' || quote_literal(pType) || '));';
18763
 
 
18764
 
  GET DIAGNOSTICS _counter = ROW_COUNT;
18765
 
 
18766
 
  RETURN _counter;
18767
 
END;
18768
 
$_$;
18769
 
 
18770
 
 
18771
 
ALTER FUNCTION public.changepseudofkeypointers(text, text, text, integer, text, text, integer, text, text, boolean) OWNER TO admin;
18772
 
 
18773
 
--
18774
 
--
18775
 
 
18776
 
COMMENT ON FUNCTION changepseudofkeypointers(text, text, text, integer, text, text, integer, text, text, boolean) IS 'Change the data in pSchema.pTable with a pseudo-foreign key relationship to another (unnamed) table. Make pSchema.pTable point to the record with primary key pTargetId instead of the record with primary key pSourceId. pSchema.pTable cannot have a true foreign key relationship because it holds data that can point to any of several tables. The pType value in the pTypeCol column describes which table the data refer to (e.g. "T" may indicate that the current record refers to a "cntct"). If the final arg is TRUE, make a backup copy of the data in the mrgundo table.';
18777
 
 
18778
 
 
18779
 
--
18780
 
--
18781
 
 
18782
 
CREATE FUNCTION changepurchasedropship(pcoitemid integer, ppoitemid integer, pdropship boolean) RETURNS integer
18783
 
    LANGUAGE plpgsql
18784
 
    AS $$
18785
 
DECLARE
18786
 
  _s RECORD;
18787
 
  _w RECORD;
18788
 
  _p RECORD;
18789
 
  _result INTEGER;
18790
 
  _poitemid INTEGER;
18791
 
 
18792
 
BEGIN
18793
 
 
18794
 
  -- Check for existing poitem for this coitem
18795
 
  SELECT * INTO _p
18796
 
  FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id)
18797
 
  WHERE (poitem_id=pPoitemId)
18798
 
    AND (poitem_order_id=pCoitemId)
18799
 
    AND (poitem_order_type='S');
18800
 
  IF (NOT FOUND) THEN
18801
 
    RAISE EXCEPTION 'Change Purchase Drop Ship PO not found';
18802
 
  END IF;
18803
 
 
18804
 
  SELECT * INTO _s
18805
 
  FROM coitem JOIN cohead ON (cohead_id = coitem_cohead_id)
18806
 
    LEFT OUTER JOIN shiptoinfo ON (cohead_shipto_id = shipto_id)
18807
 
    LEFT OUTER JOIN cntct ON (shipto_cntct_id = cntct_id)
18808
 
    LEFT OUTER JOIN addr ON (shipto_addr_id = addr_id)
18809
 
  WHERE (coitem_id = pCoitemId);
18810
 
  IF (NOT FOUND) THEN
18811
 
    RETURN -1;
18812
 
  END IF;
18813
 
 
18814
 
  IF (_p.pohead_status != 'U') THEN
18815
 
    RETURN -3;
18816
 
  END IF;
18817
 
 
18818
 
  SELECT deletePoitem(_p.poitem_id) INTO _result;
18819
 
  IF (_result < 0) THEN
18820
 
    RETURN _result;
18821
 
  END IF;
18822
 
 
18823
 
  SELECT createPurchaseToSale(_s.coitem_id, _p.poitem_itemsrc_id,
18824
 
                              pDropShip, _s.coitem_qtyord,
18825
 
                              _s.coitem_scheddate, NULL)
18826
 
     INTO _poitemid;
18827
 
  
18828
 
  RETURN _poitemid;
18829
 
 
18830
 
END;
18831
 
$$;
18832
 
 
18833
 
 
18834
 
ALTER FUNCTION public.changepurchasedropship(pcoitemid integer, ppoitemid integer, pdropship boolean) OWNER TO admin;
18835
 
 
18836
 
--
18837
 
--
18838
 
 
18839
 
CREATE FUNCTION changewodates(integer, date, date, boolean) RETURNS integer
18840
 
    LANGUAGE plpgsql
18841
 
    AS $_$
18842
 
DECLARE 
18843
 
  pWoid ALIAS FOR $1;
18844
 
  pStartDate ALIAS FOR $2;
18845
 
  pDueDate ALIAS FOR $3;
18846
 
  changeChildren ALIAS FOR $4;
18847
 
  _p RECORD;
18848
 
  returnCode INTEGER;
18849
 
  _vtemp NUMERIC;
18850
 
 
18851
 
BEGIN
18852
 
 
18853
 
  SELECT wo_status, wo_startdate, itemsite_warehous_id INTO _p
18854
 
  FROM wo
18855
 
  Inner Join itemsite on
18856
 
      wo_itemsite_id=itemsite_id
18857
 
  WHERE (wo_id=pWoid);
18858
 
 
18859
 
  IF (_p.wo_status = 'C') THEN 
18860
 
    returnCode := 0;
18861
 
 
18862
 
  ELSIF (_p.wo_status IN ('R','I')) THEN
18863
 
    PERFORM postEvent('RWoDueDateRequestChange', 'W', wo_id,
18864
 
                      itemsite_warehous_id, formatWoNumber(wo_id),
18865
 
                      NULL, NULL, pDueDate, wo_duedate)
18866
 
    FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)
18867
 
            JOIN item ON (item_id=itemsite_item_id)
18868
 
    WHERE (wo_id=pWoid);
18869
 
 
18870
 
     returnCode := 0;
18871
 
 
18872
 
  END IF;
18873
 
  
18874
 
  IF (fetchMetricBool('Routings')) THEN
18875
 
 
18876
 
    IF (fetchMetricBool('UseSiteCalendar')) THEN
18877
 
      UPDATE xtmfg.wooper
18878
 
      SET wooper_scheduled = calculatenextworkingdate(itemsite_warehous_id,DATE(pStartDate),
18879
 
                             CAST(calculateworkdays(itemsite_warehous_id, DATE(wo_startdate), DATE(wooper_scheduled)) as INTEGER))
18880
 
      FROM wo JOIN itemsite ON (wo_itemsite_id=itemsite_id)
18881
 
      WHERE ( (wooper_wo_id=wo_id)
18882
 
        AND   (wo_id=pWoid) );
18883
 
    ELSE
18884
 
      UPDATE xtmfg.wooper
18885
 
      SET wooper_scheduled = (wooper_scheduled::DATE + (pStartDate - wo_startdate))
18886
 
      FROM wo
18887
 
      WHERE ( (wooper_wo_id=wo_id)
18888
 
        AND   (wo_id=pWoid) );
18889
 
    END IF;
18890
 
 
18891
 
    UPDATE womatl
18892
 
    SET womatl_duedate=wooper_scheduled
18893
 
    FROM xtmfg.wooper
18894
 
    WHERE ( (womatl_schedatwooper)
18895
 
     AND (womatl_wooper_id=wooper_id)
18896
 
     AND (womatl_wo_id=pWoid) );
18897
 
 
18898
 
  END IF;
18899
 
 
18900
 
  UPDATE womatl
18901
 
  SET womatl_duedate=pStartDate
18902
 
  WHERE ( (NOT womatl_schedatwooper)
18903
 
   AND (womatl_wo_id=pWoid) );
18904
 
 
18905
 
  UPDATE wo
18906
 
  SET wo_startdate=pStartDate,
18907
 
      wo_duedate=pDueDate
18908
 
  WHERE (wo_id=pWoid);
18909
 
 
18910
 
  IF (changeChildren) THEN
18911
 
    SELECT MAX(changeWoDates(wo_id, (pStartDate - itemsite_leadtime), pStartDate, TRUE)) INTO returnCode
18912
 
    FROM wo, itemsite
18913
 
    WHERE ( (wo_itemsite_id=itemsite_id)
18914
 
     AND (wo_ordtype='W')
18915
 
     AND (wo_ordid=pWoid) );
18916
 
  END IF;
18917
 
 
18918
 
  IF (returnCode IS NULL) THEN
18919
 
    returnCode := 0;
18920
 
  END IF;
18921
 
 
18922
 
  RETURN returnCode;
18923
 
 
18924
 
END;
18925
 
$_$;
18926
 
 
18927
 
 
18928
 
ALTER FUNCTION public.changewodates(integer, date, date, boolean) OWNER TO admin;
18929
 
 
18930
 
--
18931
 
--
18932
 
 
18933
 
CREATE FUNCTION changewoproject(integer, integer, boolean) RETURNS integer
18934
 
    LANGUAGE plpgsql
18935
 
    AS $_$
18936
 
DECLARE
18937
 
  pWoid ALIAS FOR $1;
18938
 
  pPrjid ALIAS FOR $2;
18939
 
  changeChildren ALIAS FOR $3;
18940
 
  woStatus CHAR(1);
18941
 
  _result INTEGER;
18942
 
 
18943
 
BEGIN
18944
 
 
18945
 
  SELECT wo_status INTO woStatus
18946
 
  FROM wo
18947
 
  WHERE (wo_id=pWoid);
18948
 
 
18949
 
  UPDATE wo
18950
 
  SET wo_prj_id=pPrjid
18951
 
  WHERE (wo_id=pWoid);
18952
 
 
18953
 
  IF (woStatus = 'E' AND changeChildren) THEN
18954
 
    _result := ( SELECT MIN(changeWoProject(wo_id, pPrjid, TRUE))
18955
 
                   FROM womatl, wo
18956
 
                  WHERE ((womatl_itemsite_id=wo_itemsite_id)
18957
 
                    AND (wo_ordtype='W')
18958
 
                    AND (womatl_wo_id=pWoid)
18959
 
                    AND (wo_ordid=pWoid)) );
18960
 
 
18961
 
    UPDATE pr SET pr_prj_id=pPrjid
18962
 
      FROM womatl
18963
 
     WHERE ((womatl_wo_id=pWoid)
18964
 
       AND  (pr_order_type='W')
18965
 
       AND  (pr_order_id=womatl_id));
18966
 
  ELSE
18967
 
    _result = 1;
18968
 
  END IF;
18969
 
 
18970
 
  RETURN _result;
18971
 
END;
18972
 
$_$;
18973
 
 
18974
 
 
18975
 
ALTER FUNCTION public.changewoproject(integer, integer, boolean) OWNER TO admin;
18976
 
 
18977
 
--
18978
 
--
18979
 
 
18980
 
CREATE FUNCTION changewoqty(integer, numeric, boolean) RETURNS integer
18981
 
    LANGUAGE plpgsql
18982
 
    AS $_$
18983
 
DECLARE
18984
 
  pWoid ALIAS FOR $1;
18985
 
  pQty ALIAS FOR $2;
18986
 
  changeChildren ALIAS FOR $3;
18987
 
  _r RECORD;
18988
 
  _result INTEGER := 1;
18989
 
 
18990
 
BEGIN
18991
 
 
18992
 
  SELECT wo_qtyord, wo_status, item_fractional INTO _r
18993
 
  FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)
18994
 
          JOIN item ON (item_id=itemsite_item_id)
18995
 
  WHERE (wo_id=pWoid);
18996
 
 
18997
 
  IF (_r.wo_qtyord = pQty) THEN
18998
 
    RETURN 0;
18999
 
  END IF;
19000
 
 
19001
 
  IF (NOT _r.wo_status IN ('O','E','R','I')) THEN
19002
 
    RETURN 1;
19003
 
  END IF;
19004
 
 
19005
 
  IF (_r.wo_status IN ('R','I')) THEN
19006
 
    PERFORM postEvent('RWoQtyRequestChange', 'W', wo_id,
19007
 
                      itemsite_warehous_id, formatWoNumber(wo_id),
19008
 
                      pQty, wo_qtyord, NULL, NULL)
19009
 
    FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)
19010
 
            JOIN item ON (item_id=itemsite_item_id)
19011
 
    WHERE (wo_id=pWoid);
19012
 
 
19013
 
     _result = 0;
19014
 
  END IF;
19015
 
 
19016
 
  UPDATE wo
19017
 
  SET wo_qtyord=roundQty(_r.item_fractional, pQty)
19018
 
  WHERE (wo_id=pWoid);
19019
 
 
19020
 
  UPDATE womatl
19021
 
  SET womatl_qtyreq=(womatl_qtyfxd + wo_qtyord * womatl_qtyper) * (1 + womatl_scrap)
19022
 
  FROM wo, itemsite
19023
 
  WHERE ((womatl_wo_id=wo_id)
19024
 
    AND  (womatl_itemsite_id=itemsite_id)
19025
 
    AND  (wo_id=pWoid));
19026
 
 
19027
 
  IF (fetchMetricBool('Routings')) THEN
19028
 
 
19029
 
      UPDATE xtmfg.wooper
19030
 
         SET wooper_rntime = CASE WHEN ((booitem_rnqtyper = 0) OR (booitem_invproduomratio = 0)) THEN 0
19031
 
                                  WHEN (NOT booitem_rnrpt) THEN 0
19032
 
                                  ELSE ( ( booitem_rntime /
19033
 
                                           booitem_rnqtyper /
19034
 
                                           booitem_invproduomratio ) * wo_qtyord )
19035
 
                             END
19036
 
        FROM xtmfg.booitem, wo
19037
 
       WHERE ((wooper_wo_id=wo_id)
19038
 
         AND  (wooper_booitem_id=booitem_id)
19039
 
         AND  (wo_id=pWoid));
19040
 
  END IF;
19041
 
 
19042
 
  IF (changeChildren) THEN
19043
 
    _result := ( SELECT MIN(changeWoQty(wo_id, womatl_qtyreq, TRUE))
19044
 
                 FROM womatl, wo
19045
 
                 WHERE ((womatl_itemsite_id=wo_itemsite_id)
19046
 
                  AND (wo_ordtype='W')
19047
 
                  AND (womatl_wo_id=pWoid)
19048
 
                  AND (wo_ordid=pWoid)) );
19049
 
  END IF;
19050
 
 
19051
 
  RETURN _result;
19052
 
END;
19053
 
$_$;
19054
 
 
19055
 
 
19056
 
ALTER FUNCTION public.changewoqty(integer, numeric, boolean) OWNER TO admin;
19057
 
 
19058
 
--
19059
 
--
19060
 
 
19061
 
CREATE FUNCTION characteristicstostring(text, integer, text, text) RETURNS text
19062
 
    LANGUAGE plpgsql
19063
 
    AS $_$
19064
 
DECLARE
19065
 
  pTargetType ALIAS FOR $1;
19066
 
  pTargetId ALIAS FOR $2;
19067
 
  pValKeySep ALIAS FOR $3;
19068
 
  pPairSep ALIAS FOR $4;
19069
 
  _string TEXT := '';
19070
 
  _extra BOOLEAN := false;
19071
 
  _r RECORD;
19072
 
BEGIN
19073
 
  FOR _r IN SELECT char_name, charass_value
19074
 
              FROM charass, char
19075
 
             WHERE ((charass_char_id=char_id)
19076
 
               AND  (charass_target_type=pTargetType)
19077
 
               AND  (charass_target_id=pTargetId)) LOOP
19078
 
    IF(_extra) THEN
19079
 
      _string := _string || pPairSep;
19080
 
    END IF;
19081
 
    _extra := true;
19082
 
 
19083
 
    _string := _string || _r.char_name || pValKeySep || _r.charass_value;
19084
 
  END LOOP;
19085
 
 
19086
 
  RETURN _string;
19087
 
END;
19088
 
$_$;
19089
 
 
19090
 
 
19091
 
ALTER FUNCTION public.characteristicstostring(text, integer, text, text) OWNER TO admin;
19092
 
 
19093
 
--
19094
 
--
19095
 
 
19096
 
CREATE FUNCTION checkcreditmemositeprivs(integer) RETURNS boolean
19097
 
    LANGUAGE plpgsql
19098
 
    AS $_$
19099
 
DECLARE
19100
 
  pCmheadid ALIAS FOR $1;
19101
 
  _check    BOOLEAN;
19102
 
  _result   INTEGER;
19103
 
 
19104
 
BEGIN
19105
 
 
19106
 
  IF (NOT fetchMetricBool('MultiWhs')) THEN
19107
 
    RETURN true;
19108
 
  END IF;
19109
 
 
19110
 
  IF (NOT fetchUsrPrefBool('selectedSites')) THEN
19111
 
    RETURN true;
19112
 
  END IF;
19113
 
 
19114
 
  SELECT COALESCE(COUNT(*), 0) INTO _result
19115
 
    FROM ( SELECT cmitem_id
19116
 
             FROM cmitem JOIN itemsite ON (itemsite_id=cmitem_itemsite_id)
19117
 
            WHERE ( (cmitem_cmhead_id=pCmheadid)
19118
 
              AND   (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id
19119
 
                                                    FROM usrsite
19120
 
                                                   WHERE (usrsite_username=getEffectiveXtUser()))) )
19121
 
         ) AS data;
19122
 
  IF (_result > 0) THEN
19123
 
    RETURN false;
19124
 
  END IF;
19125
 
 
19126
 
  RETURN true;
19127
 
END;
19128
 
$_$;
19129
 
 
19130
 
 
19131
 
ALTER FUNCTION public.checkcreditmemositeprivs(integer) OWNER TO admin;
19132
 
 
19133
 
--
19134
 
--
19135
 
 
19136
 
CREATE FUNCTION checkdetailformatted(integer, integer) RETURNS SETOF checkdata
19137
 
    LANGUAGE plpgsql
19138
 
    AS $_$
19139
 
DECLARE
19140
 
  pCheckheadid ALIAS FOR $1;
19141
 
  pMaxLines ALIAS FOR $2;
19142
 
  _row checkdata%ROWTYPE;
19143
 
  _checkhead RECORD;
19144
 
  _checkdetail RECORD;
19145
 
  _rowcount INTEGER := 0;
19146
 
  _page INTEGER := 1;
19147
 
  _docnumber TEXT := '';
19148
 
  _docreference TEXT := '';
19149
 
  _docdate TEXT := '';
19150
 
  _docamount TEXT := '';
19151
 
  _docdiscount TEXT := '';
19152
 
  _docnetamount TEXT := '';
19153
 
BEGIN
19154
 
 
19155
 
  SELECT checkhead_number AS checknumber,
19156
 
         INITCAP(spellAmount(checkhead_amount, curr_id)) AS checkwords,
19157
 
         formatDate(checkhead_checkdate) AS checkdate,
19158
 
         formatMoney(checkhead_amount) AS checkamount,
19159
 
         curr_symbol AS checkcurrsymbol,
19160
 
         curr_abbr AS checkcurrabbr,
19161
 
         curr_name AS checkcurrname,
19162
 
         CASE WHEN checkhead_recip_type = 'C' THEN (SELECT cust_name
19163
 
                                                      FROM custinfo
19164
 
                                                     WHERE cust_id=checkhead_recip_id)
19165
 
              WHEN checkhead_recip_type = 'T' THEN (SELECT taxauth_name
19166
 
                                                      FROM taxauth
19167
 
                                                     WHERE taxauth_id=checkhead_recip_id)
19168
 
              WHEN checkhead_recip_type = 'V' THEN
19169
 
                                  COALESCE((SELECT vendaddr_name
19170
 
                                              FROM vendaddrinfo
19171
 
                                             WHERE((UPPER(vendaddr_code)='REMIT')
19172
 
                                               AND (vendaddr_vend_id=checkhead_recip_id))),
19173
 
                                           (SELECT vend_name
19174
 
                                              FROM vendinfo
19175
 
                                             WHERE(vend_id=checkhead_recip_id)))
19176
 
         END AS checkpayto,
19177
 
         formatAddr(CASE WHEN checkhead_recip_type = 'C' THEN
19178
 
                                                  (SELECT cntct_addr_id
19179
 
                                                   FROM cntct, custinfo
19180
 
                                                    WHERE((cust_cntct_id=cntct_id)
19181
 
                                                      AND (cust_id=checkhead_recip_id)))
19182
 
                         WHEN checkhead_recip_type = 'T' THEN 
19183
 
                                                  (SELECT taxauth_addr_id
19184
 
                                                     FROM taxauth
19185
 
                                                    WHERE(taxauth_id=checkhead_recip_id))
19186
 
                         WHEN checkhead_recip_type = 'V' THEN
19187
 
                                 COALESCE((SELECT vendaddr_addr_id
19188
 
                                             FROM vendaddrinfo
19189
 
                                            WHERE((UPPER(vendaddr_code)='REMIT')
19190
 
                                              AND (vendaddr_vend_id=checkhead_recip_id))),
19191
 
                                          (SELECT vend_addr_id
19192
 
                                             FROM vendinfo
19193
 
                                            WHERE(vend_id=checkhead_recip_id)))
19194
 
                    END) AS checkaddress,
19195
 
         checkhead_for AS checkmemo
19196
 
    INTO _checkhead
19197
 
    FROM checkhead, curr_symbol
19198
 
   WHERE((checkhead_curr_id = curr_id)
19199
 
     AND (checkhead_id=pCheckheadid) );
19200
 
  IF (NOT FOUND) THEN
19201
 
    RETURN;
19202
 
  END IF;
19203
 
 
19204
 
  _row.checkdata_page := _page;
19205
 
  _row.checkdata_checknumber := _checkhead.checknumber;
19206
 
  _row.checkdata_checkwords := _checkhead.checkwords;
19207
 
  _row.checkdata_checkdate := _checkhead.checkdate;
19208
 
  _row.checkdata_checkamount := _checkhead.checkamount;
19209
 
  _row.checkdata_checkcurrsymbol := _checkhead.checkcurrsymbol;
19210
 
  _row.checkdata_checkcurrabbr := _checkhead.checkcurrabbr;
19211
 
  _row.checkdata_checkcurrname := _checkhead.checkcurrname;
19212
 
  _row.checkdata_checkpayto := _checkhead.checkpayto;
19213
 
  _row.checkdata_checkaddress := _checkhead.checkaddress;
19214
 
  _row.checkdata_checkmemo := _checkhead.checkmemo;
19215
 
 
19216
 
  FOR _checkdetail IN 
19217
 
  SELECT  --VOUCHER-------------
19218
 
    1 AS ord,
19219
 
    1 AS sequence_value,
19220
 
    checkitem_invcnumber,
19221
 
    checkitem_ponumber,
19222
 
    formatMoney(checkitem_amount) AS docnetamount,
19223
 
    'Invoice#: ' || vohead_invcnumber AS docnumber,
19224
 
    formatDate(vohead_docdate) AS docdate,
19225
 
    vohead_reference AS docreference,
19226
 
    'Voucher: ' || checkitem_vouchernumber AS vouchernumber,
19227
 
    formatMoney(apopen_amount) AS docamount,
19228
 
    formatMoney(checkitem_discount) AS docdiscount
19229
 
  FROM checkitem, vohead, apopen
19230
 
  WHERE ((checkitem_checkhead_id=pCheckheadid)
19231
 
    AND  (checkitem_vouchernumber = vohead_number)
19232
 
    AND  (apopen_docnumber = checkitem_vouchernumber)
19233
 
    AND  (apopen_doctype = 'V'))
19234
 
  
19235
 
  UNION
19236
 
  
19237
 
  SELECT --DEBIT MEMO -------------------------
19238
 
    2 AS ord,
19239
 
    1 AS sequence_value,
19240
 
    checkitem_invcnumber,
19241
 
    checkitem_ponumber,
19242
 
    formatMoney(checkitem_amount) AS f_amount,
19243
 
    'Debit Memo PO#: ' || checkitem_ponumber AS doc_number,
19244
 
    ''  AS f_docdate,
19245
 
    'Debit Memo: ' || checkitem_vouchernumber AS doc_reference,
19246
 
    checkitem_vouchernumber AS vouchernumber,
19247
 
    formatMoney(apopen_amount) AS amount,
19248
 
    formatMoney(checkitem_discount) AS disc_cred
19249
 
  FROM checkitem, apopen
19250
 
  WHERE ((checkitem_checkhead_id=pCheckheadid)
19251
 
    AND  (checkitem_apopen_id = apopen_id)
19252
 
    AND  (apopen_doctype = 'D'))
19253
 
  
19254
 
  UNION
19255
 
  
19256
 
  SELECT --CREDIT MEMO -------------------------
19257
 
    2 AS ord,
19258
 
    1 AS sequence_value,
19259
 
    checkitem_invcnumber,
19260
 
    checkitem_ponumber,
19261
 
    formatMoney(checkitem_amount * -1.0) AS f_amount,
19262
 
    'Credit Memo PO#: ' || checkitem_ponumber AS doc_number,
19263
 
    ''  AS f_docdate,
19264
 
    'Credit Memo: ' || checkitem_vouchernumber AS doc_reference,
19265
 
    checkitem_vouchernumber AS vouchernumber,
19266
 
    '' AS amount,
19267
 
    formatMoney(checkitem_amount) AS disc_cred
19268
 
  FROM checkitem, apopen
19269
 
  WHERE ((checkitem_checkhead_id=pCheckheadid)
19270
 
    AND  (checkitem_apopen_id = apopen_id)
19271
 
    AND  (apopen_doctype = 'C'))
19272
 
  
19273
 
  UNION
19274
 
  
19275
 
  SELECT --CREDITs FOR VOUCHERS-----------------
19276
 
    3 AS ord,
19277
 
    1 AS sequence_value,
19278
 
    checkitem_invcnumber,
19279
 
    checkitem_ponumber,
19280
 
    formatMoney(checkitem_amount) AS f_amount,
19281
 
    'Invoice#: ' || vohead_invcnumber AS doc_number,
19282
 
    formatDate(vohead_docdate) AS f_docdate,
19283
 
    'Credit Applied: ' || apapply_source_doctype || ' ' ||
19284
 
                          apapply_source_docnumber AS doc_reference,
19285
 
    'Voucher: ' || checkitem_vouchernumber AS vouchernumber,
19286
 
    '' AS amount,
19287
 
    formatMoney((apapply_amount)) AS disc_cred
19288
 
  FROM checkitem, vohead, apapply
19289
 
  WHERE ((checkitem_checkhead_id=pCheckheadid)
19290
 
    AND  (checkitem_vouchernumber = vohead_number)
19291
 
    AND  (apapply_target_docnumber = checkitem_vouchernumber)
19292
 
    AND  (apapply_target_doctype = 'V')
19293
 
    AND  (apapply_source_doctype = 'C'))
19294
 
  
19295
 
  UNION 
19296
 
  
19297
 
  SELECT --CREDITs FOR DEBIT MEMOS-----------
19298
 
    3 AS ord,
19299
 
    1 AS sequence_value,
19300
 
    checkitem_invcnumber,
19301
 
    checkitem_ponumber,
19302
 
    formatMoney(checkitem_amount) AS f_amount,
19303
 
    'Debit Memo PO#: ' || checkitem_ponumber AS doc_number,
19304
 
    '' AS f_docdate,
19305
 
    'Credit Applied: ' || apapply_source_doctype || ' ' ||
19306
 
                          apapply_source_docnumber AS doc_reference,
19307
 
    'Debit Memo: ' || checkitem_vouchernumber AS vouchernumber,
19308
 
    '' AS amount,
19309
 
    formatMoney((apapply_amount)) AS disc_cred
19310
 
  FROM checkitem, apopen, apapply
19311
 
  WHERE ((checkitem_checkhead_id=pCheckheadid)
19312
 
    AND  (checkitem_vouchernumber = apopen_docnumber)
19313
 
    AND  (apopen_doctype = 'D')
19314
 
    AND  (apapply_target_docnumber = checkitem_vouchernumber)
19315
 
    AND  (apapply_target_doctype = 'D')
19316
 
    AND  (apapply_source_doctype = 'C'))
19317
 
  
19318
 
  UNION 
19319
 
  
19320
 
  SELECT --NON-VENDOR-----------------------
19321
 
    4 AS ord,
19322
 
    1 AS sequence_value,
19323
 
    checkitem_invcnumber,
19324
 
    checkitem_ponumber,
19325
 
    formatMoney(checkitem_amount) AS f_amount,
19326
 
    checkitem_invcnumber AS doc_number,
19327
 
    formatDate(checkitem_docdate) AS f_docdate,
19328
 
    '' AS doc_reference,
19329
 
    '' AS vouchernumber,
19330
 
    '' AS amount,
19331
 
    '' AS disc_cred
19332
 
  FROM checkhead LEFT OUTER JOIN
19333
 
       checkitem ON (checkitem_checkhead_id=checkhead_id)
19334
 
  WHERE ((checkhead_id=pCheckheadid) 
19335
 
    AND  (checkhead_recip_type != 'V')) LOOP
19336
 
    IF (_rowcount = pMaxLines) THEN
19337
 
      _row.checkdata_docnumber := _docnumber;
19338
 
      _row.checkdata_docreference := _docreference;
19339
 
      _row.checkdata_docdate := _docdate;
19340
 
      _row.checkdata_docamount := _docamount;
19341
 
      _row.checkdata_docdiscount := _docdiscount;
19342
 
      _row.checkdata_docnetamount := _docnetamount;
19343
 
      RETURN NEXT _row;
19344
 
 
19345
 
      _rowcount = 0;
19346
 
      _page := _page + 1;
19347
 
      _docnumber := '';
19348
 
      _docreference := '';
19349
 
      _docdate := '';
19350
 
      _docamount := '';
19351
 
      _docdiscount := '';
19352
 
      _docnetamount := '';
19353
 
 
19354
 
      _row.checkdata_page := _page;
19355
 
      _row.checkdata_checknumber := _checkhead.checknumber;
19356
 
      _row.checkdata_checkwords := 'VOID VOID PAGE '||_page||' OF CHECK #'||_checkhead.checknumber||' VOID VOID';
19357
 
      _row.checkdata_checkdate := 'VOID VOID VOID';
19358
 
      _row.checkdata_checkamount := 'VOID VOID VOID';
19359
 
      --_row.checkdata_checkcurrsymbol := _checkhead.checkcurrsymbol;
19360
 
      --_row.checkdata_checkcurrabbr := _checkhead.checkcurrabbr;
19361
 
      --_row.checkdata_checkcurrname := _checkhead.checkcurrname;
19362
 
      _row.checkdata_checkpayto := 'VOID VOID VOID';
19363
 
      --_row.checkdata_checkaddress := _checkhead.checkaddress;
19364
 
      _row.checkdata_checkmemo := 'VOID VOID PAGE '||_page||' OF CHECK #'||_checkhead.checknumber||' VOID VOID';
19365
 
    END IF;
19366
 
 
19367
 
    _rowcount := _rowcount + 1;
19368
 
    _docnumber := _docnumber || _checkdetail.docnumber || E'\n';
19369
 
    _docreference := _docreference || _checkdetail.docreference || E'\n';
19370
 
    _docdate := _docdate || _checkdetail.docdate || E'\n';
19371
 
    _docamount := _docamount || _checkdetail.docamount || E'\n';
19372
 
    _docdiscount := _docdiscount || _checkdetail.docdiscount || E'\n';
19373
 
    _docnetamount := _docnetamount || _checkdetail.docnetamount || E'\n';
19374
 
  END LOOP;
19375
 
 
19376
 
  _row.checkdata_docnumber := _docnumber;
19377
 
  _row.checkdata_docreference := _docreference;
19378
 
  _row.checkdata_docdate := _docdate;
19379
 
  _row.checkdata_docamount := _docamount;
19380
 
  _row.checkdata_docdiscount := _docdiscount;
19381
 
  _row.checkdata_docnetamount := _docnetamount;
19382
 
 
19383
 
  RETURN NEXT _row;
19384
 
  RETURN;
19385
 
END;
19386
 
$_$;
19387
 
 
19388
 
 
19389
 
ALTER FUNCTION public.checkdetailformatted(integer, integer) OWNER TO admin;
19390
 
 
19391
 
--
19392
 
--
19393
 
 
19394
 
CREATE FUNCTION checkinvoicesiteprivs(integer) RETURNS boolean
19395
 
    LANGUAGE plpgsql STABLE
19396
 
    AS $_$
19397
 
DECLARE
19398
 
  pInvcheadid ALIAS FOR $1;
19399
 
  _check    BOOLEAN;
19400
 
  _result   INTEGER;
19401
 
 
19402
 
BEGIN
19403
 
 
19404
 
  IF (NOT fetchMetricBool('MultiWhs')) THEN
19405
 
    RETURN true;
19406
 
  END IF;
19407
 
 
19408
 
  IF (NOT fetchUsrPrefBool('selectedSites')) THEN
19409
 
    RETURN true;
19410
 
  END IF;
19411
 
 
19412
 
  SELECT COALESCE(COUNT(*), 0) INTO _result
19413
 
    FROM ( SELECT invcitem_id
19414
 
             FROM invcitem
19415
 
            WHERE ( (invcitem_invchead_id=pInvcheadid)
19416
 
              AND   (invcitem_warehous_id <> -1)
19417
 
              AND   (invcitem_warehous_id NOT IN (SELECT usrsite_warehous_id
19418
 
                                                    FROM usrsite
19419
 
                                                   WHERE (usrsite_username=getEffectiveXtUser()))) )
19420
 
         ) AS data;
19421
 
  IF (_result > 0) THEN
19422
 
    RETURN false;
19423
 
  END IF;
19424
 
 
19425
 
  RETURN true;
19426
 
END;
19427
 
$_$;
19428
 
 
19429
 
 
19430
 
ALTER FUNCTION public.checkinvoicesiteprivs(integer) OWNER TO admin;
19431
 
 
19432
 
--
19433
 
--
19434
 
 
19435
 
CREATE FUNCTION checkpositeprivs(integer) RETURNS boolean
19436
 
    LANGUAGE plpgsql STABLE
19437
 
    AS $_$
19438
 
DECLARE
19439
 
  pPoheadid ALIAS FOR $1;
19440
 
  _check    BOOLEAN;
19441
 
  _result   INTEGER;
19442
 
 
19443
 
BEGIN
19444
 
 
19445
 
  IF (NOT fetchMetricBool('MultiWhs')) THEN
19446
 
    RETURN true;
19447
 
  END IF;
19448
 
 
19449
 
  IF (NOT fetchUsrPrefBool('selectedSites')) THEN
19450
 
    RETURN true;
19451
 
  END IF;
19452
 
 
19453
 
  SELECT COALESCE(COUNT(*), 0) INTO _result
19454
 
    FROM ( SELECT poitem_id
19455
 
             FROM poitem, itemsite
19456
 
            WHERE ( (poitem_pohead_id=pPoheadid)
19457
 
              AND   (poitem_itemsite_id=itemsite_id)
19458
 
              AND   (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id
19459
 
                                                    FROM usrsite
19460
 
                                                   WHERE (usrsite_username=getEffectiveXtUser()))) )
19461
 
           UNION
19462
 
           SELECT pohead_warehous_id
19463
 
             FROM pohead
19464
 
            WHERE ( (pohead_id=pPoheadid)
19465
 
              AND   (pohead_warehous_id NOT IN (SELECT usrsite_warehous_id
19466
 
                                                  FROM usrsite
19467
 
                                                 WHERE (usrsite_username=getEffectiveXtUser()))) )
19468
 
         ) AS data;
19469
 
  IF (_result > 0) THEN
19470
 
    RETURN false;
19471
 
  END IF;
19472
 
 
19473
 
  RETURN true;
19474
 
END;
19475
 
$_$;
19476
 
 
19477
 
 
19478
 
ALTER FUNCTION public.checkpositeprivs(integer) OWNER TO admin;
19479
 
 
19480
 
--
19481
 
--
19482
 
 
19483
 
CREATE FUNCTION checkprivilege(text) RETURNS boolean
19484
 
    LANGUAGE plpgsql STABLE
19485
 
    AS $_$
19486
 
DECLARE
19487
 
  pPrivilege ALIAS FOR $1;
19488
 
  _result TEXT;
19489
 
BEGIN
19490
 
  SELECT priv_id INTO _result
19491
 
    FROM priv, grppriv, usrgrp
19492
 
   WHERE((usrgrp_grp_id=grppriv_grp_id)
19493
 
     AND (grppriv_priv_id=priv_id)
19494
 
     AND (priv_name=pPrivilege)
19495
 
     AND (usrgrp_username=getEffectiveXtUser()));
19496
 
  IF (FOUND) THEN
19497
 
    RETURN true;
19498
 
  END IF;
19499
 
 
19500
 
  SELECT priv_id INTO _result
19501
 
  FROM priv, usrpriv
19502
 
  WHERE ((priv_id=usrpriv_priv_id)
19503
 
  AND (priv_name=pPrivilege)
19504
 
  AND (usrpriv_username=getEffectiveXtUser()));
19505
 
  
19506
 
  IF (FOUND) THEN
19507
 
    RETURN true;
19508
 
  ELSE
19509
 
    RETURN false;
19510
 
  END IF;
19511
 
END;
19512
 
$_$;
19513
 
 
19514
 
 
19515
 
ALTER FUNCTION public.checkprivilege(text) OWNER TO admin;
19516
 
 
19517
 
--
19518
 
--
19519
 
 
19520
 
CREATE FUNCTION checkquotesiteprivs(integer) RETURNS boolean
19521
 
    LANGUAGE plpgsql STABLE
19522
 
    AS $_$
19523
 
DECLARE
19524
 
  pQuheadid ALIAS FOR $1;
19525
 
 
19526
 
BEGIN
19527
 
 
19528
 
  RETURN checkQuoteSitePrivs(pQuheadid, NULL);
19529
 
 
19530
 
END;
19531
 
$_$;
19532
 
 
19533
 
 
19534
 
ALTER FUNCTION public.checkquotesiteprivs(integer) OWNER TO admin;
19535
 
 
19536
 
--
19537
 
--
19538
 
 
19539
 
CREATE FUNCTION checkquotesiteprivs(integer, integer) RETURNS boolean
19540
 
    LANGUAGE plpgsql STABLE
19541
 
    AS $_$
19542
 
DECLARE
19543
 
  pQuheadid ALIAS FOR $1;
19544
 
  pWarehousid ALIAS FOR $2;
19545
 
  _result   INTEGER := 0;
19546
 
 
19547
 
BEGIN
19548
 
 
19549
 
 
19550
 
  IF (NOT fetchMetricBool('MultiWhs')) THEN
19551
 
    RETURN true;
19552
 
  END IF;
19553
 
 
19554
 
  IF ( (NOT fetchUsrPrefBool('selectedSites')) AND (pWarehousid IS NULL) ) THEN
19555
 
    RETURN true;
19556
 
  END IF;
19557
 
 
19558
 
  IF (pWarehousid IS NULL) THEN
19559
 
    SELECT COALESCE(COUNT(*), 0) INTO _result
19560
 
    FROM quitem JOIN itemsite ON (itemsite_id=quitem_itemsite_id)
19561
 
                JOIN site() ON (warehous_id=itemsite_warehous_id)
19562
 
    WHERE (quitem_quhead_id=pQuheadid);
19563
 
  ELSE
19564
 
    SELECT COALESCE(COUNT(*), 0) INTO _result
19565
 
    FROM quitem JOIN itemsite ON (itemsite_id=quitem_itemsite_id)
19566
 
                JOIN site() ON (warehous_id=itemsite_warehous_id)
19567
 
    WHERE ( (quitem_quhead_id=pQuheadid)
19568
 
      AND   (itemsite_warehous_id=pWarehousid) );
19569
 
  END IF;
19570
 
 
19571
 
  IF (_result > 0) THEN
19572
 
    RETURN true;
19573
 
  END IF;
19574
 
 
19575
 
  RETURN false;
19576
 
 
19577
 
END;
19578
 
$_$;
19579
 
 
19580
 
 
19581
 
ALTER FUNCTION public.checkquotesiteprivs(integer, integer) OWNER TO admin;
19582
 
 
19583
 
--
19584
 
--
19585
 
 
19586
 
CREATE FUNCTION checkrasiteprivs(integer) RETURNS boolean
19587
 
    LANGUAGE plpgsql STABLE
19588
 
    AS $_$
19589
 
DECLARE
19590
 
  pRaheadid ALIAS FOR $1;
19591
 
  _check    BOOLEAN;
19592
 
  _result   INTEGER;
19593
 
 
19594
 
BEGIN
19595
 
 
19596
 
  IF (NOT fetchMetricBool('MultiWhs')) THEN
19597
 
    RETURN true;
19598
 
  END IF;
19599
 
 
19600
 
  IF (NOT fetchUsrPrefBool('selectedSites')) THEN
19601
 
    RETURN true;
19602
 
  END IF;
19603
 
 
19604
 
  SELECT COALESCE(COUNT(*), 0) INTO _result
19605
 
    FROM ( SELECT raitem_id
19606
 
             FROM raitem, itemsite
19607
 
            WHERE ( (raitem_rahead_id=pRaheadid)
19608
 
              AND   (raitem_itemsite_id=itemsite_id)
19609
 
              AND   (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id
19610
 
                                                    FROM usrsite
19611
 
                                                   WHERE (usrsite_username=getEffectiveXtUser()))) )
19612
 
           UNION
19613
 
           SELECT raitem_id
19614
 
             FROM raitem, itemsite
19615
 
            WHERE ( (raitem_rahead_id=pRaheadid)
19616
 
              AND   (raitem_coitem_itemsite_id=itemsite_id)
19617
 
              AND   (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id
19618
 
                                                  FROM usrsite
19619
 
                                                 WHERE (usrsite_username=getEffectiveXtUser()))) )
19620
 
         ) AS data;
19621
 
  IF (_result > 0) THEN
19622
 
    RETURN false;
19623
 
  END IF;
19624
 
 
19625
 
  RETURN true;
19626
 
END;
19627
 
$_$;
19628
 
 
19629
 
 
19630
 
ALTER FUNCTION public.checkrasiteprivs(integer) OWNER TO admin;
19631
 
 
19632
 
--
19633
 
--
19634
 
 
19635
 
CREATE FUNCTION checkshipmentsiteprivs(integer) RETURNS boolean
19636
 
    LANGUAGE plpgsql
19637
 
    AS $_$
19638
 
DECLARE
19639
 
  pShipheadid ALIAS FOR $1;
19640
 
  _check    BOOLEAN;
19641
 
  _result   INTEGER;
19642
 
 
19643
 
BEGIN
19644
 
 
19645
 
  IF (NOT fetchMetricBool('MultiWhs')) THEN
19646
 
    RETURN true;
19647
 
  END IF;
19648
 
 
19649
 
  IF (NOT fetchUsrPrefBool('selectedSites')) THEN
19650
 
    RETURN true;
19651
 
  END IF;
19652
 
 
19653
 
  SELECT COALESCE(COUNT(*), 0) INTO _result
19654
 
    FROM ( SELECT coitem_id
19655
 
             FROM shipitem, coitem, itemsite
19656
 
            WHERE ( (shipitem_shiphead_id=pShipheadid)
19657
 
              AND   (coitem_id=shipitem_orderitem_id)
19658
 
              AND   (coitem_itemsite_id=itemsite_id)
19659
 
              AND   (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id
19660
 
                                                    FROM usrsite
19661
 
                                                   WHERE (usrsite_username=getEffectiveXtUser()))) )
19662
 
           UNION
19663
 
           SELECT cohead_warehous_id
19664
 
             FROM shipitem, coitem, cohead
19665
 
            WHERE ( (shipitem_shiphead_id=pShipheadid)
19666
 
              AND   (coitem_id=shipitem_orderitem_id)
19667
 
              AND   (cohead_id=coitem_cohead_id)
19668
 
              AND   (cohead_warehous_id NOT IN (SELECT usrsite_warehous_id
19669
 
                                                  FROM usrsite
19670
 
                                                 WHERE (usrsite_username=getEffectiveXtUser()))) )
19671
 
         ) AS data;
19672
 
  IF (_result > 0) THEN
19673
 
    RETURN false;
19674
 
  END IF;
19675
 
 
19676
 
  RETURN true;
19677
 
END;
19678
 
$_$;
19679
 
 
19680
 
 
19681
 
ALTER FUNCTION public.checkshipmentsiteprivs(integer) OWNER TO admin;
19682
 
 
19683
 
--
19684
 
--
19685
 
 
19686
 
CREATE FUNCTION checksositeprivs(integer) RETURNS boolean
19687
 
    LANGUAGE plpgsql STABLE
19688
 
    AS $_$
19689
 
DECLARE
19690
 
  pSoheadid ALIAS FOR $1;
19691
 
  _check    BOOLEAN;
19692
 
  _result   INTEGER;
19693
 
 
19694
 
BEGIN
19695
 
 
19696
 
  IF (NOT fetchMetricBool('MultiWhs')) THEN
19697
 
    RETURN true;
19698
 
  END IF;
19699
 
 
19700
 
  IF (NOT fetchUsrPrefBool('selectedSites')) THEN
19701
 
    RETURN true;
19702
 
  END IF;
19703
 
 
19704
 
  SELECT COALESCE(COUNT(*), 0) INTO _result
19705
 
    FROM ( SELECT coitem_id
19706
 
             FROM coitem, itemsite
19707
 
            WHERE ( (coitem_cohead_id=pSoheadid)
19708
 
              AND   (coitem_itemsite_id=itemsite_id)
19709
 
              AND   (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id
19710
 
                                                    FROM usrsite
19711
 
                                                   WHERE (usrsite_username=getEffectiveXtUser()))) )
19712
 
           UNION
19713
 
           SELECT cohead_warehous_id
19714
 
             FROM cohead
19715
 
            WHERE ( (cohead_id=pSoheadid)
19716
 
              AND   (cohead_warehous_id NOT IN (SELECT usrsite_warehous_id
19717
 
                                                  FROM usrsite
19718
 
                                                 WHERE (usrsite_username=getEffectiveXtUser()))) )
19719
 
         ) AS data;
19720
 
  IF (_result > 0) THEN
19721
 
    RETURN false;
19722
 
  END IF;
19723
 
 
19724
 
  RETURN true;
19725
 
END;
19726
 
$_$;
19727
 
 
19728
 
 
19729
 
ALTER FUNCTION public.checksositeprivs(integer) OWNER TO admin;
19730
 
 
19731
 
--
19732
 
--
19733
 
 
19734
 
CREATE FUNCTION checkvouchersiteprivs(integer) RETURNS boolean
19735
 
    LANGUAGE plpgsql STABLE
19736
 
    AS $_$
19737
 
DECLARE
19738
 
  pVoheadid ALIAS FOR $1;
19739
 
  _check    BOOLEAN;
19740
 
  _result   INTEGER;
19741
 
 
19742
 
BEGIN
19743
 
 
19744
 
  IF (NOT fetchMetricBool('MultiWhs')) THEN
19745
 
    RETURN true;
19746
 
  END IF;
19747
 
 
19748
 
  IF (NOT fetchUsrPrefBool('selectedSites')) THEN
19749
 
    RETURN true;
19750
 
  END IF;
19751
 
 
19752
 
  SELECT COALESCE(COUNT(*), 0) INTO _result
19753
 
    FROM ( SELECT voitem_id
19754
 
             FROM voitem, poitem, itemsite
19755
 
            WHERE ( (voitem_vohead_id=pVoheadid)
19756
 
              AND   (poitem_id=voitem_poitem_id)
19757
 
              AND   (poitem_itemsite_id=itemsite_id)
19758
 
              AND   (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id
19759
 
                                                    FROM usrsite
19760
 
                                                   WHERE (usrsite_username=getEffectiveXtUser()))) )
19761
 
           UNION
19762
 
           SELECT pohead_warehous_id
19763
 
             FROM vohead, pohead
19764
 
            WHERE ( (vohead_id=pVoheadid)
19765
 
              AND   (pohead_id=vohead_pohead_id)
19766
 
              AND   (pohead_warehous_id NOT IN (SELECT usrsite_warehous_id
19767
 
                                                  FROM usrsite
19768
 
                                                 WHERE (usrsite_username=getEffectiveXtUser()))) )
19769
 
         ) AS data;
19770
 
  IF (_result > 0) THEN
19771
 
    RETURN false;
19772
 
  END IF;
19773
 
 
19774
 
  RETURN true;
19775
 
END;
19776
 
$_$;
19777
 
 
19778
 
 
19779
 
ALTER FUNCTION public.checkvouchersiteprivs(integer) OWNER TO admin;
19780
 
 
19781
 
--
19782
 
--
19783
 
 
19784
 
CREATE FUNCTION clearnumberissue(psequence text, pnumber integer) RETURNS boolean
19785
 
    LANGUAGE plpgsql
19786
 
    AS $$
19787
 
DECLARE
19788
 
  __seqiss      seqiss[];
19789
 
  __newiss      seqiss[] := ARRAY[]::seqiss[];
19790
 
  _i            INTEGER;
19791
 
  _result       BOOLEAN := FALSE;
19792
 
  _interval     TEXT := fetchMetricText('NumberIssueResetIntervalDays') || ' day';
19793
 
  _number       INTEGER;
19794
 
BEGIN
19795
 
  -- get the sequence to update
19796
 
  SELECT orderseq_seqiss INTO __seqiss
19797
 
  FROM orderseq
19798
 
  WHERE (orderseq_name=psequence);
19799
 
 
19800
 
  IF (NOT FOUND) THEN
19801
 
    RAISE EXCEPTION 'Invalid orderseq_name %', psequence;
19802
 
  END IF;
19803
 
 
19804
 
  IF(ARRAY_LENGTH(COALESCE(__seqiss,__newiss),1) IS NULL) THEN
19805
 
    RETURN FALSE;
19806
 
  END IF;
19807
 
 
19808
 
  -- build a new array sans the number we are releasing
19809
 
  FOR _i IN 1..ARRAY_LENGTH(__seqiss,1)
19810
 
  LOOP
19811
 
    IF((__seqiss[_i]).seqiss_number = pnumber) THEN
19812
 
      _result = TRUE;
19813
 
    -- don't bother re-adding stale numbers
19814
 
    ELSIF (now() - _interval::INTERVAL > (__seqiss[_i]).seqiss_time) THEN
19815
 
      IF (_number IS NULL) THEN
19816
 
        _number := (__seqiss[_i]).seqiss_number;
19817
 
      ELSE 
19818
 
        _number := LEAST((__seqiss[_i]).seqiss_number, _number);
19819
 
      END IF;
19820
 
    ELSE
19821
 
      __newiss := __newiss || __seqiss[_i];
19822
 
    END IF;
19823
 
  END LOOP;
19824
 
 
19825
 
  -- update the order sequence with the result
19826
 
  UPDATE orderseq SET
19827
 
    orderseq_seqiss = __newiss
19828
 
  WHERE (orderseq_name=psequence);
19829
 
 
19830
 
  -- reset to any cleared stale number
19831
 
  IF(_number IS NOT NULL) THEN
19832
 
    UPDATE orderseq SET
19833
 
      orderseq_number = _number
19834
 
    WHERE (orderseq_name=psequence);
19835
 
  END IF;
19836
 
  
19837
 
  RETURN _result;
19838
 
END;
19839
 
$$;
19840
 
 
19841
 
 
19842
 
ALTER FUNCTION public.clearnumberissue(psequence text, pnumber integer) OWNER TO admin;
19843
 
 
19844
 
--
19845
 
--
19846
 
 
19847
 
CREATE FUNCTION clearnumberissue(psequence text, pnumber text) RETURNS boolean
19848
 
    LANGUAGE plpgsql
19849
 
    AS $$
19850
 
DECLARE
19851
 
  _castpnumber  INTEGER;
19852
 
BEGIN
19853
 
  -- for now, order numbers in the database are text but usually
19854
 
  -- string representations of integers. allow for the occasional non-integer.
19855
 
  BEGIN
19856
 
    _castpnumber  := CAST(pnumber AS INTEGER);
19857
 
  EXCEPTION WHEN cannot_coerce OR
19858
 
                 invalid_text_representation
19859
 
  THEN
19860
 
    RAISE DEBUG 'clearNumberIssue(%, %) received an unexpected pnumber',
19861
 
                  psequence, pnumber;
19862
 
    RETURN FALSE;
19863
 
  END;
19864
 
 
19865
 
  RETURN clearNumberIssue(psequence, _castpnumber);
19866
 
END;
19867
 
$$;
19868
 
 
19869
 
 
19870
 
ALTER FUNCTION public.clearnumberissue(psequence text, pnumber text) OWNER TO admin;
19871
 
 
19872
 
--
19873
 
--
19874
 
 
19875
 
CREATE FUNCTION clearpayment(integer) RETURNS integer
19876
 
    LANGUAGE plpgsql
19877
 
    AS $_$
19878
 
DECLARE
19879
 
  pApselectid ALIAS FOR $1;
19880
 
 
19881
 
BEGIN
19882
 
 
19883
 
  DELETE FROM apselect
19884
 
  WHERE (apselect_id=pApselectid);
19885
 
 
19886
 
  RETURN 1;
19887
 
 
19888
 
END;
19889
 
$_$;
19890
 
 
19891
 
 
19892
 
ALTER FUNCTION public.clearpayment(integer) OWNER TO admin;
19893
 
 
19894
 
--
19895
 
--
19896
 
 
19897
 
CREATE FUNCTION closeaccountingperiod(integer) RETURNS integer
19898
 
    LANGUAGE plpgsql
19899
 
    AS $_$
19900
 
DECLARE
19901
 
  pPeriodid ALIAS FOR $1;
19902
 
  _r RECORD;
19903
 
  _nextPeriodid INTEGER;
19904
 
  _trialbalid INTEGER;
19905
 
  _ending NUMERIC;
19906
 
  _currYear INTEGER;
19907
 
  _nextYear INTEGER;
19908
 
BEGIN
19909
 
 
19910
 
  IF ( NOT ( SELECT period_initial
19911
 
             FROM period
19912
 
             WHERE (period_id=pPeriodid) ) ) THEN
19913
 
 
19914
 
    IF ( ( SELECT period_closed
19915
 
           FROM period
19916
 
           WHERE (period_id=pPeriodid) ) ) THEN
19917
 
      RETURN -1;
19918
 
    END IF;
19919
 
 
19920
 
    SELECT prev.period_id AS periodid, prev.period_closed AS closed INTO _r
19921
 
    FROM period AS prev, period AS curr
19922
 
    WHERE ( (prev.period_end = (curr.period_start - 1))
19923
 
     AND (curr.period_id=pPeriodid) );
19924
 
    IF (NOT FOUND) THEN
19925
 
      RETURN -2;
19926
 
    END IF;
19927
 
 
19928
 
    IF (NOT _r.closed) THEN
19929
 
      RETURN -3;
19930
 
    END IF;
19931
 
 
19932
 
  END IF;
19933
 
 
19934
 
  SELECT next.period_id INTO _nextPeriodid
19935
 
  FROM period AS next, period AS curr
19936
 
  WHERE ( (next.period_start = (curr.period_end + 1))
19937
 
   AND (curr.period_id=pPeriodid) );
19938
 
  IF (NOT FOUND) THEN
19939
 
    RETURN -4;
19940
 
  END IF;
19941
 
 
19942
 
  IF ( ( SELECT (period_end >= CURRENT_DATE)
19943
 
         FROM period
19944
 
         WHERE (period_id=pPeriodid) ) ) THEN
19945
 
    RETURN -5;
19946
 
  END IF;
19947
 
 
19948
 
  SELECT yearperiod_id INTO _currYear
19949
 
    FROM yearperiod, period
19950
 
   WHERE ((period_end BETWEEN yearperiod_start and yearperiod_end)
19951
 
     AND  (period_id=pPeriodid));
19952
 
  IF (NOT FOUND) THEN
19953
 
    _currYear := -1;
19954
 
  END IF;
19955
 
 
19956
 
  SELECT yearperiod_id INTO _nextYear
19957
 
    FROM yearperiod, period
19958
 
   WHERE ((period_end BETWEEN yearperiod_start and yearperiod_end)
19959
 
     AND  (period_id=_nextPeriodid));
19960
 
  IF (NOT FOUND) THEN
19961
 
    RETURN -6;
19962
 
  END IF;
19963
 
 
19964
 
  FOR _r IN SELECT accnt_id, accnt_type IN ('E', 'R') AS revexp,
19965
 
                   trialbal_id, trialbal_beginning,
19966
 
                   trialbal_credits, trialbal_debits
19967
 
            FROM accnt LEFT OUTER JOIN trialbal ON ( (trialbal_accnt_id=accnt_id) AND (trialbal_period_id=pPeriodid) )
19968
 
            ORDER BY accnt_id LOOP
19969
 
    IF (_r.trialbal_id IS NULL) THEN
19970
 
      _ending = 0;
19971
 
 
19972
 
      INSERT INTO trialbal
19973
 
      ( trialbal_period_id, trialbal_accnt_id,
19974
 
        trialbal_beginning, trialbal_ending, trialbal_dirty,
19975
 
        trialbal_credits, trialbal_debits )
19976
 
      VALUES
19977
 
      ( pPeriodid, _r.accnt_id,
19978
 
        0, 0, FALSE,
19979
 
        0, 0 );
19980
 
    ELSE
19981
 
      _ending = (_r.trialbal_beginning - _r.trialbal_debits + _r.trialbal_credits);
19982
 
 
19983
 
      UPDATE trialbal
19984
 
      SET trialbal_ending=_ending,
19985
 
          trialbal_dirty = FALSE
19986
 
      WHERE (trialbal_id=_r.trialbal_id);
19987
 
 
19988
 
      PERFORM forwardUpdateTrialBalance(_r.trialbal_id);
19989
 
    END IF;
19990
 
 
19991
 
    IF (_r.revexp AND _currYear != _nextYear) THEN
19992
 
      _ending := 0;
19993
 
    END IF;
19994
 
 
19995
 
    SELECT trialbal_id INTO _trialbalid
19996
 
    FROM trialbal
19997
 
    WHERE ( (trialbal_period_id=_nextPeriodid)
19998
 
     AND (trialbal_accnt_id=_r.accnt_id) );
19999
 
    IF (FOUND) THEN
20000
 
      UPDATE trialbal
20001
 
      SET trialbal_beginning = (_ending + trialbal_yearend),
20002
 
          trialbal_ending = (_ending + trialbal_yearend - trialbal_debits + trialbal_credits)
20003
 
      WHERE (trialbal_id=_trialbalid);
20004
 
    ELSE
20005
 
      INSERT INTO trialbal
20006
 
      ( trialbal_period_id, trialbal_accnt_id,
20007
 
        trialbal_beginning, trialbal_ending, trialbal_dirty,
20008
 
        trialbal_credits, trialbal_debits )
20009
 
      VALUES(_nextPeriodid, _r.accnt_id,
20010
 
             _ending, _ending, TRUE,
20011
 
             0, 0 );
20012
 
    END IF;
20013
 
 
20014
 
  END LOOP;
20015
 
 
20016
 
  UPDATE period
20017
 
  SET period_closed=TRUE
20018
 
  WHERE (period_id=pPeriodid);
20019
 
 
20020
 
  RETURN pPeriodid;
20021
 
 
20022
 
END;
20023
 
$_$;
20024
 
 
20025
 
 
20026
 
ALTER FUNCTION public.closeaccountingperiod(integer) OWNER TO admin;
20027
 
 
20028
 
--
20029
 
--
20030
 
 
20031
 
CREATE FUNCTION closeaccountingyearperiod(integer) RETURNS integer
20032
 
    LANGUAGE plpgsql
20033
 
    AS $_$
20034
 
DECLARE
20035
 
  pYearPeriodid ALIAS FOR $1;
20036
 
  _result INTEGER;
20037
 
BEGIN
20038
 
 
20039
 
  IF ( ( SELECT yearperiod_closed
20040
 
           FROM yearperiod
20041
 
          WHERE (yearperiod_id=pYearPeriodid) ) ) THEN
20042
 
    RETURN -1;
20043
 
  END IF;
20044
 
 
20045
 
  IF ( ( SELECT (count(period_id) > 0)
20046
 
           FROM period
20047
 
          WHERE ((period_yearperiod_id=pYearPeriodid)
20048
 
           AND (NOT period_closed)) ) ) THEN
20049
 
    RETURN -10;
20050
 
  END IF;
20051
 
 
20052
 
  IF ( ( SELECT (count(yearperiod_id) > 0)
20053
 
           FROM yearperiod
20054
 
          WHERE ((yearperiod_end< (
20055
 
            SELECT yearperiod_end 
20056
 
            FROM yearperiod 
20057
 
            WHERE (yearperiod_id=pYearPeriodId))
20058
 
          )
20059
 
           AND (NOT yearperiod_closed)) ) ) THEN
20060
 
    RETURN -11;
20061
 
  END IF;
20062
 
 
20063
 
 
20064
 
 
20065
 
  IF ( ( SELECT (yearperiod_end >= CURRENT_DATE)
20066
 
           FROM yearperiod
20067
 
          WHERE (yearperiod_id=pYearPeriodid) ) ) THEN
20068
 
    RETURN -5;
20069
 
  END IF;
20070
 
 
20071
 
  SELECT updateRetainedEarnings(pYearPeriodid) INTO _result;
20072
 
  IF (_result < 0) THEN
20073
 
    RETURN _result;
20074
 
  END IF;
20075
 
 
20076
 
  UPDATE yearperiod
20077
 
    SET yearperiod_closed = TRUE
20078
 
  WHERE yearperiod_id = pYearPeriodid;
20079
 
 
20080
 
  RETURN 0;
20081
 
 
20082
 
END;
20083
 
$_$;
20084
 
 
20085
 
 
20086
 
ALTER FUNCTION public.closeaccountingyearperiod(integer) OWNER TO admin;
20087
 
 
20088
 
--
20089
 
--
20090
 
 
20091
 
CREATE FUNCTION closepo(integer) RETURNS integer
20092
 
    LANGUAGE plpgsql
20093
 
    AS $_$
20094
 
DECLARE
20095
 
  pPoheadid ALIAS FOR $1;
20096
 
 
20097
 
BEGIN
20098
 
 
20099
 
  UPDATE poitem
20100
 
  SET poitem_status='C'
20101
 
  WHERE (poitem_pohead_id=pPoheadid);
20102
 
 
20103
 
 
20104
 
  RETURN 1;
20105
 
 
20106
 
END;
20107
 
$_$;
20108
 
 
20109
 
 
20110
 
ALTER FUNCTION public.closepo(integer) OWNER TO admin;
20111
 
 
20112
 
--
20113
 
--
20114
 
 
20115
 
CREATE FUNCTION closewo(integer, boolean) RETURNS integer
20116
 
    LANGUAGE plpgsql
20117
 
    AS $_$
20118
 
DECLARE
20119
 
  pWoid ALIAS FOR $1;
20120
 
  pPostMaterialVariances ALIAS FOR $2;
20121
 
 
20122
 
BEGIN
20123
 
  
20124
 
  RETURN closeWo(pWoid, pPostMaterialVariances, CURRENT_DATE);
20125
 
END;
20126
 
$_$;
20127
 
 
20128
 
 
20129
 
ALTER FUNCTION public.closewo(integer, boolean) OWNER TO admin;
20130
 
 
20131
 
--
20132
 
--
20133
 
 
20134
 
CREATE FUNCTION closewo(integer, boolean, date) RETURNS integer
20135
 
    LANGUAGE plpgsql
20136
 
    AS $_$
20137
 
DECLARE
20138
 
  pWoid ALIAS FOR $1;
20139
 
  pPostMaterialVariances ALIAS FOR $2;
20140
 
  pTransDate ALIAS FOR $3;
20141
 
  _woNumber TEXT;
20142
 
  _check CHAR;
20143
 
  _itemlocSeries INTEGER := 0;
20144
 
 
20145
 
BEGIN
20146
 
 
20147
 
  --Comment this out
20148
 
  --In addition to IssueToShipping driving PostProduction,
20149
 
  --not PostProduction can drive IssueToShipping.
20150
 
  --Must allow closing of Job items
20151
 
 
20152
 
  --If this is item type Job then we cannot close here
20153
 
  --SELECT itemsite_costmethod INTO _check
20154
 
  --FROM wo,itemsite
20155
 
  --WHERE ((wo_id=pWoid)
20156
 
  --AND (wo_itemsite_id=itemsite_id)
20157
 
  --AND (itemsite_costmethod = 'J'));
20158
 
  --IF (FOUND) THEN
20159
 
  --  RAISE EXCEPTION 'Work orders for Job items are closed when all quantities are shipped';
20160
 
  --END IF;
20161
 
 
20162
 
  SELECT formatWoNumber(pWoid) INTO _woNumber;
20163
 
 
20164
 
  IF ( SELECT (count(*) > 0)
20165
 
       FROM womatl
20166
 
       JOIN itemsite ON (womatl_itemsite_id=itemsite_id)
20167
 
       JOIN item ON ((itemsite_item_id=item_id) AND (item_type='T'))
20168
 
       WHERE ((womatl_wo_id=pWoid)
20169
 
         AND  (womatl_qtyiss > 0)) ) THEN
20170
 
    RAISE EXCEPTION 'All Tools must be returned before the W/O can be closed';
20171
 
  END IF;
20172
 
 
20173
 
  PERFORM insertGLTransaction( 'W/O', 'WO', _woNumber, ('Manufacturing Inventory Cost Variance for ' || item_number),
20174
 
                               getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), 
20175
 
                               getPrjAccntId(wo_prj_id, costcat_invcost_accnt_id), -1,
20176
 
                               COALESCE(wo_wipvalue, 0), pTransDate )
20177
 
  FROM wo, itemsite, item, costcat
20178
 
  WHERE ( (wo_itemsite_id=itemsite_id)
20179
 
   AND (itemsite_item_id=item_id)
20180
 
   AND (itemsite_costcat_id=costcat_id)
20181
 
   AND (wo_id=pWoid) );
20182
 
 
20183
 
  PERFORM insertGLTransaction( 'W/O', 'WO', _woNumber, ('Breeder Inventory Cost Variance for ' || item_number),
20184
 
                               getPrjAccntId(wo_prj_id, costcat_wip_accnt_id),
20185
 
                               CASE WHEN(itemsite_costmethod='A') THEN costcat_asset_accnt_id
20186
 
                                    ELSE getPrjAccntId(wo_prj_id, costcat_invcost_accnt_id)
20187
 
                               END,
20188
 
                               -1,
20189
 
                               COALESCE(wo_brdvalue, 0), pTransDate )
20190
 
  FROM wo, itemsite, item, costcat
20191
 
  WHERE ( (wo_itemsite_id=itemsite_id)
20192
 
   AND (itemsite_item_id=item_id)
20193
 
   AND (itemsite_costcat_id=costcat_id)
20194
 
   AND (wo_id=pWoid) );
20195
 
 
20196
 
  IF ( ( SELECT wo_qtyrcv
20197
 
         FROM wo
20198
 
         WHERE (wo_id=pWoid) ) > 0 ) THEN
20199
 
 
20200
 
    IF (pPostMaterialVariances) THEN
20201
 
    INSERT INTO womatlvar ( womatlvar_number, womatlvar_subnumber, womatlvar_posted,
20202
 
        womatlvar_parent_itemsite_id, womatlvar_component_itemsite_id,
20203
 
        womatlvar_qtyord, womatlvar_qtyrcv,
20204
 
        womatlvar_qtyiss, womatlvar_qtyfxd, womatlvar_qtyper,
20205
 
        womatlvar_scrap, womatlvar_wipscrap, womatlvar_bomitem_id,
20206
 
        womatlvar_notes, womatlvar_ref )
20207
 
      SELECT wo_number, wo_subnumber, pTransDate,
20208
 
             wo_itemsite_id, womatl_itemsite_id,
20209
 
             wo_qtyord, wo_qtyrcv,
20210
 
             itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyiss),
20211
 
             itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyfxd),
20212
 
             itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyper),
20213
 
             womatl_scrap,
20214
 
             itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtywipscrap),
20215
 
             womatl_bomitem_id,
20216
 
             womatl_notes, womatl_ref             
20217
 
      FROM wo, womatl, itemsite, item
20218
 
      WHERE ((womatl_wo_id=wo_id)
20219
 
       AND (womatl_itemsite_id=itemsite_id)
20220
 
       AND (itemsite_item_id=item_id)
20221
 
       AND (item_type <> 'T')      
20222
 
       AND (wo_id=pWoid));
20223
 
    END IF;
20224
 
  END IF;
20225
 
 
20226
 
  PERFORM deletePr('W', womatl_id)
20227
 
  FROM womatl
20228
 
  WHERE (womatl_wo_id=pWoid);
20229
 
 
20230
 
  UPDATE wo
20231
 
  SET wo_wipvalue = 0, wo_brdvalue=0,
20232
 
      wo_status='C'
20233
 
  WHERE (wo_id=pWoid);
20234
 
 
20235
 
  RETURN 1;
20236
 
END;
20237
 
$_$;
20238
 
 
20239
 
 
20240
 
ALTER FUNCTION public.closewo(integer, boolean, date) OWNER TO admin;
20241
 
 
20242
 
--
20243
 
--
20244
 
 
20245
 
CREATE TABLE cntct (
20246
 
    cntct_id integer NOT NULL,
20247
 
    cntct_crmacct_id integer,
20248
 
    cntct_addr_id integer,
20249
 
    cntct_first_name text,
20250
 
    cntct_last_name text,
20251
 
    cntct_honorific text,
20252
 
    cntct_initials text,
20253
 
    cntct_active boolean DEFAULT true,
20254
 
    cntct_phone text,
20255
 
    cntct_phone2 text,
20256
 
    cntct_fax text,
20257
 
    cntct_email text,
20258
 
    cntct_webaddr text,
20259
 
    cntct_notes text,
20260
 
    cntct_title text,
20261
 
    cntct_number text NOT NULL,
20262
 
    cntct_middle text,
20263
 
    cntct_suffix text,
20264
 
    cntct_owner_username text,
20265
 
    cntct_name text
20266
 
);
20267
 
 
20268
 
 
20269
 
ALTER TABLE public.cntct OWNER TO admin;
20270
 
 
20271
 
--
20272
 
--
20273
 
 
20274
 
COMMENT ON TABLE cntct IS 'Contact - information on how to reach a living person';
20275
 
 
20276
 
 
20277
 
--
20278
 
--
20279
 
 
20280
 
CREATE FUNCTION cntct() RETURNS SETOF cntct
20281
 
    LANGUAGE plpgsql
20282
 
    AS $$
20283
 
DECLARE
20284
 
  _row cntct%ROWTYPE;
20285
 
  _priv TEXT;
20286
 
  _grant BOOLEAN;
20287
 
 
20288
 
BEGIN
20289
 
  -- This query will give us the most permissive privilege the user has been granted
20290
 
  SELECT privilege, granted INTO _priv, _grant
20291
 
  FROM privgranted 
20292
 
  WHERE privilege IN ('MaintainAllContacts','ViewAllContacts','MaintainPersonalContacts','ViewPersonalContacts')
20293
 
  ORDER BY granted DESC, sequence
20294
 
  LIMIT 1;
20295
 
 
20296
 
  -- If have an 'All' privilege return all results
20297
 
  IF (_priv ~ 'All' AND _grant) THEN
20298
 
    FOR _row IN 
20299
 
      SELECT * FROM cntct
20300
 
    LOOP
20301
 
      RETURN NEXT _row;
20302
 
    END LOOP;
20303
 
  -- Otherwise if have any other grant, must be personal privilege.
20304
 
  ELSIF (_grant) THEN
20305
 
    FOR _row IN 
20306
 
      SELECT * FROM cntct 
20307
 
      WHERE cntct_owner_username = getEffectiveXtUser()
20308
 
    LOOP
20309
 
      RETURN NEXT _row;
20310
 
    END LOOP;
20311
 
  END IF;
20312
 
 
20313
 
  RETURN;
20314
 
 
20315
 
END;
20316
 
$$;
20317
 
 
20318
 
 
20319
 
ALTER FUNCTION public.cntct() OWNER TO admin;
20320
 
 
20321
 
--
20322
 
--
20323
 
 
20324
 
COMMENT ON FUNCTION cntct() IS 'A table function that returns Contact results according to privilege settings.';
20325
 
 
20326
 
 
20327
 
--
20328
 
--
20329
 
 
20330
 
CREATE FUNCTION cntctdups(text, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS SETOF cntctdup
20331
 
    LANGUAGE plpgsql
20332
 
    AS $_$
20333
 
DECLARE
20334
 
  pSearchText ALIAS FOR $1;
20335
 
  pSearchContactName ALIAS FOR $2;
20336
 
  pSearchPhone ALIAS FOR $3;
20337
 
  pSearchEmail ALIAS FOR $4;
20338
 
  pSearchNumber ALIAS FOR $5;
20339
 
  pSearchName ALIAS FOR $6;
20340
 
  pShowInactive ALIAS FOR $7;
20341
 
  pIgnoreBlanks ALIAS FOR $8;
20342
 
  pIndentedDups ALIAS FOR $9;
20343
 
  pCheckHnfc ALIAS FOR $10;
20344
 
  pCheckFirst ALIAS FOR $11;
20345
 
  pCheckMiddle ALIAS FOR $12;
20346
 
  pCheckLast ALIAS FOR $13;
20347
 
  pCheckSuffix ALIAS FOR $14;
20348
 
  pCheckPhone ALIAS FOR $15;
20349
 
  pCheckEmail ALIAS FOR $16;
20350
 
  _cntct cntctdup%ROWTYPE;
20351
 
  _cntctdup cntctdup%ROWTYPE;
20352
 
  _rec RECORD;
20353
 
  _operator TEXT := '';
20354
 
  _clause TEXT;
20355
 
  _qry  TEXT := '';
20356
 
  _return BOOLEAN := true;
20357
 
  _text TEXT;
20358
 
  _first BOOLEAN := true;
20359
 
 
20360
 
BEGIN
20361
 
  -- Validate
20362
 
  IF (pIndentedDups AND NOT pCheckHnfc AND NOT pCheckFirst AND NOT pCheckMiddle AND 
20363
 
      NOT pCheckLast AND NOT pCheckSuffix AND NOT pCheckEmail AND NOT pCheckPhone) THEN
20364
 
    RETURN;
20365
 
  END IF;
20366
 
 
20367
 
  _text = quote_literal(pSearchText);
20368
 
 
20369
 
  IF (pIndentedDups) THEN
20370
 
    _qry := 'SELECT 
20371
 
        -1 AS cntct_id,
20372
 
        -1 AS cntct_crmacct_id,
20373
 
        -1 AS cntct_addr_id,';
20374
 
    IF (NOT pCheckFirst) THEN
20375
 
      _qry := _qry || ''''' AS ';
20376
 
    END IF;
20377
 
    _qry := _qry || ' cntct_first_name,';
20378
 
    IF (NOT pCheckLast) THEN
20379
 
      _qry := _qry || ''''' AS ';
20380
 
    END IF;
20381
 
    _qry := _qry || ' cntct_last_name,';
20382
 
    IF (NOT pCheckHnfc) THEN
20383
 
      _qry := _qry || ''''' AS ';
20384
 
    END IF;
20385
 
    _qry := _qry || ' cntct_honorific,';
20386
 
    _qry := _qry || ' '''' AS cntct_initials,';
20387
 
    _qry := _qry || ' NULL AS cntct_active,';
20388
 
    IF (NOT pCheckPhone) THEN
20389
 
      _qry := _qry || ''''' AS ';
20390
 
    END IF;
20391
 
    _qry := _qry || ' cntct_phone,';
20392
 
    IF (NOT pCheckPhone) THEN
20393
 
      _qry := _qry || ''''' AS ';
20394
 
    END IF;
20395
 
    _qry := _qry || ' cntct_phone2,';
20396
 
    _qry := _qry || ' '''' AS cntct_fax,';
20397
 
    IF (NOT pCheckEmail) THEN
20398
 
      _qry := _qry || ''''' AS ';
20399
 
    END IF;
20400
 
    _qry := _qry || ' cntct_email,';
20401
 
    _qry := _qry || ' '''' AS cntct_webaddr,';
20402
 
    _qry := _qry || ' '''' AS cntct_notes,';
20403
 
    _qry := _qry || ' '''' AS cntct_title,';
20404
 
    _qry := _qry || ' '''' AS cntct_number,';
20405
 
    IF (NOT pCheckMiddle) THEN
20406
 
      _qry := _qry || ''''' AS ';
20407
 
    END IF;
20408
 
    _qry := _qry || ' cntct_middle,';
20409
 
    IF (NOT pCheckSuffix) THEN
20410
 
      _qry := _qry || ''''' AS ';
20411
 
    END IF;
20412
 
    _qry := _qry || ' cntct_suffix,';
20413
 
    _qry := _qry || ' '''' AS cntct_owner_username,';
20414
 
    _qry := _qry || ' '''' AS cntct_name,';
20415
 
    _qry := _qry || ' '''' AS crmacct_number, ';
20416
 
    _qry := _qry || ' '''' AS crmacct_name, ';
20417
 
    _qry := _qry || ' NULL AS addr_id,
20418
 
                NULL AS addr_active,
20419
 
                '''' AS addr_line1,
20420
 
                '''' AS addr_line2,
20421
 
                '''' AS addr_line3,
20422
 
                '''' AS addr_city,
20423
 
                '''' AS addr_state,
20424
 
                '''' AS addr_postalcode,
20425
 
                '''' AS addr_country,
20426
 
                '''' AS addr_notes,
20427
 
                '''' AS addr_number,
20428
 
                cntctdup_level FROM (';
20429
 
  END IF;
20430
 
    _clause := 'SELECT 
20431
 
                cntct_id,
20432
 
                cntct_crmacct_id,
20433
 
                cntct_addr_id,
20434
 
                UPPER(cntct_first_name) AS cntct_first_name,
20435
 
                UPPER(cntct_last_name) AS cntct_last_name,
20436
 
                UPPER(cntct_honorific) AS cntct_honorific,
20437
 
                cntct_initials,
20438
 
                cntct_active,
20439
 
                cntct_phone,
20440
 
                cntct_phone2,
20441
 
                cntct_fax,
20442
 
                UPPER(cntct_email) AS cntct_email,
20443
 
                cntct_webaddr,
20444
 
                cntct_notes,
20445
 
                cntct_title,
20446
 
                cntct_number,
20447
 
                UPPER(cntct_middle) AS cntct_middle,
20448
 
                UPPER(cntct_suffix) AS cntct_suffix,
20449
 
                cntct_owner_username,
20450
 
                cntct_name,
20451
 
                crmacct_number, 
20452
 
                crmacct_name,
20453
 
                addr.*,
20454
 
                0 AS cntctdup_level
20455
 
             FROM cntct()
20456
 
               LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id) 
20457
 
               LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) 
20458
 
             WHERE ';
20459
 
 
20460
 
  IF (NOT pIndentedDups) THEN
20461
 
    WHILE position('UPPER' in _clause) > 0
20462
 
    LOOP
20463
 
      _clause := regexp_replace(_clause, 'UPPER', '');
20464
 
    END LOOP;
20465
 
  END IF;
20466
 
 
20467
 
  _qry := _qry || _clause;
20468
 
           
20469
 
  IF (NOT pShowInactive) THEN
20470
 
    _qry := _qry || ' cntct_active AND ';
20471
 
  END IF;
20472
 
 
20473
 
  IF (pIgnoreBlanks) THEN
20474
 
    _qry := _qry || ' (COALESCE(LENGTH(cntct_first_name || cntct_last_name),0) > 0) AND ';
20475
 
  END IF;
20476
 
 
20477
 
    _qry := _qry || '(false ';
20478
 
 
20479
 
  IF (pSearchNumber) THEN
20480
 
    _qry := _qry || ' OR (crmacct_number ~* ' || quote_literal(pSearchText) || ') ';
20481
 
  END IF;
20482
 
 
20483
 
  IF (pSearchName) THEN
20484
 
    _qry := _qry || ' OR (crmacct_name ~* ' || quote_literal(pSearchText) || ') ';
20485
 
  END IF;
20486
 
 
20487
 
  IF (pSearchContactName) THEN
20488
 
    _qry := _qry || ' OR (cntct_first_name || '' '' || cntct_last_name ~* ' || quote_literal(pSearchText) || ') ';
20489
 
  END IF;
20490
 
  
20491
 
  IF (pSearchPhone) THEN
20492
 
    _qry := _qry || ' OR (cntct_phone || '' '' || cntct_phone2 || '' '' || cntct_fax ~* ' || quote_literal(pSearchText) || ') ';
20493
 
  END IF;
20494
 
 
20495
 
  IF (pSearchEmail) THEN
20496
 
    _qry := _qry || ' OR (cntct_email ~* ' || quote_literal(pSearchText) || ') ';
20497
 
  END IF;
20498
 
 
20499
 
  _qry := _qry || ' ) ';
20500
 
  
20501
 
  IF (pIndentedDups) THEN
20502
 
    _qry := _qry || ') data';
20503
 
    _clause := ' GROUP BY cntctdup_level';
20504
 
    IF (pCheckHnfc) THEN
20505
 
      _clause := _clause || ',cntct_honorific';
20506
 
    END IF;
20507
 
    IF (pCheckFirst) THEN
20508
 
      _clause := _clause || ',cntct_first_name';
20509
 
    END IF;
20510
 
    IF (pCheckMiddle) THEN
20511
 
      _clause := _clause || ',cntct_middle';
20512
 
    END IF;
20513
 
    IF (pCheckLast) THEN
20514
 
      _clause := _clause || ',cntct_last_name';
20515
 
    END IF;
20516
 
    IF (pCheckSuffix) THEN
20517
 
      _clause := _clause || ',cntct_suffix';
20518
 
    END IF;
20519
 
    IF (pCheckEmail) THEN
20520
 
      _clause := _clause || ',cntct_email';
20521
 
    END IF;
20522
 
    IF (pCheckPhone) THEN
20523
 
      _clause := _clause || ',cntct_phone';
20524
 
      _clause := _clause || ',cntct_phone2';
20525
 
    END IF;
20526
 
 
20527
 
    _qry := _qry || _clause; 
20528
 
 
20529
 
    _clause := ' HAVING(';
20530
 
    IF (pCheckHnfc) THEN
20531
 
      _clause := _clause || 'OR COUNT(cntct_honorific) > 1 ';
20532
 
    END IF;
20533
 
    IF (pCheckFirst) THEN
20534
 
      _clause := _clause || 'OR COUNT(cntct_first_name) > 1 ';
20535
 
    END IF;
20536
 
    IF (pCheckMiddle) THEN
20537
 
      _clause := _clause || 'OR COUNT(cntct_middle) > 1 ';
20538
 
    END IF;
20539
 
    IF (pCheckLast) THEN
20540
 
      _clause := _clause || 'OR COUNT(cntct_last_name) > 1 ';
20541
 
    END IF;
20542
 
    IF (pCheckSuffix) THEN
20543
 
      _clause := _clause || 'OR COUNT(cntct_suffix) > 1 ';
20544
 
    END IF;
20545
 
    IF (pCheckEmail) THEN
20546
 
      _clause := _clause || 'OR COUNT(cntct_email) > 1 ';
20547
 
    END IF;
20548
 
    IF (pCheckPhone) THEN
20549
 
      _clause := _clause || 'OR (COUNT(cntct_phone) > 1 AND LENGTH(cntct_phone) > 0) ';
20550
 
      _clause := _clause || 'OR (COUNT(cntct_phone2) > 1 AND LENGTH(cntct_phone2) > 0) ';
20551
 
    END IF;
20552
 
    _clause := _clause || ') ';
20553
 
    _clause := overlay(_clause placing '' from 9 for 2);
20554
 
 
20555
 
    IF (pCheckHnfc) THEN
20556
 
      _clause := _clause || 'AND LENGTH(cntct_honorific) > 0 ';
20557
 
    END IF;
20558
 
    IF (pCheckFirst) THEN
20559
 
      _clause := _clause || 'AND LENGTH(cntct_first_name) > 0  ';
20560
 
    END IF;
20561
 
    IF (pCheckMiddle) THEN
20562
 
      _clause := _clause || 'AND LENGTH(cntct_middle) > 0  ';
20563
 
    END IF;
20564
 
    IF (pCheckLast) THEN
20565
 
      _clause := _clause || 'AND LENGTH(cntct_last_name) > 0  ';
20566
 
    END IF;
20567
 
    IF (pCheckSuffix) THEN
20568
 
      _clause := _clause || 'AND LENGTH(cntct_suffix) > 0  ';
20569
 
    END IF;
20570
 
    IF (pCheckEmail) THEN
20571
 
      _clause := _clause || 'AND LENGTH(cntct_email) > 0  ';
20572
 
    END IF;
20573
 
    
20574
 
    _qry := _qry || _clause;
20575
 
  END IF;
20576
 
 
20577
 
  _qry := _qry || ' ORDER BY cntct_last_name, cntct_first_name;'; 
20578
 
 
20579
 
  FOR _cntct IN
20580
 
    EXECUTE _qry
20581
 
  LOOP
20582
 
 
20583
 
    RETURN NEXT _cntct;
20584
 
 
20585
 
    -- If duplicates, get duplicates
20586
 
    IF (pIndentedDups) THEN
20587
 
    
20588
 
      _qry := 'SELECT                
20589
 
                 cntct.*,
20590
 
                 crmacct_number, 
20591
 
                 crmacct_name,
20592
 
                 addr.*,
20593
 
                 1 AS cntctdup_level
20594
 
               FROM cntct()
20595
 
                 LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id) 
20596
 
                 LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)
20597
 
               WHERE (true) ';
20598
 
 
20599
 
      IF (pCheckHnfc) THEN
20600
 
        _qry := _qry || ' AND (UPPER(cntct_honorific)=' || quote_literal(_cntct.cntct_honorific) || ')';
20601
 
      END IF;
20602
 
 
20603
 
      IF (pCheckFirst) THEN
20604
 
        _qry := _qry || ' AND (UPPER(cntct_first_name)=' || quote_literal(_cntct.cntct_first_name) || ')';
20605
 
      END IF;
20606
 
 
20607
 
      IF (pCheckMiddle) THEN
20608
 
        _qry := _qry || ' AND (UPPER(cntct_middle)=' || quote_literal(_cntct.cntct_middle) || ')';
20609
 
      END IF;
20610
 
 
20611
 
      IF (pCheckLast) THEN
20612
 
        _qry := _qry || ' AND (UPPER(cntct_last_name)=' || quote_literal(_cntct.cntct_last_name) || ')';
20613
 
      END IF;
20614
 
 
20615
 
      IF (pCheckSuffix) THEN
20616
 
        _qry := _qry || ' AND (UPPER(cntct_suffix)=' ||  quote_literal(_cntct.cntct_suffix) || ')';
20617
 
      END IF;
20618
 
 
20619
 
      IF (pCheckPhone) THEN
20620
 
        _qry := _qry || ' AND (cntct_phone=' || quote_literal(_cntct.cntct_phone)  || ')';
20621
 
      END IF;
20622
 
 
20623
 
      IF (pCheckEmail) THEN
20624
 
        _qry := _qry || ' AND (UPPER(cntct_email)=' || quote_literal(_cntct.cntct_email) || ')';
20625
 
      END IF;
20626
 
 
20627
 
      FOR _cntctdup IN
20628
 
        EXECUTE _qry
20629
 
      LOOP
20630
 
        RETURN NEXT _cntctdup;
20631
 
      END LOOP;
20632
 
 
20633
 
    END IF;
20634
 
    
20635
 
  END LOOP;
20636
 
 
20637
 
  RETURN;
20638
 
END;
20639
 
$_$;
20640
 
 
20641
 
 
20642
 
ALTER FUNCTION public.cntctdups(text, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin;
20643
 
 
20644
 
--
20645
 
--
20646
 
 
20647
 
CREATE FUNCTION cntctmerge(integer, integer, boolean) RETURNS boolean
20648
 
    LANGUAGE plpgsql
20649
 
    AS $_$
20650
 
DECLARE
20651
 
  pSourceCntctId ALIAS FOR $1;
20652
 
  pTargetCntctId ALIAS FOR $2;
20653
 
  pPurge ALIAS FOR $3;
20654
 
  _fk           RECORD;
20655
 
  _pk           RECORD;
20656
 
  _sel          RECORD;
20657
 
  _seq          INTEGER;
20658
 
  _col          TEXT;
20659
 
  _pkcol        TEXT;
20660
 
  _qry          TEXT;
20661
 
  _multi        BOOLEAN;
20662
 
 
20663
 
BEGIN
20664
 
  -- Validate
20665
 
  IF (pSourceCntctId IS NULL) THEN
20666
 
    RAISE EXCEPTION 'Source contact id can not be null';
20667
 
  ELSIF (pTargetCntctId IS NULL) THEN
20668
 
    RAISE EXCEPTION 'Target contact id can not be null';
20669
 
  ELSIF (pPurge IS NULL) THEN
20670
 
    RAISE EXCEPTION 'Purge flag can not be null';
20671
 
  END IF;
20672
 
  
20673
 
  -- Determine where this contact is used by analyzing foreign key linkages and update each
20674
 
  FOR _fk IN
20675
 
    SELECT pg_namespace.nspname AS schemaname, con.relname AS tablename, conkey AS seq, conrelid AS class_id 
20676
 
    FROM pg_constraint, pg_class f, pg_class con, pg_namespace
20677
 
    WHERE confrelid=f.oid
20678
 
    AND conrelid=con.oid
20679
 
    AND f.relname = 'cntct'
20680
 
    AND con.relnamespace=pg_namespace.oid
20681
 
    AND con.relname NOT IN ('cntctsel', 'cntctmrgd', 'mrghist','trgthist')
20682
 
  LOOP
20683
 
    -- Validate
20684
 
    IF (ARRAY_UPPER(_fk.seq,1) > 1) THEN
20685
 
      RAISE EXCEPTION 'Updates to tables where the contact is one of multiple foreign key columns is not supported. Error on Table: %',
20686
 
        pg_namespace.nspname || '.' || con.relname;
20687
 
    END IF;
20688
 
    
20689
 
    _seq := _fk.seq[1];
20690
 
 
20691
 
    -- Get the specific column name
20692
 
    SELECT attname INTO _col
20693
 
    FROM pg_attribute, pg_class
20694
 
    WHERE ((attrelid=pg_class.oid)
20695
 
    AND (pg_class.oid=_fk.class_id)
20696
 
    AND (attnum=_seq));
20697
 
 
20698
 
    IF (NOT pPurge) THEN
20699
 
    -- Cache what we're going to do so we can restore if need be.
20700
 
    -- Start by determining the primary key column for this table.
20701
 
      _multi := false;
20702
 
      _qry := 'SELECT pg_attribute.attname AS key
20703
 
               FROM pg_attribute, pg_class 
20704
 
               WHERE pg_class.relnamespace = (
20705
 
                 SELECT oid 
20706
 
                 FROM pg_namespace 
20707
 
                 WHERE pg_namespace.nspname = ''' || _fk.schemaname || ''') 
20708
 
                AND  pg_class.oid IN (
20709
 
                 SELECT indexrelid 
20710
 
                 FROM pg_index 
20711
 
                 WHERE indisprimary = true 
20712
 
                  AND indrelid IN (
20713
 
                    SELECT oid 
20714
 
                    FROM pg_class 
20715
 
                    WHERE lower(relname) = ''' || _fk.tablename || ''')) 
20716
 
                AND pg_attribute.attrelid = pg_class.oid 
20717
 
                AND pg_attribute.attisdropped = false 
20718
 
               ORDER BY pg_attribute.attnum;';
20719
 
 
20720
 
      FOR _pk IN 
20721
 
        EXECUTE _qry
20722
 
      LOOP
20723
 
        IF (_multi) THEN
20724
 
          RAISE EXCEPTION 'Reference tables with composite primary keys not supported.  Try the merge and purge option.';
20725
 
        END IF;
20726
 
        _pkcol := _pk.key;
20727
 
        _multi := true;
20728
 
      END LOOP;
20729
 
 
20730
 
      -- Gather and store the history
20731
 
      _qry := 'INSERT INTO mrghist 
20732
 
               SELECT ' || pSourceCntctId || ', ''' 
20733
 
                        || _fk.schemaname || '.' || _fk.tablename || ''', ''' 
20734
 
                        || _pkcol || ''', ' 
20735
 
                        || _pkcol || ', '''
20736
 
                        || _col || ''' 
20737
 
               FROM ' || _fk.schemaname || '.' || _fk.tablename || '
20738
 
               WHERE (' || _col || '=' || pSourceCntctId || ');';
20739
 
                   --           raise exception '%',_qry;
20740
 
      EXECUTE _qry;
20741
 
      
20742
 
    END IF;
20743
 
 
20744
 
    -- Merge references
20745
 
    _qry := 'UPDATE ' || _fk.schemaname || '.' || _fk.tablename ||
20746
 
            ' SET ' || _col || '=' || pTargetCntctId ||
20747
 
            ' WHERE (' || _col || '=' || pSourceCntctId || ');';
20748
 
            
20749
 
    EXECUTE _qry;
20750
 
         
20751
 
  END LOOP;
20752
 
 
20753
 
  -- Merge cases with no foreign key
20754
 
  IF (NOT pPurge) THEN
20755
 
    INSERT INTO mrghist 
20756
 
    SELECT pSourceCntctId,
20757
 
      'comment',
20758
 
      'comment_id', 
20759
 
      comment_id,
20760
 
      'comment_source_id'
20761
 
    FROM comment
20762
 
    WHERE ((comment_source_id= pSourceCntctId)
20763
 
    AND (comment_source='T'));
20764
 
 
20765
 
    INSERT INTO mrghist 
20766
 
    SELECT pSourceCntctId,
20767
 
      'docass',
20768
 
      'docass_id', 
20769
 
      docass_id,
20770
 
      'docass_source_id'
20771
 
    FROM docass
20772
 
    WHERE ((docass_source_id= pSourceCntctId)
20773
 
    AND (docass_source_type='T'));
20774
 
 
20775
 
    INSERT INTO mrghist 
20776
 
    SELECT pSourceCntctId,
20777
 
      'docass',
20778
 
      'docass_id', 
20779
 
      docass_id,
20780
 
      'docass_target_id'
20781
 
    FROM docass
20782
 
    WHERE ((docass_target_id= pSourceCntctId)
20783
 
    AND (docass_target_type='T'));
20784
 
 
20785
 
    INSERT INTO mrghist 
20786
 
    SELECT pSourceCntctId,
20787
 
      'vendinfo',
20788
 
      'vend_id', 
20789
 
      vend_id,
20790
 
      'vend_cntct1_id'
20791
 
    FROM vendinfo
20792
 
    WHERE (vend_cntct1_id=pSourceCntctId);
20793
 
 
20794
 
    INSERT INTO mrghist 
20795
 
    SELECT pSourceCntctId,
20796
 
      'vendinfo',
20797
 
      'vend_id', 
20798
 
      vend_id,
20799
 
      'vend_cntct2_id'
20800
 
    FROM vendinfo
20801
 
    WHERE (vend_cntct2_id=pSourceCntctId);
20802
 
 
20803
 
    IF (fetchMetricBool('EnableBatchManager') AND packageIsEnabled('xtbatch')) THEN
20804
 
      INSERT INTO mrghist 
20805
 
      SELECT pSourceCntctId,
20806
 
      'xtbatch.emlassc',
20807
 
      'emlassc_id', 
20808
 
      emlassc_id,
20809
 
      'emlassc_assc_id'
20810
 
      FROM xtbatch.emlassc
20811
 
      WHERE ((emlassc_assc_id= pSourceCntctId)
20812
 
      AND (emlassc_type='T'));
20813
 
    END IF;
20814
 
  END IF;
20815
 
 
20816
 
  UPDATE comment
20817
 
  SET comment_source_id = pTargetCntctId
20818
 
  WHERE ((comment_source = 'T')
20819
 
   AND (comment_source_id = pSourceCntctId));
20820
 
 
20821
 
  UPDATE docass
20822
 
  SET docass_source_id = pTargetCntctId
20823
 
  WHERE ((docass_source_type = 'T')
20824
 
   AND (docass_source_id = pSourceCntctId));
20825
 
 
20826
 
  UPDATE docass
20827
 
  SET docass_target_id = pTargetCntctId
20828
 
  WHERE ((docass_target_type = 'T')
20829
 
   AND (docass_target_id = pSourceCntctId));
20830
 
 
20831
 
  UPDATE vendinfo
20832
 
  SET vend_cntct1_id = pTargetCntctId
20833
 
  WHERE (vend_cntct1_id = pSourceCntctId);
20834
 
 
20835
 
  UPDATE vendinfo
20836
 
  SET vend_cntct2_id = pTargetCntctId
20837
 
  WHERE (vend_cntct2_id = pSourceCntctId);
20838
 
 
20839
 
  IF (fetchMetricBool('EnableBatchManager') AND packageIsEnabled('xtbatch')) THEN
20840
 
    UPDATE xtbatch.emlassc
20841
 
    SET emlassc_assc_id = pTargetCntctId
20842
 
    WHERE ((emlassc_type = 'T')
20843
 
     AND (emlassc_assc_id = pSourceCntctId));
20844
 
  END IF;
20845
 
 
20846
 
  IF (NOT pPurge) THEN
20847
 
  -- Record that this has been merged if not already
20848
 
    IF (SELECT (COUNT(cntctmrgd_cntct_id) = 0) 
20849
 
        FROM cntctmrgd
20850
 
        WHERE (cntctmrgd_cntct_id=pSourceCntctId)) THEN
20851
 
      INSERT INTO cntctmrgd VALUES (pSourceCntctId,false);
20852
 
    END IF;
20853
 
  END IF;
20854
 
 
20855
 
 -- Merge field detail to target
20856
 
  SELECT * INTO _sel 
20857
 
  FROM cntctsel 
20858
 
    JOIN cntct ON (cntctsel_cntct_id=cntct_id)
20859
 
  WHERE (cntctsel_cntct_id=pSourceCntctId);
20860
 
  
20861
 
  IF (FOUND) THEN
20862
 
    IF (_sel.cntctsel_mrg_crmacct_id) THEN
20863
 
      IF (NOT pPurge) THEN
20864
 
        INSERT INTO trgthist
20865
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_crmacct_id', cntct_crmacct_id::text || '::integer'
20866
 
        FROM cntct
20867
 
        WHERE (cntct_id=pTargetCntctId);
20868
 
      END IF;
20869
 
      UPDATE cntct SET cntct_crmacct_id=_sel.cntct_crmacct_id WHERE (cntct_id=pTargetCntctId);
20870
 
    END IF;
20871
 
    IF (_sel.cntctsel_mrg_addr_id) THEN
20872
 
      IF (NOT pPurge) THEN
20873
 
        INSERT INTO trgthist
20874
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_addr_id', cntct_addr_id::text || '::integer'
20875
 
        FROM cntct
20876
 
        WHERE (cntct_id=pTargetCntctId);
20877
 
      END IF;
20878
 
      UPDATE cntct SET cntct_addr_id=_sel.cntct_addr_id WHERE (cntct_id=pTargetCntctId);
20879
 
    END IF;
20880
 
    IF (_sel.cntctsel_mrg_first_name) THEN
20881
 
      IF (NOT pPurge) THEN
20882
 
        INSERT INTO trgthist
20883
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_first_name', '''' || cntct_first_name || ''''
20884
 
        FROM cntct
20885
 
        WHERE (cntct_id=pTargetCntctId);
20886
 
      END IF;
20887
 
      UPDATE cntct SET cntct_first_name=_sel.cntct_first_name WHERE (cntct_id=pTargetCntctId);
20888
 
    END IF;
20889
 
    IF (_sel.cntctsel_mrg_last_name) THEN
20890
 
      IF (NOT pPurge) THEN
20891
 
        INSERT INTO trgthist
20892
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_last_name', '''' || cntct_last_name || ''''
20893
 
        FROM cntct
20894
 
        WHERE (cntct_id=pTargetCntctId);
20895
 
      END IF;
20896
 
      UPDATE cntct SET cntct_last_name=_sel.cntct_last_name WHERE (cntct_id=pTargetCntctId);
20897
 
    END IF;
20898
 
    IF (_sel.cntctsel_mrg_honorific) THEN
20899
 
      IF (NOT pPurge) THEN
20900
 
        INSERT INTO trgthist
20901
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_honorific', '''' || cntct_honorific || ''''
20902
 
        FROM cntct
20903
 
        WHERE (cntct_id=pTargetCntctId);
20904
 
      END IF;
20905
 
      UPDATE cntct SET cntct_honorific=_sel.cntct_honorific WHERE (cntct_id=pTargetCntctId);
20906
 
    END IF;
20907
 
    IF (_sel.cntctsel_mrg_initials) THEN
20908
 
      IF (NOT pPurge) THEN
20909
 
        INSERT INTO trgthist
20910
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_initials', '''' || cntct_initials || ''''
20911
 
        FROM cntct
20912
 
        WHERE (cntct_id=pTargetCntctId);
20913
 
      END IF;
20914
 
      UPDATE cntct SET cntct_initials=_sel.cntct_initials WHERE (cntct_id=pTargetCntctId);
20915
 
    END IF;
20916
 
    IF (_sel.cntctsel_mrg_phone) THEN
20917
 
      IF (NOT pPurge) THEN
20918
 
        INSERT INTO trgthist
20919
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_phone', '''' || cntct_phone || ''''
20920
 
        FROM cntct
20921
 
        WHERE (cntct_id=pTargetCntctId);
20922
 
      END IF;
20923
 
      UPDATE cntct SET cntct_phone=_sel.cntct_phone WHERE (cntct_id=pTargetCntctId);
20924
 
    END IF;
20925
 
    IF (_sel.cntctsel_mrg_phone2) THEN
20926
 
      IF (NOT pPurge) THEN
20927
 
        INSERT INTO trgthist
20928
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_phone2', '''' || cntct_phone2 || ''''
20929
 
        FROM cntct
20930
 
        WHERE (cntct_id=pTargetCntctId);
20931
 
      END IF;
20932
 
      UPDATE cntct SET cntct_phone2=_sel.cntct_phone2 WHERE (cntct_id=pTargetCntctId);
20933
 
    END IF;
20934
 
    IF (_sel.cntctsel_mrg_fax)  THEN
20935
 
      IF (NOT pPurge) THEN
20936
 
        INSERT INTO trgthist
20937
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_fax', '''' || cntct_fax || ''''
20938
 
        FROM cntct
20939
 
        WHERE (cntct_id=pTargetCntctId);
20940
 
      END IF;
20941
 
      UPDATE cntct SET cntct_fax=_sel.cntct_fax WHERE (cntct_id=pTargetCntctId);
20942
 
    END IF;
20943
 
    IF (_sel.cntctsel_mrg_email)  THEN
20944
 
      IF (NOT pPurge) THEN
20945
 
        INSERT INTO trgthist
20946
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_email', '''' || cntct_email || ''''
20947
 
        FROM cntct
20948
 
        WHERE (cntct_id=pTargetCntctId);
20949
 
      END IF;
20950
 
      UPDATE cntct SET cntct_email=_sel.cntct_email WHERE (cntct_id=pTargetCntctId);
20951
 
    END IF;
20952
 
    IF (_sel.cntctsel_mrg_webaddr) THEN
20953
 
      IF (NOT pPurge) THEN
20954
 
        INSERT INTO trgthist
20955
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_webaddr', '''' || cntct_webaddr || ''''
20956
 
        FROM cntct
20957
 
        WHERE (cntct_id=pTargetCntctId);
20958
 
      END IF;
20959
 
      UPDATE cntct SET cntct_webaddr=_sel.cntct_webaddr WHERE (cntct_id=pTargetCntctId);
20960
 
    END IF;
20961
 
    IF (_sel.cntctsel_mrg_notes) THEN
20962
 
      IF (NOT pPurge) THEN
20963
 
        INSERT INTO trgthist
20964
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_notes', '''' || cntct_notes || ''''
20965
 
        FROM cntct
20966
 
        WHERE (cntct_id=pTargetCntctId);
20967
 
      END IF;
20968
 
      UPDATE cntct SET cntct_notes=cntct_notes || '
20969
 
 
20970
 
      ' || _sel.cntct_notes WHERE (cntct_id=pTargetCntctId);
20971
 
    END IF;
20972
 
    IF (_sel.cntctsel_mrg_title) THEN
20973
 
      IF (NOT pPurge) THEN
20974
 
        INSERT INTO trgthist
20975
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_title', '''' || cntct_title || ''''
20976
 
        FROM cntct
20977
 
        WHERE (cntct_id=pTargetCntctId);
20978
 
      END IF;
20979
 
      UPDATE cntct SET cntct_title=_sel.cntct_title WHERE (cntct_id=pTargetCntctId);
20980
 
    END IF;
20981
 
    IF (_sel.cntctsel_mrg_middle) THEN
20982
 
      IF (NOT pPurge) THEN
20983
 
        INSERT INTO trgthist
20984
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_middle', '''' || cntct_middle || ''''
20985
 
        FROM cntct
20986
 
        WHERE (cntct_id=pTargetCntctId);
20987
 
      END IF;
20988
 
      UPDATE cntct SET cntct_middle=_sel.cntct_middle WHERE (cntct_id=pTargetCntctId);
20989
 
    END IF;
20990
 
    IF (_sel.cntctsel_mrg_suffix) THEN
20991
 
      IF (NOT pPurge) THEN
20992
 
        INSERT INTO trgthist
20993
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_suffix', '''' || cntct_suffix || ''''
20994
 
        FROM cntct
20995
 
        WHERE (cntct_id=pTargetCntctId);
20996
 
      END IF;
20997
 
      UPDATE cntct SET cntct_suffix=_sel.cntct_suffix WHERE (cntct_id=pTargetCntctId);
20998
 
    END IF;
20999
 
    IF (_sel.cntctsel_mrg_owner_username) THEN
21000
 
      IF (NOT pPurge) THEN
21001
 
        INSERT INTO trgthist
21002
 
        SELECT pSourceCntctId,pTargetCntctId,'cntct_owner_username', '''' || cntct_owner_username || ''''
21003
 
        FROM cntct
21004
 
        WHERE (cntct_id=pTargetCntctId);
21005
 
      END IF;
21006
 
      UPDATE cntct SET cntct_owner_username=_sel.cntct_owner_username WHERE (cntct_id=pTargetCntctId);
21007
 
    END IF;
21008
 
  ELSE
21009
 
    RAISE EXCEPTION 'Source Contact not Found';
21010
 
  END IF;
21011
 
 
21012
 
  -- Disposition source contact
21013
 
  IF (pPurge) THEN
21014
 
    DELETE FROM cntct WHERE cntct_id = pSourceCntctId;
21015
 
  END IF;
21016
 
 
21017
 
  -- Deactivate contact
21018
 
  UPDATE cntct SET cntct_active = false WHERE (cntct_id=pSourceCntctId);
21019
 
  
21020
 
  -- Clean up
21021
 
  DELETE FROM cntctsel WHERE (cntctsel_cntct_id=pSourceCntctId);
21022
 
 
21023
 
  RETURN true;
21024
 
END;
21025
 
$_$;
21026
 
 
21027
 
 
21028
 
ALTER FUNCTION public.cntctmerge(integer, integer, boolean) OWNER TO admin;
21029
 
 
21030
 
--
21031
 
--
21032
 
 
21033
 
CREATE FUNCTION cntctrestore(integer) RETURNS boolean
21034
 
    LANGUAGE plpgsql
21035
 
    AS $_$
21036
 
DECLARE
21037
 
  pCntctId ALIAS FOR $1;
21038
 
  _r RECORD;
21039
 
  _qry TEXT;
21040
 
 
21041
 
BEGIN
21042
 
  -- Validate
21043
 
  SELECT * INTO _r FROM cntctmrgd WHERE (cntctmrgd_cntct_id=pCntctId);
21044
 
  IF (NOT FOUND) THEN
21045
 
    RETURN false;
21046
 
  END IF;
21047
 
  
21048
 
  -- Gather the list of affected records
21049
 
  FOR _r IN
21050
 
    SELECT * FROM mrghist
21051
 
    WHERE (mrghist_cntct_id=pCntctId)
21052
 
  LOOP
21053
 
    -- Restore the old references
21054
 
    _qry := 'UPDATE ' || _r.mrghist_table ||
21055
 
            ' SET ' || _r.mrghist_cntct_col || '=' || pCntctId ||
21056
 
            ' WHERE (' || _r.mrghist_pkey_col || '=' || _r.mrghist_pkey_id || ');';
21057
 
    
21058
 
   EXECUTE _qry;
21059
 
         
21060
 
  END LOOP;
21061
 
 
21062
 
  -- Gather the list of affected fields
21063
 
  FOR _r IN
21064
 
    SELECT * FROM trgthist
21065
 
    WHERE (trgthist_src_cntct_id=pCntctId)
21066
 
  LOOP
21067
 
    -- Restore the old values
21068
 
    _qry := 'UPDATE cntct
21069
 
              SET ' || _r.trgthist_col || '=' || _r.trgthist_value ||
21070
 
            ' WHERE (cntct_id=' || _r.trgthist_trgt_cntct_id || ');';
21071
 
    
21072
 
   EXECUTE _qry;
21073
 
         
21074
 
  END LOOP;
21075
 
 
21076
 
  -- Clean up
21077
 
  UPDATE cntct SET cntct_active=true WHERE (cntct_id=pCntctId);
21078
 
  DELETE FROM mrghist WHERE (mrghist_cntct_id=pCntctId);
21079
 
  DELETE FROM trgthist WHERE (trgthist_src_cntct_id=pCntctId);
21080
 
  DELETE FROM cntctmrgd WHERE (cntctmrgd_cntct_id=pCntctId);
21081
 
 
21082
 
  RETURN true;
21083
 
 
21084
 
END;
21085
 
$_$;
21086
 
 
21087
 
 
21088
 
ALTER FUNCTION public.cntctrestore(integer) OWNER TO admin;
21089
 
 
21090
 
--
21091
 
--
21092
 
 
21093
 
CREATE FUNCTION cntctselect(integer, boolean) RETURNS boolean
21094
 
    LANGUAGE plpgsql
21095
 
    AS $_$
21096
 
DECLARE
21097
 
  pCntctId ALIAS FOR $1;
21098
 
  pTarget ALIAS FOR $2;
21099
 
 
21100
 
BEGIN
21101
 
  -- If target, delete any other targets
21102
 
  IF (pTarget) THEN
21103
 
    DELETE FROM cntctsel WHERE cntctsel_target;
21104
 
  END IF;
21105
 
  
21106
 
  -- Delete any previous selection of this contact
21107
 
  DELETE FROM cntctsel WHERE cntctsel_cntct_id=pCntctId;
21108
 
 
21109
 
  -- Add this contact in appropriate selection state
21110
 
  INSERT INTO cntctsel VALUES (pCntctId,pTarget);
21111
 
 
21112
 
  RETURN true;
21113
 
END;
21114
 
$_$;
21115
 
 
21116
 
 
21117
 
ALTER FUNCTION public.cntctselect(integer, boolean) OWNER TO admin;
21118
 
 
21119
 
--
21120
 
--
21121
 
 
21122
 
CREATE FUNCTION cntctselectcol(integer, integer) RETURNS boolean
21123
 
    LANGUAGE plpgsql
21124
 
    AS $_$
21125
 
DECLARE
21126
 
  pCntctId ALIAS FOR $1;
21127
 
  pColNumber ALIAS FOR $2;
21128
 
 
21129
 
BEGIN
21130
 
 
21131
 
  IF (pColNumber = 2 OR pColNumber = 3) THEN
21132
 
    UPDATE cntctsel SET cntctsel_mrg_crmacct_id=false WHERE (cntctsel_mrg_crmacct_id AND cntctsel_cntct_id != pCntctId);
21133
 
    UPDATE cntctsel SET cntctsel_mrg_crmacct_id=true WHERE (cntctsel_cntct_id = pCntctId);
21134
 
    RETURN true;
21135
 
  ELSIF (pColNumber = 4) THEN
21136
 
    UPDATE cntctsel SET cntctsel_mrg_honorific=false WHERE (cntctsel_mrg_honorific AND cntctsel_cntct_id != pCntctId);
21137
 
    UPDATE cntctsel SET cntctsel_mrg_honorific=true WHERE (cntctsel_cntct_id = pCntctId);
21138
 
    RETURN true;
21139
 
  ELSIF (pColNumber = 5) THEN
21140
 
    UPDATE cntctsel SET cntctsel_mrg_first_name=false WHERE (cntctsel_mrg_first_name AND cntctsel_cntct_id != pCntctId);
21141
 
    UPDATE cntctsel SET cntctsel_mrg_first_name=true WHERE (cntctsel_cntct_id = pCntctId);
21142
 
    RETURN true;
21143
 
  ELSIF (pColNumber = 6) THEN
21144
 
    UPDATE cntctsel SET cntctsel_mrg_middle=false WHERE (cntctsel_mrg_middle AND cntctsel_cntct_id != pCntctId);
21145
 
    UPDATE cntctsel SET cntctsel_mrg_middle=true WHERE (cntctsel_cntct_id = pCntctId);
21146
 
    RETURN true;
21147
 
  ELSIF (pColNumber = 7) THEN
21148
 
    UPDATE cntctsel SET cntctsel_mrg_last_name=false WHERE (cntctsel_mrg_last_name AND cntctsel_cntct_id != pCntctId);
21149
 
    UPDATE cntctsel SET cntctsel_mrg_last_name=true WHERE (cntctsel_cntct_id = pCntctId);
21150
 
    RETURN true;
21151
 
  ELSIF (pColNumber = 8) THEN
21152
 
    UPDATE cntctsel SET cntctsel_mrg_suffix=false WHERE (cntctsel_mrg_suffix AND cntctsel_cntct_id != pCntctId);
21153
 
    UPDATE cntctsel SET cntctsel_mrg_suffix=true WHERE (cntctsel_cntct_id = pCntctId);
21154
 
    RETURN true;
21155
 
  ELSIF (pColNumber = 9) THEN
21156
 
    UPDATE cntctsel SET cntctsel_mrg_initials=false WHERE (cntctsel_mrg_initials AND cntctsel_cntct_id != pCntctId);
21157
 
    UPDATE cntctsel SET cntctsel_mrg_initials=true WHERE (cntctsel_cntct_id = pCntctId);
21158
 
    RETURN true;
21159
 
  ELSIF (pColNumber = 10) THEN
21160
 
    UPDATE cntctsel SET cntctsel_mrg_phone=false WHERE (cntctsel_mrg_phone AND cntctsel_cntct_id != pCntctId);
21161
 
    UPDATE cntctsel SET cntctsel_mrg_phone=true WHERE (cntctsel_cntct_id = pCntctId);
21162
 
    RETURN true;
21163
 
  ELSIF (pColNumber = 11) THEN
21164
 
    UPDATE cntctsel SET cntctsel_mrg_phone2=false WHERE (cntctsel_mrg_phone2 AND cntctsel_cntct_id != pCntctId);
21165
 
    UPDATE cntctsel SET cntctsel_mrg_phone2=true WHERE (cntctsel_cntct_id = pCntctId);
21166
 
    RETURN true;
21167
 
  ELSIF (pColNumber = 12) THEN
21168
 
    UPDATE cntctsel SET cntctsel_mrg_fax=false WHERE (cntctsel_mrg_fax AND cntctsel_cntct_id != pCntctId);
21169
 
    UPDATE cntctsel SET cntctsel_mrg_fax=true WHERE (cntctsel_cntct_id = pCntctId);
21170
 
    RETURN true;
21171
 
  ELSIF (pColNumber = 13) THEN
21172
 
    UPDATE cntctsel SET cntctsel_mrg_email=false WHERE (cntctsel_mrg_email AND cntctsel_cntct_id != pCntctId);
21173
 
    UPDATE cntctsel SET cntctsel_mrg_email=true WHERE (cntctsel_cntct_id = pCntctId);
21174
 
    RETURN true;
21175
 
  ELSIF (pColNumber = 14) THEN
21176
 
    UPDATE cntctsel SET cntctsel_mrg_webaddr=false WHERE (cntctsel_mrg_webaddr AND cntctsel_cntct_id != pCntctId);
21177
 
    UPDATE cntctsel SET cntctsel_mrg_webaddr=true WHERE (cntctsel_cntct_id = pCntctId);
21178
 
    RETURN true;
21179
 
  ELSIF (pColNumber = 15) THEN
21180
 
    UPDATE cntctsel SET cntctsel_mrg_title=false WHERE (cntctsel_mrg_title AND cntctsel_cntct_id != pCntctId);
21181
 
    UPDATE cntctsel SET cntctsel_mrg_title=true WHERE (cntctsel_cntct_id = pCntctId);
21182
 
    RETURN true;
21183
 
  ELSIF (pColNumber = 16) THEN
21184
 
    UPDATE cntctsel SET cntctsel_mrg_owner_username=false WHERE (cntctsel_mrg_owner_username AND cntctsel_cntct_id != pCntctId);
21185
 
    UPDATE cntctsel SET cntctsel_mrg_owner_username=true WHERE (cntctsel_cntct_id = pCntctId);
21186
 
    RETURN true;
21187
 
  ELSIF (pColNumber = 17) THEN
21188
 
    UPDATE cntctsel SET cntctsel_mrg_notes=false WHERE (cntctsel_mrg_notes AND cntctsel_cntct_id != pCntctId);
21189
 
    UPDATE cntctsel SET cntctsel_mrg_notes=true WHERE (cntctsel_cntct_id = pCntctId);
21190
 
    RETURN true;
21191
 
  ELSIF (pColNumber >= 18) THEN
21192
 
    UPDATE cntctsel SET cntctsel_mrg_addr_id=false WHERE (cntctsel_mrg_addr_id AND cntctsel_cntct_id != pCntctId);
21193
 
    UPDATE cntctsel SET cntctsel_mrg_addr_id=true WHERE (cntctsel_cntct_id = pCntctId);
21194
 
    RETURN true;
21195
 
  END IF;
21196
 
 
21197
 
  RETURN false;
21198
 
END;
21199
 
$_$;
21200
 
 
21201
 
 
21202
 
ALTER FUNCTION public.cntctselectcol(integer, integer) OWNER TO admin;
21203
 
 
21204
 
--
21205
 
--
21206
 
 
21207
 
CREATE FUNCTION cntctused(integer) RETURNS boolean
21208
 
    LANGUAGE plpgsql
21209
 
    AS $_$
21210
 
DECLARE
21211
 
  pCntctId ALIAS FOR $1;
21212
 
  _fk RECORD;
21213
 
  _r RECORD;
21214
 
  _seq INTEGER;
21215
 
  _col TEXT;
21216
 
  _qry TEXT;
21217
 
 
21218
 
BEGIN
21219
 
  -- Determine where this contact is used by analyzing foreign key linkages
21220
 
  -- but ignore child tables and those with impermanent relationships
21221
 
  FOR _fk IN
21222
 
    SELECT pg_namespace.nspname AS schemaname, con.relname AS tablename, conkey AS seq, conrelid AS class_id 
21223
 
    FROM pg_constraint, pg_class f, pg_class con, pg_namespace
21224
 
    WHERE confrelid=f.oid
21225
 
    AND conrelid=con.oid
21226
 
    AND f.relname = 'cntct'
21227
 
    AND con.relnamespace=pg_namespace.oid
21228
 
    AND con.relname NOT IN ('cntctaddr', 'cntctdata', 'cntcteml',
21229
 
                            'cohead',    'pohead',    'quhead',   'tohead',
21230
 
                            'cntctsel',  'cntctmrgd', 'mrghist',  'trgthist')
21231
 
  LOOP
21232
 
    -- Validate
21233
 
    IF (ARRAY_UPPER(_fk.seq,1) > 1) THEN
21234
 
      RAISE EXCEPTION 'Cannot check dependencies when the contact is one of multiple foreign key columns (%.%) [xtuple: fkeycheck, -1, %, %]',
21235
 
        _fk.nspname, _fk.relname, _fk.nspname, _fk.relname;
21236
 
    END IF;
21237
 
    
21238
 
    _seq := _fk.seq[1];
21239
 
 
21240
 
    -- Get the specific column name
21241
 
    SELECT attname INTO _col
21242
 
    FROM pg_attribute, pg_class
21243
 
    WHERE ((attrelid=pg_class.oid)
21244
 
    AND (pg_class.oid=_fk.class_id)
21245
 
    AND (attnum=_seq));
21246
 
 
21247
 
    -- See if there are dependencies
21248
 
    _qry := 'SELECT * 
21249
 
            FROM ' || _fk.schemaname || '.' || _fk.tablename || '
21250
 
            WHERE ('|| _col || '=' || pCntctId || ');';
21251
 
 
21252
 
    FOR _r IN 
21253
 
      EXECUTE _qry
21254
 
    LOOP
21255
 
      RETURN true;
21256
 
    END LOOP;
21257
 
         
21258
 
  END LOOP;
21259
 
 
21260
 
  RETURN false;
21261
 
 
21262
 
END;
21263
 
$_$;
21264
 
 
21265
 
 
21266
 
ALTER FUNCTION public.cntctused(integer) OWNER TO admin;
21267
 
 
21268
 
--
21269
 
--
21270
 
 
21271
 
CREATE FUNCTION coheadstatecolor(integer) RETURNS text
21272
 
    LANGUAGE plpgsql
21273
 
    AS $_$
21274
 
DECLARE
21275
 
  pCoheadId     ALIAS FOR $1;
21276
 
  _shipheadid   INTEGER;
21277
 
  _result       TEXT := '';
21278
 
 
21279
 
BEGIN
21280
 
  
21281
 
  IF (pCoheadid IS NULL) THEN
21282
 
    RAISE EXCEPTION 'Customer Id is required.';
21283
 
  END IF;
21284
 
  
21285
 
  SELECT 
21286
 
    shiphead_id INTO _shipheadid
21287
 
  FROM cohead
21288
 
    JOIN shiphead ON ((shiphead_order_id=cohead_id)
21289
 
                  AND (shiphead_order_type='SO'))
21290
 
    JOIN shipitem ON (shiphead_id=shipitem_shiphead_id)
21291
 
  WHERE ((cohead_id=pCoheadId)
21292
 
    AND (NOT shipitem_invoiced))
21293
 
  ORDER BY shiphead_id DESC
21294
 
  LIMIT 1;
21295
 
 
21296
 
  IF (FOUND) THEN
21297
 
    SELECT 
21298
 
      CASE 
21299
 
        WHEN ((shiphead_shipped) 
21300
 
         AND (COALESCE(shiphead_order_id,0) > 0) 
21301
 
         AND (SUM(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) <= 0)) THEN 
21302
 
           'altemphasis'
21303
 
        WHEN ((COALESCE(cobmisc_cohead_id,0) > 0)       
21304
 
         AND (SUM(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) > 0)) THEN 
21305
 
           'error' 
21306
 
        WHEN (NOT shiphead_shipped) THEN 
21307
 
          'emphasis' 
21308
 
       END INTO _result
21309
 
    FROM cohead
21310
 
      JOIN coitem ON (cohead_id=coitem_cohead_id)
21311
 
      JOIN shiphead ON ((shiphead_order_id=cohead_id)
21312
 
                    AND (shiphead_order_type='SO'))
21313
 
      JOIN shipitem ON (shiphead_id=shipitem_shiphead_id)
21314
 
      LEFT OUTER JOIN (SELECT DISTINCT cobmisc_cohead_id FROM cobmisc) AS cobmisc ON (cobmisc_cohead_id=cohead_id) 
21315
 
    WHERE (shiphead_id=_shipheadid)
21316
 
    GROUP BY shiphead_id,shiphead_shipped,shiphead_order_id,cobmisc_cohead_id
21317
 
    ORDER BY shiphead_id DESC;
21318
 
  ELSE
21319
 
    _result := '';
21320
 
  END IF;
21321
 
  
21322
 
  RETURN _result;
21323
 
  
21324
 
END;
21325
 
$_$;
21326
 
 
21327
 
 
21328
 
ALTER FUNCTION public.coheadstatecolor(integer) OWNER TO admin;
21329
 
 
21330
 
--
21331
 
--
21332
 
 
21333
 
CREATE FUNCTION compareversion(text, text DEFAULT split_part(version(), ' '::text, 2)) RETURNS integer
21334
 
    LANGUAGE plpgsql STABLE
21335
 
    AS $_$
21336
 
DECLARE
21337
 
  _leftVersion ALIAS FOR $1;
21338
 
  _rightVersion ALIAS FOR $2;
21339
 
  _leftMajor SMALLINT;
21340
 
  _leftMinor SMALLINT;
21341
 
  _leftPatch SMALLINT;
21342
 
  _rightMajor SMALLINT;
21343
 
  _rightMinor SMALLINT;
21344
 
  _rightPatch SMALLINT;
21345
 
  _returnCode SMALLINT;
21346
 
  DEBUG BOOLEAN := false;
21347
 
BEGIN
21348
 
 
21349
 
SELECT  substring(_leftVersion FROM $$(\d+)\.\d+\.\d+$$)::SMALLINT, 
21350
 
        substring(_leftVersion FROM $$\d+\.(\d+)\.\d+$$)::SMALLINT, 
21351
 
        substring(_leftVersion FROM $$\d+\.\d+\.(\d+)$$)::SMALLINT 
21352
 
        INTO _leftMajor, _leftMinor, _leftPatch;
21353
 
 
21354
 
IF (DEBUG)
21355
 
  THEN RAISE NOTICE 'Left Version --> % Major --> % Minor --> % Patch --> % ', _leftVersion, _leftMajor, _leftMinor, _leftPatch;
21356
 
END IF;
21357
 
 
21358
 
SELECT  substring(_rightVersion FROM $$(\d+)\.\d+\.\d+$$)::SMALLINT, 
21359
 
        substring(_rightVersion FROM $$\d+\.(\d+)\.\d+$$)::SMALLINT, 
21360
 
        substring(_rightVersion FROM $$\d+\.\d+\.(\d+)$$)::SMALLINT 
21361
 
        INTO _rightMajor, _rightMinor, _rightPatch;
21362
 
 
21363
 
IF (DEBUG)
21364
 
 THEN RAISE NOTICE 'Right Version --> % Major --> % Minor --> % Patch --> % ', _rightVersion, _rightMajor, _rightMinor, _rightPatch;
21365
 
END IF;
21366
 
 
21367
 
IF (_leftMajor > _rightMajor) THEN _returnCode := 1;
21368
 
ELSIF (_leftMajor < _rightMajor) THEN _returnCode := -1;
21369
 
ELSIF (_leftMajor = _rightMajor) THEN
21370
 
  -- if major is equal, check minor version
21371
 
  IF (_leftMinor > _rightMinor) THEN _returnCode := 1;
21372
 
  ELSIF (_leftMinor < _rightMinor) THEN _returnCode := -1;
21373
 
  ELSIF (_leftMinor = _rightMinor) THEN
21374
 
    -- if major and minor are equal, check patch version
21375
 
    IF (_leftPatch > _rightPatch) THEN _returnCode := 1;
21376
 
    ELSIF (_leftPatch < _rightPatch) THEN _returnCode := -1;
21377
 
    ELSIF (_leftPatch = _rightPatch) THEN _returnCode := 0;
21378
 
    END IF;
21379
 
  END IF;
21380
 
ELSE RAISE EXCEPTION 'One or more of the version parameters is invalid. Expected numerical Major.Minor.Patch version string. Left --> % Right --> %', _leftVersion, _rightVersion;
21381
 
END IF;
21382
 
 
21383
 
RETURN _returnCode;
21384
 
 
21385
 
END;
21386
 
$_$;
21387
 
 
21388
 
 
21389
 
ALTER FUNCTION public.compareversion(text, text) OWNER TO admin;
21390
 
 
21391
 
--
21392
 
--
21393
 
 
21394
 
CREATE FUNCTION concataggsfunc(text, text) RETURNS text
21395
 
    LANGUAGE plpgsql
21396
 
    AS $_$
21397
 
DECLARE
21398
 
  prevstate     ALIAS FOR $1;
21399
 
  newval        ALIAS FOR $2;
21400
 
BEGIN
21401
 
  RETURN prevstate || newval;
21402
 
END;
21403
 
$_$;
21404
 
 
21405
 
 
21406
 
ALTER FUNCTION public.concataggsfunc(text, text) OWNER TO admin;
21407
 
 
21408
 
--
21409
 
--
21410
 
 
21411
 
CREATE FUNCTION consolidatelocations(integer) RETURNS integer
21412
 
    LANGUAGE plpgsql
21413
 
    AS $_$
21414
 
DECLARE
21415
 
  pItemsiteid ALIAS FOR $1;
21416
 
  _r RECORD;
21417
 
 
21418
 
BEGIN
21419
 
 
21420
 
  UPDATE itemloc
21421
 
  SET itemloc_consolflag = TRUE
21422
 
  WHERE (itemloc_itemsite_id=pItemsiteid);
21423
 
 
21424
 
  FOR _r IN SELECT itemloc_location_id, SUM(itemloc_qty) AS qty
21425
 
            FROM itemloc
21426
 
            WHERE (itemloc_itemsite_id=pItemsiteid)
21427
 
            GROUP BY itemloc_location_id LOOP
21428
 
    INSERT INTO itemloc
21429
 
    ( itemloc_itemsite_id, itemloc_location_id,
21430
 
      itemloc_expiration, itemloc_qty, itemloc_consolflag )
21431
 
    VALUES
21432
 
    ( pItemsiteid, _r.itemloc_location_id,
21433
 
      endOfTime(), _r.qty, FALSE );
21434
 
  END LOOP;
21435
 
 
21436
 
  DELETE FROM itemloc
21437
 
  WHERE ( (itemloc_itemsite_id=pItemsiteid)
21438
 
   AND (itemloc_consolflag) );
21439
 
 
21440
 
  RETURN 1;
21441
 
 
21442
 
END;
21443
 
$_$;
21444
 
 
21445
 
 
21446
 
ALTER FUNCTION public.consolidatelocations(integer) OWNER TO admin;
21447
 
 
21448
 
--
21449
 
--
21450
 
 
21451
 
CREATE FUNCTION convertcustomertoprospect(integer) RETURNS integer
21452
 
    LANGUAGE plpgsql
21453
 
    AS $_$
21454
 
DECLARE
21455
 
  pCustId     ALIAS FOR $1;
21456
 
  _c          RECORD;
21457
 
BEGIN
21458
 
  SELECT * INTO _c
21459
 
  FROM custinfo
21460
 
  WHERE (cust_id=pCustId);
21461
 
 
21462
 
  INSERT INTO prospect (
21463
 
        prospect_id, prospect_active, prospect_number,
21464
 
        prospect_name, prospect_cntct_id, prospect_taxzone_id,
21465
 
        prospect_salesrep_id, prospect_warehous_id, prospect_comments
21466
 
  ) VALUES (
21467
 
       _c.cust_id, _c.cust_active, _c.cust_number,
21468
 
       _c.cust_name, _c.cust_cntct_id, _c.cust_taxzone_id,
21469
 
       CASE WHEN(_c.cust_salesrep_id > 0) THEN _c.cust_salesrep_id
21470
 
            ELSE NULL
21471
 
       END,
21472
 
       CASE WHEN(_c.cust_preferred_warehous_id > 0) THEN _c.cust_preferred_warehous_id
21473
 
            ELSE NULL
21474
 
       END,
21475
 
       _c.cust_comments);
21476
 
 
21477
 
  DELETE FROM custinfo WHERE (cust_id=pCustId);
21478
 
 
21479
 
  RETURN pCustId;
21480
 
END;
21481
 
$_$;
21482
 
 
21483
 
 
21484
 
ALTER FUNCTION public.convertcustomertoprospect(integer) OWNER TO admin;
21485
 
 
21486
 
--
21487
 
--
21488
 
 
21489
 
CREATE FUNCTION convertprospecttocustomer(integer) RETURNS integer
21490
 
    LANGUAGE plpgsql
21491
 
    AS $_$
21492
 
BEGIN
21493
 
  RETURN convertProspectToCustomer($1, FALSE);
21494
 
END;
21495
 
$_$;
21496
 
 
21497
 
 
21498
 
ALTER FUNCTION public.convertprospecttocustomer(integer) OWNER TO admin;
21499
 
 
21500
 
--
21501
 
--
21502
 
 
21503
 
CREATE FUNCTION convertprospecttocustomer(integer, boolean) RETURNS integer
21504
 
    LANGUAGE plpgsql
21505
 
    AS $_$
21506
 
DECLARE
21507
 
  pProspectId ALIAS FOR $1;
21508
 
  pdoquotes   ALIAS FOR $2;
21509
 
  _p          RECORD;
21510
 
  _q          RECORD;
21511
 
 
21512
 
BEGIN
21513
 
  SELECT * INTO _p
21514
 
  FROM prospect
21515
 
  WHERE (prospect_id=pProspectId);
21516
 
 
21517
 
  IF (EXISTS(SELECT cust_id FROM custinfo WHERE cust_id=pProspectId)) THEN
21518
 
    RAISE EXCEPTION '[xtuple: convertProspectToCustomer, -10]';
21519
 
  END IF;
21520
 
 
21521
 
  INSERT INTO custinfo (
21522
 
        cust_id, cust_active, cust_number,
21523
 
        cust_name, cust_cntct_id, cust_taxzone_id,
21524
 
        cust_comments, cust_creditstatus,
21525
 
        cust_salesrep_id, cust_preferred_warehous_id,
21526
 
        cust_terms_id,
21527
 
        cust_custtype_id, cust_shipform_id,
21528
 
        cust_shipvia, cust_balmethod,
21529
 
        cust_ffshipto, cust_backorder,
21530
 
        cust_partialship, cust_creditlmt,
21531
 
        cust_creditrating, cust_commprcnt,
21532
 
        cust_discntprcnt, cust_blanketpos,
21533
 
        cust_shipchrg_id, cust_ffbillto,
21534
 
        cust_usespos, cust_emaildelivery,
21535
 
        cust_autoupdatestatus,cust_autoholdorders,
21536
 
        cust_soemaildelivery) 
21537
 
  SELECT
21538
 
      _p.prospect_id, _p.prospect_active, _p.prospect_number,
21539
 
      _p.prospect_name, _p.prospect_cntct_id, _p.prospect_taxzone_id,
21540
 
      _p.prospect_comments, 'G',
21541
 
      COALESCE(_p.prospect_salesrep_id, salesrep_id),
21542
 
      COALESCE(_p.prospect_warehous_id, -1),
21543
 
      FetchMetricValue('DefaultTerms'),
21544
 
      FetchMetricValue('DefaultCustType'),
21545
 
      FetchMetricValue('DefaultShipFormId'),
21546
 
      COALESCE(FetchMetricValue('DefaultShipViaId'),-1),
21547
 
      FetchMetricText('DefaultBalanceMethod'),
21548
 
      FetchMetricBool('DefaultFreeFormShiptos'),
21549
 
      FetchMetricBool('DefaultBackOrders'),
21550
 
      FetchMetricBool('DefaultPartialShipments'),
21551
 
      FetchMetricValue('SOCreditLimit'),
21552
 
      FetchMetricText('SOCreditRate'),
21553
 
      salesrep_commission,
21554
 
      0, false, -1,false,false,false,false,
21555
 
      false, false
21556
 
  FROM salesrep WHERE (salesrep_id=FetchMetricValue('DefaultSalesRep'));
21557
 
 
21558
 
  DELETE FROM prospect WHERE (prospect_id=pprospectId);
21559
 
 
21560
 
  IF (pdoquotes) THEN
21561
 
    BEGIN
21562
 
      FOR _q IN SELECT quhead_number, convertQuote(quhead_id) AS err
21563
 
                  FROM quhead
21564
 
                 WHERE ((COALESCE(quhead_expire, endOfTime()) >= CURRENT_DATE)
21565
 
                    AND (quhead_cust_id=pProspectId)) LOOP
21566
 
        IF (_q.err < 0) THEN
21567
 
          RAISE NOTICE 'Quote % for % didn''t convert to a Sales Order [xtuple: convertQuote, %]',
21568
 
                       _q.quhead_number, _p.prospect_number, _q.err;
21569
 
        END IF;
21570
 
      END LOOP;
21571
 
    EXCEPTION WHEN OTHERS THEN
21572
 
      RAISE NOTICE 'Ignored errors convering quotes: % %', SQLSTATE, SQLERRM;
21573
 
    END;
21574
 
  END IF;
21575
 
 
21576
 
  RETURN pProspectId;
21577
 
END;
21578
 
$_$;
21579
 
 
21580
 
 
21581
 
ALTER FUNCTION public.convertprospecttocustomer(integer, boolean) OWNER TO admin;
21582
 
 
21583
 
--
21584
 
--
21585
 
 
21586
 
CREATE FUNCTION convertquote(integer) RETURNS integer
21587
 
    LANGUAGE plpgsql
21588
 
    AS $_$
21589
 
DECLARE
21590
 
  pQuheadid ALIAS FOR $1;
21591
 
  _qunumber TEXT;
21592
 
  _ponumber TEXT;
21593
 
  _soheadid INTEGER;
21594
 
  _soitemid INTEGER;
21595
 
  _orderid INTEGER;
21596
 
  _ordertype CHARACTER(1);
21597
 
  _creditstatus TEXT;
21598
 
  _usespos BOOLEAN := false;
21599
 
  _blanketpos BOOLEAN := true;
21600
 
  _showConvertedQuote BOOLEAN := false;
21601
 
  _prospectid   INTEGER;
21602
 
  _r RECORD;
21603
 
  _soNum TEXT;
21604
 
 
21605
 
BEGIN
21606
 
 
21607
 
  IF (SELECT COALESCE(quhead_expire, endOfTime()) < CURRENT_DATE
21608
 
        FROM quhead
21609
 
       WHERE(quhead_id=pQuheadid)) THEN
21610
 
    RETURN -6;
21611
 
  END IF;
21612
 
 
21613
 
  SELECT quitem_id INTO _r
21614
 
    FROM quitem LEFT OUTER JOIN itemsite ON (quitem_itemsite_id=itemsite_id)
21615
 
   WHERE ((itemsite_id IS NULL)
21616
 
     AND  (quitem_quhead_id=pQuheadid));
21617
 
  IF (FOUND) THEN
21618
 
    PERFORM postEvent('CannotConvertQuote', 'Q', quhead_id,
21619
 
                      quhead_warehous_id, quhead_number,
21620
 
                      NULL, NULL, NULL, NULL)
21621
 
    FROM quhead
21622
 
    WHERE (quhead_id=pQuheadid);
21623
 
 
21624
 
    RETURN -1;
21625
 
  END IF;
21626
 
 
21627
 
  SELECT cust_creditstatus, cust_usespos, cust_blanketpos
21628
 
    INTO _creditstatus, _usespos, _blanketpos
21629
 
  FROM quhead, custinfo
21630
 
  WHERE ((quhead_cust_id=cust_id)
21631
 
    AND  (quhead_id=pQuheadid));
21632
 
 
21633
 
  IF (NOT FOUND) THEN
21634
 
    SELECT prospect_id INTO _prospectid
21635
 
    FROM quhead, prospect
21636
 
    WHERE ((quhead_cust_id=prospect_id)
21637
 
      AND  (quhead_id=pQuheadid));
21638
 
    IF (NOT FOUND) THEN
21639
 
      RETURN -2;
21640
 
    ELSE
21641
 
      RETURN -3;
21642
 
    END IF;
21643
 
  ELSIF (_creditstatus = 'H' AND NOT checkPrivilege('CreateSOForHoldCustomer')) THEN
21644
 
    RETURN -4;
21645
 
  ELSIF (_creditstatus = 'W' AND NOT checkPrivilege('CreateSOForWarnCustomer')) THEN
21646
 
    RETURN -5;
21647
 
  END IF;
21648
 
 
21649
 
  IF (_usespos) THEN
21650
 
    SELECT quhead_number, COALESCE(quhead_custponumber, ''), cohead_id INTO _qunumber, _ponumber, _soheadid
21651
 
    FROM quhead LEFT OUTER JOIN cohead ON ( (cohead_cust_id=quhead_cust_id) AND
21652
 
                                            (UPPER(cohead_custponumber)=UPPER(quhead_custponumber)) )
21653
 
    WHERE (quhead_id=pQuheadid);
21654
 
    IF (_ponumber = '') THEN
21655
 
      RAISE EXCEPTION 'Customer PO required for Quote % [xtuple: convertQuote, -7, %]',
21656
 
                      _qunumber, _qunumber;
21657
 
    END IF;
21658
 
  
21659
 
    IF ( (NOT _blanketpos) AND (_soheadid IS NOT NULL) ) THEN
21660
 
      RAISE EXCEPTION 'Duplicate Customer PO % for Quote % [xtuple: convertQuote, -8, %, %]',
21661
 
                      _ponumber, _qunumber,
21662
 
                      _ponumber, _qunumber;
21663
 
    END IF;
21664
 
  END IF;
21665
 
  
21666
 
  PERFORM quhead_number, cohead_id 
21667
 
  FROM quhead, cohead 
21668
 
  WHERE quhead_id = pQuheadid
21669
 
  AND cohead_number = quhead_number;
21670
 
 
21671
 
  IF (FOUND) THEN
21672
 
    SELECT fetchSoNumber() INTO _soNum;
21673
 
  ELSE
21674
 
    SELECT quhead_number INTO _soNum
21675
 
    FROM quhead
21676
 
    WHERE quhead_id = pQuheadid;
21677
 
  END IF;
21678
 
 
21679
 
  SELECT NEXTVAL('cohead_cohead_id_seq') INTO _soheadid;
21680
 
  INSERT INTO cohead
21681
 
  ( cohead_id, cohead_number, cohead_cust_id,
21682
 
    cohead_orderdate, cohead_packdate,
21683
 
    cohead_custponumber, cohead_warehous_id,
21684
 
    cohead_billtoname, cohead_billtoaddress1,
21685
 
    cohead_billtoaddress2, cohead_billtoaddress3,
21686
 
    cohead_billtocity, cohead_billtostate, cohead_billtozipcode,
21687
 
    cohead_billtocountry,
21688
 
    cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1,
21689
 
    cohead_shiptoaddress2, cohead_shiptoaddress3,
21690
 
    cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode,
21691
 
    cohead_shiptocountry,
21692
 
    cohead_salesrep_id, cohead_commission,
21693
 
    cohead_terms_id, cohead_shipchrg_id, cohead_shipform_id,
21694
 
    cohead_fob, cohead_shipvia,
21695
 
    cohead_ordercomments, cohead_shipcomments,
21696
 
    cohead_freight, cohead_misc, cohead_misc_accnt_id, cohead_misc_descrip,
21697
 
    cohead_holdtype, cohead_wasquote, cohead_quote_number, cohead_prj_id,
21698
 
    cohead_curr_id, cohead_taxzone_id, cohead_taxtype_id,
21699
 
    cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name,
21700
 
    cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix,
21701
 
    cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, 
21702
 
    cohead_shipto_cntct_email,
21703
 
    cohead_billto_cntct_id, cohead_billto_cntct_honorific,
21704
 
    cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, 
21705
 
    cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, 
21706
 
    cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_ophead_id,
21707
 
    cohead_calcfreight, cohead_saletype_id, cohead_shipzone_id )
21708
 
  SELECT _soheadid, _soNum, quhead_cust_id,
21709
 
         CURRENT_DATE, quhead_packdate,
21710
 
         quhead_custponumber, quhead_warehous_id,
21711
 
         quhead_billtoname, quhead_billtoaddress1,
21712
 
         quhead_billtoaddress2, quhead_billtoaddress3,
21713
 
         quhead_billtocity, quhead_billtostate, quhead_billtozip,
21714
 
         quhead_billtocountry,
21715
 
         quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1,
21716
 
         quhead_shiptoaddress2, quhead_shiptoaddress3,
21717
 
         quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode,
21718
 
         quhead_shiptocountry,
21719
 
         quhead_salesrep_id, quhead_commission,
21720
 
         quhead_terms_id, cust_shipchrg_id, cust_shipform_id,
21721
 
         quhead_fob, quhead_shipvia,
21722
 
         quhead_ordercomments, quhead_shipcomments,
21723
 
         quhead_freight, quhead_misc, quhead_misc_accnt_id, quhead_misc_descrip,
21724
 
         'N', TRUE, quhead_number, quhead_prj_id,
21725
 
         quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id,
21726
 
         quhead_shipto_cntct_id, quhead_shipto_cntct_honorific,
21727
 
         quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name,
21728
 
         quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title,
21729
 
         quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id,
21730
 
         quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle,
21731
 
         quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone,
21732
 
         quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email, quhead_ophead_id,
21733
 
         quhead_calcfreight, quhead_saletype_id, quhead_shipzone_id
21734
 
  FROM quhead JOIN custinfo ON (cust_id=quhead_cust_id)
21735
 
  WHERE (quhead_id=pQuheadid);
21736
 
 
21737
 
  -- Move Documents
21738
 
  UPDATE url SET url_source_id = _soheadid,
21739
 
                 url_source = 'S'
21740
 
  WHERE ((url_source='Q') AND (url_source_id = pQuheadid));
21741
 
 
21742
 
  UPDATE imageass SET imageass_source_id = _soheadid,
21743
 
                      imageass_source = 'S'
21744
 
  WHERE ((imageass_source='Q') AND (imageass_source_id = pQuheadid));
21745
 
 
21746
 
  UPDATE docass SET docass_source_id = _soheadid,
21747
 
                    docass_source_type = 'S'
21748
 
  WHERE ((docass_source_type='Q') AND (docass_source_id = pQuheadid));
21749
 
 
21750
 
  -- Move Email
21751
 
  IF (fetchMetricBool('EnableBatchManager')) THEN
21752
 
    UPDATE xtbatch.emlassc SET emlassc_type='S',
21753
 
                               emlassc_assc_id=_soheadid
21754
 
    WHERE ((emlassc_type='Q') AND (emlassc_assc_id=pQuheadid));
21755
 
  END IF;
21756
 
 
21757
 
  -- Copy Characteristics
21758
 
  INSERT INTO charass
21759
 
        (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price)
21760
 
  SELECT 'SO', _soheadid, charass_char_id, charass_value, charass_default, charass_price
21761
 
    FROM charass
21762
 
   WHERE ((charass_target_type='QU')
21763
 
     AND  (charass_target_id=pQuheadid));
21764
 
 
21765
 
  -- Copy Comments
21766
 
  INSERT INTO comment
21767
 
  ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text, comment_public )
21768
 
  SELECT comment_cmnttype_id, 'S', _soheadid, comment_date, comment_user, ('Quote-' || comment_text), comment_public
21769
 
  FROM comment
21770
 
  WHERE ( (comment_source='Q')
21771
 
    AND   (comment_source_id=pQuheadid) );
21772
 
 
21773
 
  FOR _r IN SELECT quitem.*,
21774
 
                   quhead_number, quhead_prj_id, quhead_saletype_id,
21775
 
                   itemsite_item_id, itemsite_leadtime,
21776
 
                   itemsite_createsopo, itemsite_createsopr,
21777
 
                   item_type, COALESCE(quitem_itemsrc_id, itemsrc_id, -1) AS itemsrcid
21778
 
            FROM quhead JOIN quitem ON (quitem_quhead_id=quhead_id)
21779
 
                        JOIN itemsite ON (itemsite_id=quitem_itemsite_id)
21780
 
                        JOIN item ON (item_id=itemsite_item_id)
21781
 
                        LEFT OUTER JOIN itemsrc ON ( (itemsrc_item_id=item_id) AND
21782
 
                                                     (itemsrc_default) )
21783
 
            WHERE (quhead_id=pQuheadid)
21784
 
            ORDER BY quitem_linenumber LOOP
21785
 
 
21786
 
    SELECT NEXTVAL('coitem_coitem_id_seq') INTO _soitemid;
21787
 
 
21788
 
    INSERT INTO coitem
21789
 
    ( coitem_id, coitem_cohead_id, coitem_linenumber, coitem_itemsite_id,
21790
 
      coitem_status, coitem_scheddate, coitem_promdate,
21791
 
      coitem_price, coitem_custprice, 
21792
 
      coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned,
21793
 
      coitem_qty_uom_id, coitem_qty_invuomratio,
21794
 
      coitem_price_uom_id, coitem_price_invuomratio,
21795
 
      coitem_unitcost, coitem_prcost,
21796
 
      coitem_custpn, coitem_memo, coitem_taxtype_id, coitem_order_id )
21797
 
    VALUES
21798
 
    ( _soitemid, _soheadid, _r.quitem_linenumber, _r.quitem_itemsite_id,
21799
 
      'O', _r.quitem_scheddate, _r.quitem_promdate,
21800
 
      _r.quitem_price, _r.quitem_custprice,
21801
 
      _r.quitem_qtyord, 0, 0,
21802
 
      _r.quitem_qty_uom_id, _r.quitem_qty_invuomratio,
21803
 
      _r.quitem_price_uom_id, _r.quitem_price_invuomratio,
21804
 
      stdcost(_r.itemsite_item_id), _r.quitem_prcost,
21805
 
      _r.quitem_custpn, _r.quitem_memo, _r.quitem_taxtype_id, -1 );
21806
 
 
21807
 
    IF (fetchMetricBool('enablextcommissionission')) THEN
21808
 
      PERFORM xtcommission.getSalesReps(quhead_cust_id, quhead_shipto_id,
21809
 
                                        _r.itemsite_item_id, _r.quhead_saletype_id,
21810
 
                                        _r.quitem_price, _r.quitem_custprice,
21811
 
                                        _soitemid, 'SalesItem')
21812
 
      FROM quhead
21813
 
      WHERE (quhead_id=pQuheadid);
21814
 
    END IF;
21815
 
 
21816
 
    -- Copy Characteristics
21817
 
    INSERT INTO charass
21818
 
          (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price)
21819
 
    SELECT 'SI', _soitemid, charass_char_id, charass_value, charass_default, charass_price
21820
 
      FROM charass
21821
 
     WHERE ((charass_target_type='QI')
21822
 
       AND  (charass_target_id=_r.quitem_id));
21823
 
 
21824
 
    -- Copy Comments
21825
 
    INSERT INTO comment
21826
 
    ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text )
21827
 
    SELECT comment_cmnttype_id, 'SI', _soitemid, comment_date, comment_user, ('Quote-' || comment_text)
21828
 
    FROM comment
21829
 
    WHERE ( (comment_source='QI')
21830
 
      AND   (comment_source_id=_r.quitem_id) );
21831
 
 
21832
 
    _orderid := -1;
21833
 
    _ordertype := '';
21834
 
    IF (_r.quitem_createorder) THEN
21835
 
 
21836
 
      IF (_r.item_type IN ('M')) THEN
21837
 
        SELECT createWo( CAST(_soNum AS INTEGER), supply.itemsite_id, 1,
21838
 
                         (_r.quitem_qtyord * _r.quitem_qty_invuomratio),
21839
 
                         _r.itemsite_leadtime, _r.quitem_scheddate, _r.quitem_memo,
21840
 
                         'S', _soitemid, _r.quhead_prj_id ) INTO _orderId
21841
 
        FROM itemsite sold, itemsite supply
21842
 
        WHERE ((sold.itemsite_item_id=supply.itemsite_item_id)
21843
 
         AND (supply.itemsite_warehous_id=_r.quitem_order_warehous_id)
21844
 
         AND (sold.itemsite_id=_r.quitem_itemsite_id) );
21845
 
        _orderType := 'W';
21846
 
 
21847
 
        INSERT INTO charass
21848
 
              (charass_target_type, charass_target_id, charass_char_id, charass_value)
21849
 
        SELECT 'W', _orderId, charass_char_id, charass_value
21850
 
          FROM charass
21851
 
         WHERE ((charass_target_type='QI')
21852
 
           AND  (charass_target_id=_r.quitem_id));
21853
 
 
21854
 
      ELSIF ( (_r.item_type IN ('P', 'O')) AND (_r.itemsite_createsopr) ) THEN
21855
 
        SELECT createPr( CAST(_soNum AS INTEGER), _r.quitem_itemsite_id,
21856
 
                         (_r.quitem_qtyord * _r.quitem_qty_invuomratio),
21857
 
                         _r.quitem_scheddate, '', 'S', _soitemid ) INTO _orderId;
21858
 
        _orderType := 'R';
21859
 
        UPDATE pr SET pr_prj_id=_r.quhead_prj_id WHERE pr_id=_orderId;
21860
 
      ELSIF ( (_r.item_type IN ('P', 'O')) AND (_r.itemsite_createsopo) ) THEN
21861
 
        IF (_r.quitem_prcost=0) THEN
21862
 
          SELECT createPurchaseToSale(_soitemid, _r.itemsrcid, _r.quitem_dropship) INTO _orderId;
21863
 
        ELSE
21864
 
          SELECT createPurchaseToSale(_soitemid, _r.itemsrcid, _r.quitem_dropship, _r.quitem_prcost) INTO _orderId;
21865
 
        END IF;
21866
 
        _orderType := 'P';
21867
 
      END IF;
21868
 
 
21869
 
      UPDATE coitem SET coitem_order_type=_ordertype, coitem_order_id=_orderid
21870
 
      WHERE (coitem_id=_soitemid);
21871
 
 
21872
 
    END IF;
21873
 
 
21874
 
  END LOOP;
21875
 
 
21876
 
  SELECT metric_value INTO _showConvertedQuote
21877
 
  FROM metric WHERE metric_name = 'ShowQuotesAfterSO';
21878
 
 
21879
 
  IF (_showConvertedQuote) THEN
21880
 
    UPDATE quhead
21881
 
    SET quhead_status= 'C'
21882
 
    WHERE (quhead_id = pQuheadid);
21883
 
  ELSE
21884
 
  PERFORM deleteQuote(pQuheadid);
21885
 
  END IF;
21886
 
 
21887
 
  RETURN _soheadid;
21888
 
 
21889
 
END;
21890
 
$_$;
21891
 
 
21892
 
 
21893
 
ALTER FUNCTION public.convertquote(integer) OWNER TO admin;
21894
 
 
21895
 
--
21896
 
--
21897
 
 
21898
 
CREATE FUNCTION convertquotetoinvoice(integer) RETURNS integer
21899
 
    LANGUAGE plpgsql
21900
 
    AS $_$
21901
 
DECLARE
21902
 
  pQuheadid ALIAS FOR $1;
21903
 
  _qunumber TEXT;
21904
 
  _ponumber TEXT;
21905
 
  _iheadid INTEGER;
21906
 
  _iitemid INTEGER;
21907
 
  _orderid INTEGER;
21908
 
  _ordertype CHARACTER(1);
21909
 
  _creditstatus TEXT;
21910
 
  _usespos BOOLEAN := false;
21911
 
  _blanketpos BOOLEAN := true;
21912
 
  _showConvertedQuote BOOLEAN := false;
21913
 
  _prospectid   INTEGER;
21914
 
  _r RECORD;
21915
 
  _inNum TEXT;
21916
 
 
21917
 
BEGIN
21918
 
 
21919
 
  IF (SELECT COALESCE(quhead_expire, endOfTime()) < CURRENT_DATE
21920
 
        FROM quhead
21921
 
       WHERE(quhead_id=pQuheadid)) THEN
21922
 
    RETURN -6;
21923
 
  END IF;
21924
 
 
21925
 
  SELECT quitem_id INTO _r
21926
 
    FROM quitem LEFT OUTER JOIN itemsite ON (quitem_itemsite_id=itemsite_id)
21927
 
   WHERE ((itemsite_id IS NULL)
21928
 
     AND  (quitem_quhead_id=pQuheadid));
21929
 
  IF (FOUND) THEN
21930
 
    PERFORM postEvent('CannotConvertQuote', 'Q', quhead_id,
21931
 
                      quhead_warehous_id, quhead_number,
21932
 
                      NULL, NULL, NULL, NULL)
21933
 
    FROM quhead
21934
 
    WHERE (quhead_id=pQuheadid);
21935
 
 
21936
 
    RETURN -1;
21937
 
  END IF;
21938
 
 
21939
 
 
21940
 
  SELECT cust_creditstatus, cust_usespos, cust_blanketpos
21941
 
    INTO _creditstatus, _usespos, _blanketpos
21942
 
  FROM quhead, custinfo
21943
 
  WHERE ((quhead_cust_id=cust_id)
21944
 
    AND  (quhead_id=pQuheadid));
21945
 
 
21946
 
 
21947
 
  IF (NOT FOUND) THEN
21948
 
    SELECT prospect_id INTO _prospectid
21949
 
    FROM quhead, prospect
21950
 
    WHERE ((quhead_cust_id=prospect_id)
21951
 
      AND  (quhead_id=pQuheadid));
21952
 
    IF (NOT FOUND) THEN
21953
 
      RETURN -2;
21954
 
    ELSE
21955
 
      RETURN -3;
21956
 
    END IF;
21957
 
  ELSIF (_creditstatus = 'H' AND NOT hasPriv('CreateSOForHoldCustomer')) THEN
21958
 
    RETURN -4;
21959
 
  ELSIF (_creditstatus = 'W' AND NOT hasPriv('CreateSOForWarnCustomer')) THEN
21960
 
    RETURN -5;
21961
 
  END IF;
21962
 
 
21963
 
  IF (_usespos) THEN
21964
 
    SELECT quhead_number, COALESCE(quhead_custponumber, ''), invchead_id INTO _qunumber, _ponumber, _iheadid
21965
 
    FROM quhead LEFT OUTER JOIN invchead ON ( (invchead_cust_id=quhead_cust_id) AND
21966
 
                                              (UPPER(invchead_ponumber)=UPPER(quhead_custponumber)) )
21967
 
    WHERE (quhead_id=pQuheadid);
21968
 
    IF (_ponumber = '') THEN
21969
 
      RAISE EXCEPTION 'Customer PO required for Quote % [xtuple: convertQuote, -7, %]',
21970
 
                      _qunumber, _qunumber;
21971
 
    END IF;
21972
 
  
21973
 
    IF ( (NOT _blanketpos) AND (_iheadid IS NOT NULL) ) THEN
21974
 
      RAISE EXCEPTION 'Duplicate Customer PO % for Quote % [xtuple: convertQuote, -8, %, %]',
21975
 
                      _ponumber, _qunumber,
21976
 
                      _ponumber, _qunumber;
21977
 
    END IF;
21978
 
  END IF;
21979
 
  
21980
 
 
21981
 
  IF (_usespos) THEN
21982
 
    SELECT quhead_number INTO _qunumber
21983
 
    FROM quhead
21984
 
    WHERE (quhead_id=pQuheadid)
21985
 
      AND (COALESCE(quhead_custponumber, '') = '');
21986
 
    IF (FOUND) THEN
21987
 
      RAISE EXCEPTION 'Customer PO required for Quote % [xtuple: convertQuote, -7, %]',
21988
 
                      _qunumber, _qunumber;
21989
 
    END IF;
21990
 
  END IF;
21991
 
  
21992
 
  IF ( (_usespos) AND (NOT _blanketpos) ) THEN
21993
 
    SELECT quhead_number, quhead_custponumber INTO _qunumber, _ponumber
21994
 
    FROM quhead JOIN invchead ON ( (invchead_cust_id=quhead_cust_id) AND
21995
 
                                   (UPPER(invchead_ponumber)=UPPER(quhead_custponumber)) )
21996
 
    WHERE (quhead_id=pQuheadid);
21997
 
    IF (FOUND) THEN
21998
 
      RAISE EXCEPTION 'Duplicate Customer PO % for Quote % [xtuple: convertQuote, -8, %, %]',
21999
 
                      _ponumber, _qunumber,
22000
 
                      _ponumber, _qunumber;
22001
 
    END IF;
22002
 
  END IF;
22003
 
  
22004
 
--Check to see if an invoice exists with the quote number
22005
 
  
22006
 
  PERFORM quhead_number, invchead_id 
22007
 
  FROM quhead, invchead 
22008
 
  WHERE quhead_id = pQuheadid
22009
 
  AND invchead_invcnumber = quhead_number;
22010
 
 
22011
 
 
22012
 
  IF (FOUND) THEN
22013
 
    SELECT fetchinvcnumber() INTO _inNum;
22014
 
  ELSE
22015
 
    SELECT quhead_number INTO _inNum
22016
 
    FROM quhead
22017
 
    WHERE quhead_id = pQuheadid;
22018
 
  END IF;
22019
 
 
22020
 
--Insert quote info into invoice tables
22021
 
 
22022
 
  SELECT NEXTVAL('invchead_invchead_id_seq') INTO _iheadid;
22023
 
  INSERT INTO invchead
22024
 
  ( invchead_ordernumber, invchead_shipdate, invchead_recurring,
22025
 
    invchead_id, invchead_invcnumber, invchead_cust_id,
22026
 
    invchead_orderdate, invchead_ponumber, 
22027
 
    invchead_billto_name, invchead_billto_address1,
22028
 
    invchead_billto_address2, invchead_billto_address3,
22029
 
    invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_country,
22030
 
    invchead_shipto_id, invchead_shipto_name, invchead_shipto_address1,
22031
 
    invchead_shipto_address2, invchead_shipto_address3,
22032
 
    invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_country, 
22033
 
    invchead_salesrep_id, invchead_commission,
22034
 
    invchead_terms_id, invchead_shipchrg_id, invchead_fob, invchead_shipvia,
22035
 
    invchead_notes, invchead_freight, 
22036
 
    invchead_misc_amount, invchead_misc_accnt_id, invchead_misc_descrip,
22037
 
    invchead_prj_id, invchead_curr_id, invchead_taxzone_id,
22038
 
    invchead_posted, invchead_printed, invchead_invcdate,
22039
 
    invchead_saletype_id, invchead_shipzone_id
22040
 
    --invchead_taxtype_id,
22041
 
    --invchead_shipto_cntct_id, invchead_shipto_cntct_honorific, invchead_shipto_cntct_first_name,
22042
 
    --invchead_shipto_cntct_middle, invchead_shipto_cntct_last_name, invchead_shipto_cntct_suffix,
22043
 
    --invchead_shipto_cntct_phone, invchead_shipto_cntct_title, invchead_shipto_cntct_fax, 
22044
 
    --invchead_shipto_cntct_email,
22045
 
    --invchead_billto_cntct_id, invchead_billto_cntct_honorific,
22046
 
    --invchead_billto_cntct_first_name, invchead_billto_cntct_middle, invchead_billto_cntct_last_name, 
22047
 
    --invchead_billto_cntct_suffix, invchead_billto_cntct_phone, invchead_billto_cntct_title, 
22048
 
    --invchead_billto_cntct_fax, invchead_billto_cntct_email, 
22049
 
    --invchead_ophead_id,
22050
 
    --invchead_calcfreight 
22051
 
    )
22052
 
  SELECT quhead_number, quhead_packdate, 'f',
22053
 
         _iheadid, _inNum, quhead_cust_id,
22054
 
         CURRENT_DATE, quhead_custponumber, 
22055
 
         quhead_billtoname, quhead_billtoaddress1,
22056
 
         quhead_billtoaddress2, quhead_billtoaddress3,
22057
 
         quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_billtocountry,
22058
 
         quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1,
22059
 
         quhead_shiptoaddress2, quhead_shiptoaddress3,
22060
 
         quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptocountry,
22061
 
         quhead_salesrep_id, quhead_commission,
22062
 
         quhead_terms_id, cust_shipchrg_id, quhead_fob, quhead_shipvia,
22063
 
         quhead_ordercomments,  quhead_freight,
22064
 
         quhead_misc, quhead_misc_accnt_id, quhead_misc_descrip,
22065
 
         quhead_prj_id, quhead_curr_id, quhead_taxzone_id,
22066
 
         'f','f',current_date,
22067
 
         quhead_saletype_id, quhead_shipzone_id
22068
 
         --quhead_shipto_cntct_id, quhead_shipto_cntct_honorific,
22069
 
         --quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name,
22070
 
         --quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title,
22071
 
         --quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id,
22072
 
         --quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle,
22073
 
         --quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone,
22074
 
         --quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email, quhead_ophead_id,
22075
 
         --quhead_calcfreight
22076
 
  FROM quhead JOIN custinfo ON (cust_id=quhead_cust_id)
22077
 
  WHERE (quhead_id=pQuheadid);
22078
 
 
22079
 
/*
22080
 
  UPDATE url SET url_source_id = _iheadid,
22081
 
                 url_source = 'I'
22082
 
  WHERE ((url_source='Q') AND (url_source_id = pQuheadid));
22083
 
 
22084
 
  UPDATE imageass SET imageass_source_id = _iheadid,
22085
 
                      imageass_source = 'I'
22086
 
  WHERE ((imageass_source='Q') AND (imageass_source_id = pQuheadid));
22087
 
 
22088
 
  UPDATE docass SET docass_source_id = _iheadid,
22089
 
                    docass_source_type = 'I'
22090
 
  WHERE ((docass_source_type='Q') AND (docass_source_id = pQuheadid));
22091
 
*/
22092
 
 
22093
 
 
22094
 
 
22095
 
/*  
22096
 
  INSERT INTO comment
22097
 
  ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text, comment_public )
22098
 
  SELECT comment_cmnttype_id, 'I', _iheadid, comment_date, comment_user, ('Quote-' || comment_text), comment_public
22099
 
  FROM comment
22100
 
  WHERE ( (comment_source='Q')
22101
 
    AND   (comment_source_id=pQuheadid) );
22102
 
*/
22103
 
 
22104
 
  FOR _r IN SELECT quitem.*,
22105
 
                   quhead_number, quhead_prj_id, quhead_saletype_id,
22106
 
                   itemsite_item_id, itemsite_leadtime,
22107
 
                   itemsite_createsopo, itemsite_createsopr,
22108
 
                   item_type, COALESCE(quitem_itemsrc_id, itemsrc_id, -1) AS itemsrcid
22109
 
            FROM quhead JOIN quitem ON (quitem_quhead_id=quhead_id)
22110
 
                        JOIN itemsite ON (itemsite_id=quitem_itemsite_id)
22111
 
                        JOIN item ON (item_id=itemsite_item_id)
22112
 
                        LEFT OUTER JOIN itemsrc ON ( (itemsrc_item_id=item_id) AND
22113
 
                                                     (itemsrc_default) )
22114
 
            WHERE (quhead_id=pQuheadid) LOOP
22115
 
 
22116
 
    SELECT NEXTVAL('invcitem_invcitem_id_seq') INTO _iitemid;
22117
 
 
22118
 
    INSERT INTO invcitem
22119
 
    ( invcitem_id, invcitem_invchead_id, invcitem_linenumber, 
22120
 
      invcitem_item_id,
22121
 
      invcitem_warehous_id,
22122
 
      --invcitem_status, 
22123
 
      --invcitem_scheddate, invcitem_promdate,
22124
 
      invcitem_price, invcitem_custprice, 
22125
 
      invcitem_ordered, invcitem_billed,
22126
 
      invcitem_qty_uom_id, invcitem_qty_invuomratio,
22127
 
      invcitem_price_uom_id, invcitem_price_invuomratio,
22128
 
      invcitem_custpn, invcitem_notes, invcitem_taxtype_id )
22129
 
    VALUES
22130
 
    ( _iitemid, _iheadid, _r.quitem_linenumber, 
22131
 
      (SELECT itemsite_item_id FROM itemsite WHERE itemsite_id = _r.quitem_itemsite_id),
22132
 
      (SELECT itemsite_warehous_id FROM itemsite WHERE itemsite_id = _r.quitem_itemsite_id),
22133
 
      --'O', 
22134
 
      --_r.quitem_scheddate, _r.quitem_promdate,
22135
 
      _r.quitem_price, _r.quitem_custprice,
22136
 
      _r.quitem_qtyord, _r.quitem_qtyord,
22137
 
      _r.quitem_qty_uom_id, _r.quitem_qty_invuomratio,
22138
 
      _r.quitem_price_uom_id, _r.quitem_price_invuomratio,
22139
 
      _r.quitem_custpn, _r.quitem_memo, _r.quitem_taxtype_id );
22140
 
 
22141
 
    IF (fetchMetricBool('enablextcommissionission')) THEN
22142
 
      PERFORM xtcommission.getSalesReps(quhead_cust_id, quhead_shipto_id,
22143
 
                                        _r.itemsite_item_id, _r.quhead_saletype_id,
22144
 
                                        _r.quitem_price, _r.quitem_custprice,
22145
 
                                        _iitemid, 'InvoiceItem')
22146
 
      FROM quhead
22147
 
      WHERE (quhead_id=pQuheadid);
22148
 
    END IF;
22149
 
 
22150
 
 
22151
 
/*
22152
 
    INSERT INTO charass
22153
 
          (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price)
22154
 
    SELECT 'SI', _iitemid, charass_char_id, charass_value, charass_default, charass_price
22155
 
      FROM charass
22156
 
     WHERE ((charass_target_type='QI')
22157
 
       AND  (charass_target_id=_r.quitem_id));
22158
 
*/
22159
 
 
22160
 
 
22161
 
 
22162
 
/*
22163
 
    INSERT INTO comment
22164
 
    ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text )
22165
 
    SELECT comment_cmnttype_id, 'SI', _iitemid, comment_date, comment_user, ('Quote-' || comment_text)
22166
 
    FROM comment
22167
 
    WHERE ( (comment_source='QI')
22168
 
      AND   (comment_source_id=_r.quitem_id) );
22169
 
*/
22170
 
 
22171
 
    _orderid := -1;
22172
 
    _ordertype := '';
22173
 
    IF (_r.quitem_createorder) THEN
22174
 
 
22175
 
      IF (_r.item_type IN ('M')) THEN
22176
 
        SELECT createWo( CAST(_r.quhead_number AS INTEGER), supply.itemsite_id, 1, (_r.quitem_qtyord * _r.quitem_qty_invuomratio),
22177
 
                         _r.itemsite_leadtime, _r.quitem_scheddate, _r.quitem_memo, 'Q', _iitemid, _r.quhead_prj_id ) INTO _orderId
22178
 
        FROM itemsite sold, itemsite supply
22179
 
        WHERE ((sold.itemsite_item_id=supply.itemsite_item_id)
22180
 
         AND (supply.itemsite_warehous_id=_r.quitem_order_warehous_id)
22181
 
         AND (sold.itemsite_id=_r.quitem_itemsite_id) );
22182
 
        _orderType := 'W';
22183
 
 
22184
 
        INSERT INTO charass
22185
 
              (charass_target_type, charass_target_id, charass_char_id, charass_value)
22186
 
        SELECT 'W', _orderId, charass_char_id, charass_value
22187
 
          FROM charass
22188
 
         WHERE ((charass_target_type='QI')
22189
 
           AND  (charass_target_id=_r.quitem_id));
22190
 
 
22191
 
      ELSIF ( (_r.item_type IN ('P', 'O')) AND (_r.itemsite_createsopr) ) THEN
22192
 
        SELECT createPr( CAST(_r.quhead_number AS INTEGER), _r.quitem_itemsite_id, (_r.quitem_qtyord * _r.quitem_qty_invuomratio),
22193
 
                         _r.quitem_scheddate, '', 'S', _iitemid ) INTO _orderId;
22194
 
        _orderType := 'R';
22195
 
        UPDATE pr SET pr_prj_id=_r.quhead_prj_id WHERE pr_id=_orderId;
22196
 
      ELSIF ( (_r.item_type IN ('P', 'O')) AND (_r.itemsite_createsopo) ) THEN
22197
 
        IF (_r.quitem_prcost=0) THEN
22198
 
            RAISE EXCEPTION 'Quote contains one or more dropship items that may not be converted from a Quote to an Invoice';
22199
 
        ELSE
22200
 
            RAISE EXCEPTION 'Quote contains one or more dropship items that may not be converted from a Quote to an Invoice';
22201
 
        END IF;
22202
 
        _orderType := 'P';
22203
 
      END IF;
22204
 
 
22205
 
 
22206
 
    END IF;
22207
 
 
22208
 
  END LOOP;
22209
 
 
22210
 
  SELECT metric_value INTO _showConvertedQuote
22211
 
  FROM metric WHERE metric_name = 'ShowQuotesAfterSO';
22212
 
 
22213
 
  IF (_showConvertedQuote) THEN
22214
 
    UPDATE quhead
22215
 
    SET quhead_status= 'C'
22216
 
    WHERE (quhead_id = pQuheadid);
22217
 
  ELSE
22218
 
     PERFORM deleteQuote(pQuheadid);
22219
 
  END IF;
22220
 
 
22221
 
  RETURN _iheadid;
22222
 
 
22223
 
END;
22224
 
$_$;
22225
 
 
22226
 
 
22227
 
ALTER FUNCTION public.convertquotetoinvoice(integer) OWNER TO admin;
22228
 
 
22229
 
--
22230
 
--
22231
 
 
22232
 
CREATE FUNCTION copybom(psitemid integer, ptitemid integer) RETURNS integer
22233
 
    LANGUAGE plpgsql
22234
 
    AS $$
22235
 
DECLARE
22236
 
  _result INTEGER;
22237
 
 
22238
 
BEGIN
22239
 
 
22240
 
  SELECT copyBOM (pSItemid, PTItemid, FALSE) into _result;
22241
 
 
22242
 
  RETURN _result;
22243
 
 
22244
 
END;
22245
 
$$;
22246
 
 
22247
 
 
22248
 
ALTER FUNCTION public.copybom(psitemid integer, ptitemid integer) OWNER TO admin;
22249
 
 
22250
 
--
22251
 
--
22252
 
 
22253
 
CREATE FUNCTION copybom(psitemid integer, ptitemid integer, pcopyusedat boolean) RETURNS integer
22254
 
    LANGUAGE plpgsql
22255
 
    AS $$
22256
 
DECLARE
22257
 
  _bh RECORD;
22258
 
  _bi RECORD;
22259
 
  _bomheadfound BOOLEAN := FALSE;
22260
 
  _bomheadid INTEGER;
22261
 
  _bomitemid INTEGER;
22262
 
  _bomworksetid INTEGER;
22263
 
  _temp INTEGER;
22264
 
  _schedatwooper BOOLEAN;
22265
 
  _booitemseqid INTEGER;
22266
 
 
22267
 
BEGIN
22268
 
 
22269
 
  SELECT * INTO _bh
22270
 
  FROM bomhead
22271
 
  WHERE ((bomhead_item_id=pSItemid)
22272
 
    AND  (bomhead_rev_id=getActiveRevID('BOM', pSItemid)));
22273
 
 
22274
 
    IF (FOUND) THEN
22275
 
      _bomheadfound := TRUE;
22276
 
    END IF;
22277
 
 
22278
 
  SELECT bomitem_id INTO _bomitemid
22279
 
  FROM bomitem
22280
 
  WHERE ((bomitem_parent_item_id=pSItemid)
22281
 
    AND  (bomitem_rev_id=getActiveRevID('BOM', pSItemid)))
22282
 
  LIMIT 1;
22283
 
 
22284
 
  IF (NOT FOUND) THEN
22285
 
    RETURN -2;
22286
 
  END IF;
22287
 
 
22288
 
  SELECT bomitem_id INTO _bomitemid
22289
 
  FROM bomitem
22290
 
  WHERE ((bomitem_parent_item_id=pTItemid)
22291
 
    AND  (bomitem_rev_id= -1))
22292
 
  LIMIT 1;
22293
 
 
22294
 
  IF (FOUND) THEN
22295
 
    RETURN -3;
22296
 
  END IF;
22297
 
 
22298
 
  IF ( SELECT (item_type IN ('M', 'F'))
22299
 
       FROM item
22300
 
       WHERE (item_id=pSItemid) ) THEN
22301
 
    SELECT indentedWhereUsed(pTItemid) INTO _bomworksetid;
22302
 
    SELECT bomwork_id INTO _temp
22303
 
    FROM bomwork
22304
 
    WHERE ( (bomwork_set_id=_bomworksetid)
22305
 
     AND (bomwork_item_id=pSItemid) )
22306
 
    LIMIT 1;
22307
 
    IF (FOUND) THEN
22308
 
      PERFORM deleteBOMWorkset(_bomworksetid);
22309
 
      RETURN -4;
22310
 
    END IF;
22311
 
    PERFORM deleteBOMWorkset(_bomworksetid);
22312
 
  END IF;
22313
 
 
22314
 
  SELECT bomhead_id INTO _bomheadid
22315
 
  FROM bomhead
22316
 
  WHERE ((bomhead_item_id=pTItemid)
22317
 
    AND  (bomhead_rev_id= -1));
22318
 
 
22319
 
  IF (NOT FOUND) THEN
22320
 
    IF (_bomheadfound) THEN
22321
 
      INSERT INTO bomhead
22322
 
      ( bomhead_item_id, bomhead_serial, bomhead_docnum,
22323
 
        bomhead_batchsize, bomhead_requiredqtyper )
22324
 
      VALUES
22325
 
      ( pTItemid, _bh.bomhead_serial, _bh.bomhead_docnum,
22326
 
        _bh.bomhead_batchsize, _bh.bomhead_requiredqtyper );
22327
 
    END IF;
22328
 
  END IF;
22329
 
 
22330
 
  FOR _bi IN SELECT bomitem.*
22331
 
             FROM bomitem(pSItemid) 
22332
 
             WHERE (bomitem_expires>CURRENT_DATE) LOOP
22333
 
 
22334
 
    SELECT NEXTVAL('bomitem_bomitem_id_seq') INTO _bomitemid;
22335
 
 
22336
 
    IF (pCopyUsedAt) THEN
22337
 
      _schedatwooper := _bi.bomitem_schedatwooper;
22338
 
      _booitemseqid := _bi.bomitem_booitem_seq_id;
22339
 
    ELSE
22340
 
      _schedatwooper := FALSE;
22341
 
      _booitemseqid := -1;
22342
 
    END IF;
22343
 
 
22344
 
    INSERT INTO bomitem
22345
 
    ( bomitem_id, bomitem_parent_item_id, bomitem_seqnumber, bomitem_item_id,
22346
 
      bomitem_uom_id, bomitem_qtyfxd, bomitem_qtyper, bomitem_scrap, bomitem_schedatwooper,
22347
 
      bomitem_booitem_seq_id,
22348
 
      bomitem_effective, bomitem_expires, bomitem_ecn,
22349
 
      bomitem_createwo, bomitem_issuemethod, bomitem_moddate, bomitem_subtype,
22350
 
      bomitem_notes, bomitem_ref )
22351
 
    VALUES
22352
 
    ( _bomitemid, pTItemid, _bi.bomitem_seqnumber, _bi.bomitem_item_id,
22353
 
      _bi.bomitem_uom_id, _bi.bomitem_qtyfxd, _bi.bomitem_qtyper, _bi.bomitem_scrap, _schedatwooper,
22354
 
      _booitemseqid,
22355
 
      CURRENT_DATE, _bi.bomitem_expires, _bi.bomitem_ecn,
22356
 
      _bi.bomitem_createwo, _bi.bomitem_issuemethod, CURRENT_DATE, _bi.bomitem_subtype,
22357
 
      _bi.bomitem_notes, _bi.bomitem_ref );
22358
 
 
22359
 
    INSERT INTO bomitemsub
22360
 
    ( bomitemsub_bomitem_id, bomitemsub_item_id,
22361
 
      bomitemsub_uomratio, bomitemsub_rank )
22362
 
    SELECT _bomitemid, bomitemsub_item_id,
22363
 
           bomitemsub_uomratio, bomitemsub_rank
22364
 
    FROM bomitemsub
22365
 
    WHERE (bomitemsub_bomitem_id=_bi.bomitem_id);
22366
 
 
22367
 
  END LOOP;
22368
 
 
22369
 
  RETURN pTItemid;
22370
 
 
22371
 
END;
22372
 
$$;
22373
 
 
22374
 
 
22375
 
ALTER FUNCTION public.copybom(psitemid integer, ptitemid integer, pcopyusedat boolean) OWNER TO admin;
22376
 
 
22377
 
--
22378
 
--
22379
 
 
22380
 
CREATE FUNCTION copybudget(integer, text, text, integer) RETURNS integer
22381
 
    LANGUAGE plpgsql
22382
 
    AS $_$
22383
 
DECLARE
22384
 
  pBudgheadid ALIAS FOR $1;
22385
 
  pName ALIAS FOR $2;
22386
 
  pDescrip ALIAS FOR $3;
22387
 
  pInterval ALIAS FOR $4;
22388
 
  _budgheadid INTEGER;
22389
 
  _periodid INTEGER;
22390
 
  _result INTEGER;
22391
 
 
22392
 
BEGIN
22393
 
  SELECT 1 INTO _result
22394
 
    FROM budgitem
22395
 
   WHERE ((budgitem_budghead_id=pBudgheadid)
22396
 
     AND  (nextPeriodByInterval(budgitem_period_id, pInterval)=-1))
22397
 
  LIMIT 1;
22398
 
  IF (FOUND) THEN
22399
 
    RETURN -1;
22400
 
  END IF;
22401
 
 
22402
 
  SELECT nextval('budghead_budghead_id_seq') INTO _budgheadid;
22403
 
  INSERT INTO budghead
22404
 
        (budghead_id, budghead_name, budghead_descrip)
22405
 
  VALUES(_budgheadid, pName, pDescrip);
22406
 
 
22407
 
  INSERT INTO budgitem (budgitem_budghead_id, budgitem_period_id,
22408
 
                        budgitem_accnt_id, budgitem_amount)
22409
 
  SELECT _budgheadid, nextPeriodByInterval(budgitem_period_id, pInterval),
22410
 
         budgitem_accnt_id, budgitem_amount
22411
 
    FROM budgitem
22412
 
   WHERE (budgitem_budghead_id=pBudgheadid);
22413
 
 
22414
 
  RETURN _budgheadid;
22415
 
END;
22416
 
$_$;
22417
 
 
22418
 
 
22419
 
ALTER FUNCTION public.copybudget(integer, text, text, integer) OWNER TO admin;
22420
 
 
22421
 
--
22422
 
--
22423
 
 
22424
 
CREATE FUNCTION copycmd(integer, text, text) RETURNS integer
22425
 
    LANGUAGE plpgsql
22426
 
    AS $_$
22427
 
DECLARE
22428
 
  pCmdId        ALIAS FOR $1;
22429
 
  pModule       ALIAS FOR $2;
22430
 
  pTitle        ALIAS FOR $3;
22431
 
  _cmdId        INTEGER;
22432
 
BEGIN
22433
 
    SELECT nextval('cmd_cmd_id_seq') INTO _cmdId;
22434
 
 
22435
 
    INSERT INTO cmd 
22436
 
      SELECT _cmdId, pModule, pTitle, cmd_descrip, cmd_privname, cmd_executable
22437
 
      FROM cmd
22438
 
      WHERE (cmd_id=pCmdId);
22439
 
 
22440
 
    INSERT INTO cmdarg (cmdarg_cmd_id, cmdarg_order, cmdarg_arg)
22441
 
      SELECT _cmdId, cmdarg_order, cmdarg_arg
22442
 
      FROM cmdarg
22443
 
      WHERE (cmdarg_cmd_id=pCmdId);
22444
 
 
22445
 
    RETURN 1;
22446
 
END;
22447
 
$_$;
22448
 
 
22449
 
 
22450
 
ALTER FUNCTION public.copycmd(integer, text, text) OWNER TO admin;
22451
 
 
22452
 
--
22453
 
--
22454
 
 
22455
 
CREATE FUNCTION copycontract(pcontrctid integer, pnumber text, peffective date, pexpires date) RETURNS integer
22456
 
    LANGUAGE plpgsql
22457
 
    AS $$
22458
 
DECLARE
22459
 
  _contrctid INTEGER;
22460
 
  _itemsrcid INTEGER;
22461
 
  _r RECORD;
22462
 
 
22463
 
BEGIN
22464
 
 
22465
 
  INSERT INTO contrct
22466
 
  ( contrct_number,
22467
 
    contrct_vend_id,
22468
 
    contrct_descrip,
22469
 
    contrct_effective,
22470
 
    contrct_expires,
22471
 
    contrct_note )
22472
 
  SELECT
22473
 
    pNumber,
22474
 
    contrct_vend_id,
22475
 
    contrct_descrip,
22476
 
    pEffective,
22477
 
    pExpires,
22478
 
    contrct_note
22479
 
  FROM contrct
22480
 
  WHERE (contrct_id=pContrctid)
22481
 
  RETURNING contrct_id INTO _contrctid;
22482
 
 
22483
 
  FOR _r IN
22484
 
  SELECT * FROM itemsrc WHERE (itemsrc_contrct_id=pContrctid)
22485
 
  LOOP
22486
 
  INSERT INTO itemsrc
22487
 
    ( itemsrc_item_id,
22488
 
      itemsrc_vend_id,
22489
 
      itemsrc_vend_item_number,
22490
 
      itemsrc_vend_item_descrip,
22491
 
      itemsrc_comments,
22492
 
      itemsrc_vend_uom,
22493
 
      itemsrc_invvendoruomratio,
22494
 
      itemsrc_minordqty,
22495
 
      itemsrc_multordqty,
22496
 
      itemsrc_leadtime,
22497
 
      itemsrc_ranking,
22498
 
      itemsrc_active,
22499
 
      itemsrc_manuf_name,
22500
 
      itemsrc_manuf_item_number,
22501
 
      itemsrc_manuf_item_descrip,
22502
 
      itemsrc_default,
22503
 
      itemsrc_upccode,
22504
 
      itemsrc_effective,
22505
 
      itemsrc_expires,
22506
 
      itemsrc_contrct_id )
22507
 
    VALUES
22508
 
    ( _r.itemsrc_item_id,
22509
 
      _r.itemsrc_vend_id,
22510
 
      _r.itemsrc_vend_item_number,
22511
 
      _r.itemsrc_vend_item_descrip,
22512
 
      _r.itemsrc_comments,
22513
 
      _r.itemsrc_vend_uom,
22514
 
      _r.itemsrc_invvendoruomratio,
22515
 
      _r.itemsrc_minordqty,
22516
 
      _r.itemsrc_multordqty,
22517
 
      _r.itemsrc_leadtime,
22518
 
      _r.itemsrc_ranking,
22519
 
      _r.itemsrc_active,
22520
 
      _r.itemsrc_manuf_name,
22521
 
      _r.itemsrc_manuf_item_number,
22522
 
      _r.itemsrc_manuf_item_descrip,
22523
 
      _r.itemsrc_default,
22524
 
      _r.itemsrc_upccode,
22525
 
      pEffective,
22526
 
      pExpires,
22527
 
      _contrctid )
22528
 
    RETURNING itemsrc_id INTO _itemsrcid;
22529
 
 
22530
 
  INSERT INTO itemsrcp
22531
 
    ( itemsrcp_itemsrc_id,
22532
 
      itemsrcp_qtybreak,
22533
 
      itemsrcp_price,
22534
 
      itemsrcp_updated,
22535
 
      itemsrcp_curr_id,
22536
 
      itemsrcp_dropship,
22537
 
      itemsrcp_warehous_id,
22538
 
      itemsrcp_type,
22539
 
      itemsrcp_discntprcnt,
22540
 
      itemsrcp_fixedamtdiscount )
22541
 
    SELECT
22542
 
      _itemsrcid,
22543
 
      itemsrcp_qtybreak,
22544
 
      itemsrcp_price,
22545
 
      CURRENT_DATE,
22546
 
      itemsrcp_curr_id,
22547
 
      itemsrcp_dropship,
22548
 
      itemsrcp_warehous_id,
22549
 
      itemsrcp_type,
22550
 
      itemsrcp_discntprcnt,
22551
 
      itemsrcp_fixedamtdiscount
22552
 
    FROM itemsrcp
22553
 
    WHERE (itemsrcp_itemsrc_id=_r.itemsrc_id);
22554
 
 
22555
 
  END LOOP;
22556
 
 
22557
 
  RETURN _contrctid;
22558
 
 
22559
 
END;
22560
 
$$;
22561
 
 
22562
 
 
22563
 
ALTER FUNCTION public.copycontract(pcontrctid integer, pnumber text, peffective date, pexpires date) OWNER TO admin;
22564
 
 
22565
 
--
22566
 
--
22567
 
 
22568
 
CREATE FUNCTION copyfinancialgroup(integer, integer, integer) RETURNS integer
22569
 
    LANGUAGE plpgsql
22570
 
    AS $_$
22571
 
DECLARE
22572
 
  pSourceGroup ALIAS FOR $1;
22573
 
  pFlheadid ALIAS FOR $2;
22574
 
  pParentFlgrpid ALIAS FOR $3;
22575
 
 
22576
 
  _flgrpid INTEGER;
22577
 
 
22578
 
BEGIN
22579
 
 
22580
 
  SELECT nextval('flgrp_flgrp_id_seq') INTO _flgrpid;
22581
 
 
22582
 
  INSERT INTO flgrp
22583
 
         (flgrp_id, flgrp_flhead_id, flgrp_flgrp_id,
22584
 
          flgrp_order, flgrp_name, flgrp_descrip,
22585
 
          flgrp_subtotal, flgrp_summarize, flgrp_subtract,
22586
 
          flgrp_showstart, flgrp_showend,
22587
 
          flgrp_showdelta, flgrp_showbudget, flgrp_showdiff, flgrp_showcustom,
22588
 
          flgrp_showstartprcnt, flgrp_showendprcnt,
22589
 
          flgrp_showdeltaprcnt, flgrp_showbudgetprcnt, flgrp_showdiffprcnt, flgrp_showcustomprcnt,
22590
 
          flgrp_usealtsubtotal, flgrp_altsubtotal,flgrp_prcnt_flgrp_id)
22591
 
  SELECT _flgrpid, pFlheadid, pParentFlgrpid,
22592
 
         flgrp_order, flgrp_name, flgrp_descrip,
22593
 
         flgrp_subtotal, flgrp_summarize, flgrp_subtract,
22594
 
         flgrp_showstart, flgrp_showend,
22595
 
         flgrp_showdelta, flgrp_showbudget, flgrp_showdiff, flgrp_showcustom,
22596
 
         flgrp_showstartprcnt, flgrp_showendprcnt,
22597
 
         flgrp_showdeltaprcnt, flgrp_showbudgetprcnt, flgrp_showdiffprcnt, flgrp_showcustomprcnt,
22598
 
         flgrp_usealtsubtotal, flgrp_altsubtotal,flgrp_prcnt_flgrp_id
22599
 
    FROM flgrp
22600
 
   WHERE (flgrp_id=pSourceGroup);
22601
 
 
22602
 
   
22603
 
   EXECUTE ' INSERT INTO tmp_flgrpxref' || getEffectiveXtUser() || ' (flgrpxref_oldid,flgrpxref_newid) VALUES (' || pSourceGroup || ',' || _flgrpid || ');';
22604
 
 
22605
 
  INSERT INTO flitem
22606
 
         (flitem_flhead_id, flitem_flgrp_id,
22607
 
          flitem_order, flitem_accnt_id, flitem_showstart,
22608
 
          flitem_showend, flitem_showdelta, flitem_showbudget, flitem_showdiff, flitem_showcustom,
22609
 
          flitem_subtract, flitem_showstartprcnt,
22610
 
          flitem_showendprcnt, flitem_showdeltaprcnt,
22611
 
          flitem_showbudgetprcnt, flitem_showdiffprcnt, flitem_showcustomprcnt,
22612
 
          flitem_custom_source, flitem_company, flitem_profit, flitem_number,
22613
 
          flitem_sub, flitem_type, flitem_subaccnttype_code, flitem_prcnt_flgrp_id)
22614
 
  SELECT pFlheadid, _flgrpid,
22615
 
         flitem_order, flitem_accnt_id, flitem_showstart,
22616
 
         flitem_showend, flitem_showdelta, flitem_showbudget, flitem_showdiff, flitem_showcustom,
22617
 
         flitem_subtract, flitem_showstartprcnt,
22618
 
         flitem_showendprcnt, flitem_showdeltaprcnt,
22619
 
         flitem_showbudgetprcnt, flitem_showdiffprcnt, flitem_showcustomprcnt,
22620
 
         flitem_custom_source, flitem_company, flitem_profit, flitem_number,
22621
 
          flitem_sub, flitem_type, flitem_subaccnttype_code, flitem_prcnt_flgrp_id
22622
 
    FROM flitem
22623
 
   WHERE (flitem_flgrp_id=pSourceGroup);
22624
 
 
22625
 
  INSERT INTO flspec
22626
 
         (flspec_flhead_id, flspec_flgrp_id,
22627
 
          flspec_order, flspec_name, flspec_type, flspec_showstart,
22628
 
          flspec_showend, flspec_showdelta, flspec_showbudget, flspec_showdiff, flspec_showcustom,
22629
 
          flspec_subtract, flspec_showstartprcnt,
22630
 
          flspec_showendprcnt, flspec_showdeltaprcnt,
22631
 
          flspec_showbudgetprcnt, flspec_showdiffprcnt, flspec_showcustomprcnt,
22632
 
          flspec_custom_source, flspec_prcnt_flgrp_id)
22633
 
  SELECT pFlheadid, _flgrpid,
22634
 
         flspec_order, flspec_name, flspec_type, flspec_showstart,
22635
 
         flspec_showend, flspec_showdelta, flspec_showbudget, flspec_showdiff, flspec_showcustom,
22636
 
         flspec_subtract, flspec_showstartprcnt,
22637
 
         flspec_showendprcnt, flspec_showdeltaprcnt,
22638
 
         flspec_showbudgetprcnt, flspec_showdiffprcnt, flspec_showcustomprcnt,
22639
 
         flspec_custom_source, flspec_prcnt_flgrp_id
22640
 
    FROM flspec
22641
 
   WHERE (flspec_flgrp_id=pSourceGroup);
22642
 
 
22643
 
  PERFORM copyFinancialGroup(flgrp_id, pFlheadid, _flgrpid)
22644
 
     FROM flgrp
22645
 
    WHERE (flgrp_flgrp_id=pSourceGroup);
22646
 
 
22647
 
  RETURN _flgrpid;
22648
 
END;
22649
 
$_$;
22650
 
 
22651
 
 
22652
 
ALTER FUNCTION public.copyfinancialgroup(integer, integer, integer) OWNER TO admin;
22653
 
 
22654
 
--
22655
 
--
22656
 
 
22657
 
CREATE FUNCTION copyfinanciallayout(integer, text) RETURNS integer
22658
 
    LANGUAGE plpgsql
22659
 
    AS $_$
22660
 
DECLARE
22661
 
  pSourceFlheadid ALIAS FOR $1;
22662
 
  pDestName ALIAS FOR $2;
22663
 
 
22664
 
  _flheadid INTEGER;
22665
 
  _tblName TEXT;
22666
 
 
22667
 
BEGIN
22668
 
 
22669
 
  PERFORM flhead_id
22670
 
     FROM flhead
22671
 
    WHERE (flhead_id=pSourceFlheadid);
22672
 
  IF (NOT FOUND) THEN
22673
 
    RETURN -1;
22674
 
  END IF;
22675
 
 
22676
 
  IF (pDestName IS NULL OR pDestName = '') THEN
22677
 
    RETURN -2;
22678
 
  END IF;
22679
 
 
22680
 
  PERFORM flhead_id
22681
 
     FROM flhead
22682
 
    WHERE (flhead_name=pDestName);
22683
 
  IF (FOUND) THEN
22684
 
    RETURN -3;
22685
 
  END IF;
22686
 
 
22687
 
  SELECT nextval('flhead_flhead_id_seq') INTO _flheadid;
22688
 
  INSERT INTO flhead
22689
 
         (flhead_id, flhead_name, flhead_descrip,
22690
 
          flhead_showtotal, flhead_showstart,
22691
 
          flhead_showend, flhead_showdelta, flhead_showbudget,
22692
 
          flhead_showdiff, flhead_showcustom,
22693
 
          flhead_custom_label,
22694
 
          flhead_usealttotal, flhead_alttotal,
22695
 
          flhead_usealtbegin, flhead_altbegin,
22696
 
          flhead_usealtend, flhead_altend,
22697
 
          flhead_usealtdebits, flhead_altdebits,
22698
 
          flhead_usealtcredits, flhead_altcredits,
22699
 
          flhead_usealtbudget, flhead_altbudget,
22700
 
          flhead_usealtdiff, flhead_altdiff,
22701
 
          flhead_type, flhead_active, flhead_sys
22702
 
)
22703
 
  SELECT _flheadid, pDestName, flhead_descrip,
22704
 
         flhead_showtotal, flhead_showstart,
22705
 
         flhead_showend, flhead_showdelta, flhead_showbudget,
22706
 
         flhead_showdiff, flhead_showcustom,
22707
 
         flhead_custom_label,
22708
 
         flhead_usealttotal, flhead_alttotal,
22709
 
         flhead_usealtbegin, flhead_altbegin,
22710
 
         flhead_usealtend, flhead_altend,
22711
 
         flhead_usealtdebits, flhead_altdebits,
22712
 
         flhead_usealtcredits, flhead_altcredits,
22713
 
         flhead_usealtbudget, flhead_altbudget,
22714
 
         flhead_usealtdiff, flhead_altdiff,
22715
 
         flhead_type, flhead_active, false
22716
 
    FROM flhead
22717
 
   WHERE (flhead_id=pSourceFlheadid);
22718
 
 
22719
 
 SELECT relname FROM pg_class INTO _tblName
22720
 
 WHERE relname = 'tmp_flgrpxref';
22721
 
 IF (_tblName IS NULL) THEN
22722
 
  EXECUTE 'CREATE TEMPORARY TABLE tmp_flgrpxref' || getEffectiveXtUser() || ' 
22723
 
  (
22724
 
        flgrpxref_oldid int4,
22725
 
        flgrpxref_newid int4
22726
 
  ) ON COMMIT DROP;';
22727
 
  END IF;
22728
 
 
22729
 
  PERFORM copyFinancialGroup(flgrp_id, _flheadid, -1)
22730
 
     FROM flgrp
22731
 
    WHERE ((flgrp_flhead_id=pSourceFlheadid)
22732
 
      AND  (flgrp_flgrp_id=-1));
22733
 
 
22734
 
  EXECUTE 'UPDATE flgrp
22735
 
  SET flgrp_prcnt_flgrp_id=flgrpxref_newid
22736
 
  FROM tmp_flgrpxref' || getEffectiveXtUser() || ' 
22737
 
  WHERE ((flgrp_flhead_id=' || _flheadid || ')
22738
 
  AND (flgrp_prcnt_flgrp_id=flgrpxref_oldid));';
22739
 
 
22740
 
  EXECUTE 'UPDATE flitem
22741
 
  SET flitem_prcnt_flgrp_id=flgrpxref_newid
22742
 
  FROM tmp_flgrpxref' || getEffectiveXtUser() || ' 
22743
 
  WHERE ((flitem_flhead_id=' || _flheadid || ')
22744
 
  AND (flitem_prcnt_flgrp_id=flgrpxref_oldid));';
22745
 
 
22746
 
  EXECUTE 'UPDATE flspec
22747
 
  SET flspec_prcnt_flgrp_id=flgrpxref_newid
22748
 
  FROM tmp_flgrpxref' || getEffectiveXtUser() || ' 
22749
 
  WHERE ((flspec_flhead_id=' || _flheadid || ')
22750
 
  AND (flspec_prcnt_flgrp_id=flgrpxref_oldid));';
22751
 
 
22752
 
  INSERT INTO flcol
22753
 
        (flcol_flhead_id,
22754
 
        flcol_name,
22755
 
        flcol_descrip,
22756
 
        flcol_report_id,
22757
 
        flcol_month,
22758
 
        flcol_quarter,
22759
 
        flcol_year,
22760
 
        flcol_showdb,
22761
 
        flcol_prcnt,
22762
 
        flcol_priortype,
22763
 
        flcol_priormonth,
22764
 
        flcol_priorquarter,
22765
 
        flcol_prioryear,
22766
 
        flcol_priorprcnt,
22767
 
        flcol_priordiff,
22768
 
        flcol_priordiffprcnt,
22769
 
        flcol_budget,
22770
 
        flcol_budgetprcnt,
22771
 
        flcol_budgetdiff,
22772
 
        flcol_budgetdiffprcnt
22773
 
)
22774
 
SELECT
22775
 
        _flheadid,flcol_name,flcol_descrip,
22776
 
        flcol_report_id,flcol_month,flcol_quarter,
22777
 
        flcol_year,flcol_showdb,flcol_prcnt,
22778
 
        flcol_priortype,flcol_priormonth,flcol_priorquarter,
22779
 
        flcol_prioryear,flcol_priorprcnt,flcol_priordiff,
22780
 
        flcol_priordiffprcnt,flcol_budget,flcol_budgetprcnt,
22781
 
        flcol_budgetdiff,flcol_budgetdiffprcnt
22782
 
FROM flcol
22783
 
WHERE (flcol_flhead_id=pSourceFlheadid);
22784
 
 
22785
 
  RETURN _flheadid;
22786
 
END;
22787
 
$_$;
22788
 
 
22789
 
 
22790
 
ALTER FUNCTION public.copyfinanciallayout(integer, text) OWNER TO admin;
22791
 
 
22792
 
--
22793
 
--
22794
 
 
22795
 
CREATE FUNCTION copyglseries(integer) RETURNS integer
22796
 
    LANGUAGE plpgsql
22797
 
    AS $_$
22798
 
DECLARE
22799
 
  pSequence ALIAS FOR $1;
22800
 
  _sequence INTEGER := fetchGLSequence();
22801
 
  _journal INTEGER;     
22802
 
 
22803
 
BEGIN
22804
 
 
22805
 
  SELECT gltrans_journalnumber INTO _journal
22806
 
  FROM gltrans
22807
 
  WHERE ( gltrans_sequence=pSequence )
22808
 
  LIMIT 1;
22809
 
 
22810
 
  IF (FOUND) THEN
22811
 
    INSERT INTO glseries
22812
 
    ( glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber,
22813
 
      glseries_notes, glseries_accnt_id, glseries_amount, glseries_distdate )
22814
 
    SELECT _sequence, gltrans_source, gltrans_doctype, gltrans_docnumber,
22815
 
           gltrans_notes, gltrans_accnt_id,
22816
 
           gltrans_amount, gltrans_date
22817
 
    FROM gltrans
22818
 
    WHERE ( gltrans_sequence=pSequence );
22819
 
  ELSE
22820
 
    RAISE EXCEPTION 'g/l transaction sequence not found';
22821
 
  END IF;
22822
 
 
22823
 
  RETURN _sequence;
22824
 
END;
22825
 
$_$;
22826
 
 
22827
 
 
22828
 
ALTER FUNCTION public.copyglseries(integer) OWNER TO admin;
22829
 
 
22830
 
--
22831
 
--
22832
 
 
22833
 
CREATE FUNCTION copyincdt(integer, timestamp with time zone) RETURNS integer
22834
 
    LANGUAGE plpgsql
22835
 
    AS $_$
22836
 
DECLARE
22837
 
  pparentid   ALIAS FOR $1;
22838
 
  ptimestamp  TIMESTAMP WITH TIME ZONE := COALESCE($2, CURRENT_TIMESTAMP);
22839
 
 
22840
 
  _alarmid    INTEGER;
22841
 
  _incdtid    INTEGER;
22842
 
  _todoitemid INTEGER;
22843
 
 
22844
 
BEGIN
22845
 
  INSERT INTO incdt(incdt_number,          incdt_crmacct_id,
22846
 
                    incdt_cntct_id,        incdt_summary,
22847
 
                    incdt_descrip,         incdt_item_id,
22848
 
                    incdt_timestamp,       incdt_incdtcat_id,
22849
 
                    incdt_incdtseverity_id,incdt_incdtpriority_id,
22850
 
                    incdt_owner_username,  incdt_recurring_incdt_id
22851
 
           ) SELECT fetchIncidentNumber(), incdt_crmacct_id,
22852
 
                    incdt_cntct_id,        incdt_summary,
22853
 
                    incdt_descrip,         incdt_item_id,
22854
 
                    ptimestamp,            incdt_incdtcat_id,
22855
 
                    incdt_incdtseverity_id,incdt_incdtpriority_id,
22856
 
                    incdt_owner_username,  incdt_recurring_incdt_id
22857
 
               FROM incdt
22858
 
              WHERE (incdt_id=pparentid)
22859
 
  RETURNING incdt_id INTO _incdtid;
22860
 
 
22861
 
  IF (_incdtid IS NULL) THEN
22862
 
    RETURN -10;
22863
 
  END IF;
22864
 
 
22865
 
  SELECT MIN(copyTodoitem(todoitem_id, CAST(ptimestamp AS DATE), _incdtid))
22866
 
            INTO _todoitemid
22867
 
    FROM todoitem
22868
 
   WHERE (todoitem_incdt_id=pparentid);
22869
 
 
22870
 
  IF (_todoitemid < 0) THEN
22871
 
    RETURN _todoitemid;
22872
 
  END IF;
22873
 
 
22874
 
  SELECT saveAlarm(NULL, NULL, CAST(ptimestamp AS DATE),
22875
 
                   CAST(alarm_time - DATE_TRUNC('day',alarm_time) AS TIME),
22876
 
                   alarm_time_offset,
22877
 
                   alarm_time_qualifier,
22878
 
                   alarm_event_recipient  IS NOT NULL, alarm_event_recipient,
22879
 
                   alarm_email_recipient  IS NOT NULL, alarm_email_recipient,
22880
 
                   alarm_sysmsg_recipient IS NOT NULL, alarm_sysmsg_recipient,
22881
 
                   'INCDT', _incdtid, 'CHANGEONE')
22882
 
    INTO _alarmid
22883
 
    FROM alarm
22884
 
   WHERE ((alarm_source='INCDT')
22885
 
      AND (alarm_source_id=pparentid));
22886
 
 
22887
 
   IF (_alarmid < 0) THEN
22888
 
     RETURN _alarmid;
22889
 
   END IF;
22890
 
 
22891
 
   INSERT INTO docass (docass_source_id, docass_source_type,
22892
 
                       docass_target_id, docass_target_type, docass_purpose
22893
 
              ) SELECT _incdtid,       'INCDT',
22894
 
                       docass_target_id, docass_target_type, docass_purpose
22895
 
                  FROM docass
22896
 
                 WHERE ((docass_source_id=pparentid)
22897
 
                    AND (docass_source_type='INCDT'));
22898
 
 
22899
 
  RETURN _incdtid;
22900
 
END;
22901
 
$_$;
22902
 
 
22903
 
 
22904
 
ALTER FUNCTION public.copyincdt(integer, timestamp with time zone) OWNER TO admin;
22905
 
 
22906
 
--
22907
 
--
22908
 
 
22909
 
CREATE FUNCTION copyinvoice(integer, date) RETURNS integer
22910
 
    LANGUAGE plpgsql
22911
 
    AS $_$
22912
 
DECLARE
22913
 
  pInvcheadid ALIAS FOR $1;
22914
 
  _invcheadid INTEGER;
22915
 
  _invcnumber TEXT;
22916
 
  _invcdate DATE := COALESCE($2, CURRENT_DATE);
22917
 
  _i RECORD;
22918
 
  _l RECORD;
22919
 
  _invcitemid INTEGER;
22920
 
 
22921
 
BEGIN
22922
 
  SELECT *
22923
 
    INTO _i
22924
 
    FROM invchead
22925
 
   WHERE(invchead_id=pInvcheadid);
22926
 
  IF(NOT FOUND) THEN
22927
 
    RETURN -1;
22928
 
  END IF;
22929
 
 
22930
 
  _invcnumber := fetchInvcNumber();
22931
 
  _invcheadid := nextval('invchead_invchead_id_seq');
22932
 
 
22933
 
  INSERT INTO invchead
22934
 
        (invchead_id,
22935
 
         invchead_cust_id, invchead_shipto_id,
22936
 
         invchead_ordernumber, invchead_orderdate,
22937
 
         invchead_posted, invchead_printed,
22938
 
         invchead_invcnumber, invchead_invcdate, invchead_shipdate,
22939
 
         invchead_ponumber, invchead_shipvia,
22940
 
         invchead_fob, invchead_billto_name,
22941
 
         invchead_billto_address1, invchead_billto_address2,
22942
 
         invchead_billto_address3, invchead_billto_city,
22943
 
         invchead_billto_state, invchead_billto_zipcode,
22944
 
         invchead_billto_phone, invchead_shipto_name,
22945
 
         invchead_shipto_address1, invchead_shipto_address2,
22946
 
         invchead_shipto_address3, invchead_shipto_city,
22947
 
         invchead_shipto_state, invchead_shipto_zipcode,
22948
 
         invchead_shipto_phone, invchead_salesrep_id,
22949
 
         invchead_commission,
22950
 
         invchead_terms_id, invchead_freight,
22951
 
         invchead_misc_amount,
22952
 
         invchead_misc_descrip, invchead_misc_accnt_id,
22953
 
         invchead_payment, invchead_paymentref,
22954
 
         invchead_notes,
22955
 
         invchead_billto_country, invchead_shipto_country,
22956
 
         invchead_prj_id, invchead_curr_id,
22957
 
         invchead_taxzone_id,
22958
 
         invchead_recurring_invchead_id,
22959
 
         invchead_saletype_id, invchead_shipzone_id)
22960
 
  VALUES(_invcheadid,
22961
 
         _i.invchead_cust_id, _i.invchead_shipto_id,
22962
 
         _i.invchead_ordernumber, _i.invchead_orderdate,
22963
 
         false, false,
22964
 
         _invcnumber, _invcdate, _i.invchead_shipdate,
22965
 
         _i.invchead_ponumber, _i.invchead_shipvia,
22966
 
         _i.invchead_fob, _i.invchead_billto_name,
22967
 
         _i.invchead_billto_address1, _i.invchead_billto_address2,
22968
 
         _i.invchead_billto_address3, _i.invchead_billto_city,
22969
 
         _i.invchead_billto_state, _i.invchead_billto_zipcode,
22970
 
         _i.invchead_billto_phone, _i.invchead_shipto_name,
22971
 
         _i.invchead_shipto_address1, _i.invchead_shipto_address2,
22972
 
         _i.invchead_shipto_address3, _i.invchead_shipto_city,
22973
 
         _i.invchead_shipto_state, _i.invchead_shipto_zipcode,
22974
 
         _i.invchead_shipto_phone, _i.invchead_salesrep_id,
22975
 
         _i.invchead_commission,
22976
 
         _i.invchead_terms_id, _i.invchead_freight,
22977
 
         _i.invchead_misc_amount,
22978
 
         _i.invchead_misc_descrip, _i.invchead_misc_accnt_id,
22979
 
         _i.invchead_payment, _i.invchead_paymentref,
22980
 
         _i.invchead_notes,
22981
 
         _i.invchead_billto_country, _i.invchead_shipto_country,
22982
 
         _i.invchead_prj_id, _i.invchead_curr_id,
22983
 
         _i.invchead_taxzone_id,
22984
 
         _i.invchead_recurring_invchead_id,
22985
 
         _i.invchead_saletype_id, _i.invchead_shipzone_id);
22986
 
 
22987
 
  FOR _l IN SELECT *
22988
 
            FROM invcitem
22989
 
            WHERE (invcitem_invchead_id=pInvcheadid) LOOP
22990
 
    SELECT NEXTVAL('invcitem_invcitem_id_seq') INTO _invcitemid;
22991
 
 
22992
 
    INSERT INTO invcitem
22993
 
        (invcitem_id, invcitem_invchead_id,
22994
 
         invcitem_linenumber, invcitem_item_id,
22995
 
         invcitem_warehous_id, invcitem_custpn,
22996
 
         invcitem_number, invcitem_descrip,
22997
 
         invcitem_ordered, invcitem_billed,
22998
 
         invcitem_custprice, invcitem_price,
22999
 
         invcitem_notes, invcitem_salescat_id,
23000
 
         invcitem_taxtype_id,
23001
 
         invcitem_qty_uom_id, invcitem_qty_invuomratio,
23002
 
         invcitem_price_uom_id, invcitem_price_invuomratio,
23003
 
         invcitem_coitem_id)
23004
 
    VALUES
23005
 
        (_invcitemid, _invcheadid,
23006
 
         _l.invcitem_linenumber, _l.invcitem_item_id,
23007
 
         _l.invcitem_warehous_id, _l.invcitem_custpn,
23008
 
         _l.invcitem_number, _l.invcitem_descrip,
23009
 
         _l.invcitem_ordered, _l.invcitem_billed,
23010
 
         _l.invcitem_custprice, _l.invcitem_price,
23011
 
         _l.invcitem_notes, _l.invcitem_salescat_id,
23012
 
         _l.invcitem_taxtype_id,
23013
 
         _l.invcitem_qty_uom_id, _l.invcitem_qty_invuomratio,
23014
 
         _l.invcitem_price_uom_id, _l.invcitem_price_invuomratio,
23015
 
         _l.invcitem_coitem_id);
23016
 
 
23017
 
  END LOOP;
23018
 
 
23019
 
  RETURN _invcheadid;
23020
 
END;
23021
 
$_$;
23022
 
 
23023
 
 
23024
 
ALTER FUNCTION public.copyinvoice(integer, date) OWNER TO admin;
23025
 
 
23026
 
--
23027
 
--
23028
 
 
23029
 
CREATE FUNCTION copyitem(integer, text) RETURNS integer
23030
 
    LANGUAGE plpgsql
23031
 
    AS $_$
23032
 
DECLARE
23033
 
  pSItemid ALIAS FOR $1;
23034
 
  pTItemNumber ALIAS FOR $2;
23035
 
  _itemid INTEGER;
23036
 
  _r RECORD;
23037
 
  _id INTEGER;
23038
 
 
23039
 
BEGIN
23040
 
 
23041
 
  SELECT NEXTVAL('item_item_id_seq') INTO _itemid;
23042
 
  INSERT INTO item
23043
 
  ( item_id, item_number, item_descrip1, item_descrip2,
23044
 
    item_classcode_id, item_type,
23045
 
    item_active, item_picklist, item_sold, item_fractional,
23046
 
    item_maxcost, item_prodweight, item_packweight,
23047
 
    item_prodcat_id,item_exclusive, item_listprice, item_listcost,
23048
 
    item_config, item_comments, item_extdescrip,
23049
 
    item_upccode, item_inv_uom_id, item_price_uom_id )
23050
 
  SELECT _itemid, pTItemNumber, item_descrip1, item_descrip2,
23051
 
         item_classcode_id, item_type,
23052
 
         item_active, item_picklist, item_sold, item_fractional,
23053
 
         item_maxcost, item_prodweight, item_packweight,
23054
 
         item_prodcat_id, item_exclusive, item_listprice, item_listcost,
23055
 
         item_config, item_comments, item_extdescrip,
23056
 
         item_upccode, item_inv_uom_id, item_price_uom_id
23057
 
  FROM item
23058
 
  WHERE (item_id=pSItemid);
23059
 
 
23060
 
  INSERT INTO imageass
23061
 
  (imageass_source_id, imageass_source, imageass_image_id, imageass_purpose)
23062
 
  SELECT _itemid, 'I', imageass_image_id, imageass_purpose
23063
 
  FROM imageass
23064
 
  WHERE ((imageass_source_id=pSItemid)
23065
 
  AND (imageass_source='I'));
23066
 
  
23067
 
  INSERT INTO url
23068
 
  (url_source_id, url_source, url_title, url_url)
23069
 
  SELECT _itemid, 'I', url_title, url_url
23070
 
  FROM url
23071
 
  WHERE ((url_source_id=pSItemid)
23072
 
  AND (url_source='I'));
23073
 
 
23074
 
  INSERT INTO itemtax
23075
 
        (itemtax_item_id, itemtax_taxzone_id, itemtax_taxtype_id)
23076
 
  SELECT _itemid, itemtax_taxzone_id, itemtax_taxtype_id
23077
 
    FROM itemtax
23078
 
   WHERE(itemtax_item_id=pSItemid);
23079
 
 
23080
 
  INSERT INTO charass
23081
 
  ( charass_target_type, charass_target_id,
23082
 
    charass_char_id, charass_value )
23083
 
  SELECT 'I', _itemid, charass_char_id, charass_value
23084
 
  FROM charass
23085
 
  WHERE ( (charass_target_type='I')
23086
 
   AND (charass_target_id=pSItemid) );
23087
 
 
23088
 
  FOR _r IN SELECT itemuomconv_id,
23089
 
                   itemuomconv_from_uom_id,
23090
 
                   itemuomconv_from_value,
23091
 
                   itemuomconv_to_uom_id,
23092
 
                   itemuomconv_to_value,
23093
 
                   itemuomconv_fractional
23094
 
              FROM itemuomconv
23095
 
             WHERE(itemuomconv_item_id=pSItemid) LOOP
23096
 
    SELECT nextval('itemuomconv_itemuomconv_id_seq') INTO _id;
23097
 
    INSERT INTO itemuomconv
23098
 
          (itemuomconv_id, itemuomconv_item_id,
23099
 
           itemuomconv_from_uom_id, itemuomconv_from_value,
23100
 
           itemuomconv_to_uom_id, itemuomconv_to_value,
23101
 
           itemuomconv_fractional)
23102
 
    VALUES(_id, _itemid,
23103
 
           _r.itemuomconv_from_uom_id, _r.itemuomconv_from_value,
23104
 
           _r.itemuomconv_to_uom_id, _r.itemuomconv_to_value,
23105
 
           _r.itemuomconv_fractional);
23106
 
 
23107
 
    INSERT INTO itemuom
23108
 
          (itemuom_itemuomconv_id, itemuom_uomtype_id)
23109
 
    SELECT _id, itemuom_uomtype_id
23110
 
      FROM itemuom
23111
 
     WHERE(itemuom_itemuomconv_id=_r.itemuomconv_id);
23112
 
  END LOOP;
23113
 
 
23114
 
  RETURN _itemid;
23115
 
 
23116
 
END;
23117
 
$_$;
23118
 
 
23119
 
 
23120
 
ALTER FUNCTION public.copyitem(integer, text) OWNER TO admin;
23121
 
 
23122
 
--
23123
 
--
23124
 
 
23125
 
CREATE FUNCTION copyitem(integer, text, boolean, boolean) RETURNS integer
23126
 
    LANGUAGE plpgsql
23127
 
    AS $_$
23128
 
DECLARE
23129
 
  pSItemid      ALIAS FOR $1;
23130
 
  pTItemNumber  ALIAS FOR $2;
23131
 
  pCopyBOM      ALIAS FOR $3;
23132
 
  pCopyCosts    ALIAS FOR $4;
23133
 
 
23134
 
  _itemid       INTEGER;
23135
 
BEGIN
23136
 
 
23137
 
  _itemid := copyItem(pSItemid, pTItemNumber);
23138
 
 
23139
 
  IF (pCopyBOM) THEN
23140
 
    PERFORM copyBOM(pSItemid, _itemid, FALSE);
23141
 
  END IF;
23142
 
 
23143
 
  IF (pCopyCosts) THEN
23144
 
    INSERT INTO itemcost
23145
 
    ( itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel,
23146
 
      itemcost_stdcost, itemcost_posted,
23147
 
      itemcost_actcost, itemcost_curr_id, itemcost_updated )
23148
 
    SELECT _itemid, itemcost_costelem_id, itemcost_lowlevel,
23149
 
      itemcost_stdcost, CURRENT_DATE,
23150
 
      itemcost_actcost, itemcost_curr_id, CURRENT_DATE
23151
 
    FROM itemcost
23152
 
    WHERE (itemcost_item_id=pSItemid);
23153
 
  END IF;
23154
 
 
23155
 
  RETURN _itemid;
23156
 
 
23157
 
END;
23158
 
$_$;
23159
 
 
23160
 
 
23161
 
ALTER FUNCTION public.copyitem(integer, text, boolean, boolean) OWNER TO admin;
23162
 
 
23163
 
--
23164
 
--
23165
 
 
23166
 
CREATE FUNCTION copyitem(integer, text, boolean, boolean, boolean) RETURNS integer
23167
 
    LANGUAGE plpgsql
23168
 
    AS $_$
23169
 
DECLARE
23170
 
  pSItemid ALIAS FOR $1;
23171
 
  pTItemNumber ALIAS FOR $2;
23172
 
  pCopyBOM ALIAS FOR $3;
23173
 
  pCopyBOO ALIAS FOR $4;        -- deprecated - xtmfg-specific
23174
 
  pCopyCosts ALIAS FOR $5;
23175
 
BEGIN
23176
 
  RAISE NOTICE 'copyItem(INTEGER, TEXT, BOOLEAN, BOOLEAN, BOOLEAN) has been deprecated.  Use copyItem(INTEGER, TEXT) or copyItem(INTEGER, TEXT, BOOLEAN, BOOLEAN) or a package-specific version instead.';
23177
 
  RETURN copyItem(pSItemid, pTItemNumber, pCopyBOM, pCopyCosts);
23178
 
END;
23179
 
$_$;
23180
 
 
23181
 
 
23182
 
ALTER FUNCTION public.copyitem(integer, text, boolean, boolean, boolean) OWNER TO admin;
23183
 
 
23184
 
--
23185
 
--
23186
 
 
23187
 
CREATE FUNCTION copyitem(integer, text, boolean, boolean, boolean, boolean) RETURNS integer
23188
 
    LANGUAGE plpgsql
23189
 
    AS $_$
23190
 
DECLARE
23191
 
  pSItemid ALIAS FOR $1;
23192
 
  pTItemNumber ALIAS FOR $2;
23193
 
  pCopyBOM ALIAS FOR $3;
23194
 
  pCopyBOO ALIAS FOR $4;        -- deprecated - xtmfg-specific
23195
 
  pCopyCosts ALIAS FOR $5;
23196
 
  pCopyUsedAt ALIAS FOR $6;     -- deprecated - xtmfg-specific
23197
 
BEGIN
23198
 
  RETURN copyItem(pSItemid, pTItemNumber, pCopyBOM, pCopyCosts);
23199
 
END;
23200
 
$_$;
23201
 
 
23202
 
 
23203
 
ALTER FUNCTION public.copyitem(integer, text, boolean, boolean, boolean, boolean) OWNER TO admin;
23204
 
 
23205
 
--
23206
 
--
23207
 
 
23208
 
CREATE FUNCTION copyitemsite(pitemsiteid integer, pdestwhsid integer) RETURNS integer
23209
 
    LANGUAGE plpgsql
23210
 
    AS $$
23211
 
 
23212
 
BEGIN
23213
 
 
23214
 
  RETURN copyItemSite(pItemsiteid, pDestWhsid, NULL);
23215
 
 
23216
 
END;
23217
 
$$;
23218
 
 
23219
 
 
23220
 
ALTER FUNCTION public.copyitemsite(pitemsiteid integer, pdestwhsid integer) OWNER TO admin;
23221
 
 
23222
 
--
23223
 
--
23224
 
 
23225
 
CREATE FUNCTION copyitemsite(pitemsiteid integer, pdestwhsid integer, pdestitemid integer) RETURNS integer
23226
 
    LANGUAGE plpgsql
23227
 
    AS $$
23228
 
DECLARE
23229
 
  _destwhs  whsinfo%ROWTYPE;
23230
 
  _new    itemsite%ROWTYPE;
23231
 
  _supplywarehousid INTEGER := NULL;
23232
 
 
23233
 
BEGIN
23234
 
  -- make a copy of the old itemsite
23235
 
  SELECT * INTO _new
23236
 
  FROM itemsite
23237
 
  WHERE (itemsite_id=pItemsiteid);
23238
 
  IF (NOT FOUND) THEN
23239
 
    RETURN -1;
23240
 
  END IF;
23241
 
 
23242
 
  -- if there is no dest warehouse then perhaps the user is manually copying it
23243
 
  IF (pDestWhsid IS NOT NULL) THEN
23244
 
    SELECT * INTO _destwhs
23245
 
    FROM whsinfo
23246
 
    WHERE (warehous_id=pDestWhsid);
23247
 
    IF (NOT FOUND) THEN
23248
 
      RETURN -2;
23249
 
    END IF;
23250
 
  END IF;
23251
 
 
23252
 
  IF (NOT checkPrivilege('MaintainItemSites')) THEN
23253
 
    RETURN -3;
23254
 
  END IF;
23255
 
 
23256
 
  SELECT itemsite_id INTO _new.itemsite_id
23257
 
  FROM itemsite
23258
 
  WHERE ((itemsite_item_id=COALESCE(pDestItemid, _new.itemsite_item_id))
23259
 
    AND  (itemsite_warehous_id=pDestWhsid OR
23260
 
    (itemsite_warehous_id IS NULL AND pDestWhsid IS NULL)));
23261
 
  IF (FOUND) THEN
23262
 
    RETURN _new.itemsite_id;
23263
 
  END IF;
23264
 
 
23265
 
  -- find supply itemsite
23266
 
  IF (_new.itemsite_supply_itemsite_id IS NOT NULL) THEN
23267
 
    SELECT itemsite_warehous_id INTO _supplywarehousid
23268
 
    FROM itemsite
23269
 
    WHERE (itemsite_id=_new.itemsite_supply_itemsite_id);
23270
 
    IF (FOUND) THEN
23271
 
      SELECT itemsite_id INTO _new.itemsite_supply_itemsite_id
23272
 
      FROM itemsite
23273
 
      WHERE (itemsite_warehous_id=_supplywarehousid)
23274
 
        AND (itemsite_item_id=pDestItemid);
23275
 
    END IF;
23276
 
  END IF;
23277
 
 
23278
 
  -- now override the things we know have to change
23279
 
  _new.itemsite_id                   := NEXTVAL('itemsite_itemsite_id_seq');
23280
 
  _new.itemsite_warehous_id          := pDestWhsid;
23281
 
  _new.itemsite_qtyonhand            := 0;
23282
 
  _new.itemsite_value                := 0;
23283
 
  _new.itemsite_datelastcount        := NULL;
23284
 
  _new.itemsite_datelastused         := NULL;
23285
 
  _new.itemsite_location_id          := -1;
23286
 
  _new.itemsite_recvlocation_id      := -1;
23287
 
  _new.itemsite_issuelocation_id     := -1;
23288
 
  _new.itemsite_location_dist        := FALSE;
23289
 
  _new.itemsite_recvlocation_dist    := FALSE;
23290
 
  _new.itemsite_issuelocation_dist   := FALSE;
23291
 
 
23292
 
  IF (_destwhs.warehous_transit) THEN
23293
 
    _new.itemsite_reorderlevel         := 0;
23294
 
    _new.itemsite_ordertoqty         := 0;
23295
 
    _new.itemsite_soldranking        := NULL;
23296
 
    _new.itemsite_posupply           := FALSE;
23297
 
    _new.itemsite_wosupply           := FALSE;
23298
 
    _new.itemsite_loccntrl           := FALSE;
23299
 
    _new.itemsite_safetystock        := 0;
23300
 
    _new.itemsite_minordqty          := 0;
23301
 
    _new.itemsite_multordqty         := 0;
23302
 
    _new.itemsite_leadtime           := 0;
23303
 
    _new.itemsite_controlmethod      := 'R';
23304
 
    IF(_new.itemsite_costmethod='N') THEN
23305
 
      _new.itemsite_costmethod       := 'S';
23306
 
    END IF;
23307
 
    _new.itemsite_active             := TRUE;
23308
 
    -- ? _new.itemsite_plancode_id   := -1;
23309
 
    -- ? _new.itemsite_costcat_id    := -1;
23310
 
    _new.itemsite_eventfence         := 1;
23311
 
    _new.itemsite_sold               := FALSE;
23312
 
    _new.itemsite_stocked            := FALSE;
23313
 
    _new.itemsite_location_id        := -1;
23314
 
    _new.itemsite_useparams          := FALSE;
23315
 
    _new.itemsite_useparamsmanual    := FALSE;
23316
 
    _new.itemsite_createpr           := FALSE;
23317
 
    _new.itemsite_location           := NULL;
23318
 
    _new.itemsite_location_comments  := NULL;
23319
 
    _new.itemsite_notes              := 'Transit Warehouse';
23320
 
    _new.itemsite_createwo           := FALSE;
23321
 
    _new.itemsite_costcat_id         := _destwhs.warehous_costcat_id;
23322
 
    _new.itemsite_supply_itemsite_id := NULL;
23323
 
  END IF;
23324
 
 
23325
 
  INSERT INTO itemsite (
23326
 
    itemsite_id,                     itemsite_item_id,
23327
 
    itemsite_warehous_id,            itemsite_qtyonhand,
23328
 
    itemsite_costmethod,             itemsite_value,
23329
 
    itemsite_reorderlevel,           itemsite_ordertoqty,
23330
 
    itemsite_cyclecountfreq,         itemsite_datelastcount,
23331
 
    itemsite_datelastused,
23332
 
    itemsite_posupply,               itemsite_wosupply,
23333
 
    itemsite_loccntrl,
23334
 
    itemsite_safetystock,            itemsite_minordqty,
23335
 
    itemsite_multordqty,             itemsite_leadtime,
23336
 
    itemsite_abcclass,               itemsite_issuemethod,
23337
 
    itemsite_controlmethod,          itemsite_active,
23338
 
    itemsite_plancode_id,            itemsite_costcat_id,
23339
 
    itemsite_eventfence,             itemsite_sold,
23340
 
    itemsite_stocked,                itemsite_freeze,
23341
 
    itemsite_location_id,
23342
 
    itemsite_useparams,              itemsite_useparamsmanual,
23343
 
    itemsite_soldranking,            itemsite_createpr,
23344
 
    itemsite_location,               itemsite_location_comments,
23345
 
    itemsite_notes,                  itemsite_perishable,
23346
 
    itemsite_autoabcclass,
23347
 
    itemsite_ordergroup,             itemsite_disallowblankwip,
23348
 
    itemsite_maxordqty,              itemsite_mps_timefence,
23349
 
    itemsite_createwo,               itemsite_warrpurc,
23350
 
    itemsite_autoreg,
23351
 
    itemsite_planning_type,          itemsite_supply_itemsite_id,
23352
 
    itemsite_createsopr,             itemsite_createsopo,
23353
 
    itemsite_dropship,
23354
 
    itemsite_recvlocation_id,        itemsite_issuelocation_id,
23355
 
    itemsite_location_dist,          itemsite_recvlocation_dist,
23356
 
    itemsite_issuelocation_dist
23357
 
  ) VALUES (
23358
 
    _new.itemsite_id,                COALESCE(pDestItemid, _new.itemsite_item_id),
23359
 
    _new.itemsite_warehous_id,         _new.itemsite_qtyonhand,
23360
 
    _new.itemsite_costmethod,        _new.itemsite_value,
23361
 
    _new.itemsite_reorderlevel,      _new.itemsite_ordertoqty,
23362
 
    _new.itemsite_cyclecountfreq,    _new.itemsite_datelastcount,
23363
 
    _new.itemsite_datelastused,
23364
 
    _new.itemsite_posupply,          _new.itemsite_wosupply,
23365
 
    _new.itemsite_loccntrl,
23366
 
    _new.itemsite_safetystock,         _new.itemsite_minordqty,
23367
 
    _new.itemsite_multordqty,        _new.itemsite_leadtime,
23368
 
    _new.itemsite_abcclass,          _new.itemsite_issuemethod,
23369
 
    _new.itemsite_controlmethod,     _new.itemsite_active,
23370
 
    _new.itemsite_plancode_id,         _new.itemsite_costcat_id,
23371
 
    _new.itemsite_eventfence,        _new.itemsite_sold,
23372
 
    _new.itemsite_stocked,           _new.itemsite_freeze,
23373
 
    _new.itemsite_location_id,
23374
 
    _new.itemsite_useparams,         _new.itemsite_useparamsmanual,
23375
 
    _new.itemsite_soldranking,         _new.itemsite_createpr,
23376
 
    _new.itemsite_location,          _new.itemsite_location_comments,
23377
 
    _new.itemsite_notes,             _new.itemsite_perishable,
23378
 
    _new.itemsite_autoabcclass,
23379
 
    _new.itemsite_ordergroup,        _new.itemsite_disallowblankwip,
23380
 
    _new.itemsite_maxordqty,         _new.itemsite_mps_timefence,
23381
 
    _new.itemsite_createwo,          _new.itemsite_warrpurc,
23382
 
    _new.itemsite_autoreg,
23383
 
    _new.itemsite_planning_type,     _new.itemsite_supply_itemsite_id,
23384
 
    _new.itemsite_createsopr,        _new.itemsite_createsopo,
23385
 
    _new.itemsite_dropship,
23386
 
    _new.itemsite_recvlocation_id,   _new.itemsite_issuelocation_id,
23387
 
    _new.itemsite_location_dist,     _new.itemsite_recvlocation_dist,
23388
 
    _new.itemsite_issuelocation_dist
23389
 
    );
23390
 
 
23391
 
  RETURN _new.itemsite_id;
23392
 
END;
23393
 
$$;
23394
 
 
23395
 
 
23396
 
ALTER FUNCTION public.copyitemsite(pitemsiteid integer, pdestwhsid integer, pdestitemid integer) OWNER TO admin;
23397
 
 
23398
 
--
23399
 
--
23400
 
 
23401
 
CREATE FUNCTION copylocale(integer) RETURNS integer
23402
 
    LANGUAGE plpgsql
23403
 
    AS $_$
23404
 
DECLARE
23405
 
  pLocaleid ALIAS FOR $1;
23406
 
  _localecode TEXT;
23407
 
  _localeid INTEGER;
23408
 
 
23409
 
BEGIN
23410
 
 
23411
 
  SELECT locale_code INTO _localecode
23412
 
  FROM locale
23413
 
  WHERE (locale_id=pLocaleid);
23414
 
 
23415
 
  IF (NOT FOUND) THEN
23416
 
    RAISE EXCEPTION 'Attempt to copy a non-existent locale-id.';
23417
 
  END IF;
23418
 
 
23419
 
  IF (EXISTS(SELECT locale_id
23420
 
             FROM locale
23421
 
             WHERE (locale_code = (_localecode || '-COPY')))) THEN
23422
 
    RAISE EXCEPTION 'Attempt to copy a Locale Code that already exists.';
23423
 
  END IF;
23424
 
 
23425
 
  SELECT NEXTVAL('locale_locale_id_seq') INTO _localeid;
23426
 
 
23427
 
  INSERT INTO locale
23428
 
        (locale_id, locale_code, locale_descrip,
23429
 
         locale_lang_file,
23430
 
         locale_dateformat,
23431
 
         locale_currformat,
23432
 
         locale_qtyformat,
23433
 
         locale_comments,
23434
 
         locale_qtyperformat,
23435
 
         locale_salespriceformat,
23436
 
         locale_extpriceformat,
23437
 
         locale_timeformat,
23438
 
         locale_timestampformat,
23439
 
         local_costformat,
23440
 
         locale_costformat,
23441
 
         locale_purchpriceformat,
23442
 
         locale_uomratioformat,
23443
 
         locale_intervalformat,
23444
 
         locale_lang_id,
23445
 
         locale_country_id,
23446
 
         locale_error_color,
23447
 
         locale_warning_color,
23448
 
         locale_emphasis_color,
23449
 
         locale_altemphasis_color,
23450
 
         locale_expired_color,
23451
 
         locale_future_color,
23452
 
         locale_curr_scale,
23453
 
         locale_salesprice_scale,
23454
 
         locale_purchprice_scale,
23455
 
         locale_extprice_scale,
23456
 
         locale_cost_scale,
23457
 
         locale_qty_scale,
23458
 
         locale_qtyper_scale,
23459
 
         locale_uomratio_scale)
23460
 
  SELECT _localeid, locale_code || '-COPY', '',
23461
 
         locale_lang_file,
23462
 
         locale_dateformat,
23463
 
         locale_currformat,
23464
 
         locale_qtyformat,
23465
 
         locale_comments,
23466
 
         locale_qtyperformat,
23467
 
         locale_salespriceformat,
23468
 
         locale_extpriceformat,
23469
 
         locale_timeformat,
23470
 
         locale_timestampformat,
23471
 
         local_costformat,
23472
 
         locale_costformat,
23473
 
         locale_purchpriceformat,
23474
 
         locale_uomratioformat,
23475
 
         locale_intervalformat,
23476
 
         locale_lang_id,
23477
 
         locale_country_id,
23478
 
         locale_error_color,
23479
 
         locale_warning_color,
23480
 
         locale_emphasis_color,
23481
 
         locale_altemphasis_color,
23482
 
         locale_expired_color,
23483
 
         locale_future_color,
23484
 
         locale_curr_scale,
23485
 
         locale_salesprice_scale,
23486
 
         locale_purchprice_scale,
23487
 
         locale_extprice_scale,
23488
 
         locale_cost_scale,
23489
 
         locale_qty_scale,
23490
 
         locale_qtyper_scale,
23491
 
         locale_uomratio_scale
23492
 
    FROM locale
23493
 
   WHERE(locale_id=pLocaleid);
23494
 
 
23495
 
  RETURN _localeid;
23496
 
 
23497
 
END;
23498
 
$_$;
23499
 
 
23500
 
 
23501
 
ALTER FUNCTION public.copylocale(integer) OWNER TO admin;
23502
 
 
23503
 
--
23504
 
--
23505
 
 
23506
 
CREATE FUNCTION copypo(integer, integer, date, boolean) RETURNS integer
23507
 
    LANGUAGE plpgsql
23508
 
    AS $_$
23509
 
DECLARE
23510
 
  pSrcid                ALIAS FOR $1;
23511
 
  pVendid               ALIAS FOR $2;
23512
 
  pOrderdate            ALIAS FOR $3;
23513
 
  pRecheckVendinfo      ALIAS FOR $4;
23514
 
 
23515
 
  _tgtid                INTEGER;
23516
 
  _orderdate            DATE;
23517
 
  _head                 RECORD;
23518
 
  _itemsrc              RECORD;
23519
 
  _lineitem             RECORD;
23520
 
  _qty                  NUMERIC;
23521
 
  _unitprice            NUMERIC;
23522
 
  _uomratio             NUMERIC;
23523
 
  _vend_restrictpurch   BOOLEAN;
23524
 
 
23525
 
BEGIN
23526
 
  SELECT * INTO _head FROM pohead WHERE pohead_id = pSrcid;
23527
 
  IF (NOT FOUND) THEN
23528
 
    RETURN -1;
23529
 
  END IF;
23530
 
  IF (_head.pohead_vend_id != pVendid) THEN
23531
 
    RETURN -2;          -- not supported now but should be in the future
23532
 
  END IF;               -- when enabled, set pRecheckVendinfo if vendors don't match
23533
 
 
23534
 
  IF (pOrderdate IS NULL) THEN
23535
 
    _orderdate := CURRENT_DATE;
23536
 
  ELSE
23537
 
    _orderdate := pOrderdate;
23538
 
  END IF;
23539
 
 
23540
 
  INSERT INTO pohead (pohead_status, pohead_number,
23541
 
                      pohead_orderdate, pohead_vend_id,
23542
 
                      pohead_fob, pohead_shipvia,
23543
 
                      pohead_freight, pohead_printed,
23544
 
                      pohead_terms_id, pohead_warehous_id,
23545
 
                      pohead_vendaddr_id, pohead_agent_username,
23546
 
                      pohead_curr_id, pohead_saved,
23547
 
                      pohead_taxtype_id, pohead_taxzone_id,
23548
 
                      pohead_dropship, pohead_vend_cntct_id,
23549
 
                      pohead_vend_cntct_honorific, pohead_vend_cntct_first_name,
23550
 
                      pohead_vend_cntct_middle, pohead_vend_cntct_last_name,
23551
 
                      pohead_vend_cntct_suffix, pohead_vend_cntct_phone,
23552
 
                      pohead_vend_cntct_title, pohead_vend_cntct_fax,
23553
 
                      pohead_vend_cntct_email, pohead_vendaddress1,
23554
 
                      pohead_vendaddress2, pohead_vendaddress3,
23555
 
                      pohead_vendcity, pohead_vendstate,
23556
 
                      pohead_vendzipcode, pohead_vendcountry,
23557
 
                      pohead_shipto_cntct_id,
23558
 
                      pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name,
23559
 
                      pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name,
23560
 
                      pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone,
23561
 
                      pohead_shipto_cntct_title, pohead_shipto_cntct_fax,
23562
 
                      pohead_shipto_cntct_email, pohead_shiptoaddress_id,
23563
 
                      pohead_shiptoaddress1,
23564
 
                      pohead_shiptoaddress2, pohead_shiptoaddress3,
23565
 
                      pohead_shiptocity, pohead_shiptostate,
23566
 
                      pohead_shiptozipcode, pohead_shiptocountry
23567
 
              ) VALUES (
23568
 
                      'U', fetchPoNumber(),
23569
 
                      _orderdate, _head.pohead_vend_id,
23570
 
                      _head.pohead_fob, _head.pohead_shipvia,
23571
 
                      _head.pohead_freight, false,
23572
 
                      _head.pohead_terms_id, _head.pohead_warehous_id,
23573
 
                      _head.pohead_vendaddr_id, _head.pohead_agent_username,
23574
 
                      _head.pohead_curr_id, true,
23575
 
                      _head.pohead_taxtype_id, _head.pohead_taxzone_id,
23576
 
                      false, _head.pohead_vend_cntct_id,
23577
 
                      _head.pohead_vend_cntct_honorific, _head.pohead_vend_cntct_first_name,
23578
 
                      _head.pohead_vend_cntct_middle, _head.pohead_vend_cntct_last_name,
23579
 
                      _head.pohead_vend_cntct_suffix, _head.pohead_vend_cntct_phone,
23580
 
                      _head.pohead_vend_cntct_title, _head.pohead_vend_cntct_fax,
23581
 
                      _head.pohead_vend_cntct_email, _head.pohead_vendaddress1,
23582
 
                      _head.pohead_vendaddress2, _head.pohead_vendaddress3,
23583
 
                      _head.pohead_vendcity, _head.pohead_vendstate,
23584
 
                      _head.pohead_vendzipcode, _head.pohead_vendcountry,
23585
 
                      _head.pohead_shipto_cntct_id,
23586
 
                      _head.pohead_shipto_cntct_honorific, _head.pohead_shipto_cntct_first_name,
23587
 
                      _head.pohead_shipto_cntct_middle, _head.pohead_shipto_cntct_last_name,
23588
 
                      _head.pohead_shipto_cntct_suffix, _head.pohead_shipto_cntct_phone,
23589
 
                      _head.pohead_shipto_cntct_title, _head.pohead_shipto_cntct_fax,
23590
 
                      _head.pohead_shipto_cntct_email, _head.pohead_shiptoaddress_id,
23591
 
                      _head.pohead_shiptoaddress1,
23592
 
                      _head.pohead_shiptoaddress2, _head.pohead_shiptoaddress3,
23593
 
                      _head.pohead_shiptocity, _head.pohead_shiptostate,
23594
 
                      _head.pohead_shiptozipcode, _head.pohead_shiptocountry);
23595
 
 
23596
 
  _tgtid := CURRVAL('pohead_pohead_id_seq');
23597
 
 
23598
 
  IF (pRecheckVendinfo) THEN
23599
 
    SELECT vend_restrictpurch INTO _vend_restrictpurch
23600
 
      FROM vendinfo WHERE (vend_id = pVendid);
23601
 
 
23602
 
    FOR _lineitem IN SELECT *
23603
 
                  FROM poitem 
23604
 
                  WHERE (poitem_pohead_id = pSrcid) LOOP
23605
 
 
23606
 
      SELECT * INTO _itemsrc
23607
 
      FROM itemsrc, itemsite
23608
 
      WHERE (itemsrc_active
23609
 
        AND  (itemsrc_id = _lineitem.poitem_itemsrc_id)
23610
 
        AND  (itemsite_id = _lineitem.poitem_itemsite_id));
23611
 
      IF (NOT FOUND AND _vend_restrictpurch) THEN
23612
 
        RETURN -3;
23613
 
      END IF;
23614
 
 
23615
 
      -- handle changes to the uom ratio and consequent qty changes
23616
 
      _uomratio := COALESCE(_itemsrc.itemsrc_invvendoruomratio, _lineitem.poitem_invvenduomratio);
23617
 
      IF (_itemsrc.itemsrc_invvendoruomratio IS NULL
23618
 
          OR _itemsrc.itemsrc_invvendoruomratio != _lineitem.poitem_invvenduomratio) THEN
23619
 
        _qty := _lineitem.poitem_qty_ordered;
23620
 
 
23621
 
      ELSE
23622
 
        _qty := _lineitem.poitem_qty_ordered * _lineitem.poitem_invvenduomratio /
23623
 
                                               _itemsrc.itemsrc_invvendoruomratio;
23624
 
        IF (_itemsrc.itemsrc_minordqty IS NOT NULL) THEN
23625
 
          IF (_qty < _itemsrc.itemsrc_minordqty) THEN
23626
 
            _qty := _itemsrc.itemsrc_minordqty;
23627
 
          ELSIF (_itemsrc.itemsrc_multordqty > 0
23628
 
                   AND _qty % _itemsrc.itemsrc_multordqty > 0) THEN
23629
 
            _qty = _qty % _itemsrc.itemsrc_multordqty + _itemsrc.itemsrc_multordqty;
23630
 
          END IF;
23631
 
        END IF;
23632
 
      END IF;
23633
 
 
23634
 
      IF (_itemsrc.itemsrc_id IS NULL) THEN
23635
 
        _unitprice = _lineitem.poitem_unitprice;
23636
 
      ELSE
23637
 
        SELECT itemsrcPrice(_itemsrc.itemsrc_id, _head.pohead_warehous_id, _head.pohead_dropship,
23638
 
                            _lineitem.poitem_qty_ordered, _head.pohead_curr_id, CURRENT_DATE) INTO _unitprice;
23639
 
        IF (_unitprice IS NULL) THEN
23640
 
          RETURN -4;
23641
 
        END IF;
23642
 
      END IF;
23643
 
 
23644
 
      INSERT INTO poitem (poitem_status, poitem_pohead_id, poitem_linenumber,
23645
 
                          poitem_duedate,
23646
 
                          poitem_itemsite_id,
23647
 
                          poitem_vend_item_descrip,
23648
 
                          poitem_vend_uom,
23649
 
                          poitem_invvenduomratio,
23650
 
                          poitem_qty_ordered, poitem_unitprice,
23651
 
                          poitem_vend_item_number,
23652
 
                          poitem_comments, poitem_expcat_id,
23653
 
                          poitem_itemsrc_id,
23654
 
                          poitem_freight,
23655
 
                          poitem_stdcost,
23656
 
                          poitem_manuf_name,
23657
 
                          poitem_manuf_item_number,
23658
 
                          poitem_manuf_item_descrip,
23659
 
                          poitem_taxtype_id
23660
 
                    ) VALUES (
23661
 
                          'U', _tgtid, _lineitem.poitem_linenumber,
23662
 
                          _orderdate + COALESCE(_itemsrc.itemsrc_leadtime, 0),
23663
 
                          _lineitem.poitem_itemsite_id,
23664
 
                          COALESCE(_itemsrc.itemsrc_vend_item_descrip,
23665
 
                                   _lineitem.poitem_vend_item_descrip),
23666
 
                          COALESCE(_itemsrc.itemsrc_vend_uom, _lineitem.poitem_vend_uom),
23667
 
                          COALESCE(_itemsrc.itemsrc_invvendoruomratio,
23668
 
                                   _lineitem.poitem_invvenduomratio),
23669
 
                          _qty, _unitprice,
23670
 
                          COALESCE(_itemsrc.itemsrc_vend_item_number,
23671
 
                                   _lineitem.poitem_vend_item_number),
23672
 
                          _lineitem.poitem_comments, _lineitem.poitem_expcat_id,
23673
 
                          COALESCE(_itemsrc.itemsrc_id, -1),
23674
 
                          _lineitem.poitem_freight,
23675
 
                          stdcost(_itemsrc.itemsite_item_id),
23676
 
                          COALESCE(_itemsrc.itemsrc_manuf_name,
23677
 
                                   _lineitem.poitem_manuf_name),
23678
 
                          COALESCE(_itemsrc.itemsrc_manuf_item_number,
23679
 
                                   _lineitem.poitem_manuf_item_number),
23680
 
                          COALESCE(_itemsrc.itemsrc_manuf_item_descrip,
23681
 
                                   _lineitem.poitem_manuf_item_descrip),
23682
 
                          _lineitem.poitem_taxtype_id);
23683
 
 
23684
 
    END LOOP;
23685
 
  ELSE
23686
 
    INSERT INTO poitem (poitem_status, poitem_pohead_id, poitem_linenumber,
23687
 
                        poitem_duedate, poitem_itemsite_id,
23688
 
                        poitem_vend_item_descrip, poitem_vend_uom,
23689
 
                        poitem_invvenduomratio, poitem_qty_ordered,
23690
 
                        poitem_unitprice,
23691
 
                        poitem_vend_item_number, poitem_comments,
23692
 
                        poitem_expcat_id, poitem_itemsrc_id, poitem_freight,
23693
 
                        poitem_stdcost, poitem_manuf_name, 
23694
 
                        poitem_manuf_item_number, poitem_manuf_item_descrip,
23695
 
                        poitem_taxtype_id
23696
 
                ) SELECT 'U', _tgtid, poitem_linenumber,
23697
 
                        _orderdate + COALESCE(itemsrc_leadtime, 0), poitem_itemsite_id,
23698
 
                        poitem_vend_item_descrip, poitem_vend_uom,
23699
 
                        poitem_invvenduomratio, poitem_qty_ordered,
23700
 
                        poitem_unitprice,
23701
 
                        poitem_vend_item_number, poitem_comments,
23702
 
                        poitem_expcat_id, poitem_itemsrc_id, poitem_freight,
23703
 
                        stdcost(itemsite_item_id), poitem_manuf_name,
23704
 
                        poitem_manuf_item_number, poitem_manuf_item_descrip,
23705
 
                        poitem_taxtype_id
23706
 
                  FROM poitem
23707
 
                    LEFT OUTER JOIN itemsrc ON (itemsrc_id=poitem_itemsrc_id)
23708
 
                    LEFT OUTER JOIN itemsite ON (itemsite_id=poitem_itemsite_id)
23709
 
                  WHERE (poitem_pohead_id = pSrcid);
23710
 
  END IF;
23711
 
 
23712
 
  -- Todo: recalculate tax?
23713
 
 
23714
 
  RETURN _tgtid;
23715
 
 
23716
 
END;
23717
 
$_$;
23718
 
 
23719
 
 
23720
 
ALTER FUNCTION public.copypo(integer, integer, date, boolean) OWNER TO admin;
23721
 
 
23722
 
--
23723
 
--
23724
 
 
23725
 
CREATE FUNCTION copypricingschedule(pipsheadid integer) RETURNS integer
23726
 
    LANGUAGE plpgsql
23727
 
    AS $$
23728
 
DECLARE
23729
 
  _ipsheadid INTEGER;
23730
 
  _ipsitemid INTEGER;
23731
 
  _ipsfreightid INTEGER;
23732
 
  _x RECORD;
23733
 
 
23734
 
BEGIN
23735
 
 
23736
 
  _ipsheadid := nextval('ipshead_ipshead_id_seq');
23737
 
  INSERT INTO ipshead 
23738
 
  ( ipshead_id, ipshead_name, ipshead_descrip,
23739
 
    ipshead_effective, ipshead_expires, 
23740
 
    ipshead_curr_id, ipshead_updated ) 
23741
 
  SELECT _ipsheadid, orig.ipshead_name || (SELECT CAST((COUNT(cnt.ipshead_id)+1) AS text)
23742
 
                                            FROM ipshead cnt
23743
 
                                            WHERE (SUBSTRING(cnt.ipshead_name FROM 0 FOR char_length(orig.ipshead_name)+1) = orig.ipshead_name)),
23744
 
         orig.ipshead_descrip, orig.ipshead_effective, orig.ipshead_expires, 
23745
 
         orig.ipshead_curr_id, CURRENT_DATE
23746
 
  FROM ipshead orig
23747
 
  WHERE (orig.ipshead_id=pIpsheadId);
23748
 
 
23749
 
  FOR _x IN
23750
 
    SELECT ipsitem_id FROM ipsiteminfo WHERE (ipsitem_ipshead_id=pIpsheadid)
23751
 
  LOOP 
23752
 
      INSERT INTO ipsiteminfo 
23753
 
          (ipsitem_ipshead_id, ipsitem_item_id, ipsitem_prodcat_id,
23754
 
           ipsitem_qtybreak, ipsitem_price,
23755
 
           ipsitem_qty_uom_id, ipsitem_price_uom_id,
23756
 
           ipsitem_discntprcnt, ipsitem_fixedamtdiscount,
23757
 
           ipsitem_type, ipsitem_warehous_id) 
23758
 
      SELECT _ipsheadid, ipsitem_item_id, ipsitem_prodcat_id,
23759
 
           ipsitem_qtybreak, ipsitem_price,
23760
 
           ipsitem_qty_uom_id, ipsitem_price_uom_id,
23761
 
           ipsitem_discntprcnt, ipsitem_fixedamtdiscount,
23762
 
           ipsitem_type, ipsitem_warehous_id
23763
 
      FROM ipsiteminfo 
23764
 
      WHERE (ipsitem_id=_x.ipsitem_id)
23765
 
      RETURNING ipsitem_id INTO _ipsitemid; 
23766
 
 
23767
 
      INSERT INTO ipsitemchar
23768
 
        ( ipsitemchar_ipsitem_id, ipsitemchar_char_id,
23769
 
          ipsitemchar_value, ipsitemchar_price)
23770
 
      SELECT  _ipsitemid, ipsitemchar_char_id,
23771
 
          ipsitemchar_value, ipsitemchar_price
23772
 
      FROM ipsitemchar
23773
 
      WHERE (ipsitemchar_ipsitem_id=_x.ipsitem_id);
23774
 
  END LOOP;
23775
 
 
23776
 
  FOR _x IN
23777
 
    SELECT ipsfreight_id FROM ipsfreight WHERE (ipsfreight_ipshead_id=pIpsheadid)
23778
 
  LOOP 
23779
 
      _ipsfreightid := nextval('ipsfreight_ipsfreight_id_seq');
23780
 
      INSERT INTO ipsfreight
23781
 
          (ipsfreight_id, ipsfreight_ipshead_id, 
23782
 
           ipsfreight_qtybreak, ipsfreight_price,
23783
 
           ipsfreight_type, ipsfreight_warehous_id,
23784
 
           ipsfreight_shipzone_id,ipsfreight_freightclass_id,
23785
 
           ipsfreight_shipvia) 
23786
 
      SELECT _ipsfreightid, _ipsheadid, ipsfreight_qtybreak, 
23787
 
           ipsfreight_price,ipsfreight_type, 
23788
 
           ipsfreight_warehous_id,ipsfreight_shipzone_id,
23789
 
           ipsfreight_freightclass_id,ipsfreight_shipvia
23790
 
      FROM ipsfreight
23791
 
      WHERE (ipsfreight_id=_x.ipsfreight_id); 
23792
 
 
23793
 
  END LOOP;
23794
 
 
23795
 
  RETURN _ipsheadid;
23796
 
 
23797
 
END;
23798
 
$$;
23799
 
 
23800
 
 
23801
 
ALTER FUNCTION public.copypricingschedule(pipsheadid integer) OWNER TO admin;
23802
 
 
23803
 
--
23804
 
--
23805
 
 
23806
 
CREATE FUNCTION copyprj(integer, date) RETURNS integer
23807
 
    LANGUAGE plpgsql
23808
 
    AS $_$
23809
 
DECLARE
23810
 
  pparentid   ALIAS FOR $1;
23811
 
  _counter    INTEGER;
23812
 
  _duedate    DATE := COALESCE($2, CURRENT_DATE);
23813
 
  _alarmid    INTEGER;
23814
 
  _i          INTEGER;
23815
 
  _newnumber  TEXT;
23816
 
  _p          RECORD;
23817
 
  _prjid      INTEGER;
23818
 
  _testnumber TEXT;
23819
 
 
23820
 
BEGIN
23821
 
  RAISE DEBUG 'copyPrj(%, %) entered', pparentid, _duedate;
23822
 
 
23823
 
  SELECT * INTO _p
23824
 
  FROM prj
23825
 
  WHERE (prj_id=pparentid);
23826
 
 
23827
 
  -- new number = old number up to but not including -, followed by _duedate
23828
 
  -- e.g. REPAIR-FRIDGE becomes REPAIR-2010-05-15
23829
 
  --  but REPAIR_FRIDGE becomes REPAIR_FRIDGE-2010-05-15
23830
 
  IF (_p.prj_recurring_prj_id IS NULL) THEN
23831
 
    _newnumber := _p.prj_number;
23832
 
  ELSE
23833
 
    _newnumber := SUBSTRING(_p.prj_number FROM '[^-]*');
23834
 
    IF (_newnumber IS NULL) THEN
23835
 
      _newnumber := _p.prj_number;
23836
 
    END IF;
23837
 
  END IF;
23838
 
  _newnumber := _newnumber || '-' || to_char(_duedate, 'YYYY-MM-DD');
23839
 
  
23840
 
  RAISE DEBUG 'copyPrj checking if _newnumber % exists', _newnumber;
23841
 
  SELECT MAX(prj_number) INTO _testnumber
23842
 
    FROM prj
23843
 
   WHERE (prj_number ~ ('^' || _newnumber));
23844
 
  IF (_testnumber = _newnumber) THEN
23845
 
    _newnumber := _newnumber || '-001';
23846
 
  ELSIF (_testnumber IS NOT NULL) THEN
23847
 
    _counter := CAST(SUBSTRING(_testnumber FROM '...$') AS INTEGER);
23848
 
    _counter := _counter + 1;
23849
 
    _newnumber := REGEXP_REPLACE(_testnumber, '...$', to_char(_counter, 'FM009'));
23850
 
  END IF;
23851
 
  RAISE DEBUG 'copyPrj _newnumber is now %', _newnumber;
23852
 
 
23853
 
  INSERT INTO prj(
23854
 
            prj_number,     prj_name,           prj_descrip,
23855
 
            prj_status,     prj_so,             prj_wo,
23856
 
            prj_po,         prj_owner_username, prj_prjtype_id,
23857
 
            prj_due_date,   prj_username,       prj_recurring_prj_id
23858
 
  ) SELECT  _newnumber,     _p.prj_name,        _p.prj_descrip,
23859
 
            'P',            _p.prj_so,          _p.prj_wo,
23860
 
            _p.prj_po,      _p.prj_owner_username, _p.prj_prjtype_id,
23861
 
            _duedate,       _p.prj_username,    _p. prj_recurring_prj_id
23862
 
      FROM prj
23863
 
     WHERE (prj_id=pparentid)
23864
 
  RETURNING prj_id INTO _prjid;
23865
 
 
23866
 
  IF (_prjid IS NULL) THEN
23867
 
    RETURN -1;
23868
 
  END IF;
23869
 
 
23870
 
  SELECT saveAlarm(NULL, NULL, _duedate,
23871
 
                   CAST(alarm_time - DATE_TRUNC('day',alarm_time) AS TIME),
23872
 
                   alarm_time_offset,
23873
 
                   alarm_time_qualifier,
23874
 
                   alarm_event_recipient  IS NOT NULL, alarm_event_recipient,
23875
 
                   alarm_email_recipient  IS NOT NULL, alarm_email_recipient,
23876
 
                   alarm_sysmsg_recipient IS NOT NULL, alarm_sysmsg_recipient,
23877
 
                   'J', _prjid, 'CHANGEONE')
23878
 
    INTO _alarmid
23879
 
    FROM alarm
23880
 
   WHERE ((alarm_source='J')
23881
 
      AND (alarm_source_id=pparentid));
23882
 
 
23883
 
   IF (_alarmid < 0) THEN
23884
 
     RETURN _alarmid;
23885
 
   END IF;
23886
 
 
23887
 
  RETURN _prjid;
23888
 
END;
23889
 
$_$;
23890
 
 
23891
 
 
23892
 
ALTER FUNCTION public.copyprj(integer, date) OWNER TO admin;
23893
 
 
23894
 
--
23895
 
--
23896
 
 
23897
 
CREATE FUNCTION copyproject(integer, text, text, date) RETURNS integer
23898
 
    LANGUAGE plpgsql
23899
 
    AS $_$
23900
 
DECLARE
23901
 
  pPrjId ALIAS FOR $1;
23902
 
  pPrjNumber ALIAS FOR $2;
23903
 
  pPrjName ALIAS FOR $3;
23904
 
  pDueDate ALIAS FOR $4;
23905
 
  _prjid INTEGER;
23906
 
  _offset INTEGER;
23907
 
 
23908
 
BEGIN
23909
 
 
23910
 
  IF (COALESCE(pPrjNumber, '') = '') THEN
23911
 
    RETURN -1;
23912
 
  END IF;
23913
 
 
23914
 
  IF (COALESCE(pPrjName, '') = '') THEN
23915
 
    RETURN -1;
23916
 
  END IF;
23917
 
 
23918
 
  IF (EXISTS(SELECT prj_id FROM prj WHERE UPPER(prj_number)=UPPER(pPrjNumber))) THEN
23919
 
    RETURN -2;
23920
 
  END IF;
23921
 
 
23922
 
  IF (NOT EXISTS(SELECT prj_id FROM prj WHERE prj_id=pPrjId)) THEN
23923
 
    RETURN -3;
23924
 
  END IF;
23925
 
 
23926
 
  IF (pDueDate IS NULL) THEN
23927
 
    RETURN -4;
23928
 
  END IF;
23929
 
 
23930
 
  SELECT (pDueDate - prj_due_date) INTO _offset
23931
 
   FROM prj
23932
 
   WHERE (prj_id=pPrjId);
23933
 
 
23934
 
  SELECT NEXTVAL('prj_prj_id_seq') INTO _prjid;
23935
 
 
23936
 
  INSERT INTO prj
23937
 
  ( prj_id, prj_number, prj_name, 
23938
 
    prj_descrip, prj_status, prj_prjtype_id,
23939
 
    prj_so, prj_wo, prj_po,
23940
 
    prj_owner_username, prj_start_date,
23941
 
    prj_due_date, prj_assigned_date, prj_completed_date,
23942
 
    prj_username, prj_recurring_prj_id,
23943
 
    prj_crmacct_id, prj_cntct_id )
23944
 
  SELECT _prjid, UPPER(pPrjNumber), pPrjName,
23945
 
         prj_descrip, 'P', prj_prjtype_id,
23946
 
         prj_so, prj_wo, prj_po,
23947
 
         prj_owner_username, NULL,
23948
 
         (prj_due_date + COALESCE(_offset, 0)),
23949
 
         CASE WHEN (prj_username IS NULL) THEN NULL ELSE CURRENT_DATE END, NULL,
23950
 
         prj_username, prj_recurring_prj_id,
23951
 
         prj_crmacct_id, prj_cntct_id
23952
 
  FROM prj
23953
 
  WHERE (prj_id=pPrjId);
23954
 
 
23955
 
  INSERT INTO prjtask
23956
 
  ( prjtask_number, prjtask_name, prjtask_descrip,
23957
 
    prjtask_prj_id, prjtask_anyuser, prjtask_status,
23958
 
    prjtask_hours_budget, prjtask_hours_actual,
23959
 
    prjtask_exp_budget, prjtask_exp_actual,
23960
 
    prjtask_owner_username, prjtask_start_date,
23961
 
    prjtask_due_date, prjtask_assigned_date,
23962
 
    prjtask_completed_date, prjtask_username )
23963
 
  SELECT prjtask_number, prjtask_name, prjtask_descrip,
23964
 
         _prjid, prjtask_anyuser, 'P',
23965
 
         prjtask_hours_budget, 0.0,
23966
 
         prjtask_exp_budget, 0.0,
23967
 
         prjtask_owner_username, NULL,
23968
 
         (prjtask_due_date + COALESCE(_offset, 0)),
23969
 
         CASE WHEN (prjtask_username IS NULL) THEN NULL ELSE CURRENT_DATE END,
23970
 
         NULL, prjtask_username
23971
 
  FROM prjtask
23972
 
  WHERE (prjtask_prj_id=pPrjId);
23973
 
 
23974
 
  INSERT INTO docass
23975
 
  ( docass_source_id, docass_source_type,
23976
 
    docass_target_id, docass_target_type,
23977
 
    docass_purpose )
23978
 
  SELECT _prjid, docass_source_type,
23979
 
         docass_target_id, docass_target_type,
23980
 
         docass_purpose
23981
 
  FROM docass
23982
 
  WHERE ((docass_source_id=pPrjId)
23983
 
    AND  (docass_source_type='J'));
23984
 
 
23985
 
  RETURN _prjid;
23986
 
 
23987
 
END;
23988
 
$_$;
23989
 
 
23990
 
 
23991
 
ALTER FUNCTION public.copyproject(integer, text, text, date) OWNER TO admin;
23992
 
 
23993
 
--
23994
 
--
23995
 
 
23996
 
CREATE FUNCTION copyquote(integer, date) RETURNS integer
23997
 
    LANGUAGE plpgsql
23998
 
    AS $_$
23999
 
DECLARE
24000
 
  pQuheadid ALIAS FOR $1;
24001
 
  pSchedDate ALIAS FOR $2;
24002
 
  _quheadid INTEGER;
24003
 
  _qunumber TEXT;
24004
 
 
24005
 
BEGIN
24006
 
 
24007
 
  SELECT NEXTVAL('quhead_quhead_id_seq') INTO _quheadid;
24008
 
  IF (fetchMetricText('QUNumberGeneration') = 'S') THEN
24009
 
    SELECT fetchSoNumber() INTO _qunumber;
24010
 
  ELSE
24011
 
    SELECT fetchQuNumber() INTO _qunumber;
24012
 
  END IF;
24013
 
 
24014
 
  INSERT INTO quhead
24015
 
  ( quhead_id, quhead_number, quhead_cust_id, quhead_prj_id,
24016
 
    quhead_quotedate, quhead_packdate, quhead_fob,
24017
 
    quhead_warehous_id, quhead_terms_id, quhead_salesrep_id,
24018
 
    quhead_custponumber, quhead_shipvia,
24019
 
    quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3,
24020
 
    quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptophone, quhead_shiptocountry,
24021
 
    quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3,
24022
 
    quhead_billtocity, quhead_billtostate, quhead_billtozip,
24023
 
    quhead_misc_accnt_id, quhead_misc_descrip, quhead_misc, quhead_freight, quhead_commission,
24024
 
    quhead_ordercomments, quhead_shipcomments,
24025
 
    quhead_imported, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_ophead_id, quhead_status,
24026
 
    quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle,
24027
 
    quhead_shipto_cntct_last_name, quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title,
24028
 
    quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, quhead_billto_cntct_honorific,
24029
 
    quhead_billto_cntct_first_name, quhead_billto_cntct_middle, quhead_billto_cntct_last_name, quhead_billto_cntct_suffix,
24030
 
    quhead_billto_cntct_phone, quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email )
24031
 
  SELECT _quheadid, _qunumber, quhead_cust_id, quhead_prj_id,
24032
 
         CURRENT_DATE, COALESCE(pSchedDate, quhead_packdate), quhead_fob,
24033
 
         quhead_warehous_id, quhead_terms_id, quhead_salesrep_id,
24034
 
         quhead_custponumber, quhead_shipvia,
24035
 
         quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3,
24036
 
         quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptophone, quhead_shiptocountry,
24037
 
         quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3,
24038
 
         quhead_billtocity, quhead_billtostate, quhead_billtozip,
24039
 
         quhead_misc_accnt_id, quhead_misc_descrip, quhead_misc, quhead_freight, quhead_commission,
24040
 
         quhead_ordercomments, quhead_shipcomments,
24041
 
         FALSE, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_ophead_id, 'O',
24042
 
         quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle,
24043
 
         quhead_shipto_cntct_last_name, quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title,
24044
 
         quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, quhead_billto_cntct_honorific,
24045
 
         quhead_billto_cntct_first_name, quhead_billto_cntct_middle, quhead_billto_cntct_last_name, quhead_billto_cntct_suffix,
24046
 
         quhead_billto_cntct_phone, quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email
24047
 
  FROM quhead
24048
 
  WHERE (quhead_id=pQuheadid);
24049
 
 
24050
 
  INSERT INTO quitem
24051
 
  ( quitem_quhead_id, quitem_linenumber, quitem_itemsite_id,
24052
 
    quitem_scheddate, quitem_promdate, quitem_qtyord,
24053
 
    quitem_price, quitem_custprice, quitem_unitcost,
24054
 
    quitem_qty_uom_id, quitem_price_uom_id,
24055
 
    quitem_qty_invuomratio, quitem_price_invuomratio,
24056
 
    quitem_memo, quitem_custpn, quitem_imported, quitem_taxtype_id,
24057
 
    quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost,
24058
 
    quitem_dropship, quitem_itemsrc_id, quitem_pricemode )
24059
 
  SELECT _quheadid, quitem_linenumber, quitem_itemsite_id,
24060
 
         COALESCE(pSchedDate, quitem_scheddate),
24061
 
         quitem_promdate,
24062
 
         quitem_qtyord,
24063
 
         quitem_price, quitem_custprice, stdCost(itemsite_item_id),
24064
 
         quitem_qty_uom_id, quitem_price_uom_id,
24065
 
         quitem_qty_invuomratio, quitem_price_invuomratio,
24066
 
         quitem_memo, quitem_custpn, FALSE, quitem_taxtype_id,
24067
 
         quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost,
24068
 
         quitem_dropship, quitem_itemsrc_id, quitem_pricemode
24069
 
  FROM quitem, itemsite
24070
 
  WHERE ( (quitem_itemsite_id=itemsite_id)
24071
 
   AND (quitem_quhead_id=pQuheadid));
24072
 
 
24073
 
  INSERT INTO charass
24074
 
        (charass_target_type, charass_target_id,
24075
 
         charass_char_id, charass_value)
24076
 
  SELECT charass_target_type, b.quitem_id,
24077
 
         charass_char_id, charass_value
24078
 
    FROM quitem a, charass, quitem b
24079
 
   WHERE ((charass_target_type='SI')
24080
 
     AND  (charass_target_id=a.quitem_id)
24081
 
     AND  (a.quitem_quhead_id=pQuheadid)
24082
 
     AND  (b.quitem_quhead_id=_quheadid)
24083
 
     AND  (a.quitem_linenumber=b.quitem_linenumber)
24084
 
     );
24085
 
 
24086
 
  RETURN _quheadid;
24087
 
 
24088
 
END;
24089
 
$_$;
24090
 
 
24091
 
 
24092
 
ALTER FUNCTION public.copyquote(integer, date) OWNER TO admin;
24093
 
 
24094
 
--
24095
 
--
24096
 
 
24097
 
CREATE FUNCTION copyso(psoheadid integer, pscheddate date) RETURNS integer
24098
 
    LANGUAGE plpgsql
24099
 
    AS $$
24100
 
DECLARE
24101
 
  _soheadid INTEGER;
24102
 
  _soitemid INTEGER;
24103
 
  _soitem RECORD;
24104
 
 
24105
 
BEGIN
24106
 
 
24107
 
  SELECT NEXTVAL('cohead_cohead_id_seq') INTO _soheadid;
24108
 
 
24109
 
  INSERT INTO cohead
24110
 
  ( cohead_id,
24111
 
    cohead_number,
24112
 
    cohead_cust_id,
24113
 
    cohead_custponumber,
24114
 
    cohead_type,
24115
 
    cohead_orderdate,
24116
 
    cohead_warehous_id,
24117
 
    cohead_shipto_id,
24118
 
    cohead_shiptoname,
24119
 
    cohead_shiptoaddress1,
24120
 
    cohead_shiptoaddress2,
24121
 
    cohead_shiptoaddress3,
24122
 
    cohead_shiptoaddress4,
24123
 
    cohead_shiptoaddress5,
24124
 
    cohead_salesrep_id,
24125
 
    cohead_terms_id,
24126
 
    cohead_fob,
24127
 
    cohead_shipvia,
24128
 
    cohead_shiptocity,
24129
 
    cohead_shiptostate,
24130
 
    cohead_shiptozipcode,
24131
 
    cohead_freight,
24132
 
    cohead_misc,
24133
 
    cohead_imported,
24134
 
    cohead_ordercomments,
24135
 
    cohead_shipcomments,
24136
 
    cohead_shiptophone,
24137
 
    cohead_shipchrg_id,
24138
 
    cohead_shipform_id,
24139
 
    cohead_billtoname,
24140
 
    cohead_billtoaddress1,
24141
 
    cohead_billtoaddress2,
24142
 
    cohead_billtoaddress3,
24143
 
    cohead_billtocity,
24144
 
    cohead_billtostate,
24145
 
    cohead_billtozipcode,
24146
 
    cohead_misc_accnt_id,
24147
 
    cohead_misc_descrip,
24148
 
    cohead_commission,
24149
 
    cohead_miscdate,
24150
 
    cohead_holdtype,
24151
 
    cohead_packdate,
24152
 
    cohead_prj_id,
24153
 
    cohead_wasquote,
24154
 
    cohead_lastupdated,
24155
 
    cohead_shipcomplete,
24156
 
    cohead_created,
24157
 
    cohead_creator,
24158
 
    cohead_quote_number,
24159
 
    cohead_billtocountry,
24160
 
    cohead_shiptocountry,
24161
 
    cohead_curr_id,
24162
 
    cohead_calcfreight,
24163
 
    cohead_shipto_cntct_id,
24164
 
    cohead_shipto_cntct_honorific,
24165
 
    cohead_shipto_cntct_first_name,
24166
 
    cohead_shipto_cntct_middle,
24167
 
    cohead_shipto_cntct_last_name,
24168
 
    cohead_shipto_cntct_suffix,
24169
 
    cohead_shipto_cntct_phone,
24170
 
    cohead_shipto_cntct_title,
24171
 
    cohead_shipto_cntct_fax,
24172
 
    cohead_shipto_cntct_email,
24173
 
    cohead_billto_cntct_id,
24174
 
    cohead_billto_cntct_honorific,
24175
 
    cohead_billto_cntct_first_name,
24176
 
    cohead_billto_cntct_middle,
24177
 
    cohead_billto_cntct_last_name,
24178
 
    cohead_billto_cntct_suffix,
24179
 
    cohead_billto_cntct_phone,
24180
 
    cohead_billto_cntct_title,
24181
 
    cohead_billto_cntct_fax,
24182
 
    cohead_billto_cntct_email,
24183
 
    cohead_taxzone_id,
24184
 
    cohead_taxtype_id,
24185
 
    cohead_ophead_id,
24186
 
    cohead_status,
24187
 
    cohead_saletype_id,
24188
 
    cohead_shipzone_id )
24189
 
  SELECT
24190
 
    _soheadid,
24191
 
    fetchSoNumber(),
24192
 
    cohead_cust_id,
24193
 
    cohead_custponumber,
24194
 
    cohead_type,
24195
 
    CURRENT_DATE,
24196
 
    cohead_warehous_id,
24197
 
    cohead_shipto_id,
24198
 
    cohead_shiptoname,
24199
 
    cohead_shiptoaddress1,
24200
 
    cohead_shiptoaddress2,
24201
 
    cohead_shiptoaddress3,
24202
 
    cohead_shiptoaddress4,
24203
 
    cohead_shiptoaddress5,
24204
 
    cohead_salesrep_id,
24205
 
    cohead_terms_id,
24206
 
    cohead_fob,
24207
 
    cohead_shipvia,
24208
 
    cohead_shiptocity,
24209
 
    cohead_shiptostate,
24210
 
    cohead_shiptozipcode,
24211
 
    cohead_freight,
24212
 
    cohead_misc,
24213
 
    FALSE,
24214
 
    cohead_ordercomments,
24215
 
    cohead_shipcomments,
24216
 
    cohead_shiptophone,
24217
 
    cohead_shipchrg_id,
24218
 
    cohead_shipform_id,
24219
 
    cohead_billtoname,
24220
 
    cohead_billtoaddress1,
24221
 
    cohead_billtoaddress2,
24222
 
    cohead_billtoaddress3,
24223
 
    cohead_billtocity,
24224
 
    cohead_billtostate,
24225
 
    cohead_billtozipcode,
24226
 
    cohead_misc_accnt_id,
24227
 
    cohead_misc_descrip,
24228
 
    cohead_commission,
24229
 
    cohead_miscdate,
24230
 
    cohead_holdtype,
24231
 
    COALESCE(pSchedDate, cohead_packdate),
24232
 
    cohead_prj_id,
24233
 
    FALSE,
24234
 
    cohead_lastupdated,
24235
 
    cohead_shipcomplete,
24236
 
    NULL,
24237
 
    getEffectiveXtUser(),
24238
 
    NULL,
24239
 
    cohead_billtocountry,
24240
 
    cohead_shiptocountry,
24241
 
    cohead_curr_id,
24242
 
    cohead_calcfreight,
24243
 
    cohead_shipto_cntct_id,
24244
 
    cohead_shipto_cntct_honorific,
24245
 
    cohead_shipto_cntct_first_name,
24246
 
    cohead_shipto_cntct_middle,
24247
 
    cohead_shipto_cntct_last_name,
24248
 
    cohead_shipto_cntct_suffix,
24249
 
    cohead_shipto_cntct_phone,
24250
 
    cohead_shipto_cntct_title,
24251
 
    cohead_shipto_cntct_fax,
24252
 
    cohead_shipto_cntct_email,
24253
 
    cohead_billto_cntct_id,
24254
 
    cohead_billto_cntct_honorific,
24255
 
    cohead_billto_cntct_first_name,
24256
 
    cohead_billto_cntct_middle,
24257
 
    cohead_billto_cntct_last_name,
24258
 
    cohead_billto_cntct_suffix,
24259
 
    cohead_billto_cntct_phone,
24260
 
    cohead_billto_cntct_title,
24261
 
    cohead_billto_cntct_fax,
24262
 
    cohead_billto_cntct_email,
24263
 
    cohead_taxzone_id,
24264
 
    cohead_taxtype_id,
24265
 
    cohead_ophead_id,
24266
 
    cohead_status,
24267
 
    cohead_saletype_id,
24268
 
    cohead_shipzone_id
24269
 
  FROM cohead
24270
 
  WHERE (cohead_id=pSoheadid);
24271
 
 
24272
 
  FOR _soitem IN
24273
 
    SELECT *
24274
 
    FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
24275
 
    WHERE ( (coitem_cohead_id=pSoheadid)
24276
 
      AND   (coitem_status <> 'X')
24277
 
      AND   (coitem_subnumber = 0) ) LOOP
24278
 
 
24279
 
    SELECT NEXTVAL('coitem_coitem_id_seq') INTO _soitemid;
24280
 
 
24281
 
    -- insert characteristics first so they can be copied to associated supply order
24282
 
    INSERT INTO charass
24283
 
          (charass_target_type, charass_target_id,
24284
 
           charass_char_id, charass_value)
24285
 
    SELECT charass_target_type, _soitemid,
24286
 
           charass_char_id, charass_value
24287
 
      FROM charass
24288
 
     WHERE ((charass_target_type='SI')
24289
 
       AND  (charass_target_id=_soitem.coitem_id));
24290
 
 
24291
 
    INSERT INTO coitem
24292
 
    ( coitem_id,
24293
 
      coitem_cohead_id,
24294
 
      coitem_linenumber,
24295
 
      coitem_itemsite_id,
24296
 
      coitem_status,
24297
 
      coitem_scheddate,
24298
 
      coitem_promdate,
24299
 
      coitem_qtyord,
24300
 
      coitem_unitcost,
24301
 
      coitem_price,
24302
 
      coitem_custprice,
24303
 
      coitem_qtyshipped,
24304
 
      coitem_order_id,
24305
 
      coitem_memo,
24306
 
      coitem_imported,
24307
 
      coitem_qtyreturned,
24308
 
      coitem_closedate,
24309
 
      coitem_custpn,
24310
 
      coitem_order_type,
24311
 
      coitem_close_username,
24312
 
      coitem_substitute_item_id,
24313
 
      coitem_created,
24314
 
      coitem_creator,
24315
 
      coitem_prcost,
24316
 
      coitem_qty_uom_id,
24317
 
      coitem_qty_invuomratio,
24318
 
      coitem_price_uom_id,
24319
 
      coitem_price_invuomratio,
24320
 
      coitem_warranty,
24321
 
      coitem_cos_accnt_id,
24322
 
      coitem_qtyreserved,
24323
 
      coitem_subnumber,
24324
 
      coitem_firm,
24325
 
      coitem_taxtype_id )
24326
 
    VALUES
24327
 
    ( _soitemid,
24328
 
      _soheadid,
24329
 
      _soitem.coitem_linenumber,
24330
 
      _soitem.coitem_itemsite_id,
24331
 
      'O',
24332
 
      COALESCE(pSchedDate, _soitem.coitem_scheddate),
24333
 
      _soitem.coitem_promdate,
24334
 
      _soitem.coitem_qtyord,
24335
 
      stdCost(_soitem.itemsite_item_id),
24336
 
      _soitem.coitem_price,
24337
 
      _soitem.coitem_custprice,
24338
 
      0.0,
24339
 
      -1,
24340
 
      _soitem.coitem_memo,
24341
 
      FALSE,
24342
 
      0.0,
24343
 
      NULL,
24344
 
      _soitem.coitem_custpn,
24345
 
      _soitem.coitem_order_type,
24346
 
      NULL,
24347
 
      _soitem.coitem_substitute_item_id,
24348
 
      NULL,
24349
 
      getEffectiveXtUser(),
24350
 
      _soitem.coitem_prcost,
24351
 
      _soitem.coitem_qty_uom_id,
24352
 
      _soitem.coitem_qty_invuomratio,
24353
 
      _soitem.coitem_price_uom_id,
24354
 
      _soitem.coitem_price_invuomratio,
24355
 
      _soitem.coitem_warranty,
24356
 
      _soitem.coitem_cos_accnt_id,
24357
 
      0.0,
24358
 
      _soitem.coitem_subnumber,
24359
 
      _soitem.coitem_firm,
24360
 
      _soitem.coitem_taxtype_id );
24361
 
 
24362
 
  END LOOP;
24363
 
 
24364
 
  RETURN _soheadid;
24365
 
 
24366
 
END;
24367
 
$$;
24368
 
 
24369
 
 
24370
 
ALTER FUNCTION public.copyso(psoheadid integer, pscheddate date) OWNER TO admin;
24371
 
 
24372
 
--
24373
 
--
24374
 
 
24375
 
CREATE FUNCTION copytodoitem(integer, date, integer) RETURNS integer
24376
 
    LANGUAGE plpgsql
24377
 
    AS $_$
24378
 
DECLARE
24379
 
  pparentid   ALIAS FOR $1;
24380
 
  _duedate    DATE := COALESCE($2, CURRENT_DATE);
24381
 
  pincdtid    ALIAS FOR $3;
24382
 
  _alarmid    INTEGER;
24383
 
  _todoitemid INTEGER;
24384
 
 
24385
 
BEGIN
24386
 
  INSERT INTO todoitem(
24387
 
            todoitem_name,      todoitem_description,
24388
 
            todoitem_incdt_id,
24389
 
            todoitem_creator_username,                  todoitem_status,
24390
 
            todoitem_active,    todoitem_due_date,
24391
 
            todoitem_assigned_date,
24392
 
            todoitem_seq,       todoitem_notes,         todoitem_crmacct_id,
24393
 
            todoitem_ophead_id, todoitem_owner_username,todoitem_priority_id,
24394
 
            todoitem_username,  todoitem_recurring_todoitem_id
24395
 
  ) SELECT  todoitem_name,      todoitem_description,
24396
 
            CASE WHEN pincdtid IS NULL THEN todoitem_incdt_id ELSE pincdtid END,
24397
 
            getEffectiveXtUser(),                               'N',
24398
 
            TRUE,               _duedate,
24399
 
            CASE WHEN (todoitem_username IS NOT NULL) THEN CURRENT_DATE
24400
 
                 ELSE NULL
24401
 
            END,
24402
 
            todoitem_seq,       todoitem_notes,         todoitem_crmacct_id,
24403
 
            todoitem_ophead_id, todoitem_owner_username,todoitem_priority_id,
24404
 
            todoitem_username,  todoitem_recurring_todoitem_id
24405
 
      FROM todoitem
24406
 
     WHERE (todoitem_id=pparentid)
24407
 
  RETURNING todoitem_id INTO _todoitemid;
24408
 
 
24409
 
  IF (_todoitemid IS NULL) THEN
24410
 
    RETURN -10;
24411
 
  END IF;
24412
 
 
24413
 
  SELECT saveAlarm(NULL, NULL, _duedate,
24414
 
                   CAST(alarm_time - DATE_TRUNC('day',alarm_time) AS TIME),
24415
 
                   alarm_time_offset,
24416
 
                   alarm_time_qualifier,
24417
 
                   (alarm_event_recipient IS NOT NULL), alarm_event_recipient,
24418
 
                   (alarm_email_recipient IS NOT NULL AND fetchMetricBool('EnableBatchManager')), alarm_email_recipient,
24419
 
                   (alarm_sysmsg_recipient IS NOT NULL), alarm_sysmsg_recipient,
24420
 
                   'TODO', _todoitemid, 'CHANGEONE')
24421
 
    INTO _alarmid
24422
 
    FROM alarm
24423
 
   WHERE ((alarm_source='TODO')
24424
 
      AND (alarm_source_id=pparentid));
24425
 
 
24426
 
   IF (_alarmid < 0) THEN
24427
 
     RETURN _alarmid;
24428
 
   END IF;
24429
 
 
24430
 
  RETURN _todoitemid;
24431
 
END;
24432
 
$_$;
24433
 
 
24434
 
 
24435
 
ALTER FUNCTION public.copytodoitem(integer, date, integer) OWNER TO admin;
24436
 
 
24437
 
--
24438
 
--
24439
 
 
24440
 
CREATE FUNCTION copyvoucher(integer, date) RETURNS integer
24441
 
    LANGUAGE plpgsql
24442
 
    AS $_$
24443
 
DECLARE
24444
 
  pVoheadid ALIAS FOR $1;
24445
 
  _voheadid INTEGER;
24446
 
  _vonumber TEXT;
24447
 
  _vodate DATE := COALESCE($2, CURRENT_DATE);
24448
 
  _i RECORD;
24449
 
  _l RECORD;
24450
 
  _vodistid INTEGER;
24451
 
 
24452
 
BEGIN
24453
 
  SELECT *
24454
 
    INTO _i
24455
 
    FROM vohead
24456
 
   WHERE(vohead_id=pVoheadid);
24457
 
  IF(NOT FOUND) THEN
24458
 
    RETURN -1;
24459
 
  END IF;
24460
 
 
24461
 
  _vonumber := fetchVoNumber();
24462
 
  _voheadid := nextval('vohead_vohead_id_seq');
24463
 
 
24464
 
  INSERT INTO vohead
24465
 
        (vohead_id,
24466
 
         vohead_number, vohead_pohead_id,
24467
 
         vohead_posted, vohead_duedate,
24468
 
         vohead_invcnumber, vohead_amount,
24469
 
         vohead_docdate, vohead_1099,
24470
 
         vohead_distdate, vohead_reference,
24471
 
         vohead_terms_id, vohead_vend_id,
24472
 
         vohead_curr_id, vohead_adjtaxtype_id,
24473
 
         vohead_freighttaxtype_id, vohead_gldistdate,
24474
 
         vohead_misc, vohead_taxzone_id,
24475
 
         vohead_taxtype_id, vohead_notes,
24476
 
         vohead_recurring_vohead_id )
24477
 
  VALUES(_voheadid,
24478
 
         _vonumber, _i.vohead_pohead_id,
24479
 
         false, determineDueDate(_i.vohead_terms_id, _vodate),
24480
 
         _i.vohead_invcnumber, _i.vohead_amount,
24481
 
         _vodate, _i.vohead_1099,
24482
 
         _vodate, _i.vohead_reference,
24483
 
         _i.vohead_terms_id, _i.vohead_vend_id,
24484
 
         _i.vohead_curr_id, _i.vohead_adjtaxtype_id,
24485
 
         _i.vohead_freighttaxtype_id, _vodate,
24486
 
         _i.vohead_misc, _i.vohead_taxzone_id,
24487
 
         _i.vohead_taxtype_id, _i.vohead_notes,
24488
 
         _i.vohead_recurring_vohead_id);
24489
 
 
24490
 
  FOR _l IN SELECT *
24491
 
            FROM vodist
24492
 
            WHERE (vodist_vohead_id=pVoheadid) LOOP
24493
 
    SELECT NEXTVAL('vodist_vodist_id_seq') INTO _vodistid;
24494
 
 
24495
 
    INSERT INTO vodist
24496
 
        (vodist_id, vodist_poitem_id,
24497
 
         vodist_vohead_id, vodist_costelem_id,
24498
 
         vodist_accnt_id, vodist_amount,
24499
 
         vodist_qty, vodist_expcat_id,
24500
 
         vodist_tax_id, vodist_discountable,
24501
 
         vodist_notes)
24502
 
    VALUES
24503
 
        (_vodistid, _l.vodist_poitem_id,
24504
 
         _voheadid, _l.vodist_costelem_id,
24505
 
         _l.vodist_accnt_id, _l.vodist_amount,
24506
 
         _l.vodist_qty, _l.vodist_expcat_id,
24507
 
         _l.vodist_tax_id, _l.vodist_discountable,
24508
 
         _l.vodist_notes);
24509
 
 
24510
 
  END LOOP;
24511
 
 
24512
 
  RETURN _voheadid;
24513
 
END;
24514
 
$_$;
24515
 
 
24516
 
 
24517
 
ALTER FUNCTION public.copyvoucher(integer, date) OWNER TO admin;
24518
 
 
24519
 
--
24520
 
--
24521
 
 
24522
 
CREATE FUNCTION correctporeceipt(integer, numeric, numeric, integer) RETURNS integer
24523
 
    LANGUAGE plpgsql
24524
 
    AS $_$
24525
 
DECLARE
24526
 
  pPorecvid ALIAS FOR $1;
24527
 
  pQty ALIAS FOR $2;
24528
 
  pFreight ALIAS FOR $3;
24529
 
  pItemlocSeries ALIAS FOR $4;
24530
 
 
24531
 
BEGIN
24532
 
  RETURN correctReceipt('PO', $1, $2, $3, $4, NULL, NULL);
24533
 
END;
24534
 
$_$;
24535
 
 
24536
 
 
24537
 
ALTER FUNCTION public.correctporeceipt(integer, numeric, numeric, integer) OWNER TO admin;
24538
 
 
24539
 
--
24540
 
--
24541
 
 
24542
 
CREATE FUNCTION correctporeceipt(integer, numeric, numeric, integer, integer, date) RETURNS integer
24543
 
    LANGUAGE plpgsql
24544
 
    AS $_$
24545
 
BEGIN
24546
 
  RETURN correctReceipt('PO', $1, $2, $3, $4, $5, $6);
24547
 
END;
24548
 
$_$;
24549
 
 
24550
 
 
24551
 
ALTER FUNCTION public.correctporeceipt(integer, numeric, numeric, integer, integer, date) OWNER TO admin;
24552
 
 
24553
 
--
24554
 
--
24555
 
 
24556
 
CREATE FUNCTION correctproduction(integer, numeric, boolean, boolean) RETURNS integer
24557
 
    LANGUAGE plpgsql
24558
 
    AS $_$
24559
 
BEGIN
24560
 
  RAISE NOTICE 'correctProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN) has been deprecated. Use corrrectProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER) or a package-specific version instead.';
24561
 
  RETURN  correctProduction($1, $2, $3, 0, now());
24562
 
END;
24563
 
$_$;
24564
 
 
24565
 
 
24566
 
ALTER FUNCTION public.correctproduction(integer, numeric, boolean, boolean) OWNER TO admin;
24567
 
 
24568
 
--
24569
 
--
24570
 
 
24571
 
CREATE FUNCTION correctproduction(integer, numeric, boolean, boolean, integer) RETURNS integer
24572
 
    LANGUAGE plpgsql
24573
 
    AS $_$
24574
 
BEGIN
24575
 
  RAISE NOTICE 'correctProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN, INTEGER) has been deprecated. Use corrrectProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER) or a package-specific version instead.';
24576
 
  RETURN correctProduction($1, $2, $3, $5, now());
24577
 
END;
24578
 
$_$;
24579
 
 
24580
 
 
24581
 
ALTER FUNCTION public.correctproduction(integer, numeric, boolean, boolean, integer) OWNER TO admin;
24582
 
 
24583
 
--
24584
 
--
24585
 
 
24586
 
CREATE FUNCTION correctproduction(integer, numeric, boolean, integer, timestamp with time zone) RETURNS integer
24587
 
    LANGUAGE plpgsql
24588
 
    AS $_$
24589
 
DECLARE
24590
 
  pWoid          ALIAS FOR $1;
24591
 
  pQty           ALIAS FOR $2;
24592
 
  pBackflush     ALIAS FOR $3;
24593
 
  pItemlocSeries ALIAS FOR $4;
24594
 
  pGlDistTS      ALIAS FOR $5;
24595
 
BEGIN
24596
 
  RETURN correctProduction($1, $2, $3, $4, $5, NULL);
24597
 
END;
24598
 
$_$;
24599
 
 
24600
 
 
24601
 
ALTER FUNCTION public.correctproduction(integer, numeric, boolean, integer, timestamp with time zone) OWNER TO admin;
24602
 
 
24603
 
--
24604
 
--
24605
 
 
24606
 
CREATE FUNCTION correctproduction(integer, numeric, boolean, integer, timestamp with time zone, integer) RETURNS integer
24607
 
    LANGUAGE plpgsql
24608
 
    AS $_$
24609
 
DECLARE
24610
 
  pWoid          ALIAS FOR $1;
24611
 
  pQty           ALIAS FOR $2;
24612
 
  pBackflush     ALIAS FOR $3;
24613
 
  pItemlocSeries ALIAS FOR $4;
24614
 
  pGlDistTS      ALIAS FOR $5;
24615
 
  pInvhistId     ALIAS FOR $6;
24616
 
  _invhistid        INTEGER;
24617
 
  _itemlocSeries    INTEGER;
24618
 
  _r                RECORD;
24619
 
  _parentWIPAccntid INTEGER;
24620
 
  _parentQty        NUMERIC;
24621
 
  _qty              NUMERIC;
24622
 
  _wipPost          NUMERIC;
24623
 
  _sense            TEXT;
24624
 
  _status           TEXT;
24625
 
  _type             TEXT;
24626
 
  _qtyfxd           NUMERIC := 0;
24627
 
 
24628
 
BEGIN
24629
 
 
24630
 
  -- Qty is positive for Assembly W/O
24631
 
  -- Qty is negative for Disassembly W/O
24632
 
  IF (pQty = 0) THEN
24633
 
    RETURN pItemlocseries;
24634
 
  ELSIF (pQty > 0) THEN
24635
 
    _sense := 'from';
24636
 
  ELSE
24637
 
    _sense := 'to';
24638
 
  END IF;
24639
 
 
24640
 
  SELECT item_type, roundQty(item_fractional, pQty), wo_status
24641
 
    INTO _type, _parentQty, _status
24642
 
    FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)
24643
 
            JOIN item ON (item_id=itemsite_item_id)
24644
 
   WHERE (wo_id=pWoid);
24645
 
  
24646
 
  IF (_status != 'I') THEN
24647
 
    RETURN -1;
24648
 
  END IF;
24649
 
 
24650
 
  IF (_type = 'J') THEN
24651
 
    RETURN -2;
24652
 
  END IF;
24653
 
 
24654
 
  IF (pItemlocSeries = 0) THEN
24655
 
    SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
24656
 
  ELSE
24657
 
    _itemlocSeries := pItemlocSeries;
24658
 
  END IF;
24659
 
 
24660
 
  --  Calculate the WIP to correct 
24661
 
  SELECT CASE WHEN (wo_cosmethod = 'D') THEN wo_postedvalue
24662
 
              ELSE  round(((wo_postedvalue - wo_wipvalue) / wo_qtyrcv * _parentQty), 2)
24663
 
         END INTO _wipPost
24664
 
  FROM wo
24665
 
  WHERE (wo_id=pWoid);
24666
 
 
24667
 
  --  Post the inventory transaction
24668
 
  SELECT postInvTrans( itemsite_id, 'RM', (_parentQty * -1.0),
24669
 
                       'W/O', 'WO', formatwonumber(pWoid), '',
24670
 
                       ('Correct Receive Inventory ' || item_number || ' ' || _sense || ' Manufacturing'),
24671
 
                       costcat_asset_accnt_id, getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), _itemlocSeries, pGlDistTS,
24672
 
                       (_wipPost * -1.0), -- only used when cost is average
24673
 
                       pInvhistId) INTO _invhistid
24674
 
  FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)
24675
 
          JOIN item ON (item_id=itemsite_item_id)
24676
 
          JOIN costcat ON (costcat_id=itemsite_costcat_id)
24677
 
  WHERE (wo_id=pWoid);
24678
 
 
24679
 
  --  Decrease this W/O's qty. received and increase its WIP value
24680
 
  UPDATE wo
24681
 
  SET wo_qtyrcv = (wo_qtyrcv - _parentQty),
24682
 
      wo_wipvalue = (wo_wipvalue + (CASE WHEN(itemsite_costmethod IN ('A','J'))
24683
 
                                              THEN _wipPost
24684
 
                                         WHEN(itemsite_costmethod='S')
24685
 
                                              THEN stdcost(itemsite_item_id) * _parentQty
24686
 
                                         ELSE 0.0 END))
24687
 
  FROM itemsite
24688
 
  WHERE ( (wo_itemsite_id=itemsite_id)
24689
 
   AND (wo_id=pWoid) );
24690
 
 
24691
 
  IF (pBackflush) THEN
24692
 
    FOR _r IN SELECT item_id, item_fractional,
24693
 
                      itemsite_id, itemsite_warehous_id,
24694
 
                      itemsite_controlmethod, itemsite_loccntrl,
24695
 
                      itemsite_costmethod, 
24696
 
                      wo_qtyrcv, wo_prj_id,
24697
 
                      womatl_id, womatl_qtyfxd, womatl_qtyper,
24698
 
                      womatl_scrap, womatl_issuemethod, womatl_uom_id
24699
 
               FROM wo JOIN womatl ON (womatl_wo_id=wo_id AND womatl_issuemethod='L')
24700
 
                       JOIN itemsite ON (itemsite_id=womatl_itemsite_id)
24701
 
                       JOIN item ON (item_id=itemsite_item_id)
24702
 
               WHERE (wo_id=pWoid) LOOP
24703
 
 
24704
 
      --  Cache the qty to be issued
24705
 
      -- If going back to beginning, unissue fixed qty as well
24706
 
      IF (_r.wo_qtyrcv - _parentQty > 0) THEN
24707
 
        _qtyfxd := 0;
24708
 
      ELSE
24709
 
        _qtyfxd := _r.womatl_qtyfxd;
24710
 
      END IF;
24711
 
      
24712
 
      _qty = roundQty(_r.item_fractional, (_qtyfxd + _parentQty * _r.womatl_qtyper) * (1 + _r.womatl_scrap));
24713
 
 
24714
 
      IF (_qty > 0) THEN
24715
 
        SELECT returnWoMaterial(_r.womatl_id, _qty, _itemlocSeries, pGlDistTS) INTO _itemlocSeries;
24716
 
      END IF;
24717
 
 
24718
 
    END LOOP;
24719
 
 
24720
 
        --  BEGIN ROB Decrease this W/O's WIP value for custom costing
24721
 
          UPDATE wo
24722
 
          SET wo_wipvalue = (wo_wipvalue - (itemcost_stdcost * _parentQty)) 
24723
 
        FROM costelem, itemcost, costcat, itemsite, item
24724
 
        WHERE 
24725
 
          ((wo_id=pWoid) AND
24726
 
          (wo_itemsite_id=itemsite_id) AND
24727
 
          (itemsite_item_id=item_id) AND
24728
 
          (costelem_id = itemcost_costelem_id) AND
24729
 
          (itemcost_item_id = itemsite_item_id) AND
24730
 
          (itemsite_costcat_id = costcat_id) AND
24731
 
          (costelem_exp_accnt_id) IS NOT NULL  AND 
24732
 
          (costelem_sys = false));
24733
 
 
24734
 
        --  ROB Distribute to G/L - create Cost Variance, debit WIP
24735
 
          PERFORM insertGLTransaction( 'W/O', 'WO', formatwonumber(pWoid),
24736
 
                                       ('Correct Post Other Cost ' || item_number || ' ' || _sense || ' Manufacturing'),
24737
 
                                       getPrjAccntId(wo_prj_id, costelem_exp_accnt_id), 
24738
 
                                       getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), _invhistid,
24739
 
                                       ((itemcost_stdcost * _parentQty)* -1),
24740
 
                                       CURRENT_DATE )
24741
 
        FROM wo, costelem, itemcost, costcat, itemsite, item
24742
 
        WHERE 
24743
 
          ((wo_id=pWoid) AND
24744
 
          (wo_itemsite_id=itemsite_id) AND
24745
 
          (itemsite_item_id=item_id) AND
24746
 
          (costelem_id = itemcost_costelem_id) AND
24747
 
          (itemcost_item_id = itemsite_item_id) AND
24748
 
          (itemsite_costcat_id = costcat_id) AND
24749
 
          (costelem_exp_accnt_id) IS NOT NULL  AND 
24750
 
          (costelem_sys = false));
24751
 
        --End ROB
24752
 
 
24753
 
  END IF;
24754
 
 
24755
 
  RETURN _itemlocSeries;
24756
 
 
24757
 
END;
24758
 
$_$;
24759
 
 
24760
 
 
24761
 
ALTER FUNCTION public.correctproduction(integer, numeric, boolean, integer, timestamp with time zone, integer) OWNER TO admin;
24762
 
 
24763
 
--
24764
 
--
24765
 
 
24766
 
CREATE FUNCTION correctreceipt(integer, numeric, numeric, integer, integer, date) RETURNS integer
24767
 
    LANGUAGE plpgsql
24768
 
    AS $_$
24769
 
BEGIN
24770
 
  RETURN correctReceipt($1, $2, $3, $4, $5, $6, NULL);
24771
 
END;
24772
 
$_$;
24773
 
 
24774
 
 
24775
 
ALTER FUNCTION public.correctreceipt(integer, numeric, numeric, integer, integer, date) OWNER TO admin;
24776
 
 
24777
 
--
24778
 
--
24779
 
 
24780
 
CREATE FUNCTION correctreceipt(integer, numeric, numeric, integer, integer, date, numeric) RETURNS integer
24781
 
    LANGUAGE plpgsql
24782
 
    AS $_$
24783
 
DECLARE
24784
 
  precvid               ALIAS FOR $1;
24785
 
  pQty                  ALIAS FOR $2;
24786
 
  pFreight              ALIAS FOR $3;
24787
 
  _itemlocSeries        INTEGER := COALESCE($4, 0);
24788
 
  _currid               INTEGER := $5;
24789
 
  pEffective            ALIAS FOR $6;
24790
 
  pRecvCost             ALIAS FOR $7;
24791
 
  _freight              NUMERIC;
24792
 
  _qty                  NUMERIC;
24793
 
  _invhistid            INTEGER;
24794
 
  _o                    RECORD;
24795
 
  _r                    RECORD;
24796
 
  _recvcost             NUMERIC;
24797
 
  _tmp        INTEGER;
24798
 
  _pricevar             NUMERIC := 0.00;
24799
 
  _journalNumber INTEGER := fetchJournalNumber('GL-MISC');
24800
 
 
24801
 
BEGIN
24802
 
  SELECT recv_qty, recv_date::DATE AS recv_date, recv_freight_curr_id,
24803
 
         recv_orderitem_id,
24804
 
         round(currToCurr(recv_freight_curr_id,
24805
 
                          COALESCE(_currid, recv_freight_curr_id),
24806
 
         recv_freight, recv_date::DATE),2) AS recv_freight,
24807
 
         recv_posted, recv_order_type,
24808
 
         COALESCE(itemsite_id, -1) AS itemsiteid,
24809
 
         itemsite_item_id, itemsite_costmethod, itemsite_controlmethod,
24810
 
         (recv_splitfrom_id IS NOT NULL
24811
 
         OR (SELECT (count(*) > 0) 
24812
 
             FROM recv
24813
 
             WHERE (recv_splitfrom_id=recv_id))) AS split INTO _r
24814
 
  FROM recv LEFT OUTER JOIN itemsite ON (recv_itemsite_id=itemsite_id)
24815
 
  WHERE (recv_id=precvid);
24816
 
 
24817
 
  IF (NOT FOUND) THEN
24818
 
    RETURN _itemlocSeries;
24819
 
  END IF;
24820
 
 
24821
 
  IF (NOT _r.recv_order_type IN ('PO', 'RA', 'TO')) THEN
24822
 
    RETURN -11;
24823
 
  END IF;
24824
 
 
24825
 
  IF (_r.split) THEN
24826
 
    RETURN -12;
24827
 
  END IF;
24828
 
 
24829
 
  SELECT currToBase(orderitem_unitcost_curr_id, orderitem_unitcost,
24830
 
                    _r.recv_date::DATE) AS unitprice_base,
24831
 
         orderhead_number, orderitem_linenumber,
24832
 
         orderhead_curr_id AS freight_curr_id,
24833
 
         orderitem_orderhead_type,
24834
 
         orderitem_qty_invuomratio INTO _o
24835
 
  FROM orderhead, orderitem
24836
 
  WHERE ((orderhead_id=orderitem_orderhead_id)
24837
 
    AND  (orderhead_type=orderitem_orderhead_type)
24838
 
    AND  (orderitem_id=_r.recv_orderitem_id)
24839
 
    AND  (orderitem_orderhead_type=_r.recv_order_type));
24840
 
 
24841
 
  IF (NOT FOUND) THEN
24842
 
    RETURN _itemlocSeries;
24843
 
  END IF;
24844
 
 
24845
 
  -- Default to _o.orderitem_unitcost if recv_purchcost is not supplied
24846
 
  -- Note: this should never happen, a value is always supplied
24847
 
  if (pRecvCost IS NULL) THEN
24848
 
    _recvcost := _o.orderitem_unitcost;
24849
 
  ELSE
24850
 
    -- Note: if the receipt has already been posted, pRecvCost will always 
24851
 
    --       equal the original recv_purchcost (cannot be modified in GUI)
24852
 
    _recvcost := pRecvCost; 
24853
 
  END IF;
24854
 
 
24855
 
  IF (_r.recv_posted) THEN
24856
 
    _qty := (pQty - _r.recv_qty);
24857
 
    IF (_qty <> 0) THEN
24858
 
      IF (_r.itemsiteid = -1) THEN
24859
 
        PERFORM insertGLTransaction( _journalNumber,'S/R',
24860
 
                                     _r.recv_order_type,
24861
 
                                     _o.orderhead_number,
24862
 
                                     'Receive Non-Inventory from ' || _r.recv_order_type,
24863
 
                                     expcat_liability_accnt_id,
24864
 
                                     getPrjAccntId(poitem_prj_id, expcat_exp_accnt_id),
24865
 
                                     -1,
24866
 
                                     ROUND(_o.unitprice_base * _qty, 2),
24867
 
                                     pEffective )
24868
 
        FROM poitem, expcat
24869
 
        WHERE ((poitem_expcat_id=expcat_id)
24870
 
          AND  (poitem_id=_r.recv_orderitem_id)
24871
 
          AND  (_o.orderitem_orderhead_type='PO'));
24872
 
 
24873
 
        UPDATE recv
24874
 
        SET recv_qty=pQty,
24875
 
            recv_value=(recv_value + ROUND(_o.unitprice_base * _qty, 2)),
24876
 
            recv_date = pEffective
24877
 
        WHERE (recv_id=precvid);
24878
 
      ELSEIF (_r.itemsite_controlmethod = 'N') THEN
24879
 
        PERFORM insertGLTransaction( _journalNumber,'S/R',
24880
 
                                     _r.recv_order_type,
24881
 
                                     _o.orderhead_number,
24882
 
                                     'Receive Non-Controlled Inventory from ' || _r.recv_order_type,
24883
 
                                     costcat_liability_accnt_id,
24884
 
                                     getPrjAccntId(poitem_prj_id, costcat_exp_accnt_id),
24885
 
                                     -1,
24886
 
                                     ROUND(_o.unitprice_base * _qty, 2),
24887
 
                                     pEffective )
24888
 
        FROM poitem, itemsite, costcat
24889
 
        WHERE ((poitem_itemsite_id=itemsite_id)
24890
 
          AND  (itemsite_costcat_id=costcat_id)
24891
 
          AND  (poitem_id=_r.recv_orderitem_id)
24892
 
          AND  (_o.orderitem_orderhead_type='PO'));
24893
 
 
24894
 
        UPDATE recv
24895
 
        SET recv_qty=pQty,
24896
 
            recv_value=(recv_value + ROUND(_o.unitprice_base * _qty, 2)),
24897
 
            recv_date = pEffective
24898
 
        WHERE (recv_id=precvid);
24899
 
      ELSE
24900
 
        IF (_itemlocSeries = 0 OR _itemlocSeries IS NULL) THEN
24901
 
          _itemlocSeries := NEXTVAL('itemloc_series_seq');
24902
 
        END IF;
24903
 
 
24904
 
  SELECT postInvTrans( itemsite_id, 'RP',
24905
 
                             (_qty * _o.orderitem_qty_invuomratio),
24906
 
                             'S/R', _r.recv_order_type,
24907
 
                             _o.orderhead_number::TEXT || '-' || _o.orderitem_linenumber::TEXT, '',
24908
 
                             'Receive Inventory from ' || _r.recv_order_type,
24909
 
                             costcat_asset_accnt_id,
24910
 
                             costcat_liability_accnt_id,
24911
 
                             _itemlocSeries, pEffective,
24912
 
           ROUND(_recvcost * _qty, 2) -- alway passing since it is ignored if not average costed item
24913
 
                           ) INTO _tmp
24914
 
        FROM itemsite, costcat
24915
 
        WHERE ((itemsite_costcat_id=costcat_id)
24916
 
    AND  (itemsite_id=_r.itemsiteid) );
24917
 
 
24918
 
        IF(_r.itemsite_costmethod='A') THEN
24919
 
          UPDATE recv
24920
 
             SET recv_qty=pQty,
24921
 
                 recv_value=(recv_value + _recvcost * _qty * _o.orderitem_qty_invuomratio),
24922
 
                 recv_date = pEffective
24923
 
           WHERE(recv_id=precvid);
24924
 
        ELSE
24925
 
          UPDATE recv
24926
 
             SET recv_qty=pQty,
24927
 
                 recv_value=(recv_value + stdcost(_r.itemsite_item_id) * _qty * _o.orderitem_qty_invuomratio),
24928
 
                 recv_date = pEffective
24929
 
           WHERE(recv_id=precvid);
24930
 
        END IF;
24931
 
    END IF;
24932
 
 
24933
 
      IF (_r.recv_order_type = 'PO') THEN
24934
 
        UPDATE poitem
24935
 
        SET poitem_qty_received=(poitem_qty_received + _qty)
24936
 
        WHERE (poitem_id=_r.recv_orderitem_id);
24937
 
      ELSIF (_r.recv_order_type = 'RA' AND fetchMetricBool('EnableReturnAuth')) THEN
24938
 
        UPDATE raitem
24939
 
        SET raitem_qtyreceived=(raitem_qtyreceived + _qty)
24940
 
        WHERE (raitem_id=_r.recv_orderitem_id);
24941
 
      ELSIF (_r.recv_order_type = 'TO' AND fetchMetricBool('MultiWhs')) THEN
24942
 
        UPDATE toitem
24943
 
        SET toitem_qty_received=(toitem_qty_received + _qty)
24944
 
        WHERE (toitem_id=_r.recv_orderitem_id);
24945
 
      END IF;
24946
 
 
24947
 
    END IF;
24948
 
 
24949
 
       IF (fetchMetricBool('RecordPPVonReceipt')) THEN -- If the 'Purchase Price Variance on Receipt' option is true
24950
 
         _invhistid := _tmp;
24951
 
         -- Find the difference in the purchase price value expected from the P/O and the value of the transaction
24952
 
         SELECT (((currToBase(pohead_curr_id,
24953
 
         COALESCE(recv_purchcost, poitem_unitprice),
24954
 
         recv_date::DATE)) * _qty) - (invhist_value_after - invhist_value_before)) INTO _pricevar
24955
 
         FROM invhist, recv, pohead, poitem
24956
 
         WHERE ((recv_orderitem_id=poitem_id)
24957
 
           AND  (poitem_pohead_id=pohead_id)
24958
 
           AND  (recv_id=precvid)
24959
 
           AND  (invhist_id = _invhistid));
24960
 
 
24961
 
         -- If difference exists then
24962
 
         IF (_pricevar <> 0.00) THEN
24963
 
           -- Record an additional GL Transaction for the purchase price variance
24964
 
           SELECT insertGLTransaction( _journalNumber,
24965
 
                'S/R', _r.recv_order_type, _o.orderhead_number,
24966
 
                                       'Purchase price variance adjusted for P/O ' || _o.orderhead_number || ' for item ' || _o.orderitem_linenumber::TEXT,
24967
 
                                       costcat_liability_accnt_id,
24968
 
                                       getPrjAccntId(poitem_prj_id, costcat_purchprice_accnt_id), -1,
24969
 
                                       _pricevar,
24970
 
                                       pEffective, false ) INTO _tmp
24971
 
           FROM itemsite, costcat, poitem, recv
24972
 
           WHERE ((itemsite_costcat_id=costcat_id)
24973
 
              AND (recv_id=precvid)
24974
 
              AND (recv_orderitem_id=poitem_id)
24975
 
              AND (itemsite_id=recv_itemsite_id) );
24976
 
           IF (NOT FOUND) THEN
24977
 
             RAISE EXCEPTION 'Could not insert G/L transaction: no cost category found for itemsite_id %',
24978
 
             _r.itemsite_id;
24979
 
           ELSIF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction
24980
 
             RETURN _tmp;
24981
 
           ELSE
24982
 
             -- Posting to trial balance is deferred to prevent locking
24983
 
             INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries)
24984
 
             VALUES ( _tmp, _itemlocSeries );
24985
 
           END IF;
24986
 
         END IF;
24987
 
       END IF;
24988
 
 
24989
 
    _freight := (pFreight - _r.recv_freight);
24990
 
    IF (_freight <> 0) THEN
24991
 
 
24992
 
      IF (_r.itemsiteid = -1) THEN
24993
 
  PERFORM insertGLTransaction( _journalNumber,'S/R', _r.recv_order_type,
24994
 
                                     _o.orderhead_number,
24995
 
                                    'Receive Non-Inventory Freight from ' || _r.recv_order_type,
24996
 
             expcat_liability_accnt_id, getPrjAccntId(poitem_prj_id, expcat_freight_accnt_id), -1,
24997
 
                                      ROUND(currToBase(_currid, _freight,
24998
 
                                                    pEffective), 2),
24999
 
                                     pEffective )
25000
 
        FROM poitem, expcat
25001
 
        WHERE ((poitem_expcat_id=expcat_id)
25002
 
          AND  (poitem_id=_r.recv_orderitem_id)
25003
 
          AND  (_r.recv_order_type='PO'));
25004
 
      ELSE
25005
 
  PERFORM insertGLTransaction(_journalNumber,'S/R', _r.recv_order_type,
25006
 
                                    _o.orderhead_number, 
25007
 
                                    'Receive Non-Inventory Freight from ' ||
25008
 
                                                            _r.recv_order_type,
25009
 
                                   costcat_liability_accnt_id,
25010
 
                                   costcat_freight_accnt_id, -1,
25011
 
                                   round(currToBase(_currid, _freight,
25012
 
                                                    pEffective), 2),
25013
 
                                   pEffective )
25014
 
        FROM itemsite, costcat
25015
 
        WHERE ( (itemsite_costcat_id=costcat_id)
25016
 
          AND   (itemsite_id=_r.itemsiteid) );
25017
 
      END IF;
25018
 
 
25019
 
      IF (_r.recv_order_type = 'PO') THEN
25020
 
        UPDATE poitem
25021
 
        SET poitem_freight_received=(poitem_freight_received +
25022
 
                                   currToCurr(_currid, _o.freight_curr_id,
25023
 
                                              _freight, pEffective))
25024
 
        WHERE (poitem_id=_r.recv_orderitem_id);
25025
 
 
25026
 
      -- raitem does not track freight
25027
 
 
25028
 
      ELSEIF (_r.recv_order_type = 'TO' AND fetchMetricBool('MultiWhs')) THEN
25029
 
        UPDATE toitem
25030
 
        SET toitem_freight_received=(toitem_freight_received +
25031
 
                                   currToCurr(_currid, _o.freight_curr_id,
25032
 
                                              _freight, pEffective))
25033
 
        WHERE (toitem_id=_r.recv_orderitem_id);
25034
 
      END IF;
25035
 
 
25036
 
      UPDATE recv
25037
 
      SET recv_freight=currToCurr(_currid, recv_freight_curr_id, pFreight,
25038
 
                                  pEffective),
25039
 
          recv_date = pEffective
25040
 
      WHERE (recv_id=precvid);
25041
 
    END IF;
25042
 
 
25043
 
  ELSE
25044
 
 
25045
 
    UPDATE recv SET recv_qty=pQty, recv_freight=pFreight, recv_purchcost=_recvcost WHERE recv_id=precvid;
25046
 
  END IF;
25047
 
 
25048
 
RETURN _itemlocSeries;
25049
 
 
25050
 
END;
25051
 
$_$;
25052
 
 
25053
 
 
25054
 
ALTER FUNCTION public.correctreceipt(integer, numeric, numeric, integer, integer, date, numeric) OWNER TO admin;
25055
 
 
25056
 
--
25057
 
--
25058
 
 
25059
 
CREATE FUNCTION cosbycustomervalue(integer, integer) RETURNS numeric
25060
 
    LANGUAGE plpgsql
25061
 
    AS $_$
25062
 
DECLARE
25063
 
  pCustid ALIAS FOR $1;
25064
 
  pPeriodid ALIAS FOR $2;
25065
 
  _value NUMERIC;
25066
 
  _startDate DATE;
25067
 
  _endDate DATE;
25068
 
 
25069
 
BEGIN
25070
 
 
25071
 
  _startDate := findPeriodStart(pPeriodid);
25072
 
  _endDate := findPeriodEnd(pPeriodid);
25073
 
 
25074
 
  SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value
25075
 
  FROM cohist
25076
 
  WHERE ( (cohist_cust_id=pCustid)
25077
 
   AND (cohist_invcdate BETWEEN _startDate AND _endDate) );
25078
 
 
25079
 
  IF (_value IS NULL) THEN
25080
 
    _value := 0;
25081
 
  END IF;
25082
 
 
25083
 
  RETURN _value;
25084
 
 
25085
 
END;
25086
 
$_$;
25087
 
 
25088
 
 
25089
 
ALTER FUNCTION public.cosbycustomervalue(integer, integer) OWNER TO admin;
25090
 
 
25091
 
--
25092
 
--
25093
 
 
25094
 
CREATE FUNCTION costsbycustomerbyitemsite(integer, integer, integer) RETURNS numeric
25095
 
    LANGUAGE plpgsql
25096
 
    AS $_$
25097
 
DECLARE
25098
 
  pCustid ALIAS FOR $1;
25099
 
  pItemsiteid ALIAS FOR $2;
25100
 
  pPeriodid ALIAS FOR $3;
25101
 
  _value NUMERIC;
25102
 
  _startDate DATE;
25103
 
  _endDate DATE;
25104
 
 
25105
 
BEGIN
25106
 
 
25107
 
  _startDate := findPeriodStart(pPeriodid);
25108
 
  _endDate := findPeriodEnd(pPeriodid);
25109
 
 
25110
 
  SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value
25111
 
  FROM cohist
25112
 
  WHERE ( (cohist_itemsite_id<>pItemsiteid)
25113
 
   AND (cohist_cust_id=pCustid)
25114
 
   AND (cohist_invcdate BETWEEN _startDate AND _endDate) );
25115
 
 
25116
 
  IF (_value IS NULL) THEN
25117
 
    _value := 0;
25118
 
  END IF;
25119
 
 
25120
 
  RETURN _value;
25121
 
 
25122
 
END;
25123
 
$_$;
25124
 
 
25125
 
 
25126
 
ALTER FUNCTION public.costsbycustomerbyitemsite(integer, integer, integer) OWNER TO admin;
25127
 
 
25128
 
--
25129
 
--
25130
 
 
25131
 
CREATE FUNCTION costsbycustomervalue(integer, integer) RETURNS numeric
25132
 
    LANGUAGE plpgsql
25133
 
    AS $_$
25134
 
DECLARE
25135
 
  pCustid ALIAS FOR $1;
25136
 
  pPeriodid ALIAS FOR $2;
25137
 
  _value NUMERIC;
25138
 
  _startDate DATE;
25139
 
  _endDate DATE;
25140
 
 
25141
 
BEGIN
25142
 
 
25143
 
  _startDate := findPeriodStart(pPeriodid);
25144
 
  _endDate := findPeriodEnd(pPeriodid);
25145
 
 
25146
 
  SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value
25147
 
  FROM cohist
25148
 
  WHERE ( (cohist_itemsite_id<>-1)
25149
 
   AND (cohist_cust_id=pCustid)
25150
 
   AND (cohist_invcdate BETWEEN _startDate AND _endDate) );
25151
 
 
25152
 
  IF (_value IS NULL) THEN
25153
 
    _value := 0;
25154
 
  END IF;
25155
 
 
25156
 
  RETURN _value;
25157
 
 
25158
 
END;
25159
 
$_$;
25160
 
 
25161
 
 
25162
 
ALTER FUNCTION public.costsbycustomervalue(integer, integer) OWNER TO admin;
25163
 
 
25164
 
--
25165
 
--
25166
 
 
25167
 
CREATE FUNCTION costsbycustomervalue(integer, integer, integer) RETURNS numeric
25168
 
    LANGUAGE plpgsql
25169
 
    AS $_$
25170
 
DECLARE
25171
 
  pCustid ALIAS FOR $1;
25172
 
  pPeriodid ALIAS FOR $2;
25173
 
  pProdcatid ALIAS FOR $3;
25174
 
  _value NUMERIC;
25175
 
  _startDate DATE;
25176
 
  _endDate DATE;
25177
 
 
25178
 
BEGIN
25179
 
 
25180
 
  _startDate := findPeriodStart(pPeriodid);
25181
 
  _endDate := findPeriodEnd(pPeriodid);
25182
 
 
25183
 
  SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value
25184
 
  FROM cohist, itemsite, item
25185
 
  WHERE ( (cohist_cust_id=pCustid)
25186
 
   AND (cohist_itemsite_id=itemsite_id)
25187
 
   AND (itemsite_item_id=item_id)
25188
 
   AND (item_prodcat_id=pProdcatid)
25189
 
   AND (cohist_invcdate BETWEEN _startDate AND _endDate) );
25190
 
 
25191
 
  IF (_value IS NULL) THEN
25192
 
    _value := 0;
25193
 
  END IF;
25194
 
 
25195
 
  RETURN _value;
25196
 
 
25197
 
END;
25198
 
$_$;
25199
 
 
25200
 
 
25201
 
ALTER FUNCTION public.costsbycustomervalue(integer, integer, integer) OWNER TO admin;
25202
 
 
25203
 
--
25204
 
--
25205
 
 
25206
 
CREATE FUNCTION costsbycustomervalue(integer, integer, text) RETURNS numeric
25207
 
    LANGUAGE plpgsql
25208
 
    AS $_$
25209
 
DECLARE
25210
 
  pCustid ALIAS FOR $1;
25211
 
  pPeriodid ALIAS FOR $2;
25212
 
  pProdcat ALIAS FOR $3;
25213
 
  _value NUMERIC;
25214
 
  _startDate DATE;
25215
 
  _endDate DATE;
25216
 
 
25217
 
BEGIN
25218
 
 
25219
 
  _startDate := findPeriodStart(pPeriodid);
25220
 
  _endDate := findPeriodEnd(pPeriodid);
25221
 
 
25222
 
  SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value
25223
 
  FROM cohist, itemsite, item, prodcat
25224
 
  WHERE ( (cohist_cust_id=pCustid)
25225
 
   AND (cohist_itemsite_id=itemsite_id)
25226
 
   AND (itemsite_item_id=item_id)
25227
 
   AND (item_prodcat_id=prodcat_id)
25228
 
   AND (prodcat_code ~ pProdcat)
25229
 
   AND (cohist_invcdate BETWEEN _startDate AND _endDate) );
25230
 
 
25231
 
  IF (_value IS NULL) THEN
25232
 
    _value := 0;
25233
 
  END IF;
25234
 
 
25235
 
  RETURN _value;
25236
 
 
25237
 
END;
25238
 
$_$;
25239
 
 
25240
 
 
25241
 
ALTER FUNCTION public.costsbycustomervalue(integer, integer, text) OWNER TO admin;
25242
 
 
25243
 
--
25244
 
--
25245
 
 
25246
 
CREATE FUNCTION createaccountingperiod(date, date) RETURNS integer
25247
 
    LANGUAGE plpgsql
25248
 
    AS $_$
25249
 
DECLARE
25250
 
  pStartDate ALIAS FOR $1;
25251
 
  pEndDate ALIAS FOR $2;
25252
 
 
25253
 
BEGIN
25254
 
 
25255
 
  RETURN createAccountingPeriod(pStartDate, pEndDate, NULL, NULL);
25256
 
 
25257
 
END;
25258
 
$_$;
25259
 
 
25260
 
 
25261
 
ALTER FUNCTION public.createaccountingperiod(date, date) OWNER TO admin;
25262
 
 
25263
 
--
25264
 
--
25265
 
 
25266
 
CREATE FUNCTION createaccountingperiod(date, date, integer, integer) RETURNS integer
25267
 
    LANGUAGE plpgsql
25268
 
    AS $_$
25269
 
DECLARE
25270
 
  pStartDate ALIAS FOR $1;
25271
 
  pEndDate ALIAS FOR $2;
25272
 
  pYearPeriodId ALIAS FOR $3;
25273
 
  pQuarter ALIAS FOR $4;
25274
 
  _periodid INTEGER;
25275
 
  _check INTEGER;
25276
 
  _r RECORD;
25277
 
  _initial BOOLEAN;
25278
 
  _number INTEGER;
25279
 
 
25280
 
BEGIN
25281
 
 
25282
 
  SELECT period_id INTO _check
25283
 
  FROM period
25284
 
  WHERE (pStartDate BETWEEN period_start AND period_end);
25285
 
  IF (FOUND) THEN
25286
 
    RETURN -1;
25287
 
  END IF;
25288
 
 
25289
 
  SELECT period_id INTO _check
25290
 
  FROM period
25291
 
  WHERE (pEndDate BETWEEN period_start AND period_end);
25292
 
  IF (FOUND) THEN
25293
 
    RETURN -2;
25294
 
  END IF;
25295
 
 
25296
 
  SELECT period_id INTO _check
25297
 
  FROM period
25298
 
  WHERE ( (period_start >= pStartDate)
25299
 
   AND (period_end <= pEndDate) );
25300
 
  IF (FOUND) THEN
25301
 
    RETURN -3;
25302
 
  END IF;
25303
 
 
25304
 
  SELECT yearperiod_id INTO _check
25305
 
  FROM yearperiod
25306
 
  WHERE ((yearperiod_id=pYearPeriodId)
25307
 
  AND (pStartDate>=yearperiod_start)
25308
 
  AND (pEndDate<=yearperiod_end));
25309
 
  IF NOT (FOUND) THEN
25310
 
    RETURN -4;
25311
 
  END IF;
25312
 
 
25313
 
  SELECT CASE WHEN(count(*) > 0) THEN FALSE
25314
 
              ELSE TRUE
25315
 
         END INTO _initial
25316
 
  FROM period;
25317
 
 
25318
 
  SELECT COALESCE(MAX(period_number),0) + 1 INTO _number
25319
 
  FROM period
25320
 
  WHERE (period_yearperiod_id=pYearPeriodId);
25321
 
 
25322
 
  SELECT NEXTVAL('period_period_id_seq') INTO _periodid;
25323
 
  INSERT INTO period
25324
 
  ( period_id, period_start, period_end, period_closed, period_freeze, 
25325
 
    period_initial, period_number, period_yearperiod_id, period_quarter )
25326
 
  VALUES
25327
 
  ( _periodid, pStartDate, pEndDate, FALSE, FALSE, _initial, _number, pYearPeriodId, pQuarter );
25328
 
 
25329
 
  FOR _r IN SELECT DISTINCT gltrans_sequence
25330
 
            FROM gltrans
25331
 
            WHERE ( (NOT gltrans_posted)
25332
 
             AND (gltrans_date BETWEEN pStartDate AND pEndDate) ) LOOP
25333
 
    PERFORM postIntoTrialBalance(_r.gltrans_sequence);
25334
 
  END LOOP;
25335
 
 
25336
 
  RETURN _periodid;
25337
 
 
25338
 
END;
25339
 
$_$;
25340
 
 
25341
 
 
25342
 
ALTER FUNCTION public.createaccountingperiod(date, date, integer, integer) OWNER TO admin;
25343
 
 
25344
 
--
25345
 
--
25346
 
 
25347
 
CREATE FUNCTION createaccountingyearperiod(date, date) RETURNS integer
25348
 
    LANGUAGE plpgsql
25349
 
    AS $_$
25350
 
DECLARE
25351
 
  pStartDate ALIAS FOR $1;
25352
 
  pEndDate ALIAS FOR $2;
25353
 
  _yearperiodid INTEGER;
25354
 
  _check INTEGER;
25355
 
  _checkBool BOOLEAN;
25356
 
  _r RECORD;
25357
 
  _initial BOOLEAN;
25358
 
 
25359
 
BEGIN
25360
 
 
25361
 
  SELECT yearperiod_id INTO _check
25362
 
  FROM yearperiod
25363
 
  WHERE (pStartDate BETWEEN yearperiod_start AND yearperiod_end);
25364
 
  IF (FOUND) THEN
25365
 
    RETURN -1;
25366
 
  END IF;
25367
 
 
25368
 
  SELECT yearperiod_id INTO _check
25369
 
  FROM yearperiod
25370
 
  WHERE (pEndDate BETWEEN yearperiod_start AND yearperiod_end);
25371
 
  IF (FOUND) THEN
25372
 
    RETURN -2;
25373
 
  END IF;
25374
 
 
25375
 
  SELECT yearperiod_id INTO _check
25376
 
  FROM yearperiod
25377
 
  WHERE ( (yearperiod_start >= pStartDate)
25378
 
   AND (yearperiod_end <= pEndDate) );
25379
 
  IF (FOUND) THEN
25380
 
    RETURN -3;
25381
 
  END IF;
25382
 
 
25383
 
  SELECT (pStartDate > pEndDate) INTO _checkBool;
25384
 
  IF (_checkBool) THEN
25385
 
    RETURN -5;
25386
 
  END IF;
25387
 
 
25388
 
  SELECT CASE WHEN(count(*) > 0) THEN FALSE
25389
 
              ELSE TRUE
25390
 
         END INTO _initial
25391
 
  FROM yearperiod;
25392
 
 
25393
 
  SELECT NEXTVAL('yearperiod_yearperiod_id_seq') INTO _yearperiodid;
25394
 
  INSERT INTO yearperiod
25395
 
  ( yearperiod_id, yearperiod_start, yearperiod_end, yearperiod_closed )
25396
 
  VALUES
25397
 
  ( _yearperiodid, pStartDate, pEndDate, FALSE );
25398
 
 
25399
 
  RETURN _yearperiodid;
25400
 
 
25401
 
END;
25402
 
$_$;
25403
 
 
25404
 
 
25405
 
ALTER FUNCTION public.createaccountingyearperiod(date, date) OWNER TO admin;
25406
 
 
25407
 
--
25408
 
--
25409
 
 
25410
 
CREATE FUNCTION createapchecks(integer, date) RETURNS integer
25411
 
    LANGUAGE plpgsql
25412
 
    AS $_$
25413
 
BEGIN
25414
 
  RAISE NOTICE 'createAPChecks() is deprecated - use createChecks() instead';
25415
 
  RETURN createChecks($1, $2);
25416
 
END;
25417
 
$_$;
25418
 
 
25419
 
 
25420
 
ALTER FUNCTION public.createapchecks(integer, date) OWNER TO admin;
25421
 
 
25422
 
--
25423
 
--
25424
 
 
25425
 
CREATE FUNCTION createapcreditmemo(integer, text, text, date, numeric, text) RETURNS integer
25426
 
    LANGUAGE plpgsql
25427
 
    AS $_$
25428
 
DECLARE
25429
 
  pVendid ALIAS FOR $1;
25430
 
  pDocNumber ALIAS FOR $2;
25431
 
  pPoNumber ALIAS FOR $3;
25432
 
  pDocDate ALIAS FOR $4;
25433
 
  pAmount ALIAS FOR $5;
25434
 
  pNotes ALIAS FOR $6;
25435
 
  _result INTEGER;
25436
 
 
25437
 
BEGIN
25438
 
 
25439
 
  SELECT createAPCreditMemo( pVendid, fetchJournalNumber('AP-MISC'),
25440
 
                             pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, -1, pDocDate, -1, baseCurrId() ) INTO _result;
25441
 
 
25442
 
  RETURN _result;
25443
 
 
25444
 
END;
25445
 
$_$;
25446
 
 
25447
 
 
25448
 
ALTER FUNCTION public.createapcreditmemo(integer, text, text, date, numeric, text) OWNER TO admin;
25449
 
 
25450
 
--
25451
 
--
25452
 
 
25453
 
CREATE FUNCTION createapcreditmemo(integer, integer, text, text, date, numeric, text) RETURNS integer
25454
 
    LANGUAGE plpgsql
25455
 
    AS $_$
25456
 
DECLARE
25457
 
  pVendid ALIAS FOR $1;
25458
 
  pJournalNumber ALIAS FOR $2;
25459
 
  pDocNumber ALIAS FOR $3;
25460
 
  pPoNumber ALIAS FOR $4;
25461
 
  pDocDate ALIAS FOR $5;
25462
 
  pAmount ALIAS FOR $6;
25463
 
  pNotes ALIAS FOR $7;
25464
 
 
25465
 
BEGIN
25466
 
  RETURN createAPCreditMemo(pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, -1, pDocDate, -1, baseCurrId() );
25467
 
END;
25468
 
$_$;
25469
 
 
25470
 
 
25471
 
ALTER FUNCTION public.createapcreditmemo(integer, integer, text, text, date, numeric, text) OWNER TO admin;
25472
 
 
25473
 
--
25474
 
--
25475
 
 
25476
 
CREATE FUNCTION createapcreditmemo(integer, text, text, date, numeric, text, integer) RETURNS integer
25477
 
    LANGUAGE plpgsql
25478
 
    AS $_$
25479
 
DECLARE
25480
 
  pVendid ALIAS FOR $1;
25481
 
  pDocNumber ALIAS FOR $2;
25482
 
  pPoNumber ALIAS FOR $3;
25483
 
  pDocDate ALIAS FOR $4;
25484
 
  pAmount ALIAS FOR $5;
25485
 
  pNotes ALIAS FOR $6;
25486
 
  pAccntid ALIAS FOR $7;
25487
 
  _result INTEGER;
25488
 
 
25489
 
BEGIN
25490
 
 
25491
 
  SELECT createAPCreditMemo( pVendid, fetchJournalNumber('AP-MISC'),
25492
 
                             pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDocDate, -1, baseCurrId() ) INTO _result;
25493
 
 
25494
 
  RETURN _result;
25495
 
 
25496
 
END;
25497
 
$_$;
25498
 
 
25499
 
 
25500
 
ALTER FUNCTION public.createapcreditmemo(integer, text, text, date, numeric, text, integer) OWNER TO admin;
25501
 
 
25502
 
--
25503
 
--
25504
 
 
25505
 
CREATE FUNCTION createapcreditmemo(integer, integer, text, text, date, numeric, text, integer) RETURNS integer
25506
 
    LANGUAGE plpgsql
25507
 
    AS $_$
25508
 
DECLARE
25509
 
  pVendid ALIAS FOR $1;
25510
 
  pJournalNumber ALIAS FOR $2;
25511
 
  pDocNumber ALIAS FOR $3;
25512
 
  pPoNumber ALIAS FOR $4;
25513
 
  pDocDate ALIAS FOR $5;
25514
 
  pAmount ALIAS FOR $6;
25515
 
  pNotes ALIAS FOR $7;
25516
 
  pAccntid ALIAS FOR $8;
25517
 
BEGIN
25518
 
  RETURN createAPCreditMemo( pVendid, pJournalNumber,
25519
 
                             pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDocDate, -1, baseCurrId() );
25520
 
END;
25521
 
$_$;
25522
 
 
25523
 
 
25524
 
ALTER FUNCTION public.createapcreditmemo(integer, integer, text, text, date, numeric, text, integer) OWNER TO admin;
25525
 
 
25526
 
--
25527
 
--
25528
 
 
25529
 
CREATE FUNCTION createapcreditmemo(integer, text, text, date, numeric, text, integer, date, integer) RETURNS integer
25530
 
    LANGUAGE plpgsql
25531
 
    AS $_$
25532
 
DECLARE
25533
 
  pVendid ALIAS FOR $1;
25534
 
  pDocNumber ALIAS FOR $2;
25535
 
  pPoNumber ALIAS FOR $3;
25536
 
  pDocDate ALIAS FOR $4;
25537
 
  pAmount ALIAS FOR $5;
25538
 
  pNotes ALIAS FOR $6;
25539
 
  pAccntid ALIAS FOR $7;
25540
 
  pDueDate ALIAS FOR $8;
25541
 
  pTermsid ALIAS FOR $9;
25542
 
  _result INTEGER;
25543
 
 
25544
 
BEGIN
25545
 
 
25546
 
  SELECT createAPCreditMemo( pVendid, fetchJournalNumber('AP-MISC'),
25547
 
                             pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, baseCurrId() ) INTO _result;
25548
 
 
25549
 
  RETURN _result;
25550
 
 
25551
 
END;
25552
 
$_$;
25553
 
 
25554
 
 
25555
 
ALTER FUNCTION public.createapcreditmemo(integer, text, text, date, numeric, text, integer, date, integer) OWNER TO admin;
25556
 
 
25557
 
--
25558
 
--
25559
 
 
25560
 
CREATE FUNCTION createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer) RETURNS integer
25561
 
    LANGUAGE plpgsql
25562
 
    AS $_$
25563
 
DECLARE
25564
 
  pVendid ALIAS FOR $1;
25565
 
  pJournalNumber ALIAS FOR $2;
25566
 
  pDocNumber ALIAS FOR $3;
25567
 
  pPoNumber ALIAS FOR $4;
25568
 
  pDocDate ALIAS FOR $5;
25569
 
  pAmount ALIAS FOR $6;
25570
 
  pNotes ALIAS FOR $7;
25571
 
  pAccntid ALIAS FOR $8;
25572
 
  pDueDate ALIAS FOR $9;
25573
 
  pTermsid ALIAS FOR $10;
25574
 
BEGIN
25575
 
  RETURN createAPCreditMemo( pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, baseCurrId() );
25576
 
END;
25577
 
$_$;
25578
 
 
25579
 
 
25580
 
ALTER FUNCTION public.createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer) OWNER TO admin;
25581
 
 
25582
 
--
25583
 
--
25584
 
 
25585
 
CREATE FUNCTION createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer) RETURNS integer
25586
 
    LANGUAGE plpgsql
25587
 
    AS $_$
25588
 
DECLARE
25589
 
  pVendid ALIAS FOR $1;
25590
 
  pJournalNumber ALIAS FOR $2;
25591
 
  pDocNumber ALIAS FOR $3;
25592
 
  pPoNumber ALIAS FOR $4;
25593
 
  pDocDate ALIAS FOR $5;
25594
 
  pAmount ALIAS FOR $6;
25595
 
  pNotes ALIAS FOR $7;
25596
 
  pAccntid ALIAS FOR $8;
25597
 
  pDueDate ALIAS FOR $9;
25598
 
  pTermsid ALIAS FOR $10;
25599
 
  pCurrId ALIAS FOR $11;
25600
 
BEGIN
25601
 
  RETURN createAPCreditMemo( NULL, pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, pCurrId );
25602
 
END;
25603
 
$_$;
25604
 
 
25605
 
 
25606
 
ALTER FUNCTION public.createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer) OWNER TO admin;
25607
 
 
25608
 
--
25609
 
--
25610
 
 
25611
 
CREATE FUNCTION createapcreditmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer) RETURNS integer
25612
 
    LANGUAGE plpgsql
25613
 
    AS $_$
25614
 
DECLARE
25615
 
  pId ALIAS FOR $1;
25616
 
  pVendid ALIAS FOR $2;
25617
 
  pJournalNumber ALIAS FOR $3;
25618
 
  pDocNumber ALIAS FOR $4;
25619
 
  pPoNumber ALIAS FOR $5;
25620
 
  pDocDate ALIAS FOR $6;
25621
 
  pAmount ALIAS FOR $7;
25622
 
  pNotes ALIAS FOR $8;
25623
 
  pAccntid ALIAS FOR $9;
25624
 
  pDueDate ALIAS FOR $10;
25625
 
  pTermsid ALIAS FOR $11;
25626
 
  pCurrId ALIAS FOR $12;
25627
 
  _vendName TEXT;
25628
 
  _apAccntid INTEGER;
25629
 
  _prepaidAccntid INTEGER;
25630
 
  _accntid INTEGER;
25631
 
  _glSequence INTEGER;
25632
 
  _journalNumber INTEGER;
25633
 
  _apopenid INTEGER;
25634
 
  _baseAmount NUMERIC;
25635
 
  _taxBaseValue NUMERIC;
25636
 
  _test INTEGER;
25637
 
 
25638
 
BEGIN
25639
 
 
25640
 
  _apopenid := pId;
25641
 
 
25642
 
  SELECT findAPAccount(pVendid) INTO _apAccntid;
25643
 
  SELECT findAPPrepaidAccount(pVendid) INTO _prepaidAccntid;
25644
 
 
25645
 
  SELECT vend_name INTO _vendName
25646
 
  FROM vendinfo
25647
 
  WHERE (vend_id=pVendid);
25648
 
  
25649
 
  _accntid := pAccntid;
25650
 
 
25651
 
  PERFORM accnt_id
25652
 
     FROM accnt
25653
 
    WHERE (accnt_id=_accntid);
25654
 
  IF (FOUND) THEN
25655
 
    _prepaidAccntid := _accntid;
25656
 
  ELSE
25657
 
    _accntid := -1;
25658
 
  END IF;
25659
 
 
25660
 
  IF(pJournalNumber IS NULL) THEN
25661
 
    SELECT fetchJournalNumber('AP-MISC') INTO _journalNumber;
25662
 
  ELSE
25663
 
    _journalNumber := pJournalNumber;
25664
 
  END IF;
25665
 
 
25666
 
  SELECT fetchGLSequence() INTO _glSequence;
25667
 
 
25668
 
  IF (_apopenid IS NOT NULL) THEN
25669
 
    UPDATE apopen SET
25670
 
      apopen_username=getEffectiveXtUser(), apopen_journalnumber=_journalNumber,
25671
 
      apopen_vend_id=pVendid, apopen_docnumber=pDocNumber,
25672
 
      apopen_doctype='C', apopen_ponumber=pPoNumber,
25673
 
      apopen_docdate=pDocDate, apopen_duedate=pDueDate,
25674
 
      apopen_distdate=pDocDate, apopen_terms_id=pTermsid,
25675
 
      apopen_amount=pAmount, apopen_paid=0,
25676
 
      apopen_open=(pAmount <> 0), apopen_notes=pNotes,
25677
 
      apopen_accnt_id=_accntid, apopen_curr_id=pCurrId,
25678
 
      apopen_closedate=CASE WHEN (pAmount = 0) THEN pDocdate END
25679
 
    WHERE apopen_id = _apopenid;
25680
 
  ELSE
25681
 
    SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid;
25682
 
    INSERT INTO apopen
25683
 
    ( apopen_id, apopen_username, apopen_journalnumber,
25684
 
      apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber,
25685
 
      apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id,
25686
 
      apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_accnt_id, apopen_curr_id,
25687
 
      apopen_closedate )
25688
 
    VALUES
25689
 
    ( _apopenid, getEffectiveXtUser(), _journalNumber,
25690
 
      pVendid, pDocNumber, 'C', pPoNumber,
25691
 
      pDocDate, pDueDate, pDocDate, pTermsid,
25692
 
      pAmount, 0, (pAmount <> 0), pNotes, _accntid, pCurrId,
25693
 
      CASE WHEN (pAmount = 0) THEN pDocDate END );
25694
 
  END IF;
25695
 
 
25696
 
  _baseAmount := round(currToBase(pCurrId, pAmount, pDocDate), 2);
25697
 
 
25698
 
  -- Debit the A/P account for the full amount
25699
 
  SELECT insertIntoGLSeries ( _glSequence, 'A/P', 'CM',
25700
 
                              pDocNumber, _apAccntid,
25701
 
                              (_baseAmount * -1),
25702
 
                              pDocDate, (_vendName || ' ' || pNotes) ) INTO _test;
25703
 
 
25704
 
  -- Credit the Tax account for the tax amount
25705
 
  _taxBaseValue := addTaxToGLSeries(_glSequence,
25706
 
                                      'A/P', 'CM', pDocNumber,
25707
 
                                      pCurrId, pDocDate, pDocDate,
25708
 
                                      'apopentax', _apopenid,
25709
 
                                      _vendName);
25710
 
 
25711
 
  UPDATE apopentax SET taxhist_journalnumber = _journalNumber
25712
 
  WHERE taxhist_parent_id=_apopenid;
25713
 
 
25714
 
  -- Credit the Prepaid account for the basis amount
25715
 
  SELECT insertIntoGLSeries ( _glSequence, 'A/P', 'CM',
25716
 
                              pDocNumber, _prepaidAccntid,
25717
 
                              (_baseAmount - _taxBaseValue),
25718
 
                              pDocDate, (_vendName || ' ' || pNotes) ) INTO _test;
25719
 
 
25720
 
  --  Commit the GLSeries;
25721
 
  SELECT postGLSeries(_glSequence, _journalNumber) INTO _test;
25722
 
  IF (_test < 0) THEN
25723
 
    DELETE FROM apopen WHERE (apopen_id=_apopenid);
25724
 
    PERFORM deleteGLSeries(_glSequence);
25725
 
    RAISE EXCEPTION 'postGLSeries commit failed with %', _test;
25726
 
  END IF;
25727
 
 
25728
 
  RETURN pJournalNumber;
25729
 
 
25730
 
END;
25731
 
$_$;
25732
 
 
25733
 
 
25734
 
ALTER FUNCTION public.createapcreditmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer) OWNER TO admin;
25735
 
 
25736
 
--
25737
 
--
25738
 
 
25739
 
CREATE FUNCTION createapcreditmemoapplication(psourceapopenid integer, ptargetapopenid integer, pamount numeric, pcurrid integer) RETURNS integer
25740
 
    LANGUAGE plpgsql
25741
 
    AS $$
25742
 
DECLARE
25743
 
  _apCreditApplyId      INTEGER;
25744
 
 
25745
 
BEGIN
25746
 
  IF (pAmount > (SELECT ROUND(currToCurr(apopen_curr_id, pCurrId, (apopen_amount - apopen_paid), apopen_docdate), 2)
25747
 
                 FROM apopen
25748
 
                 WHERE (apopen_id=pTargetApopenId))) THEN
25749
 
    RETURN -1;
25750
 
  END IF;
25751
 
 
25752
 
  IF (pAmount > (SELECT ROUND((apopen_amount - apopen_paid) - 
25753
 
                       COALESCE(SUM(currToCurr(apcreditapply_curr_id,
25754
 
                                                apopen_curr_id, 
25755
 
                                                apcreditapply_amount, 
25756
 
                                                apopen_docdate)), 0), 2)
25757
 
             FROM apopen LEFT OUTER JOIN apcreditapply 
25758
 
               ON ((apcreditapply_source_apopen_id=apopen_id) 
25759
 
              AND (apcreditapply_target_apopen_id<>pTargetApopenId)) 
25760
 
             WHERE (apopen_id=pSourceApopenId) 
25761
 
             GROUP BY apopen_amount, apopen_paid)) THEN
25762
 
      RETURN -2;
25763
 
    END IF;
25764
 
 
25765
 
  SELECT apcreditapply_id INTO _apCreditApplyId
25766
 
    FROM apcreditapply
25767
 
   WHERE ((apcreditapply_source_apopen_id=pSourceApopenId)
25768
 
     AND  (apcreditapply_target_apopen_id=pTargetApopenId));
25769
 
 
25770
 
  IF (FOUND) THEN
25771
 
    UPDATE apcreditapply SET apcreditapply_amount=pAmount,
25772
 
                             apcreditapply_curr_id=pCurrId
25773
 
    WHERE (apcreditapply_id=_apCreditApplyId);
25774
 
  ELSE
25775
 
    INSERT INTO apcreditapply (
25776
 
      apcreditapply_source_apopen_id,
25777
 
      apcreditapply_target_apopen_id,
25778
 
      apcreditapply_amount, apcreditapply_curr_id
25779
 
    ) VALUES (
25780
 
      pSourceApopenId,
25781
 
      pTargetApopenId,
25782
 
      pAmount, pCurrId)
25783
 
    RETURNING apcreditapply_id INTO _apCreditApplyId;
25784
 
  END IF;
25785
 
 
25786
 
  RETURN _apCreditApplyId;
25787
 
 
25788
 
END;
25789
 
$$;
25790
 
 
25791
 
 
25792
 
ALTER FUNCTION public.createapcreditmemoapplication(psourceapopenid integer, ptargetapopenid integer, pamount numeric, pcurrid integer) OWNER TO admin;
25793
 
 
25794
 
--
25795
 
--
25796
 
 
25797
 
CREATE FUNCTION createapdebitmemo(integer, text, text, date, numeric, text) RETURNS integer
25798
 
    LANGUAGE plpgsql
25799
 
    AS $_$
25800
 
DECLARE
25801
 
  pVendid ALIAS FOR $1;
25802
 
  pDocNumber ALIAS FOR $2;
25803
 
  pPoNumber ALIAS FOR $3;
25804
 
  pDocDate ALIAS FOR $4;
25805
 
  pAmount ALIAS FOR $5;
25806
 
  pNotes ALIAS FOR $6;
25807
 
  _result INTEGER;
25808
 
 
25809
 
BEGIN
25810
 
 
25811
 
  SELECT createAPDebitMemo( pVendid, fetchJournalNumber('AP-MISC'),
25812
 
                            pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, -1, pDocDate, -1, baseCurrId() ) INTO _result;
25813
 
 
25814
 
  RETURN _result;
25815
 
 
25816
 
END;
25817
 
$_$;
25818
 
 
25819
 
 
25820
 
ALTER FUNCTION public.createapdebitmemo(integer, text, text, date, numeric, text) OWNER TO admin;
25821
 
 
25822
 
--
25823
 
--
25824
 
 
25825
 
CREATE FUNCTION createapdebitmemo(integer, integer, text, text, date, numeric, text) RETURNS integer
25826
 
    LANGUAGE plpgsql
25827
 
    AS $_$
25828
 
DECLARE
25829
 
  pVendid ALIAS FOR $1;
25830
 
  pJournalNumber ALIAS FOR $2;
25831
 
  pDocNumber ALIAS FOR $3;
25832
 
  pPoNumber ALIAS FOR $4;
25833
 
  pDocDate ALIAS FOR $5;
25834
 
  pAmount ALIAS FOR $6;
25835
 
  pNotes ALIAS FOR $7;
25836
 
 
25837
 
BEGIN
25838
 
 
25839
 
  RETURN createAPDebitMemo(pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, -1, pDocDate, -1, baseCurrId() );
25840
 
 
25841
 
END;
25842
 
$_$;
25843
 
 
25844
 
 
25845
 
ALTER FUNCTION public.createapdebitmemo(integer, integer, text, text, date, numeric, text) OWNER TO admin;
25846
 
 
25847
 
--
25848
 
--
25849
 
 
25850
 
CREATE FUNCTION createapdebitmemo(integer, text, text, date, numeric, text, integer) RETURNS integer
25851
 
    LANGUAGE plpgsql
25852
 
    AS $_$
25853
 
DECLARE
25854
 
  pVendid ALIAS FOR $1;
25855
 
  pDocNumber ALIAS FOR $2;
25856
 
  pPoNumber ALIAS FOR $3;
25857
 
  pDocDate ALIAS FOR $4;
25858
 
  pAmount ALIAS FOR $5;
25859
 
  pNotes ALIAS FOR $6;
25860
 
  pAccntid ALIAS FOR $7;
25861
 
  _result INTEGER;
25862
 
 
25863
 
BEGIN
25864
 
 
25865
 
  SELECT createAPDebitMemo( pVendid, fetchJournalNumber('AP-MISC'),
25866
 
                            pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDocDate, -1, baseCurrId() ) INTO _result;
25867
 
 
25868
 
  RETURN _result;
25869
 
 
25870
 
END;
25871
 
$_$;
25872
 
 
25873
 
 
25874
 
ALTER FUNCTION public.createapdebitmemo(integer, text, text, date, numeric, text, integer) OWNER TO admin;
25875
 
 
25876
 
--
25877
 
--
25878
 
 
25879
 
CREATE FUNCTION createapdebitmemo(integer, integer, text, text, date, numeric, text, integer) RETURNS integer
25880
 
    LANGUAGE plpgsql
25881
 
    AS $_$
25882
 
DECLARE
25883
 
  pVendid ALIAS FOR $1;
25884
 
  pJournalNumber ALIAS FOR $2;
25885
 
  pDocNumber ALIAS FOR $3;
25886
 
  pPoNumber ALIAS FOR $4;
25887
 
  pDocDate ALIAS FOR $5;
25888
 
  pAmount ALIAS FOR $6;
25889
 
  pNotes ALIAS FOR $7;
25890
 
  pAccntid ALIAS FOR $8;
25891
 
BEGIN
25892
 
  RETURN createAPDebitMemo( pVendid, pJournalNumber,
25893
 
                            pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDocDate, -1, baseCurrId() );
25894
 
END;
25895
 
$_$;
25896
 
 
25897
 
 
25898
 
ALTER FUNCTION public.createapdebitmemo(integer, integer, text, text, date, numeric, text, integer) OWNER TO admin;
25899
 
 
25900
 
--
25901
 
--
25902
 
 
25903
 
CREATE FUNCTION createapdebitmemo(integer, text, text, date, numeric, text, integer, date, integer) RETURNS integer
25904
 
    LANGUAGE plpgsql
25905
 
    AS $_$
25906
 
DECLARE
25907
 
  pVendid ALIAS FOR $1;
25908
 
  pDocNumber ALIAS FOR $2;
25909
 
  pPoNumber ALIAS FOR $3;
25910
 
  pDocDate ALIAS FOR $4;
25911
 
  pAmount ALIAS FOR $5;
25912
 
  pNotes ALIAS FOR $6;
25913
 
  pAccntid ALIAS FOR $7;
25914
 
  pDueDate ALIAS FOR $8;
25915
 
  pTermsid ALIAS FOR $9;
25916
 
  _result INTEGER;
25917
 
 
25918
 
BEGIN
25919
 
 
25920
 
  SELECT createAPDebitMemo( pVendid, fetchJournalNumber('AP-MISC'),
25921
 
                            pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, baseCurrId() ) INTO _result;
25922
 
 
25923
 
  RETURN _result;
25924
 
 
25925
 
END;
25926
 
$_$;
25927
 
 
25928
 
 
25929
 
ALTER FUNCTION public.createapdebitmemo(integer, text, text, date, numeric, text, integer, date, integer) OWNER TO admin;
25930
 
 
25931
 
--
25932
 
--
25933
 
 
25934
 
CREATE FUNCTION createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer) RETURNS integer
25935
 
    LANGUAGE plpgsql
25936
 
    AS $_$
25937
 
DECLARE
25938
 
  pVendid ALIAS FOR $1;
25939
 
  pJournalNumber ALIAS FOR $2;
25940
 
  pDocNumber ALIAS FOR $3;
25941
 
  pPoNumber ALIAS FOR $4;
25942
 
  pDocDate ALIAS FOR $5;
25943
 
  pAmount ALIAS FOR $6;
25944
 
  pNotes ALIAS FOR $7;
25945
 
  pAccntid ALIAS FOR $8;
25946
 
  pDueDate ALIAS FOR $9;
25947
 
  pTermsid ALIAS FOR $10;
25948
 
 
25949
 
BEGIN
25950
 
  RETURN createAPDebitMemo(pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, baseCurrId() );
25951
 
END;
25952
 
$_$;
25953
 
 
25954
 
 
25955
 
ALTER FUNCTION public.createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer) OWNER TO admin;
25956
 
 
25957
 
--
25958
 
--
25959
 
 
25960
 
CREATE FUNCTION createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer) RETURNS integer
25961
 
    LANGUAGE plpgsql
25962
 
    AS $_$
25963
 
DECLARE
25964
 
  pVendid ALIAS FOR $1;
25965
 
  pJournalNumber ALIAS FOR $2;
25966
 
  pDocNumber ALIAS FOR $3;
25967
 
  pPoNumber ALIAS FOR $4;
25968
 
  pDocDate ALIAS FOR $5;
25969
 
  pAmount ALIAS FOR $6;
25970
 
  pNotes ALIAS FOR $7;
25971
 
  pAccntid ALIAS FOR $8;
25972
 
  pDueDate ALIAS FOR $9;
25973
 
  pTermsid ALIAS FOR $10;
25974
 
  pCurrId ALIAS FOR $11;
25975
 
 
25976
 
BEGIN
25977
 
  RETURN createAPDebitMemo(NULL, pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, pCurrId );
25978
 
END;
25979
 
$_$;
25980
 
 
25981
 
 
25982
 
ALTER FUNCTION public.createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer) OWNER TO admin;
25983
 
 
25984
 
--
25985
 
--
25986
 
 
25987
 
CREATE FUNCTION createapdebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer) RETURNS integer
25988
 
    LANGUAGE plpgsql
25989
 
    AS $_$
25990
 
DECLARE
25991
 
  pId ALIAS FOR $1;
25992
 
  pVendid ALIAS FOR $2;
25993
 
  pJournalNumber ALIAS FOR $3;
25994
 
  pDocNumber ALIAS FOR $4;
25995
 
  pPoNumber ALIAS FOR $5;
25996
 
  pDocDate ALIAS FOR $6;
25997
 
  pAmount ALIAS FOR $7;
25998
 
  pNotes ALIAS FOR $8;
25999
 
  pAccntid ALIAS FOR $9;
26000
 
  pDueDate ALIAS FOR $10;
26001
 
  pTermsid ALIAS FOR $11;
26002
 
  pCurrId ALIAS FOR $12;
26003
 
  _vendName TEXT;
26004
 
  _apAccntid INTEGER;
26005
 
  _prepaidAccntid INTEGER;
26006
 
  _accntid INTEGER;
26007
 
  _glSequence INTEGER;
26008
 
  _journalNumber INTEGER;
26009
 
  _apopenid INTEGER;
26010
 
  _baseAmount NUMERIC;
26011
 
  _taxBaseValue NUMERIC;
26012
 
  _test INTEGER;
26013
 
 
26014
 
BEGIN
26015
 
 
26016
 
  _apopenid := pId;
26017
 
 
26018
 
  SELECT findAPAccount(pVendid) INTO _apAccntid;
26019
 
  SELECT findAPPrepaidAccount(pVendid) INTO _prepaidAccntid;
26020
 
 
26021
 
  SELECT vend_name INTO _vendName
26022
 
  FROM vendinfo
26023
 
  WHERE (vend_id=pVendid);
26024
 
 
26025
 
  _accntid := pAccntid;
26026
 
 
26027
 
  PERFORM accnt_id
26028
 
     FROM accnt
26029
 
    WHERE (accnt_id=_accntid);
26030
 
  IF (FOUND) THEN
26031
 
    _prepaidAccntid := _accntid;
26032
 
  ELSE
26033
 
    _accntid := -1;
26034
 
  END IF;
26035
 
 
26036
 
  IF(pJournalNumber IS NULL) THEN
26037
 
    SELECT fetchJournalNumber('AP-MISC') INTO _journalNumber;
26038
 
  ELSE
26039
 
    _journalNumber := pJournalNumber;
26040
 
  END IF;
26041
 
 
26042
 
  SELECT fetchGLSequence() INTO _glSequence;
26043
 
 
26044
 
  IF (_apopenid IS NOT NULL) THEN
26045
 
    UPDATE apopen SET
26046
 
      apopen_username=getEffectiveXtUser(), apopen_journalnumber=_journalNumber,
26047
 
      apopen_vend_id=pVendid, apopen_docnumber=pDocNumber,
26048
 
      apopen_doctype='D', apopen_ponumber=pPoNumber,
26049
 
      apopen_docdate=pDocDate, apopen_duedate=pDueDate,
26050
 
      apopen_distdate=pDocDate, apopen_terms_id=pTermsid,
26051
 
      apopen_amount=pAmount, apopen_paid=0,
26052
 
      apopen_open=(pAmount <> 0), apopen_notes=pNotes,
26053
 
      apopen_accnt_id=_accntid, apopen_curr_id=pCurrId,
26054
 
      apopen_closedate=CASE WHEN (pAmount = 0) THEN pDocdate END
26055
 
    WHERE apopen_id = _apopenid;
26056
 
  ELSE
26057
 
    SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid;
26058
 
    INSERT INTO apopen
26059
 
    ( apopen_id, apopen_username, apopen_journalnumber,
26060
 
      apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber,
26061
 
      apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id,
26062
 
      apopen_amount, apopen_paid, apopen_discountable_amount, apopen_open, apopen_notes, apopen_accnt_id, apopen_curr_id,
26063
 
      apopen_closedate )
26064
 
    VALUES
26065
 
    ( _apopenid, getEffectiveXtUser(), _journalNumber,
26066
 
      pVendid, pDocNumber, 'D', pPoNumber,
26067
 
      pDocDate, pDueDate, pDocDate, pTermsid,
26068
 
      pAmount, 0, 0, (pAmount <> 0), pNotes, _accntid, pCurrId,
26069
 
      CASE WHEN (pAmount = 0) THEN pDocDate END );
26070
 
  END IF;
26071
 
 
26072
 
  _baseAmount := round(currToBase(pCurrId, pAmount, pDocDate), 2);
26073
 
 
26074
 
  -- Credit the A/P account for the full amount
26075
 
  SELECT insertIntoGLSeries ( _glSequence, 'A/P', 'DM',
26076
 
                              pDocNumber, _apAccntid,
26077
 
                              _baseAmount,
26078
 
                              pDocDate, (_vendName || ' ' || pNotes) ) INTO _test;
26079
 
 
26080
 
  -- Debit the Tax account for the tax amount
26081
 
  _taxBaseValue := addTaxToGLSeries(_glSequence,
26082
 
                                      'A/P', 'DM', pDocNumber,
26083
 
                                      pCurrId, pDocDate, pDocDate,
26084
 
                                      'apopentax', _apopenid,
26085
 
                                      _vendName);
26086
 
 
26087
 
  UPDATE apopentax SET taxhist_journalnumber = _journalNumber
26088
 
  WHERE taxhist_parent_id=_apopenid;
26089
 
 
26090
 
  -- Debit the Prepaid account for the basis amount
26091
 
  -- Note, the taxBaseValue is negative so it is added
26092
 
  SELECT insertIntoGLSeries ( _glSequence, 'A/P', 'DM',
26093
 
                              pDocNumber, _prepaidAccntid,
26094
 
                              (_baseAmount + _taxBaseValue) * -1,
26095
 
                              pDocDate, (_vendName || ' ' || pNotes) ) INTO _test;
26096
 
 
26097
 
  --  Commit the GLSeries;
26098
 
  SELECT postGLSeries(_glSequence, _journalNumber) INTO _test;
26099
 
  IF (_test < 0) THEN
26100
 
    DELETE FROM apopen WHERE (apopen_id=_apopenid);
26101
 
    PERFORM deleteGLSeries(_glSequence);
26102
 
    RAISE EXCEPTION 'postGLSeries commit failed with %', _test;
26103
 
  END IF;
26104
 
 
26105
 
  RETURN _apopenid;
26106
 
 
26107
 
END;
26108
 
$_$;
26109
 
 
26110
 
 
26111
 
ALTER FUNCTION public.createapdebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer) OWNER TO admin;
26112
 
 
26113
 
--
26114
 
--
26115
 
 
26116
 
CREATE FUNCTION createapdiscount(integer, numeric) RETURNS integer
26117
 
    LANGUAGE plpgsql
26118
 
    AS $_$
26119
 
DECLARE
26120
 
  pApopenid ALIAS FOR $1;
26121
 
  pAmount ALIAS FOR $2;
26122
 
  _result INTEGER;
26123
 
  
26124
 
BEGIN
26125
 
 
26126
 
  SELECT createAPDiscount(pApopenid, fetchJournalNumber('AP-MISC'), pAmount) INTO _result;
26127
 
 
26128
 
  RETURN _result;
26129
 
 
26130
 
END;
26131
 
$_$;
26132
 
 
26133
 
 
26134
 
ALTER FUNCTION public.createapdiscount(integer, numeric) OWNER TO admin;
26135
 
 
26136
 
--
26137
 
--
26138
 
 
26139
 
CREATE FUNCTION createapdiscount(integer, integer, numeric) RETURNS integer
26140
 
    LANGUAGE plpgsql
26141
 
    AS $_$
26142
 
DECLARE
26143
 
  pApopenid ALIAS FOR $1;
26144
 
  pJournalNumber ALIAS FOR $2;
26145
 
  pAmount ALIAS FOR $3;
26146
 
  _ap RECORD;
26147
 
  _sequence INTEGER;
26148
 
  _apopenid INTEGER;
26149
 
  _apcreditapplyid INTEGER;
26150
 
  _result INTEGER;
26151
 
  _crAccnt INTEGER;
26152
 
  _dbAccnt INTEGER;
26153
 
  _reference    TEXT;
26154
 
  _discountDateAmt NUMERIC;
26155
 
 
26156
 
BEGIN
26157
 
 
26158
 
  SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid;
26159
 
 
26160
 
  SELECT * INTO _ap
26161
 
  FROM apopen
26162
 
  WHERE (apopen_id = pApopenid);
26163
 
  IF (NOT FOUND) THEN
26164
 
    RETURN -1;
26165
 
  END IF;
26166
 
 
26167
 
  _crAccnt := findAPDiscountAccount(_ap.apopen_vend_id);
26168
 
  _dbAccnt := findAPAccount(_ap.apopen_vend_id);
26169
 
  _reference := ('Discount for ' || _ap.apopen_doctype || ' ' || _ap.apopen_docnumber);
26170
 
 
26171
 
  SELECT fetchGLSequence() INTO _sequence;
26172
 
 
26173
 
  _discountDateAmt = round(pAmount / _ap.apopen_curr_rate, 2);
26174
 
  PERFORM insertIntoGLSeries( _sequence, 'A/P', 'DS', _ap.apopen_docnumber,
26175
 
                              _dbAccnt,
26176
 
                              _discountDateAmt * -1,
26177
 
                              CURRENT_DATE,
26178
 
                              _reference);
26179
 
  PERFORM insertIntoGLSeries( _sequence, 'A/P', 'DS', _ap.apopen_docnumber,
26180
 
                              _crAccnt,
26181
 
                              _discountDateAmt,
26182
 
                              CURRENT_DATE,
26183
 
                              _reference);
26184
 
 
26185
 
  PERFORM postGLSeries(_sequence, pJournalNumber);
26186
 
 
26187
 
  INSERT INTO apopen
26188
 
  ( apopen_id, apopen_username, apopen_journalnumber,
26189
 
    apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber,
26190
 
    apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_curr_id,
26191
 
    apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_discount, apopen_curr_rate )
26192
 
  SELECT _apopenid, getEffectiveXtUser(), pJournalNumber,
26193
 
         apopen_vend_id, apopen_docnumber, 'C', apopen_ponumber,
26194
 
         CURRENT_DATE, CURRENT_DATE, CURRENT_DATE, -1, apopen_curr_id,
26195
 
         pAmount, 0, TRUE, _reference, TRUE, apopen_curr_rate
26196
 
    FROM apopen
26197
 
   WHERE (apopen_id=pApopenid);
26198
 
 
26199
 
  SELECT apcreditapply_id INTO _apcreditapplyid
26200
 
    FROM apcreditapply
26201
 
   WHERE ( (apcreditapply_source_apopen_id=_apopenid)
26202
 
     AND   (apcreditapply_target_apopen_id=pApopenid) );
26203
 
  IF (FOUND) THEN
26204
 
    UPDATE apcreditapply
26205
 
       SET apcreditapply_amount=pAmount
26206
 
     WHERE (apcreditapply_id=_apcreditapplyid);
26207
 
  ELSE
26208
 
    SELECT nextval('apcreditapply_apcreditapply_id_seq') INTO _apcreditapplyid;
26209
 
    INSERT INTO apcreditapply
26210
 
           ( apcreditapply_id, apcreditapply_source_apopen_id,
26211
 
             apcreditapply_target_apopen_id, apcreditapply_amount,
26212
 
             apcreditapply_curr_id )
26213
 
    VALUES ( _apcreditapplyid, _apopenid, pApopenid, pAmount, _ap.apopen_curr_id );
26214
 
  END IF;
26215
 
 
26216
 
  SELECT postAPCreditMemoApplication(_apopenid) INTO _result;
26217
 
 
26218
 
  IF (_result < 0) THEN
26219
 
    RETURN _result;
26220
 
  END IF;
26221
 
 
26222
 
  RETURN pJournalNumber;
26223
 
 
26224
 
END;
26225
 
$_$;
26226
 
 
26227
 
 
26228
 
ALTER FUNCTION public.createapdiscount(integer, integer, numeric) OWNER TO admin;
26229
 
 
26230
 
--
26231
 
--
26232
 
 
26233
 
CREATE FUNCTION createarcashdeposit(integer, text, text, date, numeric, text, integer, integer) RETURNS integer
26234
 
    LANGUAGE plpgsql
26235
 
    AS $_$
26236
 
DECLARE
26237
 
  pCustid ALIAS FOR $1;
26238
 
  pDocNumber ALIAS FOR $2;
26239
 
  pOrderNumber ALIAS FOR $3;
26240
 
  pDocDate ALIAS FOR $4;
26241
 
  pAmount ALIAS FOR $5;
26242
 
  pNotes ALIAS FOR $6;
26243
 
  pJournalNumber ALIAS FOR $7;
26244
 
  pCurrId ALIAS FOR $8;
26245
 
  _prepaidaccntid INTEGER;
26246
 
  _deferredaccntid INTEGER;
26247
 
  _glSequence INTEGER;
26248
 
  _aropenid INTEGER;
26249
 
 
26250
 
BEGIN
26251
 
 
26252
 
  IF (pAmount <= 0) THEN
26253
 
    RETURN 0;
26254
 
  END IF;
26255
 
 
26256
 
  _prepaidaccntid := findPrepaidAccount(pCustid);
26257
 
  IF (_prepaidaccntid = -1) THEN
26258
 
    RAISE EXCEPTION 'There was an error creating the Customer Deposit GL Transactions. No Prepaid Account is assigned.';
26259
 
  END IF;
26260
 
 
26261
 
  _deferredaccntid := findDeferredAccount(pCustid);
26262
 
  IF (_deferredaccntid = -1) THEN
26263
 
    RAISE EXCEPTION 'There was an error creating the Customer Deposit GL Transactions. No Deferred Account is assigned.';
26264
 
  END IF;
26265
 
 
26266
 
  SELECT NEXTVAL('aropen_aropen_id_seq') INTO _aropenid;
26267
 
 
26268
 
  SELECT insertGLTransaction( pJournalNumber, 'A/R', 'CD',
26269
 
                              pDocNumber, pNotes, _deferredaccntid, _prepaidaccntid,
26270
 
                              _aropenid,
26271
 
                              round(currToBase(pCurrId, pAmount, pDocDate), 2),
26272
 
                              pDocDate) INTO _glSequence;
26273
 
 
26274
 
  INSERT INTO aropen
26275
 
  ( aropen_id, aropen_username, aropen_journalnumber,
26276
 
    aropen_cust_id, aropen_docnumber, aropen_doctype, aropen_ordernumber,
26277
 
    aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_salesrep_id,
26278
 
    aropen_amount, aropen_paid, aropen_commission_due, aropen_commission_paid,
26279
 
    aropen_applyto, aropen_ponumber, aropen_cobmisc_id,
26280
 
    aropen_open, aropen_notes, aropen_rsncode_id,
26281
 
    aropen_salescat_id, aropen_accnt_id, aropen_curr_id )
26282
 
  VALUES
26283
 
  ( _aropenid, getEffectiveXtUser(), pJournalNumber,
26284
 
    pCustid, pDocNumber, 'R', pOrderNumber,
26285
 
    pDocDate, pDocDate, pDocDate, -1, NULL,
26286
 
    round(pAmount, 2), 0, 0.0, FALSE,
26287
 
    '', '', -1,
26288
 
    TRUE, pNotes, -1,
26289
 
    -1, -1, pCurrId );
26290
 
 
26291
 
  RETURN _aropenid;
26292
 
 
26293
 
END;
26294
 
$_$;
26295
 
 
26296
 
 
26297
 
ALTER FUNCTION public.createarcashdeposit(integer, text, text, date, numeric, text, integer, integer) OWNER TO admin;
26298
 
 
26299
 
--
26300
 
--
26301
 
 
26302
 
CREATE FUNCTION createarcreditmemo(pid integer, pcustid integer, pdocnumber text, pordernumber text, pdocdate date, pamount numeric, pnotes text, prsncodeid integer, psalescatid integer, paccntid integer, pduedate date, ptermsid integer, psalesrepid integer, pcommissiondue numeric DEFAULT 0, pjournalnumber integer DEFAULT NULL::integer, pcurrid integer DEFAULT basecurrid(), paraccntid integer DEFAULT NULL::integer, pcoccpayid integer DEFAULT NULL::integer) RETURNS integer
26303
 
    LANGUAGE plpgsql
26304
 
    AS $$
26305
 
DECLARE
26306
 
  _accntid        INTEGER;
26307
 
  _arAccntid      INTEGER;
26308
 
  _aropenid       INTEGER;
26309
 
  _cohistid       INTEGER;
26310
 
  _custName       TEXT;
26311
 
  _duedate        DATE    := COALESCE(pDueDate, pDocDate);
26312
 
  _glSequence     INTEGER;
26313
 
  _journalNumber  INTEGER;
26314
 
  _prepaidAccntid INTEGER;
26315
 
  _salescatid     INTEGER;
26316
 
  _taxBaseValue   NUMERIC;
26317
 
  _test           INTEGER;
26318
 
  _tmp            INTEGER;
26319
 
 
26320
 
BEGIN
26321
 
 
26322
 
  _aropenid := pId;
26323
 
 
26324
 
  IF (pAmount <= 0) THEN
26325
 
    RETURN 0;
26326
 
  END IF;
26327
 
 
26328
 
  _arAccntid := COALESCE(pARAccntid, findARAccount(pCustid));
26329
 
  _prepaidAccntid := findPrepaidAccount(pCustid);
26330
 
 
26331
 
  _accntid := pAccntid;
26332
 
  _salescatid := pSalescatid;
26333
 
 
26334
 
  SELECT cust_name INTO _custName
26335
 
  FROM custinfo
26336
 
  WHERE (cust_id=pCustid);
26337
 
 
26338
 
  IF EXISTS(SELECT 1 FROM accnt WHERE (accnt_id=_accntid)) THEN
26339
 
    _prepaidAccntid := _accntid;
26340
 
  ELSE
26341
 
    _accntid := -1;
26342
 
  END IF;
26343
 
 
26344
 
  SELECT accnt_id INTO _tmp
26345
 
    FROM salescat, accnt
26346
 
   WHERE ((salescat_prepaid_accnt_id=accnt_id)
26347
 
     AND  (salescat_id=_salescatid));
26348
 
  IF (FOUND) THEN
26349
 
    _accntid := -1;
26350
 
    _prepaidAccntid := _tmp;
26351
 
  ELSE
26352
 
    _salescatid = -1;
26353
 
  END IF;
26354
 
 
26355
 
  IF(pJournalNumber IS NULL) THEN
26356
 
    SELECT fetchJournalNumber('AR-MISC') INTO _journalNumber;
26357
 
  ELSE
26358
 
    _journalNumber := pJournalNumber;
26359
 
  END IF;
26360
 
 
26361
 
  _glSequence := fetchGLSequence();
26362
 
 
26363
 
  -- CreatelUpdate aropen for full amount
26364
 
  IF (_aropenid IS NOT NULL) THEN
26365
 
    UPDATE aropen SET
26366
 
      aropen_username=getEffectiveXtUser(), aropen_journalnumber=_journalNumber,
26367
 
      aropen_cust_id=pCustid, aropen_docnumber=pDocNumber, aropen_doctype='C',
26368
 
      aropen_ordernumber=pOrderNumber,aropen_docdate=pDocDate, aropen_duedate=_duedate,
26369
 
      aropen_distdate=pDocDate, aropen_terms_id=pTermsid,
26370
 
      aropen_salesrep_id=pSalesrepid, aropen_amount=round(pAmount, 2), aropen_paid=0,
26371
 
      aropen_commission_due=pCommissiondue, aropen_commission_paid=FALSE,
26372
 
      aropen_applyto='', aropen_ponumber='', aropen_cobmisc_id=-1,
26373
 
      aropen_open=TRUE, aropen_notes=pNotes, aropen_rsncode_id=pRsncodeid,
26374
 
      aropen_salescat_id=_salescatid, aropen_accnt_id=_accntid, aropen_curr_id=pCurrId
26375
 
    WHERE aropen_id = pId;
26376
 
  ELSE
26377
 
    SELECT NEXTVAL('aropen_aropen_id_seq') INTO _aropenid;
26378
 
    INSERT INTO aropen
26379
 
    ( aropen_id, aropen_username, aropen_journalnumber,
26380
 
      aropen_cust_id, aropen_docnumber, aropen_doctype, aropen_ordernumber,
26381
 
      aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_salesrep_id,
26382
 
      aropen_amount, aropen_paid, aropen_commission_due, aropen_commission_paid,
26383
 
      aropen_applyto, aropen_ponumber, aropen_cobmisc_id,
26384
 
      aropen_open, aropen_notes, aropen_rsncode_id,
26385
 
      aropen_salescat_id, aropen_accnt_id, aropen_curr_id )
26386
 
    VALUES
26387
 
    ( _aropenid, getEffectiveXtUser(), _journalNumber,
26388
 
      pCustid, pDocNumber, 'C', pOrderNumber,
26389
 
      pDocDate, _duedate, pDocDate, pTermsid, pSalesrepid,
26390
 
      round(pAmount, 2), 0, pCommissiondue, FALSE,
26391
 
      '', '', -1,
26392
 
      TRUE, pNotes, pRsncodeid,
26393
 
      _salescatid, _accntid, pCurrId );
26394
 
  END IF;
26395
 
 
26396
 
  -- Credit the A/R account for the full amount
26397
 
  SELECT insertIntoGLSeries ( _glSequence, 'A/R', 'CM',
26398
 
                              pDocNumber, _arAccntid,
26399
 
                              round(currToBase(pCurrId, pAmount, pDocDate), 2),
26400
 
                              pDocDate, (_custName || ' ' || pNotes)) INTO _test;
26401
 
 
26402
 
  -- Debit the Tax account for the tax amount
26403
 
  _taxBaseValue := addTaxToGLSeries(_glSequence,
26404
 
                                      'A/R', 'CM', pDocNumber,
26405
 
                                      pCurrId, pDocDate, pDocDate,
26406
 
                                      'aropentax', _aropenid,
26407
 
                                      (_custName || ' ' || pNotes));
26408
 
 
26409
 
  UPDATE aropentax SET taxhist_journalnumber = _journalNumber
26410
 
  WHERE taxhist_parent_id=_aropenid;
26411
 
 
26412
 
  -- Debit the Prepaid account for the basis amount
26413
 
  -- Note, _taxBaseValue is negative so it is added to pAmount
26414
 
  SELECT insertIntoGLSeries ( _glSequence, 'A/R', 'CM',
26415
 
                              pDocNumber, _prepaidAccntid,
26416
 
                              round(currToBase(pCurrId, pAmount * -1, pDocDate) + _taxBaseValue * -1, 2),
26417
 
                              pDocDate, (_custName || ' ' || pNotes)) INTO _test;
26418
 
 
26419
 
  --  Commit the GLSeries;
26420
 
  SELECT postGLSeries(_glSequence, _journalNumber) INTO _test;
26421
 
  IF (_test < 0) THEN
26422
 
    DELETE FROM aropen WHERE (aropen_id=_aropenid);
26423
 
    PERFORM deleteGLSeries(_glSequence);
26424
 
    RAISE EXCEPTION 'postGLSeries commit failed with %', _test;
26425
 
  END IF;
26426
 
 
26427
 
  --  Record Sales History
26428
 
  INSERT INTO cohist
26429
 
  ( cohist_cust_id,
26430
 
   cohist_itemsite_id, cohist_shipto_id,
26431
 
    cohist_misc_type, cohist_misc_descrip,
26432
 
    cohist_shipdate, cohist_shipvia,
26433
 
    cohist_ordernumber, cohist_ponumber, cohist_orderdate,
26434
 
    cohist_doctype, cohist_invcnumber, cohist_invcdate,
26435
 
    cohist_qtyshipped, cohist_unitprice, cohist_unitcost,
26436
 
    cohist_salesrep_id,
26437
 
    cohist_commission, cohist_commissionpaid,
26438
 
    cohist_curr_id, cohist_sequence, cohist_cohead_ccpay_id)
26439
 
  VALUES
26440
 
  (CASE WHEN pCustid < 0 THEN NULL ELSE pCustid END,
26441
 
   -1, -1,
26442
 
    'M', 'A/R Misc Credit Memo',
26443
 
    pDocDate, '',
26444
 
    pOrderNumber, '', pDocDate,
26445
 
    'C', pDocNumber, pDocDate,
26446
 
    1, (pAmount + _taxBaseValue) * -1, 0, -- taxBaseValue is negative, so we add
26447
 
    CASE WHEN pSalesrepid < 0 THEN NULL ELSE pSalesrepid END,
26448
 
    (pCommissiondue * -1.0), FALSE,
26449
 
    pCurrId, _glSequence, pCoCcpayId)
26450
 
  RETURNING cohist_id INTO _cohistid;
26451
 
 
26452
 
  INSERT INTO cohisttax
26453
 
  ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id,
26454
 
    taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
26455
 
    taxhist_percent, taxhist_amount, taxhist_tax,
26456
 
    taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
26457
 
    taxhist_journalnumber )
26458
 
  SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id,
26459
 
         taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
26460
 
         taxhist_percent, taxhist_amount, taxhist_tax,
26461
 
         taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
26462
 
         taxhist_journalnumber
26463
 
  FROM aropentax
26464
 
  WHERE (taxhist_parent_id=_aropenid);
26465
 
 
26466
 
  RETURN _aropenid;
26467
 
 
26468
 
END;
26469
 
$$;
26470
 
 
26471
 
 
26472
 
ALTER FUNCTION public.createarcreditmemo(pid integer, pcustid integer, pdocnumber text, pordernumber text, pdocdate date, pamount numeric, pnotes text, prsncodeid integer, psalescatid integer, paccntid integer, pduedate date, ptermsid integer, psalesrepid integer, pcommissiondue numeric, pjournalnumber integer, pcurrid integer, paraccntid integer, pcoccpayid integer) OWNER TO admin;
26473
 
 
26474
 
--
26475
 
--
26476
 
 
26477
 
CREATE FUNCTION createardebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, integer, integer, date, integer, integer, numeric, integer) RETURNS integer
26478
 
    LANGUAGE plpgsql
26479
 
    AS $_$
26480
 
DECLARE
26481
 
  pId                   ALIAS FOR $1;
26482
 
  pCustid               ALIAS FOR $2;
26483
 
  pJournalNumber        ALIAS FOR $3;
26484
 
  pDocNumber            ALIAS FOR $4;
26485
 
  pOrderNumber          ALIAS FOR $5;
26486
 
  pDocDate              ALIAS FOR $6;
26487
 
  pAmount               ALIAS FOR $7;
26488
 
  pNotes                ALIAS FOR $8;
26489
 
  pRsncodeid            ALIAS FOR $9;
26490
 
  pSalescatid           ALIAS FOR $10;
26491
 
  pAccntid              ALIAS FOR $11;
26492
 
  pDueDate              ALIAS FOR $12;
26493
 
  pTermsid              ALIAS FOR $13;
26494
 
  pSalesrepid           ALIAS FOR $14;
26495
 
  pCommissiondue        ALIAS FOR $15;
26496
 
  pCurrId               ALIAS FOR $16;
26497
 
  _custName TEXT;
26498
 
  _journalNumber INTEGER;
26499
 
  _arAccntid INTEGER;
26500
 
  _prepaidAccntid INTEGER;
26501
 
  _salescatid INTEGER;
26502
 
  _accntid INTEGER;
26503
 
  _glSequence INTEGER;
26504
 
  _aropenid INTEGER;
26505
 
  _cohistid INTEGER;
26506
 
  _tmp INTEGER;
26507
 
  _test INTEGER;
26508
 
  _taxBaseValue NUMERIC;
26509
 
 
26510
 
BEGIN
26511
 
  _aropenid=pId;
26512
 
  
26513
 
  IF (pAmount <= 0) THEN
26514
 
    RETURN 0;
26515
 
  END IF;
26516
 
 
26517
 
  SELECT findARAccount(pCustid) INTO _arAccntid;
26518
 
  SELECT findPrepaidAccount(pCustid) INTO _prepaidAccntid;
26519
 
 
26520
 
  _accntid := pAccntid;
26521
 
  _salescatid := pSalescatid;
26522
 
 
26523
 
  SELECT cust_name INTO _custName
26524
 
  FROM custinfo
26525
 
  WHERE (cust_id=pCustid);
26526
 
  
26527
 
  PERFORM accnt_id
26528
 
     FROM accnt
26529
 
    WHERE (accnt_id=_accntid);
26530
 
  IF (FOUND) THEN
26531
 
    _prepaidAccntid := _accntid;
26532
 
  ELSE
26533
 
    _accntid := -1;
26534
 
  END IF;
26535
 
 
26536
 
  SELECT accnt_id INTO _tmp
26537
 
    FROM salescat, accnt
26538
 
   WHERE ((salescat_prepaid_accnt_id=accnt_id)
26539
 
     AND  (salescat_id=_salescatid));
26540
 
  IF (FOUND) THEN
26541
 
    _accntid := -1;
26542
 
    _prepaidAccntid := _tmp;
26543
 
  ELSE
26544
 
    _salescatid = -1;
26545
 
  END IF;
26546
 
 
26547
 
  IF (pJournalNumber IS NULL) THEN
26548
 
    _journalNumber := fetchJournalNumber('AR-MISC');
26549
 
  ELSE
26550
 
    _journalNumber := pJournalNumber;
26551
 
  END IF;
26552
 
 
26553
 
  SELECT fetchGLSequence() INTO _glSequence;
26554
 
 
26555
 
  -- CreatelUpdate aropen for full amount
26556
 
  IF (_aropenid IS NOT NULL) THEN
26557
 
    UPDATE aropen SET
26558
 
      aropen_username=getEffectiveXtUser(), aropen_journalnumber=_journalNumber,
26559
 
      aropen_cust_id=pCustid, aropen_docnumber=pDocNumber, aropen_doctype='D', 
26560
 
      aropen_ordernumber=pOrderNumber,aropen_docdate=pDocDate, aropen_duedate=pDueDate, 
26561
 
      aropen_distdate=pDocDate, aropen_terms_id=pTermsid, 
26562
 
      aropen_salesrep_id=pSalesrepid, aropen_amount=round(pAmount, 2), aropen_paid=0, 
26563
 
      aropen_commission_due=pCommissiondue, aropen_commission_paid=FALSE,
26564
 
      aropen_applyto='', aropen_ponumber='', aropen_cobmisc_id=-1,
26565
 
      aropen_open=TRUE, aropen_notes=pNotes, aropen_rsncode_id=pRsncodeid,
26566
 
      aropen_salescat_id=_salescatid, aropen_accnt_id=_accntid, aropen_curr_id=pCurrId
26567
 
    WHERE aropen_id = pId;
26568
 
  ELSE
26569
 
    SELECT NEXTVAL('aropen_aropen_id_seq') INTO _aropenid;
26570
 
    INSERT INTO aropen
26571
 
    ( aropen_id, aropen_username, aropen_journalnumber,
26572
 
      aropen_cust_id, aropen_docnumber, aropen_doctype, aropen_ordernumber,
26573
 
      aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_salesrep_id,
26574
 
      aropen_amount, aropen_paid, aropen_commission_due, aropen_commission_paid,
26575
 
      aropen_applyto, aropen_ponumber, aropen_cobmisc_id,
26576
 
      aropen_open, aropen_notes, aropen_rsncode_id,
26577
 
      aropen_salescat_id, aropen_accnt_id, aropen_curr_id )
26578
 
    VALUES
26579
 
    ( _aropenid, getEffectiveXtUser(), _journalNumber,
26580
 
      pCustid, pDocNumber, 'D', pOrderNumber,
26581
 
      pDocDate, pDueDate, pDocDate, pTermsid, pSalesrepid,
26582
 
      round(pAmount, 2), 0, pCommissiondue, FALSE,
26583
 
      '', '', -1,
26584
 
      TRUE, pNotes, pRsncodeid,
26585
 
      _salescatid, _accntid, pCurrId );
26586
 
  END IF;
26587
 
 
26588
 
  -- Debit the A/R account for the full amount
26589
 
  SELECT insertIntoGLSeries ( _glSequence, 'A/R', 'DM',
26590
 
                              pDocNumber, _arAccntid,
26591
 
                              round(currToBase(pCurrId, pAmount, pDocDate) * -1, 2),
26592
 
                              pDocDate, (_custName || ' ' || pNotes)) INTO _test;
26593
 
 
26594
 
  -- Credit the Tax account for the tax amount
26595
 
  _taxBaseValue := addTaxToGLSeries(_glSequence,
26596
 
                                      'A/R', 'DM', pDocNumber,
26597
 
                                      pCurrId, pDocDate, pDocDate,
26598
 
                                      'aropentax', _aropenid,
26599
 
                                      (_custName || ' ' || pNotes));
26600
 
 
26601
 
  UPDATE aropentax SET taxhist_journalnumber = _journalNumber
26602
 
  WHERE taxhist_parent_id=_aropenid;
26603
 
 
26604
 
  -- Credit the Prepaid account for the basis amount
26605
 
  SELECT insertIntoGLSeries ( _glSequence, 'A/R', 'DM',
26606
 
                              pDocNumber, _prepaidAccntid,
26607
 
                              round(currToBase(pCurrId, (pAmount), pDocDate), 2) - _taxBaseValue,
26608
 
                              pDocDate, (_custName || ' ' || pNotes)) INTO _test;
26609
 
 
26610
 
  --  Commit the GLSeries;
26611
 
  SELECT postGLSeries(_glSequence, _journalNumber) INTO _test;
26612
 
  IF (_test < 0) THEN
26613
 
    DELETE FROM aropen WHERE (aropen_id=_aropenid);
26614
 
    PERFORM deleteGLSeries(_glSequence);
26615
 
    RAISE EXCEPTION 'postGLSeries commit failed with %', _test;
26616
 
  END IF;
26617
 
 
26618
 
  --  Record Sales History
26619
 
  SELECT nextval('cohist_cohist_id_seq') INTO _cohistid;
26620
 
  INSERT INTO cohist
26621
 
  ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id,
26622
 
    cohist_misc_type, cohist_misc_descrip,
26623
 
    cohist_shipdate, cohist_shipvia,
26624
 
    cohist_ordernumber, cohist_ponumber, cohist_orderdate,
26625
 
    cohist_doctype, cohist_invcnumber, cohist_invcdate,
26626
 
    cohist_qtyshipped, cohist_unitprice, cohist_unitcost,
26627
 
    cohist_salesrep_id, cohist_commission, cohist_commissionpaid,
26628
 
    cohist_curr_id, cohist_sequence )
26629
 
  VALUES
26630
 
  ( _cohistid, pCustid, -1, -1,
26631
 
    'M', 'A/R Misc Debit Memo',
26632
 
    pDocDate, '',
26633
 
    '', '', pDocDate,
26634
 
    'D', pDocNumber, pDocDate,
26635
 
    1, (pAmount - _taxBaseValue), 0,
26636
 
    pSalesrepid, pCommissiondue, FALSE,
26637
 
    pCurrId, _glSequence );
26638
 
  INSERT INTO cohisttax
26639
 
  ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id,
26640
 
    taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
26641
 
    taxhist_percent, taxhist_amount, taxhist_tax,
26642
 
    taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
26643
 
    taxhist_journalnumber )
26644
 
  SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id,
26645
 
         taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
26646
 
         taxhist_percent, taxhist_amount, taxhist_tax,
26647
 
         taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
26648
 
         taxhist_journalnumber
26649
 
  FROM aropentax
26650
 
  WHERE (taxhist_parent_id=_aropenid);
26651
 
 
26652
 
  RETURN _aropenid;
26653
 
 
26654
 
END;
26655
 
$_$;
26656
 
 
26657
 
 
26658
 
ALTER FUNCTION public.createardebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, integer, integer, date, integer, integer, numeric, integer) OWNER TO admin;
26659
 
 
26660
 
--
26661
 
--
26662
 
 
26663
 
CREATE FUNCTION createbillingheader(integer) RETURNS integer
26664
 
    LANGUAGE plpgsql
26665
 
    AS $_$
26666
 
DECLARE
26667
 
  pSoheadid             ALIAS FOR $1;
26668
 
  _cobmiscid            INTEGER;
26669
 
  _cohead               cohead%ROWTYPE;
26670
 
  _miscApplied          NUMERIC := 0.0;
26671
 
  _freight              NUMERIC;
26672
 
  _freighttypeid        INTEGER;
26673
 
  _invcDate             DATE;
26674
 
  _schedDate            DATE;
26675
 
  _shipDate             DATE;
26676
 
  _shipVia              TEXT;
26677
 
  _tax                  NUMERIC;
26678
 
 
26679
 
BEGIN
26680
 
 
26681
 
  --  Fetch cohead
26682
 
  SELECT * INTO _cohead
26683
 
  FROM cohead
26684
 
  WHERE (cohead_id=pSoheadid);
26685
 
 
26686
 
  --  Check for an existing cobmisc
26687
 
  SELECT cobmisc_id INTO _cobmiscid
26688
 
  FROM cobmisc
26689
 
  WHERE ( (NOT cobmisc_posted)
26690
 
   AND (cobmisc_cohead_id=pSoheadid) );
26691
 
 
26692
 
  IF (FOUND) THEN
26693
 
  --  Find a Shipping-Entered freight charge
26694
 
    SELECT SUM(currToCurr(shiphead_freight_curr_id, _cohead.cohead_curr_id,
26695
 
                          shiphead_freight, CURRENT_DATE)) INTO _freight
26696
 
    FROM (
26697
 
    SELECT shiphead_id, shiphead_freight_curr_id, shiphead_freight
26698
 
    FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id AND NOT shipitem_invoiced)
26699
 
    WHERE ((shiphead_order_type='SO')
26700
 
      AND  (shiphead_order_id=pSoheadid))
26701
 
    GROUP BY shiphead_id, shiphead_freight_curr_id, shiphead_freight) AS data;
26702
 
 
26703
 
    IF (_freight IS NOT NULL) THEN
26704
 
      UPDATE cobmisc SET cobmisc_freight = _freight
26705
 
      WHERE (cobmisc_id=_cobmiscid);
26706
 
    END IF;
26707
 
 
26708
 
    RETURN _cobmiscid;
26709
 
  END IF;
26710
 
 
26711
 
  --  Find misc charges that have already been applied for the S/O
26712
 
  SELECT COALESCE(SUM(cobmisc_misc), 0.0) INTO _miscApplied
26713
 
  FROM cobmisc
26714
 
  WHERE (cobmisc_cohead_id=pSoheadid);
26715
 
 
26716
 
  SELECT NEXTVAL('cobmisc_cobmisc_id_seq') INTO _cobmiscid;
26717
 
 
26718
 
  --  Check for a valid shipdate
26719
 
  SELECT MIN(shiphead_shipdate) INTO _shipDate
26720
 
  FROM shiphead, shipitem
26721
 
  WHERE ( (shipitem_shiphead_id=shiphead_id)
26722
 
   AND (NOT shipitem_invoiced)
26723
 
   AND (shiphead_shipped)
26724
 
   AND (shiphead_order_type='SO')
26725
 
   AND (shiphead_order_id=pSoheadid) );
26726
 
 
26727
 
  --  Schema shouldn't allow, but we'll try for now
26728
 
  IF (_shipDate IS NULL) THEN
26729
 
    SELECT MAX(shipitem_shipdate) INTO _shipDate
26730
 
    FROM shipitem, shiphead
26731
 
    WHERE ( (shipitem_shiphead_id=shiphead_id)
26732
 
     AND (shiphead_order_type='SO')
26733
 
     AND (shiphead_order_id=pSoheadid) );
26734
 
 
26735
 
    --  How about a transaction date
26736
 
    IF (_shipDate IS NULL) THEN
26737
 
      SELECT COALESCE(MAX(shipitem_transdate), CURRENT_DATE) INTO _shipDate
26738
 
      FROM shipitem, shiphead
26739
 
      WHERE ((shipitem_shiphead_id=shiphead_id)
26740
 
        AND  (shiphead_order_type='SO')
26741
 
        AND  (shiphead_order_id=pSoheadid) );
26742
 
    END IF;
26743
 
  END IF;
26744
 
 
26745
 
  --  Get the earliest schedule date for this order.
26746
 
  SELECT MIN(coitem_scheddate) INTO _schedDate
26747
 
    FROM coitem
26748
 
   WHERE ((coitem_status <> 'X') AND (coitem_cohead_id=pSoheadid));
26749
 
 
26750
 
  IF (_schedDate IS NULL) THEN
26751
 
    _schedDate := _shipDate;
26752
 
  END IF;
26753
 
 
26754
 
  --  Find a Shipping-Entered freight charge
26755
 
  SELECT SUM(currToCurr(shiphead_freight_curr_id, _cohead.cohead_curr_id,
26756
 
                        shiphead_freight, CURRENT_DATE)), shiphead_shipvia
26757
 
         INTO _freight, _shipVia
26758
 
  FROM (
26759
 
  SELECT shiphead_id, shiphead_freight_curr_id, shiphead_freight, shiphead_shipvia
26760
 
  FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id AND NOT shipitem_invoiced)
26761
 
  WHERE ((shiphead_order_type='SO')
26762
 
    AND  (shiphead_order_id=pSoheadid))
26763
 
  GROUP BY shiphead_id, shiphead_freight_curr_id, shiphead_freight, shiphead_shipvia) AS data
26764
 
  GROUP BY shiphead_shipvia;
26765
 
 
26766
 
  --  Nope, use the cohead freight charge
26767
 
  IF (_freight IS NULL) THEN
26768
 
    _freight       := _cohead.cohead_freight;
26769
 
  END IF;
26770
 
 
26771
 
  --  Finally, look for a Shipping-Entered Ship Via
26772
 
  SELECT shiphead_shipvia INTO _shipVia
26773
 
  FROM shiphead, shipitem
26774
 
  WHERE ( (shipitem_shiphead_id=shiphead_id)
26775
 
   AND (NOT shipitem_invoiced)
26776
 
   AND (shiphead_order_type='SO')
26777
 
   AND (shiphead_order_id=pSoheadid) )
26778
 
  LIMIT 1;
26779
 
  IF (NOT FOUND) THEN
26780
 
    _shipVia := _cohead.cohead_shipvia;
26781
 
  END IF;
26782
 
 
26783
 
  --Determine any tax
26784
 
 
26785
 
  SELECT 
26786
 
  getFreightTaxTypeId() INTO _freighttypeid;
26787
 
  SELECT SUM(COALESCE(taxdetail_tax, 0.00)) INTO _tax
26788
 
  FROM calculatetaxdetail(_cohead.cohead_taxzone_id, _freighttypeid, _cohead.cohead_orderdate,_cohead.cohead_curr_id, _freight);
26789
 
 
26790
 
  --  Determine if we are using the _shipDate or _schedDate or current_date for the _invcDate
26791
 
  IF( fetchMetricText('InvoiceDateSource')='scheddate') THEN
26792
 
    _invcDate := _schedDate;
26793
 
  ELSIF( fetchMetricText('InvoiceDateSource')='shipdate') THEN
26794
 
    _invcDate := _shipDate;
26795
 
  ELSE
26796
 
    _invcDate := current_date;
26797
 
  END IF;
26798
 
 
26799
 
   INSERT INTO cobmisc (
26800
 
        cobmisc_id, cobmisc_cohead_id, cobmisc_shipvia, cobmisc_freight, cobmisc_misc, cobmisc_payment 
26801
 
        ,cobmisc_notes,cobmisc_shipdate ,cobmisc_invcdate,cobmisc_posted ,cobmisc_misc_accnt_id 
26802
 
        ,cobmisc_misc_descrip,cobmisc_closeorder,cobmisc_curr_id
26803
 
        ,cobmisc_taxtype_id,cobmisc_taxzone_id
26804
 
        )
26805
 
        SELECT
26806
 
        _cobmiscid,_cohead.cohead_id,_shipVia,_freight,
26807
 
        CASE WHEN (_cohead.cohead_misc - _miscApplied = 0.0) THEN 0.0
26808
 
             ELSE (_cohead.cohead_misc - _miscApplied) END,0,
26809
 
        _cohead.cohead_ordercomments,_shipDate,_invcDate,FALSE,_cohead.cohead_misc_accnt_id,
26810
 
        _cohead.cohead_misc_descrip,NOT(cust_backorder),_cohead.cohead_curr_id,
26811
 
        _cohead.cohead_taxtype_id,_cohead.cohead_taxzone_id
26812
 
        FROM custinfo
26813
 
        WHERE (cust_id=_cohead.cohead_cust_id);
26814
 
 
26815
 
  RETURN _cobmiscid;
26816
 
 
26817
 
END;
26818
 
$_$;
26819
 
 
26820
 
 
26821
 
ALTER FUNCTION public.createbillingheader(integer) OWNER TO admin;
26822
 
 
26823
 
--
26824
 
--
26825
 
 
26826
 
CREATE FUNCTION createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text) RETURNS integer
26827
 
    LANGUAGE plpgsql
26828
 
    AS $_$
26829
 
DECLARE
26830
 
  pBomitemid ALIAS FOR $1;
26831
 
  pParentItemid ALIAS FOR $2;
26832
 
  pComponentItemid ALIAS FOR $3;
26833
 
  pSeqNumber ALIAS FOR $4;
26834
 
  pIssueMethod ALIAS FOR $5;
26835
 
  pUomId ALIAS FOR $6;
26836
 
  pQtyPer ALIAS FOR $7;
26837
 
  pScrap ALIAS FOR $8;
26838
 
  pEffective ALIAS FOR $9;
26839
 
  pExpires ALIAS FOR $10;
26840
 
  pCreateWo ALIAS FOR $11;
26841
 
  pBOOItemseqid ALIAS FOR $12;
26842
 
  pSchedAtWooper ALIAS FOR $13;
26843
 
  pECN ALIAS FOR $14;
26844
 
  pSubType ALIAS FOR $15;
26845
 
  pRevisionid ALIAS FOR $16;
26846
 
  pCharId ALIAS FOR $17;
26847
 
  pCharVal ALIAS FOR $18;
26848
 
  _bomworksetid INTEGER;
26849
 
  _temp INTEGER;
26850
 
  _bomitemid INTEGER;
26851
 
 
26852
 
BEGIN
26853
 
 
26854
 
  SELECT createBOMItem( pBomitemid, pParentItemid, pComponentItemid,
26855
 
                        pSeqNumber, pIssueMethod,
26856
 
                        pUomId, pQtyPer, pScrap,
26857
 
                        pEffective, pExpires,
26858
 
                        pCreateWo, pBOOItemseqid, pSchedAtWooper, pECN, pSubType, pRevisionid, pCharId, pCharVal, NULL, NULL ) INTO _bomitemid;
26859
 
 
26860
 
  RETURN _bomitemid;
26861
 
  
26862
 
END;
26863
 
$_$;
26864
 
 
26865
 
 
26866
 
ALTER FUNCTION public.createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text) OWNER TO admin;
26867
 
 
26868
 
--
26869
 
--
26870
 
 
26871
 
CREATE FUNCTION createbomitem(integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) RETURNS integer
26872
 
    LANGUAGE plpgsql
26873
 
    AS $_$
26874
 
DECLARE
26875
 
  pBomitemid ALIAS FOR $1;
26876
 
  pParentItemid ALIAS FOR $2;
26877
 
  pComponentItemid ALIAS FOR $3;
26878
 
  pIssueMethod ALIAS FOR $4;
26879
 
  pUomId ALIAS FOR $5;
26880
 
  pQtyPer ALIAS FOR $6;
26881
 
  pScrap ALIAS FOR $7;
26882
 
  pEffective ALIAS FOR $8;
26883
 
  pExpires ALIAS FOR $9;
26884
 
  pCreateWo ALIAS FOR $10;
26885
 
  pBOOItemseqid ALIAS FOR $11;
26886
 
  pSchedAtWooper ALIAS FOR $12;
26887
 
  pECN ALIAS FOR $13;
26888
 
  pSubType ALIAS FOR $14;
26889
 
  pRevisionid ALIAS FOR $15;
26890
 
  pCharId ALIAS FOR $16;
26891
 
  pCharVal ALIAS FOR $17;
26892
 
  pNotes ALIAS FOR $18;
26893
 
  pRef ALIAS FOR $19;
26894
 
  _seqNumber INTEGER;
26895
 
  _bomitemid INTEGER;
26896
 
 
26897
 
BEGIN
26898
 
 
26899
 
  SELECT MAX(bomitem_seqnumber) INTO _seqNumber
26900
 
  FROM bomitem(pParentItemid,pRevisionid);
26901
 
 
26902
 
  IF (_seqNumber IS NOT NULL) THEN
26903
 
   _seqNumber := (_seqNumber + 10);
26904
 
  ELSE
26905
 
   _seqNumber := 10;
26906
 
  END IF;
26907
 
 
26908
 
  SELECT createBOMItem( pBomitemid, pParentItemid, pComponentItemid,
26909
 
                        _seqNumber, pIssueMethod,
26910
 
                        pUomId, pQtyPer, pScrap,
26911
 
                        pEffective, pExpires,
26912
 
                        pCreateWo, pBOOItemseqid, pSchedAtWooper, pECN, pSubType, pRevisionid, pCharId, pCharVal, pNotes, pRef ) INTO _bomitemid;
26913
 
 
26914
 
  RETURN _bomitemid;
26915
 
 
26916
 
END;
26917
 
$_$;
26918
 
 
26919
 
 
26920
 
ALTER FUNCTION public.createbomitem(integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) OWNER TO admin;
26921
 
 
26922
 
--
26923
 
--
26924
 
 
26925
 
CREATE FUNCTION createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text) RETURNS integer
26926
 
    LANGUAGE plpgsql
26927
 
    AS $_$
26928
 
DECLARE
26929
 
  pBomitemid ALIAS FOR $1;
26930
 
  pParentItemid ALIAS FOR $2;
26931
 
  pComponentItemid ALIAS FOR $3;
26932
 
  pSeqNumber ALIAS FOR $4;
26933
 
  pIssueMethod ALIAS FOR $5;
26934
 
  pUomId ALIAS FOR $6;
26935
 
  pQtyFxd ALIAS FOR $7;
26936
 
  pQtyPer ALIAS FOR $8;
26937
 
  pScrap ALIAS FOR $9;
26938
 
  pEffective ALIAS FOR $10;
26939
 
  pExpires ALIAS FOR $11;
26940
 
  pCreateWo ALIAS FOR $12;
26941
 
  pBOOItemseqid ALIAS FOR $13;
26942
 
  pSchedAtWooper ALIAS FOR $14;
26943
 
  pECN ALIAS FOR $15;
26944
 
  pSubType ALIAS FOR $16;
26945
 
  pRevisionid ALIAS FOR $17;
26946
 
  pCharId ALIAS FOR $18;
26947
 
  pCharVal ALIAS FOR $19;
26948
 
  _bomworksetid INTEGER;
26949
 
  _temp INTEGER;
26950
 
  _bomitemid INTEGER;
26951
 
 
26952
 
BEGIN
26953
 
 
26954
 
  SELECT createBOMItem( pBomitemid, pParentItemid, pComponentItemid,
26955
 
                        pSeqNumber, pIssueMethod,
26956
 
                        pUomId, pQtyFxd, pQtyPer, pScrap,
26957
 
                        pEffective, pExpires,
26958
 
                        pCreateWo, pBOOItemseqid, pSchedAtWooper, pECN, pSubType, pRevisionid, pCharId, pCharVal, NULL, NULL ) INTO _bomitemid;
26959
 
 
26960
 
  RETURN _bomitemid;
26961
 
  
26962
 
END;
26963
 
$_$;
26964
 
 
26965
 
 
26966
 
ALTER FUNCTION public.createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text) OWNER TO admin;
26967
 
 
26968
 
--
26969
 
--
26970
 
 
26971
 
CREATE FUNCTION createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) RETURNS integer
26972
 
    LANGUAGE plpgsql
26973
 
    AS $_$
26974
 
DECLARE
26975
 
  pBomitemid ALIAS FOR $1;
26976
 
  pParentItemid ALIAS FOR $2;
26977
 
  pComponentItemid ALIAS FOR $3;
26978
 
  pSeqNumber ALIAS FOR $4;
26979
 
  pIssueMethod ALIAS FOR $5;
26980
 
  pUomId ALIAS FOR $6;
26981
 
  pQtyPer ALIAS FOR $7;
26982
 
  pScrap ALIAS FOR $8;
26983
 
  pEffective ALIAS FOR $9;
26984
 
  pExpires ALIAS FOR $10;
26985
 
  pCreateWo ALIAS FOR $11;
26986
 
  pBOOItemseqid ALIAS FOR $12;
26987
 
  pSchedAtWooper ALIAS FOR $13;
26988
 
  pECN ALIAS FOR $14;
26989
 
  pSubType ALIAS FOR $15;
26990
 
  pRevisionid ALIAS FOR $16;
26991
 
  pCharId ALIAS FOR $17;
26992
 
  pCharVal ALIAS FOR $18;
26993
 
  pNotes ALIAS FOR $19;
26994
 
  pRef ALIAS FOR $20;
26995
 
  _bomworksetid INTEGER;
26996
 
  _temp INTEGER;
26997
 
 
26998
 
BEGIN
26999
 
 
27000
 
  IF (pParentItemid = pComponentItemid) THEN
27001
 
    RETURN -1;
27002
 
  END IF;
27003
 
 
27004
 
  IF ( SELECT (item_type IN ('M', 'F'))
27005
 
       FROM item
27006
 
       WHERE (item_id=pComponentItemid) ) THEN
27007
 
    SELECT indentedWhereUsed(pParentItemid) INTO _bomworksetid;
27008
 
    SELECT bomwork_id INTO _temp
27009
 
    FROM bomwork
27010
 
    WHERE ( (bomwork_set_id=_bomworksetid)
27011
 
     AND (bomwork_item_id=pComponentItemid) )
27012
 
    LIMIT 1;
27013
 
    IF (FOUND) THEN
27014
 
      PERFORM deleteBOMWorkset(_bomworksetid);
27015
 
      RETURN -2;
27016
 
    END IF;
27017
 
  END IF;
27018
 
 
27019
 
  PERFORM deleteBOMWorkset(_bomworksetid);
27020
 
 
27021
 
  INSERT INTO bomitem
27022
 
  ( bomitem_id, bomitem_parent_item_id, bomitem_item_id,
27023
 
    bomitem_seqnumber, bomitem_issuemethod,
27024
 
    bomitem_uom_id, bomitem_qtyper, bomitem_scrap,
27025
 
    bomitem_effective, bomitem_expires,
27026
 
    bomitem_createwo,
27027
 
    bomitem_booitem_seq_id, bomitem_schedatwooper,
27028
 
    bomitem_ecn, bomitem_subtype, bomitem_moddate, bomitem_rev_id,
27029
 
    bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref )
27030
 
  VALUES
27031
 
  ( pBomitemid, pParentItemid, pComponentItemid,
27032
 
    pSeqNumber, pIssueMethod,
27033
 
    pUomId, pQtyPer, pScrap,
27034
 
    pEffective, pExpires,
27035
 
    pCreateWo,
27036
 
    pBOOItemseqid, COALESCE(pSchedAtWooper, FALSE),
27037
 
    pECN, pSubType, CURRENT_DATE, pRevisionid,
27038
 
    pCharId,pCharVal,pNotes, pRef );
27039
 
 
27040
 
  RETURN pBomitemid;
27041
 
 
27042
 
END;
27043
 
$_$;
27044
 
 
27045
 
 
27046
 
ALTER FUNCTION public.createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) OWNER TO admin;
27047
 
 
27048
 
--
27049
 
--
27050
 
 
27051
 
CREATE FUNCTION createbomitem(integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) RETURNS integer
27052
 
    LANGUAGE plpgsql
27053
 
    AS $_$
27054
 
DECLARE
27055
 
  pBomitemid ALIAS FOR $1;
27056
 
  pParentItemid ALIAS FOR $2;
27057
 
  pComponentItemid ALIAS FOR $3;
27058
 
  pIssueMethod ALIAS FOR $4;
27059
 
  pUomId ALIAS FOR $5;
27060
 
  pQtyFxd ALIAS FOR $6;
27061
 
  pQtyPer ALIAS FOR $7;
27062
 
  pScrap ALIAS FOR $8;
27063
 
  pEffective ALIAS FOR $9;
27064
 
  pExpires ALIAS FOR $10;
27065
 
  pCreateWo ALIAS FOR $11;
27066
 
  pBOOItemseqid ALIAS FOR $12;
27067
 
  pSchedAtWooper ALIAS FOR $13;
27068
 
  pECN ALIAS FOR $14;
27069
 
  pSubType ALIAS FOR $15;
27070
 
  pRevisionid ALIAS FOR $16;
27071
 
  pCharId ALIAS FOR $17;
27072
 
  pCharVal ALIAS FOR $18;
27073
 
  pNotes ALIAS FOR $19;
27074
 
  pRef ALIAS FOR $20;
27075
 
  _seqNumber INTEGER;
27076
 
  _bomitemid INTEGER;
27077
 
 
27078
 
BEGIN
27079
 
 
27080
 
  SELECT MAX(bomitem_seqnumber) INTO _seqNumber
27081
 
  FROM bomitem(pParentItemid,pRevisionid);
27082
 
 
27083
 
  IF (_seqNumber IS NOT NULL) THEN
27084
 
   _seqNumber := (_seqNumber + 10);
27085
 
  ELSE
27086
 
   _seqNumber := 10;
27087
 
  END IF;
27088
 
 
27089
 
  SELECT createBOMItem( pBomitemid, pParentItemid, pComponentItemid,
27090
 
                        _seqNumber, pIssueMethod,
27091
 
                        pUomId, pQtyFxd, pQtyPer, pScrap,
27092
 
                        pEffective, pExpires,
27093
 
                        pCreateWo, pBOOItemseqid, pSchedAtWooper, pECN, pSubType, pRevisionid, pCharId, pCharVal, pNotes, pRef ) INTO _bomitemid;
27094
 
 
27095
 
  RETURN _bomitemid;
27096
 
 
27097
 
END;
27098
 
$_$;
27099
 
 
27100
 
 
27101
 
ALTER FUNCTION public.createbomitem(integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) OWNER TO admin;
27102
 
 
27103
 
--
27104
 
--
27105
 
 
27106
 
CREATE FUNCTION createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) RETURNS integer
27107
 
    LANGUAGE plpgsql
27108
 
    AS $_$
27109
 
DECLARE
27110
 
  pBomitemid ALIAS FOR $1;
27111
 
  pParentItemid ALIAS FOR $2;
27112
 
  pComponentItemid ALIAS FOR $3;
27113
 
  pSeqNumber ALIAS FOR $4;
27114
 
  pIssueMethod ALIAS FOR $5;
27115
 
  pUomId ALIAS FOR $6;
27116
 
  pQtyFxd ALIAS FOR $7;
27117
 
  pQtyPer ALIAS FOR $8;
27118
 
  pScrap ALIAS FOR $9;
27119
 
  pEffective ALIAS FOR $10;
27120
 
  pExpires ALIAS FOR $11;
27121
 
  pCreateWo ALIAS FOR $12;
27122
 
  pBOOItemseqid ALIAS FOR $13;
27123
 
  pSchedAtWooper ALIAS FOR $14;
27124
 
  pECN ALIAS FOR $15;
27125
 
  pSubType ALIAS FOR $16;
27126
 
  pRevisionid ALIAS FOR $17;
27127
 
  pCharId ALIAS FOR $18;
27128
 
  pCharVal ALIAS FOR $19;
27129
 
  pNotes ALIAS FOR $20;
27130
 
  pRef ALIAS FOR $21;
27131
 
  _bomworksetid INTEGER;
27132
 
  _temp INTEGER;
27133
 
 
27134
 
BEGIN
27135
 
 
27136
 
  IF (pParentItemid = pComponentItemid) THEN
27137
 
    RETURN -1;
27138
 
  END IF;
27139
 
 
27140
 
  SELECT indentedWhereUsed(pParentItemid) INTO _bomworksetid;
27141
 
  SELECT bomwork_id INTO _temp
27142
 
  FROM bomwork
27143
 
  WHERE ( (bomwork_set_id=_bomworksetid)
27144
 
   AND (bomwork_item_id=pComponentItemid) )
27145
 
  LIMIT 1;
27146
 
  IF (FOUND) THEN
27147
 
    PERFORM deleteBOMWorkset(_bomworksetid);
27148
 
    RETURN -2;
27149
 
  END IF;
27150
 
 
27151
 
  PERFORM deleteBOMWorkset(_bomworksetid);
27152
 
 
27153
 
  INSERT INTO bomitem
27154
 
  ( bomitem_id, bomitem_parent_item_id, bomitem_item_id,
27155
 
    bomitem_seqnumber, bomitem_issuemethod,
27156
 
    bomitem_uom_id, bomitem_qtyfxd, bomitem_qtyper, bomitem_scrap,
27157
 
    bomitem_effective, bomitem_expires,
27158
 
    bomitem_createwo,
27159
 
    bomitem_booitem_seq_id, bomitem_schedatwooper,
27160
 
    bomitem_ecn, bomitem_subtype, bomitem_moddate, bomitem_rev_id,
27161
 
    bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref )
27162
 
  VALUES
27163
 
  ( pBomitemid, pParentItemid, pComponentItemid,
27164
 
    pSeqNumber, pIssueMethod,
27165
 
    pUomId, pQtyFxd, pQtyPer, pScrap,
27166
 
    pEffective, pExpires,
27167
 
    pCreateWo,
27168
 
    pBOOItemseqid, COALESCE(pSchedAtWooper, FALSE),
27169
 
    pECN, pSubType, CURRENT_DATE, pRevisionid,
27170
 
    pCharId,pCharVal,pNotes, pRef );
27171
 
 
27172
 
  RETURN pBomitemid;
27173
 
 
27174
 
END;
27175
 
$_$;
27176
 
 
27177
 
 
27178
 
ALTER FUNCTION public.createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) OWNER TO admin;
27179
 
 
27180
 
--
27181
 
--
27182
 
 
27183
 
CREATE FUNCTION createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean) RETURNS integer
27184
 
    LANGUAGE plpgsql
27185
 
    AS $_$
27186
 
DECLARE
27187
 
  pBankaccntid          ALIAS FOR  $1;
27188
 
  pRecipType            ALIAS FOR  $2;
27189
 
  pRecipId              ALIAS FOR  $3;
27190
 
  pCheckDate            ALIAS FOR  $4;
27191
 
  pAmount               ALIAS FOR  $5;
27192
 
  pCurrid               ALIAS FOR  $6;
27193
 
  pExpcatid             ALIAS FOR  $7;
27194
 
  _journalNumber        INTEGER := $8;
27195
 
  pFor                  ALIAS FOR  $9;
27196
 
  pNotes                ALIAS FOR $10;
27197
 
  pMisc                 ALIAS FOR $11;
27198
 
  _checkid INTEGER;
27199
 
BEGIN
27200
 
 
27201
 
  SELECT createCheck(pBankaccntid,pRecipType,pRecipId,pCheckDate,pAmount,pCurrid,pExpcatid,_journalNumber,pFor,pNotes,pMisc,NULL) INTO _checkid;
27202
 
  RETURN _checkid;
27203
 
 
27204
 
END;
27205
 
$_$;
27206
 
 
27207
 
 
27208
 
ALTER FUNCTION public.createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean) OWNER TO admin;
27209
 
 
27210
 
--
27211
 
--
27212
 
 
27213
 
CREATE FUNCTION createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean, integer) RETURNS integer
27214
 
    LANGUAGE plpgsql
27215
 
    AS $_$
27216
 
DECLARE
27217
 
  pBankaccntid          ALIAS FOR  $1;
27218
 
  pRecipType            ALIAS FOR  $2;
27219
 
  pRecipId              ALIAS FOR  $3;
27220
 
  pCheckDate            ALIAS FOR  $4;
27221
 
  pAmount               ALIAS FOR  $5;
27222
 
  pCurrid               ALIAS FOR  $6;
27223
 
  pExpcatid             ALIAS FOR  $7;
27224
 
  _journalNumber        INTEGER := $8;
27225
 
  pFor                  ALIAS FOR  $9;
27226
 
  pNotes                ALIAS FOR $10;
27227
 
  pMisc                 ALIAS FOR $11;
27228
 
  pAropenid             ALIAS FOR $12;
27229
 
  _checkid              INTEGER;
27230
 
  _check_curr_rate      NUMERIC;
27231
 
  _bankaccnt_currid     INTEGER;
27232
 
 
27233
 
BEGIN
27234
 
  SELECT bankaccnt_curr_id,currRate(bankaccnt_curr_id,pCheckDate) INTO _bankaccnt_currid, _check_curr_rate
27235
 
  FROM bankaccnt
27236
 
  WHERE bankaccnt_id = pBankaccntid;
27237
 
  IF (NOT FOUND) THEN
27238
 
    RETURN -1;
27239
 
  END IF;
27240
 
 
27241
 
  IF (pRecipType NOT IN ('C', 'T', 'V')) THEN
27242
 
    RETURN -2;
27243
 
  END IF;
27244
 
 
27245
 
  IF (pCheckDate IS NULL) THEN
27246
 
    RETURN -3;
27247
 
  END IF;
27248
 
 
27249
 
  IF (pAmount <= 0) THEN
27250
 
    RETURN -4;
27251
 
  END IF;
27252
 
 
27253
 
  IF (pCurrid IS NULL
27254
 
      OR NOT EXISTS(SELECT * FROM curr_symbol WHERE (curr_id=pCurrid))) THEN
27255
 
    RETURN -5;
27256
 
  END IF;
27257
 
 
27258
 
  IF (pExpcatid IS NOT NULL
27259
 
      AND NOT EXISTS(SELECT * FROM expcat WHERE (expcat_id=pExpcatid))) THEN
27260
 
    RETURN -6;
27261
 
  END IF;
27262
 
 
27263
 
 
27264
 
  _checkid := NEXTVAL('checkhead_checkhead_id_seq');
27265
 
 
27266
 
  INSERT INTO checkhead
27267
 
  ( checkhead_id,               checkhead_recip_type,   checkhead_recip_id,
27268
 
    checkhead_bankaccnt_id,     checkhead_number,
27269
 
    checkhead_amount,
27270
 
    checkhead_checkdate,        checkhead_misc,         checkhead_expcat_id,
27271
 
    checkhead_journalnumber,    checkhead_for,          checkhead_notes,
27272
 
    checkhead_curr_id )
27273
 
  VALUES
27274
 
  ( _checkid,                   pRecipType,             pRecipId,
27275
 
    pBankaccntid,               -1, --fetchNextCheckNumber(pBankaccntid),
27276
 
    currToCurr(pCurrid, _bankaccnt_currid, pAmount, pCheckDate),
27277
 
    pCheckDate,                 COALESCE(pMisc, FALSE), pExpcatid,
27278
 
    _journalNumber,             pFor,                   pNotes,
27279
 
    _bankaccnt_currid );
27280
 
 
27281
 
  IF (pAropenid IS NOT NULL AND fetchmetricbool('EnableReturnAuth')) THEN
27282
 
    INSERT INTO checkitem (checkitem_checkhead_id,checkitem_amount,checkitem_discount,checkitem_ponumber,
27283
 
                           checkitem_aropen_id,checkitem_docdate,checkitem_curr_id,checkitem_cmnumber,
27284
 
                           checkitem_ranumber, checkitem_curr_rate)
27285
 
    SELECT _checkid, currToCurr(checkhead_curr_id, aropen_curr_id, pAmount, checkhead_checkdate),
27286
 
      0,cmhead_custponumber,pAropenid,aropen_docdate,aropen_curr_id,cmhead_number,rahead_number,
27287
 
      1 / (_check_curr_rate / aropen_curr_rate)
27288
 
    FROM checkhead, aropen
27289
 
      LEFT OUTER JOIN cmhead ON (aropen_docnumber=cmhead_number)
27290
 
      LEFT OUTER JOIN rahead ON (cmhead_rahead_id=rahead_id)
27291
 
    WHERE ((aropen_id=pAropenid)
27292
 
     AND (checkhead_id=_checkid));
27293
 
  ELSIF (pAropenid IS NOT NULL) THEN
27294
 
    INSERT INTO checkitem (checkitem_checkhead_id,checkitem_amount,checkitem_discount,checkitem_ponumber,
27295
 
                           checkitem_aropen_id,checkitem_docdate,checkitem_curr_id,checkitem_cmnumber,
27296
 
                           checkitem_ranumber, checkitem_curr_rate)
27297
 
    SELECT _checkid,currToCurr(checkhead_curr_id, aropen_curr_id, pAmount, checkhead_checkdate),
27298
 
      0,cmhead_custponumber,pAropenid,aropen_docdate,aropen_curr_id,cmhead_number,NULL,
27299
 
      1 / (_check_curr_rate / aropen_curr_rate)
27300
 
    FROM checkhead, aropen
27301
 
      LEFT OUTER JOIN cmhead ON (aropen_docnumber=cmhead_number)
27302
 
    WHERE ((aropen_id=pAropenid)
27303
 
     AND (checkhead_id=_checkid));
27304
 
  END IF;
27305
 
  
27306
 
 
27307
 
  RETURN _checkid;
27308
 
 
27309
 
END;
27310
 
$_$;
27311
 
 
27312
 
 
27313
 
ALTER FUNCTION public.createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean, integer) OWNER TO admin;
27314
 
 
27315
 
--
27316
 
--
27317
 
 
27318
 
CREATE FUNCTION createchecks(pbankaccntid integer, pcheckdate date) RETURNS integer
27319
 
    LANGUAGE plpgsql
27320
 
    AS $_$
27321
 
DECLARE
27322
 
  _v RECORD;
27323
 
  _r RECORD;
27324
 
  _c RECORD;
27325
 
  _checkid              INTEGER;
27326
 
  _counter              INTEGER := 0;
27327
 
  _check_curr_id        INTEGER;
27328
 
  _check_curr_rate      NUMERIC;
27329
 
 
27330
 
BEGIN
27331
 
 
27332
 
  SELECT bankaccnt_curr_id, currRate(bankaccnt_curr_id, pCheckDate) 
27333
 
    INTO _check_curr_id, _check_curr_rate
27334
 
    FROM bankaccnt
27335
 
    WHERE ( bankaccnt_id = pBankaccntid );
27336
 
  FOR _v IN SELECT DISTINCT vend_id, vend_number, vend_name
27337
 
              FROM apselect
27338
 
              JOIN apopen   ON (apselect_apopen_id=apopen_id)
27339
 
              JOIN vendinfo ON (apopen_vend_id=vend_id)
27340
 
            WHERE ((apselect_bankaccnt_id=pBankaccntid)
27341
 
               AND (apselect_date <= pCheckDate)) LOOP
27342
 
 
27343
 
    -- if we owe this vendor anything (we might not) then create a check
27344
 
    -- allow $0 checks
27345
 
    IF ((SELECT SUM(CASE apopen_doctype WHEN 'C' THEN (apselect_amount * -1.0)
27346
 
                                        ELSE apselect_amount END * _check_curr_rate / apopen_curr_rate)          
27347
 
         FROM apselect JOIN apopen ON (apopen_id=apselect_apopen_id)
27348
 
         WHERE ((apopen_vend_id=_v.vend_id)
27349
 
           AND  (apselect_bankaccnt_id=pBankaccntid)) ) >= 0) THEN
27350
 
      -- 0.01 is a temporary amount; we''ll update the check amount later
27351
 
      _checkid := createCheck(pBankaccntid,     'V',    _v.vend_id,
27352
 
                              pCheckDate,               0.01,   _check_curr_id,
27353
 
                              NULL,             NULL, '',       '',     FALSE);
27354
 
 
27355
 
      FOR _r IN SELECT apopen_id, apselect_id,
27356
 
                       apopen_docnumber, apopen_invcnumber, apopen_ponumber,
27357
 
                       apopen_docdate, apselect_curr_id,
27358
 
                       apselect_amount, apselect_discount
27359
 
                FROM apselect, apopen
27360
 
                WHERE ( (apselect_apopen_id=apopen_id)
27361
 
                 AND (apopen_vend_id=_v.vend_id)
27362
 
                 AND (apselect_bankaccnt_id=pBankaccntid) ) LOOP
27363
 
        INSERT INTO checkitem
27364
 
        ( checkitem_checkhead_id, checkitem_apopen_id,
27365
 
          checkitem_vouchernumber, checkitem_invcnumber, checkitem_ponumber,
27366
 
          checkitem_amount, checkitem_discount, checkitem_docdate,
27367
 
          checkitem_curr_id, checkitem_curr_rate )
27368
 
        VALUES
27369
 
        ( _checkid, _r.apopen_id,
27370
 
          _r.apopen_docnumber, _r.apopen_invcnumber, _r.apopen_ponumber,
27371
 
          _r.apselect_amount, _r.apselect_discount, _r.apopen_docdate,
27372
 
          _r.apselect_curr_id, 
27373
 
          1 / (_check_curr_rate / currRate(_r.apselect_curr_id, pCheckdate))  );
27374
 
 
27375
 
        DELETE FROM apselect
27376
 
        WHERE (apselect_id=_r.apselect_id);
27377
 
 
27378
 
      END LOOP;
27379
 
 
27380
 
      -- one check can pay for purchases on multiple dates in multiple currencies
27381
 
      UPDATE checkhead
27382
 
      SET checkhead_amount = (SELECT SUM(CASE WHEN (apopen_doctype='C') THEN checkitem_amount / checkitem_curr_rate * -1.0
27383
 
                                              ELSE checkitem_amount / checkitem_curr_rate END)
27384
 
                              FROM checkitem LEFT OUTER JOIN apopen ON (apopen_id=checkitem_apopen_id)
27385
 
                              WHERE (checkitem_checkhead_id=checkhead_id))
27386
 
      WHERE (checkhead_id=_checkid);
27387
 
 
27388
 
      _counter := (_counter + 1);
27389
 
    END IF;
27390
 
 
27391
 
  END LOOP;
27392
 
 
27393
 
  RETURN _counter;
27394
 
 
27395
 
END;
27396
 
$_$;
27397
 
 
27398
 
 
27399
 
ALTER FUNCTION public.createchecks(pbankaccntid integer, pcheckdate date) OWNER TO admin;
27400
 
 
27401
 
--
27402
 
--
27403
 
 
27404
 
CREATE FUNCTION createcounttag(integer, text, boolean, boolean) RETURNS integer
27405
 
    LANGUAGE plpgsql
27406
 
    AS $_$
27407
 
DECLARE
27408
 
  pItemsiteid ALIAS FOR $1;
27409
 
  pComments ALIAS FOR $2;
27410
 
  pPriority ALIAS FOR $3;
27411
 
  pFreeze ALIAS FOR $4;
27412
 
BEGIN
27413
 
  RETURN createCountTag(pItemsiteid, pComments, pPriority, pFreeze, NULL);
27414
 
END;
27415
 
$_$;
27416
 
 
27417
 
 
27418
 
ALTER FUNCTION public.createcounttag(integer, text, boolean, boolean) OWNER TO admin;
27419
 
 
27420
 
--
27421
 
--
27422
 
 
27423
 
CREATE FUNCTION createcounttag(integer, text, boolean, boolean, integer) RETURNS integer
27424
 
    LANGUAGE plpgsql
27425
 
    AS $_$
27426
 
 
27427
 
DECLARE
27428
 
  pItemsiteid ALIAS FOR $1;
27429
 
  pComments ALIAS FOR $2;
27430
 
  pPriority ALIAS FOR $3;
27431
 
  pFreeze ALIAS FOR $4;
27432
 
  pLocationid ALIAS FOR $5;
27433
 
  _invcntid INTEGER;
27434
 
  _whs          RECORD;
27435
 
  _type CHARACTER;
27436
 
  _controlmethod        CHARACTER;
27437
 
 
27438
 
BEGIN
27439
 
 
27440
 
  SELECT item_type, itemsite_controlmethod INTO _type, _controlmethod
27441
 
    FROM itemsite, item
27442
 
   WHERE ((itemsite_item_id=item_id)
27443
 
     AND  (itemsite_id=pItemsiteid));
27444
 
 
27445
 
  IF (NOT FOUND OR _type IN ('F', 'R', 'L','J') OR _controlmethod = 'N') THEN
27446
 
    RETURN 0; -- We simply do not do these item types.
27447
 
  END IF;
27448
 
 
27449
 
  -- Test for existing tags
27450
 
   IF (pLocationid IS NULL) THEN
27451
 
       SELECT invcnt_id INTO _invcntid
27452
 
       FROM invcnt
27453
 
       WHERE ((NOT invcnt_posted)
27454
 
       AND (invcnt_location_id IS NULL)
27455
 
       AND (invcnt_itemsite_id=pItemsiteid));
27456
 
  
27457
 
  ELSE
27458
 
 
27459
 
    SELECT invcnt_id INTO _invcntid
27460
 
     FROM invcnt
27461
 
     WHERE ((NOT invcnt_posted)
27462
 
     AND (invcnt_itemsite_id=pItemsiteid)
27463
 
     AND (invcnt_location_id=pLocationid));
27464
 
  END IF;
27465
 
 
27466
 
  IF (NOT FOUND) THEN
27467
 
    SELECT NEXTVAL('invcnt_invcnt_id_seq') INTO _invcntid;
27468
 
 
27469
 
    SELECT whsinfo.* INTO _whs
27470
 
      FROM whsinfo, itemsite
27471
 
     WHERE ((warehous_id=itemsite_warehous_id)
27472
 
       AND  (itemsite_id=pItemsiteid));
27473
 
 
27474
 
    INSERT INTO invcnt (
27475
 
      invcnt_id, invcnt_itemsite_id, invcnt_tagdate,
27476
 
      invcnt_tagnumber,
27477
 
      invcnt_tag_username, invcnt_posted,
27478
 
      invcnt_priority, invcnt_comments, invcnt_location_id
27479
 
    ) VALUES (
27480
 
      _invcntid, pItemsiteid, CURRENT_TIMESTAMP,
27481
 
      (_whs.warehous_counttag_prefix || _whs.warehous_counttag_number::TEXT),
27482
 
      getEffectiveXtUser(), FALSE,
27483
 
      pPriority, pComments, pLocationid
27484
 
    );
27485
 
 
27486
 
    UPDATE whsinfo
27487
 
    SET warehous_counttag_number=(warehous_counttag_number + 1)
27488
 
    WHERE (warehous_id=_whs.warehous_id);
27489
 
 
27490
 
    IF (pFreeze) THEN
27491
 
      UPDATE itemsite
27492
 
      SET itemsite_freeze=TRUE
27493
 
      WHERE (itemsite_id=pItemsiteid);
27494
 
    END IF;
27495
 
 
27496
 
  END IF;
27497
 
 
27498
 
  RETURN _invcntid;
27499
 
END;
27500
 
$_$;
27501
 
 
27502
 
 
27503
 
ALTER FUNCTION public.createcounttag(integer, text, boolean, boolean, integer) OWNER TO admin;
27504
 
 
27505
 
--
27506
 
--
27507
 
 
27508
 
CREATE FUNCTION createcustomer(integer) RETURNS integer
27509
 
    LANGUAGE plpgsql
27510
 
    AS $_$
27511
 
  DECLARE
27512
 
    pcrmacctId  ALIAS FOR $1;
27513
 
    _custId     INTEGER := 0;
27514
 
  BEGIN
27515
 
    IF (pcrmacctId < 0 OR pcrmacctId IS NULL) THEN
27516
 
      RETURN -1;
27517
 
    END IF;
27518
 
 
27519
 
    SELECT crmacct_cust_id INTO _custId
27520
 
    FROM crmacct WHERE crmacct_id = pcrmacctId;
27521
 
 
27522
 
    IF (_custId IS NOT NULL AND _custId <= 0) THEN
27523
 
      RETURN -2;
27524
 
    END IF;
27525
 
 
27526
 
    INSERT INTO _customer (active, customer_number, customer_name)
27527
 
      SELECT crmacct_active, crmacct_number, crmacct_name
27528
 
      FROM crmacct
27529
 
      WHERE crmacct_id = pcrmacctId;
27530
 
    _custId := CURRVAL('cust_cust_id_seq');
27531
 
 
27532
 
    UPDATE crmacct SET crmacct_prospect_id = NULL, crmacct_cust_id = _custId
27533
 
    WHERE crmacct_id = pcrmacctId;
27534
 
 
27535
 
    RETURN _custId;
27536
 
  END;
27537
 
$_$;
27538
 
 
27539
 
 
27540
 
ALTER FUNCTION public.createcustomer(integer) OWNER TO admin;
27541
 
 
27542
 
--
27543
 
--
27544
 
 
27545
 
CREATE FUNCTION createcyclecountsbywarehouse(integer, integer, text, boolean, boolean) RETURNS integer
27546
 
    LANGUAGE plpgsql
27547
 
    AS $_$
27548
 
DECLARE
27549
 
  pWarehousid ALIAS FOR $1;
27550
 
  pMaxNumber ALIAS FOR $2;
27551
 
  pComments ALIAS FOR $3;
27552
 
  pPriority ALIAS FOR $4;
27553
 
  pFreeze ALIAS FOR $5;
27554
 
 
27555
 
BEGIN
27556
 
  RETURN createCycleCountsByWarehouse(pWarehousid, pMaxNumber, pComments, pPriority, pFreeze, NULL, FALSE);
27557
 
END;
27558
 
$_$;
27559
 
 
27560
 
 
27561
 
ALTER FUNCTION public.createcyclecountsbywarehouse(integer, integer, text, boolean, boolean) OWNER TO admin;
27562
 
 
27563
 
--
27564
 
--
27565
 
 
27566
 
CREATE FUNCTION createcyclecountsbywarehouse(integer, integer, integer, text, boolean, boolean) RETURNS integer
27567
 
    LANGUAGE plpgsql
27568
 
    AS $_$
27569
 
DECLARE
27570
 
  pWarehousid ALIAS FOR $1;
27571
 
  pClasscodeid ALIAS FOR $2;
27572
 
  pMaxNumber ALIAS FOR $3;
27573
 
  pComments ALIAS FOR $4;
27574
 
  pPriority ALIAS FOR $5;
27575
 
  pFreeze ALIAS FOR $6;
27576
 
BEGIN
27577
 
  RETURN createCycleCountsByWarehouseByClassCode(pWarehousid, pClasscodeid, pMaxNumber, pComments, pPriority, pFreeze, NULL, FALSE);
27578
 
END;
27579
 
$_$;
27580
 
 
27581
 
 
27582
 
ALTER FUNCTION public.createcyclecountsbywarehouse(integer, integer, integer, text, boolean, boolean) OWNER TO admin;
27583
 
 
27584
 
--
27585
 
--
27586
 
 
27587
 
CREATE FUNCTION createcyclecountsbywarehouse(integer, text, integer, text, boolean, boolean) RETURNS integer
27588
 
    LANGUAGE plpgsql
27589
 
    AS $_$
27590
 
DECLARE
27591
 
  pWarehousid ALIAS FOR $1;
27592
 
  pClasscodePattern ALIAS FOR $2;
27593
 
  pMaxNumber ALIAS FOR $3;
27594
 
  pComments ALIAS FOR $4;
27595
 
  pPriority ALIAS FOR $5;
27596
 
  pFreeze ALIAS FOR $6;
27597
 
BEGIN
27598
 
  RETURN createCycleCountsByWarehouseByClassCode(pWarehousid, pClasscodePattern, pMaxNumber, pComments, pPriority, pFreeze, NULL, FALSE);
27599
 
END;
27600
 
$_$;
27601
 
 
27602
 
 
27603
 
ALTER FUNCTION public.createcyclecountsbywarehouse(integer, text, integer, text, boolean, boolean) OWNER TO admin;
27604
 
 
27605
 
--
27606
 
--
27607
 
 
27608
 
CREATE FUNCTION createcyclecountsbywarehouse(integer, integer, text, boolean, boolean, integer, boolean) RETURNS integer
27609
 
    LANGUAGE plpgsql
27610
 
    AS $_$
27611
 
DECLARE
27612
 
  pWarehousid ALIAS FOR $1;
27613
 
  pMaxNumber ALIAS FOR $2;
27614
 
  pComments ALIAS FOR $3;
27615
 
  pPriority ALIAS FOR $4;
27616
 
  pFreeze ALIAS FOR $5;
27617
 
  pLocationid ALIAS FOR $6;
27618
 
  pIgnoreZeroBalance ALIAS FOR $7;
27619
 
  _itemsites RECORD;
27620
 
  _returnVal    INTEGER;
27621
 
  
27622
 
BEGIN
27623
 
 
27624
 
IF (pLocationid IS NULL) THEN
27625
 
  FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand
27626
 
                    FROM itemsite, item
27627
 
                    WHERE ( (itemsite_active)
27628
 
                     AND (itemsite_item_id=item_id)
27629
 
                     AND (itemsite_cyclecountfreq > 0)
27630
 
                     AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE)
27631
 
                     AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id
27632
 
                                               FROM invcnt, itemsite
27633
 
                                               WHERE ( (invcnt_itemsite_id=itemsite_id)
27634
 
                                                AND (itemsite_warehous_id=pWarehousid)
27635
 
                                                AND (invcnt_location_id IS NULL)
27636
 
                                                AND (NOT invcnt_posted) ) ) )
27637
 
                     AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0))
27638
 
                     AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id)))
27639
 
                     AND (itemsite_warehous_id=pWarehousid) )
27640
 
                    ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number
27641
 
 
27642
 
LIMIT pMaxNumber LOOP
27643
 
    _returnVal := createCountTag(_itemsites.itemsite_id, pComments,
27644
 
                                    pPriority, pFreeze, pLocationid);
27645
 
    IF (_returnVal < 0) THEN
27646
 
      RETURN _returnVal;
27647
 
    END IF;
27648
 
  END LOOP;            
27649
 
 
27650
 
ELSE
27651
 
  FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty)
27652
 
                    FROM itemsite, itemloc
27653
 
                    WHERE ( (itemsite_active)
27654
 
                     AND (itemsite_cyclecountfreq > 0)
27655
 
                     AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE)
27656
 
                     AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0))
27657
 
                     AND (pLocationid = itemloc_location_id)
27658
 
                     AND (itemloc_itemsite_id = itemsite_id)
27659
 
                     AND (itemsite_warehous_id=pWarehousid) )
27660
 
                    GROUP BY itemsite_id, itemsite_warehous_id,
27661
 
                             itemsite_datelastcount, itemsite_cyclecountfreq,
27662
 
                             itemsite_abcclass
27663
 
                    ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass
27664
 
 
27665
 
LIMIT pMaxNumber LOOP
27666
 
    _returnVal := createCountTag(_itemsites.itemsite_id, pComments,
27667
 
                                    pPriority, pFreeze, pLocationid);
27668
 
    IF (_returnVal < 0) THEN
27669
 
      RETURN _returnVal;
27670
 
    END IF;
27671
 
  END LOOP;  
27672
 
                   
27673
 
END IF;
27674
 
 
27675
 
  RETURN 0;
27676
 
END;
27677
 
$_$;
27678
 
 
27679
 
 
27680
 
ALTER FUNCTION public.createcyclecountsbywarehouse(integer, integer, text, boolean, boolean, integer, boolean) OWNER TO admin;
27681
 
 
27682
 
--
27683
 
--
27684
 
 
27685
 
CREATE FUNCTION createcyclecountsbywarehousebyclasscode(integer, integer, integer, text, boolean, boolean, integer, boolean) RETURNS integer
27686
 
    LANGUAGE plpgsql
27687
 
    AS $_$
27688
 
DECLARE
27689
 
  pWarehousid ALIAS FOR $1;
27690
 
  pClasscodeid ALIAS FOR $2;
27691
 
  pMaxNumber ALIAS FOR $3;
27692
 
  pComments ALIAS FOR $4;
27693
 
  pPriority ALIAS FOR $5;
27694
 
  pFreeze ALIAS FOR $6;
27695
 
  pLocationid ALIAS FOR $7;
27696
 
  pIgnoreZeroBalance ALIAS FOR $8;
27697
 
  _itemsites RECORD;
27698
 
  _returnVal    INTEGER;
27699
 
  
27700
 
BEGIN
27701
 
 
27702
 
IF (pLocationid IS NULL) THEN
27703
 
  FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand
27704
 
                    FROM itemsite, item
27705
 
                    WHERE ( (itemsite_active)
27706
 
                     AND (itemsite_item_id=item_id)
27707
 
                     AND (itemsite_cyclecountfreq > 0)
27708
 
                     AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE)
27709
 
                     AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id
27710
 
                                               FROM invcnt, itemsite
27711
 
                                               WHERE ( (invcnt_itemsite_id=itemsite_id)
27712
 
                                                AND (itemsite_warehous_id=pWarehousid)
27713
 
                                                AND (invcnt_location_id IS NULL)
27714
 
                                                AND (NOT invcnt_posted) ) ) )
27715
 
                     AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0))
27716
 
                     AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id)))
27717
 
                     AND (itemsite_warehous_id=pWarehousid)
27718
 
                     AND (item_classcode_id=pClasscodeid) )
27719
 
                    ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number
27720
 
                    LIMIT pMaxNumber LOOP
27721
 
    _returnVal := createCountTag(_itemsites.itemsite_id, pComments,
27722
 
                                    pPriority, pFreeze, pLocationid);
27723
 
    IF (_returnVal < 0) THEN
27724
 
      RETURN _returnVal;
27725
 
    END IF;
27726
 
  END LOOP;
27727
 
 
27728
 
ELSE
27729
 
  FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty)
27730
 
                    FROM itemsite, item, itemloc
27731
 
                    WHERE ( (itemsite_active)
27732
 
                     AND (itemsite_item_id=item_id)
27733
 
                     AND (itemsite_cyclecountfreq > 0)
27734
 
                     AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE)
27735
 
                     AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0))
27736
 
                     AND (pLocationid = itemloc_location_id)
27737
 
                     AND (itemloc_itemsite_id = itemsite_id)
27738
 
                     AND (itemsite_warehous_id=pWarehousid) 
27739
 
                     AND (item_classcode_id=pClasscodeid) )
27740
 
                    GROUP BY itemsite_id, itemsite_warehous_id,
27741
 
                             itemsite_datelastcount, itemsite_cyclecountfreq,
27742
 
                             itemsite_abcclass
27743
 
                    ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass
27744
 
                    LIMIT pMaxNumber LOOP
27745
 
    _returnVal := createCountTag(_itemsites.itemsite_id, pComments,
27746
 
                                    pPriority, pFreeze, pLocationid);
27747
 
    IF (_returnVal < 0) THEN
27748
 
      RETURN _returnVal;
27749
 
    END IF;
27750
 
  END LOOP;
27751
 
 
27752
 
END IF;
27753
 
 
27754
 
  RETURN 0;
27755
 
END;
27756
 
$_$;
27757
 
 
27758
 
 
27759
 
ALTER FUNCTION public.createcyclecountsbywarehousebyclasscode(integer, integer, integer, text, boolean, boolean, integer, boolean) OWNER TO admin;
27760
 
 
27761
 
--
27762
 
--
27763
 
 
27764
 
CREATE FUNCTION createcyclecountsbywarehousebyclasscode(integer, text, integer, text, boolean, boolean, integer, boolean) RETURNS integer
27765
 
    LANGUAGE plpgsql
27766
 
    AS $_$
27767
 
DECLARE
27768
 
  pWarehousid ALIAS FOR $1;
27769
 
  pClasscodePattern ALIAS FOR $2;
27770
 
  pMaxNumber ALIAS FOR $3;
27771
 
  pComments ALIAS FOR $4;
27772
 
  pPriority ALIAS FOR $5;
27773
 
  pFreeze ALIAS FOR $6;
27774
 
  pLocationid ALIAS FOR $7;
27775
 
  pIgnoreZeroBalance ALIAS FOR $8;
27776
 
  _itemsites RECORD;
27777
 
  _returnVal    INTEGER;
27778
 
  
27779
 
BEGIN
27780
 
 
27781
 
IF (pLocationid IS NULL) THEN
27782
 
  FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand
27783
 
                    FROM itemsite, item, classcode
27784
 
                    WHERE ( (itemsite_active)
27785
 
                     AND (itemsite_item_id=item_id)
27786
 
                     AND (item_classcode_id=classcode_id)
27787
 
                     AND (itemsite_cyclecountfreq > 0)
27788
 
                     AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE)
27789
 
                     AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id
27790
 
                                               FROM invcnt, itemsite
27791
 
                                               WHERE ( (invcnt_itemsite_id=itemsite_id)
27792
 
                                                AND (itemsite_warehous_id=pWarehousid)
27793
 
                                                AND (invcnt_location_id IS NULL)
27794
 
                                                AND (NOT invcnt_posted) ) ) )
27795
 
                     AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0))
27796
 
                     AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id)))
27797
 
                     AND (itemsite_warehous_id=pWarehousid)
27798
 
                     AND (classcode_code ~ pClasscodePattern) )
27799
 
                    ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number
27800
 
                    LIMIT pMaxNumber LOOP
27801
 
    _returnVal := createCountTag(_itemsites.itemsite_id, pComments,
27802
 
                                    pPriority, pFreeze, pLocationid);
27803
 
    IF (_returnVal < 0) THEN
27804
 
      RETURN _returnVal;
27805
 
    END IF;
27806
 
  END LOOP;
27807
 
 
27808
 
ELSE
27809
 
  FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty)
27810
 
                    FROM itemsite, item, classcode, itemloc
27811
 
                    WHERE ( (itemsite_active)
27812
 
                     AND (itemsite_item_id=item_id)
27813
 
                     AND (item_classcode_id=classcode_id)
27814
 
                     AND (itemsite_cyclecountfreq > 0)
27815
 
                     AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE)
27816
 
                     AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0))
27817
 
                     AND (pLocationid = itemloc_location_id)
27818
 
                     AND (itemloc_itemsite_id = itemsite_id)
27819
 
                     AND (itemsite_warehous_id=pWarehousid)
27820
 
                     AND (classcode_code ~ pClasscodePattern) )
27821
 
                    GROUP BY itemsite_id, itemsite_warehous_id,
27822
 
                             itemsite_datelastcount, itemsite_cyclecountfreq,
27823
 
                             itemsite_abcclass
27824
 
                    ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass
27825
 
                    LIMIT pMaxNumber LOOP
27826
 
    _returnVal := createCountTag(_itemsites.itemsite_id, pComments,
27827
 
                                    pPriority, pFreeze, pLocationid);
27828
 
    IF (_returnVal < 0) THEN
27829
 
      RETURN _returnVal;
27830
 
    END IF;
27831
 
  END LOOP;
27832
 
 
27833
 
END IF;
27834
 
 
27835
 
  RETURN 0;
27836
 
END;
27837
 
$_$;
27838
 
 
27839
 
 
27840
 
ALTER FUNCTION public.createcyclecountsbywarehousebyclasscode(integer, text, integer, text, boolean, boolean, integer, boolean) OWNER TO admin;
27841
 
 
27842
 
--
27843
 
--
27844
 
 
27845
 
CREATE FUNCTION createcyclecountsbywarehousebyplannercode(integer, text, integer, text, boolean, boolean, integer, boolean) RETURNS integer
27846
 
    LANGUAGE plpgsql
27847
 
    AS $_$
27848
 
DECLARE
27849
 
  pWarehousid ALIAS FOR $1;
27850
 
  pPlancodePattern ALIAS FOR $2;
27851
 
  pMaxNumber ALIAS FOR $3;
27852
 
  pComments ALIAS FOR $4;
27853
 
  pPriority ALIAS FOR $5;
27854
 
  pFreeze ALIAS FOR $6;
27855
 
  pLocationid ALIAS FOR $7;
27856
 
  pIgnoreZeroBalance ALIAS FOR $8;
27857
 
  _itemsites RECORD;
27858
 
  _returnVal    INTEGER;
27859
 
  
27860
 
BEGIN
27861
 
 
27862
 
IF (pLocationid IS NULL) THEN
27863
 
  FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand
27864
 
                    FROM itemsite, item, plancode
27865
 
                    WHERE ( (itemsite_active)
27866
 
                     AND (itemsite_item_id=item_id)
27867
 
                     AND (itemsite_plancode_id=plancode_id)
27868
 
                     AND (itemsite_cyclecountfreq > 0)
27869
 
                     AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE)
27870
 
                     AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id
27871
 
                                               FROM invcnt, itemsite
27872
 
                                               WHERE ( (invcnt_itemsite_id=itemsite_id)
27873
 
                                                AND (itemsite_warehous_id=pWarehousid)
27874
 
                                                AND (invcnt_location_id IS NULL)
27875
 
                                                AND (NOT invcnt_posted) ) ) )
27876
 
                     AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0))
27877
 
                     AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id)))
27878
 
                     AND (itemsite_warehous_id=pWarehousid)
27879
 
                     AND (plancode_code ~ pPlancodePattern) )
27880
 
                    ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number
27881
 
                    LIMIT pMaxNumber LOOP
27882
 
    _returnVal := createCountTag(_itemsites.itemsite_id, pComments,
27883
 
                                    pPriority, pFreeze, pLocationid);
27884
 
    IF (_returnVal < 0) THEN
27885
 
      RETURN _returnVal;
27886
 
    END IF;
27887
 
  END LOOP;
27888
 
 
27889
 
ELSE
27890
 
  FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty)
27891
 
                    FROM itemsite, plancode, itemloc
27892
 
                    WHERE ( (itemsite_active)
27893
 
                     AND (itemsite_plancode_id=plancode_id)
27894
 
                     AND (itemsite_cyclecountfreq > 0)
27895
 
                     AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE)
27896
 
                     AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0))
27897
 
                     AND (pLocationid = itemloc_location_id)
27898
 
                     AND (itemloc_itemsite_id = itemsite_id)
27899
 
                     AND (itemsite_warehous_id=pWarehousid)
27900
 
                     AND (plancode_code ~ pPlancodePattern) )
27901
 
                    GROUP BY itemsite_id, itemsite_warehous_id,
27902
 
                             itemsite_datelastcount, itemsite_cyclecountfreq,
27903
 
                             itemsite_abcclass
27904
 
                    ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass
27905
 
                    LIMIT pMaxNumber LOOP
27906
 
    _returnVal := createCountTag(_itemsites.itemsite_id, pComments,
27907
 
                                    pPriority, pFreeze, pLocationid);
27908
 
    IF (_returnVal < 0) THEN
27909
 
      RETURN _returnVal;
27910
 
    END IF;
27911
 
  END LOOP;
27912
 
 
27913
 
END IF;
27914
 
 
27915
 
  RETURN 0;
27916
 
END;
27917
 
$_$;
27918
 
 
27919
 
 
27920
 
ALTER FUNCTION public.createcyclecountsbywarehousebyplannercode(integer, text, integer, text, boolean, boolean, integer, boolean) OWNER TO admin;
27921
 
 
27922
 
--
27923
 
--
27924
 
 
27925
 
CREATE FUNCTION createcyclecountsbywarehousebyplannercode(integer, integer, integer, text, boolean, boolean, integer, boolean) RETURNS integer
27926
 
    LANGUAGE plpgsql
27927
 
    AS $_$
27928
 
DECLARE
27929
 
  pWarehousid ALIAS FOR $1;
27930
 
  pPlancodeid ALIAS FOR $2;
27931
 
  pMaxNumber ALIAS FOR $3;
27932
 
  pComments ALIAS FOR $4;
27933
 
  pPriority ALIAS FOR $5;
27934
 
  pFreeze ALIAS FOR $6;
27935
 
  pLocationid ALIAS FOR $7;
27936
 
  pIgnoreZeroBalance ALIAS FOR $8;
27937
 
  _itemsites RECORD;
27938
 
  _returnVal    INTEGER;
27939
 
  
27940
 
BEGIN
27941
 
 
27942
 
IF (pLocationid IS NULL) THEN
27943
 
  FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand
27944
 
                    FROM itemsite, item
27945
 
                    WHERE ( (itemsite_active)
27946
 
                     AND (itemsite_item_id=item_id)
27947
 
                     AND (itemsite_cyclecountfreq > 0)
27948
 
                     AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE)
27949
 
                     AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id
27950
 
                                               FROM invcnt, itemsite
27951
 
                                               WHERE ( (invcnt_itemsite_id=itemsite_id)
27952
 
                                                AND (itemsite_warehous_id=pWarehousid)
27953
 
                                                AND (invcnt_location_id IS NULL)
27954
 
                                                AND (NOT invcnt_posted) ) ) )
27955
 
                     AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0))
27956
 
                     AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id)))
27957
 
                     AND (itemsite_warehous_id=pWarehousid)
27958
 
                     AND (itemsite_plancode_id=pPlancodeid) )
27959
 
                    ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number
27960
 
                    LIMIT pMaxNumber LOOP
27961
 
    _returnVal := createCountTag(_itemsites.itemsite_id, pComments,
27962
 
                                    pPriority, pFreeze, pLocationid);
27963
 
    IF (_returnVal < 0) THEN
27964
 
      RETURN _returnVal;
27965
 
    END IF;
27966
 
  END LOOP;
27967
 
 
27968
 
ELSE
27969
 
  FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty)
27970
 
                    FROM itemsite, itemloc
27971
 
                    WHERE ( (itemsite_active)
27972
 
                     AND (itemsite_cyclecountfreq > 0)
27973
 
                     AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE)
27974
 
                     AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0))
27975
 
                     AND (itemloc_itemsite_id = itemsite_id)
27976
 
                     AND (itemsite_warehous_id=pWarehousid)
27977
 
                     AND (pLocationid = itemloc_location_id)
27978
 
                     AND (itemsite_plancode_id=pPlancodeid) )
27979
 
                    GROUP BY itemsite_id, itemsite_warehous_id,
27980
 
                             itemsite_datelastcount, itemsite_cyclecountfreq,
27981
 
                             itemsite_abcclass
27982
 
                    ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass
27983
 
                    LIMIT pMaxNumber LOOP
27984
 
    _returnVal := createCountTag(_itemsites.itemsite_id, pComments,
27985
 
                                    pPriority, pFreeze, pLocationid);
27986
 
    IF (_returnVal < 0) THEN
27987
 
      RETURN _returnVal;
27988
 
    END IF;
27989
 
  END LOOP;
27990
 
 
27991
 
END IF;
27992
 
 
27993
 
  RETURN 0;
27994
 
END;
27995
 
$_$;
27996
 
 
27997
 
 
27998
 
ALTER FUNCTION public.createcyclecountsbywarehousebyplannercode(integer, integer, integer, text, boolean, boolean, integer, boolean) OWNER TO admin;
27999
 
 
28000
 
--
28001
 
--
28002
 
 
28003
 
CREATE FUNCTION createfile(text, text, bytea) RETURNS integer
28004
 
    LANGUAGE plpgsql
28005
 
    AS $_$
28006
 
declare
28007
 
  pTitle ALIAS FOR $1;
28008
 
  pDescription ALIAS FOR $2;
28009
 
  pStream ALIAS FOR $3;
28010
 
  _id integer;
28011
 
begin
28012
 
  _id := nextval('file_file_id_seq');
28013
 
  insert into file (file_id, file_title, file_descrip, file_stream) values (_id, pTitle, pDescription, pStream);
28014
 
  return _id;
28015
 
end;
28016
 
$_$;
28017
 
 
28018
 
 
28019
 
ALTER FUNCTION public.createfile(text, text, bytea) OWNER TO admin;
28020
 
 
28021
 
--
28022
 
--
28023
 
 
28024
 
CREATE FUNCTION createinvoice(integer) RETURNS integer
28025
 
    LANGUAGE plpgsql
28026
 
    AS $_$
28027
 
DECLARE
28028
 
  pCobmiscid ALIAS FOR $1;
28029
 
  _invcheadid INTEGER;
28030
 
  _invcitemid INTEGER;
28031
 
  _qtyToInvoice NUMERIC;
28032
 
  _r            RECORD;
28033
 
  _s            RECORD;
28034
 
  _lastlinenumber INTEGER := 1;
28035
 
  
28036
 
BEGIN
28037
 
 
28038
 
  IF ( ( SELECT cobmisc_posted
28039
 
         FROM cobmisc
28040
 
         WHERE (cobmisc_id=pCobmiscid) ) ) THEN
28041
 
    RETURN -1;
28042
 
  END IF;
28043
 
 
28044
 
  SELECT NEXTVAL('invchead_invchead_id_seq') INTO _invcheadid;
28045
 
 
28046
 
  UPDATE cobmisc
28047
 
  SET cobmisc_invcnumber=fetchInvcNumber()
28048
 
  WHERE ( (cobmisc_invcnumber IS NULL)
28049
 
   AND (cobmisc_id=pCobmiscid) );
28050
 
 
28051
 
  INSERT INTO invchead
28052
 
  ( 
28053
 
        invchead_id,invchead_cust_id,invchead_shipto_id,invchead_ordernumber,invchead_orderdate,
28054
 
        invchead_posted,invchead_printed,invchead_invcnumber,invchead_invcdate,invchead_shipdate,
28055
 
        invchead_ponumber,invchead_shipvia,invchead_fob,invchead_billto_name,invchead_billto_address1,
28056
 
        invchead_billto_address2,invchead_billto_address3,invchead_billto_city,invchead_billto_state,invchead_billto_zipcode,
28057
 
        invchead_billto_phone,invchead_billto_country,invchead_shipto_name,invchead_shipto_address1,invchead_shipto_address2,
28058
 
        invchead_shipto_address3,invchead_shipto_city,invchead_shipto_state,invchead_shipto_zipcode,invchead_shipto_phone,
28059
 
        invchead_shipto_country,invchead_salesrep_id,invchead_commission,invchead_terms_id,invchead_freight,
28060
 
        invchead_misc_amount,invchead_misc_descrip,invchead_misc_accnt_id,invchead_payment,
28061
 
        invchead_paymentref,invchead_notes,invchead_prj_id,invchead_curr_id,
28062
 
        invchead_taxzone_id, invchead_shipchrg_id,
28063
 
        invchead_saletype_id, invchead_shipzone_id
28064
 
   )
28065
 
  SELECT 
28066
 
        _invcheadid,cohead_cust_id,cohead_shipto_id,cohead_number,cohead_orderdate,
28067
 
        FALSE,FALSE,cobmisc_invcnumber,cobmisc_invcdate,cobmisc_shipdate,
28068
 
        cohead_custponumber,cobmisc_shipvia,cohead_fob,cohead_billtoname,cohead_billtoaddress1,
28069
 
        cohead_billtoaddress2,cohead_billtoaddress3,cohead_billtocity,cohead_billtostate,cohead_billtozipcode,
28070
 
        cntct_phone AS cust_phone,cohead_billtocountry,cohead_shiptoname,cohead_shiptoaddress1,cohead_shiptoaddress2,
28071
 
        cohead_shiptoaddress3,cohead_shiptocity,cohead_shiptostate,cohead_shiptozipcode,cohead_shipto_cntct_phone,
28072
 
        cohead_shiptocountry,cohead_salesrep_id,COALESCE(cohead_commission,0),cohead_terms_id,cobmisc_freight,
28073
 
        COALESCE(cobmisc_misc, 0.00),cobmisc_misc_descrip,cobmisc_misc_accnt_id,cobmisc_payment,
28074
 
        cobmisc_paymentref,cobmisc_notes,cohead_prj_id,cobmisc_curr_id,
28075
 
        cobmisc_taxzone_id, cohead_shipchrg_id,
28076
 
        cohead_saletype_id, cohead_shipzone_id
28077
 
    FROM cobmisc, cohead, custinfo
28078
 
    LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)
28079
 
  WHERE ( (cobmisc_cohead_id=cohead_id)
28080
 
   AND (cohead_cust_id=cust_id)
28081
 
   AND (cobmisc_id=pCobmiscid) );
28082
 
 
28083
 
        INSERT INTO invcheadtax(taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, 
28084
 
                        taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate)
28085
 
        SELECT _invcheadid,taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, 
28086
 
                        taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate
28087
 
        FROM cobmisctax 
28088
 
        WHERE taxhist_parent_id = pCobmiscid 
28089
 
        AND taxhist_taxtype_id = getadjustmenttaxtypeid();
28090
 
 
28091
 
    INSERT INTO charass
28092
 
          (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price)
28093
 
    SELECT 'INV', _invcheadid, charass_char_id, charass_value, charass_default, charass_price
28094
 
      FROM cobmisc JOIN cohead ON (cohead_id=cobmisc_cohead_id)
28095
 
                   JOIN charass ON ((charass_target_type='SO') AND (charass_target_id=cohead_id))
28096
 
                   JOIN char ON (char_id=charass_char_id AND char_invoices)
28097
 
    WHERE (cobmisc_id=pCobmiscid);
28098
 
 
28099
 
  FOR _r IN SELECT coitem_id, coitem_linenumber, coitem_subnumber, coitem_custpn,
28100
 
                   coitem_qtyord, cobill_qty,
28101
 
                   coitem_qty_uom_id, coitem_qty_invuomratio,
28102
 
                   coitem_custprice, coitem_price,
28103
 
                   coitem_price_uom_id, coitem_price_invuomratio,
28104
 
                   coitem_memo, coitem_rev_accnt_id,
28105
 
                   itemsite_item_id, itemsite_warehous_id,
28106
 
                   cobill_taxtype_id,
28107
 
                   formatSoItemNumber(coitem_id) AS ordnumber
28108
 
            FROM coitem, cobill, itemsite
28109
 
            WHERE ( (cobill_coitem_id=coitem_id)
28110
 
             AND (coitem_itemsite_id=itemsite_id)
28111
 
             AND (cobill_cobmisc_id=pCobmiscid) )
28112
 
            ORDER BY coitem_linenumber, coitem_subnumber LOOP
28113
 
 
28114
 
    SELECT NEXTVAL('invcitem_invcitem_id_seq') INTO _invcitemid;
28115
 
    INSERT INTO invcitem
28116
 
    ( invcitem_id, invcitem_invchead_id,
28117
 
      invcitem_linenumber, invcitem_item_id, invcitem_warehous_id,
28118
 
      invcitem_custpn, invcitem_number, invcitem_descrip,
28119
 
      invcitem_ordered, invcitem_billed,
28120
 
      invcitem_qty_uom_id, invcitem_qty_invuomratio,
28121
 
      invcitem_custprice, invcitem_price,
28122
 
      invcitem_price_uom_id, invcitem_price_invuomratio,
28123
 
      invcitem_notes, invcitem_taxtype_id,
28124
 
      invcitem_coitem_id, invcitem_rev_accnt_id )
28125
 
    VALUES
28126
 
    ( _invcitemid, _invcheadid,
28127
 
      _lastlinenumber,
28128
 
      _r.itemsite_item_id, _r.itemsite_warehous_id,
28129
 
      _r.coitem_custpn, '', '',
28130
 
      _r.coitem_qtyord, _r.cobill_qty,
28131
 
      _r.coitem_qty_uom_id, _r.coitem_qty_invuomratio,
28132
 
      _r.coitem_custprice, _r.coitem_price,
28133
 
      _r.coitem_price_uom_id, _r.coitem_price_invuomratio,
28134
 
      _r.coitem_memo, _r.cobill_taxtype_id,
28135
 
      _r.coitem_id, _r.coitem_rev_accnt_id );
28136
 
 
28137
 
    UPDATE invdetail SET invdetail_invcitem_id = _invcitemid
28138
 
     WHERE (invdetail_id IN (SELECT invdetail_id
28139
 
                               FROM invhist JOIN invdetail ON (invdetail_invhist_id=invhist_id)
28140
 
                              WHERE ( (invhist_ordnumber = _r.ordnumber)
28141
 
                                AND   (invhist_ordtype = 'SO')
28142
 
                                AND   (invhist_transtype = 'SH')
28143
 
                                AND   (invdetail_invcitem_id IS NULL) ) ));
28144
 
 
28145
 
    _qtyToInvoice :=  _r.cobill_qty;
28146
 
    FOR _s IN SELECT shipitem.*, shipitem_qty = _r.cobill_qty AS matched
28147
 
              FROM shipitem, shiphead
28148
 
              WHERE ((shipitem_shiphead_id=shiphead_id)
28149
 
                AND  (shipitem_orderitem_id=_r.coitem_id)
28150
 
                AND  (shiphead_shipped)
28151
 
                AND  (shiphead_order_type='SO')
28152
 
                AND  (NOT shipitem_invoiced))
28153
 
              ORDER BY matched DESC, shipitem_qty DESC FOR UPDATE LOOP
28154
 
      IF (_qtyToInvoice >= _s.shipitem_qty) THEN
28155
 
        UPDATE shipitem
28156
 
        SET shipitem_invoiced=TRUE, shipitem_invcitem_id=_invcitemid
28157
 
        WHERE (shipitem_id=_s.shipitem_id);
28158
 
        _qtyToInvoice := _qtyToInvoice - _s.shipitem_qty;
28159
 
      END IF;
28160
 
      IF (_qtyToInvoice <= 0) THEN
28161
 
        EXIT;
28162
 
      END IF;
28163
 
    END LOOP;
28164
 
 
28165
 
    UPDATE cobill SET cobill_invcnum=cobmisc_invcnumber,
28166
 
                      cobill_invcitem_id=invcitem_id
28167
 
    FROM invcitem, coitem, cobmisc
28168
 
    WHERE ((invcitem_linenumber=_lastlinenumber)
28169
 
      AND  (coitem_id=cobill_coitem_id)
28170
 
      AND  (cobmisc_id=cobill_cobmisc_id)
28171
 
      AND  (cobill_cobmisc_id=pCobmiscid)
28172
 
      AND  (invcitem_invchead_id=_invcheadid));
28173
 
    
28174
 
    _lastlinenumber := _lastlinenumber + 1;
28175
 
 
28176
 
  END LOOP;
28177
 
 
28178
 
  IF ( ( SELECT cobmisc_closeorder
28179
 
         FROM cobmisc
28180
 
         WHERE (cobmisc_id=pCobmiscid) ) ) THEN
28181
 
    UPDATE coitem
28182
 
    SET coitem_status='C'
28183
 
    FROM cobmisc
28184
 
    WHERE ( (coitem_status NOT IN ('C', 'X'))
28185
 
     AND (coitem_cohead_id=cobmisc_cohead_id)
28186
 
     AND (cobmisc_id=pCobmiscid) );
28187
 
  ELSE
28188
 
    UPDATE coitem
28189
 
    SET coitem_status='C'
28190
 
    FROM cobill
28191
 
    WHERE ( (cobill_coitem_id=coitem_id)
28192
 
     AND (coitem_status <> 'X')
28193
 
     AND (cobill_toclose)
28194
 
     AND (cobill_cobmisc_id=pCobmiscid) );
28195
 
  END IF;
28196
 
 
28197
 
  UPDATE cobmisc
28198
 
  SET cobmisc_posted=TRUE, cobmisc_invchead_id=_invcheadid
28199
 
  WHERE (cobmisc_id=pCobmiscid);
28200
 
 
28201
 
  RETURN _invcheadid;
28202
 
 
28203
 
END;
28204
 
$_$;
28205
 
 
28206
 
 
28207
 
ALTER FUNCTION public.createinvoice(integer) OWNER TO admin;
28208
 
 
28209
 
--
28210
 
--
28211
 
 
28212
 
CREATE FUNCTION createinvoiceconsolidated(integer) RETURNS integer
28213
 
    LANGUAGE plpgsql
28214
 
    AS $_$
28215
 
DECLARE
28216
 
  pCustid ALIAS FOR $1;
28217
 
  _invcheadid INTEGER;
28218
 
  _invcitemid INTEGER;
28219
 
  _qtyToInvoice NUMERIC;
28220
 
  _r            RECORD;
28221
 
  _s            RECORD;
28222
 
  _c            RECORD;
28223
 
  _i            RECORD;
28224
 
  _count      INTEGER;
28225
 
  _invcnumber INTEGER;
28226
 
  _lastlinenumber INTEGER;
28227
 
 
28228
 
BEGIN
28229
 
  _count := 0;
28230
 
 
28231
 
  FOR _c IN SELECT min(cobmisc_id) AS cobmisc_id, count(*) AS cnt,
28232
 
                   cohead_billtoname, cohead_billtoaddress1,
28233
 
                   cohead_billtoaddress2, cohead_billtoaddress3,
28234
 
                   cohead_billtocity, cohead_billtostate,
28235
 
                   cohead_billtozipcode, cntct_phone AS cust_phone,
28236
 
                   cohead_billtocountry,
28237
 
                   cohead_salesrep_id, cohead_commission,
28238
 
                   cohead_terms_id,
28239
 
                   cobmisc_misc_accnt_id,
28240
 
                   cohead_prj_id, cobmisc_curr_id,
28241
 
                   cobmisc_taxzone_id,
28242
 
                   cohead_shipchrg_id,
28243
 
                   cohead_saletype_id,
28244
 
                   cohead_shipzone_id,
28245
 
                   
28246
 
                -- the following are consolidated values to use in creating the header
28247
 
                   MIN(cohead_number) AS cohead_number,
28248
 
                   MIN(cohead_orderdate) AS cohead_orderdate,
28249
 
                   MIN(cobmisc_invcdate) AS cobmisc_invcdate,
28250
 
                   MIN(cobmisc_shipdate) AS cobmisc_shipdate,
28251
 
                   SUM(cobmisc_freight) AS cobmisc_freight,
28252
 
                   SUM(cobmisc_misc) AS cobmisc_misc,
28253
 
                   SUM(cobmisc_payment) AS cobmisc_payment
28254
 
                   
28255
 
              FROM cobmisc
28256
 
              JOIN cohead   ON (cobmisc_cohead_id=cohead_id)
28257
 
              JOIN custinfo ON (cohead_cust_id=cust_id)
28258
 
              LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)
28259
 
             WHERE(NOT cobmisc_posted
28260
 
               AND (cohead_cust_id=pCustid)
28261
 
               )
28262
 
          GROUP BY cohead_billtoname, cohead_billtoaddress1,
28263
 
                   cohead_billtoaddress2, cohead_billtoaddress3,
28264
 
                   cohead_billtocity, cohead_billtostate,
28265
 
                   cohead_billtozipcode, cust_phone,
28266
 
                   cohead_billtocountry,
28267
 
                   cohead_salesrep_id, cohead_commission,
28268
 
                   cohead_terms_id,
28269
 
                   cobmisc_misc_accnt_id,
28270
 
                   cohead_prj_id, cobmisc_curr_id,
28271
 
                   cobmisc_taxzone_id,
28272
 
                   cohead_shipchrg_id,
28273
 
                   cohead_saletype_id,
28274
 
                   cohead_shipzone_id
28275
 
                LOOP
28276
 
 
28277
 
    IF(_c.cnt = 1) THEN
28278
 
      PERFORM createInvoice(_c.cobmisc_id);
28279
 
      _count := (_count + 1);
28280
 
    ELSE
28281
 
      SELECT NEXTVAL('invchead_invchead_id_seq'), fetchInvcNumber() INTO _invcheadid, _invcnumber;
28282
 
  
28283
 
  --  Create the Invoice header
28284
 
      INSERT INTO invchead
28285
 
      ( invchead_id, invchead_cust_id, invchead_shipto_id,
28286
 
        invchead_ordernumber, invchead_orderdate,
28287
 
        invchead_posted, invchead_printed,
28288
 
        invchead_invcnumber, invchead_invcdate, invchead_shipdate,
28289
 
        invchead_ponumber, invchead_shipvia, invchead_fob,
28290
 
        invchead_billto_name, invchead_billto_address1,
28291
 
        invchead_billto_address2, invchead_billto_address3,
28292
 
        invchead_billto_city, invchead_billto_state,
28293
 
        invchead_billto_zipcode, invchead_billto_phone,
28294
 
        invchead_billto_country,
28295
 
        invchead_shipto_name, invchead_shipto_address1,
28296
 
        invchead_shipto_address2, invchead_shipto_address3,
28297
 
        invchead_shipto_city, invchead_shipto_state,
28298
 
        invchead_shipto_zipcode, invchead_shipto_phone,
28299
 
        invchead_shipto_country,
28300
 
        invchead_salesrep_id, invchead_commission,
28301
 
        invchead_terms_id,
28302
 
        invchead_freight,
28303
 
        invchead_misc_amount, invchead_misc_descrip, invchead_misc_accnt_id,
28304
 
        invchead_payment, invchead_paymentref,
28305
 
        invchead_notes, invchead_prj_id, invchead_curr_id,
28306
 
        invchead_taxzone_id,
28307
 
        invchead_shipchrg_id,
28308
 
        invchead_saletype_id, invchead_shipzone_id )
28309
 
      VALUES(_invcheadid,
28310
 
             pCustid, -1,
28311
 
             NULL, _c.cohead_orderdate,
28312
 
             FALSE, FALSE,
28313
 
             _invcnumber, _c.cobmisc_invcdate, _c.cobmisc_shipdate,
28314
 
             'MULTIPLE', '', '',
28315
 
             _c.cohead_billtoname, _c.cohead_billtoaddress1,
28316
 
             _c.cohead_billtoaddress2, _c.cohead_billtoaddress3,
28317
 
             _c.cohead_billtocity, _c.cohead_billtostate,
28318
 
             _c.cohead_billtozipcode, _c.cust_phone,
28319
 
             _c.cohead_billtocountry,
28320
 
             '', '', '', '', '', '', '', '', '',
28321
 
             _c.cohead_salesrep_id, COALESCE(_c.cohead_commission, 0),
28322
 
             _c.cohead_terms_id,
28323
 
             _c.cobmisc_freight,
28324
 
             _c.cobmisc_misc, CASE WHEN(_c.cobmisc_misc <> 0) THEN 'Multiple' ELSE '' END,
28325
 
             _c.cobmisc_misc_accnt_id,
28326
 
             _c.cobmisc_payment, '',
28327
 
             'Multiple Sales Order # Invoice', _c.cohead_prj_id, _c.cobmisc_curr_id,
28328
 
             _c.cobmisc_taxzone_id,
28329
 
             _c.cohead_shipchrg_id,
28330
 
             _c.cohead_saletype_id, _c.cohead_shipzone_id
28331
 
             );
28332
 
 
28333
 
    _lastlinenumber := 1;
28334
 
    FOR _i IN SELECT cobmisc_id
28335
 
                FROM cobmisc
28336
 
                JOIN cohead   ON (cobmisc_cohead_id=cohead_id)
28337
 
                JOIN custinfo ON (cohead_cust_id=cust_id)
28338
 
                LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)
28339
 
               WHERE(NOT cobmisc_posted
28340
 
                 AND (cohead_cust_id=pCustid)
28341
 
                 AND (COALESCE(cohead_billtoname,'')         = COALESCE(_c.cohead_billtoname,''))
28342
 
                 AND (COALESCE(cohead_billtoaddress1,'')     = COALESCE(_c.cohead_billtoaddress1,''))
28343
 
                 AND (COALESCE(cohead_billtoaddress2,'')     = COALESCE(_c.cohead_billtoaddress2,''))
28344
 
                 AND (COALESCE(cohead_billtoaddress3,'')     = COALESCE(_c.cohead_billtoaddress3,''))
28345
 
                 AND (COALESCE(cohead_billtocity,'')         = COALESCE(_c.cohead_billtocity,''))
28346
 
                 AND (COALESCE(cohead_billtostate,'')        = COALESCE(_c.cohead_billtostate,''))
28347
 
                 AND (COALESCE(cohead_billtozipcode,'')      = COALESCE(_c.cohead_billtozipcode,''))
28348
 
                 AND (COALESCE(cntct_phone,'')               = COALESCE(_c.cust_phone,''))
28349
 
                 AND (COALESCE(cohead_billtocountry,'')      = COALESCE(_c.cohead_billtocountry,''))
28350
 
                 AND (COALESCE(cohead_salesrep_id, 0)        = COALESCE(_c.cohead_salesrep_id, 0))
28351
 
                 AND (COALESCE(cohead_commission, 0)         = COALESCE(_c.cohead_commission, 0))
28352
 
                 AND (COALESCE(cohead_terms_id, 0)           = COALESCE(_c.cohead_terms_id, 0))
28353
 
                 AND (COALESCE(cobmisc_misc_accnt_id, 0)     = COALESCE(_c.cobmisc_misc_accnt_id, 0))
28354
 
                 AND (COALESCE(cohead_prj_id, 0)             = COALESCE(_c.cohead_prj_id, 0))
28355
 
                 AND (COALESCE(cobmisc_curr_id, 0)           = COALESCE(_c.cobmisc_curr_id, 0))
28356
 
                 AND (COALESCE(cobmisc_taxzone_id, 0)        = COALESCE(_c.cobmisc_taxzone_id, 0))
28357
 
                 AND (COALESCE(cohead_saletype_id, 0)        = COALESCE(_c.cohead_saletype_id, 0))
28358
 
                 AND (COALESCE(cohead_shipzone_id, 0)        = COALESCE(_c.cohead_shipzone_id, 0))
28359
 
                ) LOOP
28360
 
 
28361
 
    --  Create the Invoice Head tax
28362
 
        INSERT INTO invcheadtax(taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, 
28363
 
                                taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate)
28364
 
        SELECT _invcheadid,taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, 
28365
 
               taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate
28366
 
        FROM cobmisctax 
28367
 
        WHERE taxhist_parent_id = _i.cobmisc_id
28368
 
          AND taxhist_taxtype_id = getadjustmenttaxtypeid();
28369
 
 
28370
 
    --  Give this selection a number if it has not been assigned one
28371
 
        UPDATE cobmisc
28372
 
           SET cobmisc_invcnumber=_invcnumber
28373
 
         WHERE(cobmisc_id=_i.cobmisc_id);
28374
 
      
28375
 
    --  Create the Invoice items
28376
 
        FOR _r IN SELECT coitem_id, coitem_linenumber, coitem_subnumber, coitem_custpn,
28377
 
                         coitem_qtyord, cobill_qty,
28378
 
                         coitem_qty_uom_id, coitem_qty_invuomratio,
28379
 
                         coitem_custprice, coitem_price,
28380
 
                         coitem_price_uom_id, coitem_price_invuomratio,
28381
 
                         coitem_memo,
28382
 
                         itemsite_item_id, itemsite_warehous_id,
28383
 
                         cobill_taxtype_id
28384
 
                    FROM cohead, coitem, cobill, itemsite
28385
 
                   WHERE((cobill_coitem_id=coitem_id)
28386
 
                     AND (cohead_id=coitem_cohead_id)
28387
 
                     AND (coitem_itemsite_id=itemsite_id)
28388
 
                     AND (cobill_cobmisc_id=_i.cobmisc_id) ) 
28389
 
                   ORDER BY cohead_number, coitem_linenumber, coitem_subnumber LOOP
28390
 
      
28391
 
          SELECT NEXTVAL('invcitem_invcitem_id_seq') INTO _invcitemid;
28392
 
          INSERT INTO invcitem
28393
 
          ( invcitem_id, invcitem_invchead_id,
28394
 
            invcitem_linenumber, invcitem_item_id, invcitem_warehous_id,
28395
 
            invcitem_custpn, invcitem_number, invcitem_descrip,
28396
 
            invcitem_ordered, invcitem_billed,
28397
 
            invcitem_qty_uom_id, invcitem_qty_invuomratio,
28398
 
            invcitem_custprice, invcitem_price,
28399
 
            invcitem_price_uom_id, invcitem_price_invuomratio,
28400
 
            invcitem_notes,
28401
 
            invcitem_taxtype_id,
28402
 
            invcitem_coitem_id )
28403
 
          VALUES
28404
 
          ( _invcitemid, _invcheadid,
28405
 
            _lastlinenumber,
28406
 
            _r.itemsite_item_id, _r.itemsite_warehous_id,
28407
 
            _r.coitem_custpn, '', '',
28408
 
            _r.coitem_qtyord, _r.cobill_qty,
28409
 
            _r.coitem_qty_uom_id, _r.coitem_qty_invuomratio,
28410
 
            _r.coitem_custprice, _r.coitem_price,
28411
 
            _r.coitem_price_uom_id, _r.coitem_price_invuomratio,
28412
 
            _r.coitem_memo,
28413
 
            _r.cobill_taxtype_id,
28414
 
            _r.coitem_id );
28415
 
          
28416
 
      --  Find and mark any Lot/Serial invdetail records associated with this bill
28417
 
          UPDATE invdetail SET invdetail_invcitem_id = _invcitemid
28418
 
           WHERE (invdetail_id IN (SELECT invdetail_id
28419
 
                                     FROM coitem, cohead, invhist, invdetail
28420
 
                                    WHERE ((coitem_cohead_id=cohead_id)
28421
 
                                      AND  (invdetail_invhist_id=invhist_id)
28422
 
                                      AND  (invhist_ordnumber = text(cohead_number||'-'||formatSoLineNumber(coitem_id)))
28423
 
                                      AND  (invdetail_invcitem_id IS NULL)
28424
 
                                      AND  (coitem_id=_r.coitem_id)) ) );
28425
 
      
28426
 
      --  Mark any shipped, uninvoiced shipitems for the current coitem as invoiced
28427
 
          _qtyToInvoice :=  _r.cobill_qty;
28428
 
          FOR _s IN SELECT shipitem.*, shipitem_qty = _r.cobill_qty AS matched
28429
 
                    FROM shipitem, shiphead
28430
 
                    WHERE ((shipitem_shiphead_id=shiphead_id)
28431
 
                      AND  (shipitem_orderitem_id=_r.coitem_id)
28432
 
                      AND  (shiphead_shipped)
28433
 
                      AND  (shiphead_order_type='SO')
28434
 
                      AND  (NOT shipitem_invoiced))
28435
 
                    ORDER BY matched DESC, shipitem_qty DESC FOR UPDATE LOOP
28436
 
            IF (_qtyToInvoice >= _s.shipitem_qty) THEN
28437
 
              UPDATE shipitem
28438
 
              SET shipitem_invoiced=TRUE, shipitem_invcitem_id=_invcitemid
28439
 
              WHERE (shipitem_id=_s.shipitem_id);
28440
 
              _qtyToInvoice := _qtyToInvoice - _s.shipitem_qty;
28441
 
            END IF;
28442
 
            IF (_qtyToInvoice <= 0) THEN
28443
 
              EXIT;
28444
 
            END IF;
28445
 
          END LOOP;
28446
 
 
28447
 
          UPDATE cobill SET cobill_invcnum=cobmisc_invcnumber,
28448
 
                          cobill_invcitem_id=invcitem_id
28449
 
          FROM invcitem, coitem, cobmisc
28450
 
          WHERE ((invcitem_linenumber=_lastlinenumber )
28451
 
            AND  (coitem_id=cobill_coitem_id)
28452
 
            AND  (cobmisc_id=cobill_cobmisc_id)
28453
 
            AND  (cobill_cobmisc_id=_i.cobmisc_id)
28454
 
            AND  (invcitem_invchead_id=_invcheadid));
28455
 
 
28456
 
 
28457
 
          _lastlinenumber := _lastlinenumber + 1;
28458
 
          
28459
 
        END LOOP;
28460
 
  
28461
 
      --  Close all requested coitem's
28462
 
        IF ( ( SELECT cobmisc_closeorder
28463
 
               FROM cobmisc
28464
 
               WHERE (cobmisc_id=_i.cobmisc_id) ) ) THEN
28465
 
          UPDATE coitem
28466
 
          SET coitem_status='C'
28467
 
          FROM cobmisc
28468
 
          WHERE ( (coitem_status NOT IN ('C', 'X'))
28469
 
           AND (coitem_cohead_id=cobmisc_cohead_id)
28470
 
           AND (cobmisc_id=_i.cobmisc_id) );
28471
 
        ELSE
28472
 
          UPDATE coitem
28473
 
          SET coitem_status='C'
28474
 
          FROM cobill
28475
 
          WHERE ( (cobill_coitem_id=coitem_id)
28476
 
           AND (coitem_status <> 'X')
28477
 
           AND (cobill_toclose)
28478
 
           AND (cobill_cobmisc_id=_i.cobmisc_id) );
28479
 
        END IF;
28480
 
      
28481
 
      --  Mark the cobmisc as posted
28482
 
        UPDATE cobmisc
28483
 
        SET cobmisc_posted=TRUE, cobmisc_invchead_id=_invcheadid
28484
 
        WHERE (cobmisc_id=_i.cobmisc_id);
28485
 
    
28486
 
      --  All done
28487
 
        _count := (_count + 1);
28488
 
      END LOOP;
28489
 
    END IF;
28490
 
  END LOOP;
28491
 
  RETURN _count;
28492
 
END;
28493
 
$_$;
28494
 
 
28495
 
 
28496
 
ALTER FUNCTION public.createinvoiceconsolidated(integer) OWNER TO admin;
28497
 
 
28498
 
--
28499
 
--
28500
 
 
28501
 
CREATE FUNCTION createinvoices() RETURNS integer
28502
 
    LANGUAGE plpgsql
28503
 
    AS $$
28504
 
DECLARE
28505
 
  _counter INTEGER;
28506
 
  _cobmisc RECORD;
28507
 
 
28508
 
BEGIN
28509
 
 
28510
 
  _counter := 0;
28511
 
 
28512
 
  FOR _cobmisc IN SELECT cobmisc_id
28513
 
                  FROM cobmisc
28514
 
                  WHERE (NOT cobmisc_posted) LOOP
28515
 
 
28516
 
    PERFORM createinvoice(_cobmisc.cobmisc_id);
28517
 
    _counter := (_counter + 1);
28518
 
 
28519
 
  END LOOP;
28520
 
 
28521
 
  RETURN _counter;
28522
 
END;
28523
 
$$;
28524
 
 
28525
 
 
28526
 
ALTER FUNCTION public.createinvoices() OWNER TO admin;
28527
 
 
28528
 
--
28529
 
--
28530
 
 
28531
 
CREATE FUNCTION createinvoices(integer) RETURNS integer
28532
 
    LANGUAGE plpgsql
28533
 
    AS $_$
28534
 
BEGIN
28535
 
  RETURN createinvoices($1, false);
28536
 
END;
28537
 
$_$;
28538
 
 
28539
 
 
28540
 
ALTER FUNCTION public.createinvoices(integer) OWNER TO admin;
28541
 
 
28542
 
--
28543
 
--
28544
 
 
28545
 
CREATE FUNCTION createinvoices(integer, boolean) RETURNS integer
28546
 
    LANGUAGE plpgsql
28547
 
    AS $_$
28548
 
DECLARE
28549
 
  pCustTypeId ALIAS FOR $1;
28550
 
  pConsolidate ALIAS FOR $2;
28551
 
  _counter INTEGER;
28552
 
  _tcounter INTEGER;
28553
 
  _cobmisc RECORD;
28554
 
 
28555
 
BEGIN
28556
 
 
28557
 
  _counter := 0;
28558
 
 
28559
 
  IF (pConsolidate) THEN
28560
 
    FOR _cobmisc IN SELECT DISTINCT cust_id
28561
 
                      FROM cobmisc, cohead, custinfo
28562
 
                     WHERE((NOT cobmisc_posted)
28563
 
                       AND (cohead_id=cobmisc_cohead_id)
28564
 
                       AND (cust_id=cohead_cust_id)
28565
 
                       AND (cust_custtype_id=pCustTypeId)) LOOP
28566
 
 
28567
 
      SELECT createinvoiceConsolidated(_cobmisc.cust_id)
28568
 
        INTO _tcounter;
28569
 
      _counter := (_counter + _tcounter);
28570
 
    END LOOP;
28571
 
  ELSE
28572
 
    FOR _cobmisc IN SELECT cobmisc_id
28573
 
                      FROM cobmisc, cohead, custinfo
28574
 
                     WHERE((NOT cobmisc_posted)
28575
 
                       AND (cohead_id=cobmisc_cohead_id)
28576
 
                       AND (cust_id=cohead_cust_id)
28577
 
                       AND (cust_custtype_id=pCustTypeId)) LOOP
28578
 
  
28579
 
      PERFORM createinvoice(_cobmisc.cobmisc_id);
28580
 
      _counter := (_counter + 1);
28581
 
 
28582
 
    END LOOP;
28583
 
  END IF;
28584
 
 
28585
 
  RETURN _counter;
28586
 
END;
28587
 
$_$;
28588
 
 
28589
 
 
28590
 
ALTER FUNCTION public.createinvoices(integer, boolean) OWNER TO admin;
28591
 
 
28592
 
--
28593
 
--
28594
 
 
28595
 
CREATE FUNCTION createmiscapcheck(integer, integer, date, numeric, integer, text, text) RETURNS integer
28596
 
    LANGUAGE plpgsql
28597
 
    AS $_$
28598
 
BEGIN
28599
 
  RAISE NOTICE 'createMiscAPCheck() is deprecated - use createCheck() instead';
28600
 
  RETURN createCheck($1, 'V', $2, $3, $4, baseCurrId(), $5, NULL, $6, $7, FALSE);
28601
 
END;
28602
 
$_$;
28603
 
 
28604
 
 
28605
 
ALTER FUNCTION public.createmiscapcheck(integer, integer, date, numeric, integer, text, text) OWNER TO admin;
28606
 
 
28607
 
--
28608
 
--
28609
 
 
28610
 
CREATE FUNCTION createmiscapcheck(integer, integer, date, numeric, integer, integer, text, text) RETURNS integer
28611
 
    LANGUAGE plpgsql
28612
 
    AS $_$
28613
 
BEGIN
28614
 
  RAISE NOTICE 'createMiscAPCheck() is deprecated - use createCheck() instead';
28615
 
  RETURN createCheck($1, 'V', $2, $3, pAmount, $5, $6, NULL, $7, $8, FALSE);
28616
 
END;
28617
 
$_$;
28618
 
 
28619
 
 
28620
 
ALTER FUNCTION public.createmiscapcheck(integer, integer, date, numeric, integer, integer, text, text) OWNER TO admin;
28621
 
 
28622
 
--
28623
 
--
28624
 
 
28625
 
CREATE FUNCTION createpkgschema(text, text) RETURNS integer
28626
 
    LANGUAGE plpgsql
28627
 
    AS $_$
28628
 
DECLARE
28629
 
  pname         ALIAS FOR $1;
28630
 
  pcomment      ALIAS FOR $2;
28631
 
  _createtable  TEXT;
28632
 
  _debug        BOOL    := true;
28633
 
  _namespaceoid INTEGER := -1;
28634
 
  _tabs         TEXT[] := ARRAY['cmd',  'cmdarg', 'image',  'metasql',
28635
 
                                'priv', 'report', 'script', 'uiform'] ;
28636
 
  _pkgtab       TEXT;
28637
 
 
28638
 
BEGIN
28639
 
  IF (LENGTH(COALESCE(pname, '')) <= 0) THEN
28640
 
    RAISE EXCEPTION 'Cannot create a schema for this package without a name.';
28641
 
  END IF;
28642
 
 
28643
 
  SELECT oid INTO _namespaceoid
28644
 
  FROM pg_namespace
28645
 
  WHERE (LOWER(nspname)=LOWER(pname));
28646
 
  IF (NOT FOUND) THEN
28647
 
    EXECUTE 'CREATE SCHEMA ' || LOWER(pname);
28648
 
    EXECUTE 'GRANT ALL ON SCHEMA ' || LOWER(pname) || ' TO GROUP xtrole;';
28649
 
 
28650
 
    SELECT oid INTO _namespaceoid
28651
 
    FROM pg_namespace
28652
 
    WHERE (LOWER(nspname)=LOWER(pname));
28653
 
  END IF;
28654
 
 
28655
 
  FOR i IN ARRAY_LOWER(_tabs,1)..ARRAY_UPPER(_tabs,1) LOOP
28656
 
    _pkgtab := pname || '.pkg' || _tabs[i];
28657
 
 
28658
 
    IF NOT EXISTS(SELECT oid
28659
 
                  FROM pg_class
28660
 
                  WHERE ((relname=_pkgtab)
28661
 
                     AND (relnamespace=_namespaceoid))) THEN
28662
 
      _createtable := 'CREATE TABLE ' || _pkgtab || ' () INHERITS (' || _tabs[i] || ');';
28663
 
      IF (_debug) THEN RAISE NOTICE '%', _createtable; END IF;
28664
 
      EXECUTE _createtable;
28665
 
 
28666
 
      EXECUTE 'ALTER TABLE ' || _pkgtab ||
28667
 
              ' ALTER ' || _tabs[i] || '_id SET NOT NULL,' ||
28668
 
              ' ADD PRIMARY KEY (' || _tabs[i] || '_id),' ||
28669
 
              ' ALTER ' || _tabs[i] || '_id SET DEFAULT NEXTVAL(''' ||
28670
 
              _tabs[i] || '_' || _tabs[i] || '_id_seq'');';
28671
 
 
28672
 
      EXECUTE 'REVOKE ALL ON ' || _pkgtab || ' FROM PUBLIC;';
28673
 
      EXECUTE 'GRANT  ALL ON ' || _pkgtab || ' TO GROUP xtrole;';
28674
 
 
28675
 
      IF (_tabs[i] = 'cmdarg') THEN
28676
 
        EXECUTE 'ALTER TABLE ' || _pkgtab ||
28677
 
                ' ADD FOREIGN KEY (cmdarg_cmd_id) REFERENCES ' ||
28678
 
                pname || '.pkgcmd(cmd_id);';
28679
 
      END IF;
28680
 
 
28681
 
      EXECUTE 'SELECT dropIfExists(''TRIGGER'', ''pkg' ||
28682
 
                                   _tabs[i] || 'beforetrigger'', ''' ||
28683
 
                                   pname || ''');' ;
28684
 
      EXECUTE 'CREATE TRIGGER pkg' || _tabs[i] || 'beforetrigger ' ||
28685
 
              'BEFORE INSERT OR UPDATE OR DELETE ON ' || _pkgtab ||
28686
 
              ' FOR EACH ROW EXECUTE PROCEDURE _pkg' || _tabs[i] || 'beforetrigger();';
28687
 
 
28688
 
      EXECUTE 'SELECT dropIfExists(''TRIGGER'', ''pkg' ||
28689
 
                                   _tabs[i] || 'altertrigger'', ''' ||
28690
 
                                   pname || ''');' ;
28691
 
      EXECUTE 'CREATE TRIGGER pkg' || _tabs[i] || 'altertrigger ' ||
28692
 
              'BEFORE INSERT OR UPDATE OR DELETE ON ' || _pkgtab ||
28693
 
              ' FOR EACH ROW EXECUTE PROCEDURE _pkg' || _tabs[i] || 'altertrigger();';
28694
 
 
28695
 
      EXECUTE 'SELECT dropIfExists(''TRIGGER'', ''pkg' ||
28696
 
                                   _tabs[i] || 'aftertrigger'', ''' ||
28697
 
                                   pname || ''');' ;
28698
 
      EXECUTE 'CREATE TRIGGER pkg' || _tabs[i] || 'aftertrigger ' ||
28699
 
              'AFTER INSERT OR UPDATE OR DELETE ON ' || _pkgtab ||
28700
 
              ' FOR EACH ROW EXECUTE PROCEDURE _pkg' || _tabs[i] || 'aftertrigger();';
28701
 
 
28702
 
    END IF;
28703
 
  END LOOP;
28704
 
 
28705
 
  EXECUTE 'COMMENT ON SCHEMA ' || quote_ident(pname) || ' IS ' ||
28706
 
           quote_literal(pcomment) || ';';
28707
 
 
28708
 
  RETURN _namespaceoid;
28709
 
END;
28710
 
$_$;
28711
 
 
28712
 
 
28713
 
ALTER FUNCTION public.createpkgschema(text, text) OWNER TO admin;
28714
 
 
28715
 
--
28716
 
--
28717
 
 
28718
 
CREATE FUNCTION createpr(character, integer) RETURNS integer
28719
 
    LANGUAGE plpgsql
28720
 
    AS $_$
28721
 
DECLARE
28722
 
  pParentType ALIAS FOR $1;
28723
 
  pParentId ALIAS FOR $2;
28724
 
  _orderNumber INTEGER;
28725
 
  _prid INTEGER;
28726
 
 
28727
 
BEGIN
28728
 
 
28729
 
  IF (pParentType = 'W') THEN
28730
 
    SELECT wo_number INTO _orderNumber
28731
 
    FROM wo, womatl
28732
 
    WHERE ((womatl_wo_id=wo_id)
28733
 
     AND (womatl_id=pParentId));
28734
 
 
28735
 
  ELSIF (pParentType = 'S') THEN
28736
 
    SELECT CAST(cohead_number AS INTEGER) INTO _orderNumber
28737
 
    FROM cohead, coitem
28738
 
    WHERE ((coitem_cohead_id=cohead_id)
28739
 
     AND (coitem_id=pParentId));
28740
 
 
28741
 
  ELSIF (pParentType = 'F') THEN
28742
 
    SELECT fetchPrNumber() INTO _orderNumber;
28743
 
 
28744
 
  ELSE
28745
 
    RETURN -2;
28746
 
  END IF;
28747
 
 
28748
 
  IF (NOT FOUND) THEN
28749
 
    RETURN -1;
28750
 
  END IF;
28751
 
 
28752
 
  SELECT createPr(_orderNumber, pParentType, pParentId) INTO _prid;
28753
 
 
28754
 
  RETURN _prid;
28755
 
 
28756
 
END;
28757
 
$_$;
28758
 
 
28759
 
 
28760
 
ALTER FUNCTION public.createpr(character, integer) OWNER TO admin;
28761
 
 
28762
 
--
28763
 
--
28764
 
 
28765
 
CREATE FUNCTION createpr(integer, character, integer) RETURNS integer
28766
 
    LANGUAGE plpgsql
28767
 
    AS $_$
28768
 
DECLARE
28769
 
  pOrderNumber ALIAS FOR $1;
28770
 
  pParentType ALIAS FOR $2;
28771
 
  pParentId ALIAS FOR $3;
28772
 
  _parent RECORD;
28773
 
  _prid INTEGER;
28774
 
  _orderNumber INTEGER;
28775
 
 
28776
 
BEGIN
28777
 
 
28778
 
  IF (pOrderNumber = -1) THEN
28779
 
    SELECT fetchPrNumber() INTO _orderNumber;
28780
 
  ELSE
28781
 
    _orderNumber := pOrderNumber;
28782
 
  END IF;
28783
 
 
28784
 
  IF (pParentType = 'W') THEN
28785
 
    SELECT womatl_itemsite_id AS itemsiteid,
28786
 
           itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS qty,
28787
 
           womatl_duedate AS duedate, wo_prj_id AS prjid,
28788
 
           womatl_notes AS notes INTO _parent
28789
 
    FROM wo, womatl, itemsite
28790
 
    WHERE ((womatl_wo_id=wo_id)
28791
 
     AND (womatl_itemsite_id=itemsite_id)
28792
 
     AND (womatl_id=pParentId));
28793
 
 
28794
 
  ELSIF (pParentType = 'S') THEN
28795
 
    SELECT coitem_itemsite_id AS itemsiteid,
28796
 
           (coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qty,
28797
 
           coitem_scheddate AS duedate, cohead_prj_id AS prjid,
28798
 
           coitem_memo AS notes INTO _parent
28799
 
    FROM coitem, cohead
28800
 
    WHERE ((cohead_id=coitem_cohead_id)
28801
 
     AND (coitem_id=pParentId));
28802
 
 
28803
 
  ELSIF (pParentType = 'F') THEN
28804
 
    SELECT planord_itemsite_id AS itemsiteid,
28805
 
           planord_qty AS qty,
28806
 
           planord_duedate AS duedate, NULL::INTEGER AS prjid,
28807
 
           planord_comments AS notes INTO _parent
28808
 
    FROM planord
28809
 
    WHERE (planord_id=pParentId);
28810
 
 
28811
 
  ELSE
28812
 
    RETURN -2;
28813
 
  END IF;
28814
 
 
28815
 
  IF (NOT FOUND) THEN
28816
 
    RETURN -1;
28817
 
  END IF;
28818
 
 
28819
 
  SELECT NEXTVAL('pr_pr_id_seq') INTO _prid;
28820
 
  INSERT INTO pr
28821
 
  ( pr_id, pr_number, pr_subnumber, pr_status,
28822
 
    pr_order_type, pr_order_id, pr_prj_id,
28823
 
    pr_itemsite_id, pr_qtyreq,
28824
 
    pr_duedate, pr_releasenote )
28825
 
  VALUES
28826
 
  ( _prid, _orderNumber, nextPrSubnumber(_orderNumber), 'O',
28827
 
    pParentType, pParentId, _parent.prjid,
28828
 
    _parent.itemsiteid, validateOrderQty(_parent.itemsiteid, _parent.qty, TRUE),
28829
 
    _parent.duedate, _parent.notes );
28830
 
 
28831
 
  RETURN _prid;
28832
 
 
28833
 
END;
28834
 
$_$;
28835
 
 
28836
 
 
28837
 
ALTER FUNCTION public.createpr(integer, character, integer) OWNER TO admin;
28838
 
 
28839
 
--
28840
 
--
28841
 
 
28842
 
CREATE FUNCTION createpr(integer, character, integer, text) RETURNS integer
28843
 
    LANGUAGE plpgsql
28844
 
    AS $_$
28845
 
DECLARE
28846
 
  pOrderNumber ALIAS FOR $1;
28847
 
  pParentType ALIAS FOR $2;
28848
 
  pParentId ALIAS FOR $3;
28849
 
  pParentNotes ALIAS FOR $4;
28850
 
  _parent RECORD;
28851
 
  _prid INTEGER;
28852
 
  _orderNumber INTEGER;
28853
 
 
28854
 
BEGIN
28855
 
 
28856
 
  IF (pOrderNumber = -1) THEN
28857
 
    SELECT fetchPrNumber() INTO _orderNumber;
28858
 
  ELSE
28859
 
    _orderNumber := pOrderNumber;
28860
 
  END IF;
28861
 
 
28862
 
  IF (pParentType = 'W') THEN
28863
 
    SELECT womatl_itemsite_id AS itemsiteid,
28864
 
           itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS qty,
28865
 
           womatl_duedate AS duedate, wo_prj_id AS prjid INTO _parent
28866
 
    FROM wo, womatl, itemsite
28867
 
    WHERE ((womatl_wo_id=wo_id)
28868
 
     AND (womatl_itemsite_id=itemsite_id)
28869
 
     AND (womatl_id=pParentId));
28870
 
 
28871
 
  ELSIF (pParentType = 'S') THEN
28872
 
    SELECT coitem_itemsite_id AS itemsiteid,
28873
 
           (coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qty,
28874
 
           coitem_scheddate AS duedate, cohead_prj_id AS prjid INTO _parent
28875
 
    FROM coitem, cohead
28876
 
    WHERE ((cohead_id=coitem_cohead_id)
28877
 
     AND (coitem_id=pParentId));
28878
 
 
28879
 
  ELSIF (pParentType = 'F') THEN
28880
 
    SELECT planord_itemsite_id AS itemsiteid,
28881
 
           planord_qty AS qty,
28882
 
           planord_duedate AS duedate, NULL::INTEGER AS prjid 
28883
 
           INTO _parent
28884
 
    FROM planord
28885
 
    WHERE (planord_id=pParentId);
28886
 
 
28887
 
  ELSE
28888
 
    RETURN -2;
28889
 
  END IF;
28890
 
 
28891
 
  IF (NOT FOUND) THEN
28892
 
    RETURN -1;
28893
 
  END IF;
28894
 
 
28895
 
  SELECT NEXTVAL('pr_pr_id_seq') INTO _prid;
28896
 
  INSERT INTO pr
28897
 
  ( pr_id, pr_number, pr_subnumber, pr_status,
28898
 
    pr_order_type, pr_order_id, pr_prj_id,
28899
 
    pr_itemsite_id, pr_qtyreq, pr_duedate, pr_releasenote )
28900
 
  VALUES
28901
 
  ( _prid, _orderNumber, nextPrSubnumber(_orderNumber), 'O',
28902
 
    pParentType, pParentId, _parent.prjid,
28903
 
    _parent.itemsiteid, validateOrderQty(_parent.itemsiteid, _parent.qty, TRUE),
28904
 
    _parent.duedate, pParentNotes );
28905
 
 
28906
 
  RETURN _prid;
28907
 
 
28908
 
END;
28909
 
$_$;
28910
 
 
28911
 
 
28912
 
ALTER FUNCTION public.createpr(integer, character, integer, text) OWNER TO admin;
28913
 
 
28914
 
--
28915
 
--
28916
 
 
28917
 
CREATE FUNCTION createpr(integer, integer, numeric, date, text) RETURNS integer
28918
 
    LANGUAGE plpgsql
28919
 
    AS $_$
28920
 
DECLARE
28921
 
  pOrderNumber ALIAS FOR $1;
28922
 
  pItemsiteid ALIAS FOR $2;
28923
 
  pQty ALIAS FOR $3;
28924
 
  pDueDate ALIAS FOR $4;
28925
 
  pNotes ALIAS FOR $5;
28926
 
  _prid INTEGER;
28927
 
 
28928
 
BEGIN
28929
 
 
28930
 
  SELECT NEXTVAL('pr_pr_id_seq') INTO _prid;
28931
 
  INSERT INTO pr
28932
 
  ( pr_id, pr_number, pr_subnumber, pr_status,
28933
 
    pr_order_type, pr_order_id,
28934
 
    pr_itemsite_id, pr_qtyreq, pr_duedate, pr_releasenote )
28935
 
  VALUES
28936
 
  ( _prid, pOrderNumber, nextPrSubnumber(pOrderNumber), 'O',
28937
 
    'M', -1,
28938
 
    pItemsiteid, pQty, pDuedate, pNotes);
28939
 
 
28940
 
  RETURN _prid;
28941
 
 
28942
 
END;
28943
 
$_$;
28944
 
 
28945
 
 
28946
 
ALTER FUNCTION public.createpr(integer, integer, numeric, date, text) OWNER TO admin;
28947
 
 
28948
 
--
28949
 
--
28950
 
 
28951
 
CREATE FUNCTION createpr(integer, integer, numeric, date, text, character, integer) RETURNS integer
28952
 
    LANGUAGE plpgsql
28953
 
    AS $_$
28954
 
DECLARE
28955
 
  pOrderNumber ALIAS FOR $1;
28956
 
  pItemsiteid ALIAS FOR $2;
28957
 
  pQty ALIAS FOR $3;
28958
 
  pDueDate ALIAS FOR $4;
28959
 
  pNotes ALIAS FOR $5;
28960
 
  pOrderType ALIAS FOR $6;
28961
 
  pOrderId ALIAS FOR $7;
28962
 
  _prid INTEGER;
28963
 
 
28964
 
BEGIN
28965
 
 
28966
 
  SELECT NEXTVAL('pr_pr_id_seq') INTO _prid;
28967
 
  INSERT INTO pr
28968
 
  ( pr_id, pr_number, pr_subnumber, pr_status,
28969
 
    pr_order_type, pr_order_id,
28970
 
    pr_itemsite_id, pr_qtyreq, pr_duedate, pr_releasenote )
28971
 
  VALUES
28972
 
  ( _prid, pOrderNumber, nextPrSubnumber(pOrderNumber), 'O',
28973
 
    pOrderType, pOrderId,
28974
 
    pItemsiteid, pQty, pDuedate, pNotes );
28975
 
 
28976
 
  RETURN _prid;
28977
 
 
28978
 
END;
28979
 
$_$;
28980
 
 
28981
 
 
28982
 
ALTER FUNCTION public.createpr(integer, integer, numeric, date, text, character, integer) OWNER TO admin;
28983
 
 
28984
 
--
28985
 
--
28986
 
 
28987
 
CREATE FUNCTION createpriv(text, text, text) RETURNS integer
28988
 
    LANGUAGE plpgsql
28989
 
    AS $_$
28990
 
DECLARE
28991
 
  pModule ALIAS FOR $1;
28992
 
  pName   ALIAS FOR $2;
28993
 
  pDesc   ALIAS FOR $3;
28994
 
  _id     INTEGER;
28995
 
BEGIN
28996
 
 
28997
 
  SELECT priv_id
28998
 
    INTO _id
28999
 
    FROM priv
29000
 
   WHERE(priv_name=pName);
29001
 
 
29002
 
  IF (FOUND) THEN
29003
 
    UPDATE priv
29004
 
       SET priv_module=pModule,
29005
 
           priv_descrip=pDesc
29006
 
     WHERE(priv_id=_id);
29007
 
  ELSE
29008
 
    SELECT nextval('priv_priv_id_seq') INTO _id;
29009
 
    INSERT INTO priv
29010
 
          (priv_id, priv_module, priv_name, priv_descrip)
29011
 
    VALUES(_id, pModule, pName, pDesc);
29012
 
  END IF;
29013
 
 
29014
 
  RETURN _id;
29015
 
END;
29016
 
$_$;
29017
 
 
29018
 
 
29019
 
ALTER FUNCTION public.createpriv(text, text, text) OWNER TO admin;
29020
 
 
29021
 
--
29022
 
--
29023
 
 
29024
 
CREATE FUNCTION createpurchasetosale(integer, integer, boolean) RETURNS integer
29025
 
    LANGUAGE plpgsql
29026
 
    AS $_$
29027
 
DECLARE
29028
 
  pCoitemId ALIAS FOR $1;
29029
 
  pItemSourceId ALIAS FOR $2;
29030
 
  pDropShip ALIAS FOR $3;
29031
 
 
29032
 
BEGIN
29033
 
 
29034
 
  RETURN createPurchaseToSale(pCoitemId, pItemSourceId, pDropShip, NULL, NULL, NULL);
29035
 
 
29036
 
END;
29037
 
$_$;
29038
 
 
29039
 
 
29040
 
ALTER FUNCTION public.createpurchasetosale(integer, integer, boolean) OWNER TO admin;
29041
 
 
29042
 
--
29043
 
--
29044
 
 
29045
 
CREATE FUNCTION createpurchasetosale(integer, integer, boolean, numeric) RETURNS integer
29046
 
    LANGUAGE plpgsql
29047
 
    AS $_$
29048
 
DECLARE
29049
 
  pCoitemId ALIAS FOR $1;
29050
 
  pItemSourceId ALIAS FOR $2;
29051
 
  pDropShip ALIAS FOR $3;
29052
 
  pPrice ALIAS FOR $4;
29053
 
 
29054
 
BEGIN
29055
 
 
29056
 
  RETURN createPurchaseToSale(pCoitemId, pItemSourceId, pDropShip, NULL, NULL, pPrice);
29057
 
 
29058
 
END;
29059
 
$_$;
29060
 
 
29061
 
 
29062
 
ALTER FUNCTION public.createpurchasetosale(integer, integer, boolean, numeric) OWNER TO admin;
29063
 
 
29064
 
--
29065
 
--
29066
 
 
29067
 
CREATE FUNCTION createpurchasetosale(integer, integer, boolean, numeric, date, numeric) RETURNS integer
29068
 
    LANGUAGE plpgsql
29069
 
    AS $_$
29070
 
DECLARE
29071
 
  pCoitemId ALIAS FOR $1;
29072
 
  pItemSourceId ALIAS FOR $2;
29073
 
  pDropShip ALIAS FOR $3;
29074
 
  pQty ALIAS FOR $4;
29075
 
  pDueDate ALIAS FOR $5;
29076
 
  pPrice ALIAS FOR $6;
29077
 
 
29078
 
BEGIN
29079
 
 
29080
 
  RETURN createPurchaseToSale(pCoitemId, pItemSourceId, pDropShip, pQty, pDueDate, pPrice, NULL);
29081
 
 
29082
 
END;
29083
 
$_$;
29084
 
 
29085
 
 
29086
 
ALTER FUNCTION public.createpurchasetosale(integer, integer, boolean, numeric, date, numeric) OWNER TO admin;
29087
 
 
29088
 
--
29089
 
--
29090
 
 
29091
 
CREATE FUNCTION createpurchasetosale(integer, integer, boolean, numeric, date, numeric, integer) RETURNS integer
29092
 
    LANGUAGE plpgsql
29093
 
    AS $_$
29094
 
DECLARE
29095
 
  pCoitemId ALIAS FOR $1;
29096
 
  pItemSourceId ALIAS FOR $2;
29097
 
  pDropShip ALIAS FOR $3;
29098
 
  pQty ALIAS FOR $4;
29099
 
  pDueDate ALIAS FOR $5;
29100
 
  pPrice ALIAS FOR $6;
29101
 
  pPoheadId ALIAS FOR $7;
29102
 
 
29103
 
  _s RECORD;
29104
 
  _w RECORD;
29105
 
  _i RECORD;
29106
 
  _shipto RECORD;
29107
 
  _poheadid INTEGER := -1;
29108
 
  _poitemid INTEGER := -1;
29109
 
  _taxtypeid INTEGER := -1;
29110
 
  _polinenumber INTEGER;
29111
 
  _ponumber NUMERIC;
29112
 
  _price NUMERIC;
29113
 
  _temp INTEGER;
29114
 
 
29115
 
BEGIN
29116
 
 
29117
 
  -- Check for existing poitem for this coitem
29118
 
  SELECT poitem_id INTO _poitemid
29119
 
  FROM poitem
29120
 
  WHERE (poitem_order_id=pCoitemId)
29121
 
    AND (poitem_order_type='S');
29122
 
  IF (FOUND) THEN
29123
 
    RETURN _poitemid;
29124
 
  END IF;
29125
 
 
29126
 
  SELECT *,
29127
 
         COALESCE(roundQty(item_fractional, (coitem_qtyord * coitem_qty_invuomratio)), 0.0) AS orderqty
29128
 
  INTO _s
29129
 
  FROM coitem JOIN cohead ON (cohead_id = coitem_cohead_id)
29130
 
              LEFT OUTER JOIN shiptoinfo ON (cohead_shipto_id = shipto_id)
29131
 
              LEFT OUTER JOIN addr ON (shipto_addr_id = addr_id)
29132
 
              LEFT OUTER JOIN cntct ON (shipto_cntct_id = cntct_id)
29133
 
              LEFT OUTER JOIN itemsite ON (coitem_itemsite_id = itemsite_id)
29134
 
              LEFT OUTER JOIN item ON (item_id = itemsite_item_id)
29135
 
  WHERE (coitem_id = pCoitemId);
29136
 
  IF (NOT FOUND) THEN
29137
 
    RETURN -1;
29138
 
  END IF;
29139
 
 
29140
 
  SELECT * INTO _w
29141
 
  FROM itemsite JOIN whsinfo ON (warehous_id = itemsite_warehous_id)
29142
 
                LEFT OUTER JOIN addr ON (warehous_addr_id = addr_id)
29143
 
                LEFT OUTER JOIN cntct ON (warehous_cntct_id = cntct_id)
29144
 
  WHERE (itemsite_id = _s.itemsite_id);
29145
 
 
29146
 
  SELECT * INTO _i
29147
 
  FROM itemsrc JOIN vendinfo ON (itemsrc_vend_id = vend_id)
29148
 
               LEFT OUTER JOIN cntct ON (vend_cntct1_id = cntct_id)
29149
 
               LEFT OUTER JOIN addr ON (vend_addr_id = addr_id)
29150
 
  WHERE (itemsrc_id = pItemSourceId);
29151
 
  IF (NOT FOUND) THEN
29152
 
    RETURN -2;
29153
 
  END IF;
29154
 
 
29155
 
  -- pPoheadId - NULL=add to existing PO if one exists
29156
 
  --               -1=must create new PO
29157
 
  --               >0=must add to existing specified PO
29158
 
  IF (pDropShip) THEN
29159
 
    SELECT COALESCE(pohead_id, -1) INTO _temp
29160
 
    FROM pohead
29161
 
    WHERE ( (pohead_status = 'U')
29162
 
      AND (pohead_vend_id = _i.itemsrc_vend_id)
29163
 
      AND (COALESCE(pohead_shiptoname, '') = COALESCE(_s.cohead_shiptoname, _s.shipto_name, ''))
29164
 
      AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_s.cohead_shiptoaddress1, _s.addr_line1, ''))
29165
 
      AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_s.cohead_shiptoaddress2, _s.addr_line2, ''))
29166
 
      AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_s.cohead_shiptoaddress3, _s.addr_line3, ''))
29167
 
      AND (COALESCE(pohead_shiptocity, '') = COALESCE(_s.cohead_shiptocity, _s.addr_city, ''))
29168
 
      AND (COALESCE(pohead_shiptostate, '') = COALESCE(_s.cohead_shiptostate, _s.addr_state, ''))
29169
 
      AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_s.cohead_shiptozipcode, _s.addr_postalcode, ''))
29170
 
      AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_s.cohead_shiptocountry, _s.addr_country, ''))
29171
 
      AND ((pohead_id=pPoheadId) OR (pPoheadid IS NULL)) );
29172
 
  ELSE
29173
 
    SELECT COALESCE(pohead_id, -1) INTO _temp
29174
 
    FROM pohead
29175
 
    WHERE ( (pohead_status = 'U')
29176
 
      AND (pohead_vend_id = _i.itemsrc_vend_id)
29177
 
      AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_w.addr_line1, ''))
29178
 
      AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_w.addr_line2, ''))
29179
 
      AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_w.addr_line3, ''))
29180
 
      AND (COALESCE(pohead_shiptocity, '') = COALESCE(_w.addr_city, ''))
29181
 
      AND (COALESCE(pohead_shiptostate, '') = COALESCE(_w.addr_state, ''))
29182
 
      AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_w.addr_postalcode, ''))
29183
 
      AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_w.addr_country, ''))
29184
 
      AND ((pohead_id=pPoheadId) OR (pPoheadid IS NULL)) );
29185
 
  END IF;
29186
 
 
29187
 
  IF (FOUND) THEN
29188
 
    IF (pPoheadId = -1) THEN
29189
 
      RAISE EXCEPTION 'Problem creating new PO';
29190
 
    END IF;
29191
 
    _poheadid := _temp;
29192
 
    UPDATE pohead
29193
 
    SET pohead_dropship = pDropShip
29194
 
    WHERE (pohead_id = _poheadid);
29195
 
  ELSE
29196
 
    IF (pPoheadId > 0) THEN
29197
 
      RAISE EXCEPTION 'Problem adding to existing PO';
29198
 
    END IF;
29199
 
    SELECT NEXTVAL('pohead_pohead_id_seq') INTO _poheadid;
29200
 
    SELECT fetchPoNumber() INTO _ponumber;
29201
 
 
29202
 
    IF (pDropShip) THEN
29203
 
      INSERT INTO pohead
29204
 
        ( pohead_id, pohead_number, pohead_status, pohead_dropship,
29205
 
          pohead_agent_username, pohead_vend_id, pohead_taxzone_id,
29206
 
          pohead_orderdate, pohead_curr_id, pohead_cohead_id,
29207
 
          pohead_warehous_id, pohead_shipvia,
29208
 
          pohead_terms_id, pohead_shipto_cntct_id,
29209
 
          pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name,
29210
 
          pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name,
29211
 
          pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone,
29212
 
          pohead_shipto_cntct_title, pohead_shipto_cntct_fax, 
29213
 
          pohead_shipto_cntct_email, pohead_shiptoaddress_id,
29214
 
          pohead_shiptoname,
29215
 
          pohead_shiptoaddress1,
29216
 
          pohead_shiptoaddress2,
29217
 
          pohead_shiptoaddress3,
29218
 
          pohead_shiptocity, 
29219
 
          pohead_shiptostate, pohead_shiptozipcode,
29220
 
          pohead_shiptocountry, pohead_vend_cntct_id,
29221
 
          pohead_vend_cntct_honorific, pohead_vend_cntct_first_name,
29222
 
          pohead_vend_cntct_middle, pohead_vend_cntct_last_name,
29223
 
          pohead_vend_cntct_suffix, pohead_vend_cntct_phone,
29224
 
          pohead_vend_cntct_title, pohead_vend_cntct_fax,
29225
 
          pohead_vend_cntct_email, pohead_vendaddress1,
29226
 
          pohead_vendaddress2, pohead_vendaddress3,
29227
 
          pohead_vendcity, pohead_vendstate,
29228
 
          pohead_vendzipcode, pohead_vendcountry, pohead_comments )
29229
 
      VALUES
29230
 
        ( _poheadid, _ponumber, 'U', pDropShip,
29231
 
          getEffectiveXtUser(), _i.itemsrc_vend_id, _i.vend_taxzone_id,
29232
 
          CURRENT_DATE, COALESCE(_i.vend_curr_id, basecurrid()), _s.cohead_id,
29233
 
          COALESCE(_s.cohead_warehous_id, -1), COALESCE(_i.vend_shipvia, TEXT('')),
29234
 
          COALESCE(_i.vend_terms_id, -1), COALESCE(_s.cohead_shipto_cntct_id, _s.shipto_cntct_id),
29235
 
          COALESCE(_s.cohead_shipto_cntct_honorific, _s.cntct_honorific), COALESCE(_s.cohead_shipto_cntct_first_name, _s.cntct_first_name),
29236
 
          COALESCE(_s.cohead_shipto_cntct_middle, _s.cntct_middle), COALESCE(_s.cohead_shipto_cntct_last_name, _s.cntct_last_name),
29237
 
          COALESCE(_s.cohead_shipto_cntct_suffix, _s.cntct_suffix), COALESCE(_s.cohead_shipto_cntct_phone, _s.cntct_phone),
29238
 
          COALESCE(_s.cohead_shipto_cntct_title, _s.cntct_title), COALESCE(_s.cohead_shipto_cntct_fax, _s.cntct_fax),
29239
 
          COALESCE(_s.cohead_shipto_cntct_email, _s.cntct_email), COALESCE(_s.shipto_addr_id, _s.addr_id),
29240
 
          COALESCE(_s.cohead_shiptoname, _s.shipto_name, ''),
29241
 
          COALESCE(_s.cohead_shiptoaddress1, _s.addr_line1, ''),
29242
 
          COALESCE(_s.cohead_shiptoaddress2, _s.addr_line2, ''),
29243
 
          COALESCE(_s.cohead_shiptoaddress3, _s.addr_line3, ''),
29244
 
          COALESCE(_s.cohead_shiptocity, _s.addr_city, ''),
29245
 
          COALESCE(_s.cohead_shiptostate, _s.addr_state, ''), COALESCE(_s.cohead_shiptozipcode, _s.addr_postalcode, ''),
29246
 
          COALESCE(_s.cohead_shiptocountry, _s.addr_country, ''), _i.cntct_id,
29247
 
          COALESCE(_i.cntct_honorific, TEXT('')), COALESCE(_i.cntct_first_name, TEXT('')),
29248
 
          COALESCE(_i.cntct_middle, TEXT('')), COALESCE(_i.cntct_last_name, TEXT('')),
29249
 
          COALESCE(_i.cntct_suffix, TEXT('')), COALESCE(_i.cntct_phone, TEXT('')),
29250
 
          COALESCE(_i.cntct_title, TEXT('')), COALESCE(_i.cntct_fax, TEXT('')),
29251
 
          COALESCE(_i.cntct_email, TEXT('')), COALESCE(_i.addr_line1, TEXT('')),
29252
 
          COALESCE(_i.addr_line2, TEXT('')), COALESCE(_i.addr_line3, TEXT('')),
29253
 
          COALESCE(_i.addr_city, TEXT('')), COALESCE(_i.addr_state, TEXT('')),
29254
 
          COALESCE(_i.addr_postalcode, TEXT('')), COALESCE(_i.addr_country, TEXT('')), COALESCE(_s.cohead_shipcomments, TEXT('')) );
29255
 
    ELSE
29256
 
      INSERT INTO pohead
29257
 
        ( pohead_id, pohead_number, pohead_status, pohead_dropship,
29258
 
          pohead_agent_username, pohead_vend_id, pohead_taxzone_id,
29259
 
          pohead_orderdate, pohead_curr_id, pohead_cohead_id,
29260
 
          pohead_warehous_id, pohead_shipvia,
29261
 
          pohead_terms_id, pohead_shipto_cntct_id,
29262
 
          pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name,
29263
 
          pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name,
29264
 
          pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone,
29265
 
          pohead_shipto_cntct_title, pohead_shipto_cntct_fax, 
29266
 
          pohead_shipto_cntct_email, pohead_shiptoaddress_id,
29267
 
          pohead_shiptoaddress1,
29268
 
          pohead_shiptoaddress2,
29269
 
          pohead_shiptoaddress3,
29270
 
          pohead_shiptocity, 
29271
 
          pohead_shiptostate, pohead_shiptozipcode,
29272
 
          pohead_shiptocountry, pohead_vend_cntct_id,
29273
 
          pohead_vend_cntct_honorific, pohead_vend_cntct_first_name,
29274
 
          pohead_vend_cntct_middle, pohead_vend_cntct_last_name,
29275
 
          pohead_vend_cntct_suffix, pohead_vend_cntct_phone,
29276
 
          pohead_vend_cntct_title, pohead_vend_cntct_fax,
29277
 
          pohead_vend_cntct_email, pohead_vendaddress1,
29278
 
          pohead_vendaddress2, pohead_vendaddress3,
29279
 
          pohead_vendcity, pohead_vendstate,
29280
 
          pohead_vendzipcode, pohead_vendcountry )
29281
 
      VALUES
29282
 
        ( _poheadid, _ponumber, 'U', pDropShip,
29283
 
          getEffectiveXtUser(), _i.itemsrc_vend_id, _i.vend_taxzone_id,
29284
 
          CURRENT_DATE, COALESCE(_i.vend_curr_id, basecurrid()), _s.cohead_id,
29285
 
          COALESCE(_s.cohead_warehous_id, -1), COALESCE(_i.vend_shipvia, TEXT('')),
29286
 
          COALESCE(_i.vend_terms_id, -1), _w.cntct_id,
29287
 
          _w.cntct_honorific, _w.cntct_first_name,
29288
 
          _w.cntct_middle, _w.cntct_last_name,
29289
 
          _w.cntct_suffix, _w.cntct_phone,
29290
 
          _w.cntct_title, _w.cntct_fax,
29291
 
          _w.cntct_email, _w.addr_id,
29292
 
          COALESCE(_w.addr_line1, ''),
29293
 
          COALESCE(_w.addr_line2, ''),
29294
 
          COALESCE(_w.addr_line3, ''),
29295
 
          COALESCE(_w.addr_city, ''),
29296
 
          COALESCE(_w.addr_state, ''), COALESCE(_w.addr_postalcode, ''),
29297
 
          COALESCE(_w.addr_country, ''), _i.cntct_id,
29298
 
          COALESCE(_i.cntct_honorific, TEXT('')), COALESCE(_i.cntct_first_name, TEXT('')),
29299
 
          COALESCE(_i.cntct_middle, TEXT('')), COALESCE(_i.cntct_last_name, TEXT('')),
29300
 
          COALESCE(_i.cntct_suffix, TEXT('')), COALESCE(_i.cntct_phone, TEXT('')),
29301
 
          COALESCE(_i.cntct_title, TEXT('')), COALESCE(_i.cntct_fax, TEXT('')),
29302
 
          COALESCE(_i.cntct_email, TEXT('')), COALESCE(_i.addr_line1, TEXT('')),
29303
 
          COALESCE(_i.addr_line2, TEXT('')), COALESCE(_i.addr_line3, TEXT('')),
29304
 
          COALESCE(_i.addr_city, TEXT('')), COALESCE(_i.addr_state, TEXT('')),
29305
 
          COALESCE(_i.addr_postalcode, TEXT('')), COALESCE(_i.addr_country, TEXT('')) );
29306
 
    END IF;
29307
 
  END IF;
29308
 
 
29309
 
  SELECT NEXTVAL('poitem_poitem_id_seq') INTO _poitemid;
29310
 
 
29311
 
  SELECT (COALESCE(MAX(poitem_linenumber), 0) + 1) INTO _polinenumber
29312
 
  FROM poitem
29313
 
  WHERE (poitem_pohead_id = _poheadid);
29314
 
 
29315
 
  SELECT COALESCE(itemtax_taxtype_id, -1) INTO _taxtypeid
29316
 
  FROM itemtax
29317
 
  WHERE (itemtax_item_id = _i.itemsrc_item_id);
29318
 
 
29319
 
  IF (pPrice IS NULL) THEN
29320
 
    SELECT itemsrcPrice(pItemSourceId,
29321
 
                        COALESCE(_s.cohead_warehous_id, -1),
29322
 
                        pDropShip,
29323
 
                        (COALESCE(pQty, _s.orderqty) / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)),
29324
 
                        COALESCE(_i.vend_curr_id, baseCurrId()),
29325
 
                        CURRENT_DATE) INTO _price;
29326
 
  ELSE
29327
 
    _price := pPrice;
29328
 
  END IF;
29329
 
  raise notice '_price=%', _price;
29330
 
 
29331
 
  IF (pDropShip) THEN
29332
 
    INSERT INTO poitem
29333
 
      ( poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, 
29334
 
        poitem_duedate, poitem_itemsite_id,
29335
 
        poitem_vend_item_descrip, poitem_vend_uom,
29336
 
        poitem_invvenduomratio, poitem_qty_ordered, 
29337
 
        poitem_unitprice, poitem_vend_item_number, 
29338
 
        poitem_itemsrc_id, poitem_order_id, poitem_order_type, poitem_prj_id, poitem_stdcost, 
29339
 
        poitem_manuf_name, poitem_manuf_item_number, 
29340
 
        poitem_manuf_item_descrip, poitem_taxtype_id, poitem_comments )
29341
 
    VALUES
29342
 
      ( _poitemid, 'U', _poheadid, _polinenumber,
29343
 
        COALESCE(pDueDate, _s.coitem_scheddate), _s.coitem_itemsite_id,
29344
 
        COALESCE(_i.itemsrc_vend_item_descrip, TEXT('')), COALESCE(_i.itemsrc_vend_uom, TEXT('')),
29345
 
        COALESCE(_i.itemsrc_invvendoruomratio, 1.00), (COALESCE(pQty, _s.orderqty) / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)),
29346
 
        _price, COALESCE(_i.itemsrc_vend_item_number, TEXT('')),
29347
 
        pItemSourceId, pCoitemId, 'S', _s.cohead_prj_id, stdcost(_i.itemsrc_item_id),
29348
 
        COALESCE(_i.itemsrc_manuf_name, TEXT('')), COALESCE(_i.itemsrc_manuf_item_number, TEXT('')),
29349
 
        COALESCE(_i.itemsrc_manuf_item_descrip, TEXT('')), _taxtypeid,
29350
 
        COALESCE(_s.coitem_memo, TEXT('')));
29351
 
  ELSE
29352
 
    INSERT INTO poitem
29353
 
      ( poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, 
29354
 
        poitem_duedate, poitem_itemsite_id,
29355
 
        poitem_vend_item_descrip, poitem_vend_uom,
29356
 
        poitem_invvenduomratio, poitem_qty_ordered, 
29357
 
        poitem_unitprice, poitem_vend_item_number, 
29358
 
        poitem_itemsrc_id, poitem_order_id, poitem_order_type, poitem_prj_id, poitem_stdcost, 
29359
 
        poitem_manuf_name, poitem_manuf_item_number, 
29360
 
        poitem_manuf_item_descrip, poitem_taxtype_id, poitem_comments )
29361
 
    VALUES
29362
 
      ( _poitemid, 'U', _poheadid, _polinenumber,
29363
 
        COALESCE(pDueDate, _s.coitem_scheddate), _s.coitem_itemsite_id,
29364
 
        COALESCE(_i.itemsrc_vend_item_descrip, TEXT('')), COALESCE(_i.itemsrc_vend_uom, TEXT('')),
29365
 
        COALESCE(_i.itemsrc_invvendoruomratio, 1.00), (COALESCE(pQty, _s.orderqty) / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)),
29366
 
        _price, COALESCE(_i.itemsrc_vend_item_number, TEXT('')),
29367
 
        pItemSourceId, pCoitemId, 'S', _s.cohead_prj_id, stdcost(_i.itemsrc_item_id),
29368
 
        COALESCE(_i.itemsrc_manuf_name, TEXT('')), COALESCE(_i.itemsrc_manuf_item_number, TEXT('')),
29369
 
        COALESCE(_i.itemsrc_manuf_item_descrip, TEXT('')), _taxtypeid,
29370
 
        COALESCE(_s.coitem_memo, TEXT('')));
29371
 
  END IF;
29372
 
  -- Copy characteristics from the coitem to the poitem
29373
 
  INSERT INTO charass
29374
 
    ( charass_target_type, charass_target_id, charass_char_id,
29375
 
      charass_value, charass_default, charass_price )
29376
 
  SELECT 'PI', _poitemid, charass_char_id,
29377
 
         charass_value, charass_default, charass_price
29378
 
  FROM charass
29379
 
  WHERE ( (charass_target_type='SI')
29380
 
    AND   (charass_target_id=pCoitemId) );
29381
 
 
29382
 
  UPDATE coitem
29383
 
  SET coitem_order_type = 'P',
29384
 
      coitem_order_id = _poitemid
29385
 
  WHERE ( coitem_id = pCoitemId );
29386
 
 
29387
 
  -- Generate the PoItemCreatedBySo event notice
29388
 
  PERFORM postEvent('PoItemCreatedBySo', 'P', poitem_id,
29389
 
                    itemsite_warehous_id,
29390
 
                    (pohead_number || '-'|| poitem_linenumber || ': ' || item_number),
29391
 
                    NULL, NULL, NULL, NULL)
29392
 
  FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id)
29393
 
              JOIN itemsite ON (itemsite_id=poitem_itemsite_id)
29394
 
              JOIN item ON (item_id=itemsite_item_id)
29395
 
  WHERE (poitem_id=_poitemid)
29396
 
    AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence));
29397
 
 
29398
 
  RETURN _poitemid;
29399
 
 
29400
 
END;
29401
 
$_$;
29402
 
 
29403
 
 
29404
 
ALTER FUNCTION public.createpurchasetosale(integer, integer, boolean, numeric, date, numeric, integer) OWNER TO admin;
29405
 
 
29406
 
--
29407
 
--
29408
 
 
29409
 
CREATE FUNCTION createrecurringinvoices() RETURNS integer
29410
 
    LANGUAGE plpgsql
29411
 
    AS $$
29412
 
BEGIN
29413
 
  RAISE NOTICE 'createRecurringInvoices() has been deprecated; use createRecurringItems(NULL, ''I'') instead.';
29414
 
 
29415
 
  RETURN createRecurringItems(NULL, 'I');
29416
 
END;
29417
 
$$;
29418
 
 
29419
 
 
29420
 
ALTER FUNCTION public.createrecurringinvoices() OWNER TO admin;
29421
 
 
29422
 
--
29423
 
--
29424
 
 
29425
 
CREATE FUNCTION createrecurringitems(integer, text) RETURNS integer
29426
 
    LANGUAGE plpgsql
29427
 
    AS $_$
29428
 
DECLARE
29429
 
  pParentid  ALIAS FOR $1;      -- if NULL then all items with the given pType
29430
 
  pType      TEXT := UPPER($2); -- if NULL then all types
29431
 
                                -- if both are null then all items of all types
29432
 
  _copystmt  TEXT;
29433
 
  _count     INTEGER := 0;
29434
 
  _countstmt TEXT;
29435
 
  _existcnt  INTEGER;
29436
 
  _id        INTEGER;
29437
 
  _interval  TEXT;
29438
 
  _last      TIMESTAMP WITH TIME ZONE;
29439
 
  _loopcount INTEGER := 1;
29440
 
  _maxstmt   TEXT;
29441
 
  _maxdate   TIMESTAMP WITH TIME ZONE := endOfTime();
29442
 
  _result    INTEGER := 0;
29443
 
  _next      TIMESTAMP WITH TIME ZONE;
29444
 
  _r         RECORD;
29445
 
  _rt        RECORD;
29446
 
  _tmp       INTEGER;
29447
 
 
29448
 
BEGIN
29449
 
  RAISE DEBUG 'createRecurringItems(%, %) entered', pParentid, pType;
29450
 
 
29451
 
  FOR _r IN SELECT *
29452
 
              FROM recur
29453
 
             WHERE ((COALESCE(recur_end, endOfTime()) >= CURRENT_TIMESTAMP)
29454
 
                AND (pParentid IS NULL OR recur_parent_id=pParentid)
29455
 
                AND (pType IS NULL OR UPPER(recur_parent_type)=UPPER(pType))) LOOP
29456
 
 
29457
 
    RAISE DEBUG 'createRecurringItems looking at recur %, %',
29458
 
                _r.recur_id, _r.recur_parent_type;
29459
 
    _r.recur_max := COALESCE(_r.recur_max,
29460
 
                             CAST(fetchMetricValue('RecurringInvoiceBuffer') AS INTEGER),
29461
 
                             1);
29462
 
    _interval := CASE _r.recur_period WHEN 'Y' THEN ' year'
29463
 
                                      WHEN 'M' THEN ' month'
29464
 
                                      WHEN 'W' THEN ' week'
29465
 
                                      WHEN 'D' THEN ' day'
29466
 
                                      WHEN 'H' THEN ' hour'
29467
 
                                      WHEN 'm' THEN ' minute'
29468
 
                                      ELSE NULL
29469
 
                 END;
29470
 
 
29471
 
    IF (_interval IS NULL OR COALESCE(_r.recur_freq, 0) <= 0) THEN
29472
 
      RAISE EXCEPTION 'Unknown recurrence frequency % % ON % %',
29473
 
                      _r.recur_freq,        _r.recur_period,
29474
 
                      _r.recur_parent_type, _r.recur_parent_id;
29475
 
    END IF;
29476
 
 
29477
 
    SELECT * INTO _rt FROM recurtype WHERE (UPPER(recurtype_type)=UPPER(pType));
29478
 
    GET DIAGNOSTICS _count = ROW_COUNT;
29479
 
    IF (_count <= 0) THEN
29480
 
      RETURN -10;
29481
 
    END IF;
29482
 
 
29483
 
    -- if the recurrence type has a max lookahead window, use it
29484
 
    IF (_r.recur_parent_type = 'I') THEN
29485
 
      _maxdate := CURRENT_TIMESTAMP + CAST(fetchMetricText('RecurringInvoiceBuffer') || ' days' AS INTERVAL);
29486
 
    END IF;
29487
 
    IF (_r.recur_parent_type = 'V') THEN
29488
 
      _maxdate := CURRENT_TIMESTAMP + CAST(fetchMetricText('RecurringVoucherBuffer') || ' days' AS INTERVAL);
29489
 
    END IF;
29490
 
    IF (_maxdate > _r.recur_end) THEN   -- if recur_end is null, _maxdate is ok
29491
 
      _maxdate = _r.recur_end;
29492
 
    END IF;
29493
 
 
29494
 
    -- build statements dynamically from the recurtype table because packages
29495
 
    -- might also require recurring items. this way the algorithm is fixed
29496
 
    -- and the details are data-driven
29497
 
    _countstmt := 'SELECT COUNT(*) FROM [fulltable]' 
29498
 
               || ' WHERE (($1=[table]_recurring_[table]_id)'
29499
 
               || ' AND NOT([done]) '
29500
 
               || ' AND ([limit]));';
29501
 
    _countstmt := REPLACE(_countstmt, '[fulltable]', _rt.recurtype_table);
29502
 
    _countstmt := REPLACE(_countstmt, '[table]',
29503
 
                          REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', ''));
29504
 
    _countstmt := REPLACE(_countstmt, '[done]',  _rt.recurtype_donecheck);
29505
 
    _countstmt := REPLACE(_countstmt, '[limit]',
29506
 
                          COALESCE(_rt.recurtype_limit, 'TRUE'));
29507
 
 
29508
 
    _maxstmt := 'SELECT MAX([schedcol]) FROM [fulltable]'
29509
 
               || ' WHERE (($1=[table]_recurring_[table]_id)'
29510
 
               || '    AND ([limit]));';
29511
 
    _maxstmt := REPLACE(_maxstmt, '[schedcol]', _rt.recurtype_schedcol);
29512
 
    _maxstmt := REPLACE(_maxstmt, '[fulltable]',_rt.recurtype_table);
29513
 
    _maxstmt := REPLACE(_maxstmt, '[table]',
29514
 
                          REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', ''));
29515
 
    _maxstmt := REPLACE(_maxstmt, '[limit]', COALESCE(_rt.recurtype_limit,
29516
 
                                                     'TRUE'));
29517
 
 
29518
 
    _copystmt := 'SELECT [copy]($1, [datetime] [more]);';
29519
 
    _copystmt := REPLACE(_copystmt, '[copy]', _rt.recurtype_copyfunc);
29520
 
    _copystmt := REPLACE(_copystmt, '[datetime]',
29521
 
                         CASE WHEN UPPER(_rt.recurtype_copyargs[2])='DATE' THEN
29522
 
                                    'CAST(''$2'' AS DATE)'
29523
 
                              ELSE '''$2''' END);
29524
 
    -- 8.4+:
29525
 
    -- _copystmt := REPLACE(_copystmt, '[more]',
29526
 
    --                      REPEAT(', NULL',
29527
 
    --                             array_length(_rt.recurtype_copyargs) - 2));
29528
 
    _tmp := CAST(REPLACE(REGEXP_REPLACE(array_dims(_rt.recurtype_copyargs),
29529
 
                                        '.*:', ''), ']', '') AS INTEGER);
29530
 
    _copystmt := REPLACE(_copystmt, '[more]', REPEAT(', NULL', _tmp - 2));
29531
 
 
29532
 
    EXECUTE REPLACE(_countstmt, '$1', _r.recur_parent_id::TEXT) INTO _existcnt;
29533
 
    EXECUTE REPLACE(_maxstmt,   '$1', _r.recur_parent_id::TEXT) INTO _last;
29534
 
    RAISE DEBUG E'% got %, % got %', _countstmt, _existcnt, _maxstmt, _last;
29535
 
 
29536
 
    _next := _last;
29537
 
    _loopcount := 1;
29538
 
    WHILE (_existcnt < _r.recur_max AND _next < _maxdate) LOOP
29539
 
      _next := _last +
29540
 
               CAST(_r.recur_freq * _loopcount || _interval AS INTERVAL);
29541
 
      RAISE DEBUG 'createrecurringitems looping, existcnt = %, max = %, is % between % and %?',
29542
 
                  _existcnt, _r.recur_max, _next, _r.recur_start, _r.recur_end;
29543
 
 
29544
 
      IF (_next BETWEEN _r.recur_start AND _maxdate) THEN
29545
 
        RAISE DEBUG 'createrecurringitems executing % with % and %',
29546
 
                    _copystmt, _r.recur_parent_id, _next;
29547
 
        -- 8.4+: EXECUTE _copystmt INTO _id USING _r.recur_parent_id, _next;
29548
 
        EXECUTE REPLACE(REPLACE(_copystmt, '$1', _r.recur_parent_id::TEXT),
29549
 
                                           '$2', _next::TEXT) INTO _id;
29550
 
        RAISE DEBUG 'Copying for % returned %', _next, _id;
29551
 
        _result   := _result   + 1;
29552
 
        _existcnt := _existcnt + 1;
29553
 
      END IF;
29554
 
      _loopcount := _loopcount + 1;
29555
 
    END LOOP;
29556
 
  END LOOP;
29557
 
 
29558
 
  RETURN _result;
29559
 
END;
29560
 
$_$;
29561
 
 
29562
 
 
29563
 
ALTER FUNCTION public.createrecurringitems(integer, text) OWNER TO admin;
29564
 
 
29565
 
--
29566
 
--
29567
 
 
29568
 
CREATE FUNCTION createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text) RETURNS integer
29569
 
    LANGUAGE plpgsql
29570
 
    AS $_$  
29571
 
BEGIN
29572
 
  RETURN createTodoItem($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, NULL);
29573
 
END;
29574
 
$_$;
29575
 
 
29576
 
 
29577
 
ALTER FUNCTION public.createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text) OWNER TO admin;
29578
 
 
29579
 
--
29580
 
--
29581
 
 
29582
 
CREATE FUNCTION createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text, integer) RETURNS integer
29583
 
    LANGUAGE plpgsql
29584
 
    AS $_$
29585
 
DECLARE
29586
 
  ptodoid     ALIAS FOR  $1;
29587
 
  pusername   ALIAS FOR  $2;
29588
 
  pname       ALIAS FOR  $3;
29589
 
  pdesc       ALIAS FOR  $4;
29590
 
  pincdtid    ALIAS FOR  $5;
29591
 
  pcrmacctid  ALIAS FOR  $6;
29592
 
  pOpheadid   ALIAS FOR  $7;
29593
 
  pstarted    ALIAS FOR  $8;
29594
 
  pdue        ALIAS FOR  $9;
29595
 
  pstatus     ALIAS FOR $10;
29596
 
  passigned   ALIAS FOR $11;
29597
 
  pcompleted  ALIAS FOR $12;
29598
 
  ppriority   ALIAS FOR $13;
29599
 
  pnotes      ALIAS FOR $14;
29600
 
  powner      ALIAS FOR $15;
29601
 
  pcntctid    ALIAS FOR $16;
29602
 
 
29603
 
  _todoid     INTEGER;
29604
 
  _priority   INTEGER         := ppriority;
29605
 
  _status     CHARACTER(1)    := pstatus;
29606
 
  _incdtid    INTEGER         := pincdtid;
29607
 
  _crmacctid  INTEGER         := pcrmacctid;
29608
 
  _opheadid   INTEGER         := pOpheadid;
29609
 
  _assigned   DATE            := passigned;
29610
 
  _result     INTEGER;
29611
 
 
29612
 
BEGIN
29613
 
  IF (pusername IS NULL OR pusername = '') THEN
29614
 
    RETURN -1;
29615
 
  END IF;
29616
 
 
29617
 
  IF (pname IS NULL OR pname = '') THEN
29618
 
    RETURN -2;
29619
 
  END IF;
29620
 
 
29621
 
  IF (pdue IS NULL) THEN
29622
 
    RETURN -3;
29623
 
  END IF;
29624
 
 
29625
 
  IF (pcompleted IS NOT NULL) THEN
29626
 
    _status := 'C';
29627
 
  ELSIF (pstatus IS NULL AND pstarted IS NOT NULL) THEN
29628
 
    _status := 'I';
29629
 
  ELSIF (pstatus IS NULL) THEN
29630
 
    _status := 'N';
29631
 
  END IF;
29632
 
 
29633
 
  IF (_incdtid <= 0) THEN
29634
 
    _incdtid := NULL;
29635
 
  END IF;
29636
 
 
29637
 
  IF (_crmacctid <= 0) THEN
29638
 
    _crmacctid := NULL;
29639
 
  END IF;
29640
 
 
29641
 
  IF (_opheadid <= 0) THEN
29642
 
    _opheadid := NULL;
29643
 
  END IF;
29644
 
 
29645
 
  IF (_priority <= 0) THEN
29646
 
    _priority := NULL;
29647
 
  END IF;
29648
 
 
29649
 
  IF (_assigned IS NULL) THEN
29650
 
    _assigned := CURRENT_DATE;
29651
 
  END IF;
29652
 
 
29653
 
  IF (ptodoid IS NULL) THEN
29654
 
    SELECT NEXTVAL('todoitem_todoitem_id_seq') INTO _todoid;
29655
 
  ELSE
29656
 
    _todoid := ptodoid;
29657
 
  END IF;
29658
 
 
29659
 
  INSERT INTO todoitem ( todoitem_id, todoitem_username, todoitem_name,
29660
 
                         todoitem_description, todoitem_incdt_id,
29661
 
                         todoitem_creator_username, todoitem_status,
29662
 
                         todoitem_active, todoitem_start_date,
29663
 
                         todoitem_due_date, todoitem_assigned_date,
29664
 
                         todoitem_completed_date, todoitem_priority_id,
29665
 
                         todoitem_notes, todoitem_crmacct_id,
29666
 
                         todoitem_ophead_id, todoitem_owner_username,
29667
 
                         todoitem_cntct_id
29668
 
              ) VALUES ( _todoid, pusername, pname,
29669
 
                         pdesc, _incdtid,
29670
 
                         getEffectiveXtUser(), _status,
29671
 
                         TRUE, pstarted,
29672
 
                         pdue, _assigned,
29673
 
                         pcompleted, _priority, pnotes, _crmacctid, _opheadid, powner,
29674
 
                         pcntctid );
29675
 
 
29676
 
  RETURN _todoid;
29677
 
END;
29678
 
$_$;
29679
 
 
29680
 
 
29681
 
ALTER FUNCTION public.createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text, integer) OWNER TO admin;
29682
 
 
29683
 
--
29684
 
--
29685
 
 
29686
 
CREATE FUNCTION createurl(text, text) RETURNS integer
29687
 
    LANGUAGE plpgsql
29688
 
    AS $_$
29689
 
declare
29690
 
  pTitle ALIAS FOR $1;
29691
 
  pUrl ALIAS FOR $2;
29692
 
  _id integer;
29693
 
begin
29694
 
  _id := nextval('urlinfo_url_id_seq');
29695
 
  insert into urlinfo (url_id, url_title, url_url) values (_id, pTitle, pUrl);
29696
 
  return _id;
29697
 
end;
29698
 
$_$;
29699
 
 
29700
 
 
29701
 
ALTER FUNCTION public.createurl(text, text) OWNER TO admin;
29702
 
 
29703
 
--
29704
 
--
29705
 
 
29706
 
CREATE FUNCTION createuser(pusername text, pcreateusers boolean) RETURNS integer
29707
 
    LANGUAGE plpgsql
29708
 
    AS $$
29709
 
BEGIN
29710
 
  IF (pCreateUsers) THEN
29711
 
    EXECUTE 'CREATE USER "' || pUsername || '" CREATEROLE   IN GROUP xtrole;';
29712
 
  ELSE
29713
 
    EXECUTE 'CREATE USER "' || pUsername || '" NOCREATEROLE IN GROUP xtrole;';
29714
 
  END IF;
29715
 
  RETURN 1;
29716
 
END;
29717
 
$$;
29718
 
 
29719
 
 
29720
 
ALTER FUNCTION public.createuser(pusername text, pcreateusers boolean) OWNER TO admin;
29721
 
 
29722
 
--
29723
 
--
29724
 
 
29725
 
CREATE FUNCTION createwo(integer, integer, numeric, integer, date, text) RETURNS integer
29726
 
    LANGUAGE plpgsql
29727
 
    AS $_$
29728
 
DECLARE
29729
 
  pWoNumber ALIAS FOR $1;
29730
 
  pItemsiteid ALIAS FOR $2;
29731
 
  pQtyOrdered ALIAS FOR $3;
29732
 
  pLeadTime ALIAS FOR $4;
29733
 
  pDueDate ALIAS FOR $5;
29734
 
  pProductionNotes ALIAS FOR $6;
29735
 
 
29736
 
BEGIN
29737
 
  RETURN createWo( pWoNumber, pItemsiteid, 1, pQtyOrdered,
29738
 
                   (pDueDate - pLeadTime), pDueDate,
29739
 
                   pProductionNotes, NULL, NULL, -1 ); 
29740
 
END;
29741
 
$_$;
29742
 
 
29743
 
 
29744
 
ALTER FUNCTION public.createwo(integer, integer, numeric, integer, date, text) OWNER TO admin;
29745
 
 
29746
 
--
29747
 
--
29748
 
 
29749
 
CREATE FUNCTION createwo(integer, integer, numeric, date, date, text) RETURNS integer
29750
 
    LANGUAGE plpgsql
29751
 
    AS $_$
29752
 
DECLARE
29753
 
  pWoNumber ALIAS FOR $1;
29754
 
  pItemsiteid ALIAS FOR $2;
29755
 
  pQtyOrdered ALIAS FOR $3;
29756
 
  pStartDate ALIAS FOR $4;
29757
 
  pDueDate ALIAS FOR $5;
29758
 
  pProductionNotes ALIAS FOR $6;
29759
 
 
29760
 
BEGIN
29761
 
  RETURN createWo( pWoNumber, pItemsiteid, 1, pQtyOrdered,
29762
 
                   pStartDate, pDueDate, pProductionNotes, NULL, NULL, -1);
29763
 
END;
29764
 
$_$;
29765
 
 
29766
 
 
29767
 
ALTER FUNCTION public.createwo(integer, integer, numeric, date, date, text) OWNER TO admin;
29768
 
 
29769
 
--
29770
 
--
29771
 
 
29772
 
CREATE FUNCTION createwo(integer, integer, numeric, integer, date, text, character, integer) RETURNS integer
29773
 
    LANGUAGE plpgsql
29774
 
    AS $_$
29775
 
DECLARE
29776
 
  pWoNumber ALIAS FOR $1;
29777
 
  pItemsiteid ALIAS FOR $2;
29778
 
  pQtyOrdered ALIAS FOR $3;
29779
 
  pLeadTime ALIAS FOR $4;
29780
 
  pDueDate ALIAS FOR $5;
29781
 
  pProductionNotes ALIAS FOR $6;
29782
 
  pParentType ALIAS FOR $7;
29783
 
  pParentId ALIAS FOR $8;
29784
 
 
29785
 
BEGIN
29786
 
  RETURN createWo( pWoNumber, pItemsiteid, 1, pQtyOrdered,
29787
 
                   (pDueDate - pLeadTime), pDueDate,
29788
 
                   pProductionNotes, pParentType, pParentId, -1 ); 
29789
 
END;
29790
 
$_$;
29791
 
 
29792
 
 
29793
 
ALTER FUNCTION public.createwo(integer, integer, numeric, integer, date, text, character, integer) OWNER TO admin;
29794
 
 
29795
 
--
29796
 
--
29797
 
 
29798
 
CREATE FUNCTION createwo(integer, integer, integer, numeric, integer, date, text, character, integer) RETURNS integer
29799
 
    LANGUAGE plpgsql
29800
 
    AS $_$
29801
 
DECLARE
29802
 
  pWoNumber ALIAS FOR $1;
29803
 
  pItemsiteid ALIAS FOR $2;
29804
 
  pPriority ALIAS FOR $3;
29805
 
  pQtyOrdered ALIAS FOR $4;
29806
 
  pLeadTime ALIAS FOR $5;
29807
 
  pDueDate ALIAS FOR $6;
29808
 
  pProductionNotes ALIAS FOR $7;
29809
 
  pParentType ALIAS FOR $8;
29810
 
  pParentId ALIAS FOR $9;
29811
 
 
29812
 
BEGIN
29813
 
  RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered,
29814
 
                  (pDueDate - pLeadTime), pDueDate, pProductionNotes,
29815
 
                  pParentType, pParentId, -1);
29816
 
END;
29817
 
$_$;
29818
 
 
29819
 
 
29820
 
ALTER FUNCTION public.createwo(integer, integer, integer, numeric, integer, date, text, character, integer) OWNER TO admin;
29821
 
 
29822
 
--
29823
 
--
29824
 
 
29825
 
CREATE FUNCTION createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer) RETURNS integer
29826
 
    LANGUAGE plpgsql
29827
 
    AS $_$
29828
 
DECLARE
29829
 
  pWoNumber ALIAS FOR $1;
29830
 
  pItemsiteid ALIAS FOR $2;
29831
 
  pPriority ALIAS FOR $3;
29832
 
  pQtyOrdered ALIAS FOR $4;
29833
 
  pLeadTime ALIAS FOR $5;
29834
 
  pDueDate ALIAS FOR $6;
29835
 
  pProductionNotes ALIAS FOR $7;
29836
 
  pParentType ALIAS FOR $8;
29837
 
  pParentId ALIAS FOR $9;
29838
 
  pProjectId ALIAS FOR $10;
29839
 
 
29840
 
BEGIN
29841
 
  RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered,
29842
 
                  (pDueDate - pLeadTime), pDueDate, pProductionNotes,
29843
 
                  pParentType, pParentId, pProjectId);
29844
 
END;
29845
 
$_$;
29846
 
 
29847
 
 
29848
 
ALTER FUNCTION public.createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer) OWNER TO admin;
29849
 
 
29850
 
--
29851
 
--
29852
 
 
29853
 
CREATE FUNCTION createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer) RETURNS integer
29854
 
    LANGUAGE plpgsql
29855
 
    AS $_$
29856
 
DECLARE
29857
 
  pWoNumber ALIAS FOR $1;
29858
 
  pItemsiteid ALIAS FOR $2;
29859
 
  pPriority ALIAS FOR $3;
29860
 
  pQtyOrdered ALIAS FOR $4;
29861
 
  pStartDate ALIAS FOR $5;
29862
 
  pDueDate ALIAS FOR $6;
29863
 
  pProductionNotes ALIAS FOR $7;
29864
 
  pParentType ALIAS FOR $8;
29865
 
  pParentId ALIAS FOR $9;
29866
 
  pProjectId ALIAS FOR $10;
29867
 
  _woid INTEGER;
29868
 
  _result INTEGER;
29869
 
  _parentType char(1);
29870
 
  _bomrevid INTEGER;
29871
 
  _boorevid INTEGER;
29872
 
 
29873
 
BEGIN
29874
 
 
29875
 
  SELECT getActiveRevId('BOM',itemsite_item_id) INTO _bomrevid
29876
 
  FROM itemsite
29877
 
  WHERE (itemsite_id=pItemsiteid);
29878
 
 
29879
 
  SELECT getActiveRevId('BOO',itemsite_item_id) INTO _boorevid
29880
 
  FROM itemsite
29881
 
  WHERE (itemsite_id=pItemsiteid);
29882
 
  
29883
 
  RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered,
29884
 
                  pStartDate, pDueDate, pProductionNotes,
29885
 
                  pParentType, pParentId, pProjectId, _bomrevid, _boorevid, NULL);
29886
 
 
29887
 
END;
29888
 
$_$;
29889
 
 
29890
 
 
29891
 
ALTER FUNCTION public.createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer) OWNER TO admin;
29892
 
 
29893
 
--
29894
 
--
29895
 
 
29896
 
CREATE FUNCTION createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer, integer, integer) RETURNS integer
29897
 
    LANGUAGE plpgsql
29898
 
    AS $_$
29899
 
DECLARE
29900
 
  pWoNumber ALIAS FOR $1;
29901
 
  pItemsiteid ALIAS FOR $2;
29902
 
  pPriority ALIAS FOR $3;
29903
 
  pQtyOrdered ALIAS FOR $4;
29904
 
  pLeadTime ALIAS FOR $5;
29905
 
  pDueDate ALIAS FOR $6;
29906
 
  pProductionNotes ALIAS FOR $7;
29907
 
  pParentType ALIAS FOR $8;
29908
 
  pParentId ALIAS FOR $9;
29909
 
  pProjectId ALIAS FOR $10;
29910
 
  pBomRevId ALIAS FOR $11;
29911
 
  pBooRevId ALIAS FOR $12;
29912
 
 
29913
 
BEGIN
29914
 
  RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered,
29915
 
                  (pDueDate - pLeadTime), pDueDate, pProductionNotes,
29916
 
                  pParentType, pParentId, pProjectId, pBomRevId, pBooRevId, NULL);
29917
 
END;
29918
 
$_$;
29919
 
 
29920
 
 
29921
 
ALTER FUNCTION public.createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer, integer, integer) OWNER TO admin;
29922
 
 
29923
 
--
29924
 
--
29925
 
 
29926
 
CREATE FUNCTION createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer) RETURNS integer
29927
 
    LANGUAGE plpgsql
29928
 
    AS $_$
29929
 
DECLARE
29930
 
  pWoNumber ALIAS FOR $1;
29931
 
  pItemsiteid ALIAS FOR $2;
29932
 
  pPriority ALIAS FOR $3;
29933
 
  pQtyOrdered ALIAS FOR $4;
29934
 
  pStartDate ALIAS FOR $5;
29935
 
  pDueDate ALIAS FOR $6;
29936
 
  pProductionNotes ALIAS FOR $7;
29937
 
  pParentType ALIAS FOR $8;
29938
 
  pParentId ALIAS FOR $9;
29939
 
  pProjectId ALIAS FOR $10;
29940
 
  pBomRevId ALIAS FOR $11;
29941
 
  pBooRevId ALIAS FOR $12;
29942
 
BEGIN
29943
 
  RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered,
29944
 
                  pStartDate, pDueDate, pProductionNotes,
29945
 
                  pParentType, pParentId, pProjectId, pBomRevId, pBooRevId, NULL);
29946
 
END;
29947
 
$_$;
29948
 
 
29949
 
 
29950
 
ALTER FUNCTION public.createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer) OWNER TO admin;
29951
 
 
29952
 
--
29953
 
--
29954
 
 
29955
 
CREATE FUNCTION createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer, text) RETURNS integer
29956
 
    LANGUAGE plpgsql
29957
 
    AS $_$
29958
 
DECLARE
29959
 
  pWoNumber ALIAS FOR $1;
29960
 
  pItemsiteid ALIAS FOR $2;
29961
 
  pPriority ALIAS FOR $3;
29962
 
  pQtyOrdered ALIAS FOR $4;
29963
 
  pStartDate ALIAS FOR $5;
29964
 
  pDueDate ALIAS FOR $6;
29965
 
  pProductionNotes ALIAS FOR $7;
29966
 
  pParentType ALIAS FOR $8;
29967
 
  pParentId ALIAS FOR $9;
29968
 
  pProjectId ALIAS FOR $10;
29969
 
  pBomRevId ALIAS FOR $11;
29970
 
  pBooRevId ALIAS FOR $12;
29971
 
  pCosMethod ALIAS FOR $13;
29972
 
  _startDate DATE;
29973
 
  _woid INTEGER;
29974
 
  _result INTEGER;
29975
 
  _parentType char(1);
29976
 
  _parentId INTEGER;
29977
 
  _cosmethod char(1);
29978
 
  _itemsite RECORD;
29979
 
  
29980
 
BEGIN
29981
 
  
29982
 
  _parentType := COALESCE(pParentType, ' ');
29983
 
  _parentId   := COALESCE(pParentId, -1);
29984
 
 
29985
 
  SELECT * INTO _itemsite FROM itemsite WHERE itemsite_id = pItemsiteid;
29986
 
 
29987
 
  IF (NOT _itemsite.itemsite_wosupply) THEN
29988
 
    RETURN -1;
29989
 
  END IF;
29990
 
 
29991
 
  IF (pCosMethod IN ('D', 'P')) THEN
29992
 
    _cosmethod := pCosMethod;
29993
 
  ELSE
29994
 
    IF (_itemsite.itemsite_costmethod = 'J') THEN
29995
 
      IF (_parentType = ' ' OR _parentId = -1) THEN
29996
 
        RAISE EXCEPTION 'Work Orders for Item Sites that are Job cost must have a parent order.';
29997
 
      ELSE
29998
 
        SELECT COALESCE(itemsite_cosdefault,fetchmetrictext('JobItemCosDefault'),'D') INTO _cosmethod FROM itemsite WHERE itemsite_id=pItemsiteid;
29999
 
      END IF;
30000
 
    ELSIF (_itemsite.itemsite_costmethod = 'A') THEN
30001
 
      _cosmethod := COALESCE(_itemsite.itemsite_cosdefault,fetchmetrictext('JobItemCosDefault'),'D');
30002
 
    END IF;
30003
 
  END IF;
30004
 
 
30005
 
  IF (fetchmetricbool('UseSiteCalendar')) THEN
30006
 
    _startDate := calculatenextworkingdate(_itemsite.itemsite_warehous_id, pStartDate, 0);
30007
 
    IF (_startDate != pStartDate) THEN
30008
 
      _startDate := calculatenextworkingdate(_itemsite.itemsite_warehous_id, pDueDate, -_itemsite.itemsite_leadtime);
30009
 
    END IF;
30010
 
  ELSE
30011
 
    _startDate := pStartDate;
30012
 
  END IF;
30013
 
  
30014
 
  SELECT NEXTVAL('wo_wo_id_seq') INTO _woid;
30015
 
 
30016
 
  INSERT INTO wo
30017
 
  ( wo_id, wo_number, wo_subnumber, wo_itemsite_id,
30018
 
    wo_priority, wo_ordtype, wo_ordid,
30019
 
    wo_status, wo_startdate, wo_duedate,
30020
 
    wo_qtyord, wo_qtyrcv, wo_prodnotes, wo_prj_id,
30021
 
    wo_bom_rev_id, wo_boo_rev_id, wo_cosmethod )
30022
 
  SELECT _woid, pWoNumber, nextWoSubnumber(pWoNumber), itemsite_id,
30023
 
         pPriority, _parentType, pParentId,
30024
 
         'O', _startDate, pDueDate,
30025
 
         roundQty(item_fractional, pQtyOrdered), 0, pProductionNotes, pProjectId, 
30026
 
         pBomRevid, pBooRevid, _cosmethod
30027
 
  FROM itemsite, item
30028
 
  WHERE ((itemsite_item_id=item_id)
30029
 
   AND (itemsite_id=pItemsiteid));
30030
 
 
30031
 
  IF ( ( SELECT (metric_value='t')
30032
 
         FROM metric
30033
 
         WHERE (metric_name='AutoExplodeWO') ) ) THEN
30034
 
    SELECT explodeWo( _woid, ( SELECT (metric_value = 'M')
30035
 
                               FROM metric
30036
 
                               WHERE (metric_name='WOExplosionLevel') ) ) INTO _result;
30037
 
  ELSE
30038
 
    _result := _woid;
30039
 
  END IF;
30040
 
 
30041
 
  RETURN _result;
30042
 
 
30043
 
END;
30044
 
$_$;
30045
 
 
30046
 
 
30047
 
ALTER FUNCTION public.createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer, text) OWNER TO admin;
30048
 
 
30049
 
--
30050
 
--
30051
 
 
30052
 
CREATE FUNCTION createwomaterial(integer, integer, character, numeric, numeric) RETURNS integer
30053
 
    LANGUAGE plpgsql
30054
 
    AS $_$
30055
 
DECLARE
30056
 
  pWoid ALIAS FOR $1;
30057
 
  pItemsiteid ALIAS FOR $2;
30058
 
  pIssueMethod ALIAS FOR $3;
30059
 
  pQtyPer ALIAS FOR $4;
30060
 
  pScrap ALIAS FOR $5;
30061
 
  _result INTEGER;
30062
 
BEGIN
30063
 
  SELECT createWoMaterial(pWoid, pItemsiteid, pIssueMethod, item_inv_uom_id, pQtyPer, pScrap)
30064
 
    INTO _result
30065
 
    FROM itemsite JOIN item ON (itemsite_item_id=item_id)
30066
 
   WHERE(itemsite_id=pItemsiteid);
30067
 
  RETURN _result;
30068
 
END;
30069
 
$_$;
30070
 
 
30071
 
 
30072
 
ALTER FUNCTION public.createwomaterial(integer, integer, character, numeric, numeric) OWNER TO admin;
30073
 
 
30074
 
--
30075
 
--
30076
 
 
30077
 
CREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric) RETURNS integer
30078
 
    LANGUAGE plpgsql
30079
 
    AS $_$
30080
 
DECLARE
30081
 
  pWoid ALIAS FOR $1;
30082
 
  pItemsiteid ALIAS FOR $2;
30083
 
  pIssueMethod ALIAS FOR $3;
30084
 
  pUomId ALIAS FOR $4;
30085
 
  pQtyPer ALIAS FOR $5;
30086
 
  pScrap ALIAS FOR $6;
30087
 
  _womatlid INTEGER;
30088
 
 
30089
 
BEGIN
30090
 
 
30091
 
  SELECT createWoMaterial(pWoid,pItemsiteid,pIssueMethod,pUomId,pQtyPer,pScrap,-1, NULL, NULL) INTO _womatlid;
30092
 
 
30093
 
  RETURN _womatlid;
30094
 
END;
30095
 
$_$;
30096
 
 
30097
 
 
30098
 
ALTER FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric) OWNER TO admin;
30099
 
 
30100
 
--
30101
 
--
30102
 
 
30103
 
CREATE FUNCTION createwomaterial(integer, integer, character, numeric, numeric, numeric) RETURNS integer
30104
 
    LANGUAGE plpgsql
30105
 
    AS $_$
30106
 
DECLARE
30107
 
  pWoid ALIAS FOR $1;
30108
 
  pItemsiteid ALIAS FOR $2;
30109
 
  pIssueMethod ALIAS FOR $3;
30110
 
  pQtyFxd ALIAS FOR $4;
30111
 
  pQtyPer ALIAS FOR $5;
30112
 
  pScrap ALIAS FOR $6;
30113
 
  _result INTEGER;
30114
 
BEGIN
30115
 
  SELECT createWoMaterial(pWoid, pItemsiteid, pIssueMethod, item_inv_uom_id, pQtyFxd, pQtyPer, pScrap)
30116
 
    INTO _result
30117
 
    FROM itemsite JOIN item ON (itemsite_item_id=item_id)
30118
 
   WHERE(itemsite_id=pItemsiteid);
30119
 
  RETURN _result;
30120
 
END;
30121
 
$_$;
30122
 
 
30123
 
 
30124
 
ALTER FUNCTION public.createwomaterial(integer, integer, character, numeric, numeric, numeric) OWNER TO admin;
30125
 
 
30126
 
--
30127
 
--
30128
 
 
30129
 
CREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric, integer) RETURNS integer
30130
 
    LANGUAGE plpgsql
30131
 
    AS $_$
30132
 
DECLARE
30133
 
  pWoid ALIAS FOR $1;
30134
 
  pItemsiteid ALIAS FOR $2;
30135
 
  pIssueMethod ALIAS FOR $3;
30136
 
  pUomId ALIAS FOR $4;
30137
 
  pQtyPer ALIAS FOR $5;
30138
 
  pScrap ALIAS FOR $6;
30139
 
  pBomitemId ALIAS FOR $7;
30140
 
  _womatlid INTEGER;
30141
 
 
30142
 
BEGIN
30143
 
 
30144
 
  _womatlid := (SELECT NEXTVAL('womatl_womatl_id_seq'));
30145
 
 
30146
 
  INSERT INTO womatl
30147
 
  ( womatl_id, womatl_wo_id, womatl_itemsite_id,
30148
 
    womatl_issuemethod, womatl_uom_id, womatl_qtyper, womatl_scrap,
30149
 
    womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap,
30150
 
    womatl_wooper_id, womatl_bomitem_id, womatl_duedate )
30151
 
  SELECT _womatlid, wo_id, pItemsiteid,
30152
 
         pIssueMethod, pUomId, pQtyPer, pScrap,
30153
 
         roundQty(item_fractional, (wo_qtyord * (pQtyPer * (1 + pScrap)))), 0, 0,
30154
 
         -1, pBomitemId, wo_startdate
30155
 
  FROM wo, itemsite, item
30156
 
  WHERE ( (itemsite_item_id=item_id)
30157
 
   AND (wo_id=pWoid)
30158
 
   AND (itemsite_id=pItemsiteid) );
30159
 
 
30160
 
  UPDATE wo
30161
 
  SET wo_adhoc=TRUE
30162
 
  WHERE (wo_id=pWoid);
30163
 
 
30164
 
  UPDATE wo
30165
 
  SET wo_status='E'
30166
 
  WHERE ( (wo_status='O')
30167
 
   AND (wo_id=pWoid) );
30168
 
 
30169
 
  RETURN _womatlid;
30170
 
END;
30171
 
$_$;
30172
 
 
30173
 
 
30174
 
ALTER FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric, integer) OWNER TO admin;
30175
 
 
30176
 
--
30177
 
--
30178
 
 
30179
 
CREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric, numeric) RETURNS integer
30180
 
    LANGUAGE plpgsql
30181
 
    AS $_$
30182
 
DECLARE
30183
 
  pWoid ALIAS FOR $1;
30184
 
  pItemsiteid ALIAS FOR $2;
30185
 
  pIssueMethod ALIAS FOR $3;
30186
 
  pUomId ALIAS FOR $4;
30187
 
  pQtyFxd ALIAS FOR $5;
30188
 
  pQtyPer ALIAS FOR $6;
30189
 
  pScrap ALIAS FOR $7;
30190
 
  _womatlid INTEGER;
30191
 
 
30192
 
BEGIN
30193
 
 
30194
 
  SELECT createWoMaterial(pWoid,pItemsiteid,pIssueMethod,pUomId,pQtyFxd,pQtyPer,pScrap,-1, NULL, NULL) INTO _womatlid;
30195
 
 
30196
 
  RETURN _womatlid;
30197
 
END;
30198
 
$_$;
30199
 
 
30200
 
 
30201
 
ALTER FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric, numeric) OWNER TO admin;
30202
 
 
30203
 
--
30204
 
--
30205
 
 
30206
 
CREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric, integer, text, text) RETURNS integer
30207
 
    LANGUAGE plpgsql
30208
 
    AS $_$
30209
 
DECLARE
30210
 
  pWoid ALIAS FOR $1;
30211
 
  pItemsiteid ALIAS FOR $2;
30212
 
  pIssueMethod ALIAS FOR $3;
30213
 
  pUomId ALIAS FOR $4;
30214
 
  pQtyPer ALIAS FOR $5;
30215
 
  pScrap ALIAS FOR $6;
30216
 
  pBomitemId ALIAS FOR $7;
30217
 
  pNotes ALIAS FOR $8;
30218
 
  pRef ALIAS FOR $9;
30219
 
  _womatlid INTEGER;
30220
 
  _p RECORD;
30221
 
 
30222
 
BEGIN
30223
 
 
30224
 
  _womatlid := (SELECT NEXTVAL('womatl_womatl_id_seq'));
30225
 
 
30226
 
  INSERT INTO womatl
30227
 
  ( womatl_id, womatl_wo_id, womatl_itemsite_id,
30228
 
    womatl_issuemethod, womatl_uom_id, womatl_qtyper, womatl_scrap,
30229
 
    womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap,
30230
 
    womatl_wooper_id, womatl_bomitem_id, womatl_duedate, womatl_notes, womatl_ref )
30231
 
  SELECT _womatlid, wo_id, pItemsiteid,
30232
 
         pIssueMethod, pUomId, pQtyPer, pScrap,
30233
 
         roundQty(item_fractional, (wo_qtyord * (pQtyPer * (1 + pScrap)))), 0, 0,
30234
 
         -1, pBomitemId, wo_startdate, pNotes, pRef 
30235
 
  FROM wo, itemsite, item
30236
 
  WHERE ( (itemsite_item_id=item_id)
30237
 
   AND (wo_id=pWoid)
30238
 
   AND (itemsite_id=pItemsiteid) );
30239
 
 
30240
 
  WHILE ( ( SELECT COUNT(*)
30241
 
            FROM womatl, itemsite, item
30242
 
            WHERE ( (womatl_itemsite_id=itemsite_id)
30243
 
             AND (itemsite_item_id=item_id)
30244
 
             AND (womatl_wo_id=pWoid)
30245
 
             AND (item_type='F') ) ) > 0 ) LOOP
30246
 
 
30247
 
    FOR _p IN SELECT wo_qtyord, wo_startdate, womatl_id, womatl_wooper_id
30248
 
              FROM wo, womatl, itemsite, item
30249
 
              WHERE ( (womatl_itemsite_id=itemsite_id)
30250
 
               AND (itemsite_item_id=item_id)
30251
 
               AND (item_type='F')
30252
 
               AND (womatl_wo_id=wo_id)
30253
 
               AND (wo_id=pWoid) ) LOOP
30254
 
 
30255
 
      INSERT INTO womatl
30256
 
      ( womatl_wo_id, womatl_itemsite_id, womatl_wooper_id,
30257
 
        womatl_schedatwooper, womatl_duedate,
30258
 
        womatl_uom_id, womatl_qtyper, womatl_scrap,
30259
 
        womatl_qtyreq,
30260
 
        womatl_qtyiss, womatl_qtywipscrap,
30261
 
        womatl_lastissue, womatl_lastreturn,
30262
 
        womatl_cost, womatl_picklist, womatl_createwo,
30263
 
        womatl_issuemethod, womatl_notes, womatl_ref )
30264
 
      SELECT pWoid, cs.itemsite_id, _p.womatl_wooper_id,
30265
 
             womatl_schedatwooper, womatl_duedate,
30266
 
             bomitem_uom_id, (bomitem_qtyper * womatl_qtyper), bomitem_scrap,
30267
 
             roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), (_p.wo_qtyord * bomitem_qtyper * womatl_qtyper * (1 + bomitem_scrap))),
30268
 
             0, 0,
30269
 
             startOfTime(), startOfTime(),
30270
 
             0, ci.item_picklist, ( (ci.item_type='M') AND (bomitem_createwo) ),
30271
 
             bomitem_issuemethod, bomitem_notes, bomitem_ref 
30272
 
      FROM wo, womatl, bomitem, 
30273
 
           itemsite AS cs, itemsite AS ps,
30274
 
           item AS ci, item AS pi
30275
 
      WHERE ( (womatl_itemsite_id=ps.itemsite_id)
30276
 
       AND (womatl_wo_id=wo_id)
30277
 
       AND (bomitem_parent_item_id=pi.item_id)
30278
 
       AND (bomitem_item_id=ci.item_id)
30279
 
       AND (ps.itemsite_warehous_id=cs.itemsite_warehous_id)
30280
 
       AND (cs.itemsite_item_id=ci.item_id)
30281
 
       AND (ps.itemsite_item_id=pi.item_id)
30282
 
       AND (woEffectiveDate(_p.wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1))
30283
 
       AND (womatl_id=_p.womatl_id));
30284
 
 
30285
 
      DELETE FROM womatl
30286
 
      WHERE (womatl_id=_p.womatl_id);
30287
 
 
30288
 
    END LOOP;
30289
 
  END LOOP;
30290
 
 
30291
 
  UPDATE wo
30292
 
  SET wo_adhoc=TRUE
30293
 
  WHERE (wo_id=pWoid);
30294
 
 
30295
 
  UPDATE wo
30296
 
  SET wo_status='E'
30297
 
  WHERE ( (wo_status='O')
30298
 
   AND (wo_id=pWoid) );
30299
 
 
30300
 
  RETURN _womatlid;
30301
 
END;
30302
 
$_$;
30303
 
 
30304
 
 
30305
 
ALTER FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric, integer, text, text) OWNER TO admin;
30306
 
 
30307
 
--
30308
 
--
30309
 
 
30310
 
CREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric, numeric, integer, text, text) RETURNS integer
30311
 
    LANGUAGE plpgsql
30312
 
    AS $_$
30313
 
DECLARE
30314
 
  pWoid ALIAS FOR $1;
30315
 
  pItemsiteid ALIAS FOR $2;
30316
 
  pIssueMethod ALIAS FOR $3;
30317
 
  pUomId ALIAS FOR $4;
30318
 
  pQtyFxd ALIAS FOR $5;
30319
 
  pQtyPer ALIAS FOR $6;
30320
 
  pScrap ALIAS FOR $7;
30321
 
  pBomitemId ALIAS FOR $8;
30322
 
  pNotes ALIAS FOR $9;
30323
 
  pRef ALIAS FOR $10;
30324
 
  _womatlid INTEGER;
30325
 
 
30326
 
BEGIN
30327
 
 
30328
 
  SELECT createWoMaterial(pWoid,pItemsiteid,pIssueMethod,pUomId,pQtyFxd,pQtyPer,pScrap,pBomitemId,pNotes,pRef,NULL,NULL) INTO _womatlid;
30329
 
 
30330
 
  RETURN _womatlid;
30331
 
END;
30332
 
$_$;
30333
 
 
30334
 
 
30335
 
ALTER FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric, numeric, integer, text, text) OWNER TO admin;
30336
 
 
30337
 
--
30338
 
--
30339
 
 
30340
 
CREATE FUNCTION createwomaterial(pwoid integer, pitemsiteid integer, pissuemethod character, puomid integer, pqtyfxd numeric, pqtyper numeric, pscrap numeric, pbomitemid integer, pnotes text, pref text, pwooperid integer, ppicklist boolean) RETURNS integer
30341
 
    LANGUAGE plpgsql
30342
 
    AS $$
30343
 
DECLARE
30344
 
  _womatlid INTEGER;
30345
 
 
30346
 
BEGIN
30347
 
 
30348
 
  SELECT createWoMaterial(pWoid,
30349
 
                          pItemsiteid,
30350
 
                          pIssueMethod,
30351
 
                          pUomId,
30352
 
                          pQtyFxd,
30353
 
                          pQtyPer,
30354
 
                          pScrap,
30355
 
                          pBomitemId,
30356
 
                          pNotes,
30357
 
                          pRef,
30358
 
                          pWooperId,
30359
 
                          pPickList,
30360
 
                          0.0) INTO _womatlid;
30361
 
 
30362
 
  RETURN _womatlid;
30363
 
END;
30364
 
$$;
30365
 
 
30366
 
 
30367
 
ALTER FUNCTION public.createwomaterial(pwoid integer, pitemsiteid integer, pissuemethod character, puomid integer, pqtyfxd numeric, pqtyper numeric, pscrap numeric, pbomitemid integer, pnotes text, pref text, pwooperid integer, ppicklist boolean) OWNER TO admin;
30368
 
 
30369
 
--
30370
 
--
30371
 
 
30372
 
CREATE FUNCTION createwomaterial(pwoid integer, pitemsiteid integer, pissuemethod character, puomid integer, pqtyfxd numeric, pqtyper numeric, pscrap numeric, pbomitemid integer, pnotes text, pref text, pwooperid integer, ppicklist boolean, pprice numeric) RETURNS integer
30373
 
    LANGUAGE plpgsql
30374
 
    AS $$
30375
 
DECLARE
30376
 
  _womatlid INTEGER;
30377
 
  _p RECORD;
30378
 
 
30379
 
BEGIN
30380
 
 
30381
 
  _womatlid := (SELECT NEXTVAL('womatl_womatl_id_seq'));
30382
 
 
30383
 
  INSERT INTO womatl
30384
 
  ( womatl_id, womatl_wo_id, womatl_itemsite_id,
30385
 
    womatl_issuemethod, womatl_uom_id, womatl_qtyfxd,
30386
 
    womatl_qtyper, womatl_scrap, womatl_qtyreq,
30387
 
    womatl_qtyiss, womatl_qtywipscrap, womatl_wooper_id,
30388
 
    womatl_bomitem_id, womatl_duedate, womatl_notes,
30389
 
    womatl_ref, womatl_picklist, womatl_price )
30390
 
  SELECT _womatlid, wo_id, pItemsiteid,
30391
 
         pIssueMethod, pUomId, pQtyFxd,
30392
 
         pQtyPer, pScrap, roundQty(item_fractional, (pQtyFxd + wo_qtyord * pQtyPer) * (1 + pScrap) ),
30393
 
         0, 0, COALESCE(pWooperId, -1),
30394
 
         pBomitemId, wo_startdate, pNotes,
30395
 
         pRef, COALESCE(pPickList, item_picklist), pPrice 
30396
 
  FROM wo, itemsite JOIN item ON (item_id=itemsite_item_id)
30397
 
  WHERE ( (wo_id=pWoid)
30398
 
   AND (itemsite_id=pItemsiteid) );
30399
 
 
30400
 
  WHILE ( ( SELECT COUNT(*)
30401
 
            FROM womatl, itemsite, item
30402
 
            WHERE ( (womatl_itemsite_id=itemsite_id)
30403
 
             AND (itemsite_item_id=item_id)
30404
 
             AND (womatl_wo_id=pWoid)
30405
 
             AND (item_type='F') ) ) > 0 ) LOOP
30406
 
 
30407
 
    FOR _p IN SELECT wo_qtyord, wo_startdate, womatl_id, womatl_wooper_id
30408
 
              FROM wo, womatl, itemsite, item
30409
 
              WHERE ( (womatl_itemsite_id=itemsite_id)
30410
 
               AND (itemsite_item_id=item_id)
30411
 
               AND (item_type='F')
30412
 
               AND (womatl_wo_id=wo_id)
30413
 
               AND (wo_id=pWoid) ) LOOP
30414
 
 
30415
 
      INSERT INTO womatl
30416
 
      ( womatl_wo_id, womatl_itemsite_id, womatl_wooper_id,
30417
 
        womatl_schedatwooper, womatl_duedate,
30418
 
        womatl_uom_id, womatl_qtyfxd, womatl_qtyper, womatl_scrap,
30419
 
        womatl_qtyreq,
30420
 
        womatl_qtyiss, womatl_qtywipscrap,
30421
 
        womatl_lastissue, womatl_lastreturn,
30422
 
        womatl_cost, womatl_picklist, womatl_createwo,
30423
 
        womatl_issuemethod, womatl_notes, womatl_ref )
30424
 
      SELECT pWoid, cs.itemsite_id, _p.womatl_wooper_id,
30425
 
             womatl_schedatwooper, womatl_duedate,
30426
 
             bomitem_uom_id, bomitem_qtyfxd, (bomitem_qtyper * womatl_qtyper), bomitem_scrap,
30427
 
             roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), 
30428
 
                     ((bomitem_qtyfxd + _p.wo_qtyord * bomitem_qtyper) * womatl_qtyper * (1 + bomitem_scrap))),
30429
 
             0, 0,
30430
 
             startOfTime(), startOfTime(),
30431
 
             0, ci.item_picklist, ( (ci.item_type='M') AND (bomitem_createwo) ),
30432
 
             bomitem_issuemethod, bomitem_notes, bomitem_ref 
30433
 
      FROM wo, womatl, bomitem, 
30434
 
           itemsite AS cs, itemsite AS ps,
30435
 
           item AS ci, item AS pi
30436
 
      WHERE ( (womatl_itemsite_id=ps.itemsite_id)
30437
 
       AND (womatl_wo_id=wo_id)
30438
 
       AND (bomitem_parent_item_id=pi.item_id)
30439
 
       AND (bomitem_item_id=ci.item_id)
30440
 
       AND (ps.itemsite_warehous_id=cs.itemsite_warehous_id)
30441
 
       AND (cs.itemsite_item_id=ci.item_id)
30442
 
       AND (ps.itemsite_item_id=pi.item_id)
30443
 
       AND (woEffectiveDate(_p.wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1))
30444
 
       AND (womatl_id=_p.womatl_id));
30445
 
 
30446
 
      DELETE FROM womatl
30447
 
      WHERE (womatl_id=_p.womatl_id);
30448
 
 
30449
 
    END LOOP;
30450
 
  END LOOP;
30451
 
 
30452
 
  UPDATE wo
30453
 
  SET wo_adhoc=TRUE
30454
 
  WHERE (wo_id=pWoid);
30455
 
 
30456
 
  UPDATE wo
30457
 
  SET wo_status='E'
30458
 
  WHERE ( (wo_status='O')
30459
 
   AND (wo_id=pWoid) );
30460
 
 
30461
 
  RETURN _womatlid;
30462
 
END;
30463
 
$$;
30464
 
 
30465
 
 
30466
 
ALTER FUNCTION public.createwomaterial(pwoid integer, pitemsiteid integer, pissuemethod character, puomid integer, pqtyfxd numeric, pqtyper numeric, pscrap numeric, pbomitemid integer, pnotes text, pref text, pwooperid integer, ppicklist boolean, pprice numeric) OWNER TO admin;
30467
 
 
30468
 
--
30469
 
--
30470
 
 
30471
 
CREATE FUNCTION creditmemototal(integer) RETURNS numeric
30472
 
    LANGUAGE plpgsql
30473
 
    AS $_$
30474
 
DECLARE
30475
 
  pCreditmemoId ALIAS FOR $1;
30476
 
  _result       NUMERIC;
30477
 
 
30478
 
BEGIN
30479
 
 
30480
 
  -- TO DO:  Add in line item taxes
30481
 
  SELECT COALESCE(cmhead_freight,0.0) + COALESCE(cmhead_misc,0.0) +
30482
 
         ( SELECT COALESCE(ROUND(SUM((cmitem_qtycredit * cmitem_qty_invuomratio) * cmitem_unitprice / cmitem_price_invuomratio), 2), 0.0)
30483
 
             FROM cmitem
30484
 
            WHERE (cmitem_cmhead_id=cmhead_id)
30485
 
           ) +
30486
 
         (SELECT COALESCE(SUM(tax) * -1, 0) AS tax
30487
 
           FROM ( SELECT ROUND(SUM(taxdetail_tax),2) AS tax
30488
 
                  FROM tax
30489
 
                  JOIN calculateTaxDetailSummary('CM', cmhead_id, 'T') ON (taxdetail_tax_id=tax_id)
30490
 
                  GROUP BY tax_id) AS data)
30491
 
           INTO _result
30492
 
  FROM cmhead
30493
 
  WHERE (cmhead_id=pCreditmemoId);
30494
 
 
30495
 
  IF (NOT FOUND) THEN
30496
 
    return 0;
30497
 
  ELSE
30498
 
    RETURN _result;
30499
 
  END IF;
30500
 
 
30501
 
END;
30502
 
$_$;
30503
 
 
30504
 
 
30505
 
ALTER FUNCTION public.creditmemototal(integer) OWNER TO admin;
30506
 
 
30507
 
--
30508
 
--
30509
 
 
30510
 
CREATE TABLE crmacct (
30511
 
    crmacct_id integer NOT NULL,
30512
 
    crmacct_number text NOT NULL,
30513
 
    crmacct_name text,
30514
 
    crmacct_active boolean DEFAULT true,
30515
 
    crmacct_type character(1),
30516
 
    crmacct_cust_id integer,
30517
 
    crmacct_competitor_id integer,
30518
 
    crmacct_partner_id integer,
30519
 
    crmacct_prospect_id integer,
30520
 
    crmacct_vend_id integer,
30521
 
    crmacct_cntct_id_1 integer,
30522
 
    crmacct_cntct_id_2 integer,
30523
 
    crmacct_parent_id integer,
30524
 
    crmacct_notes text,
30525
 
    crmacct_taxauth_id integer,
30526
 
    crmacct_owner_username text,
30527
 
    crmacct_emp_id integer,
30528
 
    crmacct_salesrep_id integer,
30529
 
    crmacct_usr_username text,
30530
 
    CONSTRAINT crmacct_crmacct_number_check CHECK ((crmacct_number <> ''::text)),
30531
 
    CONSTRAINT crmacct_crmacct_type_check CHECK ((crmacct_type = ANY (ARRAY['I'::bpchar, 'O'::bpchar]))),
30532
 
    CONSTRAINT crmacct_crmacct_usr_username_check CHECK ((btrim(crmacct_usr_username) <> ''::text)),
30533
 
    CONSTRAINT crmacct_owner_username_check CHECK ((btrim(crmacct_owner_username) <> ''::text))
30534
 
);
30535
 
 
30536
 
 
30537
 
ALTER TABLE public.crmacct OWNER TO admin;
30538
 
 
30539
 
--
30540
 
--
30541
 
 
30542
 
COMMENT ON TABLE crmacct IS 'CRM Accounts are umbrella records that tie together people and organizations with whom we have business relationships.';
30543
 
 
30544
 
 
30545
 
--
30546
 
--
30547
 
 
30548
 
COMMENT ON COLUMN crmacct.crmacct_id IS 'Internal ID of this CRM Account.';
30549
 
 
30550
 
 
30551
 
--
30552
 
--
30553
 
 
30554
 
COMMENT ON COLUMN crmacct.crmacct_number IS 'Abbreviated human-readable identifier for this CRM Account.';
30555
 
 
30556
 
 
30557
 
--
30558
 
--
30559
 
 
30560
 
COMMENT ON COLUMN crmacct.crmacct_name IS 'Long name of this CRM Account.';
30561
 
 
30562
 
 
30563
 
--
30564
 
--
30565
 
 
30566
 
COMMENT ON COLUMN crmacct.crmacct_active IS 'This CRM Account is available for new activity.';
30567
 
 
30568
 
 
30569
 
--
30570
 
--
30571
 
 
30572
 
COMMENT ON COLUMN crmacct.crmacct_type IS 'This indicates whether the CRM Account represents an organization or an individual person.';
30573
 
 
30574
 
 
30575
 
--
30576
 
--
30577
 
 
30578
 
COMMENT ON COLUMN crmacct.crmacct_cust_id IS 'If this is not null, this CRM Account is a Customer.';
30579
 
 
30580
 
 
30581
 
--
30582
 
--
30583
 
 
30584
 
COMMENT ON COLUMN crmacct.crmacct_competitor_id IS 'For now, > 0 indicates this CRM Account is a competitor. Eventually this may become a foreign key to a table of competitors.';
30585
 
 
30586
 
 
30587
 
--
30588
 
--
30589
 
 
30590
 
COMMENT ON COLUMN crmacct.crmacct_partner_id IS 'For now, > 0 indicates this CRM Account is a partner. Eventually this may become a foreign key to a table of partners.';
30591
 
 
30592
 
 
30593
 
--
30594
 
--
30595
 
 
30596
 
COMMENT ON COLUMN crmacct.crmacct_prospect_id IS 'If this is not null, this CRM Account is a Prospect.';
30597
 
 
30598
 
 
30599
 
--
30600
 
--
30601
 
 
30602
 
COMMENT ON COLUMN crmacct.crmacct_vend_id IS 'If this is not null, this CRM Account is a Vendor.';
30603
 
 
30604
 
 
30605
 
--
30606
 
--
30607
 
 
30608
 
COMMENT ON COLUMN crmacct.crmacct_cntct_id_1 IS 'The primary contact for the CRM Account.';
30609
 
 
30610
 
 
30611
 
--
30612
 
--
30613
 
 
30614
 
COMMENT ON COLUMN crmacct.crmacct_cntct_id_2 IS 'The secondary contact for the CRM Account.';
30615
 
 
30616
 
 
30617
 
--
30618
 
--
30619
 
 
30620
 
COMMENT ON COLUMN crmacct.crmacct_parent_id IS 'The internal ID of an (optional) parent CRM Account. For example, if the current CRM Account is a subsidiary of another company, the crmacct_parent_id points to the CRM Account representing that parent company.';
30621
 
 
30622
 
 
30623
 
--
30624
 
--
30625
 
 
30626
 
COMMENT ON COLUMN crmacct.crmacct_notes IS 'Free-form comments pertaining to the CRM Account.';
30627
 
 
30628
 
 
30629
 
--
30630
 
--
30631
 
 
30632
 
COMMENT ON COLUMN crmacct.crmacct_taxauth_id IS 'If this is not null, this CRM Account is a Tax Authority.';
30633
 
 
30634
 
 
30635
 
--
30636
 
--
30637
 
 
30638
 
COMMENT ON COLUMN crmacct.crmacct_owner_username IS 'The application User responsible for this CRM Account.';
30639
 
 
30640
 
 
30641
 
--
30642
 
--
30643
 
 
30644
 
COMMENT ON COLUMN crmacct.crmacct_emp_id IS 'If this is not null, this CRM Account is an Employee.';
30645
 
 
30646
 
 
30647
 
--
30648
 
--
30649
 
 
30650
 
COMMENT ON COLUMN crmacct.crmacct_salesrep_id IS 'If this is not null, this CRM Account is a Sales Rep.';
30651
 
 
30652
 
 
30653
 
--
30654
 
--
30655
 
 
30656
 
COMMENT ON COLUMN crmacct.crmacct_usr_username IS 'If this is not null, this CRM Account is an application User.';
30657
 
 
30658
 
 
30659
 
--
30660
 
--
30661
 
 
30662
 
CREATE FUNCTION crmacct() RETURNS SETOF crmacct
30663
 
    LANGUAGE plpgsql
30664
 
    AS $$
30665
 
DECLARE
30666
 
  _row crmacct%ROWTYPE;
30667
 
  _priv TEXT;
30668
 
  _grant BOOLEAN;
30669
 
 
30670
 
BEGIN
30671
 
  -- This query will give us the most permissive privilege the user has been granted
30672
 
  SELECT privilege, granted INTO _priv, _grant
30673
 
  FROM privgranted 
30674
 
  WHERE privilege IN ('MaintainAllCRMAccounts','ViewAllCRMAccounts','MaintainPersonalCRMAccounts','ViewPersonalCRMAccounts')
30675
 
  ORDER BY granted DESC, sequence
30676
 
  LIMIT 1;
30677
 
 
30678
 
  -- If have an 'All' privilege return all results
30679
 
  IF (_priv ~ 'All' AND _grant) THEN
30680
 
    FOR _row IN 
30681
 
      SELECT * FROM crmacct
30682
 
    LOOP
30683
 
      RETURN NEXT _row;
30684
 
    END LOOP;
30685
 
  -- Otherwise if have any other grant, must be personal privilege.
30686
 
  ELSIF (_grant) THEN
30687
 
    FOR _row IN 
30688
 
      SELECT * FROM crmacct 
30689
 
      WHERE crmacct_owner_username = getEffectiveXtUser()
30690
 
    LOOP
30691
 
      RETURN NEXT _row;
30692
 
    END LOOP;
30693
 
  END IF;
30694
 
 
30695
 
  RETURN;
30696
 
 
30697
 
END;
30698
 
$$;
30699
 
 
30700
 
 
30701
 
ALTER FUNCTION public.crmacct() OWNER TO admin;
30702
 
 
30703
 
--
30704
 
--
30705
 
 
30706
 
COMMENT ON FUNCTION crmacct() IS 'A table function that returns CRM Account results according to privilege settings.';
30707
 
 
30708
 
 
30709
 
--
30710
 
--
30711
 
 
30712
 
CREATE FUNCTION crypt(text, text) RETURNS text
30713
 
    LANGUAGE c IMMUTABLE STRICT
30714
 
    AS '$libdir/pgcrypto', 'pg_crypt';
30715
 
 
30716
 
 
30717
 
ALTER FUNCTION public.crypt(text, text) OWNER TO admin;
30718
 
 
30719
 
--
30720
 
--
30721
 
 
30722
 
CREATE FUNCTION currconcat(integer) RETURNS character varying
30723
 
    LANGUAGE plpgsql
30724
 
    AS $_$
30725
 
DECLARE
30726
 
  id ALIAS FOR $1;
30727
 
  returnVal   VARCHAR(15) := '';
30728
 
BEGIN
30729
 
  SELECT currConcat(curr_abbr, curr_symbol) INTO returnVal
30730
 
      FROM curr_symbol WHERE curr_id = id;
30731
 
  RETURN returnVal;
30732
 
END;
30733
 
$_$;
30734
 
 
30735
 
 
30736
 
ALTER FUNCTION public.currconcat(integer) OWNER TO admin;
30737
 
 
30738
 
--
30739
 
--
30740
 
 
30741
 
CREATE FUNCTION currconcat(character varying, character varying) RETURNS character varying
30742
 
    LANGUAGE plpgsql
30743
 
    AS $_$
30744
 
DECLARE
30745
 
  curr_abbr   ALIAS FOR $1;
30746
 
  curr_symbol ALIAS FOR $2;
30747
 
  returnVal   VARCHAR(15) := '';
30748
 
BEGIN
30749
 
  IF length(trim(curr_abbr)) > 0 AND length(trim(curr_symbol)) > 0 THEN
30750
 
      returnVal := trim(curr_abbr) || ' - ' || trim(curr_symbol);
30751
 
 
30752
 
  ELSIF length(trim(curr_abbr)) > 0 THEN
30753
 
      returnVal := curr_abbr;
30754
 
 
30755
 
  ELSIF length(trim(curr_symbol)) > 0 THEN
30756
 
      returnVal := curr_symbol;
30757
 
  END IF;
30758
 
 
30759
 
  RETURN returnVal;
30760
 
END;
30761
 
$_$;
30762
 
 
30763
 
 
30764
 
ALTER FUNCTION public.currconcat(character varying, character varying) OWNER TO admin;
30765
 
 
30766
 
--
30767
 
--
30768
 
 
30769
 
CREATE FUNCTION currentapmemonumber() RETURNS integer
30770
 
    LANGUAGE plpgsql
30771
 
    AS $$
30772
 
DECLARE
30773
 
  _number INTEGER;
30774
 
 
30775
 
BEGIN
30776
 
 
30777
 
  SELECT orderseq_number INTO _number
30778
 
  FROM orderseq
30779
 
  WHERE (orderseq_name='APMemoNumber');
30780
 
  IF (NOT FOUND) THEN
30781
 
    _number := 0;
30782
 
  END IF;
30783
 
 
30784
 
  RETURN _number;
30785
 
 
30786
 
END;
30787
 
$$;
30788
 
 
30789
 
 
30790
 
ALTER FUNCTION public.currentapmemonumber() OWNER TO admin;
30791
 
 
30792
 
--
30793
 
--
30794
 
 
30795
 
CREATE FUNCTION currentarmemonumber() RETURNS integer
30796
 
    LANGUAGE plpgsql
30797
 
    AS $$
30798
 
DECLARE
30799
 
  _number INTEGER;
30800
 
 
30801
 
BEGIN
30802
 
 
30803
 
  SELECT orderseq_number INTO _number
30804
 
  FROM orderseq
30805
 
  WHERE (orderseq_name='ARMemoNumber');
30806
 
  IF (NOT FOUND) THEN
30807
 
    _number := 0;
30808
 
  END IF;
30809
 
 
30810
 
  RETURN _number;
30811
 
 
30812
 
END;
30813
 
$$;
30814
 
 
30815
 
 
30816
 
ALTER FUNCTION public.currentarmemonumber() OWNER TO admin;
30817
 
 
30818
 
--
30819
 
--
30820
 
 
30821
 
CREATE FUNCTION currentcashrcptnumber() RETURNS integer
30822
 
    LANGUAGE plpgsql
30823
 
    AS $$
30824
 
DECLARE
30825
 
  _number INTEGER;
30826
 
 
30827
 
BEGIN
30828
 
 
30829
 
  SELECT orderseq_number INTO _number
30830
 
  FROM orderseq
30831
 
  WHERE (orderseq_name='CashRcptNumber');
30832
 
  IF (NOT FOUND) THEN
30833
 
    _number := 0;
30834
 
  END IF;
30835
 
 
30836
 
  RETURN _number;
30837
 
 
30838
 
END;
30839
 
$$;
30840
 
 
30841
 
 
30842
 
ALTER FUNCTION public.currentcashrcptnumber() OWNER TO admin;
30843
 
 
30844
 
--
30845
 
--
30846
 
 
30847
 
CREATE FUNCTION currentnumber(text) RETURNS integer
30848
 
    LANGUAGE plpgsql
30849
 
    AS $_$
30850
 
DECLARE
30851
 
  pName   ALIAS FOR $1;
30852
 
  _number INTEGER;
30853
 
 
30854
 
BEGIN
30855
 
  SELECT orderseq_number INTO _number
30856
 
  FROM orderseq
30857
 
  WHERE (orderseq_name=pName);
30858
 
  IF (NOT FOUND) THEN
30859
 
    _number := 0;
30860
 
  END IF;
30861
 
 
30862
 
  RETURN _number;
30863
 
 
30864
 
END;
30865
 
$_$;
30866
 
 
30867
 
 
30868
 
ALTER FUNCTION public.currentnumber(text) OWNER TO admin;
30869
 
 
30870
 
--
30871
 
--
30872
 
 
30873
 
CREATE FUNCTION currexchangecheckoverlap() RETURNS trigger
30874
 
    LANGUAGE plpgsql
30875
 
    AS $$
30876
 
DECLARE
30877
 
    numberOfOverlaps INTEGER NOT NULL := 0;
30878
 
    curr_string VARCHAR(16);
30879
 
    new_id INTEGER;
30880
 
BEGIN
30881
 
  new_id := NEW.curr_id;
30882
 
  -- ensure that effective date <= expiration date
30883
 
  IF NEW.curr_effective > NEW.curr_expires THEN
30884
 
    RAISE EXCEPTION
30885
 
      'Effective date % must be earlier than expiration date %',
30886
 
      NEW.curr_effective, NEW.curr_expires;
30887
 
  END IF;
30888
 
 
30889
 
  -- ensure new exchange rate does not overlap in time with any others
30890
 
  SELECT count(*) INTO numberOfOverlaps
30891
 
    FROM curr_rate
30892
 
    WHERE curr_id = NEW.curr_id
30893
 
      AND curr_rate_id != NEW.curr_rate_id
30894
 
      AND (
30895
 
          (curr_effective BETWEEN
30896
 
              NEW.curr_effective AND NEW.curr_expires OR
30897
 
           curr_expires BETWEEN
30898
 
              NEW.curr_effective AND NEW.curr_expires)
30899
 
         OR (curr_effective <= NEW.curr_effective AND
30900
 
             curr_expires   >= NEW.curr_expires)
30901
 
      );
30902
 
  IF numberOfOverlaps > 0 THEN
30903
 
    SELECT currConcat(curr_symbol, curr_abbr)
30904
 
      INTO curr_string
30905
 
      FROM curr_symbol
30906
 
      WHERE curr_id = new_id;
30907
 
    RAISE EXCEPTION
30908
 
      'The date range % to % overlaps with another date range.',
30909
 
      NEW.curr_effective, NEW.curr_expires;
30910
 
  END IF;
30911
 
  RETURN NEW;
30912
 
END;
30913
 
$$;
30914
 
 
30915
 
 
30916
 
ALTER FUNCTION public.currexchangecheckoverlap() OWNER TO admin;
30917
 
 
30918
 
--
30919
 
--
30920
 
 
30921
 
CREATE FUNCTION currgain(integer, numeric, date, date) RETURNS numeric
30922
 
    LANGUAGE plpgsql
30923
 
    AS $_$
30924
 
DECLARE
30925
 
  pId ALIAS FOR $1;
30926
 
  pValue ALIAS FOR $2;
30927
 
  pStart ALIAS FOR $3;
30928
 
  pEnd ALIAS FOR $4;
30929
 
  _start DATE;
30930
 
  _end DATE;
30931
 
  _gain NUMERIC;
30932
 
  _multiplier   INTEGER := 1;
30933
 
 
30934
 
BEGIN
30935
 
  IF (pEnd = pStart OR pValue = 0) THEN
30936
 
    RETURN 0;
30937
 
  END IF;
30938
 
 
30939
 
  IF (pStart > pEnd) THEN
30940
 
    _start := pEnd;
30941
 
    _end   := pStart;
30942
 
    _multiplier := -1;
30943
 
  ELSE
30944
 
    _start := pStart;
30945
 
    _end := pEnd;
30946
 
  END IF;
30947
 
 
30948
 
  _gain := currToBase(pId, pValue, _start) - currToBase(pId, pValue, _end);
30949
 
  IF (_gain IS NULL) THEN
30950
 
    RAISE EXCEPTION 'Missing exchange rate for curr_id % on % or %',
30951
 
                    pId, _start, _end;
30952
 
  END IF;
30953
 
 
30954
 
  RETURN _gain * _multiplier;
30955
 
END;
30956
 
$_$;
30957
 
 
30958
 
 
30959
 
ALTER FUNCTION public.currgain(integer, numeric, date, date) OWNER TO admin;
30960
 
 
30961
 
--
30962
 
--
30963
 
 
30964
 
CREATE FUNCTION curronebase() RETURNS trigger
30965
 
    LANGUAGE plpgsql
30966
 
    AS $$
30967
 
DECLARE
30968
 
  baseCount INTEGER := 0;
30969
 
BEGIN
30970
 
  IF NEW.curr_base = TRUE THEN
30971
 
    SELECT count(*)
30972
 
      INTO baseCount
30973
 
      FROM curr_symbol
30974
 
      WHERE curr_base = TRUE
30975
 
        AND curr_id != NEW.curr_id;
30976
 
    IF baseCount > 0 THEN
30977
 
      RAISE EXCEPTION
30978
 
          'Cannot make % - % the base currency because one is already defined.',
30979
 
          NEW.curr_symbol, NEW.curr_abbr;
30980
 
    ELSE
30981
 
      SELECT count(*)
30982
 
        INTO baseCount
30983
 
        FROM curr_rate
30984
 
        WHERE curr_id = NEW.curr_id;
30985
 
      IF baseCount = 0 THEN
30986
 
        -- put a row in the curr_rate table to avoid special-case
30987
 
        -- code for converting base currency to base currency
30988
 
        INSERT INTO curr_rate
30989
 
          (curr_id, curr_rate, curr_effective, curr_expires) VALUES
30990
 
          (NEW.curr_id, 1, startOfTime(), endOfTime());
30991
 
      END IF;
30992
 
    END IF;
30993
 
  END IF;
30994
 
  RETURN NEW;
30995
 
END;
30996
 
$$;
30997
 
 
30998
 
 
30999
 
ALTER FUNCTION public.curronebase() OWNER TO admin;
31000
 
 
31001
 
--
31002
 
--
31003
 
 
31004
 
CREATE FUNCTION currrate(integer, date) RETURNS numeric
31005
 
    LANGUAGE plpgsql STABLE
31006
 
    AS $_$
31007
 
BEGIN
31008
 
  RETURN currRate($1, NULL, $2);
31009
 
 
31010
 
END;
31011
 
$_$;
31012
 
 
31013
 
 
31014
 
ALTER FUNCTION public.currrate(integer, date) OWNER TO admin;
31015
 
 
31016
 
--
31017
 
--
31018
 
 
31019
 
CREATE FUNCTION currrate(pfromcurr integer, ptocurr integer, pdate date) RETURNS numeric
31020
 
    LANGUAGE plpgsql STABLE
31021
 
    AS $$
31022
 
DECLARE
31023
 
  _fromRate NUMERIC := 1.0;
31024
 
  _toRate NUMERIC := 1.0;
31025
 
  _returnVal NUMERIC := 1.0;
31026
 
BEGIN
31027
 
  IF pFromCurr = pToCurr THEN
31028
 
    RETURN _returnVal;
31029
 
  END IF;
31030
 
 
31031
 
  IF (pFromCurr IS NOT NULL) THEN
31032
 
    SELECT curr_rate INTO _fromRate
31033
 
    FROM curr_rate
31034
 
    WHERE ( (curr_id=pFromCurr)
31035
 
    AND (pDate BETWEEN curr_effective AND curr_expires) );
31036
 
 
31037
 
    IF ( NOT FOUND) THEN
31038
 
      RAISE EXCEPTION 'Currency exchange rate for currency % not found on %', pFromCurr, formatDate(pDate);
31039
 
    END IF;
31040
 
  END IF;
31041
 
 
31042
 
  IF (pToCurr IS NOT NULL) THEN
31043
 
    SELECT curr_rate INTO _toRate
31044
 
    FROM curr_rate
31045
 
    WHERE ( (curr_id=pToCurr)
31046
 
    AND (pDate BETWEEN curr_effective AND curr_expires) );
31047
 
 
31048
 
    IF ( NOT FOUND) THEN
31049
 
      RAISE EXCEPTION 'Currency exchange rate for currency % not found on %', pToCurr, formatDate(pDate);
31050
 
    END IF;
31051
 
  END IF;
31052
 
 
31053
 
  _returnVal := _fromRate / _toRate;
31054
 
 
31055
 
  RETURN _returnVal;
31056
 
END;
31057
 
$$;
31058
 
 
31059
 
 
31060
 
ALTER FUNCTION public.currrate(pfromcurr integer, ptocurr integer, pdate date) OWNER TO admin;
31061
 
 
31062
 
--
31063
 
--
31064
 
 
31065
 
CREATE FUNCTION currtobase(integer, numeric, date) RETURNS numeric
31066
 
    LANGUAGE plpgsql STABLE
31067
 
    AS $_$
31068
 
DECLARE
31069
 
  pId     ALIAS FOR $1;
31070
 
  pValue  ALIAS FOR $2;
31071
 
  _date  DATE;
31072
 
  _output NUMERIC;
31073
 
BEGIN
31074
 
  _date := $3;
31075
 
  IF _date IS NULL THEN
31076
 
    _date := 'now';
31077
 
  END IF;
31078
 
 
31079
 
  IF pValue = 0 OR pValue IS NULL THEN
31080
 
    _output := 0;
31081
 
  ELSIF (baseCurrId() = pId) THEN
31082
 
    _output := pValue;
31083
 
  ELSE
31084
 
    SELECT pValue / curr_rate
31085
 
        INTO  _output
31086
 
      FROM  curr_rate
31087
 
     WHERE curr_id = pId
31088
 
       AND _date BETWEEN curr_effective AND curr_expires;
31089
 
    IF (_output IS NULL OR NOT FOUND) THEN
31090
 
      RAISE EXCEPTION 'No exchange rate for % on %', pId, _date;
31091
 
    END IF;
31092
 
  END IF;
31093
 
  RETURN _output;
31094
 
END;
31095
 
$_$;
31096
 
 
31097
 
 
31098
 
ALTER FUNCTION public.currtobase(integer, numeric, date) OWNER TO admin;
31099
 
 
31100
 
--
31101
 
--
31102
 
 
31103
 
CREATE FUNCTION currtocurr(integer, integer, numeric, date) RETURNS numeric
31104
 
    LANGUAGE plpgsql
31105
 
    AS $_$
31106
 
DECLARE
31107
 
  pFromCurr ALIAS FOR $1;
31108
 
  pToCurr ALIAS FOR $2;
31109
 
  pValue   ALIAS FOR $3;
31110
 
  pEffective ALIAS FOR $4;
31111
 
  _convertedValue NUMERIC;
31112
 
  _fromRate NUMERIC;
31113
 
  _toRate NUMERIC;
31114
 
BEGIN
31115
 
  IF pFromCurr = pToCurr THEN
31116
 
    RETURN pValue;
31117
 
  END IF;
31118
 
 
31119
 
  IF pValue = 0 OR pValue IS NULL THEN
31120
 
    RETURN 0;
31121
 
  END IF;
31122
 
 
31123
 
  SELECT curr_rate INTO _fromRate
31124
 
  FROM curr_rate
31125
 
  WHERE curr_id = pFromCurr
31126
 
    AND pEffective BETWEEN curr_effective AND curr_expires;
31127
 
 
31128
 
  IF (NOT FOUND) THEN
31129
 
    RAISE EXCEPTION 'No exchange rate for % on %', pFromCurr, pEffective;
31130
 
  END IF;
31131
 
 
31132
 
  SELECT curr_rate INTO _toRate
31133
 
  FROM curr_rate
31134
 
  WHERE curr_id = pToCurr
31135
 
    AND pEffective BETWEEN curr_effective AND curr_expires;
31136
 
 
31137
 
  IF (NOT FOUND) THEN
31138
 
    RAISE EXCEPTION 'No exchange rate for % on %', pToCurr, pEffective;
31139
 
  END IF;
31140
 
 
31141
 
  _convertedValue := pValue * _toRate / _fromRate;
31142
 
 
31143
 
  RETURN _convertedValue;
31144
 
END;
31145
 
$_$;
31146
 
 
31147
 
 
31148
 
ALTER FUNCTION public.currtocurr(integer, integer, numeric, date) OWNER TO admin;
31149
 
 
31150
 
--
31151
 
--
31152
 
 
31153
 
CREATE FUNCTION currtolocal(integer, numeric, date) RETURNS numeric
31154
 
    LANGUAGE plpgsql
31155
 
    AS $_$
31156
 
DECLARE
31157
 
    pId     ALIAS FOR $1;
31158
 
    pValue  ALIAS FOR $2;
31159
 
    _date   DATE;
31160
 
    _output NUMERIC;
31161
 
BEGIN
31162
 
    _date := $3;
31163
 
    IF _date IS NULL THEN
31164
 
        _date := 'now';
31165
 
    END IF;
31166
 
 
31167
 
    IF pValue = 0 OR pValue IS NULL THEN
31168
 
        _output := 0;
31169
 
    ELSIF (baseCurrId() = pId) THEN
31170
 
      _output := pValue;
31171
 
    ELSE
31172
 
        SELECT pValue * curr_rate
31173
 
            INTO  _output
31174
 
            FROM  curr_rate
31175
 
            WHERE curr_id = pId
31176
 
              AND _date BETWEEN curr_effective AND curr_expires;
31177
 
        IF (_output IS NULL OR NOT FOUND) THEN
31178
 
          RAISE EXCEPTION 'No exchange rate for % on %', pId, _date;
31179
 
        END IF;
31180
 
    END IF;
31181
 
    RETURN _output;
31182
 
END;
31183
 
$_$;
31184
 
 
31185
 
 
31186
 
ALTER FUNCTION public.currtolocal(integer, numeric, date) OWNER TO admin;
31187
 
 
31188
 
--
31189
 
--
31190
 
 
31191
 
CREATE FUNCTION custitem(cust_id integer, shipto_id integer DEFAULT (-1), asof date DEFAULT ('now'::text)::date) RETURNS SETOF integer
31192
 
    LANGUAGE sql
31193
 
    AS $_$
31194
 
 
31195
 
  -- Non Exclusive
31196
 
  SELECT item_id
31197
 
  FROM item 
31198
 
  WHERE (NOT item_exclusive)
31199
 
   AND (item_sold)
31200
 
  UNION
31201
 
  -- Exclusive, Shipto match
31202
 
  SELECT item_id
31203
 
  FROM item
31204
 
    JOIN ipsiteminfo ON (ipsitem_item_id=item_id)
31205
 
    JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id)
31206
 
    JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
31207
 
  WHERE (item_exclusive)
31208
 
   AND (item_sold)
31209
 
   AND ($2 != -1)
31210
 
   AND (ipsass_shipto_id=$2)
31211
 
   AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1))
31212
 
  UNION
31213
 
  SELECT item_id
31214
 
  FROM item
31215
 
    JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id)
31216
 
    JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id)
31217
 
    JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
31218
 
  WHERE (item_exclusive)
31219
 
   AND (item_sold)
31220
 
   AND ($2 != -1)
31221
 
   AND (ipsass_shipto_id=$2)
31222
 
   AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1))
31223
 
  UNION
31224
 
   -- Exclusive, Shipto pattern match
31225
 
  SELECT item_id
31226
 
  FROM item
31227
 
    JOIN ipsiteminfo ON (ipsitem_item_id=item_id)
31228
 
    JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id)
31229
 
    JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
31230
 
    JOIN shiptoinfo ON (shipto_num ~ ipsass_shipto_pattern)
31231
 
  WHERE (item_exclusive)
31232
 
   AND (item_sold)
31233
 
   AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0)
31234
 
   AND (ipsass_cust_id=$1)
31235
 
   AND ($2 != -1)
31236
 
   AND (shipto_id=$2)
31237
 
   AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1))
31238
 
  UNION
31239
 
  SELECT item_id
31240
 
  FROM item
31241
 
    JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id)
31242
 
    JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id)
31243
 
    JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
31244
 
    JOIN shiptoinfo ON (shipto_num ~ ipsass_shipto_pattern)
31245
 
  WHERE (item_exclusive)
31246
 
   AND (item_sold)
31247
 
   AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0)
31248
 
   AND (ipsass_cust_id=$1)
31249
 
   AND ($2 != -1)
31250
 
   AND (shipto_id=$2)
31251
 
   AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1))
31252
 
  UNION
31253
 
   -- Exclusive, Customer match
31254
 
  SELECT item_id
31255
 
  FROM item
31256
 
    JOIN ipsiteminfo ON (ipsitem_item_id=item_id)
31257
 
    JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id)
31258
 
    JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
31259
 
  WHERE (item_exclusive)
31260
 
   AND (item_sold)
31261
 
   AND (ipsass_cust_id=$1)
31262
 
   AND (ipsass_shipto_id=-1)
31263
 
   AND (ipsass_shipto_pattern='')
31264
 
   AND (ipsass_custtype_id=-1)
31265
 
   AND (ipsass_custtype_pattern='')
31266
 
   AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1))
31267
 
  UNION
31268
 
  SELECT item_id
31269
 
  FROM item
31270
 
    JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id)
31271
 
    JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id)
31272
 
    JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
31273
 
  WHERE (item_exclusive)
31274
 
   AND (item_sold)
31275
 
   AND (ipsass_cust_id=$1)
31276
 
   AND (ipsass_shipto_id=-1)
31277
 
   AND (ipsass_shipto_pattern='')
31278
 
   AND (ipsass_custtype_id=-1)
31279
 
   AND (ipsass_custtype_pattern='')
31280
 
   AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1))
31281
 
  UNION
31282
 
  -- Exclusive, Customer Type match
31283
 
  SELECT item_id
31284
 
  FROM item
31285
 
    JOIN ipsiteminfo ON (ipsitem_item_id=item_id)
31286
 
    JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id)
31287
 
    JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
31288
 
    JOIN custinfo ON (ipsass_custtype_id=cust_custtype_id)
31289
 
  WHERE (item_exclusive)
31290
 
   AND (item_sold)
31291
 
   AND (cust_id=$1)
31292
 
   AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1))
31293
 
  UNION
31294
 
  SELECT item_id
31295
 
  FROM item
31296
 
    JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id)
31297
 
    JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id)
31298
 
    JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
31299
 
    JOIN custinfo ON (ipsass_custtype_id=cust_custtype_id)
31300
 
  WHERE (item_exclusive)
31301
 
   AND (item_sold)
31302
 
   AND (cust_id=$1)
31303
 
   AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1))
31304
 
  UNION
31305
 
  -- Exclusive, Customer Type pattern match
31306
 
  SELECT item_id
31307
 
  FROM item
31308
 
    JOIN ipsiteminfo ON (ipsitem_item_id=item_id)
31309
 
    JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id)
31310
 
    JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
31311
 
    JOIN custtype ON (custtype_code ~ ipsass_custtype_pattern)
31312
 
    JOIN custinfo ON (cust_custtype_id=custtype_id)
31313
 
  WHERE (item_exclusive)
31314
 
   AND (item_sold)
31315
 
   AND (COALESCE(length(ipsass_custtype_pattern), 0) > 0)
31316
 
   AND (cust_id=$1)
31317
 
   AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1))
31318
 
  UNION
31319
 
  SELECT item_id
31320
 
  FROM item
31321
 
    JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id)
31322
 
    JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id)
31323
 
    JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)
31324
 
    JOIN custtype ON (custtype_code ~ ipsass_custtype_pattern)
31325
 
    JOIN custinfo ON (cust_custtype_id=custtype_id)
31326
 
  WHERE (item_exclusive)
31327
 
   AND (item_sold)
31328
 
   AND (COALESCE(length(ipsass_custtype_pattern), 0) > 0)
31329
 
   AND (cust_id=$1)
31330
 
   AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1))
31331
 
   
31332
 
$_$;
31333
 
 
31334
 
 
31335
 
ALTER FUNCTION public.custitem(cust_id integer, shipto_id integer, asof date) OWNER TO admin;
31336
 
 
31337
 
--
31338
 
--
31339
 
 
31340
 
CREATE FUNCTION customercanpurchase(integer, integer) RETURNS boolean
31341
 
    LANGUAGE plpgsql
31342
 
    AS $_$
31343
 
DECLARE
31344
 
  pitemid ALIAS FOR $1;
31345
 
  pCustid ALIAS FOR $2;
31346
 
 
31347
 
BEGIN
31348
 
  RETURN customerCanPurchase(pitemid, pCustid, -1);
31349
 
END;
31350
 
$_$;
31351
 
 
31352
 
 
31353
 
ALTER FUNCTION public.customercanpurchase(integer, integer) OWNER TO admin;
31354
 
 
31355
 
--
31356
 
--
31357
 
 
31358
 
CREATE FUNCTION customercanpurchase(integer, integer, integer) RETURNS boolean
31359
 
    LANGUAGE plpgsql
31360
 
    AS $_$
31361
 
DECLARE
31362
 
  pitemid ALIAS FOR $1;
31363
 
  pCustid ALIAS FOR $2;
31364
 
  pShiptoid AlIAS FOR $3;
31365
 
  _id INTEGER;
31366
 
  _item RECORD;
31367
 
 
31368
 
BEGIN
31369
 
  RETURN customerCanPurchase(pitemid, pCustid, pShiptoid, CURRENT_DATE);
31370
 
END;
31371
 
$_$;
31372
 
 
31373
 
 
31374
 
ALTER FUNCTION public.customercanpurchase(integer, integer, integer) OWNER TO admin;
31375
 
 
31376
 
--
31377
 
--
31378
 
 
31379
 
CREATE FUNCTION customercanpurchase(integer, integer, integer, date) RETURNS boolean
31380
 
    LANGUAGE plpgsql
31381
 
    AS $_$
31382
 
DECLARE
31383
 
  pitemid ALIAS FOR $1;
31384
 
  pCustid ALIAS FOR $2;
31385
 
  pShiptoid AlIAS FOR $3;
31386
 
  pAsOf ALIAS FOR $4;
31387
 
  _id INTEGER;
31388
 
  _item RECORD;
31389
 
 
31390
 
BEGIN
31391
 
 
31392
 
  SELECT item_sold, item_exclusive
31393
 
    INTO _item
31394
 
    FROM item
31395
 
   WHERE(item_id=pItemid);
31396
 
 
31397
 
  IF (NOT _item.item_sold) THEN
31398
 
    RETURN FALSE;
31399
 
  END IF;
31400
 
 
31401
 
  IF (NOT _item.item_exclusive) THEN
31402
 
    RETURN TRUE;
31403
 
  END IF;
31404
 
 
31405
 
  IF(pShiptoid != -1) THEN
31406
 
    SELECT ipsitem_id INTO _id
31407
 
      FROM ipsiteminfo, ipshead, ipsass
31408
 
     WHERE((ipsitem_ipshead_id=ipshead_id)
31409
 
       AND (ipsass_ipshead_id=ipshead_id)
31410
 
       AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
31411
 
       AND (ipsitem_item_id=pItemid)
31412
 
       AND (ipsass_shipto_id != -1)
31413
 
       AND (ipsass_shipto_id=pShiptoid))
31414
 
     LIMIT 1;
31415
 
    IF (FOUND) THEN
31416
 
      RETURN TRUE;
31417
 
    END IF;
31418
 
    SELECT ipsitem_id INTO _id
31419
 
      FROM ipsiteminfo, item, ipshead, ipsass
31420
 
     WHERE((ipsitem_ipshead_id=ipshead_id)
31421
 
       AND (ipsitem_prodcat_id = item_prodcat_id)
31422
 
       AND (ipsass_ipshead_id=ipshead_id)
31423
 
       AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
31424
 
       AND (item_id=pItemid)
31425
 
       AND (ipsass_shipto_id != -1)
31426
 
       AND (ipsass_shipto_id=pShiptoid))
31427
 
     LIMIT 1;
31428
 
    IF (FOUND) THEN
31429
 
      RETURN TRUE;
31430
 
    END IF;
31431
 
 
31432
 
    SELECT ipsitem_id INTO _id
31433
 
      FROM ipsiteminfo, ipshead, ipsass, shiptoinfo
31434
 
     WHERE((ipsitem_ipshead_id=ipshead_id)
31435
 
       AND (ipsass_ipshead_id=ipshead_id)
31436
 
       AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
31437
 
       AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0)
31438
 
       AND (shipto_num ~ ipsass_shipto_pattern)
31439
 
       AND (ipsass_cust_id=pCustid)
31440
 
       AND (ipsitem_item_id=pItemid)
31441
 
       AND (shipto_id=pShiptoid))
31442
 
     LIMIT 1;
31443
 
    IF (FOUND) THEN
31444
 
      RETURN TRUE;
31445
 
    END IF;
31446
 
    SELECT ipsitem_id INTO _id
31447
 
      FROM ipsiteminfo, item, ipshead, ipsass, shiptoinfo
31448
 
     WHERE((ipsitem_ipshead_id=ipshead_id)
31449
 
       AND (ipsitem_prodcat_id = item_prodcat_id)
31450
 
       AND (ipsass_ipshead_id=ipshead_id)
31451
 
       AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
31452
 
       AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0)
31453
 
       AND (shipto_num ~ ipsass_shipto_pattern)
31454
 
       AND (ipsass_cust_id=pCustid)
31455
 
       AND (item_id=pItemid)
31456
 
       AND (shipto_id=pShiptoid))
31457
 
     LIMIT 1;
31458
 
    IF (FOUND) THEN
31459
 
      RETURN TRUE;
31460
 
    END IF;
31461
 
  END IF;
31462
 
 
31463
 
  SELECT ipsitem_id INTO _id
31464
 
    FROM ipsiteminfo, ipshead, ipsass
31465
 
   WHERE((ipsitem_ipshead_id=ipshead_id)
31466
 
     AND (ipsass_ipshead_id=ipshead_id)
31467
 
     AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
31468
 
     AND (ipsitem_item_id=pItemid)
31469
 
     AND (COALESCE(length(ipsass_shipto_pattern), 0) = 0)
31470
 
     AND (ipsass_cust_id=pCustid))
31471
 
   LIMIT 1;
31472
 
  IF (FOUND) THEN
31473
 
    RETURN TRUE;
31474
 
  END IF;
31475
 
  SELECT ipsitem_id INTO _id
31476
 
    FROM ipsiteminfo, item, ipshead, ipsass
31477
 
   WHERE((ipsitem_ipshead_id=ipshead_id)
31478
 
     AND (ipsitem_prodcat_id = item_prodcat_id)
31479
 
     AND (ipsass_ipshead_id=ipshead_id)
31480
 
     AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
31481
 
     AND (item_id=pItemid)
31482
 
     AND (COALESCE(length(ipsass_shipto_pattern), 0) = 0)
31483
 
     AND (ipsass_cust_id=pCustid))
31484
 
   LIMIT 1;
31485
 
  IF (FOUND) THEN
31486
 
    RETURN TRUE;
31487
 
  END IF;
31488
 
 
31489
 
  SELECT ipsitem_id INTO _id
31490
 
    FROM ipsiteminfo, ipshead, ipsass, custinfo
31491
 
   WHERE( (ipsitem_ipshead_id=ipshead_id)
31492
 
     AND  (ipsass_ipshead_id=ipshead_id)
31493
 
     AND  (ipsass_custtype_id != -1)
31494
 
     AND  (cust_custtype_id = ipsass_custtype_id)
31495
 
     AND  (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
31496
 
     AND  (ipsitem_item_id=pItemid)
31497
 
     AND  (cust_id=pCustid))
31498
 
    LIMIT 1;
31499
 
  IF (FOUND) THEN
31500
 
    RETURN TRUE;
31501
 
  END IF;
31502
 
  SELECT ipsitem_id INTO _id
31503
 
    FROM ipsiteminfo, item, ipshead, ipsass, custinfo
31504
 
   WHERE( (ipsitem_ipshead_id=ipshead_id)
31505
 
     AND  (ipsitem_prodcat_id = item_prodcat_id)
31506
 
     AND  (ipsass_ipshead_id=ipshead_id)
31507
 
     AND  (ipsass_custtype_id != -1)
31508
 
     AND  (cust_custtype_id = ipsass_custtype_id)
31509
 
     AND  (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
31510
 
     AND  (item_id=pItemid)
31511
 
     AND  (cust_id=pCustid))
31512
 
    LIMIT 1;
31513
 
  IF (FOUND) THEN
31514
 
    RETURN TRUE;
31515
 
  END IF;
31516
 
 
31517
 
  SELECT ipsitem_id INTO _id
31518
 
    FROM ipsiteminfo, ipshead, ipsass, custtype, custinfo
31519
 
   WHERE((ipsitem_ipshead_id=ipshead_id)
31520
 
     AND (ipsass_ipshead_id=ipshead_id)
31521
 
     AND (coalesce(length(ipsass_custtype_pattern), 0) > 0)
31522
 
     AND (custtype_code ~ ipsass_custtype_pattern)
31523
 
     AND (cust_custtype_id=custtype_id)
31524
 
     AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
31525
 
     AND (ipsitem_item_id=pItemid)
31526
 
     AND (cust_id=pCustid))
31527
 
   LIMIT 1;
31528
 
  IF (FOUND) THEN
31529
 
    RETURN TRUE;
31530
 
  END IF;
31531
 
  SELECT ipsitem_id INTO _id
31532
 
    FROM ipsiteminfo, item, ipshead, ipsass, custtype, custinfo
31533
 
   WHERE((ipsitem_ipshead_id=ipshead_id)
31534
 
     AND (ipsitem_prodcat_id = item_prodcat_id)
31535
 
     AND (ipsass_ipshead_id=ipshead_id)
31536
 
     AND (coalesce(length(ipsass_custtype_pattern), 0) > 0)
31537
 
     AND (custtype_code ~ ipsass_custtype_pattern)
31538
 
     AND (cust_custtype_id=custtype_id)
31539
 
     AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
31540
 
     AND (item_id=pItemid)
31541
 
     AND (cust_id=pCustid))
31542
 
   LIMIT 1;
31543
 
  IF (FOUND) THEN
31544
 
    RETURN TRUE;
31545
 
  END IF;
31546
 
 
31547
 
  RETURN FALSE;
31548
 
 
31549
 
END;
31550
 
$_$;
31551
 
 
31552
 
 
31553
 
ALTER FUNCTION public.customercanpurchase(integer, integer, integer, date) OWNER TO admin;
31554
 
 
31555
 
--
31556
 
--
31557
 
 
31558
 
CREATE FUNCTION dearmor(text) RETURNS bytea
31559
 
    LANGUAGE c IMMUTABLE STRICT
31560
 
    AS '$libdir/pgcrypto', 'pg_dearmor';
31561
 
 
31562
 
 
31563
 
ALTER FUNCTION public.dearmor(text) OWNER TO admin;
31564
 
 
31565
 
--
31566
 
--
31567
 
 
31568
 
CREATE FUNCTION decrypt(bytea, bytea, text) RETURNS bytea
31569
 
    LANGUAGE c IMMUTABLE STRICT
31570
 
    AS '$libdir/pgcrypto', 'pg_decrypt';
31571
 
 
31572
 
 
31573
 
ALTER FUNCTION public.decrypt(bytea, bytea, text) OWNER TO admin;
31574
 
 
31575
 
--
31576
 
--
31577
 
 
31578
 
CREATE FUNCTION decrypt_iv(bytea, bytea, bytea, text) RETURNS bytea
31579
 
    LANGUAGE c IMMUTABLE STRICT
31580
 
    AS '$libdir/pgcrypto', 'pg_decrypt_iv';
31581
 
 
31582
 
 
31583
 
ALTER FUNCTION public.decrypt_iv(bytea, bytea, bytea, text) OWNER TO admin;
31584
 
 
31585
 
--
31586
 
--
31587
 
 
31588
 
CREATE FUNCTION defaultlocationname(integer) RETURNS text
31589
 
    LANGUAGE plpgsql
31590
 
    AS $_$
31591
 
DECLARE
31592
 
  pItemsiteid ALIAS FOR $1;
31593
 
  _p RECORD;
31594
 
 
31595
 
BEGIN
31596
 
 
31597
 
  SELECT itemsite_location_id, itemsite_location INTO _p
31598
 
  FROM itemsite
31599
 
  WHERE (itemsite_id=pItemsiteid);
31600
 
 
31601
 
  IF (NOT FOUND) THEN
31602
 
    RETURN 'Error';
31603
 
  ELSIF (_p.itemsite_location_id = -1) THEN
31604
 
    RETURN _p.itemsite_location;
31605
 
  ELSE
31606
 
    RETURN formatLocationName(_p.itemsite_location_id);
31607
 
  END IF;
31608
 
 
31609
 
END;
31610
 
$_$;
31611
 
 
31612
 
 
31613
 
ALTER FUNCTION public.defaultlocationname(integer) OWNER TO admin;
31614
 
 
31615
 
--
31616
 
--
31617
 
 
31618
 
CREATE FUNCTION deleteaccount(integer) RETURNS integer
31619
 
    LANGUAGE plpgsql
31620
 
    AS $_$
31621
 
DECLARE
31622
 
  pAccntid ALIAS FOR $1;
31623
 
  _check INTEGER;
31624
 
 
31625
 
BEGIN
31626
 
 
31627
 
  SELECT costcat_id INTO _check
31628
 
  FROM costcat
31629
 
  WHERE ( (costcat_asset_accnt_id=pAccntid)
31630
 
     OR   (costcat_liability_accnt_id=pAccntid)
31631
 
     OR   (costcat_adjustment_accnt_id=pAccntid)
31632
 
     OR   (costcat_purchprice_accnt_id=pAccntid)
31633
 
     OR   (costcat_laboroverhead_accnt_id=pAccntid)
31634
 
     OR   (costcat_scrap_accnt_id=pAccntid)
31635
 
     OR   (costcat_invcost_accnt_id=pAccntid)
31636
 
     OR   (costcat_wip_accnt_id=pAccntid)
31637
 
     OR   (costcat_shipasset_accnt_id=pAccntid)
31638
 
     OR   (costcat_mfgscrap_accnt_id=pAccntid)
31639
 
     OR   (costcat_transform_accnt_id=pAccntid)
31640
 
     OR   (costcat_freight_accnt_id=pAccntid) )
31641
 
  LIMIT 1;
31642
 
  IF (FOUND) THEN
31643
 
    RETURN -1;
31644
 
  END IF;
31645
 
 
31646
 
  SELECT salesaccnt_id INTO _check
31647
 
  FROM salesaccnt
31648
 
  WHERE ( (salesaccnt_sales_accnt_id=pAccntid)
31649
 
     OR   (salesaccnt_credit_accnt_id=pAccntid)
31650
 
     OR   (salesaccnt_cos_accnt_id=pAccntid) )
31651
 
  LIMIT 1;
31652
 
  IF (FOUND) THEN
31653
 
    RETURN -2;
31654
 
  END IF;
31655
 
 
31656
 
  SELECT araccnt_id INTO _check
31657
 
  FROM araccnt
31658
 
  WHERE ( (araccnt_freight_accnt_id=pAccntid)
31659
 
     OR   (araccnt_ar_accnt_id=pAccntid)
31660
 
     OR   (araccnt_prepaid_accnt_id=pAccntid) )
31661
 
  LIMIT 1;
31662
 
  IF (FOUND) THEN
31663
 
    RETURN -3;
31664
 
  END IF;
31665
 
 
31666
 
  IF EXISTS (SELECT 1
31667
 
               FROM whsinfo
31668
 
              WHERE (warehous_default_accnt_id=pAccntid)) THEN
31669
 
    RETURN -4;
31670
 
  END IF;
31671
 
 
31672
 
  SELECT bankaccnt_id INTO _check
31673
 
  FROM bankaccnt
31674
 
  WHERE (bankaccnt_accnt_id=pAccntid)
31675
 
  LIMIT 1;
31676
 
  IF (FOUND) THEN
31677
 
    RETURN -5;
31678
 
  END IF;
31679
 
 
31680
 
  SELECT expcat_id INTO _check
31681
 
  FROM expcat
31682
 
  WHERE ( (expcat_exp_accnt_id=pAccntid)
31683
 
     OR   (expcat_liability_accnt_id=pAccntid)
31684
 
     OR   (expcat_purchprice_accnt_id=pAccntid)
31685
 
     OR   (expcat_freight_accnt_id=pAccntid) )
31686
 
  LIMIT 1;
31687
 
  IF (FOUND) THEN
31688
 
    RETURN -6;
31689
 
  END IF;
31690
 
 
31691
 
  SELECT tax_id INTO _check
31692
 
  FROM tax
31693
 
  WHERE (tax_sales_accnt_id=pAccntid)
31694
 
  LIMIT 1;
31695
 
  IF (FOUND) THEN
31696
 
    RETURN -7;
31697
 
  END IF;
31698
 
 
31699
 
  SELECT stdjrnlitem_id INTO _check
31700
 
  FROM stdjrnlitem
31701
 
  WHERE (stdjrnlitem_accnt_id=pAccntid)
31702
 
  LIMIT 1;
31703
 
  IF (FOUND) THEN
31704
 
    RETURN -8;
31705
 
  END IF;
31706
 
 
31707
 
  SELECT apaccnt_ap_accnt_id INTO _check
31708
 
  FROM apaccnt
31709
 
  WHERE ( (apaccnt_ap_accnt_id=pAccntid)
31710
 
     OR   (apaccnt_prepaid_accnt_id=pAccntid)
31711
 
     OR   (apaccnt_discount_accnt_id=pAccntid) )
31712
 
  LIMIT 1;
31713
 
  IF (FOUND) THEN
31714
 
    RETURN -9;
31715
 
  END IF;
31716
 
 
31717
 
  SELECT aropen_accnt_id INTO _check
31718
 
    FROM aropen
31719
 
   WHERE (aropen_accnt_id=pAccntid)
31720
 
   LIMIT 1;
31721
 
  IF (FOUND) THEN
31722
 
    RETURN -11;
31723
 
  END IF;
31724
 
 
31725
 
  SELECT gltrans_accnt_id INTO _check
31726
 
  FROM gltrans
31727
 
  WHERE (gltrans_accnt_id=pAccntid)
31728
 
  LIMIT 1;
31729
 
  IF (FOUND) THEN
31730
 
    RETURN -99;
31731
 
  END IF;
31732
 
 
31733
 
  SELECT glseries_accnt_id INTO _check
31734
 
  FROM glseries
31735
 
  WHERE (glseries_accnt_id=pAccntid)
31736
 
  LIMIT 1;
31737
 
  IF (FOUND) THEN
31738
 
    RETURN -99;
31739
 
  END IF;
31740
 
 
31741
 
  SELECT trialbal_accnt_id INTO _check
31742
 
  FROM trialbal
31743
 
  WHERE (trialbal_accnt_id=pAccntid)
31744
 
    AND (trialbal_beginning != 0 OR trialbal_ending != 0)
31745
 
  LIMIT 1;
31746
 
  IF (FOUND) THEN
31747
 
    RETURN -99;
31748
 
  END IF;
31749
 
 
31750
 
  SELECT cashrcptmisc_accnt_id INTO _check
31751
 
  FROM cashrcptmisc
31752
 
  WHERE (cashrcptmisc_accnt_id=pAccntid)
31753
 
  LIMIT 1;
31754
 
  IF (FOUND) THEN
31755
 
    RETURN -99;
31756
 
  END IF;
31757
 
 
31758
 
  DELETE FROM flitem
31759
 
  WHERE (flitem_accnt_id=pAccntid);
31760
 
 
31761
 
  -- only possible because of trialbal error-check above
31762
 
  DELETE FROM trialbal
31763
 
  WHERE (trialbal_accnt_id=pAccntid)
31764
 
    AND (trialbal_beginning=0)
31765
 
    AND (trialbal_ending=0);
31766
 
 
31767
 
  DELETE FROM accnt
31768
 
  WHERE (accnt_id=pAccntid);
31769
 
 
31770
 
  RETURN 0;
31771
 
 
31772
 
END;
31773
 
$_$;
31774
 
 
31775
 
 
31776
 
ALTER FUNCTION public.deleteaccount(integer) OWNER TO admin;
31777
 
 
31778
 
--
31779
 
--
31780
 
 
31781
 
CREATE FUNCTION deleteaccountingperiod(integer) RETURNS integer
31782
 
    LANGUAGE plpgsql
31783
 
    AS $_$
31784
 
DECLARE
31785
 
  pPeriodid ALIAS FOR $1;
31786
 
  _check RECORD;
31787
 
 
31788
 
BEGIN
31789
 
 
31790
 
  IF ( ( SELECT period_closed
31791
 
         FROM period
31792
 
         WHERE (period_id=pPeriodid) ) ) THEN
31793
 
    RETURN -1;
31794
 
  END IF;
31795
 
 
31796
 
  SELECT gltrans_id INTO _check
31797
 
  FROM gltrans, period
31798
 
  WHERE ( (gltrans_date BETWEEN period_start AND period_end)
31799
 
   AND (gltrans_posted)
31800
 
   AND (period_id=pPeriodid) )
31801
 
  LIMIT 1;
31802
 
  IF (FOUND) THEN
31803
 
    RETURN -4;
31804
 
  END IF;
31805
 
 
31806
 
  SELECT b.period_id INTO _check
31807
 
    FROM period AS a, period AS b
31808
 
   WHERE((a.period_id=pPeriodid)
31809
 
     AND (a.period_end < b.period_start))
31810
 
   LIMIT 1;
31811
 
  IF (FOUND) THEN
31812
 
    RETURN -5;
31813
 
  END IF;
31814
 
 
31815
 
  DELETE FROM period
31816
 
  WHERE (period_id=pPeriodid);
31817
 
 
31818
 
  RETURN 1;
31819
 
 
31820
 
END;
31821
 
$_$;
31822
 
 
31823
 
 
31824
 
ALTER FUNCTION public.deleteaccountingperiod(integer) OWNER TO admin;
31825
 
 
31826
 
--
31827
 
--
31828
 
 
31829
 
CREATE FUNCTION deleteaccountingyearperiod(integer) RETURNS integer
31830
 
    LANGUAGE plpgsql
31831
 
    AS $_$
31832
 
DECLARE
31833
 
  pPeriodid ALIAS FOR $1;
31834
 
  _check RECORD;
31835
 
 
31836
 
BEGIN
31837
 
 
31838
 
  IF ( ( SELECT yearperiod_closed
31839
 
         FROM yearperiod
31840
 
         WHERE (yearperiod_id=pPeriodid) ) ) THEN
31841
 
    RETURN -1;
31842
 
  END IF;
31843
 
 
31844
 
  -- this yearperiod is in use by existing periods
31845
 
  IF (EXISTS(SELECT period_id
31846
 
             FROM period
31847
 
             WHERE (period_yearperiod_id=pPeriodid))) THEN
31848
 
    RETURN -2;
31849
 
  END IF;
31850
 
 
31851
 
  DELETE FROM yearperiod
31852
 
  WHERE (yearperiod_id=pPeriodid);
31853
 
 
31854
 
  RETURN 1;
31855
 
 
31856
 
END;
31857
 
$_$;
31858
 
 
31859
 
 
31860
 
ALTER FUNCTION public.deleteaccountingyearperiod(integer) OWNER TO admin;
31861
 
 
31862
 
--
31863
 
--
31864
 
 
31865
 
CREATE FUNCTION deleteaddress(integer) RETURNS integer
31866
 
    LANGUAGE plpgsql
31867
 
    AS $_$
31868
 
DECLARE
31869
 
  paddrId     ALIAS FOR $1;
31870
 
  _count      INTEGER := 0;
31871
 
BEGIN
31872
 
  SELECT count(*) INTO _count
31873
 
    FROM cntct
31874
 
    WHERE (cntct_active
31875
 
      AND  (cntct_addr_id = paddrId));
31876
 
  IF (_count > 0) THEN
31877
 
    RETURN -1;
31878
 
  END IF;
31879
 
 
31880
 
  SELECT count(*) INTO _count
31881
 
    FROM vendinfo
31882
 
    WHERE (vend_active
31883
 
      AND  (vend_addr_id = paddrId));
31884
 
  IF (_count > 0) THEN
31885
 
    RETURN -2;
31886
 
  END IF;
31887
 
 
31888
 
  SELECT count(*) INTO _count
31889
 
    FROM shiptoinfo
31890
 
    WHERE (shipto_active
31891
 
      AND  (shipto_addr_id = paddrId));
31892
 
  IF (_count > 0) THEN
31893
 
    RETURN -3;
31894
 
  END IF;
31895
 
 
31896
 
  SELECT count(*) INTO _count
31897
 
    FROM vendaddrinfo
31898
 
    WHERE (vendaddr_addr_id = paddrId);
31899
 
  IF (_count > 0) THEN
31900
 
    RETURN -4;
31901
 
  END IF;
31902
 
 
31903
 
  SELECT count(*) INTO _count
31904
 
    FROM whsinfo
31905
 
    WHERE (warehous_active
31906
 
      AND  (warehous_addr_id = paddrId));
31907
 
  IF (_count > 0) THEN
31908
 
    RETURN -5;
31909
 
  END IF;
31910
 
 
31911
 
  UPDATE cntct SET cntct_addr_id = NULL WHERE (cntct_addr_id = paddrId);
31912
 
  UPDATE vendinfo SET vend_addr_id = NULL WHERE (vend_addr_id = paddrId);
31913
 
  UPDATE shiptoinfo SET shipto_addr_id = NULL WHERE (shipto_addr_id =paddrId);
31914
 
  UPDATE vendaddrinfo SET vendaddr_addr_id = NULL
31915
 
    WHERE (vendaddr_addr_id = paddrId);
31916
 
  UPDATE whsinfo SET warehous_addr_id = NULL WHERE (warehous_addr_id=paddrId);
31917
 
 
31918
 
  DELETE FROM addr WHERE addr_id = paddrId;
31919
 
  RETURN 0;
31920
 
END;
31921
 
$_$;
31922
 
 
31923
 
 
31924
 
ALTER FUNCTION public.deleteaddress(integer) OWNER TO admin;
31925
 
 
31926
 
--
31927
 
--
31928
 
 
31929
 
CREATE FUNCTION deleteapcheck(integer) RETURNS integer
31930
 
    LANGUAGE plpgsql
31931
 
    AS $_$
31932
 
BEGIN
31933
 
  RAISE NOTICE 'deleteAPCheck() is deprecated - use deleteCheck() instead';
31934
 
  RETURN deleteCheck($1);
31935
 
END;
31936
 
$_$;
31937
 
 
31938
 
 
31939
 
ALTER FUNCTION public.deleteapcheck(integer) OWNER TO admin;
31940
 
 
31941
 
--
31942
 
--
31943
 
 
31944
 
CREATE FUNCTION deletebankadjustmenttype(integer) RETURNS integer
31945
 
    LANGUAGE plpgsql
31946
 
    AS $_$
31947
 
DECLARE
31948
 
  pBankadjtypeid ALIAS FOR $1;
31949
 
  _check INTEGER;
31950
 
 
31951
 
BEGIN
31952
 
 
31953
 
  SELECT bankadj_bankadjtype_id INTO _check
31954
 
    FROM bankadj
31955
 
   WHERE (bankadj_bankadjtype_id=pBankadjtypeid)
31956
 
   LIMIT 1;
31957
 
  IF (FOUND) THEN
31958
 
    RETURN -1;
31959
 
  END IF;
31960
 
 
31961
 
  DELETE FROM bankadjtype
31962
 
  WHERE (bankadjtype_id=pbankadjtypeid);
31963
 
 
31964
 
  RETURN 0;
31965
 
 
31966
 
END;
31967
 
$_$;
31968
 
 
31969
 
 
31970
 
ALTER FUNCTION public.deletebankadjustmenttype(integer) OWNER TO admin;
31971
 
 
31972
 
--
31973
 
--
31974
 
 
31975
 
CREATE FUNCTION deletebankreconciliation(integer) RETURNS integer
31976
 
    LANGUAGE plpgsql
31977
 
    AS $_$
31978
 
DECLARE
31979
 
  pbankrecid    ALIAS FOR $1;
31980
 
BEGIN
31981
 
  DELETE FROM bankrecitem
31982
 
  WHERE bankrecitem_bankrec_id=pbankrecid;
31983
 
 
31984
 
  DELETE FROM bankrec
31985
 
  WHERE bankrec_id=pbankrecid;
31986
 
 
31987
 
  RETURN 0;
31988
 
END;
31989
 
$_$;
31990
 
 
31991
 
 
31992
 
ALTER FUNCTION public.deletebankreconciliation(integer) OWNER TO admin;
31993
 
 
31994
 
--
31995
 
--
31996
 
 
31997
 
CREATE FUNCTION deletebom(integer) RETURNS integer
31998
 
    LANGUAGE plpgsql
31999
 
    AS $_$
32000
 
DECLARE
32001
 
  pItemid ALIAS FOR $1;
32002
 
  _result INTEGER;
32003
 
 
32004
 
BEGIN
32005
 
 
32006
 
  IF (fetchmetricbool('RevControl')) THEN
32007
 
    SELECT rev_id INTO _result
32008
 
    FROM rev
32009
 
    WHERE ((rev_target_id=pItemid)
32010
 
    AND (rev_target_type = 'BOM'))
32011
 
    LIMIT 1;
32012
 
    IF (FOUND) THEN
32013
 
      RAISE EXCEPTION 'Bill of Materials has revision control records and may not be deleted.';
32014
 
    END IF;
32015
 
  END IF;
32016
 
 
32017
 
  DELETE FROM bomhead
32018
 
  WHERE (bomhead_item_id=pItemid);
32019
 
  DELETE FROM bomitem
32020
 
  WHERE (bomitem_parent_item_id=pItemid);
32021
 
 
32022
 
  RETURN 0;
32023
 
 
32024
 
END;
32025
 
$_$;
32026
 
 
32027
 
 
32028
 
ALTER FUNCTION public.deletebom(integer) OWNER TO admin;
32029
 
 
32030
 
--
32031
 
--
32032
 
 
32033
 
CREATE FUNCTION deletebomworkset(integer) RETURNS integer
32034
 
    LANGUAGE plpgsql
32035
 
    AS $_$
32036
 
DECLARE
32037
 
  pWorksetid ALIAS FOR $1;
32038
 
 
32039
 
BEGIN
32040
 
 
32041
 
  DELETE FROM bomwork
32042
 
  WHERE (bomwork_set_id=pWorksetid);
32043
 
 
32044
 
  RETURN 1;
32045
 
 
32046
 
END;
32047
 
$_$;
32048
 
 
32049
 
 
32050
 
ALTER FUNCTION public.deletebomworkset(integer) OWNER TO admin;
32051
 
 
32052
 
--
32053
 
--
32054
 
 
32055
 
CREATE FUNCTION deletebudget(integer) RETURNS integer
32056
 
    LANGUAGE plpgsql
32057
 
    AS $_$
32058
 
DECLARE
32059
 
  pBudgheadid ALIAS FOR $1;
32060
 
 
32061
 
BEGIN
32062
 
  DELETE FROM budgitem WHERE (budgitem_budghead_id=pBudgheadid);
32063
 
  DELETE FROM budghead WHERE (budghead_id=pBudgheadid);
32064
 
 
32065
 
  RETURN pBudgheadid;
32066
 
END;
32067
 
$_$;
32068
 
 
32069
 
 
32070
 
ALTER FUNCTION public.deletebudget(integer) OWNER TO admin;
32071
 
 
32072
 
--
32073
 
--
32074
 
 
32075
 
CREATE FUNCTION deletebudgetitems(integer) RETURNS integer
32076
 
    LANGUAGE plpgsql
32077
 
    AS $_$
32078
 
DECLARE
32079
 
  pBudgheadid ALIAS FOR $1;
32080
 
 
32081
 
BEGIN
32082
 
  DELETE FROM budgitem WHERE (budgitem_budghead_id=pBudgheadid);
32083
 
 
32084
 
  RETURN pBudgheadid;
32085
 
END;
32086
 
$_$;
32087
 
 
32088
 
 
32089
 
ALTER FUNCTION public.deletebudgetitems(integer) OWNER TO admin;
32090
 
 
32091
 
--
32092
 
--
32093
 
 
32094
 
CREATE FUNCTION deletecashrcpt(integer) RETURNS integer
32095
 
    LANGUAGE plpgsql
32096
 
    AS $_$
32097
 
DECLARE
32098
 
  pcashrcptid ALIAS FOR $1;
32099
 
  _ccreceipt    BOOLEAN;
32100
 
 
32101
 
BEGIN
32102
 
 
32103
 
  IF EXISTS(SELECT cashrcpt_id
32104
 
            FROM cashrcpt
32105
 
            JOIN ccpay ON (cashrcpt_cust_id=ccpay_cust_id)
32106
 
                       AND ((CASE WHEN TRIM(COALESCE(cashrcpt_docnumber, ''))='' THEN TEXT(cashrcpt_id)
32107
 
                                  ELSE cashrcpt_docnumber
32108
 
                             END)=ccpay_order_number)
32109
 
            WHERE ((cashrcpt_fundstype IN ('A', 'D', 'M', 'V'))
32110
 
               AND (ccpay_status NOT IN ('D', 'X'))
32111
 
               AND (ccpay_id NOT IN (SELECT payco_ccpay_id FROM payco))
32112
 
               AND (cashrcpt_id=pcashrcptid))) THEN
32113
 
    RETURN -1;
32114
 
  END IF;
32115
 
 
32116
 
  IF EXISTS(SELECT cashrcpt_id
32117
 
            FROM cashrcpt
32118
 
            WHERE ( (cashrcpt_id=pcashrcptid)
32119
 
              AND   (cashrcpt_posted) )) THEN
32120
 
    RETURN -2;
32121
 
  END IF;
32122
 
 
32123
 
  -- If there are applications for this Cash Receipt then
32124
 
  -- it has been posted and reversed.  Void instead of delete.
32125
 
  IF EXISTS(SELECT cashrcpt_id
32126
 
            FROM cashrcpt JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id)
32127
 
                          JOIN arapply ON ((arapply_reftype='CRA') AND
32128
 
                                           (arapply_ref_id=cashrcptitem_id))
32129
 
            WHERE (cashrcpt_id=pcashrcptid))
32130
 
     OR
32131
 
     EXISTS(SELECT cashrcpt_id
32132
 
            FROM cashrcpt JOIN cashrcptmisc ON (cashrcptmisc_cashrcpt_id=cashrcpt_id)
32133
 
                          JOIN arapply ON ((arapply_reftype='CRD') AND
32134
 
                                           (arapply_ref_id=cashrcptmisc_id))
32135
 
            WHERE (cashrcpt_id=pcashrcptid)) THEN
32136
 
    UPDATE cashrcpt SET cashrcpt_void = TRUE
32137
 
    WHERE (cashrcpt_id=pcashrcptid);
32138
 
    RETURN 1;
32139
 
  END IF;
32140
 
 
32141
 
  DELETE FROM cashrcptitem
32142
 
  WHERE (cashrcptitem_cashrcpt_id=pcashrcptid);
32143
 
 
32144
 
  DELETE FROM cashrcptmisc
32145
 
  WHERE (cashrcptmisc_cashrcpt_id=pcashrcptid);
32146
 
 
32147
 
  DELETE FROM cashrcpt
32148
 
  WHERE (cashrcpt_id=pcashrcptid);
32149
 
 
32150
 
  RETURN 1;
32151
 
 
32152
 
END;
32153
 
$_$;
32154
 
 
32155
 
 
32156
 
ALTER FUNCTION public.deletecashrcpt(integer) OWNER TO admin;
32157
 
 
32158
 
--
32159
 
--
32160
 
 
32161
 
CREATE FUNCTION deletecharacteristic(integer) RETURNS integer
32162
 
    LANGUAGE plpgsql
32163
 
    AS $_$
32164
 
DECLARE
32165
 
  pCharid ALIAS FOR $1;
32166
 
  _check INTEGER;
32167
 
  _r RECORD;
32168
 
 
32169
 
BEGIN
32170
 
 
32171
 
  SELECT * INTO _r
32172
 
  FROM char
32173
 
  WHERE (char_id=pCharid);
32174
 
  IF (NOT(FOUND)) THEN
32175
 
    RETURN 0;
32176
 
  END IF;
32177
 
 
32178
 
  SELECT * INTO _r
32179
 
  FROM charass
32180
 
  WHERE (charass_char_id=pCharid)
32181
 
  LIMIT 1;
32182
 
  IF (FOUND) THEN
32183
 
    IF (_r.charass_target_type = 'I') THEN
32184
 
      RETURN -1;
32185
 
    ELSIF (_r.charass_target_type = 'C') THEN
32186
 
      RETURN -2;
32187
 
    ELSIF (_r.charass_target_type = 'ADDR') THEN
32188
 
      RETURN -3;
32189
 
    ELSIF (_r.charass_target_type = 'CNTCT') THEN
32190
 
      RETURN -4;
32191
 
    ELSIF (_r.charass_target_type = 'CRMACCT') THEN
32192
 
      RETURN -5;
32193
 
    ELSIF (_r.charass_target_type = 'INCDT      ') THEN
32194
 
      RETURN -6;
32195
 
    ELSIF (_r.charass_target_type = 'EMP') THEN
32196
 
      RETURN -7;
32197
 
    ELSIF (_r.charass_target_type = 'QU') THEN
32198
 
      RETURN -8;
32199
 
    ELSIF (_r.charass_target_type = 'SO') THEN
32200
 
      RETURN -9;
32201
 
    ELSIF (_r.charass_target_type = 'INV') THEN
32202
 
      RETURN -10;
32203
 
    ELSIF (_r.charass_target_type = 'V') THEN
32204
 
      RETURN -11;
32205
 
    ELSIF (_r.charass_target_type = 'PO') THEN
32206
 
      RETURN -12;
32207
 
    ELSIF (_r.charass_target_type = 'VO') THEN
32208
 
      RETURN -13;
32209
 
    ELSE
32210
 
      RETURN -99;
32211
 
    END IF;
32212
 
  END IF;
32213
 
 
32214
 
  DELETE FROM char
32215
 
  WHERE (char_id=pCharid);
32216
 
 
32217
 
  RETURN pCharid;
32218
 
 
32219
 
END;
32220
 
$_$;
32221
 
 
32222
 
 
32223
 
ALTER FUNCTION public.deletecharacteristic(integer) OWNER TO admin;
32224
 
 
32225
 
--
32226
 
--
32227
 
 
32228
 
CREATE FUNCTION deletecheck(integer) RETURNS integer
32229
 
    LANGUAGE plpgsql
32230
 
    AS $_$
32231
 
DECLARE
32232
 
  pCheckid ALIAS FOR $1;
32233
 
 
32234
 
BEGIN
32235
 
  IF (SELECT (NOT checkhead_void) OR checkhead_posted OR checkhead_replaced
32236
 
              OR checkhead_deleted
32237
 
              OR (checkhead_ach_batch IS NOT NULL AND checkhead_printed)
32238
 
      FROM checkhead
32239
 
      WHERE (checkhead_id=pCheckid) ) THEN
32240
 
    RETURN -1;
32241
 
  END IF;
32242
 
 
32243
 
  UPDATE checkhead
32244
 
  SET checkhead_deleted=TRUE
32245
 
  WHERE (checkhead_id=pCheckid);
32246
 
 
32247
 
  RETURN 1;
32248
 
 
32249
 
END;
32250
 
$_$;
32251
 
 
32252
 
 
32253
 
ALTER FUNCTION public.deletecheck(integer) OWNER TO admin;
32254
 
 
32255
 
--
32256
 
--
32257
 
 
32258
 
CREATE FUNCTION deleteclasscode(integer) RETURNS integer
32259
 
    LANGUAGE plpgsql
32260
 
    AS $_$
32261
 
DECLARE
32262
 
  pClasscodeid ALIAS FOR $1;
32263
 
  _check INTEGER;
32264
 
 
32265
 
BEGIN
32266
 
 
32267
 
  SELECT item_id INTO _check
32268
 
  FROM item
32269
 
  WHERE (item_classcode_id=pClasscodeid)
32270
 
  LIMIT 1;
32271
 
  IF (FOUND) THEN
32272
 
    RETURN -1;
32273
 
  END IF;
32274
 
 
32275
 
  DELETE FROM classcode
32276
 
  WHERE (classcode_id=pClasscodeid);
32277
 
 
32278
 
  RETURN pClasscodeid;
32279
 
 
32280
 
END;
32281
 
$_$;
32282
 
 
32283
 
 
32284
 
ALTER FUNCTION public.deleteclasscode(integer) OWNER TO admin;
32285
 
 
32286
 
--
32287
 
--
32288
 
 
32289
 
CREATE FUNCTION deletecompany(integer) RETURNS integer
32290
 
    LANGUAGE plpgsql
32291
 
    AS $_$
32292
 
DECLARE
32293
 
  pcompanyid ALIAS FOR $1;
32294
 
 
32295
 
BEGIN
32296
 
  IF (EXISTS(SELECT accnt_id
32297
 
             FROM accnt, company
32298
 
             WHERE ((accnt_company=company_number)
32299
 
               AND  (company_id=pcompanyid))
32300
 
            )) THEN
32301
 
    RETURN -1;
32302
 
  END IF;
32303
 
 
32304
 
  DELETE FROM company
32305
 
  WHERE (company_id=pcompanyid);
32306
 
 
32307
 
  RETURN pcompanyid;
32308
 
 
32309
 
END;
32310
 
$_$;
32311
 
 
32312
 
 
32313
 
ALTER FUNCTION public.deletecompany(integer) OWNER TO admin;
32314
 
 
32315
 
--
32316
 
--
32317
 
 
32318
 
CREATE FUNCTION deletecreditmemo(integer) RETURNS boolean
32319
 
    LANGUAGE plpgsql
32320
 
    AS $_$
32321
 
DECLARE
32322
 
  pCmheadid ALIAS FOR $1;
32323
 
 
32324
 
BEGIN
32325
 
 
32326
 
  DELETE FROM cmitem
32327
 
  WHERE (cmitem_cmhead_id=pCmheadid);
32328
 
 
32329
 
  DELETE FROM cmhead
32330
 
  WHERE (cmhead_id=pCmheadid);
32331
 
 
32332
 
  RETURN TRUE;
32333
 
 
32334
 
END;
32335
 
$_$;
32336
 
 
32337
 
 
32338
 
ALTER FUNCTION public.deletecreditmemo(integer) OWNER TO admin;
32339
 
 
32340
 
--
32341
 
--
32342
 
 
32343
 
CREATE FUNCTION deletecustomer(integer) RETURNS integer
32344
 
    LANGUAGE plpgsql
32345
 
    AS $_$
32346
 
DECLARE
32347
 
  pCustid ALIAS FOR $1;
32348
 
 
32349
 
BEGIN
32350
 
 
32351
 
  PERFORM shipto_id
32352
 
  FROM shiptoinfo
32353
 
  WHERE (shipto_cust_id=pCustid)
32354
 
  LIMIT 1;
32355
 
  IF (FOUND) THEN
32356
 
    RETURN -1;
32357
 
  END IF;
32358
 
 
32359
 
  PERFORM cohead_id
32360
 
  FROM cohead
32361
 
  WHERE (cohead_cust_id=pCustid)
32362
 
  LIMIT 1;
32363
 
  IF (FOUND) THEN
32364
 
    RETURN -2;
32365
 
  END IF;
32366
 
 
32367
 
  PERFORM cmhead_id
32368
 
  FROM cmhead
32369
 
  WHERE (cmhead_cust_id=pCustid)
32370
 
  LIMIT 1;
32371
 
  IF (FOUND) THEN
32372
 
    RETURN -3;
32373
 
  END IF;
32374
 
 
32375
 
  PERFORM cohist_id
32376
 
  FROM cohist
32377
 
  WHERE (cohist_cust_id=pCustid)
32378
 
  LIMIT 1;
32379
 
  IF (FOUND) THEN
32380
 
    RETURN -4;
32381
 
  END IF;
32382
 
 
32383
 
  PERFORM aropen_id
32384
 
  FROM aropen
32385
 
  WHERE (aropen_cust_id=pCustid)
32386
 
  LIMIT 1;
32387
 
  IF (FOUND) THEN
32388
 
    RETURN -5;
32389
 
  END IF;
32390
 
 
32391
 
  PERFORM checkhead_recip_id
32392
 
    FROM checkhead
32393
 
   WHERE ((checkhead_recip_id=pCustid)
32394
 
     AND  (checkhead_recip_type='C'))
32395
 
   LIMIT 1;
32396
 
   IF (FOUND) THEN
32397
 
     RETURN -6;
32398
 
   END IF;
32399
 
 
32400
 
  PERFORM invchead_id
32401
 
     FROM invchead
32402
 
    WHERE(invchead_cust_id=pCustid)
32403
 
    LIMIT 1;
32404
 
  IF (FOUND) THEN
32405
 
    RETURN -7;
32406
 
  END IF;
32407
 
 
32408
 
  PERFORM quhead_id
32409
 
     FROM quhead
32410
 
    WHERE(quhead_cust_id=pCustid)
32411
 
    LIMIT 1;
32412
 
  IF (FOUND) THEN
32413
 
    RETURN -8;
32414
 
  END IF;
32415
 
 
32416
 
  DELETE FROM taxreg
32417
 
   WHERE ((taxreg_rel_type='C')
32418
 
     AND  (taxreg_rel_id=pCustid));
32419
 
 
32420
 
  DELETE FROM ipsass
32421
 
  WHERE (ipsass_cust_id=pCustid);
32422
 
 
32423
 
  DELETE FROM custinfo
32424
 
  WHERE (cust_id=pCustid);
32425
 
 
32426
 
  UPDATE crmacct SET crmacct_cust_id = NULL
32427
 
  WHERE (crmacct_cust_id=pCustid);
32428
 
 
32429
 
  RETURN 0;
32430
 
 
32431
 
END;
32432
 
$_$;
32433
 
 
32434
 
 
32435
 
ALTER FUNCTION public.deletecustomer(integer) OWNER TO admin;
32436
 
 
32437
 
--
32438
 
--
32439
 
 
32440
 
CREATE FUNCTION deletecustomertype(integer) RETURNS integer
32441
 
    LANGUAGE plpgsql
32442
 
    AS $_$
32443
 
DECLARE
32444
 
  pCusttypeid ALIAS FOR $1;
32445
 
 
32446
 
BEGIN
32447
 
 
32448
 
  IF EXISTS(SELECT 1
32449
 
              FROM custinfo
32450
 
             WHERE (cust_custtype_id=pCusttypeid)) THEN
32451
 
    RETURN -1;
32452
 
  END IF;
32453
 
 
32454
 
  DELETE FROM ipsass
32455
 
  WHERE (ipsass_custtype_id=pCusttypeid);
32456
 
 
32457
 
  DELETE FROM salesaccnt
32458
 
  WHERE (salesaccnt_custtype_id=pCusttypeid);
32459
 
 
32460
 
  DELETE FROM araccnt
32461
 
  WHERE (araccnt_custtype_id=pCusttypeid);
32462
 
 
32463
 
  DELETE FROM custform
32464
 
  WHERE (custform_custtype_id=pCusttypeid);
32465
 
 
32466
 
  DELETE FROM custtype
32467
 
  WHERE (custtype_id=pCusttypeid);
32468
 
 
32469
 
  RETURN pCusttypeid;
32470
 
 
32471
 
END;
32472
 
$_$;
32473
 
 
32474
 
 
32475
 
ALTER FUNCTION public.deletecustomertype(integer) OWNER TO admin;
32476
 
 
32477
 
--
32478
 
--
32479
 
 
32480
 
CREATE FUNCTION deleteempgrp(integer) RETURNS integer
32481
 
    LANGUAGE plpgsql
32482
 
    AS $_$
32483
 
DECLARE
32484
 
  pempgrpid ALIAS FOR $1;
32485
 
 
32486
 
BEGIN
32487
 
  PERFORM empgrpitem_emp_id
32488
 
  FROM empgrpitem
32489
 
  WHERE (empgrpitem_empgrp_id=pempgrpid)
32490
 
  LIMIT 1;
32491
 
  IF (FOUND) THEN
32492
 
    RETURN -1;
32493
 
  END IF;
32494
 
 
32495
 
  DELETE FROM empgrp     WHERE (empgrp_id=pempgrpid);
32496
 
 
32497
 
  RETURN 0;
32498
 
END;
32499
 
$_$;
32500
 
 
32501
 
 
32502
 
ALTER FUNCTION public.deleteempgrp(integer) OWNER TO admin;
32503
 
 
32504
 
--
32505
 
--
32506
 
 
32507
 
CREATE FUNCTION deleteexpiredips() RETURNS boolean
32508
 
    LANGUAGE plpgsql
32509
 
    AS $$
32510
 
DECLARE
32511
 
  _r RECORD;
32512
 
 
32513
 
BEGIN
32514
 
 
32515
 
  FOR _r IN SELECT ipshead_id
32516
 
    FROM ipshead
32517
 
    WHERE (ipshead_expires <= current_date)
32518
 
  LOOP
32519
 
 
32520
 
    DELETE FROM ipsass
32521
 
      WHERE (ipsass_ipshead_id=_r.ipshead_id);
32522
 
    DELETE FROM ipsiteminfo
32523
 
      WHERE (ipsitem_ipshead_id=_r.ipshead_id);
32524
 
    DELETE FROM ipsfreight
32525
 
      WHERE (ipsfreight_ipshead_id=_r.ipshead_id);
32526
 
    DELETE FROM ipshead
32527
 
      WHERE (ipshead_id=_r.ipshead_id);
32528
 
  END LOOP;
32529
 
 
32530
 
  RETURN TRUE;
32531
 
 
32532
 
END;
32533
 
$$;
32534
 
 
32535
 
 
32536
 
ALTER FUNCTION public.deleteexpiredips() OWNER TO admin;
32537
 
 
32538
 
--
32539
 
--
32540
 
 
32541
 
CREATE FUNCTION deletefile(integer) RETURNS boolean
32542
 
    LANGUAGE plpgsql
32543
 
    AS $_$
32544
 
declare
32545
 
  pId ALIAS FOR $1;
32546
 
begin
32547
 
  delete from file
32548
 
  where ( file_id in (
32549
 
    select file_id
32550
 
    from file
32551
 
      join docass on (docass_target_id=file_id)
32552
 
                 and (docass_target_type='FILE')
32553
 
    where ( docass_id = pId ) ) );
32554
 
 
32555
 
  delete from docass where docass_id = pId;
32556
 
 
32557
 
  return true;
32558
 
end;
32559
 
$_$;
32560
 
 
32561
 
 
32562
 
ALTER FUNCTION public.deletefile(integer) OWNER TO admin;
32563
 
 
32564
 
--
32565
 
--
32566
 
 
32567
 
CREATE FUNCTION deleteflgrp(integer) RETURNS integer
32568
 
    LANGUAGE plpgsql
32569
 
    AS $_$
32570
 
DECLARE
32571
 
  pFlgrpid ALIAS FOR $1;
32572
 
  _r RECORD;
32573
 
 
32574
 
BEGIN
32575
 
 
32576
 
  FOR _r IN SELECT flgrp_id
32577
 
            FROM flgrp
32578
 
            WHERE (flgrp_flgrp_id=pFlgrpid) LOOP
32579
 
    PERFORM deleteFlgrp(_r.flgrp_id);
32580
 
  END LOOP;
32581
 
 
32582
 
  DELETE FROM flitem
32583
 
  WHERE (flitem_flgrp_id=pFlgrpid);
32584
 
 
32585
 
  DELETE FROM flspec
32586
 
  WHERE (flspec_flgrp_id=pFlgrpid);
32587
 
 
32588
 
  DELETE FROM flgrp
32589
 
  WHERE (flgrp_id=pFlgrpid);
32590
 
 
32591
 
  RETURN 1;
32592
 
 
32593
 
END;
32594
 
$_$;
32595
 
 
32596
 
 
32597
 
ALTER FUNCTION public.deleteflgrp(integer) OWNER TO admin;
32598
 
 
32599
 
--
32600
 
--
32601
 
 
32602
 
CREATE FUNCTION deleteform(integer) RETURNS integer
32603
 
    LANGUAGE plpgsql
32604
 
    AS $_$
32605
 
DECLARE
32606
 
  pFormid ALIAS FOR $1;
32607
 
  _key TEXT;
32608
 
  _check INTEGER;
32609
 
 
32610
 
BEGIN
32611
 
 
32612
 
  SELECT form_key INTO _key
32613
 
  FROM form
32614
 
  WHERE (form_id=pFormid);
32615
 
  IF (NOT(FOUND)) THEN
32616
 
    RETURN 0;
32617
 
  END IF;
32618
 
 
32619
 
  IF (_key='Chck') THEN
32620
 
    SELECT bankaccnt_id INTO _check
32621
 
    FROM bankaccnt
32622
 
    WHERE (bankaccnt_check_form_id=pFormid)
32623
 
    LIMIT 1;
32624
 
    IF (FOUND) THEN
32625
 
      RETURN -1;
32626
 
    END IF;
32627
 
 
32628
 
  END IF;
32629
 
 
32630
 
  DELETE FROM form
32631
 
  WHERE (form_id=pFormid);
32632
 
 
32633
 
  RETURN pFormid;
32634
 
 
32635
 
END;
32636
 
$_$;
32637
 
 
32638
 
 
32639
 
ALTER FUNCTION public.deleteform(integer) OWNER TO admin;
32640
 
 
32641
 
--
32642
 
--
32643
 
 
32644
 
CREATE FUNCTION deletefreightclass(integer) RETURNS integer
32645
 
    LANGUAGE plpgsql
32646
 
    AS $_$
32647
 
DECLARE
32648
 
  pFreightClassid ALIAS FOR $1;
32649
 
  _check INTEGER;
32650
 
 
32651
 
BEGIN
32652
 
 
32653
 
  SELECT item_id INTO _check
32654
 
  FROM item
32655
 
  WHERE (item_freightclass_id=pFreightClassid)
32656
 
  LIMIT 1;
32657
 
  IF (FOUND) THEN
32658
 
    RETURN -1;
32659
 
  END IF;
32660
 
 
32661
 
  DELETE FROM freightclass
32662
 
  WHERE (freightclass_id=pFreightClassid);
32663
 
 
32664
 
  RETURN pFreightClassid;
32665
 
 
32666
 
END;
32667
 
$_$;
32668
 
 
32669
 
 
32670
 
ALTER FUNCTION public.deletefreightclass(integer) OWNER TO admin;
32671
 
 
32672
 
--
32673
 
--
32674
 
 
32675
 
CREATE FUNCTION deleteglseries(integer) RETURNS integer
32676
 
    LANGUAGE plpgsql
32677
 
    AS $_$
32678
 
DECLARE
32679
 
  pSequence ALIAS FOR $1;
32680
 
 
32681
 
BEGIN
32682
 
 
32683
 
  DELETE FROM glseries
32684
 
  WHERE (glseries_sequence=pSequence);
32685
 
 
32686
 
  RETURN pSequence;
32687
 
 
32688
 
END;
32689
 
$_$;
32690
 
 
32691
 
 
32692
 
ALTER FUNCTION public.deleteglseries(integer) OWNER TO admin;
32693
 
 
32694
 
--
32695
 
--
32696
 
 
32697
 
CREATE FUNCTION deleteglseries(integer, text) RETURNS boolean
32698
 
    LANGUAGE plpgsql
32699
 
    AS $_$
32700
 
DECLARE
32701
 
  pSequence ALIAS FOR $1;
32702
 
  pNotes ALIAS FOR $2;
32703
 
  _trialbalid INTEGER;
32704
 
  _count INTEGER;
32705
 
  _r RECORD;
32706
 
 
32707
 
BEGIN
32708
 
 
32709
 
  FOR _r IN SELECT gltrans_id, gltrans_date, gltrans_accnt_id, gltrans_amount, gltrans_posted, gltrans_rec,
32710
 
                   accnt_forwardupdate, period_id, period_closed, period_freeze
32711
 
            FROM accnt, gltrans LEFT OUTER JOIN period ON (gltrans_date BETWEEN period_start AND period_end)
32712
 
            WHERE ( (gltrans_accnt_id=accnt_id)
32713
 
             AND (NOT gltrans_deleted)
32714
 
             AND (gltrans_sequence=pSequence) ) LOOP
32715
 
 
32716
 
    IF ( (NOT _r.period_closed) AND 
32717
 
       ( (NOT _r.period_freeze) OR (checkPrivilege('PostFrozenPeriod')) ) AND
32718
 
       (  NOT _r.gltrans_rec) AND
32719
 
       ( _r.gltrans_posted ) ) THEN
32720
 
 
32721
 
      SELECT trialbal_id INTO _trialbalid
32722
 
      FROM trialbal
32723
 
      WHERE ( (trialbal_period_id=_r.period_id)
32724
 
       AND (trialbal_accnt_id=_r.gltrans_accnt_id) );
32725
 
 
32726
 
      GET DIAGNOSTICS _count = ROW_COUNT;
32727
 
      IF (_count > 0) THEN
32728
 
 
32729
 
        IF (_r.gltrans_amount > 0) THEN
32730
 
          UPDATE trialbal
32731
 
          SET trialbal_credits = (trialbal_credits - _r.gltrans_amount)
32732
 
          WHERE (trialbal_id=_trialbalid);
32733
 
        ELSE
32734
 
          UPDATE trialbal
32735
 
          SET trialbal_debits = (trialbal_debits - (_r.gltrans_amount * -1))
32736
 
          WHERE (trialbal_id=_trialbalid);
32737
 
        END IF;
32738
 
 
32739
 
        UPDATE trialbal
32740
 
        SET trialbal_ending = (trialbal_beginning - trialbal_debits + trialbal_credits),
32741
 
            trialbal_dirty=TRUE
32742
 
        WHERE (trialbal_id=_trialbalid);
32743
 
 
32744
 
      ELSE
32745
 
        RAISE EXCEPTION 'Can not delete G/L Series.  Trial balance record not found.';
32746
 
      END IF;
32747
 
 
32748
 
      IF (_r.accnt_forwardupdate AND fetchmetricbool('ManualForwardUpdate')) THEN
32749
 
        PERFORM forwardUpdateTrialBalance(_trialbalid);
32750
 
      END IF;
32751
 
 
32752
 
    DELETE FROM bankrecitem
32753
 
    WHERE ((bankrecitem_source='GL')
32754
 
    AND (bankrecitem_source_id=_r.gltrans_id));
32755
 
 
32756
 
    UPDATE sltrans SET
32757
 
      sltrans_posted=false,
32758
 
      sltrans_gltrans_journalnumber=null
32759
 
    FROM gltrans
32760
 
    WHERE ((gltrans_sequence=pSequence)
32761
 
    AND (sltrans_gltrans_journalnumber=gltrans_journalnumber));
32762
 
    
32763
 
      UPDATE gltrans SET
32764
 
        gltrans_posted=false,
32765
 
        gltrans_deleted=true,
32766
 
        gltrans_notes=gltrans_notes || E'\n' || pNotes
32767
 
      WHERE (gltrans_id=_r.gltrans_id);
32768
 
 
32769
 
    ELSIF (_r.period_freeze) THEN
32770
 
        RAISE EXCEPTION 'Can not delete a G/L Transaction in a frozen period';
32771
 
    ELSIF (_r.period_closed) THEN
32772
 
        RAISE EXCEPTION 'Can not delete a G/L Transaction on account % in a closed period', formatGlAccount(_r.gltrans_accnt_id);
32773
 
    ELSIF (_r.gltrans_rec) THEN
32774
 
        RAISE EXCEPTION 'Can not delete a G/L Transaction that has been reconciled';
32775
 
    ELSIF (NOT _r.gltrans_posted) THEN
32776
 
        RAISE EXCEPTION 'Can not delete a G/L Transaction that has not been posted to Trial Balance';
32777
 
    END IF;
32778
 
 
32779
 
  END LOOP;
32780
 
 
32781
 
  RETURN true;
32782
 
 
32783
 
END;
32784
 
$_$;
32785
 
 
32786
 
 
32787
 
ALTER FUNCTION public.deleteglseries(integer, text) OWNER TO admin;
32788
 
 
32789
 
--
32790
 
--
32791
 
 
32792
 
CREATE FUNCTION deleteincident(integer) RETURNS integer
32793
 
    LANGUAGE plpgsql
32794
 
    AS $_$
32795
 
DECLARE
32796
 
  pincdtid    ALIAS FOR $1;
32797
 
  _count      INTEGER := 0;
32798
 
  _incdtnbr   INTEGER := 0;
32799
 
BEGIN
32800
 
  SELECT COUNT(*) INTO _count
32801
 
  FROM todoitem
32802
 
  WHERE (todoitem_incdt_id=pincdtid);
32803
 
  IF (_count > 0) THEN
32804
 
    RETURN -1;
32805
 
  END IF;
32806
 
 
32807
 
  DELETE FROM comment
32808
 
   WHERE((comment_source='INCDT')
32809
 
     AND (comment_source_id=pincdtid));
32810
 
 
32811
 
  DELETE FROM incdthist
32812
 
   WHERE (incdthist_incdt_id=pincdtid);
32813
 
 
32814
 
  DELETE FROM imageass
32815
 
  WHERE ((imageass_source='INCDT')
32816
 
     AND (imageass_source_id=pincdtid));
32817
 
 
32818
 
  DELETE FROM url
32819
 
  WHERE ((url_source='INCDT')
32820
 
     AND (url_source_id=pincdtid));
32821
 
 
32822
 
  SELECT incdt_number INTO _incdtnbr
32823
 
  FROM incdt
32824
 
  WHERE (incdt_id=pincdtid);
32825
 
 
32826
 
  DELETE FROM incdt
32827
 
    WHERE (incdt_id=pincdtid);
32828
 
 
32829
 
 
32830
 
  RETURN 0;
32831
 
END;
32832
 
$_$;
32833
 
 
32834
 
 
32835
 
ALTER FUNCTION public.deleteincident(integer) OWNER TO admin;
32836
 
 
32837
 
--
32838
 
--
32839
 
 
32840
 
CREATE FUNCTION deleteinvoice(integer) RETURNS integer
32841
 
    LANGUAGE plpgsql
32842
 
    AS $_$
32843
 
DECLARE
32844
 
  pInvcheadid ALIAS FOR $1;
32845
 
  _cobmiscid INTEGER := -1;
32846
 
 
32847
 
BEGIN
32848
 
  UPDATE shipitem SET shipitem_invoiced=FALSE, shipitem_invcitem_id=NULL
32849
 
  FROM invcitem
32850
 
  WHERE ((shipitem_invoiced)
32851
 
    AND  (shipitem_invcitem_id=invcitem_id)
32852
 
    AND  (invcitem_invchead_id=pInvcheadid));
32853
 
 
32854
 
  UPDATE coitem SET coitem_status = 'O'
32855
 
  WHERE ((coitem_status = 'C')
32856
 
    AND  (coitem_id IN (SELECT cobill_coitem_id
32857
 
            FROM cobill, invcitem
32858
 
      WHERE ((cobill_invcitem_id=invcitem_id)
32859
 
        AND  (invcitem_invchead_id=pInvcheadid)))));
32860
 
 
32861
 
  UPDATE invdetail SET invdetail_invcitem_id=NULL
32862
 
  FROM invcitem
32863
 
  WHERE ((invdetail_invcitem_id=invcitem_id)
32864
 
    AND  (invcitem_invchead_id=pInvcheadid));
32865
 
 
32866
 
  -- Check for unposted cobmisc for the same S/O
32867
 
  -- If found then consolidate
32868
 
  SELECT cobmisc_id INTO _cobmiscid
32869
 
  FROM cobmisc
32870
 
  WHERE ((NOT cobmisc_posted)
32871
 
    AND  (cobmisc_cohead_id IN (SELECT coitem_cohead_id
32872
 
                                FROM invcitem JOIN coitem ON (coitem_id=invcitem_coitem_id)
32873
 
                                WHERE (invcitem_invchead_id=pInvcheadid))))
32874
 
  LIMIT 1;
32875
 
  IF (FOUND) THEN
32876
 
    UPDATE cobill SET cobill_invcnum=NULL, cobill_invcitem_id=NULL, cobill_cobmisc_id=_cobmiscid
32877
 
    FROM invcitem
32878
 
    WHERE ((cobill_invcitem_id=invcitem_id)
32879
 
      AND  (invcitem_invchead_id=pInvcheadid));
32880
 
 
32881
 
    DELETE FROM cobmisc
32882
 
    WHERE (cobmisc_invchead_id=pInvcheadid);
32883
 
  ELSE
32884
 
    UPDATE cobill SET cobill_invcnum=NULL, cobill_invcitem_id=NULL
32885
 
    FROM invcitem
32886
 
    WHERE ((cobill_invcitem_id=invcitem_id)
32887
 
      AND  (invcitem_invchead_id=pInvcheadid));
32888
 
 
32889
 
    UPDATE cobmisc SET cobmisc_invcnumber=NULL, cobmisc_invchead_id=NULL,
32890
 
         cobmisc_posted=FALSE
32891
 
    WHERE (cobmisc_invchead_id=pInvcheadid);
32892
 
  END IF;
32893
 
 
32894
 
  DELETE FROM aropenalloc
32895
 
  WHERE (aropenalloc_doctype='I')
32896
 
    AND (aropenalloc_doc_id=pInvcheadid);
32897
 
 
32898
 
  DELETE FROM charass
32899
 
  WHERE (charass_target_type='INV')
32900
 
    AND (charass_target_id=pInvcheadid);
32901
 
 
32902
 
  DELETE FROM invcitem
32903
 
  WHERE (invcitem_invchead_id=pInvcheadid);
32904
 
 
32905
 
  DELETE FROM invchead
32906
 
  WHERE (invchead_id=pInvcheadid);
32907
 
 
32908
 
  RETURN pInvcheadid;
32909
 
 
32910
 
END;
32911
 
$_$;
32912
 
 
32913
 
 
32914
 
ALTER FUNCTION public.deleteinvoice(integer) OWNER TO admin;
32915
 
 
32916
 
--
32917
 
--
32918
 
 
32919
 
CREATE FUNCTION deleteipsitem(pipsitemid integer) RETURNS integer
32920
 
    LANGUAGE plpgsql
32921
 
    AS $$
32922
 
DECLARE
32923
 
 
32924
 
BEGIN
32925
 
 
32926
 
  DELETE FROM ipsiteminfo WHERE ipsitem_id=pIpsItemId;
32927
 
 
32928
 
  RETURN 1;
32929
 
END;
32930
 
$$;
32931
 
 
32932
 
 
32933
 
ALTER FUNCTION public.deleteipsitem(pipsitemid integer) OWNER TO admin;
32934
 
 
32935
 
--
32936
 
--
32937
 
 
32938
 
CREATE FUNCTION deleteipsprodcat(pipsitemid integer) RETURNS integer
32939
 
    LANGUAGE plpgsql
32940
 
    AS $$
32941
 
DECLARE
32942
 
 
32943
 
BEGIN
32944
 
 
32945
 
  DELETE FROM ipsiteminfo WHERE ipsitem_id=pIpsItemId;
32946
 
  
32947
 
  RETURN 1;
32948
 
END;
32949
 
$$;
32950
 
 
32951
 
 
32952
 
ALTER FUNCTION public.deleteipsprodcat(pipsitemid integer) OWNER TO admin;
32953
 
 
32954
 
--
32955
 
--
32956
 
 
32957
 
CREATE FUNCTION deleteitem(integer) RETURNS integer
32958
 
    LANGUAGE plpgsql
32959
 
    AS $_$
32960
 
DECLARE
32961
 
  pItemid ALIAS FOR $1;
32962
 
  _result INTEGER;
32963
 
 
32964
 
BEGIN
32965
 
 
32966
 
  SELECT bomitem_id INTO _result
32967
 
  FROM bomitem
32968
 
  WHERE (bomitem_item_id=pItemid)
32969
 
  LIMIT 1;
32970
 
  IF (FOUND) THEN
32971
 
    RETURN -1;
32972
 
  END IF;
32973
 
 
32974
 
  SELECT itemsite_id INTO _result
32975
 
  FROM itemsite
32976
 
  WHERE (itemsite_item_id=pItemid)
32977
 
  LIMIT 1;
32978
 
  IF (FOUND) THEN
32979
 
    RETURN -2;
32980
 
  END IF;
32981
 
 
32982
 
  SELECT itemsub_id INTO _result
32983
 
  FROM itemsub
32984
 
  WHERE (itemsub_sub_item_id=pItemid)
32985
 
  LIMIT 1;
32986
 
  IF (FOUND) THEN
32987
 
    RETURN -3;
32988
 
  END IF;
32989
 
 
32990
 
  IF (fetchmetricbool('RevControl')) THEN
32991
 
    SELECT rev_id INTO _result
32992
 
    FROM rev
32993
 
    WHERE ((rev_target_id=pItemid)
32994
 
    AND (rev_target_type = 'BOM'))
32995
 
    LIMIT 1;
32996
 
    IF (FOUND) THEN
32997
 
      RETURN -6;
32998
 
    END IF;
32999
 
  END IF;
33000
 
 
33001
 
  DELETE FROM bomhead
33002
 
  WHERE (bomhead_item_id=pItemid);
33003
 
  DELETE FROM bomitem
33004
 
  WHERE (bomitem_item_id=pItemid);
33005
 
 
33006
 
  DELETE FROM itemcost
33007
 
  WHERE (itemcost_item_id=pItemid);
33008
 
  DELETE FROM costhist
33009
 
  WHERE (costhist_item_id=pItemid);
33010
 
 
33011
 
  DELETE FROM itemsub
33012
 
  WHERE (itemsub_parent_item_id=pItemid);
33013
 
  DELETE FROM itemsub
33014
 
  WHERE (itemsub_sub_item_id=pItemid);
33015
 
 
33016
 
  DELETE FROM itemsrcp
33017
 
  WHERE (itemsrcp_itemsrc_id IN (SELECT itemsrc_id FROM itemsrc WHERE (itemsrc_item_id=pItemid)));
33018
 
  DELETE FROM itemsrc
33019
 
  WHERE (itemsrc_item_id=pItemid);
33020
 
 
33021
 
  DELETE FROM itemalias
33022
 
  WHERE (itemalias_item_id=pItemid);
33023
 
 
33024
 
  DELETE FROM itemgrpitem
33025
 
  WHERE (itemgrpitem_item_id=pItemid);
33026
 
 
33027
 
  DELETE FROM ipsiteminfo
33028
 
  WHERE (ipsitem_item_id=pItemid);
33029
 
 
33030
 
  DELETE FROM imageass
33031
 
  WHERE ( (imageass_source='I')
33032
 
    AND   (imageass_source_id=pItemid) );
33033
 
 
33034
 
  DELETE FROM locitem
33035
 
  WHERE (locitem_item_id=pItemid);
33036
 
 
33037
 
  DELETE FROM itemtax
33038
 
   WHERE(itemtax_item_id=pItemid);
33039
 
 
33040
 
  DELETE FROM itemsite
33041
 
  WHERE (itemsite_item_id=pItemid);
33042
 
 
33043
 
  DELETE FROM itemuom
33044
 
   WHERE(itemuom_itemuomconv_id IN (SELECT itemuomconv_id
33045
 
                                      FROM itemuomconv
33046
 
                                     WHERE(itemuomconv_item_id=pItemid)));
33047
 
 
33048
 
  DELETE FROM itemuomconv
33049
 
   WHERE(itemuomconv_item_id=pItemid);
33050
 
 
33051
 
  DELETE FROM item
33052
 
  WHERE (item_id=pItemid);
33053
 
 
33054
 
  RETURN 0;
33055
 
 
33056
 
END;
33057
 
$_$;
33058
 
 
33059
 
 
33060
 
ALTER FUNCTION public.deleteitem(integer) OWNER TO admin;
33061
 
 
33062
 
--
33063
 
--
33064
 
 
33065
 
CREATE FUNCTION deleteitemcost(integer, integer) RETURNS integer
33066
 
    LANGUAGE plpgsql
33067
 
    AS $_$
33068
 
DECLARE
33069
 
  pItemId ALIAS FOR $1;
33070
 
  pCostElemId ALIAS FOR $2;
33071
 
  _itemcost_id INTEGER;
33072
 
  _postcost_return BOOLEAN;
33073
 
  _std_cost NUMERIC;
33074
 
 
33075
 
BEGIN
33076
 
  SELECT itemcost_id INTO _itemcost_id
33077
 
  FROM itemcost
33078
 
  WHERE ( (itemcost_item_id = pItemId) AND (itemcost_costelem_id = pCostElemId) );
33079
 
 
33080
 
  IF (NOT FOUND) THEN
33081
 
        RAISE EXCEPTION 'itemcost % not found for. ', pItemId || ' & ' || pCostElemId;
33082
 
  END IF;
33083
 
 
33084
 
  SELECT itemcost_stdcost INTO _std_cost
33085
 
  FROM itemcost
33086
 
  WHERE (itemcost_id = _itemcost_id);
33087
 
 
33088
 
  IF (_std_cost > 0) THEN
33089
 
--Actual Cost is updated to zero to ensure inventory is valued correctly
33090
 
    PERFORM updateCost(_itemcost_id, 0);
33091
 
  END IF;
33092
 
 
33093
 
  DELETE FROM itemcost
33094
 
  WHERE (itemcost_id=_itemcost_id);
33095
 
 
33096
 
  RETURN _itemcost_id;  
33097
 
 
33098
 
END;
33099
 
$_$;
33100
 
 
33101
 
 
33102
 
ALTER FUNCTION public.deleteitemcost(integer, integer) OWNER TO admin;
33103
 
 
33104
 
--
33105
 
--
33106
 
 
33107
 
CREATE FUNCTION deleteitemsite(pitemsiteid integer) RETURNS integer
33108
 
    LANGUAGE plpgsql
33109
 
    AS $$
33110
 
DECLARE
33111
 
  _result INTEGER;
33112
 
  _lotserial BOOLEAN;
33113
 
  _bbom BOOLEAN;
33114
 
  _mfg BOOLEAN;
33115
 
  _standard BOOLEAN;
33116
 
 
33117
 
BEGIN
33118
 
 
33119
 
  IF ( ( SELECT (itemsite_qtyonhand <> 0)
33120
 
         FROM itemsite
33121
 
         WHERE (itemsite_id=pItemsiteid) ) ) THEN
33122
 
    RETURN -9;
33123
 
  END IF;
33124
 
 
33125
 
  SELECT metric_value='t' INTO _bbom
33126
 
    FROM metric
33127
 
   WHERE (metric_name='BBOM');
33128
 
 
33129
 
  SELECT metric_value='t' INTO _lotserial
33130
 
    FROM metric
33131
 
   WHERE (metric_name='LotSerialControl');
33132
 
 
33133
 
  SELECT metric_value NOT IN ('PostBooks', 'Standard') INTO _mfg
33134
 
    FROM metric
33135
 
   WHERE (metric_name='Application');
33136
 
 
33137
 
  SELECT metric_value='Standard' INTO _standard
33138
 
    FROM metric
33139
 
   WHERE (metric_name='Application');
33140
 
 
33141
 
  SELECT invhist_id INTO _result
33142
 
  FROM invhist
33143
 
  WHERE (invhist_itemsite_id=pItemsiteid)
33144
 
  LIMIT 1;
33145
 
  IF (FOUND) THEN
33146
 
    RETURN -1;
33147
 
  END IF;
33148
 
 
33149
 
  IF (_lotserial) THEN
33150
 
    SELECT lsdetail_id INTO _result
33151
 
    FROM lsdetail
33152
 
    WHERE (lsdetail_itemsite_id=pItemsiteid)
33153
 
    LIMIT 1;
33154
 
    IF (FOUND) THEN
33155
 
      RETURN -1;
33156
 
    END IF;
33157
 
  END IF;
33158
 
 
33159
 
  SELECT wo_id INTO _result
33160
 
  FROM wo
33161
 
  WHERE (wo_itemsite_id=pItemsiteid)
33162
 
  LIMIT 1;
33163
 
  IF (FOUND) THEN
33164
 
    RETURN -2;
33165
 
  END IF;
33166
 
 
33167
 
  SELECT womatl_id INTO _result
33168
 
  FROM womatl
33169
 
  WHERE (womatl_itemsite_id=pItemsiteid)
33170
 
  LIMIT 1;
33171
 
  IF (FOUND) THEN
33172
 
    RETURN -2;
33173
 
  END IF;
33174
 
 
33175
 
  SELECT womatlvar_id INTO _result
33176
 
  FROM womatlvar
33177
 
  WHERE ( (womatlvar_parent_itemsite_id=pItemsiteid)
33178
 
   OR (womatlvar_component_itemsite_id=pItemsiteid) )
33179
 
  LIMIT 1;
33180
 
  IF (FOUND) THEN
33181
 
    RETURN -2;
33182
 
  END IF;
33183
 
 
33184
 
  IF (_bbom) THEN
33185
 
    SELECT brdvar_id INTO _result
33186
 
    FROM xtmfg.brdvar
33187
 
    WHERE ( (brdvar_itemsite_id=pItemsiteid)
33188
 
     OR (brdvar_parent_itemsite_id=pItemsiteid) )
33189
 
    LIMIT 1;
33190
 
    IF (FOUND) THEN
33191
 
      RETURN -2;
33192
 
    END IF;
33193
 
  END IF;
33194
 
 
33195
 
  SELECT coitem_id INTO _result
33196
 
  FROM coitem
33197
 
  WHERE (coitem_itemsite_id=pItemsiteid)
33198
 
  LIMIT 1;
33199
 
  IF (FOUND) THEN
33200
 
    RETURN -3;
33201
 
  END IF;
33202
 
 
33203
 
  SELECT cohist_id INTO _result
33204
 
  FROM cohist
33205
 
  WHERE (cohist_itemsite_id=pItemsiteid)
33206
 
  LIMIT 1;
33207
 
  IF (FOUND) THEN
33208
 
    RETURN -3;
33209
 
  END IF;
33210
 
 
33211
 
  SELECT quitem_id INTO _result
33212
 
  FROM quitem
33213
 
  WHERE (quitem_itemsite_id=pItemsiteid)
33214
 
  LIMIT 1;
33215
 
  IF (FOUND) THEN
33216
 
    RETURN -3;
33217
 
  END IF;
33218
 
 
33219
 
  SELECT cmitem_id INTO _result
33220
 
  FROM cmitem
33221
 
  WHERE (cmitem_itemsite_id=pItemsiteid)
33222
 
  LIMIT 1;
33223
 
  IF (FOUND) THEN
33224
 
    RETURN -3;
33225
 
  END IF;
33226
 
 
33227
 
 
33228
 
  SELECT poitem_id INTO _result
33229
 
  FROM poitem
33230
 
  WHERE (poitem_itemsite_id=pItemsiteid)
33231
 
  LIMIT 1;
33232
 
  IF (FOUND) THEN
33233
 
    RETURN -4;
33234
 
  END IF;
33235
 
 
33236
 
  SELECT recv_id INTO _result
33237
 
  FROM recv
33238
 
  WHERE (recv_itemsite_id=pItemsiteid)
33239
 
  LIMIT 1;
33240
 
  IF (FOUND) THEN
33241
 
    RETURN -4;
33242
 
  END IF;
33243
 
 
33244
 
  SELECT poreject_id INTO _result
33245
 
  FROM poreject
33246
 
  WHERE (poreject_itemsite_id=pItemsiteid)
33247
 
  LIMIT 1;
33248
 
  IF (FOUND) THEN
33249
 
    RETURN -4;
33250
 
  END IF;
33251
 
 
33252
 
  SELECT pr_id INTO _result
33253
 
  FROM pr
33254
 
  WHERE (pr_itemsite_id=pItemsiteid)
33255
 
  LIMIT 1;
33256
 
  IF (FOUND) THEN
33257
 
    RETURN -4;
33258
 
  END IF;
33259
 
 
33260
 
  IF (_mfg OR _standard) THEN
33261
 
    SELECT planord_id INTO _result
33262
 
    FROM planord
33263
 
    WHERE (planord_itemsite_id=pItemsiteid)
33264
 
    LIMIT 1;
33265
 
    IF (FOUND) THEN
33266
 
      RETURN -5;
33267
 
    END IF;
33268
 
  END IF;
33269
 
 
33270
 
  IF (_mfg) THEN
33271
 
    SELECT pschitem_id INTO _result
33272
 
    FROM xtmfg.pschitem
33273
 
    WHERE (pschitem_itemsite_id=pItemsiteid)
33274
 
    LIMIT 1;
33275
 
    IF (FOUND) THEN
33276
 
      RETURN -6;
33277
 
    END IF;
33278
 
 
33279
 
    SELECT woopervar_id INTO _result
33280
 
    FROM xtmfg.woopervar
33281
 
    WHERE (woopervar_parent_itemsite_id=pItemsiteid)
33282
 
    LIMIT 1;
33283
 
    IF (FOUND) THEN
33284
 
      RETURN -2;
33285
 
    END IF;
33286
 
    
33287
 
  END IF;
33288
 
 
33289
 
  IF (_mfg OR _standard) THEN
33290
 
    SELECT itemsite_id INTO _result
33291
 
    FROM itemsite
33292
 
    WHERE (itemsite_supply_itemsite_id=pItemsiteid)
33293
 
    LIMIT 1;
33294
 
    IF (FOUND) THEN
33295
 
      RETURN -7;
33296
 
    END IF;
33297
 
  END IF;
33298
 
 
33299
 
  DELETE FROM invcnt
33300
 
  WHERE (invcnt_itemsite_id=pItemsiteid);
33301
 
 
33302
 
  DELETE FROM itemloc
33303
 
  WHERE (itemloc_itemsite_id=pItemsiteid);
33304
 
  DELETE FROM itemlocdist
33305
 
  WHERE (itemlocdist_itemsite_id=pItemsiteid);
33306
 
 
33307
 
  IF (_bbom) THEN
33308
 
    DELETE FROM xtmfg.brddist
33309
 
    WHERE (brddist_itemsite_id=pItemsiteid);
33310
 
  END IF;
33311
 
 
33312
 
  DELETE FROM itemsite
33313
 
  WHERE (itemsite_id=pItemsiteid);
33314
 
 
33315
 
  RETURN 0;
33316
 
 
33317
 
END;
33318
 
$$;
33319
 
 
33320
 
 
33321
 
ALTER FUNCTION public.deleteitemsite(pitemsiteid integer) OWNER TO admin;
33322
 
 
33323
 
--
33324
 
--
33325
 
 
33326
 
CREATE FUNCTION deleteitemuom(integer) RETURNS integer
33327
 
    LANGUAGE plpgsql
33328
 
    AS $_$
33329
 
DECLARE
33330
 
  pItemuomid ALIAS FOR $1;
33331
 
 
33332
 
BEGIN
33333
 
  DELETE FROM itemuom WHERE itemuom_id=pItemuomid;
33334
 
 
33335
 
  RETURN 0;
33336
 
END;
33337
 
$_$;
33338
 
 
33339
 
 
33340
 
ALTER FUNCTION public.deleteitemuom(integer) OWNER TO admin;
33341
 
 
33342
 
--
33343
 
--
33344
 
 
33345
 
CREATE FUNCTION deleteitemuomconv(integer) RETURNS integer
33346
 
    LANGUAGE plpgsql
33347
 
    AS $_$
33348
 
DECLARE
33349
 
  pItemuomconvid ALIAS FOR $1;
33350
 
  _fromuomid     INTEGER;
33351
 
  _invuomid      INTEGER;
33352
 
  _itemid        INTEGER;
33353
 
  _touomid       INTEGER;
33354
 
 
33355
 
BEGIN
33356
 
  SELECT itemuomconv_item_id, item_inv_uom_id,
33357
 
         itemuomconv_from_uom_id, itemuomconv_to_uom_id
33358
 
          INTO _itemid, _invuomid, _fromuomid, _touomid
33359
 
  FROM itemuomconv JOIN item ON (itemuomconv_item_id=item_id)
33360
 
  WHERE (itemuomconv_id=pItemuomconvid);
33361
 
 
33362
 
  IF EXISTS(SELECT *
33363
 
            FROM uomusedforitem(_itemid)
33364
 
            WHERE ((uom_id IN (_fromuomid, _touomid))
33365
 
               AND (uom_id != _invuomid)) ) THEN
33366
 
    RETURN -1;
33367
 
  END IF;
33368
 
 
33369
 
  DELETE FROM itemuom WHERE itemuom_itemuomconv_id=pItemuomconvid;
33370
 
  DELETE FROM itemuomconv WHERE itemuomconv_id=pItemuomconvid;
33371
 
 
33372
 
  RETURN 0;
33373
 
END;
33374
 
$_$;
33375
 
 
33376
 
 
33377
 
ALTER FUNCTION public.deleteitemuomconv(integer) OWNER TO admin;
33378
 
 
33379
 
--
33380
 
--
33381
 
 
33382
 
CREATE FUNCTION deletelocation(integer) RETURNS integer
33383
 
    LANGUAGE plpgsql
33384
 
    AS $_$
33385
 
DECLARE
33386
 
  pLocationid ALIAS FOR $1;
33387
 
  _check INTEGER;
33388
 
 
33389
 
BEGIN
33390
 
 
33391
 
  SELECT itemsite_id INTO _check
33392
 
  FROM itemsite
33393
 
  WHERE (itemsite_location_id=pLocationid)
33394
 
  LIMIT 1;
33395
 
  IF (FOUND) THEN
33396
 
    RETURN -1;
33397
 
  END IF;
33398
 
 
33399
 
  SELECT itemloc_id INTO _check
33400
 
  FROM itemloc
33401
 
  WHERE (itemloc_location_id=pLocationid)
33402
 
  LIMIT 1;
33403
 
  IF (FOUND) THEN
33404
 
    RETURN -2;
33405
 
  END IF;
33406
 
 
33407
 
  SELECT itemlocdist_id INTO _check
33408
 
  FROM itemlocdist
33409
 
  WHERE ( (itemlocdist_source_type='L')
33410
 
  AND (itemlocdist_source_id=pLocationid) )
33411
 
  LIMIT 1;
33412
 
  IF (FOUND) THEN
33413
 
    RETURN -3;
33414
 
  END IF;
33415
 
 
33416
 
  SELECT invdetail_id INTO _check
33417
 
  FROM invdetail
33418
 
  WHERE (invdetail_location_id=pLocationid)
33419
 
  LIMIT 1;
33420
 
  IF (FOUND) THEN
33421
 
    RETURN -4;
33422
 
  END IF;
33423
 
 
33424
 
  DELETE FROM locitem
33425
 
  WHERE (locitem_location_id=pLocationid);
33426
 
 
33427
 
  DELETE FROM location
33428
 
  WHERE (location_id=pLocationid);
33429
 
 
33430
 
  RETURN pLocationid;
33431
 
 
33432
 
END;
33433
 
$_$;
33434
 
 
33435
 
 
33436
 
ALTER FUNCTION public.deletelocation(integer) OWNER TO admin;
33437
 
 
33438
 
--
33439
 
--
33440
 
 
33441
 
CREATE FUNCTION deletemetasql(integer) RETURNS integer
33442
 
    LANGUAGE plpgsql
33443
 
    AS $_$
33444
 
DECLARE
33445
 
  pid ALIAS FOR $1;
33446
 
BEGIN
33447
 
  DELETE FROM metasql WHERE metasql_id = pid;
33448
 
  RETURN 0;
33449
 
END;
33450
 
$_$;
33451
 
 
33452
 
 
33453
 
ALTER FUNCTION public.deletemetasql(integer) OWNER TO admin;
33454
 
 
33455
 
--
33456
 
--
33457
 
 
33458
 
CREATE FUNCTION deleteopenrecurringitems(integer, text, timestamp with time zone, boolean) RETURNS integer
33459
 
    LANGUAGE plpgsql
33460
 
    AS $_$
33461
 
DECLARE
33462
 
  pParentid     ALIAS FOR $1;
33463
 
  pType         TEXT                     := UPPER($2);
33464
 
  pDatetime     TIMESTAMP WITH TIME ZONE := COALESCE($3, startOfTime());
33465
 
  pInclParent   BOOLEAN                  := COALESCE($4, FALSE);
33466
 
 
33467
 
  _count         INTEGER := 0;
33468
 
  _delchildstmt  TEXT;
33469
 
  _delparentstmt TEXT;
33470
 
  _rt            RECORD;
33471
 
  _tmp           INTEGER;
33472
 
BEGIN
33473
 
  RAISE DEBUG 'deleteOpenRecurringItems(%, %, %)', pParentid, pType, pDatetime;
33474
 
 
33475
 
  IF (pParentid IS NULL) THEN
33476
 
    RETURN -11;
33477
 
  END IF;
33478
 
 
33479
 
  SELECT * INTO _rt FROM recurtype WHERE (UPPER(recurtype_type)=pType);
33480
 
  GET DIAGNOSTICS _count = ROW_COUNT;
33481
 
  IF (_count <= 0) THEN
33482
 
    RETURN -10;
33483
 
  END IF;
33484
 
 
33485
 
  -- 2 deletes avoid reparenting problems if the parent gets deleted first
33486
 
  IF (_rt.recurtype_delfunc IS NULL) THEN
33487
 
    _delchildstmt := 'DELETE FROM [fulltable] '
33488
 
                  || ' WHERE (NOT ([done])'
33489
 
                  || '    AND ([schedcol]>''$2'')'
33490
 
                  || '    AND ([table]_recurring_[table]_id=$1)'
33491
 
                  || '    AND ([table]_id!=$1));';
33492
 
 
33493
 
    _delparentstmt := 'DELETE FROM [fulltable] USING recur'
33494
 
                   || ' WHERE (NOT ([done])'
33495
 
                   || '    AND ([schedcol]>''$2'')'
33496
 
                   || '    AND ([table]_recurring_[table]_id=$1)'
33497
 
                   || '    AND ([table]_id=$1));';
33498
 
 
33499
 
  ELSE
33500
 
    _delchildstmt := 'SELECT [delfunc]([table]_id)'
33501
 
                  || '  FROM [fulltable] '
33502
 
                  || ' WHERE (NOT ([done])'
33503
 
                  || '    AND ([schedcol]>''$2'')'
33504
 
                  || '    AND ([table]_recurring_[table]_id=$1)'
33505
 
                  || '    AND ([table]_id!=$1));';
33506
 
    _delparentstmt := 'SELECT [delfunc]([table]_id)'
33507
 
                   || '  FROM [fulltable] '
33508
 
                   || ' WHERE (NOT ([done])'
33509
 
                   || '    AND ([schedcol]>''$2'')'
33510
 
                   || '    AND ([table]_recurring_[table]_id=$1)'
33511
 
                   || '    AND ([table]_id!=$1));';
33512
 
    _delchildstmt  := REPLACE(_delchildstmt,  '[delfunc]', _rt.recurtype_delfunc);
33513
 
    _delparentstmt := REPLACE(_delparentstmt, '[delfunc]', _rt.recurtype_delfunc);
33514
 
  END IF;
33515
 
 
33516
 
  RAISE DEBUG '_delchildstmt has been set to %', _delchildstmt;
33517
 
 
33518
 
  _delchildstmt := REPLACE(_delchildstmt, '[fulltable]', _rt.recurtype_table);
33519
 
  _delchildstmt := REPLACE(_delchildstmt, '[table]',
33520
 
                            REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', ''));
33521
 
  _delchildstmt := REPLACE(_delchildstmt, '[done]',  _rt.recurtype_donecheck);
33522
 
  _delchildstmt := REPLACE(_delchildstmt, '[schedcol]', _rt.recurtype_schedcol);
33523
 
 
33524
 
  _delparentstmt := REPLACE(_delparentstmt, '[fulltable]', _rt.recurtype_table);
33525
 
  _delparentstmt := REPLACE(_delparentstmt, '[table]',
33526
 
                            REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', ''));
33527
 
  _delparentstmt := REPLACE(_delparentstmt, '[done]',  _rt.recurtype_donecheck);
33528
 
  _delparentstmt := REPLACE(_delparentstmt, '[schedcol]', _rt.recurtype_schedcol);
33529
 
 
33530
 
  RAISE DEBUG 'substitutions changed _delchildstmt to %', _delchildstmt;
33531
 
 
33532
 
  IF (_rt.recurtype_delfunc IS NULL) THEN
33533
 
    -- 8.4+: EXECUTE _delchildstmt  USING pDatetime, pType;
33534
 
    RAISE DEBUG '% with % and %', _delchildstmt, pType, pDatetime;
33535
 
    EXECUTE REPLACE(REPLACE(_delchildstmt, '$1', pParentid::TEXT),
33536
 
                                           '$2', pDatetime::TEXT);
33537
 
    GET DIAGNOSTICS _count = ROW_COUNT;
33538
 
 
33539
 
    IF (pInclParent) THEN
33540
 
      -- 8.4+: EXECUTE _delparentstmt USING pDatetime, pType;
33541
 
      RAISE DEBUG '% with % and %', _delparentstmt, pType, pDatetime;
33542
 
      EXECUTE REPLACE(REPLACE(_delparentstmt, '$1', pParentid::TEXT),
33543
 
                                              '$2', pDatetime::TEXT);
33544
 
      GET DIAGNOSTICS _tmp   = ROW_COUNT;
33545
 
      _count := _count + _tmp;
33546
 
    END IF;
33547
 
 
33548
 
  ELSE
33549
 
    -- 8.4+: FOR _tmp IN EXECUTE _delchildstmt USING pDatetime, pType LOOP
33550
 
    FOR _tmp IN EXECUTE REPLACE(REPLACE(_delchildstmt, '$1', pParentid::TEXT),
33551
 
                                                       '$2', pDatetime::TEXT)
33552
 
    LOOP
33553
 
      IF _tmp < 0 THEN
33554
 
        RETURN _tmp;
33555
 
      END IF;
33556
 
      _count := _count + 1;
33557
 
    END LOOP;
33558
 
 
33559
 
    IF (pInclParent) THEN
33560
 
      -- 8.4+: EXECUTE _delparentstmt INTO _tmp USING pDatetime, pType;
33561
 
      EXECUTE REPLACE(REPLACE(_delparentstmt, '$1', pParentid::TEXT),
33562
 
                                              '$2', pDatetime::TEXT) INTO _tmp;
33563
 
      IF (_tmp < 0) THEN
33564
 
        RETURN _tmp;
33565
 
      END IF;
33566
 
      _count := _count + 1;
33567
 
    END IF;
33568
 
  END IF;
33569
 
 
33570
 
  RAISE DEBUG 'deleteOpenrecurringItems() returning %', _count;
33571
 
  RETURN _count;
33572
 
END;
33573
 
$_$;
33574
 
 
33575
 
 
33576
 
ALTER FUNCTION public.deleteopenrecurringitems(integer, text, timestamp with time zone, boolean) OWNER TO admin;
33577
 
 
33578
 
--
33579
 
--
33580
 
 
33581
 
CREATE FUNCTION deleteopportunity(integer) RETURNS integer
33582
 
    LANGUAGE plpgsql
33583
 
    AS $_$
33584
 
DECLARE
33585
 
  pOpheadid ALIAS FOR $1;
33586
 
  _test INTEGER;
33587
 
BEGIN
33588
 
 
33589
 
  SELECT todoitem_id INTO _test
33590
 
    FROM todoitem
33591
 
   WHERE(todoitem_ophead_id=pOpheadid)
33592
 
   LIMIT 1;
33593
 
  IF(FOUND) THEN
33594
 
    RETURN -1;
33595
 
  END IF;
33596
 
 
33597
 
  SELECT quhead_id INTO _test
33598
 
    FROM quhead
33599
 
   WHERE(quhead_ophead_id=pOpheadid)
33600
 
   LIMIT 1;
33601
 
  IF(FOUND) THEN
33602
 
    RETURN -2;
33603
 
  END IF;
33604
 
 
33605
 
  SELECT cohead_id INTO _test
33606
 
    FROM cohead
33607
 
   WHERE(cohead_ophead_id=pOpheadid)
33608
 
   LIMIT 1;
33609
 
  IF(FOUND) THEN
33610
 
    RETURN -3;
33611
 
  END IF;
33612
 
 
33613
 
  DELETE
33614
 
    FROM charass
33615
 
   WHERE((charass_target_type='OPP')
33616
 
     AND (charass_target_id=pOpheadid));
33617
 
 
33618
 
  DELETE
33619
 
    FROM comment
33620
 
   WHERE((comment_source='OPP')
33621
 
     AND (comment_source_id=pOpheadid));
33622
 
 
33623
 
  DELETE
33624
 
    FROM ophead
33625
 
   WHERE(ophead_id=pOpheadid);
33626
 
  
33627
 
  return 0;
33628
 
END;
33629
 
$_$;
33630
 
 
33631
 
 
33632
 
ALTER FUNCTION public.deleteopportunity(integer) OWNER TO admin;
33633
 
 
33634
 
--
33635
 
--
33636
 
 
33637
 
CREATE FUNCTION deletepackage(integer) RETURNS integer
33638
 
    LANGUAGE plpgsql
33639
 
    AS $_$
33640
 
DECLARE
33641
 
  ppkgheadid    ALIAS FOR $1;
33642
 
  _i            INTEGER := 0;
33643
 
  _pkgname      TEXT;
33644
 
  _r            RECORD;
33645
 
  _tabs         TEXT[] := ARRAY['cmd',  'cmdarg', 'image',  'metasql',
33646
 
                                'priv', 'report', 'script', 'uiform'];
33647
 
  _debug        BOOL := false;
33648
 
 
33649
 
BEGIN
33650
 
  IF (EXISTS(SELECT *
33651
 
             FROM pkgdep
33652
 
             WHERE (pkgdep_parent_pkghead_id=ppkgheadid))) THEN
33653
 
    RETURN -1;
33654
 
  END IF;
33655
 
 
33656
 
  SELECT pkghead_name INTO _pkgname
33657
 
  FROM pkghead
33658
 
  WHERE (pkghead_id=ppkgheadid);
33659
 
  IF (NOT FOUND) THEN
33660
 
    RETURN -2;
33661
 
  END IF;
33662
 
 
33663
 
  IF (LOWER(_pkgname) = 'public' OR LOWER(_pkgname) = 'api') THEN
33664
 
    RETURN -3;
33665
 
  END IF;
33666
 
 
33667
 
  FOR _i IN ARRAY_LOWER(_tabs,1)..ARRAY_UPPER(_tabs,1) LOOP
33668
 
    EXECUTE 'ALTER TABLE ' || _pkgname || '.pkg' || _tabs[_i] ||
33669
 
            ' DISABLE TRIGGER pkg' || _tabs[_i] || 'altertrigger;';
33670
 
  END LOOP;
33671
 
 
33672
 
  DELETE FROM pkghead WHERE pkghead_id=ppkgheadid;
33673
 
 
33674
 
  RETURN ppkgheadid;
33675
 
END;
33676
 
$_$;
33677
 
 
33678
 
 
33679
 
ALTER FUNCTION public.deletepackage(integer) OWNER TO admin;
33680
 
 
33681
 
--
33682
 
--
33683
 
 
33684
 
CREATE FUNCTION deletepo(integer) RETURNS boolean
33685
 
    LANGUAGE plpgsql
33686
 
    AS $_$
33687
 
DECLARE
33688
 
  pPoheadid ALIAS FOR $1;
33689
 
  _poitemid INTEGER;
33690
 
 
33691
 
BEGIN
33692
 
 
33693
 
  IF ( ( SELECT pohead_status
33694
 
         FROM pohead
33695
 
         WHERE (pohead_id=pPoheadid) ) = 'U' ) THEN
33696
 
 
33697
 
    -- Unlink from any Sales Orders
33698
 
    UPDATE coitem SET coitem_order_type=NULL,
33699
 
                      coitem_order_id=NULL
33700
 
    FROM poitem 
33701
 
    WHERE ( (coitem_order_type='P')
33702
 
      AND   (coitem_order_id=poitem_id)
33703
 
      AND   (poitem_pohead_id=pPoheadid) );
33704
 
 
33705
 
    DELETE FROM poitem
33706
 
    WHERE (poitem_pohead_id=pPoheadid);
33707
 
 
33708
 
    DELETE FROM pohead
33709
 
    WHERE (pohead_id=pPoheadid);
33710
 
 
33711
 
    RETURN TRUE;
33712
 
 
33713
 
  ELSE
33714
 
    RETURN FALSE;
33715
 
  END IF;
33716
 
 
33717
 
END;
33718
 
$_$;
33719
 
 
33720
 
 
33721
 
ALTER FUNCTION public.deletepo(integer) OWNER TO admin;
33722
 
 
33723
 
--
33724
 
--
33725
 
 
33726
 
CREATE FUNCTION deletepoitem(integer) RETURNS integer
33727
 
    LANGUAGE plpgsql
33728
 
    AS $_$
33729
 
DECLARE
33730
 
  pPoitemid ALIAS FOR $1;
33731
 
  _poheadid INTEGER := -1;
33732
 
  _status CHARACTER;
33733
 
 
33734
 
BEGIN
33735
 
  SELECT poitem_pohead_id, poitem_status INTO _poheadid, _status
33736
 
  FROM poitem
33737
 
  WHERE (poitem_id=pPoitemid);
33738
 
 
33739
 
  IF NOT(FOUND) THEN
33740
 
    RETURN 0;
33741
 
  END IF;
33742
 
 
33743
 
  IF ( _status = 'U' ) THEN
33744
 
    DELETE FROM poitem
33745
 
    WHERE (poitem_id=pPoitemid);
33746
 
  ELSE   
33747
 
    IF ( _status = 'O' ) THEN
33748
 
      PERFORM recv_id
33749
 
      FROM recv
33750
 
      WHERE ( (recv_order_type='PO')
33751
 
       AND (recv_orderitem_id=pPoitemid) );
33752
 
      IF (FOUND) THEN
33753
 
        RETURN -10;
33754
 
      ELSE
33755
 
        RETURN -20;
33756
 
      END IF;
33757
 
    ELSE
33758
 
      RETURN -10;
33759
 
    END IF;
33760
 
  END IF;
33761
 
 
33762
 
  PERFORM poitem_id
33763
 
  FROM poitem
33764
 
  WHERE poitem_pohead_id = _poheadid;
33765
 
 
33766
 
  IF NOT(FOUND) THEN
33767
 
    DELETE FROM pohead
33768
 
    WHERE (pohead_id = _poheadid);
33769
 
  END IF;
33770
 
  
33771
 
  RETURN 0;
33772
 
 
33773
 
END;
33774
 
$_$;
33775
 
 
33776
 
 
33777
 
ALTER FUNCTION public.deletepoitem(integer) OWNER TO admin;
33778
 
 
33779
 
--
33780
 
--
33781
 
 
33782
 
CREATE FUNCTION deletepr(integer) RETURNS boolean
33783
 
    LANGUAGE plpgsql
33784
 
    AS $_$
33785
 
DECLARE
33786
 
  pPrid ALIAS FOR $1;
33787
 
 
33788
 
BEGIN
33789
 
 
33790
 
  DELETE FROM pr
33791
 
  WHERE ( (pr_status='O')
33792
 
   AND (pr_id=pPrid) );
33793
 
 
33794
 
  RETURN TRUE;
33795
 
 
33796
 
END;
33797
 
$_$;
33798
 
 
33799
 
 
33800
 
ALTER FUNCTION public.deletepr(integer) OWNER TO admin;
33801
 
 
33802
 
--
33803
 
--
33804
 
 
33805
 
CREATE FUNCTION deletepr(character, integer) RETURNS boolean
33806
 
    LANGUAGE plpgsql
33807
 
    AS $_$
33808
 
DECLARE
33809
 
  pParentType ALIAS FOR $1;
33810
 
  pParentId ALIAS FOR $2;
33811
 
 
33812
 
BEGIN
33813
 
 
33814
 
  DELETE FROM pr
33815
 
  WHERE ((pr_status='O')
33816
 
   AND (pr_order_type=pParentType)
33817
 
   AND (pr_order_id=pParentId));
33818
 
 
33819
 
  RETURN TRUE;
33820
 
 
33821
 
END;
33822
 
$_$;
33823
 
 
33824
 
 
33825
 
ALTER FUNCTION public.deletepr(character, integer) OWNER TO admin;
33826
 
 
33827
 
--
33828
 
--
33829
 
 
33830
 
CREATE FUNCTION deleteproductcategory(integer) RETURNS integer
33831
 
    LANGUAGE plpgsql
33832
 
    AS $_$
33833
 
DECLARE
33834
 
  pProdcatid ALIAS FOR $1;
33835
 
  _check INTEGER;
33836
 
 
33837
 
BEGIN
33838
 
 
33839
 
  SELECT item_id INTO _check
33840
 
  FROM item
33841
 
  WHERE (item_prodcat_id=pProdcatid)
33842
 
  LIMIT 1;
33843
 
  IF (FOUND) THEN
33844
 
    RETURN -1;
33845
 
  END IF;
33846
 
 
33847
 
  DELETE FROM salesaccnt
33848
 
  WHERE (salesaccnt_prodcat_id=pProdcatid);
33849
 
 
33850
 
  DELETE FROM prodcat
33851
 
  WHERE (prodcat_id=pProdcatid);
33852
 
 
33853
 
  RETURN pProdcatid;
33854
 
 
33855
 
END;
33856
 
$_$;
33857
 
 
33858
 
 
33859
 
ALTER FUNCTION public.deleteproductcategory(integer) OWNER TO admin;
33860
 
 
33861
 
--
33862
 
--
33863
 
 
33864
 
CREATE FUNCTION deleteprofitcenter(integer) RETURNS integer
33865
 
    LANGUAGE plpgsql
33866
 
    AS $_$
33867
 
DECLARE
33868
 
  pid ALIAS FOR $1;
33869
 
 
33870
 
BEGIN
33871
 
  IF (EXISTS(SELECT accnt_id
33872
 
             FROM accnt, prftcntr
33873
 
             WHERE ((accnt_company=prftcntr_number)
33874
 
               AND  (prftcntr_id=pid))
33875
 
            )) THEN
33876
 
    RETURN -1;
33877
 
  END IF;
33878
 
 
33879
 
  DELETE FROM prftcntr
33880
 
  WHERE (prftcntr_id=pid);
33881
 
 
33882
 
  RETURN pid;
33883
 
 
33884
 
END;
33885
 
$_$;
33886
 
 
33887
 
 
33888
 
ALTER FUNCTION public.deleteprofitcenter(integer) OWNER TO admin;
33889
 
 
33890
 
--
33891
 
--
33892
 
 
33893
 
CREATE FUNCTION deleteproject(integer) RETURNS integer
33894
 
    LANGUAGE plpgsql
33895
 
    AS $_$
33896
 
DECLARE
33897
 
  pPrjid ALIAS FOR $1;
33898
 
  _result INTEGER;
33899
 
BEGIN
33900
 
 
33901
 
  SELECT quhead_id INTO _result
33902
 
    FROM quhead
33903
 
   WHERE (quhead_prj_id=pPrjid)
33904
 
   LIMIT 1;
33905
 
  IF (FOUND) THEN
33906
 
    RETURN -1;
33907
 
  END IF;
33908
 
 
33909
 
  SELECT cohead_id INTO _result
33910
 
    FROM cohead
33911
 
   WHERE (cohead_prj_id=pPrjid)
33912
 
   LIMIT 1;
33913
 
  IF (FOUND) THEN
33914
 
    RETURN -2;
33915
 
  END IF;
33916
 
 
33917
 
  SELECT wo_id INTO _result
33918
 
    FROM wo
33919
 
   WHERE (wo_prj_id=pPrjid)
33920
 
   LIMIT 1;
33921
 
  IF (FOUND) THEN
33922
 
    RETURN -3;
33923
 
  END IF;
33924
 
 
33925
 
  SELECT pr_id INTO _result
33926
 
    FROM pr
33927
 
   WHERE (pr_prj_id=pPrjid)
33928
 
   LIMIT 1;
33929
 
  IF (FOUND) THEN
33930
 
    RETURN -4;
33931
 
  END IF;
33932
 
 
33933
 
  SELECT poitem_id INTO _result
33934
 
    FROM poitem
33935
 
   WHERE (poitem_prj_id=pPrjid)
33936
 
   LIMIT 1;
33937
 
  IF (FOUND) THEN
33938
 
    RETURN -5;
33939
 
  END IF;
33940
 
 
33941
 
  SELECT invchead_id INTO _result
33942
 
    FROM invchead
33943
 
   WHERE (invchead_prj_id=pPrjid)
33944
 
   LIMIT 1;
33945
 
  IF (FOUND) THEN
33946
 
    RETURN -6;
33947
 
  END IF;
33948
 
 
33949
 
  DELETE FROM comment
33950
 
  WHERE ((comment_source='J')
33951
 
  AND (comment_source_id=pPrjid));
33952
 
 
33953
 
  DELETE FROM comment
33954
 
  WHERE ((comment_source='TA')
33955
 
  AND (comment_source_id IN (
33956
 
    SELECT prjtask_id
33957
 
    FROM prjtask
33958
 
    WHERE (prjtask_prj_id=pPrjId))));
33959
 
 
33960
 
  DELETE FROM prjtask
33961
 
   WHERE (prjtask_prj_id=pPrjid);
33962
 
 
33963
 
  UPDATE prj
33964
 
     SET prj_recurring_prj_id=null
33965
 
   WHERE(prj_recurring_prj_id=pPrjid);
33966
 
 
33967
 
  DELETE FROM prj
33968
 
   WHERE (prj_id=pPrjid);
33969
 
  RETURN pPrjid;
33970
 
END;
33971
 
$_$;
33972
 
 
33973
 
 
33974
 
ALTER FUNCTION public.deleteproject(integer) OWNER TO admin;
33975
 
 
33976
 
--
33977
 
--
33978
 
 
33979
 
CREATE FUNCTION deleteprojecttask(integer) RETURNS integer
33980
 
    LANGUAGE plpgsql
33981
 
    AS $_$
33982
 
DECLARE
33983
 
  pPrjtaskid ALIAS FOR $1;
33984
 
  _row RECORD;
33985
 
  _result INTEGER;
33986
 
BEGIN
33987
 
 
33988
 
  SELECT * INTO _row
33989
 
    FROM prjtask
33990
 
   WHERE (prjtask_id=pPrjtaskid)
33991
 
   LIMIT 1;
33992
 
  IF (NOT FOUND) THEN
33993
 
    RETURN -1;
33994
 
  END IF;
33995
 
 
33996
 
  IF (COALESCE(_row.prjtask_hours_actual, 0.0) > 0.0) THEN
33997
 
    RETURN -2;
33998
 
  END IF;
33999
 
 
34000
 
  IF (COALESCE(_row.prjtask_exp_actual, 0.0) > 0.0) THEN
34001
 
    RETURN -3;
34002
 
  END IF;
34003
 
 
34004
 
  DELETE FROM comment
34005
 
  WHERE ((comment_source='TA')
34006
 
  AND (comment_source_id=pPrjtaskid));
34007
 
 
34008
 
  DELETE FROM prjtask
34009
 
   WHERE (prjtask_id=pPrjtaskid);
34010
 
 
34011
 
  RETURN 0;
34012
 
 
34013
 
END;
34014
 
$_$;
34015
 
 
34016
 
 
34017
 
ALTER FUNCTION public.deleteprojecttask(integer) OWNER TO admin;
34018
 
 
34019
 
--
34020
 
--
34021
 
 
34022
 
CREATE FUNCTION deleteqryhead(integer) RETURNS integer
34023
 
    LANGUAGE plpgsql
34024
 
    AS $_$
34025
 
DECLARE
34026
 
  pqryheadid    ALIAS FOR $1;
34027
 
 
34028
 
BEGIN
34029
 
  DELETE FROM qryitem WHERE (qryitem_qryhead_id=pqryheadid);
34030
 
  DELETE FROM qryhead WHERE (qryhead_id=pqryheadid);
34031
 
 
34032
 
  RETURN pqryheadid;
34033
 
END;
34034
 
$_$;
34035
 
 
34036
 
 
34037
 
ALTER FUNCTION public.deleteqryhead(integer) OWNER TO admin;
34038
 
 
34039
 
--
34040
 
--
34041
 
 
34042
 
CREATE FUNCTION deletequote(integer) RETURNS integer
34043
 
    LANGUAGE plpgsql
34044
 
    AS $_$
34045
 
DECLARE
34046
 
  pQuheadid ALIAS FOR $1;
34047
 
BEGIN
34048
 
  RETURN deleteQuote(pQuheadid, NULL::TEXT);
34049
 
END;
34050
 
$_$;
34051
 
 
34052
 
 
34053
 
ALTER FUNCTION public.deletequote(integer) OWNER TO admin;
34054
 
 
34055
 
--
34056
 
--
34057
 
 
34058
 
CREATE FUNCTION deletequote(integer, text) RETURNS integer
34059
 
    LANGUAGE plpgsql
34060
 
    AS $_$
34061
 
DECLARE
34062
 
  pQuheadid     ALIAS FOR $1;
34063
 
  pQuoteNumber  ALIAS FOR $2;
34064
 
 
34065
 
  _quNumberScheme       TEXT;
34066
 
  _quoteNumber          TEXT;
34067
 
  _quitemid             INTEGER;
34068
 
  _result               INTEGER;
34069
 
 
34070
 
BEGIN
34071
 
 
34072
 
  SELECT fetchMetricText('QUNumberGeneration') INTO _quNumberScheme;
34073
 
 
34074
 
  IF (pQuoteNumber IS NULL) THEN
34075
 
    SELECT quhead_number INTO _quoteNumber
34076
 
    FROM quhead
34077
 
    WHERE (quhead_id=pQuheadid);
34078
 
  ELSE
34079
 
    _quoteNumber := pQuoteNumber;
34080
 
  END IF;
34081
 
 
34082
 
  PERFORM deleteQuoteItem(quitem_id)
34083
 
  FROM quitem
34084
 
  WHERE (quitem_quhead_id=pQuheadid);
34085
 
 
34086
 
  DELETE FROM charass
34087
 
  WHERE (charass_target_type='QU')
34088
 
    AND (charass_target_id=pQuheadid);
34089
 
 
34090
 
  DELETE FROM quhead
34091
 
  WHERE (quhead_id=pQuheadid);
34092
 
 
34093
 
  IF (_quoteNumber IS NOT NULL) THEN
34094
 
    IF (_quNumberScheme IN ('A', 'O')) THEN
34095
 
      -- do not release quote # if quote converted to sales order
34096
 
      IF (NOT EXISTS (SELECT cohead_id
34097
 
                      FROM cohead
34098
 
                      WHERE (cohead_number=_quoteNumber))) THEN
34099
 
        _result = releaseQuNumber(_quoteNumber);
34100
 
      END IF;
34101
 
    ELSEIF (_quNumberScheme = 'S') THEN
34102
 
      _result = releaseSoNumber(_quoteNumber);
34103
 
    END IF;
34104
 
  END IF;
34105
 
 
34106
 
  -- Don't care about result of release number
34107
 
  RETURN 0;
34108
 
 
34109
 
END;
34110
 
$_$;
34111
 
 
34112
 
 
34113
 
ALTER FUNCTION public.deletequote(integer, text) OWNER TO admin;
34114
 
 
34115
 
--
34116
 
--
34117
 
 
34118
 
CREATE FUNCTION deletequote(integer, integer) RETURNS integer
34119
 
    LANGUAGE plpgsql
34120
 
    AS $_$
34121
 
DECLARE
34122
 
  pQuheadid ALIAS FOR $1;
34123
 
  pQuoteNumber  ALIAS FOR $2;
34124
 
BEGIN
34125
 
  RETURN deleteQuote(pQuheadid, pQuoteNumber::TEXT);
34126
 
END;
34127
 
$_$;
34128
 
 
34129
 
 
34130
 
ALTER FUNCTION public.deletequote(integer, integer) OWNER TO admin;
34131
 
 
34132
 
--
34133
 
--
34134
 
 
34135
 
CREATE FUNCTION deletequoteitem(integer) RETURNS integer
34136
 
    LANGUAGE plpgsql
34137
 
    AS $_$
34138
 
DECLARE
34139
 
  pQuitemid ALIAS FOR $1;
34140
 
 
34141
 
  _result               INTEGER;
34142
 
 
34143
 
BEGIN
34144
 
 
34145
 
  DELETE FROM charass
34146
 
  WHERE (charass_target_type='QI')
34147
 
    AND (charass_target_id=pQuitemid);
34148
 
 
34149
 
  DELETE FROM quitem
34150
 
  WHERE (quitem_id=pQuitemid);
34151
 
 
34152
 
  RETURN 0;
34153
 
 
34154
 
END;
34155
 
$_$;
34156
 
 
34157
 
 
34158
 
ALTER FUNCTION public.deletequoteitem(integer) OWNER TO admin;
34159
 
 
34160
 
--
34161
 
--
34162
 
 
34163
 
CREATE FUNCTION deleterecvfororder(text, integer) RETURNS integer
34164
 
    LANGUAGE plpgsql
34165
 
    AS $_$
34166
 
DECLARE
34167
 
  pordertype    ALIAS FOR $1;
34168
 
  porderid      ALIAS FOR $2;
34169
 
 
34170
 
BEGIN
34171
 
  DELETE FROM recv
34172
 
  USING orderitem
34173
 
  WHERE ((recv_orderitem_id=orderitem_id)
34174
 
    AND  (recv_order_type=orderitem_orderhead_type)
34175
 
    AND  (NOT recv_posted)
34176
 
    AND  (orderitem_orderhead_id=porderid)
34177
 
    AND  (orderitem_orderhead_type=pordertype));
34178
 
 
34179
 
  RETURN 0;
34180
 
 
34181
 
END;
34182
 
$_$;
34183
 
 
34184
 
 
34185
 
ALTER FUNCTION public.deleterecvfororder(text, integer) OWNER TO admin;
34186
 
 
34187
 
--
34188
 
--
34189
 
 
34190
 
CREATE FUNCTION deletesalescategory(integer) RETURNS integer
34191
 
    LANGUAGE plpgsql
34192
 
    AS $_$
34193
 
DECLARE
34194
 
  pSalescatid ALIAS FOR $1;
34195
 
 
34196
 
BEGIN
34197
 
 
34198
 
  PERFORM invcitem_salescat_id
34199
 
  FROM invchead, invcitem
34200
 
  WHERE ( (invcitem_invchead_id=invchead_id)
34201
 
   AND (NOT invchead_posted)
34202
 
   AND (invcitem_salescat_id=pSalescatid) );
34203
 
  IF (FOUND) THEN
34204
 
    RETURN -1;
34205
 
  END IF;
34206
 
 
34207
 
  PERFORM invcitem_salescat_id
34208
 
  FROM invchead, invcitem
34209
 
  WHERE ( (invcitem_invchead_id=invchead_id)
34210
 
   AND (invchead_posted)
34211
 
   AND (invcitem_salescat_id=pSalescatid) );
34212
 
  IF (FOUND) THEN
34213
 
    RETURN -2;
34214
 
  END IF;
34215
 
 
34216
 
  PERFORM aropen_salescat_id
34217
 
     FROM aropen
34218
 
    WHERE (aropen_salescat_id=pSalescatid);
34219
 
  IF (FOUND) THEN
34220
 
    RETURN -3;
34221
 
  END IF;
34222
 
 
34223
 
  DELETE FROM salescat
34224
 
  WHERE (salescat_id=pSalescatid);
34225
 
 
34226
 
  RETURN 0;
34227
 
 
34228
 
END;
34229
 
$_$;
34230
 
 
34231
 
 
34232
 
ALTER FUNCTION public.deletesalescategory(integer) OWNER TO admin;
34233
 
 
34234
 
--
34235
 
--
34236
 
 
34237
 
CREATE FUNCTION deleteshippingcharge(integer) RETURNS integer
34238
 
    LANGUAGE plpgsql
34239
 
    AS $_$
34240
 
DECLARE
34241
 
  pShipchrgid ALIAS FOR $1;
34242
 
 
34243
 
BEGIN
34244
 
 
34245
 
  IF EXISTS(SELECT 1
34246
 
              FROM custinfo
34247
 
             WHERE (cust_shipchrg_id=pShipchrgid)) THEN
34248
 
    RETURN -1;
34249
 
  END IF;
34250
 
 
34251
 
  DELETE FROM shipchrg
34252
 
  WHERE (shipchrg_id=pShipchrgid);
34253
 
 
34254
 
  RETURN pShipchrgid;
34255
 
 
34256
 
END;
34257
 
$_$;
34258
 
 
34259
 
 
34260
 
ALTER FUNCTION public.deleteshippingcharge(integer) OWNER TO admin;
34261
 
 
34262
 
--
34263
 
--
34264
 
 
34265
 
CREATE FUNCTION deleteshippingchargetype(integer) RETURNS integer
34266
 
    LANGUAGE plpgsql
34267
 
    AS $_$
34268
 
DECLARE
34269
 
  pShipchrgid ALIAS FOR $1;
34270
 
  _check INTEGER;
34271
 
 
34272
 
BEGIN
34273
 
 
34274
 
  SELECT cust_id INTO _check
34275
 
  FROM custinfo
34276
 
  WHERE (cust_shipchrg_id=pShipchrgid)
34277
 
  LIMIT 1;
34278
 
  IF (FOUND) THEN
34279
 
    RETURN -1;
34280
 
  END IF;
34281
 
 
34282
 
  SELECT shipto_id INTO _check
34283
 
  FROM shiptoinfo
34284
 
  WHERE (shipto_shipchrg_id=pShipchrgid)
34285
 
  LIMIT 1;
34286
 
  IF (FOUND) THEN
34287
 
    RETURN -2;
34288
 
  END IF;
34289
 
 
34290
 
  SELECT cohead_id INTO _check
34291
 
  FROM cohead
34292
 
  WHERE (cohead_shipchrg_id=pShipchrgid)
34293
 
  LIMIT 1;
34294
 
  IF (FOUND) THEN
34295
 
    RETURN -3;
34296
 
  END IF;
34297
 
 
34298
 
  SELECT shiphead_id INTO _check
34299
 
  FROM shiphead
34300
 
  WHERE (shiphead_shipchrg_id=pShipchrgid)
34301
 
  LIMIT 1;
34302
 
  IF (FOUND) THEN
34303
 
    RETURN -4;
34304
 
  END IF;
34305
 
 
34306
 
  SELECT invchead_id INTO _check
34307
 
  FROM invchead
34308
 
  WHERE (invchead_shipchrg_id=pShipchrgid)
34309
 
  LIMIT 1;
34310
 
  IF (FOUND) THEN
34311
 
    RETURN -5;
34312
 
  END IF;
34313
 
 
34314
 
  DELETE FROM shipchrg
34315
 
  WHERE (shipchrg_id=pShipchrgid);
34316
 
 
34317
 
  RETURN pShipchrgid;
34318
 
 
34319
 
END;
34320
 
$_$;
34321
 
 
34322
 
 
34323
 
ALTER FUNCTION public.deleteshippingchargetype(integer) OWNER TO admin;
34324
 
 
34325
 
--
34326
 
--
34327
 
 
34328
 
CREATE FUNCTION deleteshipto(integer) RETURNS integer
34329
 
    LANGUAGE plpgsql
34330
 
    AS $_$
34331
 
DECLARE
34332
 
  pShiptoid ALIAS FOR $1;
34333
 
 
34334
 
BEGIN
34335
 
 
34336
 
  PERFORM asohist_id
34337
 
  FROM asohist
34338
 
  WHERE (asohist_shipto_id=pShiptoid)
34339
 
  LIMIT 1;
34340
 
  IF (FOUND) THEN
34341
 
    RETURN -1;
34342
 
  END IF;
34343
 
 
34344
 
  PERFORM cohead_id
34345
 
  FROM cohead
34346
 
  WHERE (cohead_shipto_id=pShiptoid)
34347
 
  LIMIT 1;
34348
 
  IF (FOUND) THEN
34349
 
    RETURN -2;
34350
 
  END IF;
34351
 
 
34352
 
  PERFORM cmhead_id
34353
 
  FROM cmhead
34354
 
  WHERE (cmhead_shipto_id=pShiptoid)
34355
 
  LIMIT 1;
34356
 
  IF (FOUND) THEN
34357
 
    RETURN -3;
34358
 
  END IF;
34359
 
 
34360
 
  PERFORM cohist_id
34361
 
  FROM cohist
34362
 
  WHERE (cohist_shipto_id=pShiptoid)
34363
 
  LIMIT 1;
34364
 
  IF (FOUND) THEN
34365
 
    RETURN -4;
34366
 
  END IF;
34367
 
 
34368
 
  PERFORM quhead_id
34369
 
  FROM quhead
34370
 
  WHERE (quhead_shipto_id=pShiptoid)
34371
 
  LIMIT 1;
34372
 
  IF (FOUND) THEN
34373
 
    RETURN -5;
34374
 
  END IF;
34375
 
 
34376
 
  PERFORM invchead_id
34377
 
  FROM invchead
34378
 
  WHERE (invchead_shipto_id=pShiptoid)
34379
 
  LIMIT 1;
34380
 
  IF (FOUND) THEN
34381
 
    RETURN -6;
34382
 
  END IF;
34383
 
 
34384
 
  DELETE FROM ipsass
34385
 
  WHERE (ipsass_shipto_id=pShiptoid);
34386
 
 
34387
 
  DELETE FROM shiptoinfo
34388
 
  WHERE (shipto_id=pShiptoid);
34389
 
 
34390
 
  RETURN 0;
34391
 
 
34392
 
END;
34393
 
$_$;
34394
 
 
34395
 
 
34396
 
ALTER FUNCTION public.deleteshipto(integer) OWNER TO admin;
34397
 
 
34398
 
--
34399
 
--
34400
 
 
34401
 
CREATE FUNCTION deleteso(integer) RETURNS integer
34402
 
    LANGUAGE plpgsql
34403
 
    AS $_$
34404
 
DECLARE
34405
 
  pSoheadid    ALIAS FOR $1;
34406
 
BEGIN
34407
 
  RETURN deleteSo(pSoheadid, NULL);
34408
 
END;
34409
 
$_$;
34410
 
 
34411
 
 
34412
 
ALTER FUNCTION public.deleteso(integer) OWNER TO admin;
34413
 
 
34414
 
--
34415
 
--
34416
 
 
34417
 
CREATE FUNCTION deleteso(integer, text) RETURNS integer
34418
 
    LANGUAGE plpgsql
34419
 
    AS $_$
34420
 
DECLARE
34421
 
  pSoheadid     ALIAS FOR $1;
34422
 
  pSonumber     ALIAS FOR $2;
34423
 
 
34424
 
  _r            RECORD;
34425
 
  _coitemid     INTEGER;
34426
 
  _result       INTEGER;
34427
 
  _poStatus     INTEGER := 0;
34428
 
 
34429
 
BEGIN
34430
 
  SELECT * INTO _r FROM cohead WHERE (cohead_id=pSoheadid);
34431
 
 
34432
 
   IF (NOT FOUND) THEN
34433
 
     RETURN 0;
34434
 
   END IF;
34435
 
 
34436
 
  IF (EXISTS(SELECT ccpay_id
34437
 
             FROM ccpay, payco
34438
 
             WHERE ((ccpay_status IN ('C'))
34439
 
               AND  (ccpay_id=payco_ccpay_id)
34440
 
               AND  (payco_cohead_id=pSoheadid)))) THEN
34441
 
    RETURN -1;
34442
 
  END IF;
34443
 
 
34444
 
  IF (EXISTS(SELECT ccpay_id
34445
 
             FROM ccpay, payco
34446
 
             WHERE ((ccpay_status != 'C')
34447
 
               AND  (ccpay_id=payco_ccpay_id)
34448
 
               AND  (payco_cohead_id=pSoheadid)))) THEN
34449
 
    RETURN -2;
34450
 
  END IF;
34451
 
 
34452
 
  FOR _coitemid IN
34453
 
    SELECT coitem_id
34454
 
    FROM coitem
34455
 
    WHERE ( (coitem_cohead_id=pSoheadid)
34456
 
      AND   (coitem_subnumber=0) ) LOOP
34457
 
 
34458
 
    SELECT deleteSoItem(_coitemid) INTO _result;
34459
 
    IF (_result < 0) THEN
34460
 
      IF (_result = -20) THEN
34461
 
        _poStatus := _poStatus - 1;
34462
 
      ELSE
34463
 
        RETURN _result;
34464
 
      END IF;
34465
 
    END IF;
34466
 
 
34467
 
  END LOOP;
34468
 
 
34469
 
  DELETE FROM pack
34470
 
  WHERE (pack_head_id=pSoheadid and pack_head_type = 'SO');
34471
 
 
34472
 
  DELETE FROM charass
34473
 
  WHERE (charass_target_type='SO')
34474
 
    AND (charass_target_id=pSoheadid);
34475
 
 
34476
 
  DELETE FROM cohead
34477
 
  WHERE (cohead_id=pSoheadid);
34478
 
 
34479
 
  IF (fetchMetricBool('AutoCreateProjectsForOrders')) THEN
34480
 
    PERFORM deleteProject(_r.cohead_prj_id);
34481
 
  END IF;
34482
 
 
34483
 
  DELETE FROM aropenalloc
34484
 
  WHERE ((aropenalloc_doctype='S')
34485
 
    AND  (aropenalloc_doc_id=pSoheadid));
34486
 
 
34487
 
  IF ( (NOT _r.cohead_wasquote) AND (NOT _r.cohead_imported) ) THEN
34488
 
    IF (COALESCE(pSonumber,'') != '') THEN
34489
 
      _result = releaseSoNumber(pSonumber);
34490
 
    ELSEIF (_r.cohead_number IS NOT NULL) THEN
34491
 
      _result = releaseSoNumber(_r.cohead_number);
34492
 
    END IF;
34493
 
  END IF;
34494
 
 
34495
 
  IF (_poStatus < 0) THEN
34496
 
    RETURN -20;
34497
 
  ELSE
34498
 
    RETURN 0;
34499
 
  END IF;
34500
 
 
34501
 
END;
34502
 
$_$;
34503
 
 
34504
 
 
34505
 
ALTER FUNCTION public.deleteso(integer, text) OWNER TO admin;
34506
 
 
34507
 
--
34508
 
--
34509
 
 
34510
 
CREATE FUNCTION deletesoitem(integer) RETURNS integer
34511
 
    LANGUAGE plpgsql
34512
 
    AS $_$
34513
 
DECLARE
34514
 
  pSoitemid     ALIAS FOR $1;
34515
 
 
34516
 
  _r            RECORD;
34517
 
  _s            RECORD;
34518
 
  _result       INTEGER;
34519
 
  _deletePO     INTEGER := 0;
34520
 
  _recvId       INTEGER := -1;
34521
 
  _poStatus     TEXT;
34522
 
  _jobItem      BOOLEAN;
34523
 
 
34524
 
BEGIN
34525
 
   SELECT * INTO _r FROM coitem WHERE (coitem_id=pSoitemid);
34526
 
 
34527
 
   IF (NOT FOUND) THEN
34528
 
     RETURN -999;
34529
 
   END IF;
34530
 
 
34531
 
  IF (_r.coitem_qtyshipped > 0) THEN
34532
 
    RETURN -101;
34533
 
  END IF;
34534
 
 
34535
 
  SELECT shipitem_id INTO _result
34536
 
  FROM shipitem JOIN shiphead ON (shiphead_id=shipitem_shiphead_id AND shiphead_order_type='SO')
34537
 
  WHERE (shipitem_orderitem_id=pSoitemid)
34538
 
  LIMIT 1;
34539
 
  IF (FOUND) THEN
34540
 
    RETURN -102;
34541
 
  END IF;
34542
 
 
34543
 
  IF (fetchMetricBool('MultiWhs')) THEN
34544
 
    SELECT raitem_id INTO _result
34545
 
    FROM raitem
34546
 
    WHERE ( (raitem_orig_coitem_id=pSoitemid)
34547
 
       OR   (raitem_new_coitem_id=pSoitemid) )
34548
 
    LIMIT 1;
34549
 
    IF (FOUND) THEN
34550
 
      RETURN -103;
34551
 
    END IF;
34552
 
  END IF;
34553
 
 
34554
 
  SELECT invhist_id INTO _result
34555
 
  FROM invhist
34556
 
  WHERE ( (invhist_ordnumber=formatSoNumber(pSoitemid))
34557
 
    AND   (invhist_ordtype='SO') )
34558
 
  LIMIT 1;
34559
 
  IF (FOUND) THEN
34560
 
    RETURN -105;
34561
 
  END IF;
34562
 
 
34563
 
  IF (_r.coitem_subnumber = 0) THEN
34564
 
    FOR _s IN
34565
 
      SELECT *
34566
 
      FROM coitem
34567
 
      WHERE ((coitem_cohead_id = _r.coitem_cohead_id)
34568
 
        AND  (coitem_linenumber = _r.coitem_linenumber)
34569
 
        AND  (coitem_subnumber > 0))
34570
 
    LOOP
34571
 
      IF ((COALESCE(_s.coitem_order_id, -1) > 0)
34572
 
       AND (_s.coitem_order_type = 'P')) THEN
34573
 
        SELECT poitem_status, COALESCE(recv_id, -1)
34574
 
          INTO _poStatus, _recvId
34575
 
        FROM poitem LEFT OUTER JOIN recv
34576
 
               ON ((recv_orderitem_id=poitem_id)
34577
 
                 AND (recv_order_type='PO'))
34578
 
        WHERE (poitem_id = _s.coitem_order_id);
34579
 
 
34580
 
        IF ((_recvId > 0) OR (_poStatus = 'C')) THEN
34581
 
          RETURN -10;
34582
 
        ELSIF ((_recvId = -1) AND (_poStatus = 'O')) THEN
34583
 
          _deletePO := _deletePO - 1;
34584
 
        END IF;
34585
 
      END IF;
34586
 
    END LOOP;
34587
 
  END IF;
34588
 
 
34589
 
 
34590
 
  SELECT (itemsite_costmethod='J') INTO _jobItem
34591
 
  FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
34592
 
  WHERE (coitem_id=pSoitemid);
34593
 
 
34594
 
  IF (_jobItem AND _r.coitem_order_type='W') THEN
34595
 
    SELECT deleteWo(_r.coitem_order_id, TRUE, TRUE) INTO _result;
34596
 
    IF (_result < 0) THEN
34597
 
      RETURN -104;
34598
 
    END IF;
34599
 
  ELSIF (_r.coitem_order_type='W') THEN
34600
 
    SELECT deleteWo(_r.coitem_order_id, TRUE) INTO _result;
34601
 
    IF (_result < 0) THEN
34602
 
      -- Cannot delete so break association
34603
 
      PERFORM changeWoProject(_r.coitem_order_id, -1, TRUE);
34604
 
    END IF;
34605
 
  ELSIF (_r.coitem_order_type='R') THEN
34606
 
    PERFORM deletePr(_r.coitem_order_id);
34607
 
  ELSIF (_r.coitem_order_type='P') THEN
34608
 
    SELECT deletepoitem(_r.coitem_order_id) INTO _result;
34609
 
    IF ((_result < 0) AND (_result <> -20)) THEN
34610
 
      RETURN _result;
34611
 
    ELSIF (_result = -20) THEN
34612
 
      _deletePO := _deletePO - 1;
34613
 
    END IF;
34614
 
  END IF;
34615
 
 
34616
 
  DELETE FROM charass
34617
 
  WHERE (charass_target_type='SI')
34618
 
    AND (charass_target_id=pSoitemid);
34619
 
 
34620
 
  IF (fetchMetricBool('EnableSOReservationsByLocation')) THEN
34621
 
    DELETE FROM reserve
34622
 
    WHERE (reserve_demand_type='SO')
34623
 
      AND (reserve_demand_id=pSoitemid);
34624
 
  END IF;
34625
 
 
34626
 
  DELETE FROM coitem
34627
 
  WHERE (coitem_id=pSoitemid);
34628
 
 
34629
 
  IF (_deletePO < 0) THEN
34630
 
    RETURN -20;
34631
 
  ELSE
34632
 
    RETURN 0;
34633
 
  END IF;
34634
 
 
34635
 
END;
34636
 
$_$;
34637
 
 
34638
 
 
34639
 
ALTER FUNCTION public.deletesoitem(integer) OWNER TO admin;
34640
 
 
34641
 
--
34642
 
--
34643
 
 
34644
 
CREATE FUNCTION deletestandardjournal(integer) RETURNS integer
34645
 
    LANGUAGE plpgsql
34646
 
    AS $_$
34647
 
DECLARE
34648
 
  pStdjrnlid ALIAS FOR $1;
34649
 
 
34650
 
BEGIN
34651
 
 
34652
 
  DELETE FROM stdjrnlitem
34653
 
  WHERE (stdjrnlitem_stdjrnl_id=pStdjrnlid);
34654
 
 
34655
 
  DELETE FROM stdjrnlgrpitem
34656
 
  WHERE (stdjrnlgrpitem_stdjrnl_id=pStdjrnlid);
34657
 
 
34658
 
  DELETE FROM stdjrnl
34659
 
  WHERE (stdjrnl_id=pStdjrnlid);
34660
 
 
34661
 
  RETURN 1;
34662
 
 
34663
 
END;
34664
 
$_$;
34665
 
 
34666
 
 
34667
 
ALTER FUNCTION public.deletestandardjournal(integer) OWNER TO admin;
34668
 
 
34669
 
--
34670
 
--
34671
 
 
34672
 
CREATE FUNCTION deletestandardjournalgroup(integer) RETURNS integer
34673
 
    LANGUAGE plpgsql
34674
 
    AS $_$
34675
 
DECLARE
34676
 
  pStdjrnlgrpid ALIAS FOR $1;
34677
 
 
34678
 
BEGIN
34679
 
 
34680
 
  DELETE FROM stdjrnlgrpitem
34681
 
  WHERE (stdjrnlgrpitem_stdjrnlgrp_id=pStdjrnlgrpid);
34682
 
 
34683
 
  DELETE FROM stdjrnlgrp
34684
 
  WHERE (stdjrnlgrp_id=pStdjrnlgrpid);
34685
 
 
34686
 
  RETURN 1;
34687
 
 
34688
 
END;
34689
 
$_$;
34690
 
 
34691
 
 
34692
 
ALTER FUNCTION public.deletestandardjournalgroup(integer) OWNER TO admin;
34693
 
 
34694
 
--
34695
 
--
34696
 
 
34697
 
CREATE FUNCTION deletesubaccount(integer) RETURNS integer
34698
 
    LANGUAGE plpgsql
34699
 
    AS $_$
34700
 
DECLARE
34701
 
  pid ALIAS FOR $1;
34702
 
 
34703
 
BEGIN
34704
 
  IF (EXISTS(SELECT accnt_id
34705
 
             FROM accnt, subaccnt
34706
 
             WHERE ((accnt_company=subaccnt_number)
34707
 
               AND  (subaccnt_id=pid))
34708
 
            )) THEN
34709
 
    RETURN -1;
34710
 
  END IF;
34711
 
 
34712
 
  DELETE FROM subaccnt
34713
 
  WHERE (subaccnt_id=pid);
34714
 
 
34715
 
  RETURN pid;
34716
 
 
34717
 
END;
34718
 
$_$;
34719
 
 
34720
 
 
34721
 
ALTER FUNCTION public.deletesubaccount(integer) OWNER TO admin;
34722
 
 
34723
 
--
34724
 
--
34725
 
 
34726
 
CREATE FUNCTION deletesubaccounttype(integer) RETURNS integer
34727
 
    LANGUAGE plpgsql
34728
 
    AS $_$
34729
 
DECLARE
34730
 
  pSubAccntTypeid ALIAS FOR $1;
34731
 
  _check INTEGER;
34732
 
 
34733
 
BEGIN
34734
 
 
34735
 
  SELECT accnt_id INTO _check
34736
 
  FROM accnt, subaccnttype
34737
 
  WHERE ( (accnt_subaccnttype_code=subaccnttype_code)
34738
 
   AND (subaccnttype_id=pSubAccntTypeid) )
34739
 
  LIMIT 1;
34740
 
  IF (FOUND) THEN
34741
 
    RETURN -1;
34742
 
  END IF;
34743
 
 
34744
 
  DELETE FROM subaccnttype
34745
 
  WHERE (subaccnttype_id=pSubAccntTypeid);
34746
 
 
34747
 
  RETURN 0;
34748
 
 
34749
 
END;
34750
 
$_$;
34751
 
 
34752
 
 
34753
 
ALTER FUNCTION public.deletesubaccounttype(integer) OWNER TO admin;
34754
 
 
34755
 
--
34756
 
--
34757
 
 
34758
 
CREATE FUNCTION deletetax(integer) RETURNS integer
34759
 
    LANGUAGE plpgsql
34760
 
    AS $_$
34761
 
DECLARE
34762
 
  ptaxid        ALIAS FOR $1;
34763
 
BEGIN
34764
 
  -- these checks allow nice error reporting instead of throwing an SQL error
34765
 
  IF EXISTS(SELECT taxass_id FROM taxass WHERE (taxass_tax_id=ptaxid)) THEN
34766
 
    RETURN -10;
34767
 
  END IF;
34768
 
  IF EXISTS(SELECT taxhist_id FROM taxhist WHERE (taxhist_tax_id=ptaxid)) THEN
34769
 
    RETURN -20;
34770
 
  END IF;
34771
 
 
34772
 
  DELETE FROM taxrate WHERE (taxrate_tax_id = ptaxid);
34773
 
  DELETE FROM tax WHERE (tax_id = ptaxid);
34774
 
 
34775
 
  RETURN ptaxid;
34776
 
 
34777
 
END;
34778
 
$_$;
34779
 
 
34780
 
 
34781
 
ALTER FUNCTION public.deletetax(integer) OWNER TO admin;
34782
 
 
34783
 
--
34784
 
--
34785
 
 
34786
 
CREATE FUNCTION deletetaxclass(integer) RETURNS integer
34787
 
    LANGUAGE plpgsql
34788
 
    AS $_$
34789
 
DECLARE
34790
 
pTaxclassid ALIAS FOR $1;
34791
 
_result INTEGER;
34792
 
 
34793
 
BEGIN
34794
 
 
34795
 
SELECT tax_id INTO _result
34796
 
FROM tax
34797
 
WHERE (tax_taxclass_id = pTaxclassid);
34798
 
IF (FOUND) THEN
34799
 
   RETURN -1;
34800
 
END IF;
34801
 
 
34802
 
DELETE FROM taxclass WHERE taxclass_id = pTaxclassid ;
34803
 
 
34804
 
RETURN pTaxclassid;
34805
 
 
34806
 
END;
34807
 
$_$;
34808
 
 
34809
 
 
34810
 
ALTER FUNCTION public.deletetaxclass(integer) OWNER TO admin;
34811
 
 
34812
 
--
34813
 
--
34814
 
 
34815
 
CREATE FUNCTION deletetaxtype(integer) RETURNS integer
34816
 
    LANGUAGE plpgsql
34817
 
    AS $_$
34818
 
DECLARE
34819
 
  pTaxtypeid ALIAS FOR $1;
34820
 
  _result INTEGER;
34821
 
BEGIN
34822
 
 
34823
 
  SELECT taxtype_id
34824
 
    INTO _result
34825
 
    FROM taxtype
34826
 
   WHERE ((taxtype_sys)
34827
 
     AND  (taxtype_id=pTaxtypeid));
34828
 
  IF (FOUND) THEN
34829
 
    RETURN -1;
34830
 
  END IF;
34831
 
 
34832
 
  SELECT taxass_id
34833
 
    INTO _result
34834
 
    FROM taxass
34835
 
   WHERE (taxass_taxtype_id=pTaxtypeid);
34836
 
  IF (FOUND) THEN
34837
 
    RETURN -2;
34838
 
  END IF;
34839
 
 
34840
 
  SELECT taxhist_id
34841
 
    INTO _result
34842
 
    FROM taxhist
34843
 
   WHERE (taxhist_taxtype_id=pTaxtypeid);
34844
 
  IF (FOUND) THEN
34845
 
    RETURN -3;
34846
 
  END IF;
34847
 
 
34848
 
  DELETE
34849
 
    FROM taxtype
34850
 
   WHERE (taxtype_id=pTaxtypeid);
34851
 
 
34852
 
  RETURN pTaxtypeid;
34853
 
 
34854
 
END;
34855
 
$_$;
34856
 
 
34857
 
 
34858
 
ALTER FUNCTION public.deletetaxtype(integer) OWNER TO admin;
34859
 
 
34860
 
--
34861
 
--
34862
 
 
34863
 
CREATE FUNCTION deletetaxzone(integer) RETURNS integer
34864
 
    LANGUAGE plpgsql
34865
 
    AS $_$
34866
 
DECLARE
34867
 
pTaxzoneid ALIAS FOR $1;
34868
 
_result INTEGER;
34869
 
 
34870
 
BEGIN
34871
 
 
34872
 
SELECT taxass_id INTO _result
34873
 
FROM taxass
34874
 
WHERE (taxass_taxzone_id=pTaxzoneid);
34875
 
IF (FOUND) THEN
34876
 
   RETURN -1;
34877
 
END IF;
34878
 
 
34879
 
SELECT taxreg_id INTO _result 
34880
 
FROM taxreg
34881
 
WHERE (taxreg_taxzone_id=pTaxzoneid);
34882
 
IF (FOUND) THEN
34883
 
   RETURN -2;
34884
 
END IF;
34885
 
 
34886
 
DELETE FROM taxzone WHERE taxzone_id = pTaxzoneid ;
34887
 
 
34888
 
RETURN pTaxzoneid;
34889
 
 
34890
 
END;
34891
 
$_$;
34892
 
 
34893
 
 
34894
 
ALTER FUNCTION public.deletetaxzone(integer) OWNER TO admin;
34895
 
 
34896
 
--
34897
 
--
34898
 
 
34899
 
CREATE FUNCTION deletetodoitem(integer) RETURNS integer
34900
 
    LANGUAGE plpgsql
34901
 
    AS $_$
34902
 
DECLARE
34903
 
  ptodoItemId ALIAS FOR $1;
34904
 
BEGIN
34905
 
  DELETE FROM alarm WHERE ( (alarm_source='TODO') AND (alarm_source_id=ptodoItemId) );
34906
 
  DELETE FROM todoitem WHERE todoitem_id = ptodoItemId;
34907
 
  RETURN 0;
34908
 
END;
34909
 
$_$;
34910
 
 
34911
 
 
34912
 
ALTER FUNCTION public.deletetodoitem(integer) OWNER TO admin;
34913
 
 
34914
 
--
34915
 
--
34916
 
 
34917
 
CREATE FUNCTION deleteunusedclasscodes() RETURNS integer
34918
 
    LANGUAGE plpgsql
34919
 
    AS $$
34920
 
BEGIN
34921
 
 
34922
 
  DELETE FROM classcode
34923
 
  WHERE (classcode_id NOT IN (SELECT DISTINCT item_classcode_id FROM item));
34924
 
 
34925
 
  RETURN 0;
34926
 
 
34927
 
END;
34928
 
$$;
34929
 
 
34930
 
 
34931
 
ALTER FUNCTION public.deleteunusedclasscodes() OWNER TO admin;
34932
 
 
34933
 
--
34934
 
--
34935
 
 
34936
 
CREATE FUNCTION deleteunusedfreightclasses() RETURNS integer
34937
 
    LANGUAGE plpgsql
34938
 
    AS $$
34939
 
BEGIN
34940
 
 
34941
 
  DELETE FROM freightclass
34942
 
  WHERE (freightclass_id NOT IN (SELECT DISTINCT COALESCE(item_freightclass_id, 0) FROM item));
34943
 
 
34944
 
  RETURN 0;
34945
 
 
34946
 
END;
34947
 
$$;
34948
 
 
34949
 
 
34950
 
ALTER FUNCTION public.deleteunusedfreightclasses() OWNER TO admin;
34951
 
 
34952
 
--
34953
 
--
34954
 
 
34955
 
CREATE FUNCTION deleteunusedproductcategories() RETURNS integer
34956
 
    LANGUAGE plpgsql
34957
 
    AS $$
34958
 
BEGIN
34959
 
 
34960
 
  DELETE FROM salesaccnt
34961
 
  WHERE ( (salesaccnt_prodcat_id <> -1)
34962
 
   AND (salesaccnt_prodcat_id NOT IN (SELECT DISTINCT item_prodcat_id FROM item)) );
34963
 
 
34964
 
  DELETE FROM prodcat
34965
 
  WHERE (prodcat_id NOT IN (SELECT DISTINCT item_prodcat_id FROM item));
34966
 
 
34967
 
  RETURN 0;
34968
 
 
34969
 
END;
34970
 
$$;
34971
 
 
34972
 
 
34973
 
ALTER FUNCTION public.deleteunusedproductcategories() OWNER TO admin;
34974
 
 
34975
 
--
34976
 
--
34977
 
 
34978
 
CREATE FUNCTION deleteuom(integer) RETURNS integer
34979
 
    LANGUAGE plpgsql
34980
 
    AS $_$
34981
 
DECLARE
34982
 
  pUomid ALIAS FOR $1;
34983
 
 
34984
 
BEGIN
34985
 
 
34986
 
  DELETE FROM uomconv WHERE uomconv_from_uom_id=pUomid;
34987
 
  DELETE FROM uomconv WHERE uomconv_to_uom_id=pUomid;
34988
 
  DELETE FROM uom WHERE uom_id=pUomid;
34989
 
 
34990
 
  RETURN 0;
34991
 
END;
34992
 
$_$;
34993
 
 
34994
 
 
34995
 
ALTER FUNCTION public.deleteuom(integer) OWNER TO admin;
34996
 
 
34997
 
--
34998
 
--
34999
 
 
35000
 
CREATE FUNCTION deleteuomconv(integer) RETURNS integer
35001
 
    LANGUAGE plpgsql
35002
 
    AS $_$
35003
 
DECLARE
35004
 
  pUomconvid ALIAS FOR $1;
35005
 
 
35006
 
BEGIN
35007
 
  DELETE FROM uomconv WHERE uomconv_id=pUomconvid;
35008
 
 
35009
 
  RETURN 0;
35010
 
END;
35011
 
$_$;
35012
 
 
35013
 
 
35014
 
ALTER FUNCTION public.deleteuomconv(integer) OWNER TO admin;
35015
 
 
35016
 
--
35017
 
--
35018
 
 
35019
 
CREATE FUNCTION deleteurl(integer) RETURNS boolean
35020
 
    LANGUAGE plpgsql
35021
 
    AS $_$
35022
 
declare
35023
 
  pId ALIAS FOR $1;
35024
 
begin
35025
 
  delete from urlinfo
35026
 
  where ( url_id in (
35027
 
    select url_id
35028
 
    from urlinfo
35029
 
      join docass on (docass_target_id=url_id)
35030
 
                 and (docass_target_type='URL')
35031
 
      where ( docass_id = pId ) ) );
35032
 
 
35033
 
  delete from docass where docass_id = pId;
35034
 
 
35035
 
  return true;
35036
 
end;
35037
 
$_$;
35038
 
 
35039
 
 
35040
 
ALTER FUNCTION public.deleteurl(integer) OWNER TO admin;
35041
 
 
35042
 
--
35043
 
--
35044
 
 
35045
 
CREATE FUNCTION deleteuserpreference(text) RETURNS boolean
35046
 
    LANGUAGE plpgsql
35047
 
    AS $_$
35048
 
DECLARE
35049
 
  pPrefname ALIAS FOR $1;
35050
 
  _return BOOLEAN;
35051
 
 
35052
 
BEGIN
35053
 
 
35054
 
  SELECT deleteUserPreference(getEffectiveXtUser(), pPrefname) INTO _return;
35055
 
 
35056
 
  RETURN _return;
35057
 
 
35058
 
END;
35059
 
$_$;
35060
 
 
35061
 
 
35062
 
ALTER FUNCTION public.deleteuserpreference(text) OWNER TO admin;
35063
 
 
35064
 
--
35065
 
--
35066
 
 
35067
 
CREATE FUNCTION deleteuserpreference(text, text) RETURNS boolean
35068
 
    LANGUAGE plpgsql
35069
 
    AS $_$
35070
 
DECLARE
35071
 
  pUsername ALIAS FOR $1;
35072
 
  pPrefname ALIAS FOR $2;
35073
 
 
35074
 
BEGIN
35075
 
 
35076
 
  DELETE FROM usrpref
35077
 
  WHERE ( (usrpref_username=pUsername)
35078
 
   AND (usrpref_name=pPrefname) );
35079
 
 
35080
 
  RETURN TRUE;
35081
 
 
35082
 
END;
35083
 
$_$;
35084
 
 
35085
 
 
35086
 
ALTER FUNCTION public.deleteuserpreference(text, text) OWNER TO admin;
35087
 
 
35088
 
--
35089
 
--
35090
 
 
35091
 
CREATE FUNCTION deletevendoraddress(integer) RETURNS integer
35092
 
    LANGUAGE plpgsql
35093
 
    AS $_$
35094
 
DECLARE
35095
 
  pVendaddrid ALIAS FOR $1;
35096
 
  _test INTEGER;
35097
 
 
35098
 
BEGIN
35099
 
 
35100
 
  SELECT pohead_id INTO _test
35101
 
  FROM pohead
35102
 
  WHERE (pohead_vendaddr_id=pVendaddrid)
35103
 
  LIMIT 1;
35104
 
  IF (FOUND) THEN
35105
 
    RETURN -1;
35106
 
  END IF;
35107
 
 
35108
 
  DELETE FROM vendaddrinfo
35109
 
  WHERE (vendaddr_id=pVendaddrid);
35110
 
 
35111
 
  RETURN 0;
35112
 
 
35113
 
END;
35114
 
$_$;
35115
 
 
35116
 
 
35117
 
ALTER FUNCTION public.deletevendoraddress(integer) OWNER TO admin;
35118
 
 
35119
 
--
35120
 
--
35121
 
 
35122
 
CREATE FUNCTION deletevendortype(integer) RETURNS integer
35123
 
    LANGUAGE plpgsql
35124
 
    AS $_$
35125
 
DECLARE
35126
 
  pVendtypeid ALIAS FOR $1;
35127
 
  _test INTEGER;
35128
 
 
35129
 
BEGIN
35130
 
 
35131
 
  SELECT vend_id INTO _test
35132
 
  FROM vendinfo
35133
 
  WHERE (vend_vendtype_id=pVendtypeid)
35134
 
  LIMIT 1;
35135
 
  IF (FOUND) THEN
35136
 
    RETURN -1;
35137
 
  END IF;
35138
 
 
35139
 
  DELETE FROM vendtype
35140
 
  WHERE (vendtype_id=pVendtypeid);
35141
 
 
35142
 
  RETURN 0;
35143
 
 
35144
 
END;
35145
 
$_$;
35146
 
 
35147
 
 
35148
 
ALTER FUNCTION public.deletevendortype(integer) OWNER TO admin;
35149
 
 
35150
 
--
35151
 
--
35152
 
 
35153
 
CREATE FUNCTION deletewo(integer, boolean) RETURNS integer
35154
 
    LANGUAGE plpgsql
35155
 
    AS $_$
35156
 
DECLARE
35157
 
  pWoid ALIAS FOR $1;
35158
 
  deleteChildren ALIAS FOR $2;
35159
 
 
35160
 
BEGIN
35161
 
  RETURN deleteWo(pWoid, deleteChildren, FALSE);
35162
 
END;
35163
 
$_$;
35164
 
 
35165
 
 
35166
 
ALTER FUNCTION public.deletewo(integer, boolean) OWNER TO admin;
35167
 
 
35168
 
--
35169
 
--
35170
 
 
35171
 
CREATE FUNCTION deletewo(integer, boolean, boolean) RETURNS integer
35172
 
    LANGUAGE plpgsql
35173
 
    AS $_$
35174
 
DECLARE
35175
 
  pWoid ALIAS FOR $1;
35176
 
  deleteChildren ALIAS FOR $2;
35177
 
  deleteForce ALIAS FOR $3;
35178
 
  woStatus CHAR(1);
35179
 
  itemType CHAR(1);
35180
 
  ordtype CHAR(1);
35181
 
  ordid INTEGER;
35182
 
  returnCode INTEGER;
35183
 
  _wotcCnt      INTEGER;
35184
 
  _routings BOOLEAN;
35185
 
 
35186
 
BEGIN
35187
 
  SELECT wo_status, wo_ordtype, wo_ordid, item_type
35188
 
  INTO woStatus, ordtype, ordid, itemType
35189
 
  FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)
35190
 
          JOIN item ON (item_id=itemsite_item_id)
35191
 
  WHERE (wo_id=pWoid);
35192
 
 
35193
 
  IF (NOT woStatus IN ('O', 'E', 'C')) THEN
35194
 
    RETURN -3;
35195
 
  END IF;
35196
 
 
35197
 
  IF (NOT deleteForce) THEN
35198
 
    IF (itemType = 'J') THEN
35199
 
      RETURN -2;
35200
 
    END IF;
35201
 
  END IF;
35202
 
 
35203
 
  SELECT fetchMetricBool('Routings') INTO _routings;
35204
 
 
35205
 
  IF (_routings AND woStatus != 'C') THEN
35206
 
    SELECT count(*) INTO _wotcCnt
35207
 
    FROM xtmfg.wotc
35208
 
    WHERE (wotc_wo_id=pWoid);
35209
 
    IF (_wotcCnt > 0) THEN
35210
 
      RETURN -1;
35211
 
    END IF;
35212
 
  END IF;
35213
 
 
35214
 
  IF (woStatus = 'R') THEN
35215
 
    PERFORM postEvent('RWoRequestCancel', 'W', wo_id,
35216
 
                      itemsite_warehous_id, formatWoNumber(wo_id),
35217
 
                      NULL, NULL, NULL, NULL)
35218
 
    FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)
35219
 
            JOIN item ON (item_id=itemsite_item_id)
35220
 
    WHERE (wo_id=pWoid);
35221
 
 
35222
 
     RETURN 0;
35223
 
  ELSE
35224
 
    IF (woStatus = 'E') THEN
35225
 
      returnCode := (SELECT implodeWo(pWoid, FALSE));
35226
 
    END IF;
35227
 
  END IF;
35228
 
 
35229
 
  IF (woStatus IN ('O', 'E', 'C')) THEN
35230
 
    DELETE FROM womatl
35231
 
    WHERE (womatl_wo_id=pWoid);
35232
 
 
35233
 
    IF _routings THEN
35234
 
      DELETE FROM xtmfg.wotc
35235
 
      WHERE (wotc_wo_id=pWoid);
35236
 
      DELETE FROM xtmfg.wooper
35237
 
      WHERE (wooper_wo_id=pWoid);
35238
 
    END IF;
35239
 
 
35240
 
    IF (ordtype = 'S') THEN
35241
 
      UPDATE coitem SET coitem_order_type=NULL, coitem_order_id=NULL
35242
 
      WHERE coitem_id=ordid;
35243
 
    END IF;
35244
 
 
35245
 
    DELETE FROM wo
35246
 
    WHERE (wo_id=pWoid);
35247
 
  END IF;
35248
 
 
35249
 
  IF (deleteChildren) THEN
35250
 
    returnCode := (SELECT MAX(deleteWo(wo_id, TRUE))
35251
 
                   FROM wo
35252
 
                   WHERE ((wo_ordtype='W')
35253
 
                    AND (wo_ordid=pWoid)));
35254
 
  END IF;
35255
 
 
35256
 
  RETURN 0;
35257
 
END;
35258
 
$_$;
35259
 
 
35260
 
 
35261
 
ALTER FUNCTION public.deletewo(integer, boolean, boolean) OWNER TO admin;
35262
 
 
35263
 
--
35264
 
--
35265
 
 
35266
 
CREATE FUNCTION deletewomaterial(integer) RETURNS integer
35267
 
    LANGUAGE plpgsql
35268
 
    AS $_$
35269
 
DECLARE
35270
 
  pWomatlid ALIAS FOR $1;
35271
 
 
35272
 
BEGIN
35273
 
 
35274
 
  UPDATE wo
35275
 
  SET wo_adhoc=TRUE
35276
 
  FROM womatl
35277
 
  WHERE ((womatl_wo_id=wo_id)
35278
 
   AND (womatl_id=pWomatlid));
35279
 
 
35280
 
  PERFORM deletePr('W', pWomatlid);
35281
 
 
35282
 
  DELETE FROM womatl
35283
 
  WHERE (womatl_id=pWomatlid);
35284
 
 
35285
 
  RETURN 0;
35286
 
END;
35287
 
$_$;
35288
 
 
35289
 
 
35290
 
ALTER FUNCTION public.deletewomaterial(integer) OWNER TO admin;
35291
 
 
35292
 
--
35293
 
--
35294
 
 
35295
 
CREATE FUNCTION detachccpayfromso(integer, integer, integer) RETURNS integer
35296
 
    LANGUAGE plpgsql
35297
 
    AS $_$
35298
 
DECLARE
35299
 
  pcoheadid             ALIAS FOR $1;
35300
 
  pwarehousid           ALIAS FOR $2;
35301
 
  pcustid               ALIAS FOR $3;
35302
 
 
35303
 
BEGIN
35304
 
  RAISE NOTICE 'detachCCPayFromSO(INTEGER, INTEGER, INTEGER): deprecated';
35305
 
  RETURN 0;
35306
 
END;
35307
 
$_$;
35308
 
 
35309
 
 
35310
 
ALTER FUNCTION public.detachccpayfromso(integer, integer, integer) OWNER TO admin;
35311
 
 
35312
 
--
35313
 
--
35314
 
 
35315
 
CREATE FUNCTION detachcontact(integer, integer) RETURNS integer
35316
 
    LANGUAGE plpgsql
35317
 
    AS $_$
35318
 
DECLARE
35319
 
  pcntctId    ALIAS FOR $1;
35320
 
  pcrmacctId  ALIAS FOR $2;
35321
 
BEGIN
35322
 
  UPDATE cntct SET cntct_crmacct_id = NULL
35323
 
  WHERE cntct_id = pcntctId
35324
 
    AND cntct_crmacct_id = pcrmacctId;
35325
 
 
35326
 
  UPDATE crmacct SET crmacct_cntct_id_1 = NULL
35327
 
  WHERE crmacct_id = pcrmacctId
35328
 
    AND crmacct_cntct_id_1 = pcntctId;
35329
 
 
35330
 
  UPDATE crmacct SET crmacct_cntct_id_2 = NULL
35331
 
  WHERE crmacct_id = pcrmacctId
35332
 
    AND crmacct_cntct_id_2 = pcntctId;
35333
 
 
35334
 
  RETURN 0;
35335
 
END;
35336
 
$_$;
35337
 
 
35338
 
 
35339
 
ALTER FUNCTION public.detachcontact(integer, integer) OWNER TO admin;
35340
 
 
35341
 
--
35342
 
--
35343
 
 
35344
 
CREATE FUNCTION detag(text) RETURNS text
35345
 
    LANGUAGE plpgsql IMMUTABLE
35346
 
    AS $_$
35347
 
DECLARE
35348
 
  pSource ALIAS FOR $1;
35349
 
  _result TEXT := '';
35350
 
 
35351
 
BEGIN
35352
 
  SELECT regexp_replace(pSource, E'<[^>]*>', '', 'g') INTO _result;
35353
 
  RETURN _result;
35354
 
END;
35355
 
$_$;
35356
 
 
35357
 
 
35358
 
ALTER FUNCTION public.detag(text) OWNER TO admin;
35359
 
 
35360
 
--
35361
 
--
35362
 
 
35363
 
CREATE FUNCTION detailednnqoh(integer, boolean) RETURNS numeric
35364
 
    LANGUAGE plpgsql
35365
 
    AS $_$
35366
 
--
35367
 
--
35368
 
DECLARE
35369
 
  pItemsiteid ALIAS FOR $1;
35370
 
  pABS ALIAS FOR $2;
35371
 
  _qoh NUMERIC;
35372
 
 
35373
 
BEGIN
35374
 
 
35375
 
  IF (pABS) THEN
35376
 
    SELECT SUM(noNeg(itemloc_qty)) INTO _qoh
35377
 
    FROM itemloc, location
35378
 
    WHERE ( (itemloc_location_id=location_id)
35379
 
     AND (NOT location_netable)
35380
 
     AND (itemloc_itemsite_id=pItemsiteid) );
35381
 
  ELSE
35382
 
    SELECT SUM(itemloc_qty) INTO _qoh
35383
 
    FROM itemloc, location
35384
 
    WHERE ( (itemloc_location_id=location_id)
35385
 
     AND (NOT location_netable)
35386
 
     AND (itemloc_itemsite_id=pItemsiteid) );
35387
 
  END IF;
35388
 
 
35389
 
  IF (_qoh IS NULL) THEN
35390
 
    _qoh := 0;
35391
 
  END IF;
35392
 
 
35393
 
  RETURN _qoh;
35394
 
 
35395
 
END;
35396
 
$_$;
35397
 
 
35398
 
 
35399
 
ALTER FUNCTION public.detailednnqoh(integer, boolean) OWNER TO admin;
35400
 
 
35401
 
--
35402
 
--
35403
 
 
35404
 
CREATE FUNCTION detailedqoh(pitemsiteid integer, pabs boolean) RETURNS numeric
35405
 
    LANGUAGE plpgsql
35406
 
    AS $$
35407
 
DECLARE
35408
 
  _qoh NUMERIC;
35409
 
 
35410
 
BEGIN
35411
 
 
35412
 
  IF (pABS) THEN
35413
 
    SELECT SUM(noNeg(itemloc_qty)) INTO _qoh
35414
 
    FROM itemloc
35415
 
    WHERE (itemloc_itemsite_id=pItemsiteid);
35416
 
  ELSE
35417
 
    SELECT SUM(itemloc_qty) INTO _qoh
35418
 
    FROM itemloc
35419
 
    WHERE (itemloc_itemsite_id=pItemsiteid);
35420
 
  END IF;
35421
 
 
35422
 
  IF (_qoh IS NULL) THEN
35423
 
    _qoh := 0.0;
35424
 
  END IF;
35425
 
 
35426
 
  RETURN _qoh;
35427
 
 
35428
 
END;
35429
 
$$;
35430
 
 
35431
 
 
35432
 
ALTER FUNCTION public.detailedqoh(pitemsiteid integer, pabs boolean) OWNER TO admin;
35433
 
 
35434
 
--
35435
 
--
35436
 
 
35437
 
CREATE FUNCTION determinediscountdate(integer, date) RETURNS date
35438
 
    LANGUAGE plpgsql STABLE
35439
 
    AS $_$
35440
 
DECLARE
35441
 
  pTermsid ALIAS FOR $1;
35442
 
  pSourceDate ALIAS FOR $2;
35443
 
  _discDate DATE;
35444
 
  _p RECORD;
35445
 
 
35446
 
BEGIN
35447
 
 
35448
 
  SELECT terms_type, terms_discdays, terms_cutoffday INTO _p
35449
 
  FROM terms
35450
 
  WHERE (terms_id=pTermsid);
35451
 
  IF (NOT FOUND) THEN
35452
 
    _discDate := pSourceDate;
35453
 
 
35454
 
  ELSIF (_p.terms_type = 'D') THEN
35455
 
    _discDate := (pSourceDate + _p.terms_discdays);
35456
 
 
35457
 
  ELSIF (_p.terms_type = 'P') THEN
35458
 
    IF (date_part('day', pSourceDate) <= _p.terms_cutoffday) THEN
35459
 
      _discDate := (DATE(date_trunc('month', pSourceDate)) + (_p.terms_discdays - 1));
35460
 
    ELSE
35461
 
      _discDate := (DATE(date_trunc('month', pSourceDate)) + (_p.terms_discdays - 1) + INTERVAL '1 month');
35462
 
    END IF;
35463
 
 
35464
 
  ELSE
35465
 
    _discDate := pSourceDate;
35466
 
  END IF;
35467
 
 
35468
 
  RETURN _discDate;
35469
 
 
35470
 
END;
35471
 
$_$;
35472
 
 
35473
 
 
35474
 
ALTER FUNCTION public.determinediscountdate(integer, date) OWNER TO admin;
35475
 
 
35476
 
--
35477
 
--
35478
 
 
35479
 
CREATE FUNCTION determineduedate(integer, date) RETURNS date
35480
 
    LANGUAGE plpgsql STABLE
35481
 
    AS $_$
35482
 
DECLARE
35483
 
  pTermsid ALIAS FOR $1;
35484
 
  pSourceDate ALIAS FOR $2;
35485
 
  _dueDate DATE;
35486
 
  _p RECORD;
35487
 
 
35488
 
BEGIN
35489
 
 
35490
 
  SELECT terms_type, terms_duedays, terms_cutoffday INTO _p
35491
 
  FROM terms
35492
 
  WHERE (terms_id=pTermsid);
35493
 
  IF (NOT FOUND) THEN
35494
 
    _dueDate := pSourceDate;
35495
 
 
35496
 
  ELSIF (_p.terms_type = 'D') THEN
35497
 
    _dueDate := (pSourceDate + _p.terms_duedays);
35498
 
 
35499
 
  ELSIF (_p.terms_type = 'P') THEN
35500
 
    IF (date_part('day', pSourceDate) <= _p.terms_cutoffday) THEN
35501
 
      _dueDate := (DATE(date_trunc('month', pSourceDate)) + (_p.terms_duedays - 1));
35502
 
    ELSE
35503
 
      _dueDate := (DATE(date_trunc('month', pSourceDate)) + (_p.terms_duedays - 1) + INTERVAL '1 month');
35504
 
    END IF;
35505
 
 
35506
 
  ELSE
35507
 
    _dueDate := pSourceDate;
35508
 
  END IF;
35509
 
 
35510
 
  RETURN _dueDate;
35511
 
 
35512
 
END;
35513
 
$_$;
35514
 
 
35515
 
 
35516
 
ALTER FUNCTION public.determineduedate(integer, date) OWNER TO admin;
35517
 
 
35518
 
--
35519
 
--
35520
 
 
35521
 
CREATE FUNCTION digest(text, text) RETURNS bytea
35522
 
    LANGUAGE c IMMUTABLE STRICT
35523
 
    AS '$libdir/pgcrypto', 'pg_digest';
35524
 
 
35525
 
 
35526
 
ALTER FUNCTION public.digest(text, text) OWNER TO admin;
35527
 
 
35528
 
--
35529
 
--
35530
 
 
35531
 
CREATE FUNCTION digest(bytea, text) RETURNS bytea
35532
 
    LANGUAGE c IMMUTABLE STRICT
35533
 
    AS '$libdir/pgcrypto', 'pg_digest';
35534
 
 
35535
 
 
35536
 
ALTER FUNCTION public.digest(bytea, text) OWNER TO admin;
35537
 
 
35538
 
--
35539
 
--
35540
 
 
35541
 
CREATE FUNCTION disablepackage(text) RETURNS integer
35542
 
    LANGUAGE plpgsql
35543
 
    AS $_$
35544
 
DECLARE
35545
 
  ppkgname ALIAS FOR $1;
35546
 
  _i       INTEGER := 0;
35547
 
  _tabs    TEXT[] := ARRAY['cmd',  'cmdarg', 'image',  'metasql',
35548
 
                           'priv', 'report', 'script', 'uiform'];
35549
 
 
35550
 
BEGIN
35551
 
  IF (version() < 'PostgreSQL 8.2') THEN
35552
 
    RETURN -1;
35553
 
  END IF;
35554
 
 
35555
 
  FOR _i IN ARRAY_LOWER(_tabs,1)..ARRAY_UPPER(_tabs,1) LOOP
35556
 
    EXECUTE 'ALTER TABLE ' || ppkgname || '.pkg' || _tabs[_i] ||
35557
 
            ' NO INHERIT public.' || _tabs[_i] || ';';
35558
 
  END LOOP;
35559
 
  
35560
 
  RETURN 0;
35561
 
END;
35562
 
$_$;
35563
 
 
35564
 
 
35565
 
ALTER FUNCTION public.disablepackage(text) OWNER TO admin;
35566
 
 
35567
 
--
35568
 
--
35569
 
 
35570
 
CREATE FUNCTION disablepackage(integer) RETURNS integer
35571
 
    LANGUAGE plpgsql
35572
 
    AS $_$
35573
 
DECLARE
35574
 
  ppkgheadid    ALIAS FOR $1;
35575
 
  _pkgname      TEXT;
35576
 
 
35577
 
BEGIN
35578
 
  SELECT pkghead_name INTO _pkgname
35579
 
  FROM pkghead
35580
 
  WHERE (pkghead_id=ppkgheadid);
35581
 
  IF (NOT FOUND) THEN
35582
 
    RETURN -2;
35583
 
  END IF;
35584
 
 
35585
 
  RETURN disablePackage(_pkgname);
35586
 
END;
35587
 
$_$;
35588
 
 
35589
 
 
35590
 
ALTER FUNCTION public.disablepackage(integer) OWNER TO admin;
35591
 
 
35592
 
--
35593
 
--
35594
 
 
35595
 
CREATE FUNCTION distributeitemlocseries(pitemlocseries integer) RETURNS integer
35596
 
    LANGUAGE plpgsql
35597
 
    AS $$
35598
 
DECLARE
35599
 
  _distCounter     INTEGER;
35600
 
  _itemlocdist     RECORD;
35601
 
  _itemlocid       INTEGER;
35602
 
  _invhistid       INTEGER;
35603
 
  _check           BOOLEAN;
35604
 
  _debug           BOOLEAN := true;
35605
 
BEGIN
35606
 
 
35607
 
  IF (_debug) THEN
35608
 
    RAISE NOTICE 'distributeItemlocSeries, series=%', pItemlocSeries;
35609
 
  END IF;
35610
 
 
35611
 
  _distCounter := 0;
35612
 
 
35613
 
  FOR _itemlocdist IN SELECT itemlocdist_id AS itemlocdistid,
35614
 
                             itemlocdist_source_type AS type,
35615
 
                             itemlocdist_source_id AS sourceid,
35616
 
                             itemlocdist_qty AS qty,
35617
 
                             itemlocdist_itemsite_id AS itemsiteid,
35618
 
                             itemsite_freeze,
35619
 
                             itemlocdist_invhist_id AS invhistid,
35620
 
                             itemlocdist_ls_id AS lotserialid,
35621
 
                             itemlocdist_expiration AS expiration,
35622
 
                             itemlocdist_flush,
35623
 
                             itemlocdist_warranty AS warranty,
35624
 
                             itemlocdist_series AS series
35625
 
                      FROM itemlocdist, itemsite
35626
 
                      WHERE ( (itemlocdist_itemsite_id=itemsite_id)
35627
 
                       AND (itemlocdist_series=pItemlocSeries) )
35628
 
                      ORDER BY itemlocdist_flush DESC LOOP
35629
 
 
35630
 
    _distCounter := _distCounter + 1;
35631
 
    IF (_debug) THEN
35632
 
      RAISE NOTICE 'itemlocdist loop %', _distCounter;
35633
 
      RAISE NOTICE 'itemlocdistid=%', _itemlocdist.itemlocdistid;
35634
 
      RAISE NOTICE 'type=%', _itemlocdist.type;
35635
 
      RAISE NOTICE 'sourceid=%', _itemlocdist.sourceid;
35636
 
      RAISE NOTICE 'qty=%', _itemlocdist.qty;
35637
 
      RAISE NOTICE 'itemsiteid=%', _itemlocdist.itemsiteid;
35638
 
      RAISE NOTICE 'freeze=%', _itemlocdist.itemsite_freeze;
35639
 
      RAISE NOTICE 'invhistid=%', _itemlocdist.invhistid;
35640
 
      RAISE NOTICE 'lotserialid=%', _itemlocdist.lotserialid;
35641
 
      RAISE NOTICE 'expiration=%', _itemlocdist.expiration;
35642
 
      RAISE NOTICE 'flush=%', _itemlocdist.itemlocdist_flush;
35643
 
      RAISE NOTICE 'warranty=%', _itemlocdist.warranty;
35644
 
    END IF;
35645
 
 
35646
 
    IF (NOT _itemlocdist.itemsite_freeze) THEN
35647
 
        PERFORM postInvHist(_itemlocdist.invhistid);
35648
 
    END IF;
35649
 
 
35650
 
    UPDATE invhist
35651
 
    SET invhist_hasdetail=TRUE
35652
 
    WHERE ( (NOT invhist_hasdetail)
35653
 
     AND (invhist_id=_itemlocdist.invhistid) );
35654
 
 
35655
 
    IF (_itemlocdist.itemlocdist_flush) THEN
35656
 
      INSERT INTO invdetail
35657
 
      ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id,
35658
 
        invdetail_qty, invdetail_qty_before, invdetail_qty_after, invdetail_expiration,
35659
 
        invdetail_warrpurc )
35660
 
      SELECT _itemlocdist.invhistid, itemloc_location_id, itemloc_ls_id,
35661
 
             (itemloc_qty * -1), itemloc_qty, 0, itemloc_expiration, 
35662
 
             _itemlocdist.warranty
35663
 
      FROM itemloc
35664
 
      WHERE ( (itemloc_qty <> 0)
35665
 
       AND (itemloc_id=_itemlocdist.sourceid) );
35666
 
 
35667
 
      IF (NOT _itemlocdist.itemsite_freeze) THEN
35668
 
        DELETE FROM itemloc
35669
 
        WHERE (itemloc_id=_itemlocdist.sourceid);
35670
 
      END IF;
35671
 
 
35672
 
    ELSE
35673
 
      IF (_itemlocdist.type = 'L') THEN
35674
 
        SELECT itemloc_id INTO _itemlocid
35675
 
        FROM itemloc
35676
 
        WHERE ( (itemloc_itemsite_id=_itemlocdist.itemsiteid)
35677
 
         AND (itemloc_location_id=_itemlocdist.sourceid)
35678
 
         AND (COALESCE(itemloc_ls_id,-1)=COALESCE(_itemlocdist.lotserialid,-1))
35679
 
         AND (COALESCE(itemloc_expiration,endOfTime())=COALESCE(_itemlocdist.expiration,endOfTime()))
35680
 
         AND (COALESCE(itemloc_warrpurc,endoftime())=COALESCE(_itemlocdist.warranty,endoftime())) );
35681
 
 
35682
 
        IF (NOT FOUND) THEN
35683
 
          SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _itemlocid;
35684
 
 
35685
 
          INSERT INTO itemloc
35686
 
          ( itemloc_id, itemloc_itemsite_id,
35687
 
            itemloc_location_id, itemloc_qty,
35688
 
            itemloc_ls_id, itemloc_expiration,
35689
 
            itemloc_warrpurc )
35690
 
          VALUES
35691
 
          ( _itemlocid, _itemlocdist.itemsiteid,
35692
 
            _itemlocdist.sourceid, 0,
35693
 
            _itemlocdist.lotserialid, _itemlocdist.expiration,
35694
 
            _itemlocdist.warranty );
35695
 
        END IF;
35696
 
 
35697
 
      ELSE
35698
 
        _itemlocid = _itemlocdist.sourceid;
35699
 
 
35700
 
        IF (_itemlocid IS NOT NULL AND (SELECT count(itemloc_id) = 0 FROM itemloc WHERE itemloc_id=_itemlocid)) THEN
35701
 
          RAISE EXCEPTION 'No record to distribute against. Someone else may have already distributed this record.';
35702
 
        END IF;
35703
 
      END IF;
35704
 
 
35705
 
      INSERT INTO invdetail
35706
 
      (invdetail_invhist_id, invdetail_location_id, invdetail_ls_id,
35707
 
       invdetail_qty, invdetail_qty_before, invdetail_qty_after, invdetail_expiration,
35708
 
       invdetail_warrpurc)
35709
 
      SELECT _itemlocdist.invhistid, itemloc_location_id, _itemlocdist.lotserialid,
35710
 
             _itemlocdist.qty, itemloc_qty, (itemloc_qty + _itemlocdist.qty),
35711
 
             itemloc_expiration,_itemlocdist.warranty
35712
 
      FROM itemloc
35713
 
      WHERE (itemloc_id=_itemlocid);
35714
 
 
35715
 
      IF (NOT _itemlocdist.itemsite_freeze) THEN
35716
 
        UPDATE itemloc
35717
 
        SET itemloc_qty = (itemloc_qty + _itemlocdist.qty)
35718
 
        WHERE (itemloc_id=_itemlocid);
35719
 
      END IF;
35720
 
 
35721
 
    END IF;
35722
 
 
35723
 
    IF (NOT _itemlocdist.itemsite_freeze) THEN
35724
 
      DELETE FROM itemloc
35725
 
      WHERE ( (itemloc_qty=0)
35726
 
       AND (itemloc_id=_itemlocid) );
35727
 
    END IF;
35728
 
 
35729
 
  END LOOP;
35730
 
 
35731
 
  DELETE FROM itemlocdist
35732
 
  WHERE (itemlocdist_series=pItemlocSeries);
35733
 
 
35734
 
  RETURN _distCounter;
35735
 
 
35736
 
END;
35737
 
$$;
35738
 
 
35739
 
 
35740
 
ALTER FUNCTION public.distributeitemlocseries(pitemlocseries integer) OWNER TO admin;
35741
 
 
35742
 
--
35743
 
--
35744
 
 
35745
 
CREATE FUNCTION distributetodefault(integer) RETURNS integer
35746
 
    LANGUAGE plpgsql
35747
 
    AS $_$
35748
 
DECLARE
35749
 
  pItemlocdistid ALIAS FOR $1;
35750
 
 
35751
 
BEGIN
35752
 
 
35753
 
  RETURN distributeToDefault(pItemlocdistid, 'O');
35754
 
 
35755
 
END;
35756
 
$_$;
35757
 
 
35758
 
 
35759
 
ALTER FUNCTION public.distributetodefault(integer) OWNER TO admin;
35760
 
 
35761
 
--
35762
 
--
35763
 
 
35764
 
CREATE FUNCTION distributetodefault(integer, text) RETURNS integer
35765
 
    LANGUAGE plpgsql
35766
 
    AS $_$
35767
 
DECLARE
35768
 
  pItemlocdistid ALIAS FOR $1;
35769
 
  pTranstype ALIAS FOR $2;
35770
 
  _locationid INTEGER;
35771
 
  _itemlocdistid INTEGER;
35772
 
  _qty NUMERIC;
35773
 
 
35774
 
BEGIN
35775
 
 
35776
 
  SELECT CASE WHEN (pTranstype='R') THEN itemsite_recvlocation_id
35777
 
              WHEN (pTranstype='I') THEN itemsite_issuelocation_id
35778
 
              ELSE itemsite_location_id
35779
 
         END INTO _locationid
35780
 
  FROM itemlocdist, itemsite
35781
 
  WHERE ( (itemlocdist_itemsite_id=itemsite_id)
35782
 
   AND (itemlocdist_id=pItemlocdistid) );
35783
 
  IF ( (NOT FOUND) OR (_locationid = -1) ) THEN
35784
 
    RETURN -1;
35785
 
  END IF;
35786
 
 
35787
 
  SELECT (p.itemlocdist_qty - COALESCE(SUM(c.itemlocdist_qty), 0)) INTO _qty
35788
 
  FROM itemlocdist AS p LEFT OUTER JOIN itemlocdist AS c ON (c.itemlocdist_itemlocdist_id=p.itemlocdist_id)
35789
 
  WHERE (p.itemlocdist_id=pItemlocdistid)
35790
 
  GROUP BY p.itemlocdist_qty;
35791
 
 
35792
 
  IF (_qty = 0) THEN
35793
 
    RETURN -2;
35794
 
  END IF;
35795
 
 
35796
 
  SELECT target.itemlocdist_id INTO _itemlocdistid
35797
 
  FROM itemlocdist AS source, itemlocdist AS target, itemloc, itemsite
35798
 
  WHERE ( (target.itemlocdist_source_type='L')
35799
 
   AND (target.itemlocdist_source_id=_locationid)
35800
 
   AND (target.itemlocdist_itemsite_id=source.itemlocdist_itemsite_id)
35801
 
   AND (COALESCE(target.itemlocdist_ls_id)=COALESCE(source.itemlocdist_ls_id))
35802
 
   AND (target.itemlocdist_expiration=source.itemlocdist_expiration)
35803
 
   AND (target.itemlocdist_itemlocdist_id=source.itemlocdist_itemlocdist_id)
35804
 
   AND (target.itemlocdist_itemsite_id=itemsite_id)
35805
 
   AND (source.itemlocdist_id=pItemlocdistid) );
35806
 
 
35807
 
  IF (FOUND) THEN
35808
 
    UPDATE itemlocdist
35809
 
    SET itemlocdist_qty = (itemlocdist_qty + _qty)
35810
 
    WHERE (itemlocdist_id=_itemlocdistid);
35811
 
 
35812
 
    RETURN _itemlocdistid;
35813
 
  END IF;
35814
 
 
35815
 
  SELECT NEXTVAL('itemlocdist_itemlocdist_id_seq') INTO _itemlocdistid;
35816
 
 
35817
 
  INSERT INTO itemlocdist
35818
 
  ( itemlocdist_id, itemlocdist_itemlocdist_id, itemlocdist_source_type,
35819
 
    itemlocdist_ls_id, itemlocdist_expiration,
35820
 
    itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_qty )
35821
 
  SELECT _itemlocdistid, pItemlocdistid, 'L',
35822
 
         itemlocdist_ls_id, itemlocdist_expiration,
35823
 
         _locationid, itemlocdist_itemsite_id, _qty
35824
 
  FROM itemlocdist
35825
 
  WHERE (itemlocdist_id=pItemlocdistid);
35826
 
 
35827
 
  RETURN _itemlocdistid;
35828
 
 
35829
 
END;
35830
 
$_$;
35831
 
 
35832
 
 
35833
 
ALTER FUNCTION public.distributetodefault(integer, text) OWNER TO admin;
35834
 
 
35835
 
--
35836
 
--
35837
 
 
35838
 
CREATE FUNCTION distributetodefaultitemloc(integer) RETURNS integer
35839
 
    LANGUAGE plpgsql
35840
 
    AS $_$
35841
 
DECLARE
35842
 
  pItemlocdistid ALIAS FOR $1;
35843
 
 
35844
 
BEGIN
35845
 
 
35846
 
  RETURN distributeToDefaultItemLoc(pItemlocdistid, 'O');
35847
 
 
35848
 
END;
35849
 
$_$;
35850
 
 
35851
 
 
35852
 
ALTER FUNCTION public.distributetodefaultitemloc(integer) OWNER TO admin;
35853
 
 
35854
 
--
35855
 
--
35856
 
 
35857
 
CREATE FUNCTION distributetodefaultitemloc(integer, text) RETURNS integer
35858
 
    LANGUAGE plpgsql
35859
 
    AS $_$
35860
 
DECLARE
35861
 
  pItemlocdistid ALIAS FOR $1;
35862
 
  pTranstype ALIAS FOR $2;
35863
 
  _itemlocid INTEGER;
35864
 
  _itemlocdistid INTEGER;
35865
 
  _qty NUMERIC;
35866
 
 
35867
 
BEGIN
35868
 
 
35869
 
  SELECT itemloc_id INTO _itemlocid
35870
 
    FROM itemlocdist, itemsite, itemloc
35871
 
   WHERE ((itemlocdist_itemsite_id=itemsite_id)
35872
 
     AND ( (itemsite_location_id=itemloc_location_id AND pTranstype='O') OR
35873
 
           (itemsite_recvlocation_id=itemloc_location_id AND pTranstype='R') OR
35874
 
           (itemsite_issuelocation_id=itemloc_location_id AND pTranstype='I') )
35875
 
     AND (itemloc_itemsite_id=itemsite_id)
35876
 
     AND (itemlocdist_id=pItemlocdistid));
35877
 
  IF ( (NOT FOUND) OR (_itemlocid = -1) ) THEN
35878
 
    RETURN -1;
35879
 
  END IF;
35880
 
 
35881
 
  SELECT (p.itemlocdist_qty - COALESCE(SUM(c.itemlocdist_qty), 0)) INTO _qty
35882
 
    FROM itemlocdist AS p LEFT OUTER JOIN itemlocdist AS c
35883
 
      ON (c.itemlocdist_itemlocdist_id=p.itemlocdist_id)
35884
 
   WHERE (p.itemlocdist_id=pItemlocdistid)
35885
 
   GROUP BY p.itemlocdist_qty;
35886
 
 
35887
 
  IF (_qty = 0) THEN
35888
 
    RETURN -2;
35889
 
  END IF;
35890
 
 
35891
 
  SELECT target.itemlocdist_id INTO _itemlocdistid
35892
 
  FROM itemlocdist AS source, itemlocdist AS target
35893
 
  WHERE ( (target.itemlocdist_source_type='I')
35894
 
   AND (target.itemlocdist_source_id=_itemlocid)
35895
 
   AND (COALESCE(target.itemlocdist_ls_id,-1)=COALESCE(source.itemlocdist_ls_id,-1))
35896
 
   AND (target.itemlocdist_expiration=source.itemlocdist_expiration)
35897
 
   AND (target.itemlocdist_itemlocdist_id=source.itemlocdist_id)
35898
 
   AND (source.itemlocdist_id=pItemlocdistid) );
35899
 
 
35900
 
  IF (FOUND) THEN
35901
 
    UPDATE itemlocdist
35902
 
    SET itemlocdist_qty = (itemlocdist_qty + _qty)
35903
 
    WHERE (itemlocdist_id=_itemlocdistid);
35904
 
 
35905
 
    RETURN _itemlocdistid;
35906
 
  END IF;
35907
 
 
35908
 
  SELECT NEXTVAL('itemlocdist_itemlocdist_id_seq') INTO _itemlocdistid;
35909
 
 
35910
 
  INSERT INTO itemlocdist
35911
 
  ( itemlocdist_id, itemlocdist_itemlocdist_id,
35912
 
    itemlocdist_source_type, itemlocdist_source_id,
35913
 
    itemlocdist_qty, itemlocdist_expiration )
35914
 
  VALUES
35915
 
  ( _itemlocdistid, pItemlocdistid,
35916
 
    'I', _itemlocid,
35917
 
    _qty, endOfTime() );
35918
 
 
35919
 
  RETURN _itemlocdistid;
35920
 
 
35921
 
END;
35922
 
$_$;
35923
 
 
35924
 
 
35925
 
ALTER FUNCTION public.distributetodefaultitemloc(integer, text) OWNER TO admin;
35926
 
 
35927
 
--
35928
 
--
35929
 
 
35930
 
CREATE FUNCTION distributetolocations(pitemlocdistid integer) RETURNS integer
35931
 
    LANGUAGE plpgsql
35932
 
    AS $$
35933
 
DECLARE
35934
 
  _distCounter INTEGER;
35935
 
  _itemlocdist RECORD;
35936
 
  _itemlocid INTEGER;
35937
 
  _runningQty NUMERIC;
35938
 
  _tmp RECORD;
35939
 
 
35940
 
BEGIN
35941
 
 
35942
 
  _distCounter := 0;
35943
 
  _runningQty  := 0;
35944
 
 
35945
 
  SELECT itemsite_id
35946
 
    INTO _tmp
35947
 
    FROM itemsite
35948
 
   WHERE(itemsite_id in (SELECT DISTINCT itemlocdist_itemsite_id
35949
 
                           FROM itemlocdist
35950
 
                          WHERE(itemlocdist_id=pItemlocdistid)))
35951
 
     FOR UPDATE;
35952
 
 
35953
 
  FOR _itemlocdist IN SELECT c.itemlocdist_id AS itemlocdistid,
35954
 
                             c.itemlocdist_source_type AS type,
35955
 
                             c.itemlocdist_source_id AS sourceid,
35956
 
                             c.itemlocdist_qty AS qty,
35957
 
                             p.itemlocdist_itemsite_id AS itemsiteid,
35958
 
                             itemsite_freeze,
35959
 
                             p.itemlocdist_invhist_id AS invhistid,
35960
 
                             p.itemlocdist_ls_id AS lotserialid,
35961
 
                             p.itemlocdist_expiration AS expiration,
35962
 
                             p.itemlocdist_warranty AS warranty,
35963
 
                             p.itemlocdist_order_type AS ordertype,
35964
 
                             p.itemlocdist_order_id AS orderid,
35965
 
                             p.itemlocdist_series AS series
35966
 
                      FROM itemlocdist AS c, itemlocdist AS p, itemsite
35967
 
                      WHERE ( (c.itemlocdist_itemlocdist_id=p.itemlocdist_id)
35968
 
                       AND (p.itemlocdist_source_type='O')
35969
 
                       AND (p.itemlocdist_itemsite_id=itemsite_id)
35970
 
                       AND (p.itemlocdist_id=pItemlocdistid) ) LOOP
35971
 
 
35972
 
    _distCounter := _distCounter + 1;
35973
 
 
35974
 
    IF (_itemlocdist.type = 'L') THEN
35975
 
      SELECT itemloc_id INTO _itemlocid
35976
 
      FROM itemloc
35977
 
      WHERE ( (itemloc_itemsite_id=_itemlocdist.itemsiteid)
35978
 
       AND (itemloc_location_id=_itemlocdist.sourceid)
35979
 
       AND (COALESCE(itemloc_ls_id, -1)=COALESCE(_itemlocdist.lotserialid, -1))
35980
 
       AND (COALESCE(itemloc_expiration,endOfTime())=COALESCE(_itemlocdist.expiration,endOfTime()))
35981
 
       AND (COALESCE(itemloc_warrpurc,endoftime())=COALESCE(_itemlocdist.warranty,endoftime())) );
35982
 
 
35983
 
      IF (NOT FOUND) THEN
35984
 
        SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _itemlocid;
35985
 
        INSERT INTO itemloc
35986
 
        ( itemloc_id, itemloc_itemsite_id,
35987
 
          itemloc_location_id, itemloc_qty,
35988
 
          itemloc_ls_id, itemloc_expiration,
35989
 
          itemloc_warrpurc )
35990
 
        VALUES
35991
 
        ( _itemlocid, _itemlocdist.itemsiteid,
35992
 
          _itemlocdist.sourceid, 0,
35993
 
          _itemlocdist.lotserialid, _itemlocdist.expiration,
35994
 
          _itemlocdist.warranty );
35995
 
      END IF;
35996
 
 
35997
 
    ELSE
35998
 
      _itemlocid = _itemlocdist.sourceid;
35999
 
 
36000
 
      IF (_itemlocid IS NOT NULL AND (SELECT count(itemloc_id) = 0 FROM itemloc WHERE itemloc_id=_itemlocid)) THEN
36001
 
        RAISE EXCEPTION 'No record to distribute against. Someone else may have already distributed this record.';
36002
 
      END IF;
36003
 
    END IF;
36004
 
 
36005
 
    INSERT INTO invdetail
36006
 
    ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id,
36007
 
      invdetail_qty, invdetail_qty_before, invdetail_qty_after, invdetail_expiration, 
36008
 
      invdetail_warrpurc )
36009
 
    SELECT _itemlocdist.invhistid, itemloc_location_id, itemloc_ls_id,
36010
 
           _itemlocdist.qty, itemloc_qty, (itemloc_qty + _itemlocdist.qty),
36011
 
           itemloc_expiration,_itemlocdist.warranty
36012
 
    FROM itemloc
36013
 
    WHERE (itemloc_id=_itemlocid);
36014
 
 
36015
 
    UPDATE invhist
36016
 
    SET invhist_hasdetail=TRUE
36017
 
    WHERE ((invhist_hasdetail=FALSE)
36018
 
     AND (invhist_id=_itemlocdist.invhistid));
36019
 
 
36020
 
    IF (NOT _itemlocdist.itemsite_freeze) THEN
36021
 
      UPDATE itemloc
36022
 
      SET itemloc_qty = (itemloc_qty + _itemlocdist.qty)
36023
 
      WHERE (itemloc_id=_itemlocid);
36024
 
 
36025
 
      PERFORM postInvHist(_itemlocdist.invhistid);
36026
 
 
36027
 
      IF ( (SELECT fetchMetricBool('EnableSOReservationsByLocation')) AND
36028
 
           (_itemlocdist.qty < 0) ) THEN
36029
 
 
36030
 
        IF (_itemlocdist.ordertype = 'SO') THEN
36031
 
          INSERT INTO shipitemlocrsrv
36032
 
          SELECT nextval('shipitemlocrsrv_shipitemlocrsrv_id_seq'),
36033
 
            shipitem_id, itemloc_itemsite_id, itemloc_location_id,
36034
 
            itemloc_ls_id, itemloc_expiration, itemloc_warrpurc,
36035
 
            least((_itemlocdist.qty * -1.0), reserve_qty)
36036
 
          FROM shipitem, itemloc
36037
 
            JOIN reserve ON (itemloc_id=reserve_supply_id AND reserve_supply_type='I')
36038
 
          WHERE ( (shipitem_invhist_id=_itemlocdist.invhistid)
36039
 
            AND   (itemloc_id=_itemlocid)
36040
 
            AND   (reserve_demand_type=_itemlocdist.ordertype)
36041
 
            AND   (reserve_demand_id=_itemlocdist.orderid) );
36042
 
        END IF;
36043
 
 
36044
 
        UPDATE reserve
36045
 
        SET reserve_qty = (reserve_qty + _itemlocdist.qty)
36046
 
        WHERE ( (reserve_supply_id=_itemlocid)
36047
 
          AND   (reserve_supply_type='I')
36048
 
          AND   (reserve_demand_type=_itemlocdist.ordertype)
36049
 
          AND   (reserve_demand_id=_itemlocdist.orderid) );
36050
 
          
36051
 
        DELETE FROM reserve
36052
 
        WHERE ( (reserve_supply_id=_itemlocid)
36053
 
          AND   (reserve_supply_type='I')
36054
 
          AND   (reserve_demand_type=_itemlocdist.ordertype)
36055
 
          AND   (reserve_demand_id=_itemlocdist.orderid)
36056
 
          AND   (reserve_qty=0) );
36057
 
      END IF;
36058
 
    END IF;
36059
 
 
36060
 
    _runningQty := _runningQty + _itemlocdist.qty;
36061
 
 
36062
 
    DELETE FROM itemlocdist
36063
 
    WHERE (itemlocdist_id=_itemlocdist.itemlocdistid);
36064
 
 
36065
 
    IF (NOT _itemlocdist.itemsite_freeze) THEN
36066
 
      DELETE FROM itemloc
36067
 
      WHERE ( (itemloc_qty=0)
36068
 
       AND (itemloc_id=_itemlocid) );
36069
 
    END IF;
36070
 
 
36071
 
  END LOOP;
36072
 
 
36073
 
  IF ( ( SELECT itemlocdist_qty
36074
 
         FROM itemlocdist
36075
 
         WHERE (itemlocdist_id=pItemlocdistid) ) = _runningQty) THEN
36076
 
    DELETE FROM itemlocdist
36077
 
    WHERE (itemlocdist_id=pItemlocdistid);
36078
 
  ELSE
36079
 
    UPDATE itemlocdist
36080
 
    SET itemlocdist_qty = (itemlocdist_qty - _runningQty)
36081
 
    WHERE (itemlocdist_id=pItemlocdistid);
36082
 
  END IF;
36083
 
 
36084
 
  RETURN _distCounter;
36085
 
 
36086
 
END;
36087
 
$$;
36088
 
 
36089
 
 
36090
 
ALTER FUNCTION public.distributetolocations(pitemlocdistid integer) OWNER TO admin;
36091
 
 
36092
 
--
36093
 
--
36094
 
 
36095
 
CREATE FUNCTION distributevoucherline(integer, integer, integer) RETURNS integer
36096
 
    LANGUAGE plpgsql
36097
 
    AS $_$
36098
 
DECLARE
36099
 
  pVoucherId ALIAS FOR $1;
36100
 
  pPoitemId ALIAS FOR $2;
36101
 
  pCurrId ALIAS FOR $3;
36102
 
  _count INTEGER;
36103
 
  _costelemId INTEGER;
36104
 
  _close BOOLEAN;
36105
 
  _r RECORD;
36106
 
  _qtyOrdered NUMERIC;
36107
 
  _voitemId INTEGER;
36108
 
  _taxtypeid INTEGER;
36109
 
 
36110
 
BEGIN
36111
 
 
36112
 
 
36113
 
  SELECT COALESCE(COUNT(*),0) INTO _count
36114
 
        FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id)
36115
 
        WHERE ((poitem_id=pPoitemid)
36116
 
        AND (pohead_curr_id=pCurrId));
36117
 
  IF (_count = 0) THEN
36118
 
        RETURN -3;
36119
 
  END IF;
36120
 
 
36121
 
 
36122
 
        SELECT COALESCE(COUNT(*),0) INTO _count
36123
 
                FROM itemcost, item, itemsite, poitem
36124
 
                WHERE ((itemcost_item_id=item_id)
36125
 
                AND (item_id=itemsite_item_id)
36126
 
                AND (itemsite_id=poitem_itemsite_id)
36127
 
                AND (poitem_id=pPoitemId));
36128
 
 
36129
 
        IF (_count > 1) THEN
36130
 
                RETURN -5;
36131
 
        ELSEIF (_count = 1) THEN
36132
 
                SELECT itemcost_costelem_id INTO _costelemId
36133
 
                        FROM itemcost, item, itemsite, poitem
36134
 
                        WHERE ((itemcost_item_id=item_id)
36135
 
                        AND (item_id=itemsite_item_id)
36136
 
                        AND (itemsite_id=poitem_itemsite_id)
36137
 
                        AND (poitem_id=pPoitemId));
36138
 
        ELSE
36139
 
                SELECT costelem_id INTO _costelemId
36140
 
                        FROM costelem
36141
 
                        WHERE (costelem_type='Material');
36142
 
        END IF;
36143
 
 
36144
 
 
36145
 
 
36146
 
        UPDATE recv SET recv_vohead_id=NULL, recv_voitem_id=NULL
36147
 
                WHERE ((recv_vohead_id=pVoucherId)
36148
 
                AND (recv_orderitem_id=pPoitemId)
36149
 
                AND (recv_order_type='PO'));
36150
 
        UPDATE poreject SET poreject_vohead_id=NULL, poreject_voitem_id=NULL
36151
 
                WHERE ((poreject_vohead_id=pVoucherId)
36152
 
                AND (poreject_poitem_id=pPoitemId));
36153
 
        DELETE FROM vodist
36154
 
                WHERE ((vodist_poitem_id=pPoitemId)
36155
 
                AND (vodist_vohead_id=pVoucherId));
36156
 
        DELETE FROM voitem
36157
 
                WHERE ((voitem_poitem_id=pPoitemId)
36158
 
                AND (voitem_vohead_id=pVoucherId));
36159
 
 
36160
 
 
36161
 
        SELECT  COALESCE(SUM(qty_received),0) AS qty_received,
36162
 
                COALESCE(SUM(qty_rejected),0) AS qty_rejected,
36163
 
                COALESCE(SUM(qty_vouchered),0) AS qty_vouchered,
36164
 
                round(COALESCE(SUM(balance),0),2) AS balance,
36165
 
                round(COALESCE(SUM(freight),0),2) AS freight INTO _r
36166
 
         FROM   (
36167
 
                SELECT  recv_qty AS qty_received,
36168
 
                        0 AS qty_rejected,
36169
 
                        0 AS qty_vouchered,
36170
 
                        (recv_qty * COALESCE(recv_purchcost, poitem_unitprice)) AS balance,
36171
 
                        recv_freight AS freight
36172
 
                FROM poitem JOIN recv ON ((recv_orderitem_id=poitem_id) AND
36173
 
                                          (recv_order_type='PO'))
36174
 
                WHERE ( (recv_vohead_id IS NULL)
36175
 
                        AND (NOT recv_invoiced)
36176
 
                        AND (recv_posted)
36177
 
                        AND (poitem_id=pPoitemId) )
36178
 
 
36179
 
                UNION ALL
36180
 
 
36181
 
                SELECT  0 AS qty_received,
36182
 
                        (poreject_qty) AS qty_rejected,
36183
 
                        0 AS qty_vouchered,
36184
 
                        (poreject_qty * -1 * COALESCE(recv_purchcost, poitem_unitprice)) AS balance,
36185
 
                        0 AS freight
36186
 
                FROM poitem JOIN poreject ON (poreject_poitem_id=poitem_id)
36187
 
                            LEFT OUTER JOIN recv ON (recv_id=poreject_recv_id)
36188
 
                WHERE ( (poreject_posted)
36189
 
                        AND (poreject_vohead_id IS NULL)
36190
 
                        AND (NOT poreject_invoiced)
36191
 
                        AND (poitem_id=pPoitemId) )
36192
 
 
36193
 
                UNION ALL
36194
 
 
36195
 
                SELECT  0 AS qty_received,
36196
 
                        0 AS qty_rejected,
36197
 
                        voitem_qty AS qty_vouchered,
36198
 
                        0 AS balance,
36199
 
                        0 AS freight
36200
 
                FROM voitem, poitem
36201
 
                WHERE ( (voitem_poitem_id=pPoitemId)
36202
 
                        AND (poitem_id=voitem_poitem_id) )
36203
 
                ) AS data;
36204
 
 
36205
 
                SELECT poitem_qty_ordered INTO _qtyOrdered
36206
 
                FROM poitem
36207
 
                WHERE (poitem_id=pPoitemId);
36208
 
 
36209
 
        IF _r.balance < 0 THEN
36210
 
                RETURN -4;
36211
 
        ELSEIF ( ((_r.qty_received <> 0) OR (_r.qty_received <> 0)) AND (_r.qty_received - _r.qty_rejected = 0) ) THEN
36212
 
                RETURN -2;
36213
 
        ELSEIF ((_r.qty_received - _r.qty_rejected) = 0) THEN
36214
 
                RETURN 0;
36215
 
        END IF;
36216
 
 
36217
 
 
36218
 
        IF (_r.qty_received -_r.qty_rejected + _r.qty_vouchered) >= _qtyOrdered THEN
36219
 
                _close:=True;
36220
 
        ELSE
36221
 
                _close:=False;
36222
 
        END IF;
36223
 
 
36224
 
 
36225
 
 
36226
 
        INSERT INTO vodist
36227
 
                (vodist_poitem_id,vodist_vohead_id,vodist_costelem_id,vodist_amount,vodist_qty,vodist_expcat_id)
36228
 
                VALUES (pPoitemId,pVoucherId,_costelemId,_r.balance,(_r.qty_received -_r.qty_rejected),-1);
36229
 
 
36230
 
        SELECT poitem_taxtype_id INTO _taxtypeid
36231
 
        FROM poitem
36232
 
        WHERE (poitem_id=pPoitemId);
36233
 
 
36234
 
        SELECT NEXTVAL('voitem_voitem_id_seq') INTO _voitemId;
36235
 
 
36236
 
        INSERT INTO voitem (voitem_id,voitem_vohead_id,voitem_poitem_id,voitem_close,voitem_qty,voitem_freight, voitem_taxtype_id)
36237
 
                VALUES (_voitemId,pVoucherId,pPoitemId,_close,(_r.qty_received -_r.qty_rejected),_r.freight, _taxtypeid);
36238
 
 
36239
 
 
36240
 
        UPDATE recv
36241
 
        SET recv_vohead_id=pVoucherId, recv_voitem_id=_voitemId
36242
 
        WHERE ((recv_orderitem_id=pPoitemId)
36243
 
          AND  (recv_order_type='PO')
36244
 
          AND  (recv_vohead_id IS NULL));
36245
 
 
36246
 
        UPDATE poreject
36247
 
        SET poreject_vohead_id=pVoucherId,poreject_voitem_id=_voitemId
36248
 
        WHERE ((poreject_poitem_id=pPoitemId)
36249
 
        AND (NOT poreject_invoiced)
36250
 
        AND (poreject_vohead_id IS NULL));
36251
 
 
36252
 
 
36253
 
  RETURN 1;
36254
 
 
36255
 
END;
36256
 
$_$;
36257
 
 
36258
 
 
36259
 
ALTER FUNCTION public.distributevoucherline(integer, integer, integer) OWNER TO admin;
36260
 
 
36261
 
--
36262
 
--
36263
 
 
36264
 
CREATE FUNCTION dopostcosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer
36265
 
    LANGUAGE plpgsql
36266
 
    AS $_$
36267
 
DECLARE
36268
 
 
36269
 
  pMaterial ALIAS FOR $1;
36270
 
  plowerMaterial ALIAS FOR $2;
36271
 
  pdirectLabor ALIAS FOR $3;
36272
 
  plowerDirectLabor ALIAS FOR $4;
36273
 
  poverhead ALIAS FOR $5;
36274
 
  plowerOverhead ALIAS FOR $6;
36275
 
  pmachOverhead ALIAS FOR $7;
36276
 
  plowerMachOverhead ALIAS FOR $8;
36277
 
  pUser ALIAS FOR $9;
36278
 
  plowerUser ALIAS FOR $10;
36279
 
  prollUp ALIAS FOR $11;
36280
 
  _item RECORD;
36281
 
  _result INTEGER := 0;
36282
 
 
36283
 
BEGIN
36284
 
 
36285
 
  PERFORM resetLowLevelCode(-1);
36286
 
 
36287
 
  FOR _item IN SELECT costUpdate_item_id
36288
 
            FROM costUpdate
36289
 
            ORDER BY costUpdate_lowlevel_code DESC LOOP
36290
 
    PERFORM doPostCosts(_item.costUpdate_item_id, FALSE,
36291
 
                       pMaterial, plowerMaterial, pdirectLabor,
36292
 
                       plowerDirectLabor, poverhead, plowerOverhead,
36293
 
                       pmachOverhead, plowerMachOverhead,
36294
 
                       puser, plowerUser, prollUp);
36295
 
  END LOOP;
36296
 
 
36297
 
  RETURN _result;
36298
 
 
36299
 
END;
36300
 
 $_$;
36301
 
 
36302
 
 
36303
 
ALTER FUNCTION public.dopostcosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin;
36304
 
 
36305
 
--
36306
 
--
36307
 
 
36308
 
CREATE FUNCTION dopostcosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer
36309
 
    LANGUAGE plpgsql
36310
 
    AS $_$
36311
 
DECLARE
36312
 
 
36313
 
  pItemId ALIAS FOR $1;
36314
 
  pResetLowLevel ALIAS FOR $2;
36315
 
  pMaterial ALIAS FOR $3;
36316
 
  plowerMaterial ALIAS FOR $4;
36317
 
  pdirectLabor ALIAS FOR $5;
36318
 
  plowerDirectLabor ALIAS FOR $6;
36319
 
  poverhead ALIAS FOR $7;
36320
 
  plowerOverhead ALIAS FOR $8;
36321
 
  pmachOverhead ALIAS FOR $9;
36322
 
  plowerMachOverhead ALIAS FOR $10;
36323
 
  pUser ALIAS FOR $11;
36324
 
  plowerUser ALIAS FOR $12;
36325
 
  prollUp ALIAS FOR $13;
36326
 
  _itemcost RECORD;
36327
 
  _result INTEGER;
36328
 
 
36329
 
BEGIN
36330
 
 
36331
 
    IF (pResetLowLevel) THEN
36332
 
        PERFORM resetLowLevelCode(pItemId);
36333
 
    END IF;
36334
 
 
36335
 
    FOR _itemcost IN SELECT itemcost_id, costelem_sys, costelem_type,
36336
 
                            itemcost_lowlevel,
36337
 
                            costUpdate_lowlevel_code, costUpdate_item_type
36338
 
            FROM itemcost, costelem, costUpdate
36339
 
            WHERE itemcost_item_id = pItemId
36340
 
              AND costUpdate_item_id = itemcost_item_id
36341
 
              AND itemcost_costelem_id = costelem_id LOOP
36342
 
      IF (NOT _itemcost.costelem_sys) THEN
36343
 
        IF ( (pUser) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN
36344
 
          PERFORM postCost(_itemcost.itemcost_id);
36345
 
          _result := _result + 1;
36346
 
        END IF;
36347
 
        IF ( (plowerUser) AND ( _itemcost.itemcost_lowlevel) ) THEN
36348
 
          PERFORM postCost(_itemcost.itemcost_id);
36349
 
          _result := _result + 1;
36350
 
        END IF;
36351
 
      END IF;
36352
 
 
36353
 
      IF (_itemcost.costelem_type = 'Material') THEN
36354
 
        IF ( (pMaterial) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN
36355
 
          PERFORM postCost(_itemcost.itemcost_id);
36356
 
          _result := _result + 1;
36357
 
        END IF;
36358
 
        IF ( (plowerMaterial) AND ( _itemcost.itemcost_lowlevel) ) THEN
36359
 
          PERFORM postCost(_itemcost.itemcost_id);
36360
 
          _result := _result + 1;
36361
 
        END IF;
36362
 
      END IF;
36363
 
 
36364
 
      IF (_itemcost.costelem_type = 'Direct Labor') THEN
36365
 
        IF ( (pdirectLabor) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN
36366
 
          PERFORM postCost(_itemcost.itemcost_id);
36367
 
          _result := _result + 1;
36368
 
        END IF;
36369
 
        IF ( (plowerDirectLabor) AND ( _itemcost.itemcost_lowlevel) ) THEN
36370
 
          PERFORM postCost(_itemcost.itemcost_id);
36371
 
          _result := _result + 1;
36372
 
        END IF;
36373
 
      END IF;
36374
 
 
36375
 
      IF (_itemcost.costelem_type = 'Overhead') THEN
36376
 
        IF ( (poverhead) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN
36377
 
          PERFORM postCost(_itemcost.itemcost_id);
36378
 
          _result := _result + 1;
36379
 
        END IF;
36380
 
        IF ( (plowerOverhead) AND ( _itemcost.itemcost_lowlevel) ) THEN
36381
 
          PERFORM postCost(_itemcost.itemcost_id);
36382
 
          _result := _result + 1;
36383
 
        END IF;
36384
 
      END IF;
36385
 
 
36386
 
      IF (_itemcost.costelem_type = 'Machine Overhead') THEN
36387
 
        IF ( (pmachOverhead) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN
36388
 
          PERFORM postCost(_itemcost.itemcost_id);
36389
 
          _result := _result + 1;
36390
 
        END IF;
36391
 
        IF ( (plowerMachOverhead) AND ( _itemcost.itemcost_lowlevel) ) THEN
36392
 
          PERFORM postCost(_itemcost.itemcost_id);
36393
 
          _result := _result + 1;
36394
 
        END IF;
36395
 
      END IF;
36396
 
 
36397
 
    END LOOP;
36398
 
 
36399
 
    IF (prollUp) THEN    
36400
 
      PERFORM rollUpStandardCost(pItemId);
36401
 
      _result := _result + 1;
36402
 
    END IF;
36403
 
 
36404
 
    RETURN _result;
36405
 
 
36406
 
END;
36407
 
 $_$;
36408
 
 
36409
 
 
36410
 
ALTER FUNCTION public.dopostcosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin;
36411
 
 
36412
 
--
36413
 
--
36414
 
 
36415
 
CREATE FUNCTION doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer
36416
 
    LANGUAGE plpgsql
36417
 
    AS $_$
36418
 
DECLARE
36419
 
 
36420
 
  plowerMaterial ALIAS FOR $1;
36421
 
  pdirectLabor ALIAS FOR $2;
36422
 
  plowerDirectLabor ALIAS FOR $3;
36423
 
  poverhead ALIAS FOR $4;
36424
 
  plowerOverhead ALIAS FOR $5;
36425
 
  pmachOverhead ALIAS FOR $6;
36426
 
  plowerMachOverhead ALIAS FOR $7;
36427
 
  plowerUser ALIAS FOR $8;
36428
 
  prollUp ALIAS FOR $9;
36429
 
 
36430
 
BEGIN
36431
 
  RETURN doUpdateCosts(plowerMaterial, pdirectLabor, plowerDirectLabor,
36432
 
                       poverhead, plowerOverhead, pmachOverhead,
36433
 
                       plowerMachOverhead, plowerUser, prollUp, TRUE);
36434
 
END;
36435
 
$_$;
36436
 
 
36437
 
 
36438
 
ALTER FUNCTION public.doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin;
36439
 
 
36440
 
--
36441
 
--
36442
 
 
36443
 
CREATE FUNCTION doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer
36444
 
    LANGUAGE plpgsql
36445
 
    AS $_$
36446
 
DECLARE
36447
 
 
36448
 
  plowerMaterial ALIAS FOR $1;
36449
 
  pdirectLabor ALIAS FOR $2;
36450
 
  plowerDirectLabor ALIAS FOR $3;
36451
 
  poverhead ALIAS FOR $4;
36452
 
  plowerOverhead ALIAS FOR $5;
36453
 
  pmachOverhead ALIAS FOR $6;
36454
 
  plowerMachOverhead ALIAS FOR $7;
36455
 
  plowerUser ALIAS FOR $8;
36456
 
  prollUp ALIAS FOR $9;
36457
 
  pActual ALIAS FOR $10;
36458
 
  _item RECORD;
36459
 
  _bom RECORD;
36460
 
  _result INTEGER := 0;
36461
 
 
36462
 
BEGIN
36463
 
 
36464
 
  PERFORM resetLowLevelCode(-1);
36465
 
 
36466
 
  FOR _item IN SELECT costUpdate_item_id
36467
 
            FROM costUpdate
36468
 
            ORDER BY costUpdate_lowlevel_code DESC LOOP
36469
 
    PERFORM doUpdateCosts(_item.costUpdate_item_id, false, plowerMaterial,
36470
 
                  pdirectLabor, plowerDirectLabor, poverhead, plowerOverhead,
36471
 
                  pmachOverhead, plowerMachOverhead, plowerUser, prollUp,
36472
 
                  pActual);
36473
 
  END LOOP;
36474
 
 
36475
 
  RETURN _result;
36476
 
 
36477
 
END;
36478
 
 $_$;
36479
 
 
36480
 
 
36481
 
ALTER FUNCTION public.doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin;
36482
 
 
36483
 
--
36484
 
--
36485
 
 
36486
 
CREATE FUNCTION doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer
36487
 
    LANGUAGE plpgsql
36488
 
    AS $_$
36489
 
DECLARE
36490
 
 
36491
 
  pItemId ALIAS FOR $1;
36492
 
  pResetLowLevel ALIAS FOR $2;
36493
 
  plowerMaterial ALIAS FOR $3;
36494
 
  pdirectLabor ALIAS FOR $4;
36495
 
  plowerDirectLabor ALIAS FOR $5;
36496
 
  poverhead ALIAS FOR $6;
36497
 
  plowerOverhead ALIAS FOR $7;
36498
 
  pmachOverhead ALIAS FOR $8;
36499
 
  plowerMachOverhead ALIAS FOR $9;
36500
 
  plowerUser ALIAS FOR $10;
36501
 
  prollUp ALIAS FOR $11;
36502
 
 
36503
 
BEGIN
36504
 
    RETURN doUpdateCosts(pItemId, pResetLowLevel, plowerMaterial, pdirectLabor,
36505
 
                         plowerDirectLabor, poverhead, plowerOverhead,
36506
 
                         pmachOverhead, plowerMachOverhead, plowerUser, prollUp,
36507
 
                         TRUE);
36508
 
END;
36509
 
$_$;
36510
 
 
36511
 
 
36512
 
ALTER FUNCTION public.doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin;
36513
 
 
36514
 
--
36515
 
--
36516
 
 
36517
 
CREATE FUNCTION doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer
36518
 
    LANGUAGE plpgsql
36519
 
    AS $_$
36520
 
DECLARE
36521
 
 
36522
 
  pItemId ALIAS FOR $1;
36523
 
  pResetLowLevel ALIAS FOR $2;
36524
 
  plowerMaterial ALIAS FOR $3;
36525
 
  pdirectLabor ALIAS FOR $4;
36526
 
  plowerDirectLabor ALIAS FOR $5;
36527
 
  poverhead ALIAS FOR $6;
36528
 
  plowerOverhead ALIAS FOR $7;
36529
 
  pmachOverhead ALIAS FOR $8;
36530
 
  plowerMachOverhead ALIAS FOR $9;
36531
 
  plowerUser ALIAS FOR $10;
36532
 
  prollUp ALIAS FOR $11;
36533
 
  pUpdateActual ALIAS FOR $12;
36534
 
  _item RECORD;
36535
 
  _bom RECORD;
36536
 
  _result INTEGER := 0;
36537
 
  _resultFromReset INTEGER;
36538
 
  _counterNum INTEGER;
36539
 
  _feedBackNum INTEGER;
36540
 
 
36541
 
BEGIN
36542
 
 
36543
 
    IF (pResetLowLevel) THEN
36544
 
        PERFORM resetLowLevelCode(pItemId);
36545
 
    END IF;
36546
 
 
36547
 
    SELECT costUpdate_item_id AS item_id, costUpdate_item_type AS item_type
36548
 
        INTO _item
36549
 
    FROM costUpdate
36550
 
    WHERE costUpdate_item_id = pItemId;
36551
 
 
36552
 
    IF ((plowerMaterial) AND ((_item.item_type <> 'P') AND (_item.item_type <> 'O'))) THEN    
36553
 
      PERFORM updateSorACost(_item.item_id, 'Material', TRUE, lowerCost(_item.item_id, 'Material', pUpdateActual), pUpdateActual);
36554
 
    END IF;
36555
 
 
36556
 
    IF (pdirectLabor) THEN    
36557
 
      PERFORM updateSorACost(_item.item_id, 'Direct Labor', FALSE, xtmfg.directLaborCost(_item.item_id), pUpdateActual);
36558
 
    END IF;
36559
 
 
36560
 
    IF (plowerDirectLabor) THEN    
36561
 
      PERFORM updateSorACost(_item.item_id, 'Direct Labor', TRUE, lowerCost(_item.item_id, 'Direct Labor', pUpdateActual), pUpdateActual);
36562
 
    END IF;
36563
 
 
36564
 
    IF (poverhead) THEN    
36565
 
      PERFORM updateSorACost(_item.item_id, 'Overhead', FALSE, xtmfg.overheadCost(_item.item_id), pUpdateActual);
36566
 
    END IF;
36567
 
 
36568
 
    IF (plowerOverhead) THEN    
36569
 
      PERFORM updateSorACost(_item.item_id, 'Overhead', TRUE, lowerCost(_item.item_id, 'Overhead', pUpdateActual), pUpdateActual);
36570
 
    END IF;
36571
 
 
36572
 
    IF (pmachOverhead) THEN    
36573
 
      PERFORM updateSorACost(_item.item_id, 'Machine Overhead', FALSE, xtmfg.machineOverheadCost(_item.item_id), pUpdateActual);
36574
 
    END IF;
36575
 
 
36576
 
    IF (plowerMachOverhead) THEN    
36577
 
      PERFORM updateSorACost(_item.item_id, 'Machine Overhead', TRUE, lowerCost(_item.item_id, 'Machine Overhead', pUpdateActual), pUpdateActual);
36578
 
    END IF;
36579
 
 
36580
 
    IF (plowerUser) THEN    
36581
 
      PERFORM updateLowerUserCosts(_item.item_id, pUpdateActual);
36582
 
    END IF;
36583
 
 
36584
 
    IF (prollUp) THEN    
36585
 
      PERFORM rollUpSorACost(_item.item_id, pUpdateActual);
36586
 
    END IF;
36587
 
 
36588
 
    RETURN _result;
36589
 
 
36590
 
END;
36591
 
 $_$;
36592
 
 
36593
 
 
36594
 
ALTER FUNCTION public.doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin;
36595
 
 
36596
 
--
36597
 
--
36598
 
 
36599
 
CREATE FUNCTION dropifexists(text, text) RETURNS integer
36600
 
    LANGUAGE plpgsql
36601
 
    AS $_$
36602
 
BEGIN
36603
 
  RETURN dropIfExists($1, $2, 'public');
36604
 
END;
36605
 
$_$;
36606
 
 
36607
 
 
36608
 
ALTER FUNCTION public.dropifexists(text, text) OWNER TO admin;
36609
 
 
36610
 
--
36611
 
--
36612
 
 
36613
 
CREATE FUNCTION dropifexists(text, text, text) RETURNS integer
36614
 
    LANGUAGE plpgsql
36615
 
    AS $_$
36616
 
BEGIN
36617
 
  RETURN dropIfExists($1, $2, $3, false);
36618
 
END;
36619
 
$_$;
36620
 
 
36621
 
 
36622
 
ALTER FUNCTION public.dropifexists(text, text, text) OWNER TO admin;
36623
 
 
36624
 
--
36625
 
--
36626
 
 
36627
 
CREATE FUNCTION dropifexists(text, text, text, boolean) RETURNS integer
36628
 
    LANGUAGE plpgsql
36629
 
    AS $_$
36630
 
DECLARE
36631
 
  pType         ALIAS FOR $1;
36632
 
  pObject       ALIAS FOR $2;
36633
 
  pSchema       ALIAS FOR $3;
36634
 
  pCascade      ALIAS FOR $4;
36635
 
  _table        TEXT;
36636
 
  _query        TEXT;
36637
 
BEGIN
36638
 
  IF (UPPER(pType) = 'INDEX') THEN
36639
 
    _query = 'DROP INDEX ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pObject));
36640
 
    
36641
 
    BEGIN
36642
 
      EXECUTE _query;
36643
 
    EXCEPTION WHEN undefined_object OR invalid_schema_name THEN
36644
 
                RETURN 0;
36645
 
              WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM;
36646
 
    END;
36647
 
 
36648
 
  ELSEIF (UPPER(pType) = 'TABLE') THEN
36649
 
    _query = 'DROP TABLE ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pObject)); 
36650
 
    
36651
 
    IF (pCascade) THEN
36652
 
      _query = _query || ' CASCADE';
36653
 
    END IF;
36654
 
 
36655
 
    BEGIN
36656
 
      EXECUTE _query;
36657
 
    EXCEPTION WHEN undefined_table OR invalid_schema_name THEN
36658
 
                RETURN 0;
36659
 
              WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM;
36660
 
    END;
36661
 
 
36662
 
  ELSIF (UPPER(pType) = 'VIEW') THEN
36663
 
    _query = 'DROP VIEW ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pObject));
36664
 
 
36665
 
    IF (pCascade) THEN
36666
 
      _query = _query || ' CASCADE';
36667
 
    END IF;
36668
 
    
36669
 
    BEGIN
36670
 
      EXECUTE _query;
36671
 
    EXCEPTION WHEN undefined_table OR invalid_schema_name THEN
36672
 
                RETURN 0;
36673
 
              WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM;
36674
 
    END;
36675
 
 
36676
 
  ELSIF (UPPER(pType) = 'TRIGGER') THEN
36677
 
    SELECT relname INTO _table
36678
 
    FROM pg_trigger, pg_class
36679
 
    WHERE ((tgrelid=pg_class.oid)
36680
 
      AND  (UPPER(tgname)=UPPER(pObject)));
36681
 
    IF (NOT FOUND) THEN
36682
 
      _table := '[no table]';
36683
 
    END IF;
36684
 
 
36685
 
    _query = 'DROP TRIGGER ' || quote_ident(LOWER(pObject)) ||
36686
 
             ' ON ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(_table));
36687
 
    BEGIN
36688
 
      EXECUTE _query;
36689
 
    EXCEPTION WHEN undefined_object THEN
36690
 
                RETURN 0;
36691
 
              WHEN undefined_table OR invalid_schema_name THEN
36692
 
                RETURN 0;
36693
 
              WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM;
36694
 
    END;
36695
 
 
36696
 
  ELSIF (UPPER(pType) = 'FUNCTION') THEN
36697
 
    _query = 'DROP FUNCTION ' || (LOWER(pSchema)) || '.' ||
36698
 
                                   (LOWER(pObject));
36699
 
    BEGIN
36700
 
      EXECUTE _query;
36701
 
    EXCEPTION WHEN undefined_object OR undefined_function OR invalid_schema_name THEN
36702
 
                RETURN 0;
36703
 
              WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM;
36704
 
    END;
36705
 
 
36706
 
  ELSIF (UPPER(pType) = 'CONSTRAINT') THEN
36707
 
    IF( (SELECT count(*)
36708
 
           FROM pg_constraint, pg_class, pg_namespace
36709
 
          WHERE((conrelid=pg_class.oid)
36710
 
            AND (connamespace=pg_namespace.oid)
36711
 
            AND (conname=pObject)
36712
 
            AND (nspname=pSchema))
36713
 
         ) > 1 ) THEN
36714
 
      RAISE EXCEPTION 'dropIfExists called on constraint name that matches more than 1 constraint.';
36715
 
    END IF;
36716
 
    SELECT relname INTO _table
36717
 
    FROM pg_constraint, pg_class, pg_namespace
36718
 
    WHERE ((conrelid=pg_class.oid)
36719
 
      AND  (connamespace=pg_namespace.oid)
36720
 
      AND  (conname=pObject)
36721
 
      AND  (nspname=pSchema));
36722
 
    IF (NOT FOUND) THEN
36723
 
      RETURN 0;
36724
 
    END IF;
36725
 
    _query = 'ALTER TABLE ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(_table))
36726
 
             || ' DROP CONSTRAINT ' || quote_ident(LOWER(pObject));
36727
 
    BEGIN
36728
 
      EXECUTE _query;
36729
 
    EXCEPTION WHEN undefined_table OR invalid_schema_name THEN
36730
 
                RETURN 0;
36731
 
              WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM;
36732
 
    END;
36733
 
 
36734
 
  ELSIF (UPPER(pType) = 'SCHEMA') THEN
36735
 
    _query = 'DROP SCHEMA ' || quote_ident(LOWER(pObject));
36736
 
    BEGIN
36737
 
      EXECUTE _query;
36738
 
    EXCEPTION WHEN invalid_schema_name THEN
36739
 
                RETURN 0;
36740
 
              WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM;
36741
 
    END;
36742
 
 
36743
 
  ELSIF (UPPER(pType) = 'TYPE') THEN
36744
 
    _query = 'DROP TYPE ' || quote_ident(LOWER(pSchema)) || '.' ||
36745
 
                               quote_ident(LOWER(pObject));
36746
 
    IF (pCascade) THEN
36747
 
      _query = _query || ' CASCADE';
36748
 
    END IF;
36749
 
    
36750
 
    BEGIN
36751
 
      EXECUTE _query;
36752
 
    EXCEPTION WHEN undefined_object OR invalid_schema_name THEN
36753
 
                RETURN 0;
36754
 
              WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM;
36755
 
    END;
36756
 
 
36757
 
  ELSE
36758
 
    RAISE EXCEPTION 'dropIfExists(%, %): unknown pType %', pType, pObject, pType;
36759
 
  END IF;
36760
 
 
36761
 
  RETURN 1;
36762
 
 
36763
 
END;
36764
 
$_$;
36765
 
 
36766
 
 
36767
 
ALTER FUNCTION public.dropifexists(text, text, text, boolean) OWNER TO admin;
36768
 
 
36769
 
--
36770
 
--
36771
 
 
36772
 
CREATE FUNCTION dropifexists(text, text, text, text) RETURNS integer
36773
 
    LANGUAGE plpgsql
36774
 
    AS $_$
36775
 
DECLARE
36776
 
  pType         ALIAS FOR $1;
36777
 
  pObject       ALIAS FOR $2;
36778
 
  pSchema       ALIAS FOR $3;
36779
 
  pRelation     ALIAS FOR $4;
36780
 
  _table        TEXT;
36781
 
  _query        TEXT;
36782
 
BEGIN
36783
 
  IF (UPPER(pType) = 'CONSTRAINT') THEN
36784
 
    SELECT relname INTO _table
36785
 
    FROM pg_constraint, pg_class, pg_namespace
36786
 
    WHERE ((conrelid=pg_class.oid)
36787
 
      AND  (connamespace=pg_namespace.oid)
36788
 
      AND  (conname=pObject)
36789
 
      AND  (relname=pRelation)
36790
 
      AND  (nspname=pSchema));
36791
 
    IF (NOT FOUND) THEN
36792
 
      RETURN 0;
36793
 
    END IF;
36794
 
    _query = 'ALTER TABLE ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pRelation))
36795
 
             || ' DROP CONSTRAINT ' || quote_ident(LOWER(pObject));
36796
 
    BEGIN
36797
 
      EXECUTE _query;
36798
 
    EXCEPTION WHEN undefined_table OR invalid_schema_name THEN
36799
 
                RETURN 0;
36800
 
              WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM;
36801
 
    END;
36802
 
 
36803
 
  ELSE
36804
 
    RAISE EXCEPTION 'dropIfExists(%, %, %, %): pType % is not supported when relation is specified', pType, pObject, pSchema, pRelation, pType;
36805
 
  END IF;
36806
 
 
36807
 
  RETURN 1;
36808
 
END;
36809
 
$_$;
36810
 
 
36811
 
 
36812
 
ALTER FUNCTION public.dropifexists(text, text, text, text) OWNER TO admin;
36813
 
 
36814
 
--
36815
 
--
36816
 
 
36817
 
CREATE FUNCTION dropstdopntable() RETURNS boolean
36818
 
    LANGUAGE plpgsql
36819
 
    AS $$
36820
 
BEGIN
36821
 
  IF((SELECT metric_value != 'Manufacturing' FROM metric WHERE metric_name = 'Application')) THEN
36822
 
    PERFORM dropIfExists('TABLE', 'stdopn');
36823
 
    RETURN true;
36824
 
  END IF;
36825
 
  RETURN false;
36826
 
END;
36827
 
$$;
36828
 
 
36829
 
 
36830
 
ALTER FUNCTION public.dropstdopntable() OWNER TO admin;
36831
 
 
36832
 
--
36833
 
--
36834
 
 
36835
 
CREATE FUNCTION editccnumber(text, text) RETURNS text
36836
 
    LANGUAGE plpgsql
36837
 
    AS $_$
36838
 
DECLARE
36839
 
  pCcardnum ALIAS FOR $1;
36840
 
  pCcardtype ALIAS FOR $2;
36841
 
  card_length INTEGER;
36842
 
  card_valid boolean := false;
36843
 
  starting_digits TEXT;
36844
 
  _sum INTEGER := 0;
36845
 
  _digit INTEGER := 0;
36846
 
  _timesTwo BOOLEAN := false;
36847
 
BEGIN
36848
 
 
36849
 
  IF (pCcardtype NOT IN ('M', 'V', 'A', 'D')) THEN
36850
 
   RETURN -1;
36851
 
  END IF;
36852
 
 
36853
 
  card_length := length(pCcardnum);
36854
 
 
36855
 
  IF (pCcardtype = 'M') THEN
36856
 
    IF (card_length != 16) THEN
36857
 
      RETURN -2;
36858
 
    END IF;
36859
 
    starting_digits := substr(pCcardnum, 1, 2);
36860
 
    IF (starting_digits < '51' OR starting_digits > '55') THEN
36861
 
      RETURN -6;
36862
 
    END IF;
36863
 
  END IF;
36864
 
 
36865
 
  IF (pCcardtype = 'V') THEN
36866
 
    IF (card_length != 13 AND card_length != 16) THEN
36867
 
      RETURN -3;
36868
 
    END IF;
36869
 
    starting_digits := substr(pCcardnum, 1, 1);
36870
 
    IF (starting_digits != '4') THEN
36871
 
      RETURN -7;
36872
 
    END IF;
36873
 
  END IF;
36874
 
 
36875
 
  IF (pCcardtype = 'A') THEN
36876
 
    IF (card_length != 15) THEN
36877
 
      RETURN -4;
36878
 
    END IF;
36879
 
    starting_digits := substr(pCcardnum, 1, 2);
36880
 
    IF (starting_digits != '34' AND starting_digits != '37') THEN
36881
 
      RETURN -8;
36882
 
    END IF;
36883
 
  END IF;
36884
 
 
36885
 
  IF (pCcardtype = 'D') THEN
36886
 
    IF (card_length != 16) THEN
36887
 
      RETURN -5;
36888
 
    END IF;
36889
 
    starting_digits := substr(pCcardnum, 1, 4);
36890
 
    IF (starting_digits != '6011') THEN
36891
 
      RETURN -9;
36892
 
    END IF;
36893
 
  END IF;
36894
 
 
36895
 
  FOR i IN REVERSE card_length .. 1 LOOP
36896
 
    _digit := int4(substr(pCcardnum, i, 1));
36897
 
    IF (_timesTwo) THEN
36898
 
      _digit := _digit * 2;
36899
 
      IF (_digit > 9) THEN
36900
 
        _digit := _digit - 9;
36901
 
      END IF;
36902
 
    END IF;
36903
 
    _sum := _sum + _digit;
36904
 
    _timesTwo := NOT _timesTwo;
36905
 
  END LOOP;
36906
 
 
36907
 
  IF (mod(_sum, 10) != 0) THEN
36908
 
    RETURN -10;
36909
 
  END IF;
36910
 
 
36911
 
  RETURN 0; -- No Error
36912
 
 
36913
 
END;
36914
 
$_$;
36915
 
 
36916
 
 
36917
 
ALTER FUNCTION public.editccnumber(text, text) OWNER TO admin;
36918
 
 
36919
 
--
36920
 
--
36921
 
 
36922
 
CREATE FUNCTION enablepackage(text) RETURNS integer
36923
 
    LANGUAGE plpgsql
36924
 
    AS $_$
36925
 
DECLARE
36926
 
  ppkgname  ALIAS FOR $1;
36927
 
  _i        INTEGER := 0;
36928
 
  _tabs     TEXT[] := ARRAY['cmd',  'cmdarg', 'image',  'metasql',
36929
 
                            'priv', 'report', 'script', 'uiform'];
36930
 
 
36931
 
BEGIN
36932
 
  IF (version() < 'PostgreSQL 8.2') THEN
36933
 
    RETURN -1;
36934
 
  END IF;
36935
 
 
36936
 
  FOR _i IN ARRAY_LOWER(_tabs,1)..ARRAY_UPPER(_tabs,1) LOOP
36937
 
    EXECUTE 'ALTER TABLE ' || ppkgname || '.pkg' || _tabs[_i] ||
36938
 
            ' INHERIT public.' || _tabs[_i] || ';';
36939
 
  END LOOP;
36940
 
 
36941
 
  RETURN 0;
36942
 
END;
36943
 
$_$;
36944
 
 
36945
 
 
36946
 
ALTER FUNCTION public.enablepackage(text) OWNER TO admin;
36947
 
 
36948
 
--
36949
 
--
36950
 
 
36951
 
CREATE FUNCTION enablepackage(integer) RETURNS integer
36952
 
    LANGUAGE plpgsql
36953
 
    AS $_$
36954
 
DECLARE
36955
 
  ppkgheadid    ALIAS FOR $1;
36956
 
  _pkgname      TEXT;
36957
 
 
36958
 
BEGIN
36959
 
  SELECT pkghead_name INTO _pkgname
36960
 
  FROM pkghead
36961
 
  WHERE (pkghead_id=ppkgheadid);
36962
 
  IF (NOT FOUND) THEN
36963
 
    RETURN -2;
36964
 
  END IF;
36965
 
 
36966
 
  RETURN enablePackage(_pkgname);
36967
 
END;
36968
 
$_$;
36969
 
 
36970
 
 
36971
 
ALTER FUNCTION public.enablepackage(integer) OWNER TO admin;
36972
 
 
36973
 
--
36974
 
--
36975
 
 
36976
 
CREATE FUNCTION encrypt(bytea, bytea, text) RETURNS bytea
36977
 
    LANGUAGE c IMMUTABLE STRICT
36978
 
    AS '$libdir/pgcrypto', 'pg_encrypt';
36979
 
 
36980
 
 
36981
 
ALTER FUNCTION public.encrypt(bytea, bytea, text) OWNER TO admin;
36982
 
 
36983
 
--
36984
 
--
36985
 
 
36986
 
CREATE FUNCTION encrypt_iv(bytea, bytea, bytea, text) RETURNS bytea
36987
 
    LANGUAGE c IMMUTABLE STRICT
36988
 
    AS '$libdir/pgcrypto', 'pg_encrypt_iv';
36989
 
 
36990
 
 
36991
 
ALTER FUNCTION public.encrypt_iv(bytea, bytea, bytea, text) OWNER TO admin;
36992
 
 
36993
 
--
36994
 
--
36995
 
 
36996
 
CREATE FUNCTION endoftime() RETURNS date
36997
 
    LANGUAGE sql IMMUTABLE
36998
 
    AS $$
36999
 
SELECT DATE('2100-01-01') as result;
37000
 
$$;
37001
 
 
37002
 
 
37003
 
ALTER FUNCTION public.endoftime() OWNER TO admin;
37004
 
 
37005
 
--
37006
 
--
37007
 
 
37008
 
CREATE FUNCTION entercount(integer, numeric, text) RETURNS integer
37009
 
    LANGUAGE plpgsql
37010
 
    AS $_$
37011
 
DECLARE
37012
 
  pInvcntid ALIAS FOR $1;
37013
 
  pQty ALIAS FOR $2;
37014
 
  pComments ALIAS FOR $3;
37015
 
BEGIN
37016
 
 
37017
 
  UPDATE invcnt
37018
 
  SET invcnt_qoh_after = pQty,
37019
 
      invcnt_comments = CASE WHEN ( (LENGTH(invcnt_comments) = 0) AND
37020
 
                                    (LENGTH(pComments) > 0) ) THEN pComments
37021
 
                             WHEN (LENGTH(pComments) > 0) THEN (invcnt_comments || E'\n' || pComments)
37022
 
                             ELSE invcnt_comments
37023
 
                        END,
37024
 
      invcnt_cntdate = CURRENT_TIMESTAMP,
37025
 
      invcnt_cnt_username = getEffectiveXtUser()
37026
 
  WHERE (invcnt_id=pInvcntid);
37027
 
 
37028
 
  RETURN 0;
37029
 
END;
37030
 
$_$;
37031
 
 
37032
 
 
37033
 
ALTER FUNCTION public.entercount(integer, numeric, text) OWNER TO admin;
37034
 
 
37035
 
--
37036
 
--
37037
 
 
37038
 
CREATE FUNCTION enterporeceipt(integer, numeric) RETURNS integer
37039
 
    LANGUAGE plpgsql
37040
 
    AS $_$
37041
 
BEGIN
37042
 
  RETURN enterReceipt('PO', $1, $2, 0.0, '', NULL, NULL);
37043
 
END;
37044
 
$_$;
37045
 
 
37046
 
 
37047
 
ALTER FUNCTION public.enterporeceipt(integer, numeric) OWNER TO admin;
37048
 
 
37049
 
--
37050
 
--
37051
 
 
37052
 
CREATE FUNCTION enterporeceipt(integer, numeric, text) RETURNS integer
37053
 
    LANGUAGE plpgsql
37054
 
    AS $_$
37055
 
BEGIN
37056
 
  RETURN enterPoReceipt('PO', $1, $2, 0.0, $3, NULL, NULL);
37057
 
END;
37058
 
$_$;
37059
 
 
37060
 
 
37061
 
ALTER FUNCTION public.enterporeceipt(integer, numeric, text) OWNER TO admin;
37062
 
 
37063
 
--
37064
 
--
37065
 
 
37066
 
CREATE FUNCTION enterporeceipt(integer, numeric, numeric, text) RETURNS integer
37067
 
    LANGUAGE plpgsql
37068
 
    AS $_$
37069
 
BEGIN
37070
 
  RETURN enterPoReceipt('PO', $1, $2, $3, $4, NULL, NULL);
37071
 
END;
37072
 
$_$;
37073
 
 
37074
 
 
37075
 
ALTER FUNCTION public.enterporeceipt(integer, numeric, numeric, text) OWNER TO admin;
37076
 
 
37077
 
--
37078
 
--
37079
 
 
37080
 
CREATE FUNCTION enterporeceipt(integer, numeric, numeric, text, integer, date) RETURNS integer
37081
 
    LANGUAGE plpgsql
37082
 
    AS $_$
37083
 
BEGIN
37084
 
  RETURN enterReceipt('PO', $1, $2, $3, $4, $5, $6);
37085
 
END;
37086
 
$_$;
37087
 
 
37088
 
 
37089
 
ALTER FUNCTION public.enterporeceipt(integer, numeric, numeric, text, integer, date) OWNER TO admin;
37090
 
 
37091
 
--
37092
 
--
37093
 
 
37094
 
CREATE FUNCTION enterporeturn(integer, numeric, integer) RETURNS integer
37095
 
    LANGUAGE plpgsql
37096
 
    AS $_$
37097
 
BEGIN
37098
 
  RETURN enterPoReturn($1, $2, $3, NULL);
37099
 
END;
37100
 
$_$;
37101
 
 
37102
 
 
37103
 
ALTER FUNCTION public.enterporeturn(integer, numeric, integer) OWNER TO admin;
37104
 
 
37105
 
--
37106
 
--
37107
 
 
37108
 
CREATE FUNCTION enterporeturn(integer, numeric, integer, integer) RETURNS integer
37109
 
    LANGUAGE plpgsql
37110
 
    AS $_$
37111
 
DECLARE
37112
 
  pPoitemid ALIAS FOR $1;
37113
 
  pQty ALIAS FOR $2;
37114
 
  pRjctcodeid ALIAS FOR $3;
37115
 
  pRecvid ALIAS FOR $4;
37116
 
  _porejectid INTEGER;
37117
 
 
37118
 
BEGIN
37119
 
 
37120
 
  SELECT NEXTVAL('poreject_poreject_id_seq') INTO _porejectid;
37121
 
 
37122
 
  INSERT INTO poreject
37123
 
  ( poreject_id, poreject_date, poreject_ponumber, poreject_poitem_id, poreject_trans_username,
37124
 
    poreject_agent_username, poreject_itemsite_id,
37125
 
    poreject_vend_id, poreject_vend_item_number, poreject_vend_item_descrip, poreject_vend_uom,
37126
 
    poreject_qty, poreject_rjctcode_id, poreject_posted, poreject_invoiced, poreject_recv_id )
37127
 
  SELECT _porejectid, CURRENT_TIMESTAMP, pohead_number, poitem_id, getEffectiveXtUser(),
37128
 
         pohead_agent_username, poitem_itemsite_id,
37129
 
         pohead_vend_id, poitem_vend_item_number, poitem_vend_item_descrip, poitem_vend_uom,
37130
 
         pQty, pRjctcodeid, FALSE, FALSE, pRecvid
37131
 
  FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id)
37132
 
  WHERE (poitem_id=pPoitemid);
37133
 
 
37134
 
  RETURN _porejectid;
37135
 
 
37136
 
END;
37137
 
$_$;
37138
 
 
37139
 
 
37140
 
ALTER FUNCTION public.enterporeturn(integer, numeric, integer, integer) OWNER TO admin;
37141
 
 
37142
 
--
37143
 
--
37144
 
 
37145
 
CREATE FUNCTION enterreceipt(text, integer, numeric, numeric, text, integer, date) RETURNS integer
37146
 
    LANGUAGE plpgsql
37147
 
    AS $_$
37148
 
BEGIN
37149
 
  RETURN enterReceipt($1, $2, $3, $4, $5, $6, $7, NULL);
37150
 
END;
37151
 
$_$;
37152
 
 
37153
 
 
37154
 
ALTER FUNCTION public.enterreceipt(text, integer, numeric, numeric, text, integer, date) OWNER TO admin;
37155
 
 
37156
 
--
37157
 
--
37158
 
 
37159
 
CREATE FUNCTION enterreceipt(text, integer, numeric, numeric, text, integer, date, numeric) RETURNS integer
37160
 
    LANGUAGE plpgsql
37161
 
    AS $_$
37162
 
DECLARE
37163
 
  pordertype    ALIAS FOR $1;
37164
 
  porderitemid  ALIAS FOR $2;
37165
 
  pQty          ALIAS FOR $3;
37166
 
  pFreight      ALIAS FOR $4;
37167
 
  pNotes        ALIAS FOR $5;
37168
 
  pcurrid       ALIAS FOR $6;   -- NULL is handled by SELECT ... INTO _o
37169
 
  precvdate     ALIAS FOR $7;   -- NULL is handled by INSERT INTO recv
37170
 
  pRecvCost     ALIAS FOR $8;
37171
 
  _timestamp    TIMESTAMP;
37172
 
  _o            RECORD;
37173
 
  _recvid       INTEGER;
37174
 
  _warehouseid  INTEGER;
37175
 
  _recvcost     NUMERIC;
37176
 
 
37177
 
BEGIN
37178
 
  IF(precvdate IS NULL OR precvdate = CURRENT_DATE) THEN
37179
 
    _timestamp := CURRENT_TIMESTAMP;
37180
 
  ELSE
37181
 
    _timestamp := precvdate;
37182
 
  END IF;
37183
 
  SELECT NEXTVAL('recv_recv_id_seq') INTO _recvid;
37184
 
 
37185
 
  DELETE FROM recv
37186
 
  WHERE ((NOT recv_posted)
37187
 
    AND  (recv_order_type=pordertype)
37188
 
    AND  (recv_orderitem_id=porderitemid) );
37189
 
 
37190
 
  IF (pQty > 0) THEN
37191
 
    IF (pordertype='PO') THEN
37192
 
      SELECT pohead_number AS orderhead_number,
37193
 
           poitem_id AS orderitem_id,
37194
 
           pohead_agent_username AS orderhead_agent_username,
37195
 
           CASE WHEN (poitem_itemsite_id = -1) THEN NULL
37196
 
                ELSE poitem_itemsite_id
37197
 
           END AS itemsite_id,
37198
 
           vend_id,
37199
 
           COALESCE(poitem_vend_item_number, '') AS vend_item_number,
37200
 
           COALESCE(poitem_vend_item_descrip, '') AS vend_item_descrip,
37201
 
           COALESCE(poitem_vend_uom, '') AS vend_uom,
37202
 
           poitem_duedate AS duedate,
37203
 
           poitem_unitprice AS orderitem_unitcost,
37204
 
           pohead_curr_id AS orderitem_unitcost_curr_id,
37205
 
           pohead_curr_id AS freight_curr_id,
37206
 
           poitem_rlsd_duedate AS rlsd_duedate INTO _o
37207
 
        FROM pohead
37208
 
          JOIN poitem ON (pohead_id=poitem_pohead_id)
37209
 
          JOIN vendinfo ON (pohead_vend_id=vend_id)
37210
 
        WHERE (poitem_id=porderitemid);
37211
 
        
37212
 
    ELSIF (pordertype='RA') THEN
37213
 
       SELECT rahead_number AS orderhead_number,
37214
 
           raitem_id AS orderitem_id,
37215
 
           ''::text AS orderhead_agent_username,
37216
 
           raitem_itemsite_id AS itemsite_id,
37217
 
           NULL::integer AS vend_id,
37218
 
           ''::text AS vend_item_number,
37219
 
           ''::text AS vend_item_descrip,
37220
 
           ''::text AS vend_uom,
37221
 
           raitem_scheddate AS duedate,
37222
 
           raitem_unitprice AS orderitem_unitcost,
37223
 
           rahead_curr_id AS orderitem_unitcost_curr_id,
37224
 
           rahead_curr_id AS freight_curr_id,
37225
 
           raitem_scheddate AS rlsd_duedate INTO _o
37226
 
        FROM rahead
37227
 
          JOIN raitem ON (rahead_id=raitem_rahead_id)
37228
 
        WHERE (raitem_id=porderitemid);
37229
 
        
37230
 
    ELSIF (pordertype='TO') THEN
37231
 
         SELECT tohead_number AS orderhead_number,
37232
 
           toitem_id AS orderitem_id,
37233
 
           tohead_agent_username AS orderhead_agent_username,
37234
 
           itemsite_id,
37235
 
           NULL::integer AS vend_id,
37236
 
           ''::text AS vend_item_number,
37237
 
           ''::text AS vend_item_descrip,
37238
 
           ''::text AS vend_uom,
37239
 
           toitem_duedate AS duedate,
37240
 
           toitem_stdcost AS orderitem_unitcost,
37241
 
           baseCurrId() AS orderitem_unitcost_curr_id,
37242
 
           toitem_freight_curr_id AS freight_curr_id,
37243
 
           toitem_duedate AS rlsd_duedate INTO _o
37244
 
        FROM itemsite, tohead
37245
 
          JOIN toitem ON (tohead_id=toitem_tohead_id)
37246
 
        WHERE ((toitem_id=porderitemid)
37247
 
          AND  (tohead_dest_warehous_id=itemsite_warehous_id)
37248
 
          AND  (toitem_item_id=itemsite_item_id));
37249
 
    END IF;
37250
 
 
37251
 
    --Make sure user has site privileges
37252
 
     IF ((FOUND) AND (_o.itemsite_id IS NOT NULL)) THEN
37253
 
       SELECT warehous_id INTO _warehouseid
37254
 
       FROM itemsite,site()
37255
 
       WHERE ((itemsite_id=_o.itemsite_id)
37256
 
         AND (warehous_id=itemsite_warehous_id));
37257
 
          
37258
 
       IF (NOT FOUND) THEN
37259
 
         RETURN 0;
37260
 
        END IF;
37261
 
      END IF;   
37262
 
 
37263
 
    --Make sure we aren't trying to receive a Kit
37264
 
    IF ((FOUND) AND (_o.itemsite_id IS NOT NULL)) THEN
37265
 
      IF (SELECT (item_type='K')
37266
 
          FROM itemsite, item
37267
 
          WHERE ((itemsite_id=_o.itemsite_id)
37268
 
            AND  (item_id=itemsite_item_id))) THEN
37269
 
        RETURN 0;
37270
 
      END IF;
37271
 
    END IF;   
37272
 
 
37273
 
    IF (NOT FOUND) THEN
37274
 
      RETURN -1;
37275
 
    END IF;
37276
 
 
37277
 
    -- default to orderitem_unitcost if recv_purchcost is not specified
37278
 
    IF(pRecvCost IS NULL) THEN
37279
 
      _recvcost := _o.orderitem_unitcost;
37280
 
    ELSE
37281
 
      _recvcost := pRecvCost;
37282
 
    END IF;
37283
 
 
37284
 
    INSERT INTO recv
37285
 
    ( recv_id, recv_date,
37286
 
      recv_order_number, recv_order_type, recv_orderitem_id,
37287
 
      recv_trans_usr_name, recv_agent_username, recv_itemsite_id,
37288
 
      recv_vend_id, recv_vend_item_number, recv_vend_item_descrip,
37289
 
      recv_vend_uom, recv_qty, recv_duedate,
37290
 
      recv_purchcost, recv_purchcost_curr_id,
37291
 
      recv_notes, recv_freight, recv_freight_curr_id, recv_rlsd_duedate
37292
 
    ) VALUES (
37293
 
      _recvid, _timestamp,
37294
 
      _o.orderhead_number, pordertype, _o.orderitem_id::INTEGER,
37295
 
      getEffectiveXtUser(), _o.orderhead_agent_username, _o.itemsite_id::INTEGER,
37296
 
      _o.vend_id::INTEGER, _o.vend_item_number, _o.vend_item_descrip,
37297
 
      _o.vend_uom, pQty, _o.duedate,
37298
 
      _recvcost, _o.orderitem_unitcost_curr_id::INTEGER,
37299
 
      pNotes, pFreight, _o.freight_curr_id::INTEGER, _o.rlsd_duedate);
37300
 
  END IF;
37301
 
 
37302
 
  RETURN _recvid;
37303
 
 
37304
 
END;
37305
 
$_$;
37306
 
 
37307
 
 
37308
 
ALTER FUNCTION public.enterreceipt(text, integer, numeric, numeric, text, integer, date, numeric) OWNER TO admin;
37309
 
 
37310
 
--
37311
 
--
37312
 
 
37313
 
CREATE FUNCTION expirecreditcard(integer, bytea) RETURNS text
37314
 
    LANGUAGE plpgsql
37315
 
    AS $_$
37316
 
DECLARE
37317
 
  pCust ALIAS FOR $1;
37318
 
  pKey ALIAS FOR $2;
37319
 
  num_updated INTEGER;
37320
 
  cc_year INTEGER;
37321
 
  cc_month INTEGER;
37322
 
  cc_year_t TEXT;
37323
 
  cc_month_t TEXT;
37324
 
  _dr RECORD;
37325
 
  _cc RECORD;
37326
 
  bf TEXT;
37327
 
 
37328
 
BEGIN
37329
 
 
37330
 
  num_updated := 0;
37331
 
  bf := 'bf';
37332
 
 
37333
 
  select cast(date_part('year', CURRENT_DATE) AS INTEGER) AS check_year, cast(date_part('month', CURRENT_DATE) AS INTEGER) AS check_month INTO _dr;
37334
 
 
37335
 
  FOR _cc IN SELECT ccard_id, 
37336
 
                    decrypt(setbytea(ccard_month_expired), setbytea(pKey), 'bf') AS ccard_month_expired,
37337
 
                    decrypt(setbytea(ccard_year_expired), setbytea(pKey), 'bf') AS ccard_year_expired
37338
 
      FROM ccard
37339
 
      WHERE ( (ccard_cust_id=pCust)
37340
 
        AND   (ccard_active) ) LOOP
37341
 
 
37342
 
      SELECT formatbytea(_cc.ccard_month_expired) INTO cc_month_t;
37343
 
      SELECT formatbytea(_cc.ccard_year_expired) INTO cc_year_t;
37344
 
      SELECT cast(cc_month_t AS INTEGER) INTO cc_month;
37345
 
      SELECT cast(cc_year_t AS INTEGER) INTO cc_year;
37346
 
 
37347
 
      IF (cc_year < _dr.check_year) THEN
37348
 
        UPDATE ccard set ccard_active = FALSE where ccard_id = _cc.ccard_id;
37349
 
        num_updated := num_updated + 1;
37350
 
      ELSIF (cc_year = _dr.check_year AND cc_month < _dr.check_month) THEN
37351
 
        UPDATE ccard set ccard_active = FALSE where ccard_id = _cc.ccard_id;
37352
 
        num_updated := num_updated + 1;
37353
 
      END IF;
37354
 
 
37355
 
  END LOOP;
37356
 
 
37357
 
  RETURN num_updated;
37358
 
 
37359
 
END;
37360
 
$_$;
37361
 
 
37362
 
 
37363
 
ALTER FUNCTION public.expirecreditcard(integer, bytea) OWNER TO admin;
37364
 
 
37365
 
--
37366
 
--
37367
 
 
37368
 
CREATE FUNCTION explodebom(integer, integer, integer) RETURNS integer
37369
 
    LANGUAGE plpgsql
37370
 
    AS $_$
37371
 
DECLARE
37372
 
  pItemid ALIAS FOR $1;
37373
 
  pParentid ALIAS FOR $2;
37374
 
  pLevel ALIAS FOR $3;
37375
 
  _revid INTEGER;
37376
 
 
37377
 
BEGIN
37378
 
 
37379
 
  SELECT getActiveRevId('BOM',pItemid) INTO _revid;
37380
 
 
37381
 
  RETURN explodeBOM(pItemid, _revid, pParentid, pLevel);
37382
 
 
37383
 
END;
37384
 
$_$;
37385
 
 
37386
 
 
37387
 
ALTER FUNCTION public.explodebom(integer, integer, integer) OWNER TO admin;
37388
 
 
37389
 
--
37390
 
--
37391
 
 
37392
 
CREATE FUNCTION explodebom(integer, integer, integer, integer) RETURNS integer
37393
 
    LANGUAGE plpgsql
37394
 
    AS $_$
37395
 
DECLARE
37396
 
  pItemid ALIAS FOR $1;
37397
 
  pRevisionid ALIAS FOR $2;
37398
 
  pParentid ALIAS FOR $3;
37399
 
  pLevel ALIAS FOR $4;
37400
 
  _bomworkid INTEGER;
37401
 
  _level INTEGER;
37402
 
  _p RECORD;
37403
 
  _r RECORD;
37404
 
  _temp TEXT;
37405
 
 
37406
 
BEGIN
37407
 
 
37408
 
  _level := (pLevel + 1);
37409
 
 
37410
 
  SELECT bomwork_item_id, bomwork_set_id, bomwork_qtyreq,
37411
 
         bomwork_seqnumber, bomwork_effective, bomwork_expires INTO _p
37412
 
  FROM bomwork
37413
 
  WHERE (bomwork_id=pParentid);
37414
 
 
37415
 
  FOR _r IN SELECT bomitem.*,
37416
 
                   item_id,
37417
 
                   (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd,
37418
 
                   (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper,
37419
 
                   CASE WHEN (_p.bomwork_effective > bomitem_effective) THEN _p.bomwork_effective
37420
 
                        ELSE bomitem_effective
37421
 
                   END AS effective,
37422
 
                   CASE WHEN (_p.bomwork_expires < bomitem_expires) THEN _p.bomwork_expires
37423
 
                        ELSE bomitem_expires
37424
 
                   END AS expires,
37425
 
                   stdcost(item_id, bomitem_id) AS standardcost, actcost(item_id, bomitem_id) AS actualcost
37426
 
  FROM bomitem(pItemid, pRevisionid), item
37427
 
  WHERE ( (bomitem_item_id=item_id)
37428
 
  AND (bomitem_expires > _p.bomwork_effective) ) LOOP
37429
 
 
37430
 
    SELECT NEXTVAL('bomwork_bomwork_id_seq') INTO _bomworkid;
37431
 
    INSERT INTO bomwork
37432
 
    ( bomwork_id, bomwork_set_id, bomwork_parent_id, bomwork_level,
37433
 
      bomwork_parent_seqnumber, bomwork_seqnumber,
37434
 
      bomwork_item_id, bomwork_createwo, bomwork_qtyreq,
37435
 
      bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_issuemethod,
37436
 
      bomwork_effective, bomwork_expires,
37437
 
      bomwork_stdunitcost, bomwork_actunitcost, 
37438
 
      bomwork_notes, bomwork_ref,
37439
 
      bomwork_bomitem_id, bomwork_ecn )
37440
 
    VALUES
37441
 
    ( _bomworkid, _p.bomwork_set_id, pParentid, _level,
37442
 
      _p.bomwork_seqnumber, _r.bomitem_seqnumber,
37443
 
      _r.item_id, _r.bomitem_createwo, (_p.bomwork_qtyreq * _r.qtyper + _r.qtyfxd),
37444
 
      _r.qtyfxd, _r.qtyper, _r.bomitem_scrap, _r.bomitem_issuemethod,
37445
 
      _r.effective, _r.expires,
37446
 
      _r.standardcost, _r.actualcost,
37447
 
      _r.bomitem_notes, _r.bomitem_ref,
37448
 
      _r.bomitem_id, _r.bomitem_ecn );
37449
 
 
37450
 
    PERFORM explodeBOM(_r.item_id, _bomworkid, _level);
37451
 
  END LOOP;
37452
 
 
37453
 
  RETURN 1;
37454
 
 
37455
 
END;
37456
 
$_$;
37457
 
 
37458
 
 
37459
 
ALTER FUNCTION public.explodebom(integer, integer, integer, integer) OWNER TO admin;
37460
 
 
37461
 
--
37462
 
--
37463
 
 
37464
 
CREATE FUNCTION explodekit(integer, integer, integer, integer, numeric) RETURNS integer
37465
 
    LANGUAGE plpgsql
37466
 
    AS $_$
37467
 
DECLARE
37468
 
  pSoheadid ALIAS FOR $1;
37469
 
  pLinenumber ALIAS FOR $2;
37470
 
  pSubnumber ALIAS FOR $3;
37471
 
  pItemsiteid ALIAS FOR $4;
37472
 
  pQty ALIAS FOR $5;
37473
 
BEGIN
37474
 
  RETURN explodeKit(pSoheadid, pLinenumber, pSubnumber, pItemsiteid, pQty, CURRENT_DATE, NULL);
37475
 
END;
37476
 
$_$;
37477
 
 
37478
 
 
37479
 
ALTER FUNCTION public.explodekit(integer, integer, integer, integer, numeric) OWNER TO admin;
37480
 
 
37481
 
--
37482
 
--
37483
 
 
37484
 
CREATE FUNCTION explodekit(integer, integer, integer, integer, numeric, date, date) RETURNS integer
37485
 
    LANGUAGE plpgsql
37486
 
    AS $_$
37487
 
DECLARE
37488
 
  pSoheadid ALIAS FOR $1;
37489
 
  pLinenumber ALIAS FOR $2;
37490
 
  pSubnumber ALIAS FOR $3;
37491
 
  pItemsiteid ALIAS FOR $4;
37492
 
  pQty ALIAS FOR $5;
37493
 
  pScheddate ALIAS FOR $6;
37494
 
  pPromdate ALIAS FOR $7;
37495
 
BEGIN
37496
 
  RETURN explodeKit(pSoheadid, pLinenumber, pSubnumber, pItemsiteid, pQty, CURRENT_DATE, NULL, '');
37497
 
END;
37498
 
$_$;
37499
 
 
37500
 
 
37501
 
ALTER FUNCTION public.explodekit(integer, integer, integer, integer, numeric, date, date) OWNER TO admin;
37502
 
 
37503
 
--
37504
 
--
37505
 
 
37506
 
CREATE FUNCTION explodekit(integer, integer, integer, integer, numeric, date, date, text) RETURNS integer
37507
 
    LANGUAGE plpgsql
37508
 
    AS $_$
37509
 
DECLARE
37510
 
  pSoheadid ALIAS FOR $1;
37511
 
  pLinenumber ALIAS FOR $2;
37512
 
  pSubnumber ALIAS FOR $3;
37513
 
  pItemsiteid ALIAS FOR $4;
37514
 
  pQty ALIAS FOR $5;
37515
 
  pScheddate ALIAS FOR $6;
37516
 
  pPromdate ALIAS FOR $7;
37517
 
  pMemo ALIAS FOR $8;
37518
 
  _subnumber INTEGER := COALESCE(pSubnumber,0);
37519
 
  _revid INTEGER;
37520
 
  _itemid INTEGER;
37521
 
  _warehousid INTEGER;
37522
 
  _item RECORD;
37523
 
  _type TEXT;
37524
 
  _coitemid INTEGER;
37525
 
  _count INTEGER;
37526
 
  _orderid INTEGER := 0;
37527
 
  _itemsrcid INTEGER;
37528
 
BEGIN
37529
 
 
37530
 
  SELECT getActiveRevId('BOM',itemsite_item_id), itemsite_warehous_id, itemsite_item_id
37531
 
    INTO _revid, _warehousid, _itemid
37532
 
    FROM itemsite
37533
 
   WHERE(itemsite_id=pItemsiteid);
37534
 
  IF(NOT FOUND) THEN
37535
 
    RAISE EXCEPTION 'No Item Site for the specified line was found.';
37536
 
  END IF;
37537
 
 
37538
 
  FOR _item IN
37539
 
  SELECT bomitem_id, 
37540
 
         itemsite_id,
37541
 
         itemsite_warehous_id,
37542
 
         COALESCE((itemsite_active AND item_active), false) AS active,
37543
 
         COALESCE((itemsite_sold AND item_sold), false) AS sold,
37544
 
         item_id,
37545
 
         item_type,
37546
 
         item_price_uom_id,
37547
 
         itemsite_createsopr,itemsite_createwo,itemsite_createsopo, itemsite_dropship,
37548
 
         bomitem_uom_id,
37549
 
         itemuomtouomratio(item_id, bomitem_uom_id, item_inv_uom_id) AS invuomratio,
37550
 
         roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id),(bomitem_qtyfxd + bomitem_qtyper * pQty) * (1 + bomitem_scrap)) AS qty
37551
 
    FROM bomitem JOIN item ON (item_id=bomitem_item_id)
37552
 
                  LEFT OUTER JOIN itemsite ON ((itemsite_item_id=item_id) AND (itemsite_warehous_id=_warehousid))
37553
 
   WHERE((bomitem_parent_item_id=_itemid)
37554
 
     AND (bomitem_rev_id=_revid)
37555
 
     AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1)))
37556
 
   ORDER BY bomitem_seqnumber LOOP
37557
 
    IF (NOT _item.active) THEN
37558
 
      RAISE EXCEPTION 'One or more of the components for the kit is inactive for the selected item site.';
37559
 
    ELSIF (NOT _item.sold) THEN
37560
 
      RAISE EXCEPTION 'One or more of the components for the kit is not sold for the selected item site.';
37561
 
    ELSIF (_item.item_type='F') THEN
37562
 
      SELECT explodeKit(pSoheadid, pLinenumber, _subnumber, _item.itemsite_id, _item.qty)
37563
 
        INTO _subnumber;
37564
 
    ELSE
37565
 
      IF (_item.itemsite_createsopr) THEN
37566
 
        _type := 'R';
37567
 
      ELSIF (_item.itemsite_createsopo) THEN
37568
 
        _type := 'P';
37569
 
      ELSIF (_item.itemsite_createwo) THEN
37570
 
        _type := 'W';
37571
 
      ELSE
37572
 
        _type := NULL;
37573
 
      END IF;
37574
 
      _subnumber := _subnumber + 1;
37575
 
      _coitemid = nextval('coitem_coitem_id_seq');
37576
 
      raise notice 'coitem id: %',_coitemid;
37577
 
      INSERT INTO coitem
37578
 
            (coitem_id, coitem_cohead_id,
37579
 
             coitem_linenumber, coitem_subnumber,
37580
 
             coitem_itemsite_id, coitem_status,
37581
 
             coitem_scheddate, coitem_promdate,
37582
 
             coitem_qtyord, coitem_qty_uom_id, coitem_qty_invuomratio,
37583
 
             coitem_qtyshipped, coitem_qtyreturned,
37584
 
             coitem_unitcost, coitem_custprice,
37585
 
             coitem_price, coitem_price_uom_id, coitem_price_invuomratio,
37586
 
             coitem_order_type, coitem_order_id,
37587
 
             coitem_custpn, coitem_memo,
37588
 
             coitem_prcost)
37589
 
      VALUES (_coitemid, pSoheadid,
37590
 
             pLinenumber, _subnumber,
37591
 
             _item.itemsite_id, 'O',
37592
 
             pScheddate, pPromdate,
37593
 
             _item.qty, _item.bomitem_uom_id, _item.invuomratio,
37594
 
             0, 0,
37595
 
             stdCost(_item.item_id), 0,
37596
 
             0, _item.item_price_uom_id, 1,
37597
 
             _type, -1,
37598
 
             '', pMemo,
37599
 
             0);
37600
 
 
37601
 
    END IF;
37602
 
  END LOOP;
37603
 
 
37604
 
  RETURN _subnumber;
37605
 
END;
37606
 
$_$;
37607
 
 
37608
 
 
37609
 
ALTER FUNCTION public.explodekit(integer, integer, integer, integer, numeric, date, date, text) OWNER TO admin;
37610
 
 
37611
 
--
37612
 
--
37613
 
 
37614
 
CREATE FUNCTION explodephantomorder(integer, integer, numeric) RETURNS integer
37615
 
    LANGUAGE plpgsql
37616
 
    AS $_$
37617
 
DECLARE
37618
 
  pPlanordid ALIAS FOR $1;
37619
 
  pPhantomid ALIAS FOR $2;
37620
 
  pQty       ALIAS FOR $3;
37621
 
  _b RECORD;
37622
 
 
37623
 
BEGIN
37624
 
  FOR _b IN SELECT planord_number, c.itemsite_id AS componentsiteid,
37625
 
                   calculatenextworkingdate(c.itemsite_warehous_id, planord_startdate, (c.itemsite_leadtime * -1)) AS startdate,
37626
 
                   planord_startdate AS duedate,
37627
 
                   bomitem_createwo, c.itemsite_planning_type AS planningtype,
37628
 
                   (itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd + pQty * bomitem_qtyper) * (1 + bomitem_scrap))) AS qtyreq,
37629
 
                   item_type
37630
 
              FROM bomitem, planord, itemsite AS p, itemsite AS c, item
37631
 
             WHERE ((bomitem_parent_item_id=p.itemsite_item_id)
37632
 
               AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id))
37633
 
               AND (bomitem_item_id=c.itemsite_item_id)
37634
 
               AND (p.itemsite_warehous_id=c.itemsite_warehous_id)
37635
 
               AND (c.itemsite_item_id=item_id)
37636
 
               AND (woEffectiveDate(planord_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1))
37637
 
               AND (p.itemsite_id=pPhantomid)
37638
 
               AND (planord_id=pPlanordid)) LOOP
37639
 
 
37640
 
    IF (_b.item_type = 'F') THEN
37641
 
      PERFORM explodePhantomOrder(pPlanordid, _b.componentsiteid, _b.qtyreq);
37642
 
    ELSE
37643
 
      INSERT INTO planreq
37644
 
      ( planreq_source, planreq_source_id,
37645
 
        planreq_itemsite_id, planreq_qty )
37646
 
      VALUES
37647
 
      ( 'P', pPlanordid,
37648
 
        _b.componentsiteid, _b.qtyreq );
37649
 
 
37650
 
      IF (_b.bomitem_createwo AND _b.planningtype != 'N') THEN
37651
 
        PERFORM createPlannedOrder( pPlanordid, _b.planord_number, _b.componentsiteid,
37652
 
                                    _b.qtyreq, _b.startdate, _b.duedate,
37653
 
                                    FALSE, FALSE, NULL, NULL);
37654
 
      END IF;
37655
 
    END IF;
37656
 
 
37657
 
  END LOOP;
37658
 
 
37659
 
  RETURN pPlanordid;
37660
 
END;
37661
 
$_$;
37662
 
 
37663
 
 
37664
 
ALTER FUNCTION public.explodephantomorder(integer, integer, numeric) OWNER TO admin;
37665
 
 
37666
 
--
37667
 
--
37668
 
 
37669
 
CREATE FUNCTION explodewo(integer, boolean) RETURNS integer
37670
 
    LANGUAGE plpgsql
37671
 
    AS $_$
37672
 
DECLARE
37673
 
  pWoid ALIAS FOR $1;
37674
 
  pExplodeChildren ALIAS FOR $2;
37675
 
  resultCode INTEGER;
37676
 
  newWo RECORD;
37677
 
  _newwoid INTEGER;
37678
 
  _p RECORD;
37679
 
  _r RECORD;
37680
 
  _bbom BOOLEAN;
37681
 
 
37682
 
BEGIN
37683
 
  SELECT metric_value='t' INTO _bbom
37684
 
         FROM metric
37685
 
         WHERE (metric_name='BBOM');
37686
 
 
37687
 
  SELECT wo_id INTO resultCode
37688
 
  FROM wo
37689
 
  WHERE ((wo_status='O')
37690
 
   AND (wo_id=pWoid));
37691
 
  IF (NOT FOUND) THEN
37692
 
    RETURN -4;
37693
 
  END IF;
37694
 
 
37695
 
  SELECT bomitem_id INTO resultCode
37696
 
  FROM wo, bomitem, itemsite
37697
 
  WHERE ( (wo_itemsite_id=itemsite_id)
37698
 
   AND (itemsite_item_id=bomitem_parent_item_id)
37699
 
   AND (woEffectiveDate(wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1))
37700
 
   AND (wo_id=pWoid)
37701
 
   AND (bomitem_rev_id=wo_bom_rev_id)
37702
 
   AND (bomitem_item_id NOT IN
37703
 
        ( SELECT component.itemsite_item_id
37704
 
          FROM itemsite AS component, itemsite AS parent
37705
 
          WHERE ( (wo_itemsite_id=parent.itemsite_id)
37706
 
           AND (parent.itemsite_item_id=bomitem_parent_item_id)
37707
 
           AND (bomitem_item_id=component.itemsite_item_id)
37708
 
           AND (woEffectiveDate(wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1))
37709
 
           AND (component.itemsite_active)
37710
 
           AND (component.itemsite_warehous_id=parent.itemsite_warehous_id) ) ) ) )
37711
 
  LIMIT 1;
37712
 
  IF (FOUND) THEN
37713
 
    RETURN -2;
37714
 
  END IF;
37715
 
 
37716
 
  IF (_bbom) THEN
37717
 
 
37718
 
    IF ( ( SELECT (item_type='B')
37719
 
           FROM wo, itemsite, item
37720
 
           WHERE ( (wo_itemsite_id=itemsite_id)
37721
 
            AND (itemsite_item_id=item_id)
37722
 
            AND (wo_id=pWoid) ) ) ) THEN
37723
 
      SELECT bbomitem_id INTO resultCode
37724
 
      FROM wo, xtmfg.bbomitem, itemsite
37725
 
      WHERE ( (wo_itemsite_id=itemsite_id)
37726
 
       AND (itemsite_item_id=bbomitem_parent_item_id)
37727
 
       AND (woEffectiveDate(wo_startdate) BETWEEN bbomitem_effective AND (bbomitem_expires - 1))
37728
 
       AND (wo_id=pWoid)
37729
 
       AND (bbomitem_item_id NOT IN
37730
 
            ( SELECT component.itemsite_item_id
37731
 
              FROM itemsite AS component, itemsite AS parent
37732
 
              WHERE ( (wo_itemsite_id=parent.itemsite_id)
37733
 
               AND (parent.itemsite_item_id=bbomitem_parent_item_id)
37734
 
               AND (bbomitem_item_id=component.itemsite_item_id)
37735
 
               AND (woEffectiveDate(wo_startdate) BETWEEN bbomitem_effective AND (bbomitem_expires - 1))
37736
 
               AND (component.itemsite_active)
37737
 
               AND (component.itemsite_warehous_id=parent.itemsite_warehous_id) ) ) ) )
37738
 
      LIMIT 1;
37739
 
      IF (FOUND) THEN
37740
 
        RETURN -3;
37741
 
      END IF;
37742
 
    END IF;
37743
 
  END IF;
37744
 
 
37745
 
  INSERT INTO womatl
37746
 
  ( womatl_wo_id, womatl_bomitem_id, womatl_wooper_id, womatl_schedatwooper,
37747
 
    womatl_itemsite_id, womatl_duedate,
37748
 
    womatl_uom_id, womatl_qtyfxd, womatl_qtyper, womatl_scrap,
37749
 
    womatl_qtyreq,
37750
 
    womatl_qtyiss, womatl_qtywipscrap,
37751
 
    womatl_lastissue, womatl_lastreturn, womatl_cost,
37752
 
    womatl_picklist, womatl_createwo, womatl_issuewo,
37753
 
    womatl_issuemethod, womatl_notes, womatl_ref,
37754
 
    womatl_price )
37755
 
  SELECT wo_id, bomitem_id, bomitem_booitem_seq_id, bomitem_schedatwooper,
37756
 
         matl_itemsite, duedate,
37757
 
         bomitem_uom_id, bomitem_qtyfxd, bomitem_qtyper, bomitem_scrap,
37758
 
         qtyreq, 0, 0,
37759
 
         startOfTime(), startOfTime(), 0,
37760
 
         item_picklist, ( (item_type='M') AND (bomitem_createwo) ), issuewo,
37761
 
         bomitem_issuemethod, bomitem_notes, bomitem_ref,
37762
 
         CASE WHEN (price=-9999.0) THEN 0.0
37763
 
              ELSE price
37764
 
         END
37765
 
  FROM (SELECT *, cs.itemsite_id AS matl_itemsite,
37766
 
               CASE WHEN bomitem_schedatwooper THEN COALESCE(calcWooperStartStub(wo_id,bomitem_booitem_seq_id), wo_startdate)
37767
 
                    ELSE wo_startdate
37768
 
               END AS duedate,
37769
 
               roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), (bomitem_qtyfxd + bomitem_qtyper * wo_qtyord) * (1 + bomitem_scrap)) AS qtyreq,
37770
 
               CASE WHEN ( (item_type='M') AND (bomitem_issuewo) ) THEN TRUE
37771
 
                    WHEN (cs.itemsite_costmethod='J') THEN TRUE
37772
 
                    ELSE FALSE
37773
 
               END AS issuewo,
37774
 
               CASE WHEN (cohead_id IS NULL) THEN item_listprice
37775
 
                    ELSE (SELECT itemprice_price
37776
 
                          FROM itemIpsPrice(item_id, cohead_cust_id, cohead_shipto_id, 
37777
 
                                      roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), (bomitem_qtyfxd + bomitem_qtyper * wo_qtyord) * (1 + bomitem_scrap)),
37778
 
                                      bomitem_uom_id, bomitem_uom_id, cohead_curr_id, CURRENT_DATE, CURRENT_DATE, cohead_warehous_id) LIMIT 1)
37779
 
               END AS price
37780
 
        FROM wo JOIN itemsite ps ON (ps.itemsite_id=wo_itemsite_id)
37781
 
                JOIN bomitem ON (bomitem_parent_item_id=ps.itemsite_item_id AND
37782
 
                                 bomitem_rev_id=wo_bom_rev_id AND
37783
 
                                 woEffectiveDate(wo_startdate) BETWEEN bomitem_effective and (bomitem_expires - 1))
37784
 
                JOIN itemsite cs ON (cs.itemsite_item_id=bomitem_item_id AND
37785
 
                                     cs.itemsite_warehous_id=ps.itemsite_warehous_id)
37786
 
                JOIN item ON (item_id=cs.itemsite_item_id)
37787
 
                LEFT OUTER JOIN coitem ON (wo_ordtype='S' AND
37788
 
                                           wo_ordid=coitem_id)
37789
 
                LEFT OUTER JOIN cohead ON (cohead_id=coitem_cohead_id)
37790
 
        WHERE ( (wo_id=pWoid)
37791
 
          AND   ((bomitem_char_id IS NULL)
37792
 
             OR  EXISTS (
37793
 
                 SELECT charass_id
37794
 
                 FROM coitem,charass
37795
 
                 WHERE ((charass_target_type='SI')
37796
 
                   AND  (charass_target_id=coitem_id)
37797
 
                   AND  (charass_char_id=bomitem_char_id)
37798
 
                   AND  (charass_value=bomitem_value)
37799
 
                   AND  (wo_ordtype='S')
37800
 
                   AND  (coitem_id=wo_ordid)))) )
37801
 
        ) AS data;
37802
 
 
37803
 
  UPDATE pr SET pr_prj_id=wo_prj_id
37804
 
    FROM womatl, wo
37805
 
   WHERE ((wo_id=pWoid)
37806
 
     AND  (womatl_wo_id=wo_id)
37807
 
     AND  (pr_order_type='W')
37808
 
     AND  (pr_order_id=womatl_id));
37809
 
 
37810
 
  IF (_bbom) THEN
37811
 
 
37812
 
    INSERT INTO xtmfg.brddist
37813
 
    ( brddist_wo_id, brddist_wo_qty, brddist_itemsite_id,
37814
 
      brddist_stdqtyper, brddist_qty, brddist_posted )
37815
 
    SELECT wo_id, 0, cs.itemsite_id,
37816
 
           bbomitem_qtyper, 0, FALSE
37817
 
    FROM wo, xtmfg.bbomitem,
37818
 
         itemsite AS ps, itemsite AS cs, item
37819
 
    WHERE ( (bbomitem_parent_item_id=ps.itemsite_item_id)
37820
 
     AND (wo_itemsite_id=ps.itemsite_id)
37821
 
     AND (ps.itemsite_item_id=item_id)
37822
 
     AND (item_type='B')
37823
 
     AND (bbomitem_item_id=cs.itemsite_item_id)
37824
 
     AND (cs.itemsite_warehous_id=ps.itemsite_warehous_id)
37825
 
     AND (wo_id=pWoid) );
37826
 
 
37827
 
  END IF;
37828
 
 
37829
 
  IF ( ( SELECT (metric_value='t')
37830
 
         FROM metric
37831
 
         WHERE (metric_name='Routings') ) ) THEN
37832
 
 
37833
 
    INSERT INTO xtmfg.wooper
37834
 
    ( wooper_wo_id, wooper_booitem_id, wooper_seqnumber,
37835
 
      wooper_wrkcnt_id, wooper_stdopn_id,
37836
 
      wooper_descrip1, wooper_descrip2, wooper_toolref,
37837
 
      wooper_sutime, wooper_sucosttype, wooper_surpt,
37838
 
      wooper_rntime, wooper_rncosttype, wooper_rnrpt,
37839
 
      wooper_rnqtyper,
37840
 
      wooper_produom, wooper_invproduomratio,
37841
 
      wooper_issuecomp, wooper_rcvinv,
37842
 
      wooper_suconsumed, wooper_sucomplete,
37843
 
      wooper_rnconsumed, wooper_rncomplete,
37844
 
      wooper_qtyrcv, wooper_instruc, wooper_scheduled,
37845
 
      wooper_wip_location_id, wooper_price )
37846
 
    SELECT wo_id, booitem_id, booitem_seqnumber,
37847
 
           booitem_wrkcnt_id, booitem_stdopn_id,
37848
 
           booitem_descrip1, booitem_descrip2, booitem_toolref,
37849
 
           CASE WHEN (booitem_surpt) THEN booitem_sutime
37850
 
                ELSE 0
37851
 
           END, booitem_sucosttype, booitem_surpt,
37852
 
           CASE WHEN ((booitem_rnqtyper = 0) OR (booitem_invproduomratio = 0)) THEN 0
37853
 
                WHEN (NOT booitem_rnrpt) THEN 0
37854
 
                ELSE ( ( booitem_rntime /
37855
 
                         booitem_rnqtyper /
37856
 
                         booitem_invproduomratio ) * wo_qtyord )
37857
 
           END, booitem_rncosttype, booitem_rnrpt,
37858
 
           CASE WHEN (booitem_rnqtyper = 0) THEN 0
37859
 
                WHEN (NOT booitem_rnrpt) THEN 0
37860
 
                ELSE (booitem_rntime / booitem_rnqtyper)
37861
 
           END,
37862
 
           booitem_produom, booitem_invproduomratio,
37863
 
           booitem_issuecomp, booitem_rcvinv,
37864
 
           0::NUMERIC, FALSE,
37865
 
           0::NUMERIC, FALSE,
37866
 
           0::NUMERIC, booitem_instruc,
37867
 
           calculatenextworkingdate(itemsite_warehous_id,wo_startdate,booitem_execday-1),
37868
 
           booitem_wip_location_id,
37869
 
           (xtmfg.directlaborcostoper(booitem_id) + xtmfg.overheadcostoper(booitem_id) + xtmfg.machineoverheadcostoper(booitem_id))
37870
 
    FROM xtmfg.booitem, wo, itemsite
37871
 
    WHERE ((wo_itemsite_id=itemsite_id)
37872
 
     AND (itemsite_item_id=booitem_item_id)
37873
 
     AND (booitem_rev_id=wo_boo_rev_id)
37874
 
     AND (woEffectiveDate(wo_startdate) BETWEEN booitem_effective AND (booitem_expires - 1))
37875
 
     AND (wo_id=pWoid));
37876
 
 
37877
 
    UPDATE womatl
37878
 
    SET womatl_wooper_id=wooper_id
37879
 
    FROM wo,xtmfg.wooper,xtmfg.booitem
37880
 
    WHERE ((womatl_wooper_id=booitem_seq_id)
37881
 
     AND (wooper_booitem_id=booitem_id)
37882
 
     AND (womatl_wo_id=wo_id)
37883
 
     AND (wooper_wo_id=wo_id)
37884
 
     AND (wo_boo_rev_id=booitem_rev_id)
37885
 
     AND (wo_id=pWoid));
37886
 
    END IF;
37887
 
 
37888
 
  WHILE ( ( SELECT COUNT(*)
37889
 
            FROM womatl, itemsite, item
37890
 
            WHERE ( (womatl_itemsite_id=itemsite_id)
37891
 
             AND (itemsite_item_id=item_id)
37892
 
             AND (womatl_wo_id=pWoid)
37893
 
             AND (item_type='F') ) ) > 0 ) LOOP
37894
 
 
37895
 
    FOR _p IN SELECT wo_qtyord, wo_startdate, womatl_id, womatl_wooper_id
37896
 
              FROM wo, womatl, itemsite, item
37897
 
              WHERE ( (womatl_itemsite_id=itemsite_id)
37898
 
               AND (itemsite_item_id=item_id)
37899
 
               AND (item_type='F')
37900
 
               AND (womatl_wo_id=wo_id)
37901
 
               AND (wo_id=pWoid) ) LOOP
37902
 
 
37903
 
      INSERT INTO womatl
37904
 
      ( womatl_wo_id, womatl_itemsite_id, womatl_wooper_id,
37905
 
        womatl_schedatwooper, womatl_duedate,
37906
 
        womatl_uom_id, womatl_qtyfxd, womatl_qtyper, womatl_scrap,
37907
 
        womatl_qtyreq,
37908
 
        womatl_qtyiss, womatl_qtywipscrap,
37909
 
        womatl_lastissue, womatl_lastreturn,
37910
 
        womatl_cost, womatl_picklist,
37911
 
        womatl_createwo, womatl_issuewo,
37912
 
        womatl_issuemethod, womatl_notes, womatl_ref )
37913
 
      SELECT pWoid, cs.itemsite_id, _p.womatl_wooper_id,
37914
 
             womatl_schedatwooper, womatl_duedate,
37915
 
             bomitem_uom_id, bomitem_qtyfxd, (bomitem_qtyper * womatl_qtyper), bomitem_scrap,
37916
 
             roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), 
37917
 
                     (bomitem_qtyfxd + _p.wo_qtyord * bomitem_qtyper * womatl_qtyper) * (1 + bomitem_scrap)),
37918
 
             0, 0,
37919
 
             startOfTime(), startOfTime(),
37920
 
             0, ci.item_picklist,
37921
 
             ( (ci.item_type='M') AND (bomitem_createwo) ), ( (ci.item_type='M') AND (bomitem_issuewo) ),
37922
 
             bomitem_issuemethod, bomitem_notes, bomitem_ref
37923
 
      FROM womatl JOIN wo ON (wo_id=womatl_wo_id)
37924
 
                  JOIN itemsite ps ON (ps.itemsite_id=womatl_itemsite_id)
37925
 
                  JOIN item pi ON (pi.item_id=ps.itemsite_item_id)
37926
 
                  JOIN bomitem ON ( (bomitem_parent_item_id=pi.item_id) AND
37927
 
                                    (woEffectiveDate(_p.wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND
37928
 
                                    (bomitem_rev_id=getActiveRevId('BOM', pi.item_id)) )
37929
 
                  JOIN item ci ON (ci.item_id=bomitem.bomitem_item_id)
37930
 
                  JOIN itemsite cs ON ( (cs.itemsite_item_id=ci.item_id) AND
37931
 
                                        (cs.itemsite_warehous_id=ps.itemsite_warehous_id) )
37932
 
      WHERE (womatl_id=_p.womatl_id);
37933
 
 
37934
 
      DELETE FROM womatl
37935
 
      WHERE (womatl_id=_p.womatl_id);
37936
 
 
37937
 
    END LOOP;
37938
 
  END LOOP;
37939
 
 
37940
 
  FOR newWo IN SELECT wo_number, nextWoSubnumber(wo_number) AS nextSubnumber,
37941
 
                      itemsite_id, itemsite_leadtime, womatl_duedate,
37942
 
                      womatl_wo_id, womatl_qtyreq, womatl_uom_id, wo_prj_id,
37943
 
                      item_id, item_inv_uom_id, womatl_id
37944
 
               FROM womatl, wo, itemsite, item
37945
 
               WHERE ( (womatl_wo_id=wo_id)
37946
 
                AND (womatl_itemsite_id=itemsite_id)
37947
 
                AND (womatl_createwo)
37948
 
                AND (itemsite_wosupply)
37949
 
                AND (itemsite_item_id=item_id)
37950
 
                AND (wo_id=pWoid) )
37951
 
               ORDER BY womatl_id LOOP
37952
 
 
37953
 
    SELECT createWo( newWo.wo_number, newWo.itemsite_id, 1, 
37954
 
                     itemuomtouom(newWo.item_id,newWo.womatl_uom_id,newWo.item_inv_uom_id,newWo.womatl_qtyreq),
37955
 
                      newWo.itemsite_leadtime, newWo.womatl_duedate, '',
37956
 
                      'W', newWo.womatl_wo_id, newWo.wo_prj_id ) INTO _newwoid;
37957
 
 
37958
 
    UPDATE wo SET wo_womatl_id = newWo.womatl_id WHERE wo_id=_newwoid;
37959
 
 
37960
 
  END LOOP;
37961
 
 
37962
 
  UPDATE wo
37963
 
  SET wo_status='E', wo_adhoc=FALSE
37964
 
  WHERE (wo_id=pWoid);
37965
 
 
37966
 
  IF (pExplodeChildren) THEN
37967
 
    SELECT MAX(explodeWo(wo_id, TRUE)) INTO resultCode
37968
 
    FROM wo
37969
 
    WHERE ( (wo_ordtype='W')
37970
 
     AND (wo_ordid=pWoid) );
37971
 
  END IF;
37972
 
 
37973
 
  RETURN pWoid;
37974
 
END;
37975
 
$_$;
37976
 
 
37977
 
 
37978
 
ALTER FUNCTION public.explodewo(integer, boolean) OWNER TO admin;
37979
 
 
37980
 
--
37981
 
--
37982
 
 
37983
 
CREATE FUNCTION explodewoeffective() RETURNS text
37984
 
    LANGUAGE plpgsql
37985
 
    AS $$
37986
 
DECLARE
37987
 
  _value TEXT;
37988
 
 
37989
 
BEGIN
37990
 
 
37991
 
  SELECT metric_value INTO _value
37992
 
  FROM metric
37993
 
  WHERE (metric_name='ExplodeWOEffective');
37994
 
 
37995
 
  RETURN _value;
37996
 
 
37997
 
END;
37998
 
$$;
37999
 
 
38000
 
 
38001
 
ALTER FUNCTION public.explodewoeffective() OWNER TO admin;
38002
 
 
38003
 
--
38004
 
--
38005
 
 
38006
 
CREATE FUNCTION fetchapmemonumber() RETURNS integer
38007
 
    LANGUAGE sql
38008
 
    AS $$
38009
 
  SELECT fetchNextNumber('APMemoNumber')::INTEGER;
38010
 
$$;
38011
 
 
38012
 
 
38013
 
ALTER FUNCTION public.fetchapmemonumber() OWNER TO admin;
38014
 
 
38015
 
--
38016
 
--
38017
 
 
38018
 
CREATE FUNCTION fetcharmemonumber() RETURNS text
38019
 
    LANGUAGE sql
38020
 
    AS $$
38021
 
  SELECT fetchNextNumber('ARMemoNumber');
38022
 
$$;
38023
 
 
38024
 
 
38025
 
ALTER FUNCTION public.fetcharmemonumber() OWNER TO admin;
38026
 
 
38027
 
--
38028
 
--
38029
 
 
38030
 
CREATE FUNCTION fetchcashrcptnumber() RETURNS text
38031
 
    LANGUAGE sql
38032
 
    AS $$
38033
 
  SELECT fetchNextNumber('CashRcptNumber');
38034
 
$$;
38035
 
 
38036
 
 
38037
 
ALTER FUNCTION public.fetchcashrcptnumber() OWNER TO admin;
38038
 
 
38039
 
--
38040
 
--
38041
 
 
38042
 
CREATE FUNCTION fetchcmnumber() RETURNS text
38043
 
    LANGUAGE sql
38044
 
    AS $$
38045
 
  SELECT fetchNextNumber('CmNumber');
38046
 
$$;
38047
 
 
38048
 
 
38049
 
ALTER FUNCTION public.fetchcmnumber() OWNER TO admin;
38050
 
 
38051
 
--
38052
 
--
38053
 
 
38054
 
CREATE FUNCTION fetchcrmaccountnumber() RETURNS integer
38055
 
    LANGUAGE sql
38056
 
    AS $$
38057
 
  SELECT fetchNextNumber('CRMAccountNumber')::INTEGER;
38058
 
$$;
38059
 
 
38060
 
 
38061
 
ALTER FUNCTION public.fetchcrmaccountnumber() OWNER TO admin;
38062
 
 
38063
 
--
38064
 
--
38065
 
 
38066
 
CREATE FUNCTION fetchdefaultfob(pwarehousid integer) RETURNS text
38067
 
    LANGUAGE sql
38068
 
    AS $_$
38069
 
  SELECT warehous_fob
38070
 
    FROM whsinfo
38071
 
   WHERE (warehous_id=$1);
38072
 
$_$;
38073
 
 
38074
 
 
38075
 
ALTER FUNCTION public.fetchdefaultfob(pwarehousid integer) OWNER TO admin;
38076
 
 
38077
 
--
38078
 
--
38079
 
 
38080
 
CREATE FUNCTION fetchdefaultshipvia() RETURNS text
38081
 
    LANGUAGE plpgsql
38082
 
    AS $$
38083
 
DECLARE
38084
 
  _returnVal TEXT;
38085
 
BEGIN
38086
 
  SELECT shipvia_code INTO _returnVal
38087
 
  FROM shipvia
38088
 
  WHERE shipvia_id=
38089
 
        (SELECT CAST(metric_value AS integer)
38090
 
        FROM metric
38091
 
        WHERE metric_name = 'DefaultShipViaId');
38092
 
  RETURN _returnVal;
38093
 
END;
38094
 
$$;
38095
 
 
38096
 
 
38097
 
ALTER FUNCTION public.fetchdefaultshipvia() OWNER TO admin;
38098
 
 
38099
 
--
38100
 
--
38101
 
 
38102
 
CREATE FUNCTION fetchglsequence() RETURNS integer
38103
 
    LANGUAGE plpgsql
38104
 
    AS $$
38105
 
DECLARE
38106
 
  _sequence INTEGER;
38107
 
 
38108
 
BEGIN
38109
 
 
38110
 
    SELECT NEXTVAL('gltrans_sequence_seq') INTO _sequence;
38111
 
    RETURN _sequence;
38112
 
 
38113
 
END;
38114
 
$$;
38115
 
 
38116
 
 
38117
 
ALTER FUNCTION public.fetchglsequence() OWNER TO admin;
38118
 
 
38119
 
--
38120
 
--
38121
 
 
38122
 
CREATE FUNCTION fetchincidentnumber() RETURNS integer
38123
 
    LANGUAGE sql
38124
 
    AS $$
38125
 
  SELECT fetchNextNumber('IncidentNumber')::integer;
38126
 
$$;
38127
 
 
38128
 
 
38129
 
ALTER FUNCTION public.fetchincidentnumber() OWNER TO admin;
38130
 
 
38131
 
--
38132
 
--
38133
 
 
38134
 
CREATE FUNCTION fetchinvcnumber() RETURNS integer
38135
 
    LANGUAGE sql
38136
 
    AS $$
38137
 
  SELECT fetchNextNumber('InvcNumber')::integer;
38138
 
$$;
38139
 
 
38140
 
 
38141
 
ALTER FUNCTION public.fetchinvcnumber() OWNER TO admin;
38142
 
 
38143
 
--
38144
 
--
38145
 
 
38146
 
CREATE FUNCTION fetchitemuomconvtypes(integer) RETURNS text[]
38147
 
    LANGUAGE plpgsql
38148
 
    AS $_$
38149
 
DECLARE
38150
 
  pItemUomConvId ALIAS FOR $1;
38151
 
  _p RECORD;
38152
 
  _result text[];
38153
 
  _cnt INTEGER;
38154
 
 
38155
 
BEGIN
38156
 
 
38157
 
  _cnt := 0;
38158
 
 
38159
 
  FOR _p IN SELECT
38160
 
    uomtype_name
38161
 
  FROM itemuomconv, itemuom, uomtype
38162
 
  WHERE ((itemuomconv_id=pItemUomConvId)
38163
 
  AND (itemuomconv_id=itemuom_itemuomconv_id)
38164
 
  AND (itemuom_uomtype_id=uomtype_id))
38165
 
  LOOP
38166
 
    _result[_cnt] := _p.uomtype_name; 
38167
 
    _cnt := _cnt + 1;
38168
 
  END LOOP;
38169
 
 
38170
 
  RETURN _result;
38171
 
END;
38172
 
$_$;
38173
 
 
38174
 
 
38175
 
ALTER FUNCTION public.fetchitemuomconvtypes(integer) OWNER TO admin;
38176
 
 
38177
 
--
38178
 
--
38179
 
 
38180
 
CREATE FUNCTION fetchjournalnumber(text) RETURNS integer
38181
 
    LANGUAGE plpgsql
38182
 
    AS $_$
38183
 
DECLARE
38184
 
  pUse ALIAS FOR $1;
38185
 
  _number INTEGER;
38186
 
 
38187
 
BEGIN
38188
 
 
38189
 
  SELECT nextval('journal_number_seq') INTO _number;
38190
 
 
38191
 
  INSERT INTO jrnluse
38192
 
  (jrnluse_date, jrnluse_number, jrnluse_use)
38193
 
  VALUES
38194
 
  (CURRENT_TIMESTAMP, _number, pUse);
38195
 
 
38196
 
  RETURN _number;
38197
 
  
38198
 
END;
38199
 
$_$;
38200
 
 
38201
 
 
38202
 
ALTER FUNCTION public.fetchjournalnumber(text) OWNER TO admin;
38203
 
 
38204
 
--
38205
 
--
38206
 
 
38207
 
CREATE FUNCTION fetchmetricbool(text) RETURNS boolean
38208
 
    LANGUAGE plpgsql STABLE
38209
 
    AS $_$
38210
 
DECLARE
38211
 
  _pMetricName ALIAS FOR $1;
38212
 
  _returnVal BOOLEAN;
38213
 
BEGIN
38214
 
  SELECT CASE 
38215
 
    WHEN MIN(metric_value) = 't' THEN
38216
 
     true
38217
 
    ELSE
38218
 
     false
38219
 
    END INTO _returnVal
38220
 
    FROM metric
38221
 
   WHERE metric_name = _pMetricName;
38222
 
  RETURN _returnVal;
38223
 
END;
38224
 
$_$;
38225
 
 
38226
 
 
38227
 
ALTER FUNCTION public.fetchmetricbool(text) OWNER TO admin;
38228
 
 
38229
 
--
38230
 
--
38231
 
 
38232
 
CREATE FUNCTION fetchmetrictext(text) RETURNS text
38233
 
    LANGUAGE plpgsql STABLE
38234
 
    AS $_$
38235
 
DECLARE
38236
 
  _pMetricName ALIAS FOR $1;
38237
 
  _returnVal TEXT;
38238
 
BEGIN
38239
 
  SELECT metric_value::TEXT INTO _returnVal
38240
 
    FROM metric
38241
 
   WHERE metric_name = _pMetricName;
38242
 
  RETURN _returnVal;
38243
 
END;
38244
 
$_$;
38245
 
 
38246
 
 
38247
 
ALTER FUNCTION public.fetchmetrictext(text) OWNER TO admin;
38248
 
 
38249
 
--
38250
 
--
38251
 
 
38252
 
CREATE FUNCTION fetchmetricvalue(text) RETURNS numeric
38253
 
    LANGUAGE plpgsql STABLE
38254
 
    AS $_$
38255
 
DECLARE
38256
 
  _pMetricName ALIAS FOR $1;
38257
 
  _returnVal INTEGER;
38258
 
BEGIN
38259
 
  SELECT CASE WHEN (isNumeric(metric_value)) THEN metric_value::INTEGER
38260
 
              ELSE NULL
38261
 
         END INTO _returnVal
38262
 
    FROM metric
38263
 
   WHERE metric_name = _pMetricName;
38264
 
  RETURN _returnVal;
38265
 
END;
38266
 
$_$;
38267
 
 
38268
 
 
38269
 
ALTER FUNCTION public.fetchmetricvalue(text) OWNER TO admin;
38270
 
 
38271
 
--
38272
 
--
38273
 
 
38274
 
CREATE FUNCTION fetchnextchecknumber(pbankaccntid integer) RETURNS integer
38275
 
    LANGUAGE plpgsql
38276
 
    AS $_$
38277
 
DECLARE
38278
 
  pBankaccntid ALIAS FOR $1;
38279
 
  _nextChkNumber INTEGER;
38280
 
  _checkheadid INTEGER;
38281
 
 
38282
 
BEGIN
38283
 
 
38284
 
  SELECT bankaccnt_nextchknum INTO _nextChkNumber
38285
 
  FROM bankaccnt
38286
 
  WHERE (bankaccnt_id=pBankaccntid);
38287
 
 
38288
 
  WHILE (TRUE) LOOP
38289
 
    SELECT checkhead_id INTO _checkheadid
38290
 
    FROM checkhead
38291
 
    WHERE (checkhead_number=_nextChkNumber)
38292
 
      AND (checkhead_bankaccnt_id=pBankaccntid);
38293
 
    IF (NOT FOUND) THEN
38294
 
      EXIT;
38295
 
    ELSE
38296
 
      _nextChkNumber := _nextChkNumber + 1;
38297
 
    END IF;
38298
 
  END LOOP;
38299
 
 
38300
 
  UPDATE bankaccnt
38301
 
  SET bankaccnt_nextchknum = (bankaccnt_nextchknum + 1)
38302
 
  WHERE (bankaccnt_id=pBankaccntid);
38303
 
 
38304
 
  RETURN _nextChkNumber;
38305
 
 
38306
 
END;
38307
 
$_$;
38308
 
 
38309
 
 
38310
 
ALTER FUNCTION public.fetchnextchecknumber(pbankaccntid integer) OWNER TO admin;
38311
 
 
38312
 
--
38313
 
--
38314
 
 
38315
 
CREATE FUNCTION fetchnextnumber(text) RETURNS text
38316
 
    LANGUAGE plpgsql
38317
 
    AS $_$
38318
 
DECLARE
38319
 
  psequence     ALIAS FOR $1;
38320
 
  _number       TEXT;
38321
 
  _numcol       TEXT;
38322
 
  _select       TEXT;
38323
 
  _table        TEXT;
38324
 
  _test         TEXT;
38325
 
  _nextnum      INTEGER;
38326
 
  _seqiss       seqiss;
38327
 
  __seqiss      seqiss[];
38328
 
  _not_issued       BOOLEAN;
38329
 
 
38330
 
BEGIN
38331
 
  SELECT CAST(orderseq_number AS text), orderseq_number, orderseq_table, orderseq_numcol, COALESCE(orderseq_seqiss, ARRAY[]::seqiss[])
38332
 
    INTO _number, _nextnum, _table, _numcol, __seqiss
38333
 
  FROM orderseq
38334
 
  WHERE (orderseq_name=psequence) FOR UPDATE;
38335
 
 
38336
 
  IF (NOT FOUND) THEN
38337
 
    RAISE EXCEPTION 'Invalid orderseq_name %', psequence;
38338
 
  END IF;
38339
 
  
38340
 
  LOOP
38341
 
 
38342
 
    _seqiss := (_nextnum, now());
38343
 
 
38344
 
    SELECT count(*) = 0 INTO _not_issued
38345
 
    FROM (SELECT UNNEST(__seqiss) AS issued) data
38346
 
    WHERE (issued).seqiss_number = _nextnum;
38347
 
 
38348
 
    _nextnum := _nextnum + 1;
38349
 
 
38350
 
    -- Test if the number has been issued, but not committed
38351
 
    IF (_not_issued) THEN
38352
 
 
38353
 
      -- Test if the number has been committed
38354
 
      _select := 'SELECT ' || quote_ident(_numcol) ||
38355
 
                 ' FROM '  || _table ||
38356
 
                 ' WHERE (' || quote_ident(_numcol) || '=' ||
38357
 
                 quote_literal(_number) || ');';
38358
 
 
38359
 
      EXECUTE _select INTO _test;
38360
 
 
38361
 
      IF (_test IS NULL OR NOT FOUND) THEN
38362
 
        EXIT;
38363
 
      END IF;
38364
 
 
38365
 
    END IF;
38366
 
 
38367
 
    -- Number in use, try again
38368
 
    _number = _nextnum::text;
38369
 
 
38370
 
  END LOOP;
38371
 
 
38372
 
  UPDATE orderseq SET 
38373
 
    orderseq_number = _nextnum
38374
 
  WHERE (orderseq_name=psequence);
38375
 
 
38376
 
  IF (fetchMetricBool('EnableGaplessNumbering')) THEN
38377
 
    UPDATE orderseq SET 
38378
 
      orderseq_seqiss = orderseq_seqiss || _seqiss
38379
 
    WHERE (orderseq_name=psequence);
38380
 
  END IF;
38381
 
 
38382
 
  RETURN _number;
38383
 
 
38384
 
END;
38385
 
$_$;
38386
 
 
38387
 
 
38388
 
ALTER FUNCTION public.fetchnextnumber(text) OWNER TO admin;
38389
 
 
38390
 
--
38391
 
--
38392
 
 
38393
 
CREATE FUNCTION fetchponumber() RETURNS text
38394
 
    LANGUAGE sql
38395
 
    AS $$
38396
 
  SELECT fetchNextNumber('PoNumber');
38397
 
$$;
38398
 
 
38399
 
 
38400
 
ALTER FUNCTION public.fetchponumber() OWNER TO admin;
38401
 
 
38402
 
--
38403
 
--
38404
 
 
38405
 
CREATE FUNCTION fetchprefwarehousid() RETURNS integer
38406
 
    LANGUAGE plpgsql
38407
 
    AS $$
38408
 
DECLARE
38409
 
  _result INTEGER;
38410
 
BEGIN
38411
 
    SELECT CAST(usrpref_value AS INTEGER) INTO _result
38412
 
    FROM usrpref
38413
 
    WHERE ((usrpref_username=getEffectiveXtUser())
38414
 
    AND (usrpref_name='PreferredWarehouse'));
38415
 
 
38416
 
    RETURN _result;
38417
 
END;
38418
 
$$;
38419
 
 
38420
 
 
38421
 
ALTER FUNCTION public.fetchprefwarehousid() OWNER TO admin;
38422
 
 
38423
 
--
38424
 
--
38425
 
 
38426
 
CREATE FUNCTION fetchprnumber() RETURNS integer
38427
 
    LANGUAGE sql
38428
 
    AS $$
38429
 
  SELECT fetchNextNumber('PrNumber')::INTEGER;
38430
 
$$;
38431
 
 
38432
 
 
38433
 
ALTER FUNCTION public.fetchprnumber() OWNER TO admin;
38434
 
 
38435
 
--
38436
 
--
38437
 
 
38438
 
CREATE FUNCTION fetchqunumber() RETURNS text
38439
 
    LANGUAGE sql
38440
 
    AS $$
38441
 
  SELECT fetchNextNumber('QuNumber');
38442
 
$$;
38443
 
 
38444
 
 
38445
 
ALTER FUNCTION public.fetchqunumber() OWNER TO admin;
38446
 
 
38447
 
--
38448
 
--
38449
 
 
38450
 
CREATE FUNCTION fetchshipmentnumber() RETURNS text
38451
 
    LANGUAGE plpgsql
38452
 
    AS $$
38453
 
DECLARE
38454
 
  _number               TEXT;
38455
 
  _test                 INTEGER;
38456
 
 
38457
 
BEGIN
38458
 
  LOOP
38459
 
 
38460
 
    SELECT CAST(nextval('shipment_number_seq') AS TEXT) INTO _number;
38461
 
    
38462
 
    SELECT shiphead_id INTO _test
38463
 
      FROM shiphead
38464
 
     WHERE (shiphead_number=_number);
38465
 
    IF (NOT FOUND) THEN
38466
 
      EXIT;
38467
 
    END IF;
38468
 
 
38469
 
  END LOOP;
38470
 
 
38471
 
  RETURN _number;
38472
 
  
38473
 
END;
38474
 
$$;
38475
 
 
38476
 
 
38477
 
ALTER FUNCTION public.fetchshipmentnumber() OWNER TO admin;
38478
 
 
38479
 
--
38480
 
--
38481
 
 
38482
 
CREATE FUNCTION fetchsonumber() RETURNS text
38483
 
    LANGUAGE sql
38484
 
    AS $$
38485
 
  SELECT fetchNextNumber('SoNumber');
38486
 
$$;
38487
 
 
38488
 
 
38489
 
ALTER FUNCTION public.fetchsonumber() OWNER TO admin;
38490
 
 
38491
 
--
38492
 
--
38493
 
 
38494
 
CREATE FUNCTION fetchtonumber() RETURNS text
38495
 
    LANGUAGE sql
38496
 
    AS $$
38497
 
  SELECT fetchNextNumber('ToNumber');
38498
 
$$;
38499
 
 
38500
 
 
38501
 
ALTER FUNCTION public.fetchtonumber() OWNER TO admin;
38502
 
 
38503
 
--
38504
 
--
38505
 
 
38506
 
CREATE FUNCTION fetchusrprefbool(text) RETURNS boolean
38507
 
    LANGUAGE plpgsql
38508
 
    AS $_$
38509
 
DECLARE
38510
 
  _pPrefName ALIAS FOR $1;
38511
 
  _returnVal BOOLEAN;
38512
 
BEGIN
38513
 
  SELECT CASE 
38514
 
    WHEN MIN(usrpref_value) = 't' THEN
38515
 
     true
38516
 
    ELSE
38517
 
     false
38518
 
    END INTO _returnVal
38519
 
  FROM usrpref
38520
 
  WHERE ( (usrpref_username=getEffectiveXtUser())
38521
 
    AND   (usrpref_name=_pPrefName) );
38522
 
  RETURN _returnVal;
38523
 
END;
38524
 
$_$;
38525
 
 
38526
 
 
38527
 
ALTER FUNCTION public.fetchusrprefbool(text) OWNER TO admin;
38528
 
 
38529
 
--
38530
 
--
38531
 
 
38532
 
CREATE FUNCTION fetchvonumber() RETURNS integer
38533
 
    LANGUAGE sql
38534
 
    AS $$
38535
 
  SELECT fetchNextNumber('VcNumber')::INTEGER;
38536
 
$$;
38537
 
 
38538
 
 
38539
 
ALTER FUNCTION public.fetchvonumber() OWNER TO admin;
38540
 
 
38541
 
--
38542
 
--
38543
 
 
38544
 
CREATE FUNCTION fetchwonumber() RETURNS integer
38545
 
    LANGUAGE sql
38546
 
    AS $$
38547
 
  SELECT fetchNextNumber('WoNumber')::INTEGER;
38548
 
$$;
38549
 
 
38550
 
 
38551
 
ALTER FUNCTION public.fetchwonumber() OWNER TO admin;
38552
 
 
38553
 
--
38554
 
--
38555
 
 
38556
 
CREATE FUNCTION financialreport(integer, integer, integer) RETURNS boolean
38557
 
    LANGUAGE plpgsql
38558
 
    AS $_$
38559
 
DECLARE
38560
 
  pFlheadid ALIAS FOR $1;
38561
 
  pPeriodid ALIAS FOR $2;
38562
 
  pPrjid    ALIAS FOR $3;
38563
 
  _result bool;
38564
 
 
38565
 
BEGIN
38566
 
 
38567
 
  SELECT financialreport(pFlheadid,pPeriodid,'M', pPrjid) INTO _result;
38568
 
 
38569
 
  RETURN _result;
38570
 
END;
38571
 
$_$;
38572
 
 
38573
 
 
38574
 
ALTER FUNCTION public.financialreport(integer, integer, integer) OWNER TO admin;
38575
 
 
38576
 
--
38577
 
--
38578
 
 
38579
 
CREATE FUNCTION financialreport(integer, integer, character, integer) RETURNS boolean
38580
 
    LANGUAGE plpgsql
38581
 
    AS $_$
38582
 
 
38583
 
/* performance vs. history:
38584
 
   versions prior to xTuple ERP 4.5.x (x ?= 1) used public.flrpt
38585
 
   to build financial reports. after that release, the function
38586
 
   creates a temporary table if necessary. with the temp table,
38587
 
   flrpt self-joins no longer require comparing flrpt_username -
38588
 
   temp tables are only visible within the current session. however,
38589
 
   there are subsidiary functions (eg insertflgroup) that _do_ join
38590
 
   on flrpt_username. in addition, flrpt_username has a not-null constraint.
38591
 
   to reduce the risk of breakage, this function still sets flrpt_username.
38592
 
*/
38593
 
DECLARE
38594
 
  pFlheadid ALIAS FOR $1;
38595
 
  pPeriodid ALIAS FOR $2;
38596
 
  pInterval ALIAS FOR $3;
38597
 
  pPrjid    ALIAS FOR $4;
38598
 
 
38599
 
  _r RECORD;
38600
 
  _t RECORD;
38601
 
  _s RECORD;
38602
 
  _username TEXT := getEffectiveXtUser();
38603
 
 
38604
 
BEGIN
38605
 
 
38606
 
   IF pInterval <> 'M' AND pInterval <> 'Q' AND pInterval <> 'Y' THEN
38607
 
     RAISE EXCEPTION 'Invalid Interval --> %', pInterval;
38608
 
   END IF;
38609
 
 
38610
 
  CREATE TEMPORARY TABLE IF NOT EXISTS flrpt
38611
 
    (LIKE public.flrpt INCLUDING ALL)
38612
 
    ON COMMIT PRESERVE ROWS;
38613
 
 
38614
 
  -- clear even temp tables because every run builds on data upserted by itself
38615
 
  DELETE FROM flrpt
38616
 
   WHERE ((flrpt_flhead_id=pFlheadid)
38617
 
     AND  (flrpt_period_id=pPeriodId)
38618
 
     AND  (flrpt_interval=pInterval));
38619
 
 
38620
 
  SELECT flhead_showtotal,
38621
 
         CASE WHEN(flhead_showstart) THEN 0.00
38622
 
              ELSE NULL
38623
 
         END AS beginning,
38624
 
         CASE WHEN(flhead_showend) THEN 0.00
38625
 
              ELSE NULL
38626
 
         END AS ending,
38627
 
         CASE WHEN(flhead_showdelta) THEN 0.00
38628
 
              ELSE NULL
38629
 
         END AS debits,
38630
 
         CASE WHEN(flhead_showdelta) THEN 0.00
38631
 
              ELSE NULL
38632
 
         END AS credits,
38633
 
         CASE WHEN(flhead_showbudget) THEN 0.00
38634
 
              ELSE NULL
38635
 
         END AS budget,
38636
 
         CASE WHEN(flhead_showdiff) THEN 0.00
38637
 
              ELSE NULL
38638
 
         END AS diff,
38639
 
         CASE WHEN(flhead_showcustom) THEN 0.00
38640
 
              ELSE NULL
38641
 
         END AS custom,
38642
 
         CASE WHEN(flhead_usealttotal) THEN flhead_alttotal
38643
 
              ELSE NULL
38644
 
         END AS altname INTO _r
38645
 
    FROM flhead
38646
 
   WHERE (flhead_id=pFlheadid);
38647
 
  IF (NOT FOUND) THEN
38648
 
    return FALSE;
38649
 
  END IF;
38650
 
 
38651
 
  IF (_r.flhead_showtotal) THEN
38652
 
    INSERT INTO flrpt
38653
 
           (flrpt_flhead_id, flrpt_period_id, flrpt_username,
38654
 
            flrpt_order, flrpt_level, flrpt_type, flrpt_type_id,
38655
 
            flrpt_beginning, flrpt_ending,
38656
 
            flrpt_debits, flrpt_credits, flrpt_budget, flrpt_diff,
38657
 
            flrpt_custom, flrpt_altname, flrpt_interval )
38658
 
    VALUES (pFlheadid, pPeriodid, _username,
38659
 
            0, -1, 'G', -1,
38660
 
            _r.beginning, _r.ending,
38661
 
            _r.debits, _r.credits, _r.budget, _r.diff,
38662
 
            _r.custom, _r.altname, pInterval );
38663
 
  END IF;
38664
 
 
38665
 
  PERFORM insertFlGroup(pFlheadid, pPeriodid, -1, 0, FALSE, pInterval, pPrjid);
38666
 
 
38667
 
  FOR _t IN SELECT flrpt_order, CASE WHEN(flgrp_prcnt_flgrp_id = -1) THEN flgrp_flgrp_id ELSE flgrp_prcnt_flgrp_id END AS flgrp_id
38668
 
              FROM flrpt, flgrp
38669
 
             WHERE ((flrpt_flhead_id=pFlheadid)
38670
 
               AND  (flrpt_period_id=pPeriodid)
38671
 
               AND  (flrpt_interval=pInterval)
38672
 
               AND  (flrpt_type='G')
38673
 
               AND  (flrpt_type_id=flgrp_id))
38674
 
             UNION
38675
 
            SELECT flrpt_order, CASE WHEN(flitem_prcnt_flgrp_id = -1) THEN flitem_flgrp_id ELSE flitem_prcnt_flgrp_id END AS flgrp_id
38676
 
              FROM flrpt, flitem
38677
 
             WHERE ((flrpt_flhead_id=pFlheadid)
38678
 
               AND  (flrpt_period_id=pPeriodid)
38679
 
               AND  (flrpt_interval=pInterval)
38680
 
               AND  (flrpt_type='I')
38681
 
               AND  (flrpt_type_id=flitem_id))
38682
 
             UNION
38683
 
            SELECT flrpt_order, CASE WHEN(flspec_prcnt_flgrp_id = -1) THEN flspec_flgrp_id ELSE flspec_prcnt_flgrp_id END AS flgrp_id
38684
 
              FROM flrpt, flspec
38685
 
             WHERE ((flrpt_flhead_id=pFlheadid)
38686
 
               AND  (flrpt_period_id=pPeriodid)
38687
 
               AND  (flrpt_interval=pInterval)
38688
 
               AND  (flrpt_type='S')
38689
 
               AND  (flrpt_type_id=flspec_id)) LOOP
38690
 
 
38691
 
    IF( (_t.flgrp_id=-1) OR (NOT (SELECT flgrp_summarize FROM flgrp WHERE flgrp_id=_t.flgrp_id)) ) THEN
38692
 
      SELECT COALESCE(SUM(flrpt_beginning),0) AS beginningTotal,
38693
 
             COALESCE(SUM(flrpt_ending),0) AS endingTotal,
38694
 
             COALESCE(SUM(flrpt_debits),0) AS debitsTotal,
38695
 
             COALESCE(SUM(flrpt_credits),0) AS creditsTotal,
38696
 
             COALESCE(SUM(flrpt_budget),0) AS budgetTotal,
38697
 
             COALESCE(SUM(flrpt_diff), 0) AS diffTotal,
38698
 
             COALESCE(SUM(flrpt_custom), 0) AS customTotal INTO _s
38699
 
        FROM flrpt
38700
 
       WHERE ((flrpt_flhead_id=pFlheadid)
38701
 
         AND  (flrpt_period_id=pPeriodid)
38702
 
         AND  (flrpt_interval=pInterval)
38703
 
         AND  (flrpt_type != 'T')
38704
 
         AND  (flrpt_parent_id=_t.flgrp_id));
38705
 
    ELSE
38706
 
      SELECT COALESCE(SUM(flrpt_beginning),0) AS beginningTotal,
38707
 
             COALESCE(SUM(flrpt_ending),0) AS endingTotal,
38708
 
             COALESCE(SUM(flrpt_debits),0) AS debitsTotal,
38709
 
             COALESCE(SUM(flrpt_credits),0) AS creditsTotal,
38710
 
             COALESCE(SUM(flrpt_budget),0) AS budgetTotal,
38711
 
             COALESCE(SUM(flrpt_diff), 0) AS diffTotal,
38712
 
             COALESCE(SUM(flrpt_custom), 0) AS customTotal INTO _s
38713
 
        FROM flrpt
38714
 
       WHERE ((flrpt_flhead_id=pFlheadid)
38715
 
         AND  (flrpt_period_id=pPeriodid)
38716
 
         AND  (flrpt_interval=pInterval)
38717
 
         AND  (flrpt_type = 'G')
38718
 
         AND  (flrpt_type_id=_t.flgrp_id));
38719
 
    END IF;
38720
 
 
38721
 
    UPDATE flrpt SET flrpt_beginningprcnt = flrpt_beginningprcnt + flrpt_beginning / CASE WHEN (_s.beginningTotal=0) THEN 1 ELSE _s.beginningTotal END,
38722
 
                     flrpt_endingprcnt = flrpt_endingprcnt + flrpt_ending / CASE WHEN (_s.endingTotal=0) THEN 1 ELSE _s.endingTotal END,
38723
 
                     flrpt_debitsprcnt = flrpt_debitsprcnt + flrpt_debits / CASE WHEN (_s.debitsTotal=0) THEN 1 ELSE _s.debitsTotal END,
38724
 
                     flrpt_creditsprcnt = flrpt_creditsprcnt + flrpt_credits / CASE WHEN (_s.creditsTotal=0) THEN 1 ELSE _s.creditsTotal END,
38725
 
                     flrpt_budgetprcnt = flrpt_budgetprcnt + flrpt_budget / CASE WHEN (_s.budgetTotal=0) THEN 1 ELSE _s.budgetTotal END,
38726
 
                     flrpt_diffprcnt = flrpt_diffprcnt + flrpt_diff / CASE WHEN (_s.diffTotal=0) THEN 1 ELSE _s.diffTotal END,
38727
 
                     flrpt_customprcnt = flrpt_customprcnt + flrpt_custom / CASE WHEN (_s.customTotal=0) THEN 1 ELSE _s.customTotal END
38728
 
     WHERE ((flrpt_flhead_id=pFlheadid)
38729
 
       AND  (flrpt_period_id=pPeriodid)
38730
 
       AND  (flrpt_interval=pInterval)
38731
 
       AND  (flrpt_order=_t.flrpt_order));
38732
 
  END LOOP;
38733
 
 
38734
 
 
38735
 
  FOR _t IN SELECT a.flrpt_order AS flrpt_order,
38736
 
                   b.flrpt_beginningprcnt AS flrpt_beginningprcnt,
38737
 
                   b.flrpt_endingprcnt AS flrpt_endingprcnt,
38738
 
                   b.flrpt_debitsprcnt AS flrpt_debitsprcnt,
38739
 
                   b.flrpt_creditsprcnt AS flrpt_creditsprcnt,
38740
 
                   b.flrpt_budgetprcnt AS flrpt_budgetprcnt,
38741
 
                   b.flrpt_diffprcnt AS flrpt_diffprcnt,
38742
 
                   b.flrpt_customprcnt AS flrpt_customprcnt
38743
 
              FROM flrpt AS a, flrpt AS b
38744
 
             WHERE ((a.flrpt_flhead_id=pFlheadid)
38745
 
               AND  (a.flrpt_period_id=pPeriodid)
38746
 
               AND  (a.flrpt_interval=pInterval)
38747
 
               AND  (a.flrpt_type='T')
38748
 
               AND  (b.flrpt_flhead_id=a.flrpt_flhead_id)
38749
 
               AND  (b.flrpt_period_id=a.flrpt_period_id)
38750
 
               AND  (b.flrpt_interval=pInterval)
38751
 
               AND  (b.flrpt_type='G')
38752
 
               AND  (b.flrpt_type_id=a.flrpt_parent_id)) LOOP
38753
 
    UPDATE flrpt SET flrpt_beginningprcnt=flrpt_beginningprcnt + _t.flrpt_beginningprcnt,
38754
 
                     flrpt_endingprcnt=flrpt_endingprcnt + _t.flrpt_endingprcnt,
38755
 
                     flrpt_debitsprcnt=flrpt_debitsprcnt + _t.flrpt_debitsprcnt,
38756
 
                     flrpt_creditsprcnt=flrpt_creditsprcnt + _t.flrpt_creditsprcnt,
38757
 
                     flrpt_budgetprcnt=flrpt_budgetprcnt + _t.flrpt_budgetprcnt,
38758
 
                     flrpt_diffprcnt=flrpt_diffprcnt + _t.flrpt_diffprcnt,
38759
 
                     flrpt_customprcnt=flrpt_customprcnt + _t.flrpt_customprcnt
38760
 
               WHERE ((flrpt_flhead_id=pFlheadid)
38761
 
                 AND  (flrpt_period_id=pPeriodid)
38762
 
                 AND  (flrpt_interval=pInterval)
38763
 
                 AND  (flrpt_order=_t.flrpt_order));
38764
 
  END LOOP;
38765
 
 
38766
 
  IF (_r.flhead_showtotal) THEN
38767
 
    UPDATE flrpt
38768
 
       SET flrpt_order = COALESCE((SELECT MAX(flrpt_order)
38769
 
                                     FROM flrpt
38770
 
                                    WHERE ((flrpt_flhead_id=pFlheadid)
38771
 
                                      AND  (flrpt_period_id=pPeriodid)
38772
 
                                      AND  (flrpt_interval=pInterval)
38773
 
                                    )
38774
 
                                  ), 0) + 1,
38775
 
           flrpt_level = 0,
38776
 
           flrpt_type = 'T'
38777
 
     WHERE ((flrpt_flhead_id=pFlheadid)
38778
 
       AND  (flrpt_period_id=pPeriodid)
38779
 
       AND  (flrpt_interval=pInterval)
38780
 
       AND  (flrpt_order=0)
38781
 
       AND  (flrpt_level = -1)
38782
 
       AND  (flrpt_type = 'G')
38783
 
       AND  (flrpt_type_id=-1));
38784
 
  END IF;
38785
 
 
38786
 
  return TRUE;
38787
 
END;
38788
 
$_$;
38789
 
 
38790
 
 
38791
 
ALTER FUNCTION public.financialreport(integer, integer, character, integer) OWNER TO admin;
38792
 
 
38793
 
--
38794
 
--
38795
 
 
38796
 
CREATE FUNCTION financialreport(integer, integer[], character, boolean, integer) RETURNS SETOF fltrenditem
38797
 
    LANGUAGE plpgsql
38798
 
    AS $_$
38799
 
DECLARE
38800
 
  pFlheadId ALIAS FOR $1;
38801
 
  pPeriodIds ALIAS FOR $2;
38802
 
  pInterval ALIAS FOR $3;
38803
 
  pShowNumbers ALIAS FOR $4;
38804
 
  pPrjid ALIAS FOR $5;
38805
 
  _row fltrenditem%ROWTYPE;
38806
 
  _type CHAR;
38807
 
  _p RECORD;
38808
 
  _count INTEGER;
38809
 
  _n NUMERIC;
38810
 
  _fld NUMERIC[];
38811
 
  _grndttl NUMERIC;
38812
 
  _i INTEGER;
38813
 
  _first BOOLEAN;
38814
 
  _prevlevel INTEGER;
38815
 
  _subgrp INTEGER;
38816
 
 
38817
 
BEGIN
38818
 
        _first := true;
38819
 
        _subgrp := 0;
38820
 
 
38821
 
        IF ARRAY_UPPER(pPeriodIds,1) <= 12 THEN
38822
 
                _count := ARRAY_UPPER(pPeriodIds,1);
38823
 
        ELSE
38824
 
                _count := 12;
38825
 
        END IF;
38826
 
 
38827
 
        --Get Type
38828
 
        SELECT flhead_type FROM flhead INTO _type WHERE flhead_id=pFlheadId;
38829
 
 
38830
 
        --Build Financial Data
38831
 
        FOR _i IN 1.._count
38832
 
        LOOP
38833
 
                PERFORM financialreport(pFlheadId,pPeriodIds[_i],pInterval,pPrjid);
38834
 
        END LOOP;
38835
 
 
38836
 
        --Get Row Data
38837
 
        FOR _p IN
38838
 
        SELECT flrpt_flhead_id,
38839
 
                flrpt_username,
38840
 
                flrpt_order,
38841
 
                flrpt_level,
38842
 
                flrpt_type,
38843
 
                flrpt_type_id,
38844
 
                flrpt_parent_id,
38845
 
                flrpt_accnt_id,
38846
 
                formatindent(flgrp.flgrp_name,flrpt.flrpt_level) AS flrpt_name,
38847
 
                CASE
38848
 
                        WHEN (flgrp_summarize AND (_type IN ('I','C'))) THEN
38849
 
                                (COALESCE(flrpt_diff,0))
38850
 
                        WHEN (flgrp_summarize AND (_type = 'B')) THEN
38851
 
                                (COALESCE(flrpt_ending,0))
38852
 
                        ELSE NULL
38853
 
                END AS f_fld1,
38854
 
                flgrp_summarize AS display
38855
 
        FROM flrpt,flgrp
38856
 
        WHERE ((flrpt_flhead_id=pFlheadId)
38857
 
        AND (flgrp_id=flrpt_type_id)
38858
 
        AND (flrpt_type='G')
38859
 
        AND (flrpt_period_id=pPeriodIds[1])
38860
 
        AND (flrpt_interval=pInterval)
38861
 
        )
38862
 
        UNION
38863
 
        SELECT flrpt_flhead_id,
38864
 
                flrpt_username,
38865
 
                flrpt_order,
38866
 
                flrpt_level,
38867
 
                flrpt_type,
38868
 
                flrpt_type_id,
38869
 
                flrpt_parent_id,
38870
 
                flrpt_accnt_id,
38871
 
                formatindent(accnt_descrip,flrpt.flrpt_level) AS flrpt_name,
38872
 
                CASE
38873
 
                        WHEN (_type IN ('I','C')) THEN
38874
 
                                (COALESCE(flrpt_diff,0))
38875
 
                        WHEN (_type = 'B') THEN
38876
 
                                (COALESCE(flrpt_ending,0))
38877
 
                        ELSE NULL
38878
 
                END AS f_fld1,
38879
 
                true AS display
38880
 
        FROM flrpt,flitem,accnt
38881
 
        WHERE ((flrpt_flhead_id=pFlheadId)
38882
 
        AND (flrpt_accnt_id=accnt_id)
38883
 
        AND (flitem_id=flrpt_type_id)
38884
 
        AND (flrpt_type='I')
38885
 
        AND (flrpt_period_id=pPeriodIds[1])
38886
 
        AND (flrpt_interval=pInterval)
38887
 
        )
38888
 
        UNION
38889
 
        SELECT flrpt_flhead_id,
38890
 
                flrpt_username,
38891
 
                flrpt_order,
38892
 
                flrpt_level,
38893
 
                flrpt_type,
38894
 
                flrpt_type_id,
38895
 
                flrpt_parent_id,
38896
 
                flrpt_accnt_id,
38897
 
                CASE
38898
 
                        WHEN (flrpt.flrpt_type='T' AND flrpt.flrpt_level=0) THEN
38899
 
                                COALESCE(flrpt.flrpt_altname, 'Total')
38900
 
                        WHEN (flrpt.flrpt_type='T') THEN
38901
 
                                formatindent(COALESCE(flrpt.flrpt_altname, 'Subtotal') ,flrpt.flrpt_level) 
38902
 
 
38903
 
                        ELSE
38904
 
                                formatindent(('Type ' || flrpt.flrpt_type || ' ' || text(flrpt.flrpt_type_id)), flrpt.flrpt_level)
38905
 
                END AS flstmtitem_name,
38906
 
                CASE
38907
 
                        WHEN (_type IN ('I','C')) THEN
38908
 
                                (COALESCE(flrpt_diff,0))
38909
 
                        WHEN (_type = 'B') THEN
38910
 
                                (COALESCE(flrpt_ending,0))
38911
 
                        ELSE NULL
38912
 
                END AS f_fld1,
38913
 
                true AS display
38914
 
        FROM flrpt
38915
 
        WHERE ((flrpt_flhead_id=pFlheadId)
38916
 
        AND (flrpt_type NOT IN ('I','S','G'))
38917
 
        AND (flrpt_period_id=pPeriodIds[1])
38918
 
        AND (flrpt_interval=pInterval)
38919
 
        )
38920
 
        ORDER BY flrpt_order
38921
 
        LOOP
38922
 
 
38923
 
                IF _type IN ('I','C') THEN
38924
 
                        _grndttl := _p.f_fld1;
38925
 
                END IF;
38926
 
 
38927
 
                --Loop through and calculate period column values
38928
 
                IF (_p.display) THEN
38929
 
                        FOR _i IN 2.._count
38930
 
                        LOOP
38931
 
                                SELECT
38932
 
                                CASE
38933
 
                                        WHEN (_type IN ('I','C')) THEN
38934
 
                                                COALESCE(flrpt_diff,0)
38935
 
                                        WHEN (_type = 'B') THEN
38936
 
                                                COALESCE(flrpt_ending,0)
38937
 
                                        ELSE NULL
38938
 
                                END INTO _n
38939
 
                                FROM flrpt
38940
 
                                WHERE ((flrpt_flhead_id=pFlheadId)
38941
 
                                AND (flrpt_period_id=pPeriodIds[_i])
38942
 
                                AND (flrpt_interval=pInterval)
38943
 
                                AND (flrpt_order=_p.flrpt_order));
38944
 
                                _fld[_i-1] := _n;
38945
 
                                IF _type IN ('I','C') THEN
38946
 
                                        _grndttl := _grndttl+_n;
38947
 
                                END IF;
38948
 
                        END LOOP;
38949
 
                END IF;
38950
 
 
38951
 
                --Send it all back to the caller
38952
 
                IF _prevlevel > _p.flrpt_level THEN
38953
 
                        _subgrp := _subgrp+1;
38954
 
                END IF;
38955
 
                _prevlevel:=_p.flrpt_level;
38956
 
                _row.fltrenditem_subgrp := _subgrp;
38957
 
 
38958
 
                IF NOT _first THEN
38959
 
                        RETURN NEXT _row;
38960
 
                END IF;
38961
 
 
38962
 
                _first := FALSE;
38963
 
 
38964
 
                _row.fltrenditem_flhead_id := _p.flrpt_flhead_id;
38965
 
                _row.fltrenditem_username := _p.flrpt_username;
38966
 
                _row.fltrenditem_order := _p.flrpt_order;
38967
 
                _row.fltrenditem_level := _p.flrpt_level;
38968
 
                _row.fltrenditem_type := _p.flrpt_type;
38969
 
                _row.fltrenditem_type_id := _p.flrpt_type_id;
38970
 
                _row.fltrenditem_parent_id := _p.flrpt_parent_id;
38971
 
                _row.fltrenditem_accnt_id := _p.flrpt_accnt_id;
38972
 
                _row.fltrenditem_name := _p.flrpt_name;
38973
 
                IF (_p.display) THEN
38974
 
                        _row.fltrenditem_fld1 := (_p.f_fld1);
38975
 
                        _row.fltrenditem_fld2 := (_fld[1]);
38976
 
                        _row.fltrenditem_fld3 := (_fld[2]);
38977
 
                        _row.fltrenditem_fld4 := (_fld[3]);
38978
 
                        _row.fltrenditem_fld5 := (_fld[4]);
38979
 
                        _row.fltrenditem_fld6 := (_fld[5]);
38980
 
                        _row.fltrenditem_fld7 := (_fld[6]);
38981
 
                        _row.fltrenditem_fld8 := (_fld[7]);
38982
 
                        _row.fltrenditem_fld9 := (_fld[8]);
38983
 
                        _row.fltrenditem_fld10 := (_fld[9]);
38984
 
                        _row.fltrenditem_fld11 := (_fld[10]);
38985
 
                        _row.fltrenditem_fld12 := (_fld[11]);
38986
 
                        _row.fltrenditem_grndttl := (_grndttl);
38987
 
                ELSE
38988
 
                        _row.fltrenditem_fld1 := NULL;
38989
 
                        _row.fltrenditem_fld2 := NULL;
38990
 
                        _row.fltrenditem_fld3 := NULL;
38991
 
                        _row.fltrenditem_fld4 := NULL;
38992
 
                        _row.fltrenditem_fld5 := NULL;
38993
 
                        _row.fltrenditem_fld6 := NULL;
38994
 
                        _row.fltrenditem_fld7 := NULL;
38995
 
                        _row.fltrenditem_fld8 := NULL;
38996
 
                        _row.fltrenditem_fld9 := NULL;
38997
 
                        _row.fltrenditem_fld10 := NULL;
38998
 
                        _row.fltrenditem_fld11 := NULL;
38999
 
                        _row.fltrenditem_fld12 := NULL;
39000
 
                        _row.fltrenditem_grndttl := NULL;
39001
 
                END IF;
39002
 
 
39003
 
        END LOOP;
39004
 
 
39005
 
        _row.fltrenditem_subgrp := _subgrp + 1;
39006
 
        RETURN NEXT _row;
39007
 
 
39008
 
END;
39009
 
$_$;
39010
 
 
39011
 
 
39012
 
ALTER FUNCTION public.financialreport(integer, integer[], character, boolean, integer) OWNER TO admin;
39013
 
 
39014
 
--
39015
 
--
39016
 
 
39017
 
CREATE FUNCTION financialreport(integer, integer, boolean, boolean, integer) RETURNS SETOF flstmtitem
39018
 
    LANGUAGE plpgsql
39019
 
    AS $_$
39020
 
DECLARE
39021
 
  pFlcolid ALIAS FOR $1;
39022
 
  pPeriodid ALIAS FOR $2;
39023
 
  pShowNumbers ALIAS FOR $3;
39024
 
  pIndentName ALIAS FOR $4;
39025
 
  pPrjid ALIAS FOR $5;
39026
 
  _row flstmtitem%ROWTYPE;
39027
 
  _p RECORD;
39028
 
  _x RECORD;
39029
 
  _priorMoPeriodId INTEGER;
39030
 
  _priorQtPeriodId INTEGER;
39031
 
  _priorYrPeriodId INTEGER;
39032
 
  _first BOOLEAN;
39033
 
  _prevlevel INTEGER;
39034
 
  _subgrp INTEGER;
39035
 
  _qtrInterval TEXT;
39036
 
--_username TEXT := getEffectiveXtUser();
39037
 
  _yrInterval TEXT;
39038
 
 
39039
 
BEGIN
39040
 
 
39041
 
  _priorMoPeriodId := -1;
39042
 
  _priorQtPeriodId := -1;
39043
 
  _priorYrPeriodId := -1;
39044
 
  _first := TRUE;
39045
 
  _prevlevel :=0;
39046
 
  _subgrp := 0;
39047
 
 
39048
 
--Get Layout Data
39049
 
  SELECT flhead_id,flhead_type,
39050
 
        flcol_month,flcol_quarter,flcol_year,flcol_priortype,
39051
 
        flcol_priormonth,flcol_priorquarter,flcol_prioryear,
39052
 
        flcol_priordiff,flcol_priordiffprcnt,flcol_priorprcnt,
39053
 
        flcol_budget,flcol_budgetdiff,flcol_budgetdiffprcnt,
39054
 
        flcol_budgetprcnt INTO _p
39055
 
  FROM flhead,flcol
39056
 
  WHERE ((flcol_id=pFlcolid)
39057
 
  AND (flhead_id=flcol_flhead_id));
39058
 
 
39059
 
  IF (_p.flhead_type='B') THEN
39060
 
    _qtrInterval := 'M';
39061
 
    _yrInterval := 'M';
39062
 
  ELSE
39063
 
    _qtrInterval := 'Q';
39064
 
    _yrInterval := 'Y';
39065
 
  END IF;
39066
 
 
39067
 
  CREATE TEMPORARY TABLE IF NOT EXISTS flrpt
39068
 
    (LIKE public.flrpt INCLUDING ALL)
39069
 
    ON COMMIT PRESERVE ROWS;
39070
 
 
39071
 
  -- clear even temp tables because every run builds on data upserted by itself
39072
 
  DELETE FROM flrpt
39073
 
  WHERE (flrpt_flhead_id=_p.flhead_id);
39074
 
 
39075
 
--Populate report data...
39076
 
--...for Month
39077
 
      IF (_p.flcol_month) THEN
39078
 
 
39079
 
        PERFORM financialreport(_p.flhead_id,pPeriodid,'M',pPrjid);
39080
 
 
39081
 
                IF ((_p.flcol_priortype = 'P') AND (_p.flcol_priormonth)) THEN
39082
 
 
39083
 
                        SELECT COALESCE(pp.period_id,-1) INTO _priorMoPeriodId
39084
 
                        FROM period cp, period pp
39085
 
                        WHERE ((cp.period_id=pPeriodId)
39086
 
                        AND (cp.period_start > pp.period_start))
39087
 
                        ORDER BY pp.period_start DESC LIMIT 1;
39088
 
 
39089
 
                        IF (_priorMoPeriodId IS NOT NULL) THEN
39090
 
                                PERFORM financialreport(_p.flhead_id,_priorMoPeriodId,'M',pPrjid);
39091
 
                        END IF;
39092
 
 
39093
 
                        ELSE IF ((_p.flcol_priortype='Y')AND (_p.flcol_priormonth)) THEN
39094
 
 
39095
 
                                SELECT COALESCE(pp.period_id,-1) INTO _priorMoPeriodId
39096
 
                                FROM period cp, period pp
39097
 
                                WHERE ((cp.period_id=pPeriodId)
39098
 
                                AND (cp.period_id != pp.period_id)
39099
 
                                AND (cp.period_start > pp.period_start)
39100
 
                                AND (cp.period_number = pp.period_number))
39101
 
                                ORDER BY pp.period_start DESC LIMIT 1;
39102
 
 
39103
 
                                IF (_priorMoPeriodId IS NOT NULL) THEN
39104
 
                                        PERFORM financialreport(_p.flhead_id,_priorMoPeriodId,'M',pPrjid);
39105
 
                                END IF;
39106
 
 
39107
 
                        END IF;
39108
 
 
39109
 
                END IF;
39110
 
        END IF;
39111
 
 
39112
 
--...for Quarter
39113
 
        IF (_p.flcol_quarter) THEN
39114
 
 
39115
 
        PERFORM financialreport(_p.flhead_id,pPeriodid,'Q',pPrjid);
39116
 
 
39117
 
        END IF;
39118
 
 
39119
 
        IF ((_p.flcol_priortype='P') AND (_p.flcol_priorquarter)) THEN
39120
 
 
39121
 
                SELECT COALESCE(pp.period_id,-1) INTO _priorQtPeriodId
39122
 
                FROM period cp, period pp
39123
 
                WHERE ((cp.period_id=pPeriodId)
39124
 
                AND (cp.period_start > pp.period_start)
39125
 
                AND (pp.period_quarter=
39126
 
                        CASE WHEN cp.period_quarter > 1 THEN
39127
 
                                cp.period_quarter - 1
39128
 
                        ELSE 4 END)
39129
 
                AND (pp.period_start >= cp.period_start - interval '1 year'))
39130
 
                ORDER BY pp.period_start DESC LIMIT 1;
39131
 
 
39132
 
                IF (_priorQtPeriodId IS NOT NULL) THEN
39133
 
                        PERFORM financialreport(_p.flhead_id,_priorQtPeriodId,'Q',pPrjid);
39134
 
                END IF;
39135
 
 
39136
 
                ELSE IF ((_p.flcol_priortype='Y')AND (_p.flcol_priorquarter)) THEN
39137
 
 
39138
 
                        SELECT pp.period_id INTO _priorQtPeriodId
39139
 
                        FROM period cp, period pp, yearperiod cy, yearperiod py
39140
 
                        WHERE ((cp.period_id=pPeriodId)
39141
 
                        AND (cp.period_yearperiod_id=cy.yearperiod_id)
39142
 
                        AND (pp.period_yearperiod_id=py.yearperiod_id)
39143
 
                        AND (cp.period_quarter=pp.period_quarter)
39144
 
                        AND (cy.yearperiod_start > py.yearperiod_start))
39145
 
                        ORDER BY py.yearperiod_start DESC, pp.period_start DESC LIMIT 1;
39146
 
 
39147
 
                        IF (_priorQtPeriodId IS NOT NULL) THEN
39148
 
                                PERFORM financialreport(_p.flhead_id,_priorQtPeriodId,'Q',pPrjid);
39149
 
                        END IF;
39150
 
 
39151
 
                END IF;
39152
 
        END IF;
39153
 
 
39154
 
--...for Year
39155
 
        IF (_p.flcol_year) THEN
39156
 
 
39157
 
                PERFORM financialreport(_p.flhead_id,pPeriodid,'Y',pPrjid);
39158
 
 
39159
 
        END IF;
39160
 
 
39161
 
        IF (_p.flcol_prioryear='D') THEN
39162
 
 
39163
 
                SELECT COALESCE(pp.period_id,-1) INTO _priorYrPeriodId
39164
 
                FROM period cp, period pp
39165
 
                WHERE ((cp.period_id = pPeriodId)
39166
 
                AND (cp.period_number = pp.period_number)
39167
 
                AND (cp.period_start > pp.period_start))
39168
 
                ORDER BY pp.period_start DESC LIMIT 1;
39169
 
 
39170
 
                IF (_priorYrPeriodId IS NOT NULL) THEN
39171
 
                        PERFORM financialreport(_p.flhead_id,_priorYrPeriodId,'Y',pPrjid);
39172
 
                END IF;
39173
 
 
39174
 
                ELSE IF (_p.flcol_prioryear='F') THEN
39175
 
 
39176
 
                        SELECT pp.period_id INTO _priorYrPeriodId
39177
 
                        FROM period cp, period pp, yearperiod cy, yearperiod py
39178
 
                        WHERE ((cp.period_id=pPeriodId)
39179
 
                        AND (cp.period_yearperiod_id=cy.yearperiod_id)
39180
 
                        AND (pp.period_yearperiod_id=py.yearperiod_id)
39181
 
                        AND (cy.yearperiod_start > py.yearperiod_start))
39182
 
                        ORDER BY pp.period_start DESC LIMIT 1;
39183
 
 
39184
 
                        IF (_priorYrPeriodId IS NOT NULL) THEN
39185
 
                                PERFORM financialreport(_p.flhead_id,_priorYrPeriodId,'Y',pPrjid);
39186
 
                        END IF;
39187
 
 
39188
 
                END IF;
39189
 
        END IF;
39190
 
 
39191
 
--Return the data
39192
 
  FOR _x IN
39193
 
        SELECT
39194
 
        flrpt.flrpt_flhead_id AS flstmtitem_flhead_id,
39195
 
        flrpt.flrpt_period_id AS flstmtitem_period_id,
39196
 
        flrpt.flrpt_username AS flstmtitem_username,
39197
 
        flrpt.flrpt_order AS flstmtitem_order,
39198
 
        flrpt.flrpt_level AS flstmtitem_level,
39199
 
        flrpt.flrpt_type AS flstmtitem_type,
39200
 
        flrpt.flrpt_type_id AS flstmtitem_type_id,
39201
 
        flrpt.flrpt_parent_id AS flstmtitem_parent_id,
39202
 
        NULL AS flstmtitem_accnt_id,
39203
 
        CASE
39204
 
                WHEN (pIndentName) THEN
39205
 
                        formatindent(flgrp.flgrp_name,flrpt.flrpt_level)
39206
 
                ELSE flgrp.flgrp_name
39207
 
        END AS flstmtitem_name,
39208
 
        CASE
39209
 
                WHEN (flgrp_summarize AND (flhead_type IN ('I','C'))) THEN
39210
 
                        (COALESCE(flrptmo.flrpt_diff,0))
39211
 
                WHEN (flgrp_summarize AND (flhead_type = 'B')) THEN
39212
 
                        (COALESCE(flrptmo.flrpt_ending,0))
39213
 
                ELSE NULL
39214
 
        END AS flstmtitem_month,
39215
 
        CASE
39216
 
                WHEN (flgrp_summarize) THEN
39217
 
                        (COALESCE(flrptmo.flrpt_debits,0))
39218
 
                ELSE NULL
39219
 
        END AS flstmtitem_monthdb,
39220
 
        CASE
39221
 
                WHEN (flgrp_summarize) THEN
39222
 
                        (COALESCE(flrptmo.flrpt_credits,0))
39223
 
                ELSE NULL
39224
 
        END AS flstmtitem_monthcr,
39225
 
        CASE
39226
 
                WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN
39227
 
                        (COALESCE(flrptmo.flrpt_diffprcnt,0))
39228
 
                WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN
39229
 
                        (COALESCE(flrptmo.flrpt_endingprcnt,0))
39230
 
                ELSE NULL
39231
 
        END AS flstmtitem_monthprcnt,
39232
 
        CASE
39233
 
                WHEN (flgrp_summarize) THEN
39234
 
                        (flrptmo.flrpt_budget)
39235
 
                ELSE NULL
39236
 
        END AS flstmtitem_monthbudget,
39237
 
        CASE
39238
 
                WHEN (flgrp_summarize) THEN
39239
 
                        (flrptmo.flrpt_budgetprcnt)
39240
 
                ELSE NULL
39241
 
        END AS flstmtitem_monthbudgetprcnt,
39242
 
        CASE
39243
 
                WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN
39244
 
                        (COALESCE((flrptmo.flrpt_diff-flrptmo.flrpt_budget),0))
39245
 
                WHEN (flgrp_summarize AND flhead_type = 'B') THEN
39246
 
                        (COALESCE((flrptmo.flrpt_ending-flrptmo.flrpt_budget),0))
39247
 
                ELSE NULL
39248
 
        END AS flstmtitem_monthbudgetdiff,
39249
 
        CASE
39250
 
                WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptmo.flrpt_budget > 0)) THEN
39251
 
                        (COALESCE(((flrptmo.flrpt_diff-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0))
39252
 
                WHEN (flgrp_summarize AND (flhead_type='B') AND (flrptmo.flrpt_budget > 0)) THEN
39253
 
                        (COALESCE(((flrptmo.flrpt_ending-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0))
39254
 
                WHEN (flgrp_summarize AND (flrptmo.flrpt_budget = 0)) THEN
39255
 
                        NULL
39256
 
                ELSE NULL
39257
 
        END AS flstmtitem_monthbudgetdiffprcnt,
39258
 
        CASE
39259
 
                WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN
39260
 
                        (COALESCE(flrptqt.flrpt_diff,0))
39261
 
                WHEN (flgrp_summarize AND flhead_type = 'B') THEN
39262
 
                        (COALESCE(flrptqt.flrpt_ending,0))
39263
 
                ELSE NULL
39264
 
        END AS flstmtitem_qtr,
39265
 
        CASE
39266
 
                WHEN (flgrp_summarize) THEN
39267
 
                        (COALESCE(flrptqt.flrpt_debits,0))
39268
 
                ELSE NULL
39269
 
        END AS flstmtitem_qtrdb,
39270
 
        CASE
39271
 
                WHEN (flgrp_summarize) THEN
39272
 
                        (COALESCE(flrptqt.flrpt_credits,0))
39273
 
                ELSE NULL
39274
 
        END AS flstmtitem_qtrcr,
39275
 
        CASE
39276
 
                WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN
39277
 
                        (flrptqt.flrpt_diffprcnt)
39278
 
                WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN
39279
 
                        (flrptqt.flrpt_endingprcnt)
39280
 
                ELSE NULL
39281
 
        END AS flstmtitem_qtrprcnt,
39282
 
        CASE
39283
 
                WHEN (flgrp_summarize) THEN
39284
 
                        (COALESCE(flrptqt.flrpt_budget,0))
39285
 
                ELSE NULL
39286
 
        END AS flstmtitem_qtrbudget,
39287
 
        CASE
39288
 
                WHEN (flgrp_summarize) THEN
39289
 
                        (flrptqt.flrpt_budgetprcnt)
39290
 
                ELSE NULL
39291
 
        END AS flstmtitem_qtrbudgetprcnt,
39292
 
        CASE
39293
 
                WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN
39294
 
                        (COALESCE((flrptqt.flrpt_diff-flrptqt.flrpt_budget),0))
39295
 
                WHEN (flgrp_summarize AND flhead_type = 'B') THEN
39296
 
                        (COALESCE((flrptqt.flrpt_ending-flrptqt.flrpt_budget),0))
39297
 
                ELSE NULL
39298
 
        END AS flstmtitem_qtrbudgetdiff,
39299
 
        CASE
39300
 
                WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptqt.flrpt_budget > 0)) THEN
39301
 
                        (COALESCE(((flrptqt.flrpt_diff-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0))
39302
 
                WHEN (flgrp_summarize AND (flhead_type='B') AND (flrptqt.flrpt_budget > 0)) THEN
39303
 
                        (COALESCE(((flrptqt.flrpt_ending-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0))
39304
 
                ELSE NULL
39305
 
        END AS flstmtitem_qtrbudgetdiffprcnt,
39306
 
        CASE
39307
 
                WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN
39308
 
                        (COALESCE(flrptyr.flrpt_diff,0))
39309
 
                WHEN (flgrp_summarize AND flhead_type = 'B') THEN
39310
 
                        (COALESCE(flrptyr.flrpt_ending,0))
39311
 
                ELSE NULL
39312
 
        END AS flstmtitem_year,
39313
 
        CASE
39314
 
                WHEN (flgrp_summarize) THEN
39315
 
                        (COALESCE(flrptyr.flrpt_debits,0))
39316
 
                ELSE NULL
39317
 
        END AS flstmtitem_yeardb,
39318
 
        CASE
39319
 
                WHEN (flgrp_summarize) THEN
39320
 
                        (COALESCE(flrptyr.flrpt_credits,0))
39321
 
                ELSE NULL
39322
 
        END AS flstmtitem_yearcr,
39323
 
        CASE
39324
 
                WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN
39325
 
                        (COALESCE(flrptyr.flrpt_diffprcnt,0))
39326
 
                WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN
39327
 
                        (COALESCE(flrptyr.flrpt_endingprcnt,0))
39328
 
                ELSE NULL
39329
 
        END AS flstmtitem_yearprcnt,
39330
 
        CASE
39331
 
                WHEN (flgrp_summarize) THEN
39332
 
                        (flrptyr.flrpt_budget)
39333
 
                ELSE NULL
39334
 
        END AS  flstmtitem_yearbudget,
39335
 
        CASE
39336
 
                WHEN (flgrp_summarize) THEN
39337
 
                        (flrptyr.flrpt_budgetprcnt)
39338
 
                ELSE NULL
39339
 
        END AS flstmtitem_yearbudgetprcnt,
39340
 
        CASE
39341
 
                WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN
39342
 
                        (COALESCE((flrptyr.flrpt_diff-flrptyr.flrpt_budget),0))
39343
 
                WHEN (flgrp_summarize AND flhead_type = 'B') THEN
39344
 
                        (COALESCE((flrptyr.flrpt_ending-flrptyr.flrpt_budget),0))
39345
 
                ELSE NULL
39346
 
        END AS flstmtitem_yearbudgetdiff,
39347
 
        CASE
39348
 
                WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptyr.flrpt_budget > 0)) THEN
39349
 
                        (COALESCE(((flrptyr.flrpt_diff-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0))
39350
 
                WHEN (flgrp_summarize AND (flhead_type = 'B') AND (flrptyr.flrpt_budget > 0)) THEN
39351
 
                        (COALESCE(((flrptyr.flrpt_ending-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0))
39352
 
                WHEN (flgrp_summarize AND (flrptyr.flrpt_budget = 0)) THEN
39353
 
                        NULL
39354
 
                ELSE NULL
39355
 
        END AS flstmtitem_yearbudgetdiffprcnt,
39356
 
        CASE
39357
 
                WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN
39358
 
                        (COALESCE(flrptprmo.flrpt_diff,0))
39359
 
                WHEN (flgrp_summarize AND flhead_type = 'B') THEN
39360
 
                        (COALESCE(flrptprmo.flrpt_ending,0))
39361
 
                ELSE NULL
39362
 
        END AS flstmtitem_prmonth,
39363
 
        CASE
39364
 
                WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN
39365
 
                        (flrptprmo.flrpt_diffprcnt)
39366
 
                WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN
39367
 
                        (flrptprmo.flrpt_endingprcnt)
39368
 
                ELSE NULL
39369
 
        END AS flstmtitem_prmonthprcnt,
39370
 
        CASE
39371
 
                WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN
39372
 
                        (COALESCE(flrptmo.flrpt_diff-flrptprmo.flrpt_diff,0))
39373
 
                WHEN (flgrp_summarize AND flhead_type = 'B') THEN
39374
 
                        (COALESCE(flrptmo.flrpt_ending-flrptprmo.flrpt_ending,0))
39375
 
                ELSE NULL
39376
 
        END AS flstmtitem_prmonthdiff,
39377
 
        CASE
39378
 
                WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptprmo.flrpt_diff > 0)) THEN
39379
 
                        (COALESCE((flrptmo.flrpt_diff-flrptprmo.flrpt_diff)/flrptprmo.flrpt_diff,0))
39380
 
                WHEN (flgrp_summarize AND (flhead_type = 'B') AND (flrptprmo.flrpt_ending > 0)) THEN
39381
 
                        (COALESCE((flrptmo.flrpt_ending-flrptprmo.flrpt_ending)/flrptprmo.flrpt_ending,0))
39382
 
                WHEN (flgrp_summarize AND (flrptprmo.flrpt_ending = 0)) THEN
39383
 
                        NULL
39384
 
                ELSE NULL
39385
 
        END AS flstmtitem_prmonthdiffprcnt,
39386
 
        CASE
39387
 
                WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN
39388
 
                        (COALESCE(flrptprqt.flrpt_diff,0))
39389
 
                WHEN (flgrp_summarize AND flhead_type = 'B') THEN
39390
 
                        (COALESCE(flrptprqt.flrpt_ending,0))
39391
 
                ELSE NULL
39392
 
        END AS flstmtitem_prqtr,
39393
 
        CASE
39394
 
                WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN
39395
 
                        (flrptprqt.flrpt_diffprcnt)
39396
 
                WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN
39397
 
                        (flrptprqt.flrpt_endingprcnt)
39398
 
                ELSE NULL
39399
 
        END AS flstmtitem_prqtrprcnt,
39400
 
        CASE
39401
 
                WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN
39402
 
                        (COALESCE(flrptqt.flrpt_diff-flrptprqt.flrpt_diff,0))
39403
 
                WHEN (flgrp_summarize AND flhead_type = 'B') THEN
39404
 
                        (COALESCE(flrptqt.flrpt_ending-flrptprqt.flrpt_ending,0))
39405
 
                ELSE NULL
39406
 
        END AS flstmtitem_prqtrdiff,
39407
 
        CASE
39408
 
                WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptprqt.flrpt_diff > 0)) THEN
39409
 
                        (COALESCE((flrptqt.flrpt_diff-flrptprqt.flrpt_diff)/flrptprqt.flrpt_diff,0))
39410
 
                WHEN (flgrp_summarize AND (flhead_type = 'B') AND (flrptprqt.flrpt_ending > 0)) THEN
39411
 
                        (COALESCE((flrptqt.flrpt_ending-flrptprqt.flrpt_ending)/flrptprqt.flrpt_ending,0))
39412
 
                WHEN (flgrp_summarize AND (flrptprqt.flrpt_ending = 0)) THEN
39413
 
                        NULL
39414
 
                ELSE NULL
39415
 
        END AS flstmtitem_prqtrdiffprcnt,
39416
 
        CASE
39417
 
                WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN
39418
 
                        (COALESCE(flrptpryr.flrpt_diff,0))
39419
 
                WHEN (flgrp_summarize AND flhead_type = 'B') THEN
39420
 
                        (COALESCE(flrptpryr.flrpt_ending,0))
39421
 
                ELSE NULL
39422
 
        END AS flstmtitem_pryear,
39423
 
        CASE
39424
 
                WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN
39425
 
                        (flrptpryr.flrpt_diffprcnt)
39426
 
                WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN
39427
 
                        (flrptpryr.flrpt_endingprcnt)
39428
 
                ELSE NULL
39429
 
        END AS flstmtitem_pryearprcnt,
39430
 
        CASE
39431
 
                WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN
39432
 
                        (COALESCE(flrptyr.flrpt_diff-flrptpryr.flrpt_diff,0))
39433
 
                WHEN (flgrp_summarize AND flhead_type = 'B') THEN
39434
 
                        (COALESCE(flrptyr.flrpt_ending-flrptpryr.flrpt_ending,0))
39435
 
                ELSE NULL
39436
 
        END AS flstmtitem_pryeardiff,
39437
 
        CASE
39438
 
                WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptpryr.flrpt_diff > 0)) THEN
39439
 
                        (COALESCE((flrptyr.flrpt_diff-flrptpryr.flrpt_diff)/flrptpryr.flrpt_diff,0))
39440
 
                WHEN (flgrp_summarize AND (flhead_type = 'B' ) AND (flrptpryr.flrpt_ending > 0)) THEN
39441
 
                        (COALESCE((flrptyr.flrpt_ending-flrptpryr.flrpt_ending)/flrptpryr.flrpt_ending,0))
39442
 
                WHEN (flgrp_summarize AND (flrptpryr.flrpt_ending = 0)) THEN
39443
 
                        NULL
39444
 
                ELSE NULL
39445
 
        END AS flstmtitem_pryeardiffprcnt
39446
 
        FROM flgrp,flhead,
39447
 
                (SELECT DISTINCT
39448
 
                        flrpt_flhead_id,
39449
 
                        flrpt_period_id,
39450
 
                        flrpt_username,
39451
 
                        flrpt_order,
39452
 
                        flrpt_level,
39453
 
                        flrpt_type,
39454
 
                        flrpt_type_id,
39455
 
                        flrpt_parent_id
39456
 
                FROM flrpt
39457
 
                WHERE ((flrpt_type='G')
39458
 
                AND (flrpt_flhead_id=_p.flhead_id)
39459
 
                AND (flrpt_period_id=pPeriodId)
39460
 
                )) AS flrpt
39461
 
                        LEFT OUTER JOIN flrpt flrptmo
39462
 
                                ON ((flrptmo.flrpt_type=flrpt.flrpt_type)
39463
 
                                AND (flrptmo.flrpt_type_id=flrpt.flrpt_type_id)
39464
 
                                AND (flrptmo.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39465
 
                                AND (flrptmo.flrpt_period_id=flrpt.flrpt_period_id)
39466
 
                                AND (flrptmo.flrpt_interval='M')
39467
 
                                AND (flrptmo.flrpt_order=flrpt.flrpt_order))
39468
 
                        LEFT OUTER JOIN flrpt flrptqt
39469
 
                                ON ((flrptqt.flrpt_type=flrpt.flrpt_type)
39470
 
                                AND (flrptqt.flrpt_type_id=flrpt.flrpt_type_id)
39471
 
                                AND (flrptqt.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39472
 
                                AND (flrptqt.flrpt_period_id=flrpt.flrpt_period_id)
39473
 
                                AND (flrptqt.flrpt_interval=_qtrInterval)
39474
 
                                AND (flrptqt.flrpt_order=flrpt.flrpt_order))
39475
 
                        LEFT OUTER JOIN flrpt flrptyr
39476
 
                                ON ((flrptyr.flrpt_type=flrpt.flrpt_type)
39477
 
                                AND (flrptyr.flrpt_type_id=flrpt.flrpt_type_id)
39478
 
                                AND (flrptyr.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39479
 
                                AND (flrptyr.flrpt_period_id=flrpt.flrpt_period_id)
39480
 
                                AND (flrptyr.flrpt_interval=_yrInterval)
39481
 
                                AND (flrptyr.flrpt_order=flrpt.flrpt_order))
39482
 
                        LEFT OUTER JOIN flrpt flrptprmo
39483
 
                                ON ((flrptprmo.flrpt_type=flrpt.flrpt_type)
39484
 
                                AND (flrptprmo.flrpt_type_id=flrpt.flrpt_type_id)
39485
 
                                AND (flrptprmo.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39486
 
                                AND (flrptprmo.flrpt_period_id=_priorMoPeriodId)
39487
 
                                AND (flrptprmo.flrpt_interval='M')
39488
 
                                AND (flrptprmo.flrpt_order=flrpt.flrpt_order))
39489
 
                        LEFT OUTER JOIN flrpt flrptprqt
39490
 
                                ON ((flrptprqt.flrpt_type=flrpt.flrpt_type)
39491
 
                                AND (flrptprqt.flrpt_type_id=flrpt.flrpt_type_id)
39492
 
                                AND (flrptprqt.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39493
 
                                AND (flrptprqt.flrpt_period_id=_priorQtPeriodId)
39494
 
                                AND (flrptprqt.flrpt_interval='Q')
39495
 
                                AND (flrptprqt.flrpt_order=flrpt.flrpt_order))
39496
 
                        LEFT OUTER JOIN flrpt flrptpryr
39497
 
                                ON ((flrptpryr.flrpt_type=flrpt.flrpt_type)
39498
 
                                AND (flrptpryr.flrpt_type_id=flrpt.flrpt_type_id)
39499
 
                                AND (flrptpryr.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39500
 
                                AND (flrptpryr.flrpt_period_id=_priorYrPeriodId)
39501
 
                                AND (flrptpryr.flrpt_interval='Y')
39502
 
                                AND (flrptpryr.flrpt_order=flrpt.flrpt_order))
39503
 
        WHERE ((flgrp_id = flrpt.flrpt_type_id)
39504
 
        AND (flhead_id = flgrp_flhead_id))
39505
 
        UNION
39506
 
        SELECT
39507
 
        flrpt.flrpt_flhead_id AS flstmtitem_flhead_id,
39508
 
        flrpt.flrpt_period_id AS flstmtitem_period_id,
39509
 
        flrpt.flrpt_username AS flstmtitem_username,
39510
 
        flrpt.flrpt_order AS flstmtitem_order,
39511
 
        flrpt.flrpt_level AS flstmtitem_level,
39512
 
        flrpt.flrpt_type AS flstmtitem_type,
39513
 
        flrpt.flrpt_type_id AS flstmtitem_type_id,
39514
 
        flrpt.flrpt_parent_id AS flstmtitem_parent_id,
39515
 
        flrpt.flrpt_accnt_id AS flstmtitem_accnt_id,
39516
 
        CASE
39517
 
                WHEN (pIndentName) THEN
39518
 
                        formatindent(flrpt.flrpt_name,flrpt.flrpt_level)
39519
 
                ELSE flrpt.flrpt_name
39520
 
        END AS flstmtitem_name,
39521
 
        CASE
39522
 
                WHEN (flhead_type IN ('I','C')) THEN
39523
 
                        (COALESCE(flrptmo.flrpt_diff,0))
39524
 
                ELSE (COALESCE(flrptmo.flrpt_ending,0))
39525
 
        END AS flstmtitem_month,
39526
 
        (COALESCE(flrptmo.flrpt_debits,0)) AS flstmtitem_monthdb,
39527
 
        (COALESCE(flrptmo.flrpt_credits,0)) AS flstmtitem_monthcr,
39528
 
        CASE
39529
 
                WHEN (flitem_showdiffprcnt) THEN
39530
 
                        (flrptmo.flrpt_diffprcnt)
39531
 
                WHEN (flitem_showendprcnt) THEN
39532
 
                        (flrptmo.flrpt_endingprcnt)
39533
 
                ELSE NULL
39534
 
        END AS flstmtitem_monthprcnt,
39535
 
        (COALESCE(flrptmo.flrpt_budget,0)) AS flstmtitem_monthbudget,
39536
 
        (flrptmo.flrpt_budgetprcnt) AS flstmtitem_monthbudgetprcnt,
39537
 
        CASE
39538
 
                WHEN (flhead_type IN ('I','C')) THEN
39539
 
                        (COALESCE((flrptmo.flrpt_diff-flrptmo.flrpt_budget),0))
39540
 
                ELSE (COALESCE((flrptmo.flrpt_ending-flrptmo.flrpt_budget),0))
39541
 
        END AS flstmtitem_monthbudgetdiff,
39542
 
        CASE
39543
 
                WHEN ((flhead_type IN ('I','C')) AND (flrptmo.flrpt_budget > 0)) THEN
39544
 
                        (COALESCE(((flrptmo.flrpt_diff-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0))
39545
 
                WHEN ((flhead_type='B') AND (flrptmo.flrpt_budget > 0)) THEN
39546
 
                        (COALESCE(((flrptmo.flrpt_ending-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0))
39547
 
                ELSE NULL
39548
 
        END AS flstmtitem_monthbudgetdiffprcnt,
39549
 
        CASE
39550
 
                WHEN (flhead_type IN ('I','C')) THEN
39551
 
                        (COALESCE(flrptqt.flrpt_diff,0))
39552
 
                ELSE (COALESCE(flrptqt.flrpt_ending,0))
39553
 
        END AS flstmtitem_qtr,
39554
 
        (COALESCE(flrptqt.flrpt_debits,0)) AS flstmtitem_qtrdb,
39555
 
        (COALESCE(flrptqt.flrpt_credits,0)) AS flstmtitem_qtrcr,
39556
 
        CASE
39557
 
                WHEN (flitem_showdiffprcnt) THEN
39558
 
                        (COALESCE(flrptqt.flrpt_diffprcnt,0))
39559
 
                WHEN (flitem_showendprcnt) THEN
39560
 
                        (COALESCE(flrptqt.flrpt_endingprcnt,0))
39561
 
                ELSE NULL
39562
 
        END AS flstmtitem_qtrprcnt,
39563
 
        (COALESCE(flrptqt.flrpt_budget,0)) AS flstmtitem_qtrbudget,
39564
 
        (flrptqt.flrpt_budgetprcnt) AS flstmtitem_qtrbudgetprcnt,
39565
 
        CASE
39566
 
                WHEN (flhead_type IN ('I','C')) THEN
39567
 
                        (COALESCE((flrptqt.flrpt_diff-flrptqt.flrpt_budget),0))
39568
 
                ELSE (COALESCE((flrptqt.flrpt_ending-flrptqt.flrpt_budget),0))
39569
 
        END AS flstmtitem_qtrbudgetdiff,
39570
 
        CASE
39571
 
                WHEN ((flhead_type IN ('I','C')) AND (flrptqt.flrpt_budget > 0)) THEN
39572
 
                        (COALESCE(((flrptqt.flrpt_diff-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0))
39573
 
                WHEN ((flhead_type='B') AND (flrptqt.flrpt_budget > 0)) THEN
39574
 
                        (COALESCE(((flrptqt.flrpt_ending-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0))
39575
 
                ELSE NULL
39576
 
        END AS flstmtitem_qtrbudgetdiffprcnt,
39577
 
        CASE
39578
 
                WHEN (flhead_type IN ('I','C')) THEN
39579
 
                        (COALESCE(flrptyr.flrpt_diff,0))
39580
 
                ELSE (COALESCE(flrptyr.flrpt_ending,0))
39581
 
        END AS flstmtitem_year,
39582
 
        (COALESCE(flrptyr.flrpt_debits,0)) AS flstmtitem_yeardb,
39583
 
        (COALESCE(flrptyr.flrpt_credits,0)) AS flstmtitem_yearcr,
39584
 
        CASE
39585
 
                WHEN (flitem_showdiffprcnt) THEN
39586
 
                        (flrptyr.flrpt_diffprcnt)
39587
 
                WHEN (flitem_showendprcnt) THEN
39588
 
                        (flrptyr.flrpt_endingprcnt)
39589
 
                ELSE NULL
39590
 
        END AS flstmtitem_yearprcnt,
39591
 
        (COALESCE(flrptyr.flrpt_budget,0)) AS  flstmtitem_yearbudget,
39592
 
        (flrptyr.flrpt_budgetprcnt) AS flstmtitem_yearbudgetprcnt,
39593
 
        CASE
39594
 
                WHEN (flhead_type IN ('I','C')) THEN
39595
 
                        (COALESCE((flrptyr.flrpt_diff-flrptyr.flrpt_budget),0))
39596
 
                ELSE (COALESCE((flrptyr.flrpt_ending-flrptyr.flrpt_budget),0))
39597
 
        END AS flstmtitem_yearbudgetdiff,
39598
 
        CASE
39599
 
                WHEN ((flhead_type IN ('I','C')) AND (flrptyr.flrpt_budget > 0)) THEN
39600
 
                        (COALESCE(((flrptyr.flrpt_diff-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0))
39601
 
                WHEN ((flhead_type = 'B') AND (flrptyr.flrpt_budget > 0)) THEN
39602
 
                        (COALESCE(((flrptyr.flrpt_ending-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0))
39603
 
                ELSE NULL
39604
 
        END AS flstmtitem_yearbudgetdiffprcnt,
39605
 
        CASE
39606
 
                WHEN (flhead_type IN ('I','C')) THEN
39607
 
                        (COALESCE(flrptprmo.flrpt_diff,0))
39608
 
                ELSE (COALESCE(flrptprmo.flrpt_ending,0))
39609
 
        END AS flstmtitem_prmonth,
39610
 
        CASE
39611
 
                WHEN (flitem_showdiffprcnt) THEN
39612
 
                        (flrptprmo.flrpt_diffprcnt)
39613
 
                WHEN (flitem_showendprcnt) THEN
39614
 
                        (flrptprmo.flrpt_endingprcnt)
39615
 
                ELSE NULL
39616
 
        END AS flstmtitem_prmonthprcnt,
39617
 
        CASE
39618
 
                WHEN (flhead_type IN ('I','C')) THEN
39619
 
                        (COALESCE(flrptmo.flrpt_diff-flrptprmo.flrpt_diff,0))
39620
 
                ELSE (COALESCE(flrptmo.flrpt_ending-flrptprmo.flrpt_ending,0))
39621
 
        END AS flstmtitem_prmonthdiff,
39622
 
        CASE
39623
 
                WHEN ((flhead_type IN ('I','C')) AND (flrptprmo.flrpt_diff > 0)) THEN
39624
 
                        (COALESCE((flrptmo.flrpt_diff-flrptprmo.flrpt_diff)/flrptprmo.flrpt_diff,0))
39625
 
                WHEN ((flhead_type = 'B') AND (flrptprmo.flrpt_ending > 0)) THEN
39626
 
                        (COALESCE((flrptmo.flrpt_ending-flrptprmo.flrpt_ending)/flrptprmo.flrpt_ending,0))
39627
 
                ELSE NULL
39628
 
        END AS flstmtitem_prmonthdiffprcnt,
39629
 
        CASE
39630
 
                WHEN (flhead_type IN ('I','C')) THEN
39631
 
                        (COALESCE(flrptprqt.flrpt_diff,0))
39632
 
                ELSE (COALESCE(flrptprqt.flrpt_ending,0))
39633
 
        END AS flstmtitem_prqtr,
39634
 
        CASE
39635
 
                WHEN (flitem_showdiffprcnt) THEN
39636
 
                        (flrptprqt.flrpt_diffprcnt)
39637
 
                WHEN (flitem_showendprcnt) THEN
39638
 
                        (flrptprqt.flrpt_endingprcnt)
39639
 
                ELSE NULL
39640
 
        END AS flstmtitem_prqtrprcnt,
39641
 
        CASE
39642
 
                WHEN (flhead_type IN ('I','C')) THEN
39643
 
                        (COALESCE(flrptqt.flrpt_diff-flrptprqt.flrpt_diff,0))
39644
 
                ELSE (COALESCE(flrptqt.flrpt_ending-flrptprqt.flrpt_ending,0))
39645
 
        END AS flstmtitem_prqtrdiff,
39646
 
        CASE
39647
 
                WHEN ((flhead_type IN ('I','C')) AND (flrptprqt.flrpt_diff > 0)) THEN
39648
 
                        (COALESCE((flrptqt.flrpt_diff-flrptprqt.flrpt_diff)/flrptprqt.flrpt_diff,0))
39649
 
                WHEN ((flhead_type = 'B') AND (flrptprqt.flrpt_ending > 0)) THEN
39650
 
                        (COALESCE((flrptqt.flrpt_ending-flrptprqt.flrpt_ending)/flrptprqt.flrpt_ending,0))
39651
 
                ELSE NULL
39652
 
        END AS flstmtitem_prqtrdiffprcnt,
39653
 
        CASE
39654
 
                WHEN (flhead_type IN ('I','C')) THEN
39655
 
                        (COALESCE(flrptpryr.flrpt_diff,0))
39656
 
                ELSE (COALESCE(flrptpryr.flrpt_ending,0))
39657
 
        END AS flstmtitem_pryear,
39658
 
        CASE
39659
 
                WHEN (flitem_showdiffprcnt) THEN
39660
 
                        (flrptpryr.flrpt_diffprcnt)
39661
 
                WHEN (flitem_showendprcnt) THEN
39662
 
                        (flrptpryr.flrpt_endingprcnt)
39663
 
                ELSE NULL
39664
 
        END AS flstmtitem_pryearprcnt,
39665
 
        CASE
39666
 
                WHEN (flhead_type IN ('I','C')) THEN
39667
 
                        (COALESCE((flrptyr.flrpt_diff-flrptpryr.flrpt_diff),0))
39668
 
                ELSE (COALESCE((flrptyr.flrpt_ending-flrptpryr.flrpt_ending),0))
39669
 
        END AS flstmtitem_pryeardiff,
39670
 
        CASE
39671
 
                WHEN ((flhead_type IN ('I','C')) AND (flrptpryr.flrpt_diff > 0)) THEN
39672
 
                        (COALESCE((flrptyr.flrpt_diff-flrptpryr.flrpt_diff)/flrptpryr.flrpt_diff,0))
39673
 
                WHEN ((flhead_type = 'B' ) AND (flrptpryr.flrpt_ending > 0)) THEN
39674
 
                        (COALESCE((flrptyr.flrpt_ending-flrptpryr.flrpt_ending)/flrptpryr.flrpt_ending,0))
39675
 
                ELSE NULL
39676
 
        END AS flstmtitem_pryeardiffprcnt
39677
 
        FROM flitem,flhead,
39678
 
                (SELECT DISTINCT
39679
 
                        flrpt_flhead_id,
39680
 
                        flrpt_period_id,
39681
 
                        flrpt_username,
39682
 
                        flrpt_order,
39683
 
                        flrpt_level,
39684
 
                        flrpt_type,
39685
 
                        flrpt_type_id,
39686
 
                        flrpt_parent_id,
39687
 
                        accnt_id AS flrpt_accnt_id,
39688
 
                        CASE WHEN (pShowNumbers) THEN
39689
 
                                (formatGLAccount(accnt_id) || '-' || accnt_descrip)
39690
 
                        ELSE accnt_descrip END AS flrpt_name
39691
 
                FROM flrpt,accnt
39692
 
                WHERE ((flrpt_type='I')
39693
 
                AND (flrpt_flhead_id=_p.flhead_id)
39694
 
                AND (flrpt_period_id=pPeriodid)
39695
 
                AND (accnt_id=flrpt_accnt_id))) AS flrpt
39696
 
                        LEFT OUTER JOIN flrpt flrptmo
39697
 
                                ON ((flrptmo.flrpt_type=flrpt.flrpt_type)
39698
 
                                AND (flrptmo.flrpt_type_id=flrpt.flrpt_type_id)
39699
 
                                AND (flrptmo.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39700
 
                                AND (flrptmo.flrpt_period_id=flrpt.flrpt_period_id)
39701
 
                                AND (flrptmo.flrpt_interval='M')
39702
 
                                AND (flrptmo.flrpt_order=flrpt.flrpt_order))
39703
 
                        LEFT OUTER JOIN flrpt flrptqt
39704
 
                                ON ((flrptqt.flrpt_type=flrpt.flrpt_type)
39705
 
                                AND (flrptqt.flrpt_type_id=flrpt.flrpt_type_id)
39706
 
                                AND (flrptqt.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39707
 
                                AND (flrptqt.flrpt_period_id=flrpt.flrpt_period_id)
39708
 
                                AND (flrptqt.flrpt_interval=_qtrInterval)
39709
 
                                AND (flrptqt.flrpt_order=flrpt.flrpt_order))
39710
 
                        LEFT OUTER JOIN flrpt flrptyr
39711
 
                                ON ((flrptyr.flrpt_type=flrpt.flrpt_type)
39712
 
                                AND (flrptyr.flrpt_type_id=flrpt.flrpt_type_id)
39713
 
                                AND (flrptyr.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39714
 
                                AND (flrptyr.flrpt_period_id=flrpt.flrpt_period_id)
39715
 
                                AND (flrptyr.flrpt_interval=_yrInterval)
39716
 
                                AND (flrptyr.flrpt_order=flrpt.flrpt_order))
39717
 
                        LEFT OUTER JOIN flrpt flrptprmo
39718
 
                                ON ((flrptprmo.flrpt_type=flrpt.flrpt_type)
39719
 
                                AND (flrptprmo.flrpt_type_id=flrpt.flrpt_type_id)
39720
 
                                AND (flrptprmo.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39721
 
                                AND (flrptprmo.flrpt_period_id=_priorMoPeriodId)
39722
 
                                AND (flrptprmo.flrpt_interval='M')
39723
 
                                AND (flrptprmo.flrpt_order=flrpt.flrpt_order))
39724
 
                        LEFT OUTER JOIN flrpt flrptprqt
39725
 
                                ON ((flrptprqt.flrpt_type=flrpt.flrpt_type)
39726
 
                                AND (flrptprqt.flrpt_type_id=flrpt.flrpt_type_id)
39727
 
                                AND (flrptprqt.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39728
 
                                AND (flrptprqt.flrpt_period_id=_priorQtPeriodId)
39729
 
                                AND (flrptprqt.flrpt_interval='Q')
39730
 
                                AND (flrptprqt.flrpt_order=flrpt.flrpt_order))
39731
 
                        LEFT OUTER JOIN flrpt flrptpryr
39732
 
                                ON ((flrptpryr.flrpt_type=flrpt.flrpt_type)
39733
 
                                AND (flrptpryr.flrpt_type_id=flrpt.flrpt_type_id)
39734
 
                                AND (flrptpryr.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39735
 
                                AND (flrptpryr.flrpt_period_id=_priorYrPeriodId)
39736
 
                                AND (flrptpryr.flrpt_interval='Y')
39737
 
                                AND (flrptpryr.flrpt_order=flrpt.flrpt_order) )
39738
 
        WHERE ((flitem_id = flrpt.flrpt_type_id)
39739
 
        AND (flhead_id = flitem_flhead_id))
39740
 
        UNION
39741
 
        SELECT
39742
 
        flrpt.flrpt_flhead_id AS flstmtitem_flhead_id,
39743
 
        flrpt.flrpt_period_id AS flstmtitem_period_id,
39744
 
        flrpt.flrpt_username AS flstmtitem_username,
39745
 
        flrpt.flrpt_order AS flstmtitem_order,
39746
 
        flrpt.flrpt_level AS flstmtitem_level,
39747
 
        flrpt.flrpt_type AS flstmtitem_type,
39748
 
        flrpt.flrpt_type_id AS flstmtitem_type_id,
39749
 
        flrpt.flrpt_parent_id AS flstmtitem_parent_id,
39750
 
        NULL AS flstmtitem_accnt_id,
39751
 
        CASE WHEN(flrpt.flrpt_type='T' AND flrpt.flrpt_level=0) THEN
39752
 
                        COALESCE(flrpt.flrpt_altname, 'Total')
39753
 
                WHEN(flrpt.flrpt_type='T') THEN
39754
 
                        formatindent(COALESCE(flrpt.flrpt_altname, 'Subtotal') ,
39755
 
                        (CASE WHEN pIndentName THEN flrpt.flrpt_level ELSE 0 END))
39756
 
                ELSE formatindent(('Type ' || flrpt.flrpt_type || ' ' || text(flrpt.flrpt_type_id)),
39757
 
                        (CASE WHEN pIndentName THEN flrpt.flrpt_level ELSE 0 END))
39758
 
                END AS flstmtitem_name,
39759
 
        CASE
39760
 
                WHEN (flhead_type IN ('I','C')) THEN
39761
 
                        (COALESCE(flrptmo.flrpt_diff,0))
39762
 
                ELSE (COALESCE(flrptmo.flrpt_ending,0))
39763
 
        END AS flstmtitem_month,
39764
 
        (COALESCE(flrptmo.flrpt_debits,0)) AS flstmtitem_monthdb,
39765
 
        (COALESCE(flrptmo.flrpt_credits,0)) AS flstmtitem_monthcr,
39766
 
        CASE
39767
 
                WHEN (flhead_type IN ('I','C')) THEN
39768
 
                        (flrptmo.flrpt_diffprcnt)
39769
 
                ELSE (flrptmo.flrpt_endingprcnt)
39770
 
        END AS flstmtitem_monthprcnt,
39771
 
        (COALESCE(flrptmo.flrpt_budget,0)) AS flstmtitem_monthbudget,
39772
 
        (flrptmo.flrpt_budgetprcnt) AS flstmtitem_monthbudgetprcnt,
39773
 
        CASE
39774
 
                WHEN (flhead_type IN ('I','C')) THEN
39775
 
                        (COALESCE((flrptmo.flrpt_diff-flrptmo.flrpt_budget),0))
39776
 
                ELSE (COALESCE((flrptmo.flrpt_ending-flrptmo.flrpt_budget),0))
39777
 
        END AS flstmtitem_monthbudgetdiff,
39778
 
        CASE
39779
 
                WHEN ((flhead_type IN ('I','C')) AND (flrptmo.flrpt_budget > 0)) THEN
39780
 
                        (COALESCE(((flrptmo.flrpt_diff-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0))
39781
 
                WHEN ((flhead_type='B') AND (flrptmo.flrpt_budget > 0)) THEN
39782
 
                        (COALESCE(((flrptmo.flrpt_ending-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0))
39783
 
                ELSE NULL
39784
 
        END AS flstmtitem_monthbudgetdiffprcnt,
39785
 
        CASE
39786
 
                WHEN (flhead_type IN ('I','C')) THEN
39787
 
                        (COALESCE(flrptqt.flrpt_diff,0))
39788
 
                ELSE (COALESCE(flrptqt.flrpt_ending,0))
39789
 
        END AS flstmtitem_qtr,
39790
 
        (COALESCE(flrptqt.flrpt_debits,0)) AS flstmtitem_qtrdb,
39791
 
        (COALESCE(flrptqt.flrpt_credits,0)) AS flstmtitem_qtrcr,
39792
 
        CASE
39793
 
                WHEN (flhead_type IN ('I','C')) THEN
39794
 
                        (flrptqt.flrpt_diffprcnt)
39795
 
                ELSE (flrptqt.flrpt_endingprcnt)
39796
 
        END AS flstmtitem_qtrprcnt,
39797
 
        (COALESCE(flrptqt.flrpt_budget,0)) AS flstmtitem_qtrbudget,
39798
 
        (flrptqt.flrpt_budgetprcnt) AS flstmtitem_qtrbudgetprcnt,
39799
 
        CASE
39800
 
                WHEN (flhead_type IN ('I','C')) THEN
39801
 
                        (COALESCE((flrptqt.flrpt_diff-flrptqt.flrpt_budget),0))
39802
 
                ELSE (COALESCE((flrptqt.flrpt_ending-flrptqt.flrpt_budget),0))
39803
 
        END AS flstmtitem_qtrbudgetdiff,
39804
 
        CASE
39805
 
                WHEN ((flhead_type IN ('I','C')) AND (flrptqt.flrpt_budget > 0)) THEN
39806
 
                        (COALESCE(((flrptqt.flrpt_diff-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0))
39807
 
                WHEN ((flhead_type='B') AND (flrptqt.flrpt_budget > 0)) THEN
39808
 
                        (COALESCE(((flrptqt.flrpt_ending-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0))
39809
 
                ELSE NULL
39810
 
        END AS flstmtitem_qtrbudgetdiffprcnt,
39811
 
        CASE
39812
 
                WHEN (flhead_type IN ('I','C')) THEN
39813
 
                        (COALESCE(flrptyr.flrpt_diff,0))
39814
 
                ELSE (COALESCE(flrptyr.flrpt_ending,0))
39815
 
        END AS flstmtitem_year,
39816
 
        (COALESCE(flrptyr.flrpt_debits,0)) AS flstmtitem_yeardb,
39817
 
        (COALESCE(flrptyr.flrpt_credits,0)) AS flstmtitem_yearcr,
39818
 
        CASE
39819
 
                WHEN (flhead_type IN ('I','C')) THEN
39820
 
                        (flrptyr.flrpt_diffprcnt)
39821
 
                ELSE (flrptyr.flrpt_endingprcnt)
39822
 
        END AS flstmtitem_yearprcnt,
39823
 
        (COALESCE(flrptyr.flrpt_budget,0)) AS  flstmtitem_yearbudget,
39824
 
        (flrptyr.flrpt_budgetprcnt) AS flstmtitem_yearbudgetprcnt,
39825
 
        CASE
39826
 
                WHEN (flhead_type IN ('I','C')) THEN
39827
 
                        (COALESCE((flrptyr.flrpt_diff-flrptyr.flrpt_budget),0))
39828
 
                ELSE (COALESCE((flrptyr.flrpt_ending-flrptyr.flrpt_budget),0))
39829
 
        END AS flstmtitem_yearbudgetdiff,
39830
 
        CASE
39831
 
                WHEN ((flhead_type IN ('I','C')) AND (flrptyr.flrpt_budget > 0)) THEN
39832
 
                        (COALESCE(((flrptyr.flrpt_diff-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0))
39833
 
                WHEN ((flhead_type = 'B') AND (flrptyr.flrpt_budget > 0)) THEN
39834
 
                        (COALESCE(((flrptyr.flrpt_ending-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0))
39835
 
                ELSE NULL
39836
 
        END AS flstmtitem_yearbudgetdiffprcnt,
39837
 
        CASE
39838
 
                WHEN (flhead_type IN ('I','C')) THEN
39839
 
                        (COALESCE(flrptprmo.flrpt_diff,0))
39840
 
                ELSE (COALESCE(flrptprmo.flrpt_ending,0))
39841
 
        END AS flstmtitem_prmonth,
39842
 
        CASE
39843
 
                WHEN (flhead_type IN ('I','C')) THEN
39844
 
                        (flrptprmo.flrpt_diffprcnt)
39845
 
                ELSE (flrptprmo.flrpt_endingprcnt)
39846
 
        END AS flstmtitem_prmonthprcnt,
39847
 
        CASE
39848
 
                WHEN (flhead_type IN ('I','C')) THEN
39849
 
                        (COALESCE(flrptmo.flrpt_diff-flrptprmo.flrpt_diff,0))
39850
 
                ELSE (COALESCE(flrptmo.flrpt_ending-flrptprmo.flrpt_ending,0))
39851
 
        END AS flstmtitem_prmonthdiff,
39852
 
        CASE
39853
 
                WHEN ((flhead_type IN ('I','C')) AND (flrptprmo.flrpt_diff > 0)) THEN
39854
 
                        (COALESCE((flrptmo.flrpt_diff-flrptprmo.flrpt_diff)/flrptprmo.flrpt_diff,0))
39855
 
                WHEN ((flhead_type = 'B') AND (flrptprmo.flrpt_ending > 0)) THEN
39856
 
                        (COALESCE((flrptmo.flrpt_ending-flrptprmo.flrpt_ending)/flrptprmo.flrpt_ending,0))
39857
 
                ELSE NULL
39858
 
        END AS flstmtitem_prmonthdiffprcnt,
39859
 
        CASE
39860
 
                WHEN (flhead_type IN ('I','C')) THEN
39861
 
                        (COALESCE(flrptprqt.flrpt_diff,0))
39862
 
                ELSE (COALESCE(flrptprqt.flrpt_ending,0))
39863
 
        END AS flstmtitem_prqtr,
39864
 
        CASE
39865
 
                WHEN (flhead_type IN ('I','C')) THEN
39866
 
                        (flrptprqt.flrpt_diffprcnt)
39867
 
                ELSE (flrptprqt.flrpt_endingprcnt)
39868
 
        END AS flstmtitem_prqtrprcnt,
39869
 
        CASE
39870
 
                WHEN (flhead_type IN ('I','C')) THEN
39871
 
                        (COALESCE(flrptqt.flrpt_diff-flrptprqt.flrpt_diff,0))
39872
 
                ELSE (COALESCE(flrptqt.flrpt_ending-flrptprqt.flrpt_ending,0))
39873
 
        END AS flstmtitem_prqtrdiff,
39874
 
        CASE
39875
 
                WHEN ((flhead_type IN ('I','C')) AND (flrptprqt.flrpt_diff > 0)) THEN
39876
 
                        (COALESCE((flrptqt.flrpt_diff-flrptprqt.flrpt_diff)/flrptprqt.flrpt_diff,0))
39877
 
                WHEN ((flhead_type = 'B') AND (flrptprqt.flrpt_ending > 0)) THEN
39878
 
                        (COALESCE((flrptqt.flrpt_ending-flrptprqt.flrpt_ending)/flrptprqt.flrpt_ending,0))
39879
 
                ELSE NULL
39880
 
        END AS flstmtitem_prqtrdiffprcnt,
39881
 
        CASE
39882
 
                WHEN (flhead_type IN ('I','C')) THEN
39883
 
                        (COALESCE(flrptpryr.flrpt_diff,0))
39884
 
                ELSE (COALESCE(flrptpryr.flrpt_ending,0))
39885
 
        END AS flstmtitem_pryear,
39886
 
        CASE
39887
 
                WHEN (flhead_type IN ('I','C')) THEN
39888
 
                        (flrptpryr.flrpt_diffprcnt)
39889
 
                ELSE (flrptpryr.flrpt_endingprcnt)
39890
 
        END AS flstmtitem_pryearprcnt,
39891
 
        CASE
39892
 
                WHEN (flhead_type IN ('I','C')) THEN
39893
 
                        (COALESCE(flrptyr.flrpt_diff-flrptpryr.flrpt_diff,0))
39894
 
                ELSE (COALESCE(flrptyr.flrpt_ending-flrptpryr.flrpt_ending,0))
39895
 
        END AS flstmtitem_pryeardiff,
39896
 
        CASE
39897
 
                WHEN ((flhead_type IN ('I','C')) AND (flrptpryr.flrpt_diff > 0)) THEN
39898
 
                        (COALESCE((flrptyr.flrpt_diff-flrptpryr.flrpt_diff)/flrptpryr.flrpt_diff,0))
39899
 
                WHEN ((flhead_type = 'B' ) AND (flrptpryr.flrpt_ending > 0)) THEN
39900
 
                        (COALESCE((flrptyr.flrpt_ending-flrptpryr.flrpt_ending)/flrptpryr.flrpt_ending,0))
39901
 
                ELSE NULL
39902
 
        END AS flstmtitem_pryeardiffprcnt
39903
 
        FROM flhead CROSS JOIN (SELECT DISTINCT
39904
 
                        flrpt_flhead_id,
39905
 
                        flrpt_period_id,
39906
 
                        flrpt_username,
39907
 
                        flrpt_order,
39908
 
                        flrpt_level,
39909
 
                        flrpt_type,
39910
 
                        flrpt_type_id,
39911
 
                        flrpt_parent_id,
39912
 
                        flrpt_altname
39913
 
                FROM flrpt
39914
 
                WHERE ((NOT (flrpt_type IN ('G','I','S')))
39915
 
                AND (flrpt_flhead_id=_p.flhead_id)
39916
 
                AND (flrpt_period_id=pPeriodId)
39917
 
                )) AS flrpt
39918
 
                        LEFT OUTER JOIN flrpt flrptmo
39919
 
                                ON ((flrptmo.flrpt_type=flrpt.flrpt_type)
39920
 
                                AND (flrptmo.flrpt_order=flrpt.flrpt_order)
39921
 
                                AND (flrptmo.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39922
 
                                AND (flrptmo.flrpt_period_id=flrpt.flrpt_period_id)
39923
 
                                AND (flrptmo.flrpt_interval='M')
39924
 
                                )
39925
 
                        LEFT OUTER JOIN flrpt flrptqt
39926
 
                                ON ((flrptqt.flrpt_type=flrpt.flrpt_type)
39927
 
                                AND (flrptqt.flrpt_order=flrpt.flrpt_order)
39928
 
                                AND (flrptqt.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39929
 
                                AND (flrptqt.flrpt_period_id=flrpt.flrpt_period_id)
39930
 
                                AND (flrptqt.flrpt_interval=_qtrInterval)
39931
 
                                )
39932
 
                        LEFT OUTER JOIN flrpt flrptyr
39933
 
                                ON ((flrptyr.flrpt_type=flrpt.flrpt_type)
39934
 
                                AND (flrptyr.flrpt_order=flrpt.flrpt_order)
39935
 
                                AND (flrptyr.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39936
 
                                AND (flrptyr.flrpt_period_id=flrpt.flrpt_period_id)
39937
 
                                AND (flrptyr.flrpt_interval=_yrInterval)
39938
 
                                )
39939
 
                        LEFT OUTER JOIN flrpt flrptprmo
39940
 
                                ON ((flrptprmo.flrpt_type=flrpt.flrpt_type)
39941
 
                                AND (flrptprmo.flrpt_order=flrpt.flrpt_order)
39942
 
                                AND (flrptprmo.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39943
 
                                AND (flrptprmo.flrpt_period_id=_priorMoPeriodId)
39944
 
                                AND (flrptprmo.flrpt_interval='M')
39945
 
                                )
39946
 
                        LEFT OUTER JOIN flrpt flrptprqt
39947
 
                                ON ((flrptprqt.flrpt_type=flrpt.flrpt_type)
39948
 
                                AND (flrptprqt.flrpt_order=flrpt.flrpt_order)
39949
 
                                AND (flrptprqt.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39950
 
                                AND (flrptprqt.flrpt_period_id=_priorQtPeriodId)
39951
 
                                AND (flrptprqt.flrpt_interval='Q')
39952
 
                                )
39953
 
                        LEFT OUTER JOIN flrpt flrptpryr
39954
 
                                ON ((flrptpryr.flrpt_type=flrpt.flrpt_type)
39955
 
                                AND (flrptpryr.flrpt_order=flrpt.flrpt_order)
39956
 
                                AND (flrptpryr.flrpt_flhead_id=flrpt.flrpt_flhead_id)
39957
 
                                AND (flrptpryr.flrpt_period_id=_priorYrPeriodId)
39958
 
                                AND (flrptpryr.flrpt_interval='Y')
39959
 
                                )
39960
 
        WHERE (flhead_id=flrpt.flrpt_flhead_id)
39961
 
        ORDER BY flstmtitem_order
39962
 
        LOOP
39963
 
                IF _prevlevel > _x.flstmtitem_level THEN
39964
 
                        _subgrp := _subgrp+1;
39965
 
                END IF;
39966
 
                _prevlevel:=_x.flstmtitem_level;
39967
 
                _row.flstmtitem_subgrp := _subgrp;
39968
 
 
39969
 
                IF NOT _first THEN
39970
 
                        RETURN NEXT _row;
39971
 
                END IF;
39972
 
 
39973
 
                _first := FALSE;
39974
 
 
39975
 
                _row.flstmtitem_flhead_id := _x.flstmtitem_flhead_id;
39976
 
                _row.flstmtitem_period_id := _x.flstmtitem_period_id;
39977
 
                _row.flstmtitem_username := _x.flstmtitem_username;
39978
 
                _row.flstmtitem_order := _x.flstmtitem_order;
39979
 
                _row.flstmtitem_level := _x.flstmtitem_level;
39980
 
                _row.flstmtitem_type := _x.flstmtitem_type;
39981
 
                _row.flstmtitem_type_id := _x.flstmtitem_type_id;
39982
 
                _row.flstmtitem_parent_id := _x.flstmtitem_parent_id;
39983
 
                _row.flstmtitem_accnt_id := _x.flstmtitem_accnt_id;
39984
 
                _row.flstmtitem_name := _x.flstmtitem_name;
39985
 
                _row.flstmtitem_month := _x.flstmtitem_month;
39986
 
                _row.flstmtitem_monthdb := _x.flstmtitem_monthdb;
39987
 
                _row.flstmtitem_monthcr := _x.flstmtitem_monthcr;
39988
 
                _row.flstmtitem_monthprcnt := _x.flstmtitem_monthprcnt;
39989
 
                _row.flstmtitem_monthbudget := _x.flstmtitem_monthbudget;
39990
 
                _row.flstmtitem_monthbudgetprcnt := _x.flstmtitem_monthbudgetprcnt;
39991
 
                _row.flstmtitem_monthbudgetdiff := _x.flstmtitem_monthbudgetdiff;
39992
 
                _row.flstmtitem_monthbudgetdiffprcnt := _x.flstmtitem_monthbudgetdiffprcnt;
39993
 
                _row.flstmtitem_qtr := _x.flstmtitem_qtr;
39994
 
                _row.flstmtitem_qtrdb := _x.flstmtitem_qtrdb;
39995
 
                _row.flstmtitem_qtrcr := _x.flstmtitem_qtrcr;
39996
 
                _row.flstmtitem_qtrprcnt := _x.flstmtitem_qtrprcnt;
39997
 
                _row.flstmtitem_qtrbudget := _x.flstmtitem_qtrbudget;
39998
 
                _row.flstmtitem_qtrbudgetprcnt := _x.flstmtitem_qtrbudgetprcnt;
39999
 
                _row.flstmtitem_qtrbudgetdiff := _x.flstmtitem_qtrbudgetdiff;
40000
 
                _row.flstmtitem_qtrbudgetdiffprcnt := _x.flstmtitem_qtrbudgetdiffprcnt;
40001
 
                _row.flstmtitem_year := _x.flstmtitem_year;
40002
 
                _row.flstmtitem_yeardb := _x.flstmtitem_yeardb;
40003
 
                _row.flstmtitem_yearcr := _x.flstmtitem_yearcr;
40004
 
                _row.flstmtitem_yearprcnt := _x.flstmtitem_yearprcnt;
40005
 
                _row.flstmtitem_yearbudget := _x.flstmtitem_yearbudget;
40006
 
                _row.flstmtitem_yearbudgetprcnt := _x.flstmtitem_yearbudgetprcnt;
40007
 
                _row.flstmtitem_yearbudgetdiff := _x.flstmtitem_yearbudgetdiff;
40008
 
                _row.flstmtitem_yearbudgetdiffprcnt := _x.flstmtitem_yearbudgetdiffprcnt;
40009
 
                _row.flstmtitem_prmonth := _x.flstmtitem_prmonth;
40010
 
                _row.flstmtitem_prmonthprcnt := _x.flstmtitem_prmonthprcnt;
40011
 
                _row.flstmtitem_prmonthdiff := _x.flstmtitem_prmonthdiff;
40012
 
                _row.flstmtitem_prmonthdiffprcnt := _x.flstmtitem_prmonthdiffprcnt;
40013
 
                _row.flstmtitem_prqtr := _x.flstmtitem_prqtr;
40014
 
                _row.flstmtitem_prqtrprcnt := _x.flstmtitem_prqtrprcnt;
40015
 
                _row.flstmtitem_prqtrdiff := _x.flstmtitem_prqtrdiff;
40016
 
                _row.flstmtitem_prqtrdiffprcnt := _x.flstmtitem_prqtrdiffprcnt;
40017
 
                _row.flstmtitem_pryear := _x.flstmtitem_pryear;
40018
 
                _row.flstmtitem_pryearprcnt := _x.flstmtitem_pryearprcnt;
40019
 
                _row.flstmtitem_pryeardiff := _x.flstmtitem_pryeardiff;
40020
 
                _row.flstmtitem_pryeardiffprcnt := _x.flstmtitem_pryeardiffprcnt;
40021
 
 
40022
 
        END LOOP;
40023
 
 
40024
 
        _row.flstmtitem_subgrp := _subgrp + 1;
40025
 
        RETURN NEXT _row;
40026
 
END;
40027
 
$_$;
40028
 
 
40029
 
 
40030
 
ALTER FUNCTION public.financialreport(integer, integer, boolean, boolean, integer) OWNER TO admin;
40031
 
 
40032
 
--
40033
 
--
40034
 
 
40035
 
CREATE FUNCTION findapaccount(integer) RETURNS integer
40036
 
    LANGUAGE plpgsql STABLE
40037
 
    AS $_$
40038
 
DECLARE
40039
 
  pVendid ALIAS FOR $1;
40040
 
  _accntid INTEGER;
40041
 
 
40042
 
BEGIN
40043
 
 
40044
 
  IF (NOT fetchMetricBool('InterfaceAPToGL')) THEN
40045
 
    RETURN 0;
40046
 
  END IF;
40047
 
 
40048
 
  SELECT apaccnt_ap_accnt_id INTO _accntid
40049
 
    FROM apaccnt
40050
 
    JOIN vendinfo ON (apaccnt_vendtype_id=vend_vendtype_id)
40051
 
  WHERE (vend_id=pVendid);
40052
 
  IF (FOUND) THEN
40053
 
    RETURN _accntid;
40054
 
  END IF;
40055
 
 
40056
 
  SELECT apaccnt_ap_accnt_id INTO _accntid
40057
 
    FROM apaccnt
40058
 
    JOIN vendtype ON (vendtype_code ~ apaccnt_vendtype)
40059
 
    JOIN vendinfo ON (vend_vendtype_id=vendtype_id)
40060
 
  WHERE ((apaccnt_vendtype_id=-1)
40061
 
     AND (vend_id=pVendid));
40062
 
  IF (FOUND) THEN
40063
 
    RETURN _accntid;
40064
 
  END IF;
40065
 
 
40066
 
  RETURN -1;
40067
 
 
40068
 
END;
40069
 
$_$;
40070
 
 
40071
 
 
40072
 
ALTER FUNCTION public.findapaccount(integer) OWNER TO admin;
40073
 
 
40074
 
--
40075
 
--
40076
 
 
40077
 
CREATE FUNCTION findapdiscountaccount(integer) RETURNS integer
40078
 
    LANGUAGE plpgsql
40079
 
    AS $_$
40080
 
DECLARE
40081
 
  pVendid ALIAS FOR $1;
40082
 
  _accntid INTEGER;
40083
 
 
40084
 
BEGIN
40085
 
 
40086
 
  IF (NOT fetchMetricBool('InterfaceAPToGL')) THEN
40087
 
    RETURN 0;
40088
 
  END IF;
40089
 
 
40090
 
  SELECT apaccnt_discount_accnt_id INTO _accntid
40091
 
    FROM apaccnt
40092
 
    JOIN vendinfo ON (apaccnt_vendtype_id=vend_vendtype_id)
40093
 
  WHERE (vend_id=pVendid);
40094
 
  IF (FOUND) THEN
40095
 
    RETURN _accntid;
40096
 
  END IF;
40097
 
 
40098
 
  SELECT apaccnt_discount_accnt_id INTO _accntid
40099
 
    FROM apaccnt
40100
 
    JOIN vendtype ON (vendtype_code ~ apaccnt_vendtype)
40101
 
    JOIN vendinfo ON (vend_vendtype_id=vendtype_id)
40102
 
  WHERE ((apaccnt_vendtype_id=-1)
40103
 
     AND (vend_id=pVendid));
40104
 
  IF (FOUND) THEN
40105
 
    RETURN _accntid;
40106
 
  END IF;
40107
 
 
40108
 
  RETURN -1;
40109
 
 
40110
 
END;
40111
 
$_$;
40112
 
 
40113
 
 
40114
 
ALTER FUNCTION public.findapdiscountaccount(integer) OWNER TO admin;
40115
 
 
40116
 
--
40117
 
--
40118
 
 
40119
 
CREATE FUNCTION findapprepaidaccount(integer) RETURNS integer
40120
 
    LANGUAGE plpgsql
40121
 
    AS $_$
40122
 
DECLARE
40123
 
  pVendid ALIAS FOR $1;
40124
 
  _accntid INTEGER;
40125
 
 
40126
 
BEGIN
40127
 
 
40128
 
  IF (NOT fetchMetricBool('InterfaceAPToGL')) THEN
40129
 
    RETURN 0;
40130
 
  END IF;
40131
 
 
40132
 
  SELECT apaccnt_prepaid_accnt_id INTO _accntid
40133
 
    FROM apaccnt
40134
 
    JOIN vendinfo ON (apaccnt_vendtype_id=vend_vendtype_id)
40135
 
  WHERE (vend_id=pVendid);
40136
 
  IF (FOUND) THEN
40137
 
    RETURN _accntid;
40138
 
  END IF;
40139
 
 
40140
 
  SELECT apaccnt_prepaid_accnt_id INTO _accntid
40141
 
    FROM apaccnt
40142
 
    JOIN vendtype ON (vendtype_code ~ apaccnt_vendtype)
40143
 
    JOIN vendinfo ON (vend_vendtype_id=vendtype_id)
40144
 
  WHERE ((apaccnt_vendtype_id=-1)
40145
 
     AND (vend_id=pVendid));
40146
 
  IF (FOUND) THEN
40147
 
    RETURN _accntid;
40148
 
  END IF;
40149
 
 
40150
 
  RETURN -1;
40151
 
 
40152
 
END;
40153
 
$_$;
40154
 
 
40155
 
 
40156
 
ALTER FUNCTION public.findapprepaidaccount(integer) OWNER TO admin;
40157
 
 
40158
 
--
40159
 
--
40160
 
 
40161
 
CREATE FUNCTION findaraccount(integer) RETURNS integer
40162
 
    LANGUAGE plpgsql STABLE
40163
 
    AS $_$
40164
 
DECLARE
40165
 
  pCustid ALIAS FOR $1;
40166
 
  _accntid INTEGER;
40167
 
 
40168
 
BEGIN
40169
 
 
40170
 
  IF (NOT fetchMetricBool('InterfaceARToGL')) THEN
40171
 
    RETURN 0;
40172
 
  END IF;
40173
 
 
40174
 
  SELECT araccnt_ar_accnt_id INTO _accntid
40175
 
  FROM araccnt, custinfo
40176
 
  WHERE ( (araccnt_custtype_id=cust_custtype_id)
40177
 
   AND (cust_id=pCustid) );
40178
 
  IF (FOUND) THEN
40179
 
    RETURN _accntid;
40180
 
  END IF;
40181
 
 
40182
 
  SELECT araccnt_ar_accnt_id INTO _accntid
40183
 
  FROM araccnt, custinfo, custtype
40184
 
  WHERE ( (custtype_code ~ araccnt_custtype)
40185
 
   AND (araccnt_custtype_id=-1)
40186
 
   AND (cust_custtype_id=custtype_id)
40187
 
   AND (cust_id=pCustid) );
40188
 
  IF (FOUND) THEN
40189
 
    RETURN _accntid;
40190
 
  END IF;
40191
 
 
40192
 
  RETURN -1;
40193
 
 
40194
 
END;
40195
 
$_$;
40196
 
 
40197
 
 
40198
 
ALTER FUNCTION public.findaraccount(integer) OWNER TO admin;
40199
 
 
40200
 
--
40201
 
--
40202
 
 
40203
 
CREATE FUNCTION findardiscountaccount(integer) RETURNS integer
40204
 
    LANGUAGE plpgsql
40205
 
    AS $_$
40206
 
DECLARE
40207
 
  pCustid ALIAS FOR $1;
40208
 
  _accntid INTEGER;
40209
 
 
40210
 
BEGIN
40211
 
 
40212
 
  IF (NOT fetchMetricBool('InterfaceARToGL')) THEN
40213
 
    RETURN 0;
40214
 
  END IF;
40215
 
 
40216
 
  SELECT araccnt_discount_accnt_id INTO _accntid
40217
 
  FROM araccnt, custinfo
40218
 
  WHERE ( (araccnt_custtype_id=cust_custtype_id)
40219
 
   AND (cust_id=pCustid) );
40220
 
  IF (FOUND) THEN
40221
 
    RETURN _accntid;
40222
 
  END IF;
40223
 
 
40224
 
  SELECT araccnt_discount_accnt_id INTO _accntid
40225
 
  FROM araccnt, custinfo, custtype
40226
 
  WHERE ( (custtype_code ~ araccnt_custtype)
40227
 
   AND (cust_custtype_id=custtype_id)
40228
 
   AND (araccnt_custtype_id=-1)
40229
 
   AND (cust_id=pCustid) );
40230
 
  IF (FOUND) THEN
40231
 
    RETURN _accntid;
40232
 
  END IF;
40233
 
 
40234
 
  RETURN -1;
40235
 
 
40236
 
END;
40237
 
$_$;
40238
 
 
40239
 
 
40240
 
ALTER FUNCTION public.findardiscountaccount(integer) OWNER TO admin;
40241
 
 
40242
 
--
40243
 
--
40244
 
 
40245
 
CREATE FUNCTION findcalendarorigin(integer) RETURNS date
40246
 
    LANGUAGE plpgsql
40247
 
    AS $_$
40248
 
DECLARE
40249
 
  pCalheadid ALIAS FOR $1;
40250
 
  _originType CHAR(1);
40251
 
  _origin DATE;
40252
 
 
40253
 
BEGIN
40254
 
 
40255
 
  SELECT calhead_origin INTO _originType
40256
 
  FROM calhead
40257
 
  WHERE (calhead_id=pCalheadid);
40258
 
 
40259
 
  IF (NOT FOUND) THEN
40260
 
    _origin := NULL;
40261
 
 
40262
 
  ELSIF (_originType = 'D') THEN
40263
 
    _origin := CURRENT_DATE;
40264
 
 
40265
 
  ELSIF (_originType = 'E') THEN
40266
 
    _origin := (CURRENT_DATE + 1);
40267
 
 
40268
 
  ELSIF (_originType = 'W') THEN
40269
 
    _origin := (CURRENT_DATE - EXTRACT(DOW FROM CURRENT_DATE)::INTEGER);
40270
 
 
40271
 
  ELSIF (_originType = 'X') THEN
40272
 
    _origin := ((CURRENT_DATE - EXTRACT(DOW FROM CURRENT_DATE)::INTEGER) + INTERVAL '1 week');
40273
 
 
40274
 
  ELSIF (_originType = 'M') THEN
40275
 
    _origin := date_trunc('month', CURRENT_DATE);
40276
 
 
40277
 
  ELSIF (_originType = 'N') THEN
40278
 
    _origin := (date_trunc('month', CURRENT_DATE) + INTERVAL '1 month');
40279
 
 
40280
 
  ELSIF (_originType = 'L') THEN
40281
 
    _origin := (date_trunc('year', CURRENT_DATE) - INTERVAL '1 year');
40282
 
 
40283
 
  ELSIF (_originType = 'Y') THEN
40284
 
    _origin := date_trunc('year', CURRENT_DATE);
40285
 
 
40286
 
  ELSIF (_originType = 'Z') THEN
40287
 
    _origin := (date_trunc('year', CURRENT_DATE) + INTERVAL '1 year');
40288
 
 
40289
 
  ELSE
40290
 
    _origin := NULL;
40291
 
  END IF;
40292
 
 
40293
 
  RETURN _origin;
40294
 
 
40295
 
  END;
40296
 
$_$;
40297
 
 
40298
 
 
40299
 
ALTER FUNCTION public.findcalendarorigin(integer) OWNER TO admin;
40300
 
 
40301
 
--
40302
 
--
40303
 
 
40304
 
CREATE FUNCTION findcustomerform(integer, character) RETURNS text
40305
 
    LANGUAGE plpgsql
40306
 
    AS $_$
40307
 
DECLARE
40308
 
  pCustid ALIAS FOR $1;
40309
 
  pFormtype ALIAS FOR $2;
40310
 
  _f RECORD;
40311
 
  _found BOOLEAN;
40312
 
 
40313
 
BEGIN
40314
 
 
40315
 
  SELECT custform.* INTO _f
40316
 
    FROM custform
40317
 
    JOIN custinfo ON (custform_custtype_id=cust_custtype_id)
40318
 
  WHERE (cust_id=pCustid);
40319
 
 
40320
 
  IF (FOUND) THEN
40321
 
    _found := TRUE;
40322
 
  ELSE
40323
 
    SELECT custform.* INTO _f
40324
 
      FROM custform
40325
 
      JOIN custtype ON (custtype_code ~ custform_custtype)
40326
 
      JOIN custinfo ON (cust_custtype_id=custtype_id)
40327
 
    WHERE ((custform_custtype_id=-1)
40328
 
       AND (cust_id=pCustid));
40329
 
 
40330
 
    IF (FOUND) THEN
40331
 
      _found := TRUE;
40332
 
    ELSE
40333
 
      _found := FALSE;
40334
 
    END IF;
40335
 
  END IF;
40336
 
 
40337
 
  IF (_found) THEN
40338
 
    IF ( (pFormType = 'I') AND (_f.custform_invoice_report_name IS NOT NULL) ) THEN
40339
 
      RETURN _f.custform_invoice_report_name;
40340
 
 
40341
 
    ELSIF ( (pFormType = 'C') AND (_f.custform_creditmemo_report_name IS NOT NULL) ) THEN
40342
 
      RETURN _f.custform_creditmemo_report_name;
40343
 
 
40344
 
    ELSIF ( (pFormType = 'S') AND (_f.custform_statement_report_name IS NOT NULL) ) THEN
40345
 
      RETURN _f.custform_statement_report_name;
40346
 
 
40347
 
    ELSIF ( (pFormType = 'Q') AND (_f.custform_quote_report_name IS NOT NULL) ) THEN
40348
 
      RETURN _f.custform_quote_report_name;
40349
 
 
40350
 
    ELSIF ( (pFormType = 'P') AND (_f.custform_packinglist_report_name IS NOT NULL) ) THEN
40351
 
      RETURN _f.custform_packinglist_report_name;
40352
 
 
40353
 
    ELSIF ( (pFormType = 'L') AND (_f.custform_sopicklist_report_name IS NOT NULL) ) THEN
40354
 
      RETURN _f.custform_sopicklist_report_name;
40355
 
    END IF;
40356
 
 
40357
 
  END IF;
40358
 
 
40359
 
  IF (pFormType = 'I') THEN
40360
 
    RETURN 'Invoice';
40361
 
  ELSIF (pFormType = 'C') THEN
40362
 
    RETURN 'CreditMemo';
40363
 
  ELSIF (pFormType = 'S') THEN
40364
 
    RETURN 'Statement';
40365
 
  ELSIF (pFormType = 'Q') THEN
40366
 
    RETURN 'Quote';
40367
 
  ELSIF (pFormType = 'P') THEN
40368
 
    RETURN 'PackingList-Shipment';
40369
 
  ELSIF (pFormType = 'L') THEN
40370
 
    RETURN 'PackingList';
40371
 
  END IF;
40372
 
 
40373
 
END;
40374
 
$_$;
40375
 
 
40376
 
 
40377
 
ALTER FUNCTION public.findcustomerform(integer, character) OWNER TO admin;
40378
 
 
40379
 
--
40380
 
--
40381
 
 
40382
 
CREATE FUNCTION finddeferredaccount(integer) RETURNS integer
40383
 
    LANGUAGE plpgsql STABLE
40384
 
    AS $_$
40385
 
DECLARE
40386
 
  pCustid ALIAS FOR $1;
40387
 
  _accntid INTEGER;
40388
 
 
40389
 
BEGIN
40390
 
 
40391
 
  IF (NOT fetchMetricBool('InterfaceARToGL')) THEN
40392
 
    RETURN 0;
40393
 
  END IF;
40394
 
 
40395
 
  SELECT araccnt_deferred_accnt_id INTO _accntid
40396
 
    FROM araccnt
40397
 
    JOIN custinfo ON (araccnt_custtype_id=cust_custtype_id)
40398
 
  WHERE (cust_id=pCustid);
40399
 
  IF (FOUND) THEN
40400
 
    RETURN _accntid;
40401
 
  END IF;
40402
 
 
40403
 
  SELECT araccnt_deferred_accnt_id INTO _accntid
40404
 
    FROM araccnt
40405
 
    JOIN custtype ON (custtype_code ~ araccnt_custtype)
40406
 
    JOIN custinfo ON (cust_custtype_id=custtype_id)
40407
 
  WHERE ((araccnt_custtype_id=-1)
40408
 
     AND (cust_id=pCustid));
40409
 
  IF (FOUND) THEN
40410
 
    RETURN _accntid;
40411
 
  END IF;
40412
 
 
40413
 
  RETURN -1;
40414
 
 
40415
 
END;
40416
 
$_$;
40417
 
 
40418
 
 
40419
 
ALTER FUNCTION public.finddeferredaccount(integer) OWNER TO admin;
40420
 
 
40421
 
--
40422
 
--
40423
 
 
40424
 
CREATE FUNCTION findfreightaccount(integer) RETURNS integer
40425
 
    LANGUAGE plpgsql
40426
 
    AS $_$
40427
 
DECLARE
40428
 
  pCustid ALIAS FOR $1;
40429
 
  _accntid INTEGER;
40430
 
 
40431
 
BEGIN
40432
 
 
40433
 
  IF (NOT fetchMetricBool('InterfaceARToGL')) THEN
40434
 
    RETURN 0;
40435
 
  END IF;
40436
 
 
40437
 
  SELECT araccnt_freight_accnt_id INTO _accntid
40438
 
  FROM araccnt, custinfo
40439
 
  WHERE ( (araccnt_custtype_id=cust_custtype_id)
40440
 
   AND (cust_id=pCustid) );
40441
 
  IF (FOUND) THEN
40442
 
    RETURN _accntid;
40443
 
  END IF;
40444
 
 
40445
 
  SELECT araccnt_freight_accnt_id INTO _accntid
40446
 
  FROM araccnt, custinfo, custtype
40447
 
  WHERE ( (custtype_code ~ araccnt_custtype)
40448
 
   AND (cust_custtype_id=custtype_id)
40449
 
   AND (araccnt_custtype_id=-1)
40450
 
   AND (cust_id=pCustid) );
40451
 
  IF (FOUND) THEN
40452
 
    RETURN _accntid;
40453
 
  END IF;
40454
 
 
40455
 
  SELECT metric_value::INTEGER INTO _accntid
40456
 
  FROM metric
40457
 
  WHERE (metric_name='FreightAccount');
40458
 
  IF (FOUND) THEN
40459
 
    RETURN _accntid;
40460
 
  END IF;
40461
 
 
40462
 
  RETURN -1;
40463
 
 
40464
 
END;
40465
 
$_$;
40466
 
 
40467
 
 
40468
 
ALTER FUNCTION public.findfreightaccount(integer) OWNER TO admin;
40469
 
 
40470
 
--
40471
 
--
40472
 
 
40473
 
CREATE FUNCTION findperiodend(integer) RETURNS date
40474
 
    LANGUAGE plpgsql STABLE
40475
 
    AS $_$
40476
 
DECLARE
40477
 
  pCalitemid ALIAS FOR $1;
40478
 
  _calType CHAR(1);
40479
 
  _calItem RECORD;
40480
 
  _start DATE;
40481
 
  _loop INTEGER;
40482
 
 
40483
 
BEGIN
40484
 
 
40485
 
  SELECT calhead_type INTO _calType
40486
 
  FROM calhead, acalitem
40487
 
  WHERE ((acalitem_calhead_id=calhead_id)
40488
 
   AND (acalitem_id=pCalitemid));
40489
 
 
40490
 
  IF (NOT FOUND) THEN
40491
 
    SELECT calhead_type INTO _calType
40492
 
    FROM calhead, rcalitem
40493
 
    WHERE ((rcalitem_calhead_id=calhead_id)
40494
 
     AND (rcalitem_id=pCalitemid));
40495
 
 
40496
 
    IF (NOT FOUND) THEN
40497
 
      RETURN NULL;
40498
 
    END IF;
40499
 
  END IF;
40500
 
 
40501
 
  IF (_calType = 'A') THEN
40502
 
    RETURN ( SELECT (findPeriodStart(acalitem_id) + acalitem_periodlength - 1)
40503
 
             FROM acalitem
40504
 
             WHERE (acalitem_id=pCalitemid) );
40505
 
 
40506
 
  ELSIF (_calType = 'R') THEN
40507
 
 
40508
 
    SELECT rcalitem_periodtype, rcalitem_periodcount INTO _calitem
40509
 
    FROM rcalitem
40510
 
    WHERE (rcalitem_id=pCalitemid);
40511
 
 
40512
 
    IF (NOT FOUND) THEN
40513
 
      RETURN NULL;
40514
 
    END If;
40515
 
 
40516
 
    SELECT findPeriodStart(pCalitemid) INTO _start;
40517
 
 
40518
 
    IF (_start IS NULL) THEN
40519
 
 
40520
 
    ELSIF (_calitem.rcalitem_periodtype = 'D') THEN
40521
 
      _start := (_start + _calitem.rcalitem_periodcount - 1);
40522
 
 
40523
 
    ELSIF (_calitem.rcalitem_periodtype = 'W') THEN
40524
 
      _loop := _calitem.rcalitem_periodcount;
40525
 
 
40526
 
      WHILE (_loop > 0) LOOP
40527
 
        _start := (_start + INTERVAL '1 week');
40528
 
        _loop := (_loop - 1);
40529
 
      END LOOP;
40530
 
 
40531
 
      _start := (_start - 1);
40532
 
 
40533
 
    ELSIF (_calitem.rcalitem_periodtype = 'M') THEN
40534
 
      _loop := _calitem.rcalitem_periodcount;
40535
 
 
40536
 
      WHILE (_loop > 0) LOOP
40537
 
        _start := (_start + INTERVAL '1 month');
40538
 
        _loop := (_loop - 1);
40539
 
      END LOOP;
40540
 
 
40541
 
      _start := (_start - 1);
40542
 
 
40543
 
    ELSIF (_calitem.rcalitem_periodtype = 'Y') THEN
40544
 
      _loop := _calitem.rcalitem_periodcount;
40545
 
 
40546
 
      WHILE (_loop > 0) LOOP
40547
 
        _start := (_start + INTERVAL '1 year');
40548
 
        _loop := (_loop - 1);
40549
 
      END LOOP;
40550
 
 
40551
 
      _start := (_start - 1);
40552
 
 
40553
 
    ELSE
40554
 
      _start := NULL;
40555
 
    END IF;
40556
 
 
40557
 
  ELSE
40558
 
    _start := NULL;
40559
 
  END IF;
40560
 
 
40561
 
  RETURN _start;
40562
 
 
40563
 
END;
40564
 
$_$;
40565
 
 
40566
 
 
40567
 
ALTER FUNCTION public.findperiodend(integer) OWNER TO admin;
40568
 
 
40569
 
--
40570
 
--
40571
 
 
40572
 
CREATE FUNCTION findperiodstart(integer) RETURNS date
40573
 
    LANGUAGE plpgsql STABLE
40574
 
    AS $_$
40575
 
DECLARE
40576
 
  pCalitemid ALIAS FOR $1;
40577
 
  _calType CHAR(1);
40578
 
  _calItem RECORD;
40579
 
  _start DATE;
40580
 
  _loop INTEGER;
40581
 
 
40582
 
BEGIN
40583
 
 
40584
 
  SELECT calhead_type INTO _calType
40585
 
  FROM calhead, acalitem
40586
 
  WHERE ((acalitem_calhead_id=calhead_id)
40587
 
   AND (acalitem_id=pCalitemid));
40588
 
 
40589
 
  IF (NOT FOUND) THEN
40590
 
    SELECT calhead_type INTO _calType
40591
 
    FROM calhead, rcalitem
40592
 
    WHERE ((rcalitem_calhead_id=calhead_id)
40593
 
     AND (rcalitem_id=pCalitemid));
40594
 
 
40595
 
    IF (NOT FOUND) THEN
40596
 
      RETURN NULL;
40597
 
    END IF;
40598
 
  END IF;
40599
 
 
40600
 
  IF (_calType = 'A') THEN
40601
 
    RETURN ( SELECT acalitem_periodstart
40602
 
             FROM acalitem
40603
 
             WHERE (acalitem_id=pCalitemid) );
40604
 
 
40605
 
  ELSIF (_calType = 'R') THEN
40606
 
 
40607
 
    SELECT rcalitem_offsettype, rcalitem_offsetcount INTO _calitem
40608
 
    FROM rcalitem
40609
 
    WHERE (rcalitem_id=pCalitemid);
40610
 
 
40611
 
    IF (NOT FOUND) THEN
40612
 
      RETURN NULL;
40613
 
    END If;
40614
 
 
40615
 
    SELECT findCalendarOrigin(calhead_id) INTO _start
40616
 
    FROM calhead, rcalitem
40617
 
    WHERE ((rcalitem_calhead_id=calhead_id)
40618
 
     AND (rcalitem_id=pCalitemid));
40619
 
 
40620
 
    IF (_calitem.rcalitem_offsettype = 'D') THEN
40621
 
      _start := (_start + _calitem.rcalitem_offsetcount);
40622
 
 
40623
 
    ELSIF (_calitem.rcalitem_offsettype = 'W') THEN
40624
 
      _start := (_start + (_calitem.rcalitem_offsetcount * 7));
40625
 
 
40626
 
    ELSIF (_calitem.rcalitem_offsettype = 'M') THEN
40627
 
      _loop := _calitem.rcalitem_offsetcount;
40628
 
 
40629
 
      IF (_loop > 0) THEN
40630
 
        WHILE (_loop > 0) LOOP
40631
 
          _start := (_start + INTERVAL '1 month');
40632
 
          _loop := _loop - 1;
40633
 
        END LOOP;
40634
 
      ELSE
40635
 
        WHILE (_loop < 0) LOOP
40636
 
          _start := (_start - INTERVAL '1 month');
40637
 
          _loop := _loop + 1;
40638
 
        END LOOP;
40639
 
      END IF;
40640
 
 
40641
 
    ELSIF (_calitem.rcalitem_offsettype = 'Y') THEN
40642
 
      _loop := _calitem.rcalitem_offsetcount;
40643
 
 
40644
 
      IF (_loop > 0) THEN
40645
 
        WHILE (_loop > 0) LOOP
40646
 
          _start := (_start + INTERVAL '1 year');
40647
 
          _loop := _loop - 1;
40648
 
        END LOOP;
40649
 
      ELSE
40650
 
        WHILE (_loop < 0) LOOP
40651
 
          _start := (_start - INTERVAL '1 year');
40652
 
          _loop := _loop + 1;
40653
 
        END LOOP;
40654
 
      END IF;
40655
 
 
40656
 
    ELSE
40657
 
      _start := NULL;
40658
 
    END IF;
40659
 
 
40660
 
  ELSE
40661
 
    _start := NULL;
40662
 
  END IF;
40663
 
 
40664
 
  RETURN _start;
40665
 
 
40666
 
END;
40667
 
$_$;
40668
 
 
40669
 
 
40670
 
ALTER FUNCTION public.findperiodstart(integer) OWNER TO admin;
40671
 
 
40672
 
--
40673
 
--
40674
 
 
40675
 
CREATE FUNCTION findprepaidaccount(integer) RETURNS integer
40676
 
    LANGUAGE plpgsql
40677
 
    AS $_$
40678
 
DECLARE
40679
 
  pCustid ALIAS FOR $1;
40680
 
  _accntid INTEGER;
40681
 
 
40682
 
BEGIN
40683
 
 
40684
 
  IF (NOT fetchMetricBool('InterfaceARToGL')) THEN
40685
 
    RETURN 0;
40686
 
  END IF;
40687
 
 
40688
 
  SELECT araccnt_prepaid_accnt_id INTO _accntid
40689
 
    FROM araccnt
40690
 
    JOIN custinfo ON (araccnt_custtype_id=cust_custtype_id)
40691
 
  WHERE (cust_id=pCustid);
40692
 
  IF (FOUND) THEN
40693
 
    RETURN _accntid;
40694
 
  END IF;
40695
 
 
40696
 
  SELECT araccnt_prepaid_accnt_id INTO _accntid
40697
 
    FROM araccnt
40698
 
    JOIN custtype ON (custtype_code ~ araccnt_custtype)
40699
 
    JOIN custinfo ON (cust_custtype_id=custtype_id)
40700
 
  WHERE ((araccnt_custtype_id=-1)
40701
 
     AND (cust_id=pCustid) );
40702
 
  IF (FOUND) THEN
40703
 
    RETURN _accntid;
40704
 
  END IF;
40705
 
 
40706
 
  RETURN -1;
40707
 
 
40708
 
END;
40709
 
$_$;
40710
 
 
40711
 
 
40712
 
ALTER FUNCTION public.findprepaidaccount(integer) OWNER TO admin;
40713
 
 
40714
 
--
40715
 
--
40716
 
 
40717
 
CREATE FUNCTION findsalesaccnt(integer, integer) RETURNS integer
40718
 
    LANGUAGE plpgsql
40719
 
    AS $_$
40720
 
BEGIN
40721
 
  RETURN findSalesAccnt($1, 'IS', $2, NULL, NULL);
40722
 
END;
40723
 
$_$;
40724
 
 
40725
 
 
40726
 
ALTER FUNCTION public.findsalesaccnt(integer, integer) OWNER TO admin;
40727
 
 
40728
 
--
40729
 
--
40730
 
 
40731
 
CREATE FUNCTION findsalesaccnt(integer, text, integer) RETURNS integer
40732
 
    LANGUAGE plpgsql
40733
 
    AS $_$
40734
 
BEGIN
40735
 
  RETURN findSalesAccnt($1, $2, $3, NULL, NULL);
40736
 
END;
40737
 
$_$;
40738
 
 
40739
 
 
40740
 
ALTER FUNCTION public.findsalesaccnt(integer, text, integer) OWNER TO admin;
40741
 
 
40742
 
--
40743
 
--
40744
 
 
40745
 
CREATE FUNCTION findsalesaccnt(pid integer, pidtype text, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer
40746
 
    LANGUAGE plpgsql
40747
 
    AS $$
40748
 
DECLARE
40749
 
  _s RECORD;
40750
 
 
40751
 
BEGIN
40752
 
 
40753
 
  IF (pidType = 'I') THEN
40754
 
    --  Check for a custtype specific rule
40755
 
    SELECT salesaccnt_id,
40756
 
           CASE WHEN (salesaccnt_warehous_id<>-1) THEN 1 ELSE 0 END +
40757
 
           CASE WHEN (salesaccnt_custtype_id<>-1) THEN 2 ELSE 0 END +
40758
 
           CASE WHEN (salesaccnt_prodcat_id<>-1) THEN 3 ELSE 0 END +
40759
 
           CASE WHEN (salesaccnt_shipzone_id<>-1) THEN 4 ELSE 0 END +
40760
 
           CASE WHEN (salesaccnt_saletype_id<>-1) THEN 5 ELSE 0 END AS orderby
40761
 
    INTO _s
40762
 
    FROM salesaccnt, item, prodcat, custinfo, custtype
40763
 
    WHERE ( (salesaccnt_warehous_id=-1)
40764
 
      AND  (item_prodcat_id=prodcat_id)
40765
 
      AND  (cust_custtype_id=custtype_id)
40766
 
      AND  ( (salesaccnt_prodcat='.*') OR
40767
 
            ( (salesaccnt_prodcat_id=-1) AND
40768
 
              (salesaccnt_prodcat<>'') AND
40769
 
              (prodcat_code ~ salesaccnt_prodcat) ) OR
40770
 
            ( (salesaccnt_prodcat_id=prodcat_id) ) )
40771
 
      AND  ( (salesaccnt_custtype='.*') OR
40772
 
            ( (salesaccnt_custtype_id=-1) AND
40773
 
              (salesaccnt_custtype<>'') AND
40774
 
              (custtype_code ~ salesaccnt_custtype) ) OR
40775
 
            ( (salesaccnt_custtype_id=custtype_id) ) )
40776
 
      AND  ( (salesaccnt_shipzone_id=-1) OR
40777
 
             (salesaccnt_shipzone_id=pShipzoneid) )
40778
 
      AND  ( (salesaccnt_saletype_id=-1) OR
40779
 
             (salesaccnt_saletype_id=pSaletypeid) )
40780
 
      AND (item_id=pid)
40781
 
      AND (cust_id=pCustid) )
40782
 
    ORDER BY orderby DESC, salesaccnt_custtype DESC, salesaccnt_prodcat DESC,
40783
 
             salesaccnt_saletype_id DESC, salesaccnt_shipzone_id DESC
40784
 
     LIMIT 1;
40785
 
 
40786
 
  ELSIF (pidType = 'IS') THEN
40787
 
    --  Check for a custtype specific rule
40788
 
    SELECT salesaccnt_id,
40789
 
           CASE WHEN (salesaccnt_warehous_id<>-1) THEN 1 ELSE 0 END +
40790
 
           CASE WHEN (salesaccnt_custtype_id<>-1) THEN 2 ELSE 0 END +
40791
 
           CASE WHEN (salesaccnt_prodcat_id<>-1) THEN 3 ELSE 0 END +
40792
 
           CASE WHEN (salesaccnt_shipzone_id<>-1) THEN 4 ELSE 0 END +
40793
 
           CASE WHEN (salesaccnt_saletype_id<>-1) THEN 5 ELSE 0 END AS orderby
40794
 
    INTO _s
40795
 
    FROM salesaccnt, itemsite, item, prodcat, custinfo, custtype
40796
 
    WHERE ( ( (salesaccnt_warehous_id=-1) OR
40797
 
              (salesaccnt_warehous_id=itemsite_warehous_id) )
40798
 
     AND (itemsite_item_id=item_id)
40799
 
     AND (item_prodcat_id=prodcat_id)
40800
 
     AND (cust_custtype_id=custtype_id)
40801
 
     AND ( (salesaccnt_prodcat='.*') OR
40802
 
           ( (salesaccnt_prodcat_id=-1) AND
40803
 
             (salesaccnt_prodcat<>'') AND
40804
 
             (prodcat_code ~ salesaccnt_prodcat) ) OR
40805
 
           ( (salesaccnt_prodcat_id=prodcat_id) ) )
40806
 
     AND ( (salesaccnt_custtype='.*') OR
40807
 
           ( (salesaccnt_custtype_id=-1) AND
40808
 
             (salesaccnt_custtype<>'') AND
40809
 
             (custtype_code ~ salesaccnt_custtype) ) OR
40810
 
           ( (salesaccnt_custtype_id=custtype_id) ) )
40811
 
     AND  ( (salesaccnt_shipzone_id=-1) OR
40812
 
            (salesaccnt_shipzone_id=pShipzoneid) )
40813
 
     AND  ( (salesaccnt_saletype_id=-1) OR
40814
 
            (salesaccnt_saletype_id=pSaletypeid) )
40815
 
     AND (itemsite_id=pid)
40816
 
     AND (cust_id=pCustid) ) 
40817
 
    ORDER BY orderby DESC, salesaccnt_custtype DESC, salesaccnt_prodcat DESC, salesaccnt_warehous_id DESC,
40818
 
             salesaccnt_saletype_id DESC, salesaccnt_shipzone_id DESC
40819
 
    LIMIT 1;
40820
 
 
40821
 
  ELSE
40822
 
    RETURN -2;  -- invalid pidType
40823
 
  END IF;
40824
 
 
40825
 
  IF (FOUND) THEN
40826
 
    RETURN _s.salesaccnt_id;
40827
 
  END IF;
40828
 
 
40829
 
  RETURN -1;
40830
 
 
40831
 
END;
40832
 
$$;
40833
 
 
40834
 
 
40835
 
ALTER FUNCTION public.findsalesaccnt(pid integer, pidtype text, pcustid integer, psaletypeid integer, pshipzoneid integer) OWNER TO admin;
40836
 
 
40837
 
--
40838
 
--
40839
 
 
40840
 
CREATE FUNCTION findspecialfinancial(text, text, integer) RETURNS numeric
40841
 
    LANGUAGE plpgsql
40842
 
    AS $_$
40843
 
DECLARE
40844
 
  pUnit ALIAS FOR $1;
40845
 
  pType ALIAS FOR $2;
40846
 
  pPeriodid ALIAS FOR $3;
40847
 
 
40848
 
  _value NUMERIC;
40849
 
BEGIN
40850
 
 
40851
 
  _value := 0.00;
40852
 
 
40853
 
  IF ('OpenAR' = pType) THEN
40854
 
    IF ( pUnit IN ('D','E') ) THEN
40855
 
      SELECT SUM( CASE WHEN (aropen_doctype IN ('C', 'R')) THEN ((aropen_amount - aropen_paid) * -1)
40856
 
                       ELSE (aropen_amount - aropen_paid) END ) INTO _value
40857
 
        FROM aropen, period
40858
 
       WHERE ((aropen_open)
40859
 
         AND  (aropen_duedate BETWEEN period_start AND period_end)
40860
 
         AND  (period_id=pPeriodid));
40861
 
 
40862
 
      IF ('E' = pUnit) THEN
40863
 
        _value := 0.00 - _value;
40864
 
      END IF;
40865
 
    END IF;
40866
 
  END IF;
40867
 
 
40868
 
  IF ('OpenAP' = pType) THEN
40869
 
    IF ( pUnit IN ('C','E') ) THEN
40870
 
      SELECT SUM( CASE WHEN (apopen_doctype='C') THEN ((apopen_amount - apopen_paid) * -1)
40871
 
                       ELSE (apopen_amount - apopen_paid) END ) INTO _value
40872
 
        FROM apopen, period
40873
 
       WHERE ((apopen_open)
40874
 
         AND  (apopen_duedate BETWEEN period_start AND period_end)
40875
 
         AND  (period_id=pPeriodid));
40876
 
    END IF;
40877
 
  END IF;
40878
 
 
40879
 
  RETURN _value;
40880
 
 
40881
 
END;
40882
 
$_$;
40883
 
 
40884
 
 
40885
 
ALTER FUNCTION public.findspecialfinancial(text, text, integer) OWNER TO admin;
40886
 
 
40887
 
--
40888
 
--
40889
 
 
40890
 
CREATE FUNCTION findxt() RETURNS void
40891
 
    LANGUAGE plpgsql
40892
 
    AS $$
40893
 
BEGIN
40894
 
  IF EXISTS (select relname from pg_class where relname = 'ext')
40895
 
THEN
40896
 
PERFORM xt.js_init();
40897
 
END IF;
40898
 
END;
40899
 
$$;
40900
 
 
40901
 
 
40902
 
ALTER FUNCTION public.findxt() OWNER TO admin;
40903
 
 
40904
 
--
40905
 
--
40906
 
 
40907
 
CREATE FUNCTION first_agg(anyelement, anyelement) RETURNS anyelement
40908
 
    LANGUAGE sql STABLE
40909
 
    AS $_$
40910
 
  SELECT CASE WHEN $1 IS NULL THEN $2 ELSE $1 END;
40911
 
$_$;
40912
 
 
40913
 
 
40914
 
ALTER FUNCTION public.first_agg(anyelement, anyelement) OWNER TO admin;
40915
 
 
40916
 
--
40917
 
--
40918
 
 
40919
 
CREATE FUNCTION firstline(text) RETURNS text
40920
 
    LANGUAGE plpgsql IMMUTABLE
40921
 
    AS $_$
40922
 
DECLARE
40923
 
  pSource ALIAS FOR $1;
40924
 
  _result TEXT := '';
40925
 
 
40926
 
BEGIN
40927
 
  SELECT regexp_replace(pSource, E'^(\r?\n)*([^\r\n]*)\r?\n.*', E'\\2') INTO _result;
40928
 
  RETURN _result;
40929
 
END;
40930
 
$_$;
40931
 
 
40932
 
 
40933
 
ALTER FUNCTION public.firstline(text) OWNER TO admin;
40934
 
 
40935
 
--
40936
 
--
40937
 
 
40938
 
CREATE FUNCTION fixacl() RETURNS integer
40939
 
    LANGUAGE plpgsql
40940
 
    AS $$
40941
 
DECLARE
40942
 
  _r        RECORD;
40943
 
  _count    INTEGER := 0;
40944
 
  _oldgrp   BOOLEAN := false;
40945
 
  _objtype  TEXT;
40946
 
  _table    TEXT;
40947
 
  _schema   TEXT;
40948
 
 
40949
 
BEGIN
40950
 
  IF EXISTS(SELECT 1 FROM pg_group WHERE groname = 'openmfg') THEN
40951
 
    _oldgrp := true;
40952
 
  END IF;
40953
 
  
40954
 
  FOR _r IN SELECT relname, nspname, relkind,
40955
 
                   CASE relkind WHEN 'r' THEN 1
40956
 
                                WHEN 'v' THEN 2
40957
 
                                WHEN 'S' THEN 3
40958
 
                                ELSE 4
40959
 
                   END AS seq
40960
 
            FROM pg_catalog.pg_class c, pg_namespace n
40961
 
            WHERE ((n.oid=c.relnamespace)
40962
 
              AND  (nspname in ('public', 'api') OR
40963
 
                    nspname in (SELECT pkghead_name FROM pkghead))
40964
 
              AND  (relkind in ('S', 'r', 'v')))
40965
 
            ORDER BY seq
40966
 
  LOOP
40967
 
    _schema := quote_ident(_r.nspname);
40968
 
    _table  := quote_ident(_r.relname);
40969
 
 
40970
 
    RAISE DEBUG '%.%', _schema, _table;
40971
 
    
40972
 
    IF (_oldgrp) THEN
40973
 
      EXECUTE 'REVOKE ALL ON ' || _schema || '.' || _table || ' FROM openmfg;';
40974
 
    END IF;
40975
 
    EXECUTE 'REVOKE ALL ON ' || _schema || '.' || _table || ' FROM PUBLIC;';
40976
 
    EXECUTE 'GRANT ALL ON '  || _schema || '.' || _table || ' TO GROUP xtrole;';
40977
 
    _count := _count + 1;
40978
 
 
40979
 
    _objtype := CASE _r.relkind WHEN 'S' THEN 'SEQUENCE'
40980
 
                                WHEN 'r' THEN 'TABLE'
40981
 
                                WHEN 'v' THEN 'VIEW'
40982
 
                                ELSE NULL
40983
 
                END;
40984
 
    IF (_objtype IS NOT NULL) THEN
40985
 
      BEGIN
40986
 
        EXECUTE 'ALTER ' || _objtype || ' ' ||
40987
 
                _schema || '.' || _table || ' OWNER TO admin;';
40988
 
      EXCEPTION WHEN OTHERS THEN
40989
 
        RAISE WARNING 'Could not change ownership of %.% to admin',
40990
 
                      _schema, _table;
40991
 
      END;
40992
 
    END IF;
40993
 
 
40994
 
  END LOOP;
40995
 
 
40996
 
  RETURN _count;
40997
 
END;
40998
 
$$;
40999
 
 
41000
 
 
41001
 
ALTER FUNCTION public.fixacl() OWNER TO admin;
41002
 
 
41003
 
--
41004
 
--
41005
 
 
41006
 
CREATE FUNCTION formatabachecks(integer, integer, text) RETURNS SETOF achline
41007
 
    LANGUAGE plpgsql
41008
 
    AS $_$
41009
 
DECLARE
41010
 
  pbankaccntid     ALIAS FOR $1;   -- all unprinted checks for this bankaccnt
41011
 
  pcheckheadid     ALIAS FOR $2;   -- but if 2nd arg not null then just 1 check
41012
 
  penckey          ALIAS FOR $3;
41013
 
  _bank            RECORD;
41014
 
  _batchcount      INTEGER := 0;
41015
 
  _batchdate       DATE;
41016
 
  _check           RECORD;
41017
 
  _vendnumber      TEXT;
41018
 
  _vendname        TEXT;
41019
 
  _filenum         TEXT;
41020
 
  _prevsec         TEXT;
41021
 
  _row             achline%ROWTYPE;
41022
 
  _totalcr         NUMERIC := 0;
41023
 
  _totaldb         NUMERIC := 0;
41024
 
  _detailcount     INTEGER := 0;     -- count of type 1 entries
41025
 
  _vendbsb         TEXT;
41026
 
 
41027
 
BEGIN
41028
 
  -- General notes:
41029
 
  -- Numeric values are formatted using RPAD(TO_CHAR(#, '0..0SG', #)).
41030
 
  --    TO_CHAR(#, ...) (at least in the default server locale) puts a space at
41031
 
  --    the beginning of the string for numbers >= 0 and '-' for numbers < 0.
41032
 
  --    'SG' pushes the sign char to the end, then RPAD cuts it off.
41033
 
  -- This whole thing is for Australian bank transactions only, and generates entries for an ABA file.
41034
 
  -- Currently restricted to checks to Vendor; there's no support for checks to
41035
 
  --    customers or tax authorities, or for debits or corrections.
41036
 
  -- This function has been adapted from the US-centric ACH formatACHChecks function.
41037
 
 
41038
 
  IF (NOT fetchMetricBool('ACHEnabled')) THEN
41039
 
    RAISE EXCEPTION 'Cannot format the ABA file because the system is not configured for ABA file generation.';
41040
 
  END IF;
41041
 
  IF (LENGTH(COALESCE(penckey, '')) <= 0) THEN
41042
 
    RAISE EXCEPTION 'Cannot format the ABA file because there is no encryption key.';
41043
 
  END IF;
41044
 
 
41045
 
  SELECT * INTO _bank
41046
 
  FROM bankaccnt
41047
 
  WHERE (bankaccnt_id=pbankaccntid);
41048
 
 
41049
 
  IF (NOT FOUND) THEN
41050
 
    RAISE EXCEPTION 'Could not find the bank information to create the ABA file.';
41051
 
  ELSIF (NOT _bank.bankaccnt_ach_enabled) THEN
41052
 
    RAISE EXCEPTION 'Cannot format the ABA file because the Bank Account % is not configured for ABA transactions.',
41053
 
      _bank.bankaccnt_name;
41054
 
  ELSIF (LENGTH(COALESCE(_bank.bankaccnt_routing, '')) <= 0) THEN 
41055
 
    RAISE EXCEPTION 'Cannot format the ABA file because the Bank Account % has no BSB number.', _bank.bankaccnt_name;
41056
 
  END IF;
41057
 
 
41058
 
  -- Check the BSB number is in the right format and then re-format for output.
41059
 
  -- Valid format is \d{3}-\d{3}|\d{6}000
41060
 
  IF (_bank.bankaccnt_routing ~ E'^(\\d{3})(?:-(?=\\d{3}$)|(?=\\d{3}0{3}$))(\\d{3})(0{3})?$') THEN
41061
 
    _bank.bankaccnt_routing := regexp_replace(
41062
 
      _bank.bankaccnt_routing,
41063
 
      E'^(\\d{3})(?:-(?=\\d{3}$)|(?=\\d{3}0{3}$))(\\d{3})(0{3})?$', E'\\1-\\2'
41064
 
    );
41065
 
  ELSE RAISE EXCEPTION 'Cannot format the ABA file because the Bank Account % has an invalid BSB number.',
41066
 
    _bank.bankaccnt_name;
41067
 
  END IF;
41068
 
 
41069
 
 
41070
 
  _filenum := LPAD(fetchNextNumber('ACHBatch'), 8, '0');
41071
 
 
41072
 
  IF (COALESCE(_bank.bankaccnt_ach_lastdate,startOfTime()) < CURRENT_DATE
41073
 
    OR _bank.bankaccnt_ach_lastfileid IS NULL) THEN
41074
 
    _bank.bankaccnt_ach_lastfileid = '0';
41075
 
  ELSIF (_bank.bankaccnt_ach_lastfileid = '9') THEN
41076
 
    _bank.bankaccnt_ach_lastfileid = 'A';
41077
 
  ELSIF (_bank.bankaccnt_ach_lastfileid = 'Z') THEN
41078
 
    RAISE EXCEPTION 'Cannot write % check % to an ABA file because too many files have been written for this bank already today.',
41079
 
      _bank.bankaccnt_name, _check.checkhead_number;
41080
 
  ELSE
41081
 
    _bank.bankaccnt_ach_lastfileid = CHR(ASCII(_bank.bankaccnt_ach_lastfileid) + 1);
41082
 
  END IF;
41083
 
  
41084
 
 
41085
 
  _row.achline_checkhead_id := NULL;
41086
 
  _row.achline_batch := _filenum;
41087
 
  _row.achline_type := 'HEADER';
41088
 
  _row.achline_value := RPAD(
41089
 
    RPAD('0',18)                                    -- Record Type 0 blank filled with 17 spaces
41090
 
    || '01'                                         -- Reel sequence number 
41091
 
    || RPAD(_bank.bankaccnt_bankname,3)             -- Approved financial instition abbreviation.
41092
 
    || RPAD('',7)                                   -- blank filled
41093
 
    || RPAD(fetchMetricText('ACHCompanyName'), 26)  -- Name of user supplying ABA file
41094
 
    || LPAD(fetchMetricText('ACHCompanyId'),6)      -- User identification number APCA issued
41095
 
    || RPAD('PAYMENT',12)                           -- description of entries on file
41096
 
                                                    --  currently only use payment description
41097
 
    || TO_CHAR(CURRENT_DATE,      'DDMMYY'),        -- date to be processed
41098
 
    120                                             -- blank filled to 120 characters
41099
 
  );
41100
 
  RETURN NEXT _row;
41101
 
 
41102
 
  FOR _check IN SELECT *
41103
 
    FROM checkhead
41104
 
    JOIN vendinfo ON (checkhead_recip_type='V'
41105
 
      AND checkhead_recip_id=vend_id
41106
 
      AND vend_ach_enabled)
41107
 
    JOIN curr_symbol ON (checkhead_curr_id=curr_id)
41108
 
    LEFT OUTER JOIN crmacct ON (crmacct_vend_id=vend_id)
41109
 
    WHERE ((checkhead_bankaccnt_id=pbankaccntid)
41110
 
      AND (checkhead_amount > 0)
41111
 
      AND (checkhead_id=pcheckheadid OR pcheckheadid IS NULL)
41112
 
      AND NOT checkhead_posted
41113
 
      AND NOT checkhead_replaced
41114
 
      AND NOT checkhead_deleted
41115
 
      AND NOT checkhead_void
41116
 
      AND NOT checkhead_printed
41117
 
      AND (LENGTH(COALESCE(checkhead_ach_batch,'')) <= 0)
41118
 
      AND (curr_abbr='AUD'))
41119
 
    ORDER BY checkhead_checkdate, vend_name LOOP
41120
 
 
41121
 
    IF (COALESCE(_check.checkhead_number, -1) <= 0
41122
 
      AND _bank.bankaccnt_ach_genchecknum) THEN
41123
 
        _check.checkhead_number := fetchNextCheckNumber(_check.checkhead_bankaccnt_id);
41124
 
    END IF;
41125
 
 
41126
 
    -- Although a crmacct record is not required for used in this function
41127
 
    -- this code is retained for consistancy with the original formatachchecks function.
41128
 
    IF (_check.crmacct_id IS NULL) THEN
41129
 
      RAISE NOTICE 'Vendor % does not have a corresponding crmacct record.',
41130
 
        _check.checkhead_recip_id;
41131
 
    ELSIF (_check.crmacct_type IS NULL) THEN
41132
 
      RAISE NOTICE 'crmacct for vendor % does not have a valid crmacct_type.',
41133
 
         _check.checkhead_recip_id;
41134
 
    END IF;
41135
 
 
41136
 
    _vendnumber := CASE WHEN _check.vend_ach_use_vendinfo THEN _check.vend_number
41137
 
      ELSE _check.vend_ach_indiv_number
41138
 
      END;
41139
 
    _vendname := CASE WHEN _check.vend_ach_use_vendinfo THEN _check.vend_name
41140
 
      ELSE _check.vend_ach_indiv_name
41141
 
      END;
41142
 
 
41143
 
    IF (COALESCE(_check.vend_ach_routingnumber, '') = '') THEN
41144
 
      RAISE EXCEPTION 'Cannot write % check % to an ABA file because the BSB number for % has not been supplied.',
41145
 
        _bank.bankaccnt_name, _check.checkhead_number, _vendnumber;
41146
 
    ELSIF (COALESCE(_check.vend_ach_accntnumber, '') = '') THEN
41147
 
      RAISE EXCEPTION 'Cannot write % check % to an ABA file because the account number for % has not been supplied.',
41148
 
        _bank.bankaccnt_name, _check.checkhead_number, _vendnumber;
41149
 
    END IF;
41150
 
    _check.vend_ach_routingnumber := decrypt(setbytea(_check.vend_ach_routingnumber),
41151
 
      setbytea(penckey), 'bf');
41152
 
    _check.vend_ach_accntnumber   := decrypt(setbytea(_check.vend_ach_accntnumber),
41153
 
      setbytea(penckey), 'bf');
41154
 
    
41155
 
    -- Check the BSB number is in the right format and then re-format for output.
41156
 
    -- Valid format is \d{3}-\d{3}|\d{6}000
41157
 
    IF (formatbytea(_check.vend_ach_routingnumber) ~ E'^(\\d{3})(?:-(?=\\d{3}$)|(?=\\d{3}0{3}$))(\\d{3})(0{3})?$') THEN
41158
 
      _vendbsb := regexp_replace(
41159
 
        formatbytea(_check.vend_ach_routingnumber),
41160
 
        E'^(\\d{3})(?:-(?=\\d{3}$)|(?=\\d{3}0{3}$))(\\d{3})(0{3})?$', E'\\1-\\2'
41161
 
      );
41162
 
    ELSE RAISE EXCEPTION 'Cannot write % check % to an ABA file because the BSB number for % is not valid.',
41163
 
      _bank.bankaccnt_name, _check.checkhead_number, _vendnumber;
41164
 
    END IF;
41165
 
 
41166
 
    _row.achline_checkhead_id := _check.checkhead_id;
41167
 
    _row.achline_batch        := _filenum;
41168
 
    _row.achline_type         := 'DETAIL';
41169
 
 
41170
 
    _totaldb      := _totaldb + _check.checkhead_amount;                -- Total debits for balancing entry
41171
 
    _detailcount  := _detailcount + 1;                                  -- Detail record counter (type 1)
41172
 
    _totalcr      := _totalcr + _check.checkhead_amount;                -- Total credits from payments
41173
 
                                                                        
41174
 
    _row.achline_value := RPAD('1'                                      -- record type 1
41175
 
      || _vendbsb                                                       -- vendor BSB #
41176
 
      || LPAD(formatbytea(_check.vend_ach_accntnumber), 9)              -- vendor account no.
41177
 
      ||' '                                                             -- withholding tax indicator
41178
 
      ||'50'                                                            -- transaction code, this should be calculated.
41179
 
      || LPAD(to_char(_check.checkhead_amount,'FM99999999V99'),10,'0')  -- amount
41180
 
      || RPAD(_vendname,   32)                                          -- vendor name
41181
 
      || RPAD('Deposit',8) || RPAD('#'  , 2) || LPAD (_filenum,8,' ')   -- Lodgement Reference
41182
 
      || _bank.bankaccnt_routing                                        -- BSB #
41183
 
      || RPAD(_bank.bankaccnt_accntnumber, 9)                           -- company account number
41184
 
      || RPAD(fetchMetricText('ACHCompanyName'), 16)                    -- company account name
41185
 
      || LPAD('', 8, '0'),                                              -- Witholding Tax Amount
41186
 
      120                                                               -- line width
41187
 
    );
41188
 
    RETURN NEXT _row;
41189
 
 
41190
 
    UPDATE checkhead
41191
 
    SET checkhead_ach_batch=_filenum,
41192
 
      checkhead_number=_check.checkhead_number
41193
 
    WHERE (checkhead_id=_check.checkhead_id);
41194
 
 
41195
 
  END LOOP;
41196
 
 
41197
 
  IF (NOT FOUND) THEN
41198
 
    RAISE EXCEPTION 'Cannot write an ABA file for % because there are no checks pending in AUD for EFT-enabled Vendors.',
41199
 
      _bank.bankaccnt_name;
41200
 
  END IF;
41201
 
 
41202
 
  -- Place a final balancing detail record.
41203
 
  -- Check that the balancing record actually balances.
41204
 
  IF (_totalcr != _totaldb) THEN
41205
 
    RAISE EXCEPTION 'Cannot write an ABA file for % because the total credits: % does not equal the total debits: %, file will not balance.',
41206
 
    _bank.bankaccnt_name, _totalcr, _totaldb;
41207
 
  END IF;
41208
 
  
41209
 
 
41210
 
  _detailcount := _detailcount + 1;
41211
 
  _row.achline_checkhead_id := NULL;
41212
 
  _row.achline_batch := _filenum;
41213
 
  _row.achline_type := 'BALANCING';
41214
 
  -- keep in sync with the other batchcontrol record format above
41215
 
  -- THE FOLLOWING IS THE DEBIT BALANCING RECORD
41216
 
  _row.achline_value := RPAD('1'                          -- record type 1
41217
 
    || _bank.bankaccnt_routing                            -- Austalian BSB #
41218
 
    || LPAD(_bank.bankaccnt_accntnumber, 9)               -- company account no.
41219
 
    || ' '                                                -- withholding tax indicator
41220
 
    || '13'                                               -- transaction code
41221
 
    || to_char(_totaldb,'FM09999999V99')                  -- the balancing amount
41222
 
    || RPAD(fetchMetricText('ACHCompanyName'),   32)      -- company name
41223
 
    || RPAD('DIRECT DEPOSIT',18)                          
41224
 
    || _bank.bankaccnt_routing                            -- Austalian BSB #
41225
 
    || RPAD(_bank.bankaccnt_accntnumber, 9)               -- company account number
41226
 
    || RPAD(fetchMetricText('ACHCompanyName'), 16)        -- company account name
41227
 
    || LPAD('', 8, '0'),                                  -- Witholding Tax Amount
41228
 
    120                                                   -- line width
41229
 
  );
41230
 
  RETURN NEXT _row;
41231
 
 
41232
 
  RAISE DEBUG 'formatABAChecks building TRAILER with _totaldb %, _totalcr %, _detailcount %',
41233
 
               _totaldb, _totalcr, _detailcount;
41234
 
  -- file control record
41235
 
  _row.achline_checkhead_id := NULL;
41236
 
  _row.achline_batch := _filenum;
41237
 
  _row.achline_type := 'TRAILER';
41238
 
  _row.achline_value := RPAD('7'                                    -- record type 7
41239
 
    || RPAD('999-999',   7)                                         -- BSB format filler
41240
 
    || RPAD('' , 12)                                                -- blank
41241
 
    || LPAD(to_char((_totaldb - _totalcr),'FM09999999V99'),10,'0')  -- net total amount
41242
 
    || LPAD(to_char(_totalcr, 'FM09999999V99'),10,'0')              -- total credit amount
41243
 
    || LPAD(to_char(_totaldb, 'FM09999999V99'),10,'0')              -- total debit amount
41244
 
    || RPAD('', 24)                                                 -- blank
41245
 
    || RPAD(to_char(_detailcount, 'FM000000'), 6,'0'),              -- count of type 1 records
41246
 
    120                                                             -- blank fill
41247
 
  );
41248
 
 
41249
 
  RETURN NEXT _row;
41250
 
 
41251
 
 
41252
 
  UPDATE bankaccnt
41253
 
  SET bankaccnt_ach_lastdate=CURRENT_DATE,
41254
 
    bankaccnt_ach_lastfileid=_bank.bankaccnt_ach_lastfileid
41255
 
  WHERE (bankaccnt_id=_bank.bankaccnt_id);
41256
 
 
41257
 
  RETURN;
41258
 
 
41259
 
END;
41260
 
$_$;
41261
 
 
41262
 
 
41263
 
ALTER FUNCTION public.formatabachecks(integer, integer, text) OWNER TO admin;
41264
 
 
41265
 
--
41266
 
--
41267
 
 
41268
 
CREATE FUNCTION formatachchecks(integer, integer, text) RETURNS SETOF achline
41269
 
    LANGUAGE plpgsql
41270
 
    AS $_$
41271
 
DECLARE
41272
 
  pbankaccntid     ALIAS FOR $1;   -- all unprinted checks for this bankaccnt
41273
 
  pcheckheadid     ALIAS FOR $2;   -- but if 2nd arg not null then just 1 check
41274
 
  penckey          ALIAS FOR $3;
41275
 
  _bank            RECORD;
41276
 
  _batchcount      INTEGER := 0;
41277
 
  _batchcr         NUMERIC := 0;
41278
 
  _batchdate       DATE;
41279
 
  _batchdb         NUMERIC := 0;
41280
 
  _batchhash       INTEGER := 0;
41281
 
  _check           RECORD;
41282
 
  _ccdnumber       TEXT;
41283
 
  _ccdname         TEXT;
41284
 
  _entrycount      INTEGER := 0;
41285
 
  _filenum         TEXT;
41286
 
  _prevsec         TEXT;
41287
 
  _row             achline%ROWTYPE;
41288
 
  _rowcount        INTEGER := 0;
41289
 
  _sec             TEXT;
41290
 
  _serviceclass    TEXT := '200';    -- 220 = credits, 225 = debits, 200 = mixed
41291
 
  _totalcr         NUMERIC := 0;
41292
 
  _totaldb         NUMERIC := 0;
41293
 
  _totalentrycnt   INTEGER := 0;
41294
 
  _totalhash       INTEGER := 0;
41295
 
  _transactionprefix TEXT;
41296
 
 
41297
 
BEGIN
41298
 
  -- General notes:
41299
 
  -- Numeric values are formatted using RPAD(TO_CHAR(#, '0..0SG', #)).
41300
 
  --    TO_CHAR(#, ...) (at least in the default server locale) puts a space at
41301
 
  --    the beginning of the string for numbers >= 0 and '-' for numbers < 0.
41302
 
  --    'SG' pushes the sign char to the end, then RPAD cuts it off.
41303
 
  -- This whole thing is US-centric, as that's where the NACHA is.
41304
 
  -- Currently restricted to checks to Vendor; there's no support for checks to
41305
 
  --    customers or tax authorities, or for debits or corrections.
41306
 
 
41307
 
  IF (NOT fetchMetricBool('ACHEnabled')) THEN
41308
 
    RAISE EXCEPTION 'Cannot format the ACH file because the system is not configured for ACH file generation.';
41309
 
  END IF;
41310
 
  IF (LENGTH(COALESCE(penckey, '')) <= 0) THEN
41311
 
    RAISE EXCEPTION 'Cannot format the ACH file because there is no encryption key.';
41312
 
  END IF;
41313
 
 
41314
 
  SELECT * INTO _bank
41315
 
  FROM bankaccnt
41316
 
  WHERE (bankaccnt_id=pbankaccntid);
41317
 
 
41318
 
  IF (NOT FOUND) THEN
41319
 
    RAISE EXCEPTION 'Could not find the bank information to create the ACH file.';
41320
 
  ELSIF (NOT _bank.bankaccnt_ach_enabled) THEN
41321
 
    RAISE EXCEPTION 'Cannot format the ACH file because the Bank Account % is not configured for ACH transactions.',
41322
 
      _bank.bankaccnt_name;
41323
 
  ELSIF (LENGTH(COALESCE(_bank.bankaccnt_routing, '')) <= 0) THEN 
41324
 
    RAISE EXCEPTION 'Cannot format the ACH file because the Bank Account % has no routing number.',
41325
 
      _bank.bankaccnt_name;
41326
 
  END IF;
41327
 
 
41328
 
  _filenum := LPAD(fetchNextNumber('ACHBatch'), 8, '0');
41329
 
 
41330
 
  IF (COALESCE(_bank.bankaccnt_ach_lastdate,startOfTime()) < CURRENT_DATE
41331
 
      OR _bank.bankaccnt_ach_lastfileid IS NULL) THEN
41332
 
    _bank.bankaccnt_ach_lastfileid = '0';
41333
 
  ELSIF (_bank.bankaccnt_ach_lastfileid = '9') THEN
41334
 
    _bank.bankaccnt_ach_lastfileid = 'A';
41335
 
  ELSIF (_bank.bankaccnt_ach_lastfileid = 'Z') THEN
41336
 
    RAISE EXCEPTION 'Cannot write % check % to an ACH file because too many files have been written for this bank already today.',
41337
 
                  _bank.bankaccnt_name, _check.checkhead_number;
41338
 
  ELSE
41339
 
    _bank.bankaccnt_ach_lastfileid = CHR(ASCII(_bank.bankaccnt_ach_lastfileid) + 1);
41340
 
  END IF;
41341
 
 
41342
 
  _rowcount := _rowcount + 1;
41343
 
  _row.achline_checkhead_id := NULL;
41344
 
  _row.achline_batch := _filenum;
41345
 
  _row.achline_type := 'FILEHEADER';
41346
 
  _row.achline_value := RPAD('1'
41347
 
                          || '01'
41348
 
                          || RPAD(CASE WHEN _bank.bankaccnt_ach_desttype = 'B' THEN ' ' || _bank.bankaccnt_routing
41349
 
                                       WHEN _bank.bankaccnt_ach_desttype = 'F' THEN ' ' || _bank.bankaccnt_ach_fed_dest
41350
 
                                       ELSE _bank.bankaccnt_ach_dest END, 10)
41351
 
                          || RPAD(CASE WHEN _bank.bankaccnt_ach_origintype = 'B' THEN ' ' || _bank.bankaccnt_routing
41352
 
                                       WHEN _bank.bankaccnt_ach_origintype = 'I' THEN formatAchCompanyId()
41353
 
                                       ELSE _bank.bankaccnt_ach_origin END, 10)
41354
 
                          || TO_CHAR(CURRENT_DATE,      'YYMMDD')
41355
 
                          || TO_CHAR(CURRENT_TIMESTAMP, 'HH24MM')
41356
 
                          || UPPER(_bank.bankaccnt_ach_lastfileid)
41357
 
                          || '094'
41358
 
                          || '10'
41359
 
                          || '1'
41360
 
                          || RPAD(CASE WHEN _bank.bankaccnt_ach_desttype = 'B' THEN _bank.bankaccnt_bankname
41361
 
                                       WHEN _bank.bankaccnt_ach_desttype = 'F' THEN 'Federal Reserve'
41362
 
                                       ELSE _bank.bankaccnt_ach_destname END, 23)
41363
 
                          || RPAD(CASE WHEN _bank.bankaccnt_ach_origintype = 'B' THEN ' ' || _bank.bankaccnt_bankname
41364
 
                                       WHEN _bank.bankaccnt_ach_origintype = 'I' THEN fetchMetricText('ACHCompanyName')
41365
 
                                       ELSE _bank.bankaccnt_ach_originname END, 23)
41366
 
                          || RPAD(_filenum, 8),
41367
 
                          94);
41368
 
  RETURN NEXT _row;
41369
 
 
41370
 
  FOR _check IN SELECT *
41371
 
                FROM checkhead
41372
 
                JOIN vendinfo ON (checkhead_recip_type='V'
41373
 
                              AND checkhead_recip_id=vend_id
41374
 
                              AND vend_ach_enabled)
41375
 
                JOIN curr_symbol ON (checkhead_curr_id=curr_id)
41376
 
                LEFT OUTER JOIN crmacct ON (crmacct_vend_id=vend_id)
41377
 
                WHERE ((checkhead_bankaccnt_id=pbankaccntid)
41378
 
                   AND (checkhead_amount > 0)
41379
 
                   AND (checkhead_id=pcheckheadid OR pcheckheadid IS NULL)
41380
 
                   AND NOT checkhead_posted
41381
 
                   AND NOT checkhead_replaced
41382
 
                   AND NOT checkhead_deleted
41383
 
                   AND NOT checkhead_void
41384
 
                   AND NOT checkhead_printed
41385
 
                   AND (LENGTH(COALESCE(checkhead_ach_batch,'')) <= 0)
41386
 
                   AND (curr_abbr='USD'))
41387
 
                ORDER BY checkhead_checkdate, vend_name LOOP
41388
 
 
41389
 
    IF (COALESCE(_check.checkhead_number, -1) <= 0
41390
 
        AND _bank.bankaccnt_ach_genchecknum) THEN
41391
 
      _check.checkhead_number := fetchNextCheckNumber(_check.checkhead_bankaccnt_id);
41392
 
    END IF;
41393
 
 
41394
 
    _prevsec := _sec;
41395
 
 
41396
 
    IF (_check.crmacct_type = 'I') THEN
41397
 
      _sec := 'PPD';
41398
 
    ELSE
41399
 
      _sec := 'CCD';
41400
 
      IF (_check.crmacct_id IS NULL) THEN
41401
 
        RAISE NOTICE 'Vendor % does not have a corresponding crmacct record.',
41402
 
                     _check.checkhead_recip_id;
41403
 
      ELSIF (_check.crmacct_type IS NULL) THEN
41404
 
        RAISE NOTICE 'crmacct for vendor % does not have a valid crmacct_type.',
41405
 
                     _check.checkhead_recip_id;
41406
 
      END IF;
41407
 
    END IF;
41408
 
 
41409
 
    _ccdnumber := CASE WHEN _check.vend_ach_use_vendinfo THEN _check.vend_number
41410
 
                       ELSE _check.vend_ach_indiv_number
41411
 
                  END;
41412
 
    _ccdname := CASE WHEN _check.vend_ach_use_vendinfo THEN _check.vend_name
41413
 
                     ELSE _check.vend_ach_indiv_name
41414
 
                END;
41415
 
 
41416
 
    IF (COALESCE(_check.vend_ach_routingnumber, '') = '') THEN
41417
 
      RAISE EXCEPTION 'Cannot write % check % to an ACH file because the routing number for % has not been supplied.',
41418
 
                  _bank.bankaccnt_name, _check.checkhead_number, _ccdnumber;
41419
 
    ELSIF (COALESCE(_check.vend_ach_accntnumber, '') = '') THEN
41420
 
      RAISE EXCEPTION 'Cannot write % check % to an ACH file because the account number for % has not been supplied.',
41421
 
                  _bank.bankaccnt_name, _check.checkhead_number, _ccdnumber;
41422
 
    END IF;
41423
 
    _check.vend_ach_routingnumber := decrypt(setbytea(_check.vend_ach_routingnumber),
41424
 
                                         setbytea(penckey), 'bf');
41425
 
    _check.vend_ach_accntnumber   := decrypt(setbytea(_check.vend_ach_accntnumber),
41426
 
                                         setbytea(penckey), 'bf');
41427
 
    _transactionprefix := CASE WHEN (_check.vend_ach_accnttype = 'K') THEN '2'
41428
 
                               WHEN (_check.vend_ach_accnttype = 'C') THEN '3'
41429
 
                          END;
41430
 
 
41431
 
    -- create separate batches for each check date and for PPD vs CCD
41432
 
    IF (COALESCE(_batchdate, startOfTime()) != _check.checkhead_checkdate
41433
 
        OR (_prevsec != _sec)) THEN
41434
 
      IF (_batchcount > 0) THEN
41435
 
        _rowcount := _rowcount + 1;
41436
 
        _row.achline_checkhead_id := NULL;
41437
 
        _row.achline_batch := _filenum;
41438
 
        _row.achline_type := 'BATCHCONTROL';
41439
 
        -- keep in sync with the other batchcontrol record format below
41440
 
        _row.achline_value := RPAD('8'
41441
 
                                || _serviceclass
41442
 
                                || RPAD(TO_CHAR(_entrycount, '000000SG'), 6)
41443
 
                                || RPAD(TO_CHAR(_batchhash % 10000000000,
41444
 
                                                '0000000000SG'), 10)
41445
 
                                || RPAD(TO_CHAR(_batchdb, '0000000000V99SG'), 12)
41446
 
                                || RPAD(TO_CHAR(_batchcr, '0000000000V99SG'), 12)
41447
 
                                || RPAD(formatAchCompanyId(), 10)
41448
 
                                || RPAD(' ', 19)
41449
 
                                || RPAD(' ',  6)
41450
 
                                || RPAD(_bank.bankaccnt_routing, 8)
41451
 
                                || RPAD(TO_CHAR(_batchcount, '0000000SG'), 7),
41452
 
                                94);
41453
 
        RETURN NEXT _row;
41454
 
      END IF;
41455
 
 
41456
 
      _batchhash     := 0;
41457
 
      _batchcr       := 0;
41458
 
      _batchdb       := 0;
41459
 
      _batchdate     := _check.checkhead_checkdate;
41460
 
      _entrycount    := 0;
41461
 
      _rowcount      := _rowcount + 1;
41462
 
      _batchcount    := _batchcount + 1;
41463
 
      _row.achline_checkhead_id := NULL;
41464
 
      _row.achline_batch := _filenum;
41465
 
      _row.achline_type := 'BATCHHEADER';
41466
 
 
41467
 
      -- effective entry date = 1 or 2 banking days after the banking day
41468
 
      -- of processing (the following accounts for weekends but not holidays)
41469
 
 
41470
 
      _row.achline_value := RPAD('5'
41471
 
                              || _serviceclass
41472
 
                              || RPAD(fetchMetricText('ACHCompanyName'), 16)
41473
 
                              || RPAD('', 20)   -- TODO: find a use
41474
 
                              || RPAD(formatAchCompanyId(), 10)
41475
 
                              || _sec
41476
 
                              || RPAD('xTuple ERP', 10)
41477
 
                              || TO_CHAR(_check.checkhead_checkdate, 'YYMMDD')
41478
 
                              || TO_CHAR(CURRENT_DATE +
41479
 
                                         COALESCE(_bank.bankaccnt_ach_leadtime,1) +
41480
 
                                         CASE WHEN EXTRACT(DOW FROM CURRENT_DATE) = 5 THEN 2
41481
 
                                              WHEN EXTRACT(DOW FROM CURRENT_DATE) = 6 THEN 1
41482
 
                                              ELSE 0 END,
41483
 
                                         'YYMMDD')
41484
 
                              || RPAD('', 3)
41485
 
                              || '1'
41486
 
                              || RPAD(_bank.bankaccnt_routing, 8)
41487
 
                              || RPAD(TO_CHAR(_batchcount, '0000000SG'), 7),
41488
 
                              94);
41489
 
      RETURN NEXT _row;
41490
 
    END IF;
41491
 
 
41492
 
    _row.achline_checkhead_id := _check.checkhead_id;
41493
 
    _row.achline_batch        := _filenum;
41494
 
    _row.achline_type         := _sec;
41495
 
 
41496
 
    IF (_sec = 'CCD' OR _sec = 'PPD') THEN
41497
 
      _rowcount      := _rowcount + 1;
41498
 
      _entrycount    := _entrycount + 1;
41499
 
      _totalentrycnt := _totalentrycnt + 1;
41500
 
      _batchhash     := _batchhash + CAST(SUBSTRING(_bank.bankaccnt_routing FOR 8) AS INTEGER);
41501
 
      _totalhash     := _totalhash + CAST(SUBSTRING(_bank.bankaccnt_routing FOR 8) AS INTEGER);
41502
 
      _batchdb       := _batchdb + _check.checkhead_amount;
41503
 
      _totaldb       := _totaldb + _check.checkhead_amount;
41504
 
 
41505
 
      _row.achline_value := RPAD('6'
41506
 
                              || _transactionprefix || '7'              -- debit
41507
 
                              || RPAD(_bank.bankaccnt_routing,      9)  -- 2 fields
41508
 
                              || RPAD(_bank.bankaccnt_accntnumber, 17)
41509
 
                              || RPAD(TO_CHAR(_check.checkhead_amount,
41510
 
                                              '00000000V99SG'), 10)
41511
 
                              || RPAD(fetchMetricText('ACHCompanyId'),   15)
41512
 
                              || RPAD(fetchMetricText('ACHCompanyName'), 22)
41513
 
                              || RPAD(TO_CHAR(_check.checkhead_id % 100, '00SG'),
41514
 
                                      2)        -- last 2 digits of checkhead_id
41515
 
                              || '0'
41516
 
                              || RPAD(_bank.bankaccnt_routing, 9)  -- split field
41517
 
                              || RPAD(TO_CHAR(_entrycount, '000000SG'), 15-9),
41518
 
                              94);
41519
 
      RETURN NEXT _row;
41520
 
 
41521
 
      _rowcount      := _rowcount + 1;
41522
 
      _entrycount    := _entrycount + 1;
41523
 
      _totalentrycnt := _totalentrycnt + 1;
41524
 
      _batchhash     := _batchhash + CAST(SUBSTRING(formatbytea(_check.vend_ach_routingnumber) FOR 8) AS INTEGER);
41525
 
      _totalhash     := _totalhash + CAST(SUBSTRING(formatbytea(_check.vend_ach_routingnumber) FOR 8) AS INTEGER);
41526
 
      _totalcr       := _totalcr + _check.checkhead_amount;
41527
 
      _batchcr       := _batchcr + _check.checkhead_amount;
41528
 
      _row.achline_value := RPAD('6'
41529
 
                              || _transactionprefix || '2'              -- credit
41530
 
                              || RPAD(formatbytea(_check.vend_ach_routingnumber), 9)   -- 2 fields
41531
 
                              || RPAD(formatbytea(_check.vend_ach_accntnumber), 17)
41532
 
                              || RPAD(TO_CHAR(_check.checkhead_amount,
41533
 
                                              '00000000V99SG'), 10)
41534
 
                              || RPAD(_ccdnumber, 15)
41535
 
                              || RPAD(_ccdname,   22)
41536
 
                              || RPAD(TO_CHAR(_check.checkhead_id % 100, '00SG'),
41537
 
                                      2)        -- last 2 digits of checkhead_id
41538
 
                              || '0'
41539
 
                              || RPAD(_bank.bankaccnt_routing, 9)  -- split field
41540
 
                              || RPAD(TO_CHAR(_entrycount, '000000SG'), 15-9),
41541
 
                              94);
41542
 
      RETURN NEXT _row;
41543
 
 
41544
 
    ELSE
41545
 
      RAISE EXCEPTION 'Cannot write % check % to an ACH file because % is not a supported SEC code.',
41546
 
                    _bank.bankaccnt_name, _check.checkhead_number, _sec;
41547
 
    END IF;
41548
 
 
41549
 
    UPDATE checkhead
41550
 
    SET checkhead_ach_batch=_filenum,
41551
 
        checkhead_number=_check.checkhead_number
41552
 
    WHERE (checkhead_id=_check.checkhead_id);
41553
 
 
41554
 
  END LOOP;
41555
 
 
41556
 
  IF (NOT FOUND) THEN
41557
 
    RAISE EXCEPTION 'Cannot write an ACH file for % because there are no checks pending in USD for ACH-enabled Vendors.',
41558
 
                    _bank.bankaccnt_name;
41559
 
  END IF;
41560
 
 
41561
 
  -- place a final batch control record
41562
 
  IF (_batchcount > 0) THEN
41563
 
    _rowcount := _rowcount + 1;
41564
 
    _row.achline_checkhead_id := NULL;
41565
 
    _row.achline_batch := _filenum;
41566
 
    _row.achline_type := 'BATCHCONTROL';
41567
 
    -- keep in sync with the other batchcontrol record format above
41568
 
    _row.achline_value := RPAD('8'
41569
 
                            || _serviceclass
41570
 
                            || RPAD(TO_CHAR(_entrycount, '000000SG'), 6)
41571
 
                            || RPAD(TO_CHAR(_batchhash % 10000000000,
41572
 
                                            '0000000000SG'), 10)
41573
 
                            || RPAD(TO_CHAR(_batchdb, '0000000000V99SG'), 12)
41574
 
                            || RPAD(TO_CHAR(_batchcr, '0000000000V99SG'), 12)
41575
 
                            || RPAD(formatAchCompanyId(), 10)
41576
 
                            || RPAD(' ', 19)
41577
 
                            || RPAD(' ',  6)
41578
 
                            || RPAD(_bank.bankaccnt_routing, 8)
41579
 
                            || RPAD(TO_CHAR(_batchcount, '0000000SG'), 7),
41580
 
                            94);
41581
 
    RETURN NEXT _row;
41582
 
  END IF;
41583
 
 
41584
 
  -- and end with a file control record
41585
 
  _rowcount := _rowcount + 1;
41586
 
  _row.achline_checkhead_id := NULL;
41587
 
  _row.achline_batch := _filenum;
41588
 
  _row.achline_type := 'FILECONTROL';
41589
 
  _row.achline_value := RPAD('9'
41590
 
                          || RPAD(TO_CHAR(_batchcount,    '000000SG'),   6)
41591
 
                          || RPAD(TO_CHAR(_rowcount,      '000000SG'),   6)
41592
 
                          || RPAD(TO_CHAR(_totalentrycnt, '00000000SG'), 8)
41593
 
                          || RPAD(TO_CHAR(_totalhash % 10000000000,
41594
 
                                          '0000000000SG'), 10)
41595
 
                          || RPAD(TO_CHAR(_totaldb, '0000000000V99SG'), 12)
41596
 
                          || RPAD(TO_CHAR(_totalcr, '0000000000V99SG'), 12)
41597
 
                          || RPAD('', 39),
41598
 
                          94);
41599
 
 
41600
 
  RETURN NEXT _row;
41601
 
 
41602
 
  -- file must be a multiple of 10 lines long
41603
 
  _row.achline_checkhead_id := NULL;
41604
 
  _row.achline_batch := _filenum;
41605
 
  _row.achline_type := 'BLOCKFILL';
41606
 
  WHILE (_rowcount % 10 > 0) LOOP
41607
 
    _rowcount := _rowcount + 1;
41608
 
    _row.achline_value := RPAD('99999999999999999999'
41609
 
                            || '99999999999999999999'
41610
 
                            || '99999999999999999999'
41611
 
                            || '99999999999999999999'
41612
 
                            || '99999999999999999999', 94);
41613
 
    RETURN NEXT _row;
41614
 
  END LOOP;
41615
 
 
41616
 
  UPDATE bankaccnt
41617
 
  SET bankaccnt_ach_lastdate=CURRENT_DATE,
41618
 
      bankaccnt_ach_lastfileid=_bank.bankaccnt_ach_lastfileid
41619
 
  WHERE (bankaccnt_id=_bank.bankaccnt_id);
41620
 
 
41621
 
  RETURN;
41622
 
 
41623
 
END;
41624
 
$_$;
41625
 
 
41626
 
 
41627
 
ALTER FUNCTION public.formatachchecks(integer, integer, text) OWNER TO admin;
41628
 
 
41629
 
--
41630
 
--
41631
 
 
41632
 
CREATE FUNCTION formatachcompanyid() RETURNS text
41633
 
    LANGUAGE plpgsql
41634
 
    AS $$
41635
 
BEGIN
41636
 
  RETURN CASE WHEN fetchMetricText('ACHCompanyIdType') = 'D' THEN '3'
41637
 
              WHEN fetchMetricText('ACHCompanyIdType') = 'E' THEN '1'
41638
 
              WHEN fetchMetricText('ACHCompanyIdType') = 'O' THEN '9'
41639
 
         END ||
41640
 
         CASE WHEN fetchMetricText('ACHCompanyIdType') = 'D' OR
41641
 
                   fetchMetricText('ACHCompanyIdType') = 'E' THEN
41642
 
                 REPLACE(fetchMetricText('ACHCompanyId'), '-', '')
41643
 
              ELSE fetchMetricText('ACHCompanyId')
41644
 
         END;
41645
 
END;
41646
 
$$;
41647
 
 
41648
 
 
41649
 
ALTER FUNCTION public.formatachcompanyid() OWNER TO admin;
41650
 
 
41651
 
--
41652
 
--
41653
 
 
41654
 
CREATE FUNCTION formataddr(integer) RETURNS text
41655
 
    LANGUAGE plpgsql
41656
 
    AS $_$
41657
 
DECLARE
41658
 
  pAddrId       ALIAS FOR $1;
41659
 
  _return       TEXT;
41660
 
 
41661
 
BEGIN
41662
 
  -- US conventions
41663
 
  SELECT formatAddr(addr_line1, addr_line2, addr_line3,
41664
 
                    addr_city || ', ' || addr_state || ' ' || addr_postalcode,
41665
 
                    addr_country) INTO _return
41666
 
  FROM addr
41667
 
  WHERE (addr_id=pAddrId);
41668
 
 
41669
 
  RETURN _return;
41670
 
END;
41671
 
$_$;
41672
 
 
41673
 
 
41674
 
ALTER FUNCTION public.formataddr(integer) OWNER TO admin;
41675
 
 
41676
 
--
41677
 
--
41678
 
 
41679
 
CREATE FUNCTION formataddr(text, text, text, text, integer) RETURNS text
41680
 
    LANGUAGE plpgsql
41681
 
    AS $_$
41682
 
DECLARE
41683
 
  f_addr1 ALIAS FOR $1;
41684
 
  f_addr2 ALIAS FOR $2;
41685
 
  f_addr3 ALIAS FOR $3;
41686
 
  csz     ALIAS FOR $4;
41687
 
  line    ALIAS FOR $5;
41688
 
 
41689
 
BEGIN
41690
 
  RETURN formatAddr(f_addr1, f_addr2, f_addr3, csz, '', line);
41691
 
END;
41692
 
$_$;
41693
 
 
41694
 
 
41695
 
ALTER FUNCTION public.formataddr(text, text, text, text, integer) OWNER TO admin;
41696
 
 
41697
 
--
41698
 
--
41699
 
 
41700
 
CREATE FUNCTION formataddr(text, text, text, text, text) RETURNS text
41701
 
    LANGUAGE plpgsql
41702
 
    AS $_$
41703
 
DECLARE
41704
 
  f_addr1 ALIAS FOR $1;
41705
 
  f_addr2 ALIAS FOR $2;
41706
 
  f_addr3 ALIAS FOR $3;
41707
 
  csz     ALIAS FOR $4;
41708
 
  country ALIAS FOR $5;
41709
 
  addr TEXT:='';
41710
 
 
41711
 
BEGIN
41712
 
 
41713
 
  IF (LENGTH(TRIM(both from f_addr1)) > 0) THEN
41714
 
    addr:=f_addr1;
41715
 
  END IF;
41716
 
 
41717
 
  IF (LENGTH(TRIM(both from f_addr2)) > 0)  THEN
41718
 
        IF (LENGTH(TRIM(both from addr)) > 0) THEN
41719
 
                addr:=addr || E'\n';
41720
 
        END IF;
41721
 
    addr:=addr || f_addr2;
41722
 
  END IF;
41723
 
 
41724
 
  IF (LENGTH(TRIM(both from f_addr3)) > 0)  THEN
41725
 
        IF (LENGTH(TRIM(both from addr)) > 0) THEN
41726
 
                addr:=addr || E'\n';
41727
 
        END IF;
41728
 
    addr:=addr || f_addr3;
41729
 
  END IF;
41730
 
 
41731
 
  IF (LENGTH(TRIM(both from csz)) > 0)  THEN
41732
 
        IF (LENGTH(TRIM(both from addr)) > 0) THEN
41733
 
                addr:=addr || E'\n';
41734
 
        END IF;
41735
 
    addr:=addr || csz;
41736
 
  END IF;
41737
 
 
41738
 
  IF (LENGTH(TRIM(both from country)) > 0)  THEN
41739
 
        IF (LENGTH(TRIM(both from addr)) > 0) THEN
41740
 
                addr:=addr || E'\n';
41741
 
        END IF;
41742
 
    addr:=addr || country;
41743
 
  END IF;
41744
 
 
41745
 
  RETURN addr;
41746
 
 
41747
 
END;
41748
 
$_$;
41749
 
 
41750
 
 
41751
 
ALTER FUNCTION public.formataddr(text, text, text, text, text) OWNER TO admin;
41752
 
 
41753
 
--
41754
 
--
41755
 
 
41756
 
CREATE FUNCTION formataddr(text, text, text, text, text, integer) RETURNS text
41757
 
    LANGUAGE plpgsql
41758
 
    AS $_$ 
41759
 
DECLARE
41760
 
  f_addr1 ALIAS FOR $1;
41761
 
  f_addr2 ALIAS FOR $2;
41762
 
  f_addr3 ALIAS FOR $3;
41763
 
  csz     ALIAS FOR $4;
41764
 
  country ALIAS FOR $5;
41765
 
  line    ALIAS FOR $6;
41766
 
 
41767
 
  i int:=0;
41768
 
 
41769
 
BEGIN
41770
 
 
41771
 
  IF (LENGTH(TRIM(both from f_addr1)) > 0) THEN
41772
 
    i:=i+1;
41773
 
  END IF;
41774
 
 
41775
 
  IF (i=line) THEN
41776
 
    RETURN f_addr1;
41777
 
  END IF;
41778
 
 
41779
 
  IF (LENGTH(TRIM(both from f_addr2)) > 0)  THEN
41780
 
    i:=i+1;
41781
 
  END IF;
41782
 
 
41783
 
  IF (i=line) THEN
41784
 
    RETURN f_addr2;
41785
 
  END IF;
41786
 
 
41787
 
  IF (LENGTH(TRIM(both from f_addr3)) > 0) THEN
41788
 
    i:=i+1;
41789
 
  END IF;
41790
 
 
41791
 
  IF (i=line) THEN
41792
 
    RETURN f_addr3;
41793
 
  END IF;
41794
 
 
41795
 
  IF (LENGTH(TRIM(both from csz)) > 0) THEN
41796
 
    i:=i+1;
41797
 
  END IF;
41798
 
 
41799
 
  IF (i=line) THEN
41800
 
    RETURN csz;
41801
 
  END IF;
41802
 
 
41803
 
  IF (LENGTH(TRIM(both from country)) > 0) THEN
41804
 
    i:=i+1;
41805
 
  END IF;
41806
 
 
41807
 
  IF (i=line) THEN
41808
 
    RETURN country;
41809
 
  END IF;
41810
 
 
41811
 
  RETURN ' ';
41812
 
 
41813
 
END;
41814
 
$_$;
41815
 
 
41816
 
 
41817
 
ALTER FUNCTION public.formataddr(text, text, text, text, text, integer) OWNER TO admin;
41818
 
 
41819
 
--
41820
 
--
41821
 
 
41822
 
CREATE FUNCTION formatboolyn(boolean) RETURNS text
41823
 
    LANGUAGE plpgsql IMMUTABLE
41824
 
    AS $_$
41825
 
DECLARE pBool ALIAS FOR $1;
41826
 
BEGIN
41827
 
  IF (pBool) THEN
41828
 
    RETURN 'Yes';
41829
 
  ELSE
41830
 
    RETURN 'No';
41831
 
  END IF;
41832
 
END;
41833
 
$_$;
41834
 
 
41835
 
 
41836
 
ALTER FUNCTION public.formatboolyn(boolean) OWNER TO admin;
41837
 
 
41838
 
--
41839
 
--
41840
 
 
41841
 
CREATE FUNCTION formatbooseq(integer, integer) RETURNS text
41842
 
    LANGUAGE plpgsql
41843
 
    AS $_$
41844
 
DECLARE
41845
 
  pItemid ALIAS FOR $1;
41846
 
  pBooitemSeqId ALIAS FOR $2;
41847
 
  _result TEXT;
41848
 
  
41849
 
BEGIN
41850
 
 
41851
 
  IF (fetchMetricBool('Routings')) THEN
41852
 
    SELECT booitem_seqnumber::text INTO _result
41853
 
    FROM xtmfg.booitem(pItemid)
41854
 
    WHERE (booitem_seq_id=pBooitemSeqId);
41855
 
 
41856
 
    RETURN _result;
41857
 
  ELSE
41858
 
    RETURN NULL;
41859
 
  END IF;
41860
 
 
41861
 
END;
41862
 
$_$;
41863
 
 
41864
 
 
41865
 
ALTER FUNCTION public.formatbooseq(integer, integer) OWNER TO admin;
41866
 
 
41867
 
--
41868
 
--
41869
 
 
41870
 
CREATE FUNCTION formatbytea(bytea) RETURNS text
41871
 
    LANGUAGE plpgsql
41872
 
    AS $_$
41873
 
DECLARE
41874
 
  pField ALIAS FOR $1;
41875
 
  output_field TEXT;
41876
 
 
41877
 
BEGIN
41878
 
 
41879
 
  output_field := pField;
41880
 
 
41881
 
  RETURN output_field;
41882
 
 
41883
 
END;
41884
 
$_$;
41885
 
 
41886
 
 
41887
 
ALTER FUNCTION public.formatbytea(bytea) OWNER TO admin;
41888
 
 
41889
 
--
41890
 
--
41891
 
 
41892
 
CREATE FUNCTION formatccdashes(text, text) RETURNS text
41893
 
    LANGUAGE plpgsql
41894
 
    AS $_$
41895
 
DECLARE
41896
 
  pCCard ALIAS FOR $1;
41897
 
  pCCardType ALIAS FOR $2;
41898
 
  _returnCard text;
41899
 
  card_length integer;
41900
 
 
41901
 
BEGIN
41902
 
 
41903
 
  IF (pCCardType = 'A')  THEN
41904
 
    _returnCard := pCCard;
41905
 
    RETURN _returnCard;
41906
 
  END IF;
41907
 
 
41908
 
  card_length := length(pCcard);
41909
 
 
41910
 
  if (card_length = 16) THEN
41911
 
    _returnCard := substr(pCCard, 1, 4) || '-' || substr(pCCard, 5, 4) || '-' || substr(pCCard, 9, 4) || '-' || substr(pCCard, 13, 4);
41912
 
  ELSE
41913
 
    _returnCard := substr(pCCard, 1, 4) || '-' || substr(pCCard, 5, 4) || '-' || substr(pCCard, 9, 4) || '-' || substr(pCCard, 13, 1);
41914
 
  END IF;
41915
 
 
41916
 
  RETURN _returnCard;
41917
 
 
41918
 
END;
41919
 
$_$;
41920
 
 
41921
 
 
41922
 
ALTER FUNCTION public.formatccdashes(text, text) OWNER TO admin;
41923
 
 
41924
 
--
41925
 
--
41926
 
 
41927
 
CREATE FUNCTION formatccnumber(text) RETURNS text
41928
 
    LANGUAGE plpgsql
41929
 
    AS $_$
41930
 
DECLARE
41931
 
  pCcardnum ALIAS FOR $1;
41932
 
  card_length INTEGER;
41933
 
  output_cardnum TEXT;
41934
 
 
41935
 
BEGIN
41936
 
 
41937
 
  card_length := length(pCcardnum);
41938
 
 
41939
 
  IF (card_length = 13) THEN
41940
 
    output_cardnum := '*********' || substr(pCcardnum, 10, 4);  
41941
 
  END IF;
41942
 
 
41943
 
  IF (card_length = 14) THEN
41944
 
    output_cardnum := '**********' || substr(pCcardnum, 11, 4);  
41945
 
  END IF;
41946
 
 
41947
 
  IF (card_length = 15) THEN
41948
 
    output_cardnum := '***********' || substr(pCcardnum, 12, 4);  
41949
 
  END IF;
41950
 
 
41951
 
  IF (card_length = 16) THEN
41952
 
    output_cardnum := '************' || substr(pCcardnum, 13, 4);  
41953
 
  END IF;
41954
 
 
41955
 
  RETURN output_cardnum;
41956
 
 
41957
 
END;
41958
 
$_$;
41959
 
 
41960
 
 
41961
 
ALTER FUNCTION public.formatccnumber(text) OWNER TO admin;
41962
 
 
41963
 
--
41964
 
--
41965
 
 
41966
 
CREATE FUNCTION formatccnumber(bytea) RETURNS text
41967
 
    LANGUAGE plpgsql
41968
 
    AS $_$
41969
 
DECLARE
41970
 
  pCcardnum ALIAS FOR $1;
41971
 
  card_length INTEGER;
41972
 
  output_cardnum TEXT;
41973
 
 
41974
 
BEGIN
41975
 
 
41976
 
  card_length := length(pCcardnum);
41977
 
 
41978
 
  IF (card_length = 13) THEN
41979
 
    output_cardnum := '*********' || substr(pCcardnum, 10, 4);  
41980
 
  END IF;
41981
 
 
41982
 
  IF (card_length = 14) THEN
41983
 
    output_cardnum := '**********' || substr(pCcardnum, 11, 4);  
41984
 
  END IF;
41985
 
 
41986
 
  IF (card_length = 15) THEN
41987
 
    output_cardnum := '***********' || substr(pCcardnum, 12, 4);  
41988
 
  END IF;
41989
 
 
41990
 
  IF (card_length = 16) THEN
41991
 
    output_cardnum := '************' || substr(pCcardnum, 13, 4);  
41992
 
  END IF;
41993
 
 
41994
 
  RETURN output_cardnum;
41995
 
 
41996
 
END;
41997
 
$_$;
41998
 
 
41999
 
 
42000
 
ALTER FUNCTION public.formatccnumber(bytea) OWNER TO admin;
42001
 
 
42002
 
--
42003
 
--
42004
 
 
42005
 
CREATE FUNCTION formatcntctname(integer) RETURNS text
42006
 
    LANGUAGE plpgsql
42007
 
    AS $_$ 
42008
 
DECLARE
42009
 
  pCntctId ALIAS FOR $1;
42010
 
  _r RECORD;
42011
 
  _rows NUMERIC;
42012
 
 
42013
 
BEGIN
42014
 
 
42015
 
  SELECT cntct_honorific, cntct_first_name, cntct_middle, 
42016
 
    cntct_last_name, cntct_suffix INTO _r
42017
 
  FROM cntct
42018
 
  WHERE (cntct_id=pCntctId);
42019
 
 
42020
 
  GET DIAGNOSTICS _rows = ROW_COUNT;
42021
 
  IF (_rows = 0) THEN
42022
 
    RETURN '';
42023
 
  END IF;
42024
 
 
42025
 
  RETURN formatCntctName(_r.cntct_honorific, _r.cntct_first_name, _r.cntct_middle, _r.cntct_last_name, _r.cntct_suffix);
42026
 
 
42027
 
END;
42028
 
$_$;
42029
 
 
42030
 
 
42031
 
ALTER FUNCTION public.formatcntctname(integer) OWNER TO admin;
42032
 
 
42033
 
--
42034
 
--
42035
 
 
42036
 
CREATE FUNCTION formatcntctname(text, text, text, text, text) RETURNS text
42037
 
    LANGUAGE plpgsql
42038
 
    AS $_$ 
42039
 
DECLARE
42040
 
  pHonorific ALIAS FOR $1;
42041
 
  pFirstName ALIAS FOR $2;
42042
 
  pMiddle ALIAS FOR $3;
42043
 
  pLastName ALIAS FOR $4;
42044
 
  pSuffix ALIAS FOR $5;
42045
 
  _name TEXT := '';
42046
 
 
42047
 
BEGIN
42048
 
 
42049
 
  IF (LENGTH(TRIM(both from COALESCE(pHonorific,''))) > 0) THEN
42050
 
    IF (POSITION('.' IN COALESCE(pHonorific, '')) > 0) THEN
42051
 
      _name:= pHonorific;
42052
 
    ELSE
42053
 
      _name:= pHonorific || '.';
42054
 
    END IF;
42055
 
  END IF;
42056
 
 
42057
 
  IF (LENGTH(TRIM(both from COALESCE(pFirstName,''))) > 0)  THEN
42058
 
        IF (LENGTH(TRIM(both from _name)) > 0) THEN
42059
 
                _name:=_name || ' ';
42060
 
        END IF;
42061
 
    _name:=_name || pFirstName;
42062
 
  END IF;
42063
 
 
42064
 
  IF (LENGTH(TRIM(both from COALESCE(pMiddle,''))) > 0)  THEN
42065
 
        IF (LENGTH(TRIM(both from _name)) > 0) THEN
42066
 
                _name:=_name || ' ';
42067
 
        END IF;
42068
 
    IF (POSITION('.' IN COALESCE(pHonorific, '')) > 0) THEN
42069
 
      _name:=_name || pMiddle;
42070
 
    ELSE
42071
 
      _name:=_name || pMiddle || '.';
42072
 
    END IF;
42073
 
  END IF;
42074
 
 
42075
 
  IF (LENGTH(TRIM(both from COALESCE(pLastName,''))) > 0)  THEN
42076
 
        IF (LENGTH(TRIM(both from _name)) > 0) THEN
42077
 
                _name:=_name || ' ';
42078
 
        END IF;
42079
 
    _name:=_name || pLastName;
42080
 
  END IF;
42081
 
 
42082
 
  IF (LENGTH(TRIM(both from COALESCE(pSuffix,''))) > 0)  THEN
42083
 
        IF (LENGTH(TRIM(both from _name)) > 0) THEN
42084
 
                _name:=_name || ' ';
42085
 
        END IF;
42086
 
    _name:=_name || pSuffix;
42087
 
  END IF;
42088
 
 
42089
 
  RETURN _name;
42090
 
 
42091
 
END;
42092
 
$_$;
42093
 
 
42094
 
 
42095
 
ALTER FUNCTION public.formatcntctname(text, text, text, text, text) OWNER TO admin;
42096
 
 
42097
 
--
42098
 
--
42099
 
 
42100
 
CREATE FUNCTION formatcost(numeric) RETURNS text
42101
 
    LANGUAGE plpgsql IMMUTABLE
42102
 
    AS $_$
42103
 
BEGIN
42104
 
  RETURN formatNumeric($1, 'cost');
42105
 
END;$_$;
42106
 
 
42107
 
 
42108
 
ALTER FUNCTION public.formatcost(numeric) OWNER TO admin;
42109
 
 
42110
 
--
42111
 
--
42112
 
 
42113
 
CREATE FUNCTION formatcounttagbarcode(integer) RETURNS text
42114
 
    LANGUAGE plpgsql IMMUTABLE
42115
 
    AS $_$
42116
 
DECLARE
42117
 
  pCnttagid ALIAS FOR $1;
42118
 
  _barcode TEXT;
42119
 
BEGIN
42120
 
 
42121
 
  SELECT ( E'\138CTXX' ||
42122
 
           LTRIM(TO_CHAR(LENGTH(invcnt_tagnumber), '00')) || invcnt_tagnumber ) INTO _barcode
42123
 
  FROM invcnt
42124
 
  WHERE (invcnt_id=pCnttagid);
42125
 
 
42126
 
  RETURN _barcode;
42127
 
 
42128
 
END;
42129
 
$_$;
42130
 
 
42131
 
 
42132
 
ALTER FUNCTION public.formatcounttagbarcode(integer) OWNER TO admin;
42133
 
 
42134
 
--
42135
 
--
42136
 
 
42137
 
CREATE FUNCTION formatcreditmemonumber(integer) RETURNS text
42138
 
    LANGUAGE plpgsql IMMUTABLE
42139
 
    AS $_$
42140
 
DECLARE
42141
 
  pCmheadid ALIAS FOR $1;
42142
 
 
42143
 
BEGIN
42144
 
  RETURN ( SELECT COALESCE(cmhead_number::TEXT, '')
42145
 
           FROM cmhead
42146
 
           WHERE (cmhead_id=pCmheadid) );
42147
 
END;
42148
 
$_$;
42149
 
 
42150
 
 
42151
 
ALTER FUNCTION public.formatcreditmemonumber(integer) OWNER TO admin;
42152
 
 
42153
 
--
42154
 
--
42155
 
 
42156
 
CREATE FUNCTION formatdate(date) RETURNS text
42157
 
    LANGUAGE sql IMMUTABLE
42158
 
    AS $_$
42159
 
SELECT TO_CHAR($1, COALESCE((SELECT locale_dateformat
42160
 
                             FROM locale, usr
42161
 
                             WHERE ((usr_locale_id=locale_id)
42162
 
                              AND (usr_username=getEffectiveXtUser())) ),
42163
 
                            'yyyy-mm-dd') ) AS result
42164
 
$_$;
42165
 
 
42166
 
 
42167
 
ALTER FUNCTION public.formatdate(date) OWNER TO admin;
42168
 
 
42169
 
--
42170
 
--
42171
 
 
42172
 
CREATE FUNCTION formatdate(timestamp with time zone) RETURNS text
42173
 
    LANGUAGE sql IMMUTABLE
42174
 
    AS $_$
42175
 
SELECT TO_CHAR($1, COALESCE((SELECT locale_dateformat
42176
 
                             FROM locale, usr
42177
 
                             WHERE ((usr_locale_id=locale_id)
42178
 
                              AND (usr_username=getEffectiveXtUser())) ),
42179
 
                            'yyyy-mm-dd' )) AS result
42180
 
$_$;
42181
 
 
42182
 
 
42183
 
ALTER FUNCTION public.formatdate(timestamp with time zone) OWNER TO admin;
42184
 
 
42185
 
--
42186
 
--
42187
 
 
42188
 
CREATE FUNCTION formatdate(date, text) RETURNS text
42189
 
    LANGUAGE plpgsql IMMUTABLE
42190
 
    AS $_$
42191
 
DECLARE
42192
 
  pDate ALIAS FOR $1;
42193
 
  pString ALIAS FOR $2;
42194
 
 
42195
 
BEGIN
42196
 
 
42197
 
  IF ( (pDate = startOfTime()) OR
42198
 
       (pDate = endOfTime()) OR
42199
 
       (pDate IS NULL) ) THEN
42200
 
    RETURN pString;
42201
 
  ELSE
42202
 
    RETURN formatDate(pDate);
42203
 
  END IF;
42204
 
 
42205
 
END;
42206
 
$_$;
42207
 
 
42208
 
 
42209
 
ALTER FUNCTION public.formatdate(date, text) OWNER TO admin;
42210
 
 
42211
 
--
42212
 
--
42213
 
 
42214
 
CREATE FUNCTION formatdatetime(timestamp with time zone) RETURNS text
42215
 
    LANGUAGE sql IMMUTABLE
42216
 
    AS $_$
42217
 
SELECT TO_CHAR($1, COALESCE((SELECT locale_timestampformat
42218
 
                             FROM locale, usr
42219
 
                             WHERE ((usr_locale_id=locale_id)
42220
 
                              AND (usr_username=getEffectiveXtUser())) ),
42221
 
                            'yyyy-mm-dd HH24:MI:SS')) AS result
42222
 
$_$;
42223
 
 
42224
 
 
42225
 
ALTER FUNCTION public.formatdatetime(timestamp with time zone) OWNER TO admin;
42226
 
 
42227
 
--
42228
 
--
42229
 
 
42230
 
CREATE FUNCTION formatdatetime(timestamp without time zone) RETURNS text
42231
 
    LANGUAGE sql IMMUTABLE
42232
 
    AS $_$
42233
 
SELECT TO_CHAR($1, COALESCE((SELECT locale_timestampformat
42234
 
                             FROM locale, usr
42235
 
                             WHERE ((usr_locale_id=locale_id)
42236
 
                              AND (usr_username=getEffectiveXtUser())) ),
42237
 
                            'yyyy-mm-dd HH24:MI:SS')) AS result
42238
 
$_$;
42239
 
 
42240
 
 
42241
 
ALTER FUNCTION public.formatdatetime(timestamp without time zone) OWNER TO admin;
42242
 
 
42243
 
--
42244
 
--
42245
 
 
42246
 
CREATE FUNCTION formatextprice(numeric) RETURNS text
42247
 
    LANGUAGE plpgsql IMMUTABLE
42248
 
    AS $_$
42249
 
BEGIN
42250
 
  RETURN formatNumeric($1, 'extprice');
42251
 
END;$_$;
42252
 
 
42253
 
 
42254
 
ALTER FUNCTION public.formatextprice(numeric) OWNER TO admin;
42255
 
 
42256
 
--
42257
 
--
42258
 
 
42259
 
CREATE FUNCTION formatflitemdescrip(integer) RETURNS text
42260
 
    LANGUAGE plpgsql
42261
 
    AS $_$
42262
 
DECLARE
42263
 
  pFlitemId ALIAS FOR $1;
42264
 
  _x RECORD;
42265
 
  _descrip TEXT;
42266
 
 
42267
 
BEGIN
42268
 
  SELECT flitem_accnt_id, flitem_company, flitem_profit, flitem_number,
42269
 
        flitem_sub, flitem_type, flitem_subaccnttype_code,
42270
 
        accnt_id, accnt_descrip INTO _x
42271
 
  FROM flitem LEFT OUTER JOIN accnt
42272
 
        ON flitem_accnt_id=accnt_id
42273
 
  WHERE flitem_id=pFlitemId;
42274
 
 
42275
 
  IF _x.flitem_accnt_id > -1 THEN
42276
 
 
42277
 
    SELECT (formatGLAccount(_x.accnt_id) || '-' || _x.accnt_descrip) INTO _descrip;
42278
 
 
42279
 
  ELSE
42280
 
 
42281
 
    _descrip:='';
42282
 
 
42283
 
    IF _x.flitem_type = 'A' THEN
42284
 
      _descrip:='Type=' || 'Asset';
42285
 
      ELSE IF _x.flitem_type='L' THEN
42286
 
        _descrip:='Type=' || 'Liability';
42287
 
        ELSE IF _x.flitem_type='R' THEN
42288
 
          _descrip:='Type=' || 'Revenue';
42289
 
          ELSE IF _x.flitem_type='E' THEN
42290
 
            _descrip:='Type=' || 'Expense';
42291
 
            ELSE IF _x.flitem_type='Q' THEN
42292
 
              _descrip:='Type=' || 'Equity';
42293
 
            END IF;
42294
 
          END IF;
42295
 
        END IF;
42296
 
      END IF;
42297
 
    END IF;
42298
 
 
42299
 
    IF _x.flitem_subaccnttype_code <> 'All' THEN
42300
 
      IF (LENGTH(TRIM(both from _descrip)) > 0) THEN
42301
 
        _descrip:=_descrip || ', ';
42302
 
      END IF;
42303
 
      _descrip:=_descrip || 'Sub Accnt Type=' || _x.flitem_subaccnttype_code;
42304
 
    END IF;
42305
 
 
42306
 
    IF _x.flitem_company <> 'All' THEN
42307
 
      IF (LENGTH(TRIM(both from _descrip)) > 0) THEN
42308
 
        _descrip:=_descrip || ', ';
42309
 
      END IF;
42310
 
      _descrip:=_descrip || 'Company=' || _x.flitem_company;
42311
 
    END IF;
42312
 
 
42313
 
    IF _x.flitem_profit <> 'All' THEN
42314
 
      IF (LENGTH(TRIM(both from _descrip)) > 0) THEN
42315
 
        _descrip:=_descrip || ', ';
42316
 
      END IF;
42317
 
      _descrip:=_descrip || 'Profit=' || _x.flitem_profit;
42318
 
    END IF;
42319
 
 
42320
 
    IF _x.flitem_number <> 'All' THEN
42321
 
      IF (LENGTH(TRIM(both from _descrip)) > 0) THEN
42322
 
        _descrip:=_descrip || ', ';
42323
 
      END IF;
42324
 
      _descrip:=_descrip || 'Number=' || _x.flitem_number;
42325
 
    END IF;
42326
 
 
42327
 
    IF _x.flitem_sub <> 'All' THEN
42328
 
      IF (LENGTH(TRIM(both from _descrip)) > 0) THEN
42329
 
        _descrip:=_descrip || ', ';
42330
 
      END IF;
42331
 
      _descrip:=_descrip || 'Sub Accnt=' || _x.flitem_sub;
42332
 
    END IF;
42333
 
  END IF;
42334
 
 
42335
 
  RETURN _descrip;
42336
 
 
42337
 
END;
42338
 
$_$;
42339
 
 
42340
 
 
42341
 
ALTER FUNCTION public.formatflitemdescrip(integer) OWNER TO admin;
42342
 
 
42343
 
--
42344
 
--
42345
 
 
42346
 
CREATE FUNCTION formatglaccount(text, text, text, text) RETURNS text
42347
 
    LANGUAGE plpgsql IMMUTABLE
42348
 
    AS $_$
42349
 
DECLARE
42350
 
  pCompany ALIAS FOR $1;
42351
 
  pProfit ALIAS FOR $2;
42352
 
  pNumber ALIAS FOR $3;
42353
 
  pSub    ALIAS FOR $4;
42354
 
  _number TEXT := '';
42355
 
 
42356
 
BEGIN
42357
 
 
42358
 
  IF ( ( SELECT metric_value::INTEGER
42359
 
         FROM metric
42360
 
         WHERE (metric_name='GLCompanySize') ) > 0 ) THEN
42361
 
    _number := pCompany || '-';
42362
 
  END IF;
42363
 
 
42364
 
  IF ( ( SELECT metric_value::INTEGER
42365
 
         FROM metric
42366
 
         WHERE (metric_name='GLProfitSize') ) > 0 ) THEN
42367
 
    _number := _number || pProfit || '-';
42368
 
  END IF;
42369
 
 
42370
 
  _number := _number || pNumber;
42371
 
 
42372
 
  IF ( ( SELECT metric_value::INTEGER
42373
 
         FROM metric
42374
 
         WHERE (metric_name='GLSubaccountSize') ) > 0 ) THEN
42375
 
    _number := _number || '-' || pSub;
42376
 
  END IF;
42377
 
 
42378
 
  RETURN _number;
42379
 
 
42380
 
END;
42381
 
$_$;
42382
 
 
42383
 
 
42384
 
ALTER FUNCTION public.formatglaccount(text, text, text, text) OWNER TO admin;
42385
 
 
42386
 
--
42387
 
--
42388
 
 
42389
 
CREATE FUNCTION formatglaccountlong(integer) RETURNS text
42390
 
    LANGUAGE plpgsql IMMUTABLE
42391
 
    AS $_$
42392
 
DECLARE
42393
 
  pAccntid ALIAS FOR $1;
42394
 
  _result TEXT;
42395
 
 
42396
 
BEGIN
42397
 
 
42398
 
  SELECT (formatGLAccount(accnt_id) || '-' || accnt_descrip) INTO _result
42399
 
  FROM accnt
42400
 
  WHERE (accnt_id=pAccntid);
42401
 
 
42402
 
  RETURN _result;
42403
 
 
42404
 
END;
42405
 
$_$;
42406
 
 
42407
 
 
42408
 
ALTER FUNCTION public.formatglaccountlong(integer) OWNER TO admin;
42409
 
 
42410
 
--
42411
 
--
42412
 
 
42413
 
CREATE FUNCTION formatindent(text, integer) RETURNS text
42414
 
    LANGUAGE plpgsql
42415
 
    AS $_$
42416
 
DECLARE
42417
 
  pText ALIAS FOR $1;
42418
 
  pIndent ALIAS FOR $2;
42419
 
  _i INTEGER;
42420
 
  _result TEXT;
42421
 
 
42422
 
BEGIN
42423
 
  _result := '';
42424
 
  _i := 0;
42425
 
 
42426
 
  WHILE _i < pIndent LOOP
42427
 
    _result := _result || '  ';
42428
 
    _i := _i + 1;
42429
 
  END LOOP;
42430
 
 
42431
 
  _result := _result || pText;
42432
 
  RETURN _result;
42433
 
END;
42434
 
$_$;
42435
 
 
42436
 
 
42437
 
ALTER FUNCTION public.formatindent(text, integer) OWNER TO admin;
42438
 
 
42439
 
--
42440
 
--
42441
 
 
42442
 
CREATE FUNCTION formatinterval(numeric) RETURNS text
42443
 
    LANGUAGE sql IMMUTABLE
42444
 
    AS $_$
42445
 
  SELECT TO_CHAR(('@ ' || trunc($1) || ' min ' ||
42446
 
                             ($1 - trunc($1)) * 60 || ' sec')::INTERVAL,
42447
 
                 ( SELECT locale_intervalformat
42448
 
                       FROM locale, usr
42449
 
                       WHERE ((usr_locale_id=locale_id)
42450
 
                         AND  (usr_username=getEffectiveXtUser())) ) ) AS result
42451
 
$_$;
42452
 
 
42453
 
 
42454
 
ALTER FUNCTION public.formatinterval(numeric) OWNER TO admin;
42455
 
 
42456
 
--
42457
 
--
42458
 
 
42459
 
CREATE FUNCTION formatinterval(interval) RETURNS text
42460
 
    LANGUAGE sql IMMUTABLE
42461
 
    AS $_$
42462
 
  SELECT TO_CHAR($1, ( SELECT locale_intervalformat
42463
 
                       FROM locale, usr
42464
 
                       WHERE ((usr_locale_id=locale_id)
42465
 
                         AND  (usr_username=getEffectiveXtUser())) ) ) AS result
42466
 
$_$;
42467
 
 
42468
 
 
42469
 
ALTER FUNCTION public.formatinterval(interval) OWNER TO admin;
42470
 
 
42471
 
--
42472
 
--
42473
 
 
42474
 
CREATE FUNCTION formatinvcnumber(integer) RETURNS text
42475
 
    LANGUAGE plpgsql IMMUTABLE
42476
 
    AS $_$
42477
 
DECLARE
42478
 
  pCobmiscid ALIAS FOR $1;
42479
 
 
42480
 
BEGIN
42481
 
  RETURN ( SELECT COALESCE(cobmisc_invcnumber::TEXT, '')
42482
 
           FROM cobmisc
42483
 
           WHERE (cobmisc_id=pCobmiscid) );
42484
 
END;
42485
 
$_$;
42486
 
 
42487
 
 
42488
 
ALTER FUNCTION public.formatinvcnumber(integer) OWNER TO admin;
42489
 
 
42490
 
--
42491
 
--
42492
 
 
42493
 
CREATE FUNCTION formatitemsitebarcode(integer) RETURNS text
42494
 
    LANGUAGE plpgsql IMMUTABLE
42495
 
    AS $_$
42496
 
DECLARE
42497
 
  pItemsiteid ALIAS FOR $1;
42498
 
  _barcode TEXT;
42499
 
BEGIN
42500
 
 
42501
 
  SELECT ( E'\138ISXX' ||
42502
 
           LTRIM(TO_CHAR(LENGTH(item_number), '00')) || LENGTH(warehous_code)::TEXT ||
42503
 
           item_number || warehous_code ) INTO _barcode
42504
 
  FROM itemsite, item, whsinfo
42505
 
  WHERE ( (itemsite_item_id=item_id)
42506
 
   AND (itemsite_warehous_id=warehous_id)
42507
 
   AND (itemsite_id=pItemsiteid) );
42508
 
 
42509
 
  RETURN _barcode;
42510
 
 
42511
 
END;
42512
 
$_$;
42513
 
 
42514
 
 
42515
 
ALTER FUNCTION public.formatitemsitebarcode(integer) OWNER TO admin;
42516
 
 
42517
 
--
42518
 
--
42519
 
 
42520
 
CREATE FUNCTION formatlocationbarcode(integer) RETURNS text
42521
 
    LANGUAGE plpgsql IMMUTABLE
42522
 
    AS $_$
42523
 
DECLARE
42524
 
  pLocationid ALIAS FOR $1;
42525
 
  _barcode TEXT;
42526
 
BEGIN
42527
 
 
42528
 
  SELECT ( E'\138LOXX' ||
42529
 
           LENGTH(warehous_code)::TEXT || LTRIM(TO_CHAR(LENGTH(location_name::TEXT), '00')) ||
42530
 
           warehous_code || location_name ) INTO _barcode
42531
 
  FROM location, whsinfo
42532
 
  WHERE ( (location_warehous_id=warehous_id)
42533
 
   AND (location_id=pLocationid) );
42534
 
 
42535
 
  RETURN _barcode;
42536
 
 
42537
 
END;
42538
 
$_$;
42539
 
 
42540
 
 
42541
 
ALTER FUNCTION public.formatlocationbarcode(integer) OWNER TO admin;
42542
 
 
42543
 
--
42544
 
--
42545
 
 
42546
 
CREATE FUNCTION formatlocationcontentsbarcode(integer) RETURNS text
42547
 
    LANGUAGE plpgsql IMMUTABLE
42548
 
    AS $_$
42549
 
DECLARE
42550
 
  pLocationid ALIAS FOR $1;
42551
 
  _barcode TEXT;
42552
 
BEGIN
42553
 
 
42554
 
  SELECT ( E'\138LOCN' ||
42555
 
           LENGTH(warehous_code)::TEXT || LTRIM(TO_CHAR(LENGTH(location_name), '00')) ||
42556
 
           warehous_code || location_name ) INTO _barcode
42557
 
  FROM location, whsinfo
42558
 
  WHERE ( (location_warehous_id=warehous_id)
42559
 
   AND (location_id=pLocationid) );
42560
 
 
42561
 
  RETURN _barcode;
42562
 
 
42563
 
END;
42564
 
$_$;
42565
 
 
42566
 
 
42567
 
ALTER FUNCTION public.formatlocationcontentsbarcode(integer) OWNER TO admin;
42568
 
 
42569
 
--
42570
 
--
42571
 
 
42572
 
CREATE FUNCTION formatlocationissuebarcode(integer) RETURNS text
42573
 
    LANGUAGE plpgsql IMMUTABLE
42574
 
    AS $_$
42575
 
DECLARE
42576
 
  pLocationid ALIAS FOR $1;
42577
 
  _barcode TEXT;
42578
 
BEGIN
42579
 
 
42580
 
  SELECT ( E'\138LOIS' ||
42581
 
           LENGTH(warehous_code)::TEXT || LTRIM(TO_CHAR(LENGTH(location_name), '00')) ||
42582
 
           warehous_code || location_name ) INTO _barcode
42583
 
  FROM location, whsinfo
42584
 
  WHERE ( (location_warehous_id=warehous_id)
42585
 
   AND (location_id=pLocationid) );
42586
 
 
42587
 
  RETURN _barcode;
42588
 
 
42589
 
END;
42590
 
$_$;
42591
 
 
42592
 
 
42593
 
ALTER FUNCTION public.formatlocationissuebarcode(integer) OWNER TO admin;
42594
 
 
42595
 
--
42596
 
--
42597
 
 
42598
 
CREATE FUNCTION formatlotserialnumber(integer) RETURNS text
42599
 
    LANGUAGE plpgsql
42600
 
    AS $_$
42601
 
DECLARE
42602
 
  pLotSerialId ALIAS FOR $1;
42603
 
  _lotserial TEXT;
42604
 
 
42605
 
BEGIN
42606
 
  --See if lot serial control turned on (Postbooks will not ever have this)
42607
 
  IF (fetchmetricbool('LotSerialControl')) THEN
42608
 
    SELECT ls_number INTO _lotserial
42609
 
    FROM ls
42610
 
    WHERE (ls_id=pLotSerialId);
42611
 
  END IF;
42612
 
 
42613
 
  RETURN COALESCE(_lotserial,'');
42614
 
 
42615
 
END;
42616
 
$_$;
42617
 
 
42618
 
 
42619
 
ALTER FUNCTION public.formatlotserialnumber(integer) OWNER TO admin;
42620
 
 
42621
 
--
42622
 
--
42623
 
 
42624
 
CREATE FUNCTION formatmoney(numeric) RETURNS text
42625
 
    LANGUAGE plpgsql IMMUTABLE
42626
 
    AS $_$
42627
 
BEGIN
42628
 
  RETURN formatNumeric($1, 'curr');
42629
 
END;$_$;
42630
 
 
42631
 
 
42632
 
ALTER FUNCTION public.formatmoney(numeric) OWNER TO admin;
42633
 
 
42634
 
--
42635
 
--
42636
 
 
42637
 
CREATE FUNCTION formatnumeric(numeric, text) RETURNS text
42638
 
    LANGUAGE plpgsql IMMUTABLE
42639
 
    AS $_$
42640
 
DECLARE
42641
 
  _value        NUMERIC := $1;
42642
 
  _type         TEXT    := LOWER(COALESCE($2, 'curr'));
42643
 
  _abs          NUMERIC;
42644
 
  _magnitudecnt NUMERIC(1000);
42645
 
  _wholefmt     TEXT    := '0';
42646
 
  _scale        INTEGER;
42647
 
  _neg          TEXT;
42648
 
  _decimal      TEXT;
42649
 
  _group        TEXT;
42650
 
  _string       TEXT;
42651
 
  _debug        BOOL := false;
42652
 
  _r            RECORD;
42653
 
 
42654
 
BEGIN
42655
 
  -- If the value passed in is NULL then we want to pass back an empty string
42656
 
  IF(_value IS NULL) THEN
42657
 
    RETURN '';
42658
 
  END IF;
42659
 
 
42660
 
  SELECT * INTO _r
42661
 
  FROM locale
42662
 
  WHERE (locale_id=getUsrLocaleId());
42663
 
 
42664
 
  _decimal := COALESCE(SUBSTRING(_r.locale_qtyformat FROM 1 FOR 1), '.');
42665
 
  _neg     := COALESCE(SUBSTRING(_r.locale_qtyformat FROM 2 FOR 1), '-');
42666
 
  _group   := COALESCE(SUBSTRING(_r.locale_qtyformat FROM 3 FOR 1), ',');
42667
 
 
42668
 
  _scale   := CASE WHEN _type = 'cost'       THEN _r.locale_cost_scale
42669
 
                   WHEN _type = 'extprice'   THEN _r.locale_extprice_scale
42670
 
                   WHEN _type = 'percent'    THEN _r.locale_percent_scale
42671
 
                   WHEN _type = 'purchprice' THEN _r.locale_purchprice_scale
42672
 
                   WHEN _type = 'qty'        THEN _r.locale_qty_scale
42673
 
                   WHEN _type = 'qtyper'     THEN _r.locale_qtyper_scale
42674
 
                   WHEN _type = 'salesprice' THEN _r.locale_salesprice_scale
42675
 
                   WHEN _type = 'uomratio'   THEN _r.locale_uomratio_scale
42676
 
                   WHEN _type = 'weight'     THEN _r.locale_weight_scale
42677
 
                   WHEN SUBSTRING(_type FOR 4) = 'curr' THEN _r.locale_curr_scale
42678
 
                   ELSE 2
42679
 
              END;
42680
 
 
42681
 
  _value        := round(_value, _scale);
42682
 
  _abs          := ABS(_value);
42683
 
  _magnitudecnt := TRUNC(_abs / 10);
42684
 
 
42685
 
  IF (_debug) THEN
42686
 
    RAISE NOTICE '_value % _abs % _scale % _neg % _decimal % _group % ',
42687
 
                 _value, _abs, _scale, _decimal, _group, _scale;
42688
 
  END IF;
42689
 
 
42690
 
  IF (_value < 0) THEN
42691
 
    _string := _neg;
42692
 
  ELSE
42693
 
    _string := '';
42694
 
  END IF;
42695
 
 
42696
 
  WHILE (_magnitudecnt >= 1) LOOP
42697
 
    _magnitudecnt := TRUNC(_magnitudecnt / 10);
42698
 
    IF (LENGTH(_wholefmt) % 3 = 0) THEN
42699
 
      _wholefmt := '"' || _group || '"' || _wholefmt;
42700
 
    END IF;
42701
 
    _wholefmt := '9' || _wholefmt;
42702
 
  END LOOP;
42703
 
 
42704
 
  IF (_scale > 0) THEN
42705
 
    _abs := (_abs * (10 ^ _scale));
42706
 
    _abs := TRUNC(_abs);
42707
 
    _wholefmt := _wholefmt || '"' || _decimal || '"' || REPEAT('0', _scale);
42708
 
  END IF;
42709
 
 
42710
 
  _wholefmt := 'FM' || _wholefmt;
42711
 
  _string := _string || to_char(_abs, _wholefmt);
42712
 
 
42713
 
  RETURN _string;
42714
 
END;$_$;
42715
 
 
42716
 
 
42717
 
ALTER FUNCTION public.formatnumeric(numeric, text) OWNER TO admin;
42718
 
 
42719
 
--
42720
 
--
42721
 
 
42722
 
CREATE FUNCTION formatperiodname(integer, character) RETURNS text
42723
 
    LANGUAGE plpgsql
42724
 
    AS $_$
42725
 
DECLARE
42726
 
  pPeriodId ALIAS FOR $1;
42727
 
  pInterval ALIAS FOR $2;
42728
 
  _result TEXT;
42729
 
 
42730
 
BEGIN
42731
 
 
42732
 
--...for Month
42733
 
 
42734
 
   IF (pInterval='M') THEN
42735
 
        SELECT
42736
 
          (CASE
42737
 
                      WHEN period_name='' THEN
42738
 
                        formatdate(period_start) || '-' || formatdate(period_end)
42739
 
                      ELSE period_name
42740
 
          END) INTO _result
42741
 
        FROM period
42742
 
        WHERE (period_id=pPeriodId);
42743
 
 
42744
 
        RETURN _result;
42745
 
 
42746
 
--...for Quarter
42747
 
 
42748
 
        ELSE IF (pInterval='Q') THEN
42749
 
                SELECT
42750
 
                        ('Q' || period_quarter || '-' || EXTRACT(year from yearperiod_end)) INTO _result
42751
 
                FROM period, yearperiod
42752
 
                WHERE ((period_id=pPeriodId)
42753
 
                AND (period_yearperiod_id=yearperiod_id));
42754
 
 
42755
 
                RETURN _result;
42756
 
--...for Year
42757
 
        ELSE
42758
 
                SELECT
42759
 
                        EXTRACT(year FROM yearperiod_end) INTO _result
42760
 
                FROM period,yearperiod
42761
 
                WHERE ((period_id=pPeriodId)
42762
 
                AND (period_yearperiod_id=yearperiod_id));
42763
 
 
42764
 
                RETURN _result;
42765
 
        END IF;
42766
 
   END IF;
42767
 
 
42768
 
   RETURN 'Err';
42769
 
 
42770
 
END;
42771
 
$_$;
42772
 
 
42773
 
 
42774
 
ALTER FUNCTION public.formatperiodname(integer, character) OWNER TO admin;
42775
 
 
42776
 
--
42777
 
--
42778
 
 
42779
 
CREATE FUNCTION formatplonumber(integer) RETURNS text
42780
 
    LANGUAGE plpgsql IMMUTABLE
42781
 
    AS $_$
42782
 
DECLARE
42783
 
  pPlanordid ALIAS FOR $1;
42784
 
  _result TEXT;
42785
 
 
42786
 
BEGIN
42787
 
 
42788
 
  SELECT (TEXT(planord_number) || '-' || TEXT(planord_subnumber)) INTO _result
42789
 
  FROM planord
42790
 
  WHERE (planord_id=pPlanordid);
42791
 
 
42792
 
  RETURN _result;
42793
 
 
42794
 
END;
42795
 
$_$;
42796
 
 
42797
 
 
42798
 
ALTER FUNCTION public.formatplonumber(integer) OWNER TO admin;
42799
 
 
42800
 
--
42801
 
--
42802
 
 
42803
 
CREATE FUNCTION formatprcnt(numeric) RETURNS text
42804
 
    LANGUAGE sql IMMUTABLE
42805
 
    AS $_$
42806
 
SELECT formatNumeric($1 * 100, 'percent')  AS result
42807
 
$_$;
42808
 
 
42809
 
 
42810
 
ALTER FUNCTION public.formatprcnt(numeric) OWNER TO admin;
42811
 
 
42812
 
--
42813
 
--
42814
 
 
42815
 
CREATE FUNCTION formatprice(numeric) RETURNS text
42816
 
    LANGUAGE sql IMMUTABLE
42817
 
    AS $_$
42818
 
  SELECT formatNumeric($1, 'salesprice') AS result;
42819
 
$_$;
42820
 
 
42821
 
 
42822
 
ALTER FUNCTION public.formatprice(numeric) OWNER TO admin;
42823
 
 
42824
 
--
42825
 
--
42826
 
 
42827
 
CREATE FUNCTION formatpurchprice(numeric) RETURNS text
42828
 
    LANGUAGE plpgsql IMMUTABLE
42829
 
    AS $_$
42830
 
BEGIN
42831
 
  RETURN formatNumeric($1, 'purchprice');
42832
 
END;$_$;
42833
 
 
42834
 
 
42835
 
ALTER FUNCTION public.formatpurchprice(numeric) OWNER TO admin;
42836
 
 
42837
 
--
42838
 
--
42839
 
 
42840
 
CREATE FUNCTION formatqty(numeric) RETURNS text
42841
 
    LANGUAGE plpgsql IMMUTABLE
42842
 
    AS $_$
42843
 
BEGIN
42844
 
  RETURN formatNumeric($1, 'qty');
42845
 
END;$_$;
42846
 
 
42847
 
 
42848
 
ALTER FUNCTION public.formatqty(numeric) OWNER TO admin;
42849
 
 
42850
 
--
42851
 
--
42852
 
 
42853
 
CREATE FUNCTION formatqtyper(numeric) RETURNS text
42854
 
    LANGUAGE plpgsql IMMUTABLE
42855
 
    AS $_$
42856
 
BEGIN
42857
 
  RETURN formatNumeric($1, 'qtyper');
42858
 
END;$_$;
42859
 
 
42860
 
 
42861
 
ALTER FUNCTION public.formatqtyper(numeric) OWNER TO admin;
42862
 
 
42863
 
--
42864
 
--
42865
 
 
42866
 
CREATE FUNCTION formatratio(numeric) RETURNS text
42867
 
    LANGUAGE sql IMMUTABLE
42868
 
    AS $_$
42869
 
  SELECT formatNumeric($1, 'uomratio');
42870
 
$_$;
42871
 
 
42872
 
 
42873
 
ALTER FUNCTION public.formatratio(numeric) OWNER TO admin;
42874
 
 
42875
 
--
42876
 
--
42877
 
 
42878
 
CREATE FUNCTION formatrevnumber(text, integer) RETURNS text
42879
 
    LANGUAGE plpgsql
42880
 
    AS $_$
42881
 
DECLARE
42882
 
  pRevType      ALIAS FOR $1;
42883
 
  pRevId        ALIAS FOR $2;
42884
 
  _revision     TEXT;
42885
 
 
42886
 
BEGIN
42887
 
  --See if revision control turned on (Postbooks will not ever have this)
42888
 
  IF (fetchmetricbool('RevControl')) THEN
42889
 
    SELECT rev_number INTO _revision
42890
 
    FROM rev
42891
 
    WHERE ((rev_target_type=pRevType)
42892
 
    AND (rev_id=pRevId));
42893
 
  END IF;
42894
 
 
42895
 
  RETURN COALESCE(_revision,'');
42896
 
 
42897
 
END;
42898
 
$_$;
42899
 
 
42900
 
 
42901
 
ALTER FUNCTION public.formatrevnumber(text, integer) OWNER TO admin;
42902
 
 
42903
 
--
42904
 
--
42905
 
 
42906
 
CREATE FUNCTION formatsalesprice(numeric) RETURNS text
42907
 
    LANGUAGE plpgsql IMMUTABLE
42908
 
    AS $_$
42909
 
BEGIN
42910
 
  RETURN formatNumeric($1, 'salesprice');
42911
 
END;$_$;
42912
 
 
42913
 
 
42914
 
ALTER FUNCTION public.formatsalesprice(numeric) OWNER TO admin;
42915
 
 
42916
 
--
42917
 
--
42918
 
 
42919
 
CREATE FUNCTION formatscrap(numeric) RETURNS text
42920
 
    LANGUAGE sql IMMUTABLE
42921
 
    AS $_$
42922
 
  SELECT formatNumeric(($1 * 100), 'percent') AS result
42923
 
$_$;
42924
 
 
42925
 
 
42926
 
ALTER FUNCTION public.formatscrap(numeric) OWNER TO admin;
42927
 
 
42928
 
--
42929
 
--
42930
 
 
42931
 
CREATE FUNCTION formatshipmentnumber(integer) RETURNS text
42932
 
    LANGUAGE plpgsql IMMUTABLE
42933
 
    AS $_$
42934
 
DECLARE
42935
 
  pshipheadid    ALIAS FOR $1;
42936
 
BEGIN
42937
 
  RETURN ( SELECT COALESCE(shiphead_number::TEXT, '')
42938
 
           FROM shiphead
42939
 
           WHERE (shiphead_id=pshipheadid) );
42940
 
END;
42941
 
$_$;
42942
 
 
42943
 
 
42944
 
ALTER FUNCTION public.formatshipmentnumber(integer) OWNER TO admin;
42945
 
 
42946
 
--
42947
 
--
42948
 
 
42949
 
CREATE FUNCTION formatsobarcode(integer) RETURNS text
42950
 
    LANGUAGE plpgsql IMMUTABLE
42951
 
    AS $_$
42952
 
DECLARE
42953
 
  pSoheadid ALIAS FOR $1;
42954
 
  _barcode TEXT;
42955
 
BEGIN
42956
 
 
42957
 
  SELECT ( E'\138SOXX' ||
42958
 
           LENGTH(TEXT(cohead_number)) || TEXT(cohead_number) ) INTO _barcode
42959
 
  FROM cohead
42960
 
  WHERE (cohead_id=pSoheadid);
42961
 
 
42962
 
  RETURN _barcode;
42963
 
 
42964
 
END;
42965
 
$_$;
42966
 
 
42967
 
 
42968
 
ALTER FUNCTION public.formatsobarcode(integer) OWNER TO admin;
42969
 
 
42970
 
--
42971
 
--
42972
 
 
42973
 
CREATE FUNCTION formatsoitembarcode(integer) RETURNS text
42974
 
    LANGUAGE plpgsql IMMUTABLE
42975
 
    AS $_$
42976
 
DECLARE
42977
 
  pSoitemid ALIAS FOR $1;
42978
 
  _barcode TEXT;
42979
 
BEGIN
42980
 
 
42981
 
  SELECT ( E'\138SOLI' ||
42982
 
           LENGTH(TEXT(cohead_number)) || LENGTH(formatsolinenumber(coitem_id)) ||
42983
 
           TEXT(cohead_number) || formatsolinenumber(coitem_id) ) INTO _barcode
42984
 
  FROM cohead, coitem
42985
 
  WHERE ( (coitem_cohead_id=cohead_id)
42986
 
   AND (coitem_id=pSoitemid) );
42987
 
 
42988
 
  RETURN _barcode;
42989
 
 
42990
 
END;
42991
 
$_$;
42992
 
 
42993
 
 
42994
 
ALTER FUNCTION public.formatsoitembarcode(integer) OWNER TO admin;
42995
 
 
42996
 
--
42997
 
--
42998
 
 
42999
 
CREATE FUNCTION formatsoitemnumber(integer) RETURNS text
43000
 
    LANGUAGE plpgsql
43001
 
    AS $_$
43002
 
DECLARE
43003
 
  targetSoitemid ALIAS FOR $1;
43004
 
BEGIN
43005
 
  RETURN ( SELECT (cohead_number::TEXT || '-' || formatsolinenumber(coitem_id))
43006
 
           FROM cohead, coitem
43007
 
           WHERE ((coitem_cohead_id=cohead_id)
43008
 
            AND (coitem_id=targetSoitemid)) );
43009
 
END;
43010
 
$_$;
43011
 
 
43012
 
 
43013
 
ALTER FUNCTION public.formatsoitemnumber(integer) OWNER TO admin;
43014
 
 
43015
 
--
43016
 
--
43017
 
 
43018
 
CREATE FUNCTION formatsonumber(integer) RETURNS text
43019
 
    LANGUAGE sql STABLE
43020
 
    AS $_$
43021
 
SELECT COALESCE((SELECT (text(cohead_number) || '-' || formatSoLineNumber(coitem_id))
43022
 
                   FROM coitem JOIN cohead ON (coitem_cohead_id=cohead_id)
43023
 
                  WHERE (coitem_id=($1))),'DELETED');
43024
 
$_$;
43025
 
 
43026
 
 
43027
 
ALTER FUNCTION public.formatsonumber(integer) OWNER TO admin;
43028
 
 
43029
 
--
43030
 
--
43031
 
 
43032
 
CREATE FUNCTION formattime(timestamp with time zone) RETURNS text
43033
 
    LANGUAGE sql IMMUTABLE
43034
 
    AS $_$
43035
 
  SELECT TO_CHAR($1, ( SELECT locale_timeformat
43036
 
                       FROM locale, usr
43037
 
                       WHERE ((usr_locale_id=locale_id)
43038
 
                        AND (usr_username=getEffectiveXtUser())) ) ) AS result
43039
 
$_$;
43040
 
 
43041
 
 
43042
 
ALTER FUNCTION public.formattime(timestamp with time zone) OWNER TO admin;
43043
 
 
43044
 
--
43045
 
--
43046
 
 
43047
 
CREATE FUNCTION formattime(numeric) RETURNS text
43048
 
    LANGUAGE sql IMMUTABLE
43049
 
    AS $_$
43050
 
  SELECT LTRIM(TO_CHAR(COALESCE($1, 0), '999999990.0'));
43051
 
$_$;
43052
 
 
43053
 
 
43054
 
ALTER FUNCTION public.formattime(numeric) OWNER TO admin;
43055
 
 
43056
 
--
43057
 
--
43058
 
 
43059
 
CREATE FUNCTION formatuomratio(numeric) RETURNS text
43060
 
    LANGUAGE plpgsql IMMUTABLE
43061
 
    AS $_$
43062
 
BEGIN
43063
 
  RETURN formatNumeric($1, 'uomratio');
43064
 
END;$_$;
43065
 
 
43066
 
 
43067
 
ALTER FUNCTION public.formatuomratio(numeric) OWNER TO admin;
43068
 
 
43069
 
--
43070
 
--
43071
 
 
43072
 
CREATE FUNCTION formatuserbarcode(integer) RETURNS text
43073
 
    LANGUAGE plpgsql IMMUTABLE
43074
 
    AS $_$
43075
 
DECLARE
43076
 
  pUserid ALIAS FOR $1;
43077
 
  _barcode TEXT;
43078
 
BEGIN
43079
 
 
43080
 
  SELECT formatUserBarcode(usr_username) INTO _barcode
43081
 
    FROM usr
43082
 
   WHERE(usr_id=pUserid);
43083
 
 
43084
 
  RETURN _barcode;
43085
 
 
43086
 
END;
43087
 
$_$;
43088
 
 
43089
 
 
43090
 
ALTER FUNCTION public.formatuserbarcode(integer) OWNER TO admin;
43091
 
 
43092
 
--
43093
 
--
43094
 
 
43095
 
CREATE FUNCTION formatuserbarcode(text) RETURNS text
43096
 
    LANGUAGE plpgsql IMMUTABLE
43097
 
    AS $_$
43098
 
DECLARE
43099
 
  pUsername ALIAS FOR $1;
43100
 
  _barcode TEXT;
43101
 
BEGIN
43102
 
 
43103
 
  _barcode := ( E'\138USER' || LENGTH(pUsername)::TEXT || pUsername );
43104
 
 
43105
 
  RETURN _barcode;
43106
 
 
43107
 
END;
43108
 
$_$;
43109
 
 
43110
 
 
43111
 
ALTER FUNCTION public.formatuserbarcode(text) OWNER TO admin;
43112
 
 
43113
 
--
43114
 
--
43115
 
 
43116
 
CREATE FUNCTION formatweight(numeric) RETURNS text
43117
 
    LANGUAGE sql IMMUTABLE
43118
 
    AS $_$
43119
 
SELECT formatNumeric($1, 'weight') AS result
43120
 
$_$;
43121
 
 
43122
 
 
43123
 
ALTER FUNCTION public.formatweight(numeric) OWNER TO admin;
43124
 
 
43125
 
--
43126
 
--
43127
 
 
43128
 
CREATE FUNCTION formatwobarcode(integer) RETURNS text
43129
 
    LANGUAGE plpgsql IMMUTABLE
43130
 
    AS $_$
43131
 
DECLARE
43132
 
  pWoid ALIAS FOR $1;
43133
 
  _barcode TEXT;
43134
 
BEGIN
43135
 
 
43136
 
  SELECT ( E'\138WOXX' ||
43137
 
           LENGTH(wo_number::TEXT) || LENGTH(wo_subnumber::TEXT) ||
43138
 
           wo_number::TEXT || wo_subnumber::TEXT ) INTO _barcode
43139
 
  FROM wo
43140
 
  WHERE (wo_id=pWoid);
43141
 
 
43142
 
  RETURN _barcode;
43143
 
 
43144
 
END;
43145
 
$_$;
43146
 
 
43147
 
 
43148
 
ALTER FUNCTION public.formatwobarcode(integer) OWNER TO admin;
43149
 
 
43150
 
--
43151
 
--
43152
 
 
43153
 
CREATE FUNCTION formatwonumber(integer) RETURNS text
43154
 
    LANGUAGE plpgsql IMMUTABLE
43155
 
    AS $_$
43156
 
DECLARE
43157
 
  pWoid ALIAS FOR $1;
43158
 
 
43159
 
BEGIN
43160
 
 
43161
 
  RETURN ( SELECT (wo_number::TEXT || '-' || wo_subnumber::TEXT)
43162
 
           FROM wo
43163
 
           WHERE (wo_id=pWoid) );
43164
 
 
43165
 
END;
43166
 
$_$;
43167
 
 
43168
 
 
43169
 
ALTER FUNCTION public.formatwonumber(integer) OWNER TO admin;
43170
 
 
43171
 
--
43172
 
--
43173
 
 
43174
 
CREATE FUNCTION formatwooperseq(integer) RETURNS text
43175
 
    LANGUAGE plpgsql
43176
 
    AS $_$
43177
 
DECLARE
43178
 
  pWooperId  ALIAS FOR $1;
43179
 
  _result    TEXT;
43180
 
 
43181
 
BEGIN
43182
 
 
43183
 
  IF pWooperId = -1 THEN
43184
 
    RETURN '';
43185
 
  ELSE
43186
 
    SELECT wooper_seqnumber INTO _result
43187
 
    FROM xtmfg.wooper
43188
 
    WHERE (wooper_id=pWooperId);
43189
 
  END IF;
43190
 
 
43191
 
  RETURN _result;
43192
 
END;
43193
 
$_$;
43194
 
 
43195
 
 
43196
 
ALTER FUNCTION public.formatwooperseq(integer) OWNER TO admin;
43197
 
 
43198
 
--
43199
 
--
43200
 
 
43201
 
CREATE FUNCTION forwardupdateaccount(integer) RETURNS integer
43202
 
    LANGUAGE plpgsql
43203
 
    AS $_$
43204
 
DECLARE
43205
 
  pAccntid ALIAS FOR $1;
43206
 
  _r RECORD;
43207
 
  _trialbalid INTEGER;
43208
 
 
43209
 
BEGIN
43210
 
  SELECT trialbal_id, trialbal_dirty,
43211
 
         CASE WHEN (trialbal_dirty) THEN 0
43212
 
              ELSE 1
43213
 
         END AS dirty_seq INTO _r
43214
 
    FROM trialbal, period
43215
 
   WHERE ((trialbal_period_id=period_id)
43216
 
     AND  (trialbal_accnt_id=pAccntid))
43217
 
   ORDER BY dirty_seq, period_start
43218
 
   LIMIT 1;
43219
 
  IF (FOUND) THEN
43220
 
    IF (_r.trialbal_dirty) THEN
43221
 
      RETURN forwardUpdateTrialBalance(_r.trialbal_id);
43222
 
    ELSE
43223
 
      RETURN _r.trialbal_id;
43224
 
    END IF;
43225
 
  ELSE
43226
 
      _trialbalid := nextval('trialbal_trialbal_id_seq');
43227
 
      
43228
 
      INSERT INTO trialbal
43229
 
      ( trialbal_id,
43230
 
        trialbal_period_id, trialbal_accnt_id,
43231
 
        trialbal_beginning, trialbal_ending,
43232
 
        trialbal_debits, trialbal_credits, trialbal_dirty )
43233
 
      SELECT
43234
 
        _trialbalid,
43235
 
        period_id, pAccntid,
43236
 
        0, 0,
43237
 
        0, 0, FALSE
43238
 
      FROM period
43239
 
      ORDER BY period_start LIMIT 1;
43240
 
 
43241
 
      RETURN forwardUpdateTrialBalance(_trialbalid);
43242
 
  END IF;
43243
 
 
43244
 
  RETURN -1;
43245
 
END;
43246
 
$_$;
43247
 
 
43248
 
 
43249
 
ALTER FUNCTION public.forwardupdateaccount(integer) OWNER TO admin;
43250
 
 
43251
 
--
43252
 
--
43253
 
 
43254
 
CREATE FUNCTION forwardupdateinvbalance(integer) RETURNS integer
43255
 
    LANGUAGE plpgsql
43256
 
    AS $_$
43257
 
DECLARE
43258
 
  pInvbalid ALIAS FOR $1;
43259
 
  _p RECORD;
43260
 
  _r RECORD;
43261
 
  _qohEnding NUMERIC;
43262
 
  _valueEnding NUMERIC;
43263
 
  _nnEnding NUMERIC;
43264
 
  _nnvalEnding NUMERIC;
43265
 
 
43266
 
BEGIN
43267
 
 
43268
 
  SELECT invbal_itemsite_id, 
43269
 
         invbal_qoh_ending,
43270
 
         invbal_value_ending,
43271
 
         invbal_nn_ending,
43272
 
         invbal_nnval_ending,
43273
 
         period_end INTO _p
43274
 
  FROM invbal
43275
 
    JOIN period ON (invbal_period_id=period_id)
43276
 
    JOIN itemsite ON (invbal_itemsite_id=itemsite_id)
43277
 
  WHERE (invbal_id=pInvbalid);
43278
 
 
43279
 
  _qohEnding = _p.invbal_qoh_ending;
43280
 
  _valueEnding = _p.invbal_value_ending;
43281
 
  _nnEnding = _p.invbal_nn_ending;
43282
 
  _nnvalEnding = _p.invbal_nnval_ending;
43283
 
 
43284
 
  FOR _r IN SELECT period_id, period_end,
43285
 
                   invbal_id, 
43286
 
                   invbal_qty_in, invbal_qty_out,
43287
 
                   invbal_value_in, invbal_value_out,
43288
 
                   invbal_nn_in, invbal_nn_out,
43289
 
                   invbal_nnval_in, invbal_nnval_out
43290
 
            FROM period 
43291
 
              LEFT OUTER JOIN invbal
43292
 
                 ON ( (invbal_period_id=period_id) AND (invbal_itemsite_id=_p.invbal_itemsite_id) )
43293
 
            WHERE (period_start > _p.period_end)
43294
 
            ORDER BY period_start LOOP
43295
 
 
43296
 
    IF (_r.invbal_id IS NULL) THEN
43297
 
 
43298
 
      INSERT INTO invbal
43299
 
      ( invbal_period_id, invbal_itemsite_id,
43300
 
        invbal_qoh_beginning, invbal_qoh_ending,
43301
 
        invbal_qty_in, invbal_qty_out,
43302
 
        invbal_value_beginning, invbal_value_ending,
43303
 
        invbal_value_in, invbal_value_out, 
43304
 
        invbal_nn_beginning, invbal_nn_ending,
43305
 
        invbal_nn_in, invbal_nn_out,
43306
 
        invbal_nnval_beginning, invbal_nnval_ending,
43307
 
        invbal_nnval_in, invbal_nnval_out, 
43308
 
        invbal_dirty )
43309
 
      VALUES
43310
 
      ( _r.period_id, _p.invbal_itemsite_id,
43311
 
        _qohEnding, _qohEnding,
43312
 
        0, 0, 
43313
 
        _valueEnding, _valueEnding,
43314
 
        0, 0,
43315
 
        _nnEnding, _nnEnding,
43316
 
        0, 0, 
43317
 
        _nnvalEnding, _nnvalEnding,
43318
 
        0, 0,
43319
 
        FALSE );
43320
 
    ELSE
43321
 
      UPDATE invbal
43322
 
      SET invbal_qoh_beginning = (_qohEnding),
43323
 
          invbal_qoh_ending = (_qohEnding + _r.invbal_qty_in - _r.invbal_qty_out),
43324
 
          invbal_value_beginning = (_valueEnding),
43325
 
          invbal_value_ending = (_valueEnding + _r.invbal_value_in - _r.invbal_value_out),
43326
 
          invbal_nn_beginning = (_nnEnding),
43327
 
          invbal_nn_ending = (_nnEnding + _r.invbal_nn_in - _r.invbal_nn_out),
43328
 
          invbal_nnval_beginning = (_nnvalEnding),
43329
 
          invbal_nnval_ending = (_nnvalEnding + _r.invbal_nnval_in - _r.invbal_nnval_out),
43330
 
          invbal_dirty = FALSE
43331
 
      WHERE (invbal_id=_r.invbal_id);
43332
 
 
43333
 
      _qohEnding = (_qohEnding + _r.invbal_qty_in - _r.invbal_qty_out);
43334
 
      _valueEnding = (_valueEnding + _r.invbal_value_in - _r.invbal_value_out);
43335
 
      _nnEnding = (_nnEnding + _r.invbal_nn_in - _r.invbal_nn_out);
43336
 
      _nnvalEnding = (_nnvalEnding + _r.invbal_nnval_in - _r.invbal_nnval_out);
43337
 
    END IF;
43338
 
  END LOOP;
43339
 
 
43340
 
  UPDATE invbal
43341
 
  SET invbal_dirty = false
43342
 
  WHERE (invbal_id=pInvbalid);
43343
 
 
43344
 
  RETURN pInvbalid;
43345
 
 
43346
 
END;
43347
 
$_$;
43348
 
 
43349
 
 
43350
 
ALTER FUNCTION public.forwardupdateinvbalance(integer) OWNER TO admin;
43351
 
 
43352
 
--
43353
 
--
43354
 
 
43355
 
CREATE FUNCTION forwardupdateitemsite(integer) RETURNS integer
43356
 
    LANGUAGE plpgsql
43357
 
    AS $_$
43358
 
DECLARE
43359
 
  pItemsiteId ALIAS FOR $1;
43360
 
  _r RECORD;
43361
 
  _invbalid INTEGER;
43362
 
 
43363
 
BEGIN
43364
 
  SELECT invbal_id INTO _r
43365
 
  FROM invbal
43366
 
      JOIN period ON (invbal_period_id=period_id)
43367
 
  WHERE (invbal_itemsite_id=pItemsiteid)
43368
 
  ORDER BY period_start
43369
 
  LIMIT 1;
43370
 
 
43371
 
  IF (FOUND) THEN
43372
 
    RETURN forwardUpdateInvbalance(_r.invbal_id);
43373
 
  ELSE
43374
 
      _invbalid := nextval('invbal_invbal_id_seq');
43375
 
      
43376
 
      INSERT INTO invbal
43377
 
      ( invbal_id,
43378
 
        invbal_period_id, invbal_itemsite_id,
43379
 
        invbal_qoh_beginning, invbal_qoh_ending,
43380
 
        invbal_qty_in, invbal_qty_out,
43381
 
        invbal_value_beginning, invbal_value_ending,
43382
 
        invbal_value_in, invbal_value_out,
43383
 
        invbal_nn_beginning, invbal_nn_ending,
43384
 
        invbal_nn_in, invbal_nn_out,
43385
 
        invbal_nnval_beginning, invbal_nnval_ending,
43386
 
        invbal_nnval_in, invbal_nnval_out,
43387
 
        invbal_dirty )
43388
 
      SELECT
43389
 
        _invbalid,
43390
 
        period_id, pItemsiteid,
43391
 
        0, 0, 0, 0, 0, 0, 0, 0,
43392
 
        0, 0, 0, 0, 0, 0, 0, 0,
43393
 
        false
43394
 
      FROM period
43395
 
      ORDER BY period_start LIMIT 1;
43396
 
 
43397
 
      RETURN forwardUpdateInvbalance(_invbalid);
43398
 
  END IF;
43399
 
 
43400
 
  RETURN -1;
43401
 
END;
43402
 
$_$;
43403
 
 
43404
 
 
43405
 
ALTER FUNCTION public.forwardupdateitemsite(integer) OWNER TO admin;
43406
 
 
43407
 
--
43408
 
--
43409
 
 
43410
 
CREATE FUNCTION forwardupdatetrialbalance(integer) RETURNS integer
43411
 
    LANGUAGE plpgsql
43412
 
    AS $_$
43413
 
DECLARE
43414
 
  pTrialbalid ALIAS FOR $1;
43415
 
  _p RECORD;
43416
 
  _r RECORD;
43417
 
  _ending NUMERIC;
43418
 
  _prevYear INTEGER;
43419
 
  _currYear INTEGER;
43420
 
  _prevYearClosed BOOLEAN;
43421
 
  _currYearClosed BOOLEAN;
43422
 
  _result INTEGER;
43423
 
 
43424
 
BEGIN
43425
 
 
43426
 
  SELECT trialbal_accnt_id, trialbal_ending,
43427
 
         yearperiod_id, yearperiod_closed,
43428
 
         period_end, accnt_type IN ('E', 'R') AS revexp INTO _p
43429
 
  FROM trialbal, period, yearperiod, accnt
43430
 
  WHERE ( (trialbal_period_id=period_id)
43431
 
   AND (yearperiod_id=period_yearperiod_id)
43432
 
   AND (trialbal_accnt_id=accnt_id)
43433
 
   AND (trialbal_id=pTrialbalid) );
43434
 
 
43435
 
  _ending = _p.trialbal_ending;
43436
 
 
43437
 
  SELECT yearperiod_id, yearperiod_closed INTO _prevYear, _prevYearClosed
43438
 
    FROM yearperiod
43439
 
   WHERE (_p.period_end BETWEEN yearperiod_start AND yearperiod_end);
43440
 
  IF (NOT FOUND) THEN
43441
 
    _prevYear := -1;
43442
 
    _prevYearClosed := false;
43443
 
  END IF;
43444
 
 
43445
 
  FOR _r IN SELECT period_id, period_end,
43446
 
                   trialbal_id, trialbal_debits, trialbal_credits,
43447
 
                   trialbal_yearend
43448
 
            FROM period LEFT OUTER JOIN trialbal
43449
 
                 ON ( (trialbal_period_id=period_id) AND (trialbal_accnt_id=_p.trialbal_accnt_id) )
43450
 
            WHERE (period_start > _p.period_end)
43451
 
            ORDER BY period_start LOOP
43452
 
 
43453
 
    SELECT yearperiod_id, yearperiod_closed INTO _currYear, _currYearClosed
43454
 
      FROM yearperiod
43455
 
     WHERE (_r.period_end BETWEEN yearperiod_start AND yearperiod_end);
43456
 
    IF (NOT FOUND) THEN
43457
 
      _currYear := -1;
43458
 
      _currYearClosed := false;
43459
 
    END IF;
43460
 
 
43461
 
    IF (_p.revexp AND _currYear != _prevYear) THEN
43462
 
      _ending := 0;
43463
 
      IF (_prevYearClosed) THEN
43464
 
        SELECT updateRetainedEarnings(_prevYear) INTO _result;
43465
 
        IF (_result < 0) THEN
43466
 
          RETURN _result;
43467
 
        END IF;
43468
 
      END IF;
43469
 
    END IF;
43470
 
 
43471
 
    _prevYear := _currYear;
43472
 
    _prevYearClosed := _currYearClosed;
43473
 
 
43474
 
    IF (_r.trialbal_id IS NULL) THEN
43475
 
      -- SELECT SUM(gltrans_amount) INTO _glAmount
43476
 
       -- FROM gltrans
43477
 
       -- WHERE ( (gltrans_date BETWEEN _r.period_start and _r.period_end )
43478
 
         -- AND   (gltrans_accnt_id=_p.trialbal_accnt_id)
43479
 
         -- AND   (gltrans_posted) );
43480
 
        -- and change 2nd and 3rd VALUES line of INSERT to read
43481
 
        --      _ending, _ending + _glAmount,
43482
 
        --      noneg(0 - _glAmount), noneg(_glAmount), FALSE );
43483
 
 
43484
 
      INSERT INTO trialbal
43485
 
      ( trialbal_period_id, trialbal_accnt_id,
43486
 
        trialbal_beginning, trialbal_ending,
43487
 
        trialbal_debits, trialbal_credits, trialbal_dirty )
43488
 
      VALUES
43489
 
      ( _r.period_id, _p.trialbal_accnt_id,
43490
 
        _ending, _ending,
43491
 
        0, 0, FALSE );
43492
 
    ELSE
43493
 
      UPDATE trialbal
43494
 
      SET trialbal_beginning = (_ending + trialbal_yearend),
43495
 
          trialbal_ending = (_ending + trialbal_yearend - _r.trialbal_debits + _r.trialbal_credits),
43496
 
          trialbal_dirty = FALSE
43497
 
      WHERE (trialbal_id=_r.trialbal_id);
43498
 
 
43499
 
      _ending = (_ending + _r.trialbal_yearend - _r.trialbal_debits + _r.trialbal_credits);
43500
 
    END IF;
43501
 
  END LOOP;
43502
 
 
43503
 
  UPDATE trialbal
43504
 
  SET trialbal_dirty = FALSE
43505
 
  WHERE (trialbal_id=pTrialbalid);
43506
 
 
43507
 
  RETURN pTrialbalid;
43508
 
 
43509
 
END;
43510
 
$_$;
43511
 
 
43512
 
 
43513
 
ALTER FUNCTION public.forwardupdatetrialbalance(integer) OWNER TO admin;
43514
 
 
43515
 
--
43516
 
--
43517
 
 
43518
 
CREATE FUNCTION freezeaccountingperiod(integer) RETURNS integer
43519
 
    LANGUAGE plpgsql
43520
 
    AS $_$
43521
 
DECLARE
43522
 
  pPeriodid ALIAS FOR $1;
43523
 
 
43524
 
BEGIN
43525
 
 
43526
 
  IF ( ( SELECT period_freeze
43527
 
         FROM period
43528
 
         WHERE (period_id=pPeriodid) ) ) THEN
43529
 
    RETURN -2;
43530
 
  END IF;
43531
 
 
43532
 
  UPDATE period
43533
 
  SET period_freeze=TRUE
43534
 
  WHERE (period_id=pPeriodid);
43535
 
 
43536
 
  RETURN pPeriodid;
43537
 
 
43538
 
END;
43539
 
$_$;
43540
 
 
43541
 
 
43542
 
ALTER FUNCTION public.freezeaccountingperiod(integer) OWNER TO admin;
43543
 
 
43544
 
--
43545
 
--
43546
 
 
43547
 
CREATE FUNCTION freightdetail(text, integer, integer, integer, date, text, integer) RETURNS SETOF freightdata
43548
 
    LANGUAGE plpgsql
43549
 
    AS $_$
43550
 
DECLARE
43551
 
  pOrderType ALIAS FOR $1;
43552
 
  pOrderId ALIAS FOR $2;
43553
 
  pCustId ALIAS FOR $3;
43554
 
  pShiptoId ALIAS FOR $4;
43555
 
  pOrderDate ALIAS FOR $5;
43556
 
  pShipVia ALIAS FOR $6;
43557
 
  pCurrId ALIAS FOR $7;
43558
 
 
43559
 
  _row freightData%ROWTYPE;
43560
 
  _order RECORD;
43561
 
  _weights RECORD;
43562
 
  _includepkgweight BOOLEAN := FALSE;
43563
 
  _qry TEXT;
43564
 
  _debug BOOLEAN := FALSE;
43565
 
 
43566
 
BEGIN
43567
 
  IF (_debug) THEN
43568
 
    RAISE NOTICE 'pOrderType = %', pOrderType;
43569
 
    RAISE NOTICE 'pOrderId = %', pOrderId;
43570
 
    RAISE NOTICE 'pCustId = %', pCustId;
43571
 
    RAISE NOTICE 'pShiptoId = %', pShiptoId;
43572
 
    RAISE NOTICE 'pOrderDate = %', pOrderDate;
43573
 
    RAISE NOTICE 'pShipVia = %', pShipVia;
43574
 
    RAISE NOTICE 'pCurrId = %', pCurrId;
43575
 
  END IF;
43576
 
 
43577
 
  SELECT fetchMetricBool('IncludePackageWeight') INTO _includepkgweight;
43578
 
 
43579
 
  --Get the order header information need to match
43580
 
  --against price schedules
43581
 
  IF (pOrderType = 'SO') THEN
43582
 
    SELECT
43583
 
      cust_id AS cust_id,
43584
 
      custtype_id,
43585
 
      custtype_code,
43586
 
      COALESCE(shipto_id, -1) AS shipto_id,
43587
 
      COALESCE(shipto_num, '') AS shipto_num,
43588
 
      COALESCE(pOrderDate, cohead_orderdate) AS orderdate,
43589
 
      COALESCE(pShipVia, cohead_shipvia) AS shipvia,
43590
 
      shipto_shipzone_id AS shipzone_id,
43591
 
      COALESCE(pCurrId, cohead_curr_id) AS curr_id,
43592
 
      currConcat(COALESCE(pCurrId, cohead_curr_id)) AS currAbbr
43593
 
    INTO _order
43594
 
      FROM cohead
43595
 
      JOIN custinfo ON (cust_id=COALESCE(pCustId, cohead_cust_id))
43596
 
      JOIN custtype ON (custtype_id=cust_custtype_id)
43597
 
      LEFT OUTER JOIN shiptoinfo ON (shipto_id=COALESCE(pShiptoId, cohead_shipto_id))
43598
 
    WHERE (cohead_id=pOrderId);
43599
 
 
43600
 
  ELSIF (pOrderType = 'QU') THEN
43601
 
    SELECT
43602
 
      quhead_cust_id AS cust_id,
43603
 
      custtype_id,
43604
 
      custtype_code,
43605
 
      COALESCE(shipto_id, -1) AS shipto_id,
43606
 
      COALESCE(shipto_num, '') AS shipto_num,
43607
 
      quhead_quotedate AS orderdate,
43608
 
      quhead_shipvia AS shipvia,
43609
 
      shipto_shipzone_id AS shipzone_id,
43610
 
      quhead_curr_id AS curr_id,
43611
 
      currConcat(quhead_curr_id) AS currAbbr
43612
 
    INTO _order
43613
 
      FROM quhead
43614
 
      JOIN custinfo ON (cust_id=quhead_cust_id)
43615
 
      JOIN custtype ON (custtype_id=cust_custtype_id)
43616
 
      LEFT OUTER JOIN shiptoinfo ON (shipto_id=quhead_shipto_id)
43617
 
    WHERE (quhead_id=pOrderId);
43618
 
 
43619
 
  ELSIF (pOrderType = 'RA') THEN
43620
 
    SELECT
43621
 
      cust_id AS cust_id,
43622
 
      custtype_id,
43623
 
      custtype_code,
43624
 
      COALESCE(shipto_id, -1) AS shipto_id,
43625
 
      COALESCE(shipto_num, '') AS shipto_num,
43626
 
      COALESCE(pOrderDate, rahead_authdate) AS orderdate,
43627
 
      ''::text AS shipvia,
43628
 
      shipto_shipzone_id AS shipzone_id,
43629
 
      COALESCE(pCurrId, rahead_curr_id) AS curr_id,
43630
 
      currConcat(COALESCE(pCurrId, rahead_curr_id)) AS currAbbr
43631
 
    INTO _order
43632
 
      FROM rahead
43633
 
      JOIN custinfo ON (cust_id=COALESCE(pCustId, rahead_cust_id))
43634
 
      JOIN custtype ON (custtype_id=cust_custtype_id)
43635
 
      LEFT OUTER JOIN shiptoinfo ON (shipto_id=COALESCE(pShiptoId, rahead_shipto_id))
43636
 
    WHERE (rahead_id=pOrderId);
43637
 
 
43638
 
  ELSE
43639
 
    RAISE EXCEPTION 'Invalid order type.';
43640
 
  END IF;
43641
 
 
43642
 
  IF (_debug) THEN
43643
 
    RAISE NOTICE 'cust_id = %', _order.cust_id;
43644
 
    RAISE NOTICE 'custtype_id = %', _order.custtype_id;
43645
 
    RAISE NOTICE 'shipto_id = %', _order.shipto_id;
43646
 
    RAISE NOTICE 'shipto_num = %', _order.shipto_num;
43647
 
    RAISE NOTICE 'orderdate = %', _order.orderdate;
43648
 
    RAISE NOTICE 'shipvia = %', _order.shipvia;
43649
 
    RAISE NOTICE 'shipzone_id = %', _order.shipzone_id;
43650
 
    RAISE NOTICE 'curr_id = %', _order.curr_id;
43651
 
    RAISE NOTICE 'currAbbr = %', _order.currAbbr;
43652
 
  END IF;
43653
 
 
43654
 
  --Get a list of aggregated weights from sites and
43655
 
  --freight classes used on order lines
43656
 
 
43657
 
  IF (_includePkgWeight) THEN
43658
 
    _qry := 'SELECT SUM(orderitem_qty_ordered * orderitem_qty_invuomratio * (item_prodweight + item_packweight)) AS weight, ';
43659
 
  ELSE
43660
 
    _qry := 'SELECT SUM(orderitem_qty_ordered * orderitem_qty_invuomratio * item_prodweight) AS weight, ';
43661
 
  END IF;
43662
 
 
43663
 
  _qry := _qry || 'itemsite_warehous_id, COALESCE(item_freightclass_id, -1) AS item_freightclass_id
43664
 
    FROM orderitem
43665
 
    JOIN itemsite ON (itemsite_id=orderitem_itemsite_id)
43666
 
    JOIN item ON (item_id=itemsite_item_id) ';
43667
 
 
43668
 
  IF (pOrderType = 'RA') THEN
43669
 
    _qry := _qry || 'JOIN raitem ON ((orderitem_id=raitem_id)
43670
 
    AND (raitem_disposition IN (''C'',''R'',''P''))) ';
43671
 
  END IF;
43672
 
 
43673
 
  _qry := _qry || '
43674
 
    WHERE ( (orderitem_orderhead_type=' || quote_literal(pOrderType) || ')
43675
 
      AND (orderitem_orderhead_id=' || quote_literal(pOrderId) || ')
43676
 
      AND (orderitem_status <> ''X'') )
43677
 
    GROUP BY itemsite_warehous_id, item_freightclass_id;';
43678
 
 
43679
 
  FOR _weights IN
43680
 
    EXECUTE _qry LOOP
43681
 
 
43682
 
    _row := calculateFreightDetail(
43683
 
      _order.cust_id, --pCustId
43684
 
      _order.custtype_id, --pCustTypeId
43685
 
      _order.custtype_code, --pCustTypeCode
43686
 
      _order.shipto_id, --pShiptoId
43687
 
      _order.shipzone_id, --pShipZoneId
43688
 
      _order.shipto_num, --pShiptoNum
43689
 
      _order.orderdate, --pOrderDate
43690
 
      _order.shipvia, --pShipVia
43691
 
      _order.curr_id, --pCurrId
43692
 
      _order.currAbbr, --pCurrAbbr
43693
 
      _weights.itemsite_warehous_id, --pItemSiteWhsId
43694
 
      _weights.item_freightclass_id, --pItemFreightclassId
43695
 
      _weights.weight --pWeight
43696
 
      );
43697
 
 
43698
 
    RETURN NEXT _row;
43699
 
 
43700
 
  END LOOP;
43701
 
  RETURN;
43702
 
END;
43703
 
$_$;
43704
 
 
43705
 
 
43706
 
ALTER FUNCTION public.freightdetail(text, integer, integer, integer, date, text, integer) OWNER TO admin;
43707
 
 
43708
 
--
43709
 
--
43710
 
 
43711
 
CREATE FUNCTION freightdetailquote(integer, text, integer, text, date, text, text, text[]) RETURNS SETOF freightdata
43712
 
    LANGUAGE plpgsql
43713
 
    AS $_$
43714
 
DECLARE
43715
 
  pCustId ALIAS FOR $1;
43716
 
  pCustNumber ALIAS FOR $2;
43717
 
  pShiptoId ALIAS FOR $3;
43718
 
  pShiptoNum ALIAS FOR $4;
43719
 
  pOrderDate ALIAS FOR $5;
43720
 
  pShipVia ALIAS FOR $6;
43721
 
  pItemArrayType ALIAS FOR $7;
43722
 
  pItemQty ALIAS FOR $8;
43723
 
    -- Array item_id format = ARRAY[['300','3'],['310','50']]
43724
 
    -- Array item_number format = ARRAY[['YTRUCK1','3'],['RTRUCK1','50']]
43725
 
    -- Array itemsite_id format = ARRAY[['293','3'],['302','50']]
43726
 
 
43727
 
  _cust RECORD;
43728
 
  _shipto RECORD;
43729
 
  _curr RECORD;
43730
 
  _includepkgweight BOOLEAN := FALSE;
43731
 
  _order_date DATE;
43732
 
  _ship_via TEXT;
43733
 
  _item_num RECORD;
43734
 
  _item_id RECORD;
43735
 
  _weights RECORD;
43736
 
  _row freightData%ROWTYPE;
43737
 
  _debug BOOLEAN := FALSE;
43738
 
 
43739
 
BEGIN
43740
 
 
43741
 
  -- Check pCustId and pCustNumber.
43742
 
  IF (pCustId IS NULL AND (pCustNumber IS NULL OR pCustNumber = '')) THEN
43743
 
    RAISE EXCEPTION 'You must specify a Customer ID or Number to get a freight quote.';
43744
 
  ELSIF (pCustId IS NULL AND pCustNumber IS NOT NULL) THEN
43745
 
    -- Get customer info using pCustNumber.
43746
 
    SELECT
43747
 
      cust_id,
43748
 
      cust_number,
43749
 
      custtype_id,
43750
 
      custtype_code,
43751
 
      cust_curr_id,
43752
 
      cust_shipvia
43753
 
    INTO _cust
43754
 
    FROM custinfo
43755
 
    LEFT JOIN custtype ON cust_custtype_id = custtype_id
43756
 
    WHERE 1=1
43757
 
      AND cust_number = pCustNumber;
43758
 
  ELSE
43759
 
    -- Get customer info using pCustId.
43760
 
    SELECT
43761
 
      cust_id,
43762
 
      cust_number,
43763
 
      custtype_id,
43764
 
      custtype_code,
43765
 
      cust_curr_id,
43766
 
      cust_shipvia
43767
 
    INTO _cust
43768
 
    FROM custinfo
43769
 
    LEFT JOIN custtype ON cust_custtype_id = custtype_id
43770
 
    WHERE 1=1
43771
 
      AND cust_id = pCustId;
43772
 
  END IF;
43773
 
 
43774
 
  IF(NOT FOUND) THEN
43775
 
    RAISE EXCEPTION 'Invalid Customer specified when trying to get a freight quote.';
43776
 
  END IF;
43777
 
 
43778
 
  -- Check pShiptoId and pShiptoNum.
43779
 
  IF (pShiptoId IS NULL AND (pShiptoNum IS NULL OR pShiptoNum = '')) THEN
43780
 
    -- Get Customer's default shipto.
43781
 
    SELECT
43782
 
      shipto_id,
43783
 
      shipto_name,
43784
 
      shipto_shipzone_id,
43785
 
      shipto_shipvia,
43786
 
      shipto_num
43787
 
    INTO _shipto
43788
 
    FROM shiptoinfo
43789
 
    WHERE 1=1
43790
 
      AND shipto_cust_id = _cust.cust_id
43791
 
      AND shipto_default;
43792
 
  ELSIF (pShiptoId IS NULL AND pShiptoNum IS NOT NULL) THEN
43793
 
    -- Get shipto info using pShiptoNum.
43794
 
    SELECT
43795
 
      shipto_id,
43796
 
      shipto_name,
43797
 
      shipto_shipzone_id,
43798
 
      shipto_shipvia,
43799
 
      shipto_num
43800
 
    INTO _shipto
43801
 
    FROM shiptoinfo
43802
 
    WHERE 1=1
43803
 
      AND shipto_cust_id = _cust.cust_id
43804
 
      AND shipto_num = pShiptoNum;
43805
 
  ELSE
43806
 
    -- Get shipto info using pShiptoId.
43807
 
    SELECT
43808
 
      shipto_id,
43809
 
      shipto_name,
43810
 
      shipto_shipzone_id,
43811
 
      shipto_shipvia,
43812
 
      shipto_num
43813
 
    INTO _shipto
43814
 
    FROM shiptoinfo
43815
 
    WHERE 1=1
43816
 
      AND shipto_cust_id = _cust.cust_id
43817
 
      AND shipto_id = pShiptoId;
43818
 
  END IF;
43819
 
 
43820
 
  IF(NOT FOUND) THEN
43821
 
    RAISE EXCEPTION 'Invalid Ship-to specified when trying to get a freight quote.';
43822
 
  END IF;
43823
 
 
43824
 
  -- Get curr info.
43825
 
  SELECT
43826
 
    curr_id,
43827
 
    curr_abbr
43828
 
  INTO _curr
43829
 
  FROM curr_symbol
43830
 
  WHERE 1=1
43831
 
    AND curr_id = _cust.cust_curr_id;
43832
 
 
43833
 
  IF(NOT FOUND) THEN
43834
 
    RAISE EXCEPTION 'Could not find currency when trying to get a freight quote.';
43835
 
  END IF;
43836
 
 
43837
 
  -- Check pOrderDate.
43838
 
  IF (pOrderDate IS NULL) THEN
43839
 
    _order_date := CURRENT_DATE;
43840
 
  ELSE
43841
 
    _order_date := pOrderDate;
43842
 
  END IF;
43843
 
 
43844
 
  -- Check pShipVia.
43845
 
  IF (pShipVia IS NULL OR pShipVia = '') THEN
43846
 
    IF (_shipto.shipto_shipvia IS NULL OR _shipto.shipto_shipvia = '') THEN
43847
 
      _ship_via := _cust.cust_shipvia;
43848
 
    ELSE
43849
 
      _ship_via := _shipto.shipto_shipvia;
43850
 
    END IF;
43851
 
  ELSE
43852
 
    _ship_via := pShipVia;
43853
 
  END IF;
43854
 
 
43855
 
  -- Determine if package weight should be included in freight calculation.
43856
 
  SELECT fetchMetricBool('IncludePackageWeight') INTO _includepkgweight;
43857
 
 
43858
 
  -- Check pItemQty.
43859
 
  IF (pItemQty IS NULL OR array_upper(pItemQty,1) IS NULL) THEN
43860
 
    -- Item Array is NULL.
43861
 
    RAISE EXCEPTION 'You must specify an Item ID, Item Number or Itemsite ID to get a freight quote.';
43862
 
  ELSIF (pItemArrayType = 'item_number' AND (array_upper(pItemQty,1) > 0)) THEN
43863
 
    -- Using item_number.
43864
 
    FOR _weights IN
43865
 
      -- Get a list of aggregated weights from sites and freight classes for items.
43866
 
      SELECT
43867
 
        CASE WHEN _includepkgweight THEN
43868
 
          SUM(qty * (item_prodweight + item_packweight))
43869
 
        ELSE
43870
 
          SUM(qty * (item_prodweight))
43871
 
        END AS weight,
43872
 
        itemsite_warehous_id,
43873
 
        COALESCE(item_freightclass_id, -1) AS item_freightclass_id
43874
 
      FROM
43875
 
        -- Create item_number -> qty record from array.
43876
 
        (SELECT
43877
 
          unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][1])) AS item_number,
43878
 
          unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][2:array_ndims(pItemQty)]))::numeric AS qty
43879
 
        ) AS itemnum_qty
43880
 
        JOIN item USING (item_number)
43881
 
        JOIN itemsite ON item_id=itemsite_item_id
43882
 
      WHERE 1=1
43883
 
        AND itemsite_warehous_id = fetchprefwarehousid()
43884
 
      GROUP BY
43885
 
        itemsite_warehous_id,
43886
 
        item_freightclass_id
43887
 
    LOOP
43888
 
      -- Calculate the freight detail for these item weights.
43889
 
      _row := calculateFreightDetail(
43890
 
        _cust.cust_id, --pCustId
43891
 
        _cust.custtype_id, --pCustTypeId
43892
 
        _cust.custtype_code, --pCustTypeCode
43893
 
        _shipto.shipto_id, --pShiptoId
43894
 
        _shipto.shipto_shipzone_id, --pShipZoneId
43895
 
        _shipto.shipto_num, --pShiptoNum
43896
 
        _order_date, --pOrderDate
43897
 
        _ship_via, --pShipVia
43898
 
        _curr.curr_id, --pCurrId
43899
 
        _curr.curr_abbr, --pCurrAbbr
43900
 
        _weights.itemsite_warehous_id, --pItemSiteWhsId
43901
 
        _weights.item_freightclass_id, --pItemFreightclassId
43902
 
        _weights.weight --pWeight
43903
 
        );
43904
 
 
43905
 
      RETURN NEXT _row;
43906
 
    END LOOP;
43907
 
 
43908
 
  ELSIF (pItemArrayType = 'item_id' AND (array_upper(pItemQty,1) > 0)) THEN
43909
 
    -- Using item_id.
43910
 
    FOR _weights IN
43911
 
      -- Get a list of aggregated weights from sites and freight classes for items.
43912
 
      SELECT
43913
 
        CASE WHEN _includepkgweight THEN
43914
 
          SUM(qty * (item_prodweight + item_packweight))
43915
 
        ELSE
43916
 
          SUM(qty * (item_prodweight))
43917
 
        END AS weight,
43918
 
        itemsite_warehous_id,
43919
 
        COALESCE(item_freightclass_id, -1) AS item_freightclass_id
43920
 
      FROM
43921
 
        -- Create item_id -> qty record from array.
43922
 
        (SELECT
43923
 
          unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][1]))::integer AS item_id,
43924
 
          unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][2:array_ndims(pItemQty)]))::numeric AS qty
43925
 
        ) AS itemid_qty
43926
 
        JOIN item USING (item_id)
43927
 
        JOIN itemsite ON item_id=itemsite_item_id
43928
 
      WHERE 1=1
43929
 
        AND itemsite_warehous_id = fetchprefwarehousid()
43930
 
      GROUP BY
43931
 
        itemsite_warehous_id,
43932
 
        item_freightclass_id
43933
 
    LOOP
43934
 
      -- Calculate the freight detail for these item weights.
43935
 
      _row := calculateFreightDetail(
43936
 
        _cust.cust_id, --pCustId
43937
 
        _cust.custtype_id, --pCustTypeId
43938
 
        _cust.custtype_code, --pCustTypeCode
43939
 
        _shipto.shipto_id, --pShiptoId
43940
 
        _shipto.shipto_shipzone_id, --pShipZoneId
43941
 
        _shipto.shipto_num, --pShiptoNum
43942
 
        _order_date, --pOrderDate
43943
 
        _ship_via, --pShipVia
43944
 
        _curr.curr_id, --pCurrId
43945
 
        _curr.curr_abbr, --pCurrAbbr
43946
 
        _weights.itemsite_warehous_id, --pItemSiteWhsId
43947
 
        _weights.item_freightclass_id, --pItemFreightclassId
43948
 
        _weights.weight --pWeight
43949
 
        );
43950
 
 
43951
 
      RETURN NEXT _row;
43952
 
    END LOOP;
43953
 
  ELSIF (pItemArrayType = 'itemsite_id' AND (array_upper(pItemQty,1) > 0)) THEN
43954
 
    -- Using itemsite_id.
43955
 
    FOR _weights IN
43956
 
      -- Get a list of aggregated weights from sites and freight classes for items.
43957
 
      SELECT
43958
 
        CASE WHEN _includepkgweight THEN
43959
 
          SUM(qty * (item_prodweight + item_packweight))
43960
 
        ELSE
43961
 
          SUM(qty * (item_prodweight))
43962
 
        END AS weight,
43963
 
        itemsite_warehous_id,
43964
 
        COALESCE(item_freightclass_id, -1) AS item_freightclass_id
43965
 
      FROM
43966
 
        -- Create itemsite_id -> qty record from array.
43967
 
        (SELECT
43968
 
          unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][1]))::integer AS itemsite_id,
43969
 
          unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][2:array_ndims(pItemQty)]))::numeric AS qty
43970
 
        ) AS itemsiteid_qty
43971
 
        JOIN itemsite USING (itemsite_id)
43972
 
        JOIN item ON item_id=itemsite_item_id
43973
 
      WHERE 1=1
43974
 
      GROUP BY
43975
 
        itemsite_warehous_id,
43976
 
        item_freightclass_id
43977
 
    LOOP
43978
 
      -- Calculate the freight detail for these item weights.
43979
 
      _row := calculateFreightDetail(
43980
 
        _cust.cust_id, --pCustId
43981
 
        _cust.custtype_id, --pCustTypeId
43982
 
        _cust.custtype_code, --pCustTypeCode
43983
 
        _shipto.shipto_id, --pShiptoId
43984
 
        _shipto.shipto_shipzone_id, --pShipZoneId
43985
 
        _shipto.shipto_num, --pShiptoNum
43986
 
        _order_date, --pOrderDate
43987
 
        _ship_via, --pShipVia
43988
 
        _curr.curr_id, --pCurrId
43989
 
        _curr.curr_abbr, --pCurrAbbr
43990
 
        _weights.itemsite_warehous_id, --pItemSiteWhsId
43991
 
        _weights.item_freightclass_id, --pItemFreightclassId
43992
 
        _weights.weight --pWeight
43993
 
        );
43994
 
 
43995
 
      RETURN NEXT _row;
43996
 
    END LOOP;
43997
 
  ELSE -- The item array provided is invalid.
43998
 
    RAISE EXCEPTION 'The Item/Itemsite array provided when trying to get a freight quote is invalid.';
43999
 
  END IF;
44000
 
 
44001
 
  IF(NOT FOUND) THEN
44002
 
    RAISE EXCEPTION 'Error trying to aggregated weights when getting a freight quote.';
44003
 
  END IF;
44004
 
 
44005
 
  -- Print debug.
44006
 
  IF (_debug) THEN
44007
 
    RAISE NOTICE 'pCustId = %', _cust.cust_id;
44008
 
    RAISE NOTICE 'pCustTypeId = %', _cust.custtype_id;
44009
 
    RAISE NOTICE 'pCustTypeCode = %', _cust.custtype_code;
44010
 
    RAISE NOTICE 'pShiptoId = %', _shipto.shipto_id;
44011
 
    RAISE NOTICE 'pShipZoneId = %', _shipto.shipto_shipzone_id;
44012
 
    RAISE NOTICE 'pShiptoNum = %', _shipto.shipto_num;
44013
 
    RAISE NOTICE 'pOrderDate = %', _order_date;
44014
 
    RAISE NOTICE 'pShipVia = %', _ship_via;
44015
 
    RAISE NOTICE 'pCurrId = %', _curr.curr_id;
44016
 
    RAISE NOTICE 'pCurrAbbr = %', _curr.curr_abbr;
44017
 
  END IF;
44018
 
 
44019
 
  RETURN;
44020
 
END;
44021
 
$_$;
44022
 
 
44023
 
 
44024
 
ALTER FUNCTION public.freightdetailquote(integer, text, integer, text, date, text, text, text[]) OWNER TO admin;
44025
 
 
44026
 
--
44027
 
--
44028
 
 
44029
 
CREATE FUNCTION freightforrecv(text, integer, boolean) RETURNS numeric
44030
 
    LANGUAGE plpgsql
44031
 
    AS $_$
44032
 
DECLARE
44033
 
  pordertype    ALIAS FOR $1;
44034
 
  porderitemid  ALIAS FOR $2;
44035
 
  pposted       ALIAS FOR $3;
44036
 
  _freight      NUMERIC;
44037
 
 
44038
 
BEGIN
44039
 
  IF (pordertype = 'TO' AND NOT fetchMetricBool('MultiWhs')) THEN
44040
 
    RETURN 0;
44041
 
  ELSIF (pordertype = 'RA' AND NOT fetchMetricBool('EnableReturnAuth')) THEN
44042
 
    RETURN 0;
44043
 
  END IF;
44044
 
 
44045
 
  SELECT SUM(COALESCE(recv_freight, 0)) INTO _freight
44046
 
  FROM recv
44047
 
  WHERE ((recv_orderitem_id=porderitemid)
44048
 
    AND  (recv_posted = pposted)
44049
 
    AND  (recv_order_type=pordertype));
44050
 
 
44051
 
  RETURN COALESCE(_freight, 0.0);
44052
 
 
44053
 
END;
44054
 
$_$;
44055
 
 
44056
 
 
44057
 
ALTER FUNCTION public.freightforrecv(text, integer, boolean) OWNER TO admin;
44058
 
 
44059
 
--
44060
 
--
44061
 
 
44062
 
CREATE FUNCTION gen_salt(text) RETURNS text
44063
 
    LANGUAGE c STRICT
44064
 
    AS '$libdir/pgcrypto', 'pg_gen_salt';
44065
 
 
44066
 
 
44067
 
ALTER FUNCTION public.gen_salt(text) OWNER TO admin;
44068
 
 
44069
 
--
44070
 
--
44071
 
 
44072
 
CREATE FUNCTION gen_salt(text, integer) RETURNS text
44073
 
    LANGUAGE c STRICT
44074
 
    AS '$libdir/pgcrypto', 'pg_gen_salt_rounds';
44075
 
 
44076
 
 
44077
 
ALTER FUNCTION public.gen_salt(text, integer) OWNER TO admin;
44078
 
 
44079
 
--
44080
 
--
44081
 
 
44082
 
CREATE FUNCTION getactiverevid(text, integer) RETURNS integer
44083
 
    LANGUAGE plpgsql STABLE
44084
 
    AS $_$
44085
 
DECLARE
44086
 
  pTargetType ALIAS FOR $1;
44087
 
  pTargetid ALIAS FOR $2;
44088
 
  _revid INTEGER;
44089
 
 
44090
 
BEGIN
44091
 
  --See if revcontrol turned on
44092
 
  IF (fetchmetricbool('RevControl')) THEN
44093
 
 
44094
 
    IF (pTargetType='BOM') THEN
44095
 
      SELECT rev_id INTO _revid
44096
 
      FROM rev
44097
 
      WHERE ((rev_target_type='BOM')
44098
 
      AND (rev_target_id=pTargetid)
44099
 
      AND (rev_status='A'));
44100
 
      IF (NOT FOUND) THEN
44101
 
        _revid:=-1;
44102
 
      END IF;
44103
 
 
44104
 
      ELSE IF (pTargetType='BOO') THEN
44105
 
      SELECT rev_id INTO _revid
44106
 
      FROM rev
44107
 
      WHERE ((rev_target_type='BOO')
44108
 
      AND (rev_target_id=pTargetid)
44109
 
      AND (rev_status='A'));
44110
 
      IF (NOT FOUND) THEN
44111
 
        _revid:=-1;
44112
 
      END IF;
44113
 
 
44114
 
      ELSE
44115
 
        RAISE EXCEPTION 'Invalid Revision Type';
44116
 
      END IF;
44117
 
    END IF;
44118
 
 
44119
 
  ELSE
44120
 
    _revid:=-1;
44121
 
  END IF;
44122
 
 
44123
 
  RETURN _revid;
44124
 
 
44125
 
END;
44126
 
$_$;
44127
 
 
44128
 
 
44129
 
ALTER FUNCTION public.getactiverevid(text, integer) OWNER TO admin;
44130
 
 
44131
 
--
44132
 
--
44133
 
 
44134
 
CREATE FUNCTION getaddrid(paddressnumber text) RETURNS integer
44135
 
    LANGUAGE plpgsql STABLE
44136
 
    AS $$
44137
 
DECLARE
44138
 
  _returnVal INTEGER;
44139
 
BEGIN
44140
 
  IF (pAddressNumber IS NULL OR pAddressNumber = '') THEN
44141
 
    RETURN NULL;
44142
 
  END IF;
44143
 
 
44144
 
  SELECT addr_id INTO _returnVal
44145
 
  FROM addr
44146
 
  WHERE (addr_number=pAddressNumber);
44147
 
 
44148
 
  IF (_returnVal IS NULL) THEN
44149
 
        RAISE EXCEPTION 'Address Number % not found.', pAddressNumber;
44150
 
  END IF;
44151
 
 
44152
 
  RETURN _returnVal;
44153
 
END;
44154
 
$$;
44155
 
 
44156
 
 
44157
 
ALTER FUNCTION public.getaddrid(paddressnumber text) OWNER TO admin;
44158
 
 
44159
 
--
44160
 
--
44161
 
 
44162
 
CREATE FUNCTION getadjustmenttaxtypeid() RETURNS integer
44163
 
    LANGUAGE plpgsql IMMUTABLE
44164
 
    AS $$
44165
 
DECLARE
44166
 
  _taxtypeid INTEGER;
44167
 
BEGIN
44168
 
  SELECT taxtype_id
44169
 
    INTO _taxtypeid
44170
 
  FROM taxtype
44171
 
  WHERE (taxtype_name='Adjustment');
44172
 
 
44173
 
  RETURN _taxtypeid;
44174
 
END;
44175
 
$$;
44176
 
 
44177
 
 
44178
 
ALTER FUNCTION public.getadjustmenttaxtypeid() OWNER TO admin;
44179
 
 
44180
 
--
44181
 
--
44182
 
 
44183
 
CREATE FUNCTION getaropenid(text, character, text) RETURNS integer
44184
 
    LANGUAGE plpgsql
44185
 
    AS $_$
44186
 
DECLARE
44187
 
  pCustNumber ALIAS FOR $1;
44188
 
  pDocType ALIAS FOR $2;
44189
 
  pDocNumber ALIAS FOR $3;
44190
 
  _returnVal INTEGER;
44191
 
BEGIN
44192
 
  IF ((pCustNumber IS NULL) OR (pDocType IS NULL) OR (pDocNumber IS NULL)) THEN
44193
 
        RETURN NULL;
44194
 
  END IF;
44195
 
 
44196
 
  SELECT aropen_id INTO _returnVal
44197
 
  FROM aropen
44198
 
  WHERE ((aropen_cust_id=getCustId(pCustNumber,true))
44199
 
    AND  (UPPER(aropen_doctype)=UPPER(pDocType))
44200
 
    AND  (UPPER(aropen_docnumber)=UPPER(pDocNumber)));
44201
 
 
44202
 
  IF (_returnVal IS NULL) THEN
44203
 
        RAISE EXCEPTION 'AR Open Item % not found.', pDocNumber;
44204
 
  END IF;
44205
 
 
44206
 
  RETURN _returnVal;
44207
 
END;
44208
 
$_$;
44209
 
 
44210
 
 
44211
 
ALTER FUNCTION public.getaropenid(text, character, text) OWNER TO admin;
44212
 
 
44213
 
--
44214
 
--
44215
 
 
44216
 
CREATE FUNCTION getbankaccntid(text) RETURNS integer
44217
 
    LANGUAGE plpgsql
44218
 
    AS $_$
44219
 
DECLARE
44220
 
  pBankAccntName ALIAS FOR $1;
44221
 
  _returnVal INTEGER;
44222
 
BEGIN
44223
 
  IF (pBankAccntName IS NULL) THEN
44224
 
        RETURN NULL;
44225
 
  END IF;
44226
 
 
44227
 
  SELECT bankaccnt_id INTO _returnVal
44228
 
  FROM bankaccnt
44229
 
  WHERE (UPPER(bankaccnt_name)=UPPER(pBankAccntName));
44230
 
 
44231
 
  IF (_returnVal IS NULL) THEN
44232
 
        RAISE EXCEPTION 'Bank Account % not found.', pBankAccntName;
44233
 
  END IF;
44234
 
 
44235
 
  RETURN _returnVal;
44236
 
END;
44237
 
$_$;
44238
 
 
44239
 
 
44240
 
ALTER FUNCTION public.getbankaccntid(text) OWNER TO admin;
44241
 
 
44242
 
--
44243
 
--
44244
 
 
44245
 
CREATE FUNCTION getbomitemid(text, text, text) RETURNS integer
44246
 
    LANGUAGE plpgsql
44247
 
    AS $_$
44248
 
DECLARE
44249
 
  pItemNumber ALIAS FOR $1;
44250
 
  pRevision ALIAS FOR $2;
44251
 
  pSeqNumber ALIAS FOR $3;
44252
 
  _returnVal INTEGER;
44253
 
  
44254
 
BEGIN
44255
 
  IF ((pItemNumber IS NULL) OR (pSeqNumber IS NULL) OR (pItemNumber = '') OR (pSeqNumber = '') ) THEN
44256
 
    RETURN NULL;
44257
 
  END IF;
44258
 
 
44259
 
  SELECT bomitem_id INTO _returnVal
44260
 
  FROM bomitem(getItemId(pItemNumber),COALESCE(getRevId('BOM',pItemNumber,pRevision)))
44261
 
  WHERE (bomitem_seqnumber=pSeqNumber);
44262
 
    
44263
 
  IF (_returnVal IS NULL) THEN
44264
 
    RAISE EXCEPTION 'Sequence % on Bill of Material % Revision % not found.', pSeqNumber, pItemNumber, pRevision;
44265
 
  END IF;
44266
 
 
44267
 
  RETURN _returnVal;
44268
 
END;
44269
 
$_$;
44270
 
 
44271
 
 
44272
 
ALTER FUNCTION public.getbomitemid(text, text, text) OWNER TO admin;
44273
 
 
44274
 
--
44275
 
--
44276
 
 
44277
 
CREATE FUNCTION getbooitemseqid(text, text) RETURNS integer
44278
 
    LANGUAGE plpgsql
44279
 
    AS $_$
44280
 
DECLARE
44281
 
  pItemNumber ALIAS FOR $1;
44282
 
  pSeqNumber ALIAS FOR $2;
44283
 
  _revid INTEGER;
44284
 
  _returnVal INTEGER;
44285
 
  
44286
 
BEGIN
44287
 
  IF ((pItemNumber IS NULL) OR (pSeqNumber IS NULL)) THEN
44288
 
    RETURN NULL;
44289
 
  END IF;
44290
 
 
44291
 
  IF (NOT fetchMetricBool('Routings')) THEN
44292
 
    RETURN -1;
44293
 
  ELSE
44294
 
    SELECT booitem_seq_id INTO _returnVal
44295
 
    FROM booitem(getItemId(pItemNumber))
44296
 
    WHERE (booitem_seqnumber=CAST(pSeqNumber AS integer));
44297
 
  END IF;
44298
 
    
44299
 
  IF (_returnVal IS NULL) THEN
44300
 
    RAISE EXCEPTION 'Boo Sequence % for Item % not found.', pSeqNumber, pItemNumber;
44301
 
  END IF;
44302
 
 
44303
 
  RETURN _returnVal;
44304
 
END;
44305
 
$_$;
44306
 
 
44307
 
 
44308
 
ALTER FUNCTION public.getbooitemseqid(text, text) OWNER TO admin;
44309
 
 
44310
 
--
44311
 
--
44312
 
 
44313
 
CREATE FUNCTION getbudgheadid(text) RETURNS integer
44314
 
    LANGUAGE plpgsql
44315
 
    AS $_$
44316
 
DECLARE
44317
 
  pBudghead ALIAS FOR $1;
44318
 
  _returnVal INTEGER;
44319
 
BEGIN
44320
 
  IF (pBudghead IS NULL) THEN
44321
 
        RETURN NULL;
44322
 
  END IF;
44323
 
 
44324
 
  SELECT budghead_id INTO _returnVal
44325
 
  FROM budghead
44326
 
  WHERE (budghead_name=(pBudghead));
44327
 
 
44328
 
  IF (_returnVal IS NULL) THEN
44329
 
    RAISE EXCEPTION 'Budget % not found.', pBudghead;
44330
 
  END IF;
44331
 
 
44332
 
  RETURN _returnVal;
44333
 
END;
44334
 
$_$;
44335
 
 
44336
 
 
44337
 
ALTER FUNCTION public.getbudgheadid(text) OWNER TO admin;
44338
 
 
44339
 
--
44340
 
--
44341
 
 
44342
 
CREATE FUNCTION getcashrcptid(text, text, text) RETURNS integer
44343
 
    LANGUAGE plpgsql
44344
 
    AS $_$
44345
 
DECLARE
44346
 
  pCustNumber ALIAS FOR $1;
44347
 
  pFundsType ALIAS FOR $2;
44348
 
  pDocNumber ALIAS FOR $3;
44349
 
  _returnVal INTEGER;
44350
 
BEGIN
44351
 
  IF ((pCustNumber IS NULL) OR (pFundsType IS NULL) OR (pDocNumber IS NULL)) THEN
44352
 
        RETURN NULL;
44353
 
  END IF;
44354
 
 
44355
 
  SELECT cashrcpt_id INTO _returnVal
44356
 
  FROM cashrcpt
44357
 
  WHERE ((cashrcpt_cust_id=getCustId(pCustNumber,true))
44358
 
    AND  (UPPER(cashrcpt_fundstype)=UPPER(pFundsType))
44359
 
    AND  (UPPER(cashrcpt_docnumber)=UPPER(pDocNumber)));
44360
 
 
44361
 
  IF (_returnVal IS NULL) THEN
44362
 
        RAISE EXCEPTION 'Cash Receipt % not found.', pDocNumber;
44363
 
  END IF;
44364
 
 
44365
 
  RETURN _returnVal;
44366
 
END;
44367
 
$_$;
44368
 
 
44369
 
 
44370
 
ALTER FUNCTION public.getcashrcptid(text, text, text) OWNER TO admin;
44371
 
 
44372
 
--
44373
 
--
44374
 
 
44375
 
CREATE FUNCTION getcharid(pchar text, ptype text) RETURNS integer
44376
 
    LANGUAGE plpgsql STABLE
44377
 
    AS $$
44378
 
DECLARE
44379
 
  _returnVal INTEGER;
44380
 
BEGIN
44381
 
  IF (COALESCE(pChar, '') = '') THEN
44382
 
    RETURN NULL;
44383
 
  END IF;
44384
 
 
44385
 
  SELECT char_id INTO _returnVal
44386
 
  FROM char
44387
 
  WHERE ((char_name=pChar)
44388
 
  AND ((pType IN ('C','CT') AND char_customers)
44389
 
    OR (pType IN ('I','SI','QI','W','PI','TI') AND char_items)
44390
 
    OR (pType='CRMACCT' AND char_crmaccounts)
44391
 
    OR (pType='ADDR' AND char_addresses)
44392
 
    OR (pType='CNTCT' AND char_contacts)
44393
 
    OR (pType='LS' AND char_lotserial)
44394
 
    OR (pType='EMP' AND char_employees)
44395
 
    OR (pType='INCDT' AND char_incidents)
44396
 
    )) LIMIT 1;
44397
 
 
44398
 
  IF (_returnVal IS NULL) THEN
44399
 
        RAISE EXCEPTION 'Characteristic % not found.', pChar;
44400
 
  END IF;
44401
 
 
44402
 
  RETURN _returnVal;
44403
 
END;
44404
 
$$;
44405
 
 
44406
 
 
44407
 
ALTER FUNCTION public.getcharid(pchar text, ptype text) OWNER TO admin;
44408
 
 
44409
 
--
44410
 
--
44411
 
 
44412
 
CREATE FUNCTION getclasscodeid(text) RETURNS integer
44413
 
    LANGUAGE plpgsql
44414
 
    AS $_$
44415
 
DECLARE
44416
 
  pClassCode ALIAS FOR $1;
44417
 
  _returnVal INTEGER;
44418
 
BEGIN
44419
 
  IF (pClassCode IS NULL) THEN
44420
 
    RETURN NULL;
44421
 
  END IF;
44422
 
 
44423
 
  SELECT classcode_id INTO _returnVal
44424
 
  FROM classcode
44425
 
  WHERE (classcode_code=pClassCode);
44426
 
 
44427
 
  IF (_returnVal IS NULL) THEN
44428
 
        RAISE EXCEPTION 'Class Code % not found.', pClassCode;
44429
 
  END IF;
44430
 
 
44431
 
  RETURN _returnVal;
44432
 
END;
44433
 
$_$;
44434
 
 
44435
 
 
44436
 
ALTER FUNCTION public.getclasscodeid(text) OWNER TO admin;
44437
 
 
44438
 
--
44439
 
--
44440
 
 
44441
 
CREATE FUNCTION getcmheadid(text) RETURNS integer
44442
 
    LANGUAGE plpgsql
44443
 
    AS $_$
44444
 
DECLARE
44445
 
  pCreditMemoNumber ALIAS FOR $1;
44446
 
BEGIN
44447
 
  RETURN getCmheadId(pCreditMemoNumber, NULL);
44448
 
END;
44449
 
$_$;
44450
 
 
44451
 
 
44452
 
ALTER FUNCTION public.getcmheadid(text) OWNER TO admin;
44453
 
 
44454
 
--
44455
 
--
44456
 
 
44457
 
CREATE FUNCTION getcmheadid(text, boolean) RETURNS integer
44458
 
    LANGUAGE plpgsql
44459
 
    AS $_$
44460
 
DECLARE
44461
 
  pCreditMemoNumber ALIAS FOR $1;
44462
 
  pPosted ALIAS FOR $2;
44463
 
  _returnVal INTEGER;
44464
 
BEGIN
44465
 
  IF (pCreditMemoNumber IS NULL) THEN
44466
 
    RETURN NULL;
44467
 
  END IF;
44468
 
 
44469
 
  SELECT cmhead_id INTO _returnVal
44470
 
  FROM cmhead
44471
 
  WHERE (UPPER(cmhead_number)=UPPER(pCreditMemoNumber))
44472
 
    AND ((pPosted IS NULL) OR (cmhead_posted=pPosted));
44473
 
 
44474
 
  IF (_returnVal IS NULL) THEN
44475
 
        RAISE EXCEPTION 'Credit Memo % not found.', pCreditMemoNumber;
44476
 
  END IF;
44477
 
 
44478
 
  RETURN _returnVal;
44479
 
END;
44480
 
$_$;
44481
 
 
44482
 
 
44483
 
ALTER FUNCTION public.getcmheadid(text, boolean) OWNER TO admin;
44484
 
 
44485
 
--
44486
 
--
44487
 
 
44488
 
CREATE FUNCTION getcmnttypeid(text) RETURNS integer
44489
 
    LANGUAGE plpgsql
44490
 
    AS $_$
44491
 
DECLARE
44492
 
  pCmntType ALIAS FOR $1;
44493
 
  _returnVal INTEGER;
44494
 
BEGIN
44495
 
  IF (COALESCE(TRIM(pCmntType), '') = '') THEN
44496
 
    RETURN NULL;
44497
 
  END IF;
44498
 
 
44499
 
  SELECT cmnttype_id INTO _returnVal
44500
 
  FROM cmnttype
44501
 
  WHERE (cmnttype_name=pCmntType) LIMIT 1;
44502
 
 
44503
 
  IF (_returnVal IS NULL) THEN
44504
 
        RAISE EXCEPTION 'Comment Type % not found.', pCmntType;
44505
 
  END IF;
44506
 
 
44507
 
  RETURN _returnVal;
44508
 
END;
44509
 
$_$;
44510
 
 
44511
 
 
44512
 
ALTER FUNCTION public.getcmnttypeid(text) OWNER TO admin;
44513
 
 
44514
 
--
44515
 
--
44516
 
 
44517
 
CREATE FUNCTION getcntctid(pcontactnumber text) RETURNS integer
44518
 
    LANGUAGE plpgsql STABLE
44519
 
    AS $$
44520
 
DECLARE
44521
 
  _returnVal INTEGER;
44522
 
BEGIN
44523
 
  SELECT getCntctId(pContactNumber,true) INTO _returnVal;
44524
 
 
44525
 
  RETURN _returnVal;
44526
 
END;
44527
 
$$;
44528
 
 
44529
 
 
44530
 
ALTER FUNCTION public.getcntctid(pcontactnumber text) OWNER TO admin;
44531
 
 
44532
 
--
44533
 
--
44534
 
 
44535
 
CREATE FUNCTION getcntctid(pcontactnumber text, pnotfounderr boolean) RETURNS integer
44536
 
    LANGUAGE plpgsql STABLE
44537
 
    AS $$
44538
 
DECLARE
44539
 
  _returnVal INTEGER;
44540
 
BEGIN
44541
 
  IF (COALESCE(TRIM(pContactNumber), '') = '') THEN
44542
 
    RETURN NULL;
44543
 
  END IF;
44544
 
 
44545
 
  SELECT cntct_id INTO _returnVal
44546
 
  FROM cntct
44547
 
  WHERE (cntct_number=pContactNumber);
44548
 
 
44549
 
  IF (_returnVal IS NULL AND pNotFoundErr) THEN
44550
 
    RAISE EXCEPTION 'Contact Number % not found.', pContactNumber;
44551
 
  ELSIF (_returnVal IS NULL) THEN
44552
 
    RETURN NULL;
44553
 
  END IF;
44554
 
 
44555
 
  RETURN _returnVal;
44556
 
END;
44557
 
$$;
44558
 
 
44559
 
 
44560
 
ALTER FUNCTION public.getcntctid(pcontactnumber text, pnotfounderr boolean) OWNER TO admin;
44561
 
 
44562
 
--
44563
 
--
44564
 
 
44565
 
CREATE FUNCTION getcoheadid(text) RETURNS integer
44566
 
    LANGUAGE plpgsql
44567
 
    AS $_$
44568
 
DECLARE
44569
 
  pSalesOrderNumber ALIAS FOR $1;
44570
 
  _returnVal INTEGER;
44571
 
BEGIN
44572
 
  IF (pSalesOrderNumber IS NULL) THEN
44573
 
    RETURN NULL;
44574
 
  END IF;
44575
 
 
44576
 
  SELECT cohead_id INTO _returnVal
44577
 
  FROM cohead
44578
 
  WHERE (cohead_number=pSalesOrderNumber);
44579
 
 
44580
 
  IF (_returnVal IS NULL) THEN
44581
 
        RAISE EXCEPTION 'Sales Order % not found.', pSalesOrderNumber;
44582
 
  END IF;
44583
 
 
44584
 
  RETURN _returnVal;
44585
 
END;
44586
 
$_$;
44587
 
 
44588
 
 
44589
 
ALTER FUNCTION public.getcoheadid(text) OWNER TO admin;
44590
 
 
44591
 
--
44592
 
--
44593
 
 
44594
 
CREATE FUNCTION getcoitemid(text, text) RETURNS integer
44595
 
    LANGUAGE plpgsql
44596
 
    AS $_$
44597
 
DECLARE
44598
 
  pSalesOrderNumber     ALIAS FOR $1;
44599
 
  pLineNumber           ALIAS FOR $2;
44600
 
  _linenumber           INTEGER;
44601
 
  _subnumber            INTEGER;
44602
 
  _returnVal            INTEGER;
44603
 
BEGIN
44604
 
  IF (pSalesOrderNumber IS NULL OR pLineNumber IS NULL) THEN
44605
 
    RETURN NULL;
44606
 
  END IF;
44607
 
 
44608
 
  --Parse Line Number
44609
 
  IF (position('.' in pLineNumber) > 0) THEN
44610
 
    _linenumber := CAST(substring(pLineNumber from 1 for position('.' in pLineNumber)-1) AS INTEGER);
44611
 
    _subnumber  := CAST(substring(pLineNumber from position('.' in pLineNumber)+1 for length(pLineNumber)) AS INTEGER);
44612
 
  ELSE
44613
 
    _linenumber := CAST(pLineNumber AS INTEGER);
44614
 
    _subnumber  := 0;
44615
 
  END IF;
44616
 
 
44617
 
  SELECT coitem_id INTO _returnVal
44618
 
  FROM cohead, coitem
44619
 
  WHERE ((cohead_number=pSalesOrderNumber)
44620
 
  AND (coitem_cohead_id=cohead_id)
44621
 
  AND (coitem_linenumber=_linenumber)
44622
 
  AND (coitem_subnumber=_subnumber));
44623
 
 
44624
 
  IF (_returnVal IS NULL) THEN
44625
 
        RAISE EXCEPTION 'Sales Order % not found.', pSalesOrderNumber;
44626
 
  END IF;
44627
 
 
44628
 
  RETURN _returnVal;
44629
 
END;
44630
 
$_$;
44631
 
 
44632
 
 
44633
 
ALTER FUNCTION public.getcoitemid(text, text) OWNER TO admin;
44634
 
 
44635
 
--
44636
 
--
44637
 
 
44638
 
CREATE FUNCTION getcontrcteffective(pcontrctnumber text) RETURNS date
44639
 
    LANGUAGE plpgsql
44640
 
    AS $$
44641
 
DECLARE
44642
 
  _returnVal DATE;
44643
 
BEGIN
44644
 
  IF (pContrctNumber IS NULL) THEN
44645
 
    RETURN NULL;
44646
 
  END IF;
44647
 
 
44648
 
  SELECT contrct_effective INTO _returnVal
44649
 
  FROM contrct
44650
 
  WHERE (contrct_number=pContrctNumber);
44651
 
 
44652
 
  IF (_returnVal IS NULL) THEN
44653
 
        RAISE EXCEPTION 'Contract Number % not found.', pContrctNumber;
44654
 
  END IF;
44655
 
 
44656
 
  RETURN _returnVal;
44657
 
END;
44658
 
$$;
44659
 
 
44660
 
 
44661
 
ALTER FUNCTION public.getcontrcteffective(pcontrctnumber text) OWNER TO admin;
44662
 
 
44663
 
--
44664
 
--
44665
 
 
44666
 
CREATE FUNCTION getcontrctexpires(pcontrctnumber text) RETURNS date
44667
 
    LANGUAGE plpgsql
44668
 
    AS $$
44669
 
DECLARE
44670
 
  _returnVal DATE;
44671
 
BEGIN
44672
 
  IF (pContrctNumber IS NULL) THEN
44673
 
    RETURN NULL;
44674
 
  END IF;
44675
 
 
44676
 
  SELECT contrct_expires INTO _returnVal
44677
 
  FROM contrct
44678
 
  WHERE (contrct_number=pContrctNumber);
44679
 
 
44680
 
  IF (_returnVal IS NULL) THEN
44681
 
        RAISE EXCEPTION 'Contract Number % not found.', pContrctNumber;
44682
 
  END IF;
44683
 
 
44684
 
  RETURN _returnVal;
44685
 
END;
44686
 
$$;
44687
 
 
44688
 
 
44689
 
ALTER FUNCTION public.getcontrctexpires(pcontrctnumber text) OWNER TO admin;
44690
 
 
44691
 
--
44692
 
--
44693
 
 
44694
 
CREATE FUNCTION getcontrctid(pcontrctnumber text) RETURNS integer
44695
 
    LANGUAGE plpgsql
44696
 
    AS $$
44697
 
DECLARE
44698
 
  _returnVal INTEGER;
44699
 
BEGIN
44700
 
  IF (pContrctNumber IS NULL) THEN
44701
 
    RETURN NULL;
44702
 
  END IF;
44703
 
 
44704
 
  SELECT contrct_id INTO _returnVal
44705
 
  FROM contrct
44706
 
  WHERE (contrct_number=pContrctNumber);
44707
 
 
44708
 
  IF (_returnVal IS NULL) THEN
44709
 
        RAISE EXCEPTION 'Contract Number % not found.', pContrctNumber;
44710
 
  END IF;
44711
 
 
44712
 
  RETURN _returnVal;
44713
 
END;
44714
 
$$;
44715
 
 
44716
 
 
44717
 
ALTER FUNCTION public.getcontrctid(pcontrctnumber text) OWNER TO admin;
44718
 
 
44719
 
--
44720
 
--
44721
 
 
44722
 
CREATE FUNCTION getcostcatid(text) RETURNS integer
44723
 
    LANGUAGE plpgsql
44724
 
    AS $_$
44725
 
DECLARE
44726
 
  pCostCat ALIAS FOR $1;
44727
 
  _returnVal INTEGER;
44728
 
BEGIN
44729
 
  IF (pCostCat IS NULL) THEN
44730
 
        RETURN NULL;
44731
 
  END IF;
44732
 
 
44733
 
  SELECT costcat_id INTO _returnVal
44734
 
  FROM costcat
44735
 
  WHERE (costcat_code=pCostCat);
44736
 
 
44737
 
  IF (_returnVal IS NULL) THEN
44738
 
        RAISE EXCEPTION 'Cost Category Code % not found.', pCostCat;
44739
 
  END IF;
44740
 
 
44741
 
  RETURN _returnVal;
44742
 
END;
44743
 
$_$;
44744
 
 
44745
 
 
44746
 
ALTER FUNCTION public.getcostcatid(text) OWNER TO admin;
44747
 
 
44748
 
--
44749
 
--
44750
 
 
44751
 
CREATE FUNCTION getcostelemid(text) RETURNS integer
44752
 
    LANGUAGE plpgsql
44753
 
    AS $_$
44754
 
DECLARE
44755
 
  pCostElemType ALIAS FOR $1;
44756
 
  _returnVal INTEGER;
44757
 
BEGIN
44758
 
  IF (pCostElemType IS NULL) THEN
44759
 
        RETURN NULL;
44760
 
  END IF;
44761
 
 
44762
 
  SELECT costelem_id INTO _returnVal
44763
 
  FROM costelem
44764
 
  WHERE (costelem_type=pCostElemType);
44765
 
 
44766
 
  IF (_returnVal IS NULL) THEN
44767
 
        RAISE EXCEPTION 'Cost Element % not found.', pCostElemType;
44768
 
  END IF;
44769
 
 
44770
 
  RETURN _returnVal;
44771
 
END;
44772
 
$_$;
44773
 
 
44774
 
 
44775
 
ALTER FUNCTION public.getcostelemid(text) OWNER TO admin;
44776
 
 
44777
 
--
44778
 
--
44779
 
 
44780
 
CREATE FUNCTION getcrmacctid(pacctnumber text) RETURNS integer
44781
 
    LANGUAGE plpgsql STABLE
44782
 
    AS $$
44783
 
DECLARE
44784
 
  _returnVal INTEGER;
44785
 
BEGIN
44786
 
  
44787
 
  IF (pAcctNumber IS NULL) THEN
44788
 
    RETURN NULL;
44789
 
  END IF;
44790
 
 
44791
 
  SELECT crmacct_id INTO _returnVal
44792
 
  FROM crmacct
44793
 
  WHERE (UPPER(crmacct_number)=UPPER(pAcctNumber));
44794
 
  
44795
 
  IF (_returnVal IS NULL) THEN
44796
 
      RAISE EXCEPTION 'CRM Account Number % not found.', pAcctNumber;
44797
 
  END IF;
44798
 
 
44799
 
  RETURN _returnVal;
44800
 
END;
44801
 
$$;
44802
 
 
44803
 
 
44804
 
ALTER FUNCTION public.getcrmacctid(pacctnumber text) OWNER TO admin;
44805
 
 
44806
 
--
44807
 
--
44808
 
 
44809
 
CREATE FUNCTION getcurrid(pcurrname text) RETURNS integer
44810
 
    LANGUAGE plpgsql STABLE
44811
 
    AS $$
44812
 
DECLARE
44813
 
  _returnVal INTEGER;
44814
 
BEGIN
44815
 
  IF (pCurrName IS NULL) THEN
44816
 
        RETURN NULL;
44817
 
  END IF;
44818
 
 
44819
 
  SELECT curr_id INTO _returnVal
44820
 
  FROM curr_symbol
44821
 
  WHERE (curr_abbr=pCurrName);
44822
 
 
44823
 
  IF (_returnVal IS NULL) THEN
44824
 
        RAISE EXCEPTION 'Currency % not found.', pCurrName;
44825
 
  END IF;
44826
 
 
44827
 
  RETURN _returnVal;
44828
 
END;
44829
 
$$;
44830
 
 
44831
 
 
44832
 
ALTER FUNCTION public.getcurrid(pcurrname text) OWNER TO admin;
44833
 
 
44834
 
--
44835
 
--
44836
 
 
44837
 
CREATE FUNCTION getcustid(pcustnumber text) RETURNS integer
44838
 
    LANGUAGE plpgsql STABLE
44839
 
    AS $$
44840
 
DECLARE
44841
 
  _returnVal INTEGER;
44842
 
BEGIN
44843
 
  
44844
 
  SELECT getCustId(pCustNumber,false) INTO _returnVal;
44845
 
 
44846
 
  RETURN _returnVal;
44847
 
END;
44848
 
$$;
44849
 
 
44850
 
 
44851
 
ALTER FUNCTION public.getcustid(pcustnumber text) OWNER TO admin;
44852
 
 
44853
 
--
44854
 
--
44855
 
 
44856
 
CREATE FUNCTION getcustid(pcustnumber text, pinclprospects boolean) RETURNS integer
44857
 
    LANGUAGE plpgsql STABLE
44858
 
    AS $$
44859
 
DECLARE
44860
 
  _returnVal INTEGER;
44861
 
BEGIN
44862
 
  IF (pCustNumber IS NULL) THEN
44863
 
    RETURN NULL;
44864
 
  END IF;
44865
 
 
44866
 
  SELECT cust_id INTO _returnVal
44867
 
  FROM custinfo
44868
 
  WHERE (cust_number=UPPER(pCustNumber));
44869
 
  
44870
 
  IF (_returnVal IS NULL) THEN
44871
 
    IF (pInclProspects) THEN
44872
 
      SELECT prospect_id INTO _returnVal
44873
 
      FROM prospect
44874
 
      WHERE (UPPER(prospect_number)=UPPER(pCustNumber));
44875
 
      IF (_returnVal IS NULL) THEN
44876
 
        RAISE EXCEPTION 'Neither Customer nor Prospect Number % found.', pCustNumber;
44877
 
      END IF;
44878
 
    ELSE
44879
 
      RAISE EXCEPTION 'Customer Number % not found.', pCustNumber;
44880
 
    END IF;
44881
 
  END IF;
44882
 
 
44883
 
  RETURN _returnVal;
44884
 
END;
44885
 
$$;
44886
 
 
44887
 
 
44888
 
ALTER FUNCTION public.getcustid(pcustnumber text, pinclprospects boolean) OWNER TO admin;
44889
 
 
44890
 
--
44891
 
--
44892
 
 
44893
 
CREATE FUNCTION getcustnamefrominfo(text, text, text, text, text, boolean) RETURNS text
44894
 
    LANGUAGE plpgsql
44895
 
    AS $_$
44896
 
DECLARE
44897
 
  _email        TEXT    := COALESCE(UPPER($1), '');
44898
 
  _company      TEXT    := COALESCE(UPPER($2), '');
44899
 
  _first        TEXT    := COALESCE(UPPER($3), '');
44900
 
  _last         TEXT    := COALESCE(UPPER($4), '');
44901
 
  _fullname     TEXT    := COALESCE(UPPER($5), '');
44902
 
  _generate     BOOLEAN := COALESCE($6, FALSE);
44903
 
  _counter      INTEGER;
44904
 
  _custcount    INTEGER := 0;
44905
 
  _custname     TEXT;
44906
 
  _candidate    RECORD;
44907
 
  _r            RECORD;
44908
 
BEGIN
44909
 
  IF (_email != '') THEN
44910
 
    SELECT count(*), cust_name INTO _custcount, _custname
44911
 
    FROM custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)
44912
 
    WHERE (UPPER(cntct_email)=_email)
44913
 
    GROUP BY cust_name;
44914
 
    IF (NOT FOUND) THEN
44915
 
      _custcount := 0;
44916
 
    ELSIF(_custcount = 1) THEN
44917
 
      RETURN _custname;
44918
 
    END IF;
44919
 
  END IF;
44920
 
 
44921
 
  IF (_company != '') THEN
44922
 
    SELECT count(*), cust_name INTO _custcount, _custname
44923
 
    FROM custinfo
44924
 
    WHERE (UPPER(cust_name)=_company)
44925
 
    GROUP BY cust_name;
44926
 
    IF (NOT FOUND) THEN
44927
 
      _custcount := 0;
44928
 
    ELSIF(_custcount = 1) THEN
44929
 
      RETURN _custname;
44930
 
    END IF;
44931
 
  END IF;
44932
 
 
44933
 
  IF (_fullname = '' AND (_first != '' OR _last != '')) THEN
44934
 
    _fullname := TRIM(_first || ' ' || _last);
44935
 
  END IF;
44936
 
 
44937
 
  IF (_custcount <= 0 AND _fullname != '') THEN
44938
 
    SELECT count(*), cust_name INTO _custcount, _custname
44939
 
    FROM custinfo
44940
 
    WHERE (UPPER(cust_name)=_fullname)
44941
 
    GROUP BY cust_name;
44942
 
    IF (NOT FOUND) THEN
44943
 
      _custcount := 0;
44944
 
    ELSIF(_custcount = 1) THEN
44945
 
      RETURN _custname;
44946
 
    END IF;
44947
 
  END IF;
44948
 
 
44949
 
  IF (_custcount > 1) THEN
44950
 
    RAISE EXCEPTION 'Found % possible Customers for % and % and %',
44951
 
                    _custcount, _email, _company, _fullname;
44952
 
  END IF;
44953
 
 
44954
 
  IF (_custcount <= 0 AND _generate) THEN
44955
 
    IF (_company != '') THEN
44956
 
      RETURN _company;
44957
 
    ELSIF (_email != '') THEN
44958
 
      RETURN _email;
44959
 
    ELSIF (_fullname != '') THEN
44960
 
      RETURN _fullname;
44961
 
    ELSE
44962
 
      RAISE EXCEPTION 'Could not generate a new Customer Name without an email address or the name of a company or person';
44963
 
    END IF;
44964
 
  END IF;
44965
 
 
44966
 
  IF (_custname IS NULL OR _custname = '') THEN
44967
 
    RAISE EXCEPTION 'Could not find Customer Name for % and %',
44968
 
                    _company, _fullname;
44969
 
  END IF;
44970
 
 
44971
 
  RETURN _custname;
44972
 
END;
44973
 
$_$;
44974
 
 
44975
 
 
44976
 
ALTER FUNCTION public.getcustnamefrominfo(text, text, text, text, text, boolean) OWNER TO admin;
44977
 
 
44978
 
--
44979
 
--
44980
 
 
44981
 
CREATE FUNCTION getcustnumberfrominfo(text, text, text, text, text, boolean) RETURNS text
44982
 
    LANGUAGE plpgsql
44983
 
    AS $_$
44984
 
DECLARE
44985
 
  _email        TEXT    := COALESCE(UPPER($1), '');
44986
 
  _company      TEXT    := COALESCE(UPPER($2), '');
44987
 
  _first        TEXT    := COALESCE(UPPER($3), '');
44988
 
  _last         TEXT    := COALESCE(UPPER($4), '');
44989
 
  _fullname     TEXT    := COALESCE(UPPER($5), TRIM(_first || ' ' || _last));
44990
 
  _generate     BOOLEAN := COALESCE($6, FALSE);
44991
 
  _counter      INTEGER;
44992
 
  _custcount    INTEGER := 0;
44993
 
  _custnumber   TEXT;
44994
 
  _candidate    TEXT    := '';
44995
 
  _loopmax      INTEGER := 0;
44996
 
  _minlength    INTEGER := 5;
44997
 
  _maxlength    INTEGER := 8;
44998
 
  _numformat    TEXT    := '';
44999
 
  _testme       TEXT;
45000
 
BEGIN
45001
 
  IF (_email != '') THEN
45002
 
    SELECT count(*), cust_number INTO _custcount, _custnumber
45003
 
    FROM custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)
45004
 
    WHERE (UPPER(cntct_email)=_email)
45005
 
    GROUP BY cust_number;
45006
 
    IF (NOT FOUND) THEN
45007
 
      _custcount := 0;
45008
 
    ELSIF(_custcount = 1) THEN
45009
 
      RETURN _custnumber;
45010
 
    END IF;
45011
 
  END IF;
45012
 
 
45013
 
  IF (_company != '') THEN
45014
 
    SELECT count(*), cust_number INTO _custcount, _custnumber
45015
 
    FROM custinfo
45016
 
    WHERE (UPPER(cust_name)=_company)
45017
 
    GROUP BY cust_number;
45018
 
    IF (NOT FOUND) THEN
45019
 
      _custcount := 0;
45020
 
    ELSIF(_custcount = 1) THEN
45021
 
      RETURN _custnumber;
45022
 
    END IF;
45023
 
  END IF;
45024
 
 
45025
 
  IF (_fullname = '' AND (_first != '' OR _last != '')) THEN
45026
 
    _fullname := TRIM(_first || ' ' || _last);
45027
 
  END IF;
45028
 
 
45029
 
  IF (_custcount <= 0 AND _fullname != '') THEN
45030
 
    SELECT count(*), cust_number INTO _custcount, _custnumber
45031
 
    FROM custinfo
45032
 
    WHERE (UPPER(cust_name)=_fullname)
45033
 
    GROUP BY cust_number;
45034
 
    IF (NOT FOUND) THEN
45035
 
      _custcount := 0;
45036
 
    ELSIF(_custcount = 1) THEN
45037
 
      RETURN _custnumber;
45038
 
    END IF;
45039
 
  END IF;
45040
 
 
45041
 
  IF (_custcount > 1) THEN
45042
 
    RAISE EXCEPTION 'Found % possible Customers for % and % and %',
45043
 
                    _custcount, _email, _company, _fullname;
45044
 
  END IF;
45045
 
 
45046
 
  IF (_custcount <= 0 AND _generate) THEN
45047
 
    IF (_maxlength < _minlength) THEN
45048
 
      RAISE EXCEPTION 'Fix getCustNumberFromInfo: max length < min length';
45049
 
    END IF;
45050
 
 
45051
 
    IF (_company != '') THEN
45052
 
      _candidate := _company;
45053
 
    ELSIF (_email != '') THEN
45054
 
      _candidate := SUBSTRING(_email FOR POSITION('@' IN _email) - 1);
45055
 
    ELSIF (_last != '') THEN
45056
 
      _candidate := _last;
45057
 
      IF (_first != '') THEN
45058
 
        _candidate := _candidate || _first;
45059
 
      END IF;
45060
 
    ELSIF (_fullname != '' AND (POSITION(' ' IN _fullname) > 0)) THEN
45061
 
      _candidate := SUBSTRING(_fullname FROM POSITION(' ' IN _fullname) + 1) ||
45062
 
                    SUBSTRING(_fullname FOR  POSITION(' ' IN _fullname) - 1);
45063
 
    END IF;
45064
 
    WHILE (POSITION(' ' IN _candidate) > 0) LOOP
45065
 
      _candidate := SUBSTRING(_candidate FOR  POSITION(' ' IN _candidate) - 1) ||
45066
 
                    SUBSTRING(_candidate FROM POSITION(' ' IN _candidate) + 1);
45067
 
    END LOOP;
45068
 
    FOR _counter IN _minlength.._maxlength LOOP
45069
 
      _testme := SUBSTRING(_candidate FOR _counter);
45070
 
      IF (NOT EXISTS(SELECT cust_number
45071
 
                     FROM custinfo
45072
 
                     WHERE (cust_number=_testme))) THEN
45073
 
        _custnumber := _testme;
45074
 
        EXIT;
45075
 
      END IF;
45076
 
    END LOOP;
45077
 
    IF (_custnumber IS NULL OR _custnumber = '') THEN
45078
 
      IF (LENGTH(_candidate) < _minlength) THEN
45079
 
        _minlength := LENGTH(_candidate);
45080
 
      END IF;
45081
 
      FOR _counter IN _minlength.._maxlength LOOP
45082
 
        _loopmax := _loopmax * 10 + 9;
45083
 
        _numformat := _numformat || '0';
45084
 
      END LOOP;
45085
 
      FOR _counter IN 1.._loopmax LOOP
45086
 
        _testme := SUBSTRING(_candidate FOR _minlength) ||
45087
 
                   TRIM(TO_CHAR(_counter, _numformat));
45088
 
        IF (NOT EXISTS(SELECT cust_number
45089
 
                       FROM custinfo
45090
 
                       WHERE (cust_number=_testme))) THEN
45091
 
          _custnumber := _testme;
45092
 
          EXIT;
45093
 
        END IF;
45094
 
      END LOOP;
45095
 
    END IF;
45096
 
    IF (_custnumber IS NULL OR _custnumber = '') THEN
45097
 
      RAISE EXCEPTION 'Could not generate a new Customer Number';
45098
 
    END IF;
45099
 
  END IF;
45100
 
 
45101
 
  IF (_custnumber IS NULL OR _custnumber = '') THEN
45102
 
    RAISE EXCEPTION 'Could not find Customer Number for % and % and %',
45103
 
                    _email, _company, _fullname;
45104
 
  END IF;
45105
 
 
45106
 
  RETURN _custnumber;
45107
 
END;
45108
 
$_$;
45109
 
 
45110
 
 
45111
 
ALTER FUNCTION public.getcustnumberfrominfo(text, text, text, text, text, boolean) OWNER TO admin;
45112
 
 
45113
 
--
45114
 
--
45115
 
 
45116
 
CREATE FUNCTION getcusttypeid(text) RETURNS integer
45117
 
    LANGUAGE plpgsql
45118
 
    AS $_$
45119
 
DECLARE
45120
 
  pCustTypeCode ALIAS FOR $1;
45121
 
  _returnVal INTEGER;
45122
 
BEGIN
45123
 
  IF (pCustTypeCode IS NULL) THEN
45124
 
    RETURN NULL;
45125
 
  END IF;
45126
 
 
45127
 
  SELECT custtype_id INTO _returnVal
45128
 
  FROM custtype
45129
 
  WHERE (custtype_code=pCustTypeCode);
45130
 
 
45131
 
  IF (_returnVal IS NULL) THEN
45132
 
        RAISE EXCEPTION 'Customer Type % not found.', pCustTypeCode;
45133
 
  END IF;
45134
 
 
45135
 
  RETURN _returnVal;
45136
 
END;
45137
 
$_$;
45138
 
 
45139
 
 
45140
 
ALTER FUNCTION public.getcusttypeid(text) OWNER TO admin;
45141
 
 
45142
 
--
45143
 
--
45144
 
 
45145
 
CREATE FUNCTION getdeptid(text) RETURNS integer
45146
 
    LANGUAGE plpgsql
45147
 
    AS $_$
45148
 
DECLARE
45149
 
  pDeptNumber ALIAS FOR $1;
45150
 
  _returnVal INTEGER;
45151
 
BEGIN
45152
 
  IF (COALESCE(TRIM(pDeptNumber), '') = '') THEN
45153
 
    RETURN NULL;
45154
 
  END IF;
45155
 
 
45156
 
  SELECT dept_id INTO _returnVal
45157
 
  FROM dept
45158
 
  WHERE (UPPER(dept_number)=UPPER(pDeptNumber));
45159
 
 
45160
 
  IF (_returnVal IS NULL) THEN
45161
 
    RAISE EXCEPTION 'Department % not found.', pDeptNumber;
45162
 
  END IF;
45163
 
 
45164
 
  RETURN _returnVal;
45165
 
END;
45166
 
$_$;
45167
 
 
45168
 
 
45169
 
ALTER FUNCTION public.getdeptid(text) OWNER TO admin;
45170
 
 
45171
 
--
45172
 
--
45173
 
 
45174
 
CREATE FUNCTION getediprofileid(text) RETURNS integer
45175
 
    LANGUAGE plpgsql
45176
 
    AS $_$
45177
 
DECLARE
45178
 
  pEdiProfileName ALIAS FOR $1;
45179
 
  _returnVal INTEGER;
45180
 
BEGIN
45181
 
  IF (pEdiProfileName IS NULL) THEN
45182
 
        RETURN NULL;
45183
 
  END IF;
45184
 
 
45185
 
  SELECT pkghead_id INTO _returnVal
45186
 
    FROM pkghead
45187
 
   WHERE(pkghead_name='xtbatch');
45188
 
  IF(NOT FOUND) THEN
45189
 
    RETURN NULL;
45190
 
  END IF;
45191
 
 
45192
 
  SELECT ediprofile_id INTO _returnVal
45193
 
  FROM xtbatch.ediprofile
45194
 
  WHERE (ediprofile_name=pEdiProfileName);
45195
 
 
45196
 
  IF (_returnVal IS NULL) THEN
45197
 
    RAISE EXCEPTION 'EDI Profile % not found.', pEdiProfileName;
45198
 
  END IF;
45199
 
 
45200
 
  RETURN _returnVal;
45201
 
END;
45202
 
$_$;
45203
 
 
45204
 
 
45205
 
ALTER FUNCTION public.getediprofileid(text) OWNER TO admin;
45206
 
 
45207
 
--
45208
 
--
45209
 
 
45210
 
CREATE FUNCTION getediprofilename(integer) RETURNS text
45211
 
    LANGUAGE plpgsql
45212
 
    AS $_$
45213
 
DECLARE
45214
 
  pEdiProfileId ALIAS FOR $1;
45215
 
  _returnVal TEXT;
45216
 
BEGIN
45217
 
  IF (pEdiProfileId IS NULL) THEN
45218
 
        RETURN NULL;
45219
 
  END IF;
45220
 
 
45221
 
  SELECT pkghead_name INTO _returnVal
45222
 
    FROM pkghead
45223
 
   WHERE(pkghead_name='xtbatch');
45224
 
  IF(NOT FOUND) THEN
45225
 
    RETURN NULL;
45226
 
  END IF;
45227
 
 
45228
 
  SELECT ediprofile_name INTO _returnVal
45229
 
  FROM xtbatch.ediprofile
45230
 
  WHERE (ediprofile_id=pEdiProfileId);
45231
 
 
45232
 
  RETURN _returnVal;
45233
 
END;
45234
 
$_$;
45235
 
 
45236
 
 
45237
 
ALTER FUNCTION public.getediprofilename(integer) OWNER TO admin;
45238
 
 
45239
 
--
45240
 
--
45241
 
 
45242
 
CREATE FUNCTION getempid(text) RETURNS integer
45243
 
    LANGUAGE plpgsql
45244
 
    AS $_$
45245
 
DECLARE
45246
 
  pEmpCode ALIAS FOR $1;
45247
 
  _returnVal INTEGER;
45248
 
BEGIN
45249
 
  IF (COALESCE(TRIM(pEmpCode), '') = '') THEN
45250
 
    RETURN NULL;
45251
 
  END IF;
45252
 
 
45253
 
  SELECT emp_id INTO _returnVal
45254
 
  FROM emp
45255
 
  WHERE (UPPER(emp_code)=UPPER(pEmpCode));
45256
 
 
45257
 
  IF (_returnVal IS NULL) THEN
45258
 
    RAISE EXCEPTION 'Employee % not found.', pEmpCode;
45259
 
  END IF;
45260
 
 
45261
 
  RETURN _returnVal;
45262
 
END;
45263
 
$_$;
45264
 
 
45265
 
 
45266
 
ALTER FUNCTION public.getempid(text) OWNER TO admin;
45267
 
 
45268
 
--
45269
 
--
45270
 
 
45271
 
CREATE FUNCTION getexpcatid(text) RETURNS integer
45272
 
    LANGUAGE plpgsql
45273
 
    AS $_$
45274
 
DECLARE
45275
 
  pExpcatCode ALIAS FOR $1;
45276
 
  _returnVal INTEGER;
45277
 
BEGIN
45278
 
  IF (COALESCE(TRIM(pExpcatCode), '') = '') THEN
45279
 
    RETURN NULL;
45280
 
  END IF;
45281
 
 
45282
 
  SELECT expcat_id INTO _returnVal
45283
 
  FROM expcat
45284
 
  WHERE (expcat_code=UPPER(pExpcatCode));
45285
 
 
45286
 
  IF (_returnVal IS NULL) THEN
45287
 
    RAISE EXCEPTION 'Expense Category % not found.', pExpcatCode;
45288
 
  END IF;
45289
 
 
45290
 
  RETURN _returnVal;
45291
 
END;
45292
 
$_$;
45293
 
 
45294
 
 
45295
 
ALTER FUNCTION public.getexpcatid(text) OWNER TO admin;
45296
 
 
45297
 
--
45298
 
--
45299
 
 
45300
 
CREATE FUNCTION getflcoldata(integer, integer) RETURNS SETOF flcoldata
45301
 
    LANGUAGE plpgsql
45302
 
    AS $_$
45303
 
DECLARE
45304
 
  pFlcolid ALIAS FOR $1;
45305
 
  pPeriodid ALIAS FOR $2;
45306
 
  _row flcoldata%ROWTYPE;
45307
 
  _r RECORD;
45308
 
  _start DATE;
45309
 
  _end DATE;
45310
 
  _col INTEGER := 1;
45311
 
  _mult INTEGER;
45312
 
 
45313
 
BEGIN
45314
 
 
45315
 
--Get Layout Data
45316
 
  SELECT * INTO _r
45317
 
  FROM flcol
45318
 
  WHERE (flcol_id=pFlcolid);
45319
 
 
45320
 
  IF (_r.flcol_month) THEN
45321
 
    SELECT period_start, period_end INTO _start, _end
45322
 
    FROM period
45323
 
    WHERE (period_id=pPeriodid);
45324
 
    
45325
 
    IF (_r.flcol_showdb) THEN
45326
 
      -- Debits Column
45327
 
      _row.flcoldata_column := _col;
45328
 
      _row.flcoldata_start := _start;
45329
 
      _row.flcoldata_end := _end;
45330
 
      RETURN NEXT _row;
45331
 
      _col := _col + 1;
45332
 
 
45333
 
      -- Credits Column
45334
 
      _row.flcoldata_column := _col;
45335
 
      _row.flcoldata_start := _start;
45336
 
      _row.flcoldata_end := _end;
45337
 
      RETURN NEXT _row;
45338
 
      _col := _col + 1;
45339
 
    END IF;
45340
 
 
45341
 
    -- Month Column
45342
 
    _row.flcoldata_column := _col;
45343
 
    _row.flcoldata_start := _start;
45344
 
    _row.flcoldata_end := _end;
45345
 
    RETURN NEXT _row;
45346
 
    _col := _col + 1;
45347
 
 
45348
 
    -- These don't have drill down
45349
 
    IF (_r.flcol_prcnt) THEN 
45350
 
      _col := _col + 1;
45351
 
    END IF;
45352
 
    IF (_r.flcol_budget) THEN
45353
 
      _col := _col + 1;
45354
 
      IF (_r.flcol_budgetprcnt) THEN
45355
 
        _col := _col + 1;
45356
 
      END IF;
45357
 
      IF (_r.flcol_budgetdiff) THEN
45358
 
        _col := _col + 1;
45359
 
      END IF;
45360
 
      IF (_r.flcol_budgetdiffprcnt) THEN
45361
 
        _col := _col + 1;
45362
 
      END IF;
45363
 
    END IF; 
45364
 
  END IF;
45365
 
 
45366
 
  IF (_r.flcol_quarter) THEN
45367
 
    SELECT min(qtr.period_start), max(qtr.period_end) INTO _start, _end
45368
 
    FROM period p
45369
 
     JOIN period qtr ON (p.period_quarter=qtr.period_quarter)
45370
 
                     AND (p.period_yearperiod_id=qtr.period_yearperiod_id)
45371
 
    WHERE (p.period_id=pPeriodid);
45372
 
    
45373
 
    IF (_r.flcol_showdb) THEN
45374
 
      -- Debits Column
45375
 
      _row.flcoldata_column := _col;
45376
 
      _row.flcoldata_start := _start;
45377
 
      _row.flcoldata_end := _end;
45378
 
      RETURN NEXT _row;
45379
 
      _col := _col + 1;
45380
 
 
45381
 
      -- Credits Column
45382
 
      _row.flcoldata_column := _col;
45383
 
      _row.flcoldata_start := _start;
45384
 
      _row.flcoldata_end := _end;
45385
 
      RETURN NEXT _row;
45386
 
      _col := _col + 1;
45387
 
    END IF;
45388
 
 
45389
 
    -- Quarter Column
45390
 
    _row.flcoldata_column := _col;
45391
 
    _row.flcoldata_start := _start;
45392
 
    _row.flcoldata_end := _end;
45393
 
    RETURN NEXT _row;
45394
 
    _col := _col + 1;
45395
 
 
45396
 
    -- These don't have drill down
45397
 
    IF (_r.flcol_prcnt) THEN 
45398
 
      _col := _col + 1;
45399
 
    END IF;
45400
 
    IF (_r.flcol_budget) THEN
45401
 
      _col := _col + 1;
45402
 
      IF (_r.flcol_budgetprcnt) THEN
45403
 
        _col := _col + 1;
45404
 
      END IF;
45405
 
      IF (_r.flcol_budgetdiff) THEN
45406
 
        _col := _col + 1;
45407
 
      END IF;
45408
 
      IF (_r.flcol_budgetdiffprcnt) THEN
45409
 
        _col := _col + 1;
45410
 
      END IF;
45411
 
    END IF; 
45412
 
  END IF;
45413
 
 
45414
 
  IF (_r.flcol_year) THEN
45415
 
    SELECT yearperiod_start, period_end INTO _start, _end
45416
 
    FROM period p
45417
 
     JOIN yearperiod ON (period_yearperiod_id=yearperiod_id)
45418
 
    WHERE (p.period_id=pPeriodid);
45419
 
    
45420
 
    IF (_r.flcol_showdb) THEN
45421
 
      -- Debits Column
45422
 
      _row.flcoldata_column := _col;
45423
 
      _row.flcoldata_start := _start;
45424
 
      _row.flcoldata_end := _end;
45425
 
      RETURN NEXT _row;
45426
 
      _col := _col + 1;
45427
 
 
45428
 
      -- Credits Column
45429
 
      _row.flcoldata_column := _col;
45430
 
      _row.flcoldata_start := _start;
45431
 
      _row.flcoldata_end := _end;
45432
 
      RETURN NEXT _row;
45433
 
      _col := _col + 1;
45434
 
    END IF;
45435
 
 
45436
 
    -- Year Column
45437
 
    _row.flcoldata_column := _col;
45438
 
    _row.flcoldata_start := _start;
45439
 
    _row.flcoldata_end := _end;
45440
 
    RETURN NEXT _row;
45441
 
    _col := _col + 1;
45442
 
 
45443
 
    -- These don't have drill down
45444
 
    IF (_r.flcol_prcnt) THEN 
45445
 
      _col := _col + 1;
45446
 
    END IF;
45447
 
    IF (_r.flcol_budget) THEN
45448
 
      _col := _col + 1;
45449
 
      IF (_r.flcol_budgetprcnt) THEN
45450
 
        _col := _col + 1;
45451
 
      END IF;
45452
 
      IF (_r.flcol_budgetdiff) THEN
45453
 
        _col := _col + 1;
45454
 
      END IF;
45455
 
      IF (_r.flcol_budgetdiffprcnt) THEN
45456
 
        _col := _col + 1;
45457
 
      END IF;
45458
 
    END IF;
45459
 
  END IF;
45460
 
 
45461
 
  -- Handle Prior Month...
45462
 
  IF (_r.flcol_priormonth) THEN
45463
 
    SELECT prv.period_start, prv.period_end INTO _start, _end
45464
 
    FROM period p
45465
 
      JOIN period prv ON (prv.period_start < p.period_start)
45466
 
    WHERE (p.period_id=pPeriodid)
45467
 
    ORDER BY prv.period_start DESC
45468
 
    LIMIT 1;
45469
 
 
45470
 
    -- Prior Month Column
45471
 
    _row.flcoldata_column := _col;
45472
 
    _row.flcoldata_start := _start;
45473
 
    _row.flcoldata_end := _end;
45474
 
    RETURN NEXT _row;
45475
 
    _col := _col + 1;
45476
 
 
45477
 
    -- These don't have drill down
45478
 
    IF (_r.flcol_priorprcnt) THEN 
45479
 
      _col := _col + 1;
45480
 
    END IF;
45481
 
    IF (_r.flcol_priordiff) THEN 
45482
 
      _col := _col + 1;
45483
 
    END IF;
45484
 
    IF (_r.flcol_priordiffprcnt) THEN 
45485
 
      _col := _col + 1;
45486
 
    END IF;
45487
 
  END IF;
45488
 
 
45489
 
  IF (_r.flcol_priorquarter) THEN
45490
 
    IF (_r.flcol_priortype = 'P') THEN
45491
 
      -- Prior Quarter
45492
 
      SELECT min(period_start), max(period_end)
45493
 
      INTO _start, _end
45494
 
      FROM (
45495
 
        SELECT prv.period_start, prv.period_end, prv.period_quarter, prv.period_yearperiod_id
45496
 
        FROM period p
45497
 
          JOIN period prv ON (prv.period_start < p.period_start)
45498
 
                          AND (prv.period_quarter != p.period_quarter)
45499
 
        WHERE (p.period_id=pPeriodid)) data
45500
 
      GROUP BY period_quarter, period_yearperiod_id
45501
 
      ORDER BY min(period_start) DESC
45502
 
      LIMIT 1;
45503
 
    ELSE
45504
 
      -- Prior Year Quarter
45505
 
      SELECT min(period_start), max(period_end)
45506
 
      INTO _start, _end
45507
 
      FROM (
45508
 
        SELECT prv.period_start, prv.period_end, prv.period_quarter, prv.period_yearperiod_id
45509
 
        FROM period p
45510
 
          JOIN period prv ON (prv.period_start < p.period_start)
45511
 
                          AND (prv.period_yearperiod_id != p.period_yearperiod_id)
45512
 
                          AND (prv.period_quarter = p.period_quarter)
45513
 
        WHERE (p.period_id=pPeriodid)) data
45514
 
      GROUP BY period_quarter, period_yearperiod_id
45515
 
      ORDER BY min(period_start) DESC
45516
 
      LIMIT 1;
45517
 
    END IF;
45518
 
 
45519
 
    -- Prior Quarter Column
45520
 
    _row.flcoldata_column := _col;
45521
 
    _row.flcoldata_start := _start;
45522
 
    _row.flcoldata_end := _end;
45523
 
    RETURN NEXT _row;
45524
 
    _col := _col + 1;
45525
 
 
45526
 
    -- These don't have drill down
45527
 
    IF (_r.flcol_priorprcnt) THEN 
45528
 
      _col := _col + 1;
45529
 
    END IF;
45530
 
    IF (_r.flcol_priordiff) THEN 
45531
 
      _col := _col + 1;
45532
 
    END IF;
45533
 
    IF (_r.flcol_priordiffprcnt) THEN 
45534
 
      _col := _col + 1;
45535
 
    END IF;
45536
 
  END IF;
45537
 
 
45538
 
  -- Handle Prior Year...
45539
 
  IF (_r.flcol_prioryear IN ('D','F')) THEN
45540
 
    IF (_r.flcol_prioryear = 'D') THEN
45541
 
      -- Prior Year to Date
45542
 
      SELECT yearperiod_start, prv.period_end INTO _start, _end
45543
 
      FROM period p
45544
 
        JOIN period prv ON (prv.period_number = p.period_number)
45545
 
                        AND (prv.period_yearperiod_id != p.period_yearperiod_id)
45546
 
                        AND (prv.period_start < p.period_start)
45547
 
        JOIN yearperiod ON (prv.period_yearperiod_id=yearperiod_id)   
45548
 
      WHERE (p.period_id=pPeriodid)
45549
 
      ORDER BY prv.period_start DESC
45550
 
      LIMIT 1;
45551
 
    ELSE
45552
 
      -- Prior Full Year
45553
 
      SELECT prv.yearperiod_start, prv.yearperiod_end INTO _start, _end
45554
 
      FROM period p
45555
 
        JOIN yearperiod cur ON (cur.yearperiod_id=p.period_yearperiod_id)
45556
 
        JOIN yearperiod prv ON (prv.yearperiod_start < cur.yearperiod_start)
45557
 
      WHERE (p.period_id=pPeriodid)
45558
 
      ORDER BY prv.yearperiod_start DESC
45559
 
      LIMIT 1;
45560
 
    END IF;
45561
 
 
45562
 
    -- Prior Year Column
45563
 
    _row.flcoldata_column := _col;
45564
 
    _row.flcoldata_start := _start;
45565
 
    _row.flcoldata_end := _end;
45566
 
    RETURN NEXT _row;
45567
 
    _col := _col + 1;
45568
 
 
45569
 
  END IF;
45570
 
 
45571
 
  RETURN;
45572
 
 
45573
 
END;
45574
 
$_$;
45575
 
 
45576
 
 
45577
 
ALTER FUNCTION public.getflcoldata(integer, integer) OWNER TO admin;
45578
 
 
45579
 
--
45580
 
--
45581
 
 
45582
 
CREATE FUNCTION getflcoldata(character, integer[], boolean) RETURNS SETOF flcoldata
45583
 
    LANGUAGE plpgsql
45584
 
    AS $_$
45585
 
DECLARE
45586
 
  pInterval ALIAS FOR $1;
45587
 
  pPeriodids ALIAS FOR $2;
45588
 
  pBudgets ALIAS FOR $3;
45589
 
  _row flcoldata%ROWTYPE;
45590
 
  _r RECORD;
45591
 
  _start DATE;
45592
 
  _end DATE;
45593
 
  _col INTEGER := 1;
45594
 
  _count INTEGER;
45595
 
  _i INTEGER := 1;
45596
 
  _incr INTEGER := 1;
45597
 
 
45598
 
BEGIN
45599
 
 
45600
 
  IF (pBudgets) THEN
45601
 
    _col := 2;
45602
 
    _incr := 2;
45603
 
  END IF;
45604
 
  
45605
 
  _count := ARRAY_UPPER(pPeriodIds,1);
45606
 
  
45607
 
  IF (pInterval = 'M') THEN
45608
 
    FOR _i IN 1.._count
45609
 
    LOOP
45610
 
      SELECT period_start, period_end INTO _start, _end
45611
 
      FROM period
45612
 
      WHERE (period_id=pPeriodids[_i]);
45613
 
 
45614
 
      _row.flcoldata_column := _col;
45615
 
      _row.flcoldata_start := _start;
45616
 
      _row.flcoldata_end := _end;
45617
 
      RETURN NEXT _row;
45618
 
      _col := _col + _incr;
45619
 
    END LOOP;
45620
 
  ELSIF (pInterval = 'Q') THEN
45621
 
    FOR _i IN 1.._count
45622
 
    LOOP
45623
 
      SELECT min(qtr.period_start), max(qtr.period_end) INTO _start, _end
45624
 
      FROM period cur
45625
 
        JOIN period qtr ON (cur.period_yearperiod_id=qtr.period_yearperiod_id)
45626
 
                        AND (cur.period_quarter=qtr.period_quarter)
45627
 
      WHERE (cur.period_id=pPeriodids[_i]);
45628
 
 
45629
 
      _row.flcoldata_column := _col;
45630
 
      _row.flcoldata_start := _start;
45631
 
      _row.flcoldata_end := _end;
45632
 
      RETURN NEXT _row;
45633
 
      _col := _col + _incr;
45634
 
    END LOOP;
45635
 
  ELSE
45636
 
    FOR _i IN 1.._count
45637
 
    LOOP
45638
 
      SELECT yearperiod_start, yearperiod_end INTO _start, _end
45639
 
      FROM period
45640
 
        JOIN yearperiod ON (period_yearperiod_id=yearperiod_id)
45641
 
      WHERE (period_id=pPeriodids[_i]);
45642
 
 
45643
 
      _row.flcoldata_column := _col;
45644
 
      _row.flcoldata_start := _start;
45645
 
      _row.flcoldata_end := _end;
45646
 
      RETURN NEXT _row;
45647
 
      _col := _col + _incr;
45648
 
    END LOOP;
45649
 
  END IF;
45650
 
  RETURN;
45651
 
 
45652
 
END;
45653
 
$_$;
45654
 
 
45655
 
 
45656
 
ALTER FUNCTION public.getflcoldata(character, integer[], boolean) OWNER TO admin;
45657
 
 
45658
 
--
45659
 
--
45660
 
 
45661
 
CREATE FUNCTION getflstmthead(integer, integer) RETURNS SETOF flstmthead
45662
 
    LANGUAGE plpgsql
45663
 
    AS $_$
45664
 
DECLARE
45665
 
  pFlcolid ALIAS FOR $1;
45666
 
  pPeriodid ALIAS FOR $2;
45667
 
  _row flstmthead%ROWTYPE;
45668
 
  _p RECORD;
45669
 
  _month TEXT;
45670
 
  _qtr TEXT;
45671
 
  _year TEXT;
45672
 
  _prmonth TEXT;
45673
 
  _prqtr TEXT;
45674
 
  _pryear TEXT;
45675
 
  _err TEXT;
45676
 
 
45677
 
BEGIN
45678
 
 
45679
 
  SELECT 'No Data' INTO _err;
45680
 
 
45681
 
--Get Layout Data
45682
 
  SELECT flcol_priortype, flcol_prioryear INTO _p
45683
 
  FROM flcol
45684
 
  WHERE (flcol_id=pFlcolid);
45685
 
 
45686
 
--get data...
45687
 
--...for current Month
45688
 
        SELECT
45689
 
          (CASE
45690
 
                      WHEN period_name='' THEN
45691
 
                        formatdate(period_start) || '-' || formatdate(period_end)
45692
 
                      ELSE period_name
45693
 
          END) INTO _month
45694
 
        FROM period
45695
 
        WHERE (period_id=pPeriodId);
45696
 
 
45697
 
        IF _month IS NULL THEN
45698
 
          _month := _err;
45699
 
        END IF;
45700
 
 
45701
 
--...for Quarter
45702
 
        SELECT
45703
 
          ('Q' || period_quarter || '-' || EXTRACT(year from yearperiod_end)) INTO _qtr
45704
 
        FROM period, yearperiod
45705
 
        WHERE ((period_id=pPeriodId)
45706
 
        AND (period_yearperiod_id=yearperiod_id));
45707
 
 
45708
 
        IF _qtr IS NULL THEN
45709
 
          _qtr := _err;
45710
 
        END IF;
45711
 
 
45712
 
--...for Year
45713
 
        SELECT
45714
 
          COALESCE((CASE WHEN period_name='' THEN
45715
 
                (formatdate(period_start) || '-' || formatdate(period_end) || ' YTD')
45716
 
          ELSE (period_name || ' YTD')
45717
 
          END),'No Data') INTO _year
45718
 
        FROM period
45719
 
        WHERE (period_id=pPeriodId);
45720
 
 
45721
 
        IF _year IS NULL THEN
45722
 
          _year := _err;
45723
 
        END IF;
45724
 
 
45725
 
--...for prior month
45726
 
 
45727
 
        IF (_p.flcol_priortype = 'P') THEN
45728
 
 
45729
 
          SELECT
45730
 
            (CASE WHEN pp.period_name='' THEN
45731
 
              formatdate(pp.period_start) || '-' || formatdate(pp.period_end)
45732
 
            ELSE pp.period_name END) INTO _prmonth
45733
 
          FROM period cp, period pp
45734
 
          WHERE ((cp.period_id=pPeriodId)
45735
 
          AND (cp.period_start > pp.period_start))
45736
 
          ORDER BY pp.period_start DESC LIMIT 1;
45737
 
 
45738
 
        ELSE
45739
 
 
45740
 
          SELECT
45741
 
            (CASE WHEN pp.period_name='' THEN
45742
 
              formatdate(pp.period_start) || '-' || formatdate(pp.period_end)
45743
 
            ELSE pp.period_name END) INTO _prmonth
45744
 
          FROM period cp, period pp
45745
 
          WHERE ((cp.period_id=pPeriodId)
45746
 
           AND (cp.period_id != pp.period_id)
45747
 
           AND (cp.period_start > pp.period_start)
45748
 
           AND (cp.period_number = pp.period_number))
45749
 
          ORDER BY pp.period_start DESC LIMIT 1;
45750
 
 
45751
 
        END IF;
45752
 
 
45753
 
          IF _prmonth IS NULL THEN
45754
 
            _prmonth := _err;
45755
 
          END IF;
45756
 
 
45757
 
 
45758
 
--...for prior quarter
45759
 
 
45760
 
        IF (_p.flcol_priortype='P') THEN
45761
 
 
45762
 
          SELECT ('Q' || pp.period_quarter || '-' || EXTRACT(year from yearperiod_end)) INTO _prqtr
45763
 
          FROM period cp, period pp, yearperiod
45764
 
          WHERE ((cp.period_id=pPeriodId)
45765
 
          AND (cp.period_start > pp.period_start)
45766
 
          AND (pp.period_quarter=
45767
 
            CASE WHEN cp.period_quarter > 1 THEN
45768
 
              cp.period_quarter - 1
45769
 
          ELSE 4 END)
45770
 
          AND (pp.period_start >= cp.period_start - interval '1 year')
45771
 
          AND (pp.period_yearperiod_id=yearperiod_id))
45772
 
          ORDER BY pp.period_start DESC LIMIT 1;
45773
 
 
45774
 
        ELSE
45775
 
 
45776
 
          SELECT
45777
 
            ('Q' || pp.period_quarter || '-' || EXTRACT(year from pp.period_start)) INTO _prqtr
45778
 
          FROM period cp, period pp, yearperiod cy, yearperiod py
45779
 
          WHERE ((cp.period_id=pPeriodId)
45780
 
          AND (cp.period_yearperiod_id=cy.yearperiod_id)
45781
 
          AND (pp.period_yearperiod_id=py.yearperiod_id)
45782
 
          AND (cp.period_quarter=pp.period_quarter)
45783
 
          AND (cy.yearperiod_start > py.yearperiod_start))
45784
 
          ORDER BY py.yearperiod_start DESC, pp.period_start DESC LIMIT 1;
45785
 
 
45786
 
        END IF;
45787
 
 
45788
 
        IF _prqtr IS NULL THEN
45789
 
          _prqtr := _err;
45790
 
        END IF;
45791
 
 
45792
 
--...for prior year
45793
 
 
45794
 
        IF (_p.flcol_prioryear='F') THEN
45795
 
 
45796
 
          SELECT (EXTRACT(year from py.yearperiod_end)||'') INTO _pryear
45797
 
          FROM period cp, yearperiod cy, yearperiod py
45798
 
          WHERE ((cp.period_id=pPeriodId)
45799
 
           AND (cp.period_yearperiod_id = cy.yearperiod_id)
45800
 
           AND (cy.yearperiod_start > py.yearperiod_start))
45801
 
          ORDER BY py.yearperiod_start DESC LIMIT 1;
45802
 
 
45803
 
        ELSE
45804
 
 
45805
 
          SELECT
45806
 
          (CASE
45807
 
                      WHEN pp.period_name='' THEN
45808
 
                        formatdate(pp.period_start) || '-' || formatdate(pp.period_end) || ' YTD'
45809
 
                      ELSE pp.period_name || ' YTD'
45810
 
          END) INTO _pryear
45811
 
          FROM period cp, period pp
45812
 
          WHERE ((cp.period_id=pPeriodId)
45813
 
            AND (cp.period_number = pp.period_number)
45814
 
            AND (cp.period_start > pp.period_start))
45815
 
          ORDER BY pp.period_start DESC LIMIT 1;
45816
 
 
45817
 
        END IF;
45818
 
 
45819
 
        IF _pryear IS NULL THEN
45820
 
          _pryear := _err;
45821
 
        END IF;
45822
 
 
45823
 
 
45824
 
        SELECT
45825
 
                flhead_id AS flstmthead_flhead_id,
45826
 
                flcol_id AS flstmthead_flcol_id,
45827
 
                pPeriodid AS flstmthead_period,
45828
 
                getEffectiveXtUser() AS flstmthead_username,
45829
 
                CASE
45830
 
                        WHEN flhead_type = 'I' THEN 'Income Statement'
45831
 
                        WHEN flhead_type = 'B' THEN 'Balance Sheet'
45832
 
                        WHEN flhead_type = 'C' THEN 'Cash Flow Statement'
45833
 
                        ELSE 'N/A'
45834
 
                END AS flstmthead_flhead_typedescrip1,
45835
 
                CASE
45836
 
                        WHEN flhead_type = 'I' THEN 'Income'
45837
 
                        WHEN flhead_type = 'B' THEN 'Balance'
45838
 
                        WHEN flhead_type = 'C' THEN 'Cash'
45839
 
                        ELSE 'N/A'
45840
 
                END AS flstmthead_flhead_typedescrip2,
45841
 
                flhead_name AS flstmthead_flhead_name,
45842
 
                flcol_name AS flstmthead_flcol_name,
45843
 
                _month AS flstmthead_month,
45844
 
                _qtr AS flstmthead_qtr,
45845
 
                _year AS flstmthead_year,
45846
 
                _prmonth AS flstmthead_prmonth,
45847
 
                _prqtr AS flstmthead_prqtr,
45848
 
                _pryear AS flstmthead_pryear INTO _p
45849
 
        FROM flhead,flcol
45850
 
        WHERE ((flcol_id=pFlcolid)
45851
 
        AND (flhead_id=flcol_flhead_id));
45852
 
 
45853
 
                _row.flstmthead_flhead_id := _p.flstmthead_flhead_id;
45854
 
                _row.flstmthead_flcol_id := _p.flstmthead_flcol_id;
45855
 
                _row.flstmthead_period_id := _p.flstmthead_period;
45856
 
                _row.flstmthead_username := _p.flstmthead_username;
45857
 
                _row.flstmthead_typedescrip1 := _p.flstmthead_flhead_typedescrip1;
45858
 
                _row.flstmthead_typedescrip2 := _p.flstmthead_flhead_typedescrip2;
45859
 
                _row.flstmthead_flhead_name := _p.flstmthead_flhead_name;
45860
 
                _row.flstmthead_flcol_name := _p.flstmthead_flcol_name;
45861
 
                _row.flstmthead_month := _p.flstmthead_month;
45862
 
                _row.flstmthead_qtr := _p.flstmthead_qtr;
45863
 
                _row.flstmthead_year := _p.flstmthead_year;
45864
 
                _row.flstmthead_prmonth := _p.flstmthead_prmonth;
45865
 
                _row.flstmthead_prqtr := _p.flstmthead_prqtr;
45866
 
                _row.flstmthead_pryear := _p.flstmthead_pryear;
45867
 
 
45868
 
        RETURN NEXT _row;
45869
 
 
45870
 
END;
45871
 
$_$;
45872
 
 
45873
 
 
45874
 
ALTER FUNCTION public.getflstmthead(integer, integer) OWNER TO admin;
45875
 
 
45876
 
--
45877
 
--
45878
 
 
45879
 
CREATE FUNCTION getfltrendhead(integer, integer[], character) RETURNS SETOF fltrendhead
45880
 
    LANGUAGE plpgsql
45881
 
    AS $_$
45882
 
DECLARE
45883
 
  pFlheadid ALIAS FOR $1;
45884
 
  pPeriodids ALIAS FOR $2;
45885
 
  pInterval ALIAS FOR $3;
45886
 
  _row fltrendhead%ROWTYPE;
45887
 
  _p RECORD;
45888
 
  _count INTEGER;
45889
 
  _i INTEGER;
45890
 
  _t TEXT;
45891
 
  _fld TEXT[];
45892
 
  _type CHAR;
45893
 
 
45894
 
BEGIN
45895
 
 
45896
 
   IF pInterval <> 'M' AND pInterval <> 'Q' AND pInterval <> 'Y' THEN
45897
 
     RAISE EXCEPTION 'Invalid Interval --> %', pInterval;
45898
 
   END IF;
45899
 
 
45900
 
   IF ARRAY_UPPER(pPeriodIds,1) <= 12 THEN
45901
 
        _count := ARRAY_UPPER(pPeriodIds,1);
45902
 
   ELSE
45903
 
        _count := 12;
45904
 
   END IF;
45905
 
 
45906
 
   SELECT flhead_type INTO _type FROM flhead WHERE flhead_id = pFlheadId;
45907
 
 
45908
 
--get data...
45909
 
--...for Month
45910
 
        IF (pInterval = 'M') THEN
45911
 
                FOR _i IN 1.._count
45912
 
                LOOP
45913
 
                        SELECT
45914
 
                        (CASE
45915
 
                                WHEN period_name='' THEN
45916
 
                                        formatdate(period_start) || '-' || formatdate(period_end)
45917
 
                                ELSE period_name
45918
 
                        END) INTO _t
45919
 
                        FROM period
45920
 
                        WHERE (period_id=pPeriodIds[_i]);
45921
 
 
45922
 
                        _fld[_i] := _t;
45923
 
 
45924
 
                END LOOP;
45925
 
 
45926
 
--...for Quarter
45927
 
                ELSE IF (pInterval = 'Q') THEN
45928
 
                        FOR _i IN 1.._count
45929
 
                        LOOP
45930
 
                                SELECT
45931
 
                                        ('Q' || period_quarter || '-' || EXTRACT(year from yearperiod_end)) INTO _t
45932
 
                                FROM period, yearperiod
45933
 
                                WHERE ((period_id=pPeriodIds[_i])
45934
 
                                AND (period_yearperiod_id=yearperiod_id));
45935
 
 
45936
 
                                        _fld[_i] := _t;
45937
 
 
45938
 
                        END LOOP;
45939
 
--...for Year
45940
 
                ELSE
45941
 
                        FOR _i IN 1.._count
45942
 
                        LOOP
45943
 
                                SELECT (EXTRACT(year from yearperiod_end)||'') INTO _t
45944
 
                                FROM period, yearperiod
45945
 
                                WHERE ((period_id=pPeriodIds[_i])
45946
 
                                AND (period_yearperiod_id=yearperiod_id));
45947
 
 
45948
 
                                _fld[_i] := _t;
45949
 
 
45950
 
                        END LOOP;
45951
 
                END IF;
45952
 
        END IF;
45953
 
 
45954
 
 
45955
 
 
45956
 
        SELECT
45957
 
                flhead_id AS fltrendhead_flhead_id,
45958
 
                getEffectiveXtUser() AS fltrendhead_username,
45959
 
                CASE
45960
 
                        WHEN flhead_type = 'I' THEN 'Income Statement'
45961
 
                        WHEN flhead_type = 'B' THEN 'Balance Sheet'
45962
 
                        WHEN flhead_type = 'C' THEN 'Cash Flow Statement'
45963
 
                        ELSE 'Ad Hoc'
45964
 
                END AS fltrendhead_flhead_typedescrip,
45965
 
                flhead_name AS fltrendhead_flhead_name INTO _p
45966
 
        FROM flhead
45967
 
        WHERE (flhead_id=pFlheadId);
45968
 
 
45969
 
                _row.fltrendhead_flhead_id := _p.fltrendhead_flhead_id;
45970
 
                _row.fltrendhead_username := _p.fltrendhead_username;
45971
 
               _row.fltrendhead_typedescrip := _p.fltrendhead_flhead_typedescrip;
45972
 
                _row.fltrendhead_flhead_name := _p.fltrendhead_flhead_name;
45973
 
                _row.fltrendhead_fld1 := _fld[1];
45974
 
                _row.fltrendhead_fld2 := _fld[2];
45975
 
                _row.fltrendhead_fld3 := _fld[3];
45976
 
                _row.fltrendhead_fld4 := _fld[4];
45977
 
                _row.fltrendhead_fld5 := _fld[5];
45978
 
                _row.fltrendhead_fld6 := _fld[6];
45979
 
                _row.fltrendhead_fld7 := _fld[7];
45980
 
                _row.fltrendhead_fld8 := _fld[8];
45981
 
                _row.fltrendhead_fld9 := _fld[9];
45982
 
                _row.fltrendhead_fld10 := _fld[10];
45983
 
                _row.fltrendhead_fld11 := _fld[11];
45984
 
                _row.fltrendhead_fld12 := _fld[12];
45985
 
                IF (_type IN ('I','C')) THEN
45986
 
                        _row.fltrendhead_grndttl := 'Total';
45987
 
                END IF;
45988
 
 
45989
 
        RETURN NEXT _row;
45990
 
 
45991
 
END;
45992
 
$_$;
45993
 
 
45994
 
 
45995
 
ALTER FUNCTION public.getfltrendhead(integer, integer[], character) OWNER TO admin;
45996
 
 
45997
 
--
45998
 
--
45999
 
 
46000
 
CREATE FUNCTION getfreightclassid(text) RETURNS integer
46001
 
    LANGUAGE plpgsql
46002
 
    AS $_$
46003
 
DECLARE
46004
 
  pFreightClassCode ALIAS FOR $1;
46005
 
  _returnVal INTEGER;
46006
 
BEGIN
46007
 
  IF (pFreightClassCode IS NULL) THEN
46008
 
    RETURN NULL;
46009
 
  END IF;
46010
 
 
46011
 
  SELECT freightclass_id INTO _returnVal
46012
 
  FROM freightclass
46013
 
  WHERE (freightclass_code=pFreightClassCode);
46014
 
 
46015
 
  IF (_returnVal IS NULL) THEN
46016
 
        RAISE EXCEPTION 'Freight Class % not found.', pFreightClassCode;
46017
 
  END IF;
46018
 
 
46019
 
  RETURN _returnVal;
46020
 
END;
46021
 
$_$;
46022
 
 
46023
 
 
46024
 
ALTER FUNCTION public.getfreightclassid(text) OWNER TO admin;
46025
 
 
46026
 
--
46027
 
--
46028
 
 
46029
 
CREATE FUNCTION getfreighttaxtypeid() RETURNS integer
46030
 
    LANGUAGE plpgsql IMMUTABLE
46031
 
    AS $$
46032
 
DECLARE
46033
 
  _taxtypeid INTEGER;
46034
 
BEGIN
46035
 
  SELECT taxtype_id
46036
 
    INTO _taxtypeid
46037
 
    FROM taxtype
46038
 
   WHERE (taxtype_name='Freight');
46039
 
 
46040
 
  RETURN _taxtypeid;
46041
 
END;
46042
 
$$;
46043
 
 
46044
 
 
46045
 
ALTER FUNCTION public.getfreighttaxtypeid() OWNER TO admin;
46046
 
 
46047
 
--
46048
 
--
46049
 
 
46050
 
CREATE FUNCTION getgainlossaccntid(integer) RETURNS integer
46051
 
    LANGUAGE plpgsql STABLE
46052
 
    AS $_$
46053
 
DECLARE
46054
 
  pAccntId ALIAS FOR $1;
46055
 
  _returnVal INTEGER;
46056
 
BEGIN
46057
 
  IF ( (pAccntId = 0) OR (pAccntId IS NULL) ) THEN
46058
 
        RETURN 0;
46059
 
  END IF;
46060
 
 
46061
 
  IF (fetchMetricValue('GLCompanySize') = 0) THEN
46062
 
    _returnVal := fetchMetricValue('CurrencyGainLossAccount')::integer;
46063
 
  ELSE
46064
 
    SELECT company_gainloss_accnt_id INTO _returnVal
46065
 
    FROM company
46066
 
      JOIN accnt ON (company_number=accnt_company)
46067
 
    WHERE (accnt_id=pAccntId);
46068
 
  END IF;
46069
 
 
46070
 
  IF (_returnVal IS NULL) THEN
46071
 
    RAISE EXCEPTION 'Currency Gain/Loss Account not found for %', formatGlAccountLong(pAccntId);
46072
 
  END IF;
46073
 
 
46074
 
  RETURN _returnVal;
46075
 
END;
46076
 
$_$;
46077
 
 
46078
 
 
46079
 
ALTER FUNCTION public.getgainlossaccntid(integer) OWNER TO admin;
46080
 
 
46081
 
--
46082
 
--
46083
 
 
46084
 
CREATE FUNCTION getglaccntid(text) RETURNS integer
46085
 
    LANGUAGE plpgsql
46086
 
    AS $_$
46087
 
DECLARE
46088
 
  pGlAccnt ALIAS FOR $1;
46089
 
  _returnVal INTEGER;
46090
 
BEGIN
46091
 
  IF (pGlAccnt IS NULL) THEN
46092
 
        RETURN NULL;
46093
 
  END IF;
46094
 
 
46095
 
  SELECT accnt_id INTO _returnVal
46096
 
  FROM accnt
46097
 
  WHERE (formatglaccount(accnt_id)=pGlAccnt);
46098
 
 
46099
 
  IF (_returnVal IS NULL) THEN
46100
 
        RAISE EXCEPTION 'Account Number % not found.', pGlAccnt;
46101
 
  END IF;
46102
 
 
46103
 
  RETURN _returnVal;
46104
 
END;
46105
 
$_$;
46106
 
 
46107
 
 
46108
 
ALTER FUNCTION public.getglaccntid(text) OWNER TO admin;
46109
 
 
46110
 
--
46111
 
--
46112
 
 
46113
 
CREATE FUNCTION getglaccntid(text, text, text, text) RETURNS integer
46114
 
    LANGUAGE plpgsql
46115
 
    AS $_$
46116
 
DECLARE
46117
 
  pCompany ALIAS FOR $1;
46118
 
  pProfit ALIAS FOR $2;
46119
 
  pGlAccnt ALIAS FOR $3;
46120
 
  pSub ALIAS FOR $4;
46121
 
  _account TEXT;
46122
 
  _returnVal INTEGER;
46123
 
BEGIN
46124
 
  IF (pGlAccnt IS NULL) THEN
46125
 
        RETURN NULL;
46126
 
  END IF;
46127
 
 
46128
 
  IF (pCompany is not null) THEN
46129
 
    _account := pCompany || '-';
46130
 
  END IF;
46131
 
 
46132
 
  IF (pProfit is not null) THEN
46133
 
    _account := _account || pProfit || '-';
46134
 
  END IF;
46135
 
  IF (pGlAccnt is not null) THEN
46136
 
    if (_account is null) then
46137
 
        _account := pGlAccnt;
46138
 
    else
46139
 
        _account := _account || pGlAccnt;
46140
 
    end if;
46141
 
  END IF;
46142
 
 
46143
 
  IF (pSub is not null) THEN
46144
 
    _account := _account || '-' || pSub;
46145
 
  END IF;
46146
 
 
46147
 
  SELECT accnt_id INTO _returnVal
46148
 
  FROM accnt
46149
 
  WHERE (formatglaccount(accnt_id)=_account);
46150
 
 
46151
 
  IF (_returnVal IS NULL) THEN
46152
 
        RAISE EXCEPTION 'Account Number % not found.', _account;
46153
 
  END IF;
46154
 
 
46155
 
  RETURN _returnVal;
46156
 
END;
46157
 
$_$;
46158
 
 
46159
 
 
46160
 
ALTER FUNCTION public.getglaccntid(text, text, text, text) OWNER TO admin;
46161
 
 
46162
 
--
46163
 
--
46164
 
 
46165
 
CREATE FUNCTION getimageid(pimagename text) RETURNS integer
46166
 
    LANGUAGE plpgsql STABLE
46167
 
    AS $$
46168
 
DECLARE
46169
 
  _returnVal INTEGER;
46170
 
BEGIN
46171
 
  IF (COALESCE(TRIM(pImageName), '') = '') THEN
46172
 
    RETURN NULL;
46173
 
  END IF;
46174
 
 
46175
 
  SELECT image_id INTO _returnVal
46176
 
  FROM image
46177
 
  WHERE (image_name=pImageName);
46178
 
 
46179
 
  IF (_returnVal IS NULL) THEN
46180
 
    RAISE EXCEPTION 'Image % not found.', pImageName;
46181
 
  END IF;
46182
 
 
46183
 
  RETURN _returnVal;
46184
 
END;
46185
 
$$;
46186
 
 
46187
 
 
46188
 
ALTER FUNCTION public.getimageid(pimagename text) OWNER TO admin;
46189
 
 
46190
 
--
46191
 
--
46192
 
 
46193
 
CREATE FUNCTION getincdtcatid(pincdtcatname text) RETURNS integer
46194
 
    LANGUAGE plpgsql STABLE
46195
 
    AS $$
46196
 
DECLARE
46197
 
  _returnVal INTEGER;
46198
 
BEGIN
46199
 
  IF (pIncdtCatName IS NULL) THEN
46200
 
        RETURN NULL;
46201
 
  END IF;
46202
 
 
46203
 
  SELECT incdtcat_id INTO _returnVal
46204
 
  FROM incdtcat
46205
 
  WHERE (incdtcat_name=pIncdtCatName);
46206
 
 
46207
 
  IF (_returnVal IS NULL) THEN
46208
 
        RAISE EXCEPTION 'Incident Category Name % not found.', pIncdtCatName;
46209
 
  END IF;
46210
 
 
46211
 
  RETURN _returnVal;
46212
 
END;
46213
 
$$;
46214
 
 
46215
 
 
46216
 
ALTER FUNCTION public.getincdtcatid(pincdtcatname text) OWNER TO admin;
46217
 
 
46218
 
--
46219
 
--
46220
 
 
46221
 
CREATE FUNCTION getincdtcrmacctid(pincidentnumber integer) RETURNS integer
46222
 
    LANGUAGE plpgsql STABLE
46223
 
    AS $$
46224
 
DECLARE
46225
 
  _returnVal INTEGER;
46226
 
BEGIN
46227
 
  IF (pIncidentNumber IS NULL) THEN
46228
 
        RETURN NULL;
46229
 
  END IF;
46230
 
 
46231
 
  SELECT incdt_crmacct_id INTO _returnVal
46232
 
  FROM incdt
46233
 
  WHERE (incdt_number=pIncidentNumber);
46234
 
 
46235
 
  IF (_returnVal IS NULL) THEN
46236
 
        RAISE EXCEPTION 'Incident Number % not found.', pIncidentNumber;
46237
 
  END IF;
46238
 
 
46239
 
  RETURN _returnVal;
46240
 
END;
46241
 
$$;
46242
 
 
46243
 
 
46244
 
ALTER FUNCTION public.getincdtcrmacctid(pincidentnumber integer) OWNER TO admin;
46245
 
 
46246
 
--
46247
 
--
46248
 
 
46249
 
CREATE FUNCTION getincdtpriorityid(pincdtpriorityname text) RETURNS integer
46250
 
    LANGUAGE plpgsql STABLE
46251
 
    AS $$
46252
 
DECLARE
46253
 
  _returnVal INTEGER;
46254
 
BEGIN
46255
 
  IF (pIncdtPriorityName IS NULL) THEN
46256
 
        RETURN NULL;
46257
 
  END IF;
46258
 
 
46259
 
  SELECT incdtpriority_id INTO _returnVal
46260
 
  FROM incdtpriority
46261
 
  WHERE (incdtpriority_name=pIncdtPriorityName);
46262
 
 
46263
 
  IF (_returnVal IS NULL) THEN
46264
 
        RAISE EXCEPTION 'Incident Priority Name % not found.', pIncdtPriorityName;
46265
 
  END IF;
46266
 
 
46267
 
  RETURN _returnVal;
46268
 
END;
46269
 
$$;
46270
 
 
46271
 
 
46272
 
ALTER FUNCTION public.getincdtpriorityid(pincdtpriorityname text) OWNER TO admin;
46273
 
 
46274
 
--
46275
 
--
46276
 
 
46277
 
CREATE FUNCTION getincdtresolutionid(pincdtresolutionname text) RETURNS integer
46278
 
    LANGUAGE plpgsql STABLE
46279
 
    AS $$
46280
 
DECLARE
46281
 
  _returnVal INTEGER;
46282
 
BEGIN
46283
 
  IF (pIncdtResolutionName IS NULL) THEN
46284
 
        RETURN NULL;
46285
 
  END IF;
46286
 
 
46287
 
  SELECT incdtresolution_id INTO _returnVal
46288
 
  FROM incdtresolution
46289
 
  WHERE (incdtresolution_name=pIncdtResolutionName);
46290
 
 
46291
 
  IF (_returnVal IS NULL) THEN
46292
 
        RAISE EXCEPTION 'Incident Resolution Name % not found.', pIncdtResolutionName;
46293
 
  END IF;
46294
 
 
46295
 
  RETURN _returnVal;
46296
 
END;
46297
 
$$;
46298
 
 
46299
 
 
46300
 
ALTER FUNCTION public.getincdtresolutionid(pincdtresolutionname text) OWNER TO admin;
46301
 
 
46302
 
--
46303
 
--
46304
 
 
46305
 
CREATE FUNCTION getincdtseverityid(pincdtseverityname text) RETURNS integer
46306
 
    LANGUAGE plpgsql STABLE
46307
 
    AS $$
46308
 
DECLARE
46309
 
  _returnVal INTEGER;
46310
 
BEGIN
46311
 
  IF (pIncdtSeverityName IS NULL) THEN
46312
 
        RETURN NULL;
46313
 
  END IF;
46314
 
 
46315
 
  SELECT incdtseverity_id INTO _returnVal
46316
 
  FROM incdtseverity
46317
 
  WHERE (incdtseverity_name=pIncdtSeverityName);
46318
 
 
46319
 
  IF (_returnVal IS NULL) THEN
46320
 
        RAISE EXCEPTION 'Incident Severity Name % not found.', pIncdtSeverityName;
46321
 
  END IF;
46322
 
 
46323
 
  RETURN _returnVal;
46324
 
END;
46325
 
$$;
46326
 
 
46327
 
 
46328
 
ALTER FUNCTION public.getincdtseverityid(pincdtseverityname text) OWNER TO admin;
46329
 
 
46330
 
--
46331
 
--
46332
 
 
46333
 
CREATE FUNCTION getincidentid(pincidentnumber integer) RETURNS integer
46334
 
    LANGUAGE plpgsql STABLE
46335
 
    AS $$
46336
 
DECLARE
46337
 
  _returnVal INTEGER;
46338
 
BEGIN
46339
 
  IF (pIncidentNumber IS NULL) THEN
46340
 
        RETURN NULL;
46341
 
  END IF;
46342
 
 
46343
 
  SELECT incdt_id INTO _returnVal
46344
 
  FROM incdt
46345
 
  WHERE (incdt_number=pIncidentNumber);
46346
 
 
46347
 
  IF (_returnVal IS NULL) THEN
46348
 
        RAISE EXCEPTION 'Incident Number % not found.', pIncidentNumber;
46349
 
  END IF;
46350
 
 
46351
 
  RETURN _returnVal;
46352
 
END;
46353
 
$$;
46354
 
 
46355
 
 
46356
 
ALTER FUNCTION public.getincidentid(pincidentnumber integer) OWNER TO admin;
46357
 
 
46358
 
--
46359
 
--
46360
 
 
46361
 
CREATE FUNCTION getinvcheadid(text) RETURNS integer
46362
 
    LANGUAGE plpgsql
46363
 
    AS $_$
46364
 
DECLARE
46365
 
  pInvcNumber ALIAS FOR $1;
46366
 
  _returnVal INTEGER;
46367
 
BEGIN
46368
 
  IF (pInvcNumber IS NULL) THEN
46369
 
        RETURN NULL;
46370
 
  END IF;
46371
 
 
46372
 
  SELECT invchead_id INTO _returnVal
46373
 
  FROM invchead
46374
 
  WHERE (UPPER(invchead_invcnumber)=UPPER(pInvcNumber));
46375
 
 
46376
 
  IF (_returnVal IS NULL) THEN
46377
 
        RAISE EXCEPTION 'Invoice % not found.', pInvcNumber;
46378
 
  END IF;
46379
 
 
46380
 
  RETURN _returnVal;
46381
 
END;
46382
 
$_$;
46383
 
 
46384
 
 
46385
 
ALTER FUNCTION public.getinvcheadid(text) OWNER TO admin;
46386
 
 
46387
 
--
46388
 
--
46389
 
 
46390
 
CREATE FUNCTION getinvcitemlotserial(integer) RETURNS text
46391
 
    LANGUAGE plpgsql
46392
 
    AS $_$
46393
 
DECLARE
46394
 
  pInvcitemid ALIAS FOR $1;
46395
 
  _lotserial text;
46396
 
  _r RECORD;
46397
 
  _first BOOLEAN;
46398
 
  _newMethod BOOLEAN;
46399
 
BEGIN
46400
 
 
46401
 
  --Test to see if Lot/Serial Enabled
46402
 
  SELECT metric_value INTO _lotserial
46403
 
  FROM metric
46404
 
  WHERE ((metric_name='LotSerialControl')
46405
 
  AND (metric_value ='t'));
46406
 
 
46407
 
  IF (FOUND) THEN
46408
 
    _lotserial := '';
46409
 
    _first := true;
46410
 
 
46411
 
 
46412
 
    SELECT (COUNT(*) > 0) INTO _newMethod 
46413
 
    FROM shipitem 
46414
 
    WHERE ((shipitem_invcitem_id=pInvcitemid)
46415
 
    AND (shipitem_invhist_id IS NOT NULL));
46416
 
 
46417
 
    IF (_newMethod) THEN
46418
 
 
46419
 
      FOR _r IN SELECT DISTINCT ls_number
46420
 
                FROM invdetail, invhist, shipitem, ls
46421
 
               WHERE ((shipitem_invcitem_id=pInvcitemid)
46422
 
                 AND  (shipitem_invhist_id=invhist_id)
46423
 
                 AND  (invhist_id=invdetail_invhist_id)
46424
 
                 AND  (invdetail_ls_id=ls_id)) LOOP
46425
 
        IF (_first = false) THEN
46426
 
          _lotserial := _lotserial || ', ';
46427
 
        END IF;
46428
 
        _lotserial := _lotserial || _r.ls_number;
46429
 
        _first := false;
46430
 
      END LOOP;
46431
 
 
46432
 
      RETURN _lotserial;
46433
 
    ELSE
46434
 
      -- Handle it old way
46435
 
      FOR _r IN SELECT DISTINCT ls_number
46436
 
                FROM ls, invdetail JOIN invhist ON (invdetail_invhist_id=invhist_id)
46437
 
               WHERE ((invhist_transtype='SH')
46438
 
                 AND  (invdetail_invcitem_id=pInvcitemid)
46439
 
                 AND  (invdetail_ls_id=ls_id)) LOOP
46440
 
        IF (_first = false) THEN
46441
 
          _lotserial := _lotserial || ', ';
46442
 
        END IF;
46443
 
        _lotserial := _lotserial || _r.ls_number;
46444
 
        _first := false;
46445
 
      END LOOP;
46446
 
 
46447
 
      RETURN _lotserial;
46448
 
    END IF;
46449
 
  ELSE
46450
 
    RETURN '';
46451
 
  END IF;
46452
 
  
46453
 
END
46454
 
$_$;
46455
 
 
46456
 
 
46457
 
ALTER FUNCTION public.getinvcitemlotserial(integer) OWNER TO admin;
46458
 
 
46459
 
--
46460
 
--
46461
 
 
46462
 
CREATE FUNCTION getipsheadid(pipsname text) RETURNS integer
46463
 
    LANGUAGE plpgsql
46464
 
    AS $$
46465
 
DECLARE
46466
 
  _returnVal INTEGER;
46467
 
BEGIN
46468
 
  IF (pIpsName IS NULL) THEN
46469
 
        RETURN NULL;
46470
 
  END IF;
46471
 
 
46472
 
  SELECT ipshead_id INTO _returnVal
46473
 
  FROM ipshead
46474
 
  WHERE (ipshead_name=pIpsName);
46475
 
 
46476
 
  IF (_returnVal IS NULL) THEN
46477
 
        RAISE EXCEPTION 'Pricing Schedule % not found.', pIpsName;
46478
 
  END IF;
46479
 
 
46480
 
  RETURN _returnVal;
46481
 
END;
46482
 
$$;
46483
 
 
46484
 
 
46485
 
ALTER FUNCTION public.getipsheadid(pipsname text) OWNER TO admin;
46486
 
 
46487
 
--
46488
 
--
46489
 
 
46490
 
CREATE FUNCTION getipsitemid(pipsname text, pitemnumber text, pqtybreak numeric, pqtyuom text, ppriceuom text) RETURNS integer
46491
 
    LANGUAGE plpgsql
46492
 
    AS $$
46493
 
DECLARE
46494
 
  _returnVal INTEGER;
46495
 
  
46496
 
BEGIN
46497
 
  IF (pIpsName IS NULL AND pItemNumber IS NULL AND pQtyBreak IS NULL AND pQtyUom IS NULL AND pPriceUom IS NULL) THEN
46498
 
        RETURN NULL;
46499
 
  END IF;
46500
 
 
46501
 
  SELECT ipsitem_id INTO _returnVal
46502
 
  FROM ipsiteminfo
46503
 
  WHERE ((ipsitem_ipshead_id=getIpsheadId(pIpsName))
46504
 
  AND (ipsitem_item_id=getItemId(pItemNumber))
46505
 
  AND (ipsitem_qtybreak=pQtyBreak)
46506
 
  AND (ipsitem_qty_uom_id=getUomId(pQtyUom))
46507
 
  AND (ipsitem_price_uom_id=getUomId(pPriceUom)));
46508
 
 
46509
 
  IF (_returnVal IS NULL) THEN
46510
 
        RAISE EXCEPTION 'Pricing Schedule Item for Schedule %, Item %,Qt Break %,Qty UOM %, Price UOM % not found.', 
46511
 
        pIpsName, pItemNumber, pQtyBreak, pQtyUom, pPriceUom;
46512
 
  END IF;
46513
 
 
46514
 
  RETURN _returnVal;
46515
 
END;
46516
 
$$;
46517
 
 
46518
 
 
46519
 
ALTER FUNCTION public.getipsitemid(pipsname text, pitemnumber text, pqtybreak numeric, pqtyuom text, ppriceuom text) OWNER TO admin;
46520
 
 
46521
 
--
46522
 
--
46523
 
 
46524
 
CREATE FUNCTION getipsprodcatid(pipsname text, pprodcat text, pqtybreak numeric) RETURNS integer
46525
 
    LANGUAGE plpgsql
46526
 
    AS $$
46527
 
DECLARE
46528
 
  _returnVal INTEGER;
46529
 
  
46530
 
BEGIN
46531
 
  IF (pIpsName IS NULL AND pProdCat IS NULL AND pQtyBreak IS NULL) THEN
46532
 
        RETURN NULL;
46533
 
  END IF;
46534
 
 
46535
 
  SELECT ipsitem_id INTO _returnVal
46536
 
  FROM ipsiteminfo
46537
 
  WHERE ((ipsitem_ipshead_id=getIpsheadId(pIpsName))
46538
 
  AND (ipsitem_prodcat_id=getProdcatId(pProdCat))
46539
 
  AND (ipsitem_qtybreak=pQtyBreak));
46540
 
 
46541
 
  IF (_returnVal IS NULL) THEN
46542
 
        RAISE EXCEPTION 'Pricing Schedule Product Category for Schedule %, Product Category %,Qt Break % not found.', 
46543
 
        pIpsName, pProdCat, pQtyBreak;
46544
 
  END IF;
46545
 
 
46546
 
  RETURN _returnVal;
46547
 
END;
46548
 
$$;
46549
 
 
46550
 
 
46551
 
ALTER FUNCTION public.getipsprodcatid(pipsname text, pprodcat text, pqtybreak numeric) OWNER TO admin;
46552
 
 
46553
 
--
46554
 
--
46555
 
 
46556
 
CREATE FUNCTION getitemid(text) RETURNS integer
46557
 
    LANGUAGE plpgsql IMMUTABLE
46558
 
    AS $_$
46559
 
DECLARE
46560
 
  pItemNumber ALIAS FOR $1;
46561
 
  _returnVal INTEGER;
46562
 
BEGIN
46563
 
  IF (pItemNumber IS NULL) THEN
46564
 
        RETURN NULL;
46565
 
  END IF;
46566
 
 
46567
 
  SELECT item_id INTO _returnVal
46568
 
  FROM item
46569
 
  WHERE (item_number=UPPER(pItemNumber));
46570
 
 
46571
 
  IF (_returnVal IS NULL) THEN
46572
 
        RAISE EXCEPTION 'Item % not found.', pItemNumber;
46573
 
  END IF;
46574
 
 
46575
 
  RETURN _returnVal;
46576
 
END;
46577
 
$_$;
46578
 
 
46579
 
 
46580
 
ALTER FUNCTION public.getitemid(text) OWNER TO admin;
46581
 
 
46582
 
--
46583
 
--
46584
 
 
46585
 
CREATE FUNCTION getitemidfromupc(text) RETURNS integer
46586
 
    LANGUAGE plpgsql
46587
 
    AS $_$
46588
 
DECLARE
46589
 
  pItemUPC ALIAS FOR $1;
46590
 
  _returnVal INTEGER;
46591
 
BEGIN
46592
 
  IF (pItemUPC IS NULL) THEN
46593
 
        RETURN NULL;
46594
 
  END IF;
46595
 
 
46596
 
  SELECT item_id INTO _returnVal
46597
 
  FROM item
46598
 
  WHERE (item_upccode=UPPER(pItemUPC));
46599
 
 
46600
 
  IF (_returnVal IS NULL) THEN
46601
 
        RAISE EXCEPTION 'Item % not found.', pItemUPC;
46602
 
  END IF;
46603
 
 
46604
 
  RETURN _returnVal;
46605
 
END;
46606
 
$_$;
46607
 
 
46608
 
 
46609
 
ALTER FUNCTION public.getitemidfromupc(text) OWNER TO admin;
46610
 
 
46611
 
--
46612
 
--
46613
 
 
46614
 
CREATE FUNCTION getitemsiteid(text, text) RETURNS integer
46615
 
    LANGUAGE plpgsql
46616
 
    AS $_$
46617
 
DECLARE
46618
 
  pWarehouseCode ALIAS FOR $1;
46619
 
  pItemNumber ALIAS FOR $2;
46620
 
  _returnVal INTEGER;
46621
 
BEGIN
46622
 
  SELECT getItemsiteId(pWarehouseCode,pItemNumber,'ALL') INTO _returnVal;
46623
 
 
46624
 
  RETURN _returnVal;
46625
 
END;
46626
 
$_$;
46627
 
 
46628
 
 
46629
 
ALTER FUNCTION public.getitemsiteid(text, text) OWNER TO admin;
46630
 
 
46631
 
--
46632
 
--
46633
 
 
46634
 
CREATE FUNCTION getitemsiteid(text, text, text) RETURNS integer
46635
 
    LANGUAGE plpgsql
46636
 
    AS $_$
46637
 
DECLARE
46638
 
  pWarehouseCode ALIAS FOR $1;
46639
 
  pItemNumber ALIAS FOR $2;
46640
 
  pType ALIAS FOR $3;
46641
 
  _type TEXT;
46642
 
  _p RECORD;
46643
 
BEGIN
46644
 
  IF ((pWarehouseCode IS NULL) OR (pItemNumber IS NULL)) THEN
46645
 
        RETURN NULL;
46646
 
  END IF;
46647
 
 
46648
 
  IF UPPER(pType) NOT IN ('ALL','ACTIVE','SOLD') THEN
46649
 
    RAISE EXCEPTION 'Invalid Type %. Valid Itemsite types are ALL and SOLD', pType;
46650
 
  END IF;
46651
 
 
46652
 
  SELECT * INTO _p
46653
 
  FROM itemsite, item
46654
 
  WHERE ((itemsite_item_id=item_id)
46655
 
  AND (itemsite_warehous_id=getWarehousId(pWarehouseCode,'ALL'))
46656
 
  AND (item_number=UPPER(pItemNumber)));
46657
 
 
46658
 
  IF NOT (FOUND) THEN
46659
 
    RAISE EXCEPTION 'Item % not found in Warehouse %', pItemNumber, pWarehouseCode;
46660
 
  ELSIF ((UPPER(pType)='ACTIVE') OR (UPPER(pType)='SOLD')) THEN
46661
 
    IF NOT (_p.item_active) THEN
46662
 
      RAISE EXCEPTION 'Item % is inactive.', pItemNumber;
46663
 
    ELSE
46664
 
      IF NOT (_p.itemsite_active) THEN
46665
 
        RAISE EXCEPTION 'Item % is inactive in Warehouse %', pItemNumber, pWarehouseCode;
46666
 
      ELSE
46667
 
        IF ((UPPER(pType)='SOLD') AND NOT _p.item_sold) THEN
46668
 
          RAISE EXCEPTION 'Item % is not sold', pItemNumber;
46669
 
        ELSE
46670
 
          IF ((UPPER(pType)='SOLD') AND NOT _p.itemsite_sold) THEN
46671
 
            RAISE EXCEPTION 'Item % is not sold from Warehouse %', pItemNumber, pWarehouseCode;
46672
 
          END IF;
46673
 
        END IF;
46674
 
      END IF;
46675
 
    END IF;
46676
 
  END IF;
46677
 
 
46678
 
  RETURN _p.itemsite_id;
46679
 
END;
46680
 
$_$;
46681
 
 
46682
 
 
46683
 
ALTER FUNCTION public.getitemsiteid(text, text, text) OWNER TO admin;
46684
 
 
46685
 
--
46686
 
--
46687
 
 
46688
 
CREATE FUNCTION getitemsrcid(text, text) RETURNS integer
46689
 
    LANGUAGE plpgsql
46690
 
    AS $_$
46691
 
DECLARE
46692
 
  pItemNumber ALIAS FOR $1;
46693
 
  pVendNumber ALIAS FOR $2;
46694
 
  _returnVal INTEGER;
46695
 
BEGIN
46696
 
  IF ((pItemNumber IS NULL) OR (pVendNumber IS NULL)) THEN
46697
 
    RETURN NULL;
46698
 
  END IF;
46699
 
 
46700
 
  SELECT itemsrc_id INTO _returnVal
46701
 
  FROM itemsrc
46702
 
  WHERE ((itemsrc_item_id=getItemId(pItemNumber))
46703
 
  AND (itemsrc_vend_id=getVendId(pVendNumber)));
46704
 
 
46705
 
  IF (_returnVal IS NULL) THEN
46706
 
        RAISE EXCEPTION 'Item Source Item % Vendor % not found.', pItemNumber,pVendNumber;
46707
 
  END IF;
46708
 
 
46709
 
  RETURN _returnVal;
46710
 
END;
46711
 
$_$;
46712
 
 
46713
 
 
46714
 
ALTER FUNCTION public.getitemsrcid(text, text) OWNER TO admin;
46715
 
 
46716
 
--
46717
 
--
46718
 
 
46719
 
CREATE FUNCTION getlasttrialbalid(integer, integer) RETURNS integer
46720
 
    LANGUAGE plpgsql STABLE
46721
 
    AS $_$
46722
 
DECLARE
46723
 
  pAccntId ALIAS FOR $1;
46724
 
  pPeriodId ALIAS FOR $2;
46725
 
  _p RECORD;
46726
 
  _accntType TEXT;
46727
 
  _result NUMERIC;
46728
 
 
46729
 
BEGIN
46730
 
 
46731
 
  SELECT period_end,period_yearperiod_id INTO _p
46732
 
  FROM period
46733
 
  WHERE period_id=pPeriodId;
46734
 
 
46735
 
  SELECT accnt_type INTO _accntType
46736
 
  FROM accnt
46737
 
  WHERE accnt_id=pAccntId;
46738
 
 
46739
 
  IF (_accntType IN ('R','E')) THEN
46740
 
        SELECT trialbal_id INTO _result
46741
 
        FROM trialbal
46742
 
        WHERE ((trialbal_accnt_id=pAccntId)
46743
 
        AND (trialbal_period_id=pPeriodId));
46744
 
  ELSE
46745
 
        SELECT trialbal_id INTO _result
46746
 
        FROM (SELECT trialbal_id
46747
 
                FROM trialbal,period
46748
 
                WHERE ((trialbal_accnt_id=pAccntId)
46749
 
                AND (trialbal_period_id=period_id)
46750
 
                AND (period_end <= _p.period_end)
46751
 
                AND (period_yearperiod_id=_p.period_yearperiod_id))
46752
 
                ORDER BY period_end DESC) AS data;
46753
 
  END IF;
46754
 
 
46755
 
  RETURN _result;
46756
 
 
46757
 
END;
46758
 
$_$;
46759
 
 
46760
 
 
46761
 
ALTER FUNCTION public.getlasttrialbalid(integer, integer) OWNER TO admin;
46762
 
 
46763
 
--
46764
 
--
46765
 
 
46766
 
CREATE FUNCTION getlocationid(pwarehouse text, plocation text) RETURNS integer
46767
 
    LANGUAGE plpgsql
46768
 
    AS $$
46769
 
DECLARE
46770
 
  _returnVal INTEGER;
46771
 
BEGIN
46772
 
  IF (pLocation IS NULL) THEN
46773
 
        RETURN NULL;
46774
 
  END IF;
46775
 
 
46776
 
  SELECT location_id INTO _returnVal
46777
 
  FROM location
46778
 
  WHERE ((location_warehous_id=getWarehousId(pWarehouse,'ACTIVE'))
46779
 
    AND  (location_formatname=pLocation))
46780
 
  LIMIT 1;
46781
 
 
46782
 
  IF (_returnVal IS NULL) THEN
46783
 
        RAISE EXCEPTION 'Location % not found in Warehouse %.', pLocation, pWarehouse;
46784
 
  END IF;
46785
 
 
46786
 
  RETURN _returnVal;
46787
 
END;
46788
 
$$;
46789
 
 
46790
 
 
46791
 
ALTER FUNCTION public.getlocationid(pwarehouse text, plocation text) OWNER TO admin;
46792
 
 
46793
 
--
46794
 
--
46795
 
 
46796
 
CREATE FUNCTION getlotserialid(text, text) RETURNS integer
46797
 
    LANGUAGE plpgsql
46798
 
    AS $_$
46799
 
DECLARE
46800
 
  pItemNumber ALIAS FOR $1;
46801
 
  pLotSerialNumber ALIAS FOR $2;
46802
 
  _returnVal INTEGER;
46803
 
BEGIN
46804
 
  IF ((pItemNumber IS NULL) OR (pLotSerialNumber IS NULL) OR (pLotSerialNumber='')) THEN
46805
 
        RETURN NULL;
46806
 
  END IF;
46807
 
 
46808
 
  SELECT ls_id INTO _returnVal
46809
 
  FROM ls
46810
 
  WHERE ((ls_item_id=getItemId(pItemNumber))
46811
 
  AND (UPPER(ls_number)=UPPER(pLotSerialNumber)));
46812
 
 
46813
 
  IF (_returnVal IS NULL) THEN
46814
 
        RAISE EXCEPTION 'LotSerial % not found.', pLotSerialNumber;
46815
 
  END IF;
46816
 
 
46817
 
  RETURN _returnVal;
46818
 
END;
46819
 
$_$;
46820
 
 
46821
 
 
46822
 
ALTER FUNCTION public.getlotserialid(text, text) OWNER TO admin;
46823
 
 
46824
 
--
46825
 
--
46826
 
 
46827
 
CREATE FUNCTION getopenshipment(pordertype text, porderid integer, pwarehousid integer) RETURNS text
46828
 
    LANGUAGE plpgsql STABLE
46829
 
    AS $$
46830
 
DECLARE
46831
 
  _result TEXT := '';
46832
 
 
46833
 
BEGIN
46834
 
 
46835
 
  IF (pOrderType = 'SO') THEN
46836
 
    SELECT shiphead_number INTO _result
46837
 
    FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)
46838
 
                  JOIN coitem ON (coitem_id=shipitem_orderitem_id)
46839
 
                  JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
46840
 
    WHERE (shiphead_order_id=pOrderId)
46841
 
      AND (shiphead_order_type='SO') 
46842
 
      AND (NOT shiphead_shipped)
46843
 
      AND (CASE WHEN (pWarehousId IS NULL) THEN TRUE
46844
 
                ELSE itemsite_warehous_id=pWarehousId END) 
46845
 
    ORDER BY shiphead_number
46846
 
    LIMIT 1; 
46847
 
  ELSEIF (pOrderType = 'TO') THEN
46848
 
    SELECT shiphead_number INTO _result
46849
 
    FROM shiphead JOIN tohead ON (tohead_id=shiphead_order_id)
46850
 
    WHERE (shiphead_order_id=pOrderId)
46851
 
      AND (shiphead_order_type='TO') 
46852
 
      AND (NOT shiphead_shipped)
46853
 
      AND (CASE WHEN (pWarehousId IS NULL) THEN TRUE
46854
 
                ELSE tohead_src_warehous_id=pWarehousId END) 
46855
 
    ORDER BY shiphead_number
46856
 
    LIMIT 1; 
46857
 
  END IF;
46858
 
 
46859
 
  RETURN _result;
46860
 
 
46861
 
END;
46862
 
$$;
46863
 
 
46864
 
 
46865
 
ALTER FUNCTION public.getopenshipment(pordertype text, porderid integer, pwarehousid integer) OWNER TO admin;
46866
 
 
46867
 
--
46868
 
--
46869
 
 
46870
 
CREATE FUNCTION getopenshipmentid(pordertype text, porderid integer, pwarehousid integer) RETURNS integer
46871
 
    LANGUAGE plpgsql STABLE
46872
 
    AS $$
46873
 
DECLARE
46874
 
  _result INTEGER := -1;
46875
 
 
46876
 
BEGIN
46877
 
 
46878
 
  IF (pOrderType = 'SO') THEN
46879
 
    SELECT shiphead_id INTO _result
46880
 
    FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)
46881
 
                  JOIN coitem ON (coitem_id=shipitem_orderitem_id)
46882
 
                  JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
46883
 
    WHERE (shiphead_order_id=pOrderId)
46884
 
      AND (shiphead_order_type='SO') 
46885
 
      AND (NOT shiphead_shipped)
46886
 
      AND (CASE WHEN (pWarehousId IS NULL) THEN TRUE
46887
 
                ELSE itemsite_warehous_id=pWarehousId END) 
46888
 
    ORDER BY shiphead_number
46889
 
    LIMIT 1; 
46890
 
  ELSEIF (pOrderType = 'TO') THEN
46891
 
    SELECT shiphead_id INTO _result
46892
 
    FROM shiphead JOIN tohead ON (tohead_id=shiphead_order_id)
46893
 
    WHERE (shiphead_order_id=pOrderId)
46894
 
      AND (shiphead_order_type='TO') 
46895
 
      AND (NOT shiphead_shipped)
46896
 
      AND (CASE WHEN (pWarehousId IS NULL) THEN TRUE
46897
 
                ELSE tohead_src_warehous_id=pWarehousId END) 
46898
 
    ORDER BY shiphead_number
46899
 
    LIMIT 1; 
46900
 
  END IF;
46901
 
 
46902
 
  RETURN _result;
46903
 
 
46904
 
END;
46905
 
$$;
46906
 
 
46907
 
 
46908
 
ALTER FUNCTION public.getopenshipmentid(pordertype text, porderid integer, pwarehousid integer) OWNER TO admin;
46909
 
 
46910
 
--
46911
 
--
46912
 
 
46913
 
CREATE FUNCTION getopheadid(text) RETURNS integer
46914
 
    LANGUAGE plpgsql
46915
 
    AS $_$
46916
 
DECLARE
46917
 
  pOpHeadName ALIAS FOR $1;
46918
 
  _returnVal INTEGER;
46919
 
BEGIN
46920
 
  
46921
 
  IF (pOpHeadName IS NULL) THEN
46922
 
    RETURN NULL;
46923
 
  END IF;
46924
 
 
46925
 
  SELECT ophead_id INTO _returnVal
46926
 
  FROM ophead
46927
 
  WHERE (UPPER(ophead_name)=UPPER(pOpHeadName));
46928
 
  
46929
 
  IF (_returnVal IS NULL) THEN
46930
 
      RAISE EXCEPTION 'Opportunity % not found.', pOpHeadName;
46931
 
  END IF;
46932
 
 
46933
 
  RETURN _returnVal;
46934
 
END;
46935
 
$_$;
46936
 
 
46937
 
 
46938
 
ALTER FUNCTION public.getopheadid(text) OWNER TO admin;
46939
 
 
46940
 
--
46941
 
--
46942
 
 
46943
 
CREATE FUNCTION getpacklistcharname(integer, integer) RETURNS text
46944
 
    LANGUAGE plpgsql
46945
 
    AS $_$
46946
 
DECLARE
46947
 
  pShipheadId ALIAS FOR $1;
46948
 
  pOrderItemId ALIAS FOR $2;
46949
 
  _charname text;
46950
 
  _r RECORD;
46951
 
  _first BOOLEAN;
46952
 
  
46953
 
BEGIN
46954
 
 
46955
 
  SELECT shiphead_order_type INTO _r
46956
 
  FROM shiphead
46957
 
  WHERE ((shiphead_id=pShipheadId)
46958
 
  AND (shiphead_order_type='TO'));
46959
 
  
46960
 
  IF (FOUND) THEN
46961
 
    RETURN '';
46962
 
  END IF;
46963
 
 
46964
 
  _charname := '';
46965
 
  _first := true;
46966
 
 
46967
 
  FOR _r IN SELECT char_name
46968
 
            FROM char, charass
46969
 
            WHERE ((char_id=charass_char_id)
46970
 
            AND (charass_target_type='SI')
46971
 
            AND (charass_target_id=pOrderItemId)) 
46972
 
  LOOP
46973
 
        IF (_first = false) THEN
46974
 
          _charname := _charname || '
46975
 
';
46976
 
        END IF;
46977
 
        _charname := _charname || _r.char_name;
46978
 
        _first := false;
46979
 
  END LOOP;
46980
 
 
46981
 
  RETURN _charname;
46982
 
  
46983
 
END
46984
 
$_$;
46985
 
 
46986
 
 
46987
 
ALTER FUNCTION public.getpacklistcharname(integer, integer) OWNER TO admin;
46988
 
 
46989
 
--
46990
 
--
46991
 
 
46992
 
CREATE FUNCTION getpacklistcharvalue(integer, integer) RETURNS text
46993
 
    LANGUAGE plpgsql
46994
 
    AS $_$
46995
 
DECLARE
46996
 
  pShipheadId ALIAS FOR $1;
46997
 
  pOrderItemId ALIAS FOR $2;
46998
 
  _charval text;
46999
 
  _r RECORD;
47000
 
  _first BOOLEAN;
47001
 
  
47002
 
BEGIN
47003
 
 
47004
 
  SELECT shiphead_order_type INTO _r
47005
 
  FROM shiphead
47006
 
  WHERE ((shiphead_id=pShipheadId)
47007
 
  AND (shiphead_order_type='TO'));
47008
 
  
47009
 
  IF (FOUND) THEN
47010
 
    RETURN '';
47011
 
  END IF;
47012
 
 
47013
 
  _charval := '';
47014
 
  _first := true;
47015
 
 
47016
 
  FOR _r IN SELECT charass_value
47017
 
            FROM char, charass
47018
 
            WHERE ((char_id=charass_char_id)
47019
 
            AND (charass_target_type='SI')
47020
 
            AND (charass_target_id=pOrderItemId)) 
47021
 
  LOOP
47022
 
        IF (_first = false) THEN
47023
 
          _charval := _charval || '
47024
 
';
47025
 
        END IF;
47026
 
        _charval := _charval || _r.charass_value;
47027
 
        _first := false;
47028
 
  END LOOP;
47029
 
 
47030
 
  RETURN _charval;
47031
 
  
47032
 
END
47033
 
$_$;
47034
 
 
47035
 
 
47036
 
ALTER FUNCTION public.getpacklistcharvalue(integer, integer) OWNER TO admin;
47037
 
 
47038
 
--
47039
 
--
47040
 
 
47041
 
CREATE FUNCTION getpacklistitemlotserial(integer, integer) RETURNS text
47042
 
    LANGUAGE plpgsql
47043
 
    AS $_$
47044
 
DECLARE
47045
 
  pShipheadId ALIAS FOR $1;
47046
 
  pOrderItemId ALIAS FOR $2;
47047
 
  _lotserial text;
47048
 
  _r RECORD;
47049
 
  _first BOOLEAN;
47050
 
  
47051
 
BEGIN
47052
 
 
47053
 
  --Test to see if Lot/Serial Enabled
47054
 
  SELECT metric_value INTO _lotserial
47055
 
  FROM metric
47056
 
  WHERE ((metric_name='LotSerialControl')
47057
 
  AND (metric_value ='t'));
47058
 
 
47059
 
  IF (FOUND) THEN
47060
 
    _lotserial := '';
47061
 
    _first := true;
47062
 
 
47063
 
    FOR _r IN SELECT DISTINCT ls_number
47064
 
              FROM invdetail, invhist, shipitem, ls
47065
 
             WHERE ((shipitem_shiphead_id=pShipheadId)
47066
 
               AND  (shipitem_orderitem_id=pOrderItemId)
47067
 
               AND  (shipitem_invhist_id=invhist_id)
47068
 
               AND  (invhist_id=invdetail_invhist_id)
47069
 
               AND  (invdetail_ls_id=ls_id)) LOOP
47070
 
      IF (_first = false) THEN
47071
 
        _lotserial := _lotserial || ', ';
47072
 
      END IF;
47073
 
      _lotserial := _lotserial || _r.ls_number;
47074
 
      _first := false;
47075
 
    END LOOP;
47076
 
 
47077
 
    RETURN _lotserial;
47078
 
  ELSE
47079
 
    RETURN '';
47080
 
  END IF;
47081
 
  
47082
 
END
47083
 
$_$;
47084
 
 
47085
 
 
47086
 
ALTER FUNCTION public.getpacklistitemlotserial(integer, integer) OWNER TO admin;
47087
 
 
47088
 
--
47089
 
--
47090
 
 
47091
 
CREATE FUNCTION getperiodid(date) RETURNS integer
47092
 
    LANGUAGE plpgsql
47093
 
    AS $_$
47094
 
DECLARE
47095
 
  pPeriodDate ALIAS FOR $1;
47096
 
  _returnVal INTEGER;
47097
 
BEGIN
47098
 
  IF (pPeriodDate IS NULL) THEN
47099
 
        RETURN NULL;
47100
 
  END IF;
47101
 
 
47102
 
  SELECT period_id INTO _returnVal
47103
 
  FROM period
47104
 
  WHERE ((pPeriodDate) between period_start AND period_end);
47105
 
 
47106
 
  IF (_returnVal IS NULL) THEN
47107
 
    RAISE EXCEPTION 'Period for % not found.', pPeriodDate;
47108
 
  END IF;
47109
 
 
47110
 
  RETURN _returnVal;
47111
 
END;
47112
 
$_$;
47113
 
 
47114
 
 
47115
 
ALTER FUNCTION public.getperiodid(date) OWNER TO admin;
47116
 
 
47117
 
--
47118
 
--
47119
 
 
47120
 
CREATE FUNCTION getperiodid(integer, character) RETURNS SETOF integer
47121
 
    LANGUAGE plpgsql IMMUTABLE
47122
 
    AS $_$
47123
 
DECLARE
47124
 
  pPeriodId ALIAS FOR $1;
47125
 
  pInterval ALIAS FOR $2;
47126
 
  _x RECORD;
47127
 
BEGIN
47128
 
 
47129
 
   IF pInterval <> 'M' AND pInterval <> 'Q' AND pInterval <> 'Y' THEN
47130
 
     RAISE EXCEPTION 'Invalid Interval --> %', pInterval;
47131
 
   END IF;
47132
 
 
47133
 
   IF pInterval='M' THEN
47134
 
       RETURN NEXT pPeriodId;
47135
 
     ELSE IF pInterval='Q' THEN
47136
 
        FOR _x IN SELECT qp.period_id AS period_id
47137
 
                FROM period cp, period qp
47138
 
                WHERE ((cp.period_id=pPeriodId)
47139
 
                AND (cp.period_yearperiod_id=qp.period_yearperiod_id)
47140
 
                AND (cp.period_quarter=qp.period_quarter)
47141
 
                AND (cp.period_start>=qp.period_start))
47142
 
        ORDER BY qp.period_start
47143
 
        LOOP
47144
 
                RETURN NEXT _x.period_id;
47145
 
        END LOOP;
47146
 
     ELSE
47147
 
        FOR _x IN SELECT yp.period_id AS period_id
47148
 
                FROM period cp, period yp
47149
 
                WHERE ((cp.period_id=pPeriodId)
47150
 
                AND (cp.period_yearperiod_id=yp.period_yearperiod_id)
47151
 
                AND (cp.period_start>=yp.period_start))
47152
 
        ORDER BY yp.period_start
47153
 
        LOOP
47154
 
                RETURN NEXT _x.period_id;
47155
 
        END LOOP;
47156
 
     END IF;
47157
 
   END IF;
47158
 
  RETURN;
47159
 
END;
47160
 
$_$;
47161
 
 
47162
 
 
47163
 
ALTER FUNCTION public.getperiodid(integer, character) OWNER TO admin;
47164
 
 
47165
 
--
47166
 
--
47167
 
 
47168
 
CREATE FUNCTION getpkgheadid(text) RETURNS integer
47169
 
    LANGUAGE plpgsql
47170
 
    AS $_$
47171
 
DECLARE
47172
 
  ppkgname ALIAS FOR $1;
47173
 
  _returnVal INTEGER;
47174
 
BEGIN
47175
 
  IF (ppkgname IS NULL) THEN
47176
 
    RETURN NULL;
47177
 
  END IF;
47178
 
 
47179
 
  SELECT pkghead_id INTO _returnVal
47180
 
  FROM pkghead
47181
 
  WHERE (UPPER(pkghead_name)=UPPER(ppkgname));
47182
 
 
47183
 
  IF (_returnVal IS NULL) THEN
47184
 
    RAISE EXCEPTION 'Package % not found.', ppkgname;
47185
 
  END IF;
47186
 
 
47187
 
  RETURN _returnVal;
47188
 
END;
47189
 
$_$;
47190
 
 
47191
 
 
47192
 
ALTER FUNCTION public.getpkgheadid(text) OWNER TO admin;
47193
 
 
47194
 
--
47195
 
--
47196
 
 
47197
 
CREATE FUNCTION getplancodeid(text) RETURNS integer
47198
 
    LANGUAGE plpgsql
47199
 
    AS $_$
47200
 
DECLARE
47201
 
  pPlanCode ALIAS FOR $1;
47202
 
  _returnVal INTEGER;
47203
 
BEGIN
47204
 
  IF (pPlanCode IS NULL) THEN
47205
 
        RETURN NULL;
47206
 
  END IF;
47207
 
 
47208
 
  SELECT plancode_id INTO _returnVal
47209
 
  FROM plancode
47210
 
  WHERE (plancode_code=pPlanCode);
47211
 
 
47212
 
  IF (_returnVal IS NULL) THEN
47213
 
        RAISE EXCEPTION 'Plan Code % not found.', pPlanCode;
47214
 
  END IF;
47215
 
 
47216
 
  RETURN _returnVal;
47217
 
END;
47218
 
$_$;
47219
 
 
47220
 
 
47221
 
ALTER FUNCTION public.getplancodeid(text) OWNER TO admin;
47222
 
 
47223
 
--
47224
 
--
47225
 
 
47226
 
CREATE FUNCTION getpoheadid(text) RETURNS integer
47227
 
    LANGUAGE plpgsql
47228
 
    AS $_$
47229
 
DECLARE
47230
 
  pPurchaseOrderNumber ALIAS FOR $1;
47231
 
  _returnVal INTEGER;
47232
 
BEGIN
47233
 
  IF (pPurchaseOrderNumber IS NULL) THEN
47234
 
    RETURN NULL;
47235
 
  END IF;
47236
 
 
47237
 
  SELECT pohead_id INTO _returnVal
47238
 
  FROM pohead
47239
 
  WHERE (pohead_number=pPurchaseOrderNumber);
47240
 
 
47241
 
  IF (_returnVal IS NULL) THEN
47242
 
        RAISE EXCEPTION 'Purchase Order % not found.', pPurchaseOrderNumber;
47243
 
  END IF;
47244
 
 
47245
 
  RETURN _returnVal;
47246
 
END;
47247
 
$_$;
47248
 
 
47249
 
 
47250
 
ALTER FUNCTION public.getpoheadid(text) OWNER TO admin;
47251
 
 
47252
 
--
47253
 
--
47254
 
 
47255
 
CREATE FUNCTION getpoitemid(text, integer) RETURNS integer
47256
 
    LANGUAGE plpgsql
47257
 
    AS $_$
47258
 
DECLARE
47259
 
  pPurchaseOrderNumber  ALIAS FOR $1;
47260
 
  pLineNumber           ALIAS FOR $2;
47261
 
  _returnVal            INTEGER;
47262
 
BEGIN
47263
 
  IF (pPurchaseOrderNumber IS NULL OR pLineNumber IS NULL) THEN
47264
 
    RETURN NULL;
47265
 
  END IF;
47266
 
 
47267
 
  SELECT poitem_id INTO _returnVal
47268
 
  FROM pohead, poitem
47269
 
  WHERE ((pohead_number=pPurchaseOrderNumber)
47270
 
  AND (poitem_pohead_id=pohead_id)
47271
 
  AND (poitem_linenumber=pLineNumber));
47272
 
 
47273
 
  IF (_returnVal IS NULL) THEN
47274
 
        RAISE EXCEPTION 'Purchase Order % not found.', pSalesOrderNumber;
47275
 
  END IF;
47276
 
 
47277
 
  RETURN _returnVal;
47278
 
END;
47279
 
$_$;
47280
 
 
47281
 
 
47282
 
ALTER FUNCTION public.getpoitemid(text, integer) OWNER TO admin;
47283
 
 
47284
 
--
47285
 
--
47286
 
 
47287
 
CREATE FUNCTION getprjaccntid(integer, integer) RETURNS integer
47288
 
    LANGUAGE plpgsql IMMUTABLE
47289
 
    AS $_$
47290
 
DECLARE
47291
 
  pPrjid ALIAS FOR $1;
47292
 
  pAccntid ALIAS FOR $2;
47293
 
  
47294
 
BEGIN
47295
 
  -- Project Accounting is required to fully implement this functionality
47296
 
  RETURN pAccntId;
47297
 
END;
47298
 
$_$;
47299
 
 
47300
 
 
47301
 
ALTER FUNCTION public.getprjaccntid(integer, integer) OWNER TO admin;
47302
 
 
47303
 
--
47304
 
--
47305
 
 
47306
 
CREATE FUNCTION getprjid(pprjnumber text) RETURNS integer
47307
 
    LANGUAGE plpgsql STABLE
47308
 
    AS $$
47309
 
DECLARE
47310
 
  _returnVal INTEGER;
47311
 
BEGIN
47312
 
  IF (pPrjNumber IS NULL) THEN
47313
 
        RETURN NULL;
47314
 
  END IF;
47315
 
 
47316
 
  SELECT prj_id INTO _returnVal
47317
 
  FROM prj
47318
 
  WHERE (prj_number=pPrjNumber);
47319
 
 
47320
 
  IF (_returnVal IS NULL) THEN
47321
 
        RAISE EXCEPTION 'Project Number % not found.', pPrjNumber;
47322
 
  END IF;
47323
 
 
47324
 
  RETURN _returnVal;
47325
 
END;
47326
 
$$;
47327
 
 
47328
 
 
47329
 
ALTER FUNCTION public.getprjid(pprjnumber text) OWNER TO admin;
47330
 
 
47331
 
--
47332
 
--
47333
 
 
47334
 
CREATE FUNCTION getprjtaskid(pprjnumber text, ptasknumber text) RETURNS integer
47335
 
    LANGUAGE plpgsql STABLE
47336
 
    AS $$
47337
 
DECLARE
47338
 
  _returnVal INTEGER;
47339
 
BEGIN
47340
 
  IF (pPrjNumber IS NULL OR pTaskNumber IS NULL) THEN
47341
 
        RETURN NULL;
47342
 
  END IF;
47343
 
 
47344
 
  SELECT prjtask_id INTO _returnVal
47345
 
  FROM prjtask
47346
 
    JOIN prj ON (prj_id=prjtask_prj_id)
47347
 
  WHERE ((prj_number=pPrjNumber)
47348
 
  AND (prjtask_number=pTaskNumber));
47349
 
 
47350
 
  IF (_returnVal IS NULL) THEN
47351
 
        RAISE EXCEPTION 'Project Task Number %-% not found.', pPrjNumber, pTaskNumber;
47352
 
  END IF;
47353
 
 
47354
 
  RETURN _returnVal;
47355
 
END;
47356
 
$$;
47357
 
 
47358
 
 
47359
 
ALTER FUNCTION public.getprjtaskid(pprjnumber text, ptasknumber text) OWNER TO admin;
47360
 
 
47361
 
--
47362
 
--
47363
 
 
47364
 
CREATE FUNCTION getprodcatid(text) RETURNS integer
47365
 
    LANGUAGE plpgsql
47366
 
    AS $_$
47367
 
DECLARE
47368
 
  pProdCat ALIAS FOR $1;
47369
 
  _returnVal INTEGER;
47370
 
BEGIN
47371
 
  IF (pProdCat IS NULL) THEN
47372
 
    RETURN NULL;
47373
 
  END IF;
47374
 
 
47375
 
  SELECT prodcat_id INTO _returnVal
47376
 
  FROM prodcat
47377
 
  WHERE (prodcat_code=pProdCat);
47378
 
 
47379
 
  IF (_returnVal IS NULL) THEN
47380
 
        RAISE EXCEPTION 'Product Category % not found.', pProdCat;
47381
 
  END IF;
47382
 
 
47383
 
  RETURN _returnVal;
47384
 
END;
47385
 
$_$;
47386
 
 
47387
 
 
47388
 
ALTER FUNCTION public.getprodcatid(text) OWNER TO admin;
47389
 
 
47390
 
--
47391
 
--
47392
 
 
47393
 
CREATE FUNCTION getprospectid(text) RETURNS integer
47394
 
    LANGUAGE plpgsql
47395
 
    AS $_$
47396
 
DECLARE
47397
 
  pProspectNumber ALIAS FOR $1;
47398
 
  _returnVal INTEGER;
47399
 
BEGIN
47400
 
  IF (pProspectNumber IS NULL) THEN
47401
 
    RETURN NULL;
47402
 
  END IF;
47403
 
 
47404
 
  SELECT prospect_id INTO _returnVal
47405
 
    FROM prospect
47406
 
   WHERE(UPPER(prospect_number)=UPPER(pProspectNumber));
47407
 
  IF (_returnVal IS NULL) THEN
47408
 
    RAISE EXCEPTION 'Prospect Number % found.', pProspectNumber;
47409
 
  END IF;
47410
 
 
47411
 
  RETURN _returnVal;
47412
 
END;
47413
 
$_$;
47414
 
 
47415
 
 
47416
 
ALTER FUNCTION public.getprospectid(text) OWNER TO admin;
47417
 
 
47418
 
--
47419
 
--
47420
 
 
47421
 
CREATE FUNCTION getquoteid(text) RETURNS integer
47422
 
    LANGUAGE plpgsql
47423
 
    AS $_$
47424
 
DECLARE
47425
 
  pQuoteNumber ALIAS FOR $1;
47426
 
  _returnVal INTEGER;
47427
 
BEGIN
47428
 
  IF (pQuoteNumber IS NULL) THEN
47429
 
    RETURN NULL;
47430
 
  END IF;
47431
 
 
47432
 
  SELECT quhead_id INTO _returnVal
47433
 
  FROM quhead
47434
 
  WHERE (quhead_number=pQuoteNumber);
47435
 
 
47436
 
  IF (_returnVal IS NULL) THEN
47437
 
        RAISE EXCEPTION 'Quote Number % not found.', pQuoteNumber;
47438
 
  END IF;
47439
 
 
47440
 
  RETURN _returnVal;
47441
 
END;
47442
 
$_$;
47443
 
 
47444
 
 
47445
 
ALTER FUNCTION public.getquoteid(text) OWNER TO admin;
47446
 
 
47447
 
--
47448
 
--
47449
 
 
47450
 
CREATE FUNCTION getquotelineitemid(text, integer) RETURNS integer
47451
 
    LANGUAGE plpgsql
47452
 
    AS $_$
47453
 
DECLARE
47454
 
  pQuoteNumber ALIAS FOR $1;
47455
 
  pLineNumber ALIAS FOR $2;
47456
 
  _returnVal INTEGER;
47457
 
BEGIN
47458
 
  IF ((pQuoteNumber IS NULL) OR (pLineNumber IS NULL)) THEN
47459
 
    RETURN NULL;
47460
 
  END IF;
47461
 
 
47462
 
  SELECT quitem_id INTO _returnVal
47463
 
  FROM quhead, quitem
47464
 
  WHERE ((quhead_number=pQuoteNumber)
47465
 
  AND (quhead_id=quitem_quhead_id)
47466
 
  AND (quitem_linenumber=pLineNumber));
47467
 
 
47468
 
  IF (_returnVal IS NULL) THEN
47469
 
        RAISE EXCEPTION 'Quote Line Item %-%not found.', pQuoteNumber,pLineNumber;
47470
 
  END IF;
47471
 
 
47472
 
  RETURN _returnVal;
47473
 
END;
47474
 
$_$;
47475
 
 
47476
 
 
47477
 
ALTER FUNCTION public.getquotelineitemid(text, integer) OWNER TO admin;
47478
 
 
47479
 
--
47480
 
--
47481
 
 
47482
 
CREATE FUNCTION getquotescheddate(integer) RETURNS date
47483
 
    LANGUAGE plpgsql
47484
 
    AS $_$
47485
 
DECLARE
47486
 
  pQuheadid ALIAS FOR $1;
47487
 
  _minscheddate DATE;
47488
 
 
47489
 
BEGIN
47490
 
 
47491
 
  SELECT MIN(quitem_scheddate) INTO _minscheddate
47492
 
  FROM quitem
47493
 
  WHERE (quitem_quhead_id=pQuheadid);
47494
 
 
47495
 
  RETURN _minscheddate;
47496
 
 
47497
 
END;
47498
 
$_$;
47499
 
 
47500
 
 
47501
 
ALTER FUNCTION public.getquotescheddate(integer) OWNER TO admin;
47502
 
 
47503
 
--
47504
 
--
47505
 
 
47506
 
CREATE FUNCTION getrevid(text, text, text) RETURNS integer
47507
 
    LANGUAGE plpgsql
47508
 
    AS $_$
47509
 
DECLARE
47510
 
  pType ALIAS FOR $1;
47511
 
  pItemNumber ALIAS FOR $2;
47512
 
  pRevision ALIAS FOR $3;
47513
 
  _returnVal INTEGER;
47514
 
BEGIN
47515
 
  IF (pItemNumber IS NULL) THEN
47516
 
    RETURN NULL;
47517
 
  END IF;
47518
 
 
47519
 
  IF (NOT fetchMetricBool('RevControl')) THEN
47520
 
    RETURN -1;
47521
 
  ELSIF ( (pRevision IS NULL) OR (LENGTH(pRevision)=0) ) THEN
47522
 
    SELECT getActiveRevId(pType, getItemId(pItemNumber)) INTO _returnVal;
47523
 
  ELSE
47524
 
    IF (pType='BOM') THEN
47525
 
      SELECT rev_id INTO _returnVal
47526
 
      FROM item, bomhead, rev
47527
 
      WHERE ((item_id=bomhead_item_id)
47528
 
      AND (bomhead_rev_id=rev_id)
47529
 
      AND (UPPER(item_number)=UPPER(pItemNumber))
47530
 
      AND (rev_number=pRevision));
47531
 
    ELSIF (pType='BOO') THEN
47532
 
      SELECT rev_id INTO _returnVal
47533
 
      FROM item, xtmfg.boohead, rev
47534
 
      WHERE ((item_id=boohead_item_id)
47535
 
      AND (boohead_rev_id=rev_id)
47536
 
      AND (UPPER(item_number)=UPPER(pItemNumber))
47537
 
      AND (rev_number=pRevision));   
47538
 
    ELSE
47539
 
      RAISE EXCEPTION 'Invalid Revision Type.';
47540
 
    END IF;
47541
 
  END IF;
47542
 
    
47543
 
  IF (_returnVal IS NULL) THEN
47544
 
    RAISE EXCEPTION '% revision % for % not found.', pType, pRevision, pItemNumber;
47545
 
  END IF;
47546
 
 
47547
 
  RETURN _returnVal;
47548
 
END;
47549
 
$_$;
47550
 
 
47551
 
 
47552
 
ALTER FUNCTION public.getrevid(text, text, text) OWNER TO admin;
47553
 
 
47554
 
--
47555
 
--
47556
 
 
47557
 
CREATE FUNCTION getrsnid(text) RETURNS integer
47558
 
    LANGUAGE plpgsql
47559
 
    AS $_$
47560
 
DECLARE
47561
 
  pRsnCode ALIAS FOR $1;
47562
 
  _returnVal INTEGER;
47563
 
BEGIN
47564
 
  IF (pRsnCode IS NULL) THEN
47565
 
    RETURN NULL;
47566
 
  END IF;
47567
 
 
47568
 
  SELECT rsncode_id INTO _returnVal
47569
 
  FROM rsncode
47570
 
  WHERE (rsncode_code=pRsnCode);
47571
 
 
47572
 
  IF (_returnVal IS NULL) THEN
47573
 
        RAISE EXCEPTION 'Reason Code % not found.', pRsnCode;
47574
 
  END IF;
47575
 
 
47576
 
  RETURN _returnVal;
47577
 
END;
47578
 
$_$;
47579
 
 
47580
 
 
47581
 
ALTER FUNCTION public.getrsnid(text) OWNER TO admin;
47582
 
 
47583
 
--
47584
 
--
47585
 
 
47586
 
CREATE FUNCTION getsalescatid(text) RETURNS integer
47587
 
    LANGUAGE plpgsql
47588
 
    AS $_$
47589
 
DECLARE
47590
 
  pSalesCatName ALIAS FOR $1;
47591
 
  _returnVal INTEGER;
47592
 
BEGIN
47593
 
  IF (pSalesCatName IS NULL) THEN
47594
 
    RETURN NULL;
47595
 
  END IF;
47596
 
 
47597
 
  SELECT salescat_id INTO _returnVal
47598
 
  FROM salescat
47599
 
  WHERE (salescat_name=pSalesCatName);
47600
 
 
47601
 
  IF (_returnVal IS NULL) THEN
47602
 
        RAISE EXCEPTION 'Sales Category % not found.', pSalesCatName;
47603
 
  END IF;
47604
 
 
47605
 
  RETURN _returnVal;
47606
 
END;
47607
 
$_$;
47608
 
 
47609
 
 
47610
 
ALTER FUNCTION public.getsalescatid(text) OWNER TO admin;
47611
 
 
47612
 
--
47613
 
--
47614
 
 
47615
 
CREATE FUNCTION getsaleslineitemid(text) RETURNS integer
47616
 
    LANGUAGE plpgsql
47617
 
    AS $_$
47618
 
DECLARE
47619
 
  pSalesOrderItem ALIAS FOR $1;
47620
 
  _delpos INTEGER = 0;
47621
 
  _order TEXT;
47622
 
  _part TEXT;
47623
 
  _ln INTEGER;
47624
 
  _sn INTEGER;
47625
 
BEGIN
47626
 
  IF (pSalesOrderItem IS NULL) THEN
47627
 
    RETURN NULL;
47628
 
  END IF;
47629
 
  _delpos := strpos(pSalesOrderItem, '-');
47630
 
  IF (_delpos > 0) THEN
47631
 
    _order := substr(pSalesOrderItem, 1, (_delpos - 1));
47632
 
    _part := substr(pSalesOrderItem, (_delpos + 1));
47633
 
    _delpos := strpos(_part, '.');
47634
 
    IF (_delpos > 0) THEN
47635
 
      _ln := CAST(substr(_part, 1, (_delpos - 1)) AS INTEGER);
47636
 
      _sn := CAST(substr(_part, (_delpos + 1)) AS INTEGER);
47637
 
    ELSE
47638
 
      _ln := CAST(_part AS INTEGER);
47639
 
      _sn := 0;
47640
 
    END IF;
47641
 
    RETURN getSalesLineItemId( _order, _ln, _sn );
47642
 
  END IF;
47643
 
  RETURN 0;
47644
 
END;
47645
 
$_$;
47646
 
 
47647
 
 
47648
 
ALTER FUNCTION public.getsaleslineitemid(text) OWNER TO admin;
47649
 
 
47650
 
--
47651
 
--
47652
 
 
47653
 
CREATE FUNCTION getsaleslineitemid(text, integer) RETURNS integer
47654
 
    LANGUAGE plpgsql
47655
 
    AS $_$
47656
 
BEGIN
47657
 
  RETURN getSalesLineItemId($1, $2, 0);
47658
 
END
47659
 
$_$;
47660
 
 
47661
 
 
47662
 
ALTER FUNCTION public.getsaleslineitemid(text, integer) OWNER TO admin;
47663
 
 
47664
 
--
47665
 
--
47666
 
 
47667
 
CREATE FUNCTION getsaleslineitemid(text, integer, integer) RETURNS integer
47668
 
    LANGUAGE plpgsql
47669
 
    AS $_$
47670
 
DECLARE
47671
 
  pSalesOrderNumber ALIAS FOR $1;
47672
 
  pLineNumber ALIAS FOR $2;
47673
 
  pSubNumber ALIAS FOR $3;
47674
 
  _returnVal INTEGER;
47675
 
BEGIN
47676
 
  IF ((pSalesOrderNumber IS NULL) OR (pLineNumber IS NULL)) THEN
47677
 
    RETURN NULL;
47678
 
  END IF;
47679
 
 
47680
 
  SELECT coitem_id INTO _returnVal
47681
 
  FROM cohead, coitem
47682
 
  WHERE ((cohead_number=pSalesOrderNumber)
47683
 
  AND (cohead_id=coitem_cohead_id)
47684
 
  AND (coitem_linenumber=pLineNumber)
47685
 
  AND (coitem_subnumber=pSubNumber));
47686
 
 
47687
 
  IF (_returnVal IS NULL) THEN
47688
 
        RAISE EXCEPTION 'Sales Line Item %-%not found.', pSalesOrderNumber,pLineNumber;
47689
 
  END IF;
47690
 
 
47691
 
  RETURN _returnVal;
47692
 
END;
47693
 
$_$;
47694
 
 
47695
 
 
47696
 
ALTER FUNCTION public.getsaleslineitemid(text, integer, integer) OWNER TO admin;
47697
 
 
47698
 
--
47699
 
--
47700
 
 
47701
 
CREATE FUNCTION getsalesorderid(text) RETURNS integer
47702
 
    LANGUAGE plpgsql
47703
 
    AS $_$
47704
 
DECLARE
47705
 
  pSalesOrderNumber ALIAS FOR $1;
47706
 
  _returnVal INTEGER;
47707
 
BEGIN
47708
 
  IF (pSalesOrderNumber IS NULL) THEN
47709
 
    RETURN NULL;
47710
 
  END IF;
47711
 
 
47712
 
  SELECT cohead_id INTO _returnVal
47713
 
  FROM cohead
47714
 
  WHERE (cohead_number=pSalesOrderNumber);
47715
 
 
47716
 
  IF (_returnVal IS NULL) THEN
47717
 
        RAISE EXCEPTION 'Sales Order Number % not found.', pSalesOrderNumber;
47718
 
  END IF;
47719
 
 
47720
 
  RETURN _returnVal;
47721
 
END;
47722
 
$_$;
47723
 
 
47724
 
 
47725
 
ALTER FUNCTION public.getsalesorderid(text) OWNER TO admin;
47726
 
 
47727
 
--
47728
 
--
47729
 
 
47730
 
CREATE FUNCTION getsalesrepid(text) RETURNS integer
47731
 
    LANGUAGE plpgsql
47732
 
    AS $_$
47733
 
DECLARE
47734
 
  pSalesRepNumber ALIAS FOR $1;
47735
 
  _returnVal INTEGER;
47736
 
BEGIN
47737
 
  IF (pSalesRepNumber IS NULL) THEN
47738
 
    RETURN NULL;
47739
 
  END IF;
47740
 
 
47741
 
  SELECT salesrep_id INTO _returnVal
47742
 
  FROM salesrep
47743
 
  WHERE (salesrep_number=pSalesRepNumber);
47744
 
 
47745
 
  IF (_returnVal IS NULL) THEN
47746
 
        RAISE EXCEPTION 'Sales Rep Number % not found.', pSalesRepNumber;
47747
 
  END IF;
47748
 
 
47749
 
  RETURN _returnVal;
47750
 
END;
47751
 
$_$;
47752
 
 
47753
 
 
47754
 
ALTER FUNCTION public.getsalesrepid(text) OWNER TO admin;
47755
 
 
47756
 
--
47757
 
--
47758
 
 
47759
 
CREATE FUNCTION getsaletypeid(psaletype text) RETURNS integer
47760
 
    LANGUAGE plpgsql
47761
 
    AS $$
47762
 
DECLARE
47763
 
  _returnVal INTEGER;
47764
 
BEGIN
47765
 
  IF (pSaleType IS NULL) THEN
47766
 
    RETURN NULL;
47767
 
  END IF;
47768
 
 
47769
 
  SELECT saletype_id INTO _returnVal
47770
 
  FROM saletype
47771
 
  WHERE (saletype_code=UPPER(pSaleType));
47772
 
 
47773
 
  IF (_returnVal IS NULL) THEN
47774
 
    RAISE EXCEPTION 'Sale Type % not found.', pSaleType;
47775
 
  END IF;
47776
 
 
47777
 
  RETURN _returnVal;
47778
 
END;
47779
 
$$;
47780
 
 
47781
 
 
47782
 
ALTER FUNCTION public.getsaletypeid(psaletype text) OWNER TO admin;
47783
 
 
47784
 
--
47785
 
--
47786
 
 
47787
 
CREATE FUNCTION getshiftid(text) RETURNS integer
47788
 
    LANGUAGE plpgsql
47789
 
    AS $_$
47790
 
DECLARE
47791
 
  pShiftNumber ALIAS FOR $1;
47792
 
  _returnVal INTEGER;
47793
 
BEGIN
47794
 
  IF (COALESCE(TRIM(pShiftNumber), '') = '') THEN
47795
 
      RETURN NULL;
47796
 
  END IF;
47797
 
 
47798
 
  SELECT shift_id INTO _returnVal
47799
 
  FROM shift
47800
 
  WHERE (UPPER(shift_number)=UPPER(pShiftNumber));
47801
 
 
47802
 
  IF (_returnVal IS NULL) THEN
47803
 
    RAISE EXCEPTION 'Shift % not found.', pShiftNumber;
47804
 
  END IF;
47805
 
 
47806
 
  RETURN _returnVal;
47807
 
END;
47808
 
$_$;
47809
 
 
47810
 
 
47811
 
ALTER FUNCTION public.getshiftid(text) OWNER TO admin;
47812
 
 
47813
 
--
47814
 
--
47815
 
 
47816
 
CREATE FUNCTION getshipchrgid(text) RETURNS integer
47817
 
    LANGUAGE plpgsql
47818
 
    AS $_$
47819
 
DECLARE
47820
 
  pShipChrgName ALIAS FOR $1;
47821
 
  _returnVal INTEGER;
47822
 
BEGIN
47823
 
  IF (pShipChrgName IS NULL) THEN
47824
 
        RETURN NULL;
47825
 
  END IF;
47826
 
 
47827
 
  SELECT shipchrg_id INTO _returnVal
47828
 
  FROM shipchrg
47829
 
  WHERE (shipchrg_name=pShipChrgName);
47830
 
 
47831
 
  IF (_returnVal IS NULL) THEN
47832
 
        RAISE EXCEPTION 'Ship Charge % not found.', pShipChrgName;
47833
 
  END IF;
47834
 
 
47835
 
  RETURN _returnVal;
47836
 
END;
47837
 
$_$;
47838
 
 
47839
 
 
47840
 
ALTER FUNCTION public.getshipchrgid(text) OWNER TO admin;
47841
 
 
47842
 
--
47843
 
--
47844
 
 
47845
 
CREATE FUNCTION getshipformid(text) RETURNS integer
47846
 
    LANGUAGE plpgsql
47847
 
    AS $_$
47848
 
DECLARE
47849
 
  pShipFormName ALIAS FOR $1;
47850
 
  _returnVal INTEGER;
47851
 
BEGIN
47852
 
  IF (pShipFormName IS NULL) THEN
47853
 
        RETURN NULL;
47854
 
  END IF;
47855
 
 
47856
 
  SELECT shipform_id INTO _returnVal
47857
 
  FROM shipform
47858
 
  WHERE (shipform_name=pShipFormName) LIMIT 1;
47859
 
 
47860
 
  IF (_returnVal IS NULL) THEN
47861
 
        RAISE EXCEPTION 'Ship Form % not found.', pShipFormName;
47862
 
  END IF;
47863
 
 
47864
 
  RETURN _returnVal;
47865
 
END;
47866
 
$_$;
47867
 
 
47868
 
 
47869
 
ALTER FUNCTION public.getshipformid(text) OWNER TO admin;
47870
 
 
47871
 
--
47872
 
--
47873
 
 
47874
 
CREATE FUNCTION getshipheadid(text) RETURNS integer
47875
 
    LANGUAGE plpgsql
47876
 
    AS $_$
47877
 
DECLARE
47878
 
  pShipmentNumber ALIAS FOR $1;
47879
 
  _returnVal INTEGER;
47880
 
BEGIN
47881
 
  IF (pShipmentNumber IS NULL OR pShipmentNumber = '') THEN
47882
 
    RETURN NULL;
47883
 
  END IF;
47884
 
 
47885
 
  SELECT shiphead_id INTO _returnVal
47886
 
  FROM shiphead
47887
 
  WHERE (shiphead_number=pShipmentNumber);
47888
 
 
47889
 
  IF (_returnVal IS NULL) THEN
47890
 
        RAISE EXCEPTION 'Shipment % not found.', pShipmentNumber;
47891
 
  END IF;
47892
 
 
47893
 
  RETURN _returnVal;
47894
 
END;
47895
 
$_$;
47896
 
 
47897
 
 
47898
 
ALTER FUNCTION public.getshipheadid(text) OWNER TO admin;
47899
 
 
47900
 
--
47901
 
--
47902
 
 
47903
 
CREATE FUNCTION getshiptoid(text, text) RETURNS integer
47904
 
    LANGUAGE plpgsql
47905
 
    AS $_$
47906
 
DECLARE
47907
 
  pCustNumber ALIAS FOR $1;
47908
 
  pShiptoNumber ALIAS FOR $2;
47909
 
  _returnVal INTEGER;
47910
 
BEGIN
47911
 
  IF ((pCustNumber IS NULL) OR (pShiptoNumber IS NULL)) THEN
47912
 
        RETURN NULL;
47913
 
  END IF;
47914
 
 
47915
 
  SELECT shipto_id INTO _returnVal
47916
 
  FROM shiptoinfo
47917
 
  WHERE ((shipto_cust_id=getCustId(pCustNumber,true))
47918
 
  AND (UPPER(shipto_num)=UPPER(pShiptoNumber)));
47919
 
 
47920
 
  IF (_returnVal IS NULL) THEN
47921
 
        RAISE EXCEPTION 'Shipto % not found.', pShiptoNumber;
47922
 
  END IF;
47923
 
 
47924
 
  RETURN _returnVal;
47925
 
END;
47926
 
$_$;
47927
 
 
47928
 
 
47929
 
ALTER FUNCTION public.getshiptoid(text, text) OWNER TO admin;
47930
 
 
47931
 
--
47932
 
--
47933
 
 
47934
 
CREATE FUNCTION getshiptonumberfrominfo(text, text, text, text, text, text, text, text, text, text, text, text, text, boolean, boolean) RETURNS text
47935
 
    LANGUAGE plpgsql
47936
 
    AS $_$
47937
 
DECLARE
47938
 
  _custname TEXT := COALESCE(TRIM(UPPER( $1)), '');
47939
 
  _email TEXT    := COALESCE(TRIM(UPPER( $2)), '');
47940
 
  _company TEXT  := COALESCE(TRIM(UPPER( $3)), '');
47941
 
  _first TEXT    := COALESCE(TRIM(UPPER( $4)), '');
47942
 
  _last TEXT     := COALESCE(TRIM(UPPER( $5)), '');
47943
 
  _fullname TEXT := COALESCE(TRIM(UPPER( $6)), '');
47944
 
  _addr1 TEXT    := COALESCE(TRIM(UPPER( $7)), '');
47945
 
  _addr2 TEXT    := COALESCE(TRIM(UPPER( $8)), '');
47946
 
  _addr3 TEXT    := COALESCE(TRIM(UPPER( $9)), '');
47947
 
  _city TEXT     := COALESCE(TRIM(UPPER($10)), '');
47948
 
  _state TEXT    := COALESCE(TRIM(UPPER($11)), '');
47949
 
  _postalcode TEXT := COALESCE(TRIM(UPPER($12)), '');
47950
 
  _country TEXT  := COALESCE(TRIM(UPPER($13)), '');
47951
 
  _generate BOOLEAN := COALESCE($14, FALSE);
47952
 
  _create BOOLEAN := COALESCE($15, FALSE);
47953
 
 
47954
 
  _citytrunc TEXT;
47955
 
  _counter INTEGER;
47956
 
  _custid INTEGER;
47957
 
  _custnumber TEXT;
47958
 
  _candidate TEXT;
47959
 
  _r RECORD;
47960
 
  _statetrunc TEXT;
47961
 
BEGIN
47962
 
  IF (_custname = '') THEN
47963
 
    _custname := getCustNameFromInfo(_email, _company, _first, _last,
47964
 
                     _fullname, FALSE);
47965
 
  END IF;
47966
 
 
47967
 
 
47968
 
  SELECT COUNT(*) INTO _counter
47969
 
  FROM custinfo, shiptoinfo, addr
47970
 
  WHERE ((UPPER(cust_name)=UPPER(_custname))
47971
 
    AND UPPER(shipto_name)=UPPER(_fullname)
47972
 
    AND (cust_id=shipto_cust_id)
47973
 
    AND (shipto_addr_id=addr_id));
47974
 
 
47975
 
  IF (_counter = 1) THEN
47976
 
    SELECT shipto_num INTO _candidate
47977
 
    FROM custinfo, shiptoinfo, addr
47978
 
    WHERE ((UPPER(cust_name)=UPPER(_custname))
47979
 
      AND UPPER(shipto_name)=UPPER(_fullname)
47980
 
      AND (cust_id=shipto_cust_id)
47981
 
      AND (shipto_addr_id=addr_id));
47982
 
 
47983
 
    RETURN _candidate;
47984
 
 
47985
 
  ELSE
47986
 
 
47987
 
    SELECT COUNT(*) INTO _counter
47988
 
    FROM custinfo, shiptoinfo, addr
47989
 
    WHERE ((UPPER(cust_name)=UPPER(_custname))
47990
 
      AND (cust_id=shipto_cust_id)
47991
 
      AND (shipto_addr_id=addr_id));
47992
 
 
47993
 
    IF (_counter = 1) THEN
47994
 
      SELECT shipto_num INTO _candidate
47995
 
      FROM custinfo, shiptoinfo, addr
47996
 
      WHERE ((UPPER(cust_name)=UPPER(_custname))
47997
 
        AND (cust_id=shipto_cust_id)
47998
 
        AND (shipto_addr_id=addr_id));
47999
 
 
48000
 
      RETURN _candidate;
48001
 
 
48002
 
    ELSIF (_counter > 1) THEN
48003
 
      SELECT shipto_num,
48004
 
         CASE WHEN (UPPER(addr_country) = _country) THEN 1 ELSE 0 END +
48005
 
         CASE WHEN (UPPER(addr_postalcode) = _postalcode) THEN 1 ELSE 0 END +
48006
 
         CASE WHEN (UPPER(addr_state) = _state) THEN 1 ELSE 0 END +
48007
 
         CASE WHEN (UPPER(addr_city) = _city) THEN 1 ELSE 0 END +
48008
 
         CASE WHEN (UPPER(addr_line3) = _addr3) THEN 1 ELSE 0 END +
48009
 
         CASE WHEN (UPPER(addr_line2) = _addr2) THEN 1 ELSE 0 END +
48010
 
         CASE WHEN (UPPER(addr_line1) = _addr1) THEN 1 ELSE 0 END
48011
 
         AS maxquotient INTO _candidate, _counter
48012
 
      FROM custinfo, shiptoinfo, addr
48013
 
      WHERE ((UPPER(cust_name)=_custname)
48014
 
        AND (cust_id=shipto_cust_id)
48015
 
        AND (shipto_addr_id=addr_id))
48016
 
      ORDER BY maxquotient desc
48017
 
      LIMIT 1;
48018
 
 
48019
 
      RETURN _candidate;
48020
 
    END IF;
48021
 
  END IF;
48022
 
 
48023
 
  IF (_generate) THEN
48024
 
    SELECT cust_number, cust_id INTO _custnumber, _custid
48025
 
    FROM custinfo
48026
 
    WHERE (UPPER(cust_name)=_custname);
48027
 
 
48028
 
    -- keep the number short
48029
 
    _citytrunc := SUBSTRING(_city FOR 5);
48030
 
    _statetrunc := SUBSTRING(_state FOR 5);
48031
 
 
48032
 
    IF (LENGTH(_citytrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num)
48033
 
              FROM shiptoinfo
48034
 
              WHERE ((shipto_cust_id=_custid)
48035
 
                AND (UPPER(shipto_num)=_citytrunc)) )) THEN
48036
 
      _candidate := _citytrunc;
48037
 
    ELSIF (LENGTH(_last || _citytrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num)
48038
 
              FROM shiptoinfo
48039
 
              WHERE ((shipto_cust_id=_custid)
48040
 
                AND (UPPER(shipto_num)=_last || _citytrunc)) )) THEN
48041
 
      _candidate := _last || _citytrunc;
48042
 
    ELSIF (LENGTH(_statetrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num)
48043
 
           FROM shiptoinfo
48044
 
           WHERE ((shipto_cust_id=_custid)
48045
 
             AND (UPPER(shipto_num)=_statetrunc)) )) THEN
48046
 
      _candidate := _statetrunc;
48047
 
    ELSIF (LENGTH(_last || _statetrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num)
48048
 
           FROM shiptoinfo
48049
 
           WHERE ((shipto_cust_id=_custid)
48050
 
             AND (UPPER(shipto_num)=_last || _statetrunc)) )) THEN
48051
 
      _candidate := _last || _statetrunc;
48052
 
 
48053
 
    ELSIF (LENGTH(_citytrunc || _statetrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num)
48054
 
              FROM shiptoinfo
48055
 
              WHERE ((shipto_cust_id=_custid)
48056
 
                AND (UPPER(shipto_num)=_citytrunc || _statetrunc)) )) THEN
48057
 
      _candidate := _citytrunc || _statetrunc;
48058
 
 
48059
 
    ELSE
48060
 
      SELECT CAST(COALESCE(MAX(CAST(shipto_num AS INTEGER)), 0) + 1 AS TEXT)
48061
 
      INTO _candidate
48062
 
      FROM shiptoinfo
48063
 
      WHERE ((shipto_cust_id=_custid)
48064
 
       AND (shipto_num~'^[0-9]*$'));
48065
 
    END IF;
48066
 
 
48067
 
    IF (_create) THEN
48068
 
      INSERT INTO api.custshipto (
48069
 
    customer_number, shipto_number, name,
48070
 
    address1, address2, address3,
48071
 
    city, state, postal_code, country, address_change,
48072
 
    first, last, email,
48073
 
    edi_profile
48074
 
      ) VALUES (
48075
 
    _custnumber, _candidate, _candidate,
48076
 
    _addr1, _addr2, _addr3,
48077
 
    _city, _state, _postalcode, _country, 'CHANGEONE',
48078
 
    _first, _last, LOWER(_email),
48079
 
    'No EDI'
48080
 
      );
48081
 
    END IF;
48082
 
 
48083
 
    RETURN _candidate;
48084
 
  END IF;
48085
 
 
48086
 
  RETURN '';
48087
 
END;
48088
 
$_$;
48089
 
 
48090
 
 
48091
 
ALTER FUNCTION public.getshiptonumberfrominfo(text, text, text, text, text, text, text, text, text, text, text, text, text, boolean, boolean) OWNER TO admin;
48092
 
 
48093
 
--
48094
 
--
48095
 
 
48096
 
CREATE FUNCTION getshipviaid(text) RETURNS integer
48097
 
    LANGUAGE plpgsql
48098
 
    AS $_$
48099
 
DECLARE
48100
 
  pShipViaCode ALIAS FOR $1;
48101
 
  _returnVal INTEGER;
48102
 
BEGIN
48103
 
  IF (pShipViaCode IS NULL) THEN
48104
 
        RETURN NULL;
48105
 
  END IF;
48106
 
 
48107
 
  SELECT shipvia_id INTO _returnVal
48108
 
  FROM shipvia
48109
 
  WHERE (shipvia_code=pShipViaCode);
48110
 
 
48111
 
  IF (_returnVal IS NULL) THEN
48112
 
        RAISE EXCEPTION 'ShipVia Code % not found.', pShipViaCode;
48113
 
  END IF;
48114
 
 
48115
 
  RETURN _returnVal;
48116
 
END;
48117
 
$_$;
48118
 
 
48119
 
 
48120
 
ALTER FUNCTION public.getshipviaid(text) OWNER TO admin;
48121
 
 
48122
 
--
48123
 
--
48124
 
 
48125
 
CREATE FUNCTION getshipzoneid(pshipzonename text) RETURNS integer
48126
 
    LANGUAGE plpgsql
48127
 
    AS $$
48128
 
DECLARE
48129
 
  _returnVal INTEGER;
48130
 
BEGIN
48131
 
  IF (pShipZoneName IS NULL) THEN
48132
 
    RETURN NULL;
48133
 
  END IF;
48134
 
 
48135
 
  SELECT shipzone_id INTO _returnVal
48136
 
  FROM shipzone
48137
 
  WHERE (shipzone_name=pShipZoneName);
48138
 
 
48139
 
  IF (_returnVal IS NULL) THEN
48140
 
    RAISE EXCEPTION 'Ship Zone % not found.', pShipZoneName;
48141
 
  END IF;
48142
 
 
48143
 
  RETURN _returnVal;
48144
 
END;
48145
 
$$;
48146
 
 
48147
 
 
48148
 
ALTER FUNCTION public.getshipzoneid(pshipzonename text) OWNER TO admin;
48149
 
 
48150
 
--
48151
 
--
48152
 
 
48153
 
CREATE FUNCTION getsitetypeid(text) RETURNS integer
48154
 
    LANGUAGE plpgsql
48155
 
    AS $_$
48156
 
DECLARE
48157
 
  pSiteType ALIAS FOR $1;
48158
 
  _returnVal INTEGER;
48159
 
BEGIN
48160
 
  IF (pSiteType IS NULL) THEN
48161
 
        RETURN NULL;
48162
 
  END IF;
48163
 
 
48164
 
  SELECT sitetype_id INTO _returnVal
48165
 
  FROM sitetype
48166
 
  WHERE (sitetype_name=pSiteType);
48167
 
 
48168
 
  IF (_returnVal IS NULL) THEN
48169
 
        RAISE EXCEPTION 'Site Type % not found.', pSiteType;
48170
 
  END IF;
48171
 
 
48172
 
  RETURN _returnVal;
48173
 
END;
48174
 
$_$;
48175
 
 
48176
 
 
48177
 
ALTER FUNCTION public.getsitetypeid(text) OWNER TO admin;
48178
 
 
48179
 
--
48180
 
--
48181
 
 
48182
 
CREATE FUNCTION getsoitemstatus(pcoitemid integer) RETURNS text
48183
 
    LANGUAGE plpgsql STABLE
48184
 
    AS $$
48185
 
DECLARE
48186
 
  _result TEXT;
48187
 
 
48188
 
BEGIN
48189
 
 
48190
 
  SELECT
48191
 
      (CASE WHEN (coitem_status='O' AND (SELECT cust_creditstatus FROM custinfo WHERE cust_id=cohead_cust_id)='H') THEN 'H'
48192
 
            WHEN (coitem_status='O' AND ((SELECT SUM(invcitem_billed)
48193
 
                                            FROM invchead, invcitem
48194
 
                                           WHERE ((CAST(invchead_ordernumber AS text)=cohead_number)
48195
 
                                             AND  (invcitem_invchead_id=invchead_id)
48196
 
                                             AND  (invcitem_item_id=itemsite_item_id)
48197
 
                                             AND  (invcitem_warehous_id=itemsite_warehous_id)
48198
 
                                             AND  (invcitem_linenumber=coitem_linenumber))) >= coitem_qtyord)) THEN 'I'
48199
 
            WHEN (coitem_status='O' AND ((SELECT SUM(invcitem_billed)
48200
 
                                            FROM invchead, invcitem
48201
 
                                           WHERE ((CAST(invchead_ordernumber AS text)=cohead_number)
48202
 
                                             AND  (invcitem_invchead_id=invchead_id)
48203
 
                                             AND  (invcitem_item_id=itemsite_item_id)
48204
 
                                             AND  (invcitem_warehous_id=itemsite_warehous_id)
48205
 
                                             AND  (invcitem_linenumber=coitem_linenumber))) > 0)) THEN 'P'
48206
 
            WHEN (coitem_status='O' AND (qtyAvailable(itemsite_id) - qtyAllocated(itemsite_id, CURRENT_DATE)
48207
 
                                         + qtyOrdered(itemsite_id, CURRENT_DATE))
48208
 
                                          >= ((coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)) THEN 'R'
48209
 
            ELSE coitem_status END
48210
 
       || CASE WHEN (coitem_firm) THEN 'F' ELSE '' END
48211
 
       ) INTO _result
48212
 
  FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)
48213
 
              JOIN custinfo ON (cust_id=cohead_cust_id)
48214
 
              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
48215
 
  WHERE (coitem_id=pCoitemid);
48216
 
 
48217
 
  RETURN _result;
48218
 
 
48219
 
END;
48220
 
$$;
48221
 
 
48222
 
 
48223
 
ALTER FUNCTION public.getsoitemstatus(pcoitemid integer) OWNER TO admin;
48224
 
 
48225
 
--
48226
 
--
48227
 
 
48228
 
CREATE FUNCTION getsoscheddate(integer) RETURNS date
48229
 
    LANGUAGE plpgsql
48230
 
    AS $_$
48231
 
DECLARE
48232
 
  pCoheadid ALIAS FOR $1;
48233
 
  _minscheddate DATE;
48234
 
 
48235
 
BEGIN
48236
 
 
48237
 
  SELECT MIN(coitem_scheddate) INTO _minscheddate
48238
 
  FROM coitem
48239
 
  WHERE ( (coitem_cohead_id=pCoheadid)
48240
 
    AND   (coitem_status NOT IN ('C', 'X')) );
48241
 
 
48242
 
  RETURN _minscheddate;
48243
 
 
48244
 
END;
48245
 
$_$;
48246
 
 
48247
 
 
48248
 
ALTER FUNCTION public.getsoscheddate(integer) OWNER TO admin;
48249
 
 
48250
 
--
48251
 
--
48252
 
 
48253
 
CREATE FUNCTION getsostatus(integer) RETURNS character
48254
 
    LANGUAGE plpgsql STABLE
48255
 
    AS $_$
48256
 
DECLARE
48257
 
  pCoheadid ALIAS FOR $1;
48258
 
  _result char(1);
48259
 
 
48260
 
BEGIN
48261
 
 
48262
 
  SELECT cohead_status INTO _result
48263
 
  FROM cohead
48264
 
  WHERE (cohead_id=pCoheadid);
48265
 
 
48266
 
  RETURN _result;
48267
 
 
48268
 
END;
48269
 
$_$;
48270
 
 
48271
 
 
48272
 
ALTER FUNCTION public.getsostatus(integer) OWNER TO admin;
48273
 
 
48274
 
--
48275
 
--
48276
 
 
48277
 
CREATE FUNCTION getsubtax(integer, integer) RETURNS SETOF subtax
48278
 
    LANGUAGE plpgsql
48279
 
    AS $_$
48280
 
DECLARE
48281
 
  pTaxCodeId ALIAS FOR $1;
48282
 
  pLevel ALIAS FOR $2;
48283
 
  _row subtax%ROWTYPE;
48284
 
  _x RECORD;
48285
 
  _y RECORD;
48286
 
 
48287
 
BEGIN
48288
 
 
48289
 
  FOR _x IN --Select all tax codes whose calculation basis is pTaxCodeId
48290
 
    SELECT tax_id, tax_code, tax_descrip
48291
 
    FROM tax
48292
 
    WHERE tax_basis_tax_id = pTaxCodeId
48293
 
    
48294
 
    
48295
 
    LOOP
48296
 
    _row.subtax_taxcode_id := _x.tax_id;
48297
 
    _row.subtax_taxcode_code := _x.tax_code;
48298
 
    _row.subtax_taxcode_descrip := _x.tax_descrip;
48299
 
    _row.subtax_taxcode_level := pLevel + 1;
48300
 
 
48301
 
   RETURN NEXT _row;  
48302
 
  
48303
 
    FOR _y IN SELECT * from getSubTax(_x.tax_id, pLevel + 1) --This is the recursive part.
48304
 
    LOOP
48305
 
 
48306
 
      _row.subtax_taxcode_id := _y.subtax_taxcode_id;
48307
 
      _row.subtax_taxcode_code := _y.subtax_taxcode_code ;
48308
 
      _row.subtax_taxcode_descrip := _y.subtax_taxcode_descrip;
48309
 
      _row.subtax_taxcode_level := pLevel + 2;
48310
 
 
48311
 
      RETURN NEXT _row;
48312
 
 
48313
 
    END LOOP;
48314
 
 
48315
 
  END LOOP;
48316
 
 
48317
 
END;
48318
 
$_$;
48319
 
 
48320
 
 
48321
 
ALTER FUNCTION public.getsubtax(integer, integer) OWNER TO admin;
48322
 
 
48323
 
--
48324
 
--
48325
 
 
48326
 
CREATE FUNCTION gettaxauthid(text) RETURNS integer
48327
 
    LANGUAGE plpgsql
48328
 
    AS $_$
48329
 
DECLARE
48330
 
  pTaxAuthCode ALIAS FOR $1;
48331
 
  _returnVal INTEGER;
48332
 
BEGIN
48333
 
  IF (pTaxAuthCode IS NULL) THEN
48334
 
        RETURN NULL;
48335
 
  END IF;
48336
 
 
48337
 
  SELECT taxauth_id INTO _returnVal
48338
 
  FROM taxauth
48339
 
  WHERE (taxauth_code=pTaxAuthCode);
48340
 
 
48341
 
  IF (_returnVal IS NULL) THEN
48342
 
        RAISE EXCEPTION 'Tax Authority % not found.', pTaxAuthCode;
48343
 
  END IF;
48344
 
 
48345
 
  RETURN _returnVal;
48346
 
END;
48347
 
$_$;
48348
 
 
48349
 
 
48350
 
ALTER FUNCTION public.gettaxauthid(text) OWNER TO admin;
48351
 
 
48352
 
--
48353
 
--
48354
 
 
48355
 
CREATE FUNCTION gettaxid(text) RETURNS integer
48356
 
    LANGUAGE plpgsql
48357
 
    AS $_$
48358
 
DECLARE
48359
 
  pTaxCode ALIAS FOR $1;
48360
 
  _returnVal INTEGER;
48361
 
BEGIN
48362
 
  IF (pTaxCode IS NULL) THEN
48363
 
        RETURN NULL;
48364
 
  END IF;
48365
 
 
48366
 
  SELECT tax_id INTO _returnVal
48367
 
  FROM tax
48368
 
  WHERE (tax_code=pTaxCode);
48369
 
 
48370
 
  IF (_returnVal IS NULL) THEN
48371
 
        RAISE EXCEPTION 'Tax Code % not found.', pTaxCode;
48372
 
  END IF;
48373
 
 
48374
 
  RETURN _returnVal;
48375
 
END;
48376
 
$_$;
48377
 
 
48378
 
 
48379
 
ALTER FUNCTION public.gettaxid(text) OWNER TO admin;
48380
 
 
48381
 
--
48382
 
--
48383
 
 
48384
 
CREATE FUNCTION gettaxtypeid(text) RETURNS integer
48385
 
    LANGUAGE plpgsql
48386
 
    AS $_$
48387
 
DECLARE
48388
 
  pTaxType ALIAS FOR $1;
48389
 
  _returnVal INTEGER;
48390
 
BEGIN
48391
 
  IF (pTaxType IS NULL) THEN
48392
 
        RETURN NULL;
48393
 
  END IF;
48394
 
 
48395
 
  SELECT taxtype_id INTO _returnVal
48396
 
  FROM taxtype
48397
 
  WHERE (taxtype_name=pTaxType);
48398
 
 
48399
 
  IF (_returnVal IS NULL) THEN
48400
 
        RAISE EXCEPTION 'Tax Type % not found.', pTaxType;
48401
 
  END IF;
48402
 
 
48403
 
  RETURN _returnVal;
48404
 
END;
48405
 
$_$;
48406
 
 
48407
 
 
48408
 
ALTER FUNCTION public.gettaxtypeid(text) OWNER TO admin;
48409
 
 
48410
 
--
48411
 
--
48412
 
 
48413
 
CREATE FUNCTION gettaxzoneid(text) RETURNS integer
48414
 
    LANGUAGE plpgsql
48415
 
    AS $_$
48416
 
DECLARE
48417
 
  pTaxZone ALIAS FOR $1;
48418
 
  _returnVal INTEGER;
48419
 
BEGIN
48420
 
  IF (pTaxZone IS NULL) THEN
48421
 
        RETURN NULL;
48422
 
  END IF;
48423
 
 
48424
 
  SELECT taxzone_id INTO _returnVal
48425
 
  FROM taxzone
48426
 
  WHERE (taxzone_code=pTaxZone);
48427
 
 
48428
 
  IF (_returnVal IS NULL) THEN
48429
 
        RAISE EXCEPTION 'Tax Zone % not found.', pTaxZone;
48430
 
  END IF;
48431
 
 
48432
 
  RETURN _returnVal;
48433
 
END;
48434
 
$_$;
48435
 
 
48436
 
 
48437
 
ALTER FUNCTION public.gettaxzoneid(text) OWNER TO admin;
48438
 
 
48439
 
--
48440
 
--
48441
 
 
48442
 
CREATE FUNCTION gettermsid(text) RETURNS integer
48443
 
    LANGUAGE plpgsql
48444
 
    AS $_$
48445
 
DECLARE
48446
 
  pTermsCode ALIAS FOR $1;
48447
 
  _returnVal INTEGER;
48448
 
BEGIN
48449
 
  IF (pTermsCode IS NULL) THEN
48450
 
        RETURN NULL;
48451
 
  END IF;
48452
 
 
48453
 
  SELECT terms_id INTO _returnVal
48454
 
  FROM terms
48455
 
  WHERE (terms_code=pTermsCode);
48456
 
 
48457
 
  IF (_returnVal IS NULL) THEN
48458
 
        RAISE EXCEPTION 'Terms Code % not found.', pTermsCode;
48459
 
  END IF;
48460
 
 
48461
 
  RETURN _returnVal;
48462
 
END;
48463
 
$_$;
48464
 
 
48465
 
 
48466
 
ALTER FUNCTION public.gettermsid(text) OWNER TO admin;
48467
 
 
48468
 
--
48469
 
--
48470
 
 
48471
 
CREATE FUNCTION getunassignedaccntid() RETURNS integer
48472
 
    LANGUAGE plpgsql STABLE
48473
 
    AS $$
48474
 
DECLARE
48475
 
  _test INTEGER;
48476
 
  _returnVal INTEGER;
48477
 
BEGIN
48478
 
  SELECT fetchMetricValue('UnassignedAccount') INTO _test;
48479
 
 
48480
 
  IF (_test IS NULL) THEN
48481
 
    RAISE EXCEPTION 'Metric not found for UnassignedAccount';
48482
 
  END IF;
48483
 
 
48484
 
  SELECT accnt_id INTO _returnVal
48485
 
  FROM accnt
48486
 
  WHERE (accnt_id=_test);
48487
 
 
48488
 
  IF (NOT FOUND) THEN
48489
 
    RAISE EXCEPTION 'Metric UnassignedAccount is an invalid G/L Account';
48490
 
  END IF;
48491
 
 
48492
 
  RETURN _returnVal;
48493
 
END;
48494
 
$$;
48495
 
 
48496
 
 
48497
 
ALTER FUNCTION public.getunassignedaccntid() OWNER TO admin;
48498
 
 
48499
 
--
48500
 
--
48501
 
 
48502
 
CREATE FUNCTION getuomid(text) RETURNS integer
48503
 
    LANGUAGE plpgsql
48504
 
    AS $_$
48505
 
DECLARE
48506
 
  pUom ALIAS FOR $1;
48507
 
  _returnVal INTEGER;
48508
 
BEGIN
48509
 
  IF (pUom IS NULL) THEN
48510
 
    RETURN NULL;
48511
 
  END IF;
48512
 
 
48513
 
  SELECT uom_id INTO _returnVal
48514
 
  FROM uom
48515
 
  WHERE (uom_name=pUom);
48516
 
 
48517
 
  IF (_returnVal IS NULL) THEN
48518
 
        RAISE EXCEPTION 'Unit of Measure % not found.', pUom;
48519
 
  END IF;
48520
 
 
48521
 
  RETURN _returnVal;
48522
 
END;
48523
 
$_$;
48524
 
 
48525
 
 
48526
 
ALTER FUNCTION public.getuomid(text) OWNER TO admin;
48527
 
 
48528
 
--
48529
 
--
48530
 
 
48531
 
CREATE FUNCTION getuomtypeid(text) RETURNS integer
48532
 
    LANGUAGE plpgsql
48533
 
    AS $_$
48534
 
DECLARE
48535
 
  pUomType ALIAS FOR $1;
48536
 
  _returnVal INTEGER;
48537
 
BEGIN
48538
 
  IF (pUomType IS NULL) THEN
48539
 
        RETURN NULL;
48540
 
  END IF;
48541
 
 
48542
 
  SELECT uomtype_id INTO _returnVal
48543
 
  FROM uomtype
48544
 
  WHERE (UPPER(uomtype_name)=UPPER(pUomType));
48545
 
 
48546
 
  IF (_returnVal IS NULL) THEN
48547
 
        RAISE EXCEPTION 'Unit of Measuer Type % not found.', pUomType;
48548
 
  END IF;
48549
 
 
48550
 
  RETURN _returnVal;
48551
 
END;
48552
 
$_$;
48553
 
 
48554
 
 
48555
 
ALTER FUNCTION public.getuomtypeid(text) OWNER TO admin;
48556
 
 
48557
 
--
48558
 
--
48559
 
 
48560
 
CREATE FUNCTION getuomtypeid(text[]) RETURNS integer[]
48561
 
    LANGUAGE plpgsql
48562
 
    AS $_$
48563
 
DECLARE
48564
 
  pUomTypes ALIAS FOR $1;
48565
 
  _returnVal INTEGER[];
48566
 
  _val INTEGER;
48567
 
  _i INTEGER;
48568
 
BEGIN
48569
 
  IF (pUomTypes IS NULL) OR (ARRAY_UPPER(pUomTypes,1) = 0) THEN
48570
 
        RETURN NULL;
48571
 
  END IF;
48572
 
 
48573
 
  FOR _i IN 1..ARRAY_UPPER(pUomTypes,1)
48574
 
  LOOP
48575
 
    SELECT uomtype_id INTO _val
48576
 
    FROM uomtype
48577
 
    WHERE (UPPER(uomtype_name)=UPPER(pUomTypes[_i]));
48578
 
 
48579
 
    IF (_val IS NULL) THEN
48580
 
        RAISE EXCEPTION 'Unit of Measure Type % not found.', pUomTypes[_i];
48581
 
    ELSE
48582
 
      _returnVal[_i] := _val;
48583
 
    END IF;
48584
 
  END LOOP;
48585
 
 
48586
 
  RETURN _returnVal;
48587
 
END;
48588
 
$_$;
48589
 
 
48590
 
 
48591
 
ALTER FUNCTION public.getuomtypeid(text[]) OWNER TO admin;
48592
 
 
48593
 
--
48594
 
--
48595
 
 
48596
 
CREATE FUNCTION getusrid(pusr text) RETURNS integer
48597
 
    LANGUAGE plpgsql STABLE
48598
 
    AS $$
48599
 
DECLARE
48600
 
  _returnVal INTEGER;
48601
 
BEGIN
48602
 
  SELECT usr_id INTO _returnVal
48603
 
  FROM usr
48604
 
  WHERE (usr_username=COALESCE(pUsr, getEffectiveXtUser()));
48605
 
 
48606
 
  IF (_returnVal IS NULL) THEN
48607
 
        RAISE EXCEPTION 'User % not found.', pUsr;
48608
 
  END IF;
48609
 
 
48610
 
  RETURN _returnVal;
48611
 
END;
48612
 
$$;
48613
 
 
48614
 
 
48615
 
ALTER FUNCTION public.getusrid(pusr text) OWNER TO admin;
48616
 
 
48617
 
--
48618
 
--
48619
 
 
48620
 
CREATE FUNCTION getusrlocaleid() RETURNS integer
48621
 
    LANGUAGE plpgsql IMMUTABLE
48622
 
    AS $$
48623
 
DECLARE
48624
 
  _returnVal INTEGER;
48625
 
BEGIN
48626
 
  SELECT CAST(usrpref_value AS INTEGER)
48627
 
  FROM usrpref
48628
 
  WHERE (usrpref_username=getEffectiveXTUser())
48629
 
    AND (usrpref_name='locale_id') INTO _returnVal;
48630
 
 
48631
 
  IF (_returnVal IS NULL) THEN
48632
 
    SELECT locale_id
48633
 
    FROM locale
48634
 
    WHERE (LOWER(locale_code) = 'default')
48635
 
    LIMIT 1 INTO _returnVal;
48636
 
  END IF;
48637
 
 
48638
 
  IF (_returnVal IS NULL) THEN
48639
 
    SELECT locale_id
48640
 
    FROM locale
48641
 
    ORDER BY locale_id
48642
 
    LIMIT 1 INTO _returnVal;
48643
 
  END IF;
48644
 
 
48645
 
  IF (_returnVal IS NULL) THEN
48646
 
        RAISE EXCEPTION 'User Locale not found.';
48647
 
  END IF;
48648
 
 
48649
 
  RETURN _returnVal;
48650
 
END;
48651
 
$$;
48652
 
 
48653
 
 
48654
 
ALTER FUNCTION public.getusrlocaleid() OWNER TO admin;
48655
 
 
48656
 
--
48657
 
--
48658
 
 
48659
 
CREATE FUNCTION getvendaddrid(text, text) RETURNS integer
48660
 
    LANGUAGE plpgsql
48661
 
    AS $_$
48662
 
DECLARE
48663
 
  pVendNumber   ALIAS FOR $1;
48664
 
  pVendAddrCode ALIAS FOR $2;
48665
 
  _returnVal INTEGER;
48666
 
BEGIN
48667
 
  IF ( (pVendNumber IS NULL) OR (pVendAddrCode IS NULL) ) THEN
48668
 
    RETURN NULL;
48669
 
  END IF;
48670
 
 
48671
 
  SELECT vendaddr_id INTO _returnVal
48672
 
    FROM vendaddrinfo
48673
 
    JOIN vendinfo ON (vend_id=vendaddr_vend_id)
48674
 
  WHERE ( (vendaddr_code=pVendAddrCode)
48675
 
    AND   (vend_number=pVendNumber) );
48676
 
 
48677
 
  IF (_returnVal IS NULL) THEN
48678
 
    RAISE EXCEPTION 'Vendor Number % Address % not found.',
48679
 
    pVendNumber, pVendAddrCode;
48680
 
  END IF;
48681
 
 
48682
 
  RETURN _returnVal;
48683
 
END;
48684
 
$_$;
48685
 
 
48686
 
 
48687
 
ALTER FUNCTION public.getvendaddrid(text, text) OWNER TO admin;
48688
 
 
48689
 
--
48690
 
--
48691
 
 
48692
 
CREATE FUNCTION getvendid(text) RETURNS integer
48693
 
    LANGUAGE plpgsql
48694
 
    AS $_$
48695
 
DECLARE
48696
 
  pVendNumber ALIAS FOR $1;
48697
 
  _returnVal INTEGER;
48698
 
BEGIN
48699
 
  IF (pVendNumber IS NULL) THEN
48700
 
    RETURN NULL;
48701
 
  END IF;
48702
 
 
48703
 
  SELECT vend_id INTO _returnVal
48704
 
    FROM vendinfo
48705
 
   WHERE (vend_number=pVendNumber);
48706
 
 
48707
 
  IF (_returnVal IS NULL) THEN
48708
 
    RAISE EXCEPTION 'Vendor Number % not found.', pVendNumber;
48709
 
  END IF;
48710
 
 
48711
 
  RETURN _returnVal;
48712
 
END;
48713
 
$_$;
48714
 
 
48715
 
 
48716
 
ALTER FUNCTION public.getvendid(text) OWNER TO admin;
48717
 
 
48718
 
--
48719
 
--
48720
 
 
48721
 
CREATE FUNCTION getvendtypeid(text) RETURNS integer
48722
 
    LANGUAGE plpgsql
48723
 
    AS $_$
48724
 
DECLARE
48725
 
  pVendTypeCode ALIAS FOR $1;
48726
 
  _returnVal INTEGER;
48727
 
BEGIN
48728
 
  IF (pVendTypeCode IS NULL) THEN
48729
 
    RETURN NULL;
48730
 
  END IF;
48731
 
 
48732
 
  SELECT vendtype_id INTO _returnVal
48733
 
  FROM vendtype
48734
 
  WHERE (UPPER(vendtype_code)=UPPER(pVendTypeCode));
48735
 
 
48736
 
  IF (_returnVal IS NULL) THEN
48737
 
        RAISE EXCEPTION 'Vendor Type % not found.', pVendTypeCode;
48738
 
  END IF;
48739
 
 
48740
 
  RETURN _returnVal;
48741
 
END;
48742
 
$_$;
48743
 
 
48744
 
 
48745
 
ALTER FUNCTION public.getvendtypeid(text) OWNER TO admin;
48746
 
 
48747
 
--
48748
 
--
48749
 
 
48750
 
CREATE FUNCTION getwarehousid(pwarehouscode text, ptype text) RETURNS integer
48751
 
    LANGUAGE plpgsql STABLE
48752
 
    AS $$
48753
 
DECLARE
48754
 
  _active BOOL;
48755
 
  _shipping BOOL;
48756
 
  _returnVal INTEGER;
48757
 
BEGIN
48758
 
  IF (pWarehousCode IS NULL) THEN
48759
 
        RETURN NULL;
48760
 
  END IF;
48761
 
 
48762
 
  IF (UPPER(pType) NOT IN ('ALL','ACTIVE','SHIPPING')) THEN
48763
 
        RAISE EXCEPTION 'Warehouse lookip type % not valid. Valid types are ALL, ACTIVE and SHIPPING', pType;
48764
 
  END IF;
48765
 
 
48766
 
  SELECT warehous_id, warehous_active, warehous_shipping INTO _returnVal, _active, _shipping
48767
 
  FROM site()
48768
 
  WHERE (warehous_code=UPPER(pWarehousCode));
48769
 
 
48770
 
  IF (_returnVal IS NULL) THEN
48771
 
    RAISE EXCEPTION 'Warehouse Code % not found.', pWarehousCode;
48772
 
    ELSE IF ((pType='SHIPPING') AND (_shipping=false)) THEN
48773
 
      RAISE EXCEPTION 'Warehouse Code % is not a vaild shipping warehouse.', pWarehousCode;
48774
 
      ELSE IF ((pType IN ('SHIPPING','ACTIVE')) AND (_active=false)) THEN
48775
 
        RAISE EXCEPTION 'Warehouse Code % is inactive.', pWarehousCode;
48776
 
      END IF;
48777
 
    END IF;
48778
 
  END IF;
48779
 
 
48780
 
  RETURN _returnVal;
48781
 
END;
48782
 
$$;
48783
 
 
48784
 
 
48785
 
ALTER FUNCTION public.getwarehousid(pwarehouscode text, ptype text) OWNER TO admin;
48786
 
 
48787
 
--
48788
 
--
48789
 
 
48790
 
CREATE FUNCTION getwhsezoneid(text, text) RETURNS integer
48791
 
    LANGUAGE plpgsql
48792
 
    AS $_$
48793
 
DECLARE
48794
 
  pWhseCode ALIAS FOR $1;
48795
 
  pWhseZoneName ALIAS FOR $2;
48796
 
  _returnVal INTEGER;
48797
 
BEGIN
48798
 
  IF ((pWhseCode IS NULL) OR (pWhseZoneName IS NULL)) THEN
48799
 
        RETURN NULL;
48800
 
  END IF;
48801
 
 
48802
 
  SELECT whsezone_id INTO _returnVal
48803
 
  FROM whsezone
48804
 
  WHERE ( (whsezone_warehous_id=getWarehousId(pWhseCode, 'ACTIVE'))
48805
 
      AND (UPPER(whsezone_name)=UPPER(pWhseZoneName)) );
48806
 
 
48807
 
  IF (_returnVal IS NULL) THEN
48808
 
        RAISE EXCEPTION 'Whsezone % not found.', pWhseZoneName;
48809
 
  END IF;
48810
 
 
48811
 
  RETURN _returnVal;
48812
 
END;
48813
 
$_$;
48814
 
 
48815
 
 
48816
 
ALTER FUNCTION public.getwhsezoneid(text, text) OWNER TO admin;
48817
 
 
48818
 
--
48819
 
--
48820
 
 
48821
 
CREATE FUNCTION grantallmodulecmnttypesource(integer, text) RETURNS integer
48822
 
    LANGUAGE plpgsql
48823
 
    AS $_$
48824
 
DECLARE
48825
 
  pCmnttypeid ALIAS FOR $1;
48826
 
  pModuleName ALIAS FOR $2;
48827
 
  _source RECORD;
48828
 
  _sourceCounter INTEGER;
48829
 
 
48830
 
BEGIN
48831
 
 
48832
 
  _sourceCounter := 0;
48833
 
 
48834
 
  FOR _source IN SELECT source_id
48835
 
                 FROM source 
48836
 
                 WHERE (source_module=pModuleName) LOOP
48837
 
 
48838
 
    IF (SELECT grantCmnttypeSource(pCmnttypeid, _source.source_id)) THEN
48839
 
      _sourceCounter := _sourceCounter + 1;
48840
 
    END IF;
48841
 
 
48842
 
  END LOOP;
48843
 
 
48844
 
  RETURN _sourceCounter;
48845
 
 
48846
 
END;
48847
 
$_$;
48848
 
 
48849
 
 
48850
 
ALTER FUNCTION public.grantallmodulecmnttypesource(integer, text) OWNER TO admin;
48851
 
 
48852
 
--
48853
 
--
48854
 
 
48855
 
CREATE FUNCTION grantallmodulepriv(text, text) RETURNS integer
48856
 
    LANGUAGE plpgsql
48857
 
    AS $_$
48858
 
DECLARE
48859
 
  pUsername ALIAS FOR $1;
48860
 
  pModuleName ALIAS FOR $2;
48861
 
  _priv RECORD;
48862
 
  _privCounter INTEGER;
48863
 
 
48864
 
BEGIN
48865
 
 
48866
 
  _privCounter := 0;
48867
 
 
48868
 
  FOR _priv IN SELECT priv_id
48869
 
               FROM priv 
48870
 
               WHERE (priv_module=pModuleName) LOOP
48871
 
 
48872
 
    IF (SELECT grantPriv(pUsername, _priv.priv_id)) THEN
48873
 
      _privCounter := _privCounter + 1;
48874
 
    END IF;
48875
 
 
48876
 
  END LOOP;
48877
 
 
48878
 
  RETURN _privCounter;
48879
 
 
48880
 
END;
48881
 
$_$;
48882
 
 
48883
 
 
48884
 
ALTER FUNCTION public.grantallmodulepriv(text, text) OWNER TO admin;
48885
 
 
48886
 
--
48887
 
--
48888
 
 
48889
 
CREATE FUNCTION grantallmoduleprivgroup(integer, text) RETURNS integer
48890
 
    LANGUAGE plpgsql
48891
 
    AS $_$
48892
 
DECLARE
48893
 
  pGrpid ALIAS FOR $1;
48894
 
  pModuleName ALIAS FOR $2;
48895
 
  _priv RECORD;
48896
 
  _privCounter INTEGER;
48897
 
 
48898
 
BEGIN
48899
 
 
48900
 
  _privCounter := 0;
48901
 
 
48902
 
  FOR _priv IN SELECT priv_id
48903
 
               FROM priv 
48904
 
               WHERE (priv_module=pModuleName) LOOP
48905
 
 
48906
 
    IF (SELECT grantPrivGroup(pGrpid, _priv.priv_id)) THEN
48907
 
      _privCounter := _privCounter + 1;
48908
 
    END IF;
48909
 
 
48910
 
  END LOOP;
48911
 
 
48912
 
  RETURN _privCounter;
48913
 
 
48914
 
END;
48915
 
$_$;
48916
 
 
48917
 
 
48918
 
ALTER FUNCTION public.grantallmoduleprivgroup(integer, text) OWNER TO admin;
48919
 
 
48920
 
--
48921
 
--
48922
 
 
48923
 
CREATE FUNCTION grantcmnttypesource(integer, integer) RETURNS boolean
48924
 
    LANGUAGE plpgsql
48925
 
    AS $_$
48926
 
DECLARE
48927
 
  pCmnttypeid ALIAS FOR $1;
48928
 
  pSourceid ALIAS FOR $2;
48929
 
  _test INTEGER;
48930
 
 
48931
 
BEGIN
48932
 
 
48933
 
  SELECT cmnttypesource_id INTO _test
48934
 
  FROM cmnttypesource
48935
 
  WHERE ( (cmnttypesource_cmnttype_id=pCmnttypeid)
48936
 
    AND (cmnttypesource_source_id=pSourceid) );
48937
 
 
48938
 
  IF (FOUND) THEN
48939
 
    RETURN FALSE;
48940
 
  END IF;
48941
 
 
48942
 
  INSERT INTO cmnttypesource
48943
 
  ( cmnttypesource_cmnttype_id, cmnttypesource_source_id )
48944
 
  VALUES
48945
 
  ( pCmnttypeid, pSourceid );
48946
 
 
48947
 
  RETURN TRUE;
48948
 
 
48949
 
END;
48950
 
$_$;
48951
 
 
48952
 
 
48953
 
ALTER FUNCTION public.grantcmnttypesource(integer, integer) OWNER TO admin;
48954
 
 
48955
 
--
48956
 
--
48957
 
 
48958
 
CREATE FUNCTION grantgroup(text, integer) RETURNS boolean
48959
 
    LANGUAGE plpgsql
48960
 
    AS $_$
48961
 
DECLARE
48962
 
  pUsername ALIAS FOR $1;
48963
 
  pGrpid ALIAS FOR $2;
48964
 
  _test INTEGER;
48965
 
 
48966
 
BEGIN
48967
 
 
48968
 
  SELECT usrgrp_id INTO _test
48969
 
  FROM usrgrp
48970
 
  WHERE ( (usrgrp_username=pUsername)
48971
 
   AND (usrgrp_grp_id=pGrpid) );
48972
 
 
48973
 
  IF (FOUND) THEN
48974
 
    RETURN FALSE;
48975
 
  END IF;
48976
 
 
48977
 
  INSERT INTO usrgrp
48978
 
  ( usrgrp_username, usrgrp_grp_id )
48979
 
  VALUES
48980
 
  ( pUsername, pGrpid );
48981
 
 
48982
 
  RETURN TRUE;
48983
 
 
48984
 
END;
48985
 
$_$;
48986
 
 
48987
 
 
48988
 
ALTER FUNCTION public.grantgroup(text, integer) OWNER TO admin;
48989
 
 
48990
 
--
48991
 
--
48992
 
 
48993
 
CREATE FUNCTION grantpriv(text, integer) RETURNS boolean
48994
 
    LANGUAGE plpgsql
48995
 
    AS $_$
48996
 
DECLARE
48997
 
  pUsername ALIAS FOR $1;
48998
 
  pPrivid ALIAS FOR $2;
48999
 
  _test INTEGER;
49000
 
 
49001
 
BEGIN
49002
 
 
49003
 
  SELECT usrpriv_id INTO _test
49004
 
  FROM usrpriv
49005
 
  WHERE ( (usrpriv_username=pUsername)
49006
 
   AND (usrpriv_priv_id=pPrivid) );
49007
 
 
49008
 
  IF (FOUND) THEN
49009
 
    RETURN FALSE;
49010
 
  END IF;
49011
 
 
49012
 
  INSERT INTO usrpriv
49013
 
  ( usrpriv_username, usrpriv_priv_id )
49014
 
  VALUES
49015
 
  ( pUsername, pPrivid );
49016
 
 
49017
 
  NOTIFY "usrprivUpdated";
49018
 
 
49019
 
  RETURN TRUE;
49020
 
 
49021
 
END;
49022
 
$_$;
49023
 
 
49024
 
 
49025
 
ALTER FUNCTION public.grantpriv(text, integer) OWNER TO admin;
49026
 
 
49027
 
--
49028
 
--
49029
 
 
49030
 
CREATE FUNCTION grantpriv(text, text) RETURNS boolean
49031
 
    LANGUAGE plpgsql
49032
 
    AS $_$
49033
 
DECLARE
49034
 
  pUsername ALIAS FOR $1;
49035
 
  pPrivname ALIAS FOR $2;
49036
 
  _test INTEGER;
49037
 
 
49038
 
BEGIN
49039
 
 
49040
 
  SELECT usrpriv_id INTO _test
49041
 
    FROM usrpriv
49042
 
    JOIN priv ON (usrpriv_priv_id=priv_id)
49043
 
  WHERE ((usrpriv_username=pUsername)
49044
 
     AND (priv_name=pPrivname) );
49045
 
 
49046
 
  IF (FOUND) THEN
49047
 
    RETURN FALSE;
49048
 
  END IF;
49049
 
 
49050
 
  INSERT INTO usrpriv
49051
 
  ( usrpriv_username, usrpriv_priv_id )
49052
 
  SELECT pUsername, priv_id
49053
 
    FROM priv
49054
 
   WHERE (priv_name=pPrivname);
49055
 
 
49056
 
  NOTIFY "usrprivUpdated";
49057
 
 
49058
 
  RETURN TRUE;
49059
 
 
49060
 
END;
49061
 
$_$;
49062
 
 
49063
 
 
49064
 
ALTER FUNCTION public.grantpriv(text, text) OWNER TO admin;
49065
 
 
49066
 
--
49067
 
--
49068
 
 
49069
 
CREATE FUNCTION grantprivgroup(integer, integer) RETURNS boolean
49070
 
    LANGUAGE plpgsql
49071
 
    AS $_$
49072
 
DECLARE
49073
 
  pGrpid ALIAS FOR $1;
49074
 
  pPrivid ALIAS FOR $2;
49075
 
  _test INTEGER;
49076
 
 
49077
 
BEGIN
49078
 
 
49079
 
  SELECT grppriv_id INTO _test
49080
 
  FROM grppriv
49081
 
  WHERE ( (grppriv_grp_id=pGrpid)
49082
 
   AND (grppriv_priv_id=pPrivid) );
49083
 
 
49084
 
  IF (FOUND) THEN
49085
 
    RETURN FALSE;
49086
 
  END IF;
49087
 
 
49088
 
  INSERT INTO grppriv
49089
 
  ( grppriv_grp_id, grppriv_priv_id )
49090
 
  VALUES
49091
 
  ( pGrpid, pPrivid );
49092
 
 
49093
 
  RETURN TRUE;
49094
 
 
49095
 
END;
49096
 
$_$;
49097
 
 
49098
 
 
49099
 
ALTER FUNCTION public.grantprivgroup(integer, integer) OWNER TO admin;
49100
 
 
49101
 
--
49102
 
--
49103
 
 
49104
 
CREATE FUNCTION hasalarms() RETURNS boolean
49105
 
    LANGUAGE plpgsql
49106
 
    AS $$
49107
 
DECLARE
49108
 
  _alarm          RECORD;
49109
 
  _batchId        INTEGER;
49110
 
  _evntlogordtype TEXT;
49111
 
  _evnttypeid     INTEGER;
49112
 
  _evnttypename   TEXT;
49113
 
  _fromEmail      TEXT;
49114
 
  _itemid         INTEGER;
49115
 
  _longsource     TEXT;
49116
 
  _msgId          INTEGER;
49117
 
  _recipient      TEXT;
49118
 
  _recipientPart  INTEGER;
49119
 
  _returnVal      BOOLEAN := FALSE;
49120
 
  _summary        TEXT;
49121
 
  _whsId          INTEGER := -1;
49122
 
 
49123
 
BEGIN
49124
 
  FOR _alarm IN SELECT *
49125
 
                FROM alarm
49126
 
                WHERE ((alarm_creator=getEffectiveXtUser())
49127
 
                   AND (CURRENT_TIMESTAMP > alarm_trigger)) LOOP
49128
 
    _returnVal := TRUE;
49129
 
 
49130
 
    IF (_alarm.alarm_source = 'TODO') THEN
49131
 
      SELECT (todoitem_name || '-' || todoitem_description),
49132
 
             'T', 'TodoAlarm', 'To-Do Item'
49133
 
      INTO _summary, _evntlogordtype, _evnttypename, _longsource
49134
 
      FROM todoitem
49135
 
      WHERE (todoitem_id = _alarm.alarm_source_id);
49136
 
 
49137
 
    ELSIF (_alarm.alarm_source = 'INCDT') THEN
49138
 
      SELECT (incdt_number || '-' || incdt_summary),
49139
 
             'I', 'IncidentAlarm', 'Incident'
49140
 
      INTO _summary, _evntlogordtype, _evnttypename, _longsource
49141
 
      FROM incdt
49142
 
      WHERE (incdt_id = _alarm.alarm_source_id);
49143
 
 
49144
 
    ELSIF (_alarm.alarm_source = 'J') THEN
49145
 
      SELECT (prj_number || ' ' || prj_name || '-' || prjtask_name),
49146
 
              'J', 'TaskAlarm', 'Project Task'
49147
 
      INTO _summary, _evntlogordtype, _evnttypename, _longsource
49148
 
      FROM prjtask JOIN prj ON (prj_id=prjtask_prj_id)
49149
 
      WHERE (prjtask_id = _alarm.alarm_source_id);
49150
 
 
49151
 
    ELSE
49152
 
      CONTINUE; -- there's nothing to do for this iteration of the loop
49153
 
    END IF;
49154
 
 
49155
 
    -- if event alarm
49156
 
    IF (_alarm.alarm_event) THEN
49157
 
      SELECT evnttype_id INTO _evnttypeid
49158
 
      FROM evnttype
49159
 
      WHERE (evnttype_name=_evnttypename);
49160
 
 
49161
 
      _recipientPart := 1;
49162
 
      LOOP
49163
 
        _recipient := SPLIT_PART(_alarm.alarm_event_recipient, ',', _recipientPart);
49164
 
        EXIT WHEN (LENGTH(_recipient) = 0);
49165
 
 
49166
 
        SELECT usrpref_value INTO _whsId
49167
 
        FROM usrpref
49168
 
        WHERE ( (usrpref_username = _recipient)
49169
 
          AND   (usrpref_name = 'PreferredWarehouse') );
49170
 
 
49171
 
        INSERT INTO evntlog (evntlog_evnttime, evntlog_username,
49172
 
                             evntlog_evnttype_id, evntlog_ordtype,
49173
 
                             evntlog_ord_id, evntlog_warehous_id, evntlog_number
49174
 
                   ) VALUES (CURRENT_TIMESTAMP, _recipient,
49175
 
                             _evnttypeid, _evntlogordtype,
49176
 
                             _alarm.alarm_source_id, _whsId, _summary);
49177
 
 
49178
 
        _recipientPart := _recipientPart + 1;
49179
 
      END LOOP;
49180
 
    END IF;
49181
 
 
49182
 
    IF (_alarm.alarm_email) THEN
49183
 
      SELECT usr_email INTO _fromEmail
49184
 
      FROM usr
49185
 
      WHERE (usr_username = _alarm.alarm_creator);
49186
 
 
49187
 
      _recipientPart := 1;
49188
 
      LOOP
49189
 
        _recipient := SPLIT_PART(_alarm.alarm_email_recipient, ',', _recipientPart);
49190
 
        EXIT WHEN (LENGTH(_recipient) <= 0);
49191
 
        _batchId := xtbatch.submitEmailToBatch(_fromEmail, _recipient, '',
49192
 
                                               _summary,
49193
 
                                               'Alarm reminder for '
49194
 
                                               || _longsource || '.',
49195
 
                                               NULL, CURRENT_TIMESTAMP,
49196
 
                                               FALSE, NULL, NULL);
49197
 
        _recipientPart := _recipientPart + 1;
49198
 
      END LOOP;
49199
 
    END IF;
49200
 
 
49201
 
    IF (_alarm.alarm_sysmsg) THEN
49202
 
      _recipientPart := 1;
49203
 
      LOOP
49204
 
        _recipient := SPLIT_PART(_alarm.alarm_sysmsg_recipient, ',', _recipientPart);
49205
 
        EXIT WHEN (LENGTH(_recipient) <= 0);
49206
 
        _msgId := postMessage(_recipient, (_longsource || ' - ' || _summary));
49207
 
        _recipientPart := _recipientPart + 1;
49208
 
      END LOOP;
49209
 
    END IF;
49210
 
 
49211
 
    DELETE FROM alarm WHERE alarm_id=_alarm.alarm_id;
49212
 
  END LOOP;
49213
 
  RETURN _returnVal;
49214
 
 
49215
 
END;
49216
 
$$;
49217
 
 
49218
 
 
49219
 
ALTER FUNCTION public.hasalarms() OWNER TO admin;
49220
 
 
49221
 
--
49222
 
--
49223
 
 
49224
 
CREATE FUNCTION hasevents() RETURNS boolean
49225
 
    LANGUAGE plpgsql
49226
 
    AS $$
49227
 
BEGIN
49228
 
 
49229
 
  PERFORM evntlog_id
49230
 
  FROM evntlog
49231
 
  WHERE ( (evntlog_dispatched IS NULL)
49232
 
   AND (evntlog_username=getEffectiveXtUser()) )
49233
 
  LIMIT 1;
49234
 
  RETURN FOUND;
49235
 
 
49236
 
END;
49237
 
$$;
49238
 
 
49239
 
 
49240
 
ALTER FUNCTION public.hasevents() OWNER TO admin;
49241
 
 
49242
 
--
49243
 
--
49244
 
 
49245
 
CREATE FUNCTION hasmessages() RETURNS boolean
49246
 
    LANGUAGE plpgsql
49247
 
    AS $$
49248
 
BEGIN
49249
 
 
49250
 
  PERFORM msguser_id
49251
 
  FROM msg, msguser
49252
 
  WHERE ( (msguser_username=getEffectiveXtUser())
49253
 
   AND (msguser_msg_id=msg_id)
49254
 
   AND (CURRENT_TIMESTAMP BETWEEN msg_scheduled AND msg_expires)
49255
 
   AND (msguser_viewed IS NULL) )
49256
 
  LIMIT 1;
49257
 
  RETURN FOUND;
49258
 
 
49259
 
END;
49260
 
$$;
49261
 
 
49262
 
 
49263
 
ALTER FUNCTION public.hasmessages() OWNER TO admin;
49264
 
 
49265
 
--
49266
 
--
49267
 
 
49268
 
CREATE FUNCTION haspriv(text) RETURNS boolean
49269
 
    LANGUAGE plpgsql
49270
 
    AS $_$
49271
 
DECLARE
49272
 
  pPrivName     ALIAS FOR $1;
49273
 
  _result       INTEGER;
49274
 
  _returnVal    BOOLEAN;
49275
 
 
49276
 
BEGIN
49277
 
  RAISE NOTICE 'hasPriv(TEXT) is deprecated. Use checkPrivilege(TEXT) instead.';
49278
 
  SELECT priv_id INTO _result
49279
 
    FROM priv, grppriv, usrgrp
49280
 
   WHERE((usrgrp_grp_id=grppriv_grp_id)
49281
 
     AND (grppriv_priv_id=priv_id)
49282
 
     AND (priv_name=pPrivName)
49283
 
     AND (usrgrp_username=getEffectiveXtUser()));
49284
 
  IF (FOUND) THEN
49285
 
    RETURN true;
49286
 
  END IF;
49287
 
 
49288
 
  SELECT COALESCE(usrpriv_id, 0) != 0 INTO _returnVal
49289
 
  FROM priv LEFT OUTER JOIN
49290
 
       usrpriv ON (priv_id=usrpriv_priv_id AND usrpriv_username = getEffectiveXtUser())
49291
 
  WHERE (priv_name=pPrivName);
49292
 
  IF (_returnVal IS NULL) THEN
49293
 
    _returnVal := FALSE;
49294
 
  END IF;
49295
 
 
49296
 
  RETURN _returnVal;
49297
 
END;
49298
 
$_$;
49299
 
 
49300
 
 
49301
 
ALTER FUNCTION public.haspriv(text) OWNER TO admin;
49302
 
 
49303
 
--
49304
 
--
49305
 
 
49306
 
CREATE FUNCTION hasprivonobject(pprivtype text, pobjecttype text, pobjectid integer DEFAULT NULL::integer, puser text DEFAULT NULL::text) RETURNS boolean
49307
 
    LANGUAGE plpgsql STABLE
49308
 
    AS $$
49309
 
DECLARE
49310
 
  _haspriv   BOOLEAN := FALSE;
49311
 
  _privfound BOOLEAN := FALSE;
49312
 
  _pkey      TEXT[];
49313
 
  _privdesc  RECORD;
49314
 
  _qstr      TEXT;
49315
 
 
49316
 
BEGIN
49317
 
  IF UPPER(pPrivType) NOT IN ('CREATE', 'EDIT', 'VIEW', 'DELETE') THEN
49318
 
    RAISE EXCEPTION 'Cannot check if user has % on % [xtuple: hasPrivOnObject, -1, %, %]',
49319
 
                     pPrivType, pObjectType, pPrivType, pObjectType;
49320
 
  END IF;
49321
 
 
49322
 
  /* TODO: create privdesc table? can't do it yet because this is a fix for a minor release
49323
 
     NOTE: only include tables that have a single integer column as pkey
49324
 
     NOTE: some of these are part of proprietary extensions. how do we make them part of the extension?
49325
 
  */
49326
 
  FOR _privdesc IN
49327
 
  WITH privdesc AS (
49328
 
    SELECT 'ADDR' AS otype,    'public' AS masterschema,
49329
 
                                         'addr' AS mastertable,
49330
 
                                                     'MaintainAddressMasters' AS editall,
49331
 
                                                                                     'ViewAddressMasters' AS viewall,
49332
 
                                                                                                               NULL AS ownerfield,        NULL AS editmine,                NULL AS viewmine
49333
 
     UNION ALL SELECT 'BBH',   'xtmfg',  'bbom',     'MaintainBBOMs',                'ViewBBOMs',              NULL,                      NULL,                            NULL
49334
 
     UNION ALL SELECT 'BBI',   'xtmfg',  'bbom',     'MaintainBBOMs',                'ViewBBOMs',              NULL,                      NULL,                            NULL
49335
 
     UNION ALL SELECT 'BMH',   'public', 'bom',      'MaintainBOMs',                 'ViewBOMs',               NULL,                      NULL,                            NULL
49336
 
     UNION ALL SELECT 'BMI',   'public', 'bom',      'MaintainBOMs',                 'ViewBOMs',               NULL,                      NULL,                            NULL
49337
 
     UNION ALL SELECT 'BOH',   'xtmfg',  'boo',      'MaintainBOOs',                 'ViewBOOs',               NULL,                      NULL,                            NULL
49338
 
     UNION ALL SELECT 'BOI',   'xtmfg',  'boo',      'MaintainBOOs',                 'ViewBOOs',               NULL,                      NULL,                            NULL
49339
 
     UNION ALL SELECT 'C',     'public', 'custinfo', 'MaintainCustomerMasters',      'ViewCustomerMasters',    NULL,                      NULL,                            NULL
49340
 
     UNION ALL SELECT 'CRMA',  'public', 'crmacct',  'MaintainAllCRMAccounts',       'ViewAllCRMAccounts',     'crmacct_owner_username',  'MaintainPersonalCRMAccounts',   'ViewPersonalCRMAccounts'
49341
 
     UNION ALL SELECT 'EMP',   'public', 'emp',      'MaintainEmployees',            'ViewEmployees',          NULL,                      NULL,                            NULL
49342
 
     UNION ALL SELECT 'I',     'public', 'item',     'MaintainItemMasters',          'ViewItemMasters',        NULL,                      NULL,                            NULL
49343
 
     UNION ALL SELECT 'INCDT', 'public', 'incdt',    'MaintainAllIncidents',         'ViewAllIncidents',       'incdt_owner_username',    'MaintainPersonalIncidents',     'ViewPersonalIncidents'
49344
 
     UNION ALL SELECT 'IR',    'public', 'itemsrc',  'MaintainItemSources',          'ViewItemSources',        NULL,                      NULL,                            NULL
49345
 
     UNION ALL SELECT 'IS',    'public', 'itemsite', 'MaintainItemSites',            'ViewItemSites',          NULL,                      NULL,                            NULL
49346
 
     UNION ALL SELECT 'J',     'public', 'prj',      'MaintainAllProjects',          'ViewAllProjects',        'prj_owner_username',      'MaintainPersonalProjects',      'ViewPersonalProjects'
49347
 
     UNION ALL SELECT 'J',     'public', 'prj',      'MaintainAllProjects',          'ViewAllProjects',        'prj_username',            'MaintainPersonalProjects',      'ViewPersonalProjects'
49348
 
     UNION ALL SELECT 'L',     'public', 'location', 'MaintainLocations',            'ViewLocations',          NULL,                      NULL,                            NULL
49349
 
     UNION ALL SELECT 'OPP',   'public', 'ophead',   'MaintainAllOpportunities',     'ViewAllOpportunities',   'ophead_owner_username',   'MaintainPersonalOpportunities', 'ViewPersonalOpportunities'
49350
 
     UNION ALL SELECT 'P',     'public', 'pohead',   'MaintainPurchaseOrders',       'ViewPurchaseOrders',     NULL,                      NULL,                            NULL
49351
 
     UNION ALL SELECT 'PI',    'public', 'pohead',   'MaintainPurchaseOrders',       'ViewPurchaseOrders',     NULL,                      NULL,                            NULL
49352
 
     UNION ALL SELECT 'Q',     'public', 'quhead',   'MaintainQuotes',               'ViewQuotes',             NULL,                      NULL,                            NULL
49353
 
     UNION ALL SELECT 'QI',    'public', 'quhead',   'MaintainQuotes',               'ViewQuotes',             NULL,                      NULL,                            NULL
49354
 
     UNION ALL SELECT 'RA',    'public', 'rahead',   'MaintainReturns',              'ViewReturns',            NULL,                      NULL,                            NULL
49355
 
     UNION ALL SELECT 'RI',    'public', 'rahead',   'MaintainReturns',              'ViewReturns',            NULL,                      NULL,                            NULL
49356
 
     UNION ALL SELECT 'S',     'public', 'cohead',   'MaintainSalesOrders',          'ViewSalesOrders',        NULL,                      NULL,                            NULL
49357
 
     UNION ALL SELECT 'SI',    'public', 'cohead',   'MaintainSalesOrders',          'ViewSalesOrders',        NULL,                      NULL,                            NULL
49358
 
     UNION ALL SELECT 'T',     'public', 'cntct',    'MaintainAllContacts',          'ViewAllContacts',        'cntct_owner_username',    'MaintainPersonalContacts',      'ViewPersonalContacts'
49359
 
     UNION ALL SELECT 'TE',    'te',     'tehead',   'MaintainTimeExpense',          'ViewTimeExpenseHistory', 'tehead_username',         'MaintainTimeExpenseSelf',       NULL
49360
 
     UNION ALL SELECT 'TE',    'te',     'tehead',   'MaintainTimeExpenseOthers',    'ViewTimeExpenseHistory', 'tehead_username',         'MaintainTimeExpenseSelf',       NULL
49361
 
     UNION ALL SELECT 'TI',    'public', 'tohead',   'MaintainTransferOrders',       'ViewTransferOrders',     NULL,                      NULL,                            NULL
49362
 
     UNION ALL SELECT 'TO',    'public', 'tohead',   'MaintainTransferOrders',       'ViewTransferOrders',     NULL,                      NULL,                            NULL
49363
 
     UNION ALL SELECT 'TODO',  'public', 'todoitem', 'MaintainAllToDoItems',         'ViewAllToDoItems',       'todoitem_owner_username', 'MaintainPersonalToDoItems',     'ViewPersonalToDoItems'
49364
 
     UNION ALL SELECT 'V',     'public', 'vendinfo', 'MaintainVendors',              'ViewVendors',            NULL,                      NULL,                            NULL
49365
 
     UNION ALL SELECT 'W',     'public', 'wo',       'MaintainWorkOrders',           'ViewWorkOrders',         NULL,                      NULL,                            NULL
49366
 
     UNION ALL SELECT 'WH',    'public', 'whsinfo',  'MaintainWarehouses',           'ViewWarehouses',         NULL,                      NULL,                            NULL)
49367
 
  -- UNION ALL SELECT 'LS',    'public', 'ls',       NULL,                           NULL,                     NULL,                      NULL,                            NULL
49368
 
  -- UNION ALL SELECT 'P',     'public', 'pohead',   'MaintainPostedPurchaseOrders', 'ViewPurchaseOrders',     NULL,                      NULL,                            NULL -- additional criteria?
49369
 
  -- UNION ALL SELECT 'PI',    'public', 'pohead',   'MaintainPostedPurchaseOrders', 'ViewPurchaseOrders',     NULL,                      NULL,                            NULL -- additional criteria?
49370
 
     SELECT *
49371
 
       FROM privdesc
49372
 
      WHERE otype = pObjectType
49373
 
  LOOP
49374
 
    _privfound := TRUE;
49375
 
    RAISE DEBUG '% % % % % % %',
49376
 
                _privdesc.otype, _privdesc.masterschema, _privdesc.mastertable,
49377
 
                _privdesc.editall, _privdesc.viewall, _privdesc.editmine, _privdesc.viewmine;
49378
 
 
49379
 
    IF checkPrivilege(CASE UPPER(pPrivType) WHEN 'CREATE' THEN _privdesc.editall
49380
 
                                            WHEN 'EDIT'   THEN _privdesc.editall
49381
 
                                            WHEN 'DELETE' THEN _privdesc.editall
49382
 
                                            WHEN 'VIEW'   THEN _privdesc.viewall
49383
 
                      END) THEN
49384
 
      _haspriv = TRUE;
49385
 
 
49386
 
    ELSIF checkPrivilege(CASE UPPER(pPrivType) WHEN 'CREATE' THEN _privdesc.editmine
49387
 
                                               WHEN 'EDIT'   THEN _privdesc.editmine
49388
 
                                               WHEN 'DELETE' THEN _privdesc.editmine
49389
 
                                               WHEN 'VIEW'   THEN _privdesc.viewmine
49390
 
                         END) THEN
49391
 
      IF pObjectId IS NULL THEN
49392
 
      _haspriv = TRUE;
49393
 
 
49394
 
      ELSE
49395
 
        _pkey := primaryKeyFields(_privdesc.masterschema, _privdesc.mastertable);
49396
 
 
49397
 
        -- SELECT ... FROM schema.table WHERE pkeyfield = pObjectId AND ownerfield = pUser
49398
 
        _qstr := 'SELECT EXISTS(SELECT 1
49399
 
                                  FROM ' || quote_ident(_privdesc.masterschema)
49400
 
                                   || '.' || quote_ident(_privdesc.mastertable)
49401
 
                                   || ' WHERE ' || quote_ident(_pkey[1]) || ' = ' || pObjectId
49402
 
                                   || '   AND ' || quote_ident(_privdesc.ownerfield)
49403
 
                                   || '= ' || quote_literal(COALESCE(pUser, getEffectiveXtUser())) || ');';
49404
 
        RAISE DEBUG '%', _qstr;
49405
 
 
49406
 
        EXECUTE _qstr INTO _haspriv;
49407
 
      END IF;
49408
 
    END IF;
49409
 
 
49410
 
    EXIT WHEN _haspriv;
49411
 
  END LOOP;
49412
 
 
49413
 
  RETURN _haspriv OR NOT _privfound;
49414
 
 
49415
 
END;
49416
 
$$;
49417
 
 
49418
 
 
49419
 
ALTER FUNCTION public.hasprivonobject(pprivtype text, pobjecttype text, pobjectid integer, puser text) OWNER TO admin;
49420
 
 
49421
 
--
49422
 
--
49423
 
 
49424
 
COMMENT ON FUNCTION hasprivonobject(pprivtype text, pobjecttype text, pobjectid integer, puser text) IS 'Return if a user has permission to view or edit a specific database object.
49425
 
pPrivType is either CREATE, EDIT, DELETE, or VIEW, and controls which privilege is checked.
49426
 
pObjectType is one of the string constants used by the Documents widget, such as ADDR for Addresses.
49427
 
pObjectId is the internal id of the record in the table associated with pObjectType (defaults to NULL).
49428
 
pUser is the username to be checked for those pObjectTypes that restrict access to individual users (NULL == current user and is the default).';
49429
 
 
49430
 
 
49431
 
--
49432
 
--
49433
 
 
49434
 
CREATE FUNCTION hmac(text, text, text) RETURNS bytea
49435
 
    LANGUAGE c IMMUTABLE STRICT
49436
 
    AS '$libdir/pgcrypto', 'pg_hmac';
49437
 
 
49438
 
 
49439
 
ALTER FUNCTION public.hmac(text, text, text) OWNER TO admin;
49440
 
 
49441
 
--
49442
 
--
49443
 
 
49444
 
CREATE FUNCTION hmac(bytea, bytea, text) RETURNS bytea
49445
 
    LANGUAGE c IMMUTABLE STRICT
49446
 
    AS '$libdir/pgcrypto', 'pg_hmac';
49447
 
 
49448
 
 
49449
 
ALTER FUNCTION public.hmac(bytea, bytea, text) OWNER TO admin;
49450
 
 
49451
 
--
49452
 
--
49453
 
 
49454
 
CREATE FUNCTION implodewo(integer, boolean) RETURNS integer
49455
 
    LANGUAGE plpgsql
49456
 
    AS $_$
49457
 
DECLARE
49458
 
  pWoid ALIAS FOR $1;
49459
 
  implodeChildren ALIAS FOR $2;
49460
 
  resultCode INTEGER;
49461
 
  _wotcCnt   INTEGER;
49462
 
  _routings  BOOLEAN;
49463
 
 
49464
 
BEGIN
49465
 
  SELECT metric_value='t' INTO _routings
49466
 
         FROM metric
49467
 
         WHERE (metric_name='Routings');
49468
 
 
49469
 
  IF ((SELECT wo_id
49470
 
       FROM wo
49471
 
       WHERE ((wo_status='E')
49472
 
        AND (wo_id=pWoid))) IS NULL) THEN
49473
 
    RETURN 0;
49474
 
  END IF;
49475
 
 
49476
 
  IF (_routings) THEN
49477
 
    SELECT count(*) INTO _wotcCnt
49478
 
    FROM xtmfg.wotc
49479
 
    WHERE (wotc_wo_id=pWoid);
49480
 
    IF (_wotcCnt > 0) THEN
49481
 
      RETURN -1;
49482
 
    END IF;
49483
 
  END IF;
49484
 
 
49485
 
  PERFORM deletePr('W', womatl_id)
49486
 
  FROM womatl
49487
 
  WHERE (womatl_wo_id=pWoid);
49488
 
 
49489
 
  DELETE FROM womatl
49490
 
  WHERE (womatl_id IN ( SELECT womatl_id
49491
 
                        FROM womatl, wo
49492
 
                        WHERE ((womatl_wo_id=wo_id)
49493
 
                         AND (wo_status='E')
49494
 
                         AND (wo_id=pWoid)) ));
49495
 
 
49496
 
  IF _routings THEN
49497
 
 
49498
 
    DELETE FROM xtmfg.wooper
49499
 
    WHERE (wooper_id IN ( SELECT wooper_id
49500
 
                          FROM xtmfg.wooper, wo
49501
 
                          WHERE ((wooper_wo_id=wo_id)
49502
 
                           AND (wo_status='E')
49503
 
                           AND (wo_id=pWoid)) ));
49504
 
  END IF;
49505
 
 
49506
 
  UPDATE wo
49507
 
  SET wo_status='O'
49508
 
  WHERE (wo_id=pWoid);
49509
 
 
49510
 
  IF (implodeChildren) THEN
49511
 
    resultCode := (SELECT MAX(implodeWo(wo_id, TRUE))
49512
 
                   FROM wo
49513
 
                   WHERE ((wo_ordtype='W')
49514
 
                    AND (wo_ordid=pWoid)));
49515
 
 
49516
 
    resultCode := (SELECT MAX(deleteWo(wo_id, TRUE))
49517
 
                   FROM wo
49518
 
                   WHERE ((wo_ordtype='W')
49519
 
                    AND (wo_ordid=pWoid)));
49520
 
  END IF;
49521
 
 
49522
 
  RETURN 0;
49523
 
END;
49524
 
$_$;
49525
 
 
49526
 
 
49527
 
ALTER FUNCTION public.implodewo(integer, boolean) OWNER TO admin;
49528
 
 
49529
 
--
49530
 
--
49531
 
 
49532
 
CREATE FUNCTION importbankreccleared(pbankrecid integer) RETURNS integer
49533
 
    LANGUAGE plpgsql
49534
 
    AS $$
49535
 
DECLARE
49536
 
  _bankrecid INTEGER;
49537
 
  _result INTEGER := 0;
49538
 
  _cleared BOOLEAN;
49539
 
  _doctype TEXT;
49540
 
  _docid INTEGER := -1;
49541
 
  _bankadjid INTEGER := -1;
49542
 
  _debitbankadjtypeid INTEGER := -1;
49543
 
  _creditbankadjtypeid INTEGER := -1;
49544
 
  _b RECORD;
49545
 
  _r RECORD;
49546
 
 
49547
 
BEGIN
49548
 
  -- cache some information
49549
 
  IF (pBankrecid = -1) THEN
49550
 
    _bankrecid := fetchMetricValue('ImportBankRecId');
49551
 
  ELSE
49552
 
    _bankrecid := pBankrecid;
49553
 
  END IF;
49554
 
 
49555
 
  SELECT * INTO _b
49556
 
  FROM bankrec JOIN bankaccnt ON (bankaccnt_id=bankrec_bankaccnt_id)
49557
 
  WHERE (bankrec_id=_bankrecid);
49558
 
  IF (NOT FOUND) THEN
49559
 
    RAISE EXCEPTION 'bankrec not found';
49560
 
  END IF;
49561
 
  IF (_b.bankrec_posted) THEN
49562
 
    RAISE EXCEPTION 'bankrec already posted';
49563
 
  END IF;
49564
 
 
49565
 
   _debitbankadjtypeid := fetchMetricValue('ImportBankRecDebitAdj');
49566
 
  IF (_debitbankadjtypeid = -1) THEN
49567
 
    RAISE EXCEPTION 'Metric ImportBankRecDebitAdj not defined [xtuple: reconcileBankAccount, -1]';
49568
 
  END IF;
49569
 
 
49570
 
   _creditbankadjtypeid := fetchMetricValue('ImportBankRecCreditAdj');
49571
 
  IF (_creditbankadjtypeid = -1) THEN
49572
 
    RAISE EXCEPTION 'Metric ImportBankRecCreditAdj not defined [xtuple: reconcileBankAccount, -2]';
49573
 
  END IF;
49574
 
 
49575
 
  -- loop thru bankrecimport and toggle cleared items
49576
 
  FOR _r IN
49577
 
  SELECT *,
49578
 
         COALESCE(bankrecimport_debit_amount, 0.0) AS debit,
49579
 
         COALESCE(bankrecimport_credit_amount, 0.0) AS credit
49580
 
  FROM bankrecimport
49581
 
  LOOP
49582
 
 
49583
 
    -- TODO how to handle duplicate document numbers
49584
 
    -- TODO how to handle amount differences
49585
 
    -- TODO add support for Project Accounting (sltrans)
49586
 
 
49587
 
    IF ( (_r.debit > 0.0) AND (_r.credit > 0.0) ) THEN
49588
 
      RAISE NOTICE 'Bankrecimport % cannot determine if debit or credit', _r.bankrecimport_reference;
49589
 
      CONTINUE;
49590
 
    END IF;
49591
 
 
49592
 
    IF (_r.debit > 0.0) THEN
49593
 
 
49594
 
      -- handle receipts
49595
 
 
49596
 
      SELECT cashrcpt_id INTO _docid
49597
 
      FROM cashrcpt
49598
 
      WHERE (cashrcpt_docnumber=_r.bankrecimport_reference)
49599
 
        AND (cashrcpt_posted)
49600
 
        AND (NOT cashrcpt_void)
49601
 
      -- TODO workaround for duplicates
49602
 
      ORDER BY cashrcpt_id DESC
49603
 
      LIMIT 1;
49604
 
      IF (FOUND) THEN
49605
 
        SELECT toggleBankrecCleared(_b.bankrec_id, 'GL', gltrans_id,
49606
 
                                    cashrcpt_curr_rate, _r.debit,
49607
 
                                    _r.bankrecimport_effdate) INTO _cleared
49608
 
        FROM gltrans LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='GL' AND
49609
 
                                                     bankrecitem_source_id=gltrans_id)
49610
 
        WHERE (gltrans_source='A/R')
49611
 
          AND (gltrans_doctype='CR')
49612
 
          AND (gltrans_misc_id=_docid)
49613
 
          AND (NOT gltrans_rec)
49614
 
          AND (gltrans_accnt_id=_b.bankaccnt_accnt_id)
49615
 
          AND (NOT COALESCE(bankrecitem_cleared, FALSE));
49616
 
      ELSE
49617
 
 
49618
 
        -- create and toggle bank adjustment
49619
 
        -- TODO define bank adjustment names
49620
 
 
49621
 
        _bankadjid := -1;
49622
 
        SELECT bankadj_id INTO _bankadjid
49623
 
        FROM bankadj JOIN bankadjtype ON (bankadjtype_id=bankadj_bankadjtype_id)
49624
 
        WHERE (bankadjtype_id=_debitbankadjtypeid)
49625
 
          AND (bankadj_docnumber=_r.bankrecimport_reference)
49626
 
          AND (bankadj_bankaccnt_id=_b.bankaccnt_id);
49627
 
        IF (NOT FOUND) THEN
49628
 
          INSERT INTO bankadj
49629
 
            (bankadj_bankaccnt_id, bankadj_bankadjtype_id, bankadj_date,
49630
 
             bankadj_docnumber, bankadj_amount, bankadj_notes,
49631
 
             bankadj_curr_id)
49632
 
          VALUES
49633
 
            (_b.bankaccnt_id, _debitbankadjtypeid, _r.bankrecimport_effdate,
49634
 
             _r.bankrecimport_reference, _r.debit, 'Import Bankrec Adjustment',
49635
 
             _b.bankaccnt_curr_id)
49636
 
          RETURNING bankadj_id INTO _bankadjid;
49637
 
        END IF;
49638
 
 
49639
 
        SELECT toggleBankrecCleared(_b.bankrec_id, 'AD', _bankadjid,
49640
 
                                    1.0, _r.debit,
49641
 
                                    _r.bankrecimport_effdate) INTO _cleared
49642
 
        FROM bankadj LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='AD' AND
49643
 
                                                     bankrecitem_source_id=bankadj_id)
49644
 
        WHERE (bankadj_id=_bankadjid)
49645
 
          AND (NOT COALESCE(bankrecitem_cleared, FALSE));
49646
 
      END IF;
49647
 
 
49648
 
      -- done with receipts
49649
 
 
49650
 
    ELSE
49651
 
 
49652
 
      -- handle checks
49653
 
 
49654
 
      SELECT checkhead_id INTO _docid
49655
 
      FROM checkhead
49656
 
      WHERE (checkhead_number::TEXT=_r.bankrecimport_reference)
49657
 
        AND (checkhead_posted)
49658
 
        AND (NOT checkhead_void);
49659
 
      IF (FOUND) THEN
49660
 
        SELECT toggleBankrecCleared(_b.bankrec_id, 'GL', gltrans_id,
49661
 
                                    checkhead_curr_rate, _r.credit,
49662
 
                                    _r.bankrecimport_effdate) INTO _cleared
49663
 
        FROM gltrans LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='GL' AND
49664
 
                                                     bankrecitem_source_id=gltrans_id)
49665
 
        WHERE (gltrans_source='A/P')
49666
 
          AND (gltrans_doctype='CK')
49667
 
          AND (gltrans_misc_id=_docid)
49668
 
          AND (NOT gltrans_rec)
49669
 
          AND (gltrans_accnt_id=_b.bankaccnt_accnt_id)
49670
 
          AND (NOT COALESCE(bankrecitem_cleared, FALSE));
49671
 
      ELSE
49672
 
 
49673
 
        -- create and toggle bank adjustment
49674
 
        -- TODO define bank adjustment names
49675
 
 
49676
 
        _bankadjid := -1;
49677
 
        SELECT bankadj_id INTO _bankadjid
49678
 
        FROM bankadj JOIN bankadjtype ON (bankadjtype_id=bankadj_bankadjtype_id)
49679
 
        WHERE (bankadjtype_id=_creditbankadjtypeid)
49680
 
          AND (bankadj_docnumber=_r.bankrecimport_reference);
49681
 
        IF (NOT FOUND) THEN
49682
 
          INSERT INTO bankadj
49683
 
            (bankadj_bankaccnt_id, bankadj_bankadjtype_id, bankadj_date,
49684
 
             bankadj_docnumber, bankadj_amount, bankadj_notes,
49685
 
             bankadj_curr_id)
49686
 
          VALUES
49687
 
            (_b.bankaccnt_id, _creditbankadjtypeid, _r.bankrecimport_effdate,
49688
 
             _r.bankrecimport_reference, _r.credit, 'Import Bankrec Adjustment',
49689
 
             _b.bankaccnt_curr_id)
49690
 
          RETURNING bankadj_id INTO _bankadjid;
49691
 
        END IF;
49692
 
 
49693
 
        SELECT toggleBankrecCleared(_b.bankrec_id, 'AD', _bankadjid,
49694
 
                                    1.0, _r.credit,
49695
 
                                    _r.bankrecimport_effdate) INTO _cleared
49696
 
        FROM bankadj LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='AD' AND
49697
 
                                                     bankrecitem_source_id=_bankadjid)
49698
 
        WHERE (NOT COALESCE(bankrecitem_cleared, FALSE));
49699
 
      END IF;
49700
 
 
49701
 
      -- done with checks
49702
 
 
49703
 
    END IF;
49704
 
 
49705
 
  END LOOP;
49706
 
 
49707
 
  RETURN _result;
49708
 
END;
49709
 
$$;
49710
 
 
49711
 
 
49712
 
ALTER FUNCTION public.importbankreccleared(pbankrecid integer) OWNER TO admin;
49713
 
 
49714
 
--
49715
 
--
49716
 
 
49717
 
CREATE TABLE incdt (
49718
 
    incdt_id integer NOT NULL,
49719
 
    incdt_number integer NOT NULL,
49720
 
    incdt_crmacct_id integer,
49721
 
    incdt_cntct_id integer,
49722
 
    incdt_summary text,
49723
 
    incdt_descrip text,
49724
 
    incdt_item_id integer,
49725
 
    incdt_timestamp timestamp without time zone DEFAULT now() NOT NULL,
49726
 
    incdt_status character(1) DEFAULT 'N'::bpchar NOT NULL,
49727
 
    incdt_assigned_username text,
49728
 
    incdt_incdtcat_id integer,
49729
 
    incdt_incdtseverity_id integer,
49730
 
    incdt_incdtpriority_id integer,
49731
 
    incdt_incdtresolution_id integer,
49732
 
    incdt_lotserial text,
49733
 
    incdt_ls_id integer,
49734
 
    incdt_aropen_id integer,
49735
 
    incdt_owner_username text,
49736
 
    incdt_recurring_incdt_id integer,
49737
 
    incdt_updated timestamp without time zone DEFAULT now() NOT NULL,
49738
 
    incdt_prj_id integer,
49739
 
    incdt_public boolean
49740
 
);
49741
 
 
49742
 
 
49743
 
ALTER TABLE public.incdt OWNER TO admin;
49744
 
 
49745
 
--
49746
 
--
49747
 
 
49748
 
COMMENT ON TABLE incdt IS 'Incident table';
49749
 
 
49750
 
 
49751
 
--
49752
 
--
49753
 
 
49754
 
COMMENT ON COLUMN incdt.incdt_lotserial IS 'incdt_lotserial is deprecated';
49755
 
 
49756
 
 
49757
 
--
49758
 
--
49759
 
 
49760
 
COMMENT ON COLUMN incdt.incdt_recurring_incdt_id IS 'The first incdt record in the series if this is a recurring Incident. If the incdt_recurring_incdt_id is the same as the incdt_id, this record is the first in the series.';
49761
 
 
49762
 
 
49763
 
--
49764
 
--
49765
 
 
49766
 
CREATE FUNCTION incdt() RETURNS SETOF incdt
49767
 
    LANGUAGE plpgsql
49768
 
    AS $$
49769
 
DECLARE
49770
 
  _row incdt%ROWTYPE;
49771
 
  _priv TEXT;
49772
 
  _grant BOOLEAN;
49773
 
 
49774
 
BEGIN
49775
 
  -- This query will give us the most permissive privilege the user has been granted
49776
 
  SELECT privilege, granted INTO _priv, _grant
49777
 
  FROM privgranted 
49778
 
  WHERE privilege IN ('MaintainAllIncidents','ViewAllIncidents','MaintainPersonalIncidents','ViewPersonalIncidents')
49779
 
  ORDER BY granted DESC, sequence
49780
 
  LIMIT 1;
49781
 
 
49782
 
  -- If have an 'All' privilege return all results
49783
 
  IF (_priv ~ 'All' AND _grant) THEN
49784
 
    FOR _row IN 
49785
 
      SELECT * FROM incdt
49786
 
    LOOP
49787
 
      RETURN NEXT _row;
49788
 
    END LOOP;
49789
 
  -- Otherwise if have any other grant, must be personal privilege.
49790
 
  ELSIF (_grant) THEN
49791
 
    FOR _row IN 
49792
 
      SELECT * FROM incdt 
49793
 
      WHERE  getEffectiveXtUser() IN (incdt_owner_username, incdt_assigned_username)
49794
 
    LOOP
49795
 
      RETURN NEXT _row;
49796
 
    END LOOP;
49797
 
  END IF;
49798
 
 
49799
 
  RETURN;
49800
 
 
49801
 
END;
49802
 
$$;
49803
 
 
49804
 
 
49805
 
ALTER FUNCTION public.incdt() OWNER TO admin;
49806
 
 
49807
 
--
49808
 
--
49809
 
 
49810
 
COMMENT ON FUNCTION incdt() IS 'A table function that returns Incident results according to privilege settings.';
49811
 
 
49812
 
 
49813
 
--
49814
 
--
49815
 
 
49816
 
CREATE FUNCTION indentedbom(integer) RETURNS integer
49817
 
    LANGUAGE plpgsql
49818
 
    AS $_$
49819
 
DECLARE
49820
 
  pItemid ALIAS FOR $1;
49821
 
  _revid INTEGER;
49822
 
 
49823
 
BEGIN
49824
 
 
49825
 
  SELECT getActiveRevId('BOM',pItemid) INTO _revid;
49826
 
 
49827
 
  RETURN indentedBOM(pItemid, _revid);
49828
 
 
49829
 
END;
49830
 
$_$;
49831
 
 
49832
 
 
49833
 
ALTER FUNCTION public.indentedbom(integer) OWNER TO admin;
49834
 
 
49835
 
--
49836
 
--
49837
 
 
49838
 
CREATE FUNCTION indentedbom(integer, integer) RETURNS integer
49839
 
    LANGUAGE plpgsql
49840
 
    AS $_$
49841
 
DECLARE
49842
 
  pItemid ALIAS FOR $1;
49843
 
  pRevisionid ALIAS FOR $2;
49844
 
  _bomworkid INTEGER;
49845
 
  _indexid INTEGER;
49846
 
  _r RECORD;
49847
 
  _batchsize NUMERIC;
49848
 
 
49849
 
BEGIN
49850
 
 
49851
 
  -- Get the batch quantity
49852
 
  SELECT COALESCE( (
49853
 
    SELECT bomhead_batchsize
49854
 
    FROM bomhead
49855
 
    WHERE ((bomhead_item_id=pItemId)
49856
 
    AND (bomhead_rev_id=pRevisionid)) LIMIT 1),1) INTO _batchsize;
49857
 
 
49858
 
 
49859
 
  SELECT NEXTVAL('misc_index_seq') INTO _indexid;
49860
 
 
49861
 
  FOR _r IN SELECT bomitem.*,
49862
 
                   item_id,
49863
 
                   itemuomtouom(item_id, item_inv_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') AS qtyreq,
49864
 
                   (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL)
49865
 
                               * bomitem_qtyfxd) AS qtyfxd,
49866
 
                   (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL)
49867
 
                               * bomitem_qtyper) AS qtyper,
49868
 
                   stdcost(item_id, bomitem_id) AS standardcost,
49869
 
                   actcost(item_id, bomitem_id) AS actualcost
49870
 
  FROM bomitem(pItemId, pRevisionid), item
49871
 
  WHERE ( (bomitem_item_id=item_id) ) LOOP
49872
 
 
49873
 
    SELECT NEXTVAL('bomwork_bomwork_id_seq') INTO _bomworkid;
49874
 
    INSERT INTO bomwork
49875
 
    ( bomwork_id, bomwork_set_id, bomwork_parent_id, bomwork_level,
49876
 
      bomwork_parent_seqnumber, bomwork_seqnumber,
49877
 
      bomwork_item_id, bomwork_createwo, bomwork_qtyreq,
49878
 
      bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_issuemethod,
49879
 
      bomwork_effective, bomwork_expires,
49880
 
      bomwork_stdunitcost, bomwork_actunitcost,
49881
 
      bomwork_char_id, bomwork_value, bomwork_notes, bomwork_ref,
49882
 
      bomwork_bomitem_id, bomwork_ecn )
49883
 
    VALUES
49884
 
    ( _bomworkid, _indexid, -1, 1,
49885
 
      0, _r.bomitem_seqnumber,
49886
 
      _r.item_id, _r.bomitem_createwo, _r.qtyreq,
49887
 
      _r.qtyfxd, _r.qtyper, _r.bomitem_scrap, _r.bomitem_issuemethod,
49888
 
      _r.bomitem_effective, _r.bomitem_expires,
49889
 
      _r.standardcost, _r.actualcost,
49890
 
      _r.bomitem_char_id, _r.bomitem_value, _r.bomitem_notes, _r.bomitem_ref,
49891
 
      _r.bomitem_id, _r.bomitem_ecn );
49892
 
 
49893
 
    PERFORM explodeBOM(_r.item_id, _bomworkid, 1);
49894
 
 
49895
 
  END LOOP;
49896
 
 
49897
 
  RETURN _indexid;
49898
 
 
49899
 
END;
49900
 
$_$;
49901
 
 
49902
 
 
49903
 
ALTER FUNCTION public.indentedbom(integer, integer) OWNER TO admin;
49904
 
 
49905
 
--
49906
 
--
49907
 
 
49908
 
CREATE FUNCTION indentedbom(integer, integer, integer, integer) RETURNS SETOF bomdata
49909
 
    LANGUAGE plpgsql
49910
 
    AS $_$
49911
 
DECLARE
49912
 
  pItemid ALIAS FOR $1;
49913
 
  pRevisionid ALIAS FOR $2;
49914
 
  pExpiredDays ALIAS FOR $3;
49915
 
  pFutureDays ALIAS FOR $4;
49916
 
  _row bomdata%ROWTYPE;
49917
 
  _bomworksetid INTEGER;
49918
 
  _x RECORD;
49919
 
  _check CHAR(1);
49920
 
  _inactive BOOLEAN := FALSE;
49921
 
  _batchsize NUMERIC;
49922
 
BEGIN
49923
 
 
49924
 
  IF (pRevisionid != -1) THEN
49925
 
    --Is this a deactivated revision?
49926
 
    SELECT rev_status INTO _check
49927
 
    FROM rev
49928
 
    WHERE ((rev_id=pRevisionid)
49929
 
    AND (rev_status='I'));
49930
 
    IF (FOUND) THEN
49931
 
      _inactive := TRUE;
49932
 
    END IF;
49933
 
  END IF;
49934
 
 
49935
 
  -- Get the batch quantity
49936
 
  SELECT COALESCE( (
49937
 
    SELECT bomhead_batchsize
49938
 
    FROM bomhead
49939
 
    WHERE ((bomhead_item_id=pItemId)
49940
 
    AND (bomhead_rev_id=pRevisionid)) LIMIT 1),1) INTO _batchsize;
49941
 
 
49942
 
  IF NOT (_inactive) THEN
49943
 
 
49944
 
    --We can explode this out based on current data
49945
 
    SELECT indentedBOM(pItemid, pRevisionid) INTO _bomworksetid;  
49946
 
 
49947
 
    FOR _x IN
49948
 
        SELECT bomwork_id, bomwork_parent_id, bomwork_level,
49949
 
               bomworkSequence(bomwork_id) AS seq_ord,
49950
 
               bomwork_seqnumber, item_id, item_number, uom_name,
49951
 
               item_descrip1, item_descrip2,
49952
 
               (item_descrip1 || ' ' || item_descrip2) AS itemdescription,
49953
 
               bomwork_qtyreq, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_createwo,
49954
 
       CASE WHEN (bomwork_issuemethod='S') THEN 'Push'
49955
 
            WHEN (bomwork_issuemethod='L') THEN 'Pull'
49956
 
            WHEN (bomwork_issuemethod='M') THEN 'Mixed'
49957
 
            ELSE 'Special'
49958
 
       END AS issuemethod,
49959
 
       bomwork_effective, bomwork_expires,
49960
 
       (bomwork_expires <= CURRENT_DATE) AS expired,
49961
 
       (bomwork_effective > CURRENT_DATE) AS future,
49962
 
       bomwork_actunitcost AS actunitcost,
49963
 
       bomwork_stdunitcost AS stdunitcost,
49964
 
       CASE WHEN item_type NOT IN ('R','T') THEN
49965
 
         itemuomtouom(item_id, item_inv_uom_id, NULL, (bomwork_qtyfxd/_batchsize + bomwork_qtyper) * (1 + bomwork_scrap), 'qtyper') * bomwork_actunitcost
49966
 
       ELSE 0.0 END AS actextendedcost,
49967
 
       CASE WHEN item_type NOT IN ('R','T') THEN
49968
 
         itemuomtouom(item_id, item_inv_uom_id, NULL, (bomwork_qtyfxd/_batchsize + bomwork_qtyper) * (1 + bomwork_scrap), 'qtyper') * bomwork_stdunitcost
49969
 
       ELSE 0.0 END AS stdextendedcost,
49970
 
       bomwork_char_id,
49971
 
       bomwork_value, bomwork_notes, bomwork_ref,
49972
 
       bomwork_bomitem_id, bomwork_ecn
49973
 
       FROM bomwork, item, uom 
49974
 
       WHERE ( (bomwork_item_id=item_id)
49975
 
       AND (item_inv_uom_id=uom_id)
49976
 
       AND (bomwork_set_id=_bomworksetid) )
49977
 
       AND (bomwork_expires > (CURRENT_DATE - pExpiredDays))
49978
 
       AND (bomwork_effective <= (CURRENT_DATE + pFutureDays))
49979
 
       UNION
49980
 
       SELECT -1, -1, 1,
49981
 
              '0',
49982
 
              NULL,-1, costelem_type AS bomdata_item_number, '',
49983
 
              '', '',
49984
 
              '',
49985
 
              NULL, NULL, NULL, NULL, NULL,
49986
 
              '',
49987
 
              NULL, NULL,
49988
 
              false,
49989
 
              false,
49990
 
              currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actunitcost,
49991
 
              itemcost_stdcost AS stdunitcost,
49992
 
              currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actextendedcost,
49993
 
              itemcost_stdcost AS stdextendedcost,
49994
 
              NULL,
49995
 
              NULL,NULL,NULL,
49996
 
              NULL,NULL
49997
 
       FROM itemcost, costelem 
49998
 
       WHERE ( (itemcost_costelem_id=costelem_id)
49999
 
       AND (NOT itemcost_lowlevel)
50000
 
       AND (itemcost_item_id=pItemid) )
50001
 
       ORDER BY seq_ord
50002
 
    LOOP
50003
 
        _row.bomdata_bomwork_id := _x.bomwork_id;
50004
 
        _row.bomdata_bomwork_parent_id := _x.bomwork_parent_id;
50005
 
        _row.bomdata_bomwork_level := _x.bomwork_level;
50006
 
        _row.bomdata_bomwork_seqnumber := _x.bomwork_seqnumber;
50007
 
        _row.bomdata_bomitem_id := _x.bomwork_bomitem_id;
50008
 
        _row.bomdata_item_id := _x.item_id;
50009
 
        _row.bomdata_item_number := _x.item_number;
50010
 
        _row.bomdata_uom_name := _x.uom_name;
50011
 
        _row.bomdata_item_descrip1 := _x.item_descrip1;
50012
 
        _row.bomdata_item_descrip2 := _x.item_descrip2;
50013
 
        _row.bomdata_itemdescription := _x.itemdescription;
50014
 
        _row.bomdata_batchsize := _batchsize;
50015
 
        _row.bomdata_qtyreq := _x.bomwork_qtyreq;
50016
 
        _row.bomdata_qtyfxd := _x.bomwork_qtyfxd;
50017
 
        _row.bomdata_qtyper := _x.bomwork_qtyper;
50018
 
        _row.bomdata_scrap := _x.bomwork_scrap;
50019
 
        _row.bomdata_createchild := _x.bomwork_createwo;
50020
 
        _row.bomdata_issuemethod := _x.issuemethod;
50021
 
        _row.bomdata_effective := _x.bomwork_effective;
50022
 
        _row.bomdata_expires := _x.bomwork_expires;
50023
 
        _row.bomdata_expired := _x.expired;
50024
 
        _row.bomdata_future := _x.future;
50025
 
        _row.bomdata_actunitcost := _x.actunitcost;
50026
 
        _row.bomdata_stdunitcost := _x.stdunitcost;
50027
 
        _row.bomdata_actextendedcost := _x.actextendedcost;
50028
 
        _row.bomdata_stdextendedcost := _x.stdextendedcost;
50029
 
        _row.bomdata_ecn := _x.bomwork_ecn;
50030
 
        _row.bomdata_char_id := _x.bomwork_char_id;
50031
 
        _row.bomdata_value := _x.bomwork_value;
50032
 
        _row.bomdata_notes := _x.bomwork_notes;
50033
 
        _row.bomdata_ref := _x.bomwork_ref;
50034
 
        RETURN NEXT _row;
50035
 
    END LOOP;
50036
 
    
50037
 
    PERFORM deleteBOMWorkset(_bomworksetid);
50038
 
 
50039
 
  ELSE
50040
 
 
50041
 
    FOR _x IN
50042
 
        SELECT bomhist_id, bomhist_parent_id, bomhist_level,
50043
 
               bomhistSequence(bomhist_seq_id) AS seq_ord,
50044
 
               bomhist_seqnumber, item_id, item_number, uom_name,
50045
 
               item_descrip1, item_descrip2,
50046
 
               (item_descrip1 || ' ' || item_descrip2) AS itemdescription,
50047
 
               bomhist_qtyreq, bomhist_qtyfxd, bomhist_qtyper, bomhist_scrap,
50048
 
               bomhist_createwo,
50049
 
       CASE WHEN (bomhist_issuemethod='S') THEN 'Push'
50050
 
            WHEN (bomhist_issuemethod='L') THEN 'Pull'
50051
 
            WHEN (bomhist_issuemethod='M') THEN 'Mixed'
50052
 
            ELSE 'Special'
50053
 
       END AS issuemethod,
50054
 
       bomhist_effective, bomhist_expires,
50055
 
       (bomhist_expires <= CURRENT_DATE) AS expired,
50056
 
       (bomhist_effective > CURRENT_DATE) AS future,
50057
 
       bomhist_actunitcost AS actunitcost,
50058
 
       bomhist_stdunitcost AS stdunitcost,
50059
 
       CASE WHEN item_type NOT IN ('R','T') THEN
50060
 
         (bomhist_qtyfxd/_batchsize + bomhist_qtyper) * (1 + bomhist_scrap) * bomhist_actunitcost
50061
 
       ELSE 0 END AS actextendedcost,
50062
 
       CASE WHEN item_type NOT IN ('R','T') THEN
50063
 
         (bomhist_qtyfxd/_batchsize + bomhist_qtyper) * (1 + bomhist_scrap) * bomhist_stdunitcost
50064
 
       ELSE 0 END AS stdextendedcost,
50065
 
       bomhist_char_id, bomhist_value, bomhist_notes, bomhist_ref 
50066
 
       FROM bomhist, item, uom 
50067
 
       WHERE ( (bomhist_item_id=item_id)
50068
 
       AND (item_inv_uom_id=uom_id)
50069
 
       AND (bomhist_rev_id=pRevisionid) )
50070
 
       AND (bomhist_expires > (CURRENT_DATE - pExpiredDays))
50071
 
       AND (bomhist_effective <= (CURRENT_DATE + pFutureDays))
50072
 
       UNION
50073
 
       SELECT -1, -1, 1,
50074
 
              '0',
50075
 
              NULL,-1, costelem_type AS bomdata_item_number, '',
50076
 
              '', '',
50077
 
              '',
50078
 
              NULL, NULL, NULL, NULL,
50079
 
              false,
50080
 
              '', NULL, NULL,
50081
 
              false,
50082
 
              false,
50083
 
              bomhist_actunitcost AS actunitcost,
50084
 
              bomhist_stdunitcost AS stdunitcost,
50085
 
              bomhist_actunitcost AS actextendedcost,
50086
 
              bomhist_stdunitcost AS stdextendedcost,
50087
 
              NULL,NULL,NULL,NULL 
50088
 
       FROM bomhist, costelem 
50089
 
       WHERE ((bomhist_rev_id=pRevisionid)
50090
 
       AND (costelem_id=bomhist_item_id))
50091
 
       ORDER BY seq_ord
50092
 
    LOOP
50093
 
        _row.bomdata_bomwork_id := _x.bomhist_id;
50094
 
        _row.bomdata_bomwork_parent_id := _x.bomhist_parent_id;
50095
 
        _row.bomdata_bomwork_level := _x.bomhist_level;
50096
 
        _row.bomdata_bomwork_seqnumber := _x.bomhist_seqnumber;
50097
 
        _row.bomdata_bomitem_id := -1;
50098
 
        _row.bomdata_item_id := _x.item_id;
50099
 
        _row.bomdata_item_number := _x.item_number;
50100
 
        _row.bomdata_uom_name := _x.uom_name;
50101
 
        _row.bomdata_item_descrip1 := _x.item_descrip1;
50102
 
        _row.bomdata_item_descrip2 := _x.item_descrip2;
50103
 
        _row.bomdata_itemdescription := _x.itemdescription;
50104
 
        _row.bomdata_batchsize := _batchsize;
50105
 
        _row.bomdata_qtyreq := _x.bomhist_qtyreq;
50106
 
        _row.bomdata_qtyfxd := _x.bomhist_qtyfxd;
50107
 
        _row.bomdata_qtyper := _x.bomhist_qtyper;
50108
 
        _row.bomdata_scrap := _x.bomhist_scrap;
50109
 
        _row.bomdata_createchild := _x.bomhist_createwo;
50110
 
        _row.bomdata_issuemethod := _x.issuemethod;
50111
 
        _row.bomdata_effective := _x.bomhist_effective;
50112
 
        _row.bomdata_expires := _x.bomhist_expires;
50113
 
        _row.bomdata_expired := _x.expired;
50114
 
        _row.bomdata_future := _x.future;
50115
 
        _row.bomdata_actunitcost := _x.actunitcost;
50116
 
        _row.bomdata_stdunitcost := _x.stdunitcost;
50117
 
        _row.bomdata_actextendedcost := _x.actextendedcost;
50118
 
        _row.bomdata_stdextendedcost := _x.stdextendedcost;
50119
 
        _row.bomdata_ecn := '';
50120
 
        _row.bomdata_char_id := _x.bomhist_char_id;
50121
 
        _row.bomdata_value := _x.bomhist_value;
50122
 
        _row.bomdata_notes := _x.bomhist_notes;
50123
 
        _row.bomdata_ref := _x.bomhist_ref;
50124
 
        RETURN NEXT _row;
50125
 
    END LOOP;
50126
 
  END IF;   
50127
 
 
50128
 
  RETURN;
50129
 
END;
50130
 
$_$;
50131
 
 
50132
 
 
50133
 
ALTER FUNCTION public.indentedbom(integer, integer, integer, integer) OWNER TO admin;
50134
 
 
50135
 
--
50136
 
--
50137
 
 
50138
 
CREATE FUNCTION indentedwhereused(integer) RETURNS integer
50139
 
    LANGUAGE plpgsql
50140
 
    AS $_$
50141
 
DECLARE
50142
 
  pItemid ALIAS FOR $1;
50143
 
  _indexid INTEGER;
50144
 
  _level INTEGER;
50145
 
 
50146
 
BEGIN
50147
 
 
50148
 
 
50149
 
  _indexid := (SELECT NEXTVAL('misc_index_seq'));
50150
 
  _level := 1;
50151
 
 
50152
 
  INSERT INTO bomwork
50153
 
  ( bomwork_set_id, bomwork_parent_id,
50154
 
    bomwork_level, bomwork_seqnumber,
50155
 
    bomwork_item_id, bomwork_item_type, bomwork_createwo,
50156
 
    bomwork_qtyfxd, bomwork_qtyper,
50157
 
    bomwork_scrap, bomwork_issuemethod,
50158
 
    bomwork_effective, bomwork_expires, bomwork_status,
50159
 
    bomwork_stdunitcost, bomwork_actunitcost )
50160
 
  SELECT _indexid, -1,
50161
 
         1, bomitem_seqnumber,
50162
 
         item_id, item_type, bomitem_createwo,
50163
 
         (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd),
50164
 
         (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper),
50165
 
         bomitem_scrap, bomitem_issuemethod,
50166
 
         bomitem_effective, bomitem_expires, 'U',
50167
 
         stdcost(item_id), actcost(item_id)
50168
 
  FROM bomitem, item
50169
 
  WHERE ((bomitem_item_id=pItemid)
50170
 
    AND (bomitem_parent_item_id=item_id)
50171
 
    AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1))
50172
 
    AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)));
50173
 
 
50174
 
  WHILE ( ( SELECT count(*)
50175
 
            FROM bomwork
50176
 
            WHERE ((bomwork_status='U')
50177
 
              AND (bomwork_set_id=_indexid)) ) > 0) LOOP
50178
 
 
50179
 
    _level := _level + 1;
50180
 
 
50181
 
    INSERT INTO bomwork
50182
 
    ( bomwork_set_id, bomwork_parent_id,
50183
 
      bomwork_level, bomwork_seqnumber,
50184
 
      bomwork_item_id, bomwork_item_type, bomwork_createwo,
50185
 
      bomwork_qtyfxd, bomwork_qtyper,
50186
 
      bomwork_scrap, bomwork_issuemethod,
50187
 
      bomwork_effective, bomwork_expires, bomwork_status,
50188
 
      bomwork_stdunitcost, bomwork_actunitcost )
50189
 
    SELECT _indexid, bomwork_id,
50190
 
           _level, bomitem_seqnumber,
50191
 
           item_id, item_type, bomitem_createwo,
50192
 
           (bomwork_qtyper * (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd)),
50193
 
           (bomwork_qtyper * (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper)),
50194
 
           bomitem_scrap, bomitem_issuemethod,
50195
 
           CASE WHEN bomitem_effective < bomwork_effective THEN
50196
 
             bomwork_effective
50197
 
           ELSE bomitem_effective END, 
50198
 
           CASE WHEN bomitem_expires > bomwork_expires THEN
50199
 
             bomwork_expires
50200
 
           ELSE bomitem_expires END,
50201
 
           'N',
50202
 
           stdcost(item_id), actcost(item_id)
50203
 
    FROM bomwork JOIN bomitem ON ( (bomitem_item_id=bomwork_item_id)
50204
 
                               AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1))
50205
 
                               AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) )
50206
 
                 JOIN item ON (item_id=bomitem_parent_item_id)
50207
 
    WHERE (bomwork_status='U');
50208
 
 
50209
 
    UPDATE bomwork
50210
 
    SET bomwork_status='C'
50211
 
    WHERE ((bomwork_status='U')
50212
 
      AND (bomwork_set_id=_indexid));
50213
 
 
50214
 
    UPDATE bomwork
50215
 
    SET bomwork_status='U'
50216
 
    WHERE ((bomwork_status='N')
50217
 
      AND (bomwork_set_id=_indexid));
50218
 
 
50219
 
  END LOOP;
50220
 
 
50221
 
  RETURN _indexid;
50222
 
END;
50223
 
$_$;
50224
 
 
50225
 
 
50226
 
ALTER FUNCTION public.indentedwhereused(integer) OWNER TO admin;
50227
 
 
50228
 
--
50229
 
--
50230
 
 
50231
 
CREATE FUNCTION indentedwo(integer, boolean, boolean, boolean) RETURNS SETOF wodata
50232
 
    LANGUAGE plpgsql
50233
 
    AS $_$
50234
 
DECLARE
50235
 
   pwoid ALIAS FOR $1;
50236
 
   pshowops ALIAS FOR $2;
50237
 
   pshowmatl ALIAS FOR $3; 
50238
 
   pshowindent ALIAS FOR $4;   
50239
 
  _row wodata%ROWTYPE;
50240
 
  _subrow wodata%ROWTYPE;  
50241
 
  _opx wodata%ROWTYPE;
50242
 
  _x RECORD;
50243
 
  _level INTEGER;
50244
 
   
50245
 
BEGIN 
50246
 
    --The wodata_id_type column is used to indicate the source of the wodata_id
50247
 
    --there are three different tables used wo, womatl and womatlvar
50248
 
    --wodata_id_type = 1 = wo_id
50249
 
    --wodata_id_type = 2 = womatl_id
50250
 
    --wodata_id_type = 3 = wooper_id
50251
 
    --initialise values
50252
 
    _level := 0;   
50253
 
    --get top level works orders
50254
 
    FOR _x IN
50255
 
       SELECT wo_id,wo_number,wo_subnumber,wo_status,wo_startdate,
50256
 
         wo_duedate,wo_adhoc,wo_itemsite_id,qtyAvailable(itemsite_id) AS availableqoh,
50257
 
         wo_qtyord,wo_qtyrcv,wo_prodnotes, item_number,
50258
 
         item_descrip1, item_descrip2, item_listprice, uom_name
50259
 
       FROM wo, itemsite, item, uom     
50260
 
       WHERE ((wo_id = pwoid)
50261
 
         AND (itemsite_id = wo_itemsite_id)
50262
 
         AND (itemsite_item_id=item_id)
50263
 
         AND (item_inv_uom_id=uom_id))      
50264
 
       ORDER BY wo_number, wo_subnumber
50265
 
    LOOP
50266
 
        _row.wodata_id := _x.wo_id;
50267
 
        _row.wodata_id_type := 1;            
50268
 
        _row.wodata_number := _x.wo_number;
50269
 
        _row.wodata_subnumber := _x.wo_subnumber;
50270
 
        _row.wodata_itemnumber := _x.item_number;
50271
 
        _row.wodata_descrip := _x.item_descrip1 || '-' || _x.item_descrip2;
50272
 
        _row.wodata_status := _x.wo_status;
50273
 
        _row.wodata_startdate := _x.wo_startdate;
50274
 
        _row.wodata_duedate := _x.wo_duedate;
50275
 
        _row.wodata_adhoc := _x.wo_adhoc;     
50276
 
        _row.wodata_itemsite_id := _x.wo_itemsite_id;
50277
 
        _row.wodata_custprice := _x.item_listprice;
50278
 
        _row.wodata_listprice := _x.item_listprice;
50279
 
        _row.wodata_qoh := _x.availableqoh;
50280
 
        _row.wodata_short := noneg(_x.wo_qtyord - _x.wo_qtyrcv);
50281
 
        _row.wodata_qtyrcv := _x.wo_qtyrcv;   
50282
 
        _row.wodata_qtyordreq := _x.wo_qtyord;   
50283
 
        _row.wodata_qtyuom := _x.uom_name;    
50284
 
        _row.wodata_scrap := 0;        
50285
 
        _row.wodata_notes := _x.wo_prodnotes;     
50286
 
        _row.wodata_level := _level;                
50287
 
        RETURN NEXT _row;
50288
 
        IF (pshowmatl AND NOT pshowops) THEN
50289
 
          --expand materials      
50290
 
          FOR _subrow IN
50291
 
             SELECT * FROM indentedwomatl(pwoid, _level)
50292
 
          LOOP                                                  
50293
 
            RETURN NEXT _subrow;
50294
 
          END LOOP;
50295
 
        END IF;
50296
 
        
50297
 
        IF ((pshowmatl OR pshowindent) AND NOT pshowops) THEN
50298
 
          --expand next level down               
50299
 
          FOR _subrow IN
50300
 
           SELECT * FROM indentedwo(_x.wo_id, NULL, _level + 1, pshowmatl, pshowindent) 
50301
 
          LOOP                                           
50302
 
            RETURN NEXT _subrow; 
50303
 
          END LOOP;
50304
 
        END IF;
50305
 
          
50306
 
        IF (pshowops) THEN
50307
 
         --expand materials not on operations   
50308
 
         IF (pshowmatl) THEN   
50309
 
           FOR _subrow IN
50310
 
             SELECT * FROM indentedwomatl(pwoid, -1, _level)
50311
 
           LOOP                                                  
50312
 
             RETURN NEXT _subrow;
50313
 
           END LOOP;
50314
 
         END IF;
50315
 
 
50316
 
         IF (pshowmatl OR pshowindent) THEN
50317
 
           --expand next level down             
50318
 
           FOR _subrow IN
50319
 
             SELECT * FROM indentedwo(_x.wo_id, -1, _level + 1,  pshowmatl, pshowindent) 
50320
 
           LOOP                                           
50321
 
             RETURN NEXT _subrow; 
50322
 
           END LOOP;
50323
 
         END IF;
50324
 
 
50325
 
         --expand opeartions
50326
 
         FOR _opx IN
50327
 
           SELECT * FROM xtmfg.indentedwoops(pwoid,_level)
50328
 
         LOOP
50329
 
           RETURN NEXT _opx;
50330
 
 
50331
 
           IF (pshowmatl) THEN  
50332
 
              --expand materials on operations      
50333
 
              FOR _subrow IN
50334
 
                 SELECT * FROM indentedwomatl(pwoid, _opx.wodata_id, _level + 1)
50335
 
              LOOP                                                  
50336
 
                RETURN NEXT _subrow;
50337
 
              END LOOP;
50338
 
           END IF;
50339
 
 
50340
 
           IF (pshowmatl OR pshowindent) THEN
50341
 
              --expand next level down             
50342
 
              FOR _subrow IN
50343
 
                SELECT * FROM indentedwo(_x.wo_id, _opx.wodata_id, _level + 2,  pshowmatl, pshowindent) 
50344
 
              LOOP                                           
50345
 
                RETURN NEXT _subrow; 
50346
 
              END LOOP;
50347
 
           END IF; 
50348
 
         END LOOP; 
50349
 
       END IF;                           
50350
 
  END LOOP;                     
50351
 
  RETURN;
50352
 
END;
50353
 
$_$;
50354
 
 
50355
 
 
50356
 
ALTER FUNCTION public.indentedwo(integer, boolean, boolean, boolean) OWNER TO admin;
50357
 
 
50358
 
--
50359
 
--
50360
 
 
50361
 
CREATE FUNCTION indentedwo(integer, integer, integer, boolean, boolean) RETURNS SETOF wodata
50362
 
    LANGUAGE plpgsql
50363
 
    AS $_$
50364
 
DECLARE
50365
 
   pwoid ALIAS FOR $1;   
50366
 
   pwooperid ALIAS FOR $2;
50367
 
   plevel ALIAS FOR $3;
50368
 
   pshowmatl ALIAS FOR $4; 
50369
 
   pshowindent ALIAS FOR $5;  
50370
 
  _row wodata%ROWTYPE;   
50371
 
  _opx wodata%ROWTYPE; 
50372
 
  _x RECORD;
50373
 
  _subx RECORD;
50374
 
  _index INTEGER;
50375
 
  _level INTEGER;
50376
 
  _qry TEXT;
50377
 
   
50378
 
BEGIN 
50379
 
    --The wodata id column is used to indicate the source of the id
50380
 
    --there are three different tables used wo, womatl and womatlvar
50381
 
    --wodata_id_type = 1 = wo_id
50382
 
    --wodata_id_type = 2 = womatl_id
50383
 
    --wodata_id_type = 3 = wooper_id
50384
 
    _level := (plevel + 1);    
50385
 
    --find all WO with the ordid of the next level up
50386
 
    _qry := 'SELECT wo_id,wo_number,wo_subnumber,wo_status,wo_startdate,wo_duedate,
50387
 
         wo_adhoc,wo_itemsite_id,qtyAvailable(itemsite_id) AS availableqoh,wo_qtyord,wo_qtyrcv, wo_prodnotes,
50388
 
         item_number,item_descrip1, item_descrip2, item_listprice, uom_name,
50389
 
         womatl_qtyiss, womatl_scrap, womatl_wooper_id
50390
 
       FROM itemsite,  wo, item, uom, womatl 
50391
 
       WHERE ((wo_ordid = ' || pwoid || ')
50392
 
         AND (wo_ordtype = ''W'')
50393
 
         AND (itemsite_item_id=item_id)
50394
 
         AND (item_inv_uom_id=uom_id)   
50395
 
         AND (wo_womatl_id=womatl_id)   
50396
 
         AND (wo_itemsite_id = itemsite_id) ';
50397
 
 
50398
 
    IF (pwooperid IS NOT NULL) THEN
50399
 
      _qry := _qry || ' AND (womatl_wooper_id=' || pwooperid || ') ';
50400
 
    END IF;               
50401
 
 
50402
 
    _qry := _qry || ') ORDER BY wo_number, wo_subnumber';
50403
 
 /* if (pwooperid IS NOT NULL) THEN
50404
 
    raise exception 'stop %',_qry;
50405
 
  END IF;*/
50406
 
    FOR _x IN
50407
 
      EXECUTE _qry
50408
 
    LOOP 
50409
 
        _row.wodata_id := _x.wo_id;
50410
 
        _row.wodata_id_type := 1;                     
50411
 
        _row.wodata_number := _x.wo_number;
50412
 
        _row.wodata_subnumber := _x.wo_subnumber;
50413
 
        _row.wodata_itemnumber := _x.item_number;
50414
 
        _row.wodata_descrip := _x.item_descrip1 || '-' || _x.item_descrip2;
50415
 
        _row.wodata_status := _x.wo_status;
50416
 
        _row.wodata_startdate := _x.wo_startdate;
50417
 
        _row.wodata_duedate := _x.wo_duedate;
50418
 
        _row.wodata_adhoc := _x.wo_adhoc;      
50419
 
        _row.wodata_itemsite_id := _x.wo_itemsite_id;        
50420
 
        _row.wodata_custprice := _x.item_listprice;
50421
 
        _row.wodata_listprice := _x.item_listprice;
50422
 
        _row.wodata_qoh := _x.availableqoh;
50423
 
        _row.wodata_short := noneg(_x.wo_qtyord - _x.wo_qtyrcv);
50424
 
        _row.wodata_qtyiss := _x.womatl_qtyiss;  
50425
 
        _row.wodata_qtyrcv := _x.wo_qtyrcv;   
50426
 
        _row.wodata_qtyordreq := _x.wo_qtyord; 
50427
 
        _row.wodata_scrap := _x.womatl_scrap;  
50428
 
        _row.wodata_notes := _x.wo_prodnotes;       
50429
 
        _row.wodata_level := plevel;                
50430
 
        RETURN NEXT _row;  
50431
 
        --if indentation require expand next level
50432
 
        IF (pshowindent AND pwooperid IS NULL) THEN
50433
 
          IF (pshowmatl AND pshowindent) THEN    
50434
 
            --get materials for this level
50435
 
            FOR _subx IN
50436
 
              SELECT * FROM indentedwomatl(_x.wo_id, plevel) 
50437
 
            LOOP                                            
50438
 
              RETURN NEXT _subx;
50439
 
            END LOOP;
50440
 
          END IF;
50441
 
 
50442
 
          IF (pshowindent) THEN  
50443
 
            --expand lower levels 
50444
 
            FOR _subx IN
50445
 
              SELECT * FROM indentedwo(_x.wo_id, NULL, _level, pshowmatl, pshowindent )
50446
 
            LOOP                                           
50447
 
              RETURN NEXT _subx; 
50448
 
            END LOOP; 
50449
 
          END IF;    
50450
 
            
50451
 
        ELSIF (pshowindent) THEN --Handle operations
50452
 
          --expand materials not on operations   
50453
 
          IF (pshowmatl) THEN   
50454
 
            FOR _subx IN
50455
 
              SELECT * FROM indentedwomatl(_x.wo_id, -1, plevel)
50456
 
            LOOP                                                  
50457
 
              RETURN NEXT _subx;
50458
 
            END LOOP;
50459
 
          END IF;
50460
 
 
50461
 
          --expand next level down not on operations
50462
 
          FOR _subx IN
50463
 
            SELECT * FROM indentedwo(_x.wo_id, -1, _level,  pshowmatl, pshowindent) 
50464
 
          LOOP                                           
50465
 
            RETURN NEXT _subx; 
50466
 
          END LOOP;
50467
 
          
50468
 
          --expand operations
50469
 
          FOR _opx IN
50470
 
            SELECT * FROM xtmfg.indentedwoops(_x.wo_id,plevel)
50471
 
          LOOP
50472
 
            RETURN NEXT _opx;
50473
 
 
50474
 
            IF (pshowmatl) THEN  
50475
 
              --expand materials on operations      
50476
 
              FOR _subx IN
50477
 
                 SELECT * FROM indentedwomatl(_x.wo_id, _opx.wodata_id, _level)
50478
 
              LOOP                                                  
50479
 
                RETURN NEXT _subx;
50480
 
                --      raise exception 'stop %',_opx.wodata_id;
50481
 
              END LOOP;
50482
 
            END IF;
50483
 
              
50484
 
            --expand next level down   
50485
 
            FOR _subx IN
50486
 
              SELECT * FROM indentedwo(_x.wo_id, _opx.wodata_id, _level + 2,  pshowmatl, pshowindent) 
50487
 
            LOOP                                        
50488
 
              RETURN NEXT _subx; 
50489
 
            END LOOP;
50490
 
              
50491
 
          END LOOP;
50492
 
        END IF;                       
50493
 
      END LOOP;                         
50494
 
  RETURN;
50495
 
END;
50496
 
$_$;
50497
 
 
50498
 
 
50499
 
ALTER FUNCTION public.indentedwo(integer, integer, integer, boolean, boolean) OWNER TO admin;
50500
 
 
50501
 
--
50502
 
--
50503
 
 
50504
 
CREATE FUNCTION indentedwomatl(integer, integer) RETURNS SETOF wodata
50505
 
    LANGUAGE plpgsql
50506
 
    AS $_$
50507
 
DECLARE
50508
 
   pwoid ALIAS FOR $1;   
50509
 
   plevel ALIAS FOR $2;
50510
 
  _subx RECORD;
50511
 
   
50512
 
BEGIN
50513
 
  FOR _subx IN
50514
 
    SELECT * FROM indentedwomatl(pwoid, NULL::integer, plevel)
50515
 
  LOOP
50516
 
    RETURN NEXT _subx;
50517
 
  END LOOP;        
50518
 
  RETURN;
50519
 
END;
50520
 
$_$;
50521
 
 
50522
 
 
50523
 
ALTER FUNCTION public.indentedwomatl(integer, integer) OWNER TO admin;
50524
 
 
50525
 
--
50526
 
--
50527
 
 
50528
 
CREATE FUNCTION indentedwomatl(integer, integer, integer) RETURNS SETOF wodata
50529
 
    LANGUAGE plpgsql
50530
 
    AS $_$
50531
 
DECLARE
50532
 
   pwoid ALIAS FOR $1;  
50533
 
   pwooperid ALIAS FOR $2; 
50534
 
   plevel ALIAS FOR $3;
50535
 
  _status TEXT; 
50536
 
  _subrow wodata%ROWTYPE;  
50537
 
  _subx RECORD;
50538
 
  _level INTEGER;
50539
 
  _qry TEXT;
50540
 
   
50541
 
BEGIN
50542
 
  --The wodata id column is used to indicate the source of the id
50543
 
  --there are three different tables used wo, womatl and womatlvar
50544
 
  --wodata_id_type = 1 = wo_id
50545
 
  --wodata_id_type = 2 = womatl_id
50546
 
  --wodata_id_type = 3 = wooper_id
50547
 
 
50548
 
  _qry := 'SELECT womatl_id, wo_number, wo_subnumber, 
50549
 
      wo_startdate, womatl_duedate, womatl_itemsite_id,
50550
 
      qtyAvailable(itemsite_id) AS availableqoh, womatl_qtyreq, womatl_qtyiss,
50551
 
      womatl_qtyper, womatl_qtyreq, womatl_scrap,
50552
 
      womatl_ref, womatl_notes, womatl_price, item_listprice,
50553
 
      item_number, item_descrip1, item_descrip2,
50554
 
      uom_name
50555
 
    FROM womatl, wo, itemsite, item, uom
50556
 
    WHERE ((wo_id = womatl_wo_id)
50557
 
     AND (wo_id = ' || pwoid || ')
50558
 
     AND (womatl_itemsite_id = itemsite_id)
50559
 
     AND (itemsite_item_id=item_id)
50560
 
     AND (womatl_uom_id=uom_id) ';
50561
 
 
50562
 
  IF (pwooperid IS NOT NULL) THEN
50563
 
    _qry := _qry || 'AND (womatl_wooper_id=' || pwooperid  || ')';
50564
 
  END IF;
50565
 
 
50566
 
  _qry := _qry || ') ORDER BY item_number;';
50567
 
  
50568
 
  _level := plevel + 1;    
50569
 
  SELECT wo_status FROM wo WHERE wo_id = pwoid  LIMIT 1 INTO _status;
50570
 
 
50571
 
  FOR _subx IN
50572
 
    EXECUTE _qry
50573
 
  LOOP
50574
 
    _subrow.wodata_id := _subx.womatl_id;
50575
 
    _subrow.wodata_id_type  := 2;       
50576
 
    _subrow.wodata_number := _subx.wo_number;
50577
 
    _subrow.wodata_subnumber := _subx.wo_subnumber;
50578
 
    _subrow.wodata_itemnumber := _subx.item_number;
50579
 
    _subrow.wodata_descrip := _subx.item_descrip1 || '-' || _subx.item_descrip2;
50580
 
    _subrow.wodata_status := _status;
50581
 
    _subrow.wodata_startdate := _subx.wo_startdate;
50582
 
    _subrow.wodata_duedate := _subx.womatl_duedate;
50583
 
    _subrow.wodata_itemsite_id := _subx.womatl_itemsite_id;    
50584
 
    _subrow.wodata_custprice := _subx.womatl_price;
50585
 
    _subrow.wodata_listprice := _subx.item_listprice;
50586
 
    _subrow.wodata_qoh := _subx.availableqoh;
50587
 
    IF((_subx.availableqoh > (_subx.womatl_qtyreq - _subx.womatl_qtyiss))) THEN
50588
 
      _subrow.wodata_short := 0;
50589
 
    ELSE
50590
 
      _subrow.wodata_short := (_subx.womatl_qtyreq - _subx.womatl_qtyiss) -  _subx.availableqoh;
50591
 
    END IF;
50592
 
    _subrow.wodata_qtyper := _subx.womatl_qtyper;
50593
 
    _subrow.wodata_qtyiss := _subx.womatl_qtyiss;         
50594
 
    _subrow.wodata_qtyordreq := _subx.womatl_qtyreq;     
50595
 
    _subrow.wodata_qtyuom := _subx.uom_name;   
50596
 
    _subrow.wodata_scrap := _subx.womatl_scrap;        
50597
 
    _subrow.wodata_notes := _subx.womatl_notes;
50598
 
    _subrow.wodata_ref := _subx.womatl_ref;       
50599
 
    _subrow.wodata_level := _level;                                   
50600
 
    RETURN NEXT _subrow; 
50601
 
  END LOOP;     
50602
 
        
50603
 
  RETURN;
50604
 
END;
50605
 
$_$;
50606
 
 
50607
 
 
50608
 
ALTER FUNCTION public.indentedwomatl(integer, integer, integer) OWNER TO admin;
50609
 
 
50610
 
--
50611
 
--
50612
 
 
50613
 
CREATE FUNCTION initeffectivextuser() RETURNS void
50614
 
    LANGUAGE plpgsql
50615
 
    AS $$
50616
 
BEGIN
50617
 
  -- Effective users use a temporary table to store the user information
50618
 
  -- and this function, called by the other functions, makes sure the temp
50619
 
  -- tables exist first.
50620
 
  PERFORM *
50621
 
     FROM pg_catalog.pg_class
50622
 
    WHERE relname = 'effective_user'
50623
 
      AND relnamespace = pg_catalog.pg_my_temp_schema();
50624
 
 
50625
 
  IF NOT FOUND THEN
50626
 
    CREATE TEMPORARY TABLE effective_user (
50627
 
      effective_key TEXT,
50628
 
      effective_value TEXT
50629
 
    );
50630
 
    CREATE UNIQUE INDEX effective_user_pkey ON effective_user (effective_key);
50631
 
  END IF;
50632
 
END;
50633
 
$$;
50634
 
 
50635
 
 
50636
 
ALTER FUNCTION public.initeffectivextuser() OWNER TO admin;
50637
 
 
50638
 
--
50639
 
--
50640
 
 
50641
 
CREATE FUNCTION initialdistribution(pitemsiteid integer, plocationid integer) RETURNS integer
50642
 
    LANGUAGE plpgsql
50643
 
    AS $$
50644
 
DECLARE
50645
 
  _itemlocid INTEGER;
50646
 
  _invhistid INTEGER;
50647
 
  _itemlocSeries INTEGER;
50648
 
  _r RECORD;
50649
 
 
50650
 
BEGIN
50651
 
 
50652
 
  IF ( (SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J')
50653
 
         FROM itemsite, item
50654
 
         WHERE ( (itemsite_item_id=item_id)
50655
 
          AND (itemsite_id=pItemsiteid) ) ) ) THEN
50656
 
    RETURN 0;
50657
 
  END IF;
50658
 
 
50659
 
  _itemlocSeries := NEXTVAL('itemloc_series_seq');
50660
 
 
50661
 
  IF ( ( SELECT (itemsite_controlmethod IN ('L', 'S'))
50662
 
         FROM itemsite
50663
 
         WHERE (itemsite_id=pItemsiteid) ) ) THEN
50664
 
 
50665
 
    FOR _r IN SELECT itemloc_id, itemloc_ls_id, itemloc_qty
50666
 
              FROM itemloc
50667
 
              WHERE (itemloc_itemsite_id=pItemsiteid) LOOP
50668
 
 
50669
 
      SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid;
50670
 
      INSERT INTO invhist
50671
 
      ( invhist_id, invhist_itemsite_id, invhist_series,
50672
 
        invhist_transtype, invhist_invqty,
50673
 
        invhist_qoh_before, invhist_qoh_after,
50674
 
        invhist_comments,
50675
 
        invhist_invuom, invhist_unitcost, invhist_hasdetail,
50676
 
        invhist_costmethod, invhist_value_before, invhist_value_after ) 
50677
 
      SELECT _invhistid, itemsite_id, _itemlocSeries,
50678
 
             'RL', 0,
50679
 
             _r.itemloc_qty, _r.itemloc_qty,
50680
 
             'Initial Distribution',
50681
 
             uom_name, stdCost(item_id), TRUE,
50682
 
             itemsite_costmethod, itemsite_value, itemsite_value
50683
 
      FROM item, itemsite, uom
50684
 
      WHERE ( (itemsite_item_id=item_id)
50685
 
       AND (item_inv_uom_id=uom_id)
50686
 
       AND (itemsite_controlmethod <> 'N')
50687
 
       AND (itemsite_id=pItemsiteid) );
50688
 
 
50689
 
      UPDATE itemloc
50690
 
      SET itemloc_location_id=pLocationid
50691
 
      WHERE (itemloc_id=_r.itemloc_id);
50692
 
 
50693
 
      INSERT INTO invdetail
50694
 
      ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id,
50695
 
        invdetail_qty, invdetail_qty_before, invdetail_qty_after )
50696
 
      VALUES
50697
 
      ( _invhistid, pLocationid, _r.itemloc_ls_id,
50698
 
        _r.itemloc_qty, 0, _r.itemloc_qty );
50699
 
 
50700
 
    END LOOP;
50701
 
 
50702
 
  ELSE
50703
 
    DELETE FROM itemloc
50704
 
    WHERE (itemloc_itemsite_id=pItemsiteid);
50705
 
 
50706
 
    SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid;
50707
 
    INSERT INTO invhist
50708
 
    ( invhist_id, invhist_itemsite_id, invhist_series,
50709
 
      invhist_transtype, invhist_invqty,
50710
 
      invhist_qoh_before, invhist_qoh_after,
50711
 
      invhist_comments,
50712
 
      invhist_invuom, invhist_unitcost, invhist_hasdetail,
50713
 
      invhist_costmethod, invhist_value_before, invhist_value_after  ) 
50714
 
    SELECT _invhistid, itemsite_id, _itemlocSeries,
50715
 
           'RL', 0,
50716
 
           itemsite_qtyonhand, itemsite_qtyonhand,
50717
 
           'Initial Distribution',
50718
 
           uom_name, stdCost(item_id), TRUE,
50719
 
           itemsite_costmethod, itemsite_value, itemsite_value
50720
 
    FROM item, itemsite, uom
50721
 
    WHERE ( (itemsite_item_id=item_id)
50722
 
     AND (item_inv_uom_id=uom_id)
50723
 
     AND (itemsite_controlmethod <> 'N')
50724
 
     AND (itemsite_id=pItemsiteid) );
50725
 
 
50726
 
    SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _itemlocid;
50727
 
    INSERT INTO itemloc
50728
 
    ( itemloc_id, itemloc_itemsite_id, itemloc_location_id,
50729
 
      itemloc_expiration, itemloc_qty )
50730
 
    SELECT _itemlocid, itemsite_id, pLocationid,
50731
 
           endOfTime(), itemsite_qtyonhand
50732
 
    FROM itemsite
50733
 
    WHERE (itemsite_id=pItemsiteid);
50734
 
 
50735
 
    INSERT INTO invdetail
50736
 
    ( invdetail_invhist_id, invdetail_location_id,
50737
 
      invdetail_qty, invdetail_qty_before, invdetail_qty_after )
50738
 
    SELECT _invhistid, pLocationid,
50739
 
           itemsite_qtyonhand, 0, itemsite_qtyonhand
50740
 
    FROM itemsite
50741
 
    WHERE (itemsite_id=pItemsiteid);
50742
 
 
50743
 
  END IF;
50744
 
 
50745
 
  RETURN _itemlocid;
50746
 
 
50747
 
END;
50748
 
$$;
50749
 
 
50750
 
 
50751
 
ALTER FUNCTION public.initialdistribution(pitemsiteid integer, plocationid integer) OWNER TO admin;
50752
 
 
50753
 
--
50754
 
--
50755
 
 
50756
 
CREATE TABLE apopen (
50757
 
    apopen_id integer DEFAULT nextval(('"apopen_apopen_id_seq"'::text)::regclass) NOT NULL,
50758
 
    apopen_docdate date,
50759
 
    apopen_duedate date,
50760
 
    apopen_terms_id integer,
50761
 
    apopen_vend_id integer,
50762
 
    apopen_doctype character(1),
50763
 
    apopen_docnumber text,
50764
 
    apopen_amount numeric(20,2),
50765
 
    apopen_notes text,
50766
 
    apopen_posted boolean,
50767
 
    apopen_reference text,
50768
 
    apopen_invcnumber text,
50769
 
    apopen_ponumber text,
50770
 
    apopen_journalnumber integer,
50771
 
    apopen_paid numeric(20,2) DEFAULT 0,
50772
 
    apopen_open boolean,
50773
 
    apopen_username text,
50774
 
    apopen_discount boolean DEFAULT false NOT NULL,
50775
 
    apopen_accnt_id integer DEFAULT (-1),
50776
 
    apopen_curr_id integer DEFAULT basecurrid(),
50777
 
    apopen_closedate date,
50778
 
    apopen_distdate date,
50779
 
    apopen_void boolean DEFAULT false NOT NULL,
50780
 
    apopen_curr_rate numeric NOT NULL,
50781
 
    apopen_discountable_amount numeric(20,2) DEFAULT 0,
50782
 
    apopen_status text,
50783
 
    CONSTRAINT apopen_apopen_status_check CHECK ((((apopen_status = 'O'::text) OR (apopen_status = 'H'::text)) OR (apopen_status = 'C'::text))),
50784
 
    CONSTRAINT apopen_apopen_status_notnull CHECK ((apopen_status IS NOT NULL))
50785
 
);
50786
 
 
50787
 
 
50788
 
ALTER TABLE public.apopen OWNER TO admin;
50789
 
 
50790
 
--
50791
 
--
50792
 
 
50793
 
COMMENT ON TABLE apopen IS 'Accounts Payable (A/P) open Items information';
50794
 
 
50795
 
 
50796
 
--
50797
 
--
50798
 
 
50799
 
CREATE TABLE curr_symbol (
50800
 
    curr_id integer NOT NULL,
50801
 
    curr_base boolean DEFAULT false NOT NULL,
50802
 
    curr_name character varying(50) NOT NULL,
50803
 
    curr_symbol character varying(9) NOT NULL,
50804
 
    curr_abbr character varying(3) NOT NULL
50805
 
);
50806
 
 
50807
 
 
50808
 
ALTER TABLE public.curr_symbol OWNER TO admin;
50809
 
 
50810
 
--
50811
 
--
50812
 
 
50813
 
COMMENT ON TABLE curr_symbol IS 'Currency Names, Symbols, and Abbreviations';
50814
 
 
50815
 
 
50816
 
--
50817
 
--
50818
 
 
50819
 
CREATE TABLE terms (
50820
 
    terms_id integer DEFAULT nextval(('terms_terms_id_seq'::text)::regclass) NOT NULL,
50821
 
    terms_code text NOT NULL,
50822
 
    terms_descrip text,
50823
 
    terms_type character(1),
50824
 
    terms_duedays integer,
50825
 
    terms_discdays integer,
50826
 
    terms_discprcnt numeric(10,6),
50827
 
    terms_cutoffday integer,
50828
 
    terms_ap boolean,
50829
 
    terms_ar boolean,
50830
 
    terms_fincharg boolean DEFAULT true NOT NULL,
50831
 
    CONSTRAINT terms_terms_code_check CHECK ((terms_code <> ''::text))
50832
 
);
50833
 
 
50834
 
 
50835
 
ALTER TABLE public.terms OWNER TO admin;
50836
 
 
50837
 
--
50838
 
--
50839
 
 
50840
 
COMMENT ON TABLE terms IS 'Billing Terms information';
50841
 
 
50842
 
 
50843
 
--
50844
 
--
50845
 
 
50846
 
CREATE TABLE vendinfo (
50847
 
    vend_id integer DEFAULT nextval(('vend_vend_id_seq'::text)::regclass) NOT NULL,
50848
 
    vend_name text,
50849
 
    vend_lastpurchdate date,
50850
 
    vend_active boolean,
50851
 
    vend_po boolean,
50852
 
    vend_comments text,
50853
 
    vend_pocomments text,
50854
 
    vend_number text NOT NULL,
50855
 
    vend_1099 boolean,
50856
 
    vend_exported boolean,
50857
 
    vend_fobsource character(1),
50858
 
    vend_fob text,
50859
 
    vend_terms_id integer,
50860
 
    vend_shipvia text,
50861
 
    vend_vendtype_id integer,
50862
 
    vend_qualified boolean,
50863
 
    vend_ediemail text,
50864
 
    vend_ediemailbody text,
50865
 
    vend_edisubject text,
50866
 
    vend_edifilename text,
50867
 
    vend_accntnum text,
50868
 
    vend_emailpodelivery boolean,
50869
 
    vend_restrictpurch boolean,
50870
 
    vend_edicc text,
50871
 
    vend_curr_id integer DEFAULT basecurrid(),
50872
 
    vend_cntct1_id integer,
50873
 
    vend_cntct2_id integer,
50874
 
    vend_addr_id integer,
50875
 
    vend_match boolean DEFAULT false NOT NULL,
50876
 
    vend_ach_enabled boolean DEFAULT false NOT NULL,
50877
 
    vend_ach_accnttype text,
50878
 
    vend_ach_use_vendinfo boolean DEFAULT true NOT NULL,
50879
 
    vend_ach_indiv_number text DEFAULT ''::text NOT NULL,
50880
 
    vend_ach_indiv_name text DEFAULT ''::text NOT NULL,
50881
 
    vend_ediemailhtml boolean DEFAULT false NOT NULL,
50882
 
    vend_ach_routingnumber bytea DEFAULT '\x00'::bytea NOT NULL,
50883
 
    vend_ach_accntnumber bytea DEFAULT '\x00'::bytea NOT NULL,
50884
 
    vend_taxzone_id integer,
50885
 
    vend_accnt_id integer,
50886
 
    vend_expcat_id integer DEFAULT (-1),
50887
 
    vend_tax_id integer DEFAULT (-1),
50888
 
    CONSTRAINT vendinfo_vend_ach_accnttype_check CHECK (((vend_ach_accnttype = 'K'::text) OR (vend_ach_accnttype = 'C'::text))),
50889
 
    CONSTRAINT vendinfo_vend_number_check CHECK ((vend_number <> ''::text))
50890
 
);
50891
 
 
50892
 
 
50893
 
ALTER TABLE public.vendinfo OWNER TO admin;
50894
 
 
50895
 
--
50896
 
--
50897
 
 
50898
 
COMMENT ON TABLE vendinfo IS 'Vendor information';
50899
 
 
50900
 
 
50901
 
--
50902
 
--
50903
 
 
50904
 
COMMENT ON COLUMN vendinfo.vend_ach_accnttype IS 'Type of bank account: K = checKing, C = Cash = savings. These values were chosen to be consistent with bankaccnt_type.';
50905
 
 
50906
 
 
50907
 
SET search_path = api, pg_catalog;
50908
 
 
50909
 
--
50910
 
--
50911
 
 
50912
 
CREATE VIEW apmemo AS
50913
 
    SELECT vendinfo.vend_number AS vendor_number, apopen.apopen_docdate AS document_date, apopen.apopen_duedate AS due_date, CASE WHEN (apopen.apopen_doctype = 'C'::bpchar) THEN 'Credit Memo'::text ELSE 'Debit Memo'::text END AS document_type, apopen.apopen_docnumber AS document_number, apopen.apopen_ponumber AS po_number, apopen.apopen_journalnumber AS journal_number, terms.terms_code AS terms, curr.curr_abbr AS currency, apopen.apopen_amount AS amount, apopen.apopen_paid AS paid, (apopen.apopen_amount - apopen.apopen_paid) AS balance, apopen.apopen_notes AS notes, CASE WHEN (apopen.apopen_accnt_id = (-1)) THEN NULL::text ELSE public.formatglaccount(apopen.apopen_accnt_id) END AS alternate_prepaid_account FROM (((public.apopen LEFT JOIN public.vendinfo ON ((vendinfo.vend_id = apopen.apopen_vend_id))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = apopen.apopen_curr_id))) LEFT JOIN public.terms ON ((terms.terms_id = apopen.apopen_terms_id))) WHERE (apopen.apopen_doctype = ANY (ARRAY['C'::bpchar, 'D'::bpchar]));
50914
 
 
50915
 
 
50916
 
ALTER TABLE api.apmemo OWNER TO admin;
50917
 
 
50918
 
--
50919
 
--
50920
 
 
50921
 
COMMENT ON VIEW apmemo IS 'A/P Credit and Debit Memo';
50922
 
 
50923
 
 
50924
 
SET search_path = public, pg_catalog;
50925
 
 
50926
 
--
50927
 
--
50928
 
 
50929
 
CREATE FUNCTION insertapmemo(api.apmemo) RETURNS boolean
50930
 
    LANGUAGE plpgsql
50931
 
    AS $_$
50932
 
DECLARE
50933
 
  pNew ALIAS FOR $1;
50934
 
  _result INTEGER;
50935
 
 
50936
 
BEGIN
50937
 
  IF (pNew.document_type = 'Credit Memo') THEN
50938
 
    SELECT createAPCreditMemo( getVendId(pNew.vendor_number),
50939
 
                               pNew.document_number,
50940
 
                               pNew.po_number,
50941
 
                               pNew.document_date,
50942
 
                               pNew.amount,
50943
 
                               pNew.notes,
50944
 
                               getGLAccntId(pNew.alternate_prepaid_account),
50945
 
                               pNew.due_date,
50946
 
                               getTermsId(pNew.terms) ) INTO _result;
50947
 
    IF (_result <= 0) THEN
50948
 
      RAISE EXCEPTION 'Function createAPCreditMemo failed with result = %', _result;
50949
 
    END IF;
50950
 
  ELSE
50951
 
    IF (pNew.document_type = 'Debit Memo') THEN
50952
 
      SELECT createAPDebitMemo( null, getVendId(pNew.vendor_number),
50953
 
                                pNew.journal_number,
50954
 
                                pNew.document_number,
50955
 
                                pNew.po_number,
50956
 
                                pNew.document_date,
50957
 
                                pNew.amount,
50958
 
                                pNew.notes,
50959
 
                                getGLAccntId(pNew.alternate_prepaid_account),
50960
 
                                pNew.due_date,
50961
 
                                getTermsId(pNew.terms),
50962
 
                                COALESCE(getCurrId(pNew.currency), baseCurrId()) ) INTO _result;
50963
 
      IF (_result <= 0) THEN
50964
 
        RAISE EXCEPTION 'Function createAPDebitMemo failed with result = %', _result;
50965
 
      END IF;
50966
 
    ELSE
50967
 
      RAISE EXCEPTION 'Function insertAPMemo failed, invalid Document Type';
50968
 
    END IF;
50969
 
  END IF;
50970
 
 
50971
 
  RETURN TRUE;
50972
 
END;
50973
 
$_$;
50974
 
 
50975
 
 
50976
 
ALTER FUNCTION public.insertapmemo(api.apmemo) OWNER TO admin;
50977
 
 
50978
 
--
50979
 
--
50980
 
 
50981
 
CREATE TABLE aropen (
50982
 
    aropen_id integer DEFAULT nextval(('"aropen_aropen_id_seq"'::text)::regclass) NOT NULL,
50983
 
    aropen_docdate date NOT NULL,
50984
 
    aropen_duedate date NOT NULL,
50985
 
    aropen_terms_id integer,
50986
 
    aropen_cust_id integer,
50987
 
    aropen_doctype character(1),
50988
 
    aropen_docnumber text,
50989
 
    aropen_applyto text,
50990
 
    aropen_ponumber text,
50991
 
    aropen_amount numeric(20,2) NOT NULL,
50992
 
    aropen_notes text,
50993
 
    aropen_posted boolean DEFAULT false NOT NULL,
50994
 
    aropen_salesrep_id integer,
50995
 
    aropen_commission_due numeric(20,2),
50996
 
    aropen_commission_paid boolean DEFAULT false,
50997
 
    aropen_ordernumber text,
50998
 
    aropen_cobmisc_id integer DEFAULT (-1),
50999
 
    aropen_journalnumber integer,
51000
 
    aropen_paid numeric(20,2) DEFAULT 0,
51001
 
    aropen_open boolean,
51002
 
    aropen_username text,
51003
 
    aropen_rsncode_id integer,
51004
 
    aropen_salescat_id integer DEFAULT (-1),
51005
 
    aropen_accnt_id integer DEFAULT (-1),
51006
 
    aropen_curr_id integer DEFAULT basecurrid(),
51007
 
    aropen_closedate date,
51008
 
    aropen_distdate date,
51009
 
    aropen_curr_rate numeric NOT NULL,
51010
 
    aropen_discount boolean DEFAULT false NOT NULL,
51011
 
    aropen_fincharg_date date,
51012
 
    aropen_fincharg_amount numeric(20,2)
51013
 
);
51014
 
 
51015
 
 
51016
 
ALTER TABLE public.aropen OWNER TO admin;
51017
 
 
51018
 
--
51019
 
--
51020
 
 
51021
 
COMMENT ON TABLE aropen IS 'Accounts Receivable (A/R) open Items information';
51022
 
 
51023
 
 
51024
 
--
51025
 
--
51026
 
 
51027
 
CREATE TABLE custinfo (
51028
 
    cust_id integer DEFAULT nextval(('cust_cust_id_seq'::text)::regclass) NOT NULL,
51029
 
    cust_active boolean NOT NULL,
51030
 
    cust_custtype_id integer,
51031
 
    cust_salesrep_id integer,
51032
 
    cust_commprcnt numeric(10,6),
51033
 
    cust_name text,
51034
 
    cust_creditlmt integer,
51035
 
    cust_creditrating text,
51036
 
    cust_financecharge boolean,
51037
 
    cust_backorder boolean NOT NULL,
51038
 
    cust_partialship boolean NOT NULL,
51039
 
    cust_terms_id integer,
51040
 
    cust_discntprcnt numeric(10,6) NOT NULL,
51041
 
    cust_balmethod character(1) NOT NULL,
51042
 
    cust_ffshipto boolean NOT NULL,
51043
 
    cust_shipform_id integer,
51044
 
    cust_shipvia text,
51045
 
    cust_blanketpos boolean NOT NULL,
51046
 
    cust_shipchrg_id integer NOT NULL,
51047
 
    cust_creditstatus character(1) NOT NULL,
51048
 
    cust_comments text,
51049
 
    cust_ffbillto boolean NOT NULL,
51050
 
    cust_usespos boolean NOT NULL,
51051
 
    cust_number text NOT NULL,
51052
 
    cust_dateadded date DEFAULT ('now'::text)::date,
51053
 
    cust_exported boolean DEFAULT false,
51054
 
    cust_emaildelivery boolean DEFAULT false,
51055
 
    cust_ediemail text,
51056
 
    cust_edisubject text,
51057
 
    cust_edifilename text,
51058
 
    cust_ediemailbody text,
51059
 
    cust_autoupdatestatus boolean NOT NULL,
51060
 
    cust_autoholdorders boolean NOT NULL,
51061
 
    cust_edicc text,
51062
 
    cust_ediprofile_id integer,
51063
 
    cust_preferred_warehous_id integer DEFAULT (-1) NOT NULL,
51064
 
    cust_curr_id integer DEFAULT basecurrid(),
51065
 
    cust_creditlmt_curr_id integer DEFAULT basecurrid(),
51066
 
    cust_cntct_id integer,
51067
 
    cust_corrcntct_id integer,
51068
 
    cust_soemaildelivery boolean DEFAULT false,
51069
 
    cust_soediemail text,
51070
 
    cust_soedisubject text,
51071
 
    cust_soedifilename text,
51072
 
    cust_soediemailbody text,
51073
 
    cust_soedicc text,
51074
 
    cust_soediprofile_id integer,
51075
 
    cust_gracedays integer,
51076
 
    cust_ediemailhtml boolean DEFAULT false NOT NULL,
51077
 
    cust_soediemailhtml boolean DEFAULT false NOT NULL,
51078
 
    cust_taxzone_id integer,
51079
 
    cust_statementcycle text,
51080
 
    CONSTRAINT custinfo_balmethod_check CHECK (((cust_balmethod = 'B'::bpchar) OR (cust_balmethod = 'O'::bpchar))),
51081
 
    CONSTRAINT custinfo_creditstatus_check CHECK ((((cust_creditstatus = 'G'::bpchar) OR (cust_creditstatus = 'W'::bpchar)) OR (cust_creditstatus = 'H'::bpchar))),
51082
 
    CONSTRAINT custinfo_cust_number_check CHECK ((cust_number <> ''::text))
51083
 
);
51084
 
 
51085
 
 
51086
 
ALTER TABLE public.custinfo OWNER TO admin;
51087
 
 
51088
 
--
51089
 
--
51090
 
 
51091
 
COMMENT ON TABLE custinfo IS 'Customer information';
51092
 
 
51093
 
 
51094
 
--
51095
 
--
51096
 
 
51097
 
COMMENT ON COLUMN custinfo.cust_ediemail IS 'Deprecated column - DO NOT USE';
51098
 
 
51099
 
 
51100
 
--
51101
 
--
51102
 
 
51103
 
COMMENT ON COLUMN custinfo.cust_edisubject IS 'Deprecated column - DO NOT USE';
51104
 
 
51105
 
 
51106
 
--
51107
 
--
51108
 
 
51109
 
COMMENT ON COLUMN custinfo.cust_edifilename IS 'Deprecated column - DO NOT USE';
51110
 
 
51111
 
 
51112
 
--
51113
 
--
51114
 
 
51115
 
COMMENT ON COLUMN custinfo.cust_ediemailbody IS 'Deprecated column - DO NOT USE';
51116
 
 
51117
 
 
51118
 
--
51119
 
--
51120
 
 
51121
 
COMMENT ON COLUMN custinfo.cust_edicc IS 'Deprecated column - DO NOT USE';
51122
 
 
51123
 
 
51124
 
--
51125
 
--
51126
 
 
51127
 
COMMENT ON COLUMN custinfo.cust_ediprofile_id IS 'Deprecated column - DO NOT USE';
51128
 
 
51129
 
 
51130
 
--
51131
 
--
51132
 
 
51133
 
COMMENT ON COLUMN custinfo.cust_soediemail IS 'Deprecated column - DO NOT USE';
51134
 
 
51135
 
 
51136
 
--
51137
 
--
51138
 
 
51139
 
COMMENT ON COLUMN custinfo.cust_soedisubject IS 'Deprecated column - DO NOT USE';
51140
 
 
51141
 
 
51142
 
--
51143
 
--
51144
 
 
51145
 
COMMENT ON COLUMN custinfo.cust_soedifilename IS 'Deprecated column - DO NOT USE';
51146
 
 
51147
 
 
51148
 
--
51149
 
--
51150
 
 
51151
 
COMMENT ON COLUMN custinfo.cust_soediemailbody IS 'Deprecated column - DO NOT USE';
51152
 
 
51153
 
 
51154
 
--
51155
 
--
51156
 
 
51157
 
COMMENT ON COLUMN custinfo.cust_soedicc IS 'Deprecated column - DO NOT USE';
51158
 
 
51159
 
 
51160
 
--
51161
 
--
51162
 
 
51163
 
COMMENT ON COLUMN custinfo.cust_soediprofile_id IS 'Deprecated column - DO NOT USE';
51164
 
 
51165
 
 
51166
 
--
51167
 
--
51168
 
 
51169
 
COMMENT ON COLUMN custinfo.cust_ediemailhtml IS 'Deprecated column - DO NOT USE';
51170
 
 
51171
 
 
51172
 
--
51173
 
--
51174
 
 
51175
 
COMMENT ON COLUMN custinfo.cust_soediemailhtml IS 'Deprecated column - DO NOT USE';
51176
 
 
51177
 
 
51178
 
--
51179
 
--
51180
 
 
51181
 
CREATE TABLE rsncode (
51182
 
    rsncode_id integer NOT NULL,
51183
 
    rsncode_code text NOT NULL,
51184
 
    rsncode_descrip text,
51185
 
    rsncode_doctype text,
51186
 
    CONSTRAINT rsncode_rsncode_code_check CHECK ((rsncode_code <> ''::text))
51187
 
);
51188
 
 
51189
 
 
51190
 
ALTER TABLE public.rsncode OWNER TO admin;
51191
 
 
51192
 
--
51193
 
--
51194
 
 
51195
 
COMMENT ON TABLE rsncode IS 'Debit/Credit Memo Reason Code information';
51196
 
 
51197
 
 
51198
 
--
51199
 
--
51200
 
 
51201
 
CREATE TABLE salescat (
51202
 
    salescat_id integer NOT NULL,
51203
 
    salescat_active boolean,
51204
 
    salescat_name text NOT NULL,
51205
 
    salescat_descrip text,
51206
 
    salescat_sales_accnt_id integer,
51207
 
    salescat_prepaid_accnt_id integer,
51208
 
    salescat_ar_accnt_id integer,
51209
 
    CONSTRAINT salescat_salescat_name_check CHECK ((salescat_name <> ''::text))
51210
 
);
51211
 
 
51212
 
 
51213
 
ALTER TABLE public.salescat OWNER TO admin;
51214
 
 
51215
 
--
51216
 
--
51217
 
 
51218
 
COMMENT ON TABLE salescat IS 'Sales Category information';
51219
 
 
51220
 
 
51221
 
--
51222
 
--
51223
 
 
51224
 
CREATE TABLE salesrep (
51225
 
    salesrep_id integer DEFAULT nextval(('salesrep_salesrep_id_seq'::text)::regclass) NOT NULL,
51226
 
    salesrep_active boolean,
51227
 
    salesrep_number text NOT NULL,
51228
 
    salesrep_name text,
51229
 
    salesrep_commission numeric(8,4),
51230
 
    salesrep_method character(1),
51231
 
    salesrep_emp_id integer,
51232
 
    CONSTRAINT salesrep_salesrep_number_check CHECK ((salesrep_number <> ''::text))
51233
 
);
51234
 
 
51235
 
 
51236
 
ALTER TABLE public.salesrep OWNER TO admin;
51237
 
 
51238
 
--
51239
 
--
51240
 
 
51241
 
COMMENT ON TABLE salesrep IS 'Sales Representative information';
51242
 
 
51243
 
 
51244
 
--
51245
 
--
51246
 
 
51247
 
COMMENT ON COLUMN salesrep.salesrep_emp_id IS 'DEPRECATED - the relationship between Sales Rep and Employee is now maintained through the crmacct table.';
51248
 
 
51249
 
 
51250
 
SET search_path = api, pg_catalog;
51251
 
 
51252
 
--
51253
 
--
51254
 
 
51255
 
CREATE VIEW armemo AS
51256
 
    SELECT custinfo.cust_number AS customer_number, aropen.aropen_docdate AS document_date, aropen.aropen_duedate AS due_date, CASE WHEN (aropen.aropen_doctype = 'C'::bpchar) THEN 'Credit Memo'::text ELSE 'Debit Memo'::text END AS document_type, aropen.aropen_docnumber AS document_number, aropen.aropen_applyto AS order_number, aropen.aropen_journalnumber AS journal_number, rsncode.rsncode_code AS reason_code, terms.terms_code AS terms, salesrep.salesrep_number AS sales_rep, curr.curr_abbr AS currency, aropen.aropen_amount AS amount, aropen.aropen_paid AS paid, (aropen.aropen_amount - aropen.aropen_paid) AS balance, aropen.aropen_commission_due AS commission_due, aropen.aropen_commission_paid AS commission_paid, aropen.aropen_notes AS notes, salescat.salescat_name AS alternate_prepaid_sales_category, CASE WHEN (aropen.aropen_accnt_id = (-1)) THEN NULL::text ELSE public.formatglaccount(aropen.aropen_accnt_id) END AS alternate_prepaid_account FROM ((((((public.aropen LEFT JOIN public.custinfo ON ((custinfo.cust_id = aropen.aropen_cust_id))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = aropen.aropen_curr_id))) LEFT JOIN public.salesrep ON ((salesrep.salesrep_id = aropen.aropen_salesrep_id))) LEFT JOIN public.terms ON ((terms.terms_id = aropen.aropen_terms_id))) LEFT JOIN public.salescat ON ((salescat.salescat_id = aropen.aropen_salescat_id))) LEFT JOIN public.rsncode ON ((rsncode.rsncode_id = aropen.aropen_rsncode_id))) WHERE (aropen.aropen_doctype = ANY (ARRAY['C'::bpchar, 'D'::bpchar]));
51257
 
 
51258
 
 
51259
 
ALTER TABLE api.armemo OWNER TO admin;
51260
 
 
51261
 
--
51262
 
--
51263
 
 
51264
 
COMMENT ON VIEW armemo IS 'A/R Credit and Debit Memo';
51265
 
 
51266
 
 
51267
 
SET search_path = public, pg_catalog;
51268
 
 
51269
 
--
51270
 
--
51271
 
 
51272
 
CREATE FUNCTION insertarmemo(api.armemo) RETURNS boolean
51273
 
    LANGUAGE plpgsql
51274
 
    AS $_$
51275
 
DECLARE
51276
 
  pNew ALIAS FOR $1;
51277
 
  _result INTEGER;
51278
 
 
51279
 
BEGIN
51280
 
  IF (pNew.document_type = 'Credit Memo') THEN
51281
 
    SELECT createARCreditMemo( NULL,
51282
 
                               getCustId(pNew.customer_number),
51283
 
                               pNew.document_number,
51284
 
                               pNew.order_number,
51285
 
                               pNew.document_date,
51286
 
                               pNew.amount,
51287
 
                               pNew.notes,
51288
 
                               getRsnId(pNew.reason_code),
51289
 
                               getSalescatId(pNew.alternate_prepaid_sales_category),
51290
 
                               getGLAccntId(pNew.alternate_prepaid_account),
51291
 
                               pNew.due_date,
51292
 
                               getTermsId(pNew.terms),
51293
 
                               getSalesrepId(pNew.sales_rep),
51294
 
                               pNew.commission_due,
51295
 
                               pNew.journal_number,
51296
 
                               COALESCE(getCurrId(pNew.currency), baseCurrId()) ) INTO _result;
51297
 
    IF (_result <= 0) THEN
51298
 
      RAISE EXCEPTION 'Function createARCreditMemo failed with result = %', _result;
51299
 
    END IF;
51300
 
  ELSE
51301
 
    IF (pNew.document_type = 'Debit Memo') THEN
51302
 
      SELECT createARDebitMemo( null, getCustId(pNew.customer_number),
51303
 
                                pNew.journal_number,
51304
 
                                pNew.document_number,
51305
 
                                pNew.order_number,
51306
 
                                pNew.document_date,
51307
 
                                pNew.amount,
51308
 
                                pNew.notes,
51309
 
                                getRsnId(pNew.reason_code),
51310
 
                                getSalescatId(pNew.alternate_prepaid_sales_category),
51311
 
                                getGLAccntId(pNew.alternate_prepaid_account),
51312
 
                                pNew.due_date,
51313
 
                                getTermsId(pNew.terms),
51314
 
                                getSalesrepId(pNew.sales_rep),
51315
 
                                pNew.commission_due,
51316
 
                                COALESCE(getCurrId(pNew.currency), baseCurrId()) ) INTO _result;
51317
 
      IF (_result <= 0) THEN
51318
 
        RAISE EXCEPTION 'Function createARDebitMemo failed with result = %', _result;
51319
 
      END IF;
51320
 
    ELSE
51321
 
      RAISE EXCEPTION 'Function insertARMemo failed, invalid Document Type';
51322
 
    END IF;
51323
 
  END IF;
51324
 
 
51325
 
  RETURN TRUE;
51326
 
END;
51327
 
$_$;
51328
 
 
51329
 
 
51330
 
ALTER FUNCTION public.insertarmemo(api.armemo) OWNER TO admin;
51331
 
 
51332
 
--
51333
 
--
51334
 
 
51335
 
CREATE FUNCTION insertccard(text, boolean, text, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, text) RETURNS boolean
51336
 
    LANGUAGE plpgsql
51337
 
    AS $_$
51338
 
DECLARE
51339
 
  pCustomer ALIAS FOR $1;
51340
 
  pActive ALIAS FOR $2;
51341
 
  pType ALIAS FOR $3;
51342
 
  pNumber ALIAS FOR $4;
51343
 
  pName ALIAS FOR $5;
51344
 
  pAddr1 ALIAS FOR $6;
51345
 
  pAddr2 ALIAS FOR $7;
51346
 
  pCity ALIAS FOR $8;
51347
 
  pState ALIAS FOR $9;
51348
 
  pPostal ALIAS FOR $10;
51349
 
  pCountry ALIAS FOR $11;
51350
 
  pMonth ALIAS FOR $12;
51351
 
  pYear ALIAS FOR $13;
51352
 
  pKey ALIAS FOR $14;
51353
 
  _type CHAR;
51354
 
  _number TEXT;
51355
 
  _month INTEGER;
51356
 
  _year INTEGER;
51357
 
  _result INTEGER;
51358
 
 
51359
 
BEGIN
51360
 
  --Initialize
51361
 
  _number = CAST(encode(pNumber, 'escape') AS text);
51362
 
  _month = CAST(encode(pMonth, 'escape') AS integer);
51363
 
  _year = CAST(encode(pYear, 'escape') AS integer);
51364
 
 
51365
 
  -- Check Card holder info
51366
 
  IF (pName IS NULL) THEN
51367
 
      RAISE EXCEPTION 'The name of the card holder must be entered';
51368
 
  END IF;
51369
 
  IF (pAddr1 IS NULL OR pAddr1 = '') THEN
51370
 
      RAISE EXCEPTION 'The first address line must be entered';
51371
 
  END IF;
51372
 
  IF (pCity IS NULL OR pCity = '') THEN
51373
 
      RAISE EXCEPTION 'The city must be entered';
51374
 
  END IF;
51375
 
  IF (pState IS NULL OR pState = '') THEN
51376
 
      RAISE EXCEPTION 'The state must be entered';
51377
 
  END IF;
51378
 
  IF (pPostal IS NULL OR pPostal = '') THEN
51379
 
      RAISE EXCEPTION 'The zip code must be entered';
51380
 
  END IF;
51381
 
  IF (pCountry IS NULL OR pCountry = '') THEN
51382
 
      RAISE EXCEPTION 'The country must be entered';
51383
 
  END IF;
51384
 
  IF (pMonth IS NULL OR pMonth = '') THEN
51385
 
      RAISE EXCEPTION 'The Expiration Month must be entered';
51386
 
  END IF;
51387
 
  IF (_month < 1 OR _month > 12) THEN
51388
 
      RAISE EXCEPTION 'Valid Expiration Months are 01 through 12';
51389
 
  END IF;
51390
 
  IF (LENGTH(_year::text) <> 4) THEN
51391
 
      RAISE EXCEPTION 'Valid Expiration Years are CCYY in format';
51392
 
  END IF;
51393
 
  IF (_year < 1970 OR _year > 2100) THEN
51394
 
      RAISE EXCEPTION 'Valid Expiration Years are 1970 through 2100';
51395
 
  END IF;
51396
 
  
51397
 
  -- Check Number Length
51398
 
  IF ((NOT _number ~  '[0-9]{13,16}') OR (LENGTH(_number) = 14) OR (LENGTH(_number) > 16)) THEN
51399
 
    RAISE EXCEPTION 'The credit card number must be all numeric (no spaces or hyphens) and must be 13, 15 or 16 characters in length';
51400
 
  END IF;
51401
 
 
51402
 
  -- Convert Type
51403
 
  IF (pType = 'Visa') THEN
51404
 
    _type  = 'V';
51405
 
  ELSE
51406
 
    IF (pType = 'Master Card') THEN
51407
 
      _type  = 'M';
51408
 
    ELSE
51409
 
      IF (pType = 'American Express') THEN
51410
 
        _type  = 'A';
51411
 
      ELSE
51412
 
        IF (pType = 'Discover') THEN
51413
 
          _type  = 'D';
51414
 
        ELSE
51415
 
          RAISE EXCEPTION 'You must select Master Card, Visa, American 
51416
 
                            Express or Discover as the credit card type.';
51417
 
        END IF;
51418
 
      END IF;
51419
 
    END IF;
51420
 
  END IF;
51421
 
  
51422
 
  -- Check Card Specific Data
51423
 
  SELECT editccnumber(_number, _type) INTO _result;
51424
 
 
51425
 
  IF (_result = -1) THEN
51426
 
    RAISE EXCEPTION 'You must select Master Card, Visa, American 
51427
 
                      Express or Discover as the credit card type.';
51428
 
  END IF;
51429
 
  IF (_result = -2) THEN
51430
 
    RAISE EXCEPTION 'The length of a Master Card credit card number
51431
 
                      has to be 16 digits.';
51432
 
  END IF;
51433
 
  IF (_result = -3) THEN
51434
 
    RAISE EXCEPTION 'The length of a Visa credit card number
51435
 
                      has to be either 13 or 16 digits.';
51436
 
  END IF;
51437
 
  IF (_result = -4) THEN
51438
 
    RAISE EXCEPTION 'The length of an American Express credit card
51439
 
                      number has to be 15 digits.';
51440
 
  END IF;
51441
 
  IF (_result = -5) THEN
51442
 
    RAISE EXCEPTION 'The length of a Discover credit card number 
51443
 
                      has to be 16 digits.';
51444
 
  END IF;
51445
 
   IF (_result = -6) THEN
51446
 
    RAISE EXCEPTION 'The first two digits for a valid Master Card
51447
 
                      number must be between 51 and 55';
51448
 
  END IF;
51449
 
  IF (_result = -7) THEN
51450
 
    RAISE EXCEPTION 'The first digit for a valid Visa number must
51451
 
                      be 4';
51452
 
  END IF;
51453
 
   IF (_result = -8) THEN
51454
 
    RAISE EXCEPTION 'The first two digits for a valid American
51455
 
                      Express number must be 34 or 37.';
51456
 
  END IF;
51457
 
  IF (_result = -9) THEN
51458
 
    RAISE EXCEPTION 'The first four digits for a valid Discover
51459
 
                      Express number must be 6011.';
51460
 
  END IF;
51461
 
  IF ((_result = -10) AND NOT fetchmetricbool('CCTest')) THEN
51462
 
    RAISE EXCEPTION 'The credit card number that you have provided
51463
 
                      is not valid.';
51464
 
  END IF;
51465
 
  IF (_result < -10) THEN
51466
 
    RAISE EXCEPTION 'Invalid Credit Card Information';
51467
 
  END IF;
51468
 
 
51469
 
  -- Insert Record
51470
 
 
51471
 
  INSERT INTO ccard ( 
51472
 
    ccard_seq, 
51473
 
    ccard_cust_id,
51474
 
    ccard_active, 
51475
 
    ccard_name, 
51476
 
    ccard_address1,
51477
 
    ccard_address2,
51478
 
    ccard_city, 
51479
 
    ccard_state, 
51480
 
    ccard_zip,
51481
 
    ccard_country, 
51482
 
    ccard_number,
51483
 
    ccard_month_expired, 
51484
 
    ccard_year_expired, 
51485
 
    ccard_type)
51486
 
    VALUES 
51487
 
    ((SELECT COALESCE(MAX(ccard_seq), 0) + 10
51488
 
      FROM ccard 
51489
 
      WHERE (ccard_cust_id =getCustId(pCustomer))),
51490
 
     getCustId(pCustomer),
51491
 
     COALESCE(pActive),
51492
 
     encrypt(setbytea(pName), setbytea(pKey), 'bf'),
51493
 
     encrypt(setbytea(pAddr1), setbytea(pKey), 'bf'),
51494
 
     encrypt(setbytea(pAddr2), setbytea(pKey), 'bf'),
51495
 
     encrypt(setbytea(pCity), setbytea(pKey), 'bf'),
51496
 
     encrypt(setbytea(pState), setbytea(pKey), 'bf'),
51497
 
     encrypt(setbytea(pPostal), setbytea(pKey), 'bf'),
51498
 
     encrypt(setbytea(pCountry), setbytea(pKey), 'bf'),
51499
 
     encrypt(setbytea(pNumber), setbytea(pKey), 'bf'),
51500
 
     encrypt(setbytea(pMonth), setbytea(pKey), 'bf'),
51501
 
     encrypt(setbytea(pYear), setbytea(pKey), 'bf'),
51502
 
     _type );
51503
 
 
51504
 
  RETURN true;
51505
 
END;
51506
 
$_$;
51507
 
 
51508
 
 
51509
 
ALTER FUNCTION public.insertccard(text, boolean, text, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, text) OWNER TO admin;
51510
 
 
51511
 
--
51512
 
--
51513
 
 
51514
 
COMMENT ON FUNCTION insertccard(text, boolean, text, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, text) IS 'This function is generally used to support the _custcreditcard API view';
51515
 
 
51516
 
 
51517
 
--
51518
 
--
51519
 
 
51520
 
CREATE TABLE cmhead (
51521
 
    cmhead_id integer DEFAULT nextval(('cmhead_cmhead_id_seq'::text)::regclass) NOT NULL,
51522
 
    cmhead_number text NOT NULL,
51523
 
    cmhead_posted boolean,
51524
 
    cmhead_invcnumber text,
51525
 
    cmhead_custponumber text,
51526
 
    cmhead_cust_id integer,
51527
 
    cmhead_docdate date,
51528
 
    cmhead_shipto_id integer,
51529
 
    cmhead_shipto_name text,
51530
 
    cmhead_shipto_address1 text,
51531
 
    cmhead_shipto_address2 text,
51532
 
    cmhead_shipto_address3 text,
51533
 
    cmhead_shipto_city text,
51534
 
    cmhead_shipto_state text,
51535
 
    cmhead_shipto_zipcode text,
51536
 
    cmhead_salesrep_id integer,
51537
 
    cmhead_freight numeric(16,4),
51538
 
    cmhead_misc numeric(16,4),
51539
 
    cmhead_comments text,
51540
 
    cmhead_printed boolean,
51541
 
    cmhead_billtoname text,
51542
 
    cmhead_billtoaddress1 text,
51543
 
    cmhead_billtoaddress2 text,
51544
 
    cmhead_billtoaddress3 text,
51545
 
    cmhead_billtocity text,
51546
 
    cmhead_billtostate text,
51547
 
    cmhead_billtozip text,
51548
 
    cmhead_hold boolean,
51549
 
    cmhead_commission numeric(8,4),
51550
 
    cmhead_misc_accnt_id integer,
51551
 
    cmhead_misc_descrip text,
51552
 
    cmhead_rsncode_id integer,
51553
 
    cmhead_curr_id integer DEFAULT basecurrid(),
51554
 
    cmhead_freighttaxtype_id integer,
51555
 
    cmhead_gldistdate date,
51556
 
    cmhead_billtocountry text,
51557
 
    cmhead_shipto_country text,
51558
 
    cmhead_rahead_id integer,
51559
 
    cmhead_taxzone_id integer,
51560
 
    cmhead_prj_id integer,
51561
 
    cmhead_void boolean DEFAULT false,
51562
 
    cmhead_saletype_id integer,
51563
 
    cmhead_shipzone_id integer,
51564
 
    CONSTRAINT cmhead_cmhead_number_check CHECK ((cmhead_number <> ''::text))
51565
 
);
51566
 
 
51567
 
 
51568
 
ALTER TABLE public.cmhead OWNER TO admin;
51569
 
 
51570
 
--
51571
 
--
51572
 
 
51573
 
COMMENT ON TABLE cmhead IS 'S/O Credit Memo header information';
51574
 
 
51575
 
 
51576
 
--
51577
 
--
51578
 
 
51579
 
COMMENT ON COLUMN cmhead.cmhead_freighttaxtype_id IS 'Deprecated column - DO NOT USE';
51580
 
 
51581
 
 
51582
 
--
51583
 
--
51584
 
 
51585
 
COMMENT ON COLUMN cmhead.cmhead_saletype_id IS 'Associated sale type for credit memo.';
51586
 
 
51587
 
 
51588
 
--
51589
 
--
51590
 
 
51591
 
COMMENT ON COLUMN cmhead.cmhead_shipzone_id IS 'Associated shipping zone for credit memo.';
51592
 
 
51593
 
 
51594
 
--
51595
 
--
51596
 
 
51597
 
CREATE TABLE shiptoinfo (
51598
 
    shipto_id integer DEFAULT nextval(('shipto_shipto_id_seq'::text)::regclass) NOT NULL,
51599
 
    shipto_cust_id integer NOT NULL,
51600
 
    shipto_name text,
51601
 
    shipto_salesrep_id integer,
51602
 
    shipto_comments text,
51603
 
    shipto_shipcomments text,
51604
 
    shipto_shipzone_id integer,
51605
 
    shipto_shipvia text,
51606
 
    shipto_commission numeric(10,4) NOT NULL,
51607
 
    shipto_shipform_id integer,
51608
 
    shipto_shipchrg_id integer,
51609
 
    shipto_active boolean NOT NULL,
51610
 
    shipto_default boolean,
51611
 
    shipto_num text,
51612
 
    shipto_ediprofile_id integer,
51613
 
    shipto_cntct_id integer,
51614
 
    shipto_addr_id integer,
51615
 
    shipto_taxzone_id integer,
51616
 
    shipto_preferred_warehous_id integer DEFAULT (-1) NOT NULL
51617
 
);
51618
 
 
51619
 
 
51620
 
ALTER TABLE public.shiptoinfo OWNER TO admin;
51621
 
 
51622
 
--
51623
 
--
51624
 
 
51625
 
COMMENT ON TABLE shiptoinfo IS 'Ship-To information';
51626
 
 
51627
 
 
51628
 
--
51629
 
--
51630
 
 
51631
 
COMMENT ON COLUMN shiptoinfo.shipto_ediprofile_id IS 'Deprecated column - DO NOT USE';
51632
 
 
51633
 
 
51634
 
--
51635
 
--
51636
 
 
51637
 
CREATE TABLE taxzone (
51638
 
    taxzone_id integer NOT NULL,
51639
 
    taxzone_code text NOT NULL,
51640
 
    taxzone_descrip text,
51641
 
    CONSTRAINT taxzone_taxzone_code_check CHECK ((taxzone_code <> ''::text))
51642
 
);
51643
 
 
51644
 
 
51645
 
ALTER TABLE public.taxzone OWNER TO admin;
51646
 
 
51647
 
--
51648
 
--
51649
 
 
51650
 
COMMENT ON TABLE taxzone IS 'Tax zone information';
51651
 
 
51652
 
 
51653
 
--
51654
 
--
51655
 
 
51656
 
COMMENT ON COLUMN taxzone.taxzone_id IS 'Primary key';
51657
 
 
51658
 
 
51659
 
--
51660
 
--
51661
 
 
51662
 
COMMENT ON COLUMN taxzone.taxzone_code IS 'Code';
51663
 
 
51664
 
 
51665
 
--
51666
 
--
51667
 
 
51668
 
COMMENT ON COLUMN taxzone.taxzone_descrip IS 'Description';
51669
 
 
51670
 
 
51671
 
SET search_path = api, pg_catalog;
51672
 
 
51673
 
--
51674
 
--
51675
 
 
51676
 
CREATE VIEW creditmemo AS
51677
 
    SELECT cmhead.cmhead_number AS memo_number, CASE WHEN (cmhead.cmhead_invcnumber = '-1'::text) THEN ''::text ELSE cmhead.cmhead_invcnumber END AS apply_to, cmhead.cmhead_docdate AS memo_date, CASE WHEN cmhead.cmhead_posted THEN 'Posted'::text ELSE 'Unposted'::text END AS status, salesrep.salesrep_number AS sales_rep, cmhead.cmhead_commission AS commission, COALESCE(taxzone.taxzone_code, 'None'::text) AS tax_zone, COALESCE(rsncode.rsncode_code, 'None'::text) AS reason_code, cmhead.cmhead_hold AS on_hold, custinfo.cust_number AS customer_number, cmhead.cmhead_billtoname AS billto_name, cmhead.cmhead_billtoaddress1 AS billto_address1, cmhead.cmhead_billtoaddress2 AS billto_address2, cmhead.cmhead_billtoaddress3 AS billto_address3, cmhead.cmhead_billtocity AS billto_city, cmhead.cmhead_billtostate AS billto_state, cmhead.cmhead_billtozip AS billto_postal_code, cmhead.cmhead_billtocountry AS billto_country, shiptoinfo.shipto_num AS shipto_number, cmhead.cmhead_shipto_name AS shipto_name, cmhead.cmhead_shipto_address1 AS shipto_address1, cmhead.cmhead_shipto_address2 AS shipto_address2, cmhead.cmhead_shipto_address3 AS shipto_address3, cmhead.cmhead_shipto_city AS shipto_city, cmhead.cmhead_shipto_state AS shipto_state, cmhead.cmhead_shipto_zipcode AS shipto_postal_code, cmhead.cmhead_shipto_country AS shipto_country, cmhead.cmhead_custponumber AS customer_po_number, cmhead.cmhead_comments AS notes, curr.curr_abbr AS currency, cmhead.cmhead_misc_descrip AS misc_charge_description, cmhead.cmhead_misc AS misc_charge_amount, CASE WHEN (cmhead.cmhead_misc_accnt_id = (-1)) THEN ''::text ELSE public.formatglaccount(cmhead.cmhead_misc_accnt_id) END AS misc_charge_credit_account, cmhead.cmhead_freight AS freight FROM ((((((public.cmhead LEFT JOIN public.custinfo ON ((custinfo.cust_id = cmhead.cmhead_cust_id))) LEFT JOIN public.shiptoinfo ON ((shiptoinfo.shipto_id = cmhead.cmhead_shipto_id))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = cmhead.cmhead_curr_id))) LEFT JOIN public.salesrep ON ((salesrep.salesrep_id = cmhead.cmhead_salesrep_id))) LEFT JOIN public.taxzone ON ((taxzone.taxzone_id = cmhead.cmhead_taxzone_id))) LEFT JOIN public.rsncode ON ((rsncode.rsncode_id = cmhead.cmhead_rsncode_id)));
51678
 
 
51679
 
 
51680
 
ALTER TABLE api.creditmemo OWNER TO admin;
51681
 
 
51682
 
--
51683
 
--
51684
 
 
51685
 
COMMENT ON VIEW creditmemo IS 'Credit Memo Header';
51686
 
 
51687
 
 
51688
 
SET search_path = public, pg_catalog;
51689
 
 
51690
 
--
51691
 
--
51692
 
 
51693
 
CREATE FUNCTION insertcreditmemo(api.creditmemo) RETURNS boolean
51694
 
    LANGUAGE plpgsql
51695
 
    AS $_$
51696
 
DECLARE
51697
 
        pNew ALIAS FOR $1;
51698
 
BEGIN
51699
 
        -- NOTE: (SELECT getCustId(...)) seems redundant, but it actually produces
51700
 
        -- a HUGE performance increase because it makes the Postgres query planner
51701
 
        -- use an index scan rather than an sequential table scan on cust_id
51702
 
  INSERT INTO cmhead (
51703
 
                cmhead_number,
51704
 
                cmhead_posted,
51705
 
                cmhead_invcnumber,
51706
 
                cmhead_custponumber,
51707
 
                cmhead_cust_id,
51708
 
                cmhead_docdate,
51709
 
                cmhead_shipto_id,
51710
 
                cmhead_shipto_name,
51711
 
                cmhead_shipto_address1,
51712
 
                cmhead_shipto_address2,
51713
 
                cmhead_shipto_address3,
51714
 
                cmhead_shipto_city,
51715
 
                cmhead_shipto_state,
51716
 
                cmhead_shipto_zipcode,
51717
 
                cmhead_shipto_country,
51718
 
                cmhead_salesrep_id,
51719
 
                cmhead_freight,
51720
 
                cmhead_misc,
51721
 
                cmhead_comments,
51722
 
                cmhead_printed,
51723
 
                cmhead_billtoname,
51724
 
                cmhead_billtoaddress1,
51725
 
                cmhead_billtoaddress2,
51726
 
                cmhead_billtoaddress3,
51727
 
                cmhead_billtocity,
51728
 
                cmhead_billtostate,
51729
 
                cmhead_billtozip,
51730
 
                cmhead_billtocountry,
51731
 
                cmhead_hold,
51732
 
                cmhead_commission,
51733
 
                cmhead_misc_accnt_id,
51734
 
                cmhead_misc_descrip,
51735
 
                cmhead_rsncode_id,
51736
 
                cmhead_curr_id,
51737
 
                cmhead_taxzone_id,
51738
 
                cmhead_gldistdate,
51739
 
                cmhead_rahead_id
51740
 
                )
51741
 
         SELECT
51742
 
                (CASE -- use a case here so we don't unnecessarily fetch a new CM number
51743
 
                        WHEN pNew.memo_number IS NULL THEN fetchCMNumber()
51744
 
                        ELSE pNew.memo_number
51745
 
                END),
51746
 
                FALSE, -- posted
51747
 
                pNew.apply_to,
51748
 
                pNew.customer_po_number,
51749
 
                cust_id,
51750
 
                COALESCE(pNew.memo_date, CURRENT_DATE),
51751
 
                COALESCE(shipto_id,-1),
51752
 
                pNew.shipto_name,
51753
 
                pNew.shipto_address1,
51754
 
                pNew.shipto_address2,
51755
 
                pNew.shipto_address3,
51756
 
                pNew.shipto_city,
51757
 
                pNew.shipto_state,
51758
 
                pNew.shipto_postal_code,
51759
 
                pNew.shipto_country,
51760
 
                COALESCE(getSalesRepId(pNew.sales_rep),shipto_salesrep_id,cust_salesrep_id),
51761
 
                COALESCE(pNew.freight, 0),
51762
 
                COALESCE(pNew.misc_charge_amount, 0),
51763
 
                pNew.notes,
51764
 
                FALSE, -- printed
51765
 
                COALESCE(pNew.billto_name, invchead_billto_name, cust_name),
51766
 
                COALESCE(pNew.billto_address1, invchead_billto_address1, addr_line1),
51767
 
                COALESCE(pNew.billto_address2, invchead_billto_address2, addr_line2),
51768
 
                COALESCE(pNew.billto_address3, invchead_billto_address3, addr_line3),
51769
 
                COALESCE(pNew.billto_city, invchead_billto_city, addr_city),
51770
 
                COALESCE(pNew.billto_state, invchead_billto_state, addr_state),
51771
 
                COALESCE(pNew.billto_postal_code, invchead_billto_zipcode, addr_postalcode),
51772
 
                COALESCE(pNew.billto_country, invchead_billto_country, addr_country),
51773
 
                COALESCE(pNew.on_hold, FALSE),
51774
 
                COALESCE(pNew.commission, 0),
51775
 
                COALESCE(getGlAccntId(pNew.misc_charge_credit_account),-1),
51776
 
                pNew.misc_charge_description,
51777
 
                (SELECT rsncode_id FROM rsncode WHERE rsncode_code = pNew.reason_code),
51778
 
                COALESCE(getCurrId(pNew.currency),cust_curr_id,basecurrid()),
51779
 
                CASE WHEN pNew.tax_zone = 'None' THEN NULL
51780
 
                     ELSE COALESCE(getTaxZoneID(pNew.tax_zone),cust_taxzone_id)
51781
 
                END,
51782
 
                NULL,
51783
 
                NULL
51784
 
        FROM custinfo
51785
 
                LEFT OUTER JOIN shiptoinfo ON (shipto_id=(SELECT CASE
51786
 
                        WHEN getShiptoId(pNew.customer_number,pNew.shipto_number) IS NOT NULL
51787
 
                                THEN getShiptoId(pNew.customer_number,pNew.shipto_number)
51788
 
                        ELSE (SELECT shipto_id FROM shiptoinfo WHERE shipto_cust_id=cust_id AND shipto_default)
51789
 
                END))
51790
 
                LEFT OUTER JOIN invchead ON (invchead_id=getInvcheadId(pNEW.apply_to))
51791
 
                LEFT OUTER JOIN cntct ON (cntct_id=cust_cntct_id)
51792
 
                LEFT OUTER JOIN addr ON (addr_id=cntct_addr_id)
51793
 
        WHERE cust_id = (CASE
51794
 
                WHEN pNew.customer_number IS NOT NULL THEN (SELECT getCustId(pNew.customer_number))
51795
 
                ELSE (SELECT invchead_cust_id FROM invchead WHERE invchead_invcnumber = pNew.apply_to)
51796
 
        END);
51797
 
        RETURN TRUE;
51798
 
END;
51799
 
$_$;
51800
 
 
51801
 
 
51802
 
ALTER FUNCTION public.insertcreditmemo(api.creditmemo) OWNER TO admin;
51803
 
 
51804
 
--
51805
 
--
51806
 
 
51807
 
CREATE TABLE cmitem (
51808
 
    cmitem_id integer DEFAULT nextval(('cmitem_cmitem_id_seq'::text)::regclass) NOT NULL,
51809
 
    cmitem_cmhead_id integer NOT NULL,
51810
 
    cmitem_linenumber integer NOT NULL,
51811
 
    cmitem_itemsite_id integer NOT NULL,
51812
 
    cmitem_qtycredit numeric(18,6) NOT NULL,
51813
 
    cmitem_qtyreturned numeric(18,6) NOT NULL,
51814
 
    cmitem_unitprice numeric(16,4) NOT NULL,
51815
 
    cmitem_comments text,
51816
 
    cmitem_rsncode_id integer,
51817
 
    cmitem_taxtype_id integer,
51818
 
    cmitem_qty_uom_id integer NOT NULL,
51819
 
    cmitem_qty_invuomratio numeric(20,10) NOT NULL,
51820
 
    cmitem_price_uom_id integer NOT NULL,
51821
 
    cmitem_price_invuomratio numeric(20,10) NOT NULL,
51822
 
    cmitem_raitem_id integer,
51823
 
    cmitem_updateinv boolean DEFAULT true NOT NULL
51824
 
);
51825
 
 
51826
 
 
51827
 
ALTER TABLE public.cmitem OWNER TO admin;
51828
 
 
51829
 
--
51830
 
--
51831
 
 
51832
 
COMMENT ON TABLE cmitem IS 'S/O Credit Memo Line Item information';
51833
 
 
51834
 
 
51835
 
SET search_path = api, pg_catalog;
51836
 
 
51837
 
--
51838
 
--
51839
 
 
51840
 
CREATE VIEW creditmemoline AS
51841
 
    SELECT cmhead.cmhead_number AS memo_number, cmitem.cmitem_linenumber AS line_number, item.item_number, whsinfo.warehous_code AS recv_site, rsncode.rsncode_code AS reason_code, cmitem.cmitem_qtyreturned AS qty_returned, cmitem.cmitem_qtycredit AS qty_to_credit, COALESCE(qty_uom.uom_name, 'None'::text) AS qty_uom, cmitem.cmitem_unitprice AS net_unit_price, COALESCE(price_uom.uom_name, 'None'::text) AS price_uom, COALESCE(taxtype.taxtype_name, 'None'::text) AS tax_type, cmitem.cmitem_comments AS notes FROM ((((((((public.cmitem LEFT JOIN public.cmhead ON ((cmitem.cmitem_cmhead_id = cmhead.cmhead_id))) LEFT JOIN public.itemsite ON ((itemsite.itemsite_id = cmitem.cmitem_itemsite_id))) LEFT JOIN public.item ON ((item.item_id = itemsite.itemsite_item_id))) LEFT JOIN public.whsinfo ON ((whsinfo.warehous_id = itemsite.itemsite_warehous_id))) LEFT JOIN public.rsncode ON ((rsncode.rsncode_id = cmitem.cmitem_rsncode_id))) LEFT JOIN public.taxtype ON ((taxtype.taxtype_id = cmitem.cmitem_taxtype_id))) LEFT JOIN public.uom qty_uom ON ((qty_uom.uom_id = cmitem.cmitem_qty_uom_id))) LEFT JOIN public.uom price_uom ON ((price_uom.uom_id = cmitem.cmitem_price_uom_id)));
51842
 
 
51843
 
 
51844
 
ALTER TABLE api.creditmemoline OWNER TO admin;
51845
 
 
51846
 
--
51847
 
--
51848
 
 
51849
 
COMMENT ON VIEW creditmemoline IS 'Credit Memo Line';
51850
 
 
51851
 
 
51852
 
SET search_path = public, pg_catalog;
51853
 
 
51854
 
--
51855
 
--
51856
 
 
51857
 
CREATE FUNCTION insertcreditmemoline(api.creditmemoline) RETURNS boolean
51858
 
    LANGUAGE plpgsql
51859
 
    AS $_$
51860
 
DECLARE
51861
 
  pNew ALIAS FOR $1;
51862
 
  _check INTEGER;
51863
 
  _r RECORD;
51864
 
 
51865
 
BEGIN
51866
 
  SELECT cmhead_id INTO _check
51867
 
  FROM cmhead
51868
 
  WHERE (cmhead_id=getCmheadId(pNew.memo_number, FALSE));
51869
 
  IF (NOT FOUND) THEN
51870
 
    RAISE EXCEPTION 'Credit Memo # % not found', pNew.memo_number;
51871
 
  END IF;
51872
 
 
51873
 
  INSERT INTO cmitem ( cmitem_cmhead_id,
51874
 
                       cmitem_linenumber,
51875
 
                       cmitem_itemsite_id,
51876
 
                       cmitem_qtycredit,
51877
 
                       cmitem_qtyreturned,
51878
 
                       cmitem_unitprice,
51879
 
                       cmitem_comments,
51880
 
                       cmitem_rsncode_id,
51881
 
                       cmitem_taxtype_id,
51882
 
                       cmitem_qty_uom_id,
51883
 
                       cmitem_qty_invuomratio,
51884
 
                       cmitem_price_uom_id,
51885
 
                       cmitem_price_invuomratio )
51886
 
  SELECT cmhead_id,
51887
 
         COALESCE(pNew.line_number,
51888
 
                  (SELECT (COALESCE(MAX(cmitem_linenumber), 0) + 1)
51889
 
                   FROM cmitem WHERE (cmitem_cmhead_id=cmhead_id))),
51890
 
         COALESCE(itemsite_id, -1),
51891
 
         COALESCE(pNew.qty_to_credit, 0),
51892
 
         COALESCE(pNew.qty_returned, 0),
51893
 
         COALESCE(pNew.net_unit_price, 0),
51894
 
         pNew.notes,
51895
 
         getRsnId(pNew.reason_code),
51896
 
         taxtype_id,
51897
 
         COALESCE(getUomId(pNew.qty_uom), item_inv_uom_id),
51898
 
         CASE
51899
 
           WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE(getUomId(pNew.qty_uom),item_inv_uom_id),item_inv_uom_id)
51900
 
           ELSE 1
51901
 
         END,
51902
 
         COALESCE(getUomId(pNew.price_uom),item_price_uom_id),
51903
 
         CASE
51904
 
           WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE(getUomId(pNew.price_uom),item_price_uom_id),item_price_uom_id)
51905
 
           ELSE 1
51906
 
        END
51907
 
  FROM cmhead LEFT OUTER JOIN item ON (item_id=getItemId(pNew.item_number))
51908
 
              LEFT OUTER JOIN itemsite ON (itemsite_item_id=item_id AND itemsite_warehous_id=getWarehousId(pNew.recv_site, 'ALL'))
51909
 
              LEFT OUTER JOIN taxtype ON (taxtype_id=CASE WHEN pNew.tax_type IS NULL THEN getItemTaxType(item_id,cmhead_taxzone_id)
51910
 
                                                          WHEN pNew.tax_type = 'None' THEN NULL
51911
 
                                                          ELSE getTaxTypeId(pNew.tax_type)
51912
 
                                                     END)
51913
 
  WHERE (cmhead_id=getCmheadId(pNew.memo_number, FALSE));
51914
 
 
51915
 
  RETURN TRUE;
51916
 
END;
51917
 
$_$;
51918
 
 
51919
 
 
51920
 
ALTER FUNCTION public.insertcreditmemoline(api.creditmemoline) OWNER TO admin;
51921
 
 
51922
 
--
51923
 
--
51924
 
 
51925
 
CREATE FUNCTION insertflgroup(pflheadid integer, pperiodid integer, pflgrpid integer, plevel integer, psummarize boolean, pinterval character DEFAULT NULL::bpchar, pprjid integer DEFAULT NULL::integer) RETURNS boolean
51926
 
    LANGUAGE plpgsql
51927
 
    AS $$
51928
 
 
51929
 
/* see the "performance vs. history" comment in financialreport() */
51930
 
DECLARE
51931
 
  _subtotal BOOLEAN;
51932
 
  _r RECORD;
51933
 
  _g RECORD;
51934
 
  _all BOOLEAN;
51935
 
  _username TEXT := getEffectiveXtUser();
51936
 
 
51937
 
BEGIN
51938
 
 
51939
 
  _all = COALESCE(pPrjid,-1) = -1;
51940
 
  
51941
 
  _subtotal := FALSE;
51942
 
  IF (pFlgrpid != -1) THEN
51943
 
    SELECT COALESCE(flgrp_subtotal, FALSE) INTO _subtotal
51944
 
      FROM flgrp
51945
 
     WHERE ((flgrp_flhead_id=pFlheadid)
51946
 
       AND  (flgrp_id=pFlgrpid));
51947
 
  END IF;
51948
 
 
51949
 
  FOR _r IN SELECT 'G' AS type, flgrp_id AS type_id,
51950
 
                   flgrp_order AS orderby,
51951
 
                   flgrp_summarize AS summarize,
51952
 
                   flgrp_subtract AS subtract,
51953
 
                   CASE WHEN(flgrp_summarize AND (NOT flgrp_showstart)) THEN NULL
51954
 
                        ELSE 0.00
51955
 
                   END AS beginning,
51956
 
                   CASE WHEN(flgrp_summarize AND (NOT flgrp_showend)) THEN NULL
51957
 
                        ELSE 0.00
51958
 
                   END AS ending,
51959
 
                   CASE WHEN(flgrp_summarize AND (NOT flgrp_showdelta)) THEN NULL
51960
 
                        ELSE 0.00
51961
 
                   END AS debits,
51962
 
                   CASE WHEN(flgrp_summarize AND (NOT flgrp_showdelta)) THEN NULL
51963
 
                        ELSE 0.00
51964
 
                   END AS credits,
51965
 
                   CASE WHEN(flgrp_summarize AND (NOT flgrp_showbudget)) THEN NULL
51966
 
                        ELSE 0.00
51967
 
                   END AS budget,
51968
 
                   CASE WHEN(flgrp_summarize AND (NOT flgrp_showdiff)) THEN NULL
51969
 
                        ELSE 0.00
51970
 
                   END AS diff,
51971
 
                   CASE WHEN(flgrp_summarize AND (NOT flgrp_showcustom)) THEN NULL
51972
 
                        ELSE 0.00
51973
 
                   END AS custom,
51974
 
                   CASE WHEN(flgrp_showstartprcnt) THEN 0.00
51975
 
                        ELSE NULL
51976
 
                   END AS beginningprcnt,
51977
 
                   CASE WHEN(flgrp_showendprcnt) THEN 0.00
51978
 
                        ELSE NULL
51979
 
                   END AS endingprcnt,
51980
 
                   CASE WHEN(flgrp_showdeltaprcnt) THEN 0.00
51981
 
                        ELSE NULL
51982
 
                   END AS debitsprcnt,
51983
 
                   CASE WHEN(flgrp_showdeltaprcnt) THEN 0.00
51984
 
                        ELSE NULL
51985
 
                   END AS creditsprcnt,
51986
 
                   CASE WHEN(flgrp_showbudgetprcnt) THEN 0.00
51987
 
                        ELSE NULL
51988
 
                   END AS budgetprcnt,
51989
 
                   CASE WHEN(flgrp_showdiffprcnt) THEN 0.00
51990
 
                        ELSE NULL
51991
 
                   END AS diffprcnt,
51992
 
                   CASE WHEN(flgrp_showcustomprcnt) THEN 0.00
51993
 
                        ELSE NULL
51994
 
                   END AS customprcnt,
51995
 
                   -1 AS accnt_id,
51996
 
                   '' AS accnt_number
51997
 
              FROM flgrp
51998
 
             WHERE ((flgrp_flgrp_id=pFlgrpid)
51999
 
               AND  (flgrp_flhead_id=pFlheadid))
52000
 
             UNION ALL
52001
 
            SELECT 'I' AS type, flitem_id AS type_id,
52002
 
                   flitem_order AS orderby,
52003
 
                   FALSE AS summarize,
52004
 
                   flitem_subtract AS subtract,
52005
 
                   CASE WHEN (flitem_showstart AND (first_trialbal_id IS NULL)) THEN 0.00
52006
 
                        WHEN (flitem_showstart) THEN normalizeTrialBal(first_trialbal_id, 'B')
52007
 
                        ELSE NULL
52008
 
                   END AS beginning,
52009
 
                   CASE WHEN (flitem_showend AND (last_trialbal_id IS NULL)) THEN 0.00
52010
 
                        WHEN (flitem_showend) THEN normalizeTrialBal(last_trialbal_id, 'E')
52011
 
                        ELSE NULL
52012
 
                   END AS ending,
52013
 
                   CASE WHEN (flitem_showdelta) THEN sum_trialbal_debits
52014
 
                        ELSE NULL
52015
 
                   END AS debits,
52016
 
                   CASE WHEN (flitem_showdelta) THEN sum_trialbal_credits
52017
 
                        ELSE NULL
52018
 
                   END AS credits,
52019
 
                   CASE WHEN ((flitem_showbudget) AND (accnt_type IN ('R','E')) AND flhead_type IN ('I','C','A')) THEN COALESCE(sum_budget_amount,0)
52020
 
                        WHEN ((flitem_showbudget) AND (accnt_type IN ('R','E')) AND flhead_type = 'B' ) THEN
52021
 
                                (SELECT COALESCE(SUM(b.budget_amount),0)
52022
 
                                FROM budget b,
52023
 
                                        (SELECT ytd.period_id AS ytd_period_id
52024
 
                                        FROM period cp, period ytd
52025
 
                                        WHERE ((cp.period_id = last_flitem_period_id)
52026
 
                                        AND (ytd.period_start <= cp.period_start)
52027
 
                                AND (ytd.period_yearperiod_id = cp.period_yearperiod_id))) AS periods
52028
 
                                WHERE ((b.budget_accnt_id=accnt_id)
52029
 
                                AND (b.budget_period_id=ytd_period_id)))
52030
 
                        WHEN ((flitem_showbudget) AND (accnt_type IN ('A','L','Q')) AND flhead_type = 'C') THEN calccashbudget(accnt_id,last_flitem_period_id,pInterval)
52031
 
                        ELSE COALESCE(last_budget_amount,0)
52032
 
                   END AS budget,
52033
 
                   CASE WHEN (flitem_showdiff AND (first_trialbal_id IS NULL)) THEN 0.00
52034
 
                        WHEN (flitem_showdiff) THEN COALESCE(normalizeTrialBal(last_trialbal_id, 'E') - normalizeTrialBal(first_trialbal_id, 'B'), 0.00)
52035
 
                        ELSE NULL
52036
 
                   END AS diff,
52037
 
                   CASE WHEN (NOT flitem_showcustom) THEN NULL
52038
 
                        WHEN (flitem_custom_source='S' AND (first_trialbal_id IS NOT NULL)) THEN normalizeTrialBal(first_trialbal_id, 'B')
52039
 
                        WHEN (flitem_custom_source='E' AND (first_trialbal_id IS NOT NULL)) THEN normalizeTrialBal(last_trialbal_id, 'E')
52040
 
                        WHEN (flitem_custom_source='D') THEN sum_trialbal_debits
52041
 
                        WHEN (flitem_custom_source='C') THEN sum_trialbal_credits
52042
 
                        WHEN (flitem_custom_source='B') THEN (
52043
 
                                CASE
52044
 
                                  WHEN (accnt_type IN ('R','E')) THEN sum_budget_amount
52045
 
                                  ELSE last_budget_amount
52046
 
                                END)
52047
 
                        WHEN (flitem_custom_source='F' AND  (first_trialbal_id IS NOT NULL)) THEN COALESCE(normalizeTrialBal(last_trialbal_id, 'E') - normalizeTrialBal(first_trialbal_id, 'B'), 0.00)
52048
 
                        ELSE 0.00
52049
 
                   END AS custom,
52050
 
                   CASE WHEN(flitem_showstartprcnt) THEN 0.00
52051
 
                        ELSE NULL
52052
 
                   END AS beginningprcnt,
52053
 
                   CASE WHEN(flitem_showendprcnt) THEN 0.00
52054
 
                        ELSE NULL
52055
 
                   END AS endingprcnt,
52056
 
                   CASE WHEN(flitem_showdeltaprcnt) THEN 0.00
52057
 
                        ELSE NULL
52058
 
                   END AS debitsprcnt,
52059
 
                   CASE WHEN(flitem_showdeltaprcnt) THEN 0.00
52060
 
                        ELSE NULL
52061
 
                   END AS creditsprcnt,
52062
 
                   CASE WHEN(flitem_showbudgetprcnt) THEN 0.00
52063
 
                        ELSE NULL
52064
 
                   END AS budgetprcnt,
52065
 
                   CASE WHEN(flitem_showdiffprcnt) THEN 0.00
52066
 
                        ELSE NULL
52067
 
                   END AS diffprcnt,
52068
 
                   CASE WHEN(flitem_showcustomprcnt) THEN 0.00
52069
 
                        ELSE NULL
52070
 
                   END AS customprcnt,
52071
 
                   accnt_id,
52072
 
                   public.formatglaccount(accnt_id) AS accnt_number
52073
 
              FROM
52074
 
                (SELECT 
52075
 
                  flhead_type,flitem_id,flitem_order,flitem_subtract,flitem_showstart,flitem_showend,
52076
 
                  flitem_showdelta,flitem_showbudget,flitem_showdiff,flitem_showcustom,
52077
 
                  flitem_custom_source,flitem_showstartprcnt,flitem_showendprcnt,flitem_showdeltaprcnt,
52078
 
                  flitem_showbudgetprcnt,flitem_showdiffprcnt,flitem_showcustomprcnt,
52079
 
                  accnt_id,accnt_type,
52080
 
                  FIRST(trialbal_id) AS first_trialbal_id, LAST(trialbal_id) AS last_trialbal_id,
52081
 
                  SUM(trialbal_debits) AS sum_trialbal_debits, SUM(trialbal_credits) AS sum_trialbal_credits, 
52082
 
                  LAST(flitem_period_id) AS last_flitem_period_id,
52083
 
                  SUM(budget_amount) AS sum_budget_amount, LAST(budget_amount) AS last_budget_amount
52084
 
                  FROM
52085
 
                (SELECT period_id AS flitem_period_id, period_start,flhead_type,flitem_id,flitem_order,flitem_subtract,flitem_showstart,flitem_showend,
52086
 
                        flitem_showdelta,flitem_showbudget,flitem_showdiff,flitem_showcustom,
52087
 
                        flitem_custom_source,flitem_showstartprcnt,flitem_showendprcnt,flitem_showdeltaprcnt,
52088
 
                        flitem_showbudgetprcnt,flitem_showdiffprcnt,flitem_showcustomprcnt,
52089
 
                        accnt_id,accnt_type,COALESCE(trialbal_id,getlasttrialbalid(accnt_id,period_id)) as trialbal_id,COALESCE(trialbal_debits,0) as trialbal_debits,
52090
 
                        COALESCE(trialbal_credits,0) AS trialbal_credits,COALESCE(budget_amount,0) AS budget_amount
52091
 
                   FROM (SELECT period_id, period_start, flhead_type, flitem_id,flitem_order,flitem_subtract,flitem_showstart,flitem_showend,
52092
 
                                flitem_showdelta,flitem_showbudget,flitem_showdiff,flitem_showcustom,flitem_custom_source,flitem_showstartprcnt,
52093
 
                                flitem_showendprcnt,flitem_showdeltaprcnt,flitem_showbudgetprcnt,flitem_showdiffprcnt,flitem_showcustomprcnt,
52094
 
                                accnt_id, accnt_type
52095
 
                        FROM  period,flaccnt
52096
 
                        WHERE ((flitem_flhead_id=pFlheadid)
52097
 
                        AND (flitem_flgrp_id=pFlgrpid)
52098
 
                        AND (_all OR prj_id=pPrjId)
52099
 
                        AND (period_id IN  (SELECT * FROM getperiodid(pPeriodId,pInterval))))
52100
 
                        ORDER BY flitem_id
52101
 
                        ) AS flitem
52102
 
                   LEFT OUTER JOIN trialbal
52103
 
                     ON ((trialbal_accnt_id=accnt_id)
52104
 
                     AND (trialbal_period_id=period_id))
52105
 
                   LEFT OUTER JOIN budget
52106
 
                     ON ((budget_accnt_id=accnt_id)
52107
 
                     AND (budget_period_id=period_id))
52108
 
             ORDER BY accnt_id, period_start) AS data
52109
 
             GROUP BY flhead_type,flitem_id,flitem_order,flitem_subtract,flitem_showstart,flitem_showend,
52110
 
                flitem_showdelta,flitem_showbudget,flitem_showdiff,flitem_showcustom,
52111
 
                flitem_custom_source,flitem_showstartprcnt,flitem_showendprcnt,flitem_showdeltaprcnt,
52112
 
                flitem_showbudgetprcnt,flitem_showdiffprcnt,flitem_showcustomprcnt,accnt_id,accnt_type) AS agg
52113
 
             UNION ALL
52114
 
            SELECT 'S' AS type, flspec_id AS type_id,
52115
 
                   flspec_order AS orderby,
52116
 
                   FALSE AS summarize,
52117
 
                   flspec_subtract AS subtract,
52118
 
                   CASE WHEN (flspec_showstart) THEN findSpecialFinancial('S', flspec_type, pPeriodid)
52119
 
                        ELSE NULL
52120
 
                   END AS beginning,
52121
 
                   CASE WHEN (flspec_showend) THEN findSpecialFinancial('E', flspec_type, pPeriodid)
52122
 
                        ELSE NULL
52123
 
                   END AS ending,
52124
 
                   CASE WHEN (flspec_showdelta) THEN findSpecialFinancial('D', flspec_type, pPeriodid)
52125
 
                        ELSE NULL
52126
 
                   END AS debits,
52127
 
                   CASE WHEN (flspec_showdelta) THEN findSpecialFinancial('C', flspec_type, pPeriodid)
52128
 
                        ELSE NULL
52129
 
                   END AS credits,
52130
 
                   CASE WHEN (flspec_showbudget) THEN findSpecialFinancial('B', flspec_type, pPeriodid)
52131
 
                        ELSE NULL
52132
 
                   END AS budget,
52133
 
                   CASE WHEN (flspec_showdiff) THEN findSpecialFinancial('E', flspec_type, pPeriodid) - findSpecialFinancial('S', flspec_type, pPeriodid)
52134
 
                        ELSE NULL
52135
 
                   END AS diff,
52136
 
                   CASE WHEN (NOT flspec_showcustom) THEN NULL
52137
 
                        WHEN (flspec_custom_source='F') THEN findSpecialFinancial('E', flspec_type, pPeriodid) - findSpecialFinancial('S', flspec_type, pPeriodid)
52138
 
                        WHEN (flspec_custom_source IN ('S', 'E', 'D', 'C', 'B')) THEN findSpecialFinancial(flspec_custom_source, flspec_type, pPeriodid)
52139
 
                        ELSE 0.00
52140
 
                   END AS custom,
52141
 
                   CASE WHEN(flspec_showstartprcnt) THEN 0.00
52142
 
                        ELSE NULL
52143
 
                   END AS beginningprcnt,
52144
 
                   CASE WHEN(flspec_showendprcnt) THEN 0.00
52145
 
                        ELSE NULL
52146
 
                   END AS endingprcnt,
52147
 
                   CASE WHEN(flspec_showdeltaprcnt) THEN 0.00
52148
 
                        ELSE NULL
52149
 
                   END AS debitsprcnt,
52150
 
                   CASE WHEN(flspec_showdeltaprcnt) THEN 0.00
52151
 
                        ELSE NULL
52152
 
                   END AS creditsprcnt,
52153
 
                   CASE WHEN(flspec_showbudgetprcnt) THEN 0.00
52154
 
                        ELSE NULL
52155
 
                   END AS budgetprcnt,
52156
 
                   CASE WHEN(flspec_showdiffprcnt) THEN 0.00
52157
 
                        ELSE NULL
52158
 
                   END AS diffprcnt,
52159
 
                   CASE WHEN(flspec_showcustomprcnt) THEN 0.00
52160
 
                        ELSE NULL
52161
 
                   END AS customprcnt,
52162
 
                   -1 AS accnt_id,
52163
 
                   '' AS accnt_number
52164
 
              FROM flspec
52165
 
             WHERE ((flspec_flgrp_id=pFlgrpid)
52166
 
               AND  (flspec_flhead_id=pFlheadid))
52167
 
          ORDER BY orderby, accnt_number LOOP
52168
 
 
52169
 
    IF (_r.type = 'G') THEN
52170
 
 
52171
 
      INSERT INTO flrpt
52172
 
             (flrpt_flhead_id, flrpt_period_id, flrpt_username,
52173
 
              flrpt_order,
52174
 
              flrpt_level, flrpt_type, flrpt_type_id,
52175
 
              flrpt_beginning, flrpt_ending,
52176
 
              flrpt_debits, flrpt_credits, flrpt_budget, flrpt_diff, flrpt_custom,
52177
 
              flrpt_beginningprcnt, flrpt_endingprcnt,
52178
 
              flrpt_debitsprcnt, flrpt_creditsprcnt, flrpt_budgetprcnt, flrpt_diffprcnt, flrpt_customprcnt,
52179
 
              flrpt_parent_id, flrpt_interval)
52180
 
      VALUES (pFlheadid, pPeriodid, _username,
52181
 
              (COALESCE(( SELECT MAX(flrpt_order)
52182
 
                            FROM flrpt
52183
 
                           WHERE ((flrpt_flhead_id=pFlheadid)
52184
 
                             AND  (flrpt_period_id=pPeriodid)
52185
 
                             AND (flrpt_interval=pInterval)
52186
 
                             )
52187
 
                        ), 1) + 1),
52188
 
              pLevel, _r.type, _r.type_id,
52189
 
              _r.beginning, _r.ending,
52190
 
              _r.debits, _r.credits, _r.budget, _r.diff, _r.custom,
52191
 
              _r.beginningprcnt, _r.endingprcnt,
52192
 
              _r.debitsprcnt, _r.creditsprcnt, _r.budgetprcnt, _r.diffprcnt, _r.customprcnt,
52193
 
              pFlgrpid, pInterval);
52194
 
 
52195
 
      PERFORM insertFlGroup(pFlheadid, pPeriodid, _r.type_id, (pLevel + 1), (pSummarize OR _r.summarize), pInterval, pPrjid);
52196
 
 
52197
 
      SELECT COALESCE(flrpt_beginning, 0.00) AS beginning,
52198
 
             COALESCE(flrpt_ending, 0.00) AS ending,
52199
 
             COALESCE(flrpt_debits, 0.00) AS debits,
52200
 
             COALESCE(flrpt_credits, 0.00) AS credits,
52201
 
             COALESCE(flrpt_budget, 0.00) AS budget,
52202
 
             COALESCE(flrpt_diff, 0.00) AS diff,
52203
 
             COALESCE(flrpt_custom, 0.00) AS custom INTO _g
52204
 
        FROM flrpt
52205
 
       WHERE ((flrpt_flhead_id=pFlheadid)
52206
 
         AND  (flrpt_period_id=pPeriodid)
52207
 
          AND (flrpt_interval=pInterval)
52208
 
         AND  (flrpt_type=_r.type)
52209
 
         AND  (flrpt_type_id=_r.type_id));
52210
 
      IF (_r.subtract) THEN
52211
 
        UPDATE flrpt
52212
 
           SET flrpt_beginning = flrpt_beginning - _g.beginning,
52213
 
               flrpt_ending    = flrpt_ending    - _g.ending,
52214
 
               flrpt_debits    = flrpt_debits    - _g.debits,
52215
 
               flrpt_credits   = flrpt_credits   - _g.credits,
52216
 
               flrpt_budget    = flrpt_budget    - _g.budget,
52217
 
               flrpt_diff      = flrpt_diff      - _g.diff,
52218
 
               flrpt_custom    = flrpt_custom    - _g.custom
52219
 
         WHERE ((flrpt_flhead_id=pFlheadid)
52220
 
           AND  (flrpt_period_id=pPeriodid)
52221
 
           AND  (flrpt_interval=pInterval)
52222
 
           AND  (flrpt_type='G')
52223
 
           AND  (flrpt_type_id=pFlgrpid));
52224
 
      ELSE
52225
 
        UPDATE flrpt
52226
 
           SET flrpt_beginning = flrpt_beginning + _g.beginning,
52227
 
               flrpt_ending    = flrpt_ending    + _g.ending,
52228
 
               flrpt_debits    = flrpt_debits    + _g.debits,
52229
 
               flrpt_credits   = flrpt_credits   + _g.credits,
52230
 
               flrpt_budget    = flrpt_budget    + _g.budget,
52231
 
               flrpt_diff      = flrpt_diff      + _g.diff,
52232
 
               flrpt_custom    = flrpt_custom    + _g.custom
52233
 
         WHERE ((flrpt_flhead_id=pFlheadid)
52234
 
           AND  (flrpt_period_id=pPeriodid)
52235
 
           AND  (flrpt_interval=pInterval)
52236
 
           AND  (flrpt_type='G')
52237
 
           AND  (flrpt_type_id=pFlgrpid));
52238
 
      END IF;
52239
 
 
52240
 
      IF (pSummarize) THEN
52241
 
        DELETE FROM flrpt
52242
 
         WHERE ((flrpt_flhead_id=pFlheadid)
52243
 
          AND  (flrpt_period_id=pPeriodid)
52244
 
          AND  (flrpt_interval=pInterval)
52245
 
          AND  (flrpt_type=_r.type)
52246
 
          AND  (flrpt_type_id=_r.type_id));
52247
 
      END IF;
52248
 
 
52249
 
    ELSE
52250
 
      IF (_r.type = 'I' OR _r.type = 'S' ) THEN
52251
 
 
52252
 
        IF (NOT pSummarize) THEN
52253
 
          INSERT INTO flrpt
52254
 
                 (flrpt_flhead_id, flrpt_period_id, flrpt_username,
52255
 
                  flrpt_order,
52256
 
                  flrpt_level, flrpt_type, flrpt_type_id,
52257
 
                  flrpt_beginning, flrpt_ending,
52258
 
                  flrpt_debits, flrpt_credits, flrpt_budget, flrpt_diff, flrpt_custom,
52259
 
                  flrpt_beginningprcnt, flrpt_endingprcnt,
52260
 
                  flrpt_debitsprcnt, flrpt_creditsprcnt, flrpt_budgetprcnt, flrpt_diffprcnt, flrpt_customprcnt,
52261
 
                  flrpt_parent_id,flrpt_accnt_id,flrpt_interval)
52262
 
          VALUES (pFlheadid, pPeriodid, _username,
52263
 
                  (COALESCE(( SELECT MAX(flrpt_order)
52264
 
                               FROM flrpt
52265
 
                              WHERE ((flrpt_flhead_id=pFlheadid)
52266
 
                                AND  (flrpt_period_id=pPeriodid)
52267
 
                                AND  (flrpt_interval=pInterval)
52268
 
                                )
52269
 
                            ), 1) + 1),
52270
 
                  pLevel, _r.type, _r.type_id,
52271
 
                  _r.beginning, _r.ending,
52272
 
                  _r.debits, _r.credits, _r.budget, _r.diff, _r.custom,
52273
 
                  _r.beginningprcnt, _r.endingprcnt,
52274
 
                  _r.debitsprcnt, _r.creditsprcnt, _r.budgetprcnt, _r.diffprcnt, _r.customprcnt,
52275
 
                  pFlgrpid,_r.accnt_id,pInterval);
52276
 
        END IF;
52277
 
 
52278
 
        IF (_r.subtract) THEN
52279
 
          UPDATE flrpt
52280
 
             SET flrpt_beginning = flrpt_beginning - COALESCE(_r.beginning, 0.00),
52281
 
                 flrpt_ending    = flrpt_ending    - COALESCE(_r.ending, 0.00),
52282
 
                 flrpt_debits    = flrpt_debits    - COALESCE(_r.debits, 0.00),
52283
 
                 flrpt_credits   = flrpt_credits   - COALESCE(_r.credits, 0.00),
52284
 
                 flrpt_budget    = flrpt_budget    - COALESCE(_r.budget, 0.00),
52285
 
                 flrpt_diff      = flrpt_diff      - COALESCE(_r.diff, 0.00),
52286
 
                 flrpt_custom    = flrpt_custom    - COALESCE(_r.custom, 0.00)
52287
 
           WHERE ((flrpt_flhead_id=pFlheadid)
52288
 
             AND  (flrpt_period_id=pPeriodid)
52289
 
             AND  (flrpt_interval=pInterval)
52290
 
             AND  (flrpt_type='G')
52291
 
             AND  (flrpt_type_id=pFlgrpid));
52292
 
        ELSE
52293
 
          UPDATE flrpt
52294
 
             SET flrpt_beginning = flrpt_beginning + COALESCE(_r.beginning, 0.00),
52295
 
                 flrpt_ending    = flrpt_ending    + COALESCE(_r.ending, 0.00),
52296
 
                 flrpt_debits    = flrpt_debits    + COALESCE(_r.debits, 0.00),
52297
 
                 flrpt_credits   = flrpt_credits   + COALESCE(_r.credits, 0.00),
52298
 
                 flrpt_budget    = flrpt_budget    + COALESCE(_r.budget, 0.00),
52299
 
                 flrpt_diff      = flrpt_diff      + COALESCE(_r.diff, 0.00),
52300
 
                 flrpt_custom    = flrpt_custom    + COALESCE(_r.custom, 0.00)
52301
 
           WHERE ((flrpt_flhead_id=pFlheadid)
52302
 
             AND  (flrpt_interval=pInterval)
52303
 
             AND  (flrpt_period_id=pPeriodid)
52304
 
             AND  (flrpt_type='G')
52305
 
             AND  (flrpt_type_id=pFlgrpid));
52306
 
        END IF;
52307
 
 
52308
 
      END IF;
52309
 
    END IF;
52310
 
 
52311
 
  END LOOP;
52312
 
 
52313
 
  IF (NOT pSummarize) THEN
52314
 
    IF (_subtotal) THEN
52315
 
      INSERT INTO flrpt
52316
 
             (flrpt_flhead_id, flrpt_period_id, flrpt_username,
52317
 
              flrpt_order,
52318
 
              flrpt_level, flrpt_type, flrpt_type_id,
52319
 
              flrpt_beginning, flrpt_ending,
52320
 
              flrpt_debits, flrpt_credits, flrpt_budget, flrpt_diff, flrpt_custom,
52321
 
              flrpt_beginningprcnt, flrpt_endingprcnt,
52322
 
              flrpt_debitsprcnt, flrpt_creditsprcnt, flrpt_budgetprcnt, flrpt_diffprcnt, flrpt_customprcnt,
52323
 
              flrpt_parent_id, flrpt_altname,flrpt_interval )
52324
 
      SELECT pFlheadid, pPeriodid, _username,
52325
 
             (COALESCE(( SELECT MAX(flrpt_order)
52326
 
                           FROM flrpt
52327
 
                          WHERE ((flrpt_flhead_id=pFlheadid)
52328
 
                            AND  (flrpt_period_id=pPeriodid)
52329
 
                            AND  (flrpt_interval=pInterval)
52330
 
                                )
52331
 
                       ), 1) + 1),
52332
 
             pLevel, 'T', -1,
52333
 
             CASE WHEN (flgrp_showstart) THEN flrpt_beginning
52334
 
                  ELSE NULL
52335
 
             END,
52336
 
             CASE WHEN (flgrp_showend) THEN flrpt_ending
52337
 
                  ELSE NULL
52338
 
             END,
52339
 
             CASE WHEN (flgrp_showdelta) THEN flrpt_debits
52340
 
                  ELSE NULL
52341
 
             END,
52342
 
             CASE WHEN (flgrp_showdelta) THEN flrpt_credits
52343
 
                  ELSE NULL
52344
 
             END,
52345
 
             CASE WHEN (flgrp_showbudget) THEN flrpt_budget
52346
 
                  ELSE NULL
52347
 
             END,
52348
 
             CASE WHEN (flgrp_showdiff) THEN flrpt_diff
52349
 
                  ELSE NULL
52350
 
             END,
52351
 
             CASE WHEN (flgrp_showcustom) THEN flrpt_custom
52352
 
                  ELSE NULL
52353
 
             END,
52354
 
             CASE WHEN (flgrp_showstartprcnt) THEN flrpt_beginningprcnt
52355
 
                  ELSE NULL
52356
 
             END,
52357
 
             CASE WHEN (flgrp_showendprcnt) THEN flrpt_endingprcnt
52358
 
                  ELSE NULL
52359
 
             END,
52360
 
             CASE WHEN (flgrp_showdeltaprcnt) THEN flrpt_debitsprcnt
52361
 
                  ELSE NULL
52362
 
             END,
52363
 
             CASE WHEN (flgrp_showdeltaprcnt) THEN flrpt_creditsprcnt
52364
 
                  ELSE NULL
52365
 
             END,
52366
 
             CASE WHEN (flgrp_showbudgetprcnt) THEN flrpt_budgetprcnt
52367
 
                  ELSE NULL
52368
 
             END,
52369
 
             CASE WHEN (flgrp_showdiffprcnt) THEN flrpt_diffprcnt
52370
 
                  ELSE NULL
52371
 
             END,
52372
 
             CASE WHEN (flgrp_showcustomprcnt) THEN flrpt_customprcnt
52373
 
                  ELSE NULL
52374
 
             END,
52375
 
             pFlgrpid,
52376
 
             CASE WHEN (flgrp_usealtsubtotal) THEN flgrp_altsubtotal
52377
 
                  ELSE NULL
52378
 
             END, pInterval
52379
 
        FROM flrpt, flgrp
52380
 
       WHERE ((flrpt_flhead_id=flgrp_flhead_id)
52381
 
         AND  (flrpt_type_id=flgrp_id)
52382
 
         AND  (flrpt_flhead_id=pFlheadid)
52383
 
         AND  (flrpt_period_id=pPeriodid)
52384
 
         AND  (flrpt_interval=pInterval)
52385
 
         AND  (flrpt_type='G')
52386
 
         AND  (flrpt_type_id=pFlgrpid));
52387
 
    END IF;
52388
 
  END IF;
52389
 
 
52390
 
  return TRUE;
52391
 
END;
52392
 
$$;
52393
 
 
52394
 
 
52395
 
ALTER FUNCTION public.insertflgroup(pflheadid integer, pperiodid integer, pflgrpid integer, plevel integer, psummarize boolean, pinterval character, pprjid integer) OWNER TO admin;
52396
 
 
52397
 
--
52398
 
--
52399
 
 
52400
 
CREATE FUNCTION insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date) RETURNS integer
52401
 
    LANGUAGE plpgsql
52402
 
    AS $_$
52403
 
DECLARE
52404
 
  pSource ALIAS FOR $1;
52405
 
  pDocType ALIAS FOR $2;
52406
 
  pDocNumber ALIAS FOR $3;
52407
 
  pNotes ALIAS FOR $4;
52408
 
  pCreditid ALIAS FOR $5;
52409
 
  pDebitid ALIAS FOR $6;
52410
 
  pMiscid ALIAS FOR $7;
52411
 
  pAmount ALIAS FOR $8;
52412
 
  pDistDate ALIAS FOR $9;
52413
 
  _return INTEGER;
52414
 
 
52415
 
BEGIN
52416
 
 
52417
 
  SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'),
52418
 
                              pSource, pDocType, pDocNumber, pNotes,
52419
 
                              pCreditid, pDebitid, pMiscid, pAmount, pDistDate) INTO _return;
52420
 
 
52421
 
  RETURN _return;
52422
 
 
52423
 
END;
52424
 
$_$;
52425
 
 
52426
 
 
52427
 
ALTER FUNCTION public.insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date) OWNER TO admin;
52428
 
 
52429
 
--
52430
 
--
52431
 
 
52432
 
CREATE FUNCTION insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date) RETURNS integer
52433
 
    LANGUAGE plpgsql
52434
 
    AS $_$
52435
 
DECLARE
52436
 
  pJournalNumber ALIAS FOR $1;
52437
 
  pSource ALIAS FOR $2;
52438
 
  pDocType ALIAS FOR $3;
52439
 
  pDocNumber ALIAS FOR $4;
52440
 
  pNotes ALIAS FOR $5;
52441
 
  pCreditid ALIAS FOR $6;
52442
 
  pDebitid ALIAS FOR $7;
52443
 
  pMiscid ALIAS FOR $8;
52444
 
  pAmount ALIAS FOR $9;
52445
 
  pDistDate ALIAS FOR $10;
52446
 
  _return INTEGER;
52447
 
 
52448
 
BEGIN
52449
 
 
52450
 
  SELECT insertGLTransaction( pJournalNumber, pSource, pDocType, pDocNumber, pNotes,
52451
 
                              pCreditid, pDebitid, pMiscid, pAmount, pDistDate, TRUE) INTO _return;
52452
 
 
52453
 
  RETURN _return;
52454
 
 
52455
 
END;
52456
 
$_$;
52457
 
 
52458
 
 
52459
 
ALTER FUNCTION public.insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date) OWNER TO admin;
52460
 
 
52461
 
--
52462
 
--
52463
 
 
52464
 
CREATE FUNCTION insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date, boolean) RETURNS integer
52465
 
    LANGUAGE plpgsql
52466
 
    AS $_$
52467
 
DECLARE
52468
 
  pSource ALIAS FOR $1;
52469
 
  pDocType ALIAS FOR $2;
52470
 
  pDocNumber ALIAS FOR $3;
52471
 
  pNotes ALIAS FOR $4;
52472
 
  pCreditid ALIAS FOR $5;
52473
 
  pDebitid ALIAS FOR $6;
52474
 
  pMiscid ALIAS FOR $7;
52475
 
  pAmount ALIAS FOR $8;
52476
 
  pDistDate ALIAS FOR $9;
52477
 
  pPostTrialBal ALIAS FOR $10;
52478
 
  _return INTEGER;
52479
 
 
52480
 
BEGIN
52481
 
 
52482
 
  SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'),
52483
 
                              pSource, pDocType, pDocNumber, pNotes,
52484
 
                              pCreditid, pDebitid, pMiscid, pAmount, pDistDate, pPostTrialBal) INTO _return;
52485
 
 
52486
 
  RETURN _return;
52487
 
 
52488
 
END;
52489
 
$_$;
52490
 
 
52491
 
 
52492
 
ALTER FUNCTION public.insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date, boolean) OWNER TO admin;
52493
 
 
52494
 
--
52495
 
--
52496
 
 
52497
 
CREATE FUNCTION insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean) RETURNS integer
52498
 
    LANGUAGE plpgsql
52499
 
    AS $_$
52500
 
DECLARE
52501
 
  pJournalNumber ALIAS FOR $1;
52502
 
  pSource ALIAS FOR $2;
52503
 
  pDocType ALIAS FOR $3;
52504
 
  pDocNumber ALIAS FOR $4;
52505
 
  pNotes ALIAS FOR $5;
52506
 
  pCreditid ALIAS FOR $6;
52507
 
  pDebitid ALIAS FOR $7;
52508
 
  pMiscid ALIAS FOR $8;
52509
 
  pAmount ALIAS FOR $9;
52510
 
  pDistDate ALIAS FOR $10;
52511
 
  pPostTrialBal ALIAS FOR $11;
52512
 
  
52513
 
  _return INTEGER;
52514
 
 
52515
 
BEGIN
52516
 
 
52517
 
  SELECT insertGLTransaction( pJournalNumber, pSource, pDocType, pDocNumber, pNotes,
52518
 
                              pCreditid, pDebitid, pMiscid, pAmount, pDistDate, pPostTrialBal, false) INTO _return;
52519
 
 
52520
 
  RETURN _return;
52521
 
 
52522
 
END;
52523
 
$_$;
52524
 
 
52525
 
 
52526
 
ALTER FUNCTION public.insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean) OWNER TO admin;
52527
 
 
52528
 
--
52529
 
--
52530
 
 
52531
 
CREATE FUNCTION insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean, boolean) RETURNS integer
52532
 
    LANGUAGE plpgsql
52533
 
    AS $_$
52534
 
DECLARE
52535
 
  pJournalNumber ALIAS FOR $1;
52536
 
  pSource ALIAS FOR $2;
52537
 
  pDocType ALIAS FOR $3;
52538
 
  pDocNumber ALIAS FOR $4;
52539
 
  pNotes ALIAS FOR $5;
52540
 
  pCreditid ALIAS FOR $6;
52541
 
  pDebitid ALIAS FOR $7;
52542
 
  pMiscid ALIAS FOR $8;
52543
 
  pAmount ALIAS FOR $9;
52544
 
  pDistDate ALIAS FOR $10;
52545
 
  pPostTrialBal ALIAS FOR $11;
52546
 
  pOnlyGL ALIAS FOR $12;
52547
 
  _debitid INTEGER;
52548
 
  _creditid INTEGER;
52549
 
  _sequence INTEGER;
52550
 
  _check INTEGER;
52551
 
 
52552
 
BEGIN
52553
 
 
52554
 
  IF (fetchMetricBool('InterfaceToGL') = false AND pSource IN ('I/M', 'P/D', 'S/R', 'W/O')) THEN
52555
 
    RETURN 0;
52556
 
  END IF;
52557
 
  IF (fetchMetricBool('InterfaceAPToGL') = false AND pSource = 'A/P') THEN
52558
 
    RETURN 0;
52559
 
  END IF;
52560
 
  IF (fetchMetricBool('InterfaceARToGL') = false AND pSource IN ('A/R', 'S/O', 'S/R')) THEN
52561
 
    RETURN 0;
52562
 
  END IF;
52563
 
 
52564
 
  IF (round(pAmount, 2) = 0) THEN
52565
 
    RETURN -3;
52566
 
  END IF;
52567
 
 
52568
 
/*  Make sure we don't create an imbalance across companies.
52569
 
    The 'IgnoreCompanyBalance' metric is a back door mechanism to
52570
 
    allow legacy users to create transactions accross companies if
52571
 
    they have been using the company segment for something else
52572
 
    and they MUST continue to be able to do so.  It can only be 
52573
 
    implemented by direct sql update to the metric table and should 
52574
 
    otherwise be discouraged.
52575
 
*/ 
52576
 
  IF (COALESCE(fetchMetricValue('GLCompanySize'),0) > 0 
52577
 
    AND fetchMetricBool('IgnoreCompany') = false)  THEN
52578
 
 
52579
 
    IF (SELECT (COALESCE(d.accnt_company,'') != COALESCE(c.accnt_company,''))
52580
 
       FROM accnt d, accnt c
52581
 
       WHERE ((d.accnt_id=pDebitid)
52582
 
        AND (c.accnt_id=pCreditid))) THEN
52583
 
      RAISE EXCEPTION 'G/L Transaction can not be posted because accounts % and % reference two differnt companies.',
52584
 
        formatGlaccount(pDebitid), formatGlaccount(pCreditid);
52585
 
    END IF;
52586
 
  END IF;
52587
 
 
52588
 
  IF (pDebitid IN (SELECT accnt_id FROM accnt)) THEN
52589
 
    _debitid := pDebitid;
52590
 
  ELSE
52591
 
    SELECT getUnassignedAccntId() INTO _debitid;
52592
 
  END IF;
52593
 
 
52594
 
  IF (pCreditid IN (SELECT accnt_id FROM accnt)) THEN
52595
 
    _creditid := pCreditid;
52596
 
  ELSE
52597
 
    SELECT getUnassignedAccntId() INTO _creditid;
52598
 
  END IF;
52599
 
 
52600
 
  IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE))
52601
 
      FROM accnt LEFT OUTER JOIN
52602
 
           period ON (pDistDate BETWEEN period_start AND period_end)
52603
 
      WHERE (accnt_id IN (_creditid, _debitid))) THEN
52604
 
    RAISE EXCEPTION 'Cannot post to closed period (%).', pDistDate;
52605
 
    RETURN -4;  -- remove raise exception when all callers check return code
52606
 
  END IF;
52607
 
 
52608
 
  IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND
52609
 
             BOOL_AND(COALESCE(period_freeze, FALSE))
52610
 
      FROM accnt LEFT OUTER JOIN
52611
 
           period ON (pDistDate BETWEEN period_start AND period_end)
52612
 
      WHERE (accnt_id IN (_creditid, _debitid))) THEN
52613
 
    RAISE EXCEPTION 'Cannot post to frozen period (%).', pDistDate;
52614
 
    RETURN -4;  -- remove raise exception when all callers check return code
52615
 
  END IF;
52616
 
 
52617
 
  IF NOT EXISTS(SELECT period_id
52618
 
                FROM period
52619
 
                WHERE (pDistDate BETWEEN period_start AND period_end)) THEN
52620
 
    RAISE EXCEPTION 'Cannot post to nonexistent period (%).', pDistDate;
52621
 
  END IF;
52622
 
 
52623
 
  SELECT fetchGLSequence() INTO _sequence;
52624
 
 
52625
 
  IF (NOT pOnlyGL AND fetchMetricBool('UseJournals')) THEN
52626
 
  --  First the credit  
52627
 
    INSERT INTO sltrans
52628
 
    ( sltrans_journalnumber, sltrans_posted, sltrans_created, sltrans_date,
52629
 
      sltrans_sequence, sltrans_accnt_id, sltrans_source,
52630
 
      sltrans_doctype, sltrans_docnumber, sltrans_notes,
52631
 
      sltrans_misc_id, sltrans_amount )
52632
 
    VALUES
52633
 
    ( pJournalNumber, FALSE, CURRENT_TIMESTAMP, pDistDate,
52634
 
      _sequence, _creditid, pSource,
52635
 
      pDocType, pDocNumber, pNotes,
52636
 
      pMiscid, pAmount );
52637
 
 
52638
 
  --  Now the debit
52639
 
    INSERT INTO sltrans
52640
 
    ( sltrans_journalnumber, sltrans_posted, sltrans_created, sltrans_date,
52641
 
      sltrans_sequence, sltrans_accnt_id, sltrans_source,
52642
 
      sltrans_doctype, sltrans_docnumber, sltrans_notes,
52643
 
      sltrans_misc_id, sltrans_amount )
52644
 
    VALUES
52645
 
    ( pJournalNumber, FALSE, CURRENT_TIMESTAMP, pDistDate,
52646
 
      _sequence, _debitid, pSource,
52647
 
      pDocType, pDocNumber, pNotes,
52648
 
      pMiscid, (pAmount * -1) );
52649
 
  ELSE
52650
 
  --  First the credit
52651
 
    INSERT INTO gltrans
52652
 
    ( gltrans_journalnumber, gltrans_posted, gltrans_exported, gltrans_created, gltrans_date,
52653
 
      gltrans_sequence, gltrans_accnt_id, gltrans_source,
52654
 
      gltrans_doctype, gltrans_docnumber, gltrans_notes,
52655
 
      gltrans_misc_id, gltrans_amount )
52656
 
    VALUES
52657
 
    ( pJournalNumber, FALSE, FALSE, CURRENT_TIMESTAMP, pDistDate,
52658
 
      _sequence, _creditid, pSource,
52659
 
      pDocType, pDocNumber, pNotes,
52660
 
      pMiscid, pAmount );
52661
 
 
52662
 
  --  Now the debit
52663
 
    INSERT INTO gltrans
52664
 
    ( gltrans_journalnumber, gltrans_posted, gltrans_exported, gltrans_created, gltrans_date,
52665
 
      gltrans_sequence, gltrans_accnt_id, gltrans_source,
52666
 
      gltrans_doctype, gltrans_docnumber, gltrans_notes,
52667
 
      gltrans_misc_id, gltrans_amount )
52668
 
    VALUES
52669
 
    ( pJournalNumber, FALSE, FALSE, CURRENT_TIMESTAMP, pDistDate,
52670
 
      _sequence, _debitid, pSource,
52671
 
      pDocType, pDocNumber, pNotes,
52672
 
      pMiscid, (pAmount * -1) );
52673
 
 
52674
 
    IF (pPostTrialBal) THEN
52675
 
      PERFORM postIntoTrialBalance(_sequence);
52676
 
    END IF;
52677
 
  END IF;
52678
 
 
52679
 
  RETURN _sequence;
52680
 
 
52681
 
END;
52682
 
$_$;
52683
 
 
52684
 
 
52685
 
ALTER FUNCTION public.insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean, boolean) OWNER TO admin;
52686
 
 
52687
 
--
52688
 
--
52689
 
 
52690
 
CREATE FUNCTION insertintoglseries(integer, text, text, text, integer, numeric) RETURNS integer
52691
 
    LANGUAGE plpgsql
52692
 
    AS $_$
52693
 
DECLARE
52694
 
  pSequence ALIAS FOR $1;
52695
 
  pSource ALIAS FOR $2;
52696
 
  pDocType ALIAS FOR $3;
52697
 
  pDocNumber ALIAS FOR $4;
52698
 
  pAccntid ALIAS FOR $5;
52699
 
  pAmount ALIAS FOR $6;
52700
 
  _returnValue INTEGER;
52701
 
 
52702
 
BEGIN
52703
 
 
52704
 
  SELECT insertIntoGLSeries( pSequence, pSource, pDocType, pDocNumber,
52705
 
                             pAccntid, pAmount, CURRENT_DATE, '' ) INTO _returnValue;
52706
 
 
52707
 
  RETURN _returnValue;
52708
 
 
52709
 
END;
52710
 
$_$;
52711
 
 
52712
 
 
52713
 
ALTER FUNCTION public.insertintoglseries(integer, text, text, text, integer, numeric) OWNER TO admin;
52714
 
 
52715
 
--
52716
 
--
52717
 
 
52718
 
CREATE FUNCTION insertintoglseries(integer, text, text, text, integer, numeric, date) RETURNS integer
52719
 
    LANGUAGE plpgsql
52720
 
    AS $_$
52721
 
DECLARE
52722
 
  pSequence ALIAS FOR $1;
52723
 
  pSource ALIAS FOR $2;
52724
 
  pDocType ALIAS FOR $3;
52725
 
  pDocNumber ALIAS FOR $4;
52726
 
  pAccntid ALIAS FOR $5;
52727
 
  pAmount ALIAS FOR $6;
52728
 
  pDistDate ALIAS FOR $7;
52729
 
  _returnValue INTEGER;
52730
 
 
52731
 
BEGIN
52732
 
 
52733
 
  SELECT insertIntoGLSeries( pSequence, pSource, pDocType, pDocNumber,
52734
 
                             pAccntid, pAmount, pDistDate, '' ) INTO _returnValue;
52735
 
 
52736
 
  RETURN _returnValue;
52737
 
 
52738
 
END;
52739
 
$_$;
52740
 
 
52741
 
 
52742
 
ALTER FUNCTION public.insertintoglseries(integer, text, text, text, integer, numeric, date) OWNER TO admin;
52743
 
 
52744
 
--
52745
 
--
52746
 
 
52747
 
CREATE FUNCTION insertintoglseries(integer, text, text, text, integer, numeric, date, text) RETURNS integer
52748
 
    LANGUAGE plpgsql
52749
 
    AS $_$
52750
 
DECLARE
52751
 
  pSequence ALIAS FOR $1;
52752
 
  pSource ALIAS FOR $2;
52753
 
  pDocType ALIAS FOR $3;
52754
 
  pDocNumber ALIAS FOR $4;
52755
 
  pAccntid ALIAS FOR $5;
52756
 
  pAmount ALIAS FOR $6;
52757
 
  pDistDate ALIAS FOR $7;
52758
 
  pNotes ALIAS FOR $8;
52759
 
  _returnValue INTEGER;
52760
 
 
52761
 
BEGIN
52762
 
 
52763
 
  SELECT insertIntoGLSeries( pSequence, pSource, pDocType, pDocNumber,
52764
 
                             pAccntid, pAmount, pDistDate, pNotes, NULL ) INTO _returnValue;
52765
 
 
52766
 
  RETURN _returnValue;
52767
 
 
52768
 
END;
52769
 
$_$;
52770
 
 
52771
 
 
52772
 
ALTER FUNCTION public.insertintoglseries(integer, text, text, text, integer, numeric, date, text) OWNER TO admin;
52773
 
 
52774
 
--
52775
 
--
52776
 
 
52777
 
CREATE FUNCTION insertintoglseries(integer, text, text, text, integer, numeric, date, text, integer) RETURNS integer
52778
 
    LANGUAGE plpgsql
52779
 
    AS $_$
52780
 
DECLARE
52781
 
  pSequence ALIAS FOR $1;
52782
 
  pSource ALIAS FOR $2;
52783
 
  pDocType ALIAS FOR $3;
52784
 
  pDocNumber ALIAS FOR $4;
52785
 
  pAccntid ALIAS FOR $5;
52786
 
  pAmount ALIAS FOR $6;
52787
 
  pDistDate ALIAS FOR $7;
52788
 
  pNotes ALIAS FOR $8;
52789
 
  pMiscid ALIAS FOR $9;
52790
 
  _glseriesid INTEGER;
52791
 
 
52792
 
BEGIN
52793
 
 
52794
 
  IF (fetchMetricBool('InterfaceToGL') = false AND pSource IN ('I/M', 'P/D', 'S/R', 'W/O')) THEN
52795
 
    RETURN 0;
52796
 
  END IF;
52797
 
  IF (fetchMetricBool('InterfaceAPToGL') = false AND pSource = 'A/P') THEN
52798
 
    RETURN 0;
52799
 
  END IF;
52800
 
  IF (fetchMetricBool('InterfaceARToGL') = false AND pSource IN ('A/R', 'S/O', 'S/R')) THEN
52801
 
    RETURN 0;
52802
 
  END IF;
52803
 
 
52804
 
  IF ( (pAccntid IS NULL) OR (pAccntid = -1) ) THEN
52805
 
    RETURN -1;
52806
 
  END IF;
52807
 
 
52808
 
  IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE))
52809
 
      FROM accnt LEFT OUTER JOIN
52810
 
           period ON (pDistDate BETWEEN period_start AND period_end)
52811
 
      WHERE (accnt_id = pAccntid)) THEN
52812
 
    RAISE EXCEPTION 'Cannot post to closed period (%).', pDistDate;
52813
 
    RETURN -4;  -- remove raise exception when all callers check return code
52814
 
  END IF;
52815
 
 
52816
 
  IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND
52817
 
             BOOL_AND(COALESCE(period_freeze, FALSE))
52818
 
      FROM accnt LEFT OUTER JOIN
52819
 
           period ON (pDistDate BETWEEN period_start AND period_end)
52820
 
      WHERE (accnt_id = pAccntid)) THEN
52821
 
    RAISE EXCEPTION 'Cannot post to frozen period (%).', pDistDate;
52822
 
    RETURN -4;  -- remove raise exception when all callers check return code
52823
 
  END IF;
52824
 
 
52825
 
  IF NOT EXISTS(SELECT period_id
52826
 
                FROM period
52827
 
                WHERE (pDistDate BETWEEN period_start AND period_end)) THEN
52828
 
    RAISE EXCEPTION 'Cannot post to nonexistent period (%).', pDistDate;
52829
 
  END IF;
52830
 
 
52831
 
  SELECT NEXTVAL('glseries_glseries_id_seq') INTO _glseriesid;
52832
 
  INSERT INTO glseries
52833
 
  ( glseries_id, glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber,
52834
 
    glseries_accnt_id, glseries_amount, glseries_distdate, glseries_notes, glseries_misc_id )
52835
 
  VALUES
52836
 
  ( _glseriesid, pSequence, pSource, pDocType, pDocNumber,
52837
 
    pAccntid, pAmount, pDistDate, pNotes, pMiscid );
52838
 
 
52839
 
  RETURN _glseriesid;
52840
 
 
52841
 
END;
52842
 
$_$;
52843
 
 
52844
 
 
52845
 
ALTER FUNCTION public.insertintoglseries(integer, text, text, text, integer, numeric, date, text, integer) OWNER TO admin;
52846
 
 
52847
 
--
52848
 
--
52849
 
 
52850
 
CREATE TABLE invchead (
52851
 
    invchead_id integer NOT NULL,
52852
 
    invchead_cust_id integer NOT NULL,
52853
 
    invchead_shipto_id integer,
52854
 
    invchead_ordernumber text,
52855
 
    invchead_orderdate date,
52856
 
    invchead_posted boolean NOT NULL,
52857
 
    invchead_printed boolean NOT NULL,
52858
 
    invchead_invcnumber text NOT NULL,
52859
 
    invchead_invcdate date NOT NULL,
52860
 
    invchead_shipdate date,
52861
 
    invchead_ponumber text,
52862
 
    invchead_shipvia text,
52863
 
    invchead_fob text,
52864
 
    invchead_billto_name text,
52865
 
    invchead_billto_address1 text,
52866
 
    invchead_billto_address2 text,
52867
 
    invchead_billto_address3 text,
52868
 
    invchead_billto_city text,
52869
 
    invchead_billto_state text,
52870
 
    invchead_billto_zipcode text,
52871
 
    invchead_billto_phone text,
52872
 
    invchead_shipto_name text,
52873
 
    invchead_shipto_address1 text,
52874
 
    invchead_shipto_address2 text,
52875
 
    invchead_shipto_address3 text,
52876
 
    invchead_shipto_city text,
52877
 
    invchead_shipto_state text,
52878
 
    invchead_shipto_zipcode text,
52879
 
    invchead_shipto_phone text,
52880
 
    invchead_salesrep_id integer,
52881
 
    invchead_commission numeric(20,10) NOT NULL,
52882
 
    invchead_terms_id integer,
52883
 
    invchead_freight numeric(16,2) NOT NULL,
52884
 
    invchead_misc_amount numeric(16,2) NOT NULL,
52885
 
    invchead_misc_descrip text,
52886
 
    invchead_misc_accnt_id integer,
52887
 
    invchead_payment numeric(16,2),
52888
 
    invchead_paymentref text,
52889
 
    invchead_notes text,
52890
 
    invchead_billto_country text,
52891
 
    invchead_shipto_country text,
52892
 
    invchead_prj_id integer,
52893
 
    invchead_curr_id integer DEFAULT basecurrid(),
52894
 
    invchead_gldistdate date,
52895
 
    invchead_recurring boolean DEFAULT false NOT NULL,
52896
 
    invchead_recurring_interval integer,
52897
 
    invchead_recurring_type text,
52898
 
    invchead_recurring_until date,
52899
 
    invchead_recurring_invchead_id integer,
52900
 
    invchead_shipchrg_id integer,
52901
 
    invchead_taxzone_id integer,
52902
 
    invchead_void boolean DEFAULT false,
52903
 
    invchead_saletype_id integer,
52904
 
    invchead_shipzone_id integer,
52905
 
    CONSTRAINT invchead_invchead_invcnumber_check CHECK ((invchead_invcnumber <> ''::text))
52906
 
);
52907
 
 
52908
 
 
52909
 
ALTER TABLE public.invchead OWNER TO admin;
52910
 
 
52911
 
--
52912
 
--
52913
 
 
52914
 
COMMENT ON TABLE invchead IS 'Invoice header information';
52915
 
 
52916
 
 
52917
 
--
52918
 
--
52919
 
 
52920
 
COMMENT ON COLUMN invchead.invchead_recurring IS 'Deprecated.';
52921
 
 
52922
 
 
52923
 
--
52924
 
--
52925
 
 
52926
 
COMMENT ON COLUMN invchead.invchead_recurring_interval IS 'Deprecated.';
52927
 
 
52928
 
 
52929
 
--
52930
 
--
52931
 
 
52932
 
COMMENT ON COLUMN invchead.invchead_recurring_type IS 'Deprecated.';
52933
 
 
52934
 
 
52935
 
--
52936
 
--
52937
 
 
52938
 
COMMENT ON COLUMN invchead.invchead_recurring_until IS 'Deprecated.';
52939
 
 
52940
 
 
52941
 
--
52942
 
--
52943
 
 
52944
 
COMMENT ON COLUMN invchead.invchead_saletype_id IS 'Associated sale type for invoice.';
52945
 
 
52946
 
 
52947
 
--
52948
 
--
52949
 
 
52950
 
COMMENT ON COLUMN invchead.invchead_shipzone_id IS 'Associated shipping zone for invoice.';
52951
 
 
52952
 
 
52953
 
--
52954
 
--
52955
 
 
52956
 
CREATE TABLE prj (
52957
 
    prj_id integer NOT NULL,
52958
 
    prj_number text NOT NULL,
52959
 
    prj_name text NOT NULL,
52960
 
    prj_descrip text,
52961
 
    prj_status character(1) NOT NULL,
52962
 
    prj_so boolean,
52963
 
    prj_wo boolean,
52964
 
    prj_po boolean,
52965
 
    prj_owner_username text,
52966
 
    prj_start_date date,
52967
 
    prj_due_date date,
52968
 
    prj_assigned_date date,
52969
 
    prj_completed_date date,
52970
 
    prj_username text,
52971
 
    prj_recurring_prj_id integer,
52972
 
    prj_crmacct_id integer,
52973
 
    prj_cntct_id integer,
52974
 
    prj_prjtype_id integer,
52975
 
    CONSTRAINT prj_prj_number_check CHECK ((prj_number <> ''::text)),
52976
 
    CONSTRAINT prj_prj_status_check CHECK ((prj_status = ANY (ARRAY['P'::bpchar, 'O'::bpchar, 'C'::bpchar])))
52977
 
);
52978
 
 
52979
 
 
52980
 
ALTER TABLE public.prj OWNER TO admin;
52981
 
 
52982
 
--
52983
 
--
52984
 
 
52985
 
COMMENT ON TABLE prj IS 'Project information';
52986
 
 
52987
 
 
52988
 
--
52989
 
--
52990
 
 
52991
 
COMMENT ON COLUMN prj.prj_recurring_prj_id IS 'The first prj record in the series if this is a recurring Project. If the prj_recurring_prj_id is the same as the prj_id, this record is the first in the series.';
52992
 
 
52993
 
 
52994
 
--
52995
 
--
52996
 
 
52997
 
CREATE TABLE saletype (
52998
 
    saletype_id integer NOT NULL,
52999
 
    saletype_code text NOT NULL,
53000
 
    saletype_descr text,
53001
 
    saletype_active boolean DEFAULT true NOT NULL
53002
 
);
53003
 
 
53004
 
 
53005
 
ALTER TABLE public.saletype OWNER TO admin;
53006
 
 
53007
 
--
53008
 
--
53009
 
 
53010
 
COMMENT ON TABLE saletype IS 'Type or Origination of Sale.';
53011
 
 
53012
 
 
53013
 
--
53014
 
--
53015
 
 
53016
 
COMMENT ON COLUMN saletype.saletype_id IS 'Sequence identifier for sale type.';
53017
 
 
53018
 
 
53019
 
--
53020
 
--
53021
 
 
53022
 
COMMENT ON COLUMN saletype.saletype_code IS 'User defined identifier for sale type.';
53023
 
 
53024
 
 
53025
 
--
53026
 
--
53027
 
 
53028
 
COMMENT ON COLUMN saletype.saletype_descr IS 'Description for sale type.';
53029
 
 
53030
 
 
53031
 
--
53032
 
--
53033
 
 
53034
 
COMMENT ON COLUMN saletype.saletype_active IS 'Boolean to deactivate a sale type.';
53035
 
 
53036
 
 
53037
 
--
53038
 
--
53039
 
 
53040
 
CREATE TABLE shipzone (
53041
 
    shipzone_id integer DEFAULT nextval(('shipzone_shipzone_id_seq'::text)::regclass) NOT NULL,
53042
 
    shipzone_name text NOT NULL,
53043
 
    shipzone_descrip text,
53044
 
    CONSTRAINT shipzone_shipzone_name_check CHECK ((shipzone_name <> ''::text))
53045
 
);
53046
 
 
53047
 
 
53048
 
ALTER TABLE public.shipzone OWNER TO admin;
53049
 
 
53050
 
--
53051
 
--
53052
 
 
53053
 
COMMENT ON TABLE shipzone IS 'Shipping Zone information';
53054
 
 
53055
 
 
53056
 
SET search_path = api, pg_catalog;
53057
 
 
53058
 
--
53059
 
--
53060
 
 
53061
 
CREATE VIEW invoice AS
53062
 
    SELECT invchead.invchead_invcnumber AS invoice_number, invchead.invchead_ordernumber AS order_number, invchead.invchead_invcdate AS invoice_date, invchead.invchead_shipdate AS ship_date, invchead.invchead_orderdate AS order_date, saletype.saletype_code AS sale_type, salesrep.salesrep_number AS sales_rep, invchead.invchead_commission AS commission, COALESCE(taxzone.taxzone_code, 'None'::text) AS tax_zone, terms.terms_code AS terms, custinfo.cust_number AS customer_number, invchead.invchead_billto_name AS billto_name, invchead.invchead_billto_address1 AS billto_address1, invchead.invchead_billto_address2 AS billto_address2, invchead.invchead_billto_address3 AS billto_address3, invchead.invchead_billto_city AS billto_city, invchead.invchead_billto_state AS billto_state, invchead.invchead_billto_zipcode AS billto_postal_code, invchead.invchead_billto_country AS billto_country, invchead.invchead_billto_phone AS billto_phone, shiptoinfo.shipto_num AS shipto_number, invchead.invchead_shipto_name AS shipto_name, invchead.invchead_shipto_address1 AS shipto_address1, invchead.invchead_shipto_address2 AS shipto_address2, invchead.invchead_shipto_address3 AS shipto_address3, invchead.invchead_shipto_city AS shipto_city, invchead.invchead_shipto_state AS shipto_state, invchead.invchead_shipto_zipcode AS shipto_postal_code, invchead.invchead_shipto_country AS shipto_country, shipzone.shipzone_name AS shipto_shipzone, invchead.invchead_shipto_phone AS shipto_phone, invchead.invchead_ponumber AS po_number, invchead.invchead_shipvia AS ship_via, prj.prj_number AS project_number, invchead.invchead_fob AS fob, invchead.invchead_misc_descrip AS misc_charge_description, invchead.invchead_misc_amount AS misc_charge, CASE WHEN (invchead.invchead_misc_accnt_id = (-1)) THEN NULL::text ELSE public.formatglaccount(invchead.invchead_misc_accnt_id) END AS misc_charge_account_number, invchead.invchead_freight AS freight, curr.curr_abbr AS currency, invchead.invchead_payment AS payment, invchead.invchead_notes AS notes FROM (((((((((public.invchead LEFT JOIN public.custinfo ON ((custinfo.cust_id = invchead.invchead_cust_id))) LEFT JOIN public.shiptoinfo ON ((shiptoinfo.shipto_id = invchead.invchead_shipto_id))) LEFT JOIN public.prj ON ((prj.prj_id = invchead.invchead_prj_id))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = invchead.invchead_curr_id))) LEFT JOIN public.salesrep ON ((salesrep.salesrep_id = invchead.invchead_salesrep_id))) LEFT JOIN public.terms ON ((terms.terms_id = invchead.invchead_terms_id))) LEFT JOIN public.taxzone ON ((taxzone.taxzone_id = invchead.invchead_taxzone_id))) LEFT JOIN public.saletype ON ((invchead.invchead_saletype_id = saletype.saletype_id))) LEFT JOIN public.shipzone ON ((invchead.invchead_shipzone_id = shipzone.shipzone_id)));
53063
 
 
53064
 
 
53065
 
ALTER TABLE api.invoice OWNER TO admin;
53066
 
 
53067
 
--
53068
 
--
53069
 
 
53070
 
COMMENT ON VIEW invoice IS '
53071
 
This view can be used as an interface to import Invioce Header data directly  
53072
 
into the system.  Required fields will be checked and default values will be 
53073
 
populated';
53074
 
 
53075
 
 
53076
 
SET search_path = public, pg_catalog;
53077
 
 
53078
 
--
53079
 
--
53080
 
 
53081
 
CREATE FUNCTION insertinvoice(api.invoice) RETURNS boolean
53082
 
    LANGUAGE plpgsql
53083
 
    AS $_$
53084
 
DECLARE
53085
 
        pNew ALIAS FOR $1;
53086
 
BEGIN
53087
 
        -- NOTE: (SELECT getCustId(...)) seems redundant, but it actually produces
53088
 
        -- a HUGE performance increase because it makes the Postgres query planner
53089
 
        -- use an index scan rather than an sequential table scan on cust_id
53090
 
        INSERT INTO invchead (
53091
 
                invchead_invcnumber,
53092
 
                invchead_ordernumber,
53093
 
                invchead_invcdate,
53094
 
                invchead_shipdate,
53095
 
                invchead_orderdate,
53096
 
                invchead_printed,
53097
 
                invchead_posted,
53098
 
                invchead_salesrep_id,
53099
 
                invchead_commission,
53100
 
                invchead_taxzone_id,
53101
 
                invchead_terms_id,
53102
 
                invchead_cust_id,
53103
 
                invchead_billto_name,
53104
 
                invchead_billto_address1,
53105
 
                invchead_billto_address2,
53106
 
                invchead_billto_address3,
53107
 
                invchead_billto_city,
53108
 
                invchead_billto_state,
53109
 
                invchead_billto_zipcode,
53110
 
                invchead_billto_country,
53111
 
                invchead_billto_phone,
53112
 
                invchead_shipto_id,
53113
 
                invchead_shipto_name,
53114
 
                invchead_shipto_address1,
53115
 
                invchead_shipto_address2,
53116
 
                invchead_shipto_address3,
53117
 
                invchead_shipto_city,
53118
 
                invchead_shipto_state,
53119
 
                invchead_shipto_zipcode,
53120
 
                invchead_shipto_country,
53121
 
                invchead_shipto_phone,
53122
 
                invchead_ponumber,
53123
 
                invchead_shipvia,
53124
 
                invchead_prj_id,
53125
 
                invchead_fob,
53126
 
                invchead_misc_descrip,
53127
 
                invchead_misc_amount,
53128
 
                invchead_misc_accnt_id,
53129
 
                invchead_freight,
53130
 
                invchead_curr_id,
53131
 
                invchead_payment,
53132
 
                invchead_notes,
53133
 
                invchead_saletype_id,
53134
 
                invchead_shipzone_id
53135
 
        ) SELECT
53136
 
                (CASE -- use a case here so we don't unnecessarily fetch a new invoice number
53137
 
                        WHEN pNew.invoice_number IS NULL THEN CAST(fetchInvcNumber() AS TEXT)
53138
 
                        WHEN pNew.invoice_number = '' THEN CAST(fetchInvcNumber() AS TEXT)
53139
 
                        ELSE pNew.invoice_number
53140
 
                END),
53141
 
                pNew.order_number,
53142
 
                COALESCE(pNew.invoice_date, CURRENT_DATE),
53143
 
                pNew.ship_date,
53144
 
                pNew.order_date,
53145
 
                FALSE,
53146
 
                FALSE,
53147
 
                COALESCE(getSalesRepId(pNew.sales_rep),shipto_salesrep_id,cust_salesrep_id),
53148
 
                COALESCE(pNew.commission, 0),
53149
 
                CASE
53150
 
                        WHEN pNew.tax_zone = 'None' THEN NULL
53151
 
                        ELSE COALESCE(getTaxZoneId(pNew.tax_zone),shipto_taxzone_id,cust_taxzone_id)
53152
 
                END,
53153
 
                COALESCE(getTermsId(pNew.terms),cust_terms_id),
53154
 
                (SELECT getCustId(pNew.customer_number)),
53155
 
                COALESCE(pNew.billto_name, cohead_billtoname, cust_name),
53156
 
                COALESCE(pNew.billto_address1, cohead_billtoaddress1, addr_line1),
53157
 
                COALESCE(pNew.billto_address2, cohead_billtoaddress2, addr_line2),
53158
 
                COALESCE(pNew.billto_address3, cohead_billtoaddress3, addr_line3),
53159
 
                COALESCE(pNew.billto_city, cohead_billtocity, addr_city),
53160
 
                COALESCE(pNew.billto_state, cohead_billtostate, addr_state),
53161
 
                COALESCE(pNew.billto_postal_code, cohead_billtozipcode, addr_postalcode),
53162
 
                COALESCE(pNew.billto_country, cohead_billtocountry, addr_country),
53163
 
                COALESCE(pNew.billto_phone, ''),
53164
 
                COALESCE(shipto_id,-1),
53165
 
                pNew.shipto_name,
53166
 
                pNew.shipto_address1,
53167
 
                pNew.shipto_address2,
53168
 
                pNew.shipto_address3,
53169
 
                pNew.shipto_city,
53170
 
                pNew.shipto_state,
53171
 
                pNew.shipto_postal_code,
53172
 
                pNew.shipto_country,
53173
 
                pNew.shipto_phone,
53174
 
                COALESCE(pNew.po_number, ''),
53175
 
                COALESCE(pNew.ship_via,shipto_shipvia,cust_shipvia),
53176
 
                COALESCE(getPrjId(pNew.project_number),-1),
53177
 
                COALESCE(pNew.fob,fetchDefaultFob((
53178
 
                        SELECT CAST(usrpref_value AS INTEGER) 
53179
 
                        FROM usrpref, whsinfo
53180
 
                        WHERE ((warehous_id=CAST(usrpref_value AS INTEGER))
53181
 
                                AND (warehous_shipping)
53182
 
                                AND (warehous_active)
53183
 
                                AND (usrpref_username=getEffectiveXtUser())
53184
 
                                AND (usrpref_name='PreferredWarehouse')
53185
 
                        )
53186
 
                ))),
53187
 
                pNew.misc_charge_description,
53188
 
                COALESCE(pNew.misc_charge, 0),
53189
 
                COALESCE(getGlAccntId(pNew.misc_charge_account_number),-1),
53190
 
                COALESCE(pNew.freight, 0),
53191
 
                COALESCE(getCurrId(pNew.currency),(
53192
 
                        SELECT cust_curr_id
53193
 
                        FROM custinfo
53194
 
                        WHERE (cust_id=(SELECT getCustId(pNew.customer_number)))
53195
 
                ),basecurrid()),
53196
 
                COALESCE(pNew.payment,0),
53197
 
                COALESCE(pNew.notes,''),
53198
 
                getSaleTypeId(pNew.sale_type),
53199
 
                getShipZoneId(pNew.shipto_shipzone)
53200
 
        FROM custinfo
53201
 
                LEFT OUTER JOIN shiptoinfo ON (shipto_id=(SELECT CASE
53202
 
                        WHEN getShiptoId(pNew.customer_number,pNew.shipto_number) IS NOT NULL
53203
 
                                THEN getShiptoId(pNew.customer_number,pNew.shipto_number)
53204
 
                        ELSE (SELECT shipto_id FROM shiptoinfo WHERE shipto_cust_id=cust_id AND shipto_default)
53205
 
                END))
53206
 
               LEFT OUTER JOIN cohead ON (cohead_number=pNEW.order_number)
53207
 
               LEFT OUTER JOIN cntct ON (cntct_id=cust_cntct_id)
53208
 
               LEFT OUTER JOIN addr ON (addr_id=cntct_addr_id)
53209
 
        WHERE cust_id = (SELECT getCustId(pNew.customer_number));
53210
 
        RETURN TRUE;
53211
 
END;
53212
 
$_$;
53213
 
 
53214
 
 
53215
 
ALTER FUNCTION public.insertinvoice(api.invoice) OWNER TO admin;
53216
 
 
53217
 
--
53218
 
--
53219
 
 
53220
 
CREATE TABLE invcitem (
53221
 
    invcitem_id integer NOT NULL,
53222
 
    invcitem_invchead_id integer NOT NULL,
53223
 
    invcitem_linenumber integer,
53224
 
    invcitem_item_id integer,
53225
 
    invcitem_warehous_id integer DEFAULT (-1),
53226
 
    invcitem_custpn text,
53227
 
    invcitem_number text,
53228
 
    invcitem_descrip text,
53229
 
    invcitem_ordered numeric(20,6) NOT NULL,
53230
 
    invcitem_billed numeric(20,6) NOT NULL,
53231
 
    invcitem_custprice numeric(20,4),
53232
 
    invcitem_price numeric(20,4) NOT NULL,
53233
 
    invcitem_notes text,
53234
 
    invcitem_salescat_id integer,
53235
 
    invcitem_taxtype_id integer,
53236
 
    invcitem_qty_uom_id integer,
53237
 
    invcitem_qty_invuomratio numeric(20,10) NOT NULL,
53238
 
    invcitem_price_uom_id integer,
53239
 
    invcitem_price_invuomratio numeric(20,10) NOT NULL,
53240
 
    invcitem_coitem_id integer,
53241
 
    invcitem_updateinv boolean DEFAULT false,
53242
 
    invcitem_rev_accnt_id integer
53243
 
);
53244
 
 
53245
 
 
53246
 
ALTER TABLE public.invcitem OWNER TO admin;
53247
 
 
53248
 
--
53249
 
--
53250
 
 
53251
 
COMMENT ON TABLE invcitem IS 'Invoice Line Item information';
53252
 
 
53253
 
 
53254
 
SET search_path = api, pg_catalog;
53255
 
 
53256
 
--
53257
 
--
53258
 
 
53259
 
CREATE VIEW invoiceline AS
53260
 
    SELECT invchead.invchead_invcnumber AS invoice_number, invcitem.invcitem_linenumber AS line_number, item.item_number, invcitem.invcitem_number AS misc_item_number, whsinfo.warehous_code AS site, invcitem.invcitem_descrip AS misc_item_description, salescat.salescat_name AS sales_category, invcitem.invcitem_custpn AS customer_part_number, invcitem.invcitem_ordered AS qty_ordered, invcitem.invcitem_billed AS qty_billed, invcitem.invcitem_updateinv AS update_inventory, invcitem.invcitem_price AS net_unit_price, COALESCE(taxtype.taxtype_name, 'None'::text) AS tax_type, COALESCE(qty_uom.uom_name, 'None'::text) AS qty_uom, COALESCE(price_uom.uom_name, 'None'::text) AS price_uom, invcitem.invcitem_notes AS notes, CASE WHEN (invcitem.invcitem_rev_accnt_id IS NOT NULL) THEN public.formatglaccount(invcitem.invcitem_rev_accnt_id) ELSE NULL::text END AS alternate_rev_account FROM (((((((public.invcitem LEFT JOIN public.invchead ON ((invcitem.invcitem_invchead_id = invchead.invchead_id))) LEFT JOIN public.item ON ((item.item_id = invcitem.invcitem_item_id))) LEFT JOIN public.whsinfo ON ((invcitem.invcitem_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.salescat ON ((salescat.salescat_id = invcitem.invcitem_salescat_id))) LEFT JOIN public.taxtype ON ((taxtype.taxtype_id = invcitem.invcitem_taxtype_id))) LEFT JOIN public.uom qty_uom ON ((qty_uom.uom_id = invcitem.invcitem_qty_uom_id))) LEFT JOIN public.uom price_uom ON ((price_uom.uom_id = invcitem.invcitem_price_uom_id)));
53261
 
 
53262
 
 
53263
 
ALTER TABLE api.invoiceline OWNER TO admin;
53264
 
 
53265
 
--
53266
 
--
53267
 
 
53268
 
COMMENT ON VIEW invoiceline IS '
53269
 
This view can be used as an interface to import Invoice Line Items data directly
53270
 
into the system.  Required fields will be checked and default values will be
53271
 
populated';
53272
 
 
53273
 
 
53274
 
SET search_path = public, pg_catalog;
53275
 
 
53276
 
--
53277
 
--
53278
 
 
53279
 
CREATE FUNCTION insertinvoicelineitem(api.invoiceline) RETURNS boolean
53280
 
    LANGUAGE plpgsql
53281
 
    AS $_$
53282
 
DECLARE
53283
 
        pNew ALIAS FOR $1;
53284
 
        _r RECORD;
53285
 
BEGIN
53286
 
        INSERT INTO invcitem (
53287
 
                invcitem_invchead_id,
53288
 
                invcitem_linenumber,
53289
 
                invcitem_item_id,
53290
 
                invcitem_warehous_id,
53291
 
                invcitem_custpn,
53292
 
                invcitem_number,
53293
 
                invcitem_descrip,
53294
 
                invcitem_ordered,
53295
 
                invcitem_billed,
53296
 
                invcitem_updateinv,
53297
 
                invcitem_custprice,
53298
 
                invcitem_price,
53299
 
                invcitem_notes,
53300
 
                invcitem_salescat_id,
53301
 
                invcitem_taxtype_id,
53302
 
                invcitem_qty_uom_id,
53303
 
                invcitem_qty_invuomratio,
53304
 
                invcitem_price_uom_id,
53305
 
                invcitem_price_invuomratio,
53306
 
                invcitem_rev_accnt_id
53307
 
        ) SELECT
53308
 
                invchead_id,
53309
 
                COALESCE(pNew.line_number,(
53310
 
                        SELECT (COALESCE(MAX(invcitem_linenumber), 0) + 1)
53311
 
                        FROM invcitem WHERE (invcitem_invchead_id=invchead_id)
53312
 
                )),
53313
 
                COALESCE(item_id, -1),
53314
 
                COALESCE(getwarehousid(pNew.site,'ALL'),-1),
53315
 
                pNew.customer_part_number,
53316
 
                (CASE WHEN item_id IS NULL THEN pNew.misc_item_number ELSE NULL END),
53317
 
                (CASE WHEN item_id IS NULL THEN pNew.misc_item_description ELSE NULL END),
53318
 
                pNew.qty_ordered,
53319
 
                COALESCE(pNew.qty_billed, 0),
53320
 
                COALESCE(pNew.update_inventory,FALSE),
53321
 
                0, -- invcitem_custprice
53322
 
                COALESCE(pNew.net_unit_price,itemPrice(item_id,invchead_cust_id,
53323
 
                        invchead_shipto_id,pNew.qty_ordered,invchead_curr_id,invchead_orderdate)),
53324
 
                COALESCE(pNew.notes,''),
53325
 
                CASE
53326
 
                        WHEN item_id IS NULL THEN
53327
 
                                (SELECT salescat_id FROM salescat WHERE salescat_name = pNew.sales_category)
53328
 
                        ELSE NULL
53329
 
                END,
53330
 
                taxtype_id,
53331
 
                CASE
53332
 
                        WHEN item_id IS NOT NULL THEN
53333
 
                                COALESCE((SELECT uom_id FROM uom WHERE (uom_name=pNew.qty_uom)), item_price_uom_id)
53334
 
                        ELSE NULL
53335
 
                END,
53336
 
                CASE
53337
 
                        WHEN item_id IS NOT NULL THEN
53338
 
                                itemuomtouomratio(item_id,
53339
 
                                        COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.qty_uom),item_price_uom_id),
53340
 
                                        item_price_uom_id
53341
 
                                )
53342
 
                        ELSE 1
53343
 
                END,
53344
 
                CASE
53345
 
                        WHEN item_id IS NOT NULL THEN
53346
 
                                COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.price_uom),item_price_uom_id)
53347
 
                        ELSE NULL
53348
 
                END,
53349
 
                CASE
53350
 
                        WHEN item_id IS NOT NULL THEN
53351
 
                                itemuomtouomratio(item_id,
53352
 
                                        COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.price_uom),item_price_uom_id),
53353
 
                                        item_price_uom_id
53354
 
                                )
53355
 
                        ELSE 1
53356
 
                END,
53357
 
                getGlAccntId(pNew.alternate_rev_account)
53358
 
        FROM invchead
53359
 
                LEFT OUTER JOIN item ON (item_id=getItemId(pNew.item_number))
53360
 
                LEFT OUTER JOIN taxtype ON (taxtype_id=CASE
53361
 
                        WHEN pNew.tax_type IS NULL THEN getItemTaxType(item_id,invchead_taxzone_id)
53362
 
                        WHEN pNew.tax_type = 'None' THEN NULL
53363
 
                        ELSE (SELECT taxtype_id FROM taxtype WHERE taxtype_name=pNew.tax_type)
53364
 
                END)
53365
 
        WHERE (invchead_invcnumber=pNew.invoice_number) AND (invchead_posted=FALSE);
53366
 
        RETURN TRUE;
53367
 
END;
53368
 
$_$;
53369
 
 
53370
 
 
53371
 
ALTER FUNCTION public.insertinvoicelineitem(api.invoiceline) OWNER TO admin;
53372
 
 
53373
 
--
53374
 
--
53375
 
 
53376
 
CREATE FUNCTION insertitemcost(integer, integer, integer, numeric, boolean) RETURNS integer
53377
 
    LANGUAGE plpgsql
53378
 
    AS $_$
53379
 
DECLARE
53380
 
pItemId ALIAS FOR $1;
53381
 
pCostElemId ALIAS FOR $2;
53382
 
pCurrId ALIAS FOR $3;
53383
 
pCost ALIAS FOR $4;
53384
 
pPostToStandard ALIAS FOR $5;
53385
 
_itemcost_id INTEGER;
53386
 
_update_return INTEGER;
53387
 
_postcost_return BOOLEAN;
53388
 
 
53389
 
--This function is used with the api.itemcost View for updating and inserting
53390
 
--into the itemcosts table
53391
 
 
53392
 
BEGIN
53393
 
  IF (pCost IS NULL OR pCost < 0) THEN
53394
 
    RAISE EXCEPTION 'itemcost Actual Cost Invalid ', pCost;
53395
 
  END IF;
53396
 
 
53397
 
  SELECT itemcost_id INTO _itemcost_id
53398
 
  FROM itemcost
53399
 
  WHERE ( (itemcost_item_id = pItemId)
53400
 
    AND   (itemcost_costelem_id = pCostElemId)
53401
 
    AND   (NOT itemcost_lowlevel) );
53402
 
  IF (FOUND) THEN
53403
 
    RAISE EXCEPTION 'itemcost already exists for this Item and Cost Element';
53404
 
  END IF;
53405
 
 
53406
 
  IF (SELECT (COUNT(*) > 0)
53407
 
      FROM item, costelem
53408
 
      WHERE (item_id=pItemId)
53409
 
        AND (costelem_id=pCostElemId)
53410
 
        AND (item_type IN ('M', 'F', 'B', 'C', 'T'))
53411
 
        AND (costelem_type IN ('Material'))) THEN
53412
 
    RAISE EXCEPTION 'itemcost of this type is invalid for Manufactured Item';
53413
 
  END IF;
53414
 
  
53415
 
  IF (SELECT (COUNT(*) > 0)
53416
 
      FROM item, costelem
53417
 
      WHERE (item_id=pItemId)
53418
 
        AND (costelem_id=pCostElemId)
53419
 
        AND (item_type IN ('O', 'P'))
53420
 
        AND (costelem_type IN ('Direct Labor', 'Overhead', 'Machine Overhead'))) THEN
53421
 
    RAISE EXCEPTION 'itemcost of this type is invalid for Purchased Item';
53422
 
  END IF;
53423
 
  
53424
 
  IF (pCost > 0) THEN
53425
 
    SELECT NEXTVAL('itemcost_itemcost_id_seq') INTO _itemcost_id;
53426
 
    INSERT INTO itemcost
53427
 
      ( itemcost_id, itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel,
53428
 
        itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated, itemcost_curr_id )
53429
 
    VALUES
53430
 
      ( _itemcost_id, pItemId, pCostElemId, FALSE,
53431
 
        0, startOfTime(), pCost, CURRENT_DATE, pCurrId );
53432
 
 
53433
 
    --Only Post Cost to standard if the parameter is set to true
53434
 
    IF (pPostToStandard) THEN
53435
 
      IF (NOT checkPrivilege('PostStandardCosts')) THEN
53436
 
        RAISE EXCEPTION 'You do not have privileges to poststandard itemcosts. Set api.itemcost post_to_standard to false';
53437
 
      END IF;
53438
 
      SELECT postcost(_itemcost_id) INTO _postcost_return;       
53439
 
      IF (NOT _postcost_return) THEN
53440
 
        RETURN -2;
53441
 
      END IF;
53442
 
    END IF;
53443
 
  ELSE 
53444
 
    RETURN -1;
53445
 
  END IF;
53446
 
 
53447
 
  RETURN _itemcost_id;
53448
 
  
53449
 
END;
53450
 
$_$;
53451
 
 
53452
 
 
53453
 
ALTER FUNCTION public.insertitemcost(integer, integer, integer, numeric, boolean) OWNER TO admin;
53454
 
 
53455
 
--
53456
 
--
53457
 
 
53458
 
CREATE FUNCTION insertsalesline(api.salesline) RETURNS boolean
53459
 
    LANGUAGE plpgsql
53460
 
    AS $_$
53461
 
DECLARE
53462
 
  pNEW ALIAS FOR $1;
53463
 
  _r RECORD;
53464
 
 
53465
 
BEGIN
53466
 
 
53467
 
  IF (NOT EXISTS (SELECT cohead_id FROM cohead WHERE cohead_number=pNEW.order_number)) THEN
53468
 
    RAISE EXCEPTION 'Function insertSalesLine failed because Sales Order % not found', pNEW.order_number;
53469
 
  END IF;
53470
 
 
53471
 
  IF (NOT EXISTS (SELECT item_id FROM item WHERE item_number=pNEW.item_number)) THEN
53472
 
    RAISE EXCEPTION 'Function insertSalesLine failed because Item Number % not found', pNEW.item_number;
53473
 
  END IF;
53474
 
 
53475
 
  SELECT * INTO _r
53476
 
  FROM cohead, itemsite, item, whsinfo
53477
 
  WHERE ((cohead_number=pNEW.order_number)
53478
 
  AND (itemsite_warehous_id=warehous_id
53479
 
  AND (itemsite_item_id=item_id)
53480
 
  AND (itemsite_active)
53481
 
  AND (item_number=pNEW.item_number)
53482
 
  AND (warehous_active)
53483
 
  AND (warehous_id=COALESCE(getWarehousId(pNEW.sold_from_site,'ALL'),cohead_warehous_id,fetchprefwarehousid()))));
53484
 
 
53485
 
  IF (NOT FOUND) THEN
53486
 
    RAISE EXCEPTION 'Function insertSalesLine failed with unknown failure to retrieve Sales Order';
53487
 
  END IF;
53488
 
 
53489
 
  INSERT INTO coitem (
53490
 
    coitem_cohead_id,
53491
 
    coitem_linenumber,
53492
 
    coitem_itemsite_id,
53493
 
    coitem_status,
53494
 
    coitem_scheddate,
53495
 
    coitem_promdate,
53496
 
    coitem_qtyord,
53497
 
    coitem_qty_uom_id,
53498
 
    coitem_qty_invuomratio,
53499
 
    coitem_qtyshipped,
53500
 
    coitem_unitcost,
53501
 
    coitem_price,
53502
 
    coitem_price_uom_id,
53503
 
    coitem_price_invuomratio,
53504
 
    coitem_custprice,
53505
 
    coitem_order_id,
53506
 
    coitem_memo,
53507
 
    coitem_imported,
53508
 
    coitem_qtyreturned,
53509
 
    coitem_custpn,
53510
 
    coitem_order_type,
53511
 
    coitem_substitute_item_id,
53512
 
    coitem_prcost,
53513
 
    coitem_taxtype_id,
53514
 
    coitem_warranty,
53515
 
    coitem_cos_accnt_id,
53516
 
    coitem_rev_accnt_id)
53517
 
  VALUES (
53518
 
    _r.cohead_id,
53519
 
    pNEW.line_number::INTEGER,
53520
 
    _r.itemsite_id,
53521
 
    pNEW.status,
53522
 
    pNEW.scheduled_date,
53523
 
    pNEW.promise_date,
53524
 
    pNEW.qty_ordered,
53525
 
    COALESCE(getUomId(pNEW.qty_uom),_r.item_inv_uom_id),
53526
 
    itemuomtouomratio(_r.item_id,COALESCE(getUomId(pNEW.qty_uom),_r.item_inv_uom_id),_r.item_inv_uom_id),
53527
 
    0,
53528
 
    stdCost(_r.item_id),
53529
 
    COALESCE(pNEW.net_unit_price,itemPrice(_r.item_id,_r.cohead_cust_id,
53530
 
             _r.cohead_shipto_id,pNEW.qty_ordered,_r.cohead_curr_id,_r.cohead_orderdate)),
53531
 
    COALESCE(getUomId(pNEW.price_uom),_r.item_price_uom_id),
53532
 
    itemuomtouomratio(_r.item_id,COALESCE(getUomId(pNEW.price_uom),_r.item_price_uom_id),_r.item_price_uom_id),
53533
 
    itemPrice(_r.item_id,_r.cohead_cust_id,_r.cohead_shipto_id,pNEW.qty_ordered,_r.cohead_curr_id,_r.cohead_orderdate),
53534
 
    -1,
53535
 
    pNEW.notes,
53536
 
    true,
53537
 
    0,
53538
 
    pNEW.customer_pn,
53539
 
    CASE
53540
 
      WHEN ((pNEW.create_order  AND (_r.item_type = 'M')) OR 
53541
 
           ((pNEW.create_order IS NULL) AND _r.itemsite_createwo)) THEN
53542
 
        'W'
53543
 
      WHEN ((pNEW.create_order AND (_r.item_type = 'P')) OR 
53544
 
           ((pNEW.create_order IS NULL) AND _r.itemsite_createsopr)) THEN
53545
 
        'R'
53546
 
      WHEN ((pNEW.create_order AND (_r.item_type = 'P') AND (_r.itemsite_createsopo)) OR 
53547
 
           ((pNEW.create_order IS NULL) AND _r.itemsite_createsopo)) THEN
53548
 
        'P'
53549
 
    END,
53550
 
    getitemid(pNEW.substitute_for),
53551
 
    pNEW.overwrite_po_price,
53552
 
    COALESCE(getTaxTypeId(pNEW.tax_type), getItemTaxType(_r.itemsite_item_id, _r.cohead_taxzone_id)),
53553
 
    pNEW.warranty,
53554
 
    getGlAccntId(pNEW.alternate_cos_account),
53555
 
    getGlAccntId(pNEW.alternate_rev_account)
53556
 
    );
53557
 
 
53558
 
  RETURN TRUE;
53559
 
END;
53560
 
$_$;
53561
 
 
53562
 
 
53563
 
ALTER FUNCTION public.insertsalesline(api.salesline) OWNER TO admin;
53564
 
 
53565
 
--
53566
 
--
53567
 
 
53568
 
CREATE FUNCTION intervaltominutes(interval) RETURNS numeric
53569
 
    LANGUAGE sql
53570
 
    AS $_$
53571
 
  SELECT (EXTRACT(DAY FROM $1) * 24 * 60 +
53572
 
          EXTRACT(HOUR FROM $1) * 60 +
53573
 
          EXTRACT(MINUTE FROM $1) +
53574
 
          ROUND((EXTRACT(SECOND FROM $1) / 60)::NUMERIC, 4))::NUMERIC AS result
53575
 
$_$;
53576
 
 
53577
 
 
53578
 
ALTER FUNCTION public.intervaltominutes(interval) OWNER TO admin;
53579
 
 
53580
 
--
53581
 
--
53582
 
 
53583
 
CREATE FUNCTION invadjustment(integer, numeric, text, text) RETURNS integer
53584
 
    LANGUAGE plpgsql
53585
 
    AS $_$
53586
 
BEGIN
53587
 
  RETURN invAdjustment($1, $2, $3, $4, CURRENT_TIMESTAMP, NULL);
53588
 
END;
53589
 
$_$;
53590
 
 
53591
 
 
53592
 
ALTER FUNCTION public.invadjustment(integer, numeric, text, text) OWNER TO admin;
53593
 
 
53594
 
--
53595
 
--
53596
 
 
53597
 
CREATE FUNCTION invadjustment(integer, numeric, text, text, timestamp with time zone) RETURNS integer
53598
 
    LANGUAGE plpgsql
53599
 
    AS $_$
53600
 
BEGIN
53601
 
  RETURN invAdjustment($1, $2, $3, $4, $5, NULL);
53602
 
END;
53603
 
$_$;
53604
 
 
53605
 
 
53606
 
ALTER FUNCTION public.invadjustment(integer, numeric, text, text, timestamp with time zone) OWNER TO admin;
53607
 
 
53608
 
--
53609
 
--
53610
 
 
53611
 
CREATE FUNCTION invadjustment(integer, numeric, text, text, timestamp with time zone, numeric) RETURNS integer
53612
 
    LANGUAGE plpgsql
53613
 
    AS $_$
53614
 
DECLARE
53615
 
  pItemsiteid     ALIAS FOR $1;
53616
 
  pQty            ALIAS FOR $2;
53617
 
  pDocumentNumber ALIAS FOR $3;
53618
 
  pComments       ALIAS FOR $4;
53619
 
  pGlDistTS       ALIAS FOR $5;
53620
 
  pCostValue      ALIAS FOR $6;
53621
 
  _invhistid      INTEGER;
53622
 
  _itemlocSeries  INTEGER;
53623
 
 
53624
 
BEGIN
53625
 
 
53626
 
  IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J')
53627
 
         FROM itemsite, item
53628
 
         WHERE ( (itemsite_item_id=item_id)
53629
 
          AND (itemsite_id=pItemsiteid) ) ) ) THEN
53630
 
    RETURN 0;
53631
 
  END IF;
53632
 
 
53633
 
  SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
53634
 
  SELECT postInvTrans( itemsite_id, 'AD', pQty,
53635
 
                       'I/M', 'AD', pDocumentNumber, '',
53636
 
                       ('Miscellaneous Adjustment for item ' || item_number || E'\n' ||  pComments),
53637
 
                       costcat_asset_accnt_id, costcat_adjustment_accnt_id,
53638
 
                       _itemlocSeries, pGlDistTS, pCostValue) INTO _invhistid
53639
 
  FROM itemsite, item, costcat
53640
 
  WHERE ( (itemsite_item_id=item_id)
53641
 
   AND (itemsite_costcat_id=costcat_id)
53642
 
   AND (itemsite_id=pItemsiteid) );
53643
 
 
53644
 
  RETURN _itemlocSeries;
53645
 
 
53646
 
END;
53647
 
$_$;
53648
 
 
53649
 
 
53650
 
ALTER FUNCTION public.invadjustment(integer, numeric, text, text, timestamp with time zone, numeric) OWNER TO admin;
53651
 
 
53652
 
--
53653
 
--
53654
 
 
53655
 
CREATE FUNCTION invexpense(pitemsiteid integer, pqty numeric, pexpcatid integer, pdocumentnumber text, pcomments text, pgldistts timestamp with time zone DEFAULT now(), pprjid integer DEFAULT NULL::integer) RETURNS integer
53656
 
    LANGUAGE plpgsql
53657
 
    AS $$
53658
 
DECLARE
53659
 
  _invhistid INTEGER;
53660
 
  _itemlocSeries INTEGER;
53661
 
 
53662
 
BEGIN
53663
 
 
53664
 
  --  Make sure the passed itemsite points to a real item
53665
 
  IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J')
53666
 
         FROM itemsite, item
53667
 
         WHERE ( (itemsite_item_id=item_id)
53668
 
          AND (itemsite_id=pItemsiteid) ) ) ) THEN
53669
 
    RETURN 0;
53670
 
  END IF;
53671
 
 
53672
 
  SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
53673
 
  SELECT postInvTrans( itemsite_id, 'EX', pQty,
53674
 
                       'I/M', 'EX', pDocumentNumber, '',
53675
 
                       CASE WHEN (pQty < 0) THEN ('Reverse Material Expense for item ' || item_number || E'\n' ||  pComments)
53676
 
                            ELSE  ('Material Expense for item ' || item_number || E'\n' ||  pComments)
53677
 
                       END,
53678
 
                       getPrjAccntId(pPrjid, expcat_exp_accnt_id), costcat_asset_accnt_id,
53679
 
                       _itemlocSeries, pGlDistTS) INTO _invhistid
53680
 
  FROM itemsite, item, costcat, expcat
53681
 
  WHERE ( (itemsite_item_id=item_id)
53682
 
   AND (itemsite_costcat_id=costcat_id)
53683
 
   AND (itemsite_id=pItemsiteid)
53684
 
   AND (expcat_id=pExpcatid) );
53685
 
 
53686
 
  INSERT INTO invhistexpcat (invhistexpcat_invhist_id, invhistexpcat_expcat_id)
53687
 
                     VALUES (_invhistid,               pExpcatid);
53688
 
 
53689
 
  RETURN _itemlocSeries;
53690
 
 
53691
 
END;
53692
 
$$;
53693
 
 
53694
 
 
53695
 
ALTER FUNCTION public.invexpense(pitemsiteid integer, pqty numeric, pexpcatid integer, pdocumentnumber text, pcomments text, pgldistts timestamp with time zone, pprjid integer) OWNER TO admin;
53696
 
 
53697
 
--
53698
 
--
53699
 
 
53700
 
CREATE FUNCTION invhistsense(integer) RETURNS integer
53701
 
    LANGUAGE plpgsql
53702
 
    AS $_$
53703
 
DECLARE
53704
 
  pInvhistId ALIAS FOR $1;
53705
 
  _count INTEGER;
53706
 
  _row RECORD;
53707
 
  _sense INTEGER;
53708
 
BEGIN
53709
 
 
53710
 
  SELECT invhist_transtype, invhist_ordnumber, itemsite_warehous_id
53711
 
  INTO _row 
53712
 
  FROM invhist 
53713
 
    JOIN itemsite ON (itemsite_id=invhist_itemsite_id)
53714
 
  WHERE (invhist_id=pInvhistId);
53715
 
 
53716
 
  GET DIAGNOSTICS _count = ROW_COUNT;
53717
 
  IF (_count = 0) THEN
53718
 
    RAISE EXCEPTION 'Record not found for invhist_id=%',pInvhistId;
53719
 
  END IF;
53720
 
  
53721
 
  -- increase inventory: AD RM RT RP RR RS RX RB TR
53722
 
  -- decrease inventory: IM IB IT SH SI EX RI
53723
 
  -- TS and TR are special: shipShipment and recallShipment should not change
53724
 
  -- QOH at the Transfer Order src whs (as this was done by issueToShipping)
53725
 
  -- but postReceipt should change QOH at the transit whs
53726
 
  IF (_row.invhist_transtype='TS') THEN
53727
 
       _sense := CASE WHEN (SELECT tohead_trns_warehous_id=_row.itemsite_warehous_id
53728
 
                                  FROM tohead
53729
 
                                  WHERE (tohead_number=_row.invhist_ordnumber)) THEN -1
53730
 
                ELSE 0
53731
 
                END;
53732
 
  ELSIF (_row.invhist_transtype='TR') THEN
53733
 
      _sense := CASE WHEN (SELECT tohead_src_warehous_id=_row.itemsite_warehous_id
53734
 
                                  FROM tohead
53735
 
                                  WHERE (tohead_number=_row.invhist_ordnumber)) THEN 0
53736
 
                ELSE 1
53737
 
                END;
53738
 
  ELSIF (_row.invhist_transtype IN ('IM', 'IB', 'IT', 'SH', 'SI', 'EX', 'RI')) THEN
53739
 
      _sense := -1;
53740
 
    ELSE
53741
 
      _sense := 1;
53742
 
    END IF;
53743
 
 
53744
 
  RETURN _sense;
53745
 
END;
53746
 
$_$;
53747
 
 
53748
 
 
53749
 
ALTER FUNCTION public.invhistsense(integer) OWNER TO admin;
53750
 
 
53751
 
--
53752
 
--
53753
 
 
53754
 
CREATE FUNCTION invhisttrig() RETURNS trigger
53755
 
    LANGUAGE plpgsql
53756
 
    AS $$
53757
 
BEGIN
53758
 
 
53759
 
 
53760
 
  IF ( ( SELECT itemsite_freeze
53761
 
         FROM itemsite
53762
 
         WHERE (itemsite_id=NEW.invhist_itemsite_id) ) ) THEN
53763
 
    NEW.invhist_posted = FALSE;
53764
 
  END IF;
53765
 
 
53766
 
  -- never change the created timestamp, which defaults to CURRENT_TIMESTAMP
53767
 
  IF (TG_OP != 'INSERT') THEN
53768
 
    NEW.invhist_created = OLD.invhist_created;
53769
 
  ELSE
53770
 
    -- Always need a series id for distribution posting
53771
 
    IF (NEW.invhist_series IS NULL) THEN
53772
 
      RAISE EXCEPTION 'Column invhist_series may not be null.';
53773
 
    END IF;
53774
 
  END IF;
53775
 
 
53776
 
  RETURN NEW;
53777
 
 
53778
 
END;
53779
 
$$;
53780
 
 
53781
 
 
53782
 
ALTER FUNCTION public.invhisttrig() OWNER TO admin;
53783
 
 
53784
 
--
53785
 
--
53786
 
 
53787
 
CREATE FUNCTION invoicetotal(integer) RETURNS numeric
53788
 
    LANGUAGE plpgsql
53789
 
    AS $_$
53790
 
DECLARE
53791
 
  pInvoiceId ALIAS FOR $1;
53792
 
  _linesum   NUMERIC;
53793
 
  _linetax   NUMERIC;
53794
 
  _result    NUMERIC;
53795
 
  _allocated NUMERIC;
53796
 
  _posted    BOOLEAN;
53797
 
 
53798
 
BEGIN
53799
 
 
53800
 
  SELECT SUM(ROUND(COALESCE((invcitem_billed * invcitem_qty_invuomratio) *
53801
 
                             (invcitem_price / COALESCE(invcitem_price_invuomratio,1)), 0),2))
53802
 
                          INTO _linesum
53803
 
  FROM invcitem
53804
 
  WHERE (invcitem_invchead_id=pInvoiceId);
53805
 
 
53806
 
  -- TODO: why sum on the result of select round(sum(), 2)?
53807
 
  SELECT SUM(tax) INTO _linetax
53808
 
    FROM (SELECT ROUND(SUM(COALESCE(taxdetail_tax, 0)),2) AS tax 
53809
 
            FROM tax 
53810
 
            JOIN calculateTaxDetailSummary('I', pInvoiceId, 'T') ON (taxdetail_tax_id=tax_id)
53811
 
          GROUP BY tax_id) AS data;
53812
 
 
53813
 
  SELECT noNeg(invchead_freight + invchead_misc_amount + COALESCE(_linetax, 0) + COALESCE(_linesum, 0)),
53814
 
         invchead_posted INTO _result, _posted
53815
 
  FROM invchead
53816
 
  WHERE (invchead_id=pInvoiceId);
53817
 
 
53818
 
  IF NOT FOUND THEN
53819
 
    RETURN 0;
53820
 
  END IF;
53821
 
 
53822
 
  IF (_posted) THEN
53823
 
    SELECT COALESCE(SUM(currToCurr(arapply_curr_id, aropen_curr_id,
53824
 
                                   arapply_applied, aropen_docdate)),0) INTO _allocated
53825
 
     FROM arapply, aropen, invchead
53826
 
    WHERE ( (invchead_posted)
53827
 
      AND   (invchead_id=pInvoiceId)
53828
 
      AND   (aropen_docnumber=invchead_invcnumber)
53829
 
      AND   (aropen_doctype='I')
53830
 
      AND   (arapply_target_aropen_id=aropen_id)
53831
 
      AND   (arapply_reftype='S')
53832
 
      AND   (invchead_posted) ) ;
53833
 
  ELSE
53834
 
    SELECT COALESCE(SUM(CASE WHEN((aropen_amount - aropen_paid) >=
53835
 
                       currToCurr(aropenalloc_curr_id, aropen_curr_id,
53836
 
                          aropenalloc_amount, aropen_docdate))
53837
 
           THEN currToCurr(aropenalloc_curr_id, invchead_curr_id,
53838
 
                   aropenalloc_amount, aropen_docdate)
53839
 
           ELSE currToCurr(aropen_curr_id, invchead_curr_id,
53840
 
                   aropen_amount - aropen_paid, aropen_docdate)
53841
 
           END),0) INTO _allocated
53842
 
     FROM invchead LEFT OUTER JOIN cohead ON (cohead_number=invchead_ordernumber)
53843
 
                   JOIN aropenalloc ON ((aropenalloc_doctype='I' AND aropenalloc_doc_id=invchead_id) OR
53844
 
                                        (aropenalloc_doctype='S' AND aropenalloc_doc_id=cohead_id))
53845
 
                   JOIN aropen ON (aropen_id=aropenalloc_aropen_id AND (aropen_amount - aropen_paid) > 0.0)
53846
 
    WHERE ( (NOT invchead_posted)
53847
 
      AND   (invchead_id=pInvoiceId) );
53848
 
  END IF;
53849
 
  
53850
 
  RETURN _result - COALESCE(_allocated, 0);
53851
 
 
53852
 
END;
53853
 
$_$;
53854
 
 
53855
 
 
53856
 
ALTER FUNCTION public.invoicetotal(integer) OWNER TO admin;
53857
 
 
53858
 
--
53859
 
--
53860
 
 
53861
 
CREATE FUNCTION invreceipt(integer, numeric, text, text, text) RETURNS integer
53862
 
    LANGUAGE plpgsql
53863
 
    AS $_$
53864
 
BEGIN
53865
 
  RETURN invReceipt($1, $2, $3, $4, $5, CURRENT_TIMESTAMP, NULL);
53866
 
END;
53867
 
$_$;
53868
 
 
53869
 
 
53870
 
ALTER FUNCTION public.invreceipt(integer, numeric, text, text, text) OWNER TO admin;
53871
 
 
53872
 
--
53873
 
--
53874
 
 
53875
 
CREATE FUNCTION invreceipt(integer, numeric, text, text, text, timestamp with time zone) RETURNS integer
53876
 
    LANGUAGE plpgsql
53877
 
    AS $_$
53878
 
BEGIN
53879
 
  RETURN invReceipt($1, $2, $3, $4, $5, $6, NULL);
53880
 
END;
53881
 
$_$;
53882
 
 
53883
 
 
53884
 
ALTER FUNCTION public.invreceipt(integer, numeric, text, text, text, timestamp with time zone) OWNER TO admin;
53885
 
 
53886
 
--
53887
 
--
53888
 
 
53889
 
CREATE FUNCTION invreceipt(integer, numeric, text, text, text, timestamp with time zone, numeric) RETURNS integer
53890
 
    LANGUAGE plpgsql
53891
 
    AS $_$
53892
 
DECLARE
53893
 
  pItemsiteid ALIAS FOR $1;
53894
 
  pQty ALIAS FOR $2;
53895
 
  pOrdernumber ALIAS FOR $3;
53896
 
  pDocumentNumber ALIAS FOR $4;
53897
 
  pComments ALIAS FOR $5;
53898
 
  pGlDistTS     ALIAS FOR $6;
53899
 
  pCostValue ALIAS FOR $7;
53900
 
  _invhistid INTEGER;
53901
 
  _itemlocSeries INTEGER;
53902
 
 
53903
 
BEGIN
53904
 
 
53905
 
  IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J')
53906
 
         FROM itemsite, item
53907
 
         WHERE ( (itemsite_item_id=item_id)
53908
 
          AND (itemsite_id=pItemsiteid) ) ) ) THEN
53909
 
    RETURN 0;
53910
 
  END IF;
53911
 
 
53912
 
  SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
53913
 
  SELECT postInvTrans( itemsite_id, 'RX', pQty,
53914
 
                       'I/M', 'RX', pDocumentNumber, '',
53915
 
                       ('Miscellaneous Receipt for item ' || item_number || E'\n' ||  pComments),
53916
 
                       costcat_asset_accnt_id, costcat_liability_accnt_id,
53917
 
                       _itemlocSeries, pGlDistTS, pCostValue) INTO _invhistid
53918
 
  FROM itemsite, item, costcat
53919
 
  WHERE ( (itemsite_item_id=item_id)
53920
 
   AND (itemsite_costcat_id=costcat_id)
53921
 
   AND (itemsite_id=pItemsiteid) );
53922
 
 
53923
 
  RETURN _itemlocSeries;
53924
 
 
53925
 
END;
53926
 
$_$;
53927
 
 
53928
 
 
53929
 
ALTER FUNCTION public.invreceipt(integer, numeric, text, text, text, timestamp with time zone, numeric) OWNER TO admin;
53930
 
 
53931
 
--
53932
 
--
53933
 
 
53934
 
CREATE FUNCTION invscrap(integer, numeric, text, text) RETURNS integer
53935
 
    LANGUAGE plpgsql
53936
 
    AS $_$
53937
 
BEGIN
53938
 
  RETURN invScrap($1, $2, $3, $4, CURRENT_TIMESTAMP);
53939
 
END;
53940
 
$_$;
53941
 
 
53942
 
 
53943
 
ALTER FUNCTION public.invscrap(integer, numeric, text, text) OWNER TO admin;
53944
 
 
53945
 
--
53946
 
--
53947
 
 
53948
 
CREATE FUNCTION invscrap(integer, numeric, text, text, timestamp with time zone) RETURNS integer
53949
 
    LANGUAGE plpgsql
53950
 
    AS $_$
53951
 
BEGIN
53952
 
  RETURN invScrap($1, $2, $3, $4, $5, NULL);
53953
 
END;
53954
 
$_$;
53955
 
 
53956
 
 
53957
 
ALTER FUNCTION public.invscrap(integer, numeric, text, text, timestamp with time zone) OWNER TO admin;
53958
 
 
53959
 
--
53960
 
--
53961
 
 
53962
 
CREATE FUNCTION invscrap(integer, numeric, text, text, timestamp with time zone, integer) RETURNS integer
53963
 
    LANGUAGE plpgsql
53964
 
    AS $_$
53965
 
BEGIN
53966
 
  RETURN invScrap($1, $2, $3, $4, $5, $6, NULL);
53967
 
END;
53968
 
$_$;
53969
 
 
53970
 
 
53971
 
ALTER FUNCTION public.invscrap(integer, numeric, text, text, timestamp with time zone, integer) OWNER TO admin;
53972
 
 
53973
 
--
53974
 
--
53975
 
 
53976
 
CREATE FUNCTION invscrap(integer, numeric, text, text, timestamp with time zone, integer, integer) RETURNS integer
53977
 
    LANGUAGE plpgsql
53978
 
    AS $_$
53979
 
DECLARE
53980
 
  pItemsiteid ALIAS FOR $1;
53981
 
  pQty ALIAS FOR $2;
53982
 
  pDocumentNumber ALIAS FOR $3;
53983
 
  pComments ALIAS FOR $4;
53984
 
  pGlDistTS ALIAS FOR $5;
53985
 
  pInvHistId ALIAS FOR $6;
53986
 
  pPrjid ALIAS FOR $7;
53987
 
  _invhistid INTEGER;
53988
 
  _itemlocSeries INTEGER;
53989
 
 
53990
 
BEGIN
53991
 
 
53992
 
  IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J')
53993
 
         FROM itemsite, item
53994
 
         WHERE ( (itemsite_item_id=item_id)
53995
 
          AND (itemsite_id=pItemsiteid) ) ) ) THEN
53996
 
    RETURN 0;
53997
 
  END IF;
53998
 
 
53999
 
  IF (pInvHistId IS NOT NULL) THEN
54000
 
    SELECT invhist_series INTO _itemlocSeries
54001
 
    FROM invhist
54002
 
    WHERE invhist_id=pInvHistId;
54003
 
  ELSE
54004
 
    SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
54005
 
  END IF;
54006
 
  
54007
 
  SELECT postInvTrans( itemsite_id, 'SI', pQty,
54008
 
                       'I/M', 'SI', pDocumentNumber, '',
54009
 
                       CASE WHEN (pQty < 0) THEN ('Reverse Material Scrap for item ' || item_number || E'\n' ||  pComments)
54010
 
                            ELSE ('Material Scrap for item ' || item_number || E'\n' ||  pComments)
54011
 
                       END,
54012
 
                       getPrjAccntId(pPrjid, costcat_scrap_accnt_id), costcat_asset_accnt_id,
54013
 
                       _itemlocSeries, pGlDistTS, NULL, pInvHistId) INTO _invhistid
54014
 
  FROM itemsite, item, costcat
54015
 
  WHERE ( (itemsite_item_id=item_id)
54016
 
   AND (itemsite_costcat_id=costcat_id)
54017
 
   AND (itemsite_id=pItemsiteid) );
54018
 
 
54019
 
  RETURN _itemlocSeries;
54020
 
 
54021
 
END;
54022
 
$_$;
54023
 
 
54024
 
 
54025
 
ALTER FUNCTION public.invscrap(integer, numeric, text, text, timestamp with time zone, integer, integer) OWNER TO admin;
54026
 
 
54027
 
--
54028
 
--
54029
 
 
54030
 
CREATE FUNCTION isdba(text DEFAULT NULL::text) RETURNS boolean
54031
 
    LANGUAGE sql
54032
 
    AS $_$
54033
 
  SELECT (datdba=pg_roles.oid OR rolsuper) AS issuper
54034
 
    FROM pg_database, pg_roles
54035
 
  WHERE ((datname=current_database())
54036
 
     AND (rolname=COALESCE($1, getEffectiveXtUser())));
54037
 
$_$;
54038
 
 
54039
 
 
54040
 
ALTER FUNCTION public.isdba(text) OWNER TO admin;
54041
 
 
54042
 
--
54043
 
--
54044
 
 
54045
 
CREATE FUNCTION ismulticurr() RETURNS boolean
54046
 
    LANGUAGE plpgsql IMMUTABLE
54047
 
    AS $$
54048
 
BEGIN
54049
 
  RETURN (SELECT (count(*) > 1)
54050
 
          FROM curr_symbol);
54051
 
END;
54052
 
$$;
54053
 
 
54054
 
 
54055
 
ALTER FUNCTION public.ismulticurr() OWNER TO admin;
54056
 
 
54057
 
--
54058
 
--
54059
 
 
54060
 
CREATE FUNCTION isnumeric(text) RETURNS boolean
54061
 
    LANGUAGE plpgsql IMMUTABLE
54062
 
    AS $_$
54063
 
DECLARE
54064
 
  pText ALIAS FOR $1;
54065
 
  _cursor INTEGER;
54066
 
 
54067
 
BEGIN
54068
 
 
54069
 
  IF ( (LENGTH(pText) = 0) OR (pText IS NULL) ) THEN
54070
 
    RETURN FALSE;
54071
 
  END IF;
54072
 
 
54073
 
  FOR _cursor IN 1..LENGTH(pText) LOOP
54074
 
    IF (SUBSTRING(pText FROM _cursor FOR 1) NOT IN ( '0', '1', '2', '3', '4',
54075
 
                                                     '5' ,'6' ,'7' ,'8' ,'9' )) THEN
54076
 
      RETURN FALSE;
54077
 
    END IF;
54078
 
  END LOOP;
54079
 
 
54080
 
  RETURN TRUE;
54081
 
 
54082
 
END;
54083
 
$_$;
54084
 
 
54085
 
 
54086
 
ALTER FUNCTION public.isnumeric(text) OWNER TO admin;
54087
 
 
54088
 
--
54089
 
--
54090
 
 
54091
 
CREATE FUNCTION issueallbalancetoshipping(integer) RETURNS integer
54092
 
    LANGUAGE plpgsql
54093
 
    AS $_$
54094
 
BEGIN
54095
 
  RETURN issueAllBalanceToShipping('SO', $1, 0, NULL);
54096
 
END;
54097
 
$_$;
54098
 
 
54099
 
 
54100
 
ALTER FUNCTION public.issueallbalancetoshipping(integer) OWNER TO admin;
54101
 
 
54102
 
--
54103
 
--
54104
 
 
54105
 
CREATE FUNCTION issueallbalancetoshipping(text, integer, integer, timestamp with time zone) RETURNS integer
54106
 
    LANGUAGE plpgsql
54107
 
    AS $_$
54108
 
DECLARE
54109
 
  pordertype            ALIAS FOR $1;
54110
 
  pheadid               ALIAS FOR $2;
54111
 
  _itemlocSeries        INTEGER                  := $3;
54112
 
  _timestamp            TIMESTAMP WITH TIME ZONE := $4;
54113
 
  _s                    RECORD;
54114
 
 
54115
 
BEGIN
54116
 
  IF (pordertype = 'SO') THEN
54117
 
    FOR _s IN SELECT coitem_id,
54118
 
                     CASE WHEN (fetchMetricBool('RequireSOReservations'))
54119
 
                          THEN coitem_qtyreserved
54120
 
                          ELSE noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id) )
54121
 
                     END AS _balance
54122
 
              FROM coitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id)) ON (coitem_itemsite_id=itemsite_id)
54123
 
              WHERE ( (coitem_status NOT IN ('C','X'))
54124
 
                AND (item_type != 'K')
54125
 
               AND (coitem_cohead_id=pheadid) ) LOOP
54126
 
 
54127
 
      IF (_s.balance <> 0) THEN
54128
 
        _itemlocSeries := issueToShipping(pordertype, _s.coitem_id, _s.balance, _itemlocSeries, _timestamp);
54129
 
        IF (_itemlocSeries < 0) THEN
54130
 
          EXIT;
54131
 
        END IF;
54132
 
      END IF;
54133
 
    END LOOP;
54134
 
 
54135
 
  ELSEIF (pordertype = 'TO') THEN
54136
 
    FOR _s IN SELECT toitem_id,
54137
 
                     noNeg( toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id) )
54138
 
                      AS balance
54139
 
              FROM toitem
54140
 
              WHERE ( (toitem_status NOT IN ('C','X'))
54141
 
               AND (toitem_tohead_id=pheadid) ) LOOP
54142
 
 
54143
 
      IF (_s.balance <> 0) THEN
54144
 
        _itemlocSeries := issueToShipping(pordertype, _s.toitem_id, _s.balance, _itemlocSeries, _timestamp);
54145
 
        IF (_itemlocSeries < 0) THEN
54146
 
          EXIT;
54147
 
        END IF;
54148
 
      END IF;
54149
 
    END LOOP;
54150
 
 
54151
 
  ELSE
54152
 
    RETURN -1;
54153
 
  END IF;
54154
 
 
54155
 
  RETURN _itemlocSeries;
54156
 
 
54157
 
END;
54158
 
$_$;
54159
 
 
54160
 
 
54161
 
ALTER FUNCTION public.issueallbalancetoshipping(text, integer, integer, timestamp with time zone) OWNER TO admin;
54162
 
 
54163
 
--
54164
 
--
54165
 
 
54166
 
CREATE FUNCTION issuelinebalancetoshipping(integer) RETURNS integer
54167
 
    LANGUAGE plpgsql
54168
 
    AS $_$
54169
 
BEGIN
54170
 
  RETURN issueLineBalanceToShipping('SO', $1, NULL);
54171
 
END;
54172
 
$_$;
54173
 
 
54174
 
 
54175
 
ALTER FUNCTION public.issuelinebalancetoshipping(integer) OWNER TO admin;
54176
 
 
54177
 
--
54178
 
--
54179
 
 
54180
 
CREATE FUNCTION issuelinebalancetoshipping(text, integer, timestamp with time zone) RETURNS integer
54181
 
    LANGUAGE plpgsql
54182
 
    AS $_$
54183
 
BEGIN
54184
 
  RETURN issueLineBalanceToShipping($1, $2, $3, 0, NULL);
54185
 
END;
54186
 
$_$;
54187
 
 
54188
 
 
54189
 
ALTER FUNCTION public.issuelinebalancetoshipping(text, integer, timestamp with time zone) OWNER TO admin;
54190
 
 
54191
 
--
54192
 
--
54193
 
 
54194
 
CREATE FUNCTION issuelinebalancetoshipping(text, integer, timestamp with time zone, integer, integer) RETURNS integer
54195
 
    LANGUAGE plpgsql
54196
 
    AS $_$
54197
 
DECLARE
54198
 
  pordertype            ALIAS FOR $1;
54199
 
  pitemid               ALIAS FOR $2;
54200
 
  ptimestamp            ALIAS FOR $3;
54201
 
  pitemlocseries        ALIAS FOR $4;
54202
 
  pinvhistid            ALIAS FOR $5;
54203
 
  _itemlocSeries        INTEGER := 0;
54204
 
  _qty                  NUMERIC;
54205
 
 
54206
 
BEGIN
54207
 
  _itemlocSeries := COALESCE(pitemlocseries,0);
54208
 
  
54209
 
  IF (pordertype = 'SO') THEN
54210
 
    SELECT CASE WHEN (fetchMetricBool('RequireSOReservations'))
54211
 
                THEN coitem_qtyreserved
54212
 
                ELSE noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id) )
54213
 
           END INTO _qty
54214
 
    FROM coitem
54215
 
    WHERE (coitem_id=pitemid);
54216
 
  ELSEIF (pordertype = 'TO') THEN
54217
 
    SELECT noNeg( toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id) )
54218
 
               INTO _qty
54219
 
    FROM toitem
54220
 
    WHERE (toitem_id=pitemid);
54221
 
  ELSE
54222
 
    RETURN -1;
54223
 
  END IF;
54224
 
 
54225
 
  IF (_qty > 0) THEN
54226
 
    _itemlocSeries := issueToShipping(pordertype, pitemid, _qty, _itemlocSeries, ptimestamp, pinvhistid);
54227
 
  END IF;
54228
 
 
54229
 
  RETURN _itemlocSeries;
54230
 
 
54231
 
END;
54232
 
$_$;
54233
 
 
54234
 
 
54235
 
ALTER FUNCTION public.issuelinebalancetoshipping(text, integer, timestamp with time zone, integer, integer) OWNER TO admin;
54236
 
 
54237
 
--
54238
 
--
54239
 
 
54240
 
CREATE FUNCTION issues(text) RETURNS boolean
54241
 
    LANGUAGE plpgsql
54242
 
    AS $_$
54243
 
DECLARE
54244
 
  pTransType ALIAS FOR $1;
54245
 
 
54246
 
BEGIN
54247
 
  IF (pTransType IN ('IM', 'IB', 'IT')) THEN
54248
 
    RETURN TRUE;
54249
 
  ELSE
54250
 
    RETURN FALSE;
54251
 
  END IF;
54252
 
 
54253
 
END;
54254
 
$_$;
54255
 
 
54256
 
 
54257
 
ALTER FUNCTION public.issues(text) OWNER TO admin;
54258
 
 
54259
 
--
54260
 
--
54261
 
 
54262
 
CREATE FUNCTION issuetoshipping(integer, numeric) RETURNS integer
54263
 
    LANGUAGE plpgsql
54264
 
    AS $_$
54265
 
BEGIN
54266
 
  RETURN issueToShipping('SO', $1, $2, 0, CURRENT_TIMESTAMP);
54267
 
END;
54268
 
$_$;
54269
 
 
54270
 
 
54271
 
ALTER FUNCTION public.issuetoshipping(integer, numeric) OWNER TO admin;
54272
 
 
54273
 
--
54274
 
--
54275
 
 
54276
 
CREATE FUNCTION issuetoshipping(integer, numeric, integer) RETURNS integer
54277
 
    LANGUAGE plpgsql
54278
 
    AS $_$
54279
 
BEGIN
54280
 
  RETURN issueToShipping('SO', $1, $2, $3, CURRENT_TIMESTAMP);
54281
 
END;
54282
 
$_$;
54283
 
 
54284
 
 
54285
 
ALTER FUNCTION public.issuetoshipping(integer, numeric, integer) OWNER TO admin;
54286
 
 
54287
 
--
54288
 
--
54289
 
 
54290
 
CREATE FUNCTION issuetoshipping(text, integer, numeric, integer, timestamp with time zone) RETURNS integer
54291
 
    LANGUAGE plpgsql
54292
 
    AS $_$
54293
 
BEGIN
54294
 
  RETURN issueToShipping($1, $2, $3, $4, $5, NULL);
54295
 
END;
54296
 
$_$;
54297
 
 
54298
 
 
54299
 
ALTER FUNCTION public.issuetoshipping(text, integer, numeric, integer, timestamp with time zone) OWNER TO admin;
54300
 
 
54301
 
--
54302
 
--
54303
 
 
54304
 
CREATE FUNCTION issuetoshipping(pordertype text, pitemid integer, pqty numeric, pitemlocseries integer, ptimestamp timestamp with time zone, pinvhistid integer) RETURNS integer
54305
 
    LANGUAGE plpgsql
54306
 
    AS $$
54307
 
DECLARE
54308
 
  _itemlocSeries        INTEGER;
54309
 
  _timestamp            TIMESTAMP WITH TIME ZONE;
54310
 
  _coholdtype           TEXT;
54311
 
  _balance              NUMERIC;
54312
 
  _invhistid            INTEGER;
54313
 
  _shipheadid           INTEGER;
54314
 
  _shipnumber           INTEGER;
54315
 
  _cntctid              INTEGER;
54316
 
  _p                    RECORD;
54317
 
  _m                    RECORD;
54318
 
  _value                NUMERIC;
54319
 
  _warehouseid          INTEGER;
54320
 
  _shipitemid           INTEGER;
54321
 
  _freight              NUMERIC;
54322
 
 
54323
 
BEGIN
54324
 
 
54325
 
  IF (pTimestamp IS NULL) THEN
54326
 
    _timestamp := CURRENT_TIMESTAMP;
54327
 
  ELSE
54328
 
    _timestamp := pTimestamp;
54329
 
  END IF;
54330
 
 
54331
 
  IF (pItemlocSeries = 0) THEN
54332
 
    _itemlocSeries := NEXTVAL('itemloc_series_seq');
54333
 
  ELSE
54334
 
    _itemlocSeries := pItemlocSeries;
54335
 
  END IF;
54336
 
 
54337
 
  IF (pordertype = 'SO') THEN
54338
 
 
54339
 
    -- Check site security
54340
 
    SELECT warehous_id INTO _warehouseid
54341
 
    FROM coitem,itemsite,site()
54342
 
    WHERE ((coitem_id=pitemid)
54343
 
    AND (itemsite_id=coitem_itemsite_id)
54344
 
    AND (warehous_id=itemsite_warehous_id));
54345
 
          
54346
 
    IF (NOT FOUND) THEN
54347
 
      RETURN 0;
54348
 
    END IF;
54349
 
 
54350
 
    -- Check for average cost items going negative
54351
 
    IF ( SELECT ( (itemsite_costmethod='A') AND
54352
 
                  ((itemsite_qtyonhand - round(pQty * coitem_qty_invuomratio, 6)) < 0.0) )
54353
 
         FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
54354
 
         WHERE (coitem_id=pitemid) ) THEN
54355
 
      RETURN -20;
54356
 
    END IF;
54357
 
 
54358
 
    -- Check auto registration
54359
 
    IF ( SELECT COALESCE(itemsite_autoreg, FALSE)
54360
 
         FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
54361
 
         WHERE (coitem_id=pitemid) ) THEN
54362
 
      SELECT COALESCE(crmacct_cntct_id_1, -1) INTO _cntctid
54363
 
      FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)
54364
 
                  JOIN crmacct ON (crmacct_cust_id=cohead_cust_id)
54365
 
      WHERE (coitem_id=pitemid);
54366
 
      IF (_cntctid = -1) THEN
54367
 
        RETURN -15;
54368
 
      END IF;
54369
 
    END IF; 
54370
 
  
54371
 
    -- Check Credit Hold
54372
 
    SELECT cohead_holdtype INTO _coholdtype
54373
 
    FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)
54374
 
    WHERE (coitem_id=pitemid);
54375
 
 
54376
 
    SELECT calcSalesOrderAmt(cohead_id) -
54377
 
           COALESCE(SUM(currToCurr(aropenalloc_curr_id, cohead_curr_id,
54378
 
                                   aropenalloc_amount, cohead_orderdate)),0) INTO _balance
54379
 
    FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)
54380
 
                LEFT OUTER JOIN aropenalloc ON (aropenalloc_doctype='S' AND
54381
 
                                                aropenalloc_doc_id=cohead_id)
54382
 
    WHERE (coitem_id=pitemid)
54383
 
    GROUP BY cohead_id;
54384
 
 
54385
 
    --RAISE NOTICE 'issueToShipping - order balance is %', _balance;
54386
 
    IF ( (_coholdtype = 'C') AND (_balance > 0.0) ) THEN
54387
 
      RETURN -12;
54388
 
    ELSIF (_coholdtype = 'P') THEN
54389
 
      RETURN -13;
54390
 
    ELSIF (_coholdtype = 'R') THEN
54391
 
      RETURN -14;
54392
 
    END IF;
54393
 
 
54394
 
    SELECT shiphead_id INTO _shipheadid
54395
 
    FROM shiphead, coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
54396
 
    WHERE ( (coitem_id=pitemid)
54397
 
      AND   (shiphead_number=getOpenShipment(pordertype, coitem_cohead_id, itemsite_warehous_id)) );
54398
 
    IF (NOT FOUND) THEN
54399
 
      SELECT NEXTVAL('shiphead_shiphead_id_seq') INTO _shipheadid;
54400
 
 
54401
 
      _shipnumber := fetchShipmentNumber();
54402
 
      IF (_shipnumber < 0) THEN
54403
 
        RETURN -10;
54404
 
      END IF;
54405
 
 
54406
 
      INSERT INTO shiphead
54407
 
      ( shiphead_id, shiphead_number, shiphead_order_id, shiphead_order_type,
54408
 
        shiphead_shipped,
54409
 
        shiphead_sfstatus, shiphead_shipvia, shiphead_shipchrg_id,
54410
 
        shiphead_freight, shiphead_freight_curr_id,
54411
 
        shiphead_shipdate, shiphead_notes, shiphead_shipform_id )
54412
 
      SELECT _shipheadid, _shipnumber, coitem_cohead_id, pordertype,
54413
 
             FALSE,
54414
 
             'N', cohead_shipvia,
54415
 
             CASE WHEN (cohead_shipchrg_id <= 0) THEN NULL
54416
 
                  ELSE cohead_shipchrg_id
54417
 
             END,
54418
 
             cohead_freight, cohead_curr_id,
54419
 
             _timestamp::DATE, cohead_shipcomments,
54420
 
             CASE WHEN cohead_shipform_id = -1 THEN NULL
54421
 
                  ELSE cohead_shipform_id
54422
 
             END
54423
 
      FROM cohead, coitem
54424
 
      WHERE ((coitem_cohead_id=cohead_id)
54425
 
         AND (coitem_id=pitemid) );
54426
 
 
54427
 
      UPDATE pack
54428
 
      SET pack_shiphead_id = _shipheadid,
54429
 
          pack_printed = FALSE
54430
 
      FROM coitem
54431
 
      WHERE ((pack_head_id=coitem_cohead_id)
54432
 
        AND  (pack_shiphead_id IS NULL)
54433
 
        AND  (pack_head_type='SO')
54434
 
        AND  (coitem_id=pitemid));
54435
 
 
54436
 
    ELSE
54437
 
      UPDATE pack
54438
 
      SET pack_printed = FALSE
54439
 
      FROM coitem
54440
 
      WHERE ((pack_head_id=coitem_cohead_id)
54441
 
        AND  (pack_shiphead_id=_shipheadid)
54442
 
        AND  (pack_head_type='SO')
54443
 
        AND  (coitem_id=pitemid));
54444
 
    END IF;
54445
 
 
54446
 
    -- Handle g/l transaction
54447
 
    SELECT postInvTrans( itemsite_id, 'SH', (pQty * coitem_qty_invuomratio),
54448
 
                           'S/R', porderType,
54449
 
                           formatSoNumber(coitem_id), shiphead_number,
54450
 
                           ('Issue ' || item_number || ' to Shipping for customer ' || cohead_billtoname),
54451
 
                           getPrjAccntId(cohead_prj_id, costcat_shipasset_accnt_id), costcat_asset_accnt_id,
54452
 
                           _itemlocSeries, _timestamp, NULL, pinvhistid ) INTO _invhistid
54453
 
    FROM coitem, cohead, itemsite, item, costcat, shiphead
54454
 
    WHERE ( (coitem_cohead_id=cohead_id)
54455
 
     AND (coitem_itemsite_id=itemsite_id)
54456
 
     AND (itemsite_item_id=item_id)
54457
 
     AND (itemsite_costcat_id=costcat_id)
54458
 
     AND (coitem_id=pitemid)
54459
 
     AND (shiphead_id=_shipheadid) );
54460
 
 
54461
 
    SELECT (invhist_unitcost * invhist_invqty) INTO _value
54462
 
    FROM invhist
54463
 
    WHERE (invhist_id=_invhistid);
54464
 
 
54465
 
    _shipitemid := nextval('shipitem_shipitem_id_seq');
54466
 
    INSERT INTO shipitem
54467
 
    ( shipitem_id, shipitem_shiphead_id, shipitem_orderitem_id, shipitem_qty,
54468
 
      shipitem_transdate, shipitem_trans_username, shipitem_invoiced,
54469
 
      shipitem_value, shipitem_invhist_id )
54470
 
    VALUES
54471
 
    ( _shipitemid, _shipheadid, pitemid, pQty,
54472
 
      _timestamp, getEffectiveXtUser(), FALSE,
54473
 
      _value, 
54474
 
      CASE WHEN _invhistid = -1 THEN
54475
 
        NULL
54476
 
      ELSE 
54477
 
        _invhistid
54478
 
      END );
54479
 
 
54480
 
    -- Handle reservation
54481
 
    IF (fetchmetricbool('EnableSOReservations')) THEN
54482
 
      -- Remember what was reserved so we can re-reserve if this issue is returned
54483
 
      INSERT INTO shipitemrsrv 
54484
 
        (shipitemrsrv_shipitem_id, shipitemrsrv_qty)
54485
 
      SELECT _shipitemid, least(pQty,coitem_qtyreserved)
54486
 
      FROM coitem
54487
 
      WHERE ((coitem_id=pitemid)
54488
 
      AND (coitem_qtyreserved > 0));
54489
 
 
54490
 
      -- Update sales order
54491
 
      UPDATE coitem
54492
 
        SET coitem_qtyreserved = noNeg(coitem_qtyreserved - pQty)
54493
 
      WHERE(coitem_id=pitemid);
54494
 
    END IF;
54495
 
 
54496
 
    -- Calculate shipment freight
54497
 
    SELECT calcShipFreight(_shipheadid) INTO _freight;
54498
 
    UPDATE shiphead SET shiphead_freight=_freight
54499
 
    WHERE (shiphead_id=_shipheadid);
54500
 
 
54501
 
  ELSEIF (pordertype = 'TO') THEN
54502
 
 
54503
 
    -- Check site security
54504
 
    IF (fetchMetricBool('MultiWhs')) THEN
54505
 
      SELECT warehous_id INTO _warehouseid
54506
 
      FROM toitem, tohead, site()
54507
 
      WHERE ( (toitem_id=pitemid)
54508
 
        AND   (tohead_id=toitem_tohead_id)
54509
 
        AND   (warehous_id=tohead_src_warehous_id) );
54510
 
          
54511
 
      IF (NOT FOUND) THEN
54512
 
        RETURN 0;
54513
 
      END IF;
54514
 
    END IF;
54515
 
 
54516
 
    SELECT postInvTrans( itemsite_id, 'SH', pQty, 'S/R',
54517
 
                         pordertype, formatToNumber(toitem_id), '', 'Issue to Shipping',
54518
 
                         costcat_shipasset_accnt_id, costcat_asset_accnt_id,
54519
 
                         _itemlocSeries, _timestamp) INTO _invhistid
54520
 
    FROM tohead, toitem, itemsite, costcat
54521
 
    WHERE ((tohead_id=toitem_tohead_id)
54522
 
      AND  (itemsite_item_id=toitem_item_id)
54523
 
      AND  (itemsite_warehous_id=tohead_src_warehous_id)
54524
 
      AND  (itemsite_costcat_id=costcat_id)
54525
 
      AND  (toitem_id=pitemid) );
54526
 
 
54527
 
    SELECT (invhist_unitcost * invhist_invqty) INTO _value
54528
 
    FROM invhist
54529
 
    WHERE (invhist_id=_invhistid);
54530
 
 
54531
 
    SELECT shiphead_id INTO _shipheadid
54532
 
    FROM shiphead, toitem JOIN tohead ON (tohead_id=toitem_tohead_id)
54533
 
    WHERE ( (toitem_id=pitemid)
54534
 
      AND   (shiphead_number=getOpenShipment(pordertype, tohead_id, tohead_src_warehous_id)) );
54535
 
 
54536
 
    IF (NOT FOUND) THEN
54537
 
      _shipheadid := NEXTVAL('shiphead_shiphead_id_seq');
54538
 
 
54539
 
      _shipnumber := fetchShipmentNumber();
54540
 
      IF (_shipnumber < 0) THEN
54541
 
        RETURN -10;
54542
 
      END IF;
54543
 
 
54544
 
      INSERT INTO shiphead
54545
 
      ( shiphead_id, shiphead_number, shiphead_order_id, shiphead_order_type,
54546
 
        shiphead_shipped,
54547
 
        shiphead_sfstatus, shiphead_shipvia, shiphead_shipchrg_id,
54548
 
        shiphead_freight, shiphead_freight_curr_id,
54549
 
        shiphead_shipdate, shiphead_notes, shiphead_shipform_id )
54550
 
      SELECT _shipheadid, _shipnumber, tohead_id, pordertype,
54551
 
             FALSE,
54552
 
             'N', tohead_shipvia, tohead_shipchrg_id,
54553
 
             tohead_freight + SUM(toitem_freight), tohead_freight_curr_id,
54554
 
             _timestamp::DATE, tohead_shipcomments, tohead_shipform_id
54555
 
      FROM tohead, toitem
54556
 
      WHERE ((toitem_tohead_id=tohead_id)
54557
 
         AND (tohead_id IN (SELECT toitem_tohead_id
54558
 
                            FROM toitem
54559
 
                            WHERE (toitem_id=pitemid))) )
54560
 
      GROUP BY tohead_id, tohead_shipvia, tohead_shipchrg_id, tohead_freight,
54561
 
               tohead_freight_curr_id, tohead_shipcomments, tohead_shipform_id;
54562
 
    END IF;
54563
 
 
54564
 
    INSERT INTO shipitem
54565
 
    ( shipitem_shiphead_id, shipitem_orderitem_id, shipitem_qty,
54566
 
      shipitem_transdate, shipitem_trans_username, shipitem_invoiced,
54567
 
      shipitem_value, shipitem_invhist_id )
54568
 
    VALUES
54569
 
    ( _shipheadid, pitemid, pQty,
54570
 
      _timestamp, getEffectiveXtUser(), FALSE,
54571
 
      _value, 
54572
 
      CASE WHEN _invhistid = -1 THEN NULL
54573
 
           ELSE _invhistid
54574
 
      END
54575
 
    );
54576
 
 
54577
 
  ELSE
54578
 
    RETURN -11;
54579
 
  END IF;
54580
 
 
54581
 
  RETURN _itemlocSeries;
54582
 
 
54583
 
END;
54584
 
$$;
54585
 
 
54586
 
 
54587
 
ALTER FUNCTION public.issuetoshipping(pordertype text, pitemid integer, pqty numeric, pitemlocseries integer, ptimestamp timestamp with time zone, pinvhistid integer) OWNER TO admin;
54588
 
 
54589
 
--
54590
 
--
54591
 
 
54592
 
CREATE FUNCTION issuewomaterial(integer, numeric) RETURNS integer
54593
 
    LANGUAGE plpgsql
54594
 
    AS $_$
54595
 
DECLARE
54596
 
  pWomatlid ALIAS FOR $1;
54597
 
  pQty ALIAS FOR $2;
54598
 
  _itemlocSeries INTEGER;
54599
 
 
54600
 
BEGIN
54601
 
 
54602
 
  SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
54603
 
  RETURN issueWoMaterial(pWomatlid, pQty, _itemlocSeries);
54604
 
 
54605
 
END;
54606
 
$_$;
54607
 
 
54608
 
 
54609
 
ALTER FUNCTION public.issuewomaterial(integer, numeric) OWNER TO admin;
54610
 
 
54611
 
--
54612
 
--
54613
 
 
54614
 
CREATE FUNCTION issuewomaterial(integer, numeric, integer) RETURNS integer
54615
 
    LANGUAGE plpgsql
54616
 
    AS $_$
54617
 
DECLARE
54618
 
  pWomatlid ALIAS FOR $1;
54619
 
  pQty ALIAS FOR $2;
54620
 
  pItemlocSeries ALIAS FOR $3;
54621
 
  _p RECORD;
54622
 
  _invhistid INTEGER;
54623
 
  _itemlocSeries INTEGER;
54624
 
 
54625
 
BEGIN
54626
 
  RETURN issueWoMaterial(pWomatlid, pQty, pItemlocSeries, now());
54627
 
END;
54628
 
$_$;
54629
 
 
54630
 
 
54631
 
ALTER FUNCTION public.issuewomaterial(integer, numeric, integer) OWNER TO admin;
54632
 
 
54633
 
--
54634
 
--
54635
 
 
54636
 
CREATE FUNCTION issuewomaterial(integer, numeric, boolean) RETURNS integer
54637
 
    LANGUAGE plpgsql
54638
 
    AS $_$
54639
 
DECLARE
54640
 
  pWomatlid ALIAS FOR $1;
54641
 
  pQty ALIAS FOR $2;
54642
 
  pMarkPush ALIAS FOR $3;
54643
 
  _itemlocSeries INTEGER;
54644
 
 
54645
 
BEGIN
54646
 
  RETURN issueWoMaterial(pWomatlid, pQty, pMarkPush, now());
54647
 
END;
54648
 
$_$;
54649
 
 
54650
 
 
54651
 
ALTER FUNCTION public.issuewomaterial(integer, numeric, boolean) OWNER TO admin;
54652
 
 
54653
 
--
54654
 
--
54655
 
 
54656
 
CREATE FUNCTION issuewomaterial(integer, numeric, integer, boolean) RETURNS integer
54657
 
    LANGUAGE plpgsql
54658
 
    AS $_$
54659
 
DECLARE
54660
 
  pWomatlid ALIAS FOR $1;
54661
 
  pQty ALIAS FOR $2;
54662
 
  pItemlocSeries ALIAS FOR $3;
54663
 
  pMarkPush ALIAS FOR $4;
54664
 
  _itemlocSeries INTEGER;
54665
 
 
54666
 
BEGIN
54667
 
  RETURN issueWoMaterial(pWomatlid, pQty, pItemlocSeries,now());
54668
 
END;
54669
 
$_$;
54670
 
 
54671
 
 
54672
 
ALTER FUNCTION public.issuewomaterial(integer, numeric, integer, boolean) OWNER TO admin;
54673
 
 
54674
 
--
54675
 
--
54676
 
 
54677
 
CREATE FUNCTION issuewomaterial(integer, numeric, integer, timestamp with time zone) RETURNS integer
54678
 
    LANGUAGE plpgsql
54679
 
    AS $_$
54680
 
BEGIN
54681
 
  RETURN issueWoMaterial($1, $2, $3, $4, NULL);
54682
 
END;
54683
 
$_$;
54684
 
 
54685
 
 
54686
 
ALTER FUNCTION public.issuewomaterial(integer, numeric, integer, timestamp with time zone) OWNER TO admin;
54687
 
 
54688
 
--
54689
 
--
54690
 
 
54691
 
CREATE FUNCTION issuewomaterial(integer, numeric, boolean, timestamp with time zone) RETURNS integer
54692
 
    LANGUAGE plpgsql
54693
 
    AS $_$
54694
 
DECLARE
54695
 
  pWomatlid ALIAS FOR $1;
54696
 
  pQty ALIAS FOR $2;
54697
 
  pMarkPush ALIAS FOR $3;
54698
 
  pGlDistTS ALIAS FOR $4;
54699
 
  _itemlocSeries INTEGER;
54700
 
 
54701
 
BEGIN
54702
 
 
54703
 
  SELECT issueWoMaterial(pWomatlid, pQty, 0, pGlDistTS) INTO _itemlocSeries;
54704
 
  IF (_itemlocSeries < 0) THEN
54705
 
    RETURN _itemlocSeries;
54706
 
  END IF;
54707
 
 
54708
 
  IF (pMarkPush) THEN
54709
 
    UPDATE womatl
54710
 
    SET womatl_issuemethod='S'
54711
 
    WHERE ((womatl_issuemethod='M')
54712
 
     AND (womatl_id=pWomatlid));
54713
 
  END IF;
54714
 
 
54715
 
  RETURN _itemlocSeries;
54716
 
 
54717
 
END;
54718
 
$_$;
54719
 
 
54720
 
 
54721
 
ALTER FUNCTION public.issuewomaterial(integer, numeric, boolean, timestamp with time zone) OWNER TO admin;
54722
 
 
54723
 
--
54724
 
--
54725
 
 
54726
 
CREATE FUNCTION issuewomaterial(integer, numeric, integer, boolean, timestamp with time zone) RETURNS integer
54727
 
    LANGUAGE plpgsql
54728
 
    AS $_$
54729
 
DECLARE
54730
 
  pWomatlid ALIAS FOR $1;
54731
 
  pQty ALIAS FOR $2;
54732
 
  pItemlocSeries ALIAS FOR $3;
54733
 
  pMarkPush ALIAS FOR $4;
54734
 
  pGlDistTS ALIAS FOR $5;
54735
 
  _itemlocSeries INTEGER;
54736
 
 
54737
 
BEGIN
54738
 
 
54739
 
  SELECT issueWoMaterial(pWomatlid, pQty, pItemlocSeries, pGlDistTS) INTO _itemlocSeries;
54740
 
 
54741
 
  IF (pMarkPush) THEN
54742
 
    UPDATE womatl
54743
 
    SET womatl_issuemethod='S'
54744
 
    WHERE ((womatl_issuemethod='M')
54745
 
     AND (womatl_id=pWomatlid));
54746
 
  END IF;
54747
 
 
54748
 
  RETURN _itemlocSeries;
54749
 
 
54750
 
END;
54751
 
$_$;
54752
 
 
54753
 
 
54754
 
ALTER FUNCTION public.issuewomaterial(integer, numeric, integer, boolean, timestamp with time zone) OWNER TO admin;
54755
 
 
54756
 
--
54757
 
--
54758
 
 
54759
 
CREATE FUNCTION issuewomaterial(integer, numeric, integer, timestamp with time zone, integer) RETURNS integer
54760
 
    LANGUAGE plpgsql
54761
 
    AS $_$
54762
 
DECLARE
54763
 
  pWomatlid ALIAS FOR $1;
54764
 
  pQty ALIAS FOR $2;
54765
 
  pItemlocSeries ALIAS FOR $3;
54766
 
  pGlDistTS ALIAS FOR $4;
54767
 
  pInvhistid ALIAS FOR $5;
54768
 
  _p RECORD;
54769
 
  _invhistid INTEGER;
54770
 
  _itemlocSeries INTEGER;
54771
 
 
54772
 
BEGIN
54773
 
 
54774
 
  SELECT item_id,
54775
 
         itemsite_id AS c_itemsite_id,
54776
 
         wo_itemsite_id AS p_itemsite_id,
54777
 
         itemsite_loccntrl, itemsite_controlmethod,
54778
 
         womatl_wo_id, womatl_qtyreq, itemsite_item_id, womatl_uom_id, wo_prj_id,
54779
 
         roundQty(item_fractional, itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, pQty)) AS qty,
54780
 
         formatWoNumber(wo_id) AS woNumber,
54781
 
         CASE WHEN(itemsite_costmethod='J' AND item_type='P' AND poitem_id IS NOT NULL) THEN poitem_unitprice
54782
 
              WHEN(itemsite_costmethod IN ('A','J')) THEN avgcost(itemsite_id)
54783
 
              WHEN(itemsite_costmethod='S') THEN stdcost(itemsite_item_id)
54784
 
              ELSE 0.0
54785
 
         END AS cost,
54786
 
         womatl_issuemethod AS issueMethod INTO _p
54787
 
  FROM womatl JOIN wo ON (wo_id=womatl_wo_id)
54788
 
              JOIN itemsite ON (itemsite_id=womatl_itemsite_id)
54789
 
              JOIN item ON (item_id=itemsite_item_id)
54790
 
              LEFT OUTER JOIN poitem ON (poitem_order_id=womatl_id AND poitem_order_type='W')
54791
 
  WHERE (womatl_id=pWomatlid);
54792
 
 
54793
 
  IF (pQty < 0) THEN
54794
 
    RETURN pItemlocSeries;
54795
 
  END IF;
54796
 
 
54797
 
  IF (pItemlocSeries <> 0) THEN
54798
 
    _itemlocSeries := pItemlocSeries;
54799
 
  ELSE
54800
 
    SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
54801
 
  END IF;
54802
 
  SELECT postInvTrans( ci.itemsite_id, 'IM', _p.qty,
54803
 
                      'W/O', 'WO', _p.woNumber, '',
54804
 
                      ('Material ' || item_number || ' Issue to Work Order'),
54805
 
                      getPrjAccntId(_p.wo_prj_id, pc.costcat_wip_accnt_id),
54806
 
                      cc.costcat_asset_accnt_id, _itemlocSeries, pGlDistTS,
54807
 
                      NULL, pInvhistid ) INTO _invhistid
54808
 
  FROM itemsite AS ci, itemsite AS pi,
54809
 
       costcat AS cc, costcat AS pc,
54810
 
       item
54811
 
  WHERE ( (ci.itemsite_costcat_id=cc.costcat_id)
54812
 
   AND (pi.itemsite_costcat_id=pc.costcat_id)
54813
 
   AND (ci.itemsite_id=_p.c_itemsite_id)
54814
 
   AND (pi.itemsite_id=_p.p_itemsite_id)
54815
 
   AND (ci.itemsite_item_id=item_id) );
54816
 
 
54817
 
  IF (_invhistid != -1) THEN
54818
 
    INSERT INTO womatlpost (womatlpost_womatl_id,womatlpost_invhist_id)
54819
 
                VALUES (pWomatlid,_invhistid);
54820
 
  END IF;
54821
 
 
54822
 
  UPDATE wo
54823
 
  SET wo_wipvalue = (wo_wipvalue + (_p.cost * _p.qty)),
54824
 
      wo_postedvalue = (wo_postedvalue + (_p.cost * _p.qty))
54825
 
  WHERE (wo_id=_p.womatl_wo_id);
54826
 
 
54827
 
  UPDATE womatl
54828
 
  SET womatl_qtyiss = (womatl_qtyiss + itemuomtouom(_p.itemsite_item_id, NULL, _p.womatl_uom_id, _p.qty)),
54829
 
      womatl_lastissue = pGlDistTS::DATE
54830
 
  WHERE (womatl_id=pWomatlid);
54831
 
 
54832
 
  UPDATE wo
54833
 
  SET wo_status='I'
54834
 
  WHERE ( (wo_status <> 'I')
54835
 
   AND (wo_id=_p.womatl_wo_id) );
54836
 
 
54837
 
  RETURN _itemlocSeries;
54838
 
 
54839
 
END;
54840
 
$_$;
54841
 
 
54842
 
 
54843
 
ALTER FUNCTION public.issuewomaterial(integer, numeric, integer, timestamp with time zone, integer) OWNER TO admin;
54844
 
 
54845
 
--
54846
 
--
54847
 
 
54848
 
CREATE FUNCTION issuewomaterialbatch(integer) RETURNS integer
54849
 
    LANGUAGE plpgsql
54850
 
    AS $_$
54851
 
DECLARE
54852
 
  pWoid ALIAS FOR $1;
54853
 
  _itemlocSeries INTEGER;
54854
 
  _r RECORD;
54855
 
  _woNumber TEXT;
54856
 
 
54857
 
BEGIN
54858
 
 
54859
 
  SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
54860
 
 
54861
 
  FOR _r IN SELECT womatl_id, 
54862
 
              CASE WHEN (womatl_qtyreq >= 0) THEN
54863
 
                roundQty(itemuomfractionalbyuom(item_id, womatl_uom_id), noNeg(womatl_qtyreq - womatl_qtyiss))
54864
 
              ELSE
54865
 
                roundQty(itemuomfractionalbyuom(item_id, womatl_uom_id), noNeg(womatl_qtyiss * -1)) 
54866
 
              END AS qty
54867
 
            FROM womatl, itemsite, item
54868
 
            WHERE ( (womatl_itemsite_id=itemsite_id)
54869
 
             AND (itemsite_item_id=item_id)
54870
 
             AND (womatl_issuemethod IN ('S', 'M'))
54871
 
             AND (womatl_wo_id=pWoid) ) LOOP
54872
 
 
54873
 
    IF (_r.qty > 0) THEN
54874
 
      SELECT issueWoMaterial(_r.womatl_id, _r.qty, _itemlocSeries, TRUE) INTO _itemlocSeries;
54875
 
    END IF;
54876
 
 
54877
 
  END LOOP;
54878
 
 
54879
 
  RETURN _itemlocSeries;
54880
 
 
54881
 
END;
54882
 
$_$;
54883
 
 
54884
 
 
54885
 
ALTER FUNCTION public.issuewomaterialbatch(integer) OWNER TO admin;
54886
 
 
54887
 
--
54888
 
--
54889
 
 
54890
 
CREATE FUNCTION itemaltcapinvrat(integer) RETURNS numeric
54891
 
    LANGUAGE plpgsql STABLE
54892
 
    AS $_$
54893
 
DECLARE
54894
 
  pItemid ALIAS FOR $1;
54895
 
 
54896
 
BEGIN
54897
 
  RETURN itemUOMRatioByType(pItemid, 'AltCapacity');
54898
 
END;
54899
 
$_$;
54900
 
 
54901
 
 
54902
 
ALTER FUNCTION public.itemaltcapinvrat(integer) OWNER TO admin;
54903
 
 
54904
 
--
54905
 
--
54906
 
 
54907
 
CREATE FUNCTION itemaltcapuom(integer) RETURNS text
54908
 
    LANGUAGE plpgsql STABLE
54909
 
    AS $_$
54910
 
DECLARE
54911
 
  pItemid ALIAS FOR $1;
54912
 
 
54913
 
BEGIN
54914
 
  RETURN itemUOMByType(pItemid, 'AltCapacity');
54915
 
END;
54916
 
$_$;
54917
 
 
54918
 
 
54919
 
ALTER FUNCTION public.itemaltcapuom(integer) OWNER TO admin;
54920
 
 
54921
 
--
54922
 
--
54923
 
 
54924
 
CREATE FUNCTION itemcapinvrat(integer) RETURNS numeric
54925
 
    LANGUAGE plpgsql STABLE
54926
 
    AS $_$
54927
 
DECLARE
54928
 
  pItemid ALIAS FOR $1;
54929
 
 
54930
 
BEGIN
54931
 
  RETURN itemUOMRatioByType(pItemid, 'Capacity');
54932
 
END;
54933
 
$_$;
54934
 
 
54935
 
 
54936
 
ALTER FUNCTION public.itemcapinvrat(integer) OWNER TO admin;
54937
 
 
54938
 
--
54939
 
--
54940
 
 
54941
 
CREATE FUNCTION itemcapuom(integer) RETURNS text
54942
 
    LANGUAGE plpgsql STABLE
54943
 
    AS $_$
54944
 
DECLARE
54945
 
  pItemid ALIAS FOR $1;
54946
 
 
54947
 
BEGIN
54948
 
  RETURN itemUOMByType(pItemid, 'Capacity');
54949
 
END;
54950
 
$_$;
54951
 
 
54952
 
 
54953
 
ALTER FUNCTION public.itemcapuom(integer) OWNER TO admin;
54954
 
 
54955
 
--
54956
 
--
54957
 
 
54958
 
CREATE FUNCTION itemcharprice(integer, integer, text, integer, numeric) RETURNS numeric
54959
 
    LANGUAGE plpgsql
54960
 
    AS $_$
54961
 
DECLARE
54962
 
  pItemid ALIAS FOR $1;
54963
 
  pCharid ALIAS FOR $2;
54964
 
  pCharValue ALIAS FOR $3;
54965
 
  pCustid ALIAS FOR $4;
54966
 
  pQty ALIAS FOR $5;
54967
 
 
54968
 
BEGIN
54969
 
  RETURN itemCharPrice(pItemid, pCharid, pCharValue, pCustid, -1, pQty, baseCurrId(), CURRENT_DATE);
54970
 
END;
54971
 
$_$;
54972
 
 
54973
 
 
54974
 
ALTER FUNCTION public.itemcharprice(integer, integer, text, integer, numeric) OWNER TO admin;
54975
 
 
54976
 
--
54977
 
--
54978
 
 
54979
 
CREATE FUNCTION itemcharprice(integer, integer, text, integer, integer, numeric) RETURNS numeric
54980
 
    LANGUAGE plpgsql
54981
 
    AS $_$
54982
 
DECLARE
54983
 
  pItemid ALIAS FOR $1;
54984
 
  pCharid ALIAS FOR $2;
54985
 
  pCharValue ALIAS FOR $3;
54986
 
  pCustid ALIAS FOR $4;
54987
 
  pShiptoid ALIAS FOR $5;
54988
 
  pQty ALIAS FOR $6;
54989
 
 
54990
 
BEGIN
54991
 
  RETURN itemCharPrice(pItemid, pCharid, pCharValue, pCustid, pShiptoid, pQty, baseCurrId(), CURRENT_DATE);
54992
 
END;
54993
 
$_$;
54994
 
 
54995
 
 
54996
 
ALTER FUNCTION public.itemcharprice(integer, integer, text, integer, integer, numeric) OWNER TO admin;
54997
 
 
54998
 
--
54999
 
--
55000
 
 
55001
 
CREATE FUNCTION itemcharprice(integer, integer, text, integer, integer, numeric, integer) RETURNS numeric
55002
 
    LANGUAGE plpgsql
55003
 
    AS $_$
55004
 
DECLARE
55005
 
  pItemid ALIAS FOR $1;
55006
 
  pCharid ALIAS FOR $2;
55007
 
  pCharValue ALIAS FOR $3;
55008
 
  pCustid ALIAS FOR $4;
55009
 
  pShiptoid ALIAS FOR $5;
55010
 
  pQty ALIAS FOR $6;
55011
 
  pCurrid ALIAS FOR $7;
55012
 
 
55013
 
BEGIN
55014
 
  RETURN itemCharPrice(pItemid, pCharid, pCharValue, pCustid, pShiptoid, pQty, pCurrid, CURRENT_DATE);
55015
 
END;
55016
 
$_$;
55017
 
 
55018
 
 
55019
 
ALTER FUNCTION public.itemcharprice(integer, integer, text, integer, integer, numeric, integer) OWNER TO admin;
55020
 
 
55021
 
--
55022
 
--
55023
 
 
55024
 
CREATE FUNCTION itemcharprice(integer, integer, text, integer, integer, numeric, integer, date) RETURNS numeric
55025
 
    LANGUAGE plpgsql
55026
 
    AS $_$
55027
 
DECLARE
55028
 
  pItemid ALIAS FOR $1;
55029
 
  pCharid ALIAS FOR $2;
55030
 
  pCharValue ALIAS FOR $3;
55031
 
  pCustid ALIAS FOR $4;
55032
 
  pShiptoid ALIAS FOR $5;
55033
 
  pQty ALIAS FOR $6;
55034
 
  pCurrid ALIAS FOR $7;
55035
 
  pEffective ALIAS FOR $8;
55036
 
 
55037
 
BEGIN
55038
 
  RETURN itemCharPrice(pItemid, pCharid, pCharValue, pCustid, pShiptoid, pQty, pCurrid, CURRENT_DATE, CURRENT_DATE);
55039
 
END;
55040
 
$_$;
55041
 
 
55042
 
 
55043
 
ALTER FUNCTION public.itemcharprice(integer, integer, text, integer, integer, numeric, integer, date) OWNER TO admin;
55044
 
 
55045
 
--
55046
 
--
55047
 
 
55048
 
CREATE FUNCTION itemcharprice(integer, integer, text, integer, integer, numeric, integer, date, date) RETURNS numeric
55049
 
    LANGUAGE plpgsql
55050
 
    AS $_$
55051
 
DECLARE
55052
 
  pItemid ALIAS FOR $1;
55053
 
  pCharid ALIAS FOR $2;
55054
 
  pCharValue ALIAS FOR $3;
55055
 
  pCustid ALIAS FOR $4;
55056
 
  pShiptoid ALIAS FOR $5;
55057
 
  pQty ALIAS FOR $6;
55058
 
  pCurrid ALIAS FOR $7;
55059
 
  pEffective ALIAS FOR $8;
55060
 
  pAsOf ALIAS FOR $9;
55061
 
  _price NUMERIC;
55062
 
  _sales NUMERIC;
55063
 
  _item RECORD;
55064
 
  _iteminvpricerat NUMERIC;
55065
 
 
55066
 
BEGIN
55067
 
  IF (pCharValue IS NULL) THEN 
55068
 
    RETURN 0;
55069
 
  END IF;
55070
 
 
55071
 
 
55072
 
  SELECT iteminvpricerat(pItemid)
55073
 
    INTO _iteminvpricerat;
55074
 
 
55075
 
  SELECT currToCurr(ipshead_curr_id, pCurrid,
55076
 
                      ipsprice_price - (ipsprice_price * cust_discntprcnt),
55077
 
                      pEffective) INTO _sales
55078
 
  FROM (
55079
 
  SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id,
55080
 
         itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak,
55081
 
         (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price
55082
 
    FROM ipsiteminfo,ipsitemchar
55083
 
   WHERE((ipsitem_item_id=pItemid)
55084
 
    AND (ipsitemchar_char_id=pCharid)
55085
 
    AND (ipsitemchar_value=pCharValue)
55086
 
    AND (ipsitemchar_ipsitem_id=ipsitem_id))
55087
 
       ) AS
55088
 
        ipsprice, ipshead, sale, custinfo
55089
 
  WHERE ( (ipsprice_ipshead_id=ipshead_id)
55090
 
   AND (sale_ipshead_id=ipshead_id)
55091
 
   AND (pAsOf BETWEEN sale_startdate AND sale_enddate)
55092
 
   AND (ipsprice_qtybreak <= pQty)
55093
 
   AND (cust_id=pCustid) )
55094
 
  ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC
55095
 
  LIMIT 1;
55096
 
 
55097
 
  SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price
55098
 
  FROM (
55099
 
  SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id,
55100
 
         itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak,
55101
 
         (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price
55102
 
    FROM ipsiteminfo,ipsitemchar
55103
 
   WHERE ((ipsitem_item_id=pItemid)
55104
 
    AND (ipsitemchar_char_id=pCharid)
55105
 
    AND (ipsitemchar_value=pCharValue)
55106
 
    AND (ipsitemchar_ipsitem_id=ipsitem_id))
55107
 
       ) AS
55108
 
        ipsprice, ipshead, ipsass
55109
 
  WHERE ( (ipsprice_ipshead_id=ipshead_id)
55110
 
   AND (ipsass_ipshead_id=ipshead_id)
55111
 
   AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
55112
 
   AND (ipsprice_qtybreak <= pQty)
55113
 
   AND (ipsass_shipto_id != -1)
55114
 
   AND (ipsass_shipto_id=pShiptoid) )
55115
 
  ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC
55116
 
  LIMIT 1;
55117
 
 
55118
 
  IF (_price IS NOT NULL) THEN
55119
 
    IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN
55120
 
      RETURN _sales;
55121
 
    END IF;
55122
 
    RETURN _price;
55123
 
  END IF;
55124
 
 
55125
 
  SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price
55126
 
  FROM (
55127
 
  SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id,
55128
 
         itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak,
55129
 
         (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price
55130
 
    FROM ipsiteminfo,ipsitemchar
55131
 
   WHERE ((ipsitem_item_id=pItemid)
55132
 
    AND (ipsitemchar_char_id=pCharid)
55133
 
    AND (ipsitemchar_value=pCharValue)
55134
 
    AND (ipsitemchar_ipsitem_id=ipsitem_id))
55135
 
       ) AS
55136
 
        ipsprice, ipshead, ipsass, shiptoinfo
55137
 
  WHERE ( (ipsprice_ipshead_id=ipshead_id)
55138
 
   AND (ipsass_ipshead_id=ipshead_id)
55139
 
   AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
55140
 
   AND (ipsprice_qtybreak <= pQty)
55141
 
   AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0)
55142
 
   AND (shipto_num ~ ipsass_shipto_pattern)
55143
 
   AND (ipsass_cust_id=pCustid)
55144
 
   AND (shipto_id=pShiptoid) )
55145
 
  ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC
55146
 
  LIMIT 1;
55147
 
 
55148
 
  IF (_price IS NOT NULL) THEN
55149
 
    IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN
55150
 
      RETURN _sales;
55151
 
    END IF;
55152
 
    RETURN _price;
55153
 
  END IF;
55154
 
 
55155
 
  SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price
55156
 
  FROM (
55157
 
  SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id,
55158
 
         itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak,
55159
 
         (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price
55160
 
    FROM ipsiteminfo,ipsitemchar
55161
 
   WHERE ((ipsitem_item_id=pItemid)
55162
 
    AND (ipsitemchar_char_id=pCharid)
55163
 
    AND (ipsitemchar_value=pCharValue)
55164
 
    AND (ipsitemchar_ipsitem_id=ipsitem_id))
55165
 
       ) AS
55166
 
        ipsprice, ipshead, ipsass
55167
 
  WHERE ( (ipsprice_ipshead_id=ipshead_id)
55168
 
   AND (ipsass_ipshead_id=ipshead_id)
55169
 
   AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
55170
 
   AND (ipsprice_qtybreak <= pQty)
55171
 
   AND (COALESCE(length(ipsass_shipto_pattern), 0) = 0)
55172
 
   AND (ipsass_cust_id=pCustid) )
55173
 
  ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC
55174
 
  LIMIT 1;
55175
 
 
55176
 
  IF (_price IS NOT NULL) THEN
55177
 
    IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN
55178
 
      RETURN _sales;
55179
 
    END IF;
55180
 
    RETURN _price;
55181
 
  END IF;
55182
 
 
55183
 
  SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price
55184
 
  FROM (
55185
 
  SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id,
55186
 
         itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak,
55187
 
         (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price
55188
 
    FROM ipsiteminfo,ipsitemchar
55189
 
   WHERE((ipsitem_item_id=pItemid)
55190
 
    AND (ipsitemchar_char_id=pCharid)
55191
 
    AND (ipsitemchar_value=pCharValue)
55192
 
    AND (ipsitemchar_ipsitem_id=ipsitem_id))
55193
 
       ) AS
55194
 
        ipsprice, ipshead, ipsass, custinfo
55195
 
  WHERE ( (ipsprice_ipshead_id=ipshead_id)
55196
 
   AND (ipsass_ipshead_id=ipshead_id)
55197
 
   AND (ipsass_custtype_id=cust_custtype_id)
55198
 
   AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
55199
 
   AND (ipsprice_qtybreak <= pQty)
55200
 
   AND (cust_id=pCustid) )
55201
 
  ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC
55202
 
  LIMIT 1;
55203
 
 
55204
 
  IF (_price IS NOT NULL) THEN
55205
 
    IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN
55206
 
      RETURN _sales;
55207
 
    END IF;
55208
 
    RETURN _price;
55209
 
  END IF;
55210
 
 
55211
 
  SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price
55212
 
  FROM (
55213
 
  SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id,
55214
 
         itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak,
55215
 
         (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price
55216
 
    FROM ipsiteminfo,ipsitemchar
55217
 
   WHERE ((ipsitem_item_id=pItemid)
55218
 
    AND (ipsitemchar_char_id=pCharid)
55219
 
    AND (ipsitemchar_value=pCharValue)
55220
 
    AND (ipsitemchar_ipsitem_id=ipsitem_id))
55221
 
       ) AS
55222
 
        ipsprice, ipshead, ipsass, custtype, custinfo
55223
 
  WHERE ( (ipsprice_ipshead_id=ipshead_id)
55224
 
   AND (ipsass_ipshead_id=ipshead_id)
55225
 
   AND (coalesce(length(ipsass_custtype_pattern), 0) > 0)
55226
 
   AND (custtype_code ~ ipsass_custtype_pattern)
55227
 
   AND (cust_custtype_id=custtype_id)
55228
 
   AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1))
55229
 
   AND (ipsprice_qtybreak <= pQty)
55230
 
   AND (cust_id=pCustid) )
55231
 
  ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC
55232
 
  LIMIT 1;
55233
 
 
55234
 
  IF (_price IS NOT NULL) THEN
55235
 
    IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN
55236
 
      RETURN _sales;
55237
 
    END IF;
55238
 
    RETURN _price;
55239
 
  END IF;
55240
 
 
55241
 
  IF (_sales IS NOT NULL) THEN
55242
 
    RETURN _sales;
55243
 
  END IF;
55244
 
 
55245
 
  SELECT MIN(currToLocal(pCurrid,
55246
 
                       charass_price - (charass_price * COALESCE(cust_discntprcnt, 0)),
55247
 
                       pEffective)) AS price,
55248
 
         item_exclusive INTO _item
55249
 
  FROM charass,item LEFT OUTER JOIN custinfo ON (cust_id=pCustid)
55250
 
  WHERE ((item_id=pItemid)
55251
 
   AND (charass_char_id=pCharid)
55252
 
   AND (charass_value=pCharValue)
55253
 
   AND (charass_target_type='I')
55254
 
   AND (charass_target_id=item_id))
55255
 
  GROUP BY item_exclusive;
55256
 
  IF (FOUND) THEN
55257
 
    IF (NOT _item.item_exclusive) THEN
55258
 
      IF (_item.price < 0) THEN
55259
 
        RETURN 0;
55260
 
      ELSE
55261
 
        RETURN _item.price;
55262
 
      END IF;
55263
 
    ELSE
55264
 
      RETURN 0;
55265
 
    END IF;
55266
 
  ELSE
55267
 
    RETURN 0;
55268
 
  END IF;
55269
 
 
55270
 
END;
55271
 
$_$;
55272
 
 
55273
 
 
55274
 
ALTER FUNCTION public.itemcharprice(integer, integer, text, integer, integer, numeric, integer, date, date) OWNER TO admin;
55275
 
 
55276
 
--
55277
 
--
55278
 
 
55279
 
CREATE FUNCTION itemcharvalue(integer, text) RETURNS text
55280
 
    LANGUAGE plpgsql
55281
 
    AS $_$
55282
 
DECLARE
55283
 
  pItemid ALIAS FOR $1;
55284
 
  pCharName ALIAS FOR $2;
55285
 
  _value TEXT;
55286
 
 
55287
 
BEGIN
55288
 
 
55289
 
  SELECT charass_value INTO _value
55290
 
  FROM charass, char
55291
 
  WHERE ( (charass_char_id=char_id)
55292
 
   AND (charass_target_type='I')
55293
 
   AND (charass_target_id=pItemid)
55294
 
   AND (char_name=pCharName) );
55295
 
  IF (NOT FOUND) THEN
55296
 
    _value = '';
55297
 
  END IF;
55298
 
 
55299
 
  RETURN _value;
55300
 
 
55301
 
END;
55302
 
$_$;
55303
 
 
55304
 
 
55305
 
ALTER FUNCTION public.itemcharvalue(integer, text) OWNER TO admin;
55306
 
 
55307
 
--
55308
 
--
55309
 
 
55310
 
CREATE FUNCTION itemcost(pitemsiteid integer) RETURNS numeric
55311
 
    LANGUAGE plpgsql STABLE
55312
 
    AS $$
55313
 
DECLARE
55314
 
  _cost NUMERIC;
55315
 
BEGIN
55316
 
  SELECT CASE WHEN (itemsite_costmethod='A' AND itemsite_qtyonhand != 0.0) THEN (itemsite_value / itemsite_qtyonhand)
55317
 
              WHEN (itemsite_costmethod='A' AND itemsite_qtyonhand = 0.0) THEN 0.0
55318
 
              WHEN (itemsite_costmethod='N') THEN 0.0
55319
 
              ELSE stdCost(itemsite_item_id)
55320
 
         END INTO _cost
55321
 
    FROM itemsite
55322
 
   WHERE(itemsite_id=pItemsiteid);
55323
 
  RETURN _cost;
55324
 
END;
55325
 
$$;
55326
 
 
55327
 
 
55328
 
ALTER FUNCTION public.itemcost(pitemsiteid integer) OWNER TO admin;
55329
 
 
55330
 
--
55331
 
--
55332
 
 
55333
 
CREATE FUNCTION itemcost(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) RETURNS numeric
55334
 
    LANGUAGE plpgsql STABLE
55335
 
    AS $$
55336
 
--
55337
 
--
55338
 
DECLARE
55339
 
  _r RECORD;
55340
 
  _cost NUMERIC := 0.0;
55341
 
BEGIN
55342
 
  -- cache item info
55343
 
  SELECT *, itemInvPriceRat(item_id) AS itempriceinvrat INTO _r
55344
 
  FROM itemsite, item
55345
 
  WHERE (itemsite_item_id=pItemid)
55346
 
    AND (itemsite_warehous_id=pSiteid)
55347
 
    AND (item_id=pItemid);
55348
 
 
55349
 
  IF (_r.item_type = 'K') THEN
55350
 
    SELECT SUM(roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id),
55351
 
                                               (bomitem_qtyfxd + bomitem_qtyper) * (1 + bomitem_scrap))
55352
 
               * stdCost(bomitem_item_id)) INTO _cost
55353
 
    FROM bomitem
55354
 
    WHERE (bomitem_parent_item_id=_r.item_id)
55355
 
      AND (bomitem_rev_id=getActiveRevid('BOM', _r.item_id))
55356
 
      AND (pEffective BETWEEN bomitem_effective AND (bomitem_expires - 1));
55357
 
  ELSEIF (fetchMetricBool('WholesalePriceCosting')) THEN
55358
 
    _cost := _r.item_listcost / _r.itempriceinvrat;
55359
 
  ELSE
55360
 
    SELECT itemcost(_r.itemsite_id) INTO _cost;
55361
 
  END IF;
55362
 
 
55363
 
  RETURN _cost;
55364
 
END;
55365
 
$$;
55366
 
 
55367
 
 
55368
 
ALTER FUNCTION public.itemcost(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) OWNER TO admin;
55369
 
 
55370
 
--
55371
 
--
55372
 
 
55373
 
CREATE FUNCTION iteminventoryuominuse(pitemid integer) RETURNS boolean
55374
 
    LANGUAGE plpgsql
55375
 
    AS $$
55376
 
DECLARE
55377
 
  _uomid INTEGER;
55378
 
  _result INTEGER;
55379
 
BEGIN
55380
 
  SELECT item_inv_uom_id INTO _uomid
55381
 
    FROM item
55382
 
   WHERE(item_id=pItemid);
55383
 
 
55384
 
  SELECT itemuomconv_id INTO _result
55385
 
    FROM itemuomconv
55386
 
   WHERE(itemuomconv_item_id=pItemid)
55387
 
   LIMIT 1;
55388
 
  IF (FOUND) THEN
55389
 
    RETURN TRUE;
55390
 
  END IF;
55391
 
 
55392
 
  SELECT itemsite_id INTO _result
55393
 
  FROM itemsite WHERE ( (itemsite_item_id=pItemid)
55394
 
                  AND   (itemsite_qtyonhand <> 0) )
55395
 
  LIMIT 1;
55396
 
  IF (FOUND) THEN
55397
 
    RETURN TRUE;
55398
 
  END IF;
55399
 
 
55400
 
  RETURN FALSE;
55401
 
END;
55402
 
$$;
55403
 
 
55404
 
 
55405
 
ALTER FUNCTION public.iteminventoryuominuse(pitemid integer) OWNER TO admin;
55406
 
 
55407
 
--
55408
 
--
55409
 
 
55410
 
CREATE FUNCTION iteminvpricerat(integer) RETURNS numeric
55411
 
    LANGUAGE plpgsql STABLE
55412
 
    AS $_$
55413
 
DECLARE
55414
 
  pItemid ALIAS FOR $1;
55415
 
  _fromUomid INTEGER;
55416
 
  _toUomid INTEGER;
55417
 
  _ratio NUMERIC;
55418
 
BEGIN
55419
 
 
55420
 
  IF(pItemid IS NULL) THEN
55421
 
    RETURN 1.0;
55422
 
  END IF;
55423
 
 
55424
 
  SELECT item_inv_uom_id, item_price_uom_id
55425
 
    INTO _fromUomid, _toUomid
55426
 
    FROM item
55427
 
   WHERE(item_id=pItemid);
55428
 
 
55429
 
  IF(NOT FOUND) THEN
55430
 
    RAISE EXCEPTION 'No item record found for item_id %', pItemid;
55431
 
  END IF;
55432
 
 
55433
 
  IF(_fromUomid = _toUomid) THEN
55434
 
    RETURN 1.0;
55435
 
  END IF;
55436
 
 
55437
 
  -- Return the ration as inventory / price
55438
 
  SELECT CASE WHEN(itemuomconv_from_uom_id=_fromUomid) THEN itemuomconv_from_value / itemuomconv_to_value
55439
 
              ELSE itemuomconv_to_value / itemuomconv_from_value
55440
 
         END
55441
 
    INTO _ratio
55442
 
    FROM itemuomconv
55443
 
   WHERE((((itemuomconv_from_uom_id=_fromUomid) AND (itemuomconv_to_uom_id=_toUomid))
55444
 
       OR ((itemuomconv_from_uom_id=_toUomid) AND (itemuomconv_to_uom_id=_fromUomid)))
55445
 
     AND (itemuomconv_item_id=pItemid));
55446
 
 
55447
 
  IF(NOT FOUND) THEN
55448
 
    RAISE EXCEPTION 'No itemuomconv record found for item_id % to item_price_uomid %', pItemid, _toUomid;
55449
 
  END IF;
55450
 
  
55451
 
  RETURN _ratio;
55452
 
END;
55453
 
$_$;
55454
 
 
55455
 
 
55456
 
ALTER FUNCTION public.iteminvpricerat(integer) OWNER TO admin;
55457
 
 
55458
 
--
55459
 
--
55460
 
 
55461
 
CREATE FUNCTION itemipsprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) RETURNS SETOF itemprice
55462
 
    LANGUAGE plpgsql
55463
 
    AS $$
55464
 
DECLARE
55465
 
  _row  itemprice%ROWTYPE;
55466
 
  _sale RECORD;
55467
 
  _ips RECORD;
55468
 
  _item RECORD;
55469
 
  _cust RECORD;
55470
 
  _shipto RECORD;
55471
 
  _itempricepricerat NUMERIC := 1.0;
55472
 
  _listprice NUMERIC := 0.0;
55473
 
  _qty NUMERIC;
55474
 
  _asof DATE;
55475
 
  _wholesalepricecosting BOOLEAN := false;
55476
 
  _long30markups BOOLEAN := false;
55477
 
  _itempricingprecedence BOOLEAN := false;
55478
 
 
55479
 
BEGIN
55480
 
  _wholesalepricecosting := fetchMetricBool('WholesalePriceCosting');
55481
 
  _long30markups := fetchMetricBool('Long30Markups');
55482
 
  _itempricingprecedence := fetchMetricBool('ItemPricingPrecedence');
55483
 
 
55484
 
  _qty := itemuomtouom(pItemid, pQtyUOM, NULL, pQty);
55485
 
 
55486
 
  _asof := COALESCE(pAsOf, CURRENT_DATE);
55487
 
 
55488
 
  SELECT item.*, (itemCost(itemsite_id) / itemuomtouomratio(item_id, item_inv_uom_id, item_price_uom_id)) AS invcost INTO _item
55489
 
  FROM item LEFT OUTER JOIN itemsite ON (itemsite_item_id=item_id AND itemsite_warehous_id=pSiteid)
55490
 
  WHERE (item_id=pItemid);
55491
 
 
55492
 
  SELECT * INTO _cust
55493
 
  FROM custinfo JOIN custtype ON (custtype_id=cust_custtype_id)
55494
 
  WHERE (cust_id=pCustid);
55495
 
 
55496
 
  SELECT * INTO _shipto
55497
 
  FROM shiptoinfo
55498
 
  WHERE (shipto_id=pShiptoid);
55499
 
 
55500
 
  SELECT itemuomtouomratio(pItemid, pPriceUOM, _item.item_price_uom_id) AS ratio
55501
 
    INTO _itempricepricerat;
55502
 
 
55503
 
  SELECT INTO _sale
55504
 
    currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) AS rightprice, ipsitem_type AS righttype
55505
 
  FROM (
55506
 
  SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, ipsitem_type,
55507
 
         CASE WHEN (ipsitem_type = 'N') THEN
55508
 
               (ipsitem_price * itemuomtouomratio(_item.item_id, pPriceUOM, ipsitem_price_uom_id))
55509
 
              WHEN (ipsitem_type = 'D') THEN
55510
 
               noNeg(_item.item_listprice - (_item.item_listprice * ipsitem_discntprcnt) - ipsitem_fixedamtdiscount) * _itempricepricerat
55511
 
              WHEN ((ipsitem_type = 'M') AND _long30markups AND _wholesalepricecosting) THEN
55512
 
               (_item.item_listcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat
55513
 
              WHEN ((ipsitem_type = 'M') AND _long30markups) THEN
55514
 
               (_item.invcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat
55515
 
              WHEN (ipsitem_type = 'M' AND _wholesalepricecosting) THEN
55516
 
               (_item.item_listcost + (_item.item_listcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat
55517
 
              WHEN (ipsitem_type = 'M') THEN
55518
 
               (_item.invcost + (_item.invcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat
55519
 
              ELSE 0.00
55520
 
         END AS ipsprice_price,
55521
 
         CASE WHEN (ipsitem_item_id=_item.item_id) THEN itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak)
55522
 
              ELSE ipsitem_qtybreak
55523
 
         END AS ipsprice_qtybreak,
55524
 
         (COALESCE(ipsitem_price_uom_id, -1)=COALESCE(pPriceUOM,-1)) AS uommatched,
55525
 
         CASE WHEN (_itempricingprecedence) THEN (COALESCE(ipsitem_item_id, -1)=_item.item_id)
55526
 
              ELSE true END AS itemmatched
55527
 
    FROM ipsiteminfo
55528
 
   WHERE(ipsitem_item_id=_item.item_id) OR (ipsitem_prodcat_id=_item.item_prodcat_id) ) AS
55529
 
        ipsprice, ipshead, ipsass, sale
55530
 
  WHERE ( (ipsprice_ipshead_id=ipshead_id)
55531
 
    AND   (sale_ipshead_id=ipsprice_ipshead_id)
55532
 
    AND   (_asof BETWEEN sale_startdate AND sale_enddate)
55533
 
    AND   (ipsprice_qtybreak <= _qty)
55534
 
    AND   (ipsass_ipshead_id=ipshead_id)
55535
 
    AND ( (ipsass_shipto_id=_shipto.shipto_id)
55536
 
     OR   ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (_shipto.shipto_num ~ ipsass_shipto_pattern))
55537
 
     OR   (ipsass_cust_id=_cust.cust_id)
55538
 
     OR   (ipsass_custtype_id=_cust.cust_custtype_id)
55539
 
     OR   ((COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND (_cust.custtype_code ~ ipsass_custtype_pattern)) )
55540
 
        )
55541
 
  ORDER BY itemmatched DESC, uommatched DESC, ipsprice_qtybreak DESC, ipsprice_price ASC
55542
 
  LIMIT 1;
55543
 
 
55544
 
 
55545
 
  SELECT INTO _ips
55546
 
    currToCurr(ipshead_curr_id, pCurrid, protoprice, pEffective) AS rightprice, ipsitem_type AS righttype
55547
 
  
55548
 
  FROM (
55549
 
    SELECT *,
55550
 
           CASE WHEN (COALESCE(ipsass_shipto_id, -1) > 0) THEN 1
55551
 
             WHEN (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) THEN 2
55552
 
             WHEN (COALESCE(ipsass_cust_id, -1) > 0) THEN 3
55553
 
             WHEN (COALESCE(ipsass_custtype_id, -1) > 0) THEN 4
55554
 
             WHEN (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) THEN 5
55555
 
             ELSE 99
55556
 
           END AS assignseq,
55557
 
           CASE WHEN (ipsitem_type = 'N') THEN
55558
 
                 (ipsitem_price * itemuomtouomratio(_item.item_id, pPriceUOM, ipsitem_price_uom_id))
55559
 
                WHEN (ipsitem_type = 'D') THEN
55560
 
                 noNeg(_item.item_listprice - (_item.item_listprice * ipsitem_discntprcnt) - ipsitem_fixedamtdiscount) * _itempricepricerat
55561
 
                WHEN ((ipsitem_type = 'M') AND _long30markups AND _wholesalepricecosting) THEN
55562
 
                 (_item.item_listcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat
55563
 
                WHEN ((ipsitem_type = 'M') AND _long30markups) THEN
55564
 
                 (_item.invcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat
55565
 
                WHEN (ipsitem_type = 'M' AND _wholesalepricecosting) THEN
55566
 
                 (_item.item_listcost + (_item.item_listcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat
55567
 
                WHEN (ipsitem_type = 'M') THEN
55568
 
                 (_item.invcost + (_item.invcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat
55569
 
                ELSE 0.00
55570
 
           END AS protoprice,
55571
 
           CASE WHEN (ipsitem_item_id=_item.item_id) THEN itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak)
55572
 
                ELSE ipsitem_qtybreak
55573
 
           END AS protoqtybreak,
55574
 
           (COALESCE(ipsitem_price_uom_id, -1)=COALESCE(pPriceUOM,-1)) AS uommatched,
55575
 
           CASE WHEN (_itempricingprecedence) THEN (COALESCE(ipsitem_item_id, -1)=_item.item_id)
55576
 
                ELSE true END AS itemmatched
55577
 
    FROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)
55578
 
                JOIN ipsiteminfo ON (ipsitem_ipshead_id=ipshead_id)
55579
 
    WHERE ((ipsitem_item_id=_item.item_id) OR (ipsitem_prodcat_id=_item.item_prodcat_id))
55580
 
      AND (_asof BETWEEN ipshead_effective AND ipshead_expires)
55581
 
      AND ((ipsitem_warehous_id=pSiteid) OR (ipsitem_warehous_id IS NULL))
55582
 
      AND ( (ipsass_shipto_id=_shipto.shipto_id)
55583
 
       OR   ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (_shipto.shipto_num ~ ipsass_shipto_pattern))
55584
 
       OR   (ipsass_cust_id=_cust.cust_id)
55585
 
       OR   (ipsass_custtype_id=_cust.cust_custtype_id)
55586
 
       OR   ((COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND (_cust.custtype_code ~ ipsass_custtype_pattern))
55587
 
          )
55588
 
  ) AS proto
55589
 
  WHERE (protoqtybreak <= pQty)
55590
 
  ORDER BY assignseq, itemmatched DESC, protoqtybreak DESC, rightprice
55591
 
  LIMIT 1;
55592
 
 
55593
 
  IF (_ips.rightprice IS NOT NULL) THEN
55594
 
    IF ((_sale.rightprice IS NOT NULL) AND (_sale.rightprice < _ips.rightprice)) THEN
55595
 
      RAISE DEBUG 'itemprice, item=%, cust=%, shipto=%, sale price= %', pItemid, pCustid, pShiptoid, _sale.rightprice;
55596
 
      _row.itemprice_price := _sale.rightprice;
55597
 
      _row.itemprice_type := _sale.righttype;
55598
 
      RETURN NEXT _row;
55599
 
    END IF;
55600
 
    RAISE DEBUG 'itemprice, item=%, cust=%, shipto=%, schedule price= %', pItemid, pCustid, pShiptoid, _ips.rightprice;
55601
 
    _row.itemprice_price := _ips.rightprice;
55602
 
    _row.itemprice_type := _ips.righttype;
55603
 
    RETURN NEXT _row;
55604
 
  END IF;
55605
 
 
55606
 
  IF (_item.item_exclusive) THEN
55607
 
    RAISE DEBUG 'itemprice, item=%, cust=%, shipto=%, item exclusive, price=-9999', pItemid, pCustid, pShiptoid;
55608
 
    _row.itemprice_price := -9999.0;
55609
 
    _row.itemprice_type := '';
55610
 
    RETURN NEXT _row;
55611
 
  END IF;
55612
 
 
55613
 
  _listprice := noNeg(currToLocal(pCurrid, _item.item_listprice - (_item.item_listprice * COALESCE(_cust.cust_discntprcnt, 0.0)), pEffective)
55614
 
                      * itemuomtouomratio(pItemid, pPriceUOM, _item.item_price_uom_id));
55615
 
 
55616
 
  RAISE DEBUG 'itemprice, item=%, cust=%, shipto=%, list price= %', pItemid, pCustid, pShiptoid, _listprice;
55617
 
 
55618
 
  _row.itemprice_price := _listprice;
55619
 
  _row.itemprice_type := 'P';
55620
 
  RETURN NEXT _row;
55621
 
 
55622
 
  RETURN;
55623
 
 
55624
 
END;
55625
 
$$;
55626
 
 
55627
 
 
55628
 
ALTER FUNCTION public.itemipsprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) OWNER TO admin;
55629
 
 
55630
 
--
55631
 
--
55632
 
 
55633
 
CREATE FUNCTION itemlocdistqty(integer, integer) RETURNS numeric
55634
 
    LANGUAGE plpgsql
55635
 
    AS $_$
55636
 
DECLARE
55637
 
  pLocationid ALIAS FOR $1;
55638
 
  pParentid ALIAS FOR $2;
55639
 
  _qty NUMERIC;
55640
 
  _tempQty NUMERIC;
55641
 
 
55642
 
BEGIN
55643
 
 
55644
 
  SELECT COALESCE(SUM(itemlocdist_qty), 0) INTO _qty
55645
 
  FROM itemlocdist
55646
 
  WHERE ( (itemlocdist_source_type='L')
55647
 
   AND (itemlocdist_source_id=pLocationid)
55648
 
   AND (itemlocdist_itemlocdist_id=pParentid) );
55649
 
 
55650
 
  SELECT COALESCE(SUM(itemlocdist_qty), 0) INTO _tempQty
55651
 
  FROM itemlocdist, itemloc
55652
 
  WHERE ( (itemlocdist_source_type='I')
55653
 
   AND (itemlocdist_source_id=itemloc_id)
55654
 
   AND (itemloc_location_id=pLocationid)
55655
 
   AND (itemlocdist_itemlocdist_id=pParentid) );
55656
 
 
55657
 
  _qty := (_qty + _tempQty);
55658
 
 
55659
 
  RETURN _qty;
55660
 
 
55661
 
END;
55662
 
$_$;
55663
 
 
55664
 
 
55665
 
ALTER FUNCTION public.itemlocdistqty(integer, integer) OWNER TO admin;
55666
 
 
55667
 
--
55668
 
--
55669
 
 
55670
 
CREATE FUNCTION itemlocdistqty(text, integer, integer) RETURNS numeric
55671
 
    LANGUAGE plpgsql
55672
 
    AS $_$
55673
 
DECLARE
55674
 
  pTypes ALIAS FOR $1;
55675
 
  pLocationid ALIAS FOR $2;
55676
 
  pParentid ALIAS FOR $3;
55677
 
  _qty NUMERIC := 0;
55678
 
  _tempQty NUMERIC;
55679
 
 
55680
 
BEGIN
55681
 
 
55682
 
  IF (strpos(pTypes, 'L') > 0) THEN
55683
 
    SELECT COALESCE(SUM(itemlocdist_qty), 0) INTO _tempQty
55684
 
    FROM itemlocdist
55685
 
    WHERE ( (itemlocdist_source_type='L')
55686
 
     AND (itemlocdist_source_id=pLocationid)
55687
 
     AND (itemlocdist_itemlocdist_id=pParentid) );
55688
 
 
55689
 
    _qty := (_qty + _tempQty);
55690
 
  END IF;
55691
 
 
55692
 
  IF (strpos(pTypes, 'I') > 0) THEN
55693
 
    SELECT COALESCE(SUM(itemlocdist_qty), 0) INTO _tempQty
55694
 
    FROM itemlocdist, itemloc
55695
 
    WHERE ( (itemlocdist_source_type='I')
55696
 
     AND (itemlocdist_source_id=itemloc_id)
55697
 
     AND (itemloc_location_id=pLocationid)
55698
 
     AND (itemlocdist_itemlocdist_id=pParentid) );
55699
 
 
55700
 
    _qty := (_qty + _tempQty);
55701
 
  END IF;
55702
 
 
55703
 
  RETURN _qty;
55704
 
 
55705
 
END;
55706
 
$_$;
55707
 
 
55708
 
 
55709
 
ALTER FUNCTION public.itemlocdistqty(text, integer, integer) OWNER TO admin;
55710
 
 
55711
 
--
55712
 
--
55713
 
 
55714
 
CREATE FUNCTION itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pcurrid integer, peffective date) RETURNS numeric
55715
 
    LANGUAGE plpgsql
55716
 
    AS $$
55717
 
DECLARE
55718
 
  _item RECORD;
55719
 
 
55720
 
BEGIN
55721
 
  SELECT item_inv_uom_id, item_price_uom_id
55722
 
    INTO _item
55723
 
    FROM item
55724
 
   WHERE(item_id=pItemid);
55725
 
  IF (FOUND) THEN
55726
 
    RETURN itemPrice(pItemid, pCustid, pShiptoid, pQty, _item.item_inv_uom_id, _item.item_price_uom_id, pCurrid, pEffective);
55727
 
  END IF;
55728
 
  RETURN -9999;
55729
 
END;
55730
 
$$;
55731
 
 
55732
 
 
55733
 
ALTER FUNCTION public.itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pcurrid integer, peffective date) OWNER TO admin;
55734
 
 
55735
 
--
55736
 
--
55737
 
 
55738
 
CREATE FUNCTION itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date) RETURNS numeric
55739
 
    LANGUAGE plpgsql
55740
 
    AS $$
55741
 
DECLARE
55742
 
 
55743
 
BEGIN
55744
 
  RETURN itemPrice(pItemid, pCustid, pShiptoid, pQty, pQtyUOM, pPriceUOM, pCurrid, pEffective, CURRENT_DATE);
55745
 
END;
55746
 
$$;
55747
 
 
55748
 
 
55749
 
ALTER FUNCTION public.itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date) OWNER TO admin;
55750
 
 
55751
 
--
55752
 
--
55753
 
 
55754
 
CREATE FUNCTION itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date) RETURNS numeric
55755
 
    LANGUAGE plpgsql
55756
 
    AS $$
55757
 
DECLARE
55758
 
 
55759
 
BEGIN
55760
 
  RETURN itemPrice(pItemid, pCustid, pShiptoid, pQty, pQtyUOM, pPriceUOM, pCurrid, pEffective, pAsOf, NULL);
55761
 
END;
55762
 
$$;
55763
 
 
55764
 
 
55765
 
ALTER FUNCTION public.itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date) OWNER TO admin;
55766
 
 
55767
 
--
55768
 
--
55769
 
 
55770
 
CREATE FUNCTION itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) RETURNS numeric
55771
 
    LANGUAGE plpgsql
55772
 
    AS $$
55773
 
DECLARE
55774
 
  _r RECORD;
55775
 
 
55776
 
BEGIN
55777
 
  SELECT * FROM itemIpsPrice(pItemid, pCustid, pShiptoid, pQty, pQtyUOM, pPriceUOM,
55778
 
                             pCurrid, pEffective, pAsOf, pSiteid) INTO _r;
55779
 
  RETURN _r.itemprice_price;
55780
 
END;
55781
 
$$;
55782
 
 
55783
 
 
55784
 
ALTER FUNCTION public.itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) OWNER TO admin;
55785
 
 
55786
 
--
55787
 
--
55788
 
 
55789
 
CREATE FUNCTION itemsellinguom(integer) RETURNS text
55790
 
    LANGUAGE plpgsql
55791
 
    AS $_$
55792
 
DECLARE
55793
 
  pItemid ALIAS FOR $1;
55794
 
 
55795
 
BEGIN
55796
 
  RETURN itemUOMByType(pItemid, 'Selling');
55797
 
END;
55798
 
$_$;
55799
 
 
55800
 
 
55801
 
ALTER FUNCTION public.itemsellinguom(integer) OWNER TO admin;
55802
 
 
55803
 
--
55804
 
--
55805
 
 
55806
 
CREATE FUNCTION itemsrcprice(pitemsrcid integer, pqty numeric, pcurrid integer, peffective date) RETURNS numeric
55807
 
    LANGUAGE plpgsql
55808
 
    AS $$
55809
 
DECLARE
55810
 
  _price NUMERIC := 0.0;
55811
 
 
55812
 
BEGIN
55813
 
 
55814
 
  SELECT itemsrcPrice(pItemsrcid, -1, FALSE, pQty, pCurrid, pEffective) INTO _price;
55815
 
 
55816
 
  RETURN _price;
55817
 
 
55818
 
END;
55819
 
$$;
55820
 
 
55821
 
 
55822
 
ALTER FUNCTION public.itemsrcprice(pitemsrcid integer, pqty numeric, pcurrid integer, peffective date) OWNER TO admin;
55823
 
 
55824
 
--
55825
 
--
55826
 
 
55827
 
CREATE FUNCTION itemsrcprice(pitemsrcid integer, psiteid integer, pdropship boolean, pqty numeric, pcurrid integer, peffective date) RETURNS numeric
55828
 
    LANGUAGE plpgsql
55829
 
    AS $$
55830
 
DECLARE
55831
 
  _price NUMERIC := 0.0;
55832
 
  _r RECORD;
55833
 
  _effective DATE;
55834
 
 
55835
 
BEGIN
55836
 
  _effective := COALESCE(pEffective, CURRENT_DATE);
55837
 
 
55838
 
  SELECT *
55839
 
  INTO _r
55840
 
  FROM itemsrc JOIN item ON (item_id=itemsrc_item_id)
55841
 
  WHERE (itemsrc_id=pItemsrcid);
55842
 
  IF (NOT FOUND) THEN
55843
 
    RAISE EXCEPTION 'itemsrc % not found.', pItemsrcid;
55844
 
  END IF;
55845
 
 
55846
 
  SELECT currToCurr(itemsrcp_curr_id, pCurrid, price, _effective) INTO _price
55847
 
  FROM (
55848
 
    SELECT *,
55849
 
           CASE WHEN (itemsrcp_dropship) THEN 0
55850
 
                ELSE 1
55851
 
           END AS seq,
55852
 
           CASE itemsrcp_type WHEN ('N') THEN itemsrcp_price
55853
 
                              WHEN ('D') THEN (_r.item_listcost - (_r.item_listcost * itemsrcp_discntprcnt) - itemsrcp_fixedamtdiscount)
55854
 
                              ELSE 0.0
55855
 
           END AS price
55856
 
    FROM itemsrcp
55857
 
    WHERE ( (itemsrcp_itemsrc_id=_r.itemsrc_id)
55858
 
      AND   ((itemsrcp_warehous_id=pSiteid) OR (itemsrcp_warehous_id=-1))
55859
 
      AND   ((itemsrcp_dropship=pDropship) OR (NOT itemsrcp_dropship))
55860
 
      AND   (itemsrcp_qtybreak <= pQty) )
55861
 
    ORDER BY seq, itemsrcp_qtybreak DESC
55862
 
    LIMIT 1
55863
 
       ) AS data
55864
 
  ;
55865
 
 
55866
 
  RETURN _price;
55867
 
 
55868
 
END;
55869
 
$$;
55870
 
 
55871
 
 
55872
 
ALTER FUNCTION public.itemsrcprice(pitemsrcid integer, psiteid integer, pdropship boolean, pqty numeric, pcurrid integer, peffective date) OWNER TO admin;
55873
 
 
55874
 
--
55875
 
--
55876
 
 
55877
 
CREATE FUNCTION itemuombytype(integer, text) RETURNS text
55878
 
    LANGUAGE plpgsql STABLE
55879
 
    AS $_$
55880
 
DECLARE
55881
 
  pItemid ALIAS FOR $1;
55882
 
  pUomtype ALIAS FOR $2;
55883
 
  _uom TEXT;
55884
 
BEGIN
55885
 
  SELECT uom_name INTO _uom FROM (
55886
 
  SELECT uom_name
55887
 
    FROM item
55888
 
    JOIN itemuomconv ON (itemuomconv_item_id=item_id)
55889
 
    JOIN itemuom ON (itemuom_itemuomconv_id=itemuomconv_id)
55890
 
    JOIN uomtype ON (itemuom_uomtype_id=uomtype_id)
55891
 
    JOIN uom ON (itemuomconv_to_uom_id=uom_id)
55892
 
   WHERE((item_id=pItemid)
55893
 
     AND (uomtype_name=pUomtype)
55894
 
     AND (item_inv_uom_id != itemuomconv_to_uom_id))
55895
 
  UNION
55896
 
  SELECT uom_name
55897
 
    FROM item
55898
 
    JOIN itemuomconv ON (itemuomconv_item_id=item_id)
55899
 
    JOIN itemuom ON (itemuom_itemuomconv_id=itemuomconv_id)
55900
 
    JOIN uomtype ON (itemuom_uomtype_id=uomtype_id)
55901
 
    JOIN uom ON (itemuomconv_from_uom_id=uom_id)
55902
 
   WHERE((item_id=pItemid)
55903
 
     AND (uomtype_name=pUomtype)
55904
 
     AND (item_inv_uom_id != itemuomconv_from_uom_id))) data
55905
 
   LIMIT 1;
55906
 
 
55907
 
  IF (NOT FOUND) THEN
55908
 
    SELECT uom_name
55909
 
      INTO _uom
55910
 
      FROM item
55911
 
      JOIN uom ON (item_inv_uom_id=uom_id)
55912
 
     WHERE(item_id=pItemid);
55913
 
  END IF;
55914
 
 
55915
 
  RETURN _uom;
55916
 
END;
55917
 
$_$;
55918
 
 
55919
 
 
55920
 
ALTER FUNCTION public.itemuombytype(integer, text) OWNER TO admin;
55921
 
 
55922
 
--
55923
 
--
55924
 
 
55925
 
CREATE FUNCTION itemuomfractionalbytype(integer, text) RETURNS boolean
55926
 
    LANGUAGE plpgsql
55927
 
    AS $_$
55928
 
DECLARE
55929
 
  pItemid ALIAS FOR $1;
55930
 
  pUomtype ALIAS FOR $2;
55931
 
  _frac BOOLEAN;
55932
 
BEGIN
55933
 
  SELECT itemuomconv_fractional
55934
 
    INTO _frac
55935
 
    FROM item
55936
 
    JOIN itemuomconv ON (itemuomconv_item_id=item_id)
55937
 
    JOIN itemuom ON (itemuom_itemuomconv_id=itemuomconv_id)
55938
 
    JOIN uomtype ON (itemuom_uomtype_id=uomtype_id)
55939
 
   WHERE((item_id=pItemid)
55940
 
     AND (uomtype_name=pUomtype))
55941
 
   LIMIT 1;
55942
 
 
55943
 
  IF (NOT FOUND) THEN
55944
 
    SELECT item_fractional
55945
 
      INTO _frac
55946
 
      FROM item
55947
 
      JOIN uom ON (item_inv_uom_id=uom_id)
55948
 
     WHERE(item_id=pItemid);
55949
 
  END IF;
55950
 
 
55951
 
  RETURN _frac;
55952
 
END;
55953
 
$_$;
55954
 
 
55955
 
 
55956
 
ALTER FUNCTION public.itemuomfractionalbytype(integer, text) OWNER TO admin;
55957
 
 
55958
 
--
55959
 
--
55960
 
 
55961
 
CREATE FUNCTION itemuomfractionalbyuom(integer, integer) RETURNS boolean
55962
 
    LANGUAGE plpgsql
55963
 
    AS $_$
55964
 
DECLARE
55965
 
  pItemid ALIAS FOR $1;
55966
 
  pUomid ALIAS FOR $2;
55967
 
  _frac BOOLEAN;
55968
 
BEGIN
55969
 
  SELECT itemuomconv_fractional
55970
 
    INTO _frac
55971
 
    FROM item
55972
 
    JOIN itemuomconv ON (itemuomconv_item_id=item_id)
55973
 
   WHERE((item_id=pItemid)
55974
 
     AND ((itemuomconv_from_uom_id=item_inv_uom_id AND itemuomconv_to_uom_id=pUomid)
55975
 
       OR (itemuomconv_to_uom_id=item_inv_uom_id AND itemuomconv_from_uom_id=pUomid)))
55976
 
   LIMIT 1;
55977
 
 
55978
 
  IF (NOT FOUND) THEN
55979
 
    SELECT item_fractional
55980
 
      INTO _frac
55981
 
      FROM item
55982
 
      JOIN uom ON (item_inv_uom_id=uom_id)
55983
 
     WHERE(item_id=pItemid);
55984
 
  END IF;
55985
 
 
55986
 
  RETURN _frac;
55987
 
END;
55988
 
$_$;
55989
 
 
55990
 
 
55991
 
ALTER FUNCTION public.itemuomfractionalbyuom(integer, integer) OWNER TO admin;
55992
 
 
55993
 
--
55994
 
--
55995
 
 
55996
 
CREATE FUNCTION itemuomratiobytype(integer, text) RETURNS numeric
55997
 
    LANGUAGE plpgsql STABLE
55998
 
    AS $_$
55999
 
DECLARE
56000
 
  pItemid ALIAS FOR $1;
56001
 
  pUomtype ALIAS FOR $2;
56002
 
  _ratio NUMERIC;
56003
 
BEGIN
56004
 
  -- Return the ration as alternate / inventory uom
56005
 
  SELECT CASE WHEN(itemuomconv_from_uom_id=item_inv_uom_id) THEN itemuomconv_to_value / itemuomconv_from_value
56006
 
              ELSE itemuomconv_from_value / itemuomconv_to_value
56007
 
         END
56008
 
    INTO _ratio
56009
 
    FROM item
56010
 
    JOIN itemuomconv ON (itemuomconv_item_id=item_id)
56011
 
    JOIN itemuom ON (itemuom_itemuomconv_id=itemuomconv_id)
56012
 
    JOIN uomtype ON (itemuom_uomtype_id=uomtype_id)
56013
 
   WHERE((item_id=pItemid)
56014
 
     AND (uomtype_name=pUomtype))
56015
 
   LIMIT 1;
56016
 
 
56017
 
  IF (NOT FOUND) THEN
56018
 
    _ratio := 1.0;
56019
 
  END IF;
56020
 
 
56021
 
  RETURN _ratio;
56022
 
END;
56023
 
$_$;
56024
 
 
56025
 
 
56026
 
ALTER FUNCTION public.itemuomratiobytype(integer, text) OWNER TO admin;
56027
 
 
56028
 
--
56029
 
--
56030
 
 
56031
 
CREATE FUNCTION itemuomtouom(integer, integer, integer, numeric) RETURNS numeric
56032
 
    LANGUAGE plpgsql STABLE
56033
 
    AS $_$
56034
 
BEGIN
56035
 
  RETURN itemuomtouom($1, $2, $3, $4, 'qty');
56036
 
END;
56037
 
$_$;
56038
 
 
56039
 
 
56040
 
ALTER FUNCTION public.itemuomtouom(integer, integer, integer, numeric) OWNER TO admin;
56041
 
 
56042
 
--
56043
 
--
56044
 
 
56045
 
CREATE FUNCTION itemuomtouom(pitemid integer, puomidfrom integer, puomidto integer, pqtyfrom numeric, plocale text) RETURNS numeric
56046
 
    LANGUAGE plpgsql STABLE
56047
 
    AS $$
56048
 
DECLARE
56049
 
  _uomidFrom INTEGER;
56050
 
  _uomidTo   INTEGER;
56051
 
  _uomidInv  INTEGER;
56052
 
  _valueFrom NUMERIC := 0.0;
56053
 
  _valueTo   NUMERIC := 0.0;
56054
 
  _value     NUMERIC := 0.0;
56055
 
  _item      RECORD;
56056
 
  _conv      RECORD;
56057
 
  _frac      BOOLEAN := FALSE;
56058
 
BEGIN
56059
 
 
56060
 
  SELECT item_inv_uom_id, item_fractional
56061
 
    INTO _item
56062
 
    FROM item
56063
 
   WHERE(item_id=pItemid);
56064
 
  IF(NOT FOUND) THEN
56065
 
    RAISE EXCEPTION 'No item record was found for item id %', pItemid;
56066
 
  END IF;
56067
 
 
56068
 
  _uomidFrom := COALESCE(pUomidFrom, _item.item_inv_uom_id);
56069
 
  _uomidTo   := COALESCE(pUomidTo,   _item.item_inv_uom_id);
56070
 
  _uomidInv  := _item.item_inv_uom_id;
56071
 
 
56072
 
  -- Should we round the qty here or not?
56073
 
  IF(_uomidFrom = _uomidTo) THEN
56074
 
    -- Both from/to are the same. If it is the item inv uom
56075
 
    -- then use the item fractional value otherwise assume
56076
 
    -- it is fractional for now so the user gets the same value back.
56077
 
    IF(_uomidFrom = _item.item_inv_uom_id) THEN
56078
 
      _frac := _item.item_fractional;
56079
 
    ELSE
56080
 
      _frac := true;
56081
 
    END IF;
56082
 
    RETURN roundLocale(_frac, pQtyFrom, pLocale);
56083
 
  END IF;
56084
 
 
56085
 
  -- Try a direct conversion
56086
 
  SELECT itemuomconv_from_uom_id, itemuomconv_from_value,
56087
 
         itemuomconv_to_uom_id, itemuomconv_to_value,
56088
 
         itemuomconv_fractional
56089
 
    INTO _conv
56090
 
    FROM itemuomconv
56091
 
   WHERE(((itemuomconv_from_uom_id=_uomidFrom AND itemuomconv_to_uom_id=_uomidTo)
56092
 
       OR (itemuomconv_from_uom_id=_uomidTo AND itemuomconv_to_uom_id=_uomidFrom))
56093
 
     AND (itemuomconv_item_id=pItemid));
56094
 
  IF(FOUND) THEN
56095
 
    IF(_conv.itemuomconv_from_uom_id=_uomidFrom) THEN
56096
 
      _valueFrom := _conv.itemuomconv_from_value;
56097
 
      _valueTo := _conv.itemuomconv_to_value;
56098
 
    ELSE
56099
 
      _valueFrom := _conv.itemuomconv_to_value;
56100
 
      _valueTo := _conv.itemuomconv_from_value;
56101
 
    END IF;
56102
 
 
56103
 
    -- If we are converting to the item inv uom use the item fractional value
56104
 
    -- otherwise use the conversion fractional value.
56105
 
    if(_uomidTo = _uomidInv) THEN
56106
 
      _frac := _item.item_fractional;
56107
 
    ELSE
56108
 
      _frac := _conv.itemuomconv_fractional;
56109
 
    END IF;
56110
 
    _value := roundLocale(_frac, ((_valueTo/_valueFrom) * pQtyFrom), pLocale);
56111
 
  ELSE
56112
 
    -- Try to convert the from uom to the inventory uom
56113
 
    SELECT itemuomconv_from_uom_id, itemuomconv_from_value,
56114
 
           itemuomconv_to_uom_id, itemuomconv_to_value,
56115
 
           itemuomconv_fractional
56116
 
      INTO _conv
56117
 
      FROM itemuomconv
56118
 
     WHERE(((itemuomconv_from_uom_id=_uomidFrom AND itemuomconv_to_uom_id=_uomidInv)
56119
 
         OR (itemuomconv_from_uom_id=_uomidInv AND itemuomconv_to_uom_id=_uomidFrom))
56120
 
       AND (itemuomconv_item_id=pItemid));
56121
 
    IF(NOT FOUND) THEN
56122
 
      RAISE EXCEPTION 'A conversion for item_id % from uom_id % to inv_uom_id % was not found.', pItemid, _uomidFrom, _uomidInv;
56123
 
    END IF;
56124
 
    IF(_conv.itemuomconv_from_uom_id=_uomidInv) THEN
56125
 
      _valueFrom := _conv.itemuomconv_from_value;
56126
 
      _valueTo := _conv.itemuomconv_to_value;
56127
 
    ELSE
56128
 
      _valueFrom := _conv.itemuomconv_to_value;
56129
 
      _valueTo := _conv.itemuomconv_from_value;
56130
 
    END IF;
56131
 
    _value := (_valueTo / _valueFrom);
56132
 
    IF (_conv.itemuomconv_fractional OR _item.item_fractional) THEN
56133
 
      _frac := TRUE;
56134
 
    END IF;
56135
 
    -- Try to convert the to uom to the inventory uom
56136
 
    SELECT itemuomconv_from_uom_id, itemuomconv_from_value,
56137
 
           itemuomconv_to_uom_id, itemuomconv_to_value,
56138
 
           itemuomconv_fractional
56139
 
      INTO _conv
56140
 
      FROM itemuomconv
56141
 
     WHERE(((itemuomconv_from_uom_id=_uomidInv AND itemuomconv_to_uom_id=_uomidTo)
56142
 
         OR (itemuomconv_from_uom_id=_uomidTo AND itemuomconv_to_uom_id=_uomidInv))
56143
 
       AND (itemuomconv_item_id=pItemid));
56144
 
    IF(NOT FOUND) THEN
56145
 
      RAISE EXCEPTION 'A conversion for item_id % from uom_id % to inv_uom_id % was not found.', pItemid, _uomidTo, _uomidInv;
56146
 
    END IF;
56147
 
    IF(_conv.itemuomconv_from_uom_id=_uomidInv) THEN
56148
 
      _valueFrom := _conv.itemuomconv_from_value;
56149
 
      _valueTo := _conv.itemuomconv_to_value;
56150
 
    ELSE
56151
 
      _valueFrom := _conv.itemuomconv_to_value;
56152
 
      _valueTo := _conv.itemuomconv_from_value;
56153
 
    END IF;
56154
 
    _value := _value * (_valueTo / _valueFrom);
56155
 
    IF (_conv.itemuomconv_fractional OR _item.item_fractional) THEN
56156
 
      _frac := TRUE;
56157
 
    END IF;
56158
 
    _value := roundLocale(_frac, (_value * pQtyFrom), pLocale);
56159
 
  END IF;
56160
 
 
56161
 
  RETURN _value;
56162
 
END;
56163
 
$$;
56164
 
 
56165
 
 
56166
 
ALTER FUNCTION public.itemuomtouom(pitemid integer, puomidfrom integer, puomidto integer, pqtyfrom numeric, plocale text) OWNER TO admin;
56167
 
 
56168
 
--
56169
 
--
56170
 
 
56171
 
CREATE FUNCTION itemuomtouomratio(pitemid integer, puomidfrom integer, puomidto integer) RETURNS numeric
56172
 
    LANGUAGE plpgsql STABLE
56173
 
    AS $$
56174
 
DECLARE
56175
 
  _uomidFrom INTEGER;
56176
 
  _uomidTo   INTEGER;
56177
 
  _uomidInv  INTEGER;
56178
 
  _valueFrom NUMERIC := 0.0;
56179
 
  _valueTo   NUMERIC := 0.0;
56180
 
  _value     NUMERIC := 0.0;
56181
 
  _item      RECORD;
56182
 
  _conv      RECORD;
56183
 
BEGIN
56184
 
 
56185
 
  SELECT item_inv_uom_id
56186
 
    INTO _item
56187
 
    FROM item
56188
 
   WHERE(item_id=pItemid);
56189
 
  IF(NOT FOUND) THEN
56190
 
    RAISE EXCEPTION 'No item record was found for item id %', pItemid;
56191
 
  END IF;
56192
 
 
56193
 
  _uomidFrom := COALESCE(pUomidFrom, _item.item_inv_uom_id);
56194
 
  _uomidTo   := COALESCE(pUomidTo,   _item.item_inv_uom_id);
56195
 
  _uomidInv  := _item.item_inv_uom_id;
56196
 
 
56197
 
  IF(_uomidFrom = _uomidTo) THEN
56198
 
    RETURN 1.0;
56199
 
  END IF;
56200
 
 
56201
 
  -- Try a direct conversion
56202
 
  SELECT itemuomconv_from_uom_id, itemuomconv_from_value,
56203
 
         itemuomconv_to_uom_id, itemuomconv_to_value
56204
 
    INTO _conv
56205
 
    FROM itemuomconv
56206
 
   WHERE(((itemuomconv_from_uom_id=_uomidFrom AND itemuomconv_to_uom_id=_uomidTo)
56207
 
       OR (itemuomconv_from_uom_id=_uomidTo AND itemuomconv_to_uom_id=_uomidFrom))
56208
 
     AND (itemuomconv_item_id=pItemid));
56209
 
  IF(FOUND) THEN
56210
 
    IF(_conv.itemuomconv_from_uom_id=_uomidFrom) THEN
56211
 
      _valueFrom := _conv.itemuomconv_from_value;
56212
 
      _valueTo := _conv.itemuomconv_to_value;
56213
 
    ELSE
56214
 
      _valueFrom := _conv.itemuomconv_to_value;
56215
 
      _valueTo := _conv.itemuomconv_from_value;
56216
 
    END IF;
56217
 
    _value := (_valueTo / _valueFrom);
56218
 
  ELSE
56219
 
    -- Try to convert the from uom to the inventory uom
56220
 
    SELECT itemuomconv_from_uom_id, itemuomconv_from_value,
56221
 
           itemuomconv_to_uom_id, itemuomconv_to_value
56222
 
      INTO _conv
56223
 
      FROM itemuomconv
56224
 
     WHERE(((itemuomconv_from_uom_id=_uomidFrom AND itemuomconv_to_uom_id=_uomidInv)
56225
 
         OR (itemuomconv_from_uom_id=_uomidInv AND itemuomconv_to_uom_id=_uomidFrom))
56226
 
       AND (itemuomconv_item_id=pItemid));
56227
 
    IF(NOT FOUND) THEN
56228
 
      RAISE EXCEPTION 'A conversion for item_id % from uom_id % to inv_uom_id % was not found.', pItemid, _uomidFrom, _uomidInv;
56229
 
    END IF;
56230
 
    IF(_conv.itemuomconv_from_uom_id=_uomidInv) THEN
56231
 
      _valueFrom := _conv.itemuomconv_from_value;
56232
 
      _valueTo := _conv.itemuomconv_to_value;
56233
 
    ELSE
56234
 
      _valueFrom := _conv.itemuomconv_to_value;
56235
 
      _valueTo := _conv.itemuomconv_from_value;
56236
 
    END IF;
56237
 
    _value := (_valueTo / _valueFrom);
56238
 
    -- Try to convert the to uom to the inventory uom
56239
 
    SELECT itemuomconv_from_uom_id, itemuomconv_from_value,
56240
 
           itemuomconv_to_uom_id, itemuomconv_to_value
56241
 
      INTO _conv
56242
 
      FROM itemuomconv
56243
 
     WHERE(((itemuomconv_from_uom_id=_uomidInv AND itemuomconv_to_uom_id=_uomidTo)
56244
 
         OR (itemuomconv_from_uom_id=_uomidTo AND itemuomconv_to_uom_id=_uomidInv))
56245
 
       AND (itemuomconv_item_id=pItemid));
56246
 
    IF(NOT FOUND) THEN
56247
 
      RAISE EXCEPTION 'A conversion for item_id % from uom_id % to inv_uom_id % was not found.', pItemid, _uomidTo, _uomidInv;
56248
 
    END IF;
56249
 
    IF(_conv.itemuomconv_from_uom_id=_uomidInv) THEN
56250
 
      _valueFrom := _conv.itemuomconv_from_value;
56251
 
      _valueTo := _conv.itemuomconv_to_value;
56252
 
    ELSE
56253
 
      _valueFrom := _conv.itemuomconv_to_value;
56254
 
      _valueTo := _conv.itemuomconv_from_value;
56255
 
    END IF;
56256
 
    _value := _value * (_valueTo / _valueFrom);
56257
 
  END IF;
56258
 
 
56259
 
  RETURN _value;
56260
 
END;
56261
 
$$;
56262
 
 
56263
 
 
56264
 
ALTER FUNCTION public.itemuomtouomratio(pitemid integer, puomidfrom integer, puomidto integer) OWNER TO admin;
56265
 
 
56266
 
--
56267
 
--
56268
 
 
56269
 
CREATE FUNCTION last_agg(anyelement, anyelement) RETURNS anyelement
56270
 
    LANGUAGE sql STABLE
56271
 
    AS $_$
56272
 
  SELECT $2;
56273
 
$_$;
56274
 
 
56275
 
 
56276
 
ALTER FUNCTION public.last_agg(anyelement, anyelement) OWNER TO admin;
56277
 
 
56278
 
--
56279
 
--
56280
 
 
56281
 
CREATE FUNCTION login() RETURNS integer
56282
 
    LANGUAGE plpgsql
56283
 
    AS $$
56284
 
DECLARE 
56285
 
  _p RECORD;
56286
 
 
56287
 
BEGIN
56288
 
 
56289
 
  RETURN login(false);
56290
 
 
56291
 
END;
56292
 
$$;
56293
 
 
56294
 
 
56295
 
ALTER FUNCTION public.login() OWNER TO admin;
56296
 
 
56297
 
--
56298
 
--
56299
 
 
56300
 
CREATE FUNCTION login(boolean) RETURNS integer
56301
 
    LANGUAGE plpgsql
56302
 
    AS $_$
56303
 
DECLARE 
56304
 
  _setSearchPath ALIAS FOR $1;
56305
 
  _p RECORD;
56306
 
 
56307
 
BEGIN
56308
 
  -- added support for PostgreSQL 9.2.0, Incident 21852
56309
 
  IF (compareversion('9.2.0') <= 0)
56310
 
  THEN
56311
 
    PERFORM pg_try_advisory_lock(datid::integer, pid)
56312
 
     FROM pg_stat_activity
56313
 
    WHERE(pid = pg_backend_pid());
56314
 
  ELSE
56315
 
    PERFORM pg_try_advisory_lock(datid::integer, procpid)
56316
 
     FROM pg_stat_activity
56317
 
    WHERE(procpid = pg_backend_pid());
56318
 
  END IF;
56319
 
 
56320
 
  -- This is new to version 9.0 and higher and will error on older versions
56321
 
  IF (compareversion('9.0.0') <= 0) THEN
56322
 
    SET bytea_output TO escape;
56323
 
  END IF;
56324
 
 
56325
 
  -- this is temporary until either qt fixes the postgres driver or we find &
56326
 
  -- fix all of the places in our app that can write strings with backslashes
56327
 
  SET standard_conforming_strings TO false;
56328
 
 
56329
 
  SELECT usr_id, userCanLogin(usr_username) AS usr_active INTO _p
56330
 
  FROM usr
56331
 
  WHERE (usr_username=getEffectiveXtUser());
56332
 
 
56333
 
  IF (NOT FOUND) THEN
56334
 
    RETURN -1;
56335
 
 
56336
 
  ELSIF (NOT _p.usr_active) THEN
56337
 
    IF(SELECT metric_value='AdminOnly'
56338
 
         FROM metric
56339
 
        WHERE metric_name='AllowedUserLogins') THEN
56340
 
      RETURN -3;
56341
 
    END IF;
56342
 
    RETURN -2;
56343
 
  END IF;
56344
 
 
56345
 
  IF (_setSearchPath) THEN
56346
 
    IF EXISTS(SELECT 1
56347
 
                FROM pg_proc
56348
 
                JOIN pg_namespace ON (pronamespace=pg_namespace.oid)
56349
 
               WHERE nspname='public'
56350
 
                 AND proname='buildsearchpath') THEN
56351
 
      EXECUTE 'SET SEARCH_PATH TO ' || public.buildSearchPath();
56352
 
    END IF;
56353
 
  END IF;
56354
 
 
56355
 
  RETURN 1;
56356
 
 
56357
 
END;
56358
 
$_$;
56359
 
 
56360
 
 
56361
 
ALTER FUNCTION public.login(boolean) OWNER TO admin;
56362
 
 
56363
 
--
56364
 
--
56365
 
 
56366
 
CREATE FUNCTION logout() RETURNS integer
56367
 
    LANGUAGE plpgsql
56368
 
    AS $$
56369
 
BEGIN
56370
 
  IF (compareversion('9.2.0') <= 0)
56371
 
  THEN
56372
 
    PERFORM pg_advisory_unlock(datid::integer, pid)
56373
 
     FROM pg_stat_activity
56374
 
    WHERE(pid = pg_backend_pid());
56375
 
  ELSE
56376
 
    PERFORM pg_advisory_unlock(datid::integer, procpid)
56377
 
       FROM pg_stat_activity
56378
 
      WHERE(procpid = pg_backend_pid());
56379
 
  END IF;
56380
 
 
56381
 
  RETURN 0;
56382
 
END;
56383
 
$$;
56384
 
 
56385
 
 
56386
 
ALTER FUNCTION public.logout() OWNER TO admin;
56387
 
 
56388
 
--
56389
 
--
56390
 
 
56391
 
CREATE FUNCTION lowercost(integer, text) RETURNS numeric
56392
 
    LANGUAGE plpgsql
56393
 
    AS $_$
56394
 
DECLARE
56395
 
  pItemid       ALIAS FOR $1;
56396
 
  pCosttype     ALIAS FOR $2;
56397
 
 
56398
 
BEGIN
56399
 
    RETURN lowerCost(pItemid, pCosttype, TRUE);
56400
 
END;
56401
 
$_$;
56402
 
 
56403
 
 
56404
 
ALTER FUNCTION public.lowercost(integer, text) OWNER TO admin;
56405
 
 
56406
 
--
56407
 
--
56408
 
 
56409
 
CREATE FUNCTION lowercost(integer, text, boolean) RETURNS numeric
56410
 
    LANGUAGE plpgsql
56411
 
    AS $_$
56412
 
DECLARE
56413
 
  pItemid ALIAS FOR $1;
56414
 
  pCosttype ALIAS FOR $2;
56415
 
  pActual       ALIAS FOR $3;
56416
 
  _type CHAR(1);
56417
 
  _actCost      NUMERIC;
56418
 
  _actCost1     NUMERIC;
56419
 
  _actCost2     NUMERIC;
56420
 
  _stdCost      NUMERIC;
56421
 
  _stdCost1     NUMERIC;
56422
 
  _stdCost2     NUMERIC;
56423
 
  _cost         NUMERIC;
56424
 
  _cost1        NUMERIC;
56425
 
  _cost2        NUMERIC;
56426
 
  _batchsize    NUMERIC;
56427
 
 
56428
 
BEGIN
56429
 
 
56430
 
  SELECT item_type INTO _type
56431
 
  FROM item
56432
 
  WHERE (item_id=pItemid);
56433
 
 
56434
 
  _batchsize := COALESCE( (
56435
 
    SELECT bomhead_batchsize
56436
 
    FROM bomhead
56437
 
    WHERE ((bomhead_item_id=pItemId)
56438
 
     AND  (bomhead_rev_id=getActiveRevId('BOM',pItemId))) LIMIT 1), 1);
56439
 
 
56440
 
  -- find the lowercost in the base currency at the current conversion rate
56441
 
  IF (_type IN ('M', 'F', 'B', 'T')) THEN
56442
 
 
56443
 
    IF (pActual) THEN
56444
 
      SELECT SUM( CASE WHEN (bomitemcost_id IS NOT NULL AND bc.costelem_id IS NOT NULL) THEN
56445
 
                  round(currToBase(bomitemcost_curr_id, bomitemcost_actcost, CURRENT_DATE),6) *
56446
 
                    itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper')
56447
 
                  ELSE
56448
 
                  round(currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE),6) *
56449
 
                    itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper')
56450
 
                  END )
56451
 
          INTO _cost
56452
 
      FROM bomitem(pItemid)
56453
 
        JOIN item ON (item_id=bomitem_item_id AND item_type <> 'T')
56454
 
        JOIN itemcost ON (itemcost_item_id=bomitem_item_id)
56455
 
        JOIN costelem ic ON (ic.costelem_id=itemcost_costelem_id AND ic.costelem_type=pCosttype)
56456
 
        LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=bomitem_id)
56457
 
        LEFT OUTER JOIN costelem bc ON (bc.costelem_id=bomitemcost_costelem_id AND bc.costelem_type=pCosttype)
56458
 
      WHERE ( CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1) );
56459
 
    ELSE
56460
 
      SELECT SUM( CASE WHEN (bomitemcost_id IS NOT NULL AND bc.costelem_id IS NOT NULL) THEN
56461
 
                  bomitemcost_stdcost *
56462
 
                    itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper')
56463
 
                  ELSE
56464
 
                  itemcost_stdcost *
56465
 
                    itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper')
56466
 
                  END )
56467
 
          INTO _cost
56468
 
      FROM bomitem(pItemid)
56469
 
        JOIN item ON (item_id=bomitem_item_id AND item_type <> 'T')
56470
 
        JOIN itemcost ON (itemcost_item_id=bomitem_item_id)
56471
 
        JOIN costelem ON (costelem_id=itemcost_costelem_id AND costelem_type=pCosttype)
56472
 
        LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=bomitem_id)
56473
 
        LEFT OUTER JOIN costelem bc ON (bc.costelem_id=bomitemcost_costelem_id AND bc.costelem_type=pCosttype)
56474
 
      WHERE ( CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1) ); 
56475
 
    END IF;
56476
 
    
56477
 
    IF (NOT FOUND) THEN
56478
 
      _cost := NULL;
56479
 
    END IF;
56480
 
 
56481
 
  ELSIF (_type IN ('C')) THEN
56482
 
    SELECT SUM(CASE WHEN (bbomitem_qtyper = 0) THEN 0
56483
 
                    ELSE currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) / bbomitem_qtyper * bbomitem_costabsorb
56484
 
               END),
56485
 
           SUM(CASE WHEN (bbomitem_qtyper = 0) THEN 0
56486
 
                    ELSE itemcost_stdcost / bbomitem_qtyper * bbomitem_costabsorb
56487
 
               END)
56488
 
        INTO _actCost1, _stdCost1
56489
 
    FROM itemcost
56490
 
         JOIN costelem       ON (itemcost_costelem_id=costelem_id)
56491
 
         JOIN xtmfg.bbomitem ON (bbomitem_parent_item_id=itemcost_item_id)
56492
 
    WHERE ( (bbomitem_item_id=pItemid)
56493
 
     AND (CURRENT_DATE BETWEEN bbomitem_effective AND (bbomitem_expires - 1))
56494
 
     AND (costelem_type=pCosttype) );
56495
 
 
56496
 
    SELECT SUM(CASE WHEN (t.bbomitem_qtyper = 0) THEN 0
56497
 
                    ELSE currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) * s.bbomitem_qtyper / t.bbomitem_qtyper * t.bbomitem_costabsorb
56498
 
               END),
56499
 
           SUM(CASE WHEN (t.bbomitem_qtyper = 0) THEN 0
56500
 
                    ELSE itemcost_stdcost * s.bbomitem_qtyper / t.bbomitem_qtyper * t.bbomitem_costabsorb
56501
 
               END)
56502
 
        INTO _actCost2, _stdCost2
56503
 
    FROM costelem
56504
 
         JOIN itemcost            ON (costelem_id=itemcost_costelem_id)
56505
 
         JOIN xtmfg.bbomitem AS s ON (itemcost_item_id=s.bbomitem_item_id)
56506
 
         JOIN xtmfg.bbomitem AS t ON (s.bbomitem_parent_item_id=t.bbomitem_parent_item_id)
56507
 
         JOIN  item               ON (s.bbomitem_item_id=item_id)
56508
 
    WHERE ( (t.bbomitem_item_id=pItemid)
56509
 
     AND ( CURRENT_DATE BETWEEN s.bbomitem_effective
56510
 
                        AND (s.bbomitem_expires - 1) )
56511
 
     AND ( CURRENT_DATE BETWEEN t.bbomitem_effective
56512
 
                        AND (t.bbomitem_expires - 1) )
56513
 
     AND (item_type='Y')
56514
 
     AND (costelem_type=pCosttype) );
56515
 
 
56516
 
    IF (pActual) THEN
56517
 
        _cost  = _actCost;
56518
 
        _cost1 = _actCost1;
56519
 
        _cost2 = _actCost2;
56520
 
    ELSE
56521
 
        _cost  = _stdCost;
56522
 
        _cost1 = _stdCost1;
56523
 
        _cost2 = _stdCost2;     -- should this be std or act?
56524
 
    END IF;
56525
 
 
56526
 
    IF (_cost1 IS NULL AND _cost2 IS NULL) THEN
56527
 
        _cost = NULL;
56528
 
    ELSE
56529
 
        _cost = COALESCE(_cost1, 0) + COALESCE(_cost2, 0);
56530
 
    END IF;
56531
 
 
56532
 
  ELSE
56533
 
    RETURN NULL;
56534
 
  END IF;
56535
 
 
56536
 
  RETURN round(_cost,6);
56537
 
 
56538
 
END;
56539
 
$_$;
56540
 
 
56541
 
 
56542
 
ALTER FUNCTION public.lowercost(integer, text, boolean) OWNER TO admin;
56543
 
 
56544
 
--
56545
 
--
56546
 
 
56547
 
CREATE FUNCTION maintainbomworkspace() RETURNS integer
56548
 
    LANGUAGE plpgsql
56549
 
    AS $$
56550
 
DECLARE
56551
 
  _test TEXT;
56552
 
 
56553
 
BEGIN
56554
 
 
56555
 
  SELECT tablename INTO _test
56556
 
  FROM pg_tables
56557
 
  WHERE (tablename='bomwork');
56558
 
  IF (NOT FOUND) THEN
56559
 
    CREATE TEMPORARY TABLE bomwork
56560
 
    ( bomwork_id INTEGER, bomwork_set_id INTEGER, bomwork_parent_id INTEGER,
56561
 
      bomwork_seqnumber INTEGER, bomwork_parent_seqnumber INTEGER,
56562
 
      bomwork_item_id INTEGER, bomwork_item_type CHARACTER(1), bomwork_status CHARACTER(1),
56563
 
      bomwork_qtyper NUMERIC(20, 8), bomwork_scrap NUMERIC(20, 10),
56564
 
      bomwork_level INTEGER, bomwork_effective DATE, bomwork_expires DATE,
56565
 
      bomwork_stdunitcost NUMERIC(16, 4), bomwork_actunitcost NUMERIC(16, 4),
56566
 
      bomwork_createwo BOOLEAN, bomwork_issuemethod CHARACTER(1) );
56567
 
    CREATE INDEX bomwork_set_id_idx ON bomwork(bomwork_set_id);
56568
 
  END IF;
56569
 
 
56570
 
  RETURN 1;
56571
 
 
56572
 
END;
56573
 
$$;
56574
 
 
56575
 
 
56576
 
ALTER FUNCTION public.maintainbomworkspace() OWNER TO admin;
56577
 
 
56578
 
--
56579
 
--
56580
 
 
56581
 
CREATE FUNCTION markapcheckasposted(integer) RETURNS integer
56582
 
    LANGUAGE plpgsql
56583
 
    AS $_$
56584
 
BEGIN
56585
 
  RAISE NOTICE 'markAPCheckAsPosted() is deprecated - use markCheckAsPosted() instead';
56586
 
  RETURN markCheckAsPosted($1);
56587
 
 
56588
 
END;
56589
 
$_$;
56590
 
 
56591
 
 
56592
 
ALTER FUNCTION public.markapcheckasposted(integer) OWNER TO admin;
56593
 
 
56594
 
--
56595
 
--
56596
 
 
56597
 
CREATE FUNCTION markapcheckasprinted(integer) RETURNS integer
56598
 
    LANGUAGE plpgsql
56599
 
    AS $_$
56600
 
BEGIN
56601
 
  RAISE NOTICE 'markAPCheckAsPrinted() is deprecated - use markCheckAsPrinted()';
56602
 
  RETURN markCheckAsPrinted($1);
56603
 
END;
56604
 
$_$;
56605
 
 
56606
 
 
56607
 
ALTER FUNCTION public.markapcheckasprinted(integer) OWNER TO admin;
56608
 
 
56609
 
--
56610
 
--
56611
 
 
56612
 
CREATE FUNCTION markcheckasposted(integer) RETURNS integer
56613
 
    LANGUAGE plpgsql
56614
 
    AS $_$
56615
 
DECLARE
56616
 
  pCheckid ALIAS FOR $1;
56617
 
 
56618
 
BEGIN
56619
 
 
56620
 
  UPDATE checkhead
56621
 
  SET checkhead_posted=TRUE
56622
 
  WHERE (checkhead_id=pCheckid);
56623
 
 
56624
 
  RETURN 1;
56625
 
 
56626
 
END;
56627
 
$_$;
56628
 
 
56629
 
 
56630
 
ALTER FUNCTION public.markcheckasposted(integer) OWNER TO admin;
56631
 
 
56632
 
--
56633
 
--
56634
 
 
56635
 
CREATE FUNCTION markcheckasprinted(integer) RETURNS integer
56636
 
    LANGUAGE plpgsql
56637
 
    AS $_$
56638
 
DECLARE
56639
 
  pCheckid ALIAS FOR $1;
56640
 
 
56641
 
BEGIN
56642
 
 
56643
 
  UPDATE checkhead
56644
 
  SET checkhead_printed=TRUE
56645
 
  WHERE (checkhead_id=pCheckid);
56646
 
 
56647
 
  RETURN 1;
56648
 
 
56649
 
END;
56650
 
$_$;
56651
 
 
56652
 
 
56653
 
ALTER FUNCTION public.markcheckasprinted(integer) OWNER TO admin;
56654
 
 
56655
 
--
56656
 
--
56657
 
 
56658
 
CREATE FUNCTION massexpirebomitem(integer, date, text) RETURNS boolean
56659
 
    LANGUAGE plpgsql
56660
 
    AS $_$
56661
 
DECLARE
56662
 
  pItemid ALIAS FOR $1;
56663
 
  pExpireDate ALIAS FOR $2;
56664
 
  pECN ALIAS FOR $3;
56665
 
 
56666
 
BEGIN
56667
 
 
56668
 
  UPDATE bomitem
56669
 
  SET bomitem_expires=pExpireDate
56670
 
  WHERE ( (bomitem_expires >= CURRENT_DATE)
56671
 
   AND (bomitem_item_id=pItemid)
56672
 
   AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) );
56673
 
 
56674
 
  RETURN TRUE;
56675
 
END;
56676
 
$_$;
56677
 
 
56678
 
 
56679
 
ALTER FUNCTION public.massexpirebomitem(integer, date, text) OWNER TO admin;
56680
 
 
56681
 
--
56682
 
--
56683
 
 
56684
 
CREATE FUNCTION massreplacebomitem(integer, integer, date, text) RETURNS integer
56685
 
    LANGUAGE plpgsql
56686
 
    AS $_$
56687
 
DECLARE
56688
 
  pNewItemid ALIAS FOR $1;
56689
 
  pOriginalItemid ALIAS FOR $2;
56690
 
  pEffectiveDate ALIAS FOR $3;
56691
 
  pECN ALIAS FOR $4;
56692
 
  _effectiveDate DATE;
56693
 
  _result               INTEGER;
56694
 
 
56695
 
BEGIN
56696
 
 
56697
 
  _effectiveDate := COALESCE(pEffectiveDate, CURRENT_DATE);
56698
 
 
56699
 
  IF (BOMContains(pOriginalItemid, pNewItemid) OR
56700
 
      BOMContains(pNewItemid, pOriginalItemid)) THEN
56701
 
    RETURN -1;
56702
 
  END IF;
56703
 
 
56704
 
  INSERT INTO bomitem
56705
 
  ( bomitem_parent_item_id, bomitem_seqnumber,
56706
 
    bomitem_item_id, bomitem_qtyfxd, bomitem_qtyper, bomitem_uom_id,
56707
 
    bomitem_scrap, bomitem_effective, bomitem_expires, bomitem_ecn,
56708
 
    bomitem_createwo, bomitem_issuemethod, bomitem_subtype,
56709
 
    bomitem_booitem_seq_id, bomitem_schedatwooper, bomitem_moddate, bomitem_rev_id,
56710
 
    bomitem_char_id, bomitem_value )
56711
 
  SELECT bomitem_parent_item_id, bomitem_seqnumber,
56712
 
         pNewItemid, bomitem_qtyfxd, bomitem_qtyper, bomitem_uom_id,
56713
 
         bomitem_scrap, _effectiveDate, endOfTime(), pECN,
56714
 
         bomitem_createwo, bomitem_issuemethod, 'I',
56715
 
         bomitem_booitem_seq_id, bomitem_schedatwooper, CURRENT_DATE, getActiveRevId('BOM',bomitem_parent_item_id),
56716
 
         bomitem_char_id, bomitem_value
56717
 
  FROM bomitem
56718
 
  WHERE ( (_effectiveDate < bomitem_expires)
56719
 
   AND (bomitem_item_id=pOriginalItemid)
56720
 
   AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) );
56721
 
 
56722
 
  UPDATE bomitem
56723
 
  SET bomitem_expires=_effectiveDate
56724
 
  WHERE ( (_effectiveDate < bomitem_expires)
56725
 
   AND (bomitem_item_id=pOriginalItemid)
56726
 
   AND (bomitem_rev_id=getActiveRevid('BOM',bomitem_parent_item_id)) );
56727
 
 
56728
 
  RETURN 1;
56729
 
END;
56730
 
$_$;
56731
 
 
56732
 
 
56733
 
ALTER FUNCTION public.massreplacebomitem(integer, integer, date, text) OWNER TO admin;
56734
 
 
56735
 
--
56736
 
--
56737
 
 
56738
 
CREATE FUNCTION merge2crmaccts(integer, integer, boolean) RETURNS integer
56739
 
    LANGUAGE plpgsql
56740
 
    AS $_$
56741
 
DECLARE
56742
 
  pSourceId ALIAS FOR $1;
56743
 
  pTargetId ALIAS FOR $2;
56744
 
  _purge    BOOLEAN := COALESCE($3, FALSE);
56745
 
 
56746
 
  _coldesc    RECORD;
56747
 
  _count      INTEGER := 0;
56748
 
  _hassubtype BOOLEAN;
56749
 
  _mrgcol     BOOLEAN;
56750
 
  _result     INTEGER := 0;
56751
 
  _sel        RECORD;
56752
 
  _colname    TEXT;
56753
 
  _tmpid      INTEGER;
56754
 
 
56755
 
BEGIN
56756
 
  -- Validate
56757
 
  IF (pSourceId = pTargetId) THEN
56758
 
    RAISE NOTICE 'Tried to merge a CRM Account with itself: %.', pSourceId;
56759
 
    RETURN 0;
56760
 
  ELSIF (pSourceId IS NULL) THEN
56761
 
    RAISE EXCEPTION 'Merge source id cannot be null [xtuple: merge, -1]';
56762
 
  ELSIF NOT(EXISTS(SELECT 1 FROM crmacct WHERE crmacct_id=pSourceId)) THEN
56763
 
    RAISE EXCEPTION 'Merge source % not found [xtuple: merge, -2, %]',
56764
 
                    pSourceId, pSourceId;
56765
 
  ELSIF (pTargetId IS NULL) THEN
56766
 
    RAISE EXCEPTION 'Merge target id cannot be null [xtuple: merge, -3]';
56767
 
  ELSIF NOT(EXISTS(SELECT 1 FROM crmacct WHERE crmacct_id=pTargetId)) THEN
56768
 
    RAISE EXCEPTION 'Merge target % not found [xtuple: merge, -4, %]',
56769
 
                    pTargetId, pTargetId;
56770
 
  ELSIF NOT(EXISTS(SELECT 1
56771
 
                     FROM crmacctsel
56772
 
                    WHERE (crmacctsel_src_crmacct_id=pSourceId)
56773
 
                      AND (crmacctsel_dest_crmacct_id=pTargetId))) THEN
56774
 
    RAISE EXCEPTION 'Source % and target % have not been selected for merging [xtuple: merge, -5, %, %]',
56775
 
                    pSourceId, pTargetId, pSourceId, pTargetId;
56776
 
  END IF;
56777
 
 
56778
 
  _result:= changeFkeyPointers('public', 'crmacct', pSourceId, pTargetId,
56779
 
                               ARRAY[ 'crmacctsel', 'crmacctmrgd' ], _purge)
56780
 
          + changePseudoFKeyPointers('public', 'alarm', 'alarm_source_id',
56781
 
                                     pSourceId, 'public', 'crmacct', pTargetId,
56782
 
                                     'alarm_source', 'CRMA', _purge)
56783
 
          + changePseudoFKeyPointers('public', 'charass', 'charass_target_id',
56784
 
                                     pSourceId, 'public', 'crmacct', pTargetId,
56785
 
                                     'charass_target_type', 'CRMACCT', _purge)
56786
 
          + changePseudoFKeyPointers('public', 'comment', 'comment_source_id',
56787
 
                                     pSourceId, 'public', 'crmacct', pTargetId,
56788
 
                                     'comment_source', 'CRMA', _purge)
56789
 
          + changePseudoFKeyPointers('public', 'docass', 'docass_source_id',
56790
 
                                     pSourceId, 'public', 'crmacct', pTargetId,
56791
 
                                     'docass_source_type', 'CRMA', _purge)
56792
 
          + changePseudoFKeyPointers('public', 'docass', 'docass_target_id',
56793
 
                                     pSourceId, 'public', 'crmacct', pTargetId,
56794
 
                                     'docass_target_type', 'CRMA', _purge)
56795
 
          + changePseudoFKeyPointers('public', 'imageass', 'imageass_source_id',
56796
 
                                     pSourceId, 'public', 'crmacct', pTargetId,
56797
 
                                     'imageass_source', 'CRMA', _purge)
56798
 
          ;
56799
 
 
56800
 
  -- TODO: find a generic way to handle pseudofkeys in packages - see 9401
56801
 
  IF (fetchMetricBool('EnableBatchManager') AND packageIsEnabled('xtbatch')) THEN
56802
 
    _result:= _result
56803
 
            + changePseudoFKeyPointers('xtbatch', 'emlassc', 'emlassc_assc_id',
56804
 
                                       pSourceId, 'public', 'crmacct', pTargetId,
56805
 
                                       'emlassc_type', 'CRMA', _purge);
56806
 
  END IF;
56807
 
 
56808
 
  -- back up all of the values in the target record that are about to be changed
56809
 
  FOR _coldesc IN SELECT attname, typname
56810
 
                    FROM pg_attribute
56811
 
                    JOIN pg_type      ON (atttypid=pg_type.oid)
56812
 
                    JOIN pg_class     ON (attrelid=pg_class.oid)
56813
 
                    JOIN pg_namespace ON (relnamespace=pg_namespace.oid)
56814
 
                   WHERE (attnum >= 0)
56815
 
                     AND (relname='crmacct')
56816
 
                     AND (nspname='public')
56817
 
                     AND (attname NOT IN ('crmacct_id', 'crmacct_number'))
56818
 
  LOOP
56819
 
 
56820
 
    -- if we're supposed to merge this column at all
56821
 
    EXECUTE 'SELECT ' || quote_ident('crmacctsel_mrg_' || _coldesc.attname) || '
56822
 
               FROM crmacctsel
56823
 
              WHERE ((crmacctsel_src_crmacct_id='  || pSourceId || ')
56824
 
                 AND (crmacctsel_dest_crmacct_id=' || pTargetId || '))' INTO _mrgcol;
56825
 
 
56826
 
    IF (_mrgcol) THEN
56827
 
      _colname := REPLACE(_coldesc.attname, 'crmacctsel_mrg_', '');
56828
 
 
56829
 
      -- optionally back up the old value from the destination
56830
 
      -- we'll back up the old value from the source further down
56831
 
      IF (NOT _purge) THEN
56832
 
        BEGIN
56833
 
          EXECUTE 'INSERT INTO mrgundo (
56834
 
                       mrgundo_schema,      mrgundo_table,
56835
 
                       mrgundo_pkey_col,    mrgundo_pkey_id,
56836
 
                       mrgundo_col,         mrgundo_value,      mrgundo_type,
56837
 
                       mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id
56838
 
                 ) SELECT ''public'',     ''crmacct'',
56839
 
                          ''crmacct_id'', crmacct_id, '   ||
56840
 
                          quote_literal(_colname)         || ', ' ||
56841
 
                          quote_ident(_colname)           || ', ' ||
56842
 
                          quote_literal(_coldesc.typname) || ',
56843
 
                          ''public'', ''crmacct'', crmacct_id
56844
 
                     FROM crmacct
56845
 
                    WHERE (crmacct_id=' || pTargetId || ');' ;
56846
 
        EXCEPTION WHEN unique_violation THEN
56847
 
          RAISE EXCEPTION 'Could not make a backup copy of % when merging % into % [xtuple: merge, -8, %, %, public, crmacct, %]',
56848
 
                       _colname, pSourceId, pTargetId,
56849
 
                       _colname, pSourceId, pTargetId;
56850
 
        END;
56851
 
      END IF;
56852
 
 
56853
 
      -- TODO: what do we do about users?
56854
 
      /* update the destination crmacct in one of 3 different ways:
56855
 
         - crmacct_notes might be concatenated from more than one source record
56856
 
         - foreign keys to crm account subtype records (e.g. crmacct_cust_id)
56857
 
           must not leave orphaned records and must avoid uniqueness violations
56858
 
         - some fields can simply be updated in place
56859
 
       */
56860
 
      IF (_colname = 'crmacct_notes') THEN
56861
 
        EXECUTE 'UPDATE crmacct dest
56862
 
                    SET '      || quote_ident(_colname) ||
56863
 
                      '=dest.' || quote_ident(_colname) ||
56864
 
                      E' || E''\\n'' || src.' || _colname || '
56865
 
                  FROM crmacct src
56866
 
                  JOIN crmacctsel ON (src.crmacct_id=crmacctsel_src_crmacct_id)
56867
 
                 WHERE ((dest.crmacct_id=crmacctsel_dest_crmacct_id)
56868
 
                    AND (dest.crmacct_id!=crmacctsel_src_crmacct_id));';
56869
 
 
56870
 
      ELSIF (_colname IN ('crmacct_cust_id', 'crmacct_prospect_id', 
56871
 
                          'crmacct_vend_id', 'crmacct_taxauth_id',
56872
 
                          'crmacct_emp_id',  'crmacct_salesrep_id')) THEN
56873
 
        IF (_colname IN ('crmacct_cust_id', 'crmacct_prospect_id')) THEN
56874
 
          EXECUTE 'SELECT src.' || quote_ident(_colname) || ' IS NOT NULL
56875
 
                      AND (dest.crmacct_prospect_id IS NOT NULL OR
56876
 
                           dest.crmacct_cust_id IS NOT NULL)
56877
 
                     FROM crmacct src
56878
 
                     JOIN crmacctsel ON (src.crmacct_id=crmacctsel_src_crmacct_id)
56879
 
                     JOIN crmacct dest ON (crmacctsel_dest_crmacct_id=dest.crmacct_id)
56880
 
                    WHERE ((src.crmacct_id='  || pSourceId || ')
56881
 
                       AND (dest.crmacct_id=' || pTargetId || '))' INTO _hassubtype;
56882
 
          IF (_hassubtype) THEN
56883
 
            RAISE EXCEPTION 'Cannot merge two CRM Accounts that both refer to Customers and/or Prospects [xtuple: merge, -6, %, %]',
56884
 
                            pSourceId, pTargetId;
56885
 
          END IF;
56886
 
        ELSE
56887
 
          EXECUTE 'SELECT src.' || quote_ident(_colname) || ' IS NOT NULL
56888
 
                      AND dest.'|| quote_ident(_colname) || ' IS NOT NULL
56889
 
                     FROM crmacct src
56890
 
                     JOIN crmacctsel ON (src.crmacct_id=crmacctsel_src_crmacct_id)
56891
 
                     JOIN crmacct dest ON (crmacctsel_dest_crmacct_id=dest.crmacct_id)
56892
 
                    WHERE ((src.crmacct_id='  || pSourceId || ')
56893
 
                       AND (dest.crmacct_id=' || pTargetId || '))' INTO _hassubtype;
56894
 
 
56895
 
          IF (_hassubtype) THEN
56896
 
            RAISE EXCEPTION 'Cannot merge CRM Accounts until the % child records have been merged [xtuple: merge, -7, %, %, %]',
56897
 
                            _colname, _colname, pSourceId, pTargetId;
56898
 
          END IF;
56899
 
 
56900
 
        END IF;
56901
 
 
56902
 
        /* clearing the source separately from setting the target avoids
56903
 
           problems with triggers updating the wrong records */
56904
 
        EXECUTE 'SELECT ' || quote_ident(_colname) || ' FROM crmacct
56905
 
                  WHERE crmacct_id=' || pSourceId
56906
 
        INTO _tmpid;
56907
 
 
56908
 
        -- now we have the data to back up the source
56909
 
        IF (NOT _purge) THEN
56910
 
          BEGIN
56911
 
            EXECUTE 'INSERT INTO mrgundo (
56912
 
                         mrgundo_schema,      mrgundo_table,
56913
 
                         mrgundo_pkey_col,    mrgundo_pkey_id,
56914
 
                         mrgundo_col,         mrgundo_value,      mrgundo_type,
56915
 
                         mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id
56916
 
                   ) SELECT ''public'',     ''crmacct'',
56917
 
                            ''crmacct_id'', crmacct_id, '   ||
56918
 
                            quote_literal(_colname)         || ', ' ||
56919
 
                            quote_ident(_colname)           || ', ' ||
56920
 
                            quote_literal(_coldesc.typname) || ',
56921
 
                            ''public'', ''crmacct'', '      || pTargetId || '
56922
 
                       FROM crmacct
56923
 
                      WHERE (crmacct_id=' || pSourceId || ');' ;
56924
 
          EXCEPTION WHEN unique_violation THEN
56925
 
            RAISE EXCEPTION 'Could not make a backup copy of % when merging % into % [xtuple: merge, -8, %, %, public, crmacct, %]',
56926
 
                         _colname, pSourceId, pTargetId,
56927
 
                         _colname, pSourceId, pTargetId;
56928
 
          END;
56929
 
        END IF;
56930
 
 
56931
 
        EXECUTE 'UPDATE crmacct SET ' || quote_ident(_colname) || '=NULL
56932
 
              WHERE (crmacct_id=' || pSourceId || ');';
56933
 
 
56934
 
        EXECUTE 'UPDATE crmacct
56935
 
                    SET ' || quote_ident(_colname) || '=' || quote_literal(_tmpid) || '
56936
 
              WHERE (crmacct_id=' || pTargetId || ');';
56937
 
 
56938
 
      ELSE
56939
 
        EXECUTE 'UPDATE crmacct dest
56940
 
                    SET '      || quote_ident(_colname) || '
56941
 
                        =src.' || quote_ident(_colname) || '
56942
 
                  FROM crmacct src
56943
 
                 WHERE ((dest.crmacct_id=' || pTargetId || ')
56944
 
                    AND (src.crmacct_id='  || pSourceId || '));';
56945
 
      END IF;
56946
 
 
56947
 
      GET DIAGNOSTICS _count = ROW_COUNT;
56948
 
      _result := _result + _count;
56949
 
    END IF;
56950
 
 
56951
 
  END LOOP;
56952
 
 
56953
 
  IF (_purge) THEN
56954
 
    DELETE FROM crmacct WHERE crmacct = pSourceId;
56955
 
  ELSE
56956
 
    INSERT INTO mrgundo (
56957
 
           mrgundo_schema,      mrgundo_table,
56958
 
           mrgundo_pkey_col,    mrgundo_pkey_id,
56959
 
           mrgundo_col,         mrgundo_value,      mrgundo_type,
56960
 
           mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id
56961
 
    ) SELECT 'public',         'crmacct',
56962
 
             'crmacct_id',     pSourceId,
56963
 
             'crmacct_active', crmacct_active, 'bool',
56964
 
             'public',         'crmacct',       pTargetId
56965
 
        FROM crmacct
56966
 
       WHERE crmacct_active AND (crmacct_id = pSourceId);
56967
 
    GET DIAGNOSTICS _count = ROW_COUNT;
56968
 
    IF (_count > 0) THEN
56969
 
      _result := _result + _count;
56970
 
      UPDATE crmacct SET crmacct_active = false WHERE (crmacct_id=pSourceId);
56971
 
    END IF;
56972
 
 
56973
 
    -- make a special record of the source crm account so we can delete it later
56974
 
    INSERT INTO mrgundo (
56975
 
           mrgundo_schema,      mrgundo_table,
56976
 
           mrgundo_pkey_col,    mrgundo_pkey_id,
56977
 
           mrgundo_col,         mrgundo_value,      mrgundo_type,
56978
 
           mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id
56979
 
     ) VALUES (
56980
 
           'public',     'crmacct',
56981
 
           'crmacct_id', pSourceId,
56982
 
           NULL,         NULL,       NULL,
56983
 
           'public',     'crmacct', pTargetId);
56984
 
  END IF;
56985
 
 
56986
 
  DELETE FROM crmacctsel WHERE (crmacctsel_src_crmacct_id=pSourceId);
56987
 
 
56988
 
  RETURN _result;
56989
 
END;
56990
 
$_$;
56991
 
 
56992
 
 
56993
 
ALTER FUNCTION public.merge2crmaccts(integer, integer, boolean) OWNER TO admin;
56994
 
 
56995
 
--
56996
 
--
56997
 
 
56998
 
COMMENT ON FUNCTION merge2crmaccts(integer, integer, boolean) IS 'This function merges two crmacct records as decribed in crmacctsel records. For each field in the crmacctsel record marked TRUE, the data are copied from the crmacct record with crmacct_id=pSourceId to the record with crmacct_id=pTargetId. If the purge argument is TRUE, the source record is deleted. If it is FALSE, then mrgundo records are created so the merge can later be undone.';
56999
 
 
57000
 
 
57001
 
--
57002
 
--
57003
 
 
57004
 
CREATE FUNCTION mergecrmaccts(integer, boolean) RETURNS integer
57005
 
    LANGUAGE plpgsql
57006
 
    AS $_$
57007
 
DECLARE
57008
 
  pTargetId     ALIAS FOR $1;
57009
 
  _purge        BOOLEAN := COALESCE($2, FALSE);
57010
 
 
57011
 
  _retval       INTEGER;
57012
 
BEGIN
57013
 
 
57014
 
  /* if crmacctsel says the target should not keep its original
57015
 
     notes, clear them.  notes are special because the merge allows
57016
 
     concatenating them from multiple sources. this needs to be
57017
 
     kept in sync with merge2crmaccts' similar check.
57018
 
   */
57019
 
  IF NOT (SELECT crmacctsel_mrg_crmacct_notes
57020
 
            FROM crmacctsel
57021
 
           WHERE crmacctsel_src_crmacct_id=crmacctsel_dest_crmacct_id
57022
 
             AND crmacctsel_dest_crmacct_id=pTargetId) THEN
57023
 
    IF (NOT _purge) THEN
57024
 
      INSERT INTO mrgundo (
57025
 
             mrgundo_schema,      mrgundo_table,
57026
 
             mrgundo_pkey_col,    mrgundo_pkey_id,
57027
 
             mrgundo_col,         mrgundo_value,      mrgundo_type,
57028
 
             mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id)
57029
 
      SELECT 'public', 'crmacct', crmacct_id,
57030
 
             'public', 'crmacct', 'crmacct_id', crmacct_id,
57031
 
             'crmacct_notes', crmacct_notes, 'text',
57032
 
             'public', 'crmacct', crmacct_id
57033
 
        FROM crmacct
57034
 
       WHERE (crmacct_id=pTargetId);
57035
 
    END IF;
57036
 
 
57037
 
    UPDATE crmacct
57038
 
       SET crmacct_notes = ''
57039
 
     WHERE (crmacct_id=pTargetId);
57040
 
  END IF;
57041
 
 
57042
 
  -- merge the data from the various source records
57043
 
  SELECT SUM(merge2crmaccts(crmacctsel_src_crmacct_id, pTargetId, _purge))
57044
 
         INTO _retval
57045
 
    FROM crmacctsel
57046
 
   WHERE ((crmacctsel_dest_crmacct_id=pTargetId)
57047
 
      AND (crmacctsel_dest_crmacct_id!=crmacctsel_src_crmacct_id));
57048
 
 
57049
 
  DELETE FROM crmacctsel WHERE crmacctsel_dest_crmacct_id=pTargetId;
57050
 
 
57051
 
  RETURN COALESCE(_retval, 0);
57052
 
 
57053
 
END;
57054
 
$_$;
57055
 
 
57056
 
 
57057
 
ALTER FUNCTION public.mergecrmaccts(integer, boolean) OWNER TO admin;
57058
 
 
57059
 
--
57060
 
--
57061
 
 
57062
 
COMMENT ON FUNCTION mergecrmaccts(integer, boolean) IS 'This function uses the crmacctsel table to merge multiple crmacct records together. Only the merges into the specified target account are performed. Most of the work is done by repeated calls to the merge2crmaccts function. If the purge argument is FALSE, data are kept to allow reversing the merge.';
57063
 
 
57064
 
 
57065
 
--
57066
 
--
57067
 
 
57068
 
CREATE FUNCTION movebomitemdown(integer) RETURNS integer
57069
 
    LANGUAGE plpgsql
57070
 
    AS $_$
57071
 
DECLARE
57072
 
  pBomitemid ALIAS FOR $1;
57073
 
  _nextBomitem RECORD;
57074
 
 
57075
 
BEGIN
57076
 
 
57077
 
  SELECT nextbomitem.bomitem_seqnumber AS next_seqnumber,
57078
 
         thisbomitem.bomitem_seqnumber AS this_seqnumber,
57079
 
         thisbomitem.bomitem_parent_item_id AS parent_item_id,
57080
 
         thisbomitem.bomitem_rev_id AS rev_id
57081
 
          INTO _nextBomitem
57082
 
  FROM bomitem AS nextbomitem, bomitem AS thisbomitem
57083
 
  WHERE ((nextbomitem.bomitem_seqnumber > thisbomitem.bomitem_seqnumber)
57084
 
   AND (nextbomitem.bomitem_parent_item_id=thisbomitem.bomitem_parent_item_id)
57085
 
   AND (nextbomitem.bomitem_rev_id=thisbomitem.bomitem_rev_id)
57086
 
   AND (thisbomitem.bomitem_id=pBomitemid))
57087
 
  ORDER BY next_seqnumber
57088
 
  LIMIT 1;
57089
 
 
57090
 
  IF (FOUND) THEN
57091
 
 
57092
 
    UPDATE bomitem
57093
 
    SET bomitem_seqnumber=0
57094
 
    WHERE (bomitem_seqnumber=_nextBomitem.next_seqnumber)
57095
 
      AND (bomitem_parent_item_id=_nextBomitem.parent_item_id)
57096
 
      AND (bomitem_rev_id=_nextBomitem.rev_id);
57097
 
 
57098
 
    UPDATE bomitem 
57099
 
    SET bomitem_seqnumber=_nextBomitem.next_seqnumber
57100
 
    WHERE (bomitem_seqnumber=_nextBomitem.this_seqnumber)
57101
 
      AND (bomitem_parent_item_id=_nextBomitem.parent_item_id)
57102
 
      AND (bomitem_rev_id=_nextBomitem.rev_id);
57103
 
 
57104
 
    UPDATE bomitem
57105
 
    SET bomitem_seqnumber=_nextBomitem.this_seqnumber
57106
 
    WHERE (bomitem_seqnumber=0)
57107
 
      AND (bomitem_parent_item_id=_nextBomitem.parent_item_id)
57108
 
      AND (bomitem_rev_id=_nextBomitem.rev_id);
57109
 
  END IF;
57110
 
 
57111
 
  RETURN 1;
57112
 
 
57113
 
END;
57114
 
$_$;
57115
 
 
57116
 
 
57117
 
ALTER FUNCTION public.movebomitemdown(integer) OWNER TO admin;
57118
 
 
57119
 
--
57120
 
--
57121
 
 
57122
 
CREATE FUNCTION movebomitemup(integer) RETURNS integer
57123
 
    LANGUAGE plpgsql
57124
 
    AS $_$
57125
 
DECLARE
57126
 
  pBomitemid ALIAS FOR $1;
57127
 
  _nextBomitem RECORD;
57128
 
 
57129
 
BEGIN
57130
 
 
57131
 
  SELECT nextbomitem.bomitem_seqnumber AS next_seqnumber,
57132
 
         thisbomitem.bomitem_seqnumber AS this_seqnumber,
57133
 
         thisbomitem.bomitem_parent_item_id AS parent_item_id,
57134
 
         thisbomitem.bomitem_rev_id AS rev_id
57135
 
          INTO _nextBomitem
57136
 
  FROM bomitem AS nextbomitem, bomitem AS thisbomitem
57137
 
  WHERE ((nextbomitem.bomitem_seqnumber < thisbomitem.bomitem_seqnumber)
57138
 
   AND (nextbomitem.bomitem_parent_item_id=thisbomitem.bomitem_parent_item_id)
57139
 
   AND (nextbomitem.bomitem_rev_id=thisbomitem.bomitem_rev_id)
57140
 
   AND (thisbomitem.bomitem_id=pBomitemid))
57141
 
  ORDER BY next_seqnumber DESC
57142
 
  LIMIT 1;
57143
 
 
57144
 
  IF (FOUND) THEN
57145
 
 
57146
 
    UPDATE bomitem
57147
 
    SET bomitem_seqnumber=0
57148
 
    WHERE (bomitem_seqnumber=_nextBomitem.next_seqnumber)
57149
 
      AND (bomitem_parent_item_id=_nextBomitem.parent_item_id)
57150
 
      AND (bomitem_rev_id=_nextBomitem.rev_id);
57151
 
 
57152
 
    UPDATE bomitem 
57153
 
    SET bomitem_seqnumber=_nextBomitem.next_seqnumber
57154
 
    WHERE (bomitem_seqnumber=_nextBomitem.this_seqnumber)
57155
 
      AND (bomitem_parent_item_id=_nextBomitem.parent_item_id)
57156
 
      AND (bomitem_rev_id=_nextBomitem.rev_id);
57157
 
 
57158
 
    UPDATE bomitem
57159
 
    SET bomitem_seqnumber=_nextBomitem.this_seqnumber
57160
 
    WHERE (bomitem_seqnumber=0)
57161
 
      AND (bomitem_parent_item_id=_nextBomitem.parent_item_id)
57162
 
      AND (bomitem_rev_id=_nextBomitem.rev_id);
57163
 
  END IF;
57164
 
 
57165
 
  RETURN 1;
57166
 
 
57167
 
END;
57168
 
$_$;
57169
 
 
57170
 
 
57171
 
ALTER FUNCTION public.movebomitemup(integer) OWNER TO admin;
57172
 
 
57173
 
--
57174
 
--
57175
 
 
57176
 
CREATE FUNCTION moveccarddown(integer) RETURNS integer
57177
 
    LANGUAGE plpgsql
57178
 
    AS $_$
57179
 
DECLARE
57180
 
  pCcardid ALIAS FOR $1;
57181
 
  _nextCcard RECORD;
57182
 
 
57183
 
BEGIN
57184
 
 
57185
 
  SELECT nextCcard.ccard_id, nextCcard.ccard_seq AS next_seqnumber,
57186
 
         thisCcard.ccard_seq AS this_seqnumber INTO _nextCcard
57187
 
  FROM Ccard AS nextCcard, Ccard AS thisCcard
57188
 
  WHERE ((nextCcard.ccard_seq > thisCcard.ccard_seq)
57189
 
   AND (nextCcard.ccard_cust_id=thisCcard.ccard_cust_id)
57190
 
   AND (thisCcard.ccard_id=pCcardid))
57191
 
  ORDER BY next_seqnumber
57192
 
  LIMIT 1;
57193
 
 
57194
 
  IF (FOUND) THEN
57195
 
 
57196
 
    UPDATE Ccard
57197
 
    SET ccard_seq=_nextCcard.next_seqnumber
57198
 
    WHERE (ccard_id=pCcardid);
57199
 
 
57200
 
    UPDATE Ccard
57201
 
    SET ccard_seq=_nextCcard.this_seqnumber
57202
 
    WHERE (ccard_id=_nextCcard.ccard_id);
57203
 
  END IF;
57204
 
 
57205
 
  RETURN 1;
57206
 
 
57207
 
END;
57208
 
$_$;
57209
 
 
57210
 
 
57211
 
ALTER FUNCTION public.moveccarddown(integer) OWNER TO admin;
57212
 
 
57213
 
--
57214
 
--
57215
 
 
57216
 
CREATE FUNCTION moveccardup(integer) RETURNS integer
57217
 
    LANGUAGE plpgsql
57218
 
    AS $_$
57219
 
DECLARE
57220
 
  pCcardid ALIAS FOR $1;
57221
 
  _nextCcard RECORD;
57222
 
 
57223
 
BEGIN
57224
 
 
57225
 
  SELECT nextCcard.ccard_id AS ccard_id, nextCcard.ccard_seq AS next_seqnumber,
57226
 
         thisCcard.ccard_seq AS this_seqnumber INTO _nextCcard
57227
 
  FROM ccard AS nextCcard, ccard AS thisCcard
57228
 
  WHERE ((nextCcard.ccard_seq < thisCcard.ccard_seq)
57229
 
   AND (nextCcard.ccard_cust_id=thisCcard.ccard_cust_id)
57230
 
   AND (thisCcard.ccard_id=pCcardid))
57231
 
  ORDER BY next_seqnumber DESC
57232
 
  LIMIT 1;
57233
 
 
57234
 
  IF (FOUND) THEN
57235
 
 
57236
 
    UPDATE Ccard 
57237
 
    SET ccard_seq=_nextCcard.next_seqnumber
57238
 
    WHERE (ccard_id=pCcardid);
57239
 
 
57240
 
    UPDATE Ccard
57241
 
    SET ccard_seq=_nextCcard.this_seqnumber
57242
 
    WHERE (ccard_id=_nextCcard.ccard_id);
57243
 
  END IF;
57244
 
 
57245
 
  RETURN 1;
57246
 
 
57247
 
END;
57248
 
$_$;
57249
 
 
57250
 
 
57251
 
ALTER FUNCTION public.moveccardup(integer) OWNER TO admin;
57252
 
 
57253
 
--
57254
 
--
57255
 
 
57256
 
CREATE FUNCTION moveflgroupdown(integer) RETURNS integer
57257
 
    LANGUAGE plpgsql
57258
 
    AS $_$
57259
 
DECLARE
57260
 
  pFlgrpid ALIAS FOR $1;
57261
 
  _from RECORD;
57262
 
  _to RECORD;
57263
 
 
57264
 
BEGIN
57265
 
 
57266
 
  SELECT flgrp_id AS id,
57267
 
         flgrp_flhead_id AS flhead_id,
57268
 
         flgrp_flgrp_id AS flgrp_id,
57269
 
         flgrp_order AS ord INTO _from
57270
 
    FROM flgrp
57271
 
   WHERE (flgrp_id=pFlgrpid);
57272
 
  IF (NOT FOUND) THEN
57273
 
    RETURN -1;
57274
 
  END IF;
57275
 
 
57276
 
  SELECT id, type, ord INTO _to
57277
 
    FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord
57278
 
            FROM flitem
57279
 
           WHERE ((flitem_flgrp_id=_from.flgrp_id)
57280
 
             AND  (flitem_flhead_id=_from.flhead_id))
57281
 
           UNION
57282
 
          SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord
57283
 
            FROM flgrp
57284
 
           WHERE ((flgrp_flgrp_id=_from.flgrp_id)
57285
 
             AND  (flgrp_flhead_id=_from.flhead_id))
57286
 
           UNION
57287
 
          SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord
57288
 
            FROM flspec
57289
 
           WHERE ((flspec_flgrp_id=_from.flgrp_id)
57290
 
             AND  (flspec_flhead_id=_from.flhead_id)) ) AS data
57291
 
   WHERE (ord > _from.ord)
57292
 
   ORDER BY ord
57293
 
   LIMIT 1;
57294
 
  IF (FOUND) THEN
57295
 
    UPDATE flgrp
57296
 
       SET flgrp_order=_to.ord
57297
 
     WHERE (flgrp_id=_from.id);
57298
 
 
57299
 
    IF (_to.type='I') THEN
57300
 
      UPDATE flitem
57301
 
         SET flitem_order=_from.ord
57302
 
       WHERE (flitem_id=_to.id);
57303
 
    ELSE
57304
 
      IF (_to.type='G') THEN
57305
 
        UPDATE flgrp
57306
 
           SET flgrp_order=_from.ord
57307
 
         WHERE (flgrp_id=_to.id);
57308
 
      ELSE
57309
 
        IF (_to.type='S') THEN
57310
 
          UPDATE flspec
57311
 
             SET flspec_order=_from.ord
57312
 
           WHERE (flspec_id=_to.id);
57313
 
        END IF;
57314
 
      END IF;
57315
 
    END IF;
57316
 
  END IF;
57317
 
 
57318
 
  RETURN 0;
57319
 
 
57320
 
END;
57321
 
$_$;
57322
 
 
57323
 
 
57324
 
ALTER FUNCTION public.moveflgroupdown(integer) OWNER TO admin;
57325
 
 
57326
 
--
57327
 
--
57328
 
 
57329
 
CREATE FUNCTION moveflgroupup(integer) RETURNS integer
57330
 
    LANGUAGE plpgsql
57331
 
    AS $_$
57332
 
DECLARE
57333
 
  pFlgrpid ALIAS FOR $1;
57334
 
  _from RECORD;
57335
 
  _to RECORD;
57336
 
 
57337
 
BEGIN
57338
 
 
57339
 
  SELECT flgrp_id AS id,
57340
 
         flgrp_flhead_id AS flhead_id,
57341
 
         flgrp_flgrp_id AS flgrp_id,
57342
 
         flgrp_order AS ord INTO _from
57343
 
    FROM flgrp
57344
 
   WHERE (flgrp_id=pFlgrpid);
57345
 
  IF (NOT FOUND) THEN
57346
 
    RETURN -1;
57347
 
  END IF;
57348
 
 
57349
 
  SELECT id, type, ord INTO _to
57350
 
    FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord
57351
 
            FROM flitem
57352
 
           WHERE ((flitem_flgrp_id=_from.flgrp_id)
57353
 
             AND  (flitem_flhead_id=_from.flhead_id))
57354
 
           UNION
57355
 
          SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord
57356
 
            FROM flgrp
57357
 
           WHERE ((flgrp_flgrp_id=_from.flgrp_id)
57358
 
             AND  (flgrp_flhead_id=_from.flhead_id))
57359
 
           UNION
57360
 
          SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord
57361
 
            FROM flspec
57362
 
           WHERE ((flspec_flgrp_id=_from.flgrp_id)
57363
 
             AND  (flspec_flhead_id=_from.flhead_id)) ) AS data
57364
 
   WHERE (ord < _from.ord)
57365
 
   ORDER BY ord DESC
57366
 
   LIMIT 1;
57367
 
  IF (FOUND) THEN
57368
 
    UPDATE flgrp
57369
 
       SET flgrp_order=_to.ord
57370
 
     WHERE (flgrp_id=_from.id);
57371
 
 
57372
 
    IF (_to.type='I') THEN
57373
 
      UPDATE flitem
57374
 
         SET flitem_order=_from.ord
57375
 
       WHERE (flitem_id=_to.id);
57376
 
    ELSE
57377
 
      IF (_to.type='G') THEN
57378
 
        UPDATE flgrp
57379
 
           SET flgrp_order=_from.ord
57380
 
         WHERE (flgrp_id=_to.id);
57381
 
      ELSE
57382
 
        IF (_to.type='S') THEN
57383
 
          UPDATE flspec
57384
 
             SET flspec_order=_from.ord
57385
 
           WHERE (flspec_id=_to.id);
57386
 
        END IF;
57387
 
      END IF;
57388
 
    END IF;
57389
 
  END IF;
57390
 
 
57391
 
  RETURN 0;
57392
 
 
57393
 
END;
57394
 
$_$;
57395
 
 
57396
 
 
57397
 
ALTER FUNCTION public.moveflgroupup(integer) OWNER TO admin;
57398
 
 
57399
 
--
57400
 
--
57401
 
 
57402
 
CREATE FUNCTION moveflitemdown(integer) RETURNS integer
57403
 
    LANGUAGE plpgsql
57404
 
    AS $_$
57405
 
DECLARE
57406
 
  pFlitemid ALIAS FOR $1;
57407
 
  _from RECORD;
57408
 
  _to RECORD;
57409
 
 
57410
 
BEGIN
57411
 
 
57412
 
  SELECT flitem_id AS id,
57413
 
         flitem_flhead_id AS flhead_id,
57414
 
         flitem_flgrp_id AS flgrp_id,
57415
 
         flitem_order AS ord INTO _from
57416
 
    FROM flitem
57417
 
   WHERE (flitem_id=pFlitemid);
57418
 
  IF (NOT FOUND) THEN
57419
 
    RETURN -1;
57420
 
  END IF;
57421
 
 
57422
 
  SELECT id, type, ord INTO _to
57423
 
    FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord
57424
 
            FROM flitem
57425
 
           WHERE ((flitem_flgrp_id=_from.flgrp_id)
57426
 
             AND  (flitem_flhead_id=_from.flhead_id))
57427
 
           UNION
57428
 
          SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord
57429
 
            FROM flgrp
57430
 
           WHERE ((flgrp_flgrp_id=_from.flgrp_id)
57431
 
             AND  (flgrp_flhead_id=_from.flhead_id))
57432
 
           UNION
57433
 
          SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord
57434
 
            FROM flspec
57435
 
           WHERE ((flspec_flgrp_id=_from.flgrp_id)
57436
 
             AND  (flspec_flhead_id=_from.flhead_id)) ) AS data
57437
 
   WHERE (ord > _from.ord)
57438
 
   ORDER BY ord
57439
 
   LIMIT 1;
57440
 
  IF (FOUND) THEN
57441
 
    UPDATE flitem
57442
 
       SET flitem_order=_to.ord
57443
 
     WHERE (flitem_id=_from.id);
57444
 
 
57445
 
    IF (_to.type='I') THEN
57446
 
      UPDATE flitem
57447
 
         SET flitem_order=_from.ord
57448
 
       WHERE (flitem_id=_to.id);
57449
 
    ELSE
57450
 
      IF (_to.type='G') THEN
57451
 
        UPDATE flgrp
57452
 
           SET flgrp_order=_from.ord
57453
 
         WHERE (flgrp_id=_to.id);
57454
 
      ELSE
57455
 
        IF (_to.type='S') THEN
57456
 
          UPDATE flspec
57457
 
             SET flspec_order=_from.ord
57458
 
           WHERE (flspec_id=_to.id);
57459
 
        END IF;
57460
 
      END IF;
57461
 
    END IF;
57462
 
  END IF;
57463
 
 
57464
 
  RETURN 0;
57465
 
 
57466
 
END;
57467
 
$_$;
57468
 
 
57469
 
 
57470
 
ALTER FUNCTION public.moveflitemdown(integer) OWNER TO admin;
57471
 
 
57472
 
--
57473
 
--
57474
 
 
57475
 
CREATE FUNCTION moveflitemup(integer) RETURNS integer
57476
 
    LANGUAGE plpgsql
57477
 
    AS $_$
57478
 
DECLARE
57479
 
  pFlitemid ALIAS FOR $1;
57480
 
  _from RECORD;
57481
 
  _to RECORD;
57482
 
 
57483
 
BEGIN
57484
 
 
57485
 
  SELECT flitem_id AS id,
57486
 
         flitem_flhead_id AS flhead_id,
57487
 
         flitem_flgrp_id AS flgrp_id,
57488
 
         flitem_order AS ord INTO _from
57489
 
    FROM flitem
57490
 
   WHERE (flitem_id=pFlitemid);
57491
 
  IF (NOT FOUND) THEN
57492
 
    RETURN -1;
57493
 
  END IF;
57494
 
 
57495
 
  SELECT id, type, ord INTO _to
57496
 
    FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord
57497
 
            FROM flitem
57498
 
           WHERE ((flitem_flgrp_id=_from.flgrp_id)
57499
 
             AND  (flitem_flhead_id=_from.flhead_id))
57500
 
           UNION
57501
 
          SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord
57502
 
            FROM flgrp
57503
 
           WHERE ((flgrp_flgrp_id=_from.flgrp_id)
57504
 
             AND  (flgrp_flhead_id=_from.flhead_id))
57505
 
           UNION
57506
 
          SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord
57507
 
            FROM flspec
57508
 
           WHERE ((flspec_flgrp_id=_from.flgrp_id)
57509
 
             AND  (flspec_flhead_id=_from.flhead_id)) ) AS data
57510
 
   WHERE (ord < _from.ord)
57511
 
   ORDER BY ord DESC
57512
 
   LIMIT 1;
57513
 
  IF (FOUND) THEN
57514
 
    UPDATE flitem
57515
 
       SET flitem_order=_to.ord
57516
 
     WHERE (flitem_id=_from.id);
57517
 
 
57518
 
    IF (_to.type='I') THEN
57519
 
      UPDATE flitem
57520
 
         SET flitem_order=_from.ord
57521
 
       WHERE (flitem_id=_to.id);
57522
 
    ELSE
57523
 
      IF (_to.type='G') THEN
57524
 
        UPDATE flgrp
57525
 
           SET flgrp_order=_from.ord
57526
 
         WHERE (flgrp_id=_to.id);
57527
 
      ELSE
57528
 
        IF (_to.type='S') THEN
57529
 
          UPDATE flspec
57530
 
             SET flspec_order=_from.ord
57531
 
           WHERE (flspec_id=_to.id);
57532
 
        END IF;
57533
 
      END IF;
57534
 
    END IF;
57535
 
  END IF;
57536
 
 
57537
 
  RETURN 0;
57538
 
 
57539
 
END;
57540
 
$_$;
57541
 
 
57542
 
 
57543
 
ALTER FUNCTION public.moveflitemup(integer) OWNER TO admin;
57544
 
 
57545
 
--
57546
 
--
57547
 
 
57548
 
CREATE FUNCTION moveflspecdown(integer) RETURNS integer
57549
 
    LANGUAGE plpgsql
57550
 
    AS $_$
57551
 
DECLARE
57552
 
  pFlspecid ALIAS FOR $1;
57553
 
  _from RECORD;
57554
 
  _to RECORD;
57555
 
 
57556
 
BEGIN
57557
 
 
57558
 
  SELECT flspec_id AS id,
57559
 
         flspec_flhead_id AS flhead_id,
57560
 
         flspec_flgrp_id AS flgrp_id,
57561
 
         flspec_order AS ord INTO _from
57562
 
    FROM flspec
57563
 
   WHERE (flspec_id=pFlspecid);
57564
 
  IF (NOT FOUND) THEN
57565
 
    RETURN -1;
57566
 
  END IF;
57567
 
 
57568
 
  SELECT id, type, ord INTO _to
57569
 
    FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord
57570
 
            FROM flitem
57571
 
           WHERE ((flitem_flgrp_id=_from.flgrp_id)
57572
 
             AND  (flitem_flhead_id=_from.flhead_id))
57573
 
           UNION
57574
 
          SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord
57575
 
            FROM flgrp
57576
 
           WHERE ((flgrp_flgrp_id=_from.flgrp_id)
57577
 
             AND  (flgrp_flhead_id=_from.flhead_id))
57578
 
           UNION
57579
 
          SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord
57580
 
            FROM flspec
57581
 
           WHERE ((flspec_flgrp_id=_from.flgrp_id)
57582
 
             AND  (flspec_flhead_id=_from.flhead_id)) ) AS data
57583
 
   WHERE (ord > _from.ord)
57584
 
   ORDER BY ord
57585
 
   LIMIT 1;
57586
 
  IF (FOUND) THEN
57587
 
    UPDATE flspec
57588
 
       SET flspec_order=_to.ord
57589
 
     WHERE (flspec_id=_from.id);
57590
 
 
57591
 
    IF (_to.type='I') THEN
57592
 
      UPDATE flitem
57593
 
         SET flitem_order=_from.ord
57594
 
       WHERE (flitem_id=_to.id);
57595
 
    ELSE
57596
 
      IF (_to.type='G') THEN
57597
 
        UPDATE flgrp
57598
 
           SET flgrp_order=_from.ord
57599
 
         WHERE (flgrp_id=_to.id);
57600
 
      ELSE
57601
 
        IF (_to.type='S') THEN
57602
 
          UPDATE flspec
57603
 
             SET flspec_order=_from.ord
57604
 
           WHERE (flspec_id=_to.id);
57605
 
        END IF;
57606
 
      END IF;
57607
 
    END IF;
57608
 
  END IF;
57609
 
 
57610
 
  RETURN 0;
57611
 
 
57612
 
END;
57613
 
$_$;
57614
 
 
57615
 
 
57616
 
ALTER FUNCTION public.moveflspecdown(integer) OWNER TO admin;
57617
 
 
57618
 
--
57619
 
--
57620
 
 
57621
 
CREATE FUNCTION moveflspecup(integer) RETURNS integer
57622
 
    LANGUAGE plpgsql
57623
 
    AS $_$
57624
 
DECLARE
57625
 
  pFlspecid ALIAS FOR $1;
57626
 
  _from RECORD;
57627
 
  _to RECORD;
57628
 
 
57629
 
BEGIN
57630
 
 
57631
 
  SELECT flspec_id AS id,
57632
 
         flspec_flhead_id AS flhead_id,
57633
 
         flspec_flgrp_id AS flgrp_id,
57634
 
         flspec_order AS ord INTO _from
57635
 
    FROM flspec
57636
 
   WHERE (flspec_id=pFlspecid);
57637
 
  IF (NOT FOUND) THEN
57638
 
    RETURN -1;
57639
 
  END IF;
57640
 
 
57641
 
  SELECT id, type, ord INTO _to
57642
 
    FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord
57643
 
            FROM flitem
57644
 
           WHERE ((flitem_flgrp_id=_from.flgrp_id)
57645
 
             AND  (flitem_flhead_id=_from.flhead_id))
57646
 
           UNION
57647
 
          SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord
57648
 
            FROM flgrp
57649
 
           WHERE ((flgrp_flgrp_id=_from.flgrp_id)
57650
 
             AND  (flgrp_flhead_id=_from.flhead_id))
57651
 
           UNION
57652
 
          SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord
57653
 
            FROM flspec
57654
 
           WHERE ((flspec_flgrp_id=_from.flgrp_id)
57655
 
             AND  (flspec_flhead_id=_from.flhead_id)) ) AS data
57656
 
   WHERE (ord < _from.ord)
57657
 
   ORDER BY ord DESC
57658
 
   LIMIT 1;
57659
 
  IF (FOUND) THEN
57660
 
    UPDATE flspec
57661
 
       SET flspec_order=_to.ord
57662
 
     WHERE (flspec_id=_from.id);
57663
 
 
57664
 
    IF (_to.type='I') THEN
57665
 
      UPDATE flitem
57666
 
         SET flitem_order=_from.ord
57667
 
       WHERE (flitem_id=_to.id);
57668
 
    ELSE
57669
 
      IF (_to.type='G') THEN
57670
 
        UPDATE flgrp
57671
 
           SET flgrp_order=_from.ord
57672
 
         WHERE (flgrp_id=_to.id);
57673
 
      ELSE
57674
 
        IF (_to.type='S') THEN
57675
 
          UPDATE flspec
57676
 
             SET flspec_order=_from.ord
57677
 
           WHERE (flspec_id=_to.id);
57678
 
        END IF;
57679
 
      END IF;
57680
 
    END IF;
57681
 
  END IF;
57682
 
 
57683
 
  RETURN 0;
57684
 
 
57685
 
END;
57686
 
$_$;
57687
 
 
57688
 
 
57689
 
ALTER FUNCTION public.moveflspecup(integer) OWNER TO admin;
57690
 
 
57691
 
--
57692
 
--
57693
 
 
57694
 
CREATE FUNCTION movescript(integer, integer, integer) RETURNS integer
57695
 
    LANGUAGE plpgsql
57696
 
    AS $_$
57697
 
DECLARE
57698
 
  pscriptid ALIAS FOR $1;
57699
 
  poldpkgid ALIAS FOR $2;
57700
 
  pnewpkgid ALIAS FOR $3;
57701
 
 
57702
 
  _deletestr    TEXT;
57703
 
  _destination  TEXT;
57704
 
  _insertstr    TEXT;
57705
 
  _rows         INTEGER;
57706
 
  _selectstr    TEXT;
57707
 
  _source       TEXT;
57708
 
  _record       RECORD;
57709
 
 
57710
 
BEGIN
57711
 
  IF (poldpkgid = pnewpkgid) THEN
57712
 
    RETURN 0;
57713
 
  END IF;
57714
 
 
57715
 
  IF (poldpkgid = -1) THEN
57716
 
    _source = 'public.script';
57717
 
  ELSE
57718
 
    SELECT pkghead_name || '.pkgscript' INTO _source
57719
 
    FROM pkghead
57720
 
    WHERE pkghead_id=poldpkgid;
57721
 
 
57722
 
    IF NOT FOUND THEN
57723
 
      RETURN -1;
57724
 
    END IF;
57725
 
  END IF;
57726
 
 
57727
 
  IF (pnewpkgid = -1) THEN
57728
 
    _destination = 'public.script';
57729
 
  ELSE
57730
 
    SELECT pkghead_name || '.pkgscript' INTO _destination
57731
 
    FROM pkghead
57732
 
    WHERE pkghead_id=pnewpkgid;
57733
 
 
57734
 
    IF NOT FOUND THEN
57735
 
      RETURN -2;
57736
 
    END IF;
57737
 
  END IF;
57738
 
 
57739
 
  _selectstr := ' SELECT * FROM ' || _source ||
57740
 
                ' WHERE script_id = ' || pscriptid;
57741
 
  EXECUTE _selectstr INTO _record;
57742
 
 
57743
 
  _deletestr := 'DELETE FROM ONLY ' || _source || 
57744
 
                ' WHERE script_id = ' || pscriptid;
57745
 
  EXECUTE _deletestr;
57746
 
  GET DIAGNOSTICS _rows = ROW_COUNT;
57747
 
  RAISE NOTICE '% rows from %', _rows, _deletestr;
57748
 
  IF (_rows < 1) THEN
57749
 
    RETURN -3;
57750
 
  ELSIF (_rows > 1) THEN
57751
 
    RAISE EXCEPTION 'Tried to delete % scripts with the id % when there should be exactly 1',
57752
 
                    _rows, pscriptid;
57753
 
  END IF;
57754
 
 
57755
 
  _insertstr := 'INSERT INTO ' || _destination ||
57756
 
                ' (script_id, script_name, script_order, script_enabled, ' ||
57757
 
                '  script_source, script_notes) VALUES ('
57758
 
                || _record.script_id      || ','
57759
 
                || quote_literal(_record.script_name)    || ','
57760
 
                || _record.script_order   || ','
57761
 
                || _record.script_enabled || ','
57762
 
                || quote_literal(_record.script_source)  || ','
57763
 
                || quote_literal(_record.script_notes )  || ');'
57764
 
                ;
57765
 
  EXECUTE _insertstr;
57766
 
  GET DIAGNOSTICS _rows = ROW_COUNT;
57767
 
  RAISE NOTICE '% rows from %', _rows, _insertstr;
57768
 
  IF (_rows < 1) THEN
57769
 
    RETURN -4;
57770
 
  ELSIF (_rows > 1) THEN
57771
 
    RAISE EXCEPTION 'Tried to insert % scripts with the id % when there should be exactly 1',
57772
 
                    _rows, pscriptid;
57773
 
  END IF;
57774
 
 
57775
 
  RETURN pscriptid;
57776
 
 
57777
 
END;
57778
 
$_$;
57779
 
 
57780
 
 
57781
 
ALTER FUNCTION public.movescript(integer, integer, integer) OWNER TO admin;
57782
 
 
57783
 
--
57784
 
--
57785
 
 
57786
 
CREATE FUNCTION moveuiform(integer, integer, integer) RETURNS integer
57787
 
    LANGUAGE plpgsql
57788
 
    AS $_$
57789
 
DECLARE
57790
 
  puiformid ALIAS FOR $1;
57791
 
  poldpkgid ALIAS FOR $2;
57792
 
  pnewpkgid ALIAS FOR $3;
57793
 
 
57794
 
  _deletestr    TEXT;
57795
 
  _destination  TEXT;
57796
 
  _insertstr    TEXT;
57797
 
  _rows         INTEGER;
57798
 
  _selectstr    TEXT;
57799
 
  _source       TEXT;
57800
 
  _record       RECORD;
57801
 
 
57802
 
BEGIN
57803
 
  IF (poldpkgid = pnewpkgid) THEN
57804
 
    RETURN 0;
57805
 
  END IF;
57806
 
 
57807
 
  IF (poldpkgid = -1) THEN
57808
 
    _source = 'public.uiform';
57809
 
  ELSE
57810
 
    SELECT pkghead_name || '.pkguiform' INTO _source
57811
 
    FROM pkghead
57812
 
    WHERE pkghead_id=poldpkgid;
57813
 
 
57814
 
    IF NOT FOUND THEN
57815
 
      RETURN -1;
57816
 
    END IF;
57817
 
  END IF;
57818
 
 
57819
 
  IF (pnewpkgid = -1) THEN
57820
 
    _destination = 'public.uiform';
57821
 
  ELSE
57822
 
    SELECT pkghead_name || '.pkguiform' INTO _destination
57823
 
    FROM pkghead
57824
 
    WHERE pkghead_id=pnewpkgid;
57825
 
 
57826
 
    IF NOT FOUND THEN
57827
 
      RETURN -2;
57828
 
    END IF;
57829
 
  END IF;
57830
 
 
57831
 
  _selectstr := ' SELECT * FROM ' || _source ||
57832
 
                ' WHERE uiform_id = ' || puiformid;
57833
 
  EXECUTE _selectstr INTO _record;
57834
 
 
57835
 
  _deletestr := 'DELETE FROM ONLY ' || _source || 
57836
 
                ' WHERE uiform_id = ' || puiformid;
57837
 
  EXECUTE _deletestr;
57838
 
  GET DIAGNOSTICS _rows = ROW_COUNT;
57839
 
  RAISE NOTICE '% rows from %', _rows, _deletestr;
57840
 
  IF (_rows < 1) THEN
57841
 
    RETURN -3;
57842
 
  ELSIF (_rows > 1) THEN
57843
 
    RAISE EXCEPTION 'Tried to delete % uiforms with the id % when there should be exactly 1',
57844
 
                    _rows, puiformid;
57845
 
  END IF;
57846
 
 
57847
 
  _insertstr := 'INSERT INTO ' || _destination ||
57848
 
                ' (uiform_id, uiform_name, uiform_order, uiform_enabled, ' ||
57849
 
                '  uiform_source, uiform_notes) VALUES ('
57850
 
                || _record.uiform_id      || ','
57851
 
                || quote_literal(_record.uiform_name)    || ','
57852
 
                || _record.uiform_order   || ','
57853
 
                || _record.uiform_enabled || ','
57854
 
                || quote_literal(_record.uiform_source)  || ','
57855
 
                || quote_literal(_record.uiform_notes )  || ');'
57856
 
                ;
57857
 
  EXECUTE _insertstr;
57858
 
  GET DIAGNOSTICS _rows = ROW_COUNT;
57859
 
  RAISE NOTICE '% rows from %', _rows, _insertstr;
57860
 
  IF (_rows < 1) THEN
57861
 
    RETURN -4;
57862
 
  ELSIF (_rows > 1) THEN
57863
 
    RAISE EXCEPTION 'Tried to insert % uiforms with the id % when there should be exactly 1',
57864
 
                    _rows, puiformid;
57865
 
  END IF;
57866
 
 
57867
 
  RETURN puiformid;
57868
 
 
57869
 
END;
57870
 
$_$;
57871
 
 
57872
 
 
57873
 
ALTER FUNCTION public.moveuiform(integer, integer, integer) OWNER TO admin;
57874
 
 
57875
 
--
57876
 
--
57877
 
 
57878
 
CREATE FUNCTION moveupdown(pid integer, pschema text, ptable text, pseqcol text, pjoincol text, pextra text, pdir text) RETURNS integer
57879
 
    LANGUAGE plpgsql
57880
 
    AS $_$
57881
 
DECLARE
57882
 
  _keyfield TEXT;
57883
 
  _keysize  INTEGER;
57884
 
  _qry      TEXT;
57885
 
  _r        RECORD;
57886
 
  _rowcnt   INTEGER;
57887
 
  _schema   TEXT := COALESCE(pSchema, 'public');
57888
 
BEGIN
57889
 
  RAISE DEBUG 'moveUpDown(%, %, %, %, %, %, %) entered',
57890
 
              pId, pSchema, pTable, pSeqCol, pJoinCol, pExtra, pDir;
57891
 
 
57892
 
  IF (UPPER(pDir) NOT IN ('UP', 'DOWN')) THEN
57893
 
     RAISE EXCEPTION 'Cannot change the order of records; unsure what % means for sequencing [xtuple: moveUpDown, -1, %, %.%]',
57894
 
                     pDir, pDir, _schema, pTable;
57895
 
  END IF;
57896
 
 
57897
 
  SELECT attname, ARRAY_UPPER(conkey, 1) INTO _keyfield, _keysize
57898
 
    FROM pg_attribute
57899
 
    JOIN pg_constraint ON (attrelid=conrelid AND attnum=conkey[1])
57900
 
    JOIN pg_class      ON (conrelid=pg_class.oid)
57901
 
    JOIN pg_namespace  ON (relnamespace=pg_namespace.oid)
57902
 
   WHERE ((contype='p')
57903
 
      AND (nspname=_schema)
57904
 
      AND (relname=pTable));
57905
 
 
57906
 
  RAISE DEBUG 'SELECT attname... returned %, %', _keyfield, _keysize;
57907
 
 
57908
 
  IF (_keysize > 1) THEN
57909
 
    RAISE EXCEPTION 'Cannot change the order of records because %.% has a composite primary key [xtuple: moveUpDown, -2, %.%]',
57910
 
                     _schema, pTable,
57911
 
                     _schema, pTable;
57912
 
  END IF;
57913
 
 
57914
 
  /* SELECT next._keyfield AS nextid,
57915
 
            next.pSeqCol   AS nextseq,
57916
 
            this.pSeqCol   AS thisseq
57917
 
       FROM _schema.pTable AS next,
57918
 
            _schema.pTable AS this
57919
 
      WHERE (this._keyfield=$1)
57920
 
          AND (next.pSeqCol [> or <] this.pSeqCol)
57921
 
        [ AND (next.pJoinCol=this.pJoinCol) ]
57922
 
        [ AND (pExtra) ]
57923
 
      ORDER BY nextseq [ DESC or ASC ]
57924
 
      LIMIT 1;
57925
 
  */
57926
 
 
57927
 
  _qry := 'SELECT next.' || quote_ident(_keyfield) || ' AS nextid,
57928
 
                  next.' || quote_ident(pSeqCol)   || ' AS nextseq,
57929
 
                  this.' || quote_ident(pSeqCol)   || ' AS thisseq
57930
 
             FROM ' || _schema || '.' || quote_ident(pTable) || ' AS next,
57931
 
                  ' || _schema || '.' || quote_ident(pTable) || ' AS this
57932
 
            WHERE ((this.' || quote_ident(_keyfield)  || '=$1)
57933
 
               AND (next.' || quote_ident(pSeqCol)    ||
57934
 
                    CASE pDir WHEN 'UP' THEN ' < ' ELSE ' > ' END ||
57935
 
                   'this.' || quote_ident(pSeqCol) || ')' ||
57936
 
               CASE WHEN pJoinCol IS NULL THEN ''
57937
 
                    ELSE ' AND (next.' || quote_ident(pJoinCol)  ||
57938
 
                         '=this.' || quote_ident(pJoinCol) || ')'
57939
 
               END ||
57940
 
          '     AND (' || COALESCE(pExtra, 'TRUE') || '))
57941
 
            ORDER BY nextseq ' ||
57942
 
               CASE pDir WHEN 'UP' THEN 'DESC' ELSE 'ASC' END ||
57943
 
          ' LIMIT 1;';
57944
 
  RAISE DEBUG 'moveUpDown about to use % when running %', pId, _qry;
57945
 
 
57946
 
  EXECUTE _qry INTO _r USING pId;
57947
 
  GET DIAGNOSTICS _rowcnt = ROW_COUNT;
57948
 
  RAISE DEBUG 'next id %, next seq %, this id %, this seq %',
57949
 
               _r.nextid, _r.nextseq, pId, _r.thisseq;
57950
 
 
57951
 
  IF (_rowcnt > 0) THEN
57952
 
    _qry := 'UPDATE ' || _schema || '.' || quote_ident(pTable)  ||
57953
 
              ' SET ' || pSeqCol || '=CAST($1 AS INTEGER)
57954
 
             WHERE (' || quote_ident(_keyfield) || '=$2);';
57955
 
 
57956
 
    EXECUTE _qry USING -1,         _r.nextid;
57957
 
    EXECUTE _qry USING _r.nextseq, pId;
57958
 
    EXECUTE _qry USING _r.thisseq, _r.nextid;
57959
 
    RETURN _r.nextid;
57960
 
  END IF;
57961
 
 
57962
 
  RETURN pId;
57963
 
END;
57964
 
$_$;
57965
 
 
57966
 
 
57967
 
ALTER FUNCTION public.moveupdown(pid integer, pschema text, ptable text, pseqcol text, pjoincol text, pextra text, pdir text) OWNER TO admin;
57968
 
 
57969
 
--
57970
 
--
57971
 
 
57972
 
COMMENT ON FUNCTION moveupdown(pid integer, pschema text, ptable text, pseqcol text, pjoincol text, pextra text, pdir text) IS 'moveUpDown moves a particular record up or down in an ordered list.
57973
 
      pId argument names the record to move.
57974
 
      pSchema (uses public if NULL) and pTable name the table holding the list.
57975
 
      pSeqCol is the column that holds the sequence number.
57976
 
      pJoinCol is the column that distinguishes one list from another in the same table, or NULL if the table holds only one list.
57977
 
      pExtra is an extra join clause that may be required, or NULL.
57978
 
      pDir is either UP, meaning move the pId record closer to the beginning,
57979
 
                or DOWN.
57980
 
Returns the id of the record with which pId was swapped,
57981
 
      or pId if the record was already at the end in the specified direction.';
57982
 
 
57983
 
 
57984
 
--
57985
 
--
57986
 
 
57987
 
CREATE FUNCTION nextperiodbyinterval(integer, integer) RETURNS integer
57988
 
    LANGUAGE plpgsql
57989
 
    AS $_$
57990
 
DECLARE
57991
 
  pPeriodid ALIAS FOR $1;
57992
 
  pInterval ALIAS FOR $2;
57993
 
  _periodid INTEGER;
57994
 
BEGIN
57995
 
  SELECT b.period_id INTO _periodid
57996
 
    FROM period AS a, period AS b
57997
 
   WHERE ((a.period_id=pPeriodid)
57998
 
     AND  (b.period_start >= a.period_start))
57999
 
   ORDER BY b.period_start
58000
 
   LIMIT 1 OFFSET pInterval;
58001
 
  IF (NOT FOUND) THEN
58002
 
    RETURN -1;
58003
 
  END IF;
58004
 
  RETURN _periodid;
58005
 
END;
58006
 
$_$;
58007
 
 
58008
 
 
58009
 
ALTER FUNCTION public.nextperiodbyinterval(integer, integer) OWNER TO admin;
58010
 
 
58011
 
--
58012
 
--
58013
 
 
58014
 
CREATE FUNCTION nextprsubnumber(integer) RETURNS integer
58015
 
    LANGUAGE plpgsql
58016
 
    AS $_$
58017
 
DECLARE
58018
 
  pPrNumber ALIAS FOR $1;
58019
 
  _subNumber INTEGER;
58020
 
 
58021
 
BEGIN
58022
 
 
58023
 
  SELECT MAX(pr_subnumber) INTO _subNumber
58024
 
  FROM pr
58025
 
  WHERE (pr_number=pPrNumber);
58026
 
 
58027
 
  IF (_subNumber IS NULL)
58028
 
    THEN _subNumber := 0;
58029
 
  END IF;
58030
 
 
58031
 
  RETURN (_subNumber + 1);
58032
 
 
58033
 
END;
58034
 
$_$;
58035
 
 
58036
 
 
58037
 
ALTER FUNCTION public.nextprsubnumber(integer) OWNER TO admin;
58038
 
 
58039
 
--
58040
 
--
58041
 
 
58042
 
CREATE FUNCTION nextwosubnumber(integer) RETURNS integer
58043
 
    LANGUAGE sql
58044
 
    AS $_$
58045
 
SELECT COALESCE((MAX(wo_subnumber) + 1), 1)
58046
 
FROM wo
58047
 
WHERE (wo_number=($1));
58048
 
$_$;
58049
 
 
58050
 
 
58051
 
ALTER FUNCTION public.nextwosubnumber(integer) OWNER TO admin;
58052
 
 
58053
 
--
58054
 
--
58055
 
 
58056
 
CREATE FUNCTION noneg(numeric) RETURNS numeric
58057
 
    LANGUAGE plpgsql IMMUTABLE
58058
 
    AS $_$
58059
 
DECLARE
58060
 
  pValue ALIAS FOR $1;
58061
 
 
58062
 
BEGIN
58063
 
 
58064
 
  IF (pValue < 0) THEN
58065
 
    RETURN 0;
58066
 
  ELSE
58067
 
   RETURN pValue;
58068
 
  END IF;
58069
 
 
58070
 
END;
58071
 
$_$;
58072
 
 
58073
 
 
58074
 
ALTER FUNCTION public.noneg(numeric) OWNER TO admin;
58075
 
 
58076
 
--
58077
 
--
58078
 
 
58079
 
CREATE FUNCTION nopos(numeric) RETURNS numeric
58080
 
    LANGUAGE plpgsql IMMUTABLE
58081
 
    AS $_$
58082
 
DECLARE
58083
 
  pValue ALIAS FOR $1;
58084
 
 
58085
 
BEGIN
58086
 
 
58087
 
  IF (pValue > 0) THEN
58088
 
    RETURN 0;
58089
 
  ELSE
58090
 
   RETURN pValue;
58091
 
  END IF;
58092
 
 
58093
 
END;
58094
 
$_$;
58095
 
 
58096
 
 
58097
 
ALTER FUNCTION public.nopos(numeric) OWNER TO admin;
58098
 
 
58099
 
--
58100
 
--
58101
 
 
58102
 
CREATE FUNCTION normalizetrialbal(integer, character) RETURNS numeric
58103
 
    LANGUAGE plpgsql STABLE
58104
 
    AS $_$
58105
 
DECLARE
58106
 
  pTrialbalid ALIAS FOR $1;
58107
 
  pSide ALIAS FOR $2;
58108
 
  _value NUMERIC;
58109
 
  _r RECORD;
58110
 
 
58111
 
BEGIN
58112
 
 
58113
 
  SELECT accnt_type, trialbal_beginning, trialbal_ending INTO _r
58114
 
  FROM trialbal, accnt
58115
 
  WHERE ( (trialbal_accnt_id=accnt_id)
58116
 
   AND (trialbal_id=pTrialbalid) );
58117
 
  IF (NOT FOUND) THEN
58118
 
    RETURN -1;
58119
 
  END IF;
58120
 
 
58121
 
  IF (pSide = 'E') THEN
58122
 
    _value = _r.trialbal_ending;
58123
 
 
58124
 
  ELSE
58125
 
    _value = _r.trialbal_beginning;
58126
 
  END IF;
58127
 
 
58128
 
  IF (_r.accnt_type IN ('A', 'E')) THEN
58129
 
    _value := (_value * -1);
58130
 
  END IF;
58131
 
 
58132
 
  RETURN _value;
58133
 
 
58134
 
END;
58135
 
$_$;
58136
 
 
58137
 
 
58138
 
ALTER FUNCTION public.normalizetrialbal(integer, character) OWNER TO admin;
58139
 
 
58140
 
--
58141
 
--
58142
 
 
58143
 
CREATE FUNCTION numofdatabaseusers() RETURNS integer
58144
 
    LANGUAGE plpgsql
58145
 
    AS $$
58146
 
DECLARE
58147
 
  _count INTEGER;
58148
 
 
58149
 
BEGIN
58150
 
 
58151
 
  -- in version 9.2.0 the column "procpid" was changed to just "pid" Incident #21852
58152
 
  IF (compareversion('9.2.0') <= 0)
58153
 
  THEN
58154
 
  SELECT count(*)
58155
 
    INTO _count
58156
 
    FROM pg_stat_activity, pg_locks
58157
 
   WHERE((database=datid)
58158
 
     AND (classid=datid)
58159
 
     AND (objsubid=2)
58160
 
     AND (pg_stat_activity.pid = pg_backend_pid()));
58161
 
  ELSE
58162
 
  SELECT count(*)
58163
 
    INTO _count
58164
 
    FROM pg_stat_activity, pg_locks
58165
 
   WHERE((database=datid)
58166
 
     AND (classid=datid)
58167
 
     AND (objsubid=2)
58168
 
     AND (procpid = pg_backend_pid()));
58169
 
  END IF;
58170
 
 
58171
 
  IF (_count IS NULL) THEN
58172
 
    _count := 0;
58173
 
  END IF;
58174
 
 
58175
 
  RETURN _count;
58176
 
 
58177
 
END;
58178
 
$$;
58179
 
 
58180
 
 
58181
 
ALTER FUNCTION public.numofdatabaseusers() OWNER TO admin;
58182
 
 
58183
 
--
58184
 
--
58185
 
 
58186
 
CREATE FUNCTION numofserverusers() RETURNS integer
58187
 
    LANGUAGE plpgsql
58188
 
    AS $$
58189
 
DECLARE
58190
 
  _count INTEGER;
58191
 
 
58192
 
BEGIN
58193
 
 
58194
 
  SELECT COUNT(*) INTO _count
58195
 
  FROM pg_stat_activity;
58196
 
  IF (_count IS NULL) THEN
58197
 
    _count := 0;
58198
 
  END IF;
58199
 
 
58200
 
  RETURN _count;
58201
 
 
58202
 
END;
58203
 
$$;
58204
 
 
58205
 
 
58206
 
ALTER FUNCTION public.numofserverusers() OWNER TO admin;
58207
 
 
58208
 
--
58209
 
--
58210
 
 
58211
 
CREATE FUNCTION openaccountingperiod(integer) RETURNS integer
58212
 
    LANGUAGE plpgsql
58213
 
    AS $_$
58214
 
DECLARE
58215
 
  pPeriodid ALIAS FOR $1;
58216
 
  _r RECORD;
58217
 
 
58218
 
BEGIN
58219
 
 
58220
 
  IF ( ( SELECT (NOT period_closed)
58221
 
         FROM period
58222
 
         WHERE (period_id=pPeriodid) ) ) THEN
58223
 
    RETURN -1;
58224
 
  END IF;
58225
 
 
58226
 
  IF ( ( SELECT (count(period_id) > 0)
58227
 
           FROM period
58228
 
          WHERE ((period_end > (
58229
 
            SELECT period_end 
58230
 
            FROM period 
58231
 
            WHERE (period_id=pPeriodId))
58232
 
          )
58233
 
           AND (period_closed)) ) ) THEN
58234
 
    RETURN -3;
58235
 
  END IF;
58236
 
  
58237
 
  IF ( ( SELECT (yearperiod_closed)
58238
 
         FROM yearperiod
58239
 
           JOIN period ON (period_yearperiod_id=yearperiod_id)
58240
 
         WHERE (period_id=pPeriodid) ) ) THEN
58241
 
    RETURN -4;
58242
 
  END IF;
58243
 
 
58244
 
  UPDATE period
58245
 
  SET period_closed=FALSE
58246
 
  WHERE (period_id=pPeriodid);
58247
 
 
58248
 
  FOR _r IN SELECT DISTINCT gltrans_sequence
58249
 
            FROM gltrans, period
58250
 
            WHERE ( (NOT gltrans_posted)
58251
 
             AND (gltrans_date BETWEEN period_start AND period_end)
58252
 
             AND (period_id=pPeriodid) ) LOOP
58253
 
    PERFORM postIntoTrialBalance(_r.gltrans_sequence);
58254
 
  END LOOP;
58255
 
 
58256
 
  RETURN pPeriodid;
58257
 
 
58258
 
END;
58259
 
$_$;
58260
 
 
58261
 
 
58262
 
ALTER FUNCTION public.openaccountingperiod(integer) OWNER TO admin;
58263
 
 
58264
 
--
58265
 
--
58266
 
 
58267
 
CREATE FUNCTION openaccountingyearperiod(integer) RETURNS integer
58268
 
    LANGUAGE plpgsql
58269
 
    AS $_$
58270
 
DECLARE
58271
 
  pYearPeriodId ALIAS FOR $1;
58272
 
  _r RECORD;
58273
 
 
58274
 
BEGIN
58275
 
 
58276
 
  IF ( ( SELECT (NOT yearperiod_closed)
58277
 
         FROM yearperiod
58278
 
         WHERE (yearperiod_id=pYearPeriodId) ) ) THEN
58279
 
    RETURN -1;
58280
 
  END IF;
58281
 
 
58282
 
  IF ( ( SELECT (count(yearperiod_id) > 0)
58283
 
           FROM yearperiod
58284
 
          WHERE ((yearperiod_end> (
58285
 
            SELECT yearperiod_end 
58286
 
            FROM yearperiod 
58287
 
            WHERE (yearperiod_id=pYearPeriodId))
58288
 
          )
58289
 
           AND (yearperiod_closed)) ) ) THEN
58290
 
    RETURN -2;
58291
 
  END IF;
58292
 
 
58293
 
  UPDATE yearperiod
58294
 
  SET yearperiod_closed=FALSE
58295
 
  WHERE (yearperiod_id=pYearPeriodId);
58296
 
 
58297
 
  RETURN pYearPeriodid;
58298
 
 
58299
 
END;
58300
 
$_$;
58301
 
 
58302
 
 
58303
 
ALTER FUNCTION public.openaccountingyearperiod(integer) OWNER TO admin;
58304
 
 
58305
 
--
58306
 
--
58307
 
 
58308
 
CREATE FUNCTION openapitemsvalue(pvendid integer, pperiodid integer) RETURNS numeric
58309
 
    LANGUAGE plpgsql
58310
 
    AS $$
58311
 
DECLARE
58312
 
  _value NUMERIC;
58313
 
 
58314
 
BEGIN
58315
 
 
58316
 
  SELECT SUM( (apopen_amount - apopen_paid) / apopen_curr_rate *
58317
 
               CASE WHEN (apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END )
58318
 
               INTO _value
58319
 
  FROM apopen
58320
 
  WHERE ( (apopen_open)
58321
 
    AND   (apopen_vend_id=pVendid)
58322
 
    AND   (apopen_duedate BETWEEN findPeriodStart(pPeriodid) AND findPeriodEnd(pPeriodid)) );
58323
 
 
58324
 
  RETURN COALESCE(_value, 0.0);
58325
 
 
58326
 
END;
58327
 
$$;
58328
 
 
58329
 
 
58330
 
ALTER FUNCTION public.openapitemsvalue(pvendid integer, pperiodid integer) OWNER TO admin;
58331
 
 
58332
 
--
58333
 
--
58334
 
 
58335
 
CREATE FUNCTION openaritemsvalue(integer, integer) RETURNS numeric
58336
 
    LANGUAGE plpgsql
58337
 
    AS $_$
58338
 
DECLARE
58339
 
  pCustid ALIAS FOR $1;
58340
 
  pPeriodid ALIAS FOR $2;
58341
 
  _value NUMERIC;
58342
 
 
58343
 
BEGIN
58344
 
 
58345
 
  SELECT SUM( CASE WHEN (aropen_doctype IN ('C', 'R')) THEN ((aropen_amount - aropen_paid) * -1)
58346
 
                   ELSE (aropen_amount - aropen_paid)
58347
 
              END )  INTO _value
58348
 
  FROM aropen
58349
 
  WHERE ( (aropen_open)
58350
 
    AND (aropen_cust_id=pCustid)
58351
 
    AND (aropen_duedate BETWEEN findPeriodStart(pPeriodid) AND findPeriodEnd(pPeriodid)) );
58352
 
 
58353
 
  IF (_value IS NULL) THEN
58354
 
    _value := 0;
58355
 
  END IF;
58356
 
 
58357
 
  RETURN _value;
58358
 
 
58359
 
END;
58360
 
$_$;
58361
 
 
58362
 
 
58363
 
ALTER FUNCTION public.openaritemsvalue(integer, integer) OWNER TO admin;
58364
 
 
58365
 
--
58366
 
--
58367
 
 
58368
 
CREATE FUNCTION openrecurringitems(integer, text, timestamp with time zone) RETURNS integer
58369
 
    LANGUAGE plpgsql
58370
 
    AS $_$
58371
 
DECLARE
58372
 
  pParentid  ALIAS FOR $1;
58373
 
  pType      TEXT := UPPER($2);
58374
 
  pDatetime  TIMESTAMP WITH TIME ZONE := COALESCE($3, CURRENT_TIMESTAMP);
58375
 
 
58376
 
  _count     INTEGER := -1;
58377
 
  _countstmt TEXT;
58378
 
  _rt        RECORD;
58379
 
 
58380
 
BEGIN
58381
 
  IF (pParentid IS NULL) THEN
58382
 
    RETURN -11;
58383
 
  END IF;
58384
 
  
58385
 
  SELECT * INTO _rt FROM recurtype WHERE (UPPER(recurtype_type)=pType);
58386
 
  GET DIAGNOSTICS _count = ROW_COUNT;
58387
 
  IF (_count <= 0) THEN
58388
 
    RETURN -10;
58389
 
  END IF;
58390
 
 
58391
 
  _countstmt := 'SELECT COUNT(*) FROM [fulltable]'
58392
 
             || ' WHERE (NOT ([done])'
58393
 
             || '    AND ([schedcol]>=''$1'')'
58394
 
             || '    AND ([table]_recurring_[table]_id=''$2''));';
58395
 
  _countstmt := REPLACE(_countstmt, '[fulltable]',    _rt.recurtype_table);
58396
 
  _countstmt := REPLACE(_countstmt, '[table]',
58397
 
                        REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', ''));
58398
 
  _countstmt := REPLACE(_countstmt, '[done]',     _rt.recurtype_donecheck);
58399
 
  _countstmt := REPLACE(_countstmt, '[schedcol]', _rt.recurtype_schedcol);
58400
 
 
58401
 
  -- 8.4+: EXECUTE _countstmt INTO _count USING pDatetime, pParentid;
58402
 
  EXECUTE REPLACE(REPLACE(_countstmt, '$1', pDatetime::TEXT),
58403
 
                                      '$2', pParentid::TEXT) INTO _count;
58404
 
 
58405
 
  RETURN _count;
58406
 
END;
58407
 
$_$;
58408
 
 
58409
 
 
58410
 
ALTER FUNCTION public.openrecurringitems(integer, text, timestamp with time zone) OWNER TO admin;
58411
 
 
58412
 
--
58413
 
--
58414
 
 
58415
 
CREATE TABLE ophead (
58416
 
    ophead_id integer NOT NULL,
58417
 
    ophead_name text NOT NULL,
58418
 
    ophead_crmacct_id integer,
58419
 
    ophead_owner_username text,
58420
 
    ophead_opstage_id integer,
58421
 
    ophead_opsource_id integer,
58422
 
    ophead_optype_id integer,
58423
 
    ophead_probability_prcnt integer,
58424
 
    ophead_amount numeric(20,4),
58425
 
    ophead_target_date date,
58426
 
    ophead_actual_date date,
58427
 
    ophead_notes text,
58428
 
    ophead_curr_id integer,
58429
 
    ophead_active boolean DEFAULT true,
58430
 
    ophead_cntct_id integer,
58431
 
    ophead_username text,
58432
 
    ophead_start_date date,
58433
 
    ophead_assigned_date date,
58434
 
    ophead_priority_id integer,
58435
 
    ophead_number text NOT NULL,
58436
 
    CONSTRAINT ophead_ophead_number_check CHECK ((ophead_number <> ''::text))
58437
 
);
58438
 
 
58439
 
 
58440
 
ALTER TABLE public.ophead OWNER TO admin;
58441
 
 
58442
 
--
58443
 
--
58444
 
 
58445
 
COMMENT ON TABLE ophead IS 'Opportunity header.';
58446
 
 
58447
 
 
58448
 
--
58449
 
--
58450
 
 
58451
 
CREATE FUNCTION ophead() RETURNS SETOF ophead
58452
 
    LANGUAGE plpgsql
58453
 
    AS $$
58454
 
DECLARE
58455
 
  _row ophead%ROWTYPE;
58456
 
  _priv TEXT;
58457
 
  _grant BOOLEAN;
58458
 
 
58459
 
BEGIN
58460
 
  -- This query will give us the most permissive privilege the user has been granted
58461
 
  SELECT privilege, granted INTO _priv, _grant
58462
 
  FROM privgranted 
58463
 
  WHERE privilege IN ('MaintainAllOpportunities','ViewAllOpportunities','MaintainPersonalOpportunities','ViewPersonalOpportunities')
58464
 
  ORDER BY granted DESC, sequence
58465
 
  LIMIT 1;
58466
 
 
58467
 
  -- If have an 'All' privilege return all results
58468
 
  IF (_priv ~ 'All' AND _grant) THEN
58469
 
    FOR _row IN 
58470
 
      SELECT * FROM ophead
58471
 
    LOOP
58472
 
      RETURN NEXT _row;
58473
 
    END LOOP;
58474
 
  -- Otherwise if have any other grant, must be personal privilege.
58475
 
  ELSIF (_grant) THEN
58476
 
    FOR _row IN 
58477
 
      SELECT * FROM ophead 
58478
 
      WHERE getEffectiveXtUser() IN (ophead_owner_username, ophead_username)
58479
 
    LOOP
58480
 
      RETURN NEXT _row;
58481
 
    END LOOP;
58482
 
  END IF;
58483
 
 
58484
 
  RETURN;
58485
 
 
58486
 
END;
58487
 
$$;
58488
 
 
58489
 
 
58490
 
ALTER FUNCTION public.ophead() OWNER TO admin;
58491
 
 
58492
 
--
58493
 
--
58494
 
 
58495
 
COMMENT ON FUNCTION ophead() IS 'A table function that returns Opportunity results according to privilege settings.';
58496
 
 
58497
 
 
58498
 
--
58499
 
--
58500
 
 
58501
 
CREATE FUNCTION orderedbypo(integer, integer) RETURNS numeric
58502
 
    LANGUAGE plpgsql
58503
 
    AS $_$
58504
 
DECLARE
58505
 
  pItemsiteid ALIAS FOR $1;
58506
 
  pLookAhead ALIAS FOR $2;
58507
 
  _qty NUMERIC;
58508
 
 
58509
 
BEGIN
58510
 
 
58511
 
  SELECT orderedByPo(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookAhead)) INTO _qty;
58512
 
  RETURN _qty;
58513
 
 
58514
 
END;
58515
 
$_$;
58516
 
 
58517
 
 
58518
 
ALTER FUNCTION public.orderedbypo(integer, integer) OWNER TO admin;
58519
 
 
58520
 
--
58521
 
--
58522
 
 
58523
 
CREATE FUNCTION orderedbypo(integer, date, date) RETURNS numeric
58524
 
    LANGUAGE plpgsql
58525
 
    AS $_$
58526
 
DECLARE
58527
 
  pItemsiteid ALIAS FOR $1;
58528
 
  pStartDate ALIAS FOR $2;
58529
 
  pEndDate ALIAS FOR $3;
58530
 
  _qty NUMERIC;
58531
 
 
58532
 
BEGIN
58533
 
 
58534
 
  SELECT COALESCE(SUM(noNeg(poitem_qty_ordered - poitem_qty_received) * poitem_invvenduomratio), 0.0) INTO _qty
58535
 
  FROM poitem
58536
 
  WHERE ( (poitem_itemsite_id=pItemsiteid)
58537
 
    AND (poitem_status <> 'C')
58538
 
    AND (poitem_duedate BETWEEN pStartDate AND pEndDate) );
58539
 
 
58540
 
  RETURN _qty;
58541
 
 
58542
 
END;
58543
 
$_$;
58544
 
 
58545
 
 
58546
 
ALTER FUNCTION public.orderedbypo(integer, date, date) OWNER TO admin;
58547
 
 
58548
 
--
58549
 
--
58550
 
 
58551
 
CREATE FUNCTION orderedbywo(integer, integer) RETURNS numeric
58552
 
    LANGUAGE plpgsql
58553
 
    AS $_$
58554
 
DECLARE
58555
 
  pItemsiteid ALIAS FOR $1;
58556
 
  pLookAheadDays ALIAS FOR $2;
58557
 
 
58558
 
BEGIN
58559
 
 
58560
 
  RETURN orderedByWo(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookAheadDays));
58561
 
 
58562
 
END;
58563
 
$_$;
58564
 
 
58565
 
 
58566
 
ALTER FUNCTION public.orderedbywo(integer, integer) OWNER TO admin;
58567
 
 
58568
 
--
58569
 
--
58570
 
 
58571
 
CREATE FUNCTION orderedbywo(integer, date, date) RETURNS numeric
58572
 
    LANGUAGE plpgsql
58573
 
    AS $_$
58574
 
DECLARE
58575
 
  pItemsiteid ALIAS FOR $1;
58576
 
  pStartDate ALIAS FOR $2;
58577
 
  pEndDate ALIAS FOR $3;
58578
 
  _itemType CHARACTER(1);
58579
 
  _qty NUMERIC := 0;
58580
 
 
58581
 
BEGIN
58582
 
  SELECT item_type INTO _itemType
58583
 
  FROM itemsite, item
58584
 
  WHERE ( (itemsite_item_id=item_id)
58585
 
   AND (itemsite_id=pItemsiteid) );
58586
 
  
58587
 
  IF (_itemType NOT IN ('C','T')) THEN
58588
 
    SELECT COALESCE(SUM(noNeg(wo_qtyord - wo_qtyrcv)), 0.0) INTO _qty
58589
 
    FROM wo
58590
 
    WHERE ( (wo_status <> 'C')
58591
 
     AND (wo_itemsite_id=pItemsiteid)
58592
 
     AND (wo_duedate BETWEEN pStartDate AND pEndDate) );
58593
 
  ELSIF (_itemType = 'C') THEN
58594
 
    SELECT COALESCE(SUM((noNeg(wo_qtyord - wo_qtyrcv) * brddist_stdqtyper)), 0.0) INTO _qty
58595
 
    FROM wo, xtmfg.brddist
58596
 
    WHERE ( (wo_status <> 'C')
58597
 
     AND (brddist_wo_id=wo_id)
58598
 
     AND (brddist_itemsite_id=pItemsiteid)
58599
 
     AND (wo_duedate BETWEEN pStartDate AND pEndDate) );
58600
 
  ELSIF (_itemType = 'T' AND fetchMetricBool('Routings')) THEN -- Tooling:  Determine quantity already returned
58601
 
    SELECT
58602
 
      -- Qty Required
58603
 
      COALESCE(SUM(noNeg(womatl_qtyreq)),0)  - 
58604
 
      -- Qty Returned
58605
 
     (SELECT COALESCE(SUM(abs(invhist_invqty)),0) 
58606
 
      FROM wo
58607
 
        JOIN womatl ON (womatl_wo_id=wo_id)
58608
 
        JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)
58609
 
        JOIN invhist ON ((womatlpost_invhist_id=invhist_id)
58610
 
                     AND (invhist_invqty < 0))   
58611
 
      LEFT OUTER JOIN xtmfg.wooper ON (womatl_wooper_id=wooper_id)
58612
 
    WHERE ( NOT (COALESCE(wooper_rncomplete,wo_status = 'C'))
58613
 
     AND (womatl_itemsite_id=pItemsiteid)
58614
 
     AND (wo_duedate BETWEEN pStartDate AND pEndDate) )
58615
 
       )
58616
 
   INTO _qty
58617
 
    FROM wo
58618
 
      JOIN womatl ON (womatl_wo_id=wo_id)
58619
 
      LEFT OUTER JOIN xtmfg.wooper ON (womatl_wooper_id=wooper_id)
58620
 
    WHERE ( NOT (COALESCE(wooper_rncomplete,wo_status = 'C'))
58621
 
     AND (womatl_itemsite_id=pItemsiteid)
58622
 
     AND (wo_duedate BETWEEN pStartDate AND pEndDate) )
58623
 
    GROUP BY womatl_qtyreq;   
58624
 
  ELSIF (_itemType = 'T') THEN -- Tooling:  Determine quantity already returned
58625
 
    SELECT
58626
 
      -- Qty Required
58627
 
      COALESCE(SUM(noNeg(womatl_qtyreq)),0)  - 
58628
 
      -- Qty Returned
58629
 
     (SELECT COALESCE(SUM(abs(invhist_invqty)),0) 
58630
 
      FROM wo
58631
 
        JOIN womatl ON (womatl_wo_id=wo_id)
58632
 
        JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)
58633
 
        JOIN invhist ON ((womatlpost_invhist_id=invhist_id)
58634
 
                     AND (invhist_invqty < 0))
58635
 
    WHERE ( NOT (wo_status = 'C')
58636
 
     AND (womatl_itemsite_id=pItemsiteid)
58637
 
     AND (wo_duedate BETWEEN pStartDate AND pEndDate) )
58638
 
       )
58639
 
   INTO _qty
58640
 
    FROM wo
58641
 
      JOIN womatl ON (womatl_wo_id=wo_id)
58642
 
    WHERE ( NOT (wo_status = 'C')
58643
 
     AND (womatl_itemsite_id=pItemsiteid)
58644
 
     AND (wo_duedate BETWEEN pStartDate AND pEndDate) )
58645
 
    GROUP BY womatl_qtyreq;   
58646
 
  END IF;
58647
 
 
58648
 
  RETURN COALESCE(_qty,0);
58649
 
 
58650
 
END;
58651
 
$_$;
58652
 
 
58653
 
 
58654
 
ALTER FUNCTION public.orderedbywo(integer, date, date) OWNER TO admin;
58655
 
 
58656
 
--
58657
 
--
58658
 
 
58659
 
CREATE FUNCTION orderhead() RETURNS SETOF ordhead
58660
 
    LANGUAGE plpgsql
58661
 
    AS $$
58662
 
DECLARE
58663
 
  _row ordhead%ROWTYPE;
58664
 
  _query TEXT;
58665
 
BEGIN
58666
 
 
58667
 
  _query := '
58668
 
  SELECT DISTINCT * FROM (
58669
 
  SELECT pohead_id              AS orderhead_id,
58670
 
         ''PO''                 AS orderhead_type,
58671
 
         pohead_number          AS orderhead_number,
58672
 
         pohead_status          AS orderhead_status,
58673
 
         pohead_orderdate       AS orderhead_orderdate,
58674
 
         (SELECT count(*)
58675
 
           FROM poitem
58676
 
           WHERE poitem_pohead_id=pohead_id) AS orderhead_linecount,
58677
 
         pohead_vend_id         AS orderhead_from_id,
58678
 
         vend_name              AS orderhead_from,
58679
 
         NULL                   AS orderhead_to_id,
58680
 
         ''''                   AS orderhead_to,
58681
 
         pohead_curr_id         AS orderhead_curr_id,
58682
 
         pohead_agent_username  AS orderhead_agent_username,
58683
 
         pohead_shipvia         AS orderhead_shipvia
58684
 
  FROM pohead LEFT OUTER JOIN vendinfo ON (pohead_vend_id=vend_id)
58685
 
  UNION
58686
 
  SELECT cohead_id              AS orderhead_id,
58687
 
         ''SO''                 AS orderhead_type,
58688
 
         cohead_number          AS orderhead_number,
58689
 
         COALESCE(coitem_status,''C'') AS orderhead_status,
58690
 
         cohead_orderdate       AS orderhead_orderdate,
58691
 
         (SELECT count(*)
58692
 
           FROM coitem
58693
 
           WHERE coitem_cohead_id=cohead_id) AS orderhead_linecount,
58694
 
         NULL                   AS orderhead_from_id,
58695
 
         ''''                   AS orderhead_from,
58696
 
         cohead_cust_id         AS orderhead_to_id,
58697
 
         cust_name              AS orderhead_to,
58698
 
         cohead_curr_id         AS orderhead_curr_id,
58699
 
         ''''                   AS orderhead_agent_username,
58700
 
         cohead_shipvia         AS orderhead_shipvia
58701
 
  FROM cohead LEFT OUTER JOIN custinfo ON (cohead_cust_id=cust_id)
58702
 
              LEFT OUTER JOIN coitem ON ((cohead_id=coitem_cohead_id)
58703
 
                                     AND (coitem_status=''O''))';
58704
 
 
58705
 
  IF (fetchmetricbool('MultiWhs')) THEN
58706
 
    _query := _query || '
58707
 
    UNION
58708
 
    SELECT tohead_id            AS orderhead_id,
58709
 
         ''TO''                 AS orderhead_type,
58710
 
         tohead_number          AS orderhead_number,
58711
 
         tohead_status          AS orderhead_status,
58712
 
         tohead_orderdate       AS orderhead_orderdate,
58713
 
         (SELECT count(*)
58714
 
           FROM toitem
58715
 
           WHERE toitem_tohead_id=tohead_id) AS orderhead_linecount,
58716
 
         tohead_src_warehous_id  AS orderhead_from_id,
58717
 
         tohead_srcname         AS orderhead_from,
58718
 
         tohead_dest_warehous_id AS orderhead_to_id,
58719
 
         tohead_destname        AS orderhead_to,
58720
 
         tohead_freight_curr_id AS orderhead_curr_id,
58721
 
         tohead_agent_username  AS orderhead_agent_username,
58722
 
         tohead_shipvia         AS orderhead_shipvia
58723
 
    FROM tohead';
58724
 
  END IF;
58725
 
 
58726
 
  IF (fetchmetricbool('EnableReturnAuth')) THEN
58727
 
    _query := _query || '
58728
 
  UNION
58729
 
    SELECT rahead_id            AS orderhead_id,
58730
 
         ''RA''                 AS orderhead_type,
58731
 
         rahead_number          AS orderhead_number,
58732
 
         COALESCE(raitem_status,''C'') AS orderhead_status,
58733
 
         rahead_authdate        AS orderhead_orderdate,
58734
 
         (SELECT count(*)
58735
 
           FROM raitem
58736
 
           WHERE raitem_rahead_id=rahead_id) AS orderhead_linecount,
58737
 
         rahead_cust_id         AS orderhead_from_id,
58738
 
         cust_name              AS orderhead_from,
58739
 
         NULL                   AS orderhead_to_id,
58740
 
         ''''                   AS orderhead_to,
58741
 
         rahead_curr_id         AS orderhead_curr_id,
58742
 
         ''''                   AS orderhead_agent_username,
58743
 
         ''''                   AS orderhead_shipvia
58744
 
    FROM rahead LEFT OUTER JOIN custinfo ON (rahead_cust_id=cust_id)
58745
 
              LEFT OUTER JOIN raitem ON ((rahead_id=raitem_rahead_id)
58746
 
                                     AND (raitem_status=''O''))';
58747
 
  END IF;
58748
 
 
58749
 
  _query := _query || ') AS data ORDER BY orderhead_type, orderhead_number ;';
58750
 
  
58751
 
  FOR _row IN EXECUTE _query
58752
 
  LOOP
58753
 
    RETURN NEXT _row;
58754
 
  END LOOP;
58755
 
 
58756
 
  RETURN;
58757
 
END;
58758
 
$$;
58759
 
 
58760
 
 
58761
 
ALTER FUNCTION public.orderhead() OWNER TO admin;
58762
 
 
58763
 
--
58764
 
--
58765
 
 
58766
 
CREATE FUNCTION orderitem() RETURNS SETOF orditem
58767
 
    LANGUAGE plpgsql
58768
 
    AS $$
58769
 
DECLARE
58770
 
  _row orditem%ROWTYPE;
58771
 
  _query TEXT;
58772
 
BEGIN
58773
 
 
58774
 
  _query := '
58775
 
  SELECT poitem_id              AS orderitem_id,
58776
 
         ''PO''                 AS orderitem_orderhead_type,
58777
 
         poitem_pohead_id       AS orderitem_orderhead_id,
58778
 
         poitem_linenumber      AS orderitem_linenumber,
58779
 
         poitem_status          AS orderitem_status,
58780
 
         poitem_itemsite_id     AS orderitem_itemsite_id,
58781
 
         poitem_duedate         AS orderitem_scheddate,
58782
 
         poitem_qty_ordered     AS orderitem_qty_ordered,
58783
 
         poitem_qty_returned    AS orderitem_qty_shipped,
58784
 
         poitem_qty_received    AS orderitem_qty_received,
58785
 
         uom_id                 AS orderitem_qty_uom_id,
58786
 
         poitem_invvenduomratio AS orderitem_qty_invuomratio,
58787
 
         poitem_unitprice       AS orderitem_unitcost,
58788
 
         pohead_curr_id         AS orderitem_unitcost_curr_id,
58789
 
         poitem_freight         AS orderitem_freight,
58790
 
         poitem_freight_received AS orderitem_freight_received,
58791
 
         pohead_curr_id         AS orderitem_freight_curr_id
58792
 
 
58793
 
  FROM poitem LEFT OUTER JOIN pohead ON (poitem_pohead_id=pohead_id)
58794
 
              LEFT OUTER JOIN uom ON (uom_name=poitem_vend_uom)
58795
 
  UNION
58796
 
  SELECT coitem_id              AS orderitem_id,
58797
 
         ''SO''                 AS orderitem_orderhead_type,
58798
 
         coitem_cohead_id       AS orderitem_orderhead_id,
58799
 
         coitem_linenumber      AS orderitem_linenumber,
58800
 
         coitem_status          AS orderitem_status,
58801
 
         coitem_itemsite_id     AS orderitem_itemsite_id,
58802
 
         coitem_scheddate       AS orderitem_scheddate,
58803
 
         coitem_qtyord          AS orderitem_qty_ordered,
58804
 
         coitem_qtyshipped      AS orderitem_qty_shipped,
58805
 
         coitem_qtyreturned     AS orderitem_qty_received,
58806
 
         coitem_qty_uom_id      AS orderitem_qty_uom_id,
58807
 
         coitem_qty_invuomratio AS orderitem_qty_invuomratio,
58808
 
         coitem_unitcost        AS orderitem_unitcost,
58809
 
         basecurrid()           AS orderitem_unitcost_curr_id,
58810
 
         NULL                   AS orderitem_freight,
58811
 
         NULL                   AS orderitem_freight_received,
58812
 
         basecurrid()           AS orderitem_freight_curr_id
58813
 
  FROM coitem';
58814
 
 
58815
 
  IF (fetchmetricbool('MultiWhs')) THEN
58816
 
    _query := _query || '
58817
 
    UNION
58818
 
    SELECT toitem_id            AS orderitem_id,
58819
 
      ''TO''                    AS orderitem_orderhead_type,
58820
 
      toitem_tohead_id  AS orderitem_orderhead_id,
58821
 
      toitem_linenumber AS orderitem_linenumber,
58822
 
      toitem_status             AS orderitem_status,
58823
 
      itemsite_id               AS orderitem_itemsite_id,
58824
 
      toitem_duedate            AS orderitem_scheddate,
58825
 
      toitem_qty_ordered        AS orderitem_qty_ordered,
58826
 
      toitem_qty_shipped        AS orderitem_qty_shipped,
58827
 
      toitem_qty_received       AS orderitem_qty_received,
58828
 
      uom_id                    AS orderitem_qty_uom_id,
58829
 
      1                 AS orderitem_qty_invuomratio,
58830
 
      toitem_stdcost            AS orderitem_unitcost,
58831
 
      basecurrid()              AS orderitem_unitcost_curr_id,
58832
 
      toitem_freight            AS orderitem_freight,
58833
 
      toitem_freight_received AS orderitem_freight_received,
58834
 
      toitem_freight_curr_id    AS orderitem_freight_curr_id
58835
 
    FROM tohead, itemsite, toitem LEFT OUTER JOIN uom ON (uom_name=toitem_uom)
58836
 
    WHERE ((toitem_tohead_id=tohead_id)
58837
 
     AND  (tohead_src_warehous_id=itemsite_warehous_id)
58838
 
     AND  (toitem_item_id=itemsite_item_id)) ';
58839
 
  END IF;
58840
 
 
58841
 
  IF (fetchmetricbool('EnableReturnAuth')) THEN
58842
 
    _query := _query || '
58843
 
    UNION
58844
 
    SELECT raitem_id            AS orderitem_id,
58845
 
      ''RA''                    AS orderitem_orderhead_type,
58846
 
      raitem_rahead_id  AS orderitem_orderhead_id,
58847
 
      raitem_linenumber AS orderitem_linenumber,
58848
 
      raitem_status             AS orderitem_status,
58849
 
      raitem_itemsite_id        AS orderitem_itemsite_id,
58850
 
      raitem_scheddate  AS orderitem_scheddate,
58851
 
      raitem_qtyauthorized      AS orderitem_qty_ordered,
58852
 
      0                 AS orderitem_qty_shipped,
58853
 
      raitem_qtyreceived        AS orderitem_qty_received,
58854
 
      raitem_qty_uom_id AS orderitem_qty_uom_id,
58855
 
      raitem_qty_invuomratio    AS orderitem_qty_invuomratio,
58856
 
      raitem_unitprice  AS orderitem_unitcost,
58857
 
      basecurrid()              AS orderitem_unitcost_curr_id,
58858
 
      NULL                      AS orderitem_freight,
58859
 
      NULL                      AS orderitem_freight_received,
58860
 
      basecurrid()              AS orderitem_freight_curr_id
58861
 
    FROM raitem';
58862
 
  END IF;
58863
 
  
58864
 
  FOR _row IN EXECUTE _query
58865
 
  LOOP
58866
 
    RETURN NEXT _row;
58867
 
  END LOOP;
58868
 
 
58869
 
  RETURN;
58870
 
END;
58871
 
$$;
58872
 
 
58873
 
 
58874
 
ALTER FUNCTION public.orderitem() OWNER TO admin;
58875
 
 
58876
 
--
58877
 
--
58878
 
 
58879
 
CREATE FUNCTION orderitemdata(text, integer, integer) RETURNS SETOF orderitemtype
58880
 
    LANGUAGE plpgsql
58881
 
    AS $_$
58882
 
DECLARE
58883
 
  pOrdertype ALIAS FOR $1;
58884
 
  pOrderheadid ALIAS FOR $2;
58885
 
  pOrderitemid ALIAS FOR $3;
58886
 
  _row orderitemtype%ROWTYPE;
58887
 
  _set RECORD;
58888
 
 
58889
 
BEGIN
58890
 
 
58891
 
  IF(UPPER(pOrdertype)='PO') THEN
58892
 
    FOR _set IN 
58893
 
      SELECT poitem_id              AS orderitem_id,
58894
 
             'PO'                   AS orderitem_orderhead_type,
58895
 
             poitem_pohead_id       AS orderitem_orderhead_id,
58896
 
             poitem_linenumber      AS orderitem_linenumber,
58897
 
             poitem_status          AS orderitem_status,
58898
 
             poitem_itemsite_id     AS orderitem_itemsite_id,
58899
 
             poitem_duedate         AS orderitem_scheddate,
58900
 
             poitem_qty_ordered     AS orderitem_qty_ordered,
58901
 
             poitem_qty_returned    AS orderitem_qty_shipped,
58902
 
             poitem_qty_received    AS orderitem_qty_received,
58903
 
             uom_id                 AS orderitem_qty_uom_id,
58904
 
             poitem_invvenduomratio AS orderitem_qty_invuomratio,
58905
 
             poitem_unitprice       AS orderitem_unitcost,
58906
 
             (SELECT pohead_curr_id FROM pohead WHERE pohead_id=poitem_pohead_id)
58907
 
                                    AS orderitem_unitcost_curr_id,
58908
 
             poitem_freight         AS orderitem_freight,
58909
 
             poitem_freight_received AS orderitem_freight_received,
58910
 
             (SELECT pohead_curr_id FROM pohead WHERE pohead_id=poitem_pohead_id)
58911
 
                                    AS orderitem_freight_curr_id
58912
 
        FROM poitem LEFT OUTER JOIN uom ON (uom_name=poitem_vend_uom)
58913
 
       WHERE(((pOrderheadid IS NULL) OR (poitem_pohead_id=pOrderheadid))
58914
 
         AND ((pOrderitemid IS NULL) OR (poitem_id=pOrderitemid))) LOOP
58915
 
  
58916
 
      _row.orderitem_id := _set.orderitem_id;
58917
 
      _row.orderitem_orderhead_type := _set.orderitem_orderhead_type;
58918
 
      _row.orderitem_orderhead_id := _set.orderitem_orderhead_id;
58919
 
      _row.orderitem_linenumber := _set.orderitem_linenumber;
58920
 
      _row.orderitem_status := _set.orderitem_status;
58921
 
      _row.orderitem_itemsite_id := _set.orderitem_itemsite_id;
58922
 
      _row.orderitem_scheddate := _set.orderitem_scheddate;
58923
 
      _row.orderitem_qty_ordered := _set.orderitem_qty_ordered;
58924
 
      _row.orderitem_qty_shipped := _set.orderitem_qty_shipped;
58925
 
      _row.orderitem_qty_received := _set.orderitem_qty_received;
58926
 
      _row.orderitem_qty_uom_id := _set.orderitem_qty_uom_id;
58927
 
      _row.orderitem_qty_invuomratio := _set.orderitem_qty_invuomratio;
58928
 
      _row.orderitem_unitcost := _set.orderitem_unitcost;
58929
 
      _row.orderitem_unitcost_curr_id := _set.orderitem_unitcost_curr_id;
58930
 
      _row.orderitem_freight := _set.orderitem_freight;
58931
 
      _row.orderitem_freight_received := _set.orderitem_freight_received;
58932
 
      _row.orderitem_freight_curr_id := _set.orderitem_freight_curr_id;
58933
 
 
58934
 
      RETURN NEXT _row;
58935
 
    END LOOP;
58936
 
  ELSEIF(UPPER(pOrdertype)='SO') THEN
58937
 
    FOR _set IN 
58938
 
      SELECT coitem_id              AS orderitem_id,
58939
 
             'SO'                   AS orderitem_orderhead_type,
58940
 
             coitem_cohead_id       AS orderitem_orderhead_id,
58941
 
             coitem_linenumber      AS orderitem_linenumber,
58942
 
             coitem_status          AS orderitem_status,
58943
 
             coitem_itemsite_id     AS orderitem_itemsite_id,
58944
 
             coitem_scheddate       AS orderitem_scheddate,
58945
 
             coitem_qtyord          AS orderitem_qty_ordered,
58946
 
             coitem_qtyshipped      AS orderitem_qty_shipped,
58947
 
             coitem_qtyreturned     AS orderitem_qty_received,
58948
 
             coitem_qty_uom_id      AS orderitem_qty_uom_id,
58949
 
             coitem_qty_invuomratio AS orderitem_qty_invuomratio,
58950
 
             coitem_unitcost        AS orderitem_unitcost,
58951
 
             basecurrid()           AS orderitem_unitcost_curr_id,
58952
 
             NULL                   AS orderitem_freight,
58953
 
             NULL                   AS orderitem_freight_received,
58954
 
             basecurrid()           AS orderitem_freight_curr_id
58955
 
        FROM coitem
58956
 
       WHERE(((pOrderheadid IS NULL) OR (coitem_cohead_id=pOrderheadid))
58957
 
         AND ((pOrderitemid IS NULL) OR (coitem_id=pOrderitemid))) LOOP
58958
 
  
58959
 
      _row.orderitem_id := _set.orderitem_id;
58960
 
      _row.orderitem_orderhead_type := _set.orderitem_orderhead_type;
58961
 
      _row.orderitem_orderhead_id := _set.orderitem_orderhead_id;
58962
 
      _row.orderitem_linenumber := _set.orderitem_linenumber;
58963
 
      _row.orderitem_status := _set.orderitem_status;
58964
 
      _row.orderitem_itemsite_id := _set.orderitem_itemsite_id;
58965
 
      _row.orderitem_scheddate := _set.orderitem_scheddate;
58966
 
      _row.orderitem_qty_ordered := _set.orderitem_qty_ordered;
58967
 
      _row.orderitem_qty_shipped := _set.orderitem_qty_shipped;
58968
 
      _row.orderitem_qty_received := _set.orderitem_qty_received;
58969
 
      _row.orderitem_qty_uom_id := _set.orderitem_qty_uom_id;
58970
 
      _row.orderitem_qty_invuomratio := _set.orderitem_qty_invuomratio;
58971
 
      _row.orderitem_unitcost := _set.orderitem_unitcost;
58972
 
      _row.orderitem_unitcost_curr_id := _set.orderitem_unitcost_curr_id;
58973
 
      _row.orderitem_freight := _set.orderitem_freight;
58974
 
      _row.orderitem_freight_received := _set.orderitem_freight_received;
58975
 
      _row.orderitem_freight_curr_id := _set.orderitem_freight_curr_id;
58976
 
 
58977
 
      RETURN NEXT _row;
58978
 
    END LOOP;
58979
 
  ELSEIF(UPPER(pOrdertype)='RA') THEN
58980
 
    FOR _set IN 
58981
 
      SELECT raitem_id              AS orderitem_id,
58982
 
             'RA'                   AS orderitem_orderhead_type,
58983
 
             raitem_rahead_id       AS orderitem_orderhead_id,
58984
 
             raitem_linenumber      AS orderitem_linenumber,
58985
 
             raitem_status          AS orderitem_status,
58986
 
             raitem_itemsite_id     AS orderitem_itemsite_id,
58987
 
             raitem_scheddate       AS orderitem_scheddate,
58988
 
             raitem_qtyauthorized   AS orderitem_qty_ordered,
58989
 
             0                      AS orderitem_qty_shipped,
58990
 
             raitem_qtyreceived     AS orderitem_qty_received,
58991
 
             raitem_qty_uom_id      AS orderitem_qty_uom_id,
58992
 
             raitem_qty_invuomratio AS orderitem_qty_invuomratio,
58993
 
             raitem_unitprice       AS orderitem_unitcost,
58994
 
             basecurrid()           AS orderitem_unitcost_curr_id,
58995
 
             NULL                   AS orderitem_freight,
58996
 
             NULL                   AS orderitem_freight_received,
58997
 
             basecurrid()           AS orderitem_freight_curr_id
58998
 
        FROM raitem
58999
 
       WHERE(((pOrderheadid IS NULL) OR (raitem_rahead_id=pOrderheadid))
59000
 
         AND ((pOrderitemid IS NULL) OR (raitem_id=pOrderitemid))) LOOP
59001
 
  
59002
 
      _row.orderitem_id := _set.orderitem_id;
59003
 
      _row.orderitem_orderhead_type := _set.orderitem_orderhead_type;
59004
 
      _row.orderitem_orderhead_id := _set.orderitem_orderhead_id;
59005
 
      _row.orderitem_linenumber := _set.orderitem_linenumber;
59006
 
      _row.orderitem_status := _set.orderitem_status;
59007
 
      _row.orderitem_itemsite_id := _set.orderitem_itemsite_id;
59008
 
      _row.orderitem_scheddate := _set.orderitem_scheddate;
59009
 
      _row.orderitem_qty_ordered := _set.orderitem_qty_ordered;
59010
 
      _row.orderitem_qty_shipped := _set.orderitem_qty_shipped;
59011
 
      _row.orderitem_qty_received := _set.orderitem_qty_received;
59012
 
      _row.orderitem_qty_uom_id := _set.orderitem_qty_uom_id;
59013
 
      _row.orderitem_qty_invuomratio := _set.orderitem_qty_invuomratio;
59014
 
      _row.orderitem_unitcost := _set.orderitem_unitcost;
59015
 
      _row.orderitem_unitcost_curr_id := _set.orderitem_unitcost_curr_id;
59016
 
      _row.orderitem_freight := _set.orderitem_freight;
59017
 
      _row.orderitem_freight_received := _set.orderitem_freight_received;
59018
 
      _row.orderitem_freight_curr_id := _set.orderitem_freight_curr_id;
59019
 
 
59020
 
      RETURN NEXT _row;
59021
 
    END LOOP;
59022
 
  ELSEIF(UPPER(pOrdertype)='TO') THEN
59023
 
    FOR _set IN 
59024
 
      SELECT toitem_id              AS orderitem_id,
59025
 
             'TO'                   AS orderitem_orderhead_type,
59026
 
             toitem_tohead_id       AS orderitem_orderhead_id,
59027
 
             toitem_linenumber      AS orderitem_linenumber,
59028
 
             toitem_status          AS orderitem_status,
59029
 
             itemsite_id            AS orderitem_itemsite_id,
59030
 
             toitem_duedate         AS orderitem_scheddate,
59031
 
             toitem_qty_ordered     AS orderitem_qty_ordered,
59032
 
             toitem_qty_shipped     AS orderitem_qty_shipped,
59033
 
             toitem_qty_received    AS orderitem_qty_received,
59034
 
             uom_id                 AS orderitem_qty_uom_id,
59035
 
             1                      AS orderitem_qty_invuomratio,
59036
 
             toitem_stdcost         AS orderitem_unitcost,
59037
 
             basecurrid()           AS orderitem_unitcost_curr_id,
59038
 
             toitem_freight         AS orderitem_freight,
59039
 
             toitem_freight_received AS orderitem_freight_received,
59040
 
             toitem_freight_curr_id AS orderitem_freight_curr_id
59041
 
        FROM tohead, itemsite, toitem LEFT OUTER JOIN uom ON (uom_name=toitem_uom)
59042
 
       WHERE((toitem_tohead_id=tohead_id)
59043
 
         AND (tohead_src_warehous_id=itemsite_warehous_id)
59044
 
         AND (toitem_item_id=itemsite_item_id)
59045
 
         AND ((pOrderheadid IS NULL) OR (toitem_tohead_id=pOrderheadid))
59046
 
         AND ((pOrderitemid IS NULL) OR (toitem_id=pOrderitemid))) LOOP
59047
 
  
59048
 
      _row.orderitem_id := _set.orderitem_id;
59049
 
      _row.orderitem_orderhead_type := _set.orderitem_orderhead_type;
59050
 
      _row.orderitem_orderhead_id := _set.orderitem_orderhead_id;
59051
 
      _row.orderitem_linenumber := _set.orderitem_linenumber;
59052
 
      _row.orderitem_status := _set.orderitem_status;
59053
 
      _row.orderitem_itemsite_id := _set.orderitem_itemsite_id;
59054
 
      _row.orderitem_scheddate := _set.orderitem_scheddate;
59055
 
      _row.orderitem_qty_ordered := _set.orderitem_qty_ordered;
59056
 
      _row.orderitem_qty_shipped := _set.orderitem_qty_shipped;
59057
 
      _row.orderitem_qty_received := _set.orderitem_qty_received;
59058
 
      _row.orderitem_qty_uom_id := _set.orderitem_qty_uom_id;
59059
 
      _row.orderitem_qty_invuomratio := _set.orderitem_qty_invuomratio;
59060
 
      _row.orderitem_unitcost := _set.orderitem_unitcost;
59061
 
      _row.orderitem_unitcost_curr_id := _set.orderitem_unitcost_curr_id;
59062
 
      _row.orderitem_freight := _set.orderitem_freight;
59063
 
      _row.orderitem_freight_received := _set.orderitem_freight_received;
59064
 
      _row.orderitem_freight_curr_id := _set.orderitem_freight_curr_id;
59065
 
 
59066
 
      RETURN NEXT _row;
59067
 
    END LOOP;
59068
 
  END IF;
59069
 
 
59070
 
  RETURN;
59071
 
END;
59072
 
$_$;
59073
 
 
59074
 
 
59075
 
ALTER FUNCTION public.orderitemdata(text, integer, integer) OWNER TO admin;
59076
 
 
59077
 
--
59078
 
--
59079
 
 
59080
 
CREATE FUNCTION packageisenabled(integer) RETURNS boolean
59081
 
    LANGUAGE sql
59082
 
    AS $_$
59083
 
  SELECT COUNT(*) >= 8
59084
 
  FROM pg_inherits, pg_class, pg_namespace, pkghead
59085
 
  WHERE ((inhrelid=pg_class.oid)
59086
 
     AND (relnamespace=pg_namespace.oid)
59087
 
     AND  (nspname=lower(pkghead_name))
59088
 
     AND  (pkghead_id=$1));
59089
 
$_$;
59090
 
 
59091
 
 
59092
 
ALTER FUNCTION public.packageisenabled(integer) OWNER TO admin;
59093
 
 
59094
 
--
59095
 
--
59096
 
 
59097
 
CREATE FUNCTION packageisenabled(text) RETURNS boolean
59098
 
    LANGUAGE sql
59099
 
    AS $_$
59100
 
  SELECT COUNT(*) >= 8
59101
 
  FROM pg_inherits, pg_class, pg_namespace
59102
 
  WHERE ((inhrelid=pg_class.oid)
59103
 
     AND (relnamespace=pg_namespace.oid)
59104
 
     AND  (nspname=lower($1)));
59105
 
$_$;
59106
 
 
59107
 
 
59108
 
ALTER FUNCTION public.packageisenabled(text) OWNER TO admin;
59109
 
 
59110
 
--
59111
 
--
59112
 
 
59113
 
CREATE FUNCTION pgp_key_id(bytea) RETURNS text
59114
 
    LANGUAGE c IMMUTABLE STRICT
59115
 
    AS '$libdir/pgcrypto', 'pgp_key_id_w';
59116
 
 
59117
 
 
59118
 
ALTER FUNCTION public.pgp_key_id(bytea) OWNER TO admin;
59119
 
 
59120
 
--
59121
 
--
59122
 
 
59123
 
CREATE FUNCTION pgp_pub_decrypt(bytea, bytea) RETURNS text
59124
 
    LANGUAGE c IMMUTABLE STRICT
59125
 
    AS '$libdir/pgcrypto', 'pgp_pub_decrypt_text';
59126
 
 
59127
 
 
59128
 
ALTER FUNCTION public.pgp_pub_decrypt(bytea, bytea) OWNER TO admin;
59129
 
 
59130
 
--
59131
 
--
59132
 
 
59133
 
CREATE FUNCTION pgp_pub_decrypt(bytea, bytea, text) RETURNS text
59134
 
    LANGUAGE c IMMUTABLE STRICT
59135
 
    AS '$libdir/pgcrypto', 'pgp_pub_decrypt_text';
59136
 
 
59137
 
 
59138
 
ALTER FUNCTION public.pgp_pub_decrypt(bytea, bytea, text) OWNER TO admin;
59139
 
 
59140
 
--
59141
 
--
59142
 
 
59143
 
CREATE FUNCTION pgp_pub_decrypt(bytea, bytea, text, text) RETURNS text
59144
 
    LANGUAGE c IMMUTABLE STRICT
59145
 
    AS '$libdir/pgcrypto', 'pgp_pub_decrypt_text';
59146
 
 
59147
 
 
59148
 
ALTER FUNCTION public.pgp_pub_decrypt(bytea, bytea, text, text) OWNER TO admin;
59149
 
 
59150
 
--
59151
 
--
59152
 
 
59153
 
CREATE FUNCTION pgp_pub_decrypt_bytea(bytea, bytea) RETURNS bytea
59154
 
    LANGUAGE c IMMUTABLE STRICT
59155
 
    AS '$libdir/pgcrypto', 'pgp_pub_decrypt_bytea';
59156
 
 
59157
 
 
59158
 
ALTER FUNCTION public.pgp_pub_decrypt_bytea(bytea, bytea) OWNER TO admin;
59159
 
 
59160
 
--
59161
 
--
59162
 
 
59163
 
CREATE FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text) RETURNS bytea
59164
 
    LANGUAGE c IMMUTABLE STRICT
59165
 
    AS '$libdir/pgcrypto', 'pgp_pub_decrypt_bytea';
59166
 
 
59167
 
 
59168
 
ALTER FUNCTION public.pgp_pub_decrypt_bytea(bytea, bytea, text) OWNER TO admin;
59169
 
 
59170
 
--
59171
 
--
59172
 
 
59173
 
CREATE FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text, text) RETURNS bytea
59174
 
    LANGUAGE c IMMUTABLE STRICT
59175
 
    AS '$libdir/pgcrypto', 'pgp_pub_decrypt_bytea';
59176
 
 
59177
 
 
59178
 
ALTER FUNCTION public.pgp_pub_decrypt_bytea(bytea, bytea, text, text) OWNER TO admin;
59179
 
 
59180
 
--
59181
 
--
59182
 
 
59183
 
CREATE FUNCTION pgp_pub_encrypt(text, bytea) RETURNS bytea
59184
 
    LANGUAGE c STRICT
59185
 
    AS '$libdir/pgcrypto', 'pgp_pub_encrypt_text';
59186
 
 
59187
 
 
59188
 
ALTER FUNCTION public.pgp_pub_encrypt(text, bytea) OWNER TO admin;
59189
 
 
59190
 
--
59191
 
--
59192
 
 
59193
 
CREATE FUNCTION pgp_pub_encrypt(text, bytea, text) RETURNS bytea
59194
 
    LANGUAGE c STRICT
59195
 
    AS '$libdir/pgcrypto', 'pgp_pub_encrypt_text';
59196
 
 
59197
 
 
59198
 
ALTER FUNCTION public.pgp_pub_encrypt(text, bytea, text) OWNER TO admin;
59199
 
 
59200
 
--
59201
 
--
59202
 
 
59203
 
CREATE FUNCTION pgp_pub_encrypt_bytea(bytea, bytea) RETURNS bytea
59204
 
    LANGUAGE c STRICT
59205
 
    AS '$libdir/pgcrypto', 'pgp_pub_encrypt_bytea';
59206
 
 
59207
 
 
59208
 
ALTER FUNCTION public.pgp_pub_encrypt_bytea(bytea, bytea) OWNER TO admin;
59209
 
 
59210
 
--
59211
 
--
59212
 
 
59213
 
CREATE FUNCTION pgp_pub_encrypt_bytea(bytea, bytea, text) RETURNS bytea
59214
 
    LANGUAGE c STRICT
59215
 
    AS '$libdir/pgcrypto', 'pgp_pub_encrypt_bytea';
59216
 
 
59217
 
 
59218
 
ALTER FUNCTION public.pgp_pub_encrypt_bytea(bytea, bytea, text) OWNER TO admin;
59219
 
 
59220
 
--
59221
 
--
59222
 
 
59223
 
CREATE FUNCTION pgp_sym_decrypt(bytea, text) RETURNS text
59224
 
    LANGUAGE c IMMUTABLE STRICT
59225
 
    AS '$libdir/pgcrypto', 'pgp_sym_decrypt_text';
59226
 
 
59227
 
 
59228
 
ALTER FUNCTION public.pgp_sym_decrypt(bytea, text) OWNER TO admin;
59229
 
 
59230
 
--
59231
 
--
59232
 
 
59233
 
CREATE FUNCTION pgp_sym_decrypt(bytea, text, text) RETURNS text
59234
 
    LANGUAGE c IMMUTABLE STRICT
59235
 
    AS '$libdir/pgcrypto', 'pgp_sym_decrypt_text';
59236
 
 
59237
 
 
59238
 
ALTER FUNCTION public.pgp_sym_decrypt(bytea, text, text) OWNER TO admin;
59239
 
 
59240
 
--
59241
 
--
59242
 
 
59243
 
CREATE FUNCTION pgp_sym_decrypt_bytea(bytea, text) RETURNS bytea
59244
 
    LANGUAGE c IMMUTABLE STRICT
59245
 
    AS '$libdir/pgcrypto', 'pgp_sym_decrypt_bytea';
59246
 
 
59247
 
 
59248
 
ALTER FUNCTION public.pgp_sym_decrypt_bytea(bytea, text) OWNER TO admin;
59249
 
 
59250
 
--
59251
 
--
59252
 
 
59253
 
CREATE FUNCTION pgp_sym_decrypt_bytea(bytea, text, text) RETURNS bytea
59254
 
    LANGUAGE c IMMUTABLE STRICT
59255
 
    AS '$libdir/pgcrypto', 'pgp_sym_decrypt_bytea';
59256
 
 
59257
 
 
59258
 
ALTER FUNCTION public.pgp_sym_decrypt_bytea(bytea, text, text) OWNER TO admin;
59259
 
 
59260
 
--
59261
 
--
59262
 
 
59263
 
CREATE FUNCTION pgp_sym_encrypt(text, text) RETURNS bytea
59264
 
    LANGUAGE c STRICT
59265
 
    AS '$libdir/pgcrypto', 'pgp_sym_encrypt_text';
59266
 
 
59267
 
 
59268
 
ALTER FUNCTION public.pgp_sym_encrypt(text, text) OWNER TO admin;
59269
 
 
59270
 
--
59271
 
--
59272
 
 
59273
 
CREATE FUNCTION pgp_sym_encrypt(text, text, text) RETURNS bytea
59274
 
    LANGUAGE c STRICT
59275
 
    AS '$libdir/pgcrypto', 'pgp_sym_encrypt_text';
59276
 
 
59277
 
 
59278
 
ALTER FUNCTION public.pgp_sym_encrypt(text, text, text) OWNER TO admin;
59279
 
 
59280
 
--
59281
 
--
59282
 
 
59283
 
CREATE FUNCTION pgp_sym_encrypt_bytea(bytea, text) RETURNS bytea
59284
 
    LANGUAGE c STRICT
59285
 
    AS '$libdir/pgcrypto', 'pgp_sym_encrypt_bytea';
59286
 
 
59287
 
 
59288
 
ALTER FUNCTION public.pgp_sym_encrypt_bytea(bytea, text) OWNER TO admin;
59289
 
 
59290
 
--
59291
 
--
59292
 
 
59293
 
CREATE FUNCTION pgp_sym_encrypt_bytea(bytea, text, text) RETURNS bytea
59294
 
    LANGUAGE c STRICT
59295
 
    AS '$libdir/pgcrypto', 'pgp_sym_encrypt_bytea';
59296
 
 
59297
 
 
59298
 
ALTER FUNCTION public.pgp_sym_encrypt_bytea(bytea, text, text) OWNER TO admin;
59299
 
 
59300
 
--
59301
 
--
59302
 
 
59303
 
CREATE FUNCTION pkgmaybemodified(name) RETURNS boolean
59304
 
    LANGUAGE plpgsql
59305
 
    AS $_$
59306
 
DECLARE
59307
 
  pschemaname ALIAS FOR $1;
59308
 
  _returnval  BOOLEAN;
59309
 
BEGIN
59310
 
  SELECT pkghead_indev INTO _returnval
59311
 
  FROM pkghead
59312
 
  WHERE (pkghead_name=pschemaname);
59313
 
  IF (NOT FOUND) THEN
59314
 
    RETURN FALSE;
59315
 
  END IF;
59316
 
  RETURN _returnval;
59317
 
END;
59318
 
$_$;
59319
 
 
59320
 
 
59321
 
ALTER FUNCTION public.pkgmaybemodified(name) OWNER TO admin;
59322
 
 
59323
 
--
59324
 
--
59325
 
 
59326
 
CREATE FUNCTION plpgsql_call_handler() RETURNS language_handler
59327
 
    LANGUAGE c
59328
 
    AS '$libdir/plpgsql', 'plpgsql_call_handler';
59329
 
 
59330
 
 
59331
 
ALTER FUNCTION public.plpgsql_call_handler() OWNER TO admin;
59332
 
 
59333
 
--
59334
 
--
59335
 
 
59336
 
CREATE FUNCTION plpgsql_validator(oid) RETURNS void
59337
 
    LANGUAGE c
59338
 
    AS '$libdir/plpgsql', 'plpgsql_validator';
59339
 
 
59340
 
 
59341
 
ALTER FUNCTION public.plpgsql_validator(oid) OWNER TO admin;
59342
 
 
59343
 
--
59344
 
--
59345
 
 
59346
 
CREATE FUNCTION postapcheck(integer) RETURNS integer
59347
 
    LANGUAGE plpgsql
59348
 
    AS $_$
59349
 
BEGIN
59350
 
  RAISE NOTICE 'postAPCheck() is deprecated - use postCheck() instead';
59351
 
  RETURN postCheck($1, fetchJournalNumber('AP-CK'));
59352
 
END;
59353
 
$_$;
59354
 
 
59355
 
 
59356
 
ALTER FUNCTION public.postapcheck(integer) OWNER TO admin;
59357
 
 
59358
 
--
59359
 
--
59360
 
 
59361
 
CREATE FUNCTION postapcheck(integer, integer) RETURNS integer
59362
 
    LANGUAGE plpgsql
59363
 
    AS $_$
59364
 
BEGIN
59365
 
  RAISE NOTICE 'postAPCheck() is deprecated - use postCheck() instead';
59366
 
  RETURN postCheck($1, $2);
59367
 
END;
59368
 
$_$;
59369
 
 
59370
 
 
59371
 
ALTER FUNCTION public.postapcheck(integer, integer) OWNER TO admin;
59372
 
 
59373
 
--
59374
 
--
59375
 
 
59376
 
CREATE FUNCTION postapchecks(integer) RETURNS integer
59377
 
    LANGUAGE plpgsql
59378
 
    AS $_$
59379
 
BEGIN
59380
 
 
59381
 
  RAISE NOTICE 'postAPChecks() is deprecated - use postChecks() instead';
59382
 
  RETURN postChecks($1);
59383
 
 
59384
 
END;
59385
 
$_$;
59386
 
 
59387
 
 
59388
 
ALTER FUNCTION public.postapchecks(integer) OWNER TO admin;
59389
 
 
59390
 
--
59391
 
--
59392
 
 
59393
 
CREATE FUNCTION postapcreditmemoapplication(integer) RETURNS integer
59394
 
    LANGUAGE plpgsql
59395
 
    AS $_$
59396
 
DECLARE
59397
 
  pApopenid ALIAS FOR $1;
59398
 
  _src RECORD;
59399
 
  _r RECORD;
59400
 
  _totalAmount NUMERIC := 0.0;
59401
 
  _exchGain NUMERIC := 0.0;
59402
 
  _apaccntid INTEGER;
59403
 
 
59404
 
BEGIN
59405
 
 
59406
 
  SELECT apopen_docnumber, (apopen_amount - apopen_paid) AS balance,
59407
 
--                               apcreditapply_amount, CURRENT_DATE)) AS toApply,
59408
 
         SUM(apcreditapply_amount) AS toApply,
59409
 
         apopen_curr_rate INTO _src
59410
 
  FROM apopen, apcreditapply
59411
 
  WHERE ( (apcreditapply_source_apopen_id=apopen_id)
59412
 
   AND (apopen_id=pApopenid) )
59413
 
  GROUP BY apopen_docnumber, apopen_amount, apopen_paid,
59414
 
           apopen_curr_rate;
59415
 
  IF (NOT FOUND) THEN
59416
 
    RETURN -1;
59417
 
  ELSIF (_src.toApply = 0) THEN
59418
 
    RETURN -2;
59419
 
  ELSIF (_src.toApply > _src.balance) THEN
59420
 
    RETURN -3;
59421
 
  ELSIF (_src.toApply IS NULL) THEN
59422
 
    RETURN -6;          -- amount to apply is NULL for some unknown reason
59423
 
  END IF;
59424
 
 
59425
 
  SELECT apopen_id, apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_amount,
59426
 
         apopen_curr_id, apopen_curr_rate, apopen_docdate, apopen_accnt_id INTO _src
59427
 
  FROM apopen
59428
 
  WHERE (apopen_id=pApopenid);
59429
 
  IF (NOT FOUND) THEN
59430
 
    RETURN -5;
59431
 
  END IF;
59432
 
 
59433
 
  FOR _r IN SELECT apcreditapply_id, apcreditapply_target_apopen_id,
59434
 
                   apcreditapply_amount AS apply_amountSource,
59435
 
                   currToCurr(apcreditapply_curr_id, apopen_curr_id,
59436
 
                              apcreditapply_amount, CURRENT_DATE) AS apply_amountTarget,
59437
 
                   apopen_id, apopen_doctype, apopen_docnumber, apopen_curr_id, apopen_curr_rate, apopen_docdate
59438
 
            FROM apcreditapply, apopen
59439
 
            WHERE ( (apcreditapply_source_apopen_id=pApopenid)
59440
 
             AND (apcreditapply_target_apopen_id=apopen_id) ) LOOP
59441
 
 
59442
 
    IF (_r.apply_amountTarget IS NULL) THEN
59443
 
      RETURN -4;        -- missing exchange rate
59444
 
    END IF;
59445
 
 
59446
 
    IF (_r.apply_amountTarget > 0) THEN
59447
 
 
59448
 
      UPDATE apopen
59449
 
      SET apopen_paid = (apopen_paid + _r.apply_amountTarget)
59450
 
      WHERE (apopen_id=_r.apcreditapply_target_apopen_id);
59451
 
 
59452
 
      UPDATE apopen
59453
 
      SET apopen_open = false,
59454
 
        apopen_closedate = current_date
59455
 
      WHERE ( (apopen_id=_r.apcreditapply_target_apopen_id)
59456
 
        AND (apopen_amount <= apopen_paid) );
59457
 
 
59458
 
      _totalAmount := (_totalAmount + _r.apply_amountSource);
59459
 
 
59460
 
      INSERT INTO apapply
59461
 
      ( apapply_vend_id, apapply_amount,
59462
 
        apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber,
59463
 
        apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber,
59464
 
        apapply_postdate, apapply_journalnumber, apapply_username, apapply_curr_id )
59465
 
      VALUES
59466
 
      ( _src.apopen_vend_id, round(_r.apply_amountSource, 2),
59467
 
        pApopenid, 'C', _src.apopen_docnumber,
59468
 
        _r.apopen_id, _r.apopen_doctype, _r.apopen_docnumber,
59469
 
        CURRENT_DATE, 0, getEffectiveXtUser(), _src.apopen_curr_id );
59470
 
 
59471
 
    END IF;
59472
 
 
59473
 
    DELETE FROM apcreditapply
59474
 
    WHERE (apcreditapply_id=_r.apcreditapply_id);
59475
 
 
59476
 
  END LOOP;
59477
 
 
59478
 
  UPDATE apopen
59479
 
  SET apopen_paid = (apopen_paid + _totalAmount)
59480
 
  WHERE (apopen_id=pApopenid);
59481
 
 
59482
 
  UPDATE apopen
59483
 
  SET apopen_open = false,
59484
 
    apopen_closedate = current_date
59485
 
  WHERE ( (apopen_id=pApopenid)
59486
 
    AND (apopen_amount <= apopen_paid) );
59487
 
 
59488
 
  IF (_r.apopen_curr_id = _src.apopen_curr_id) THEN
59489
 
    IF (_r.apopen_docdate > _src.apopen_docdate) THEN
59490
 
      _exchGain := (_totalAmount / _r.apopen_curr_rate - _totalAmount / _src.apopen_curr_rate) * -1;
59491
 
    ELSE
59492
 
      _exchGain := _totalAmount / _src.apopen_curr_rate - _totalAmount / _r.apopen_curr_rate;
59493
 
    END IF;
59494
 
  END IF;
59495
 
 
59496
 
    _apaccntid := findAPAccount(_src.apopen_vend_id);
59497
 
 
59498
 
  PERFORM insertGLTransaction(fetchJournalNumber('AP-MISC'), 'A/P', 'CM',
59499
 
                            _src.apopen_docnumber, 'CM Application',
59500
 
                            _apaccntid,
59501
 
                            getGainLossAccntId(_apaccntid), -1,
59502
 
                            _exchGain,
59503
 
                            CURRENT_DATE);
59504
 
 
59505
 
 
59506
 
  RETURN pApopenid;
59507
 
 
59508
 
END;
59509
 
$_$;
59510
 
 
59511
 
 
59512
 
ALTER FUNCTION public.postapcreditmemoapplication(integer) OWNER TO admin;
59513
 
 
59514
 
--
59515
 
--
59516
 
 
59517
 
CREATE FUNCTION postapopenitems() RETURNS boolean
59518
 
    LANGUAGE plpgsql
59519
 
    AS $$
59520
 
BEGIN
59521
 
 
59522
 
  UPDATE apopen
59523
 
  SET apopen_posted=TRUE
59524
 
  WHERE (NOT apopen_posted);
59525
 
 
59526
 
  RETURN TRUE;
59527
 
 
59528
 
END;
59529
 
$$;
59530
 
 
59531
 
 
59532
 
ALTER FUNCTION public.postapopenitems() OWNER TO admin;
59533
 
 
59534
 
--
59535
 
--
59536
 
 
59537
 
CREATE FUNCTION postarcreditmemoapplication(integer) RETURNS integer
59538
 
    LANGUAGE plpgsql
59539
 
    AS $_$
59540
 
DECLARE
59541
 
  pAropenid ALIAS FOR $1;
59542
 
BEGIN
59543
 
  RETURN postARCreditMemoApplication(pAropenid, CURRENT_DATE);
59544
 
END;
59545
 
$_$;
59546
 
 
59547
 
 
59548
 
ALTER FUNCTION public.postarcreditmemoapplication(integer) OWNER TO admin;
59549
 
 
59550
 
--
59551
 
--
59552
 
 
59553
 
CREATE FUNCTION postarcreditmemoapplication(integer, date) RETURNS integer
59554
 
    LANGUAGE plpgsql
59555
 
    AS $_$
59556
 
DECLARE
59557
 
  pAropenid ALIAS FOR $1;
59558
 
  _applyDate DATE := COALESCE($2, CURRENT_DATE);
59559
 
  _p RECORD;
59560
 
  _r RECORD;
59561
 
  _totalAmount NUMERIC := 0;
59562
 
  _totalTarget NUMERIC := 0;
59563
 
  _exchGain NUMERIC := 0;
59564
 
  _result NUMERIC;
59565
 
  _araccntid INTEGER;
59566
 
 
59567
 
BEGIN
59568
 
 
59569
 
  SELECT aropen_docnumber,
59570
 
         ROUND(aropen_amount - aropen_paid, 2) AS balance,
59571
 
         aropen_open, aropen_curr_rate,
59572
 
         ROUND(SUM(currToCurr(arcreditapply_curr_id, aropen_curr_id,
59573
 
              COALESCE(arcreditapply_amount, 0), _applyDate)), 2) AS toApply INTO _p
59574
 
  FROM aropen, arcreditapply
59575
 
  WHERE ( (arcreditapply_source_aropen_id=aropen_id)
59576
 
   AND (aropen_id=pAropenid) )
59577
 
  GROUP BY aropen_docnumber, aropen_amount, aropen_paid, aropen_open, aropen_curr_rate;
59578
 
  IF (NOT FOUND) THEN
59579
 
    RETURN -1;
59580
 
  ELSIF (_p.toApply = 0) THEN
59581
 
    RETURN -2;
59582
 
  ELSIF (_p.toApply > _p.balance) THEN
59583
 
    RETURN -3;
59584
 
  END IF;
59585
 
 
59586
 
  SELECT aropen_cust_id, aropen_docnumber, aropen_doctype, aropen_amount,
59587
 
         aropen_curr_id, aropen_docdate, aropen_accnt_id, aropen_cust_id,
59588
 
         aropen_curr_rate INTO _p
59589
 
  FROM aropen
59590
 
  WHERE (aropen_id=pAropenid);
59591
 
  IF (NOT FOUND) THEN
59592
 
    RETURN -5;
59593
 
  END IF;
59594
 
 
59595
 
  FOR _r IN SELECT arcreditapply_id, arcreditapply_target_aropen_id,
59596
 
                   arcreditapply_amount AS arcreditapply_amountSource,
59597
 
                   arcreditapply_reftype, arcreditapply_ref_id,
59598
 
                   currToCurr(arcreditapply_curr_id, aropen_curr_id,
59599
 
                              arcreditapply_amount, _applyDate) AS arcreditapply_amountTarget,
59600
 
                   aropen_id, aropen_doctype, aropen_docnumber, aropen_docdate, aropen_curr_rate
59601
 
            FROM arcreditapply, aropen
59602
 
            WHERE ( (arcreditapply_source_aropen_id=pAropenid)
59603
 
             AND (arcreditapply_target_aropen_id=aropen_id) ) LOOP
59604
 
 
59605
 
    IF (_r.arcreditapply_amountTarget IS NULL) THEN
59606
 
      RETURN -4;
59607
 
    END IF;
59608
 
 
59609
 
    IF (_r.arcreditapply_amountTarget > 0) THEN
59610
 
 
59611
 
      UPDATE aropen
59612
 
      SET aropen_paid = round(aropen_paid + _r.arcreditapply_amountTarget, 2)
59613
 
      WHERE (aropen_id=_r.arcreditapply_target_aropen_id);
59614
 
 
59615
 
      UPDATE aropen
59616
 
      SET aropen_open = (round(aropen_amount, 2) > round(aropen_paid, 2))
59617
 
      WHERE (aropen_id=_r.arcreditapply_target_aropen_id);
59618
 
 
59619
 
      _totalAmount := (_totalAmount + _r.arcreditapply_amountSource);
59620
 
      _totalTarget := (_totalTarget + _r.arcreditapply_amountTarget);
59621
 
 
59622
 
      INSERT INTO arapply
59623
 
      ( arapply_cust_id,
59624
 
        arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber,
59625
 
        arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber,
59626
 
        arapply_fundstype, arapply_refnumber,
59627
 
        arapply_applied, arapply_closed, arapply_postdate, arapply_distdate,
59628
 
        arapply_journalnumber, arapply_username, arapply_curr_id,
59629
 
        arapply_reftype, arapply_ref_id )
59630
 
      VALUES
59631
 
      ( _p.aropen_cust_id,
59632
 
        pAropenid, _p.aropen_doctype, _p.aropen_docnumber,
59633
 
        _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber,
59634
 
        '', '',
59635
 
        round(_r.arcreditapply_amountSource, 2), TRUE, _applyDate, _applyDate,
59636
 
        0, getEffectiveXtUser(), _p.aropen_curr_id, 
59637
 
        _r.arcreditapply_reftype, _r.arcreditapply_ref_id );
59638
 
 
59639
 
    END IF;
59640
 
 
59641
 
    DELETE FROM arcreditapply
59642
 
    WHERE (arcreditapply_id=_r.arcreditapply_id);
59643
 
 
59644
 
    IF (_r.aropen_docdate > _p.aropen_docdate) THEN
59645
 
      _exchGain := (_totalTarget / _r.aropen_curr_rate - _totalAmount / _p.aropen_curr_rate) * -1;
59646
 
    ELSE
59647
 
      _exchGain := _totalAmount / _p.aropen_curr_rate - _totalTarget / _r.aropen_curr_rate;
59648
 
    END IF;
59649
 
 
59650
 
    IF (_p.aropen_accnt_id > -1) THEN
59651
 
      _araccntid := _p.aropen_accnt_id;
59652
 
    ELSE 
59653
 
      _araccntid := findARAccount(_p.aropen_cust_id);
59654
 
    END IF;
59655
 
    
59656
 
    IF (_exchGain <> 0) THEN
59657
 
        PERFORM insertGLTransaction(fetchJournalNumber('AR-MISC'), 'A/R',
59658
 
                                    'CR', _p.aropen_docnumber, 'CM Application',
59659
 
                                    _araccntid, getGainLossAccntId(_araccntid),
59660
 
                                    -1, _exchGain * -1, _applyDate);
59661
 
    END IF;
59662
 
 
59663
 
  END LOOP;
59664
 
 
59665
 
  IF(_p.aropen_doctype='R') THEN
59666
 
    SELECT insertGLTransaction(fetchJournalNumber('AR-MISC'), 'A/R',
59667
 
                               'CD', _p.aropen_docnumber, 'CM Application',
59668
 
                               cr.accnt_id, db.accnt_id,
59669
 
                               -1, currToBase(_p.aropen_curr_id, _totalAmount, _p.aropen_docdate),
59670
 
                               _applyDate)
59671
 
      INTO _result
59672
 
      FROM accnt AS cr, accnt AS db
59673
 
     WHERE ((db.accnt_id = findDeferredAccount(_p.aropen_cust_id))
59674
 
       AND  (cr.accnt_id = findARAccount(_p.aropen_cust_id)) );
59675
 
    IF(NOT FOUND OR _result < 0) THEN
59676
 
      RAISE EXCEPTION 'There was an error posting the Customer Deposit GL Transactions.';
59677
 
    END IF;
59678
 
  END IF;
59679
 
 
59680
 
  UPDATE aropen
59681
 
  SET aropen_paid = round(aropen_paid + _totalAmount, 2)
59682
 
  WHERE (aropen_id=pAropenid);
59683
 
 
59684
 
  UPDATE aropen
59685
 
  SET aropen_open = (round(aropen_amount, 2) > round(aropen_paid, 2))
59686
 
  WHERE (aropen_id=pAropenid);
59687
 
 
59688
 
  RETURN pAropenid;
59689
 
 
59690
 
END;
59691
 
$_$;
59692
 
 
59693
 
 
59694
 
ALTER FUNCTION public.postarcreditmemoapplication(integer, date) OWNER TO admin;
59695
 
 
59696
 
--
59697
 
--
59698
 
 
59699
 
CREATE FUNCTION postaropenitems() RETURNS boolean
59700
 
    LANGUAGE plpgsql
59701
 
    AS $$
59702
 
BEGIN
59703
 
 
59704
 
  UPDATE aropen
59705
 
  SET aropen_posted=TRUE
59706
 
  WHERE (NOT aropen_posted);
59707
 
 
59708
 
  RETURN TRUE;
59709
 
 
59710
 
END;
59711
 
$$;
59712
 
 
59713
 
 
59714
 
ALTER FUNCTION public.postaropenitems() OWNER TO admin;
59715
 
 
59716
 
--
59717
 
--
59718
 
 
59719
 
CREATE FUNCTION postbankadjustment(integer) RETURNS integer
59720
 
    LANGUAGE plpgsql
59721
 
    AS $_$
59722
 
DECLARE
59723
 
  pBankadjid ALIAS FOR $1;
59724
 
  _sequence INTEGER;
59725
 
  _r RECORD;
59726
 
 
59727
 
BEGIN
59728
 
 
59729
 
  SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), 'G/L', 'AD',
59730
 
                              bankadj_docnumber, (bankadjtype_name || '-' || bankadj_notes),
59731
 
                              bankadjtype_accnt_id, bankaccnt_accnt_id, bankadj_id,
59732
 
                              round(currToBase(bankaccnt_curr_id,
59733
 
                                         CASE WHEN(bankadjtype_iscredit) THEN
59734
 
                                             (bankadj_amount * -1)
59735
 
                                         ELSE bankadj_amount END,
59736
 
                                         bankadj_date), 2),
59737
 
                              bankadj_date, TRUE, TRUE ) INTO _sequence
59738
 
    FROM bankadj, bankaccnt, bankadjtype
59739
 
   WHERE ( (bankadj_bankaccnt_id=bankaccnt_id)
59740
 
     AND   (bankadj_bankadjtype_id=bankadjtype_id)
59741
 
     AND   (NOT bankadj_posted)
59742
 
     AND   (bankadj_id=pBankadjid) );
59743
 
  IF ( NOT FOUND ) THEN
59744
 
    RETURN -1;
59745
 
  END IF;
59746
 
 
59747
 
  IF (_sequence >= 0) THEN
59748
 
    UPDATE bankadj
59749
 
       SET bankadj_sequence = _sequence,
59750
 
           bankadj_posted = TRUE
59751
 
     WHERE bankadj_id=pBankadjid;
59752
 
  END IF;
59753
 
 
59754
 
  RETURN _sequence;
59755
 
 
59756
 
END;
59757
 
$_$;
59758
 
 
59759
 
 
59760
 
ALTER FUNCTION public.postbankadjustment(integer) OWNER TO admin;
59761
 
 
59762
 
--
59763
 
--
59764
 
 
59765
 
CREATE FUNCTION postbankreconciliation(pbankrecid integer) RETURNS integer
59766
 
    LANGUAGE plpgsql
59767
 
    AS $$
59768
 
BEGIN
59769
 
  RETURN bankReconciliation(pBankrecid, 'post');
59770
 
END;
59771
 
$$;
59772
 
 
59773
 
 
59774
 
ALTER FUNCTION public.postbankreconciliation(pbankrecid integer) OWNER TO admin;
59775
 
 
59776
 
--
59777
 
--
59778
 
 
59779
 
CREATE FUNCTION postbillingselection(integer) RETURNS integer
59780
 
    LANGUAGE plpgsql
59781
 
    AS $_$
59782
 
DECLARE
59783
 
  pCobmiscid ALIAS FOR $1;
59784
 
 
59785
 
BEGIN
59786
 
 
59787
 
  RAISE NOTICE 'postBillingselection(integer) has been deprecated.  Please use createInvoice(integer).';
59788
 
  RETURN createInvoice(pCobmiscid);
59789
 
 
59790
 
END;
59791
 
$_$;
59792
 
 
59793
 
 
59794
 
ALTER FUNCTION public.postbillingselection(integer) OWNER TO admin;
59795
 
 
59796
 
--
59797
 
--
59798
 
 
59799
 
CREATE FUNCTION postbillingselectionconsolidated(integer) RETURNS integer
59800
 
    LANGUAGE plpgsql
59801
 
    AS $_$
59802
 
DECLARE
59803
 
  pCustid ALIAS FOR $1;
59804
 
 
59805
 
BEGIN
59806
 
 
59807
 
  RAISE NOTICE 'postBillingselectionConsolidated(integer) has been deprecated.  Please use createInvoiceConsolidated(integer).';
59808
 
  RETURN createInvoiceConsolidated(pCustid);
59809
 
 
59810
 
END;
59811
 
$_$;
59812
 
 
59813
 
 
59814
 
ALTER FUNCTION public.postbillingselectionconsolidated(integer) OWNER TO admin;
59815
 
 
59816
 
--
59817
 
--
59818
 
 
59819
 
CREATE FUNCTION postbillingselections() RETURNS integer
59820
 
    LANGUAGE plpgsql
59821
 
    AS $$
59822
 
BEGIN
59823
 
 
59824
 
  RAISE NOTICE 'postBillingselections() has been deprecated.  Please use createInvoices().';
59825
 
  RETURN createInvoices();
59826
 
  
59827
 
END;
59828
 
$$;
59829
 
 
59830
 
 
59831
 
ALTER FUNCTION public.postbillingselections() OWNER TO admin;
59832
 
 
59833
 
--
59834
 
--
59835
 
 
59836
 
CREATE FUNCTION postbillingselections(integer) RETURNS integer
59837
 
    LANGUAGE plpgsql
59838
 
    AS $_$
59839
 
BEGIN
59840
 
  RAISE NOTICE 'postBillingselections(int) has been deprecated.  Please use createInvoices(int).';
59841
 
  RETURN createInvoices($1, false);
59842
 
END;
59843
 
$_$;
59844
 
 
59845
 
 
59846
 
ALTER FUNCTION public.postbillingselections(integer) OWNER TO admin;
59847
 
 
59848
 
--
59849
 
--
59850
 
 
59851
 
CREATE FUNCTION postbillingselections(integer, boolean) RETURNS integer
59852
 
    LANGUAGE plpgsql
59853
 
    AS $_$
59854
 
DECLARE
59855
 
  pCustTypeId ALIAS FOR $1;
59856
 
  pConsolidate ALIAS FOR $2;
59857
 
 
59858
 
BEGIN
59859
 
 
59860
 
  RAISE NOTICE 'postBillingselections(int,bool) has been deprecated.  Please use createInvoices(int,bool).';
59861
 
  RETURN createInvoices(pCustTypeId, pConsolidate);
59862
 
  
59863
 
END;
59864
 
$_$;
59865
 
 
59866
 
 
59867
 
ALTER FUNCTION public.postbillingselections(integer, boolean) OWNER TO admin;
59868
 
 
59869
 
--
59870
 
--
59871
 
 
59872
 
CREATE FUNCTION postcashreceipt(pcashrcptid integer, pjournalnumber integer) RETURNS integer
59873
 
    LANGUAGE plpgsql
59874
 
    AS $$
59875
 
DECLARE
59876
 
  _ccpayid  INTEGER;
59877
 
  _cctype TEXT;
59878
 
  _p RECORD;
59879
 
  _r RECORD;
59880
 
  _t RECORD;
59881
 
  _v RECORD;
59882
 
  _postToAR NUMERIC;
59883
 
  _postToMisc NUMERIC;
59884
 
  _postToCM NUMERIC;
59885
 
  _posted_base NUMERIC := 0;
59886
 
  _posted NUMERIC := 0;
59887
 
  _sequence INTEGER;
59888
 
  _aropenid INTEGER;
59889
 
  _arMemoNumber TEXT;
59890
 
  _arAccntid INTEGER;
59891
 
  _closed BOOLEAN;
59892
 
  _debitAccntid INTEGER;
59893
 
  _exchGain NUMERIC;
59894
 
  _comment TEXT;
59895
 
  _predist BOOLEAN;
59896
 
  _check INTEGER;
59897
 
 
59898
 
BEGIN
59899
 
  _posted := 0;
59900
 
  _posted_base := 0;
59901
 
 
59902
 
  SELECT fetchGLSequence() INTO _sequence;
59903
 
 
59904
 
  SELECT accnt_id INTO _arAccntid
59905
 
  FROM cashrcpt, accnt, salescat
59906
 
  WHERE ((cashrcpt_salescat_id=salescat_id)
59907
 
    AND  (salescat_ar_accnt_id=accnt_id)
59908
 
    AND  (cashrcpt_id=pCashrcptid));
59909
 
  IF (NOT FOUND) THEN
59910
 
    SELECT accnt_id INTO _arAccntid
59911
 
    FROM cashrcpt LEFT OUTER JOIN accnt ON (accnt_id=findARAccount(cashrcpt_cust_id))
59912
 
    WHERE ( (findARAccount(cashrcpt_cust_id)=0 OR accnt_id > 0) -- G/L interface might be disabled
59913
 
     AND (cashrcpt_id=pCashrcptid) );
59914
 
    IF (NOT FOUND) THEN
59915
 
      RETURN -5;
59916
 
    END IF;
59917
 
  END IF;
59918
 
 
59919
 
  SELECT cashrcpt.*,
59920
 
         (cust_number||'-'||cust_name) AS custnote,
59921
 
         (cashrcpt_amount / cashrcpt_curr_rate) AS cashrcpt_amount_base,
59922
 
         (cashrcpt_discount / cashrcpt_curr_rate) AS cashrcpt_discount_base,
59923
 
         cashrcpt_bankaccnt_id AS bankaccnt_id,
59924
 
         accnt_id AS prepaid_accnt_id,
59925
 
         COALESCE(cashrcpt_applydate, cashrcpt_distdate) AS applydate
59926
 
       INTO _p
59927
 
  FROM cashrcpt LEFT OUTER JOIN custinfo ON (cashrcpt_cust_id=cust_id)
59928
 
                LEFT OUTER JOIN accnt ON (accnt_id=findPrepaidAccount(cashrcpt_cust_id))
59929
 
  WHERE ( (findPrepaidAccount(cashrcpt_cust_id)=0 OR accnt_id > 0) -- G/L interface might be disabled
59930
 
     AND (cashrcpt_id=pCashrcptid) );
59931
 
  IF (NOT FOUND) THEN
59932
 
    RETURN -7;
59933
 
  END IF;
59934
 
 
59935
 
  IF (COALESCE(_p.cashrcpt_distdate > _p.applydate, false)) THEN
59936
 
    RAISE EXCEPTION 'Cannot post cashrcpt % because application date is before distribution date.', _p.cashrcpt_docnumber;
59937
 
  END IF;
59938
 
 
59939
 
  IF (COALESCE(_p.cashrcpt_posted, false)) THEN
59940
 
    RAISE EXCEPTION 'Cannot post cashrcpt % because the document has already been posted.', _p.cashrcpt_docnumber;
59941
 
  END IF;
59942
 
 
59943
 
  IF (COALESCE(_p.cashrcpt_void, false)) THEN
59944
 
    RAISE EXCEPTION 'Cannot post cashrcpt % because the document has been voided.', _p.cashrcpt_docnumber;
59945
 
  END IF;
59946
 
 
59947
 
  _predist := COALESCE(_p.cashrcpt_distdate < _p.applydate, false);
59948
 
 
59949
 
  IF (_p.cashrcpt_fundstype IN ('A', 'D', 'M', 'V')) THEN
59950
 
    SELECT ccpay_id, ccpay_type INTO _ccpayid, _cctype
59951
 
    FROM ccpay
59952
 
    WHERE ((ccpay_r_ordernum IN (CAST(pCashrcptid AS TEXT), _p.cashrcpt_docnumber))
59953
 
       AND (ccpay_status IN ('C', 'A')));
59954
 
 
59955
 
    IF NOT FOUND THEN
59956
 
      -- the following select seems to work except for xikar - bug 8848. why?
59957
 
      -- raise warning so there is some visibility if people fall into this path.
59958
 
      SELECT ccpay_id, ccpay_type INTO _ccpayid, _cctype
59959
 
      FROM ccpay
59960
 
      WHERE ((ccpay_order_number IN (CAST(pCashrcptid AS TEXT), _p.cashrcpt_docnumber))
59961
 
         AND (ccpay_status IN ('C', 'A')));
59962
 
      IF (NOT FOUND) THEN
59963
 
        RETURN -8;
59964
 
      ELSE
59965
 
        RAISE NOTICE 'PostCashReceipt() found ccpay_id % for order number %/% (ref 8848).',
59966
 
                      _ccpayid, pCashrcptid, _p.cashrcpt_docnumber;
59967
 
      END IF;
59968
 
    END IF;
59969
 
 
59970
 
    IF (_cctype = 'C' ) THEN
59971
 
      _debitAccntid := findPrepaidAccount(_p.cashrcpt_cust_id);
59972
 
    ELSE
59973
 
      SELECT accnt_id INTO _debitAccntid
59974
 
      FROM cashrcpt, bankaccnt, accnt
59975
 
      WHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id)
59976
 
       AND (bankaccnt_accnt_id=accnt_id)
59977
 
       AND (cashrcpt_id=pCashrcptid) );
59978
 
      IF (NOT FOUND) THEN
59979
 
        RETURN -6;
59980
 
      END IF;
59981
 
    END IF;
59982
 
  ELSE
59983
 
    SELECT accnt_id INTO _debitAccntid
59984
 
    FROM cashrcpt, bankaccnt, accnt
59985
 
    WHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id)
59986
 
     AND (bankaccnt_accnt_id=accnt_id)
59987
 
     AND (cashrcpt_id=pCashrcptid) );
59988
 
    IF (NOT FOUND) THEN
59989
 
      RETURN -6;
59990
 
    END IF;
59991
 
  END IF;
59992
 
 
59993
 
  SELECT COALESCE(SUM(cashrcptitem_amount), 0) INTO _postToAR
59994
 
  FROM cashrcptitem JOIN aropen ON (aropen_id=cashrcptitem_aropen_id)
59995
 
  WHERE (cashrcptitem_cashrcpt_id=pCashrcptid);
59996
 
  IF (NOT FOUND) THEN
59997
 
    _postToAR := 0;
59998
 
  END IF;
59999
 
 
60000
 
  SELECT COALESCE(SUM(cashrcptmisc_amount), 0) INTO _postToMisc
60001
 
  FROM cashrcptmisc
60002
 
  WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid);
60003
 
  IF (NOT FOUND) THEN
60004
 
    _postToMisc := 0;
60005
 
  END IF;
60006
 
 
60007
 
  SELECT COALESCE(SUM(cashrcptitem_discount), 0) INTO _postToCM
60008
 
  FROM cashrcptitem JOIN aropen ON ( (aropen_id=cashrcptitem_aropen_id) AND (aropen_doctype IN ('I', 'D')) )
60009
 
  WHERE (cashrcptitem_cashrcpt_id=pCashrcptid);
60010
 
  IF (NOT FOUND) THEN
60011
 
    _postToCM := 0;
60012
 
  END IF;
60013
 
  
60014
 
  IF ((_postToAR + _postToMisc) > _p.cashrcpt_amount) THEN
60015
 
    RETURN -1;
60016
 
  END IF;
60017
 
 
60018
 
  IF (_p.cashrcpt_amount <= 0) THEN
60019
 
    RETURN -2;
60020
 
  END IF;
60021
 
 
60022
 
    FOR _r IN SELECT aropen_id, aropen_doctype, aropen_docnumber, aropen_docdate,
60023
 
                     aropen_duedate, aropen_curr_id, aropen_curr_rate, aropen_amount,
60024
 
                     round(aropen_amount - aropen_paid, 2) <=
60025
 
                        round(currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_amount + cashrcptitem_discount),_p.cashrcpt_distdate),2)
60026
 
                                 AS closed,
60027
 
                     cashrcptitem_id, cashrcptitem_amount, cashrcptitem_discount,
60028
 
                     (cashrcptitem_amount / _p.cashrcpt_curr_rate) AS cashrcptitem_amount_base,
60029
 
                     (cashrcptitem_discount / _p.cashrcpt_curr_rate) AS cashrcptitem_discount_base,
60030
 
                     round(aropen_paid + 
60031
 
                       currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_amount),_p.cashrcpt_distdate),2) AS new_paid,
60032
 
                     round(currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,cashrcptitem_discount,_p.cashrcpt_distdate),2) AS new_discount
60033
 
              FROM cashrcptitem JOIN aropen ON (aropen_id=cashrcptitem_aropen_id)
60034
 
              WHERE ((cashrcptitem_cashrcpt_id=pCashrcptid)
60035
 
               AND (NOT _predist OR aropen_doctype IN ('C','R'))) LOOP
60036
 
  
60037
 
  --  Handle discount 
60038
 
      IF (_r.cashrcptitem_discount_base > 0) THEN
60039
 
        PERFORM postCashReceiptDisc(_r.cashrcptitem_id, pJournalNumber);
60040
 
      END IF;
60041
 
     
60042
 
  --  Update the aropen item to post the paid amount
60043
 
      UPDATE aropen
60044
 
      SET aropen_paid = _r.new_paid + _r.new_discount,
60045
 
          aropen_open = (NOT _r.closed),
60046
 
          aropen_closedate = CASE WHEN _r.closed THEN _p.cashrcpt_distdate END
60047
 
      WHERE (aropen_id=_r.aropen_id);
60048
 
  
60049
 
  --  Cache the running amount posted
60050
 
      _posted_base := _posted_base + _r.cashrcptitem_amount_base;
60051
 
      _posted := _posted + _r.cashrcptitem_amount;
60052
 
 
60053
 
  --  Record the cashrcpt application
60054
 
    IF (_r.aropen_doctype IN ('I','D')) THEN
60055
 
      INSERT INTO arapply
60056
 
      ( arapply_cust_id,
60057
 
        arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber,
60058
 
        arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber,
60059
 
        arapply_fundstype, arapply_refnumber, arapply_reftype, arapply_ref_id,
60060
 
        arapply_applied, arapply_closed,
60061
 
        arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username,
60062
 
        arapply_curr_id )
60063
 
      VALUES
60064
 
      ( _p.cashrcpt_cust_id,
60065
 
        -1, 'K', _p.cashrcpt_number,
60066
 
        _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber,
60067
 
        _p.cashrcpt_fundstype, _p.cashrcpt_docnumber, 'CRA', _r.cashrcptitem_id,
60068
 
        round(_r.cashrcptitem_amount, 2), _r.closed,
60069
 
        _p.applydate, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id);
60070
 
    ELSE
60071
 
      INSERT INTO arapply
60072
 
      ( arapply_cust_id,
60073
 
        arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber,
60074
 
        arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber,
60075
 
        arapply_fundstype, arapply_refnumber, arapply_reftype, arapply_ref_id,
60076
 
        arapply_applied, arapply_closed, arapply_postdate, arapply_distdate,
60077
 
        arapply_journalnumber, arapply_username, arapply_curr_id )
60078
 
      VALUES
60079
 
      ( _p.cashrcpt_cust_id,
60080
 
        _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber,
60081
 
        -1, 'R', _p.cashrcpt_number,
60082
 
        '', '', 'CRA', _r.cashrcptitem_id,
60083
 
        round(abs(_r.cashrcptitem_amount), 2), _r.closed,
60084
 
        _p.applydate, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id );
60085
 
    END IF;
60086
 
  
60087
 
      _exchGain := arCurrGain(_r.aropen_id,_p.cashrcpt_curr_id, abs(_r.cashrcptitem_amount),
60088
 
                             _p.cashrcpt_distdate);
60089
 
 
60090
 
       PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR',
60091
 
                          (_r.aropen_doctype || '-' || _r.aropen_docnumber),
60092
 
                          CASE WHEN _r.aropen_doctype != 'R' THEN _arAccntid
60093
 
                          ELSE findDeferredAccount(_p.cashrcpt_cust_id) END, 
60094
 
                          round(_r.cashrcptitem_amount_base + _exchGain, 2),
60095
 
                          _p.cashrcpt_distdate, _p.custnote, pCashrcptid );      
60096
 
                          
60097
 
      IF (_exchGain <> 0) THEN
60098
 
          PERFORM insertIntoGLSeries(_sequence, 'A/R', 'CR',
60099
 
                 _r.aropen_doctype || '-' || _r.aropen_docnumber,
60100
 
                 getGainLossAccntId(
60101
 
                   CASE WHEN _r.aropen_doctype != 'R' THEN _arAccntid
60102
 
                   ELSE findDeferredAccount(_p.cashrcpt_cust_id) END
60103
 
                 ), round(_exchGain, 2) * -1,
60104
 
                 _p.cashrcpt_distdate, _p.custnote, pCashrcptid);
60105
 
      END IF;
60106
 
 
60107
 
    END LOOP;
60108
 
 
60109
 
  FOR _r IN SELECT cashrcptmisc_id, cashrcptmisc_accnt_id, cashrcptmisc_amount,
60110
 
                   (cashrcptmisc_amount / cashrcpt_curr_rate) AS cashrcptmisc_amount_base,
60111
 
                   cashrcptmisc_notes, cashrcpt_curr_id
60112
 
            FROM cashrcptmisc JOIN
60113
 
                 cashrcpt ON (cashrcptmisc_cashrcpt_id = cashrcpt_id)
60114
 
            WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid)  LOOP
60115
 
 
60116
 
    _posted_base := (_posted_base + _r.cashrcptmisc_amount_base);
60117
 
    _posted := (_posted + _r.cashrcptmisc_amount);
60118
 
 
60119
 
    INSERT INTO arapply
60120
 
    ( arapply_cust_id,
60121
 
      arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber,
60122
 
      arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber,
60123
 
      arapply_fundstype, arapply_refnumber,
60124
 
      arapply_applied, arapply_closed,
60125
 
      arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username,
60126
 
      arapply_curr_id, arapply_reftype, arapply_ref_id )
60127
 
    VALUES
60128
 
    ( _p.cashrcpt_cust_id,
60129
 
      -1, 'K', '',
60130
 
      -1, 'Misc.', '',
60131
 
      _p.cashrcpt_fundstype, _p.cashrcpt_docnumber,
60132
 
      round(_r.cashrcptmisc_amount, 2), TRUE,
60133
 
      _p.applydate, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), 
60134
 
      _r.cashrcpt_curr_id, 'CRD', _r.cashrcptmisc_id );
60135
 
    PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', _r.cashrcptmisc_notes,
60136
 
                                _r.cashrcptmisc_accnt_id,
60137
 
                                round(_r.cashrcptmisc_amount_base, 2),
60138
 
                                _p.cashrcpt_distdate, _p.custnote, pCashrcptid );
60139
 
 
60140
 
  END LOOP;
60141
 
 
60142
 
  IF (round(_posted_base, 2) < round(_p.cashrcpt_amount_base, 2)) THEN
60143
 
    _comment := ('Unapplied from ' || _p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber);
60144
 
    PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR',
60145
 
                                _comment,
60146
 
                                _p.prepaid_accnt_id,
60147
 
                                round(_p.cashrcpt_amount_base, 2) -
60148
 
                                                        round(_posted_base, 2),
60149
 
                                _p.cashrcpt_distdate, _p.custnote, pCashrcptid );
60150
 
    SELECT fetchArMemoNumber() INTO _arMemoNumber;
60151
 
    IF(_p.cashrcpt_usecustdeposit) THEN
60152
 
      -- Post Customer Deposit
60153
 
      SELECT createARCashDeposit(_p.cashrcpt_cust_id, _arMemoNumber, '',
60154
 
                                 _p.cashrcpt_distdate, (_p.cashrcpt_amount - _posted),
60155
 
                                 _comment, pJournalNumber, _p.cashrcpt_curr_id) INTO _aropenid;
60156
 
    ELSE
60157
 
      -- Post A/R Credit Memo
60158
 
      _aropenid := createARCreditMemo(NULL, _p.cashrcpt_cust_id, _arMemoNumber, '',
60159
 
                                _p.cashrcpt_distdate, (_p.cashrcpt_amount - _posted),
60160
 
                                _comment, -1, -1, -1, _p.cashrcpt_distdate, -1, NULL, 0,
60161
 
                                pJournalNumber, _p.cashrcpt_curr_id, _arAccntid);
60162
 
    END IF;
60163
 
 
60164
 
    IF (_ccpayid IS NOT NULL) THEN
60165
 
      INSERT INTO payaropen (payaropen_ccpay_id, payaropen_aropen_id,
60166
 
                             payaropen_amount,   payaropen_curr_id
60167
 
                   ) VALUES (_ccpayid,           _aropenid,
60168
 
                             _p.cashrcpt_amount, _p.cashrcpt_curr_id);
60169
 
    END IF;
60170
 
 
60171
 
    -- Create Cash Receipt Item to capture posting
60172
 
    IF (_predist=false) THEN
60173
 
      INSERT INTO cashrcptitem
60174
 
        ( cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount, cashrcptitem_applied )
60175
 
      VALUES
60176
 
        ( pCashrcptid, _aropenid, (_p.cashrcpt_amount - _posted), false );
60177
 
    END IF;
60178
 
 
60179
 
  ELSIF (round(_posted_base, 2) > round((_p.cashrcpt_amount_base), 2)) THEN
60180
 
    PERFORM insertIntoGLSeries(_sequence, 'A/R', 'CR',
60181
 
                   'Currency Exchange Rounding - ' || _p.cashrcpt_docnumber,
60182
 
                   getGainLossAccntId(_debitAccntid),
60183
 
                   round(_posted_base, 2) - round((_p.cashrcpt_amount_base + _p.cashrcpt_discount_base), 2),
60184
 
                   _p.cashrcpt_distdate, _p.custnote, pCashrcptid);
60185
 
  END IF;
60186
 
 
60187
 
  PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR',
60188
 
                    (_p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber),
60189
 
                     _debitAccntid, round(_p.cashrcpt_amount_base, 2) * -1, 
60190
 
                     _p.cashrcpt_distdate,
60191
 
                     _p.custnote, pCashrcptid );
60192
 
 
60193
 
  -- Post any gain/loss from the alternate currency exchange rate
60194
 
  IF (COALESCE(_p.cashrcpt_alt_curr_rate, 0.0) <> 0.0) THEN
60195
 
    _exchGain := ROUND((_p.cashrcpt_amount / _p.cashrcpt_alt_curr_rate) -
60196
 
                       (_p.cashrcpt_amount / _p.cashrcpt_curr_rate), 2);
60197
 
 
60198
 
    IF (_exchGain <> 0) THEN
60199
 
      PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR',
60200
 
                          (_p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber),
60201
 
                          _debitAccntid, (_exchGain * -1.0),
60202
 
                          _p.cashrcpt_distdate, _p.custnote, pCashrcptid );      
60203
 
                          
60204
 
      PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR',
60205
 
                          (_p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber),
60206
 
                          getGainLossAccntId(_debitAccntid), _exchGain,
60207
 
                          _p.cashrcpt_distdate, _p.custnote, pCashrcptid );      
60208
 
    END IF;
60209
 
  END IF;
60210
 
 
60211
 
  PERFORM postGLSeries(_sequence, pJournalNumber);
60212
 
 
60213
 
  -- convert the cashrcptitem records to applications against the cm/cd if we are _predist
60214
 
  IF(_predist=true) THEN
60215
 
    FOR _r IN SELECT *
60216
 
              FROM cashrcptitem
60217
 
              WHERE ((cashrcptitem_cashrcpt_id=pCashrcptid)
60218
 
                AND (cashrcptitem_amount > 0)) LOOP
60219
 
 
60220
 
      -- Handle discount if applicable
60221
 
      IF (_r.cashrcptitem_discount > 0) THEN
60222
 
        PERFORM postCashReceiptDisc(_r.cashrcptitem_id, pJournalNumber);
60223
 
      END IF;
60224
 
      
60225
 
      INSERT INTO arcreditapply (arcreditapply_source_aropen_id, arcreditapply_target_aropen_id,
60226
 
                                 arcreditapply_amount, arcreditapply_curr_id)
60227
 
                          VALUES(_aropenid, _r.cashrcptitem_aropen_id,
60228
 
                                 _r.cashrcptitem_amount, _p.cashrcpt_curr_id);
60229
 
      _posted := (_posted + _r.cashrcptitem_amount);
60230
 
      
60231
 
    END LOOP;
60232
 
 
60233
 
    PERFORM postArCreditMemoApplication(_aropenid, _p.applydate);
60234
 
    
60235
 
    -- If there is any left over go ahead and create an additional cashrcptitem record for it with the amount
60236
 
    IF (round(_posted, 2) < round(_p.cashrcpt_amount, 2)) THEN
60237
 
      INSERT INTO cashrcptitem
60238
 
        ( cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount, cashrcptitem_applied )
60239
 
      VALUES
60240
 
        ( pCashrcptid, _aropenid, (_p.cashrcpt_amount - _posted), false );
60241
 
    END IF;
60242
 
  END IF;
60243
 
 
60244
 
  UPDATE cashrcpt SET cashrcpt_posted=TRUE,
60245
 
                      cashrcpt_posteddate=CURRENT_DATE,
60246
 
                      cashrcpt_postedby=getEffectiveXtUser()
60247
 
  WHERE (cashrcpt_id=pCashrcptid);
60248
 
 
60249
 
  RETURN 1;
60250
 
 
60251
 
END;
60252
 
$$;
60253
 
 
60254
 
 
60255
 
ALTER FUNCTION public.postcashreceipt(pcashrcptid integer, pjournalnumber integer) OWNER TO admin;
60256
 
 
60257
 
--
60258
 
--
60259
 
 
60260
 
CREATE FUNCTION postcashreceiptdisc(integer, integer) RETURNS integer
60261
 
    LANGUAGE plpgsql
60262
 
    AS $_$
60263
 
DECLARE
60264
 
  pCashrcptItemId ALIAS FOR $1;
60265
 
  pJournalNumber ALIAS FOR $2;
60266
 
  _r RECORD;
60267
 
  _t RECORD;
60268
 
  _v RECORD;
60269
 
  _ardiscountid INTEGER;
60270
 
  _arMemoNumber TEXT;
60271
 
  _arAccntid INTEGER;
60272
 
  _discountAccntid INTEGER;
60273
 
  _comment      TEXT;
60274
 
  _discprcnt NUMERIC;
60275
 
  _check INTEGER;
60276
 
 
60277
 
BEGIN
60278
 
 
60279
 
    -- Fetch base records for processing
60280
 
    SELECT aropen_id, aropen_doctype, aropen_amount,
60281
 
           cashrcptitem_discount,
60282
 
           cashrcpt_cust_id, cashrcpt_distdate, cashrcpt_applydate,
60283
 
           cashrcpt_curr_id, cashrcpt_fundstype, cashrcpt_docnumber,
60284
 
           round(currToCurr(cashrcpt_curr_id, aropen_curr_id, cashrcptitem_discount, cashrcpt_distdate),2) AS aropen_discount
60285
 
      INTO _r
60286
 
    FROM cashrcptitem 
60287
 
      JOIN cashrcpt ON (cashrcptitem_cashrcpt_id=cashrcpt_id)
60288
 
      JOIN aropen ON ( (aropen_id=cashrcptitem_aropen_id) AND (aropen_doctype IN ('I', 'D')) )
60289
 
    WHERE (cashrcptitem_id=pCashrcptItemId);
60290
 
 
60291
 
    -- Get discount account
60292
 
    _discountAccntid := findardiscountaccount(_r.cashrcpt_cust_id);
60293
 
  
60294
 
    IF (_r.cashrcptitem_discount > 0) THEN
60295
 
      --  Determine discount percentage
60296
 
      _discprcnt := _r.aropen_discount / _r.aropen_amount;
60297
 
 
60298
 
      SELECT fetchArMemoNumber() INTO _arMemoNumber;
60299
 
      _comment := 'Discount Credit from ' || _r.cashrcpt_fundstype || '-' || _r.cashrcpt_docnumber;
60300
 
 
60301
 
      -- Create misc credit memo record
60302
 
      _ardiscountid := nextval('aropen_aropen_id_seq');
60303
 
      INSERT INTO aropen (
60304
 
        aropen_id, aropen_docdate, aropen_duedate, aropen_doctype, 
60305
 
        aropen_docnumber, aropen_curr_id, aropen_posted, aropen_amount) 
60306
 
      VALUES (
60307
 
        _ardiscountid, _r.cashrcpt_distdate, _r.cashrcpt_distdate, 'C', 
60308
 
        _arMemoNumber, _r.cashrcpt_curr_id, false,_r.cashrcptitem_discount);
60309
 
        
60310
 
      IF (fetchMetricBool('CreditTaxDiscount')) THEN
60311
 
        --  proportional tax credits calculated and implemented for the credit memo generated by the discount
60312
 
        IF (_r.aropen_doctype  = 'I') THEN
60313
 
          -- Tax for invoices
60314
 
          SELECT aropen_cobmisc_id AS invcheadid, 
60315
 
                 invchead_curr_id, 
60316
 
                 invchead_invcdate INTO _t
60317
 
          FROM aropen
60318
 
            LEFT OUTER JOIN invchead ON (aropen_cobmisc_id = invchead_id) 
60319
 
            LEFT OUTER JOIN invcitem ON (invchead_id = invcitem_invchead_id)
60320
 
          WHERE aropen_id = _r.aropen_id;
60321
 
 
60322
 
          FOR _v IN SELECT tax_sales_accnt_id,
60323
 
                           tax_id, 
60324
 
                           round(sum(taxdetail_tax), 2) AS tax,
60325
 
                           currToBase(_t.invchead_curr_id, round(sum(taxdetail_tax), 2), _t.invchead_invcdate) AS taxbasevalue
60326
 
          FROM tax 
60327
 
            JOIN calculateTaxDetailSummary('I', _t.invcheadid, 'T') ON (taxdetail_tax_id=tax_id)
60328
 
            GROUP BY tax_id, tax_sales_accnt_id 
60329
 
          LOOP
60330
 
            INSERT INTO aropentax(
60331
 
              taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id,
60332
 
              taxhist_percent, taxhist_amount, taxhist_tax, 
60333
 
              taxhist_docdate, taxhist_basis)
60334
 
            VALUES (
60335
 
              _ardiscountid, getadjustmenttaxtypeid(), _v.tax_id, 
60336
 
              0.00, 0.00, (round((_v.tax * _discprcnt), 2) * -1), 
60337
 
              _r.cashrcpt_distdate, 0.00);
60338
 
          END LOOP;
60339
 
 
60340
 
        ELSIF (_r.aropen_doctype  = 'D') THEN
60341
 
          -- Tax for debit memos
60342
 
          INSERT INTO aropentax(
60343
 
            taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id,
60344
 
            taxhist_percent, taxhist_amount, taxhist_tax, 
60345
 
            taxhist_docdate, taxhist_basis)
60346
 
          SELECT
60347
 
            _ardiscountid, taxhist_taxtype_id, taxhist_tax_id, 
60348
 
            0.00, 0.00, (round((taxhist_tax * _discprcnt), 2) * -1),  
60349
 
            _r.cashrcpt_distdate, 0.00
60350
 
          FROM aropentax
60351
 
          WHERE (taxhist_parent_id=_r.aropen_id);
60352
 
              
60353
 
        END IF;
60354
 
      END IF; -- End taxes
60355
 
 
60356
 
      -- Create credit memo for discount
60357
 
      SELECT createARCreditMemo(_ardiscountid, _r.cashrcpt_cust_id, _arMemoNumber, '',
60358
 
                                _r.cashrcpt_distdate, _r.cashrcptitem_discount,
60359
 
                                _comment, -1, -1, _discountAccntid, _r.cashrcpt_distdate,
60360
 
                                -1, NULL, 0,
60361
 
                                pJournalNumber, _r.cashrcpt_curr_id) INTO _ardiscountid;
60362
 
 
60363
 
      -- Apply discount credit memo
60364
 
      INSERT INTO arcreditapply ( 
60365
 
        arcreditapply_source_aropen_id, arcreditapply_target_aropen_id,
60366
 
        arcreditapply_amount, arcreditapply_curr_id )
60367
 
      VALUES ( 
60368
 
        _ardiscountid, _r.aropen_id, _r.cashrcptitem_discount, _r.cashrcpt_curr_id );
60369
 
 
60370
 
      SELECT postARCreditMemoApplication(_ardiscountid, _r.cashrcpt_applydate) INTO _check;
60371
 
      IF (_check < 0) THEN
60372
 
        RAISE EXCEPTION 'Error posting discount credit memo application. Code %', _check;
60373
 
      END IF;
60374
 
        
60375
 
   END IF; -- End handle Discount
60376
 
 
60377
 
   RETURN 1;
60378
 
 
60379
 
END;
60380
 
$_$;
60381
 
 
60382
 
 
60383
 
ALTER FUNCTION public.postcashreceiptdisc(integer, integer) OWNER TO admin;
60384
 
 
60385
 
--
60386
 
--
60387
 
 
60388
 
CREATE FUNCTION postcccashreceipt(pccpay integer, pdocid integer, pdoctype text DEFAULT NULL::text, pamount numeric DEFAULT NULL::numeric) RETURNS integer
60389
 
    LANGUAGE plpgsql
60390
 
    AS $$
60391
 
DECLARE
60392
 
  _aropenid     INTEGER;
60393
 
  _bankaccnt_id INTEGER;
60394
 
  _c            RECORD;
60395
 
  _ccOrderDesc  TEXT;
60396
 
  _journal      INTEGER;
60397
 
  _realaccnt    INTEGER;
60398
 
  _return       INTEGER := 0;
60399
 
 
60400
 
BEGIN
60401
 
  SELECT * INTO _c
60402
 
     FROM ccpay
60403
 
     JOIN custinfo ON ccpay_cust_id = cust_id
60404
 
     WHERE (ccpay_id = pCCpay);
60405
 
 
60406
 
  IF (NOT FOUND) THEN
60407
 
    RAISE EXCEPTION 'Cannot find the Credit Card transaction information [xtuple: postCCcashReceipt, -11, %]',
60408
 
                    pCCpay;
60409
 
  END IF;
60410
 
 
60411
 
  IF (pamount IS NOT NULL) THEN
60412
 
    _c.ccpay_amount = pamount;
60413
 
  END IF;
60414
 
 
60415
 
  SELECT bankaccnt_id, bankaccnt_accnt_id INTO _bankaccnt_id, _realaccnt
60416
 
  FROM ccbank
60417
 
  JOIN bankaccnt ON (ccbank_bankaccnt_id=bankaccnt_id)
60418
 
  WHERE (ccbank_ccard_type=_c.ccpay_card_type);
60419
 
 
60420
 
  IF (_bankaccnt_id IS NULL) THEN
60421
 
    RAISE EXCEPTION 'Cannot find the default Bank Account for this Credit Card [xtuple: postCCcredit, -1, %]',
60422
 
                    _c.ccpay_card_type;
60423
 
  END IF;
60424
 
 
60425
 
  _ccOrderDesc := (_c.ccpay_card_type || '-' || _c.ccpay_order_number::TEXT ||
60426
 
                  '-' || _c.ccpay_order_number_seq::TEXT);
60427
 
 
60428
 
  _journal := fetchJournalNumber('C/R');
60429
 
 
60430
 
  IF (pdoctype = 'cashrcpt') THEN
60431
 
    IF (COALESCE(pdocid, -1) < 0) THEN
60432
 
      INSERT INTO cashrcpt (
60433
 
        cashrcpt_cust_id,   cashrcpt_amount,     cashrcpt_curr_id,
60434
 
        cashrcpt_fundstype, cashrcpt_docnumber,  cashrcpt_notes,
60435
 
        cashrcpt_distdate,  cashrcpt_bankaccnt_id,
60436
 
        cashrcpt_usecustdeposit
60437
 
      ) VALUES (
60438
 
        _c.ccpay_cust_id,   _c.ccpay_amount,     _c.ccpay_curr_id,
60439
 
        _c.ccpay_card_type,      _c.ccpay_r_ordernum, _ccOrderDesc,
60440
 
        CURRENT_DATE,       _bankaccnt_id,
60441
 
        fetchMetricBool('EnableCustomerDeposits'))
60442
 
      RETURNING cashrcpt_id INTO _return;
60443
 
    ELSE
60444
 
      UPDATE cashrcpt
60445
 
      SET cashrcpt_cust_id=_c.ccpay_cust_id,
60446
 
          cashrcpt_amount=_c.ccpay_amount,
60447
 
          cashrcpt_curr_id=_c.ccpay_curr_id,
60448
 
          cashrcpt_fundstype=_c.ccpay_card_type,
60449
 
          cashrcpt_docnumber=_c.ccpay_r_ordernum,
60450
 
          cashrcpt_notes=_ccOrderDesc,
60451
 
          cashrcpt_distdate=CURRENT_DATE,
60452
 
          cashrcpt_bankaccnt_id=_bankaccnt_id
60453
 
      WHERE (cashrcpt_id=pdocid);
60454
 
      _return := pdocid;
60455
 
    END IF;
60456
 
 
60457
 
  ELSIF (pdoctype = 'cohead') THEN
60458
 
    SELECT createARCreditMemo(NULL,               _c.ccpay_cust_id,
60459
 
                             fetchArMemoNumber(), cohead_number,
60460
 
                             CURRENT_DATE,        _c.ccpay_amount,
60461
 
                             'Unapplied from ' || _ccOrderDesc,
60462
 
                             NULL,                NULL, NULL,
60463
 
                             CURRENT_DATE,        NULL,
60464
 
                             cohead_salesrep_id,  NULL,
60465
 
                             _journal,            _c.ccpay_curr_id,
60466
 
                             NULL,                pCCpay) INTO _aropenid
60467
 
      FROM cohead
60468
 
     WHERE cohead_id = pdocid;
60469
 
    IF (COALESCE(_aropenid, -1) < 0) THEN       -- coalesce handles not-found case
60470
 
      RAISE EXCEPTION '[xtuple: createARCreditMemo, %]', _aropenid;
60471
 
    END IF;
60472
 
 
60473
 
    INSERT INTO payaropen (payaropen_ccpay_id, payaropen_aropen_id,
60474
 
                           payaropen_amount,   payaropen_curr_id)
60475
 
                  VALUES  (pccpay,             _aropenid,
60476
 
                           _c.ccpay_amount,    _c.ccpay_curr_id);
60477
 
    INSERT INTO aropenalloc (aropenalloc_aropen_id, aropenalloc_doctype, aropenalloc_doc_id,
60478
 
                             aropenalloc_amount,    aropenalloc_curr_id)
60479
 
                     VALUES (_aropenid, 'S',          pdocid,
60480
 
                             _c.ccpay_amount,    _c.ccpay_curr_id);
60481
 
    _return := _aropenid;
60482
 
  END IF;
60483
 
 
60484
 
  PERFORM insertGLTransaction(_journal, 'A/R', 'CR', _ccOrderDesc,
60485
 
                              ('Cash Receipt from Credit Card ' || _c.cust_name),
60486
 
                              findPrepaidAccount(_c.ccpay_cust_id),
60487
 
                              _realaccnt,
60488
 
                              NULL,
60489
 
                              ROUND(currToBase(_c.ccpay_curr_id,
60490
 
                                               _c.ccpay_amount,
60491
 
                                               _c.ccpay_transaction_datetime::DATE),2),
60492
 
                              CURRENT_DATE);
60493
 
 
60494
 
  RETURN _return;
60495
 
END;
60496
 
$$;
60497
 
 
60498
 
 
60499
 
ALTER FUNCTION public.postcccashreceipt(pccpay integer, pdocid integer, pdoctype text, pamount numeric) OWNER TO admin;
60500
 
 
60501
 
--
60502
 
--
60503
 
 
60504
 
CREATE FUNCTION postcccredit(integer, text, integer) RETURNS integer
60505
 
    LANGUAGE plpgsql
60506
 
    AS $_$
60507
 
DECLARE
60508
 
  pCCpay        ALIAS FOR $1;
60509
 
  preftype      ALIAS FOR $2;
60510
 
  prefid        ALIAS FOR $3;
60511
 
  _c            RECORD;
60512
 
  _ccOrderDesc  TEXT;
60513
 
  _cglaccnt     INTEGER;
60514
 
  _dglaccnt     INTEGER;
60515
 
  _glseriesres  INTEGER;
60516
 
  _notes        TEXT := 'Credit via Credit Card';
60517
 
  _r            RECORD;
60518
 
  _sequence     INTEGER;
60519
 
  _dmaropenid   INTEGER;
60520
 
 
60521
 
BEGIN
60522
 
  IF ((preftype = 'cohead') AND NOT EXISTS(SELECT cohead_id
60523
 
                                           FROM cohead
60524
 
                                           WHERE (cohead_id=prefid))) THEN
60525
 
    RAISE EXCEPTION 'Cannot find original Sales Order for this Credit Card credit [xtuple: postCCcredit, -2, %, %, %]',
60526
 
                    pCCpay, preftype, prefid;
60527
 
  ELSIF ((preftype = 'aropen') AND NOT EXISTS(SELECT aropen_id
60528
 
                                              FROM aropen
60529
 
                                              WHERE (aropen_id=prefid))) THEN
60530
 
    RAISE EXCEPTION 'Cannot find original A/R Open record for this Credit Card credit [xtuple: postCCcredit, -2, %, %, %]',
60531
 
                    pCCpay, preftype, prefid;
60532
 
  ELSIF ((preftype = 'cmhead') AND NOT EXISTS(SELECT cmhead_id
60533
 
                                              FROM cmhead
60534
 
                                              WHERE cmhead_id=prefid)) THEN
60535
 
    RAISE EXCEPTION 'Cannot find original Credit Memo record for this Credit Card credit [xtuple: postCCcredit, -2, %, %, %]',
60536
 
                    pCCpay, preftype, prefid;
60537
 
  END IF;
60538
 
 
60539
 
  SELECT * INTO _c
60540
 
  FROM ccpay
60541
 
  WHERE (ccpay_id = pCCpay);
60542
 
 
60543
 
  IF (NOT FOUND) THEN
60544
 
    RAISE EXCEPTION 'Cannot find the record for this Credit Card credit [xtuple: postCCcredit, -3, %, %, %]',
60545
 
                    pCCpay, preftype, prefid;
60546
 
  END IF;
60547
 
 
60548
 
  IF (preftype = 'cohead') THEN
60549
 
    _dglaccnt := findPrepaidAccount(_c.ccpay_cust_id);
60550
 
  ELSE
60551
 
    _dglaccnt := findARAccount(_c.ccpay_cust_id);
60552
 
  END IF;
60553
 
 
60554
 
  SELECT bankaccnt_accnt_id INTO _cglaccnt
60555
 
  FROM ccbank
60556
 
  JOIN bankaccnt ON (ccbank_bankaccnt_id=bankaccnt_id)
60557
 
  WHERE (ccbank_ccard_type=_c.ccpay_card_type);
60558
 
 
60559
 
  IF (NOT FOUND) THEN
60560
 
    RAISE EXCEPTION 'Cannot find the default Bank Account for this Credit Card [xtuple: postCCcredit, -1, %]',
60561
 
                    pCCpay;
60562
 
  END IF;
60563
 
 
60564
 
  IF (_c.ccpay_type != 'R') THEN
60565
 
    RAISE EXCEPTION 'This Credit Card transaction is not a credit/refund [xtuple: postCCcredit, -4, %]',
60566
 
                    pCCpay;
60567
 
  END IF;
60568
 
 
60569
 
  _sequence := fetchGLSequence();
60570
 
 
60571
 
  IF (_c.ccpay_r_ref IS NOT NULL) THEN
60572
 
    _ccOrderDesc := (_c.ccpay_card_type || '-' || _c.ccpay_r_ref);
60573
 
  ELSE
60574
 
    _ccOrderDesc := (_c.ccpay_card_type || '-' || _c.ccpay_order_number::TEXT ||
60575
 
                    '-' || COALESCE(_c.ccpay_order_number_seq::TEXT, ''));
60576
 
  END IF;
60577
 
 
60578
 
  _glseriesres := insertIntoGLSeries(_sequence, 'A/R', 'CC', _ccOrderDesc,
60579
 
                                     _dglaccnt,
60580
 
                                     ROUND(currToBase(_c.ccpay_curr_id,
60581
 
                                                      _c.ccpay_amount,
60582
 
                                                      _c.ccpay_transaction_datetime::DATE), 2) * -1,
60583
 
                                     CURRENT_DATE, _notes);
60584
 
  IF (_glseriesres < 0) THEN
60585
 
    RAISE EXCEPTION 'Could not write debit side of Credit Card credit to the G/L [xtuple: insertIntoGLSeries, %]',
60586
 
                    _glseriesres;
60587
 
  END IF;
60588
 
 
60589
 
  _glseriesres := insertIntoGLSeries(_sequence, 'A/R', 'CC', _ccOrderDesc,
60590
 
                                     _cglaccnt,
60591
 
                                     ROUND(currToBase(_c.ccpay_curr_id,
60592
 
                                                      _c.ccpay_amount,
60593
 
                                                      _c.ccpay_transaction_datetime::DATE),2),
60594
 
                                     CURRENT_DATE, _notes);
60595
 
  IF (_glseriesres < 0) THEN
60596
 
    RAISE EXCEPTION 'Could not write credit side of Credit Card credit to the G/L [xtuple: insertIntoGLSeries, %]',
60597
 
                    _glseriesres;
60598
 
  END IF;
60599
 
 
60600
 
  _glseriesres := postGLSeries(_sequence, fetchJournalNumber('C/R') );
60601
 
  IF (_glseriesres < 0) THEN
60602
 
    RAISE EXCEPTION 'Could not post Credit Card credit to the G/L [xtuple: postglseries, %]',
60603
 
                    _glseriesres;
60604
 
  END IF;
60605
 
 
60606
 
  IF (preftype = 'aropen') THEN
60607
 
    SELECT * INTO _r
60608
 
    FROM aropen
60609
 
    WHERE (aropen_id=prefid);
60610
 
 
60611
 
  ELSE
60612
 
    SELECT aropen.* INTO _r
60613
 
    FROM ccpay n
60614
 
      JOIN ccpay o  ON (o.ccpay_id=n.ccpay_ccpay_id)
60615
 
      JOIN payaropen ON (payaropen_ccpay_id=o.ccpay_id)
60616
 
      JOIN aropen ON (payaropen_aropen_id=aropen_id)
60617
 
    WHERE (n.ccpay_id=pCCpay);
60618
 
  END IF;
60619
 
 
60620
 
  IF (FOUND) THEN
60621
 
    SELECT createardebitmemo(
60622
 
            NULL,
60623
 
            _r.aropen_cust_id, NULL, fetchARMemoNumber(),
60624
 
            _r.aropen_ordernumber, current_date, _c.ccpay_amount,
60625
 
            _notes,
60626
 
            -1, -1, -1, CURRENT_DATE, -1, NULL, 0,
60627
 
            _r.aropen_curr_id) INTO _dmaropenid;
60628
 
 
60629
 
    IF (_r.aropen_open) THEN
60630
 
      PERFORM applyARCreditMemoToBalance(_r.aropen_id, _dmaropenid);
60631
 
      PERFORM postARCreditMemoApplication(_r.aropen_id);
60632
 
    END IF;
60633
 
 
60634
 
  END IF;
60635
 
 
60636
 
  IF (preftype = 'cohead') THEN
60637
 
    INSERT INTO payco (
60638
 
      payco_ccpay_id, payco_cohead_id, payco_amount, payco_curr_id
60639
 
    ) VALUES (
60640
 
      pCCpay, prefid, 0 - _c.ccpay_amount, _c.ccpay_curr_id
60641
 
    );
60642
 
  END IF;
60643
 
 
60644
 
  RETURN 0;
60645
 
 
60646
 
END;
60647
 
$_$;
60648
 
 
60649
 
 
60650
 
ALTER FUNCTION public.postcccredit(integer, text, integer) OWNER TO admin;
60651
 
 
60652
 
--
60653
 
--
60654
 
 
60655
 
CREATE FUNCTION postccvoid(integer) RETURNS integer
60656
 
    LANGUAGE plpgsql
60657
 
    AS $_$
60658
 
DECLARE
60659
 
  pccpayid ALIAS FOR $1;
60660
 
 
60661
 
BEGIN
60662
 
  -- for now this is very simple: mark the ccpay record voided.
60663
 
  -- in the future this might be expanded to back out changes to other tables
60664
 
  -- but for now the VOID request is sent to the credit card processing company
60665
 
  -- before those other tables are modified.
60666
 
 
60667
 
  UPDATE ccpay SET ccpay_status = 'V' WHERE (ccpay_id=pccpayid);
60668
 
 
60669
 
  IF (NOT FOUND) THEN
60670
 
    RETURN -1;
60671
 
  END IF;
60672
 
 
60673
 
  RETURN 0;
60674
 
 
60675
 
END;
60676
 
$_$;
60677
 
 
60678
 
 
60679
 
ALTER FUNCTION public.postccvoid(integer) OWNER TO admin;
60680
 
 
60681
 
--
60682
 
--
60683
 
 
60684
 
CREATE FUNCTION postcheck(integer, integer) RETURNS integer
60685
 
    LANGUAGE plpgsql
60686
 
    AS $_$
60687
 
DECLARE
60688
 
  pcheckid              ALIAS FOR $1;
60689
 
  _journalNumber        INTEGER := $2;
60690
 
  _amount_base          NUMERIC := 0;
60691
 
  _credit_glaccnt       INTEGER;
60692
 
  _exchGain             NUMERIC := 0;
60693
 
  _exchGainTmp          NUMERIC := 0;
60694
 
  _gltransNote          TEXT;
60695
 
  _p                    RECORD;
60696
 
  _r                    RECORD;
60697
 
  _t                    RECORD;
60698
 
  _sequence             INTEGER;
60699
 
  _test                 INTEGER;
60700
 
  _cm                   BOOLEAN;
60701
 
  _amount_check         NUMERIC := 0;
60702
 
 
60703
 
BEGIN
60704
 
 
60705
 
  _cm := FALSE;
60706
 
 
60707
 
  SELECT fetchGLSequence() INTO _sequence;
60708
 
  IF (_journalNumber IS NULL) THEN
60709
 
    _journalNumber := fetchJournalNumber('AP-CK');
60710
 
  END IF;
60711
 
 
60712
 
  SELECT checkhead.*,
60713
 
         checkhead_amount / checkhead_curr_rate AS checkhead_amount_base,
60714
 
         bankaccnt_accnt_id AS bankaccntid INTO _p
60715
 
  FROM checkhead
60716
 
   JOIN bankaccnt ON (checkhead_bankaccnt_id=bankaccnt_id)
60717
 
  WHERE (checkhead_id=pcheckid);
60718
 
 
60719
 
  IF (FOUND) THEN
60720
 
    IF (_p.checkhead_recip_type = 'V') THEN
60721
 
      SELECT
60722
 
        vend_number AS checkrecip_number,
60723
 
        vend_name AS checkrecip_name,
60724
 
        findAPAccount(vend_id) AS checkrecip_accnt_id,
60725
 
        'A/P'::text AS checkrecip_gltrans_source
60726
 
        INTO _t
60727
 
      FROM vendinfo
60728
 
      WHERE (vend_id=_p.checkhead_recip_id);
60729
 
    ELSIF (_p.checkhead_recip_type = 'C') THEN
60730
 
      SELECT
60731
 
        cust_number AS checkrecip_number,
60732
 
        cust_name AS checkrecip_name,
60733
 
        findARAccount(cust_id) AS checkrecip_accnt_id,
60734
 
        'A/R'::text AS checkrecip_gltrans_source
60735
 
        INTO _t
60736
 
      FROM custinfo
60737
 
      WHERE (cust_id=_p.checkhead_recip_id); 
60738
 
    ELSIF (_p.checkhead_recip_type = 'T') THEN
60739
 
      SELECT
60740
 
        taxauth_code AS checkrecip_number,
60741
 
        taxauth_name AS checkrecip_name,
60742
 
        taxauth_accnt_id AS checkrecip_accnt_id,
60743
 
        'G/L'::text AS checkrecip_gltrans_source
60744
 
        INTO _t
60745
 
      FROM taxauth
60746
 
      WHERE (taxauth_id=_p.checkhead_recip_id);
60747
 
    ELSE
60748
 
      RETURN -11;
60749
 
    END IF;
60750
 
  ELSE
60751
 
    RETURN -11;
60752
 
  END IF;
60753
 
 
60754
 
  IF (_p.checkhead_posted) THEN
60755
 
    RETURN -10;
60756
 
  END IF;
60757
 
 
60758
 
  IF (_p.checkhead_recip_type = 'C') THEN
60759
 
    SELECT checkitem_id FROM checkitem INTO _test
60760
 
    WHERE (checkitem_checkhead_id=pcheckid)
60761
 
    LIMIT 1;
60762
 
    IF (FOUND) THEN
60763
 
      _cm := TRUE;
60764
 
    END IF;
60765
 
  END IF;
60766
 
 
60767
 
  _gltransNote := _t.checkrecip_number || '-' || _t.checkrecip_name;
60768
 
 
60769
 
  IF (_p.checkhead_misc AND NOT _cm) THEN
60770
 
    IF (COALESCE(_p.checkhead_expcat_id, -1) < 0) THEN
60771
 
      IF (_p.checkhead_recip_type = 'V') THEN
60772
 
        PERFORM createAPCreditMemo( _p.checkhead_recip_id, _journalNumber,
60773
 
                                    CAST(fetchAPMemoNumber() AS text), '',
60774
 
                                    _p.checkhead_checkdate, _p.checkhead_amount,
60775
 
                                    _gltransNote || ' ' || _p.checkhead_notes,
60776
 
                                    -1, _p.checkhead_checkdate,
60777
 
                                    -1, _p.checkhead_curr_id );
60778
 
        _credit_glaccnt := findAPPrepaidAccount(_p.checkhead_recip_id);
60779
 
 
60780
 
      ELSIF (_p.checkhead_recip_type = 'C') THEN
60781
 
        PERFORM createARDebitMemo(NULL, _p.checkhead_recip_id, NULL,
60782
 
                                     fetchARMemoNumber(), '',
60783
 
                                     _p.checkhead_checkdate, _p.checkhead_amount,
60784
 
                                     _gltransNote || ' ' || _p.checkhead_notes,
60785
 
                                     -1, -1, -1, _p.checkhead_checkdate, -1, NULL, 0,
60786
 
                                     _p.checkhead_curr_id );
60787
 
        _credit_glaccnt := findPrepaidAccount(_p.checkhead_recip_id);
60788
 
      ELSIF (_p.checkhead_recip_type = 'T') THEN
60789
 
        -- TODO: should we create a credit memo for the tax authority? how?
60790
 
        _credit_glaccnt := _t.checkrecip_accnt_id;
60791
 
 
60792
 
      END IF; -- recip type
60793
 
 
60794
 
    ELSE
60795
 
      IF (_cm) THEN
60796
 
        _credit_glaccnt := findARAccount(_p.checkhead_recip_id);
60797
 
      ELSE
60798
 
        SELECT expcat_exp_accnt_id INTO _credit_glaccnt
60799
 
        FROM expcat
60800
 
        WHERE (expcat_id=_p.checkhead_expcat_id);
60801
 
        IF (NOT FOUND) THEN
60802
 
          RETURN -12;
60803
 
        END IF;
60804
 
      END IF;
60805
 
    END IF;
60806
 
 
60807
 
    IF (COALESCE(_credit_glaccnt, -1) < 0) THEN
60808
 
      RETURN -13;
60809
 
    END IF;
60810
 
 
60811
 
    PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK',
60812
 
                                CAST(_p.checkhead_number AS TEXT),
60813
 
                                _credit_glaccnt,
60814
 
                                round(_p.checkhead_amount_base, 2) * -1,
60815
 
                                _p.checkhead_checkdate, _gltransNote, pcheckid );
60816
 
 
60817
 
    _amount_base := _p.checkhead_amount_base;
60818
 
 
60819
 
  ELSE
60820
 
    FOR _r IN SELECT checkitem_amount, checkitem_discount,
60821
 
                     CASE WHEN (checkitem_apopen_id IS NOT NULL AND apopen_doctype='C') THEN
60822
 
                            checkitem_amount / apopen_curr_rate * -1.0
60823
 
                          WHEN (checkitem_apopen_id IS NOT NULL) THEN
60824
 
                            checkitem_amount / apopen_curr_rate
60825
 
                          ELSE
60826
 
                            currToBase(checkitem_curr_id,
60827
 
                                       checkitem_amount,
60828
 
                                       COALESCE(checkitem_docdate, _p.checkhead_checkdate)) 
60829
 
                     END AS checkitem_amount_base,
60830
 
                     currTocurr(checkitem_curr_id, _p.checkhead_curr_id,
60831
 
                                CASE WHEN (checkitem_apopen_id IS NOT NULL AND apopen_doctype='C') THEN
60832
 
                                          checkitem_amount * -1.0
60833
 
                                     ELSE checkitem_amount END,
60834
 
                                  _p.checkhead_checkdate) AS amount_check,
60835
 
                     apopen_id, apopen_doctype, apopen_docnumber,
60836
 
                     aropen_id, aropen_doctype, aropen_docnumber,
60837
 
                     checkitem_curr_id, checkitem_curr_rate, apopen_curr_rate,
60838
 
                     COALESCE(checkitem_docdate, _p.checkhead_checkdate) AS docdate
60839
 
              FROM (checkitem LEFT OUTER JOIN
60840
 
                    apopen ON (checkitem_apopen_id=apopen_id)) LEFT OUTER JOIN
60841
 
                    aropen ON (checkitem_aropen_id=aropen_id)
60842
 
              WHERE (checkitem_checkhead_id=pcheckid) LOOP
60843
 
 
60844
 
      _exchGainTmp := 0;
60845
 
      IF (_r.apopen_id IS NOT NULL) THEN
60846
 
        --  take the discount if specified before we do anything else
60847
 
        IF(_r.checkitem_discount > 0.0) THEN
60848
 
          PERFORM createAPDiscount(_r.apopen_id, _r.checkitem_discount);
60849
 
        END IF;
60850
 
 
60851
 
        UPDATE apopen
60852
 
 
60853
 
        SET apopen_paid = round(apopen_paid + _r.checkitem_amount, 2),
60854
 
            apopen_open = round(apopen_amount, 2) >
60855
 
                          round(apopen_paid + _r.checkitem_amount, 2),
60856
 
            apopen_closedate = CASE WHEN (round(apopen_amount, 2) <=
60857
 
                                          round(apopen_paid + _r.checkitem_amount, 2)) THEN _p.checkhead_checkdate END
60858
 
        WHERE (apopen_id=_r.apopen_id);
60859
 
 
60860
 
        --  Post the application
60861
 
        INSERT INTO apapply
60862
 
        ( apapply_vend_id, apapply_postdate, apapply_username,
60863
 
          apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber,
60864
 
          apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber,
60865
 
          apapply_journalnumber, apapply_amount, apapply_curr_id, apapply_checkhead_id )
60866
 
        VALUES
60867
 
        ( _p.checkhead_recip_id, _p.checkhead_checkdate, getEffectiveXtUser(),
60868
 
          -1, 'K', _p.checkhead_number,
60869
 
          _r.apopen_id, _r.apopen_doctype, _r.apopen_docnumber,
60870
 
          _journalNumber, _r.checkitem_amount, _r.checkitem_curr_id, _p.checkhead_id );
60871
 
      END IF; -- if check item's apopen_id is not null
60872
 
 
60873
 
      IF (_r.aropen_id IS NOT NULL) THEN
60874
 
 
60875
 
        UPDATE aropen
60876
 
        SET aropen_paid = round(aropen_paid + _r.checkitem_amount, 2),
60877
 
            aropen_open = round(aropen_amount, 2) >
60878
 
                          round(aropen_paid + _r.checkitem_amount, 2),
60879
 
            aropen_closedate = CASE WHEN (round(aropen_amount, 2) <=
60880
 
                                          round(aropen_paid + _r.checkitem_amount, 2)) THEN _p.checkhead_checkdate END
60881
 
        WHERE (aropen_id=_r.aropen_id);
60882
 
 
60883
 
        --  Post the application
60884
 
        INSERT INTO arapply
60885
 
        ( arapply_cust_id, arapply_postdate, arapply_distdate, arapply_username,
60886
 
          arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber,
60887
 
          arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber,
60888
 
          arapply_journalnumber, arapply_applied, arapply_curr_id )
60889
 
        VALUES
60890
 
        ( _p.checkhead_recip_id, _p.checkhead_checkdate, _p.checkhead_checkdate, getEffectiveXtUser(),
60891
 
          _r.aropen_id,_r.aropen_doctype, _r.aropen_docnumber,
60892
 
          -1, 'K',_p.checkhead_number ,
60893
 
          _journalNumber, _r.checkitem_amount, _r.checkitem_curr_id );
60894
 
 
60895
 
      END IF; -- if check item's aropen_id is not null
60896
 
 
60897
 
      IF (_r.apopen_id IS NOT NULL) THEN
60898
 
        SELECT apCurrGain(_r.apopen_id,_r.checkitem_curr_id, _r.checkitem_amount,
60899
 
                        _p.checkhead_checkdate)
60900
 
              INTO _exchGainTmp;
60901
 
      ELSIF (_r.aropen_id IS NOT NULL) THEN
60902
 
        SELECT arCurrGain(_r.aropen_id,_r.checkitem_curr_id, _r.checkitem_amount,
60903
 
                        _p.checkhead_checkdate)
60904
 
              INTO _exchGainTmp;
60905
 
      END IF;
60906
 
      _exchGain := _exchGain + _exchGainTmp;
60907
 
 
60908
 
      PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source,
60909
 
                                  'CK', CAST(_p.checkhead_number AS TEXT),
60910
 
                                  _t.checkrecip_accnt_id,
60911
 
                                  round(_r.checkitem_amount_base, 2) * -1.0,
60912
 
                                  _p.checkhead_checkdate, _gltransNote, pcheckid );
60913
 
      IF (_exchGainTmp <> 0) THEN
60914
 
        PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source,
60915
 
                                   'CK', CAST(_p.checkhead_number AS TEXT),
60916
 
                                   getGainLossAccntId(_t.checkrecip_accnt_id),
60917
 
                                   round(_exchGainTmp,2),
60918
 
                                   _p.checkhead_checkdate, _gltransNote, pcheckid );
60919
 
      END IF;
60920
 
 
60921
 
      _amount_check := (_amount_check + _r.amount_check);
60922
 
      _amount_base := (_amount_base + _r.checkitem_amount_base);
60923
 
 
60924
 
    END LOOP;
60925
 
 
60926
 
    IF( (_amount_check - _p.checkhead_amount) <> 0.0 ) THEN 
60927
 
      _exchGainTmp := currToBase(_p.checkhead_curr_id,
60928
 
                                 _amount_check - _p.checkhead_amount,
60929
 
                                 _p.checkhead_checkdate);
60930
 
      _exchGain := _exchGain + _exchGainTmp;
60931
 
    END IF;
60932
 
    --  ensure that the check balances, attribute rounding errors to gain/loss
60933
 
    IF round(_amount_base, 2) - round(_exchGain, 2) <> round(_p.checkhead_amount_base, 2) THEN
60934
 
      IF round(_amount_base - _exchGain, 2) = round(_p.checkhead_amount_base, 2) THEN
60935
 
        PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source,
60936
 
                                    'CK',
60937
 
                                    CAST(_p.checkhead_number AS TEXT),
60938
 
                                    getGainLossAccntId(_p.bankaccntid),
60939
 
                                    round(_amount_base, 2) -
60940
 
                                      round(_exchGain, 2) -
60941
 
                                      round(_p.checkhead_amount_base, 2),
60942
 
                                    _p.checkhead_checkdate, _gltransNote, pcheckid );
60943
 
      ELSE
60944
 
        RAISE EXCEPTION 'checkhead_id % does not balance (% - % <> %)', pcheckid,
60945
 
              _amount_base, _exchGain, _p.checkhead_amount_base;
60946
 
      END IF;
60947
 
    END IF;
60948
 
  END IF;
60949
 
 
60950
 
  PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK',
60951
 
                              CAST(_p.checkhead_number AS TEXT),
60952
 
                              _p.bankaccntid,
60953
 
                              round(_p.checkhead_amount_base, 2),
60954
 
                              _p.checkhead_checkdate, _gltransNote, pcheckid );
60955
 
 
60956
 
  -- Post any gain/loss from the alternate currency exchange rate
60957
 
  IF (COALESCE(_p.checkhead_alt_curr_rate, 0.0) <> 0.0) THEN
60958
 
    _exchGain := ROUND((_p.checkhead_curr_rate - _p.checkhead_alt_curr_rate) * _p.checkhead_amount_base, 2);
60959
 
 
60960
 
    IF (_exchGain <> 0) THEN
60961
 
      PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK',
60962
 
                          CAST(_p.checkhead_number AS TEXT),
60963
 
                          _p.bankaccntid, (_exchGain * -1.0),
60964
 
                          _p.checkhead_checkdate, _gltransNote, pcheckid );      
60965
 
                          
60966
 
      PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK',
60967
 
                          CAST(_p.checkhead_number AS TEXT),
60968
 
                          getGainLossAccntId(_p.bankaccntid), _exchGain,
60969
 
                          _p.checkhead_checkdate, _gltransNote, pcheckid );      
60970
 
    END IF;
60971
 
  END IF;
60972
 
 
60973
 
  PERFORM postGLSeries(_sequence, _journalNumber);
60974
 
 
60975
 
  UPDATE checkhead
60976
 
  SET checkhead_posted=TRUE,
60977
 
      checkhead_journalnumber=_journalNumber
60978
 
  WHERE (checkhead_id=pcheckid);
60979
 
 
60980
 
  RETURN _journalNumber;
60981
 
 
60982
 
END;
60983
 
$_$;
60984
 
 
60985
 
 
60986
 
ALTER FUNCTION public.postcheck(integer, integer) OWNER TO admin;
60987
 
 
60988
 
--
60989
 
--
60990
 
 
60991
 
CREATE FUNCTION postchecks(integer) RETURNS integer
60992
 
    LANGUAGE plpgsql
60993
 
    AS $_$
60994
 
DECLARE
60995
 
  pBankaccntid ALIAS FOR $1;
60996
 
  _journalNumber INTEGER;
60997
 
 
60998
 
BEGIN
60999
 
 
61000
 
  SELECT fetchJournalNumber('AP-CK') INTO _journalNumber;
61001
 
 
61002
 
  PERFORM postCheck(checkhead_id, _journalNumber)
61003
 
  FROM checkhead
61004
 
  WHERE ( (NOT checkhead_void)
61005
 
    AND   (NOT checkhead_posted)
61006
 
    AND   (checkhead_printed)
61007
 
    AND   (checkhead_bankaccnt_id=pBankaccntid) );
61008
 
 
61009
 
  RETURN _journalNumber;
61010
 
 
61011
 
END;
61012
 
$_$;
61013
 
 
61014
 
 
61015
 
ALTER FUNCTION public.postchecks(integer) OWNER TO admin;
61016
 
 
61017
 
--
61018
 
--
61019
 
 
61020
 
CREATE FUNCTION postcomment(pcmnttypeid integer, psource text, psourceid integer, ptext text) RETURNS integer
61021
 
    LANGUAGE plpgsql
61022
 
    AS $$
61023
 
DECLARE
61024
 
 
61025
 
BEGIN
61026
 
  RETURN postComment(pCmnttypeid, pSource, pSourceid, pText, NULL);
61027
 
END
61028
 
$$;
61029
 
 
61030
 
 
61031
 
ALTER FUNCTION public.postcomment(pcmnttypeid integer, psource text, psourceid integer, ptext text) OWNER TO admin;
61032
 
 
61033
 
--
61034
 
--
61035
 
 
61036
 
CREATE FUNCTION postcomment(pcmnttypename text, psource text, psourceid integer, ptext text) RETURNS integer
61037
 
    LANGUAGE plpgsql
61038
 
    AS $$
61039
 
DECLARE
61040
 
  _cmnttypeid INTEGER;
61041
 
 
61042
 
BEGIN
61043
 
  SELECT cmnttype_id INTO _cmnttypeid
61044
 
  FROM cmnttype
61045
 
  WHERE (cmnttype_name=pCmnttypename);
61046
 
  IF (NOT FOUND) THEN
61047
 
    RAISE EXCEPTION 'Comment type % not found.', pCmnttypename;
61048
 
  END IF;
61049
 
 
61050
 
  RETURN postComment(_cmnttypeid, pSource, pSourceid, pText, NULL);
61051
 
END
61052
 
$$;
61053
 
 
61054
 
 
61055
 
ALTER FUNCTION public.postcomment(pcmnttypename text, psource text, psourceid integer, ptext text) OWNER TO admin;
61056
 
 
61057
 
--
61058
 
--
61059
 
 
61060
 
CREATE FUNCTION postcomment(pcmnttypeid integer, psource text, psourceid integer, ptext text, ppublic boolean) RETURNS integer
61061
 
    LANGUAGE plpgsql
61062
 
    AS $$
61063
 
DECLARE
61064
 
  _commentid INTEGER;
61065
 
  _public BOOLEAN;
61066
 
 
61067
 
BEGIN
61068
 
  _public := COALESCE(pPublic, fetchmetricbool('CommentPublicDefault'));
61069
 
 
61070
 
  INSERT INTO comment
61071
 
  ( comment_cmnttype_id, comment_source, comment_source_id,
61072
 
    comment_date, comment_user, comment_text, comment_public )
61073
 
  VALUES
61074
 
  ( pCmnttypeid, pSource, pSourceid,
61075
 
    CURRENT_TIMESTAMP, getEffectiveXtUser(), pText, _public )
61076
 
  RETURNING comment_id INTO _commentid;
61077
 
 
61078
 
  RETURN _commentid;
61079
 
 
61080
 
END;
61081
 
$$;
61082
 
 
61083
 
 
61084
 
ALTER FUNCTION public.postcomment(pcmnttypeid integer, psource text, psourceid integer, ptext text, ppublic boolean) OWNER TO admin;
61085
 
 
61086
 
--
61087
 
--
61088
 
 
61089
 
CREATE FUNCTION postcost(integer) RETURNS boolean
61090
 
    LANGUAGE plpgsql
61091
 
    AS $_$
61092
 
DECLARE
61093
 
  pItemcostid ALIAS FOR $1;
61094
 
  _p RECORD;
61095
 
 
61096
 
BEGIN
61097
 
 
61098
 
  SELECT round(currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE),6) AS newcost,
61099
 
         itemcost_curr_id, CURRENT_DATE AS effective,
61100
 
         item_number,
61101
 
         itemcost_stdcost AS oldcost INTO _p
61102
 
  FROM itemcost, item
61103
 
  WHERE ((itemcost_item_id=item_id)
61104
 
    AND  (itemcost_id=pItemcostid));
61105
 
 
61106
 
  IF (_p.newcost IS NULL) THEN
61107
 
      RAISE EXCEPTION 'There is no valid Exchange Rate for this currency. (%, %)',
61108
 
                  _p.itemcost_curr_id, _p.effective;
61109
 
      RETURN FALSE;
61110
 
  END IF;
61111
 
 
61112
 
  RETURN updateStdCost(pItemcostid, _p.newcost, _p.oldcost, 'Post Cost',
61113
 
               ('Post Actual Cost to Standard for item ' || _p.item_number));
61114
 
 
61115
 
END;
61116
 
$_$;
61117
 
 
61118
 
 
61119
 
ALTER FUNCTION public.postcost(integer) OWNER TO admin;
61120
 
 
61121
 
--
61122
 
--
61123
 
 
61124
 
CREATE FUNCTION postcountslip(integer) RETURNS integer
61125
 
    LANGUAGE plpgsql
61126
 
    AS $_$
61127
 
DECLARE
61128
 
  pCntslipid ALIAS FOR $1;
61129
 
  _p RECORD;
61130
 
  _comments TEXT;
61131
 
  _temp TEXT;
61132
 
 
61133
 
BEGIN
61134
 
 
61135
 
  SELECT itemsite_loccntrl, itemsite_controlmethod,
61136
 
         cntslip_posted, cntslip_lotserial, cntslip_comments,
61137
 
         cntslip_number, cntslip_qty INTO _p
61138
 
  FROM cntslip, invcnt, itemsite
61139
 
  WHERE ( (cntslip_cnttag_id=invcnt_id)
61140
 
   AND (invcnt_itemsite_id=itemsite_id)
61141
 
   AND (cntslip_id=pCntslipid) );
61142
 
 
61143
 
  IF (NOT _p.cntslip_posted) THEN
61144
 
    SELECT ( E'\nCount Slip #' || _p.cntslip_number ||
61145
 
             ' counted ' || formatQty(_p.cntslip_qty) ) INTO _comments;
61146
 
 
61147
 
    IF (_p.itemsite_loccntrl) THEN
61148
 
      SELECT ( ', Location:' || location_name ) INTO _temp
61149
 
      FROM location, cntslip
61150
 
      WHERE ( (cntslip_location_id=location_id)
61151
 
       AND (cntslip_id=pCntslipid) );
61152
 
 
61153
 
      _comments := (_comments || _temp);
61154
 
    END IF;
61155
 
 
61156
 
    IF (_p.itemsite_controlmethod = 'L') THEN
61157
 
      _comments := (_comments || ( ', Lot #:' || _p.cntslip_lotserial));
61158
 
    ELSIF (_p.itemsite_controlmethod = 'S') THEN
61159
 
      _comments := (_comments || ( ', Serial #:' || _p.cntslip_lotserial));
61160
 
    END IF;
61161
 
 
61162
 
    _comments := (_comments || ' ' || _p.cntslip_comments);
61163
 
 
61164
 
    UPDATE cntslip
61165
 
    SET cntslip_posted=TRUE
61166
 
    WHERE (cntslip_id=pCntslipid);
61167
 
 
61168
 
    UPDATE invcnt
61169
 
    SET invcnt_qoh_after = ( COALESCE(invcnt_qoh_after, 0) + cntslip_qty),
61170
 
        invcnt_comments = (invcnt_comments || _comments)
61171
 
    FROM cntslip
61172
 
    WHERE ( (cntslip_cnttag_id=invcnt_id)
61173
 
     AND (cntslip_id=pCntslipid) );
61174
 
 
61175
 
    RETURN 1;
61176
 
 
61177
 
  ELSE
61178
 
    RETURN -1;
61179
 
  END IF;
61180
 
 
61181
 
END;
61182
 
$_$;
61183
 
 
61184
 
 
61185
 
ALTER FUNCTION public.postcountslip(integer) OWNER TO admin;
61186
 
 
61187
 
--
61188
 
--
61189
 
 
61190
 
CREATE FUNCTION postcounttag(pinvcntid integer, pthaw boolean) RETURNS integer
61191
 
    LANGUAGE plpgsql
61192
 
    AS $$
61193
 
DECLARE
61194
 
  _avgCostingMethod TEXT;
61195
 
  _invhistid INTEGER;
61196
 
  _postDate TIMESTAMP;
61197
 
  _runningQty NUMERIC;
61198
 
  _errorCode INTEGER;
61199
 
  _itemlocSeries INTEGER := 0;
61200
 
  _hasDetail BOOLEAN;
61201
 
  _p RECORD;
61202
 
  _itemloc RECORD;
61203
 
  _cntslip RECORD;
61204
 
  _lsid INTEGER;
61205
 
 
61206
 
BEGIN
61207
 
 
61208
 
  SELECT COALESCE(fetchMetricText('CountAvgCostMethod'), 'STD') INTO _avgCostingMethod;
61209
 
 
61210
 
  SELECT invcnt_id, invcnt_tagnumber, invcnt_qoh_after,
61211
 
         invcnt_location_id,
61212
 
         item_number,
61213
 
         itemsite_id, itemsite_freeze,
61214
 
         itemsite_qtyonhand,
61215
 
         itemsite_loccntrl, itemsite_location_id,
61216
 
         CASE WHEN (itemsite_costmethod = 'N') THEN 0
61217
 
              WHEN ( (itemsite_costmethod = 'A') AND
61218
 
                     (itemsite_qtyonhand = 0) AND
61219
 
                     (_avgCostingMethod = 'ACT') ) THEN actcost(itemsite_item_id)
61220
 
              WHEN ( (itemsite_costmethod = 'A') AND
61221
 
                     (_avgCostingMethod IN ('ACT', 'AVG')) ) THEN avgcost(itemsite_id)
61222
 
              ELSE stdcost(itemsite_item_id)
61223
 
         END AS cost, itemsite_costmethod,
61224
 
         itemsite_controlmethod,
61225
 
         itemsite_value INTO _p
61226
 
  FROM invcnt, itemsite, item
61227
 
  WHERE ( (invcnt_itemsite_id=itemsite_id)
61228
 
   AND (itemsite_item_id=item_id)
61229
 
   AND (invcnt_qoh_after IS NOT NULL)
61230
 
   AND (NOT invcnt_posted)
61231
 
   AND (invcnt_id=pInvcntid) );
61232
 
  IF (FOUND) THEN
61233
 
    IF (_p.invcnt_location_id IS NOT NULL) THEN
61234
 
      RETURN postCountTagLocation(pInvcntid, pThaw);
61235
 
    END IF;
61236
 
 
61237
 
    SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid;
61238
 
 
61239
 
    IF (_p.itemsite_freeze) THEN
61240
 
      SELECT invcnt_tagdate INTO _postDate
61241
 
      FROM invcnt
61242
 
      WHERE (invcnt_id=pInvcntid) ;
61243
 
    ELSE
61244
 
      _postDate = CURRENT_TIMESTAMP;
61245
 
    END IF;
61246
 
 
61247
 
    _hasDetail = FALSE;
61248
 
 
61249
 
    IF ( (_p.itemsite_loccntrl) OR
61250
 
         (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN
61251
 
 
61252
 
      SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
61253
 
 
61254
 
      FOR _itemloc IN SELECT itemloc_id, itemloc_location_id,
61255
 
                             itemloc_ls_id, itemloc_qty
61256
 
                      FROM itemloc
61257
 
                      WHERE (itemloc_itemsite_id=_p.itemsite_id) LOOP
61258
 
 
61259
 
        _hasDetail = TRUE;
61260
 
 
61261
 
        INSERT INTO itemlocdist
61262
 
        ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id,
61263
 
          itemlocdist_expiration,
61264
 
          itemlocdist_itemsite_id, itemlocdist_invhist_id, itemlocdist_flush )
61265
 
        VALUES
61266
 
        ( _itemlocSeries, 'I', _itemloc.itemloc_id,
61267
 
          endOfTime(),
61268
 
          _p.itemsite_id, _invhistid, TRUE );
61269
 
 
61270
 
      END LOOP;
61271
 
 
61272
 
      _runningQty := 0;
61273
 
 
61274
 
      FOR _cntslip IN SELECT cntslip_location_id, cntslip_lotserial,
61275
 
                             cntslip_lotserial_expiration,
61276
 
                             cntslip_lotserial_warrpurc,
61277
 
                             SUM(cntslip_qty) AS qty,
61278
 
                             itemsite_item_id
61279
 
                      FROM cntslip, invcnt, itemsite
61280
 
                      WHERE ((cntslip_cnttag_id=pInvcntid)
61281
 
                      AND (cntslip_cnttag_id=invcnt_id)
61282
 
                      AND (invcnt_itemsite_id=itemsite_id))
61283
 
                      GROUP BY cntslip_location_id, cntslip_lotserial, 
61284
 
                      cntslip_lotserial_expiration, cntslip_lotserial_warrpurc,itemsite_item_id LOOP
61285
 
 
61286
 
        IF (LENGTH(_cntslip.cntslip_lotserial)>0) THEN
61287
 
          SELECT ls_id INTO _lsid
61288
 
          FROM ls
61289
 
          WHERE ((ls_item_id=_cntslip.itemsite_item_id)
61290
 
          AND (UPPER(ls_number)=UPPER(_cntslip.cntslip_lotserial)));
61291
 
 
61292
 
          IF (NOT FOUND) THEN
61293
 
            _lsid := NEXTVAL('ls_ls_id_seq');
61294
 
            INSERT INTO ls
61295
 
            VALUES (_lsid,_cntslip.itemsite_item_id,UPPER(_cntslip.cntslip_lotserial));
61296
 
          END IF;
61297
 
        END IF;
61298
 
 
61299
 
        _runningQty := (_runningQty + _cntslip.qty);
61300
 
        _hasDetail = TRUE;
61301
 
 
61302
 
        INSERT INTO itemlocdist
61303
 
        ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id,
61304
 
          itemlocdist_itemsite_id,
61305
 
          itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_warranty,
61306
 
          itemlocdist_qty, itemlocdist_invhist_id )
61307
 
        VALUES
61308
 
        ( _itemlocSeries, 'L', _cntslip.cntslip_location_id,
61309
 
          _p.itemsite_id,
61310
 
          _lsid, COALESCE(_cntslip.cntslip_lotserial_expiration, endOfTime()),
61311
 
          _cntslip.cntslip_lotserial_warrpurc,_cntslip.qty, _invhistid );
61312
 
 
61313
 
      END LOOP;
61314
 
 
61315
 
      IF (_runningQty > _p.invcnt_qoh_after) THEN
61316
 
        _errorCode = -1;
61317
 
 
61318
 
      ELSIF ( (_runningQty < _p.invcnt_qoh_after) AND
61319
 
              (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN
61320
 
        _errorCode = -2;
61321
 
 
61322
 
      ELSIF (_runningQty < _p.invcnt_qoh_after) THEN
61323
 
        IF ( (NOT _p.itemsite_loccntrl) OR
61324
 
             (_p.itemsite_location_id = -1) ) THEN
61325
 
          _errorCode = -3;
61326
 
 
61327
 
        ELSIF ( SELECT (metric_value='f')
61328
 
                FROM metric
61329
 
                WHERE (metric_name='PostCountTagToDefault') ) THEN
61330
 
          _errorCode = -4;
61331
 
 
61332
 
        ELSE
61333
 
          INSERT INTO itemlocdist
61334
 
          ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id,
61335
 
            itemlocdist_itemsite_id,
61336
 
            itemlocdist_expiration,
61337
 
            itemlocdist_qty, itemlocdist_invhist_id )
61338
 
          SELECT _itemlocSeries, 'L', _p.itemsite_location_id,
61339
 
                 _p.itemsite_id,
61340
 
                 endOfTime(),
61341
 
                 (_p.invcnt_qoh_after - _runningQty), _invhistid;
61342
 
 
61343
 
          _hasDetail = TRUE;
61344
 
          _errorCode = 0;
61345
 
        END IF;
61346
 
      ELSE
61347
 
        _errorCode = 0;
61348
 
      END IF;
61349
 
 
61350
 
      IF (_errorCode <> 0) THEN
61351
 
        DELETE FROM itemlocdist
61352
 
        WHERE (itemlocdist_series=_itemlocSeries);
61353
 
  
61354
 
        RETURN _errorCode;
61355
 
      END IF;
61356
 
 
61357
 
    END IF;
61358
 
 
61359
 
    UPDATE invcnt
61360
 
    SET invcnt_qoh_before=_p.itemsite_qtyonhand,
61361
 
        invcnt_postdate=_postDate,
61362
 
        invcnt_posted=TRUE,
61363
 
        invcnt_invhist_id=_invhistid,
61364
 
        invcnt_post_username=getEffectiveXtUser()
61365
 
    WHERE (invcnt_id=pInvcntid);
61366
 
 
61367
 
    INSERT INTO invhist
61368
 
     ( invhist_id, invhist_itemsite_id,
61369
 
       invhist_transdate, invhist_transtype, invhist_invqty,
61370
 
       invhist_qoh_before, invhist_qoh_after,
61371
 
       invhist_docnumber, invhist_comments,
61372
 
       invhist_invuom, invhist_unitcost, invhist_hasdetail,
61373
 
       invhist_costmethod, invhist_value_before, invhist_value_after,
61374
 
       invhist_series )
61375
 
    SELECT _invhistid, itemsite_id,
61376
 
           _postDate, 'CC', (invcnt_qoh_after - invcnt_qoh_before),
61377
 
           invcnt_qoh_before, invcnt_qoh_after,
61378
 
           invcnt_tagnumber, invcnt_comments,
61379
 
           uom_name, _p.cost, _hasDetail,
61380
 
           _p.itemsite_costmethod, _p.itemsite_value, 
61381
 
           _p.itemsite_value + (_p.cost * (invcnt_qoh_after - invcnt_qoh_before)),
61382
 
           _itemlocSeries
61383
 
    FROM itemsite, invcnt, item, uom
61384
 
    WHERE ( (invcnt_itemsite_id=itemsite_id)
61385
 
     AND (itemsite_item_id=item_id)
61386
 
     AND (item_inv_uom_id=uom_id)
61387
 
     AND (itemsite_controlmethod <> 'N')
61388
 
     AND (invcnt_id=pInvcntid) );
61389
 
 
61390
 
    IF ( SELECT metric_value
61391
 
        FROM metric
61392
 
        WHERE ((metric_name = 'EnableAsOfQOH')
61393
 
        AND (metric_value = 't'))) THEN
61394
 
      IF (NOT postIntoInvBalance(_invhistid)) THEN
61395
 
        RAISE EXCEPTION 'Post into Inventory Balance for invhist_id=% was unsuccessful',_invhistid;
61396
 
      END IF;
61397
 
    END IF;
61398
 
 
61399
 
    UPDATE itemsite
61400
 
    SET itemsite_qtyonhand=_p.invcnt_qoh_after,
61401
 
        itemsite_value = CASE WHEN ((itemsite_costmethod='A') AND
61402
 
                                    (_p.itemsite_value + (_p.cost * (_p.invcnt_qoh_after - itemsite_qtyonhand))) < 0.0) THEN 0.0
61403
 
                              ELSE (_p.itemsite_value + (_p.cost * (_p.invcnt_qoh_after - itemsite_qtyonhand)))
61404
 
                         END,
61405
 
        itemsite_datelastcount=_postDate
61406
 
    WHERE (itemsite_id=_p.itemsite_id);
61407
 
 
61408
 
    IF (_hasDetail) THEN
61409
 
      PERFORM distributeItemlocSeries(_itemlocSeries);
61410
 
    END IF;
61411
 
 
61412
 
    IF (pThaw) THEN
61413
 
      PERFORM thawItemSite(invcnt_itemsite_id) 
61414
 
      FROM invcnt
61415
 
      WHERE (invcnt_id=pInvcntid);
61416
 
    END IF;
61417
 
 
61418
 
    PERFORM insertGLTransaction( 'I/M', 'CT', _p.invcnt_tagnumber,
61419
 
                                 ('Post Count Tag #' || _p.invcnt_tagnumber || ' for Item ' || _p.item_number),
61420
 
                                 costcat_adjustment_accnt_id, costcat_asset_accnt_id, _invhistid,
61421
 
                                 ( (_p.invcnt_qoh_after - _p.itemsite_qtyonhand) * _p.cost), _postDate::DATE )
61422
 
    FROM invcnt, itemsite, costcat
61423
 
    WHERE ( (invcnt_itemsite_id=itemsite_id)
61424
 
     AND (itemsite_costcat_id=costcat_id)
61425
 
     AND (invcnt_id=pInvcntid) );
61426
 
 
61427
 
    RETURN 0;
61428
 
 
61429
 
  ELSE
61430
 
    RETURN -9;
61431
 
  END IF;
61432
 
 
61433
 
END;
61434
 
$$;
61435
 
 
61436
 
 
61437
 
ALTER FUNCTION public.postcounttag(pinvcntid integer, pthaw boolean) OWNER TO admin;
61438
 
 
61439
 
--
61440
 
--
61441
 
 
61442
 
CREATE FUNCTION postcounttaglocation(pinvcntid integer, pthaw boolean) RETURNS integer
61443
 
    LANGUAGE plpgsql
61444
 
    AS $$
61445
 
DECLARE
61446
 
  _avgCostingMethod TEXT;
61447
 
  _invhistid INTEGER;
61448
 
  _postDate TIMESTAMP;
61449
 
  _runningQty NUMERIC;
61450
 
  _errorCode INTEGER;
61451
 
  _itemlocSeries INTEGER := 0;
61452
 
  _hasDetail BOOLEAN;
61453
 
  _p RECORD;
61454
 
  _itemloc RECORD;
61455
 
  _cntslip RECORD;
61456
 
  _origLocQty NUMERIC;
61457
 
  _lsid INTEGER;
61458
 
BEGIN
61459
 
 
61460
 
  SELECT COALESCE(fetchMetricText('CountAvgCostMethod'), 'STD') INTO _avgCostingMethod;
61461
 
 
61462
 
  SELECT invcnt_id, invcnt_tagnumber, invcnt_qoh_after,
61463
 
         invcnt_location_id, invcnt_tagdate,
61464
 
         item_number,
61465
 
         itemsite_id, itemsite_freeze,
61466
 
         itemsite_qtyonhand,
61467
 
         itemsite_loccntrl, COALESCE(invcnt_location_id, -1) AS itemsite_location_id,
61468
 
         CASE WHEN (itemsite_costmethod = 'N') THEN 0
61469
 
              WHEN ( (itemsite_costmethod = 'A') AND
61470
 
                     (itemsite_qtyonhand = 0.0) AND
61471
 
                     (_avgCostingMethod = 'ACT') ) THEN actcost(itemsite_item_id)
61472
 
              WHEN ( (itemsite_costmethod = 'A') AND
61473
 
                     (_avgCostingMethod IN ('ACT', 'AVG')) ) THEN avgcost(itemsite_id)
61474
 
              ELSE stdcost(itemsite_item_id)
61475
 
         END AS cost, itemsite_costmethod,
61476
 
         itemsite_controlmethod, itemsite_value INTO _p
61477
 
  FROM invcnt, itemsite, item
61478
 
  WHERE ( (invcnt_itemsite_id=itemsite_id)
61479
 
   AND (itemsite_item_id=item_id)
61480
 
   AND (invcnt_qoh_after IS NOT NULL)
61481
 
   AND (NOT invcnt_posted)
61482
 
   AND (invcnt_id=pInvcntid) );
61483
 
  IF (NOT FOUND) THEN
61484
 
    RETURN -9;
61485
 
  END IF;
61486
 
 
61487
 
  SELECT COALESCE(SUM(itemloc_qty),0.0) INTO _origLocQty
61488
 
    FROM itemloc
61489
 
   WHERE ((itemloc_itemsite_id=_p.itemsite_id)
61490
 
     AND  (itemloc_location_id=_p.invcnt_location_id));
61491
 
  IF (NOT FOUND) THEN
61492
 
    _origLocQty := 0.0;
61493
 
  END IF;
61494
 
 
61495
 
  SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid;
61496
 
 
61497
 
  IF (_p.itemsite_freeze) THEN
61498
 
    _postDate := _p.invcnt_tagdate;
61499
 
  ELSE
61500
 
    _postDate := CURRENT_TIMESTAMP;
61501
 
  END IF;
61502
 
 
61503
 
  _hasDetail = FALSE;
61504
 
 
61505
 
  IF ( (_p.itemsite_loccntrl) OR
61506
 
       (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN
61507
 
 
61508
 
    SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
61509
 
 
61510
 
    FOR _itemloc IN SELECT itemloc_id, itemloc_location_id,
61511
 
                           itemloc_ls_id, itemloc_qty
61512
 
                    FROM itemloc
61513
 
                    WHERE ((itemloc_itemsite_id=_p.itemsite_id)
61514
 
                      AND  (itemloc_location_id=_p.invcnt_location_id)) LOOP
61515
 
 
61516
 
      _hasDetail = TRUE;
61517
 
 
61518
 
      INSERT INTO itemlocdist
61519
 
      ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id,
61520
 
        itemlocdist_expiration,
61521
 
        itemlocdist_itemsite_id, itemlocdist_invhist_id, itemlocdist_flush )
61522
 
      VALUES
61523
 
      ( _itemlocSeries, 'I', _itemloc.itemloc_id,
61524
 
        endOfTime(),
61525
 
        _p.itemsite_id, _invhistid, TRUE );
61526
 
 
61527
 
    END LOOP;
61528
 
 
61529
 
    _runningQty := 0;
61530
 
 
61531
 
    FOR _cntslip IN SELECT cntslip_location_id, cntslip_lotserial,
61532
 
                           cntslip_lotserial_expiration,
61533
 
                           cntslip_lotserial_warrpurc,
61534
 
                           SUM(cntslip_qty) AS qty,
61535
 
                           itemsite_item_id
61536
 
                    FROM cntslip,invcnt,itemsite
61537
 
                    WHERE ((cntslip_cnttag_id=pInvcntid)
61538
 
                    AND (cntslip_cnttag_id=invcnt_id)
61539
 
                    AND (invcnt_itemsite_id=itemsite_id))
61540
 
                    GROUP BY cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration,
61541
 
                    cntslip_lotserial_warrpurc, itemsite_item_id LOOP
61542
 
 
61543
 
      IF (LENGTH(_cntslip.cntslip_lotserial)>0) THEN
61544
 
        SELECT ls_id INTO _lsid
61545
 
        FROM ls
61546
 
        WHERE ((ls_item_id=_cntslip.itemsite_item_id)
61547
 
        AND (UPPER(ls_number)=UPPER(_cntslip.cntslip_lotserial)));
61548
 
 
61549
 
        IF (NOT FOUND) THEN
61550
 
          _lsid := NEXTVAL('ls_ls_id_seq');
61551
 
          INSERT INTO ls
61552
 
          VALUES (_lsid,_cntslip.itemsite_item_id,UPPER(_cntslip.cntslip_lotserial));
61553
 
        END IF;
61554
 
      END IF;
61555
 
       
61556
 
      _runningQty := (_runningQty + _cntslip.qty);
61557
 
      _hasDetail = TRUE;
61558
 
 
61559
 
      INSERT INTO itemlocdist
61560
 
      ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id,
61561
 
        itemlocdist_itemsite_id,
61562
 
        itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_warranty,
61563
 
        itemlocdist_qty, itemlocdist_invhist_id )
61564
 
      VALUES
61565
 
      ( _itemlocSeries, 'L', _cntslip.cntslip_location_id,
61566
 
        _p.itemsite_id,
61567
 
        _lsid, COALESCE(_cntslip.cntslip_lotserial_expiration, endOfTime()),
61568
 
        _cntslip.cntslip_lotserial_warrpurc,
61569
 
        _cntslip.qty, _invhistid );
61570
 
 
61571
 
    END LOOP;
61572
 
 
61573
 
    IF (_runningQty > _p.invcnt_qoh_after) THEN
61574
 
      _errorCode = -1;
61575
 
 
61576
 
    ELSIF ( (_runningQty < _p.invcnt_qoh_after) AND
61577
 
            (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN
61578
 
      _errorCode = -2;
61579
 
 
61580
 
    ELSIF (_runningQty < _p.invcnt_qoh_after) THEN
61581
 
      IF ( (NOT _p.itemsite_loccntrl) OR
61582
 
           (_p.itemsite_location_id = -1) ) THEN
61583
 
        _errorCode = -3;
61584
 
 
61585
 
      ELSIF ( SELECT (metric_value='f')
61586
 
              FROM metric
61587
 
              WHERE (metric_name='PostCountTagToDefault') ) THEN
61588
 
        _errorCode = -4;
61589
 
 
61590
 
      ELSE
61591
 
        INSERT INTO itemlocdist
61592
 
        ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id,
61593
 
          itemlocdist_itemsite_id,
61594
 
          itemlocdist_ls_id, itemlocdist_expiration,
61595
 
          itemlocdist_qty, itemlocdist_invhist_id )
61596
 
        SELECT _itemlocSeries, 'L', _p.itemsite_location_id,
61597
 
               _p.itemsite_id,
61598
 
               _lsid, endOfTime(),
61599
 
               (_p.invcnt_qoh_after - _runningQty), _invhistid;
61600
 
 
61601
 
        _hasDetail = TRUE;
61602
 
        _errorCode = 0;
61603
 
      END IF;
61604
 
    ELSE
61605
 
      _errorCode = 0;
61606
 
    END IF;
61607
 
 
61608
 
    IF (_errorCode <> 0) THEN
61609
 
      DELETE FROM itemlocdist
61610
 
      WHERE (itemlocdist_series=_itemlocSeries);
61611
 
  
61612
 
      RETURN _errorCode;
61613
 
    END IF;
61614
 
 
61615
 
  END IF;
61616
 
 
61617
 
  UPDATE invcnt
61618
 
  SET invcnt_qoh_before=_origLocQty,
61619
 
      invcnt_postdate=_postDate,
61620
 
      invcnt_posted=TRUE,
61621
 
      invcnt_invhist_id=_invhistid,
61622
 
      invcnt_post_username=getEffectiveXtUser()
61623
 
  WHERE (invcnt_id=pInvcntid);
61624
 
 
61625
 
  INSERT INTO invhist
61626
 
   ( invhist_id, invhist_itemsite_id,
61627
 
     invhist_transdate, invhist_transtype, invhist_invqty,
61628
 
     invhist_qoh_before, invhist_qoh_after,
61629
 
     invhist_docnumber, invhist_comments,
61630
 
     invhist_invuom, invhist_unitcost, invhist_hasdetail,
61631
 
     invhist_costmethod, invhist_value_before, invhist_value_after,
61632
 
     invhist_series )
61633
 
  SELECT _invhistid, itemsite_id,
61634
 
         _postDate, 'CC', (invcnt_qoh_after - invcnt_qoh_before),
61635
 
         invcnt_qoh_before, invcnt_qoh_after,
61636
 
         invcnt_tagnumber, invcnt_comments,
61637
 
         uom_name, _p.cost, _hasDetail,
61638
 
         _p.itemsite_costmethod, _p.itemsite_value,
61639
 
         _p.itemsite_value + (_p.cost * (invcnt_qoh_after - invcnt_qoh_before)),
61640
 
         _itemlocSeries
61641
 
  FROM itemsite, invcnt, item, uom
61642
 
  WHERE ( (invcnt_itemsite_id=itemsite_id)
61643
 
   AND (itemsite_item_id=item_id)
61644
 
   AND (item_inv_uom_id=uom_id)
61645
 
   AND (itemsite_controlmethod <> 'N')
61646
 
   AND (invcnt_id=pInvcntid) );
61647
 
 
61648
 
  UPDATE itemsite
61649
 
  SET itemsite_qtyonhand= itemsite_qtyonhand + (_p.invcnt_qoh_after - _origLocQty),
61650
 
      itemsite_datelastcount=_postDate
61651
 
  WHERE (itemsite_id=_p.itemsite_id);
61652
 
  UPDATE itemsite
61653
 
  SET itemsite_value =  itemsite_qtyonhand * _p.cost
61654
 
  WHERE (itemsite_id=_p.itemsite_id);
61655
 
 
61656
 
  IF (_hasDetail) THEN
61657
 
    PERFORM distributeItemlocSeries(_itemlocSeries);
61658
 
  END IF;
61659
 
 
61660
 
  IF (pThaw) THEN
61661
 
    PERFORM thawItemSite(invcnt_itemsite_id) 
61662
 
    FROM invcnt
61663
 
    WHERE (invcnt_id=pInvcntid);
61664
 
  END IF;
61665
 
 
61666
 
  PERFORM insertGLTransaction( 'I/M', 'CT', _p.invcnt_tagnumber,
61667
 
                               ('Post Count Tag #' || _p.invcnt_tagnumber || ' for Item ' || _p.item_number),
61668
 
                               costcat_adjustment_accnt_id, costcat_asset_accnt_id, _invhistid,
61669
 
                               ( (_p.invcnt_qoh_after - _origLocQty) * _p.cost), CURRENT_DATE )
61670
 
  FROM invcnt, itemsite, costcat
61671
 
  WHERE ( (invcnt_itemsite_id=itemsite_id)
61672
 
   AND (itemsite_costcat_id=costcat_id)
61673
 
   AND (invcnt_id=pInvcntid) );
61674
 
 
61675
 
  RETURN 0;
61676
 
END;
61677
 
$$;
61678
 
 
61679
 
 
61680
 
ALTER FUNCTION public.postcounttaglocation(pinvcntid integer, pthaw boolean) OWNER TO admin;
61681
 
 
61682
 
--
61683
 
--
61684
 
 
61685
 
CREATE FUNCTION postcounttaglocation(integer, boolean, text) RETURNS integer
61686
 
    LANGUAGE plpgsql
61687
 
    AS $_$
61688
 
DECLARE
61689
 
  pInvcntid ALIAS FOR $1;
61690
 
  pThaw ALIAS FOR $2;
61691
 
  pAvgCostingMethod ALIAS FOR $3;
61692
 
  _invhistid INTEGER;
61693
 
  _postDate TIMESTAMP;
61694
 
  _runningQty NUMERIC;
61695
 
  _errorCode INTEGER;
61696
 
  _itemlocSeries INTEGER := 0;
61697
 
  _hasDetail BOOLEAN;
61698
 
  _p RECORD;
61699
 
  _itemloc RECORD;
61700
 
  _cntslip RECORD;
61701
 
  _origLocQty NUMERIC;
61702
 
  _netable BOOLEAN;
61703
 
  _lsid INTEGER;
61704
 
BEGIN
61705
 
 
61706
 
  SELECT invcnt_id, invcnt_tagnumber, invcnt_qoh_after,
61707
 
         invcnt_location_id, invcnt_tagdate,
61708
 
         item_number,
61709
 
         itemsite_id, itemsite_freeze,
61710
 
         itemsite_qtyonhand,
61711
 
         itemsite_loccntrl, COALESCE(invcnt_location_id, -1) AS itemsite_location_id,
61712
 
         CASE WHEN (itemsite_costmethod = 'N') THEN 0
61713
 
              WHEN ( (itemsite_costmethod = 'A') AND
61714
 
                     (itemsite_qtyonhand = 0) AND
61715
 
                     (pAvgCostingMethod = 'ACT') ) THEN actcost(itemsite_item_id)
61716
 
              WHEN ( (itemsite_costmethod = 'A') AND
61717
 
                     (pAvgCostingMethod IN ('ACT', 'AVG')) ) THEN avgcost(itemsite_id)
61718
 
              ELSE stdcost(itemsite_item_id)
61719
 
         END AS cost, itemsite_costmethod,
61720
 
         itemsite_controlmethod, itemsite_value INTO _p
61721
 
  FROM invcnt, itemsite, item
61722
 
  WHERE ( (invcnt_itemsite_id=itemsite_id)
61723
 
   AND (itemsite_item_id=item_id)
61724
 
   AND (invcnt_qoh_after IS NOT NULL)
61725
 
   AND (NOT invcnt_posted)
61726
 
   AND (invcnt_id=pInvcntid) );
61727
 
  IF (NOT FOUND) THEN
61728
 
    RETURN -9;
61729
 
  END IF;
61730
 
 
61731
 
  SELECT COALESCE(SUM(itemloc_qty),0.0), location_netable INTO _origLocQty,_netable
61732
 
    FROM itemloc,location
61733
 
   WHERE ((itemloc_itemsite_id=_p.itemsite_id)
61734
 
     AND  (location_id=itemloc_location_id)
61735
 
     AND  (itemloc_location_id=_p.invcnt_location_id))
61736
 
   GROUP BY location_netable;
61737
 
  IF (NOT FOUND) THEN
61738
 
    _origLocQty := 0.0;
61739
 
    _netable := TRUE;
61740
 
  END IF;
61741
 
 
61742
 
  SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid;
61743
 
 
61744
 
  IF (_p.itemsite_freeze) THEN
61745
 
    _postDate := _p.invcnt_tagdate;
61746
 
  ELSE
61747
 
    _postDate := CURRENT_TIMESTAMP;
61748
 
  END IF;
61749
 
 
61750
 
  _hasDetail = FALSE;
61751
 
 
61752
 
  IF ( (_p.itemsite_loccntrl) OR
61753
 
       (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN
61754
 
 
61755
 
    SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
61756
 
 
61757
 
    FOR _itemloc IN SELECT itemloc_id, itemloc_location_id,
61758
 
                           itemloc_ls_id, itemloc_qty
61759
 
                    FROM itemloc
61760
 
                    WHERE ((itemloc_itemsite_id=_p.itemsite_id)
61761
 
                      AND  (itemloc_location_id=_p.invcnt_location_id)) LOOP
61762
 
 
61763
 
      _hasDetail = TRUE;
61764
 
 
61765
 
      INSERT INTO itemlocdist
61766
 
      ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id,
61767
 
        itemlocdist_expiration,
61768
 
        itemlocdist_itemsite_id, itemlocdist_invhist_id, itemlocdist_flush )
61769
 
      VALUES
61770
 
      ( _itemlocSeries, 'I', _itemloc.itemloc_id,
61771
 
        endOfTime(),
61772
 
        _p.itemsite_id, _invhistid, TRUE );
61773
 
 
61774
 
    END LOOP;
61775
 
 
61776
 
    _runningQty := 0;
61777
 
 
61778
 
    FOR _cntslip IN SELECT cntslip_location_id, cntslip_lotserial,
61779
 
                           cntslip_lotserial_expiration,
61780
 
                           cntslip_lotserial_warrpurc,
61781
 
                           SUM(cntslip_qty) AS qty,
61782
 
                           itemsite_item_id
61783
 
                    FROM cntslip,invcnt,itemsite
61784
 
                    WHERE ((cntslip_cnttag_id=pInvcntid)
61785
 
                    AND (cntslip_cnttag_id=invcnt_id)
61786
 
                    AND (invcnt_itemsite_id=itemsite_id))
61787
 
                    GROUP BY cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration,
61788
 
                    cntslip_lotserial_warrpurc, itemsite_item_id LOOP
61789
 
 
61790
 
      IF (LENGTH(_cntslip.cntslip_lotserial)>0) THEN
61791
 
        SELECT ls_id INTO _lsid
61792
 
        FROM ls
61793
 
        WHERE ((ls_item_id=_cntslip.itemsite_item_id)
61794
 
        AND (UPPER(ls_number)=UPPER(_cntslip.cntslip_lotserial)));
61795
 
 
61796
 
        IF (NOT FOUND) THEN
61797
 
          _lsid := NEXTVAL('ls_ls_id_seq');
61798
 
          INSERT INTO ls
61799
 
          VALUES (_lsid,_cntslip.itemsite_item_id,UPPER(_cntslip.cntslip_lotserial));
61800
 
        END IF;
61801
 
      END IF;
61802
 
       
61803
 
      _runningQty := (_runningQty + _cntslip.qty);
61804
 
      _hasDetail = TRUE;
61805
 
 
61806
 
      INSERT INTO itemlocdist
61807
 
      ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id,
61808
 
        itemlocdist_itemsite_id,
61809
 
        itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_warranty,
61810
 
        itemlocdist_qty, itemlocdist_invhist_id )
61811
 
      VALUES
61812
 
      ( _itemlocSeries, 'L', _cntslip.cntslip_location_id,
61813
 
        _p.itemsite_id,
61814
 
        _lsid, COALESCE(_cntslip.cntslip_lotserial_expiration, endOfTime()),
61815
 
        _cntslip.cntslip_lotserial_warrpurc,
61816
 
        _cntslip.qty, _invhistid );
61817
 
 
61818
 
    END LOOP;
61819
 
 
61820
 
    IF (_runningQty > _p.invcnt_qoh_after) THEN
61821
 
      _errorCode = -1;
61822
 
 
61823
 
    ELSIF ( (_runningQty < _p.invcnt_qoh_after) AND
61824
 
            (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN
61825
 
      _errorCode = -2;
61826
 
 
61827
 
    ELSIF (_runningQty < _p.invcnt_qoh_after) THEN
61828
 
      IF ( (NOT _p.itemsite_loccntrl) OR
61829
 
           (_p.itemsite_location_id = -1) ) THEN
61830
 
        _errorCode = -3;
61831
 
 
61832
 
      ELSIF ( SELECT (metric_value='f')
61833
 
              FROM metric
61834
 
              WHERE (metric_name='PostCountTagToDefault') ) THEN
61835
 
        _errorCode = -4;
61836
 
 
61837
 
      ELSE
61838
 
        INSERT INTO itemlocdist
61839
 
        ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id,
61840
 
          itemlocdist_itemsite_id,
61841
 
          itemlocdist_ls_id, itemlocdist_expiration,
61842
 
          itemlocdist_qty, itemlocdist_invhist_id )
61843
 
        SELECT _itemlocSeries, 'L', _p.itemsite_location_id,
61844
 
               _p.itemsite_id,
61845
 
               _lsid, endOfTime(),
61846
 
               (_p.invcnt_qoh_after - _runningQty), _invhistid;
61847
 
 
61848
 
        _hasDetail = TRUE;
61849
 
        _errorCode = 0;
61850
 
      END IF;
61851
 
    ELSE
61852
 
      _errorCode = 0;
61853
 
    END IF;
61854
 
 
61855
 
    IF (_errorCode <> 0) THEN
61856
 
      DELETE FROM itemlocdist
61857
 
      WHERE (itemlocdist_series=_itemlocSeries);
61858
 
  
61859
 
      RETURN _errorCode;
61860
 
    END IF;
61861
 
 
61862
 
  END IF;
61863
 
 
61864
 
  UPDATE invcnt
61865
 
  SET invcnt_qoh_before=_origLocQty,
61866
 
      invcnt_postdate=_postDate,
61867
 
      invcnt_posted=TRUE,
61868
 
      invcnt_invhist_id=_invhistid,
61869
 
      invcnt_post_username=CURRENT_USER
61870
 
  WHERE (invcnt_id=pInvcntid);
61871
 
 
61872
 
  INSERT INTO invhist
61873
 
   ( invhist_id, invhist_itemsite_id,
61874
 
     invhist_transdate, invhist_transtype, invhist_invqty,
61875
 
     invhist_qoh_before, invhist_qoh_after,
61876
 
     invhist_docnumber, invhist_comments,
61877
 
     invhist_invuom, invhist_unitcost, invhist_hasdetail,
61878
 
     invhist_costmethod, invhist_value_before, invhist_value_after,
61879
 
     invhist_series )
61880
 
  SELECT _invhistid, itemsite_id,
61881
 
         _postDate, 'CC', (invcnt_qoh_after - invcnt_qoh_before),
61882
 
         invcnt_qoh_before, invcnt_qoh_after,
61883
 
         invcnt_tagnumber, invcnt_comments,
61884
 
         uom_name, _p.cost, _hasDetail,
61885
 
         _p.itemsite_costmethod, _p.itemsite_value,
61886
 
         _p.itemsite_value + (_p.cost * (invcnt_qoh_after - invcnt_qoh_before)),
61887
 
         _itemlocSeries
61888
 
  FROM itemsite, invcnt, item, uom
61889
 
  WHERE ( (invcnt_itemsite_id=itemsite_id)
61890
 
   AND (itemsite_item_id=item_id)
61891
 
   AND (item_inv_uom_id=uom_id)
61892
 
   AND (itemsite_controlmethod <> 'N')
61893
 
   AND (invcnt_id=pInvcntid) );
61894
 
 
61895
 
  IF (_netable) THEN
61896
 
    UPDATE itemsite
61897
 
    SET itemsite_qtyonhand= itemsite_qtyonhand + (_p.invcnt_qoh_after - _origLocQty),
61898
 
        itemsite_datelastcount=_postDate
61899
 
    WHERE (itemsite_id=_p.itemsite_id);
61900
 
  ELSE
61901
 
    UPDATE itemsite
61902
 
    SET itemsite_nnqoh =  itemsite_nnqoh - _origLocQty,
61903
 
        itemsite_qtyonhand = itemsite_qtyonhand + _p.invcnt_qoh_after,
61904
 
        itemsite_datelastcount=_postDate
61905
 
    WHERE (itemsite_id=_p.itemsite_id);
61906
 
  END IF;
61907
 
 
61908
 
  IF (_hasDetail) THEN
61909
 
    PERFORM distributeItemlocSeries(_itemlocSeries);
61910
 
  END IF;
61911
 
 
61912
 
  IF (pThaw) THEN
61913
 
    PERFORM thawItemSite(invcnt_itemsite_id) 
61914
 
    FROM invcnt
61915
 
    WHERE (invcnt_id=pInvcntid);
61916
 
  END IF;
61917
 
 
61918
 
  PERFORM insertGLTransaction( 'I/M', 'CT', _p.invcnt_tagnumber, ('Post Count Tag #' || _p.invcnt_tagnumber || ' for Item ' || _p.item_number),
61919
 
                               costcat_adjustment_accnt_id, costcat_asset_accnt_id, _invhistid,
61920
 
                               ( (_p.invcnt_qoh_after - _origLocQty) * _p.cost), CURRENT_DATE )
61921
 
  FROM invcnt, itemsite, costcat
61922
 
  WHERE ( (invcnt_itemsite_id=itemsite_id)
61923
 
   AND (itemsite_costcat_id=costcat_id)
61924
 
   AND (invcnt_id=pInvcntid) );
61925
 
 
61926
 
  RETURN 0;
61927
 
END;
61928
 
$_$;
61929
 
 
61930
 
 
61931
 
ALTER FUNCTION public.postcounttaglocation(integer, boolean, text) OWNER TO admin;
61932
 
 
61933
 
--
61934
 
--
61935
 
 
61936
 
CREATE FUNCTION postcounttags(integer, boolean) RETURNS integer
61937
 
    LANGUAGE plpgsql
61938
 
    AS $_$
61939
 
DECLARE
61940
 
  pWarehousid ALIAS FOR $1;
61941
 
  pThaw ALIAS FOR $2;
61942
 
  _invcnt RECORD;
61943
 
  _result INTEGER := 0;
61944
 
  _return INTEGER := 0;
61945
 
 
61946
 
BEGIN
61947
 
 
61948
 
  FOR _invcnt IN SELECT invcnt_id
61949
 
                 FROM invcnt, itemsite
61950
 
                 WHERE ( (invcnt_itemsite_id=itemsite_id)
61951
 
                  AND ( (pWarehousid=-1) OR (itemsite_warehous_id=pWarehousid) )
61952
 
                  AND (invcnt_qoh_after IS NOT NULL)
61953
 
                  AND (NOT invcnt_posted) ) LOOP
61954
 
    SELECT postCountTag(_invcnt.invcnt_id, pThaw) INTO _result;
61955
 
    IF (_result < _return) THEN
61956
 
      _return := _result;
61957
 
    END IF;
61958
 
  END LOOP;
61959
 
 
61960
 
  RETURN _return;
61961
 
 
61962
 
END;
61963
 
$_$;
61964
 
 
61965
 
 
61966
 
ALTER FUNCTION public.postcounttags(integer, boolean) OWNER TO admin;
61967
 
 
61968
 
--
61969
 
--
61970
 
 
61971
 
CREATE FUNCTION postcreditmemo(integer, integer) RETURNS integer
61972
 
    LANGUAGE plpgsql
61973
 
    AS $_$
61974
 
DECLARE
61975
 
  pCmheadid ALIAS FOR $1;
61976
 
  pItemlocSeries ALIAS FOR $2;
61977
 
  _return INTEGER;
61978
 
 
61979
 
BEGIN
61980
 
 
61981
 
  SELECT postCreditMemo(pCmheadid, fetchJournalNumber('AR-CM'), pItemlocSeries) INTO _return;
61982
 
 
61983
 
  RETURN _return;
61984
 
 
61985
 
END;
61986
 
$_$;
61987
 
 
61988
 
 
61989
 
ALTER FUNCTION public.postcreditmemo(integer, integer) OWNER TO admin;
61990
 
 
61991
 
--
61992
 
--
61993
 
 
61994
 
CREATE FUNCTION postcreditmemo(integer, integer, integer) RETURNS integer
61995
 
    LANGUAGE plpgsql
61996
 
    AS $_$
61997
 
DECLARE
61998
 
  pCmheadid ALIAS FOR $1;
61999
 
  pJournalNumber ALIAS FOR $2;
62000
 
  pItemlocSeries ALIAS FOR $3;
62001
 
  _r RECORD;
62002
 
  _p RECORD;
62003
 
  _aropenid INTEGER;
62004
 
  _cohistid INTEGER;
62005
 
  _sequence INTEGER;
62006
 
  _itemlocSeries INTEGER;
62007
 
  _invhistid INTEGER;
62008
 
  _test INTEGER;
62009
 
  _totalAmount NUMERIC   := 0;
62010
 
  _commissionDue NUMERIC := 0;
62011
 
  _toApply NUMERIC;
62012
 
  _toClose BOOLEAN;
62013
 
  _glDate       DATE;
62014
 
  _taxBaseValue NUMERIC := 0;
62015
 
 
62016
 
BEGIN
62017
 
 
62018
 
  SELECT cmhead.*,
62019
 
         findARAccount(cmhead_cust_id) AS ar_accnt_id,
62020
 
         ( SELECT COALESCE(SUM(taxhist_tax), 0)
62021
 
           FROM cmheadtax
62022
 
           WHERE ( (taxhist_parent_id = cmhead_id)
62023
 
             AND   (taxhist_taxtype_id = getAdjustmentTaxtypeId()) ) ) AS adjtax
62024
 
         INTO _p
62025
 
  FROM cmhead
62026
 
  WHERE (cmhead_id=pCmheadid);
62027
 
 
62028
 
  IF (_p.cmhead_posted) THEN
62029
 
    RETURN -10;
62030
 
  END IF;
62031
 
 
62032
 
  IF (_p.cmhead_hold) THEN
62033
 
    RETURN -11;
62034
 
  END IF;
62035
 
 
62036
 
  _glDate := COALESCE(_p.cmhead_gldistdate, _p.cmhead_docdate);
62037
 
 
62038
 
  _itemlocSeries = pItemlocSeries;
62039
 
 
62040
 
  SELECT fetchGLSequence() INTO _sequence;
62041
 
 
62042
 
  FOR _r IN SELECT tax_sales_accnt_id, 
62043
 
              round(sum(taxdetail_tax),2) AS tax,
62044
 
              currToBase(_p.cmhead_curr_id, round(sum(taxdetail_tax),2), _p.cmhead_docdate) AS taxbasevalue
62045
 
            FROM tax 
62046
 
             JOIN calculateTaxDetailSummary('CM', pCmheadid, 'T') ON (taxdetail_tax_id=tax_id)
62047
 
            GROUP BY tax_id, tax_sales_accnt_id LOOP
62048
 
 
62049
 
    PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number,
62050
 
                                _r.tax_sales_accnt_id, 
62051
 
                                _r.taxbasevalue,
62052
 
                                _glDate, _p.cmhead_billtoname );
62053
 
 
62054
 
    _totalAmount := _totalAmount + _r.tax * -1;
62055
 
  END LOOP;
62056
 
 
62057
 
  UPDATE cmitemtax SET 
62058
 
    taxhist_docdate=_p.cmhead_docdate,
62059
 
    taxhist_distdate=_glDate,
62060
 
    taxhist_curr_id=_p.cmhead_curr_id,
62061
 
    taxhist_curr_rate=curr_rate,
62062
 
    taxhist_journalnumber=pJournalNumber
62063
 
  FROM cmhead
62064
 
   JOIN cmitem ON (cmhead_id=cmitem_cmhead_id),
62065
 
   curr_rate
62066
 
  WHERE ((cmhead_id=pCmheadId)
62067
 
    AND (taxhist_parent_id=cmitem_id)
62068
 
    AND (_p.cmhead_curr_id=curr_id)
62069
 
    AND (_p.cmhead_docdate BETWEEN curr_effective 
62070
 
                           AND curr_expires) );
62071
 
 
62072
 
  UPDATE cmheadtax SET 
62073
 
    taxhist_docdate=_p.cmhead_docdate,
62074
 
    taxhist_distdate=_glDate,
62075
 
    taxhist_curr_id=_p.cmhead_curr_id,
62076
 
    taxhist_curr_rate=curr_rate,
62077
 
    taxhist_journalnumber=pJournalNumber
62078
 
  FROM curr_rate
62079
 
  WHERE ((taxhist_parent_id=pCmheadId)
62080
 
    AND (_p.cmhead_curr_id=curr_id)
62081
 
    AND (_p.cmhead_docdate BETWEEN curr_effective 
62082
 
                           AND curr_expires) );
62083
 
 
62084
 
  FOR _r IN SELECT *, stdCost(item_id) AS std_cost
62085
 
            FROM creditmemoitem
62086
 
            WHERE ( (cmitem_cmhead_id=pCmheadid)
62087
 
              AND   (cmitem_qtycredit <> 0 ) ) LOOP
62088
 
 
62089
 
    _commissionDue := (_commissionDue + (_r.extprice * _p.cmhead_commission));
62090
 
 
62091
 
    IF (_r.extprice <> 0) THEN
62092
 
      SELECT insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number,
62093
 
                                 CASE WHEN _p.cmhead_rahead_id IS NULL THEN
62094
 
                                   getPrjAccntId(_p.cmhead_prj_id, salesaccnt_credit_accnt_id)
62095
 
                                 ELSE
62096
 
                                   getPrjAccntId(_p.cmhead_prj_id, salesaccnt_returns_accnt_id)
62097
 
                                 END,
62098
 
                               round(currToBase(_p.cmhead_curr_id,
62099
 
                                                _r.extprice * -1,
62100
 
                                                _p.cmhead_docdate), 2),
62101
 
                                 _glDate, _p.cmhead_billtoname) INTO _test
62102
 
      FROM salesaccnt
62103
 
      WHERE (salesaccnt_id=findSalesAccnt(_r.cmitem_itemsite_id, 'IS', _p.cmhead_cust_id,
62104
 
                                          _p.cmhead_saletype_id, _p.cmhead_shipzone_id));
62105
 
      IF (NOT FOUND) THEN
62106
 
        PERFORM deleteGLSeries(_sequence);
62107
 
        RETURN -12;
62108
 
      END IF;
62109
 
    END IF;
62110
 
 
62111
 
    SELECT nextval('cohist_cohist_id_seq') INTO _cohistid;
62112
 
    INSERT INTO cohist
62113
 
    ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id,
62114
 
      cohist_shipdate, cohist_shipvia,
62115
 
      cohist_ordernumber, cohist_ponumber, cohist_orderdate,
62116
 
      cohist_doctype, cohist_invcnumber, cohist_invcdate,
62117
 
      cohist_qtyshipped, cohist_unitprice, cohist_unitcost,
62118
 
      cohist_salesrep_id, cohist_commission, cohist_commissionpaid,
62119
 
      cohist_billtoname, cohist_billtoaddress1,
62120
 
      cohist_billtoaddress2, cohist_billtoaddress3,
62121
 
      cohist_billtocity, cohist_billtostate, cohist_billtozip,
62122
 
      cohist_shiptoname, cohist_shiptoaddress1,
62123
 
      cohist_shiptoaddress2, cohist_shiptoaddress3,
62124
 
      cohist_shiptocity, cohist_shiptostate, cohist_shiptozip,
62125
 
      cohist_curr_id, cohist_taxtype_id, cohist_taxzone_id,
62126
 
      cohist_shipzone_id, cohist_saletype_id )
62127
 
    VALUES
62128
 
    ( _cohistid, _p.cmhead_cust_id, _r.cmitem_itemsite_id, _p.cmhead_shipto_id,
62129
 
      _p.cmhead_docdate, '',
62130
 
      _p.cmhead_number, _p.cmhead_custponumber, _p.cmhead_docdate,
62131
 
      'C', _p.cmhead_invcnumber, _p.cmhead_docdate,
62132
 
      (_r.qty * -1), _r.unitprice, _r.std_cost,
62133
 
      _p.cmhead_salesrep_id, (_p.cmhead_commission * _r.extprice * -1), FALSE,
62134
 
      _p.cmhead_billtoname, _p.cmhead_billtoaddress1,
62135
 
      _p.cmhead_billtoaddress2, _p.cmhead_billtoaddress3,
62136
 
      _p.cmhead_billtocity, _p.cmhead_billtostate, _p.cmhead_billtozip,
62137
 
      _p.cmhead_shipto_name, _p.cmhead_shipto_address1,
62138
 
      _p.cmhead_shipto_address2, _p.cmhead_shipto_address3,
62139
 
      _p.cmhead_shipto_city, _p.cmhead_shipto_state, _p.cmhead_shipto_zipcode,
62140
 
      _p.cmhead_curr_id, _r.cmitem_taxtype_id, _p.cmhead_taxzone_id,
62141
 
      _p.cmhead_shipzone_id, _p.cmhead_saletype_id );
62142
 
    INSERT INTO cohisttax
62143
 
    ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id,
62144
 
      taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
62145
 
      taxhist_percent, taxhist_amount, taxhist_tax,
62146
 
      taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
62147
 
      taxhist_journalnumber )
62148
 
    SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id,
62149
 
           taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
62150
 
           taxhist_percent, taxhist_amount, taxhist_tax,
62151
 
           taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
62152
 
           taxhist_journalnumber 
62153
 
    FROM cmitemtax
62154
 
    WHERE (taxhist_parent_id=_r.cmitem_id);
62155
 
 
62156
 
    _totalAmount := _totalAmount + round(_r.extprice, 2);
62157
 
 
62158
 
  END LOOP;
62159
 
 
62160
 
  IF (_p.cmhead_misc <> 0) THEN
62161
 
    SELECT insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number,
62162
 
                               getPrjAccntId(_p.cmhead_prj_id, accnt_id), round(currToBase(_p.cmhead_curr_id,
62163
 
                                                          _p.cmhead_misc * -1,
62164
 
                                                          _p.cmhead_docdate), 2),
62165
 
                               _glDate, _p.cmhead_billtoname) INTO _test
62166
 
    FROM accnt
62167
 
    WHERE (accnt_id=_p.cmhead_misc_accnt_id);
62168
 
 
62169
 
    IF (NOT FOUND) THEN
62170
 
      PERFORM deleteGLSeries(_sequence);
62171
 
      RETURN -14;
62172
 
    END IF;
62173
 
 
62174
 
    INSERT INTO cohist
62175
 
    ( cohist_cust_id, cohist_itemsite_id, cohist_shipto_id,
62176
 
      cohist_misc_type, cohist_misc_descrip, cohist_misc_id,
62177
 
      cohist_shipdate, cohist_shipvia,
62178
 
      cohist_ordernumber, cohist_ponumber, cohist_orderdate,
62179
 
      cohist_doctype, cohist_invcnumber, cohist_invcdate,
62180
 
      cohist_qtyshipped, cohist_unitprice, cohist_unitcost,
62181
 
      cohist_salesrep_id, cohist_commission, cohist_commissionpaid,
62182
 
      cohist_billtoname, cohist_billtoaddress1,
62183
 
      cohist_billtoaddress2, cohist_billtoaddress3,
62184
 
      cohist_billtocity, cohist_billtostate, cohist_billtozip,
62185
 
      cohist_shiptoname, cohist_shiptoaddress1,
62186
 
      cohist_shiptoaddress2, cohist_shiptoaddress3,
62187
 
      cohist_shiptocity, cohist_shiptostate, cohist_shiptozip,
62188
 
      cohist_curr_id,
62189
 
      cohist_shipzone_id, cohist_saletype_id )
62190
 
    VALUES
62191
 
    ( _p.cmhead_cust_id, -1, _p.cmhead_shipto_id,
62192
 
      'M', _p.cmhead_misc_descrip, _p.cmhead_misc_accnt_id,
62193
 
      _p.cmhead_docdate, '',
62194
 
      _p.cmhead_number, _p.cmhead_custponumber, _p.cmhead_docdate,
62195
 
      'C', _p.cmhead_invcnumber, _p.cmhead_docdate,
62196
 
      1, (_p.cmhead_misc * -1), (_p.cmhead_misc * -1),
62197
 
      _p.cmhead_salesrep_id, 0, FALSE,
62198
 
      _p.cmhead_billtoname, _p.cmhead_billtoaddress1,
62199
 
      _p.cmhead_billtoaddress2, _p.cmhead_billtoaddress3,
62200
 
      _p.cmhead_billtocity, _p.cmhead_billtostate, _p.cmhead_billtozip,
62201
 
      _p.cmhead_shipto_name, _p.cmhead_shipto_address1,
62202
 
      _p.cmhead_shipto_address2, _p.cmhead_shipto_address3,
62203
 
      _p.cmhead_shipto_city, _p.cmhead_shipto_state, _p.cmhead_shipto_zipcode,
62204
 
      _p.cmhead_curr_id,
62205
 
      _p.cmhead_shipzone_id, _p.cmhead_saletype_id );
62206
 
 
62207
 
    _totalAmount := _totalAmount + _p.cmhead_misc;
62208
 
  END IF;
62209
 
 
62210
 
  -- Credit Tax Adjustments
62211
 
  IF (_p.adjtax <> 0) THEN
62212
 
  --  Record the Sales History for Tax Adjustment
62213
 
    SELECT nextval('cohist_cohist_id_seq') INTO _cohistid;
62214
 
    INSERT INTO cohist
62215
 
    ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id,
62216
 
      cohist_misc_type, cohist_misc_descrip,
62217
 
      cohist_shipdate, cohist_shipvia,
62218
 
      cohist_ordernumber, cohist_ponumber, cohist_orderdate,
62219
 
      cohist_doctype, cohist_invcnumber, cohist_invcdate,
62220
 
      cohist_qtyshipped, cohist_unitprice, cohist_unitcost,
62221
 
      cohist_salesrep_id, cohist_commission, cohist_commissionpaid,
62222
 
      cohist_billtoname, cohist_billtoaddress1,
62223
 
      cohist_billtoaddress2, cohist_billtoaddress3,
62224
 
      cohist_billtocity, cohist_billtostate, cohist_billtozip,
62225
 
      cohist_shiptoname, cohist_shiptoaddress1,
62226
 
      cohist_shiptoaddress2, cohist_shiptoaddress3,
62227
 
      cohist_shiptocity, cohist_shiptostate, cohist_shiptozip,
62228
 
      cohist_curr_id, cohist_taxtype_id, cohist_taxzone_id,
62229
 
      cohist_shipzone_id, cohist_saletype_id )
62230
 
    VALUES
62231
 
    ( _cohistid, _p.cmhead_cust_id, -1, _p.cmhead_shipto_id,
62232
 
      'T', 'Misc Tax Adjustment',
62233
 
      _p.cmhead_docdate, '',
62234
 
      _p.cmhead_number, _p.cmhead_custponumber, _p.cmhead_docdate,
62235
 
      'C', _p.cmhead_invcnumber, _p.cmhead_docdate,
62236
 
      0, 0, 0,
62237
 
      _p.cmhead_salesrep_id, 0, FALSE,
62238
 
      _p.cmhead_billtoname, _p.cmhead_billtoaddress1,
62239
 
      _p.cmhead_billtoaddress2, _p.cmhead_billtoaddress3,
62240
 
      _p.cmhead_billtocity, _p.cmhead_billtostate, _p.cmhead_billtozip,
62241
 
      _p.cmhead_shipto_name, _p.cmhead_shipto_address1,
62242
 
      _p.cmhead_shipto_address2, _p.cmhead_shipto_address3,
62243
 
      _p.cmhead_shipto_city, _p.cmhead_shipto_state, _p.cmhead_shipto_zipcode,
62244
 
      _p.cmhead_curr_id, getAdjustmentTaxtypeId(), _p.cmhead_taxzone_id,
62245
 
      _p.cmhead_shipzone_id, _p.cmhead_saletype_id );
62246
 
    INSERT INTO cohisttax
62247
 
    ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id,
62248
 
      taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
62249
 
      taxhist_percent, taxhist_amount, taxhist_tax,
62250
 
      taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
62251
 
      taxhist_journalnumber  )
62252
 
    SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id,
62253
 
           (taxhist_basis * -1), taxhist_basis_tax_id, taxhist_sequence,
62254
 
           taxhist_percent, taxhist_amount, taxhist_tax,
62255
 
           taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
62256
 
           taxhist_journalnumber 
62257
 
    FROM cmheadtax
62258
 
    WHERE ( (taxhist_parent_id=_p.cmhead_id)
62259
 
      AND   (taxhist_taxtype_id=getAdjustmentTaxtypeId()) );
62260
 
 
62261
 
  END IF;
62262
 
 
62263
 
  IF (_p.cmhead_freight <> 0) THEN
62264
 
    SELECT insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number,
62265
 
                               getPrjAccntId(_p.cmhead_prj_id, accnt_id),
62266
 
                               round(currToBase(_p.cmhead_curr_id,
62267
 
                                                _p.cmhead_freight * -1,
62268
 
                                                _p.cmhead_docdate), 2),
62269
 
                               _glDate, _p.cmhead_billtoname) INTO _test
62270
 
    FROM accnt
62271
 
    WHERE (accnt_id=findFreightAccount(_p.cmhead_cust_id));
62272
 
 
62273
 
    IF (NOT FOUND) THEN
62274
 
      PERFORM deleteGLSeries(_sequence);
62275
 
      RETURN -16;
62276
 
    END IF;
62277
 
 
62278
 
    _totalAmount := _totalAmount + _p.cmhead_freight;
62279
 
 
62280
 
    SELECT nextval('cohist_cohist_id_seq') INTO _cohistid;
62281
 
    INSERT INTO cohist
62282
 
    ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id,
62283
 
      cohist_misc_type, cohist_misc_descrip,
62284
 
      cohist_shipdate, cohist_shipvia,
62285
 
      cohist_ordernumber, cohist_ponumber, cohist_orderdate,
62286
 
      cohist_doctype, cohist_invcnumber, cohist_invcdate,
62287
 
      cohist_qtyshipped, cohist_unitprice, cohist_unitcost,
62288
 
      cohist_salesrep_id, cohist_commission, cohist_commissionpaid,
62289
 
      cohist_billtoname, cohist_billtoaddress1,
62290
 
      cohist_billtoaddress2, cohist_billtoaddress3,
62291
 
      cohist_billtocity, cohist_billtostate, cohist_billtozip,
62292
 
      cohist_shiptoname, cohist_shiptoaddress1,
62293
 
      cohist_shiptoaddress2, cohist_shiptoaddress3,
62294
 
      cohist_shiptocity, cohist_shiptostate, cohist_shiptozip,
62295
 
      cohist_curr_id, cohist_taxtype_id, cohist_taxzone_id,
62296
 
      cohist_shipzone_id, cohist_saletype_id )
62297
 
    VALUES
62298
 
    ( _cohistid, _p.cmhead_cust_id, -1, _p.cmhead_shipto_id,
62299
 
      'F', 'Freight Charge',
62300
 
      _p.cmhead_docdate, '',
62301
 
      _p.cmhead_number, _p.cmhead_custponumber, _p.cmhead_docdate,
62302
 
      'C', _p.cmhead_invcnumber, _p.cmhead_docdate,
62303
 
      1, (_p.cmhead_freight * -1), (_p.cmhead_freight * -1),
62304
 
      _p.cmhead_salesrep_id, 0, FALSE,
62305
 
      _p.cmhead_billtoname, _p.cmhead_billtoaddress1,
62306
 
      _p.cmhead_billtoaddress2, _p.cmhead_billtoaddress3,
62307
 
      _p.cmhead_billtocity, _p.cmhead_billtostate, _p.cmhead_billtozip,
62308
 
      _p.cmhead_shipto_name, _p.cmhead_shipto_address1,
62309
 
      _p.cmhead_shipto_address2, _p.cmhead_shipto_address3,
62310
 
      _p.cmhead_shipto_city, _p.cmhead_shipto_state, _p.cmhead_shipto_zipcode,
62311
 
      _p.cmhead_curr_id, getFreightTaxtypeId(), _p.cmhead_taxzone_id,
62312
 
      _p.cmhead_shipzone_id, _p.cmhead_saletype_id );
62313
 
    INSERT INTO cohisttax
62314
 
    ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id,
62315
 
      taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
62316
 
      taxhist_percent, taxhist_amount, taxhist_tax,
62317
 
      taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
62318
 
      taxhist_journalnumber  )
62319
 
    SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id,
62320
 
           (taxhist_basis * -1), taxhist_basis_tax_id, taxhist_sequence,
62321
 
           taxhist_percent, taxhist_amount, taxhist_tax,
62322
 
           taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
62323
 
           taxhist_journalnumber 
62324
 
    FROM cmheadtax
62325
 
    WHERE ( (taxhist_parent_id=_p.cmhead_id)
62326
 
      AND   (taxhist_taxtype_id=getFreightTaxtypeId()) );
62327
 
 
62328
 
  END IF;
62329
 
 
62330
 
  _totalAmount := _totalAmount;
62331
 
 
62332
 
  IF (_totalAmount <> 0) THEN
62333
 
    IF (_p.ar_accnt_id != -1) THEN
62334
 
      PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number,
62335
 
                                  _p.ar_accnt_id,
62336
 
                                  round(currToBase(_p.cmhead_curr_id,
62337
 
                                                   _totalAmount,
62338
 
                                                   _p.cmhead_docdate), 2),
62339
 
                                  _glDate, _p.cmhead_billtoname);
62340
 
    ELSE
62341
 
      PERFORM deleteGLSeries(_sequence);
62342
 
      RETURN -18;
62343
 
    END IF;
62344
 
  END IF;
62345
 
 
62346
 
  PERFORM postGLSeries(_sequence, pJournalNumber);
62347
 
 
62348
 
  SELECT NEXTVAL('aropen_aropen_id_seq') INTO _aropenid;
62349
 
  INSERT INTO aropen
62350
 
  ( aropen_id, aropen_username, aropen_journalnumber,
62351
 
    aropen_open, aropen_posted,
62352
 
    aropen_cust_id, aropen_ponumber,
62353
 
    aropen_docnumber,
62354
 
    aropen_applyto, aropen_doctype,
62355
 
    aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id,
62356
 
    aropen_amount, aropen_paid,
62357
 
    aropen_salesrep_id, aropen_commission_due, aropen_commission_paid,
62358
 
    aropen_ordernumber, aropen_notes,
62359
 
    aropen_rsncode_id, aropen_curr_id )
62360
 
  SELECT _aropenid, getEffectiveXtUser(), pJournalNumber,
62361
 
         TRUE, FALSE,
62362
 
         cmhead_cust_id, cmhead_custponumber,
62363
 
         cmhead_number,
62364
 
         CASE WHEN (cmhead_invcnumber='-1') THEN 'OPEN'
62365
 
              ELSE (cmhead_invcnumber::TEXT)
62366
 
         END,
62367
 
         'C',
62368
 
         cmhead_docdate, cmhead_docdate, _glDate, -1,
62369
 
         _totalAmount, 0,
62370
 
         cmhead_salesrep_id, (_commissionDue * -1), FALSE,
62371
 
         cmhead_number::TEXT, cmhead_comments,
62372
 
         cmhead_rsncode_id, cmhead_curr_id
62373
 
  FROM cmhead
62374
 
  WHERE (cmhead_id=pCmheadid);
62375
 
 
62376
 
  FOR _r IN SELECT cmitem_itemsite_id AS itemsite_id, cmitem_id,
62377
 
                   (cmitem_qtyreturned * cmitem_qty_invuomratio) AS qty,
62378
 
                   cmhead_number, cmhead_cust_id AS cust_id, item_number,
62379
 
                   cmhead_saletype_id AS saletype_id, cmhead_shipzone_id AS shipzone_id,
62380
 
                   stdCost(item_id) AS std_cost, cmhead_prj_id,
62381
 
                   itemsite_costmethod
62382
 
            FROM cmhead, cmitem, itemsite, item
62383
 
            WHERE ( (cmitem_cmhead_id=cmhead_id)
62384
 
             AND (cmitem_itemsite_id=itemsite_id)
62385
 
             AND (itemsite_item_id=item_id)
62386
 
             AND (cmitem_qtyreturned <> 0)
62387
 
             AND (cmitem_updateinv)
62388
 
             AND (cmhead_id=pCmheadid) ) LOOP
62389
 
 
62390
 
    IF (_itemlocSeries = 0) THEN
62391
 
      _itemlocSeries := NEXTVAL('itemloc_series_seq');
62392
 
    END IF;
62393
 
    IF (_r.itemsite_costmethod != 'J') THEN
62394
 
      SELECT postInvTrans(itemsite_id, 'RS', _r.qty,
62395
 
                         'S/O', 'CM', _r.cmhead_number, '',
62396
 
                         ('Credit Return ' || _r.item_number),
62397
 
                         costcat_asset_accnt_id,
62398
 
                         getPrjAccntId(_r.cmhead_prj_id, resolveCOSAccount(itemsite_id, _r.cust_id, _r.saletype_id, _r.shipzone_id)), 
62399
 
                         _itemlocSeries, _glDate, (_r.std_cost * _r.qty)) INTO _invhistid
62400
 
        FROM itemsite, costcat
62401
 
       WHERE ((itemsite_costcat_id=costcat_id)
62402
 
          AND (itemsite_id=_r.itemsite_id));
62403
 
    ELSE
62404
 
      RAISE DEBUG 'postCreditMemo(%, %, %) tried to postInvTrans a %-costed item',
62405
 
                  pCmheadid, pJournalNumber, pItemlocSeries,
62406
 
                  _r.itemsite_costmethod;
62407
 
    END IF;
62408
 
 
62409
 
  END LOOP;
62410
 
 
62411
 
  FOR _r IN SELECT cmitem_qtyreturned, cmitem_itemsite_id, cohead_id
62412
 
            FROM cmitem, cmhead, invchead, cohead
62413
 
            WHERE ( (cmitem_cmhead_id=cmhead_id)
62414
 
             AND (cmhead_invcnumber=invchead_invcnumber)
62415
 
             AND (invchead_ordernumber=cohead_number)
62416
 
             AND (cmitem_qtyreturned <> 0)
62417
 
             AND (cmitem_updateinv)
62418
 
             AND (cmhead_id=pCmheadid) ) LOOP
62419
 
    UPDATE coitem
62420
 
    SET coitem_qtyreturned = (coitem_qtyreturned + _r.cmitem_qtyreturned)
62421
 
    WHERE coitem_id IN ( SELECT coitem_id
62422
 
                         FROM coitem
62423
 
                         WHERE ( (coitem_cohead_id=_r.cohead_id)
62424
 
                          AND (coitem_itemsite_id = _r.cmitem_itemsite_id) )
62425
 
                         LIMIT 1 );
62426
 
  END LOOP;
62427
 
 
62428
 
  UPDATE cmhead
62429
 
  SET cmhead_posted=TRUE, cmhead_gldistdate=_glDate
62430
 
  WHERE (cmhead_id=pCmheadid);
62431
 
 
62432
 
  SELECT cmhead_number, cmhead_curr_id, cmhead_docdate,
62433
 
         aropen_id, aropen_cust_id, aropen_docnumber,
62434
 
         currToCurr(aropen_curr_id, cmhead_curr_id, aropen_amount - aropen_paid,
62435
 
                    cmhead_docdate) AS balance INTO _p
62436
 
  FROM aropen, cmhead
62437
 
  WHERE ( (aropen_doctype='I')
62438
 
   AND (aropen_docnumber=cmhead_invcnumber)
62439
 
   AND (cmhead_id=pCmheadid) );
62440
 
  IF (FOUND) THEN
62441
 
 
62442
 
    IF round(_totalAmount, 2) <= round(_p.balance, 2) THEN
62443
 
      _toApply = _totalAmount;
62444
 
    ELSE
62445
 
      _toApply = _p.balance;
62446
 
    END IF;
62447
 
 
62448
 
    UPDATE aropen
62449
 
    SET aropen_paid = round(aropen_paid + currToCurr(_p.cmhead_curr_id,
62450
 
                                                     aropen_curr_id, _toApply,
62451
 
                                                     _p.cmhead_docdate), 2)
62452
 
    WHERE (aropen_id=_p.aropen_id);
62453
 
 
62454
 
    UPDATE aropen
62455
 
    SET aropen_paid = round(currToCurr(_p.cmhead_curr_id, aropen_curr_id,
62456
 
                                       _toApply, _p.cmhead_docdate), 2)
62457
 
    WHERE (aropen_id=_aropenid);
62458
 
 
62459
 
    INSERT INTO arapply
62460
 
    ( arapply_cust_id,
62461
 
      arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber,
62462
 
      arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber,
62463
 
      arapply_fundstype, arapply_refnumber,
62464
 
      arapply_applied, arapply_closed,
62465
 
      arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_curr_id )
62466
 
    VALUES
62467
 
    ( _p.aropen_cust_id,
62468
 
      _aropenid, 'C', _p.cmhead_number,
62469
 
      _p.aropen_id, 'I', _p.aropen_docnumber,
62470
 
      '', '',
62471
 
      round(_toApply, 2), _toClose,
62472
 
      CURRENT_DATE, _p.cmhead_docdate, 0, _p.cmhead_curr_id );
62473
 
 
62474
 
  END IF;
62475
 
    
62476
 
  RETURN _itemlocSeries;
62477
 
 
62478
 
END;
62479
 
$_$;
62480
 
 
62481
 
 
62482
 
ALTER FUNCTION public.postcreditmemo(integer, integer, integer) OWNER TO admin;
62483
 
 
62484
 
--
62485
 
--
62486
 
 
62487
 
CREATE FUNCTION postcreditmemos(boolean) RETURNS integer
62488
 
    LANGUAGE plpgsql
62489
 
    AS $_$
62490
 
DECLARE
62491
 
  pPostUnprinted ALIAS FOR $1;
62492
 
  _cmhead RECORD;
62493
 
  _result INTEGER;
62494
 
  _return INTEGER        := 0;
62495
 
  _itemlocSeries INTEGER := 0;
62496
 
 
62497
 
BEGIN
62498
 
 
62499
 
  _itemlocSeries := 0;
62500
 
 
62501
 
  FOR _cmhead IN SELECT cmhead_id
62502
 
                 FROM cmhead
62503
 
                 WHERE ( (NOT cmhead_posted)
62504
 
                   AND   (NOT cmhead_hold)
62505
 
                   AND   (checkCreditMemoSitePrivs(cmhead_id))
62506
 
                   AND   ((pPostUnprinted) OR (cmhead_printed)) ) LOOP
62507
 
 
62508
 
    SELECT postCreditMemo(_cmhead.cmhead_id, _itemlocSeries) INTO _result;
62509
 
    IF (_result < _return) THEN
62510
 
      _return := _result;
62511
 
    END IF;
62512
 
 
62513
 
  END LOOP;
62514
 
 
62515
 
  RETURN _return;
62516
 
 
62517
 
END;
62518
 
$_$;
62519
 
 
62520
 
 
62521
 
ALTER FUNCTION public.postcreditmemos(boolean) OWNER TO admin;
62522
 
 
62523
 
--
62524
 
--
62525
 
 
62526
 
CREATE FUNCTION postcreditmemos(boolean, integer) RETURNS integer
62527
 
    LANGUAGE plpgsql
62528
 
    AS $_$
62529
 
DECLARE
62530
 
  pPostUnprinted ALIAS FOR $1;
62531
 
  pJournalNumber ALIAS FOR $2;
62532
 
  _r RECORD;
62533
 
  _itemlocSeries INTEGER := 0;
62534
 
 
62535
 
BEGIN
62536
 
 
62537
 
  _itemlocSeries := 0;
62538
 
 
62539
 
  FOR _r IN SELECT cmhead_id
62540
 
            FROM cmhead
62541
 
            WHERE ( (NOT cmhead_posted)
62542
 
              AND   (NOT cmhead_hold)
62543
 
              AND   (checkCreditMemoSitePrivs(cmhead_id))
62544
 
              AND   ((pPostUnprinted) OR (cmhead_printed)) ) LOOP
62545
 
 
62546
 
    SELECT postCreditMemo(_r.cmhead_id, pJournalNumber, _itemlocSeries) INTO _itemlocSeries;
62547
 
 
62548
 
  END LOOP;
62549
 
 
62550
 
  RETURN _itemlocSeries;
62551
 
 
62552
 
END;
62553
 
$_$;
62554
 
 
62555
 
 
62556
 
ALTER FUNCTION public.postcreditmemos(boolean, integer) OWNER TO admin;
62557
 
 
62558
 
--
62559
 
--
62560
 
 
62561
 
CREATE FUNCTION postevent(pevnttypename text, pordtype text, pordid integer, pwhsid integer, pnumber text, pnewvalue numeric, poldvalue numeric, pnewdate date, polddate date) RETURNS integer
62562
 
    LANGUAGE plpgsql
62563
 
    AS $$
62564
 
DECLARE
62565
 
  _evnttypeid INTEGER;
62566
 
  _whsid INTEGER;
62567
 
 
62568
 
BEGIN
62569
 
  -- Find event type
62570
 
  SELECT evnttype_id INTO _evnttypeid
62571
 
  FROM evnttype
62572
 
  WHERE (evnttype_name=pEvnttypename);
62573
 
  IF (NOT FOUND) THEN
62574
 
    RAISE EXCEPTION 'Event type % not found.', pEvnttypename;
62575
 
  END IF;
62576
 
 
62577
 
  IF (pWhsid IS NULL) THEN
62578
 
    -- Find user preferred warehouse
62579
 
    SELECT usrpref_value  INTO _whsid
62580
 
    FROM usrpref
62581
 
    WHERE usrpref_username = getEffectiveXtUser()
62582
 
      AND usrpref_name = 'PreferredWarehouse';
62583
 
  ELSE
62584
 
    _whsid := pWhsid;
62585
 
  END IF;
62586
 
 
62587
 
  INSERT INTO evntlog ( evntlog_evnttime, evntlog_evnttype_id,
62588
 
                        evntlog_ordtype, evntlog_ord_id,
62589
 
                        evntlog_warehous_id, evntlog_number,
62590
 
                        evntlog_newvalue, evntlog_oldvalue,
62591
 
                        evntlog_newdate, evntlog_olddate,
62592
 
                        evntlog_username )
62593
 
  SELECT CURRENT_TIMESTAMP, evnttype_id,
62594
 
         pOrdtype, pOrdid,
62595
 
         _whsid, pNumber,
62596
 
         pNewValue, pOldValue,
62597
 
         pNewDate, pOldDate,
62598
 
         evntnot_username
62599
 
  FROM evnttype JOIN evntnot ON ( (evntnot_evnttype_id=evnttype_id) AND
62600
 
                                  (evntnot_warehous_id=_whsid) )
62601
 
  WHERE (evnttype_id=_evnttypeid);
62602
 
 
62603
 
  RETURN 0;
62604
 
 
62605
 
END
62606
 
$$;
62607
 
 
62608
 
 
62609
 
ALTER FUNCTION public.postevent(pevnttypename text, pordtype text, pordid integer, pwhsid integer, pnumber text, pnewvalue numeric, poldvalue numeric, pnewdate date, polddate date) OWNER TO admin;
62610
 
 
62611
 
--
62612
 
--
62613
 
 
62614
 
CREATE FUNCTION postglseries(integer) RETURNS integer
62615
 
    LANGUAGE plpgsql
62616
 
    AS $_$
62617
 
DECLARE
62618
 
  pSequence ALIAS FOR $1;
62619
 
  _journalNumber INTEGER;
62620
 
  _returnValue INTEGER;
62621
 
 
62622
 
BEGIN
62623
 
 
62624
 
  SELECT postGLSeries(pSequence, fetchJournalNumber('G/L')) INTO _returnValue;
62625
 
  RETURN _returnValue;
62626
 
 
62627
 
END;
62628
 
$_$;
62629
 
 
62630
 
 
62631
 
ALTER FUNCTION public.postglseries(integer) OWNER TO admin;
62632
 
 
62633
 
--
62634
 
--
62635
 
 
62636
 
CREATE FUNCTION postglseries(integer, integer) RETURNS integer
62637
 
    LANGUAGE plpgsql
62638
 
    AS $_$
62639
 
DECLARE
62640
 
  pSequence ALIAS FOR $1;
62641
 
  pJournalNumber ALIAS FOR $2;
62642
 
  _returnValue INTEGER;
62643
 
 
62644
 
BEGIN
62645
 
 
62646
 
  SELECT postGLSeries(pSequence, pJournalNumber, true) INTO _returnValue;
62647
 
  RETURN _returnValue;
62648
 
 
62649
 
END;
62650
 
$_$;
62651
 
 
62652
 
 
62653
 
ALTER FUNCTION public.postglseries(integer, integer) OWNER TO admin;
62654
 
 
62655
 
--
62656
 
--
62657
 
 
62658
 
CREATE FUNCTION postglseries(integer, integer, boolean) RETURNS integer
62659
 
    LANGUAGE plpgsql
62660
 
    AS $_$
62661
 
DECLARE
62662
 
  pSequence             ALIAS FOR $1;
62663
 
  pJournalNumber        ALIAS FOR $2;
62664
 
  pPostZero             ALIAS FOR $3;
62665
 
  _glseries RECORD;
62666
 
  _transCount INTEGER := 0;
62667
 
  _delta NUMERIC;
62668
 
  _discrepDate DATE;
62669
 
  _discrepAccntid INTEGER;
62670
 
  _rows INTEGER;
62671
 
BEGIN
62672
 
 
62673
 
/*  Make sure we don't create an imbalance across companies.
62674
 
    The 'IgnoreCompanyBalance' metric is a back door mechanism to
62675
 
    allow legacy users to create transactions accross companies if
62676
 
    they have been using the company segment for something else
62677
 
    and they MUST continue to be able to do so.  It can only be 
62678
 
    implemented by direct sql update to the metric table and should 
62679
 
    otherwise be discouraged.
62680
 
*/ 
62681
 
  IF (COALESCE(fetchMetricValue('GLCompanySize'),0) > 0 
62682
 
    AND fetchMetricBool('IgnoreCompany') = false)  THEN
62683
 
 
62684
 
    SELECT count(accnt_company) INTO _rows
62685
 
    FROM (
62686
 
      SELECT DISTINCT accnt_company
62687
 
      FROM accnt 
62688
 
        JOIN glseries ON (glseries_accnt_id=accnt_id)
62689
 
      WHERE (glseries_sequence=pSequence)) _data;
62690
 
    
62691
 
    IF (_rows > 1) THEN
62692
 
      RAISE EXCEPTION 'G/L Series can not be posted because multiple companies are referenced in the same series.';
62693
 
    END IF;
62694
 
  END IF;
62695
 
  
62696
 
  SELECT SUM(glseries_amount), MAX(glseries_distdate) INTO _delta, _discrepDate
62697
 
    FROM glseries
62698
 
   WHERE (glseries_sequence=pSequence);
62699
 
  IF ( _delta <> 0 ) THEN
62700
 
    IF (COALESCE(fetchMetricValue('GLCompanySize'),0) = 0) THEN
62701
 
      SELECT accnt_id INTO _discrepAccntid
62702
 
        FROM accnt, metric
62703
 
       WHERE ((metric_name='GLSeriesDiscrepancyAccount')
62704
 
         AND  (accnt_id=CAST(metric_value AS INTEGER)));
62705
 
    ELSE
62706
 
       SELECT company_dscrp_accnt_id INTO _discrepAccntid
62707
 
        FROM company
62708
 
          JOIN accnt ON (accnt_company=company_number) 
62709
 
          JOIN glseries ON (glseries_accnt_id=accnt_id)
62710
 
       WHERE (glseries_sequence=pSequence)
62711
 
       LIMIT 1;
62712
 
    END IF;
62713
 
 
62714
 
    IF (NOT FOUND) THEN
62715
 
      RETURN -5;
62716
 
    END IF;
62717
 
    
62718
 
    INSERT INTO glseries
62719
 
           ( glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber,
62720
 
             glseries_accnt_id, glseries_amount, glseries_distdate, glseries_notes )
62721
 
    SELECT glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber,
62722
 
             _discrepAccntid, (_delta * -1), _discrepDate, 'G/L Series Discrepancy'
62723
 
      FROM glseries
62724
 
     WHERE (glseries_sequence=pSequence)
62725
 
     LIMIT 1;
62726
 
  END IF;
62727
 
 
62728
 
  FOR _glseries IN SELECT glseries_source, glseries_doctype, glseries_docnumber,
62729
 
                          glseries_accnt_id, glseries_distdate, glseries_notes,
62730
 
                          glseries_misc_id,
62731
 
                          SUM(glseries_amount) as amount
62732
 
                     FROM glseries
62733
 
                    WHERE ((glseries_amount<>0.0)
62734
 
                      AND  (glseries_sequence=pSequence))
62735
 
                    GROUP BY glseries_source, glseries_doctype, glseries_docnumber,
62736
 
                             glseries_accnt_id, glseries_distdate, glseries_notes,
62737
 
                             glseries_misc_id LOOP
62738
 
 
62739
 
    IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE))
62740
 
        FROM accnt LEFT OUTER JOIN
62741
 
             period ON (_glseries.glseries_distdate BETWEEN period_start AND period_end)
62742
 
        WHERE (accnt_id = _glseries.glseries_accnt_id)) THEN
62743
 
      RAISE EXCEPTION 'Cannot post to closed period (%).', _glseries.glseries_distdate;
62744
 
      RETURN -4;        -- remove raise exception when all callers check return code
62745
 
    END IF;
62746
 
 
62747
 
    IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND
62748
 
               BOOL_AND(COALESCE(period_freeze, FALSE))
62749
 
        FROM accnt LEFT OUTER JOIN
62750
 
             period ON (_glseries.glseries_distdate BETWEEN period_start AND period_end)
62751
 
        WHERE (accnt_id = _glseries.glseries_accnt_id)) THEN
62752
 
      RAISE EXCEPTION 'Cannot post to frozen period (%).', _glseries.glseries_distdate;
62753
 
      RETURN -4;        -- remove raise exception when all callers check return code
62754
 
    END IF;
62755
 
 
62756
 
    IF NOT EXISTS(SELECT period_id
62757
 
                  FROM period
62758
 
                  WHERE (_glseries.glseries_distdate BETWEEN period_start AND period_end)) THEN
62759
 
      RAISE EXCEPTION 'Cannot post to nonexistent period (%).', pDistDate;
62760
 
    END IF;
62761
 
 
62762
 
    IF (_glseries.amount != 0 OR pPostZero) THEN
62763
 
      IF (fetchMetricBool('UseJournals')) THEN
62764
 
       INSERT INTO sltrans
62765
 
        ( sltrans_posted, sltrans_created, sltrans_date, sltrans_misc_id,
62766
 
          sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_notes,
62767
 
          sltrans_doctype, sltrans_docnumber, sltrans_amount, sltrans_journalnumber )
62768
 
        VALUES
62769
 
        ( FALSE, CURRENT_TIMESTAMP, _glseries.glseries_distdate, _glseries.glseries_misc_id,
62770
 
          pSequence, _glseries.glseries_accnt_id, _glseries.glseries_source, _glseries.glseries_notes,
62771
 
          _glseries.glseries_doctype, _glseries.glseries_docnumber, _glseries.amount, pJournalNumber );      
62772
 
      ELSE
62773
 
       INSERT INTO gltrans
62774
 
        ( gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_misc_id,
62775
 
          gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_notes,
62776
 
          gltrans_doctype, gltrans_docnumber, gltrans_amount, gltrans_journalnumber )
62777
 
        VALUES
62778
 
        ( FALSE, FALSE, CURRENT_TIMESTAMP, _glseries.glseries_distdate, _glseries.glseries_misc_id,
62779
 
          pSequence, _glseries.glseries_accnt_id, _glseries.glseries_source, _glseries.glseries_notes,
62780
 
          _glseries.glseries_doctype, _glseries.glseries_docnumber, _glseries.amount, pJournalNumber );
62781
 
      END IF;
62782
 
      
62783
 
      _transCount := _transCount + 1;
62784
 
    END IF;
62785
 
  END LOOP;
62786
 
 
62787
 
  DELETE FROM glseries
62788
 
  WHERE (glseries_sequence=pSequence);
62789
 
 
62790
 
  PERFORM postIntoTrialBalance(pSequence);
62791
 
 
62792
 
  RETURN _transCount;
62793
 
 
62794
 
END;
62795
 
$_$;
62796
 
 
62797
 
 
62798
 
ALTER FUNCTION public.postglseries(integer, integer, boolean) OWNER TO admin;
62799
 
 
62800
 
--
62801
 
--
62802
 
 
62803
 
CREATE FUNCTION postglseriesnosumm(integer) RETURNS integer
62804
 
    LANGUAGE plpgsql
62805
 
    AS $_$
62806
 
DECLARE
62807
 
  pSequence ALIAS FOR $1;
62808
 
  _journalNumber INTEGER;
62809
 
  _returnValue INTEGER;
62810
 
 
62811
 
BEGIN
62812
 
 
62813
 
  SELECT postGLSeriesNoSumm(pSequence, fetchJournalNumber('G/L')) INTO _returnValue;
62814
 
  RETURN _returnValue;
62815
 
 
62816
 
END;
62817
 
$_$;
62818
 
 
62819
 
 
62820
 
ALTER FUNCTION public.postglseriesnosumm(integer) OWNER TO admin;
62821
 
 
62822
 
--
62823
 
--
62824
 
 
62825
 
CREATE FUNCTION postglseriesnosumm(integer, integer) RETURNS integer
62826
 
    LANGUAGE plpgsql
62827
 
    AS $_$
62828
 
DECLARE
62829
 
  pSequence ALIAS FOR $1;
62830
 
  pJournalNumber ALIAS FOR $2;
62831
 
  _glseries RECORD;
62832
 
  _transCount INTEGER := 0;
62833
 
  _rows INTEGER;
62834
 
 
62835
 
BEGIN
62836
 
 
62837
 
/*  Make sure we don't create an imbalance across companies.
62838
 
    The 'IgnoreCompanyBalance' metric is a back door mechanism to
62839
 
    allow legacy users to create transactions accross companies if
62840
 
    they have been using the company segment for something else
62841
 
    and they MUST continue to be able to do so.  It can only be 
62842
 
    implemented by direct sql update to the metric table and should 
62843
 
    otherwise be discouraged.
62844
 
*/  
62845
 
  IF (COALESCE(fetchMetricValue('GLCompanySize'),0) > 0 
62846
 
    AND fetchMetricBool('IgnoreCompany') = false)  THEN
62847
 
 
62848
 
    SELECT count(accnt_company) INTO _rows
62849
 
    FROM (
62850
 
      SELECT DISTINCT accnt_company
62851
 
      FROM accnt 
62852
 
        JOIN glseries ON (glseries_accnt_id=accnt_id)
62853
 
      WHERE (glseries_sequence=pSequence)) _data;
62854
 
    
62855
 
    IF (_rows > 1) THEN
62856
 
      RAISE EXCEPTION 'G/L Series can not be posted because multiple companies are referenced in the same series.';
62857
 
    END IF;
62858
 
  END IF;
62859
 
  
62860
 
  IF ( ( SELECT SUM(glseries_amount)
62861
 
         FROM glseries
62862
 
         WHERE (glseries_sequence=pSequence) ) <> 0 ) THEN
62863
 
    RETURN -1;
62864
 
  END IF;
62865
 
 
62866
 
  FOR _glseries IN SELECT glseries_source, glseries_doctype, glseries_docnumber,
62867
 
                          glseries_accnt_id, glseries_distdate, glseries_notes,
62868
 
                          glseries_misc_id, glseries_amount as amount
62869
 
                     FROM glseries
62870
 
                    WHERE ((glseries_amount<>0.0)
62871
 
                      AND  (glseries_sequence=pSequence)) LOOP
62872
 
 
62873
 
    IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE))
62874
 
        FROM accnt LEFT OUTER JOIN
62875
 
             period ON (_glseries.glseries_distdate BETWEEN period_start AND period_end)
62876
 
        WHERE (accnt_id = _glseries.glseries_accnt_id)) THEN
62877
 
      RAISE EXCEPTION 'Cannot post to closed period (%).', _glseries.glseries_distdate;
62878
 
      RETURN -4;        -- remove raise exception when all callers check return code
62879
 
    END IF;
62880
 
 
62881
 
    IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND
62882
 
               BOOL_AND(COALESCE(period_freeze, FALSE))
62883
 
        FROM accnt LEFT OUTER JOIN
62884
 
             period ON (_glseries.glseries_distdate BETWEEN period_start AND period_end)
62885
 
        WHERE (accnt_id = _glseries.glseries_accnt_id)) THEN
62886
 
      RAISE EXCEPTION 'Cannot post to frozen period (%).', _glseries.glseries_distdate;
62887
 
      RETURN -4;        -- remove raise exception when all callers check return code
62888
 
    END IF;
62889
 
 
62890
 
    IF NOT EXISTS(SELECT period_id
62891
 
                  FROM period
62892
 
                  WHERE (_glseries.glseries_distdate BETWEEN period_start AND period_end)) THEN
62893
 
      RAISE EXCEPTION 'Cannot post to nonexistent period (%).', pDistDate;
62894
 
    END IF;
62895
 
 
62896
 
    IF (fetchMetricBool('UseJournals')) THEN
62897
 
      INSERT INTO sltrans
62898
 
      ( sltrans_posted, sltrans_created, sltrans_date, sltrans_misc_id,
62899
 
        sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_notes,
62900
 
        sltrans_doctype, sltrans_docnumber, sltrans_amount, sltrans_journalnumber )
62901
 
      VALUES
62902
 
      ( FALSE, CURRENT_TIMESTAMP, _glseries.glseries_distdate, _glseries.glseries_misc_id,
62903
 
        pSequence, _glseries.glseries_accnt_id, _glseries.glseries_source, _glseries.glseries_notes,
62904
 
        _glseries.glseries_doctype, _glseries.glseries_docnumber, _glseries.amount, pJournalNumber );
62905
 
    ELSE
62906
 
      INSERT INTO gltrans
62907
 
      ( gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_misc_id,
62908
 
        gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_notes,
62909
 
        gltrans_doctype, gltrans_docnumber, gltrans_amount, gltrans_journalnumber )
62910
 
      VALUES
62911
 
      ( FALSE, FALSE, CURRENT_TIMESTAMP, _glseries.glseries_distdate, _glseries.glseries_misc_id,
62912
 
        pSequence, _glseries.glseries_accnt_id, _glseries.glseries_source, _glseries.glseries_notes,
62913
 
        _glseries.glseries_doctype, _glseries.glseries_docnumber, _glseries.amount, pJournalNumber );
62914
 
    END IF;
62915
 
 
62916
 
    _transCount := _transCount + 1;
62917
 
 
62918
 
  END LOOP;
62919
 
 
62920
 
  DELETE FROM glseries
62921
 
  WHERE (glseries_sequence=pSequence);
62922
 
 
62923
 
  PERFORM postIntoTrialBalance(pSequence);
62924
 
 
62925
 
  RETURN _transCount;
62926
 
 
62927
 
END;
62928
 
$_$;
62929
 
 
62930
 
 
62931
 
ALTER FUNCTION public.postglseriesnosumm(integer, integer) OWNER TO admin;
62932
 
 
62933
 
--
62934
 
--
62935
 
 
62936
 
CREATE FUNCTION postintoinvbalance(integer) RETURNS boolean
62937
 
    LANGUAGE plpgsql
62938
 
    AS $_$
62939
 
DECLARE
62940
 
  pInvhistId ALIAS FOR $1;
62941
 
  _invbalid INTEGER;
62942
 
  _r RECORD;
62943
 
  _count INTEGER;
62944
 
  _qty NUMERIC;
62945
 
 
62946
 
BEGIN
62947
 
 
62948
 
  SELECT invhist.*,
62949
 
         CASE WHEN (invhist_transtype='TS' AND invhist_invqty < 0.0 AND warehous_transit) THEN 1
62950
 
              ELSE invhistSense(invhist_id)
62951
 
         END AS sense,
62952
 
         period_id INTO _r
62953
 
  FROM invhist
62954
 
    JOIN itemsite ON (itemsite_id=invhist_itemsite_id)
62955
 
    JOIN whsinfo ON (warehous_id=itemsite_warehous_id)
62956
 
    LEFT OUTER JOIN period ON (invhist_transdate::date BETWEEN period_start AND period_end)
62957
 
  WHERE ( invhist_id=pInvhistId );
62958
 
 
62959
 
  GET DIAGNOSTICS _count = ROW_COUNT;
62960
 
 
62961
 
  IF ( _count > 0 ) THEN
62962
 
 
62963
 
    IF (_r.period_id IS NULL) THEN
62964
 
      RAISE EXCEPTION 'No accounting period exists for invhist_id %, transaction date %.  Transaction can not be posted.', _r.invhist_id, formatDate(_r.invhist_transdate);
62965
 
    END IF;
62966
 
 
62967
 
 
62968
 
    SELECT 
62969
 
      invbal_id, 
62970
 
      _r.invhist_invqty
62971
 
      INTO _invbalid, _qty
62972
 
    FROM invbal
62973
 
    WHERE ( (invbal_period_id=_r.period_id)
62974
 
      AND (invbal_itemsite_id=_r.invhist_itemsite_id) );
62975
 
 
62976
 
    GET DIAGNOSTICS _count = ROW_COUNT;
62977
 
    IF (_count > 0) THEN
62978
 
 
62979
 
    IF (_r.sense * _qty > 0) THEN
62980
 
      UPDATE invbal SET 
62981
 
        invbal_qty_in = (invbal_qty_in + abs(_qty)),
62982
 
        invbal_value_in = (invbal_value_in + abs(_qty) * _r.invhist_unitcost)
62983
 
      WHERE (invbal_id=_invbalid);
62984
 
    ELSIF (_r.sense * _qty < 0) THEN
62985
 
      UPDATE invbal SET 
62986
 
        invbal_qty_out = (invbal_qty_out + abs(_qty)),
62987
 
        invbal_value_out = (invbal_value_out + abs(_qty) *  _r.invhist_unitcost)
62988
 
      WHERE (invbal_id=_invbalid);
62989
 
    END IF;
62990
 
 
62991
 
    -- Non-netable transactions have their own balances
62992
 
    IF (_r.invhist_transtype = 'NN') THEN
62993
 
      UPDATE invbal SET 
62994
 
        invbal_nn_in = (invbal_nn_in + _qty * -1),
62995
 
        invbal_nnval_in = (invbal_nnval_in + _qty * -1 * _r.invhist_unitcost)
62996
 
      WHERE (invbal_id=_invbalid);
62997
 
    END IF;
62998
 
 
62999
 
    UPDATE invbal SET 
63000
 
      invbal_qoh_ending = (invbal_qoh_beginning + invbal_qty_in - invbal_qty_out),
63001
 
      invbal_value_ending = (invbal_value_beginning + invbal_value_in - invbal_value_out),
63002
 
      invbal_nn_ending = (invbal_nn_beginning + invbal_nn_in - invbal_nn_out),
63003
 
      invbal_nnval_ending = (invbal_nnval_beginning + invbal_nnval_in - invbal_nnval_out),
63004
 
      invbal_dirty=true
63005
 
    WHERE (invbal_id=_invbalid);
63006
 
  ELSE
63007
 
 
63008
 
    SELECT NEXTVAL('invbal_invbal_id_seq') INTO _invbalid;
63009
 
      INSERT INTO invbal
63010
 
        ( invbal_id, invbal_itemsite_id, invbal_period_id,
63011
 
          invbal_qoh_beginning,
63012
 
          invbal_qoh_ending,
63013
 
          invbal_qty_in,
63014
 
          invbal_qty_out,
63015
 
          invbal_value_beginning,
63016
 
          invbal_value_ending,
63017
 
          invbal_value_in,
63018
 
          invbal_value_out,
63019
 
          invbal_nn_beginning,
63020
 
          invbal_nn_ending,
63021
 
          invbal_nn_in,
63022
 
          invbal_nn_out,
63023
 
          invbal_nnval_beginning,
63024
 
          invbal_nnval_ending,
63025
 
          invbal_nnval_in,
63026
 
          invbal_nnval_out,
63027
 
          invbal_dirty )
63028
 
      VALUES
63029
 
        ( _invbalid, _r.invhist_itemsite_id, _r.period_id,
63030
 
         -- Netable
63031
 
          0, 
63032
 
          _r.invhist_invqty * _r.sense,
63033
 
          CASE WHEN (_r.sense > 0) THEN _r.invhist_invqty
63034
 
               ELSE 0
63035
 
          END,
63036
 
          CASE WHEN (_r.sense < 0) THEN (_r.invhist_invqty)
63037
 
               ELSE 0
63038
 
          END,
63039
 
          0,
63040
 
          _r.invhist_invqty * _r.invhist_unitcost * _r.sense,
63041
 
          CASE WHEN (_r.sense > 0) THEN _r.invhist_invqty * _r.invhist_unitcost
63042
 
               ELSE 0
63043
 
          END,
63044
 
          CASE WHEN (_r.sense < 0) THEN (_r.invhist_invqty  * _r.invhist_unitcost)
63045
 
               ELSE 0
63046
 
          END,
63047
 
          -- Non netable
63048
 
          0, 
63049
 
          CASE WHEN (_r.invhist_transtype='NN') THEN _r.invhist_invqty * -1
63050
 
               ELSE 0
63051
 
          END,
63052
 
          CASE WHEN (_r.sense > 0 AND _r.invhist_transtype='NN') THEN _r.invhist_invqty * -1
63053
 
               ELSE 0
63054
 
          END,
63055
 
          CASE WHEN (_r.sense < 0 AND _r.invhist_transtype='NN') THEN _r.invhist_invqty * -1
63056
 
               ELSE 0
63057
 
          END,
63058
 
          0,
63059
 
          CASE WHEN (_r.invhist_transtype='NN') THEN _r.invhist_invqty * _r.invhist_unitcost * -1
63060
 
               ELSE 0
63061
 
          END,
63062
 
          CASE WHEN (_r.sense > 0 AND _r.invhist_transtype='NN') THEN _r.invhist_invqty * -1 * _r.invhist_unitcost
63063
 
               ELSE 0
63064
 
          END,
63065
 
          CASE WHEN (_r.sense < 0 AND _r.invhist_transtype='NN') THEN (_r.invhist_invqty  * -1 * _r.invhist_unitcost)
63066
 
               ELSE 0
63067
 
          END,
63068
 
          true );
63069
 
    END IF;
63070
 
  ELSE
63071
 
    RETURN FALSE;
63072
 
  END IF;
63073
 
 
63074
 
  RETURN TRUE;
63075
 
 
63076
 
END;
63077
 
$_$;
63078
 
 
63079
 
 
63080
 
ALTER FUNCTION public.postintoinvbalance(integer) OWNER TO admin;
63081
 
 
63082
 
--
63083
 
--
63084
 
 
63085
 
CREATE FUNCTION postintotrialbalance(integer) RETURNS integer
63086
 
    LANGUAGE plpgsql
63087
 
    AS $_$
63088
 
DECLARE
63089
 
  pSequence ALIAS FOR $1;
63090
 
  _trialbalid INTEGER;
63091
 
  _r RECORD;
63092
 
 
63093
 
BEGIN
63094
 
 
63095
 
  FOR _r IN SELECT gltrans_id, gltrans_date, gltrans_accnt_id, gltrans_amount,
63096
 
                   accnt_forwardupdate, period_id, period_closed, period_freeze
63097
 
            FROM accnt, gltrans LEFT OUTER JOIN period ON (gltrans_date BETWEEN period_start AND period_end)
63098
 
            WHERE ( (gltrans_accnt_id=accnt_id)
63099
 
             AND (NOT gltrans_posted)
63100
 
             AND (NOT gltrans_deleted)
63101
 
             AND (gltrans_sequence=pSequence) ) LOOP
63102
 
 
63103
 
    IF ( (NOT _r.period_closed) AND ( (NOT _r.period_freeze) OR (checkPrivilege('PostFrozenPeriod')) ) ) THEN
63104
 
 
63105
 
      SELECT trialbal_id INTO _trialbalid
63106
 
      FROM trialbal
63107
 
      WHERE ( (trialbal_period_id=_r.period_id)
63108
 
       AND (trialbal_accnt_id=_r.gltrans_accnt_id) );
63109
 
      IF (FOUND) THEN
63110
 
 
63111
 
        IF (_r.gltrans_amount > 0) THEN
63112
 
          UPDATE trialbal
63113
 
          SET trialbal_credits = (trialbal_credits + _r.gltrans_amount)
63114
 
          WHERE (trialbal_id=_trialbalid);
63115
 
        ELSE
63116
 
          UPDATE trialbal
63117
 
          SET trialbal_debits = (trialbal_debits + (_r.gltrans_amount * -1))
63118
 
          WHERE (trialbal_id=_trialbalid);
63119
 
        END IF;
63120
 
 
63121
 
        UPDATE trialbal
63122
 
        SET trialbal_ending = (trialbal_beginning - trialbal_debits + trialbal_credits),
63123
 
            trialbal_dirty=TRUE
63124
 
        WHERE (trialbal_id=_trialbalid);
63125
 
      ELSE
63126
 
 
63127
 
        SELECT NEXTVAL('trialbal_trialbal_id_seq') INTO _trialbalid;
63128
 
        INSERT INTO trialbal
63129
 
        ( trialbal_id, trialbal_accnt_id, trialbal_period_id,
63130
 
          trialbal_beginning, trialbal_dirty,
63131
 
          trialbal_ending,
63132
 
          trialbal_credits,
63133
 
          trialbal_debits )
63134
 
        VALUES
63135
 
        ( _trialbalid, _r.gltrans_accnt_id, _r.period_id,
63136
 
          0, TRUE,
63137
 
          _r.gltrans_amount,
63138
 
          CASE WHEN (_r.gltrans_amount > 0) THEN _r.gltrans_amount
63139
 
               ELSE 0
63140
 
          END,
63141
 
          CASE WHEN (_r.gltrans_amount < 0) THEN (_r.gltrans_amount * -1)
63142
 
               ELSE 0
63143
 
          END );
63144
 
      END IF;
63145
 
 
63146
 
      IF (_r.accnt_forwardupdate AND fetchmetricbool('ManualForwardUpdate')) THEN
63147
 
        PERFORM forwardUpdateTrialBalance(_trialbalid);
63148
 
      END IF;
63149
 
 
63150
 
      UPDATE gltrans
63151
 
      SET gltrans_posted=TRUE
63152
 
      WHERE (gltrans_id=_r.gltrans_id);
63153
 
 
63154
 
    END IF;
63155
 
 
63156
 
  END LOOP;
63157
 
 
63158
 
  RETURN 1;
63159
 
 
63160
 
END;
63161
 
$_$;
63162
 
 
63163
 
 
63164
 
ALTER FUNCTION public.postintotrialbalance(integer) OWNER TO admin;
63165
 
 
63166
 
--
63167
 
--
63168
 
 
63169
 
CREATE FUNCTION postinvhist(integer) RETURNS boolean
63170
 
    LANGUAGE plpgsql
63171
 
    AS $_$
63172
 
DECLARE
63173
 
  pInvhistId ALIAS FOR $1;
63174
 
  _r RECORD;
63175
 
BEGIN
63176
 
 
63177
 
    IF ( SELECT metric_value
63178
 
        FROM metric
63179
 
        WHERE ((metric_name = 'EnableAsOfQOH')
63180
 
        AND (metric_value = 't'))) THEN
63181
 
      IF (NOT postIntoInvBalance(pInvhistId)) THEN
63182
 
        RAISE EXCEPTION 'Post into Inventory Balance for invhist_id=% was unsuccessful',pInvhistId;
63183
 
      END IF;
63184
 
    END IF;
63185
 
 
63186
 
    --Update itemsite qoh and change posted flag
63187
 
    UPDATE itemsite SET 
63188
 
      itemsite_qtyonhand = (itemsite_qtyonhand + (invhist_invqty * invhistSense(invhist_id))),
63189
 
      itemsite_value = itemsite_value + invhist_value_after - invhist_value_before
63190
 
    FROM invhist
63191
 
    WHERE ( (itemsite_id=invhist_itemsite_id)
63192
 
    AND (invhist_id=pInvhistId)
63193
 
    AND (NOT invhist_posted) );
63194
 
 
63195
 
    --Flag as posted
63196
 
    UPDATE invhist SET
63197
 
      invhist_posted=TRUE
63198
 
    WHERE ( (invhist_id=pInvhistId)
63199
 
    AND (invhist_posted=FALSE) );
63200
 
 
63201
 
RETURN TRUE;
63202
 
 
63203
 
END;
63204
 
$_$;
63205
 
 
63206
 
 
63207
 
ALTER FUNCTION public.postinvhist(integer) OWNER TO admin;
63208
 
 
63209
 
--
63210
 
--
63211
 
 
63212
 
CREATE FUNCTION postinvoice(integer) RETURNS integer
63213
 
    LANGUAGE plpgsql
63214
 
    AS $_$
63215
 
DECLARE
63216
 
  pInvcheadid ALIAS FOR $1;
63217
 
  _return INTEGER;
63218
 
 
63219
 
BEGIN
63220
 
 
63221
 
  SELECT postInvoice(pInvcheadid, fetchJournalNumber('AR-IN')) INTO _return;
63222
 
 
63223
 
  RETURN _return;
63224
 
 
63225
 
END;
63226
 
$_$;
63227
 
 
63228
 
 
63229
 
ALTER FUNCTION public.postinvoice(integer) OWNER TO admin;
63230
 
 
63231
 
--
63232
 
--
63233
 
 
63234
 
CREATE FUNCTION postinvoice(integer, integer) RETURNS integer
63235
 
    LANGUAGE plpgsql
63236
 
    AS $_$
63237
 
DECLARE
63238
 
  pInvcheadid ALIAS FOR $1;
63239
 
  pJournalNumber ALIAS FOR $2;
63240
 
  _itemlocSeries INTEGER;
63241
 
  _return INTEGER;
63242
 
 
63243
 
BEGIN
63244
 
 
63245
 
  SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
63246
 
  SELECT postInvoice(pInvcheadid, pJournalNumber, _itemlocseries) INTO _return;
63247
 
 
63248
 
  RETURN _return;
63249
 
 
63250
 
END;
63251
 
$_$;
63252
 
 
63253
 
 
63254
 
ALTER FUNCTION public.postinvoice(integer, integer) OWNER TO admin;
63255
 
 
63256
 
--
63257
 
--
63258
 
 
63259
 
CREATE FUNCTION postinvoice(integer, integer, integer) RETURNS integer
63260
 
    LANGUAGE plpgsql
63261
 
    AS $_$
63262
 
DECLARE
63263
 
  pInvcheadid ALIAS FOR $1;
63264
 
  pJournalNumber ALIAS FOR $2;
63265
 
  pItemlocSeries ALIAS FOR $3;
63266
 
  _aropenid INTEGER;
63267
 
  _cohistid INTEGER;
63268
 
  _itemlocSeries INTEGER := 0;
63269
 
  _invhistid INTEGER := 0;
63270
 
  _amount NUMERIC;
63271
 
  _roundedBase NUMERIC;
63272
 
  _sequence INTEGER;
63273
 
  _r RECORD;
63274
 
  _p RECORD;
63275
 
  _test INTEGER;
63276
 
  _totalAmount          NUMERIC := 0;
63277
 
  _totalRoundedBase     NUMERIC := 0;
63278
 
  _totalAmountBase      NUMERIC := 0;
63279
 
  _appliedAmount        NUMERIC := 0;
63280
 
  _commissionDue        NUMERIC := 0;
63281
 
  _tmpAccntId INTEGER;
63282
 
  _tmpCurrId  INTEGER;
63283
 
  _firstExchDate        DATE;
63284
 
  _glDate               DATE;
63285
 
  _exchGain             NUMERIC := 0;
63286
 
 
63287
 
BEGIN
63288
 
 
63289
 
  IF ( ( SELECT invchead_posted
63290
 
         FROM invchead
63291
 
         WHERE (invchead_id=pInvcheadid) ) ) THEN
63292
 
    RETURN -10;
63293
 
  END IF;
63294
 
 
63295
 
  SELECT invchead.*, fetchGLSequence() AS sequence,
63296
 
         findFreightAccount(invchead_cust_id) AS freightaccntid,
63297
 
         findARAccount(invchead_cust_id) AS araccntid,
63298
 
         ( SELECT COALESCE(SUM(taxhist_tax), 0)
63299
 
           FROM invcheadtax
63300
 
           WHERE ( (taxhist_parent_id = invchead_id)
63301
 
             AND   (taxhist_taxtype_id = getFreightTaxtypeId()) ) ) AS freighttax,
63302
 
         ( SELECT COALESCE(SUM(taxhist_tax), 0)
63303
 
           FROM invcheadtax
63304
 
           WHERE ( (taxhist_parent_id = invchead_id)
63305
 
             AND   (taxhist_taxtype_id = getAdjustmentTaxtypeId()) ) ) AS adjtax
63306
 
       INTO _p 
63307
 
  FROM invchead
63308
 
  WHERE (invchead_id=pInvcheadid);
63309
 
 
63310
 
  _itemlocSeries = pItemlocSeries;
63311
 
 
63312
 
  _glDate := COALESCE(_p.invchead_gldistdate, _p.invchead_invcdate);
63313
 
 
63314
 
  IF (_p.invchead_salesrep_id < 0) THEN
63315
 
    RAISE NOTICE 'Patch negative invchead_salesrep_id until invchead_salesrep_id is a true fkey';
63316
 
    _p.invchead_salesrep_id := NULL;
63317
 
  END IF;
63318
 
 
63319
 
  IF TRUE THEN
63320
 
      _firstExchDate := _p.invchead_invcdate;
63321
 
  ELSE
63322
 
      SELECT cohead_orderdate INTO _firstExchDate
63323
 
      FROM cohead JOIN invchead ON (cohead_number = invchead_ordernumber)
63324
 
      WHERE (invchead_id = pInvcheadid);
63325
 
  END IF;
63326
 
 
63327
 
  FOR _r IN SELECT tax_sales_accnt_id, 
63328
 
              round(sum(taxdetail_tax),2) AS tax,
63329
 
              currToBase(_p.invchead_curr_id, round(sum(taxdetail_tax),2), _firstExchDate) AS taxbasevalue
63330
 
            FROM tax 
63331
 
             JOIN calculateTaxDetailSummary('I', pInvcheadid, 'T') ON (taxdetail_tax_id=tax_id)
63332
 
            GROUP BY tax_id, tax_sales_accnt_id LOOP
63333
 
 
63334
 
    PERFORM insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber,
63335
 
                                _r.tax_sales_accnt_id, 
63336
 
                                _r.taxbasevalue,
63337
 
                                _glDate, _p.invchead_billto_name );
63338
 
 
63339
 
    _totalAmount := _totalAmount + _r.tax;
63340
 
    _totalRoundedBase := _totalRoundedBase + _r.taxbasevalue;  
63341
 
  END LOOP;
63342
 
 
63343
 
    UPDATE invcitemtax SET 
63344
 
      taxhist_docdate=_firstExchDate,
63345
 
      taxhist_distdate=_glDate,
63346
 
      taxhist_curr_id=_p.invchead_curr_id,
63347
 
      taxhist_curr_rate=curr_rate,
63348
 
      taxhist_journalnumber=pJournalNumber
63349
 
    FROM invchead
63350
 
     JOIN invcitem ON (invchead_id=invcitem_invchead_id), 
63351
 
     curr_rate
63352
 
    WHERE ((invchead_id=pInvcheadId)
63353
 
      AND (taxhist_parent_id=invcitem_id)
63354
 
      AND (_p.invchead_curr_id=curr_id)
63355
 
      AND ( _firstExchDate BETWEEN curr_effective 
63356
 
                           AND curr_expires) );
63357
 
 
63358
 
    UPDATE invcheadtax SET 
63359
 
      taxhist_docdate=_firstExchDate,
63360
 
      taxhist_distdate=_glDate,
63361
 
      taxhist_curr_id=_p.invchead_curr_id,
63362
 
      taxhist_curr_rate=curr_rate,
63363
 
      taxhist_journalnumber=pJournalNumber
63364
 
    FROM curr_rate
63365
 
    WHERE ((taxhist_parent_id=pInvcheadid)
63366
 
      AND (_p.invchead_curr_id=curr_id)
63367
 
      AND ( _firstExchDate BETWEEN curr_effective 
63368
 
                           AND curr_expires) );
63369
 
 
63370
 
  FOR _r IN SELECT *
63371
 
            FROM invoiceitem
63372
 
            WHERE ( (invcitem_invchead_id = pInvcheadid)
63373
 
              AND   (invcitem_item_id <> -1) ) LOOP
63374
 
 
63375
 
    _amount := _r.extprice;
63376
 
 
63377
 
    IF (_amount > 0) THEN
63378
 
      IF (_r.invcitem_rev_accnt_id IS NOT NULL) THEN
63379
 
        SELECT getPrjAccntId(_p.invchead_prj_id, _r.invcitem_rev_accnt_id)
63380
 
        INTO _tmpAccntId;
63381
 
      ELSEIF (_r.itemsite_id IS NULL) THEN
63382
 
        SELECT getPrjAccntId(_p.invchead_prj_id, salesaccnt_sales_accnt_id) 
63383
 
        INTO _tmpAccntId
63384
 
        FROM salesaccnt
63385
 
        WHERE (salesaccnt_id=findSalesAccnt(_r.invcitem_item_id, 'I', _p.invchead_cust_id,
63386
 
                                            _p.invchead_saletype_id, _p.invchead_shipzone_id));
63387
 
      ELSE
63388
 
        SELECT getPrjAccntId(_p.invchead_prj_id, salesaccnt_sales_accnt_id) 
63389
 
        INTO _tmpAccntId
63390
 
        FROM salesaccnt
63391
 
        WHERE (salesaccnt_id=findSalesAccnt(_r.itemsite_id, 'IS', _p.invchead_cust_id,
63392
 
                                            _p.invchead_saletype_id, _p.invchead_shipzone_id));
63393
 
      END IF;
63394
 
 
63395
 
      IF (NOT FOUND) THEN
63396
 
        PERFORM deleteGLSeries(_p.sequence);
63397
 
        DELETE FROM cohist
63398
 
         WHERE ((cohist_sequence=_p.sequence)
63399
 
           AND  (cohist_invcnumber=_p.invchead_invcnumber));
63400
 
        RETURN -11;
63401
 
      END IF;
63402
 
 
63403
 
      _roundedBase := round(currToBase(_p.invchead_curr_id, _amount, _firstExchDate), 2);
63404
 
      SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN',
63405
 
                                 _p.invchead_invcnumber, _tmpAccntId,
63406
 
                                 _roundedBase, _glDate, _p.invchead_billto_name ) INTO _test;
63407
 
 
63408
 
      _totalAmount := (_totalAmount + _amount);
63409
 
      _totalRoundedBase := _totalRoundedBase + _roundedBase;
63410
 
      _commissionDue := (_commissionDue + (_amount * _p.invchead_commission));
63411
 
    END IF;
63412
 
 
63413
 
    _totalAmount := _totalAmount;
63414
 
    _totalRoundedBase := _totalRoundedBase;
63415
 
 
63416
 
    SELECT nextval('cohist_cohist_id_seq') INTO _cohistid;
63417
 
    INSERT INTO cohist
63418
 
    ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id,
63419
 
      cohist_shipdate, cohist_shipvia,
63420
 
      cohist_ordernumber, cohist_ponumber, cohist_orderdate,
63421
 
      cohist_doctype, cohist_invcnumber, cohist_invcdate,
63422
 
      cohist_qtyshipped, cohist_unitprice, cohist_unitcost,
63423
 
      cohist_salesrep_id, cohist_commission, cohist_commissionpaid,
63424
 
      cohist_billtoname, cohist_billtoaddress1,
63425
 
      cohist_billtoaddress2, cohist_billtoaddress3,
63426
 
      cohist_billtocity, cohist_billtostate, cohist_billtozip,
63427
 
      cohist_shiptoname, cohist_shiptoaddress1,
63428
 
      cohist_shiptoaddress2, cohist_shiptoaddress3,
63429
 
      cohist_shiptocity, cohist_shiptostate, cohist_shiptozip,
63430
 
      cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id,
63431
 
      cohist_shipzone_id, cohist_saletype_id )
63432
 
    VALUES
63433
 
    ( _cohistid, _p.invchead_cust_id, _r.itemsite_id, _p.invchead_shipto_id,
63434
 
      _p.invchead_shipdate, _p.invchead_shipvia,
63435
 
      COALESCE(_p.invchead_ordernumber, _r.cohead_number), _p.invchead_ponumber, _p.invchead_orderdate,
63436
 
      'I', _p.invchead_invcnumber, _p.invchead_invcdate,
63437
 
      _r.qty, _r.unitprice, _r.unitcost,
63438
 
      _p.invchead_salesrep_id, (_p.invchead_commission * _r.extprice), FALSE,
63439
 
      _p.invchead_billto_name, _p.invchead_billto_address1,
63440
 
      _p.invchead_billto_address2, _p.invchead_billto_address3,
63441
 
      _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode,
63442
 
      _p.invchead_shipto_name, _p.invchead_shipto_address1,
63443
 
      _p.invchead_shipto_address2, _p.invchead_shipto_address3,
63444
 
      _p.invchead_shipto_city, _p.invchead_shipto_state,
63445
 
      _p.invchead_shipto_zipcode, _p.invchead_curr_id,
63446
 
      _p.sequence, _r.invcitem_taxtype_id, _p.invchead_taxzone_id,
63447
 
      _p.invchead_shipzone_id, _p.invchead_saletype_id );
63448
 
    INSERT INTO cohisttax
63449
 
    ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id,
63450
 
      taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
63451
 
      taxhist_percent, taxhist_amount, taxhist_tax,
63452
 
      taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
63453
 
      taxhist_journalnumber )
63454
 
    SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id,
63455
 
           taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
63456
 
           taxhist_percent, taxhist_amount, taxhist_tax,
63457
 
           taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
63458
 
           taxhist_journalnumber
63459
 
    FROM invcitemtax
63460
 
    WHERE (taxhist_parent_id=_r.invcitem_id);
63461
 
 
63462
 
  END LOOP;
63463
 
 
63464
 
  FOR _r IN SELECT *
63465
 
            FROM invoiceitem JOIN salescat ON (salescat_id = invcitem_salescat_id)
63466
 
            WHERE ( (invcitem_item_id = -1)
63467
 
              AND   (invcitem_invchead_id=pInvcheadid) ) LOOP
63468
 
 
63469
 
    _amount := _r.extprice;
63470
 
 
63471
 
    IF (_amount > 0) THEN
63472
 
      _roundedBase = round(currToBase(_p.invchead_curr_id, _amount,
63473
 
                                      _firstExchDate), 2);
63474
 
      SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber,
63475
 
                                 getPrjAccntId(_p.invchead_prj_id, COALESCE(_r.invcitem_rev_accnt_id, _r.salescat_sales_accnt_id)), 
63476
 
                                 _roundedBase,
63477
 
                                 _glDate, _p.invchead_billto_name ) INTO _test;
63478
 
      IF (_test < 0) THEN
63479
 
        PERFORM deleteGLSeries(_p.sequence);
63480
 
        DELETE FROM cohist
63481
 
         WHERE ((cohist_sequence=_p.sequence)
63482
 
           AND  (cohist_invcnumber=_p.invchead_invcnumber));
63483
 
        RETURN _test;
63484
 
      END IF;
63485
 
 
63486
 
      _totalAmount := (_totalAmount + _amount);
63487
 
      _totalRoundedBase :=  _totalRoundedBase + _roundedBase;
63488
 
      _commissionDue := (_commissionDue + (_amount * _p.invchead_commission));
63489
 
    END IF;
63490
 
 
63491
 
    SELECT nextval('cohist_cohist_id_seq') INTO _cohistid;
63492
 
    INSERT INTO cohist
63493
 
    ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id,
63494
 
      cohist_misc_type, cohist_misc_descrip,
63495
 
      cohist_shipdate, cohist_shipvia,
63496
 
      cohist_ordernumber, cohist_ponumber, cohist_orderdate,
63497
 
      cohist_doctype, cohist_invcnumber, cohist_invcdate,
63498
 
      cohist_qtyshipped, cohist_unitprice, cohist_unitcost,
63499
 
      cohist_salesrep_id, cohist_commission, cohist_commissionpaid,
63500
 
      cohist_billtoname, cohist_billtoaddress1,
63501
 
      cohist_billtoaddress2, cohist_billtoaddress3,
63502
 
      cohist_billtocity, cohist_billtostate, cohist_billtozip,
63503
 
      cohist_shiptoname, cohist_shiptoaddress1,
63504
 
      cohist_shiptoaddress2, cohist_shiptoaddress3,
63505
 
      cohist_shiptocity, cohist_shiptostate, cohist_shiptozip,
63506
 
      cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id,
63507
 
      cohist_shipzone_id, cohist_saletype_id )
63508
 
    VALUES
63509
 
    ( _cohistid, _p.invchead_cust_id, -1, _p.invchead_shipto_id,
63510
 
      'M', (_r.invcitem_number || '-' || _r.invcitem_descrip),
63511
 
      _p.invchead_shipdate, _p.invchead_shipvia,
63512
 
      COALESCE(_p.invchead_ordernumber, _r.cohead_number), _p.invchead_ponumber, _p.invchead_orderdate,
63513
 
      'I', _p.invchead_invcnumber, _p.invchead_invcdate,
63514
 
      _r.qty, _r.unitprice, 0,
63515
 
      _p.invchead_salesrep_id, (_p.invchead_commission * _r.extprice), FALSE,
63516
 
      _p.invchead_billto_name, _p.invchead_billto_address1,
63517
 
      _p.invchead_billto_address2, _p.invchead_billto_address3,
63518
 
      _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode,
63519
 
      _p.invchead_shipto_name, _p.invchead_shipto_address1,
63520
 
      _p.invchead_shipto_address2, _p.invchead_shipto_address3,
63521
 
      _p.invchead_shipto_city, _p.invchead_shipto_state,
63522
 
      _p.invchead_shipto_zipcode, _p.invchead_curr_id,
63523
 
      _p.sequence, _r.invcitem_taxtype_id, _p.invchead_taxzone_id,
63524
 
      _p.invchead_shipzone_id, _p.invchead_saletype_id );
63525
 
    INSERT INTO cohisttax
63526
 
    ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id,
63527
 
      taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
63528
 
      taxhist_percent, taxhist_amount, taxhist_tax,
63529
 
      taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
63530
 
      taxhist_journalnumber )
63531
 
    SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id,
63532
 
           taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
63533
 
           taxhist_percent, taxhist_amount, taxhist_tax,
63534
 
           taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
63535
 
           taxhist_journalnumber
63536
 
    FROM invcitemtax
63537
 
    WHERE (taxhist_parent_id=_r.invcitem_id);
63538
 
 
63539
 
  END LOOP;
63540
 
 
63541
 
  IF (_p.invchead_freight <> 0) THEN
63542
 
    IF (_p.freightaccntid <> -1) THEN
63543
 
      _roundedBase = round(currToBase(_p.invchead_curr_id, _p.invchead_freight,
63544
 
                                      _firstExchDate), 2);
63545
 
      SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber,
63546
 
                                 getPrjAccntId(_p.invchead_prj_id,_p.freightaccntid), 
63547
 
                                 _roundedBase,
63548
 
                                 _glDate, _p.invchead_billto_name ) INTO _test;
63549
 
 
63550
 
        _totalAmount := (_totalAmount + _p.invchead_freight);
63551
 
        _totalRoundedBase := _totalRoundedBase + _roundedBase;
63552
 
    ELSE
63553
 
      _test := -14;
63554
 
    END IF;
63555
 
 
63556
 
    IF (_test < 0) THEN
63557
 
      PERFORM deleteGLSeries(_p.sequence);
63558
 
      DELETE FROM cohist
63559
 
       WHERE ((cohist_sequence=_p.sequence)
63560
 
         AND  (cohist_invcnumber=_p.invchead_invcnumber));
63561
 
      RETURN _test;
63562
 
    END IF;
63563
 
 
63564
 
    SELECT nextval('cohist_cohist_id_seq') INTO _cohistid;
63565
 
    INSERT INTO cohist
63566
 
    ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id,
63567
 
      cohist_misc_type, cohist_misc_descrip,
63568
 
      cohist_shipdate, cohist_shipvia,
63569
 
      cohist_ordernumber, cohist_ponumber, cohist_orderdate,
63570
 
      cohist_doctype, cohist_invcnumber, cohist_invcdate,
63571
 
      cohist_qtyshipped, cohist_unitprice, cohist_unitcost,
63572
 
      cohist_salesrep_id, cohist_commission, cohist_commissionpaid,
63573
 
      cohist_billtoname, cohist_billtoaddress1,
63574
 
      cohist_billtoaddress2, cohist_billtoaddress3,
63575
 
      cohist_billtocity, cohist_billtostate, cohist_billtozip,
63576
 
      cohist_shiptoname, cohist_shiptoaddress1,
63577
 
      cohist_shiptoaddress2, cohist_shiptoaddress3,
63578
 
      cohist_shiptocity, cohist_shiptostate, cohist_shiptozip,
63579
 
      cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id,
63580
 
      cohist_shipzone_id, cohist_saletype_id )
63581
 
    VALUES
63582
 
    ( _cohistid, _p.invchead_cust_id, -1, _p.invchead_shipto_id,
63583
 
      'F', 'Freight',
63584
 
      _p.invchead_shipdate, _p.invchead_shipvia,
63585
 
      _p.invchead_ordernumber, _p.invchead_ponumber, _p.invchead_orderdate,
63586
 
      'I', _p.invchead_invcnumber, _p.invchead_invcdate,
63587
 
      1, _p.invchead_freight, _p.invchead_freight,
63588
 
      _p.invchead_salesrep_id, 0, FALSE,
63589
 
      _p.invchead_billto_name, _p.invchead_billto_address1,
63590
 
      _p.invchead_billto_address2, _p.invchead_billto_address3,
63591
 
      _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode,
63592
 
      _p.invchead_shipto_name, _p.invchead_shipto_address1,
63593
 
      _p.invchead_shipto_address2, _p.invchead_shipto_address3,
63594
 
      _p.invchead_shipto_city, _p.invchead_shipto_state,
63595
 
      _p.invchead_shipto_zipcode, _p.invchead_curr_id,
63596
 
      _p.sequence, getFreightTaxtypeId(), _p.invchead_taxzone_id,
63597
 
      _p.invchead_shipzone_id, _p.invchead_saletype_id );
63598
 
    INSERT INTO cohisttax
63599
 
    ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id,
63600
 
      taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
63601
 
      taxhist_percent, taxhist_amount, taxhist_tax,
63602
 
      taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
63603
 
      taxhist_journalnumber )
63604
 
    SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id,
63605
 
           taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
63606
 
           taxhist_percent, taxhist_amount, taxhist_tax,
63607
 
           taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
63608
 
           taxhist_journalnumber
63609
 
    FROM invcheadtax
63610
 
    WHERE ( (taxhist_parent_id=_p.invchead_id)
63611
 
      AND   (taxhist_taxtype_id=getFreightTaxtypeId()) );
63612
 
 
63613
 
  END IF;
63614
 
 
63615
 
  IF (_p.invchead_misc_amount <> 0) THEN
63616
 
    _roundedBase := round(currToBase(_p.invchead_curr_id, _p.invchead_misc_amount,
63617
 
                                     _firstExchDate), 2);
63618
 
    SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber,
63619
 
                               getPrjAccntId(_p.invchead_prj_id, _p.invchead_misc_accnt_id), 
63620
 
                               _roundedBase,
63621
 
                               _glDate, _p.invchead_billto_name ) INTO _test;
63622
 
 
63623
 
    IF (_test < 0) THEN
63624
 
      PERFORM deleteGLSeries(_p.sequence);
63625
 
      DELETE FROM cohist
63626
 
       WHERE ((cohist_sequence=_p.sequence)
63627
 
         AND  (cohist_invcnumber=_p.invchead_invcnumber));
63628
 
      RETURN _test;
63629
 
    END IF;
63630
 
 
63631
 
    _totalAmount := (_totalAmount + _p.invchead_misc_amount);
63632
 
    _totalRoundedBase := _totalRoundedBase + _roundedBase;
63633
 
 
63634
 
    INSERT INTO cohist
63635
 
    ( cohist_cust_id, cohist_itemsite_id, cohist_shipto_id,
63636
 
      cohist_misc_type, cohist_misc_descrip, cohist_misc_id,
63637
 
      cohist_shipdate, cohist_shipvia,
63638
 
      cohist_ordernumber, cohist_ponumber, cohist_orderdate,
63639
 
      cohist_doctype, cohist_invcnumber, cohist_invcdate,
63640
 
      cohist_qtyshipped, cohist_unitprice, cohist_unitcost,
63641
 
      cohist_salesrep_id, cohist_commission, cohist_commissionpaid,
63642
 
      cohist_billtoname, cohist_billtoaddress1,
63643
 
      cohist_billtoaddress2, cohist_billtoaddress3,
63644
 
      cohist_billtocity, cohist_billtostate, cohist_billtozip,
63645
 
      cohist_shiptoname, cohist_shiptoaddress1,
63646
 
      cohist_shiptoaddress2, cohist_shiptoaddress3,
63647
 
      cohist_shiptocity, cohist_shiptostate, cohist_shiptozip,
63648
 
      cohist_curr_id, cohist_sequence,
63649
 
      cohist_shipzone_id, cohist_saletype_id )
63650
 
    VALUES
63651
 
    ( _p.invchead_cust_id, -1, _p.invchead_shipto_id,
63652
 
      'M', _p.invchead_misc_descrip, _p.invchead_misc_accnt_id,
63653
 
      _p.invchead_shipdate, _p.invchead_shipvia,
63654
 
      _p.invchead_ordernumber, _p.invchead_ponumber, _p.invchead_orderdate,
63655
 
      'I', _p.invchead_invcnumber, _p.invchead_invcdate,
63656
 
      1, _p.invchead_misc_amount, _p.invchead_misc_amount,
63657
 
      _p.invchead_salesrep_id, 0, FALSE,
63658
 
      _p.invchead_billto_name, _p.invchead_billto_address1,
63659
 
      _p.invchead_billto_address2, _p.invchead_billto_address3,
63660
 
      _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode,
63661
 
      _p.invchead_shipto_name, _p.invchead_shipto_address1,
63662
 
      _p.invchead_shipto_address2, _p.invchead_shipto_address3,
63663
 
      _p.invchead_shipto_city, _p.invchead_shipto_state,
63664
 
      _p.invchead_shipto_zipcode, _p.invchead_curr_id,
63665
 
      _p.sequence,
63666
 
      _p.invchead_shipzone_id, _p.invchead_saletype_id );
63667
 
 
63668
 
  END IF;
63669
 
 
63670
 
  IF (_p.adjtax <> 0) THEN
63671
 
    SELECT nextval('cohist_cohist_id_seq') INTO _cohistid;
63672
 
    INSERT INTO cohist
63673
 
    ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id,
63674
 
      cohist_misc_type, cohist_misc_descrip,
63675
 
      cohist_shipdate, cohist_shipvia,
63676
 
      cohist_ordernumber, cohist_ponumber, cohist_orderdate,
63677
 
      cohist_doctype, cohist_invcnumber, cohist_invcdate,
63678
 
      cohist_qtyshipped, cohist_unitprice, cohist_unitcost,
63679
 
      cohist_salesrep_id, cohist_commission, cohist_commissionpaid,
63680
 
      cohist_billtoname, cohist_billtoaddress1,
63681
 
      cohist_billtoaddress2, cohist_billtoaddress3,
63682
 
      cohist_billtocity, cohist_billtostate, cohist_billtozip,
63683
 
      cohist_shiptoname, cohist_shiptoaddress1,
63684
 
      cohist_shiptoaddress2, cohist_shiptoaddress3,
63685
 
      cohist_shiptocity, cohist_shiptostate, cohist_shiptozip,
63686
 
      cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id,
63687
 
      cohist_shipzone_id, cohist_saletype_id )
63688
 
    VALUES
63689
 
    ( _cohistid, _p.invchead_cust_id, -1, _p.invchead_shipto_id,
63690
 
      'T', 'Misc Tax Adjustment',
63691
 
      _p.invchead_shipdate, _p.invchead_shipvia,
63692
 
      _p.invchead_ordernumber, _p.invchead_ponumber, _p.invchead_orderdate,
63693
 
      'I', _p.invchead_invcnumber, _p.invchead_invcdate,
63694
 
      1, 0.0, 0.0,
63695
 
      _p.invchead_salesrep_id, 0, FALSE,
63696
 
      _p.invchead_billto_name, _p.invchead_billto_address1,
63697
 
      _p.invchead_billto_address2, _p.invchead_billto_address3,
63698
 
      _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode,
63699
 
      _p.invchead_shipto_name, _p.invchead_shipto_address1,
63700
 
      _p.invchead_shipto_address2, _p.invchead_shipto_address3,
63701
 
      _p.invchead_shipto_city, _p.invchead_shipto_state,
63702
 
      _p.invchead_shipto_zipcode, _p.invchead_curr_id,
63703
 
      _p.sequence, getAdjustmentTaxtypeId(), _p.invchead_taxzone_id,
63704
 
      _p.invchead_shipzone_id, _p.invchead_saletype_id );
63705
 
    INSERT INTO cohisttax
63706
 
    ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id,
63707
 
      taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
63708
 
      taxhist_percent, taxhist_amount, taxhist_tax,
63709
 
      taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
63710
 
      taxhist_journalnumber )
63711
 
    SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id,
63712
 
           taxhist_basis, taxhist_basis_tax_id, taxhist_sequence,
63713
 
           taxhist_percent, taxhist_amount, taxhist_tax,
63714
 
           taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate,
63715
 
           taxhist_journalnumber
63716
 
    FROM invcheadtax
63717
 
    WHERE ( (taxhist_parent_id=_p.invchead_id)
63718
 
      AND   (taxhist_taxtype_id=getAdjustmentTaxtypeId()) );
63719
 
 
63720
 
  END IF;
63721
 
 
63722
 
    _exchGain := currGain(_p.invchead_curr_id, _totalAmount,
63723
 
                          _firstExchDate, _glDate);
63724
 
    IF (_exchGain <> 0) THEN
63725
 
        SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN',
63726
 
                                   _p.invchead_invcnumber, getGainLossAccntId(_p.araccntid),
63727
 
                                   round(_exchGain, 2) * -1,
63728
 
                                   _glDate, _p.invchead_billto_name ) INTO _test ;
63729
 
        IF (_test < 0) THEN
63730
 
          PERFORM deleteGLSeries(_p.sequence);
63731
 
          DELETE FROM cohist
63732
 
           WHERE ((cohist_sequence=_p.sequence)
63733
 
             AND  (cohist_invcnumber=_p.invchead_invcnumber));
63734
 
          RETURN _test;
63735
 
        END IF;
63736
 
    END IF;
63737
 
 
63738
 
  IF (_totalRoundedBase <> 0) THEN
63739
 
    IF (_p.araccntid != -1) THEN
63740
 
      PERFORM insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber,
63741
 
                                  _p.araccntid, round(_totalRoundedBase * -1, 2),
63742
 
                                  _glDate, _p.invchead_billto_name );
63743
 
    ELSE
63744
 
      PERFORM deleteGLSeries(_p.sequence);
63745
 
      DELETE FROM cohist
63746
 
       WHERE ((cohist_sequence=_p.sequence)
63747
 
         AND  (cohist_invcnumber=_p.invchead_invcnumber));
63748
 
      RETURN -17;
63749
 
    END IF;
63750
 
  END IF;
63751
 
 
63752
 
  SELECT postGLSeries(_p.sequence, pJournalNumber) INTO _test;
63753
 
  IF (_test < 0) THEN
63754
 
    PERFORM deleteGLSeries(_p.sequence);
63755
 
    DELETE FROM cohist
63756
 
     WHERE ((cohist_sequence=_p.sequence)
63757
 
       AND  (cohist_invcnumber=_p.invchead_invcnumber));
63758
 
    RETURN _test;
63759
 
  END IF;
63760
 
 
63761
 
  SELECT nextval('aropen_aropen_id_seq') INTO _aropenid;
63762
 
  INSERT INTO aropen
63763
 
  ( aropen_id, aropen_username, aropen_journalnumber,
63764
 
    aropen_open, aropen_posted,
63765
 
    aropen_cust_id, aropen_ponumber,
63766
 
    aropen_docnumber, aropen_applyto, aropen_doctype,
63767
 
    aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id,
63768
 
    aropen_amount, aropen_paid,
63769
 
    aropen_salesrep_id, aropen_commission_due, aropen_commission_paid,
63770
 
    aropen_ordernumber, aropen_notes, aropen_cobmisc_id,
63771
 
    aropen_curr_id )
63772
 
  VALUES
63773
 
  ( _aropenid, getEffectiveXtUser(), pJournalNumber,
63774
 
    TRUE, FALSE,
63775
 
    _p.invchead_cust_id, _p.invchead_ponumber,
63776
 
    _p.invchead_invcnumber, _p.invchead_invcnumber, 'I',
63777
 
    _p.invchead_invcdate, determineDueDate(_p.invchead_terms_id, _p.invchead_invcdate), _glDate, _p.invchead_terms_id,
63778
 
    round(_totalAmount, 2), 0, 
63779
 
    _p.invchead_salesrep_id, _commissionDue, FALSE,
63780
 
    _p.invchead_ordernumber::text, _p.invchead_notes, pInvcheadid,
63781
 
    _p.invchead_curr_id );
63782
 
 
63783
 
  FOR _r IN SELECT itemsite_id AS itemsite_id, invcitem_id,
63784
 
                   (invcitem_billed * invcitem_qty_invuomratio) AS qty,
63785
 
                   invchead_invcnumber, invchead_cust_id AS cust_id, item_number,
63786
 
                   invchead_saletype_id AS saletype_id, invchead_shipzone_id AS shipzone_id,
63787
 
                   invchead_prj_id, itemsite_costmethod
63788
 
            FROM invchead JOIN invcitem ON ( (invcitem_invchead_id=invchead_id) AND
63789
 
                                             (invcitem_billed <> 0) AND
63790
 
                                             (invcitem_updateinv) )
63791
 
                          JOIN itemsite ON ( (itemsite_item_id=invcitem_item_id) AND
63792
 
                                             (itemsite_warehous_id=invcitem_warehous_id) )
63793
 
                          JOIN item ON (item_id=invcitem_item_id)
63794
 
            WHERE (invchead_id=pInvcheadid) LOOP
63795
 
 
63796
 
    IF (_itemlocSeries = 0) THEN
63797
 
      _itemlocSeries := NEXTVAL('itemloc_series_seq');
63798
 
    END IF;
63799
 
    IF (_r.itemsite_costmethod != 'J') THEN
63800
 
      SELECT postInvTrans(itemsite_id, 'SH', _r.qty,
63801
 
                         'S/O', 'IN', _r.invchead_invcnumber, '',
63802
 
                         ('Invoice Billed ' || _r.item_number),
63803
 
                         getPrjAccntId(_r.invchead_prj_id, resolveCOSAccount(itemsite_id, _r.cust_id, _r.saletype_id, _r.shipzone_id)),
63804
 
                         costcat_asset_accnt_id, _itemlocSeries, _glDate) INTO _invhistid
63805
 
      FROM itemsite, costcat
63806
 
      WHERE ( (itemsite_costcat_id=costcat_id)
63807
 
       AND (itemsite_id=_r.itemsite_id) );
63808
 
    ELSE
63809
 
      RAISE DEBUG 'postInvoice(%, %, %) tried to postInvTrans a %-costed item',
63810
 
                  pInvcheadid, pJournalNumber, pItemlocSeries,
63811
 
                  _r.itemsite_costmethod;
63812
 
    END IF;
63813
 
 
63814
 
  END LOOP;
63815
 
 
63816
 
  UPDATE invchead
63817
 
  SET invchead_posted=TRUE, invchead_gldistdate=_glDate
63818
 
  WHERE (invchead_id=pInvcheadid);
63819
 
 
63820
 
  IF (_totalAmount > 0) THEN
63821
 
    -- get a list of allocated CMs
63822
 
    FOR _r IN SELECT aropen_id,
63823
 
                     CASE WHEN((aropen_amount - aropen_paid) >=
63824
 
                                aropenalloc_amount / (1 / aropen_curr_rate / 
63825
 
                                currRate(aropenalloc_curr_id,_firstExchDate))) THEN
63826
 
                              aropenalloc_amount / (1 / aropen_curr_rate / 
63827
 
                                currRate(aropenalloc_curr_id,_firstExchDate))
63828
 
                          ELSE (aropen_amount - aropen_paid)
63829
 
                     END AS balance,
63830
 
                     aropen_curr_id, aropen_curr_rate,
63831
 
                     aropenalloc_doctype, aropenalloc_doc_id
63832
 
                FROM aropenalloc, aropen
63833
 
               WHERE ( (aropenalloc_aropen_id=aropen_id)
63834
 
                 AND   ((aropenalloc_doctype='S' AND aropenalloc_doc_id=(SELECT cohead_id
63835
 
                                                                           FROM cohead
63836
 
                                                                          WHERE cohead_number=_p.invchead_ordernumber)) OR
63837
 
                        (aropenalloc_doctype='I' AND aropenalloc_doc_id=_p.invchead_id)) ) LOOP
63838
 
 
63839
 
      _appliedAmount := _r.balance;
63840
 
      IF (_totalAmount < _appliedAmount / (1 / currRate(_r.aropen_curr_id,_firstExchDate) /
63841
 
                        _r.aropen_curr_rate)) THEN
63842
 
        _appliedAmount := _totalAmount;
63843
 
        _tmpCurrId := _p.invchead_curr_id;
63844
 
      ELSE
63845
 
        _tmpCurrId := _r.aropen_curr_id;
63846
 
      END IF;
63847
 
 
63848
 
      -- ignore if no appliable balance
63849
 
      IF (_appliedAmount > 0) THEN
63850
 
        -- create an arcreditapply record linking the source c/m and the target invoice
63851
 
        -- for an amount that is equal to the balance on the invoice or the balance on
63852
 
        -- c/m whichever is greater.
63853
 
        INSERT INTO arcreditapply
63854
 
              (arcreditapply_source_aropen_id, arcreditapply_target_aropen_id,
63855
 
               arcreditapply_amount, arcreditapply_curr_id, arcreditapply_reftype, arcreditapply_ref_id)
63856
 
        VALUES(_r.aropen_id, _aropenid, _appliedAmount, _tmpCurrId, 'S',  _r.aropenalloc_doc_id);
63857
 
 
63858
 
        -- call postARCreditMemoApplication(aropen_id of C/M)
63859
 
        SELECT postARCreditMemoApplication(_r.aropen_id) into _test;
63860
 
 
63861
 
        -- if no error decrement the balance and contiue on
63862
 
        IF (_test >= 0) THEN
63863
 
          _totalAmount := _totalAmount - currToCurr(_tmpCurrId, _p.invchead_curr_id,
63864
 
                                                    _appliedAmount, _firstExchDate);
63865
 
        END IF;
63866
 
 
63867
 
        -- delete the allocation
63868
 
        DELETE FROM aropenalloc
63869
 
        WHERE (aropenalloc_doctype='I')
63870
 
          AND (aropenalloc_doc_id=_p.invchead_id);
63871
 
 
63872
 
      END IF;
63873
 
    END LOOP;
63874
 
  END IF;
63875
 
 
63876
 
  RETURN _itemlocSeries;
63877
 
 
63878
 
END;
63879
 
$_$;
63880
 
 
63881
 
 
63882
 
ALTER FUNCTION public.postinvoice(integer, integer, integer) OWNER TO admin;
63883
 
 
63884
 
--
63885
 
--
63886
 
 
63887
 
CREATE FUNCTION postinvoices(boolean) RETURNS integer
63888
 
    LANGUAGE plpgsql
63889
 
    AS $_$
63890
 
DECLARE
63891
 
  pPostUnprinted ALIAS FOR $1;
63892
 
BEGIN
63893
 
  RETURN postInvoices(pPostUnprinted, FALSE);
63894
 
END;
63895
 
$_$;
63896
 
 
63897
 
 
63898
 
ALTER FUNCTION public.postinvoices(boolean) OWNER TO admin;
63899
 
 
63900
 
--
63901
 
--
63902
 
 
63903
 
CREATE FUNCTION postinvoices(boolean, boolean) RETURNS integer
63904
 
    LANGUAGE plpgsql
63905
 
    AS $_$
63906
 
DECLARE
63907
 
  pPostUnprinted ALIAS FOR $1;
63908
 
  pInclZeros     ALIAS FOR $2;
63909
 
BEGIN
63910
 
  RETURN postInvoices(pPostUnprinted, pInclZeros, fetchJournalNumber('AR-IN'));
63911
 
END;
63912
 
$_$;
63913
 
 
63914
 
 
63915
 
ALTER FUNCTION public.postinvoices(boolean, boolean) OWNER TO admin;
63916
 
 
63917
 
--
63918
 
--
63919
 
 
63920
 
CREATE FUNCTION postinvoices(boolean, boolean, integer) RETURNS integer
63921
 
    LANGUAGE plpgsql
63922
 
    AS $_$
63923
 
DECLARE
63924
 
  pPostUnprinted ALIAS FOR $1;
63925
 
  pInclZeros     ALIAS FOR $2;
63926
 
  pJournalNumber ALIAS FOR $3;
63927
 
  _invcheadid    INTEGER;
63928
 
  _itemlocSeries INTEGER;
63929
 
  _counter INTEGER;
63930
 
  _r RECORD;
63931
 
 
63932
 
BEGIN
63933
 
 
63934
 
  _itemlocSeries := 0;
63935
 
 
63936
 
  IF (pInclZeros) THEN
63937
 
 
63938
 
    FOR _invcheadid IN
63939
 
      SELECT invchead_id
63940
 
      FROM invchead
63941
 
      WHERE ( (NOT invchead_posted)
63942
 
       AND (checkInvoiceSitePrivs(invchead_id))
63943
 
       AND (pPostUnprinted OR invchead_printed) ) LOOP
63944
 
 
63945
 
      SELECT postInvoice(_invcheadid, pJournalNumber, _itemlocSeries) INTO _itemlocSeries;
63946
 
      IF (_itemlocSeries < 0) THEN
63947
 
        RETURN _itemlocSeries;
63948
 
      END IF;
63949
 
    END LOOP;
63950
 
 
63951
 
  ELSE
63952
 
 
63953
 
    FOR _invcheadid IN
63954
 
      SELECT invchead_id
63955
 
      FROM invchead LEFT OUTER JOIN invcitem ON (invchead_id=invcitem_invchead_id)
63956
 
                    LEFT OUTER JOIN item ON (invcitem_item_id=item_id)  
63957
 
      WHERE((NOT invchead_posted)
63958
 
        AND (checkInvoiceSitePrivs(invchead_id))
63959
 
        AND (pPostUnprinted OR invchead_printed))
63960
 
      GROUP BY invchead_id, invchead_freight, invchead_misc_amount
63961
 
      HAVING (COALESCE(SUM(round((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price /  
63962
 
              CASE WHEN (item_id IS NULL) THEN 1 
63963
 
              ELSE invcitem_price_invuomratio END), 2)),0)
63964
 
             + invchead_freight + invchead_misc_amount) > 0 LOOP
63965
 
 
63966
 
      SELECT postInvoice(_invcheadid, pJournalNumber, _itemlocSeries) INTO _itemlocSeries;
63967
 
      IF (_itemlocSeries < 0) THEN
63968
 
        RETURN _itemlocSeries;
63969
 
      END IF;
63970
 
    END LOOP;
63971
 
 
63972
 
  END IF;
63973
 
 
63974
 
  RETURN _itemlocSeries;
63975
 
 
63976
 
END;
63977
 
$_$;
63978
 
 
63979
 
 
63980
 
ALTER FUNCTION public.postinvoices(boolean, boolean, integer) OWNER TO admin;
63981
 
 
63982
 
--
63983
 
--
63984
 
 
63985
 
CREATE FUNCTION postinvtrans(pitemsiteid integer, ptranstype text, pqty numeric, pmodule text, pordertype text, pordernumber text, pdocnumber text, pcomments text, pdebitid integer, pcreditid integer, pitemlocseries integer, ptimestamp timestamp with time zone DEFAULT now(), pcostovrld numeric DEFAULT NULL::numeric, pinvhistid integer DEFAULT NULL::integer) RETURNS integer
63986
 
    LANGUAGE plpgsql
63987
 
    AS $$
63988
 
DECLARE
63989
 
  _creditid          INTEGER;
63990
 
  _debitid           INTEGER;
63991
 
  _glreturn          INTEGER;
63992
 
  _invhistid         INTEGER;
63993
 
  _itemlocdistid     INTEGER;
63994
 
  _r                 RECORD;
63995
 
  _sense             INTEGER;  -- direction in which to adjust inventory QOH
63996
 
  _t                 RECORD;
63997
 
  _timestamp         TIMESTAMP WITH TIME ZONE;
63998
 
  _xferwhsid         INTEGER;
63999
 
 
64000
 
BEGIN
64001
 
 
64002
 
  --  Cache item and itemsite info  
64003
 
  SELECT CASE WHEN(itemsite_costmethod IN ('A','J')) THEN COALESCE(abs(pCostOvrld / pQty), avgcost(itemsite_id))
64004
 
              ELSE stdCost(itemsite_item_id)
64005
 
         END AS cost,
64006
 
         itemsite_costmethod,
64007
 
         itemsite_qtyonhand,
64008
 
         itemsite_warehous_id,
64009
 
         ( (item_type = 'R') OR (itemsite_controlmethod = 'N') ) AS nocontrol,
64010
 
         (itemsite_controlmethod IN ('L', 'S')) AS lotserial,
64011
 
         (itemsite_loccntrl) AS loccntrl,
64012
 
         itemsite_freeze AS frozen INTO _r
64013
 
  FROM itemsite JOIN item ON (item_id=itemsite_item_id)
64014
 
  WHERE (itemsite_id=pItemsiteid);
64015
 
 
64016
 
  --Post the Inventory Transactions
64017
 
  IF (_r.nocontrol) THEN
64018
 
    RETURN -1; -- non-fatal error so dont throw an exception?
64019
 
  END IF;
64020
 
 
64021
 
  IF (COALESCE(pItemlocSeries,0) = 0) THEN
64022
 
    RAISE EXCEPTION 'Transaction series must be provided';
64023
 
  END IF;
64024
 
 
64025
 
  SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid;
64026
 
 
64027
 
  IF ((pTimestamp IS NULL) OR (CAST(pTimestamp AS date)=CURRENT_DATE)) THEN
64028
 
    _timestamp := CURRENT_TIMESTAMP;
64029
 
  ELSE
64030
 
    _timestamp := pTimestamp;
64031
 
  END IF;
64032
 
 
64033
 
  IF (pTransType = 'TS' OR pTransType = 'TR') THEN
64034
 
    SELECT * INTO _t FROM tohead WHERE (tohead_number=pDocNumber);
64035
 
    IF (pTransType = 'TS') THEN
64036
 
      _xferwhsid := CASE
64037
 
          WHEN (_t.tohead_src_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_trns_warehous_id
64038
 
          WHEN (_t.tohead_trns_warehous_id=_r.itemsite_warehous_id AND pComments ~* 'recall') THEN _t.tohead_src_warehous_id
64039
 
          WHEN (_t.tohead_trns_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_dest_warehous_id
64040
 
          WHEN (_t.tohead_dest_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_trns_warehous_id
64041
 
          ELSE NULL
64042
 
          END;
64043
 
    ELSIF (pTransType = 'TR') THEN
64044
 
      _xferwhsid := CASE
64045
 
          WHEN (_t.tohead_src_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_trns_warehous_id
64046
 
          WHEN (_t.tohead_trns_warehous_id=_r.itemsite_warehous_id AND pComments ~* 'recall') THEN _t.tohead_dest_warehous_id
64047
 
          WHEN (_t.tohead_trns_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_src_warehous_id
64048
 
          WHEN (_t.tohead_dest_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_trns_warehous_id
64049
 
          ELSE NULL
64050
 
          END;
64051
 
    END IF;
64052
 
  END IF;
64053
 
 
64054
 
 
64055
 
  -- increase inventory: AD RM RT RP RR RS RX RB TR
64056
 
  -- decrease inventory: IM IB IT SH SI EX RI
64057
 
  -- TS and TR are special: shipShipment and recallShipment should not change
64058
 
  -- QOH at the Transfer Order src whs (as this was done by issueToShipping)
64059
 
  -- but postReceipt should change QOH at the transit whs
64060
 
  IF (pTransType='TS') THEN
64061
 
    _sense := CASE WHEN (SELECT tohead_trns_warehous_id=_r.itemsite_warehous_id
64062
 
                         FROM tohead
64063
 
                         WHERE (tohead_number=pDocNumber)) THEN -1
64064
 
                         ELSE 0
64065
 
                         END;
64066
 
  ELSIF (pTransType='TR') THEN
64067
 
    _sense := CASE WHEN (SELECT tohead_src_warehous_id=_r.itemsite_warehous_id
64068
 
                         FROM tohead
64069
 
                         WHERE (tohead_number=pDocNumber)) THEN 0
64070
 
                         ELSE 1
64071
 
                         END;
64072
 
  ELSIF (pTransType IN ('IM', 'IB', 'IT', 'SH', 'SI', 'EX', 'RI')) THEN
64073
 
    _sense := -1;
64074
 
 
64075
 
  ELSE
64076
 
    _sense := 1;
64077
 
  END IF;
64078
 
 
64079
 
  IF((_r.itemsite_costmethod='A') AND (_r.itemsite_qtyonhand + round(_sense * pQty, 6)) < 0) THEN
64080
 
    -- Can not let average costed itemsites go negative
64081
 
    RAISE EXCEPTION 'This transaction will cause an Average Costed item to go negative which is not allowed [xtuple: postinvtrans, -2]';
64082
 
  END IF;
64083
 
 
64084
 
  INSERT INTO invhist
64085
 
  ( invhist_id, invhist_itemsite_id, invhist_transtype, invhist_transdate,
64086
 
      invhist_invqty, invhist_qoh_before,
64087
 
      invhist_qoh_after,
64088
 
      invhist_costmethod, invhist_value_before, invhist_value_after,
64089
 
      invhist_ordtype, invhist_ordnumber, invhist_docnumber, invhist_comments,
64090
 
      invhist_invuom, invhist_unitcost, invhist_xfer_warehous_id, invhist_posted,
64091
 
      invhist_series )
64092
 
  SELECT
64093
 
    _invhistid, itemsite_id, pTransType, _timestamp,
64094
 
    pQty, itemsite_qtyonhand,
64095
 
    (itemsite_qtyonhand + (_sense * pQty)),
64096
 
    itemsite_costmethod, itemsite_value,
64097
 
    -- sanity check to ensure that value = 0 when qtyonhand = 0
64098
 
    CASE WHEN ((itemsite_qtyonhand + (_sense * pQty))) = 0.0 THEN 0.0
64099
 
         ELSE itemsite_value + (_r.cost * _sense * pQty)
64100
 
    END,
64101
 
    pOrderType, pOrderNumber, pDocNumber, pComments,
64102
 
    uom_name, _r.cost, _xferwhsid, FALSE, pItemlocSeries
64103
 
  FROM itemsite, item, uom
64104
 
  WHERE ( (itemsite_item_id=item_id)
64105
 
   AND (item_inv_uom_id=uom_id)
64106
 
   AND (itemsite_id=pItemsiteid) );
64107
 
 
64108
 
  IF (pCreditid IN (SELECT accnt_id FROM accnt)) THEN
64109
 
    _creditid = pCreditid;
64110
 
  ELSE
64111
 
    SELECT warehous_default_accnt_id INTO _creditid
64112
 
    FROM itemsite, whsinfo
64113
 
    WHERE ( (itemsite_warehous_id=warehous_id)
64114
 
      AND  (itemsite_id=pItemsiteid) );
64115
 
  END IF;
64116
 
 
64117
 
  IF (pDebitid IN (SELECT accnt_id FROM accnt)) THEN
64118
 
    _debitid = pDebitid;
64119
 
  ELSE
64120
 
    SELECT warehous_default_accnt_id INTO _debitid
64121
 
    FROM itemsite, whsinfo
64122
 
    WHERE ( (itemsite_warehous_id=warehous_id)
64123
 
      AND  (itemsite_id=pItemsiteid) );
64124
 
  END IF;
64125
 
 
64126
 
  --  Post the G/L Transaction
64127
 
  IF (_creditid <> _debitid) THEN
64128
 
    SELECT insertGLTransaction(pModule, pOrderType, pOrderNumber, pComments,
64129
 
                               _creditid, _debitid, _invhistid,
64130
 
                               (_r.cost * pQty), _timestamp::DATE, FALSE) INTO _glreturn;
64131
 
  END IF;
64132
 
 
64133
 
  --  Distribute this if this itemsite is controlled
64134
 
  IF ( _r.lotserial OR _r.loccntrl ) THEN
64135
 
 
64136
 
    _itemlocdistid := nextval('itemlocdist_itemlocdist_id_seq');
64137
 
    INSERT INTO itemlocdist
64138
 
    ( itemlocdist_id,
64139
 
      itemlocdist_itemsite_id,
64140
 
      itemlocdist_source_type,
64141
 
      itemlocdist_reqlotserial,
64142
 
      itemlocdist_distlotserial,
64143
 
      itemlocdist_expiration,
64144
 
      itemlocdist_qty,
64145
 
      itemlocdist_series,
64146
 
      itemlocdist_invhist_id,
64147
 
      itemlocdist_order_type,
64148
 
      itemlocdist_order_id )
64149
 
    SELECT _itemlocdistid,
64150
 
           pItemsiteid,
64151
 
           'O',
64152
 
           (((pQty * _sense) > 0)  AND _r.lotserial),
64153
 
           ((pQty * _sense) < 0),
64154
 
           endOfTime(),
64155
 
           (_sense * pQty),
64156
 
           pItemlocSeries,
64157
 
           _invhistid,
64158
 
           pOrderType, 
64159
 
           CASE WHEN pOrderType='SO' THEN getSalesLineItemId(pOrderNumber)
64160
 
                ELSE NULL
64161
 
           END;
64162
 
 
64163
 
    -- populate distributions if invhist_id parameter passed to undo
64164
 
    IF (pInvhistid IS NOT NULL) THEN
64165
 
      INSERT INTO itemlocdist
64166
 
        ( itemlocdist_itemlocdist_id, itemlocdist_source_type, itemlocdist_source_id,
64167
 
          itemlocdist_itemsite_id, itemlocdist_ls_id, itemlocdist_expiration,
64168
 
          itemlocdist_qty, itemlocdist_series, itemlocdist_invhist_id ) 
64169
 
      SELECT _itemlocdistid, 'L', COALESCE(invdetail_location_id, -1),
64170
 
             invhist_itemsite_id, invdetail_ls_id,  COALESCE(invdetail_expiration, endoftime()),
64171
 
             (invdetail_qty * -1.0), pItemlocSeries, _invhistid
64172
 
      FROM invhist JOIN invdetail ON (invdetail_invhist_id=invhist_id)
64173
 
      WHERE (invhist_id=pInvhistid);
64174
 
 
64175
 
      IF ( _r.lotserial)  THEN          
64176
 
        INSERT INTO lsdetail 
64177
 
          ( lsdetail_itemsite_id, lsdetail_ls_id, lsdetail_created,
64178
 
            lsdetail_source_type, lsdetail_source_id, lsdetail_source_number ) 
64179
 
        SELECT invhist_itemsite_id, invdetail_ls_id, CURRENT_TIMESTAMP,
64180
 
               'I', _itemlocdistid, ''
64181
 
        FROM invhist JOIN invdetail ON (invdetail_invhist_id=invhist_id)
64182
 
        WHERE (invhist_id=pInvhistid);
64183
 
      END IF;
64184
 
 
64185
 
      PERFORM distributeitemlocseries(pItemlocSeries);
64186
 
      
64187
 
    END IF;
64188
 
 
64189
 
  END IF;   -- end of distributions
64190
 
 
64191
 
  -- These records will be used for posting G/L transactions to trial balance after records committed.
64192
 
  -- If we try to do it now concurrency locking prevents any transactions while
64193
 
  -- user enters item distribution information.  Cant have that.
64194
 
  INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries)
64195
 
  VALUES ( _glreturn, pItemlocSeries );
64196
 
 
64197
 
  RETURN _invhistid;
64198
 
 
64199
 
END;
64200
 
$$;
64201
 
 
64202
 
 
64203
 
ALTER FUNCTION public.postinvtrans(pitemsiteid integer, ptranstype text, pqty numeric, pmodule text, pordertype text, pordernumber text, pdocnumber text, pcomments text, pdebitid integer, pcreditid integer, pitemlocseries integer, ptimestamp timestamp with time zone, pcostovrld numeric, pinvhistid integer) OWNER TO admin;
64204
 
 
64205
 
--
64206
 
--
64207
 
 
64208
 
CREATE FUNCTION postitemlocseries(integer) RETURNS boolean
64209
 
    LANGUAGE plpgsql
64210
 
    AS $_$
64211
 
DECLARE
64212
 
  pItemlocseries ALIAS FOR $1;
64213
 
  _result INTEGER;
64214
 
 
64215
 
BEGIN
64216
 
 
64217
 
  PERFORM postIntoTrialBalance(itemlocpost_glseq)
64218
 
  FROM (
64219
 
    SELECT DISTINCT itemlocpost_glseq, gltrans_accnt_id
64220
 
    FROM itemlocpost
64221
 
      JOIN gltrans ON (itemlocpost_glseq=gltrans_sequence)
64222
 
    WHERE (itemlocpost_itemlocseries=pItemlocseries)
64223
 
    ORDER BY gltrans_accnt_id
64224
 
  ) AS data;
64225
 
  
64226
 
  PERFORM postInvHist(invhist_id)
64227
 
  FROM invhist
64228
 
    JOIN itemsite ON (invhist_itemsite_id=itemsite_id)
64229
 
  WHERE ( (invhist_series=pItemlocseries)
64230
 
  AND ( NOT invhist_posted) 
64231
 
  AND ( NOT itemsite_freeze) );
64232
 
 
64233
 
  DELETE FROM itemlocpost WHERE (itemlocpost_itemlocseries=pItemlocseries);
64234
 
 
64235
 
  RETURN TRUE;
64236
 
  
64237
 
END;
64238
 
$_$;
64239
 
 
64240
 
 
64241
 
ALTER FUNCTION public.postitemlocseries(integer) OWNER TO admin;
64242
 
 
64243
 
--
64244
 
--
64245
 
 
64246
 
CREATE FUNCTION postjournals(integer) RETURNS integer
64247
 
    LANGUAGE plpgsql
64248
 
    AS $_$
64249
 
DECLARE
64250
 
  pSequence     ALIAS FOR $1;
64251
 
  _transCount INTEGER := 0;
64252
 
  _journalnumber INTEGER := fetchJournalNumber('J/P');
64253
 
  _sequence INTEGER := fetchGLSequence();
64254
 
  _sltrans RECORD;
64255
 
BEGIN
64256
 
 
64257
 
  IF (SELECT SUM(sltrans_amount) != 0
64258
 
      FROM sltrans
64259
 
      WHERE ((NOT sltrans_posted )
64260
 
       AND (sltrans_sequence=pSequence))) THEN
64261
 
     RAISE EXCEPTION 'Can not post journals. Transactions do not balance in selected date range.';
64262
 
  END IF;
64263
 
 
64264
 
  FOR _sltrans IN SELECT sltrans_source, sltrans_accnt_id,
64265
 
                          SUM(sltrans_amount) as amount
64266
 
                     FROM sltrans
64267
 
                    WHERE ((sltrans_amount<>0.0)
64268
 
                      AND  (NOT sltrans_posted)
64269
 
                      AND  (sltrans_sequence=pSequence))
64270
 
                    GROUP BY sltrans_source, sltrans_accnt_id LOOP
64271
 
 
64272
 
    IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE))
64273
 
        FROM accnt LEFT OUTER JOIN
64274
 
             period ON (CURRENT_DATE BETWEEN period_start AND period_end)
64275
 
        WHERE (accnt_id = _sltrans.sltrans_accnt_id)) THEN
64276
 
      RAISE EXCEPTION 'Cannot post to closed period (%).', _sltrans.sltrans_distdate;
64277
 
      RETURN -4;        -- remove raise exception when all callers check return code
64278
 
    END IF;
64279
 
 
64280
 
    IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND
64281
 
               BOOL_AND(COALESCE(period_freeze, FALSE))
64282
 
        FROM accnt LEFT OUTER JOIN
64283
 
             period ON (CURRENT_DATE BETWEEN period_start AND period_end)
64284
 
        WHERE (accnt_id = _sltrans.sltrans_accnt_id)) THEN
64285
 
      RAISE EXCEPTION 'Cannot post to frozen period (%).', _sltrans.sltrans_distdate;
64286
 
      RETURN -4;        -- remove raise exception when all callers check return code
64287
 
    END IF;
64288
 
 
64289
 
    IF (_sltrans.amount != 0) THEN
64290
 
       INSERT INTO gltrans
64291
 
        ( gltrans_posted, gltrans_exported, gltrans_created, gltrans_date,
64292
 
          gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_notes,
64293
 
          gltrans_doctype, gltrans_docnumber, gltrans_amount, gltrans_journalnumber, gltrans_rec )
64294
 
        VALUES
64295
 
        ( FALSE, FALSE, CURRENT_TIMESTAMP, CURRENT_DATE,
64296
 
          _sequence, _sltrans.sltrans_accnt_id, _sltrans.sltrans_source, 'Journal Posting',
64297
 
          'JP', _journalnumber, _sltrans.amount, _journalnumber, TRUE );
64298
 
      
64299
 
      _transCount := _transCount + 1;
64300
 
    END IF;
64301
 
  END LOOP;
64302
 
 
64303
 
  UPDATE sltrans SET
64304
 
    sltrans_posted=true,
64305
 
    sltrans_gltrans_journalnumber=_journalnumber
64306
 
  WHERE ((NOT sltrans_posted)
64307
 
    AND (sltrans_sequence=pSequence));
64308
 
 
64309
 
  PERFORM postIntoTrialBalance(_sequence);
64310
 
 
64311
 
  RETURN _journalnumber;
64312
 
 
64313
 
END;
64314
 
$_$;
64315
 
 
64316
 
 
64317
 
ALTER FUNCTION public.postjournals(integer) OWNER TO admin;
64318
 
 
64319
 
--
64320
 
--
64321
 
 
64322
 
CREATE FUNCTION postjournals(text[], date, date, date) RETURNS SETOF integer
64323
 
    LANGUAGE plpgsql
64324
 
    AS $_$
64325
 
DECLARE
64326
 
  pSources              ALIAS FOR $1;
64327
 
  pStartDate            ALIAS FOR $2;
64328
 
  pEndDate              ALIAS FOR $3;
64329
 
  pDistDate             ALIAS FOR $4;
64330
 
  _i INTEGER;
64331
 
BEGIN
64332
 
  FOR _i IN 1..ARRAY_UPPER(pSources,1)
64333
 
  LOOP
64334
 
    RETURN NEXT postJournals(pSources[_i], pStartDate, pEndDate, pDistDate);
64335
 
  END LOOP;
64336
 
  RETURN;
64337
 
END;
64338
 
$_$;
64339
 
 
64340
 
 
64341
 
ALTER FUNCTION public.postjournals(text[], date, date, date) OWNER TO admin;
64342
 
 
64343
 
--
64344
 
--
64345
 
 
64346
 
CREATE FUNCTION postjournals(text, date, date, date) RETURNS integer
64347
 
    LANGUAGE plpgsql
64348
 
    AS $_$
64349
 
DECLARE
64350
 
  pSource               ALIAS FOR $1;
64351
 
  pStartDate            ALIAS FOR $2;
64352
 
  pEndDate              ALIAS FOR $3;
64353
 
  pDistDate             ALIAS FOR $4;
64354
 
  _transCount INTEGER := 0;
64355
 
  _journalnumber INTEGER := fetchJournalNumber('J/P');
64356
 
  _sequence INTEGER := fetchGLSequence();
64357
 
  _sltrans RECORD;
64358
 
BEGIN
64359
 
 
64360
 
  IF (SELECT SUM(sltrans_amount) != 0
64361
 
      FROM sltrans
64362
 
      WHERE ((NOT sltrans_posted )
64363
 
       AND (sltrans_source=pSource)
64364
 
       AND (sltrans_date BETWEEN pStartDate AND pEndDate))) THEN
64365
 
     RAISE EXCEPTION 'Can not post journals. Transactions do not balance in selected date range.';
64366
 
  END IF;
64367
 
 
64368
 
  FOR _sltrans IN SELECT sltrans_source, sltrans_accnt_id,
64369
 
                          SUM(sltrans_amount) as amount
64370
 
                     FROM sltrans
64371
 
                    WHERE ((sltrans_amount<>0.0)
64372
 
                      AND  (NOT sltrans_posted)
64373
 
                      AND  (sltrans_source=pSource)
64374
 
                      AND  (sltrans_date BETWEEN pStartDate AND pEndDate))
64375
 
                    GROUP BY sltrans_source, sltrans_accnt_id LOOP
64376
 
 
64377
 
    IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND
64378
 
               BOOL_AND(COALESCE(period_freeze, FALSE))
64379
 
        FROM accnt LEFT OUTER JOIN
64380
 
             period ON (pDistDate BETWEEN period_start AND period_end)
64381
 
        WHERE (accnt_id = _sltrans.sltrans_accnt_id)) THEN
64382
 
      RAISE EXCEPTION 'Cannot post to frozen period (%).', _sltrans.sltrans_distdate;
64383
 
      RETURN -4;        -- remove raise exception when all callers check return code
64384
 
    END IF;
64385
 
 
64386
 
    IF (_sltrans.amount != 0) THEN
64387
 
       INSERT INTO gltrans
64388
 
        ( gltrans_posted, gltrans_exported, gltrans_created, gltrans_date,
64389
 
          gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_notes,
64390
 
          gltrans_doctype, gltrans_docnumber, gltrans_amount, gltrans_journalnumber )
64391
 
        VALUES
64392
 
        ( FALSE, FALSE, CURRENT_TIMESTAMP, pDistDate,
64393
 
          _sequence, _sltrans.sltrans_accnt_id, _sltrans.sltrans_source, 'Journal Posting',
64394
 
          'JP', _journalnumber, _sltrans.amount, _journalnumber );
64395
 
      
64396
 
      _transCount := _transCount + 1;
64397
 
    END IF;
64398
 
  END LOOP;
64399
 
 
64400
 
  UPDATE sltrans SET
64401
 
    sltrans_posted=true,
64402
 
    sltrans_gltrans_journalnumber=_journalnumber
64403
 
  WHERE ((NOT sltrans_posted)
64404
 
    AND (sltrans_source=pSource)
64405
 
    AND (sltrans_date BETWEEN pStartDate AND pEndDate));
64406
 
 
64407
 
  PERFORM postIntoTrialBalance(_sequence);
64408
 
 
64409
 
  RETURN _journalnumber;
64410
 
 
64411
 
END;
64412
 
$_$;
64413
 
 
64414
 
 
64415
 
ALTER FUNCTION public.postjournals(text, date, date, date) OWNER TO admin;
64416
 
 
64417
 
--
64418
 
--
64419
 
 
64420
 
CREATE FUNCTION postmessage(text, text) RETURNS integer
64421
 
    LANGUAGE plpgsql
64422
 
    AS $_$
64423
 
DECLARE
64424
 
  pUsername ALIAS FOR $1;
64425
 
  pText ALIAS FOR $2;
64426
 
  _msgid INTEGER;
64427
 
 
64428
 
BEGIN
64429
 
 
64430
 
  SELECT NEXTVAL('msg_msg_id_seq') INTO _msgid;
64431
 
  INSERT INTO msg
64432
 
  (msg_id, msg_posted, msg_scheduled, msg_expires, msg_username, msg_text)
64433
 
  VALUES
64434
 
  (_msgid, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, endOfTime(), getEffectiveXtUser(), pText);
64435
 
 
64436
 
  INSERT INTO msguser
64437
 
  ( msguser_msg_id, msguser_username )
64438
 
  VALUES
64439
 
  ( _msgid, pUsername );
64440
 
 
64441
 
  NOTIFY "messagePosted";
64442
 
 
64443
 
  RETURN _msgid;
64444
 
 
64445
 
END;
64446
 
$_$;
64447
 
 
64448
 
 
64449
 
ALTER FUNCTION public.postmessage(text, text) OWNER TO admin;
64450
 
 
64451
 
--
64452
 
--
64453
 
 
64454
 
CREATE FUNCTION postmessage(timestamp without time zone, timestamp without time zone, text) RETURNS integer
64455
 
    LANGUAGE plpgsql
64456
 
    AS $_$
64457
 
DECLARE
64458
 
  pScheduled ALIAS FOR $1;
64459
 
  pExpires ALIAS FOR $2;
64460
 
  pText ALIAS FOR $3;
64461
 
  _msgid INTEGER;
64462
 
 
64463
 
BEGIN
64464
 
 
64465
 
  SELECT NEXTVAL('msg_msg_id_seq') INTO _msgid;
64466
 
  INSERT INTO msg
64467
 
  (msg_id, msg_posted, msg_scheduled, msg_expires, msg_username, msg_text)
64468
 
  VALUES
64469
 
  (_msgid, CURRENT_TIMESTAMP, pScheduled, pExpires, getEffectiveXtUser(), pText);
64470
 
 
64471
 
  INSERT INTO msguser
64472
 
  ( msguser_msg_id, msguser_username )
64473
 
  SELECT _msgid, usr_username
64474
 
  FROM usr
64475
 
  WHERE (usr_username <> getEffectiveXtUser());
64476
 
 
64477
 
  NOTIFY "messagePosted";
64478
 
 
64479
 
  RETURN _msgid;
64480
 
 
64481
 
END;
64482
 
$_$;
64483
 
 
64484
 
 
64485
 
ALTER FUNCTION public.postmessage(timestamp without time zone, timestamp without time zone, text) OWNER TO admin;
64486
 
 
64487
 
--
64488
 
--
64489
 
 
64490
 
CREATE FUNCTION postmessage(timestamp without time zone, timestamp without time zone, text, text) RETURNS integer
64491
 
    LANGUAGE plpgsql
64492
 
    AS $_$
64493
 
DECLARE
64494
 
  pScheduled ALIAS FOR $1;
64495
 
  pExpires ALIAS FOR $2;
64496
 
  pUsername ALIAS FOR $3;
64497
 
  pText ALIAS FOR $4;
64498
 
  _msgid INTEGER;
64499
 
 
64500
 
BEGIN
64501
 
 
64502
 
  SELECT NEXTVAL('msg_msg_id_seq') INTO _msgid;
64503
 
  INSERT INTO msg
64504
 
  (msg_id, msg_posted, msg_scheduled, msg_expires, msg_username, msg_text)
64505
 
  VALUES
64506
 
  (_msgid, CURRENT_TIMESTAMP, pScheduled, pExpires, getEffectiveXtUser(), pText);
64507
 
 
64508
 
  INSERT INTO msguser
64509
 
  ( msguser_msg_id, msguser_username )
64510
 
  VALUES
64511
 
  ( _msgid, pUsername );
64512
 
 
64513
 
  NOTIFY "messagePosted";
64514
 
 
64515
 
  RETURN _msgid;
64516
 
 
64517
 
END;
64518
 
$_$;
64519
 
 
64520
 
 
64521
 
ALTER FUNCTION public.postmessage(timestamp without time zone, timestamp without time zone, text, text) OWNER TO admin;
64522
 
 
64523
 
--
64524
 
--
64525
 
 
64526
 
CREATE FUNCTION postmisccount(pitemsiteid integer, pqty numeric, pcomments text) RETURNS integer
64527
 
    LANGUAGE plpgsql
64528
 
    AS $_$
64529
 
DECLARE
64530
 
  pItemsiteid ALIAS FOR $1;
64531
 
  pQty ALIAS FOR $2;
64532
 
  pComments ALIAS FOR $3;
64533
 
  _invcntid INTEGER;
64534
 
  _result INTEGER;
64535
 
 
64536
 
BEGIN
64537
 
 
64538
 
  IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J')
64539
 
         FROM itemsite, item
64540
 
         WHERE ( (itemsite_item_id=item_id)
64541
 
          AND (itemsite_id=pItemsiteid) ) ) ) THEN
64542
 
    RETURN 0;
64543
 
  END IF;
64544
 
 
64545
 
  SELECT invcnt_id INTO _invcntid
64546
 
  FROM invcnt
64547
 
  WHERE ( (NOT invcnt_posted)
64548
 
   AND (invcnt_itemsite_id=pItemsiteid) );
64549
 
 
64550
 
  IF (_invcntid IS NULL) THEN
64551
 
    _invcntid := NEXTVAL('invcnt_invcnt_id_seq');
64552
 
 
64553
 
    INSERT INTO invcnt
64554
 
     ( invcnt_id, invcnt_itemsite_id, invcnt_tagdate,
64555
 
       invcnt_qoh_before, invcnt_qoh_after,
64556
 
       invcnt_tag_username, invcnt_cntdate, invcnt_cnt_username,
64557
 
       invcnt_postdate, invcnt_post_username, invcnt_posted,
64558
 
       invcnt_priority, invcnt_comments )
64559
 
    SELECT _invcntid, pItemsiteid, now(),
64560
 
           itemsite_qtyonhand, pQty,
64561
 
           getEffectiveXtUser(), now(), getEffectiveXtUser(),
64562
 
           now(), getEffectiveXtUser(), FALSE,
64563
 
           FALSE, pComments
64564
 
    FROM itemsite
64565
 
    WHERE (itemsite_id=pItemsiteid);
64566
 
 
64567
 
    SELECT postCountTag(_invcntid, FALSE) INTO _result;
64568
 
    IF (_result < 0) THEN
64569
 
      DELETE FROM invcnt
64570
 
      WHERE (invcnt_id=_invcntid);
64571
 
    END IF;
64572
 
 
64573
 
    RETURN _result;
64574
 
  ELSE
64575
 
    RETURN -2;
64576
 
  END IF;
64577
 
 
64578
 
END;
64579
 
$_$;
64580
 
 
64581
 
 
64582
 
ALTER FUNCTION public.postmisccount(pitemsiteid integer, pqty numeric, pcomments text) OWNER TO admin;
64583
 
 
64584
 
--
64585
 
--
64586
 
 
64587
 
CREATE FUNCTION postpogltransactions() RETURNS boolean
64588
 
    LANGUAGE plpgsql
64589
 
    AS $$
64590
 
BEGIN
64591
 
 
64592
 
  UPDATE gltrans
64593
 
  SET gltrans_exported=TRUE
64594
 
  WHERE ( (NOT gltrans_exported)
64595
 
   AND (gltrans_source='A/P')
64596
 
   AND (gltrans_doctype IN ('VO')) );
64597
 
 
64598
 
  RETURN TRUE;
64599
 
 
64600
 
END;
64601
 
$$;
64602
 
 
64603
 
 
64604
 
ALTER FUNCTION public.postpogltransactions() OWNER TO admin;
64605
 
 
64606
 
--
64607
 
--
64608
 
 
64609
 
CREATE FUNCTION postporeceipt(integer, integer) RETURNS integer
64610
 
    LANGUAGE plpgsql
64611
 
    AS $_$
64612
 
BEGIN
64613
 
  RETURN postReceipt($1, $2);
64614
 
END;
64615
 
$_$;
64616
 
 
64617
 
 
64618
 
ALTER FUNCTION public.postporeceipt(integer, integer) OWNER TO admin;
64619
 
 
64620
 
--
64621
 
--
64622
 
 
64623
 
CREATE FUNCTION postporeceipts(integer) RETURNS integer
64624
 
    LANGUAGE plpgsql
64625
 
    AS $_$
64626
 
BEGIN
64627
 
  RETURN postReceipts('PO', $1, NULL);
64628
 
END;
64629
 
$_$;
64630
 
 
64631
 
 
64632
 
ALTER FUNCTION public.postporeceipts(integer) OWNER TO admin;
64633
 
 
64634
 
--
64635
 
--
64636
 
 
64637
 
CREATE FUNCTION postporeturncreditmemo(integer) RETURNS integer
64638
 
    LANGUAGE plpgsql
64639
 
    AS $_$
64640
 
DECLARE
64641
 
  pPorejectId ALIAS FOR $1;
64642
 
 
64643
 
BEGIN
64644
 
  RETURN postPoReturnCreditMemo(pPorejectId, NULL);
64645
 
END;
64646
 
$_$;
64647
 
 
64648
 
 
64649
 
ALTER FUNCTION public.postporeturncreditmemo(integer) OWNER TO admin;
64650
 
 
64651
 
--
64652
 
--
64653
 
 
64654
 
CREATE FUNCTION postporeturncreditmemo(integer, numeric) RETURNS integer
64655
 
    LANGUAGE plpgsql
64656
 
    AS $_$
64657
 
DECLARE
64658
 
  pPorejectId ALIAS FOR $1;
64659
 
  pAmount ALIAS FOR $2;
64660
 
  _p RECORD;
64661
 
  _a RECORD;
64662
 
  _itemsiteId INTEGER;
64663
 
  _docNumber TEXT;
64664
 
  _sequence INTEGER;
64665
 
  _journalNumber INTEGER;
64666
 
  _apopenid INTEGER;
64667
 
  _exchGainItem NUMERIC;
64668
 
  _itemAmount_base NUMERIC;
64669
 
  _itemAmount NUMERIC;
64670
 
  _glseriesTotal NUMERIC;
64671
 
  _tmpTotal NUMERIC;
64672
 
  _test INTEGER;
64673
 
  _exchDate DATE;
64674
 
  _tax RECORD;
64675
 
  _taxAmount NUMERIC := 0;
64676
 
  _taxAmount_base NUMERIC;
64677
 
  _apaccntid INTEGER;
64678
 
 
64679
 
BEGIN
64680
 
--Set things up
64681
 
  SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid;
64682
 
  SELECT fetchGLSequence() INTO _sequence;
64683
 
  SELECT fetchJournalNumber('AP-MISC') INTO _journalNumber;
64684
 
  SELECT fetchapmemonumber() INTO _docNumber;
64685
 
  _glseriesTotal := 0;
64686
 
 
64687
 
--Get poreject data
64688
 
  SELECT pohead_vend_id, pohead_number, pohead_curr_id, pohead_orderdate, pohead_taxzone_id,
64689
 
         poitem_id, poitem_itemsite_id,poitem_expcat_id, poitem_taxtype_id,
64690
 
        itemsite_costcat_id, poreject_qty, poreject_date,
64691
 
        ('Return of Item ' || COALESCE(item_number,poitem_vend_item_number)
64692
 
           || ', qty. ' || formatqty(poreject_qty)) AS notes,
64693
 
        poreject_value AS value,
64694
 
        currToBase(pohead_curr_id,(poitem_unitprice * poreject_qty),CURRENT_DATE) AS itemAmount_base,
64695
 
        (poitem_unitprice * poreject_qty) AS itemAmount
64696
 
        INTO _p
64697
 
  FROM pohead, poreject, poitem
64698
 
        LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)
64699
 
        LEFT OUTER JOIN item ON (itemsite_item_id=item_id)
64700
 
  WHERE ((poreject_poitem_id=poitem_id)
64701
 
  AND (pohead_id=poitem_pohead_id)
64702
 
  AND (poreject_id=pPorejectId));
64703
 
 
64704
 
  _itemAmount := _p.itemAmount;
64705
 
  _itemAmount_base := _p.itemAmount_base;
64706
 
  IF (pAmount IS NOT NULL) THEN
64707
 
    _itemAmount := pAmount;
64708
 
    _itemAmount_base := currToBase(_p.pohead_curr_id, pAmount, CURRENT_DATE);
64709
 
  END IF;
64710
 
  
64711
 
 
64712
 
  IF (COALESCE(_p.poitem_itemsite_id, -1) = -1) THEN
64713
 
    SELECT pp.accnt_id AS pp_accnt_id,
64714
 
           lb.accnt_id AS lb_accnt_id INTO _a
64715
 
    FROM expcat, accnt AS pp, accnt AS lb
64716
 
    WHERE ( (expcat_purchprice_accnt_id=pp.accnt_id)
64717
 
     AND (expcat_liability_accnt_id=lb.accnt_id)
64718
 
     AND (expcat_id=_p.poitem_expcat_id) );
64719
 
    IF (NOT FOUND) THEN
64720
 
      RAISE EXCEPTION 'Cannot Post Credit Memo due to unassigned G/L Accounts.';
64721
 
    END IF;
64722
 
  ELSE
64723
 
    SELECT pp.accnt_id AS pp_accnt_id,
64724
 
           lb.accnt_id AS lb_accnt_id INTO _a
64725
 
    FROM costcat, accnt AS pp, accnt AS lb
64726
 
    WHERE ( (costcat_purchprice_accnt_id=pp.accnt_id)
64727
 
     AND (costcat_liability_accnt_id=lb.accnt_id)
64728
 
     AND (costcat_id=_p.itemsite_costcat_id) );
64729
 
    IF (NOT FOUND) THEN
64730
 
      RAISE EXCEPTION 'Cannot Post Credit Memo due to unassigned G/L Accounts.';
64731
 
    END IF;
64732
 
  END IF;
64733
 
 
64734
 
    INSERT INTO apopen
64735
 
    ( apopen_id, apopen_username, apopen_journalnumber,
64736
 
      apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber,
64737
 
      apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id,
64738
 
      apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_accnt_id, apopen_curr_id,
64739
 
      apopen_closedate )
64740
 
    VALUES
64741
 
    ( _apopenid, getEffectiveXtUser(), _journalNumber,
64742
 
      _p.pohead_vend_id, _docNumber, 'C', _p.pohead_number,
64743
 
      CURRENT_DATE, CURRENT_DATE, CURRENT_DATE, -1,
64744
 
      round(_itemAmount, 2), 0, (round(_itemAmount, 2) <> 0), _p.notes, -1, _p.pohead_curr_id,
64745
 
      CASE WHEN (round(_itemAmount, 2) = 0) THEN _p.poreject_date END );
64746
 
 
64747
 
    FOR _tax IN
64748
 
      SELECT taxdetail_tax_id, sum(taxdetail_tax) AS taxdetail_tax,
64749
 
        currToBase(_p.pohead_curr_id, round(sum(taxdetail_tax),2), current_date) AS taxbasevalue
64750
 
      FROM calculateTaxDetail(_p.pohead_taxzone_id, _p.poitem_taxtype_id,
64751
 
                               current_date, _p.pohead_curr_id, 
64752
 
                               _itemAmount) 
64753
 
      GROUP BY taxdetail_tax_id
64754
 
    LOOP
64755
 
      INSERT INTO apopentax (taxhist_basis,taxhist_percent,taxhist_amount,taxhist_docdate, taxhist_tax_id, taxhist_tax, 
64756
 
                             taxhist_taxtype_id, taxhist_parent_id, taxhist_journalnumber ) 
64757
 
      VALUES (0, 0, 0, current_date, _tax.taxdetail_tax_id, _tax.taxdetail_tax, getadjustmenttaxtypeid(), 
64758
 
              _apopenid, _journalNumber);
64759
 
 
64760
 
      _taxAmount := _taxAmount + _tax.taxdetail_tax;
64761
 
 
64762
 
    END LOOP;
64763
 
 
64764
 
    _taxAmount_base := addTaxToGLSeries(_sequence,
64765
 
                       'A/P', 'CM', _docNumber,
64766
 
                       _p.pohead_curr_id, current_date, current_date,
64767
 
                      'apopentax', _apopenid,
64768
 
                      _p.notes);
64769
 
 
64770
 
    UPDATE apopen SET apopen_amount = round(_itemAmount + _taxAmount,2)
64771
 
    WHERE (apopen_id = _apopenid);
64772
 
 
64773
 
    PERFORM insertIntoGLSeries( _sequence, 'A/P', 'CM', _docNumber,
64774
 
                _a.lb_accnt_id,
64775
 
                round(_p.value, 2),
64776
 
                current_date, _p.notes );
64777
 
    _glseriesTotal := _glseriesTotal + round(_p.value, 2);
64778
 
 
64779
 
    IF (round(_itemAmount_base, 2) <> round(_p.value, 2)) THEN
64780
 
      _tmpTotal := round(_itemAmount_base, 2) - round(_p.value, 2);
64781
 
      PERFORM insertIntoGLSeries( _sequence, 'A/P', 'CM', _docNumber,
64782
 
                                  _a.pp_accnt_id,
64783
 
                                  _tmpTotal,
64784
 
                                  current_date, _p.notes );
64785
 
        _glseriesTotal := _glseriesTotal + _tmpTotal;
64786
 
    END IF;
64787
 
 
64788
 
    UPDATE poreject
64789
 
    SET poreject_invoiced=TRUE
64790
 
    WHERE poreject_id=pPorejectId;
64791
 
 
64792
 
    UPDATE poitem
64793
 
       SET poitem_qty_vouchered = (poitem_qty_vouchered - _p.poreject_qty)
64794
 
     WHERE (poitem_id=_p.poitem_id);
64795
 
 
64796
 
  SELECT findAPAccount(_p.pohead_vend_id) INTO _apaccntid;
64797
 
  IF (NOT FOUND) THEN
64798
 
    RAISE EXCEPTION 'Cannot Post Credit Memo due to an unassigned A/P Account.';
64799
 
  END IF;
64800
 
 
64801
 
  SELECT insertIntoGLSeries( _sequence, 'A/P', 'CM', _docNumber,
64802
 
                             _apaccntid, round(_itemAmount_base + _taxAmount_base, 2) *-1,
64803
 
                             current_date, _p.notes ) INTO _test;
64804
 
  IF (NOT FOUND) THEN
64805
 
    RAISE EXCEPTION 'Cannot Post Credit Memo.';
64806
 
  END IF;
64807
 
 
64808
 
 
64809
 
  _glseriesTotal := _glseriesTotal + round(_itemAmount_base, 2)*-1;
64810
 
 
64811
 
  IF (round(_glseriesTotal, 2) != 0) THEN
64812
 
        PERFORM insertIntoGLSeries(_sequence, 'A/P', 'CM',
64813
 
            'Currency Exchange Rounding - ' || _docNumber,
64814
 
            getGainLossAccntId(_apaccntid), round(_glseriesTotal, 2) * -1,
64815
 
           current_date, _p.notes);
64816
 
  END IF;
64817
 
 
64818
 
  PERFORM postGLSeries(_sequence, _journalNumber);
64819
 
 
64820
 
  RETURN _journalNumber;
64821
 
 
64822
 
END;
64823
 
$_$;
64824
 
 
64825
 
 
64826
 
ALTER FUNCTION public.postporeturncreditmemo(integer, numeric) OWNER TO admin;
64827
 
 
64828
 
--
64829
 
--
64830
 
 
64831
 
CREATE FUNCTION postporeturns(integer) RETURNS integer
64832
 
    LANGUAGE plpgsql
64833
 
    AS $_$
64834
 
DECLARE
64835
 
  pPoheadid ALIAS FOR $1;
64836
 
  _itemlocSeries INTEGER;
64837
 
  _p RECORD;
64838
 
  _returnval    INTEGER;
64839
 
 
64840
 
BEGIN
64841
 
 
64842
 
  _itemlocSeries := 0;
64843
 
 
64844
 
  SELECT postPoReturns(pPoheadid,false) INTO _itemlocseries;
64845
 
 
64846
 
  RETURN _itemlocSeries;
64847
 
 
64848
 
END;
64849
 
$_$;
64850
 
 
64851
 
 
64852
 
ALTER FUNCTION public.postporeturns(integer) OWNER TO admin;
64853
 
 
64854
 
--
64855
 
--
64856
 
 
64857
 
CREATE FUNCTION postporeturns(integer, boolean) RETURNS integer
64858
 
    LANGUAGE plpgsql
64859
 
    AS $_$
64860
 
DECLARE
64861
 
  pPoheadid ALIAS FOR $1;
64862
 
  pCreateMemo ALIAS FOR $2;
64863
 
  _itemlocSeries INTEGER;
64864
 
  _p RECORD;
64865
 
  _returnval    INTEGER;
64866
 
  _tmp        INTEGER;
64867
 
  _pricevar   NUMERIC := 0.00;
64868
 
  _invhistid            INTEGER;
64869
 
  _journalNumber INTEGER := fetchJournalNumber('GL-MISC');
64870
 
 
64871
 
BEGIN
64872
 
 
64873
 
  _itemlocSeries := 0;
64874
 
 
64875
 
  FOR _p IN SELECT pohead_number, pohead_curr_id, poreject_id, poitem_prj_id,
64876
 
                   poreject_poitem_id, poitem_id, poitem_expcat_id, poitem_linenumber,
64877
 
                   currToBase(COALESCE(recv_purchcost_curr_id, pohead_curr_id),
64878
 
                              COALESCE(recv_purchcost, poitem_unitprice),
64879
 
                              pohead_orderdate) AS poitem_unitprice_base,
64880
 
                   COALESCE(itemsite_id, -1) AS itemsiteid, poitem_invvenduomratio,
64881
 
                   SUM(poreject_qty) AS totalqty,
64882
 
                   itemsite_item_id, itemsite_costmethod, itemsite_controlmethod, recv_date
64883
 
            FROM pohead JOIN poitem ON (poitem_pohead_id=pohead_id)
64884
 
                        JOIN poreject ON (poreject_poitem_id=poitem_id AND NOT poreject_posted) 
64885
 
                        LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)
64886
 
                        LEFT OUTER JOIN recv ON (recv_id=poreject_recv_id)
64887
 
            WHERE (pohead_id=pPoheadid)
64888
 
            GROUP BY poreject_id, pohead_number, poreject_poitem_id, poitem_id, poitem_prj_id,
64889
 
                     poitem_expcat_id, poitem_linenumber, poitem_unitprice, pohead_curr_id,
64890
 
                     pohead_orderdate, itemsite_id, poitem_invvenduomratio,
64891
 
                     itemsite_item_id, itemsite_costmethod, itemsite_controlmethod, recv_date,
64892
 
                     recv_purchcost_curr_id, recv_purchcost LOOP
64893
 
 
64894
 
    IF (_p.itemsiteid = -1) THEN
64895
 
        SELECT insertGLTransaction( 'S/R', 'PO', _p.pohead_number, 'Return Non-Inventory to P/O',
64896
 
                                     expcat_liability_accnt_id, 
64897
 
                                     getPrjAccntId(_p.poitem_prj_id, expcat_exp_accnt_id), -1,
64898
 
                                     round(_p.poitem_unitprice_base * _p.totalqty * -1, 2),
64899
 
                                     CURRENT_DATE ) INTO _returnval
64900
 
        FROM expcat
64901
 
        WHERE (expcat_id=_p.poitem_expcat_id);
64902
 
 
64903
 
        UPDATE poreject
64904
 
        SET poreject_posted=TRUE, poreject_value= round(_p.poitem_unitprice_base * _p.totalqty, 2)
64905
 
        WHERE (poreject_id=_p.poreject_id);
64906
 
 
64907
 
    ELSEIF (_p.itemsite_controlmethod='N') THEN
64908
 
      SELECT insertGLTransaction('S/R', 'PO', _p.pohead_number, 'Return Non-Controlled Inventory from PO',
64909
 
                                 costcat_liability_accnt_id,
64910
 
                                 getPrjAccntId(_p.poitem_prj_id, costcat_exp_accnt_id), -1,
64911
 
                                 round((_p.poitem_unitprice_base * _p.totalqty * -1), 2),
64912
 
                                 CURRENT_DATE ) INTO _returnval
64913
 
      FROM itemsite, costcat
64914
 
      WHERE((itemsite_costcat_id=costcat_id)
64915
 
        AND (itemsite_id=_p.itemsiteid));
64916
 
      IF (_returnval = -3) THEN -- zero value transaction
64917
 
        _returnval := 0;
64918
 
      END IF;
64919
 
      UPDATE poreject
64920
 
      SET poreject_posted=TRUE, poreject_value= round(_p.poitem_unitprice_base * _p.totalqty, 2)
64921
 
      WHERE (poreject_id=_p.poreject_id);
64922
 
    ELSE
64923
 
      IF (_itemlocSeries = 0) THEN
64924
 
        SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
64925
 
      END IF;
64926
 
 
64927
 
      SELECT postInvTrans( itemsite_id, 'RP', (_p.totalqty * _p.poitem_invvenduomratio * -1),
64928
 
                           'S/R', 'PO', (_p.pohead_number || '-' || _p.poitem_linenumber::TEXT), '', 'Return Inventory to P/O',
64929
 
                           costcat_asset_accnt_id, costcat_liability_accnt_id, _itemlocSeries, CURRENT_TIMESTAMP) INTO _returnval
64930
 
      FROM itemsite, costcat
64931
 
      WHERE ( (itemsite_costcat_id=costcat_id)
64932
 
       AND (itemsite_id=_p.itemsiteid) );
64933
 
 
64934
 
      UPDATE poreject
64935
 
      SET poreject_posted=TRUE, poreject_value=(invhist_unitcost *_p.totalqty * _p.poitem_invvenduomratio)
64936
 
      FROM invhist
64937
 
      WHERE ((poreject_id=_p.poreject_id)
64938
 
      AND (invhist_id=_returnval));
64939
 
 
64940
 
    END IF;
64941
 
 
64942
 
    IF (_returnval < 0) THEN
64943
 
      RETURN _returnval;
64944
 
    END IF;
64945
 
 
64946
 
 
64947
 
    UPDATE poitem
64948
 
    SET poitem_qty_returned=(poitem_qty_returned + _p.totalqty),
64949
 
        poitem_status='O'
64950
 
    WHERE (poitem_id=_p.poitem_id);
64951
 
 
64952
 
      IF (fetchMetricBool('RecordPPVonReceipt')) THEN -- If the 'Purchase Price Variance on Receipt' option is true
64953
 
         _invhistid := _returnval;
64954
 
         -- Find the difference in the purchase price value expected from the P/O and the value of the transaction
64955
 
         SELECT ((_p.poitem_unitprice_base * poitem_qty_returned) - (invhist_value_before - invhist_value_after)) INTO _pricevar
64956
 
         FROM invhist, poitem
64957
 
         WHERE ((invhist_id = _invhistid)
64958
 
           AND  (poitem_id=_p.poitem_id));
64959
 
 
64960
 
         -- If difference exists then
64961
 
         IF (_pricevar <> 0.00) THEN
64962
 
           -- Record an additional GL Transaction for the purchase price variance
64963
 
           SELECT insertGLTransaction( _journalNumber,
64964
 
                'S/R', 'PO', _p.pohead_number,
64965
 
                                       'Purchase price variance adjusted for P/O ' || _p.pohead_number || ' for item ' || _p.poitem_linenumber::TEXT,
64966
 
                                       costcat_liability_accnt_id,
64967
 
                                       getPrjAccntId(_p.poitem_prj_id, costcat_purchprice_accnt_id), -1,
64968
 
                                       _pricevar,
64969
 
                                       CURRENT_DATE, false ) INTO _tmp
64970
 
           FROM itemsite, costcat, poitem
64971
 
           WHERE ((itemsite_costcat_id=costcat_id)
64972
 
              AND (itemsite_id=poitem_itemsite_id) );
64973
 
           IF (NOT FOUND) THEN
64974
 
             RAISE EXCEPTION 'Could not insert G/L transaction: no cost category found for itemsite_id %',
64975
 
             _p.itemsiteid;
64976
 
           ELSIF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction
64977
 
             RETURN _tmp;
64978
 
           ELSE
64979
 
             -- Posting to trial balance is deferred to prevent locking
64980
 
             INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries)
64981
 
             VALUES ( _tmp, _itemlocSeries );
64982
 
           END IF;
64983
 
         END IF;
64984
 
       END IF;
64985
 
 
64986
 
    IF (pCreateMemo) THEN
64987
 
        SELECT postPoReturnCreditMemo(_p.poreject_id) INTO _returnval;
64988
 
    END IF;
64989
 
 
64990
 
    IF (_returnval < 0) THEN
64991
 
      RETURN _returnval;
64992
 
    END IF;
64993
 
 
64994
 
  END LOOP;
64995
 
 
64996
 
  RETURN _itemlocSeries;
64997
 
 
64998
 
END;
64999
 
$_$;
65000
 
 
65001
 
 
65002
 
ALTER FUNCTION public.postporeturns(integer, boolean) OWNER TO admin;
65003
 
 
65004
 
--
65005
 
--
65006
 
 
65007
 
CREATE FUNCTION postproduction(integer, numeric, boolean, boolean) RETURNS integer
65008
 
    LANGUAGE plpgsql
65009
 
    AS $_$
65010
 
BEGIN
65011
 
  RAISE NOTICE 'postProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN) is deprecated. please use postProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER, TIMESTAMP WITH TIME ZONE) instead';
65012
 
  RETURN postProduction($1, $2, $3, 0, now());
65013
 
END;
65014
 
$_$;
65015
 
 
65016
 
 
65017
 
ALTER FUNCTION public.postproduction(integer, numeric, boolean, boolean) OWNER TO admin;
65018
 
 
65019
 
--
65020
 
--
65021
 
 
65022
 
CREATE FUNCTION postproduction(integer, numeric, boolean, boolean, integer) RETURNS integer
65023
 
    LANGUAGE plpgsql
65024
 
    AS $_$
65025
 
BEGIN
65026
 
  RAISE NOTICE 'postProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN, INTEGER) is deprecated. please use postProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER, TIMESTAMP WITH TIME ZONE) instead';
65027
 
  RETURN postProduction($1, $2, $3, $5, now());
65028
 
END;
65029
 
$_$;
65030
 
 
65031
 
 
65032
 
ALTER FUNCTION public.postproduction(integer, numeric, boolean, boolean, integer) OWNER TO admin;
65033
 
 
65034
 
--
65035
 
--
65036
 
 
65037
 
CREATE FUNCTION postproduction(integer, numeric, boolean, integer, timestamp with time zone) RETURNS integer
65038
 
    LANGUAGE plpgsql
65039
 
    AS $_$
65040
 
DECLARE
65041
 
  pWoid          ALIAS FOR $1;
65042
 
  pQty           ALIAS FOR $2;
65043
 
  pBackflush     ALIAS FOR $3;
65044
 
  pItemlocSeries ALIAS FOR $4;
65045
 
  pGlDistTS      ALIAS FOR $5;
65046
 
  _test          INTEGER;
65047
 
  _invhistid     INTEGER;
65048
 
  _itemlocSeries INTEGER;
65049
 
  _parentQty     NUMERIC;
65050
 
  _r             RECORD;
65051
 
  _sense         TEXT;
65052
 
  _wipPost       NUMERIC;
65053
 
  _woNumber      TEXT;
65054
 
  _ucost         NUMERIC;
65055
 
 
65056
 
BEGIN
65057
 
 
65058
 
  IF (pQty = 0) THEN
65059
 
    RETURN 0;
65060
 
  ELSIF (pQty > 0) THEN
65061
 
    _sense = 'from';
65062
 
  ELSE
65063
 
    _sense = 'to';
65064
 
  END IF;
65065
 
 
65066
 
  IF ( ( SELECT wo_status
65067
 
         FROM wo
65068
 
         WHERE (wo_id=pWoid) ) NOT IN  ('R','E','I') ) THEN
65069
 
    RETURN -1;
65070
 
  END IF;
65071
 
 
65072
 
  SELECT bomitem_id INTO _test
65073
 
  FROM wo, bomitem, itemsite
65074
 
  WHERE ( (wo_itemsite_id=itemsite_id)
65075
 
   AND (itemsite_item_id=bomitem_parent_item_id)
65076
 
   AND (woEffectiveDate(wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1))
65077
 
   AND (wo_id=pWoid)
65078
 
   AND (bomitem_rev_id=wo_bom_rev_id)
65079
 
   AND (bomitem_item_id NOT IN
65080
 
        ( SELECT component.itemsite_item_id
65081
 
          FROM itemsite AS component, itemsite AS parent
65082
 
          WHERE ( (wo_itemsite_id=parent.itemsite_id)
65083
 
           AND (parent.itemsite_item_id=bomitem_parent_item_id)
65084
 
           AND (bomitem_item_id=component.itemsite_item_id)
65085
 
           AND (woEffectiveDate(wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1))
65086
 
           AND (bomitem_rev_id=wo_bom_rev_id)
65087
 
           AND (component.itemsite_active)
65088
 
           AND (component.itemsite_warehous_id=parent.itemsite_warehous_id) ) ) ) )
65089
 
  LIMIT 1;
65090
 
  IF (FOUND AND pBackflush) THEN
65091
 
    RETURN -2;
65092
 
  END IF;
65093
 
 
65094
 
  SELECT formatWoNumber(pWoid) INTO _woNumber;
65095
 
 
65096
 
  SELECT roundQty(item_fractional, pQty) INTO _parentQty
65097
 
  FROM wo, itemsite, item
65098
 
  WHERE ((wo_itemsite_id=itemsite_id)
65099
 
   AND (itemsite_item_id=item_id)
65100
 
   AND (wo_id=pWoid));
65101
 
 
65102
 
  IF (pItemlocSeries = 0) THEN
65103
 
    SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
65104
 
  ELSE
65105
 
    _itemlocSeries = pItemlocSeries;
65106
 
  END IF;
65107
 
 
65108
 
  IF (pBackflush) THEN
65109
 
    FOR _r IN SELECT womatl_id, womatl_qtyiss + 
65110
 
                     (CASE 
65111
 
                       WHEN (womatl_qtywipscrap >  ((womatl_qtyfxd + (_parentQty + wo_qtyrcv) * womatl_qtyper) * womatl_scrap)) THEN
65112
 
                         (womatl_qtyfxd + (_parentQty + wo_qtyrcv) * womatl_qtyper) * womatl_scrap
65113
 
                       ELSE 
65114
 
                         womatl_qtywipscrap 
65115
 
                      END) AS consumed,
65116
 
                     (womatl_qtyfxd + ((_parentQty + wo_qtyrcv) * womatl_qtyper)) * (1 + womatl_scrap) AS expected
65117
 
              FROM womatl, wo, itemsite, item
65118
 
              WHERE ((womatl_issuemethod IN ('L', 'M'))
65119
 
                AND  (womatl_wo_id=pWoid)
65120
 
                AND  (womatl_wo_id=wo_id)
65121
 
                AND  (womatl_itemsite_id=itemsite_id)
65122
 
                AND  (itemsite_item_id=item_id)) LOOP
65123
 
      -- Don't issue more than should have already been consumed at this point
65124
 
      IF (pQty > 0) THEN
65125
 
        IF (noNeg(_r.expected - _r.consumed) > 0) THEN
65126
 
          SELECT issueWoMaterial(_r.womatl_id, noNeg(_r.expected - _r.consumed), _itemlocSeries, pGlDistTS) INTO _itemlocSeries;
65127
 
        END IF;
65128
 
      ELSE
65129
 
        -- Used by postMiscProduction of disassembly
65130
 
        SELECT returnWoMaterial(_r.womatl_id, (_r.expected * -1.0), _itemlocSeries, CURRENT_TIMESTAMP, true) INTO _itemlocSeries;
65131
 
      END IF;
65132
 
 
65133
 
      UPDATE womatl
65134
 
      SET womatl_issuemethod='L'
65135
 
      WHERE ( (womatl_issuemethod='M')
65136
 
       AND (womatl_id=_r.womatl_id) );
65137
 
 
65138
 
    END LOOP;
65139
 
  END IF;
65140
 
 
65141
 
  SELECT CASE WHEN (pQty < 0 AND itemsite_costmethod='S') THEN stdcost(itemsite_item_id) * pQty
65142
 
              WHEN (pQty < 0) THEN avgcost(itemsite_id) * pQty
65143
 
              WHEN (wo_cosmethod = 'D') THEN wo_wipvalue
65144
 
              ELSE  round((wo_wipvalue - (wo_postedvalue / wo_qtyord * (wo_qtyord -
65145
 
                    CASE WHEN (wo_qtyord < wo_qtyrcv + pQty) THEN wo_qtyord
65146
 
                         ELSE wo_qtyrcv + pQty
65147
 
                    END ))),2)
65148
 
         END INTO _wipPost
65149
 
  FROM wo
65150
 
    JOIN itemsite ON (wo_itemsite_id=itemsite_id)
65151
 
  WHERE (wo_id=pWoid);
65152
 
 
65153
 
  SELECT postInvTrans( itemsite_id, 'RM', _parentQty,
65154
 
                       'W/O', 'WO', _woNumber, '', ('Receive Inventory ' || item_number || ' ' || _sense || ' Manufacturing'),
65155
 
                       costcat_asset_accnt_id, getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), _itemlocSeries, pGlDistTS,
65156
 
                       -- the following is only actually used when the item is average or job costed
65157
 
                       _wipPost ) INTO _invhistid
65158
 
  FROM wo, itemsite, item, costcat
65159
 
  WHERE ( (wo_itemsite_id=itemsite_id)
65160
 
   AND (itemsite_item_id=item_id)
65161
 
   AND (itemsite_costcat_id=costcat_id)
65162
 
   AND (wo_id=pWoid) );
65163
 
 
65164
 
  IF (pQty < 0 ) THEN
65165
 
    _wipPost := _wipPost * -1;
65166
 
  END IF;
65167
 
  
65168
 
  UPDATE wo
65169
 
  SET wo_qtyrcv = (wo_qtyrcv + _parentQty),
65170
 
      wo_wipvalue = (wo_wipvalue - (CASE WHEN (itemsite_costmethod IN ('A','J'))
65171
 
                                               THEN _wipPost
65172
 
                                         WHEN (itemsite_costmethod='S')
65173
 
                                               THEN (stdcost(itemsite_item_id) * _parentQty)
65174
 
                                         ELSE 0.0  END))
65175
 
  FROM itemsite, item
65176
 
  WHERE ((wo_itemsite_id=itemsite_id)
65177
 
   AND (itemsite_item_id=item_id)
65178
 
   AND (wo_id=pWoid));
65179
 
 
65180
 
  SELECT SUM(itemcost_stdcost * _parentQty) INTO _ucost 
65181
 
  FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)
65182
 
          JOIN itemcost ON (itemcost_item_id=itemsite_item_id)
65183
 
          JOIN costelem ON ((costelem_id=itemcost_costelem_id) AND
65184
 
                            (costelem_exp_accnt_id IS NOT NULL) AND
65185
 
                            (NOT costelem_sys))
65186
 
  WHERE (wo_id=pWoid);
65187
 
 
65188
 
  UPDATE wo
65189
 
  SET wo_wipvalue = (wo_wipvalue + coalesce(_ucost,0))
65190
 
  WHERE (wo_id=pWoid);
65191
 
 
65192
 
  PERFORM insertGLTransaction( 'W/O', 'WO', _woNumber,
65193
 
                               ('Post Other Cost ' || item_number || ' ' || _sense || ' Manufacturing'),
65194
 
                               getPrjAccntId(wo_prj_id, costelem_exp_accnt_id), 
65195
 
                               getPrjAccntId(wo_prj_id,costcat_wip_accnt_id), _invhistid,
65196
 
                               (itemcost_stdcost * _parentQty),
65197
 
                                pGlDistTS::DATE )
65198
 
FROM wo, costelem, itemcost, costcat, itemsite, item
65199
 
WHERE 
65200
 
  ((wo_id=pWoid) AND
65201
 
  (wo_itemsite_id=itemsite_id) AND
65202
 
  (itemsite_item_id=item_id) AND
65203
 
  (costelem_id = itemcost_costelem_id) AND
65204
 
  (itemcost_item_id = itemsite_item_id) AND
65205
 
  (itemsite_costcat_id = costcat_id) AND
65206
 
  (costelem_exp_accnt_id) IS NOT NULL  AND 
65207
 
  (costelem_sys = false));
65208
 
--End
65209
 
 
65210
 
 
65211
 
  UPDATE wo
65212
 
  SET wo_status='I'
65213
 
  WHERE (wo_id=pWoid);
65214
 
 
65215
 
  RETURN _itemlocSeries;
65216
 
 
65217
 
END;
65218
 
$_$;
65219
 
 
65220
 
 
65221
 
ALTER FUNCTION public.postproduction(integer, numeric, boolean, integer, timestamp with time zone) OWNER TO admin;
65222
 
 
65223
 
--
65224
 
--
65225
 
 
65226
 
CREATE FUNCTION postproduction(integer, numeric, boolean, boolean, integer, text, text) RETURNS integer
65227
 
    LANGUAGE plpgsql
65228
 
    AS $_$
65229
 
BEGIN
65230
 
  RAISE NOTICE 'postProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN, INTEGER, TEXT, TEXT) is deprecated. please use postProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER, TIMESTAMP WITH TIME ZONE) instead';
65231
 
  RETURN postProduction($1, $2, $3, $5, now());
65232
 
END;
65233
 
$_$;
65234
 
 
65235
 
 
65236
 
ALTER FUNCTION public.postproduction(integer, numeric, boolean, boolean, integer, text, text) OWNER TO admin;
65237
 
 
65238
 
--
65239
 
--
65240
 
 
65241
 
CREATE FUNCTION postreceipt(integer, integer) RETURNS integer
65242
 
    LANGUAGE plpgsql
65243
 
    AS $_$
65244
 
DECLARE
65245
 
  precvid               ALIAS FOR $1;
65246
 
  _itemlocSeries        INTEGER := COALESCE($2, 0);
65247
 
  _freightAccnt         INTEGER;
65248
 
  _glDate               TIMESTAMP WITH TIME ZONE;
65249
 
  _o                    RECORD;
65250
 
  _ordertypeabbr        TEXT;
65251
 
  _r                    RECORD;
65252
 
  _ra                   RECORD;
65253
 
  _recvinvqty          NUMERIC := 0.00;
65254
 
  _recvvalue            NUMERIC := 0.00;
65255
 
  _pricevar            NUMERIC := 0.00;
65256
 
  _tmp                  INTEGER;
65257
 
  _toitemitemid         INTEGER;
65258
 
  _coheadid             INTEGER;
65259
 
  _coitemid             INTEGER;
65260
 
  _linenumber          INTEGER;
65261
 
  _invhistid            INTEGER;
65262
 
  _shipheadid           INTEGER;
65263
 
  _ship                 BOOLEAN;
65264
 
  _i                    RECORD;
65265
 
 
65266
 
BEGIN
65267
 
  SELECT recv_id, recv_order_type, recv_orderitem_id, recv_qty,
65268
 
         round(currToBase(recv_freight_curr_id, recv_freight, recv_date::DATE),
65269
 
               2) AS recv_freight_base,
65270
 
         recv_freight, recv_freight_curr_id, recv_date, recv_gldistdate,
65271
 
         itemsite_id, itemsite_item_id, item_inv_uom_id, itemsite_costmethod,
65272
 
         itemsite_controlmethod, vend_name, item_number, item_fractional
65273
 
         INTO _r
65274
 
  FROM recv LEFT OUTER JOIN itemsite ON (recv_itemsite_id=itemsite_id)
65275
 
            LEFT OUTER JOIN item ON (itemsite_item_id=item_id)
65276
 
            LEFT OUTER JOIN vendinfo ON (recv_vend_id=vend_id)
65277
 
  WHERE ((recv_id=precvid)
65278
 
    AND  (NOT recv_posted));
65279
 
 
65280
 
  IF (NOT FOUND) THEN
65281
 
    IF (_itemlocSeries = 0) THEN
65282
 
      RETURN -10;
65283
 
    END IF;
65284
 
    RETURN _itemlocSeries;
65285
 
 
65286
 
  ELSEIF (_r.recv_qty <= 0) THEN
65287
 
    RETURN -11;
65288
 
 
65289
 
  ELSIF (_r.recv_order_type ='PO') THEN
65290
 
    _ordertypeabbr := ('P/O for ' || _r.vend_name || ' for item ' || _r.item_number);
65291
 
 
65292
 
    SELECT pohead_number AS orderhead_number, poitem_id AS orderitem_id,
65293
 
           poitem_linenumber AS orderitem_linenumber,
65294
 
           currToBase(pohead_curr_id,
65295
 
                      COALESCE(recv_purchcost, poitem_unitprice),
65296
 
                      recv_date::DATE) AS item_unitprice_base,
65297
 
           poitem_invvenduomratio AS invvenduomratio,
65298
 
           pohead_orderdate AS orderdate, pohead_dropship,
65299
 
           poitem_prj_id AS prj_id INTO _o
65300
 
    FROM recv, pohead, poitem
65301
 
    WHERE ((recv_orderitem_id=poitem_id)
65302
 
      AND  (poitem_pohead_id=pohead_id)
65303
 
      AND  (NOT recv_posted)
65304
 
      AND  (recv_id=precvid));
65305
 
  ELSIF (_r.recv_order_type ='RA') THEN
65306
 
    _ordertypeabbr := 'R/A for item ' || _r.item_number;
65307
 
    
65308
 
    SELECT rahead_id AS orderhead_id, rahead_number AS orderhead_number, raitem_id AS orderitem_id,
65309
 
           raitem_linenumber AS orderitem_linenumber,
65310
 
           currToBase(rahead_curr_id, raitem_unitprice,
65311
 
                    recv_date::DATE) AS item_unitprice_base,
65312
 
           raitem_qty_invuomratio AS invvenduomratio,
65313
 
           rahead_authdate AS orderdate,
65314
 
           raitem_unitcost AS unitcost,
65315
 
           rahead_prj_id AS prj_id INTO _o
65316
 
    FROM recv, rahead, raitem
65317
 
    WHERE ((recv_orderitem_id=raitem_id)
65318
 
      AND  (raitem_rahead_id=rahead_id)
65319
 
      AND  (NOT recv_posted)
65320
 
      AND  (recv_id=precvid));
65321
 
  ELSIF (_r.recv_order_type ='TO') THEN
65322
 
     _ordertypeabbr := 'T/O for item ' || _r.item_number;
65323
 
 
65324
 
    SELECT tohead_number AS orderhead_number, toitem_id AS orderitem_id,
65325
 
           toitem_linenumber AS orderitem_linenumber,
65326
 
           toitem_stdcost AS item_unitprice_base,
65327
 
           1.0 AS invvenduomratio,
65328
 
           tohead_orderdate AS orderdate,
65329
 
           NULL AS prj_id INTO _o
65330
 
    FROM recv, tohead, toitem
65331
 
    WHERE ((recv_orderitem_id=toitem_id)
65332
 
      AND  (toitem_tohead_id=tohead_id)
65333
 
      AND  (NOT recv_posted)
65334
 
      AND  (recv_id=precvid));
65335
 
  ELSE
65336
 
    RETURN -13; -- don't know how to handle this order type
65337
 
  END IF;
65338
 
 
65339
 
  IF (NOT FOUND) THEN
65340
 
    IF (_itemlocSeries = 0) THEN
65341
 
      RETURN -10;
65342
 
    END IF;
65343
 
    RETURN _itemlocSeries;
65344
 
  END IF;
65345
 
 
65346
 
  IF (_itemlocSeries = 0) THEN
65347
 
    _itemlocSeries := NEXTVAL('itemloc_series_seq');
65348
 
  ELSEIF (_itemlocSeries < 0) THEN
65349
 
    RETURN _itemlocSeries;
65350
 
  END IF;
65351
 
 
65352
 
  _glDate := COALESCE(_r.recv_gldistdate, _r.recv_date);
65353
 
  _recvinvqty := roundQty(_r.item_fractional, (_r.recv_qty * _o.invvenduomratio));
65354
 
 
65355
 
  IF ( (_r.recv_order_type = 'PO') AND
65356
 
        (_r.itemsite_id = -1 OR _r.itemsite_id IS NULL OR _r.itemsite_controlmethod = 'N') ) THEN
65357
 
 
65358
 
    IF (_r.itemsite_id IS NOT NULL) THEN
65359
 
      SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), 
65360
 
                                  'S/R', _r.recv_order_type, _o.orderhead_number,
65361
 
                                  'Receive Non-Controlled Inventory from ' || _ordertypeabbr,
65362
 
                                   costcat_liability_accnt_id,
65363
 
                                   getPrjAccntId(_o.prj_id, costcat_exp_accnt_id), -1,
65364
 
                                   round((_o.item_unitprice_base * _r.recv_qty),2),
65365
 
                                   _glDate::DATE, false ) INTO _tmp
65366
 
      FROM poitem, itemsite, costcat
65367
 
      WHERE((poitem_itemsite_id=itemsite_id)
65368
 
        AND (itemsite_costcat_id=costcat_id)
65369
 
        AND (poitem_id=_o.orderitem_id));
65370
 
    ELSE
65371
 
      SELECT insertGLTransaction(fetchJournalNumber('GL-MISC'),
65372
 
                                  'S/R', _r.recv_order_type, _o.orderhead_number,
65373
 
                                  'Receive Non-Inventory from ' || 'P/O for ' || _r.vend_name || ' for ' || expcat_code,
65374
 
                                   expcat_liability_accnt_id,
65375
 
                                   getPrjAccntId(_o.prj_id, expcat_exp_accnt_id), -1,
65376
 
                                   round((_o.item_unitprice_base * _r.recv_qty),2),
65377
 
                                   _glDate::DATE, false ) INTO _tmp
65378
 
      FROM poitem, expcat
65379
 
      WHERE((poitem_expcat_id=expcat_id)
65380
 
        AND (poitem_id=_o.orderitem_id));
65381
 
    END IF;
65382
 
      
65383
 
 
65384
 
    IF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction
65385
 
      RETURN _tmp;
65386
 
    ELSE
65387
 
      -- Posting to trial balance is deferred to prevent locking
65388
 
      INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries)
65389
 
      VALUES ( _tmp, _itemlocSeries );
65390
 
      
65391
 
    END IF;
65392
 
 
65393
 
    SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'),
65394
 
                                'S/R', _r.recv_order_type, _o.orderhead_number,
65395
 
                                'Receive Non-Inventory Freight from ' || _ordertypeabbr,
65396
 
                                 expcat_liability_accnt_id,
65397
 
                                 getPrjAccntId(_o.prj_id, expcat_freight_accnt_id), -1,
65398
 
                                 _r.recv_freight_base,
65399
 
                                 _glDate::DATE, false ),
65400
 
           expcat_freight_accnt_id INTO _tmp, _freightAccnt
65401
 
    FROM poitem, expcat
65402
 
    WHERE((poitem_expcat_id=expcat_id)
65403
 
      AND (poitem_id=_o.orderitem_id));
65404
 
 
65405
 
    IF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction
65406
 
      RETURN _tmp;
65407
 
    ELSE
65408
 
      -- Posting to trial balance is deferred to prevent locking
65409
 
      INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries)
65410
 
      VALUES ( _tmp, _itemlocSeries );
65411
 
    END IF;
65412
 
 
65413
 
    _recvvalue := ROUND((_o.item_unitprice_base * _r.recv_qty),2);
65414
 
 
65415
 
    UPDATE poitem
65416
 
    SET poitem_qty_received = (poitem_qty_received + _r.recv_qty),
65417
 
        poitem_freight_received = (poitem_freight_received + _r.recv_freight_base)
65418
 
    WHERE (poitem_id=_o.orderitem_id);
65419
 
 
65420
 
  ELSEIF ( (_r.recv_order_type = 'RA') AND
65421
 
           (_r.itemsite_id = -1 OR _r.itemsite_id IS NULL) ) THEN
65422
 
    RAISE NOTICE 'itemsite controlmethod is %, cannot post receipt.', _r.itemsite_controlmethod;
65423
 
    RETURN -14; -- otherwise how do we get the accounts?
65424
 
 
65425
 
  ELSEIF ( (_r.recv_order_type = 'TO') AND
65426
 
           (_r.itemsite_id = -1 OR _r.itemsite_id IS NULL) ) THEN
65427
 
    RAISE NOTICE 'itemsite missing';
65428
 
    RETURN -14; -- otherwise how do we get the accounts?
65429
 
 
65430
 
  ELSE  -- not ELSIF: some code is shared between diff order types
65431
 
    IF (_r.recv_order_type = 'PO') THEN
65432
 
      SELECT postInvTrans( itemsite_id, 'RP'::TEXT,
65433
 
                           _recvinvqty,
65434
 
                           'S/R'::TEXT,
65435
 
                           _r.recv_order_type::TEXT, _o.orderhead_number::TEXT || '-' || _o.orderitem_linenumber::TEXT,
65436
 
                           ''::TEXT,
65437
 
                           'Receive Inventory from ' || _ordertypeabbr,
65438
 
                           costcat_asset_accnt_id, costcat_liability_accnt_id,
65439
 
                           _itemlocSeries,
65440
 
                           _glDate,
65441
 
                           round((_o.item_unitprice_base * _r.recv_qty),2) -- always passing this in since it is ignored if it is not average costed item
65442
 
                           ) INTO _tmp
65443
 
      FROM itemsite, costcat
65444
 
      WHERE ( (itemsite_costcat_id=costcat_id)
65445
 
       AND (itemsite_id=_r.itemsite_id) );
65446
 
      IF (NOT FOUND) THEN
65447
 
        RAISE EXCEPTION 'Could not post inventory transaction: no cost category found for itemsite_id %',
65448
 
          _r.itemsite_id;
65449
 
      ELSIF (_tmp < -1) THEN -- less than -1 because -1 means it is a none controlled item
65450
 
        IF(_tmp = -3) THEN
65451
 
          RETURN -12; -- The GL trans value was 0 which means we likely do not have a std cost
65452
 
        END IF;
65453
 
        RETURN _tmp;
65454
 
      END IF;
65455
 
 
65456
 
      -- If the 'Purchase Price Variance on Receipt' option is true
65457
 
      IF (fetchMetricBool('RecordPPVonReceipt')) THEN
65458
 
        _invhistid := _tmp;
65459
 
        -- Find the difference in the purchase price value expected from the P/O and the value of the transaction
65460
 
        SELECT ((_o.item_unitprice_base * _r.recv_qty) - (invhist_value_after - invhist_value_before)) INTO _pricevar
65461
 
        FROM invhist
65462
 
        WHERE (invhist_id = _invhistid);
65463
 
 
65464
 
        -- If difference exists then
65465
 
        IF (_pricevar <> 0.00) THEN
65466
 
          -- Record an additional GL Transaction for the purchase price variance
65467
 
          SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'),
65468
 
                                       'S/R', _r.recv_order_type, _o.orderhead_number,
65469
 
                                      'Purchase price variance adjusted for P/O ' || _o.orderhead_number || ' for item ' || _r.item_number,
65470
 
                                      costcat_liability_accnt_id,
65471
 
                                      getPrjAccntId(_o.prj_id, costcat_purchprice_accnt_id), -1,
65472
 
                                      _pricevar,
65473
 
                                      _glDate::DATE, false ) INTO _tmp
65474
 
          FROM itemsite, costcat
65475
 
          WHERE ((itemsite_costcat_id=costcat_id)
65476
 
             AND (itemsite_id=_r.itemsite_id) );
65477
 
          IF (NOT FOUND) THEN
65478
 
            RAISE EXCEPTION 'Could not insert G/L transaction: no cost category found for itemsite_id %',
65479
 
            _r.itemsite_id;
65480
 
          ELSIF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction
65481
 
            RETURN _tmp;
65482
 
          ELSE
65483
 
            -- Posting to trial balance is deferred to prevent locking
65484
 
            INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries)
65485
 
            VALUES ( _tmp, _itemlocSeries );
65486
 
          END IF;
65487
 
        END IF;
65488
 
      END IF;
65489
 
 
65490
 
      SELECT insertGLTransaction(fetchJournalNumber('GL-MISC'),
65491
 
                                  'S/R', _r.recv_order_type, _o.orderhead_number,
65492
 
                                  'Receive Inventory Freight from ' || _o.orderhead_number || ' for item ' || _r.item_number,
65493
 
                                   costcat_liability_accnt_id,
65494
 
                                   getPrjAccntId(_o.prj_id, costcat_freight_accnt_id), -1,
65495
 
                                   _r.recv_freight_base,
65496
 
                                   _glDate::DATE, false ),
65497
 
             costcat_freight_accnt_id INTO _tmp, _freightAccnt
65498
 
      FROM itemsite, costcat
65499
 
      WHERE ( (itemsite_costcat_id=costcat_id)
65500
 
       AND (itemsite_id=_r.itemsite_id) );
65501
 
      IF (NOT FOUND) THEN
65502
 
        RAISE EXCEPTION 'Could not insert G/L transaction: no cost category found for itemsite_id %',
65503
 
          _r.itemsite_id;
65504
 
      ELSIF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction
65505
 
        RETURN _tmp;
65506
 
      ELSE
65507
 
          -- Posting to trial balance is deferred to prevent locking
65508
 
          INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries)
65509
 
          VALUES ( _tmp, _itemlocSeries );
65510
 
      END IF;
65511
 
 
65512
 
      UPDATE poitem
65513
 
      SET poitem_qty_received = (poitem_qty_received + _r.recv_qty),
65514
 
          poitem_freight_received = (poitem_freight_received + _r.recv_freight_base)
65515
 
      WHERE (poitem_id=_o.orderitem_id);
65516
 
 
65517
 
    ELSIF (_r.recv_order_type = 'RA') THEN
65518
 
      SELECT rahead.*, raitem.* INTO _ra
65519
 
            FROM rahead, raitem
65520
 
        WHERE ((rahead_id=raitem_rahead_id)
65521
 
        AND  (raitem_id=_r.recv_orderitem_id));
65522
 
 
65523
 
      IF (_r.itemsite_controlmethod = 'N') THEN
65524
 
        SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), 
65525
 
                                    'S/R', _r.recv_order_type, _o.orderhead_number,
65526
 
                                    'Receive Non-Controlled Inventory from ' || _ordertypeabbr,
65527
 
                                    costcat_liability_accnt_id,
65528
 
                                    getPrjAccntId(_o.prj_id, costcat_exp_accnt_id), -1,
65529
 
                                    round((_o.item_unitprice_base * _r.recv_qty),2),
65530
 
                                    _glDate::DATE, false ) INTO _tmp
65531
 
        FROM itemsite JOIN costcat ON (costcat_id=itemsite_costcat_id)
65532
 
        WHERE(itemsite_id=_r.itemsite_id);
65533
 
        IF (NOT FOUND) THEN
65534
 
          RAISE EXCEPTION 'Could not post inventory transaction: no cost category found for itemsite_id %', _r.itemsite_id;
65535
 
        END IF;
65536
 
      ELSE
65537
 
        SELECT postInvTrans(_r.itemsite_id, 'RR',
65538
 
                            _recvinvqty,
65539
 
                            'S/R',
65540
 
                            _r.recv_order_type, _ra.rahead_number::TEXT || '-' || _ra.raitem_linenumber::TEXT,
65541
 
                            '',
65542
 
                            'Receive Inventory from ' || _ordertypeabbr,
65543
 
                            costcat_asset_accnt_id,
65544
 
                            CASE WHEN(COALESCE(_ra.raitem_cos_accnt_id, -1) != -1) THEN 
65545
 
                                  getPrjAccntId(_o.prj_id, _ra.raitem_cos_accnt_id)
65546
 
                                 WHEN (_ra.raitem_warranty) THEN 
65547
 
                                  getPrjAccntId(_o.prj_id, resolveCOWAccount(_r.itemsite_id, _ra.rahead_cust_id, _ra.rahead_saletype_id, _ra.rahead_shipzone_id))
65548
 
                                 ELSE
65549
 
                                  getPrjAccntId(_o.prj_id, resolveCORAccount(_r.itemsite_id, _ra.rahead_cust_id, _ra.rahead_saletype_id, _ra.rahead_shipzone_id))
65550
 
                            END,
65551
 
                            _itemlocSeries, _glDate, COALESCE(_o.unitcost,stdcost(itemsite_item_id)) * _recvinvqty) INTO _tmp
65552
 
        FROM itemsite, costcat
65553
 
        WHERE ( (itemsite_costcat_id=costcat_id)
65554
 
         AND (itemsite_id=_r.itemsite_id) );
65555
 
 
65556
 
        IF (NOT FOUND) THEN
65557
 
          RAISE EXCEPTION 'Could not post inventory transaction: no cost category found for itemsite_id %', _r.itemsite_id;
65558
 
        ELSIF (_tmp < -1) THEN -- less than -1 because -1 means it is a none controlled item
65559
 
          IF(_tmp = -3) THEN
65560
 
            RAISE NOTICE 'The GL trans value was 0 which means we likely do not have a std cost';
65561
 
            RETURN -12; -- The GL trans value was 0 which means we likely do not have a std cost
65562
 
          END IF;
65563
 
          RETURN _tmp;
65564
 
        END IF;
65565
 
      END IF;
65566
 
 
65567
 
      INSERT INTO rahist (rahist_itemsite_id, rahist_date,
65568
 
                          rahist_descrip,
65569
 
                          rahist_qty, rahist_uom_id,
65570
 
                          rahist_source, rahist_source_id, rahist_rahead_id
65571
 
          ) VALUES (_r.itemsite_id, _glDate,
65572
 
                      'Receive Inventory from ' || _ordertypeabbr,
65573
 
                      _recvinvqty, _r.item_inv_uom_id,
65574
 
                      'RR', _r.recv_id, _ra.rahead_id
65575
 
                  );
65576
 
 
65577
 
      SELECT insertGLTransaction(fetchJournalNumber('GL-MISC'),
65578
 
                                  'S/R', _r.recv_order_type, _o.orderhead_number,
65579
 
                                  'Receive Inventory Freight from ' || _o.orderhead_number || ' for item ' || _r.item_number,
65580
 
                                   costcat_liability_accnt_id,
65581
 
                                   getPrjAccntId(_o.prj_id, costcat_freight_accnt_id), -1,
65582
 
                                   _r.recv_freight_base,
65583
 
                                   _glDate::DATE, false ),
65584
 
             costcat_freight_accnt_id INTO _tmp, _freightAccnt
65585
 
      FROM itemsite, costcat
65586
 
      WHERE ( (itemsite_costcat_id=costcat_id)
65587
 
       AND (itemsite_id=_r.itemsite_id) );
65588
 
      IF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction
65589
 
            RETURN _tmp;
65590
 
      ELSE
65591
 
        -- Posting to trial balance is deferred to prevent locking
65592
 
        INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries)
65593
 
        VALUES ( _tmp, _itemlocSeries );
65594
 
      END IF;
65595
 
 
65596
 
      INSERT INTO rahist (rahist_date, rahist_descrip,
65597
 
                          rahist_source, rahist_source_id,
65598
 
                          rahist_curr_id, rahist_amount,
65599
 
                          rahist_rahead_id
65600
 
          ) VALUES (_glDate, 'Receive Inventory Freight from ' || _ordertypeabbr,
65601
 
                  'RR', _r.recv_id, _r.recv_freight_curr_id, _r.recv_freight,
65602
 
                  _ra.rahead_id
65603
 
          );
65604
 
 
65605
 
      UPDATE raitem
65606
 
      SET raitem_qtyreceived = (raitem_qtyreceived + _r.recv_qty)
65607
 
      WHERE (raitem_id=_o.orderitem_id);
65608
 
      
65609
 
      UPDATE rahead
65610
 
      SET rahead_expiredate = NULL
65611
 
      WHERE (rahead_id=_o.orderhead_id);
65612
 
 
65613
 
    SELECT (count(*) > 0) INTO _ship
65614
 
    FROM raitem
65615
 
    WHERE ((raitem_disposition = 'S')
65616
 
     AND (raitem_new_coitem_id IS NULL)
65617
 
     AND (raitem_rahead_id=_ra.rahead_id));
65618
 
 
65619
 
      IF ((_ra.rahead_timing='R') AND
65620
 
          (_ship OR (
65621
 
          (_ra.raitem_disposition IN ('P','V')) AND
65622
 
          (_ra.raitem_new_coitem_id IS NULL) AND
65623
 
          (_ra.raitem_qtyauthorized > 0)))) THEN
65624
 
 
65625
 
          IF (_ra.rahead_new_cohead_id IS NOT NULL) THEN
65626
 
            _coheadid = _ra.rahead_new_cohead_id;
65627
 
          ELSE  
65628
 
            SELECT nextval('cohead_cohead_id_seq') INTO _coheadid;
65629
 
 
65630
 
            INSERT INTO cohead (
65631
 
              cohead_id,cohead_number,cohead_cust_id,cohead_custponumber,
65632
 
              cohead_orderdate,cohead_salesrep_id,cohead_terms_id,
65633
 
              cohead_shipvia,cohead_shipto_id,cohead_shiptoname,
65634
 
              cohead_shiptoaddress1,cohead_shiptoaddress2,cohead_shiptoaddress3,
65635
 
              cohead_shiptocity,cohead_shiptostate,cohead_shiptozipcode,
65636
 
              cohead_shiptocountry,cohead_freight,cohead_shiptophone,
65637
 
              cohead_shipto_cntct_id, cohead_shipto_cntct_honorific,
65638
 
              cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle,
65639
 
              cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix,
65640
 
              cohead_shipto_cntct_phone, cohead_shipto_cntct_title,
65641
 
              cohead_shipto_cntct_fax, cohead_shipto_cntct_email,
65642
 
              cohead_shipchrg_id, cohead_shipform_id,cohead_billtoname,
65643
 
              cohead_billtoaddress1,cohead_billtoaddress2,cohead_billtoaddress3,
65644
 
              cohead_billtocity,cohead_billtostate,cohead_billtozipcode,
65645
 
              cohead_billtocountry,cohead_misc_accnt_id,cohead_misc_descrip,
65646
 
              cohead_commission,cohead_holdtype,cohead_prj_id,cohead_shipcomplete,
65647
 
              cohead_curr_id,cohead_taxzone_id,cohead_saletype_id,cohead_shipzone_id)
65648
 
            SELECT _coheadid,fetchsonumber(),rahead_cust_id,rahead_custponumber,
65649
 
              current_date,rahead_salesrep_id,COALESCE(cohead_terms_id,cust_terms_id),
65650
 
              COALESCE(cohead_shipvia,cust_shipvia),rahead_shipto_id,rahead_shipto_name,
65651
 
              rahead_shipto_address1,rahead_shipto_address2,rahead_shipto_address3,
65652
 
              rahead_shipto_city,rahead_shipto_state,rahead_shipto_zipcode,
65653
 
              rahead_shipto_country,0,COALESCE(cohead_shiptophone,''),
65654
 
              cntct_id, cntct_honorific,
65655
 
              cntct_first_name, cntct_middle,
65656
 
              cntct_last_name, cntct_suffix,
65657
 
              cntct_phone, cntct_title,
65658
 
              cntct_fax, cntct_email,
65659
 
              COALESCE(cohead_shipchrg_id,cust_shipchrg_id),
65660
 
              COALESCE(cohead_shipform_id,cust_shipform_id),
65661
 
              rahead_billtoname,rahead_billtoaddress1,rahead_billtoaddress2,rahead_billtoaddress3,
65662
 
              rahead_billtocity,rahead_billtostate,rahead_billtozip,
65663
 
              rahead_billtocountry,NULL,'',rahead_commission, 'N', rahead_prj_id,
65664
 
              COALESCE(cohead_shipcomplete,
65665
 
                CASE WHEN cust_partialship THEN 
65666
 
                  false 
65667
 
                ELSE true
65668
 
                END),rahead_curr_id,rahead_taxzone_id,rahead_saletype_id,rahead_shipzone_id
65669
 
            FROM rahead
65670
 
              JOIN custinfo ON (rahead_cust_id=cust_id)
65671
 
              LEFT OUTER JOIN cohead ON (rahead_orig_cohead_id=cohead_id)
65672
 
              LEFT OUTER JOIN shiptoinfo ON (rahead_shipto_id=shipto_id)
65673
 
              LEFT OUTER JOIN cntct ON (shipto_cntct_id=cntct_id)
65674
 
            WHERE (rahead_id=_ra.rahead_id);
65675
 
 
65676
 
            UPDATE rahead SET rahead_new_cohead_id=_coheadid WHERE rahead_id=_ra.rahead_id;
65677
 
            
65678
 
          END IF;
65679
 
                  
65680
 
        IF (_ra.raitem_disposition IN ('P','V')) AND
65681
 
           (_ra.raitem_new_coitem_id IS NULL) AND
65682
 
           (_ra.raitem_qtyauthorized > 0) THEN
65683
 
           
65684
 
          SELECT nextval('coitem_coitem_id_seq') INTO _coitemid;
65685
 
 
65686
 
          SELECT COALESCE(MAX(coitem_linenumber),0)+1 INTO _linenumber
65687
 
          FROM coitem
65688
 
          WHERE (coitem_cohead_id=_coheadid);
65689
 
      
65690
 
          INSERT INTO coitem (
65691
 
            coitem_id,coitem_cohead_id,coitem_linenumber,coitem_itemsite_id,
65692
 
            coitem_status,coitem_scheddate,coitem_promdate, coitem_qtyord,
65693
 
            coitem_unitcost,coitem_price,coitem_custprice,coitem_qtyshipped,
65694
 
            coitem_order_id,coitem_memo,coitem_qtyreturned,
65695
 
            coitem_taxtype_id,coitem_qty_uom_id,coitem_qty_invuomratio,
65696
 
            coitem_price_uom_id,coitem_price_invuomratio,coitem_warranty,
65697
 
            coitem_cos_accnt_id,coitem_order_type, coitem_custpn)
65698
 
          SELECT _coitemid,_coheadid,_linenumber,_ra.raitem_coitem_itemsite_id,
65699
 
              'O',_ra.raitem_scheddate,_ra.raitem_scheddate,_ra.raitem_qtyauthorized,
65700
 
              stdcost(itemsite_item_id),COALESCE(_ra.raitem_saleprice,0),0,0,
65701
 
              -1,_ra.raitem_notes,0,
65702
 
              _ra.raitem_taxtype_id,_ra.raitem_qty_uom_id,_ra.raitem_qty_invuomratio,
65703
 
              _ra.raitem_price_uom_id,_ra.raitem_price_invuomratio,_ra.raitem_warranty,
65704
 
              _ra.raitem_cos_accnt_id,
65705
 
              CASE WHEN itemsite_createwo THEN 'W' ELSE NULL END, _ra.raitem_custpn
65706
 
          FROM itemsite
65707
 
          WHERE (itemsite_id=_ra.raitem_coitem_itemsite_id);
65708
 
 
65709
 
          UPDATE raitem SET raitem_new_coitem_id=_coitemid WHERE (raitem_id=_ra.raitem_id);
65710
 
        END IF;
65711
 
        
65712
 
        -- Create items to ship that have no direct relation to receipts.
65713
 
        IF (_ship) THEN
65714
 
          FOR _i IN
65715
 
            SELECT raitem_id FROM raitem
65716
 
            WHERE ((raitem_rahead_id=_ra.rahead_id)
65717
 
              AND (raitem_disposition = 'S')
65718
 
              AND (raitem_new_coitem_id IS NULL))
65719
 
          LOOP
65720
 
 
65721
 
            SELECT nextval('coitem_coitem_id_seq') INTO _coitemid;
65722
 
 
65723
 
            SELECT COALESCE(MAX(coitem_linenumber),0)+1 INTO _linenumber
65724
 
              FROM coitem
65725
 
            WHERE (coitem_cohead_id=_coheadid);
65726
 
      
65727
 
            INSERT INTO coitem (
65728
 
              coitem_id,coitem_cohead_id,coitem_linenumber,coitem_itemsite_id,
65729
 
              coitem_status,coitem_scheddate,coitem_promdate, coitem_qtyord,
65730
 
              coitem_unitcost,coitem_price,coitem_custprice,coitem_qtyshipped,
65731
 
              coitem_order_id,coitem_memo,coitem_qtyreturned,
65732
 
              coitem_taxtype_id,coitem_qty_uom_id,coitem_qty_invuomratio,
65733
 
              coitem_price_uom_id,coitem_price_invuomratio,coitem_warranty,
65734
 
              coitem_cos_accnt_id,coitem_order_type,coitem_custpn)
65735
 
            SELECT _coitemid,_coheadid,_linenumber,raitem_coitem_itemsite_id,
65736
 
              'O',raitem_scheddate,raitem_scheddate,raitem_qtyauthorized,
65737
 
              stdcost(itemsite_item_id),COALESCE(raitem_saleprice,0),0,0,
65738
 
              -1,raitem_notes,0,
65739
 
              raitem_taxtype_id,raitem_qty_uom_id,raitem_qty_invuomratio,
65740
 
              raitem_price_uom_id,raitem_price_invuomratio,raitem_warranty,
65741
 
              raitem_cos_accnt_id,
65742
 
              CASE WHEN itemsite_createwo THEN 'W' ELSE NULL END,raitem_custpn
65743
 
            FROM raitem
65744
 
              JOIN itemsite ON (itemsite_id=raitem_itemsite_id)
65745
 
            WHERE (raitem_id=_i.raitem_id);
65746
 
                        
65747
 
            UPDATE raitem SET raitem_new_coitem_id=_coitemid WHERE (raitem_id=_i.raitem_id);
65748
 
 
65749
 
          END LOOP;
65750
 
        END IF;
65751
 
      END IF;
65752
 
 
65753
 
 
65754
 
    ELSIF (_r.recv_order_type = 'TO' AND fetchMetricBool('MultiWhs')) THEN
65755
 
      SELECT interWarehouseTransfer(toitem_item_id, tohead_trns_warehous_id,
65756
 
            tohead_dest_warehous_id, _r.recv_qty, 
65757
 
            'TO', formatToNumber(toitem_id), 'Receive from Transit To Dest Warehouse', _itemlocSeries, _glDate ) INTO _tmp
65758
 
      FROM tohead, toitem
65759
 
      WHERE ((tohead_id=toitem_tohead_id)
65760
 
        AND  (toitem_id=_r.recv_orderitem_id));     
65761
 
 
65762
 
      IF (_tmp < 0) THEN
65763
 
            RETURN _tmp;
65764
 
      END IF;
65765
 
 
65766
 
      SELECT insertGLTransaction(fetchJournalNumber('GL-MISC'), 
65767
 
                                  'S/R', _r.recv_order_type, _o.orderhead_number,
65768
 
                                  'Receive Inventory Freight from ' || _o.orderhead_number || ' for item ' || _r.item_number,
65769
 
                                   costcat_toliability_accnt_id,
65770
 
                                   costcat_freight_accnt_id, -1,
65771
 
                                   _r.recv_freight_base,
65772
 
                                   _glDate::DATE, false ),
65773
 
             costcat_freight_accnt_id INTO _tmp, _freightAccnt
65774
 
      FROM itemsite, costcat
65775
 
      WHERE ( (itemsite_costcat_id=costcat_id)
65776
 
       AND (itemsite_id=_r.itemsite_id) );
65777
 
      IF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction
65778
 
            RETURN _tmp;
65779
 
      ELSE
65780
 
        -- Posting to trial balance is deferred to prevent locking
65781
 
        INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries)
65782
 
        VALUES ( _tmp, _itemlocSeries );
65783
 
      END IF;
65784
 
 
65785
 
      UPDATE toitem
65786
 
      SET toitem_qty_received = (toitem_qty_received + _r.recv_qty),
65787
 
          toitem_freight_received = (toitem_freight_received +
65788
 
                                      currToCurr(_r.recv_freight_curr_id,
65789
 
                                                 toitem_freight_curr_id,
65790
 
                                                 _r.recv_freight, _glDate::DATE))
65791
 
      WHERE (toitem_id=_o.orderitem_id);
65792
 
 
65793
 
    END IF;
65794
 
    IF(_r.itemsite_costmethod='A') THEN
65795
 
      _recvvalue := ROUND((_o.item_unitprice_base * _r.recv_qty),2);
65796
 
    ELSIF (fetchMetricBool('RecordPPVonReceipt')) THEN
65797
 
      _recvvalue := ROUND((_o.item_unitprice_base * _r.recv_qty), 2);
65798
 
    ELSE
65799
 
      _recvvalue := ROUND(stdcost(_r.itemsite_item_id) * _recvinvqty, 2);
65800
 
    END IF;
65801
 
  END IF;
65802
 
 
65803
 
  UPDATE recv
65804
 
  SET recv_value=_recvvalue, recv_recvcost=_recvvalue / recv_qty, recv_posted=TRUE, recv_gldistdate=_glDate::DATE
65805
 
  WHERE (recv_id=precvid);
65806
 
  
65807
 
  IF (_r.recv_order_type = 'PO') THEN
65808
 
    -- If this is a drop-shipped PO, then Issue the item to Shipping and Ship the item
65809
 
    IF (_o.pohead_dropship = TRUE) THEN
65810
 
 
65811
 
      -- Generate the PoItemDropShipped event
65812
 
      PERFORM postEvent('PoItemDropShipped', 'P', poitem_id,
65813
 
                        itemsite_warehous_id,
65814
 
                        (pohead_number || '-' || poitem_linenumber || ': ' || item_number),
65815
 
                        NULL, NULL, NULL, NULL)
65816
 
      FROM poitem JOIN itemsite ON (itemsite_id=poitem_itemsite_id)
65817
 
                  JOIN item ON (item_id=itemsite_item_id)
65818
 
                  JOIN pohead ON (pohead_id=poitem_pohead_id)
65819
 
      WHERE (poitem_id=_o.orderitem_id)
65820
 
        AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence));
65821
 
 
65822
 
    END IF;
65823
 
  END IF;
65824
 
  RETURN _itemlocSeries;
65825
 
 
65826
 
END;
65827
 
$_$;
65828
 
 
65829
 
 
65830
 
ALTER FUNCTION public.postreceipt(integer, integer) OWNER TO admin;
65831
 
 
65832
 
--
65833
 
--
65834
 
 
65835
 
CREATE FUNCTION postreceipts(text, integer, integer) RETURNS integer
65836
 
    LANGUAGE plpgsql
65837
 
    AS $_$
65838
 
DECLARE
65839
 
  pordertype            ALIAS FOR $1;
65840
 
  porderid              ALIAS FOR $2;
65841
 
  _itemlocSeries        INTEGER := $3;
65842
 
  _qtyToRecv            NUMERIC;
65843
 
  _r                    RECORD;
65844
 
 
65845
 
BEGIN
65846
 
 
65847
 
  SELECT SUM(qtyToReceive(pordertype, recv_orderitem_id)) INTO _qtyToRecv
65848
 
  FROM recv, orderitem
65849
 
  WHERE ((recv_orderitem_id=orderitem_id)
65850
 
    AND  (recv_order_type=pordertype)
65851
 
    AND  (orderitem_orderhead_type=pordertype)
65852
 
    AND  (orderitem_orderhead_id=porderid));
65853
 
 
65854
 
  IF (_qtyToRecv <= 0) THEN
65855
 
    RETURN -11;
65856
 
  END IF;
65857
 
 
65858
 
  IF (_itemlocSeries IS NULL OR _itemlocSeries <= 0) THEN
65859
 
    _itemlocSeries := NEXTVAL('itemloc_series_seq');
65860
 
  END IF;
65861
 
 
65862
 
  FOR _r IN SELECT postReceipt(recv_id, _itemlocSeries) AS postResult
65863
 
            FROM recv, orderitem
65864
 
            WHERE ((recv_orderitem_id=orderitem_id)
65865
 
              AND  (orderitem_orderhead_id=porderid)
65866
 
              AND  (orderitem_orderhead_type=pordertype)
65867
 
              AND  (NOT recv_posted)
65868
 
              AND  (recv_trans_usr_name=getEffectiveXtUser())
65869
 
              AND  (recv_order_type=pordertype)) LOOP
65870
 
    IF (_r.postResult < 0 AND _r.postResult != -11) THEN
65871
 
      RETURN _r.postResult; -- fail on 1st error but ignore lines with qty == 0
65872
 
    END IF;
65873
 
  END LOOP;
65874
 
 
65875
 
  RETURN _itemlocSeries;
65876
 
END;
65877
 
$_$;
65878
 
 
65879
 
 
65880
 
ALTER FUNCTION public.postreceipts(text, integer, integer) OWNER TO admin;
65881
 
 
65882
 
--
65883
 
--
65884
 
 
65885
 
CREATE FUNCTION postsogltransactions() RETURNS boolean
65886
 
    LANGUAGE plpgsql
65887
 
    AS $$
65888
 
BEGIN
65889
 
 
65890
 
  UPDATE gltrans
65891
 
  SET gltrans_exported=TRUE
65892
 
  WHERE ( (NOT gltrans_exported)
65893
 
   AND (gltrans_source='A/R')
65894
 
   AND (gltrans_doctype IN ('IN', 'CM')) );
65895
 
 
65896
 
  RETURN TRUE;
65897
 
 
65898
 
END;
65899
 
$$;
65900
 
 
65901
 
 
65902
 
ALTER FUNCTION public.postsogltransactions() OWNER TO admin;
65903
 
 
65904
 
--
65905
 
--
65906
 
 
65907
 
CREATE FUNCTION postsoitemproduction(integer, timestamp with time zone) RETURNS integer
65908
 
    LANGUAGE plpgsql
65909
 
    AS $_$
65910
 
DECLARE
65911
 
  pSoitemId      ALIAS FOR $1;
65912
 
  pGlDistTS      ALIAS FOR $2;
65913
 
  _qty NUMERIC;
65914
 
  
65915
 
BEGIN
65916
 
  -- Issuing all, so determine line balance
65917
 
  SELECT noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - 
65918
 
              ( SELECT COALESCE(SUM(shipitem_qty), 0)
65919
 
                FROM shipitem, shiphead
65920
 
                WHERE ((shipitem_orderitem_id=coitem_id)
65921
 
                  AND  (shipitem_shiphead_id=shiphead_id)
65922
 
                  AND  (NOT shiphead_shipped) ) ) ) INTO _qty
65923
 
  FROM coitem
65924
 
  WHERE (coitem_id=pSoitemId);
65925
 
 
65926
 
  RETURN postSoItemProduction($1, _qty, $2);
65927
 
END;
65928
 
$_$;
65929
 
 
65930
 
 
65931
 
ALTER FUNCTION public.postsoitemproduction(integer, timestamp with time zone) OWNER TO admin;
65932
 
 
65933
 
--
65934
 
--
65935
 
 
65936
 
CREATE FUNCTION postsoitemproduction(integer, numeric, timestamp with time zone) RETURNS integer
65937
 
    LANGUAGE plpgsql
65938
 
    AS $_$
65939
 
DECLARE
65940
 
  pSoitemId ALIAS FOR $1;
65941
 
  pQty ALIAS FOR $2;
65942
 
  pGlDistTS ALIAS FOR $3;
65943
 
  _itemlocSeries INTEGER := 0;
65944
 
  
65945
 
BEGIN
65946
 
  --If this cost method is not Job then we are using the wrong function
65947
 
  IF (NOT EXISTS(SELECT itemsite_costmethod
65948
 
             FROM coitem,itemsite
65949
 
             WHERE ((coitem_id=pSoitemId)
65950
 
                AND (coitem_itemsite_id=itemsite_id)
65951
 
                AND (itemsite_costmethod = 'J')))) THEN
65952
 
    RAISE EXCEPTION 'The postSoLineBalanceProduction function may only be used with Job costed item sites';
65953
 
  END IF;
65954
 
 
65955
 
  IF (pQty > 0) THEN
65956
 
    SELECT COALESCE(postProduction(wo_id, (pQty * coitem_qty_invuomratio), true, 0, pGlDistTS),-1) INTO _itemlocSeries
65957
 
    FROM wo, coitem
65958
 
    WHERE ((wo_ordid=pSoItemid)
65959
 
     AND (wo_ordtype='S')
65960
 
     AND (coitem_id=pSoItemid));
65961
 
    
65962
 
    UPDATE wo SET wo_status = 'C'
65963
 
    WHERE ((wo_ordid=pSoItemid)
65964
 
     AND (wo_ordtype='S')
65965
 
     AND (wo_qtyrcv >= wo_qtyord));
65966
 
  END IF;
65967
 
 
65968
 
  RETURN _itemlocSeries;
65969
 
END;
65970
 
$_$;
65971
 
 
65972
 
 
65973
 
ALTER FUNCTION public.postsoitemproduction(integer, numeric, timestamp with time zone) OWNER TO admin;
65974
 
 
65975
 
--
65976
 
--
65977
 
 
65978
 
CREATE FUNCTION poststandardjournal(integer, date) RETURNS integer
65979
 
    LANGUAGE plpgsql
65980
 
    AS $_$
65981
 
DECLARE
65982
 
  pStdjrnlid ALIAS FOR $1;
65983
 
  pDate ALIAS FOR $2;
65984
 
  _returnValue INTEGER;
65985
 
 
65986
 
BEGIN
65987
 
 
65988
 
  SELECT postStandardJournal(pStdjrnlid, pDate, FALSE, fetchGLSequence()) INTO _returnValue;
65989
 
 
65990
 
  RETURN _returnValue;
65991
 
 
65992
 
END;
65993
 
$_$;
65994
 
 
65995
 
 
65996
 
ALTER FUNCTION public.poststandardjournal(integer, date) OWNER TO admin;
65997
 
 
65998
 
--
65999
 
--
66000
 
 
66001
 
CREATE FUNCTION poststandardjournal(integer, date, integer) RETURNS integer
66002
 
    LANGUAGE plpgsql
66003
 
    AS $_$
66004
 
DECLARE
66005
 
  pStdjrnlid ALIAS FOR $1;
66006
 
  pDate ALIAS FOR $2;
66007
 
  pGlSequence ALIAS FOR $3;
66008
 
 
66009
 
BEGIN
66010
 
 
66011
 
  RETURN postStandardJournal(pStdjrnlid, pDate, FALSE, pGLSequence);
66012
 
 
66013
 
END;
66014
 
$_$;
66015
 
 
66016
 
 
66017
 
ALTER FUNCTION public.poststandardjournal(integer, date, integer) OWNER TO admin;
66018
 
 
66019
 
--
66020
 
--
66021
 
 
66022
 
CREATE FUNCTION poststandardjournal(integer, date, boolean) RETURNS integer
66023
 
    LANGUAGE plpgsql
66024
 
    AS $_$
66025
 
DECLARE
66026
 
  pStdjrnlid ALIAS FOR $1;
66027
 
  pDate ALIAS FOR $2;
66028
 
  pReverse ALIAS FOR $3;
66029
 
  _returnValue INTEGER;
66030
 
 
66031
 
BEGIN
66032
 
 
66033
 
  RETURN postStandardJournal(pStdjrnlid, pDate, pReverse, fetchGLSequence());
66034
 
 
66035
 
END;
66036
 
$_$;
66037
 
 
66038
 
 
66039
 
ALTER FUNCTION public.poststandardjournal(integer, date, boolean) OWNER TO admin;
66040
 
 
66041
 
--
66042
 
--
66043
 
 
66044
 
CREATE FUNCTION poststandardjournal(integer, date, boolean, integer) RETURNS integer
66045
 
    LANGUAGE plpgsql
66046
 
    AS $_$
66047
 
DECLARE
66048
 
  pStdjrnlid ALIAS FOR $1;
66049
 
  pDate ALIAS FOR $2;
66050
 
  pReverse ALIAS FOR $3;
66051
 
  pGlSequence ALIAS FOR $4;
66052
 
 
66053
 
BEGIN
66054
 
 
66055
 
  INSERT INTO glseries
66056
 
  ( glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber,
66057
 
    glseries_notes, glseries_accnt_id, glseries_amount, glseries_distdate )
66058
 
  SELECT pGlSequence, 'G/L', 'ST', stdjrnl_name,
66059
 
         stdjrnlitem_notes, stdjrnlitem_accnt_id,
66060
 
         CASE WHEN (pReverse=TRUE) THEN (stdjrnlitem_amount * -1)
66061
 
              ELSE stdjrnlitem_amount
66062
 
         END,
66063
 
         pDate
66064
 
  FROM stdjrnlitem, stdjrnl
66065
 
  WHERE ( (stdjrnlitem_stdjrnl_id=stdjrnl_id)
66066
 
   AND (stdjrnl_id=pStdjrnlid) );
66067
 
 
66068
 
  RETURN pGlSequence;
66069
 
 
66070
 
END;
66071
 
$_$;
66072
 
 
66073
 
 
66074
 
ALTER FUNCTION public.poststandardjournal(integer, date, boolean, integer) OWNER TO admin;
66075
 
 
66076
 
--
66077
 
--
66078
 
 
66079
 
CREATE FUNCTION poststandardjournalgroup(integer, date) RETURNS integer
66080
 
    LANGUAGE plpgsql
66081
 
    AS $_$
66082
 
DECLARE
66083
 
  pStdjrnlgrpid ALIAS FOR $1;
66084
 
  pDate ALIAS FOR $2;
66085
 
BEGIN
66086
 
  RETURN postStandardJournalGroup(pStdjrnlgrpid, pDate, FALSE);
66087
 
END;
66088
 
$_$;
66089
 
 
66090
 
 
66091
 
ALTER FUNCTION public.poststandardjournalgroup(integer, date) OWNER TO admin;
66092
 
 
66093
 
--
66094
 
--
66095
 
 
66096
 
CREATE FUNCTION poststandardjournalgroup(integer, date, boolean) RETURNS integer
66097
 
    LANGUAGE plpgsql
66098
 
    AS $_$
66099
 
DECLARE
66100
 
  pStdjrnlgrpid ALIAS FOR $1;
66101
 
  pDate ALIAS FOR $2;
66102
 
  pReverse ALIAS FOR $3;
66103
 
  _r RECORD;
66104
 
  _glSequence INTEGER := -1;
66105
 
 
66106
 
BEGIN
66107
 
 
66108
 
  FOR _r IN SELECT stdjrnlgrpitem_id, stdjrnlgrpitem_stdjrnl_id
66109
 
            FROM stdjrnlgrpitem
66110
 
            WHERE ( (stdjrnlgrpitem_stdjrnlgrp_id=pStdjrnlgrpid)
66111
 
             AND (CURRENT_DATE BETWEEN stdjrnlgrpitem_effective AND (stdjrnlgrpitem_expires - 1))
66112
 
             AND ( (stdjrnlgrpitem_toapply = -1)
66113
 
              OR (stdjrnlgrpitem_toapply > stdjrnlgrpitem_applied) ) ) LOOP
66114
 
 
66115
 
    IF (_glSequence = -1) THEN
66116
 
      SELECT fetchGLSequence() INTO _glSequence;
66117
 
    END IF;
66118
 
 
66119
 
    PERFORM postStandardJournal(_r.stdjrnlgrpitem_stdjrnl_id, pDate, pReverse, _glSequence);
66120
 
 
66121
 
    UPDATE stdjrnlgrpitem
66122
 
    SET stdjrnlgrpitem_applied=(stdjrnlgrpitem_applied + 1)
66123
 
    WHERE (stdjrnlgrpitem_id=_r.stdjrnlgrpitem_id);
66124
 
 
66125
 
  END LOOP;
66126
 
 
66127
 
  RETURN _glSequence;
66128
 
 
66129
 
END;
66130
 
$_$;
66131
 
 
66132
 
 
66133
 
ALTER FUNCTION public.poststandardjournalgroup(integer, date, boolean) OWNER TO admin;
66134
 
 
66135
 
--
66136
 
--
66137
 
 
66138
 
CREATE FUNCTION postvalueintoinvbalance(integer, date, numeric, numeric, numeric, numeric) RETURNS boolean
66139
 
    LANGUAGE plpgsql
66140
 
    AS $_$
66141
 
DECLARE
66142
 
  pItemsiteId ALIAS FOR $1;
66143
 
  pDate ALIAS FOR $2;
66144
 
  pQoh ALIAS FOR $3;
66145
 
  pNn ALIAS FOR $4;
66146
 
  pOldCost ALIAS FOR $5;
66147
 
  pNewCost ALIAS FOR $6;
66148
 
  _invbalid INTEGER;
66149
 
  _r RECORD;
66150
 
  _count INTEGER;
66151
 
  _valChange NUMERIC;
66152
 
  _nnvalChange NUMERIC;
66153
 
 
66154
 
BEGIN
66155
 
 
66156
 
  SELECT period_id INTO _r
66157
 
  FROM period
66158
 
  WHERE (pDate BETWEEN period_start AND period_end);
66159
 
 
66160
 
  GET DIAGNOSTICS _count = ROW_COUNT;
66161
 
  
66162
 
  IF ( _count > 0 ) THEN
66163
 
    SELECT invbal_id INTO _invbalid
66164
 
    FROM invbal
66165
 
    WHERE ( (invbal_period_id=_r.period_id)
66166
 
      AND (invbal_itemsite_id=pItemsiteId) );
66167
 
 
66168
 
    GET DIAGNOSTICS _count = ROW_COUNT;
66169
 
    IF (_count = 0) THEN
66170
 
      -- Wasn't there, so forward update
66171
 
      PERFORM forwardUpdateItemsite(pItemsiteId);
66172
 
 
66173
 
      --  Try to find an existing invbal again
66174
 
      SELECT invbal_id INTO _invbalid
66175
 
      FROM invbal
66176
 
      WHERE ( (invbal_period_id=_r.period_id)
66177
 
        AND (invbal_itemsite_id=pItemsiteId) );
66178
 
 
66179
 
      GET DIAGNOSTICS _count = ROW_COUNT;
66180
 
      IF (_count = 0) THEN
66181
 
        RAISE EXCEPTION 'An inventory balance record was not found for updating standard costs';
66182
 
      END IF;
66183
 
    END IF;
66184
 
 
66185
 
    _valChange := round((pNewCost - pOldCost) * pQoh, 2);
66186
 
    _nnvalChange := round((pNewCost - pOldCost) * pNn, 2);
66187
 
    
66188
 
    IF (_valChange > 0) THEN
66189
 
      UPDATE invbal SET 
66190
 
        invbal_value_in = (invbal_value_in + _valChange)
66191
 
      WHERE (invbal_id=_invbalid);
66192
 
    ELSE
66193
 
      UPDATE invbal SET 
66194
 
        invbal_value_out = (invbal_value_out - _valChange)
66195
 
      WHERE (invbal_id=_invbalid);
66196
 
    END IF;
66197
 
 
66198
 
    IF (_nnvalChange > 0) THEN
66199
 
      UPDATE invbal SET 
66200
 
        invbal_nnval_in = (invbal_nnval_in + _nnvalChange)
66201
 
      WHERE (invbal_id=_invbalid);
66202
 
    ELSE
66203
 
      UPDATE invbal SET 
66204
 
        invbal_nnval_out = (invbal_nnval_out - _nnvalChange)
66205
 
      WHERE (invbal_id=_invbalid);
66206
 
    END IF;
66207
 
 
66208
 
    UPDATE invbal SET 
66209
 
      invbal_value_ending = (invbal_value_beginning + invbal_value_in - invbal_value_out),
66210
 
      invbal_nnval_ending = (invbal_nnval_beginning + invbal_nnval_in - invbal_nnval_out),
66211
 
      invbal_dirty=true
66212
 
    WHERE (invbal_id=_invbalid);  
66213
 
 
66214
 
  ELSE
66215
 
    RAISE EXCEPTION 'No period exists for date %.', pDate;
66216
 
  END IF;
66217
 
 
66218
 
  RETURN TRUE;
66219
 
 
66220
 
END;
66221
 
$_$;
66222
 
 
66223
 
 
66224
 
ALTER FUNCTION public.postvalueintoinvbalance(integer, date, numeric, numeric, numeric, numeric) OWNER TO admin;
66225
 
 
66226
 
--
66227
 
--
66228
 
 
66229
 
CREATE FUNCTION postvoucher(integer, boolean) RETURNS integer
66230
 
    LANGUAGE plpgsql
66231
 
    AS $_$
66232
 
DECLARE
66233
 
  pVoheadid ALIAS FOR $1;
66234
 
  pPostCosts ALIAS FOR $2;
66235
 
 
66236
 
BEGIN
66237
 
  RETURN postVoucher(pVoheadid, fetchJournalNumber('AP-VO'), pPostCosts);
66238
 
END;
66239
 
$_$;
66240
 
 
66241
 
 
66242
 
ALTER FUNCTION public.postvoucher(integer, boolean) OWNER TO admin;
66243
 
 
66244
 
--
66245
 
--
66246
 
 
66247
 
CREATE FUNCTION postvoucher(integer, integer, boolean) RETURNS integer
66248
 
    LANGUAGE plpgsql
66249
 
    AS $_$
66250
 
DECLARE
66251
 
  pVoheadid ALIAS FOR $1;
66252
 
  pJournalNumber ALIAS FOR $2;
66253
 
  pPostCosts ALIAS FOR $3;
66254
 
  _sequence INTEGER;
66255
 
  _totalAmount_base NUMERIC;
66256
 
  _totalAmount NUMERIC;
66257
 
  _itemAmount_base NUMERIC;
66258
 
  _itemAmount NUMERIC;
66259
 
  _totalDiscountableAmount NUMERIC;
66260
 
  _test INTEGER;
66261
 
  _a RECORD;
66262
 
  _d RECORD;
66263
 
  _g RECORD;
66264
 
  _p RECORD;
66265
 
  _r RECORD;
66266
 
  _costx RECORD;
66267
 
  _pPostCosts BOOLEAN;
66268
 
  _pExplain BOOLEAN;
66269
 
  _pLowLevel BOOLEAN;
66270
 
  _exchGainFreight NUMERIC;
66271
 
  _taxBaseValue NUMERIC;
66272
 
  _firstExchDateFreight DATE;
66273
 
  _tmpTotal             NUMERIC;
66274
 
  _glDate               DATE;
66275
 
 
66276
 
BEGIN
66277
 
 
66278
 
  RAISE DEBUG 'postVoucher(%, %, %)', pVoheadid, pJournalNumber, pPostCosts;
66279
 
 
66280
 
  _pPostCosts := TRUE;
66281
 
  _totalAmount_base := 0;
66282
 
  _totalAmount := 0;
66283
 
  _totalDiscountableAmount := 0;
66284
 
  SELECT fetchGLSequence() INTO _sequence;
66285
 
 
66286
 
  SELECT vohead.*,
66287
 
         vend_number || '-' || vend_name || ' ' || vohead_reference
66288
 
                                                          AS glnotes,
66289
 
         COALESCE(pohead_orderdate, vohead_docdate) AS pohead_orderdate,
66290
 
         COALESCE(pohead_curr_id, vohead_curr_id) AS pohead_curr_id INTO _p
66291
 
  FROM vendinfo, vohead LEFT OUTER JOIN pohead ON (vohead_pohead_id = pohead_id)
66292
 
  WHERE ( (vohead_id=pVoheadid)
66293
 
  AND (vend_id=vohead_vend_id) )
66294
 
  FOR UPDATE OF vohead;
66295
 
 
66296
 
  IF (_p.vohead_posted) THEN
66297
 
    RAISE EXCEPTION 'Cannot post Voucher #% as it is already posted [xtuple: postVoucher, -10, %]',
66298
 
                        _p.vohead_number, _p.vohead_number;
66299
 
  END IF;
66300
 
 
66301
 
  _glDate := COALESCE(_p.vohead_gldistdate, _p.vohead_distdate);
66302
 
 
66303
 
  IF (_p.vohead_distdate IS NULL) THEN
66304
 
    DELETE FROM vohead WHERE vohead_id = pVoheadid;
66305
 
    RETURN 0;
66306
 
  END IF;
66307
 
  IF (_p.vohead_amount <= 0) THEN
66308
 
    RAISE EXCEPTION 'Cannot Post Voucher #% for a negative or zero amount (%) [xtuple: postVoucher, -1, %, %]',
66309
 
                        _p.vohead_number, _p.vohead_amount,
66310
 
                        _p.vohead_number, _p.vohead_amount;
66311
 
  END IF;
66312
 
 
66313
 
  SELECT recv_date::DATE INTO _firstExchDateFreight
66314
 
      FROM recv
66315
 
      WHERE (recv_vohead_id = pVoheadid);
66316
 
 
66317
 
  SELECT round(SUM(amount),4) INTO _tmpTotal
66318
 
  FROM (
66319
 
  SELECT SUM(vodist_amount) AS amount
66320
 
    FROM vodist
66321
 
   WHERE ( (vodist_vohead_id=pVoheadid)
66322
 
     AND   (vodist_tax_id=-1) )
66323
 
  UNION ALL
66324
 
  SELECT SUM(voitem_freight) AS amount
66325
 
    FROM voitem
66326
 
   WHERE (voitem_vohead_id=pVoheadid)
66327
 
  UNION ALL
66328
 
  SELECT SUM(tax*-1)
66329
 
  FROM 
66330
 
    (SELECT round(sum(taxdetail_tax),2) AS tax,
66331
 
              currToBase(_p.vohead_curr_id, round(sum(taxdetail_tax),2), _p.vohead_docdate) AS taxbasevalue
66332
 
     FROM tax 
66333
 
     JOIN calculateTaxDetailSummary('VO', pVoheadid, 'T') ON (taxdetail_tax_id=tax_id)
66334
 
     GROUP BY tax_id, tax_sales_accnt_id
66335
 
    ) AS taxdata
66336
 
  ) AS data;
66337
 
 
66338
 
  IF (_tmpTotal IS NULL OR _tmpTotal <= 0) THEN
66339
 
    RAISE EXCEPTION 'Cannot Post Voucher #% with negative or zero distributions (%) [xtuple: postVoucher, -2, %, %]',
66340
 
                        _p.vohead_number, _tmpTotal,
66341
 
                        _p.vohead_number, _tmpTotal;
66342
 
  END IF;
66343
 
 
66344
 
  IF (_tmpTotal > _p.vohead_amount) THEN
66345
 
    RAISE EXCEPTION 'Cannot Post Voucher #% with distributions greater than the voucher amount (% > %) [xtuple: postVoucher, -3, %, %, %]',
66346
 
                        _p.vohead_number, _tmpTotal, _p.vohead_amount,
66347
 
                        _p.vohead_number, _tmpTotal, _p.vohead_amount;
66348
 
  END IF;
66349
 
 
66350
 
  IF (_tmpTotal < _p.vohead_amount) THEN
66351
 
    RAISE EXCEPTION 'Cannot Post Voucher #% with distributions less than the voucher amount (% < %) [xtuple: postVoucher, -4, %, %, %]',
66352
 
                        _p.vohead_number, _tmpTotal, _p.vohead_amount,
66353
 
                        _p.vohead_number, _tmpTotal, _p.vohead_amount;
66354
 
  END IF;
66355
 
 
66356
 
  SELECT DISTINCT poitem_linenumber INTO _test
66357
 
    FROM vodist, voitem, poitem 
66358
 
   WHERE ( (vodist_poitem_id=poitem_id)
66359
 
     AND   (voitem_poitem_id=poitem_id)
66360
 
     AND   (voitem_vohead_id=vodist_vohead_id)
66361
 
     AND   ((poitem_qty_received - poitem_qty_vouchered) = 0)
66362
 
     AND   (vodist_vohead_id=pVoheadid) )
66363
 
   LIMIT 1;
66364
 
  IF (FOUND) THEN
66365
 
    RAISE EXCEPTION 'Cannot Post Voucher #% as one or more of the line items have already been fully vouchered. Check P/O Line #% [postVoucher, -6, %, %]',
66366
 
         _p.vohead_number, _test,
66367
 
         _p.vohead_number, _test;
66368
 
  END IF;
66369
 
 
66370
 
  FOR _r IN SELECT tax_sales_accnt_id, 
66371
 
              round(sum(taxdetail_tax),2) AS tax,
66372
 
              currToBase(_p.vohead_curr_id, round(sum(taxdetail_tax),2), _p.vohead_docdate) AS taxbasevalue
66373
 
            FROM tax 
66374
 
             JOIN calculateTaxDetailSummary('VO', pVoheadid, 'T') ON (taxdetail_tax_id=tax_id)
66375
 
            GROUP BY tax_id, tax_sales_accnt_id LOOP
66376
 
 
66377
 
    PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', _p.vohead_number,
66378
 
                                _r.tax_sales_accnt_id, 
66379
 
                                _r.taxbasevalue,
66380
 
                                _glDate, _p.glnotes );
66381
 
 
66382
 
    RAISE DEBUG 'postVoucher: _r.tax=%', _r.tax;
66383
 
 
66384
 
    _totalAmount_base := (_totalAmount_base - _r.taxbasevalue);
66385
 
    _totalAmount := (_totalAmount - _r.tax);
66386
 
     
66387
 
  END LOOP;
66388
 
 
66389
 
    UPDATE voitemtax SET 
66390
 
      taxhist_docdate=_p.vohead_docdate,
66391
 
      taxhist_distdate=_glDate,
66392
 
      taxhist_curr_id=_p.vohead_curr_id,
66393
 
      taxhist_curr_rate=curr_rate,
66394
 
      taxhist_journalnumber=pJournalNumber
66395
 
    FROM vohead
66396
 
     JOIN voitem ON (vohead_id=voitem_vohead_id), 
66397
 
     curr_rate
66398
 
    WHERE ((vohead_id=pVoheadId)
66399
 
      AND (taxhist_parent_id=voitem_id)
66400
 
      AND (_p.vohead_curr_id=curr_id)
66401
 
      AND (_p.vohead_docdate BETWEEN curr_effective 
66402
 
                           AND curr_expires) );
66403
 
 
66404
 
    UPDATE voheadtax SET 
66405
 
      taxhist_docdate=_p.vohead_docdate,
66406
 
      taxhist_distdate=_glDate,
66407
 
      taxhist_curr_id=_p.vohead_curr_id,
66408
 
      taxhist_curr_rate=curr_rate,
66409
 
      taxhist_journalnumber=pJournalNumber
66410
 
    FROM curr_rate
66411
 
    WHERE ((taxhist_parent_id=pVoheadid)
66412
 
      AND (_p.vohead_curr_id=curr_id)
66413
 
      AND (_p.vohead_docdate BETWEEN curr_effective 
66414
 
                           AND curr_expires) );
66415
 
 
66416
 
  FOR _g IN SELECT DISTINCT poitem_id, voitem_id, voitem_qty, poitem_expcat_id,
66417
 
                            poitem_invvenduomratio, poitem_prj_id,
66418
 
                            COALESCE(itemsite_id, -1) AS itemsiteid,
66419
 
                            COALESCE(itemsite_costcat_id, -1) AS costcatid,
66420
 
                            COALESCE(itemsite_item_id, -1) AS itemsite_item_id,
66421
 
                            (SELECT SUM(value) 
66422
 
                             FROM (
66423
 
                                SELECT SUM(recv_value) AS value
66424
 
                                FROM recv
66425
 
                                WHERE (recv_voitem_id=voitem_id)
66426
 
                             UNION
66427
 
                                SELECT SUM(poreject_value)*-1 AS value
66428
 
                                FROM poreject
66429
 
                                WHERE (poreject_voitem_id=voitem_id)) as data)
66430
 
                           AS value_base,
66431
 
                           (poitem_freight_received - poitem_freight_vouchered) /
66432
 
                               (poitem_qty_received - poitem_qty_vouchered) * voitem_qty AS vouchered_freight,
66433
 
                            currToBase(_p.pohead_curr_id,
66434
 
                                       (poitem_freight_received - poitem_freight_vouchered) /
66435
 
                                       (poitem_qty_received - poitem_qty_vouchered) * voitem_qty,
66436
 
                                        _firstExchDateFreight ) AS vouchered_freight_base,
66437
 
                            voitem_freight,
66438
 
                            currToBase(_p.vohead_curr_id, voitem_freight,
66439
 
                                       _p.vohead_distdate) AS voitem_freight_base
66440
 
            FROM vodist, voitem,
66441
 
                 poitem LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)
66442
 
            WHERE ( (vodist_poitem_id=poitem_id)
66443
 
             AND (voitem_poitem_id=poitem_id)
66444
 
             AND (voitem_vohead_id=vodist_vohead_id)
66445
 
             AND (vodist_vohead_id=pVoheadid)) LOOP
66446
 
 
66447
 
    IF (_g.costcatid = -1) THEN
66448
 
      SELECT getPrjAccntId(_g.poitem_prj_id, pp.accnt_id) AS pp_accnt_id,
66449
 
             lb.accnt_id AS lb_accnt_id,
66450
 
             fr.accnt_id AS freight_accnt_id INTO _a
66451
 
      FROM expcat, accnt AS pp, accnt AS lb, accnt AS fr
66452
 
      WHERE ( (expcat_purchprice_accnt_id=pp.accnt_id)
66453
 
       AND (expcat_liability_accnt_id=lb.accnt_id)
66454
 
       AND (expcat_freight_accnt_id=fr.accnt_id)
66455
 
       AND (expcat_id=_g.poitem_expcat_id) );
66456
 
      IF (NOT FOUND) THEN
66457
 
        RAISE EXCEPTION 'Cannot Post Voucher #% due to unassigned G/L Accounts [xtuple: postVoucher, -7, %]',
66458
 
                        _p.vohead_number, _p.vohead_number;
66459
 
      END IF;
66460
 
    ELSE
66461
 
      SELECT getPrjAccntId(_g.poitem_prj_id, costcat_purchprice_accnt_id) AS pp_accnt_id,
66462
 
             getPrjAccntId(_g.poitem_prj_id, costcat_liability_accnt_id) AS lb_accnt_id,
66463
 
             getPrjAccntId(_g.poitem_prj_id, costcat_freight_accnt_id) AS freight_accnt_id
66464
 
      INTO _a
66465
 
      FROM costcat
66466
 
      WHERE (costcat_id=_g.costcatid);
66467
 
      IF (NOT FOUND) THEN
66468
 
        RAISE EXCEPTION 'Cannot Post Voucher #% due to unassigned G/L Accounts [xtuple: postVoucher, -8, %]',
66469
 
                        _p.vohead_number, _p.vohead_number;
66470
 
      END IF;
66471
 
    END IF;
66472
 
 
66473
 
    _itemAmount_base := 0;
66474
 
    _itemAmount := 0;
66475
 
 
66476
 
    FOR _d IN SELECT vodist_id, vodist_amount, vodist_discountable,
66477
 
                     _p.vohead_curr_id, vodist_costelem_id,
66478
 
                     currToBase(_p.vohead_curr_id, vodist_amount,
66479
 
                                _p.vohead_distdate) AS vodist_amount_base
66480
 
              FROM vodist
66481
 
              WHERE ( (vodist_vohead_id=pVoheadid)
66482
 
               AND (vodist_poitem_id=_g.poitem_id) ) LOOP
66483
 
 
66484
 
       _pExplain := FALSE;
66485
 
       SELECT * INTO _costx
66486
 
         FROM itemcost
66487
 
        WHERE ( (itemcost_item_id = _g.itemsite_item_id)
66488
 
          AND   (itemcost_costelem_id = _d.vodist_costelem_id) );
66489
 
 
66490
 
       IF (FOUND) THEN
66491
 
         _pExplain := _costx.itemcost_lowlevel;
66492
 
       END IF;
66493
 
 
66494
 
      IF ( (_d.vodist_costelem_id <> -1) AND (_g.itemsite_item_id <> -1) ) THEN
66495
 
        PERFORM updateCost( _g.itemsite_item_id, _d.vodist_costelem_id,
66496
 
                            _pExplain, (_d.vodist_amount / (_g.voitem_qty * _g.poitem_invvenduomratio)),
66497
 
                            _p.vohead_curr_id );
66498
 
      END IF;
66499
 
 
66500
 
      RAISE DEBUG 'postVoucher: _d.vodist_amount=%', _d.vodist_amount;
66501
 
 
66502
 
      _itemAmount_base := _itemAmount_base + ROUND(_d.vodist_amount_base, 2);
66503
 
      _itemAmount := _itemAmount + _d.vodist_amount;
66504
 
      IF (_d.vodist_discountable) THEN
66505
 
        _totalDiscountableAmount := (_totalDiscountableAmount + _d.vodist_amount);
66506
 
      END IF;
66507
 
 
66508
 
    END LOOP;
66509
 
 
66510
 
    PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number),
66511
 
                _a.lb_accnt_id,
66512
 
                round(_g.value_base + _g.vouchered_freight_base, 2) * -1,
66513
 
                _glDate, _p.glnotes );
66514
 
 
66515
 
 
66516
 
    _exchGainFreight := 0;
66517
 
    SELECT currGain(_p.pohead_curr_id, _g.vouchered_freight,
66518
 
                    _firstExchDateFreight, _p.vohead_distdate )
66519
 
                    INTO _exchGainFreight;
66520
 
    IF (round(_exchGainFreight, 2) <> 0) THEN
66521
 
        PERFORM insertIntoGLSeries(_sequence, 'A/P', 'VO',
66522
 
            text(_p.vohead_number),
66523
 
            getGainLossAccntId(_a.lb_accnt_id), round(_exchGainFreight, 2),
66524
 
           _glDate, _p.glnotes);
66525
 
    END IF;
66526
 
 
66527
 
    IF (round(_itemAmount_base, 2) <> round(_g.value_base, 2)) THEN
66528
 
      _tmpTotal := round(_itemAmount_base, 2) - round(_g.value_base, 2);
66529
 
      PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number),
66530
 
                                  _a.pp_accnt_id,
66531
 
                                  _tmpTotal * -1,
66532
 
                                  _glDate, _p.glnotes );
66533
 
    END IF;
66534
 
 
66535
 
    IF (round(_g.voitem_freight_base + _exchGainFreight, 2) <> round(_g.vouchered_freight_base, 2)) THEN
66536
 
      _tmpTotal := round(_g.voitem_freight_base + _exchGainFreight, 2) - round(_g.vouchered_freight_base, 2);
66537
 
      PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number),
66538
 
        _a.freight_accnt_id,
66539
 
              _tmpTotal * -1,
66540
 
              _glDate, _p.glnotes );
66541
 
    END IF;
66542
 
 
66543
 
    RAISE DEBUG 'postVoucher: _itemAmount=%', _itemAmount;
66544
 
 
66545
 
    _totalAmount_base := (_totalAmount_base + _itemAmount_base + _g.voitem_freight_base);
66546
 
    _totalAmount := (_totalAmount + _itemAmount + _g.voitem_freight);
66547
 
 
66548
 
    UPDATE recv
66549
 
    SET recv_invoiced=TRUE,
66550
 
        recv_recvcost_curr_id=basecurrid(),
66551
 
        recv_recvcost=round(_g.value_base / _g.voitem_qty, 2)
66552
 
    FROM poitem
66553
 
    WHERE ((recv_orderitem_id=poitem_id)
66554
 
      AND  (recv_order_type='PO')
66555
 
      AND  (recv_orderitem_id=_g.poitem_id)
66556
 
      AND  (recv_vohead_id=pVoheadid) );
66557
 
 
66558
 
    UPDATE poreject
66559
 
    SET poreject_invoiced=TRUE
66560
 
    WHERE ( (poreject_poitem_id=_g.poitem_id)
66561
 
     AND (poreject_vohead_id=pVoheadid) );
66562
 
 
66563
 
    UPDATE poitem
66564
 
       SET poitem_qty_vouchered = (poitem_qty_vouchered + _g.voitem_qty),
66565
 
           poitem_freight_vouchered = (poitem_freight_vouchered + _g.vouchered_freight)
66566
 
     WHERE (poitem_id=_g.poitem_id);
66567
 
 
66568
 
  END LOOP;
66569
 
 
66570
 
  FOR _d IN SELECT vodist_id, vodist_discountable,
66571
 
                   currToBase(_p.vohead_curr_id, vodist_amount,
66572
 
                              _p.vohead_distdate) AS vodist_amount_base,
66573
 
                   vodist_amount,
66574
 
                   vodist_accnt_id, vodist_expcat_id
66575
 
            FROM vodist
66576
 
            WHERE ( (vodist_vohead_id=pVoheadid)
66577
 
             AND (vodist_poitem_id=-1)
66578
 
             AND (vodist_tax_id=-1) ) LOOP
66579
 
 
66580
 
    IF (_d.vodist_accnt_id = -1) THEN
66581
 
      PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number),
66582
 
                          expcat_exp_accnt_id,
66583
 
                          round(_d.vodist_amount_base, 2) * -1,
66584
 
                          _glDate, _p.glnotes )
66585
 
         FROM expcat
66586
 
        WHERE (expcat_id=_d.vodist_expcat_id);
66587
 
    ELSE
66588
 
      PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number),
66589
 
                          _d.vodist_accnt_id,
66590
 
                          round(_d.vodist_amount_base, 2) * -1,
66591
 
                          _glDate, _p.glnotes );
66592
 
    END IF;
66593
 
 
66594
 
    RAISE DEBUG 'postVoucher: _d.vodist_amount=%', _d.vodist_amount;
66595
 
 
66596
 
    _totalAmount_base := _totalAmount_base + ROUND(_d.vodist_amount_base, 2);
66597
 
    _totalAmount := _totalAmount + _d.vodist_amount;
66598
 
    IF (_d.vodist_discountable) THEN
66599
 
      _totalDiscountableAmount := (_totalDiscountableAmount + _d.vodist_amount);
66600
 
    END IF;
66601
 
 
66602
 
  END LOOP;
66603
 
 
66604
 
  SELECT insertIntoGLSeries( _sequence, 'A/P', 'VO', text(vohead_number),
66605
 
                             accnt_id, round(_totalAmount_base, 2),
66606
 
                             _glDate, _p.glnotes ) INTO _test
66607
 
  FROM vohead LEFT OUTER JOIN accnt ON (accnt_id=findAPAccount(vohead_vend_id))
66608
 
  WHERE ( (findAPAccount(vohead_vend_id)=0 OR accnt_id > 0) -- G/L interface might be disabled
66609
 
    AND (vohead_id=pVoheadid) );
66610
 
  IF (NOT FOUND) THEN
66611
 
    RAISE EXCEPTION 'Cannot Post Voucher #% due to an unassigned A/P Account [xtuple: postVoucher, -9, %]',
66612
 
                    _p.vohead_number, _p.vohead_number;
66613
 
  END IF;
66614
 
 
66615
 
  PERFORM postGLSeries(_sequence, pJournalNumber);
66616
 
 
66617
 
  RAISE DEBUG 'postVoucher: _totalAmount=%, _totalDiscountableAmount=%',
66618
 
                _totalAmount, _totalDiscountableAmount;
66619
 
 
66620
 
  INSERT INTO apopen
66621
 
  ( apopen_journalnumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_open,
66622
 
    apopen_terms_id, apopen_vend_id, apopen_doctype,
66623
 
    apopen_docnumber, apopen_invcnumber, apopen_ponumber, apopen_reference,
66624
 
    apopen_amount, apopen_paid, apopen_notes, apopen_username, apopen_posted,
66625
 
    apopen_curr_id, apopen_discountable_amount )
66626
 
  SELECT pJournalNumber, vohead_docdate, vohead_duedate, _glDate, TRUE,
66627
 
         vohead_terms_id, vohead_vend_id, 'V',
66628
 
         vohead_number, vohead_invcnumber, COALESCE(TEXT(pohead_number), 'Misc.'), vohead_reference,
66629
 
         round(_totalAmount, 2), 0, '', getEffectiveXtUser(), FALSE,
66630
 
         vohead_curr_id, round(_totalDiscountableAmount, 2)
66631
 
  FROM vohead LEFT OUTER JOIN pohead ON (vohead_pohead_id=pohead_id)
66632
 
  WHERE (vohead_id=pVoheadid);
66633
 
 
66634
 
  UPDATE poitem
66635
 
  SET poitem_status='C'
66636
 
  FROM voitem
66637
 
  WHERE ( (voitem_poitem_id=poitem_id)
66638
 
   AND (voitem_close)
66639
 
   AND (voitem_vohead_id=pVoheadid) );
66640
 
 
66641
 
  IF ( (SELECT (count(*) < 1)
66642
 
          FROM vohead, poitem
66643
 
         WHERE ((vohead_pohead_id=poitem_pohead_id)
66644
 
           AND  (poitem_status<>'C')
66645
 
           AND  (vohead_id=pVoheadid) ) ) ) THEN
66646
 
    PERFORM closePo(vohead_pohead_id)
66647
 
       FROM vohead
66648
 
      WHERE (vohead_id=pVoheadid);
66649
 
  END IF;
66650
 
 
66651
 
  UPDATE vohead
66652
 
  SET vohead_posted=TRUE, vohead_gldistdate=_glDate
66653
 
  WHERE (vohead_id=pVoheadid);
66654
 
 
66655
 
  RETURN pJournalNumber;
66656
 
 
66657
 
END;
66658
 
$_$;
66659
 
 
66660
 
 
66661
 
ALTER FUNCTION public.postvoucher(integer, integer, boolean) OWNER TO admin;
66662
 
 
66663
 
--
66664
 
--
66665
 
 
66666
 
CREATE FUNCTION postvouchers(boolean) RETURNS integer
66667
 
    LANGUAGE plpgsql
66668
 
    AS $_$
66669
 
DECLARE
66670
 
  pPostCosts ALIAS FOR $1;
66671
 
  _journalNumber INTEGER;
66672
 
 
66673
 
BEGIN
66674
 
 
66675
 
  SELECT fetchJournalNumber('AP-VO') INTO _journalNumber;
66676
 
 
66677
 
  PERFORM postVoucher(vohead_id, _journalNumber, pPostCosts)
66678
 
  FROM vohead
66679
 
  WHERE (NOT vohead_posted);
66680
 
 
66681
 
  RETURN _journalNumber;
66682
 
 
66683
 
END;
66684
 
$_$;
66685
 
 
66686
 
 
66687
 
ALTER FUNCTION public.postvouchers(boolean) OWNER TO admin;
66688
 
 
66689
 
--
66690
 
--
66691
 
 
66692
 
CREATE FUNCTION primarykeyfields(text, text) RETURNS text[]
66693
 
    LANGUAGE plpgsql STABLE
66694
 
    AS $_$ 
66695
 
DECLARE
66696
 
  pSchema       ALIAS FOR $1;
66697
 
  pRelation     ALIAS FOR $2;
66698
 
  _colname      TEXT;
66699
 
  _counter      INTEGER := 0;
66700
 
  _result       TEXT[];
66701
 
 
66702
 
BEGIN
66703
 
  EXECUTE 'SELECT ARRAY(SELECT attname
66704
 
                         FROM pg_attribute
66705
 
                         JOIN pg_class idx ON (attrelid         = idx.oid)
66706
 
                         JOIN pg_namespace ON (idx.relnamespace = pg_namespace.oid)
66707
 
                         JOIN pg_index     ON (idx.oid          = indexrelid)
66708
 
                         JOIN pg_class tab ON (indrelid         = tab.oid)
66709
 
                        WHERE NOT attisdropped
66710
 
                          AND nspname = ''' || pSchema || ''' 
66711
 
                          AND indisprimary
66712
 
                          AND LOWER(tab.relname) = ''' || pRelation || '''
66713
 
                       ORDER BY attnum);'
66714
 
  INTO _result;
66715
 
 
66716
 
  RETURN _result;
66717
 
END;
66718
 
$_$;
66719
 
 
66720
 
 
66721
 
ALTER FUNCTION public.primarykeyfields(text, text) OWNER TO admin;
66722
 
 
66723
 
--
66724
 
--
66725
 
 
66726
 
COMMENT ON FUNCTION primarykeyfields(text, text) IS 'Return an array containing the names of the primary key fields of pSchema.pRelation. The first key field is in _result[1].';
66727
 
 
66728
 
 
66729
 
--
66730
 
--
66731
 
 
66732
 
CREATE FUNCTION prj() RETURNS SETOF prj
66733
 
    LANGUAGE plpgsql
66734
 
    AS $$
66735
 
DECLARE
66736
 
  _row prj%ROWTYPE;
66737
 
  _priv TEXT;
66738
 
  _grant BOOLEAN;
66739
 
 
66740
 
BEGIN
66741
 
  -- This query will give us the most permissive privilege the user has been granted
66742
 
  SELECT privilege, granted INTO _priv, _grant
66743
 
  FROM privgranted 
66744
 
  WHERE privilege IN ('MaintainAllProjects','ViewAllProjects','MaintainPersonalProjects','ViewPersonalProjects')
66745
 
  ORDER BY granted DESC, sequence
66746
 
  LIMIT 1;
66747
 
 
66748
 
  -- If have an 'All' privilege return all results
66749
 
  IF (_priv ~ 'All' AND _grant) THEN
66750
 
    FOR _row IN 
66751
 
      SELECT * FROM prj
66752
 
    LOOP
66753
 
      RETURN NEXT _row;
66754
 
    END LOOP;
66755
 
  -- Otherwise if have any other grant, must be personal privilege.
66756
 
  ELSIF (_grant) THEN
66757
 
    FOR _row IN 
66758
 
      SELECT * FROM prj 
66759
 
      WHERE getEffectiveXtUser() IN (prj_owner_username, prj_username)
66760
 
    LOOP
66761
 
      RETURN NEXT _row;
66762
 
    END LOOP;
66763
 
  END IF;
66764
 
 
66765
 
  RETURN;
66766
 
 
66767
 
END;
66768
 
$$;
66769
 
 
66770
 
 
66771
 
ALTER FUNCTION public.prj() OWNER TO admin;
66772
 
 
66773
 
--
66774
 
--
66775
 
 
66776
 
COMMENT ON FUNCTION prj() IS 'A table function that returns Project results according to privilege settings.';
66777
 
 
66778
 
 
66779
 
--
66780
 
--
66781
 
 
66782
 
CREATE TABLE prjtask (
66783
 
    prjtask_id integer NOT NULL,
66784
 
    prjtask_number text NOT NULL,
66785
 
    prjtask_name text NOT NULL,
66786
 
    prjtask_descrip text,
66787
 
    prjtask_prj_id integer NOT NULL,
66788
 
    prjtask_anyuser boolean,
66789
 
    prjtask_status character(1) NOT NULL,
66790
 
    prjtask_hours_budget numeric(18,6) NOT NULL,
66791
 
    prjtask_hours_actual numeric(18,6) NOT NULL,
66792
 
    prjtask_exp_budget numeric(16,4) NOT NULL,
66793
 
    prjtask_exp_actual numeric(16,4) NOT NULL,
66794
 
    prjtask_owner_username text,
66795
 
    prjtask_start_date date,
66796
 
    prjtask_due_date date,
66797
 
    prjtask_assigned_date date,
66798
 
    prjtask_completed_date date,
66799
 
    prjtask_username text,
66800
 
    CONSTRAINT prjtask_prjtask_status_check CHECK ((prjtask_status = ANY (ARRAY['P'::bpchar, 'O'::bpchar, 'C'::bpchar])))
66801
 
);
66802
 
 
66803
 
 
66804
 
ALTER TABLE public.prjtask OWNER TO admin;
66805
 
 
66806
 
--
66807
 
--
66808
 
 
66809
 
COMMENT ON TABLE prjtask IS 'Project Task information';
66810
 
 
66811
 
 
66812
 
--
66813
 
--
66814
 
 
66815
 
CREATE FUNCTION prjtask() RETURNS SETOF prjtask
66816
 
    LANGUAGE plpgsql
66817
 
    AS $$
66818
 
DECLARE
66819
 
  _row prjtask%ROWTYPE;
66820
 
  _priv TEXT;
66821
 
  _grant BOOLEAN;
66822
 
 
66823
 
BEGIN
66824
 
  -- This query will give us the most permissive privilege the user has been granted
66825
 
  SELECT privilege, granted INTO _priv, _grant
66826
 
  FROM privgranted 
66827
 
  WHERE privilege IN ('MaintainAllProjects','ViewAllProjects','MaintainPersonalProjects','ViewPersonalProjects')
66828
 
  ORDER BY granted DESC, sequence
66829
 
  LIMIT 1;
66830
 
 
66831
 
  -- If have an 'All' privilege return all results
66832
 
  IF (_priv ~ 'All' AND _grant) THEN
66833
 
    FOR _row IN 
66834
 
      SELECT * FROM prjtask
66835
 
    LOOP
66836
 
      RETURN NEXT _row;
66837
 
    END LOOP;
66838
 
  -- Otherwise if have any other grant, must be personal privilege.
66839
 
  ELSIF (_grant) THEN
66840
 
    FOR _row IN 
66841
 
      SELECT prjtask.* FROM prjtask
66842
 
      JOIN prj ON prj_id=prjtask_prj_id
66843
 
      WHERE getEffectiveXtUser() IN (prjtask_owner_username,prjtask_username,prj_username,prj_owner_username)
66844
 
    LOOP
66845
 
      RETURN NEXT _row;
66846
 
    END LOOP;
66847
 
  END IF;
66848
 
 
66849
 
  RETURN;
66850
 
 
66851
 
END;
66852
 
$$;
66853
 
 
66854
 
 
66855
 
ALTER FUNCTION public.prjtask() OWNER TO admin;
66856
 
 
66857
 
--
66858
 
--
66859
 
 
66860
 
COMMENT ON FUNCTION prjtask() IS 'A table function that returns Project results according to privilege settings.';
66861
 
 
66862
 
 
66863
 
--
66864
 
--
66865
 
 
66866
 
CREATE FUNCTION purgecreditmemos(date) RETURNS boolean
66867
 
    LANGUAGE plpgsql
66868
 
    AS $_$
66869
 
DECLARE
66870
 
  pCutoffDate ALIAS FOR $1;
66871
 
 
66872
 
BEGIN
66873
 
 
66874
 
  DELETE FROM cmitem
66875
 
  WHERE (cmitem_id IN ( SELECT cmitem_id
66876
 
                        FROM cmitem, cmhead
66877
 
                        WHERE ( (cmitem_cmhead_id=cmhead_id)
66878
 
                          AND   (cmhead_posted)
66879
 
                          AND   (cmhead_printed)
66880
 
                          AND   (cmhead_docdate<=pCutoffDate)
66881
 
                          AND   (checkCreditMemoSitePrivs(cmhead_id)) ) ) );
66882
 
 
66883
 
  DELETE FROM cmhead
66884
 
  WHERE ( (cmhead_posted)
66885
 
    AND   (cmhead_printed)
66886
 
    AND   (cmhead_docdate<=pCutoffDate)
66887
 
    AND   (checkCreditMemoSitePrivs(cmhead_id)) );
66888
 
 
66889
 
  RETURN TRUE;
66890
 
 
66891
 
END;
66892
 
$_$;
66893
 
 
66894
 
 
66895
 
ALTER FUNCTION public.purgecreditmemos(date) OWNER TO admin;
66896
 
 
66897
 
--
66898
 
--
66899
 
 
66900
 
CREATE FUNCTION purgecrmacctmerge(integer) RETURNS integer
66901
 
    LANGUAGE plpgsql
66902
 
    AS $_$
66903
 
DECLARE
66904
 
  pDestid       ALIAS FOR $1;
66905
 
  _result       INTEGER := 0;
66906
 
  _tmpcount     INTEGER := 0;
66907
 
BEGIN
66908
 
  IF EXISTS(SELECT 1
66909
 
              FROM crmacctsel
66910
 
             WHERE crmacctsel_dest_crmacct_id=pDestid) THEN
66911
 
    DELETE FROM crmacctsel WHERE crmacctsel_dest_crmacct_id = pDestid;
66912
 
    GET DIAGNOSTICS _result = ROW_COUNT;
66913
 
 
66914
 
  ELSIF EXISTS(SELECT 1
66915
 
                 FROM mrgundo
66916
 
                WHERE mrgundo_base_schema='public'
66917
 
                  AND mrgundo_base_table='crmacct'
66918
 
                  AND mrgundo_base_id=pDestid) THEN
66919
 
 
66920
 
    DELETE FROM crmacct
66921
 
     WHERE crmacct_id IN (
66922
 
              SELECT mrgundo_pkey_id
66923
 
                FROM mrgundo
66924
 
               WHERE mrgundo_schema   = 'public'
66925
 
                 AND mrgundo_table    = 'crmacct'
66926
 
                 and mrgundo_pkey_col = 'crmacct_id'
66927
 
                 AND mrgundo_col IS NULL
66928
 
                 AND mrgundo_base_schema = 'public'
66929
 
                 AND mrgundo_base_table  = 'crmacct'
66930
 
                 AND mrgundo_base_id     = pDestid)
66931
 
        AND crmacct_id != pDestid;
66932
 
    GET DIAGNOSTICS _result = ROW_COUNT;
66933
 
 
66934
 
    DELETE FROM mrgundo
66935
 
     WHERE mrgundo_base_schema ='public'
66936
 
       AND mrgundo_base_table  ='crmacct'
66937
 
       AND mrgundo_base_id     = pDestid;
66938
 
    GET DIAGNOSTICS _tmpcount = ROW_COUNT;
66939
 
 
66940
 
    _result := _result + _tmpcount;
66941
 
  END IF;
66942
 
 
66943
 
  RETURN _result;
66944
 
END;
66945
 
$_$;
66946
 
 
66947
 
 
66948
 
ALTER FUNCTION public.purgecrmacctmerge(integer) OWNER TO admin;
66949
 
 
66950
 
--
66951
 
--
66952
 
 
66953
 
CREATE FUNCTION purgeinvoicerecord(date, integer) RETURNS text
66954
 
    LANGUAGE plpgsql
66955
 
    AS $_$
66956
 
DECLARE
66957
 
  pCutoffDate ALIAS FOR $1;
66958
 
  pInvcheadId ALIAS FOR $2;
66959
 
  _r RECORD;
66960
 
  _ra RECORD;
66961
 
  _raheadid INTEGER;
66962
 
  _result INTEGER;
66963
 
  _debug BOOLEAN := FALSE;
66964
 
 
66965
 
BEGIN
66966
 
 
66967
 
 
66968
 
  FOR _r IN
66969
 
  SELECT invchead_id, cobmisc_id, shiphead_id, ordershipped.cohead_id AS ordship_id, orderinvoiced.cohead_id AS ordinv_id
66970
 
    FROM invchead LEFT OUTER JOIN invcitem ON (invcitem_invchead_id=invchead_id)
66971
 
                  LEFT OUTER JOIN cobmisc ON (cobmisc_invcnumber::TEXT=invchead_invcnumber)
66972
 
                  LEFT OUTER JOIN shipitem ON (shipitem_invcitem_id=invcitem_id)
66973
 
                  LEFT OUTER JOIN shiphead ON (shiphead_id=shipitem_shiphead_id)
66974
 
                  LEFT OUTER JOIN cohead ordershipped ON (ordershipped.cohead_id=shiphead_order_id)
66975
 
                  LEFT OUTER JOIN coitem ON (coitem_id=invcitem_coitem_id)
66976
 
                  LEFT OUTER JOIN cohead orderinvoiced ON (orderinvoiced.cohead_id=coitem_cohead_id)
66977
 
   WHERE ( (invchead_id = pInvcheadId)
66978
 
     AND   (invchead_posted)
66979
 
     AND   (checkInvoiceSitePrivs(invchead_id)) )
66980
 
  GROUP BY invchead_id, cobmisc_id, shiphead_id, ordship_id, ordinv_id LOOP
66981
 
 
66982
 
 
66983
 
    SELECT cobmisc_id INTO _result
66984
 
      FROM cobmisc
66985
 
     WHERE ( (cobmisc_id=_r.cobmisc_id) AND (NOT cobmisc_posted) );
66986
 
    IF (FOUND) THEN
66987
 
      RETURN 'Billing not closed';
66988
 
    END IF;
66989
 
 
66990
 
    SELECT cobill_id INTO _result
66991
 
      FROM cobill JOIN invcitem ON (invcitem_id=cobill_invcitem_id)
66992
 
                  JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND
66993
 
                                     ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) )
66994
 
                  JOIN coitem ON ( (coitem_id=cobill_coitem_id) AND
66995
 
                                   (coitem_status NOT IN ('C', 'X')) )
66996
 
     WHERE (cobill_cobmisc_id=_r.cobmisc_id);
66997
 
    IF (FOUND) THEN
66998
 
      RETURN 'Invoice/Sales Order associated with Billing not closed';
66999
 
    END IF;
67000
 
 
67001
 
 
67002
 
    SELECT shiphead_id INTO _result
67003
 
      FROM shiphead
67004
 
     WHERE ( (shiphead_id=_r.shiphead_id) AND (NOT shiphead_shipped) );
67005
 
    IF (FOUND) THEN
67006
 
      RETURN 'Shipper not closed';
67007
 
    END IF;
67008
 
 
67009
 
    SELECT shiphead_id INTO _result
67010
 
      FROM shiphead, cohead, coitem
67011
 
     WHERE ( (shiphead_id=_r.shiphead_id)
67012
 
       AND   ( (shiphead_order_type='SO') AND (shiphead_order_id=cohead_id) )
67013
 
       AND   (coitem_cohead_id=cohead_id)
67014
 
       AND   (coitem_status NOT IN ('C', 'X')) );
67015
 
    IF (FOUND) THEN
67016
 
      RETURN 'Sales Order associated with Shipper not closed';
67017
 
    END IF;
67018
 
 
67019
 
    SELECT shiphead_id INTO _result
67020
 
      FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)
67021
 
                    JOIN invcitem ON (invcitem_id=shipitem_invcitem_id)
67022
 
                    JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND
67023
 
                                       ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) )
67024
 
     WHERE (shiphead_id=_r.shiphead_id);
67025
 
    IF (FOUND) THEN
67026
 
      RETURN 'Invoice associated with Shipper not closed';
67027
 
    END IF;
67028
 
 
67029
 
 
67030
 
    SELECT cohead_id INTO _result
67031
 
      FROM cohead JOIN coitem ON ( (coitem_cohead_id=cohead_id) AND
67032
 
                                   (coitem_status NOT IN ('C', 'X')) )
67033
 
     WHERE (cohead_id=_r.ordship_id);
67034
 
    IF (FOUND) THEN
67035
 
      RETURN 'Shipped Sales Order not closed';
67036
 
    END IF;
67037
 
    SELECT cohead_id INTO _result
67038
 
      FROM cohead JOIN coitem ON ( (coitem_cohead_id=cohead_id) AND
67039
 
                                   (coitem_status NOT IN ('C', 'X')) )
67040
 
     WHERE (cohead_id=_r.ordinv_id);
67041
 
    IF (FOUND) THEN
67042
 
      RETURN 'Invoiced Sales Order not closed';
67043
 
    END IF;
67044
 
 
67045
 
    IF (fetchMetricBool('MultiWhs')) THEN
67046
 
    -- Check Original Return Authorization and cross check to New Sales Order
67047
 
      SELECT rahead_id INTO _result
67048
 
        FROM rahead JOIN raitem ON ( (raitem_rahead_id=rahead_id) AND
67049
 
                                     (raitem_status NOT IN ('C', 'X')) )
67050
 
                    JOIN coitem ON ( (coitem_id=raitem_new_coitem_id) AND
67051
 
                                     (coitem_status NOT IN ('C', 'X')) )
67052
 
                    JOIN invcitem ON (invcitem_coitem_id=coitem_id)
67053
 
                    JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND
67054
 
                                       ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) )
67055
 
       WHERE (rahead_orig_cohead_id=_r.ordship_id);
67056
 
      IF (FOUND) THEN
67057
 
        RETURN 'Shipped Original Return Authorization not closed';
67058
 
      END IF;
67059
 
      SELECT rahead_id INTO _result
67060
 
        FROM rahead JOIN raitem ON ( (raitem_rahead_id=rahead_id) AND
67061
 
                                     (raitem_status NOT IN ('C', 'X')) )
67062
 
                    JOIN coitem ON ( (coitem_id=raitem_new_coitem_id) AND
67063
 
                                     (coitem_status NOT IN ('C', 'X')) )
67064
 
                    JOIN invcitem ON (invcitem_coitem_id=coitem_id)
67065
 
                    JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND
67066
 
                                       ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) )
67067
 
       WHERE (rahead_orig_cohead_id=_r.ordinv_id);
67068
 
      IF (FOUND) THEN
67069
 
        RETURN 'Invoiced Original Return Authorization not closed';
67070
 
      END IF;
67071
 
 
67072
 
  -- Check New Return Authorization
67073
 
      SELECT rahead_id INTO _result
67074
 
        FROM rahead JOIN raitem ON ( (raitem_rahead_id=rahead_id) AND
67075
 
                                     (NOT raitem_status IN ('C', 'X')) )
67076
 
                    JOIN coitem ON ( (coitem_id=raitem_orig_coitem_id) AND
67077
 
                                     (NOT coitem_status IN ('C', 'X')) )
67078
 
                    JOIN invcitem ON (invcitem_coitem_id=coitem_id)
67079
 
                    JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND
67080
 
                                       ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) )
67081
 
       WHERE (rahead_new_cohead_id=_r.ordship_id);
67082
 
      IF (FOUND) THEN
67083
 
        RETURN 'Shipped New Return Authorization not closed';
67084
 
      END IF;
67085
 
      SELECT rahead_id INTO _result
67086
 
        FROM rahead JOIN raitem ON ( (raitem_rahead_id=rahead_id) AND
67087
 
                                     (NOT raitem_status IN ('C', 'X')) )
67088
 
                    JOIN coitem ON ( (coitem_id=raitem_orig_coitem_id) AND
67089
 
                                     (NOT coitem_status IN ('C', 'X')) )
67090
 
                    JOIN invcitem ON (invcitem_coitem_id=coitem_id)
67091
 
                    JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND
67092
 
                                       ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) )
67093
 
       WHERE (rahead_new_cohead_id=_r.ordinv_id);
67094
 
      IF (FOUND) THEN
67095
 
        RETURN 'Invoiced New Return Authorization not closed';
67096
 
      END IF;
67097
 
    END IF;
67098
 
 
67099
 
 
67100
 
    IF (fetchMetricBool('MultiWhs')) THEN
67101
 
  -- Registration associated with Sales Order must be expired
67102
 
      SELECT lsreg_id INTO _result
67103
 
        FROM lsreg
67104
 
       WHERE ( (lsreg_cohead_id=_r.ordship_id)
67105
 
         AND   (lsreg_expiredate > CURRENT_DATE) );
67106
 
      IF (FOUND) THEN
67107
 
        RETURN 'Shipped Sales Order Lot/Serial Registration not closed';
67108
 
      END IF;
67109
 
      SELECT lsreg_id INTO _result
67110
 
        FROM lsreg
67111
 
       WHERE ( (lsreg_cohead_id=_r.ordinv_id)
67112
 
         AND   (lsreg_expiredate > CURRENT_DATE) );
67113
 
      IF (FOUND) THEN
67114
 
        RETURN 'Invoiced Sales Order Lot/Serial Registration not closed';
67115
 
      END IF;
67116
 
 
67117
 
  -- Registration associated with Shipping must be expired
67118
 
      SELECT lsreg_id INTO _result
67119
 
        FROM lsreg
67120
 
       WHERE ( (lsreg_cohead_id=_r.shiphead_id)
67121
 
         AND   (lsreg_expiredate > CURRENT_DATE) );
67122
 
      IF (FOUND) THEN
67123
 
        RETURN 'Shipper Lot/Serial Registration not closed';
67124
 
      END IF;
67125
 
    END IF;
67126
 
 
67127
 
    IF (fetchMetricBool('MultiWhs')) THEN
67128
 
  -- Registration associated with Original Return Authorization must be expired
67129
 
      SELECT rahead_id INTO _result
67130
 
        FROM rahead JOIN raitem ON (raitem_rahead_id=rahead_id)
67131
 
                    JOIN raitemls ON (raitemls_raitem_id=raitem_id)
67132
 
                    JOIN lsreg ON ( (lsreg_ls_id=raitemls_ls_id) AND
67133
 
                                    (lsreg_expiredate > CURRENT_DATE) )
67134
 
       WHERE (rahead_orig_cohead_id=_r.ordship_id);
67135
 
      IF (FOUND) THEN
67136
 
        RETURN 'Shipped Original Return Authorization Lot/Serial Registration not closed';
67137
 
      END IF;
67138
 
      SELECT rahead_id INTO _result
67139
 
        FROM rahead JOIN raitem ON (raitem_rahead_id=rahead_id)
67140
 
                    JOIN raitemls ON (raitemls_raitem_id=raitem_id)
67141
 
                    JOIN lsreg ON ( (lsreg_ls_id=raitemls_ls_id) AND
67142
 
                                    (lsreg_expiredate > CURRENT_DATE) )
67143
 
       WHERE (rahead_orig_cohead_id=_r.ordinv_id);
67144
 
      IF (FOUND) THEN
67145
 
        RETURN 'Invoiced Original Return Authorization Lot/Serial Registration not closed';
67146
 
      END IF;
67147
 
 
67148
 
  -- Registration associated with New Return Authorization must be expired
67149
 
      SELECT rahead_id INTO _result
67150
 
        FROM rahead JOIN raitem ON (raitem_rahead_id=rahead_id)
67151
 
                    JOIN raitemls ON (raitemls_raitem_id=raitem_id)
67152
 
                    JOIN lsreg ON ( (lsreg_ls_id=raitemls_ls_id) AND
67153
 
                                    (lsreg_expiredate > CURRENT_DATE) )
67154
 
       WHERE (rahead_new_cohead_id=_r.ordship_id);
67155
 
      IF (FOUND) THEN
67156
 
        RETURN 'Shipped New Return Authorization Lot/Serial Registration not closed';
67157
 
      END IF;
67158
 
      SELECT rahead_id INTO _result
67159
 
        FROM rahead JOIN raitem ON (raitem_rahead_id=rahead_id)
67160
 
                    JOIN raitemls ON (raitemls_raitem_id=raitem_id)
67161
 
                    JOIN lsreg ON ( (lsreg_ls_id=raitemls_ls_id) AND
67162
 
                                    (lsreg_expiredate > CURRENT_DATE) )
67163
 
       WHERE (rahead_new_cohead_id=_r.ordinv_id);
67164
 
      IF (FOUND) THEN
67165
 
        RETURN 'Invoiced New Return Authorization Lot/Serial Registration not closed';
67166
 
      END IF;
67167
 
    END IF;
67168
 
 
67169
 
    SELECT aropenalloc_doc_id INTO _result   
67170
 
      FROM aropenalloc
67171
 
     WHERE ((aropenalloc_doctype='S')
67172
 
       AND  (aropenalloc_doc_id=_r.ordship_id));
67173
 
    IF (FOUND) THEN
67174
 
      RETURN 'Shipped Cash Advance not closed';
67175
 
    END IF;
67176
 
    SELECT aropenalloc_doc_id INTO _result   
67177
 
      FROM aropenalloc
67178
 
     WHERE ((aropenalloc_doctype='S')
67179
 
       AND  (aropenalloc_doc_id=_r.ordinv_id));
67180
 
    IF (FOUND) THEN
67181
 
      RETURN 'Invoiced Cash Advance not closed';
67182
 
    END IF;
67183
 
 
67184
 
  END LOOP;
67185
 
 
67186
 
  FOR _r IN
67187
 
  SELECT invchead_id, cobmisc_id, shiphead_id, ordershipped.cohead_id AS ordship_id, orderinvoiced.cohead_id AS ordinv_id
67188
 
    FROM invchead LEFT OUTER JOIN invcitem ON (invcitem_invchead_id=invchead_id)
67189
 
                  LEFT OUTER JOIN cobmisc ON (cobmisc_invcnumber::TEXT=invchead_invcnumber)
67190
 
                  LEFT OUTER JOIN shipitem ON (shipitem_invcitem_id=invcitem_id)
67191
 
                  LEFT OUTER JOIN shiphead ON (shiphead_id=shipitem_shiphead_id)
67192
 
                  LEFT OUTER JOIN cohead ordershipped ON (ordershipped.cohead_id=shiphead_order_id)
67193
 
                  LEFT OUTER JOIN coitem ON (coitem_id=invcitem_coitem_id)
67194
 
                  LEFT OUTER JOIN cohead orderinvoiced ON (orderinvoiced.cohead_id=coitem_cohead_id)
67195
 
   WHERE ( (invchead_id = pInvcheadId)
67196
 
     AND   (invchead_posted)
67197
 
     AND   (checkInvoiceSitePrivs(invchead_id)) )
67198
 
  GROUP BY invchead_id, cobmisc_id, shiphead_id, ordship_id, ordinv_id LOOP
67199
 
 
67200
 
    IF (fetchMetricBool('MultiWhs')) THEN
67201
 
      FOR _ra IN
67202
 
        SELECT rahead_id
67203
 
        FROM rahead
67204
 
        WHERE (rahead_orig_cohead_id=_r.ordship_id) LOOP
67205
 
        IF (_debug) THEN
67206
 
          RAISE NOTICE 'Deleting Original Return head id %', _ra.rahead_id;
67207
 
        END IF;
67208
 
        DELETE FROM raitemls WHERE (raitemls_raitem_id IN (SELECT raitem_id
67209
 
                                                           FROM raitem
67210
 
                                                           WHERE (raitem_rahead_id=_ra.rahead_id)));
67211
 
        DELETE FROM rahist WHERE (rahist_rahead_id=_ra.rahead_id);
67212
 
        DELETE FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id);
67213
 
        DELETE FROM rahead WHERE (rahead_id=_ra.rahead_id);
67214
 
      END LOOP;
67215
 
      FOR _ra IN
67216
 
        SELECT rahead_id
67217
 
        FROM rahead
67218
 
        WHERE (rahead_orig_cohead_id=_r.ordinv_id) LOOP
67219
 
        IF (_debug) THEN
67220
 
          RAISE NOTICE 'Deleting Original Return head id %', _ra.rahead_id;
67221
 
        END IF;
67222
 
        DELETE FROM raitemls WHERE (raitemls_raitem_id IN (SELECT raitem_id
67223
 
                                                           FROM raitem
67224
 
                                                           WHERE (raitem_rahead_id=_ra.rahead_id)));
67225
 
        DELETE FROM rahist WHERE (rahist_rahead_id=_ra.rahead_id);
67226
 
        DELETE FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id);
67227
 
        DELETE FROM rahead WHERE (rahead_id=_ra.rahead_id);
67228
 
      END LOOP;
67229
 
 
67230
 
      FOR _ra IN
67231
 
        SELECT rahead_id
67232
 
          FROM rahead
67233
 
         WHERE (rahead_new_cohead_id=_r.ordship_id) LOOP
67234
 
        IF (_debug) THEN
67235
 
          RAISE NOTICE 'Deleting New Return head id %', _ra.rahead_id;
67236
 
        END IF;
67237
 
        DELETE FROM raitemls WHERE (raitemls_raitem_id IN (SELECT raitem_id
67238
 
                                                           FROM raitem
67239
 
                                                           WHERE (raitem_rahead_id=_ra.rahead_id)));
67240
 
        DELETE FROM rahist WHERE (rahist_rahead_id=_ra.rahead_id);
67241
 
        DELETE FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id);
67242
 
        DELETE FROM rahead WHERE (rahead_id=_ra.rahead_id);
67243
 
      END LOOP;
67244
 
      FOR _ra IN
67245
 
        SELECT rahead_id
67246
 
          FROM rahead
67247
 
         WHERE (rahead_new_cohead_id=_r.ordinv_id) LOOP
67248
 
        IF (_debug) THEN
67249
 
          RAISE NOTICE 'Deleting New Return head id %', _ra.rahead_id;
67250
 
        END IF;
67251
 
        DELETE FROM raitemls WHERE (raitemls_raitem_id IN (SELECT raitem_id
67252
 
                                                           FROM raitem
67253
 
                                                           WHERE (raitem_rahead_id=_ra.rahead_id)));
67254
 
        DELETE FROM rahist WHERE (rahist_rahead_id=_ra.rahead_id);
67255
 
        DELETE FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id);
67256
 
        DELETE FROM rahead WHERE (rahead_id=_ra.rahead_id);
67257
 
      END LOOP;
67258
 
    END IF;
67259
 
 
67260
 
    IF (fetchMetricBool('MultiWhs')) THEN
67261
 
      IF (_debug) THEN
67262
 
        RAISE NOTICE 'Deleting Lot/Serial Registrations';
67263
 
      END IF;
67264
 
      DELETE FROM lsreg WHERE (lsreg_cohead_id=_r.ordship_id);
67265
 
      DELETE FROM lsreg WHERE (lsreg_cohead_id=_r.ordinv_id);
67266
 
      DELETE FROM lsreg WHERE (lsreg_shiphead_id=_r.shiphead_id);
67267
 
    END IF;
67268
 
 
67269
 
    IF (_debug) THEN
67270
 
      RAISE NOTICE 'Deleting Shipped Sales Order head id %', _r.ordship_id;
67271
 
    END IF;
67272
 
    DELETE FROM payco WHERE (payco_cohead_id=_r.ordship_id);
67273
 
    -- Delete kit components first
67274
 
    DELETE FROM coitem WHERE (coitem_cohead_id=_r.ordship_id AND coitem_subnumber > 0);
67275
 
    DELETE FROM coitem WHERE (coitem_cohead_id=_r.ordship_id);
67276
 
    DELETE FROM cohead WHERE (cohead_id=_r.ordship_id);
67277
 
 
67278
 
    IF (_debug) THEN
67279
 
      RAISE NOTICE 'Deleting Sales Order head id %', _r.ordinv_id;
67280
 
    END IF;
67281
 
    DELETE FROM payco WHERE (payco_cohead_id=_r.ordinv_id);
67282
 
    -- Delete kit components first
67283
 
    DELETE FROM coitem WHERE (coitem_cohead_id=_r.ordinv_id AND coitem_subnumber > 0);
67284
 
    DELETE FROM coitem WHERE (coitem_cohead_id=_r.ordinv_id);
67285
 
    DELETE FROM cohead WHERE (cohead_id=_r.ordinv_id);
67286
 
 
67287
 
    IF (_debug) THEN
67288
 
      RAISE NOTICE 'Deleting Ship head id %', _r.shiphead_id;
67289
 
    END IF;
67290
 
    DELETE FROM shipitem WHERE (shipitem_shiphead_id=_r.shiphead_id);
67291
 
    DELETE FROM pack WHERE (pack_shiphead_id=_r.shiphead_id);
67292
 
    DELETE FROM shiphead WHERE (shiphead_id=_r.shiphead_id);
67293
 
 
67294
 
    IF (_debug) THEN
67295
 
      RAISE NOTICE 'Deleting Billing head id %', _r.cobmisc_id;
67296
 
    END IF;
67297
 
    DELETE FROM cobill WHERE (cobill_cobmisc_id=_r.cobmisc_id);
67298
 
    DELETE FROM cobmisc WHERE (cobmisc_id=_r.cobmisc_id);
67299
 
  END LOOP;
67300
 
  
67301
 
  IF (_debug) THEN
67302
 
    RAISE NOTICE 'Deleting Invoice head id %', _r.invchead_id;
67303
 
  END IF;
67304
 
  DELETE FROM invcitem WHERE (invcitem_invchead_id=_r.invchead_id);
67305
 
  DELETE FROM invchead WHERE (invchead_id=_r.invchead_id);
67306
 
 
67307
 
  RETURN 'Purged';
67308
 
 
67309
 
END;
67310
 
$_$;
67311
 
 
67312
 
 
67313
 
ALTER FUNCTION public.purgeinvoicerecord(date, integer) OWNER TO admin;
67314
 
 
67315
 
--
67316
 
--
67317
 
 
67318
 
CREATE FUNCTION purgeinvoicerecords(date) RETURNS integer
67319
 
    LANGUAGE plpgsql
67320
 
    AS $_$
67321
 
DECLARE
67322
 
  pCutoffDate ALIAS FOR $1;
67323
 
 
67324
 
BEGIN
67325
 
 
67326
 
  DELETE FROM shipitem
67327
 
  WHERE (shipitem_invcitem_id IN (SELECT invcitem_id 
67328
 
                                  FROM invcitem 
67329
 
                                  WHERE invcitem_invchead_id IN ( SELECT invchead_id
67330
 
                                     FROM invchead
67331
 
                                     WHERE ( (invchead_invcdate <= pCutoffDate)
67332
 
                                     AND   (checkInvoiceSitePrivs(invchead_id))
67333
 
                                     AND   (invchead_posted) ) ) ) );
67334
 
 
67335
 
  DELETE FROM cobill
67336
 
  WHERE (cobill_cobmisc_id IN ( SELECT cobmisc_id
67337
 
                                FROM cobmisc, invchead
67338
 
                                WHERE ( (invchead_invcnumber=cobmisc_invcnumber::TEXT)
67339
 
                                  AND   (checkInvoiceSitePrivs(invchead_id))
67340
 
                                  AND   (cobmisc_invcdate <= pCutoffDate)
67341
 
                                  AND   (cobmisc_posted)) ) );
67342
 
 
67343
 
  DELETE FROM cobmisc
67344
 
  WHERE ( (checkInvoiceSitePrivs(getInvcheadId(cobmisc_invcnumber::TEXT)))
67345
 
    AND   (cobmisc_invcdate <= pCutoffDate)
67346
 
    AND   (cobmisc_posted) );
67347
 
 
67348
 
  DELETE FROM invcitem
67349
 
  WHERE (invcitem_invchead_id IN ( SELECT invchead_id
67350
 
                                   FROM invchead
67351
 
                                   WHERE ( (invchead_invcdate <= pCutoffDate)
67352
 
                                     AND   (checkInvoiceSitePrivs(invchead_id))
67353
 
                                     AND   (invchead_posted) ) ) );
67354
 
 
67355
 
  DELETE FROM invchead
67356
 
  WHERE ( (invchead_invcdate <= pCutoffDate)
67357
 
    AND   (checkInvoiceSitePrivs(invchead_id))
67358
 
    AND   (invchead_posted) );
67359
 
 
67360
 
  RETURN 1;
67361
 
 
67362
 
END;
67363
 
$_$;
67364
 
 
67365
 
 
67366
 
ALTER FUNCTION public.purgeinvoicerecords(date) OWNER TO admin;
67367
 
 
67368
 
--
67369
 
--
67370
 
 
67371
 
CREATE FUNCTION purgepostedcountslips(date, integer) RETURNS integer
67372
 
    LANGUAGE plpgsql
67373
 
    AS $_$
67374
 
DECLARE
67375
 
  pCutoffDate ALIAS FOR $1;
67376
 
  pWarehousid ALIAS FOR $2;
67377
 
 
67378
 
BEGIN
67379
 
 
67380
 
  IF (pWarehousid = -1) THEN
67381
 
    DELETE FROM cntslip
67382
 
    WHERE (cntslip_id IN ( SELECT cntslip_id
67383
 
                           FROM cntslip, invcnt
67384
 
                           WHERE ( (cntslip_cnttag_id=invcnt_id)
67385
 
                            AND (invcnt_posted)
67386
 
                            AND (cntslip_posted)
67387
 
                            AND (date(invcnt_postdate) <= pCutoffDate) ) ) );
67388
 
 
67389
 
  ELSE
67390
 
    DELETE FROM cntslip
67391
 
    WHERE (cntslip_id IN ( SELECT cntslip_id
67392
 
                           FROM invcnt, itemsite
67393
 
                           WHERE ( (cntslip_cnttag_id=invcnt_id)
67394
 
                            AND (invcnt_posted)
67395
 
                            AND (cntslip_posted)
67396
 
                            AND (invcnt_itemsite_id=itemsite_id)
67397
 
                            AND (date(invcnt_postdate) <= pCutoffDate)
67398
 
                            AND (itemsite_warehous_id=pWarehousid) ) ) );
67399
 
  END IF;
67400
 
 
67401
 
  RETURN 1;
67402
 
 
67403
 
END;
67404
 
$_$;
67405
 
 
67406
 
 
67407
 
ALTER FUNCTION public.purgepostedcountslips(date, integer) OWNER TO admin;
67408
 
 
67409
 
--
67410
 
--
67411
 
 
67412
 
CREATE FUNCTION purgepostedcounttags(date, integer) RETURNS integer
67413
 
    LANGUAGE plpgsql
67414
 
    AS $_$
67415
 
DECLARE
67416
 
  pCutoffDate ALIAS FOR $1;
67417
 
  pWarehousid ALIAS FOR $2;
67418
 
 
67419
 
BEGIN
67420
 
 
67421
 
  IF (pWarehousid = -1) THEN
67422
 
    DELETE FROM cntslip
67423
 
    WHERE (cntslip_cnttag_id IN ( SELECT invcnt_id
67424
 
                                  FROM invcnt
67425
 
                                  WHERE ( (invcnt_posted)
67426
 
                                   AND (date(invcnt_postdate) <= pCutoffDate) ) ) );
67427
 
 
67428
 
    DELETE FROM invcnt
67429
 
    WHERE ((invcnt_posted)
67430
 
     AND (date(invcnt_postdate) <= pCutoffDate));
67431
 
 
67432
 
  ELSE
67433
 
    DELETE FROM cntslip
67434
 
    WHERE (cntslip_cnttag_id IN ( SELECT invcnt_id
67435
 
                                  FROM invcnt, itemsite
67436
 
                                  WHERE ( (invcnt_posted)
67437
 
                                   AND (invcnt_itemsite_id=itemsite_id)
67438
 
                                   AND (date(invcnt_postdate) <= pCutoffDate)
67439
 
                                   AND (itemsite_warehous_id=pWarehousid) ) ) );
67440
 
 
67441
 
    DELETE FROM invcnt
67442
 
    WHERE (invcnt_id IN ( SELECT invcnt_id 
67443
 
                          FROM invcnt, itemsite
67444
 
                          WHERE ( (invcnt_posted)
67445
 
                           AND (invcnt_itemsite_id=itemsite_id)
67446
 
                           AND (date(invcnt_postdate) <= pCutoffDate)
67447
 
                           AND (itemsite_warehous_id=pWarehousid) ) ) );
67448
 
  END IF;
67449
 
 
67450
 
  RETURN 1;
67451
 
 
67452
 
END;
67453
 
$_$;
67454
 
 
67455
 
 
67456
 
ALTER FUNCTION public.purgepostedcounttags(date, integer) OWNER TO admin;
67457
 
 
67458
 
--
67459
 
--
67460
 
 
67461
 
CREATE FUNCTION purgeshipments(date) RETURNS integer
67462
 
    LANGUAGE plpgsql
67463
 
    AS $_$
67464
 
DECLARE
67465
 
  pcutoff ALIAS FOR $1;
67466
 
  _r RECORD;
67467
 
 
67468
 
BEGIN
67469
 
 
67470
 
  -- Used for transfer orders shipments (which are never invoiced)
67471
 
  FOR _r IN SELECT shiphead_id
67472
 
              FROM shiphead
67473
 
             WHERE ( (shiphead_order_type='TO')
67474
 
               AND   (shiphead_shipped)
67475
 
               AND   (shiphead_shipdate <= pcutoff) ) LOOP
67476
 
    DELETE FROM shipitem WHERE (shipitem_shiphead_id=_r.shiphead_id);
67477
 
    DELETE FROM shiphead WHERE (shiphead_id=_r.shiphead_id);
67478
 
  END LOOP;
67479
 
 
67480
 
  RETURN 0;
67481
 
 
67482
 
END;
67483
 
$_$;
67484
 
 
67485
 
 
67486
 
ALTER FUNCTION public.purgeshipments(date) OWNER TO admin;
67487
 
 
67488
 
--
67489
 
--
67490
 
 
67491
 
CREATE FUNCTION qtyallocated(integer, integer) RETURNS numeric
67492
 
    LANGUAGE plpgsql
67493
 
    AS $_$
67494
 
DECLARE
67495
 
  pItemsiteid ALIAS FOR $1;
67496
 
  pLookAheaddays ALIAS FOR $2;
67497
 
 
67498
 
BEGIN
67499
 
 
67500
 
  RETURN qtyAllocated(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookAheadDays));
67501
 
 
67502
 
END;
67503
 
$_$;
67504
 
 
67505
 
 
67506
 
ALTER FUNCTION public.qtyallocated(integer, integer) OWNER TO admin;
67507
 
 
67508
 
--
67509
 
--
67510
 
 
67511
 
CREATE FUNCTION qtyallocated(integer, date) RETURNS numeric
67512
 
    LANGUAGE plpgsql
67513
 
    AS $_$
67514
 
DECLARE
67515
 
  pItemsiteid ALIAS FOR $1;
67516
 
  pDate ALIAS FOR $2;
67517
 
 
67518
 
BEGIN
67519
 
 
67520
 
  RETURN qtyAllocated(pItemsiteid, startOfTime(), pDate);
67521
 
 
67522
 
END;
67523
 
$_$;
67524
 
 
67525
 
 
67526
 
ALTER FUNCTION public.qtyallocated(integer, date) OWNER TO admin;
67527
 
 
67528
 
--
67529
 
--
67530
 
 
67531
 
CREATE FUNCTION qtyallocated(integer, date, date) RETURNS numeric
67532
 
    LANGUAGE plpgsql STABLE
67533
 
    AS $_$
67534
 
DECLARE
67535
 
  pItemsiteid ALIAS FOR $1;
67536
 
  pStartDate ALIAS FOR $2;
67537
 
  pEndDate ALIAS FOR $3;
67538
 
 
67539
 
BEGIN
67540
 
 
67541
 
  IF ( fetchMetricBool('MultiWhs')) THEN
67542
 
    IF ( SELECT item_sold
67543
 
         FROM itemsite, item
67544
 
         WHERE ((itemsite_item_id=item_id)
67545
 
         AND (itemsite_id=pItemsiteid)) ) THEN
67546
 
      RETURN (allocatedForTo(pItemsiteid, pStartDate, pEndDate) +
67547
 
              allocatedForWo(pItemsiteid, pStartDate, pEndDate) +
67548
 
              allocatedForSo(pItemsiteid, pStartDate, pEndDate));
67549
 
    ELSE
67550
 
      RETURN (allocatedForTo(pItemsiteid, pStartDate, pEndDate) +
67551
 
              allocatedForWo(pItemsiteid, pStartDate, pEndDate));
67552
 
    END IF;
67553
 
  ELSE
67554
 
    IF ( SELECT item_sold
67555
 
         FROM itemsite, item
67556
 
         WHERE ((itemsite_item_id=item_id)
67557
 
         AND (itemsite_id=pItemsiteid)) ) THEN
67558
 
      RETURN (allocatedForWo(pItemsiteid, pStartDate, pEndDate) +
67559
 
              allocatedForSo(pItemsiteid, pStartDate, pEndDate));
67560
 
    ELSE
67561
 
      RETURN (allocatedForWo(pItemsiteid, pStartDate, pEndDate));
67562
 
    END IF;
67563
 
  END IF;
67564
 
END;
67565
 
$_$;
67566
 
 
67567
 
 
67568
 
ALTER FUNCTION public.qtyallocated(integer, date, date) OWNER TO admin;
67569
 
 
67570
 
--
67571
 
--
67572
 
 
67573
 
CREATE FUNCTION qtyatlocation(pitemsiteid integer, plocationid integer) RETURNS numeric
67574
 
    LANGUAGE plpgsql STABLE
67575
 
    AS $$
67576
 
DECLARE
67577
 
  _qty         NUMERIC := 0.0;
67578
 
 
67579
 
BEGIN
67580
 
  SELECT CASE WHEN (pLocationid IS NULL) THEN itemsite_qtyonhand
67581
 
              ELSE COALESCE(SUM(itemloc_qty), 0.0)
67582
 
         END INTO _qty
67583
 
    FROM itemsite LEFT OUTER JOIN itemloc ON (itemloc_itemsite_id=itemsite_id)
67584
 
   WHERE ((itemsite_id=pItemsiteid)
67585
 
     AND  (itemloc_location_id=pLocationid))
67586
 
  GROUP BY itemsite_qtyonhand;
67587
 
 
67588
 
  RETURN _qty;
67589
 
 
67590
 
END;
67591
 
$$;
67592
 
 
67593
 
 
67594
 
ALTER FUNCTION public.qtyatlocation(pitemsiteid integer, plocationid integer) OWNER TO admin;
67595
 
 
67596
 
--
67597
 
--
67598
 
 
67599
 
CREATE FUNCTION qtyatshipping(integer) RETURNS numeric
67600
 
    LANGUAGE plpgsql
67601
 
    AS $_$
67602
 
BEGIN
67603
 
  RETURN qtyAtShipping('SO', $1);
67604
 
END;
67605
 
$_$;
67606
 
 
67607
 
 
67608
 
ALTER FUNCTION public.qtyatshipping(integer) OWNER TO admin;
67609
 
 
67610
 
--
67611
 
--
67612
 
 
67613
 
CREATE FUNCTION qtyatshipping(text, integer) RETURNS numeric
67614
 
    LANGUAGE plpgsql
67615
 
    AS $_$
67616
 
BEGIN
67617
 
  RETURN qtyAtShipping($1, $2, 'U');
67618
 
END;
67619
 
$_$;
67620
 
 
67621
 
 
67622
 
ALTER FUNCTION public.qtyatshipping(text, integer) OWNER TO admin;
67623
 
 
67624
 
--
67625
 
--
67626
 
 
67627
 
CREATE FUNCTION qtyatshipping(text, integer, text) RETURNS numeric
67628
 
    LANGUAGE plpgsql STABLE
67629
 
    AS $_$
67630
 
DECLARE
67631
 
  pordertype    ALIAS FOR $1;
67632
 
  plineitemid   ALIAS FOR $2;
67633
 
  pstatus       ALIAS FOR $3;
67634
 
  _qty NUMERIC  := 0.0;
67635
 
 
67636
 
BEGIN
67637
 
 
67638
 
 
67639
 
  IF (pordertype NOT IN ('SO', 'TO')) THEN
67640
 
    RAISE EXCEPTION '% is not a valid order type', pordertype;
67641
 
  END IF;
67642
 
 
67643
 
  IF (pstatus NOT IN ('U', 'S', 'B')) THEN
67644
 
    RAISE EXCEPTION '% is not a valid status', pstatus;
67645
 
  END IF;
67646
 
 
67647
 
  SELECT COALESCE(SUM(shipitem_qty), 0.0) INTO _qty
67648
 
  FROM shipitem, shiphead
67649
 
  WHERE ((shipitem_shiphead_id=shiphead_id)
67650
 
    AND  (shiphead_order_type=pordertype)
67651
 
    AND  (shipitem_orderitem_id=plineitemid)
67652
 
    AND  (((shiphead_shipped) AND (pstatus IN ('S', 'B'))) OR ((NOT shiphead_shipped) AND (pstatus IN ('U', 'B'))))  );
67653
 
 
67654
 
  RETURN _qty;
67655
 
 
67656
 
END;
67657
 
$_$;
67658
 
 
67659
 
 
67660
 
ALTER FUNCTION public.qtyatshipping(text, integer, text) OWNER TO admin;
67661
 
 
67662
 
--
67663
 
--
67664
 
 
67665
 
CREATE FUNCTION qtyavailable(pitemsiteid integer) RETURNS numeric
67666
 
    LANGUAGE plpgsql STABLE
67667
 
    AS $$
67668
 
DECLARE
67669
 
  _qty         NUMERIC = 0.0;
67670
 
 
67671
 
BEGIN
67672
 
  _qty := qtyAvailable(pItemsiteId, TRUE);
67673
 
 
67674
 
  RETURN _qty;
67675
 
 
67676
 
END;
67677
 
$$;
67678
 
 
67679
 
 
67680
 
ALTER FUNCTION public.qtyavailable(pitemsiteid integer) OWNER TO admin;
67681
 
 
67682
 
--
67683
 
--
67684
 
 
67685
 
CREATE FUNCTION qtyavailable(pitemsiteid integer, plookaheaddays integer) RETURNS numeric
67686
 
    LANGUAGE plpgsql STABLE
67687
 
    AS $$
67688
 
DECLARE
67689
 
 
67690
 
BEGIN
67691
 
 
67692
 
  RETURN ( ( SELECT qtyAvailable(itemsite_id)
67693
 
             FROM itemsite
67694
 
             WHERE (itemsite_id=pItemsiteid) ) +
67695
 
           (SELECT qtyOrdered(pItemsiteid, pLookAheadDays)) -
67696
 
           (SELECT qtyAllocated(pitemsiteid, pLookAheadDays)) );
67697
 
END;
67698
 
$$;
67699
 
 
67700
 
 
67701
 
ALTER FUNCTION public.qtyavailable(pitemsiteid integer, plookaheaddays integer) OWNER TO admin;
67702
 
 
67703
 
--
67704
 
--
67705
 
 
67706
 
CREATE FUNCTION qtyavailable(pitemsiteid integer, pdate date) RETURNS numeric
67707
 
    LANGUAGE plpgsql STABLE
67708
 
    AS $$
67709
 
DECLARE
67710
 
 
67711
 
BEGIN
67712
 
 
67713
 
  RETURN ( ( SELECT qtyAvailable(itemsite_id)
67714
 
             FROM itemsite
67715
 
             WHERE (itemsite_id=pItemsiteid) ) +
67716
 
           (SELECT qtyOrdered(pItemsiteid, (pDate - CURRENT_DATE))) -
67717
 
           (SELECT qtyAllocated(pItemsiteid, (pDate - CURRENT_DATE))) );
67718
 
END;
67719
 
$$;
67720
 
 
67721
 
 
67722
 
ALTER FUNCTION public.qtyavailable(pitemsiteid integer, pdate date) OWNER TO admin;
67723
 
 
67724
 
--
67725
 
--
67726
 
 
67727
 
CREATE FUNCTION qtyavailable(pitemsiteid integer, pusable boolean) RETURNS numeric
67728
 
    LANGUAGE plpgsql STABLE
67729
 
    AS $$
67730
 
DECLARE
67731
 
  _qty         NUMERIC = 0.0;
67732
 
 
67733
 
BEGIN
67734
 
  IF (pUsable) THEN
67735
 
    -- Summarize itemloc qty for this itemsite/usable locations
67736
 
    -- or use itemsite_qtyonhand for regular/non-lot
67737
 
    SELECT COALESCE(SUM(itemloc_qty), itemsite_qtyonhand) INTO _qty
67738
 
      FROM itemsite LEFT OUTER JOIN itemloc ON (itemloc_itemsite_id=itemsite_id)
67739
 
                    LEFT OUTER JOIN location ON (location_id=itemloc_location_id)
67740
 
     WHERE (itemsite_id=pItemsiteId)
67741
 
       AND ((location_id IS NULL) OR (COALESCE(location_usable, true)))
67742
 
     GROUP BY itemsite_qtyonhand;
67743
 
  ELSE
67744
 
    -- Summarize itemloc qty for this itemsite/non-usable locations
67745
 
    SELECT COALESCE(SUM(itemloc_qty), 0.0) INTO _qty
67746
 
      FROM itemloc JOIN location ON (location_id=itemloc_location_id)
67747
 
     WHERE (itemloc_itemsite_id=pItemsiteId)
67748
 
       AND (NOT COALESCE(location_usable, true));
67749
 
  END IF;
67750
 
 
67751
 
  RETURN _qty;
67752
 
 
67753
 
END;
67754
 
$$;
67755
 
 
67756
 
 
67757
 
ALTER FUNCTION public.qtyavailable(pitemsiteid integer, pusable boolean) OWNER TO admin;
67758
 
 
67759
 
--
67760
 
--
67761
 
 
67762
 
CREATE FUNCTION qtyinshipment(text, integer, integer) RETURNS numeric
67763
 
    LANGUAGE plpgsql
67764
 
    AS $_$
67765
 
DECLARE
67766
 
  pordertype    ALIAS FOR $1;
67767
 
  plineitemid   ALIAS FOR $2;
67768
 
  pshipheadid   ALIAS FOR $3;
67769
 
  _qty NUMERIC;
67770
 
 
67771
 
BEGIN
67772
 
 
67773
 
  IF (pordertype NOT IN ('SO', 'TO')) THEN
67774
 
    RAISE EXCEPTION '% is not a valid order type', pordertype;
67775
 
  END IF;
67776
 
 
67777
 
  IF (pshipheadid IS NULL) THEN
67778
 
    RAISE EXCEPTION 'Cannot calculate quantity in a shipment with a NULL shipment';
67779
 
  END IF;
67780
 
 
67781
 
  SELECT SUM(COALESCE(shipitem_qty, 0.0)) INTO _qty
67782
 
  FROM shipitem, shiphead
67783
 
  WHERE ((shipitem_shiphead_id=shiphead_id)
67784
 
      AND (shiphead_order_type=pordertype)
67785
 
      AND (shipitem_orderitem_id=plineitemid)
67786
 
      AND (shiphead_id=pshipheadid));
67787
 
 
67788
 
  IF (NOT FOUND) THEN
67789
 
    RAISE NOTICE 'Quantity of % item % is 0 because shipment % does not exist.',
67790
 
                  pordertype, plineitemid, pshipheadid;
67791
 
  END IF;
67792
 
 
67793
 
  RETURN _qty;
67794
 
 
67795
 
END;
67796
 
$_$;
67797
 
 
67798
 
 
67799
 
ALTER FUNCTION public.qtyinshipment(text, integer, integer) OWNER TO admin;
67800
 
 
67801
 
--
67802
 
--
67803
 
 
67804
 
CREATE FUNCTION qtylocation(integer, integer, date, date, integer, text, integer, integer) RETURNS numeric
67805
 
    LANGUAGE plpgsql
67806
 
    AS $_$
67807
 
DECLARE
67808
 
  pLocationId  ALIAS FOR $1;
67809
 
  pLsId        ALIAS FOR $2;
67810
 
  pExpiration  ALIAS FOR $3;
67811
 
  pWarranty    ALIAS FOR $4;
67812
 
  pItemsiteId  ALIAS FOR $5;
67813
 
  pOrderType   ALIAS FOR $6;
67814
 
  pOrderId     ALIAS FOR $7;
67815
 
  pItemlocdistId ALIAS FOR $8;
67816
 
  _qty         NUMERIC = 0.0;
67817
 
  _qtyDist     NUMERIC = 0.0;
67818
 
  _qtyReserved NUMERIC = 0.0;
67819
 
 
67820
 
BEGIN
67821
 
  SELECT COALESCE(SUM(itemloc_qty), 0) INTO _qty
67822
 
    FROM itemloc
67823
 
   WHERE ( (itemloc_itemsite_id=pItemsiteId)
67824
 
     AND (itemloc_location_id=pLocationId)
67825
 
     AND (COALESCE(itemloc_ls_id, -1)=COALESCE(pLsId, itemloc_ls_id, -1))
67826
 
     AND (COALESCE(itemloc_expiration, endoftime())=COALESCE(pExpiration, itemloc_expiration, endoftime()))
67827
 
     AND (COALESCE(itemloc_warrpurc, endoftime())=COALESCE(pWarranty, itemloc_warrpurc, endoftime())) );
67828
 
 
67829
 
  SELECT COALESCE(SUM(loc.itemlocdist_qty), 0) INTO _qtyDist
67830
 
    FROM itemlocdist loc
67831
 
      JOIN itemlocdist ls ON ((ls.itemlocdist_source_type='O')
67832
 
                          AND (ls.itemlocdist_id=loc.itemlocdist_itemlocdist_id))
67833
 
   WHERE ( (ls.itemlocdist_itemsite_id=pItemsiteId)
67834
 
     AND (loc.itemlocdist_source_type='L')
67835
 
     AND (loc.itemlocdist_source_id=pLocationId)
67836
 
     AND (COALESCE(ls.itemlocdist_ls_id, -1)=COALESCE(pLsId, ls.itemlocdist_ls_id, -1))
67837
 
     AND (COALESCE(ls.itemlocdist_expiration, endoftime())=COALESCE(pExpiration, ls.itemlocdist_expiration, endoftime()))
67838
 
     AND (COALESCE(ls.itemlocdist_warranty, endoftime())=COALESCE(pWarranty, ls.itemlocdist_warranty, endoftime()))
67839
 
     AND (ls.itemlocdist_id != pItemlocdistId ) );
67840
 
 
67841
 
  IF (fetchMetricBool('EnableSOReservationsByLocation')) THEN
67842
 
    SELECT COALESCE(SUM(reserve_qty), 0) INTO _qtyReserved
67843
 
      FROM itemloc JOIN reserve ON ( (reserve_supply_id=itemloc_id AND reserve_supply_type='I')
67844
 
                                    AND  ((reserve_demand_type <> COALESCE(pOrderType, '')) OR
67845
 
                                          (reserve_demand_id <> COALESCE(pOrderId, -1))) )
67846
 
     WHERE ( (itemloc_itemsite_id=pItemsiteId)
67847
 
       AND (itemloc_location_id=pLocationId)
67848
 
       AND (COALESCE(itemloc_ls_id, -1)=COALESCE(pLsId, itemloc_ls_id, -1))
67849
 
       AND (COALESCE(itemloc_expiration, endoftime())=COALESCE(pExpiration, itemloc_expiration, endoftime()))
67850
 
       AND (COALESCE(itemloc_warrpurc, endoftime())=COALESCE(pWarranty, itemloc_warrpurc, endoftime())) );
67851
 
  END IF;
67852
 
 
67853
 
  RETURN (_qty + _qtyDist - _qtyReserved);
67854
 
 
67855
 
END;
67856
 
$_$;
67857
 
 
67858
 
 
67859
 
ALTER FUNCTION public.qtylocation(integer, integer, date, date, integer, text, integer, integer) OWNER TO admin;
67860
 
 
67861
 
--
67862
 
--
67863
 
 
67864
 
CREATE FUNCTION qtynetable(pitemsiteid integer) RETURNS numeric
67865
 
    LANGUAGE plpgsql STABLE
67866
 
    AS $$
67867
 
DECLARE
67868
 
  _qty         NUMERIC = 0.0;
67869
 
 
67870
 
BEGIN
67871
 
  _qty := qtyNetable(pItemsiteId, TRUE);
67872
 
 
67873
 
  RETURN _qty;
67874
 
 
67875
 
END;
67876
 
$$;
67877
 
 
67878
 
 
67879
 
ALTER FUNCTION public.qtynetable(pitemsiteid integer) OWNER TO admin;
67880
 
 
67881
 
--
67882
 
--
67883
 
 
67884
 
CREATE FUNCTION qtynetable(pitemsiteid integer, pnetable boolean) RETURNS numeric
67885
 
    LANGUAGE plpgsql STABLE
67886
 
    AS $$
67887
 
DECLARE
67888
 
  _qty         NUMERIC = 0.0;
67889
 
 
67890
 
BEGIN
67891
 
  IF (pNetable) THEN
67892
 
    -- Summarize itemloc qty for this itemsite/netable locations
67893
 
    -- or use itemsite_qtyonhand for regular/non-lot
67894
 
    SELECT COALESCE(SUM(itemloc_qty), itemsite_qtyonhand) INTO _qty
67895
 
      FROM itemsite LEFT OUTER JOIN itemloc ON (itemloc_itemsite_id=itemsite_id)
67896
 
                    LEFT OUTER JOIN location ON (location_id=itemloc_location_id)
67897
 
     WHERE (itemsite_id=pItemsiteId)
67898
 
       AND ((location_id IS NULL) OR (COALESCE(location_netable, true)))
67899
 
     GROUP BY itemsite_qtyonhand;
67900
 
  ELSE
67901
 
    -- Summarize itemloc qty for this itemsite/non-netable locations
67902
 
    SELECT COALESCE(SUM(itemloc_qty), 0.0) INTO _qty
67903
 
      FROM itemloc JOIN location ON (location_id=itemloc_location_id)
67904
 
     WHERE (itemloc_itemsite_id=pItemsiteId)
67905
 
       AND (NOT COALESCE(location_netable, true));
67906
 
  END IF;
67907
 
 
67908
 
  RETURN _qty;
67909
 
 
67910
 
END;
67911
 
$$;
67912
 
 
67913
 
 
67914
 
ALTER FUNCTION public.qtynetable(pitemsiteid integer, pnetable boolean) OWNER TO admin;
67915
 
 
67916
 
--
67917
 
--
67918
 
 
67919
 
CREATE FUNCTION qtyordered(integer, integer) RETURNS numeric
67920
 
    LANGUAGE plpgsql
67921
 
    AS $_$
67922
 
DECLARE
67923
 
  pItemsiteid ALIAS FOR $1;
67924
 
  pLookahead ALIAS FOR $2;
67925
 
  _itemType TEXT;
67926
 
  _result NUMERIC;
67927
 
 
67928
 
BEGIN
67929
 
 
67930
 
  RETURN qtyOrdered(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookahead));
67931
 
 
67932
 
END;
67933
 
$_$;
67934
 
 
67935
 
 
67936
 
ALTER FUNCTION public.qtyordered(integer, integer) OWNER TO admin;
67937
 
 
67938
 
--
67939
 
--
67940
 
 
67941
 
CREATE FUNCTION qtyordered(integer, date) RETURNS numeric
67942
 
    LANGUAGE plpgsql
67943
 
    AS $_$
67944
 
DECLARE
67945
 
  pItemsiteid ALIAS FOR $1;
67946
 
  pDate ALIAS FOR $2;
67947
 
 
67948
 
BEGIN
67949
 
 
67950
 
  RETURN qtyOrdered(pItemsiteid, startOfTime(), pDate);
67951
 
 
67952
 
END;
67953
 
$_$;
67954
 
 
67955
 
 
67956
 
ALTER FUNCTION public.qtyordered(integer, date) OWNER TO admin;
67957
 
 
67958
 
--
67959
 
--
67960
 
 
67961
 
CREATE FUNCTION qtyordered(integer, date, date) RETURNS numeric
67962
 
    LANGUAGE plpgsql
67963
 
    AS $_$
67964
 
DECLARE
67965
 
  pItemsiteid ALIAS FOR $1;
67966
 
  pStartDate ALIAS FOR $2;
67967
 
  pEndDate ALIAS FOR $3;
67968
 
  _itemType TEXT;
67969
 
 
67970
 
BEGIN
67971
 
 
67972
 
  SELECT item_type INTO _itemType
67973
 
  FROM item, itemsite
67974
 
  WHERE ( (itemsite_item_id=item_id)
67975
 
   AND (itemsite_id=pItemsiteid) );
67976
 
 
67977
 
  IF ( SELECT metric_value
67978
 
        FROM metric
67979
 
        WHERE ((metric_name = 'MultiWhs')
67980
 
        AND (metric_value = 't'))) THEN
67981
 
    RETURN orderedByPo(pItemsiteid, pStartDate, pEndDate) +
67982
 
           orderedByWo(pItemsiteid, pStartDate, pEndDate) +
67983
 
           orderedByTo(pItemsiteid, pStartDate, pEndDate);
67984
 
  ELSE
67985
 
    RETURN orderedByPo(pItemsiteid, pStartDate, pEndDate) +
67986
 
           orderedByWo(pItemsiteid, pStartDate, pEndDate);
67987
 
 
67988
 
  END IF;
67989
 
 
67990
 
END;
67991
 
$_$;
67992
 
 
67993
 
 
67994
 
ALTER FUNCTION public.qtyordered(integer, date, date) OWNER TO admin;
67995
 
 
67996
 
--
67997
 
--
67998
 
 
67999
 
CREATE FUNCTION qtypr(integer, integer) RETURNS numeric
68000
 
    LANGUAGE plpgsql
68001
 
    AS $_$
68002
 
DECLARE
68003
 
  pItemsiteid ALIAS FOR $1;
68004
 
  pLookahead ALIAS FOR $2; 
68005
 
 
68006
 
BEGIN
68007
 
  RETURN qtypr(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookahead));
68008
 
END;
68009
 
$_$;
68010
 
 
68011
 
 
68012
 
ALTER FUNCTION public.qtypr(integer, integer) OWNER TO admin;
68013
 
 
68014
 
--
68015
 
--
68016
 
 
68017
 
CREATE FUNCTION qtypr(integer, date) RETURNS numeric
68018
 
    LANGUAGE plpgsql
68019
 
    AS $_$
68020
 
DECLARE
68021
 
  pItemsiteid ALIAS FOR $1;
68022
 
  pDate ALIAS FOR $2;
68023
 
 
68024
 
BEGIN
68025
 
  RETURN qtypr(pItemsiteid, startOfTime(), pDate);
68026
 
END;
68027
 
$_$;
68028
 
 
68029
 
 
68030
 
ALTER FUNCTION public.qtypr(integer, date) OWNER TO admin;
68031
 
 
68032
 
--
68033
 
--
68034
 
 
68035
 
CREATE FUNCTION qtypr(integer, date, date) RETURNS numeric
68036
 
    LANGUAGE plpgsql
68037
 
    AS $_$
68038
 
DECLARE
68039
 
  pItemsiteid ALIAS FOR $1;
68040
 
  pStartDate ALIAS FOR $2;
68041
 
  pEndDate ALIAS FOR $3;
68042
 
  _prtotal NUMERIC;
68043
 
 
68044
 
BEGIN
68045
 
 
68046
 
SELECT SUM(pr_qtyreq) INTO _prtotal
68047
 
  FROM pr
68048
 
  WHERE ((pr_status = 'O')
68049
 
    AND (pr_itemsite_id=pItemsiteid)
68050
 
    AND (pr_duedate BETWEEN pStartDate AND pEndDate));
68051
 
 
68052
 
 IF (_prtotal IS NULL) THEN
68053
 
     RETURN 0.0;
68054
 
 END IF;
68055
 
 
68056
 
 RETURN _prtotal;
68057
 
 
68058
 
END;
68059
 
$_$;
68060
 
 
68061
 
 
68062
 
ALTER FUNCTION public.qtypr(integer, date, date) OWNER TO admin;
68063
 
 
68064
 
--
68065
 
--
68066
 
 
68067
 
CREATE FUNCTION qtyreserved(integer) RETURNS numeric
68068
 
    LANGUAGE plpgsql
68069
 
    AS $_$
68070
 
DECLARE
68071
 
  pItemsiteid ALIAS FOR $1;
68072
 
  _qty NUMERIC;
68073
 
 
68074
 
BEGIN
68075
 
 
68076
 
  SELECT COALESCE(SUM(coitem_qtyreserved),0) INTO _qty
68077
 
    FROM coitem
68078
 
   WHERE(coitem_itemsite_id=pItemsiteid);
68079
 
 
68080
 
  RETURN _qty;
68081
 
END;
68082
 
$_$;
68083
 
 
68084
 
 
68085
 
ALTER FUNCTION public.qtyreserved(integer) OWNER TO admin;
68086
 
 
68087
 
--
68088
 
--
68089
 
 
68090
 
CREATE FUNCTION qtytoreceive(text, integer) RETURNS numeric
68091
 
    LANGUAGE plpgsql
68092
 
    AS $_$
68093
 
DECLARE
68094
 
  pordertype    ALIAS FOR $1;
68095
 
  porderitemid  ALIAS FOR $2;
68096
 
  _qty          NUMERIC;
68097
 
 
68098
 
BEGIN
68099
 
  IF (pordertype = 'TO' AND NOT fetchMetricBool('MultiWhs')) THEN
68100
 
    RETURN 0;
68101
 
  END IF;
68102
 
 
68103
 
  IF (pordertype = 'RA' AND NOT fetchMetricBool('EnableReturnAuth')) THEN
68104
 
    RETURN 0;
68105
 
  END IF;
68106
 
 
68107
 
  SELECT SUM(recv_qty) INTO _qty
68108
 
  FROM recv
68109
 
  WHERE ((recv_orderitem_id=porderitemid)
68110
 
    AND  (NOT recv_posted)
68111
 
    AND  (recv_order_type=pordertype));
68112
 
 
68113
 
  RETURN COALESCE(_qty, 0.0);
68114
 
 
68115
 
END;
68116
 
$_$;
68117
 
 
68118
 
 
68119
 
ALTER FUNCTION public.qtytoreceive(text, integer) OWNER TO admin;
68120
 
 
68121
 
--
68122
 
--
68123
 
 
68124
 
CREATE FUNCTION recallshipment(integer) RETURNS integer
68125
 
    LANGUAGE plpgsql
68126
 
    AS $_$
68127
 
BEGIN
68128
 
  RETURN recallShipment($1, CURRENT_TIMESTAMP);
68129
 
END;
68130
 
$_$;
68131
 
 
68132
 
 
68133
 
ALTER FUNCTION public.recallshipment(integer) OWNER TO admin;
68134
 
 
68135
 
--
68136
 
--
68137
 
 
68138
 
CREATE FUNCTION recallshipment(integer, timestamp with time zone) RETURNS integer
68139
 
    LANGUAGE plpgsql
68140
 
    AS $_$
68141
 
DECLARE
68142
 
  pshipheadid           ALIAS FOR $1;
68143
 
  _timestamp            TIMESTAMP WITH TIME ZONE := $2;
68144
 
  _allInvoiced          BOOLEAN;
68145
 
  _invoicePosted        BOOLEAN;
68146
 
  _in                   RECORD;
68147
 
  _co                   RECORD;
68148
 
  _cobill               RECORD;
68149
 
  _h                    RECORD;
68150
 
  _result               INTEGER;
68151
 
  _invhistid            INTEGER;
68152
 
  _itemlocSeries        INTEGER;
68153
 
  _qty                  NUMERIC;
68154
 
  _qtyToBill            NUMERIC;
68155
 
  _shiphead             RECORD;
68156
 
  _to                   RECORD;
68157
 
  _ti                   RECORD;
68158
 
  _value                NUMERIC;
68159
 
 
68160
 
BEGIN
68161
 
 
68162
 
  IF (_timestamp IS NULL) THEN
68163
 
    _timestamp := CURRENT_TIMESTAMP;
68164
 
  END IF;
68165
 
 
68166
 
  SELECT * INTO _shiphead
68167
 
  FROM shiphead
68168
 
  WHERE (shiphead_id=pshipheadid);
68169
 
  IF (NOT FOUND OR NOT _shiphead.shiphead_shipped) THEN
68170
 
    RETURN -1;
68171
 
  END IF;
68172
 
 
68173
 
  IF (_shiphead.shiphead_order_type = 'SO') THEN
68174
 
    SELECT cohead_number AS head_number, cohead_cust_id AS cust_id, cohead_prj_id AS prj_id,
68175
 
           cohead_saletype_id AS saletype_id, cohead_shipzone_id AS shipzone_id INTO _h
68176
 
      FROM cohead
68177
 
     WHERE (cohead_id=_shiphead.shiphead_order_id);
68178
 
    IF (NOT FOUND) THEN
68179
 
      RETURN -1;
68180
 
    END IF;
68181
 
 
68182
 
    SELECT COALESCE(BOOL_AND(shipitem_invoiced), FALSE) INTO _allInvoiced
68183
 
     FROM cobill, shipitem
68184
 
    WHERE ((cobill_coitem_id=shipitem_orderitem_id)
68185
 
      AND  (shipitem_shiphead_id=pshipheadid));
68186
 
 
68187
 
    IF (_allInvoiced AND NOT checkPrivilege('RecallInvoicedShipment')) THEN
68188
 
      RETURN -2;
68189
 
    END IF;
68190
 
 
68191
 
    -- Check for any associated posted Invoices
68192
 
    SELECT COALESCE(BOOL_AND(invchead_posted), FALSE) INTO _invoicePosted
68193
 
    FROM shipitem JOIN invcitem ON (invcitem_id=shipitem_invcitem_id)
68194
 
                  JOIN invchead ON (invchead_id=invcitem_invchead_id)
68195
 
    WHERE (shipitem_shiphead_id=pshipheadid);
68196
 
 
68197
 
    IF (_invoicePosted) THEN
68198
 
      RETURN -4;
68199
 
    END IF;
68200
 
 
68201
 
    -- Delete any associated unposted Invoices
68202
 
    FOR _in IN SELECT DISTINCT invchead_id
68203
 
                 FROM shipitem JOIN invcitem ON (invcitem_id=shipitem_invcitem_id)
68204
 
                               JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND
68205
 
                                                  (NOT invchead_posted) )
68206
 
                WHERE (shipitem_shiphead_id=pshipheadid) LOOP
68207
 
      SELECT deleteInvoice(_in.invchead_id) INTO _result;
68208
 
      IF (_result < 0) THEN
68209
 
        RETURN _result;
68210
 
      END IF;
68211
 
    END LOOP;
68212
 
 
68213
 
    FOR _co IN SELECT coitem_id, coitem_itemsite_id, coitem_qty_invuomratio, coitem_warranty, coitem_cos_accnt_id,
68214
 
                   itemsite_controlmethod
68215
 
                 FROM coitem
68216
 
                  JOIN itemsite ON (coitem_itemsite_id=itemsite_id)
68217
 
                WHERE(coitem_id IN (SELECT shipitem_orderitem_id
68218
 
                                      FROM shipitem, shiphead
68219
 
                                     WHERE((shipitem_shiphead_id=shiphead_id)
68220
 
                                       AND (shiphead_shipped)
68221
 
                                       AND (shiphead_id=pshipheadid)))) FOR UPDATE LOOP
68222
 
 
68223
 
      SELECT SUM(shipitem_qty),SUM(COALESCE(shipitem_value, 0)) INTO _qty, _value
68224
 
      FROM shipitem
68225
 
      WHERE ( (shipitem_orderitem_id=_co.coitem_id)
68226
 
       AND (shipitem_shiphead_id=pshipheadid) );
68227
 
 
68228
 
      UPDATE coitem
68229
 
      SET coitem_qtyshipped = (coitem_qtyshipped - _qty)
68230
 
      WHERE (coitem_id=_co.coitem_id);
68231
 
 
68232
 
      _qtyToBill := _qty;
68233
 
      FOR _cobill IN SELECT cobill_id, cobill_qty
68234
 
                         FROM cobill, shipitem
68235
 
                        WHERE ((cobill_coitem_id=shipitem_orderitem_id)
68236
 
                          AND  (shipitem_shiphead_id=pshipheadid)
68237
 
                          AND  (cobill_coitem_id=_co.coitem_id)) FOR UPDATE LOOP
68238
 
 
68239
 
        IF (noNeg(_cobill.cobill_qty - _qtyToBill) = 0) THEN
68240
 
          DELETE FROM cobill WHERE (cobill_id=_cobill.cobill_id);
68241
 
        ELSE
68242
 
          UPDATE cobill
68243
 
          SET cobill_qty = noNeg(cobill_qty - _qtyToBill)
68244
 
          WHERE (cobill_id=_cobill.cobill_id);
68245
 
        END IF;
68246
 
 
68247
 
        _qtyToBill = _qtyToBill - _cobill.cobill_qty;
68248
 
        EXIT WHEN (_qtyToBill <= 0.0);
68249
 
      END LOOP;
68250
 
 
68251
 
  --  Check to see if all of the cobills have been deleted for this cobmisc
68252
 
      IF (EXISTS(SELECT cobmisc_id
68253
 
                 FROM cobmisc JOIN cobill ON (cobill_cobmisc_id=cobmisc_id)
68254
 
                 WHERE (cobmisc_cohead_id=_shiphead.shiphead_order_id AND NOT cobmisc_posted))) THEN
68255
 
  --  Lines exist, update the freight
68256
 
        UPDATE cobmisc SET cobmisc_freight = (cobmisc_freight - _shiphead.shiphead_freight)
68257
 
        WHERE (cobmisc_cohead_id=_shiphead.shiphead_order_id AND NOT cobmisc_posted);
68258
 
      ELSE
68259
 
  --  No lines exist, delete the cobmisc
68260
 
        DELETE FROM cobmisc
68261
 
        WHERE (cobmisc_cohead_id=_shiphead.shiphead_order_id AND NOT cobmisc_posted);
68262
 
      END IF;
68263
 
 
68264
 
  --  Distribute to G/L, debit Shipping Asset, credit COS
68265
 
      IF (_co.itemsite_controlmethod != 'N') THEN
68266
 
        PERFORM insertGLTransaction( 'S/R', _shiphead.shiphead_order_type,
68267
 
                                   _h.head_number::TEXT, 'Recall Shipment',
68268
 
                                   CASE WHEN(COALESCE(_co.coitem_cos_accnt_id, -1) != -1)
68269
 
                                          THEN getPrjAccntId(_h.prj_id, _co.coitem_cos_accnt_id)
68270
 
                                        WHEN(_co.coitem_warranty = TRUE)
68271
 
                                          THEN getPrjAccntId(_h.prj_id, resolveCOWAccount(itemsite_id, _h.cust_id, _h.saletype_id, _h.shipzone_id))
68272
 
                                        ELSE getPrjAccntId(_h.prj_id, resolveCOSAccount(itemsite_id, _h.cust_id, _h.saletype_id, _h.shipzone_id))
68273
 
                                   END,
68274
 
                                   getPrjAccntId(_h.prj_id,costcat_shipasset_accnt_id), -1,
68275
 
                                   _value,
68276
 
                                   _timestamp::DATE )
68277
 
        FROM itemsite, costcat
68278
 
        WHERE ( (itemsite_costcat_id=costcat_id)
68279
 
         AND (itemsite_id=_co.coitem_itemsite_id) );
68280
 
       END IF;
68281
 
 
68282
 
    END LOOP;
68283
 
 
68284
 
    FOR _cobill IN SELECT cobill_id, cobill_qty
68285
 
                   FROM shipitem JOIN coitem sub ON (sub.coitem_id=shipitem_orderitem_id)
68286
 
                                 JOIN coitem kit ON (kit.coitem_id <> sub.coitem_id AND
68287
 
                                                     kit.coitem_cohead_id = sub.coitem_cohead_id AND
68288
 
                                                     kit.coitem_linenumber = sub.coitem_linenumber AND
68289
 
                                                     kit.coitem_subnumber = 0)
68290
 
                                 JOIN cobill ON (cobill_coitem_id=kit.coitem_id)
68291
 
                   WHERE (shipitem_shiphead_id=pshipheadid)
68292
 
                     AND (sub.coitem_subnumber > 0)
68293
 
                   GROUP BY cobill_id, cobill_qty
68294
 
    LOOP
68295
 
      UPDATE cobill SET cobill_qty = 0.0
68296
 
      WHERE (cobill_id=_cobill.cobill_id);
68297
 
    END LOOP;
68298
 
 
68299
 
  ELSEIF (_shiphead.shiphead_order_type = 'TO') THEN
68300
 
    SELECT * INTO _to
68301
 
      FROM tohead
68302
 
     WHERE (tohead_id=_shiphead.shiphead_order_id);
68303
 
    IF (NOT FOUND) THEN
68304
 
      RETURN -1;
68305
 
    END IF;
68306
 
    IF (_to.tohead_status = 'C') THEN
68307
 
      RETURN -6;
68308
 
    END IF;
68309
 
 
68310
 
    FOR _ti IN SELECT toitem_id,
68311
 
                      sis.itemsite_id AS src_itemsite_id,
68312
 
                      tis.itemsite_id AS trns_itemsite_id,
68313
 
                      scc.costcat_shipasset_accnt_id AS src_shipasset_accnt_id,
68314
 
                      tcc.costcat_asset_accnt_id AS trns_asset_accnt_id,
68315
 
                      itemcost(tis.itemsite_id) AS trns_cost,
68316
 
                      SUM(shipitem_qty) AS recall_qty
68317
 
               FROM shipitem JOIN toitem ON (toitem_id=shipitem_orderitem_id)
68318
 
                             JOIN itemsite sis ON (sis.itemsite_item_id=toitem_item_id AND sis.itemsite_warehous_id=_to.tohead_src_warehous_id)
68319
 
                             JOIN itemsite tis ON (tis.itemsite_item_id=toitem_item_id AND tis.itemsite_warehous_id=_to.tohead_trns_warehous_id)
68320
 
                             JOIN costcat scc ON (scc.costcat_id=sis.itemsite_costcat_id)
68321
 
                             JOIN costcat tcc ON (tcc.costcat_id=tis.itemsite_costcat_id)
68322
 
               WHERE (shipitem_shiphead_id=pshipheadid)
68323
 
               GROUP BY toitem_id, sis.itemsite_id, tis.itemsite_id,
68324
 
                        scc.costcat_shipasset_accnt_id, tcc.costcat_asset_accnt_id
68325
 
    LOOP
68326
 
 
68327
 
      _itemlocSeries := NEXTVAL('itemloc_series_seq');
68328
 
      
68329
 
      SELECT postInvTrans(_ti.src_itemsite_id, 'TS', (_ti.recall_qty * -1.0), 'I/M',
68330
 
                          _shiphead.shiphead_order_type, formatToNumber(_ti.toitem_id),
68331
 
                          _to.tohead_number,
68332
 
                          'Recall TO Shipment To Src Warehouse',
68333
 
                          _ti.trns_asset_accnt_id,
68334
 
                          _ti.src_shipasset_accnt_id,
68335
 
                          _itemlocSeries, _timestamp,
68336
 
                          (_ti.trns_cost * _ti.recall_qty * -1.0)) INTO _invhistid;
68337
 
 
68338
 
      IF (_invhistid < 0) THEN
68339
 
        RETURN _invhistid;
68340
 
      END IF;
68341
 
 
68342
 
      -- post the inventory history if lot/serial or location control
68343
 
      PERFORM postItemlocseries(_itemlocSeries);
68344
 
 
68345
 
      -- record inventory history and qoh changes at transit warehouse but
68346
 
      -- there is only one g/l account to touch
68347
 
      SELECT postInvTrans(_ti.trns_itemsite_id, 'TR', (_ti.recall_qty * -1.0), 'I/M',
68348
 
                          _shiphead.shiphead_order_type, formatToNumber(_ti.toitem_id),
68349
 
                          _to.tohead_number,
68350
 
                          'Recall TO Shipment From Transit Warehouse',
68351
 
                          _ti.trns_asset_accnt_id,
68352
 
                          _ti.trns_asset_accnt_id,
68353
 
                          _itemlocSeries, _timestamp,
68354
 
                          (_ti.trns_cost * _ti.recall_qty * -1.0)) INTO _invhistid;
68355
 
 
68356
 
      IF (_invhistid < 0) THEN
68357
 
        RETURN _invhistid;
68358
 
      END IF;
68359
 
 
68360
 
      -- post the inventory history if lot/serial or location control
68361
 
      PERFORM postItemlocseries(_itemlocSeries);
68362
 
 
68363
 
      UPDATE toitem
68364
 
      SET toitem_qty_shipped = (toitem_qty_shipped - _ti.recall_qty)
68365
 
      WHERE (toitem_id=_ti.toitem_id);
68366
 
 
68367
 
      UPDATE shipitem SET shipitem_shipdate=NULL,
68368
 
                          shipitem_shipped=FALSE,
68369
 
                          shipitem_value=(shipitem_qty * _ti.trns_cost)
68370
 
      WHERE ((shipitem_orderitem_id=_ti.toitem_id)
68371
 
        AND  (shipitem_shiphead_id=pshipheadid));
68372
 
 
68373
 
      DELETE FROM recv
68374
 
        WHERE ((recv_orderitem_id=_ti.toitem_id)
68375
 
          AND  (recv_order_type='TO')
68376
 
          AND  (NOT recv_posted));
68377
 
 
68378
 
    END LOOP;
68379
 
 
68380
 
  END IF;
68381
 
 
68382
 
  UPDATE shiphead
68383
 
  SET shiphead_shipped=FALSE
68384
 
  WHERE (shiphead_id=pshipheadid);
68385
 
 
68386
 
  RETURN _itemlocSeries;
68387
 
 
68388
 
END;
68389
 
$_$;
68390
 
 
68391
 
 
68392
 
ALTER FUNCTION public.recallshipment(integer, timestamp with time zone) OWNER TO admin;
68393
 
 
68394
 
--
68395
 
--
68396
 
 
68397
 
CREATE FUNCTION recallwo(integer, boolean) RETURNS integer
68398
 
    LANGUAGE plpgsql
68399
 
    AS $_$
68400
 
DECLARE
68401
 
  pWoid ALIAS FOR $1;
68402
 
  recallChildren ALIAS FOR $2;
68403
 
  returnCode INTEGER;
68404
 
 
68405
 
BEGIN
68406
 
 
68407
 
  UPDATE wo
68408
 
  SET wo_status='E'
68409
 
  WHERE ((wo_status='R')
68410
 
   AND (wo_id=pWoid));
68411
 
 
68412
 
  IF (recallChildren) THEN
68413
 
    returnCode := (SELECT MAX(recallWo(wo_id, TRUE))
68414
 
                   FROM wo
68415
 
                   WHERE ((wo_ordtype='W')
68416
 
                    AND (wo_ordid=pWoid)));
68417
 
  END IF;
68418
 
 
68419
 
  RETURN 0;
68420
 
END;
68421
 
$_$;
68422
 
 
68423
 
 
68424
 
ALTER FUNCTION public.recallwo(integer, boolean) OWNER TO admin;
68425
 
 
68426
 
--
68427
 
--
68428
 
 
68429
 
CREATE FUNCTION receipts(text) RETURNS boolean
68430
 
    LANGUAGE plpgsql
68431
 
    AS $_$
68432
 
DECLARE
68433
 
  pTransType ALIAS FOR $1;
68434
 
 
68435
 
BEGIN
68436
 
  IF (pTransType IN ('RM', 'RB', 'RT', 'RP', 'RR', 'RX', 'TR')) THEN
68437
 
    RETURN TRUE;
68438
 
  ELSE
68439
 
    RETURN FALSE;
68440
 
  END IF;
68441
 
 
68442
 
END;
68443
 
$_$;
68444
 
 
68445
 
 
68446
 
ALTER FUNCTION public.receipts(text) OWNER TO admin;
68447
 
 
68448
 
--
68449
 
--
68450
 
 
68451
 
CREATE FUNCTION releaseapmemonumber(integer) RETURNS boolean
68452
 
    LANGUAGE sql
68453
 
    AS $_$
68454
 
  SELECT releaseNumber('APMemoNumber', $1::INTEGER) > 0;
68455
 
$_$;
68456
 
 
68457
 
 
68458
 
ALTER FUNCTION public.releaseapmemonumber(integer) OWNER TO admin;
68459
 
 
68460
 
--
68461
 
--
68462
 
 
68463
 
CREATE FUNCTION releasearmemonumber(integer) RETURNS boolean
68464
 
    LANGUAGE sql
68465
 
    AS $_$
68466
 
  select releaseNumber('ARMemoNumber', $1::INTEGER) > 0;
68467
 
$_$;
68468
 
 
68469
 
 
68470
 
ALTER FUNCTION public.releasearmemonumber(integer) OWNER TO admin;
68471
 
 
68472
 
--
68473
 
--
68474
 
 
68475
 
CREATE FUNCTION releasecashrcptnumber(integer) RETURNS boolean
68476
 
    LANGUAGE sql
68477
 
    AS $_$
68478
 
  SELECT releaseNumber('CashRcptNumber', $1) > 0;
68479
 
$_$;
68480
 
 
68481
 
 
68482
 
ALTER FUNCTION public.releasecashrcptnumber(integer) OWNER TO admin;
68483
 
 
68484
 
--
68485
 
--
68486
 
 
68487
 
CREATE FUNCTION releasecmnumber(integer) RETURNS boolean
68488
 
    LANGUAGE sql
68489
 
    AS $_$
68490
 
  SELECT releaseNumber('CmNumber', $1) > 0;
68491
 
$_$;
68492
 
 
68493
 
 
68494
 
ALTER FUNCTION public.releasecmnumber(integer) OWNER TO admin;
68495
 
 
68496
 
--
68497
 
--
68498
 
 
68499
 
CREATE FUNCTION releasecmnumber(text) RETURNS boolean
68500
 
    LANGUAGE sql
68501
 
    AS $_$
68502
 
  SELECT releaseNumber('CmNumber', $1::INTEGER) > 0;
68503
 
$_$;
68504
 
 
68505
 
 
68506
 
ALTER FUNCTION public.releasecmnumber(text) OWNER TO admin;
68507
 
 
68508
 
--
68509
 
--
68510
 
 
68511
 
CREATE FUNCTION releasecrmaccountnumber(integer) RETURNS boolean
68512
 
    LANGUAGE sql
68513
 
    AS $_$
68514
 
  SELECT releaseNumber('CRMAccountNumber', $1::INTEGER) > 0;
68515
 
$_$;
68516
 
 
68517
 
 
68518
 
ALTER FUNCTION public.releasecrmaccountnumber(integer) OWNER TO admin;
68519
 
 
68520
 
--
68521
 
--
68522
 
 
68523
 
CREATE FUNCTION releaseincidentnumber(integer) RETURNS boolean
68524
 
    LANGUAGE sql
68525
 
    AS $_$
68526
 
  SELECT releaseNumber('IncidentNumber', $1) = 1;
68527
 
$_$;
68528
 
 
68529
 
 
68530
 
ALTER FUNCTION public.releaseincidentnumber(integer) OWNER TO admin;
68531
 
 
68532
 
--
68533
 
--
68534
 
 
68535
 
CREATE FUNCTION releaseinvcnumber(integer) RETURNS boolean
68536
 
    LANGUAGE sql
68537
 
    AS $_$
68538
 
  SELECT releaseNumber('InvcNumber', $1) > 0;
68539
 
$_$;
68540
 
 
68541
 
 
68542
 
ALTER FUNCTION public.releaseinvcnumber(integer) OWNER TO admin;
68543
 
 
68544
 
--
68545
 
--
68546
 
 
68547
 
CREATE FUNCTION releaseinvcnumber(text) RETURNS boolean
68548
 
    LANGUAGE sql
68549
 
    AS $_$
68550
 
  SELECT releaseNumber('InvcNumber', $1::INTEGER) > 0;
68551
 
$_$;
68552
 
 
68553
 
 
68554
 
ALTER FUNCTION public.releaseinvcnumber(text) OWNER TO admin;
68555
 
 
68556
 
--
68557
 
--
68558
 
 
68559
 
CREATE FUNCTION releasenumber(text, integer) RETURNS integer
68560
 
    LANGUAGE plpgsql
68561
 
    AS $_$
68562
 
DECLARE
68563
 
  psequence     ALIAS FOR $1;
68564
 
  pnumber       ALIAS FOR $2;
68565
 
BEGIN
68566
 
  IF (fetchMetricBool('EnableGaplessNumbering')) THEN
68567
 
    -- drop the number back into the pool if it was not committed
68568
 
    PERFORM clearNumberIssue(psequence, pnumber);
68569
 
  END IF;
68570
 
  
68571
 
  UPDATE orderseq SET
68572
 
    orderseq_number = LEAST(pnumber, orderseq_number)
68573
 
  WHERE (orderseq_name=psequence);
68574
 
 
68575
 
  RETURN 1;
68576
 
END;
68577
 
$_$;
68578
 
 
68579
 
 
68580
 
ALTER FUNCTION public.releasenumber(text, integer) OWNER TO admin;
68581
 
 
68582
 
--
68583
 
--
68584
 
 
68585
 
CREATE FUNCTION releaseponumber(integer) RETURNS boolean
68586
 
    LANGUAGE sql
68587
 
    AS $_$
68588
 
  SELECT releaseNumber('PoNumber', $1) > 0;
68589
 
$_$;
68590
 
 
68591
 
 
68592
 
ALTER FUNCTION public.releaseponumber(integer) OWNER TO admin;
68593
 
 
68594
 
--
68595
 
--
68596
 
 
68597
 
CREATE FUNCTION releaseponumber(text) RETURNS boolean
68598
 
    LANGUAGE sql
68599
 
    AS $_$
68600
 
  SELECT releaseNumber('PoNumber', $1::INTEGER) > 0;
68601
 
$_$;
68602
 
 
68603
 
 
68604
 
ALTER FUNCTION public.releaseponumber(text) OWNER TO admin;
68605
 
 
68606
 
--
68607
 
--
68608
 
 
68609
 
CREATE FUNCTION releasepr(pprid integer) RETURNS integer
68610
 
    LANGUAGE plpgsql
68611
 
    AS $$
68612
 
DECLARE
68613
 
  _pr RECORD;
68614
 
  _w RECORD;
68615
 
  _i RECORD;
68616
 
  _rows INTEGER := 0;
68617
 
  _itemsrcid INTEGER := -1;
68618
 
  _poheadid INTEGER := -1;
68619
 
  _poitemid INTEGER := -1;
68620
 
  _taxtypeid INTEGER := -1;
68621
 
  _polinenumber INTEGER;
68622
 
  _ponumber NUMERIC;
68623
 
  _price NUMERIC;
68624
 
 
68625
 
BEGIN
68626
 
 
68627
 
  -- Cache information
68628
 
  SELECT *,
68629
 
         CASE WHEN(pr_order_type='W') THEN pr_order_id
68630
 
              ELSE -1
68631
 
         END AS parentwo,
68632
 
         CASE WHEN(pr_order_type='S') THEN pr_order_id
68633
 
              ELSE -1
68634
 
         END AS parentso
68635
 
  INTO _pr
68636
 
  FROM pr LEFT OUTER JOIN itemsite ON (pr_itemsite_id = itemsite_id)
68637
 
          LEFT OUTER JOIN item ON (item_id = itemsite_item_id)
68638
 
          LEFT OUTER JOIN prj ON (prj_id = pr_prj_id)
68639
 
  WHERE (pr_id = pPrId);
68640
 
  IF (NOT FOUND) THEN
68641
 
    RETURN -1;
68642
 
  END IF;
68643
 
 
68644
 
  SELECT * INTO _w
68645
 
  FROM itemsite JOIN whsinfo ON (warehous_id = itemsite_warehous_id)
68646
 
                LEFT OUTER JOIN addr ON (warehous_addr_id = addr_id)
68647
 
                LEFT OUTER JOIN cntct ON (warehous_cntct_id = cntct_id)
68648
 
  WHERE (itemsite_id = _pr.itemsite_id);
68649
 
 
68650
 
  -- Must either be a single itemsrc or a default itemsrc
68651
 
  SELECT itemsrc_id INTO _itemsrcid
68652
 
  FROM itemsrc
68653
 
  WHERE (itemsrc_item_id = _pr.item_id)
68654
 
    AND (_pr.pr_duedate BETWEEN COALESCE(itemsrc_effective, startOfTime()) AND COALESCE(itemsrc_expires, endOfTime()))
68655
 
    AND (itemsrc_default);
68656
 
  IF (NOT FOUND) THEN
68657
 
    SELECT MAX(itemsrc_id), count(*) INTO _itemsrcid, _rows
68658
 
    FROM itemsrc
68659
 
    WHERE (itemsrc_item_id = _pr.item_id)
68660
 
      AND (_pr.pr_duedate BETWEEN COALESCE(itemsrc_effective, startOfTime()) AND COALESCE(itemsrc_expires, endOfTime()))
68661
 
    GROUP BY itemsrc_item_id;
68662
 
    IF (NOT FOUND) THEN
68663
 
      RETURN -2;
68664
 
    END IF;
68665
 
    IF (_rows > 1) THEN
68666
 
      RETURN -2;
68667
 
    END IF;
68668
 
  END IF;
68669
 
    
68670
 
  SELECT * INTO _i
68671
 
  FROM itemsrc JOIN vendinfo ON (itemsrc_vend_id = vend_id)
68672
 
               LEFT OUTER JOIN cntct ON (vend_cntct1_id = cntct_id)
68673
 
               LEFT OUTER JOIN addr ON (vend_addr_id = addr_id)
68674
 
  WHERE (itemsrc_id = _itemsrcid);
68675
 
 
68676
 
  RAISE NOTICE 'releasepr selected itemsrc_id = % for pr = %', _itemsrcid, _pr.pr_id;
68677
 
 
68678
 
  -- Find matching unreleased PO
68679
 
  SELECT COALESCE(pohead_id, -1) INTO _poheadid
68680
 
  FROM pohead
68681
 
  WHERE ( (pohead_status = 'U')
68682
 
    AND (pohead_vend_id = _i.itemsrc_vend_id)
68683
 
    AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_w.addr_line1, ''))
68684
 
    AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_w.addr_line2, ''))
68685
 
    AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_w.addr_line3, ''))
68686
 
    AND (COALESCE(pohead_shiptocity, '') = COALESCE(_w.addr_city, ''))
68687
 
    AND (COALESCE(pohead_shiptostate, '') = COALESCE(_w.addr_state, ''))
68688
 
    AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_w.addr_postalcode, ''))
68689
 
    AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_w.addr_country, '')) );
68690
 
 
68691
 
  IF (NOT FOUND) THEN
68692
 
    -- Create new PO
68693
 
    SELECT NEXTVAL('pohead_pohead_id_seq') INTO _poheadid;
68694
 
    SELECT fetchPoNumber() INTO _ponumber;
68695
 
 
68696
 
    INSERT INTO pohead
68697
 
      ( pohead_id, pohead_number, pohead_status, pohead_dropship,
68698
 
        pohead_agent_username, pohead_vend_id, pohead_taxzone_id,
68699
 
        pohead_orderdate, pohead_curr_id, pohead_cohead_id,
68700
 
        pohead_warehous_id, pohead_shipvia,
68701
 
        pohead_terms_id, pohead_shipto_cntct_id,
68702
 
        pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name,
68703
 
        pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name,
68704
 
        pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone,
68705
 
        pohead_shipto_cntct_title, pohead_shipto_cntct_fax, 
68706
 
        pohead_shipto_cntct_email, pohead_shiptoaddress_id,
68707
 
        pohead_shiptoaddress1,
68708
 
        pohead_shiptoaddress2,
68709
 
        pohead_shiptoaddress3,
68710
 
        pohead_shiptocity, 
68711
 
        pohead_shiptostate, pohead_shiptozipcode,
68712
 
        pohead_shiptocountry, pohead_vend_cntct_id,
68713
 
        pohead_vend_cntct_honorific, pohead_vend_cntct_first_name,
68714
 
        pohead_vend_cntct_middle, pohead_vend_cntct_last_name,
68715
 
        pohead_vend_cntct_suffix, pohead_vend_cntct_phone,
68716
 
        pohead_vend_cntct_title, pohead_vend_cntct_fax,
68717
 
        pohead_vend_cntct_email, pohead_vendaddress1,
68718
 
        pohead_vendaddress2, pohead_vendaddress3,
68719
 
        pohead_vendcity, pohead_vendstate,
68720
 
        pohead_vendzipcode, pohead_vendcountry )
68721
 
    VALUES
68722
 
      ( _poheadid, _ponumber, 'U', FALSE,
68723
 
        getEffectiveXtUser(), _i.itemsrc_vend_id, _i.vend_taxzone_id,
68724
 
        CURRENT_DATE, COALESCE(_i.vend_curr_id, basecurrid()), NULL,
68725
 
        COALESCE(_pr.itemsite_warehous_id, -1), COALESCE(_i.vend_shipvia, TEXT('')),
68726
 
        COALESCE(_i.vend_terms_id, -1), _w.cntct_id,
68727
 
        _w.cntct_honorific, _w.cntct_first_name,
68728
 
        _w.cntct_middle, _w.cntct_last_name,
68729
 
        _w.cntct_suffix, _w.cntct_phone,
68730
 
        _w.cntct_title, _w.cntct_fax,
68731
 
        _w.cntct_email, _w.addr_id,
68732
 
        COALESCE(_w.addr_line1, ''),
68733
 
        COALESCE(_w.addr_line2, ''),
68734
 
        COALESCE(_w.addr_line3, ''),
68735
 
        COALESCE(_w.addr_city, ''),
68736
 
        COALESCE(_w.addr_state, ''), COALESCE(_w.addr_postalcode, ''),
68737
 
        COALESCE(_w.addr_country, ''), _i.cntct_id,
68738
 
        COALESCE(_i.cntct_honorific, TEXT('')), COALESCE(_i.cntct_first_name, TEXT('')),
68739
 
        COALESCE(_i.cntct_middle, TEXT('')), COALESCE(_i.cntct_last_name, TEXT('')),
68740
 
        COALESCE(_i.cntct_suffix, TEXT('')), COALESCE(_i.cntct_phone, TEXT('')),
68741
 
        COALESCE(_i.cntct_title, TEXT('')), COALESCE(_i.cntct_fax, TEXT('')),
68742
 
        COALESCE(_i.cntct_email, TEXT('')), COALESCE(_i.addr_line1, TEXT('')),
68743
 
        COALESCE(_i.addr_line2, TEXT('')), COALESCE(_i.addr_line3, TEXT('')),
68744
 
        COALESCE(_i.addr_city, TEXT('')), COALESCE(_i.addr_state, TEXT('')),
68745
 
        COALESCE(_i.addr_postalcode, TEXT('')), COALESCE(_i.addr_country, TEXT('')) );
68746
 
  END IF;
68747
 
 
68748
 
  SELECT NEXTVAL('poitem_poitem_id_seq') INTO _poitemid;
68749
 
 
68750
 
  SELECT (COALESCE(MAX(poitem_linenumber), 0) + 1) INTO _polinenumber
68751
 
  FROM poitem
68752
 
  WHERE (poitem_pohead_id = _poheadid);
68753
 
 
68754
 
  SELECT COALESCE(itemtax_taxtype_id, -1) INTO _taxtypeid
68755
 
  FROM itemtax
68756
 
  WHERE (itemtax_item_id = _i.itemsrc_item_id);
68757
 
 
68758
 
  SELECT itemsrcPrice(_i.itemsrc_id,
68759
 
                      COALESCE(_pr.itemsite_warehous_id, -1),
68760
 
                      FALSE,
68761
 
                      (_pr.pr_qtyreq / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)),
68762
 
                      COALESCE(_i.vend_curr_id, baseCurrId()),
68763
 
                      CURRENT_DATE) INTO _price;
68764
 
 
68765
 
  -- Create PO Item
68766
 
  INSERT INTO poitem
68767
 
    ( poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, 
68768
 
      poitem_duedate, poitem_itemsite_id,
68769
 
      poitem_vend_item_descrip, poitem_vend_uom,
68770
 
      poitem_invvenduomratio, poitem_qty_ordered, 
68771
 
      poitem_unitprice, poitem_vend_item_number, 
68772
 
      poitem_itemsrc_id, poitem_order_id, poitem_order_type, poitem_prj_id, poitem_stdcost, 
68773
 
      poitem_manuf_name, poitem_manuf_item_number, 
68774
 
      poitem_manuf_item_descrip, poitem_taxtype_id, poitem_comments )
68775
 
  VALUES
68776
 
    ( _poitemid, 'U', _poheadid, _polinenumber,
68777
 
      _pr.pr_duedate, _pr.itemsite_id,
68778
 
      COALESCE(_i.itemsrc_vend_item_descrip, TEXT('')), COALESCE(_i.itemsrc_vend_uom, TEXT('')),
68779
 
      COALESCE(_i.itemsrc_invvendoruomratio, 1.00), (_pr.pr_qtyreq / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)),
68780
 
      _price, COALESCE(_i.itemsrc_vend_item_number, TEXT('')),
68781
 
      _i.itemsrc_id, _pr.pr_order_id, _pr.pr_order_type, _pr.prj_id, stdcost(_i.itemsrc_item_id),
68782
 
      COALESCE(_i.itemsrc_manuf_name, TEXT('')), COALESCE(_i.itemsrc_manuf_item_number, TEXT('')),
68783
 
      COALESCE(_i.itemsrc_manuf_item_descrip, TEXT('')), _taxtypeid,
68784
 
      COALESCE(_pr.pr_releasenote, TEXT('')));
68785
 
 
68786
 
  -- Copy characteristics from the pr to the poitem
68787
 
  INSERT INTO charass
68788
 
    ( charass_target_type, charass_target_id, charass_char_id,
68789
 
      charass_value, charass_default, charass_price )
68790
 
  SELECT 'PI', _poitemid, charass_char_id,
68791
 
         charass_value, charass_default, charass_price
68792
 
  FROM charass
68793
 
  WHERE ( (charass_target_type='PR')
68794
 
    AND   (charass_target_id=pPrId) );
68795
 
 
68796
 
  -- Delete the PR
68797
 
  PERFORM deletePr(pPrId);
68798
 
 
68799
 
  RETURN _poitemid;
68800
 
 
68801
 
END;
68802
 
$$;
68803
 
 
68804
 
 
68805
 
ALTER FUNCTION public.releasepr(pprid integer) OWNER TO admin;
68806
 
 
68807
 
--
68808
 
--
68809
 
 
68810
 
CREATE FUNCTION releaseprnumber(integer) RETURNS boolean
68811
 
    LANGUAGE sql
68812
 
    AS $_$
68813
 
  SELECT releaseNumber('PrNumber', $1) > 0;
68814
 
$_$;
68815
 
 
68816
 
 
68817
 
ALTER FUNCTION public.releaseprnumber(integer) OWNER TO admin;
68818
 
 
68819
 
--
68820
 
--
68821
 
 
68822
 
CREATE FUNCTION releasepurchaseorder(integer) RETURNS integer
68823
 
    LANGUAGE plpgsql
68824
 
    AS $_$
68825
 
DECLARE
68826
 
  pPoheadid ALIAS FOR $1;
68827
 
 
68828
 
BEGIN
68829
 
 
68830
 
  IF ( ( SELECT (COUNT(*) = 0)
68831
 
         FROM poitem
68832
 
         WHERE ( (poitem_pohead_id=pPoheadid)
68833
 
           AND   (poitem_status='U') ) ) ) THEN
68834
 
    RETURN -1;
68835
 
  END IF;
68836
 
 
68837
 
  IF ( ( SELECT (pohead_status='U')
68838
 
         FROM pohead
68839
 
         WHERE (pohead_id=pPoheadid) ) ) THEN
68840
 
 
68841
 
    --update status and store the date that the order was released on
68842
 
    UPDATE pohead
68843
 
    SET pohead_status='O', pohead_released = current_date
68844
 
    WHERE (pohead_id=pPoheadid);
68845
 
 
68846
 
  END IF;
68847
 
 
68848
 
  --update status and store the duedates at release
68849
 
  UPDATE poitem
68850
 
  SET poitem_status='O', poitem_rlsd_duedate = poitem_duedate
68851
 
  WHERE (poitem_pohead_id=pPoheadid);
68852
 
 
68853
 
  RETURN 1;
68854
 
 
68855
 
END;
68856
 
$_$;
68857
 
 
68858
 
 
68859
 
ALTER FUNCTION public.releasepurchaseorder(integer) OWNER TO admin;
68860
 
 
68861
 
--
68862
 
--
68863
 
 
68864
 
CREATE FUNCTION releasequnumber(integer) RETURNS integer
68865
 
    LANGUAGE sql
68866
 
    AS $_$
68867
 
  SELECT releaseNumber('QuNumber', $1);
68868
 
$_$;
68869
 
 
68870
 
 
68871
 
ALTER FUNCTION public.releasequnumber(integer) OWNER TO admin;
68872
 
 
68873
 
--
68874
 
--
68875
 
 
68876
 
CREATE FUNCTION releasequnumber(text) RETURNS integer
68877
 
    LANGUAGE sql
68878
 
    AS $_$
68879
 
  SELECT releaseNumber('QuNumber', $1::INTEGER);
68880
 
$_$;
68881
 
 
68882
 
 
68883
 
ALTER FUNCTION public.releasequnumber(text) OWNER TO admin;
68884
 
 
68885
 
--
68886
 
--
68887
 
 
68888
 
CREATE FUNCTION releaseshipmentnumber(integer) RETURNS boolean
68889
 
    LANGUAGE plpgsql
68890
 
    AS $_$
68891
 
DECLARE
68892
 
  pNumber ALIAS FOR $1;
68893
 
  _test INTEGER;
68894
 
 
68895
 
BEGIN
68896
 
 
68897
 
  SELECT shiphead_id INTO _test
68898
 
  FROM shiphead
68899
 
  WHERE (shiphead_number=pNumber);
68900
 
 
68901
 
  IF (FOUND) THEN
68902
 
    RETURN FALSE;
68903
 
  END IF;
68904
 
 
68905
 
  SELECT orderseq_number INTO _test
68906
 
  FROM orderseq
68907
 
  WHERE (orderseq_name='ShipmentNumber');
68908
 
 
68909
 
  IF ((_test - 1) <> pNumber) THEN
68910
 
    RETURN FALSE;
68911
 
  END IF;
68912
 
 
68913
 
  UPDATE orderseq
68914
 
  SET orderseq_number = (orderseq_number - 1)
68915
 
  WHERE (orderseq_name='ShipmentNumber');
68916
 
 
68917
 
  RETURN TRUE;
68918
 
 
68919
 
END;
68920
 
$_$;
68921
 
 
68922
 
 
68923
 
ALTER FUNCTION public.releaseshipmentnumber(integer) OWNER TO admin;
68924
 
 
68925
 
--
68926
 
--
68927
 
 
68928
 
CREATE FUNCTION releasesohead(integer) RETURNS boolean
68929
 
    LANGUAGE plpgsql
68930
 
    AS $_$
68931
 
DECLARE
68932
 
  pSoheadid ALIAS FOR $1;
68933
 
 
68934
 
BEGIN
68935
 
 
68936
 
  DELETE FROM soheadlock
68937
 
   WHERE ( (soheadlock_sohead_id=pSoheadid)
68938
 
     AND   (soheadlock_username=getEffectiveXtUser())
68939
 
     AND   (soheadlock_procpid=pg_backend_pid()) );
68940
 
 
68941
 
  RETURN TRUE;
68942
 
END;
68943
 
$_$;
68944
 
 
68945
 
 
68946
 
ALTER FUNCTION public.releasesohead(integer) OWNER TO admin;
68947
 
 
68948
 
--
68949
 
--
68950
 
 
68951
 
CREATE FUNCTION releasesonumber(integer) RETURNS integer
68952
 
    LANGUAGE sql
68953
 
    AS $_$
68954
 
  SELECT releaseNumber('SoNumber', $1);
68955
 
$_$;
68956
 
 
68957
 
 
68958
 
ALTER FUNCTION public.releasesonumber(integer) OWNER TO admin;
68959
 
 
68960
 
--
68961
 
--
68962
 
 
68963
 
CREATE FUNCTION releasesonumber(text) RETURNS integer
68964
 
    LANGUAGE plpgsql
68965
 
    AS $_$
68966
 
BEGIN
68967
 
        IF (COALESCE($1, '') = '' OR $1 ~ '[^0-9]')
68968
 
        THEN
68969
 
        --do nothing;
68970
 
        RETURN 1;
68971
 
        ELSE
68972
 
        RETURN releaseNumber('SoNumber', $1::INTEGER);
68973
 
        
68974
 
        END IF;
68975
 
END;
68976
 
$_$;
68977
 
 
68978
 
 
68979
 
ALTER FUNCTION public.releasesonumber(text) OWNER TO admin;
68980
 
 
68981
 
--
68982
 
--
68983
 
 
68984
 
CREATE FUNCTION releaseunusedbillingheader(integer) RETURNS integer
68985
 
    LANGUAGE plpgsql
68986
 
    AS $_$
68987
 
DECLARE
68988
 
  pCobmiscid ALIAS FOR $1;
68989
 
  _p RECORD;
68990
 
 
68991
 
BEGIN
68992
 
 
68993
 
  IF ( ( SELECT cobmisc_posted
68994
 
         FROM cobmisc
68995
 
         WHERE (cobmisc_id=pCobmiscid) ) ) THEN
68996
 
    RETURN -1;
68997
 
  END IF;
68998
 
 
68999
 
  SELECT cobill_id INTO _p
69000
 
    FROM cobill
69001
 
   WHERE (cobill_cobmisc_id=pCobmiscid)
69002
 
   LIMIT 1;
69003
 
  IF (FOUND) THEN
69004
 
    RETURN -2;
69005
 
  END IF;
69006
 
 
69007
 
  DELETE FROM cobmisc
69008
 
  WHERE (cobmisc_id=pCobmiscid);
69009
 
 
69010
 
  RETURN 0;
69011
 
END;
69012
 
$_$;
69013
 
 
69014
 
 
69015
 
ALTER FUNCTION public.releaseunusedbillingheader(integer) OWNER TO admin;
69016
 
 
69017
 
--
69018
 
--
69019
 
 
69020
 
CREATE FUNCTION releasevonumber(integer) RETURNS boolean
69021
 
    LANGUAGE sql
69022
 
    AS $_$
69023
 
  SELECT releaseNumber('VcNumber', $1) > 0;
69024
 
$_$;
69025
 
 
69026
 
 
69027
 
ALTER FUNCTION public.releasevonumber(integer) OWNER TO admin;
69028
 
 
69029
 
--
69030
 
--
69031
 
 
69032
 
CREATE FUNCTION releasewo(integer, boolean) RETURNS integer
69033
 
    LANGUAGE plpgsql
69034
 
    AS $_$
69035
 
DECLARE
69036
 
  pWoid ALIAS FOR $1;
69037
 
  releaseChildren ALIAS FOR $2;
69038
 
  returnCode INTEGER;
69039
 
BEGIN
69040
 
  UPDATE wo
69041
 
  SET wo_status='R'
69042
 
  WHERE ((wo_status='E')
69043
 
   AND (wo_id=pWoid));
69044
 
 
69045
 
  IF (releaseChildren) THEN
69046
 
    returnCode := (SELECT MAX(releaseWo(wo_id, TRUE))
69047
 
                   FROM wo
69048
 
                   WHERE ((wo_ordtype='W')
69049
 
                    AND (wo_ordid=pWoid)));
69050
 
  END IF;
69051
 
 
69052
 
  RETURN 0;
69053
 
END;
69054
 
$_$;
69055
 
 
69056
 
 
69057
 
ALTER FUNCTION public.releasewo(integer, boolean) OWNER TO admin;
69058
 
 
69059
 
--
69060
 
--
69061
 
 
69062
 
CREATE FUNCTION releasewonumber(integer) RETURNS boolean
69063
 
    LANGUAGE sql
69064
 
    AS $_$
69065
 
  SELECT releaseNumber('WoNumber', $1) > 0;
69066
 
$_$;
69067
 
 
69068
 
 
69069
 
ALTER FUNCTION public.releasewonumber(integer) OWNER TO admin;
69070
 
 
69071
 
--
69072
 
--
69073
 
 
69074
 
CREATE FUNCTION relocateinventory(integer, integer, integer, numeric, text) RETURNS integer
69075
 
    LANGUAGE plpgsql
69076
 
    AS $_$
69077
 
BEGIN
69078
 
  RETURN relocateInventory($1, $2, $3, $4, $5, CURRENT_TIMESTAMP);
69079
 
END;
69080
 
$_$;
69081
 
 
69082
 
 
69083
 
ALTER FUNCTION public.relocateinventory(integer, integer, integer, numeric, text) OWNER TO admin;
69084
 
 
69085
 
--
69086
 
--
69087
 
 
69088
 
CREATE FUNCTION relocateinventory(psourceitemlocid integer, ptargetlocationid integer, pitemsiteid integer, pqty numeric, pcomments text, pgldistts timestamp with time zone) RETURNS integer
69089
 
    LANGUAGE plpgsql
69090
 
    AS $$
69091
 
DECLARE
69092
 
  _GlDistTS             TIMESTAMP WITH TIME ZONE;
69093
 
  _targetItemlocid      INTEGER;
69094
 
  _invhistid            INTEGER;
69095
 
  _p                    RECORD;
69096
 
  _rsrv                 RECORD;
69097
 
  _qty                  NUMERIC;
69098
 
  _qtyunreserved        NUMERIC := 0.0;
69099
 
  _qtytomove            NUMERIC := 0.0;
69100
 
  _result               INTEGER := -1;
69101
 
  _itemlocSeries        INTEGER := NEXTVAL('itemloc_series_seq');
69102
 
 
69103
 
BEGIN
69104
 
 
69105
 
    IF ((pGlDistTS IS NULL) OR (CAST(pGlDistTS AS date)=CURRENT_DATE)) THEN
69106
 
      _GlDistTS := CURRENT_TIMESTAMP;
69107
 
    ELSE
69108
 
      _GLDistTS := pGLDistTS;
69109
 
    END IF;
69110
 
 
69111
 
  IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J')
69112
 
         FROM itemsite, item
69113
 
         WHERE ( (itemsite_item_id=item_id)
69114
 
          AND (itemsite_id=pItemsiteid) ) ) ) THEN
69115
 
    RETURN 0;
69116
 
  END IF;
69117
 
 
69118
 
  SELECT itemloc_ls_id,
69119
 
         itemloc_itemsite_id AS itemsiteid,
69120
 
         itemloc_expiration,
69121
 
         itemloc_warrpurc,
69122
 
         itemloc_qty INTO _p
69123
 
  FROM itemloc
69124
 
  WHERE (itemloc_id=pSourceItemlocid);
69125
 
 
69126
 
  IF (_p.itemloc_qty < pQty) THEN
69127
 
    RETURN -1;
69128
 
  END IF;
69129
 
 
69130
 
  SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid;
69131
 
  INSERT INTO invhist
69132
 
  ( invhist_id, invhist_itemsite_id,
69133
 
    invhist_transtype, invhist_invqty,
69134
 
    invhist_qoh_before, invhist_qoh_after,
69135
 
    invhist_comments,   invhist_transdate,
69136
 
    invhist_invuom, invhist_unitcost, invhist_costmethod,
69137
 
    invhist_value_before, invhist_value_after, invhist_series) 
69138
 
  SELECT _invhistid, itemsite_id,
69139
 
         'RL', 0,
69140
 
         itemsite_qtyonhand, itemsite_qtyonhand,
69141
 
         pComments, _GlDistTS,
69142
 
         uom_name,
69143
 
         CASE WHEN (itemsite_costmethod='A') THEN avgcost(itemsite_id)
69144
 
              ELSE stdCost(item_id)
69145
 
         END, itemsite_costmethod,
69146
 
         itemsite_value, itemsite_value, _itemlocSeries
69147
 
  FROM item, itemsite, uom
69148
 
  WHERE ((itemsite_item_id=item_id)
69149
 
   AND (item_inv_uom_id=uom_id)
69150
 
   AND (itemsite_controlmethod <> 'N')
69151
 
   AND (itemsite_id=pItemsiteid));
69152
 
 
69153
 
  INSERT INTO invdetail
69154
 
  ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id,
69155
 
    invdetail_qty, invdetail_qty_before, invdetail_qty_after,
69156
 
    invdetail_expiration, invdetail_warrpurc )
69157
 
  SELECT _invhistid, itemloc_location_id, itemloc_ls_id,
69158
 
         (pQty * -1), itemloc_qty, (itemloc_qty - pQty),
69159
 
         itemloc_expiration, itemloc_warrpurc
69160
 
  FROM itemloc
69161
 
  WHERE (itemloc_id=pSourceItemlocid);
69162
 
 
69163
 
  UPDATE itemloc
69164
 
  SET itemloc_qty=(itemloc_qty - pQty)
69165
 
  FROM itemsite
69166
 
  WHERE ( (itemloc_itemsite_id=itemsite_id)
69167
 
   AND (NOT itemsite_freeze)
69168
 
   AND (itemloc_id=pSourceItemlocid) );
69169
 
 
69170
 
  SELECT itemloc_id INTO _targetItemlocid
69171
 
  FROM itemloc 
69172
 
  WHERE ( (COALESCE(itemloc_ls_id, -1)=COALESCE(_p.itemloc_ls_id,-1))
69173
 
   AND (COALESCE(itemloc_expiration,endOfTime())=COALESCE(_p.itemloc_expiration,endOfTime()))
69174
 
   AND (COALESCE(itemloc_warrpurc,endOfTime())=COALESCE(_p.itemloc_warrpurc,endOfTime()))
69175
 
   AND (itemloc_itemsite_id=pItemsiteid)
69176
 
   AND (itemloc_location_id=pTargetLocationid) );
69177
 
 
69178
 
  IF (NOT FOUND) THEN
69179
 
    SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _targetItemlocid;
69180
 
    INSERT INTO itemloc
69181
 
    ( itemloc_id, itemloc_itemsite_id, itemloc_location_id,
69182
 
      itemloc_ls_id, itemloc_expiration, itemloc_warrpurc, itemloc_qty )
69183
 
    VALUES
69184
 
    ( _targetItemlocid, pItemsiteid, pTargetLocationid,
69185
 
      _p.itemloc_ls_id, _p.itemloc_expiration, _p.itemloc_warrpurc, 0 );
69186
 
  END IF;
69187
 
 
69188
 
  INSERT INTO invdetail
69189
 
  ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id,
69190
 
    invdetail_qty, invdetail_qty_before, invdetail_qty_after,
69191
 
    invdetail_expiration, invdetail_warrpurc )
69192
 
  SELECT _invhistid, pTargetLocationid, _p.itemloc_ls_id,
69193
 
         pQty, itemloc_qty, (itemloc_qty + pQty), 
69194
 
         _p.itemloc_expiration, _p.itemloc_warrpurc
69195
 
  FROM itemloc
69196
 
  WHERE (itemloc_id=_targetItemlocid);
69197
 
 
69198
 
  UPDATE itemloc
69199
 
  SET itemloc_qty=(itemloc_qty + pQty)
69200
 
  FROM itemsite
69201
 
  WHERE ( (itemloc_itemsite_id=itemsite_id)
69202
 
   AND (NOT itemsite_freeze)
69203
 
   AND (itemloc_id=_targetItemlocid) );
69204
 
 
69205
 
  UPDATE invhist
69206
 
  SET invhist_hasdetail=TRUE
69207
 
  WHERE (invhist_id=_invhistid);
69208
 
 
69209
 
  DELETE FROM itemloc
69210
 
  WHERE ( (itemloc_qty=0)
69211
 
   AND (itemloc_id=_targetItemlocid) );
69212
 
 
69213
 
  IF (fetchMetricBool('EnableSOReservationsByLocation')) THEN
69214
 
    SELECT CASE WHEN (qtyReservedLocation(itemloc_id) > itemloc_qty)
69215
 
                THEN (qtyReservedLocation(itemloc_id) - itemloc_qty)
69216
 
                ELSE 0.0
69217
 
                END INTO _qtyunreserved
69218
 
    FROM itemloc
69219
 
    WHERE (itemloc_id=pSourceItemlocid);
69220
 
    -- Move reservations as necessary
69221
 
    WHILE (_qtyunreserved > 0.0) LOOP
69222
 
      SELECT * INTO _rsrv
69223
 
      FROM reserve
69224
 
      WHERE ((reserve_supply_type='I')
69225
 
        AND  (reserve_supply_id=pSourceItemlocid))
69226
 
      ORDER BY reserve_qty;
69227
 
      IF (NOT FOUND) THEN
69228
 
        RAISE EXCEPTION 'Cannot find reservation to unreserve.';
69229
 
      END IF;
69230
 
      IF (_rsrv.reserve_qty > _qtyunreserved) THEN
69231
 
        _qtytomove := _qtyunreserved;
69232
 
      ELSE
69233
 
        _qtytomove := _rsrv.reserve_qty;
69234
 
      END IF;
69235
 
      -- Unreserve Source Location
69236
 
      SELECT unreserveSOLineQty(_rsrv.reserve_demand_id,
69237
 
                                _qtytomove,
69238
 
                                pSourceItemlocid) INTO _result;
69239
 
      IF (_result < 0) THEN
69240
 
        RAISE EXCEPTION 'unreserveSOLineQty failed with result=%, reserve_id=%, qty=%',
69241
 
                        _result, _rsrv.reserve_id, _qtytomove;
69242
 
      END IF;
69243
 
      -- Reserve to new Location
69244
 
      SELECT reserveSOLineQty(_rsrv.reserve_demand_id,
69245
 
                              TRUE,
69246
 
                              _qtytomove,
69247
 
                              _targetItemlocid) INTO _result;
69248
 
      IF (_result < 0) THEN
69249
 
        RAISE EXCEPTION 'reserveSOLineQty failed with result=%, reserve_id=%, qty=%',
69250
 
                        _result, _rsrv.reserve_id, _qtytomove;
69251
 
      END IF;
69252
 
      -- Calculate running total
69253
 
      _qtyunreserved := _qtyunreserved - _qtytomove;
69254
 
    END LOOP;
69255
 
  END IF;
69256
 
 
69257
 
  DELETE FROM itemloc
69258
 
  WHERE ( (itemloc_qty=0)
69259
 
   AND (itemloc_id=pSourceItemlocid) );
69260
 
 
69261
 
  RETURN _invhistid;
69262
 
 
69263
 
END;
69264
 
$$;
69265
 
 
69266
 
 
69267
 
ALTER FUNCTION public.relocateinventory(psourceitemlocid integer, ptargetlocationid integer, pitemsiteid integer, pqty numeric, pcomments text, pgldistts timestamp with time zone) OWNER TO admin;
69268
 
 
69269
 
--
69270
 
--
69271
 
 
69272
 
CREATE FUNCTION reopenbankreconciliation(pbankrecid integer) RETURNS integer
69273
 
    LANGUAGE plpgsql
69274
 
    AS $$
69275
 
BEGIN
69276
 
  RETURN bankReconciliation(pBankrecid, 'reopen');
69277
 
END;
69278
 
$$;
69279
 
 
69280
 
 
69281
 
ALTER FUNCTION public.reopenbankreconciliation(pbankrecid integer) OWNER TO admin;
69282
 
 
69283
 
--
69284
 
--
69285
 
 
69286
 
CREATE FUNCTION reorderdate(integer, integer, boolean) RETURNS date
69287
 
    LANGUAGE plpgsql
69288
 
    AS $_$
69289
 
DECLARE
69290
 
  pItemsiteid ALIAS FOR $1;
69291
 
  pLookAhead ALIAS FOR $2;
69292
 
  pIncludePlanned ALIAS FOR $3;
69293
 
  _runningAvailability NUMERIC;
69294
 
  _reorderLevel NUMERIC;
69295
 
  _availability RECORD;
69296
 
 
69297
 
BEGIN
69298
 
 
69299
 
  IF ( SELECT (NOT (item_type IN ('M', 'P')))
69300
 
       FROM item, itemsite
69301
 
       WHERE ( (itemsite_item_id=item_id)
69302
 
        AND (itemsite_id=pItemsiteid) ) ) THEN
69303
 
    RETURN NULL;
69304
 
  END IF;
69305
 
 
69306
 
  SELECT itemsite_qtyonhand INTO _runningAvailability
69307
 
  FROM itemsite
69308
 
  WHERE (itemsite_id=pItemsiteid);
69309
 
 
69310
 
  IF ( ( SELECT itemsite_useparams
69311
 
         FROM itemsite
69312
 
         WHERE (itemsite_id=pItemsiteid) ) ) THEN
69313
 
    SELECT itemsite_reorderlevel INTO _reorderLevel
69314
 
    FROM itemsite
69315
 
    WHERE (itemsite_id=pItemsiteid);
69316
 
  ELSE
69317
 
    _reorderLevel := 0;
69318
 
  END IF;
69319
 
 
69320
 
  IF (_runningAvailability <= _reorderLevel) THEN
69321
 
    RETURN CURRENT_DATE;
69322
 
  END IF;
69323
 
 
69324
 
  FOR _availability IN SELECT 1 AS seq,
69325
 
                              wo_duedate AS orderdate,
69326
 
                              (noNeg(wo_qtyord - wo_qtyrcv)) AS balance
69327
 
                       FROM wo
69328
 
                       WHERE ((wo_status IN ('O', 'E', 'R', 'I'))
69329
 
                        AND (wo_duedate <= (CURRENT_DATE + pLookAhead))
69330
 
                        AND (wo_itemsite_id=pItemsiteid))
69331
 
 
69332
 
                      UNION SELECT 2 AS seq,
69333
 
                                   womatl_duedate AS orderdate,
69334
 
                                   (noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq - womatl_qtyiss)) * -1) AS balance
69335
 
                      FROM womatl, wo, itemsite
69336
 
                      WHERE ((wo_status IN ('O', 'E', 'R', 'I'))
69337
 
                       AND (womatl_wo_id=wo_id)
69338
 
                       AND (womatl_itemsite_id=itemsite_id)
69339
 
                       AND (womatl_duedate <= (CURRENT_DATE + pLookahead))
69340
 
                       AND (womatl_itemsite_id=pItemsiteid))
69341
 
 
69342
 
                      UNION SELECT 1 AS seq,
69343
 
                                   poitem_duedate AS orderdate,
69344
 
                                   (noNeg(poitem_qty_ordered - poitem_qty_received) * poitem_invvenduomratio) AS balance
69345
 
                      FROM pohead, poitem
69346
 
                      WHERE ((poitem_pohead_id=pohead_id)
69347
 
                       AND (poitem_status = 'O')
69348
 
                       AND (poitem_duedate <= (CURRENT_DATE + pLookAhead))
69349
 
                       AND (poitem_itemsite_id=pItemsiteid))
69350
 
 
69351
 
                      UNION SELECT 2 AS seq,
69352
 
                                   coitem_scheddate AS orderdate,
69353
 
                                   (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * -1) AS balance
69354
 
                      FROM coitem, cohead
69355
 
                      WHERE ((coitem_status = 'O')
69356
 
                       AND (coitem_cohead_id=cohead_id)
69357
 
                       AND (coitem_scheddate <= (CURRENT_DATE + pLookAhead))
69358
 
                       AND (coitem_itemsite_id=pItemsiteid))
69359
 
 
69360
 
                      UNION SELECT 2 AS seq,
69361
 
                                   planord_startdate AS orderdate,
69362
 
                                   (planreq_qty * -1) AS balance
69363
 
                      FROM planreq, planord
69364
 
                      WHERE ( (pIncludePlanned)
69365
 
                       AND (planreq_source='P')
69366
 
                       AND (planreq_source_id=planord_id)
69367
 
                       AND (planord_startdate <= (CURRENT_DATE + pLookAhead))
69368
 
                       AND (planord_itemsite_id=pItemsiteid) )
69369
 
 
69370
 
                      UNION SELECT 1 AS seq,
69371
 
                                   planord_duedate AS orderdate,
69372
 
                                   planord_qty AS balance
69373
 
                      FROM planord
69374
 
                      WHERE ( (pIncludePlanned)
69375
 
                       AND (planord_duedate <= (CURRENT_DATE + pLookAhead))
69376
 
                       AND (planord_itemsite_id=pItemsiteid) )
69377
 
 
69378
 
                      ORDER BY orderdate, seq LOOP
69379
 
 
69380
 
    _runningAvailability := (_runningAvailability + _availability.balance);
69381
 
 
69382
 
    IF (_runningAvailability < _reorderLevel) THEN
69383
 
      RETURN _availability.orderdate;
69384
 
    END IF;
69385
 
 
69386
 
  END LOOP;
69387
 
 
69388
 
  RETURN NULL;
69389
 
 
69390
 
END;
69391
 
$_$;
69392
 
 
69393
 
 
69394
 
ALTER FUNCTION public.reorderdate(integer, integer, boolean) OWNER TO admin;
69395
 
 
69396
 
--
69397
 
--
69398
 
 
69399
 
CREATE FUNCTION replaceallvoidedapchecks(integer) RETURNS integer
69400
 
    LANGUAGE plpgsql
69401
 
    AS $_$
69402
 
BEGIN
69403
 
  RAISE NOTICE 'replaceAllVoidedAPChecks() is deprecated - use replaceAllVoidedChecks() instead';
69404
 
  RETURN replaceAllVoidedChecks($1);
69405
 
END;
69406
 
$_$;
69407
 
 
69408
 
 
69409
 
ALTER FUNCTION public.replaceallvoidedapchecks(integer) OWNER TO admin;
69410
 
 
69411
 
--
69412
 
--
69413
 
 
69414
 
CREATE FUNCTION replaceallvoidedchecks(integer) RETURNS integer
69415
 
    LANGUAGE plpgsql
69416
 
    AS $_$
69417
 
DECLARE
69418
 
  pBankaccntid  ALIAS FOR $1;
69419
 
  _returnValue  INTEGER := 0;
69420
 
 
69421
 
BEGIN
69422
 
 
69423
 
  SELECT MIN(replaceVoidedCheck(checkhead_id)) INTO _returnValue
69424
 
    FROM checkhead
69425
 
    WHERE ( (checkhead_void)
69426
 
     AND (NOT checkhead_posted)
69427
 
     AND (NOT checkhead_replaced)
69428
 
     AND (NOT checkhead_deleted)
69429
 
     AND (checkhead_bankaccnt_id=pBankaccntid) );
69430
 
 
69431
 
  RETURN _returnValue;
69432
 
 
69433
 
END;
69434
 
$_$;
69435
 
 
69436
 
 
69437
 
ALTER FUNCTION public.replaceallvoidedchecks(integer) OWNER TO admin;
69438
 
 
69439
 
--
69440
 
--
69441
 
 
69442
 
CREATE FUNCTION replacevoidedapcheck(integer) RETURNS integer
69443
 
    LANGUAGE plpgsql
69444
 
    AS $_$
69445
 
BEGIN
69446
 
  RAISE NOTICE 'replaceVoidedAPCheck() is deprecated - use replaceVoidedCheck()';
69447
 
  RETURN replaceVoidedCheck($1);
69448
 
END;
69449
 
$_$;
69450
 
 
69451
 
 
69452
 
ALTER FUNCTION public.replacevoidedapcheck(integer) OWNER TO admin;
69453
 
 
69454
 
--
69455
 
--
69456
 
 
69457
 
CREATE FUNCTION replacevoidedcheck(integer) RETURNS integer
69458
 
    LANGUAGE plpgsql
69459
 
    AS $_$
69460
 
DECLARE
69461
 
  pCheckid      ALIAS FOR $1;
69462
 
  _newCheckid   INTEGER;
69463
 
 
69464
 
BEGIN
69465
 
  IF ( ( SELECT ( (NOT checkhead_void) OR checkhead_posted OR checkhead_replaced )
69466
 
         FROM checkhead
69467
 
         WHERE (checkhead_id=pCheckid) ) ) THEN
69468
 
    RETURN -1;
69469
 
  END IF;
69470
 
 
69471
 
  -- has someone created a new check for one of the items while this was void?
69472
 
  IF EXISTS (SELECT dup.checkitem_id
69473
 
             FROM checkitem orig, checkitem dup, checkhead AS duphead
69474
 
             WHERE ((COALESCE(orig.checkitem_aropen_id,-1)=COALESCE(dup.checkitem_aropen_id,-1))
69475
 
                AND (COALESCE(orig.checkitem_apopen_id,-1)=COALESCE(dup.checkitem_apopen_id,-1))
69476
 
                AND (orig.checkitem_checkhead_id!=dup.checkitem_checkhead_id)
69477
 
                AND (dup.checkitem_checkhead_id=duphead.checkhead_id)
69478
 
                AND (NOT duphead.checkhead_void)
69479
 
                AND (orig.checkitem_checkhead_id=pCheckid))) THEN
69480
 
    RETURN -2;
69481
 
  END IF;
69482
 
 
69483
 
  SELECT NEXTVAL('checkhead_checkhead_id_seq') INTO _newCheckid;
69484
 
 
69485
 
  INSERT INTO checkhead
69486
 
  ( checkhead_id, checkhead_recip_id, checkhead_recip_type,
69487
 
    checkhead_bankaccnt_id, checkhead_checkdate,
69488
 
    checkhead_number, checkhead_amount,
69489
 
    checkhead_for, checkhead_journalnumber,
69490
 
    checkhead_notes,
69491
 
    checkhead_misc, checkhead_expcat_id, checkhead_curr_id )
69492
 
  SELECT _newCheckid, checkhead_recip_id, checkhead_recip_type,
69493
 
         checkhead_bankaccnt_id, checkhead_checkdate,
69494
 
         -1, -- fetchNextCheckNumber(checkhead_bankaccnt_id),
69495
 
         checkhead_amount,
69496
 
         checkhead_for, checkhead_journalnumber,
69497
 
         checkhead_notes || '
69498
 
Replaces voided check ' || checkhead_number,
69499
 
         checkhead_misc, checkhead_expcat_id, checkhead_curr_id
69500
 
  FROM checkhead
69501
 
  WHERE (checkhead_id=pCheckid);
69502
 
 
69503
 
  INSERT INTO checkitem
69504
 
  ( checkitem_checkhead_id, checkitem_amount, checkitem_discount,
69505
 
    checkitem_ponumber, checkitem_vouchernumber, checkitem_invcnumber,
69506
 
    checkitem_apopen_id, checkitem_aropen_id,
69507
 
    checkitem_docdate, checkitem_curr_id, checkitem_curr_rate )
69508
 
  SELECT _newCheckid, checkitem_amount, checkitem_discount,
69509
 
         checkitem_ponumber, checkitem_vouchernumber, checkitem_invcnumber,
69510
 
         checkitem_apopen_id, checkitem_aropen_id,
69511
 
         checkitem_docdate, checkitem_curr_id, checkitem_curr_rate
69512
 
  FROM checkitem
69513
 
  WHERE (checkitem_checkhead_id=pCheckid);
69514
 
 
69515
 
  UPDATE checkhead
69516
 
  SET checkhead_replaced=TRUE
69517
 
  WHERE (checkhead_id=pCheckid);
69518
 
 
69519
 
  RETURN _newCheckid;
69520
 
 
69521
 
END;
69522
 
$_$;
69523
 
 
69524
 
 
69525
 
ALTER FUNCTION public.replacevoidedcheck(integer) OWNER TO admin;
69526
 
 
69527
 
--
69528
 
--
69529
 
 
69530
 
CREATE FUNCTION reprioritizewo(integer, integer, boolean) RETURNS integer
69531
 
    LANGUAGE plpgsql
69532
 
    AS $_$
69533
 
DECLARE
69534
 
  pWoid ALIAS FOR $1;
69535
 
  pPriority ALIAS FOR $2;
69536
 
  pChangeChildren ALIAS FOR $3;
69537
 
  _status CHAR(1);
69538
 
  _result INTEGER;
69539
 
 
69540
 
BEGIN
69541
 
 
69542
 
  SELECT wo_status INTO _status
69543
 
  FROM wo
69544
 
  WHERE (wo_id=pWoid);
69545
 
 
69546
 
  IF (NOT (_status IN ('O', 'E','R','I'))) THEN
69547
 
    return -1;
69548
 
  END IF;
69549
 
 
69550
 
  UPDATE wo
69551
 
  SET wo_priority=pPriority
69552
 
  WHERE (wo_id=pWoid);
69553
 
 
69554
 
  IF ( (_status IN ('E','R','I')) AND (pChangeChildren) ) THEN
69555
 
    SELECT COALESCE(MIN(reprioritizeWo(wo_id, pPriority, TRUE)), 1) INTO _result
69556
 
    FROM wo
69557
 
    WHERE ( (wo_ordtype='W')
69558
 
     AND (wo_ordid=pWoid) );
69559
 
  ELSE
69560
 
    _result = 1;
69561
 
  END IF;
69562
 
 
69563
 
  RETURN _result;
69564
 
 
69565
 
END;
69566
 
$_$;
69567
 
 
69568
 
 
69569
 
ALTER FUNCTION public.reprioritizewo(integer, integer, boolean) OWNER TO admin;
69570
 
 
69571
 
--
69572
 
--
69573
 
 
69574
 
CREATE FUNCTION resetdbobjperms() RETURNS integer
69575
 
    LANGUAGE plpgsql
69576
 
    AS $$
69577
 
DECLARE
69578
 
  _count        INTEGER := 0;
69579
 
BEGIN
69580
 
  SELECT SUM(resetDBObjPerms(nspname || '.' || relname)) INTO _count
69581
 
  FROM pg_catalog.pg_class, pg_catalog.pg_namespace
69582
 
  WHERE (relkind IN ('r', 'S', 'v')
69583
 
    AND  (relnamespace=pg_namespace.oid)
69584
 
    AND  (nspname IN ('public', 'api')));
69585
 
 
69586
 
  RETURN _count;
69587
 
END;
69588
 
$$;
69589
 
 
69590
 
 
69591
 
ALTER FUNCTION public.resetdbobjperms() OWNER TO admin;
69592
 
 
69593
 
--
69594
 
--
69595
 
 
69596
 
CREATE FUNCTION resetdbobjperms(text) RETURNS integer
69597
 
    LANGUAGE plpgsql
69598
 
    AS $_$
69599
 
DECLARE
69600
 
  pObjname      ALIAS FOR $1;
69601
 
BEGIN
69602
 
  EXECUTE 'ALTER TABLE '   || pObjname || ' OWNER TO ' || getEffectiveXtUser() || ';';
69603
 
  EXECUTE 'REVOKE ALL ON ' || pObjname || ' FROM PUBLIC;';
69604
 
  EXECUTE 'GRANT  ALL ON ' || pObjname || ' TO GROUP xtrole;';
69605
 
  RETURN 1;
69606
 
END;
69607
 
$_$;
69608
 
 
69609
 
 
69610
 
ALTER FUNCTION public.resetdbobjperms(text) OWNER TO admin;
69611
 
 
69612
 
--
69613
 
--
69614
 
 
69615
 
CREATE FUNCTION resetlowlevelcode(integer) RETURNS integer
69616
 
    LANGUAGE plpgsql
69617
 
    AS $_$
69618
 
DECLARE
69619
 
 
69620
 
    pItemId ALIAS FOR $1;
69621
 
    _result     INTEGER;
69622
 
    _counterNum INTEGER := 1;
69623
 
    _feedBackNum INTEGER := 1;
69624
 
    _r                  RECORD;
69625
 
 
69626
 
BEGIN
69627
 
    DELETE FROM costUpdate;
69628
 
 
69629
 
    IF pItemId = -1 THEN        -- -1 is an invalid item_id => do them all
69630
 
        INSERT INTO costUpdate ( costUpdate_item_id, costUpdate_item_type )
69631
 
                        SELECT item_id, item_type
69632
 
                        FROM   item;
69633
 
 
69634
 
        -- Recalculate the Item Lowlevel codes
69635
 
        WHILE _feedBackNum > 0 LOOP
69636
 
            SELECT updateLowlevel(_counterNum) INTO _feedBackNum;
69637
 
            _counterNum := _counterNum + 1;
69638
 
        END LOOP;
69639
 
 
69640
 
    ELSE
69641
 
        INSERT INTO costUpdate ( costUpdate_item_id, costUpdate_item_type )
69642
 
                        SELECT item_id, item_type
69643
 
                        FROM   item
69644
 
                        WHERE (item_id=pItemId);
69645
 
      FOR _r IN SELECT item_id, bomdata_bomwork_level, item_type
69646
 
                FROM item,
69647
 
                     indentedBOM(pItemId, getActiveRevId('BOM',pItemId),0,0)
69648
 
                WHERE (bomdata_item_id=item_id)
69649
 
                ORDER BY bomdata_bomwork_level LOOP
69650
 
 
69651
 
        -- this only works because of the ORDER BY in the loop SELECT
69652
 
        UPDATE costUpdate
69653
 
        SET costupdate_lowlevel_code = _r.bomdata_bomwork_level
69654
 
        WHERE (costupdate_item_id=_r.item_id);
69655
 
 
69656
 
        IF (NOT FOUND) THEN
69657
 
          INSERT INTO costUpdate (
69658
 
            costUpdate_item_id, costUpdate_lowlevel_code, costUpdate_item_type
69659
 
          ) VALUES (
69660
 
            _r.item_id, _r.bomdata_bomwork_level, _r.item_type
69661
 
          );
69662
 
        END IF;
69663
 
      END LOOP;
69664
 
 
69665
 
    END IF;
69666
 
 
69667
 
    SELECT count(*) INTO _result
69668
 
    FROM costUpdate;
69669
 
 
69670
 
    RETURN _result;
69671
 
 
69672
 
END;
69673
 
$_$;
69674
 
 
69675
 
 
69676
 
ALTER FUNCTION public.resetlowlevelcode(integer) OWNER TO admin;
69677
 
 
69678
 
--
69679
 
--
69680
 
 
69681
 
CREATE FUNCTION resetqohbalance(integer) RETURNS integer
69682
 
    LANGUAGE plpgsql
69683
 
    AS $_$
69684
 
BEGIN
69685
 
  RETURN resetQOHBalance($1, CURRENT_TIMESTAMP);
69686
 
END;
69687
 
$_$;
69688
 
 
69689
 
 
69690
 
ALTER FUNCTION public.resetqohbalance(integer) OWNER TO admin;
69691
 
 
69692
 
--
69693
 
--
69694
 
 
69695
 
CREATE FUNCTION resetqohbalance(integer, timestamp with time zone) RETURNS integer
69696
 
    LANGUAGE plpgsql
69697
 
    AS $_$
69698
 
DECLARE
69699
 
  pItemsiteid   ALIAS FOR $1;
69700
 
  pGlDistTS     ALIAS FOR $2;
69701
 
  _invhistid    INTEGER;
69702
 
  _itemlocSeries INTEGER;
69703
 
 
69704
 
BEGIN
69705
 
 
69706
 
  IF ( ( SELECT ( (itemsite_controlmethod IN ('L', 'S')) OR
69707
 
                  (item_type = 'R') OR
69708
 
                  (itemsite_costmethod = 'J') OR
69709
 
                  (itemsite_loccntrl) OR
69710
 
                  (itemsite_qtyonhand > 0) )
69711
 
         FROM itemsite, item
69712
 
         WHERE ( (itemsite_item_id=item_id)
69713
 
          AND (itemsite_id=pItemsiteid) ) ) ) THEN
69714
 
    RETURN 0;
69715
 
  END IF;
69716
 
 
69717
 
  _itemlocSeries := NEXTVAL('itemloc_series_seq');
69718
 
 
69719
 
  SELECT postInvTrans( itemsite_id, 'AD', (itemsite_qtyonhand * -1),
69720
 
                       'I/M', '', '', 'RESET',
69721
 
                       'Reset QOH Balance to 0',
69722
 
                       costcat_asset_accnt_id, costcat_adjustment_accnt_id,
69723
 
                       _itemlocSeries, pGlDistTS ) INTO _invhistid
69724
 
  FROM itemsite, costcat
69725
 
  WHERE ( (itemsite_costcat_id=costcat_id)
69726
 
   AND (itemsite_id=pItemsiteid) );
69727
 
 
69728
 
  PERFORM postItemLocSeries(_itemlocSeries);
69729
 
 
69730
 
  RETURN _invhistid;
69731
 
 
69732
 
END;
69733
 
$_$;
69734
 
 
69735
 
 
69736
 
ALTER FUNCTION public.resetqohbalance(integer, timestamp with time zone) OWNER TO admin;
69737
 
 
69738
 
--
69739
 
--
69740
 
 
69741
 
CREATE FUNCTION resolvecosaccount(integer, integer) RETURNS integer
69742
 
    LANGUAGE plpgsql STABLE
69743
 
    AS $_$
69744
 
BEGIN
69745
 
 
69746
 
  RETURN resolveCOSAccount($1, $2, -1, -1);
69747
 
 
69748
 
END;
69749
 
$_$;
69750
 
 
69751
 
 
69752
 
ALTER FUNCTION public.resolvecosaccount(integer, integer) OWNER TO admin;
69753
 
 
69754
 
--
69755
 
--
69756
 
 
69757
 
CREATE FUNCTION resolvecosaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer
69758
 
    LANGUAGE plpgsql STABLE
69759
 
    AS $$
69760
 
DECLARE
69761
 
  _salesaccntid INTEGER;
69762
 
  _accntid INTEGER;
69763
 
 
69764
 
BEGIN
69765
 
 
69766
 
  SELECT findSalesAccnt(pItemsiteid, 'IS', pCustid, pSaletypeid, pShipzoneid) INTO _salesaccntid;
69767
 
  IF (_salesaccntid = -1) THEN
69768
 
    SELECT getUnassignedAccntId() INTO _accntid;
69769
 
  ELSE
69770
 
    SELECT salesaccnt_cos_accnt_id INTO _accntid
69771
 
    FROM salesaccnt
69772
 
    WHERE (salesaccnt_id=_salesaccntid);
69773
 
  END IF;
69774
 
 
69775
 
  RETURN _accntid;
69776
 
 
69777
 
END;
69778
 
$$;
69779
 
 
69780
 
 
69781
 
ALTER FUNCTION public.resolvecosaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) OWNER TO admin;
69782
 
 
69783
 
--
69784
 
--
69785
 
 
69786
 
CREATE FUNCTION resolvecowaccount(integer, integer) RETURNS integer
69787
 
    LANGUAGE plpgsql STABLE
69788
 
    AS $_$
69789
 
BEGIN
69790
 
 
69791
 
  RETURN resolveCOWAccount($1, $2, -1, -1);
69792
 
 
69793
 
END;
69794
 
$_$;
69795
 
 
69796
 
 
69797
 
ALTER FUNCTION public.resolvecowaccount(integer, integer) OWNER TO admin;
69798
 
 
69799
 
--
69800
 
--
69801
 
 
69802
 
CREATE FUNCTION resolvecowaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer
69803
 
    LANGUAGE plpgsql
69804
 
    AS $$
69805
 
DECLARE
69806
 
  _salesaccntid INTEGER;
69807
 
  _accntid INTEGER;
69808
 
 
69809
 
BEGIN
69810
 
 
69811
 
  SELECT findSalesAccnt(pItemsiteid, 'IS', pCustid, pSaletypeid, pShipzoneid) INTO _salesaccntid;
69812
 
  IF (_salesaccntid = -1) THEN
69813
 
    SELECT getUnassignedAccntId() INTO _accntid;
69814
 
  ELSE
69815
 
    SELECT salesaccnt_cow_accnt_id INTO _accntid
69816
 
    FROM salesaccnt
69817
 
    WHERE (salesaccnt_id=_salesaccntid);
69818
 
  END IF;
69819
 
 
69820
 
  RETURN _accntid;
69821
 
 
69822
 
END;
69823
 
$$;
69824
 
 
69825
 
 
69826
 
ALTER FUNCTION public.resolvecowaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) OWNER TO admin;
69827
 
 
69828
 
--
69829
 
--
69830
 
 
69831
 
CREATE FUNCTION resolvecreditaccount(integer, integer) RETURNS integer
69832
 
    LANGUAGE plpgsql STABLE
69833
 
    AS $_$
69834
 
BEGIN
69835
 
 
69836
 
  RETURN resolveCreditAccount($1, $2, -1, -1);
69837
 
 
69838
 
END;
69839
 
$_$;
69840
 
 
69841
 
 
69842
 
ALTER FUNCTION public.resolvecreditaccount(integer, integer) OWNER TO admin;
69843
 
 
69844
 
--
69845
 
--
69846
 
 
69847
 
CREATE FUNCTION resolvecreditaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer
69848
 
    LANGUAGE plpgsql
69849
 
    AS $$
69850
 
DECLARE
69851
 
  _salesaccntid INTEGER;
69852
 
  _accntid INTEGER;
69853
 
 
69854
 
BEGIN
69855
 
 
69856
 
  SELECT findSalesAccnt(pItemsiteid, 'IS', pCustid, pSaletypeid, pShipzoneid) INTO _salesaccntid;
69857
 
  IF (_salesaccntid = -1) THEN
69858
 
    SELECT getUnassignedAccntId() INTO _accntid;
69859
 
  ELSE
69860
 
    SELECT salesaccnt_credit_accnt_id INTO _accntid
69861
 
    FROM salesaccnt
69862
 
    WHERE (salesaccnt_id=_salesaccntid);
69863
 
  END IF;
69864
 
 
69865
 
  RETURN _accntid;
69866
 
 
69867
 
END;
69868
 
$$;
69869
 
 
69870
 
 
69871
 
ALTER FUNCTION public.resolvecreditaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) OWNER TO admin;
69872
 
 
69873
 
--
69874
 
--
69875
 
 
69876
 
CREATE FUNCTION resolvesalesaccount(integer, integer) RETURNS integer
69877
 
    LANGUAGE plpgsql STABLE
69878
 
    AS $_$
69879
 
BEGIN
69880
 
 
69881
 
  RETURN resolveSalesAccount($1, $2, -1, -1);
69882
 
 
69883
 
END;
69884
 
$_$;
69885
 
 
69886
 
 
69887
 
ALTER FUNCTION public.resolvesalesaccount(integer, integer) OWNER TO admin;
69888
 
 
69889
 
--
69890
 
--
69891
 
 
69892
 
CREATE FUNCTION resolvesalesaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer
69893
 
    LANGUAGE plpgsql
69894
 
    AS $$
69895
 
DECLARE
69896
 
  _salesaccntid INTEGER;
69897
 
  _accntid INTEGER;
69898
 
 
69899
 
BEGIN
69900
 
 
69901
 
  SELECT findSalesAccnt(pItemsiteid, 'IS', pCustid, pSaletypeid, pShipzoneid) INTO _salesaccntid;
69902
 
  IF (_salesaccntid = -1) THEN
69903
 
    SELECT getUnassignedAccntId() INTO _accntid;
69904
 
  ELSE
69905
 
    SELECT salesaccnt_sales_accnt_id INTO _accntid
69906
 
    FROM salesaccnt
69907
 
    WHERE (salesaccnt_id=_salesaccntid);
69908
 
  END IF;
69909
 
 
69910
 
  RETURN _accntid;
69911
 
 
69912
 
END;
69913
 
$$;
69914
 
 
69915
 
 
69916
 
ALTER FUNCTION public.resolvesalesaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) OWNER TO admin;
69917
 
 
69918
 
--
69919
 
--
69920
 
 
69921
 
CREATE FUNCTION restoresaleshistory(integer) RETURNS integer
69922
 
    LANGUAGE plpgsql
69923
 
    AS $_$
69924
 
DECLARE
69925
 
  pAsohistid ALIAS FOR $1;
69926
 
 
69927
 
BEGIN
69928
 
 
69929
 
  INSERT INTO cohist ( cohist_id,
69930
 
                       cohist_cust_id,
69931
 
                       cohist_itemsite_id,
69932
 
                       cohist_shipdate,
69933
 
                       cohist_invcdate,
69934
 
                       cohist_duedate,
69935
 
                       cohist_promisedate,
69936
 
                       cohist_ordernumber,
69937
 
                       cohist_invcnumber,
69938
 
                       cohist_qtyshipped,
69939
 
                       cohist_unitprice,
69940
 
                       cohist_unitcost,
69941
 
                       cohist_billtoname,
69942
 
                       cohist_billtoaddress1,
69943
 
                       cohist_billtoaddress2,
69944
 
                       cohist_billtoaddress3,
69945
 
                       cohist_billtocity,
69946
 
                       cohist_billtostate,
69947
 
                       cohist_billtozip,
69948
 
                       cohist_shiptoname,
69949
 
                       cohist_shiptoaddress1,
69950
 
                       cohist_shiptoaddress2,
69951
 
                       cohist_shiptoaddress3,
69952
 
                       cohist_shiptocity,
69953
 
                       cohist_shiptostate,
69954
 
                       cohist_shiptozip,
69955
 
                       cohist_shipto_id,
69956
 
                       cohist_shipvia,
69957
 
                       cohist_salesrep_id,
69958
 
                       cohist_misc_type,
69959
 
                       cohist_misc_descrip,
69960
 
                       cohist_misc_id,
69961
 
                       cohist_commission,
69962
 
                       cohist_commissionpaid,
69963
 
                       cohist_doctype,
69964
 
                       cohist_orderdate,
69965
 
                       cohist_imported,
69966
 
                       cohist_ponumber,
69967
 
                       cohist_curr_id,
69968
 
                       cohist_taxtype_id,
69969
 
                       cohist_taxzone_id )
69970
 
  SELECT asohist_id,
69971
 
         CASE asohist_cust_id WHEN -1 THEN NULL ELSE asohist_cust_id END,
69972
 
         asohist_itemsite_id,
69973
 
         asohist_shipdate,
69974
 
         asohist_invcdate,
69975
 
         asohist_duedate,
69976
 
         asohist_promisedate,
69977
 
         asohist_ordernumber,
69978
 
         asohist_invcnumber,
69979
 
         asohist_qtyshipped,
69980
 
         asohist_unitprice,
69981
 
         asohist_unitcost,
69982
 
         asohist_billtoname,
69983
 
         asohist_billtoaddress1,
69984
 
         asohist_billtoaddress2,
69985
 
         asohist_billtoaddress3,
69986
 
         asohist_billtocity,
69987
 
         asohist_billtostate,
69988
 
         asohist_billtozip,
69989
 
         asohist_shiptoname,
69990
 
         asohist_shiptoaddress1,
69991
 
         asohist_shiptoaddress2,
69992
 
         asohist_shiptoaddress3,
69993
 
         asohist_shiptocity,
69994
 
         asohist_shiptostate,
69995
 
         asohist_shiptozip,
69996
 
         asohist_shipto_id,
69997
 
         asohist_shipvia,
69998
 
         CASE asohist_salesrep_id WHEN -1 THEN NULL ELSE asohist_salesrep_id END,
69999
 
         asohist_misc_type,
70000
 
         asohist_misc_descrip,
70001
 
         asohist_misc_id,
70002
 
         asohist_commission,
70003
 
         asohist_commissionpaid,
70004
 
         asohist_doctype,
70005
 
         asohist_orderdate,
70006
 
         asohist_imported,
70007
 
         asohist_ponumber,
70008
 
         asohist_curr_id,
70009
 
         asohist_taxtype_id,
70010
 
         asohist_taxzone_id
70011
 
  FROM asohist
70012
 
  WHERE (asohist_id=pAsohistid);
70013
 
 
70014
 
  INSERT INTO cohisttax ( taxhist_id,
70015
 
                          taxhist_parent_id,
70016
 
                          taxhist_taxtype_id,
70017
 
                          taxhist_tax_id,
70018
 
                          taxhist_basis,
70019
 
                          taxhist_basis_tax_id,
70020
 
                          taxhist_sequence,
70021
 
                          taxhist_percent,
70022
 
                          taxhist_amount,
70023
 
                          taxhist_tax,
70024
 
                          taxhist_docdate,
70025
 
                          taxhist_distdate,
70026
 
                          taxhist_curr_id,
70027
 
                          taxhist_curr_rate,
70028
 
                          taxhist_journalnumber )
70029
 
  SELECT taxhist_id,
70030
 
         taxhist_parent_id,
70031
 
         taxhist_taxtype_id,
70032
 
         taxhist_tax_id,
70033
 
         taxhist_basis,
70034
 
         taxhist_basis_tax_id,
70035
 
         taxhist_sequence,
70036
 
         taxhist_percent,
70037
 
         taxhist_amount,
70038
 
         taxhist_tax,
70039
 
         taxhist_docdate,
70040
 
         taxhist_distdate,
70041
 
         taxhist_curr_id,
70042
 
         taxhist_curr_rate,
70043
 
         taxhist_journalnumber
70044
 
  FROM asohisttax
70045
 
  WHERE (taxhist_parent_id=pAsohistid);
70046
 
 
70047
 
  DELETE FROM asohisttax
70048
 
  WHERE (taxhist_parent_id=pAsohistid);
70049
 
 
70050
 
  DELETE FROM asohist
70051
 
  WHERE (asohist_id=pAsohistid);
70052
 
 
70053
 
  RETURN pAsohistid;
70054
 
 
70055
 
END;
70056
 
$_$;
70057
 
 
70058
 
 
70059
 
ALTER FUNCTION public.restoresaleshistory(integer) OWNER TO admin;
70060
 
 
70061
 
--
70062
 
--
70063
 
 
70064
 
CREATE FUNCTION returncompleteshipment(integer) RETURNS integer
70065
 
    LANGUAGE plpgsql
70066
 
    AS $_$
70067
 
BEGIN
70068
 
  RETURN returnCompleteShipment($1, 0, CURRENT_TIMESTAMP);
70069
 
END;
70070
 
$_$;
70071
 
 
70072
 
 
70073
 
ALTER FUNCTION public.returncompleteshipment(integer) OWNER TO admin;
70074
 
 
70075
 
--
70076
 
--
70077
 
 
70078
 
CREATE FUNCTION returncompleteshipment(integer, integer, timestamp with time zone) RETURNS integer
70079
 
    LANGUAGE plpgsql
70080
 
    AS $_$
70081
 
DECLARE
70082
 
  pshipheadid           ALIAS FOR $1;
70083
 
  _itemlocSeries        INTEGER := $2;
70084
 
  _timestamp            TIMESTAMP WITH TIME ZONE := $3;
70085
 
  _r RECORD;
70086
 
  _result               RECORD;
70087
 
  _shiphead_number      TEXT := '';
70088
 
  _count                INTEGER := 0;
70089
 
  _countsum             INTEGER := 0;
70090
 
 
70091
 
BEGIN
70092
 
  FOR _r IN SELECT shipitem_id
70093
 
            FROM shipitem, shiphead
70094
 
            WHERE ( (shipitem_shiphead_id=shiphead_id)
70095
 
             AND (NOT shiphead_shipped)
70096
 
             AND (shiphead_id=pshipheadid) ) LOOP
70097
 
    _itemlocSeries := returnShipmentTransaction(_r.shipitem_id, _itemlocSeries, _timestamp);
70098
 
  END LOOP;
70099
 
 
70100
 
  FOR _result IN SELECT shiphead_number
70101
 
                   FROM shiphead
70102
 
                  WHERE ( (shiphead_id=pshipheadid) ) LOOP
70103
 
    _shiphead_number := _result.shiphead_number;
70104
 
  END LOOP;
70105
 
 
70106
 
  SELECT COUNT(*) INTO _count
70107
 
    FROM shipdata
70108
 
   WHERE(shipdata_shiphead_number=_shiphead_number);
70109
 
 
70110
 
  SELECT COUNT(*) INTO _countsum
70111
 
    FROM shipdatasum
70112
 
   WHERE(shipdatasum_shiphead_number=_shiphead_number);
70113
 
 
70114
 
  IF (_count > 0) THEN
70115
 
    DELETE FROM shipdata
70116
 
     WHERE(shipdata_shiphead_number=_shiphead_number);
70117
 
  END IF;
70118
 
  IF (_countsum > 0) THEN
70119
 
    DELETE FROM shipdatasum
70120
 
     WHERE(shipdatasum_shiphead_number=_shiphead_number);
70121
 
  END IF;
70122
 
 
70123
 
  DELETE FROM pack
70124
 
   WHERE(pack_shiphead_id=pshipheadid);
70125
 
  DELETE FROM shiphead
70126
 
  WHERE (shiphead_id=pshipheadid);
70127
 
 
70128
 
  RETURN _itemlocSeries;
70129
 
 
70130
 
END;
70131
 
$_$;
70132
 
 
70133
 
 
70134
 
ALTER FUNCTION public.returncompleteshipment(integer, integer, timestamp with time zone) OWNER TO admin;
70135
 
 
70136
 
--
70137
 
--
70138
 
 
70139
 
CREATE FUNCTION returnitemshipments(integer) RETURNS integer
70140
 
    LANGUAGE plpgsql
70141
 
    AS $_$
70142
 
BEGIN
70143
 
  RETURN returnItemShipments('SO', $1, 0, CURRENT_TIMESTAMP);
70144
 
END;
70145
 
$_$;
70146
 
 
70147
 
 
70148
 
ALTER FUNCTION public.returnitemshipments(integer) OWNER TO admin;
70149
 
 
70150
 
--
70151
 
--
70152
 
 
70153
 
CREATE FUNCTION returnitemshipments(integer, integer) RETURNS integer
70154
 
    LANGUAGE plpgsql
70155
 
    AS $_$
70156
 
BEGIN
70157
 
  RETURN returnItemShipments('SO', $1, $2, CURRENT_TIMESTAMP);
70158
 
END;
70159
 
$_$;
70160
 
 
70161
 
 
70162
 
ALTER FUNCTION public.returnitemshipments(integer, integer) OWNER TO admin;
70163
 
 
70164
 
--
70165
 
--
70166
 
 
70167
 
CREATE FUNCTION returnitemshipments(text, integer, integer, timestamp with time zone) RETURNS integer
70168
 
    LANGUAGE plpgsql
70169
 
    AS $_$
70170
 
DECLARE
70171
 
  pordertype            ALIAS FOR $1;
70172
 
  pitemid               ALIAS FOR $2;
70173
 
  _itemlocSeries        INTEGER                         := $3;
70174
 
  _timestamp            TIMESTAMP WITH TIME ZONE        := $4;
70175
 
  _invhistid INTEGER;
70176
 
  _r RECORD;
70177
 
 
70178
 
BEGIN
70179
 
 
70180
 
  IF (COALESCE(_itemlocSeries,0) = 0 ) THEN
70181
 
    _itemlocSeries := NEXTVAL('itemloc_series_seq');
70182
 
  END IF;
70183
 
 
70184
 
  FOR _r IN 
70185
 
    SELECT shipitem_id
70186
 
    FROM shipitem
70187
 
      JOIN shiphead ON (shiphead_id=shipitem_shiphead_id)
70188
 
    WHERE ((NOT shiphead_shipped)
70189
 
      AND  (shiphead_order_type=pordertype)
70190
 
      AND  (shipitem_orderitem_id=pitemid))
70191
 
  LOOP
70192
 
 
70193
 
    SELECT returnShipmentTransaction(_r.shipitem_id, _itemlocSeries, _timestamp) INTO _itemlocSeries;
70194
 
 
70195
 
    IF (_itemlocSeries < 0) THEN
70196
 
      RETURN _itemlocSeries;
70197
 
    END IF;
70198
 
 
70199
 
  END LOOP;
70200
 
 
70201
 
  RETURN _itemlocSeries;
70202
 
 
70203
 
END;
70204
 
$_$;
70205
 
 
70206
 
 
70207
 
ALTER FUNCTION public.returnitemshipments(text, integer, integer, timestamp with time zone) OWNER TO admin;
70208
 
 
70209
 
--
70210
 
--
70211
 
 
70212
 
CREATE FUNCTION returnshipmenttransaction(integer) RETURNS integer
70213
 
    LANGUAGE plpgsql
70214
 
    AS $_$
70215
 
BEGIN
70216
 
  RETURN returnShipmentTransaction($1, 0, CURRENT_TIMESTAMP);
70217
 
END;
70218
 
$_$;
70219
 
 
70220
 
 
70221
 
ALTER FUNCTION public.returnshipmenttransaction(integer) OWNER TO admin;
70222
 
 
70223
 
--
70224
 
--
70225
 
 
70226
 
CREATE FUNCTION returnshipmenttransaction(integer, integer) RETURNS integer
70227
 
    LANGUAGE plpgsql
70228
 
    AS $_$
70229
 
BEGIN
70230
 
  RETURN returnShipmentTransaction($1, $2, CURRENT_TIMESTAMP);
70231
 
END;
70232
 
$_$;
70233
 
 
70234
 
 
70235
 
ALTER FUNCTION public.returnshipmenttransaction(integer, integer) OWNER TO admin;
70236
 
 
70237
 
--
70238
 
--
70239
 
 
70240
 
CREATE FUNCTION returnshipmenttransaction(integer, integer, timestamp with time zone) RETURNS integer
70241
 
    LANGUAGE plpgsql
70242
 
    AS $_$
70243
 
DECLARE
70244
 
  pShipitemId           ALIAS FOR $1;
70245
 
  pItemlocSeries        ALIAS FOR $2;
70246
 
  pTimestamp            ALIAS FOR $3;
70247
 
  _itemlocSeries        INTEGER;
70248
 
  _invhistid            INTEGER;
70249
 
  _reserveid            INTEGER;
70250
 
  _coheadid             INTEGER;
70251
 
  _rows                 INTEGER;
70252
 
  _r                    RECORD;
70253
 
  _rsrv                 RECORD;
70254
 
 
70255
 
BEGIN
70256
 
 
70257
 
    IF (COALESCE(pItemlocSeries, 0) = 0 ) THEN
70258
 
      _itemlocSeries := NEXTVAL('itemloc_series_seq');
70259
 
    ELSE
70260
 
      _itemlocSeries := pItemlocSeries;
70261
 
    END IF;
70262
 
  
70263
 
    -- Find the shipment transaction record
70264
 
    SELECT shipitem.*,
70265
 
           shiphead_id, shiphead_number, shiphead_order_type, invhist_series,
70266
 
           itemsite_loccntrl, itemsite_costmethod, itemsite_controlmethod,
70267
 
           cohead_prj_id AS prj_id     
70268
 
      INTO _r
70269
 
    FROM shipitem
70270
 
      JOIN shiphead ON (shiphead_id=shipitem_shiphead_id)
70271
 
      JOIN invhist ON (invhist_id=shipitem_invhist_id)
70272
 
      JOIN itemsite ON (itemsite_id=invhist_itemsite_id)
70273
 
      LEFT OUTER JOIN cohead ON ((shiphead_order_type = 'SO') AND (shiphead_order_id = cohead_id))
70274
 
    WHERE ((NOT shiphead_shipped)
70275
 
      AND  (shipitem_id=pShipitemId));
70276
 
      
70277
 
    GET DIAGNOSTICS _rows = ROW_COUNT;
70278
 
    IF (_rows = 0 ) THEN
70279
 
      -- Was it a non-controlled sales order item?
70280
 
      SELECT shipitem.*,
70281
 
             shiphead_id, shiphead_number, shiphead_order_type,
70282
 
             itemsite_loccntrl, itemsite_costmethod, itemsite_controlmethod,
70283
 
             cohead_prj_id AS prj_id
70284
 
      INTO _r
70285
 
      FROM shipitem
70286
 
        JOIN shiphead ON (shiphead_id=shipitem_shiphead_id)
70287
 
        JOIN coitem ON (shipitem_orderitem_id=coitem_id)
70288
 
        JOIN cohead ON (cohead_id=coitem_cohead_id)
70289
 
        JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
70290
 
      WHERE ((NOT shiphead_shipped)
70291
 
        AND  (shipitem_id=pShipitemId)
70292
 
        AND  (shiphead_order_type = 'SO'));
70293
 
    END IF;
70294
 
    
70295
 
    GET DIAGNOSTICS _rows = ROW_COUNT;
70296
 
    IF (_rows = 0 AND fetchmetricbool('MultiWhs') ) THEN
70297
 
      -- Was it a non-controlled transfer order item?
70298
 
      SELECT shipitem.*,
70299
 
             shiphead_id, shiphead_number, shiphead_order_type,
70300
 
             itemsite_loccntrl, itemsite_costmethod, itemsite_controlmethod,
70301
 
             NULL AS prj_id
70302
 
      INTO _r
70303
 
      FROM shipitem
70304
 
        JOIN shiphead ON (shiphead_id=shipitem_shiphead_id)
70305
 
        JOIN toitem ON (shipitem_orderitem_id=toitem_id)
70306
 
        JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
70307
 
      WHERE ((NOT shiphead_shipped)
70308
 
        AND  (shipitem_id=pShipitemId)
70309
 
        AND  (shiphead_order_type = 'TO'));
70310
 
    END IF;
70311
 
    
70312
 
    IF (_rows > 0 ) THEN  
70313
 
      IF (_r.shiphead_order_type = 'SO') THEN
70314
 
        -- Handle inventory transaction
70315
 
        IF (_r.itemsite_controlmethod != 'N' OR _r.itemsite_costmethod = 'J') THEN
70316
 
          SELECT postInvTrans( itemsite_id, 'RS', (_r.shipitem_qty * coitem_qty_invuomratio),
70317
 
                               'S/R', _r.shiphead_order_type, formatSoNumber(_r.shipitem_orderitem_id),
70318
 
                               shiphead_number, 'Return from Shipping',
70319
 
                               costcat_asset_accnt_id, getPrjAccntId(_r.prj_id, costcat_shipasset_accnt_id),
70320
 
                               _itemlocSeries, pTimestamp, _r.shipitem_value, _r.shipitem_invhist_id ) INTO _invhistid
70321
 
          FROM coitem, itemsite, costcat, shiphead, shipitem
70322
 
          WHERE ((coitem_itemsite_id=itemsite_id)
70323
 
            AND  (itemsite_costcat_id=costcat_id)
70324
 
            AND  (coitem_id=_r.shipitem_orderitem_id)
70325
 
            AND  (shiphead_order_type=_r.shiphead_order_type)
70326
 
            AND  (shiphead_id=shipitem_shiphead_id)
70327
 
            AND  (shipitem_orderitem_id=_r.shipitem_orderitem_id));
70328
 
 
70329
 
          -- We know the distribution so post this through so the any w/o activity knows about it
70330
 
          PERFORM postItemlocseries(_itemlocSeries);
70331
 
        END IF;
70332
 
 
70333
 
        IF (_r.itemsite_costmethod = 'J') THEN   
70334
 
          -- Reopen the work order
70335
 
          UPDATE wo SET wo_status = 'I' WHERE ((wo_ordtype='S') AND (wo_ordid=_r.shipitem_orderitem_id));
70336
 
          
70337
 
          --  Job cost, so correct Production Posting referencing original receipt for reverse info.
70338
 
          PERFORM correctProduction(wo_id, invhist_invqty, false, _itemlocSeries, pTimestamp, invhist_id)
70339
 
          FROM wo, invhist
70340
 
          WHERE ((wo_ordtype = 'S')
70341
 
            AND  (wo_ordid = _r.shipitem_orderitem_id) 
70342
 
            AND  (invhist_series=_r.invhist_series)
70343
 
            AND  (invhist_transtype='RM'));
70344
 
             
70345
 
          --  Return eligble material
70346
 
          PERFORM returnWoMaterial(womatlpost_womatl_id, _itemlocSeries, pTimestamp, womatlpost_invhist_id)
70347
 
          FROM womatlpost, invhist m, invhist s 
70348
 
          WHERE ((womatlpost_invhist_id=m.invhist_id)
70349
 
            AND  (m.invhist_series=s.invhist_series)
70350
 
            AND  (m.invhist_transtype='IM')
70351
 
            AND  (s.invhist_id=_r.shipitem_invhist_id));
70352
 
 
70353
 
        END IF; -- end Job Costing
70354
 
 
70355
 
      ELSIF (_r.shiphead_order_type = 'TO') THEN
70356
 
        SELECT postInvTrans(itemsite_id, 'RS', _r.shipitem_qty,
70357
 
                            'S/R', _r.shiphead_order_type, formatToNumber(toitem_id),
70358
 
                            tohead_number, 'Return from Shipping',
70359
 
                            costcat_asset_accnt_id, costcat_shipasset_accnt_id,
70360
 
                            _itemlocSeries, pTimestamp, _r.shipitem_value, _r.shipitem_invhist_id ) INTO _invhistid
70361
 
        FROM toitem, tohead, itemsite, costcat
70362
 
        WHERE ((toitem_item_id=itemsite_item_id)
70363
 
          AND  (toitem_tohead_id=tohead_id)
70364
 
          AND  (tohead_src_warehous_id=itemsite_warehous_id)
70365
 
          AND  (itemsite_costcat_id=costcat_id)
70366
 
          AND  (toitem_id=_r.shipitem_orderitem_id));
70367
 
 
70368
 
      ELSE
70369
 
        -- Don't know what kind of order this is
70370
 
        RETURN -11;
70371
 
      END IF;
70372
 
 
70373
 
      UPDATE shiphead
70374
 
      SET shiphead_sfstatus='D'
70375
 
      WHERE ((shiphead_id=_r.shiphead_id)
70376
 
        AND  (shiphead_sfstatus='P'));
70377
 
 
70378
 
       -- Handle reservation if applicable
70379
 
      IF (fetchmetricbool('EnableSOReservations')) THEN
70380
 
        UPDATE coitem
70381
 
          SET coitem_qtyreserved = (coitem_qtyreserved + shipitemrsrv_qty)
70382
 
        FROM shipitemrsrv
70383
 
        WHERE ((coitem_id=_r.shipitem_orderitem_id)
70384
 
          AND  (shipitemrsrv_shipitem_id=_r.shipitem_id));
70385
 
 
70386
 
        -- Handle location reservations if applicable
70387
 
        FOR _rsrv IN
70388
 
          SELECT *
70389
 
          FROM shipitemlocrsrv
70390
 
          WHERE (shipitemlocrsrv_shipitem_id=_r.shipitem_id)
70391
 
        LOOP
70392
 
          -- See if a reservation record still exists
70393
 
          SELECT reserve_id INTO _reserveid
70394
 
          FROM reserve JOIN itemloc ON (reserve_supply_id=itemloc_id)
70395
 
          WHERE ((reserve_supply_type='I')
70396
 
            AND  (reserve_demand_type = 'SO')
70397
 
            AND  (reserve_demand_id = _r.shipitem_orderitem_id )
70398
 
            AND  (itemloc_itemsite_id=_rsrv.shipitemlocrsrv_itemsite_id)
70399
 
            AND  (itemloc_location_id=_rsrv.shipitemlocrsrv_location_id)
70400
 
            AND  (COALESCE(itemloc_ls_id, -1)=COALESCE(_rsrv.shipitemlocrsrv_ls_id, -1))
70401
 
            AND  (COALESCE(itemloc_expiration, endOfTime())=COALESCE(_rsrv.shipitemlocrsrv_expiration, endOfTime()))
70402
 
            AND  (COALESCE(itemloc_warrpurc, endoftime())=COALESCE(_rsrv.shipitemlocrsrv_warrpurc, endoftime())) );
70403
 
 
70404
 
          GET DIAGNOSTICS _rows = ROW_COUNT;
70405
 
          IF (_rows > 0 ) THEN  
70406
 
            -- Update existing
70407
 
            UPDATE reserve
70408
 
            SET reserve_qty = (reserve_qty + _rsrv.shipitemlocrsrv_qty)
70409
 
            WHERE (reserve_id=_reserveid);
70410
 
          ELSE
70411
 
            -- Recreate record
70412
 
            INSERT INTO reserve
70413
 
            SELECT nextval('reserve_reserve_id_seq'), 'SO', _r.shipitem_orderitem_id,
70414
 
                   'I', itemloc_id, _rsrv.shipitemlocrsrv_qty, 'R'
70415
 
            FROM itemloc
70416
 
            WHERE ((itemloc_itemsite_id=_rsrv.shipitemlocrsrv_itemsite_id)
70417
 
              AND  (itemloc_location_id=_rsrv.shipitemlocrsrv_location_id)
70418
 
              AND  (COALESCE(itemloc_ls_id, -1)=COALESCE(_rsrv.shipitemlocrsrv_ls_id, -1))
70419
 
              AND  (COALESCE(itemloc_expiration, endOfTime())=COALESCE(_rsrv.shipitemlocrsrv_expiration, endOfTime()))
70420
 
              AND  (COALESCE(itemloc_warrpurc, endoftime())=COALESCE(_rsrv.shipitemlocrsrv_warrpurc, endoftime())) );
70421
 
          END IF;
70422
 
        END LOOP;
70423
 
      END IF;
70424
 
      
70425
 
      DELETE FROM shipitem WHERE (shipitem_id = _r.shipitem_id );
70426
 
 
70427
 
      -- Clean up if this is the last shipitem on the shipment
70428
 
      IF (NOT EXISTS(SELECT shipitem_shiphead_id
70429
 
                     FROM shipitem
70430
 
                     WHERE (shipitem_shiphead_id=_r.shiphead_id))) THEN
70431
 
        DELETE FROM shipdata
70432
 
         WHERE(shipdata_shiphead_number=_r.shiphead_number);
70433
 
        DELETE FROM shipdatasum
70434
 
         WHERE(shipdatasum_shiphead_number=_r.shiphead_number);
70435
 
        DELETE FROM pack
70436
 
         WHERE(pack_shiphead_id=_r.shiphead_id);
70437
 
        DELETE FROM shiphead
70438
 
         WHERE (shiphead_id=_r.shiphead_id);
70439
 
      END IF;
70440
 
 
70441
 
    END IF;
70442
 
 
70443
 
    RETURN _itemlocSeries;
70444
 
 
70445
 
END;
70446
 
$_$;
70447
 
 
70448
 
 
70449
 
ALTER FUNCTION public.returnshipmenttransaction(integer, integer, timestamp with time zone) OWNER TO admin;
70450
 
 
70451
 
--
70452
 
--
70453
 
 
70454
 
CREATE FUNCTION returnwomaterial(integer, numeric, timestamp with time zone) RETURNS integer
70455
 
    LANGUAGE plpgsql
70456
 
    AS $_$
70457
 
DECLARE
70458
 
  pWomatlid ALIAS FOR $1;
70459
 
  pQty ALIAS FOR $2;
70460
 
  pGlDistTS ALIAS FOR $3;
70461
 
  _itemlocSeries INTEGER;
70462
 
 
70463
 
BEGIN
70464
 
 
70465
 
  SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
70466
 
  RETURN returnWoMaterial(pWomatlid, pQty, _itemlocSeries, pGlDistTS);
70467
 
 
70468
 
END;
70469
 
$_$;
70470
 
 
70471
 
 
70472
 
ALTER FUNCTION public.returnwomaterial(integer, numeric, timestamp with time zone) OWNER TO admin;
70473
 
 
70474
 
--
70475
 
--
70476
 
 
70477
 
CREATE FUNCTION returnwomaterial(integer, integer, timestamp with time zone, integer) RETURNS integer
70478
 
    LANGUAGE plpgsql
70479
 
    AS $_$
70480
 
DECLARE
70481
 
  pWomatlid ALIAS FOR $1;
70482
 
  pItemlocSeries ALIAS FOR $2;
70483
 
  pGlDistTS ALIAS FOR $3;
70484
 
  pInvhistId ALIAS FOR $4;
70485
 
  _woNumber TEXT;
70486
 
  _invhistid INTEGER;
70487
 
  _itemlocSeries INTEGER;
70488
 
  _invqty NUMERIC;
70489
 
  _womatlqty NUMERIC;
70490
 
  _cost NUMERIC := 0;
70491
 
  _rows INTEGER;
70492
 
 
70493
 
BEGIN
70494
 
 
70495
 
  _itemlocSeries := 0;
70496
 
 
70497
 
  SELECT invhist_invqty, invhist_invqty * invhist_unitcost INTO _invqty, _cost
70498
 
  FROM invhist
70499
 
  WHERE (invhist_id=pInvhistId);
70500
 
 
70501
 
  GET DIAGNOSTICS _rows = ROW_COUNT;
70502
 
  
70503
 
  IF (_rows = 0) THEN
70504
 
    RAISE EXCEPTION 'No transaction found for invhist_id %', pInvhistId;
70505
 
  END IF;
70506
 
  
70507
 
  SELECT itemuomtouom(itemsite_item_id, NULL, womatl_uom_id, _invqty)
70508
 
    INTO _womatlqty
70509
 
    FROM womatl, itemsite
70510
 
    WHERE((womatl_itemsite_id=itemsite_id)
70511
 
     AND (womatl_id=pWomatlid));
70512
 
 
70513
 
  GET DIAGNOSTICS _rows = ROW_COUNT;
70514
 
  
70515
 
  IF (_rows = 0) THEN
70516
 
    _womatlqty := _invqty;
70517
 
  END IF;
70518
 
 
70519
 
  IF ( SELECT (
70520
 
         CASE WHEN (womatl_qtyreq >= 0) THEN
70521
 
           womatl_qtyiss < _womatlqty
70522
 
         ELSE
70523
 
           womatl_qtyiss > _womatlqty
70524
 
         END )
70525
 
       FROM womatl
70526
 
       WHERE ( womatl_id=pWomatlid ) ) THEN
70527
 
    RETURN pItemlocSeries;
70528
 
  END IF;
70529
 
 
70530
 
  SELECT formatWoNumber(womatl_wo_id) INTO _woNumber
70531
 
  FROM womatl
70532
 
  WHERE (womatl_id=pWomatlid);
70533
 
 
70534
 
  IF (pItemlocSeries = 0) THEN
70535
 
    SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
70536
 
  ELSE
70537
 
    _itemlocSeries = pItemlocSeries;
70538
 
  END IF;
70539
 
 
70540
 
  -- Post the transaction
70541
 
  SELECT postInvTrans( ci.itemsite_id, 'IM', (_invqty * -1), 
70542
 
                       'W/O', 'WO', _woNumber, '',
70543
 
                       ('Return ' || item_number || ' from Work Order'),
70544
 
                       getPrjAccntId(wo_prj_id, pc.costcat_wip_accnt_id), cc.costcat_asset_accnt_id, _itemlocSeries, pGlDistTS,
70545
 
                       -- Cost will be ignored by Standard Cost items sites
70546
 
                       _cost, pInvhistId) INTO _invhistid
70547
 
    FROM womatl, wo,
70548
 
         itemsite AS ci, costcat AS cc,
70549
 
         itemsite AS pi, costcat AS pc,
70550
 
         item
70551
 
   WHERE((womatl_itemsite_id=ci.itemsite_id)
70552
 
     AND (ci.itemsite_costcat_id=cc.costcat_id)
70553
 
     AND (womatl_wo_id=wo_id)
70554
 
     AND (wo_itemsite_id=pi.itemsite_id)
70555
 
     AND (pi.itemsite_costcat_id=pc.costcat_id)
70556
 
     AND (ci.itemsite_item_id=item_id)
70557
 
     AND (womatl_id=pWomatlid) );
70558
 
 
70559
 
  INSERT INTO womatlpost (womatlpost_womatl_id,womatlpost_invhist_id)
70560
 
              VALUES (pWomatlid,_invhistid);
70561
 
 
70562
 
  UPDATE wo
70563
 
  SET wo_wipvalue = (wo_wipvalue - (CASE WHEN(itemsite_costmethod IN ('A','J'))
70564
 
                                              THEN _cost
70565
 
                                         WHEN(itemsite_costmethod='S')
70566
 
                                              THEN stdcost(itemsite_item_id) * _invqty
70567
 
                                         ELSE 0.0 END )),
70568
 
      wo_postedvalue = (wo_postedvalue - (CASE WHEN(itemsite_costmethod IN ('A','J'))
70569
 
                                                    THEN _cost
70570
 
                                               WHEN(itemsite_costmethod='S')
70571
 
                                                    THEN stdcost(itemsite_item_id) * _invqty
70572
 
                                               ELSE 0.0 END ))
70573
 
  FROM womatl, itemsite
70574
 
  WHERE ( (wo_id=womatl_wo_id)
70575
 
   AND (womatl_itemsite_id=itemsite_id)
70576
 
   AND (womatl_id=pWomatlid) );
70577
 
 
70578
 
  UPDATE womatl
70579
 
  SET womatl_qtyiss = (womatl_qtyiss - _womatlqty),
70580
 
      womatl_lastreturn = CURRENT_DATE
70581
 
  WHERE (womatl_id=pWomatlid);
70582
 
 
70583
 
  RETURN _itemlocSeries;
70584
 
END;
70585
 
$_$;
70586
 
 
70587
 
 
70588
 
ALTER FUNCTION public.returnwomaterial(integer, integer, timestamp with time zone, integer) OWNER TO admin;
70589
 
 
70590
 
--
70591
 
--
70592
 
 
70593
 
COMMENT ON FUNCTION returnwomaterial(integer, integer, timestamp with time zone, integer) IS 'Returns material by reversing a specific historical transaction';
70594
 
 
70595
 
 
70596
 
--
70597
 
--
70598
 
 
70599
 
CREATE FUNCTION returnwomaterial(integer, numeric, integer, timestamp with time zone, boolean DEFAULT false) RETURNS integer
70600
 
    LANGUAGE plpgsql
70601
 
    AS $_$
70602
 
DECLARE
70603
 
  pWomatlid ALIAS FOR $1;
70604
 
  pQty ALIAS FOR $2;
70605
 
  pItemlocSeries ALIAS FOR $3;
70606
 
  pGlDistTS ALIAS FOR $4;
70607
 
  pReqStdCost ALIAS FOR $5;
70608
 
  _woNumber TEXT;
70609
 
  _invhistid INTEGER;
70610
 
  _itemlocSeries INTEGER;
70611
 
  _qty NUMERIC;
70612
 
  _cost NUMERIC := 0;
70613
 
 
70614
 
BEGIN
70615
 
 
70616
 
  _itemlocSeries := 0;
70617
 
  
70618
 
  IF ( SELECT (
70619
 
         CASE WHEN (womatl_qtyreq >= 0) THEN
70620
 
           womatl_qtyiss < pQty
70621
 
         ELSE
70622
 
           womatl_qtyiss > pQty
70623
 
         END )
70624
 
       FROM womatl
70625
 
       WHERE ( womatl_id=pWomatlid ) ) THEN
70626
 
    RETURN pItemlocSeries;
70627
 
  END IF;
70628
 
 
70629
 
  SELECT itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, pQty)
70630
 
    INTO _qty
70631
 
    FROM womatl, itemsite
70632
 
   WHERE((womatl_itemsite_id=itemsite_id)
70633
 
     AND (womatl_id=pWomatlid));
70634
 
  IF (NOT FOUND) THEN
70635
 
    _qty := pQty;
70636
 
  END IF;
70637
 
 
70638
 
  SELECT formatWoNumber(womatl_wo_id) INTO _woNumber
70639
 
  FROM womatl
70640
 
  WHERE (womatl_id=pWomatlid);
70641
 
 
70642
 
  IF (pItemlocSeries = 0) THEN
70643
 
    SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
70644
 
  ELSE
70645
 
    _itemlocSeries = pItemlocSeries;
70646
 
  END IF;
70647
 
 
70648
 
  -- Get the cost average
70649
 
  IF (pReqStdCost) THEN
70650
 
    SELECT stdcost(itemsite_item_id) * _qty INTO _cost
70651
 
    FROM womatl, itemsite
70652
 
    WHERE((womatl_itemsite_id=itemsite_id)
70653
 
      AND (womatl_id=pWomatlid));
70654
 
  ELSE
70655
 
    SELECT SUM(invhist_value_before - invhist_value_after) / SUM(invhist_qoh_before - invhist_qoh_after)  * _qty INTO _cost
70656
 
    FROM invhist, womatlpost, womatl 
70657
 
    WHERE((womatlpost_womatl_id=womatl_id) 
70658
 
     AND (womatlpost_invhist_id=invhist_id) 
70659
 
     AND (invhist_qoh_before > invhist_qoh_after)
70660
 
     AND (womatl_id=pWomatlId));
70661
 
  END IF;
70662
 
 
70663
 
  _cost := COALESCE(_cost, 0); -- make sure it's not a null value
70664
 
 
70665
 
  -- Post the transaction
70666
 
  SELECT postInvTrans( ci.itemsite_id, 'IM', (_qty * -1), 
70667
 
                       'W/O', 'WO', _woNumber, '',
70668
 
                       ('Return ' || item_number || ' from Work Order'),
70669
 
                       getPrjAccntId(wo_prj_id, pc.costcat_wip_accnt_id), cc.costcat_asset_accnt_id, _itemlocSeries, pGlDistTS,
70670
 
                       -- Cost will be ignored by Standard Cost items sites
70671
 
                       _cost) INTO _invhistid
70672
 
    FROM womatl, wo,
70673
 
         itemsite AS ci, costcat AS cc,
70674
 
         itemsite AS pi, costcat AS pc,
70675
 
         item
70676
 
   WHERE((womatl_itemsite_id=ci.itemsite_id)
70677
 
     AND (ci.itemsite_costcat_id=cc.costcat_id)
70678
 
     AND (womatl_wo_id=wo_id)
70679
 
     AND (wo_itemsite_id=pi.itemsite_id)
70680
 
     AND (pi.itemsite_costcat_id=pc.costcat_id)
70681
 
     AND (ci.itemsite_item_id=item_id)
70682
 
     AND (womatl_id=pWomatlid) );
70683
 
 
70684
 
  IF (_invhistid != -1) THEN
70685
 
    INSERT INTO womatlpost (womatlpost_womatl_id,womatlpost_invhist_id)
70686
 
                VALUES (pWomatlid,_invhistid);
70687
 
  END IF;
70688
 
 
70689
 
  UPDATE wo
70690
 
  SET wo_wipvalue = (wo_wipvalue - (CASE WHEN(itemsite_costmethod IN ('A','J'))
70691
 
                                              THEN _cost
70692
 
                                         WHEN(itemsite_costmethod='S')
70693
 
                                              THEN stdcost(itemsite_item_id) * _qty
70694
 
                                         ELSE 0.0 END )),
70695
 
      wo_postedvalue = (wo_postedvalue - (CASE WHEN(itemsite_costmethod IN ('A','J'))
70696
 
                                                    THEN _cost
70697
 
                                               WHEN(itemsite_costmethod='S')
70698
 
                                                    THEN stdcost(itemsite_item_id) * _qty
70699
 
                                               ELSE 0.0 END ))
70700
 
  FROM womatl, itemsite
70701
 
  WHERE ( (wo_id=womatl_wo_id)
70702
 
   AND (womatl_itemsite_id=itemsite_id)
70703
 
   AND (womatl_id=pWomatlid) );
70704
 
 
70705
 
  UPDATE womatl
70706
 
  SET womatl_qtyiss = (womatl_qtyiss - pQty),
70707
 
      womatl_lastreturn = CURRENT_DATE
70708
 
  WHERE (womatl_id=pWomatlid);
70709
 
 
70710
 
  RETURN _itemlocSeries;
70711
 
 
70712
 
END;
70713
 
$_$;
70714
 
 
70715
 
 
70716
 
ALTER FUNCTION public.returnwomaterial(integer, numeric, integer, timestamp with time zone, boolean) OWNER TO admin;
70717
 
 
70718
 
--
70719
 
--
70720
 
 
70721
 
CREATE FUNCTION returnwomaterialbatch(integer) RETURNS integer
70722
 
    LANGUAGE plpgsql
70723
 
    AS $_$
70724
 
DECLARE
70725
 
  pWoid ALIAS FOR $1;
70726
 
  _itemlocSeries INTEGER;
70727
 
  _woid INTEGER;
70728
 
  _r RECORD;
70729
 
 
70730
 
BEGIN
70731
 
 
70732
 
  SELECT wo_id INTO _woid
70733
 
  FROM wo
70734
 
  WHERE ( (wo_status IN ('E','I'))
70735
 
   AND (wo_id=pWoid) );
70736
 
 
70737
 
  IF (FOUND) THEN
70738
 
    SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
70739
 
 
70740
 
    FOR _r IN SELECT womatl_id, 
70741
 
                CASE WHEN wo_qtyord >= 0 THEN
70742
 
                  womatl_qtyiss
70743
 
                ELSE
70744
 
                  ((womatl_qtyreq - womatl_qtyiss) * -1)
70745
 
                END AS qty
70746
 
              FROM wo, womatl, itemsite
70747
 
              WHERE ((wo_id=womatl_wo_id)
70748
 
              AND (womatl_itemsite_id=itemsite_id)
70749
 
              AND ( (wo_qtyord < 0) OR (womatl_issuemethod IN ('S','M')) )
70750
 
              AND (womatl_wo_id=pWoid)) LOOP
70751
 
 
70752
 
      IF (_r.qty != 0) THEN
70753
 
        PERFORM returnWoMaterial(_r.womatl_id, _r.qty, _itemlocSeries, now());
70754
 
      END IF;
70755
 
 
70756
 
    END LOOP;
70757
 
 
70758
 
    UPDATE wo
70759
 
    SET wo_status='E'
70760
 
    WHERE (wo_id=pWoid);
70761
 
 
70762
 
    RETURN _itemlocSeries;
70763
 
 
70764
 
  ELSE 
70765
 
    RETURN -1;
70766
 
  END IF;
70767
 
 
70768
 
END;
70769
 
$_$;
70770
 
 
70771
 
 
70772
 
ALTER FUNCTION public.returnwomaterialbatch(integer) OWNER TO admin;
70773
 
 
70774
 
--
70775
 
--
70776
 
 
70777
 
CREATE FUNCTION reversecashreceipt(integer, integer) RETURNS integer
70778
 
    LANGUAGE plpgsql
70779
 
    AS $_$
70780
 
DECLARE
70781
 
  pCashrcptid ALIAS FOR $1;
70782
 
  pJournalNumber ALIAS FOR $2;
70783
 
  _p RECORD;
70784
 
  _r RECORD;
70785
 
  _postToAR NUMERIC;
70786
 
  _postToMisc NUMERIC;
70787
 
  _posted_base NUMERIC := 0;
70788
 
  _posted NUMERIC := 0;
70789
 
  _sequence INTEGER;
70790
 
  _aropenid INTEGER;
70791
 
  _arMemoNumber TEXT;
70792
 
  _arAccntid INTEGER;
70793
 
  _closed BOOLEAN;
70794
 
  _debitAccntid INTEGER;
70795
 
  _exchGain NUMERIC;
70796
 
  _comment      TEXT;
70797
 
  _ccpayid  INTEGER;
70798
 
  _cctype TEXT;
70799
 
 
70800
 
BEGIN
70801
 
  _posted := 0;
70802
 
  _posted_base := 0;
70803
 
 
70804
 
  SELECT fetchGLSequence() INTO _sequence;
70805
 
 
70806
 
  SELECT accnt_id INTO _arAccntid
70807
 
  FROM cashrcpt, accnt, salescat
70808
 
  WHERE ((cashrcpt_salescat_id=salescat_id)
70809
 
    AND  (salescat_ar_accnt_id=accnt_id)
70810
 
    AND  (cashrcpt_id=pCashrcptid));
70811
 
  IF (NOT FOUND) THEN
70812
 
    SELECT accnt_id INTO _arAccntid
70813
 
    FROM cashrcpt, accnt
70814
 
    WHERE ( (findARAccount(cashrcpt_cust_id)=accnt_id)
70815
 
     AND (cashrcpt_id=pCashrcptid) );
70816
 
    IF (NOT FOUND) THEN
70817
 
      RETURN -5;
70818
 
    END IF;
70819
 
  END IF;
70820
 
 
70821
 
  SELECT cashrcpt_cust_id, ('Reverse Cash Receipt posting for ' || cust_number||'-'||cust_name) AS custnote,
70822
 
         cashrcpt_fundstype, cashrcpt_number, cashrcpt_docnumber,
70823
 
         cashrcpt_distdate, cashrcpt_amount, cashrcpt_discount,
70824
 
         (cashrcpt_amount / cashrcpt_curr_rate) AS cashrcpt_amount_base,
70825
 
         (cashrcpt_discount / cashrcpt_curr_rate) AS cashrcpt_discount_base,
70826
 
         cashrcpt_notes,
70827
 
         cashrcpt_bankaccnt_id AS bankaccnt_id,
70828
 
         accnt_id AS prepaid_accnt_id,
70829
 
         cashrcpt_usecustdeposit,
70830
 
         cashrcpt_curr_id, cashrcpt_curr_rate INTO _p
70831
 
  FROM accnt, cashrcpt LEFT OUTER JOIN custinfo ON (cashrcpt_cust_id=cust_id)
70832
 
  WHERE ( (findPrepaidAccount(cashrcpt_cust_id)=accnt_id)
70833
 
   AND (cashrcpt_id=pCashrcptid) );
70834
 
  IF (NOT FOUND) THEN
70835
 
    RETURN -7;
70836
 
  END IF;
70837
 
 
70838
 
  IF (_p.cashrcpt_fundstype IN ('A', 'D', 'M', 'V')) THEN
70839
 
    SELECT ccpay_id, ccpay_type INTO _ccpayid, _cctype
70840
 
    FROM ccpay
70841
 
    WHERE ((ccpay_r_ordernum IN (CAST(pCashrcptid AS TEXT), _p.cashrcpt_docnumber))
70842
 
       AND (ccpay_status IN ('C', 'A')));
70843
 
 
70844
 
    IF NOT FOUND THEN
70845
 
      -- the following select seems to work except for xikar - bug 8848. why?
70846
 
      -- raise warning so there is some visibility if people fall into this path.
70847
 
      SELECT ccpay_id, ccpay_type INTO _ccpayid, _cctype
70848
 
      FROM ccpay
70849
 
      WHERE ((ccpay_order_number IN (CAST(pCashrcptid AS TEXT), _p.cashrcpt_docnumber))
70850
 
         AND (ccpay_status IN ('C', 'A')));
70851
 
      IF (NOT FOUND) THEN
70852
 
        RETURN -8;
70853
 
      ELSE
70854
 
        RAISE NOTICE 'PostCashReceipt() found ccpay_id % for order number %/% (ref 8848).',
70855
 
                      _ccpayid, pCashrcptid, _p.cashrcpt_docnumber;
70856
 
      END IF;
70857
 
    END IF;
70858
 
 
70859
 
    IF (_cctype = 'C' ) THEN
70860
 
      _debitAccntid := findPrepaidAccount(_p.cashrcpt_cust_id);
70861
 
    ELSE
70862
 
      SELECT accnt_id INTO _debitAccntid
70863
 
      FROM cashrcpt, bankaccnt, accnt
70864
 
      WHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id)
70865
 
       AND (bankaccnt_accnt_id=accnt_id)
70866
 
       AND (cashrcpt_id=pCashrcptid) );
70867
 
      IF (NOT FOUND) THEN
70868
 
        RETURN -6;
70869
 
      END IF;
70870
 
    END IF;
70871
 
  ELSE
70872
 
    SELECT accnt_id INTO _debitAccntid
70873
 
    FROM cashrcpt, bankaccnt, accnt
70874
 
    WHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id)
70875
 
     AND (bankaccnt_accnt_id=accnt_id)
70876
 
     AND (cashrcpt_id=pCashrcptid) );
70877
 
    IF (NOT FOUND) THEN
70878
 
      RETURN -6;
70879
 
    END IF;
70880
 
  END IF;
70881
 
 
70882
 
  SELECT COALESCE(SUM(cashrcptitem_amount),0) INTO _postToAR
70883
 
  FROM cashrcptitem JOIN aropen ON (aropen_id=cashrcptitem_aropen_id)
70884
 
  WHERE ((cashrcptitem_cashrcpt_id=pCashrcptid)
70885
 
   AND (cashrcptitem_applied));
70886
 
  IF (NOT FOUND) THEN
70887
 
    _postToAR := 0;
70888
 
  END IF;
70889
 
 
70890
 
  SELECT COALESCE(SUM(cashrcptmisc_amount),0) INTO _postToMisc
70891
 
  FROM cashrcptmisc
70892
 
  WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid);
70893
 
  IF (NOT FOUND) THEN
70894
 
    _postToMisc := 0;
70895
 
  END IF;
70896
 
 
70897
 
  IF ((_postToAR + _postToMisc) > _p.cashrcpt_amount) THEN
70898
 
    RETURN -1;
70899
 
  END IF;
70900
 
 
70901
 
  IF (_p.cashrcpt_amount <= 0) THEN
70902
 
    RETURN -2;
70903
 
  END IF;
70904
 
 
70905
 
  FOR _r IN SELECT aropen_id, aropen_doctype, aropen_docnumber, aropen_docdate,
70906
 
                   aropen_duedate, aropen_curr_id, aropen_curr_rate,
70907
 
                   round(aropen_amount - aropen_paid, 2) <=
70908
 
                      round(aropen_paid + 
70909
 
                      currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_amount + cashrcptitem_discount),_p.cashrcpt_distdate),2)
70910
 
                               AS closed,
70911
 
                   cashrcptitem_id, cashrcptitem_amount, cashrcptitem_discount,
70912
 
                   (cashrcptitem_amount / _p.cashrcpt_curr_rate) AS cashrcptitem_amount_base,
70913
 
                   (cashrcptitem_discount / _p.cashrcpt_curr_rate) AS cashrcptitem_discount_base,
70914
 
                   round(aropen_paid - 
70915
 
                      currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_amount),_p.cashrcpt_distdate),2) AS new_paid,
70916
 
                   round(currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_discount),_p.cashrcpt_distdate),2) AS new_discount
70917
 
            FROM cashrcptitem JOIN aropen ON (cashrcptitem_aropen_id=aropen_id)
70918
 
            WHERE ((cashrcptitem_cashrcpt_id=pCashrcptid)
70919
 
              AND (cashrcptitem_applied)) LOOP
70920
 
 
70921
 
    IF (_r.cashrcptitem_discount_base > 0) THEN
70922
 
      PERFORM reverseCashReceiptDisc(_r.cashrcptitem_id, pJournalNumber);
70923
 
    END IF;
70924
 
     
70925
 
    UPDATE aropen
70926
 
    SET aropen_paid = _r.new_paid - _r.new_discount,
70927
 
        aropen_open = TRUE,
70928
 
        aropen_closedate = NULL
70929
 
    WHERE (aropen_id=_r.aropen_id);
70930
 
 
70931
 
    _posted_base := _posted_base + _r.cashrcptitem_amount_base;
70932
 
    _posted := _posted + _r.cashrcptitem_amount;
70933
 
 
70934
 
    IF (_r.aropen_doctype IN ('I','D')) THEN
70935
 
      INSERT INTO arapply
70936
 
      ( arapply_cust_id,
70937
 
        arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber,
70938
 
        arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber,
70939
 
        arapply_fundstype, arapply_refnumber, arapply_reftype, arapply_ref_id,
70940
 
        arapply_applied, arapply_closed,
70941
 
        arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username,
70942
 
        arapply_curr_id
70943
 
       )
70944
 
      VALUES
70945
 
      ( _p.cashrcpt_cust_id,
70946
 
        -1, 'K', _p.cashrcpt_number,
70947
 
        _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber,
70948
 
        _p.cashrcpt_fundstype, _p.cashrcpt_docnumber, 'CRA', _r.cashrcptitem_id,
70949
 
        (round(_r.cashrcptitem_amount, 2) * -1.0), _r.closed,
70950
 
        CURRENT_DATE, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id );
70951
 
    ELSE
70952
 
      INSERT INTO arapply
70953
 
      ( arapply_cust_id,
70954
 
        arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber,
70955
 
        arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber,
70956
 
        arapply_fundstype, arapply_refnumber, arapply_reftype, arapply_ref_id,
70957
 
        arapply_applied, arapply_closed, arapply_postdate, arapply_distdate,
70958
 
        arapply_journalnumber, arapply_username, arapply_curr_id )
70959
 
      VALUES
70960
 
      ( _p.cashrcpt_cust_id,
70961
 
        _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber,
70962
 
        -1, 'R', _p.cashrcpt_number,
70963
 
        '', '', 'CRA', _r.cashrcptitem_id,
70964
 
        (round(abs(_r.cashrcptitem_amount), 2) * -1.0), _r.closed,
70965
 
        CURRENT_DATE, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id );
70966
 
    END IF;
70967
 
 
70968
 
    _exchGain := arCurrGain(_r.aropen_id,_p.cashrcpt_curr_id, abs(_r.cashrcptitem_amount),
70969
 
                           _p.cashrcpt_distdate);
70970
 
 
70971
 
    PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR',
70972
 
                        (_r.aropen_doctype || '-' || _r.aropen_docnumber),
70973
 
                        CASE WHEN _r.aropen_doctype != 'R' THEN _arAccntid
70974
 
                        ELSE findDeferredAccount(_p.cashrcpt_cust_id) END, 
70975
 
                        (round(_r.cashrcptitem_amount_base + _exchGain, 2) * -1.0),
70976
 
                        _p.cashrcpt_distdate, _p.custnote );
70977
 
 
70978
 
    IF (_exchGain <> 0) THEN
70979
 
        PERFORM insertIntoGLSeries(_sequence, 'A/R', 'CR',
70980
 
               _r.aropen_doctype || '-' || _r.aropen_docnumber,
70981
 
               getGainLossAccntId(
70982
 
               CASE WHEN _r.aropen_doctype != 'R' THEN _arAccntid
70983
 
               ELSE findDeferredAccount(_p.cashrcpt_cust_id) END
70984
 
               ), round(_exchGain, 2),
70985
 
               _p.cashrcpt_distdate, _p.custnote);
70986
 
 
70987
 
    END IF;
70988
 
 
70989
 
  END LOOP;
70990
 
 
70991
 
  FOR _r IN SELECT cashrcptmisc_id, cashrcptmisc_accnt_id, cashrcptmisc_amount,
70992
 
                   (cashrcptmisc_amount / _p.cashrcpt_curr_rate) AS cashrcptmisc_amount_base,
70993
 
                   cashrcptmisc_notes
70994
 
            FROM cashrcptmisc
70995
 
            WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid)  LOOP
70996
 
 
70997
 
    _posted_base := (_posted_base + _r.cashrcptmisc_amount_base);
70998
 
    _posted := (_posted + _r.cashrcptmisc_amount);
70999
 
 
71000
 
    INSERT INTO arapply
71001
 
    ( arapply_cust_id,
71002
 
      arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber,
71003
 
      arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber,
71004
 
      arapply_fundstype, arapply_refnumber,
71005
 
      arapply_applied, arapply_closed,
71006
 
      arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username,
71007
 
      arapply_curr_id, arapply_reftype, arapply_ref_id )
71008
 
    VALUES
71009
 
    ( _p.cashrcpt_cust_id,
71010
 
      -1, 'K', '',
71011
 
      -1, 'Misc.', '',
71012
 
      _p.cashrcpt_fundstype, _p.cashrcpt_docnumber,
71013
 
      (round(_r.cashrcptmisc_amount, 2) * -1.0), TRUE,
71014
 
      CURRENT_DATE, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), 
71015
 
      _p.cashrcpt_curr_id, 'CRD', _r.cashrcptmisc_id );
71016
 
 
71017
 
    PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', _r.cashrcptmisc_notes,
71018
 
                                _r.cashrcptmisc_accnt_id,
71019
 
                                (round(_r.cashrcptmisc_amount_base, 2) * -1.0),
71020
 
                                _p.cashrcpt_distdate, _p.custnote );
71021
 
 
71022
 
  END LOOP;
71023
 
 
71024
 
  IF (round(_posted_base, 2) < round(_p.cashrcpt_amount_base, 2)) THEN
71025
 
    _comment := ('Unapplied from ' || _p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber);
71026
 
    PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR',
71027
 
                                _comment,
71028
 
                                _p.prepaid_accnt_id,
71029
 
                                ((round(_p.cashrcpt_amount_base, 2) - round(_posted_base, 2)) * -1.0),
71030
 
                                _p.cashrcpt_distdate, _p.custnote );
71031
 
    SELECT fetchArMemoNumber() INTO _arMemoNumber;
71032
 
    -- Post A/R Debit Memo
71033
 
    SELECT createARDebitMemo(NULL, _p.cashrcpt_cust_id, pJournalNumber, _arMemoNumber, '',
71034
 
                              _p.cashrcpt_distdate, (_p.cashrcpt_amount - _posted),
71035
 
                              _comment, -1, -1, -1, _p.cashrcpt_distdate, -1, NULL, 0,
71036
 
                              _p.cashrcpt_curr_id) INTO _aropenid;
71037
 
    -- Create Cash Receipt Item to capture posting
71038
 
    INSERT INTO cashrcptitem
71039
 
      ( cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount )
71040
 
    VALUES
71041
 
      ( pCashrcptid, _aropenid, ((_p.cashrcpt_amount - _posted) * 1.0) );
71042
 
 
71043
 
  ELSIF (round(_posted_base, 2) > round(_p.cashrcpt_amount_base, 2)) THEN
71044
 
    PERFORM insertIntoGLSeries(_sequence, 'A/R', 'CR',
71045
 
                   'Currency Exchange Rounding - ' || _p.cashrcpt_docnumber,
71046
 
                   getGainLossAccntId(_debitAccntid),
71047
 
                   ((round(_posted_base, 2) - round((_p.cashrcpt_amount_base + _p.cashrcpt_discount_base), 2)) * 1.0),
71048
 
                   _p.cashrcpt_distdate, _p.custnote);
71049
 
  END IF;
71050
 
 
71051
 
  PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR',
71052
 
                    (_p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber),
71053
 
                     _debitAccntid, round(_p.cashrcpt_amount_base, 2),
71054
 
                     _p.cashrcpt_distdate,
71055
 
                     _p.custnote );
71056
 
 
71057
 
  PERFORM postGLSeries(_sequence, pJournalNumber);
71058
 
 
71059
 
  UPDATE cashrcpt SET cashrcpt_posted=FALSE,
71060
 
                      cashrcpt_posteddate=NULL,
71061
 
                      cashrcpt_postedby=NULL,
71062
 
                      cashrcpt_void=TRUE
71063
 
  WHERE (cashrcpt_id=pCashrcptid);
71064
 
 
71065
 
  RETURN 1;
71066
 
 
71067
 
END;
71068
 
$_$;
71069
 
 
71070
 
 
71071
 
ALTER FUNCTION public.reversecashreceipt(integer, integer) OWNER TO admin;
71072
 
 
71073
 
--
71074
 
--
71075
 
 
71076
 
CREATE FUNCTION reversecashreceiptdisc(integer, integer) RETURNS integer
71077
 
    LANGUAGE plpgsql
71078
 
    AS $_$
71079
 
DECLARE
71080
 
  pCashrcptItemId ALIAS FOR $1;
71081
 
  pJournalNumber ALIAS FOR $2;
71082
 
  _r RECORD;
71083
 
  _t RECORD;
71084
 
  _v RECORD;
71085
 
  _ardiscountid INTEGER;
71086
 
  _arMemoNumber TEXT;
71087
 
  _arAccntid INTEGER;
71088
 
  _discountAccntid INTEGER;
71089
 
  _comment      TEXT;
71090
 
  _discprcnt NUMERIC;
71091
 
  _check INTEGER;
71092
 
 
71093
 
BEGIN
71094
 
 
71095
 
    -- Fetch base records for processing
71096
 
    SELECT aropen_id, aropen_doctype, aropen_amount,
71097
 
           cashrcptitem_discount,
71098
 
           cashrcpt_cust_id, cashrcpt_distdate, cashrcpt_applydate,
71099
 
           cashrcpt_curr_id, cashrcpt_fundstype, cashrcpt_docnumber,
71100
 
           round(currToCurr(cashrcpt_curr_id, aropen_curr_id, cashrcptitem_discount, cashrcpt_distdate),2) AS aropen_discount
71101
 
      INTO _r
71102
 
    FROM cashrcptitem 
71103
 
      JOIN cashrcpt ON (cashrcptitem_cashrcpt_id=cashrcpt_id)
71104
 
      JOIN aropen ON ( (aropen_id=cashrcptitem_aropen_id) AND (aropen_doctype IN ('I', 'D')) )
71105
 
    WHERE (cashrcptitem_id=pCashrcptItemId);
71106
 
 
71107
 
    -- Get discount account
71108
 
    _discountAccntid := findardiscountaccount(_r.cashrcpt_cust_id);
71109
 
  
71110
 
    IF (_r.cashrcptitem_discount > 0) THEN
71111
 
      --  Determine discount percentage
71112
 
      _discprcnt := _r.aropen_discount / _r.aropen_amount;
71113
 
 
71114
 
      SELECT fetchArMemoNumber() INTO _arMemoNumber;
71115
 
      _comment := 'Discount Credit Reversal from ' || _r.cashrcpt_fundstype || '-' || _r.cashrcpt_docnumber;
71116
 
 
71117
 
      -- Create misc debit memo record
71118
 
      _ardiscountid := nextval('aropen_aropen_id_seq');
71119
 
      INSERT INTO aropen (
71120
 
        aropen_id, aropen_docdate, aropen_duedate, aropen_doctype, 
71121
 
        aropen_docnumber, aropen_curr_id, aropen_posted, aropen_amount ) 
71122
 
      VALUES ( 
71123
 
        _ardiscountid, _r.cashrcpt_distdate, _r.cashrcpt_distdate, 'D', 
71124
 
        _arMemoNumber, _r.cashrcpt_curr_id, false,_r.cashrcptitem_discount);
71125
 
        
71126
 
      IF (fetchMetricBool('CreditTaxDiscount')) THEN
71127
 
        --  proportional tax credits calculated and implemented for the debit memo generated by the discount
71128
 
        IF (_r.aropen_doctype  = 'I') THEN
71129
 
          -- Tax for invoices
71130
 
          SELECT aropen_cobmisc_id AS invcheadid, 
71131
 
                 invchead_curr_id, 
71132
 
                 invchead_invcdate INTO _t
71133
 
          FROM aropen
71134
 
            LEFT OUTER JOIN invchead ON (aropen_cobmisc_id = invchead_id) 
71135
 
            LEFT OUTER JOIN invcitem ON (invchead_id = invcitem_invchead_id)
71136
 
          WHERE aropen_id = _r.aropen_id;
71137
 
 
71138
 
          FOR _v IN SELECT tax_sales_accnt_id,
71139
 
                           tax_id, 
71140
 
                           round(sum(taxdetail_tax), 2) AS tax,
71141
 
                           currToBase(_t.invchead_curr_id, round(sum(taxdetail_tax), 2), _t.invchead_invcdate) AS taxbasevalue
71142
 
          FROM tax 
71143
 
            JOIN calculateTaxDetailSummary('I', _t.invcheadid, 'T') ON (taxdetail_tax_id=tax_id)
71144
 
            GROUP BY tax_id, tax_sales_accnt_id 
71145
 
          LOOP
71146
 
            INSERT INTO aropentax(
71147
 
              taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id,
71148
 
              taxhist_percent, taxhist_amount, taxhist_tax, 
71149
 
              taxhist_docdate, taxhist_basis)
71150
 
            VALUES (
71151
 
              _ardiscountid, getadjustmenttaxtypeid(), _v.tax_id, 
71152
 
              0.00, 0.00, (round((_v.tax * _discprcnt), 2)), 
71153
 
              _r.cashrcpt_distdate, 0.00);
71154
 
          END LOOP;
71155
 
 
71156
 
        ELSIF (_r.aropen_doctype  = 'D') THEN
71157
 
          -- Tax for debit memos
71158
 
          INSERT INTO aropentax(
71159
 
            taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id,
71160
 
            taxhist_percent, taxhist_amount, taxhist_tax, 
71161
 
            taxhist_docdate, taxhist_basis)
71162
 
          SELECT
71163
 
            _ardiscountid, taxhist_taxtype_id, taxhist_tax_id, 
71164
 
            0.00, 0.00, (round((taxhist_tax * _discprcnt), 2)),  
71165
 
            _r.cashrcpt_distdate, 0.00
71166
 
          FROM aropentax
71167
 
          WHERE (taxhist_parent_id=_r.aropen_id);
71168
 
              
71169
 
        END IF;
71170
 
      END IF; -- End taxes
71171
 
 
71172
 
      -- Create debit memo for discount
71173
 
      SELECT createARDebitMemo(_ardiscountid, _r.cashrcpt_cust_id, pJournalNumber, _arMemoNumber, '',
71174
 
                                _r.cashrcpt_distdate, _r.cashrcptitem_discount,
71175
 
                                _comment, -1, -1, _discountAccntid, _r.cashrcpt_distdate,
71176
 
                                -1, NULL, 0, _r.cashrcpt_curr_id) INTO _ardiscountid;
71177
 
 
71178
 
    END IF; -- End handle Discount
71179
 
 
71180
 
    RETURN 1;
71181
 
 
71182
 
END;
71183
 
$_$;
71184
 
 
71185
 
 
71186
 
ALTER FUNCTION public.reversecashreceiptdisc(integer, integer) OWNER TO admin;
71187
 
 
71188
 
--
71189
 
--
71190
 
 
71191
 
CREATE FUNCTION reverseglseries(integer, date, text) RETURNS integer
71192
 
    LANGUAGE plpgsql
71193
 
    AS $_$
71194
 
DECLARE
71195
 
  pSequence ALIAS FOR $1;
71196
 
  pDistDate ALIAS FOR $2;
71197
 
  pNotes ALIAS FOR $3;
71198
 
  _sequence INTEGER := fetchGLSequence();       
71199
 
  _journal INTEGER;
71200
 
 
71201
 
BEGIN
71202
 
 
71203
 
  IF (SELECT COUNT(gltrans_sequence) > 0 FROM gltrans WHERE gltrans_sequence = pSequence) THEN
71204
 
    SELECT fetchJournalNumber(jrnluse_use) INTO _journal
71205
 
    FROM gltrans
71206
 
      JOIN jrnluse ON (gltrans_journalnumber=jrnluse_number)
71207
 
    WHERE (gltrans_sequence=pSequence)
71208
 
    LIMIT 1;
71209
 
  
71210
 
    INSERT INTO gltrans (gltrans_created, gltrans_posted, gltrans_exported,
71211
 
                         gltrans_date, gltrans_sequence, gltrans_accnt_id,
71212
 
                         gltrans_source, gltrans_docnumber, gltrans_misc_id,
71213
 
                         gltrans_amount, gltrans_notes, gltrans_journalnumber,
71214
 
                         gltrans_doctype)
71215
 
                 SELECT  CURRENT_TIMESTAMP, FALSE, FALSE,
71216
 
                         pDistDate, _sequence, gltrans_accnt_id,
71217
 
                         gltrans_source, gltrans_docnumber, gltrans_misc_id,
71218
 
                         (gltrans_amount * -1), pNotes, _journal,
71219
 
                         gltrans_doctype
71220
 
                    FROM gltrans
71221
 
                   WHERE (gltrans_sequence=pSequence);
71222
 
 
71223
 
    PERFORM postIntoTrialBalance(_sequence);
71224
 
  ELSE
71225
 
    SELECT fetchJournalNumber(jrnluse_use) INTO _journal
71226
 
    FROM sltrans
71227
 
      JOIN jrnluse ON (sltrans_journalnumber=jrnluse_number)
71228
 
    WHERE (sltrans_sequence=pSequence)
71229
 
    LIMIT 1;
71230
 
    
71231
 
    INSERT INTO sltrans (sltrans_created, sltrans_posted,
71232
 
                         sltrans_date, sltrans_sequence, sltrans_accnt_id,
71233
 
                         sltrans_source, sltrans_docnumber, sltrans_misc_id,
71234
 
                         sltrans_amount, sltrans_notes, sltrans_journalnumber,
71235
 
                         sltrans_doctype)
71236
 
                 SELECT  CURRENT_TIMESTAMP, FALSE,
71237
 
                         pDistDate, _sequence, sltrans_accnt_id,
71238
 
                         sltrans_source, sltrans_docnumber, sltrans_misc_id,
71239
 
                         (sltrans_amount * -1), pNotes, _journal,
71240
 
                         sltrans_doctype
71241
 
                    FROM sltrans
71242
 
                   WHERE (sltrans_sequence=pSequence);
71243
 
  END IF;
71244
 
 
71245
 
  RETURN _journal;
71246
 
END;
71247
 
$_$;
71248
 
 
71249
 
 
71250
 
ALTER FUNCTION public.reverseglseries(integer, date, text) OWNER TO admin;
71251
 
 
71252
 
--
71253
 
--
71254
 
 
71255
 
CREATE FUNCTION revokeallmodulecmnttypesource(integer, text) RETURNS integer
71256
 
    LANGUAGE plpgsql
71257
 
    AS $_$
71258
 
DECLARE
71259
 
  pCmnttypeid ALIAS FOR $1;
71260
 
  pModuleName ALIAS FOR $2;
71261
 
 
71262
 
BEGIN
71263
 
 
71264
 
  DELETE FROM cmnttypesource
71265
 
  WHERE (cmnttypesource_id IN ( SELECT cmnttypesource_id
71266
 
                                FROM cmnttypesource, source
71267
 
                                WHERE ( (cmnttypesource_source_id=source_id)
71268
 
                                  AND (cmnttypesource_cmnttype_id=pCmnttypeid)
71269
 
                                  AND (source_module=pModuleName) ) ) );
71270
 
 
71271
 
  RETURN 1;
71272
 
 
71273
 
END;
71274
 
$_$;
71275
 
 
71276
 
 
71277
 
ALTER FUNCTION public.revokeallmodulecmnttypesource(integer, text) OWNER TO admin;
71278
 
 
71279
 
--
71280
 
--
71281
 
 
71282
 
CREATE FUNCTION revokeallmodulepriv(text, text) RETURNS integer
71283
 
    LANGUAGE plpgsql
71284
 
    AS $_$
71285
 
DECLARE
71286
 
  pUsername ALIAS FOR $1;
71287
 
  pModuleName ALIAS FOR $2;
71288
 
 
71289
 
BEGIN
71290
 
 
71291
 
  DELETE FROM usrpriv
71292
 
  WHERE (usrpriv_id IN ( SELECT usrpriv_id
71293
 
                         FROM usrpriv, priv
71294
 
                         WHERE ( (usrpriv_priv_id=priv_id)
71295
 
                          AND (usrpriv_username=pUsername)
71296
 
                          AND (priv_module=pModuleName) ) ) );
71297
 
 
71298
 
  NOTIFY "usrprivUpdated";
71299
 
 
71300
 
  RETURN 1;
71301
 
 
71302
 
END;
71303
 
$_$;
71304
 
 
71305
 
 
71306
 
ALTER FUNCTION public.revokeallmodulepriv(text, text) OWNER TO admin;
71307
 
 
71308
 
--
71309
 
--
71310
 
 
71311
 
CREATE FUNCTION revokeallmoduleprivgroup(integer, text) RETURNS integer
71312
 
    LANGUAGE plpgsql
71313
 
    AS $_$
71314
 
DECLARE
71315
 
  pGrpid ALIAS FOR $1;
71316
 
  pModuleName ALIAS FOR $2;
71317
 
 
71318
 
BEGIN
71319
 
 
71320
 
  DELETE FROM grppriv
71321
 
  WHERE (grppriv_id IN ( SELECT grppriv_id
71322
 
                         FROM grppriv, priv
71323
 
                         WHERE ( (grppriv_priv_id=priv_id)
71324
 
                          AND (grppriv_grp_id=pGrpid)
71325
 
                          AND (priv_module=pModuleName) ) ) );
71326
 
 
71327
 
  RETURN 1;
71328
 
 
71329
 
END;
71330
 
$_$;
71331
 
 
71332
 
 
71333
 
ALTER FUNCTION public.revokeallmoduleprivgroup(integer, text) OWNER TO admin;
71334
 
 
71335
 
--
71336
 
--
71337
 
 
71338
 
CREATE FUNCTION revokecmnttypesource(integer, integer) RETURNS boolean
71339
 
    LANGUAGE plpgsql
71340
 
    AS $_$
71341
 
DECLARE
71342
 
  pCmnttypeid ALIAS FOR $1;
71343
 
  pSourceid ALIAS FOR $2;
71344
 
 
71345
 
BEGIN
71346
 
 
71347
 
  DELETE FROM cmnttypesource
71348
 
  WHERE ( (cmnttypesource_cmnttype_id=pCmnttypeid)
71349
 
    AND (cmnttypesource_source_id=pSourceid) );
71350
 
 
71351
 
  RETURN TRUE;
71352
 
 
71353
 
END;
71354
 
$_$;
71355
 
 
71356
 
 
71357
 
ALTER FUNCTION public.revokecmnttypesource(integer, integer) OWNER TO admin;
71358
 
 
71359
 
--
71360
 
--
71361
 
 
71362
 
CREATE FUNCTION revokegroup(text, integer) RETURNS boolean
71363
 
    LANGUAGE plpgsql
71364
 
    AS $_$
71365
 
DECLARE
71366
 
  pUsername ALIAS FOR $1;
71367
 
  pGrpid ALIAS FOR $2;
71368
 
 
71369
 
BEGIN
71370
 
 
71371
 
  DELETE FROM usrgrp
71372
 
  WHERE ( (usrgrp_username=pUsername)
71373
 
   AND (usrgrp_grp_id=pGrpid) );
71374
 
 
71375
 
  RETURN TRUE;
71376
 
 
71377
 
END;
71378
 
$_$;
71379
 
 
71380
 
 
71381
 
ALTER FUNCTION public.revokegroup(text, integer) OWNER TO admin;
71382
 
 
71383
 
--
71384
 
--
71385
 
 
71386
 
CREATE FUNCTION revokepriv(text, integer) RETURNS boolean
71387
 
    LANGUAGE plpgsql
71388
 
    AS $_$
71389
 
DECLARE
71390
 
  pUsername ALIAS FOR $1;
71391
 
  pPrivid ALIAS FOR $2;
71392
 
 
71393
 
BEGIN
71394
 
 
71395
 
  DELETE FROM usrpriv
71396
 
  WHERE ( (usrpriv_username=pUsername)
71397
 
   AND (usrpriv_priv_id=pPrivid) );
71398
 
 
71399
 
  NOTIFY "usrprivUpdated";
71400
 
 
71401
 
  RETURN TRUE;
71402
 
 
71403
 
END;
71404
 
$_$;
71405
 
 
71406
 
 
71407
 
ALTER FUNCTION public.revokepriv(text, integer) OWNER TO admin;
71408
 
 
71409
 
--
71410
 
--
71411
 
 
71412
 
CREATE FUNCTION revokepriv(text, text) RETURNS boolean
71413
 
    LANGUAGE plpgsql
71414
 
    AS $_$
71415
 
DECLARE
71416
 
  pUsername ALIAS FOR $1;
71417
 
  pPrivname ALIAS FOR $2;
71418
 
 
71419
 
BEGIN
71420
 
 
71421
 
  DELETE FROM usrpriv
71422
 
  WHERE ( (usrpriv_username=pUsername)
71423
 
   AND (usrpriv_priv_id IN (SELECT priv_id
71424
 
                              FROM priv
71425
 
                             WHERE priv_name=pPrivname) ));
71426
 
 
71427
 
  NOTIFY "usrprivUpdated";
71428
 
 
71429
 
  RETURN TRUE;
71430
 
 
71431
 
END;
71432
 
$_$;
71433
 
 
71434
 
 
71435
 
ALTER FUNCTION public.revokepriv(text, text) OWNER TO admin;
71436
 
 
71437
 
--
71438
 
--
71439
 
 
71440
 
CREATE FUNCTION revokeprivgroup(integer, integer) RETURNS boolean
71441
 
    LANGUAGE plpgsql
71442
 
    AS $_$
71443
 
DECLARE
71444
 
  pGrpid ALIAS FOR $1;
71445
 
  pPrivid ALIAS FOR $2;
71446
 
 
71447
 
BEGIN
71448
 
 
71449
 
  DELETE FROM grppriv
71450
 
  WHERE ( (grppriv_grp_id=pGrpid)
71451
 
   AND (grppriv_priv_id=pPrivid) );
71452
 
 
71453
 
  NOTIFY "usrprivUpdated";
71454
 
 
71455
 
  RETURN TRUE;
71456
 
 
71457
 
END;
71458
 
$_$;
71459
 
 
71460
 
 
71461
 
ALTER FUNCTION public.revokeprivgroup(integer, integer) OWNER TO admin;
71462
 
 
71463
 
--
71464
 
--
71465
 
 
71466
 
CREATE FUNCTION rollupactualcost(integer) RETURNS integer
71467
 
    LANGUAGE plpgsql
71468
 
    AS $_$
71469
 
DECLARE
71470
 
    pItemid ALIAS FOR $1;
71471
 
 
71472
 
BEGIN
71473
 
    RETURN rollUpSorACost(pitemid, TRUE);
71474
 
END;
71475
 
$_$;
71476
 
 
71477
 
 
71478
 
ALTER FUNCTION public.rollupactualcost(integer) OWNER TO admin;
71479
 
 
71480
 
--
71481
 
--
71482
 
 
71483
 
CREATE FUNCTION rollupsoracost(integer, boolean) RETURNS integer
71484
 
    LANGUAGE plpgsql
71485
 
    AS $_$
71486
 
DECLARE
71487
 
  pItemid       ALIAS FOR $1;
71488
 
  pActual       ALIAS FOR $2;
71489
 
  _counter INTEGER;
71490
 
  _setid INTEGER;
71491
 
  _consumers RECORD;
71492
 
 
71493
 
BEGIN
71494
 
 
71495
 
  _counter := 0;
71496
 
 
71497
 
  SELECT indentedWhereUsed(pItemid) INTO _setid;
71498
 
 
71499
 
  FOR _consumers IN SELECT bomwork_item_id
71500
 
                    FROM bomwork
71501
 
                    WHERE (bomwork_set_id=_setid)
71502
 
                    ORDER BY bomwork_level LOOP
71503
 
    PERFORM updateSorACost( _consumers.bomwork_item_id, costelem_type, TRUE,
71504
 
                            lowerCost(_consumers.bomwork_item_id,
71505
 
                                      costelem_type, pActual),
71506
 
                            pActual )
71507
 
    FROM costelem
71508
 
    WHERE (costelem_sys);
71509
 
 
71510
 
    PERFORM updateLowerUserCosts(_consumers.bomwork_item_id, pActual);
71511
 
 
71512
 
    _counter := _counter + 1;
71513
 
 
71514
 
  END LOOP;
71515
 
 
71516
 
  PERFORM deleteBOMWorkset(_setid);
71517
 
 
71518
 
  RETURN _counter;
71519
 
 
71520
 
END;
71521
 
$_$;
71522
 
 
71523
 
 
71524
 
ALTER FUNCTION public.rollupsoracost(integer, boolean) OWNER TO admin;
71525
 
 
71526
 
--
71527
 
--
71528
 
 
71529
 
CREATE FUNCTION rollupstandardcost(integer) RETURNS integer
71530
 
    LANGUAGE plpgsql
71531
 
    AS $_$
71532
 
DECLARE
71533
 
    pItemid ALIAS FOR $1;
71534
 
 
71535
 
BEGIN
71536
 
    RETURN rollUpSorACost(pItemid, FALSE);
71537
 
END;
71538
 
$_$;
71539
 
 
71540
 
 
71541
 
ALTER FUNCTION public.rollupstandardcost(integer) OWNER TO admin;
71542
 
 
71543
 
--
71544
 
--
71545
 
 
71546
 
CREATE FUNCTION roundcost(pcost numeric) RETURNS numeric
71547
 
    LANGUAGE plpgsql IMMUTABLE
71548
 
    AS $$
71549
 
DECLARE
71550
 
  _scale INTEGER;
71551
 
 
71552
 
BEGIN
71553
 
  IF (pCost IS NULL) THEN
71554
 
    RETURN NULL;
71555
 
  END IF;
71556
 
 
71557
 
  SELECT locale_cost_scale INTO _scale
71558
 
  FROM locale
71559
 
  WHERE (locale_id=getUsrLocaleId());
71560
 
 
71561
 
  RETURN ROUND(pCost, _scale);
71562
 
 
71563
 
END;
71564
 
$$;
71565
 
 
71566
 
 
71567
 
ALTER FUNCTION public.roundcost(pcost numeric) OWNER TO admin;
71568
 
 
71569
 
--
71570
 
--
71571
 
 
71572
 
CREATE FUNCTION roundlocale(pfractional boolean, pqty numeric, plocale text) RETURNS numeric
71573
 
    LANGUAGE plpgsql IMMUTABLE
71574
 
    AS $$
71575
 
DECLARE
71576
 
  _r RECORD;
71577
 
  _scale INTEGER;
71578
 
 
71579
 
BEGIN
71580
 
  IF (pFractional) THEN
71581
 
    SELECT * INTO _r
71582
 
    FROM locale
71583
 
    WHERE (locale_id=getUsrLocaleId());
71584
 
 
71585
 
    _scale := CASE pLocale WHEN 'qtyper' THEN _r.locale_qtyper_scale
71586
 
                           WHEN 'cost' THEN _r.locale_cost_scale
71587
 
                           ELSE _r.locale_qty_scale
71588
 
              END;
71589
 
 
71590
 
    RETURN ROUND(pQty, _scale);
71591
 
  ELSE
71592
 
    IF (TRUNC(pQty) < pQty) THEN
71593
 
      RETURN (TRUNC(pQty) + 1);
71594
 
    ELSE
71595
 
      RETURN TRUNC(pQty);
71596
 
    END IF;
71597
 
  END IF;
71598
 
END;
71599
 
$$;
71600
 
 
71601
 
 
71602
 
ALTER FUNCTION public.roundlocale(pfractional boolean, pqty numeric, plocale text) OWNER TO admin;
71603
 
 
71604
 
--
71605
 
--
71606
 
 
71607
 
CREATE FUNCTION roundqty(pfractional boolean, pqty numeric) RETURNS numeric
71608
 
    LANGUAGE plpgsql IMMUTABLE
71609
 
    AS $$
71610
 
DECLARE
71611
 
  _scale INTEGER;
71612
 
 
71613
 
BEGIN
71614
 
  SELECT locale_qty_scale INTO _scale
71615
 
  FROM locale
71616
 
  WHERE (locale_id=getUsrLocaleId());
71617
 
 
71618
 
  IF (pFractional) THEN
71619
 
    RETURN ROUND(pQty, _scale);
71620
 
  ELSE
71621
 
    IF (TRUNC(pQty) < ROUND(pQty, _scale)) THEN
71622
 
      RETURN (TRUNC(pQty) + 1);
71623
 
    ELSE
71624
 
      RETURN TRUNC(pQty);
71625
 
    END IF;
71626
 
  END IF;
71627
 
END;
71628
 
$$;
71629
 
 
71630
 
 
71631
 
ALTER FUNCTION public.roundqty(pfractional boolean, pqty numeric) OWNER TO admin;
71632
 
 
71633
 
--
71634
 
--
71635
 
 
71636
 
CREATE FUNCTION roundsale(psale numeric) RETURNS numeric
71637
 
    LANGUAGE plpgsql IMMUTABLE
71638
 
    AS $$
71639
 
DECLARE
71640
 
  _scale INTEGER;
71641
 
 
71642
 
BEGIN
71643
 
  IF (pSale IS NULL) THEN
71644
 
    RETURN NULL;
71645
 
  END IF;
71646
 
 
71647
 
  SELECT locale_salesprice_scale INTO _scale
71648
 
  FROM locale
71649
 
  WHERE (locale_id=getUsrLocaleId());
71650
 
 
71651
 
  RETURN ROUND(pSale, _scale);
71652
 
 
71653
 
END;
71654
 
$$;
71655
 
 
71656
 
 
71657
 
ALTER FUNCTION public.roundsale(psale numeric) OWNER TO admin;
71658
 
 
71659
 
--
71660
 
--
71661
 
 
71662
 
CREATE FUNCTION roundup(numeric) RETURNS numeric
71663
 
    LANGUAGE plpgsql IMMUTABLE
71664
 
    AS $_$
71665
 
DECLARE
71666
 
 
71667
 
  pValue ALIAS FOR $1;
71668
 
  _checkValue integer;
71669
 
 
71670
 
BEGIN
71671
 
 
71672
 
  _checkValue := pValue::integer;
71673
 
 
71674
 
  IF (_checkValue::numeric < pValue) THEN
71675
 
    RETURN (_checkValue + 1)::numeric;
71676
 
  ELSE
71677
 
    RETURN _checkValue::numeric;
71678
 
  END IF;
71679
 
 
71680
 
END;
71681
 
$_$;
71682
 
 
71683
 
 
71684
 
ALTER FUNCTION public.roundup(numeric) OWNER TO admin;
71685
 
 
71686
 
--
71687
 
--
71688
 
 
71689
 
CREATE FUNCTION saveaddr(integer, text, text, text, text, text, text, text, text, text) RETURNS integer
71690
 
    LANGUAGE plpgsql
71691
 
    AS $_$
71692
 
DECLARE
71693
 
  pAddrId ALIAS FOR $1;
71694
 
  pNumber ALIAS FOR $2;
71695
 
  pAddr1 ALIAS FOR $3;
71696
 
  pAddr2 ALIAS FOR $4;
71697
 
  pAddr3 ALIAS FOR $5;
71698
 
  pCity ALIAS FOR $6;
71699
 
  pState ALIAS FOR $7;
71700
 
  pPostalCode ALIAS FOR $8;
71701
 
  pCountry ALIAS FOR $9;
71702
 
  pFlag ALIAS FOR $10;
71703
 
  _returnVal INTEGER;
71704
 
 
71705
 
BEGIN
71706
 
 
71707
 
  SELECT saveAddr(pAddrId,pNumber, pAddr1,pAddr2,pAddr3,pCity,pState,pPostalCode,pCountry,true,'',pFlag) INTO _returnVal;
71708
 
  
71709
 
  RETURN _returnVal;
71710
 
 
71711
 
END;
71712
 
$_$;
71713
 
 
71714
 
 
71715
 
ALTER FUNCTION public.saveaddr(integer, text, text, text, text, text, text, text, text, text) OWNER TO admin;
71716
 
 
71717
 
--
71718
 
--
71719
 
 
71720
 
CREATE FUNCTION saveaddr(integer, text, text, text, text, text, text, text, text, boolean, text, text) RETURNS integer
71721
 
    LANGUAGE plpgsql
71722
 
    AS $_$
71723
 
DECLARE
71724
 
  pAddrId ALIAS FOR $1;
71725
 
  pNumber ALIAS FOR $2;
71726
 
  pAddr1 ALIAS FOR $3;
71727
 
  pAddr2 ALIAS FOR $4;
71728
 
  pAddr3 ALIAS FOR $5;
71729
 
  pCity ALIAS FOR $6;
71730
 
  pState ALIAS FOR $7;
71731
 
  pPostalCode ALIAS FOR $8;
71732
 
  pCountry ALIAS FOR $9;
71733
 
  pActive ALIAS FOR $10;
71734
 
  pNotes ALIAS FOR $11;
71735
 
  pFlag ALIAS FOR $12;
71736
 
  _addrId INTEGER;
71737
 
  _addrNumber INTEGER;
71738
 
  _flag TEXT;
71739
 
  _p RECORD;
71740
 
  _cnt INTEGER;
71741
 
  _notes TEXT;
71742
 
 
71743
 
BEGIN
71744
 
  --Validate
71745
 
  IF ((pFlag IS NULL) OR (pFlag = '') OR (pFlag = 'CHECK') OR (pFlag = 'CHANGEONE') OR (pFlag = 'CHANGEALL')) THEN
71746
 
    IF (pFlag='') THEN
71747
 
      _flag := 'CHECK';
71748
 
    ELSE
71749
 
      _flag := COALESCE(pFlag,'CHECK');
71750
 
    END IF;
71751
 
  ELSE
71752
 
        RAISE EXCEPTION 'Invalid Flag (%). Valid flags are CHECK, CHANGEONE or CHANGEALL', pFlag;
71753
 
  END IF;
71754
 
 
71755
 
  _notes := COALESCE(pNotes,'');
71756
 
  
71757
 
  --If there is nothing here, get out
71758
 
  IF ( (pNumber = '' OR pNumber IS NULL)
71759
 
    AND (pAddr1 = '' OR pAddr1 IS NULL)
71760
 
    AND (pAddr2 = '' OR pAddr2 IS NULL)
71761
 
    AND (pAddr3 = '' OR pAddr3 IS NULL)
71762
 
    AND (pCity = '' OR pCity IS NULL)
71763
 
    AND (pState = '' OR pState IS NULL)
71764
 
    AND (pPostalCode = '' OR pPostalCode IS NULL)
71765
 
    AND (pCountry = '' OR pCountry IS NULL) ) THEN
71766
 
    RETURN NULL;
71767
 
  
71768
 
  END IF;
71769
 
  
71770
 
  _addrId := COALESCE(pAddrId,-1);
71771
 
 
71772
 
  --If we have an ID see if anything has changed, if not get out
71773
 
  IF (_addrId >= 0) THEN
71774
 
    SELECT * FROM addr INTO _p
71775
 
    WHERE ((pAddrId=addr_id)
71776
 
    AND (COALESCE(pNumber,addr_number)=addr_number)
71777
 
    AND (COALESCE(pAddr1, '')=COALESCE(addr_line1, ''))
71778
 
    AND (COALESCE(pAddr2, '')=COALESCE(addr_line2, ''))
71779
 
    AND (COALESCE(pAddr3, '')=COALESCE(addr_line3, ''))
71780
 
    AND (COALESCE(pCity, '')=COALESCE(addr_city, ''))
71781
 
    AND (COALESCE(pState, '')=COALESCE(addr_state, ''))
71782
 
    AND (COALESCE(pPostalCode, '')=COALESCE(addr_postalcode, ''))
71783
 
    AND (COALESCE(pCountry, '')=COALESCE(addr_country, ''))
71784
 
    AND (pActive=addr_active)
71785
 
    AND (_notes=COALESCE(addr_notes,'')));
71786
 
    IF (FOUND) THEN
71787
 
      RETURN _addrId;
71788
 
    END IF;
71789
 
  END IF;
71790
 
 
71791
 
  --Check to see if duplicate address exists
71792
 
 
71793
 
    SELECT addr_id, addr_notes INTO _p
71794
 
    FROM addr 
71795
 
    WHERE ((_addrId <> addr_id)
71796
 
    AND  (COALESCE(UPPER(addr_line1),'') = COALESCE(UPPER(pAddr1),''))
71797
 
    AND  (COALESCE(UPPER(addr_line2),'') = COALESCE(UPPER(pAddr2),''))
71798
 
    AND  (COALESCE(UPPER(addr_line3),'') = COALESCE(UPPER(pAddr3),''))
71799
 
    AND  (COALESCE(UPPER(addr_city),'') = COALESCE(UPPER(pCity),''))
71800
 
    AND  (COALESCE(UPPER(addr_state),'') = COALESCE(UPPER(pState),''))
71801
 
    AND  (COALESCE(UPPER(addr_postalcode),'') = COALESCE(UPPER(pPostalcode),''))
71802
 
    AND  (COALESCE(UPPER(addr_country),'') = COALESCE(UPPER(pCountry),'')));
71803
 
    IF (FOUND) THEN
71804
 
        --Note:  To prevent overwriting of existing notes, the application
71805
 
        --needs to load any existing notes for a matching address before altering them.
71806
 
        IF (_notes <> _p.addr_notes) THEN
71807
 
                UPDATE addr 
71808
 
                SET addr_notes=addr_notes || '
71809
 
' || _notes
71810
 
                WHERE addr_id=_p.addr_id;
71811
 
        END IF;
71812
 
        RETURN _p.addr_id;  --A matching address exits
71813
 
    END IF;
71814
 
 
71815
 
  IF (_addrId < 0) THEN
71816
 
    _flag := 'CHANGEONE';
71817
 
  END IF;
71818
 
 
71819
 
  IF (_flag = 'CHECK') THEN
71820
 
    IF addrUseCount(_addrId) > 1 THEN
71821
 
      RETURN -2;
71822
 
    ELSIF (SELECT COUNT(addr_id)=0 FROM addr WHERE (addr_id=_addrId)) THEN
71823
 
      _flag := 'CHANGEONE';
71824
 
    ELSE
71825
 
      _flag := 'CHANGEALL';
71826
 
    END IF;
71827
 
  END IF;
71828
 
 
71829
 
  IF (_flag = 'CHANGEALL') THEN
71830
 
    _addrNumber := pNumber;
71831
 
    IF (_addrNumber IS NULL) THEN
71832
 
      SELECT addr_number INTO _addrNumber
71833
 
        FROM addr
71834
 
       WHERE(addr_id = _addrId);
71835
 
      IF (_addrNumber IS NULL) THEN
71836
 
        _addrNumber := fetchNextNumber('AddressNumber');
71837
 
      END IF;
71838
 
    END IF;
71839
 
   
71840
 
    UPDATE addr SET
71841
 
      addr_line1 = pAddr1, addr_line2 = pAddr2, addr_line3 = pAddr3,
71842
 
      addr_city = pCity, addr_state = pState,
71843
 
      addr_postalcode = pPostalcode, addr_country = pCountry,
71844
 
      addr_active = pActive, addr_notes = pNotes
71845
 
    WHERE addr_id = _addrId;
71846
 
    RETURN _addrId;
71847
 
 
71848
 
  ELSE
71849
 
    SELECT NEXTVAL('addr_addr_id_seq') INTO _addrId;
71850
 
 
71851
 
    IF (_flag = 'CHANGEONE') THEN
71852
 
      _addrNumber := fetchNextNumber('AddressNumber');
71853
 
    ELSE
71854
 
      _addrNumber := COALESCE(pNumber::text,fetchNextNumber('AddressNumber'));
71855
 
    END IF;
71856
 
 
71857
 
    INSERT INTO addr ( addr_id, addr_number,
71858
 
    addr_line1, addr_line2, addr_line3, 
71859
 
    addr_city, addr_state, addr_postalcode, addr_country, 
71860
 
    addr_active, addr_notes  
71861
 
    ) VALUES ( _addrId, _addrNumber,
71862
 
    pAddr1, pAddr2, pAddr3, 
71863
 
    pCity, pState, pPostalcode, pCountry,
71864
 
    pActive, _notes);
71865
 
    RETURN _addrId;
71866
 
        
71867
 
  END IF;
71868
 
END;
71869
 
$_$;
71870
 
 
71871
 
 
71872
 
ALTER FUNCTION public.saveaddr(integer, text, text, text, text, text, text, text, text, boolean, text, text) OWNER TO admin;
71873
 
 
71874
 
--
71875
 
--
71876
 
 
71877
 
CREATE FUNCTION savealarm(integer, text, date, time without time zone, integer, text, boolean, text, boolean, text, boolean, text, text, integer, text) RETURNS integer
71878
 
    LANGUAGE plpgsql
71879
 
    AS $_$
71880
 
DECLARE
71881
 
  pAlarmId ALIAS FOR $1;
71882
 
  pAlarmNumber ALIAS FOR $2;
71883
 
  pDate ALIAS FOR $3;
71884
 
  pTime ALIAS FOR $4;
71885
 
  pOffset ALIAS FOR $5;
71886
 
  pQualifier ALIAS FOR $6;
71887
 
  pEvent ALIAS FOR $7;
71888
 
  pEventRecipient ALIAS FOR $8;
71889
 
  pEmail ALIAS FOR $9;
71890
 
  pEmailRecipient ALIAS FOR $10;
71891
 
  pSysmsg ALIAS FOR $11;
71892
 
  pSysmsgRecipient ALIAS FOR $12;
71893
 
  pSource ALIAS FOR $13;
71894
 
  pSourceId ALIAS FOR $14;
71895
 
  pFlag ALIAS FOR $15;
71896
 
  _alarmId INTEGER;
71897
 
  _alarmNumber TEXT;
71898
 
  _alarmTime TIMESTAMP;
71899
 
  _alarmInterval INTERVAL;
71900
 
  _alarmTrigger TIMESTAMP;
71901
 
  _isNew BOOLEAN;
71902
 
  _flag TEXT;
71903
 
  _alarmCount INTEGER := 0;
71904
 
  _debug BOOLEAN := false;
71905
 
 
71906
 
BEGIN
71907
 
  IF (_debug) THEN
71908
 
    RAISE NOTICE 'pAlarmId = %', pAlarmId;
71909
 
    RAISE NOTICE 'pAlarmNumber = %', pAlarmNumber;
71910
 
    RAISE NOTICE 'pDate = %', pDate;
71911
 
    RAISE NOTICE 'pTime = %', pTime;
71912
 
    RAISE NOTICE 'pOffset = %', pOffset;
71913
 
    RAISE NOTICE 'pQualifier = %', pQualifier;
71914
 
    RAISE NOTICE 'pEvent = %', pEvent;
71915
 
    RAISE NOTICE 'pEventRecipient = %', pEventRecipient;
71916
 
    RAISE NOTICE 'pEmail = %', pEmail;
71917
 
    RAISE NOTICE 'pEmailRecipient = %', pEmailRecipient;
71918
 
    RAISE NOTICE 'pSysmsg = %', pSysmsg;
71919
 
    RAISE NOTICE 'pSysmsgRecipient = %', pSysmsgRecipient;
71920
 
    RAISE NOTICE 'pSource = %', pSource;
71921
 
    RAISE NOTICE 'pSourceId = %', pSourceId;
71922
 
    RAISE NOTICE 'pFlag = %', pFlag;
71923
 
  END IF;
71924
 
  --Validate
71925
 
  IF ((pFlag IS NULL) OR (pFlag = '') OR (pFlag = 'CHECK') OR (pFlag = 'CHANGEONE') OR (pFlag = 'CHANGEALL')) THEN
71926
 
    IF (pFlag='') THEN
71927
 
      _flag := 'CHECK';
71928
 
    ELSE
71929
 
      _flag := COALESCE(pFlag,'CHECK');
71930
 
    END IF;
71931
 
  ELSE
71932
 
        RAISE EXCEPTION 'Invalid Flag (%). Valid flags are CHECK, CHANGEONE or CHANGEALL', pFlag;
71933
 
  END IF;
71934
 
  
71935
 
  --If there is nothing here get out
71936
 
  IF ( (pAlarmId IS NULL OR pAlarmId = -1)
71937
 
        AND (pOffset IS NULL)
71938
 
        AND (pSourceId IS NULL)
71939
 
        AND (COALESCE(pQualifier, '') = '')
71940
 
        AND (COALESCE(pEventRecipient, '') = '')
71941
 
        AND (COALESCE(pEmailRecipient, '') = '')
71942
 
        AND (COALESCE(pSysmsgRecipient, '') = '')
71943
 
        AND (COALESCE(pSource, '') = '') ) THEN
71944
 
        
71945
 
        RETURN NULL;
71946
 
 
71947
 
  END IF;
71948
 
  
71949
 
  IF (pAlarmId IS NULL OR pAlarmId = -1) THEN 
71950
 
    _isNew := true;
71951
 
    _alarmId := nextval('alarm_alarm_id_seq');
71952
 
    _alarmNumber := fetchNextNumber('AlarmNumber');
71953
 
  ELSE
71954
 
    SELECT COUNT(alarm_id) INTO _alarmCount
71955
 
      FROM alarm
71956
 
      WHERE ((alarm_id=pAlarmId)
71957
 
      AND (alarm_source=pSource)
71958
 
      AND (alarm_source_id=pSourceId));
71959
 
 
71960
 
    -- ask whether new or update if name changes
71961
 
    -- but only if this isn't a new record with a pre-allocated id
71962
 
    IF (_alarmCount < 1 AND _flag = 'CHECK') THEN
71963
 
      IF (EXISTS(SELECT alarm_id
71964
 
                 FROM alarm
71965
 
                 WHERE (alarm_id=pAlarmId))) THEN
71966
 
        RETURN -10;
71967
 
      ELSE
71968
 
        _isNew := true;
71969
 
        _alarmNumber := fetchNextNumber('AlarmNumber');
71970
 
      END IF;
71971
 
    ELSIF (_flag = 'CHANGEONE') THEN
71972
 
      _isNew := true;
71973
 
      _alarmId := nextval('alarm_alarm_id_seq');
71974
 
      _alarmNumber := fetchNextNumber('AlarmNumber');
71975
 
    END IF;
71976
 
  END IF;
71977
 
 
71978
 
  _alarmNumber := COALESCE(_alarmNumber,pAlarmNumber,fetchNextNumber('AlarmNumber'));
71979
 
 
71980
 
  _alarmTime := COALESCE(pDate, CURRENT_DATE) + COALESCE(pTime, CURRENT_TIME);
71981
 
  IF (COALESCE(pOffset, 0) > 0) THEN
71982
 
    _alarmInterval := CASE WHEN (pQualifier IN ('MB', 'MA')) THEN CAST(pOffset AS TEXT) || ' minutes'
71983
 
                           WHEN (pQualifier IN ('HB', 'HA')) THEN CAST(pOffset AS TEXT) || ' hours'
71984
 
                           WHEN (pQualifier IN ('DB', 'DA')) THEN CAST(pOffset AS TEXT) || ' days'
71985
 
                           ELSE ''
71986
 
                     END;
71987
 
    _alarmTrigger := CASE WHEN (pQualifier IN ('MB', 'HB', 'DB')) THEN _alarmTime - _alarmInterval 
71988
 
                          WHEN (pQualifier IN ('MA', 'HA', 'DA')) THEN _alarmTime + _alarmInterval
71989
 
                          ELSE _alarmTime
71990
 
                     END; 
71991
 
  ELSE
71992
 
    _alarmTrigger := _alarmTime;
71993
 
  END IF;
71994
 
 
71995
 
  IF (_isNew) THEN
71996
 
    _alarmId := COALESCE(_alarmId,pAlarmId,nextval('alarm_alarm_id_seq'));
71997
 
 
71998
 
    INSERT INTO alarm (
71999
 
      alarm_id,alarm_number,
72000
 
      alarm_event, alarm_email, alarm_sysmsg, alarm_trigger,
72001
 
      alarm_time, alarm_time_offset, alarm_time_qualifier,
72002
 
      alarm_creator, alarm_event_recipient, alarm_email_recipient, alarm_sysmsg_recipient,
72003
 
      alarm_source, alarm_source_id )
72004
 
    VALUES (
72005
 
      _alarmId, _alarmNumber,
72006
 
      pEvent, pEmail, pSysmsg, _alarmTrigger,
72007
 
      _alarmTime, pOffset, pQualifier,
72008
 
      getEffectiveXtUser(), pEventRecipient, pEmailRecipient, pSysmsgRecipient,
72009
 
      pSource, pSourceId );
72010
 
 
72011
 
    RETURN _alarmId;
72012
 
 
72013
 
  ELSE
72014
 
    UPDATE alarm SET
72015
 
      alarm_number=_alarmNumber,
72016
 
      alarm_event=COALESCE(pEvent, alarm_event),
72017
 
      alarm_email=COALESCE(pEmail, alarm_event),
72018
 
      alarm_sysmsg=COALESCE(pSysmsg, alarm_event),
72019
 
      alarm_trigger=_alarmTrigger,
72020
 
      alarm_time=_alarmTime,
72021
 
      alarm_time_offset=COALESCE(pOffset, alarm_time_offset),
72022
 
      alarm_time_qualifier=COALESCE(pQualifier, alarm_time_qualifier),
72023
 
      alarm_event_recipient=COALESCE(pEventRecipient, alarm_event_recipient),
72024
 
      alarm_email_recipient=COALESCE(pEmailRecipient, alarm_email_recipient),
72025
 
      alarm_sysmsg_recipient=COALESCE(pSysmsgRecipient, alarm_sysmsg_recipient)
72026
 
    WHERE (alarm_id=pAlarmId);
72027
 
    
72028
 
    RETURN pAlarmId;
72029
 
 
72030
 
  END IF;
72031
 
END;
72032
 
$_$;
72033
 
 
72034
 
 
72035
 
ALTER FUNCTION public.savealarm(integer, text, date, time without time zone, integer, text, boolean, text, boolean, text, boolean, text, text, integer, text) OWNER TO admin;
72036
 
 
72037
 
--
72038
 
--
72039
 
 
72040
 
CREATE FUNCTION savebomhead(integer, text, date, text, numeric, numeric) RETURNS integer
72041
 
    LANGUAGE plpgsql
72042
 
    AS $_$
72043
 
DECLARE
72044
 
  pItemid ALIAS FOR $1;
72045
 
  pRevision ALIAS FOR $2;
72046
 
  pRevisionDate ALIAS FOR $3;
72047
 
  pDocumentNumber ALIAS FOR $4;
72048
 
  pBatchSize ALIAS FOR $5;
72049
 
  pRequiredQtyPer ALIAS FOR $6;
72050
 
  _seq INTEGER;
72051
 
  _p RECORD;
72052
 
  _revid INTEGER;
72053
 
  
72054
 
BEGIN
72055
 
 
72056
 
  IF (NOT fetchMetricBool('RevControl')) THEN -- Deal with BOM if Rev Control Turned off
72057
 
    SELECT bomhead_id INTO _seq
72058
 
    FROM bomhead 
72059
 
    WHERE (bomhead_item_id=pItemid);
72060
 
 
72061
 
    IF (NOT FOUND) THEN  -- No bomhead exists
72062
 
      _seq := NEXTVAL('bomhead_bomhead_id_seq');
72063
 
      
72064
 
      INSERT INTO bomhead 
72065
 
        (bomhead_id,bomhead_item_id,bomhead_docnum,bomhead_revision,
72066
 
        bomhead_revisiondate,bomhead_batchsize,bomhead_requiredqtyper,bomhead_rev_id)
72067
 
        VALUES 
72068
 
        (_seq,pItemid, pDocumentNumber, pRevision, pRevisionDate, pBatchSize, pRequiredQtyPer,-1);   
72069
 
    ELSE
72070
 
      UPDATE bomhead SET
72071
 
        bomhead_revision        = pRevision,
72072
 
        bomhead_revisiondate    = pRevisionDate,
72073
 
        bomhead_docnum          = pDocumentNumber,
72074
 
        bomhead_batchsize       = pBatchSize,
72075
 
        bomhead_requiredqtyper = pRequiredQtyPer
72076
 
      WHERE (bomhead_id=_seq);
72077
 
    END IF;
72078
 
    
72079
 
    RETURN _seq;
72080
 
  ELSE  -- Deal with Revision Control
72081
 
    IF (COALESCE(pRevision,'') = '' AND getActiveRevId('BOM',pItemid) != -1) THEN 
72082
 
        RAISE EXCEPTION 'Revision Control records exist for item.  You must provide a new or existing revision number.';
72083
 
    END IF;
72084
 
    
72085
 
    SELECT * INTO _p
72086
 
    FROM bomhead
72087
 
      LEFT OUTER JOIN rev ON (bomhead_rev_id=rev_id),
72088
 
      item
72089
 
    WHERE ((bomhead_item_id=pItemid)
72090
 
    AND (COALESCE(bomhead_revision,'')=COALESCE(pRevision,''))
72091
 
    AND (bomhead_item_id=item_id));
72092
 
 
72093
 
    IF (NOT FOUND) THEN  -- This is a new bomhead record
72094
 
      IF LENGTH(pRevision) > 0 THEN  -- We need to create a revision record   
72095
 
        SELECT createbomrev(pItemid, pRevision) INTO _revid;
72096
 
        
72097
 
        UPDATE bomhead SET
72098
 
          bomhead_revisiondate          = pRevisiondate,
72099
 
          bomhead_docnum                = pDocumentNumber,
72100
 
          bomhead_batchsize             = pBatchsize,
72101
 
          bomhead_requiredqtyper        = pRequiredqtyper
72102
 
        WHERE (bomhead_rev_id=_revid);
72103
 
        
72104
 
        SELECT bomhead_id INTO _seq
72105
 
        FROM bomhead
72106
 
        WHERE (bomhead_rev_id=_revid);
72107
 
        
72108
 
        RETURN _seq;      
72109
 
      ELSE  -- Just create a regular bom header record
72110
 
       _seq := NEXTVAL('bomhead_bomhead_id_seq');
72111
 
       
72112
 
       INSERT INTO bomhead 
72113
 
        (bomhead_id,bomhead_item_id,bomhead_docnum,bomhead_revision,
72114
 
        bomhead_revisiondate,bomhead_batchsize,bomhead_requiredqtyper,bomhead_rev_id)
72115
 
        VALUES 
72116
 
        (_seq,pItemid, pDocumentNumber, pRevision, pRevisionDate, pBatchSize, pRequiredQtyPer,-1);
72117
 
        
72118
 
        RETURN _seq;      
72119
 
        
72120
 
      END IF;
72121
 
    ELSE  -- We need to update a record
72122
 
      IF (_p.rev_status = 'I') THEN
72123
 
        RAISE EXCEPTION 'Revision % for % is inactive.  Update not allowed.', _p.rev_number, _p.item_number;
72124
 
 
72125
 
      ELSIF (COALESCE(pRevision,'') = COALESCE(_p.bomhead_revision,'')) THEN  -- No change, just update
72126
 
        UPDATE bomhead SET
72127
 
          bomhead_revisiondate          = pRevisiondate,
72128
 
          bomhead_docnum                = pDocumentNumber,
72129
 
          bomhead_batchsize             = pBatchSize,
72130
 
          bomhead_requiredqtyper        = pRequiredqtyper
72131
 
        WHERE (bomhead_id=_p.bomhead_id);
72132
 
 
72133
 
        RETURN _p.bomhead_id;
72134
 
        
72135
 
      ELSE -- Need a new revision
72136
 
        SELECT createbomrev(pItemid, pRevision) INTO _revid;
72137
 
        
72138
 
        UPDATE bomhead SET
72139
 
          bomhead_revisiondate          = pRevisiondate,
72140
 
          bomhead_docnum                = pDocumentNumber,
72141
 
          bomhead_batchsize             = pBatchSize,
72142
 
          bomhead_requiredqtyper        = pRequiredqtyper
72143
 
        WHERE (bomhead_rev_id=_revid);
72144
 
 
72145
 
        SELECT bomhead_id INTO _seq
72146
 
        FROM bomhead
72147
 
        WHERE (bomhead_rev_id=_revid);
72148
 
        
72149
 
        RETURN _seq;
72150
 
      END IF;
72151
 
    END IF;
72152
 
  END IF;
72153
 
 
72154
 
  RETURN _seq;
72155
 
 
72156
 
END;
72157
 
$_$;
72158
 
 
72159
 
 
72160
 
ALTER FUNCTION public.savebomhead(integer, text, date, text, numeric, numeric) OWNER TO admin;
72161
 
 
72162
 
--
72163
 
--
72164
 
 
72165
 
CREATE FUNCTION savecntct(pcntctid integer, pcontactnumber text, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, ptitle text, pflag text) RETURNS integer
72166
 
    LANGUAGE plpgsql
72167
 
    AS $$
72168
 
DECLARE
72169
 
  _returnVal INTEGER;
72170
 
 
72171
 
BEGIN
72172
 
  
72173
 
  SELECT saveCntct(pCntctId,pContactNumber,NULL,pAddrId,pHonorific,pFirstName,pMiddleName,pLastName,pSuffix,NULL,
72174
 
        NULL,pPhone,pPhone2,pFax,pEmail,pWebAddr,NULL,pTitle,pFlag, NULL) INTO _returnVal;
72175
 
  
72176
 
  RETURN _returnVal;
72177
 
 
72178
 
END;
72179
 
$$;
72180
 
 
72181
 
 
72182
 
ALTER FUNCTION public.savecntct(pcntctid integer, pcontactnumber text, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, ptitle text, pflag text) OWNER TO admin;
72183
 
 
72184
 
--
72185
 
--
72186
 
 
72187
 
CREATE FUNCTION savecntct(pcntctid integer, pcontactnumber text, pcrmacctid integer, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pinitials text, pactive boolean, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, pnotes text, ptitle text, pflag text) RETURNS integer
72188
 
    LANGUAGE plpgsql
72189
 
    AS $$
72190
 
DECLARE
72191
 
  _returnVal INTEGER;
72192
 
 
72193
 
BEGIN
72194
 
  
72195
 
  SELECT saveCntct( pCntctId, pContactNumber, pCrmAcctId, pAddrId, pHonorific, pFirstName, pMiddleName, pLastName, pSuffix, pInitials, 
72196
 
        pActive, pPhone, pPhone2, pFax, pEmail, pWebAddr, pNotes, pTitle, pFlag, NULL) INTO _returnVal;
72197
 
  RETURN _returnVal;
72198
 
 
72199
 
END;
72200
 
$$;
72201
 
 
72202
 
 
72203
 
ALTER FUNCTION public.savecntct(pcntctid integer, pcontactnumber text, pcrmacctid integer, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pinitials text, pactive boolean, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, pnotes text, ptitle text, pflag text) OWNER TO admin;
72204
 
 
72205
 
--
72206
 
--
72207
 
 
72208
 
CREATE FUNCTION savecntct(pcntctid integer, pcontactnumber text, pcrmacctid integer, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pinitials text, pactive boolean, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, pnotes text, ptitle text, pflag text, pownerusername text) RETURNS integer
72209
 
    LANGUAGE plpgsql
72210
 
    AS $$
72211
 
DECLARE
72212
 
  _cntctId INTEGER;
72213
 
  _cntctNumber TEXT;
72214
 
  _isNew BOOLEAN;
72215
 
  _flag TEXT;
72216
 
  _contactCount INTEGER := 0;
72217
 
 
72218
 
BEGIN
72219
 
  --Validate
72220
 
  IF ((pFlag IS NULL) OR (pFlag = '') OR (pFlag = 'CHECK') OR (pFlag = 'CHANGEONE') OR (pFlag = 'CHANGEALL')) THEN
72221
 
    IF (pFlag='') THEN
72222
 
      _flag := 'CHECK';
72223
 
    ELSE
72224
 
      _flag := COALESCE(pFlag,'CHECK');
72225
 
    END IF;
72226
 
  ELSE
72227
 
        RAISE EXCEPTION 'Invalid Flag (%). Valid flags are CHECK, CHANGEONE or CHANGEALL', pFlag;
72228
 
  END IF;
72229
 
  
72230
 
  --If there is nothing here get out
72231
 
  IF ( (pCntctId IS NULL OR pCntctId = -1)
72232
 
        AND (pAddrId IS NULL)
72233
 
        AND (COALESCE(pFirstName, '') = '')
72234
 
        AND (COALESCE(pMiddleName, '') = '')
72235
 
        AND (COALESCE(pLastName, '') = '')
72236
 
        AND (COALESCE(pSuffix, '') = '')
72237
 
        AND (COALESCE(pHonorific, '') = '')
72238
 
        AND (COALESCE(pInitials, '') = '')
72239
 
        AND (COALESCE(pPhone, '') = '')
72240
 
        AND (COALESCE(pPhone2, '') = '')
72241
 
        AND (COALESCE(pFax, '') = '')
72242
 
        AND (COALESCE(pEmail, '') = '')
72243
 
        AND (COALESCE(pWebAddr, '') = '')
72244
 
        AND (COALESCE(pNotes, '') = '')
72245
 
        AND (COALESCE(pTitle, '') = '') ) THEN
72246
 
        
72247
 
        RETURN NULL;
72248
 
 
72249
 
  END IF;
72250
 
  
72251
 
  IF (pCntctId IS NULL OR pCntctId = -1) THEN 
72252
 
    _isNew := true;
72253
 
    _cntctId := nextval('cntct_cntct_id_seq');
72254
 
    _cntctNumber := COALESCE(pContactNumber,fetchNextNumber('ContactNumber'));
72255
 
  ELSE
72256
 
    SELECT COUNT(cntct_id) INTO _contactCount
72257
 
      FROM cntct
72258
 
      WHERE ((cntct_id=pCntctId)
72259
 
      AND (cntct_first_name=pFirstName)
72260
 
      AND (cntct_last_name=pLastName));
72261
 
 
72262
 
    -- ask whether new or update if name changes
72263
 
    -- but only if this isn't a new record with a pre-allocated id
72264
 
    IF (_contactCount < 1 AND _flag = 'CHECK') THEN
72265
 
      IF (EXISTS(SELECT cntct_id
72266
 
                 FROM cntct
72267
 
                 WHERE (cntct_id=pCntctId))) THEN
72268
 
        RETURN -10;
72269
 
      ELSE
72270
 
        _isNew := true;
72271
 
        _cntctNumber := fetchNextNumber('ContactNumber');
72272
 
      END IF;
72273
 
    ELSIF (_flag = 'CHANGEONE') THEN
72274
 
      _isNew := true;
72275
 
      _cntctId := nextval('cntct_cntct_id_seq');
72276
 
      _cntctNumber := fetchNextNumber('ContactNumber');
72277
 
    ELSIF (_flag = 'CHANGEALL') THEN
72278
 
      _isNew := false;
72279
 
    END IF;
72280
 
  END IF;
72281
 
 
72282
 
  IF (pContactNumber = '') THEN
72283
 
    _cntctNumber := fetchNextNumber('ContactNumber');
72284
 
  ELSE
72285
 
    _cntctNumber := COALESCE(_cntctNumber,pContactNumber,fetchNextNumber('ContactNumber'));
72286
 
  END IF;
72287
 
 
72288
 
  IF (_isNew) THEN
72289
 
    _cntctId := COALESCE(_cntctId,pCntctId,nextval('cntct_cntct_id_seq'));
72290
 
 
72291
 
    INSERT INTO cntct (
72292
 
      cntct_id,cntct_number,
72293
 
      cntct_crmacct_id,cntct_addr_id,cntct_first_name,
72294
 
      cntct_last_name,cntct_honorific,cntct_initials,
72295
 
      cntct_active,cntct_phone,cntct_phone2,
72296
 
      cntct_fax,cntct_email,cntct_webaddr,
72297
 
      cntct_notes,cntct_title,cntct_middle,cntct_suffix, cntct_owner_username ) 
72298
 
    VALUES (
72299
 
      _cntctId, COALESCE(_cntctNumber,fetchNextNumber('ContactNumber')) ,pCrmAcctId,pAddrId,
72300
 
      pFirstName,pLastName,pHonorific,
72301
 
      pInitials,COALESCE(pActive,true),pPhone,pPhone2,pFax,
72302
 
      pEmail,pWebAddr,pNotes,pTitle,pMiddleName,pSuffix,pOwnerUsername );
72303
 
 
72304
 
    RETURN _cntctId;
72305
 
 
72306
 
  ELSE
72307
 
    UPDATE cntct SET
72308
 
      cntct_number=COALESCE(_cntctNumber,fetchNextNumber('ContactNumber')),
72309
 
      cntct_crmacct_id=COALESCE(pCrmAcctId,cntct_crmacct_id),
72310
 
      cntct_addr_id=COALESCE(pAddrId,cntct_addr_id),
72311
 
      cntct_first_name=COALESCE(pFirstName,cntct_first_name),
72312
 
      cntct_last_name=COALESCE(pLastName,cntct_last_name),
72313
 
      cntct_honorific=COALESCE(pHonorific,cntct_honorific),
72314
 
      cntct_initials=COALESCE(pInitials,cntct_initials),
72315
 
      cntct_active=COALESCE(pActive,cntct_active),
72316
 
      cntct_phone=COALESCE(pPhone,cntct_phone),
72317
 
      cntct_phone2=COALESCE(pPhone2,cntct_phone2),
72318
 
      cntct_fax=COALESCE(pFax,cntct_fax),
72319
 
      cntct_email=COALESCE(pEmail,cntct_email),
72320
 
      cntct_webaddr=COALESCE(pWebAddr,cntct_webaddr),
72321
 
      cntct_notes=COALESCE(pNotes,cntct_notes),
72322
 
      cntct_title=COALESCE(pTitle,cntct_title),
72323
 
      cntct_middle=COALESCE(pMiddleName,cntct_middle),
72324
 
      cntct_suffix=COALESCE(pSuffix,cntct_suffix),
72325
 
      cntct_owner_username=COALESCE(pOwnerUsername, cntct_owner_username) 
72326
 
    WHERE (cntct_id=pCntctId);
72327
 
    
72328
 
    RETURN pCntctId;
72329
 
 
72330
 
  END IF;
72331
 
END;
72332
 
$$;
72333
 
 
72334
 
 
72335
 
ALTER FUNCTION public.savecntct(pcntctid integer, pcontactnumber text, pcrmacctid integer, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pinitials text, pactive boolean, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, pnotes text, ptitle text, pflag text, pownerusername text) OWNER TO admin;
72336
 
 
72337
 
--
72338
 
--
72339
 
 
72340
 
CREATE FUNCTION saveimageass(text, integer, character, integer) RETURNS integer
72341
 
    LANGUAGE plpgsql
72342
 
    AS $_$
72343
 
DECLARE
72344
 
  pSource       ALIAS FOR $1;
72345
 
  pSourceId     ALIAS FOR $2;
72346
 
  pPurpose      ALIAS FOR $3;
72347
 
  pImageid      ALIAS FOR $4;
72348
 
  _imageassId INTEGER = 0;
72349
 
 
72350
 
BEGIN
72351
 
 
72352
 
  SELECT imageass_id INTO _imageassId
72353
 
  FROM imageass
72354
 
  WHERE ((imageass_source_id=pSourceId)
72355
 
  AND (imageass_source=pSource)
72356
 
  AND (imageass_image_id=pImageId)
72357
 
  AND (imageass_purpose=pPurpose));
72358
 
 
72359
 
  IF (FOUND) THEN
72360
 
    RETURN _imageassId;
72361
 
  END IF;
72362
 
  
72363
 
  IF (pSource = 'I' AND pPurpose != 'M') THEN
72364
 
    SELECT imageass_id INTO _imageassId
72365
 
    FROM imageass
72366
 
    WHERE ((imageass_source_id=pSourceId)
72367
 
    AND (imageass_source=pSource)
72368
 
    AND (imageass_purpose=pPurpose));
72369
 
  END IF;
72370
 
 
72371
 
  IF (_imageassId > 0) THEN
72372
 
    UPDATE imageass SET
72373
 
      imageass_image_id=pImageId
72374
 
    WHERE (imageass_id=_imageassId);
72375
 
  ELSE
72376
 
    _imageassId := NEXTVAL('imageass_imageass_id_seq');
72377
 
    INSERT INTO imageass VALUES (_imageassId,pSourceId,pSource,pImageid,CASE WHEN pSource='I' THEN pPurpose ELSE 'M' END);
72378
 
  END IF;
72379
 
  
72380
 
  RETURN _imageassId;
72381
 
END;
72382
 
$_$;
72383
 
 
72384
 
 
72385
 
ALTER FUNCTION public.saveimageass(text, integer, character, integer) OWNER TO admin;
72386
 
 
72387
 
--
72388
 
--
72389
 
 
72390
 
CREATE FUNCTION saveipsitem(integer, integer, integer, numeric, numeric, integer, integer) RETURNS integer
72391
 
    LANGUAGE plpgsql
72392
 
    AS $_$
72393
 
DECLARE
72394
 
  pIpsItemId    ALIAS FOR $1;
72395
 
  pIpsHeadId    ALIAS FOR $2;
72396
 
  pItemId       ALIAS FOR $3;
72397
 
  pQtyBreak     ALIAS FOR $4;
72398
 
  pPrice        ALIAS FOR $5;
72399
 
  pQtyUomId     ALIAS FOR $6;
72400
 
  pPriceUomId   ALIAS FOR $7;
72401
 
  _ipsitemid    INTEGER;
72402
 
  _new          BOOLEAN;
72403
 
BEGIN
72404
 
 
72405
 
  -- Validation
72406
 
  IF (SELECT COUNT(item_id)=0 FROM item WHERE (item_id=pItemId)) THEN
72407
 
    RAISE EXCEPTION 'You must provide a valid Item';
72408
 
  ELSIF (COALESCE(pQtyBreak,0) < 0) THEN
72409
 
    RAISE EXCEPTION 'Quantity can not be a negative value';
72410
 
  ELSIF (COALESCE(pPrice,0) < 0) THEN
72411
 
    RAISE EXCEPTION 'Price must be a negative value';
72412
 
  ELSIF ((pQtyUomId IS NOT NULL) AND (SELECT COUNT(item_id)=0 FROM
72413
 
        (SELECT item_id
72414
 
         FROM item
72415
 
         WHERE ((item_id=pItemId)
72416
 
           AND (item_inv_uom_id=pQtyUomId))
72417
 
         UNION
72418
 
         SELECT item_id
72419
 
         FROM item,itemuomconv,itemuom,uomtype
72420
 
         WHERE ((item_id=pItemId)
72421
 
           AND (itemuomconv_item_id=item_id)
72422
 
           AND (itemuomconv_from_uom_id=pQtyUomId)
72423
 
           AND (itemuom_itemuomconv_id=itemuomconv_id)
72424
 
           AND (itemuom_uomtype_id=uomtype_id)
72425
 
           AND (uomtype_name='Selling'))
72426
 
         UNION
72427
 
         SELECT item_id
72428
 
         FROM item,itemuomconv,itemuom,uomtype
72429
 
         WHERE ((item_id=pItemId)
72430
 
           AND (itemuomconv_item_id=item_id)
72431
 
           AND (itemuomconv_to_uom_id=pQtyUomId)
72432
 
           AND (itemuom_itemuomconv_id=itemuomconv_id)
72433
 
           AND (itemuom_uomtype_id=uomtype_id)
72434
 
           AND (uomtype_name='Selling'))) AS data)) THEN
72435
 
    RAISE EXCEPTION 'Qty UOM Must be a valid Selling UOM for the Item';
72436
 
  ELSIF ((pPriceUomId IS NOT NULL) AND (SELECT COUNT(item_id)=0 FROM
72437
 
        (SELECT item_id
72438
 
         FROM item
72439
 
         WHERE ((item_id=pItemId)
72440
 
           AND (item_inv_uom_id=pPriceUomId))
72441
 
         UNION
72442
 
         SELECT item_id
72443
 
         FROM item,itemuomconv,itemuom,uomtype
72444
 
         WHERE ((item_id=pItemId)
72445
 
           AND (itemuomconv_item_id=item_id)
72446
 
           AND (itemuomconv_from_uom_id=pPriceUomId)
72447
 
           AND (itemuom_itemuomconv_id=itemuomconv_id)
72448
 
           AND (itemuom_uomtype_id=uomtype_id)
72449
 
           AND (uomtype_name='Selling'))
72450
 
         UNION
72451
 
         SELECT item_id
72452
 
         FROM item,itemuomconv,itemuom,uomtype
72453
 
         WHERE ((item_id=pItemId)
72454
 
           AND (itemuomconv_item_id=item_id)
72455
 
           AND (itemuomconv_to_uom_id=pPriceUomId)
72456
 
           AND (itemuom_itemuomconv_id=itemuomconv_id)
72457
 
           AND (itemuom_uomtype_id=uomtype_id)
72458
 
           AND (uomtype_name='Selling'))) AS data)) THEN
72459
 
    RAISE EXCEPTION 'Price UOM Must be a valid Selling UOM for the Item';
72460
 
  END IF;
72461
 
 
72462
 
  _new := TRUE;
72463
 
 
72464
 
  IF (pIpsItemId IS NOT NULL) THEN
72465
 
    SELECT ipsitem_id INTO _ipsitemid
72466
 
    FROM ipsitem
72467
 
    WHERE (ipsitem_id=pIpsItemId);
72468
 
 
72469
 
    IF (FOUND) THEN
72470
 
      _new := FALSE;
72471
 
    ELSE
72472
 
      RAISE EXCEPTION 'Pricing Schedule Item not found.';
72473
 
    END IF;
72474
 
  ELSE
72475
 
    SELECT ipsitem_id INTO _ipsitemid
72476
 
    FROM ipsitem
72477
 
    WHERE ((ipsitem_ipshead_id  = pIpsheadId)
72478
 
      AND (ipsitem_item_id      = pItemId)
72479
 
      AND (ipsitem_qtybreak     = pQtyBreak)
72480
 
      AND (ipsitem_qty_uom_id = COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))) 
72481
 
      AND (ipsitem_price_uom_id =
72482
 
           CASE
72483
 
             WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN
72484
 
               COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))
72485
 
             ELSE
72486
 
               COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))
72487
 
           END));
72488
 
  END IF;
72489
 
  
72490
 
  IF (FOUND) THEN
72491
 
    _new := false;
72492
 
  ELSE
72493
 
    _ipsitemid := nextval('ipsitem_ipsitem_id_seq');
72494
 
  END IF;
72495
 
  
72496
 
  IF (_new) THEN
72497
 
    INSERT INTO ipsitem (
72498
 
      ipsitem_id,
72499
 
      ipsitem_ipshead_id, 
72500
 
      ipsitem_item_id, 
72501
 
      ipsitem_qtybreak, 
72502
 
      ipsitem_price, 
72503
 
      ipsitem_qty_uom_id, 
72504
 
      ipsitem_price_uom_id,
72505
 
      ipsitem_discntprcnt,
72506
 
      ipsitem_fixedamtdiscount) 
72507
 
    VALUES (
72508
 
      _ipsitemid,
72509
 
      pIpsheadId,
72510
 
      pItemId,
72511
 
      pQtyBreak, 
72512
 
      pPrice,
72513
 
      COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)), 
72514
 
      CASE
72515
 
        WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN
72516
 
          COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))
72517
 
        ELSE
72518
 
          COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))
72519
 
      END,
72520
 
      0.0,
72521
 
      0.0);
72522
 
  ELSE 
72523
 
    UPDATE ipsitem SET 
72524
 
      ipsitem_qtybreak = pQtyBreak, 
72525
 
      ipsitem_price = pPrice, 
72526
 
      ipsitem_qty_uom_id = COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)), 
72527
 
      ipsitem_price_uom_id =
72528
 
      CASE
72529
 
        WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN
72530
 
          COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))
72531
 
        ELSE
72532
 
          COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))
72533
 
      END
72534
 
    WHERE (ipsitem_id=_ipsitemid);
72535
 
   END IF;
72536
 
 
72537
 
   RETURN _ipsitemid;
72538
 
 
72539
 
END;
72540
 
$_$;
72541
 
 
72542
 
 
72543
 
ALTER FUNCTION public.saveipsitem(integer, integer, integer, numeric, numeric, integer, integer) OWNER TO admin;
72544
 
 
72545
 
--
72546
 
--
72547
 
 
72548
 
CREATE FUNCTION saveipsitem(pipsitemid integer, pipsheadid integer, pitemid integer, pqtybreak numeric, pprice numeric, pqtyuomid integer, ppriceuomid integer, ppercent numeric, pfixedamt numeric, ptype text) RETURNS integer
72549
 
    LANGUAGE plpgsql
72550
 
    AS $$
72551
 
DECLARE
72552
 
  _ipsitemid    INTEGER;
72553
 
  _new          BOOLEAN;
72554
 
BEGIN
72555
 
 
72556
 
  -- Validation
72557
 
  IF (SELECT COUNT(item_id)=0 FROM item WHERE (item_id=pItemId)) THEN
72558
 
    RAISE EXCEPTION 'You must provide a valid Item';
72559
 
  ELSIF (COALESCE(pQtyBreak,0) < 0) THEN
72560
 
    RAISE EXCEPTION 'Quantity can not be a negative value';
72561
 
  ELSIF (COALESCE(pPrice,0) < 0) THEN
72562
 
    RAISE EXCEPTION 'Price must be a negative value';
72563
 
  ELSIF ((pQtyUomId IS NOT NULL) AND (SELECT COUNT(item_id)=0 FROM
72564
 
        (SELECT item_id
72565
 
         FROM item
72566
 
         WHERE ((item_id=pItemId)
72567
 
           AND (item_inv_uom_id=pQtyUomId))
72568
 
         UNION
72569
 
         SELECT item_id
72570
 
         FROM item,itemuomconv,itemuom,uomtype
72571
 
         WHERE ((item_id=pItemId)
72572
 
           AND (itemuomconv_item_id=item_id)
72573
 
           AND (itemuomconv_from_uom_id=pQtyUomId)
72574
 
           AND (itemuom_itemuomconv_id=itemuomconv_id)
72575
 
           AND (itemuom_uomtype_id=uomtype_id)
72576
 
           AND (uomtype_name='Selling'))
72577
 
         UNION
72578
 
         SELECT item_id
72579
 
         FROM item,itemuomconv,itemuom,uomtype
72580
 
         WHERE ((item_id=pItemId)
72581
 
           AND (itemuomconv_item_id=item_id)
72582
 
           AND (itemuomconv_to_uom_id=pQtyUomId)
72583
 
           AND (itemuom_itemuomconv_id=itemuomconv_id)
72584
 
           AND (itemuom_uomtype_id=uomtype_id)
72585
 
           AND (uomtype_name='Selling'))) AS data)) THEN
72586
 
    RAISE EXCEPTION 'Qty UOM Must be a valid Selling UOM for the Item';
72587
 
  ELSIF ((pPriceUomId IS NOT NULL) AND (SELECT COUNT(item_id)=0 FROM
72588
 
        (SELECT item_id
72589
 
         FROM item
72590
 
         WHERE ((item_id=pItemId)
72591
 
           AND (item_inv_uom_id=pPriceUomId))
72592
 
         UNION
72593
 
         SELECT item_id
72594
 
         FROM item,itemuomconv,itemuom,uomtype
72595
 
         WHERE ((item_id=pItemId)
72596
 
           AND (itemuomconv_item_id=item_id)
72597
 
           AND (itemuomconv_from_uom_id=pPriceUomId)
72598
 
           AND (itemuom_itemuomconv_id=itemuomconv_id)
72599
 
           AND (itemuom_uomtype_id=uomtype_id)
72600
 
           AND (uomtype_name='Selling'))
72601
 
         UNION
72602
 
         SELECT item_id
72603
 
         FROM item,itemuomconv,itemuom,uomtype
72604
 
         WHERE ((item_id=pItemId)
72605
 
           AND (itemuomconv_item_id=item_id)
72606
 
           AND (itemuomconv_to_uom_id=pPriceUomId)
72607
 
           AND (itemuom_itemuomconv_id=itemuomconv_id)
72608
 
           AND (itemuom_uomtype_id=uomtype_id)
72609
 
           AND (uomtype_name='Selling'))) AS data)) THEN
72610
 
    RAISE EXCEPTION 'Price UOM Must be a valid Selling UOM for the Item';
72611
 
  END IF;
72612
 
 
72613
 
  _new := TRUE;
72614
 
 
72615
 
  IF (pIpsItemId IS NOT NULL) THEN
72616
 
    SELECT ipsitem_id INTO _ipsitemid
72617
 
    FROM ipsiteminfo
72618
 
    WHERE (ipsitem_id=pIpsItemId);
72619
 
 
72620
 
    IF (FOUND) THEN
72621
 
      _new := FALSE;
72622
 
    ELSE
72623
 
      RAISE EXCEPTION 'Pricing Schedule Item not found.';
72624
 
    END IF;
72625
 
  ELSE
72626
 
    SELECT ipsitem_id INTO _ipsitemid
72627
 
    FROM ipsiteminfo
72628
 
    WHERE ((ipsitem_ipshead_id  = pIpsheadId)
72629
 
      AND (ipsitem_item_id      = pItemId)
72630
 
      AND (ipsitem_qtybreak     = pQtyBreak)
72631
 
      AND (ipsitem_qty_uom_id = COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))) 
72632
 
      AND (ipsitem_price_uom_id =
72633
 
           CASE
72634
 
             WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN
72635
 
               COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))
72636
 
             ELSE
72637
 
               COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))
72638
 
           END));
72639
 
  END IF;
72640
 
  
72641
 
  IF (FOUND) THEN
72642
 
    _new := false;
72643
 
  END IF;
72644
 
  
72645
 
  IF (_new) THEN
72646
 
    INSERT INTO ipsiteminfo (
72647
 
      ipsitem_ipshead_id, 
72648
 
      ipsitem_item_id, 
72649
 
      ipsitem_qtybreak, 
72650
 
      ipsitem_price, 
72651
 
      ipsitem_qty_uom_id, 
72652
 
      ipsitem_price_uom_id,
72653
 
      ipsitem_discntprcnt,
72654
 
      ipsitem_fixedamtdiscount,
72655
 
      ipsitem_type) 
72656
 
    VALUES (
72657
 
      pIpsheadId,
72658
 
      pItemId,
72659
 
      pQtyBreak, 
72660
 
      pPrice,
72661
 
      COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)), 
72662
 
      CASE
72663
 
        WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN
72664
 
          COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))
72665
 
        ELSE
72666
 
          COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))
72667
 
      END,
72668
 
      pPercent,
72669
 
      pFixedAmt,
72670
 
      pType)
72671
 
    RETURNING ipsitem_id INTO _ipsitemid;
72672
 
  ELSE 
72673
 
    UPDATE ipsiteminfo SET 
72674
 
      ipsitem_qtybreak = pQtyBreak, 
72675
 
      ipsitem_price = pPrice, 
72676
 
      ipsitem_qty_uom_id = COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)), 
72677
 
      ipsitem_price_uom_id =
72678
 
      CASE
72679
 
        WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN
72680
 
          COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))
72681
 
        ELSE
72682
 
          COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))
72683
 
      END,
72684
 
      ipsitem_discntprcnt=pPercent,
72685
 
      ipsitem_fixedamtdiscount=pFixedAmt,
72686
 
      ipsitem_type=pType
72687
 
    WHERE (ipsitem_id=_ipsitemid);
72688
 
   END IF;
72689
 
 
72690
 
   RETURN _ipsitemid;
72691
 
 
72692
 
END;
72693
 
$$;
72694
 
 
72695
 
 
72696
 
ALTER FUNCTION public.saveipsitem(pipsitemid integer, pipsheadid integer, pitemid integer, pqtybreak numeric, pprice numeric, pqtyuomid integer, ppriceuomid integer, ppercent numeric, pfixedamt numeric, ptype text) OWNER TO admin;
72697
 
 
72698
 
--
72699
 
--
72700
 
 
72701
 
CREATE FUNCTION saveipsprodcat(integer, integer, integer, numeric, numeric) RETURNS integer
72702
 
    LANGUAGE plpgsql
72703
 
    AS $_$
72704
 
DECLARE
72705
 
  pIpsProdcatId ALIAS FOR $1;
72706
 
  pIpsHeadId    ALIAS FOR $2;
72707
 
  pProdCatId    ALIAS FOR $3;
72708
 
  pQtyBreak     ALIAS FOR $4;
72709
 
  pDiscount     ALIAS FOR $5;
72710
 
  _ipsprodcatid INTEGER;
72711
 
  _new          BOOLEAN;
72712
 
  
72713
 
BEGIN
72714
 
 
72715
 
  -- Validation
72716
 
  IF (SELECT COUNT(*)=0 FROM prodcat WHERE (prodcat_id=pProdcatId)) THEN
72717
 
    RAISE EXCEPTION 'You must provide a valid Product Category';
72718
 
  ELSIF (COALESCE(pQtyBreak,0) < 0) THEN
72719
 
    RAISE EXCEPTION 'Quantity can not be a negative value';
72720
 
  ELSIF (COALESCE(pDiscount,0) < 0) THEN
72721
 
    RAISE EXCEPTION 'Discount must be a negative value';
72722
 
  END IF;
72723
 
    
72724
 
  _new := TRUE;
72725
 
 
72726
 
  IF (pIpsProdcatId IS NOT NULL) THEN
72727
 
    SELECT ipsprodcat_id INTO _ipsprodcatid
72728
 
    FROM ipsprodcat
72729
 
    WHERE (ipsprodcat_id=pIpsprodcatId);
72730
 
 
72731
 
    IF (FOUND) THEN
72732
 
      _new := FALSE;
72733
 
    ELSE
72734
 
      RAISE EXCEPTION 'Pricing Schedule Product Category not found';
72735
 
    END IF;
72736
 
  ELSE
72737
 
    SELECT ipsprodcat_id INTO _ipsprodcatid
72738
 
    FROM ipsprodcat
72739
 
    WHERE ((ipsprodcat_ipshead_id=pIpsheadId)
72740
 
      AND (ipsprodcat_prodcat_id=pProdcatId)
72741
 
      AND (ipsprodcat_qtybreak=pQtyBreak));
72742
 
 
72743
 
    IF (FOUND) THEN
72744
 
      _new := false;
72745
 
    ELSE
72746
 
      _ipsprodcatid := nextval('ipsprodcat_ipsprodcat_id_seq');
72747
 
    END IF;
72748
 
  END IF;
72749
 
  
72750
 
  IF (_new) THEN
72751
 
    INSERT INTO ipsprodcat (
72752
 
      ipsprodcat_id,
72753
 
      ipsprodcat_ipshead_id, 
72754
 
      ipsprodcat_prodcat_id, 
72755
 
      ipsprodcat_qtybreak, 
72756
 
      ipsprodcat_discntprcnt) 
72757
 
    VALUES (
72758
 
      _ipsprodcatid,
72759
 
      pIpsheadId,
72760
 
      pProdcatId,
72761
 
      pQtyBreak, 
72762
 
      pDiscount * .01);
72763
 
  ELSE 
72764
 
    UPDATE ipsprodcat SET 
72765
 
      ipsprodcat_qtybreak = pQtyBreak, 
72766
 
      ipsprodcat_discntprcnt = pDiscount * .01
72767
 
    WHERE (ipsprodcat_id=_ipsprodcatid);
72768
 
  END IF;
72769
 
 
72770
 
  RETURN _ipsprodcatid;
72771
 
END;
72772
 
$_$;
72773
 
 
72774
 
 
72775
 
ALTER FUNCTION public.saveipsprodcat(integer, integer, integer, numeric, numeric) OWNER TO admin;
72776
 
 
72777
 
--
72778
 
--
72779
 
 
72780
 
CREATE FUNCTION saveipsprodcat(integer, integer, integer, numeric, numeric, numeric) RETURNS integer
72781
 
    LANGUAGE plpgsql
72782
 
    AS $_$
72783
 
DECLARE
72784
 
  pIpsProdcatId     ALIAS FOR $1;
72785
 
  pIpsHeadId        ALIAS FOR $2;
72786
 
  pProdCatId        ALIAS FOR $3;
72787
 
  pQtyBreak         ALIAS FOR $4;
72788
 
  pDiscount         ALIAS FOR $5;
72789
 
  pFixedAmtDiscount ALIAS FOR $6;
72790
 
  _ipsprodcatid INTEGER;
72791
 
  _new          BOOLEAN;
72792
 
  
72793
 
BEGIN
72794
 
 
72795
 
  -- Validation
72796
 
  IF (SELECT COUNT(*)=0 FROM prodcat WHERE (prodcat_id=pProdcatId)) THEN
72797
 
    RAISE EXCEPTION 'You must provide a valid Product Category';
72798
 
  ELSIF (COALESCE(pQtyBreak,0) < 0) THEN
72799
 
    RAISE EXCEPTION 'Quantity can not be a negative value';
72800
 
  ELSIF (COALESCE(pDiscount,0) < 0) THEN
72801
 
    RAISE EXCEPTION 'Discount must be a negative value';
72802
 
  END IF;
72803
 
    
72804
 
  _new := TRUE;
72805
 
 
72806
 
  IF (pIpsProdcatId IS NOT NULL) THEN
72807
 
    SELECT ipsprodcat_id INTO _ipsprodcatid
72808
 
    FROM ipsprodcat
72809
 
    WHERE (ipsprodcat_id=pIpsprodcatId);
72810
 
 
72811
 
    IF (FOUND) THEN
72812
 
      _new := FALSE;
72813
 
    ELSE
72814
 
      RAISE EXCEPTION 'Pricing Schedule Product Category not found';
72815
 
    END IF;
72816
 
  ELSE
72817
 
    SELECT ipsprodcat_id INTO _ipsprodcatid
72818
 
    FROM ipsprodcat
72819
 
    WHERE ((ipsprodcat_ipshead_id=pIpsheadId)
72820
 
      AND (ipsprodcat_prodcat_id=pProdcatId)
72821
 
      AND (ipsprodcat_qtybreak=pQtyBreak));
72822
 
 
72823
 
    IF (FOUND) THEN
72824
 
      _new := false;
72825
 
    ELSE
72826
 
      _ipsprodcatid := nextval('ipsprodcat_ipsprodcat_id_seq');
72827
 
    END IF;
72828
 
  END IF;
72829
 
  
72830
 
  IF (_new) THEN
72831
 
    INSERT INTO ipsprodcat (
72832
 
      ipsprodcat_id,
72833
 
      ipsprodcat_ipshead_id, 
72834
 
      ipsprodcat_prodcat_id, 
72835
 
      ipsprodcat_qtybreak, 
72836
 
      ipsprodcat_discntprcnt,
72837
 
      ipsprodcat_fixedamtdiscount)  
72838
 
    VALUES (
72839
 
      _ipsprodcatid,
72840
 
      pIpsheadId,
72841
 
      pProdcatId,
72842
 
      pQtyBreak, 
72843
 
      pDiscount * .01,
72844
 
      pFixedAmtDiscount);
72845
 
  ELSE 
72846
 
    UPDATE ipsprodcat SET 
72847
 
      ipsprodcat_qtybreak = pQtyBreak, 
72848
 
      ipsprodcat_discntprcnt = pDiscount * .01,
72849
 
      ipsprodcat_fixedamtdiscount = pFixedAmtDiscount 
72850
 
    WHERE (ipsprodcat_id=_ipsprodcatid);
72851
 
  END IF;
72852
 
 
72853
 
  RETURN _ipsprodcatid;
72854
 
END;
72855
 
$_$;
72856
 
 
72857
 
 
72858
 
ALTER FUNCTION public.saveipsprodcat(integer, integer, integer, numeric, numeric, numeric) OWNER TO admin;
72859
 
 
72860
 
--
72861
 
--
72862
 
 
72863
 
CREATE FUNCTION saveipsprodcat(pipsprodcatid integer, pipsheadid integer, pprodcatid integer, pqtybreak numeric, pdiscount numeric, pfixedamtdiscount numeric, ptype text) RETURNS integer
72864
 
    LANGUAGE plpgsql
72865
 
    AS $$
72866
 
DECLARE
72867
 
  _ipsitemid    INTEGER;
72868
 
  _new          BOOLEAN;
72869
 
  
72870
 
BEGIN
72871
 
 
72872
 
  -- Validation
72873
 
  IF (SELECT COUNT(*)=0 FROM prodcat WHERE (prodcat_id=pProdcatId)) THEN
72874
 
    RAISE EXCEPTION 'You must provide a valid Product Category';
72875
 
  ELSIF (COALESCE(pQtyBreak,0) < 0) THEN
72876
 
    RAISE EXCEPTION 'Quantity can not be a negative value';
72877
 
  ELSIF (COALESCE(pDiscount,0) < 0) THEN
72878
 
    RAISE EXCEPTION 'Discount must be a negative value';
72879
 
  END IF;
72880
 
    
72881
 
  _new := TRUE;
72882
 
 
72883
 
  IF (pIpsProdcatId IS NOT NULL) THEN
72884
 
    SELECT ipsitem_id INTO _ipsitemid
72885
 
    FROM ipsiteminfo
72886
 
    WHERE (ipsprodcat_id=pIpsprodcatId);
72887
 
 
72888
 
    IF (FOUND) THEN
72889
 
      _new := FALSE;
72890
 
    ELSE
72891
 
      RAISE EXCEPTION 'Pricing Schedule Product Category not found';
72892
 
    END IF;
72893
 
  ELSE
72894
 
    SELECT ipsitem_id INTO _ipsitemid
72895
 
    FROM ipsiteminfo
72896
 
    WHERE ((ipsitem_ipshead_id=pIpsheadId)
72897
 
      AND (ipsitem_prodcat_id=pProdcatId)
72898
 
      AND (ipsitem_qtybreak=pQtyBreak));
72899
 
 
72900
 
    IF (FOUND) THEN
72901
 
      _new := false;
72902
 
    ELSE
72903
 
      _ipsitemid := nextval('ipsitem_ipsitem_id_seq');
72904
 
    END IF;
72905
 
  END IF;
72906
 
  
72907
 
  IF (_new) THEN
72908
 
    INSERT INTO ipsiteminfo (
72909
 
      ipsitem_id,
72910
 
      ipsitem_ipshead_id, 
72911
 
      ipsitem_prodcat_id, 
72912
 
      ipsitem_qtybreak,
72913
 
      ipsitem_price, 
72914
 
      ipsitem_discntprcnt,
72915
 
      ipsitem_fixedamtdiscount,
72916
 
      ipsitem_type)  
72917
 
    VALUES (
72918
 
      _ipsitemid,
72919
 
      pIpsheadId,
72920
 
      pProdcatId,
72921
 
      pQtyBreak, 
72922
 
      0.0,
72923
 
      pDiscount * .01,
72924
 
      pFixedAmtDiscount,
72925
 
      pType);
72926
 
  ELSE 
72927
 
    UPDATE ipsiteminfo SET 
72928
 
      ipsitem_qtybreak = pQtyBreak, 
72929
 
      ipsitem_discntprcnt = pDiscount * .01,
72930
 
      ipsitem_fixedamtdiscount = pFixedAmtDiscount,
72931
 
      ipsitem_type = pType 
72932
 
    WHERE (ipsitem_id=_ipsitemid);
72933
 
  END IF;
72934
 
 
72935
 
  RETURN _ipsitemid;
72936
 
END;
72937
 
$$;
72938
 
 
72939
 
 
72940
 
ALTER FUNCTION public.saveipsprodcat(pipsprodcatid integer, pipsheadid integer, pprodcatid integer, pqtybreak numeric, pdiscount numeric, pfixedamtdiscount numeric, ptype text) OWNER TO admin;
72941
 
 
72942
 
--
72943
 
--
72944
 
 
72945
 
CREATE FUNCTION saveitemimage(integer, character, integer) RETURNS integer
72946
 
    LANGUAGE plpgsql
72947
 
    AS $_$
72948
 
DECLARE
72949
 
  pItemid ALIAS FOR $1;
72950
 
  pPurpose ALIAS FOR $2;
72951
 
  pImageid ALIAS FOR $3;
72952
 
  _itemimageId INTEGER;
72953
 
 
72954
 
BEGIN
72955
 
  SELECT imageass_id INTO _itemimageId
72956
 
  FROM imageass
72957
 
  WHERE ( (imageass_source='I')
72958
 
    AND   (imageass_source_id=pItemid)
72959
 
    AND   (imageass_purpose=pPurpose) );
72960
 
 
72961
 
  IF (FOUND) THEN
72962
 
    UPDATE imageass SET imageass_image_id=pImageId
72963
 
    WHERE (imageass_id=_itemimageId);
72964
 
  ELSE
72965
 
    _itemimageId := NEXTVAL('imageass_imageass_id_seq');
72966
 
    INSERT INTO imageass VALUES (_itemimageId,pItemid,'I',pImageid,pPurpose);
72967
 
  END IF;
72968
 
  
72969
 
  RETURN _itemimageId;
72970
 
END;
72971
 
$_$;
72972
 
 
72973
 
 
72974
 
ALTER FUNCTION public.saveitemimage(integer, character, integer) OWNER TO admin;
72975
 
 
72976
 
--
72977
 
--
72978
 
 
72979
 
CREATE FUNCTION saveitemuomconv(integer, integer, numeric, integer, numeric, boolean, integer[]) RETURNS integer
72980
 
    LANGUAGE plpgsql
72981
 
    AS $_$
72982
 
DECLARE
72983
 
  pItemId ALIAS FOR $1;
72984
 
  pFromUomId ALIAS FOR $2;
72985
 
  pFromValue ALIAS FOR $3;
72986
 
  pToUomId ALIAS FOR $4;
72987
 
  pToValue ALIAS FOR $5;
72988
 
  pFractional ALIAS FOR $6;
72989
 
  pUomTypes ALIAS FOR $7;
72990
 
  _p RECORD;
72991
 
  _fromUomId INTEGER;
72992
 
  _fromValue NUMERIC;
72993
 
  _toUomId INTEGER;
72994
 
  _toValue NUMERIC;
72995
 
  _fractional BOOLEAN;
72996
 
  _seq INTEGER;
72997
 
  _i INTEGER;
72998
 
  _uomtype TEXT;
72999
 
 
73000
 
BEGIN
73001
 
  IF (pUomTypes IS NULL) OR (ARRAY_UPPER(pUomTypes,1) = 0) THEN
73002
 
        RAISE EXCEPTION 'You must include at least one item type.';
73003
 
  END IF;
73004
 
 
73005
 
  SELECT * INTO _p
73006
 
  FROM uomconv
73007
 
  WHERE ((((uomconv_from_uom_id=pFromUomId)
73008
 
  AND (uomconv_to_uom_id=pToUomId))
73009
 
  OR ((uomconv_from_uom_id=pToUomId)
73010
 
  AND (uomconv_to_uom_id=pFromUomId))));
73011
 
 
73012
 
  IF (FOUND) THEN
73013
 
    _fromUomId := _p.uomconv_from_uom_id;
73014
 
    _toUomId := _p.uomconv_to_uom_id;
73015
 
    _fromValue := _p.uomconv_from_value;
73016
 
    _toValue := _p.uomconv_to_value;
73017
 
    _fractional := _p.uomconv_fractional;
73018
 
    RAISE NOTICE 'Defaulted to global Unit of Measure conversion ratios.';
73019
 
  ELSE
73020
 
    _fromUomId := pFromUomId;
73021
 
    _fromValue := pFromValue;
73022
 
    _toUomId := pToUomId;
73023
 
    _toValue := pToValue;
73024
 
    _fractional := pFractional;
73025
 
  END IF;
73026
 
 
73027
 
  SELECT f.uom_name AS f_uom, t.uom_name as t_uom INTO _p
73028
 
  FROM itemuomconv,uom f, uom t
73029
 
  WHERE ((itemuomconv_item_id=pItemId)
73030
 
  AND (itemuomconv_from_uom_id=_toUomId)
73031
 
  AND (itemuomconv_to_uom_id=_fromUomId)
73032
 
  AND (f.uom_id=itemuomconv_from_uom_id)
73033
 
  AND (t.uom_id=itemuomconv_to_uom_id));
73034
 
  IF (FOUND) THEN
73035
 
    RAISE EXCEPTION 'Unit of measure conversion already exists going from % to %.',_p.f_uom,_p.t_uom;
73036
 
  END IF;
73037
 
 
73038
 
  SELECT * INTO _p
73039
 
  FROM itemuomconv
73040
 
  WHERE ((itemuomconv_item_id=pItemId)
73041
 
  AND (itemuomconv_from_uom_id=_fromUomId)
73042
 
  AND (itemuomconv_to_uom_id=_toUomId));
73043
 
 
73044
 
  IF (FOUND) THEN
73045
 
    UPDATE itemuomconv SET
73046
 
      itemuomconv_from_value=_fromValue,
73047
 
      itemuomconv_to_value=_toValue,
73048
 
      itemuomconv_fractional=_fractional
73049
 
    WHERE (itemuomconv_id=_p.itemuomconv_id);
73050
 
    _seq := _p.itemuomconv_id;
73051
 
    
73052
 
    --Delete old type list
73053
 
    DELETE FROM itemuom WHERE itemuom_itemuomconv_id=_p.itemuomconv_id;
73054
 
  ELSE
73055
 
  
73056
 
    SELECT NEXTVAL('itemuomconv_itemuomconv_id_seq') INTO _seq;
73057
 
    INSERT INTO itemuomconv VALUES
73058
 
      (_seq, pItemId,_fromUomId,_fromValue,_toUomId,_toValue,_fractional);
73059
 
  END IF;
73060
 
  
73061
 
  FOR _i IN 1..ARRAY_UPPER(pUomTypes,1)
73062
 
  LOOP
73063
 
    SELECT uomtype_name INTO _uomtype
73064
 
    FROM itemuomconv, itemuom, uomtype
73065
 
    WHERE ((itemuom_uomtype_id=uomtype_id)
73066
 
    AND (itemuomconv_id=itemuom_itemuomconv_id)
73067
 
    AND (itemuomconv_item_id=pItemId)
73068
 
    AND (uomtype_name != 'Selling')
73069
 
    AND (itemuom_uomtype_id=pUomTypes[_i]));
73070
 
    IF (FOUND) THEN
73071
 
      RAISE EXCEPTION 'Unit of Measure Type % is already used on this item',_uomtype;
73072
 
    ELSE
73073
 
      INSERT INTO itemuom (itemuom_itemuomconv_id,itemuom_uomtype_id)
73074
 
      VALUES (_seq,pUomTypes[_i]);
73075
 
    END IF;
73076
 
  END LOOP;
73077
 
  
73078
 
  RETURN _seq;
73079
 
END;
73080
 
$_$;
73081
 
 
73082
 
 
73083
 
ALTER FUNCTION public.saveitemuomconv(integer, integer, numeric, integer, numeric, boolean, integer[]) OWNER TO admin;
73084
 
 
73085
 
--
73086
 
--
73087
 
 
73088
 
CREATE FUNCTION savemetasql(text, text, text, text) RETURNS integer
73089
 
    LANGUAGE plpgsql
73090
 
    AS $_$
73091
 
BEGIN
73092
 
  RETURN saveMetasql($1, $2, $3, $4, true, NULL, 0);
73093
 
END;
73094
 
$_$;
73095
 
 
73096
 
 
73097
 
ALTER FUNCTION public.savemetasql(text, text, text, text) OWNER TO admin;
73098
 
 
73099
 
--
73100
 
--
73101
 
 
73102
 
CREATE FUNCTION savemetasql(text, text, text, text, boolean) RETURNS integer
73103
 
    LANGUAGE plpgsql
73104
 
    AS $_$
73105
 
BEGIN
73106
 
  RETURN saveMetasql($1, $2, $3, $4, $5, NULL, 0);
73107
 
END;
73108
 
$_$;
73109
 
 
73110
 
 
73111
 
ALTER FUNCTION public.savemetasql(text, text, text, text, boolean) OWNER TO admin;
73112
 
 
73113
 
--
73114
 
--
73115
 
 
73116
 
CREATE FUNCTION savemetasql(text, text, text, text, boolean, text) RETURNS integer
73117
 
    LANGUAGE plpgsql
73118
 
    AS $_$
73119
 
BEGIN
73120
 
  RETURN saveMetasql($1, $2, $3, $4, $5, $6, 0);
73121
 
END;
73122
 
$_$;
73123
 
 
73124
 
 
73125
 
ALTER FUNCTION public.savemetasql(text, text, text, text, boolean, text) OWNER TO admin;
73126
 
 
73127
 
--
73128
 
--
73129
 
 
73130
 
CREATE FUNCTION savemetasql(text, text, text, text, boolean, text, integer) RETURNS integer
73131
 
    LANGUAGE plpgsql
73132
 
    AS $_$
73133
 
DECLARE
73134
 
  pGroup        ALIAS FOR $1;
73135
 
  pName         ALIAS FOR $2;
73136
 
  pNotes        ALIAS FOR $3;
73137
 
  pQuery        ALIAS FOR $4;
73138
 
  pSystem       ALIAS FOR $5;
73139
 
  pSchema       ALIAS FOR $6;
73140
 
  pGrade        ALIAS FOR $7;
73141
 
  _metasqlid    INTEGER;
73142
 
  _debug        BOOL    := false;
73143
 
  _grade        INTEGER;
73144
 
  _insertstr    TEXT;
73145
 
  _table        TEXT;
73146
 
  
73147
 
BEGIN
73148
 
 
73149
 
  --See if Query already exists
73150
 
  SELECT metasql_id INTO _metasqlid
73151
 
  FROM metasql
73152
 
  WHERE ((metasql_group=pGroup)
73153
 
     AND (metasql_name=pName)
73154
 
     AND (metasql_grade=pGrade));
73155
 
 
73156
 
  IF (FOUND) THEN
73157
 
    IF (_debug) THEN RAISE NOTICE 'update metasql'; END IF;
73158
 
    UPDATE metasql SET
73159
 
      metasql_group=pGroup,
73160
 
      metasql_name=pName,
73161
 
      metasql_notes=pNotes,
73162
 
      metasql_query=pQuery
73163
 
    WHERE (metasql_id=_metasqlid);
73164
 
  ELSE
73165
 
    IF (COALESCE(pSchema, 'public') = 'public' OR
73166
 
        TRIM(pSchema) = '') THEN
73167
 
      _table := 'metasql';
73168
 
    ELSE
73169
 
      _table := pSchema || '.pkgmetasql';
73170
 
    END IF;
73171
 
 
73172
 
    IF (pGrade IS NULL) THEN
73173
 
      SELECT MAX(metasql_grade) + 1 INTO _grade
73174
 
      FROM metasql
73175
 
      WHERE ((metasql_group=pGroup)
73176
 
         AND (metasql_name=pName));
73177
 
    ELSE
73178
 
      _grade := pGrade;
73179
 
    END IF;
73180
 
 
73181
 
    _insertstr := 'INSERT INTO ' || _table ||
73182
 
                  ' (metasql_group, metasql_name, metasql_notes, ' ||
73183
 
                  '  metasql_query, metasql_grade) VALUES (' ||
73184
 
                  COALESCE(quote_literal(pGroup),'NULL') || ',' || COALESCE(quote_literal(pName), 'NULL') || ',' ||
73185
 
                  COALESCE(quote_literal(pNotes), 'NULL') || ',' || COALESCE(quote_literal(pQuery), 'NULL') ||',' ||
73186
 
                  COALESCE(quote_literal(_grade), 'NULL') || ') RETURNING metasql_id;' ;
73187
 
 
73188
 
    IF (_debug) THEN RAISE NOTICE '%', _insertstr; END IF;
73189
 
    EXECUTE _insertstr INTO _metasqlid;
73190
 
  END IF;
73191
 
 
73192
 
  RETURN _metasqlid;
73193
 
END;
73194
 
$_$;
73195
 
 
73196
 
 
73197
 
ALTER FUNCTION public.savemetasql(text, text, text, text, boolean, text, integer) OWNER TO admin;
73198
 
 
73199
 
--
73200
 
--
73201
 
 
73202
 
CREATE FUNCTION scraps(text) RETURNS boolean
73203
 
    LANGUAGE plpgsql
73204
 
    AS $_$
73205
 
DECLARE
73206
 
  pTransType ALIAS FOR $1;
73207
 
 
73208
 
BEGIN
73209
 
  IF (pTransType IN ('SI', 'SM', 'EX')) THEN
73210
 
    RETURN TRUE;
73211
 
  ELSE
73212
 
    RETURN FALSE;
73213
 
  END IF;
73214
 
 
73215
 
END;
73216
 
$_$;
73217
 
 
73218
 
 
73219
 
ALTER FUNCTION public.scraps(text) OWNER TO admin;
73220
 
 
73221
 
--
73222
 
--
73223
 
 
73224
 
CREATE FUNCTION scrapwomaterial(integer, numeric) RETURNS integer
73225
 
    LANGUAGE plpgsql
73226
 
    AS $_$
73227
 
BEGIN
73228
 
  RETURN scrapWoMaterial($1, $2, CURRENT_TIMESTAMP);
73229
 
END;
73230
 
$_$;
73231
 
 
73232
 
 
73233
 
ALTER FUNCTION public.scrapwomaterial(integer, numeric) OWNER TO admin;
73234
 
 
73235
 
--
73236
 
--
73237
 
 
73238
 
CREATE FUNCTION scrapwomaterial(integer, numeric, timestamp with time zone) RETURNS integer
73239
 
    LANGUAGE plpgsql
73240
 
    AS $_$
73241
 
DECLARE
73242
 
  pWomatlid     ALIAS FOR $1;
73243
 
  pQty          ALIAS FOR $2;
73244
 
  pGlDistTS     ALIAS FOR $3;
73245
 
  _costmethod           CHAR(1);
73246
 
  _scrapValue           NUMERIC;
73247
 
  _r                    RECORD;
73248
 
 
73249
 
BEGIN
73250
 
  -- Validate
73251
 
  IF (pQty <= 0) THEN
73252
 
    RAISE EXCEPTION 'Scrap quantity must be a positive number';
73253
 
  ELSIF ( ( SELECT (womatl_qtyiss < pQty)
73254
 
             FROM womatl
73255
 
             WHERE (womatl_id=pWomatlid) ) ) THEN
73256
 
    RAISE EXCEPTION 'You may not scrap more material than has been issued';
73257
 
  END IF;
73258
 
 
73259
 
  -- Get the wip G/L account
73260
 
  SELECT costcat_wip_accnt_id
73261
 
    INTO _r
73262
 
    FROM womatl, wo, itemsite, costcat
73263
 
   WHERE((womatl_wo_id=wo_id)
73264
 
     AND (wo_itemsite_id=itemsite_id)
73265
 
     AND (itemsite_costcat_id=costcat_id)
73266
 
     AND (womatl_id=pWomatlid));
73267
 
 
73268
 
  -- Calculate scrap value
73269
 
  SELECT itemsite_costmethod INTO _costmethod
73270
 
  FROM womatl
73271
 
    JOIN itemsite ON (womatl_itemsite_id=itemsite_id)
73272
 
  WHERE (womatl_id=pWomatlid);
73273
 
 
73274
 
  IF (_costmethod = 'S') THEN
73275
 
    SELECT ROUND((stdCost(itemsite_item_id) * itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, pQty)),2)
73276
 
    INTO _scrapValue
73277
 
    FROM womatl
73278
 
      JOIN itemsite ON (womatl_itemsite_id=itemsite_id)
73279
 
    WHERE (womatl_id=pWomatlid);
73280
 
     
73281
 
  ELSIF (_costmethod = 'A') THEN
73282
 
    SELECT ROUND((SUM(invhist_invqty * invhist_unitcost)-womatl_scrapvalue)/
73283
 
            (CASE WHEN (SUM(invhist_invqty)-itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtywipscrap) = 0) THEN
73284
 
              1
73285
 
            ELSE
73286
 
              SUM(invhist_invqty)-itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtywipscrap)
73287
 
            END),2) * itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, pQty)
73288
 
      INTO _scrapValue
73289
 
    FROM womatl
73290
 
        JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)
73291
 
        JOIN invhist ON (womatlpost_invhist_id=invhist_id)
73292
 
        JOIN itemsite ON (womatl_itemsite_id=itemsite_id)
73293
 
    WHERE (womatl_id=pWomatlid)
73294
 
    GROUP BY itemsite_item_id,womatl_uom_id,womatl_qtywipscrap,womatl_scrapvalue;
73295
 
  ELSE
73296
 
    RAISE EXCEPTION 'Cost method not supported to scrap this item';
73297
 
  END IF;
73298
 
 
73299
 
  --  Distribute to G/L
73300
 
  PERFORM insertGLTransaction( 'W/O', 'WO', formatWoNumber(womatl_wo_id),
73301
 
                 ('Scrap ' || item_number || ' from Work Order'),
73302
 
                 getPrjAccntId(wo_prj_id, _r.costcat_wip_accnt_id), getPrjAccntId(wo_prj_id, costcat_mfgscrap_accnt_id), -1,
73303
 
                 _scrapValue, date(pGlDistTS) )
73304
 
  FROM wo, womatl, itemsite, item, costcat
73305
 
  WHERE ( (wo_id=womatl_wo_id)
73306
 
   AND (womatl_itemsite_id=itemsite_id)
73307
 
   AND (itemsite_item_id=item_id)
73308
 
   AND (itemsite_costcat_id=costcat_id)
73309
 
   AND (womatl_id=pWomatlid) );
73310
 
 
73311
 
  UPDATE womatl
73312
 
  SET womatl_qtywipscrap=(womatl_qtywipscrap + pQty),
73313
 
    womatl_scrapvalue = womatl_scrapvalue + _scrapValue,
73314
 
    womatl_qtyiss=(womatl_qtyiss - pQty)
73315
 
  WHERE (womatl_id=pWomatlid);
73316
 
 
73317
 
  UPDATE wo
73318
 
  SET wo_wipvalue = wo_wipvalue-_scrapValue,
73319
 
    wo_postedvalue = wo_postedvalue-_scrapValue
73320
 
  FROM womatl
73321
 
  WHERE ((womatl_id=pWomatlid)
73322
 
   AND (wo_id=womatl_wo_id));
73323
 
 
73324
 
  RETURN pWomatlid;
73325
 
 
73326
 
END;
73327
 
$_$;
73328
 
 
73329
 
 
73330
 
ALTER FUNCTION public.scrapwomaterial(integer, numeric, timestamp with time zone) OWNER TO admin;
73331
 
 
73332
 
--
73333
 
--
73334
 
 
73335
 
CREATE FUNCTION selectbalanceforbilling(integer) RETURNS boolean
73336
 
    LANGUAGE plpgsql
73337
 
    AS $_$
73338
 
DECLARE
73339
 
  pSoheadid ALIAS FOR $1;
73340
 
  _returnval    BOOLEAN := TRUE;
73341
 
  _doSelect BOOLEAN;
73342
 
  _result INTEGER;
73343
 
  _soitem RECORD;
73344
 
 
73345
 
BEGIN
73346
 
 
73347
 
  FOR _soitem IN
73348
 
    -- Get the shipments for this SO.  Kits are not shipped
73349
 
    SELECT cust_partialship, coitem_id,
73350
 
           coitem_linenumber, 'NOTK' AS item_type,
73351
 
           SUM(shipitem_qty) AS qty,
73352
 
           ( (SUM(shipitem_qty) >= (coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned + SUM(shipitem_qty))) OR
73353
 
             (NOT cust_partialship) ) AS toclose
73354
 
    FROM cohead JOIN custinfo ON (cust_id=cohead_cust_id)
73355
 
                JOIN coitem ON (coitem_cohead_id=cohead_id)
73356
 
                JOIN shipitem ON ( (shipitem_orderitem_id=coitem_id) AND (NOT shipitem_invoiced) )
73357
 
                JOIN shiphead ON ( (shiphead_id=shipitem_shiphead_id) AND (shiphead_order_type='SO') AND (shiphead_shipped) )
73358
 
    WHERE (cohead_id=pSoheadid)
73359
 
    GROUP BY cust_partialship, coitem_id, item_type,
73360
 
             coitem_linenumber, coitem_qtyord,
73361
 
             coitem_qtyshipped, coitem_qtyreturned
73362
 
    UNION
73363
 
    -- Get the Kits for this SO
73364
 
    SELECT cust_partialship, coitem_id,
73365
 
           coitem_linenumber, 'K' AS item_type,
73366
 
           coitem_qtyord AS qty,
73367
 
           TRUE AS toclose
73368
 
    FROM cohead JOIN custinfo ON (cust_id=cohead_cust_id)
73369
 
                JOIN coitem ON (coitem_cohead_id=cohead_id AND coitem_status='O')
73370
 
                JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
73371
 
                JOIN item ON ( (item_id=itemsite_item_id) AND (item_type='K') )
73372
 
    WHERE (cohead_id=pSoheadid)
73373
 
  LOOP
73374
 
 
73375
 
    _doSelect := true;
73376
 
    IF(_soitem.item_type = 'K') THEN
73377
 
      -- see if all the sub items are shipped
73378
 
      SELECT coitem_id
73379
 
        INTO _result
73380
 
        FROM coitem
73381
 
       WHERE((coitem_cohead_id=pSoheadid)
73382
 
         AND (coitem_linenumber=_soitem.coitem_linenumber)
73383
 
         AND (coitem_subnumber > 0)
73384
 
         AND ((coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) > 0))
73385
 
       LIMIT 1;
73386
 
      IF( FOUND ) THEN
73387
 
        _doSelect := false;
73388
 
      END IF;
73389
 
    END IF;
73390
 
 
73391
 
    IF (_doSelect) THEN
73392
 
      -- do as much as we can but still report errors if they occur
73393
 
      IF (selectForBilling(_soitem.coitem_id, _soitem.qty, _soitem.toclose) < 0) THEN
73394
 
        _returnval := FALSE;
73395
 
      END IF;
73396
 
    END IF;
73397
 
 
73398
 
  END LOOP;
73399
 
 
73400
 
  RETURN _returnval;
73401
 
 
73402
 
END;
73403
 
$_$;
73404
 
 
73405
 
 
73406
 
ALTER FUNCTION public.selectbalanceforbilling(integer) OWNER TO admin;
73407
 
 
73408
 
--
73409
 
--
73410
 
 
73411
 
CREATE FUNCTION selectdiscountitemsforpayment(integer, integer) RETURNS integer
73412
 
    LANGUAGE plpgsql
73413
 
    AS $_$
73414
 
DECLARE
73415
 
  pVendid ALIAS FOR $1;
73416
 
  pBankaccntid ALIAS FOR $2;
73417
 
  _currid INTEGER;
73418
 
  _r RECORD;
73419
 
 
73420
 
BEGIN
73421
 
 
73422
 
  SELECT bankaccnt_curr_id INTO _currid
73423
 
  FROM bankaccnt
73424
 
  WHERE (bankaccnt_id=pBankaccntid);
73425
 
 
73426
 
  FOR _r IN SELECT apopen_id
73427
 
              FROM apopen, terms
73428
 
             WHERE((CURRENT_DATE <= determineDiscountDate(apopen_terms_id, apopen_docdate))
73429
 
               AND (terms_discprcnt > 0.0)
73430
 
               AND (apopen_terms_id=terms_id)
73431
 
               AND (apopen_open)
73432
 
               AND (apopen_status = 'O')
73433
 
               AND (apopen_doctype IN ('V', 'D'))
73434
 
               AND (apopen_vend_id=pVendid)
73435
 
               AND (apopen_curr_id=_currid) ) LOOP
73436
 
    PERFORM selectPayment(_r.apopen_id, pBankaccntid);
73437
 
  END LOOP;
73438
 
 
73439
 
  RETURN 1;
73440
 
 
73441
 
END;
73442
 
$_$;
73443
 
 
73444
 
 
73445
 
ALTER FUNCTION public.selectdiscountitemsforpayment(integer, integer) OWNER TO admin;
73446
 
 
73447
 
--
73448
 
--
73449
 
 
73450
 
CREATE FUNCTION selectdueitemsforpayment(integer, integer) RETURNS integer
73451
 
    LANGUAGE plpgsql
73452
 
    AS $_$
73453
 
DECLARE
73454
 
  pVendid ALIAS FOR $1;
73455
 
  pBankaccntid ALIAS FOR $2;
73456
 
  _currid INTEGER;
73457
 
 
73458
 
BEGIN
73459
 
 
73460
 
  SELECT bankaccnt_curr_id INTO _currid
73461
 
  FROM bankaccnt
73462
 
  WHERE (bankaccnt_id=pBankaccntid);
73463
 
 
73464
 
  PERFORM selectPayment(apopen_id, pBankaccntid)
73465
 
     FROM apopen
73466
 
    WHERE((apopen_open)
73467
 
      AND (apopen_vend_id=pVendid)
73468
 
      AND (apopen_duedate <= CURRENT_DATE)
73469
 
      AND (apopen_status = 'O')
73470
 
      AND (apopen_doctype IN ('V', 'D'))
73471
 
      AND (apopen_curr_id=_currid) );
73472
 
 
73473
 
  RETURN 1;
73474
 
 
73475
 
END;
73476
 
$_$;
73477
 
 
73478
 
 
73479
 
ALTER FUNCTION public.selectdueitemsforpayment(integer, integer) OWNER TO admin;
73480
 
 
73481
 
--
73482
 
--
73483
 
 
73484
 
CREATE FUNCTION selectforbilling(integer, numeric, boolean) RETURNS integer
73485
 
    LANGUAGE plpgsql
73486
 
    AS $_$
73487
 
DECLARE
73488
 
  pSoitemid     ALIAS FOR $1;
73489
 
  pQty  ALIAS FOR $2;
73490
 
  pClose        ALIAS FOR $3;
73491
 
  _itemid       INTEGER := NULL;
73492
 
  _taxzoneid    INTEGER := NULL;
73493
 
  _taxid        INTEGER := NULL;
73494
 
  _taxtypeid    INTEGER := NULL;
73495
 
 
73496
 
BEGIN
73497
 
  SELECT cobmisc_taxzone_id,  item_id, coitem_taxtype_id
73498
 
  INTO _taxzoneid,  _itemid, _taxtypeid
73499
 
  FROM cobmisc, coitem, itemsite, item
73500
 
  WHERE ((cobmisc_cohead_id = coitem_cohead_id)
73501
 
  AND   (NOT cobmisc_posted)
73502
 
  AND   (coitem_itemsite_id = itemsite_id)
73503
 
  AND   (itemsite_item_id = item_id)
73504
 
  AND   (coitem_id = pSoitemid) )
73505
 
  LIMIT 1;
73506
 
 
73507
 
   RETURN selectforbilling(pSoitemid, pQty, pClose, _taxtypeid);
73508
 
END;
73509
 
$_$;
73510
 
 
73511
 
 
73512
 
ALTER FUNCTION public.selectforbilling(integer, numeric, boolean) OWNER TO admin;
73513
 
 
73514
 
--
73515
 
--
73516
 
 
73517
 
CREATE FUNCTION selectforbilling(integer, numeric, boolean, integer) RETURNS integer
73518
 
    LANGUAGE plpgsql
73519
 
    AS $_$
73520
 
DECLARE
73521
 
  pSoitemid     ALIAS FOR $1;
73522
 
  pQty          ALIAS FOR $2;
73523
 
  pClose        ALIAS FOR $3;
73524
 
  ptaxtypeid    ALIAS FOR $4;
73525
 
  _cobillid INTEGER;
73526
 
  _r RECORD;
73527
 
 
73528
 
BEGIN
73529
 
 
73530
 
  SELECT cobmisc_id, cobmisc_taxzone_id, coitem_id, coitem_price,
73531
 
    coitem_price_invuomratio AS invpricerat, coitem_qty_invuomratio, item_id
73532
 
  INTO _r
73533
 
  FROM cobmisc, coitem, itemsite, item, site()
73534
 
  WHERE ((cobmisc_cohead_id = coitem_cohead_id)
73535
 
  AND   (NOT cobmisc_posted)
73536
 
  AND   (coitem_itemsite_id = itemsite_id)
73537
 
  AND   (itemsite_item_id = item_id)
73538
 
  AND   (coitem_id = pSoitemid)
73539
 
  AND   (itemsite_warehous_id = warehous_id) )
73540
 
  LIMIT 1;
73541
 
 
73542
 
  IF ((SELECT (pQty < SUM(shipitem_qty))
73543
 
       FROM shipitem, shiphead, coitem
73544
 
       WHERE ( (shipitem_shiphead_id=shiphead_id)
73545
 
       AND (shiphead_order_type='SO')
73546
 
       AND (shiphead_order_id=coitem_cohead_id)
73547
 
       AND (shipitem_orderitem_id=coitem_id)
73548
 
       AND (shiphead_shipped)
73549
 
       AND (NOT shipitem_invoiced)
73550
 
       AND (coitem_id=pSoitemid) ) ) ) THEN
73551
 
    RETURN -1;
73552
 
  END IF;
73553
 
 
73554
 
  SELECT cobill_id INTO _cobillid
73555
 
  FROM cobill, cobmisc, coitem
73556
 
  WHERE ((cobill_cobmisc_id = cobmisc_id)
73557
 
  AND (cobmisc_cohead_id = coitem_cohead_id)
73558
 
  AND (cobill_coitem_id = coitem_id)
73559
 
  AND (NOT cobmisc_posted)
73560
 
  AND (coitem_id = pSoitemid));
73561
 
 
73562
 
  IF (FOUND) THEN
73563
 
    UPDATE cobill
73564
 
    SET cobill_selectdate = CURRENT_DATE,
73565
 
        cobill_select_username = getEffectiveXtUser(),
73566
 
        cobill_qty = pQty,
73567
 
        cobill_toclose = pClose,
73568
 
        cobill_taxtype_id = ptaxtypeid
73569
 
    WHERE (cobill_id=_cobillid);
73570
 
 
73571
 
  ELSE
73572
 
    SELECT NEXTVAL('cobill_cobill_id_seq') INTO _cobillid;
73573
 
    INSERT INTO cobill
73574
 
    (cobill_id, cobill_coitem_id, cobill_cobmisc_id,
73575
 
     cobill_selectdate, cobill_select_username,
73576
 
     cobill_qty, cobill_toclose,
73577
 
     cobill_taxtype_id)
73578
 
    VALUES
73579
 
    (_cobillid, _r.coitem_id, _r.cobmisc_id,
73580
 
      CURRENT_DATE, getEffectiveXtUser(),
73581
 
      pQty, pClose,
73582
 
      ptaxtypeid);
73583
 
  END IF;
73584
 
 
73585
 
  RETURN _cobillid;
73586
 
 
73587
 
END;
73588
 
$_$;
73589
 
 
73590
 
 
73591
 
ALTER FUNCTION public.selectforbilling(integer, numeric, boolean, integer) OWNER TO admin;
73592
 
 
73593
 
--
73594
 
--
73595
 
 
73596
 
CREATE FUNCTION selectpayment(integer, integer) RETURNS integer
73597
 
    LANGUAGE plpgsql
73598
 
    AS $_$
73599
 
DECLARE
73600
 
  pApopenid ALIAS FOR $1;
73601
 
  pBankaccntid ALIAS FOR $2;
73602
 
  _p RECORD;
73603
 
  _apselectid INTEGER;
73604
 
  _amount NUMERIC;
73605
 
  _discount NUMERIC;
73606
 
BEGIN
73607
 
 
73608
 
  SELECT apopen_amount, apopen_paid,
73609
 
         apopen_doctype, apopen_docdate,
73610
 
         apopen_curr_id,
73611
 
         apopen_amount - apopen_paid - apCheckPending(apopen_id) AS balance,
73612
 
         noNeg(COALESCE(apopen_discountable_amount, 0) *
73613
 
               CASE WHEN (CURRENT_DATE <= determineDiscountDate(apopen_terms_id, apopen_docdate)) THEN terms_discprcnt
73614
 
                    ELSE 0.0 END - discount_applied) AS discount_available
73615
 
    INTO _p
73616
 
    FROM apopen LEFT OUTER JOIN terms ON (apopen_terms_id=terms_id),
73617
 
         (SELECT COALESCE(SUM(apapply_amount),0) AS discount_applied
73618
 
            FROM apapply, apopen
73619
 
           WHERE((apapply_target_apopen_id=pApopenid)
73620
 
             AND (apapply_source_apopen_id=apopen_id)
73621
 
             AND (apopen_discount)) ) AS data
73622
 
   WHERE(apopen_id=pApopenid);
73623
 
  IF(NOT FOUND OR (NOT _p.apopen_doctype IN ('V','D','C'))) THEN
73624
 
    RETURN -1;
73625
 
  END IF;
73626
 
 
73627
 
  _discount := round(_p.discount_available, 2);
73628
 
  _amount := noNeg(round(_p.balance, 2) - _discount);
73629
 
 
73630
 
  IF (round(_p.balance,2) < (_discount + _amount)) THEN
73631
 
    RETURN -2;
73632
 
  END IF;
73633
 
 
73634
 
  IF (_amount > 0) THEN
73635
 
    SELECT apselect_id INTO _apselectid
73636
 
    FROM apselect
73637
 
    WHERE (apselect_apopen_id=pApopenid);
73638
 
 
73639
 
    IF (FOUND) THEN
73640
 
      UPDATE apselect
73641
 
         SET apselect_amount=_amount,
73642
 
             apselect_discount=_discount,
73643
 
             apselect_curr_id = _p.apopen_curr_id
73644
 
       WHERE(apselect_id=_apselectid);
73645
 
    ELSE
73646
 
      SELECT NEXTVAL('apselect_apselect_id_seq') INTO _apselectid;
73647
 
 
73648
 
      INSERT INTO apselect
73649
 
      ( apselect_id, apselect_apopen_id,
73650
 
        apselect_amount, apselect_discount,
73651
 
        apselect_bankaccnt_id,
73652
 
        apselect_curr_id, apselect_date )
73653
 
      VALUES
73654
 
      ( _apselectid, pApopenid,
73655
 
        _amount, _discount,
73656
 
        pBankaccntid,
73657
 
        _p.apopen_curr_id, _p.apopen_docdate );
73658
 
    END IF;
73659
 
  ELSE
73660
 
    _apselectid := 0;
73661
 
  END IF;
73662
 
  
73663
 
  RETURN _apselectid;
73664
 
 
73665
 
END;
73666
 
$_$;
73667
 
 
73668
 
 
73669
 
ALTER FUNCTION public.selectpayment(integer, integer) OWNER TO admin;
73670
 
 
73671
 
--
73672
 
--
73673
 
 
73674
 
CREATE FUNCTION selectuninvoicedshipment(integer) RETURNS integer
73675
 
    LANGUAGE plpgsql
73676
 
    AS $_$
73677
 
DECLARE
73678
 
  pShipheadid ALIAS FOR $1;
73679
 
  _cobmiscid INTEGER;
73680
 
  _coheadid  INTEGER;
73681
 
  _r RECORD;
73682
 
  _cobillid INTEGER;
73683
 
 
73684
 
BEGIN
73685
 
 
73686
 
  -- make a cobmisc head if it doesn't already exist for this cohead
73687
 
  SELECT shiphead_order_id, createBillingHeader(shiphead_order_id)
73688
 
    INTO _coheadid, _cobmiscid
73689
 
    FROM shiphead
73690
 
    JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)
73691
 
   WHERE (shiphead_shipped
73692
 
      AND NOT shipitem_invoiced
73693
 
      AND (shiphead_id=pShipheadid));
73694
 
 
73695
 
  --  Grab all of the uninvoiced shipitem records
73696
 
  FOR _r IN SELECT cohead_id, coitem_id, SUM(shipitem_qty) AS qty,
73697
 
                   coitem_price, coitem_price_invuomratio AS invpricerat, coitem_qty_invuomratio, item_id,
73698
 
                   ( ((coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) <= 0)
73699
 
                    OR (NOT cust_partialship) ) AS toclose, coitem_taxtype_id
73700
 
            FROM shiphead, shipitem, coitem, cohead, custinfo, itemsite, item
73701
 
            WHERE ( (shipitem_shiphead_id=shiphead_id)
73702
 
             AND (shipitem_orderitem_id=coitem_id)
73703
 
             AND (coitem_cohead_id=cohead_id)
73704
 
             AND (shiphead_shipped)
73705
 
             AND (NOT shipitem_invoiced)
73706
 
             AND (coitem_itemsite_id=itemsite_id)
73707
 
             AND (itemsite_item_id=item_id)
73708
 
             AND (cohead_cust_id=cust_id)
73709
 
             AND (item_type != 'K')
73710
 
             AND (cohead_id=_coheadid)
73711
 
             AND (shiphead_id=pShipheadid) )
73712
 
            GROUP BY cohead_id, coitem_id, cust_partialship, coitem_taxtype_id,
73713
 
                     coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned,
73714
 
                     coitem_price, invpricerat, coitem_qty_invuomratio, item_id
73715
 
            UNION
73716
 
            SELECT cohead_id, coitem_id, coitem_qtyord AS qty,
73717
 
                   coitem_price, coitem_price_invuomratio AS invpricerat, coitem_qty_invuomratio, item_id,
73718
 
                   true AS toclose, coitem_taxtype_id
73719
 
              FROM shiphead, cohead, custinfo, itemsite, item, coitem AS kit
73720
 
             WHERE((shiphead_order_id=cohead_id)
73721
 
               AND (coitem_cohead_id=cohead_id)
73722
 
               AND (coitem_status='O')
73723
 
               AND (shiphead_shipped)
73724
 
               AND (coitem_itemsite_id=itemsite_id)
73725
 
               AND (itemsite_item_id=item_id)
73726
 
               AND (cohead_cust_id=cust_id)
73727
 
               AND (item_type = 'K')
73728
 
               AND (cohead_id=_coheadid)
73729
 
               AND (shiphead_id=pShipheadid)
73730
 
               AND (coitem_linenumber NOT IN
73731
 
                      (SELECT sub.coitem_linenumber
73732
 
                       FROM coitem AS sub
73733
 
                       WHERE sub.coitem_cohead_id=cohead_id     -- cohead for kit
73734
 
                        AND sub.coitem_linenumber=kit.coitem_linenumber
73735
 
                        AND sub.coitem_subnumber > 0
73736
 
                        AND ((sub.coitem_qtyord - sub.coitem_qtyshipped + sub.coitem_qtyreturned) > 0)
73737
 
                        LIMIT 1)
73738
 
               ))
73739
 
             GROUP BY cohead_id, coitem_id, cust_partialship, coitem_taxtype_id,
73740
 
                      coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned,
73741
 
                      coitem_price, invpricerat, coitem_qty_invuomratio, item_id, coitem_linenumber
73742
 
  LOOP
73743
 
 
73744
 
    SELECT cobill_id INTO _cobillid
73745
 
      FROM cobill, cobmisc, coitem
73746
 
     WHERE ((cobill_cobmisc_id=cobmisc_id)
73747
 
       AND  (cobmisc_cohead_id=coitem_cohead_id)
73748
 
       AND  (cobill_coitem_id=coitem_id)
73749
 
       AND  (NOT cobmisc_posted)
73750
 
       AND  (cobill_cobmisc_id=_cobmiscid)
73751
 
       AND  (coitem_id=_r.coitem_id))
73752
 
     LIMIT 1;
73753
 
 
73754
 
    IF (FOUND) THEN
73755
 
      UPDATE cobill
73756
 
         SET cobill_selectdate = CURRENT_DATE,
73757
 
             cobill_select_username = getEffectiveXtUser(),
73758
 
             cobill_qty = cobill_qty + _r.qty,
73759
 
             cobill_toclose = _r.toclose,
73760
 
             cobill_taxtype_id = _r.coitem_taxtype_id
73761
 
      WHERE (cobill_id=_cobillid);
73762
 
    ELSE
73763
 
      INSERT INTO cobill
73764
 
      ( cobill_cobmisc_id, cobill_coitem_id,
73765
 
        cobill_selectdate, cobill_select_username,
73766
 
        cobill_qty, cobill_toclose,
73767
 
        cobill_taxtype_id )
73768
 
      VALUES
73769
 
      ( _cobmiscid, _r.coitem_id,
73770
 
        CURRENT_DATE, getEffectiveXtUser(),
73771
 
        _r.qty, _r.toclose,
73772
 
         _r.coitem_taxtype_id );
73773
 
     END IF;
73774
 
 
73775
 
  END LOOP;
73776
 
 
73777
 
  RETURN _cobmiscid;
73778
 
 
73779
 
END;
73780
 
$_$;
73781
 
 
73782
 
 
73783
 
ALTER FUNCTION public.selectuninvoicedshipment(integer) OWNER TO admin;
73784
 
 
73785
 
--
73786
 
--
73787
 
 
73788
 
CREATE FUNCTION selectuninvoicedshipments(integer) RETURNS integer
73789
 
    LANGUAGE plpgsql
73790
 
    AS $_$
73791
 
DECLARE
73792
 
  pWarehousid ALIAS FOR $1;
73793
 
  _r RECORD;
73794
 
  _recordCounter INTEGER := 0;
73795
 
 
73796
 
BEGIN
73797
 
 
73798
 
  FOR _r IN SELECT DISTINCT shiphead_id
73799
 
            FROM shiphead, shipitem, coitem, itemsite
73800
 
            WHERE ( (shiphead_order_type='SO')
73801
 
             AND (shipitem_shiphead_id=shiphead_id)
73802
 
             AND (shipitem_orderitem_id=coitem_id)
73803
 
             AND (coitem_itemsite_id=itemsite_id)
73804
 
             AND (coitem_status <> 'C')
73805
 
             AND ( (pWarehousid = -1) OR (itemsite_warehous_id=pWarehousid) )
73806
 
             AND (shiphead_shipped)
73807
 
             AND (NOT shipitem_invoiced)
73808
 
             AND (coitem_id NOT IN ( SELECT cobill_coitem_id
73809
 
                                     FROM cobmisc, cobill
73810
 
                                     WHERE ((cobill_cobmisc_id=cobmisc_id)
73811
 
                                      AND (NOT cobmisc_posted) ) ) ) ) LOOP
73812
 
 
73813
 
      PERFORM selectUninvoicedShipment(_r.shiphead_id);
73814
 
 
73815
 
    _recordCounter := _recordCounter + 1;
73816
 
 
73817
 
  END LOOP;
73818
 
 
73819
 
  RETURN _recordCounter;
73820
 
 
73821
 
END;
73822
 
$_$;
73823
 
 
73824
 
 
73825
 
ALTER FUNCTION public.selectuninvoicedshipments(integer) OWNER TO admin;
73826
 
 
73827
 
--
73828
 
--
73829
 
 
73830
 
CREATE FUNCTION selectuninvoicedshipments(integer, text) RETURNS integer
73831
 
    LANGUAGE plpgsql
73832
 
    AS $_$
73833
 
DECLARE
73834
 
  pWarehousid ALIAS FOR $1;
73835
 
  pCusttype ALIAS FOR $2;
73836
 
  _r RECORD;
73837
 
  _recordCounter INTEGER := 0;
73838
 
 
73839
 
BEGIN
73840
 
 
73841
 
  FOR _r IN SELECT DISTINCT shiphead_id
73842
 
            FROM shiphead, shipitem, coitem, itemsite, cohead, custinfo, custtype
73843
 
            WHERE ( (shiphead_order_type='SO')
73844
 
             AND (shipitem_shiphead_id=shiphead_id)
73845
 
             AND (shipitem_orderitem_id=coitem_id)
73846
 
             AND (coitem_itemsite_id=itemsite_id)
73847
 
             AND (coitem_status <> 'C')
73848
 
             AND (coitem_cohead_id=cohead_id)
73849
 
             AND (cohead_cust_id=cust_id)
73850
 
             AND (cust_custtype_id=custtype_id)
73851
 
             AND ( (pWarehousid = -1) OR (itemsite_warehous_id=pWarehousid) )
73852
 
             AND (custtype_code ~ pCusttype)
73853
 
             AND (shiphead_shipped)
73854
 
             AND (NOT shipitem_invoiced)
73855
 
             AND (coitem_id NOT IN ( SELECT cobill_coitem_id
73856
 
                                     FROM cobmisc, cobill
73857
 
                                     WHERE ((cobill_cobmisc_id=cobmisc_id)
73858
 
                                      AND (NOT cobmisc_posted) ) ) ) ) LOOP
73859
 
 
73860
 
      PERFORM selectUninvoicedShipment(_r.shiphead_id);
73861
 
 
73862
 
    _recordCounter := _recordCounter + 1;
73863
 
 
73864
 
  END LOOP;
73865
 
 
73866
 
  RETURN _recordCounter;
73867
 
 
73868
 
END;
73869
 
$_$;
73870
 
 
73871
 
 
73872
 
ALTER FUNCTION public.selectuninvoicedshipments(integer, text) OWNER TO admin;
73873
 
 
73874
 
--
73875
 
--
73876
 
 
73877
 
CREATE FUNCTION selectuninvoicedshipments(integer, integer) RETURNS integer
73878
 
    LANGUAGE plpgsql
73879
 
    AS $_$
73880
 
DECLARE
73881
 
  pWarehousid ALIAS FOR $1;
73882
 
  pCusttypeid ALIAS FOR $2;
73883
 
  _r RECORD;
73884
 
  _recordCounter INTEGER := 0;
73885
 
 
73886
 
BEGIN
73887
 
 
73888
 
  FOR _r IN SELECT DISTINCT shiphead_id
73889
 
            FROM shiphead, shipitem, coitem, itemsite, cohead, custinfo
73890
 
            WHERE ( (shiphead_order_type='SO')
73891
 
             AND (shipitem_shiphead_id=shiphead_id)
73892
 
             AND (shipitem_orderitem_id=coitem_id)
73893
 
             AND (coitem_itemsite_id=itemsite_id)
73894
 
             AND (coitem_status <> 'C')
73895
 
             AND (coitem_cohead_id=cohead_id)
73896
 
             AND (cohead_cust_id=cust_id)
73897
 
             AND (cust_custtype_id=pCusttypeid)
73898
 
             AND ( (pWarehousid = -1) OR (itemsite_warehous_id=pWarehousid) )
73899
 
             AND (shiphead_shipped)
73900
 
             AND (NOT shipitem_invoiced)
73901
 
             AND (coitem_id NOT IN ( SELECT cobill_coitem_id
73902
 
                                     FROM cobmisc, cobill
73903
 
                                     WHERE ((cobill_cobmisc_id=cobmisc_id)
73904
 
                                      AND (NOT cobmisc_posted) ) ) ) ) LOOP
73905
 
 
73906
 
      PERFORM selectUninvoicedShipment(_r.shiphead_id);
73907
 
 
73908
 
    _recordCounter := _recordCounter + 1;
73909
 
 
73910
 
  END LOOP;
73911
 
 
73912
 
  RETURN _recordCounter;
73913
 
 
73914
 
END;
73915
 
$_$;
73916
 
 
73917
 
 
73918
 
ALTER FUNCTION public.selectuninvoicedshipments(integer, integer) OWNER TO admin;
73919
 
 
73920
 
--
73921
 
--
73922
 
 
73923
 
CREATE FUNCTION setapjournalnumber() RETURNS integer
73924
 
    LANGUAGE plpgsql
73925
 
    AS $$
73926
 
DECLARE
73927
 
  _journalNumber INTEGER;
73928
 
  _r RECORD;
73929
 
 
73930
 
BEGIN
73931
 
 
73932
 
  SELECT fetchJournalNumber('A/P') INTO _journalNumber;
73933
 
 
73934
 
  FOR _r IN SELECT apopen_id, apopen_docnumber
73935
 
            FROM apopen
73936
 
            WHERE (NOT apopen_posted) LOOP
73937
 
 
73938
 
    UPDATE gltrans
73939
 
    SET gltrans_journalnumber=_journalNumber
73940
 
    WHERE ( (gltrans_source='P/O')
73941
 
     AND (gltrans_doctype IN ('VO'))
73942
 
     AND (gltrans_docnumber=_r.apopen_docnumber)
73943
 
     AND (NOT gltrans_exported) );
73944
 
 
73945
 
    UPDATE apopen
73946
 
    SET apopen_journalnumber=_journalNumber
73947
 
    WHERE (apopen_id=_r.apopen_id);
73948
 
 
73949
 
  END LOOP;
73950
 
 
73951
 
  RETURN _journalNumber;
73952
 
 
73953
 
END;
73954
 
$$;
73955
 
 
73956
 
 
73957
 
ALTER FUNCTION public.setapjournalnumber() OWNER TO admin;
73958
 
 
73959
 
--
73960
 
--
73961
 
 
73962
 
CREATE FUNCTION setarjournalnumber() RETURNS integer
73963
 
    LANGUAGE plpgsql
73964
 
    AS $$
73965
 
DECLARE
73966
 
  _journalNumber INTEGER;
73967
 
  _r RECORD;
73968
 
 
73969
 
BEGIN
73970
 
 
73971
 
  SELECT fetchJournalNumber('A/R') INTO _journalNumber;
73972
 
 
73973
 
  FOR _r IN SELECT aropen_id, aropen_docnumber
73974
 
            FROM aropen
73975
 
            WHERE (NOT aropen_posted) LOOP
73976
 
 
73977
 
    UPDATE gltrans
73978
 
    SET gltrans_journalnumber=_journalNumber
73979
 
    WHERE ( (gltrans_source='S/O')
73980
 
     AND (gltrans_doctype IN ('CM', 'IN'))
73981
 
     AND (gltrans_docnumber=_r.aropen_docnumber)
73982
 
     AND (NOT gltrans_exported) );
73983
 
 
73984
 
    UPDATE aropen
73985
 
    SET aropen_journalnumber=_journalNumber
73986
 
    WHERE (aropen_id=_r.aropen_id);
73987
 
 
73988
 
  END LOOP;
73989
 
 
73990
 
  RETURN _journalNumber;
73991
 
 
73992
 
END;
73993
 
$$;
73994
 
 
73995
 
 
73996
 
ALTER FUNCTION public.setarjournalnumber() OWNER TO admin;
73997
 
 
73998
 
--
73999
 
--
74000
 
 
74001
 
CREATE FUNCTION setbudget(integer, integer, numeric) RETURNS integer
74002
 
    LANGUAGE plpgsql
74003
 
    AS $_$
74004
 
DECLARE
74005
 
  pPeriodid ALIAS FOR $1;
74006
 
  pAccntid ALIAS FOR $2;
74007
 
  pAmount ALIAS FOR $3;
74008
 
 
74009
 
BEGIN
74010
 
  RETURN setBudget(1, pPeriodid, pAccntid, pAmount);
74011
 
END;
74012
 
$_$;
74013
 
 
74014
 
 
74015
 
ALTER FUNCTION public.setbudget(integer, integer, numeric) OWNER TO admin;
74016
 
 
74017
 
--
74018
 
--
74019
 
 
74020
 
CREATE FUNCTION setbudget(integer, integer, integer, numeric) RETURNS integer
74021
 
    LANGUAGE plpgsql
74022
 
    AS $_$
74023
 
DECLARE
74024
 
  pBudgheadid ALIAS FOR $1;
74025
 
  pPeriodid ALIAS FOR $2;
74026
 
  pAccntid ALIAS FOR $3;
74027
 
  pAmount ALIAS FOR $4;
74028
 
  _budgetid INTEGER;
74029
 
 
74030
 
BEGIN
74031
 
 
74032
 
  SELECT budgitem_id INTO _budgetid
74033
 
    FROM budgitem
74034
 
   WHERE ((budgitem_period_id=pPeriodid)
74035
 
     AND  (budgitem_budghead_id=pBudgheadid)
74036
 
     AND  (budgitem_accnt_id=pAccntid));
74037
 
  IF (FOUND) THEN
74038
 
    UPDATE budgitem
74039
 
       SET budgitem_amount = pAmount
74040
 
     WHERE (budgitem_id=_budgetid);
74041
 
  ELSE
74042
 
    SELECT nextval('budgitem_budgitem_id_seq') INTO _budgetid;
74043
 
 
74044
 
    INSERT INTO budgitem
74045
 
          (budgitem_id, budgitem_budghead_id, budgitem_period_id, budgitem_accnt_id, budgitem_amount)
74046
 
    VALUES(_budgetid, pBudgheadid, pPeriodid, pAccntid, pAmount);
74047
 
  END IF;
74048
 
 
74049
 
  RETURN _budgetid;
74050
 
 
74051
 
END;
74052
 
$_$;
74053
 
 
74054
 
 
74055
 
ALTER FUNCTION public.setbudget(integer, integer, integer, numeric) OWNER TO admin;
74056
 
 
74057
 
--
74058
 
--
74059
 
 
74060
 
CREATE FUNCTION setbytea(text) RETURNS bytea
74061
 
    LANGUAGE plpgsql
74062
 
    AS $_$
74063
 
DECLARE
74064
 
  pMetricName ALIAS FOR $1;
74065
 
  _value bytea;
74066
 
 
74067
 
BEGIN
74068
 
 
74069
 
  _value := decode(pMetricName, 'escape');
74070
 
 
74071
 
  RETURN _value;
74072
 
 
74073
 
END;
74074
 
$_$;
74075
 
 
74076
 
 
74077
 
ALTER FUNCTION public.setbytea(text) OWNER TO admin;
74078
 
 
74079
 
--
74080
 
--
74081
 
 
74082
 
CREATE FUNCTION setbytea(bytea) RETURNS bytea
74083
 
    LANGUAGE plpgsql
74084
 
    AS $_$
74085
 
DECLARE
74086
 
  pMetricName ALIAS FOR $1;
74087
 
  _value bytea;
74088
 
 
74089
 
BEGIN
74090
 
 
74091
 
  _value := pMetricName;
74092
 
 
74093
 
  RETURN _value;
74094
 
 
74095
 
END;
74096
 
$_$;
74097
 
 
74098
 
 
74099
 
ALTER FUNCTION public.setbytea(bytea) OWNER TO admin;
74100
 
 
74101
 
--
74102
 
--
74103
 
 
74104
 
CREATE FUNCTION setccbankaccnt(text, integer) RETURNS integer
74105
 
    LANGUAGE plpgsql
74106
 
    AS $_$
74107
 
DECLARE
74108
 
  pccardtype   ALIAS FOR $1;
74109
 
  pbankaccntid ALIAS FOR $2;
74110
 
 
74111
 
  _ccbankid    INTEGER;
74112
 
  _numfound    INTEGER;
74113
 
 
74114
 
BEGIN
74115
 
  RAISE DEBUG 'setCCBankAccount(%, %) entered', pccardtype, pbankaccntid;
74116
 
  UPDATE ccbank SET ccbank_bankaccnt_id=pbankaccntid
74117
 
  WHERE ccbank_ccard_type=pccardtype
74118
 
  RETURNING ccbank_id INTO _ccbankid;
74119
 
 
74120
 
  GET DIAGNOSTICS _numfound = ROW_COUNT;
74121
 
 
74122
 
  IF (_numfound <= 0) THEN
74123
 
    INSERT INTO ccbank (ccbank_ccard_type, ccbank_bankaccnt_id)
74124
 
                VALUES (pccardtype,        pbankaccntid)
74125
 
    RETURNING ccbank_id INTO _ccbankid;
74126
 
  END IF;
74127
 
 
74128
 
  RETURN _ccbankid;
74129
 
END;
74130
 
$_$;
74131
 
 
74132
 
 
74133
 
ALTER FUNCTION public.setccbankaccnt(text, integer) OWNER TO admin;
74134
 
 
74135
 
--
74136
 
--
74137
 
 
74138
 
CREATE FUNCTION seteffectivextuser(text) RETURNS boolean
74139
 
    LANGUAGE plpgsql
74140
 
    AS $_$
74141
 
DECLARE
74142
 
  pUsername ALIAS FOR $1;
74143
 
BEGIN
74144
 
  PERFORM initEffectiveXtUser();
74145
 
 
74146
 
  PERFORM *
74147
 
     FROM effective_user
74148
 
    WHERE effective_key = 'username';
74149
 
 
74150
 
  IF FOUND THEN
74151
 
    UPDATE effective_user
74152
 
       SET effective_value = pUsername
74153
 
     WHERE effective_key = 'username';
74154
 
  ELSE
74155
 
    INSERT INTO effective_user (effective_key, effective_value)
74156
 
         VALUES('username', pUsername);
74157
 
  END IF;
74158
 
 
74159
 
  RETURN true;
74160
 
END;
74161
 
$_$;
74162
 
 
74163
 
 
74164
 
ALTER FUNCTION public.seteffectivextuser(text) OWNER TO admin;
74165
 
 
74166
 
--
74167
 
--
74168
 
 
74169
 
CREATE FUNCTION setgljournalnumber(date, date) RETURNS integer
74170
 
    LANGUAGE plpgsql
74171
 
    AS $_$
74172
 
DECLARE
74173
 
  pStartDate ALIAS FOR $1;
74174
 
  pEndDate ALIAS FOR $2;
74175
 
  _journalNumber INTEGER;
74176
 
 
74177
 
BEGIN
74178
 
 
74179
 
  SELECT fetchJournalNumber('G/L') INTO _journalNumber;
74180
 
 
74181
 
  UPDATE gltrans
74182
 
  SET gltrans_journalnumber=_journalNumber
74183
 
  WHERE ( (NOT gltrans_exported)
74184
 
    AND (gltrans_date BETWEEN pStartDate and pEndDate) );
74185
 
 
74186
 
  RETURN _journalNumber;
74187
 
 
74188
 
END;
74189
 
$_$;
74190
 
 
74191
 
 
74192
 
ALTER FUNCTION public.setgljournalnumber(date, date) OWNER TO admin;
74193
 
 
74194
 
--
74195
 
--
74196
 
 
74197
 
CREATE FUNCTION setmetric(text, text) RETURNS boolean
74198
 
    LANGUAGE plpgsql
74199
 
    AS $_$
74200
 
DECLARE
74201
 
  pMetricName ALIAS FOR $1;
74202
 
  pMetricValue ALIAS FOR $2;
74203
 
  _metricid INTEGER;
74204
 
 
74205
 
BEGIN
74206
 
 
74207
 
  SELECT metric_id INTO _metricid
74208
 
  FROM metric
74209
 
  WHERE (metric_name=pMetricName);
74210
 
 
74211
 
  IF (FOUND) THEN
74212
 
    UPDATE metric
74213
 
    SET metric_value=pMetricValue
74214
 
    WHERE (metric_id=_metricid);
74215
 
 
74216
 
  ELSE
74217
 
    INSERT INTO metric
74218
 
    (metric_name, metric_value)
74219
 
    VALUES (pMetricName, pMetricValue);
74220
 
  END IF;
74221
 
 
74222
 
  RETURN TRUE;
74223
 
 
74224
 
END;
74225
 
$_$;
74226
 
 
74227
 
 
74228
 
ALTER FUNCTION public.setmetric(text, text) OWNER TO admin;
74229
 
 
74230
 
--
74231
 
--
74232
 
 
74233
 
CREATE FUNCTION setmetricenc(text, text, text) RETURNS boolean
74234
 
    LANGUAGE plpgsql
74235
 
    AS $_$
74236
 
DECLARE
74237
 
  pMetricName ALIAS FOR $1;
74238
 
  pMetricValue ALIAS FOR $2;
74239
 
  pMetricEnc ALIAS FOR $3;
74240
 
  _metricid INTEGER;
74241
 
  _value bytea;
74242
 
  _key bytea;
74243
 
 
74244
 
BEGIN
74245
 
 
74246
 
  _value = decode(pMetricValue, 'escape');
74247
 
  _key = decode(pMetricEnc, 'escape');
74248
 
 
74249
 
  SELECT metricenc_id INTO _metricid
74250
 
  FROM metricenc
74251
 
  WHERE (metricenc_name=pMetricName);
74252
 
 
74253
 
  IF (FOUND) THEN
74254
 
    UPDATE metricenc
74255
 
    SET metricenc_value=encrypt(_value, _key, 'bf')
74256
 
    WHERE (metricenc_id=_metricid);
74257
 
 
74258
 
  ELSE
74259
 
    INSERT INTO metricenc
74260
 
    (metricenc_name, metricenc_value)
74261
 
    VALUES (pMetricName, encrypt(_value, _key, 'bf'));
74262
 
  END IF;
74263
 
 
74264
 
  RETURN TRUE;
74265
 
 
74266
 
END;
74267
 
$_$;
74268
 
 
74269
 
 
74270
 
ALTER FUNCTION public.setmetricenc(text, text, text) OWNER TO admin;
74271
 
 
74272
 
--
74273
 
--
74274
 
 
74275
 
CREATE FUNCTION setnextapmemonumber(integer) RETURNS integer
74276
 
    LANGUAGE plpgsql
74277
 
    AS $_$
74278
 
DECLARE
74279
 
  pNumber ALIAS FOR $1;
74280
 
  _orderseqid INTEGER;
74281
 
 
74282
 
BEGIN
74283
 
 
74284
 
  SELECT orderseq_id INTO _orderseqid
74285
 
  FROM orderseq
74286
 
  WHERE (orderseq_name='APMemoNumber');
74287
 
  IF (FOUND) THEN
74288
 
    UPDATE orderseq
74289
 
    SET orderseq_number=pNumber
74290
 
    WHERE (orderseq_id=_orderseqid);
74291
 
 
74292
 
  ELSE
74293
 
    INSERT INTO orderseq
74294
 
    (orderseq_name, orderseq_number)
74295
 
    VALUES
74296
 
    ('APMemoNumber', pNumber);
74297
 
  END IF;
74298
 
 
74299
 
  RETURN 1;
74300
 
 
74301
 
END;
74302
 
$_$;
74303
 
 
74304
 
 
74305
 
ALTER FUNCTION public.setnextapmemonumber(integer) OWNER TO admin;
74306
 
 
74307
 
--
74308
 
--
74309
 
 
74310
 
CREATE FUNCTION setnextarmemonumber(integer) RETURNS integer
74311
 
    LANGUAGE plpgsql
74312
 
    AS $_$
74313
 
DECLARE
74314
 
  pNumber ALIAS FOR $1;
74315
 
  _orderseqid INTEGER;
74316
 
 
74317
 
BEGIN
74318
 
 
74319
 
  SELECT orderseq_id INTO _orderseqid
74320
 
  FROM orderseq
74321
 
  WHERE (orderseq_name='ARMemoNumber');
74322
 
  IF (FOUND) THEN
74323
 
    UPDATE orderseq
74324
 
    SET orderseq_number=pNumber
74325
 
    WHERE (orderseq_id=_orderseqid);
74326
 
 
74327
 
  ELSE
74328
 
    INSERT INTO orderseq
74329
 
    (orderseq_name, orderseq_number)
74330
 
    VALUES
74331
 
    ('ARMemoNumber', pNumber);
74332
 
  END IF;
74333
 
 
74334
 
  RETURN 1;
74335
 
 
74336
 
END;
74337
 
$_$;
74338
 
 
74339
 
 
74340
 
ALTER FUNCTION public.setnextarmemonumber(integer) OWNER TO admin;
74341
 
 
74342
 
--
74343
 
--
74344
 
 
74345
 
CREATE FUNCTION setnextcashrcptnumber(integer) RETURNS integer
74346
 
    LANGUAGE plpgsql
74347
 
    AS $_$
74348
 
DECLARE
74349
 
  pNumber ALIAS FOR $1;
74350
 
  _orderseqid INTEGER;
74351
 
 
74352
 
BEGIN
74353
 
 
74354
 
  SELECT orderseq_id INTO _orderseqid
74355
 
  FROM orderseq
74356
 
  WHERE (orderseq_name='CashRcptNumber');
74357
 
  IF (FOUND) THEN
74358
 
    UPDATE orderseq
74359
 
    SET orderseq_number=pNumber
74360
 
    WHERE (orderseq_id=_orderseqid);
74361
 
 
74362
 
  ELSE
74363
 
    INSERT INTO orderseq
74364
 
    (orderseq_name, orderseq_number)
74365
 
    VALUES
74366
 
    ('CashRcptNumber', pNumber);
74367
 
  END IF;
74368
 
 
74369
 
  RETURN 1;
74370
 
 
74371
 
END;
74372
 
$_$;
74373
 
 
74374
 
 
74375
 
ALTER FUNCTION public.setnextcashrcptnumber(integer) OWNER TO admin;
74376
 
 
74377
 
--
74378
 
--
74379
 
 
74380
 
CREATE FUNCTION setnextchecknumber(pbankaccntid integer, pnextchecknumber integer) RETURNS boolean
74381
 
    LANGUAGE plpgsql
74382
 
    AS $$
74383
 
DECLARE
74384
 
  _nextChkNumber INTEGER;
74385
 
  _checkheadid INTEGER;
74386
 
 
74387
 
BEGIN
74388
 
 
74389
 
  _nextChkNumber := pNextCheckNumber;
74390
 
 
74391
 
  WHILE (TRUE) LOOP
74392
 
    SELECT checkhead_id INTO _checkheadid
74393
 
    FROM checkhead
74394
 
    WHERE (checkhead_number=_nextChkNumber)
74395
 
      AND (checkhead_bankaccnt_id=pBankaccntid);
74396
 
    IF (NOT FOUND) THEN
74397
 
      EXIT;
74398
 
    ELSE
74399
 
      _nextChkNumber := _nextChkNumber + 1;
74400
 
    END IF;
74401
 
  END LOOP;
74402
 
 
74403
 
  UPDATE bankaccnt
74404
 
  SET bankaccnt_nextchknum=_nextChkNumber
74405
 
  WHERE (bankaccnt_id=pBankaccntid);
74406
 
 
74407
 
  RETURN TRUE;
74408
 
 
74409
 
END;
74410
 
$$;
74411
 
 
74412
 
 
74413
 
ALTER FUNCTION public.setnextchecknumber(pbankaccntid integer, pnextchecknumber integer) OWNER TO admin;
74414
 
 
74415
 
--
74416
 
--
74417
 
 
74418
 
CREATE FUNCTION setnextcmnumber(integer) RETURNS integer
74419
 
    LANGUAGE plpgsql
74420
 
    AS $_$
74421
 
DECLARE
74422
 
  pNumber ALIAS FOR $1;
74423
 
  _orderseqid INTEGER;
74424
 
 
74425
 
BEGIN
74426
 
 
74427
 
  SELECT orderseq_id INTO _orderseqid
74428
 
  FROM orderseq
74429
 
  WHERE (orderseq_name='CmNumber');
74430
 
 
74431
 
  IF (NOT FOUND) THEN
74432
 
    SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid;
74433
 
 
74434
 
    INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number)
74435
 
    VALUES (_orderseqid, 'CmNumber', pNumber);
74436
 
 
74437
 
  ELSE
74438
 
    UPDATE orderseq
74439
 
    SET orderseq_number=pNumber
74440
 
    WHERE (orderseq_name='CmNumber');
74441
 
  END IF;
74442
 
 
74443
 
  RETURN _orderseqid;
74444
 
 
74445
 
END;
74446
 
$_$;
74447
 
 
74448
 
 
74449
 
ALTER FUNCTION public.setnextcmnumber(integer) OWNER TO admin;
74450
 
 
74451
 
--
74452
 
--
74453
 
 
74454
 
CREATE FUNCTION setnextcrmaccountnumber(integer) RETURNS integer
74455
 
    LANGUAGE plpgsql
74456
 
    AS $_$
74457
 
DECLARE
74458
 
  pNumber ALIAS FOR $1;
74459
 
  _orderseqid INTEGER;
74460
 
 
74461
 
BEGIN
74462
 
 
74463
 
  SELECT orderseq_id INTO _orderseqid
74464
 
  FROM orderseq
74465
 
  WHERE (orderseq_name='CRMAccountNumber');
74466
 
 
74467
 
  IF (NOT FOUND) THEN
74468
 
    SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid;
74469
 
 
74470
 
    INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number)
74471
 
    VALUES (_orderseqid, 'CRMAccountNumber', pNumber);
74472
 
 
74473
 
  ELSE
74474
 
    UPDATE orderseq
74475
 
    SET orderseq_number=pNumber
74476
 
    WHERE (orderseq_name='CRMAccountNumber');
74477
 
  END IF;
74478
 
 
74479
 
  RETURN _orderseqid;
74480
 
 
74481
 
END;
74482
 
$_$;
74483
 
 
74484
 
 
74485
 
ALTER FUNCTION public.setnextcrmaccountnumber(integer) OWNER TO admin;
74486
 
 
74487
 
--
74488
 
--
74489
 
 
74490
 
CREATE FUNCTION setnextincidentnumber(integer) RETURNS integer
74491
 
    LANGUAGE plpgsql
74492
 
    AS $_$
74493
 
DECLARE
74494
 
  pNumber ALIAS FOR $1;
74495
 
  _orderseqid INTEGER;
74496
 
 
74497
 
BEGIN
74498
 
 
74499
 
  SELECT orderseq_id INTO _orderseqid
74500
 
  FROM orderseq
74501
 
  WHERE (orderseq_name='IncidentNumber');
74502
 
 
74503
 
  IF (NOT FOUND) THEN
74504
 
    SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid;
74505
 
 
74506
 
    INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number)
74507
 
    VALUES (_orderseqid, 'IncidentNumber', pNumber);
74508
 
 
74509
 
  ELSE
74510
 
    UPDATE orderseq
74511
 
    SET orderseq_number=pNumber
74512
 
    WHERE (orderseq_name='IncidentNumber');
74513
 
  END IF;
74514
 
 
74515
 
  RETURN _orderseqid;
74516
 
 
74517
 
END;
74518
 
$_$;
74519
 
 
74520
 
 
74521
 
ALTER FUNCTION public.setnextincidentnumber(integer) OWNER TO admin;
74522
 
 
74523
 
--
74524
 
--
74525
 
 
74526
 
CREATE FUNCTION setnextinvcnumber(integer) RETURNS integer
74527
 
    LANGUAGE plpgsql
74528
 
    AS $_$
74529
 
DECLARE
74530
 
  pNumber ALIAS FOR $1;
74531
 
  _orderseqid INTEGER;
74532
 
 
74533
 
BEGIN
74534
 
 
74535
 
  SELECT orderseq_id INTO _orderseqid
74536
 
  FROM orderseq
74537
 
  WHERE (orderseq_name='InvcNumber');
74538
 
 
74539
 
  IF (NOT FOUND) THEN
74540
 
    SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid;
74541
 
 
74542
 
    INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number)
74543
 
    VALUES (_orderseqid, 'InvcNumber', pNumber);
74544
 
 
74545
 
  ELSE
74546
 
    UPDATE orderseq
74547
 
    SET orderseq_number=pNumber
74548
 
    WHERE (orderseq_name='InvcNumber');
74549
 
  END IF;
74550
 
 
74551
 
  RETURN _orderseqid;
74552
 
 
74553
 
END;
74554
 
$_$;
74555
 
 
74556
 
 
74557
 
ALTER FUNCTION public.setnextinvcnumber(integer) OWNER TO admin;
74558
 
 
74559
 
--
74560
 
--
74561
 
 
74562
 
CREATE FUNCTION setnextnumber(text, integer) RETURNS integer
74563
 
    LANGUAGE plpgsql
74564
 
    AS $_$
74565
 
DECLARE
74566
 
  psequence     ALIAS FOR $1;
74567
 
  pnumber       ALIAS FOR $2;
74568
 
  _orderseqid   INTEGER;
74569
 
 
74570
 
BEGIN
74571
 
  SELECT orderseq_id INTO _orderseqid
74572
 
  FROM orderseq
74573
 
  WHERE (orderseq_name=psequence);
74574
 
 
74575
 
  IF (NOT FOUND) THEN
74576
 
    INSERT INTO orderseq (orderseq_name, orderseq_number,
74577
 
                          orderseq_table, orderseq_numcol)
74578
 
                  VALUES (psequence,     pnumber,
74579
 
                          CASE WHEN (psequence='APMemoNumber') THEN 'apopen'
74580
 
                               WHEN (psequence='ARMemoNumber') THEN 'aropen'
74581
 
                               WHEN (psequence='CmNumber') THEN 'cmhead'
74582
 
                               WHEN (psequence='IncidentNumber') THEN 'incdt'
74583
 
                               WHEN (psequence='InvcNumber') THEN 'invchead'
74584
 
                               WHEN (psequence='JournalNumber') THEN 'gltrans'
74585
 
                               WHEN (psequence='PlanNumber') THEN 'planord'
74586
 
                               WHEN (psequence='PoNumber') THEN 'pohead'
74587
 
                               WHEN (psequence='PrNumber') THEN 'pr'
74588
 
                               WHEN (psequence='QuNumber') THEN 'quhead'
74589
 
                               WHEN (psequence='ShipmentNumber') THEN 'shiphead'
74590
 
                               WHEN (psequence='SoNumber') THEN 'cohead'
74591
 
                               WHEN (psequence='ToNumber') THEN 'tohead'
74592
 
                               WHEN (psequence='VcNumber') THEN 'vohead'
74593
 
                               WHEN (psequence='WoNumber') THEN 'wo'
74594
 
                               ELSE ''
74595
 
                          END,
74596
 
                          CASE WHEN (psequence='APMemoNumber') THEN 'apopen_docnumber'
74597
 
                               WHEN (psequence='ARMemoNumber') THEN 'aropen_docnumber'
74598
 
                               WHEN (psequence='CmNumber') THEN 'cmhead_number'
74599
 
                               WHEN (psequence='IncidentNumber') THEN 'incdt_number'
74600
 
                               WHEN (psequence='InvcNumber') THEN 'invchead_invcnumber'
74601
 
                               WHEN (psequence='JournalNumber') THEN 'gltrans_journalnumber'
74602
 
                               WHEN (psequence='PlanNumber') THEN 'planord_number'
74603
 
                               WHEN (psequence='PoNumber') THEN 'pohead_number'
74604
 
                               WHEN (psequence='PrNumber') THEN 'pr_number'
74605
 
                               WHEN (psequence='QuNumber') THEN 'quhead_number'
74606
 
                               WHEN (psequence='ShipmentNumber') THEN 'shiphead_number'
74607
 
                               WHEN (psequence='SoNumber') THEN 'cohead_number'
74608
 
                               WHEN (psequence='ToNumber') THEN 'tohead_number'
74609
 
                               WHEN (psequence='VcNumber') THEN 'vohead_number'
74610
 
                               WHEN (psequence='WoNumber') THEN 'wo_number'
74611
 
                               ELSE ''
74612
 
                          END
74613
 
                          );
74614
 
  ELSE
74615
 
    UPDATE orderseq
74616
 
    SET orderseq_number=pnumber
74617
 
    WHERE (orderseq_name=psequence);
74618
 
  END IF;
74619
 
 
74620
 
  RETURN 0;
74621
 
END;
74622
 
$_$;
74623
 
 
74624
 
 
74625
 
ALTER FUNCTION public.setnextnumber(text, integer) OWNER TO admin;
74626
 
 
74627
 
--
74628
 
--
74629
 
 
74630
 
CREATE FUNCTION setnextponumber(integer) RETURNS integer
74631
 
    LANGUAGE plpgsql
74632
 
    AS $_$
74633
 
DECLARE
74634
 
  pNumber ALIAS FOR $1;
74635
 
  _orderseqid INTEGER;
74636
 
 
74637
 
BEGIN
74638
 
 
74639
 
  SELECT orderseq_id INTO _orderseqid
74640
 
  FROM orderseq
74641
 
  WHERE (orderseq_name='PoNumber');
74642
 
 
74643
 
  IF (NOT FOUND) THEN
74644
 
    SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid;
74645
 
    INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number)
74646
 
    VALUES (_orderseqid, 'PoNumber', pNumber);
74647
 
 
74648
 
  ELSE
74649
 
    UPDATE orderseq
74650
 
    SET orderseq_number=pNumber
74651
 
    WHERE (orderseq_name='PoNumber');
74652
 
  END IF;
74653
 
 
74654
 
  RETURN _orderseqid;
74655
 
 
74656
 
END;
74657
 
$_$;
74658
 
 
74659
 
 
74660
 
ALTER FUNCTION public.setnextponumber(integer) OWNER TO admin;
74661
 
 
74662
 
--
74663
 
--
74664
 
 
74665
 
CREATE FUNCTION setnextprnumber(integer) RETURNS integer
74666
 
    LANGUAGE plpgsql
74667
 
    AS $_$
74668
 
DECLARE
74669
 
  pNumber ALIAS FOR $1;
74670
 
  _orderseqid INTEGER;
74671
 
 
74672
 
BEGIN
74673
 
 
74674
 
  SELECT orderseq_id INTO _orderseqid
74675
 
  FROM orderseq
74676
 
  WHERE (orderseq_name='PrNumber');
74677
 
 
74678
 
  IF (NOT FOUND) THEN
74679
 
    SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid;
74680
 
    INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number)
74681
 
    VALUES (_orderseqid, 'PrNumber', pNumber);
74682
 
 
74683
 
  ELSE
74684
 
    UPDATE orderseq
74685
 
    SET orderseq_number=pNumber
74686
 
    WHERE (orderseq_name='PrNumber');
74687
 
  END IF;
74688
 
 
74689
 
  RETURN _orderseqid;
74690
 
 
74691
 
END;
74692
 
$_$;
74693
 
 
74694
 
 
74695
 
ALTER FUNCTION public.setnextprnumber(integer) OWNER TO admin;
74696
 
 
74697
 
--
74698
 
--
74699
 
 
74700
 
CREATE FUNCTION setnextqunumber(integer) RETURNS integer
74701
 
    LANGUAGE plpgsql
74702
 
    AS $_$
74703
 
DECLARE
74704
 
  pQuNumber ALIAS FOR $1;
74705
 
  _orderseqid INTEGER;
74706
 
 
74707
 
BEGIN
74708
 
 
74709
 
  SELECT orderseq_id INTO _orderseqid
74710
 
  FROM orderseq
74711
 
  WHERE (orderseq_name='QuNumber');
74712
 
 
74713
 
  IF (NOT FOUND) THEN
74714
 
    SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid;
74715
 
 
74716
 
    INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number)
74717
 
    VALUES (_orderseqid, 'QuNumber', pQuNumber);
74718
 
 
74719
 
  ELSE
74720
 
    UPDATE orderseq
74721
 
    SET orderseq_number=pQuNumber
74722
 
    WHERE (orderseq_name='QuNumber');
74723
 
  END IF;
74724
 
 
74725
 
  RETURN _orderseqid;
74726
 
 
74727
 
END;
74728
 
$_$;
74729
 
 
74730
 
 
74731
 
ALTER FUNCTION public.setnextqunumber(integer) OWNER TO admin;
74732
 
 
74733
 
--
74734
 
--
74735
 
 
74736
 
CREATE FUNCTION setnextshipmentnumber(integer) RETURNS integer
74737
 
    LANGUAGE plpgsql
74738
 
    AS $_$
74739
 
DECLARE
74740
 
  pShipmentNumber ALIAS FOR $1;
74741
 
  _orderseqid INTEGER;
74742
 
 
74743
 
BEGIN
74744
 
 
74745
 
  SELECT orderseq_id INTO _orderseqid
74746
 
  FROM orderseq
74747
 
  WHERE (orderseq_name='ShipmentNumber');
74748
 
 
74749
 
  IF (NOT FOUND) THEN
74750
 
    SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid;
74751
 
 
74752
 
    INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number)
74753
 
    VALUES (_orderseqid, 'ShipmentNumber', pShipmentNumber);
74754
 
 
74755
 
  ELSE
74756
 
    UPDATE orderseq
74757
 
    SET orderseq_number=pShipmentNumber
74758
 
    WHERE (orderseq_name='ShipmentNumber');
74759
 
  END IF;
74760
 
 
74761
 
  RETURN _orderseqid;
74762
 
 
74763
 
END;
74764
 
$_$;
74765
 
 
74766
 
 
74767
 
ALTER FUNCTION public.setnextshipmentnumber(integer) OWNER TO admin;
74768
 
 
74769
 
--
74770
 
--
74771
 
 
74772
 
CREATE FUNCTION setnextsonumber(integer) RETURNS integer
74773
 
    LANGUAGE plpgsql
74774
 
    AS $_$
74775
 
DECLARE
74776
 
  pSoNumber ALIAS FOR $1;
74777
 
  _orderseqid INTEGER;
74778
 
 
74779
 
BEGIN
74780
 
 
74781
 
  SELECT orderseq_id INTO _orderseqid
74782
 
  FROM orderseq
74783
 
  WHERE (orderseq_name='SoNumber');
74784
 
 
74785
 
  IF (NOT FOUND) THEN
74786
 
    SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid;
74787
 
 
74788
 
    INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number)
74789
 
    VALUES (_orderseqid, 'SoNumber', pSoNumber);
74790
 
 
74791
 
  ELSE
74792
 
    UPDATE orderseq
74793
 
    SET orderseq_number=pSoNumber
74794
 
    WHERE (orderseq_name='SoNumber');
74795
 
  END IF;
74796
 
 
74797
 
  RETURN _orderseqid;
74798
 
 
74799
 
END;
74800
 
$_$;
74801
 
 
74802
 
 
74803
 
ALTER FUNCTION public.setnextsonumber(integer) OWNER TO admin;
74804
 
 
74805
 
--
74806
 
--
74807
 
 
74808
 
CREATE FUNCTION setnextvcnumber(integer) RETURNS integer
74809
 
    LANGUAGE plpgsql
74810
 
    AS $_$
74811
 
DECLARE
74812
 
  pNumber ALIAS FOR $1;
74813
 
  _orderseqid INTEGER;
74814
 
 
74815
 
BEGIN
74816
 
 
74817
 
  SELECT orderseq_id INTO _orderseqid
74818
 
  FROM orderseq
74819
 
  WHERE (orderseq_name='VcNumber');
74820
 
 
74821
 
  IF (NOT FOUND) THEN
74822
 
    SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid;
74823
 
    INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number)
74824
 
    VALUES (_orderseqid, 'VcNumber', pNumber);
74825
 
 
74826
 
  ELSE
74827
 
    UPDATE orderseq
74828
 
    SET orderseq_number=pNumber
74829
 
    WHERE (orderseq_name='VcNumber');
74830
 
  END IF;
74831
 
 
74832
 
  RETURN _orderseqid;
74833
 
 
74834
 
END;
74835
 
$_$;
74836
 
 
74837
 
 
74838
 
ALTER FUNCTION public.setnextvcnumber(integer) OWNER TO admin;
74839
 
 
74840
 
--
74841
 
--
74842
 
 
74843
 
CREATE FUNCTION setnextwonumber(integer) RETURNS integer
74844
 
    LANGUAGE plpgsql
74845
 
    AS $_$
74846
 
DECLARE
74847
 
  pWoNumber ALIAS FOR $1;
74848
 
  _orderseqid INTEGER;
74849
 
 
74850
 
BEGIN
74851
 
 
74852
 
  SELECT orderseq_id INTO _orderseqid
74853
 
  FROM orderseq
74854
 
  WHERE (orderseq_name='WoNumber');
74855
 
 
74856
 
  IF (NOT FOUND) THEN
74857
 
    SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid;
74858
 
 
74859
 
    INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number)
74860
 
    VALUES (_orderseqid, 'WoNumber', pWoNumber);
74861
 
 
74862
 
  ELSE
74863
 
    UPDATE orderseq
74864
 
    SET orderseq_number=pWoNumber
74865
 
    WHERE (orderseq_name='WoNumber');
74866
 
  END IF;
74867
 
 
74868
 
  RETURN _orderseqid;
74869
 
 
74870
 
END;
74871
 
$_$;
74872
 
 
74873
 
 
74874
 
ALTER FUNCTION public.setnextwonumber(integer) OWNER TO admin;
74875
 
 
74876
 
--
74877
 
--
74878
 
 
74879
 
CREATE FUNCTION setusercancreateusers(pusername text, pcreateuser boolean) RETURNS boolean
74880
 
    LANGUAGE plpgsql
74881
 
    AS $$
74882
 
BEGIN
74883
 
  IF (pCreateUser) THEN
74884
 
    EXECUTE 'ALTER USER "' || pUsername || '" CREATEROLE;';
74885
 
  ELSE
74886
 
    EXECUTE 'ALTER USER "' || pUsername || '" NOCREATEROLE;';
74887
 
  END IF;
74888
 
  RETURN TRUE;
74889
 
END;
74890
 
$$;
74891
 
 
74892
 
 
74893
 
ALTER FUNCTION public.setusercancreateusers(pusername text, pcreateuser boolean) OWNER TO admin;
74894
 
 
74895
 
--
74896
 
--
74897
 
 
74898
 
CREATE FUNCTION setuserpreference(text, text) RETURNS boolean
74899
 
    LANGUAGE plpgsql
74900
 
    AS $_$
74901
 
DECLARE
74902
 
  pPrefName ALIAS FOR $1;
74903
 
  pPrefValue ALIAS FOR $2;
74904
 
 
74905
 
BEGIN
74906
 
  RETURN setUserPreferences(getEffectiveXtUser(), pPrefName, pPrefValue);
74907
 
END;
74908
 
$_$;
74909
 
 
74910
 
 
74911
 
ALTER FUNCTION public.setuserpreference(text, text) OWNER TO admin;
74912
 
 
74913
 
--
74914
 
--
74915
 
 
74916
 
CREATE FUNCTION setuserpreference(text, text, text) RETURNS boolean
74917
 
    LANGUAGE plpgsql
74918
 
    AS $_$
74919
 
DECLARE
74920
 
  pUsername ALIAS FOR $1;
74921
 
  pPrefName ALIAS FOR $2;
74922
 
  pPrefValue ALIAS FOR $3;
74923
 
  _usrprefid INTEGER;
74924
 
 
74925
 
BEGIN
74926
 
 
74927
 
  SELECT usrpref_id INTO _usrprefid
74928
 
  FROM usrpref
74929
 
  WHERE ( (usrpref_username=pUsername)
74930
 
   AND (usrpref_name=pPrefName) );
74931
 
 
74932
 
  IF (FOUND) THEN
74933
 
    UPDATE usrpref
74934
 
    SET usrpref_value=pPrefValue
74935
 
    WHERE (usrpref_id=_usrprefid);
74936
 
 
74937
 
  ELSE
74938
 
    INSERT INTO usrpref
74939
 
    (usrpref_username, usrpref_name, usrpref_value)
74940
 
    VALUES
74941
 
    (pUsername, pPrefName, pPrefValue);
74942
 
  END IF;
74943
 
 
74944
 
  RETURN TRUE;
74945
 
 
74946
 
END;
74947
 
$_$;
74948
 
 
74949
 
 
74950
 
ALTER FUNCTION public.setuserpreference(text, text, text) OWNER TO admin;
74951
 
 
74952
 
--
74953
 
--
74954
 
 
74955
 
CREATE FUNCTION shipments(text) RETURNS boolean
74956
 
    LANGUAGE plpgsql
74957
 
    AS $_$
74958
 
DECLARE
74959
 
  pTransType ALIAS FOR $1;
74960
 
 
74961
 
BEGIN
74962
 
  IF (pTransType IN ('SC', 'SV', 'SH', 'RS', 'TS')) THEN
74963
 
    RETURN TRUE;
74964
 
  ELSE
74965
 
    RETURN FALSE;
74966
 
  END IF;
74967
 
 
74968
 
END;
74969
 
$_$;
74970
 
 
74971
 
 
74972
 
ALTER FUNCTION public.shipments(text) OWNER TO admin;
74973
 
 
74974
 
--
74975
 
--
74976
 
 
74977
 
CREATE FUNCTION shipshipment(integer) RETURNS integer
74978
 
    LANGUAGE sql
74979
 
    AS $_$
74980
 
  SELECT shipShipment($1, CURRENT_TIMESTAMP);
74981
 
$_$;
74982
 
 
74983
 
 
74984
 
ALTER FUNCTION public.shipshipment(integer) OWNER TO admin;
74985
 
 
74986
 
--
74987
 
--
74988
 
 
74989
 
CREATE FUNCTION shipshipment(integer, timestamp with time zone) RETURNS integer
74990
 
    LANGUAGE plpgsql
74991
 
    AS $_$
74992
 
DECLARE
74993
 
  pshipheadid           ALIAS FOR $1;
74994
 
  _timestamp            TIMESTAMP WITH TIME ZONE := $2;
74995
 
 
74996
 
  _billedQty            NUMERIC;
74997
 
  _c                    RECORD;
74998
 
  _coholdtype           TEXT;
74999
 
  _gldate               DATE;
75000
 
  _invhistid            INTEGER;
75001
 
  _itemlocSeries        INTEGER;
75002
 
  _lineitemsToClose     INTEGER[];
75003
 
  _newQty               NUMERIC;
75004
 
  _result               INTEGER;
75005
 
  _s                    RECORD;
75006
 
  _shipcomplete         BOOLEAN;
75007
 
  _shiphead             RECORD;
75008
 
  _ti                   RECORD;
75009
 
  _to                   RECORD;
75010
 
  _variance             NUMERIC;
75011
 
  _k                    RECORD;
75012
 
 
75013
 
BEGIN
75014
 
 
75015
 
  IF (_timestamp IS NULL) THEN
75016
 
    _timestamp := CURRENT_TIMESTAMP;
75017
 
  END IF;
75018
 
  _gldate := _timestamp::DATE;
75019
 
 
75020
 
  SELECT * INTO _shiphead
75021
 
  FROM shiphead WHERE (shiphead_id=pshipheadid);
75022
 
  IF (NOT FOUND) THEN
75023
 
    RETURN -50;
75024
 
  END IF;
75025
 
 
75026
 
  IF (_shiphead.shiphead_order_type = 'SO') THEN
75027
 
 
75028
 
    SELECT cohead_shipcomplete, cohead_holdtype INTO _shipcomplete, _coholdtype
75029
 
      FROM cohead, shiphead
75030
 
     WHERE ((shiphead_order_id=cohead_id)
75031
 
       AND  (NOT shiphead_shipped)
75032
 
       AND  (shiphead_order_type=_shiphead.shiphead_order_type)
75033
 
       AND  (shiphead_id=pshipheadid));
75034
 
 
75035
 
    IF (_coholdtype = 'C') THEN
75036
 
      RETURN -12;
75037
 
    ELSIF (_coholdtype = 'P') THEN
75038
 
      RETURN -13;
75039
 
    ELSIF (_coholdtype = 'R') THEN
75040
 
      RETURN -14;
75041
 
    ELSIF (_coholdtype = 'S') THEN
75042
 
      RETURN -15;
75043
 
    END IF;
75044
 
 
75045
 
---Must Ship Kit components (coitem_subnumber <> 0 complete---------------
75046
 
    IF ((
75047
 
         --  Test to see if order's customer accepts backorders and partials 
75048
 
         --  If not then test for shipping kit components complete 
75049
 
        SELECT cohead_number
75050
 
        FROM shiphead, cohead, custinfo
75051
 
        WHERE 
75052
 
          (shiphead_order_id = cohead_id) AND
75053
 
          (cohead_cust_id = cust_id) AND
75054
 
          (shiphead_order_type = 'SO') AND 
75055
 
          (cust_partialship) AND
75056
 
          (cust_backorder) AND
75057
 
          (shiphead_id = pshipheadid)
75058
 
         ) IS NULL) THEN
75059
 
      FOR _k IN SELECT (coitem_qtyord -
75060
 
                        (COALESCE(SUM(shipitem_qty),0) +
75061
 
                         (coitem_qtyshipped - coitem_qtyreturned))) AS remain
75062
 
                  FROM (coitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id)) ON (coitem_itemsite_id=itemsite_id)) LEFT OUTER JOIN
75063
 
                       shipitem ON (shipitem_orderitem_id=coitem_id
75064
 
                                AND shipitem_shiphead_id=pshipheadid)
75065
 
                 WHERE ((coitem_status NOT IN ('C','X'))
75066
 
                   AND  (item_type != 'K')
75067
 
                   AND  (coitem_cohead_id=_shiphead.shiphead_order_id)
75068
 
                   AND  (coitem_subnumber <> 0)
75069
 
                   )
75070
 
              GROUP BY coitem_id, coitem_qtyshipped, coitem_qtyord,
75071
 
                       coitem_qtyreturned LOOP
75072
 
        IF (_k.remain > 0) THEN
75073
 
          RAISE EXCEPTION 'Kit component item not shipped complete.  Kits must be shipped and shipped complete or closed on the order.';
75074
 
        END IF;
75075
 
      END LOOP;
75076
 
    END IF;
75077
 
---End--------------------------------------------------------------------
75078
 
 
75079
 
    IF ( _shipcomplete ) THEN
75080
 
      FOR _c IN SELECT (coitem_qtyord -
75081
 
                        (COALESCE(SUM(shipitem_qty),0) +
75082
 
                         (coitem_qtyshipped - coitem_qtyreturned))) AS remain
75083
 
                  FROM (coitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id)) ON (coitem_itemsite_id=itemsite_id)) LEFT OUTER JOIN
75084
 
                       shipitem ON (shipitem_orderitem_id=coitem_id
75085
 
                                AND shipitem_shiphead_id=pshipheadid)
75086
 
                 WHERE ((coitem_status<>'X')
75087
 
                   AND  (item_type != 'K')
75088
 
                   AND  (coitem_cohead_id=_shiphead.shiphead_order_id))
75089
 
              GROUP BY coitem_id, coitem_qtyshipped, coitem_qtyord,
75090
 
                       coitem_qtyreturned LOOP
75091
 
        IF (_c.remain > 0) THEN
75092
 
          RETURN -99;
75093
 
        END IF;
75094
 
      END LOOP;
75095
 
    END IF;
75096
 
 
75097
 
    FOR _c IN SELECT coitem_id, cohead_number, cohead_cust_id, cohead_billtoname, cohead_prj_id,
75098
 
                     cohead_saletype_id, cohead_shipzone_id,
75099
 
                     itemsite_id, itemsite_item_id,
75100
 
                     coitem_qty_invuomratio,
75101
 
                     coitem_warranty, coitem_cos_accnt_id,
75102
 
                     SUM(shipitem_qty) AS _qty,
75103
 
                     SUM(shipitem_value) AS _value
75104
 
              FROM coitem, cohead, shiphead, shipitem, itemsite
75105
 
              WHERE ( (coitem_cohead_id=cohead_id)
75106
 
               AND (coitem_itemsite_id=itemsite_id)
75107
 
               AND (shiphead_order_id=cohead_id)
75108
 
               AND (shipitem_shiphead_id=shiphead_id)
75109
 
               AND (shipitem_orderitem_id=coitem_id)
75110
 
               AND (NOT shiphead_shipped)
75111
 
               AND (shiphead_id=pshipheadid) )
75112
 
              GROUP BY coitem_id, coitem_qty_invuomratio, cohead_number, cohead_cust_id, cohead_billtoname,
75113
 
           itemsite_id, itemsite_item_id, coitem_warranty, coitem_cos_accnt_id, cohead_prj_id, cohead_saletype_id, cohead_shipzone_id
75114
 
    LOOP
75115
 
 
75116
 
      IF _c._value > 0 THEN
75117
 
  --    Distribute to G/L, credit Shipping Asset, debit COS
75118
 
        SELECT MIN(insertGLTransaction( 'S/R', 'SH', _shiphead.shiphead_number,
75119
 
                                        ('Ship Order ' || _c.cohead_number || ' for Customer ' || _c.cohead_billtoname),
75120
 
                                        getPrjAccntId(_c.cohead_prj_id, costcat_shipasset_accnt_id),
75121
 
                                        CASE WHEN (COALESCE(_c.coitem_cos_accnt_id, -1) != -1)
75122
 
                                               THEN getPrjAccntId(_c.cohead_prj_id, _c.coitem_cos_accnt_id)
75123
 
                                             WHEN (_c.coitem_warranty=TRUE)
75124
 
                                               THEN getPrjAccntId(_c.cohead_prj_id, resolveCOWAccount(itemsite_id, _c.cohead_cust_id, _c.cohead_saletype_id, _c.cohead_shipzone_id))
75125
 
                                             ELSE getPrjAccntId(_c.cohead_prj_id, resolveCOSAccount(itemsite_id, _c.cohead_cust_id, _c.cohead_saletype_id, _c.cohead_shipzone_id))
75126
 
                                        END,
75127
 
                                        -1, _c._value, _gldate )) INTO _result
75128
 
        FROM itemsite, costcat
75129
 
        WHERE ( (itemsite_costcat_id=costcat_id)
75130
 
        AND (itemsite_id=_c.itemsite_id) );
75131
 
 
75132
 
        IF (_result < 0 AND _result != -3) THEN -- ignore -3 as it just means it's not posting a 0 value
75133
 
          RETURN _result;
75134
 
        END IF;
75135
 
 
75136
 
      END IF;
75137
 
 
75138
 
      UPDATE coitem
75139
 
      SET coitem_qtyshipped = (coitem_qtyshipped + _c._qty)
75140
 
      WHERE (coitem_id=_c.coitem_id);
75141
 
 
75142
 
      -- check to see if we have more invoiced than shipped items
75143
 
      -- if we do we will need to mark some of these records as invoiced
75144
 
      SELECT noNeg(( SELECT COALESCE(SUM(cobill_qty), 0.0)
75145
 
                     FROM cobill, cobmisc, coitem
75146
 
                     WHERE ( (cobill_cobmisc_id=cobmisc_id)
75147
 
                      AND (cobmisc_cohead_id=coitem_cohead_id)
75148
 
                      AND (cobill_coitem_id=coitem_id)
75149
 
                      AND (cobmisc_posted)
75150
 
                      AND (coitem_id=_c.coitem_id) )
75151
 
                   ) - ( SELECT COALESCE(SUM(shipitem_qty), 0.0)
75152
 
                         FROM shipitem, shiphead, coitem
75153
 
                         WHERE ( (shipitem_shiphead_id=shiphead_id)
75154
 
                          AND (shiphead_order_id=coitem_cohead_id)
75155
 
                          AND (shipitem_orderitem_id=coitem_id)
75156
 
                          AND (shiphead_order_type=_shiphead.shiphead_order_type)
75157
 
                          AND (shiphead_shipped)
75158
 
                          AND (coitem_id=_c.coitem_id) )
75159
 
                       ) ) INTO _billedQty;
75160
 
 
75161
 
      IF (_billedQty > 0.0) THEN
75162
 
        FOR _s IN SELECT shipitem_id, shipitem_qty
75163
 
                  FROM shipitem, shiphead
75164
 
                  WHERE ( (shipitem_shiphead_id=shiphead_id)
75165
 
                   AND (shipitem_orderitem_id=_c.coitem_id)
75166
 
                   AND (shiphead_order_type=_shiphead.shiphead_order_type)
75167
 
                   AND (NOT shiphead_shipped)
75168
 
                   AND (shiphead_id=pshipheadid) )
75169
 
                  ORDER BY shipitem_qty LOOP
75170
 
 
75171
 
          IF (_billedQty > 0.0) THEN
75172
 
 
75173
 
            IF (_billedQty >= _s.shipitem_qty) THEN
75174
 
              UPDATE shipitem SET shipitem_invoiced=TRUE WHERE shipitem_id=_s.shipitem_id;
75175
 
              -- must wait to close coitems until after shiphead_shipped -> true
75176
 
              _lineitemsToClose := _lineitemsToClose || _c.coitem_id;
75177
 
            ELSE
75178
 
              _newQty := _s.shipitem_qty - _billedQty;
75179
 
              UPDATE shipitem SET shipitem_invoiced=TRUE, shipitem_qty=_billedQty WHERE shipitem_id=_s.shipitem_id;
75180
 
              INSERT INTO shipitem ( shipitem_orderitem_id, shipitem_shipdate,
75181
 
                shipitem_qty, shipitem_transdate, shipitem_invoiced,
75182
 
                shipitem_shiphead_id, shipitem_trans_username)
75183
 
              SELECT shipitem_orderitem_id, shipitem_shipdate,
75184
 
                _newQty, shipitem_transdate, FALSE,
75185
 
                shipitem_shiphead_id, shipitem_trans_username
75186
 
              FROM shipitem
75187
 
              WHERE (shipitem_id=_s.shipitem_id);
75188
 
            END IF;
75189
 
 
75190
 
            _billedQty := _billedQty - _s.shipitem_qty;
75191
 
          END IF;
75192
 
        END LOOP;
75193
 
 
75194
 
      END IF;
75195
 
    END LOOP;
75196
 
 
75197
 
  ELSEIF (_shiphead.shiphead_order_type = 'TO') THEN
75198
 
    IF (_shiphead.shiphead_shipped) THEN
75199
 
      RETURN -8;
75200
 
    END IF;
75201
 
 
75202
 
    SELECT tohead.* INTO _to
75203
 
      FROM tohead
75204
 
     WHERE (tohead_id=_shiphead.shiphead_order_id);
75205
 
 
75206
 
    IF ( _to.tohead_shipcomplete ) THEN
75207
 
      -- use sufficientInventory...()?
75208
 
      FOR _ti IN SELECT (toitem_qty_ordered -
75209
 
                         (COALESCE(SUM(shipitem_qty),0) + toitem_qty_shipped)) AS remain
75210
 
                  FROM toitem LEFT OUTER JOIN
75211
 
                       shipitem ON (shipitem_orderitem_id=toitem_id)
75212
 
                 WHERE ((toitem_status<>'X')
75213
 
                   AND  (toitem_tohead_id=_shiphead.shiphead_order_id))
75214
 
              GROUP BY toitem_qty_shipped, toitem_qty_ordered LOOP
75215
 
        IF (_ti.remain > 0) THEN
75216
 
          RETURN -99;
75217
 
        END IF;
75218
 
      END LOOP;
75219
 
    END IF;
75220
 
 
75221
 
    FOR _ti IN SELECT toitem_id, toitem_item_id, SUM(shipitem_qty) AS qty, SUM(shipitem_value) AS value
75222
 
                FROM toitem, shipitem
75223
 
                WHERE ((toitem_tohead_id=_to.tohead_id)
75224
 
                  AND  (shipitem_orderitem_id=toitem_id)
75225
 
                  AND  (shipitem_shiphead_id=pshipheadid))
75226
 
                GROUP BY toitem_id, toitem_item_id LOOP
75227
 
 
75228
 
      IF (NOT EXISTS(SELECT itemsite_id
75229
 
                     FROM itemsite
75230
 
                     WHERE ((itemsite_item_id=_ti.toitem_item_id)
75231
 
                     AND  (itemsite_warehous_id = _to.tohead_trns_warehous_id))
75232
 
                     )) THEN
75233
 
        RETURN -6;
75234
 
      END IF;
75235
 
 
75236
 
      _itemlocSeries := NEXTVAL('itemloc_series_seq');
75237
 
 
75238
 
      SELECT postInvTrans(si.itemsite_id, 'TS', _ti.qty,
75239
 
                          'I/M', _shiphead.shiphead_order_type,
75240
 
                          formatToNumber(_ti.toitem_id), _to.tohead_number,
75241
 
                          'Ship from Src to Transit Warehouse',
75242
 
                          tc.costcat_asset_accnt_id,
75243
 
                          sc.costcat_shipasset_accnt_id,
75244
 
                          _itemlocSeries, _timestamp, _ti.value) INTO _invhistid
75245
 
      FROM itemsite AS ti, costcat AS tc,
75246
 
           itemsite AS si, costcat AS sc
75247
 
      WHERE ( (ti.itemsite_costcat_id=tc.costcat_id)
75248
 
        AND  (si.itemsite_costcat_id=sc.costcat_id)
75249
 
        AND  (ti.itemsite_item_id=_ti.toitem_item_id)
75250
 
        AND  (si.itemsite_item_id=_ti.toitem_item_id)
75251
 
        AND  (ti.itemsite_warehous_id=_to.tohead_trns_warehous_id)
75252
 
        AND  (si.itemsite_warehous_id=_to.tohead_src_warehous_id) );
75253
 
 
75254
 
      --We do not need to distribute lot/serial info for transit, post trans and discard dist detail
75255
 
      PERFORM postIntoTrialBalance(itemlocpost_glseq) FROM itemlocpost WHERE (itemlocpost_itemlocseries=_itemlocSeries);
75256
 
      IF (_invhistid > 0) THEN
75257
 
        PERFORM postInvHist(_invhistid);
75258
 
      END IF;
75259
 
      DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocSeries);
75260
 
      DELETE FROM itemlocpost WHERE (itemlocpost_itemlocSeries=_itemlocSeries);
75261
 
 
75262
 
      IF (_result < 0) THEN
75263
 
        RETURN _result;
75264
 
      END IF;
75265
 
 
75266
 
      -- record inventory history and qoh changes at transit warehouse but
75267
 
      -- there is only one g/l account to touch
75268
 
      SELECT postInvTrans(ti.itemsite_id, 'TR', _ti.qty,
75269
 
                          'I/M', _shiphead.shiphead_order_type,
75270
 
                          formatToNumber(_ti.toitem_id), _to.tohead_number,
75271
 
                          'Receive into Transit from Src Warehouse',
75272
 
                          tc.costcat_asset_accnt_id,
75273
 
                          tc.costcat_asset_accnt_id,
75274
 
                          _itemlocSeries, _timestamp, 
75275
 
                          _ti.value) INTO _invhistid
75276
 
      FROM itemsite AS ti, costcat AS tc
75277
 
      WHERE ((ti.itemsite_costcat_id=tc.costcat_id)
75278
 
        AND  (ti.itemsite_item_id=_ti.toitem_item_id)
75279
 
        AND  (ti.itemsite_warehous_id=_to.tohead_trns_warehous_id));
75280
 
      --We do not need to distribute lot/serial info for transit, post trans and discard dist detail
75281
 
      PERFORM postIntoTrialBalance(itemlocpost_glseq) FROM itemlocpost WHERE (itemlocpost_itemlocseries=_itemlocSeries);
75282
 
      IF (_invhistid > 0) THEN
75283
 
        PERFORM postInvHist(_invhistid);
75284
 
      END IF;
75285
 
      DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocSeries);
75286
 
      DELETE FROM itemlocpost WHERE (itemlocpost_itemlocSeries=_itemlocSeries);
75287
 
 
75288
 
      --See if there was a change in values during the transfer, if so record the variance
75289
 
      SELECT (invhist_invqty * invhist_unitcost - _ti.value) INTO _variance
75290
 
      FROM invhist
75291
 
      WHERE (invhist_id=_invhistid);
75292
 
 
75293
 
      IF (_variance > 0) THEN
75294
 
        PERFORM insertGLTransaction( 'S/R', _shiphead.shiphead_order_type, _to.tohead_number, 
75295
 
                                     'Transfer Order - Transfer Variance',
75296
 
                                     tc.costcat_invcost_accnt_id, tc.costcat_asset_accnt_id, _invhistid,
75297
 
                                     _variance,
75298
 
                                     CAST(_timestamp AS DATE) )
75299
 
        FROM itemsite AS ti, costcat AS tc
75300
 
        WHERE ( (ti.itemsite_costcat_id=tc.costcat_id)
75301
 
        AND  (ti.itemsite_item_id=_ti.toitem_item_id)
75302
 
        AND  (ti.itemsite_warehous_id=_to.tohead_trns_warehous_id) );
75303
 
      END IF;
75304
 
 
75305
 
      IF (_result < 0) THEN
75306
 
        RETURN _result;
75307
 
      END IF;
75308
 
 
75309
 
      UPDATE shipitem SET shipitem_shipdate=_timestamp, shipitem_shipped=TRUE
75310
 
      WHERE ((shipitem_orderitem_id=_ti.toitem_id)
75311
 
        AND  (shipitem_shiphead_id=pshipheadid));
75312
 
 
75313
 
      UPDATE toitem
75314
 
      SET toitem_qty_shipped = (toitem_qty_shipped + _ti.qty)
75315
 
      WHERE (toitem_id=_ti.toitem_id);
75316
 
    END LOOP;
75317
 
  END IF;
75318
 
 
75319
 
  UPDATE shiphead
75320
 
  SET shiphead_shipped=TRUE, shiphead_shipdate=_gldate
75321
 
  WHERE (shiphead_id=pshipheadid);
75322
 
 
75323
 
  -- now try to close line items that are fully shipped and invoiced
75324
 
  IF (_shiphead.shiphead_order_type = 'SO') THEN
75325
 
    UPDATE coitem SET coitem_status='C'
75326
 
    WHERE ((coitem_id = ANY (_lineitemsToClose))
75327
 
      AND  (coitem_qtyshipped >= coitem_qtyord));
75328
 
  END IF;
75329
 
 
75330
 
  RETURN _itemlocSeries;
75331
 
 
75332
 
END;
75333
 
$_$;
75334
 
 
75335
 
 
75336
 
ALTER FUNCTION public.shipshipment(integer, timestamp with time zone) OWNER TO admin;
75337
 
 
75338
 
--
75339
 
--
75340
 
 
75341
 
CREATE FUNCTION singlecharacteristicstostring(text, integer, text, text, integer) RETURNS text
75342
 
    LANGUAGE plpgsql
75343
 
    AS $_$
75344
 
DECLARE
75345
 
  pTargetType ALIAS FOR $1;
75346
 
  pTargetId ALIAS FOR $2;
75347
 
  pValKeySep ALIAS FOR $3;
75348
 
  pPairSep ALIAS FOR $4;
75349
 
  pCharId ALIAS FOR $5;
75350
 
  _string TEXT := '';
75351
 
  _extra BOOLEAN := false;
75352
 
  _r RECORD;
75353
 
BEGIN
75354
 
  FOR _r IN SELECT char_name, charass_value
75355
 
              FROM charass, char
75356
 
             WHERE ((charass_char_id=char_id)
75357
 
               AND  (charass_char_id=pCharId)
75358
 
               AND  (charass_target_type=pTargetType)
75359
 
               AND  (charass_target_id=pTargetId)) LOOP
75360
 
    IF(_extra) THEN
75361
 
      _string := _string || pPairSep;
75362
 
    END IF;
75363
 
    _extra := true;
75364
 
 
75365
 
    _string := _string || _r.char_name || pValKeySep || _r.charass_value;
75366
 
  END LOOP;
75367
 
 
75368
 
  RETURN _string;
75369
 
END;
75370
 
$_$;
75371
 
 
75372
 
 
75373
 
ALTER FUNCTION public.singlecharacteristicstostring(text, integer, text, text, integer) OWNER TO admin;
75374
 
 
75375
 
--
75376
 
--
75377
 
 
75378
 
CREATE FUNCTION singlelevelbom(integer, integer, integer, integer) RETURNS SETOF bomdata
75379
 
    LANGUAGE plpgsql
75380
 
    AS $_$
75381
 
DECLARE
75382
 
  pItemid ALIAS FOR $1;
75383
 
  pRevisionid ALIAS FOR $2;
75384
 
  pExpiredDays ALIAS FOR $3;
75385
 
  pFutureDays ALIAS FOR $4;
75386
 
  _row bomdata%ROWTYPE;
75387
 
  _bomworksetid INTEGER;
75388
 
  _x RECORD;
75389
 
  _check CHAR(1);
75390
 
  _inactive BOOLEAN;
75391
 
  _batchsize NUMERIC;
75392
 
 
75393
 
BEGIN
75394
 
 
75395
 
  _inactive := FALSE;
75396
 
 
75397
 
  IF (pRevisionid != -1) THEN
75398
 
    --Is this a deactivated revision?
75399
 
    SELECT rev_status INTO _check
75400
 
    FROM rev
75401
 
    WHERE ((rev_id=pRevisionid)
75402
 
    AND (rev_status='I'));
75403
 
    IF (FOUND) THEN
75404
 
      _inactive := TRUE;
75405
 
    END IF;
75406
 
  END IF;
75407
 
 
75408
 
  -- Get the batch quantity
75409
 
  SELECT COALESCE( (
75410
 
    SELECT bomhead_batchsize
75411
 
    FROM bomhead
75412
 
    WHERE ((bomhead_item_id=pItemId)
75413
 
    AND (bomhead_rev_id=pRevisionid))),1) INTO _batchsize;
75414
 
 
75415
 
  IF NOT (_inactive) THEN
75416
 
    FOR _x IN
75417
 
        SELECT bomitem_id, bomitem_seqnumber, bomitem_seqnumber AS f_bomitem_seqnumber,
75418
 
               item_id, item_number, uom_name,
75419
 
               item_descrip1, item_descrip2,
75420
 
               (item_descrip1 || ' ' || item_descrip2) AS itemdescription,
75421
 
               (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd,
75422
 
               (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper,
75423
 
               bomitem_scrap, bomitem_createwo,
75424
 
               CASE WHEN (bomitem_issuemethod='S') THEN 'Push'
75425
 
                 WHEN (bomitem_issuemethod='L') THEN 'Pull'
75426
 
                 WHEN (bomitem_issuemethod='M') THEN 'Mixed'
75427
 
                 ELSE 'Special'
75428
 
               END AS issuemethod,
75429
 
               bomitem_effective, bomitem_expires,
75430
 
               CASE WHEN (bomitem_expires <= CURRENT_DATE) THEN TRUE
75431
 
                 ELSE FALSE
75432
 
               END AS expired,
75433
 
               CASE WHEN (bomitem_effective > CURRENT_DATE) THEN TRUE
75434
 
                 ELSE FALSE
75435
 
               END AS future,
75436
 
               actcost(bomitem_item_id, bomitem_id) AS actunitcost,
75437
 
               stdcost(bomitem_item_id, bomitem_id) AS stdunitcost,
75438
 
               CASE WHEN item_type NOT IN ('R','T') THEN
75439
 
                 itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL,
75440
 
                              (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * actcost(bomitem_item_id, bomitem_id)
75441
 
               ELSE 0.0 END AS actextendedcost,
75442
 
               CASE WHEN item_type NOT IN ('R','T') THEN
75443
 
                 itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL,
75444
 
                              (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * stdcost(bomitem_item_id, bomitem_id)
75445
 
               ELSE 0.0 END AS stdextendedcost,
75446
 
               bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref 
75447
 
       FROM bomitem(pItemid,pRevisionid), item, uom 
75448
 
       WHERE ( (item_inv_uom_id=uom_id)
75449
 
       AND (bomitem_item_id=item_id)
75450
 
       AND (bomitem_expires > (CURRENT_DATE - pExpiredDays))
75451
 
       AND (bomitem_effective <= (CURRENT_DATE + pFutureDays)) )
75452
 
       UNION
75453
 
       SELECT -1, -1, NULL, -1, costelem_type AS bomdata_item_number, '',
75454
 
              '', '',
75455
 
              '',
75456
 
              NULL,
75457
 
              NULL,
75458
 
              NULL, NULL,
75459
 
              NULL,
75460
 
              NULL, NULL,
75461
 
              false,false,
75462
 
              currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actunitcost,
75463
 
              itemcost_stdcost AS stdunitcost,
75464
 
              currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actextendedcost,
75465
 
              itemcost_stdcost AS stdextendedcost,
75466
 
              NULL, NULL, NULL, NULL
75467
 
       FROM itemcost, costelem 
75468
 
       WHERE ( (itemcost_costelem_id=costelem_id)
75469
 
       AND (NOT itemcost_lowlevel)
75470
 
       AND (itemcost_item_id=pItemid) )
75471
 
       ORDER BY bomitem_seqnumber, bomitem_effective, item_number
75472
 
    LOOP
75473
 
        _row.bomdata_bomitem_id := _x.bomitem_id;
75474
 
        _row.bomdata_bomwork_seqnumber := _x.f_bomitem_seqnumber;
75475
 
        _row.bomdata_item_id := _x.item_id;
75476
 
        _row.bomdata_item_number := _x.item_number;
75477
 
        _row.bomdata_uom_name := _x.uom_name;
75478
 
        _row.bomdata_item_descrip1 := _x.item_descrip1;
75479
 
        _row.bomdata_item_descrip2 := _x.item_descrip2;
75480
 
        _row.bomdata_itemdescription := _x.itemdescription;
75481
 
        _row.bomdata_batchsize := _batchsize;
75482
 
        _row.bomdata_qtyfxd := _x.qtyfxd;
75483
 
        _row.bomdata_qtyper := _x.qtyper;
75484
 
        _row.bomdata_scrap := _x.bomitem_scrap;
75485
 
        _row.bomdata_createchild := _x.bomitem_createwo;
75486
 
        _row.bomdata_issuemethod := _x.issuemethod;
75487
 
        _row.bomdata_effective := _x.bomitem_effective;
75488
 
        _row.bomdata_expires := _x.bomitem_expires;
75489
 
        _row.bomdata_expired := _x.expired;
75490
 
        _row.bomdata_future := _x.future;
75491
 
        _row.bomdata_actunitcost := _x.actunitcost;
75492
 
        _row.bomdata_stdunitcost := _x.stdunitcost;
75493
 
        _row.bomdata_actextendedcost := _x.actextendedcost;
75494
 
        _row.bomdata_stdextendedcost := _x.stdextendedcost;
75495
 
        _row.bomdata_char_id := _x.bomitem_char_id;
75496
 
        _row.bomdata_value := _x.bomitem_value;
75497
 
        _row.bomdata_notes := _x.bomitem_notes;
75498
 
        _row.bomdata_ref := _x.bomitem_ref;
75499
 
        RETURN NEXT _row;
75500
 
    END LOOP;
75501
 
 
75502
 
   ELSE
75503
 
 
75504
 
    FOR _x IN
75505
 
        SELECT bomitem_id, bomitem_seqnumber, bomitem_seqnumber AS f_bomitem_seqnumber,
75506
 
               item_id, item_number, uom_name,
75507
 
               item_descrip1, item_descrip2,
75508
 
               (item_descrip1 || ' ' || item_descrip2) AS itemdescription,
75509
 
               (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd,
75510
 
               (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper,
75511
 
               bomitem_scrap, bomitem_createwo,
75512
 
               CASE WHEN (bomitem_issuemethod='S') THEN 'Push'
75513
 
                 WHEN (bomitem_issuemethod='L') THEN 'Pull'
75514
 
                 WHEN (bomitem_issuemethod='M') THEN 'Mixed'
75515
 
                 ELSE 'Special'
75516
 
               END AS issuemethod,
75517
 
               bomitem_effective, bomitem_expires,
75518
 
               CASE WHEN (bomitem_expires <= CURRENT_DATE) THEN TRUE
75519
 
                 ELSE FALSE
75520
 
               END AS expired,
75521
 
               CASE WHEN (bomitem_effective > CURRENT_DATE) THEN TRUE
75522
 
                 ELSE FALSE
75523
 
               END AS future,
75524
 
               actcost(bomitem_item_id) AS actunitcost,
75525
 
               stdcost(bomitem_item_id) AS stdunitcost,
75526
 
               CASE WHEN item_type NOT IN ('R','T') THEN
75527
 
                 itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL,
75528
 
                              (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * actcost(bomitem_item_id)
75529
 
               ELSE 0.0 END AS actextendedcost,
75530
 
               CASE WHEN item_type NOT IN ('R','T') THEN
75531
 
                 itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL,
75532
 
                              (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * stdcost(bomitem_item_id)
75533
 
               ELSE 0.0 END AS stdextendedcost,
75534
 
               bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref 
75535
 
       FROM bomitem(pItemid,pRevisionid), item, uom 
75536
 
       WHERE ( (item_inv_uom_id=uom_id)
75537
 
       AND (bomitem_item_id=item_id)
75538
 
       AND (bomitem_expires > (CURRENT_DATE - pExpiredDays))
75539
 
       AND (bomitem_effective <= (CURRENT_DATE + pFutureDays)) )
75540
 
       UNION
75541
 
       SELECT -1, -1, NULL, -1, costelem_type AS bomdata_item_number, '',
75542
 
              '', '',
75543
 
              '',
75544
 
              NULL,
75545
 
              NULL,
75546
 
              NULL, NULL,
75547
 
              NULL,
75548
 
              NULL, NULL,
75549
 
              false,false,
75550
 
              bomhist_actunitcost AS actunitcost,
75551
 
              bomhist_stdunitcost AS stdunitcost,
75552
 
              bomhist_actunitcost AS actextendedcost,
75553
 
              bomhist_stdunitcost AS stdextendedcost,
75554
 
              NULL, NULL, NULL, NULL
75555
 
       FROM bomhist, costelem 
75556
 
       WHERE ( (bomhist_item_id=costelem_id)
75557
 
       AND (bomhist_item_type='E')
75558
 
       AND (bomhist_rev_id=pRevisionid) )
75559
 
       ORDER BY bomitem_seqnumber, bomitem_effective, item_number
75560
 
    LOOP
75561
 
        _row.bomdata_bomitem_id := _x.bomitem_id;
75562
 
        _row.bomdata_bomwork_seqnumber := _x.f_bomitem_seqnumber;
75563
 
        _row.bomdata_item_id := _x.item_id;
75564
 
        _row.bomdata_item_number := _x.item_number;
75565
 
        _row.bomdata_uom_name := _x.uom_name;
75566
 
        _row.bomdata_item_descrip1 := _x.item_descrip1;
75567
 
        _row.bomdata_item_descrip2 := _x.item_descrip2;
75568
 
        _row.bomdata_itemdescription := _x.itemdescription;
75569
 
        _row.bomdata_batchsize := _batchsize;
75570
 
        _row.bomdata_qtyfxd := _x.qtyfxd;
75571
 
        _row.bomdata_qtyper := _x.qtyper;
75572
 
        _row.bomdata_scrap := _x.bomitem_scrap;
75573
 
        _row.bomdata_createchild := _x.bomitem_createwo;
75574
 
        _row.bomdata_issuemethod := _x.issuemethod;
75575
 
        _row.bomdata_effective := _x.bomitem_effective;
75576
 
        _row.bomdata_expires := _x.bomitem_expires;
75577
 
        _row.bomdata_expired := _x.expired;
75578
 
        _row.bomdata_future := _x.future;
75579
 
        _row.bomdata_actunitcost := _x.actunitcost;
75580
 
        _row.bomdata_stdunitcost := _x.stdunitcost;
75581
 
        _row.bomdata_actextendedcost := _x.actextendedcost;
75582
 
        _row.bomdata_stdextendedcost := _x.stdextendedcost;
75583
 
        _row.bomdata_char_id := _x.bomitem_char_id;
75584
 
        _row.bomdata_value := _x.bomitem_value;
75585
 
        _row.bomdata_notes := _x.bomitem_notes;
75586
 
        _row.bomdata_ref := _x.bomitem_ref;
75587
 
        RETURN NEXT _row;
75588
 
    END LOOP;
75589
 
  END IF;
75590
 
 
75591
 
  RETURN;
75592
 
END;
75593
 
$_$;
75594
 
 
75595
 
 
75596
 
ALTER FUNCTION public.singlelevelbom(integer, integer, integer, integer) OWNER TO admin;
75597
 
 
75598
 
--
75599
 
--
75600
 
 
75601
 
CREATE FUNCTION site() RETURNS SETOF whsinfo
75602
 
    LANGUAGE plpgsql
75603
 
    AS $$
75604
 
DECLARE
75605
 
  _row whsinfo%ROWTYPE;
75606
 
  _r RECORD;
75607
 
 
75608
 
BEGIN
75609
 
 
75610
 
  IF ( (fetchMetricBool('MultiWhs')) AND
75611
 
       (SELECT (COUNT(usrpref_id)=1)
75612
 
        FROM usrpref
75613
 
        WHERE ((usrpref_name='selectedSites')
75614
 
        AND (usrpref_value='t')
75615
 
        AND (usrpref_username=getEffectiveXtUser()))) ) THEN
75616
 
 
75617
 
    FOR _r IN SELECT *
75618
 
            FROM whsinfo,usrsite
75619
 
            WHERE ((warehous_id=usrsite_warehous_id)
75620
 
            AND (usrsite_username=getEffectiveXtUser()))
75621
 
    LOOP
75622
 
      _row.warehous_id:=_r.warehous_id;
75623
 
      _row.warehous_code:=_r.warehous_code;
75624
 
      _row.warehous_descrip:=_r.warehous_descrip;
75625
 
      _row.warehous_fob:=_r.warehous_fob;
75626
 
      _row.warehous_active:=_r.warehous_active;
75627
 
      _row.warehous_counttag_prefix:=_r.warehous_counttag_prefix;
75628
 
      _row.warehous_counttag_number:=_r.warehous_counttag_number;
75629
 
      _row.warehous_bol_prefix:=_r.warehous_bol_prefix;
75630
 
      _row.warehous_bol_number:=_r.warehous_bol_number;
75631
 
      _row.warehous_shipping:=_r.warehous_shipping;
75632
 
      _row.warehous_useslips:=_r.warehous_useslips;
75633
 
      _row.warehous_usezones:=_r.warehous_usezones;
75634
 
      _row.warehous_aislesize:=_r.warehous_aislesize;
75635
 
      _row.warehous_racksize:=_r.warehous_racksize;
75636
 
      _row.warehous_binsize:=_r.warehous_binsize;
75637
 
      _row.warehous_binalpha:=_r.warehous_binalpha;
75638
 
      _row.warehous_locationsize:=_r.warehous_locationsize;
75639
 
      _row.warehous_locationalpha:=_r.warehous_locationalpha;
75640
 
      _row.warehous_enforcearbl:=_r.warehous_enforcearbl;
75641
 
      _row.warehous_default_accnt_id:=_r.warehous_default_accnt_id;
75642
 
      _row.warehous_shipping_commission:=_r.warehous_shipping_commission;
75643
 
      _row.warehous_cntct_id:=_r.warehous_cntct_id;
75644
 
      _row.warehous_addr_id:=_r.warehous_addr_id;
75645
 
      _row.warehous_taxzone_id:=_r.warehous_taxzone_id;
75646
 
      _row.warehous_transit:=_r.warehous_transit;
75647
 
      _row.warehous_shipform_id:=_r.warehous_shipform_id;
75648
 
      _row.warehous_shipvia_id:=_r.warehous_shipvia_id;
75649
 
      _row.warehous_shipcomments:=_r.warehous_shipcomments;
75650
 
      _row.warehous_costcat_id:=_r.warehous_costcat_id;
75651
 
      _row.warehous_sitetype_id:=_r.warehous_sitetype_id;
75652
 
             
75653
 
      RETURN NEXT _row;
75654
 
    END LOOP;
75655
 
  ELSE
75656
 
    FOR _r IN SELECT *
75657
 
            FROM whsinfo
75658
 
    LOOP
75659
 
      _row.warehous_id:=_r.warehous_id;
75660
 
      _row.warehous_code:=_r.warehous_code;
75661
 
      _row.warehous_descrip:=_r.warehous_descrip;
75662
 
      _row.warehous_fob:=_r.warehous_fob;
75663
 
      _row.warehous_active:=_r.warehous_active;
75664
 
      _row.warehous_counttag_prefix:=_r.warehous_counttag_prefix;
75665
 
      _row.warehous_counttag_number:=_r.warehous_counttag_number;
75666
 
      _row.warehous_bol_prefix:=_r.warehous_bol_prefix;
75667
 
      _row.warehous_bol_number:=_r.warehous_bol_number;
75668
 
      _row.warehous_shipping:=_r.warehous_shipping;
75669
 
      _row.warehous_useslips:=_r.warehous_useslips;
75670
 
      _row.warehous_usezones:=_r.warehous_usezones;
75671
 
      _row.warehous_aislesize:=_r.warehous_aislesize;
75672
 
      _row.warehous_racksize:=_r.warehous_racksize;
75673
 
      _row.warehous_binsize:=_r.warehous_binsize;
75674
 
      _row.warehous_binalpha:=_r.warehous_binalpha;
75675
 
      _row.warehous_locationsize:=_r.warehous_locationsize;
75676
 
      _row.warehous_locationalpha:=_r.warehous_locationalpha;
75677
 
      _row.warehous_enforcearbl:=_r.warehous_enforcearbl;
75678
 
      _row.warehous_default_accnt_id:=_r.warehous_default_accnt_id;
75679
 
      _row.warehous_shipping_commission:=_r.warehous_shipping_commission;
75680
 
      _row.warehous_cntct_id:=_r.warehous_cntct_id;
75681
 
      _row.warehous_addr_id:=_r.warehous_addr_id;
75682
 
      _row.warehous_taxzone_id:=_r.warehous_taxzone_id;
75683
 
      _row.warehous_transit:=_r.warehous_transit;
75684
 
      _row.warehous_shipform_id:=_r.warehous_shipform_id;
75685
 
      _row.warehous_shipvia_id:=_r.warehous_shipvia_id;
75686
 
      _row.warehous_shipcomments:=_r.warehous_shipcomments;
75687
 
      _row.warehous_costcat_id:=_r.warehous_costcat_id;
75688
 
      _row.warehous_sitetype_id:=_r.warehous_sitetype_id;
75689
 
             
75690
 
      RETURN NEXT _row;
75691
 
    END LOOP;
75692
 
  END IF;
75693
 
  
75694
 
  RETURN;
75695
 
END;
75696
 
$$;
75697
 
 
75698
 
 
75699
 
ALTER FUNCTION public.site() OWNER TO admin;
75700
 
 
75701
 
--
75702
 
--
75703
 
 
75704
 
CREATE FUNCTION snoozemessage(integer) RETURNS boolean
75705
 
    LANGUAGE plpgsql
75706
 
    AS $_$
75707
 
DECLARE
75708
 
  pMsgid ALIAS FOR $1;
75709
 
  snooze INTERVAL := '10 minutes';
75710
 
 
75711
 
BEGIN
75712
 
 
75713
 
  UPDATE msg
75714
 
  SET msg_scheduled=(msg_scheduled + snooze)
75715
 
  WHERE (msg_id=pMsgid);
75716
 
 
75717
 
  RETURN TRUE;
75718
 
 
75719
 
END;
75720
 
$_$;
75721
 
 
75722
 
 
75723
 
ALTER FUNCTION public.snoozemessage(integer) OWNER TO admin;
75724
 
 
75725
 
--
75726
 
--
75727
 
 
75728
 
CREATE FUNCTION spellamount(numeric) RETURNS text
75729
 
    LANGUAGE plpgsql
75730
 
    AS $_$
75731
 
BEGIN
75732
 
  RETURN spellAmount($1, baseCurrId());
75733
 
END;
75734
 
$_$;
75735
 
 
75736
 
 
75737
 
ALTER FUNCTION public.spellamount(numeric) OWNER TO admin;
75738
 
 
75739
 
--
75740
 
--
75741
 
 
75742
 
CREATE FUNCTION spellamount(numeric, integer) RETURNS text
75743
 
    LANGUAGE plpgsql
75744
 
    AS $_$
75745
 
DECLARE
75746
 
  pN ALIAS FOR $1;
75747
 
  pCurrId ALIAS FOR $2;
75748
 
  _t text;
75749
 
  _dollars text;
75750
 
  _cents text;
75751
 
  _l integer;
75752
 
  _p integer;
75753
 
  _words text;
75754
 
  _word text;
75755
 
  _hundreds char;
75756
 
  _tens char;
75757
 
  _ones char;
75758
 
  _fractionalPartName text;
75759
 
  _curr curr_symbol%ROWTYPE;
75760
 
BEGIN
75761
 
 
75762
 
  _t := ltrim(to_char(pN, '999999999990D99'),' ');
75763
 
  IF strpos(_t, '.') > 0 THEN
75764
 
    _dollars := split_part(_t, '.', 1);
75765
 
    _cents := split_part(_t, '.', 2);
75766
 
  ELSIF strpos(_t, ',') > 0 THEN
75767
 
    _dollars := split_part(_t, ',', 1);
75768
 
    _cents := split_part(_t, ',', 2);
75769
 
  END IF;
75770
 
 
75771
 
  _p := 0;
75772
 
  _l := length(_dollars);
75773
 
 
75774
 
  _words := '';
75775
 
  WHILE (_p < _l) LOOP
75776
 
    IF((_l - _p - 2) < 1) THEN
75777
 
      _hundreds := '0';
75778
 
    ELSE
75779
 
      _hundreds := substr(_dollars, _l - _p - 2, 1);
75780
 
    END IF;
75781
 
    IF((_l - _p - 1) < 1) THEN
75782
 
      _tens := '0';
75783
 
    ELSE
75784
 
      _tens := substr(_dollars, _l - _p - 1, 1);
75785
 
    END IF;
75786
 
    IF((_l - _p) < 1) THEN
75787
 
      _ones := '0';
75788
 
    ELSE
75789
 
      _ones := substr(_dollars, _l - _p, 1);
75790
 
    END IF;
75791
 
 
75792
 
    IF(_hundreds != '0' OR _tens != '0' OR _ones != '0') THEN
75793
 
      IF (_p = 3) THEN
75794
 
        _words := 'thousand ' || _words;
75795
 
      ELSIF (_p = 6) THEN
75796
 
        _words := 'million ' || _words;
75797
 
      ELSIF (_p = 9) THEN
75798
 
        _words := 'billion ' || _words;
75799
 
      END IF;
75800
 
 
75801
 
      _word := '';
75802
 
      IF(_tens = '1') THEN
75803
 
        IF(_ones = '0') THEN
75804
 
          _word := 'ten';
75805
 
        ELSIF(_ones = '1') THEN
75806
 
          _word := 'eleven';
75807
 
        ELSIF(_ones = '2') THEN
75808
 
          _word := 'twelve';
75809
 
        ELSIF(_ones = '3') THEN
75810
 
          _word := 'thirteen';
75811
 
        ELSIF(_ones = '4') THEN
75812
 
          _word := 'fourteen';
75813
 
        ELSIF(_ones = '5') THEN
75814
 
          _word := 'fifteen';
75815
 
        ELSIF(_ones = '6') THEN
75816
 
          _word := 'sixteen';
75817
 
        ELSIF(_ones = '7') THEN
75818
 
          _word := 'seventeen';
75819
 
        ELSIF(_ones = '8') THEN
75820
 
          _word := 'eighteen';
75821
 
        ELSIF(_ones = '9') THEN
75822
 
          _word := 'nineteen';
75823
 
        ELSE
75824
 
          _word := 'ERROR';
75825
 
        END IF;
75826
 
      ELSE
75827
 
        IF(_ones = '1') THEN
75828
 
          _word := 'one';
75829
 
        ELSIF(_ones = '2') THEN
75830
 
          _word := 'two';
75831
 
        ELSIF(_ones = '3') THEN
75832
 
          _word := 'three';
75833
 
        ELSIF(_ones = '4') THEN
75834
 
          _word := 'four';
75835
 
        ELSIF(_ones = '5') THEN
75836
 
          _word := 'five';
75837
 
        ELSIF(_ones = '6') THEN
75838
 
          _word := 'six';
75839
 
        ELSIF(_ones = '7') THEN
75840
 
          _word := 'seven';
75841
 
        ELSIF(_ones = '8') THEN
75842
 
          _word := 'eight';
75843
 
        ELSIF(_ones = '9') THEN
75844
 
          _word := 'nine';
75845
 
        ELSIF(_ones != '0') THEN
75846
 
          _word := 'ERROR';
75847
 
        END IF;
75848
 
 
75849
 
        if(_tens != '0') THEN
75850
 
          _word := '-' || _word;
75851
 
        END IF;
75852
 
 
75853
 
        IF(_tens = '2') THEN
75854
 
          _word := 'twenty' || _word;
75855
 
        ELSIF(_tens = '3') THEN
75856
 
          _word := 'thirty' || _word;
75857
 
        ELSIF(_tens = '4') THEN
75858
 
          _word := 'forty' || _word;
75859
 
        ELSIF(_tens = '5') THEN
75860
 
          _word := 'fifty' || _word;
75861
 
        ELSIF(_tens = '6') THEN
75862
 
          _word := 'sixty' || _word;
75863
 
        ELSIF(_tens = '7') THEN
75864
 
          _word := 'seventy' || _word;
75865
 
        ELSIF(_tens = '8') THEN
75866
 
          _word := 'eighty' || _word;
75867
 
        ELSIF(_tens = '9') THEN
75868
 
          _word := 'ninety' || _word;
75869
 
        ELSIF(_tens != '0' AND _tens != '1') THEN
75870
 
          _word := 'ERROR' || _word;
75871
 
        END IF;
75872
 
      END IF;
75873
 
      if(_word != '') THEN
75874
 
        _words := _word || ' ' || _words;
75875
 
      END IF;
75876
 
 
75877
 
      _word := '';
75878
 
      IF(_hundreds = '1') THEN
75879
 
        _word := 'one hundred';
75880
 
      ELSIF(_hundreds = '2') THEN
75881
 
        _word := 'two hundred';
75882
 
      ELSIF(_hundreds = '3') THEN
75883
 
        _word := 'three hundred';
75884
 
      ELSIF(_hundreds = '4') THEN
75885
 
        _word := 'four hundred';
75886
 
      ELSIF(_hundreds = '5') THEN
75887
 
        _word := 'five hundred';
75888
 
      ELSIF(_hundreds = '6') THEN
75889
 
        _word := 'six hundred';
75890
 
      ELSIF(_hundreds = '7') THEN
75891
 
        _word := 'seven hundred';
75892
 
      ELSIF(_hundreds = '8') THEN
75893
 
        _word := 'eight hundred';
75894
 
      ELSIF(_hundreds = '9') THEN
75895
 
        _word := 'nine hundred';
75896
 
      ELSIF(_hundreds != '0') THEN
75897
 
        _words := 'ERROR';
75898
 
      END IF;
75899
 
      if(_word != '') THEN
75900
 
        _words := _word || ' ' || _words;
75901
 
      END IF;
75902
 
    END IF;
75903
 
 
75904
 
    _p := _p + 3;
75905
 
  END LOOP;
75906
 
 
75907
 
  _words := rtrim(_words, ' ');
75908
 
  IF(_words = '') THEN
75909
 
    _words := 'zero';
75910
 
  END IF;
75911
 
 
75912
 
  SELECT * INTO _curr
75913
 
    FROM curr_symbol
75914
 
    WHERE curr_id = pCurrId;
75915
 
 
75916
 
  IF(_words = 'one') AND TRIM(_curr.curr_name) ~ '.*s' THEN
75917
 
    _word := rtrim(_curr.curr_name, ' s');
75918
 
  ELSE
75919
 
    _word := trim(_curr.curr_name);
75920
 
  END IF;
75921
 
 
75922
 
  IF _curr.curr_abbr = 'USD' OR _curr.curr_abbr = 'CAD' THEN
75923
 
      IF (_cents = '1') THEN
75924
 
        _fractionalPartName = ' cent';
75925
 
      ELSE
75926
 
        _fractionalPartName = ' cents';
75927
 
      END IF;
75928
 
  ELSE
75929
 
    _fractionalPartName = ' / 100 ';
75930
 
  END IF;
75931
 
 
75932
 
  RETURN _words || ' ' || _word || ' and ' || _cents || _fractionalPartName;
75933
 
END;
75934
 
$_$;
75935
 
 
75936
 
 
75937
 
ALTER FUNCTION public.spellamount(numeric, integer) OWNER TO admin;
75938
 
 
75939
 
--
75940
 
--
75941
 
 
75942
 
CREATE FUNCTION splitreceipt(integer, numeric, numeric) RETURNS integer
75943
 
    LANGUAGE plpgsql
75944
 
    AS $_$
75945
 
DECLARE
75946
 
  precvid       ALIAS FOR $1;
75947
 
  pqty          ALIAS FOR $2;
75948
 
  pfreight      ALIAS FOR $3;
75949
 
  _check        RECORD;
75950
 
  _seq          INTEGER;
75951
 
 
75952
 
BEGIN
75953
 
  -- validate
75954
 
  IF (COALESCE(pQty,0) <= 0) THEN
75955
 
    RETURN -7;
75956
 
  END IF;
75957
 
  
75958
 
  SELECT * INTO _check
75959
 
  FROM recv
75960
 
  WHERE (recv_id=precvid);
75961
 
 
75962
 
  IF (FOUND) THEN
75963
 
    IF (_check.recv_order_type != 'PO') THEN
75964
 
      RETURN -1;
75965
 
    ELSIF ( NOT _check.recv_posted) THEN
75966
 
      RETURN -2;
75967
 
    ELSIF ( (_check.recv_invoiced)
75968
 
         OR (_check.recv_vohead_id IS NOT NULL)
75969
 
         OR (_check.recv_voitem_id IS NOT NULL) ) THEN
75970
 
      RETURN -3;
75971
 
    ELSIF (pqty >= _check.recv_qty) THEN
75972
 
      RETURN -4;
75973
 
    ELSIF (COALESCE(pfreight,0) > _check.recv_freight) THEN
75974
 
      RETURN -5;
75975
 
    END IF;
75976
 
  ELSE
75977
 
    RETURN -6;
75978
 
  END IF;
75979
 
 
75980
 
  -- Create new receipt record
75981
 
  _seq := nextval('recv_recv_id_seq');
75982
 
  
75983
 
  INSERT INTO recv
75984
 
  SELECT _seq, recv_order_type,recv_order_number,
75985
 
         recv_orderitem_id, recv_agent_username, recv_itemsite_id, recv_vend_id,
75986
 
         recv_vend_item_number, recv_vend_item_descrip, recv_vend_uom,
75987
 
         recv_purchcost, recv_purchcost_curr_id, recv_duedate, pqty, 
75988
 
         recv_recvcost, recv_recvcost_curr_id, COALESCE(pfreight,0), recv_freight_curr_id, recv_date, 
75989
 
         ROUND(recv_value/recv_qty * pqty, 2), TRUE, FALSE, NULL, NULL,
75990
 
         recv_trans_usr_name, recv_notes, recv_gldistdate, precvid
75991
 
  FROM recv
75992
 
  WHERE (recv_id=precvid);
75993
 
 
75994
 
  --  Update qty and value of old record
75995
 
  UPDATE recv SET
75996
 
    recv_qty = recv_qty-pqty,
75997
 
    recv_value = recv_value - ROUND(recv_value/recv_qty * pqty, 2),
75998
 
    recv_freight = recv_freight - COALESCE(pfreight,0)
75999
 
  WHERE (recv_id=precvid);
76000
 
 
76001
 
  RETURN _seq;
76002
 
END;
76003
 
$_$;
76004
 
 
76005
 
 
76006
 
ALTER FUNCTION public.splitreceipt(integer, numeric, numeric) OWNER TO admin;
76007
 
 
76008
 
--
76009
 
--
76010
 
 
76011
 
CREATE FUNCTION splitrecurrence(integer, text, timestamp with time zone) RETURNS integer
76012
 
    LANGUAGE plpgsql
76013
 
    AS $_$
76014
 
DECLARE
76015
 
  pParentid     ALIAS FOR $1;
76016
 
  pType         TEXT := UPPER($2);
76017
 
  pDatetime     TIMESTAMP WITH TIME ZONE := COALESCE($3, CURRENT_TIMESTAMP);
76018
 
 
76019
 
  _count         INTEGER;
76020
 
  _newrecurid    INTEGER;
76021
 
  _newparentid   INTEGER;
76022
 
  _newparentstmt TEXT;
76023
 
  _rt            RECORD;
76024
 
  _updchildstmt  TEXT;
76025
 
 
76026
 
BEGIN
76027
 
  IF (pParentid IS NULL) THEN
76028
 
    RETURN -11;
76029
 
  END IF;
76030
 
 
76031
 
  SELECT * INTO _rt FROM recurtype WHERE (UPPER(recurtype_type)=pType);
76032
 
  GET DIAGNOSTICS _count = ROW_COUNT;
76033
 
  IF (_count <= 0) THEN
76034
 
    RETURN -10;
76035
 
  END IF;
76036
 
 
76037
 
  _newparentstmt := 'SELECT [table]_id FROM [fulltable]'
76038
 
                 || ' WHERE (([table]_recurring_[table]_id=$1)'
76039
 
                 || '    AND NOT ([done])'
76040
 
                 || '    AND ([schedcol]>=''$2''))'
76041
 
                 || ' ORDER BY [schedcol]'
76042
 
                 || ' LIMIT 1;';
76043
 
  _newparentstmt := REPLACE(_newparentstmt, '[fulltable]', _rt.recurtype_table);
76044
 
  _newparentstmt := REPLACE(_newparentstmt, '[table]',
76045
 
                            REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', ''));
76046
 
  _newparentstmt := REPLACE(_newparentstmt, '[done]',  _rt.recurtype_donecheck);
76047
 
  _newparentstmt := REPLACE(_newparentstmt, '[schedcol]', _rt.recurtype_schedcol);
76048
 
  _updchildstmt := 'UPDATE [fulltable] SET [table]_recurring_[table]_id=$1'
76049
 
                || ' WHERE (([table]_recurring_[table]_id=$2)'
76050
 
                || '   AND NOT ([done])'
76051
 
                || '   AND ([schedcol] > ''$3''));';
76052
 
  _updchildstmt := REPLACE(_updchildstmt, '[fulltable]', _rt.recurtype_table);
76053
 
  _updchildstmt := REPLACE(_updchildstmt, '[table]',
76054
 
                           REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', ''));
76055
 
  _updchildstmt := REPLACE(_updchildstmt, '[done]',  _rt.recurtype_donecheck);
76056
 
  _updchildstmt := REPLACE(_updchildstmt, '[schedcol]', _rt.recurtype_schedcol);
76057
 
 
76058
 
  -- 8.4+: EXECUTE _newparentstmt INTO _newparentid USING pParentid, pDatetime;
76059
 
  EXECUTE REPLACE(REPLACE(_newparentstmt, '$1', pParentid::TEXT),
76060
 
                                          '$2', pDatetime::TEXT)
76061
 
          INTO _newparentid;
76062
 
 
76063
 
  -- if nothing to split
76064
 
  IF (_newparentid = pParentid OR _newparentid IS NULL) THEN
76065
 
    SELECT recur_id INTO _newrecurid
76066
 
      FROM recur
76067
 
     WHERE ((recur_parent_id=pParentid)
76068
 
        AND (recur_parent_type=pType));
76069
 
 
76070
 
  ELSE
76071
 
    INSERT INTO recur (recur_parent_id, recur_parent_type, recur_period,
76072
 
                       recur_freq,      recur_start,       recur_end,
76073
 
                       recur_max,       recur_data
76074
 
             ) SELECT _newparentid,     pType,             recur_period,
76075
 
                      recur_freq,       pDatetime,         recur_end,
76076
 
                      recur_max,        recur_data
76077
 
                 FROM recur
76078
 
                WHERE ((recur_parent_id=pParentid)
76079
 
                   AND (recur_parent_type=pType))
76080
 
      RETURNING recur_id INTO _newrecurid;
76081
 
 
76082
 
    UPDATE recur SET recur_end=pDatetime
76083
 
    WHERE ((recur_parent_id=pParentid)
76084
 
       AND (recur_parent_type=pType));
76085
 
 
76086
 
    -- 8.4+: EXECUTE _updchildstmt USING _newparentid, pParentid, pDatetime;
76087
 
    EXECUTE REPLACE(REPLACE(REPLACE(_updchildstmt, '$1', _newparentid::TEXT),
76088
 
                                                   '$2', pParentid::TEXT),
76089
 
                                                   '$3', pDatetime::TEXT);
76090
 
  END IF;
76091
 
 
76092
 
  RETURN _newrecurid;
76093
 
END;
76094
 
$_$;
76095
 
 
76096
 
 
76097
 
ALTER FUNCTION public.splitrecurrence(integer, text, timestamp with time zone) OWNER TO admin;
76098
 
 
76099
 
--
76100
 
--
76101
 
 
76102
 
CREATE FUNCTION startoftime() RETURNS date
76103
 
    LANGUAGE sql IMMUTABLE
76104
 
    AS $$
76105
 
SELECT DATE('1970-01-01') AS return;
76106
 
$$;
76107
 
 
76108
 
 
76109
 
ALTER FUNCTION public.startoftime() OWNER TO admin;
76110
 
 
76111
 
--
76112
 
--
76113
 
 
76114
 
CREATE FUNCTION stdcost(integer) RETURNS numeric
76115
 
    LANGUAGE plpgsql STABLE
76116
 
    AS $_$
76117
 
BEGIN
76118
 
  RETURN stdCost($1, NULL);
76119
 
END;
76120
 
$_$;
76121
 
 
76122
 
 
76123
 
ALTER FUNCTION public.stdcost(integer) OWNER TO admin;
76124
 
 
76125
 
--
76126
 
--
76127
 
 
76128
 
CREATE FUNCTION stdcost(integer, integer) RETURNS numeric
76129
 
    LANGUAGE plpgsql STABLE
76130
 
    AS $_$
76131
 
DECLARE
76132
 
  pItemid ALIAS FOR $1;
76133
 
  pBomitemid ALIAS FOR $2;
76134
 
  _cost NUMERIC;
76135
 
 
76136
 
BEGIN
76137
 
 
76138
 
  SELECT SUM(COALESCE(bomitemcost_stdcost, itemcost_stdcost)) INTO _cost
76139
 
  FROM itemcost
76140
 
    LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=pBomitemid AND bomitemcost_costelem_id=itemcost_costelem_id)
76141
 
  WHERE (itemcost_item_id=pItemid);
76142
 
 
76143
 
  IF (_cost IS NULL) THEN
76144
 
    RETURN 0;
76145
 
  ELSE
76146
 
    RETURN _cost;
76147
 
  END IF;
76148
 
 
76149
 
END;
76150
 
$_$;
76151
 
 
76152
 
 
76153
 
ALTER FUNCTION public.stdcost(integer, integer) OWNER TO admin;
76154
 
 
76155
 
--
76156
 
--
76157
 
 
76158
 
CREATE FUNCTION sufficientinventorytoshipitem(text, integer) RETURNS integer
76159
 
    LANGUAGE plpgsql
76160
 
    AS $_$
76161
 
DECLARE
76162
 
  pordertype    ALIAS FOR $1;
76163
 
  porderitemid  ALIAS FOR $2;
76164
 
 
76165
 
BEGIN
76166
 
  RETURN sufficientInventoryToShipItem(pordertype, porderitemid, NULL);
76167
 
END;
76168
 
$_$;
76169
 
 
76170
 
 
76171
 
ALTER FUNCTION public.sufficientinventorytoshipitem(text, integer) OWNER TO admin;
76172
 
 
76173
 
--
76174
 
--
76175
 
 
76176
 
CREATE FUNCTION sufficientinventorytoshipitem(text, integer, numeric) RETURNS integer
76177
 
    LANGUAGE plpgsql
76178
 
    AS $_$
76179
 
DECLARE
76180
 
  pordertype           ALIAS FOR $1;
76181
 
  porderitemid         ALIAS FOR $2;
76182
 
  pqty                 ALIAS FOR $3;
76183
 
  _returnVal           INTEGER;
76184
 
  _isqtyavail          BOOLEAN;
76185
 
 
76186
 
BEGIN
76187
 
  IF (porderitemid IS NULL) THEN
76188
 
    RETURN -1;
76189
 
  END IF;
76190
 
 
76191
 
  IF (pordertype = 'SO') THEN
76192
 
    IF ( SELECT fetchMetricBool('EnableSOReservations') ) THEN
76193
 
      IF (SELECT (itemsite_costmethod = 'J')
76194
 
          FROM coitem JOIN itemsite ON (coitem_itemsite_id=itemsite_id)
76195
 
          WHERE (coitem_id=porderitemid)) THEN
76196
 
        RETURN 0;
76197
 
      END IF;
76198
 
 
76199
 
      SELECT (((COALESCE(pqty, roundQty(item_fractional,
76200
 
                      noNeg(coitem_qtyord - coitem_qtyshipped +
76201
 
                            coitem_qtyreturned - qtyAtShipping(pordertype, coitem_id)
76202
 
                           ))) - coitem_qtyreserved) * coitem_qty_invuomratio
76203
 
                      ) <= qtyAvailable(itemsite_id))
76204
 
              AND 
76205
 
             (((COALESCE(pqty, roundQty(item_fractional,
76206
 
                      noNeg(coitem_qtyord - coitem_qtyshipped +
76207
 
                            coitem_qtyreturned - qtyAtShipping(pordertype, coitem_id)
76208
 
                           ))) - coitem_qtyreserved) * coitem_qty_invuomratio
76209
 
                      ) <= qtyunreserved(itemsite_id))
76210
 
        INTO _isqtyavail
76211
 
        FROM coitem, itemsite, item
76212
 
       WHERE ((coitem_itemsite_id=itemsite_id) 
76213
 
         AND (coitem_status <> 'X')
76214
 
         AND  (NOT ((item_type IN ('R','J')) OR (itemsite_controlmethod = 'N'))) 
76215
 
         AND (itemsite_item_id=item_id) 
76216
 
         AND (coitem_id=porderitemid));
76217
 
    ELSE
76218
 
      SELECT (COALESCE(pqty, roundQty(item_fractional,
76219
 
                                      noNeg(coitem_qtyord - coitem_qtyshipped +
76220
 
                                      coitem_qtyreturned - qtyAtShipping(pordertype, coitem_id) - coitem_qtyreserved
76221
 
                                      ) * coitem_qty_invuomratio
76222
 
                      )
76223
 
              ) <= qtyAvailable(itemsite_id))
76224
 
        INTO _isqtyavail
76225
 
        FROM coitem, itemsite, item
76226
 
       WHERE ((coitem_itemsite_id=itemsite_id) 
76227
 
         AND (coitem_status <> 'X')
76228
 
         AND  (NOT ((item_type IN ('R','J')) OR (itemsite_controlmethod = 'N'))) 
76229
 
         AND (itemsite_item_id=item_id) 
76230
 
         AND (coitem_id=porderitemid));
76231
 
    END IF;
76232
 
  ELSEIF (pordertype = 'TO') THEN
76233
 
    SELECT (COALESCE(pqty, roundQty(item_fractional,
76234
 
                                    noNeg(toitem_qty_ordered - toitem_qty_shipped - 
76235
 
                                    qtyAtShipping(pordertype, toitem_id)
76236
 
                                    )
76237
 
                    )
76238
 
           ) <= qtyAvailable(itemsite_id)) INTO _isqtyavail  
76239
 
      FROM toitem, tohead, itemsite, item
76240
 
     WHERE ((toitem_tohead_id=tohead_id)
76241
 
       AND  (tohead_src_warehous_id=itemsite_warehous_id) 
76242
 
       AND  (toitem_item_id=itemsite_item_id) 
76243
 
       AND  (itemsite_warehous_id=tohead_src_warehous_id) 
76244
 
       AND  (itemsite_item_id=item_id) 
76245
 
       AND  (toitem_status <> 'X')
76246
 
         AND  (NOT ((item_type IN ('R','J')) OR (itemsite_controlmethod = 'N'))) 
76247
 
       AND  (toitem_id=porderitemid));
76248
 
  ELSE
76249
 
    RETURN -11;
76250
 
  END IF;
76251
 
 
76252
 
  IF (NOT _isqtyavail) THEN
76253
 
    RETURN -2;
76254
 
  END IF;
76255
 
 
76256
 
  IF (pordertype = 'SO') THEN
76257
 
    SELECT (COALESCE((SELECT SUM(itemloc_qty) 
76258
 
                        FROM itemloc 
76259
 
                       WHERE (itemloc_itemsite_id=itemsite_id)), 0.0) >= roundQty(item_fractional, 
76260
 
                              COALESCE(pQty, noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - 
76261
 
                              qtyAtShipping(pordertype, coitem_id) )) * coitem_qty_invuomratio
76262
 
                             )) INTO _isqtyavail 
76263
 
      FROM coitem, itemsite, item
76264
 
     WHERE ((coitem_itemsite_id=itemsite_id) 
76265
 
       AND (itemsite_item_id=item_id) 
76266
 
       AND (NOT ((item_type ='R') OR (itemsite_controlmethod = 'N'))) 
76267
 
       AND ((itemsite_controlmethod IN ('L', 'S')) OR (itemsite_loccntrl)) 
76268
 
       AND (coitem_id=porderitemid)); 
76269
 
 
76270
 
  ELSEIF (pordertype = 'TO') THEN
76271
 
    SELECT (COALESCE((SELECT SUM(itemloc_qty) 
76272
 
                        FROM itemloc 
76273
 
                       WHERE (itemloc_itemsite_id=itemsite_id)), 0.0) >= roundQty(item_fractional, 
76274
 
                              noNeg( toitem_qty_ordered - toitem_qty_shipped - 
76275
 
                              qtyAtShipping(pordertype, toitem_id) )
76276
 
                             )) INTO _isqtyavail 
76277
 
      FROM toitem, tohead, itemsite, item
76278
 
     WHERE ((toitem_tohead_id=tohead_id)
76279
 
       AND  (tohead_src_warehous_id=itemsite_warehous_id) 
76280
 
       AND  (toitem_item_id=itemsite_item_id) 
76281
 
       AND  (itemsite_item_id=item_id) 
76282
 
       AND  (toitem_status <> 'X')
76283
 
       AND  (NOT ((item_type ='R') OR (itemsite_costmethod = 'J') OR (itemsite_controlmethod = 'N'))) 
76284
 
       AND  ((itemsite_controlmethod IN ('L', 'S')) OR (itemsite_loccntrl)) 
76285
 
       AND  (toitem_id=porderitemid)); 
76286
 
  END IF;
76287
 
  
76288
 
  IF (NOT _isqtyavail) THEN
76289
 
    RETURN -3;
76290
 
  END IF;
76291
 
 
76292
 
  IF (pordertype = 'SO') THEN
76293
 
    IF ( SELECT fetchMetricBool('RequireSOReservations') ) THEN
76294
 
      SELECT (COALESCE(pqty, coitem_qtyreserved) <= coitem_qtyreserved)
76295
 
        INTO _isqtyavail
76296
 
        FROM coitem, itemsite, item
76297
 
       WHERE ((coitem_itemsite_id=itemsite_id) 
76298
 
         AND (coitem_status <> 'X')
76299
 
         AND  (NOT ((item_type IN ('R','J')) OR (itemsite_controlmethod = 'N'))) 
76300
 
         AND (itemsite_item_id=item_id) 
76301
 
         AND (coitem_id=porderitemid));
76302
 
    END IF;
76303
 
  END IF;
76304
 
 
76305
 
  IF (NOT _isqtyavail) THEN
76306
 
    RETURN -4;
76307
 
  END IF;
76308
 
 
76309
 
  RETURN 0;
76310
 
END;
76311
 
$_$;
76312
 
 
76313
 
 
76314
 
ALTER FUNCTION public.sufficientinventorytoshipitem(text, integer, numeric) OWNER TO admin;
76315
 
 
76316
 
--
76317
 
--
76318
 
 
76319
 
CREATE FUNCTION sufficientinventorytoshiporder(text, integer) RETURNS integer
76320
 
    LANGUAGE plpgsql
76321
 
    AS $_$
76322
 
DECLARE
76323
 
  pordertype    ALIAS FOR $1;
76324
 
  porderid      ALIAS FOR $2;
76325
 
  _s            RECORD;
76326
 
  _returnVal    INTEGER := 0;
76327
 
 
76328
 
BEGIN
76329
 
  IF (pordertype = 'SO') THEN
76330
 
    FOR _s IN SELECT coitem_id
76331
 
                FROM coitem
76332
 
                 JOIN itemsite ON (coitem_itemsite_id=itemsite_id)
76333
 
               WHERE((coitem_cohead_id=porderid) 
76334
 
                AND (itemsite_costmethod != 'J')) LOOP
76335
 
      _returnVal := sufficientInventoryToShipItem(pordertype, _s.coitem_id);
76336
 
      EXIT WHEN (_returnVal < 0);
76337
 
    END LOOP;
76338
 
  ELSEIF (pordertype = 'TO') THEN
76339
 
    FOR _s IN SELECT toitem_id
76340
 
                FROM toitem
76341
 
               WHERE(toitem_tohead_id=porderid) LOOP
76342
 
      _returnVal := sufficientInventoryToShipItem(pordertype, _s.toitem_id);
76343
 
      EXIT WHEN (_returnVal < 0);
76344
 
    END LOOP;
76345
 
  END IF;
76346
 
 
76347
 
  RETURN _returnVal;
76348
 
END;
76349
 
$_$;
76350
 
 
76351
 
 
76352
 
ALTER FUNCTION public.sufficientinventorytoshiporder(text, integer) OWNER TO admin;
76353
 
 
76354
 
--
76355
 
--
76356
 
 
76357
 
CREATE FUNCTION summarizedbom(integer) RETURNS integer
76358
 
    LANGUAGE plpgsql
76359
 
    AS $_$
76360
 
DECLARE
76361
 
  pItemid ALIAS FOR $1;
76362
 
  _revid INTEGER;
76363
 
 
76364
 
BEGIN
76365
 
 
76366
 
  SELECT getActiveRevId('BOM',pItemid) INTO _revid;
76367
 
  
76368
 
  RETURN summarizedBOM(pItemid, _revid);
76369
 
 
76370
 
END;
76371
 
$_$;
76372
 
 
76373
 
 
76374
 
ALTER FUNCTION public.summarizedbom(integer) OWNER TO admin;
76375
 
 
76376
 
--
76377
 
--
76378
 
 
76379
 
CREATE FUNCTION summarizedbom(integer, integer) RETURNS integer
76380
 
    LANGUAGE plpgsql
76381
 
    AS $_$
76382
 
DECLARE
76383
 
  pItemid ALIAS FOR $1;
76384
 
  pRevisionid ALIAS FOR $2;
76385
 
  _bomworkid INTEGER;
76386
 
  _indexid INTEGER;
76387
 
  _r RECORD;
76388
 
 
76389
 
BEGIN
76390
 
 
76391
 
 
76392
 
  SELECT NEXTVAL('misc_index_seq') INTO _indexid;
76393
 
 
76394
 
  FOR _r IN SELECT bomitem.*,
76395
 
                   item_id,
76396
 
                   (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL)
76397
 
                              * bomitem_qtyfxd) AS qtyfxd,
76398
 
                   (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL)
76399
 
                              * bomitem_qtyper) AS qtyper,
76400
 
                   stdcost(item_id, bomitem_id) AS standardcost,
76401
 
                   actcost(item_id, bomitem_id) AS actualcost
76402
 
  FROM bomitem(pItemid, pRevisionid), item
76403
 
  WHERE (bomitem_item_id=item_id) LOOP
76404
 
 
76405
 
    SELECT NEXTVAL('bomwork_bomwork_id_seq') INTO _bomworkid;
76406
 
    INSERT INTO bomwork
76407
 
    ( bomwork_id, bomwork_set_id, bomwork_parent_id, bomwork_level,
76408
 
      bomwork_parent_seqnumber, bomwork_seqnumber,
76409
 
      bomwork_item_id, bomwork_createwo, bomwork_qtyreq,
76410
 
      bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_issuemethod,
76411
 
      bomwork_effective, bomwork_expires,
76412
 
      bomwork_stdunitcost, bomwork_actunitcost )
76413
 
    VALUES
76414
 
    ( _bomworkid, _indexid, -1, 1,
76415
 
      0, _r.bomitem_seqnumber,
76416
 
      _r.item_id, _r.bomitem_createwo, (_r.qtyfxd + _r.qtyper),
76417
 
      _r.qtyfxd, _r.qtyper, _r.bomitem_scrap, _r.bomitem_issuemethod,
76418
 
      _r.bomitem_effective, _r.bomitem_expires,
76419
 
      _r.standardcost, _r.actualcost,
76420
 
      _r.bomitem_char_id, _r.bomitem_value, _r.bomitem_notes, _r.bomitem_ref,
76421
 
      _r.bomitem_id, _r.bomitem_ecn );
76422
 
 
76423
 
    PERFORM explodeBOM(_r.item_id, _bomworkid, 1);
76424
 
 
76425
 
  END LOOP;
76426
 
 
76427
 
  RETURN _indexid;
76428
 
 
76429
 
END;
76430
 
$_$;
76431
 
 
76432
 
 
76433
 
ALTER FUNCTION public.summarizedbom(integer, integer) OWNER TO admin;
76434
 
 
76435
 
--
76436
 
--
76437
 
 
76438
 
CREATE FUNCTION summarizedbom(integer, integer, integer) RETURNS integer
76439
 
    LANGUAGE plpgsql
76440
 
    AS $_$
76441
 
DECLARE
76442
 
  pItemid ALIAS FOR $1;
76443
 
  pExpired ALIAS FOR $2;
76444
 
  pFuture ALIAS FOR $3;
76445
 
  _revid INTEGER;
76446
 
 
76447
 
BEGIN
76448
 
 
76449
 
  SELECT getActiveRevId('BOM',pItemid) INTO _revid;
76450
 
  
76451
 
  RETURN summarizedBOM(pItemid, _revid, pExpired, pFuture);
76452
 
 
76453
 
END;
76454
 
$_$;
76455
 
 
76456
 
 
76457
 
ALTER FUNCTION public.summarizedbom(integer, integer, integer) OWNER TO admin;
76458
 
 
76459
 
--
76460
 
--
76461
 
 
76462
 
CREATE FUNCTION summarizedbom(integer, integer, integer, integer) RETURNS SETOF bomdata
76463
 
    LANGUAGE plpgsql
76464
 
    AS $_$
76465
 
DECLARE
76466
 
  pItemid ALIAS FOR $1;
76467
 
  pRevisionid ALIAS FOR $2;
76468
 
  pExpiredDays  INTEGER := COALESCE($3, 0);
76469
 
  pFutureDays   INTEGER := COALESCE($4, 0);
76470
 
  _row bomdata%ROWTYPE;
76471
 
  _bomworksetid INTEGER;
76472
 
  _x RECORD;
76473
 
  _check CHAR(1);
76474
 
  _inactive BOOLEAN := FALSE;
76475
 
  _batchsize NUMERIC;
76476
 
 
76477
 
BEGIN
76478
 
 
76479
 
  IF (pRevisionid != -1) THEN
76480
 
    --Is this a deactivated revision?
76481
 
    SELECT rev_status INTO _check
76482
 
    FROM rev
76483
 
    WHERE ((rev_id=pRevisionid)
76484
 
    AND (rev_status='I'));
76485
 
    IF (FOUND) THEN
76486
 
      _inactive := TRUE;
76487
 
    END IF;
76488
 
  END IF;
76489
 
 
76490
 
  -- Get the batch quantity
76491
 
  SELECT COALESCE( (
76492
 
    SELECT bomhead_batchsize
76493
 
    FROM bomhead
76494
 
    WHERE ((bomhead_item_id=pItemId)
76495
 
    AND (bomhead_rev_id=pRevisionid))),1) INTO _batchsize;
76496
 
 
76497
 
  IF NOT (_inactive) THEN
76498
 
 
76499
 
    --We can explode this out based on current data
76500
 
    SELECT indentedBOM(pItemid, pRevisionid) INTO _bomworksetid;  
76501
 
 
76502
 
    FOR _x IN
76503
 
       SELECT item_number, uom_name,
76504
 
               item_descrip1, item_descrip2,
76505
 
               (item_descrip1 || ' ' || item_descrip2) AS itemdescription,
76506
 
               SUM(bomwork_qtyreq) AS qtyreq,
76507
 
               SUM(bomwork_qtyfxd * (1 + bomwork_scrap)) AS qtyfxd,
76508
 
               SUM(bomwork_qtyper * (1 + bomwork_scrap)) AS qtyper,
76509
 
       MAX(bomwork_actunitcost) AS actunitcost,
76510
 
       MAX(bomwork_stdunitcost) AS stdunitcost,
76511
 
       CASE WHEN item_type NOT IN ('R','T') THEN
76512
 
         SUM(bomwork_actunitcost * bomwork_qtyreq)
76513
 
       ELSE 0 END AS actextendedcost,
76514
 
       CASE WHEN item_type NOT IN ('R','T') THEN
76515
 
         SUM(bomwork_stdunitcost * bomwork_qtyreq)
76516
 
       ELSE 0 END AS stdextendedcost,
76517
 
       bomwork_effective,
76518
 
       bomwork_expires,
76519
 
       bomwork_effective > CURRENT_DATE AS future,
76520
 
       bomwork_expires  <= CURRENT_DATE AS expired
76521
 
       FROM ( SELECT item_number, item_type, uom_name,
76522
 
                     item_descrip1, item_descrip2,
76523
 
                     bomwork_qtyreq, bomwork_qtyfxd,
76524
 
                     bomwork_qtyper, bomwork_scrap,
76525
 
                     bomwork_actunitcost, bomwork_stdunitcost,
76526
 
                     CASE WHEN (bomwork_effective > CURRENT_DATE) THEN (CURRENT_DATE + 1)
76527
 
                          ELSE CURRENT_DATE END AS bomwork_effective,
76528
 
                     CASE WHEN (bomwork_expires <= CURRENT_DATE) THEN (CURRENT_DATE - 1)
76529
 
                          ELSE (CURRENT_DATE + 1) END AS bomwork_expires
76530
 
                     FROM bomwork, item, uom 
76531
 
                     WHERE ( (bomwork_item_id=item_id)
76532
 
                       AND (item_inv_uom_id=uom_id)
76533
 
                       AND (bomwork_set_id=_bomworksetid) )
76534
 
                       AND (bomwork_expires > (CURRENT_DATE - pExpiredDays))
76535
 
                       AND (bomwork_effective <= (CURRENT_DATE + pFutureDays)) ) AS data
76536
 
       GROUP BY item_number, uom_name, item_type,
76537
 
                item_descrip1, item_descrip2,
76538
 
                bomwork_effective, bomwork_expires
76539
 
       ORDER BY item_number
76540
 
    LOOP
76541
 
        _row.bomdata_item_number := _x.item_number;
76542
 
        _row.bomdata_uom_name := _x.uom_name;
76543
 
        _row.bomdata_item_descrip1 := _x.item_descrip1;
76544
 
        _row.bomdata_item_descrip2 := _x.item_descrip2;
76545
 
        _row.bomdata_itemdescription := _x.itemdescription;
76546
 
        _row.bomdata_qtyreq := _x.qtyreq;
76547
 
        _row.bomdata_qtyfxd := _x.qtyfxd;
76548
 
        _row.bomdata_qtyper := _x.qtyper;
76549
 
        _row.bomdata_actunitcost := _x.actunitcost;
76550
 
        _row.bomdata_stdunitcost := _x.stdunitcost;
76551
 
        _row.bomdata_actextendedcost := _x.actextendedcost;
76552
 
        _row.bomdata_stdextendedcost := _x.stdextendedcost;
76553
 
        _row.bomdata_effective := _x.bomwork_effective;
76554
 
        _row.bomdata_expires := _x.bomwork_expires;
76555
 
        _row.bomdata_future := _x.future;
76556
 
        _row.bomdata_expired := _x.expired;
76557
 
        RETURN NEXT _row;
76558
 
    END LOOP;
76559
 
    
76560
 
    PERFORM deleteBOMWorkset(_bomworksetid);
76561
 
 
76562
 
  ELSE
76563
 
   
76564
 
    FOR _x IN
76565
 
       SELECT item_number, uom_name,
76566
 
               item_descrip1, item_descrip2,
76567
 
               (item_descrip1 || ' ' || item_descrip2) AS itemdescription,
76568
 
               SUM(bomhist_qtyreq * (1 + bomhist_scrap)) AS qtyreq,
76569
 
               SUM(bomhist_qtyfxd * (1 + bomhist_scrap)) AS qtyfxd,
76570
 
               SUM(bomhist_qtyper * (1 + bomhist_scrap)) AS qtyper,
76571
 
       MAX(bomhist_actunitcost) AS actunitcost,
76572
 
       MAX(bomhist_stdunitcost) AS stdunitcost,
76573
 
       CASE WHEN item_type NOT IN ('R','T') THEN
76574
 
         MAX(bomhist_actunitcost) * SUM((bomhist_qtyfxd/_batchsize + bomhist_qtyper) * (1 + bomhist_scrap))
76575
 
       ELSE 0 END AS actextendedcost,
76576
 
       CASE WHEN item_type NOT IN ('R','T') THEN
76577
 
         MAX(bomhist_stdunitcost) * SUM((bomhist_qtyfxd/_batchsize + bomhist_qtyper) * (1 + bomhist_scrap)) 
76578
 
       ELSE 0 END AS stdextendedcost
76579
 
       FROM bomhist, item, uom 
76580
 
       WHERE ( (bomhist_item_id=item_id)
76581
 
       AND (item_inv_uom_id=uom_id)
76582
 
       AND (bomhist_rev_id=pRevisionid) )
76583
 
       AND (bomhist_expires > (CURRENT_DATE - pExpiredDays))
76584
 
       AND (bomhist_effective <= (CURRENT_DATE + pFutureDays))
76585
 
       GROUP BY item_number, uom_name, item_type,
76586
 
                item_descrip1, item_descrip2
76587
 
       ORDER BY item_number
76588
 
    LOOP
76589
 
        _row.bomdata_item_number := _x.item_number;
76590
 
        _row.bomdata_uom_name := _x.uom_name;
76591
 
        _row.bomdata_item_descrip1 := _x.item_descrip1;
76592
 
        _row.bomdata_item_descrip2 := _x.item_descrip2;
76593
 
        _row.bomdata_itemdescription := _x.itemdescription;
76594
 
        _row.bomdata_qtyreq := _x.qtyreq;
76595
 
        _row.bomdata_qtyfxd := _x.qtyfxd;
76596
 
        _row.bomdata_qtyper := _x.qtyper;
76597
 
        _row.bomdata_actunitcost := _x.actunitcost;
76598
 
        _row.bomdata_stdunitcost := _x.stdunitcost;
76599
 
        _row.bomdata_actextendedcost := _x.actextendedcost;
76600
 
        _row.bomdata_stdextendedcost := _x.stdextendedcost;
76601
 
        RETURN NEXT _row;
76602
 
    END LOOP;
76603
 
 
76604
 
  END IF;
76605
 
 
76606
 
  RETURN;
76607
 
 
76608
 
END;
76609
 
$_$;
76610
 
 
76611
 
 
76612
 
ALTER FUNCTION public.summarizedbom(integer, integer, integer, integer) OWNER TO admin;
76613
 
 
76614
 
--
76615
 
--
76616
 
 
76617
 
CREATE FUNCTION summarizetransactions(integer, date, date) RETURNS integer
76618
 
    LANGUAGE plpgsql
76619
 
    AS $_$
76620
 
DECLARE
76621
 
  pItemsiteid ALIAS FOR $1;
76622
 
  pStartDate ALIAS FOR $2;
76623
 
  pEndDate ALIAS FOR $3;
76624
 
  _startDate DATE;
76625
 
  _endDate DATE;
76626
 
  _invhist RECORD;
76627
 
  _itemuom TEXT;
76628
 
  _transCounter INTEGER;
76629
 
  _itemlocSeries INTEGER;
76630
 
 
76631
 
BEGIN
76632
 
 
76633
 
  SELECT uom_name INTO _itemuom
76634
 
  FROM itemsite, item, uom
76635
 
  WHERE ((itemsite_item_id=item_id)
76636
 
    AND (item_inv_uom_id=uom_id)
76637
 
    AND (itemsite_id=pItemsiteid));
76638
 
 
76639
 
  IF (pEndDate > CURRENT_DATE) THEN
76640
 
    _endDate := CURRENT_DATE;
76641
 
  ELSE
76642
 
    _endDate := pEndDate;
76643
 
  END IF;
76644
 
 
76645
 
  IF (pStartDate > pEndDate) THEN
76646
 
    _startDate := pEndDate;
76647
 
  ELSE
76648
 
    _startDate := pStartDate;
76649
 
  END IF;
76650
 
 
76651
 
  SELECT invhist_id INTO _transCounter
76652
 
  FROM invhist JOIN womatlpost ON (womatlpost_invhist_id=invhist_id)
76653
 
  WHERE ((invhist_itemsite_id=pItemsiteid)
76654
 
    AND (invhist_transdate::DATE BETWEEN _startDate AND _endDate))
76655
 
  LIMIT 1;
76656
 
  IF (FOUND) THEN
76657
 
    RETURN 0;
76658
 
  END IF;
76659
 
 
76660
 
  SELECT invhist_id INTO _transCounter
76661
 
  FROM invhist JOIN shipitem ON (shipitem_invhist_id=invhist_id)
76662
 
  WHERE ((invhist_itemsite_id=pItemsiteid)
76663
 
    AND (invhist_transdate::DATE BETWEEN _startDate AND _endDate))
76664
 
  LIMIT 1;
76665
 
  IF (FOUND) THEN
76666
 
    RETURN 0;
76667
 
  END IF;
76668
 
 
76669
 
  _transCounter := 0;
76670
 
  _itemlocSeries := NEXTVAL('itemloc_series_seq');
76671
 
 
76672
 
  FOR _invhist IN SELECT invhist_transtype, invhist_costmethod, SUM(invhist_invqty) AS qty
76673
 
                  FROM invhist
76674
 
                  WHERE ((invhist_itemsite_id=pItemsiteid)
76675
 
                   AND (invhist_transdate::DATE BETWEEN _startDate AND _endDate))
76676
 
                  GROUP BY invhist_transtype, invhist_costmethod LOOP
76677
 
 
76678
 
    DELETE FROM invhist
76679
 
    WHERE ((invhist_transdate::DATE BETWEEN _startDate AND _endDate)
76680
 
     AND (invhist_transtype=_invhist.invhist_transtype)
76681
 
     AND (invhist_itemsite_id=pItemsiteid));
76682
 
 
76683
 
    INSERT INTO invhist
76684
 
    ( invhist_itemsite_id, invhist_transdate, invhist_transtype,
76685
 
      invhist_invqty, invhist_qoh_before, invhist_qoh_after,
76686
 
      invhist_invuom, invhist_user, invhist_ordnumber,
76687
 
      invhist_costmethod, invhist_value_before, invhist_value_after,
76688
 
      invhist_series )
76689
 
    VALUES
76690
 
    ( pItemsiteid, _endDate, _invhist.invhist_transtype,
76691
 
      _invhist.qty, 0, 0,
76692
 
      _itemuom, getEffectiveXtUser(), 'Summary',
76693
 
      _invhist.invhist_costmethod, 0, 0,
76694
 
      _itemlocSeries );
76695
 
 
76696
 
    _transCounter := (_transCounter + 1);
76697
 
 
76698
 
  END LOOP;
76699
 
 
76700
 
  RETURN _transCounter;
76701
 
 
76702
 
END;
76703
 
$_$;
76704
 
 
76705
 
 
76706
 
ALTER FUNCTION public.summarizetransactions(integer, date, date) OWNER TO admin;
76707
 
 
76708
 
--
76709
 
--
76710
 
 
76711
 
CREATE FUNCTION summdemand(integer, integer) RETURNS numeric
76712
 
    LANGUAGE plpgsql
76713
 
    AS $_$
76714
 
DECLARE
76715
 
  pItemsiteid ALIAS FOR $1;
76716
 
  pCalitemid ALIAS FOR $2;
76717
 
  _value NUMERIC;
76718
 
 
76719
 
BEGIN
76720
 
 
76721
 
  SELECT summDemand(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value;
76722
 
 
76723
 
  RETURN _value;
76724
 
 
76725
 
END;
76726
 
$_$;
76727
 
 
76728
 
 
76729
 
ALTER FUNCTION public.summdemand(integer, integer) OWNER TO admin;
76730
 
 
76731
 
--
76732
 
--
76733
 
 
76734
 
CREATE FUNCTION summdemand(integer, date, date) RETURNS numeric
76735
 
    LANGUAGE plpgsql
76736
 
    AS $_$
76737
 
DECLARE
76738
 
  pItemsiteid ALIAS FOR $1;
76739
 
  pStartDate ALIAS FOR $2;
76740
 
  pEndDate ALIAS FOR $3;
76741
 
  _value NUMERIC;
76742
 
 
76743
 
BEGIN
76744
 
 
76745
 
  SELECT SUM(wo_qtyord - wo_qtyrcv) INTO _value
76746
 
  FROM wo
76747
 
  WHERE ( (wo_itemsite_id=pItemsiteid)
76748
 
   AND (wo_status IN ('R', 'I'))
76749
 
   AND (wo_startdate::DATE BETWEEN pStartDate AND pEndDate) );
76750
 
 
76751
 
  IF (_value IS NULL) THEN
76752
 
    _value := 0;
76753
 
  END IF;
76754
 
 
76755
 
  RETURN _value;
76756
 
 
76757
 
END;
76758
 
$_$;
76759
 
 
76760
 
 
76761
 
ALTER FUNCTION public.summdemand(integer, date, date) OWNER TO admin;
76762
 
 
76763
 
--
76764
 
--
76765
 
 
76766
 
CREATE FUNCTION summprod(integer, integer) RETURNS numeric
76767
 
    LANGUAGE plpgsql
76768
 
    AS $_$
76769
 
DECLARE
76770
 
  pItemsiteid ALIAS FOR $1;
76771
 
  pCalitemid ALIAS FOR $2;
76772
 
  _value NUMERIC;
76773
 
 
76774
 
BEGIN
76775
 
 
76776
 
  SELECT summProd(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value;
76777
 
 
76778
 
  RETURN _value;
76779
 
 
76780
 
END;
76781
 
$_$;
76782
 
 
76783
 
 
76784
 
ALTER FUNCTION public.summprod(integer, integer) OWNER TO admin;
76785
 
 
76786
 
--
76787
 
--
76788
 
 
76789
 
CREATE FUNCTION summprod(integer, date, date) RETURNS numeric
76790
 
    LANGUAGE plpgsql
76791
 
    AS $_$
76792
 
DECLARE
76793
 
  pItemsiteid ALIAS FOR $1;
76794
 
  pStartDate ALIAS FOR $2;
76795
 
  pEndDate ALIAS FOR $3;
76796
 
  _value NUMERIC;
76797
 
 
76798
 
BEGIN
76799
 
 
76800
 
  SELECT SUM(invhist_invqty) INTO _value
76801
 
  FROM invhist
76802
 
  WHERE ( (invhist_itemsite_id=pItemsiteid)
76803
 
   AND (invhist_transtype IN ('RM', 'RB'))
76804
 
   AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) );
76805
 
 
76806
 
  IF (_value IS NULL) THEN
76807
 
    _value := 0;
76808
 
  END IF;
76809
 
 
76810
 
  RETURN _value;
76811
 
 
76812
 
END;
76813
 
$_$;
76814
 
 
76815
 
 
76816
 
ALTER FUNCTION public.summprod(integer, date, date) OWNER TO admin;
76817
 
 
76818
 
--
76819
 
--
76820
 
 
76821
 
CREATE FUNCTION summtransa(integer, integer) RETURNS numeric
76822
 
    LANGUAGE plpgsql
76823
 
    AS $_$
76824
 
DECLARE
76825
 
  pItemsiteid ALIAS FOR $1;
76826
 
  pCalitemid ALIAS FOR $2;
76827
 
  _value NUMERIC;
76828
 
 
76829
 
BEGIN
76830
 
 
76831
 
  SELECT summTransA(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value;
76832
 
 
76833
 
  RETURN _value;
76834
 
 
76835
 
END;
76836
 
$_$;
76837
 
 
76838
 
 
76839
 
ALTER FUNCTION public.summtransa(integer, integer) OWNER TO admin;
76840
 
 
76841
 
--
76842
 
--
76843
 
 
76844
 
CREATE FUNCTION summtransa(integer, date, date) RETURNS numeric
76845
 
    LANGUAGE plpgsql
76846
 
    AS $_$
76847
 
DECLARE
76848
 
  pItemsiteid ALIAS FOR $1;
76849
 
  pStartDate ALIAS FOR $2;
76850
 
  pEndDate ALIAS FOR $3;
76851
 
  _value NUMERIC;
76852
 
 
76853
 
BEGIN
76854
 
 
76855
 
  SELECT SUM(invhist_invqty) INTO _value
76856
 
  FROM invhist
76857
 
  WHERE ((invhist_transdate::DATE BETWEEN pStartDate AND pEndDate)
76858
 
   AND (invhist_transtype IN ('AD', 'CC'))
76859
 
   AND (invhist_itemsite_id=pItemsiteid));
76860
 
 
76861
 
  IF (_value IS NULL) THEN
76862
 
    _value := 0;
76863
 
  END IF;
76864
 
 
76865
 
  RETURN _value;
76866
 
 
76867
 
END;
76868
 
$_$;
76869
 
 
76870
 
 
76871
 
ALTER FUNCTION public.summtransa(integer, date, date) OWNER TO admin;
76872
 
 
76873
 
--
76874
 
--
76875
 
 
76876
 
CREATE FUNCTION summtransc(integer, integer) RETURNS numeric
76877
 
    LANGUAGE plpgsql
76878
 
    AS $_$
76879
 
DECLARE
76880
 
  pItemsiteid ALIAS FOR $1;
76881
 
  pCalitemid ALIAS FOR $2;
76882
 
  _value NUMERIC;
76883
 
 
76884
 
BEGIN
76885
 
 
76886
 
  SELECT summTransC(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value;
76887
 
 
76888
 
  RETURN _value;
76889
 
 
76890
 
END;
76891
 
$_$;
76892
 
 
76893
 
 
76894
 
ALTER FUNCTION public.summtransc(integer, integer) OWNER TO admin;
76895
 
 
76896
 
--
76897
 
--
76898
 
 
76899
 
CREATE FUNCTION summtransc(integer, date, date) RETURNS numeric
76900
 
    LANGUAGE plpgsql
76901
 
    AS $_$
76902
 
DECLARE
76903
 
  pItemsiteid ALIAS FOR $1;
76904
 
  pStartDate ALIAS FOR $2;
76905
 
  pEndDAte ALIAS FOR $3;
76906
 
  _value NUMERIC;
76907
 
 
76908
 
BEGIN
76909
 
 
76910
 
  SELECT SUM(invhist_invqty) INTO _value
76911
 
  FROM invhist
76912
 
  WHERE ((invhist_transdate::DATE BETWEEN pStartDate AND pEndDate)
76913
 
   AND (invhist_transtype IN ('SI'))
76914
 
   AND (invhist_itemsite_id=pItemsiteid));
76915
 
 
76916
 
  IF (_value IS NULL) THEN
76917
 
    _value := 0;
76918
 
  END IF;
76919
 
 
76920
 
  RETURN _value;
76921
 
 
76922
 
END;
76923
 
$_$;
76924
 
 
76925
 
 
76926
 
ALTER FUNCTION public.summtransc(integer, date, date) OWNER TO admin;
76927
 
 
76928
 
--
76929
 
--
76930
 
 
76931
 
CREATE FUNCTION summtransi(integer, integer) RETURNS numeric
76932
 
    LANGUAGE plpgsql
76933
 
    AS $_$
76934
 
DECLARE
76935
 
  pItemsiteid ALIAS FOR $1;
76936
 
  pCalitemid ALIAS FOR $2;
76937
 
  _value NUMERIC;
76938
 
 
76939
 
BEGIN
76940
 
 
76941
 
  SELECT summTransI(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value;
76942
 
 
76943
 
  RETURN _value;
76944
 
 
76945
 
END;
76946
 
$_$;
76947
 
 
76948
 
 
76949
 
ALTER FUNCTION public.summtransi(integer, integer) OWNER TO admin;
76950
 
 
76951
 
--
76952
 
--
76953
 
 
76954
 
CREATE FUNCTION summtransi(integer, date, date) RETURNS numeric
76955
 
    LANGUAGE plpgsql
76956
 
    AS $_$
76957
 
DECLARE
76958
 
  pItemsiteid ALIAS FOR $1;
76959
 
  pStartDate ALIAS FOR $2;
76960
 
  pEndDate ALIAS FOR $3;
76961
 
  _value NUMERIC;
76962
 
 
76963
 
BEGIN
76964
 
 
76965
 
  SELECT SUM(invhist_invqty) INTO _value
76966
 
  FROM invhist
76967
 
  WHERE ((invhist_transdate::DATE BETWEEN pStartDate AND pEndDate)
76968
 
   AND (invhist_transtype IN ('IM', 'IC'))
76969
 
   AND (invhist_itemsite_id=pItemsiteid));
76970
 
 
76971
 
  IF (_value IS NULL) THEN
76972
 
    _value := 0;
76973
 
  END IF;
76974
 
 
76975
 
  RETURN _value;
76976
 
 
76977
 
END;
76978
 
$_$;
76979
 
 
76980
 
 
76981
 
ALTER FUNCTION public.summtransi(integer, date, date) OWNER TO admin;
76982
 
 
76983
 
--
76984
 
--
76985
 
 
76986
 
CREATE FUNCTION summtransr(integer, integer) RETURNS numeric
76987
 
    LANGUAGE plpgsql
76988
 
    AS $_$
76989
 
DECLARE
76990
 
  pItemsiteid ALIAS FOR $1;
76991
 
  pCalitemid ALIAS FOR $2;
76992
 
  _value NUMERIC;
76993
 
 
76994
 
BEGIN
76995
 
 
76996
 
  SELECT summTransR(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value;
76997
 
 
76998
 
  RETURN _value;
76999
 
 
77000
 
END;
77001
 
$_$;
77002
 
 
77003
 
 
77004
 
ALTER FUNCTION public.summtransr(integer, integer) OWNER TO admin;
77005
 
 
77006
 
--
77007
 
--
77008
 
 
77009
 
CREATE FUNCTION summtransr(integer, date, date) RETURNS numeric
77010
 
    LANGUAGE plpgsql
77011
 
    AS $_$
77012
 
DECLARE
77013
 
  pItemsiteid ALIAS FOR $1;
77014
 
  pStartDate ALIAS FOR $2;
77015
 
  pEndDate ALIAS FOR $3;
77016
 
  _value NUMERIC;
77017
 
 
77018
 
BEGIN
77019
 
 
77020
 
  SELECT SUM(invhist_invqty) INTO _value
77021
 
  FROM invhist
77022
 
  WHERE ((invhist_transdate::DATE BETWEEN pStartDate AND pEndDate)
77023
 
   AND (invhist_transtype IN ('RM', 'RP', 'RX'))
77024
 
   AND (invhist_itemsite_id=pItemsiteid) );
77025
 
 
77026
 
  IF (_value IS NULL) THEN
77027
 
    _value := 0;
77028
 
  END IF;
77029
 
 
77030
 
  RETURN _value;
77031
 
 
77032
 
END;
77033
 
$_$;
77034
 
 
77035
 
 
77036
 
ALTER FUNCTION public.summtransr(integer, date, date) OWNER TO admin;
77037
 
 
77038
 
--
77039
 
--
77040
 
 
77041
 
CREATE FUNCTION summtranss(pitemsiteid integer, pcalitemid integer) RETURNS numeric
77042
 
    LANGUAGE plpgsql
77043
 
    AS $_$
77044
 
DECLARE
77045
 
  pItemsiteid ALIAS FOR $1;
77046
 
  pCalitemid ALIAS FOR $2;
77047
 
  _value NUMERIC;
77048
 
 
77049
 
BEGIN
77050
 
 
77051
 
  SELECT summTransS(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value;
77052
 
 
77053
 
  RETURN _value;
77054
 
 
77055
 
END;
77056
 
$_$;
77057
 
 
77058
 
 
77059
 
ALTER FUNCTION public.summtranss(pitemsiteid integer, pcalitemid integer) OWNER TO admin;
77060
 
 
77061
 
--
77062
 
--
77063
 
 
77064
 
CREATE FUNCTION summtranss(pitemsiteid integer, pstartdate date, penddate date) RETURNS numeric
77065
 
    LANGUAGE plpgsql
77066
 
    AS $$
77067
 
DECLARE
77068
 
  _value NUMERIC;
77069
 
 
77070
 
BEGIN
77071
 
 
77072
 
  SELECT SUM( CASE WHEN (invhist_transtype = 'RS') THEN (invhist_invqty * -1)
77073
 
                   ELSE (invhist_invqty)
77074
 
              END ) INTO _value
77075
 
  FROM invhist
77076
 
  WHERE ( (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate)
77077
 
   AND (invhist_transtype IN ('SC', 'SH', 'SV', 'RS'))
77078
 
   AND (invhist_ordtype != 'TO')
77079
 
   AND (invhist_itemsite_id=pItemsiteid) );
77080
 
 
77081
 
  IF (_value IS NULL) THEN
77082
 
    _value := 0;
77083
 
  END IF;
77084
 
 
77085
 
  RETURN _value;
77086
 
 
77087
 
END;
77088
 
$$;
77089
 
 
77090
 
 
77091
 
ALTER FUNCTION public.summtranss(pitemsiteid integer, pstartdate date, penddate date) OWNER TO admin;
77092
 
 
77093
 
--
77094
 
--
77095
 
 
77096
 
CREATE FUNCTION summtranst(integer, integer) RETURNS numeric
77097
 
    LANGUAGE plpgsql
77098
 
    AS $_$
77099
 
DECLARE
77100
 
  pItemsiteid ALIAS FOR $1;
77101
 
  pCalitemid ALIAS FOR $2;
77102
 
  _value NUMERIC;
77103
 
 
77104
 
BEGIN
77105
 
 
77106
 
  SELECT summTransT(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value;
77107
 
 
77108
 
  RETURN _value;
77109
 
 
77110
 
END;
77111
 
$_$;
77112
 
 
77113
 
 
77114
 
ALTER FUNCTION public.summtranst(integer, integer) OWNER TO admin;
77115
 
 
77116
 
--
77117
 
--
77118
 
 
77119
 
CREATE FUNCTION summtranst(integer, date, date) RETURNS numeric
77120
 
    LANGUAGE plpgsql
77121
 
    AS $_$
77122
 
DECLARE
77123
 
  pItemsiteid ALIAS FOR $1;
77124
 
  pStartDate ALIAS FOR $2;
77125
 
  pEndDate ALIAS FOR $3;
77126
 
  _value NUMERIC;
77127
 
 
77128
 
BEGIN
77129
 
 
77130
 
  SELECT SUM( CASE WHEN (invhist_transtype = 'TS') THEN (invhist_invqty * -1)
77131
 
                   ELSE (invhist_invqty)
77132
 
              END ) INTO _value
77133
 
  FROM invhist
77134
 
  WHERE ( (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate)
77135
 
   AND (invhist_transtype IN ('TS', 'TR', 'TW'))
77136
 
   AND (invhist_itemsite_id=pItemsiteid) );
77137
 
 
77138
 
  IF (_value IS NULL) THEN
77139
 
    _value := 0;
77140
 
  END IF;
77141
 
 
77142
 
  RETURN _value;
77143
 
 
77144
 
END;
77145
 
$_$;
77146
 
 
77147
 
 
77148
 
ALTER FUNCTION public.summtranst(integer, date, date) OWNER TO admin;
77149
 
 
77150
 
--
77151
 
--
77152
 
 
77153
 
CREATE FUNCTION taxassignments(integer, integer) RETURNS SETOF taxassign
77154
 
    LANGUAGE plpgsql
77155
 
    AS $_$
77156
 
DECLARE
77157
 
  pTaxZoneId ALIAS FOR $1;
77158
 
  pTaxTypeId ALIAS FOR $2;
77159
 
  _row taxassign%ROWTYPE;
77160
 
  _qry text;
77161
 
  _x RECORD;
77162
 
  _y RECORD;
77163
 
  _z RECORD;
77164
 
 
77165
 
BEGIN
77166
 
  _qry = 'SELECT DISTINCT COALESCE(taxass_taxzone_id, -1) AS taxass_taxzone_id, COALESCE(taxass_taxtype_id, -1) AS taxass_taxtype_id, ';
77167
 
  _qry = _qry || 'taxzone_code, taxtype_name FROM taxass LEFT OUTER JOIN taxzone ON (taxass_taxzone_id=taxzone_id) ';
77168
 
  _qry = _qry || 'LEFT OUTER JOIN taxtype ON (taxass_taxtype_id=taxtype_id) ';
77169
 
 
77170
 
  IF ((pTaxZoneId > 0) OR (pTaxTypeId > 0)) THEN
77171
 
    _qry := _qry || ' WHERE ';
77172
 
    IF (pTaxZoneId > 0) THEN
77173
 
      _qry := _qry || ' (taxass_taxzone_id = ' || pTaxZoneId ||')';
77174
 
      IF (pTaxTypeId > 0) THEN
77175
 
        _qry := _qry || ' AND ';
77176
 
      END IF;
77177
 
    END IF;
77178
 
    IF (pTaxTypeId > 0) THEN
77179
 
      _qry := _qry || ' (taxass_taxtype_id = ' || pTaxTypeId || ')';
77180
 
    END IF;
77181
 
  END IF;
77182
 
 
77183
 
  --This first query gets all the distinct tax zone and type groupings as if it were its own table.
77184
 
  --This allows us to have a level 0 record as pictured in Tax Assignments window that code assignements will
77185
 
  --Subordinate to.
77186
 
  FOR _x IN  EXECUTE _qry
77187
 
  LOOP
77188
 
    --Map values to _row here
77189
 
    _row.taxassign_taxzone_id = _x.taxass_taxzone_id;
77190
 
    _row.taxassign_taxtype_id = _x.taxass_taxtype_id;
77191
 
    _row.taxassign_level = 0;
77192
 
    _row.taxassign_zone_code = _x.taxzone_code;
77193
 
    _row.taxassign_type_descrip = _x.taxtype_name;
77194
 
    _row.taxassign_taxclass_code = '';
77195
 
    _row.taxassign_taxclass_sequence = NULL;
77196
 
    RETURN NEXT _row; --so we get a level tax zone/type 0 record.
77197
 
  
77198
 
    -- Now get all the tax code assignments that belong to this Zone and Type pair
77199
 
    FOR _y IN
77200
 
      SELECT taxass_id, COALESCE(taxzone_id, -1) AS taxzone_id, tax_id,
77201
 
      tax_code, tax_descrip, COALESCE(taxtype_id, -1) AS taxtype_id, taxzone_code, 
77202
 
      taxtype_descrip, taxclass_code, 
77203
 
      COALESCE(taxclass_sequence, 0) AS taxclass_sequence
77204
 
      FROM taxass JOIN tax 
77205
 
         LEFT OUTER JOIN taxclass ON (tax_taxclass_id = taxclass_id)
77206
 
      ON (taxass_tax_id = tax_id)
77207
 
      LEFT OUTER JOIN taxzone ON (taxass_taxzone_id = taxzone_id)
77208
 
      LEFT OUTER JOIN taxtype ON (taxass_taxtype_id = taxtype_id)
77209
 
      WHERE COALESCE(taxass_taxzone_id, -1) = _x.taxass_taxzone_id
77210
 
      AND   COALESCE(taxass_taxtype_id, -1) = _x.taxass_taxtype_id
77211
 
    LOOP
77212
 
      --Map results to _row
77213
 
      _row.taxassign_taxzone_id = _y.taxzone_id;
77214
 
      _row.taxassign_taxtype_id = _y.taxtype_id;
77215
 
      _row.taxassign_level = 1;
77216
 
      _row.taxassign_zone_code = _y.tax_code;
77217
 
      _row.taxassign_type_descrip = _y.tax_descrip;
77218
 
      _row.taxassign_taxclass_code = _y.taxclass_code;
77219
 
      _row.taxassign_taxclass_sequence = _y.taxclass_sequence;
77220
 
      RETURN NEXT _row; --to get code detail record;
77221
 
      
77222
 
      FOR _z IN SELECT * FROM getsubtax(_y.tax_id, 1) --a new recursive function described above
77223
 
      LOOP
77224
 
        --Map results to _row
77225
 
        _row.taxassign_taxzone_id = _y.taxzone_id;
77226
 
        _row.taxassign_taxtype_id = _y.taxtype_id;
77227
 
        _row.taxassign_level = _z.subtax_taxcode_level;
77228
 
        _row.taxassign_zone_code = _z.subtax_taxcode_code;
77229
 
        _row.taxassign_type_descrip = _z.subtax_taxcode_descrip;
77230
 
        _row.taxassign_taxclass_code = _y.taxclass_code;
77231
 
        _row.taxassign_taxclass_sequence = _y.taxclass_sequence;
77232
 
        RETURN NEXT _row;
77233
 
      END  LOOP;
77234
 
 
77235
 
    END LOOP;
77236
 
 
77237
 
  END LOOP;
77238
 
 
77239
 
END;
77240
 
$_$;
77241
 
 
77242
 
 
77243
 
ALTER FUNCTION public.taxassignments(integer, integer) OWNER TO admin;
77244
 
 
77245
 
--
77246
 
--
77247
 
 
77248
 
CREATE FUNCTION thawaccountingperiod(integer) RETURNS integer
77249
 
    LANGUAGE plpgsql
77250
 
    AS $_$
77251
 
DECLARE
77252
 
  pPeriodid ALIAS FOR $1;
77253
 
  _r RECORD;
77254
 
 
77255
 
BEGIN
77256
 
 
77257
 
  IF ( ( SELECT (NOT period_freeze)
77258
 
         FROM period
77259
 
         WHERE (period_id=pPeriodid) ) ) THEN
77260
 
    RETURN -2;
77261
 
  END IF;
77262
 
 
77263
 
  IF ( ( SELECT (period_closed)
77264
 
         FROM period
77265
 
         WHERE (period_id=pPeriodid) ) ) THEN
77266
 
    RETURN -1;
77267
 
  END IF;
77268
 
 
77269
 
  UPDATE period
77270
 
  SET period_freeze=FALSE
77271
 
  WHERE (period_id=pPeriodid);
77272
 
 
77273
 
  FOR _r IN SELECT DISTINCT gltrans_sequence
77274
 
            FROM gltrans, accnt, period
77275
 
            WHERE ( (gltrans_accnt_id=accnt_id)
77276
 
             AND (NOT gltrans_posted)
77277
 
             AND (gltrans_date BETWEEN period_start AND period_end)
77278
 
             AND (period_id=pPeriodid) ) LOOP
77279
 
    PERFORM postIntoTrialBalance(_r.gltrans_sequence);
77280
 
  END LOOP;
77281
 
 
77282
 
  RETURN pPeriodid;
77283
 
 
77284
 
END;
77285
 
$_$;
77286
 
 
77287
 
 
77288
 
ALTER FUNCTION public.thawaccountingperiod(integer) OWNER TO admin;
77289
 
 
77290
 
--
77291
 
--
77292
 
 
77293
 
CREATE FUNCTION thawitemsite(pitemsiteid integer) RETURNS integer
77294
 
    LANGUAGE plpgsql
77295
 
    AS $$
77296
 
DECLARE
77297
 
  _qoh            NUMERIC := 0;
77298
 
  _value          NUMERIC := 0;
77299
 
  _itemlocid INTEGER;
77300
 
  _itemloc RECORD;
77301
 
  _invhist RECORD;
77302
 
  _coarse RECORD;
77303
 
  _fine RECORD;
77304
 
 
77305
 
BEGIN
77306
 
 
77307
 
  IF ( SELECT itemsite_freeze
77308
 
       FROM itemsite
77309
 
       WHERE (itemsite_id=pItemsiteid) ) THEN
77310
 
 
77311
 
    SELECT invhist_id INTO _invhist
77312
 
    FROM invhist
77313
 
    WHERE ( (invhist_itemsite_id=pItemsiteid)
77314
 
     AND (NOT invhist_posted) )
77315
 
    LIMIT 1;
77316
 
    IF (NOT FOUND) THEN
77317
 
      UPDATE itemsite
77318
 
      SET itemsite_freeze=FALSE
77319
 
      WHERE (itemsite_id=pItemsiteid);
77320
 
   END IF;
77321
 
 
77322
 
    IF ( SELECT ( (itemsite_loccntrl) OR
77323
 
                  (itemsite_controlmethod IN ('L', 'S')) )
77324
 
         FROM itemsite
77325
 
         WHERE (itemsite_id=pItemsiteid) ) THEN
77326
 
 
77327
 
      FOR _coarse IN SELECT DISTINCT invdetail_location_id, invdetail_ls_id,
77328
 
                                     invdetail_expiration, invdetail_warrpurc
77329
 
                     FROM invhist, invdetail
77330
 
                     WHERE ( (invdetail_invhist_id=invhist_id)
77331
 
                      AND (NOT invhist_posted)
77332
 
                      AND (invhist_itemsite_id=pItemsiteid) )
77333
 
                     ORDER BY invdetail_location_id, invdetail_ls_id LOOP
77334
 
 
77335
 
        SELECT itemloc_id, itemloc_qty
77336
 
        INTO _itemloc
77337
 
        FROM itemloc
77338
 
        WHERE ( (itemloc_itemsite_id=pItemsiteid)
77339
 
         AND (itemloc_location_id=_coarse.invdetail_location_id)
77340
 
         AND (COALESCE(itemloc_ls_id,-1)=COALESCE(_coarse.invdetail_ls_id,-1))
77341
 
         AND (COALESCE(itemloc_expiration,endOfTime())=COALESCE(_coarse.invdetail_expiration,endOfTime()))
77342
 
         AND (COALESCE(itemloc_warrpurc,endOfTime())=COALESCE(_coarse.invdetail_warrpurc,endOfTime())) );
77343
 
 
77344
 
        IF (NOT FOUND) THEN
77345
 
          SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _itemlocid;
77346
 
          INSERT INTO itemloc
77347
 
          ( itemloc_id, itemloc_itemsite_id,
77348
 
            itemloc_location_id, itemloc_ls_id,
77349
 
            itemloc_qty, itemloc_expiration )
77350
 
          VALUES
77351
 
          ( _itemlocid, pItemsiteid,
77352
 
            _coarse.invdetail_location_id, _coarse.invdetail_ls_id,
77353
 
            0, endOfTime() );
77354
 
 
77355
 
        _qoh := 0.0;
77356
 
 
77357
 
        ELSE
77358
 
          _itemlocid := _itemloc.itemloc_id;
77359
 
          _qoh := _itemloc.itemloc_qty;
77360
 
        END IF;
77361
 
 
77362
 
        FOR _fine IN SELECT invdetail_id, invdetail_qty
77363
 
                     FROM invhist, invdetail
77364
 
                     WHERE ( (invdetail_invhist_id=invhist_id)
77365
 
                      AND (NOT invhist_posted)
77366
 
                      AND (invhist_itemsite_id=pItemsiteid)
77367
 
                      AND (invdetail_location_id=_coarse.invdetail_location_id)
77368
 
                      AND (COALESCE(invdetail_ls_id,-1)=COALESCE(_coarse.invdetail_ls_id,-1))
77369
 
                      AND (COALESCE(invdetail_expiration,endOfTime())=COALESCE(_coarse.invdetail_expiration,endOfTime()))
77370
 
                      AND (COALESCE(invdetail_warrpurc,endOfTime())=COALESCE(_coarse.invdetail_warrpurc,endOfTime())) )
77371
 
                     ORDER BY invhist_transdate LOOP
77372
 
 
77373
 
          UPDATE invdetail
77374
 
          SET invdetail_qty_before = _qoh,
77375
 
              invdetail_qty_after = (_qoh + invdetail_qty)
77376
 
          WHERE (invdetail_id=_fine.invdetail_id);
77377
 
 
77378
 
          _qoh = (_qoh + _fine.invdetail_qty);
77379
 
 
77380
 
        END LOOP;
77381
 
 
77382
 
        IF (_qoh = 0) THEN
77383
 
          DELETE FROM itemloc
77384
 
          WHERE (itemloc_id=_itemlocid);
77385
 
 
77386
 
        ELSE
77387
 
          UPDATE itemloc
77388
 
          SET itemloc_qty=_qoh
77389
 
          WHERE (itemloc_id=_itemlocid);
77390
 
        END IF;
77391
 
 
77392
 
      END LOOP;
77393
 
 
77394
 
    END IF; 
77395
 
 
77396
 
    SELECT itemsite_qtyonhand, itemsite_value INTO _qoh, _value
77397
 
    FROM itemsite
77398
 
    WHERE (itemsite_id=pItemsiteid);
77399
 
 
77400
 
 
77401
 
    UPDATE itemsite
77402
 
    SET itemsite_freeze=FALSE
77403
 
    WHERE (itemsite_id=pItemsiteid);
77404
 
 
77405
 
    FOR _invhist IN SELECT invhist_id,
77406
 
                           invhist_qoh_before, invhist_qoh_after,
77407
 
                           invhist_value_before, invhist_value_after
77408
 
                      FROM invhist
77409
 
                     WHERE((invhist_itemsite_id=pItemsiteid)
77410
 
                       AND (NOT invhist_posted))
77411
 
                     ORDER BY invhist_transdate LOOP
77412
 
 
77413
 
      UPDATE invhist
77414
 
      SET invhist_qoh_before = _qoh,
77415
 
          invhist_qoh_after = ( _qoh +
77416
 
                                _invhist.invhist_qoh_after -
77417
 
                                _invhist.invhist_qoh_before ),
77418
 
          invhist_value_before = _value,
77419
 
          invhist_value_after = ( _value +
77420
 
                                  _invhist.invhist_value_after -
77421
 
                                  _invhist.invhist_value_before ),
77422
 
          invhist_posted = TRUE
77423
 
      WHERE (invhist_id=_invhist.invhist_id);
77424
 
 
77425
 
      _qoh := (_qoh + (_invhist.invhist_qoh_after - _invhist.invhist_qoh_before));
77426
 
      _value := (_value + (_invhist.invhist_value_after - _invhist.invhist_value_before));
77427
 
 
77428
 
    END LOOP;
77429
 
 
77430
 
    UPDATE itemsite
77431
 
       SET itemsite_qtyonhand = _qoh,
77432
 
           itemsite_value = CASE WHEN ((itemsite_costmethod='A') AND (_value < 0.0)) THEN 0.0
77433
 
                                 ELSE _value END
77434
 
     WHERE(itemsite_id=pItemsiteid);
77435
 
 
77436
 
  END IF;
77437
 
 
77438
 
  RETURN pItemsiteid;
77439
 
 
77440
 
END;
77441
 
$$;
77442
 
 
77443
 
 
77444
 
ALTER FUNCTION public.thawitemsite(pitemsiteid integer) OWNER TO admin;
77445
 
 
77446
 
--
77447
 
--
77448
 
 
77449
 
CREATE TABLE todoitem (
77450
 
    todoitem_id integer NOT NULL,
77451
 
    todoitem_name text NOT NULL,
77452
 
    todoitem_description text,
77453
 
    todoitem_incdt_id integer,
77454
 
    todoitem_creator_username text DEFAULT geteffectivextuser() NOT NULL,
77455
 
    todoitem_status character(1),
77456
 
    todoitem_active boolean DEFAULT true NOT NULL,
77457
 
    todoitem_start_date date,
77458
 
    todoitem_due_date date,
77459
 
    todoitem_assigned_date date,
77460
 
    todoitem_completed_date date,
77461
 
    todoitem_seq integer DEFAULT 0 NOT NULL,
77462
 
    todoitem_notes text,
77463
 
    todoitem_crmacct_id integer,
77464
 
    todoitem_ophead_id integer,
77465
 
    todoitem_owner_username text,
77466
 
    todoitem_priority_id integer,
77467
 
    todoitem_username text,
77468
 
    todoitem_recurring_todoitem_id integer,
77469
 
    todoitem_cntct_id integer
77470
 
);
77471
 
 
77472
 
 
77473
 
ALTER TABLE public.todoitem OWNER TO admin;
77474
 
 
77475
 
--
77476
 
--
77477
 
 
77478
 
COMMENT ON TABLE todoitem IS 'To-Do List items.';
77479
 
 
77480
 
 
77481
 
--
77482
 
--
77483
 
 
77484
 
COMMENT ON COLUMN todoitem.todoitem_recurring_todoitem_id IS 'The first todoitem record in the series if this is a recurring To-Do item. If the todoitem_recurring_todoitem_id is the same as the todoitem_id, this record is the first in the series.';
77485
 
 
77486
 
 
77487
 
--
77488
 
--
77489
 
 
77490
 
CREATE FUNCTION todoitem() RETURNS SETOF todoitem
77491
 
    LANGUAGE plpgsql
77492
 
    AS $$
77493
 
DECLARE
77494
 
  _row todoitem%ROWTYPE;
77495
 
  _priv TEXT;
77496
 
  _grant BOOLEAN;
77497
 
 
77498
 
BEGIN
77499
 
  -- This query will give us the most permissive privilege the user has been granted
77500
 
  SELECT privilege, granted INTO _priv, _grant
77501
 
  FROM privgranted 
77502
 
  WHERE privilege IN ('MaintainAllToDoItems','ViewAllToDoItems','MaintainPersonalToDoItems','ViewPersonalToDoItems')
77503
 
  ORDER BY granted DESC, sequence
77504
 
  LIMIT 1;
77505
 
 
77506
 
  -- If have an 'All' privilege return all results
77507
 
  IF (_priv ~ 'All' AND _grant) THEN
77508
 
    FOR _row IN 
77509
 
      SELECT * FROM todoitem
77510
 
    LOOP
77511
 
      RETURN NEXT _row;
77512
 
    END LOOP;
77513
 
  -- Otherwise if have any other grant, must be personal privilege.
77514
 
  ELSIF (_grant) THEN
77515
 
    FOR _row IN 
77516
 
      SELECT * FROM todoitem 
77517
 
      WHERE getEffectiveXtUser() IN (todoitem_owner_username, todoitem_username)
77518
 
    LOOP
77519
 
      RETURN NEXT _row;
77520
 
    END LOOP;
77521
 
  END IF;
77522
 
 
77523
 
  RETURN;
77524
 
 
77525
 
END;
77526
 
$$;
77527
 
 
77528
 
 
77529
 
ALTER FUNCTION public.todoitem() OWNER TO admin;
77530
 
 
77531
 
--
77532
 
--
77533
 
 
77534
 
COMMENT ON FUNCTION todoitem() IS 'A table function that returns To Do Items results according to privilege settings.';
77535
 
 
77536
 
 
77537
 
--
77538
 
--
77539
 
 
77540
 
CREATE FUNCTION todoitemmove(integer, integer) RETURNS integer
77541
 
    LANGUAGE plpgsql
77542
 
    AS $_$
77543
 
DECLARE
77544
 
  ptodoItemId ALIAS FOR $1;
77545
 
  pHowFar     ALIAS FOR $2;   -- -1 moves toward front of list, +1 toward back
77546
 
  _howFar     INTEGER := pHowFar;
77547
 
  _username   TEXT;
77548
 
  _currseq    INTEGER;
77549
 
BEGIN
77550
 
  SELECT todoitem_username, todoitem_seq INTO _username, _currseq
77551
 
  FROM todoitem
77552
 
  WHERE todoitem_id = ptodoItemId;
77553
 
 
77554
 
  IF NOT FOUND THEN
77555
 
    RETURN -1;
77556
 
  END IF;
77557
 
 
77558
 
  IF (_currseq + pHowFar <= 0) THEN
77559
 
    _howFar = 1 - _currseq;   -- move to beginning
77560
 
  END IF;
77561
 
 
77562
 
  UPDATE todoitem
77563
 
  SET todoitem_seq=todoitem_seq - _howFar
77564
 
  WHERE todoitem_seq >= _currseq + _howFar
77565
 
    AND todoitem_id != ptodoItemId
77566
 
    AND todoitem_username = _username
77567
 
    AND todoitem_status != 'C';
77568
 
 
77569
 
  UPDATE todoitem
77570
 
  SET todoitem_seq=_currseq + _howFar
77571
 
  WHERE todoitem_id = ptodoItemId;
77572
 
 
77573
 
  RETURN 0;
77574
 
END;
77575
 
$_$;
77576
 
 
77577
 
 
77578
 
ALTER FUNCTION public.todoitemmove(integer, integer) OWNER TO admin;
77579
 
 
77580
 
--
77581
 
--
77582
 
 
77583
 
CREATE FUNCTION todoitemmovedown(integer) RETURNS integer
77584
 
    LANGUAGE plpgsql
77585
 
    AS $_$
77586
 
DECLARE
77587
 
  ptodoItemId ALIAS FOR $1;
77588
 
BEGIN
77589
 
  RETURN todoItemMove(ptodoItemId, 1);        -- move toward end of list
77590
 
END;
77591
 
$_$;
77592
 
 
77593
 
 
77594
 
ALTER FUNCTION public.todoitemmovedown(integer) OWNER TO admin;
77595
 
 
77596
 
--
77597
 
--
77598
 
 
77599
 
CREATE FUNCTION todoitemmoveup(integer) RETURNS integer
77600
 
    LANGUAGE plpgsql
77601
 
    AS $_$
77602
 
DECLARE
77603
 
  ptodoItemId ALIAS FOR $1;
77604
 
BEGIN
77605
 
  RETURN todoItemMove(ptodoItemId, -1);       -- move toward front of list
77606
 
END;
77607
 
$_$;
77608
 
 
77609
 
 
77610
 
ALTER FUNCTION public.todoitemmoveup(integer) OWNER TO admin;
77611
 
 
77612
 
--
77613
 
--
77614
 
 
77615
 
CREATE FUNCTION togglebankreccleared(integer, text, integer, numeric) RETURNS boolean
77616
 
    LANGUAGE plpgsql
77617
 
    AS $_$
77618
 
DECLARE
77619
 
  pBankrecid ALIAS FOR $1;
77620
 
  pSource    ALIAS FOR $2;
77621
 
  pSourceid  ALIAS FOR $3;
77622
 
  pCurrrate  ALIAS FOR $4;
77623
 
  _cleared BOOLEAN;
77624
 
  _r RECORD;
77625
 
 
77626
 
BEGIN
77627
 
 
77628
 
  SELECT bankrecitem_id, bankrecitem_cleared INTO _r
77629
 
    FROM bankrecitem
77630
 
   WHERE ( (bankrecitem_bankrec_id=pBankrecid)
77631
 
     AND   (bankrecitem_source=pSource)
77632
 
     AND   (bankrecitem_source_id=pSourceid) );
77633
 
  IF ( NOT FOUND ) THEN
77634
 
    _cleared := TRUE;
77635
 
    INSERT INTO bankrecitem
77636
 
    (bankrecitem_bankrec_id, bankrecitem_source,
77637
 
     bankrecitem_source_id, bankrecitem_cleared,
77638
 
     bankrecitem_curr_rate)
77639
 
    VALUES
77640
 
    (pBankrecid, pSource,
77641
 
     pSourceid, _cleared,
77642
 
     pCurrrate);
77643
 
  ELSE
77644
 
    _cleared := (NOT _r.bankrecitem_cleared);
77645
 
    UPDATE bankrecitem
77646
 
       SET bankrecitem_cleared=_cleared,
77647
 
           bankrecitem_curr_rate=pCurrrate
77648
 
     WHERE (bankrecitem_id=_r.bankrecitem_id);
77649
 
  END IF;
77650
 
 
77651
 
  RETURN _cleared;
77652
 
END;
77653
 
$_$;
77654
 
 
77655
 
 
77656
 
ALTER FUNCTION public.togglebankreccleared(integer, text, integer, numeric) OWNER TO admin;
77657
 
 
77658
 
--
77659
 
--
77660
 
 
77661
 
CREATE FUNCTION togglebankreccleared(integer, text, integer, numeric, numeric) RETURNS boolean
77662
 
    LANGUAGE plpgsql
77663
 
    AS $_$
77664
 
DECLARE
77665
 
  pBankrecid ALIAS FOR $1;
77666
 
  pSource    ALIAS FOR $2;
77667
 
  pSourceid  ALIAS FOR $3;
77668
 
  pCurrrate  ALIAS FOR $4;
77669
 
  pAmount    ALIAS FOR $5;
77670
 
 
77671
 
BEGIN
77672
 
  RETURN toggleBankrecCleared(pBankrecid, pSource, pSourceid, pCurrrate, pAmount, NULL);
77673
 
END;
77674
 
$_$;
77675
 
 
77676
 
 
77677
 
ALTER FUNCTION public.togglebankreccleared(integer, text, integer, numeric, numeric) OWNER TO admin;
77678
 
 
77679
 
--
77680
 
--
77681
 
 
77682
 
CREATE FUNCTION togglebankreccleared(integer, text, integer, numeric, numeric, date) RETURNS boolean
77683
 
    LANGUAGE plpgsql
77684
 
    AS $_$
77685
 
DECLARE
77686
 
  pBankrecid ALIAS FOR $1;
77687
 
  pSource    ALIAS FOR $2;
77688
 
  pSourceid  ALIAS FOR $3;
77689
 
  pCurrrate  ALIAS FOR $4;
77690
 
  pAmount    ALIAS FOR $5;
77691
 
  pDate      ALIAS FOR $6;
77692
 
  _cleared BOOLEAN;
77693
 
  _r RECORD;
77694
 
 
77695
 
BEGIN
77696
 
  SELECT bankrecitem_id, bankrecitem_cleared INTO _r
77697
 
    FROM bankrecitem
77698
 
   WHERE ( (bankrecitem_bankrec_id=pBankrecid)
77699
 
     AND   (bankrecitem_source=pSource)
77700
 
     AND   (bankrecitem_source_id=pSourceid) );
77701
 
  IF ( NOT FOUND ) THEN
77702
 
    _cleared := TRUE;
77703
 
    INSERT INTO bankrecitem
77704
 
    (bankrecitem_bankrec_id, bankrecitem_source,
77705
 
     bankrecitem_source_id, bankrecitem_cleared,
77706
 
     bankrecitem_curr_rate, bankrecitem_amount,
77707
 
     bankrecitem_effdate)
77708
 
    VALUES
77709
 
    (pBankrecid, pSource,
77710
 
     pSourceid, _cleared,
77711
 
     pCurrrate, pAmount,
77712
 
     pDate);
77713
 
  ELSE
77714
 
    _cleared := FALSE;
77715
 
    DELETE FROM bankrecitem 
77716
 
    WHERE bankrecitem_id = _r.bankrecitem_id;
77717
 
  END IF;
77718
 
 
77719
 
  RETURN _cleared;
77720
 
END;
77721
 
$_$;
77722
 
 
77723
 
 
77724
 
ALTER FUNCTION public.togglebankreccleared(integer, text, integer, numeric, numeric, date) OWNER TO admin;
77725
 
 
77726
 
--
77727
 
--
77728
 
 
77729
 
CREATE FUNCTION togglebomitemcost(integer, boolean) RETURNS integer
77730
 
    LANGUAGE plpgsql
77731
 
    AS $_$
77732
 
DECLARE
77733
 
  pBomitemid ALIAS FOR $1;
77734
 
  pEnabled   ALIAS FOR $2;
77735
 
 
77736
 
BEGIN
77737
 
 
77738
 
  IF (pEnabled) THEN
77739
 
    INSERT INTO bomitemcost
77740
 
    (bomitemcost_bomitem_id, bomitemcost_costelem_id,
77741
 
     bomitemcost_lowlevel, bomitemcost_stdcost,
77742
 
     bomitemcost_posted, bomitemcost_actcost,
77743
 
     bomitemcost_updated, bomitemcost_curr_id)
77744
 
    SELECT
77745
 
     bomitem_id, itemcost_costelem_id,
77746
 
     itemcost_lowlevel, itemcost_stdcost,
77747
 
     itemcost_posted, itemcost_actcost,
77748
 
     itemcost_updated, itemcost_curr_id
77749
 
    FROM bomitem JOIN itemcost ON (itemcost_item_id=bomitem_item_id)
77750
 
    WHERE (bomitem_id=pBomitemid);
77751
 
  ELSE
77752
 
    DELETE FROM bomitemcost
77753
 
    WHERE (bomitemcost_bomitem_id=pBomitemid);
77754
 
  END IF;
77755
 
 
77756
 
  RETURN 0;
77757
 
END;
77758
 
$_$;
77759
 
 
77760
 
 
77761
 
ALTER FUNCTION public.togglebomitemcost(integer, boolean) OWNER TO admin;
77762
 
 
77763
 
--
77764
 
--
77765
 
 
77766
 
CREATE FUNCTION tonumeric(text, numeric) RETURNS numeric
77767
 
    LANGUAGE plpgsql IMMUTABLE
77768
 
    AS $_$
77769
 
DECLARE
77770
 
  pText ALIAS FOR $1;
77771
 
  pDefault ALIAS FOR $2;
77772
 
 
77773
 
BEGIN
77774
 
 
77775
 
  IF (isNumeric(pText)) THEN
77776
 
    RETURN TO_NUMBER(pText, '999999999999');
77777
 
  ELSE
77778
 
    RETURN pDefault;
77779
 
  END IF;
77780
 
 
77781
 
END;
77782
 
$_$;
77783
 
 
77784
 
 
77785
 
ALTER FUNCTION public.tonumeric(text, numeric) OWNER TO admin;
77786
 
 
77787
 
--
77788
 
--
77789
 
 
77790
 
CREATE FUNCTION transitwhs() RETURNS integer
77791
 
    LANGUAGE plpgsql
77792
 
    AS $$
77793
 
DECLARE
77794
 
  _id   INTEGER;
77795
 
 
77796
 
BEGIN
77797
 
  _id = fetchMetricValue('TransitWarehouse');
77798
 
 
77799
 
  IF (_id IS NOT NULL
77800
 
      AND EXISTS(SELECT warehous_id FROM whsinfo WHERE (warehous_id=_id)) ) THEN
77801
 
    RETURN _id;
77802
 
  END IF;
77803
 
 
77804
 
  SELECT warehous_id INTO _id FROM whsinfo WHERE warehous_transit;
77805
 
 
77806
 
  IF (NOT FOUND) THEN
77807
 
    _id := NEXTVAL('warehous_warehous_id_seq');
77808
 
 
77809
 
    INSERT INTO whsinfo (
77810
 
      warehous_id,
77811
 
      warehous_code,
77812
 
      warehous_descrip,
77813
 
      --warehous_fob,
77814
 
      warehous_active,
77815
 
      --warehous_counttag_prefix,
77816
 
      --warehous_counttag_number,
77817
 
      --warehous_bol_prefix,
77818
 
      --warehous_bol_number,
77819
 
      warehous_shipping,
77820
 
      warehous_useslips,
77821
 
      warehous_usezones,
77822
 
      --warehous_aislesize,
77823
 
      --warehous_aislealpha,
77824
 
      --warehous_racksize,
77825
 
      --warehous_rackalpha,
77826
 
      --warehous_binsize,
77827
 
      --warehous_binalpha,
77828
 
      --warehous_locationsize,
77829
 
      --warehous_locationalpha,
77830
 
      warehous_enforcearbl,
77831
 
      warehous_default_accnt_id,
77832
 
      --warehous_shipping_commission,
77833
 
      --warehous_cntct_id,
77834
 
      --warehous_addr_id,
77835
 
      warehous_taxzone_id
77836
 
     ) VALUES (
77837
 
       _id,
77838
 
      'TRANSIT',
77839
 
      'Intermediate Warehouse for Inter-Warehouse Transfers',
77840
 
      --text,
77841
 
      TRUE,
77842
 
      --text, 
77843
 
      --integer, 
77844
 
      --text, 
77845
 
      --integer, 
77846
 
      TRUE,
77847
 
      FALSE,
77848
 
      FALSE,
77849
 
      --integer, 
77850
 
      --boolean, 
77851
 
      --integer, 
77852
 
      --boolean, 
77853
 
      --integer, 
77854
 
      --boolean, 
77855
 
      --integer, 
77856
 
      --boolean, 
77857
 
      FALSE,
77858
 
      fetchMetricValue('UnassignedAccount'),
77859
 
      --numeric(8,4) default 0.00,
77860
 
      --integer, 
77861
 
      --integer, 
77862
 
      NULL
77863
 
    );
77864
 
  END IF;
77865
 
 
77866
 
  PERFORM setMetric('TransitWarehouse', _id);
77867
 
 
77868
 
  RETURN _id;
77869
 
 
77870
 
END;
77871
 
$$;
77872
 
 
77873
 
 
77874
 
ALTER FUNCTION public.transitwhs() OWNER TO admin;
77875
 
 
77876
 
--
77877
 
--
77878
 
 
77879
 
CREATE FUNCTION transtype(text, integer) RETURNS boolean
77880
 
    LANGUAGE plpgsql
77881
 
    AS $_$
77882
 
DECLARE
77883
 
  pTransType ALIAS FOR $1;
77884
 
  pTargetType ALIAS FOR $2;
77885
 
 
77886
 
BEGIN
77887
 
 
77888
 
  IF (pTargetType = 255) THEN
77889
 
    RETURN TRUE;
77890
 
  ELSIF (pTargetType = 1) THEN
77891
 
    RETURN receipts(pTransType);
77892
 
  ELSIF (pTargetType = 2) THEN
77893
 
    RETURN issues(pTransType);
77894
 
  ELSIF (pTargetType = 4) THEN
77895
 
    RETURN shipments(pTransType);
77896
 
  ELSIF (pTargetType = 8) THEN
77897
 
    RETURN adjustments(pTransType);
77898
 
  ELSIF (pTargetType = 16) THEN
77899
 
    RETURN transfers(pTransType);
77900
 
  ELSIF (pTargetType = 32) THEN
77901
 
    RETURN scraps(pTransType);
77902
 
  ELSE
77903
 
    RETURN TRUE;
77904
 
  END IF;
77905
 
 
77906
 
END;
77907
 
$_$;
77908
 
 
77909
 
 
77910
 
ALTER FUNCTION public.transtype(text, integer) OWNER TO admin;
77911
 
 
77912
 
--
77913
 
--
77914
 
 
77915
 
CREATE FUNCTION trylock(integer, integer) RETURNS boolean
77916
 
    LANGUAGE plpgsql
77917
 
    AS $_$
77918
 
DECLARE
77919
 
  pKey1 ALIAS FOR $1;
77920
 
  pKey2 ALIAS FOR $2;
77921
 
  _pid integer;
77922
 
BEGIN
77923
 
 
77924
 
  /* The standard try lock ignores locks made by the current user in same
77925
 
     session.  Check for ANY lock on this id, whether by this user or not */
77926
 
  SELECT pid INTO _pid
77927
 
  FROM pg_locks
77928
 
  WHERE ((classid=pKey1)
77929
 
   AND (objid=pKey2)
77930
 
   AND (objsubid=2));
77931
 
 
77932
 
  IF (FOUND) THEN
77933
 
    RETURN false;
77934
 
  ELSE
77935
 
    RETURN pg_try_advisory_lock(pKey1,pKey2);
77936
 
  END IF;
77937
 
   
77938
 
END;
77939
 
$_$;
77940
 
 
77941
 
 
77942
 
ALTER FUNCTION public.trylock(integer, integer) OWNER TO admin;
77943
 
 
77944
 
--
77945
 
--
77946
 
 
77947
 
CREATE FUNCTION undomerge(text, text, integer) RETURNS integer
77948
 
    LANGUAGE plpgsql
77949
 
    AS $_$
77950
 
DECLARE
77951
 
  pSchema       ALIAS FOR $1;
77952
 
  pTable        ALIAS FOR $2;
77953
 
  pId           ALIAS FOR $3;
77954
 
  _qry          TEXT;
77955
 
  _r            RECORD;
77956
 
  _result       INTEGER;
77957
 
 
77958
 
BEGIN
77959
 
  FOR _r IN
77960
 
    SELECT *
77961
 
      FROM mrgundo
77962
 
     WHERE mrgundo_base_schema = pSchema
77963
 
       AND mrgundo_base_table  = pTable
77964
 
       AND mrgundo_base_id     = pId
77965
 
       AND mrgundo_col IS NOT NULL  -- NULL mrgundo_col signals a row to delete on purge
77966
 
  LOOP
77967
 
    IF (_r.mrgundo_value IS NULL) THEN
77968
 
      _qry := 'UPDATE ' || quote_ident(_r.mrgundo_schema)  ||
77969
 
                    '.' || quote_ident(_r.mrgundo_table)   ||
77970
 
                ' SET ' || quote_ident(_r.mrgundo_col)     || '= NULL
77971
 
               WHERE (' || _r.mrgundo_pkey_col || '=' || _r.mrgundo_pkey_id || ');';
77972
 
    ELSE
77973
 
      _qry := 'UPDATE ' || quote_ident(_r.mrgundo_schema)  ||
77974
 
                    '.' || quote_ident(_r.mrgundo_table)   ||
77975
 
                ' SET ' || quote_ident(_r.mrgundo_col)     ||
77976
 
              '= CAST(' || quote_literal(_r.mrgundo_value) || ' AS '
77977
 
                        || quote_ident(_r.mrgundo_type)    || ')
77978
 
               WHERE (' || _r.mrgundo_pkey_col || '=' || _r.mrgundo_pkey_id || ');';
77979
 
    END IF;
77980
 
 
77981
 
    EXECUTE _qry;
77982
 
  END LOOP;
77983
 
 
77984
 
  DELETE FROM mrgundo
77985
 
   WHERE mrgundo_base_schema = pSchema
77986
 
     AND mrgundo_base_table  = pTable
77987
 
     AND mrgundo_base_id     = pId;
77988
 
 
77989
 
  GET DIAGNOSTICS _result = ROW_COUNT;
77990
 
 
77991
 
  RETURN _result;
77992
 
 
77993
 
END;
77994
 
$_$;
77995
 
 
77996
 
 
77997
 
ALTER FUNCTION public.undomerge(text, text, integer) OWNER TO admin;
77998
 
 
77999
 
--
78000
 
--
78001
 
 
78002
 
CREATE FUNCTION unreleasepurchaseorder(ppoheadid integer) RETURNS integer
78003
 
    LANGUAGE plpgsql
78004
 
    AS $$
78005
 
BEGIN
78006
 
 
78007
 
  IF ( ( SELECT (COUNT(*) > 0)
78008
 
         FROM poitem LEFT OUTER JOIN recv ON (recv_order_type='PO' AND
78009
 
                                              recv_orderitem_id=poitem_id)
78010
 
         WHERE ( (poitem_pohead_id=pPoheadid)
78011
 
           AND   ( (poitem_status='C') OR
78012
 
                   (poitem_qty_received > 0.0) OR
78013
 
                   (poitem_qty_returned > 0.0) OR
78014
 
                   (poitem_qty_vouchered > 0.0) OR
78015
 
                   (recv_id IS NOT NULL) ) ) ) ) THEN
78016
 
    RETURN -1;
78017
 
  END IF;
78018
 
 
78019
 
  IF ( ( SELECT (pohead_status='O')
78020
 
         FROM pohead
78021
 
         WHERE (pohead_id=pPoheadid) ) ) THEN
78022
 
 
78023
 
    --update status and erase the date that the order was released on
78024
 
    UPDATE pohead
78025
 
    SET pohead_status='U', pohead_released = NULL
78026
 
    WHERE (pohead_id=pPoheadid);
78027
 
 
78028
 
  END IF;
78029
 
 
78030
 
  --update status and erase the duedates at release
78031
 
  UPDATE poitem
78032
 
  SET poitem_status='U', poitem_rlsd_duedate = NULL
78033
 
  WHERE (poitem_pohead_id=pPoheadid);
78034
 
 
78035
 
  RETURN 1;
78036
 
 
78037
 
END;
78038
 
$$;
78039
 
 
78040
 
 
78041
 
ALTER FUNCTION public.unreleasepurchaseorder(ppoheadid integer) OWNER TO admin;
78042
 
 
78043
 
--
78044
 
--
78045
 
 
78046
 
CREATE FUNCTION uomusedforitem(integer) RETURNS SETOF uom
78047
 
    LANGUAGE plpgsql
78048
 
    AS $_$
78049
 
DECLARE
78050
 
  pitemid       ALIAS FOR $1;
78051
 
  _row          uom%ROWTYPE;
78052
 
BEGIN
78053
 
  FOR _row IN SELECT DISTINCT *
78054
 
              FROM uom
78055
 
              WHERE uom_id IN (
78056
 
                SELECT bomitem_uom_id AS uom_id 
78057
 
                FROM bomitem 
78058
 
                WHERE (bomitem_item_id=pitemid)
78059
 
                UNION 
78060
 
                SELECT cmitem_qty_uom_id 
78061
 
                FROM cmitem, itemsite 
78062
 
                WHERE ((cmitem_itemsite_id=itemsite_id)
78063
 
                   AND (itemsite_item_id=pitemid))
78064
 
                UNION 
78065
 
                SELECT cmitem_price_uom_id 
78066
 
                FROM cmitem, itemsite 
78067
 
                WHERE ((cmitem_itemsite_id=itemsite_id)
78068
 
                   AND (itemsite_item_id=pitemid))
78069
 
                UNION 
78070
 
                SELECT coitem_qty_uom_id 
78071
 
                FROM coitem, itemsite 
78072
 
                WHERE ((coitem_itemsite_id=itemsite_id)
78073
 
                   AND (itemsite_item_id=pitemid))
78074
 
                UNION 
78075
 
                SELECT coitem_price_uom_id 
78076
 
                FROM coitem, itemsite 
78077
 
                WHERE ((coitem_itemsite_id=itemsite_id)
78078
 
                   AND (itemsite_item_id=pitemid))
78079
 
                UNION 
78080
 
                SELECT invcitem_qty_uom_id 
78081
 
                FROM invcitem 
78082
 
                WHERE ((invcitem_item_id=pitemid))
78083
 
                UNION 
78084
 
                SELECT invcitem_price_uom_id 
78085
 
                FROM invcitem 
78086
 
                WHERE ((invcitem_item_id=pitemid))
78087
 
                UNION 
78088
 
                SELECT ipsitem_qty_uom_id 
78089
 
                FROM ipsiteminfo 
78090
 
                WHERE (ipsitem_item_id=pitemid)
78091
 
                UNION 
78092
 
                SELECT ipsitem_price_uom_id 
78093
 
                FROM ipsiteminfo 
78094
 
                WHERE (ipsitem_item_id=pitemid)
78095
 
                UNION 
78096
 
                SELECT quitem_qty_uom_id 
78097
 
                FROM quitem, itemsite 
78098
 
                WHERE ((quitem_itemsite_id=itemsite_id)
78099
 
                   AND (itemsite_item_id=pitemid))
78100
 
                UNION 
78101
 
                SELECT quitem_price_uom_id 
78102
 
                FROM quitem, itemsite 
78103
 
                WHERE ((quitem_itemsite_id=itemsite_id)
78104
 
                   AND (itemsite_item_id=pitemid))
78105
 
                UNION 
78106
 
                SELECT womatl_uom_id 
78107
 
                FROM womatl, itemsite 
78108
 
                WHERE ((womatl_itemsite_id=itemsite_id)
78109
 
                   AND (itemsite_item_id=pitemid))
78110
 
  ) LOOP
78111
 
    RETURN NEXT _row;
78112
 
  END LOOP;
78113
 
 
78114
 
  IF (fetchmetricbool('MultiWhs')) THEN
78115
 
    FOR _row IN SELECT DISTINCT *
78116
 
                FROM uom
78117
 
                WHERE uom_id IN (
78118
 
                  SELECT rahist_uom_id 
78119
 
                  FROM rahist, itemsite 
78120
 
                  WHERE ((rahist_itemsite_id=itemsite_id)
78121
 
                     AND (itemsite_item_id=pitemid))
78122
 
    ) LOOP
78123
 
      RETURN NEXT _row;
78124
 
    END LOOP;
78125
 
  END IF;
78126
 
 
78127
 
  RETURN;
78128
 
END;
78129
 
$_$;
78130
 
 
78131
 
 
78132
 
ALTER FUNCTION public.uomusedforitem(integer) OWNER TO admin;
78133
 
 
78134
 
--
78135
 
--
78136
 
 
78137
 
CREATE FUNCTION updateabcclass(text, numeric, numeric, date, date) RETURNS integer
78138
 
    LANGUAGE plpgsql
78139
 
    AS $_$
78140
 
DECLARE
78141
 
  pClassCodePattern ALIAS FOR $1;
78142
 
  pACutoff ALIAS FOR $2;
78143
 
  pBCutoff ALIAS FOR $3;
78144
 
  pStartDate ALIAS FOR $4;
78145
 
  pEndDate ALIAS FOR $5;
78146
 
  _result INTEGER;
78147
 
 
78148
 
BEGIN
78149
 
 
78150
 
  SELECT updateABCClass(pClassCodePattern, -1, pACutoff, pBCutoff, pStartDate, pEndDate) INTO _result;
78151
 
  RETURN _result;
78152
 
 
78153
 
END;
78154
 
$_$;
78155
 
 
78156
 
 
78157
 
ALTER FUNCTION public.updateabcclass(text, numeric, numeric, date, date) OWNER TO admin;
78158
 
 
78159
 
--
78160
 
--
78161
 
 
78162
 
CREATE FUNCTION updateabcclass(integer, numeric, numeric, date, date) RETURNS integer
78163
 
    LANGUAGE plpgsql
78164
 
    AS $_$
78165
 
DECLARE
78166
 
  pClasscodeid ALIAS FOR $1;
78167
 
  pACutoff ALIAS FOR $2;
78168
 
  pBCutoff ALIAS FOR $3;
78169
 
  pStartDate ALIAS FOR $4;
78170
 
  pEndDate ALIAS FOR $5;
78171
 
  _result INTEGER;
78172
 
 
78173
 
BEGIN
78174
 
 
78175
 
  SELECT updateABCClass(pClassCodeid, -1, pACutoff, pBCutoff, pStartDate, pEndDate) INTO _result;
78176
 
  RETURN _result;
78177
 
 
78178
 
END;
78179
 
$_$;
78180
 
 
78181
 
 
78182
 
ALTER FUNCTION public.updateabcclass(integer, numeric, numeric, date, date) OWNER TO admin;
78183
 
 
78184
 
--
78185
 
--
78186
 
 
78187
 
CREATE FUNCTION updateabcclass(text, integer, numeric, numeric, date, date) RETURNS integer
78188
 
    LANGUAGE plpgsql
78189
 
    AS $_$
78190
 
DECLARE
78191
 
  pClassCodePattern ALIAS FOR $1;
78192
 
  pWarehousid ALIAS FOR $2;
78193
 
  pACutoff ALIAS FOR $3;
78194
 
  pBCutoff ALIAS FOR $4;
78195
 
  pStartDate ALIAS FOR $5;
78196
 
  pEndDate ALIAS FOR $6;
78197
 
  _updateCount INTEGER;
78198
 
  _totalValue NUMERIC;
78199
 
  _cumulativeValue NUMERIC;
78200
 
  _itemsite RECORD;
78201
 
 
78202
 
BEGIN
78203
 
 
78204
 
  SELECT COUNT(*) INTO _updateCount
78205
 
  FROM itemsite, item, classcode
78206
 
  WHERE ( (itemsite_item_id=item_id)
78207
 
   AND (item_classcode_id=classcode_id)
78208
 
   AND (itemsite_autoabcclass)
78209
 
   AND (classcode_code ~ pClassCodePattern)
78210
 
   AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) );
78211
 
 
78212
 
  IF (_updateCount IS NULL) THEN
78213
 
    RETURN 0;
78214
 
  ELSE
78215
 
 
78216
 
    UPDATE itemsite
78217
 
    SET itemsite_abcclass='T'
78218
 
    FROM item, classcode
78219
 
    WHERE ( (itemsite_item_id=item_id)
78220
 
     AND (item_classcode_id=classcode_id)
78221
 
     AND (itemsite_autoabcclass)
78222
 
     AND (classcode_code ~ pClassCodePattern)
78223
 
     AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) );
78224
 
 
78225
 
    SELECT SUM(ABS(invhist_qoh_before - invhist_qoh_after) * invhist_unitcost) INTO _totalValue
78226
 
    FROM invhist, itemsite, item, classcode
78227
 
    WHERE ( (invhist_itemsite_id=itemsite_id)
78228
 
     AND (itemsite_item_id=item_id)
78229
 
     AND (item_classcode_id=classcode_id)
78230
 
     AND (invhist_analyze)
78231
 
     AND (invhist_transtype ~ '^[IR]')
78232
 
     AND (itemsite_autoabcclass)
78233
 
     AND (classcode_code ~ pClassCodePattern)
78234
 
     AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate)
78235
 
     AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) );
78236
 
 
78237
 
    IF ( (_totalValue IS NULL) OR (_totalValue = 0) ) THEN
78238
 
      UPDATE itemsite
78239
 
      SET itemsite_abcclass='A'
78240
 
      WHERE (itemsite_abcclass='T');
78241
 
    ELSE
78242
 
 
78243
 
      _cumulativeValue := 0;
78244
 
 
78245
 
      FOR _itemsite IN SELECT itemsite_id, item_number,
78246
 
                              SUM(ABS(invhist_qoh_before - invhist_qoh_after) * invhist_unitcost) AS value
78247
 
                       FROM invhist, itemsite, item, classcode
78248
 
                       WHERE ( (invhist_itemsite_id=itemsite_id)
78249
 
                        AND (itemsite_item_id=item_id)
78250
 
                        AND (item_classcode_id=classcode_id)
78251
 
                        AND (invhist_analyze)
78252
 
                        AND (invhist_transtype ~ '^[IR]')
78253
 
                        AND (itemsite_autoabcclass)
78254
 
                        AND (classcode_code ~ pClassCodePattern)
78255
 
                        AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate)
78256
 
                        AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) )
78257
 
                       GROUP BY itemsite_id, item_number
78258
 
                       ORDER BY value DESC LOOP
78259
 
 
78260
 
        IF (_itemsite.value IS NOT NULL) THEN
78261
 
          _cumulativeValue := _cumulativeValue + _itemsite.value;
78262
 
        END IF;
78263
 
 
78264
 
        IF ((_cumulativeValue / _totalValue) <= pACutoff) THEN
78265
 
          UPDATE itemsite
78266
 
          SET itemsite_abcclass='A'
78267
 
          WHERE (itemsite_id=_itemsite.itemsite_id);
78268
 
        ELSE
78269
 
          IF ((_cumulativeValue / _totalValue) <= pBCutoff) THEN
78270
 
            UPDATE itemsite
78271
 
            SET itemsite_abcclass='B'
78272
 
            WHERE (itemsite_id=_itemsite.itemsite_id);
78273
 
          ELSE
78274
 
            UPDATE itemsite
78275
 
            SET itemsite_abcclass='C'
78276
 
            WHERE (itemsite_id=_itemsite.itemsite_id);
78277
 
          END IF;
78278
 
        END IF;
78279
 
 
78280
 
      END LOOP;
78281
 
 
78282
 
      UPDATE itemsite
78283
 
      SET itemsite_abcclass='C'
78284
 
      WHERE (itemsite_abcclass='T');
78285
 
    END IF;
78286
 
 
78287
 
  END IF;
78288
 
 
78289
 
  RETURN _updateCount;
78290
 
 
78291
 
END;
78292
 
$_$;
78293
 
 
78294
 
 
78295
 
ALTER FUNCTION public.updateabcclass(text, integer, numeric, numeric, date, date) OWNER TO admin;
78296
 
 
78297
 
--
78298
 
--
78299
 
 
78300
 
CREATE FUNCTION updateabcclass(integer, integer, numeric, numeric, date, date) RETURNS integer
78301
 
    LANGUAGE plpgsql
78302
 
    AS $_$
78303
 
DECLARE
78304
 
  pClasscodeid ALIAS FOR $1;
78305
 
  pWarehousid ALIAS FOR $2;
78306
 
  pACutoff ALIAS FOR $3;
78307
 
  pBCutoff ALIAS FOR $4;
78308
 
  pStartDate ALIAS FOR $5;
78309
 
  pEndDate ALIAS FOR $6;
78310
 
  _updateCount INTEGER;
78311
 
  _totalValue NUMERIC;
78312
 
  _cumulativeValue NUMERIC;
78313
 
  _itemsite RECORD;
78314
 
 
78315
 
BEGIN
78316
 
 
78317
 
  SELECT COUNT(*) INTO _updateCount
78318
 
  FROM itemsite, item
78319
 
  WHERE ( (itemsite_item_id=item_id)
78320
 
   AND ((item_classcode_id=pClasscodeid) OR (pClasscodeid=-1))
78321
 
   AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) );
78322
 
 
78323
 
  IF (_updateCount IS NULL) THEN
78324
 
    _updateCount := 0;
78325
 
  ELSE
78326
 
 
78327
 
    UPDATE itemsite
78328
 
    SET itemsite_abcclass='T'
78329
 
    FROM item
78330
 
    WHERE ( (itemsite_item_id=item_id)
78331
 
     AND ((item_classcode_id=pClasscodeid) OR (pClasscodeid=-1))
78332
 
     AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) );
78333
 
 
78334
 
    SELECT SUM(ABS(invhist_qoh_before - invhist_qoh_after) * invhist_unitcost) INTO _totalValue
78335
 
    FROM invhist, itemsite, item
78336
 
    WHERE ( (invhist_itemsite_id=itemsite_id)
78337
 
     AND (itemsite_item_id=item_id)
78338
 
     AND (invhist_analyze)
78339
 
     AND (invhist_transtype ~ '^[IR]')
78340
 
     AND ((item_classcode_id=pClasscodeid) OR (pClasscodeid=-1))
78341
 
     AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate)
78342
 
     AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) );
78343
 
 
78344
 
    IF ( (_totalValue IS NULL) OR (_totalValue = 0) ) THEN
78345
 
      UPDATE itemsite
78346
 
      SET itemsite_abcclass='A'
78347
 
      WHERE (itemsite_abcclass='T');
78348
 
    ELSE
78349
 
 
78350
 
      _cumulativeValue := 0;
78351
 
 
78352
 
      FOR _itemsite IN SELECT itemsite_id, item_number,
78353
 
                              SUM(ABS(invhist_qoh_before - invhist_qoh_after) * invhist_unitcost) AS value
78354
 
                       FROM invhist, itemsite, item
78355
 
                       WHERE ( (invhist_itemsite_id=itemsite_id)
78356
 
                        AND (itemsite_item_id=item_id)
78357
 
                        AND (invhist_analyze)
78358
 
                        AND (invhist_transtype ~ '^[IR]')
78359
 
                        AND ((item_classcode_id=pClasscodeid) OR (pClasscodeid=-1))
78360
 
                        AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate)
78361
 
                        AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) )
78362
 
                       GROUP BY itemsite_id, item_number
78363
 
                       ORDER BY value DESC LOOP
78364
 
 
78365
 
        IF (_itemsite.value IS NOT NULL) THEN
78366
 
          _cumulativeValue := _cumulativeValue + _itemsite.value;
78367
 
        END IF;
78368
 
 
78369
 
        IF ((_cumulativeValue / _totalValue) <= pACutoff) THEN
78370
 
          UPDATE itemsite
78371
 
          SET itemsite_abcclass='A'
78372
 
          WHERE (itemsite_id=_itemsite.itemsite_id);
78373
 
        ELSE
78374
 
          IF ((_cumulativeValue / _totalValue) <= pBCutoff) THEN
78375
 
            UPDATE itemsite
78376
 
            SET itemsite_abcclass='B'
78377
 
            WHERE (itemsite_id=_itemsite.itemsite_id);
78378
 
          ELSE
78379
 
            UPDATE itemsite
78380
 
            SET itemsite_abcclass='C'
78381
 
            WHERE (itemsite_id=_itemsite.itemsite_id);
78382
 
          END IF;
78383
 
        END IF;
78384
 
 
78385
 
      END LOOP;
78386
 
 
78387
 
      UPDATE itemsite
78388
 
      SET itemsite_abcclass='C'
78389
 
      WHERE (itemsite_abcclass='T');
78390
 
    END IF;
78391
 
 
78392
 
  END IF;
78393
 
 
78394
 
  RETURN _updateCount;
78395
 
 
78396
 
END;
78397
 
$_$;
78398
 
 
78399
 
 
78400
 
ALTER FUNCTION public.updateabcclass(integer, integer, numeric, numeric, date, date) OWNER TO admin;
78401
 
 
78402
 
--
78403
 
--
78404
 
 
78405
 
CREATE FUNCTION updatecharassignment(text, integer, integer, text) RETURNS integer
78406
 
    LANGUAGE plpgsql
78407
 
    AS $_$
78408
 
DECLARE
78409
 
  pTargetType ALIAS FOR $1;
78410
 
  pTargetId ALIAS FOR $2;
78411
 
  pCharId ALIAS FOR $3;
78412
 
  pValue ALIAS FOR $4;
78413
 
  _charassid INTEGER;
78414
 
 
78415
 
BEGIN
78416
 
 
78417
 
  SELECT updateCharAssignment(pTargetType, pTargetId, pCharId, pValue, 0) INTO _charassid;
78418
 
 
78419
 
  RETURN _charassid;
78420
 
 
78421
 
END;
78422
 
$_$;
78423
 
 
78424
 
 
78425
 
ALTER FUNCTION public.updatecharassignment(text, integer, integer, text) OWNER TO admin;
78426
 
 
78427
 
--
78428
 
--
78429
 
 
78430
 
CREATE FUNCTION updatecharassignment(text, integer, integer, text, numeric) RETURNS integer
78431
 
    LANGUAGE plpgsql
78432
 
    AS $_$
78433
 
DECLARE
78434
 
  pTargetType ALIAS FOR $1;
78435
 
  pTargetId ALIAS FOR $2;
78436
 
  pCharId ALIAS FOR $3;
78437
 
  pValue ALIAS FOR $4;
78438
 
  pPrice ALIAS FOR $5;
78439
 
  _charassid INTEGER;
78440
 
  _charassprice NUMERIC;
78441
 
  _explodedJob BOOLEAN = FALSE;
78442
 
  _value TEXT;
78443
 
 
78444
 
BEGIN
78445
 
 
78446
 
  -- Check for Valid Assignment
78447
 
  IF (pTargetType='SI') THEN
78448
 
    SELECT (item_config AND wo_status != 'O') INTO _explodedJob
78449
 
        FROM coitem,itemsite,item,wo
78450
 
        WHERE ((coitem_id=pTargetId)
78451
 
        AND (itemsite_id=coitem_itemsite_id)
78452
 
        AND (item_id=itemsite_item_id)
78453
 
        AND (wo_ordtype='S')
78454
 
        AND (wo_ordid=coitem_id));
78455
 
  END IF;
78456
 
  
78457
 
  SELECT charass_id,charass_value INTO _charassid, _value
78458
 
    FROM charass
78459
 
   WHERE ((charass_target_type=pTargetType)
78460
 
     AND  (charass_target_id=pTargetId)
78461
 
     AND  (charass_char_id=pCharId) )
78462
 
   LIMIT 1;
78463
 
  IF (FOUND) THEN
78464
 
    IF (_explodedJob AND pValue != _value) THEN
78465
 
      RAISE EXCEPTION  'Characteristic may not be updated for Configured Item with exploded Work Order.';
78466
 
    ELSIF(COALESCE(pValue, '')!='') THEN
78467
 
        UPDATE charass
78468
 
        SET charass_value = pValue,
78469
 
            charass_price = pPrice
78470
 
        WHERE (charass_id=_charassid);
78471
 
    ELSE
78472
 
      DELETE
78473
 
        FROM charass
78474
 
       WHERE (charass_id=_charassid);
78475
 
      _charassid := 0;
78476
 
    END IF;
78477
 
  ELSE
78478
 
    IF ( (_explodedJob) AND (COALESCE(pValue, '')!='') ) THEN
78479
 
      RAISE EXCEPTION  'Characteristics may not be updated for Configured Item with exploded Work Order.';
78480
 
    ELSIF(COALESCE(pValue, '')!='') THEN
78481
 
      SELECT nextval('charass_charass_id_seq') INTO _charassid;
78482
 
      INSERT INTO charass
78483
 
            (charass_id, charass_target_type, charass_target_id,
78484
 
             charass_char_id, charass_value, charass_price)
78485
 
      VALUES(_charassid, pTargetType, pTargetId,
78486
 
             pCharId, pValue, pPrice);
78487
 
    ELSE
78488
 
      _charassid := 0;
78489
 
    END IF;
78490
 
  END IF;
78491
 
 
78492
 
  RETURN _charassid;
78493
 
 
78494
 
END;
78495
 
$_$;
78496
 
 
78497
 
 
78498
 
ALTER FUNCTION public.updatecharassignment(text, integer, integer, text, numeric) OWNER TO admin;
78499
 
 
78500
 
--
78501
 
--
78502
 
 
78503
 
CREATE FUNCTION updatecost(integer, numeric) RETURNS integer
78504
 
    LANGUAGE plpgsql
78505
 
    AS $_$
78506
 
DECLARE
78507
 
  pItemcostid ALIAS FOR $1;
78508
 
  pCost ALIAS FOR $2;
78509
 
 
78510
 
BEGIN
78511
 
  RETURN updateCost(pItemcostid, pCost, baseCurrId());
78512
 
END;
78513
 
$_$;
78514
 
 
78515
 
 
78516
 
ALTER FUNCTION public.updatecost(integer, numeric) OWNER TO admin;
78517
 
 
78518
 
--
78519
 
--
78520
 
 
78521
 
CREATE FUNCTION updatecost(integer, numeric, integer) RETURNS integer
78522
 
    LANGUAGE plpgsql
78523
 
    AS $_$
78524
 
DECLARE
78525
 
    pItemcostid ALIAS FOR $1;
78526
 
    pCost ALIAS FOR $2;
78527
 
    pCurrId ALIAS FOR $3;
78528
 
 
78529
 
BEGIN
78530
 
  IF ( ( SELECT (itemcost_stdcost > 0)
78531
 
           FROM itemcost
78532
 
          WHERE (itemcost_id=pItemcostid) )  OR
78533
 
        (pCost > 0) ) THEN
78534
 
    UPDATE itemcost
78535
 
       SET itemcost_actcost=pCost, itemcost_updated=CURRENT_DATE,
78536
 
           itemcost_curr_id=pCurrId
78537
 
     WHERE (itemcost_id=pItemcostid);
78538
 
 
78539
 
    RETURN pItemcostid;
78540
 
 
78541
 
  ELSE
78542
 
    DELETE FROM itemcost
78543
 
     WHERE (itemcost_id=pItemcostid);
78544
 
 
78545
 
    RETURN -1;
78546
 
  END IF;
78547
 
 
78548
 
END;
78549
 
$_$;
78550
 
 
78551
 
 
78552
 
ALTER FUNCTION public.updatecost(integer, numeric, integer) OWNER TO admin;
78553
 
 
78554
 
--
78555
 
--
78556
 
 
78557
 
CREATE FUNCTION updatecost(integer, text, boolean, numeric) RETURNS integer
78558
 
    LANGUAGE plpgsql
78559
 
    AS $_$
78560
 
DECLARE
78561
 
  returnVal INTEGER;
78562
 
 
78563
 
BEGIN
78564
 
  SELECT updateCost($1, $2, $3, $4, baseCurrId()) INTO returnVal;
78565
 
  RETURN returnVal;
78566
 
END;
78567
 
$_$;
78568
 
 
78569
 
 
78570
 
ALTER FUNCTION public.updatecost(integer, text, boolean, numeric) OWNER TO admin;
78571
 
 
78572
 
--
78573
 
--
78574
 
 
78575
 
CREATE FUNCTION updatecost(integer, integer, boolean, numeric) RETURNS integer
78576
 
    LANGUAGE plpgsql
78577
 
    AS $_$
78578
 
DECLARE
78579
 
  returnVal INTEGER;
78580
 
 
78581
 
BEGIN
78582
 
  SELECT updateCost($1, $2, $3, $4, baseCurrId()) INTO returnVal;
78583
 
  RETURN returnVal;
78584
 
END;
78585
 
$_$;
78586
 
 
78587
 
 
78588
 
ALTER FUNCTION public.updatecost(integer, integer, boolean, numeric) OWNER TO admin;
78589
 
 
78590
 
--
78591
 
--
78592
 
 
78593
 
CREATE FUNCTION updatecost(integer, text, boolean, numeric, integer) RETURNS integer
78594
 
    LANGUAGE plpgsql
78595
 
    AS $_$
78596
 
DECLARE
78597
 
  pItemid ALIAS FOR $1;
78598
 
  pCosttype ALIAS FOR $2;
78599
 
  pLevel ALIAS FOR $3;
78600
 
  pCost ALIAS FOR $4;
78601
 
  pCurrid ALIAS FOR $5;
78602
 
  _cost NUMERIC;
78603
 
  _currId INTEGER;
78604
 
  _p RECORD;
78605
 
  _itemcostid INTEGER;
78606
 
 
78607
 
BEGIN
78608
 
 
78609
 
  IF (pCost IS NULL) THEN
78610
 
    _cost = 0;
78611
 
  ELSE
78612
 
    _cost = pCost;
78613
 
  END IF;
78614
 
 
78615
 
  IF (pCurrId IS NULL) THEN
78616
 
    _currId := baseCurrID();
78617
 
  ELSE
78618
 
    _currId := pCurrId;
78619
 
  END IF;
78620
 
 
78621
 
  SELECT itemcost_id, itemcost_stdcost INTO _p
78622
 
  FROM itemcost, costelem
78623
 
  WHERE ( (itemcost_costelem_id=costelem_id)
78624
 
   AND (itemcost_item_id=pItemid)
78625
 
   AND (itemcost_lowlevel=pLevel)
78626
 
   AND (costelem_type=pCosttype) );
78627
 
 
78628
 
  IF (NOT FOUND) THEN
78629
 
    IF (_cost > 0) THEN
78630
 
      SELECT NEXTVAL('itemcost_itemcost_id_seq') INTO _itemcostid;
78631
 
      INSERT INTO itemcost
78632
 
      ( itemcost_id, itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel,
78633
 
        itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated,
78634
 
        itemcost_curr_id )
78635
 
      SELECT _itemcostid, pItemid, costelem_id, pLevel,
78636
 
             0, startOfTime(), _cost, CURRENT_DATE,
78637
 
             _currId
78638
 
      FROM costelem
78639
 
      WHERE (costelem_type=pCosttype);
78640
 
 
78641
 
      RETURN _itemcostid;
78642
 
 
78643
 
    ELSE
78644
 
      RETURN -1;
78645
 
    END IF;
78646
 
 
78647
 
  ELSIF ( (_p.itemcost_stdcost > 0) OR (_cost > 0) ) THEN
78648
 
    UPDATE itemcost
78649
 
    SET itemcost_actcost=_cost,
78650
 
        itemcost_curr_id = _currId,
78651
 
        itemcost_updated=CURRENT_DATE
78652
 
    WHERE (itemcost_id=_p.itemcost_id);
78653
 
 
78654
 
    RETURN _p.itemcost_id;
78655
 
 
78656
 
  ELSE
78657
 
    DELETE FROM itemcost
78658
 
    WHERE (itemcost_id=_p.itemcost_id);
78659
 
 
78660
 
    RETURN -1;
78661
 
  END IF;
78662
 
 
78663
 
END;
78664
 
$_$;
78665
 
 
78666
 
 
78667
 
ALTER FUNCTION public.updatecost(integer, text, boolean, numeric, integer) OWNER TO admin;
78668
 
 
78669
 
--
78670
 
--
78671
 
 
78672
 
CREATE FUNCTION updatecost(integer, integer, boolean, numeric, integer) RETURNS integer
78673
 
    LANGUAGE plpgsql
78674
 
    AS $_$
78675
 
DECLARE
78676
 
  pItemid ALIAS FOR $1;
78677
 
  pCostelemid ALIAS FOR $2;
78678
 
  pLevel ALIAS FOR $3;
78679
 
  pCost ALIAS FOR $4;
78680
 
  pCurrid ALIAS FOR $5;
78681
 
  _cost NUMERIC;
78682
 
  _currId INTEGER;
78683
 
  _p RECORD;
78684
 
  _itemcostid INTEGER;
78685
 
 
78686
 
BEGIN
78687
 
 
78688
 
  IF (pCost IS NULL) THEN
78689
 
    _cost = 0;
78690
 
  ELSE
78691
 
    _cost = pCost;
78692
 
  END IF;
78693
 
 
78694
 
  IF (pCurrId IS NULL) THEN
78695
 
    _currId := baseCurrID();
78696
 
  ELSE
78697
 
    _currId := pCurrId;
78698
 
  END IF;
78699
 
 
78700
 
  SELECT itemcost_id, itemcost_stdcost INTO _p
78701
 
  FROM itemcost
78702
 
  WHERE ((itemcost_costelem_id=pCostelemid)
78703
 
   AND (itemcost_item_id=pItemid)
78704
 
   AND (itemcost_lowlevel=pLevel) );
78705
 
 
78706
 
  IF (NOT FOUND) THEN
78707
 
    IF (_cost > 0) THEN
78708
 
      SELECT NEXTVAL('itemcost_itemcost_id_seq') INTO _itemcostid;
78709
 
      INSERT INTO itemcost
78710
 
      ( itemcost_id, itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel,
78711
 
        itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated,
78712
 
        itemcost_curr_id )
78713
 
      SELECT _itemcostid, pItemid, costelem_id, pLevel,
78714
 
             0, startOfTime(), _cost, CURRENT_DATE,
78715
 
             _currId
78716
 
      FROM costelem
78717
 
      WHERE (costelem_id=pCostelemid);
78718
 
 
78719
 
      RETURN _itemcostid;
78720
 
 
78721
 
    ELSE
78722
 
      RETURN -1;
78723
 
    END IF;
78724
 
 
78725
 
  ELSIF ( (_p.itemcost_stdcost > 0) OR (_cost > 0) ) THEN
78726
 
    UPDATE itemcost
78727
 
    SET itemcost_actcost=_cost,
78728
 
        itemcost_curr_id = _currId,
78729
 
        itemcost_updated=CURRENT_DATE
78730
 
    WHERE (itemcost_id=_p.itemcost_id);
78731
 
 
78732
 
    RETURN _p.itemcost_id;
78733
 
 
78734
 
  ELSE
78735
 
    DELETE FROM itemcost
78736
 
    WHERE (itemcost_id=_p.itemcost_id);
78737
 
 
78738
 
    RETURN -1;
78739
 
  END IF;
78740
 
 
78741
 
END;
78742
 
$_$;
78743
 
 
78744
 
 
78745
 
ALTER FUNCTION public.updatecost(integer, integer, boolean, numeric, integer) OWNER TO admin;
78746
 
 
78747
 
--
78748
 
--
78749
 
 
78750
 
CREATE FUNCTION updatecreditmemoline(api.creditmemoline, api.creditmemoline) RETURNS boolean
78751
 
    LANGUAGE plpgsql
78752
 
    AS $_$
78753
 
DECLARE
78754
 
  pNew ALIAS FOR $1;
78755
 
  pOld ALIAS FOR $2;
78756
 
  _check INTEGER;
78757
 
  _r RECORD;
78758
 
 
78759
 
BEGIN
78760
 
  SELECT cmitem_id INTO _check
78761
 
  FROM cmitem
78762
 
  WHERE ( (cmitem_cmhead_id=getCmheadId(pOld.memo_number, FALSE)) AND (cmitem_linenumber=pOld.line_number) );
78763
 
  IF (NOT FOUND) THEN
78764
 
    RAISE EXCEPTION 'Credit Memo # % Line Number # not found', pOld.memo_number, pOld.line_number;
78765
 
  END IF;
78766
 
 
78767
 
  UPDATE cmitem
78768
 
    SET cmitem_itemsite_id=COALESCE(itemsite_id, -1),
78769
 
        cmitem_qtycredit=pNew.qty_to_credit,
78770
 
        cmitem_qtyreturned=pNew.qty_returned,
78771
 
        cmitem_unitprice=pNew.net_unit_price,
78772
 
        cmitem_comments=pNew.notes,
78773
 
        cmitem_rsncode_id=getRsnId(pNew.reason_code),
78774
 
        cmitem_taxtype_id=taxtype_id,
78775
 
        cmitem_qty_uom_id=COALESCE(getUomId(pNew.qty_uom), item_inv_uom_id),
78776
 
        cmitem_qty_invuomratio=CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE(getUomId(pNew.qty_uom),item_inv_uom_id),item_inv_uom_id)
78777
 
                                    ELSE 1
78778
 
                               END,
78779
 
        cmitem_price_uom_id=COALESCE(getUomId(pNew.price_uom),item_price_uom_id),
78780
 
        cmitem_price_invuomratio=CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE(getUomId(pNew.price_uom),item_price_uom_id),item_price_uom_id)
78781
 
                                      ELSE 1
78782
 
                                 END
78783
 
  FROM cmhead LEFT OUTER JOIN item ON (item_id=getItemId(pNew.item_number))
78784
 
              LEFT OUTER JOIN itemsite ON (itemsite_item_id=item_id AND
78785
 
                                           itemsite_warehous_id=getWarehousId(pNew.recv_site, 'ALL'))
78786
 
              LEFT OUTER JOIN taxtype ON (taxtype_id=CASE WHEN pNew.tax_type IS NULL THEN getItemTaxType(item_id,cmhead_taxzone_id)
78787
 
                                                          WHEN pNew.tax_type = 'None' THEN NULL
78788
 
                                                          ELSE getTaxTypeId(pNew.tax_type)
78789
 
                                                     END)
78790
 
  WHERE cmitem_cmhead_id=cmhead_id
78791
 
    AND cmhead_number=pOld.memo_number
78792
 
    AND cmitem_linenumber=pOld.line_number
78793
 
    AND cmhead_posted=FALSE;
78794
 
 
78795
 
  RETURN TRUE;
78796
 
END;
78797
 
$_$;
78798
 
 
78799
 
 
78800
 
ALTER FUNCTION public.updatecreditmemoline(api.creditmemoline, api.creditmemoline) OWNER TO admin;
78801
 
 
78802
 
--
78803
 
--
78804
 
 
78805
 
CREATE FUNCTION updatecustomprivs() RETURNS boolean
78806
 
    LANGUAGE plpgsql
78807
 
    AS $$
78808
 
DECLARE
78809
 
  _r RECORD;
78810
 
BEGIN
78811
 
 
78812
 
  FOR _r IN SELECT priv_id
78813
 
              FROM priv
78814
 
             WHERE ((priv_name IN (SELECT priv_name
78815
 
                                     FROM priv
78816
 
                                    WHERE (priv_module='Custom')
78817
 
                                   EXCEPT
78818
 
                                   SELECT ('Custom'||cmd_privname)
78819
 
                                     FROM cmd))
78820
 
               AND  (priv_module='Custom')) LOOP
78821
 
    -- TODO: something here
78822
 
    DELETE FROM grppriv WHERE grppriv_priv_id=_r.priv_id;
78823
 
    DELETE FROM usrpriv WHERE usrpriv_priv_id=_r.priv_id;
78824
 
    DELETE FROM priv WHERE priv_id=_r.priv_id;
78825
 
  END LOOP;
78826
 
 
78827
 
  FOR _r IN SELECT ('Custom'||cmd_privname) AS privname
78828
 
              FROM cmd
78829
 
            EXCEPT
78830
 
            SELECT priv_name
78831
 
              FROM priv
78832
 
             WHERE (priv_module='Custom') LOOP
78833
 
    -- TODO: something here
78834
 
    INSERT INTO priv (priv_module, priv_name, priv_descrip)
78835
 
              VALUES ('Custom', _r.privname, 'Auto Generated Custom Priv.');
78836
 
  END LOOP;
78837
 
 
78838
 
  RETURN TRUE;
78839
 
END;
78840
 
$$;
78841
 
 
78842
 
 
78843
 
ALTER FUNCTION public.updatecustomprivs() OWNER TO admin;
78844
 
 
78845
 
--
78846
 
--
78847
 
 
78848
 
CREATE FUNCTION updateinvoicelineitem(api.invoiceline, api.invoiceline) RETURNS boolean
78849
 
    LANGUAGE plpgsql
78850
 
    AS $_$
78851
 
DECLARE
78852
 
        pNew ALIAS FOR $1;
78853
 
        pOld ALIAS FOR $2;
78854
 
        _r RECORD;
78855
 
BEGIN
78856
 
        UPDATE invcitem SET
78857
 
                invcitem_linenumber=pNew.line_number,
78858
 
                invcitem_item_id=COALESCE(item_id, -1),
78859
 
                invcitem_custpn=pNew.customer_part_number,
78860
 
                invcitem_number=(CASE WHEN item_id IS NULL THEN pNew.misc_item_number ELSE NULL END),
78861
 
                invcitem_warehous_id=(CASE WHEN invcitem_warehous_id IS NULL THEN COALESCE(getwarehousid(pNew.site,'ALL'),-1) ELSE NULL END),
78862
 
                invcitem_descrip=(CASE WHEN item_id IS NULL THEN pNew.misc_item_description ELSE NULL END),
78863
 
                invcitem_ordered=pNew.qty_ordered,
78864
 
                invcitem_billed=COALESCE(pNew.qty_billed, 0),
78865
 
                invcitem_updateinv=COALESCE(pNew.update_inventory,FALSE),
78866
 
                invcitem_price=COALESCE(pNew.net_unit_price,itemPrice(item_id,invchead_cust_id,
78867
 
                        invchead_shipto_id,pNew.qty_ordered,invchead_curr_id,invchead_orderdate)),
78868
 
                invcitem_notes=COALESCE(pNew.notes,''),
78869
 
                invcitem_salescat_id=CASE
78870
 
                        WHEN item_id IS NULL THEN
78871
 
                                (SELECT salescat_id FROM salescat WHERE salescat_name = pNew.sales_category)
78872
 
                        ELSE NULL
78873
 
                END,
78874
 
                invcitem_taxtype_id=taxtype_id,
78875
 
                invcitem_qty_uom_id=CASE
78876
 
                        WHEN item_id IS NOT NULL THEN
78877
 
                                COALESCE((SELECT uom_id FROM uom WHERE (uom_name=pNew.qty_uom)), item_price_uom_id)
78878
 
                        ELSE NULL
78879
 
                END,
78880
 
                invcitem_qty_invuomratio=CASE
78881
 
                        WHEN item_id IS NOT NULL THEN
78882
 
                                itemuomtouomratio(item_id,
78883
 
                                        COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.qty_uom),item_price_uom_id),
78884
 
                                        item_price_uom_id
78885
 
                                )
78886
 
                        ELSE 1
78887
 
                END,
78888
 
                invcitem_price_uom_id=CASE
78889
 
                        WHEN item_id IS NOT NULL THEN
78890
 
                                COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.price_uom),item_price_uom_id)
78891
 
                        ELSE NULL
78892
 
                END,
78893
 
                invcitem_price_invuomratio=CASE
78894
 
                        WHEN item_id IS NOT NULL THEN
78895
 
                                itemuomtouomratio(item_id,
78896
 
                                        COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.price_uom),item_price_uom_id),
78897
 
                                        item_price_uom_id
78898
 
                                )
78899
 
                        ELSE 1
78900
 
                END,
78901
 
                invcitem_rev_accnt_id=getGlAccntId(alternate_rev_account)
78902
 
        FROM invchead
78903
 
                LEFT OUTER JOIN item ON (item_id=getItemId(pNew.item_number))
78904
 
                LEFT OUTER JOIN taxtype ON (taxtype_id=CASE
78905
 
                        WHEN pNew.tax_type IS NULL THEN getItemTaxType(item_id,invchead_taxzone_id)
78906
 
                        WHEN pNew.tax_type = 'None' THEN NULL
78907
 
                        ELSE (SELECT taxtype_id FROM taxtype WHERE taxtype_name=pNew.tax_type)
78908
 
                END)
78909
 
        WHERE invcitem_invchead_id=invchead_id
78910
 
                AND invcitem_linenumber=pOld.line_number
78911
 
                AND invchead_invcnumber=pOld.invoice_number
78912
 
                AND invchead_posted=FALSE;
78913
 
        RETURN TRUE;
78914
 
END;
78915
 
$_$;
78916
 
 
78917
 
 
78918
 
ALTER FUNCTION public.updateinvoicelineitem(api.invoiceline, api.invoiceline) OWNER TO admin;
78919
 
 
78920
 
--
78921
 
--
78922
 
 
78923
 
CREATE FUNCTION updateitemcost(integer, integer, integer, numeric, boolean) RETURNS integer
78924
 
    LANGUAGE plpgsql
78925
 
    AS $_$
78926
 
DECLARE
78927
 
pItemId ALIAS FOR $1;
78928
 
pCostElemId ALIAS FOR $2;
78929
 
pCurrId ALIAS FOR $3;
78930
 
pCost ALIAS FOR $4;
78931
 
pPostToStandard ALIAS FOR $5;
78932
 
_itemcost_id INTEGER;
78933
 
_update_return INTEGER;
78934
 
_postcost_return BOOLEAN;
78935
 
 
78936
 
--This function is used with the api.itemcost View for updating
78937
 
--the itemcost table
78938
 
 
78939
 
BEGIN
78940
 
  SELECT itemcost_id INTO _itemcost_id
78941
 
  FROM itemcost
78942
 
  WHERE ( (itemcost_item_id = pItemId) AND (itemcost_costelem_id = pCostElemId) );
78943
 
 
78944
 
  IF (NOT FOUND) THEN
78945
 
    RAISE EXCEPTION 'itemcost % not found for. ', pItemId || ' & ' || pCostElemId;
78946
 
  END IF;
78947
 
 
78948
 
  IF (pCost IS NULL OR pCost < 0) THEN
78949
 
    RAISE EXCEPTION 'itemcost Actual Cost Invalid ', pCost;
78950
 
  END IF;
78951
 
  
78952
 
  IF (pCost > 0) THEN
78953
 
    UPDATE itemcost
78954
 
    SET itemcost_actcost=pCost,
78955
 
        itemcost_curr_id = pCurrId
78956
 
    WHERE (itemcost_id=_itemcost_id);
78957
 
 
78958
 
    --Only Post Cost to standard if the parameter is set to true
78959
 
    IF (pPostToStandard) THEN
78960
 
      IF (NOT checkPrivilege('PostStandardCosts')) THEN
78961
 
        RAISE EXCEPTION 'You do not have privileges to poststandard itemcosts. Set api.itemcost post_to_standard to false';
78962
 
      END IF;
78963
 
      SELECT postcost(_itemcost_id) INTO _postcost_return;       
78964
 
      IF (NOT _postcost_return) THEN
78965
 
        RETURN -2;
78966
 
      END IF;
78967
 
    END IF;
78968
 
  ELSE 
78969
 
    RETURN -1;
78970
 
  END IF;
78971
 
 
78972
 
  RETURN _itemcost_id;
78973
 
  
78974
 
END;
78975
 
$_$;
78976
 
 
78977
 
 
78978
 
ALTER FUNCTION public.updateitemcost(integer, integer, integer, numeric, boolean) OWNER TO admin;
78979
 
 
78980
 
--
78981
 
--
78982
 
 
78983
 
CREATE FUNCTION updateitemsiteleadtime(integer, integer) RETURNS integer
78984
 
    LANGUAGE plpgsql
78985
 
    AS $_$
78986
 
DECLARE
78987
 
  pItemsiteid ALIAS FOR $1;
78988
 
  pPad ALIAS FOR $2;
78989
 
  _p RECORD;
78990
 
  _materialLeadTime INTEGER;
78991
 
  _productionLeadTime INTEGER;
78992
 
  _leadTime INTEGER;
78993
 
 
78994
 
BEGIN
78995
 
 
78996
 
  SELECT item_type, itemsite_wosupply INTO _p
78997
 
  FROM item, itemsite
78998
 
  WHERE ( (itemsite_item_id=item_id)
78999
 
   AND (itemsite_id=pitemsiteid) );
79000
 
  
79001
 
  IF ( (_p.item_type IN ('M', 'P')) ) THEN
79002
 
 
79003
 
    IF (_p.item_type = 'M') THEN
79004
 
      SELECT COALESCE(MAX(component.itemsite_leadtime), 0) INTO _materialLeadTime
79005
 
      FROM bomitem, itemsite AS parent, itemsite AS component
79006
 
      WHERE ( (bomitem_parent_item_id=parent.itemsite_item_id)
79007
 
       AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id))
79008
 
       AND (bomitem_item_id=component.itemsite_item_id)
79009
 
       AND (parent.itemsite_warehous_id=component.itemsite_warehous_id)
79010
 
       AND (parent.itemsite_id=pItemsiteid) );
79011
 
 
79012
 
      SELECT COALESCE(MAX(booitem_execday), 0) INTO _productionLeadTime
79013
 
      FROM xtmfg.booitem, itemsite
79014
 
      WHERE ( (booitem_item_id=itemsite_item_id)
79015
 
       AND (booitem_rev_id=getActiveRevId('BOO',booitem_item_id))
79016
 
       AND (itemsite_id=pItemsiteid) );
79017
 
 
79018
 
      _leadTime := (_materialLeadTime + _productionLeadTime + pPad);
79019
 
 
79020
 
    ELSIF (_p.item_type IN ('P')) THEN
79021
 
      SELECT COALESCE(MAX(itemsrc_leadtime), 0) INTO _leadTime
79022
 
      FROM itemsrc, itemsite
79023
 
      WHERE ( (itemsite_item_id=itemsrc_item_id)
79024
 
       AND (itemsite_id=pItemsiteid) );
79025
 
 
79026
 
      _leadTime := (_leadTime + pPad);
79027
 
    END IF;
79028
 
 
79029
 
  ELSE
79030
 
    _leadTime = pPad;
79031
 
  END IF;
79032
 
 
79033
 
  UPDATE itemsite
79034
 
  SET itemsite_leadtime=_leadTime
79035
 
  WHERE (itemsite_id=pItemsiteid);
79036
 
 
79037
 
  RETURN _leadTime;
79038
 
 
79039
 
END;
79040
 
$_$;
79041
 
 
79042
 
 
79043
 
ALTER FUNCTION public.updateitemsiteleadtime(integer, integer) OWNER TO admin;
79044
 
 
79045
 
--
79046
 
--
79047
 
 
79048
 
CREATE FUNCTION updatelistprice(integer, numeric) RETURNS numeric
79049
 
    LANGUAGE plpgsql
79050
 
    AS $_$
79051
 
DECLARE
79052
 
  pItemid ALIAS FOR $1;
79053
 
  pUpdateBy ALIAS FOR $2;
79054
 
 
79055
 
BEGIN
79056
 
 
79057
 
  UPDATE item
79058
 
  SET item_listprice = (item_listprice * pUpdateBy)
79059
 
  WHERE (item_id=pItemid);
79060
 
 
79061
 
  RETURN 1;
79062
 
 
79063
 
END;
79064
 
$_$;
79065
 
 
79066
 
 
79067
 
ALTER FUNCTION public.updatelistprice(integer, numeric) OWNER TO admin;
79068
 
 
79069
 
--
79070
 
--
79071
 
 
79072
 
CREATE FUNCTION updatelowerusercosts(integer) RETURNS integer
79073
 
    LANGUAGE plpgsql
79074
 
    AS $_$
79075
 
DECLARE
79076
 
  pItemid ALIAS FOR $1;
79077
 
 
79078
 
BEGIN
79079
 
    RETURN updateLowerUserCosts(pItemid, TRUE);
79080
 
END;
79081
 
$_$;
79082
 
 
79083
 
 
79084
 
ALTER FUNCTION public.updatelowerusercosts(integer) OWNER TO admin;
79085
 
 
79086
 
--
79087
 
--
79088
 
 
79089
 
CREATE FUNCTION updatelowerusercosts(integer, boolean) RETURNS integer
79090
 
    LANGUAGE plpgsql
79091
 
    AS $_$
79092
 
DECLARE
79093
 
  pItemid       ALIAS FOR $1;
79094
 
  pUpdateActual ALIAS FOR $2;
79095
 
  _bomitem RECORD;
79096
 
  _type CHAR(1);
79097
 
 
79098
 
BEGIN
79099
 
 
79100
 
  SELECT item_type INTO _type
79101
 
  FROM item
79102
 
  WHERE (item_id=pItemid);
79103
 
 
79104
 
  IF (_type IN ('M', 'F', 'B', 'T')) THEN
79105
 
    FOR _bomitem IN SELECT DISTINCT costelem_type
79106
 
                    FROM ( SELECT COALESCE(bc.costelem_type, ic.costelem_type) AS costelem_type
79107
 
                           FROM bomitem(pItemid)
79108
 
                             JOIN item ON (item_id=bomitem_item_id AND item_type <> 'T')
79109
 
                             JOIN itemcost ON (itemcost_item_id=bomitem_item_id)
79110
 
                             JOIN costelem ic ON (ic.costelem_id=itemcost_costelem_id AND NOT ic.costelem_sys)
79111
 
                             LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=bomitem_id)
79112
 
                             LEFT OUTER JOIN costelem bc ON (bc.costelem_id=bomitemcost_costelem_id AND NOT bc.costelem_sys)
79113
 
                           WHERE ( CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1) )
79114
 
 
79115
 
                           UNION SELECT costelem_type
79116
 
                           FROM itemcost, costelem
79117
 
                           WHERE ( (itemcost_costelem_id=costelem_id)
79118
 
                            AND (itemcost_item_id=pItemid) ) ) AS data LOOP
79119
 
 
79120
 
      PERFORM updateSorACost( pItemid, _bomitem.costelem_type,
79121
 
                              TRUE, lowerCost(pItemid, _bomitem.costelem_type, pUpdateActual),
79122
 
                              pUpdateActual);
79123
 
    END LOOP;
79124
 
 
79125
 
  ELSIF (_type = 'C') THEN
79126
 
    FOR _bomitem IN SELECT DISTINCT costelem_type
79127
 
                    FROM ( SELECT costelem_type
79128
 
                           FROM itemcost, costelem,
79129
 
                                xtmfg.bbomitem
79130
 
                           WHERE ( (bbomitem_item_id=pItemid)
79131
 
                            AND ( CURRENT_DATE BETWEEN bbomitem_effective
79132
 
                                               AND (bbomitem_expires - 1) )
79133
 
                            AND (NOT costelem_sys)
79134
 
                            AND (bbomitem_item_id=itemcost_item_id)
79135
 
                            AND (itemcost_costelem_id=costelem_id) ) 
79136
 
 
79137
 
                           UNION SELECT costelem_type
79138
 
                           FROM itemcost, costelem,
79139
 
                                xtmfg.bbomitem AS t,
79140
 
                                xtmfg.bbomitem AS s
79141
 
                           WHERE ( (t.bbomitem_item_id=pItemid)
79142
 
                            AND ( CURRENT_DATE BETWEEN s.bbomitem_effective
79143
 
                                               AND (s.bbomitem_expires - 1) )
79144
 
                            AND ( CURRENT_DATE BETWEEN t.bbomitem_effective
79145
 
                                               AND (t.bbomitem_expires - 1) )
79146
 
                            AND (s.bbomitem_parent_item_id=t.bbomitem_parent_item_id)
79147
 
                            AND (NOT costelem_sys)
79148
 
                            AND (s.bbomitem_item_id=itemcost_item_id)
79149
 
                            AND (itemcost_costelem_id=costelem_id) ) ) AS data LOOP
79150
 
 
79151
 
      PERFORM updateSorACost( pItemid, _bomitem.costelem_type,
79152
 
                              TRUE, lowerCost(pItemid, _bomitem.costelem_type, pUpdateActual),
79153
 
                              pUpdateActual);
79154
 
    END LOOP;
79155
 
  END IF;
79156
 
 
79157
 
  RETURN 1;
79158
 
 
79159
 
END;
79160
 
$_$;
79161
 
 
79162
 
 
79163
 
ALTER FUNCTION public.updatelowerusercosts(integer, boolean) OWNER TO admin;
79164
 
 
79165
 
--
79166
 
--
79167
 
 
79168
 
CREATE FUNCTION updatelowlevel(integer) RETURNS integer
79169
 
    LANGUAGE plpgsql
79170
 
    AS $_$
79171
 
DECLARE
79172
 
 
79173
 
  pLowlevel ALIAS FOR $1;
79174
 
  _num_back INTEGER;
79175
 
 
79176
 
BEGIN
79177
 
 
79178
 
  UPDATE costUpdate SET costUpdate_lowlevel_code = (pLowlevel + 1)
79179
 
    WHERE costUpdate_item_id IN (
79180
 
          SELECT bomitem_item_id
79181
 
          FROM bomitem JOIN costUpdate ON (bomitem_parent_item_id = costUpdate_item_id)
79182
 
          WHERE ((costUpdate_lowlevel_code = pLowlevel)
79183
 
            AND  (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id))
79184
 
            AND  (CURRENT_DATE BETWEEN bomitem_effective
79185
 
                                               AND (bomitem_expires - 1))))
79186
 
      AND costUpdate_lowlevel_code >= pLowlevel;
79187
 
 
79188
 
  GET DIAGNOSTICS _num_back = ROW_COUNT;
79189
 
 
79190
 
  RETURN _num_back;
79191
 
 
79192
 
END;
79193
 
$_$;
79194
 
 
79195
 
 
79196
 
ALTER FUNCTION public.updatelowlevel(integer) OWNER TO admin;
79197
 
 
79198
 
--
79199
 
--
79200
 
 
79201
 
CREATE FUNCTION updateoutlevel(integer, integer, integer[]) RETURNS boolean
79202
 
    LANGUAGE plpgsql
79203
 
    AS $_$
79204
 
DECLARE
79205
 
  pItemsiteid ALIAS FOR $1;
79206
 
  pDays ALIAS FOR $2;
79207
 
  pPeriods ALIAS FOR $3;
79208
 
  _cursor INTEGER;
79209
 
  _periodid INTEGER;
79210
 
  _usage NUMERIC;
79211
 
  _totalUsage NUMERIC;
79212
 
  _totalDays INTEGER;
79213
 
  _outLevel NUMERIC;
79214
 
  _averageUsage NUMERIC;
79215
 
 
79216
 
BEGIN
79217
 
 
79218
 
  _cursor := 1;
79219
 
  _totalUsage := 0;
79220
 
  _totalDays := 0;
79221
 
 
79222
 
  _periodid = pPeriods[_cursor];
79223
 
  WHILE (_periodid IS NOT NULL) LOOP
79224
 
    SELECT COALESCE(SUM(invhist_invqty), 0) INTO _usage
79225
 
    FROM invhist
79226
 
    WHERE ( (invhist_itemsite_id=pItemsiteid)
79227
 
     AND ( invhist_transdate::DATE BETWEEN findPeriodStart(_periodid)
79228
 
                                   AND findPeriodEnd(_periodid) )
79229
 
     AND (invhist_transtype IN ('SH', 'IM')) );
79230
 
 
79231
 
    _totalUsage := (_totalUsage + _usage);
79232
 
 
79233
 
    _totalDays := ( _totalDays + ( findPeriodEnd(_periodid) -
79234
 
                                   findPeriodStart(_periodid) + 1 ) );
79235
 
 
79236
 
    _cursor := (_cursor + 1);
79237
 
    _periodid = pPeriods[_cursor];
79238
 
  END LOOP;
79239
 
 
79240
 
  IF (_totalDays > 0) THEN
79241
 
    _outLevel := round(_totalUsage / _totalDays * pDays);
79242
 
 
79243
 
    IF (_outLevel > 0) THEN
79244
 
      UPDATE itemsite
79245
 
      SET itemsite_ordertoqty = _outLevel
79246
 
      WHERE (itemsite_id=pItemsiteid);
79247
 
    ELSE
79248
 
      UPDATE itemsite
79249
 
      SET itemsite_ordertoqty = 0
79250
 
      WHERE (itemsite_id=pItemsiteid);
79251
 
    END IF;
79252
 
 
79253
 
    RETURN TRUE;
79254
 
  ELSE
79255
 
    RETURN FALSE;
79256
 
  END IF;
79257
 
 
79258
 
END;
79259
 
$_$;
79260
 
 
79261
 
 
79262
 
ALTER FUNCTION public.updateoutlevel(integer, integer, integer[]) OWNER TO admin;
79263
 
 
79264
 
--
79265
 
--
79266
 
 
79267
 
CREATE FUNCTION updateprice(integer, numeric) RETURNS numeric
79268
 
    LANGUAGE plpgsql
79269
 
    AS $_$
79270
 
DECLARE
79271
 
  pIpsitemid ALIAS FOR $1;
79272
 
  pUpdateBy ALIAS FOR $2;
79273
 
 
79274
 
BEGIN
79275
 
 
79276
 
  RETURN updatePrice(pIpsitemid, 'P', pUpdateBy);
79277
 
  
79278
 
END;
79279
 
 
79280
 
$_$;
79281
 
 
79282
 
 
79283
 
ALTER FUNCTION public.updateprice(integer, numeric) OWNER TO admin;
79284
 
 
79285
 
--
79286
 
--
79287
 
 
79288
 
CREATE FUNCTION updateprice(integer, character, numeric) RETURNS numeric
79289
 
    LANGUAGE plpgsql
79290
 
    AS $_$
79291
 
DECLARE
79292
 
  pIpsitemid ALIAS FOR $1;
79293
 
  pUpdateType ALIAS FOR $2;
79294
 
  pUpdateBy ALIAS FOR $3;
79295
 
 
79296
 
BEGIN
79297
 
 
79298
 
  IF (pUpdateType IN('V')) THEN
79299
 
    UPDATE ipsitem
79300
 
    SET ipsitem_price = (ipsitem_price + pUpdateBy)
79301
 
    WHERE (ipsitem_id=pIpsitemid);
79302
 
    RETURN 1;
79303
 
  ELSE
79304
 
    UPDATE ipsitem
79305
 
    SET ipsitem_price = (ipsitem_price * pUpdateBy)
79306
 
    WHERE (ipsitem_id=pIpsitemid);
79307
 
    RETURN 1;
79308
 
  END IF;
79309
 
 
79310
 
END;
79311
 
$_$;
79312
 
 
79313
 
 
79314
 
ALTER FUNCTION public.updateprice(integer, character, numeric) OWNER TO admin;
79315
 
 
79316
 
--
79317
 
--
79318
 
 
79319
 
CREATE FUNCTION updatepricesbypricingschedule(pipsheadid integer, pupdatetype character, pupdateby numeric, pupdatecharprices boolean) RETURNS numeric
79320
 
    LANGUAGE plpgsql
79321
 
    AS $$
79322
 
DECLARE
79323
 
  _percentMultiplier NUMERIC;
79324
 
  _currencyDecimals INTEGER;
79325
 
  _itemRows INTEGER :=0;
79326
 
  _charRows INTEGER :=0;
79327
 
 
79328
 
BEGIN
79329
 
 
79330
 
        IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN
79331
 
                RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.';
79332
 
        END IF;
79333
 
 
79334
 
        -- Get the current user's currency precision
79335
 
        SELECT COALESCE(locale_curr_scale, 2) INTO _currencyDecimals
79336
 
        FROM locale, usr
79337
 
        WHERE usr_locale_id = locale_id AND usr_username = CURRENT_USER;
79338
 
 
79339
 
        IF (pUpdateType = 'V') THEN
79340
 
                UPDATE ipsitem
79341
 
                SET ipsitem_price = noNeg(ROUND( (ipsitem_price + pUpdateBy), _currencyDecimals))
79342
 
                WHERE (ipsitem_ipshead_id = pIpsHeadId);        
79343
 
 
79344
 
                GET DIAGNOSTICS _itemRows = ROW_COUNT;
79345
 
                
79346
 
        ELSE
79347
 
                _percentMultiplier := (1.0 + (pUpdateBy / 100.0));
79348
 
 
79349
 
                UPDATE ipsitem
79350
 
                SET ipsitem_price = noNeg(ROUND( (ipsitem_price * _percentMultiplier), _currencyDecimals))
79351
 
                WHERE (ipsitem_ipshead_id = pIpsHeadId);
79352
 
                
79353
 
                GET DIAGNOSTICS _itemRows = ROW_COUNT;
79354
 
                
79355
 
                IF (pUpdateCharPrices) THEN
79356
 
                        UPDATE ipsitemchar 
79357
 
                        SET ipsitemchar_price = noNeg(ROUND( (ipsitemchar_price * _percentMultiplier), _currencyDecimals))
79358
 
                        FROM ipsitem
79359
 
                        WHERE ipsitemchar_ipsitem_id = ipsitem_id AND ipsitem_ipshead_id = pIpsHeadId;
79360
 
                        
79361
 
                        GET DIAGNOSTICS _charRows = ROW_COUNT;
79362
 
                END IF;
79363
 
 
79364
 
        END IF;
79365
 
        
79366
 
        RETURN _itemRows + _charRows;
79367
 
 
79368
 
END;
79369
 
$$;
79370
 
 
79371
 
 
79372
 
ALTER FUNCTION public.updatepricesbypricingschedule(pipsheadid integer, pupdatetype character, pupdateby numeric, pupdatecharprices boolean) OWNER TO admin;
79373
 
 
79374
 
--
79375
 
--
79376
 
 
79377
 
CREATE FUNCTION updatepricesbyproductcategory(pprodcatid integer, pprodcatpattern text, pupdatetype character, pupdateby numeric, pupdatecharprices boolean) RETURNS numeric
79378
 
    LANGUAGE plpgsql
79379
 
    AS $$
79380
 
DECLARE
79381
 
  _percentMultiplier NUMERIC;
79382
 
  _currencyDecimals INTEGER;
79383
 
  _itemRows INTEGER :=0;
79384
 
  _charRows INTEGER :=0;
79385
 
 
79386
 
BEGIN
79387
 
 
79388
 
        IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN
79389
 
                RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.';
79390
 
        END IF;
79391
 
 
79392
 
        -- Get the current user's currency precision
79393
 
        SELECT COALESCE(locale_curr_scale, 2) INTO _currencyDecimals
79394
 
        FROM locale, usr
79395
 
        WHERE usr_locale_id = locale_id AND usr_username = CURRENT_USER;
79396
 
        
79397
 
        _percentMultiplier := (1.0 + (pUpdateBy / 100.0));
79398
 
        
79399
 
        IF (pUpdateType = 'V') THEN
79400
 
        
79401
 
                IF (pProdCatId IS NOT NULL) THEN
79402
 
                        -- Specified category id
79403
 
                        UPDATE ipsitem 
79404
 
                        SET ipsitem_price = noNeg(ROUND( (ipsitem_price + pUpdateBy), _currencyDecimals ))
79405
 
                        FROM item
79406
 
                        WHERE 
79407
 
                                ipsitem_item_id = item_id
79408
 
                                AND item_prodcat_id = pProdCatId;
79409
 
                        
79410
 
                ELSIF (pProdCatPattern IS NOT NULL) THEN
79411
 
                        -- Pattern match category
79412
 
                        UPDATE ipsitem 
79413
 
                        SET ipsitem_price = noNeg(ROUND( (ipsitem_price + pUpdateBy), _currencyDecimals ))
79414
 
                        FROM item
79415
 
                        WHERE 
79416
 
                                ipsitem_item_id = item_id
79417
 
                                AND item_prodcat_id IN (
79418
 
                                        SELECT prodcat_id FROM prodcat 
79419
 
                                        WHERE (prodcat_code ~ pProdCatPattern) 
79420
 
                                );              
79421
 
                ELSE
79422
 
                        -- All categories
79423
 
                        UPDATE ipsitem 
79424
 
                        SET ipsitem_price = noNeg(ROUND( (ipsitem_price + pUpdateBy), _currencyDecimals ));
79425
 
                END IF;
79426
 
                
79427
 
                GET DIAGNOSTICS _itemRows = ROW_COUNT;
79428
 
                
79429
 
        ELSE
79430
 
                
79431
 
                IF (pProdCatId IS NOT NULL) THEN
79432
 
                        -- Specified category id
79433
 
                        UPDATE ipsitem 
79434
 
                        SET ipsitem_price = noNeg(ROUND( (ipsitem_price * _percentMultiplier), _currencyDecimals ))
79435
 
                        FROM item
79436
 
                        WHERE 
79437
 
                                ipsitem_item_id = item_id
79438
 
                                AND item_prodcat_id = pProdCatId;
79439
 
                                
79440
 
                        GET DIAGNOSTICS _itemRows = ROW_COUNT;
79441
 
 
79442
 
                        IF(pUpdateCharPrices) THEN
79443
 
                                UPDATE ipsitemchar
79444
 
                                SET ipsitemchar_price = noNeg(ROUND( (ipsitemchar_price * _percentMultiplier), _currencyDecimals ))
79445
 
                                FROM ipsitem, item
79446
 
                                WHERE
79447
 
                                        item_prodcat_id = pProdCatId
79448
 
                                        AND ipsitem_item_id = item_id
79449
 
                                        AND ipsitemchar_ipsitem_id = ipsitem_id;
79450
 
                                
79451
 
                                GET DIAGNOSTICS _charRows = ROW_COUNT;
79452
 
                        END IF;
79453
 
                        
79454
 
                ELSIF (pProdCatPattern IS NOT NULL) THEN
79455
 
                        -- Pattern match category
79456
 
                        UPDATE ipsitem 
79457
 
                        SET ipsitem_price = noNeg(ROUND( (ipsitem_price * _percentMultiplier), _currencyDecimals ))
79458
 
                        FROM item
79459
 
                        WHERE 
79460
 
                                item_prodcat_id IN (
79461
 
                                        SELECT prodcat_id FROM prodcat 
79462
 
                                        WHERE (prodcat_code ~ pProdCatPattern ) 
79463
 
                                )
79464
 
                                AND ipsitem_item_id = item_id;
79465
 
                        
79466
 
                        GET DIAGNOSTICS _itemRows = ROW_COUNT;
79467
 
 
79468
 
                        IF(pUpdateCharPrices) THEN
79469
 
                                UPDATE ipsitemchar
79470
 
                                SET ipsitemchar_price = noNeg(ROUND( (ipsitemchar_price * _percentMultiplier), _currencyDecimals ))
79471
 
                                FROM ipsitem, item
79472
 
                                WHERE
79473
 
                                        item_prodcat_id IN (
79474
 
                                                SELECT prodcat_id FROM prodcat 
79475
 
                                                WHERE (prodcat_code ~ pProdCatPattern ) 
79476
 
                                        )
79477
 
                                        AND ipsitem_item_id = item_id
79478
 
                                        AND ipsitemchar_ipsitem_id = ipsitem_id;
79479
 
                                
79480
 
                                GET DIAGNOSTICS _charRows = ROW_COUNT;
79481
 
                        END IF;
79482
 
                        
79483
 
                ELSE
79484
 
                        -- All categories
79485
 
                        UPDATE ipsitem 
79486
 
                        SET ipsitem_price = noNeg(ROUND( (ipsitem_price * _percentMultiplier), _currencyDecimals ));
79487
 
                        
79488
 
                        GET DIAGNOSTICS _itemRows = ROW_COUNT;
79489
 
                        
79490
 
                        IF(pUpdateCharPrices) THEN
79491
 
                                UPDATE ipsitemchar
79492
 
                                SET ipsitemchar_price = noNeg(ROUND( (ipsitemchar_price * _percentMultiplier), _currencyDecimals ));
79493
 
                                
79494
 
                                GET DIAGNOSTICS _charRows = ROW_COUNT;
79495
 
                        END IF;
79496
 
                        
79497
 
                END IF;
79498
 
 
79499
 
        END IF;
79500
 
 
79501
 
        RETURN _itemRows + _charRows;
79502
 
 
79503
 
END;
79504
 
$$;
79505
 
 
79506
 
 
79507
 
ALTER FUNCTION public.updatepricesbyproductcategory(pprodcatid integer, pprodcatpattern text, pupdatetype character, pupdateby numeric, pupdatecharprices boolean) OWNER TO admin;
79508
 
 
79509
 
--
79510
 
--
79511
 
 
79512
 
CREATE FUNCTION updatereorderlevel(integer, integer, integer[]) RETURNS boolean
79513
 
    LANGUAGE plpgsql
79514
 
    AS $_$
79515
 
DECLARE
79516
 
  pItemsiteid ALIAS FOR $1;
79517
 
  pDays ALIAS FOR $2;
79518
 
  pPeriods ALIAS FOR $3;
79519
 
  _cursor INTEGER;
79520
 
  _periodid INTEGER;
79521
 
  _usage NUMERIC;
79522
 
  _totalUsage NUMERIC;
79523
 
  _totalDays INTEGER;
79524
 
  _reorderLevel INTEGER;
79525
 
  _averageUsage NUMERIC;
79526
 
  _result       TEXT;
79527
 
 
79528
 
BEGIN
79529
 
 
79530
 
  _cursor := 1;
79531
 
  _totalUsage := 0;
79532
 
  _totalDays := 0;
79533
 
 
79534
 
  _periodid = pPeriods[_cursor];
79535
 
  WHILE (_periodid IS NOT NULL) LOOP
79536
 
    SELECT COALESCE(SUM(invhist_invqty), 0) INTO _usage
79537
 
    FROM invhist
79538
 
    WHERE ( (invhist_itemsite_id=pItemsiteid)
79539
 
     AND ( invhist_transdate::DATE BETWEEN findPeriodStart(_periodid)
79540
 
                                   AND findPeriodEnd(_periodid) )
79541
 
     AND (invhist_transtype IN ('SH', 'IM')) );
79542
 
 
79543
 
    _totalUsage := (_totalUsage + _usage);
79544
 
 
79545
 
    _totalDays := ( _totalDays + ( findPeriodEnd(_periodid) -
79546
 
                                   findPeriodStart(_periodid) + 1 ) );
79547
 
 
79548
 
    _cursor := (_cursor + 1);
79549
 
    _periodid = pPeriods[_cursor];
79550
 
  END LOOP;
79551
 
 
79552
 
  IF (_totalDays > 0) THEN
79553
 
    _reorderLevel := round(_totalUsage / _totalDays * pDays);
79554
 
 
79555
 
    SELECT itemsite_stocked INTO _result from itemsite WHERE (itemsite_id=pItemsiteid);
79556
 
    IF (_reorderLevel = 0 AND _result='t') THEN
79557
 
      _reorderLevel := 1;
79558
 
    END IF;
79559
 
    
79560
 
    IF (_reorderLevel > 0) THEN
79561
 
      UPDATE itemsite
79562
 
      SET itemsite_reorderlevel = _reorderLevel
79563
 
      WHERE (itemsite_id=pItemsiteid);
79564
 
    ELSE
79565
 
      UPDATE itemsite
79566
 
      SET itemsite_reorderlevel = 0
79567
 
      WHERE (itemsite_id=pItemsiteid);
79568
 
    END IF;
79569
 
 
79570
 
    RETURN TRUE;
79571
 
  ELSE
79572
 
    RETURN FALSE;
79573
 
  END IF;
79574
 
 
79575
 
END;
79576
 
$_$;
79577
 
 
79578
 
 
79579
 
ALTER FUNCTION public.updatereorderlevel(integer, integer, integer[]) OWNER TO admin;
79580
 
 
79581
 
--
79582
 
--
79583
 
 
79584
 
CREATE FUNCTION updatereorderlevel(integer[], integer, boolean, integer[]) RETURNS SETOF reordlvl
79585
 
    LANGUAGE plpgsql
79586
 
    AS $_$
79587
 
DECLARE
79588
 
  pItemsiteids          ALIAS FOR $1;
79589
 
  pDays                 ALIAS FOR $2;
79590
 
  pAddLeadtime          ALIAS FOR $3;
79591
 
  pPeriodIds            ALIAS FOR $4;
79592
 
  _icursor              INTEGER := 1;
79593
 
  _pcursor              INTEGER := 1;
79594
 
  _totalUsage           NUMERIC := 0;
79595
 
  _totalDays            INTEGER := 0;
79596
 
  _reorderLevel         INTEGER := 0;
79597
 
  _result               TEXT;
79598
 
  _usage                NUMERIC;
79599
 
  _averageUsage         NUMERIC;
79600
 
  _row reordlvl         %ROWTYPE;
79601
 
 
79602
 
BEGIN
79603
 
  -- Validate
79604
 
  IF (pItemsiteIds[1] IS NULL OR pPeriodIds[1] IS NULL) THEN
79605
 
    RETURN;
79606
 
  END IF;
79607
 
  
79608
 
  -- Calculate total days
79609
 
  FOR _pcursor IN 1..ARRAY_UPPER(pPeriodIds,1) 
79610
 
  LOOP
79611
 
    _totalDays := ( _totalDays + ( findPeriodEnd(pPeriodIds[_pcursor]) -
79612
 
                                      findPeriodStart(pPeriodIds[_pcursor]) + 1 ) );
79613
 
  END LOOP;
79614
 
 
79615
 
  --  Loop through each itemsite id
79616
 
  FOR _icursor IN 1..ARRAY_UPPER(pItemsiteIds,1)
79617
 
  LOOP
79618
 
      -- Get itemsite data
79619
 
    SELECT itemsite_id,
79620
 
      item_id,
79621
 
      warehous_code,
79622
 
      item_number,
79623
 
      item_descrip1,
79624
 
      itemsite_leadtime,
79625
 
      0,
79626
 
      itemsite_reorderlevel,
79627
 
      0,
79628
 
      0,
79629
 
      0
79630
 
      INTO _row
79631
 
    FROM itemsite
79632
 
      JOIN item ON (itemsite_item_id=item_id)
79633
 
      JOIN whsinfo ON (itemsite_warehous_id=warehous_id)
79634
 
    WHERE (itemsite_id=pItemsiteIds[_icursor]);
79635
 
 
79636
 
    IF (FOUND) THEN
79637
 
      IF (pAddLeadtime) THEN
79638
 
        _row.reordlvl_daysofstock := pDays + _row.reordlvl_leadtime;
79639
 
      ELSE
79640
 
        _row.reordlvl_daysofstock := pDays;
79641
 
      END IF;
79642
 
      
79643
 
      --  Loop through each period id
79644
 
      FOR _pcursor IN 1..ARRAY_UPPER(pPeriodIds,1) 
79645
 
      LOOP
79646
 
        -- Sum days and usage shipping and inventory transactions
79647
 
        SELECT COALESCE(SUM(invhist_invqty), 0) INTO _usage
79648
 
        FROM invhist
79649
 
        WHERE ( (invhist_itemsite_id=pItemsiteIds[_icursor])
79650
 
         AND ( invhist_transdate::DATE BETWEEN findPeriodStart(pPeriodIds[_pcursor])
79651
 
                                       AND findPeriodEnd(pPeriodIds[_pcursor]) )
79652
 
         AND (invhist_transtype IN ('SH', 'IM')) );
79653
 
 
79654
 
        _totalUsage := (_totalUsage + _usage);
79655
 
 
79656
 
      END LOOP;
79657
 
 
79658
 
      -- Calculate reorder level
79659
 
      IF (_totalDays > 0) THEN
79660
 
        _reorderLevel := round(_totalUsage / _totalDays * _row.reordlvl_daysofstock);
79661
 
      END IF;
79662
 
  
79663
 
      IF (_reorderLevel <= 0) THEN
79664
 
        _reorderLevel := 0;
79665
 
      END IF;
79666
 
 
79667
 
      SELECT itemsite_stocked INTO _result from itemsite WHERE (itemsite_id=pItemsiteIds[_icursor]);
79668
 
      IF (_reorderLevel = 0 AND _result='t') THEN
79669
 
        _reorderLevel := 1;
79670
 
      END IF;
79671
 
 
79672
 
      -- Set values
79673
 
      _row.reordlvl_total_days          := _totalDays;
79674
 
      _row.reordlvl_total_usage := _totalUsage;
79675
 
      _row.reordlvl_calc_level          := _reorderLevel;
79676
 
 
79677
 
      -- Return result
79678
 
      RETURN NEXT _row;
79679
 
    END IF;
79680
 
 
79681
 
    _usage              := 0;
79682
 
    _averageUsage       := 0;
79683
 
    _totalUsage         := 0;
79684
 
    _reorderLevel       := 0;
79685
 
  END LOOP;
79686
 
 
79687
 
  RETURN;
79688
 
END;
79689
 
$_$;
79690
 
 
79691
 
 
79692
 
ALTER FUNCTION public.updatereorderlevel(integer[], integer, boolean, integer[]) OWNER TO admin;
79693
 
 
79694
 
--
79695
 
--
79696
 
 
79697
 
CREATE FUNCTION updateretainedearnings(integer) RETURNS integer
79698
 
    LANGUAGE plpgsql
79699
 
    AS $_$
79700
 
DECLARE
79701
 
  pYearPeriodid ALIAS FOR $1;
79702
 
  _r RECORD;
79703
 
  _n RECORD;
79704
 
  _c RECORD;
79705
 
  _beginningPeriodid INTEGER;
79706
 
  _trialbalid INTEGER;
79707
 
  _accntid INTEGER;
79708
 
  _totalProfitLoss      NUMERIC;
79709
 
  _periodid INTEGER;
79710
 
  _forwardupdate INTEGER;
79711
 
BEGIN
79712
 
 
79713
 
 
79714
 
  SELECT * INTO _r FROM yearperiod where yearperiod_id = pYearPeriodid;
79715
 
 
79716
 
  IF (NOT FOUND) THEN
79717
 
    RETURN -6;
79718
 
  END IF;
79719
 
 
79720
 
 
79721
 
  SELECT * INTO _n FROM yearperiod WHERE yearperiod_start = _r.yearperiod_end + interval '1 day';
79722
 
 
79723
 
  IF (NOT FOUND) THEN
79724
 
    RETURN -4;
79725
 
  END IF;
79726
 
 
79727
 
 
79728
 
  SELECT period_id INTO _periodid FROM period WHERE period_start = _n.yearperiod_start;
79729
 
 
79730
 
  IF (NOT FOUND) THEN
79731
 
    RETURN -8;
79732
 
  END IF;
79733
 
 
79734
 
 
79735
 
  IF (coalesce(fetchMetricValue('GLCompanySize'),0) = 0) THEN
79736
 
  --  Process for installs not using company segment
79737
 
  --  Now we need to get the default account number for year end closing
79738
 
 
79739
 
    SELECT CAST ( metric_value AS integer ) INTO _accntid FROM metric WHERE metric_name = 'YearEndEquityAccount';
79740
 
 
79741
 
    IF (NOT FOUND) THEN
79742
 
      RETURN -7;
79743
 
    END IF;
79744
 
 
79745
 
  --  So far so good.  Now we need to calculate the profit-loss for the year that we are closing
79746
 
 
79747
 
    SELECT SUM(gltrans_amount) INTO _totalProfitLoss
79748
 
     FROM gltrans, accnt
79749
 
     WHERE ( (gltrans_accnt_id = accnt_id)
79750
 
       AND   (accnt_type IN ( 'R', 'E' ) )
79751
 
       AND   (gltrans_posted)
79752
 
       AND   (NOT gltrans_deleted)
79753
 
       AND   (gltrans_date between _r.yearperiod_start and _r.yearperiod_end ) );
79754
 
    IF (_totalProfitLoss IS NULL) THEN
79755
 
      _totalProfitLoss := 0;
79756
 
    END IF;
79757
 
 
79758
 
  -- Get the trailbal_id
79759
 
 
79760
 
    SELECT trialbal_id INTO _trialbalid
79761
 
      FROM trialbal
79762
 
     WHERE ( (trialbal_period_id = _periodid )
79763
 
       AND   (trialbal_accnt_id = _accntid) );
79764
 
 
79765
 
    IF (NOT FOUND) THEN
79766
 
      RETURN -9;
79767
 
    END IF;
79768
 
 
79769
 
  -- Lets do the update for the trialbal
79770
 
 
79771
 
    UPDATE trialbal
79772
 
       SET trialbal_beginning = trialbal_beginning - trialbal_yearend + _totalProfitLoss,
79773
 
           trialbal_ending = trialbal_beginning - trialbal_yearend - trialbal_debits + trialbal_credits + _totalProfitLoss,
79774
 
           trialbal_yearend = _totalProfitLoss
79775
 
     WHERE trialbal_id = _trialbalid;
79776
 
 
79777
 
  -- Now the forward update
79778
 
 
79779
 
    SELECT forwardupdatetrialbalance(_trialbalid) INTO _forwardupdate;
79780
 
    
79781
 
  ELSE  -- Process for a multi-company set up
79782
 
  
79783
 
    FOR _c IN
79784
 
      SELECT company_number, company_yearend_accnt_id
79785
 
      FROM company
79786
 
    LOOP
79787
 
  --  Calculate the profit-loss for the year that we are closing
79788
 
 
79789
 
      SELECT SUM(gltrans_amount) INTO _totalProfitLoss
79790
 
       FROM gltrans, accnt
79791
 
       WHERE ( (gltrans_accnt_id = accnt_id)
79792
 
         AND   (accnt_type IN ( 'R', 'E' ) )
79793
 
         AND   (gltrans_posted)
79794
 
         AND   (NOT gltrans_deleted)
79795
 
         AND   (accnt_company = _c.company_number)
79796
 
         AND   (gltrans_date between _r.yearperiod_start and _r.yearperiod_end ) );
79797
 
      IF(_totalProfitLoss IS NULL) THEN
79798
 
        _totalProfitLoss := 0;
79799
 
      END IF;
79800
 
 
79801
 
    -- Get the trailbal_id
79802
 
 
79803
 
      SELECT trialbal_id INTO _trialbalid
79804
 
        FROM trialbal
79805
 
          JOIN accnt ON (trialbal_accnt_id=accnt_id)
79806
 
       WHERE ( (trialbal_period_id = _periodid )
79807
 
         AND   (trialbal_accnt_id = _c.company_yearend_accnt_id) );
79808
 
 
79809
 
      IF (NOT FOUND) THEN
79810
 
        -- Create a trial balance record
79811
 
        SELECT NEXTVAL('trialbal_trialbal_id_seq') INTO _trialbalid;
79812
 
        INSERT INTO trialbal
79813
 
          ( trialbal_id, trialbal_accnt_id, trialbal_period_id,
79814
 
            trialbal_beginning, trialbal_dirty,
79815
 
            trialbal_ending,
79816
 
            trialbal_credits,
79817
 
            trialbal_debits,
79818
 
            trialbal_yearend )
79819
 
        VALUES
79820
 
          ( _trialbalid, _c.company_yearend_accnt_id, _periodid,
79821
 
            _totalProfitLoss, TRUE,
79822
 
            _totalProfitLoss,
79823
 
            0,
79824
 
            0,
79825
 
            _totalProfitLoss );
79826
 
      ELSE
79827
 
        -- Lets do the update for the trialbal
79828
 
        UPDATE trialbal
79829
 
           SET trialbal_beginning = trialbal_beginning - trialbal_yearend + _totalProfitLoss,
79830
 
               trialbal_ending = trialbal_beginning - trialbal_yearend - trialbal_debits + trialbal_credits + _totalProfitLoss,
79831
 
               trialbal_yearend = _totalProfitLoss
79832
 
         WHERE trialbal_id = _trialbalid;
79833
 
      END IF;
79834
 
 
79835
 
    -- Now the forward update
79836
 
 
79837
 
      SELECT forwardupdatetrialbalance(_trialbalid) INTO _forwardupdate;
79838
 
 
79839
 
    END LOOP;
79840
 
  END IF;
79841
 
 
79842
 
  RETURN 0;
79843
 
 
79844
 
END;
79845
 
$_$;
79846
 
 
79847
 
 
79848
 
ALTER FUNCTION public.updateretainedearnings(integer) OWNER TO admin;
79849
 
 
79850
 
--
79851
 
--
79852
 
 
79853
 
CREATE FUNCTION updatesoracost(integer, text, boolean, numeric, boolean) RETURNS integer
79854
 
    LANGUAGE plpgsql
79855
 
    AS $_$
79856
 
DECLARE
79857
 
  pItemid       ALIAS FOR $1;
79858
 
  pCosttype     ALIAS FOR $2;
79859
 
  pLevel        ALIAS FOR $3;
79860
 
  pCost         ALIAS FOR $4;
79861
 
  pUpdateActual ALIAS FOR $5;
79862
 
 
79863
 
BEGIN
79864
 
    IF (pUpdateActual) THEN
79865
 
        RETURN updateCost(pItemid, pCosttype, pLevel, pCost);
79866
 
    ELSE
79867
 
        RETURN updateStdCost(pItemid, pCosttype, pLevel, pCost);
79868
 
    END IF;
79869
 
END;
79870
 
$_$;
79871
 
 
79872
 
 
79873
 
ALTER FUNCTION public.updatesoracost(integer, text, boolean, numeric, boolean) OWNER TO admin;
79874
 
 
79875
 
--
79876
 
--
79877
 
 
79878
 
CREATE FUNCTION updatestdcost(integer, text, boolean, numeric) RETURNS integer
79879
 
    LANGUAGE plpgsql
79880
 
    AS $_$
79881
 
DECLARE
79882
 
    pItemid     ALIAS FOR $1;
79883
 
    pCostType   ALIAS FOR $2;
79884
 
    pLevel      ALIAS FOR $3;
79885
 
    pCost       ALIAS FOR $4;
79886
 
    _newCost    NUMERIC;
79887
 
    _oldCost    NUMERIC := 0;
79888
 
    _itemcostid INTEGER;
79889
 
    _updateRet  BOOLEAN;
79890
 
    _itemNumber TEXT;
79891
 
 
79892
 
BEGIN
79893
 
    IF (pCost IS NULL) THEN
79894
 
        _newCost = 0;
79895
 
    ELSE
79896
 
        _newCost = pCost;
79897
 
    END IF;
79898
 
 
79899
 
    SELECT itemcost_id, itemcost_stdCost, item_number
79900
 
        INTO _itemcostid, _oldCost, _itemNumber
79901
 
    FROM itemcost, costelem, item
79902
 
    WHERE ((itemcost_costelem_id=costelem_id)
79903
 
      AND  (itemcost_item_id=item_id)
79904
 
      AND  (item_id=pItemid)
79905
 
      AND  (itemcost_lowlevel=pLevel)
79906
 
      AND  (costelem_type=pCosttype));
79907
 
 
79908
 
    IF (NOT FOUND) AND (_newCost > 0) THEN
79909
 
        SELECT NEXTVAL('itemcost_itemcost_id_seq') INTO _itemcostid;
79910
 
        RAISE NOTICE 'updateStdCost() inserting itemcost_id %', _itemcostid;
79911
 
        INSERT INTO itemcost
79912
 
            (itemcost_id, itemcost_item_id, itemcost_costelem_id,
79913
 
             itemcost_lowlevel, itemcost_stdcost, itemcost_posted,
79914
 
             itemcost_actcost, itemcost_updated)
79915
 
        SELECT
79916
 
              _itemcostid, pItemid, costelem_id,
79917
 
              pLevel, _newCost, CURRENT_DATE,
79918
 
              0, CURRENT_DATE
79919
 
        FROM costelem
79920
 
        WHERE (costelem_type=pCosttype);
79921
 
    END IF;
79922
 
 
79923
 
    IF (_itemcostid IS NOT NULL) THEN
79924
 
        SELECT updateStdCost(_itemcostid, _newCost, _oldCost, 'Post Cost',
79925
 
               ('Set Standard Cost - ' || pCosttype || ' for item ' || _itemNumber)) INTO _updateRet;
79926
 
        IF (_updateRet) THEN
79927
 
            RETURN _itemcostid;
79928
 
        END IF;
79929
 
    END IF;
79930
 
 
79931
 
    RETURN -1;
79932
 
END;
79933
 
$_$;
79934
 
 
79935
 
 
79936
 
ALTER FUNCTION public.updatestdcost(integer, text, boolean, numeric) OWNER TO admin;
79937
 
 
79938
 
--
79939
 
--
79940
 
 
79941
 
CREATE FUNCTION updatestdcost(pitemcostid integer, pnewcost numeric, poldcost numeric, pdocnumber text, pnotes text) RETURNS boolean
79942
 
    LANGUAGE plpgsql
79943
 
    AS $$
79944
 
DECLARE
79945
 
    _itemcostid INTEGER;
79946
 
    _r          RECORD;
79947
 
    _newcost    NUMERIC;
79948
 
    _oldcost    NUMERIC;
79949
 
 
79950
 
BEGIN
79951
 
  IF (pNewcost IS NULL) THEN
79952
 
    _newcost := 0;
79953
 
  ELSE
79954
 
    _newcost := pNewcost;
79955
 
  END IF;
79956
 
  IF (pOldcost IS NULL) THEN
79957
 
    _oldcost := 0;
79958
 
  ELSE
79959
 
    _oldcost := pOldcost;
79960
 
  END IF;
79961
 
 
79962
 
  IF (_newcost > 0) THEN
79963
 
    UPDATE itemcost
79964
 
    SET itemcost_stdcost=_newcost,
79965
 
        itemcost_posted=CURRENT_DATE
79966
 
    WHERE (itemcost_id=pItemcostid);
79967
 
  END IF;
79968
 
 
79969
 
  FOR _r IN SELECT itemsite_id, itemsite_qtyonhand AS totalQty,
79970
 
                   costcat_invcost_accnt_id, costcat_asset_accnt_id,
79971
 
                   itemsite_costmethod
79972
 
            FROM itemcost, itemsite, costcat
79973
 
            WHERE ( (itemsite_item_id=itemcost_item_id)
79974
 
             AND (itemsite_costcat_id=costcat_id)
79975
 
             AND (itemsite_costmethod != 'A')
79976
 
             AND (itemsite_qtyonhand <> 0.0)
79977
 
             AND (itemcost_id=pItemcostid) ) LOOP
79978
 
    PERFORM insertGLTransaction( 'P/D', '', pDocNumber, pNotes,
79979
 
                                 _r.costcat_invcost_accnt_id, _r.costcat_asset_accnt_id, _r.itemsite_id,
79980
 
                                 ((_newcost - _oldcost) * _r.totalQty),
79981
 
                                 CURRENT_DATE );
79982
 
    IF (_r.itemsite_costmethod <> 'A') THEN
79983
 
      UPDATE itemsite SET itemsite_value=(_r.totalQty * stdCost(itemsite_item_id))
79984
 
      WHERE (itemsite_id=_r.itemsite_id);
79985
 
    END IF;
79986
 
  END LOOP;
79987
 
 
79988
 
  IF (_newcost = 0) THEN
79989
 
    DELETE FROM itemcost
79990
 
    WHERE (itemcost_id=pItemcostid);
79991
 
 
79992
 
    RETURN FALSE;
79993
 
  END IF;
79994
 
 
79995
 
  IF ( SELECT metric_value
79996
 
        FROM metric
79997
 
        WHERE ((metric_name = 'EnableAsOfQOH')
79998
 
        AND (metric_value = 't'))) THEN
79999
 
    IF (pNewcost IS NOT NULL) THEN
80000
 
      _newcost := pNewcost;
80001
 
    END IF;
80002
 
    IF (pOldcost IS NULL) THEN
80003
 
      _oldcost := 0;
80004
 
    ELSE
80005
 
      _oldcost := pOldcost;
80006
 
    END IF;
80007
 
  --  Distribute to G/L, debit Inventory Asset, credit Inventory Cost Variance
80008
 
    PERFORM postValueIntoInvBalance(
80009
 
                  itemsite_id,
80010
 
                  current_date,
80011
 
                  asofinvqty(itemsite_id,current_date),
80012
 
                  asofinvnn(itemsite_id,current_date),
80013
 
                  _oldcost,
80014
 
                  _newcost)
80015
 
       FROM itemsite
80016
 
       JOIN item ON (itemsite_item_id=item_id)
80017
 
       JOIN itemcost ON (itemcost_item_id=item_id)
80018
 
      WHERE((itemsite_costmethod = 'S')
80019
 
        AND (itemcost_id=pItemcostid));
80020
 
  END IF;
80021
 
 
80022
 
  RETURN TRUE;
80023
 
 
80024
 
END;
80025
 
$$;
80026
 
 
80027
 
 
80028
 
ALTER FUNCTION public.updatestdcost(pitemcostid integer, pnewcost numeric, poldcost numeric, pdocnumber text, pnotes text) OWNER TO admin;
80029
 
 
80030
 
--
80031
 
--
80032
 
 
80033
 
CREATE FUNCTION updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text) RETURNS integer
80034
 
    LANGUAGE plpgsql
80035
 
    AS $_$
80036
 
BEGIN
80037
 
  RETURN updateTodoItem($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, NULL);
80038
 
END;
80039
 
$_$;
80040
 
 
80041
 
 
80042
 
ALTER FUNCTION public.updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text) OWNER TO admin;
80043
 
 
80044
 
--
80045
 
--
80046
 
 
80047
 
CREATE FUNCTION updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text, integer) RETURNS integer
80048
 
    LANGUAGE plpgsql
80049
 
    AS $_$
80050
 
DECLARE
80051
 
  ptodoitemid ALIAS FOR  $1;
80052
 
  pusername   ALIAS FOR  $2;
80053
 
  pname       ALIAS FOR  $3;
80054
 
  pdesc       ALIAS FOR  $4;
80055
 
  pincdtid    ALIAS FOR  $5;
80056
 
  pcrmacctid  ALIAS FOR  $6;
80057
 
  pOpheadid   ALIAS FOR  $7;
80058
 
  pstarted    ALIAS FOR  $8;
80059
 
  pdue        ALIAS FOR  $9;
80060
 
  pstatus     ALIAS FOR $10;
80061
 
  passigned   ALIAS FOR $11;
80062
 
  pcompleted  ALIAS FOR $12;
80063
 
  ppriority   ALIAS FOR $13;
80064
 
  pnotes      ALIAS FOR $14;
80065
 
  pactive     ALIAS FOR $15;
80066
 
  powner        ALIAS FOR $16;
80067
 
  pcntctid      ALIAS FOR $17;
80068
 
 
80069
 
  _priority   INTEGER         := ppriority;
80070
 
  _status     CHARACTER(1)    := pstatus;
80071
 
  _incdtid    INTEGER         := pincdtid;
80072
 
  _crmacctid  INTEGER         := pcrmacctid;
80073
 
  _opheadid   INTEGER         := pOpheadid;
80074
 
  _assigned   DATE            := passigned;
80075
 
  _active     BOOL            := pactive;
80076
 
  _result     INTEGER;
80077
 
 
80078
 
BEGIN
80079
 
  IF (pusername IS NULL OR pusername = '') THEN
80080
 
    RETURN -1;
80081
 
  END IF;
80082
 
 
80083
 
  IF (pname IS NULL OR pname = '') THEN
80084
 
    RETURN -2;
80085
 
  END IF;
80086
 
 
80087
 
  IF (pdue IS NULL) THEN
80088
 
    RETURN -3;
80089
 
  END IF;
80090
 
 
80091
 
  IF (ptodoitemid IS NULL OR ptodoitemid <= 0) THEN
80092
 
    RETURN -10;
80093
 
  END IF;
80094
 
 
80095
 
  IF (pcompleted IS NOT NULL) THEN
80096
 
    _status := 'C';
80097
 
  ELSIF (pstatus IS NULL AND pstarted IS NOT NULL) THEN
80098
 
    _status := 'I';
80099
 
  ELSIF (pstatus IS NULL) THEN
80100
 
    _status := 'N';
80101
 
  END IF;
80102
 
 
80103
 
  IF (_incdtid <= 0) THEN
80104
 
    _incdtid := NULL;
80105
 
  END IF;
80106
 
 
80107
 
  IF (_crmacctid <= 0) THEN
80108
 
    _crmacctid := NULL;
80109
 
  END IF;
80110
 
 
80111
 
  IF (_opheadid <= 0) THEN
80112
 
    _opheadid := NULL;
80113
 
  END IF;
80114
 
 
80115
 
  IF (_priority <= 0) THEN
80116
 
    _priority := NULL;
80117
 
  END IF;
80118
 
 
80119
 
  IF (_assigned IS NULL) THEN
80120
 
    _assigned := CURRENT_DATE;
80121
 
  END IF;
80122
 
 
80123
 
  IF (_active IS NULL) THEN
80124
 
    _active := TRUE;
80125
 
  END IF;
80126
 
 
80127
 
  UPDATE todoitem SET
80128
 
      todoitem_username=pusername, todoitem_name=pname, todoitem_description=pdesc,
80129
 
      todoitem_incdt_id=_incdtid, todoitem_status=_status,
80130
 
      todoitem_active=_active, todoitem_start_date=pstarted,
80131
 
      todoitem_due_date=pdue, todoitem_assigned_date=_assigned,
80132
 
      todoitem_completed_date=pcompleted, todoitem_priority_id=_priority,
80133
 
      todoitem_notes=pnotes, todoitem_crmacct_id=_crmacctid,
80134
 
      todoitem_ophead_id=_opheadid, todoitem_owner_username=powner,
80135
 
      todoitem_cntct_id=pcntctid
80136
 
  WHERE (todoitem_id=ptodoitemid);
80137
 
 
80138
 
  RETURN ptodoitemid;
80139
 
END;
80140
 
$_$;
80141
 
 
80142
 
 
80143
 
ALTER FUNCTION public.updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text, integer) OWNER TO admin;
80144
 
 
80145
 
--
80146
 
--
80147
 
 
80148
 
CREATE FUNCTION usedefaultlocation(integer) RETURNS boolean
80149
 
    LANGUAGE plpgsql
80150
 
    AS $_$
80151
 
DECLARE
80152
 
  pItemsiteid ALIAS FOR $1;
80153
 
  _p RECORD;
80154
 
 
80155
 
BEGIN
80156
 
 
80157
 
  SELECT itemsite_location_id,
80158
 
         LENGTH(itemsite_location) AS locationlength INTO _p
80159
 
  FROM itemsite
80160
 
  WHERE (itemsite_id=pItemsiteid);
80161
 
 
80162
 
  IF (NOT FOUND) THEN
80163
 
    RETURN FALSE;
80164
 
 
80165
 
  ELSIF (_p.itemsite_location_id <> -1) THEN
80166
 
    RETURN TRUE;
80167
 
 
80168
 
  ELSIF (_p.locationlength > 0) THEN
80169
 
    RETURN TRUE;
80170
 
 
80171
 
  ELSE
80172
 
    RETURN FALSE;
80173
 
  END IF;
80174
 
 
80175
 
END;
80176
 
$_$;
80177
 
 
80178
 
 
80179
 
ALTER FUNCTION public.usedefaultlocation(integer) OWNER TO admin;
80180
 
 
80181
 
--
80182
 
--
80183
 
 
80184
 
CREATE FUNCTION usercancreateusers(text) RETURNS boolean
80185
 
    LANGUAGE sql
80186
 
    AS $_$
80187
 
SELECT rolcreaterole OR rolsuper
80188
 
  FROM pg_roles
80189
 
 WHERE rolname=($1);
80190
 
$_$;
80191
 
 
80192
 
 
80193
 
ALTER FUNCTION public.usercancreateusers(text) OWNER TO admin;
80194
 
 
80195
 
--
80196
 
--
80197
 
 
80198
 
CREATE FUNCTION usercanlogin(pusername text) RETURNS boolean
80199
 
    LANGUAGE plpgsql
80200
 
    AS $$
80201
 
DECLARE
80202
 
  _isactive  BOOLEAN;
80203
 
  _mode      TEXT;
80204
 
BEGIN
80205
 
  IF (isDBA(pUsername) OR userCanCreateUsers(pUsername)) THEN
80206
 
    RETURN TRUE;
80207
 
 
80208
 
  ELSIF (pg_has_role(pUsername, 'xtrole', 'member')) THEN
80209
 
    _mode := COALESCE(fetchMetricText('AllowedUserLogins'), '');
80210
 
 
80211
 
    IF (_mode = 'AdminOnly') THEN
80212
 
      RETURN FALSE; -- administrators were checked above
80213
 
    END IF;
80214
 
 
80215
 
    IF (_mode NOT IN ('AdminOnly','ActiveOnly','Any')) THEN
80216
 
      _mode := 'ActiveOnly';
80217
 
    END IF;
80218
 
 
80219
 
    SELECT (usrpref_value = 't') INTO _isactive
80220
 
      FROM usrpref
80221
 
     WHERE usrpref_username = pUsername
80222
 
       AND usrpref_name = 'active';
80223
 
 
80224
 
    IF (_isactive OR _mode = 'Any') THEN
80225
 
      RETURN TRUE;
80226
 
    END IF;
80227
 
  END IF;
80228
 
 
80229
 
  RETURN FALSE;
80230
 
END;
80231
 
$$;
80232
 
 
80233
 
 
80234
 
ALTER FUNCTION public.usercanlogin(pusername text) OWNER TO admin;
80235
 
 
80236
 
--
80237
 
--
80238
 
 
80239
 
CREATE FUNCTION userid(text) RETURNS integer
80240
 
    LANGUAGE plpgsql
80241
 
    AS $_$
80242
 
DECLARE
80243
 
  pUsername ALIAS FOR $1;
80244
 
  _userId INTEGER;
80245
 
 
80246
 
BEGIN
80247
 
 
80248
 
  SELECT usesysid INTO _userId
80249
 
  FROM pg_user
80250
 
  WHERE (usename=pUsername);
80251
 
 
80252
 
  IF (FOUND) THEN
80253
 
    RETURN _userId;
80254
 
  ELSE
80255
 
    RETURN -1;
80256
 
  END IF;
80257
 
 
80258
 
END;
80259
 
$_$;
80260
 
 
80261
 
 
80262
 
ALTER FUNCTION public.userid(text) OWNER TO admin;
80263
 
 
80264
 
--
80265
 
--
80266
 
 
80267
 
CREATE FUNCTION validateorderqty(integer, numeric, boolean) RETURNS numeric
80268
 
    LANGUAGE plpgsql
80269
 
    AS $_$
80270
 
DECLARE
80271
 
  pItemsiteid ALIAS FOR $1;
80272
 
  pQty ALIAS FOR $2;
80273
 
  pManual ALIAS FOR $3;
80274
 
  _p RECORD;
80275
 
  _qty NUMERIC;
80276
 
 
80277
 
BEGIN
80278
 
 
80279
 
  _qty := pQty;
80280
 
 
80281
 
  SELECT itemsite_useparams,
80282
 
         CASE WHEN (itemsite_useparams) THEN itemsite_useparamsmanual ELSE FALSE END AS itemsite_useparamsmanual,
80283
 
         CASE WHEN (itemsite_useparams) THEN itemsite_minordqty ELSE 0.0 END AS itemsite_minordqty,
80284
 
         CASE WHEN (itemsite_useparams) THEN itemsite_multordqty ELSE 0.0 END AS itemsite_multordqty,
80285
 
         item_fractional, item_type INTO _p
80286
 
  FROM itemsite, item
80287
 
  WHERE ( (itemsite_item_id=item_id)
80288
 
   AND (itemsite_id=pItemsiteid) );
80289
 
 
80290
 
  IF ( (pManual AND (_p.itemsite_useparamsmanual)) OR
80291
 
       ((NOT pManual) AND (_p.itemsite_useparams)) ) THEN
80292
 
 
80293
 
    IF (_qty < _p.itemsite_minordqty) THEN
80294
 
      _qty := _p.itemsite_minordqty;
80295
 
    END IF;
80296
 
 
80297
 
    IF ( (_p.itemsite_multordqty > 0) AND ((_qty % _p.itemsite_multordqty) > 0) ) THEN
80298
 
      _qty := ((TRUNC(_qty / _p.itemsite_multordqty) * _p.itemsite_multordqty) + _p.itemsite_multordqty);
80299
 
    END IF;
80300
 
 
80301
 
  END IF;
80302
 
 
80303
 
  _qty := roundQty(_p.item_fractional, _qty);
80304
 
 
80305
 
  RETURN _qty;
80306
 
 
80307
 
END;
80308
 
$_$;
80309
 
 
80310
 
 
80311
 
ALTER FUNCTION public.validateorderqty(integer, numeric, boolean) OWNER TO admin;
80312
 
 
80313
 
--
80314
 
--
80315
 
 
80316
 
CREATE FUNCTION validlocation(integer, integer) RETURNS boolean
80317
 
    LANGUAGE plpgsql
80318
 
    AS $_$
80319
 
DECLARE
80320
 
  pLocationid ALIAS FOR $1;
80321
 
  pItemsiteid ALIAS FOR $2;
80322
 
  _p RECORD;
80323
 
  
80324
 
BEGIN
80325
 
 
80326
 
  SELECT location_restrict INTO _p
80327
 
  FROM location, itemsite
80328
 
  WHERE ( (location_warehous_id=itemsite_warehous_id)
80329
 
    AND (itemsite_id=pItemsiteid)
80330
 
    AND (location_id=pLocationid) );
80331
 
 
80332
 
  IF (FOUND) THEN
80333
 
    IF (_p.location_restrict) THEN
80334
 
 
80335
 
      SELECT locitem_id INTO _p
80336
 
      FROM locitem, itemsite
80337
 
      WHERE ( (locitem_item_id=itemsite_item_id)
80338
 
       AND (itemsite_id=pItemsiteid)
80339
 
       AND (locitem_location_id=pLocationid) );
80340
 
 
80341
 
      IF (FOUND) THEN
80342
 
        RETURN TRUE;
80343
 
      END IF;
80344
 
 
80345
 
    ELSE
80346
 
      RETURN TRUE;
80347
 
    END IF;
80348
 
 
80349
 
  ELSE
80350
 
    RETURN FALSE;
80351
 
  END IF;
80352
 
 
80353
 
  RETURN FALSE;
80354
 
 
80355
 
END;
80356
 
$_$;
80357
 
 
80358
 
 
80359
 
ALTER FUNCTION public.validlocation(integer, integer) OWNER TO admin;
80360
 
 
80361
 
--
80362
 
--
80363
 
 
80364
 
CREATE FUNCTION valueatshipping(plineitemid integer) RETURNS numeric
80365
 
    LANGUAGE plpgsql
80366
 
    AS $$
80367
 
BEGIN
80368
 
  RETURN valueAtShipping('SO', plineitemid);
80369
 
END;
80370
 
$$;
80371
 
 
80372
 
 
80373
 
ALTER FUNCTION public.valueatshipping(plineitemid integer) OWNER TO admin;
80374
 
 
80375
 
--
80376
 
--
80377
 
 
80378
 
CREATE FUNCTION valueatshipping(pordertype text, plineitemid integer) RETURNS numeric
80379
 
    LANGUAGE plpgsql
80380
 
    AS $$
80381
 
DECLARE
80382
 
  _value NUMERIC := 0.0;
80383
 
 
80384
 
BEGIN
80385
 
 
80386
 
  IF (pordertype NOT IN ('SO', 'TO')) THEN
80387
 
    RAISE EXCEPTION '% is not a valid order type', pordertype;
80388
 
  END IF;
80389
 
 
80390
 
  SELECT COALESCE(SUM(shipitem_value), 0.0) INTO _value
80391
 
  FROM shipitem JOIN shiphead ON (shipitem_shiphead_id=shiphead_id)
80392
 
  WHERE ( (NOT shiphead_shipped)
80393
 
    AND  (shiphead_order_type=pordertype)
80394
 
    AND  (shipitem_orderitem_id=plineitemid) );
80395
 
 
80396
 
  RETURN _value;
80397
 
 
80398
 
END;
80399
 
$$;
80400
 
 
80401
 
 
80402
 
ALTER FUNCTION public.valueatshipping(pordertype text, plineitemid integer) OWNER TO admin;
80403
 
 
80404
 
--
80405
 
--
80406
 
 
80407
 
CREATE FUNCTION voidapcheck(integer) RETURNS integer
80408
 
    LANGUAGE plpgsql
80409
 
    AS $_$
80410
 
BEGIN
80411
 
  RAISE NOTICE 'voidAPCheck() is deprecated - use voidCheck() instead';
80412
 
  RETURN voidCheck($1);
80413
 
END;
80414
 
$_$;
80415
 
 
80416
 
 
80417
 
ALTER FUNCTION public.voidapcheck(integer) OWNER TO admin;
80418
 
 
80419
 
--
80420
 
--
80421
 
 
80422
 
CREATE FUNCTION voidapopenvoucher(integer) RETURNS integer
80423
 
    LANGUAGE plpgsql
80424
 
    AS $_$
80425
 
DECLARE
80426
 
  pApopenid ALIAS FOR $1;
80427
 
BEGIN
80428
 
  RETURN voidApopenVoucher(pApopenid, fetchJournalNumber('AP-VO'));
80429
 
END;
80430
 
$_$;
80431
 
 
80432
 
 
80433
 
ALTER FUNCTION public.voidapopenvoucher(integer) OWNER TO admin;
80434
 
 
80435
 
--
80436
 
--
80437
 
 
80438
 
CREATE FUNCTION voidapopenvoucher(integer, integer) RETURNS integer
80439
 
    LANGUAGE plpgsql
80440
 
    AS $_$
80441
 
DECLARE
80442
 
  pApopenid ALIAS FOR $1;
80443
 
  pJournalNumber ALIAS FOR $2;
80444
 
  _apopenid INTEGER;
80445
 
  _apcreditapplyid INTEGER;
80446
 
  _reference    TEXT;
80447
 
  _result INTEGER;
80448
 
  _sequence INTEGER;
80449
 
  _totalAmount_base NUMERIC;
80450
 
  _totalAmount NUMERIC;
80451
 
  _itemAmount_base NUMERIC;
80452
 
  _itemAmount NUMERIC;
80453
 
  _test INTEGER;
80454
 
  _a RECORD;
80455
 
  _d RECORD;
80456
 
  _g RECORD;
80457
 
  _p RECORD;
80458
 
  _n RECORD;
80459
 
  _r RECORD;
80460
 
  _costx RECORD;
80461
 
  _pExplain BOOLEAN;
80462
 
  _pLowLevel BOOLEAN;
80463
 
  _exchGainFreight NUMERIC;
80464
 
  _firstExchDateFreight DATE;
80465
 
  _tmpTotal             NUMERIC;
80466
 
  _glDate               DATE;
80467
 
 
80468
 
BEGIN
80469
 
 
80470
 
  _totalAmount_base := 0;
80471
 
  _totalAmount := 0;
80472
 
  SELECT fetchGLSequence() INTO _sequence;
80473
 
 
80474
 
  SELECT apopen.* INTO _n
80475
 
  FROM apopen
80476
 
  WHERE ( (apopen_doctype='V')
80477
 
    AND   (apopen_id=pApopenid) );
80478
 
  IF (NOT FOUND) THEN
80479
 
    RAISE EXCEPTION 'Cannot Void Voucher Id % as apopen not found [xtuple: voidAPOpenVoucher, -10, %]',
80480
 
                        pApopenid, pApopenid;
80481
 
  END IF;
80482
 
 
80483
 
  SELECT vohead.*,
80484
 
         vend_number || '-' || vend_name || ' ' || vohead_reference
80485
 
                                                          AS glnotes,
80486
 
         COALESCE(pohead_orderdate, vohead_docdate) AS pohead_orderdate,
80487
 
         COALESCE(pohead_curr_id, vohead_curr_id) AS pohead_curr_id INTO _p
80488
 
  FROM vohead JOIN vendinfo ON (vend_id=vohead_vend_id)
80489
 
              LEFT OUTER JOIN pohead ON (vohead_pohead_id = pohead_id)
80490
 
  WHERE (vohead_number=_n.apopen_docnumber);
80491
 
  IF (NOT FOUND) THEN
80492
 
    RAISE EXCEPTION 'Cannot Void Voucher #% as vohead not found [xtuple: voidAPOpenVoucher, -20, %]',
80493
 
                        _n.apopen_docnumber, _n.apopen_docnumber;
80494
 
  END IF;
80495
 
 
80496
 
  SELECT apapply_id INTO _test
80497
 
  FROM apapply
80498
 
  WHERE (apapply_target_apopen_id=_n.apopen_id)
80499
 
  LIMIT 1;
80500
 
  IF (FOUND) THEN
80501
 
    RAISE EXCEPTION 'Cannot Void Voucher #% as applications exist [xtuple: voidAPOpenVoucher, -30, %]',
80502
 
                        _n.apopen_docnumber, _n.apopen_docnumber;
80503
 
  END IF;
80504
 
 
80505
 
  _glDate := COALESCE(_p.vohead_gldistdate, _p.vohead_distdate);
80506
 
 
80507
 
  SELECT recv_date::DATE INTO _firstExchDateFreight
80508
 
  FROM recv
80509
 
  WHERE (recv_vohead_id = _p.vohead_id);
80510
 
 
80511
 
  FOR _r IN SELECT tax_sales_accnt_id, 
80512
 
              round(sum(taxdetail_tax),2) AS tax,
80513
 
              currToBase(_p.vohead_curr_id, round(sum(taxdetail_tax),2), _p.vohead_docdate) AS taxbasevalue
80514
 
            FROM tax 
80515
 
             JOIN calculateTaxDetailSummary('VO', _p.vohead_id, 'T') ON (taxdetail_tax_id=tax_id)
80516
 
            GROUP BY tax_id, tax_sales_accnt_id LOOP
80517
 
 
80518
 
    PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', _p.vohead_number,
80519
 
                                _r.tax_sales_accnt_id, 
80520
 
                                (_r.taxbasevalue * -1),
80521
 
                                _glDate, _p.glnotes );
80522
 
 
80523
 
    _totalAmount_base := (_totalAmount_base - _r.taxbasevalue);
80524
 
    _totalAmount := (_totalAmount - _r.tax);
80525
 
     
80526
 
  END LOOP;
80527
 
 
80528
 
  FOR _g IN SELECT DISTINCT poitem_id, voitem_qty, poitem_expcat_id,
80529
 
                            poitem_invvenduomratio,
80530
 
                            COALESCE(itemsite_id, -1) AS itemsiteid,
80531
 
                            COALESCE(itemsite_costcat_id, -1) AS costcatid,
80532
 
                            COALESCE(itemsite_item_id, -1) AS itemsite_item_id,
80533
 
                            (SELECT SUM(value) 
80534
 
                             FROM (
80535
 
                                SELECT SUM(recv_value) AS value
80536
 
                                FROM recv
80537
 
                                WHERE (recv_voitem_id=voitem_id)
80538
 
                             UNION
80539
 
                                SELECT SUM(poreject_value)*-1 AS value
80540
 
                                FROM poreject
80541
 
                                WHERE (poreject_voitem_id=voitem_id)) as data)
80542
 
                            AS value_base,
80543
 
                            (poitem_freight_vouchered / poitem_qty_vouchered) * voitem_qty AS vouchered_freight,
80544
 
                            currToBase(_p.pohead_curr_id, (poitem_freight_vouchered / poitem_qty_vouchered) * voitem_qty, _firstExchDateFreight ) AS vouchered_freight_base,
80545
 
                            voitem_freight,
80546
 
                            currToBase(_p.vohead_curr_id, voitem_freight,
80547
 
                                       _p.vohead_distdate) AS voitem_freight_base
80548
 
            FROM vodist, voitem,
80549
 
                 poitem LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)
80550
 
            WHERE ( (vodist_poitem_id=poitem_id)
80551
 
             AND (voitem_poitem_id=poitem_id)
80552
 
             AND (voitem_vohead_id=vodist_vohead_id)
80553
 
             AND (vodist_vohead_id=_p.vohead_id)) LOOP
80554
 
 
80555
 
    IF (_g.costcatid = -1) THEN
80556
 
      SELECT pp.accnt_id AS pp_accnt_id,
80557
 
             lb.accnt_id AS lb_accnt_id INTO _a
80558
 
      FROM expcat, accnt AS pp, accnt AS lb
80559
 
      WHERE ( (expcat_purchprice_accnt_id=pp.accnt_id)
80560
 
       AND (expcat_liability_accnt_id=lb.accnt_id)
80561
 
       AND (expcat_id=_g.poitem_expcat_id) );
80562
 
      IF (NOT FOUND) THEN
80563
 
        RAISE EXCEPTION 'Cannot Void Voucher #% due to unassigned G/L Accounts [xtuple: voidAPOpenVoucher, -40, %]',
80564
 
                        _p.vohead_number, _p.vohead_number;
80565
 
      END IF;
80566
 
    ELSE
80567
 
      SELECT pp.accnt_id AS pp_accnt_id,
80568
 
             lb.accnt_id AS lb_accnt_id INTO _a
80569
 
      FROM costcat, accnt AS pp, accnt AS lb
80570
 
      WHERE ( (costcat_purchprice_accnt_id=pp.accnt_id)
80571
 
       AND (costcat_liability_accnt_id=lb.accnt_id)
80572
 
       AND (costcat_id=_g.costcatid) );
80573
 
      IF (NOT FOUND) THEN
80574
 
        RAISE EXCEPTION 'Cannot Void Voucher #% due to unassigned G/L Accounts [xtuple: voidAPOpenVoucher, -50, %]',
80575
 
                        _p.vohead_number, _p.vohead_number;
80576
 
      END IF;
80577
 
    END IF;
80578
 
 
80579
 
    _itemAmount_base := 0;
80580
 
    _itemAmount := 0;
80581
 
 
80582
 
    FOR _d IN SELECT vodist_id, vodist_amount,
80583
 
                     _p.vohead_curr_id, vodist_costelem_id,
80584
 
                     currToBase(_p.vohead_curr_id, vodist_amount,
80585
 
                                _p.vohead_distdate) AS vodist_amount_base
80586
 
              FROM vodist
80587
 
              WHERE ( (vodist_vohead_id=_p.vohead_id)
80588
 
               AND (vodist_poitem_id=_g.poitem_id) ) LOOP
80589
 
 
80590
 
       _pExplain := TRUE;
80591
 
       SELECT * INTO _costx
80592
 
         FROM itemcost
80593
 
        WHERE ( (itemcost_item_id = _g.itemsite_item_id)
80594
 
          AND   (itemcost_costelem_id = _d.vodist_costelem_id) );
80595
 
 
80596
 
       IF (FOUND) THEN
80597
 
         _pExplain := _costx.itemcost_lowlevel;
80598
 
       END IF;
80599
 
 
80600
 
      _itemAmount_base := _itemAmount_base + ROUND(_d.vodist_amount_base, 2);
80601
 
      _itemAmount := _itemAmount + _d.vodist_amount;
80602
 
 
80603
 
    END LOOP;
80604
 
 
80605
 
    PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number),
80606
 
                                _a.lb_accnt_id,
80607
 
                                round(_g.value_base + _g.vouchered_freight_base, 2),
80608
 
                                _glDate, _p.glnotes );
80609
 
 
80610
 
    _exchGainFreight := 0;
80611
 
    SELECT currGain(_p.pohead_curr_id, _g.vouchered_freight,
80612
 
                    _firstExchDateFreight, _p.vohead_distdate )
80613
 
                    INTO _exchGainFreight;
80614
 
    IF (round(_exchGainFreight, 2) <> 0) THEN
80615
 
      PERFORM insertIntoGLSeries(_sequence, 'A/P', 'VO',
80616
 
                                 text(_p.vohead_number),
80617
 
                                 getGainLossAccntId(_a.lb_accnt_id), round(_exchGainFreight, 2) * -1,
80618
 
                                 _glDate, _p.glnotes);
80619
 
    END IF;
80620
 
 
80621
 
    IF (round(_itemAmount_base, 2) <> round(_g.value_base, 2)) THEN
80622
 
      _tmpTotal := round(_itemAmount_base, 2) - round(_g.value_base, 2);
80623
 
      PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number),
80624
 
                                  _a.pp_accnt_id,
80625
 
                                  _tmpTotal,
80626
 
                                  _glDate, _p.glnotes );
80627
 
    END IF;
80628
 
 
80629
 
    IF (round(_g.voitem_freight_base + _exchGainFreight, 2) <> round(_g.vouchered_freight_base, 2)) THEN
80630
 
      _tmpTotal := round(_g.voitem_freight_base + _exchGainFreight, 2) - round(_g.vouchered_freight_base, 2);
80631
 
      PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number),
80632
 
                                  _a.pp_accnt_id,
80633
 
                                  _tmpTotal,
80634
 
                                  _glDate, _p.glnotes );
80635
 
    END IF;
80636
 
 
80637
 
    _totalAmount_base := (_totalAmount_base + _itemAmount_base + _g.voitem_freight_base);
80638
 
    _totalAmount := (_totalAmount + _itemAmount + _g.voitem_freight);
80639
 
 
80640
 
    UPDATE recv
80641
 
    SET recv_invoiced=FALSE,
80642
 
        recv_recvcost_curr_id=basecurrid(),
80643
 
        recv_recvcost=0,
80644
 
        recv_vohead_id=NULL,
80645
 
        recv_voitem_id=NULL
80646
 
    FROM poitem
80647
 
    WHERE ( (recv_orderitem_id=poitem_id)
80648
 
      AND   (recv_order_type='PO')
80649
 
      AND   (recv_orderitem_id=_g.poitem_id)
80650
 
      AND   (recv_vohead_id=_p.vohead_id) );
80651
 
 
80652
 
    UPDATE poreject
80653
 
    SET poreject_invoiced=FALSE,
80654
 
        poreject_vohead_id=NULL,
80655
 
        poreject_voitem_id=NULL
80656
 
    WHERE ( (poreject_poitem_id=_g.poitem_id)
80657
 
      AND   (poreject_vohead_id=_p.vohead_id) );
80658
 
 
80659
 
    UPDATE poitem
80660
 
       SET poitem_qty_vouchered = (poitem_qty_vouchered - _g.voitem_qty),
80661
 
           poitem_freight_vouchered = (poitem_freight_vouchered - _g.voitem_freight)
80662
 
    WHERE (poitem_id=_g.poitem_id);
80663
 
 
80664
 
  END LOOP;
80665
 
 
80666
 
  FOR _d IN SELECT vodist_id,
80667
 
                   currToBase(_p.vohead_curr_id, vodist_amount,
80668
 
                              _p.vohead_distdate) AS vodist_amount_base,
80669
 
                   vodist_amount,
80670
 
                   vodist_accnt_id, vodist_expcat_id
80671
 
            FROM vodist
80672
 
            WHERE ( (vodist_vohead_id=_p.vohead_id)
80673
 
              AND   (vodist_poitem_id=-1)
80674
 
              AND   (vodist_tax_id=-1) ) LOOP
80675
 
 
80676
 
    IF (_d.vodist_accnt_id = -1) THEN
80677
 
      PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number),
80678
 
                                  expcat_exp_accnt_id,
80679
 
                                  round(_d.vodist_amount_base, 2),
80680
 
                                  _glDate, _p.glnotes )
80681
 
      FROM expcat
80682
 
      WHERE (expcat_id=_d.vodist_expcat_id);
80683
 
    ELSE
80684
 
      PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number),
80685
 
                                  _d.vodist_accnt_id,
80686
 
                                  round(_d.vodist_amount_base, 2),
80687
 
                                  _glDate, _p.glnotes );
80688
 
    END IF;
80689
 
 
80690
 
    _totalAmount_base := _totalAmount_base + ROUND(_d.vodist_amount_base, 2);
80691
 
    _totalAmount := _totalAmount + _d.vodist_amount;
80692
 
 
80693
 
  END LOOP;
80694
 
 
80695
 
  SELECT insertIntoGLSeries( _sequence, 'A/P', 'VO', text(vohead_number),
80696
 
                             accnt_id, round(_totalAmount_base, 2) * -1,
80697
 
                             _glDate, _p.glnotes ) INTO _test
80698
 
  FROM vohead LEFT OUTER JOIN accnt ON (accnt_id=findAPAccount(vohead_vend_id))
80699
 
  WHERE ( (findAPAccount(vohead_vend_id)=0 OR accnt_id > 0) -- G/L interface might be disabled
80700
 
    AND   (vohead_id=_p.vohead_id) );
80701
 
  IF (NOT FOUND) THEN
80702
 
    RAISE EXCEPTION 'Cannot Void Voucher #% due to an unassigned A/P Account [xtuple: voidAPOpenVoucher, -60, %]',
80703
 
                        _p.vohead_number, _p.vohead_number;
80704
 
  END IF;
80705
 
 
80706
 
  PERFORM postGLSeries(_sequence, pJournalNumber);
80707
 
 
80708
 
  SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid;
80709
 
  _reference := ('Void Voucher #' || _n.apopen_docnumber);
80710
 
  INSERT INTO apopen
80711
 
  ( apopen_id, apopen_username, apopen_journalnumber,
80712
 
    apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber,
80713
 
    apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_curr_id,
80714
 
    apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_discount, apopen_curr_rate )
80715
 
  SELECT _apopenid, getEffectiveXtUser(), pJournalnumber,
80716
 
         apopen_vend_id, apopen_docnumber, 'C', apopen_ponumber,
80717
 
         _glDate, _glDate, _glDate, -1, apopen_curr_id,
80718
 
         apopen_amount - apopen_paid, 0, TRUE, _reference, TRUE, apopen_curr_rate
80719
 
    FROM apopen
80720
 
   WHERE (apopen_id=_n.apopen_id);
80721
 
 
80722
 
  SELECT apcreditapply_id INTO _apcreditapplyid
80723
 
    FROM apcreditapply
80724
 
   WHERE ( (apcreditapply_source_apopen_id=_apopenid)
80725
 
     AND   (apcreditapply_target_apopen_id=_n.apopen_id) );
80726
 
  IF (FOUND) THEN
80727
 
    UPDATE apcreditapply
80728
 
       SET apcreditapply_amount=_n.apopen_amount-_n.apopen_paid
80729
 
     WHERE (apcreditapply_id=_apcreditapplyid);
80730
 
  ELSE
80731
 
    SELECT nextval('apcreditapply_apcreditapply_id_seq') INTO _apcreditapplyid;
80732
 
    INSERT INTO apcreditapply
80733
 
           ( apcreditapply_id, apcreditapply_source_apopen_id,
80734
 
             apcreditapply_target_apopen_id, apcreditapply_amount,
80735
 
             apcreditapply_curr_id )
80736
 
    VALUES ( _apcreditapplyid, _apopenid, _n.apopen_id, _n.apopen_amount-_n.apopen_paid, _n.apopen_curr_id );
80737
 
  END IF;
80738
 
 
80739
 
  SELECT postAPCreditMemoApplication(_apopenid) INTO _result;
80740
 
 
80741
 
  IF (_result < 0) THEN
80742
 
    RAISE EXCEPTION 'Credit application failed with result % [xtuple: voidAPOpenVoucher, -70, %]',
80743
 
                        _result, _result;
80744
 
  END IF;
80745
 
 
80746
 
  UPDATE poitem
80747
 
  SET poitem_status='O'
80748
 
  FROM voitem
80749
 
  WHERE ( (voitem_poitem_id=poitem_id)
80750
 
    AND   (voitem_close)
80751
 
    AND   (voitem_vohead_id=_p.vohead_id) );
80752
 
 
80753
 
  UPDATE pohead
80754
 
  SET pohead_status='O'
80755
 
  WHERE (pohead_id=_p.vohead_pohead_id);
80756
 
 
80757
 
  UPDATE apopen
80758
 
  SET apopen_void=TRUE
80759
 
  WHERE (apopen_id=_n.apopen_id);
80760
 
 
80761
 
  RETURN pJournalNumber;
80762
 
 
80763
 
END;
80764
 
$_$;
80765
 
 
80766
 
 
80767
 
ALTER FUNCTION public.voidapopenvoucher(integer, integer) OWNER TO admin;
80768
 
 
80769
 
--
80770
 
--
80771
 
 
80772
 
CREATE FUNCTION voidcheck(integer) RETURNS integer
80773
 
    LANGUAGE plpgsql
80774
 
    AS $_$
80775
 
DECLARE
80776
 
  pCheckid ALIAS FOR $1;
80777
 
 
80778
 
BEGIN
80779
 
 
80780
 
  IF ( SELECT (checkhead_void OR checkhead_posted OR checkhead_replaced)
80781
 
       FROM checkhead
80782
 
       WHERE (checkhead_id=pCheckid) ) THEN
80783
 
    RETURN -1;
80784
 
  END IF;
80785
 
 
80786
 
  UPDATE checkhead
80787
 
  SET checkhead_void=TRUE
80788
 
  WHERE (checkhead_id=pCheckid);
80789
 
 
80790
 
  RETURN 1;
80791
 
 
80792
 
END;
80793
 
$_$;
80794
 
 
80795
 
 
80796
 
ALTER FUNCTION public.voidcheck(integer) OWNER TO admin;
80797
 
 
80798
 
--
80799
 
--
80800
 
 
80801
 
CREATE FUNCTION voidcreditmemo(integer) RETURNS integer
80802
 
    LANGUAGE plpgsql
80803
 
    AS $_$
80804
 
DECLARE
80805
 
  pCmheadid ALIAS FOR $1;
80806
 
  _r RECORD;
80807
 
  _p RECORD;
80808
 
  _n RECORD;
80809
 
  _glSequence INTEGER := 0;
80810
 
  _glJournal INTEGER := 0;
80811
 
  _itemlocSeries INTEGER := 0;
80812
 
  _invhistid INTEGER;
80813
 
  _test INTEGER;
80814
 
  _amount NUMERIC;
80815
 
  _roundedBase NUMERIC;
80816
 
  _totalAmount NUMERIC   := 0;
80817
 
  _totalRoundedBase NUMERIC := 0;
80818
 
  _commissionDue NUMERIC := 0;
80819
 
  _toApply NUMERIC;
80820
 
  _toClose BOOLEAN;
80821
 
  _glDate       DATE;
80822
 
  _taxBaseValue NUMERIC := 0;
80823
 
 
80824
 
BEGIN
80825
 
 
80826
 
  SELECT cmhead.*,
80827
 
         findARAccount(cmhead_cust_id) AS ar_accnt_id,
80828
 
         ( SELECT COALESCE(SUM(taxhist_tax), 0)
80829
 
           FROM cmheadtax
80830
 
           WHERE ( (taxhist_parent_id = cmhead_id)
80831
 
             AND   (taxhist_taxtype_id = getAdjustmentTaxtypeId()) ) ) AS adjtax
80832
 
         INTO _p
80833
 
  FROM cmhead
80834
 
  WHERE (cmhead_id=pCmheadid);
80835
 
  IF (NOT FOUND) THEN
80836
 
    RAISE EXCEPTION 'Cannot Void Credit Memo as cmhead not found';
80837
 
  END IF;
80838
 
  IF (NOT _p.cmhead_posted) THEN
80839
 
    RETURN -10;
80840
 
  END IF;
80841
 
 
80842
 
  SELECT aropen.* INTO _n
80843
 
  FROM aropen
80844
 
  WHERE ( (aropen_doctype='C')
80845
 
    AND   (aropen_docnumber=_p.cmhead_number) );
80846
 
  IF (NOT FOUND) THEN
80847
 
    RAISE EXCEPTION 'Cannot Void Credit Memo as aropen not found';
80848
 
  END IF;
80849
 
 
80850
 
  SELECT arapply_id INTO _test
80851
 
  FROM arapply
80852
 
  WHERE (arapply_target_aropen_id=_n.aropen_id)
80853
 
     OR (arapply_source_aropen_id=_n.aropen_id)
80854
 
  LIMIT 1;
80855
 
  IF (FOUND) THEN
80856
 
    RETURN -20;
80857
 
  END IF;
80858
 
 
80859
 
  _glDate := COALESCE(_p.cmhead_gldistdate, _p.cmhead_docdate);
80860
 
 
80861
 
  SELECT fetchGLSequence() INTO _glSequence;
80862
 
  SELECT fetchJournalNumber('AR-IN') INTO _glJournal;
80863
 
 
80864
 
  FOR _r IN SELECT tax_sales_accnt_id, 
80865
 
              round(sum(taxdetail_tax),2) AS tax,
80866
 
              currToBase(_p.cmhead_curr_id, round(sum(taxdetail_tax),2), _p.cmhead_docdate) AS taxbasevalue
80867
 
            FROM tax 
80868
 
             JOIN calculateTaxDetailSummary('CM', _p.cmhead_id, 'T') ON (taxdetail_tax_id=tax_id)
80869
 
            GROUP BY tax_id, tax_sales_accnt_id LOOP
80870
 
 
80871
 
    PERFORM insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number,
80872
 
                                _r.tax_sales_accnt_id, 
80873
 
                                (_r.taxbasevalue * -1.0),
80874
 
                                _glDate, ('Void-' || _p.cmhead_billtoname) );
80875
 
 
80876
 
    _totalAmount := _totalAmount + _r.tax * -1;
80877
 
    _totalRoundedBase := _totalRoundedBase + _r.taxbasevalue * -1;  
80878
 
  END LOOP;
80879
 
 
80880
 
  FOR _r IN SELECT *
80881
 
            FROM creditmemoitem
80882
 
            WHERE ( (cmitem_cmhead_id=_p.cmhead_id)
80883
 
              AND   (cmitem_qtycredit <> 0 ) ) LOOP
80884
 
 
80885
 
    IF (_r.extprice <> 0) THEN
80886
 
      _roundedBase := round(currToBase(_p.cmhead_curr_id, _r.extprice, _p.cmhead_docdate), 2);
80887
 
      SELECT insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number,
80888
 
                                 CASE WHEN _p.cmhead_rahead_id IS NULL THEN
80889
 
                                   getPrjAccntId(_p.cmhead_prj_id, salesaccnt_credit_accnt_id)
80890
 
                                 ELSE
80891
 
                                   getPrjAccntId(_p.cmhead_prj_id, salesaccnt_returns_accnt_id)
80892
 
                                 END,
80893
 
                                 _roundedBase,
80894
 
                                 _glDate, ('Void-' || _p.cmhead_billtoname) ) INTO _test
80895
 
      FROM salesaccnt
80896
 
      WHERE (salesaccnt_id=findSalesAccnt(_r.cmitem_itemsite_id, 'IS', _p.cmhead_cust_id,
80897
 
                                          _p.cmhead_saletype_id, _p.cmhead_shipzone_id));
80898
 
      IF (NOT FOUND) THEN
80899
 
        PERFORM deleteGLSeries(_glSequence);
80900
 
        RETURN -11;
80901
 
      END IF;
80902
 
    END IF;
80903
 
 
80904
 
    _totalAmount := _totalAmount + round(_r.extprice, 2);
80905
 
    _totalRoundedBase := _totalRoundedBase + _roundedBase;
80906
 
 
80907
 
  END LOOP;
80908
 
 
80909
 
  IF (_p.cmhead_misc <> 0) THEN
80910
 
    _roundedBase := round(currToBase(_p.cmhead_curr_id, _p.cmhead_misc, _p.cmhead_docdate), 2);
80911
 
    SELECT insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number,
80912
 
                               getPrjAccntId(_p.cmhead_prj_id, accnt_id),
80913
 
                               _roundedBase,
80914
 
                               _glDate, ('Void-' ||_p.cmhead_billtoname) ) INTO _test
80915
 
    FROM accnt
80916
 
    WHERE (accnt_id=_p.cmhead_misc_accnt_id);
80917
 
 
80918
 
    IF (NOT FOUND) THEN
80919
 
      PERFORM deleteGLSeries(_glSequence);
80920
 
      RETURN _test;
80921
 
    END IF;
80922
 
 
80923
 
    _totalAmount := _totalAmount + _p.cmhead_misc;
80924
 
    _totalRoundedBase := _totalRoundedBase + _roundedBase;
80925
 
  END IF;
80926
 
 
80927
 
  IF (_p.cmhead_freight <> 0) THEN
80928
 
    _roundedBase := round(currToBase(_p.cmhead_curr_id, _p.cmhead_freight, _p.cmhead_docdate), 2);
80929
 
    SELECT insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number,
80930
 
                               getPrjAccntId(_p.cmhead_prj_id, accnt_id),
80931
 
                               _roundedBase,
80932
 
                               _glDate, ('Void-' || _p.cmhead_billtoname) ) INTO _test
80933
 
    FROM accnt
80934
 
    WHERE (accnt_id=findFreightAccount(_p.cmhead_cust_id));
80935
 
 
80936
 
    IF (NOT FOUND) THEN
80937
 
      PERFORM deleteGLSeries(_glSequence);
80938
 
      RETURN _test;
80939
 
    END IF;
80940
 
 
80941
 
    _totalAmount := _totalAmount + _p.cmhead_freight;
80942
 
    _totalRoundedBase := _totalRoundedBase + _roundedBase;
80943
 
  END IF;
80944
 
 
80945
 
  _totalAmount := _totalAmount;
80946
 
 
80947
 
  IF (_totalAmount <> 0) THEN
80948
 
    IF (_p.ar_accnt_id != -1) THEN
80949
 
      SELECT insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number,
80950
 
                                 _p.ar_accnt_id,
80951
 
                                 (_totalRoundedBase * -1.0),
80952
 
                                 _glDate, ('Void-' || _p.cmhead_billtoname) ) INTO _test;
80953
 
    ELSE
80954
 
      PERFORM deleteGLSeries(_glSequence);
80955
 
      RETURN _test;
80956
 
    END IF;
80957
 
  END IF;
80958
 
 
80959
 
  SELECT postGLSeries(_glSequence, _glJournal) INTO _test;
80960
 
  IF (_test < 0) THEN
80961
 
    PERFORM deleteGLSeries(_glSequence);
80962
 
    RETURN _test;
80963
 
  END IF;
80964
 
 
80965
 
  DELETE FROM cohisttax
80966
 
  WHERE (taxhist_parent_id IN (SELECT cohist_id
80967
 
                               FROM cohist
80968
 
                               WHERE (cohist_doctype='C' AND cohist_ordernumber=_p.cmhead_number)));
80969
 
 
80970
 
  DELETE FROM cohist
80971
 
  WHERE (cohist_doctype='C' AND cohist_ordernumber=_p.cmhead_number);
80972
 
 
80973
 
  DELETE FROM aropen
80974
 
  WHERE (aropen_doctype='C' AND aropen_docnumber=_p.cmhead_number);
80975
 
 
80976
 
  FOR _r IN SELECT cmitem_itemsite_id AS itemsite_id, cmitem_id,
80977
 
                   (cmitem_qtyreturned * cmitem_qty_invuomratio) AS qty,
80978
 
                   cmhead_number, cmhead_cust_id AS cust_id, item_number,
80979
 
                   cmhead_prj_id AS prj_id, cmhead_saletype_id AS saletype_id,
80980
 
                   cmhead_shipzone_id AS shipzone_id
80981
 
            FROM cmhead, cmitem, itemsite, item
80982
 
            WHERE ( (cmitem_cmhead_id=cmhead_id)
80983
 
             AND (cmitem_itemsite_id=itemsite_id)
80984
 
             AND (itemsite_item_id=item_id)
80985
 
             AND (cmitem_qtyreturned <> 0)
80986
 
             AND (cmitem_updateinv)
80987
 
             AND (cmhead_id=_p.cmhead_id) ) LOOP
80988
 
 
80989
 
    IF (_itemlocSeries = 0) THEN
80990
 
      SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
80991
 
    END IF;
80992
 
    SELECT postInvTrans( itemsite_id, 'RS', (_r.qty * -1),
80993
 
                         'S/O', 'CM', _r.cmhead_number, '',
80994
 
                         ('Credit Voided ' || _r.item_number),
80995
 
                         costcat_asset_accnt_id,
80996
 
                         getPrjAccntId(_r.prj_id, resolveCOSAccount(itemsite_id, _r.cust_id, _r.saletype_id, _r.shipzone_id)),  
80997
 
                         _itemlocSeries, _glDate) INTO _invhistid
80998
 
    FROM itemsite, costcat
80999
 
    WHERE ( (itemsite_costcat_id=costcat_id)
81000
 
     AND (itemsite_id=_r.itemsite_id) );
81001
 
 
81002
 
  END LOOP;
81003
 
 
81004
 
  FOR _r IN SELECT cmitem_qtyreturned, cmitem_itemsite_id, cohead_id
81005
 
            FROM cmitem, cmhead, invchead, cohead
81006
 
            WHERE ( (cmitem_cmhead_id=cmhead_id)
81007
 
             AND (cmhead_invcnumber=invchead_invcnumber)
81008
 
             AND (invchead_ordernumber=cohead_number)
81009
 
             AND (cmitem_qtyreturned <> 0)
81010
 
             AND (cmitem_updateinv)
81011
 
             AND (cmhead_id=_p.cmhead_id) ) LOOP
81012
 
    UPDATE coitem
81013
 
    SET coitem_qtyreturned = (coitem_qtyreturned + (_r.cmitem_qtyreturned * -1.0))
81014
 
    WHERE coitem_id IN ( SELECT coitem_id
81015
 
                         FROM coitem
81016
 
                         WHERE ( (coitem_cohead_id=_r.cohead_id)
81017
 
                          AND (coitem_itemsite_id = _r.cmitem_itemsite_id) )
81018
 
                         LIMIT 1 );
81019
 
  END LOOP;
81020
 
 
81021
 
  UPDATE cmhead
81022
 
  SET cmhead_void=TRUE
81023
 
  WHERE (cmhead_id=_p.cmhead_id);
81024
 
 
81025
 
  RETURN _itemlocSeries;
81026
 
 
81027
 
END;
81028
 
$_$;
81029
 
 
81030
 
 
81031
 
ALTER FUNCTION public.voidcreditmemo(integer) OWNER TO admin;
81032
 
 
81033
 
--
81034
 
--
81035
 
 
81036
 
CREATE FUNCTION voidinvoice(integer) RETURNS integer
81037
 
    LANGUAGE plpgsql
81038
 
    AS $_$
81039
 
DECLARE
81040
 
  pInvcheadid ALIAS FOR $1;
81041
 
  _glSequence INTEGER := 0;
81042
 
  _glJournal INTEGER := 0;
81043
 
  _itemlocSeries INTEGER := 0;
81044
 
  _aropenid INTEGER := 0;
81045
 
  _invhistid INTEGER := 0;
81046
 
  _amount NUMERIC;
81047
 
  _roundedBase NUMERIC;
81048
 
  _r RECORD;
81049
 
  _p RECORD;
81050
 
  _n RECORD;
81051
 
  _test INTEGER;
81052
 
  _totalAmount          NUMERIC := 0;
81053
 
  _totalRoundedBase     NUMERIC := 0;
81054
 
  _totalAmountBase      NUMERIC := 0;
81055
 
  _appliedAmount        NUMERIC := 0;
81056
 
  _commissionDue        NUMERIC := 0;
81057
 
  _tmpAccntId INTEGER;
81058
 
  _tmpCurrId  INTEGER;
81059
 
  _firstExchDate        DATE;
81060
 
  _glDate               DATE;
81061
 
  _exchGain             NUMERIC := 0;
81062
 
 
81063
 
BEGIN
81064
 
 
81065
 
  SELECT invchead.*,
81066
 
         findFreightAccount(invchead_cust_id) AS freightaccntid,
81067
 
         findARAccount(invchead_cust_id) AS araccntid,
81068
 
         aropen_id, cohist_unitcost,
81069
 
         ( SELECT COALESCE(SUM(taxhist_tax), 0)
81070
 
           FROM invcheadtax
81071
 
           WHERE ( (taxhist_parent_id = invchead_id)
81072
 
             AND   (taxhist_taxtype_id = getFreightTaxtypeId()) ) ) AS freighttax,
81073
 
         ( SELECT COALESCE(SUM(taxhist_tax), 0)
81074
 
           FROM invcheadtax
81075
 
           WHERE ( (taxhist_parent_id = invchead_id)
81076
 
             AND   (taxhist_taxtype_id = getAdjustmentTaxtypeId()) ) ) AS adjtax
81077
 
       INTO _p 
81078
 
  FROM invchead JOIN aropen ON (aropen_doctype='I' AND aropen_docnumber=invchead_invcnumber)
81079
 
                JOIN cohist ON (cohist_doctype='I' AND cohist_invcnumber=invchead_invcnumber)
81080
 
  WHERE (invchead_id=pInvcheadid);
81081
 
  IF (NOT FOUND) THEN
81082
 
    RAISE EXCEPTION 'Cannot Void Invoice as invchead not found';
81083
 
  END IF;
81084
 
  IF (NOT _p.invchead_posted) THEN
81085
 
    RETURN -10;
81086
 
  END IF;
81087
 
 
81088
 
  SELECT aropen.* INTO _n
81089
 
  FROM aropen
81090
 
  WHERE ( (aropen_doctype='I')
81091
 
    AND   (aropen_docnumber=_p.invchead_invcnumber) );
81092
 
  IF (NOT FOUND) THEN
81093
 
    RAISE EXCEPTION 'Cannot Void Invoice as aropen not found';
81094
 
  END IF;
81095
 
 
81096
 
  SELECT arapply_id INTO _test
81097
 
  FROM arapply
81098
 
  WHERE (arapply_target_aropen_id=_n.aropen_id)
81099
 
  LIMIT 1;
81100
 
  IF (FOUND) THEN
81101
 
    RETURN -20;
81102
 
  END IF;
81103
 
 
81104
 
  SELECT fetchGLSequence() INTO _glSequence;
81105
 
  SELECT fetchJournalNumber('AR-IN') INTO _glJournal;
81106
 
 
81107
 
  _glDate := COALESCE(_p.invchead_gldistdate, _p.invchead_invcdate);
81108
 
 
81109
 
  IF TRUE THEN
81110
 
      _firstExchDate := _p.invchead_invcdate;
81111
 
  ELSE
81112
 
      SELECT cohead_orderdate INTO _firstExchDate
81113
 
      FROM cohead
81114
 
      WHERE (cohead_number = _p.invchead_ordernumber);
81115
 
  END IF;
81116
 
 
81117
 
  FOR _r IN SELECT tax_sales_accnt_id, 
81118
 
              round(sum(taxdetail_tax),2) AS tax,
81119
 
              currToBase(_p.invchead_curr_id, round(sum(taxdetail_tax),2), _firstExchDate) AS taxbasevalue
81120
 
            FROM tax 
81121
 
             JOIN calculateTaxDetailSummary('I', _p.invchead_id, 'T') ON (taxdetail_tax_id=tax_id)
81122
 
            GROUP BY tax_id, tax_sales_accnt_id LOOP
81123
 
 
81124
 
    PERFORM insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber,
81125
 
                                _r.tax_sales_accnt_id, 
81126
 
                                (_r.taxbasevalue * -1.0),
81127
 
                                _glDate, ('Void-' || _p.invchead_billto_name) );
81128
 
 
81129
 
    _totalAmount := _totalAmount + _r.tax;
81130
 
    _totalRoundedBase := _totalRoundedBase + _r.taxbasevalue;  
81131
 
  END LOOP;
81132
 
 
81133
 
  FOR _r IN SELECT *
81134
 
            FROM invoiceitem
81135
 
            WHERE ( (invcitem_invchead_id = _p.invchead_id)
81136
 
              AND   (invcitem_item_id <> -1) ) LOOP
81137
 
 
81138
 
    _amount := _r.extprice;
81139
 
 
81140
 
    IF (_amount > 0) THEN
81141
 
      IF (_r.itemsite_id IS NULL) THEN
81142
 
        SELECT getPrjAccntId(_p.invchead_prj_id, salesaccnt_sales_accnt_id) 
81143
 
        INTO _tmpAccntId
81144
 
        FROM salesaccnt
81145
 
        WHERE (salesaccnt_id=findSalesAccnt(_r.invcitem_item_id, 'I', _p.invchead_cust_id,
81146
 
                                            _p.invchead_saletype_id, _p.invchead_shipzone_id));
81147
 
      ELSE
81148
 
        SELECT getPrjAccntId(_p.invchead_prj_id, salesaccnt_sales_accnt_id) 
81149
 
        INTO _tmpAccntId
81150
 
        FROM salesaccnt
81151
 
        WHERE (salesaccnt_id=findSalesAccnt(_r.itemsite_id, 'IS', _p.invchead_cust_id,
81152
 
                                            _p.invchead_saletype_id, _p.invchead_shipzone_id));
81153
 
      END IF;
81154
 
 
81155
 
      IF (NOT FOUND) THEN
81156
 
        PERFORM deleteGLSeries(_glSequence);
81157
 
        RETURN -11;
81158
 
      END IF;
81159
 
 
81160
 
      _roundedBase := round(currToBase(_p.invchead_curr_id, _amount, _firstExchDate), 2);
81161
 
      SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber,
81162
 
                                 _tmpAccntId,
81163
 
                                 (_roundedBase * -1.0),
81164
 
                                 _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test;
81165
 
 
81166
 
      _totalAmount := (_totalAmount + _amount);
81167
 
      _totalRoundedBase := _totalRoundedBase + _roundedBase;
81168
 
      _commissionDue := (_commissionDue + (_amount * _p.invchead_commission));
81169
 
    END IF;
81170
 
 
81171
 
    _totalAmount := _totalAmount;
81172
 
    _totalRoundedBase := _totalRoundedBase;
81173
 
 
81174
 
  END LOOP;
81175
 
 
81176
 
  FOR _r IN SELECT *
81177
 
            FROM invoiceitem JOIN salescat ON (salescat_id = invcitem_salescat_id)
81178
 
            WHERE ( (invcitem_item_id = -1)
81179
 
              AND   (invcitem_invchead_id=_p.invchead_id) ) LOOP
81180
 
 
81181
 
    _amount := _r.extprice;
81182
 
 
81183
 
    IF (_amount > 0) THEN
81184
 
      _roundedBase = round(currToBase(_p.invchead_curr_id, _amount,
81185
 
                                      _firstExchDate), 2);
81186
 
      SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber,
81187
 
                                 getPrjAccntId(_p.invchead_prj_id, _r.salescat_sales_accnt_id), 
81188
 
                                 (_roundedBase * -1.0),
81189
 
                                 _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test;
81190
 
 
81191
 
      IF (_test < 0) THEN
81192
 
        PERFORM deleteGLSeries(_glSequence);
81193
 
        RETURN _test;
81194
 
      END IF;
81195
 
 
81196
 
      _totalAmount := (_totalAmount + _amount);
81197
 
      _totalRoundedBase :=  _totalRoundedBase + _roundedBase;
81198
 
      _commissionDue := (_commissionDue + (_amount * _p.invchead_commission));
81199
 
    END IF;
81200
 
 
81201
 
  END LOOP;
81202
 
 
81203
 
  IF (_p.invchead_freight <> 0) THEN
81204
 
    IF (_p.freightaccntid <> -1) THEN
81205
 
      _roundedBase = round(currToBase(_p.invchead_curr_id, _p.invchead_freight,
81206
 
                                      _firstExchDate), 2);
81207
 
      SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber,
81208
 
                                 getPrjAccntId(_p.invchead_prj_id,_p.freightaccntid), 
81209
 
                                 (_roundedBase * -1.0),
81210
 
                                 _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test;
81211
 
 
81212
 
        _totalAmount := (_totalAmount + _p.invchead_freight);
81213
 
        _totalRoundedBase := _totalRoundedBase + _roundedBase;
81214
 
    ELSE
81215
 
      _test := -14;
81216
 
    END IF;
81217
 
 
81218
 
    IF (_test < 0) THEN
81219
 
      PERFORM deleteGLSeries(_glSequence);
81220
 
      RETURN _test;
81221
 
    END IF;
81222
 
 
81223
 
  END IF;
81224
 
 
81225
 
  IF (_p.invchead_misc_amount <> 0) THEN
81226
 
    _roundedBase := round(currToBase(_p.invchead_curr_id, _p.invchead_misc_amount,
81227
 
                                     _firstExchDate), 2);
81228
 
    SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber,
81229
 
                               getPrjAccntId(_p.invchead_prj_id, _p.invchead_misc_accnt_id), 
81230
 
                               (_roundedBase * -1.0),
81231
 
                               _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test;
81232
 
 
81233
 
    IF (_test < 0) THEN
81234
 
      PERFORM deleteGLSeries(_glSequence);
81235
 
      RETURN _test;
81236
 
    END IF;
81237
 
 
81238
 
    _totalAmount := (_totalAmount + _p.invchead_misc_amount);
81239
 
    _totalRoundedBase := _totalRoundedBase + _roundedBase;
81240
 
 
81241
 
  END IF;
81242
 
 
81243
 
    _exchGain := currGain(_p.invchead_curr_id, _totalAmount,
81244
 
                          _firstExchDate, _glDate);
81245
 
    IF (_exchGain <> 0) THEN
81246
 
        SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber,
81247
 
                                   getGainLossAccntId(_p.araccntid),
81248
 
                                   round(_exchGain, 2),
81249
 
                                   _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test ;
81250
 
        IF (_test < 0) THEN
81251
 
          PERFORM deleteGLSeries(_glSequence);
81252
 
          RETURN _test;
81253
 
        END IF;
81254
 
    END IF;
81255
 
 
81256
 
  IF (_totalRoundedBase <> 0) THEN
81257
 
    IF (_p.araccntid != -1) THEN
81258
 
      SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber,
81259
 
                                 _p.araccntid,
81260
 
                                 round(_totalRoundedBase, 2),
81261
 
                                 _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test;
81262
 
    ELSE
81263
 
      PERFORM deleteGLSeries(_glSequence);
81264
 
      RETURN _test;
81265
 
    END IF;
81266
 
  END IF;
81267
 
 
81268
 
  SELECT postGLSeries(_glSequence, _glJournal) INTO _test;
81269
 
  IF (_test < 0) THEN
81270
 
    PERFORM deleteGLSeries(_glSequence);
81271
 
    RETURN _test;
81272
 
  END IF;
81273
 
 
81274
 
  DELETE FROM cohisttax
81275
 
  WHERE (taxhist_parent_id IN (SELECT cohist_id
81276
 
                               FROM cohist
81277
 
                               WHERE (cohist_doctype='I' AND cohist_invcnumber=_p.invchead_invcnumber)));
81278
 
 
81279
 
  DELETE FROM cohist
81280
 
  WHERE (cohist_doctype='I' AND cohist_invcnumber=_p.invchead_invcnumber);
81281
 
 
81282
 
  SELECT nextval('aropen_aropen_id_seq') INTO _aropenid;
81283
 
  INSERT INTO aropen
81284
 
  ( aropen_id, aropen_username, aropen_journalnumber,
81285
 
    aropen_open, aropen_posted,
81286
 
    aropen_cust_id, aropen_ponumber,
81287
 
    aropen_docnumber, aropen_applyto, aropen_doctype,
81288
 
    aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id,
81289
 
    aropen_amount, aropen_paid,
81290
 
    aropen_salesrep_id, aropen_commission_due, aropen_commission_paid,
81291
 
    aropen_ordernumber, aropen_notes, aropen_cobmisc_id,
81292
 
    aropen_curr_id )
81293
 
  VALUES
81294
 
  ( _aropenid, getEffectiveXtUser(), _glJournal,
81295
 
    TRUE, FALSE,
81296
 
    _p.invchead_cust_id, _p.invchead_ponumber,
81297
 
    _p.invchead_invcnumber, _p.invchead_invcnumber, 'C',
81298
 
    _p.invchead_invcdate, determineDueDate(_p.invchead_terms_id, _p.invchead_invcdate), _glDate, _p.invchead_terms_id,
81299
 
    round(_totalAmount, 2), round(_totalAmount, 2), 
81300
 
    _p.invchead_salesrep_id, _commissionDue, FALSE,
81301
 
    _p.invchead_ordernumber::text, _p.invchead_notes, pInvcheadid,
81302
 
    _p.invchead_curr_id );
81303
 
 
81304
 
    UPDATE aropen
81305
 
    SET aropen_paid = round(_totalAmount, 2)
81306
 
    WHERE (aropen_id=_p.aropen_id);
81307
 
 
81308
 
    INSERT INTO arapply
81309
 
    ( arapply_cust_id,
81310
 
      arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber,
81311
 
      arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber,
81312
 
      arapply_fundstype, arapply_refnumber,
81313
 
      arapply_applied, arapply_closed,
81314
 
      arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_curr_id )
81315
 
    VALUES
81316
 
    ( _p.invchead_cust_id,
81317
 
      _aropenid, 'C', _p.invchead_invcnumber,
81318
 
      _p.aropen_id, 'I', _p.invchead_invcnumber,
81319
 
      '', '',
81320
 
      round(_totalAmount, 2), TRUE,
81321
 
      CURRENT_DATE, _p.invchead_invcdate, 0, _p.invchead_curr_id );
81322
 
 
81323
 
  FOR _r IN SELECT itemsite_id AS itemsite_id, invcitem_id,
81324
 
                   (invcitem_billed * invcitem_qty_invuomratio) AS qty,
81325
 
                   invchead_invcnumber, invchead_cust_id AS cust_id, item_number,
81326
 
                   invchead_prj_id AS prj_id, invchead_saletype_id AS saletype_id,
81327
 
                   invchead_shipzone_id AS shipzone_id
81328
 
            FROM invchead JOIN invcitem ON ( (invcitem_invchead_id=invchead_id) AND
81329
 
                                             (invcitem_billed <> 0) AND
81330
 
                                             (invcitem_updateinv) )
81331
 
                          JOIN itemsite ON ( (itemsite_item_id=invcitem_item_id) AND
81332
 
                                             (itemsite_warehous_id=invcitem_warehous_id) )
81333
 
                          JOIN item ON (item_id=invcitem_item_id)
81334
 
            WHERE (invchead_id=_p.invchead_id) LOOP
81335
 
 
81336
 
    IF (_itemlocSeries = 0) THEN
81337
 
      SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries;
81338
 
    END IF;
81339
 
    SELECT postInvTrans( itemsite_id, 'SH', (_r.qty * -1.0),
81340
 
                         'S/O', 'IN', _r.invchead_invcnumber, '',
81341
 
                         ('Invoice Voided ' || _r.item_number),
81342
 
                         getPrjAccntId(_r.prj_id, resolveCOSAccount(itemsite_id, _r.cust_id, _r.saletype_id, _r.shipzone_id)),
81343
 
                         costcat_asset_accnt_id, _itemlocSeries, _glDate,
81344
 
                         (_p.cohist_unitcost * _r.qty)) INTO _invhistid
81345
 
    FROM itemsite JOIN costcat ON (itemsite_costcat_id=costcat_id)
81346
 
    WHERE (itemsite_id=_r.itemsite_id);
81347
 
 
81348
 
  END LOOP;
81349
 
 
81350
 
  UPDATE shipitem
81351
 
  SET shipitem_invoiced=FALSE,
81352
 
      shipitem_invcitem_id=NULL
81353
 
  WHERE (shipitem_invcitem_id IN (SELECT invcitem_id
81354
 
                                  FROM invcitem
81355
 
                                  WHERE (invcitem_invchead_id=_p.invchead_id)));
81356
 
  UPDATE cobill
81357
 
  SET cobill_invcnum=NULL,
81358
 
      cobill_invcitem_id=NULL
81359
 
  WHERE (cobill_invcitem_id IN (SELECT invcitem_id
81360
 
                                FROM invcitem
81361
 
                                WHERE (invcitem_invchead_id=_p.invchead_id)));
81362
 
  UPDATE cobmisc
81363
 
  SET cobmisc_posted=FALSE,
81364
 
      cobmisc_invcnumber=NULL,
81365
 
      cobmisc_invchead_id=NULL
81366
 
  WHERE (cobmisc_invchead_id=_p.invchead_id);
81367
 
 
81368
 
  UPDATE invchead
81369
 
  SET invchead_void=TRUE,
81370
 
      invchead_notes=(invchead_notes || 'Voided on ' || current_date || ' by ' || getEffectiveXtUser())
81371
 
  WHERE (invchead_id=_p.invchead_id);
81372
 
 
81373
 
  RETURN _itemlocSeries;
81374
 
 
81375
 
END;
81376
 
$_$;
81377
 
 
81378
 
 
81379
 
ALTER FUNCTION public.voidinvoice(integer) OWNER TO admin;
81380
 
 
81381
 
--
81382
 
--
81383
 
 
81384
 
CREATE FUNCTION voidpostedapcheck(integer) RETURNS integer
81385
 
    LANGUAGE plpgsql
81386
 
    AS $_$
81387
 
BEGIN
81388
 
  RAISE NOTICE 'voidPostedAPCheck() is deprecated - use voidPostedCheck() instead';
81389
 
  RETURN voidPostedCheck($1, fetchJournalNumber('AP-CK'), CURRENT_DATE);
81390
 
END;
81391
 
$_$;
81392
 
 
81393
 
 
81394
 
ALTER FUNCTION public.voidpostedapcheck(integer) OWNER TO admin;
81395
 
 
81396
 
--
81397
 
--
81398
 
 
81399
 
CREATE FUNCTION voidpostedapcheck(integer, integer) RETURNS integer
81400
 
    LANGUAGE plpgsql
81401
 
    AS $_$
81402
 
BEGIN
81403
 
  RAISE NOTICE 'voidPostedAPCheck() is deprecated - use voidPostedCheck() instead';
81404
 
  RETURN voidPostedCheck($1, $2, CURRENT_DATE);
81405
 
END;
81406
 
$_$;
81407
 
 
81408
 
 
81409
 
ALTER FUNCTION public.voidpostedapcheck(integer, integer) OWNER TO admin;
81410
 
 
81411
 
--
81412
 
--
81413
 
 
81414
 
CREATE FUNCTION voidpostedapcheck(integer, integer, date) RETURNS integer
81415
 
    LANGUAGE plpgsql
81416
 
    AS $_$
81417
 
BEGIN
81418
 
  RAISE NOTICE 'voidPostedAPCheck() is deprecated - use voidPostedCheck() instead';
81419
 
  RETURN voidPostedCheck($1, $2, $3);
81420
 
END;
81421
 
$_$;
81422
 
 
81423
 
 
81424
 
ALTER FUNCTION public.voidpostedapcheck(integer, integer, date) OWNER TO admin;
81425
 
 
81426
 
--
81427
 
--
81428
 
 
81429
 
CREATE FUNCTION voidpostedcheck(integer, integer, date) RETURNS integer
81430
 
    LANGUAGE plpgsql
81431
 
    AS $_$
81432
 
DECLARE
81433
 
  pCheckid              ALIAS FOR $1;
81434
 
  pJournalNumber        ALIAS FOR $2;
81435
 
  pVoidDate             ALIAS FOR $3;
81436
 
  _amount_base          NUMERIC := 0;
81437
 
  _result               INTEGER;
81438
 
  _apopenid             INTEGER;
81439
 
  _credit_glaccnt       INTEGER;
81440
 
  _docnumber            TEXT;
81441
 
  _exchGain             NUMERIC := 0;
81442
 
  _exchGainTmp          NUMERIC := 0;
81443
 
  _gltransNote          TEXT;
81444
 
  _p                    RECORD;
81445
 
  _r                    RECORD;
81446
 
  _sequence             INTEGER;
81447
 
  _amount_check         NUMERIC := 0;
81448
 
 
81449
 
BEGIN
81450
 
 
81451
 
  SELECT fetchGLSequence() INTO _sequence;
81452
 
 
81453
 
  SELECT checkhead.*,
81454
 
         checkhead_amount / checkhead_curr_rate AS checkhead_amount_base,
81455
 
         bankaccnt_accnt_id AS bankaccntid,
81456
 
         findPrepaidAccount(checkhead_recip_id) AS prepaidaccntid,
81457
 
         checkrecip.* INTO _p
81458
 
  FROM bankaccnt, checkhead LEFT OUTER JOIN
81459
 
       checkrecip ON ((checkrecip_type=checkhead_recip_type)
81460
 
                  AND (checkrecip_id=checkhead_recip_id))
81461
 
  WHERE ((checkhead_bankaccnt_id=bankaccnt_id)
81462
 
    AND  (checkhead_id=pCheckid));
81463
 
 
81464
 
  IF (NOT _p.checkhead_posted) THEN
81465
 
    RETURN -10;
81466
 
  END IF;
81467
 
 
81468
 
  IF (_p.checkrecip_id IS NULL) THEN    -- outer join failed
81469
 
    RETURN -11;
81470
 
  END IF;
81471
 
 
81472
 
  -- Cannot void if already reconciled
81473
 
  SELECT trans_id INTO _result
81474
 
  FROM ( SELECT gltrans_id AS trans_id
81475
 
         FROM gltrans
81476
 
              LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='GL' AND bankrecitem_source_id=gltrans_id)
81477
 
         WHERE ( (gltrans_doctype='CK')
81478
 
           AND   (gltrans_misc_id=_p.checkhead_id)
81479
 
           AND   ((gltrans_rec) OR (bankrecitem_id IS NOT NULL)) )
81480
 
         UNION ALL
81481
 
         SELECT sltrans_id AS trans_id
81482
 
         FROM sltrans
81483
 
              LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='GL' AND bankrecitem_source_id=sltrans_id)
81484
 
         WHERE ( (sltrans_doctype='CK')
81485
 
           AND   (sltrans_misc_id=_p.checkhead_id)
81486
 
           AND   ((sltrans_rec) OR (bankrecitem_id IS NOT NULL)) )
81487
 
       ) AS data;
81488
 
  IF (FOUND) THEN
81489
 
    RETURN -14;
81490
 
  END IF;
81491
 
 
81492
 
  _gltransNote := 'Void Posted Check #' || _p.checkhead_number || ' ' ||
81493
 
                  _p.checkrecip_number || '-' || _p.checkrecip_name;
81494
 
 
81495
 
  IF (_p.checkhead_misc) THEN
81496
 
    IF (COALESCE(_p.checkhead_expcat_id, -1) < 0) THEN
81497
 
      IF (_p.checkhead_recip_type = 'V') THEN
81498
 
        PERFORM createAPDebitMemo(_p.checkhead_recip_id, pJournalNumber,
81499
 
                                  CAST(fetchAPMemoNumber() AS text), '',
81500
 
                                  pVoidDate, _p.checkhead_amount,
81501
 
                                  _gltransNote || ' '|| _p.checkhead_notes,
81502
 
                                  -1, pVoidDate, -1, _p.checkhead_curr_id );
81503
 
        _credit_glaccnt := findAPPrepaidAccount(_p.checkhead_recip_id);
81504
 
 
81505
 
      ELSIF (_p.checkhead_recip_type = 'C') THEN
81506
 
        PERFORM createARCreditMemo(NULL, _p.checkhead_recip_id,
81507
 
                                  fetchARMemoNumber(), '', 
81508
 
                                  pVoidDate, _p.checkhead_amount,
81509
 
                                  _gltransNote || ' '|| _p.checkhead_notes,
81510
 
                                  -1, -1, -1, pVoidDate, -1, NULL, 0.0,
81511
 
                                  pJournalNumber, _p.checkhead_curr_id );
81512
 
        _credit_glaccnt := _p.prepaidaccntid;
81513
 
 
81514
 
      ELSIF (_p.checkhead_recip_type = 'T') THEN
81515
 
        -- TODO: should we create a debit memo for the tax authority? how?
81516
 
        _credit_glaccnt := _p.checkrecip_accnt_id;
81517
 
 
81518
 
      END IF; -- recip type
81519
 
 
81520
 
    ELSE
81521
 
      SELECT expcat_exp_accnt_id INTO _credit_glaccnt
81522
 
      FROM expcat
81523
 
      WHERE (expcat_id=_p.checkhead_expcat_id);
81524
 
      IF (NOT FOUND) THEN
81525
 
        RETURN -12;
81526
 
      END IF;
81527
 
    END IF;
81528
 
 
81529
 
    IF (COALESCE(_credit_glaccnt, -1) < 0) THEN
81530
 
      RETURN -13;
81531
 
    END IF;
81532
 
 
81533
 
    PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'CK',
81534
 
                                text(_p.checkhead_number),
81535
 
                                _credit_glaccnt,
81536
 
                                round(_p.checkhead_amount_base, 2),
81537
 
                                pVoidDate, _gltransNote, pCheckid);
81538
 
 
81539
 
    _amount_base := _p.checkhead_amount_base;
81540
 
 
81541
 
  ELSE
81542
 
    FOR _r IN SELECT checkitem_amount, checkitem_discount,
81543
 
                     CASE WHEN (checkitem_apopen_id IS NOT NULL AND apopen_doctype='C') THEN
81544
 
                            checkitem_amount / apopen_curr_rate * -1.0
81545
 
                          WHEN (checkitem_apopen_id IS NOT NULL) THEN
81546
 
                            checkitem_amount / apopen_curr_rate
81547
 
                          ELSE
81548
 
                            currToBase(checkitem_curr_id,
81549
 
                                       checkitem_amount,
81550
 
                                       COALESCE(checkitem_docdate, _p.checkhead_checkdate)) 
81551
 
                     END AS checkitem_amount_base,
81552
 
                     currTocurr(checkitem_curr_id, _p.checkhead_curr_id,
81553
 
                                CASE WHEN (checkitem_apopen_id IS NOT NULL AND apopen_doctype='C') THEN
81554
 
                                          checkitem_amount * -1.0
81555
 
                                     ELSE checkitem_amount END,
81556
 
                                  _p.checkhead_checkdate) AS amount_check,
81557
 
                     apopen_id, apopen_doctype, apopen_docnumber, apopen_curr_rate, apopen_docdate,
81558
 
                     aropen_id, aropen_doctype, aropen_docnumber,
81559
 
                     checkitem_curr_id, checkitem_curr_rate,
81560
 
                     COALESCE(checkitem_docdate, _p.checkhead_checkdate) AS docdate
81561
 
              FROM (checkitem LEFT OUTER JOIN
81562
 
                    apopen ON (checkitem_apopen_id=apopen_id)) LEFT OUTER JOIN
81563
 
                    aropen ON (checkitem_aropen_id=aropen_id)
81564
 
              WHERE (checkitem_checkhead_id=pcheckid) LOOP
81565
 
 
81566
 
      _exchGainTmp := 0;
81567
 
      IF (_r.apopen_id IS NOT NULL) THEN
81568
 
        -- undo the APDiscount Credit Memo if a discount was taken
81569
 
        IF(_r.checkitem_discount > 0) THEN
81570
 
          SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid;
81571
 
          SELECT fetchAPMemoNumber() INTO _docnumber;
81572
 
          INSERT INTO apopen
81573
 
          ( apopen_id, apopen_username, apopen_journalnumber,
81574
 
            apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber,
81575
 
            apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id,
81576
 
            apopen_amount, apopen_paid, apopen_open,
81577
 
            apopen_notes,
81578
 
            apopen_accnt_id, apopen_curr_id, apopen_discount, apopen_curr_rate,
81579
 
            apopen_closedate )
81580
 
          VALUES
81581
 
          ( _apopenid, getEffectiveXtUser(), pJournalNumber,
81582
 
            _p.checkhead_recip_id, _docnumber, 'D', '',
81583
 
            pVoidDate, pVoidDate, pVoidDate, -1,
81584
 
            _r.checkitem_discount, _r.checkitem_discount, FALSE,
81585
 
            ('Reverse Posted Discount ' || _r.apopen_doctype || ' ' ||
81586
 
              _r.apopen_docnumber),
81587
 
            -1, _p.checkhead_curr_id, TRUE, _r.apopen_curr_rate,
81588
 
            current_date );
81589
 
 
81590
 
 
81591
 
          PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source,
81592
 
                                      'DS', _r.apopen_docnumber,
81593
 
                                      findAPDiscountAccount(_p.checkhead_recip_id),
81594
 
                                      round(_r.checkitem_discount / _r.apopen_curr_rate, 2) * -1,
81595
 
                                      pVoidDate, _gltransNote, pCheckid);
81596
 
 
81597
 
          PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source,
81598
 
                                      'DS', _r.apopen_docnumber,
81599
 
                                      findAPAccount(_p.checkhead_recip_id),
81600
 
                                      round(_r.checkitem_discount / _r.apopen_curr_rate, 2),
81601
 
                                      pVoidDate, _gltransNote, pCheckid);
81602
 
 
81603
 
          --  Post the application
81604
 
          INSERT INTO apapply
81605
 
          ( apapply_vend_id, apapply_postdate, apapply_username,
81606
 
            apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber,
81607
 
            apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber,
81608
 
            apapply_journalnumber, apapply_amount, apapply_curr_id )
81609
 
          VALUES
81610
 
          ( _p.checkhead_recip_id, pVoidDate, getEffectiveXtUser(),
81611
 
            _apopenid, 'D', _docnumber,
81612
 
            _r.apopen_id, _r.apopen_doctype, _r.apopen_docnumber,
81613
 
            pJournalNumber, (_r.checkitem_discount * -1), _r.checkitem_curr_id );
81614
 
        END IF; -- discount was taken
81615
 
 
81616
 
        UPDATE apopen
81617
 
       SET apopen_paid = round(apopen_paid -
81618
 
                                (_r.checkitem_amount + noNeg(_r.checkitem_discount)), 2),
81619
 
            apopen_open = round(apopen_amount, 2) >
81620
 
                          round(apopen_paid -
81621
 
                                (_r.checkitem_amount + noNeg(_r.checkitem_discount)), 2),
81622
 
            apopen_closedate = CASE WHEN (round(apopen_amount, 2) >
81623
 
                                          round(apopen_paid -
81624
 
                                           (_r.checkitem_amount + noNeg(_r.checkitem_discount)))) THEN NULL ELSE apopen_closedate END
81625
 
        WHERE (apopen_id=_r.apopen_id);
81626
 
 
81627
 
        --  Post the application
81628
 
        INSERT INTO apapply
81629
 
        ( apapply_vend_id, apapply_postdate, apapply_username,
81630
 
          apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber,
81631
 
          apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber,
81632
 
          apapply_journalnumber, apapply_amount, apapply_curr_id )
81633
 
        VALUES
81634
 
        ( _p.checkhead_recip_id, pVoidDate, getEffectiveXtUser(),
81635
 
          -1, 'K', _p.checkhead_number,
81636
 
          _r.apopen_id, _r.apopen_doctype, _r.apopen_docnumber,
81637
 
          pJournalNumber, (_r.checkitem_amount * -1), _r.checkitem_curr_id );
81638
 
      END IF; -- if check item's apopen_id is not null
81639
 
 
81640
 
      IF (_r.aropen_id IS NOT NULL) THEN
81641
 
        UPDATE aropen
81642
 
        SET aropen_paid = round(aropen_paid -_r.checkitem_amount, 2),
81643
 
            aropen_open = round(aropen_amount, 2) >
81644
 
                          round(aropen_paid - _r.checkitem_amount, 2)
81645
 
        WHERE (aropen_id=_r.aropen_id);
81646
 
 
81647
 
        --  Post the application
81648
 
        INSERT INTO arapply
81649
 
        ( arapply_cust_id, arapply_postdate, arapply_distdate, arapply_username,
81650
 
          arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber,
81651
 
          arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber,
81652
 
          arapply_journalnumber, arapply_applied, arapply_curr_id )
81653
 
        VALUES
81654
 
        ( _p.checkhead_recip_id, pVoidDate, pVoidDate, getEffectiveXtUser(),
81655
 
          -1, 'K', _p.checkhead_number,
81656
 
          _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber,
81657
 
          pJournalNumber, (_r.checkitem_amount * -1), _r.checkitem_curr_id );
81658
 
 
81659
 
      END IF; -- if check item's aropen_id is not null
81660
 
 
81661
 
      IF (_r.apopen_id IS NOT NULL) THEN
81662
 
        IF (_p.checkhead_curr_id = _r.checkitem_curr_id) THEN
81663
 
          IF (_r.apopen_docdate > _p.checkhead_checkdate) THEN
81664
 
            _exchGainTmp := ((_r.checkitem_amount/_p.checkhead_curr_rate) - (_r.checkitem_amount / _r.apopen_curr_rate)) * -1;
81665
 
          ELSE
81666
 
            _exchGainTmp := ((_r.checkitem_amount / _r.apopen_curr_rate) - (_r.checkitem_amount/_p.checkhead_curr_rate));
81667
 
          END IF;
81668
 
        ELSE
81669
 
          -- unusual condition where bank overridden and different currency from voucher
81670
 
          -- this does not work for all situations
81671
 
          --IF (_r.apopen_docdate > _p.checkhead_checkdate) THEN
81672
 
          --  _exchGainTmp := ((_r.checkitem_amount/_r.checkitem_curr_rate) - (_r.checkitem_amount / _r.apopen_curr_rate)) * -1;
81673
 
          --ELSE
81674
 
          --  _exchGainTmp := ((_r.checkitem_amount / _r.apopen_curr_rate) - (_r.checkitem_amount/_r.checkitem_curr_rate));
81675
 
          --END IF;
81676
 
          _exchGainTmp := 0.0;
81677
 
        END IF;
81678
 
      ELSE
81679
 
        SELECT arCurrGain(_r.aropen_id,_r.checkitem_curr_id, _r.checkitem_amount,
81680
 
                        _p.checkhead_checkdate)
81681
 
              INTO _exchGainTmp;
81682
 
      END IF;
81683
 
      _exchGain := _exchGain + _exchGainTmp;
81684
 
 
81685
 
      PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source,
81686
 
                                  'CK', text(_p.checkhead_number),
81687
 
                                  _p.checkrecip_accnt_id,
81688
 
                                  round(_r.checkitem_amount_base, 2),
81689
 
                                  pVoidDate, _gltransNote, pCheckid);
81690
 
      IF (_exchGainTmp <> 0) THEN
81691
 
          PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source,
81692
 
                                      'CK', text(_p.checkhead_number),
81693
 
                                      getGainLossAccntId(_p.checkrecip_accnt_id),
81694
 
                                      round(_exchGainTmp, 2) * -1,
81695
 
                                      pVoidDate, _gltransNote, pCheckid);
81696
 
      END IF;
81697
 
 
81698
 
      _amount_check := (_amount_check + _r.amount_check);
81699
 
      _amount_base := (_amount_base + _r.checkitem_amount_base);
81700
 
 
81701
 
    END LOOP;
81702
 
 
81703
 
    IF( (_amount_check - _p.checkhead_amount) <> 0.0 ) THEN 
81704
 
      _exchGainTmp :=  (_amount_check - _p.checkhead_amount) / _p.checkhead_curr_rate;
81705
 
      _exchGain := _exchGain + _exchGainTmp;
81706
 
    END IF;
81707
 
 
81708
 
    --  ensure that the check balances, attribute rounding errors to gain/loss
81709
 
    IF round(_amount_base, 2) - round(_exchGain, 2) <> round(_p.checkhead_amount_base, 2) THEN
81710
 
      IF round(_amount_base - _exchGain, 2) = round(_p.checkhead_amount_base, 2) THEN
81711
 
        PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source,
81712
 
                                    'CK',
81713
 
                                    text(_p.checkhead_number), getGainLossAccntId(_p.bankaccntid),
81714
 
                                    (round(_amount_base, 2) -
81715
 
                                     round(_exchGain, 2) -
81716
 
                                     round(_p.checkhead_amount_base, 2)) * -1,
81717
 
                                    pVoidDate, _gltransNote, pCheckid);
81718
 
      ELSE
81719
 
        RAISE EXCEPTION 'checkhead_id % does not balance (% - % <> %)', pCheckid,
81720
 
              _amount_base, _exchGain, _p.checkhead_amount_base;
81721
 
      END IF;
81722
 
    END IF;
81723
 
  END IF;
81724
 
 
81725
 
  PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'CK',
81726
 
                              text(_p.checkhead_number),
81727
 
                              _p.bankaccntid,
81728
 
                              round(_p.checkhead_amount_base, 2) * -1,
81729
 
                              pVoidDate, _gltransNote, pCheckid);
81730
 
 
81731
 
  PERFORM postGLSeries(_sequence, pJournalNumber);
81732
 
 
81733
 
  UPDATE gltrans
81734
 
     SET gltrans_misc_id=pCheckid
81735
 
   WHERE gltrans_sequence=_sequence;
81736
 
 
81737
 
  UPDATE checkhead
81738
 
  SET checkhead_posted=false,
81739
 
      checkhead_void=true,
81740
 
      checkhead_journalnumber=pJournalNumber
81741
 
  WHERE (checkhead_id=pCheckid);
81742
 
 
81743
 
  RETURN pJournalNumber;
81744
 
 
81745
 
END;
81746
 
$_$;
81747
 
 
81748
 
 
81749
 
ALTER FUNCTION public.voidpostedcheck(integer, integer, date) OWNER TO admin;
81750
 
 
81751
 
--
81752
 
--
81753
 
 
81754
 
CREATE FUNCTION woeffectivedate(date) RETURNS date
81755
 
    LANGUAGE plpgsql
81756
 
    AS $_$
81757
 
DECLARE
81758
 
  pStartDate ALIAS FOR $1;
81759
 
 
81760
 
BEGIN
81761
 
 
81762
 
  IF (explodeWoEffective() = 'E') THEN
81763
 
    RETURN CURRENT_DATE;
81764
 
  ELSE
81765
 
    RETURN pStartDate;
81766
 
  END IF;
81767
 
 
81768
 
END;
81769
 
$_$;
81770
 
 
81771
 
 
81772
 
ALTER FUNCTION public.woeffectivedate(date) OWNER TO admin;
81773
 
 
81774
 
--
81775
 
--
81776
 
 
81777
 
CREATE FUNCTION woinvavail(integer, integer, boolean, boolean) RETURNS SETOF woinvav
81778
 
    LANGUAGE plpgsql
81779
 
    AS $_$
81780
 
DECLARE
81781
 
   pwoid ALIAS FOR $1; 
81782
 
   plevel ALIAS FOR $2;
81783
 
   pshowshortage ALIAS FOR $3;
81784
 
   pshowlowinventory ALIAS FOR $4;
81785
 
  _row woinvav%ROWTYPE;
81786
 
  _x RECORD;
81787
 
  _subx RECORD;
81788
 
  _index INTEGER;
81789
 
  _level INTEGER;
81790
 
  _qry TEXT;   
81791
 
BEGIN   
81792
 
    FOR _x IN
81793
 
          SELECT wo_id,
81794
 
                itemsite_id,
81795
 
                item_type,
81796
 
                wo_number,
81797
 
                wo_subnumber,                             
81798
 
                item_number,
81799
 
                item_descrip1, 
81800
 
                item_descrip2, 
81801
 
                uom_name,
81802
 
                qoh, 
81803
 
                wobalance, 
81804
 
                allocated, 
81805
 
                ordered,                        
81806
 
                reorderlevel,
81807
 
                (qoh + ordered - wobalance) AS woavail,
81808
 
                (qoh + ordered - allocated) AS totalavail 
81809
 
         FROM(SELECT wo_id,
81810
 
                itemsite_id,
81811
 
                item_type,
81812
 
                wo_number,
81813
 
                wo_subnumber,                             
81814
 
                item_number,
81815
 
                item_descrip1, 
81816
 
                item_descrip2, 
81817
 
                uom_name,
81818
 
                noNeg(qtyAvailable(itemsite_id)) AS qoh, 
81819
 
                noNeg(wo_qtyord - wo_qtyrcv) AS wobalance, 
81820
 
                qtyAllocated(itemsite_id, wo_duedate) AS allocated, 
81821
 
                qtyOrdered(itemsite_id, wo_duedate) AS ordered,                        
81822
 
                CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel 
81823
 
          FROM wo, itemsite, item, uom     
81824
 
         WHERE ((wo_ordid = pwoid AND wo_ordtype = 'W')
81825
 
           AND NOT (wo_status = 'C')          
81826
 
           AND (itemsite_id = wo_itemsite_id)
81827
 
           AND (itemsite_item_id=item_id)
81828
 
           AND (item_inv_uom_id=uom_id))               
81829
 
         ORDER BY wo_number, wo_subnumber) AS data
81830
 
       LOOP       
81831
 
         _row.woinvav_itemsite_id := _x.itemsite_id;            
81832
 
         _row.woinvav_womatl_id := -1;
81833
 
         _row.woinvav_type := _x.item_type;          
81834
 
         _row.woinvav_item_wo_number := _x.wo_number || '-' || _x.wo_subnumber;
81835
 
         _row.woinvav_descrip := _x.item_descrip1 || ' ' || _x.item_descrip2;
81836
 
         _row.woinvav_uomname := _x.uom_name;
81837
 
         _row.woinvav_qoh := _x.qoh;
81838
 
         _row.woinvav_balance := _x.wobalance;
81839
 
         _row.woinvav_allocated := _x.allocated;     
81840
 
         _row.woinvav_ordered := _x.ordered;         
81841
 
         _row.woinvav_woavail := _x.woavail;
81842
 
         _row.woinvav_totalavail := _x.totalavail;
81843
 
         _row.woinvav_reorderlevel := _x.reorderlevel;               
81844
 
         _row.woinvav_level := plevel;                       
81845
 
         RETURN NEXT _row;         
81846
 
        --get materials for this level
81847
 
        FOR _subx IN
81848
 
          SELECT * FROM woinvavailmatl(_x.wo_id, plevel + 1, pshowshortage, pshowlowinventory) 
81849
 
        LOOP                                            
81850
 
          RETURN NEXT _subx;
81851
 
        END LOOP;
81852
 
        --get next level wo
81853
 
        FOR _subx IN
81854
 
          SELECT * FROM woinvavail(_x.wo_id, plevel + 1, pshowshortage, pshowlowinventory) 
81855
 
        LOOP                                            
81856
 
          RETURN NEXT _subx;
81857
 
        END LOOP;
81858
 
      END LOOP;   
81859
 
  RETURN;
81860
 
END;
81861
 
$_$;
81862
 
 
81863
 
 
81864
 
ALTER FUNCTION public.woinvavail(integer, integer, boolean, boolean) OWNER TO admin;
81865
 
 
81866
 
--
81867
 
--
81868
 
 
81869
 
CREATE FUNCTION woinvavail(integer, boolean, boolean, boolean, boolean) RETURNS SETOF woinvav
81870
 
    LANGUAGE plpgsql
81871
 
    AS $_$
81872
 
DECLARE
81873
 
   pwoid ALIAS FOR $1;   
81874
 
   pshowchildindent ALIAS FOR $2;    
81875
 
   pshowchildsum ALIAS FOR $3;
81876
 
   pshowshortage ALIAS FOR $4;
81877
 
   pshowlowinventory ALIAS FOR $5;
81878
 
  _row woinvav%ROWTYPE;
81879
 
  _subrow woinvav%ROWTYPE;
81880
 
  _wonumber TEXT;
81881
 
  _x RECORD;
81882
 
  _subx RECORD;  
81883
 
  _qry TEXT;
81884
 
   
81885
 
BEGIN   
81886
 
    
81887
 
    IF(pshowchildindent) THEN 
81888
 
      --get top level order   
81889
 
      FOR _x IN
81890
 
          SELECT wo_id,
81891
 
                itemsite_id,
81892
 
                item_type,
81893
 
                wo_number,
81894
 
                wo_subnumber,                             
81895
 
                item_number,
81896
 
                item_descrip1, 
81897
 
                item_descrip2, 
81898
 
                uom_name,
81899
 
                qoh, 
81900
 
                wobalance, 
81901
 
                allocated, 
81902
 
                ordered,                        
81903
 
                reorderlevel,
81904
 
                (qoh + ordered - wobalance) AS woavail,
81905
 
                (qoh + ordered - allocated) AS totalavail 
81906
 
         FROM(SELECT wo_id,
81907
 
                itemsite_id,
81908
 
                item_type,
81909
 
                wo_number,
81910
 
                wo_subnumber,                             
81911
 
                item_number,
81912
 
                item_descrip1, 
81913
 
                item_descrip2, 
81914
 
                uom_name,
81915
 
                noNeg(qtyAvailable(itemsite_id)) AS qoh, 
81916
 
                noNeg(wo_qtyord - wo_qtyrcv) AS wobalance, 
81917
 
                qtyAllocated(itemsite_id, wo_duedate) AS allocated, 
81918
 
                qtyOrdered(itemsite_id, wo_duedate) AS ordered,                        
81919
 
                CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel 
81920
 
          FROM wo, itemsite, item, uom     
81921
 
         WHERE ((wo_id = pwoid)          
81922
 
           AND (itemsite_id = wo_itemsite_id)
81923
 
           AND (itemsite_item_id=item_id)
81924
 
           AND (item_inv_uom_id=uom_id))               
81925
 
         ORDER BY wo_number, wo_subnumber) AS data
81926
 
       LOOP       
81927
 
         _row.woinvav_itemsite_id := _x.itemsite_id;            
81928
 
         _row.woinvav_womatl_id := -1;
81929
 
         _row.woinvav_type := _x.item_type;          
81930
 
         _row.woinvav_item_wo_number := _x.wo_number || '-' || _x.wo_subnumber;
81931
 
         _row.woinvav_descrip := _x.item_descrip1 || ' ' || _x.item_descrip2;
81932
 
         _row.woinvav_uomname := _x.uom_name;
81933
 
         _row.woinvav_qoh := _x.qoh;
81934
 
         _row.woinvav_balance := _x.wobalance;
81935
 
         _row.woinvav_allocated := _x.allocated;     
81936
 
         _row.woinvav_ordered := _x.ordered;         
81937
 
         _row.woinvav_woavail := _x.woavail;
81938
 
         _row.woinvav_totalavail := _x.totalavail;
81939
 
         _row.woinvav_reorderlevel := _x.reorderlevel;
81940
 
         _row.woinvav_level := 0;                       
81941
 
         RETURN NEXT _row;                
81942
 
        --get materials for this level        
81943
 
        FOR _subx IN
81944
 
          SELECT * FROM woinvavailmatl(_x.wo_id, 1, pshowshortage, pshowlowinventory) 
81945
 
        LOOP                                            
81946
 
          RETURN NEXT _subx;
81947
 
        END LOOP;  
81948
 
        FOR _subx IN
81949
 
          SELECT * FROM woinvavail(_x.wo_id, 1, pshowshortage, pshowlowinventory)
81950
 
        LOOP                                            
81951
 
          RETURN NEXT _subx;
81952
 
        END LOOP;  
81953
 
     END LOOP;             
81954
 
    ELSE
81955
 
       SELECT wo_number FROM wo WHERE wo_id=pwoid LIMIT 1 INTO _wonumber;   
81956
 
       --display a single level sum of work order requirements
81957
 
       _qry := 'SELECT  wo_id,
81958
 
                        itemsite_id, 
81959
 
                        womatl_id,
81960
 
                        item_type,
81961
 
                        wo_number,                         
81962
 
                        item_number, 
81963
 
                        item_descrip1, 
81964
 
                        item_descrip2, 
81965
 
                        uom_name,                         
81966
 
                        qoh, 
81967
 
                        wobalance, 
81968
 
                        allocated, 
81969
 
                        ordered,                        
81970
 
                        reorderlevel,
81971
 
                        (qoh + ordered - wobalance) AS woavail,
81972
 
                        (qoh + ordered - allocated) AS totalavail
81973
 
                  FROM (SELECT wo_id,
81974
 
                        itemsite_id, 
81975
 
                        womatl_id,
81976
 
                        item_type,                      
81977
 
                        wo_number,                         
81978
 
                        item_number, 
81979
 
                        item_descrip1, 
81980
 
                        item_descrip2, 
81981
 
                        uom_name,                         
81982
 
                        noNeg(qtyAvailable(itemsite_id)) AS qoh, 
81983
 
                        noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq - womatl_qtyiss)) AS wobalance, 
81984
 
                        qtyAllocated(itemsite_id, womatl_duedate) AS allocated, 
81985
 
                        qtyOrdered(itemsite_id, womatl_duedate) AS ordered,                        
81986
 
                        CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel 
81987
 
                   FROM wo, womatl, itemsite, item, uom  
81988
 
                 WHERE (womatl_wo_id=wo_id) 
81989
 
                   AND (womatl_itemsite_id=itemsite_id) 
81990
 
                   AND (itemsite_item_id=item_id) 
81991
 
                   AND (item_inv_uom_id=uom_id) ';
81992
 
                IF(pshowchildsum) THEN
81993
 
                  _qry := _qry || ' AND (wo_number=' || _wonumber || ')';
81994
 
                ELSE  
81995
 
                  _qry := _qry || ' AND (womatl_wo_id=' || pwoid || ')';                  
81996
 
                END IF; 
81997
 
                 _qry := _qry || ' ORDER BY item_number) AS data ';  
81998
 
                IF(pshowshortage) THEN
81999
 
                  _qry := _qry || ' WHERE (((qoh + ordered - allocated) < 0) OR ((qoh + ordered - wobalance) < 0)) '; 
82000
 
                END IF;
82001
 
                IF(pshowlowinventory AND NOT pshowshortage) THEN                 
82002
 
                  _qry := _qry || ' WHERE (((qoh - allocated) < 0) OR ((qoh - wobalance) < 0)) '; 
82003
 
                END IF;                 
82004
 
                
82005
 
      FOR _x IN   
82006
 
         EXECUTE _qry
82007
 
      LOOP        
82008
 
        _row.woinvav_itemsite_id := _x.itemsite_id;            
82009
 
        _row.woinvav_womatl_id := _x.womatl_id;  
82010
 
        _row.woinvav_type := _x.item_type;      
82011
 
        _row.woinvav_item_wo_number := _x.item_number;
82012
 
        _row.woinvav_descrip := _x.item_descrip1 || ' ' || _x.item_descrip2;
82013
 
        _row.woinvav_uomname := _x.uom_name;
82014
 
        _row.woinvav_qoh := _x.qoh;
82015
 
        _row.woinvav_balance := _x.wobalance;
82016
 
        _row.woinvav_allocated := _x.allocated;     
82017
 
        _row.woinvav_ordered := _x.ordered;         
82018
 
        _row.woinvav_woavail := _x.woavail;
82019
 
        _row.woinvav_totalavail := _x.totalavail;
82020
 
        _row.woinvav_reorderlevel := _x.reorderlevel;
82021
 
        _row.woinvav_level := 0;                
82022
 
        RETURN NEXT _row;  
82023
 
  END LOOP;
82024
 
  END IF;                     
82025
 
  RETURN;
82026
 
END;
82027
 
$_$;
82028
 
 
82029
 
 
82030
 
ALTER FUNCTION public.woinvavail(integer, boolean, boolean, boolean, boolean) OWNER TO admin;
82031
 
 
82032
 
--
82033
 
--
82034
 
 
82035
 
CREATE FUNCTION woinvavailmatl(integer, integer, boolean, boolean) RETURNS SETOF woinvav
82036
 
    LANGUAGE plpgsql
82037
 
    AS $_$
82038
 
DECLARE
82039
 
   pwoid ALIAS FOR $1;    
82040
 
   plevel ALIAS FOR $2;
82041
 
   pshowshortage ALIAS FOR $3;
82042
 
   pshowlowinventory ALIAS FOR $4;
82043
 
  _subrow woinvav%ROWTYPE;  
82044
 
  _subx RECORD;
82045
 
  _qry TEXT;
82046
 
BEGIN
82047
 
  
82048
 
   _qry := 'SELECT itemsite_id, 
82049
 
           womatl_id,
82050
 
           item_type, 
82051
 
           wo_number, 
82052
 
           wo_subnumber, 
82053
 
           womatl_ref, 
82054
 
           womatl_notes, 
82055
 
           item_number,
82056
 
           item_descrip1, 
82057
 
           item_descrip2, 
82058
 
           uom_name,
82059
 
           qoh, 
82060
 
           wobalance, 
82061
 
           allocated, 
82062
 
           ordered,
82063
 
           (qoh + ordered - wobalance) AS woavail,
82064
 
           (qoh + ordered - allocated) AS totalavail,
82065
 
           reorderlevel 
82066
 
    FROM(SELECT itemsite_id, 
82067
 
                womatl_id,
82068
 
                item_type,                 
82069
 
                wo_number, 
82070
 
                wo_subnumber, 
82071
 
                womatl_ref, 
82072
 
                womatl_notes, 
82073
 
                item_number,
82074
 
                item_descrip1, 
82075
 
                item_descrip2, 
82076
 
                uom_name,
82077
 
                noNeg(qtyAvailable(itemsite_id)) AS qoh, 
82078
 
                noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq - womatl_qtyiss)) AS wobalance, 
82079
 
                qtyAllocated(itemsite_id, womatl_duedate) AS allocated, 
82080
 
                qtyOrdered(itemsite_id, womatl_duedate) AS ordered,
82081
 
                CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel
82082
 
    FROM womatl, wo, itemsite, item, uom
82083
 
    WHERE ((wo_id = womatl_wo_id)     
82084
 
     AND (womatl_itemsite_id = itemsite_id)
82085
 
     AND (itemsite_item_id=item_id)
82086
 
     AND (womatl_uom_id=uom_id)
82087
 
     AND (NOT womatl_createwo OR womatl_createwo IS NULL))';
82088
 
     _qry := _qry || ' AND (wo_id=' || pwoid || ') ORDER BY item_number) AS data';
82089
 
     IF(pshowshortage) THEN
82090
 
     _qry := _qry || ' WHERE (((qoh + ordered - allocated) < 0) OR ((qoh + ordered - wobalance) < 0)) '; 
82091
 
     END IF;
82092
 
     IF(pshowlowinventory AND NOT pshowshortage) THEN                 
82093
 
     _qry := _qry || ' WHERE (((qoh - allocated) < 0) OR ((qoh - wobalance) < 0)) '; 
82094
 
     END IF;
82095
 
        
82096
 
     
82097
 
     
82098
 
  FOR _subx IN
82099
 
      EXECUTE _qry
82100
 
  LOOP
82101
 
     _subrow.woinvav_itemsite_id := _subx.itemsite_id;            
82102
 
     _subrow.woinvav_womatl_id := _subx.womatl_id;
82103
 
     _subrow.woinvav_type := _subx.item_type;            
82104
 
     _subrow.woinvav_item_wo_number := _subx.item_number;
82105
 
     _subrow.woinvav_descrip := _subx.item_descrip1 || ' ' || _subx.item_descrip2;
82106
 
     _subrow.woinvav_uomname := _subx.uom_name;
82107
 
     _subrow.woinvav_qoh := _subx.qoh;
82108
 
     _subrow.woinvav_balance := _subx.wobalance;
82109
 
     _subrow.woinvav_allocated := _subx.allocated;     
82110
 
     _subrow.woinvav_ordered := _subx.ordered;         
82111
 
     _subrow.woinvav_woavail := _subx.woavail;
82112
 
     _subrow.woinvav_totalavail := _subx.totalavail;
82113
 
     _subrow.woinvav_reorderlevel := _subx.reorderlevel;
82114
 
     _subrow.woinvav_level := plevel;                                     
82115
 
    RETURN NEXT _subrow; 
82116
 
  END LOOP;            
82117
 
  RETURN;
82118
 
END;
82119
 
$_$;
82120
 
 
82121
 
 
82122
 
ALTER FUNCTION public.woinvavailmatl(integer, integer, boolean, boolean) OWNER TO admin;
82123
 
 
82124
 
--
82125
 
--
82126
 
 
82127
 
CREATE FUNCTION wostarted(pwoid integer) RETURNS boolean
82128
 
    LANGUAGE plpgsql
82129
 
    AS $$
82130
 
DECLARE
82131
 
  _result BOOLEAN := FALSE;
82132
 
   
82133
 
BEGIN   
82134
 
  -- is it really this simple?
82135
 
  SELECT (wo_wipvalue > 0) INTO _result
82136
 
    FROM wo
82137
 
   WHERE wo_id=pWoid;
82138
 
  
82139
 
  RETURN COALESCE(_result, FALSE);
82140
 
END;
82141
 
$$;
82142
 
 
82143
 
 
82144
 
ALTER FUNCTION public.wostarted(pwoid integer) OWNER TO admin;
82145
 
 
82146
 
SET search_path = te, pg_catalog;
82147
 
 
82148
 
--
82149
 
--
82150
 
 
82151
 
CREATE FUNCTION calcrate(numeric, character) RETURNS numeric
82152
 
    LANGUAGE plpgsql
82153
 
    AS $_$
82154
 
DECLARE
82155
 
pAmount ALIAS FOR $1;
82156
 
pPeriod ALIAS FOR $2;
82157
 
_state integer;
82158
 
_count integer;
82159
 
 
82160
 
BEGIN
82161
 
  -- Convert amount to hourly rate
82162
 
  IF (pPeriod = 'H') THEN  -- hourly
82163
 
    RETURN round(pAmount,2);
82164
 
  ELSIF (pPeriod = 'D') THEN -- daily
82165
 
    RETURN round(pAmount / 8, 2);
82166
 
  ELSIF (pPeriod = 'W') THEN  -- weekly
82167
 
    RETURN round(pAmount / 40, 2);
82168
 
  ELSIF (pPeriod = 'BW') THEN  -- bi-weekly
82169
 
    RETURN round(pAmount / 80, 2);
82170
 
  ELSIF (pPeriod = 'M') THEN -- monthly
82171
 
    RETURN round(pAmount / 160, 2);
82172
 
  ELSIF (pPeriod = 'Y') THEN -- annually 
82173
 
    RETURN round(pAmount / 2080, 2);
82174
 
  ELSE
82175
 
    RAISE EXCEPTION 'Unknown period type passed: %', pPeriod;
82176
 
  END IF;
82177
 
 
82178
 
END;
82179
 
$_$;
82180
 
 
82181
 
 
82182
 
ALTER FUNCTION te.calcrate(numeric, character) OWNER TO admin;
82183
 
 
82184
 
--
82185
 
--
82186
 
 
82187
 
CREATE FUNCTION copyitem(integer, text) RETURNS integer
82188
 
    LANGUAGE plpgsql
82189
 
    AS $_$
82190
 
DECLARE
82191
 
  pSItemid ALIAS FOR $1;
82192
 
  pTItemNumber ALIAS FOR $2;
82193
 
  _itemid INTEGER;
82194
 
  _r RECORD;
82195
 
  _id INTEGER;
82196
 
 
82197
 
BEGIN
82198
 
  _itemid := public.copyItem(pSItemid, pTItemNumber);
82199
 
 
82200
 
  INSERT INTO te.teexp
82201
 
  SELECT _itemid, teexp_expcat_id, teexp_accnt_id
82202
 
  FROM te.teexp src
82203
 
  WHERE (src.teexp_id=pSItemid);
82204
 
 
82205
 
  RETURN _itemid;
82206
 
END;
82207
 
$_$;
82208
 
 
82209
 
 
82210
 
ALTER FUNCTION te.copyitem(integer, text) OWNER TO admin;
82211
 
 
82212
 
--
82213
 
--
82214
 
 
82215
 
CREATE FUNCTION invoicesheets(integer[]) RETURNS integer
82216
 
    LANGUAGE plpgsql
82217
 
    AS $_$
82218
 
DECLARE
82219
 
pHeadIDs ALIAS FOR $1;
82220
 
 
82221
 
_invcnum text;
82222
 
_invcheadid integer;
82223
 
_invcitemid integer;
82224
 
_s record;
82225
 
_t record;
82226
 
_linenum integer;
82227
 
 
82228
 
BEGIN
82229
 
       -- Loop through time sheet items with matching criteria and make invoices
82230
 
       FOR _s in SELECT DISTINCT 
82231
 
                   teitem_cust_id, 
82232
 
                   teitem_po, 
82233
 
                   prj_id, 
82234
 
                   teitem_curr_id
82235
 
       FROM te.tehead 
82236
 
         JOIN te.teitem ON (teitem_tehead_id=tehead_id AND teitem_billable)
82237
 
         JOIN prjtask ON (teitem_prjtask_id=prjtask_id)
82238
 
         JOIN prj ON (prjtask_prj_id=prj_id)
82239
 
       WHERE ((tehead_id IN (SELECT * FROM te.unnest(pHeadIDs) ) )
82240
 
        AND (teitem_billable)
82241
 
        AND (teitem_invcitem_id IS NULL))
82242
 
 
82243
 
       -- loop thru records and create invoices by customer, by PO for the provided headid
82244
 
       LOOP
82245
 
         --select nextval('invchead_invchead_id_seq') into _invcid;
82246
 
         _invcnum := CAST(fetchInvcNumber() AS TEXT);
82247
 
         _invcheadid := nextval('invchead_invchead_id_seq');
82248
 
         _linenum := 1;
82249
 
 
82250
 
         INSERT INTO invchead
82251
 
         SELECT _invcheadid, cust_id, -1, '', current_date, false, false, _invcnum,
82252
 
           current_date, current_date, _s.teitem_po, '', '', cust_name, COALESCE(addr_line1,''),
82253
 
           COALESCE(addr_line2,''), COALESCE(addr_line3,''), COALESCE(addr_city,''),
82254
 
           COALESCE(addr_state,''), COALESCE(addr_postalcode,''), cntct_phone, 
82255
 
           '', '', '', '', '', '', '', '', cust_salesrep_id, salesrep_commission, cust_terms_id,
82256
 
           0, 0, '', -1, 0, '', '', COALESCE(addr_country,''), '', _s.prj_id, 
82257
 
           _s.teitem_curr_id, current_date, false, null, null, null, null, null, cust_taxzone_id
82258
 
         FROM custinfo
82259
 
           JOIN salesrep ON (cust_salesrep_id=salesrep_id)
82260
 
           LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)
82261
 
           LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)
82262
 
         WHERE (cust_id=_s.teitem_cust_id);
82263
 
 
82264
 
          -- loop thru all lines of the sheet
82265
 
          FOR _t IN SELECT 
82266
 
               teitem_id,
82267
 
               teitem_linenumber, 
82268
 
               tehead_warehous_id,
82269
 
               teitem_type,
82270
 
               tehead_emp_id,
82271
 
               cust_taxzone_id,
82272
 
               item_number,
82273
 
               teitem_cust_id,
82274
 
               teitem_po,
82275
 
               teitem_item_id,
82276
 
               teitem_qty,
82277
 
               teitem_uom_id,
82278
 
               teitem_rate,
82279
 
               teitem_notes
82280
 
             FROM te.teitem
82281
 
               JOIN te.tehead ON (teitem_tehead_id = tehead_id)
82282
 
               JOIN custinfo ON (cust_id = teitem_cust_id)
82283
 
               JOIN item ON (item_id = teitem_item_id)
82284
 
               JOIN prjtask ON (teitem_prjtask_id=prjtask_id)
82285
 
               JOIN prj ON (prjtask_prj_id=prj_id)
82286
 
             WHERE ((tehead_id IN (SELECT * FROM te.unnest(pHeadIDs) ) )
82287
 
              AND (teitem_billable)
82288
 
              AND (teitem_invcitem_id IS NULL)
82289
 
              AND (item_id = teitem_item_id)
82290
 
              AND (teitem_cust_id = _s.teitem_cust_id)
82291
 
              AND (teitem_po = _s.teitem_po)
82292
 
              AND (prj_id = _s.prj_id)
82293
 
              AND (teitem_curr_id = _s.teitem_curr_id))
82294
 
             ORDER BY teitem_linenumber
82295
 
          LOOP
82296
 
            _invcitemid := nextval('invcitem_invcitem_id_seq');
82297
 
 
82298
 
            INSERT INTO invcitem
82299
 
            SELECT 
82300
 
              _invcitemid, _invcheadid, _linenum, _t.teitem_item_id,
82301
 
              _t.tehead_warehous_id, '', '', '', _t.teitem_qty, _t.teitem_qty, _t.teitem_rate,
82302
 
              _t.teitem_rate, _t.teitem_notes, -1, getItemTaxType(item_id, _t.cust_taxzone_id), 
82303
 
              _t.teitem_uom_id, itemuomtouomratio(item_id, _t.teitem_uom_id, item_inv_uom_id),
82304
 
              _t.teitem_uom_id, itemuomtouomratio(item_id, _t.teitem_uom_id, item_inv_uom_id),
82305
 
              null
82306
 
            FROM item
82307
 
            WHERE (item_id=_t.teitem_item_id);
82308
 
 
82309
 
            _linenum := _linenum + 1;
82310
 
            
82311
 
            -- Update the time sheet item record
82312
 
            UPDATE te.teitem SET teitem_invcitem_id = _invcitemid WHERE (teitem_id = _t.teitem_id);
82313
 
            
82314
 
          END LOOP;
82315
 
       END LOOP;
82316
 
 
82317
 
RETURN 1;
82318
 
END;
82319
 
$_$;
82320
 
 
82321
 
 
82322
 
ALTER FUNCTION te.invoicesheets(integer[]) OWNER TO admin;
82323
 
 
82324
 
--
82325
 
--
82326
 
 
82327
 
CREATE FUNCTION postsheet(integer, text, text) RETURNS integer
82328
 
    LANGUAGE plpgsql
82329
 
    AS $_$
82330
 
DECLARE
82331
 
pTeheadId ALIAS FOR $1;
82332
 
pPhrase1 ALIAS FOR $2;
82333
 
pPhrase2 ALIAS FOR $3; 
82334
 
_r record;
82335
 
_notes TEXT;
82336
 
_value NUMERIC;
82337
 
_olaccntid INTEGER;
82338
 
_expaccntid INTEGER;
82339
 
_count INTEGER;
82340
 
 
82341
 
BEGIN
82342
 
  -- Validate: No posting for contractors
82343
 
  IF (SELECT (count(teemp_id) > 0) 
82344
 
      FROM te.tehead
82345
 
        JOIN te.teemp ON (tehead_emp_id=teemp_emp_id)
82346
 
      WHERE ((tehead_id=pTeheadId)
82347
 
        AND (teemp_contractor))) THEN
82348
 
    RAISE EXCEPTION 'Time and Expense Sheets can not be posted for contractors.  Voucher instead.';
82349
 
  END IF;
82350
 
  
82351
 
  -- Get labor and overhead account
82352
 
  SELECT accnt_id INTO _olaccntid
82353
 
  FROM accnt
82354
 
  WHERE (accnt_id=fetchmetricvalue('PrjLaborAndOverhead'));
82355
 
 
82356
 
  GET DIAGNOSTICS _count = ROW_COUNT;
82357
 
  IF (_count = 0) THEN
82358
 
    RAISE EXCEPTION 'No valid Project Labor and Overhead Account Defined';
82359
 
  END IF;
82360
 
 
82361
 
  -- Get applicable time sheets
82362
 
  FOR _r IN 
82363
 
    SELECT tehead_number,
82364
 
      teitem_id, teitem_linenumber, teitem_type, teitem_notes,
82365
 
      item_descrip1, teitem_qty,
82366
 
      teexp_expcat_id, teexp_accnt_id, 
82367
 
      emp_code, emp_wage, emp_wage_period,
82368
 
      prj_id, prj_number
82369
 
    FROM te.tehead
82370
 
     JOIN te.teitem ON (teitem_tehead_id=tehead_id)
82371
 
     JOIN item ON (teitem_item_id=item_id)
82372
 
     JOIN te.teexp ON (teitem_item_id=teexp_id)
82373
 
     JOIN emp ON (tehead_emp_id=emp_id)
82374
 
     JOIN prjtask ON (prjtask_id=teitem_prjtask_id)
82375
 
     JOIN prj ON (prj_id=prjtask_prj_id)
82376
 
    WHERE ((tehead_id = pTeheadId)
82377
 
     AND (NOT teitem_posted)
82378
 
     AND (teitem_vodist_id IS NULL)
82379
 
     AND (teitem_type = 'T'))
82380
 
 
82381
 
  LOOP  
82382
 
    -- Determine value
82383
 
    _value := te.calcRate(_r.emp_wage, _r.emp_wage_period) * _r.teitem_qty;
82384
 
 
82385
 
    -- Determine G/L account to post to
82386
 
    IF (_r.teexp_accnt_id > 1) THEN
82387
 
      _expaccntid := getPrjAccntId(_r.prj_id, _r.teexp_accnt_id);
82388
 
    ELSE
82389
 
      SELECT getPrjAccntId(_r.prj_id, expcat_exp_accnt_id) INTO _expaccntid
82390
 
      FROM expcat
82391
 
      WHERE (expcat_id=_r.teexp_expcat_id);
82392
 
    END IF;
82393
 
 
82394
 
    -- Execute the posting
82395
 
    _notes := (pPhrase1 || _r.item_descrip1 || '/' || _r.emp_code || pPhrase2 || ' ' || _r.prj_number);
82396
 
    PERFORM insertGLTransaction( 'T/E', 'TE', _r.tehead_number, _notes,
82397
 
                                 _olaccntid, _expaccntid, -1,
82398
 
                                 _value, current_date );
82399
 
 
82400
 
    -- Update the time sheet item
82401
 
    UPDATE te.teitem SET 
82402
 
      teitem_posted = true,
82403
 
      teitem_postedvalue = teitem_postedvalue + _value
82404
 
    WHERE (teitem_id=_r.teitem_id);
82405
 
                        
82406
 
  END LOOP;
82407
 
          
82408
 
RETURN 1;
82409
 
END;
82410
 
$_$;
82411
 
 
82412
 
 
82413
 
ALTER FUNCTION te.postsheet(integer, text, text) OWNER TO admin;
82414
 
 
82415
 
--
82416
 
--
82417
 
 
82418
 
CREATE FUNCTION sheetstate(integer, character) RETURNS integer
82419
 
    LANGUAGE plpgsql
82420
 
    AS $_$
82421
 
DECLARE
82422
 
  pTeheadId ALIAS FOR $1;
82423
 
  pType     ALIAS FOR $2;
82424
 
  _state    INTEGER := -1;
82425
 
 
82426
 
BEGIN
82427
 
  -- Check and return the process state of the sheet
82428
 
  --    1 = All processed
82429
 
  --    0 = Processing required
82430
 
  --   -1 = Not Applicable
82431
 
 
82432
 
  IF (pType = 'I') THEN
82433
 
    SELECT MIN(CASE teitem_invcitem_id IS NULL WHEN TRUE THEN 0 ELSE 1 END) INTO _state
82434
 
      FROM te.teitem
82435
 
     WHERE ((teitem_tehead_id=pTeheadId)
82436
 
        AND (teitem_billable)
82437
 
        AND (teitem_qty >= 0));
82438
 
 
82439
 
  ELSIF (pType = 'V') THEN
82440
 
    -- todo: why outer join then check teitem_type and vend_id is not null?
82441
 
    SELECT MIN(CASE teitem_vodist_id IS NULL WHEN TRUE THEN 0 ELSE 1 END) INTO _state
82442
 
      FROM te.tehead
82443
 
        JOIN emp ON (tehead_emp_id=emp_id)
82444
 
        LEFT OUTER JOIN te.teemp ON (emp_id=teemp_emp_id)
82445
 
        LEFT OUTER JOIN te.teitem ON (teitem_tehead_id=tehead_id)
82446
 
        LEFT OUTER JOIN vendinfo ON (UPPER(emp_code)=UPPER(vend_number))
82447
 
      WHERE ((teitem_tehead_id=pTeheadId)
82448
 
         AND ((teitem_type = 'E' AND NOT teitem_prepaid) 
82449
 
           OR (teitem_type = 'T' AND COALESCE(teemp_contractor,false)))
82450
 
         AND (vend_id IS NOT NULL)
82451
 
         AND (teitem_qty > 0));
82452
 
 
82453
 
  ELSIF (pType = 'P') THEN
82454
 
    SELECT MIN(CASE teitem_posted WHEN FALSE THEN 0 ELSE 1 END) INTO _state
82455
 
      FROM te.teitem
82456
 
      JOIN te.tehead ON (teitem_tehead_id=tehead_id)
82457
 
      JOIN te.teemp ON (tehead_emp_id=teemp_emp_id)
82458
 
     WHERE ((teitem_tehead_id=pTeheadId)
82459
 
        AND (teitem_type = 'T')
82460
 
        AND (NOT teemp_contractor));
82461
 
 
82462
 
  ELSE
82463
 
    -- TODO: either make ErrorReporter::error find this or use xtuple
82464
 
    RAISE EXCEPTION 'Unknown process type % [xtte: sheetstate, -2, %]',
82465
 
                    pType, pType;
82466
 
  END IF;
82467
 
 
82468
 
  RETURN _state;
82469
 
 
82470
 
END;
82471
 
$_$;
82472
 
 
82473
 
 
82474
 
ALTER FUNCTION te.sheetstate(integer, character) OWNER TO admin;
82475
 
 
82476
 
--
82477
 
--
82478
 
 
82479
 
CREATE FUNCTION triggertehead() RETURNS trigger
82480
 
    LANGUAGE plpgsql
82481
 
    AS $$
82482
 
DECLARE
82483
 
_r RECORD;
82484
 
_sense INTEGER := 0;
82485
 
 
82486
 
BEGIN
82487
 
 
82488
 
  -- Determine whether we are adding or subtracting totals
82489
 
  IF (TG_OP = 'UPDATE') THEN
82490
 
    IF (OLD.tehead_status = 'O' AND NEW.tehead_status = 'A') THEN
82491
 
    -- Approving so add
82492
 
      _sense := 1;
82493
 
    ELSIF  (OLD.tehead_status = 'A' AND NEW.tehead_status = 'O') THEN
82494
 
    -- Unapproving so subtract
82495
 
      _sense := -1;
82496
 
    END IF;
82497
 
  END IF;
82498
 
 
82499
 
  IF (_sense != 0) THEN
82500
 
    -- Loop thru all lines of the sheet and update project
82501
 
    FOR _r in 
82502
 
      SELECT teitem_prjtask_id, teitem_type, teitem_qty, teitem_total 
82503
 
      FROM te.teitem
82504
 
      WHERE teitem_tehead_id = NEW.tehead_id
82505
 
 
82506
 
    LOOP
82507
 
      IF (_r.teitem_type = 'T') THEN
82508
 
        UPDATE prjtask SET 
82509
 
          prjtask_hours_actual = prjtask_hours_actual + _r.teitem_qty * _sense
82510
 
        WHERE prjtask_id = _r.teitem_prjtask_id;
82511
 
      ELSE
82512
 
        UPDATE prjtask SET 
82513
 
          prjtask_exp_actual = prjtask_exp_actual + _r.teitem_total * _sense
82514
 
        WHERE prjtask_id = _r.teitem_prjtask_id;
82515
 
      END IF;
82516
 
            
82517
 
    END LOOP;
82518
 
  END IF;
82519
 
 
82520
 
  RETURN NEW;
82521
 
END;
82522
 
$$;
82523
 
 
82524
 
 
82525
 
ALTER FUNCTION te.triggertehead() OWNER TO admin;
82526
 
 
82527
 
--
82528
 
--
82529
 
 
82530
 
CREATE FUNCTION triggerteitem() RETURNS trigger
82531
 
    LANGUAGE plpgsql
82532
 
    AS $$
82533
 
DECLARE
82534
 
_r RECORD;
82535
 
_status CHAR(1) := 'O';
82536
 
 
82537
 
BEGIN
82538
 
  -- Validate whether we can take this action
82539
 
  IF (TG_OP = 'UPDATE') THEN
82540
 
    IF ((OLD.teitem_type != NEW.teitem_type)
82541
 
      OR (OLD.teitem_workdate != NEW.teitem_workdate)
82542
 
      OR (OLD.teitem_cust_id != NEW.teitem_cust_id)
82543
 
      OR (OLD.teitem_po != NEW.teitem_po)
82544
 
      OR (OLD.teitem_item_id != NEW.teitem_item_id)
82545
 
      OR (OLD.teitem_qty != NEW.teitem_qty)
82546
 
      OR (OLD.teitem_rate != NEW.teitem_rate)
82547
 
      OR (OLD.teitem_total != NEW.teitem_total)
82548
 
      OR (OLD.teitem_billable != NEW.teitem_billable)
82549
 
      OR (OLD.teitem_prepaid != NEW.teitem_prepaid)
82550
 
      OR (OLD.teitem_notes != NEW.teitem_notes)) THEN
82551
 
      
82552
 
      SELECT tehead_status INTO _status FROM te.tehead WHERE tehead_id=NEW.teitem_tehead_id;
82553
 
    END IF;
82554
 
  ELSIF (TG_OP = 'INSERT') THEN
82555
 
    SELECT tehead_status INTO _status FROM te.tehead WHERE tehead_id=NEW.teitem_tehead_id;
82556
 
  ELSE -- Must be delete
82557
 
    SELECT tehead_status INTO _status FROM te.tehead WHERE tehead_id=OLD.teitem_tehead_id;
82558
 
  END IF;
82559
 
 
82560
 
  IF (_status != 'O') THEN
82561
 
    RAISE EXCEPTION 'Time and Expense Sheets may only be edited or deleted when the status is Open';
82562
 
  END IF;
82563
 
 
82564
 
  _status := 'C';
82565
 
  
82566
 
  -- Update header status, default is to close if all processing complete
82567
 
  IF (TG_OP = 'UPDATE') THEN
82568
 
    IF ((COALESCE(OLD.teitem_invcitem_id,-1) != COALESCE(NEW.teitem_invcitem_id,-1))
82569
 
      OR (COALESCE(OLD.teitem_vodist_id,-1) != COALESCE(NEW.teitem_vodist_id,-1))
82570
 
      OR (OLD.teitem_posted != NEW.teitem_posted)) THEN
82571
 
 
82572
 
      SELECT 
82573
 
        te.sheetstate(NEW.teitem_tehead_id, 'I') AS invoiced,
82574
 
        te.sheetstate(NEW.teitem_tehead_id, 'V') AS vouchered,
82575
 
        te.sheetstate(NEW.teitem_tehead_id, 'P') AS posted
82576
 
      INTO _r;
82577
 
 
82578
 
      IF (_r.invoiced = 0 OR _r.vouchered = 0 OR _r.posted = 0) THEN
82579
 
        _status := 'A'; -- Something is still open, so approved
82580
 
      END IF;
82581
 
    
82582
 
      UPDATE te.tehead SET tehead_status = _status WHERE (tehead_id=NEW.teitem_tehead_id);
82583
 
    END IF;
82584
 
  END IF;
82585
 
 
82586
 
  -- Update header with last use info
82587
 
  IF (TG_OP = 'DELETE') THEN
82588
 
    UPDATE te.tehead SET
82589
 
      tehead_lastupdated=('now'::text)::timestamp(6) with time zone
82590
 
    WHERE (tehead_id=OLD.teitem_tehead_id);
82591
 
  ELSE
82592
 
    UPDATE te.tehead SET
82593
 
      tehead_lastupdated=('now'::text)::timestamp(6) with time zone,
82594
 
      tehead_username=current_user
82595
 
    WHERE (tehead_id=NEW.teitem_tehead_id);
82596
 
  END IF;
82597
 
 
82598
 
  RETURN NEW;
82599
 
END;
82600
 
$$;
82601
 
 
82602
 
 
82603
 
ALTER FUNCTION te.triggerteitem() OWNER TO admin;
82604
 
 
82605
 
--
82606
 
--
82607
 
 
82608
 
CREATE FUNCTION triggerteprj() RETURNS trigger
82609
 
    LANGUAGE plpgsql
82610
 
    AS $$
82611
 
DECLARE
82612
 
  _update BOOLEAN := false;
82613
 
BEGIN
82614
 
 
82615
 
  IF (TG_OP = 'INSERT') THEN
82616
 
    _update = true;
82617
 
  ELSIF (TG_OP = 'UPDATE') THEN
82618
 
    IF (COALESCE(OLD.teprj_cust_id,-1) != COALESCE(NEW.teprj_cust_id,-1)) THEN
82619
 
      _update = true;
82620
 
    END IF;
82621
 
  END IF;
82622
 
 
82623
 
  IF (_update) THEN
82624
 
      UPDATE te.teprjtask SET teprjtask_cust_id=NEW.teprj_cust_id
82625
 
      FROM prjtask
82626
 
      WHERE ((teprjtask_prjtask_id=prjtask_id)
82627
 
      AND (prjtask_prj_id=NEW.teprj_prj_id));
82628
 
  END IF;
82629
 
  
82630
 
  RETURN NEW;
82631
 
END;
82632
 
$$;
82633
 
 
82634
 
 
82635
 
ALTER FUNCTION te.triggerteprj() OWNER TO admin;
82636
 
 
82637
 
--
82638
 
--
82639
 
 
82640
 
CREATE FUNCTION unnest(anyarray) RETURNS SETOF anyelement
82641
 
    LANGUAGE sql IMMUTABLE
82642
 
    AS $_$
82643
 
SELECT $1[i] FROM
82644
 
    generate_series(array_lower($1,1),
82645
 
                    array_upper($1,1)) i;
82646
 
$_$;
82647
 
 
82648
 
 
82649
 
ALTER FUNCTION te.unnest(anyarray) OWNER TO admin;
82650
 
 
82651
 
--
82652
 
--
82653
 
 
82654
 
CREATE FUNCTION vouchersheet(integer) RETURNS integer
82655
 
    LANGUAGE plpgsql
82656
 
    AS $_$
82657
 
DECLARE
82658
 
  pHeadID ALIAS FOR $1;
82659
 
  _distamt  NUMERIC;
82660
 
  _glaccnt  INTEGER;
82661
 
  _notes    TEXT;
82662
 
  _s        RECORD;
82663
 
  _total    NUMERIC := 0;
82664
 
  _v        RECORD;
82665
 
  _vodistid INTEGER;
82666
 
  _voheadid INTEGER;
82667
 
 
82668
 
BEGIN
82669
 
  FOR _v IN
82670
 
    -- distinct filters duplicate rows returned because of the teitem join
82671
 
    -- TODO: can we push the teitem down into the loop and avoid the distinct?
82672
 
    SELECT DISTINCT
82673
 
           tehead_id, tehead_number,   tehead_weekending,          tehead_notes,
82674
 
           teitem_curr_id,
82675
 
           emp_wage, emp_wage_period,
82676
 
           vend_id,   vend_taxzone_id, vend_terms_id, vend_number, vend_1099,
82677
 
           COALESCE(teemp_contractor, false) AS isContractor
82678
 
      FROM te.tehead
82679
 
      JOIN te.teitem ON (teitem_tehead_id=tehead_id)
82680
 
      JOIN emp       ON (tehead_emp_id=emp_id)
82681
 
      JOIN vendinfo  ON (UPPER(emp_code)=UPPER(vend_number))
82682
 
      LEFT OUTER JOIN te.teemp ON (emp_id=teemp_emp_id)
82683
 
    WHERE ((tehead_id      = pHeadID)
82684
 
       AND (teitem_prepaid = false)
82685
 
       AND (teitem_vodist_id IS NULL)
82686
 
       AND (teitem_type = 'E' OR (COALESCE(teemp_contractor,false) AND (teitem_empcost > 0 OR emp_wage > 0 ))))  LOOP
82687
 
 
82688
 
     INSERT INTO vohead (vohead_id,        vohead_number,     vohead_vend_id,
82689
 
                         vohead_distdate,  vohead_docdate,
82690
 
                         vohead_duedate,
82691
 
                         vohead_terms_id,  vohead_taxzone_id, vohead_invcnumber,
82692
 
                         vohead_reference, vohead_amount,     vohead_1099,
82693
 
                         vohead_curr_id,   vohead_notes,      vohead_posted,
82694
 
                         vohead_misc,      vohead_pohead_id)
82695
 
                 VALUES (DEFAULT,              fetchVoNumber(),    _v.vend_id,
82696
 
                         _v.tehead_weekending, _v.tehead_weekending,
82697
 
                         determineDueDate(_v.vend_terms_id, _v.tehead_weekending),
82698
 
                         _v.vend_terms_id,     _v.vend_taxzone_id, 'N/A',
82699
 
                         ('T&E Sheet ' || _v.tehead_number),    0, _v.vend_1099,
82700
 
                         _v.teitem_curr_id,    _v.tehead_notes, false,
82701
 
                         true,                 -1)
82702
 
     RETURNING vohead_id INTO _voheadid;
82703
 
 
82704
 
     FOR _s IN
82705
 
       SELECT teitem_id,       teitem_linenumber, teitem_workdate, teitem_type,
82706
 
              item_number,     teitem_item_id,    teitem_qty,      prjtask_prj_id,
82707
 
              CASE
82708
 
                WHEN teitem_empcost > 0 THEN teitem_empcost
82709
 
                ELSE te.calcRate(_v.emp_wage, _v.emp_wage_period)
82710
 
              END AS rate,
82711
 
              teitem_total,    teitem_type,
82712
 
              teexp_expcat_id, teexp_accnt_id
82713
 
         FROM te.teitem
82714
 
         JOIN te.teexp ON (teitem_item_id=teexp_id)
82715
 
         JOIN item     ON (teitem_item_id=item_id)
82716
 
         JOIN prjtask  ON (teitem_prjtask_id=prjtask_id)
82717
 
        WHERE ((teitem_tehead_id = _v.tehead_id)
82718
 
           AND (teitem_curr_id   = _v.teitem_curr_id)
82719
 
           AND (teitem_prepaid   = false)
82720
 
           AND (teitem_vodist_id IS NULL)
82721
 
           AND (teitem_type = 'E' OR (_v.isContractor AND (teitem_empcost > 0 OR _v.emp_wage > 0 )))) 
82722
 
 
82723
 
 
82724
 
       -- Loop thru records and create vouchers by supplier for the provided headid
82725
 
     LOOP
82726
 
        -- insert vodist records here
82727
 
        _vodistid = nextval('vodist_vodist_id_seq');
82728
 
 
82729
 
        -- Map expense directly to account so we can get project account mapping if applicable
82730
 
        IF (_s.teexp_accnt_id > 1) THEN
82731
 
          _glaccnt := getPrjAccntId(_s.prjtask_prj_id, _s.teexp_accnt_id);
82732
 
        ELSE
82733
 
          SELECT getPrjAccntId(_s.prjtask_prj_id, expcat_exp_accnt_id) INTO _glaccnt
82734
 
            FROM expcat
82735
 
           WHERE (expcat_id=_s.teexp_expcat_id);
82736
 
        END IF;
82737
 
 
82738
 
        IF (_s.teitem_type = 'T') THEN -- Time sheet record
82739
 
          _notes := formatdate(_s.teitem_workdate) || E'\t' || _s.item_number ||
82740
 
                    E'\t' || formatQty(_s.teitem_qty) || ' hours' || E'\t';
82741
 
          _distamt := _s.rate * _s.teitem_qty;
82742
 
        ELSE -- Expense record
82743
 
          _notes := formatdate(_s.teitem_workdate) || E'\t' || _s.item_number ||
82744
 
                    E'\t' || E'\t';
82745
 
          _distamt := _s.teitem_total;
82746
 
        END IF;
82747
 
 
82748
 
        INSERT INTO vodist (vodist_id,          vodist_vohead_id, vodist_poitem_id,
82749
 
                            vodist_costelem_id, vodist_accnt_id,  vodist_amount,
82750
 
                            vodist_expcat_id,   vodist_notes)
82751
 
                    VALUES (_vodistid, _voheadid, -1,
82752
 
                            -1,        _glaccnt,  _distamt,
82753
 
                            -1,        _notes);
82754
 
        _total := _total + _distamt;
82755
 
 
82756
 
        -- Update the te.teitem record with the relationship
82757
 
        UPDATE te.teitem SET teitem_vodist_id = _vodistid WHERE teitem_id = _s.teitem_id;
82758
 
     END LOOP;
82759
 
 
82760
 
    UPDATE vohead SET vohead_amount = _total WHERE (vohead_id=_voheadid);
82761
 
     _total := 0;
82762
 
 
82763
 
  END LOOP;
82764
 
 
82765
 
  RETURN 1;
82766
 
END;
82767
 
$_$;
82768
 
 
82769
 
 
82770
 
ALTER FUNCTION te.vouchersheet(integer) OWNER TO admin;
82771
 
 
82772
 
SET search_path = xt, pg_catalog;
82773
 
 
82774
 
--
82775
 
--
82776
 
 
82777
 
CREATE FUNCTION add_column(table_name text, column_name text, type_name text, constraint_text text DEFAULT NULL::text, schema_name text DEFAULT 'xt'::text, column_comment text DEFAULT NULL::text) RETURNS boolean
82778
 
    LANGUAGE plpgsql
82779
 
    AS $$
82780
 
declare
82781
 
  count integer;
82782
 
  query text;
82783
 
  comment_query text;
82784
 
begin
82785
 
 
82786
 
  perform *
82787
 
  from pg_class c, pg_namespace n, pg_attribute a, pg_type t
82788
 
  where c.relname = table_name
82789
 
   and n.nspname = schema_name
82790
 
   and a.attname = column_name
82791
 
   and n.oid = c.relnamespace
82792
 
   and a.attnum > 0
82793
 
   and a.attrelid = c.oid
82794
 
   and a.atttypid = t.oid;
82795
 
 
82796
 
  get diagnostics count = row_count;
82797
 
 
82798
 
  if (count > 0) then
82799
 
    return false;
82800
 
  end if;
82801
 
 
82802
 
  query = 'alter table ' || schema_name || '.' || table_name || ' add column ' || column_name || ' ' || type_name || ' ' || coalesce(constraint_text, '');
82803
 
 
82804
 
  execute query;
82805
 
 
82806
 
  if (column_comment is not null) then
82807
 
    comment_query = 'comment on column ' || schema_name || '.' || table_name || '.' || column_name || ' is ' || quote_literal(column_comment);
82808
 
    execute comment_query;
82809
 
  end if;
82810
 
 
82811
 
  return true;
82812
 
 
82813
 
end;
82814
 
$$;
82815
 
 
82816
 
 
82817
 
ALTER FUNCTION xt.add_column(table_name text, column_name text, type_name text, constraint_text text, schema_name text, column_comment text) OWNER TO admin;
82818
 
 
82819
 
--
82820
 
--
82821
 
 
82822
 
CREATE FUNCTION add_comment_type(text, text, text) RETURNS boolean
82823
 
    LANGUAGE plpgsql
82824
 
    AS $_$
82825
 
DECLARE
82826
 
   _module  ALIAS FOR $1;
82827
 
   _comment ALIAS FOR $2;
82828
 
   _descr   ALIAS FOR $3;
82829
 
   _cmntid INTEGER;
82830
 
 
82831
 
BEGIN
82832
 
  SELECT source_id INTO _cmntid
82833
 
        FROM source WHERE source_name = _comment;
82834
 
 
82835
 
  IF (NOT FOUND) THEN
82836
 
    INSERT INTO source (source_module, source_name, source_descrip)
82837
 
      VALUES (_module, _comment, _descr) 
82838
 
      RETURNING source_id INTO _cmntid;
82839
 
 
82840
 
  INSERT INTO cmnttypesource (cmnttypesource_cmnttype_id, cmnttypesource_source_id)
82841
 
        VALUES (1, _cmntid);  -- General Comments
82842
 
  INSERT INTO cmnttypesource (cmnttypesource_cmnttype_id, cmnttypesource_source_id)
82843
 
          VALUES (2, _cmntid);  -- ChangeLog Comments
82844
 
  
82845
 
  END IF;
82846
 
 
82847
 
  RETURN true;
82848
 
 
82849
 
END;
82850
 
 
82851
 
$_$;
82852
 
 
82853
 
 
82854
 
ALTER FUNCTION xt.add_comment_type(text, text, text) OWNER TO admin;
82855
 
 
82856
 
--
82857
 
--
82858
 
 
82859
 
CREATE FUNCTION add_constraint(table_name text, constraint_name text, constraint_text text, schema_name text DEFAULT 'xt'::text) RETURNS boolean
82860
 
    LANGUAGE plpgsql
82861
 
    AS $$
82862
 
declare
82863
 
  count integer;
82864
 
  query text;
82865
 
begin
82866
 
 
82867
 
  perform *
82868
 
  from pg_constraint
82869
 
    join pg_namespace on (connamespace=pg_namespace.oid)
82870
 
    join pg_class f on (conrelid=f.oid)
82871
 
  where f.relname = table_name
82872
 
    and nspname = schema_name
82873
 
    and conname = constraint_name;
82874
 
  
82875
 
  get diagnostics count = row_count;
82876
 
  
82877
 
  if (count > 0) then
82878
 
    return false;
82879
 
  end if;
82880
 
 
82881
 
  query = 'alter table ' || schema_name || '.' || table_name || ' add constraint ' || constraint_name || ' ' || constraint_text || ';';
82882
 
  execute query;
82883
 
 
82884
 
  return true;
82885
 
  
82886
 
end;
82887
 
$$;
82888
 
 
82889
 
 
82890
 
ALTER FUNCTION xt.add_constraint(table_name text, constraint_name text, constraint_text text, schema_name text) OWNER TO admin;
82891
 
 
82892
 
--
82893
 
--
82894
 
 
82895
 
CREATE FUNCTION add_index(table_name text, column_names text, index_name text, using_name text DEFAULT 'btree'::text, schema_name text DEFAULT 'xt'::text) RETURNS boolean
82896
 
    LANGUAGE plpgsql
82897
 
    AS $$
82898
 
declare
82899
 
  count integer;
82900
 
  query text;
82901
 
begin
82902
 
 
82903
 
  perform *
82904
 
  from pg_index
82905
 
    join pg_class s on (indexrelid=s.oid)
82906
 
    join pg_class f on (indrelid=f.oid)
82907
 
    join pg_namespace on (f.relnamespace=pg_namespace.oid)
82908
 
  where f.relname = table_name
82909
 
    and nspname = schema_name
82910
 
    and s.relname = index_name;
82911
 
  
82912
 
  get diagnostics count = row_count;
82913
 
  
82914
 
  if (count > 0) then
82915
 
    return false;
82916
 
  end if;
82917
 
 
82918
 
  query = 'create index  ' || index_name || ' on ' || schema_name || '.' || table_name || ' using ' || using_name || '(' || column_names || ');';
82919
 
  execute query;
82920
 
 
82921
 
  return true;
82922
 
  
82923
 
end;
82924
 
$$;
82925
 
 
82926
 
 
82927
 
ALTER FUNCTION xt.add_index(table_name text, column_names text, index_name text, using_name text, schema_name text) OWNER TO admin;
82928
 
 
82929
 
--
82930
 
--
82931
 
 
82932
 
CREATE FUNCTION add_primary_key(table_name text, column_name text, schema_name text DEFAULT 'xt'::text) RETURNS boolean
82933
 
    LANGUAGE plpgsql
82934
 
    AS $$
82935
 
declare
82936
 
  count integer;
82937
 
  query text;
82938
 
begin
82939
 
 
82940
 
  perform *
82941
 
  from pg_constraint
82942
 
    join pg_namespace on (connamespace=pg_namespace.oid)
82943
 
    join pg_class f on (conrelid=f.oid)
82944
 
  where f.relname = table_name
82945
 
    and nspname = schema_name
82946
 
    and contype = 'p';
82947
 
  
82948
 
  get diagnostics count = row_count;
82949
 
  
82950
 
  if (count > 0) then
82951
 
    return false;
82952
 
  end if;
82953
 
 
82954
 
  query = 'alter table ' || schema_name || '.' || table_name || ' add primary key (' || column_name || ');';
82955
 
  execute query;
82956
 
 
82957
 
  return true;
82958
 
  
82959
 
end;
82960
 
$$;
82961
 
 
82962
 
 
82963
 
ALTER FUNCTION xt.add_primary_key(table_name text, column_name text, schema_name text) OWNER TO admin;
82964
 
 
82965
 
--
82966
 
--
82967
 
 
82968
 
CREATE FUNCTION create_table(table_name text, schema_name text DEFAULT 'xt'::text, with_oids boolean DEFAULT false, inherit_table text DEFAULT NULL::text) RETURNS boolean
82969
 
    LANGUAGE plpgsql
82970
 
    AS $$
82971
 
declare
82972
 
  count integer;
82973
 
  query text;
82974
 
  with_clause text := '';
82975
 
  inherit_from text := '';
82976
 
begin
82977
 
 
82978
 
  perform *
82979
 
  from pg_tables 
82980
 
  where schemaname = schema_name and tablename = table_name;
82981
 
  
82982
 
  get diagnostics count = row_count;
82983
 
  
82984
 
  if (count > 0) then
82985
 
    return false;
82986
 
  end if;
82987
 
 
82988
 
  if (with_oids) then
82989
 
    with_clause := 'with (OIDS=TRUE)';
82990
 
  end if;
82991
 
 
82992
 
  if (inherit_table is not null) then
82993
 
    inherit_from := ' INHERITS (' || inherit_table || ') ';
82994
 
  end if;
82995
 
 
82996
 
  query = 'create table ' || schema_name || '.' || table_name || '()' || inherit_from || with_clause || '; 
82997
 
           grant all on ' || schema_name || '.' || table_name || ' to xtrole;';
82998
 
  execute query;
82999
 
 
83000
 
  return true;
83001
 
  
83002
 
end;
83003
 
$$;
83004
 
 
83005
 
 
83006
 
ALTER FUNCTION xt.create_table(table_name text, schema_name text, with_oids boolean, inherit_table text) OWNER TO admin;
83007
 
 
83008
 
SET search_path = xtdesktop, pg_catalog;
83009
 
 
83010
 
--
83011
 
--
83012
 
 
83013
 
CREATE FUNCTION fetchwelcomehtml() RETURNS text
83014
 
    LANGUAGE plpgsql IMMUTABLE
83015
 
    AS $$
83016
 
DECLARE
83017
 
  _html TEXT;
83018
 
 
83019
 
BEGIN
83020
 
 
83021
 
  _html := '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
83022
 
<HTML> 
83023
 
<HEAD> 
83024
 
        <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> 
83025
 
        <TITLE></TITLE> 
83026
 
        <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.0  (Unix)"> 
83027
 
        <META NAME="CREATED" CONTENT="20100422;16091500"> 
83028
 
        <META NAME="CHANGED" CONTENT="20100422;16095800"> 
83029
 
        <META NAME="Info 1" CONTENT=""> 
83030
 
        <META NAME="Info 2" CONTENT=""> 
83031
 
        <META NAME="Info 3" CONTENT=""> 
83032
 
        <META NAME="Info 4" CONTENT=""> 
83033
 
        <STYLE TYPE="text/css"> 
83034
 
        <!--
83035
 
                @page { margin: 0.79in }
83036
 
                P { margin-bottom: 0.08in }
83037
 
        --> 
83038
 
        </STYLE> 
83039
 
</HEAD> 
83040
 
<BODY LANG="en-US" DIR="LTR"> 
83041
 
<P STYLE="margin-bottom: 0in"><B>Welcome to xTuple</B></P> 
83042
 
<P STYLE="margin-bottom: 0in"><BR> 
83043
 
</P> 
83044
 
<P STYLE="margin-bottom: 0in">You are not connected to the internet
83045
 
at this time</P> 
83046
 
</BODY> 
83047
 
</HTML>';
83048
 
 
83049
 
  RETURN _html;
83050
 
 
83051
 
END;
83052
 
$$;
83053
 
 
83054
 
 
83055
 
ALTER FUNCTION xtdesktop.fetchwelcomehtml() OWNER TO admin;
83056
 
 
83057
 
--
83058
 
--
83059
 
 
83060
 
CREATE FUNCTION usersonline() RETURNS SETOF usersonline
83061
 
    LANGUAGE plpgsql
83062
 
    AS $$
83063
 
DECLARE
83064
 
 _row xtdesktop.usersonline%ROWTYPE;
83065
 
 _query TEXT;
83066
 
BEGIN
83067
 
  -- first part of our query doesn't care what PG version it is
83068
 
  _query :=    'SELECT usr.usr_id, usr.usr_username, usr.usr_propername, usr.usr_email, '
83069
 
            || 'min(backend_start) AS client_start, max(query_start) AS query_start, '
83070
 
            || 'sum(CASE WHEN(database IS NULL) THEN 0 ELSE 1 END) AS cnt_internal, '
83071
 
            || 'sum(CASE WHEN(database IS NULL) THEN 1 ELSE 0 END) AS cnt_external, '
83072
 
            || 'client_addr '
83073
 
            || 'FROM pg_stat_activity '
83074
 
            || 'JOIN public.usr ON (usr.usr_id=usesysid) ';
83075
 
 
83076
 
   -- use the integer comparison to compare server version to 9.2.0, where procpid was changed to just pid
83077
 
   IF (compareversion('9.2.0') <= 0)
83078
 
   THEN
83079
 
     _query := _query || 'LEFT OUTER JOIN pg_locks ON (database=datid AND classid=datid AND objid=pg_stat_activity.pid AND objsubid=2) ';
83080
 
   ELSE
83081
 
     _query := _query || 'LEFT OUTER JOIN pg_locks ON (database=datid AND classid=datid AND objid=procpid AND objsubid=2) ';
83082
 
   END IF;
83083
 
 
83084
 
   -- the rest of the query
83085
 
   _query := _query || 'WHERE(datname=current_database()) '
83086
 
                    || 'GROUP BY usr_id, usr_username, usr_propername, usr_email, client_addr ';
83087
 
 
83088
 
   -- loop over the rows that executing this query returns, and return them to the calling user
83089
 
   FOR _row IN
83090
 
      EXECUTE _query
83091
 
      LOOP
83092
 
        RETURN NEXT _row;
83093
 
      END LOOP;
83094
 
   RETURN;
83095
 
 
83096
 
END;
83097
 
$$;
83098
 
 
83099
 
 
83100
 
ALTER FUNCTION xtdesktop.usersonline() OWNER TO admin;
83101
 
 
83102
 
--
83103
 
--
83104
 
 
83105
 
COMMENT ON FUNCTION usersonline() IS 'A table function that returns a PostgreSQL-version aware count of users online.';
83106
 
 
83107
 
 
83108
 
SET search_path = public, pg_catalog;
83109
 
 
83110
 
--
83111
 
--
83112
 
 
83113
 
CREATE AGGREGATE concatagg(text) (
83114
 
    SFUNC = concataggsfunc,
83115
 
    STYPE = text,
83116
 
    INITCOND = ''
83117
 
);
83118
 
 
83119
 
 
83120
 
ALTER AGGREGATE public.concatagg(text) OWNER TO admin;
83121
 
 
83122
 
--
83123
 
--
83124
 
 
83125
 
CREATE AGGREGATE first(anyelement) (
83126
 
    SFUNC = first_agg,
83127
 
    STYPE = anyelement
83128
 
);
83129
 
 
83130
 
 
83131
 
ALTER AGGREGATE public.first(anyelement) OWNER TO admin;
83132
 
 
83133
 
--
83134
 
--
83135
 
 
83136
 
CREATE AGGREGATE last(anyelement) (
83137
 
    SFUNC = last_agg,
83138
 
    STYPE = anyelement
83139
 
);
83140
 
 
83141
 
 
83142
 
ALTER AGGREGATE public.last(anyelement) OWNER TO admin;
83143
 
 
83144
 
--
83145
 
--
83146
 
 
83147
 
CREATE TABLE addr (
83148
 
    addr_id integer NOT NULL,
83149
 
    addr_active boolean DEFAULT true,
83150
 
    addr_line1 text DEFAULT ''::text,
83151
 
    addr_line2 text DEFAULT ''::text,
83152
 
    addr_line3 text DEFAULT ''::text,
83153
 
    addr_city text DEFAULT ''::text,
83154
 
    addr_state text DEFAULT ''::text,
83155
 
    addr_postalcode text DEFAULT ''::text,
83156
 
    addr_country text DEFAULT ''::text,
83157
 
    addr_notes text DEFAULT ''::text,
83158
 
    addr_number text NOT NULL,
83159
 
    CONSTRAINT addr_addr_number_check CHECK ((addr_number <> ''::text))
83160
 
);
83161
 
 
83162
 
 
83163
 
ALTER TABLE public.addr OWNER TO admin;
83164
 
 
83165
 
--
83166
 
--
83167
 
 
83168
 
COMMENT ON TABLE addr IS 'Postal Address';
83169
 
 
83170
 
 
83171
 
SET search_path = api, pg_catalog;
83172
 
 
83173
 
--
83174
 
--
83175
 
 
83176
 
CREATE VIEW account AS
83177
 
    SELECT (c.crmacct_number)::character varying AS account_number, p.crmacct_number AS parent_account, c.crmacct_name AS account_name, c.crmacct_active AS active, CASE WHEN (c.crmacct_type = 'O'::bpchar) THEN 'Organization'::text ELSE 'Individual'::text END AS type, pc.cntct_number AS primary_contact_number, pc.cntct_honorific AS primary_contact_honorific, pc.cntct_first_name AS primary_contact_first, pc.cntct_middle AS primary_contact_middle, pc.cntct_last_name AS primary_contact_last, pc.cntct_suffix AS primary_contact_suffix, pc.cntct_title AS primary_contact_job_title, pc.cntct_phone AS primary_contact_voice, pc.cntct_fax AS primary_contact_fax, pc.cntct_email AS primary_contact_email, ''::text AS primary_contact_change, m.addr_number AS primary_contact_address_number, m.addr_line1 AS primary_contact_address1, m.addr_line2 AS primary_contact_address2, m.addr_line3 AS primary_contact_address3, m.addr_city AS primary_contact_city, m.addr_state AS primary_contact_state, m.addr_postalcode AS primary_contact_postalcode, m.addr_country AS primary_contact_country, ''::text AS primary_contact_address_change, sc.cntct_number AS secondary_contact_number, sc.cntct_honorific AS secondary_contact_honorific, sc.cntct_first_name AS secondary_contact_first, sc.cntct_middle AS secondary_contact_middle, sc.cntct_last_name AS secondary_contact_last, sc.cntct_suffix AS secondary_contact_suffix, sc.cntct_title AS secondary_contact_job_title, sc.cntct_phone AS secondary_contact_voice, sc.cntct_fax AS secondary_contact_fax, sc.cntct_email AS secondary_contact_email, sc.cntct_webaddr AS secondary_contact_web, ''::text AS secondary_contact_change, s.addr_number AS secondary_contact_address_number, s.addr_line1 AS secondary_contact_address1, s.addr_line2 AS secondary_contact_address2, s.addr_line3 AS secondary_contact_address3, s.addr_city AS secondary_contact_city, s.addr_state AS secondary_contact_state, s.addr_postalcode AS secondary_contact_postalcode, s.addr_country AS secondary_contact_country, ''::text AS secondary_contact_address_change, c.crmacct_notes AS notes FROM (((((public.crmacct c LEFT JOIN public.crmacct p ON ((c.crmacct_parent_id = p.crmacct_id))) LEFT JOIN public.cntct pc ON ((c.crmacct_cntct_id_1 = pc.cntct_id))) LEFT JOIN public.addr m ON ((pc.cntct_addr_id = m.addr_id))) LEFT JOIN public.cntct sc ON ((c.crmacct_cntct_id_2 = sc.cntct_id))) LEFT JOIN public.addr s ON ((sc.cntct_addr_id = s.addr_id)));
83178
 
 
83179
 
 
83180
 
ALTER TABLE api.account OWNER TO admin;
83181
 
 
83182
 
--
83183
 
--
83184
 
 
83185
 
COMMENT ON VIEW account IS 'Account';
83186
 
 
83187
 
 
83188
 
SET search_path = public, pg_catalog;
83189
 
 
83190
 
--
83191
 
--
83192
 
 
83193
 
CREATE TABLE "char" (
83194
 
    char_id integer NOT NULL,
83195
 
    char_name text NOT NULL,
83196
 
    char_items boolean,
83197
 
    char_options boolean,
83198
 
    char_attributes boolean,
83199
 
    char_lotserial boolean,
83200
 
    char_notes text,
83201
 
    char_customers boolean,
83202
 
    char_crmaccounts boolean,
83203
 
    char_addresses boolean,
83204
 
    char_contacts boolean,
83205
 
    char_opportunity boolean,
83206
 
    char_employees boolean DEFAULT false,
83207
 
    char_mask text,
83208
 
    char_validator text,
83209
 
    char_incidents boolean DEFAULT false,
83210
 
    char_type integer DEFAULT 0 NOT NULL,
83211
 
    char_order integer DEFAULT 0 NOT NULL,
83212
 
    char_search boolean DEFAULT true NOT NULL,
83213
 
    char_quotes boolean DEFAULT false,
83214
 
    char_salesorders boolean DEFAULT false,
83215
 
    char_invoices boolean DEFAULT false,
83216
 
    char_vendors boolean DEFAULT false,
83217
 
    char_purchaseorders boolean DEFAULT false,
83218
 
    char_vouchers boolean DEFAULT false,
83219
 
    char_projects boolean DEFAULT false,
83220
 
    char_tasks boolean DEFAULT false,
83221
 
    CONSTRAINT char_char_name_check CHECK ((char_name <> ''::text))
83222
 
);
83223
 
 
83224
 
 
83225
 
ALTER TABLE public."char" OWNER TO admin;
83226
 
 
83227
 
--
83228
 
--
83229
 
 
83230
 
COMMENT ON TABLE "char" IS 'Characteristic information';
83231
 
 
83232
 
 
83233
 
--
83234
 
--
83235
 
 
83236
 
CREATE TABLE charass (
83237
 
    charass_id integer NOT NULL,
83238
 
    charass_target_type text,
83239
 
    charass_target_id integer,
83240
 
    charass_char_id integer,
83241
 
    charass_value text,
83242
 
    charass_default boolean DEFAULT false NOT NULL,
83243
 
    charass_price numeric(16,4) DEFAULT 0 NOT NULL
83244
 
);
83245
 
 
83246
 
 
83247
 
ALTER TABLE public.charass OWNER TO admin;
83248
 
 
83249
 
--
83250
 
--
83251
 
 
83252
 
COMMENT ON TABLE charass IS 'Characteristic assignment information';
83253
 
 
83254
 
 
83255
 
SET search_path = api, pg_catalog;
83256
 
 
83257
 
--
83258
 
--
83259
 
 
83260
 
CREATE VIEW accountchar AS
83261
 
    SELECT (crmacct.crmacct_number)::character varying AS account_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.crmacct, public."char", public.charass WHERE ((('CRMACCT'::text = charass.charass_target_type) AND (crmacct.crmacct_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id));
83262
 
 
83263
 
 
83264
 
ALTER TABLE api.accountchar OWNER TO admin;
83265
 
 
83266
 
--
83267
 
--
83268
 
 
83269
 
COMMENT ON VIEW accountchar IS 'Account Characteristics';
83270
 
 
83271
 
 
83272
 
SET search_path = public, pg_catalog;
83273
 
 
83274
 
--
83275
 
--
83276
 
 
83277
 
CREATE TABLE cmnttype (
83278
 
    cmnttype_id integer NOT NULL,
83279
 
    cmnttype_name text NOT NULL,
83280
 
    cmnttype_descrip text NOT NULL,
83281
 
    cmnttype_usedin text,
83282
 
    cmnttype_sys boolean DEFAULT false NOT NULL,
83283
 
    cmnttype_editable boolean DEFAULT false NOT NULL,
83284
 
    cmnttype_order integer,
83285
 
    CONSTRAINT cmnttype_cmnttype_name_check CHECK ((cmnttype_name <> ''::text))
83286
 
);
83287
 
 
83288
 
 
83289
 
ALTER TABLE public.cmnttype OWNER TO admin;
83290
 
 
83291
 
--
83292
 
--
83293
 
 
83294
 
COMMENT ON TABLE cmnttype IS 'Comment Type information';
83295
 
 
83296
 
 
83297
 
--
83298
 
--
83299
 
 
83300
 
CREATE TABLE comment (
83301
 
    comment_id integer DEFAULT nextval(('"comment_comment_id_seq"'::text)::regclass) NOT NULL,
83302
 
    comment_source_id integer,
83303
 
    comment_date timestamp with time zone,
83304
 
    comment_user text,
83305
 
    comment_text text,
83306
 
    comment_cmnttype_id integer,
83307
 
    comment_source text,
83308
 
    comment_public boolean
83309
 
);
83310
 
 
83311
 
 
83312
 
ALTER TABLE public.comment OWNER TO admin;
83313
 
 
83314
 
--
83315
 
--
83316
 
 
83317
 
COMMENT ON TABLE comment IS 'Comment information';
83318
 
 
83319
 
 
83320
 
SET search_path = api, pg_catalog;
83321
 
 
83322
 
--
83323
 
--
83324
 
 
83325
 
CREATE VIEW accountcomment AS
83326
 
    SELECT (crmacct.crmacct_number)::character varying AS account_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.crmacct, public.cmnttype, public.comment WHERE (((comment.comment_source = 'CRMA'::text) AND (comment.comment_source_id = crmacct.crmacct_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id));
83327
 
 
83328
 
 
83329
 
ALTER TABLE api.accountcomment OWNER TO admin;
83330
 
 
83331
 
--
83332
 
--
83333
 
 
83334
 
COMMENT ON VIEW accountcomment IS 'Account Comment';
83335
 
 
83336
 
 
83337
 
SET search_path = public, pg_catalog;
83338
 
 
83339
 
--
83340
 
--
83341
 
 
83342
 
CREATE TABLE docass (
83343
 
    docass_id integer NOT NULL,
83344
 
    docass_source_id integer NOT NULL,
83345
 
    docass_source_type text NOT NULL,
83346
 
    docass_target_id integer NOT NULL,
83347
 
    docass_target_type text DEFAULT 'URL'::text NOT NULL,
83348
 
    docass_purpose character(1) DEFAULT 'S'::bpchar NOT NULL,
83349
 
    CONSTRAINT docass_docass_purpose_check CHECK (((((((((docass_purpose = 'I'::bpchar) OR (docass_purpose = 'E'::bpchar)) OR (docass_purpose = 'M'::bpchar)) OR (docass_purpose = 'P'::bpchar)) OR (docass_purpose = 'A'::bpchar)) OR (docass_purpose = 'C'::bpchar)) OR (docass_purpose = 'S'::bpchar)) OR (docass_purpose = 'D'::bpchar)))
83350
 
);
83351
 
 
83352
 
 
83353
 
ALTER TABLE public.docass OWNER TO admin;
83354
 
 
83355
 
--
83356
 
--
83357
 
 
83358
 
COMMENT ON TABLE docass IS 'Document Assignement References';
83359
 
 
83360
 
 
83361
 
--
83362
 
--
83363
 
 
83364
 
CREATE TABLE file (
83365
 
    file_id integer NOT NULL,
83366
 
    file_title text NOT NULL,
83367
 
    file_stream bytea,
83368
 
    file_descrip text NOT NULL
83369
 
);
83370
 
 
83371
 
 
83372
 
ALTER TABLE public.file OWNER TO admin;
83373
 
 
83374
 
--
83375
 
--
83376
 
 
83377
 
CREATE TABLE urlinfo (
83378
 
    url_id integer NOT NULL,
83379
 
    url_title text NOT NULL,
83380
 
    url_url text NOT NULL
83381
 
);
83382
 
 
83383
 
 
83384
 
ALTER TABLE public.urlinfo OWNER TO admin;
83385
 
 
83386
 
--
83387
 
--
83388
 
 
83389
 
CREATE VIEW url AS
83390
 
    SELECT docass.docass_id AS url_id, docass.docass_source_id AS url_source_id, docass.docass_source_type AS url_source, file.file_title AS url_title, file.file_descrip AS url_url, file.file_stream AS url_stream FROM (file JOIN docass ON (((docass.docass_target_id = file.file_id) AND (docass.docass_target_type = 'FILE'::text)))) UNION ALL SELECT docass.docass_id AS url_id, docass.docass_source_id AS url_source_id, docass.docass_source_type AS url_source, urlinfo.url_title, urlinfo.url_url, NULL::bytea AS url_stream FROM (urlinfo JOIN docass ON (((docass.docass_target_id = urlinfo.url_id) AND (docass.docass_target_type = 'URL'::text))));
83391
 
 
83392
 
 
83393
 
ALTER TABLE public.url OWNER TO admin;
83394
 
 
83395
 
SET search_path = api, pg_catalog;
83396
 
 
83397
 
--
83398
 
--
83399
 
 
83400
 
CREATE VIEW accountfile AS
83401
 
    SELECT crmacct.crmacct_number AS account_number, url.url_title AS title, url.url_url AS url FROM public.crmacct, public.url WHERE ((crmacct.crmacct_id = url.url_source_id) AND (url.url_source = 'CRMA'::text));
83402
 
 
83403
 
 
83404
 
ALTER TABLE api.accountfile OWNER TO admin;
83405
 
 
83406
 
--
83407
 
--
83408
 
 
83409
 
COMMENT ON VIEW accountfile IS 'Account File';
83410
 
 
83411
 
 
83412
 
SET search_path = public, pg_catalog;
83413
 
 
83414
 
--
83415
 
--
83416
 
 
83417
 
CREATE SEQUENCE docass_docass_id_seq
83418
 
    START WITH 1
83419
 
    INCREMENT BY 1
83420
 
    NO MINVALUE
83421
 
    NO MAXVALUE
83422
 
    CACHE 1;
83423
 
 
83424
 
 
83425
 
ALTER TABLE public.docass_docass_id_seq OWNER TO admin;
83426
 
 
83427
 
--
83428
 
--
83429
 
 
83430
 
ALTER SEQUENCE docass_docass_id_seq OWNED BY docass.docass_id;
83431
 
 
83432
 
 
83433
 
--
83434
 
--
83435
 
 
83436
 
CREATE TABLE image (
83437
 
    image_id integer DEFAULT nextval(('"image_image_id_seq"'::text)::regclass) NOT NULL,
83438
 
    image_name text,
83439
 
    image_descrip text,
83440
 
    image_data text
83441
 
);
83442
 
 
83443
 
 
83444
 
ALTER TABLE public.image OWNER TO admin;
83445
 
 
83446
 
--
83447
 
--
83448
 
 
83449
 
COMMENT ON TABLE image IS 'Image information';
83450
 
 
83451
 
 
83452
 
--
83453
 
--
83454
 
 
83455
 
CREATE TABLE imageass (
83456
 
    imageass_id integer DEFAULT nextval('docass_docass_id_seq'::regclass) NOT NULL,
83457
 
    imageass_source_id integer NOT NULL,
83458
 
    imageass_source text NOT NULL,
83459
 
    imageass_image_id integer NOT NULL,
83460
 
    imageass_purpose character(1) NOT NULL,
83461
 
    CONSTRAINT imageass_imageass_purpose_check CHECK (((((((((imageass_purpose = 'I'::bpchar) OR (imageass_purpose = 'E'::bpchar)) OR (imageass_purpose = 'M'::bpchar)) OR (imageass_purpose = 'P'::bpchar)) OR (imageass_purpose = 'A'::bpchar)) OR (imageass_purpose = 'C'::bpchar)) OR (imageass_purpose = 'D'::bpchar)) OR (imageass_purpose = 'S'::bpchar)))
83462
 
);
83463
 
 
83464
 
 
83465
 
ALTER TABLE public.imageass OWNER TO admin;
83466
 
 
83467
 
--
83468
 
--
83469
 
 
83470
 
COMMENT ON TABLE imageass IS 'Image Assignement References';
83471
 
 
83472
 
 
83473
 
SET search_path = api, pg_catalog;
83474
 
 
83475
 
--
83476
 
--
83477
 
 
83478
 
CREATE VIEW accountimage AS
83479
 
    SELECT crmacct.crmacct_number AS account_number, image.image_name FROM public.crmacct, public.imageass, public.image WHERE (((crmacct.crmacct_id = imageass.imageass_source_id) AND (imageass.imageass_source = 'CRMA'::text)) AND (imageass.imageass_image_id = image.image_id));
83480
 
 
83481
 
 
83482
 
ALTER TABLE api.accountimage OWNER TO admin;
83483
 
 
83484
 
--
83485
 
--
83486
 
 
83487
 
COMMENT ON VIEW accountimage IS 'Account Image';
83488
 
 
83489
 
 
83490
 
--
83491
 
--
83492
 
 
83493
 
CREATE VIEW address AS
83494
 
    SELECT (addr.addr_number)::character varying AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postal_code, addr.addr_country AS country, addr.addr_active AS active, addr.addr_notes AS notes, ''::text AS change FROM public.addr;
83495
 
 
83496
 
 
83497
 
ALTER TABLE api.address OWNER TO admin;
83498
 
 
83499
 
--
83500
 
--
83501
 
 
83502
 
COMMENT ON VIEW address IS 'Address';
83503
 
 
83504
 
 
83505
 
--
83506
 
--
83507
 
 
83508
 
CREATE VIEW addresschar AS
83509
 
    SELECT (addr.addr_number)::character varying AS address_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.addr, public."char", public.charass WHERE ((('ADDR'::text = charass.charass_target_type) AND (addr.addr_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id));
83510
 
 
83511
 
 
83512
 
ALTER TABLE api.addresschar OWNER TO admin;
83513
 
 
83514
 
--
83515
 
--
83516
 
 
83517
 
COMMENT ON VIEW addresschar IS 'Address Characteristics';
83518
 
 
83519
 
 
83520
 
--
83521
 
--
83522
 
 
83523
 
CREATE VIEW addresscomment AS
83524
 
    SELECT (addr.addr_number)::character varying AS address_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.addr, public.cmnttype, public.comment WHERE (((comment.comment_source = 'ADDR'::text) AND (comment.comment_source_id = addr.addr_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id));
83525
 
 
83526
 
 
83527
 
ALTER TABLE api.addresscomment OWNER TO admin;
83528
 
 
83529
 
--
83530
 
--
83531
 
 
83532
 
COMMENT ON VIEW addresscomment IS 'Address Comment';
83533
 
 
83534
 
 
83535
 
SET search_path = public, pg_catalog;
83536
 
 
83537
 
--
83538
 
--
83539
 
 
83540
 
CREATE TABLE bomhead (
83541
 
    bomhead_id integer DEFAULT nextval(('"bomhead_bomhead_id_seq"'::text)::regclass) NOT NULL,
83542
 
    bomhead_item_id integer NOT NULL,
83543
 
    bomhead_serial integer,
83544
 
    bomhead_docnum text,
83545
 
    bomhead_revision text,
83546
 
    bomhead_revisiondate date,
83547
 
    bomhead_batchsize numeric(18,6),
83548
 
    bomhead_requiredqtyper numeric(20,8),
83549
 
    bomhead_rev_id integer DEFAULT (-1),
83550
 
    CONSTRAINT bomhead_bomhead_batchsize_check CHECK ((bomhead_batchsize > (0)::numeric))
83551
 
);
83552
 
 
83553
 
 
83554
 
ALTER TABLE public.bomhead OWNER TO admin;
83555
 
 
83556
 
--
83557
 
--
83558
 
 
83559
 
COMMENT ON TABLE bomhead IS 'Bill of Materials (BOM) header information';
83560
 
 
83561
 
 
83562
 
SET search_path = api, pg_catalog;
83563
 
 
83564
 
--
83565
 
--
83566
 
 
83567
 
CREATE VIEW bom AS
83568
 
    SELECT (item.item_number)::character varying AS item_number, (bomhead.bomhead_revision)::character varying AS revision, bomhead.bomhead_docnum AS document_number, bomhead.bomhead_revisiondate AS revision_date, bomhead.bomhead_batchsize AS batch_size, bomhead.bomhead_requiredqtyper AS total_qty_per FROM public.bomhead, public.item WHERE (bomhead.bomhead_item_id = item.item_id);
83569
 
 
83570
 
 
83571
 
ALTER TABLE api.bom OWNER TO admin;
83572
 
 
83573
 
--
83574
 
--
83575
 
 
83576
 
COMMENT ON VIEW bom IS 'Bill of Material Header';
83577
 
 
83578
 
 
83579
 
--
83580
 
--
83581
 
 
83582
 
CREATE VIEW bomitem AS
83583
 
    SELECT bomitem.bomitem_id AS id, (p.item_number)::character varying AS bom_item_number, (bomhead.bomhead_revision)::character varying AS bom_revision, bomitem.bomitem_seqnumber AS sequence_number, i.item_number, CASE WHEN (bomitem.bomitem_effective = public.startoftime()) THEN 'Always'::text ELSE public.formatdate(bomitem.bomitem_effective) END AS effective, CASE WHEN (bomitem.bomitem_expires = public.endoftime()) THEN 'Never'::text ELSE public.formatdate(bomitem.bomitem_expires) END AS expires, bomitem.bomitem_qtyper AS qty_per, uom.uom_name AS issue_uom, bomitem.bomitem_scrap AS scrap, bomitem.bomitem_createwo AS create_child_wo, CASE WHEN (bomitem.bomitem_issuemethod = 'M'::bpchar) THEN 'Mixed'::text WHEN (bomitem.bomitem_issuemethod = 'L'::bpchar) THEN 'Pull'::text WHEN (bomitem.bomitem_issuemethod = 'S'::bpchar) THEN 'Push'::text ELSE NULL::text END AS issue_method, public.formatbooseq(p.item_id, bomitem.bomitem_booitem_seq_id) AS used_at, bomitem.bomitem_schedatwooper AS schedule_at_wo_operation, bomitem.bomitem_ecn AS ecn_number, bomitem.bomitem_notes AS notes, bomitem.bomitem_ref AS reference, CASE WHEN (bomitem.bomitem_subtype = 'N'::bpchar) THEN 'No'::text WHEN (bomitem.bomitem_subtype = 'I'::bpchar) THEN 'Item-Defined'::text WHEN (bomitem.bomitem_subtype = 'B'::bpchar) THEN 'BOM-Defined'::text ELSE NULL::text END AS substitutions, "char".char_name AS characteristic, bomitem.bomitem_value AS value FROM ((public.bomitem LEFT JOIN public.bomhead ON (((bomitem.bomitem_parent_item_id = bomhead.bomhead_item_id) AND (bomitem.bomitem_rev_id = bomhead.bomhead_rev_id)))) LEFT JOIN public."char" ON ((bomitem.bomitem_char_id = "char".char_id))), public.item p, public.item i, public.uom WHERE (((bomitem.bomitem_parent_item_id = p.item_id) AND (bomitem.bomitem_item_id = i.item_id)) AND (bomitem.bomitem_uom_id = uom.uom_id)) ORDER BY p.item_number, bomitem.bomitem_seqnumber;
83584
 
 
83585
 
 
83586
 
ALTER TABLE api.bomitem OWNER TO admin;
83587
 
 
83588
 
--
83589
 
--
83590
 
 
83591
 
COMMENT ON VIEW bomitem IS 'Bill of Material Item';
83592
 
 
83593
 
 
83594
 
--
83595
 
--
83596
 
 
83597
 
CREATE VIEW bomitemcomment AS
83598
 
    SELECT bomitem.bomitem_id, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM (public.bomitem LEFT JOIN public.bomhead ON (((bomitem.bomitem_parent_item_id = bomhead.bomhead_item_id) AND (bomitem.bomitem_rev_id = bomhead.bomhead_rev_id)))), public.item, public.cmnttype, public.comment WHERE ((((comment.comment_source = 'BMI'::text) AND (comment.comment_source_id = bomitem.bomitem_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)) AND (bomitem.bomitem_parent_item_id = item.item_id)) ORDER BY item.item_number, bomhead.bomhead_revision, bomitem.bomitem_seqnumber, comment.comment_date;
83599
 
 
83600
 
 
83601
 
ALTER TABLE api.bomitemcomment OWNER TO admin;
83602
 
 
83603
 
--
83604
 
--
83605
 
 
83606
 
COMMENT ON VIEW bomitemcomment IS 'Bill of Material Comment';
83607
 
 
83608
 
 
83609
 
SET search_path = public, pg_catalog;
83610
 
 
83611
 
--
83612
 
--
83613
 
 
83614
 
CREATE TABLE bomitemsub (
83615
 
    bomitemsub_id integer NOT NULL,
83616
 
    bomitemsub_bomitem_id integer NOT NULL,
83617
 
    bomitemsub_item_id integer NOT NULL,
83618
 
    bomitemsub_uomratio numeric(20,10) NOT NULL,
83619
 
    bomitemsub_rank integer NOT NULL
83620
 
);
83621
 
 
83622
 
 
83623
 
ALTER TABLE public.bomitemsub OWNER TO admin;
83624
 
 
83625
 
--
83626
 
--
83627
 
 
83628
 
COMMENT ON TABLE bomitemsub IS 'Bill of Materials (BOM) defined Substitutions information';
83629
 
 
83630
 
 
83631
 
SET search_path = api, pg_catalog;
83632
 
 
83633
 
--
83634
 
--
83635
 
 
83636
 
CREATE VIEW bomitemsubstitute AS
83637
 
    SELECT bomitem.bomitem_id, (p.item_number)::character varying AS bom_item_number, (bomhead.bomhead_revision)::character varying AS bom_revision, bomitem.bomitem_seqnumber AS sequence_number, (s.item_number)::character varying AS substitute_item_number, bomitemsub.bomitemsub_uomratio AS sub_parent_uom_ratio, bomitemsub.bomitemsub_rank AS ranking FROM public.item p, public.item s, (public.bomitem LEFT JOIN public.bomhead ON (((bomitem.bomitem_parent_item_id = bomhead.bomhead_item_id) AND (bomitem.bomitem_rev_id = bomhead.bomhead_rev_id)))), public.bomitemsub WHERE (((p.item_id = bomitem.bomitem_parent_item_id) AND (s.item_id = bomitemsub.bomitemsub_item_id)) AND (bomitemsub.bomitemsub_bomitem_id = bomitem.bomitem_id));
83638
 
 
83639
 
 
83640
 
ALTER TABLE api.bomitemsubstitute OWNER TO admin;
83641
 
 
83642
 
--
83643
 
--
83644
 
 
83645
 
COMMENT ON VIEW bomitemsubstitute IS 'Bill of Material Item Substitute';
83646
 
 
83647
 
 
83648
 
SET search_path = public, pg_catalog;
83649
 
 
83650
 
--
83651
 
--
83652
 
 
83653
 
CREATE TABLE budghead (
83654
 
    budghead_id integer NOT NULL,
83655
 
    budghead_name text NOT NULL,
83656
 
    budghead_descrip text,
83657
 
    CONSTRAINT budghead_budghead_name_check CHECK ((budghead_name <> ''::text))
83658
 
);
83659
 
 
83660
 
 
83661
 
ALTER TABLE public.budghead OWNER TO admin;
83662
 
 
83663
 
SET search_path = api, pg_catalog;
83664
 
 
83665
 
--
83666
 
--
83667
 
 
83668
 
CREATE VIEW budget AS
83669
 
    SELECT budghead.budghead_name AS name, budghead.budghead_descrip AS description FROM public.budghead ORDER BY budghead.budghead_name;
83670
 
 
83671
 
 
83672
 
ALTER TABLE api.budget OWNER TO admin;
83673
 
 
83674
 
--
83675
 
--
83676
 
 
83677
 
COMMENT ON VIEW budget IS 'Budget Header';
83678
 
 
83679
 
 
83680
 
SET search_path = public, pg_catalog;
83681
 
 
83682
 
--
83683
 
--
83684
 
 
83685
 
CREATE TABLE accnt (
83686
 
    accnt_id integer DEFAULT nextval(('accnt_accnt_id_seq'::text)::regclass) NOT NULL,
83687
 
    accnt_number text,
83688
 
    accnt_descrip text,
83689
 
    accnt_comments text,
83690
 
    accnt_profit text,
83691
 
    accnt_sub text,
83692
 
    accnt_type character(1) NOT NULL,
83693
 
    accnt_extref text,
83694
 
    accnt_company text,
83695
 
    accnt_forwardupdate boolean,
83696
 
    accnt_subaccnttype_code text,
83697
 
    accnt_curr_id integer DEFAULT basecurrid(),
83698
 
    accnt_active boolean DEFAULT true NOT NULL,
83699
 
    accnt_name text,
83700
 
    CONSTRAINT accnt_accnt_type_check CHECK ((accnt_type = ANY (ARRAY['A'::bpchar, 'E'::bpchar, 'L'::bpchar, 'Q'::bpchar, 'R'::bpchar])))
83701
 
);
83702
 
 
83703
 
 
83704
 
ALTER TABLE public.accnt OWNER TO admin;
83705
 
 
83706
 
--
83707
 
--
83708
 
 
83709
 
COMMENT ON TABLE accnt IS 'General Ledger (G/L) Account Number information';
83710
 
 
83711
 
 
83712
 
--
83713
 
--
83714
 
 
83715
 
CREATE TABLE budgitem (
83716
 
    budgitem_id integer NOT NULL,
83717
 
    budgitem_budghead_id integer NOT NULL,
83718
 
    budgitem_period_id integer NOT NULL,
83719
 
    budgitem_accnt_id integer NOT NULL,
83720
 
    budgitem_amount numeric(20,4) NOT NULL
83721
 
);
83722
 
 
83723
 
 
83724
 
ALTER TABLE public.budgitem OWNER TO admin;
83725
 
 
83726
 
--
83727
 
--
83728
 
 
83729
 
CREATE TABLE period (
83730
 
    period_id integer NOT NULL,
83731
 
    period_start date,
83732
 
    period_end date,
83733
 
    period_closed boolean,
83734
 
    period_freeze boolean,
83735
 
    period_initial boolean DEFAULT false,
83736
 
    period_name text,
83737
 
    period_yearperiod_id integer,
83738
 
    period_quarter integer,
83739
 
    period_number integer NOT NULL
83740
 
);
83741
 
 
83742
 
 
83743
 
ALTER TABLE public.period OWNER TO admin;
83744
 
 
83745
 
--
83746
 
--
83747
 
 
83748
 
COMMENT ON TABLE period IS 'Accounting Period information';
83749
 
 
83750
 
 
83751
 
SET search_path = api, pg_catalog;
83752
 
 
83753
 
--
83754
 
--
83755
 
 
83756
 
CREATE VIEW budgetentry AS
83757
 
    SELECT budghead.budghead_name AS name, public.formatglaccount(accnt.accnt_id) AS account, period.period_start, budgitem.budgitem_amount AS amount FROM public.budgitem, public.budghead, public.period, public.accnt WHERE (((budgitem.budgitem_budghead_id = budghead.budghead_id) AND (budgitem.budgitem_period_id = period.period_id)) AND (budgitem.budgitem_accnt_id = accnt.accnt_id)) ORDER BY budghead.budghead_name, period.period_start, public.formatglaccount(accnt.accnt_id);
83758
 
 
83759
 
 
83760
 
ALTER TABLE api.budgetentry OWNER TO admin;
83761
 
 
83762
 
--
83763
 
--
83764
 
 
83765
 
COMMENT ON VIEW budgetentry IS 'Budget Entry';
83766
 
 
83767
 
 
83768
 
SET search_path = public, pg_catalog;
83769
 
 
83770
 
--
83771
 
--
83772
 
 
83773
 
CREATE TABLE bankaccnt (
83774
 
    bankaccnt_id integer NOT NULL,
83775
 
    bankaccnt_name text NOT NULL,
83776
 
    bankaccnt_descrip text,
83777
 
    bankaccnt_bankname text,
83778
 
    bankaccnt_accntnumber text,
83779
 
    bankaccnt_ar boolean,
83780
 
    bankaccnt_ap boolean,
83781
 
    bankaccnt_nextchknum integer,
83782
 
    bankaccnt_type character(1),
83783
 
    bankaccnt_accnt_id integer,
83784
 
    bankaccnt_check_form_id integer,
83785
 
    bankaccnt_userec boolean,
83786
 
    bankaccnt_rec_accnt_id integer,
83787
 
    bankaccnt_curr_id integer DEFAULT basecurrid(),
83788
 
    bankaccnt_notes text,
83789
 
    bankaccnt_routing text DEFAULT ''::text NOT NULL,
83790
 
    bankaccnt_ach_enabled boolean DEFAULT false NOT NULL,
83791
 
    bankaccnt_ach_origin text DEFAULT ''::text NOT NULL,
83792
 
    bankaccnt_ach_genchecknum boolean DEFAULT false NOT NULL,
83793
 
    bankaccnt_ach_leadtime integer,
83794
 
    bankaccnt_ach_lastdate date,
83795
 
    bankaccnt_ach_lastfileid character(1),
83796
 
    bankaccnt_ach_origintype text,
83797
 
    bankaccnt_ach_originname text,
83798
 
    bankaccnt_ach_desttype text,
83799
 
    bankaccnt_ach_fed_dest text,
83800
 
    bankaccnt_ach_destname text,
83801
 
    bankaccnt_ach_dest text,
83802
 
    CONSTRAINT bankaccnt_bankaccnt_name_check CHECK ((bankaccnt_name <> ''::text))
83803
 
);
83804
 
 
83805
 
 
83806
 
ALTER TABLE public.bankaccnt OWNER TO admin;
83807
 
 
83808
 
--
83809
 
--
83810
 
 
83811
 
COMMENT ON TABLE bankaccnt IS 'Bank Account information';
83812
 
 
83813
 
 
83814
 
--
83815
 
--
83816
 
 
83817
 
CREATE TABLE cashrcpt (
83818
 
    cashrcpt_id integer NOT NULL,
83819
 
    cashrcpt_cust_id integer NOT NULL,
83820
 
    cashrcpt_amount numeric(20,2) NOT NULL,
83821
 
    cashrcpt_fundstype character(1) NOT NULL,
83822
 
    cashrcpt_docnumber text,
83823
 
    cashrcpt_bankaccnt_id integer NOT NULL,
83824
 
    cashrcpt_notes text,
83825
 
    cashrcpt_distdate date DEFAULT ('now'::text)::date,
83826
 
    cashrcpt_salescat_id integer DEFAULT (-1),
83827
 
    cashrcpt_curr_id integer DEFAULT basecurrid(),
83828
 
    cashrcpt_usecustdeposit boolean DEFAULT false NOT NULL,
83829
 
    cashrcpt_void boolean DEFAULT false NOT NULL,
83830
 
    cashrcpt_number text NOT NULL,
83831
 
    cashrcpt_docdate date,
83832
 
    cashrcpt_posted boolean DEFAULT false NOT NULL,
83833
 
    cashrcpt_posteddate date,
83834
 
    cashrcpt_postedby text,
83835
 
    cashrcpt_applydate date,
83836
 
    cashrcpt_discount numeric(20,2) DEFAULT 0.00 NOT NULL,
83837
 
    cashrcpt_curr_rate numeric NOT NULL,
83838
 
    cashrcpt_alt_curr_rate numeric,
83839
 
    CONSTRAINT cashrcpt_cashrcpt_number_check CHECK ((cashrcpt_number <> ''::text))
83840
 
);
83841
 
 
83842
 
 
83843
 
ALTER TABLE public.cashrcpt OWNER TO admin;
83844
 
 
83845
 
--
83846
 
--
83847
 
 
83848
 
COMMENT ON TABLE cashrcpt IS 'Temporary table for storing Cash Receipt information before Cash Receipts are posted';
83849
 
 
83850
 
 
83851
 
SET search_path = api, pg_catalog;
83852
 
 
83853
 
--
83854
 
--
83855
 
 
83856
 
CREATE VIEW cashreceipt AS
83857
 
    SELECT (custinfo.cust_number)::character varying AS customer_number, cashrcpt.cashrcpt_number AS cashreceipt_number, CASE WHEN (cashrcpt.cashrcpt_fundstype = 'C'::bpchar) THEN 'Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'T'::bpchar) THEN 'Certified Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'M'::bpchar) THEN 'Master Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'V'::bpchar) THEN 'Visa'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'A'::bpchar) THEN 'American Express'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'D'::bpchar) THEN 'Discover Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'R'::bpchar) THEN 'Other Credit Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'K'::bpchar) THEN 'Cash'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'W'::bpchar) THEN 'Wire Transfer'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'O'::bpchar) THEN 'Other'::character varying ELSE NULL::character varying END AS funds_type, (cashrcpt.cashrcpt_docnumber)::character varying AS check_document_number, custinfo.cust_name AS customer_name, m.addr_line1 AS customer_address, curr_symbol.curr_abbr AS currency, cashrcpt.cashrcpt_amount AS amount_received, bankaccnt.bankaccnt_name AS post_to, public.formatdate(cashrcpt.cashrcpt_distdate) AS distribution_date, CASE WHEN cashrcpt.cashrcpt_usecustdeposit THEN 'Customer Deposit'::text ELSE 'Credit Memo'::text END AS apply_balance_as, salescat.salescat_name AS sales_category, cashrcpt.cashrcpt_notes AS notes FROM ((((((public.cashrcpt LEFT JOIN public.custinfo ON ((custinfo.cust_id = cashrcpt.cashrcpt_cust_id))) LEFT JOIN public.cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN public.addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN public.curr_symbol ON ((curr_symbol.curr_id = cashrcpt.cashrcpt_curr_id))) LEFT JOIN public.bankaccnt ON ((bankaccnt.bankaccnt_id = cashrcpt.cashrcpt_bankaccnt_id))) LEFT JOIN public.salescat ON ((salescat.salescat_id = cashrcpt.cashrcpt_salescat_id)));
83858
 
 
83859
 
 
83860
 
ALTER TABLE api.cashreceipt OWNER TO admin;
83861
 
 
83862
 
--
83863
 
--
83864
 
 
83865
 
COMMENT ON VIEW cashreceipt IS '
83866
 
This view can be used as an interface to import Cash Receipt data directly  
83867
 
into the system.  Required fields will be checked and default values will be 
83868
 
populated';
83869
 
 
83870
 
 
83871
 
SET search_path = public, pg_catalog;
83872
 
 
83873
 
--
83874
 
--
83875
 
 
83876
 
CREATE TABLE cashrcptitem (
83877
 
    cashrcptitem_id integer NOT NULL,
83878
 
    cashrcptitem_cashrcpt_id integer NOT NULL,
83879
 
    cashrcptitem_aropen_id integer NOT NULL,
83880
 
    cashrcptitem_amount numeric(20,2) NOT NULL,
83881
 
    cashrcptitem_discount numeric(20,2) DEFAULT 0.00 NOT NULL,
83882
 
    cashrcptitem_applied boolean DEFAULT true
83883
 
);
83884
 
 
83885
 
 
83886
 
ALTER TABLE public.cashrcptitem OWNER TO admin;
83887
 
 
83888
 
--
83889
 
--
83890
 
 
83891
 
COMMENT ON TABLE cashrcptitem IS 'Temporary table for storing information about applications of Cash Receipts before Cash Receipts are posted';
83892
 
 
83893
 
 
83894
 
SET search_path = api, pg_catalog;
83895
 
 
83896
 
--
83897
 
--
83898
 
 
83899
 
CREATE VIEW cashreceiptapply AS
83900
 
    SELECT (custinfo.cust_number)::character varying AS customer_number, CASE WHEN (cashrcpt.cashrcpt_fundstype = 'C'::bpchar) THEN 'Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'T'::bpchar) THEN 'Certified Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'M'::bpchar) THEN 'Master Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'V'::bpchar) THEN 'Visa'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'A'::bpchar) THEN 'American Express'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'D'::bpchar) THEN 'Discover Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'R'::bpchar) THEN 'Other Credit Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'K'::bpchar) THEN 'Cash'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'W'::bpchar) THEN 'Wire Transfer'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'O'::bpchar) THEN 'Other'::character varying ELSE NULL::character varying END AS funds_type, (cashrcpt.cashrcpt_docnumber)::character varying AS check_document_number, (aropen.aropen_doctype)::character varying AS doc_type, (aropen.aropen_docnumber)::character varying AS doc_number, custinfo.cust_name AS customer_name, m.addr_line1 AS customer_address, public.formatdate(aropen.aropen_docdate) AS doc_date, public.formatdate(aropen.aropen_duedate) AS due_date, curr_symbol.curr_abbr AS currency, aropen.aropen_amount AS open_amount, cashrcptitem.cashrcptitem_amount AS amount_to_apply, cashrcptitem.cashrcptitem_discount FROM ((((((public.cashrcptitem LEFT JOIN public.cashrcpt ON ((cashrcpt.cashrcpt_id = cashrcptitem.cashrcptitem_cashrcpt_id))) LEFT JOIN public.custinfo ON ((custinfo.cust_id = cashrcpt.cashrcpt_cust_id))) LEFT JOIN public.cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN public.addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN public.curr_symbol ON ((curr_symbol.curr_id = cashrcpt.cashrcpt_curr_id))) LEFT JOIN public.aropen ON ((aropen.aropen_id = cashrcptitem.cashrcptitem_aropen_id)));
83901
 
 
83902
 
 
83903
 
ALTER TABLE api.cashreceiptapply OWNER TO admin;
83904
 
 
83905
 
--
83906
 
--
83907
 
 
83908
 
COMMENT ON VIEW cashreceiptapply IS '
83909
 
This view can be used as an interface to import Cash Receipt Application data directly  
83910
 
into the system.  Required fields will be checked and default values will be 
83911
 
populated';
83912
 
 
83913
 
 
83914
 
SET search_path = public, pg_catalog;
83915
 
 
83916
 
--
83917
 
--
83918
 
 
83919
 
CREATE TABLE cashrcptmisc (
83920
 
    cashrcptmisc_id integer NOT NULL,
83921
 
    cashrcptmisc_cashrcpt_id integer NOT NULL,
83922
 
    cashrcptmisc_accnt_id integer NOT NULL,
83923
 
    cashrcptmisc_amount numeric(20,2) NOT NULL,
83924
 
    cashrcptmisc_notes text
83925
 
);
83926
 
 
83927
 
 
83928
 
ALTER TABLE public.cashrcptmisc OWNER TO admin;
83929
 
 
83930
 
--
83931
 
--
83932
 
 
83933
 
COMMENT ON TABLE cashrcptmisc IS 'Cash Receipt Miscellaneous Application information';
83934
 
 
83935
 
 
83936
 
SET search_path = api, pg_catalog;
83937
 
 
83938
 
--
83939
 
--
83940
 
 
83941
 
CREATE VIEW cashreceiptapplymisc AS
83942
 
    SELECT (custinfo.cust_number)::character varying AS customer_number, CASE WHEN (cashrcpt.cashrcpt_fundstype = 'C'::bpchar) THEN 'Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'T'::bpchar) THEN 'Certified Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'M'::bpchar) THEN 'Master Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'V'::bpchar) THEN 'Visa'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'A'::bpchar) THEN 'American Express'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'D'::bpchar) THEN 'Discover Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'R'::bpchar) THEN 'Other Credit Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'K'::bpchar) THEN 'Cash'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'W'::bpchar) THEN 'Wire Transfer'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'O'::bpchar) THEN 'Other'::character varying ELSE NULL::character varying END AS funds_type, (cashrcpt.cashrcpt_docnumber)::character varying AS check_document_number, (public.formatglaccount(accnt.accnt_id))::character varying AS account, custinfo.cust_name AS customer_name, m.addr_line1 AS customer_address, accnt.accnt_descrip AS account_description, curr_symbol.curr_abbr AS currency, cashrcptmisc.cashrcptmisc_amount AS amount_to_distribute, cashrcptmisc.cashrcptmisc_notes AS notes FROM ((((((public.cashrcptmisc LEFT JOIN public.cashrcpt ON ((cashrcpt.cashrcpt_id = cashrcptmisc.cashrcptmisc_cashrcpt_id))) LEFT JOIN public.custinfo ON ((custinfo.cust_id = cashrcpt.cashrcpt_cust_id))) LEFT JOIN public.cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN public.addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN public.curr_symbol ON ((curr_symbol.curr_id = cashrcpt.cashrcpt_curr_id))) LEFT JOIN public.accnt ON ((accnt.accnt_id = cashrcptmisc.cashrcptmisc_accnt_id)));
83943
 
 
83944
 
 
83945
 
ALTER TABLE api.cashreceiptapplymisc OWNER TO admin;
83946
 
 
83947
 
--
83948
 
--
83949
 
 
83950
 
COMMENT ON VIEW cashreceiptapplymisc IS '
83951
 
This view can be used as an interface to import Cash Receipt Miscellaneous Application
83952
 
data directly into the system.  Required fields will be checked and default values
83953
 
will be populated';
83954
 
 
83955
 
 
83956
 
--
83957
 
--
83958
 
 
83959
 
CREATE VIEW contact AS
83960
 
    SELECT (cntct.cntct_number)::character varying AS contact_number, cntct.cntct_honorific AS honorific, cntct.cntct_first_name AS first, cntct.cntct_middle AS middle, cntct.cntct_last_name AS last, cntct.cntct_suffix AS suffix, cntct.cntct_initials AS initials, crmacct.crmacct_number AS crm_account, cntct.cntct_active AS active, cntct.cntct_title AS job_title, cntct.cntct_phone AS voice, cntct.cntct_phone2 AS alternate, cntct.cntct_fax AS fax, cntct.cntct_email AS email, cntct.cntct_webaddr AS web, ''::text AS contact_change, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postal_code, addr.addr_country AS country, cntct.cntct_notes AS notes, ''::text AS address_change FROM ((public.cntct LEFT JOIN public.addr ON ((cntct.cntct_addr_id = addr.addr_id))) LEFT JOIN public.crmacct ON ((cntct.cntct_crmacct_id = crmacct.crmacct_id)));
83961
 
 
83962
 
 
83963
 
ALTER TABLE api.contact OWNER TO admin;
83964
 
 
83965
 
--
83966
 
--
83967
 
 
83968
 
COMMENT ON VIEW contact IS 'Contact';
83969
 
 
83970
 
 
83971
 
--
83972
 
--
83973
 
 
83974
 
CREATE VIEW contactchar AS
83975
 
    SELECT cntct.cntct_number AS contact_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.cntct, public."char", public.charass WHERE ((('CNTCT'::text = charass.charass_target_type) AND (cntct.cntct_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id));
83976
 
 
83977
 
 
83978
 
ALTER TABLE api.contactchar OWNER TO admin;
83979
 
 
83980
 
--
83981
 
--
83982
 
 
83983
 
COMMENT ON VIEW contactchar IS 'Contact Characteristics';
83984
 
 
83985
 
 
83986
 
--
83987
 
--
83988
 
 
83989
 
CREATE VIEW contactcomment AS
83990
 
    SELECT cntct.cntct_number AS contact_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.cntct, public.cmnttype, public.comment WHERE (((comment.comment_source = 'T'::text) AND (comment.comment_source_id = cntct.cntct_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id));
83991
 
 
83992
 
 
83993
 
ALTER TABLE api.contactcomment OWNER TO admin;
83994
 
 
83995
 
--
83996
 
--
83997
 
 
83998
 
COMMENT ON VIEW contactcomment IS 'Contact Comment';
83999
 
 
84000
 
 
84001
 
--
84002
 
--
84003
 
 
84004
 
CREATE VIEW custchar AS
84005
 
    SELECT (custinfo.cust_number)::character varying AS customer_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.custinfo, public."char", public.charass WHERE ((('C'::text = charass.charass_target_type) AND (custinfo.cust_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id));
84006
 
 
84007
 
 
84008
 
ALTER TABLE api.custchar OWNER TO admin;
84009
 
 
84010
 
--
84011
 
--
84012
 
 
84013
 
COMMENT ON VIEW custchar IS 'Customer Characteristics';
84014
 
 
84015
 
 
84016
 
--
84017
 
--
84018
 
 
84019
 
CREATE VIEW custcomment AS
84020
 
    SELECT (custinfo.cust_number)::character varying AS customer_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.custinfo, public.cmnttype, public.comment WHERE (((comment.comment_source = 'C'::text) AND (comment.comment_source_id = custinfo.cust_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id));
84021
 
 
84022
 
 
84023
 
ALTER TABLE api.custcomment OWNER TO admin;
84024
 
 
84025
 
--
84026
 
--
84027
 
 
84028
 
COMMENT ON VIEW custcomment IS 'Customer Comment';
84029
 
 
84030
 
 
84031
 
SET search_path = public, pg_catalog;
84032
 
 
84033
 
--
84034
 
--
84035
 
 
84036
 
CREATE TABLE ccard (
84037
 
    ccard_id integer NOT NULL,
84038
 
    ccard_seq integer DEFAULT 10 NOT NULL,
84039
 
    ccard_cust_id integer NOT NULL,
84040
 
    ccard_active boolean DEFAULT true,
84041
 
    ccard_name bytea,
84042
 
    ccard_address1 bytea,
84043
 
    ccard_address2 bytea,
84044
 
    ccard_city bytea,
84045
 
    ccard_state bytea,
84046
 
    ccard_zip bytea,
84047
 
    ccard_country bytea,
84048
 
    ccard_number bytea,
84049
 
    ccard_debit boolean DEFAULT false,
84050
 
    ccard_month_expired bytea,
84051
 
    ccard_year_expired bytea,
84052
 
    ccard_type character(1) NOT NULL,
84053
 
    ccard_date_added timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL,
84054
 
    ccard_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL,
84055
 
    ccard_added_by_username text DEFAULT geteffectivextuser() NOT NULL,
84056
 
    ccard_last_updated_by_username text DEFAULT geteffectivextuser() NOT NULL
84057
 
);
84058
 
 
84059
 
 
84060
 
ALTER TABLE public.ccard OWNER TO admin;
84061
 
 
84062
 
--
84063
 
--
84064
 
 
84065
 
COMMENT ON TABLE ccard IS 'Credit Card Information - all bytea data is encrypted';
84066
 
 
84067
 
 
84068
 
SET search_path = api, pg_catalog;
84069
 
 
84070
 
--
84071
 
--
84072
 
 
84073
 
CREATE VIEW custcreditcard AS
84074
 
    SELECT (custinfo.cust_number)::character varying AS customer_number, CASE WHEN (ccard.ccard_type = 'V'::bpchar) THEN 'Visa'::text WHEN (ccard.ccard_type = 'M'::bpchar) THEN 'Master Card'::text WHEN (ccard.ccard_type = 'A'::bpchar) THEN 'American Express'::text WHEN (ccard.ccard_type = 'D'::bpchar) THEN 'Discover'::text ELSE 'Not Supported'::text END AS credit_card_type, ccard.ccard_active AS active, ccard.ccard_number AS credit_card_number, ccard.ccard_name AS name, ccard.ccard_address1 AS street_address1, ccard.ccard_address2 AS street_address2, ccard.ccard_city AS city, ccard.ccard_state AS state, ccard.ccard_zip AS postal_code, ccard.ccard_country AS country, ccard.ccard_month_expired AS expiration_month, ccard.ccard_year_expired AS expiration_year, ''::text AS key FROM public.ccard, public.custinfo WHERE (ccard.ccard_cust_id = custinfo.cust_id);
84075
 
 
84076
 
 
84077
 
ALTER TABLE api.custcreditcard OWNER TO admin;
84078
 
 
84079
 
--
84080
 
--
84081
 
 
84082
 
COMMENT ON VIEW custcreditcard IS 'Customer Credit Cards.';
84083
 
 
84084
 
 
84085
 
SET search_path = public, pg_catalog;
84086
 
 
84087
 
--
84088
 
--
84089
 
 
84090
 
CREATE TABLE custtype (
84091
 
    custtype_id integer DEFAULT nextval(('custtype_custtype_id_seq'::text)::regclass) NOT NULL,
84092
 
    custtype_code text NOT NULL,
84093
 
    custtype_descrip text NOT NULL,
84094
 
    custtype_char boolean DEFAULT false NOT NULL,
84095
 
    CONSTRAINT custtype_custtype_code_check CHECK ((custtype_code <> ''::text))
84096
 
);
84097
 
 
84098
 
 
84099
 
ALTER TABLE public.custtype OWNER TO admin;
84100
 
 
84101
 
--
84102
 
--
84103
 
 
84104
 
COMMENT ON TABLE custtype IS 'Customer Type information';
84105
 
 
84106
 
 
84107
 
--
84108
 
--
84109
 
 
84110
 
CREATE TABLE shipchrg (
84111
 
    shipchrg_id integer NOT NULL,
84112
 
    shipchrg_name text NOT NULL,
84113
 
    shipchrg_descrip text,
84114
 
    shipchrg_custfreight boolean,
84115
 
    shipchrg_handling character(1),
84116
 
    CONSTRAINT shipchrg_shipchrg_name_check CHECK ((shipchrg_name <> ''::text))
84117
 
);
84118
 
 
84119
 
 
84120
 
ALTER TABLE public.shipchrg OWNER TO admin;
84121
 
 
84122
 
--
84123
 
--
84124
 
 
84125
 
COMMENT ON TABLE shipchrg IS 'Shipping Charge information';
84126
 
 
84127
 
 
84128
 
--
84129
 
--
84130
 
 
84131
 
CREATE TABLE shipform (
84132
 
    shipform_id integer DEFAULT nextval(('"shipform_shipform_id_seq"'::text)::regclass) NOT NULL,
84133
 
    shipform_name text NOT NULL,
84134
 
    shipform_report_id integer,
84135
 
    shipform_report_name text,
84136
 
    CONSTRAINT shipform_shipform_name_check CHECK ((shipform_name <> ''::text))
84137
 
);
84138
 
 
84139
 
 
84140
 
ALTER TABLE public.shipform OWNER TO admin;
84141
 
 
84142
 
--
84143
 
--
84144
 
 
84145
 
COMMENT ON TABLE shipform IS 'Shipping Form information';
84146
 
 
84147
 
 
84148
 
--
84149
 
--
84150
 
 
84151
 
COMMENT ON COLUMN shipform.shipform_report_id IS 'Obsolete -- reference shipform_report_name instead.';
84152
 
 
84153
 
 
84154
 
SET search_path = api, pg_catalog;
84155
 
 
84156
 
--
84157
 
--
84158
 
 
84159
 
CREATE VIEW customer AS
84160
 
    SELECT (custinfo.cust_number)::character varying AS customer_number, custtype.custtype_code AS customer_type, custinfo.cust_name AS customer_name, custinfo.cust_active AS active, salesrep.salesrep_number AS sales_rep, (custinfo.cust_commprcnt * (100)::numeric) AS commission, custinfo.cust_shipvia AS ship_via, shipform.shipform_name AS ship_form, shipchrg.shipchrg_name AS shipping_charges, custinfo.cust_backorder AS accepts_backorders, custinfo.cust_partialship AS accepts_partial_shipments, custinfo.cust_ffshipto AS allow_free_form_shipto, custinfo.cust_ffbillto AS allow_free_form_billto, whsinfo.warehous_code AS preferred_selling_site, taxzone.taxzone_code AS default_tax_zone, terms.terms_code AS default_terms, CASE WHEN (custinfo.cust_balmethod = 'B'::bpchar) THEN 'Balance Forward'::text ELSE 'Open Item'::text END AS balance_method, custinfo.cust_discntprcnt AS default_discount, dc.curr_abbr AS default_currency, clc.curr_abbr AS credit_limit_currency, custinfo.cust_creditlmt AS credit_limit, CASE WHEN (COALESCE(custinfo.cust_gracedays, 0) > 0) THEN custinfo.cust_gracedays ELSE NULL::integer END AS alternate_grace_days, custinfo.cust_creditrating AS credit_rating, CASE WHEN (custinfo.cust_creditstatus = 'G'::bpchar) THEN 'In Good Standing'::text WHEN (custinfo.cust_creditstatus = 'W'::bpchar) THEN 'On Credit Warning'::text ELSE 'On Credit Hold'::text END AS credit_status, custinfo.cust_autoupdatestatus AS credit_status_exceed_warn, custinfo.cust_autoholdorders AS credit_status_exceed_hold, custinfo.cust_usespos AS uses_purchase_orders, custinfo.cust_blanketpos AS uses_blanket_pos, mc.cntct_number AS billing_contact_number, mc.cntct_honorific AS billing_contact_honorific, mc.cntct_first_name AS billing_contact_first, mc.cntct_middle AS billing_contact_middle, mc.cntct_last_name AS billing_contact_last, mc.cntct_suffix AS billing_contact_suffix, mc.cntct_title AS billing_contact_job_title, mc.cntct_phone AS billing_contact_voice, mc.cntct_phone2 AS billing_contact_alternate, mc.cntct_fax AS billing_contact_fax, mc.cntct_email AS billing_contact_email, mc.cntct_webaddr AS billing_contact_web, ''::text AS billing_contact_change, m.addr_number AS billing_contact_address_number, m.addr_line1 AS billing_contact_address1, m.addr_line2 AS billing_contact_address2, m.addr_line3 AS billing_contact_address3, m.addr_city AS billing_contact_city, m.addr_state AS billing_contact_state, m.addr_postalcode AS billing_contact_postalcode, m.addr_country AS billing_contact_country, ''::text AS billing_contact_address_change, cc.cntct_number AS correspond_contact_number, cc.cntct_honorific AS correspond_contact_honorific, cc.cntct_first_name AS correspond_contact_first, cc.cntct_middle AS correspond_contact_middle, cc.cntct_last_name AS correspond_contact_last, cc.cntct_suffix AS correspond_contact_suffix, cc.cntct_title AS correspond_contact_job_title, cc.cntct_phone AS correspond_contact_voice, cc.cntct_phone2 AS correspond_contact_alternate, cc.cntct_fax AS correspond_contact_fax, cc.cntct_email AS correspond_contact_email, cc.cntct_webaddr AS correspond_contact_web, ''::text AS correspond_contact_change, c.addr_number AS correspond_contact_address_number, c.addr_line1 AS correspond_contact_address1, c.addr_line2 AS correspond_contact_address2, c.addr_line3 AS correspond_contact_address3, c.addr_city AS correspond_contact_city, c.addr_state AS correspond_contact_state, c.addr_postalcode AS correspond_contact_postalcode, c.addr_country AS correspond_contact_country, ''::text AS correspond_contact_address_change, custinfo.cust_comments AS notes FROM ((((((((public.custinfo LEFT JOIN public.shipchrg ON ((custinfo.cust_shipchrg_id = shipchrg.shipchrg_id))) LEFT JOIN public.whsinfo ON ((custinfo.cust_preferred_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN public.addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN public.cntct cc ON ((custinfo.cust_corrcntct_id = cc.cntct_id))) LEFT JOIN public.addr c ON ((cc.cntct_addr_id = c.addr_id))) LEFT JOIN public.taxzone ON ((custinfo.cust_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.shipform ON ((custinfo.cust_shipform_id = shipform.shipform_id))), public.custtype, public.salesrep, public.curr_symbol dc, public.curr_symbol clc, public.terms WHERE (((((custinfo.cust_custtype_id = custtype.custtype_id) AND (custinfo.cust_salesrep_id = salesrep.salesrep_id)) AND (custinfo.cust_curr_id = dc.curr_id)) AND (custinfo.cust_creditlmt_curr_id = clc.curr_id)) AND (custinfo.cust_terms_id = terms.terms_id));
84161
 
 
84162
 
 
84163
 
ALTER TABLE api.customer OWNER TO admin;
84164
 
 
84165
 
--
84166
 
--
84167
 
 
84168
 
COMMENT ON VIEW customer IS 'Customer';
84169
 
 
84170
 
 
84171
 
SET search_path = public, pg_catalog;
84172
 
 
84173
 
--
84174
 
--
84175
 
 
84176
 
CREATE TABLE taxauth (
84177
 
    taxauth_id integer NOT NULL,
84178
 
    taxauth_code text NOT NULL,
84179
 
    taxauth_name text,
84180
 
    taxauth_extref text,
84181
 
    taxauth_addr_id integer,
84182
 
    taxauth_curr_id integer,
84183
 
    taxauth_county text,
84184
 
    taxauth_accnt_id integer,
84185
 
    CONSTRAINT taxauth_taxauth_code_check CHECK ((taxauth_code <> ''::text))
84186
 
);
84187
 
 
84188
 
 
84189
 
ALTER TABLE public.taxauth OWNER TO admin;
84190
 
 
84191
 
--
84192
 
--
84193
 
 
84194
 
COMMENT ON TABLE taxauth IS 'The Tax Authority table.';
84195
 
 
84196
 
 
84197
 
--
84198
 
--
84199
 
 
84200
 
COMMENT ON COLUMN taxauth.taxauth_curr_id IS 'The required currency for recording tax information as. NULL means no preference.';
84201
 
 
84202
 
 
84203
 
--
84204
 
--
84205
 
 
84206
 
CREATE TABLE taxreg (
84207
 
    taxreg_id integer NOT NULL,
84208
 
    taxreg_rel_id integer NOT NULL,
84209
 
    taxreg_rel_type character(1),
84210
 
    taxreg_taxauth_id integer,
84211
 
    taxreg_number text NOT NULL,
84212
 
    taxreg_taxzone_id integer,
84213
 
    taxreg_effective date DEFAULT startoftime(),
84214
 
    taxreg_expires date DEFAULT endoftime(),
84215
 
    taxreg_notes text DEFAULT ''::text,
84216
 
    CONSTRAINT taxreg_taxreg_number_check CHECK ((taxreg_number <> ''::text))
84217
 
);
84218
 
 
84219
 
 
84220
 
ALTER TABLE public.taxreg OWNER TO admin;
84221
 
 
84222
 
--
84223
 
--
84224
 
 
84225
 
COMMENT ON TABLE taxreg IS 'Stores Tax Registration numbers related to objects and a given tax authority. The rel_id specifies the object id and teh rel_type specifies the object type. See column comment for additional detail on types.';
84226
 
 
84227
 
 
84228
 
--
84229
 
--
84230
 
 
84231
 
COMMENT ON COLUMN taxreg.taxreg_rel_type IS 'The type of relation this record is for. Known values are C=Customer, V=Vendor, NULL=This Manufacturer in which case taxreg_rel_id is meaningless and should be -1.';
84232
 
 
84233
 
 
84234
 
SET search_path = api, pg_catalog;
84235
 
 
84236
 
--
84237
 
--
84238
 
 
84239
 
CREATE VIEW customertaxreg AS
84240
 
    SELECT (custinfo.cust_number)::character varying AS customer_number, (COALESCE(taxzone.taxzone_code, 'Any'::text))::character varying AS tax_zone, (taxauth.taxauth_code)::character varying AS tax_authority, taxreg.taxreg_number AS registration_number, CASE WHEN (taxreg.taxreg_effective = public.startoftime()) THEN 'Always'::text ELSE public.formatdate(taxreg.taxreg_effective) END AS start_date, CASE WHEN (taxreg.taxreg_expires = public.endoftime()) THEN 'Never'::text ELSE public.formatdate(taxreg.taxreg_expires) END AS end_date, taxreg.taxreg_notes AS notes FROM (((public.taxreg LEFT JOIN public.custinfo ON ((custinfo.cust_id = taxreg.taxreg_rel_id))) LEFT JOIN public.taxauth ON ((taxauth.taxauth_id = taxreg.taxreg_taxauth_id))) LEFT JOIN public.taxzone ON ((taxzone.taxzone_id = taxreg.taxreg_taxzone_id))) WHERE (taxreg.taxreg_rel_type = 'C'::bpchar) ORDER BY custinfo.cust_number, taxreg.taxreg_number;
84241
 
 
84242
 
 
84243
 
ALTER TABLE api.customertaxreg OWNER TO admin;
84244
 
 
84245
 
--
84246
 
--
84247
 
 
84248
 
COMMENT ON VIEW customertaxreg IS 'Customer Tax Registrations';
84249
 
 
84250
 
 
84251
 
--
84252
 
--
84253
 
 
84254
 
CREATE VIEW customertype AS
84255
 
    SELECT (custtype.custtype_code)::character varying AS code, custtype.custtype_descrip AS description, custtype.custtype_char AS enable_characteristics_profile FROM public.custtype ORDER BY custtype.custtype_code;
84256
 
 
84257
 
 
84258
 
ALTER TABLE api.customertype OWNER TO admin;
84259
 
 
84260
 
--
84261
 
--
84262
 
 
84263
 
COMMENT ON VIEW customertype IS 'Customer Type';
84264
 
 
84265
 
 
84266
 
--
84267
 
--
84268
 
 
84269
 
CREATE VIEW customertypechar AS
84270
 
    SELECT (custtype.custtype_code)::character varying AS customer_type, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value, charass.charass_default AS is_default FROM public.custtype, public."char", public.charass WHERE ((('CT'::text = charass.charass_target_type) AND (custtype.custtype_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id));
84271
 
 
84272
 
 
84273
 
ALTER TABLE api.customertypechar OWNER TO admin;
84274
 
 
84275
 
--
84276
 
--
84277
 
 
84278
 
COMMENT ON VIEW customertypechar IS 'Customer Type Characteristics';
84279
 
 
84280
 
 
84281
 
--
84282
 
--
84283
 
 
84284
 
CREATE VIEW custshipto AS
84285
 
    SELECT (custinfo.cust_number)::character varying AS customer_number, (shiptoinfo.shipto_num)::character varying AS shipto_number, shiptoinfo.shipto_active AS active, shiptoinfo.shipto_name AS name, shiptoinfo.shipto_default AS default_flag, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postal_code, addr.addr_country AS country, ''::text AS address_change, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS honorific, cntct.cntct_first_name AS first, cntct.cntct_middle AS middle, cntct.cntct_last_name AS last, cntct.cntct_suffix AS suffix, cntct.cntct_title AS job_title, cntct.cntct_phone AS phone, cntct.cntct_fax AS fax, cntct.cntct_email AS email, ''::text AS contact_change, salesrep.salesrep_number AS sales_rep, (shiptoinfo.shipto_commission * 100.0) AS commission, shipzone.shipzone_name AS zone, taxzone.taxzone_code AS tax_zone, shiptoinfo.shipto_shipvia AS ship_via, shipform.shipform_name AS ship_form, shipchrg.shipchrg_name AS shipping_charges, CASE WHEN (shiptoinfo.shipto_ediprofile_id = (-1)) THEN 'No EDI'::text WHEN (shiptoinfo.shipto_ediprofile_id = (-2)) THEN 'Use Customer Master'::text ELSE public.getediprofilename(shiptoinfo.shipto_ediprofile_id) END AS edi_profile, shiptoinfo.shipto_comments AS general_notes, shiptoinfo.shipto_shipcomments AS shipping_notes FROM public.custinfo, ((((((public.shiptoinfo LEFT JOIN public.shipchrg ON ((shiptoinfo.shipto_shipchrg_id = shipchrg.shipchrg_id))) LEFT JOIN public.cntct ON ((shiptoinfo.shipto_cntct_id = cntct.cntct_id))) LEFT JOIN public.addr ON ((shiptoinfo.shipto_addr_id = addr.addr_id))) LEFT JOIN public.taxzone ON ((shiptoinfo.shipto_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.shipzone ON ((shiptoinfo.shipto_shipzone_id = shipzone.shipzone_id))) LEFT JOIN public.salesrep ON ((shiptoinfo.shipto_salesrep_id = salesrep.salesrep_id))), public.shipform WHERE ((custinfo.cust_id = shiptoinfo.shipto_cust_id) AND (custinfo.cust_shipform_id = shipform.shipform_id));
84286
 
 
84287
 
 
84288
 
ALTER TABLE api.custshipto OWNER TO admin;
84289
 
 
84290
 
--
84291
 
--
84292
 
 
84293
 
COMMENT ON VIEW custshipto IS 'Customer Shipto Address';
84294
 
 
84295
 
 
84296
 
--
84297
 
--
84298
 
 
84299
 
CREATE VIEW custtax AS
84300
 
    SELECT (custinfo.cust_number)::character varying AS customer_number, (taxauth.taxauth_code)::character varying AS tax_authority, taxreg.taxreg_number AS registration_number FROM public.custinfo, public.taxauth, public.taxreg WHERE (((taxreg.taxreg_rel_type = 'C'::bpchar) AND (taxreg.taxreg_rel_id = custinfo.cust_id)) AND (taxreg.taxreg_taxauth_id = taxauth.taxauth_id));
84301
 
 
84302
 
 
84303
 
ALTER TABLE api.custtax OWNER TO admin;
84304
 
 
84305
 
--
84306
 
--
84307
 
 
84308
 
COMMENT ON VIEW custtax IS 'Customer Tax Registration';
84309
 
 
84310
 
 
84311
 
SET search_path = public, pg_catalog;
84312
 
 
84313
 
--
84314
 
--
84315
 
 
84316
 
CREATE TABLE dept (
84317
 
    dept_id integer NOT NULL,
84318
 
    dept_number text NOT NULL,
84319
 
    dept_name text NOT NULL,
84320
 
    CONSTRAINT dept_dept_number_check CHECK ((dept_number <> ''::text))
84321
 
);
84322
 
 
84323
 
 
84324
 
ALTER TABLE public.dept OWNER TO admin;
84325
 
 
84326
 
--
84327
 
--
84328
 
 
84329
 
COMMENT ON TABLE dept IS 'List of Departments';
84330
 
 
84331
 
 
84332
 
--
84333
 
--
84334
 
 
84335
 
CREATE TABLE emp (
84336
 
    emp_id integer NOT NULL,
84337
 
    emp_code text NOT NULL,
84338
 
    emp_number text NOT NULL,
84339
 
    emp_active boolean DEFAULT true NOT NULL,
84340
 
    emp_cntct_id integer,
84341
 
    emp_warehous_id integer,
84342
 
    emp_mgr_emp_id integer,
84343
 
    emp_wage_type text NOT NULL,
84344
 
    emp_wage numeric,
84345
 
    emp_wage_curr_id integer DEFAULT basecurrid(),
84346
 
    emp_wage_period text NOT NULL,
84347
 
    emp_dept_id integer,
84348
 
    emp_shift_id integer,
84349
 
    emp_notes text,
84350
 
    emp_image_id integer,
84351
 
    emp_username text,
84352
 
    emp_extrate numeric,
84353
 
    emp_extrate_period text NOT NULL,
84354
 
    emp_startdate date DEFAULT ('now'::text)::date,
84355
 
    emp_name text NOT NULL,
84356
 
    CONSTRAINT emp_check CHECK (((((COALESCE(emp_wage_type, ''::text) = ''::text) OR (COALESCE(emp_wage_type, ''::text) = 'H'::text)) OR (COALESCE(emp_wage_type, ''::text) = 'S'::text)) AND ((COALESCE(emp_wage, (0)::numeric) = (0)::numeric) OR ((COALESCE(emp_wage_type, ''::text) <> ''::text) AND (emp_wage IS NOT NULL))))),
84357
 
    CONSTRAINT emp_emp_code_check CHECK ((emp_code <> ''::text)),
84358
 
    CONSTRAINT emp_emp_number_check CHECK ((emp_number <> ''::text)),
84359
 
    CONSTRAINT emp_emp_wage_period_check CHECK ((((((((COALESCE(emp_wage_period, ''::text) = ''::text) OR (COALESCE(emp_wage_period, ''::text) = 'H'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'D'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'W'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'BW'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'M'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'Y'::text)))
84360
 
);
84361
 
 
84362
 
 
84363
 
ALTER TABLE public.emp OWNER TO admin;
84364
 
 
84365
 
--
84366
 
--
84367
 
 
84368
 
COMMENT ON TABLE emp IS 'Employee table describing the basic properties of an employee. Employees need not be system users.';
84369
 
 
84370
 
 
84371
 
--
84372
 
--
84373
 
 
84374
 
COMMENT ON COLUMN emp.emp_code IS 'Short, human-readable name for employee. This value is kept synchronized with usr_username and salesrep_number, and so is unique across all three tables emp, usr, and salesrep.';
84375
 
 
84376
 
 
84377
 
--
84378
 
--
84379
 
 
84380
 
COMMENT ON COLUMN emp.emp_number IS 'Official employee number. This might be used for ID badges, payroll accounting, or other purposes.';
84381
 
 
84382
 
 
84383
 
--
84384
 
--
84385
 
 
84386
 
COMMENT ON COLUMN emp.emp_mgr_emp_id IS 'Internal ID of this employee''s manager/supervisor.';
84387
 
 
84388
 
 
84389
 
--
84390
 
--
84391
 
 
84392
 
COMMENT ON COLUMN emp.emp_wage_type IS 'The nature of the wage or employment agreement. ''H'' indicates this employee is paid on an hourly basis (or some other period) while ''S'' indicates this employee is salaried.';
84393
 
 
84394
 
 
84395
 
--
84396
 
--
84397
 
 
84398
 
COMMENT ON COLUMN emp.emp_wage_period IS 'The periodicity of wage payment: ''H'' for hourly, ''D'' for daily, ''W'' for weekly, ''BW'' for biweekly, ''M'' for monthly, ''Y'' for yearly.';
84399
 
 
84400
 
 
84401
 
--
84402
 
--
84403
 
 
84404
 
COMMENT ON COLUMN emp.emp_username IS 'DEPRECATED - the relationship between Employee and User is now maintained through the crmacct table.';
84405
 
 
84406
 
 
84407
 
--
84408
 
--
84409
 
 
84410
 
COMMENT ON COLUMN emp.emp_extrate_period IS 'The periodicity of external rate payment: ''H'' for hourly, ''D'' for daily, ''W'' for weekly, ''BW'' for biweekly, ''M'' for monthly, ''Y'' for yearly.';
84411
 
 
84412
 
 
84413
 
--
84414
 
--
84415
 
 
84416
 
CREATE TABLE shift (
84417
 
    shift_id integer NOT NULL,
84418
 
    shift_number text NOT NULL,
84419
 
    shift_name text NOT NULL,
84420
 
    CONSTRAINT shift_shift_number_check CHECK ((shift_number <> ''::text))
84421
 
);
84422
 
 
84423
 
 
84424
 
ALTER TABLE public.shift OWNER TO admin;
84425
 
 
84426
 
--
84427
 
--
84428
 
 
84429
 
COMMENT ON TABLE shift IS 'List of work Shifts';
84430
 
 
84431
 
 
84432
 
SET search_path = api, pg_catalog;
84433
 
 
84434
 
--
84435
 
--
84436
 
 
84437
 
CREATE VIEW employee AS
84438
 
    SELECT (e.emp_code)::character varying AS code, (e.emp_number)::character varying AS number, e.emp_active AS active, e.emp_startdate AS start_date, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS honorific, cntct.cntct_first_name AS first, cntct.cntct_middle AS middle, cntct.cntct_last_name AS last, cntct.cntct_suffix AS suffix, cntct.cntct_title AS job_title, cntct.cntct_phone AS voice, cntct.cntct_phone2 AS alternate, cntct.cntct_fax AS fax, cntct.cntct_email AS email, cntct.cntct_webaddr AS web, ''::text AS contact_change, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postalcode, addr.addr_country AS country, ''::text AS address_change, whsinfo.warehous_code AS site, m.emp_code AS manager_code, CASE WHEN (e.emp_wage_type = 'H'::text) THEN 'Hourly'::text WHEN (e.emp_wage_type = 'S'::text) THEN 'Salaried'::text WHEN (e.emp_wage_type IS NULL) THEN NULL::text ELSE 'Error'::text END AS wage_type, e.emp_wage AS wage, curr_symbol.curr_abbr AS wage_currency, CASE WHEN (e.emp_wage_period = 'H'::text) THEN 'Hour'::text WHEN (e.emp_wage_period = 'D'::text) THEN 'Day'::text WHEN (e.emp_wage_period = 'W'::text) THEN 'Week'::text WHEN (e.emp_wage_period = 'BW'::text) THEN 'Biweek'::text WHEN (e.emp_wage_period = 'M'::text) THEN 'Month'::text WHEN (e.emp_wage_period = 'Y'::text) THEN 'Year'::text WHEN (e.emp_wage_period IS NULL) THEN NULL::text ELSE 'Error'::text END AS wage_period, dept.dept_number AS department, shift.shift_number AS shift, (crmacct.crmacct_usr_username IS NOT NULL) AS is_user, (salesrep.salesrep_id IS NOT NULL) AS is_salesrep, (vendinfo.vend_id IS NOT NULL) AS is_vendor, e.emp_notes AS notes, image.image_name AS image, e.emp_extrate AS rate, curr_symbol.curr_abbr AS billing_currency, CASE WHEN (e.emp_extrate_period = 'H'::text) THEN 'Hour'::text WHEN (e.emp_extrate_period = 'D'::text) THEN 'Day'::text WHEN (e.emp_extrate_period = 'W'::text) THEN 'Week'::text WHEN (e.emp_extrate_period = 'BW'::text) THEN 'Biweek'::text WHEN (e.emp_extrate_period = 'M'::text) THEN 'Month'::text WHEN (e.emp_extrate_period = 'Y'::text) THEN 'Year'::text WHEN (e.emp_extrate_period IS NULL) THEN NULL::text ELSE 'Error'::text END AS billing_period FROM (((((((((((public.emp e JOIN public.crmacct ON ((e.emp_id = crmacct.crmacct_emp_id))) LEFT JOIN public.cntct ON ((e.emp_cntct_id = cntct.cntct_id))) LEFT JOIN public.addr ON ((cntct.cntct_addr_id = addr.addr_id))) LEFT JOIN public.whsinfo ON ((e.emp_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.emp m ON ((e.emp_mgr_emp_id = m.emp_id))) LEFT JOIN public.dept ON ((e.emp_dept_id = dept.dept_id))) LEFT JOIN public.shift ON ((e.emp_shift_id = shift.shift_id))) LEFT JOIN public.salesrep ON ((crmacct.crmacct_salesrep_id = salesrep.salesrep_id))) LEFT JOIN public.vendinfo ON ((crmacct.crmacct_vend_id = vendinfo.vend_id))) LEFT JOIN public.image ON ((e.emp_image_id = image.image_id))) JOIN public.curr_symbol ON ((e.emp_wage_curr_id = curr_symbol.curr_id)));
84439
 
 
84440
 
 
84441
 
ALTER TABLE api.employee OWNER TO admin;
84442
 
 
84443
 
--
84444
 
--
84445
 
 
84446
 
COMMENT ON VIEW employee IS 'Employee';
84447
 
 
84448
 
 
84449
 
--
84450
 
--
84451
 
 
84452
 
CREATE VIEW employeechar AS
84453
 
    SELECT (emp.emp_code)::character varying AS employee_code, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.emp, public."char", public.charass WHERE ((('EMP'::text = charass.charass_target_type) AND (emp.emp_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id));
84454
 
 
84455
 
 
84456
 
ALTER TABLE api.employeechar OWNER TO admin;
84457
 
 
84458
 
--
84459
 
--
84460
 
 
84461
 
COMMENT ON VIEW employeechar IS 'Employee Characteristics';
84462
 
 
84463
 
 
84464
 
--
84465
 
--
84466
 
 
84467
 
CREATE VIEW employeecomment AS
84468
 
    SELECT (emp.emp_code)::character varying AS code, (cmnttype.cmnttype_name)::character varying AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.emp, public.cmnttype, public.comment WHERE (((comment.comment_source = 'EMP'::text) AND (comment.comment_source_id = emp.emp_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id));
84469
 
 
84470
 
 
84471
 
ALTER TABLE api.employeecomment OWNER TO admin;
84472
 
 
84473
 
--
84474
 
--
84475
 
 
84476
 
COMMENT ON VIEW employeecomment IS 'Employee Comment';
84477
 
 
84478
 
 
84479
 
SET search_path = public, pg_catalog;
84480
 
 
84481
 
--
84482
 
--
84483
 
 
84484
 
CREATE TABLE shipdata (
84485
 
    shipdata_cohead_number text NOT NULL,
84486
 
    shipdata_cosmisc_tracknum text NOT NULL,
84487
 
    shipdata_cosmisc_packnum_tracknum text NOT NULL,
84488
 
    shipdata_weight numeric(16,4),
84489
 
    shipdata_base_freight numeric(16,4),
84490
 
    shipdata_total_freight numeric(16,4),
84491
 
    shipdata_shipper text DEFAULT 'UPS'::text,
84492
 
    shipdata_billing_option text,
84493
 
    shipdata_package_type text,
84494
 
    shipdata_void_ind character(1) NOT NULL,
84495
 
    shipdata_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL,
84496
 
    shipdata_shiphead_number text,
84497
 
    shipdata_base_freight_curr_id integer DEFAULT basecurrid(),
84498
 
    shipdata_total_freight_curr_id integer DEFAULT basecurrid()
84499
 
);
84500
 
 
84501
 
 
84502
 
ALTER TABLE public.shipdata OWNER TO admin;
84503
 
 
84504
 
--
84505
 
--
84506
 
 
84507
 
COMMENT ON TABLE shipdata IS 'Shipping Interface information - note that the shipdata_cohead_nember is text and not int.  That is due to ODBC chopping off during the transfer';
84508
 
 
84509
 
 
84510
 
SET search_path = api, pg_catalog;
84511
 
 
84512
 
--
84513
 
--
84514
 
 
84515
 
CREATE VIEW extshipmaint AS
84516
 
    SELECT (shipdata.shipdata_cohead_number)::character varying AS so_number, (shipdata.shipdata_shiphead_number)::character varying AS shipment_number, (shipdata.shipdata_shipper)::character varying AS shipper, (shipdata.shipdata_cosmisc_packnum_tracknum)::character varying AS package_tracking_number, shipdata.shipdata_void_ind AS void, shipdata.shipdata_billing_option AS billing_option, shipdata.shipdata_weight AS weight, shipdata.shipdata_base_freight AS base_freight, base.curr_abbr AS base_freight_currency, shipdata.shipdata_total_freight AS total_freight, total.curr_abbr AS total_freight_currency, shipdata.shipdata_package_type AS package_type, shipdata.shipdata_cosmisc_tracknum AS tracking_number, shipdata.shipdata_lastupdated AS last_updated FROM public.shipdata, public.curr_symbol base, public.curr_symbol total WHERE ((shipdata.shipdata_base_freight_curr_id = base.curr_id) AND (shipdata.shipdata_total_freight_curr_id = total.curr_id)) ORDER BY shipdata.shipdata_cohead_number, shipdata.shipdata_shiphead_number;
84517
 
 
84518
 
 
84519
 
ALTER TABLE api.extshipmaint OWNER TO admin;
84520
 
 
84521
 
--
84522
 
--
84523
 
 
84524
 
COMMENT ON VIEW extshipmaint IS 'External Shipping Maintenance';
84525
 
 
84526
 
 
84527
 
SET search_path = public, pg_catalog;
84528
 
 
84529
 
--
84530
 
--
84531
 
 
84532
 
CREATE TABLE freightclass (
84533
 
    freightclass_id integer NOT NULL,
84534
 
    freightclass_code text NOT NULL,
84535
 
    freightclass_descrip text,
84536
 
    CONSTRAINT freightclass_freightclass_code_check CHECK ((freightclass_code <> ''::text))
84537
 
);
84538
 
 
84539
 
 
84540
 
ALTER TABLE public.freightclass OWNER TO admin;
84541
 
 
84542
 
--
84543
 
--
84544
 
 
84545
 
COMMENT ON TABLE freightclass IS 'This table is the freight price schedules.';
84546
 
 
84547
 
 
84548
 
--
84549
 
--
84550
 
 
84551
 
CREATE TABLE ipsfreight (
84552
 
    ipsfreight_id integer NOT NULL,
84553
 
    ipsfreight_ipshead_id integer NOT NULL,
84554
 
    ipsfreight_qtybreak numeric DEFAULT 0 NOT NULL,
84555
 
    ipsfreight_price numeric DEFAULT 0 NOT NULL,
84556
 
    ipsfreight_type character(1) NOT NULL,
84557
 
    ipsfreight_warehous_id integer,
84558
 
    ipsfreight_shipzone_id integer,
84559
 
    ipsfreight_freightclass_id integer,
84560
 
    ipsfreight_shipvia text
84561
 
);
84562
 
 
84563
 
 
84564
 
ALTER TABLE public.ipsfreight OWNER TO admin;
84565
 
 
84566
 
--
84567
 
--
84568
 
 
84569
 
CREATE TABLE ipshead (
84570
 
    ipshead_id integer DEFAULT nextval(('"ipshead_ipshead_id_seq"'::text)::regclass) NOT NULL,
84571
 
    ipshead_name text NOT NULL,
84572
 
    ipshead_descrip text,
84573
 
    ipshead_effective date,
84574
 
    ipshead_expires date,
84575
 
    ipshead_curr_id integer DEFAULT basecurrid() NOT NULL,
84576
 
    ipshead_updated date,
84577
 
    CONSTRAINT ipshead_ipshead_name_check CHECK ((ipshead_name <> ''::text))
84578
 
);
84579
 
 
84580
 
 
84581
 
ALTER TABLE public.ipshead OWNER TO admin;
84582
 
 
84583
 
--
84584
 
--
84585
 
 
84586
 
COMMENT ON TABLE ipshead IS 'Pricing Schedule header information';
84587
 
 
84588
 
 
84589
 
SET search_path = api, pg_catalog;
84590
 
 
84591
 
--
84592
 
--
84593
 
 
84594
 
CREATE VIEW freightpricingscheduleitem AS
84595
 
    SELECT (ipshead.ipshead_name)::character varying AS pricing_schedule, ipsfreight.ipsfreight_qtybreak AS qty_break, (qtyuom.uom_name)::character varying AS qty_uom, ipsfreight.ipsfreight_price AS price, CASE WHEN (ipsfreight.ipsfreight_type = 'F'::bpchar) THEN 'Flat Rate'::text ELSE 'Price Per UOM'::text END AS price_type, COALESCE(whsinfo.warehous_code, 'Any'::text) AS from_site, COALESCE(shipzone.shipzone_name, 'Any'::text) AS to_shipzone, COALESCE(ipsfreight.ipsfreight_shipvia, 'Any'::text) AS ship_via, COALESCE(freightclass.freightclass_code, 'Any'::text) AS freight_class FROM (((((public.ipsfreight JOIN public.ipshead ON ((ipsfreight.ipsfreight_ipshead_id = ipshead.ipshead_id))) LEFT JOIN public.uom qtyuom ON (qtyuom.uom_item_weight)) LEFT JOIN public.whsinfo ON ((whsinfo.warehous_id = ipsfreight.ipsfreight_warehous_id))) LEFT JOIN public.shipzone ON ((shipzone.shipzone_id = ipsfreight.ipsfreight_shipzone_id))) LEFT JOIN public.freightclass ON ((freightclass.freightclass_id = ipsfreight.ipsfreight_freightclass_id)));
84596
 
 
84597
 
 
84598
 
ALTER TABLE api.freightpricingscheduleitem OWNER TO admin;
84599
 
 
84600
 
--
84601
 
--
84602
 
 
84603
 
COMMENT ON VIEW freightpricingscheduleitem IS 'Freight Pricing Schedule Item';
84604
 
 
84605
 
 
84606
 
--
84607
 
--
84608
 
 
84609
 
CREATE VIEW glaccount AS
84610
 
    SELECT (accnt.accnt_company)::character varying AS company, (accnt.accnt_profit)::character varying AS profit_center, (accnt.accnt_number)::character varying AS account_number, (accnt.accnt_sub)::character varying AS sub_account, accnt.accnt_descrip AS description, accnt.accnt_extref AS ext_reference, CASE WHEN (accnt.accnt_type = 'A'::bpchar) THEN 'Asset'::text WHEN (accnt.accnt_type = 'L'::bpchar) THEN 'Liability'::text WHEN (accnt.accnt_type = 'E'::bpchar) THEN 'Expense'::text WHEN (accnt.accnt_type = 'R'::bpchar) THEN 'Revenue'::text WHEN (accnt.accnt_type = 'Q'::bpchar) THEN 'Equity'::text ELSE '?'::text END AS type, accnt.accnt_subaccnttype_code AS sub_type, accnt.accnt_forwardupdate AS forward_update_trial_balances, accnt.accnt_comments AS notes FROM public.accnt ORDER BY accnt.accnt_company, accnt.accnt_profit, accnt.accnt_number, accnt.accnt_sub;
84611
 
 
84612
 
 
84613
 
ALTER TABLE api.glaccount OWNER TO admin;
84614
 
 
84615
 
--
84616
 
--
84617
 
 
84618
 
COMMENT ON VIEW glaccount IS 'GL Account';
84619
 
 
84620
 
 
84621
 
SET search_path = public, pg_catalog;
84622
 
 
84623
 
--
84624
 
--
84625
 
 
84626
 
CREATE TABLE incdtcat (
84627
 
    incdtcat_id integer NOT NULL,
84628
 
    incdtcat_name text NOT NULL,
84629
 
    incdtcat_order integer,
84630
 
    incdtcat_descrip text,
84631
 
    incdtcat_ediprofile_id integer,
84632
 
    CONSTRAINT incdtcat_incdtcat_name_check CHECK ((incdtcat_name <> ''::text))
84633
 
);
84634
 
 
84635
 
 
84636
 
ALTER TABLE public.incdtcat OWNER TO admin;
84637
 
 
84638
 
--
84639
 
--
84640
 
 
84641
 
COMMENT ON TABLE incdtcat IS 'Incident Category table';
84642
 
 
84643
 
 
84644
 
--
84645
 
--
84646
 
 
84647
 
CREATE TABLE incdtpriority (
84648
 
    incdtpriority_id integer NOT NULL,
84649
 
    incdtpriority_name text NOT NULL,
84650
 
    incdtpriority_order integer,
84651
 
    incdtpriority_descrip text,
84652
 
    CONSTRAINT incdtpriority_incdtpriority_name_check CHECK ((incdtpriority_name <> ''::text))
84653
 
);
84654
 
 
84655
 
 
84656
 
ALTER TABLE public.incdtpriority OWNER TO admin;
84657
 
 
84658
 
--
84659
 
--
84660
 
 
84661
 
COMMENT ON TABLE incdtpriority IS 'Incident Priority table';
84662
 
 
84663
 
 
84664
 
--
84665
 
--
84666
 
 
84667
 
CREATE TABLE incdtresolution (
84668
 
    incdtresolution_id integer NOT NULL,
84669
 
    incdtresolution_name text NOT NULL,
84670
 
    incdtresolution_order integer,
84671
 
    incdtresolution_descrip text,
84672
 
    CONSTRAINT incdtresolution_incdtresolution_name_check CHECK ((incdtresolution_name <> ''::text))
84673
 
);
84674
 
 
84675
 
 
84676
 
ALTER TABLE public.incdtresolution OWNER TO admin;
84677
 
 
84678
 
--
84679
 
--
84680
 
 
84681
 
COMMENT ON TABLE incdtresolution IS 'Incident Resolution table';
84682
 
 
84683
 
 
84684
 
--
84685
 
--
84686
 
 
84687
 
CREATE TABLE incdtseverity (
84688
 
    incdtseverity_id integer NOT NULL,
84689
 
    incdtseverity_name text NOT NULL,
84690
 
    incdtseverity_order integer,
84691
 
    incdtseverity_descrip text,
84692
 
    CONSTRAINT incdtseverity_incdtseverity_name_check CHECK ((incdtseverity_name <> ''::text))
84693
 
);
84694
 
 
84695
 
 
84696
 
ALTER TABLE public.incdtseverity OWNER TO admin;
84697
 
 
84698
 
--
84699
 
--
84700
 
 
84701
 
COMMENT ON TABLE incdtseverity IS 'Incident Severity table';
84702
 
 
84703
 
 
84704
 
SET search_path = api, pg_catalog;
84705
 
 
84706
 
--
84707
 
--
84708
 
 
84709
 
CREATE VIEW incident AS
84710
 
    SELECT incdt.incdt_number AS incident_number, incdtcat.incdtcat_name AS category, incdt.incdt_summary AS description, crmacct.crmacct_number AS crm_account, incdt.incdt_assigned_username AS assigned_to, CASE WHEN (incdt.incdt_status = 'N'::bpchar) THEN 'New'::text WHEN (incdt.incdt_status = 'F'::bpchar) THEN 'Feedback'::text WHEN (incdt.incdt_status = 'C'::bpchar) THEN 'Confirmed'::text WHEN (incdt.incdt_status = 'A'::bpchar) THEN 'Assigned'::text WHEN (incdt.incdt_status = 'R'::bpchar) THEN 'Resolved'::text WHEN (incdt.incdt_status = 'L'::bpchar) THEN 'Closed'::text ELSE '?'::text END AS status, incdtseverity.incdtseverity_name AS severity, incdtpriority.incdtpriority_name AS priority, incdtresolution.incdtresolution_name AS resolution, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS honorific, cntct.cntct_first_name AS first, cntct.cntct_middle AS middle, cntct.cntct_last_name AS last, cntct.cntct_suffix AS suffix, cntct.cntct_title AS job_title, cntct.cntct_phone AS phone, cntct.cntct_fax AS fax, cntct.cntct_email AS email, ''::text AS contact_change, incdt.incdt_descrip AS notes, item.item_number, incdt.incdt_lotserial AS lot_serial_number, CASE WHEN (aropen.aropen_doctype = 'C'::bpchar) THEN 'C/M'::text WHEN (aropen.aropen_doctype = 'D'::bpchar) THEN 'D/M'::text WHEN (aropen.aropen_doctype = 'I'::bpchar) THEN 'Invoice'::text WHEN (aropen.aropen_doctype = 'R'::bpchar) THEN 'C/D'::text ELSE ''::text END AS ar_doc_type, aropen.aropen_docnumber AS ar_doc_number FROM ((((((((public.incdt LEFT JOIN public.incdtcat ON ((incdtcat.incdtcat_id = incdt.incdt_incdtcat_id))) LEFT JOIN public.crmacct ON ((crmacct.crmacct_id = incdt.incdt_crmacct_id))) LEFT JOIN public.incdtseverity ON ((incdtseverity.incdtseverity_id = incdt.incdt_incdtseverity_id))) LEFT JOIN public.incdtpriority ON ((incdtpriority.incdtpriority_id = incdt.incdt_incdtpriority_id))) LEFT JOIN public.incdtresolution ON ((incdtresolution.incdtresolution_id = incdt.incdt_incdtresolution_id))) LEFT JOIN public.cntct ON ((cntct.cntct_id = incdt.incdt_cntct_id))) LEFT JOIN public.item ON ((item.item_id = incdt.incdt_item_id))) LEFT JOIN public.aropen ON ((aropen.aropen_id = incdt.incdt_aropen_id)));
84711
 
 
84712
 
 
84713
 
ALTER TABLE api.incident OWNER TO admin;
84714
 
 
84715
 
--
84716
 
--
84717
 
 
84718
 
COMMENT ON VIEW incident IS 'Incident';
84719
 
 
84720
 
 
84721
 
--
84722
 
--
84723
 
 
84724
 
CREATE VIEW incidentchar AS
84725
 
    SELECT incdt.incdt_number AS incident_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.incdt, public."char", public.charass WHERE ((('INCDT'::text = charass.charass_target_type) AND (incdt.incdt_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id));
84726
 
 
84727
 
 
84728
 
ALTER TABLE api.incidentchar OWNER TO admin;
84729
 
 
84730
 
--
84731
 
--
84732
 
 
84733
 
COMMENT ON VIEW incidentchar IS 'Incident Characteristics';
84734
 
 
84735
 
 
84736
 
--
84737
 
--
84738
 
 
84739
 
CREATE VIEW incidentcomment AS
84740
 
    SELECT incdt.incdt_number AS incident_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text, comment.comment_public AS public FROM public.incdt, public.cmnttype, public.comment WHERE (((comment.comment_source = 'INCDT'::text) AND (comment.comment_source_id = incdt.incdt_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id));
84741
 
 
84742
 
 
84743
 
ALTER TABLE api.incidentcomment OWNER TO admin;
84744
 
 
84745
 
--
84746
 
--
84747
 
 
84748
 
COMMENT ON VIEW incidentcomment IS 'Incident Comment';
84749
 
 
84750
 
 
84751
 
--
84752
 
--
84753
 
 
84754
 
CREATE VIEW incidentfile AS
84755
 
    SELECT incdt.incdt_number AS incident_number, url.url_title AS title, url.url_url AS url FROM public.incdt, public.url WHERE ((incdt.incdt_id = url.url_source_id) AND (url.url_source = 'INCDT'::text));
84756
 
 
84757
 
 
84758
 
ALTER TABLE api.incidentfile OWNER TO admin;
84759
 
 
84760
 
--
84761
 
--
84762
 
 
84763
 
COMMENT ON VIEW incidentfile IS 'Incident File';
84764
 
 
84765
 
 
84766
 
--
84767
 
--
84768
 
 
84769
 
CREATE VIEW incidentimage AS
84770
 
    SELECT incdt.incdt_number AS incident_number, image.image_name FROM public.incdt, public.imageass, public.image WHERE (((incdt.incdt_id = imageass.imageass_source_id) AND (imageass.imageass_source = 'INCDT'::text)) AND (imageass.imageass_image_id = image.image_id));
84771
 
 
84772
 
 
84773
 
ALTER TABLE api.incidentimage OWNER TO admin;
84774
 
 
84775
 
--
84776
 
--
84777
 
 
84778
 
COMMENT ON VIEW incidentimage IS 'Incident Image';
84779
 
 
84780
 
 
84781
 
SET search_path = public, pg_catalog;
84782
 
 
84783
 
--
84784
 
--
84785
 
 
84786
 
CREATE TABLE classcode (
84787
 
    classcode_id integer DEFAULT nextval(('classcode_classcode_id_seq'::text)::regclass) NOT NULL,
84788
 
    classcode_code text NOT NULL,
84789
 
    classcode_descrip text,
84790
 
    classcode_mfg boolean,
84791
 
    classcode_creator text,
84792
 
    classcode_created timestamp without time zone,
84793
 
    classcode_modifier text,
84794
 
    classcode_modified timestamp without time zone,
84795
 
    classcode_type text,
84796
 
    CONSTRAINT classcode_classcode_code_check CHECK ((classcode_code <> ''::text))
84797
 
);
84798
 
 
84799
 
 
84800
 
ALTER TABLE public.classcode OWNER TO admin;
84801
 
 
84802
 
--
84803
 
--
84804
 
 
84805
 
COMMENT ON TABLE classcode IS 'Class Code information';
84806
 
 
84807
 
 
84808
 
--
84809
 
--
84810
 
 
84811
 
CREATE TABLE prodcat (
84812
 
    prodcat_id integer DEFAULT nextval(('prodcat_prodcat_id_seq'::text)::regclass) NOT NULL,
84813
 
    prodcat_code text NOT NULL,
84814
 
    prodcat_descrip text,
84815
 
    CONSTRAINT prodcat_prodcat_code_check CHECK ((prodcat_code <> ''::text))
84816
 
);
84817
 
 
84818
 
 
84819
 
ALTER TABLE public.prodcat OWNER TO admin;
84820
 
 
84821
 
--
84822
 
--
84823
 
 
84824
 
COMMENT ON TABLE prodcat IS 'Product Category information';
84825
 
 
84826
 
 
84827
 
SET search_path = api, pg_catalog;
84828
 
 
84829
 
--
84830
 
--
84831
 
 
84832
 
CREATE VIEW item AS
84833
 
    SELECT (item.item_number)::character varying AS item_number, item.item_active AS active, item.item_descrip1 AS description1, item.item_descrip2 AS description2, CASE WHEN (item.item_type = 'P'::bpchar) THEN 'Purchased'::text WHEN (item.item_type = 'M'::bpchar) THEN 'Manufactured'::text WHEN (item.item_type = 'J'::bpchar) THEN 'Job'::text WHEN (item.item_type = 'K'::bpchar) THEN 'Kit'::text WHEN (item.item_type = 'F'::bpchar) THEN 'Phantom'::text WHEN (item.item_type = 'R'::bpchar) THEN 'Reference'::text WHEN (item.item_type = 'S'::bpchar) THEN 'Costing'::text WHEN (item.item_type = 'T'::bpchar) THEN 'Tooling'::text WHEN (item.item_type = 'O'::bpchar) THEN 'Outside Process'::text WHEN (item.item_type = 'L'::bpchar) THEN 'Planning'::text WHEN (item.item_type = 'B'::bpchar) THEN 'Breeder'::text WHEN (item.item_type = 'C'::bpchar) THEN 'Co-Product'::text WHEN (item.item_type = 'Y'::bpchar) THEN 'By-Product'::text ELSE NULL::text END AS item_type, item.item_maxcost AS maximum_desired_cost, classcode.classcode_code AS class_code, i.uom_name AS inventory_uom, item.item_picklist AS pick_list_item, item.item_fractional AS fractional, item.item_config AS configured, item.item_sold AS item_is_sold, prodcat.prodcat_code AS product_category, item.item_exclusive AS exclusive, item.item_listprice AS list_price, item.item_listcost AS list_cost, p.uom_name AS list_price_uom, item.item_upccode AS upc_code, item.item_prodweight AS product_weight, item.item_packweight AS packaging_weight, item.item_comments AS notes, item.item_extdescrip AS ext_description FROM (public.item LEFT JOIN public.prodcat ON ((item.item_prodcat_id = prodcat.prodcat_id))), public.classcode, public.uom i, public.uom p WHERE (((item.item_classcode_id = classcode.classcode_id) AND (item.item_inv_uom_id = i.uom_id)) AND (item.item_price_uom_id = p.uom_id)) ORDER BY (item.item_number)::character varying;
84834
 
 
84835
 
 
84836
 
ALTER TABLE api.item OWNER TO admin;
84837
 
 
84838
 
--
84839
 
--
84840
 
 
84841
 
COMMENT ON VIEW item IS 'Item';
84842
 
 
84843
 
 
84844
 
SET search_path = public, pg_catalog;
84845
 
 
84846
 
--
84847
 
--
84848
 
 
84849
 
CREATE TABLE itemalias (
84850
 
    itemalias_id integer DEFAULT nextval(('"itemalias_itemalias_id_seq"'::text)::regclass) NOT NULL,
84851
 
    itemalias_item_id integer NOT NULL,
84852
 
    itemalias_number text NOT NULL,
84853
 
    itemalias_comments text,
84854
 
    itemalias_usedescrip boolean NOT NULL,
84855
 
    itemalias_descrip1 text,
84856
 
    itemalias_descrip2 text,
84857
 
    itemalias_crmacct_id integer,
84858
 
    CONSTRAINT itemalias_itemalias_number_check CHECK ((itemalias_number <> ''::text))
84859
 
);
84860
 
 
84861
 
 
84862
 
ALTER TABLE public.itemalias OWNER TO admin;
84863
 
 
84864
 
--
84865
 
--
84866
 
 
84867
 
COMMENT ON TABLE itemalias IS 'Item Alias information';
84868
 
 
84869
 
 
84870
 
--
84871
 
--
84872
 
 
84873
 
COMMENT ON COLUMN itemalias.itemalias_crmacct_id IS 'Associated crmacct for item alias.';
84874
 
 
84875
 
 
84876
 
SET search_path = api, pg_catalog;
84877
 
 
84878
 
--
84879
 
--
84880
 
 
84881
 
CREATE VIEW itemalias AS
84882
 
    SELECT (item.item_number)::character varying AS item_number, itemalias.itemalias_number AS alias_number, itemalias.itemalias_usedescrip AS use_description, itemalias.itemalias_descrip1 AS description1, itemalias.itemalias_descrip2 AS description2, itemalias.itemalias_comments AS comments FROM public.item, public.itemalias WHERE (item.item_id = itemalias.itemalias_item_id);
84883
 
 
84884
 
 
84885
 
ALTER TABLE api.itemalias OWNER TO admin;
84886
 
 
84887
 
--
84888
 
--
84889
 
 
84890
 
COMMENT ON VIEW itemalias IS 'Item Alias';
84891
 
 
84892
 
 
84893
 
--
84894
 
--
84895
 
 
84896
 
CREATE VIEW itemchar AS
84897
 
    SELECT (item.item_number)::character varying AS item_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value, charass.charass_default AS is_default FROM public.item, public."char", public.charass WHERE ((('I'::text = charass.charass_target_type) AND (item.item_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id));
84898
 
 
84899
 
 
84900
 
ALTER TABLE api.itemchar OWNER TO admin;
84901
 
 
84902
 
--
84903
 
--
84904
 
 
84905
 
COMMENT ON VIEW itemchar IS 'Item Characteristic';
84906
 
 
84907
 
 
84908
 
--
84909
 
--
84910
 
 
84911
 
CREATE VIEW itemcomment AS
84912
 
    SELECT (item.item_number)::character varying AS item_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.item, public.cmnttype, public.comment WHERE (((comment.comment_source = 'I'::text) AND (comment.comment_source_id = item.item_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id));
84913
 
 
84914
 
 
84915
 
ALTER TABLE api.itemcomment OWNER TO admin;
84916
 
 
84917
 
--
84918
 
--
84919
 
 
84920
 
COMMENT ON VIEW itemcomment IS 'Item Comments';
84921
 
 
84922
 
 
84923
 
SET search_path = public, pg_catalog;
84924
 
 
84925
 
--
84926
 
--
84927
 
 
84928
 
CREATE TABLE costelem (
84929
 
    costelem_id integer DEFAULT nextval(('costelem_costelem_id_seq'::text)::regclass) NOT NULL,
84930
 
    costelem_type text NOT NULL,
84931
 
    costelem_sys boolean,
84932
 
    costelem_po boolean,
84933
 
    costelem_active boolean,
84934
 
    costelem_exp_accnt_id integer,
84935
 
    costelem_cost_item_id integer,
84936
 
    CONSTRAINT costelem_costelem_type_check CHECK ((costelem_type <> ''::text))
84937
 
);
84938
 
 
84939
 
 
84940
 
ALTER TABLE public.costelem OWNER TO admin;
84941
 
 
84942
 
--
84943
 
--
84944
 
 
84945
 
COMMENT ON TABLE costelem IS 'Costing Element information';
84946
 
 
84947
 
 
84948
 
--
84949
 
--
84950
 
 
84951
 
CREATE TABLE itemcost (
84952
 
    itemcost_id integer DEFAULT nextval(('itemcost_itemcost_id_seq'::text)::regclass) NOT NULL,
84953
 
    itemcost_item_id integer NOT NULL,
84954
 
    itemcost_costelem_id integer NOT NULL,
84955
 
    itemcost_lowlevel boolean DEFAULT false NOT NULL,
84956
 
    itemcost_stdcost numeric(16,6) DEFAULT 0 NOT NULL,
84957
 
    itemcost_posted date,
84958
 
    itemcost_actcost numeric(16,6) DEFAULT 0 NOT NULL,
84959
 
    itemcost_updated date,
84960
 
    itemcost_curr_id integer DEFAULT basecurrid() NOT NULL
84961
 
);
84962
 
 
84963
 
 
84964
 
ALTER TABLE public.itemcost OWNER TO admin;
84965
 
 
84966
 
--
84967
 
--
84968
 
 
84969
 
COMMENT ON TABLE itemcost IS 'Item Cost information';
84970
 
 
84971
 
 
84972
 
SET search_path = api, pg_catalog;
84973
 
 
84974
 
--
84975
 
--
84976
 
 
84977
 
CREATE VIEW itemcost AS
84978
 
    SELECT (item.item_number)::character varying(100) AS item_number, (costelem.costelem_type)::character varying(100) AS costing_element, itemcost.itemcost_actcost AS actual_cost, curr_symbol.curr_abbr AS currency, false AS post_to_standard FROM (((public.itemcost LEFT JOIN public.item ON ((itemcost.itemcost_item_id = item.item_id))) LEFT JOIN public.costelem ON ((itemcost.itemcost_costelem_id = costelem.costelem_id))) LEFT JOIN public.curr_symbol ON ((itemcost.itemcost_curr_id = curr_symbol.curr_id))) ORDER BY (item.item_number)::character varying(100), (costelem.costelem_type)::character varying(100);
84979
 
 
84980
 
 
84981
 
ALTER TABLE api.itemcost OWNER TO admin;
84982
 
 
84983
 
--
84984
 
--
84985
 
 
84986
 
COMMENT ON VIEW itemcost IS 'Item Cost';
84987
 
 
84988
 
 
84989
 
--
84990
 
--
84991
 
 
84992
 
CREATE VIEW itemfile AS
84993
 
    SELECT (item.item_number)::character varying AS item_number, url.url_title AS title, url.url_url AS url FROM public.item, public.url WHERE ((item.item_id = url.url_source_id) AND (url.url_source = 'I'::text));
84994
 
 
84995
 
 
84996
 
ALTER TABLE api.itemfile OWNER TO admin;
84997
 
 
84998
 
--
84999
 
--
85000
 
 
85001
 
COMMENT ON VIEW itemfile IS 'Item File';
85002
 
 
85003
 
 
85004
 
--
85005
 
--
85006
 
 
85007
 
CREATE VIEW itemimage AS
85008
 
    SELECT (item.item_number)::character varying AS item_number, CASE WHEN (imageass.imageass_purpose = 'P'::bpchar) THEN 'Product Description'::text WHEN (imageass.imageass_purpose = 'I'::bpchar) THEN 'Inventory Description'::text WHEN (imageass.imageass_purpose = 'E'::bpchar) THEN 'Engineering Reference'::text WHEN (imageass.imageass_purpose = 'M'::bpchar) THEN 'Miscellaneous'::text ELSE 'Other'::text END AS purpose, image.image_name FROM public.item, public.imageass, public.image WHERE (((item.item_id = imageass.imageass_source_id) AND (imageass.imageass_source = 'I'::text)) AND (imageass.imageass_image_id = image.image_id));
85009
 
 
85010
 
 
85011
 
ALTER TABLE api.itemimage OWNER TO admin;
85012
 
 
85013
 
--
85014
 
--
85015
 
 
85016
 
COMMENT ON VIEW itemimage IS 'Item Image';
85017
 
 
85018
 
 
85019
 
SET search_path = public, pg_catalog;
85020
 
 
85021
 
--
85022
 
--
85023
 
 
85024
 
CREATE TABLE costcat (
85025
 
    costcat_id integer DEFAULT nextval(('costcat_costcat_id_seq'::text)::regclass) NOT NULL,
85026
 
    costcat_code text NOT NULL,
85027
 
    costcat_descrip text,
85028
 
    costcat_asset_accnt_id integer,
85029
 
    costcat_liability_accnt_id integer,
85030
 
    costcat_adjustment_accnt_id integer,
85031
 
    costcat_matusage_accnt_id integer,
85032
 
    costcat_purchprice_accnt_id integer,
85033
 
    costcat_laboroverhead_accnt_id integer,
85034
 
    costcat_scrap_accnt_id integer,
85035
 
    costcat_invcost_accnt_id integer,
85036
 
    costcat_wip_accnt_id integer,
85037
 
    costcat_shipasset_accnt_id integer,
85038
 
    costcat_mfgscrap_accnt_id integer,
85039
 
    costcat_transform_accnt_id integer,
85040
 
    costcat_freight_accnt_id integer,
85041
 
    costcat_toliability_accnt_id integer,
85042
 
    costcat_exp_accnt_id integer,
85043
 
    CONSTRAINT costcat_costcat_code_check CHECK ((costcat_code <> ''::text))
85044
 
);
85045
 
 
85046
 
 
85047
 
ALTER TABLE public.costcat OWNER TO admin;
85048
 
 
85049
 
--
85050
 
--
85051
 
 
85052
 
COMMENT ON TABLE costcat IS 'Cost Category information';
85053
 
 
85054
 
 
85055
 
--
85056
 
--
85057
 
 
85058
 
CREATE TABLE plancode (
85059
 
    plancode_id integer DEFAULT nextval(('plancode_plancode_id_seq'::text)::regclass) NOT NULL,
85060
 
    plancode_code text NOT NULL,
85061
 
    plancode_name text,
85062
 
    plancode_mpsexplosion character(1),
85063
 
    plancode_consumefcst boolean,
85064
 
    plancode_mrpexcp_resched boolean,
85065
 
    plancode_mrpexcp_delete boolean,
85066
 
    CONSTRAINT plancode_plancode_code_check CHECK ((plancode_code <> ''::text))
85067
 
);
85068
 
 
85069
 
 
85070
 
ALTER TABLE public.plancode OWNER TO admin;
85071
 
 
85072
 
--
85073
 
--
85074
 
 
85075
 
COMMENT ON TABLE plancode IS 'Planner Code information';
85076
 
 
85077
 
 
85078
 
SET search_path = api, pg_catalog;
85079
 
 
85080
 
--
85081
 
--
85082
 
 
85083
 
CREATE VIEW itemsite AS
85084
 
    SELECT (item.item_number)::character varying AS item_number, (whsinfo.warehous_code)::character varying AS site, itemsite.itemsite_active AS active, itemsite.itemsite_wosupply AS wo_supplied_at_site, itemsite.itemsite_createwo AS create_wos, itemsite.itemsite_posupply AS po_supplied_at_site, itemsite.itemsite_createpr AS create_prs, itemsite.itemsite_createsopr AS create_soprs, itemsite.itemsite_createsopo AS create_sopos, itemsite.itemsite_dropship AS dropship, itemsite.itemsite_sold AS sold_from_site, itemsite.itemsite_soldranking AS ranking, CASE WHEN (itemsite.itemsite_costmethod = 'N'::bpchar) THEN 'None'::text WHEN (itemsite.itemsite_costmethod = 'A'::bpchar) THEN 'Average'::text WHEN (itemsite.itemsite_costmethod = 'S'::bpchar) THEN 'Standard'::text WHEN (itemsite.itemsite_costmethod = 'J'::bpchar) THEN 'Job'::text ELSE NULL::text END AS cost_method, CASE WHEN (itemsite.itemsite_controlmethod = 'N'::bpchar) THEN 'None'::text WHEN (itemsite.itemsite_controlmethod = 'R'::bpchar) THEN 'Regular'::text WHEN (itemsite.itemsite_controlmethod = 'S'::bpchar) THEN 'Serial #'::text WHEN (itemsite.itemsite_controlmethod = 'L'::bpchar) THEN 'Lot #'::text ELSE NULL::text END AS control_method, plancode.plancode_code AS planner_code, costcat.costcat_code AS cost_category, itemsite.itemsite_stocked AS stocked, itemsite.itemsite_abcclass AS abc_class, itemsite.itemsite_autoabcclass AS allow_automatic_updates, itemsite.itemsite_cyclecountfreq AS cycl_cnt_freq, itemsite.itemsite_eventfence AS event_fence, itemsite.itemsite_loccntrl AS multiple_location_control, public.formatlocationname(itemsite.itemsite_location_id) AS location, public.formatlocationname(itemsite.itemsite_recvlocation_id) AS receive_location, public.formatlocationname(itemsite.itemsite_issuelocation_id) AS issue_location, itemsite.itemsite_location_dist AS auto_distr_location, itemsite.itemsite_recvlocation_dist AS auto_distr_receive_location, itemsite.itemsite_issuelocation_dist AS auto_distr_issue_location, itemsite.itemsite_location AS user_defined_location, itemsite.itemsite_location_comments AS location_comment, itemsite.itemsite_disallowblankwip AS disallow_blank_wip_locations, itemsite.itemsite_useparams AS enforce_order_parameters, itemsite.itemsite_reorderlevel AS reorder_level, itemsite.itemsite_ordertoqty AS order_up_to, itemsite.itemsite_minordqty AS minimum_order, itemsite.itemsite_maxordqty AS maximum_order, itemsite.itemsite_multordqty AS order_multiple, itemsite.itemsite_useparamsmanual AS enforce_on_manual_orders, CASE WHEN (itemsite.itemsite_planning_type = 'N'::bpchar) THEN 'None'::text WHEN (itemsite.itemsite_planning_type = 'M'::bpchar) THEN 'MRP'::text WHEN (itemsite.itemsite_planning_type = 'S'::bpchar) THEN 'MPS'::text ELSE NULL::text END AS planning_system, itemsite.itemsite_ordergroup AS group_mps_mrp_orders, itemsite.itemsite_ordergroup_first AS first_group, itemsite.itemsite_mps_timefence AS mps_time_fence, itemsite.itemsite_leadtime AS lead_time, itemsite.itemsite_safetystock AS safety_stock, COALESCE((SELECT whsinfo.warehous_code FROM (public.itemsite supplysite JOIN public.whsinfo ON ((whsinfo.warehous_id = supplysite.itemsite_warehous_id))) WHERE (supplysite.itemsite_id = itemsite.itemsite_supply_itemsite_id)), 'None'::text) AS supplied_from_site, itemsite.itemsite_notes AS notes, itemsite.itemsite_perishable AS perishable, itemsite.itemsite_warrpurc AS require_warranty, itemsite.itemsite_autoreg AS auto_register FROM ((((public.itemsite JOIN public.item ON ((item.item_id = itemsite.itemsite_item_id))) JOIN public.plancode ON ((plancode.plancode_id = itemsite.itemsite_plancode_id))) JOIN public.costcat ON ((costcat.costcat_id = itemsite.itemsite_costcat_id))) JOIN public.whsinfo ON ((whsinfo.warehous_id = itemsite.itemsite_warehous_id)));
85085
 
 
85086
 
 
85087
 
ALTER TABLE api.itemsite OWNER TO admin;
85088
 
 
85089
 
--
85090
 
--
85091
 
 
85092
 
COMMENT ON VIEW itemsite IS 'Item Site';
85093
 
 
85094
 
 
85095
 
--
85096
 
--
85097
 
 
85098
 
CREATE VIEW itemsitecomment AS
85099
 
    SELECT (item.item_number)::character varying AS item_number, (whsinfo.warehous_code)::character varying AS site, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.itemsite, public.item, public.whsinfo, public.cmnttype, public.comment WHERE ((itemsite.itemsite_item_id = item.item_id) AND ((((itemsite.itemsite_warehous_id = whsinfo.warehous_id) AND (comment.comment_source = 'IS'::text)) AND (comment.comment_source_id = itemsite.itemsite_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)));
85100
 
 
85101
 
 
85102
 
ALTER TABLE api.itemsitecomment OWNER TO admin;
85103
 
 
85104
 
--
85105
 
--
85106
 
 
85107
 
COMMENT ON VIEW itemsitecomment IS 'Item Site Comments';
85108
 
 
85109
 
 
85110
 
SET search_path = public, pg_catalog;
85111
 
 
85112
 
--
85113
 
--
85114
 
 
85115
 
CREATE TABLE contrct (
85116
 
    contrct_id integer NOT NULL,
85117
 
    contrct_number text NOT NULL,
85118
 
    contrct_vend_id integer NOT NULL,
85119
 
    contrct_descrip text,
85120
 
    contrct_effective date NOT NULL,
85121
 
    contrct_expires date NOT NULL,
85122
 
    contrct_note text
85123
 
);
85124
 
 
85125
 
 
85126
 
ALTER TABLE public.contrct OWNER TO admin;
85127
 
 
85128
 
--
85129
 
--
85130
 
 
85131
 
COMMENT ON TABLE contrct IS 'Grouping of Item Sources for a Vendor with common effective and expiration dates.';
85132
 
 
85133
 
 
85134
 
--
85135
 
--
85136
 
 
85137
 
COMMENT ON COLUMN contrct.contrct_id IS 'Sequence identifier for contract.';
85138
 
 
85139
 
 
85140
 
--
85141
 
--
85142
 
 
85143
 
COMMENT ON COLUMN contrct.contrct_number IS 'User defined identifier for contract.';
85144
 
 
85145
 
 
85146
 
--
85147
 
--
85148
 
 
85149
 
COMMENT ON COLUMN contrct.contrct_vend_id IS 'Vendor associated with contract.';
85150
 
 
85151
 
 
85152
 
--
85153
 
--
85154
 
 
85155
 
COMMENT ON COLUMN contrct.contrct_descrip IS 'Description for contract.';
85156
 
 
85157
 
 
85158
 
--
85159
 
--
85160
 
 
85161
 
COMMENT ON COLUMN contrct.contrct_effective IS 'Effective date for contract.  Constraint for overlap.';
85162
 
 
85163
 
 
85164
 
--
85165
 
--
85166
 
 
85167
 
COMMENT ON COLUMN contrct.contrct_expires IS 'Expiration date for contract.  Constraint for overlap.';
85168
 
 
85169
 
 
85170
 
--
85171
 
--
85172
 
 
85173
 
COMMENT ON COLUMN contrct.contrct_note IS 'Notes for contract.';
85174
 
 
85175
 
 
85176
 
--
85177
 
--
85178
 
 
85179
 
CREATE TABLE itemsrc (
85180
 
    itemsrc_id integer DEFAULT nextval(('"itemsrc_itemsrc_id_seq"'::text)::regclass) NOT NULL,
85181
 
    itemsrc_item_id integer NOT NULL,
85182
 
    itemsrc_vend_id integer NOT NULL,
85183
 
    itemsrc_vend_item_number text,
85184
 
    itemsrc_vend_item_descrip text,
85185
 
    itemsrc_comments text,
85186
 
    itemsrc_vend_uom text NOT NULL,
85187
 
    itemsrc_invvendoruomratio numeric(20,10) NOT NULL,
85188
 
    itemsrc_minordqty numeric(18,6) NOT NULL,
85189
 
    itemsrc_multordqty numeric(18,6) NOT NULL,
85190
 
    itemsrc_leadtime integer NOT NULL,
85191
 
    itemsrc_ranking integer NOT NULL,
85192
 
    itemsrc_active boolean NOT NULL,
85193
 
    itemsrc_manuf_name text DEFAULT ''::text NOT NULL,
85194
 
    itemsrc_manuf_item_number text DEFAULT ''::text NOT NULL,
85195
 
    itemsrc_manuf_item_descrip text,
85196
 
    itemsrc_default boolean,
85197
 
    itemsrc_upccode text,
85198
 
    itemsrc_effective date DEFAULT startoftime() NOT NULL,
85199
 
    itemsrc_expires date DEFAULT endoftime() NOT NULL,
85200
 
    itemsrc_contrct_id integer,
85201
 
    itemsrc_contrct_max numeric(18,6) DEFAULT 0.0 NOT NULL,
85202
 
    itemsrc_contrct_min numeric(18,6) DEFAULT 0.0 NOT NULL
85203
 
);
85204
 
 
85205
 
 
85206
 
ALTER TABLE public.itemsrc OWNER TO admin;
85207
 
 
85208
 
--
85209
 
--
85210
 
 
85211
 
COMMENT ON TABLE itemsrc IS 'Item Source information';
85212
 
 
85213
 
 
85214
 
--
85215
 
--
85216
 
 
85217
 
COMMENT ON COLUMN itemsrc.itemsrc_effective IS 'Effective date for item source.  Constraint for overlap.';
85218
 
 
85219
 
 
85220
 
--
85221
 
--
85222
 
 
85223
 
COMMENT ON COLUMN itemsrc.itemsrc_expires IS 'Expiration date for item source.  Constraint for overlap.';
85224
 
 
85225
 
 
85226
 
--
85227
 
--
85228
 
 
85229
 
COMMENT ON COLUMN itemsrc.itemsrc_contrct_id IS 'Associated contract for item source.  Inherits effective, expiration dates.';
85230
 
 
85231
 
 
85232
 
SET search_path = api, pg_catalog;
85233
 
 
85234
 
--
85235
 
--
85236
 
 
85237
 
CREATE VIEW itemsource AS
85238
 
    SELECT (item.item_number)::character varying AS item_number, (vendinfo.vend_number)::character varying AS vendor, itemsrc.itemsrc_vend_item_number AS vendor_item_number, itemsrc.itemsrc_active AS active, itemsrc.itemsrc_default, itemsrc.itemsrc_vend_uom AS vendor_uom, itemsrc.itemsrc_invvendoruomratio AS inventory_vendor_uom_ratio, itemsrc.itemsrc_minordqty AS minimum_order, itemsrc.itemsrc_multordqty AS order_multiple, itemsrc.itemsrc_ranking AS vendor_ranking, itemsrc.itemsrc_leadtime AS lead_time, itemsrc.itemsrc_comments AS notes, itemsrc.itemsrc_vend_item_descrip AS vendor_description, itemsrc.itemsrc_manuf_name AS manufacturer_name, itemsrc.itemsrc_manuf_item_number AS manufacturer_item_number, itemsrc.itemsrc_manuf_item_descrip AS manufacturer_description, itemsrc.itemsrc_upccode AS bar_code, contrct.contrct_number AS contract_number, itemsrc.itemsrc_effective AS effective_date, itemsrc.itemsrc_expires AS expires_date FROM (((public.itemsrc LEFT JOIN public.item ON ((itemsrc.itemsrc_item_id = item.item_id))) LEFT JOIN public.vendinfo ON ((itemsrc.itemsrc_vend_id = vendinfo.vend_id))) LEFT JOIN public.contrct ON ((itemsrc.itemsrc_contrct_id = contrct.contrct_id))) ORDER BY (item.item_number)::character varying(100), (vendinfo.vend_number)::character varying(100);
85239
 
 
85240
 
 
85241
 
ALTER TABLE api.itemsource OWNER TO admin;
85242
 
 
85243
 
--
85244
 
--
85245
 
 
85246
 
COMMENT ON VIEW itemsource IS 'Item Source';
85247
 
 
85248
 
 
85249
 
SET search_path = public, pg_catalog;
85250
 
 
85251
 
--
85252
 
--
85253
 
 
85254
 
CREATE TABLE itemsrcp (
85255
 
    itemsrcp_id integer DEFAULT nextval(('itemsrcp_itemsrcp_id_seq'::text)::regclass) NOT NULL,
85256
 
    itemsrcp_itemsrc_id integer NOT NULL,
85257
 
    itemsrcp_qtybreak numeric(18,6) NOT NULL,
85258
 
    itemsrcp_price numeric(16,6),
85259
 
    itemsrcp_updated date,
85260
 
    itemsrcp_curr_id integer DEFAULT basecurrid() NOT NULL,
85261
 
    itemsrcp_dropship boolean DEFAULT false NOT NULL,
85262
 
    itemsrcp_warehous_id integer DEFAULT (-1) NOT NULL,
85263
 
    itemsrcp_type character(1) NOT NULL,
85264
 
    itemsrcp_discntprcnt numeric(16,6),
85265
 
    itemsrcp_fixedamtdiscount numeric(16,6),
85266
 
    CONSTRAINT valid_itemsrcp_type CHECK ((itemsrcp_type = ANY (ARRAY['N'::bpchar, 'D'::bpchar])))
85267
 
);
85268
 
 
85269
 
 
85270
 
ALTER TABLE public.itemsrcp OWNER TO admin;
85271
 
 
85272
 
--
85273
 
--
85274
 
 
85275
 
COMMENT ON TABLE itemsrcp IS 'Item Source Price information';
85276
 
 
85277
 
 
85278
 
--
85279
 
--
85280
 
 
85281
 
COMMENT ON COLUMN itemsrcp.itemsrcp_dropship IS 'Used to determine if item source price applies only to drop ship purchase orders.';
85282
 
 
85283
 
 
85284
 
--
85285
 
--
85286
 
 
85287
 
COMMENT ON COLUMN itemsrcp.itemsrcp_warehous_id IS 'Used to determine if item source price applies only to specific site on purchase orders.';
85288
 
 
85289
 
 
85290
 
--
85291
 
--
85292
 
 
85293
 
COMMENT ON COLUMN itemsrcp.itemsrcp_type IS 'Pricing type for item source price.  Valid values are N-nominal and D-discount.';
85294
 
 
85295
 
 
85296
 
--
85297
 
--
85298
 
 
85299
 
COMMENT ON COLUMN itemsrcp.itemsrcp_discntprcnt IS 'Discount percent for item source price.';
85300
 
 
85301
 
 
85302
 
--
85303
 
--
85304
 
 
85305
 
COMMENT ON COLUMN itemsrcp.itemsrcp_fixedamtdiscount IS 'Fixed amount discount for item source price.';
85306
 
 
85307
 
 
85308
 
SET search_path = api, pg_catalog;
85309
 
 
85310
 
--
85311
 
--
85312
 
 
85313
 
CREATE VIEW itemsourceprice AS
85314
 
    SELECT (item.item_number)::character varying AS item_number, (vendinfo.vend_number)::character varying AS vendor, itemsrcp.itemsrcp_qtybreak AS qty_break, CASE WHEN (itemsrcp.itemsrcp_type = 'N'::bpchar) THEN 'Nominal'::text ELSE 'Discount'::text END AS pricing_type, CASE WHEN (itemsrcp.itemsrcp_warehous_id = (-1)) THEN 'All'::text ELSE whsinfo.warehous_code END AS pricing_site, itemsrcp.itemsrcp_dropship AS dropship_only, itemsrcp.itemsrcp_price AS price_per_unit, curr_symbol.curr_abbr AS currency, (itemsrcp.itemsrcp_discntprcnt * 100.0) AS discount_percent, itemsrcp.itemsrcp_fixedamtdiscount AS discount_fixed_amount FROM (((((public.itemsrcp LEFT JOIN public.itemsrc ON ((itemsrc.itemsrc_id = itemsrcp.itemsrcp_itemsrc_id))) LEFT JOIN public.item ON ((itemsrc.itemsrc_item_id = item.item_id))) LEFT JOIN public.vendinfo ON ((itemsrc.itemsrc_vend_id = vendinfo.vend_id))) LEFT JOIN public.curr_symbol ON ((itemsrcp.itemsrcp_curr_id = curr_symbol.curr_id))) LEFT JOIN public.whsinfo ON ((itemsrcp.itemsrcp_warehous_id = whsinfo.warehous_id))) ORDER BY (item.item_number)::character varying(100), (vendinfo.vend_number)::character varying(100);
85315
 
 
85316
 
 
85317
 
ALTER TABLE api.itemsourceprice OWNER TO admin;
85318
 
 
85319
 
--
85320
 
--
85321
 
 
85322
 
COMMENT ON VIEW itemsourceprice IS 'Item Source Price';
85323
 
 
85324
 
 
85325
 
SET search_path = public, pg_catalog;
85326
 
 
85327
 
--
85328
 
--
85329
 
 
85330
 
CREATE TABLE itemsub (
85331
 
    itemsub_id integer DEFAULT nextval(('itemsub_itemsub_id_seq'::text)::regclass) NOT NULL,
85332
 
    itemsub_parent_item_id integer NOT NULL,
85333
 
    itemsub_sub_item_id integer NOT NULL,
85334
 
    itemsub_uomratio numeric(20,10) NOT NULL,
85335
 
    itemsub_rank integer NOT NULL
85336
 
);
85337
 
 
85338
 
 
85339
 
ALTER TABLE public.itemsub OWNER TO admin;
85340
 
 
85341
 
--
85342
 
--
85343
 
 
85344
 
COMMENT ON TABLE itemsub IS 'Item Substitutes information';
85345
 
 
85346
 
 
85347
 
SET search_path = api, pg_catalog;
85348
 
 
85349
 
--
85350
 
--
85351
 
 
85352
 
CREATE VIEW itemsubstitute AS
85353
 
    SELECT (p.item_number)::character varying AS root_item_number, (s.item_number)::character varying AS substitute_item_number, itemsub.itemsub_uomratio AS sub_parent_uom_ratio, itemsub.itemsub_rank AS ranking FROM public.item p, public.item s, public.itemsub WHERE ((p.item_id = itemsub.itemsub_parent_item_id) AND (s.item_id = itemsub.itemsub_sub_item_id));
85354
 
 
85355
 
 
85356
 
ALTER TABLE api.itemsubstitute OWNER TO admin;
85357
 
 
85358
 
--
85359
 
--
85360
 
 
85361
 
COMMENT ON VIEW itemsubstitute IS 'Item Substitute';
85362
 
 
85363
 
 
85364
 
SET search_path = public, pg_catalog;
85365
 
 
85366
 
--
85367
 
--
85368
 
 
85369
 
CREATE TABLE itemtax (
85370
 
    itemtax_id integer NOT NULL,
85371
 
    itemtax_item_id integer NOT NULL,
85372
 
    itemtax_taxtype_id integer NOT NULL,
85373
 
    itemtax_taxzone_id integer
85374
 
);
85375
 
 
85376
 
 
85377
 
ALTER TABLE public.itemtax OWNER TO admin;
85378
 
 
85379
 
--
85380
 
--
85381
 
 
85382
 
COMMENT ON TABLE itemtax IS 'This table associates tax types in a specified tax authority for the given item.';
85383
 
 
85384
 
 
85385
 
SET search_path = api, pg_catalog;
85386
 
 
85387
 
--
85388
 
--
85389
 
 
85390
 
CREATE VIEW itemtaxtype AS
85391
 
    SELECT (item.item_number)::character varying AS item_number, CASE WHEN (taxzone.taxzone_id IS NULL) THEN 'Any'::character varying ELSE (taxzone.taxzone_code)::character varying END AS tax_zone, taxtype.taxtype_name AS tax_type FROM public.item, (public.itemtax LEFT JOIN public.taxzone ON ((itemtax.itemtax_taxzone_id = taxzone.taxzone_id))), public.taxtype WHERE ((item.item_id = itemtax.itemtax_item_id) AND (itemtax.itemtax_taxtype_id = taxtype.taxtype_id));
85392
 
 
85393
 
 
85394
 
ALTER TABLE api.itemtaxtype OWNER TO admin;
85395
 
 
85396
 
--
85397
 
--
85398
 
 
85399
 
COMMENT ON VIEW itemtaxtype IS 'Item Tax Type';
85400
 
 
85401
 
 
85402
 
SET search_path = public, pg_catalog;
85403
 
 
85404
 
--
85405
 
--
85406
 
 
85407
 
CREATE TABLE itemuomconv (
85408
 
    itemuomconv_id integer NOT NULL,
85409
 
    itemuomconv_item_id integer NOT NULL,
85410
 
    itemuomconv_from_uom_id integer NOT NULL,
85411
 
    itemuomconv_from_value numeric(20,10) NOT NULL,
85412
 
    itemuomconv_to_uom_id integer NOT NULL,
85413
 
    itemuomconv_to_value numeric(20,10) NOT NULL,
85414
 
    itemuomconv_fractional boolean DEFAULT false NOT NULL,
85415
 
    CONSTRAINT itemuomconv_uom CHECK ((itemuomconv_from_uom_id <> itemuomconv_to_uom_id))
85416
 
);
85417
 
 
85418
 
 
85419
 
ALTER TABLE public.itemuomconv OWNER TO admin;
85420
 
 
85421
 
--
85422
 
--
85423
 
 
85424
 
COMMENT ON TABLE itemuomconv IS 'UOM conversion information. From Unit to To Unit with a value per.';
85425
 
 
85426
 
 
85427
 
SET search_path = api, pg_catalog;
85428
 
 
85429
 
--
85430
 
--
85431
 
 
85432
 
CREATE VIEW itemuomconversion AS
85433
 
    SELECT (item.item_number)::character varying AS item_number, (f.uom_name)::character varying AS uom, itemuomconv.itemuomconv_from_value AS uom_value, p.uom_name AS per_uom, itemuomconv.itemuomconv_to_value AS per_uom_value, itemuomconv.itemuomconv_fractional AS fractional, public.fetchitemuomconvtypes(itemuomconv.itemuomconv_id) AS selected_types FROM public.item, public.itemuomconv, public.uom f, public.uom p WHERE (((item.item_id = itemuomconv.itemuomconv_item_id) AND (itemuomconv.itemuomconv_from_uom_id = f.uom_id)) AND (itemuomconv.itemuomconv_to_uom_id = p.uom_id));
85434
 
 
85435
 
 
85436
 
ALTER TABLE api.itemuomconversion OWNER TO admin;
85437
 
 
85438
 
--
85439
 
--
85440
 
 
85441
 
COMMENT ON VIEW itemuomconversion IS 'Item Unit of Measure Conversion';
85442
 
 
85443
 
 
85444
 
SET search_path = public, pg_catalog;
85445
 
 
85446
 
--
85447
 
--
85448
 
 
85449
 
CREATE TABLE gltrans (
85450
 
    gltrans_id integer DEFAULT nextval(('"gltrans_gltrans_id_seq"'::text)::regclass) NOT NULL,
85451
 
    gltrans_exported boolean,
85452
 
    gltrans_created timestamp with time zone,
85453
 
    gltrans_date date NOT NULL,
85454
 
    gltrans_sequence integer,
85455
 
    gltrans_accnt_id integer NOT NULL,
85456
 
    gltrans_source text,
85457
 
    gltrans_docnumber text,
85458
 
    gltrans_misc_id integer,
85459
 
    gltrans_amount numeric(20,2) NOT NULL,
85460
 
    gltrans_notes text,
85461
 
    gltrans_journalnumber integer,
85462
 
    gltrans_posted boolean NOT NULL,
85463
 
    gltrans_doctype text,
85464
 
    gltrans_rec boolean DEFAULT false NOT NULL,
85465
 
    gltrans_username text DEFAULT geteffectivextuser() NOT NULL,
85466
 
    gltrans_deleted boolean DEFAULT false
85467
 
);
85468
 
 
85469
 
 
85470
 
ALTER TABLE public.gltrans OWNER TO admin;
85471
 
 
85472
 
--
85473
 
--
85474
 
 
85475
 
COMMENT ON TABLE gltrans IS 'General Ledger (G/L) transaction information';
85476
 
 
85477
 
 
85478
 
SET search_path = api, pg_catalog;
85479
 
 
85480
 
--
85481
 
--
85482
 
 
85483
 
CREATE VIEW journalentry AS
85484
 
    SELECT curr_symbol.curr_abbr AS currency, c.gltrans_amount AS amount, c.gltrans_date AS dist_date, c.gltrans_docnumber AS doc_number, public.formatglaccount(da.accnt_id) AS debit, public.formatglaccount(ca.accnt_id) AS credit, c.gltrans_notes AS notes FROM public.gltrans d, public.gltrans c, public.accnt da, public.accnt ca, public.curr_symbol WHERE ((((((((d.gltrans_sequence = c.gltrans_sequence) AND (d.gltrans_accnt_id = da.accnt_id)) AND (c.gltrans_accnt_id = ca.accnt_id)) AND (d.gltrans_amount < (0)::numeric)) AND (c.gltrans_amount > (0)::numeric)) AND (d.gltrans_doctype = 'JE'::text)) AND (c.gltrans_doctype = 'JE'::text)) AND (curr_symbol.curr_id = public.basecurrid())) ORDER BY d.gltrans_date DESC;
85485
 
 
85486
 
 
85487
 
ALTER TABLE api.journalentry OWNER TO admin;
85488
 
 
85489
 
--
85490
 
--
85491
 
 
85492
 
COMMENT ON VIEW journalentry IS 'Journal Entry';
85493
 
 
85494
 
 
85495
 
SET search_path = public, pg_catalog;
85496
 
 
85497
 
--
85498
 
--
85499
 
 
85500
 
CREATE TABLE location (
85501
 
    location_id integer DEFAULT nextval(('location_location_id_seq'::text)::regclass) NOT NULL,
85502
 
    location_warehous_id integer NOT NULL,
85503
 
    location_name text NOT NULL,
85504
 
    location_descrip text,
85505
 
    location_restrict boolean,
85506
 
    location_netable boolean,
85507
 
    location_whsezone_id integer,
85508
 
    location_aisle text,
85509
 
    location_rack text,
85510
 
    location_bin text,
85511
 
    location_formatname text,
85512
 
    location_usable boolean
85513
 
);
85514
 
 
85515
 
 
85516
 
ALTER TABLE public.location OWNER TO admin;
85517
 
 
85518
 
--
85519
 
--
85520
 
 
85521
 
COMMENT ON TABLE location IS 'Warehouse Location information';
85522
 
 
85523
 
 
85524
 
--
85525
 
--
85526
 
 
85527
 
CREATE TABLE whsezone (
85528
 
    whsezone_id integer NOT NULL,
85529
 
    whsezone_warehous_id integer NOT NULL,
85530
 
    whsezone_name text NOT NULL,
85531
 
    whsezone_descrip text
85532
 
);
85533
 
 
85534
 
 
85535
 
ALTER TABLE public.whsezone OWNER TO admin;
85536
 
 
85537
 
--
85538
 
--
85539
 
 
85540
 
COMMENT ON TABLE whsezone IS 'Warehouse Zone information';
85541
 
 
85542
 
 
85543
 
SET search_path = api, pg_catalog;
85544
 
 
85545
 
--
85546
 
--
85547
 
 
85548
 
CREATE VIEW location AS
85549
 
    SELECT (whsinfo.warehous_code)::character varying AS site, (location.location_aisle)::character varying AS aisle, (location.location_rack)::character varying AS rack, (location.location_bin)::character varying AS bin, (location.location_name)::character varying AS location, whsezone.whsezone_name AS zone, location.location_netable AS netable, location.location_restrict AS restricted, location.location_descrip AS description FROM ((public.location LEFT JOIN public.whsinfo ON ((whsinfo.warehous_id = location.location_warehous_id))) LEFT JOIN public.whsezone ON ((whsezone.whsezone_id = location.location_whsezone_id)));
85550
 
 
85551
 
 
85552
 
ALTER TABLE api.location OWNER TO admin;
85553
 
 
85554
 
--
85555
 
--
85556
 
 
85557
 
COMMENT ON VIEW location IS 'Location';
85558
 
 
85559
 
 
85560
 
--
85561
 
--
85562
 
 
85563
 
CREATE VIEW misccounttag AS
85564
 
    SELECT 'This view is for inserts only'::text AS site, 'This view is for inserts only'::text AS item_number, (0)::numeric AS quantity, 'This view is for inserts only'::text AS comment;
85565
 
 
85566
 
 
85567
 
ALTER TABLE api.misccounttag OWNER TO admin;
85568
 
 
85569
 
--
85570
 
--
85571
 
 
85572
 
COMMENT ON VIEW misccounttag IS 'Miscellaneous Count Tag';
85573
 
 
85574
 
 
85575
 
--
85576
 
--
85577
 
 
85578
 
CREATE VIEW pricingschedule AS
85579
 
    SELECT (ipshead.ipshead_name)::character varying AS name, ipshead.ipshead_descrip AS description, public.formatdate(ipshead.ipshead_effective, 'Always'::text) AS effective, public.formatdate(ipshead.ipshead_expires, 'Never'::text) AS expires, curr_symbol.curr_abbr AS currency FROM public.ipshead, public.curr_symbol WHERE (curr_symbol.curr_id = ipshead.ipshead_curr_id);
85580
 
 
85581
 
 
85582
 
ALTER TABLE api.pricingschedule OWNER TO admin;
85583
 
 
85584
 
--
85585
 
--
85586
 
 
85587
 
COMMENT ON VIEW pricingschedule IS 'Pricing Schedule';
85588
 
 
85589
 
 
85590
 
SET search_path = public, pg_catalog;
85591
 
 
85592
 
--
85593
 
--
85594
 
 
85595
 
CREATE TABLE ipsass (
85596
 
    ipsass_id integer NOT NULL,
85597
 
    ipsass_ipshead_id integer NOT NULL,
85598
 
    ipsass_cust_id integer,
85599
 
    ipsass_custtype_id integer,
85600
 
    ipsass_custtype_pattern text,
85601
 
    ipsass_shipto_id integer DEFAULT (-1),
85602
 
    ipsass_shipto_pattern text
85603
 
);
85604
 
 
85605
 
 
85606
 
ALTER TABLE public.ipsass OWNER TO admin;
85607
 
 
85608
 
--
85609
 
--
85610
 
 
85611
 
COMMENT ON TABLE ipsass IS 'Pricing Schedule assignment information';
85612
 
 
85613
 
 
85614
 
SET search_path = api, pg_catalog;
85615
 
 
85616
 
--
85617
 
--
85618
 
 
85619
 
CREATE VIEW pricingscheduleassign AS
85620
 
    SELECT (COALESCE(custinfo.cust_number, 'Any'::text))::character varying AS customer_number, (COALESCE(shiptoinfo.shipto_num, 'Any'::text))::character varying AS customer_shipto, (COALESCE(ipsass.ipsass_shipto_pattern, 'N/A'::text))::character varying AS customer_shipto_pattern, (COALESCE(custtype.custtype_code, 'N/A'::text))::character varying AS customer_type, (COALESCE(ipsass.ipsass_custtype_pattern, 'N/A'::text))::character varying AS customer_type_pattern, (ipshead.ipshead_name)::character varying AS pricing_schedule FROM ((((public.ipshead JOIN public.ipsass ON ((ipshead.ipshead_id = ipsass.ipsass_ipshead_id))) LEFT JOIN public.custinfo ON ((ipsass.ipsass_cust_id = custinfo.cust_id))) LEFT JOIN public.custtype ON ((ipsass.ipsass_custtype_id = custtype.custtype_id))) LEFT JOIN public.shiptoinfo ON ((ipsass.ipsass_shipto_id = shiptoinfo.shipto_id))) ORDER BY (COALESCE(custinfo.cust_number, 'Any'::text))::character varying, (COALESCE(shiptoinfo.shipto_num, 'Any'::text))::character varying, (COALESCE(custtype.custtype_code, 'N/A'::text))::character varying, (COALESCE(ipsass.ipsass_custtype_pattern, 'N/A'::text))::character varying, (ipshead.ipshead_name)::character varying;
85621
 
 
85622
 
 
85623
 
ALTER TABLE api.pricingscheduleassign OWNER TO admin;
85624
 
 
85625
 
--
85626
 
--
85627
 
 
85628
 
COMMENT ON VIEW pricingscheduleassign IS 'Pricing Schedule Assignments';
85629
 
 
85630
 
 
85631
 
SET search_path = public, pg_catalog;
85632
 
 
85633
 
--
85634
 
--
85635
 
 
85636
 
CREATE TABLE ipsiteminfo (
85637
 
    ipsitem_id integer DEFAULT nextval(('"ipsitem_ipsitem_id_seq"'::text)::regclass) NOT NULL,
85638
 
    ipsitem_ipshead_id integer,
85639
 
    ipsitem_item_id integer,
85640
 
    ipsitem_qtybreak numeric(18,6) NOT NULL,
85641
 
    ipsitem_price numeric(16,4) NOT NULL,
85642
 
    ipsitem_qty_uom_id integer,
85643
 
    ipsitem_price_uom_id integer,
85644
 
    ipsitem_discntprcnt numeric(10,6) DEFAULT 0.00 NOT NULL,
85645
 
    ipsitem_fixedamtdiscount numeric(16,4) DEFAULT 0.00 NOT NULL,
85646
 
    ipsitem_prodcat_id integer,
85647
 
    ipsitem_type character(1) NOT NULL,
85648
 
    ipsitem_warehous_id integer,
85649
 
    CONSTRAINT valid_ipsitem_type CHECK ((ipsitem_type = ANY (ARRAY['N'::bpchar, 'D'::bpchar, 'M'::bpchar])))
85650
 
);
85651
 
 
85652
 
 
85653
 
ALTER TABLE public.ipsiteminfo OWNER TO admin;
85654
 
 
85655
 
--
85656
 
--
85657
 
 
85658
 
COMMENT ON TABLE ipsiteminfo IS 'Pricing Schedule Item information';
85659
 
 
85660
 
 
85661
 
--
85662
 
--
85663
 
 
85664
 
COMMENT ON COLUMN ipsiteminfo.ipsitem_prodcat_id IS 'Product category for pricing schedule item.';
85665
 
 
85666
 
 
85667
 
--
85668
 
--
85669
 
 
85670
 
COMMENT ON COLUMN ipsiteminfo.ipsitem_type IS 'Pricing type for pricing schedule item.  Valid values are N-nominal, D-discount, and M-markup';
85671
 
 
85672
 
 
85673
 
--
85674
 
--
85675
 
 
85676
 
COMMENT ON COLUMN ipsiteminfo.ipsitem_warehous_id IS 'Site for pricing schedule item which enables pricing by site.';
85677
 
 
85678
 
 
85679
 
SET search_path = api, pg_catalog;
85680
 
 
85681
 
--
85682
 
--
85683
 
 
85684
 
CREATE VIEW pricingscheduleitem AS
85685
 
    SELECT (ipshead.ipshead_name)::character varying AS pricing_schedule, CASE WHEN (COALESCE(ipsiteminfo.ipsitem_item_id, (-1)) > 0) THEN 'Item'::character varying ELSE 'Product Category'::character varying END AS type, (COALESCE(item.item_number, ''::text))::character varying AS item_number, (COALESCE(prodcat.prodcat_code, ''::text))::character varying AS product_category, ipsiteminfo.ipsitem_qtybreak AS qty_break, (qtyuom.uom_name)::character varying AS qty_uom, (priceuom.uom_name)::character varying AS price_uom, ipsiteminfo.ipsitem_price AS price, ipsiteminfo.ipsitem_discntprcnt AS percent, ipsiteminfo.ipsitem_fixedamtdiscount AS fixedamt, CASE WHEN (ipsiteminfo.ipsitem_type = 'N'::bpchar) THEN 'Nominal'::character varying WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN 'Discount'::character varying WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN 'Markup'::character varying ELSE NULL::character varying END AS pricing_type FROM (((((public.ipsiteminfo JOIN public.ipshead ON ((ipsiteminfo.ipsitem_ipshead_id = ipshead.ipshead_id))) LEFT JOIN public.item ON ((ipsiteminfo.ipsitem_item_id = item.item_id))) LEFT JOIN public.prodcat ON ((ipsiteminfo.ipsitem_prodcat_id = prodcat.prodcat_id))) LEFT JOIN public.uom qtyuom ON ((ipsiteminfo.ipsitem_qty_uom_id = qtyuom.uom_id))) LEFT JOIN public.uom priceuom ON ((ipsiteminfo.ipsitem_price_uom_id = priceuom.uom_id)));
85686
 
 
85687
 
 
85688
 
ALTER TABLE api.pricingscheduleitem OWNER TO admin;
85689
 
 
85690
 
--
85691
 
--
85692
 
 
85693
 
COMMENT ON VIEW pricingscheduleitem IS 'Pricing Schedule Item';
85694
 
 
85695
 
 
85696
 
SET search_path = public, pg_catalog;
85697
 
 
85698
 
--
85699
 
--
85700
 
 
85701
 
CREATE TABLE ipsitemchar (
85702
 
    ipsitemchar_id integer NOT NULL,
85703
 
    ipsitemchar_ipsitem_id integer NOT NULL,
85704
 
    ipsitemchar_char_id integer NOT NULL,
85705
 
    ipsitemchar_value text NOT NULL,
85706
 
    ipsitemchar_price numeric(16,4)
85707
 
);
85708
 
 
85709
 
 
85710
 
ALTER TABLE public.ipsitemchar OWNER TO admin;
85711
 
 
85712
 
--
85713
 
--
85714
 
 
85715
 
COMMENT ON TABLE ipsitemchar IS 'Item Price Schedule Characteristic Prices.';
85716
 
 
85717
 
 
85718
 
SET search_path = api, pg_catalog;
85719
 
 
85720
 
--
85721
 
--
85722
 
 
85723
 
CREATE VIEW pricingscheduleitemchar AS
85724
 
    SELECT (ipshead.ipshead_name)::character varying AS pricing_schedule, (item.item_number)::character varying AS item_number, ipsiteminfo.ipsitem_qtybreak AS qty_break, (qtyuom.uom_name)::character varying AS qty_uom, (priceuom.uom_name)::character varying AS price_uom, ("char".char_name)::character varying AS characteristic, (ipsitemchar.ipsitemchar_value)::character varying AS value, ipsitemchar.ipsitemchar_price AS price FROM public.ipshead, public.ipsiteminfo, public.ipsitemchar, public.item, public."char", public.uom qtyuom, public.uom priceuom WHERE ((((((ipshead.ipshead_id = ipsiteminfo.ipsitem_ipshead_id) AND (ipsiteminfo.ipsitem_id = ipsitemchar.ipsitemchar_ipsitem_id)) AND (ipsiteminfo.ipsitem_item_id = item.item_id)) AND (ipsiteminfo.ipsitem_qty_uom_id = qtyuom.uom_id)) AND (ipsiteminfo.ipsitem_price_uom_id = priceuom.uom_id)) AND (ipsitemchar.ipsitemchar_char_id = "char".char_id));
85725
 
 
85726
 
 
85727
 
ALTER TABLE api.pricingscheduleitemchar OWNER TO admin;
85728
 
 
85729
 
--
85730
 
--
85731
 
 
85732
 
COMMENT ON VIEW pricingscheduleitemchar IS 'Pricing Schedule Item Characteristics';
85733
 
 
85734
 
 
85735
 
--
85736
 
--
85737
 
 
85738
 
CREATE VIEW project AS
85739
 
    SELECT prj.prj_number AS number, prj.prj_name AS name, prj.prj_descrip AS description, prj.prj_owner_username AS owner, prj.prj_username AS assigned_to, prj.prj_so AS sales_orders, prj.prj_wo AS work_orders, prj.prj_po AS purchase_orders, CASE WHEN (prj.prj_status = 'P'::bpchar) THEN 'Concept'::text WHEN (prj.prj_status = 'O'::bpchar) THEN 'In-Process'::text WHEN (prj.prj_status = 'C'::bpchar) THEN 'Closed'::text ELSE 'Error'::text END AS status, prj.prj_due_date AS due, prj.prj_assigned_date AS assigned, prj.prj_start_date AS started, prj.prj_completed_date AS completed FROM public.prj;
85740
 
 
85741
 
 
85742
 
ALTER TABLE api.project OWNER TO admin;
85743
 
 
85744
 
--
85745
 
--
85746
 
 
85747
 
COMMENT ON VIEW project IS 'Project';
85748
 
 
85749
 
 
85750
 
--
85751
 
--
85752
 
 
85753
 
CREATE VIEW projectcomment AS
85754
 
    SELECT (prj.prj_number)::character varying AS project_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.prj, public.cmnttype, public.comment WHERE (((comment.comment_source = 'J'::text) AND (comment.comment_source_id = prj.prj_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id));
85755
 
 
85756
 
 
85757
 
ALTER TABLE api.projectcomment OWNER TO admin;
85758
 
 
85759
 
--
85760
 
--
85761
 
 
85762
 
COMMENT ON VIEW projectcomment IS 'Project Comment';
85763
 
 
85764
 
 
85765
 
SET search_path = public, pg_catalog;
85766
 
 
85767
 
--
85768
 
--
85769
 
 
85770
 
CREATE SEQUENCE cust_cust_id_seq
85771
 
    START WITH 1
85772
 
    INCREMENT BY 1
85773
 
    NO MINVALUE
85774
 
    NO MAXVALUE
85775
 
    CACHE 1;
85776
 
 
85777
 
 
85778
 
ALTER TABLE public.cust_cust_id_seq OWNER TO admin;
85779
 
 
85780
 
--
85781
 
--
85782
 
 
85783
 
CREATE TABLE prospect (
85784
 
    prospect_id integer DEFAULT nextval('cust_cust_id_seq'::regclass) NOT NULL,
85785
 
    prospect_active boolean DEFAULT true NOT NULL,
85786
 
    prospect_number text NOT NULL,
85787
 
    prospect_name text NOT NULL,
85788
 
    prospect_cntct_id integer,
85789
 
    prospect_comments text,
85790
 
    prospect_created date DEFAULT ('now'::text)::date NOT NULL,
85791
 
    prospect_salesrep_id integer,
85792
 
    prospect_warehous_id integer,
85793
 
    prospect_taxzone_id integer,
85794
 
    CONSTRAINT prospect_prospect_number_check CHECK ((prospect_number <> ''::text))
85795
 
);
85796
 
 
85797
 
 
85798
 
ALTER TABLE public.prospect OWNER TO admin;
85799
 
 
85800
 
--
85801
 
--
85802
 
 
85803
 
COMMENT ON TABLE prospect IS 'Prospect Information';
85804
 
 
85805
 
 
85806
 
SET search_path = api, pg_catalog;
85807
 
 
85808
 
--
85809
 
--
85810
 
 
85811
 
CREATE VIEW prospect AS
85812
 
    SELECT (prospect.prospect_number)::character varying AS prospect_number, prospect.prospect_name, prospect.prospect_active AS active, salesrep.salesrep_number AS sales_rep, whsinfo.warehous_code AS site_code, taxzone.taxzone_code AS default_tax_zone, prospect.prospect_comments AS notes, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS contact_honorific, cntct.cntct_first_name AS contact_first, cntct.cntct_middle AS contact_middle, cntct.cntct_last_name AS contact_last, cntct.cntct_suffix AS contact_suffix, cntct.cntct_title AS contact_job_title, cntct.cntct_phone AS contact_voice, cntct.cntct_phone2 AS contact_alternate, cntct.cntct_fax AS contact_fax, cntct.cntct_email AS contact_email, cntct.cntct_webaddr AS contact_web, ''::text AS contact_change, addr.addr_number AS contact_address_number, addr.addr_line1 AS contact_address1, addr.addr_line2 AS contact_address2, addr.addr_line3 AS contact_address3, addr.addr_city AS contact_city, addr.addr_state AS contact_state, addr.addr_postalcode AS contact_postalcode, addr.addr_country AS contact_country, ''::text AS contact_address_change FROM (((((public.prospect LEFT JOIN public.cntct ON ((prospect.prospect_cntct_id = cntct.cntct_id))) LEFT JOIN public.addr ON ((cntct.cntct_addr_id = addr.addr_id))) LEFT JOIN public.taxzone ON ((prospect.prospect_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.salesrep ON ((prospect.prospect_salesrep_id = salesrep.salesrep_id))) LEFT JOIN public.whsinfo ON ((prospect.prospect_warehous_id = whsinfo.warehous_id)));
85813
 
 
85814
 
 
85815
 
ALTER TABLE api.prospect OWNER TO admin;
85816
 
 
85817
 
--
85818
 
--
85819
 
 
85820
 
COMMENT ON VIEW prospect IS 'Prospect';
85821
 
 
85822
 
 
85823
 
SET search_path = public, pg_catalog;
85824
 
 
85825
 
--
85826
 
--
85827
 
 
85828
 
CREATE TABLE expcat (
85829
 
    expcat_id integer NOT NULL,
85830
 
    expcat_code text NOT NULL,
85831
 
    expcat_descrip text,
85832
 
    expcat_exp_accnt_id integer,
85833
 
    expcat_liability_accnt_id integer,
85834
 
    expcat_active boolean,
85835
 
    expcat_purchprice_accnt_id integer,
85836
 
    expcat_freight_accnt_id integer,
85837
 
    CONSTRAINT expcat_expcat_code_check CHECK ((expcat_code <> ''::text))
85838
 
);
85839
 
 
85840
 
 
85841
 
ALTER TABLE public.expcat OWNER TO admin;
85842
 
 
85843
 
--
85844
 
--
85845
 
 
85846
 
COMMENT ON TABLE expcat IS 'Expense Category information';
85847
 
 
85848
 
 
85849
 
--
85850
 
--
85851
 
 
85852
 
CREATE TABLE womatl (
85853
 
    womatl_id integer DEFAULT nextval(('womatl_womatl_id_seq'::text)::regclass) NOT NULL,
85854
 
    womatl_wo_id integer,
85855
 
    womatl_itemsite_id integer,
85856
 
    womatl_qtyper numeric(20,8) NOT NULL,
85857
 
    womatl_scrap numeric(8,4) NOT NULL,
85858
 
    womatl_qtyreq numeric(18,6) NOT NULL,
85859
 
    womatl_qtyiss numeric(18,6) NOT NULL,
85860
 
    womatl_qtywipscrap numeric(18,6) NOT NULL,
85861
 
    womatl_lastissue date,
85862
 
    womatl_lastreturn date,
85863
 
    womatl_cost numeric(16,6),
85864
 
    womatl_picklist boolean,
85865
 
    womatl_status character(1),
85866
 
    womatl_imported boolean DEFAULT false,
85867
 
    womatl_createwo boolean,
85868
 
    womatl_issuemethod character(1),
85869
 
    womatl_wooper_id integer,
85870
 
    womatl_bomitem_id integer,
85871
 
    womatl_duedate date,
85872
 
    womatl_schedatwooper boolean,
85873
 
    womatl_uom_id integer NOT NULL,
85874
 
    womatl_notes text,
85875
 
    womatl_ref text,
85876
 
    womatl_scrapvalue numeric(16,6) DEFAULT 0,
85877
 
    womatl_qtyfxd numeric(20,8) DEFAULT 0 NOT NULL,
85878
 
    womatl_issuewo boolean DEFAULT false NOT NULL,
85879
 
    womatl_price numeric(16,6) DEFAULT 0 NOT NULL
85880
 
);
85881
 
 
85882
 
 
85883
 
ALTER TABLE public.womatl OWNER TO admin;
85884
 
 
85885
 
--
85886
 
--
85887
 
 
85888
 
COMMENT ON TABLE womatl IS 'Work Order Material Requirements information';
85889
 
 
85890
 
 
85891
 
--
85892
 
--
85893
 
 
85894
 
COMMENT ON COLUMN womatl.womatl_qtyfxd IS 'The fixed quantity required';
85895
 
 
85896
 
 
85897
 
SET search_path = api, pg_catalog;
85898
 
 
85899
 
--
85900
 
--
85901
 
 
85902
 
CREATE VIEW purchaseline AS
85903
 
    SELECT (pohead.pohead_number)::character varying AS order_number, poitem.poitem_linenumber AS line_number, item.item_number, whsinfo.warehous_code AS site, expcat.expcat_code AS expense_category, poitem.poitem_qty_ordered AS qty_ordered, poitem.poitem_unitprice AS unit_price, poitem.poitem_freight AS freight, poitem.poitem_duedate AS due_date, prj.prj_number AS project_number, poitem.poitem_vend_item_number AS vend_item_number, poitem.poitem_vend_item_descrip AS vendor_description, poitem.poitem_manuf_name AS manufacturer_name, poitem.poitem_manuf_item_number AS manufacturer_item_number, poitem.poitem_manuf_item_descrip AS manufacturer_description, poitem.poitem_comments AS notes, public.formatrevnumber('BOM'::text, poitem.poitem_bom_rev_id) AS bill_of_materials_revision, public.formatrevnumber('BOO'::text, poitem.poitem_boo_rev_id) AS bill_of_operations_revision, public.formatsonumber(coitem.coitem_id) AS sales_order_number, public.formatwonumber(womatl.womatl_wo_id) AS work_order_number FROM ((((((((public.pohead JOIN public.poitem ON ((pohead.pohead_id = poitem.poitem_pohead_id))) LEFT JOIN public.prj ON ((poitem.poitem_prj_id = prj.prj_id))) LEFT JOIN public.expcat ON ((poitem.poitem_expcat_id = expcat.expcat_id))) LEFT JOIN public.itemsite ON ((poitem.poitem_itemsite_id = itemsite.itemsite_id))) LEFT JOIN public.item ON ((itemsite.itemsite_item_id = item.item_id))) LEFT JOIN public.whsinfo ON ((itemsite.itemsite_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.coitem ON (((coitem.coitem_id = poitem.poitem_order_id) AND (poitem.poitem_order_type = 'S'::bpchar)))) LEFT JOIN public.womatl ON (((womatl.womatl_id = poitem.poitem_order_id) AND (poitem.poitem_order_type = 'W'::bpchar)))) ORDER BY pohead.pohead_number, poitem.poitem_linenumber;
85904
 
 
85905
 
 
85906
 
ALTER TABLE api.purchaseline OWNER TO admin;
85907
 
 
85908
 
--
85909
 
--
85910
 
 
85911
 
COMMENT ON VIEW purchaseline IS 'Purchase Order Line';
85912
 
 
85913
 
 
85914
 
--
85915
 
--
85916
 
 
85917
 
CREATE VIEW purchaselinechar AS
85918
 
    SELECT (data.order_number)::character varying AS order_number, data.line_number, data.characteristic, COALESCE(pi.charass_value, i3.charass_value) AS value FROM (((((SELECT DISTINCT "char".char_id, poitem.poitem_id, poitem.poitem_itemsite_id, pohead.pohead_number AS order_number, poitem.poitem_linenumber AS line_number, "char".char_name AS characteristic FROM public.pohead, public.poitem, public.itemsite, public.item, public.charass, public."char" WHERE ((((((pohead.pohead_id = poitem.poitem_pohead_id) AND (poitem.poitem_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (charass.charass_char_id = "char".char_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id))) data LEFT JOIN public.charass pi ON ((((data.poitem_id = pi.charass_target_id) AND ('PI'::text = pi.charass_target_type)) AND (pi.charass_char_id = data.char_id)))) LEFT JOIN public.itemsite i1 ON ((data.poitem_itemsite_id = i1.itemsite_id))) LEFT JOIN public.item i2 ON ((i1.itemsite_item_id = i2.item_id))) LEFT JOIN public.charass i3 ON (((((i2.item_id = i3.charass_target_id) AND ('I'::text = i3.charass_target_type)) AND (i3.charass_char_id = data.char_id)) AND i3.charass_default))) ORDER BY (data.order_number)::character varying, data.line_number, data.characteristic;
85919
 
 
85920
 
 
85921
 
ALTER TABLE api.purchaselinechar OWNER TO admin;
85922
 
 
85923
 
--
85924
 
--
85925
 
 
85926
 
COMMENT ON VIEW purchaselinechar IS 'Purchase Order Line Item Characteristic';
85927
 
 
85928
 
 
85929
 
--
85930
 
--
85931
 
 
85932
 
CREATE VIEW purchaselinecomment AS
85933
 
    SELECT (pohead.pohead_number)::character varying AS order_number, poitem.poitem_linenumber AS line_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.pohead, public.poitem, public.cmnttype, public.comment WHERE ((((pohead.pohead_id = poitem.poitem_pohead_id) AND (comment.comment_source = 'PI'::text)) AND (comment.comment_source_id = poitem.poitem_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)) ORDER BY pohead.pohead_number, poitem.poitem_linenumber, comment.comment_date DESC;
85934
 
 
85935
 
 
85936
 
ALTER TABLE api.purchaselinecomment OWNER TO admin;
85937
 
 
85938
 
--
85939
 
--
85940
 
 
85941
 
COMMENT ON VIEW purchaselinecomment IS 'Purchase Order Line Item Comment';
85942
 
 
85943
 
 
85944
 
SET search_path = public, pg_catalog;
85945
 
 
85946
 
--
85947
 
--
85948
 
 
85949
 
CREATE TABLE tax (
85950
 
    tax_id integer DEFAULT nextval(('"tax_tax_id_seq"'::text)::regclass) NOT NULL,
85951
 
    tax_code text NOT NULL,
85952
 
    tax_descrip text,
85953
 
    tax_sales_accnt_id integer,
85954
 
    tax_taxclass_id integer,
85955
 
    tax_taxauth_id integer,
85956
 
    tax_basis_tax_id integer,
85957
 
    tax_dist_accnt_id integer,
85958
 
    CONSTRAINT tax_tax_code_check CHECK ((tax_code <> ''::text))
85959
 
);
85960
 
 
85961
 
 
85962
 
ALTER TABLE public.tax OWNER TO admin;
85963
 
 
85964
 
--
85965
 
--
85966
 
 
85967
 
COMMENT ON TABLE tax IS 'Tax information';
85968
 
 
85969
 
 
85970
 
--
85971
 
--
85972
 
 
85973
 
COMMENT ON COLUMN tax.tax_sales_accnt_id IS 'Deprecated column - DO NOT USE';
85974
 
 
85975
 
 
85976
 
--
85977
 
--
85978
 
 
85979
 
CREATE TABLE vendaddrinfo (
85980
 
    vendaddr_id integer DEFAULT nextval(('vendaddr_vendaddr_id_seq'::text)::regclass) NOT NULL,
85981
 
    vendaddr_vend_id integer,
85982
 
    vendaddr_code text,
85983
 
    vendaddr_name text,
85984
 
    vendaddr_comments text,
85985
 
    vendaddr_cntct_id integer,
85986
 
    vendaddr_addr_id integer,
85987
 
    vendaddr_taxzone_id integer
85988
 
);
85989
 
 
85990
 
 
85991
 
ALTER TABLE public.vendaddrinfo OWNER TO admin;
85992
 
 
85993
 
--
85994
 
--
85995
 
 
85996
 
COMMENT ON TABLE vendaddrinfo IS 'Vendor Address information';
85997
 
 
85998
 
 
85999
 
SET search_path = api, pg_catalog;
86000
 
 
86001
 
--
86002
 
--
86003
 
 
86004
 
CREATE VIEW purchaseorder AS
86005
 
    SELECT (pohead.pohead_number)::character varying AS order_number, pohead.pohead_orderdate AS order_date, terms.terms_code AS terms, taxzone.taxzone_code AS tax_zone, whsinfo.warehous_code AS receiving_site, pohead.pohead_agent_username AS purchasing_agent, vendinfo.vend_number AS vendor_number, COALESCE(ua.vendaddr_code, 'MAIN'::text) AS alt_address, pohead.pohead_fob AS fob, pohead.pohead_shipvia AS ship_via, curr_symbol.curr_abbr AS currency, (SELECT COALESCE(sum(data.tax), 0.00) AS tax FROM (SELECT round(sum(calculatetaxdetailsummary.taxdetail_tax), 2) AS tax FROM (public.tax JOIN public.calculatetaxdetailsummary('PO'::text, pohead.pohead_id, 'T'::text) calculatetaxdetailsummary(taxdetail_tax_id, taxdetail_tax_code, taxdetail_tax_descrip, taxdetail_tax_basis_tax_id, taxdetail_taxrate_percent, taxdetail_taxrate_amount, taxdetail_level, taxdetail_taxclass_id, taxdetail_taxclass_code, taxdetail_taxclass_sequence, taxdetail_tax, taxdetail_curr_id, taxdetail_curr_abbr) ON ((calculatetaxdetailsummary.taxdetail_tax_id = tax.tax_id))) GROUP BY tax.tax_id) data) AS tax, pohead.pohead_freight AS freight, pohead.pohead_comments AS notes, pohead.pohead_dropship AS dropship, vc.cntct_number AS vend_contact_number, pohead.pohead_vend_cntct_honorific AS vend_cntct_honorific, pohead.pohead_vend_cntct_first_name AS vend_cntct_first_name, pohead.pohead_vend_cntct_middle AS vend_cntct_middle, pohead.pohead_vend_cntct_last_name AS vend_cntct_last_name, pohead.pohead_vend_cntct_suffix AS vend_cntct_suffix, pohead.pohead_vend_cntct_phone AS vend_cntct_phone, pohead.pohead_vend_cntct_title AS vend_cntct_title, pohead.pohead_vend_cntct_fax AS vend_cntct_fax, pohead.pohead_vend_cntct_email AS vend_cntct_email, pohead.pohead_vendaddress1 AS vendaddress1, pohead.pohead_vendaddress2 AS vendaddress2, pohead.pohead_vendaddress3 AS vendaddress3, pohead.pohead_vendcity AS vendcity, pohead.pohead_vendstate AS vendstate, pohead.pohead_vendzipcode AS vendzipcode, pohead.pohead_vendcountry AS vendcountry, sc.cntct_number AS shipto_contact_number, pohead.pohead_shipto_cntct_honorific AS shipto_cntct_honorific, pohead.pohead_shipto_cntct_first_name AS shipto_cntct_first_name, pohead.pohead_shipto_cntct_middle AS shipto_cntct_middle, pohead.pohead_shipto_cntct_last_name AS shipto_cntct_last_name, pohead.pohead_shipto_cntct_suffix AS shipto_cntct_suffix, pohead.pohead_shipto_cntct_phone AS shipto_cntct_phone, pohead.pohead_shipto_cntct_title AS shipto_cntct_title, pohead.pohead_shipto_cntct_fax AS shipto_cntct_fax, pohead.pohead_shipto_cntct_email AS shipto_cntct_email, addr.addr_number AS shiptoaddress_number, pohead.pohead_shiptoaddress1 AS shiptoaddress1, pohead.pohead_shiptoaddress2 AS shiptoaddress2, pohead.pohead_shiptoaddress3 AS shiptoaddress3, pohead.pohead_shiptocity AS shiptocity, pohead.pohead_shiptostate AS shiptostate, pohead.pohead_shiptozipcode AS shiptozipcode, pohead.pohead_shiptocountry AS shiptocountry, cohead.cohead_number AS sales_order_number FROM ((((((((((public.pohead LEFT JOIN public.cntct vc ON ((pohead.pohead_vend_cntct_id = vc.cntct_id))) LEFT JOIN public.cntct sc ON ((pohead.pohead_shipto_cntct_id = sc.cntct_id))) LEFT JOIN public.addr ON ((pohead.pohead_shiptoaddress_id = addr.addr_id))) LEFT JOIN public.terms ON ((pohead.pohead_terms_id = terms.terms_id))) LEFT JOIN public.taxzone ON ((pohead.pohead_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.whsinfo ON ((pohead.pohead_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.vendaddrinfo ua ON ((pohead.pohead_vendaddr_id = ua.vendaddr_id))) LEFT JOIN public.cohead ON ((pohead.pohead_cohead_id = cohead.cohead_id))) JOIN public.vendinfo ON ((pohead.pohead_vend_id = vendinfo.vend_id))) JOIN public.curr_symbol ON ((pohead.pohead_curr_id = curr_symbol.curr_id))) ORDER BY pohead.pohead_number;
86006
 
 
86007
 
 
86008
 
ALTER TABLE api.purchaseorder OWNER TO admin;
86009
 
 
86010
 
--
86011
 
--
86012
 
 
86013
 
COMMENT ON VIEW purchaseorder IS 'Purchase Order';
86014
 
 
86015
 
 
86016
 
--
86017
 
--
86018
 
 
86019
 
CREATE VIEW purchaseordercomment AS
86020
 
    SELECT (pohead.pohead_number)::character varying AS order_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.pohead, public.cmnttype, public.comment WHERE (((comment.comment_source = 'P'::text) AND (comment.comment_source_id = pohead.pohead_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id));
86021
 
 
86022
 
 
86023
 
ALTER TABLE api.purchaseordercomment OWNER TO admin;
86024
 
 
86025
 
--
86026
 
--
86027
 
 
86028
 
COMMENT ON VIEW purchaseordercomment IS 'Purchase Order Comment';
86029
 
 
86030
 
 
86031
 
SET search_path = public, pg_catalog;
86032
 
 
86033
 
--
86034
 
--
86035
 
 
86036
 
CREATE TABLE quhead (
86037
 
    quhead_id integer DEFAULT nextval(('"quhead_quhead_id_seq"'::text)::regclass) NOT NULL,
86038
 
    quhead_number text NOT NULL,
86039
 
    quhead_cust_id integer NOT NULL,
86040
 
    quhead_quotedate date,
86041
 
    quhead_shipto_id integer,
86042
 
    quhead_shiptoname text,
86043
 
    quhead_shiptoaddress1 text,
86044
 
    quhead_shiptoaddress2 text,
86045
 
    quhead_shiptoaddress3 text,
86046
 
    quhead_shiptocity text,
86047
 
    quhead_shiptostate text,
86048
 
    quhead_shiptozipcode text,
86049
 
    quhead_shiptophone text,
86050
 
    quhead_salesrep_id integer,
86051
 
    quhead_terms_id integer,
86052
 
    quhead_freight numeric(16,4),
86053
 
    quhead_ordercomments text,
86054
 
    quhead_shipcomments text,
86055
 
    quhead_billtoname text,
86056
 
    quhead_billtoaddress1 text,
86057
 
    quhead_billtoaddress2 text,
86058
 
    quhead_billtoaddress3 text,
86059
 
    quhead_billtocity text,
86060
 
    quhead_billtostate text,
86061
 
    quhead_billtozip text,
86062
 
    quhead_commission numeric(16,4),
86063
 
    quhead_custponumber text,
86064
 
    quhead_fob text,
86065
 
    quhead_shipvia text,
86066
 
    quhead_warehous_id integer,
86067
 
    quhead_packdate date,
86068
 
    quhead_prj_id integer,
86069
 
    quhead_misc numeric(16,4) DEFAULT 0 NOT NULL,
86070
 
    quhead_misc_accnt_id integer,
86071
 
    quhead_misc_descrip text,
86072
 
    quhead_billtocountry text,
86073
 
    quhead_shiptocountry text,
86074
 
    quhead_curr_id integer DEFAULT basecurrid(),
86075
 
    quhead_imported boolean DEFAULT false,
86076
 
    quhead_expire date,
86077
 
    quhead_calcfreight boolean DEFAULT false NOT NULL,
86078
 
    quhead_shipto_cntct_id integer,
86079
 
    quhead_shipto_cntct_honorific text,
86080
 
    quhead_shipto_cntct_first_name text,
86081
 
    quhead_shipto_cntct_middle text,
86082
 
    quhead_shipto_cntct_last_name text,
86083
 
    quhead_shipto_cntct_suffix text,
86084
 
    quhead_shipto_cntct_phone text,
86085
 
    quhead_shipto_cntct_title text,
86086
 
    quhead_shipto_cntct_fax text,
86087
 
    quhead_shipto_cntct_email text,
86088
 
    quhead_billto_cntct_id integer,
86089
 
    quhead_billto_cntct_honorific text,
86090
 
    quhead_billto_cntct_first_name text,
86091
 
    quhead_billto_cntct_middle text,
86092
 
    quhead_billto_cntct_last_name text,
86093
 
    quhead_billto_cntct_suffix text,
86094
 
    quhead_billto_cntct_phone text,
86095
 
    quhead_billto_cntct_title text,
86096
 
    quhead_billto_cntct_fax text,
86097
 
    quhead_billto_cntct_email text,
86098
 
    quhead_taxzone_id integer,
86099
 
    quhead_taxtype_id integer,
86100
 
    quhead_ophead_id integer,
86101
 
    quhead_status text,
86102
 
    quhead_saletype_id integer,
86103
 
    quhead_shipzone_id integer,
86104
 
    CONSTRAINT quhead_check CHECK ((((quhead_misc = (0)::numeric) AND (quhead_misc_accnt_id IS NULL)) OR ((quhead_misc <> (0)::numeric) AND (quhead_misc_accnt_id IS NOT NULL)))),
86105
 
    CONSTRAINT quhead_quhead_number_check CHECK ((quhead_number <> ''::text)),
86106
 
    CONSTRAINT quhead_quhead_status_check CHECK ((((quhead_status = 'O'::text) OR (quhead_status = 'C'::text)) OR (quhead_status = 'X'::text)))
86107
 
);
86108
 
 
86109
 
 
86110
 
ALTER TABLE public.quhead OWNER TO admin;
86111
 
 
86112
 
--
86113
 
--
86114
 
 
86115
 
COMMENT ON TABLE quhead IS 'Quote header information';
86116
 
 
86117
 
 
86118
 
--
86119
 
--
86120
 
 
86121
 
COMMENT ON COLUMN quhead.quhead_saletype_id IS 'Associated sale type for quote.';
86122
 
 
86123
 
 
86124
 
--
86125
 
--
86126
 
 
86127
 
COMMENT ON COLUMN quhead.quhead_shipzone_id IS 'Associated shipping zone for quote.';
86128
 
 
86129
 
 
86130
 
SET search_path = api, pg_catalog;
86131
 
 
86132
 
--
86133
 
--
86134
 
 
86135
 
CREATE VIEW quote AS
86136
 
    SELECT (quhead.quhead_number)::character varying AS quote_number, whsinfo.warehous_code AS site, quhead.quhead_quotedate AS quote_date, quhead.quhead_packdate AS pack_date, saletype.saletype_code AS sale_type, salesrep.salesrep_number AS sales_rep, quhead.quhead_commission AS commission, taxzone.taxzone_code AS tax_zone, taxtype.taxtype_name AS tax_type, terms.terms_code AS terms, prj.prj_number AS project_number, COALESCE(custinfo.cust_number, prospect.prospect_number) AS customer_number, quhead.quhead_billtoname AS billto_name, quhead.quhead_billtoaddress1 AS billto_address1, quhead.quhead_billtoaddress2 AS billto_address2, quhead.quhead_billtoaddress3 AS billto_address3, quhead.quhead_billtocity AS billto_city, quhead.quhead_billtostate AS billto_state, quhead.quhead_billtozip AS billto_postal_code, quhead.quhead_billtocountry AS billto_country, shiptoinfo.shipto_num AS shipto_number, quhead.quhead_shiptoname AS shipto_name, quhead.quhead_shiptophone AS shipto_phone, quhead.quhead_shiptoaddress1 AS shipto_address1, quhead.quhead_shiptoaddress2 AS shipto_address2, quhead.quhead_shiptoaddress3 AS shipto_address3, quhead.quhead_shiptocity AS shipto_city, quhead.quhead_shiptostate AS shipto_state, quhead.quhead_shiptozipcode AS shipto_postal_code, quhead.quhead_shiptocountry AS shipto_country, shipzone.shipzone_name AS shipto_shipzone, quhead.quhead_custponumber AS cust_po_number, quhead.quhead_fob AS fob, quhead.quhead_shipvia AS ship_via, curr_symbol.curr_abbr AS currency, quhead.quhead_misc_descrip AS misc_charge_description, CASE WHEN (quhead.quhead_misc_accnt_id IS NULL) THEN NULL::text ELSE public.formatglaccount(quhead.quhead_misc_accnt_id) END AS misc_account_number, quhead.quhead_misc AS misc_charge, quhead.quhead_freight AS freight, quhead.quhead_ordercomments AS order_notes, quhead.quhead_shipcomments AS shipping_notes, false AS add_to_packing_list_batch, quhead.quhead_expire AS expire_date, CASE WHEN (quhead.quhead_status = 'C'::text) THEN 'Converted'::text ELSE 'Open'::text END AS status FROM public.curr_symbol, (((((((((((public.quhead LEFT JOIN public.whsinfo ON ((quhead.quhead_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.prj ON ((quhead.quhead_prj_id = prj.prj_id))) LEFT JOIN public.shiptoinfo ON ((quhead.quhead_shipto_id = shiptoinfo.shipto_id))) LEFT JOIN public.taxzone ON ((quhead.quhead_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.taxtype ON ((quhead.quhead_taxtype_id = taxtype.taxtype_id))) LEFT JOIN public.custinfo ON ((quhead.quhead_cust_id = custinfo.cust_id))) LEFT JOIN public.prospect ON ((quhead.quhead_cust_id = prospect.prospect_id))) LEFT JOIN public.salesrep ON ((quhead.quhead_salesrep_id = salesrep.salesrep_id))) LEFT JOIN public.terms ON ((quhead.quhead_terms_id = terms.terms_id))) LEFT JOIN public.saletype ON ((quhead.quhead_saletype_id = saletype.saletype_id))) LEFT JOIN public.shipzone ON ((quhead.quhead_shipzone_id = shipzone.shipzone_id))) WHERE (quhead.quhead_curr_id = curr_symbol.curr_id);
86137
 
 
86138
 
 
86139
 
ALTER TABLE api.quote OWNER TO admin;
86140
 
 
86141
 
--
86142
 
--
86143
 
 
86144
 
COMMENT ON VIEW quote IS 'Quote';
86145
 
 
86146
 
 
86147
 
--
86148
 
--
86149
 
 
86150
 
CREATE VIEW quotecomment AS
86151
 
    SELECT quhead.quhead_number AS quote_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.quhead, public.cmnttype, public.comment WHERE (((comment.comment_source = 'Q'::text) AND (comment.comment_source_id = quhead.quhead_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id));
86152
 
 
86153
 
 
86154
 
ALTER TABLE api.quotecomment OWNER TO admin;
86155
 
 
86156
 
--
86157
 
--
86158
 
 
86159
 
COMMENT ON VIEW quotecomment IS 'Quote Comment';
86160
 
 
86161
 
 
86162
 
SET search_path = public, pg_catalog;
86163
 
 
86164
 
--
86165
 
--
86166
 
 
86167
 
CREATE TABLE quitem (
86168
 
    quitem_id integer DEFAULT nextval(('"quitem_quitem_id_seq"'::text)::regclass) NOT NULL,
86169
 
    quitem_quhead_id integer,
86170
 
    quitem_linenumber integer,
86171
 
    quitem_itemsite_id integer,
86172
 
    quitem_scheddate date,
86173
 
    quitem_qtyord numeric(18,6),
86174
 
    quitem_unitcost numeric(16,6),
86175
 
    quitem_price numeric(16,4),
86176
 
    quitem_custprice numeric(16,4),
86177
 
    quitem_memo text,
86178
 
    quitem_custpn text,
86179
 
    quitem_createorder boolean,
86180
 
    quitem_order_warehous_id integer,
86181
 
    quitem_item_id integer,
86182
 
    quitem_prcost numeric(16,6),
86183
 
    quitem_imported boolean DEFAULT false,
86184
 
    quitem_qty_uom_id integer NOT NULL,
86185
 
    quitem_qty_invuomratio numeric(20,10) NOT NULL,
86186
 
    quitem_price_uom_id integer NOT NULL,
86187
 
    quitem_price_invuomratio numeric(20,10) NOT NULL,
86188
 
    quitem_promdate date,
86189
 
    quitem_taxtype_id integer,
86190
 
    quitem_dropship boolean DEFAULT false,
86191
 
    quitem_itemsrc_id integer,
86192
 
    quitem_pricemode character(1) DEFAULT 'D'::bpchar NOT NULL,
86193
 
    CONSTRAINT valid_quitem_pricemode CHECK ((quitem_pricemode = ANY (ARRAY['D'::bpchar, 'M'::bpchar])))
86194
 
);
86195
 
 
86196
 
 
86197
 
ALTER TABLE public.quitem OWNER TO admin;
86198
 
 
86199
 
--
86200
 
--
86201
 
 
86202
 
COMMENT ON TABLE quitem IS 'Quote Line Item information';
86203
 
 
86204
 
 
86205
 
--
86206
 
--
86207
 
 
86208
 
COMMENT ON COLUMN quitem.quitem_pricemode IS 'Pricing mode for quote item.  Valid values are D-discount, and M-markup';
86209
 
 
86210
 
 
86211
 
SET search_path = api, pg_catalog;
86212
 
 
86213
 
--
86214
 
--
86215
 
 
86216
 
CREATE VIEW quoteline AS
86217
 
    SELECT quhead.quhead_number AS quote_number, quitem.quitem_linenumber AS line_number, l.item_number, quitem.quitem_custpn AS customer_pn, i.warehous_code AS sold_from_site, quitem.quitem_qtyord AS qty_ordered, q.uom_name AS qty_uom, quitem.quitem_price AS net_unit_price, p.uom_name AS price_uom, quitem.quitem_scheddate AS scheduled_date, COALESCE((SELECT taxtype.taxtype_name FROM public.taxtype WHERE (taxtype.taxtype_id = public.getitemtaxtype(l.item_id, quhead.quhead_taxzone_id))), 'None'::text) AS tax_type, CASE WHEN (quitem.quitem_price = (0)::numeric) THEN '100'::text WHEN (quitem.quitem_custprice = (0)::numeric) THEN 'N/A'::text ELSE (round((((1)::numeric - (quitem.quitem_price / quitem.quitem_custprice)) * (100)::numeric), 4))::text END AS discount_pct_from_list, quitem.quitem_createorder AS create_order, s.warehous_code AS supplying_site, quitem.quitem_prcost AS overwrite_po_price, quitem.quitem_memo AS notes FROM public.quhead, public.uom q, public.uom p, (public.quitem LEFT JOIN public.whsinfo s ON ((quitem.quitem_order_warehous_id = s.warehous_id))), public.itemsite il, public.item l, public.whsinfo i WHERE ((((((quhead.quhead_id = quitem.quitem_quhead_id) AND (quitem.quitem_itemsite_id = il.itemsite_id)) AND (il.itemsite_item_id = l.item_id)) AND (il.itemsite_warehous_id = i.warehous_id)) AND (quitem.quitem_qty_uom_id = q.uom_id)) AND (quitem.quitem_price_uom_id = p.uom_id)) ORDER BY quhead.quhead_number, quitem.quitem_linenumber;
86218
 
 
86219
 
 
86220
 
ALTER TABLE api.quoteline OWNER TO admin;
86221
 
 
86222
 
--
86223
 
--
86224
 
 
86225
 
COMMENT ON VIEW quoteline IS 'Quote Line Item';
86226
 
 
86227
 
 
86228
 
--
86229
 
--
86230
 
 
86231
 
CREATE VIEW quotelinechar AS
86232
 
    SELECT DISTINCT quhead.quhead_number AS quote_number, quitem.quitem_linenumber AS line_number, "char".char_name AS characteristic, COALESCE((SELECT b.charass_value FROM public.charass b WHERE (((b.charass_target_type = 'QI'::text) AND (b.charass_target_id = quitem.quitem_id)) AND (b.charass_char_id = "char".char_id))), (SELECT c.charass_value FROM public.charass c WHERE ((((c.charass_target_type = 'I'::text) AND (c.charass_target_id = item.item_id)) AND c.charass_default) AND (c.charass_char_id = "char".char_id)) LIMIT 1)) AS value FROM public.quhead, public.quitem, public.itemsite, public.item, public.charass a, public."char" WHERE ((((((quhead.quhead_id = quitem.quitem_quhead_id) AND (quitem.quitem_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (a.charass_char_id = "char".char_id)) AND (a.charass_target_type = 'I'::text)) AND (a.charass_target_id = item.item_id)) ORDER BY quhead.quhead_number, quitem.quitem_linenumber, "char".char_name;
86233
 
 
86234
 
 
86235
 
ALTER TABLE api.quotelinechar OWNER TO admin;
86236
 
 
86237
 
--
86238
 
--
86239
 
 
86240
 
COMMENT ON VIEW quotelinechar IS 'Quote Line Item Characteristics';
86241
 
 
86242
 
 
86243
 
--
86244
 
--
86245
 
 
86246
 
CREATE VIEW quotelinecomment AS
86247
 
    SELECT quhead.quhead_number AS quote_number, quitem.quitem_linenumber AS line_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.quhead, public.quitem, public.cmnttype, public.comment WHERE ((((quhead.quhead_id = quitem.quitem_quhead_id) AND (comment.comment_source = 'QI'::text)) AND (comment.comment_source_id = quitem.quitem_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)) ORDER BY quhead.quhead_number, quitem.quitem_linenumber, comment.comment_date DESC;
86248
 
 
86249
 
 
86250
 
ALTER TABLE api.quotelinecomment OWNER TO admin;
86251
 
 
86252
 
--
86253
 
--
86254
 
 
86255
 
COMMENT ON VIEW quotelinecomment IS 'Quote Line Item Comment';
86256
 
 
86257
 
 
86258
 
SET search_path = public, pg_catalog;
86259
 
 
86260
 
--
86261
 
--
86262
 
 
86263
 
CREATE TABLE aropenalloc (
86264
 
    aropenalloc_aropen_id integer NOT NULL,
86265
 
    aropenalloc_doctype character(1) NOT NULL,
86266
 
    aropenalloc_doc_id integer NOT NULL,
86267
 
    aropenalloc_amount numeric(20,2) DEFAULT 0.00 NOT NULL,
86268
 
    aropenalloc_curr_id integer DEFAULT basecurrid()
86269
 
);
86270
 
 
86271
 
 
86272
 
ALTER TABLE public.aropenalloc OWNER TO admin;
86273
 
 
86274
 
SET search_path = api, pg_catalog;
86275
 
 
86276
 
--
86277
 
--
86278
 
 
86279
 
CREATE VIEW salescredit AS
86280
 
    SELECT custinfo.cust_number AS customer_number, aropen.aropen_docnumber AS cm_number, cohead.cohead_number AS so_number, (aropenalloc.aropenalloc_amount)::numeric(16,4) AS amount, curr.curr_abbr AS currency FROM ((((public.aropenalloc LEFT JOIN public.aropen ON ((aropen.aropen_id = aropenalloc.aropenalloc_aropen_id))) LEFT JOIN public.custinfo ON ((custinfo.cust_id = aropen.aropen_cust_id))) LEFT JOIN public.cohead ON (((aropenalloc.aropenalloc_doctype = 'S'::bpchar) AND (cohead.cohead_id = aropenalloc.aropenalloc_doc_id)))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = aropenalloc.aropenalloc_curr_id))) WHERE (aropenalloc.aropenalloc_doctype = 'S'::bpchar);
86281
 
 
86282
 
 
86283
 
ALTER TABLE api.salescredit OWNER TO admin;
86284
 
 
86285
 
--
86286
 
--
86287
 
 
86288
 
COMMENT ON VIEW salescredit IS 'Payments (credit memos) pre-applied to sales orders';
86289
 
 
86290
 
 
86291
 
SET search_path = public, pg_catalog;
86292
 
 
86293
 
--
86294
 
--
86295
 
 
86296
 
CREATE TABLE cohist (
86297
 
    cohist_id integer DEFAULT nextval(('cohist_cohist_id_seq'::text)::regclass) NOT NULL,
86298
 
    cohist_cust_id integer,
86299
 
    cohist_itemsite_id integer,
86300
 
    cohist_shipdate date,
86301
 
    cohist_shipvia text,
86302
 
    cohist_ordernumber text,
86303
 
    cohist_orderdate date,
86304
 
    cohist_invcnumber text,
86305
 
    cohist_invcdate date,
86306
 
    cohist_qtyshipped numeric(18,6),
86307
 
    cohist_unitprice numeric(16,4),
86308
 
    cohist_shipto_id integer,
86309
 
    cohist_salesrep_id integer,
86310
 
    cohist_duedate date,
86311
 
    cohist_imported boolean DEFAULT false,
86312
 
    cohist_billtoname text,
86313
 
    cohist_billtoaddress1 text,
86314
 
    cohist_billtoaddress2 text,
86315
 
    cohist_billtoaddress3 text,
86316
 
    cohist_billtocity text,
86317
 
    cohist_billtostate text,
86318
 
    cohist_billtozip text,
86319
 
    cohist_shiptoname text,
86320
 
    cohist_shiptoaddress1 text,
86321
 
    cohist_shiptoaddress2 text,
86322
 
    cohist_shiptoaddress3 text,
86323
 
    cohist_shiptocity text,
86324
 
    cohist_shiptostate text,
86325
 
    cohist_shiptozip text,
86326
 
    cohist_commission numeric(16,4),
86327
 
    cohist_commissionpaid boolean,
86328
 
    cohist_unitcost numeric(18,6),
86329
 
    cohist_misc_type character(1),
86330
 
    cohist_misc_descrip text,
86331
 
    cohist_misc_id integer,
86332
 
    cohist_doctype text,
86333
 
    cohist_promisedate date,
86334
 
    cohist_ponumber text,
86335
 
    cohist_curr_id integer DEFAULT basecurrid(),
86336
 
    cohist_sequence integer,
86337
 
    cohist_taxtype_id integer,
86338
 
    cohist_taxzone_id integer,
86339
 
    cohist_cohead_ccpay_id integer,
86340
 
    cohist_saletype_id integer,
86341
 
    cohist_shipzone_id integer
86342
 
);
86343
 
 
86344
 
 
86345
 
ALTER TABLE public.cohist OWNER TO admin;
86346
 
 
86347
 
--
86348
 
--
86349
 
 
86350
 
COMMENT ON TABLE cohist IS 'Sales Order history';
86351
 
 
86352
 
 
86353
 
--
86354
 
--
86355
 
 
86356
 
COMMENT ON COLUMN cohist.cohist_cohead_ccpay_id IS 'Credit card payments made at sales order time (as opposed to invoice time) need special treatment. This field allows checking for this case.';
86357
 
 
86358
 
 
86359
 
--
86360
 
--
86361
 
 
86362
 
COMMENT ON COLUMN cohist.cohist_saletype_id IS 'Associated sale type for sales history.';
86363
 
 
86364
 
 
86365
 
--
86366
 
--
86367
 
 
86368
 
COMMENT ON COLUMN cohist.cohist_shipzone_id IS 'Associated shipping zone for sales history.';
86369
 
 
86370
 
 
86371
 
--
86372
 
--
86373
 
 
86374
 
CREATE TABLE taxhist (
86375
 
    taxhist_id integer NOT NULL,
86376
 
    taxhist_parent_id integer NOT NULL,
86377
 
    taxhist_taxtype_id integer,
86378
 
    taxhist_tax_id integer NOT NULL,
86379
 
    taxhist_basis numeric(16,2) NOT NULL,
86380
 
    taxhist_basis_tax_id integer,
86381
 
    taxhist_sequence integer,
86382
 
    taxhist_percent numeric(10,6) NOT NULL,
86383
 
    taxhist_amount numeric(16,2) NOT NULL,
86384
 
    taxhist_tax numeric(16,6) NOT NULL,
86385
 
    taxhist_docdate date NOT NULL,
86386
 
    taxhist_distdate date,
86387
 
    taxhist_curr_id integer,
86388
 
    taxhist_curr_rate numeric,
86389
 
    taxhist_journalnumber integer
86390
 
);
86391
 
 
86392
 
 
86393
 
ALTER TABLE public.taxhist OWNER TO admin;
86394
 
 
86395
 
--
86396
 
--
86397
 
 
86398
 
COMMENT ON TABLE taxhist IS 'A table type to record tax transaction history. Inherited by other tables that actually record history. As the parent, queries can be run against it that will join all child tables. ';
86399
 
 
86400
 
 
86401
 
--
86402
 
--
86403
 
 
86404
 
COMMENT ON COLUMN taxhist.taxhist_id IS 'Primary key';
86405
 
 
86406
 
 
86407
 
--
86408
 
--
86409
 
 
86410
 
COMMENT ON COLUMN taxhist.taxhist_parent_id IS 'Source parent id.';
86411
 
 
86412
 
 
86413
 
--
86414
 
--
86415
 
 
86416
 
COMMENT ON COLUMN taxhist.taxhist_taxtype_id IS 'Tax type id';
86417
 
 
86418
 
 
86419
 
--
86420
 
--
86421
 
 
86422
 
COMMENT ON COLUMN taxhist.taxhist_tax_id IS 'Tax code id.';
86423
 
 
86424
 
 
86425
 
--
86426
 
--
86427
 
 
86428
 
COMMENT ON COLUMN taxhist.taxhist_basis IS 'Base price amount on which the tax calculation is based.';
86429
 
 
86430
 
 
86431
 
--
86432
 
--
86433
 
 
86434
 
COMMENT ON COLUMN taxhist.taxhist_basis_tax_id IS 'Tax rate calculation basis.  If null, then the amount of the parent document, otherwise calculated on the result amount of the tax code id referenced.';
86435
 
 
86436
 
 
86437
 
--
86438
 
--
86439
 
 
86440
 
COMMENT ON COLUMN taxhist.taxhist_amount IS 'Flat tax amount.';
86441
 
 
86442
 
 
86443
 
--
86444
 
--
86445
 
 
86446
 
COMMENT ON COLUMN taxhist.taxhist_tax IS 'Calculated tax amount.';
86447
 
 
86448
 
 
86449
 
--
86450
 
--
86451
 
 
86452
 
COMMENT ON COLUMN taxhist.taxhist_docdate IS 'The date of the parent document.';
86453
 
 
86454
 
 
86455
 
--
86456
 
--
86457
 
 
86458
 
COMMENT ON COLUMN taxhist.taxhist_distdate IS 'The G/L distribution date of the parent document.';
86459
 
 
86460
 
 
86461
 
--
86462
 
--
86463
 
 
86464
 
CREATE TABLE cohisttax (
86465
 
)
86466
 
INHERITS (taxhist);
86467
 
 
86468
 
 
86469
 
ALTER TABLE public.cohisttax OWNER TO admin;
86470
 
 
86471
 
SET search_path = api, pg_catalog;
86472
 
 
86473
 
--
86474
 
--
86475
 
 
86476
 
CREATE VIEW saleshistory AS
86477
 
    SELECT custinfo.cust_number AS customer_number, item.item_number, whsinfo.warehous_code AS site_code, cohist.cohist_shipdate AS ship_date, cohist.cohist_shipvia AS ship_via, cohist.cohist_ordernumber AS order_number, cohist.cohist_ponumber AS purchase_order_number, cohist.cohist_orderdate AS order_date, cohist.cohist_invcnumber AS invoice_number, cohist.cohist_invcdate AS invoice_date, cohist.cohist_qtyshipped AS quantity_shipped, cohist.cohist_unitprice AS unit_price, shiptoinfo.shipto_num AS shipto_number, salesrep.salesrep_number AS sales_rep, cohist.cohist_duedate AS due_date, cohist.cohist_promisedate AS promise_date, cohist.cohist_imported AS imported, cohist.cohist_billtoname AS billto_name, cohist.cohist_billtoaddress1 AS billto_address1, cohist.cohist_billtoaddress2 AS billto_address2, cohist.cohist_billtoaddress3 AS billto_address3, cohist.cohist_billtocity AS billto_city, cohist.cohist_billtostate AS billto_state, cohist.cohist_billtozip AS billto_zip, cohist.cohist_shiptoname AS shipto_name, cohist.cohist_shiptoaddress1 AS shipto_address1, cohist.cohist_shiptoaddress2 AS shipto_address2, cohist.cohist_shiptoaddress3 AS shipto_address3, cohist.cohist_shiptocity AS shipto_city, cohist.cohist_shiptostate AS shipto_state, cohist.cohist_shiptozip AS shipto_zip, cohist.cohist_commission AS commission, cohist.cohist_commissionpaid AS commission_paid, cohist.cohist_unitcost AS unit_cost, CASE WHEN (cohist.cohist_misc_type IS NULL) THEN ''::text WHEN (cohist.cohist_misc_type = 'M'::bpchar) THEN 'Misc. Charge'::text WHEN (cohist.cohist_misc_type = 'F'::bpchar) THEN 'Freight'::text ELSE 'Unknown'::text END AS misc_type, cohist.cohist_misc_descrip AS misc_description, CASE WHEN (cohist.cohist_misc_id IS NULL) THEN ''::text WHEN (cohist.cohist_misc_type = 'M'::bpchar) THEN public.formatglaccount(cohist.cohist_misc_id) ELSE 'Unknown'::text END AS misc_info, taxzone.taxzone_code AS tax_zone, taxtype.taxtype_name AS tax_type, CASE WHEN (cohist.cohist_doctype = 'I'::text) THEN 'Invoice'::text WHEN (cohist.cohist_doctype = 'C'::text) THEN 'Credit Memo'::text ELSE 'Unknown'::text END AS document_type, curr_symbol.curr_abbr AS currency, cohist.cohist_sequence AS gl_sequence, (SELECT sum(cohisttax.taxhist_tax) AS sum FROM public.cohisttax WHERE (cohisttax.taxhist_parent_id = cohist.cohist_id)) AS tax FROM (((((((((public.cohist LEFT JOIN public.custinfo ON ((cohist.cohist_cust_id = custinfo.cust_id))) LEFT JOIN public.shiptoinfo ON ((cohist.cohist_shipto_id = shiptoinfo.shipto_id))) LEFT JOIN public.taxzone ON ((cohist.cohist_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.taxtype ON ((cohist.cohist_taxtype_id = taxtype.taxtype_id))) LEFT JOIN public.salesrep ON ((cohist.cohist_salesrep_id = salesrep.salesrep_id))) LEFT JOIN public.itemsite ON ((cohist.cohist_itemsite_id = itemsite.itemsite_id))) LEFT JOIN public.item ON ((itemsite.itemsite_item_id = item.item_id))) LEFT JOIN public.whsinfo ON ((itemsite.itemsite_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.curr_symbol ON ((cohist.cohist_curr_id = curr_symbol.curr_id)));
86478
 
 
86479
 
 
86480
 
ALTER TABLE api.saleshistory OWNER TO admin;
86481
 
 
86482
 
--
86483
 
--
86484
 
 
86485
 
COMMENT ON VIEW saleshistory IS 'Sales History';
86486
 
 
86487
 
 
86488
 
--
86489
 
--
86490
 
 
86491
 
CREATE VIEW saleslinechar AS
86492
 
    SELECT (data.order_number)::character varying AS order_number, data.line_number, data.characteristic, COALESCE(si.charass_value, i3.charass_value) AS value, (COALESCE(si.charass_price, public.itemcharprice(data.item_id, data.char_id, COALESCE(si.charass_value, i3.charass_value), data.cohead_cust_id, data.cohead_shipto_id, data.coitem_qtyord, data.cohead_curr_id, data.cohead_orderdate), (0)::numeric))::numeric(16,4) AS price FROM (((((SELECT DISTINCT cohead.cohead_cust_id, cohead.cohead_shipto_id, cohead.cohead_curr_id, cohead.cohead_orderdate, coitem.coitem_id, coitem.coitem_itemsite_id, coitem.coitem_qtyord, "char".char_id, item.item_id, cohead.cohead_number AS order_number, CASE WHEN (coitem.coitem_subnumber = 0) THEN ((coitem.coitem_linenumber)::character varying)::text ELSE ((((coitem.coitem_linenumber)::character varying)::text || ('.'::character varying)::text) || ((coitem.coitem_subnumber)::character varying)::text) END AS line_number, "char".char_name AS characteristic FROM public.cohead, public.coitem, public.itemsite, public.item, public.charass, public."char" WHERE ((((((cohead.cohead_id = coitem.coitem_cohead_id) AND (coitem.coitem_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (charass.charass_char_id = "char".char_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id))) data LEFT JOIN public.charass si ON ((((data.coitem_id = si.charass_target_id) AND ('SI'::text = si.charass_target_type)) AND (si.charass_char_id = data.char_id)))) LEFT JOIN public.itemsite i1 ON ((data.coitem_itemsite_id = i1.itemsite_id))) LEFT JOIN public.item i2 ON ((i1.itemsite_item_id = i2.item_id))) LEFT JOIN public.charass i3 ON (((((i2.item_id = i3.charass_target_id) AND ('I'::text = i3.charass_target_type)) AND (i3.charass_char_id = data.char_id)) AND i3.charass_default))) ORDER BY (data.order_number)::character varying, data.line_number, data.characteristic;
86493
 
 
86494
 
 
86495
 
ALTER TABLE api.saleslinechar OWNER TO admin;
86496
 
 
86497
 
--
86498
 
--
86499
 
 
86500
 
COMMENT ON VIEW saleslinechar IS 'Sales Order Line Item Characteristic';
86501
 
 
86502
 
 
86503
 
--
86504
 
--
86505
 
 
86506
 
CREATE VIEW saleslinecomment AS
86507
 
    SELECT (cohead.cohead_number)::character varying AS order_number, CASE WHEN (coitem.coitem_subnumber = 0) THEN ((coitem.coitem_linenumber)::character varying)::text ELSE ((((coitem.coitem_linenumber)::character varying)::text || ('.'::character varying)::text) || ((coitem.coitem_subnumber)::character varying)::text) END AS line_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.cohead, public.coitem, public.cmnttype, public.comment WHERE ((((cohead.cohead_id = coitem.coitem_cohead_id) AND (comment.comment_source = 'SI'::text)) AND (comment.comment_source_id = coitem.coitem_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)) ORDER BY cohead.cohead_number, coitem.coitem_linenumber, comment.comment_date DESC;
86508
 
 
86509
 
 
86510
 
ALTER TABLE api.saleslinecomment OWNER TO admin;
86511
 
 
86512
 
--
86513
 
--
86514
 
 
86515
 
COMMENT ON VIEW saleslinecomment IS 'Sales Order Line Item Comment';
86516
 
 
86517
 
 
86518
 
--
86519
 
--
86520
 
 
86521
 
CREATE VIEW salesorder AS
86522
 
    SELECT (cohead.cohead_number)::character varying AS order_number, whsinfo.warehous_code AS site, cohead.cohead_orderdate AS order_date, cohead.cohead_packdate AS pack_date, saletype.saletype_code AS sale_type, salesrep.salesrep_number AS sales_rep, cohead.cohead_commission AS commission, COALESCE(taxzone.taxzone_code, 'None'::text) AS tax_zone, terms.terms_code AS terms, prj.prj_number AS project_number, custinfo.cust_number AS customer_number, bc.cntct_number AS billto_contact_number, cohead.cohead_billto_cntct_honorific AS billto_contact_name, cohead.cohead_billto_cntct_first_name AS billto_contact_first, cohead.cohead_billto_cntct_middle AS billto_contact_middle, cohead.cohead_billto_cntct_last_name AS billto_contact_last, cohead.cohead_billto_cntct_suffix AS billto_contact_suffix, cohead.cohead_billto_cntct_phone AS billto_contact_phone, cohead.cohead_billto_cntct_title AS billto_contact_title, cohead.cohead_billto_cntct_fax AS billto_contct_fax, cohead.cohead_billto_cntct_email AS billto_contact_email, cohead.cohead_billtoname AS billto_name, cohead.cohead_billtoaddress1 AS billto_address1, cohead.cohead_billtoaddress2 AS billto_address2, cohead.cohead_billtoaddress3 AS billto_address3, cohead.cohead_billtocity AS billto_city, cohead.cohead_billtostate AS billto_state, cohead.cohead_billtozipcode AS billto_postal_code, cohead.cohead_billtocountry AS billto_country, shiptoinfo.shipto_num AS shipto_number, sc.cntct_number AS shipto_contact_number, cohead.cohead_shipto_cntct_honorific AS shipto_contact_honorific, cohead.cohead_shipto_cntct_first_name AS shipto_contact_first, cohead.cohead_shipto_cntct_middle AS shipto_contact_middle, cohead.cohead_shipto_cntct_last_name AS shipto_contact_last, cohead.cohead_shipto_cntct_suffix AS shipto_contact_suffix, cohead.cohead_shipto_cntct_phone AS shipto_contact_phone, cohead.cohead_shipto_cntct_title AS shipto_contact_title, cohead.cohead_shipto_cntct_fax AS shipto_contact_fax, cohead.cohead_shipto_cntct_email AS shipto_contact_email, cohead.cohead_shiptoname AS shipto_name, cohead.cohead_shiptophone AS shipto_phone, cohead.cohead_shiptoaddress1 AS shipto_address1, cohead.cohead_shiptoaddress2 AS shipto_address2, cohead.cohead_shiptoaddress3 AS shipto_address3, cohead.cohead_shiptocity AS shipto_city, cohead.cohead_shiptostate AS shipto_state, cohead.cohead_shiptozipcode AS shipto_postal_code, cohead.cohead_shiptocountry AS shipto_country, shipzone.shipzone_name AS shipto_shipzone, cohead.cohead_custponumber AS cust_po_number, cohead.cohead_fob AS fob, cohead.cohead_shipvia AS ship_via, CASE WHEN (cohead.cohead_holdtype = 'N'::bpchar) THEN 'None'::text WHEN (cohead.cohead_holdtype = 'C'::bpchar) THEN 'Credit'::text WHEN (cohead.cohead_holdtype = 'S'::bpchar) THEN 'Shipping'::text WHEN (cohead.cohead_holdtype = 'P'::bpchar) THEN 'Packing'::text WHEN (cohead.cohead_holdtype = 'R'::bpchar) THEN 'Return'::text ELSE 'Error'::text END AS hold_type, shipchrg.shipchrg_name AS shipping_chgs, shipform.shipform_name AS shipping_form, cohead.cohead_shipcomplete AS ship_complete, curr_symbol.curr_abbr AS currency, cohead.cohead_misc_descrip AS misc_charge_description, CASE WHEN (cohead.cohead_misc_accnt_id IS NULL) THEN NULL::text ELSE public.formatglaccount(cohead.cohead_misc_accnt_id) END AS misc_account_number, cohead.cohead_misc AS misc_charge, cohead.cohead_freight AS freight, cohead.cohead_calcfreight AS calculate_freight, cohead.cohead_ordercomments AS order_notes, cohead.cohead_shipcomments AS shipping_notes, false AS add_to_packing_list_batch FROM (((((((((public.cohead LEFT JOIN public.cntct bc ON ((cohead.cohead_billto_cntct_id = bc.cntct_id))) LEFT JOIN public.cntct sc ON ((cohead.cohead_shipto_cntct_id = sc.cntct_id))) LEFT JOIN public.whsinfo ON ((cohead.cohead_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.prj ON ((cohead.cohead_prj_id = prj.prj_id))) LEFT JOIN public.shiptoinfo ON ((cohead.cohead_shipto_id = shiptoinfo.shipto_id))) LEFT JOIN public.shipchrg ON ((cohead.cohead_shipchrg_id = shipchrg.shipchrg_id))) LEFT JOIN public.taxzone ON ((cohead.cohead_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.saletype ON ((cohead.cohead_saletype_id = saletype.saletype_id))) LEFT JOIN public.shipzone ON ((cohead.cohead_shipzone_id = shipzone.shipzone_id))), public.custinfo, public.shipform, public.salesrep, public.terms, public.curr_symbol WHERE (((((cohead.cohead_cust_id = custinfo.cust_id) AND (cohead.cohead_shipform_id = shipform.shipform_id)) AND (cohead.cohead_salesrep_id = salesrep.salesrep_id)) AND (cohead.cohead_terms_id = terms.terms_id)) AND (cohead.cohead_curr_id = curr_symbol.curr_id));
86523
 
 
86524
 
 
86525
 
ALTER TABLE api.salesorder OWNER TO admin;
86526
 
 
86527
 
--
86528
 
--
86529
 
 
86530
 
COMMENT ON VIEW salesorder IS 'Sales Order';
86531
 
 
86532
 
 
86533
 
--
86534
 
--
86535
 
 
86536
 
CREATE VIEW salesordercomment AS
86537
 
    SELECT (cohead.cohead_number)::character varying AS order_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.cohead, public.cmnttype, public.comment WHERE (((comment.comment_source = 'S'::text) AND (comment.comment_source_id = cohead.cohead_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id));
86538
 
 
86539
 
 
86540
 
ALTER TABLE api.salesordercomment OWNER TO admin;
86541
 
 
86542
 
--
86543
 
--
86544
 
 
86545
 
COMMENT ON VIEW salesordercomment IS 'Sales Order Comment';
86546
 
 
86547
 
 
86548
 
--
86549
 
--
86550
 
 
86551
 
CREATE VIEW salesrep AS
86552
 
    SELECT (salesrep.salesrep_number)::character varying AS number, salesrep.salesrep_active AS active, salesrep.salesrep_name AS name, (salesrep.salesrep_commission * (100)::numeric) AS commission_percent, emp.emp_number AS employee FROM (public.salesrep LEFT JOIN public.emp ON ((emp.emp_id = salesrep.salesrep_emp_id))) ORDER BY salesrep.salesrep_number;
86553
 
 
86554
 
 
86555
 
ALTER TABLE api.salesrep OWNER TO admin;
86556
 
 
86557
 
--
86558
 
--
86559
 
 
86560
 
COMMENT ON VIEW salesrep IS 'Sales Rep';
86561
 
 
86562
 
 
86563
 
SET search_path = public, pg_catalog;
86564
 
 
86565
 
--
86566
 
--
86567
 
 
86568
 
CREATE TABLE shipvia (
86569
 
    shipvia_id integer DEFAULT nextval(('shipvia_shipvia_id_seq'::text)::regclass) NOT NULL,
86570
 
    shipvia_code text NOT NULL,
86571
 
    shipvia_descrip text,
86572
 
    CONSTRAINT shipvia_shipvia_code_check CHECK ((shipvia_code <> ''::text))
86573
 
);
86574
 
 
86575
 
 
86576
 
ALTER TABLE public.shipvia OWNER TO admin;
86577
 
 
86578
 
--
86579
 
--
86580
 
 
86581
 
COMMENT ON TABLE shipvia IS 'Ship Via information';
86582
 
 
86583
 
 
86584
 
--
86585
 
--
86586
 
 
86587
 
CREATE TABLE sitetype (
86588
 
    sitetype_id integer NOT NULL,
86589
 
    sitetype_name text NOT NULL,
86590
 
    sitetype_descrip text,
86591
 
    CONSTRAINT sitetype_sitetype_name_check CHECK ((sitetype_name <> ''::text))
86592
 
);
86593
 
 
86594
 
 
86595
 
ALTER TABLE public.sitetype OWNER TO admin;
86596
 
 
86597
 
--
86598
 
--
86599
 
 
86600
 
COMMENT ON TABLE sitetype IS 'This table is the different types of sites.';
86601
 
 
86602
 
 
86603
 
SET search_path = api, pg_catalog;
86604
 
 
86605
 
--
86606
 
--
86607
 
 
86608
 
CREATE VIEW site AS
86609
 
    SELECT (whsinfo.warehous_code)::character varying AS code, st.sitetype_name AS type, whsinfo.warehous_active AS active, whsinfo.warehous_descrip AS description, m.addr_number AS address_number, m.addr_line1 AS address1, m.addr_line2 AS address2, m.addr_line3 AS address3, m.addr_city AS city, m.addr_state AS state, m.addr_postalcode AS postal_code, m.addr_country AS country, ''::text AS address_change, c.cntct_number AS contact_number, c.cntct_honorific AS honorific, c.cntct_first_name AS first, c.cntct_middle AS middle, c.cntct_last_name AS last, c.cntct_suffix AS suffix, c.cntct_title AS job_title, c.cntct_phone AS phone, c.cntct_fax AS fax, c.cntct_email AS email, ''::text AS contact_change, public.formatglaccount(a.accnt_id) AS post_unassigned_transactions_to, a.accnt_descrip AS post_unassigned_transactions_to_description, whsinfo.warehous_transit AS transit_type, CASE WHEN whsinfo.warehous_transit THEN false ELSE true END AS inventory_type, CASE WHEN whsinfo.warehous_transit THEN ''::text ELSE whsinfo.warehous_bol_prefix END AS next_bill_of_lading_prefix, CASE WHEN whsinfo.warehous_transit THEN 0 ELSE whsinfo.warehous_bol_number END AS next_bill_of_lading_number, CASE WHEN whsinfo.warehous_transit THEN false ELSE whsinfo.warehous_shipping END AS shipping_site, CASE WHEN whsinfo.warehous_transit THEN ''::text ELSE whsinfo.warehous_counttag_prefix END AS next_count_tag_prefix, CASE WHEN whsinfo.warehous_transit THEN 0 ELSE whsinfo.warehous_counttag_number END AS next_count_tag_number, CASE WHEN whsinfo.warehous_transit THEN false ELSE whsinfo.warehous_useslips END AS force_the_use_of_count_slips, CASE WHEN whsinfo.warehous_transit THEN false ELSE whsinfo.warehous_usezones END AS force_the_use_of_zones, CASE WHEN whsinfo.warehous_transit THEN 0 ELSE whsinfo.warehous_sequence END AS scheduling_sequence, CASE WHEN whsinfo.warehous_transit THEN (0)::numeric ELSE (whsinfo.warehous_shipping_commission * 100.0) END AS shipping_commission, CASE WHEN whsinfo.warehous_transit THEN ''::text ELSE t.taxzone_code END AS tax_zone, CASE WHEN whsinfo.warehous_transit THEN ''::text ELSE whsinfo.warehous_fob END AS default_fob, CASE WHEN whsinfo.warehous_transit THEN s.shipvia_code ELSE ''::text END AS default_ship_via, CASE WHEN whsinfo.warehous_transit THEN f.shipform_name ELSE ''::text END AS default_shipping_form, CASE WHEN whsinfo.warehous_transit THEN cc.costcat_code ELSE ''::text END AS default_cost_category, CASE WHEN whsinfo.warehous_transit THEN whsinfo.warehous_shipcomments ELSE ''::text END AS shipping_comments, CASE WHEN whsinfo.warehous_transit THEN false ELSE whsinfo.warehous_enforcearbl END AS enforce_arbl_naming_convention, CASE WHEN whsinfo.warehous_transit THEN 0 WHEN whsinfo.warehous_enforcearbl THEN whsinfo.warehous_aislesize ELSE 0 END AS aisle_size, CASE WHEN whsinfo.warehous_transit THEN false WHEN (whsinfo.warehous_enforcearbl AND whsinfo.warehous_aislealpha) THEN true ELSE false END AS aisle_allow_alpha_characters, CASE WHEN whsinfo.warehous_transit THEN 0 WHEN whsinfo.warehous_enforcearbl THEN whsinfo.warehous_racksize ELSE 0 END AS rack_size, CASE WHEN whsinfo.warehous_transit THEN false WHEN (whsinfo.warehous_enforcearbl AND whsinfo.warehous_rackalpha) THEN true ELSE false END AS rack_allow_alpha_characters, CASE WHEN whsinfo.warehous_transit THEN 0 WHEN whsinfo.warehous_enforcearbl THEN whsinfo.warehous_binsize ELSE 0 END AS bin_size, CASE WHEN whsinfo.warehous_transit THEN false WHEN (whsinfo.warehous_enforcearbl AND whsinfo.warehous_binalpha) THEN true ELSE false END AS bin_allow_alpha_characters, CASE WHEN whsinfo.warehous_transit THEN 0 WHEN whsinfo.warehous_enforcearbl THEN whsinfo.warehous_locationsize ELSE 0 END AS location_size, CASE WHEN whsinfo.warehous_transit THEN false WHEN (whsinfo.warehous_enforcearbl AND whsinfo.warehous_locationalpha) THEN true ELSE false END AS location_allow_alpha_characters FROM ((((((((public.whsinfo LEFT JOIN public.addr m ON ((whsinfo.warehous_addr_id = m.addr_id))) LEFT JOIN public.cntct c ON ((whsinfo.warehous_cntct_id = c.cntct_id))) LEFT JOIN public.accnt a ON ((whsinfo.warehous_default_accnt_id = a.accnt_id))) LEFT JOIN public.taxzone t ON ((whsinfo.warehous_taxzone_id = t.taxzone_id))) LEFT JOIN public.shipvia s ON ((whsinfo.warehous_shipvia_id = s.shipvia_id))) LEFT JOIN public.shipform f ON ((whsinfo.warehous_shipform_id = f.shipform_id))) LEFT JOIN public.costcat cc ON ((whsinfo.warehous_costcat_id = cc.costcat_id))) LEFT JOIN public.sitetype st ON ((whsinfo.warehous_sitetype_id = st.sitetype_id))) ORDER BY whsinfo.warehous_code;
86610
 
 
86611
 
 
86612
 
ALTER TABLE api.site OWNER TO admin;
86613
 
 
86614
 
--
86615
 
--
86616
 
 
86617
 
COMMENT ON VIEW site IS 'Site';
86618
 
 
86619
 
 
86620
 
--
86621
 
--
86622
 
 
86623
 
CREATE VIEW sitezone AS
86624
 
    SELECT (whsinfo.warehous_code)::character varying AS site, (whsezone.whsezone_name)::character varying AS name, whsezone.whsezone_descrip AS description FROM (public.whsezone LEFT JOIN public.whsinfo ON ((whsinfo.warehous_id = whsezone.whsezone_warehous_id)));
86625
 
 
86626
 
 
86627
 
ALTER TABLE api.sitezone OWNER TO admin;
86628
 
 
86629
 
--
86630
 
--
86631
 
 
86632
 
COMMENT ON VIEW sitezone IS 'Site Zone';
86633
 
 
86634
 
 
86635
 
--
86636
 
--
86637
 
 
86638
 
CREATE VIEW task AS
86639
 
    SELECT prj.prj_number AS project_number, prjtask.prjtask_number AS number, CASE WHEN (prjtask.prjtask_status = 'P'::bpchar) THEN 'Concept'::text WHEN (prjtask.prjtask_status = 'O'::bpchar) THEN 'In-Process'::text WHEN (prjtask.prjtask_status = 'C'::bpchar) THEN 'Closed'::text ELSE 'Error'::text END AS status, prjtask.prjtask_name AS name, prjtask.prjtask_descrip AS description, prjtask.prjtask_owner_username AS owner, prjtask.prjtask_username AS assigned_to, prjtask.prjtask_hours_budget AS hours_budgeted, prjtask.prjtask_hours_actual AS hours_actual, prjtask.prjtask_exp_budget AS expenses_budgeted, prjtask.prjtask_exp_actual AS expenses_actual, prjtask.prjtask_due_date AS due, prjtask.prjtask_assigned_date AS assigned, prjtask.prjtask_start_date AS started, prjtask.prjtask_completed_date AS completed FROM (public.prjtask JOIN public.prj ON ((prj.prj_id = prjtask.prjtask_prj_id)));
86640
 
 
86641
 
 
86642
 
ALTER TABLE api.task OWNER TO admin;
86643
 
 
86644
 
--
86645
 
--
86646
 
 
86647
 
COMMENT ON VIEW task IS 'Task';
86648
 
 
86649
 
 
86650
 
--
86651
 
--
86652
 
 
86653
 
CREATE VIEW taskcomment AS
86654
 
    SELECT (prj.prj_number)::character varying AS project_number, (prjtask.prjtask_number)::character varying AS task_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.prj, public.prjtask, public.cmnttype, public.comment WHERE ((((comment.comment_source = 'TA'::text) AND (prj.prj_id = prjtask.prjtask_prj_id)) AND (comment.comment_source_id = prjtask.prjtask_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id));
86655
 
 
86656
 
 
86657
 
ALTER TABLE api.taskcomment OWNER TO admin;
86658
 
 
86659
 
--
86660
 
--
86661
 
 
86662
 
COMMENT ON VIEW taskcomment IS 'Task Comment';
86663
 
 
86664
 
 
86665
 
--
86666
 
--
86667
 
 
86668
 
CREATE VIEW todo AS
86669
 
    SELECT todoitem.todoitem_id AS task_number, todoitem.todoitem_owner_username AS owner, todoitem.todoitem_username AS assigned_to, todoitem.todoitem_name AS task_name, incdtpriority.incdtpriority_name AS priority, incdt.incdt_number AS incident, ophead.ophead_name AS opportunity, crmacct.crmacct_number AS account, public.formatdate(todoitem.todoitem_due_date) AS date_due, public.formatdate(todoitem.todoitem_assigned_date) AS date_assigned, public.formatdate(todoitem.todoitem_start_date) AS date_started, public.formatdate(todoitem.todoitem_completed_date) AS date_completed, CASE WHEN (todoitem.todoitem_status = 'P'::bpchar) THEN 'Pending Input'::text WHEN (todoitem.todoitem_status = 'D'::bpchar) THEN 'Deferred'::text ELSE 'Neither'::text END AS status, todoitem.todoitem_active AS active, todoitem.todoitem_description AS description, todoitem.todoitem_notes AS notes FROM ((((public.todoitem LEFT JOIN public.incdt ON ((incdt.incdt_id = todoitem.todoitem_incdt_id))) LEFT JOIN public.ophead ON ((ophead.ophead_id = todoitem.todoitem_ophead_id))) LEFT JOIN public.crmacct ON ((crmacct.crmacct_id = todoitem.todoitem_crmacct_id))) LEFT JOIN public.incdtpriority ON ((incdtpriority.incdtpriority_id = todoitem.todoitem_priority_id)));
86670
 
 
86671
 
 
86672
 
ALTER TABLE api.todo OWNER TO admin;
86673
 
 
86674
 
--
86675
 
--
86676
 
 
86677
 
COMMENT ON VIEW todo IS 'To-Do List';
86678
 
 
86679
 
 
86680
 
SET search_path = public, pg_catalog;
86681
 
 
86682
 
--
86683
 
--
86684
 
 
86685
 
CREATE TABLE vendtype (
86686
 
    vendtype_id integer NOT NULL,
86687
 
    vendtype_code text NOT NULL,
86688
 
    vendtype_descrip text,
86689
 
    CONSTRAINT vendtype_vendtype_code_check CHECK ((vendtype_code <> ''::text))
86690
 
);
86691
 
 
86692
 
 
86693
 
ALTER TABLE public.vendtype OWNER TO admin;
86694
 
 
86695
 
--
86696
 
--
86697
 
 
86698
 
COMMENT ON TABLE vendtype IS 'Vendor Type information';
86699
 
 
86700
 
 
86701
 
SET search_path = api, pg_catalog;
86702
 
 
86703
 
--
86704
 
--
86705
 
 
86706
 
CREATE VIEW vendor AS
86707
 
    SELECT (vendinfo.vend_number)::character varying AS vendor_number, vendtype.vendtype_code AS vendor_type, vendinfo.vend_name AS vendor_name, vendinfo.vend_active AS active, vendinfo.vend_accntnum AS account_number, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postalcode, addr.addr_country AS country, ''::text AS address_change, terms.terms_code AS default_terms, vendinfo.vend_shipvia AS ship_via, curr_symbol.curr_abbr AS default_currency, CASE WHEN (vendinfo.vend_fobsource = 'W'::bpchar) THEN 'Receiving Site'::text ELSE vendinfo.vend_fob END AS default_fob, vendinfo.vend_po AS sells_purchase_order_items, vendinfo.vend_restrictpurch AS may_only_sell_item_source, vendinfo.vend_qualified AS qualified, vendinfo.vend_match AS matching_vo_po_amounts, vendinfo.vend_1099 AS receives_1099, taxzone.taxzone_code AS default_tax_zone, CASE WHEN (accnt.accnt_id IS NULL) THEN 'N/A'::text ELSE public.formatglaccount(accnt.accnt_id) END AS default_dist_gl_account, CASE WHEN (expcat.expcat_id IS NULL) THEN 'N/A'::text ELSE expcat.expcat_code END AS default_dist_expense_category, CASE WHEN (tax.tax_id IS NULL) THEN 'N/A'::text ELSE tax.tax_code END AS default_dist_tax_code, c1.cntct_number AS contact1_number, c1.cntct_honorific AS contact1_honorific, c1.cntct_first_name AS contact1_first, c1.cntct_middle AS contact1_middle, c1.cntct_last_name AS contact1_last, c1.cntct_suffix AS contact1_suffix, c1.cntct_title AS contact1_job_title, c1.cntct_phone AS contact1_voice, c1.cntct_phone2 AS contact1_alternate, c1.cntct_fax AS contact1_fax, c1.cntct_email AS contact1_email, c1.cntct_webaddr AS contact1_web, ''::text AS contact1_change, c2.cntct_number AS contact2_number, c2.cntct_honorific AS contact2_honorific, c2.cntct_first_name AS contact2_first, c2.cntct_middle AS contact2_middle, c2.cntct_last_name AS contact2_last, c2.cntct_suffix AS contact2_suffix, c2.cntct_title AS contact2_job_title, c2.cntct_phone AS contact2_voice, c2.cntct_phone2 AS contact2_alternate, c2.cntct_fax AS contact2_fax, c2.cntct_email AS contact2_email, c2.cntct_webaddr AS contact2_web, ''::text AS contact2_change, vendinfo.vend_comments AS notes, vendinfo.vend_pocomments AS po_comments, vendinfo.vend_emailpodelivery AS allow_email_po_delivery, vendinfo.vend_ediemail AS po_edi_email, vendinfo.vend_edicc AS po_edi_cc, vendinfo.vend_edisubject AS po_edi_subject, vendinfo.vend_edifilename AS po_edi_filename, vendinfo.vend_ediemailbody AS po_edi_emailbody FROM ((((((((((public.vendinfo LEFT JOIN public.addr ON ((vendinfo.vend_addr_id = addr.addr_id))) LEFT JOIN public.cntct c1 ON ((vendinfo.vend_cntct1_id = c1.cntct_id))) LEFT JOIN public.cntct c2 ON ((vendinfo.vend_cntct2_id = c2.cntct_id))) LEFT JOIN public.taxzone ON ((vendinfo.vend_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.curr_symbol ON ((vendinfo.vend_curr_id = curr_symbol.curr_id))) LEFT JOIN public.terms ON ((vendinfo.vend_terms_id = terms.terms_id))) LEFT JOIN public.vendtype ON ((vendinfo.vend_vendtype_id = vendtype.vendtype_id))) LEFT JOIN public.accnt ON ((vendinfo.vend_accnt_id = accnt.accnt_id))) LEFT JOIN public.expcat ON ((vendinfo.vend_expcat_id = expcat.expcat_id))) LEFT JOIN public.tax ON ((vendinfo.vend_tax_id = tax.tax_id))) ORDER BY vendinfo.vend_number;
86708
 
 
86709
 
 
86710
 
ALTER TABLE api.vendor OWNER TO admin;
86711
 
 
86712
 
--
86713
 
--
86714
 
 
86715
 
COMMENT ON VIEW vendor IS 'vendor';
86716
 
 
86717
 
 
86718
 
--
86719
 
--
86720
 
 
86721
 
CREATE VIEW vendoraddress AS
86722
 
    SELECT (vendinfo.vend_number)::character varying AS vendor_number, vendinfo.vend_name AS vendor_name, (vendaddrinfo.vendaddr_code)::character varying AS vendor_address_number, vendaddrinfo.vendaddr_name AS vendor_address_name, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postalcode, addr.addr_country AS country, ''::text AS address_change, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS contact_honorific, cntct.cntct_first_name AS contact_first, cntct.cntct_middle AS contact_middle, cntct.cntct_last_name AS contact_last, cntct.cntct_suffix AS contact_suffix, cntct.cntct_title AS contact_job_title, cntct.cntct_phone AS contact_voice, cntct.cntct_phone2 AS contact_alternate, cntct.cntct_fax AS contact_fax, cntct.cntct_email AS contact_email, cntct.cntct_webaddr AS contact_web, ''::text AS contact_change, vendaddrinfo.vendaddr_comments AS notes FROM (((public.vendaddrinfo LEFT JOIN public.vendinfo ON ((vendinfo.vend_id = vendaddrinfo.vendaddr_vend_id))) LEFT JOIN public.addr ON ((vendaddrinfo.vendaddr_addr_id = addr.addr_id))) LEFT JOIN public.cntct ON ((vendaddrinfo.vendaddr_cntct_id = cntct.cntct_id))) ORDER BY vendaddrinfo.vendaddr_code;
86723
 
 
86724
 
 
86725
 
ALTER TABLE api.vendoraddress OWNER TO admin;
86726
 
 
86727
 
--
86728
 
--
86729
 
 
86730
 
COMMENT ON VIEW vendoraddress IS 'vendor address';
86731
 
 
86732
 
 
86733
 
--
86734
 
--
86735
 
 
86736
 
CREATE VIEW vendortype AS
86737
 
    SELECT (vendtype.vendtype_code)::character varying AS code, vendtype.vendtype_descrip AS description FROM public.vendtype ORDER BY vendtype.vendtype_code;
86738
 
 
86739
 
 
86740
 
ALTER TABLE api.vendortype OWNER TO admin;
86741
 
 
86742
 
--
86743
 
--
86744
 
 
86745
 
COMMENT ON VIEW vendortype IS 'Vendor Type';
86746
 
 
86747
 
 
86748
 
SET search_path = public, pg_catalog;
86749
 
 
86750
 
--
86751
 
--
86752
 
 
86753
 
CREATE TABLE cmd (
86754
 
    cmd_id integer NOT NULL,
86755
 
    cmd_module text NOT NULL,
86756
 
    cmd_title text NOT NULL,
86757
 
    cmd_descrip text,
86758
 
    cmd_privname text,
86759
 
    cmd_executable text NOT NULL,
86760
 
    cmd_name text
86761
 
);
86762
 
 
86763
 
 
86764
 
ALTER TABLE public.cmd OWNER TO admin;
86765
 
 
86766
 
--
86767
 
--
86768
 
 
86769
 
COMMENT ON TABLE cmd IS 'Custom menu command table.';
86770
 
 
86771
 
 
86772
 
--
86773
 
--
86774
 
 
86775
 
CREATE SEQUENCE cmd_cmd_id_seq
86776
 
    START WITH 1
86777
 
    INCREMENT BY 1
86778
 
    NO MINVALUE
86779
 
    NO MAXVALUE
86780
 
    CACHE 1;
86781
 
 
86782
 
 
86783
 
ALTER TABLE public.cmd_cmd_id_seq OWNER TO admin;
86784
 
 
86785
 
--
86786
 
--
86787
 
 
86788
 
ALTER SEQUENCE cmd_cmd_id_seq OWNED BY cmd.cmd_id;
86789
 
 
86790
 
 
86791
 
SET search_path = fixcountry, pg_catalog;
86792
 
 
86793
 
--
86794
 
--
86795
 
 
86796
 
CREATE TABLE pkgcmd (
86797
 
    cmd_id integer DEFAULT nextval('public.cmd_cmd_id_seq'::regclass)
86798
 
)
86799
 
INHERITS (public.cmd);
86800
 
 
86801
 
 
86802
 
ALTER TABLE fixcountry.pkgcmd OWNER TO admin;
86803
 
 
86804
 
SET search_path = public, pg_catalog;
86805
 
 
86806
 
--
86807
 
--
86808
 
 
86809
 
CREATE TABLE cmdarg (
86810
 
    cmdarg_id integer NOT NULL,
86811
 
    cmdarg_cmd_id integer NOT NULL,
86812
 
    cmdarg_order integer NOT NULL,
86813
 
    cmdarg_arg text NOT NULL
86814
 
);
86815
 
 
86816
 
 
86817
 
ALTER TABLE public.cmdarg OWNER TO admin;
86818
 
 
86819
 
--
86820
 
--
86821
 
 
86822
 
COMMENT ON TABLE cmdarg IS 'Command argument for custom menu command table.';
86823
 
 
86824
 
 
86825
 
--
86826
 
--
86827
 
 
86828
 
CREATE SEQUENCE cmdarg_cmdarg_id_seq
86829
 
    START WITH 1
86830
 
    INCREMENT BY 1
86831
 
    NO MINVALUE
86832
 
    NO MAXVALUE
86833
 
    CACHE 1;
86834
 
 
86835
 
 
86836
 
ALTER TABLE public.cmdarg_cmdarg_id_seq OWNER TO admin;
86837
 
 
86838
 
--
86839
 
--
86840
 
 
86841
 
ALTER SEQUENCE cmdarg_cmdarg_id_seq OWNED BY cmdarg.cmdarg_id;
86842
 
 
86843
 
 
86844
 
SET search_path = fixcountry, pg_catalog;
86845
 
 
86846
 
--
86847
 
--
86848
 
 
86849
 
CREATE TABLE pkgcmdarg (
86850
 
    cmdarg_id integer DEFAULT nextval('public.cmdarg_cmdarg_id_seq'::regclass)
86851
 
)
86852
 
INHERITS (public.cmdarg);
86853
 
 
86854
 
 
86855
 
ALTER TABLE fixcountry.pkgcmdarg OWNER TO admin;
86856
 
 
86857
 
SET search_path = public, pg_catalog;
86858
 
 
86859
 
--
86860
 
--
86861
 
 
86862
 
CREATE SEQUENCE image_image_id_seq
86863
 
    START WITH 1
86864
 
    INCREMENT BY 1
86865
 
    NO MINVALUE
86866
 
    MAXVALUE 2147483647
86867
 
    CACHE 1;
86868
 
 
86869
 
 
86870
 
ALTER TABLE public.image_image_id_seq OWNER TO admin;
86871
 
 
86872
 
SET search_path = fixcountry, pg_catalog;
86873
 
 
86874
 
--
86875
 
--
86876
 
 
86877
 
CREATE TABLE pkgimage (
86878
 
    image_id integer DEFAULT nextval('public.image_image_id_seq'::regclass)
86879
 
)
86880
 
INHERITS (public.image);
86881
 
 
86882
 
 
86883
 
ALTER TABLE fixcountry.pkgimage OWNER TO admin;
86884
 
 
86885
 
SET search_path = public, pg_catalog;
86886
 
 
86887
 
--
86888
 
--
86889
 
 
86890
 
CREATE TABLE metasql (
86891
 
    metasql_id integer NOT NULL,
86892
 
    metasql_group text,
86893
 
    metasql_name text,
86894
 
    metasql_notes text,
86895
 
    metasql_query text,
86896
 
    metasql_lastuser text,
86897
 
    metasql_lastupdate date,
86898
 
    metasql_grade integer DEFAULT 0 NOT NULL
86899
 
);
86900
 
 
86901
 
 
86902
 
ALTER TABLE public.metasql OWNER TO admin;
86903
 
 
86904
 
--
86905
 
--
86906
 
 
86907
 
COMMENT ON TABLE metasql IS 'MetaSQL Table';
86908
 
 
86909
 
 
86910
 
--
86911
 
--
86912
 
 
86913
 
CREATE SEQUENCE metasql_metasql_id_seq
86914
 
    START WITH 1
86915
 
    INCREMENT BY 1
86916
 
    NO MINVALUE
86917
 
    NO MAXVALUE
86918
 
    CACHE 1;
86919
 
 
86920
 
 
86921
 
ALTER TABLE public.metasql_metasql_id_seq OWNER TO admin;
86922
 
 
86923
 
--
86924
 
--
86925
 
 
86926
 
ALTER SEQUENCE metasql_metasql_id_seq OWNED BY metasql.metasql_id;
86927
 
 
86928
 
 
86929
 
SET search_path = fixcountry, pg_catalog;
86930
 
 
86931
 
--
86932
 
--
86933
 
 
86934
 
CREATE TABLE pkgmetasql (
86935
 
    metasql_id integer DEFAULT nextval('public.metasql_metasql_id_seq'::regclass)
86936
 
)
86937
 
INHERITS (public.metasql);
86938
 
 
86939
 
 
86940
 
ALTER TABLE fixcountry.pkgmetasql OWNER TO admin;
86941
 
 
86942
 
SET search_path = public, pg_catalog;
86943
 
 
86944
 
--
86945
 
--
86946
 
 
86947
 
CREATE TABLE priv (
86948
 
    priv_id integer DEFAULT nextval(('priv_priv_id_seq'::text)::regclass) NOT NULL,
86949
 
    priv_module text,
86950
 
    priv_name text,
86951
 
    priv_descrip text,
86952
 
    priv_seq integer
86953
 
);
86954
 
 
86955
 
 
86956
 
ALTER TABLE public.priv OWNER TO admin;
86957
 
 
86958
 
--
86959
 
--
86960
 
 
86961
 
COMMENT ON TABLE priv IS 'System Privilege information';
86962
 
 
86963
 
 
86964
 
--
86965
 
--
86966
 
 
86967
 
CREATE SEQUENCE priv_priv_id_seq
86968
 
    START WITH 1
86969
 
    INCREMENT BY 1
86970
 
    NO MINVALUE
86971
 
    MAXVALUE 2147483647
86972
 
    CACHE 1;
86973
 
 
86974
 
 
86975
 
ALTER TABLE public.priv_priv_id_seq OWNER TO admin;
86976
 
 
86977
 
SET search_path = fixcountry, pg_catalog;
86978
 
 
86979
 
--
86980
 
--
86981
 
 
86982
 
CREATE TABLE pkgpriv (
86983
 
    priv_id integer DEFAULT nextval('public.priv_priv_id_seq'::regclass)
86984
 
)
86985
 
INHERITS (public.priv);
86986
 
 
86987
 
 
86988
 
ALTER TABLE fixcountry.pkgpriv OWNER TO admin;
86989
 
 
86990
 
SET search_path = public, pg_catalog;
86991
 
 
86992
 
--
86993
 
--
86994
 
 
86995
 
CREATE TABLE report (
86996
 
    report_id integer DEFAULT nextval(('report_report_id_seq'::text)::regclass) NOT NULL,
86997
 
    report_name text,
86998
 
    report_sys boolean,
86999
 
    report_source text,
87000
 
    report_descrip text,
87001
 
    report_grade integer NOT NULL,
87002
 
    report_loaddate timestamp without time zone
87003
 
);
87004
 
 
87005
 
 
87006
 
ALTER TABLE public.report OWNER TO admin;
87007
 
 
87008
 
--
87009
 
--
87010
 
 
87011
 
COMMENT ON TABLE report IS 'Report definition information';
87012
 
 
87013
 
 
87014
 
--
87015
 
--
87016
 
 
87017
 
CREATE SEQUENCE report_report_id_seq
87018
 
    START WITH 1
87019
 
    INCREMENT BY 1
87020
 
    NO MINVALUE
87021
 
    MAXVALUE 2147483647
87022
 
    CACHE 1;
87023
 
 
87024
 
 
87025
 
ALTER TABLE public.report_report_id_seq OWNER TO admin;
87026
 
 
87027
 
SET search_path = fixcountry, pg_catalog;
87028
 
 
87029
 
--
87030
 
--
87031
 
 
87032
 
CREATE TABLE pkgreport (
87033
 
    report_id integer DEFAULT nextval('public.report_report_id_seq'::regclass)
87034
 
)
87035
 
INHERITS (public.report);
87036
 
 
87037
 
 
87038
 
ALTER TABLE fixcountry.pkgreport OWNER TO admin;
87039
 
 
87040
 
SET search_path = public, pg_catalog;
87041
 
 
87042
 
--
87043
 
--
87044
 
 
87045
 
CREATE TABLE script (
87046
 
    script_id integer NOT NULL,
87047
 
    script_name text NOT NULL,
87048
 
    script_order integer NOT NULL,
87049
 
    script_enabled boolean DEFAULT false NOT NULL,
87050
 
    script_source text NOT NULL,
87051
 
    script_notes text
87052
 
);
87053
 
 
87054
 
 
87055
 
ALTER TABLE public.script OWNER TO admin;
87056
 
 
87057
 
--
87058
 
--
87059
 
 
87060
 
CREATE SEQUENCE script_script_id_seq
87061
 
    START WITH 1
87062
 
    INCREMENT BY 1
87063
 
    NO MINVALUE
87064
 
    NO MAXVALUE
87065
 
    CACHE 1;
87066
 
 
87067
 
 
87068
 
ALTER TABLE public.script_script_id_seq OWNER TO admin;
87069
 
 
87070
 
--
87071
 
--
87072
 
 
87073
 
ALTER SEQUENCE script_script_id_seq OWNED BY script.script_id;
87074
 
 
87075
 
 
87076
 
SET search_path = fixcountry, pg_catalog;
87077
 
 
87078
 
--
87079
 
--
87080
 
 
87081
 
CREATE TABLE pkgscript (
87082
 
    script_id integer DEFAULT nextval('public.script_script_id_seq'::regclass)
87083
 
)
87084
 
INHERITS (public.script);
87085
 
 
87086
 
 
87087
 
ALTER TABLE fixcountry.pkgscript OWNER TO admin;
87088
 
 
87089
 
SET search_path = public, pg_catalog;
87090
 
 
87091
 
--
87092
 
--
87093
 
 
87094
 
CREATE TABLE uiform (
87095
 
    uiform_id integer NOT NULL,
87096
 
    uiform_name text NOT NULL,
87097
 
    uiform_order integer NOT NULL,
87098
 
    uiform_enabled boolean DEFAULT false NOT NULL,
87099
 
    uiform_source text NOT NULL,
87100
 
    uiform_notes text
87101
 
);
87102
 
 
87103
 
 
87104
 
ALTER TABLE public.uiform OWNER TO admin;
87105
 
 
87106
 
--
87107
 
--
87108
 
 
87109
 
CREATE SEQUENCE uiform_uiform_id_seq
87110
 
    START WITH 1
87111
 
    INCREMENT BY 1
87112
 
    NO MINVALUE
87113
 
    NO MAXVALUE
87114
 
    CACHE 1;
87115
 
 
87116
 
 
87117
 
ALTER TABLE public.uiform_uiform_id_seq OWNER TO admin;
87118
 
 
87119
 
--
87120
 
--
87121
 
 
87122
 
ALTER SEQUENCE uiform_uiform_id_seq OWNED BY uiform.uiform_id;
87123
 
 
87124
 
 
87125
 
SET search_path = fixcountry, pg_catalog;
87126
 
 
87127
 
--
87128
 
--
87129
 
 
87130
 
CREATE TABLE pkguiform (
87131
 
    uiform_id integer DEFAULT nextval('public.uiform_uiform_id_seq'::regclass)
87132
 
)
87133
 
INHERITS (public.uiform);
87134
 
 
87135
 
 
87136
 
ALTER TABLE fixcountry.pkguiform OWNER TO admin;
87137
 
 
87138
 
SET search_path = public, pg_catalog;
87139
 
 
87140
 
--
87141
 
--
87142
 
 
87143
 
CREATE TABLE acalitem (
87144
 
    acalitem_id integer DEFAULT nextval(('"xcalitem_xcalitem_id_seq"'::text)::regclass) NOT NULL,
87145
 
    acalitem_calhead_id integer,
87146
 
    acalitem_periodstart date,
87147
 
    acalitem_periodlength integer,
87148
 
    acalitem_name text
87149
 
);
87150
 
 
87151
 
 
87152
 
ALTER TABLE public.acalitem OWNER TO admin;
87153
 
 
87154
 
--
87155
 
--
87156
 
 
87157
 
COMMENT ON TABLE acalitem IS 'Absolute Calendar Item information';
87158
 
 
87159
 
 
87160
 
--
87161
 
--
87162
 
 
87163
 
CREATE SEQUENCE accnt_accnt_id_seq
87164
 
    START WITH 1
87165
 
    INCREMENT BY 1
87166
 
    NO MINVALUE
87167
 
    MAXVALUE 2147483647
87168
 
    CACHE 1;
87169
 
 
87170
 
 
87171
 
ALTER TABLE public.accnt_accnt_id_seq OWNER TO admin;
87172
 
 
87173
 
--
87174
 
--
87175
 
 
87176
 
CREATE SEQUENCE addr_addr_id_seq
87177
 
    START WITH 1
87178
 
    INCREMENT BY 1
87179
 
    NO MINVALUE
87180
 
    NO MAXVALUE
87181
 
    CACHE 1;
87182
 
 
87183
 
 
87184
 
ALTER TABLE public.addr_addr_id_seq OWNER TO admin;
87185
 
 
87186
 
--
87187
 
--
87188
 
 
87189
 
ALTER SEQUENCE addr_addr_id_seq OWNED BY addr.addr_id;
87190
 
 
87191
 
 
87192
 
--
87193
 
--
87194
 
 
87195
 
CREATE VIEW address AS
87196
 
    SELECT addresses.addr_id, addresses.addr_active, addresses.addr_line1, addresses.addr_line2, addresses.addr_line3, addresses.addr_city, addresses.addr_state, addresses.addr_postalcode, addresses.addr_country, addresses.addr_notes, addresses.addr_number, addresses.crmacct_id, addresses.crmacct_number, addresses.crmacct_name FROM ((((SELECT base.addr_id, base.addr_active, base.addr_line1, base.addr_line2, base.addr_line3, base.addr_city, base.addr_state, base.addr_postalcode, base.addr_country, base.addr_notes, base.addr_number, base.crmacct_id, base.crmacct_number, base.crmacct_name FROM ((((SELECT addr.addr_id, addr.addr_active, addr.addr_line1, addr.addr_line2, addr.addr_line3, addr.addr_city, addr.addr_state, addr.addr_postalcode, addr.addr_country, addr.addr_notes, addr.addr_number, COALESCE(crmacct.crmacct_id, (-1)) AS crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM ((addr LEFT JOIN cntct ON ((cntct.cntct_addr_id = addr.addr_id))) LEFT JOIN crmacct ON ((crmacct.crmacct_id = cntct.cntct_crmacct_id))) EXCEPT SELECT addr.addr_id, addr.addr_active, addr.addr_line1, addr.addr_line2, addr.addr_line3, addr.addr_city, addr.addr_state, addr.addr_postalcode, addr.addr_country, addr.addr_notes, addr.addr_number, (-1), NULL::text, NULL::text FROM ((addr JOIN vendinfo ON ((vendinfo.vend_addr_id = addr.addr_id))) JOIN crmacct ON ((vendinfo.vend_id = crmacct.crmacct_vend_id)))) EXCEPT SELECT addr.addr_id, addr.addr_active, addr.addr_line1, addr.addr_line2, addr.addr_line3, addr.addr_city, addr.addr_state, addr.addr_postalcode, addr.addr_country, addr.addr_notes, addr.addr_number, (-1), NULL::text, NULL::text FROM ((addr JOIN vendaddrinfo ON ((vendaddrinfo.vendaddr_addr_id = addr.addr_id))) JOIN crmacct ON ((vendaddrinfo.vendaddr_vend_id = crmacct.crmacct_vend_id)))) EXCEPT SELECT addr.addr_id, addr.addr_active, addr.addr_line1, addr.addr_line2, addr.addr_line3, addr.addr_city, addr.addr_state, addr.addr_postalcode, addr.addr_country, addr.addr_notes, addr.addr_number, (-1), NULL::text, NULL::text FROM ((addr JOIN taxauth ON ((taxauth.taxauth_addr_id = addr.addr_id))) JOIN crmacct ON ((taxauth.taxauth_id = crmacct.crmacct_taxauth_id)))) EXCEPT SELECT addr.addr_id, addr.addr_active, addr.addr_line1, addr.addr_line2, addr.addr_line3, addr.addr_city, addr.addr_state, addr.addr_postalcode, addr.addr_country, addr.addr_notes, addr.addr_number, (-1), NULL::text, NULL::text FROM ((addr JOIN shiptoinfo ON ((shiptoinfo.shipto_addr_id = addr.addr_id))) JOIN crmacct ON ((shiptoinfo.shipto_cust_id = crmacct.crmacct_cust_id)))) base UNION SELECT addr.addr_id, addr.addr_active, addr.addr_line1, addr.addr_line2, addr.addr_line3, addr.addr_city, addr.addr_state, addr.addr_postalcode, addr.addr_country, addr.addr_notes, addr.addr_number, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM ((addr JOIN vendinfo ON ((vendinfo.vend_addr_id = addr.addr_id))) JOIN crmacct ON ((vendinfo.vend_id = crmacct.crmacct_vend_id)))) UNION SELECT addr.addr_id, addr.addr_active, addr.addr_line1, addr.addr_line2, addr.addr_line3, addr.addr_city, addr.addr_state, addr.addr_postalcode, addr.addr_country, addr.addr_notes, addr.addr_number, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM ((addr JOIN vendaddrinfo ON ((vendaddrinfo.vendaddr_addr_id = addr.addr_id))) JOIN crmacct ON ((vendaddrinfo.vendaddr_vend_id = crmacct.crmacct_vend_id)))) UNION SELECT addr.addr_id, addr.addr_active, addr.addr_line1, addr.addr_line2, addr.addr_line3, addr.addr_city, addr.addr_state, addr.addr_postalcode, addr.addr_country, addr.addr_notes, addr.addr_number, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM ((addr JOIN taxauth ON ((taxauth.taxauth_addr_id = addr.addr_id))) JOIN crmacct ON ((taxauth.taxauth_id = crmacct.crmacct_taxauth_id)))) UNION SELECT addr.addr_id, addr.addr_active, addr.addr_line1, addr.addr_line2, addr.addr_line3, addr.addr_city, addr.addr_state, addr.addr_postalcode, addr.addr_country, addr.addr_notes, addr.addr_number, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM ((addr JOIN shiptoinfo ON ((shiptoinfo.shipto_addr_id = addr.addr_id))) JOIN crmacct ON ((shiptoinfo.shipto_cust_id = crmacct.crmacct_cust_id)))) addresses ORDER BY addresses.addr_country, addresses.addr_state, addresses.addr_postalcode, addresses.addr_line1, addresses.addr_line2, addresses.addr_line3;
87197
 
 
87198
 
 
87199
 
ALTER TABLE public.address OWNER TO admin;
87200
 
 
87201
 
--
87202
 
--
87203
 
 
87204
 
CREATE TABLE alarm (
87205
 
    alarm_id integer NOT NULL,
87206
 
    alarm_number text NOT NULL,
87207
 
    alarm_event boolean DEFAULT false NOT NULL,
87208
 
    alarm_email boolean DEFAULT false NOT NULL,
87209
 
    alarm_sysmsg boolean DEFAULT false NOT NULL,
87210
 
    alarm_trigger timestamp with time zone,
87211
 
    alarm_time timestamp with time zone,
87212
 
    alarm_time_offset integer,
87213
 
    alarm_time_qualifier text,
87214
 
    alarm_creator text,
87215
 
    alarm_event_recipient text,
87216
 
    alarm_email_recipient text,
87217
 
    alarm_sysmsg_recipient text,
87218
 
    alarm_source text,
87219
 
    alarm_source_id integer
87220
 
);
87221
 
 
87222
 
 
87223
 
ALTER TABLE public.alarm OWNER TO admin;
87224
 
 
87225
 
--
87226
 
--
87227
 
 
87228
 
COMMENT ON TABLE alarm IS 'This table is the open alarms.';
87229
 
 
87230
 
 
87231
 
--
87232
 
--
87233
 
 
87234
 
CREATE SEQUENCE alarm_alarm_id_seq
87235
 
    START WITH 1
87236
 
    INCREMENT BY 1
87237
 
    NO MINVALUE
87238
 
    NO MAXVALUE
87239
 
    CACHE 1;
87240
 
 
87241
 
 
87242
 
ALTER TABLE public.alarm_alarm_id_seq OWNER TO admin;
87243
 
 
87244
 
--
87245
 
--
87246
 
 
87247
 
ALTER SEQUENCE alarm_alarm_id_seq OWNED BY alarm.alarm_id;
87248
 
 
87249
 
 
87250
 
--
87251
 
--
87252
 
 
87253
 
CREATE TABLE apaccnt (
87254
 
    apaccnt_id integer NOT NULL,
87255
 
    apaccnt_vendtype_id integer,
87256
 
    apaccnt_vendtype text,
87257
 
    apaccnt_ap_accnt_id integer NOT NULL,
87258
 
    apaccnt_prepaid_accnt_id integer,
87259
 
    apaccnt_discount_accnt_id integer
87260
 
);
87261
 
 
87262
 
 
87263
 
ALTER TABLE public.apaccnt OWNER TO admin;
87264
 
 
87265
 
--
87266
 
--
87267
 
 
87268
 
COMMENT ON TABLE apaccnt IS 'Accounts Payable (A/P) Account assignment information';
87269
 
 
87270
 
 
87271
 
--
87272
 
--
87273
 
 
87274
 
CREATE SEQUENCE apaccnt_apaccnt_id_seq
87275
 
    START WITH 1
87276
 
    INCREMENT BY 1
87277
 
    NO MINVALUE
87278
 
    NO MAXVALUE
87279
 
    CACHE 1;
87280
 
 
87281
 
 
87282
 
ALTER TABLE public.apaccnt_apaccnt_id_seq OWNER TO admin;
87283
 
 
87284
 
--
87285
 
--
87286
 
 
87287
 
ALTER SEQUENCE apaccnt_apaccnt_id_seq OWNED BY apaccnt.apaccnt_id;
87288
 
 
87289
 
 
87290
 
--
87291
 
--
87292
 
 
87293
 
CREATE TABLE apapply (
87294
 
    apapply_id integer NOT NULL,
87295
 
    apapply_vend_id integer,
87296
 
    apapply_postdate date,
87297
 
    apapply_username text,
87298
 
    apapply_source_apopen_id integer,
87299
 
    apapply_source_doctype text,
87300
 
    apapply_source_docnumber text,
87301
 
    apapply_target_apopen_id integer,
87302
 
    apapply_target_doctype text,
87303
 
    apapply_target_docnumber text,
87304
 
    apapply_journalnumber integer,
87305
 
    apapply_amount numeric(20,2),
87306
 
    apapply_curr_id integer DEFAULT basecurrid(),
87307
 
    apapply_target_paid numeric(20,2),
87308
 
    apapply_checkhead_id integer
87309
 
);
87310
 
 
87311
 
 
87312
 
ALTER TABLE public.apapply OWNER TO admin;
87313
 
 
87314
 
--
87315
 
--
87316
 
 
87317
 
COMMENT ON TABLE apapply IS 'Applications (e.g., Payments, A/P Credit Memos) made to Accounts Payable (A/P) Documents';
87318
 
 
87319
 
 
87320
 
--
87321
 
--
87322
 
 
87323
 
COMMENT ON COLUMN apapply.apapply_source_apopen_id IS 'If apapply_source_doctype is "C" (credit memo) then apapply_source_apopen_id acts as a foreign key to the apopen table. If the source doctype is "K" (check) then the apapply_source_apopen_id acts as a foreign key to the checkhead table. If the apapply_source_apopen_id is -1 then the internal id of the source document is not known (always the case for checks posted before release 3.2.0BETA).';
87324
 
 
87325
 
 
87326
 
--
87327
 
--
87328
 
 
87329
 
CREATE SEQUENCE apapply_apapply_id_seq
87330
 
    START WITH 1
87331
 
    INCREMENT BY 1
87332
 
    NO MINVALUE
87333
 
    NO MAXVALUE
87334
 
    CACHE 1;
87335
 
 
87336
 
 
87337
 
ALTER TABLE public.apapply_apapply_id_seq OWNER TO admin;
87338
 
 
87339
 
--
87340
 
--
87341
 
 
87342
 
ALTER SEQUENCE apapply_apapply_id_seq OWNED BY apapply.apapply_id;
87343
 
 
87344
 
 
87345
 
--
87346
 
--
87347
 
 
87348
 
CREATE TABLE checkhead (
87349
 
    checkhead_id integer NOT NULL,
87350
 
    checkhead_recip_id integer NOT NULL,
87351
 
    checkhead_recip_type text NOT NULL,
87352
 
    checkhead_bankaccnt_id integer NOT NULL,
87353
 
    checkhead_printed boolean DEFAULT false NOT NULL,
87354
 
    checkhead_checkdate date NOT NULL,
87355
 
    checkhead_number integer NOT NULL,
87356
 
    checkhead_amount numeric(20,2) NOT NULL,
87357
 
    checkhead_void boolean DEFAULT false NOT NULL,
87358
 
    checkhead_replaced boolean DEFAULT false NOT NULL,
87359
 
    checkhead_posted boolean DEFAULT false NOT NULL,
87360
 
    checkhead_rec boolean DEFAULT false NOT NULL,
87361
 
    checkhead_misc boolean DEFAULT false NOT NULL,
87362
 
    checkhead_expcat_id integer,
87363
 
    checkhead_for text NOT NULL,
87364
 
    checkhead_notes text NOT NULL,
87365
 
    checkhead_journalnumber integer,
87366
 
    checkhead_curr_id integer DEFAULT basecurrid() NOT NULL,
87367
 
    checkhead_deleted boolean DEFAULT false NOT NULL,
87368
 
    checkhead_ach_batch text,
87369
 
    checkhead_curr_rate numeric NOT NULL,
87370
 
    checkhead_alt_curr_rate numeric,
87371
 
    CONSTRAINT checkhead_checkhead_amount_check CHECK ((checkhead_amount > (0)::numeric)),
87372
 
    CONSTRAINT checkhead_checkhead_recip_type_check CHECK ((((checkhead_recip_type = 'C'::text) OR (checkhead_recip_type = 'V'::text)) OR (checkhead_recip_type = 'T'::text)))
87373
 
);
87374
 
 
87375
 
 
87376
 
ALTER TABLE public.checkhead OWNER TO admin;
87377
 
 
87378
 
--
87379
 
--
87380
 
 
87381
 
COMMENT ON TABLE checkhead IS 'Accounts Payable Check Information';
87382
 
 
87383
 
 
87384
 
--
87385
 
--
87386
 
 
87387
 
CREATE VIEW apchk AS
87388
 
    SELECT checkhead.checkhead_id AS apchk_id, checkhead.checkhead_recip_id AS apchk_vend_id, checkhead.checkhead_bankaccnt_id AS apchk_bankaccnt_id, checkhead.checkhead_printed AS apchk_printed, checkhead.checkhead_checkdate AS apchk_checkdate, checkhead.checkhead_number AS apchk_number, checkhead.checkhead_amount AS apchk_amount, checkhead.checkhead_void AS apchk_void, checkhead.checkhead_replaced AS apchk_replaced, checkhead.checkhead_posted AS apchk_posted, checkhead.checkhead_rec AS apchk_rec, checkhead.checkhead_misc AS apchk_misc, checkhead.checkhead_expcat_id AS apchk_expcat_id, checkhead.checkhead_for AS apchk_for, checkhead.checkhead_notes AS apchk_notes, checkhead.checkhead_journalnumber AS apchk_journalnumber, checkhead.checkhead_curr_id AS apchk_curr_id, checkhead.checkhead_deleted AS apchk_deleted FROM checkhead WHERE (checkhead.checkhead_recip_type = 'V'::text);
87389
 
 
87390
 
 
87391
 
ALTER TABLE public.apchk OWNER TO admin;
87392
 
 
87393
 
--
87394
 
--
87395
 
 
87396
 
CREATE TABLE checkitem (
87397
 
    checkitem_id integer NOT NULL,
87398
 
    checkitem_checkhead_id integer NOT NULL,
87399
 
    checkitem_amount numeric(20,2) DEFAULT 0.0 NOT NULL,
87400
 
    checkitem_discount numeric(20,2) DEFAULT 0.0 NOT NULL,
87401
 
    checkitem_ponumber text,
87402
 
    checkitem_vouchernumber text,
87403
 
    checkitem_invcnumber text,
87404
 
    checkitem_apopen_id integer,
87405
 
    checkitem_aropen_id integer,
87406
 
    checkitem_docdate date,
87407
 
    checkitem_curr_id integer DEFAULT basecurrid() NOT NULL,
87408
 
    checkitem_cmnumber text,
87409
 
    checkitem_ranumber text,
87410
 
    checkitem_curr_rate numeric,
87411
 
    CONSTRAINT checkitem_check CHECK ((NOT ((checkitem_apopen_id IS NOT NULL) AND (checkitem_aropen_id IS NOT NULL))))
87412
 
);
87413
 
 
87414
 
 
87415
 
ALTER TABLE public.checkitem OWNER TO admin;
87416
 
 
87417
 
--
87418
 
--
87419
 
 
87420
 
COMMENT ON TABLE checkitem IS 'Accounts Payable Check Line Item Information';
87421
 
 
87422
 
 
87423
 
--
87424
 
--
87425
 
 
87426
 
CREATE VIEW apchkitem AS
87427
 
    SELECT checkitem.checkitem_id AS apchkitem_id, checkitem.checkitem_checkhead_id AS apchkitem_apchk_id, checkitem.checkitem_vouchernumber AS apchkitem_vouchernumber, checkitem.checkitem_ponumber AS apchkitem_ponumber, checkitem.checkitem_amount AS apchkitem_amount, checkitem.checkitem_invcnumber AS apchkitem_invcnumber, checkitem.checkitem_apopen_id AS apchkitem_apopen_id, checkitem.checkitem_docdate AS apchkitem_docdate, checkitem.checkitem_curr_id AS apchkitem_curr_id, checkitem.checkitem_discount AS apchkitem_discount FROM checkhead, checkitem WHERE ((checkitem.checkitem_checkhead_id = checkhead.checkhead_id) AND (checkhead.checkhead_recip_type = 'V'::text));
87428
 
 
87429
 
 
87430
 
ALTER TABLE public.apchkitem OWNER TO admin;
87431
 
 
87432
 
--
87433
 
--
87434
 
 
87435
 
CREATE TABLE apcreditapply (
87436
 
    apcreditapply_id integer NOT NULL,
87437
 
    apcreditapply_source_apopen_id integer,
87438
 
    apcreditapply_target_apopen_id integer,
87439
 
    apcreditapply_amount numeric(20,2),
87440
 
    apcreditapply_curr_id integer DEFAULT basecurrid()
87441
 
);
87442
 
 
87443
 
 
87444
 
ALTER TABLE public.apcreditapply OWNER TO admin;
87445
 
 
87446
 
--
87447
 
--
87448
 
 
87449
 
COMMENT ON TABLE apcreditapply IS 'Temporary table for storing details of Accounts Payable (A/P) Credit Memo applications before those applications are posted';
87450
 
 
87451
 
 
87452
 
--
87453
 
--
87454
 
 
87455
 
CREATE SEQUENCE apcreditapply_apcreditapply_id_seq
87456
 
    START WITH 1
87457
 
    INCREMENT BY 1
87458
 
    NO MINVALUE
87459
 
    NO MAXVALUE
87460
 
    CACHE 1;
87461
 
 
87462
 
 
87463
 
ALTER TABLE public.apcreditapply_apcreditapply_id_seq OWNER TO admin;
87464
 
 
87465
 
--
87466
 
--
87467
 
 
87468
 
ALTER SEQUENCE apcreditapply_apcreditapply_id_seq OWNED BY apcreditapply.apcreditapply_id;
87469
 
 
87470
 
 
87471
 
--
87472
 
--
87473
 
 
87474
 
CREATE VIEW apmemo AS
87475
 
    SELECT apopen.apopen_id, apopen.apopen_docnumber FROM apopen WHERE (apopen.apopen_doctype = ANY (ARRAY['D'::bpchar, 'C'::bpchar]));
87476
 
 
87477
 
 
87478
 
ALTER TABLE public.apmemo OWNER TO admin;
87479
 
 
87480
 
--
87481
 
--
87482
 
 
87483
 
CREATE SEQUENCE apopen_apopen_id_seq
87484
 
    START WITH 1
87485
 
    INCREMENT BY 1
87486
 
    NO MINVALUE
87487
 
    NO MAXVALUE
87488
 
    CACHE 1;
87489
 
 
87490
 
 
87491
 
ALTER TABLE public.apopen_apopen_id_seq OWNER TO admin;
87492
 
 
87493
 
--
87494
 
--
87495
 
 
87496
 
CREATE TABLE apopentax (
87497
 
)
87498
 
INHERITS (taxhist);
87499
 
 
87500
 
 
87501
 
ALTER TABLE public.apopentax OWNER TO admin;
87502
 
 
87503
 
--
87504
 
--
87505
 
 
87506
 
CREATE TABLE apselect (
87507
 
    apselect_id integer NOT NULL,
87508
 
    apselect_apopen_id integer NOT NULL,
87509
 
    apselect_amount numeric(20,2) NOT NULL,
87510
 
    apselect_bankaccnt_id integer,
87511
 
    apselect_curr_id integer DEFAULT basecurrid(),
87512
 
    apselect_date date,
87513
 
    apselect_discount numeric(20,2) DEFAULT 0.0 NOT NULL
87514
 
);
87515
 
 
87516
 
 
87517
 
ALTER TABLE public.apselect OWNER TO admin;
87518
 
 
87519
 
--
87520
 
--
87521
 
 
87522
 
COMMENT ON TABLE apselect IS 'Temporary table for storing details of Accounts Payable (A/P) Payment selections';
87523
 
 
87524
 
 
87525
 
--
87526
 
--
87527
 
 
87528
 
CREATE SEQUENCE apselect_apselect_id_seq
87529
 
    START WITH 1
87530
 
    INCREMENT BY 1
87531
 
    NO MINVALUE
87532
 
    NO MAXVALUE
87533
 
    CACHE 1;
87534
 
 
87535
 
 
87536
 
ALTER TABLE public.apselect_apselect_id_seq OWNER TO admin;
87537
 
 
87538
 
--
87539
 
--
87540
 
 
87541
 
ALTER SEQUENCE apselect_apselect_id_seq OWNED BY apselect.apselect_id;
87542
 
 
87543
 
 
87544
 
--
87545
 
--
87546
 
 
87547
 
CREATE TABLE araccnt (
87548
 
    araccnt_id integer DEFAULT nextval(('araccnt_araccnt_id_seq'::text)::regclass) NOT NULL,
87549
 
    araccnt_custtype_id integer,
87550
 
    araccnt_custtype text,
87551
 
    araccnt_freight_accnt_id integer,
87552
 
    araccnt_ar_accnt_id integer,
87553
 
    araccnt_prepaid_accnt_id integer,
87554
 
    araccnt_deferred_accnt_id integer,
87555
 
    araccnt_discount_accnt_id integer
87556
 
);
87557
 
 
87558
 
 
87559
 
ALTER TABLE public.araccnt OWNER TO admin;
87560
 
 
87561
 
--
87562
 
--
87563
 
 
87564
 
COMMENT ON TABLE araccnt IS 'Accounts Receivable (A/R) Account assignment information';
87565
 
 
87566
 
 
87567
 
--
87568
 
--
87569
 
 
87570
 
CREATE SEQUENCE araccnt_araccnt_id_seq
87571
 
    START WITH 1
87572
 
    INCREMENT BY 1
87573
 
    NO MINVALUE
87574
 
    NO MAXVALUE
87575
 
    CACHE 1;
87576
 
 
87577
 
 
87578
 
ALTER TABLE public.araccnt_araccnt_id_seq OWNER TO admin;
87579
 
 
87580
 
--
87581
 
--
87582
 
 
87583
 
CREATE TABLE arapply (
87584
 
    arapply_id integer NOT NULL,
87585
 
    arapply_postdate date,
87586
 
    arapply_cust_id integer,
87587
 
    arapply_source_doctype text,
87588
 
    arapply_source_docnumber text,
87589
 
    arapply_target_doctype text,
87590
 
    arapply_target_docnumber text,
87591
 
    arapply_fundstype text,
87592
 
    arapply_refnumber text,
87593
 
    arapply_applied numeric(20,2),
87594
 
    arapply_closed boolean,
87595
 
    arapply_journalnumber text,
87596
 
    arapply_source_aropen_id integer,
87597
 
    arapply_target_aropen_id integer,
87598
 
    arapply_username text,
87599
 
    arapply_curr_id integer DEFAULT basecurrid(),
87600
 
    arapply_distdate date NOT NULL,
87601
 
    arapply_target_paid numeric(20,2),
87602
 
    arapply_reftype text,
87603
 
    arapply_ref_id integer
87604
 
);
87605
 
 
87606
 
 
87607
 
ALTER TABLE public.arapply OWNER TO admin;
87608
 
 
87609
 
--
87610
 
--
87611
 
 
87612
 
COMMENT ON TABLE arapply IS 'Applications (e.g., Cash Receipts, A/R Credit Memos) made to Accounts Receivable (A/R) Documents';
87613
 
 
87614
 
 
87615
 
--
87616
 
--
87617
 
 
87618
 
CREATE SEQUENCE arapply_arapply_id_seq
87619
 
    START WITH 1
87620
 
    INCREMENT BY 1
87621
 
    NO MINVALUE
87622
 
    NO MAXVALUE
87623
 
    CACHE 1;
87624
 
 
87625
 
 
87626
 
ALTER TABLE public.arapply_arapply_id_seq OWNER TO admin;
87627
 
 
87628
 
--
87629
 
--
87630
 
 
87631
 
ALTER SEQUENCE arapply_arapply_id_seq OWNED BY arapply.arapply_id;
87632
 
 
87633
 
 
87634
 
--
87635
 
--
87636
 
 
87637
 
CREATE SEQUENCE cashrcptitem_cashrcptitem_id_seq
87638
 
    START WITH 1
87639
 
    INCREMENT BY 1
87640
 
    NO MINVALUE
87641
 
    NO MAXVALUE
87642
 
    CACHE 1;
87643
 
 
87644
 
 
87645
 
ALTER TABLE public.cashrcptitem_cashrcptitem_id_seq OWNER TO admin;
87646
 
 
87647
 
--
87648
 
--
87649
 
 
87650
 
ALTER SEQUENCE cashrcptitem_cashrcptitem_id_seq OWNED BY cashrcptitem.cashrcptitem_id;
87651
 
 
87652
 
 
87653
 
--
87654
 
--
87655
 
 
87656
 
CREATE TABLE arcreditapply (
87657
 
    arcreditapply_id integer DEFAULT nextval('cashrcptitem_cashrcptitem_id_seq'::regclass) NOT NULL,
87658
 
    arcreditapply_source_aropen_id integer,
87659
 
    arcreditapply_target_aropen_id integer,
87660
 
    arcreditapply_amount numeric(20,2),
87661
 
    arcreditapply_curr_id integer DEFAULT basecurrid(),
87662
 
    arcreditapply_reftype text,
87663
 
    arcreditapply_ref_id integer
87664
 
);
87665
 
 
87666
 
 
87667
 
ALTER TABLE public.arcreditapply OWNER TO admin;
87668
 
 
87669
 
--
87670
 
--
87671
 
 
87672
 
COMMENT ON TABLE arcreditapply IS 'Temporary table for storing details of Accounts Receivable (A/R) Credit Memo applications before those applications are posted';
87673
 
 
87674
 
 
87675
 
--
87676
 
--
87677
 
 
87678
 
CREATE SEQUENCE arcreditapply_arcreditapply_id_seq
87679
 
    START WITH 1
87680
 
    INCREMENT BY 1
87681
 
    NO MINVALUE
87682
 
    NO MAXVALUE
87683
 
    CACHE 1;
87684
 
 
87685
 
 
87686
 
ALTER TABLE public.arcreditapply_arcreditapply_id_seq OWNER TO admin;
87687
 
 
87688
 
--
87689
 
--
87690
 
 
87691
 
ALTER SEQUENCE arcreditapply_arcreditapply_id_seq OWNED BY arcreditapply.arcreditapply_id;
87692
 
 
87693
 
 
87694
 
--
87695
 
--
87696
 
 
87697
 
CREATE VIEW armemo AS
87698
 
    SELECT aropen.aropen_id, aropen.aropen_docnumber FROM aropen WHERE (aropen.aropen_doctype = ANY (ARRAY['D'::bpchar, 'C'::bpchar, 'R'::bpchar])) UNION SELECT cmhead.cmhead_id AS aropen_id, cmhead.cmhead_number AS aropen_docnumber FROM cmhead;
87699
 
 
87700
 
 
87701
 
ALTER TABLE public.armemo OWNER TO admin;
87702
 
 
87703
 
--
87704
 
--
87705
 
 
87706
 
CREATE SEQUENCE aropen_aropen_id_seq
87707
 
    START WITH 1
87708
 
    INCREMENT BY 1
87709
 
    NO MINVALUE
87710
 
    MAXVALUE 2147483647
87711
 
    CACHE 1;
87712
 
 
87713
 
 
87714
 
ALTER TABLE public.aropen_aropen_id_seq OWNER TO admin;
87715
 
 
87716
 
--
87717
 
--
87718
 
 
87719
 
CREATE TABLE aropentax (
87720
 
)
87721
 
INHERITS (taxhist);
87722
 
 
87723
 
 
87724
 
ALTER TABLE public.aropentax OWNER TO admin;
87725
 
 
87726
 
--
87727
 
--
87728
 
 
87729
 
CREATE TABLE asohist (
87730
 
    asohist_id integer NOT NULL,
87731
 
    asohist_cust_id integer,
87732
 
    asohist_itemsite_id integer,
87733
 
    asohist_shipdate date,
87734
 
    asohist_invcdate date,
87735
 
    asohist_duedate date,
87736
 
    asohist_promisedate date,
87737
 
    asohist_ordernumber text,
87738
 
    asohist_invcnumber text,
87739
 
    asohist_qtyshipped numeric(18,6),
87740
 
    asohist_unitprice numeric(16,4),
87741
 
    asohist_unitcost numeric(16,6),
87742
 
    asohist_billtoname text,
87743
 
    asohist_billtoaddress1 text,
87744
 
    asohist_billtoaddress2 text,
87745
 
    asohist_billtoaddress3 text,
87746
 
    asohist_billtocity text,
87747
 
    asohist_billtostate text,
87748
 
    asohist_billtozip text,
87749
 
    asohist_shiptoname text,
87750
 
    asohist_shiptoaddress1 text,
87751
 
    asohist_shiptoaddress2 text,
87752
 
    asohist_shiptoaddress3 text,
87753
 
    asohist_shiptocity text,
87754
 
    asohist_shiptostate text,
87755
 
    asohist_shiptozip text,
87756
 
    asohist_shipto_id integer,
87757
 
    asohist_shipvia text,
87758
 
    asohist_salesrep_id integer,
87759
 
    asohist_misc_type character(1),
87760
 
    asohist_misc_descrip text,
87761
 
    asohist_misc_id integer,
87762
 
    asohist_commission numeric(16,4),
87763
 
    asohist_commissionpaid boolean,
87764
 
    asohist_doctype text,
87765
 
    asohist_orderdate date,
87766
 
    asohist_imported boolean,
87767
 
    asohist_ponumber text,
87768
 
    asohist_curr_id integer DEFAULT basecurrid(),
87769
 
    asohist_taxtype_id integer,
87770
 
    asohist_taxzone_id integer
87771
 
);
87772
 
 
87773
 
 
87774
 
ALTER TABLE public.asohist OWNER TO admin;
87775
 
 
87776
 
--
87777
 
--
87778
 
 
87779
 
COMMENT ON TABLE asohist IS 'Archived Sales history';
87780
 
 
87781
 
 
87782
 
--
87783
 
--
87784
 
 
87785
 
CREATE SEQUENCE asohist_asohist_id_seq
87786
 
    START WITH 1
87787
 
    INCREMENT BY 1
87788
 
    NO MINVALUE
87789
 
    NO MAXVALUE
87790
 
    CACHE 1;
87791
 
 
87792
 
 
87793
 
ALTER TABLE public.asohist_asohist_id_seq OWNER TO admin;
87794
 
 
87795
 
--
87796
 
--
87797
 
 
87798
 
ALTER SEQUENCE asohist_asohist_id_seq OWNED BY asohist.asohist_id;
87799
 
 
87800
 
 
87801
 
--
87802
 
--
87803
 
 
87804
 
CREATE TABLE asohisttax (
87805
 
)
87806
 
INHERITS (taxhist);
87807
 
 
87808
 
 
87809
 
ALTER TABLE public.asohisttax OWNER TO admin;
87810
 
 
87811
 
--
87812
 
--
87813
 
 
87814
 
CREATE TABLE atlasmap (
87815
 
    atlasmap_id integer NOT NULL,
87816
 
    atlasmap_name text NOT NULL,
87817
 
    atlasmap_filter text NOT NULL,
87818
 
    atlasmap_filtertype text NOT NULL,
87819
 
    atlasmap_atlas text NOT NULL,
87820
 
    atlasmap_map text NOT NULL,
87821
 
    atlasmap_headerline boolean DEFAULT false NOT NULL,
87822
 
    CONSTRAINT atlasmap_atlasmap_name_check CHECK ((atlasmap_name <> ''::text))
87823
 
);
87824
 
 
87825
 
 
87826
 
ALTER TABLE public.atlasmap OWNER TO admin;
87827
 
 
87828
 
--
87829
 
--
87830
 
 
87831
 
COMMENT ON TABLE atlasmap IS 'Describes heuristics for finding a CSVImp atlas for a given CSV file. When looking for a CSV Atlas to use when importing a CSV file, the first atlasmap record found that matches the CSV file is used to select the Atlas file and Map in that Atlas to import the CSV file.';
87832
 
 
87833
 
 
87834
 
--
87835
 
--
87836
 
 
87837
 
COMMENT ON COLUMN atlasmap.atlasmap_id IS 'The internal id of this CSVImp atlas mapping.';
87838
 
 
87839
 
 
87840
 
--
87841
 
--
87842
 
 
87843
 
COMMENT ON COLUMN atlasmap.atlasmap_name IS 'The human-readable name of this atlas mapping.';
87844
 
 
87845
 
 
87846
 
--
87847
 
--
87848
 
 
87849
 
COMMENT ON COLUMN atlasmap.atlasmap_filter IS 'A regular expression that should match the CSV file. Which part of the file that matches is determined by the filter type.';
87850
 
 
87851
 
 
87852
 
--
87853
 
--
87854
 
 
87855
 
COMMENT ON COLUMN atlasmap.atlasmap_filtertype IS 'A description of what aspect of the CSV file the filter should be compared with. Handled values are: ''filename'' - the filter is matched against the name of the file; and ''firstline'' - the filter is matched against the first line of the file contents.';
87856
 
 
87857
 
 
87858
 
--
87859
 
--
87860
 
 
87861
 
COMMENT ON COLUMN atlasmap.atlasmap_atlas IS 'The name of the CSVImp Atlas file. This should be a simple pathname, not an absolute or relative name if possible. The full path will be determined by concatenating the operating-system-specific CSV Atlas default directory with the value here unless this is an absolute pathname.';
87862
 
 
87863
 
 
87864
 
--
87865
 
--
87866
 
 
87867
 
COMMENT ON COLUMN atlasmap.atlasmap_map IS 'The name of the Map inside the Atlas to use if the filter and filter type match the CVS file.';
87868
 
 
87869
 
 
87870
 
--
87871
 
--
87872
 
 
87873
 
COMMENT ON COLUMN atlasmap.atlasmap_headerline IS 'An indicator of whether the first line of the CSV file should be treated as a header line or as data.';
87874
 
 
87875
 
 
87876
 
--
87877
 
--
87878
 
 
87879
 
CREATE SEQUENCE atlasmap_atlasmap_id_seq
87880
 
    START WITH 1
87881
 
    INCREMENT BY 1
87882
 
    NO MINVALUE
87883
 
    NO MAXVALUE
87884
 
    CACHE 1;
87885
 
 
87886
 
 
87887
 
ALTER TABLE public.atlasmap_atlasmap_id_seq OWNER TO admin;
87888
 
 
87889
 
--
87890
 
--
87891
 
 
87892
 
ALTER SEQUENCE atlasmap_atlasmap_id_seq OWNED BY atlasmap.atlasmap_id;
87893
 
 
87894
 
 
87895
 
--
87896
 
--
87897
 
 
87898
 
CREATE TABLE backup_usr (
87899
 
    usr_id integer,
87900
 
    usr_username text,
87901
 
    usr_propername text,
87902
 
    usr_passwd text,
87903
 
    usr_locale_id integer,
87904
 
    usr_initials text,
87905
 
    usr_agent boolean,
87906
 
    usr_active boolean,
87907
 
    usr_email text,
87908
 
    usr_dept_id integer,
87909
 
    usr_shift_id integer,
87910
 
    usr_window text
87911
 
);
87912
 
 
87913
 
 
87914
 
ALTER TABLE public.backup_usr OWNER TO admin;
87915
 
 
87916
 
--
87917
 
--
87918
 
 
87919
 
CREATE SEQUENCE bankaccnt_bankaccnt_id_seq
87920
 
    START WITH 1
87921
 
    INCREMENT BY 1
87922
 
    NO MINVALUE
87923
 
    NO MAXVALUE
87924
 
    CACHE 1;
87925
 
 
87926
 
 
87927
 
ALTER TABLE public.bankaccnt_bankaccnt_id_seq OWNER TO admin;
87928
 
 
87929
 
--
87930
 
--
87931
 
 
87932
 
ALTER SEQUENCE bankaccnt_bankaccnt_id_seq OWNED BY bankaccnt.bankaccnt_id;
87933
 
 
87934
 
 
87935
 
--
87936
 
--
87937
 
 
87938
 
CREATE TABLE bankadj (
87939
 
    bankadj_id integer NOT NULL,
87940
 
    bankadj_bankaccnt_id integer NOT NULL,
87941
 
    bankadj_bankadjtype_id integer NOT NULL,
87942
 
    bankadj_created timestamp without time zone DEFAULT now() NOT NULL,
87943
 
    bankadj_username text DEFAULT geteffectivextuser() NOT NULL,
87944
 
    bankadj_date date NOT NULL,
87945
 
    bankadj_docnumber text,
87946
 
    bankadj_amount numeric(10,2) NOT NULL,
87947
 
    bankadj_notes text,
87948
 
    bankadj_sequence integer,
87949
 
    bankadj_posted boolean DEFAULT false NOT NULL,
87950
 
    bankadj_curr_id integer DEFAULT basecurrid(),
87951
 
    bankadj_curr_rate numeric
87952
 
);
87953
 
 
87954
 
 
87955
 
ALTER TABLE public.bankadj OWNER TO admin;
87956
 
 
87957
 
--
87958
 
--
87959
 
 
87960
 
COMMENT ON TABLE bankadj IS 'Bank Adjustments information';
87961
 
 
87962
 
 
87963
 
--
87964
 
--
87965
 
 
87966
 
CREATE SEQUENCE bankadj_bankadj_id_seq
87967
 
    START WITH 1
87968
 
    INCREMENT BY 1
87969
 
    NO MINVALUE
87970
 
    NO MAXVALUE
87971
 
    CACHE 1;
87972
 
 
87973
 
 
87974
 
ALTER TABLE public.bankadj_bankadj_id_seq OWNER TO admin;
87975
 
 
87976
 
--
87977
 
--
87978
 
 
87979
 
ALTER SEQUENCE bankadj_bankadj_id_seq OWNED BY bankadj.bankadj_id;
87980
 
 
87981
 
 
87982
 
--
87983
 
--
87984
 
 
87985
 
CREATE TABLE bankadjtype (
87986
 
    bankadjtype_id integer NOT NULL,
87987
 
    bankadjtype_name text NOT NULL,
87988
 
    bankadjtype_descrip text,
87989
 
    bankadjtype_accnt_id integer NOT NULL,
87990
 
    bankadjtype_iscredit boolean DEFAULT false NOT NULL,
87991
 
    CONSTRAINT bankadjtype_bankadjtype_name_check CHECK ((bankadjtype_name <> ''::text))
87992
 
);
87993
 
 
87994
 
 
87995
 
ALTER TABLE public.bankadjtype OWNER TO admin;
87996
 
 
87997
 
--
87998
 
--
87999
 
 
88000
 
COMMENT ON TABLE bankadjtype IS 'Bank Adjustment Types information';
88001
 
 
88002
 
 
88003
 
--
88004
 
--
88005
 
 
88006
 
CREATE SEQUENCE bankadjtype_bankadjtype_id_seq
88007
 
    START WITH 1
88008
 
    INCREMENT BY 1
88009
 
    NO MINVALUE
88010
 
    NO MAXVALUE
88011
 
    CACHE 1;
88012
 
 
88013
 
 
88014
 
ALTER TABLE public.bankadjtype_bankadjtype_id_seq OWNER TO admin;
88015
 
 
88016
 
--
88017
 
--
88018
 
 
88019
 
ALTER SEQUENCE bankadjtype_bankadjtype_id_seq OWNED BY bankadjtype.bankadjtype_id;
88020
 
 
88021
 
 
88022
 
--
88023
 
--
88024
 
 
88025
 
CREATE TABLE bankrec (
88026
 
    bankrec_id integer NOT NULL,
88027
 
    bankrec_created timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL,
88028
 
    bankrec_username text DEFAULT geteffectivextuser() NOT NULL,
88029
 
    bankrec_bankaccnt_id integer,
88030
 
    bankrec_opendate date,
88031
 
    bankrec_enddate date,
88032
 
    bankrec_openbal numeric(20,2),
88033
 
    bankrec_endbal numeric(20,2),
88034
 
    bankrec_posted boolean DEFAULT false,
88035
 
    bankrec_postdate timestamp without time zone
88036
 
);
88037
 
 
88038
 
 
88039
 
ALTER TABLE public.bankrec OWNER TO admin;
88040
 
 
88041
 
--
88042
 
--
88043
 
 
88044
 
COMMENT ON TABLE bankrec IS 'Bank Reconciliation posting history';
88045
 
 
88046
 
 
88047
 
--
88048
 
--
88049
 
 
88050
 
CREATE SEQUENCE bankrec_bankrec_id_seq
88051
 
    START WITH 1
88052
 
    INCREMENT BY 1
88053
 
    NO MINVALUE
88054
 
    NO MAXVALUE
88055
 
    CACHE 1;
88056
 
 
88057
 
 
88058
 
ALTER TABLE public.bankrec_bankrec_id_seq OWNER TO admin;
88059
 
 
88060
 
--
88061
 
--
88062
 
 
88063
 
ALTER SEQUENCE bankrec_bankrec_id_seq OWNED BY bankrec.bankrec_id;
88064
 
 
88065
 
 
88066
 
--
88067
 
--
88068
 
 
88069
 
CREATE TABLE bankrecimport (
88070
 
    bankrecimport_id integer NOT NULL,
88071
 
    bankrecimport_reference text,
88072
 
    bankrecimport_descrip text,
88073
 
    bankrecimport_comment text,
88074
 
    bankrecimport_debit_amount numeric,
88075
 
    bankrecimport_credit_amount numeric,
88076
 
    bankrecimport_effdate date,
88077
 
    bankrecimport_curr_rate numeric
88078
 
);
88079
 
 
88080
 
 
88081
 
ALTER TABLE public.bankrecimport OWNER TO admin;
88082
 
 
88083
 
--
88084
 
--
88085
 
 
88086
 
CREATE SEQUENCE bankrecimport_bankrecimport_id_seq
88087
 
    START WITH 1
88088
 
    INCREMENT BY 1
88089
 
    NO MINVALUE
88090
 
    NO MAXVALUE
88091
 
    CACHE 1;
88092
 
 
88093
 
 
88094
 
ALTER TABLE public.bankrecimport_bankrecimport_id_seq OWNER TO admin;
88095
 
 
88096
 
--
88097
 
--
88098
 
 
88099
 
ALTER SEQUENCE bankrecimport_bankrecimport_id_seq OWNED BY bankrecimport.bankrecimport_id;
88100
 
 
88101
 
 
88102
 
--
88103
 
--
88104
 
 
88105
 
CREATE TABLE bankrecitem (
88106
 
    bankrecitem_id integer NOT NULL,
88107
 
    bankrecitem_bankrec_id integer NOT NULL,
88108
 
    bankrecitem_source text NOT NULL,
88109
 
    bankrecitem_source_id integer NOT NULL,
88110
 
    bankrecitem_cleared boolean DEFAULT false,
88111
 
    bankrecitem_curr_rate numeric,
88112
 
    bankrecitem_amount numeric,
88113
 
    bankrecitem_effdate date
88114
 
);
88115
 
 
88116
 
 
88117
 
ALTER TABLE public.bankrecitem OWNER TO admin;
88118
 
 
88119
 
--
88120
 
--
88121
 
 
88122
 
COMMENT ON TABLE bankrecitem IS 'Posted Bank Reconciliation Line Item information';
88123
 
 
88124
 
 
88125
 
--
88126
 
--
88127
 
 
88128
 
CREATE SEQUENCE bankrecitem_bankrecitem_id_seq
88129
 
    START WITH 1
88130
 
    INCREMENT BY 1
88131
 
    NO MINVALUE
88132
 
    NO MAXVALUE
88133
 
    CACHE 1;
88134
 
 
88135
 
 
88136
 
ALTER TABLE public.bankrecitem_bankrecitem_id_seq OWNER TO admin;
88137
 
 
88138
 
--
88139
 
--
88140
 
 
88141
 
ALTER SEQUENCE bankrecitem_bankrecitem_id_seq OWNED BY bankrecitem.bankrecitem_id;
88142
 
 
88143
 
 
88144
 
--
88145
 
--
88146
 
 
88147
 
CREATE SEQUENCE bomhead_bomhead_id_seq
88148
 
    START WITH 1
88149
 
    INCREMENT BY 1
88150
 
    NO MINVALUE
88151
 
    MAXVALUE 2147483647
88152
 
    CACHE 1;
88153
 
 
88154
 
 
88155
 
ALTER TABLE public.bomhead_bomhead_id_seq OWNER TO admin;
88156
 
 
88157
 
--
88158
 
--
88159
 
 
88160
 
CREATE SEQUENCE bomitem_bomitem_id_seq
88161
 
    START WITH 1
88162
 
    INCREMENT BY 1
88163
 
    NO MINVALUE
88164
 
    MAXVALUE 2147483647
88165
 
    CACHE 1;
88166
 
 
88167
 
 
88168
 
ALTER TABLE public.bomitem_bomitem_id_seq OWNER TO admin;
88169
 
 
88170
 
--
88171
 
--
88172
 
 
88173
 
CREATE TABLE bomitemcost (
88174
 
    bomitemcost_id integer NOT NULL,
88175
 
    bomitemcost_bomitem_id integer NOT NULL,
88176
 
    bomitemcost_costelem_id integer NOT NULL,
88177
 
    bomitemcost_lowlevel boolean DEFAULT false NOT NULL,
88178
 
    bomitemcost_stdcost numeric(16,6) DEFAULT 0 NOT NULL,
88179
 
    bomitemcost_posted date,
88180
 
    bomitemcost_actcost numeric(16,6) DEFAULT 0 NOT NULL,
88181
 
    bomitemcost_updated date,
88182
 
    bomitemcost_curr_id integer DEFAULT basecurrid() NOT NULL
88183
 
);
88184
 
 
88185
 
 
88186
 
ALTER TABLE public.bomitemcost OWNER TO admin;
88187
 
 
88188
 
--
88189
 
--
88190
 
 
88191
 
COMMENT ON TABLE bomitemcost IS 'Bomitem Cost information';
88192
 
 
88193
 
 
88194
 
--
88195
 
--
88196
 
 
88197
 
CREATE SEQUENCE bomitemcost_bomitemcost_id_seq
88198
 
    START WITH 1
88199
 
    INCREMENT BY 1
88200
 
    NO MINVALUE
88201
 
    NO MAXVALUE
88202
 
    CACHE 1;
88203
 
 
88204
 
 
88205
 
ALTER TABLE public.bomitemcost_bomitemcost_id_seq OWNER TO admin;
88206
 
 
88207
 
--
88208
 
--
88209
 
 
88210
 
ALTER SEQUENCE bomitemcost_bomitemcost_id_seq OWNED BY bomitemcost.bomitemcost_id;
88211
 
 
88212
 
 
88213
 
--
88214
 
--
88215
 
 
88216
 
CREATE SEQUENCE bomitemsub_bomitemsub_id_seq
88217
 
    START WITH 1
88218
 
    INCREMENT BY 1
88219
 
    NO MINVALUE
88220
 
    NO MAXVALUE
88221
 
    CACHE 1;
88222
 
 
88223
 
 
88224
 
ALTER TABLE public.bomitemsub_bomitemsub_id_seq OWNER TO admin;
88225
 
 
88226
 
--
88227
 
--
88228
 
 
88229
 
ALTER SEQUENCE bomitemsub_bomitemsub_id_seq OWNED BY bomitemsub.bomitemsub_id;
88230
 
 
88231
 
 
88232
 
--
88233
 
--
88234
 
 
88235
 
CREATE TABLE bomwork (
88236
 
    bomwork_id integer NOT NULL,
88237
 
    bomwork_set_id integer,
88238
 
    bomwork_seqnumber integer,
88239
 
    bomwork_item_id integer,
88240
 
    bomwork_item_type character(1),
88241
 
    bomwork_qtyper numeric(20,8),
88242
 
    bomwork_scrap numeric(20,10),
88243
 
    bomwork_status character(1),
88244
 
    bomwork_level integer,
88245
 
    bomwork_parent_id integer,
88246
 
    bomwork_effective date,
88247
 
    bomwork_expires date,
88248
 
    bomwork_stdunitcost numeric(16,6),
88249
 
    bomwork_actunitcost numeric(16,6),
88250
 
    bomwork_parent_seqnumber integer,
88251
 
    bomwork_createwo boolean,
88252
 
    bomwork_issuemethod character(1),
88253
 
    bomwork_char_id integer,
88254
 
    bomwork_value text,
88255
 
    bomwork_notes text,
88256
 
    bomwork_ref text,
88257
 
    bomwork_bomitem_id integer,
88258
 
    bomwork_ecn text,
88259
 
    bomwork_qtyfxd numeric(20,8) DEFAULT 0 NOT NULL,
88260
 
    bomwork_qtyreq numeric(20,8) DEFAULT 0 NOT NULL
88261
 
);
88262
 
 
88263
 
 
88264
 
ALTER TABLE public.bomwork OWNER TO admin;
88265
 
 
88266
 
--
88267
 
--
88268
 
 
88269
 
COMMENT ON TABLE bomwork IS 'Temporary table for storing information requested by Bill of Materials (BOM) displays and reports';
88270
 
 
88271
 
 
88272
 
--
88273
 
--
88274
 
 
88275
 
COMMENT ON COLUMN bomwork.bomwork_qtyfxd IS 'The fixed quantity required';
88276
 
 
88277
 
 
88278
 
--
88279
 
--
88280
 
 
88281
 
COMMENT ON COLUMN bomwork.bomwork_qtyreq IS 'The total quantity required';
88282
 
 
88283
 
 
88284
 
--
88285
 
--
88286
 
 
88287
 
CREATE SEQUENCE bomwork_bomwork_id_seq
88288
 
    START WITH 1
88289
 
    INCREMENT BY 1
88290
 
    NO MINVALUE
88291
 
    NO MAXVALUE
88292
 
    CACHE 1;
88293
 
 
88294
 
 
88295
 
ALTER TABLE public.bomwork_bomwork_id_seq OWNER TO admin;
88296
 
 
88297
 
--
88298
 
--
88299
 
 
88300
 
ALTER SEQUENCE bomwork_bomwork_id_seq OWNED BY bomwork.bomwork_id;
88301
 
 
88302
 
 
88303
 
--
88304
 
--
88305
 
 
88306
 
CREATE VIEW budget AS
88307
 
    SELECT budgitem.budgitem_id AS budget_id, budgitem.budgitem_period_id AS budget_period_id, budgitem.budgitem_accnt_id AS budget_accnt_id, budgitem.budgitem_amount AS budget_amount FROM budgitem;
88308
 
 
88309
 
 
88310
 
ALTER TABLE public.budget OWNER TO admin;
88311
 
 
88312
 
--
88313
 
--
88314
 
 
88315
 
CREATE SEQUENCE budghead_budghead_id_seq
88316
 
    START WITH 1
88317
 
    INCREMENT BY 1
88318
 
    NO MINVALUE
88319
 
    NO MAXVALUE
88320
 
    CACHE 1;
88321
 
 
88322
 
 
88323
 
ALTER TABLE public.budghead_budghead_id_seq OWNER TO admin;
88324
 
 
88325
 
--
88326
 
--
88327
 
 
88328
 
ALTER SEQUENCE budghead_budghead_id_seq OWNED BY budghead.budghead_id;
88329
 
 
88330
 
 
88331
 
--
88332
 
--
88333
 
 
88334
 
CREATE SEQUENCE budgitem_budgitem_id_seq
88335
 
    START WITH 1
88336
 
    INCREMENT BY 1
88337
 
    NO MINVALUE
88338
 
    NO MAXVALUE
88339
 
    CACHE 1;
88340
 
 
88341
 
 
88342
 
ALTER TABLE public.budgitem_budgitem_id_seq OWNER TO admin;
88343
 
 
88344
 
--
88345
 
--
88346
 
 
88347
 
ALTER SEQUENCE budgitem_budgitem_id_seq OWNED BY budgitem.budgitem_id;
88348
 
 
88349
 
 
88350
 
--
88351
 
--
88352
 
 
88353
 
CREATE TABLE calhead (
88354
 
    calhead_id integer DEFAULT nextval(('"calhead_calhead_id_seq"'::text)::regclass) NOT NULL,
88355
 
    calhead_type character(1),
88356
 
    calhead_name text NOT NULL,
88357
 
    calhead_descrip text,
88358
 
    calhead_origin character(1),
88359
 
    CONSTRAINT calhead_calhead_name_check CHECK ((calhead_name <> ''::text))
88360
 
);
88361
 
 
88362
 
 
88363
 
ALTER TABLE public.calhead OWNER TO admin;
88364
 
 
88365
 
--
88366
 
--
88367
 
 
88368
 
COMMENT ON TABLE calhead IS 'Calendar header information';
88369
 
 
88370
 
 
88371
 
--
88372
 
--
88373
 
 
88374
 
CREATE SEQUENCE calhead_calhead_id_seq
88375
 
    START WITH 1
88376
 
    INCREMENT BY 1
88377
 
    NO MINVALUE
88378
 
    MAXVALUE 2147483647
88379
 
    CACHE 1;
88380
 
 
88381
 
 
88382
 
ALTER TABLE public.calhead_calhead_id_seq OWNER TO admin;
88383
 
 
88384
 
--
88385
 
--
88386
 
 
88387
 
CREATE SEQUENCE carrier_carrier_id_seq
88388
 
    START WITH 1
88389
 
    INCREMENT BY 1
88390
 
    NO MINVALUE
88391
 
    MAXVALUE 2147483647
88392
 
    CACHE 1;
88393
 
 
88394
 
 
88395
 
ALTER TABLE public.carrier_carrier_id_seq OWNER TO admin;
88396
 
 
88397
 
--
88398
 
--
88399
 
 
88400
 
CREATE SEQUENCE cashrcpt_cashrcpt_id_seq
88401
 
    START WITH 1
88402
 
    INCREMENT BY 1
88403
 
    NO MINVALUE
88404
 
    NO MAXVALUE
88405
 
    CACHE 1;
88406
 
 
88407
 
 
88408
 
ALTER TABLE public.cashrcpt_cashrcpt_id_seq OWNER TO admin;
88409
 
 
88410
 
--
88411
 
--
88412
 
 
88413
 
ALTER SEQUENCE cashrcpt_cashrcpt_id_seq OWNED BY cashrcpt.cashrcpt_id;
88414
 
 
88415
 
 
88416
 
--
88417
 
--
88418
 
 
88419
 
CREATE SEQUENCE cashrcptmisc_cashrcptmisc_id_seq
88420
 
    START WITH 1
88421
 
    INCREMENT BY 1
88422
 
    NO MINVALUE
88423
 
    NO MAXVALUE
88424
 
    CACHE 1;
88425
 
 
88426
 
 
88427
 
ALTER TABLE public.cashrcptmisc_cashrcptmisc_id_seq OWNER TO admin;
88428
 
 
88429
 
--
88430
 
--
88431
 
 
88432
 
ALTER SEQUENCE cashrcptmisc_cashrcptmisc_id_seq OWNED BY cashrcptmisc.cashrcptmisc_id;
88433
 
 
88434
 
 
88435
 
--
88436
 
--
88437
 
 
88438
 
CREATE SEQUENCE ccard_ccard_id_seq
88439
 
    START WITH 1
88440
 
    INCREMENT BY 1
88441
 
    NO MINVALUE
88442
 
    NO MAXVALUE
88443
 
    CACHE 1;
88444
 
 
88445
 
 
88446
 
ALTER TABLE public.ccard_ccard_id_seq OWNER TO admin;
88447
 
 
88448
 
--
88449
 
--
88450
 
 
88451
 
ALTER SEQUENCE ccard_ccard_id_seq OWNED BY ccard.ccard_id;
88452
 
 
88453
 
 
88454
 
--
88455
 
--
88456
 
 
88457
 
CREATE TABLE ccardaud (
88458
 
    ccardaud_id integer NOT NULL,
88459
 
    ccardaud_ccard_id integer,
88460
 
    ccardaud_ccard_seq_old integer,
88461
 
    ccardaud_ccard_seq_new integer,
88462
 
    ccardaud_ccard_cust_id_old integer,
88463
 
    ccardaud_ccard_cust_id_new integer,
88464
 
    ccardaud_ccard_active_old boolean,
88465
 
    ccardaud_ccard_active_new boolean,
88466
 
    ccardaud_ccard_name_old bytea,
88467
 
    ccardaud_ccard_name_new bytea,
88468
 
    ccardaud_ccard_address1_old bytea,
88469
 
    ccardaud_ccard_address1_new bytea,
88470
 
    ccardaud_ccard_address2_old bytea,
88471
 
    ccardaud_ccard_address2_new bytea,
88472
 
    ccardaud_ccard_city_old bytea,
88473
 
    ccardaud_ccard_city_new bytea,
88474
 
    ccardaud_ccard_state_old bytea,
88475
 
    ccardaud_ccard_state_new bytea,
88476
 
    ccardaud_ccard_zip_old bytea,
88477
 
    ccardaud_ccard_zip_new bytea,
88478
 
    ccardaud_ccard_country_old bytea,
88479
 
    ccardaud_ccard_country_new bytea,
88480
 
    ccardaud_ccard_number_old bytea,
88481
 
    ccardaud_ccard_number_new bytea,
88482
 
    ccardaud_ccard_debit_old boolean,
88483
 
    ccardaud_ccard_debit_new boolean,
88484
 
    ccardaud_ccard_month_expired_old bytea,
88485
 
    ccardaud_ccard_month_expired_new bytea,
88486
 
    ccardaud_ccard_year_expired_old bytea,
88487
 
    ccardaud_ccard_year_expired_new bytea,
88488
 
    ccardaud_ccard_type_old character(1),
88489
 
    ccardaud_ccard_type_new character(1),
88490
 
    ccardaud_ccard_last_updated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL,
88491
 
    ccardaud_ccard_last_updated_by_username text DEFAULT geteffectivextuser() NOT NULL
88492
 
);
88493
 
 
88494
 
 
88495
 
ALTER TABLE public.ccardaud OWNER TO admin;
88496
 
 
88497
 
--
88498
 
--
88499
 
 
88500
 
COMMENT ON TABLE ccardaud IS 'Credit Card Information tracking data';
88501
 
 
88502
 
 
88503
 
--
88504
 
--
88505
 
 
88506
 
CREATE SEQUENCE ccardaud_ccardaud_id_seq
88507
 
    START WITH 1
88508
 
    INCREMENT BY 1
88509
 
    NO MINVALUE
88510
 
    NO MAXVALUE
88511
 
    CACHE 1;
88512
 
 
88513
 
 
88514
 
ALTER TABLE public.ccardaud_ccardaud_id_seq OWNER TO admin;
88515
 
 
88516
 
--
88517
 
--
88518
 
 
88519
 
ALTER SEQUENCE ccardaud_ccardaud_id_seq OWNED BY ccardaud.ccardaud_id;
88520
 
 
88521
 
 
88522
 
--
88523
 
--
88524
 
 
88525
 
CREATE TABLE ccbank (
88526
 
    ccbank_id integer NOT NULL,
88527
 
    ccbank_ccard_type text NOT NULL,
88528
 
    ccbank_bankaccnt_id integer,
88529
 
    CONSTRAINT ccbank_ccbank_ccard_type_check CHECK ((ccbank_ccard_type = ANY (ARRAY['A'::text, 'D'::text, 'M'::text, 'P'::text, 'V'::text, 'O'::text])))
88530
 
);
88531
 
 
88532
 
 
88533
 
ALTER TABLE public.ccbank OWNER TO admin;
88534
 
 
88535
 
--
88536
 
--
88537
 
 
88538
 
CREATE SEQUENCE ccbank_ccbank_id_seq
88539
 
    START WITH 1
88540
 
    INCREMENT BY 1
88541
 
    NO MINVALUE
88542
 
    NO MAXVALUE
88543
 
    CACHE 1;
88544
 
 
88545
 
 
88546
 
ALTER TABLE public.ccbank_ccbank_id_seq OWNER TO admin;
88547
 
 
88548
 
--
88549
 
--
88550
 
 
88551
 
ALTER SEQUENCE ccbank_ccbank_id_seq OWNED BY ccbank.ccbank_id;
88552
 
 
88553
 
 
88554
 
--
88555
 
--
88556
 
 
88557
 
CREATE TABLE ccpay (
88558
 
    ccpay_id integer NOT NULL,
88559
 
    ccpay_ccard_id integer,
88560
 
    ccpay_cust_id integer,
88561
 
    ccpay_amount numeric(20,2) DEFAULT 0.00 NOT NULL,
88562
 
    ccpay_auth boolean DEFAULT true NOT NULL,
88563
 
    ccpay_status character(1) NOT NULL,
88564
 
    ccpay_type character(1) NOT NULL,
88565
 
    ccpay_auth_charge character(1) NOT NULL,
88566
 
    ccpay_order_number text,
88567
 
    ccpay_order_number_seq integer,
88568
 
    ccpay_r_avs text,
88569
 
    ccpay_r_ordernum text,
88570
 
    ccpay_r_error text,
88571
 
    ccpay_r_approved text,
88572
 
    ccpay_r_code text,
88573
 
    ccpay_r_message text,
88574
 
    ccpay_yp_r_time timestamp without time zone,
88575
 
    ccpay_r_ref text,
88576
 
    ccpay_yp_r_tdate text,
88577
 
    ccpay_r_tax text,
88578
 
    ccpay_r_shipping text,
88579
 
    ccpay_yp_r_score integer,
88580
 
    ccpay_transaction_datetime timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL,
88581
 
    ccpay_by_username text DEFAULT geteffectivextuser() NOT NULL,
88582
 
    ccpay_curr_id integer DEFAULT basecurrid(),
88583
 
    ccpay_ccpay_id integer,
88584
 
    ccpay_card_pan_trunc text,
88585
 
    ccpay_card_type text
88586
 
);
88587
 
 
88588
 
 
88589
 
ALTER TABLE public.ccpay OWNER TO admin;
88590
 
 
88591
 
--
88592
 
--
88593
 
 
88594
 
COMMENT ON TABLE ccpay IS 'Track Credit Card PAYments, although really this table tracs communications with Credit Card processing companies. Records in this table may progress from preauthorizations through captures to credits, or they may simply remain in their original state if there is no further processing.';
88595
 
 
88596
 
 
88597
 
--
88598
 
--
88599
 
 
88600
 
COMMENT ON COLUMN ccpay.ccpay_id IS 'Internal ID of this ccpay record.';
88601
 
 
88602
 
 
88603
 
--
88604
 
--
88605
 
 
88606
 
COMMENT ON COLUMN ccpay.ccpay_ccard_id IS 'Internal ID of the Credit Card used for this transaction.';
88607
 
 
88608
 
 
88609
 
--
88610
 
--
88611
 
 
88612
 
COMMENT ON COLUMN ccpay.ccpay_cust_id IS 'Internal ID of the Customer owning the Credit Card';
88613
 
 
88614
 
 
88615
 
--
88616
 
--
88617
 
 
88618
 
COMMENT ON COLUMN ccpay.ccpay_amount IS 'Actual amount of this transaction.';
88619
 
 
88620
 
 
88621
 
--
88622
 
--
88623
 
 
88624
 
COMMENT ON COLUMN ccpay.ccpay_auth IS 'Boolean indicator of whether this transaction started out as a pre-authorization or not.';
88625
 
 
88626
 
 
88627
 
--
88628
 
--
88629
 
 
88630
 
COMMENT ON COLUMN ccpay.ccpay_status IS 'The status of the last attempted transaction for this record. Values include A = Authorized, C = Charged, D = Declined or otherwise rejected, V = Voided, X = Error.';
88631
 
 
88632
 
 
88633
 
--
88634
 
--
88635
 
 
88636
 
COMMENT ON COLUMN ccpay.ccpay_type IS 'The most recent type of transaction attempted with this record. Values include A = Authorize, C = Capture or Charge, R = cRedit, V = reVerse or Void.';
88637
 
 
88638
 
 
88639
 
--
88640
 
--
88641
 
 
88642
 
COMMENT ON COLUMN ccpay.ccpay_auth_charge IS 'The original type of transaction attempted with this record. Values are the same as for ccpay_type.';
88643
 
 
88644
 
 
88645
 
--
88646
 
--
88647
 
 
88648
 
COMMENT ON COLUMN ccpay.ccpay_order_number IS 'The original xTuple ERP order for which this credit card transaction applies. This will usually be either a Sales Order number or Credit Memo number.';
88649
 
 
88650
 
 
88651
 
--
88652
 
--
88653
 
 
88654
 
COMMENT ON COLUMN ccpay.ccpay_order_number_seq IS 'A sequence number to differentiate between different transactions for the same ccpay_order_number. For example, if a Customer makes a down payment and a final payment for a single order, there will be two distinct ccpay records with the same ccpay_order_number but different ccpay_order_number_seq values (1 and 2, respectively).';
88655
 
 
88656
 
 
88657
 
--
88658
 
--
88659
 
 
88660
 
COMMENT ON COLUMN ccpay.ccpay_r_avs IS 'The Address Verification System code returned by the credit card processing company.';
88661
 
 
88662
 
 
88663
 
--
88664
 
--
88665
 
 
88666
 
COMMENT ON COLUMN ccpay.ccpay_r_ordernum IS 'A transaction ID returned by the credit card processing company to be used when referring to this transaction later. It may be used for voiding, crediting, or capturing previous transactions.';
88667
 
 
88668
 
 
88669
 
--
88670
 
--
88671
 
 
88672
 
COMMENT ON COLUMN ccpay.ccpay_r_error IS 'Error message, if any, describing why this record failed to be processed properly.';
88673
 
 
88674
 
 
88675
 
--
88676
 
--
88677
 
 
88678
 
COMMENT ON COLUMN ccpay.ccpay_r_approved IS 'English text stating whether the transaction was approved, declined, hit an error, or was held for review. Specific values differ depending on the credit card processor.';
88679
 
 
88680
 
 
88681
 
--
88682
 
--
88683
 
 
88684
 
COMMENT ON COLUMN ccpay.ccpay_r_code IS 'The transaction Approval code returned by the credit card processor. Specific values differ depending on the credit card processor.';
88685
 
 
88686
 
 
88687
 
--
88688
 
--
88689
 
 
88690
 
COMMENT ON COLUMN ccpay.ccpay_r_message IS 'Additional text that describes the status of the transaction. This may be empty.';
88691
 
 
88692
 
 
88693
 
--
88694
 
--
88695
 
 
88696
 
COMMENT ON COLUMN ccpay.ccpay_yp_r_time IS 'The time the transaction was posted according to the credit card processing company. May be blank.';
88697
 
 
88698
 
 
88699
 
--
88700
 
--
88701
 
 
88702
 
COMMENT ON COLUMN ccpay.ccpay_r_ref IS 'An additional reference number assigned to this transaction by the credit card processing company.';
88703
 
 
88704
 
 
88705
 
--
88706
 
--
88707
 
 
88708
 
COMMENT ON COLUMN ccpay.ccpay_yp_r_tdate IS 'The date the transaction was posted according to the credit card processing company. May be blank.';
88709
 
 
88710
 
 
88711
 
--
88712
 
--
88713
 
 
88714
 
COMMENT ON COLUMN ccpay.ccpay_r_tax IS '[ deprecated ]';
88715
 
 
88716
 
 
88717
 
--
88718
 
--
88719
 
 
88720
 
COMMENT ON COLUMN ccpay.ccpay_r_shipping IS '[ deprecated ]';
88721
 
 
88722
 
 
88723
 
--
88724
 
--
88725
 
 
88726
 
COMMENT ON COLUMN ccpay.ccpay_yp_r_score IS 'A potential fraud score returned by the credit card company. May be blank.';
88727
 
 
88728
 
 
88729
 
--
88730
 
--
88731
 
 
88732
 
COMMENT ON COLUMN ccpay.ccpay_transaction_datetime IS 'The date and time this record was created, unless explicitly set by the application.';
88733
 
 
88734
 
 
88735
 
--
88736
 
--
88737
 
 
88738
 
COMMENT ON COLUMN ccpay.ccpay_by_username IS 'The user who created this record, unless explicitly set by the application.';
88739
 
 
88740
 
 
88741
 
--
88742
 
--
88743
 
 
88744
 
COMMENT ON COLUMN ccpay.ccpay_curr_id IS 'The internal ID of the currency of the ccpay_amount.';
88745
 
 
88746
 
 
88747
 
--
88748
 
--
88749
 
 
88750
 
COMMENT ON COLUMN ccpay.ccpay_ccpay_id IS 'Foreign key to another ccpay record. This will have a value if a new ccpay record is created to record a Refund for part or all of another ccpay record.';
88751
 
 
88752
 
 
88753
 
--
88754
 
--
88755
 
 
88756
 
COMMENT ON COLUMN ccpay.ccpay_card_pan_trunc IS 'External Pre-Auth truncated PAN. Last four digits of the card.';
88757
 
 
88758
 
 
88759
 
--
88760
 
--
88761
 
 
88762
 
COMMENT ON COLUMN ccpay.ccpay_card_type IS 'External Pre-Auth card type: V=Visa, M=MasterCard, A=American Express, D=Discover.';
88763
 
 
88764
 
 
88765
 
--
88766
 
--
88767
 
 
88768
 
CREATE SEQUENCE ccpay_ccpay_id_seq
88769
 
    START WITH 1
88770
 
    INCREMENT BY 1
88771
 
    NO MINVALUE
88772
 
    NO MAXVALUE
88773
 
    CACHE 1;
88774
 
 
88775
 
 
88776
 
ALTER TABLE public.ccpay_ccpay_id_seq OWNER TO admin;
88777
 
 
88778
 
--
88779
 
--
88780
 
 
88781
 
ALTER SEQUENCE ccpay_ccpay_id_seq OWNED BY ccpay.ccpay_id;
88782
 
 
88783
 
 
88784
 
--
88785
 
--
88786
 
 
88787
 
CREATE SEQUENCE char_char_id_seq
88788
 
    START WITH 1
88789
 
    INCREMENT BY 1
88790
 
    NO MINVALUE
88791
 
    NO MAXVALUE
88792
 
    CACHE 1;
88793
 
 
88794
 
 
88795
 
ALTER TABLE public.char_char_id_seq OWNER TO admin;
88796
 
 
88797
 
--
88798
 
--
88799
 
 
88800
 
ALTER SEQUENCE char_char_id_seq OWNED BY "char".char_id;
88801
 
 
88802
 
 
88803
 
--
88804
 
--
88805
 
 
88806
 
CREATE SEQUENCE charass_charass_id_seq
88807
 
    START WITH 1
88808
 
    INCREMENT BY 1
88809
 
    NO MINVALUE
88810
 
    NO MAXVALUE
88811
 
    CACHE 1;
88812
 
 
88813
 
 
88814
 
ALTER TABLE public.charass_charass_id_seq OWNER TO admin;
88815
 
 
88816
 
--
88817
 
--
88818
 
 
88819
 
ALTER SEQUENCE charass_charass_id_seq OWNED BY charass.charass_id;
88820
 
 
88821
 
 
88822
 
--
88823
 
--
88824
 
 
88825
 
CREATE TABLE charopt (
88826
 
    charopt_id integer NOT NULL,
88827
 
    charopt_char_id integer,
88828
 
    charopt_value text NOT NULL,
88829
 
    charopt_order integer DEFAULT 0 NOT NULL
88830
 
);
88831
 
 
88832
 
 
88833
 
ALTER TABLE public.charopt OWNER TO admin;
88834
 
 
88835
 
--
88836
 
--
88837
 
 
88838
 
COMMENT ON TABLE charopt IS 'Stores list options for characteristics';
88839
 
 
88840
 
 
88841
 
--
88842
 
--
88843
 
 
88844
 
COMMENT ON COLUMN charopt.charopt_id IS 'Primary key';
88845
 
 
88846
 
 
88847
 
--
88848
 
--
88849
 
 
88850
 
COMMENT ON COLUMN charopt.charopt_char_id IS 'Reference to char table';
88851
 
 
88852
 
 
88853
 
--
88854
 
--
88855
 
 
88856
 
COMMENT ON COLUMN charopt.charopt_value IS 'Option value';
88857
 
 
88858
 
 
88859
 
--
88860
 
--
88861
 
 
88862
 
COMMENT ON COLUMN charopt.charopt_order IS 'Option sort order';
88863
 
 
88864
 
 
88865
 
--
88866
 
--
88867
 
 
88868
 
CREATE SEQUENCE charopt_charopt_id_seq
88869
 
    START WITH 1
88870
 
    INCREMENT BY 1
88871
 
    NO MINVALUE
88872
 
    NO MAXVALUE
88873
 
    CACHE 1;
88874
 
 
88875
 
 
88876
 
ALTER TABLE public.charopt_charopt_id_seq OWNER TO admin;
88877
 
 
88878
 
--
88879
 
--
88880
 
 
88881
 
ALTER SEQUENCE charopt_charopt_id_seq OWNED BY charopt.charopt_id;
88882
 
 
88883
 
 
88884
 
--
88885
 
--
88886
 
 
88887
 
CREATE SEQUENCE checkhead_checkhead_id_seq
88888
 
    START WITH 1
88889
 
    INCREMENT BY 1
88890
 
    NO MINVALUE
88891
 
    NO MAXVALUE
88892
 
    CACHE 1;
88893
 
 
88894
 
 
88895
 
ALTER TABLE public.checkhead_checkhead_id_seq OWNER TO admin;
88896
 
 
88897
 
--
88898
 
--
88899
 
 
88900
 
ALTER SEQUENCE checkhead_checkhead_id_seq OWNED BY checkhead.checkhead_id;
88901
 
 
88902
 
 
88903
 
--
88904
 
--
88905
 
 
88906
 
CREATE SEQUENCE checkitem_checkitem_id_seq
88907
 
    START WITH 1
88908
 
    INCREMENT BY 1
88909
 
    NO MINVALUE
88910
 
    NO MAXVALUE
88911
 
    CACHE 1;
88912
 
 
88913
 
 
88914
 
ALTER TABLE public.checkitem_checkitem_id_seq OWNER TO admin;
88915
 
 
88916
 
--
88917
 
--
88918
 
 
88919
 
ALTER SEQUENCE checkitem_checkitem_id_seq OWNED BY checkitem.checkitem_id;
88920
 
 
88921
 
 
88922
 
--
88923
 
--
88924
 
 
88925
 
CREATE VIEW checkrecip AS
88926
 
    (SELECT custinfo.cust_id AS checkrecip_id, 'C'::text AS checkrecip_type, custinfo.cust_number AS checkrecip_number, custinfo.cust_name AS checkrecip_name, 'A/R'::text AS checkrecip_gltrans_source, findaraccount(custinfo.cust_id) AS checkrecip_accnt_id, cntct.cntct_addr_id AS checkrecip_addr_id FROM (custinfo LEFT JOIN cntct ON ((custinfo.cust_cntct_id = cntct.cntct_id))) UNION ALL SELECT taxauth.taxauth_id AS checkrecip_id, 'T'::text AS checkrecip_type, taxauth.taxauth_code AS checkrecip_number, taxauth.taxauth_name AS checkrecip_name, 'G/L'::text AS checkrecip_gltrans_source, taxauth.taxauth_accnt_id AS checkrecip_accnt_id, taxauth.taxauth_addr_id AS checkrecip_addr_id FROM taxauth) UNION ALL SELECT vendinfo.vend_id AS checkrecip_id, 'V'::text AS checkrecip_type, vendinfo.vend_number AS checkrecip_number, vendinfo.vend_name AS checkrecip_name, 'A/P'::text AS checkrecip_gltrans_source, findapaccount(vendinfo.vend_id) AS checkrecip_accnt_id, vendaddrinfo.vendaddr_addr_id AS checkrecip_addr_id FROM (vendinfo LEFT JOIN vendaddrinfo ON (((vendinfo.vend_id = vendaddrinfo.vendaddr_vend_id) AND (upper(vendaddrinfo.vendaddr_code) = 'REMIT'::text))));
88927
 
 
88928
 
 
88929
 
ALTER TABLE public.checkrecip OWNER TO admin;
88930
 
 
88931
 
--
88932
 
--
88933
 
 
88934
 
CREATE SEQUENCE classcode_classcode_id_seq
88935
 
    START WITH 1
88936
 
    INCREMENT BY 1
88937
 
    NO MINVALUE
88938
 
    MAXVALUE 2147483647
88939
 
    CACHE 1;
88940
 
 
88941
 
 
88942
 
ALTER TABLE public.classcode_classcode_id_seq OWNER TO admin;
88943
 
 
88944
 
--
88945
 
--
88946
 
 
88947
 
CREATE SEQUENCE cmhead_cmhead_id_seq
88948
 
    START WITH 1
88949
 
    INCREMENT BY 1
88950
 
    NO MINVALUE
88951
 
    MAXVALUE 2147483647
88952
 
    CACHE 1;
88953
 
 
88954
 
 
88955
 
ALTER TABLE public.cmhead_cmhead_id_seq OWNER TO admin;
88956
 
 
88957
 
--
88958
 
--
88959
 
 
88960
 
CREATE TABLE cmheadtax (
88961
 
)
88962
 
INHERITS (taxhist);
88963
 
 
88964
 
 
88965
 
ALTER TABLE public.cmheadtax OWNER TO admin;
88966
 
 
88967
 
--
88968
 
--
88969
 
 
88970
 
CREATE SEQUENCE cmitem_cmitem_id_seq
88971
 
    START WITH 1
88972
 
    INCREMENT BY 1
88973
 
    NO MINVALUE
88974
 
    MAXVALUE 2147483647
88975
 
    CACHE 1;
88976
 
 
88977
 
 
88978
 
ALTER TABLE public.cmitem_cmitem_id_seq OWNER TO admin;
88979
 
 
88980
 
--
88981
 
--
88982
 
 
88983
 
CREATE TABLE cmitemtax (
88984
 
)
88985
 
INHERITS (taxhist);
88986
 
 
88987
 
 
88988
 
ALTER TABLE public.cmitemtax OWNER TO admin;
88989
 
 
88990
 
--
88991
 
--
88992
 
 
88993
 
CREATE SEQUENCE cmnttype_cmnttype_id_seq
88994
 
    START WITH 1
88995
 
    INCREMENT BY 1
88996
 
    NO MINVALUE
88997
 
    NO MAXVALUE
88998
 
    CACHE 1;
88999
 
 
89000
 
 
89001
 
ALTER TABLE public.cmnttype_cmnttype_id_seq OWNER TO admin;
89002
 
 
89003
 
--
89004
 
--
89005
 
 
89006
 
ALTER SEQUENCE cmnttype_cmnttype_id_seq OWNED BY cmnttype.cmnttype_id;
89007
 
 
89008
 
 
89009
 
--
89010
 
--
89011
 
 
89012
 
CREATE TABLE cmnttypesource (
89013
 
    cmnttypesource_id integer NOT NULL,
89014
 
    cmnttypesource_cmnttype_id integer,
89015
 
    cmnttypesource_source_id integer
89016
 
);
89017
 
 
89018
 
 
89019
 
ALTER TABLE public.cmnttypesource OWNER TO admin;
89020
 
 
89021
 
--
89022
 
--
89023
 
 
89024
 
COMMENT ON TABLE cmnttypesource IS 'Comment Type/Source association';
89025
 
 
89026
 
 
89027
 
--
89028
 
--
89029
 
 
89030
 
CREATE SEQUENCE cmnttypesource_cmnttypesource_id_seq
89031
 
    START WITH 1
89032
 
    INCREMENT BY 1
89033
 
    NO MINVALUE
89034
 
    NO MAXVALUE
89035
 
    CACHE 1;
89036
 
 
89037
 
 
89038
 
ALTER TABLE public.cmnttypesource_cmnttypesource_id_seq OWNER TO admin;
89039
 
 
89040
 
--
89041
 
--
89042
 
 
89043
 
ALTER SEQUENCE cmnttypesource_cmnttypesource_id_seq OWNED BY cmnttypesource.cmnttypesource_id;
89044
 
 
89045
 
 
89046
 
--
89047
 
--
89048
 
 
89049
 
CREATE SEQUENCE cntct_cntct_id_seq
89050
 
    START WITH 1
89051
 
    INCREMENT BY 1
89052
 
    NO MINVALUE
89053
 
    NO MAXVALUE
89054
 
    CACHE 1;
89055
 
 
89056
 
 
89057
 
ALTER TABLE public.cntct_cntct_id_seq OWNER TO admin;
89058
 
 
89059
 
--
89060
 
--
89061
 
 
89062
 
ALTER SEQUENCE cntct_cntct_id_seq OWNED BY cntct.cntct_id;
89063
 
 
89064
 
 
89065
 
--
89066
 
--
89067
 
 
89068
 
CREATE TABLE cntctaddr (
89069
 
    cntctaddr_id integer NOT NULL,
89070
 
    cntctaddr_cntct_id integer,
89071
 
    cntctaddr_primary boolean NOT NULL,
89072
 
    cntctaddr_addr_id integer NOT NULL,
89073
 
    cntctaddr_type character(2) NOT NULL
89074
 
);
89075
 
 
89076
 
 
89077
 
ALTER TABLE public.cntctaddr OWNER TO admin;
89078
 
 
89079
 
--
89080
 
--
89081
 
 
89082
 
CREATE SEQUENCE cntctaddr_cntctaddr_id_seq
89083
 
    START WITH 1
89084
 
    INCREMENT BY 1
89085
 
    NO MINVALUE
89086
 
    NO MAXVALUE
89087
 
    CACHE 1;
89088
 
 
89089
 
 
89090
 
ALTER TABLE public.cntctaddr_cntctaddr_id_seq OWNER TO admin;
89091
 
 
89092
 
--
89093
 
--
89094
 
 
89095
 
ALTER SEQUENCE cntctaddr_cntctaddr_id_seq OWNED BY cntctaddr.cntctaddr_id;
89096
 
 
89097
 
 
89098
 
--
89099
 
--
89100
 
 
89101
 
CREATE TABLE cntctdata (
89102
 
    cntctdata_id integer NOT NULL,
89103
 
    cntctdata_cntct_id integer,
89104
 
    cntctdata_primary boolean NOT NULL,
89105
 
    cntctdata_text text NOT NULL,
89106
 
    cntctdata_type character(2) NOT NULL
89107
 
);
89108
 
 
89109
 
 
89110
 
ALTER TABLE public.cntctdata OWNER TO admin;
89111
 
 
89112
 
--
89113
 
--
89114
 
 
89115
 
CREATE SEQUENCE cntctdata_cntctdata_id_seq
89116
 
    START WITH 1
89117
 
    INCREMENT BY 1
89118
 
    NO MINVALUE
89119
 
    NO MAXVALUE
89120
 
    CACHE 1;
89121
 
 
89122
 
 
89123
 
ALTER TABLE public.cntctdata_cntctdata_id_seq OWNER TO admin;
89124
 
 
89125
 
--
89126
 
--
89127
 
 
89128
 
ALTER SEQUENCE cntctdata_cntctdata_id_seq OWNED BY cntctdata.cntctdata_id;
89129
 
 
89130
 
 
89131
 
--
89132
 
--
89133
 
 
89134
 
CREATE TABLE cntcteml (
89135
 
    cntcteml_id integer NOT NULL,
89136
 
    cntcteml_cntct_id integer,
89137
 
    cntcteml_primary boolean DEFAULT false NOT NULL,
89138
 
    cntcteml_email text NOT NULL
89139
 
);
89140
 
 
89141
 
 
89142
 
ALTER TABLE public.cntcteml OWNER TO admin;
89143
 
 
89144
 
--
89145
 
--
89146
 
 
89147
 
COMMENT ON TABLE cntcteml IS 'Stores email addresses for contacts';
89148
 
 
89149
 
 
89150
 
--
89151
 
--
89152
 
 
89153
 
COMMENT ON COLUMN cntcteml.cntcteml_id IS 'Primary key';
89154
 
 
89155
 
 
89156
 
--
89157
 
--
89158
 
 
89159
 
COMMENT ON COLUMN cntcteml.cntcteml_cntct_id IS 'Reference to contact table';
89160
 
 
89161
 
 
89162
 
--
89163
 
--
89164
 
 
89165
 
COMMENT ON COLUMN cntcteml.cntcteml_primary IS 'Flags whether this is the primary email address';
89166
 
 
89167
 
 
89168
 
--
89169
 
--
89170
 
 
89171
 
COMMENT ON COLUMN cntcteml.cntcteml_email IS 'Alternate information';
89172
 
 
89173
 
 
89174
 
--
89175
 
--
89176
 
 
89177
 
CREATE SEQUENCE cntcteml_cntcteml_id_seq
89178
 
    START WITH 1
89179
 
    INCREMENT BY 1
89180
 
    NO MINVALUE
89181
 
    NO MAXVALUE
89182
 
    CACHE 1;
89183
 
 
89184
 
 
89185
 
ALTER TABLE public.cntcteml_cntcteml_id_seq OWNER TO admin;
89186
 
 
89187
 
--
89188
 
--
89189
 
 
89190
 
ALTER SEQUENCE cntcteml_cntcteml_id_seq OWNED BY cntcteml.cntcteml_id;
89191
 
 
89192
 
 
89193
 
--
89194
 
--
89195
 
 
89196
 
CREATE TABLE cntctmrgd (
89197
 
    cntctmrgd_cntct_id integer NOT NULL,
89198
 
    cntctmrgd_error boolean DEFAULT false
89199
 
);
89200
 
 
89201
 
 
89202
 
ALTER TABLE public.cntctmrgd OWNER TO admin;
89203
 
 
89204
 
--
89205
 
--
89206
 
 
89207
 
CREATE TABLE cntctsel (
89208
 
    cntctsel_cntct_id integer NOT NULL,
89209
 
    cntctsel_target boolean,
89210
 
    cntctsel_mrg_crmacct_id boolean DEFAULT false,
89211
 
    cntctsel_mrg_addr_id boolean DEFAULT false,
89212
 
    cntctsel_mrg_first_name boolean DEFAULT false,
89213
 
    cntctsel_mrg_last_name boolean DEFAULT false,
89214
 
    cntctsel_mrg_honorific boolean DEFAULT false,
89215
 
    cntctsel_mrg_initials boolean DEFAULT false,
89216
 
    cntctsel_mrg_phone boolean DEFAULT false,
89217
 
    cntctsel_mrg_phone2 boolean DEFAULT false,
89218
 
    cntctsel_mrg_fax boolean DEFAULT false,
89219
 
    cntctsel_mrg_email boolean DEFAULT false,
89220
 
    cntctsel_mrg_webaddr boolean DEFAULT false,
89221
 
    cntctsel_mrg_notes boolean DEFAULT false,
89222
 
    cntctsel_mrg_title boolean DEFAULT false,
89223
 
    cntctsel_mrg_middle boolean DEFAULT false,
89224
 
    cntctsel_mrg_suffix boolean DEFAULT false,
89225
 
    cntctsel_mrg_owner_username boolean DEFAULT false
89226
 
);
89227
 
 
89228
 
 
89229
 
ALTER TABLE public.cntctsel OWNER TO admin;
89230
 
 
89231
 
--
89232
 
--
89233
 
 
89234
 
CREATE SEQUENCE cntslip_cntslip_id_seq
89235
 
    START WITH 1
89236
 
    INCREMENT BY 1
89237
 
    NO MINVALUE
89238
 
    MAXVALUE 2147483647
89239
 
    CACHE 1;
89240
 
 
89241
 
 
89242
 
ALTER TABLE public.cntslip_cntslip_id_seq OWNER TO admin;
89243
 
 
89244
 
--
89245
 
--
89246
 
 
89247
 
CREATE TABLE cobill (
89248
 
    cobill_id integer DEFAULT nextval(('cobill_cobill_id_seq'::text)::regclass) NOT NULL,
89249
 
    cobill_coitem_id integer,
89250
 
    cobill_selectdate timestamp with time zone,
89251
 
    cobill_qty numeric(18,6),
89252
 
    cobill_invcnum integer,
89253
 
    cobill_toclose boolean,
89254
 
    cobill_cobmisc_id integer,
89255
 
    cobill_select_username text,
89256
 
    cobill_invcitem_id integer,
89257
 
    cobill_taxtype_id integer
89258
 
);
89259
 
 
89260
 
 
89261
 
ALTER TABLE public.cobill OWNER TO admin;
89262
 
 
89263
 
--
89264
 
--
89265
 
 
89266
 
COMMENT ON TABLE cobill IS 'Billing Selection Line Item information';
89267
 
 
89268
 
 
89269
 
--
89270
 
--
89271
 
 
89272
 
CREATE SEQUENCE cobill_cobill_id_seq
89273
 
    START WITH 1
89274
 
    INCREMENT BY 1
89275
 
    NO MINVALUE
89276
 
    MAXVALUE 2147483647
89277
 
    CACHE 1;
89278
 
 
89279
 
 
89280
 
ALTER TABLE public.cobill_cobill_id_seq OWNER TO admin;
89281
 
 
89282
 
--
89283
 
--
89284
 
 
89285
 
CREATE TABLE cobilltax (
89286
 
)
89287
 
INHERITS (taxhist);
89288
 
 
89289
 
 
89290
 
ALTER TABLE public.cobilltax OWNER TO admin;
89291
 
 
89292
 
--
89293
 
--
89294
 
 
89295
 
CREATE TABLE cobmisc (
89296
 
    cobmisc_id integer DEFAULT nextval(('cobmisc_cobmisc_id_seq'::text)::regclass) NOT NULL,
89297
 
    cobmisc_cohead_id integer,
89298
 
    cobmisc_shipvia text,
89299
 
    cobmisc_freight numeric(16,4),
89300
 
    cobmisc_misc numeric(16,4),
89301
 
    cobmisc_payment numeric(16,4),
89302
 
    cobmisc_paymentref text,
89303
 
    cobmisc_notes text,
89304
 
    cobmisc_shipdate date,
89305
 
    cobmisc_invcnumber integer,
89306
 
    cobmisc_invcdate date,
89307
 
    cobmisc_posted boolean,
89308
 
    cobmisc_misc_accnt_id integer,
89309
 
    cobmisc_misc_descrip text,
89310
 
    cobmisc_closeorder boolean,
89311
 
    cobmisc_curr_id integer DEFAULT basecurrid(),
89312
 
    cobmisc_invchead_id integer,
89313
 
    cobmisc_taxzone_id integer,
89314
 
    cobmisc_taxtype_id integer
89315
 
);
89316
 
 
89317
 
 
89318
 
ALTER TABLE public.cobmisc OWNER TO admin;
89319
 
 
89320
 
--
89321
 
--
89322
 
 
89323
 
COMMENT ON TABLE cobmisc IS 'General information about Billing Selections';
89324
 
 
89325
 
 
89326
 
--
89327
 
--
89328
 
 
89329
 
CREATE SEQUENCE cobmisc_cobmisc_id_seq
89330
 
    START WITH 1
89331
 
    INCREMENT BY 1
89332
 
    NO MINVALUE
89333
 
    MAXVALUE 2147483647
89334
 
    CACHE 1;
89335
 
 
89336
 
 
89337
 
ALTER TABLE public.cobmisc_cobmisc_id_seq OWNER TO admin;
89338
 
 
89339
 
--
89340
 
--
89341
 
 
89342
 
CREATE TABLE cobmisctax (
89343
 
)
89344
 
INHERITS (taxhist);
89345
 
 
89346
 
 
89347
 
ALTER TABLE public.cobmisctax OWNER TO admin;
89348
 
 
89349
 
--
89350
 
--
89351
 
 
89352
 
CREATE SEQUENCE cohead_cohead_id_seq
89353
 
    START WITH 1
89354
 
    INCREMENT BY 1
89355
 
    NO MINVALUE
89356
 
    MAXVALUE 2147483647
89357
 
    CACHE 1;
89358
 
 
89359
 
 
89360
 
ALTER TABLE public.cohead_cohead_id_seq OWNER TO admin;
89361
 
 
89362
 
--
89363
 
--
89364
 
 
89365
 
CREATE SEQUENCE cohist_cohist_id_seq
89366
 
    START WITH 1
89367
 
    INCREMENT BY 1
89368
 
    NO MINVALUE
89369
 
    MAXVALUE 2147483647
89370
 
    CACHE 1;
89371
 
 
89372
 
 
89373
 
ALTER TABLE public.cohist_cohist_id_seq OWNER TO admin;
89374
 
 
89375
 
--
89376
 
--
89377
 
 
89378
 
CREATE SEQUENCE coitem_coitem_id_seq
89379
 
    START WITH 1
89380
 
    INCREMENT BY 1
89381
 
    NO MINVALUE
89382
 
    MAXVALUE 2147483647
89383
 
    CACHE 1;
89384
 
 
89385
 
 
89386
 
ALTER TABLE public.coitem_coitem_id_seq OWNER TO admin;
89387
 
 
89388
 
--
89389
 
--
89390
 
 
89391
 
CREATE SEQUENCE comment_comment_id_seq
89392
 
    START WITH 1
89393
 
    INCREMENT BY 1
89394
 
    NO MINVALUE
89395
 
    NO MAXVALUE
89396
 
    CACHE 1;
89397
 
 
89398
 
 
89399
 
ALTER TABLE public.comment_comment_id_seq OWNER TO admin;
89400
 
 
89401
 
--
89402
 
--
89403
 
 
89404
 
CREATE TABLE company (
89405
 
    company_id integer NOT NULL,
89406
 
    company_number text NOT NULL,
89407
 
    company_descrip text,
89408
 
    company_external boolean DEFAULT false NOT NULL,
89409
 
    company_server text,
89410
 
    company_port integer,
89411
 
    company_database text,
89412
 
    company_curr_id integer,
89413
 
    company_yearend_accnt_id integer,
89414
 
    company_gainloss_accnt_id integer,
89415
 
    company_dscrp_accnt_id integer,
89416
 
    company_unrlzgainloss_accnt_id integer,
89417
 
    CONSTRAINT company_company_number_check CHECK ((company_number <> ''::text))
89418
 
);
89419
 
 
89420
 
 
89421
 
ALTER TABLE public.company OWNER TO admin;
89422
 
 
89423
 
--
89424
 
--
89425
 
 
89426
 
COMMENT ON TABLE company IS 'Company information';
89427
 
 
89428
 
 
89429
 
--
89430
 
--
89431
 
 
89432
 
CREATE SEQUENCE company_company_id_seq
89433
 
    START WITH 1
89434
 
    INCREMENT BY 1
89435
 
    NO MINVALUE
89436
 
    NO MAXVALUE
89437
 
    CACHE 1;
89438
 
 
89439
 
 
89440
 
ALTER TABLE public.company_company_id_seq OWNER TO admin;
89441
 
 
89442
 
--
89443
 
--
89444
 
 
89445
 
ALTER SEQUENCE company_company_id_seq OWNED BY company.company_id;
89446
 
 
89447
 
 
89448
 
--
89449
 
--
89450
 
 
89451
 
CREATE SEQUENCE contrct_contrct_id_seq
89452
 
    START WITH 1
89453
 
    INCREMENT BY 1
89454
 
    NO MINVALUE
89455
 
    NO MAXVALUE
89456
 
    CACHE 1;
89457
 
 
89458
 
 
89459
 
ALTER TABLE public.contrct_contrct_id_seq OWNER TO admin;
89460
 
 
89461
 
--
89462
 
--
89463
 
 
89464
 
ALTER SEQUENCE contrct_contrct_id_seq OWNED BY contrct.contrct_id;
89465
 
 
89466
 
 
89467
 
--
89468
 
--
89469
 
 
89470
 
CREATE TABLE shiphead (
89471
 
    shiphead_id integer NOT NULL,
89472
 
    shiphead_order_id integer NOT NULL,
89473
 
    shiphead_order_type text NOT NULL,
89474
 
    shiphead_number text NOT NULL,
89475
 
    shiphead_shipvia text,
89476
 
    shiphead_freight numeric(16,4) DEFAULT 0.0 NOT NULL,
89477
 
    shiphead_freight_curr_id integer DEFAULT basecurrid() NOT NULL,
89478
 
    shiphead_notes text,
89479
 
    shiphead_shipped boolean DEFAULT false NOT NULL,
89480
 
    shiphead_shipdate date,
89481
 
    shiphead_shipchrg_id integer,
89482
 
    shiphead_shipform_id integer,
89483
 
    shiphead_sfstatus character(1) NOT NULL,
89484
 
    shiphead_tracknum text,
89485
 
    CONSTRAINT shiphead_shiphead_number_check CHECK ((shiphead_number <> ''::text)),
89486
 
    CONSTRAINT shiphead_shiphead_order_type_check CHECK (((shiphead_order_type = 'SO'::text) OR (shiphead_order_type = 'TO'::text))),
89487
 
    CONSTRAINT shiphead_shiphead_sfstatus_check CHECK ((((shiphead_sfstatus = 'D'::bpchar) OR (shiphead_sfstatus = 'N'::bpchar)) OR (shiphead_sfstatus = 'P'::bpchar)))
89488
 
);
89489
 
 
89490
 
 
89491
 
ALTER TABLE public.shiphead OWNER TO admin;
89492
 
 
89493
 
--
89494
 
--
89495
 
 
89496
 
COMMENT ON TABLE shiphead IS 'General information about Shipments';
89497
 
 
89498
 
 
89499
 
--
89500
 
--
89501
 
 
89502
 
CREATE TABLE shipitem (
89503
 
    shipitem_id integer NOT NULL,
89504
 
    shipitem_orderitem_id integer NOT NULL,
89505
 
    shipitem_shiphead_id integer NOT NULL,
89506
 
    shipitem_qty numeric(18,6) NOT NULL,
89507
 
    shipitem_shipped boolean DEFAULT false NOT NULL,
89508
 
    shipitem_shipdate timestamp with time zone,
89509
 
    shipitem_transdate timestamp with time zone,
89510
 
    shipitem_trans_username text,
89511
 
    shipitem_invoiced boolean DEFAULT false NOT NULL,
89512
 
    shipitem_invcitem_id integer,
89513
 
    shipitem_value numeric(18,6),
89514
 
    shipitem_invhist_id integer
89515
 
);
89516
 
 
89517
 
 
89518
 
ALTER TABLE public.shipitem OWNER TO admin;
89519
 
 
89520
 
--
89521
 
--
89522
 
 
89523
 
COMMENT ON TABLE shipitem IS 'Information about Shipment Line Items';
89524
 
 
89525
 
 
89526
 
--
89527
 
--
89528
 
 
89529
 
CREATE VIEW coship AS
89530
 
    SELECT shipitem.shipitem_id AS coship_id, shipitem.shipitem_orderitem_id AS coship_coitem_id, shipitem.shipitem_shipdate AS coship_shipdate, shipitem.shipitem_qty AS coship_qty, shipitem.shipitem_transdate AS coship_transdate, shipitem.shipitem_shipped AS coship_shipped, shipitem.shipitem_invoiced AS coship_invoiced, shipitem.shipitem_shiphead_id AS coship_cosmisc_id, shipitem.shipitem_trans_username AS coship_trans_username, shipitem.shipitem_invcitem_id AS coship_invcitem_id FROM shipitem, shiphead WHERE ((shipitem.shipitem_shiphead_id = shiphead.shiphead_id) AND (shiphead.shiphead_order_type = 'SO'::text));
89531
 
 
89532
 
 
89533
 
ALTER TABLE public.coship OWNER TO admin;
89534
 
 
89535
 
--
89536
 
--
89537
 
 
89538
 
CREATE SEQUENCE coship_coship_id_seq
89539
 
    START WITH 1
89540
 
    INCREMENT BY 1
89541
 
    NO MINVALUE
89542
 
    MAXVALUE 2147483647
89543
 
    CACHE 1;
89544
 
 
89545
 
 
89546
 
ALTER TABLE public.coship_coship_id_seq OWNER TO admin;
89547
 
 
89548
 
--
89549
 
--
89550
 
 
89551
 
CREATE VIEW cosmisc AS
89552
 
    SELECT shiphead.shiphead_id AS cosmisc_id, shiphead.shiphead_order_id AS cosmisc_cohead_id, shiphead.shiphead_shipvia AS cosmisc_shipvia, shiphead.shiphead_freight AS cosmisc_freight, shiphead.shiphead_notes AS cosmisc_notes, shiphead.shiphead_shipdate AS cosmisc_shipdate, shiphead.shiphead_shipchrg_id AS cosmisc_shipchrg_id, shiphead.shiphead_shipform_id AS cosmisc_shipform_id, shiphead.shiphead_shipped AS cosmisc_shipped, shiphead.shiphead_sfstatus AS cosmisc_sfstatus, shiphead.shiphead_tracknum AS cosmisc_tracknum, shiphead.shiphead_number AS cosmisc_number FROM shiphead WHERE (shiphead.shiphead_order_type = 'SO'::text);
89553
 
 
89554
 
 
89555
 
ALTER TABLE public.cosmisc OWNER TO admin;
89556
 
 
89557
 
--
89558
 
--
89559
 
 
89560
 
CREATE SEQUENCE cosmisc_cosmisc_id_seq
89561
 
    START WITH 1
89562
 
    INCREMENT BY 1
89563
 
    NO MINVALUE
89564
 
    MAXVALUE 2147483647
89565
 
    CACHE 1;
89566
 
 
89567
 
 
89568
 
ALTER TABLE public.cosmisc_cosmisc_id_seq OWNER TO admin;
89569
 
 
89570
 
--
89571
 
--
89572
 
 
89573
 
CREATE SEQUENCE cosrc_cosrc_id_seq
89574
 
    START WITH 1
89575
 
    INCREMENT BY 1
89576
 
    NO MINVALUE
89577
 
    MAXVALUE 2147483647
89578
 
    CACHE 1;
89579
 
 
89580
 
 
89581
 
ALTER TABLE public.cosrc_cosrc_id_seq OWNER TO admin;
89582
 
 
89583
 
--
89584
 
--
89585
 
 
89586
 
CREATE SEQUENCE costcat_costcat_id_seq
89587
 
    START WITH 1
89588
 
    INCREMENT BY 1
89589
 
    NO MINVALUE
89590
 
    MAXVALUE 2147483647
89591
 
    CACHE 1;
89592
 
 
89593
 
 
89594
 
ALTER TABLE public.costcat_costcat_id_seq OWNER TO admin;
89595
 
 
89596
 
--
89597
 
--
89598
 
 
89599
 
CREATE SEQUENCE costelem_costelem_id_seq
89600
 
    START WITH 1
89601
 
    INCREMENT BY 1
89602
 
    NO MINVALUE
89603
 
    MAXVALUE 2147483647
89604
 
    CACHE 1;
89605
 
 
89606
 
 
89607
 
ALTER TABLE public.costelem_costelem_id_seq OWNER TO admin;
89608
 
 
89609
 
--
89610
 
--
89611
 
 
89612
 
CREATE TABLE costhist (
89613
 
    costhist_id integer DEFAULT nextval(('"costhist_costhist_id_seq"'::text)::regclass) NOT NULL,
89614
 
    costhist_item_id integer,
89615
 
    costhist_costelem_id integer,
89616
 
    costhist_type character(1),
89617
 
    costhist_date timestamp with time zone,
89618
 
    costhist_oldcost numeric(16,6),
89619
 
    costhist_newcost numeric(16,6),
89620
 
    costhist_lowlevel boolean,
89621
 
    costhist_oldcurr_id integer DEFAULT basecurrid(),
89622
 
    costhist_newcurr_id integer DEFAULT basecurrid(),
89623
 
    costhist_username text
89624
 
);
89625
 
 
89626
 
 
89627
 
ALTER TABLE public.costhist OWNER TO admin;
89628
 
 
89629
 
--
89630
 
--
89631
 
 
89632
 
COMMENT ON TABLE costhist IS 'Item Cost history';
89633
 
 
89634
 
 
89635
 
--
89636
 
--
89637
 
 
89638
 
CREATE SEQUENCE costhist_costhist_id_seq
89639
 
    START WITH 1
89640
 
    INCREMENT BY 1
89641
 
    NO MINVALUE
89642
 
    NO MAXVALUE
89643
 
    CACHE 1;
89644
 
 
89645
 
 
89646
 
ALTER TABLE public.costhist_costhist_id_seq OWNER TO admin;
89647
 
 
89648
 
--
89649
 
--
89650
 
 
89651
 
CREATE TABLE costupdate (
89652
 
    costupdate_item_id integer,
89653
 
    costupdate_lowlevel_code integer DEFAULT 1 NOT NULL,
89654
 
    costupdate_item_type character(1)
89655
 
);
89656
 
 
89657
 
 
89658
 
ALTER TABLE public.costupdate OWNER TO admin;
89659
 
 
89660
 
--
89661
 
--
89662
 
 
89663
 
COMMENT ON TABLE costupdate IS 'Scratch area for sequencing the updating of item costs';
89664
 
 
89665
 
 
89666
 
--
89667
 
--
89668
 
 
89669
 
CREATE TABLE country (
89670
 
    country_id integer NOT NULL,
89671
 
    country_abbr character(2),
89672
 
    country_name text,
89673
 
    country_curr_abbr character(3),
89674
 
    country_curr_name text,
89675
 
    country_curr_number character(3),
89676
 
    country_curr_symbol character varying(9),
89677
 
    country_qt_number integer,
89678
 
    CONSTRAINT country_country_abbr_check CHECK ((country_abbr <> ''::bpchar)),
89679
 
    CONSTRAINT country_country_name_check CHECK ((country_name <> ''::text))
89680
 
);
89681
 
 
89682
 
 
89683
 
ALTER TABLE public.country OWNER TO admin;
89684
 
 
89685
 
--
89686
 
--
89687
 
 
89688
 
COMMENT ON TABLE country IS 'Basic information and properties about countries.';
89689
 
 
89690
 
 
89691
 
--
89692
 
--
89693
 
 
89694
 
CREATE SEQUENCE country_country_id_seq
89695
 
    START WITH 1
89696
 
    INCREMENT BY 1
89697
 
    NO MINVALUE
89698
 
    NO MAXVALUE
89699
 
    CACHE 1;
89700
 
 
89701
 
 
89702
 
ALTER TABLE public.country_country_id_seq OWNER TO admin;
89703
 
 
89704
 
--
89705
 
--
89706
 
 
89707
 
ALTER SEQUENCE country_country_id_seq OWNED BY country.country_id;
89708
 
 
89709
 
 
89710
 
--
89711
 
--
89712
 
 
89713
 
CREATE TABLE salesaccnt (
89714
 
    salesaccnt_id integer DEFAULT nextval(('"salesaccnt_salesaccnt_id_seq"'::text)::regclass) NOT NULL,
89715
 
    salesaccnt_custtype_id integer,
89716
 
    salesaccnt_prodcat_id integer,
89717
 
    salesaccnt_warehous_id integer,
89718
 
    salesaccnt_sales_accnt_id integer,
89719
 
    salesaccnt_credit_accnt_id integer,
89720
 
    salesaccnt_cos_accnt_id integer,
89721
 
    salesaccnt_custtype text,
89722
 
    salesaccnt_prodcat text,
89723
 
    salesaccnt_returns_accnt_id integer,
89724
 
    salesaccnt_cor_accnt_id integer,
89725
 
    salesaccnt_cow_accnt_id integer,
89726
 
    salesaccnt_saletype_id integer,
89727
 
    salesaccnt_shipzone_id integer
89728
 
);
89729
 
 
89730
 
 
89731
 
ALTER TABLE public.salesaccnt OWNER TO admin;
89732
 
 
89733
 
--
89734
 
--
89735
 
 
89736
 
COMMENT ON TABLE salesaccnt IS 'Sales Account assignment information';
89737
 
 
89738
 
 
89739
 
--
89740
 
--
89741
 
 
89742
 
COMMENT ON COLUMN salesaccnt.salesaccnt_saletype_id IS 'Associated sale type for sales account.';
89743
 
 
89744
 
 
89745
 
--
89746
 
--
89747
 
 
89748
 
COMMENT ON COLUMN salesaccnt.salesaccnt_shipzone_id IS 'Associated shipping zone for sales account.';
89749
 
 
89750
 
 
89751
 
--
89752
 
--
89753
 
 
89754
 
CREATE VIEW creditmemoeditlist AS
89755
 
    ((((SELECT cmhead.cmhead_id AS orderid, (-2) AS itemid, ('C/M-'::text || formatcreditmemonumber(cmhead.cmhead_id)) AS documentnumber, custinfo.cust_number, cmhead.cmhead_billtoname AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, ''::text AS item, ''::text AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, ''::text AS price, formatmoney((((calccmheadamt(cmhead.cmhead_id) + cmhead.cmhead_freight) + cmhead.cmhead_misc) + calccmheadtax(cmhead.cmhead_id))) AS extprice, 'Credit'::text AS sence, COALESCE((SELECT formatglaccountlong(accnt.accnt_id) AS formatglaccountlong FROM accnt WHERE (accnt.accnt_id = findaraccount(custinfo.cust_id))), 'Not Assigned'::text) AS account FROM custinfo, cmhead WHERE ((((cmhead.cmhead_cust_id = custinfo.cust_id) AND (cmhead.cmhead_cust_id = custinfo.cust_id)) AND (NOT cmhead.cmhead_posted)) AND (NOT cmhead.cmhead_hold)) UNION SELECT cmhead.cmhead_id AS orderid, (-1) AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, 'Freight'::text AS item, 'Freight Charge'::text AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, formatmoney(cmhead.cmhead_freight) AS price, formatmoney(cmhead.cmhead_freight) AS extprice, 'Debit'::text AS sence, CASE WHEN (accnt.accnt_id IS NULL) THEN 'Not Assigned'::text ELSE formatglaccountlong(accnt.accnt_id) END AS account FROM (cmhead LEFT JOIN accnt ON ((accnt.accnt_id = findfreightaccount(cmhead.cmhead_cust_id)))) WHERE (((NOT cmhead.cmhead_posted) AND (NOT cmhead.cmhead_hold)) AND (cmhead.cmhead_freight <> (0)::numeric))) UNION SELECT cmhead.cmhead_id AS orderid, (-1) AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, 'Misc. Charge'::text AS item, cmhead.cmhead_misc_descrip AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, formatmoney(cmhead.cmhead_misc) AS price, formatmoney(cmhead.cmhead_misc) AS extprice, 'Debit'::text AS sence, formatglaccountlong(cmhead.cmhead_misc_accnt_id) AS account FROM cmhead WHERE (((NOT cmhead.cmhead_posted) AND (NOT cmhead.cmhead_hold)) AND (cmhead.cmhead_misc <> (0)::numeric))) UNION SELECT cmhead.cmhead_id AS orderid, (-1) AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, 'Sales Tax'::text AS item, tax.tax_descrip AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, formatmoney((cmheadtax.taxhist_tax * (-1.0))) AS price, formatmoney((cmheadtax.taxhist_tax * (-1.0))) AS extprice, 'Debit'::text AS sence, CASE WHEN (accnt.accnt_id IS NULL) THEN 'Not Assigned'::text ELSE ((formatglaccountlong(accnt.accnt_id) || ' - '::text) || accnt.accnt_descrip) END AS account FROM (((cmhead JOIN cmheadtax ON ((cmheadtax.taxhist_parent_id = cmhead.cmhead_id))) JOIN tax ON ((tax.tax_id = cmheadtax.taxhist_tax_id))) LEFT JOIN accnt ON ((accnt.accnt_id = tax.tax_sales_accnt_id))) WHERE ((NOT cmhead.cmhead_posted) AND (NOT cmhead.cmhead_hold))) UNION SELECT cmhead.cmhead_id AS orderid, (-1) AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, 'Sales Tax'::text AS item, tax.tax_descrip AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, formatmoney((cmitemtax.taxhist_tax * (-1.0))) AS price, formatmoney((cmitemtax.taxhist_tax * (-1.0))) AS extprice, 'Debit'::text AS sence, CASE WHEN (accnt.accnt_id IS NULL) THEN 'Not Assigned'::text ELSE ((formatglaccountlong(accnt.accnt_id) || ' - '::text) || accnt.accnt_descrip) END AS account FROM ((((cmhead JOIN cmitem ON ((cmitem.cmitem_cmhead_id = cmhead.cmhead_id))) JOIN cmitemtax ON ((cmitemtax.taxhist_parent_id = cmitem.cmitem_id))) JOIN tax ON ((tax.tax_id = cmitemtax.taxhist_tax_id))) LEFT JOIN accnt ON ((accnt.accnt_id = tax.tax_sales_accnt_id))) WHERE ((NOT cmhead.cmhead_posted) AND (NOT cmhead.cmhead_hold))) UNION SELECT cmhead.cmhead_id AS orderid, cmitem.cmitem_id AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, cmitem.cmitem_linenumber AS linenumber, item.item_number AS item, item.item_descrip1 AS itemdescrip, uom.uom_name AS iteminvuom, formatqty(COALESCE((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio), (0)::numeric)) AS qtytobill, formatprice(COALESCE((cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio), (0)::numeric)) AS price, formatmoney(COALESCE(round(((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio) * (cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio)), 2), (0)::numeric)) AS extprice, 'Debit'::text AS sence, COALESCE((SELECT formatglaccountlong(accnt.accnt_id) AS formatglaccountlong FROM accnt, salesaccnt WHERE ((salesaccnt.salesaccnt_sales_accnt_id = accnt.accnt_id) AND (salesaccnt.salesaccnt_id = findsalesaccnt(cmitem.cmitem_itemsite_id, 'IS'::text, cmhead.cmhead_cust_id, cmhead.cmhead_saletype_id, cmhead.cmhead_shipzone_id)))), 'Not Assigned'::text) AS account FROM item, itemsite, cmhead, cmitem, uom WHERE ((((((cmitem.cmitem_cmhead_id = cmhead.cmhead_id) AND (cmitem.cmitem_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (item.item_inv_uom_id = uom.uom_id)) AND (NOT cmhead.cmhead_posted)) AND (NOT cmhead.cmhead_hold)) ORDER BY 6, 7;
89756
 
 
89757
 
 
89758
 
ALTER TABLE public.creditmemoeditlist OWNER TO admin;
89759
 
 
89760
 
--
89761
 
--
89762
 
 
89763
 
CREATE VIEW creditmemoitem AS
89764
 
    SELECT cmitem.cmitem_id, cmitem.cmitem_cmhead_id, cmitem.cmitem_linenumber, cmitem.cmitem_itemsite_id, cmitem.cmitem_qtycredit, cmitem.cmitem_qtyreturned, cmitem.cmitem_unitprice, cmitem.cmitem_comments, cmitem.cmitem_rsncode_id, cmitem.cmitem_taxtype_id, cmitem.cmitem_qty_uom_id, cmitem.cmitem_qty_invuomratio, cmitem.cmitem_price_uom_id, cmitem.cmitem_price_invuomratio, cmitem.cmitem_raitem_id, cmitem.cmitem_updateinv, itemsite.itemsite_item_id AS item_id, COALESCE((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio), (0)::numeric) AS qty, COALESCE((cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio), (0)::numeric) AS unitprice, COALESCE(round(((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio) * (cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio)), 2), (0)::numeric) AS extprice, currtobase(cmhead.cmhead_curr_id, COALESCE(round(((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio) * (cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio)), 2), (0)::numeric), cmhead.cmhead_docdate) AS baseextprice, (SELECT COALESCE(sum(cmitemtax.taxhist_tax), (0)::numeric) AS "coalesce" FROM cmitemtax WHERE (cmitemtax.taxhist_parent_id = cmitem.cmitem_id)) AS tax, CASE WHEN (itemsite.itemsite_costmethod = 'A'::bpchar) THEN avgcost(itemsite.itemsite_id) ELSE stdcost(itemsite.itemsite_item_id) END AS unitcost FROM ((cmitem JOIN cmhead ON ((cmhead.cmhead_id = cmitem.cmitem_cmhead_id))) LEFT JOIN itemsite ON ((itemsite.itemsite_id = cmitem.cmitem_itemsite_id)));
89765
 
 
89766
 
 
89767
 
ALTER TABLE public.creditmemoitem OWNER TO admin;
89768
 
 
89769
 
--
89770
 
--
89771
 
 
89772
 
COMMENT ON VIEW creditmemoitem IS 'Single point for credit memo item (cmitem) calculations.';
89773
 
 
89774
 
 
89775
 
--
89776
 
--
89777
 
 
89778
 
CREATE SEQUENCE crmacct_crmacct_id_seq
89779
 
    START WITH 1
89780
 
    INCREMENT BY 1
89781
 
    NO MINVALUE
89782
 
    NO MAXVALUE
89783
 
    CACHE 1;
89784
 
 
89785
 
 
89786
 
ALTER TABLE public.crmacct_crmacct_id_seq OWNER TO admin;
89787
 
 
89788
 
--
89789
 
--
89790
 
 
89791
 
ALTER SEQUENCE crmacct_crmacct_id_seq OWNED BY crmacct.crmacct_id;
89792
 
 
89793
 
 
89794
 
--
89795
 
--
89796
 
 
89797
 
CREATE TABLE crmacctsel (
89798
 
    crmacctsel_src_crmacct_id integer NOT NULL,
89799
 
    crmacctsel_dest_crmacct_id integer,
89800
 
    crmacctsel_mrg_crmacct_active boolean DEFAULT false NOT NULL,
89801
 
    crmacctsel_mrg_crmacct_cntct_id_1 boolean DEFAULT false NOT NULL,
89802
 
    crmacctsel_mrg_crmacct_cntct_id_2 boolean DEFAULT false NOT NULL,
89803
 
    crmacctsel_mrg_crmacct_competitor_id boolean DEFAULT false NOT NULL,
89804
 
    crmacctsel_mrg_crmacct_cust_id boolean DEFAULT false NOT NULL,
89805
 
    crmacctsel_mrg_crmacct_emp_id boolean DEFAULT false NOT NULL,
89806
 
    crmacctsel_mrg_crmacct_name boolean DEFAULT false NOT NULL,
89807
 
    crmacctsel_mrg_crmacct_notes boolean DEFAULT false NOT NULL,
89808
 
    crmacctsel_mrg_crmacct_owner_username boolean DEFAULT false NOT NULL,
89809
 
    crmacctsel_mrg_crmacct_parent_id boolean DEFAULT false NOT NULL,
89810
 
    crmacctsel_mrg_crmacct_partner_id boolean DEFAULT false NOT NULL,
89811
 
    crmacctsel_mrg_crmacct_prospect_id boolean DEFAULT false NOT NULL,
89812
 
    crmacctsel_mrg_crmacct_salesrep_id boolean DEFAULT false NOT NULL,
89813
 
    crmacctsel_mrg_crmacct_taxauth_id boolean DEFAULT false NOT NULL,
89814
 
    crmacctsel_mrg_crmacct_type boolean DEFAULT false NOT NULL,
89815
 
    crmacctsel_mrg_crmacct_usr_username boolean DEFAULT false NOT NULL,
89816
 
    crmacctsel_mrg_crmacct_vend_id boolean DEFAULT false NOT NULL,
89817
 
    crmacctsel_mrg_crmacct_number boolean DEFAULT false NOT NULL
89818
 
);
89819
 
 
89820
 
 
89821
 
ALTER TABLE public.crmacctsel OWNER TO admin;
89822
 
 
89823
 
--
89824
 
--
89825
 
 
89826
 
COMMENT ON TABLE crmacctsel IS 'This table records the proposed conditions of a CRM Account merge. When this merge is performed, the BOOLEAN columns in this table indicate which values in the crmacct table will be copied to the target record. Data in this table are temporary and will be removed by a purge.';
89827
 
 
89828
 
 
89829
 
--
89830
 
--
89831
 
 
89832
 
COMMENT ON COLUMN crmacctsel.crmacctsel_src_crmacct_id IS 'This is the internal ID of the CRM Account record the data will come from during the merge.';
89833
 
 
89834
 
 
89835
 
--
89836
 
--
89837
 
 
89838
 
COMMENT ON COLUMN crmacctsel.crmacctsel_dest_crmacct_id IS 'This is the internal ID of the CRM Account record the data will go to during the merge. If crmacctsel_src_crmacct_id = crmacctsel_dest_crmacct_id, they indicate which crmacct record is the destination of the merge, meaning this is the record that will remain in the database after the merge has been completed and the intermediate data have been purged.';
89839
 
 
89840
 
 
89841
 
--
89842
 
--
89843
 
 
89844
 
CREATE TABLE curr_rate (
89845
 
    curr_rate_id integer NOT NULL,
89846
 
    curr_id integer NOT NULL,
89847
 
    curr_rate numeric(16,8) NOT NULL,
89848
 
    curr_effective date NOT NULL,
89849
 
    curr_expires date NOT NULL,
89850
 
    CONSTRAINT curr_rate_curr_rate_check CHECK ((curr_rate > (0)::numeric))
89851
 
);
89852
 
 
89853
 
 
89854
 
ALTER TABLE public.curr_rate OWNER TO admin;
89855
 
 
89856
 
--
89857
 
--
89858
 
 
89859
 
COMMENT ON TABLE curr_rate IS 'Exchange Rates Between Base and Foreign Currencies';
89860
 
 
89861
 
 
89862
 
--
89863
 
--
89864
 
 
89865
 
CREATE SEQUENCE curr_rate_curr_rate_id_seq
89866
 
    START WITH 1
89867
 
    INCREMENT BY 1
89868
 
    NO MINVALUE
89869
 
    NO MAXVALUE
89870
 
    CACHE 1;
89871
 
 
89872
 
 
89873
 
ALTER TABLE public.curr_rate_curr_rate_id_seq OWNER TO admin;
89874
 
 
89875
 
--
89876
 
--
89877
 
 
89878
 
ALTER SEQUENCE curr_rate_curr_rate_id_seq OWNED BY curr_rate.curr_rate_id;
89879
 
 
89880
 
 
89881
 
--
89882
 
--
89883
 
 
89884
 
CREATE SEQUENCE curr_symbol_curr_id_seq
89885
 
    START WITH 1
89886
 
    INCREMENT BY 1
89887
 
    NO MINVALUE
89888
 
    NO MAXVALUE
89889
 
    CACHE 1;
89890
 
 
89891
 
 
89892
 
ALTER TABLE public.curr_symbol_curr_id_seq OWNER TO admin;
89893
 
 
89894
 
--
89895
 
--
89896
 
 
89897
 
ALTER SEQUENCE curr_symbol_curr_id_seq OWNED BY curr_symbol.curr_id;
89898
 
 
89899
 
 
89900
 
--
89901
 
--
89902
 
 
89903
 
CREATE VIEW cust AS
89904
 
    SELECT custinfo.cust_id, custinfo.cust_active, custinfo.cust_custtype_id, custinfo.cust_salesrep_id, custinfo.cust_commprcnt, custinfo.cust_name, m.addr_line1 AS cust_address1, m.addr_line2 AS cust_address2, m.addr_line3 AS cust_address3, m.addr_city AS cust_city, m.addr_state AS cust_state, m.addr_postalcode AS cust_zipcode, btrim(((mc.cntct_first_name || ' '::text) || mc.cntct_last_name)) AS cust_contact, mc.cntct_phone AS cust_phone, mc.cntct_fax AS cust_fax, mc.cntct_email AS cust_email, c.addr_line1 AS cust_corraddress1, c.addr_line2 AS cust_corraddress2, c.addr_line3 AS cust_corraddress3, c.addr_city AS cust_corrcity, c.addr_state AS cust_corrstate, c.addr_postalcode AS cust_corrzipcode, btrim(((cc.cntct_first_name || ' '::text) || cc.cntct_last_name)) AS cust_corrcontact, cc.cntct_phone AS cust_corrphone, cc.cntct_fax AS cust_corrfax, cc.cntct_email AS cust_corremail, custinfo.cust_creditlmt, custinfo.cust_creditrating, custinfo.cust_financecharge, custinfo.cust_backorder, custinfo.cust_partialship, custinfo.cust_terms_id, custinfo.cust_discntprcnt, custinfo.cust_taxzone_id, custinfo.cust_balmethod, custinfo.cust_ffshipto, custinfo.cust_shipform_id, custinfo.cust_shipvia, custinfo.cust_blanketpos, custinfo.cust_shipchrg_id, custinfo.cust_creditstatus, custinfo.cust_comments, custinfo.cust_ffbillto, m.addr_country AS cust_country, c.addr_country AS cust_corrcountry, custinfo.cust_usespos, custinfo.cust_number, custinfo.cust_dateadded, custinfo.cust_exported, custinfo.cust_emaildelivery, custinfo.cust_ediemail, custinfo.cust_edisubject, custinfo.cust_edifilename, custinfo.cust_ediemailbody, custinfo.cust_autoupdatestatus, custinfo.cust_autoholdorders, custinfo.cust_edicc, custinfo.cust_ediprofile_id, custinfo.cust_preferred_warehous_id, custinfo.cust_curr_id, custinfo.cust_creditlmt_curr_id FROM ((((custinfo LEFT JOIN cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN cntct cc ON ((custinfo.cust_corrcntct_id = cc.cntct_id))) LEFT JOIN addr c ON ((cc.cntct_addr_id = c.addr_id)));
89905
 
 
89906
 
 
89907
 
ALTER TABLE public.cust OWNER TO admin;
89908
 
 
89909
 
--
89910
 
--
89911
 
 
89912
 
CREATE SEQUENCE cust_serial_seq
89913
 
    START WITH 1
89914
 
    INCREMENT BY 1
89915
 
    NO MINVALUE
89916
 
    MAXVALUE 2147483647
89917
 
    CACHE 1;
89918
 
 
89919
 
 
89920
 
ALTER TABLE public.cust_serial_seq OWNER TO admin;
89921
 
 
89922
 
--
89923
 
--
89924
 
 
89925
 
CREATE TABLE custform (
89926
 
    custform_id integer DEFAULT nextval(('"custform_custform_id_seq"'::text)::regclass) NOT NULL,
89927
 
    custform_custtype_id integer,
89928
 
    custform_custtype text,
89929
 
    custform_invoice_report_id integer,
89930
 
    custform_creditmemo_report_id integer,
89931
 
    custform_quote_report_id integer,
89932
 
    custform_packinglist_report_id integer,
89933
 
    custform_statement_report_id integer,
89934
 
    custform_sopicklist_report_id integer,
89935
 
    custform_invoice_report_name text,
89936
 
    custform_creditmemo_report_name text,
89937
 
    custform_quote_report_name text,
89938
 
    custform_packinglist_report_name text,
89939
 
    custform_statement_report_name text,
89940
 
    custform_sopicklist_report_name text
89941
 
);
89942
 
 
89943
 
 
89944
 
ALTER TABLE public.custform OWNER TO admin;
89945
 
 
89946
 
--
89947
 
--
89948
 
 
89949
 
COMMENT ON TABLE custform IS 'Customer Form assignment information';
89950
 
 
89951
 
 
89952
 
--
89953
 
--
89954
 
 
89955
 
COMMENT ON COLUMN custform.custform_invoice_report_id IS 'Obsolete -- reference custform_invoice_report_name instead.';
89956
 
 
89957
 
 
89958
 
--
89959
 
--
89960
 
 
89961
 
COMMENT ON COLUMN custform.custform_creditmemo_report_id IS 'Obsolete -- reference custform_creditmemo_report_name instead.';
89962
 
 
89963
 
 
89964
 
--
89965
 
--
89966
 
 
89967
 
COMMENT ON COLUMN custform.custform_quote_report_id IS 'Obsolete -- reference custform_quote_report_name instead.';
89968
 
 
89969
 
 
89970
 
--
89971
 
--
89972
 
 
89973
 
COMMENT ON COLUMN custform.custform_packinglist_report_id IS 'Obsolete -- reference custform_packinglist_report_name instead.';
89974
 
 
89975
 
 
89976
 
--
89977
 
--
89978
 
 
89979
 
COMMENT ON COLUMN custform.custform_statement_report_id IS 'Obsolete -- reference custform_statement_report_name instead.';
89980
 
 
89981
 
 
89982
 
--
89983
 
--
89984
 
 
89985
 
COMMENT ON COLUMN custform.custform_sopicklist_report_id IS 'Obsolete -- reference custform_sopicklist_report_name instead.';
89986
 
 
89987
 
 
89988
 
--
89989
 
--
89990
 
 
89991
 
CREATE SEQUENCE custform_custform_id_seq
89992
 
    START WITH 1
89993
 
    INCREMENT BY 1
89994
 
    NO MINVALUE
89995
 
    NO MAXVALUE
89996
 
    CACHE 1;
89997
 
 
89998
 
 
89999
 
ALTER TABLE public.custform_custform_id_seq OWNER TO admin;
90000
 
 
90001
 
--
90002
 
--
90003
 
 
90004
 
CREATE TABLE custgrp (
90005
 
    custgrp_id integer DEFAULT nextval(('"custgrp_custgrp_id_seq"'::text)::regclass) NOT NULL,
90006
 
    custgrp_name text NOT NULL,
90007
 
    custgrp_descrip text,
90008
 
    CONSTRAINT custgrp_custgrp_name_check CHECK ((custgrp_name <> ''::text))
90009
 
);
90010
 
 
90011
 
 
90012
 
ALTER TABLE public.custgrp OWNER TO admin;
90013
 
 
90014
 
--
90015
 
--
90016
 
 
90017
 
COMMENT ON TABLE custgrp IS 'Customer Group information';
90018
 
 
90019
 
 
90020
 
--
90021
 
--
90022
 
 
90023
 
CREATE SEQUENCE custgrp_custgrp_id_seq
90024
 
    START WITH 1
90025
 
    INCREMENT BY 1
90026
 
    NO MINVALUE
90027
 
    NO MAXVALUE
90028
 
    CACHE 1;
90029
 
 
90030
 
 
90031
 
ALTER TABLE public.custgrp_custgrp_id_seq OWNER TO admin;
90032
 
 
90033
 
--
90034
 
--
90035
 
 
90036
 
CREATE TABLE custgrpitem (
90037
 
    custgrpitem_id integer DEFAULT nextval(('"custgrpitem_custgrpitem_id_seq"'::text)::regclass) NOT NULL,
90038
 
    custgrpitem_custgrp_id integer,
90039
 
    custgrpitem_cust_id integer
90040
 
);
90041
 
 
90042
 
 
90043
 
ALTER TABLE public.custgrpitem OWNER TO admin;
90044
 
 
90045
 
--
90046
 
--
90047
 
 
90048
 
COMMENT ON TABLE custgrpitem IS 'Customer Group Item information';
90049
 
 
90050
 
 
90051
 
--
90052
 
--
90053
 
 
90054
 
CREATE SEQUENCE custgrpitem_custgrpitem_id_seq
90055
 
    START WITH 1
90056
 
    INCREMENT BY 1
90057
 
    NO MINVALUE
90058
 
    NO MAXVALUE
90059
 
    CACHE 1;
90060
 
 
90061
 
 
90062
 
ALTER TABLE public.custgrpitem_custgrpitem_id_seq OWNER TO admin;
90063
 
 
90064
 
--
90065
 
--
90066
 
 
90067
 
CREATE SEQUENCE custtype_custtype_id_seq
90068
 
    START WITH 1
90069
 
    INCREMENT BY 1
90070
 
    NO MINVALUE
90071
 
    MAXVALUE 2147483647
90072
 
    CACHE 1;
90073
 
 
90074
 
 
90075
 
ALTER TABLE public.custtype_custtype_id_seq OWNER TO admin;
90076
 
 
90077
 
--
90078
 
--
90079
 
 
90080
 
CREATE SEQUENCE dept_dept_id_seq
90081
 
    START WITH 1
90082
 
    INCREMENT BY 1
90083
 
    NO MINVALUE
90084
 
    NO MAXVALUE
90085
 
    CACHE 1;
90086
 
 
90087
 
 
90088
 
ALTER TABLE public.dept_dept_id_seq OWNER TO admin;
90089
 
 
90090
 
--
90091
 
--
90092
 
 
90093
 
ALTER SEQUENCE dept_dept_id_seq OWNED BY dept.dept_id;
90094
 
 
90095
 
 
90096
 
--
90097
 
--
90098
 
 
90099
 
CREATE TABLE destination (
90100
 
    destination_id integer DEFAULT nextval(('"destination_destination_id_seq"'::text)::regclass) NOT NULL,
90101
 
    destination_name text,
90102
 
    destination_city text,
90103
 
    destination_state text,
90104
 
    destination_comments text
90105
 
);
90106
 
 
90107
 
 
90108
 
ALTER TABLE public.destination OWNER TO admin;
90109
 
 
90110
 
--
90111
 
--
90112
 
 
90113
 
COMMENT ON TABLE destination IS 'Destination information';
90114
 
 
90115
 
 
90116
 
--
90117
 
--
90118
 
 
90119
 
CREATE SEQUENCE destination_destination_id_seq
90120
 
    START WITH 1
90121
 
    INCREMENT BY 1
90122
 
    NO MINVALUE
90123
 
    MAXVALUE 2147483647
90124
 
    CACHE 1;
90125
 
 
90126
 
 
90127
 
ALTER TABLE public.destination_destination_id_seq OWNER TO admin;
90128
 
 
90129
 
--
90130
 
--
90131
 
 
90132
 
CREATE TABLE wo (
90133
 
    wo_id integer DEFAULT nextval(('wo_wo_id_seq'::text)::regclass) NOT NULL,
90134
 
    wo_number integer,
90135
 
    wo_subnumber integer,
90136
 
    wo_status character(1),
90137
 
    wo_itemsite_id integer,
90138
 
    wo_startdate date,
90139
 
    wo_duedate date,
90140
 
    wo_ordtype character(1),
90141
 
    wo_ordid integer,
90142
 
    wo_qtyord numeric(18,6),
90143
 
    wo_qtyrcv numeric(18,6),
90144
 
    wo_adhoc boolean,
90145
 
    wo_itemcfg_series integer,
90146
 
    wo_imported boolean,
90147
 
    wo_wipvalue numeric(16,6) DEFAULT 0,
90148
 
    wo_postedvalue numeric(16,6) DEFAULT 0,
90149
 
    wo_prodnotes text,
90150
 
    wo_prj_id integer,
90151
 
    wo_priority integer DEFAULT 1 NOT NULL,
90152
 
    wo_brdvalue numeric(16,6) DEFAULT 0,
90153
 
    wo_bom_rev_id integer DEFAULT (-1),
90154
 
    wo_boo_rev_id integer DEFAULT (-1),
90155
 
    wo_cosmethod character(1),
90156
 
    wo_womatl_id integer,
90157
 
    wo_username text DEFAULT geteffectivextuser(),
90158
 
    CONSTRAINT chk_wo_cosmethod CHECK ((((wo_cosmethod = NULL::bpchar) OR (wo_cosmethod = 'D'::bpchar)) OR (wo_cosmethod = 'P'::bpchar)))
90159
 
);
90160
 
 
90161
 
 
90162
 
ALTER TABLE public.wo OWNER TO admin;
90163
 
 
90164
 
--
90165
 
--
90166
 
 
90167
 
COMMENT ON TABLE wo IS 'Work Order information';
90168
 
 
90169
 
 
90170
 
--
90171
 
--
90172
 
 
90173
 
CREATE VIEW docinfo AS
90174
 
    (((((((((((((((((((((((((((((((SELECT imageass.imageass_id AS id, (image.image_id)::text AS target_number, 'IMG'::text AS target_type, imageass.imageass_image_id AS target_id, imageass.imageass_source AS source_type, imageass.imageass_source_id AS source_id, image.image_name AS name, image.image_descrip AS description, imageass.imageass_purpose AS purpose FROM imageass, image WHERE (imageass.imageass_image_id = image.image_id) UNION ALL SELECT url.url_id AS id, (url.url_id)::text AS target_number, 'URL'::text AS target_type, url.url_id AS target_id, url.url_source AS source_type, url.url_source_id AS source_id, url.url_title AS name, url.url_url AS description, 'S'::bpchar AS purpose FROM url WHERE (url.url_stream IS NULL)) UNION ALL SELECT url.url_id AS id, (url.url_id)::text AS target_number, 'FILE'::text AS target_type, url.url_id AS target_id, url.url_source AS source_type, url.url_source_id AS source_id, url.url_title AS name, url.url_url AS description, 'S'::bpchar AS purpose FROM url WHERE (url.url_stream IS NOT NULL)) UNION ALL SELECT docass.docass_id AS id, (incdt.incdt_number)::text AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, incdt.incdt_summary AS name, firstline(incdt.incdt_descrip) AS description, docass.docass_purpose AS purpose FROM docass, incdt WHERE ((docass.docass_target_type = 'INCDT'::text) AND (docass.docass_target_id = incdt.incdt_id))) UNION ALL SELECT docass.docass_id AS id, (incdt.incdt_number)::text AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, incdt.incdt_summary AS name, firstline(incdt.incdt_descrip) AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, incdt WHERE ((docass.docass_source_type = 'INCDT'::text) AND (docass.docass_source_id = incdt.incdt_id))) UNION ALL SELECT docass.docass_id AS id, (todoitem.todoitem_id)::text AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, todoitem.todoitem_name AS name, firstline(todoitem.todoitem_description) AS description, docass.docass_purpose AS purpose FROM docass, todoitem WHERE ((docass.docass_target_type = 'TODO'::text) AND (docass.docass_target_id = todoitem.todoitem_id))) UNION ALL SELECT docass.docass_id AS id, (todoitem.todoitem_id)::text AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, todoitem.todoitem_name AS name, firstline(todoitem.todoitem_description) AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, todoitem WHERE ((docass.docass_source_type = 'TODO'::text) AND (docass.docass_source_id = todoitem.todoitem_id))) UNION ALL SELECT docass.docass_id AS id, prj.prj_number AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, prj.prj_name AS name, firstline(prj.prj_descrip) AS description, docass.docass_purpose AS purpose FROM docass, prj WHERE ((docass.docass_target_type = 'J'::text) AND (docass.docass_target_id = prj.prj_id))) UNION ALL SELECT docass.docass_id AS id, prj.prj_number AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, prj.prj_name AS name, firstline(prj.prj_descrip) AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, prj WHERE ((docass.docass_source_type = 'J'::text) AND (docass.docass_source_id = prj.prj_id))) UNION ALL SELECT docass.docass_id AS id, item.item_number AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, firstline(item.item_descrip1) AS name, firstline(item.item_descrip2) AS description, docass.docass_purpose AS purpose FROM docass, item WHERE ((docass.docass_target_type = 'I'::text) AND (docass.docass_target_id = item.item_id))) UNION ALL SELECT docass.docass_id AS id, item.item_number AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, firstline(item.item_descrip1) AS name, firstline(item.item_descrip2) AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, item WHERE ((docass.docass_source_type = 'I'::text) AND (docass.docass_source_id = item.item_id))) UNION ALL SELECT docass.docass_id AS id, crmacct.crmacct_number AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, crmacct.crmacct_name AS name, firstline(crmacct.crmacct_notes) AS description, docass.docass_purpose AS purpose FROM docass, crmacct WHERE ((docass.docass_target_type = 'CRMA'::text) AND (docass.docass_target_id = crmacct.crmacct_id))) UNION ALL SELECT docass.docass_id AS id, crmacct.crmacct_number AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, crmacct.crmacct_name AS name, firstline(crmacct.crmacct_notes) AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, crmacct WHERE ((docass.docass_source_type = 'CRMA'::text) AND (docass.docass_source_id = crmacct.crmacct_id))) UNION SELECT docass.docass_id AS id, custinfo.cust_number AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, custinfo.cust_name AS name, firstline(custinfo.cust_comments) AS description, docass.docass_purpose AS purpose FROM docass, custinfo WHERE ((docass.docass_target_type = 'C'::text) AND (docass.docass_target_id = custinfo.cust_id))) UNION ALL SELECT docass.docass_id AS id, custinfo.cust_number AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, custinfo.cust_name AS name, firstline(custinfo.cust_comments) AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, custinfo WHERE ((docass.docass_source_type = 'C'::text) AND (docass.docass_source_id = custinfo.cust_id))) UNION ALL SELECT docass.docass_id AS id, vendinfo.vend_number AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, vendinfo.vend_name AS name, firstline(vendinfo.vend_comments) AS description, docass.docass_purpose AS purpose FROM docass, vendinfo WHERE ((docass.docass_target_type = 'V'::text) AND (docass.docass_target_id = vendinfo.vend_id))) UNION ALL SELECT docass.docass_id AS id, vendinfo.vend_number AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, vendinfo.vend_name AS name, firstline(vendinfo.vend_comments) AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, vendinfo WHERE ((docass.docass_source_type = 'V'::text) AND (docass.docass_source_id = vendinfo.vend_id))) UNION ALL SELECT docass.docass_id AS id, cntct.cntct_number AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, cntct.cntct_name AS name, cntct.cntct_title AS description, docass.docass_purpose AS purpose FROM docass, cntct WHERE ((docass.docass_target_type = 'T'::text) AND (docass.docass_target_id = cntct.cntct_id))) UNION ALL SELECT docass.docass_id AS id, cntct.cntct_number AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, cntct.cntct_name AS name, cntct.cntct_title AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, cntct WHERE ((docass.docass_source_type = 'T'::text) AND (docass.docass_source_id = cntct.cntct_id))) UNION ALL SELECT docass.docass_id AS id, (ophead.ophead_id)::text AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, ophead.ophead_name AS name, firstline(ophead.ophead_notes) AS description, docass.docass_purpose AS purpose FROM docass, ophead WHERE ((docass.docass_target_type = 'OPP'::text) AND (docass.docass_target_id = ophead.ophead_id))) UNION ALL SELECT docass.docass_id AS id, (ophead.ophead_id)::text AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, ophead.ophead_name AS name, firstline(ophead.ophead_notes) AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, ophead WHERE ((docass.docass_source_type = 'OPP'::text) AND (docass.docass_source_id = ophead.ophead_id))) UNION ALL SELECT docass.docass_id AS id, quhead.quhead_number AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, custinfo.cust_name AS name, firstline(quhead.quhead_ordercomments) AS description, docass.docass_purpose AS purpose FROM docass, quhead, custinfo WHERE (((docass.docass_target_type = 'Q'::text) AND (docass.docass_target_id = quhead.quhead_id)) AND (custinfo.cust_id = quhead.quhead_cust_id))) UNION ALL SELECT docass.docass_id AS id, quhead.quhead_number AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, custinfo.cust_name AS name, firstline(quhead.quhead_ordercomments) AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, quhead, custinfo WHERE (((docass.docass_source_type = 'Q'::text) AND (docass.docass_source_id = quhead.quhead_id)) AND (custinfo.cust_id = quhead.quhead_cust_id))) UNION ALL SELECT docass.docass_id AS id, cohead.cohead_number AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, custinfo.cust_name AS name, firstline(cohead.cohead_ordercomments) AS description, docass.docass_purpose AS purpose FROM docass, cohead, custinfo WHERE (((docass.docass_target_type = 'S'::text) AND (docass.docass_target_id = cohead.cohead_id)) AND (custinfo.cust_id = cohead.cohead_cust_id))) UNION ALL SELECT docass.docass_id AS id, cohead.cohead_number AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, custinfo.cust_name AS name, firstline(cohead.cohead_ordercomments) AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, cohead, custinfo WHERE (((docass.docass_source_type = 'S'::text) AND (docass.docass_source_id = cohead.cohead_id)) AND (custinfo.cust_id = cohead.cohead_cust_id))) UNION ALL SELECT docass.docass_id AS id, invchead.invchead_invcnumber AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, custinfo.cust_name AS name, firstline(invchead.invchead_notes) AS description, docass.docass_purpose AS purpose FROM docass, invchead, custinfo WHERE (((docass.docass_target_type = 'INV'::text) AND (docass.docass_target_id = invchead.invchead_id)) AND (custinfo.cust_id = invchead.invchead_cust_id))) UNION ALL SELECT docass.docass_id AS id, invchead.invchead_invcnumber AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, custinfo.cust_name AS name, firstline(invchead.invchead_notes) AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, invchead, custinfo WHERE (((docass.docass_source_type = 'INV'::text) AND (docass.docass_source_id = invchead.invchead_id)) AND (custinfo.cust_id = invchead.invchead_cust_id))) UNION ALL SELECT docass.docass_id AS id, pohead.pohead_number AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, vendinfo.vend_name AS name, firstline(pohead.pohead_comments) AS description, docass.docass_purpose AS purpose FROM docass, pohead, vendinfo WHERE (((docass.docass_target_type = 'P'::text) AND (docass.docass_target_id = pohead.pohead_id)) AND (vendinfo.vend_id = pohead.pohead_vend_id))) UNION ALL SELECT docass.docass_id AS id, pohead.pohead_number AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, vendinfo.vend_name AS name, firstline(pohead.pohead_comments) AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, pohead, vendinfo WHERE (((docass.docass_source_type = 'P'::text) AND (docass.docass_source_id = pohead.pohead_id)) AND (vendinfo.vend_id = pohead.pohead_vend_id))) UNION ALL SELECT docass.docass_id AS id, formatwonumber(wo.wo_id) AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, item.item_descrip1 AS name, item.item_descrip2 AS description, docass.docass_purpose AS purpose FROM docass, wo, itemsite, item WHERE ((((docass.docass_target_type = 'W'::text) AND (docass.docass_target_id = wo.wo_id)) AND (wo.wo_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id))) UNION ALL SELECT docass.docass_id AS id, formatwonumber(wo.wo_id) AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, item.item_descrip1 AS name, item.item_descrip2 AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, wo, itemsite, item WHERE ((((docass.docass_source_type = 'W'::text) AND (docass.docass_source_id = wo.wo_id)) AND (wo.wo_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id))) UNION ALL SELECT docass.docass_id AS id, emp.emp_number AS target_number, docass.docass_target_type AS target_type, docass.docass_target_id AS target_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id, cntct.cntct_name AS name, cntct.cntct_title AS description, docass.docass_purpose AS purpose FROM docass, (emp LEFT JOIN cntct ON ((emp.emp_cntct_id = cntct.cntct_id))) WHERE ((docass.docass_target_type = 'EMP'::text) AND (docass.docass_target_id = emp.emp_id))) UNION ALL SELECT docass.docass_id AS id, emp.emp_number AS target_number, docass.docass_source_type AS target_type, docass.docass_source_id AS target_id, docass.docass_target_type AS source_type, docass.docass_target_id AS source_id, cntct.cntct_name AS name, cntct.cntct_title AS description, CASE WHEN (docass.docass_purpose = 'A'::bpchar) THEN 'C'::bpchar WHEN (docass.docass_purpose = 'C'::bpchar) THEN 'A'::bpchar ELSE docass.docass_purpose END AS purpose FROM docass, (emp LEFT JOIN cntct ON ((emp.emp_cntct_id = cntct.cntct_id))) WHERE ((docass.docass_source_type = 'EMP'::text) AND (docass.docass_source_id = emp.emp_id));
90175
 
 
90176
 
 
90177
 
ALTER TABLE public.docinfo OWNER TO admin;
90178
 
 
90179
 
--
90180
 
--
90181
 
 
90182
 
CREATE SEQUENCE emp_emp_id_seq
90183
 
    START WITH 1
90184
 
    INCREMENT BY 1
90185
 
    NO MINVALUE
90186
 
    NO MAXVALUE
90187
 
    CACHE 1;
90188
 
 
90189
 
 
90190
 
ALTER TABLE public.emp_emp_id_seq OWNER TO admin;
90191
 
 
90192
 
--
90193
 
--
90194
 
 
90195
 
ALTER SEQUENCE emp_emp_id_seq OWNED BY emp.emp_id;
90196
 
 
90197
 
 
90198
 
--
90199
 
--
90200
 
 
90201
 
CREATE TABLE empgrp (
90202
 
    empgrp_id integer NOT NULL,
90203
 
    empgrp_name text NOT NULL,
90204
 
    empgrp_descrip text NOT NULL,
90205
 
    CONSTRAINT empgrp_empgrp_name_check CHECK ((empgrp_name <> ''::text))
90206
 
);
90207
 
 
90208
 
 
90209
 
ALTER TABLE public.empgrp OWNER TO admin;
90210
 
 
90211
 
--
90212
 
--
90213
 
 
90214
 
CREATE SEQUENCE empgrp_empgrp_id_seq
90215
 
    START WITH 1
90216
 
    INCREMENT BY 1
90217
 
    NO MINVALUE
90218
 
    NO MAXVALUE
90219
 
    CACHE 1;
90220
 
 
90221
 
 
90222
 
ALTER TABLE public.empgrp_empgrp_id_seq OWNER TO admin;
90223
 
 
90224
 
--
90225
 
--
90226
 
 
90227
 
ALTER SEQUENCE empgrp_empgrp_id_seq OWNED BY empgrp.empgrp_id;
90228
 
 
90229
 
 
90230
 
--
90231
 
--
90232
 
 
90233
 
CREATE TABLE empgrpitem (
90234
 
    empgrpitem_id integer NOT NULL,
90235
 
    empgrpitem_empgrp_id integer NOT NULL,
90236
 
    empgrpitem_emp_id integer NOT NULL
90237
 
);
90238
 
 
90239
 
 
90240
 
ALTER TABLE public.empgrpitem OWNER TO admin;
90241
 
 
90242
 
--
90243
 
--
90244
 
 
90245
 
CREATE SEQUENCE empgrpitem_empgrpitem_id_seq
90246
 
    START WITH 1
90247
 
    INCREMENT BY 1
90248
 
    NO MINVALUE
90249
 
    NO MAXVALUE
90250
 
    CACHE 1;
90251
 
 
90252
 
 
90253
 
ALTER TABLE public.empgrpitem_empgrpitem_id_seq OWNER TO admin;
90254
 
 
90255
 
--
90256
 
--
90257
 
 
90258
 
ALTER SEQUENCE empgrpitem_empgrpitem_id_seq OWNED BY empgrpitem.empgrpitem_id;
90259
 
 
90260
 
 
90261
 
--
90262
 
--
90263
 
 
90264
 
CREATE TABLE evntlog (
90265
 
    evntlog_id integer DEFAULT nextval(('evntlog_evntlog_id_seq'::text)::regclass) NOT NULL,
90266
 
    evntlog_evnttime timestamp with time zone,
90267
 
    evntlog_evnttype_id integer,
90268
 
    evntlog_ord_id integer,
90269
 
    evntlog_dispatched timestamp with time zone,
90270
 
    evntlog_action text,
90271
 
    evntlog_warehous_id integer,
90272
 
    evntlog_number text,
90273
 
    evntlog_newvalue numeric(20,10),
90274
 
    evntlog_oldvalue numeric(20,10),
90275
 
    evntlog_newdate date,
90276
 
    evntlog_olddate date,
90277
 
    evntlog_ordtype character(2),
90278
 
    evntlog_username text
90279
 
);
90280
 
 
90281
 
 
90282
 
ALTER TABLE public.evntlog OWNER TO admin;
90283
 
 
90284
 
--
90285
 
--
90286
 
 
90287
 
COMMENT ON TABLE evntlog IS 'Event Notification history';
90288
 
 
90289
 
 
90290
 
--
90291
 
--
90292
 
 
90293
 
CREATE SEQUENCE evntlog_evntlog_id_seq
90294
 
    START WITH 1
90295
 
    INCREMENT BY 1
90296
 
    NO MINVALUE
90297
 
    MAXVALUE 2147483647
90298
 
    CACHE 1;
90299
 
 
90300
 
 
90301
 
ALTER TABLE public.evntlog_evntlog_id_seq OWNER TO admin;
90302
 
 
90303
 
--
90304
 
--
90305
 
 
90306
 
CREATE TABLE evntnot (
90307
 
    evntnot_id integer DEFAULT nextval(('evntnot_evntnot_id_seq'::text)::regclass) NOT NULL,
90308
 
    evntnot_evnttype_id integer,
90309
 
    evntnot_warehous_id integer,
90310
 
    evntnot_username text
90311
 
);
90312
 
 
90313
 
 
90314
 
ALTER TABLE public.evntnot OWNER TO admin;
90315
 
 
90316
 
--
90317
 
--
90318
 
 
90319
 
COMMENT ON TABLE evntnot IS 'Temporary table for storing information about user Event Notification selections';
90320
 
 
90321
 
 
90322
 
--
90323
 
--
90324
 
 
90325
 
CREATE SEQUENCE evntnot_evntnot_id_seq
90326
 
    START WITH 1
90327
 
    INCREMENT BY 1
90328
 
    NO MINVALUE
90329
 
    MAXVALUE 2147483647
90330
 
    CACHE 1;
90331
 
 
90332
 
 
90333
 
ALTER TABLE public.evntnot_evntnot_id_seq OWNER TO admin;
90334
 
 
90335
 
--
90336
 
--
90337
 
 
90338
 
CREATE TABLE evnttype (
90339
 
    evnttype_id integer DEFAULT nextval(('evnttype_evnttype_id_seq'::text)::regclass) NOT NULL,
90340
 
    evnttype_name text NOT NULL,
90341
 
    evnttype_descrip text,
90342
 
    evnttype_module text,
90343
 
    CONSTRAINT evnttype_evnttype_name_check CHECK ((evnttype_name <> ''::text))
90344
 
);
90345
 
 
90346
 
 
90347
 
ALTER TABLE public.evnttype OWNER TO admin;
90348
 
 
90349
 
--
90350
 
--
90351
 
 
90352
 
COMMENT ON TABLE evnttype IS 'Event Type information';
90353
 
 
90354
 
 
90355
 
--
90356
 
--
90357
 
 
90358
 
CREATE SEQUENCE evnttype_evnttype_id_seq
90359
 
    START WITH 1
90360
 
    INCREMENT BY 1
90361
 
    NO MINVALUE
90362
 
    MAXVALUE 2147483647
90363
 
    CACHE 1;
90364
 
 
90365
 
 
90366
 
ALTER TABLE public.evnttype_evnttype_id_seq OWNER TO admin;
90367
 
 
90368
 
--
90369
 
--
90370
 
 
90371
 
CREATE SEQUENCE expcat_expcat_id_seq
90372
 
    START WITH 1
90373
 
    INCREMENT BY 1
90374
 
    NO MINVALUE
90375
 
    NO MAXVALUE
90376
 
    CACHE 1;
90377
 
 
90378
 
 
90379
 
ALTER TABLE public.expcat_expcat_id_seq OWNER TO admin;
90380
 
 
90381
 
--
90382
 
--
90383
 
 
90384
 
ALTER SEQUENCE expcat_expcat_id_seq OWNED BY expcat.expcat_id;
90385
 
 
90386
 
 
90387
 
--
90388
 
--
90389
 
 
90390
 
CREATE SEQUENCE file_file_id_seq
90391
 
    START WITH 1
90392
 
    INCREMENT BY 1
90393
 
    NO MINVALUE
90394
 
    NO MAXVALUE
90395
 
    CACHE 1;
90396
 
 
90397
 
 
90398
 
ALTER TABLE public.file_file_id_seq OWNER TO admin;
90399
 
 
90400
 
--
90401
 
--
90402
 
 
90403
 
ALTER SEQUENCE file_file_id_seq OWNED BY file.file_id;
90404
 
 
90405
 
 
90406
 
--
90407
 
--
90408
 
 
90409
 
CREATE TABLE filter (
90410
 
    filter_id integer NOT NULL,
90411
 
    filter_screen text NOT NULL,
90412
 
    filter_value text NOT NULL,
90413
 
    filter_username text,
90414
 
    filter_name text NOT NULL,
90415
 
    filter_selected boolean DEFAULT false
90416
 
);
90417
 
 
90418
 
 
90419
 
ALTER TABLE public.filter OWNER TO admin;
90420
 
 
90421
 
--
90422
 
--
90423
 
 
90424
 
CREATE SEQUENCE filter_filter_id_seq
90425
 
    START WITH 1
90426
 
    INCREMENT BY 1
90427
 
    NO MINVALUE
90428
 
    NO MAXVALUE
90429
 
    CACHE 1;
90430
 
 
90431
 
 
90432
 
ALTER TABLE public.filter_filter_id_seq OWNER TO admin;
90433
 
 
90434
 
--
90435
 
--
90436
 
 
90437
 
ALTER SEQUENCE filter_filter_id_seq OWNED BY filter.filter_id;
90438
 
 
90439
 
 
90440
 
--
90441
 
--
90442
 
 
90443
 
CREATE TABLE fincharg (
90444
 
    fincharg_id integer NOT NULL,
90445
 
    fincharg_mincharg numeric NOT NULL,
90446
 
    fincharg_graceperiod integer NOT NULL,
90447
 
    fincharg_assessoverdue boolean NOT NULL,
90448
 
    fincharg_calcfrom integer NOT NULL,
90449
 
    fincharg_markoninvoice text NOT NULL,
90450
 
    fincharg_air numeric NOT NULL,
90451
 
    fincharg_accnt_id integer NOT NULL,
90452
 
    fincharg_salescat_id integer NOT NULL,
90453
 
    fincharg_lastfc_statementcyclefrom text,
90454
 
    fincharg_lastfc_custidfrom text,
90455
 
    fincharg_lastfc_custidto text,
90456
 
    fincharg_lastfc_statementcycleto text
90457
 
);
90458
 
 
90459
 
 
90460
 
ALTER TABLE public.fincharg OWNER TO admin;
90461
 
 
90462
 
--
90463
 
--
90464
 
 
90465
 
COMMENT ON TABLE fincharg IS 'Finance Charge configuration information';
90466
 
 
90467
 
 
90468
 
--
90469
 
--
90470
 
 
90471
 
CREATE SEQUENCE fincharg_fincharg_id_seq
90472
 
    START WITH 1
90473
 
    INCREMENT BY 1
90474
 
    NO MINVALUE
90475
 
    NO MAXVALUE
90476
 
    CACHE 1;
90477
 
 
90478
 
 
90479
 
ALTER TABLE public.fincharg_fincharg_id_seq OWNER TO admin;
90480
 
 
90481
 
--
90482
 
--
90483
 
 
90484
 
ALTER SEQUENCE fincharg_fincharg_id_seq OWNED BY fincharg.fincharg_id;
90485
 
 
90486
 
 
90487
 
--
90488
 
--
90489
 
 
90490
 
CREATE TABLE flhead (
90491
 
    flhead_id integer NOT NULL,
90492
 
    flhead_name text NOT NULL,
90493
 
    flhead_descrip text,
90494
 
    flhead_showtotal boolean DEFAULT false NOT NULL,
90495
 
    flhead_showstart boolean DEFAULT true NOT NULL,
90496
 
    flhead_showend boolean DEFAULT true NOT NULL,
90497
 
    flhead_showdelta boolean DEFAULT true NOT NULL,
90498
 
    flhead_showbudget boolean DEFAULT true NOT NULL,
90499
 
    flhead_showdiff boolean DEFAULT false NOT NULL,
90500
 
    flhead_showcustom boolean DEFAULT false NOT NULL,
90501
 
    flhead_custom_label text,
90502
 
    flhead_usealttotal boolean DEFAULT false NOT NULL,
90503
 
    flhead_alttotal text,
90504
 
    flhead_usealtbegin boolean DEFAULT false NOT NULL,
90505
 
    flhead_altbegin text,
90506
 
    flhead_usealtend boolean DEFAULT false NOT NULL,
90507
 
    flhead_altend text,
90508
 
    flhead_usealtdebits boolean DEFAULT false NOT NULL,
90509
 
    flhead_altdebits text,
90510
 
    flhead_usealtcredits boolean DEFAULT false NOT NULL,
90511
 
    flhead_altcredits text,
90512
 
    flhead_usealtbudget boolean DEFAULT false NOT NULL,
90513
 
    flhead_altbudget text,
90514
 
    flhead_usealtdiff boolean DEFAULT false NOT NULL,
90515
 
    flhead_altdiff text,
90516
 
    flhead_type character(1) DEFAULT 'A'::bpchar NOT NULL,
90517
 
    flhead_active boolean DEFAULT true NOT NULL,
90518
 
    flhead_sys boolean DEFAULT false,
90519
 
    flhead_notes text DEFAULT ''::text,
90520
 
    CONSTRAINT flhead_flhead_name_check CHECK ((flhead_name <> ''::text))
90521
 
);
90522
 
 
90523
 
 
90524
 
ALTER TABLE public.flhead OWNER TO admin;
90525
 
 
90526
 
--
90527
 
--
90528
 
 
90529
 
COMMENT ON TABLE flhead IS 'Financial Layout header information';
90530
 
 
90531
 
 
90532
 
--
90533
 
--
90534
 
 
90535
 
CREATE TABLE flitem (
90536
 
    flitem_id integer NOT NULL,
90537
 
    flitem_flhead_id integer,
90538
 
    flitem_flgrp_id integer,
90539
 
    flitem_order integer,
90540
 
    flitem_accnt_id integer,
90541
 
    flitem_showstart boolean,
90542
 
    flitem_showend boolean,
90543
 
    flitem_showdelta boolean,
90544
 
    flitem_showbudget boolean DEFAULT false NOT NULL,
90545
 
    flitem_subtract boolean DEFAULT false NOT NULL,
90546
 
    flitem_showstartprcnt boolean DEFAULT false NOT NULL,
90547
 
    flitem_showendprcnt boolean DEFAULT false NOT NULL,
90548
 
    flitem_showdeltaprcnt boolean DEFAULT false NOT NULL,
90549
 
    flitem_showbudgetprcnt boolean DEFAULT false NOT NULL,
90550
 
    flitem_prcnt_flgrp_id integer DEFAULT (-1) NOT NULL,
90551
 
    flitem_showdiff boolean DEFAULT false NOT NULL,
90552
 
    flitem_showdiffprcnt boolean DEFAULT false NOT NULL,
90553
 
    flitem_showcustom boolean DEFAULT false NOT NULL,
90554
 
    flitem_showcustomprcnt boolean DEFAULT false NOT NULL,
90555
 
    flitem_custom_source character(1),
90556
 
    flitem_company text,
90557
 
    flitem_profit text,
90558
 
    flitem_number text,
90559
 
    flitem_sub text,
90560
 
    flitem_type character(1),
90561
 
    flitem_subaccnttype_code text
90562
 
);
90563
 
 
90564
 
 
90565
 
ALTER TABLE public.flitem OWNER TO admin;
90566
 
 
90567
 
--
90568
 
--
90569
 
 
90570
 
COMMENT ON TABLE flitem IS 'Financial Layout Account information';
90571
 
 
90572
 
 
90573
 
--
90574
 
--
90575
 
 
90576
 
CREATE VIEW flaccnt AS
90577
 
    SELECT flhead.flhead_type, flitem.flitem_id, flitem.flitem_flhead_id, flitem.flitem_flgrp_id, flitem.flitem_order, flitem.flitem_accnt_id, flitem.flitem_showstart, flitem.flitem_showend, flitem.flitem_showdelta, flitem.flitem_showbudget, flitem.flitem_subtract, flitem.flitem_showstartprcnt, flitem.flitem_showendprcnt, flitem.flitem_showdeltaprcnt, flitem.flitem_showbudgetprcnt, flitem.flitem_prcnt_flgrp_id, flitem.flitem_showdiff, flitem.flitem_showdiffprcnt, flitem.flitem_showcustom, flitem.flitem_showcustomprcnt, flitem.flitem_custom_source, flitem.flitem_company, flitem.flitem_profit, flitem.flitem_number, flitem.flitem_sub, flitem.flitem_type, flitem.flitem_subaccnttype_code, accnt.accnt_id, accnt.accnt_type, accnt.accnt_company, accnt.accnt_profit, accnt.accnt_number, accnt.accnt_sub, (-1) AS prj_id FROM ((flhead JOIN flitem ON ((flhead.flhead_id = flitem.flitem_flhead_id))) JOIN accnt ON ((flitem.flitem_accnt_id = accnt.accnt_id))) UNION ALL SELECT flhead.flhead_type, flitem.flitem_id, flitem.flitem_flhead_id, flitem.flitem_flgrp_id, flitem.flitem_order, flitem.flitem_accnt_id, flitem.flitem_showstart, flitem.flitem_showend, flitem.flitem_showdelta, flitem.flitem_showbudget, flitem.flitem_subtract, flitem.flitem_showstartprcnt, flitem.flitem_showendprcnt, flitem.flitem_showdeltaprcnt, flitem.flitem_showbudgetprcnt, flitem.flitem_prcnt_flgrp_id, flitem.flitem_showdiff, flitem.flitem_showdiffprcnt, flitem.flitem_showcustom, flitem.flitem_showcustomprcnt, flitem.flitem_custom_source, flitem.flitem_company, flitem.flitem_profit, flitem.flitem_number, flitem.flitem_sub, flitem.flitem_type, flitem.flitem_subaccnttype_code, accnt.accnt_id, accnt.accnt_type, accnt.accnt_company, accnt.accnt_profit, accnt.accnt_number, accnt.accnt_sub, (-1) AS prj_id FROM (flhead JOIN flitem ON ((flhead.flhead_id = flitem.flitem_flhead_id))), accnt WHERE (((((((flitem.flitem_accnt_id = (-1)) AND ((flitem.flitem_type = ''::bpchar) OR (accnt.accnt_type = flitem.flitem_type))) AND ((flitem.flitem_company = 'All'::text) OR (accnt.accnt_company = flitem.flitem_company))) AND ((flitem.flitem_profit = 'All'::text) OR (accnt.accnt_profit = flitem.flitem_profit))) AND ((flitem.flitem_number = 'All'::text) OR (accnt.accnt_number = flitem.flitem_number))) AND ((flitem.flitem_sub = 'All'::text) OR (accnt.accnt_sub = flitem.flitem_sub))) AND ((flitem.flitem_subaccnttype_code = 'All'::text) OR (accnt.accnt_subaccnttype_code = flitem.flitem_subaccnttype_code))) ORDER BY 30, 31, 32, 33;
90578
 
 
90579
 
 
90580
 
ALTER TABLE public.flaccnt OWNER TO admin;
90581
 
 
90582
 
--
90583
 
--
90584
 
 
90585
 
CREATE TABLE flcol (
90586
 
    flcol_id integer NOT NULL,
90587
 
    flcol_flhead_id integer NOT NULL,
90588
 
    flcol_name text,
90589
 
    flcol_descrip text,
90590
 
    flcol_report_id integer,
90591
 
    flcol_month boolean,
90592
 
    flcol_quarter boolean,
90593
 
    flcol_year boolean,
90594
 
    flcol_showdb boolean,
90595
 
    flcol_prcnt boolean,
90596
 
    flcol_priortype character(1),
90597
 
    flcol_priormonth boolean,
90598
 
    flcol_priorquarter boolean,
90599
 
    flcol_prioryear character(1),
90600
 
    flcol_priorprcnt boolean,
90601
 
    flcol_priordiff boolean,
90602
 
    flcol_priordiffprcnt boolean,
90603
 
    flcol_budget boolean,
90604
 
    flcol_budgetprcnt boolean,
90605
 
    flcol_budgetdiff boolean,
90606
 
    flcol_budgetdiffprcnt boolean
90607
 
);
90608
 
 
90609
 
 
90610
 
ALTER TABLE public.flcol OWNER TO admin;
90611
 
 
90612
 
--
90613
 
--
90614
 
 
90615
 
CREATE SEQUENCE flcol_flcol_id_seq
90616
 
    START WITH 1
90617
 
    INCREMENT BY 1
90618
 
    NO MINVALUE
90619
 
    NO MAXVALUE
90620
 
    CACHE 1;
90621
 
 
90622
 
 
90623
 
ALTER TABLE public.flcol_flcol_id_seq OWNER TO admin;
90624
 
 
90625
 
--
90626
 
--
90627
 
 
90628
 
ALTER SEQUENCE flcol_flcol_id_seq OWNED BY flcol.flcol_id;
90629
 
 
90630
 
 
90631
 
--
90632
 
--
90633
 
 
90634
 
CREATE TABLE flgrp (
90635
 
    flgrp_id integer NOT NULL,
90636
 
    flgrp_flhead_id integer,
90637
 
    flgrp_flgrp_id integer,
90638
 
    flgrp_order integer,
90639
 
    flgrp_name text,
90640
 
    flgrp_descrip text,
90641
 
    flgrp_subtotal boolean DEFAULT false NOT NULL,
90642
 
    flgrp_summarize boolean DEFAULT false NOT NULL,
90643
 
    flgrp_subtract boolean DEFAULT false NOT NULL,
90644
 
    flgrp_showstart boolean DEFAULT true NOT NULL,
90645
 
    flgrp_showend boolean DEFAULT true NOT NULL,
90646
 
    flgrp_showdelta boolean DEFAULT true NOT NULL,
90647
 
    flgrp_showbudget boolean DEFAULT true NOT NULL,
90648
 
    flgrp_showstartprcnt boolean DEFAULT false NOT NULL,
90649
 
    flgrp_showendprcnt boolean DEFAULT false NOT NULL,
90650
 
    flgrp_showdeltaprcnt boolean DEFAULT false NOT NULL,
90651
 
    flgrp_showbudgetprcnt boolean DEFAULT false NOT NULL,
90652
 
    flgrp_prcnt_flgrp_id integer DEFAULT (-1) NOT NULL,
90653
 
    flgrp_showdiff boolean DEFAULT false NOT NULL,
90654
 
    flgrp_showdiffprcnt boolean DEFAULT false NOT NULL,
90655
 
    flgrp_showcustom boolean DEFAULT false NOT NULL,
90656
 
    flgrp_showcustomprcnt boolean DEFAULT false NOT NULL,
90657
 
    flgrp_usealtsubtotal boolean DEFAULT false NOT NULL,
90658
 
    flgrp_altsubtotal text
90659
 
);
90660
 
 
90661
 
 
90662
 
ALTER TABLE public.flgrp OWNER TO admin;
90663
 
 
90664
 
--
90665
 
--
90666
 
 
90667
 
COMMENT ON TABLE flgrp IS 'Financial Layout Group information';
90668
 
 
90669
 
 
90670
 
--
90671
 
--
90672
 
 
90673
 
CREATE SEQUENCE flgrp_flgrp_id_seq
90674
 
    START WITH 1
90675
 
    INCREMENT BY 1
90676
 
    NO MINVALUE
90677
 
    NO MAXVALUE
90678
 
    CACHE 1;
90679
 
 
90680
 
 
90681
 
ALTER TABLE public.flgrp_flgrp_id_seq OWNER TO admin;
90682
 
 
90683
 
--
90684
 
--
90685
 
 
90686
 
ALTER SEQUENCE flgrp_flgrp_id_seq OWNED BY flgrp.flgrp_id;
90687
 
 
90688
 
 
90689
 
--
90690
 
--
90691
 
 
90692
 
CREATE SEQUENCE flhead_flhead_id_seq
90693
 
    START WITH 1
90694
 
    INCREMENT BY 1
90695
 
    NO MINVALUE
90696
 
    NO MAXVALUE
90697
 
    CACHE 1;
90698
 
 
90699
 
 
90700
 
ALTER TABLE public.flhead_flhead_id_seq OWNER TO admin;
90701
 
 
90702
 
--
90703
 
--
90704
 
 
90705
 
ALTER SEQUENCE flhead_flhead_id_seq OWNED BY flhead.flhead_id;
90706
 
 
90707
 
 
90708
 
--
90709
 
--
90710
 
 
90711
 
CREATE SEQUENCE flitem_flitem_id_seq
90712
 
    START WITH 1
90713
 
    INCREMENT BY 1
90714
 
    NO MINVALUE
90715
 
    NO MAXVALUE
90716
 
    CACHE 1;
90717
 
 
90718
 
 
90719
 
ALTER TABLE public.flitem_flitem_id_seq OWNER TO admin;
90720
 
 
90721
 
--
90722
 
--
90723
 
 
90724
 
ALTER SEQUENCE flitem_flitem_id_seq OWNED BY flitem.flitem_id;
90725
 
 
90726
 
 
90727
 
--
90728
 
--
90729
 
 
90730
 
CREATE TABLE flnotes (
90731
 
    flnotes_id integer NOT NULL,
90732
 
    flnotes_flhead_id integer,
90733
 
    flnotes_period_id integer,
90734
 
    flnotes_notes text DEFAULT ''::text
90735
 
);
90736
 
 
90737
 
 
90738
 
ALTER TABLE public.flnotes OWNER TO admin;
90739
 
 
90740
 
--
90741
 
--
90742
 
 
90743
 
CREATE SEQUENCE flnotes_flnotes_id_seq
90744
 
    START WITH 1
90745
 
    INCREMENT BY 1
90746
 
    NO MINVALUE
90747
 
    NO MAXVALUE
90748
 
    CACHE 1;
90749
 
 
90750
 
 
90751
 
ALTER TABLE public.flnotes_flnotes_id_seq OWNER TO admin;
90752
 
 
90753
 
--
90754
 
--
90755
 
 
90756
 
ALTER SEQUENCE flnotes_flnotes_id_seq OWNED BY flnotes.flnotes_id;
90757
 
 
90758
 
 
90759
 
--
90760
 
--
90761
 
 
90762
 
CREATE TABLE flrpt (
90763
 
    flrpt_flhead_id integer NOT NULL,
90764
 
    flrpt_period_id integer NOT NULL,
90765
 
    flrpt_username text NOT NULL,
90766
 
    flrpt_order integer NOT NULL,
90767
 
    flrpt_level integer NOT NULL,
90768
 
    flrpt_type text NOT NULL,
90769
 
    flrpt_type_id integer NOT NULL,
90770
 
    flrpt_beginning numeric,
90771
 
    flrpt_ending numeric,
90772
 
    flrpt_debits numeric,
90773
 
    flrpt_credits numeric,
90774
 
    flrpt_budget numeric,
90775
 
    flrpt_beginningprcnt numeric,
90776
 
    flrpt_endingprcnt numeric,
90777
 
    flrpt_debitsprcnt numeric,
90778
 
    flrpt_creditsprcnt numeric,
90779
 
    flrpt_budgetprcnt numeric,
90780
 
    flrpt_parent_id integer,
90781
 
    flrpt_diff numeric,
90782
 
    flrpt_diffprcnt numeric,
90783
 
    flrpt_custom numeric,
90784
 
    flrpt_customprcnt numeric,
90785
 
    flrpt_altname text,
90786
 
    flrpt_accnt_id integer,
90787
 
    flrpt_interval character(1),
90788
 
    flrpt_id integer NOT NULL
90789
 
);
90790
 
 
90791
 
 
90792
 
ALTER TABLE public.flrpt OWNER TO admin;
90793
 
 
90794
 
--
90795
 
--
90796
 
 
90797
 
COMMENT ON TABLE flrpt IS 'Scratch table where financial reporting information is processed before being displayed.';
90798
 
 
90799
 
 
90800
 
--
90801
 
--
90802
 
 
90803
 
CREATE SEQUENCE flrpt_flrpt_id_seq
90804
 
    START WITH 1
90805
 
    INCREMENT BY 1
90806
 
    NO MINVALUE
90807
 
    NO MAXVALUE
90808
 
    CACHE 1;
90809
 
 
90810
 
 
90811
 
ALTER TABLE public.flrpt_flrpt_id_seq OWNER TO admin;
90812
 
 
90813
 
--
90814
 
--
90815
 
 
90816
 
ALTER SEQUENCE flrpt_flrpt_id_seq OWNED BY flrpt.flrpt_id;
90817
 
 
90818
 
 
90819
 
--
90820
 
--
90821
 
 
90822
 
CREATE TABLE flspec (
90823
 
    flspec_id integer NOT NULL,
90824
 
    flspec_flhead_id integer NOT NULL,
90825
 
    flspec_flgrp_id integer NOT NULL,
90826
 
    flspec_order integer NOT NULL,
90827
 
    flspec_name text,
90828
 
    flspec_type text,
90829
 
    flspec_showstart boolean DEFAULT true NOT NULL,
90830
 
    flspec_showend boolean DEFAULT true NOT NULL,
90831
 
    flspec_showdelta boolean DEFAULT true NOT NULL,
90832
 
    flspec_showbudget boolean DEFAULT false NOT NULL,
90833
 
    flspec_subtract boolean DEFAULT false NOT NULL,
90834
 
    flspec_showstartprcnt boolean DEFAULT false NOT NULL,
90835
 
    flspec_showendprcnt boolean DEFAULT false NOT NULL,
90836
 
    flspec_showdeltaprcnt boolean DEFAULT false NOT NULL,
90837
 
    flspec_showbudgetprcnt boolean DEFAULT false NOT NULL,
90838
 
    flspec_showdiff boolean DEFAULT false NOT NULL,
90839
 
    flspec_showdiffprcnt boolean DEFAULT false NOT NULL,
90840
 
    flspec_prcnt_flgrp_id integer DEFAULT (-1) NOT NULL,
90841
 
    flspec_showcustom boolean DEFAULT false NOT NULL,
90842
 
    flspec_showcustomprcnt boolean DEFAULT false NOT NULL,
90843
 
    flspec_custom_source character(1)
90844
 
);
90845
 
 
90846
 
 
90847
 
ALTER TABLE public.flspec OWNER TO admin;
90848
 
 
90849
 
--
90850
 
--
90851
 
 
90852
 
COMMENT ON TABLE flspec IS 'Financial Layout Special entries.';
90853
 
 
90854
 
 
90855
 
--
90856
 
--
90857
 
 
90858
 
CREATE SEQUENCE flspec_flspec_id_seq
90859
 
    START WITH 1
90860
 
    INCREMENT BY 1
90861
 
    NO MINVALUE
90862
 
    NO MAXVALUE
90863
 
    CACHE 1;
90864
 
 
90865
 
 
90866
 
ALTER TABLE public.flspec_flspec_id_seq OWNER TO admin;
90867
 
 
90868
 
--
90869
 
--
90870
 
 
90871
 
ALTER SEQUENCE flspec_flspec_id_seq OWNED BY flspec.flspec_id;
90872
 
 
90873
 
 
90874
 
--
90875
 
--
90876
 
 
90877
 
CREATE TABLE form (
90878
 
    form_id integer DEFAULT nextval(('"form_form_id_seq"'::text)::regclass) NOT NULL,
90879
 
    form_name text NOT NULL,
90880
 
    form_descrip text,
90881
 
    form_report_id integer,
90882
 
    form_key character varying(4),
90883
 
    form_report_name text,
90884
 
    CONSTRAINT form_form_name_check CHECK ((form_name <> ''::text))
90885
 
);
90886
 
 
90887
 
 
90888
 
ALTER TABLE public.form OWNER TO admin;
90889
 
 
90890
 
--
90891
 
--
90892
 
 
90893
 
COMMENT ON TABLE form IS 'Form information';
90894
 
 
90895
 
 
90896
 
--
90897
 
--
90898
 
 
90899
 
COMMENT ON COLUMN form.form_report_id IS 'Obsolete -- reference form_report_name instead.';
90900
 
 
90901
 
 
90902
 
--
90903
 
--
90904
 
 
90905
 
CREATE SEQUENCE form_form_id_seq
90906
 
    START WITH 1
90907
 
    INCREMENT BY 1
90908
 
    NO MINVALUE
90909
 
    MAXVALUE 2147483647
90910
 
    CACHE 1;
90911
 
 
90912
 
 
90913
 
ALTER TABLE public.form_form_id_seq OWNER TO admin;
90914
 
 
90915
 
--
90916
 
--
90917
 
 
90918
 
CREATE SEQUENCE freightclass_freightclass_id_seq
90919
 
    START WITH 1
90920
 
    INCREMENT BY 1
90921
 
    NO MINVALUE
90922
 
    NO MAXVALUE
90923
 
    CACHE 1;
90924
 
 
90925
 
 
90926
 
ALTER TABLE public.freightclass_freightclass_id_seq OWNER TO admin;
90927
 
 
90928
 
--
90929
 
--
90930
 
 
90931
 
ALTER SEQUENCE freightclass_freightclass_id_seq OWNED BY freightclass.freightclass_id;
90932
 
 
90933
 
 
90934
 
--
90935
 
--
90936
 
 
90937
 
CREATE TABLE glseries (
90938
 
    glseries_id integer DEFAULT nextval(('"glseries_glseries_id_seq"'::text)::regclass) NOT NULL,
90939
 
    glseries_sequence integer,
90940
 
    glseries_doctype character(2),
90941
 
    glseries_docnumber text,
90942
 
    glseries_accnt_id integer,
90943
 
    glseries_amount numeric(20,2),
90944
 
    glseries_source text,
90945
 
    glseries_distdate date,
90946
 
    glseries_notes text,
90947
 
    glseries_misc_id integer
90948
 
);
90949
 
 
90950
 
 
90951
 
ALTER TABLE public.glseries OWNER TO admin;
90952
 
 
90953
 
--
90954
 
--
90955
 
 
90956
 
COMMENT ON TABLE glseries IS 'Temporary table for storing information about General Ledger (G/L) Series Entries before Series Entries are posted';
90957
 
 
90958
 
 
90959
 
--
90960
 
--
90961
 
 
90962
 
CREATE SEQUENCE glseries_glseries_id_seq
90963
 
    START WITH 1
90964
 
    INCREMENT BY 1
90965
 
    NO MINVALUE
90966
 
    MAXVALUE 2147483647
90967
 
    CACHE 1;
90968
 
 
90969
 
 
90970
 
ALTER TABLE public.glseries_glseries_id_seq OWNER TO admin;
90971
 
 
90972
 
--
90973
 
--
90974
 
 
90975
 
CREATE SEQUENCE gltrans_gltrans_id_seq
90976
 
    START WITH 1
90977
 
    INCREMENT BY 1
90978
 
    NO MINVALUE
90979
 
    MAXVALUE 2147483647
90980
 
    CACHE 1;
90981
 
 
90982
 
 
90983
 
ALTER TABLE public.gltrans_gltrans_id_seq OWNER TO admin;
90984
 
 
90985
 
--
90986
 
--
90987
 
 
90988
 
CREATE SEQUENCE gltrans_sequence_seq
90989
 
    START WITH 1
90990
 
    INCREMENT BY 1
90991
 
    NO MINVALUE
90992
 
    MAXVALUE 2147483647
90993
 
    CACHE 1;
90994
 
 
90995
 
 
90996
 
ALTER TABLE public.gltrans_sequence_seq OWNER TO admin;
90997
 
 
90998
 
--
90999
 
--
91000
 
 
91001
 
CREATE TABLE grp (
91002
 
    grp_id integer NOT NULL,
91003
 
    grp_name text NOT NULL,
91004
 
    grp_descrip text,
91005
 
    CONSTRAINT grp_grp_name_check CHECK ((grp_name <> ''::text))
91006
 
);
91007
 
 
91008
 
 
91009
 
ALTER TABLE public.grp OWNER TO admin;
91010
 
 
91011
 
--
91012
 
--
91013
 
 
91014
 
COMMENT ON TABLE grp IS 'This table is the basic group information.';
91015
 
 
91016
 
 
91017
 
--
91018
 
--
91019
 
 
91020
 
CREATE SEQUENCE grp_grp_id_seq
91021
 
    START WITH 1
91022
 
    INCREMENT BY 1
91023
 
    NO MINVALUE
91024
 
    NO MAXVALUE
91025
 
    CACHE 1;
91026
 
 
91027
 
 
91028
 
ALTER TABLE public.grp_grp_id_seq OWNER TO admin;
91029
 
 
91030
 
--
91031
 
--
91032
 
 
91033
 
ALTER SEQUENCE grp_grp_id_seq OWNED BY grp.grp_id;
91034
 
 
91035
 
 
91036
 
--
91037
 
--
91038
 
 
91039
 
CREATE TABLE grppriv (
91040
 
    grppriv_id integer NOT NULL,
91041
 
    grppriv_grp_id integer NOT NULL,
91042
 
    grppriv_priv_id integer NOT NULL
91043
 
);
91044
 
 
91045
 
 
91046
 
ALTER TABLE public.grppriv OWNER TO admin;
91047
 
 
91048
 
--
91049
 
--
91050
 
 
91051
 
COMMENT ON TABLE grppriv IS 'This is a specific priv for a specific group.';
91052
 
 
91053
 
 
91054
 
--
91055
 
--
91056
 
 
91057
 
CREATE SEQUENCE grppriv_grppriv_id_seq
91058
 
    START WITH 1
91059
 
    INCREMENT BY 1
91060
 
    NO MINVALUE
91061
 
    NO MAXVALUE
91062
 
    CACHE 1;
91063
 
 
91064
 
 
91065
 
ALTER TABLE public.grppriv_grppriv_id_seq OWNER TO admin;
91066
 
 
91067
 
--
91068
 
--
91069
 
 
91070
 
ALTER SEQUENCE grppriv_grppriv_id_seq OWNED BY grppriv.grppriv_id;
91071
 
 
91072
 
 
91073
 
--
91074
 
--
91075
 
 
91076
 
CREATE TABLE hnfc (
91077
 
    hnfc_id integer NOT NULL,
91078
 
    hnfc_code text NOT NULL,
91079
 
    CONSTRAINT hnfc_hnfc_code_check CHECK ((hnfc_code <> ''::text))
91080
 
);
91081
 
 
91082
 
 
91083
 
ALTER TABLE public.hnfc OWNER TO admin;
91084
 
 
91085
 
--
91086
 
--
91087
 
 
91088
 
COMMENT ON TABLE hnfc IS 'List of personal titles/honorifics used in cntct table.';
91089
 
 
91090
 
 
91091
 
--
91092
 
--
91093
 
 
91094
 
CREATE SEQUENCE hnfc_hnfc_id_seq
91095
 
    START WITH 1
91096
 
    INCREMENT BY 1
91097
 
    NO MINVALUE
91098
 
    NO MAXVALUE
91099
 
    CACHE 1;
91100
 
 
91101
 
 
91102
 
ALTER TABLE public.hnfc_hnfc_id_seq OWNER TO admin;
91103
 
 
91104
 
--
91105
 
--
91106
 
 
91107
 
ALTER SEQUENCE hnfc_hnfc_id_seq OWNED BY hnfc.hnfc_id;
91108
 
 
91109
 
 
91110
 
--
91111
 
--
91112
 
 
91113
 
CREATE SEQUENCE incdt_incdt_id_seq
91114
 
    START WITH 1
91115
 
    INCREMENT BY 1
91116
 
    NO MINVALUE
91117
 
    NO MAXVALUE
91118
 
    CACHE 1;
91119
 
 
91120
 
 
91121
 
ALTER TABLE public.incdt_incdt_id_seq OWNER TO admin;
91122
 
 
91123
 
--
91124
 
--
91125
 
 
91126
 
ALTER SEQUENCE incdt_incdt_id_seq OWNED BY incdt.incdt_id;
91127
 
 
91128
 
 
91129
 
--
91130
 
--
91131
 
 
91132
 
CREATE SEQUENCE incdtcat_incdtcat_id_seq
91133
 
    START WITH 1
91134
 
    INCREMENT BY 1
91135
 
    NO MINVALUE
91136
 
    NO MAXVALUE
91137
 
    CACHE 1;
91138
 
 
91139
 
 
91140
 
ALTER TABLE public.incdtcat_incdtcat_id_seq OWNER TO admin;
91141
 
 
91142
 
--
91143
 
--
91144
 
 
91145
 
ALTER SEQUENCE incdtcat_incdtcat_id_seq OWNED BY incdtcat.incdtcat_id;
91146
 
 
91147
 
 
91148
 
--
91149
 
--
91150
 
 
91151
 
CREATE TABLE incdthist (
91152
 
    incdthist_id integer NOT NULL,
91153
 
    incdthist_incdt_id integer NOT NULL,
91154
 
    incdthist_change character(1),
91155
 
    incdthist_target_id integer,
91156
 
    incdthist_timestamp timestamp without time zone DEFAULT now() NOT NULL,
91157
 
    incdthist_username text DEFAULT geteffectivextuser() NOT NULL,
91158
 
    incdthist_descrip text
91159
 
);
91160
 
 
91161
 
 
91162
 
ALTER TABLE public.incdthist OWNER TO admin;
91163
 
 
91164
 
--
91165
 
--
91166
 
 
91167
 
COMMENT ON TABLE incdthist IS 'Incident history changes';
91168
 
 
91169
 
 
91170
 
--
91171
 
--
91172
 
 
91173
 
CREATE SEQUENCE incdthist_incdthist_id_seq
91174
 
    START WITH 1
91175
 
    INCREMENT BY 1
91176
 
    NO MINVALUE
91177
 
    NO MAXVALUE
91178
 
    CACHE 1;
91179
 
 
91180
 
 
91181
 
ALTER TABLE public.incdthist_incdthist_id_seq OWNER TO admin;
91182
 
 
91183
 
--
91184
 
--
91185
 
 
91186
 
ALTER SEQUENCE incdthist_incdthist_id_seq OWNED BY incdthist.incdthist_id;
91187
 
 
91188
 
 
91189
 
--
91190
 
--
91191
 
 
91192
 
CREATE SEQUENCE incdtpriority_incdtpriority_id_seq
91193
 
    START WITH 1
91194
 
    INCREMENT BY 1
91195
 
    NO MINVALUE
91196
 
    NO MAXVALUE
91197
 
    CACHE 1;
91198
 
 
91199
 
 
91200
 
ALTER TABLE public.incdtpriority_incdtpriority_id_seq OWNER TO admin;
91201
 
 
91202
 
--
91203
 
--
91204
 
 
91205
 
ALTER SEQUENCE incdtpriority_incdtpriority_id_seq OWNED BY incdtpriority.incdtpriority_id;
91206
 
 
91207
 
 
91208
 
--
91209
 
--
91210
 
 
91211
 
CREATE SEQUENCE incdtresolution_incdtresolution_id_seq
91212
 
    START WITH 1
91213
 
    INCREMENT BY 1
91214
 
    NO MINVALUE
91215
 
    NO MAXVALUE
91216
 
    CACHE 1;
91217
 
 
91218
 
 
91219
 
ALTER TABLE public.incdtresolution_incdtresolution_id_seq OWNER TO admin;
91220
 
 
91221
 
--
91222
 
--
91223
 
 
91224
 
ALTER SEQUENCE incdtresolution_incdtresolution_id_seq OWNED BY incdtresolution.incdtresolution_id;
91225
 
 
91226
 
 
91227
 
--
91228
 
--
91229
 
 
91230
 
CREATE SEQUENCE incdtseverity_incdtseverity_id_seq
91231
 
    START WITH 1
91232
 
    INCREMENT BY 1
91233
 
    NO MINVALUE
91234
 
    NO MAXVALUE
91235
 
    CACHE 1;
91236
 
 
91237
 
 
91238
 
ALTER TABLE public.incdtseverity_incdtseverity_id_seq OWNER TO admin;
91239
 
 
91240
 
--
91241
 
--
91242
 
 
91243
 
ALTER SEQUENCE incdtseverity_incdtseverity_id_seq OWNED BY incdtseverity.incdtseverity_id;
91244
 
 
91245
 
 
91246
 
--
91247
 
--
91248
 
 
91249
 
CREATE SEQUENCE invbal_invbal_id_seq
91250
 
    START WITH 1
91251
 
    INCREMENT BY 1
91252
 
    NO MINVALUE
91253
 
    NO MAXVALUE
91254
 
    CACHE 1;
91255
 
 
91256
 
 
91257
 
ALTER TABLE public.invbal_invbal_id_seq OWNER TO admin;
91258
 
 
91259
 
--
91260
 
--
91261
 
 
91262
 
ALTER SEQUENCE invbal_invbal_id_seq OWNED BY invbal.invbal_id;
91263
 
 
91264
 
 
91265
 
--
91266
 
--
91267
 
 
91268
 
CREATE SEQUENCE invc_invc_id_seq
91269
 
    START WITH 1
91270
 
    INCREMENT BY 1
91271
 
    NO MINVALUE
91272
 
    MAXVALUE 2147483647
91273
 
    CACHE 1;
91274
 
 
91275
 
 
91276
 
ALTER TABLE public.invc_invc_id_seq OWNER TO admin;
91277
 
 
91278
 
--
91279
 
--
91280
 
 
91281
 
CREATE SEQUENCE invchead_invchead_id_seq
91282
 
    START WITH 1
91283
 
    INCREMENT BY 1
91284
 
    NO MINVALUE
91285
 
    NO MAXVALUE
91286
 
    CACHE 1;
91287
 
 
91288
 
 
91289
 
ALTER TABLE public.invchead_invchead_id_seq OWNER TO admin;
91290
 
 
91291
 
--
91292
 
--
91293
 
 
91294
 
ALTER SEQUENCE invchead_invchead_id_seq OWNED BY invchead.invchead_id;
91295
 
 
91296
 
 
91297
 
--
91298
 
--
91299
 
 
91300
 
CREATE TABLE invcheadtax (
91301
 
)
91302
 
INHERITS (taxhist);
91303
 
 
91304
 
 
91305
 
ALTER TABLE public.invcheadtax OWNER TO admin;
91306
 
 
91307
 
--
91308
 
--
91309
 
 
91310
 
CREATE SEQUENCE invcitem_invcitem_id_seq
91311
 
    START WITH 1
91312
 
    INCREMENT BY 1
91313
 
    NO MINVALUE
91314
 
    NO MAXVALUE
91315
 
    CACHE 1;
91316
 
 
91317
 
 
91318
 
ALTER TABLE public.invcitem_invcitem_id_seq OWNER TO admin;
91319
 
 
91320
 
--
91321
 
--
91322
 
 
91323
 
ALTER SEQUENCE invcitem_invcitem_id_seq OWNED BY invcitem.invcitem_id;
91324
 
 
91325
 
 
91326
 
--
91327
 
--
91328
 
 
91329
 
CREATE TABLE invcitemtax (
91330
 
)
91331
 
INHERITS (taxhist);
91332
 
 
91333
 
 
91334
 
ALTER TABLE public.invcitemtax OWNER TO admin;
91335
 
 
91336
 
--
91337
 
--
91338
 
 
91339
 
CREATE SEQUENCE invcnt_invcnt_id_seq
91340
 
    START WITH 1
91341
 
    INCREMENT BY 1
91342
 
    NO MINVALUE
91343
 
    MAXVALUE 2147483647
91344
 
    CACHE 1;
91345
 
 
91346
 
 
91347
 
ALTER TABLE public.invcnt_invcnt_id_seq OWNER TO admin;
91348
 
 
91349
 
--
91350
 
--
91351
 
 
91352
 
CREATE TABLE invdetail (
91353
 
    invdetail_id integer DEFAULT nextval(('"invdetail_invdetail_id_seq"'::text)::regclass) NOT NULL,
91354
 
    invdetail_transtype character(2),
91355
 
    invdetail_invhist_id integer,
91356
 
    invdetail_location_id integer,
91357
 
    invdetail_qty numeric(18,6),
91358
 
    invdetail_comments text,
91359
 
    invdetail_qty_before numeric(18,6),
91360
 
    invdetail_qty_after numeric(18,6),
91361
 
    invdetail_invcitem_id integer,
91362
 
    invdetail_expiration date,
91363
 
    invdetail_warrpurc date,
91364
 
    invdetail_ls_id integer
91365
 
);
91366
 
 
91367
 
 
91368
 
ALTER TABLE public.invdetail OWNER TO admin;
91369
 
 
91370
 
--
91371
 
--
91372
 
 
91373
 
COMMENT ON TABLE invdetail IS 'Detailed Inventory transaction information for Lot/Serial and Multiple Location Control (MLC) Items';
91374
 
 
91375
 
 
91376
 
--
91377
 
--
91378
 
 
91379
 
CREATE SEQUENCE invdetail_invdetail_id_seq
91380
 
    START WITH 1
91381
 
    INCREMENT BY 1
91382
 
    NO MINVALUE
91383
 
    MAXVALUE 2147483647
91384
 
    CACHE 1;
91385
 
 
91386
 
 
91387
 
ALTER TABLE public.invdetail_invdetail_id_seq OWNER TO admin;
91388
 
 
91389
 
--
91390
 
--
91391
 
 
91392
 
CREATE TABLE invhist (
91393
 
    invhist_id integer DEFAULT nextval(('invhist_invhist_id_seq'::text)::regclass) NOT NULL,
91394
 
    invhist_itemsite_id integer,
91395
 
    invhist_transdate timestamp with time zone DEFAULT ('now'::text)::timestamp(6) with time zone,
91396
 
    invhist_transtype character(2),
91397
 
    invhist_invqty numeric(18,6),
91398
 
    invhist_invuom text,
91399
 
    invhist_ordnumber text,
91400
 
    invhist_docnumber text,
91401
 
    invhist_qoh_before numeric(18,6),
91402
 
    invhist_qoh_after numeric(18,6),
91403
 
    invhist_unitcost numeric(16,6),
91404
 
    invhist_acct_id integer,
91405
 
    invhist_xfer_warehous_id integer,
91406
 
    invhist_comments text,
91407
 
    invhist_posted boolean DEFAULT true,
91408
 
    invhist_imported boolean,
91409
 
    invhist_hasdetail boolean DEFAULT false,
91410
 
    invhist_ordtype text,
91411
 
    invhist_analyze boolean DEFAULT true,
91412
 
    invhist_user text DEFAULT geteffectivextuser(),
91413
 
    invhist_created timestamp with time zone DEFAULT now() NOT NULL,
91414
 
    invhist_costmethod character(1) NOT NULL,
91415
 
    invhist_value_before numeric(12,2) NOT NULL,
91416
 
    invhist_value_after numeric(12,2) NOT NULL,
91417
 
    invhist_series integer
91418
 
);
91419
 
 
91420
 
 
91421
 
ALTER TABLE public.invhist OWNER TO admin;
91422
 
 
91423
 
--
91424
 
--
91425
 
 
91426
 
COMMENT ON TABLE invhist IS 'Inventory transaction history';
91427
 
 
91428
 
 
91429
 
--
91430
 
--
91431
 
 
91432
 
CREATE SEQUENCE invhist_invhist_id_seq
91433
 
    START WITH 1
91434
 
    INCREMENT BY 1
91435
 
    NO MINVALUE
91436
 
    MAXVALUE 2147483647
91437
 
    CACHE 1;
91438
 
 
91439
 
 
91440
 
ALTER TABLE public.invhist_invhist_id_seq OWNER TO admin;
91441
 
 
91442
 
--
91443
 
--
91444
 
 
91445
 
CREATE TABLE invhistexpcat (
91446
 
    invhistexpcat_id integer NOT NULL,
91447
 
    invhistexpcat_invhist_id integer NOT NULL,
91448
 
    invhistexpcat_expcat_id integer NOT NULL
91449
 
);
91450
 
 
91451
 
 
91452
 
ALTER TABLE public.invhistexpcat OWNER TO admin;
91453
 
 
91454
 
--
91455
 
--
91456
 
 
91457
 
COMMENT ON TABLE invhistexpcat IS 'Track the relationship between an EX transaction in the invhist table and the corresponding Expense Category.';
91458
 
 
91459
 
 
91460
 
--
91461
 
--
91462
 
 
91463
 
CREATE SEQUENCE invhistexpcat_invhistexpcat_id_seq
91464
 
    START WITH 1
91465
 
    INCREMENT BY 1
91466
 
    NO MINVALUE
91467
 
    NO MAXVALUE
91468
 
    CACHE 1;
91469
 
 
91470
 
 
91471
 
ALTER TABLE public.invhistexpcat_invhistexpcat_id_seq OWNER TO admin;
91472
 
 
91473
 
--
91474
 
--
91475
 
 
91476
 
ALTER SEQUENCE invhistexpcat_invhistexpcat_id_seq OWNED BY invhistexpcat.invhistexpcat_id;
91477
 
 
91478
 
 
91479
 
--
91480
 
--
91481
 
 
91482
 
CREATE VIEW invoiceitem AS
91483
 
    SELECT invcitem.invcitem_id, invcitem.invcitem_invchead_id, invcitem.invcitem_linenumber, invcitem.invcitem_item_id, invcitem.invcitem_warehous_id, invcitem.invcitem_custpn, invcitem.invcitem_number, invcitem.invcitem_descrip, invcitem.invcitem_ordered, invcitem.invcitem_billed, invcitem.invcitem_custprice, invcitem.invcitem_price, invcitem.invcitem_notes, invcitem.invcitem_salescat_id, invcitem.invcitem_taxtype_id, invcitem.invcitem_qty_uom_id, invcitem.invcitem_qty_invuomratio, invcitem.invcitem_price_uom_id, invcitem.invcitem_price_invuomratio, invcitem.invcitem_coitem_id, invcitem.invcitem_updateinv, invcitem.invcitem_rev_accnt_id, itemsite.itemsite_id, cohead.cohead_number, COALESCE((invcitem.invcitem_billed * invcitem.invcitem_qty_invuomratio), (0)::numeric) AS qty, COALESCE((invcitem.invcitem_price / invcitem.invcitem_price_invuomratio), (0)::numeric) AS unitprice, COALESCE(round(((invcitem.invcitem_billed * invcitem.invcitem_qty_invuomratio) * (invcitem.invcitem_price / invcitem.invcitem_price_invuomratio)), 2), (0)::numeric) AS extprice, currtobase(invchead.invchead_curr_id, COALESCE(round(((invcitem.invcitem_billed * invcitem.invcitem_qty_invuomratio) * (invcitem.invcitem_price / invcitem.invcitem_price_invuomratio)), 2), (0)::numeric), invchead.invchead_invcdate) AS baseextprice, (SELECT COALESCE(sum(invcitemtax.taxhist_tax), (0)::numeric) AS "coalesce" FROM invcitemtax WHERE (invcitemtax.taxhist_parent_id = invcitem.invcitem_id)) AS tax, ((SELECT COALESCE(sum(shipitem.shipitem_value), (itemcost(itemsite.itemsite_id) * invcitem.invcitem_billed), (0)::numeric) AS "coalesce" FROM shipitem WHERE (shipitem.shipitem_invcitem_id = invcitem.invcitem_id)) / CASE WHEN (invcitem.invcitem_billed <> (0)::numeric) THEN (invcitem.invcitem_billed * invcitem.invcitem_qty_invuomratio) ELSE (1)::numeric END) AS unitcost FROM ((((invcitem JOIN invchead ON ((invchead.invchead_id = invcitem.invcitem_invchead_id))) LEFT JOIN coitem ON ((coitem.coitem_id = invcitem.invcitem_coitem_id))) LEFT JOIN cohead ON ((cohead.cohead_id = coitem.coitem_cohead_id))) LEFT JOIN itemsite ON (((itemsite.itemsite_item_id = invcitem.invcitem_item_id) AND (itemsite.itemsite_warehous_id = invcitem.invcitem_warehous_id))));
91484
 
 
91485
 
 
91486
 
ALTER TABLE public.invoiceitem OWNER TO admin;
91487
 
 
91488
 
--
91489
 
--
91490
 
 
91491
 
COMMENT ON VIEW invoiceitem IS 'Single point for invoice item (invcitem) calculations.';
91492
 
 
91493
 
 
91494
 
--
91495
 
--
91496
 
 
91497
 
CREATE SEQUENCE ipsass_ipsass_id_seq
91498
 
    START WITH 1
91499
 
    INCREMENT BY 1
91500
 
    NO MINVALUE
91501
 
    NO MAXVALUE
91502
 
    CACHE 1;
91503
 
 
91504
 
 
91505
 
ALTER TABLE public.ipsass_ipsass_id_seq OWNER TO admin;
91506
 
 
91507
 
--
91508
 
--
91509
 
 
91510
 
ALTER SEQUENCE ipsass_ipsass_id_seq OWNED BY ipsass.ipsass_id;
91511
 
 
91512
 
 
91513
 
--
91514
 
--
91515
 
 
91516
 
CREATE SEQUENCE ipsctyp_ipsctyp_id_seq
91517
 
    START WITH 1
91518
 
    INCREMENT BY 1
91519
 
    NO MINVALUE
91520
 
    NO MAXVALUE
91521
 
    CACHE 1;
91522
 
 
91523
 
 
91524
 
ALTER TABLE public.ipsctyp_ipsctyp_id_seq OWNER TO admin;
91525
 
 
91526
 
--
91527
 
--
91528
 
 
91529
 
CREATE SEQUENCE ipscust_ipscust_id_seq
91530
 
    START WITH 1
91531
 
    INCREMENT BY 1
91532
 
    NO MINVALUE
91533
 
    NO MAXVALUE
91534
 
    CACHE 1;
91535
 
 
91536
 
 
91537
 
ALTER TABLE public.ipscust_ipscust_id_seq OWNER TO admin;
91538
 
 
91539
 
--
91540
 
--
91541
 
 
91542
 
CREATE SEQUENCE ipsfreight_ipsfreight_id_seq
91543
 
    START WITH 1
91544
 
    INCREMENT BY 1
91545
 
    NO MINVALUE
91546
 
    NO MAXVALUE
91547
 
    CACHE 1;
91548
 
 
91549
 
 
91550
 
ALTER TABLE public.ipsfreight_ipsfreight_id_seq OWNER TO admin;
91551
 
 
91552
 
--
91553
 
--
91554
 
 
91555
 
ALTER SEQUENCE ipsfreight_ipsfreight_id_seq OWNED BY ipsfreight.ipsfreight_id;
91556
 
 
91557
 
 
91558
 
--
91559
 
--
91560
 
 
91561
 
CREATE SEQUENCE ipshead_ipshead_id_seq
91562
 
    START WITH 1
91563
 
    INCREMENT BY 1
91564
 
    NO MINVALUE
91565
 
    NO MAXVALUE
91566
 
    CACHE 1;
91567
 
 
91568
 
 
91569
 
ALTER TABLE public.ipshead_ipshead_id_seq OWNER TO admin;
91570
 
 
91571
 
--
91572
 
--
91573
 
 
91574
 
CREATE SEQUENCE ipsitem_ipsitem_id_seq
91575
 
    START WITH 1
91576
 
    INCREMENT BY 1
91577
 
    NO MINVALUE
91578
 
    NO MAXVALUE
91579
 
    CACHE 1;
91580
 
 
91581
 
 
91582
 
ALTER TABLE public.ipsitem_ipsitem_id_seq OWNER TO admin;
91583
 
 
91584
 
--
91585
 
--
91586
 
 
91587
 
CREATE SEQUENCE ipsitemchar_ipsitemchar_id_seq
91588
 
    START WITH 1
91589
 
    INCREMENT BY 1
91590
 
    NO MINVALUE
91591
 
    NO MAXVALUE
91592
 
    CACHE 1;
91593
 
 
91594
 
 
91595
 
ALTER TABLE public.ipsitemchar_ipsitemchar_id_seq OWNER TO admin;
91596
 
 
91597
 
--
91598
 
--
91599
 
 
91600
 
ALTER SEQUENCE ipsitemchar_ipsitemchar_id_seq OWNED BY ipsitemchar.ipsitemchar_id;
91601
 
 
91602
 
 
91603
 
--
91604
 
--
91605
 
 
91606
 
CREATE VIEW ipsprice AS
91607
 
    SELECT ipsiteminfo.ipsitem_id AS ipsprice_id, 'I'::text AS ipsprice_source, ipsiteminfo.ipsitem_ipshead_id AS ipsprice_ipshead_id, ipsiteminfo.ipsitem_item_id AS ipsprice_item_id, itemuomtouom(ipsiteminfo.ipsitem_item_id, ipsiteminfo.ipsitem_qty_uom_id, NULL::integer, ipsiteminfo.ipsitem_qtybreak) AS ipsprice_qtybreak, CASE WHEN (ipsiteminfo.ipsitem_type = 'N'::bpchar) THEN ((ipsiteminfo.ipsitem_price * itemuomtouomratio(ipsiteminfo.ipsitem_item_id, NULL::integer, ipsiteminfo.ipsitem_price_uom_id)) * iteminvpricerat(ipsiteminfo.ipsitem_item_id)) WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN ((item.item_listprice - (item.item_listprice * ipsiteminfo.ipsitem_discntprcnt)) - ipsiteminfo.ipsitem_fixedamtdiscount) WHEN ((ipsiteminfo.ipsitem_type = 'M'::bpchar) AND fetchmetricbool('Long30Markups'::text)) THEN ((stdcost(item.item_id) / (1.0 - ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN ((item.item_listcost + (item.item_listcost * ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) ELSE NULL::numeric END AS ipsprice_price, ipsiteminfo.ipsitem_qtybreak AS ipsprice_uomqtybreak, ipsiteminfo.ipsitem_qty_uom_id AS ipsprice_uomqtybreak_uom_id, CASE WHEN (ipsiteminfo.ipsitem_type = 'N'::bpchar) THEN ipsiteminfo.ipsitem_price WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN ((item.item_listprice - (item.item_listprice * ipsiteminfo.ipsitem_discntprcnt)) - ipsiteminfo.ipsitem_fixedamtdiscount) WHEN ((ipsiteminfo.ipsitem_type = 'M'::bpchar) AND fetchmetricbool('Long30Markups'::text)) THEN ((stdcost(item.item_id) / (1.0 - ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN ((item.item_listcost + (item.item_listcost * ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) ELSE NULL::numeric END AS ipsprice_uomprice, ipsiteminfo.ipsitem_price_uom_id AS ipsprice_uomprice_uom_id, ipsiteminfo.ipsitem_discntprcnt AS ipsprice_discountpercent, ipsiteminfo.ipsitem_fixedamtdiscount AS ipsprice_discountfixed, ipsiteminfo.ipsitem_type AS ipsprice_type FROM (ipsiteminfo JOIN item ON ((item.item_id = ipsiteminfo.ipsitem_item_id))) UNION SELECT ipsiteminfo.ipsitem_id AS ipsprice_id, 'P'::text AS ipsprice_source, ipsiteminfo.ipsitem_ipshead_id AS ipsprice_ipshead_id, item.item_id AS ipsprice_item_id, ipsiteminfo.ipsitem_qtybreak AS ipsprice_qtybreak, CASE WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN ((item.item_listprice - (item.item_listprice * ipsiteminfo.ipsitem_discntprcnt)) - ipsiteminfo.ipsitem_fixedamtdiscount) WHEN ((ipsiteminfo.ipsitem_type = 'M'::bpchar) AND fetchmetricbool('Long30Markups'::text)) THEN ((stdcost(item.item_id) / (1.0 - ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN ((item.item_listcost + (item.item_listcost * ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) ELSE NULL::numeric END AS ipsprice_price, ipsiteminfo.ipsitem_qtybreak AS ipsprice_uomqtybreak, item.item_inv_uom_id AS ipsprice_uomqtybreak_uom_id, CASE WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN ((item.item_listprice - (item.item_listprice * ipsiteminfo.ipsitem_discntprcnt)) - ipsiteminfo.ipsitem_fixedamtdiscount) WHEN ((ipsiteminfo.ipsitem_type = 'M'::bpchar) AND fetchmetricbool('Long30Markups'::text)) THEN ((stdcost(item.item_id) / (1.0 - ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN ((item.item_listcost + (item.item_listcost * ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) ELSE NULL::numeric END AS ipsprice_uomprice, item.item_price_uom_id AS ipsprice_uomprice_uom_id, ipsiteminfo.ipsitem_discntprcnt AS ipsprice_discountpercent, ipsiteminfo.ipsitem_fixedamtdiscount AS ipsprice_discountfixed, ipsiteminfo.ipsitem_type AS ipsprice_type FROM (ipsiteminfo JOIN item ON ((ipsiteminfo.ipsitem_prodcat_id = item.item_prodcat_id)));
91608
 
 
91609
 
 
91610
 
ALTER TABLE public.ipsprice OWNER TO admin;
91611
 
 
91612
 
--
91613
 
--
91614
 
 
91615
 
CREATE TABLE ipsprodcat_bak (
91616
 
    ipsprodcat_id integer NOT NULL,
91617
 
    ipsprodcat_ipshead_id integer NOT NULL,
91618
 
    ipsprodcat_prodcat_id integer NOT NULL,
91619
 
    ipsprodcat_qtybreak numeric(18,6) NOT NULL,
91620
 
    ipsprodcat_discntprcnt numeric(10,6) NOT NULL,
91621
 
    ipsprodcat_fixedamtdiscount numeric(16,4) DEFAULT 0.00 NOT NULL
91622
 
);
91623
 
 
91624
 
 
91625
 
ALTER TABLE public.ipsprodcat_bak OWNER TO admin;
91626
 
 
91627
 
--
91628
 
--
91629
 
 
91630
 
COMMENT ON TABLE ipsprodcat_bak IS 'Pricing Schedule Product Category information.';
91631
 
 
91632
 
 
91633
 
--
91634
 
--
91635
 
 
91636
 
CREATE SEQUENCE ipsprodcat_ipsprodcat_id_seq
91637
 
    START WITH 1
91638
 
    INCREMENT BY 1
91639
 
    NO MINVALUE
91640
 
    NO MAXVALUE
91641
 
    CACHE 1;
91642
 
 
91643
 
 
91644
 
ALTER TABLE public.ipsprodcat_ipsprodcat_id_seq OWNER TO admin;
91645
 
 
91646
 
--
91647
 
--
91648
 
 
91649
 
ALTER SEQUENCE ipsprodcat_ipsprodcat_id_seq OWNED BY ipsprodcat_bak.ipsprodcat_id;
91650
 
 
91651
 
 
91652
 
--
91653
 
--
91654
 
 
91655
 
CREATE SEQUENCE item_item_id_seq
91656
 
    START WITH 1
91657
 
    INCREMENT BY 1
91658
 
    NO MINVALUE
91659
 
    MAXVALUE 2147483647
91660
 
    CACHE 1;
91661
 
 
91662
 
 
91663
 
ALTER TABLE public.item_item_id_seq OWNER TO admin;
91664
 
 
91665
 
--
91666
 
--
91667
 
 
91668
 
CREATE SEQUENCE itemalias_itemalias_id_seq
91669
 
    START WITH 1
91670
 
    INCREMENT BY 1
91671
 
    NO MINVALUE
91672
 
    MAXVALUE 2147483647
91673
 
    CACHE 1;
91674
 
 
91675
 
 
91676
 
ALTER TABLE public.itemalias_itemalias_id_seq OWNER TO admin;
91677
 
 
91678
 
--
91679
 
--
91680
 
 
91681
 
CREATE SEQUENCE itematr_itematr_id_seq
91682
 
    START WITH 1
91683
 
    INCREMENT BY 1
91684
 
    NO MINVALUE
91685
 
    MAXVALUE 2147483647
91686
 
    CACHE 1;
91687
 
 
91688
 
 
91689
 
ALTER TABLE public.itematr_itematr_id_seq OWNER TO admin;
91690
 
 
91691
 
--
91692
 
--
91693
 
 
91694
 
CREATE SEQUENCE itemcost_itemcost_id_seq
91695
 
    START WITH 1
91696
 
    INCREMENT BY 1
91697
 
    NO MINVALUE
91698
 
    MAXVALUE 2147483647
91699
 
    CACHE 1;
91700
 
 
91701
 
 
91702
 
ALTER TABLE public.itemcost_itemcost_id_seq OWNER TO admin;
91703
 
 
91704
 
--
91705
 
--
91706
 
 
91707
 
CREATE SEQUENCE itemfrez_itemfrez_seq
91708
 
    START WITH 1
91709
 
    INCREMENT BY 1
91710
 
    NO MINVALUE
91711
 
    MAXVALUE 2147483647
91712
 
    CACHE 1;
91713
 
 
91714
 
 
91715
 
ALTER TABLE public.itemfrez_itemfrez_seq OWNER TO admin;
91716
 
 
91717
 
--
91718
 
--
91719
 
 
91720
 
CREATE TABLE itemgrp (
91721
 
    itemgrp_id integer DEFAULT nextval(('"itemgrp_itemgrp_id_seq"'::text)::regclass) NOT NULL,
91722
 
    itemgrp_name text NOT NULL,
91723
 
    itemgrp_descrip text,
91724
 
    itemgrp_catalog boolean DEFAULT false NOT NULL,
91725
 
    CONSTRAINT itemgrp_itemgrp_name_check CHECK ((itemgrp_name <> ''::text))
91726
 
);
91727
 
 
91728
 
 
91729
 
ALTER TABLE public.itemgrp OWNER TO admin;
91730
 
 
91731
 
--
91732
 
--
91733
 
 
91734
 
COMMENT ON TABLE itemgrp IS 'Item Group information';
91735
 
 
91736
 
 
91737
 
--
91738
 
--
91739
 
 
91740
 
CREATE SEQUENCE itemgrp_itemgrp_id_seq
91741
 
    START WITH 1
91742
 
    INCREMENT BY 1
91743
 
    NO MINVALUE
91744
 
    MAXVALUE 2147483647
91745
 
    CACHE 1;
91746
 
 
91747
 
 
91748
 
ALTER TABLE public.itemgrp_itemgrp_id_seq OWNER TO admin;
91749
 
 
91750
 
--
91751
 
--
91752
 
 
91753
 
CREATE TABLE itemgrpitem (
91754
 
    itemgrpitem_id integer DEFAULT nextval(('"itemgrpitem_itemgrpitem_id_seq"'::text)::regclass) NOT NULL,
91755
 
    itemgrpitem_itemgrp_id integer,
91756
 
    itemgrpitem_item_id integer,
91757
 
    itemgrpitem_item_type character(1) DEFAULT 'I'::bpchar NOT NULL,
91758
 
    CONSTRAINT itemgrpitem_valid_item_type CHECK ((itemgrpitem_item_type = ANY (ARRAY['I'::bpchar, 'G'::bpchar])))
91759
 
);
91760
 
 
91761
 
 
91762
 
ALTER TABLE public.itemgrpitem OWNER TO admin;
91763
 
 
91764
 
--
91765
 
--
91766
 
 
91767
 
COMMENT ON TABLE itemgrpitem IS 'Item Group Item information';
91768
 
 
91769
 
 
91770
 
--
91771
 
--
91772
 
 
91773
 
CREATE SEQUENCE itemgrpitem_itemgrpitem_id_seq
91774
 
    START WITH 1
91775
 
    INCREMENT BY 1
91776
 
    NO MINVALUE
91777
 
    MAXVALUE 2147483647
91778
 
    CACHE 1;
91779
 
 
91780
 
 
91781
 
ALTER TABLE public.itemgrpitem_itemgrpitem_id_seq OWNER TO admin;
91782
 
 
91783
 
--
91784
 
--
91785
 
 
91786
 
CREATE VIEW itemimage AS
91787
 
    SELECT imageass.imageass_id AS itemimage_id, imageass.imageass_source_id AS itemimage_item_id, imageass.imageass_image_id AS itemimage_image_id, imageass.imageass_purpose AS itemimage_purpose FROM imageass WHERE (imageass.imageass_source = 'I'::text);
91788
 
 
91789
 
 
91790
 
ALTER TABLE public.itemimage OWNER TO admin;
91791
 
 
91792
 
--
91793
 
--
91794
 
 
91795
 
COMMENT ON VIEW itemimage IS 'Itemimage view for legacy support. Use of itemimage is deprecated. Use imageass table for future development';
91796
 
 
91797
 
 
91798
 
--
91799
 
--
91800
 
 
91801
 
CREATE SEQUENCE itemimage_itemimage_id_seq
91802
 
    START WITH 1
91803
 
    INCREMENT BY 1
91804
 
    NO MINVALUE
91805
 
    NO MAXVALUE
91806
 
    CACHE 1;
91807
 
 
91808
 
 
91809
 
ALTER TABLE public.itemimage_itemimage_id_seq OWNER TO admin;
91810
 
 
91811
 
--
91812
 
--
91813
 
 
91814
 
CREATE TABLE itemloc (
91815
 
    itemloc_id integer DEFAULT nextval(('"itemloc_itemloc_id_seq"'::text)::regclass) NOT NULL,
91816
 
    itemloc_itemsite_id integer NOT NULL,
91817
 
    itemloc_location_id integer NOT NULL,
91818
 
    itemloc_qty numeric(18,6) NOT NULL,
91819
 
    itemloc_expiration date NOT NULL,
91820
 
    itemloc_consolflag boolean,
91821
 
    itemloc_ls_id integer,
91822
 
    itemloc_warrpurc date
91823
 
);
91824
 
 
91825
 
 
91826
 
ALTER TABLE public.itemloc OWNER TO admin;
91827
 
 
91828
 
--
91829
 
--
91830
 
 
91831
 
COMMENT ON TABLE itemloc IS 'Detailed Location information for Lot/Serial and Multiple Location Control (MLC) Items';
91832
 
 
91833
 
 
91834
 
--
91835
 
--
91836
 
 
91837
 
CREATE SEQUENCE itemloc_itemloc_id_seq
91838
 
    START WITH 1
91839
 
    INCREMENT BY 1
91840
 
    NO MINVALUE
91841
 
    NO MAXVALUE
91842
 
    CACHE 1;
91843
 
 
91844
 
 
91845
 
ALTER TABLE public.itemloc_itemloc_id_seq OWNER TO admin;
91846
 
 
91847
 
--
91848
 
--
91849
 
 
91850
 
CREATE SEQUENCE itemloc_series_seq
91851
 
    START WITH 1
91852
 
    INCREMENT BY 1
91853
 
    NO MINVALUE
91854
 
    MAXVALUE 2147483647
91855
 
    CACHE 1;
91856
 
 
91857
 
 
91858
 
ALTER TABLE public.itemloc_series_seq OWNER TO admin;
91859
 
 
91860
 
--
91861
 
--
91862
 
 
91863
 
CREATE TABLE itemlocdist (
91864
 
    itemlocdist_id integer DEFAULT nextval(('"itemlocdist_itemlocdist_id_seq"'::text)::regclass) NOT NULL,
91865
 
    itemlocdist_itemlocdist_id integer,
91866
 
    itemlocdist_source_type character(1),
91867
 
    itemlocdist_source_id integer,
91868
 
    itemlocdist_qty numeric(18,6),
91869
 
    itemlocdist_series integer,
91870
 
    itemlocdist_invhist_id integer,
91871
 
    itemlocdist_itemsite_id integer,
91872
 
    itemlocdist_reqlotserial boolean DEFAULT false,
91873
 
    itemlocdist_flush boolean DEFAULT false,
91874
 
    itemlocdist_expiration date,
91875
 
    itemlocdist_distlotserial boolean,
91876
 
    itemlocdist_warranty date,
91877
 
    itemlocdist_ls_id integer,
91878
 
    itemlocdist_order_type text,
91879
 
    itemlocdist_order_id integer
91880
 
);
91881
 
 
91882
 
 
91883
 
ALTER TABLE public.itemlocdist OWNER TO admin;
91884
 
 
91885
 
--
91886
 
--
91887
 
 
91888
 
COMMENT ON TABLE itemlocdist IS 'Temporary table for storing information about Inventory distributions involving Lot/Serial and Multiple Location Control (MLC) Items';
91889
 
 
91890
 
 
91891
 
--
91892
 
--
91893
 
 
91894
 
CREATE SEQUENCE itemlocdist_itemlocdist_id_seq
91895
 
    START WITH 1
91896
 
    INCREMENT BY 1
91897
 
    NO MINVALUE
91898
 
    NO MAXVALUE
91899
 
    CACHE 1;
91900
 
 
91901
 
 
91902
 
ALTER TABLE public.itemlocdist_itemlocdist_id_seq OWNER TO admin;
91903
 
 
91904
 
--
91905
 
--
91906
 
 
91907
 
CREATE TABLE itemlocpost (
91908
 
    itemlocpost_id integer NOT NULL,
91909
 
    itemlocpost_itemlocseries integer,
91910
 
    itemlocpost_glseq integer
91911
 
);
91912
 
 
91913
 
 
91914
 
ALTER TABLE public.itemlocpost OWNER TO admin;
91915
 
 
91916
 
--
91917
 
--
91918
 
 
91919
 
COMMENT ON TABLE itemlocpost IS 'Temporary table for storing information about Inventory distribution G/L postings involving Lot/Serial and Multiple Location Control (MLC) Items';
91920
 
 
91921
 
 
91922
 
--
91923
 
--
91924
 
 
91925
 
CREATE SEQUENCE itemlocpost_itemlocpost_id_seq
91926
 
    START WITH 1
91927
 
    INCREMENT BY 1
91928
 
    NO MINVALUE
91929
 
    NO MAXVALUE
91930
 
    CACHE 1;
91931
 
 
91932
 
 
91933
 
ALTER TABLE public.itemlocpost_itemlocpost_id_seq OWNER TO admin;
91934
 
 
91935
 
--
91936
 
--
91937
 
 
91938
 
ALTER SEQUENCE itemlocpost_itemlocpost_id_seq OWNED BY itemlocpost.itemlocpost_id;
91939
 
 
91940
 
 
91941
 
--
91942
 
--
91943
 
 
91944
 
CREATE SEQUENCE itemopn_itemopn_id_seq
91945
 
    START WITH 1
91946
 
    INCREMENT BY 1
91947
 
    NO MINVALUE
91948
 
    MAXVALUE 2147483647
91949
 
    CACHE 1;
91950
 
 
91951
 
 
91952
 
ALTER TABLE public.itemopn_itemopn_id_seq OWNER TO admin;
91953
 
 
91954
 
--
91955
 
--
91956
 
 
91957
 
CREATE SEQUENCE itemsite_itemsite_id_seq
91958
 
    START WITH 1
91959
 
    INCREMENT BY 1
91960
 
    NO MINVALUE
91961
 
    MAXVALUE 2147483647
91962
 
    CACHE 1;
91963
 
 
91964
 
 
91965
 
ALTER TABLE public.itemsite_itemsite_id_seq OWNER TO admin;
91966
 
 
91967
 
--
91968
 
--
91969
 
 
91970
 
CREATE SEQUENCE itemsrc_itemsrc_id_seq
91971
 
    START WITH 1
91972
 
    INCREMENT BY 1
91973
 
    NO MINVALUE
91974
 
    MAXVALUE 2147483647
91975
 
    CACHE 1;
91976
 
 
91977
 
 
91978
 
ALTER TABLE public.itemsrc_itemsrc_id_seq OWNER TO admin;
91979
 
 
91980
 
--
91981
 
--
91982
 
 
91983
 
CREATE SEQUENCE itemsrcp_itemsrcp_id_seq
91984
 
    START WITH 1
91985
 
    INCREMENT BY 1
91986
 
    NO MINVALUE
91987
 
    MAXVALUE 2147483647
91988
 
    CACHE 1;
91989
 
 
91990
 
 
91991
 
ALTER TABLE public.itemsrcp_itemsrcp_id_seq OWNER TO admin;
91992
 
 
91993
 
--
91994
 
--
91995
 
 
91996
 
CREATE SEQUENCE itemsub_itemsub_id_seq
91997
 
    START WITH 1
91998
 
    INCREMENT BY 1
91999
 
    NO MINVALUE
92000
 
    MAXVALUE 2147483647
92001
 
    CACHE 1;
92002
 
 
92003
 
 
92004
 
ALTER TABLE public.itemsub_itemsub_id_seq OWNER TO admin;
92005
 
 
92006
 
--
92007
 
--
92008
 
 
92009
 
CREATE SEQUENCE itemtax_itemtax_id_seq
92010
 
    START WITH 1
92011
 
    INCREMENT BY 1
92012
 
    NO MINVALUE
92013
 
    NO MAXVALUE
92014
 
    CACHE 1;
92015
 
 
92016
 
 
92017
 
ALTER TABLE public.itemtax_itemtax_id_seq OWNER TO admin;
92018
 
 
92019
 
--
92020
 
--
92021
 
 
92022
 
ALTER SEQUENCE itemtax_itemtax_id_seq OWNED BY itemtax.itemtax_id;
92023
 
 
92024
 
 
92025
 
--
92026
 
--
92027
 
 
92028
 
CREATE TABLE itemtrans (
92029
 
    itemtrans_id integer NOT NULL,
92030
 
    itemtrans_source_item_id integer,
92031
 
    itemtrans_target_item_id integer
92032
 
);
92033
 
 
92034
 
 
92035
 
ALTER TABLE public.itemtrans OWNER TO admin;
92036
 
 
92037
 
--
92038
 
--
92039
 
 
92040
 
COMMENT ON TABLE itemtrans IS 'Item Transformation information';
92041
 
 
92042
 
 
92043
 
--
92044
 
--
92045
 
 
92046
 
CREATE SEQUENCE itemtrans_itemtrans_id_seq
92047
 
    START WITH 1
92048
 
    INCREMENT BY 1
92049
 
    NO MINVALUE
92050
 
    NO MAXVALUE
92051
 
    CACHE 1;
92052
 
 
92053
 
 
92054
 
ALTER TABLE public.itemtrans_itemtrans_id_seq OWNER TO admin;
92055
 
 
92056
 
--
92057
 
--
92058
 
 
92059
 
ALTER SEQUENCE itemtrans_itemtrans_id_seq OWNED BY itemtrans.itemtrans_id;
92060
 
 
92061
 
 
92062
 
--
92063
 
--
92064
 
 
92065
 
CREATE TABLE itemuom (
92066
 
    itemuom_id integer NOT NULL,
92067
 
    itemuom_itemuomconv_id integer NOT NULL,
92068
 
    itemuom_uomtype_id integer NOT NULL
92069
 
);
92070
 
 
92071
 
 
92072
 
ALTER TABLE public.itemuom OWNER TO admin;
92073
 
 
92074
 
--
92075
 
--
92076
 
 
92077
 
COMMENT ON TABLE itemuom IS 'A UOM type relation for a specific conversion.';
92078
 
 
92079
 
 
92080
 
--
92081
 
--
92082
 
 
92083
 
CREATE SEQUENCE itemuom_itemuom_id_seq
92084
 
    START WITH 1
92085
 
    INCREMENT BY 1
92086
 
    NO MINVALUE
92087
 
    NO MAXVALUE
92088
 
    CACHE 1;
92089
 
 
92090
 
 
92091
 
ALTER TABLE public.itemuom_itemuom_id_seq OWNER TO admin;
92092
 
 
92093
 
--
92094
 
--
92095
 
 
92096
 
ALTER SEQUENCE itemuom_itemuom_id_seq OWNED BY itemuom.itemuom_id;
92097
 
 
92098
 
 
92099
 
--
92100
 
--
92101
 
 
92102
 
CREATE SEQUENCE itemuomconv_itemuomconv_id_seq
92103
 
    START WITH 1
92104
 
    INCREMENT BY 1
92105
 
    NO MINVALUE
92106
 
    NO MAXVALUE
92107
 
    CACHE 1;
92108
 
 
92109
 
 
92110
 
ALTER TABLE public.itemuomconv_itemuomconv_id_seq OWNER TO admin;
92111
 
 
92112
 
--
92113
 
--
92114
 
 
92115
 
ALTER SEQUENCE itemuomconv_itemuomconv_id_seq OWNED BY itemuomconv.itemuomconv_id;
92116
 
 
92117
 
 
92118
 
--
92119
 
--
92120
 
 
92121
 
CREATE SEQUENCE journal_number_seq
92122
 
    START WITH 1
92123
 
    INCREMENT BY 1
92124
 
    NO MINVALUE
92125
 
    NO MAXVALUE
92126
 
    CACHE 1;
92127
 
 
92128
 
 
92129
 
ALTER TABLE public.journal_number_seq OWNER TO admin;
92130
 
 
92131
 
--
92132
 
--
92133
 
 
92134
 
CREATE TABLE jrnluse (
92135
 
    jrnluse_id integer DEFAULT nextval(('"jrnluse_jrnluse_id_seq"'::text)::regclass) NOT NULL,
92136
 
    jrnluse_date timestamp without time zone,
92137
 
    jrnluse_number integer,
92138
 
    jrnluse_use text
92139
 
);
92140
 
 
92141
 
 
92142
 
ALTER TABLE public.jrnluse OWNER TO admin;
92143
 
 
92144
 
--
92145
 
--
92146
 
 
92147
 
COMMENT ON TABLE jrnluse IS 'Journal entry and use information';
92148
 
 
92149
 
 
92150
 
--
92151
 
--
92152
 
 
92153
 
CREATE SEQUENCE jrnluse_jrnluse_id_seq
92154
 
    START WITH 1
92155
 
    INCREMENT BY 1
92156
 
    NO MINVALUE
92157
 
    NO MAXVALUE
92158
 
    CACHE 1;
92159
 
 
92160
 
 
92161
 
ALTER TABLE public.jrnluse_jrnluse_id_seq OWNER TO admin;
92162
 
 
92163
 
--
92164
 
--
92165
 
 
92166
 
CREATE TABLE labeldef (
92167
 
    labeldef_id integer NOT NULL,
92168
 
    labeldef_name text NOT NULL,
92169
 
    labeldef_papersize text NOT NULL,
92170
 
    labeldef_columns integer NOT NULL,
92171
 
    labeldef_rows integer NOT NULL,
92172
 
    labeldef_width integer NOT NULL,
92173
 
    labeldef_height integer NOT NULL,
92174
 
    labeldef_start_offset_x integer NOT NULL,
92175
 
    labeldef_start_offset_y integer NOT NULL,
92176
 
    labeldef_horizontal_gap integer NOT NULL,
92177
 
    labeldef_vertical_gap integer NOT NULL
92178
 
);
92179
 
 
92180
 
 
92181
 
ALTER TABLE public.labeldef OWNER TO admin;
92182
 
 
92183
 
--
92184
 
--
92185
 
 
92186
 
CREATE SEQUENCE labeldef_labeldef_id_seq
92187
 
    START WITH 1
92188
 
    INCREMENT BY 1
92189
 
    NO MINVALUE
92190
 
    NO MAXVALUE
92191
 
    CACHE 1;
92192
 
 
92193
 
 
92194
 
ALTER TABLE public.labeldef_labeldef_id_seq OWNER TO admin;
92195
 
 
92196
 
--
92197
 
--
92198
 
 
92199
 
ALTER SEQUENCE labeldef_labeldef_id_seq OWNED BY labeldef.labeldef_id;
92200
 
 
92201
 
 
92202
 
--
92203
 
--
92204
 
 
92205
 
CREATE TABLE labelform (
92206
 
    labelform_id integer DEFAULT nextval(('"labelform_labelform_id_seq"'::text)::regclass) NOT NULL,
92207
 
    labelform_name text NOT NULL,
92208
 
    labelform_report_id integer,
92209
 
    labelform_perpage integer,
92210
 
    labelform_report_name text,
92211
 
    CONSTRAINT labelform_labelform_name_check CHECK ((labelform_name <> ''::text))
92212
 
);
92213
 
 
92214
 
 
92215
 
ALTER TABLE public.labelform OWNER TO admin;
92216
 
 
92217
 
--
92218
 
--
92219
 
 
92220
 
COMMENT ON TABLE labelform IS 'Label Form information';
92221
 
 
92222
 
 
92223
 
--
92224
 
--
92225
 
 
92226
 
COMMENT ON COLUMN labelform.labelform_report_id IS 'Obsolete -- reference labelform_report_name instead.';
92227
 
 
92228
 
 
92229
 
--
92230
 
--
92231
 
 
92232
 
CREATE SEQUENCE labelform_labelform_id_seq
92233
 
    START WITH 1
92234
 
    INCREMENT BY 1
92235
 
    NO MINVALUE
92236
 
    NO MAXVALUE
92237
 
    CACHE 1;
92238
 
 
92239
 
 
92240
 
ALTER TABLE public.labelform_labelform_id_seq OWNER TO admin;
92241
 
 
92242
 
--
92243
 
--
92244
 
 
92245
 
CREATE TABLE lang (
92246
 
    lang_id integer NOT NULL,
92247
 
    lang_qt_number integer,
92248
 
    lang_abbr3 text,
92249
 
    lang_abbr2 text,
92250
 
    lang_name text NOT NULL
92251
 
);
92252
 
 
92253
 
 
92254
 
ALTER TABLE public.lang OWNER TO admin;
92255
 
 
92256
 
--
92257
 
--
92258
 
 
92259
 
COMMENT ON TABLE lang IS 'Table mapping ISO 639-1 and 639-2 language codes to Qt''s enum QLocale::Language integer values. See http://www.loc.gov/standards/iso639-2/php/code_list.php and the QLocale documentation..';
92260
 
 
92261
 
 
92262
 
--
92263
 
--
92264
 
 
92265
 
COMMENT ON COLUMN lang.lang_abbr3 IS 'ISO 639-2 code for language. Where there is a choice between bibliographic (B) and terminology (T) usage, this value is the T code';
92266
 
 
92267
 
 
92268
 
--
92269
 
--
92270
 
 
92271
 
COMMENT ON COLUMN lang.lang_abbr2 IS 'ISO 639-1 code for language';
92272
 
 
92273
 
 
92274
 
--
92275
 
--
92276
 
 
92277
 
COMMENT ON COLUMN lang.lang_name IS 'Name of a human language, taken from the ISO 639-2 documentation';
92278
 
 
92279
 
 
92280
 
--
92281
 
--
92282
 
 
92283
 
CREATE SEQUENCE lang_lang_id_seq
92284
 
    START WITH 1
92285
 
    INCREMENT BY 1
92286
 
    NO MINVALUE
92287
 
    NO MAXVALUE
92288
 
    CACHE 1;
92289
 
 
92290
 
 
92291
 
ALTER TABLE public.lang_lang_id_seq OWNER TO admin;
92292
 
 
92293
 
--
92294
 
--
92295
 
 
92296
 
ALTER SEQUENCE lang_lang_id_seq OWNED BY lang.lang_id;
92297
 
 
92298
 
 
92299
 
--
92300
 
--
92301
 
 
92302
 
CREATE TABLE locale (
92303
 
    locale_id integer DEFAULT nextval(('locale_locale_id_seq'::text)::regclass) NOT NULL,
92304
 
    locale_code text NOT NULL,
92305
 
    locale_descrip text,
92306
 
    locale_lang_file text,
92307
 
    locale_dateformat text,
92308
 
    locale_currformat text,
92309
 
    locale_qtyformat text,
92310
 
    locale_comments text,
92311
 
    locale_qtyperformat text,
92312
 
    locale_salespriceformat text,
92313
 
    locale_extpriceformat text,
92314
 
    locale_timeformat text,
92315
 
    locale_timestampformat text,
92316
 
    local_costformat text,
92317
 
    locale_costformat text,
92318
 
    locale_purchpriceformat text,
92319
 
    locale_uomratioformat text,
92320
 
    locale_intervalformat text,
92321
 
    locale_lang_id integer,
92322
 
    locale_country_id integer,
92323
 
    locale_error_color text,
92324
 
    locale_warning_color text,
92325
 
    locale_emphasis_color text,
92326
 
    locale_altemphasis_color text,
92327
 
    locale_expired_color text,
92328
 
    locale_future_color text,
92329
 
    locale_curr_scale integer,
92330
 
    locale_salesprice_scale integer,
92331
 
    locale_purchprice_scale integer,
92332
 
    locale_extprice_scale integer,
92333
 
    locale_cost_scale integer,
92334
 
    locale_qty_scale integer,
92335
 
    locale_qtyper_scale integer,
92336
 
    locale_uomratio_scale integer,
92337
 
    locale_percent_scale integer DEFAULT 2,
92338
 
    locale_weight_scale integer DEFAULT 2 NOT NULL,
92339
 
    CONSTRAINT locale_locale_code_check CHECK ((locale_code <> ''::text))
92340
 
);
92341
 
 
92342
 
 
92343
 
ALTER TABLE public.locale OWNER TO admin;
92344
 
 
92345
 
--
92346
 
--
92347
 
 
92348
 
COMMENT ON TABLE locale IS 'The locale table holds information required to show data to the user in a localized format. Colors are either names documented by the WWW Consortium or RGB colors. Format for RGB colors is #RGB, #RRGGBB, or #RRRGGGBBB, where the letters R, G, and B stand for hexidecimal digits.';
92349
 
 
92350
 
 
92351
 
--
92352
 
--
92353
 
 
92354
 
COMMENT ON COLUMN locale.locale_lang_file IS 'Deprecated';
92355
 
 
92356
 
 
92357
 
--
92358
 
--
92359
 
 
92360
 
COMMENT ON COLUMN locale.locale_dateformat IS 'Deprecated';
92361
 
 
92362
 
 
92363
 
--
92364
 
--
92365
 
 
92366
 
COMMENT ON COLUMN locale.locale_currformat IS 'Deprecated';
92367
 
 
92368
 
 
92369
 
--
92370
 
--
92371
 
 
92372
 
COMMENT ON COLUMN locale.locale_qtyformat IS 'Deprecated';
92373
 
 
92374
 
 
92375
 
--
92376
 
--
92377
 
 
92378
 
COMMENT ON COLUMN locale.locale_qtyperformat IS 'Deprecated';
92379
 
 
92380
 
 
92381
 
--
92382
 
--
92383
 
 
92384
 
COMMENT ON COLUMN locale.locale_salespriceformat IS 'Deprecated';
92385
 
 
92386
 
 
92387
 
--
92388
 
--
92389
 
 
92390
 
COMMENT ON COLUMN locale.locale_extpriceformat IS 'Deprecated';
92391
 
 
92392
 
 
92393
 
--
92394
 
--
92395
 
 
92396
 
COMMENT ON COLUMN locale.locale_timeformat IS 'Deprecated';
92397
 
 
92398
 
 
92399
 
--
92400
 
--
92401
 
 
92402
 
COMMENT ON COLUMN locale.locale_timestampformat IS 'Deprecated';
92403
 
 
92404
 
 
92405
 
--
92406
 
--
92407
 
 
92408
 
COMMENT ON COLUMN locale.local_costformat IS 'Deprecated';
92409
 
 
92410
 
 
92411
 
--
92412
 
--
92413
 
 
92414
 
COMMENT ON COLUMN locale.locale_costformat IS 'Deprecated';
92415
 
 
92416
 
 
92417
 
--
92418
 
--
92419
 
 
92420
 
COMMENT ON COLUMN locale.locale_purchpriceformat IS 'Deprecated';
92421
 
 
92422
 
 
92423
 
--
92424
 
--
92425
 
 
92426
 
COMMENT ON COLUMN locale.locale_uomratioformat IS 'Deprecated';
92427
 
 
92428
 
 
92429
 
--
92430
 
--
92431
 
 
92432
 
COMMENT ON COLUMN locale.locale_intervalformat IS 'Deprecated';
92433
 
 
92434
 
 
92435
 
--
92436
 
--
92437
 
 
92438
 
COMMENT ON COLUMN locale.locale_error_color IS 'Color to use to mark data that require immediate attention.';
92439
 
 
92440
 
 
92441
 
--
92442
 
--
92443
 
 
92444
 
COMMENT ON COLUMN locale.locale_warning_color IS 'Color to use to mark data that require attention soon.';
92445
 
 
92446
 
 
92447
 
--
92448
 
--
92449
 
 
92450
 
COMMENT ON COLUMN locale.locale_emphasis_color IS 'Color to use to mark data that need to stand out but are not in error.';
92451
 
 
92452
 
 
92453
 
--
92454
 
--
92455
 
 
92456
 
COMMENT ON COLUMN locale.locale_altemphasis_color IS 'Color to use to mark data that need to stand out and be differentiated from other emphasized data.';
92457
 
 
92458
 
 
92459
 
--
92460
 
--
92461
 
 
92462
 
COMMENT ON COLUMN locale.locale_expired_color IS 'Color to use to mark data that are no longer current.';
92463
 
 
92464
 
 
92465
 
--
92466
 
--
92467
 
 
92468
 
COMMENT ON COLUMN locale.locale_future_color IS 'Color to use to mark data that will not be effective until some point in the future.';
92469
 
 
92470
 
 
92471
 
--
92472
 
--
92473
 
 
92474
 
COMMENT ON COLUMN locale.locale_curr_scale IS 'Number of decimal places to show when displaying Currency values.';
92475
 
 
92476
 
 
92477
 
--
92478
 
--
92479
 
 
92480
 
COMMENT ON COLUMN locale.locale_salesprice_scale IS 'Number of decimal places to show when displaying Sales Prices.';
92481
 
 
92482
 
 
92483
 
--
92484
 
--
92485
 
 
92486
 
COMMENT ON COLUMN locale.locale_purchprice_scale IS 'Number of decimal places to show when displaying Purchase Prices.';
92487
 
 
92488
 
 
92489
 
--
92490
 
--
92491
 
 
92492
 
COMMENT ON COLUMN locale.locale_extprice_scale IS 'Number of decimal places to show when displaying Extended Prices.';
92493
 
 
92494
 
 
92495
 
--
92496
 
--
92497
 
 
92498
 
COMMENT ON COLUMN locale.locale_cost_scale IS 'Number of decimal places to show when displaying Costs.';
92499
 
 
92500
 
 
92501
 
--
92502
 
--
92503
 
 
92504
 
COMMENT ON COLUMN locale.locale_qty_scale IS 'Number of decimal places to show when displaying Quantities.';
92505
 
 
92506
 
 
92507
 
--
92508
 
--
92509
 
 
92510
 
COMMENT ON COLUMN locale.locale_qtyper_scale IS 'Number of decimal places to show when displaying Quantities Per.';
92511
 
 
92512
 
 
92513
 
--
92514
 
--
92515
 
 
92516
 
COMMENT ON COLUMN locale.locale_uomratio_scale IS 'Number of decimal places to show when displaying UOM Ratios.';
92517
 
 
92518
 
 
92519
 
--
92520
 
--
92521
 
 
92522
 
CREATE SEQUENCE locale_locale_id_seq
92523
 
    START WITH 1
92524
 
    INCREMENT BY 1
92525
 
    NO MINVALUE
92526
 
    MAXVALUE 2147483647
92527
 
    CACHE 1;
92528
 
 
92529
 
 
92530
 
ALTER TABLE public.locale_locale_id_seq OWNER TO admin;
92531
 
 
92532
 
--
92533
 
--
92534
 
 
92535
 
CREATE SEQUENCE location_location_id_seq
92536
 
    START WITH 1
92537
 
    INCREMENT BY 1
92538
 
    NO MINVALUE
92539
 
    MAXVALUE 2147483647
92540
 
    CACHE 1;
92541
 
 
92542
 
 
92543
 
ALTER TABLE public.location_location_id_seq OWNER TO admin;
92544
 
 
92545
 
--
92546
 
--
92547
 
 
92548
 
CREATE TABLE locitem (
92549
 
    locitem_id integer DEFAULT nextval(('"locitem_locitem_id_seq"'::text)::regclass) NOT NULL,
92550
 
    locitem_location_id integer,
92551
 
    locitem_item_id integer
92552
 
);
92553
 
 
92554
 
 
92555
 
ALTER TABLE public.locitem OWNER TO admin;
92556
 
 
92557
 
--
92558
 
--
92559
 
 
92560
 
COMMENT ON TABLE locitem IS 'Restricted Warehouse Location Allowable Items information';
92561
 
 
92562
 
 
92563
 
--
92564
 
--
92565
 
 
92566
 
CREATE SEQUENCE locitem_locitem_id_seq
92567
 
    START WITH 1
92568
 
    INCREMENT BY 1
92569
 
    NO MINVALUE
92570
 
    MAXVALUE 2147483647
92571
 
    CACHE 1;
92572
 
 
92573
 
 
92574
 
ALTER TABLE public.locitem_locitem_id_seq OWNER TO admin;
92575
 
 
92576
 
--
92577
 
--
92578
 
 
92579
 
CREATE SEQUENCE log_log_id_seq
92580
 
    START WITH 1
92581
 
    INCREMENT BY 1
92582
 
    NO MINVALUE
92583
 
    MAXVALUE 2147483647
92584
 
    CACHE 1;
92585
 
 
92586
 
 
92587
 
ALTER TABLE public.log_log_id_seq OWNER TO admin;
92588
 
 
92589
 
--
92590
 
--
92591
 
 
92592
 
CREATE TABLE metric (
92593
 
    metric_id integer DEFAULT nextval(('metric_metric_id_seq'::text)::regclass) NOT NULL,
92594
 
    metric_name text NOT NULL,
92595
 
    metric_value text,
92596
 
    metric_module text,
92597
 
    CONSTRAINT metric_metric_name_check CHECK ((metric_name <> ''::text))
92598
 
);
92599
 
 
92600
 
 
92601
 
ALTER TABLE public.metric OWNER TO admin;
92602
 
 
92603
 
--
92604
 
--
92605
 
 
92606
 
COMMENT ON TABLE metric IS 'Application-wide settings information';
92607
 
 
92608
 
 
92609
 
--
92610
 
--
92611
 
 
92612
 
CREATE SEQUENCE metric_metric_id_seq
92613
 
    START WITH 1
92614
 
    INCREMENT BY 1
92615
 
    NO MINVALUE
92616
 
    MAXVALUE 2147483647
92617
 
    CACHE 1;
92618
 
 
92619
 
 
92620
 
ALTER TABLE public.metric_metric_id_seq OWNER TO admin;
92621
 
 
92622
 
--
92623
 
--
92624
 
 
92625
 
CREATE TABLE metricenc (
92626
 
    metricenc_id integer NOT NULL,
92627
 
    metricenc_name text NOT NULL,
92628
 
    metricenc_value bytea,
92629
 
    metricenc_module text,
92630
 
    CONSTRAINT metricenc_metricenc_name_check CHECK ((metricenc_name <> ''::text))
92631
 
);
92632
 
 
92633
 
 
92634
 
ALTER TABLE public.metricenc OWNER TO admin;
92635
 
 
92636
 
--
92637
 
--
92638
 
 
92639
 
COMMENT ON TABLE metricenc IS 'Application-wide settings information encrypted data';
92640
 
 
92641
 
 
92642
 
--
92643
 
--
92644
 
 
92645
 
CREATE SEQUENCE metricenc_metricenc_id_seq
92646
 
    START WITH 1
92647
 
    INCREMENT BY 1
92648
 
    NO MINVALUE
92649
 
    NO MAXVALUE
92650
 
    CACHE 1;
92651
 
 
92652
 
 
92653
 
ALTER TABLE public.metricenc_metricenc_id_seq OWNER TO admin;
92654
 
 
92655
 
--
92656
 
--
92657
 
 
92658
 
ALTER SEQUENCE metricenc_metricenc_id_seq OWNED BY metricenc.metricenc_id;
92659
 
 
92660
 
 
92661
 
--
92662
 
--
92663
 
 
92664
 
CREATE SEQUENCE misc_index_seq
92665
 
    START WITH 1
92666
 
    INCREMENT BY 1
92667
 
    NO MINVALUE
92668
 
    MAXVALUE 2147483647
92669
 
    CACHE 1;
92670
 
 
92671
 
 
92672
 
ALTER TABLE public.misc_index_seq OWNER TO admin;
92673
 
 
92674
 
--
92675
 
--
92676
 
 
92677
 
CREATE TABLE mrghist (
92678
 
    mrghist_cntct_id integer NOT NULL,
92679
 
    mrghist_table text NOT NULL,
92680
 
    mrghist_pkey_col text NOT NULL,
92681
 
    mrghist_pkey_id integer NOT NULL,
92682
 
    mrghist_cntct_col text NOT NULL
92683
 
);
92684
 
 
92685
 
 
92686
 
ALTER TABLE public.mrghist OWNER TO admin;
92687
 
 
92688
 
--
92689
 
--
92690
 
 
92691
 
CREATE TABLE mrgundo (
92692
 
    mrgundo_base_schema text,
92693
 
    mrgundo_base_table text,
92694
 
    mrgundo_base_id integer,
92695
 
    mrgundo_schema text,
92696
 
    mrgundo_table text,
92697
 
    mrgundo_pkey_col text,
92698
 
    mrgundo_pkey_id integer,
92699
 
    mrgundo_col text,
92700
 
    mrgundo_value text,
92701
 
    mrgundo_type text
92702
 
);
92703
 
 
92704
 
 
92705
 
ALTER TABLE public.mrgundo OWNER TO admin;
92706
 
 
92707
 
--
92708
 
--
92709
 
 
92710
 
COMMENT ON TABLE mrgundo IS 'This table keeps track of the original values of changes made while merging two records. It is a generalization of mrghist and trgthist, which are specific to merging contacts. The schema, table, and pkey_id columns uniquely identify the record that was changed while the _base_ columns identify the merge target. The _base_ columns are required to allow finding all of the records that pertain to a particular merge (e.g. find changes to the comment table that pertain to a crmacct merge).';
92711
 
 
92712
 
 
92713
 
--
92714
 
--
92715
 
 
92716
 
COMMENT ON COLUMN mrgundo.mrgundo_base_schema IS 'The schema in which the merge target resides.';
92717
 
 
92718
 
 
92719
 
--
92720
 
--
92721
 
 
92722
 
COMMENT ON COLUMN mrgundo.mrgundo_base_table IS 'The table in which the merge target resides.';
92723
 
 
92724
 
 
92725
 
--
92726
 
--
92727
 
 
92728
 
COMMENT ON COLUMN mrgundo.mrgundo_base_id IS 'The internal id of the merge target record.';
92729
 
 
92730
 
 
92731
 
--
92732
 
--
92733
 
 
92734
 
COMMENT ON COLUMN mrgundo.mrgundo_schema IS 'The name of the schema in which the modified table resides.';
92735
 
 
92736
 
 
92737
 
--
92738
 
--
92739
 
 
92740
 
COMMENT ON COLUMN mrgundo.mrgundo_table IS 'The name of the table that was modified during a merge.';
92741
 
 
92742
 
 
92743
 
--
92744
 
--
92745
 
 
92746
 
COMMENT ON COLUMN mrgundo.mrgundo_pkey_col IS 'The name of the primary key column in the modified table. This could be derived during the undo processing but it is simpler just to store it during the merge.';
92747
 
 
92748
 
 
92749
 
--
92750
 
--
92751
 
 
92752
 
COMMENT ON COLUMN mrgundo.mrgundo_pkey_id IS 'The primary key of the modified record.';
92753
 
 
92754
 
 
92755
 
--
92756
 
--
92757
 
 
92758
 
COMMENT ON COLUMN mrgundo.mrgundo_col IS 'The column that was modified.';
92759
 
 
92760
 
 
92761
 
--
92762
 
--
92763
 
 
92764
 
COMMENT ON COLUMN mrgundo.mrgundo_value IS 'The value of the column before the change.';
92765
 
 
92766
 
 
92767
 
--
92768
 
--
92769
 
 
92770
 
COMMENT ON COLUMN mrgundo.mrgundo_type IS 'The data type of the modified column. This could be derived during the undo processing but it is simpler just to store it during the merge.';
92771
 
 
92772
 
 
92773
 
--
92774
 
--
92775
 
 
92776
 
CREATE TABLE msg (
92777
 
    msg_id integer DEFAULT nextval(('"msg_msg_id_seq"'::text)::regclass) NOT NULL,
92778
 
    msg_posted timestamp with time zone,
92779
 
    msg_scheduled timestamp with time zone,
92780
 
    msg_text text,
92781
 
    msg_expires timestamp with time zone,
92782
 
    msg_username text
92783
 
);
92784
 
 
92785
 
 
92786
 
ALTER TABLE public.msg OWNER TO admin;
92787
 
 
92788
 
--
92789
 
--
92790
 
 
92791
 
COMMENT ON TABLE msg IS 'System Message information';
92792
 
 
92793
 
 
92794
 
--
92795
 
--
92796
 
 
92797
 
CREATE SEQUENCE msg_msg_id_seq
92798
 
    START WITH 1
92799
 
    INCREMENT BY 1
92800
 
    NO MINVALUE
92801
 
    MAXVALUE 2147483647
92802
 
    CACHE 1;
92803
 
 
92804
 
 
92805
 
ALTER TABLE public.msg_msg_id_seq OWNER TO admin;
92806
 
 
92807
 
--
92808
 
--
92809
 
 
92810
 
CREATE TABLE msguser (
92811
 
    msguser_id integer DEFAULT nextval(('"msguser_msguser_id_seq"'::text)::regclass) NOT NULL,
92812
 
    msguser_msg_id integer,
92813
 
    msguser_viewed timestamp with time zone,
92814
 
    msguser_username text
92815
 
);
92816
 
 
92817
 
 
92818
 
ALTER TABLE public.msguser OWNER TO admin;
92819
 
 
92820
 
--
92821
 
--
92822
 
 
92823
 
COMMENT ON TABLE msguser IS 'System Message user information';
92824
 
 
92825
 
 
92826
 
--
92827
 
--
92828
 
 
92829
 
CREATE SEQUENCE msguser_msguser_id_seq
92830
 
    START WITH 1
92831
 
    INCREMENT BY 1
92832
 
    NO MINVALUE
92833
 
    MAXVALUE 2147483647
92834
 
    CACHE 1;
92835
 
 
92836
 
 
92837
 
ALTER TABLE public.msguser_msguser_id_seq OWNER TO admin;
92838
 
 
92839
 
--
92840
 
--
92841
 
 
92842
 
CREATE SEQUENCE nvend_nvend_id_seq
92843
 
    START WITH 1
92844
 
    INCREMENT BY 1
92845
 
    NO MINVALUE
92846
 
    MAXVALUE 2147483647
92847
 
    CACHE 1;
92848
 
 
92849
 
 
92850
 
ALTER TABLE public.nvend_nvend_id_seq OWNER TO admin;
92851
 
 
92852
 
--
92853
 
--
92854
 
 
92855
 
CREATE TABLE obsolete_tax (
92856
 
    tax_id integer DEFAULT nextval(('"tax_tax_id_seq"'::text)::regclass) NOT NULL,
92857
 
    tax_code text,
92858
 
    tax_descrip text,
92859
 
    tax_ratea numeric(8,4),
92860
 
    tax_sales_accnt_id integer,
92861
 
    tax_freight boolean DEFAULT false NOT NULL,
92862
 
    tax_cumulative boolean DEFAULT false NOT NULL,
92863
 
    tax_rateb numeric(8,4),
92864
 
    tax_salesb_accnt_id integer,
92865
 
    tax_ratec numeric(8,4),
92866
 
    tax_salesc_accnt_id integer
92867
 
);
92868
 
 
92869
 
 
92870
 
ALTER TABLE public.obsolete_tax OWNER TO admin;
92871
 
 
92872
 
--
92873
 
--
92874
 
 
92875
 
COMMENT ON TABLE obsolete_tax IS 'Tax information. Obsolete table structure.';
92876
 
 
92877
 
 
92878
 
--
92879
 
--
92880
 
 
92881
 
COMMENT ON COLUMN obsolete_tax.tax_freight IS 'Deprecated in 2.1 and moved to taxsel table where taxtype is the system defined Freight.';
92882
 
 
92883
 
 
92884
 
--
92885
 
--
92886
 
 
92887
 
CREATE SEQUENCE ophead_ophead_id_seq
92888
 
    START WITH 1
92889
 
    INCREMENT BY 1
92890
 
    NO MINVALUE
92891
 
    NO MAXVALUE
92892
 
    CACHE 1;
92893
 
 
92894
 
 
92895
 
ALTER TABLE public.ophead_ophead_id_seq OWNER TO admin;
92896
 
 
92897
 
--
92898
 
--
92899
 
 
92900
 
ALTER SEQUENCE ophead_ophead_id_seq OWNED BY ophead.ophead_id;
92901
 
 
92902
 
 
92903
 
--
92904
 
--
92905
 
 
92906
 
CREATE TABLE opsource (
92907
 
    opsource_id integer NOT NULL,
92908
 
    opsource_name text NOT NULL,
92909
 
    opsource_descrip text,
92910
 
    CONSTRAINT opsource_opsource_name_check CHECK ((opsource_name <> ''::text))
92911
 
);
92912
 
 
92913
 
 
92914
 
ALTER TABLE public.opsource OWNER TO admin;
92915
 
 
92916
 
--
92917
 
--
92918
 
 
92919
 
COMMENT ON TABLE opsource IS 'Opportunity Lead Source values.';
92920
 
 
92921
 
 
92922
 
--
92923
 
--
92924
 
 
92925
 
CREATE SEQUENCE opsource_opsource_id_seq
92926
 
    START WITH 1
92927
 
    INCREMENT BY 1
92928
 
    NO MINVALUE
92929
 
    NO MAXVALUE
92930
 
    CACHE 1;
92931
 
 
92932
 
 
92933
 
ALTER TABLE public.opsource_opsource_id_seq OWNER TO admin;
92934
 
 
92935
 
--
92936
 
--
92937
 
 
92938
 
ALTER SEQUENCE opsource_opsource_id_seq OWNED BY opsource.opsource_id;
92939
 
 
92940
 
 
92941
 
--
92942
 
--
92943
 
 
92944
 
CREATE TABLE opstage (
92945
 
    opstage_id integer NOT NULL,
92946
 
    opstage_name text NOT NULL,
92947
 
    opstage_descrip text,
92948
 
    opstage_order integer DEFAULT 0 NOT NULL,
92949
 
    opstage_opinactive boolean DEFAULT false,
92950
 
    CONSTRAINT opstage_opstage_name_check CHECK ((opstage_name <> ''::text))
92951
 
);
92952
 
 
92953
 
 
92954
 
ALTER TABLE public.opstage OWNER TO admin;
92955
 
 
92956
 
--
92957
 
--
92958
 
 
92959
 
COMMENT ON TABLE opstage IS 'Opportunity stage values.';
92960
 
 
92961
 
 
92962
 
--
92963
 
--
92964
 
 
92965
 
CREATE SEQUENCE opstage_opstage_id_seq
92966
 
    START WITH 1
92967
 
    INCREMENT BY 1
92968
 
    NO MINVALUE
92969
 
    NO MAXVALUE
92970
 
    CACHE 1;
92971
 
 
92972
 
 
92973
 
ALTER TABLE public.opstage_opstage_id_seq OWNER TO admin;
92974
 
 
92975
 
--
92976
 
--
92977
 
 
92978
 
ALTER SEQUENCE opstage_opstage_id_seq OWNED BY opstage.opstage_id;
92979
 
 
92980
 
 
92981
 
--
92982
 
--
92983
 
 
92984
 
CREATE TABLE optype (
92985
 
    optype_id integer NOT NULL,
92986
 
    optype_name text NOT NULL,
92987
 
    optype_descrip text,
92988
 
    CONSTRAINT optype_optype_name_check CHECK ((optype_name <> ''::text))
92989
 
);
92990
 
 
92991
 
 
92992
 
ALTER TABLE public.optype OWNER TO admin;
92993
 
 
92994
 
--
92995
 
--
92996
 
 
92997
 
COMMENT ON TABLE optype IS 'Opportunity Type values.';
92998
 
 
92999
 
 
93000
 
--
93001
 
--
93002
 
 
93003
 
CREATE SEQUENCE optype_optype_id_seq
93004
 
    START WITH 1
93005
 
    INCREMENT BY 1
93006
 
    NO MINVALUE
93007
 
    NO MAXVALUE
93008
 
    CACHE 1;
93009
 
 
93010
 
 
93011
 
ALTER TABLE public.optype_optype_id_seq OWNER TO admin;
93012
 
 
93013
 
--
93014
 
--
93015
 
 
93016
 
ALTER SEQUENCE optype_optype_id_seq OWNED BY optype.optype_id;
93017
 
 
93018
 
 
93019
 
--
93020
 
--
93021
 
 
93022
 
CREATE VIEW orderhead AS
93023
 
    SELECT DISTINCT data.orderhead_id, data.orderhead_type, data.orderhead_number, data.orderhead_status, data.orderhead_orderdate, data.orderhead_linecount, data.orderhead_from_id, data.orderhead_from, data.orderhead_to_id, data.orderhead_to, data.orderhead_curr_id, data.orderhead_agent_username, data.orderhead_shipvia FROM (SELECT pohead.pohead_id AS orderhead_id, 'PO'::text AS orderhead_type, pohead.pohead_number AS orderhead_number, pohead.pohead_status AS orderhead_status, pohead.pohead_orderdate AS orderhead_orderdate, (SELECT count(*) AS count FROM poitem WHERE (poitem.poitem_pohead_id = pohead.pohead_id)) AS orderhead_linecount, pohead.pohead_vend_id AS orderhead_from_id, vendinfo.vend_name AS orderhead_from, NULL::integer AS orderhead_to_id, ''::text AS orderhead_to, pohead.pohead_curr_id AS orderhead_curr_id, pohead.pohead_agent_username AS orderhead_agent_username, pohead.pohead_shipvia AS orderhead_shipvia FROM (pohead LEFT JOIN vendinfo ON ((pohead.pohead_vend_id = vendinfo.vend_id))) UNION ALL SELECT cohead.cohead_id AS orderhead_id, 'SO'::text AS orderhead_type, cohead.cohead_number AS orderhead_number, cohead.cohead_status AS orderhead_status, cohead.cohead_orderdate AS orderhead_orderdate, (SELECT count(*) AS count FROM coitem WHERE (coitem.coitem_cohead_id = cohead.cohead_id)) AS orderhead_linecount, NULL::integer AS orderhead_from_id, ''::text AS orderhead_from, cohead.cohead_cust_id AS orderhead_to_id, CASE WHEN (length(cohead.cohead_shiptoname) > 0) THEN cohead.cohead_shiptoname ELSE cohead.cohead_billtoname END AS orderhead_to, cohead.cohead_curr_id AS orderhead_curr_id, ''::text AS orderhead_agent_username, cohead.cohead_shipvia AS orderhead_shipvia FROM cohead) data;
93024
 
 
93025
 
 
93026
 
ALTER TABLE public.orderhead OWNER TO admin;
93027
 
 
93028
 
--
93029
 
--
93030
 
 
93031
 
COMMENT ON VIEW orderhead IS 'Union of all orders for use by widgets and stored procedures which process multiple types of order';
93032
 
 
93033
 
 
93034
 
--
93035
 
--
93036
 
 
93037
 
CREATE VIEW orderitem AS
93038
 
    (SELECT poitem.poitem_id AS orderitem_id, 'PO'::text AS orderitem_orderhead_type, poitem.poitem_pohead_id AS orderitem_orderhead_id, poitem.poitem_linenumber AS orderitem_linenumber, poitem.poitem_status AS orderitem_status, poitem.poitem_itemsite_id AS orderitem_itemsite_id, poitem.poitem_duedate AS orderitem_scheddate, poitem.poitem_qty_ordered AS orderitem_qty_ordered, poitem.poitem_qty_returned AS orderitem_qty_shipped, poitem.poitem_qty_received AS orderitem_qty_received, uom.uom_id AS orderitem_qty_uom_id, poitem.poitem_invvenduomratio AS orderitem_qty_invuomratio, poitem.poitem_unitprice AS orderitem_unitcost, pohead.pohead_curr_id AS orderitem_unitcost_curr_id, poitem.poitem_freight AS orderitem_freight, poitem.poitem_freight_received AS orderitem_freight_received, pohead.pohead_curr_id AS orderitem_freight_curr_id FROM ((poitem LEFT JOIN pohead ON ((poitem.poitem_pohead_id = pohead.pohead_id))) LEFT JOIN uom ON ((uom.uom_name = poitem.poitem_vend_uom))) UNION ALL SELECT coitem.coitem_id AS orderitem_id, 'SO'::text AS orderitem_orderhead_type, coitem.coitem_cohead_id AS orderitem_orderhead_id, coitem.coitem_linenumber AS orderitem_linenumber, coitem.coitem_status AS orderitem_status, coitem.coitem_itemsite_id AS orderitem_itemsite_id, coitem.coitem_scheddate AS orderitem_scheddate, coitem.coitem_qtyord AS orderitem_qty_ordered, coitem.coitem_qtyshipped AS orderitem_qty_shipped, coitem.coitem_qtyreturned AS orderitem_qty_received, coitem.coitem_qty_uom_id AS orderitem_qty_uom_id, coitem.coitem_qty_invuomratio AS orderitem_qty_invuomratio, coitem.coitem_unitcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL::numeric AS orderitem_freight, NULL::numeric AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM coitem) UNION ALL SELECT quitem.quitem_id AS orderitem_id, 'QU'::text AS orderitem_orderhead_type, quitem.quitem_quhead_id AS orderitem_orderhead_id, quitem.quitem_linenumber AS orderitem_linenumber, 'O'::bpchar AS orderitem_status, quitem.quitem_itemsite_id AS orderitem_itemsite_id, quitem.quitem_scheddate AS orderitem_scheddate, quitem.quitem_qtyord AS orderitem_qty_ordered, 0 AS orderitem_qty_shipped, 0 AS orderitem_qty_received, quitem.quitem_qty_uom_id AS orderitem_qty_uom_id, quitem.quitem_qty_invuomratio AS orderitem_qty_invuomratio, quitem.quitem_unitcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL::numeric AS orderitem_freight, NULL::numeric AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM quitem;
93039
 
 
93040
 
 
93041
 
ALTER TABLE public.orderitem OWNER TO admin;
93042
 
 
93043
 
--
93044
 
--
93045
 
 
93046
 
COMMENT ON VIEW orderitem IS 'Union of all order line items for use by widgets and stored procedures which process multiple types of order';
93047
 
 
93048
 
 
93049
 
--
93050
 
--
93051
 
 
93052
 
CREATE TABLE orderseq (
93053
 
    orderseq_id integer DEFAULT nextval(('orderseq_orderseq_id_seq'::text)::regclass) NOT NULL,
93054
 
    orderseq_name text NOT NULL,
93055
 
    orderseq_number integer,
93056
 
    orderseq_table text,
93057
 
    orderseq_numcol text,
93058
 
    orderseq_seqiss seqiss[],
93059
 
    CONSTRAINT orderseq_orderseq_name_check CHECK ((orderseq_name <> ''::text))
93060
 
);
93061
 
 
93062
 
 
93063
 
ALTER TABLE public.orderseq OWNER TO admin;
93064
 
 
93065
 
--
93066
 
--
93067
 
 
93068
 
COMMENT ON TABLE orderseq IS 'Configuration information for common numbering sequences';
93069
 
 
93070
 
 
93071
 
--
93072
 
--
93073
 
 
93074
 
CREATE SEQUENCE orderseq_orderseq_id_seq
93075
 
    START WITH 1
93076
 
    INCREMENT BY 1
93077
 
    NO MINVALUE
93078
 
    MAXVALUE 2147483647
93079
 
    CACHE 1;
93080
 
 
93081
 
 
93082
 
ALTER TABLE public.orderseq_orderseq_id_seq OWNER TO admin;
93083
 
 
93084
 
--
93085
 
--
93086
 
 
93087
 
CREATE TABLE pack (
93088
 
    pack_id integer NOT NULL,
93089
 
    pack_head_id integer NOT NULL,
93090
 
    pack_head_type text NOT NULL,
93091
 
    pack_shiphead_id integer,
93092
 
    pack_printed boolean DEFAULT false NOT NULL,
93093
 
    CONSTRAINT pack_pack_head_type_check CHECK (((pack_head_type = 'SO'::text) OR (pack_head_type = 'TO'::text)))
93094
 
);
93095
 
 
93096
 
 
93097
 
ALTER TABLE public.pack OWNER TO admin;
93098
 
 
93099
 
--
93100
 
--
93101
 
 
93102
 
COMMENT ON TABLE pack IS 'Temporary table for storing information about Orders added to the Packing List Batch';
93103
 
 
93104
 
 
93105
 
--
93106
 
--
93107
 
 
93108
 
CREATE SEQUENCE pack_pack_id_seq
93109
 
    START WITH 1
93110
 
    INCREMENT BY 1
93111
 
    NO MINVALUE
93112
 
    NO MAXVALUE
93113
 
    CACHE 1;
93114
 
 
93115
 
 
93116
 
ALTER TABLE public.pack_pack_id_seq OWNER TO admin;
93117
 
 
93118
 
--
93119
 
--
93120
 
 
93121
 
ALTER SEQUENCE pack_pack_id_seq OWNED BY pack.pack_id;
93122
 
 
93123
 
 
93124
 
--
93125
 
--
93126
 
 
93127
 
CREATE TABLE payaropen (
93128
 
    payaropen_ccpay_id integer NOT NULL,
93129
 
    payaropen_aropen_id integer NOT NULL,
93130
 
    payaropen_amount numeric(20,2) DEFAULT 0.00 NOT NULL,
93131
 
    payaropen_curr_id integer DEFAULT basecurrid()
93132
 
);
93133
 
 
93134
 
 
93135
 
ALTER TABLE public.payaropen OWNER TO admin;
93136
 
 
93137
 
--
93138
 
--
93139
 
 
93140
 
COMMENT ON TABLE payaropen IS 'Credit Card payment to credit memo join table';
93141
 
 
93142
 
 
93143
 
--
93144
 
--
93145
 
 
93146
 
CREATE TABLE payco (
93147
 
    payco_ccpay_id integer NOT NULL,
93148
 
    payco_cohead_id integer NOT NULL,
93149
 
    payco_amount numeric(20,2) DEFAULT 0.00 NOT NULL,
93150
 
    payco_curr_id integer DEFAULT basecurrid(),
93151
 
    payco_id integer NOT NULL
93152
 
);
93153
 
 
93154
 
 
93155
 
ALTER TABLE public.payco OWNER TO admin;
93156
 
 
93157
 
--
93158
 
--
93159
 
 
93160
 
COMMENT ON TABLE payco IS 'Credit Card payment to sales order join table';
93161
 
 
93162
 
 
93163
 
--
93164
 
--
93165
 
 
93166
 
COMMENT ON COLUMN payco.payco_id IS 'payco table primary key.';
93167
 
 
93168
 
 
93169
 
--
93170
 
--
93171
 
 
93172
 
CREATE SEQUENCE payco_payco_id_seq
93173
 
    START WITH 1
93174
 
    INCREMENT BY 1
93175
 
    NO MINVALUE
93176
 
    NO MAXVALUE
93177
 
    CACHE 1;
93178
 
 
93179
 
 
93180
 
ALTER TABLE public.payco_payco_id_seq OWNER TO admin;
93181
 
 
93182
 
--
93183
 
--
93184
 
 
93185
 
ALTER SEQUENCE payco_payco_id_seq OWNED BY payco.payco_id;
93186
 
 
93187
 
 
93188
 
--
93189
 
--
93190
 
 
93191
 
CREATE SEQUENCE period_period_id_seq
93192
 
    START WITH 1
93193
 
    INCREMENT BY 1
93194
 
    NO MINVALUE
93195
 
    NO MAXVALUE
93196
 
    CACHE 1;
93197
 
 
93198
 
 
93199
 
ALTER TABLE public.period_period_id_seq OWNER TO admin;
93200
 
 
93201
 
--
93202
 
--
93203
 
 
93204
 
ALTER SEQUENCE period_period_id_seq OWNED BY period.period_id;
93205
 
 
93206
 
 
93207
 
--
93208
 
--
93209
 
 
93210
 
CREATE TABLE pkgdep (
93211
 
    pkgdep_id integer NOT NULL,
93212
 
    pkgdep_pkghead_id integer NOT NULL,
93213
 
    pkgdep_parent_pkghead_id integer NOT NULL
93214
 
);
93215
 
 
93216
 
 
93217
 
ALTER TABLE public.pkgdep OWNER TO admin;
93218
 
 
93219
 
--
93220
 
--
93221
 
 
93222
 
COMMENT ON TABLE pkgdep IS 'Package Dependencies list describing which packages are dependent on which other packages.';
93223
 
 
93224
 
 
93225
 
--
93226
 
--
93227
 
 
93228
 
COMMENT ON COLUMN pkgdep.pkgdep_pkghead_id IS 'This is the internal ID of a package which requires at least one other package to be installed first to operate successfully';
93229
 
 
93230
 
 
93231
 
--
93232
 
--
93233
 
 
93234
 
COMMENT ON COLUMN pkgdep.pkgdep_parent_pkghead_id IS 'This is the internal ID of a package which must be installed for the package pointed to by pkgdep_pkghead_id to operate successfully.';
93235
 
 
93236
 
 
93237
 
--
93238
 
--
93239
 
 
93240
 
CREATE SEQUENCE pkgdep_pkgdep_id_seq
93241
 
    START WITH 1
93242
 
    INCREMENT BY 1
93243
 
    NO MINVALUE
93244
 
    NO MAXVALUE
93245
 
    CACHE 1;
93246
 
 
93247
 
 
93248
 
ALTER TABLE public.pkgdep_pkgdep_id_seq OWNER TO admin;
93249
 
 
93250
 
--
93251
 
--
93252
 
 
93253
 
ALTER SEQUENCE pkgdep_pkgdep_id_seq OWNED BY pkgdep.pkgdep_id;
93254
 
 
93255
 
 
93256
 
--
93257
 
--
93258
 
 
93259
 
CREATE TABLE pkghead (
93260
 
    pkghead_id integer NOT NULL,
93261
 
    pkghead_name text NOT NULL,
93262
 
    pkghead_descrip text,
93263
 
    pkghead_version text NOT NULL,
93264
 
    pkghead_developer text NOT NULL,
93265
 
    pkghead_notes text,
93266
 
    pkghead_created timestamp with time zone,
93267
 
    pkghead_updated timestamp with time zone,
93268
 
    pkghead_indev boolean DEFAULT false NOT NULL,
93269
 
    CONSTRAINT pkghead_pkghead_name_check CHECK ((pkghead_name <> ''::text))
93270
 
);
93271
 
 
93272
 
 
93273
 
ALTER TABLE public.pkghead OWNER TO admin;
93274
 
 
93275
 
--
93276
 
--
93277
 
 
93278
 
COMMENT ON TABLE pkghead IS 'Information about non-core Packages added to the database';
93279
 
 
93280
 
 
93281
 
--
93282
 
--
93283
 
 
93284
 
COMMENT ON COLUMN pkghead.pkghead_indev IS 'Flag indicating whether the contents of this package may be modified in-place - this package is /in dev/elopment.';
93285
 
 
93286
 
 
93287
 
--
93288
 
--
93289
 
 
93290
 
CREATE SEQUENCE pkghead_pkghead_id_seq
93291
 
    START WITH 1
93292
 
    INCREMENT BY 1
93293
 
    NO MINVALUE
93294
 
    NO MAXVALUE
93295
 
    CACHE 1;
93296
 
 
93297
 
 
93298
 
ALTER TABLE public.pkghead_pkghead_id_seq OWNER TO admin;
93299
 
 
93300
 
--
93301
 
--
93302
 
 
93303
 
ALTER SEQUENCE pkghead_pkghead_id_seq OWNED BY pkghead.pkghead_id;
93304
 
 
93305
 
 
93306
 
--
93307
 
--
93308
 
 
93309
 
CREATE TABLE pkgitem (
93310
 
    pkgitem_id integer NOT NULL,
93311
 
    pkgitem_pkghead_id integer,
93312
 
    pkgitem_type text,
93313
 
    pkgitem_item_id integer NOT NULL,
93314
 
    pkgitem_name text NOT NULL,
93315
 
    pkgitem_descrip text,
93316
 
    CONSTRAINT pkgitem_pkgitem_type_check CHECK (((((((((((((pkgitem_type = 'C'::text) OR (pkgitem_type = 'D'::text)) OR (pkgitem_type = 'F'::text)) OR (pkgitem_type = 'G'::text)) OR (pkgitem_type = 'I'::text)) OR (pkgitem_type = 'M'::text)) OR (pkgitem_type = 'P'::text)) OR (pkgitem_type = 'R'::text)) OR (pkgitem_type = 'S'::text)) OR (pkgitem_type = 'T'::text)) OR (pkgitem_type = 'U'::text)) OR (pkgitem_type = 'V'::text)))
93317
 
);
93318
 
 
93319
 
 
93320
 
ALTER TABLE public.pkgitem OWNER TO admin;
93321
 
 
93322
 
--
93323
 
--
93324
 
 
93325
 
COMMENT ON TABLE pkgitem IS 'Deprecated - the pkgitem table is no longer used to track package contents. It has been replaced by direct queries to the database schema and component tables. This table will be removed when all users have switched to Updater 2.2.0 or later.';
93326
 
 
93327
 
 
93328
 
--
93329
 
--
93330
 
 
93331
 
CREATE SEQUENCE pkgitem_pkgitem_id_seq
93332
 
    START WITH 1
93333
 
    INCREMENT BY 1
93334
 
    NO MINVALUE
93335
 
    NO MAXVALUE
93336
 
    CACHE 1;
93337
 
 
93338
 
 
93339
 
ALTER TABLE public.pkgitem_pkgitem_id_seq OWNER TO admin;
93340
 
 
93341
 
--
93342
 
--
93343
 
 
93344
 
ALTER SEQUENCE pkgitem_pkgitem_id_seq OWNED BY pkgitem.pkgitem_id;
93345
 
 
93346
 
 
93347
 
--
93348
 
--
93349
 
 
93350
 
CREATE SEQUENCE plancode_plancode_id_seq
93351
 
    START WITH 1
93352
 
    INCREMENT BY 1
93353
 
    NO MINVALUE
93354
 
    NO MAXVALUE
93355
 
    CACHE 1;
93356
 
 
93357
 
 
93358
 
ALTER TABLE public.plancode_plancode_id_seq OWNER TO admin;
93359
 
 
93360
 
--
93361
 
--
93362
 
 
93363
 
CREATE SEQUENCE planord_planord_id_seq
93364
 
    START WITH 1
93365
 
    INCREMENT BY 1
93366
 
    NO MINVALUE
93367
 
    MAXVALUE 2147483647
93368
 
    CACHE 1;
93369
 
 
93370
 
 
93371
 
ALTER TABLE public.planord_planord_id_seq OWNER TO admin;
93372
 
 
93373
 
--
93374
 
--
93375
 
 
93376
 
CREATE SEQUENCE pohead_pohead_id_seq
93377
 
    START WITH 1
93378
 
    INCREMENT BY 1
93379
 
    NO MINVALUE
93380
 
    MAXVALUE 2147483647
93381
 
    CACHE 1;
93382
 
 
93383
 
 
93384
 
ALTER TABLE public.pohead_pohead_id_seq OWNER TO admin;
93385
 
 
93386
 
--
93387
 
--
93388
 
 
93389
 
CREATE SEQUENCE poitem_poitem_id_seq
93390
 
    START WITH 1
93391
 
    INCREMENT BY 1
93392
 
    NO MINVALUE
93393
 
    MAXVALUE 2147483647
93394
 
    CACHE 1;
93395
 
 
93396
 
 
93397
 
ALTER TABLE public.poitem_poitem_id_seq OWNER TO admin;
93398
 
 
93399
 
--
93400
 
--
93401
 
 
93402
 
CREATE TABLE recv (
93403
 
    recv_id integer NOT NULL,
93404
 
    recv_order_type text NOT NULL,
93405
 
    recv_order_number text NOT NULL,
93406
 
    recv_orderitem_id integer NOT NULL,
93407
 
    recv_agent_username text,
93408
 
    recv_itemsite_id integer,
93409
 
    recv_vend_id integer,
93410
 
    recv_vend_item_number text,
93411
 
    recv_vend_item_descrip text,
93412
 
    recv_vend_uom text,
93413
 
    recv_purchcost numeric(16,6),
93414
 
    recv_purchcost_curr_id integer,
93415
 
    recv_duedate date,
93416
 
    recv_qty numeric(18,6),
93417
 
    recv_recvcost numeric(16,6),
93418
 
    recv_recvcost_curr_id integer,
93419
 
    recv_freight numeric(16,4),
93420
 
    recv_freight_curr_id integer,
93421
 
    recv_date timestamp with time zone,
93422
 
    recv_value numeric(18,6),
93423
 
    recv_posted boolean DEFAULT false NOT NULL,
93424
 
    recv_invoiced boolean DEFAULT false NOT NULL,
93425
 
    recv_vohead_id integer,
93426
 
    recv_voitem_id integer,
93427
 
    recv_trans_usr_name text DEFAULT geteffectivextuser() NOT NULL,
93428
 
    recv_notes text,
93429
 
    recv_gldistdate date,
93430
 
    recv_splitfrom_id integer,
93431
 
    recv_rlsd_duedate date,
93432
 
    CONSTRAINT recv_recv_order_type_check CHECK ((((recv_order_type = 'PO'::text) OR (recv_order_type = 'RA'::text)) OR (recv_order_type = 'TO'::text)))
93433
 
);
93434
 
 
93435
 
 
93436
 
ALTER TABLE public.recv OWNER TO admin;
93437
 
 
93438
 
--
93439
 
--
93440
 
 
93441
 
COMMENT ON TABLE recv IS 'Information about Received Orders.';
93442
 
 
93443
 
 
93444
 
--
93445
 
--
93446
 
 
93447
 
CREATE VIEW porecv AS
93448
 
    SELECT recv.recv_id AS porecv_id, recv.recv_date AS porecv_date, recv.recv_rlsd_duedate AS porecv_rlsd_duedate, pohead.pohead_orderdate AS porecv_orderdate, pohead.pohead_released AS porecv_released, recv.recv_order_number AS porecv_ponumber, recv.recv_itemsite_id AS porecv_itemsite_id, recv.recv_vend_id AS porecv_vend_id, item.item_number AS porecv_item_number, recv.recv_vend_item_number AS porecv_vend_item_number, COALESCE(item.item_descrip1, recv.recv_vend_item_descrip) AS porecv_vend_item_descrip, recv.recv_vend_uom AS porecv_vend_uom, recv.recv_qty AS porecv_qty, recv.recv_posted AS porecv_posted, recv.recv_invoiced AS porecv_invoiced, (pg_user.usesysid)::integer AS porecv_trans_usr_id, recv.recv_orderitem_id AS porecv_poitem_id, NULL::integer AS porecv_linenumber, recv.recv_purchcost AS porecv_purchcost, recv.recv_vohead_id AS porecv_vohead_id, recv.recv_recvcost AS porecv_recvcost, recv.recv_duedate AS porecv_duedate, recv.recv_agent_username AS porecv_agent_username, recv.recv_notes AS porecv_notes, recv.recv_freight AS porecv_freight, recv.recv_freight_curr_id AS porecv_curr_id, recv.recv_gldistdate AS porecv_gldistdate, recv.recv_voitem_id AS porecv_voitem_id, recv.recv_value AS porecv_value FROM ((((recv LEFT JOIN pg_user ON ((recv.recv_trans_usr_name = (pg_user.usename)::text))) LEFT JOIN pohead ON ((recv.recv_order_number = pohead.pohead_number))) LEFT JOIN itemsite ON ((recv.recv_itemsite_id = itemsite.itemsite_id))) LEFT JOIN item ON ((itemsite.itemsite_item_id = item.item_id))) WHERE (recv.recv_order_type = 'PO'::text);
93449
 
 
93450
 
 
93451
 
ALTER TABLE public.porecv OWNER TO admin;
93452
 
 
93453
 
--
93454
 
--
93455
 
 
93456
 
CREATE SEQUENCE porecv_porecv_id_seq
93457
 
    START WITH 1
93458
 
    INCREMENT BY 1
93459
 
    NO MINVALUE
93460
 
    MAXVALUE 2147483647
93461
 
    CACHE 1;
93462
 
 
93463
 
 
93464
 
ALTER TABLE public.porecv_porecv_id_seq OWNER TO admin;
93465
 
 
93466
 
--
93467
 
--
93468
 
 
93469
 
CREATE TABLE poreject (
93470
 
    poreject_id integer DEFAULT nextval(('"poreject_poreject_id_seq"'::text)::regclass) NOT NULL,
93471
 
    poreject_date timestamp with time zone,
93472
 
    poreject_ponumber text,
93473
 
    poreject_itemsite_id integer,
93474
 
    poreject_vend_id integer,
93475
 
    poreject_vend_item_number text,
93476
 
    poreject_vend_item_descrip text,
93477
 
    poreject_vend_uom text,
93478
 
    poreject_qty numeric(18,6),
93479
 
    poreject_posted boolean,
93480
 
    poreject_rjctcode_id integer,
93481
 
    poreject_poitem_id integer,
93482
 
    poreject_invoiced boolean,
93483
 
    poreject_vohead_id integer,
93484
 
    poreject_agent_username text,
93485
 
    poreject_voitem_id integer,
93486
 
    poreject_value numeric(18,6),
93487
 
    poreject_trans_username text,
93488
 
    poreject_recv_id integer
93489
 
);
93490
 
 
93491
 
 
93492
 
ALTER TABLE public.poreject OWNER TO admin;
93493
 
 
93494
 
--
93495
 
--
93496
 
 
93497
 
COMMENT ON TABLE poreject IS 'The poreject table describes Purchase Order Items that were returned to Vendors.';
93498
 
 
93499
 
 
93500
 
--
93501
 
--
93502
 
 
93503
 
COMMENT ON COLUMN poreject.poreject_id IS 'This is the internal id of this poreject record';
93504
 
 
93505
 
 
93506
 
--
93507
 
--
93508
 
 
93509
 
COMMENT ON COLUMN poreject.poreject_date IS 'This is the date and time the return was entered into the database';
93510
 
 
93511
 
 
93512
 
--
93513
 
--
93514
 
 
93515
 
COMMENT ON COLUMN poreject.poreject_ponumber IS 'This is the number of the original Purchase Order of this item';
93516
 
 
93517
 
 
93518
 
--
93519
 
--
93520
 
 
93521
 
COMMENT ON COLUMN poreject.poreject_itemsite_id IS 'This is the Item Site into which the item had been received';
93522
 
 
93523
 
 
93524
 
--
93525
 
--
93526
 
 
93527
 
COMMENT ON COLUMN poreject.poreject_vend_id IS 'This is the Vendor from which the item had been purchased';
93528
 
 
93529
 
 
93530
 
--
93531
 
--
93532
 
 
93533
 
COMMENT ON COLUMN poreject.poreject_vend_item_number IS 'This is the Vendor''s item number for this item';
93534
 
 
93535
 
 
93536
 
--
93537
 
--
93538
 
 
93539
 
COMMENT ON COLUMN poreject.poreject_vend_item_descrip IS 'This is the Vendor''s description of this item';
93540
 
 
93541
 
 
93542
 
--
93543
 
--
93544
 
 
93545
 
COMMENT ON COLUMN poreject.poreject_vend_uom IS 'This is the Unit of Measure in which the Vendor sold this item';
93546
 
 
93547
 
 
93548
 
--
93549
 
--
93550
 
 
93551
 
COMMENT ON COLUMN poreject.poreject_qty IS 'This is the quantity of the item that was returned';
93552
 
 
93553
 
 
93554
 
--
93555
 
--
93556
 
 
93557
 
COMMENT ON COLUMN poreject.poreject_posted IS 'This indicates whether or not the return has been recorded in the General Ledger, Inventory History, and Purchase Order Item';
93558
 
 
93559
 
 
93560
 
--
93561
 
--
93562
 
 
93563
 
COMMENT ON COLUMN poreject.poreject_rjctcode_id IS 'This indicates the reason for the return';
93564
 
 
93565
 
 
93566
 
--
93567
 
--
93568
 
 
93569
 
COMMENT ON COLUMN poreject.poreject_poitem_id IS 'This is the internal id of the original Purchase Order Item';
93570
 
 
93571
 
 
93572
 
--
93573
 
--
93574
 
 
93575
 
COMMENT ON COLUMN poreject.poreject_invoiced IS 'This indicates whether the Credit Memo associated with the return has been posted';
93576
 
 
93577
 
 
93578
 
--
93579
 
--
93580
 
 
93581
 
COMMENT ON COLUMN poreject.poreject_vohead_id IS 'This is the Voucher associated with the Purchase Order Item';
93582
 
 
93583
 
 
93584
 
--
93585
 
--
93586
 
 
93587
 
COMMENT ON COLUMN poreject.poreject_agent_username IS 'This is the Purchase Order Agent responsible for the original Purchase Order';
93588
 
 
93589
 
 
93590
 
--
93591
 
--
93592
 
 
93593
 
COMMENT ON COLUMN poreject.poreject_voitem_id IS 'This is the Voucher Item associated with the Purchase Order Item';
93594
 
 
93595
 
 
93596
 
--
93597
 
--
93598
 
 
93599
 
COMMENT ON COLUMN poreject.poreject_value IS 'This is the value (in base currency) of the return at the time it was posted to the General Ledger';
93600
 
 
93601
 
 
93602
 
--
93603
 
--
93604
 
 
93605
 
COMMENT ON COLUMN poreject.poreject_trans_username IS 'This is the user who recorded the return';
93606
 
 
93607
 
 
93608
 
--
93609
 
--
93610
 
 
93611
 
CREATE SEQUENCE poreject_poreject_id_seq
93612
 
    START WITH 1
93613
 
    INCREMENT BY 1
93614
 
    NO MINVALUE
93615
 
    MAXVALUE 2147483647
93616
 
    CACHE 1;
93617
 
 
93618
 
 
93619
 
ALTER TABLE public.poreject_poreject_id_seq OWNER TO admin;
93620
 
 
93621
 
--
93622
 
--
93623
 
 
93624
 
CREATE TABLE potype (
93625
 
    potype_id integer NOT NULL,
93626
 
    potype_name text,
93627
 
    potype_descrip text
93628
 
);
93629
 
 
93630
 
 
93631
 
ALTER TABLE public.potype OWNER TO admin;
93632
 
 
93633
 
--
93634
 
--
93635
 
 
93636
 
COMMENT ON TABLE potype IS 'Purchase Order Type information';
93637
 
 
93638
 
 
93639
 
--
93640
 
--
93641
 
 
93642
 
CREATE SEQUENCE potype_potype_id_seq
93643
 
    START WITH 1
93644
 
    INCREMENT BY 1
93645
 
    NO MINVALUE
93646
 
    NO MAXVALUE
93647
 
    CACHE 1;
93648
 
 
93649
 
 
93650
 
ALTER TABLE public.potype_potype_id_seq OWNER TO admin;
93651
 
 
93652
 
--
93653
 
--
93654
 
 
93655
 
ALTER SEQUENCE potype_potype_id_seq OWNED BY potype.potype_id;
93656
 
 
93657
 
 
93658
 
--
93659
 
--
93660
 
 
93661
 
CREATE TABLE pr (
93662
 
    pr_id integer DEFAULT nextval(('"pr_pr_id_seq"'::text)::regclass) NOT NULL,
93663
 
    pr_number integer,
93664
 
    pr_subnumber integer,
93665
 
    pr_status character(1),
93666
 
    pr_order_type character(1),
93667
 
    pr_order_id integer,
93668
 
    pr_poitem_id integer,
93669
 
    pr_duedate date,
93670
 
    pr_itemsite_id integer,
93671
 
    pr_qtyreq numeric(18,6),
93672
 
    pr_prj_id integer,
93673
 
    pr_releasenote text,
93674
 
    pr_createdate timestamp without time zone DEFAULT now()
93675
 
);
93676
 
 
93677
 
 
93678
 
ALTER TABLE public.pr OWNER TO admin;
93679
 
 
93680
 
--
93681
 
--
93682
 
 
93683
 
COMMENT ON TABLE pr IS 'Purchase Request information';
93684
 
 
93685
 
 
93686
 
--
93687
 
--
93688
 
 
93689
 
CREATE SEQUENCE pr_pr_id_seq
93690
 
    START WITH 1
93691
 
    INCREMENT BY 1
93692
 
    NO MINVALUE
93693
 
    NO MAXVALUE
93694
 
    CACHE 1;
93695
 
 
93696
 
 
93697
 
ALTER TABLE public.pr_pr_id_seq OWNER TO admin;
93698
 
 
93699
 
--
93700
 
--
93701
 
 
93702
 
CREATE TABLE prftcntr (
93703
 
    prftcntr_id integer NOT NULL,
93704
 
    prftcntr_number text NOT NULL,
93705
 
    prftcntr_descrip text,
93706
 
    CONSTRAINT prftcntr_prftcntr_number_check CHECK ((prftcntr_number <> ''::text))
93707
 
);
93708
 
 
93709
 
 
93710
 
ALTER TABLE public.prftcntr OWNER TO admin;
93711
 
 
93712
 
--
93713
 
--
93714
 
 
93715
 
COMMENT ON TABLE prftcntr IS 'Profit Center information';
93716
 
 
93717
 
 
93718
 
--
93719
 
--
93720
 
 
93721
 
CREATE SEQUENCE prftcntr_prftcntr_id_seq
93722
 
    START WITH 1
93723
 
    INCREMENT BY 1
93724
 
    NO MINVALUE
93725
 
    NO MAXVALUE
93726
 
    CACHE 1;
93727
 
 
93728
 
 
93729
 
ALTER TABLE public.prftcntr_prftcntr_id_seq OWNER TO admin;
93730
 
 
93731
 
--
93732
 
--
93733
 
 
93734
 
ALTER SEQUENCE prftcntr_prftcntr_id_seq OWNED BY prftcntr.prftcntr_id;
93735
 
 
93736
 
 
93737
 
--
93738
 
--
93739
 
 
93740
 
CREATE TABLE usrgrp (
93741
 
    usrgrp_id integer NOT NULL,
93742
 
    usrgrp_grp_id integer NOT NULL,
93743
 
    usrgrp_username text NOT NULL
93744
 
);
93745
 
 
93746
 
 
93747
 
ALTER TABLE public.usrgrp OWNER TO admin;
93748
 
 
93749
 
--
93750
 
--
93751
 
 
93752
 
COMMENT ON TABLE usrgrp IS 'This is which group a user belongs to.';
93753
 
 
93754
 
 
93755
 
--
93756
 
--
93757
 
 
93758
 
CREATE TABLE usrpriv (
93759
 
    usrpriv_id integer DEFAULT nextval(('usrpriv_usrpriv_id_seq'::text)::regclass) NOT NULL,
93760
 
    usrpriv_priv_id integer,
93761
 
    usrpriv_username text
93762
 
);
93763
 
 
93764
 
 
93765
 
ALTER TABLE public.usrpriv OWNER TO admin;
93766
 
 
93767
 
--
93768
 
--
93769
 
 
93770
 
COMMENT ON TABLE usrpriv IS 'User Privileges information';
93771
 
 
93772
 
 
93773
 
--
93774
 
--
93775
 
 
93776
 
CREATE VIEW privgranted AS
93777
 
    SELECT priv.priv_name AS privilege, (COALESCE(usrpriv.usrpriv_priv_id, grppriv.grppriv_priv_id, (-1)) > 0) AS granted, priv.priv_seq AS sequence FROM ((priv LEFT JOIN usrpriv ON (((priv.priv_id = usrpriv.usrpriv_priv_id) AND (usrpriv.usrpriv_username = geteffectivextuser())))) LEFT JOIN (SELECT DISTINCT grppriv.grppriv_priv_id FROM (grppriv JOIN usrgrp ON (((grppriv.grppriv_grp_id = usrgrp.usrgrp_grp_id) AND (usrgrp.usrgrp_username = geteffectivextuser()))))) grppriv ON ((grppriv.grppriv_priv_id = priv.priv_id)));
93778
 
 
93779
 
 
93780
 
ALTER TABLE public.privgranted OWNER TO admin;
93781
 
 
93782
 
--
93783
 
--
93784
 
 
93785
 
CREATE SEQUENCE prj_prj_id_seq
93786
 
    START WITH 1
93787
 
    INCREMENT BY 1
93788
 
    NO MINVALUE
93789
 
    NO MAXVALUE
93790
 
    CACHE 1;
93791
 
 
93792
 
 
93793
 
ALTER TABLE public.prj_prj_id_seq OWNER TO admin;
93794
 
 
93795
 
--
93796
 
--
93797
 
 
93798
 
ALTER SEQUENCE prj_prj_id_seq OWNED BY prj.prj_id;
93799
 
 
93800
 
 
93801
 
--
93802
 
--
93803
 
 
93804
 
CREATE SEQUENCE prjtask_prjtask_id_seq
93805
 
    START WITH 1
93806
 
    INCREMENT BY 1
93807
 
    NO MINVALUE
93808
 
    NO MAXVALUE
93809
 
    CACHE 1;
93810
 
 
93811
 
 
93812
 
ALTER TABLE public.prjtask_prjtask_id_seq OWNER TO admin;
93813
 
 
93814
 
--
93815
 
--
93816
 
 
93817
 
ALTER SEQUENCE prjtask_prjtask_id_seq OWNED BY prjtask.prjtask_id;
93818
 
 
93819
 
 
93820
 
--
93821
 
--
93822
 
 
93823
 
CREATE TABLE prjtaskuser (
93824
 
    prjtaskuser_id integer NOT NULL,
93825
 
    prjtaskuser_prjtask_id integer,
93826
 
    prjtaskuser_username text
93827
 
);
93828
 
 
93829
 
 
93830
 
ALTER TABLE public.prjtaskuser OWNER TO admin;
93831
 
 
93832
 
--
93833
 
--
93834
 
 
93835
 
COMMENT ON TABLE prjtaskuser IS 'Project Task user information';
93836
 
 
93837
 
 
93838
 
--
93839
 
--
93840
 
 
93841
 
CREATE SEQUENCE prjtaskuser_prjtaskuser_id_seq
93842
 
    START WITH 1
93843
 
    INCREMENT BY 1
93844
 
    NO MINVALUE
93845
 
    NO MAXVALUE
93846
 
    CACHE 1;
93847
 
 
93848
 
 
93849
 
ALTER TABLE public.prjtaskuser_prjtaskuser_id_seq OWNER TO admin;
93850
 
 
93851
 
--
93852
 
--
93853
 
 
93854
 
ALTER SEQUENCE prjtaskuser_prjtaskuser_id_seq OWNED BY prjtaskuser.prjtaskuser_id;
93855
 
 
93856
 
 
93857
 
--
93858
 
--
93859
 
 
93860
 
CREATE TABLE prjtype (
93861
 
    prjtype_id integer NOT NULL,
93862
 
    prjtype_code text,
93863
 
    prjtype_descr text,
93864
 
    prjtype_active boolean DEFAULT true
93865
 
);
93866
 
 
93867
 
 
93868
 
ALTER TABLE public.prjtype OWNER TO admin;
93869
 
 
93870
 
--
93871
 
--
93872
 
 
93873
 
CREATE SEQUENCE prjtype_prjtype_id_seq
93874
 
    START WITH 1
93875
 
    INCREMENT BY 1
93876
 
    NO MINVALUE
93877
 
    NO MAXVALUE
93878
 
    CACHE 1;
93879
 
 
93880
 
 
93881
 
ALTER TABLE public.prjtype_prjtype_id_seq OWNER TO admin;
93882
 
 
93883
 
--
93884
 
--
93885
 
 
93886
 
ALTER SEQUENCE prjtype_prjtype_id_seq OWNED BY prjtype.prjtype_id;
93887
 
 
93888
 
 
93889
 
--
93890
 
--
93891
 
 
93892
 
CREATE SEQUENCE prodcat_prodcat_id_seq
93893
 
    START WITH 1
93894
 
    INCREMENT BY 1
93895
 
    NO MINVALUE
93896
 
    MAXVALUE 2147483647
93897
 
    CACHE 1;
93898
 
 
93899
 
 
93900
 
ALTER TABLE public.prodcat_prodcat_id_seq OWNER TO admin;
93901
 
 
93902
 
--
93903
 
--
93904
 
 
93905
 
CREATE TABLE qryhead (
93906
 
    qryhead_id integer NOT NULL,
93907
 
    qryhead_name text NOT NULL,
93908
 
    qryhead_descrip text,
93909
 
    qryhead_notes text,
93910
 
    qryhead_username text DEFAULT geteffectivextuser() NOT NULL,
93911
 
    qryhead_updated date DEFAULT ('now'::text)::date NOT NULL,
93912
 
    CONSTRAINT qryhead_qryhead_name_check CHECK ((qryhead_name <> ''::text))
93913
 
);
93914
 
 
93915
 
 
93916
 
ALTER TABLE public.qryhead OWNER TO admin;
93917
 
 
93918
 
--
93919
 
--
93920
 
 
93921
 
COMMENT ON TABLE qryhead IS 'A header record for a set of queries to be run sequentially. One use is for data export.';
93922
 
 
93923
 
 
93924
 
--
93925
 
--
93926
 
 
93927
 
COMMENT ON COLUMN qryhead.qryhead_id IS 'The primary key, holding an internal value used to cross-reference this table.';
93928
 
 
93929
 
 
93930
 
--
93931
 
--
93932
 
 
93933
 
COMMENT ON COLUMN qryhead.qryhead_name IS 'The user-assigned short name for this set of queries.';
93934
 
 
93935
 
 
93936
 
--
93937
 
--
93938
 
 
93939
 
COMMENT ON COLUMN qryhead.qryhead_descrip IS 'A long description of the purpose of this set of queries.';
93940
 
 
93941
 
 
93942
 
--
93943
 
--
93944
 
 
93945
 
COMMENT ON COLUMN qryhead.qryhead_notes IS 'General information about this queryset.';
93946
 
 
93947
 
 
93948
 
--
93949
 
--
93950
 
 
93951
 
COMMENT ON COLUMN qryhead.qryhead_username IS 'The name of the user who last modified this qryhead record.';
93952
 
 
93953
 
 
93954
 
--
93955
 
--
93956
 
 
93957
 
COMMENT ON COLUMN qryhead.qryhead_updated IS 'The date this qryhead was last modified.';
93958
 
 
93959
 
 
93960
 
--
93961
 
--
93962
 
 
93963
 
CREATE SEQUENCE qryhead_qryhead_id_seq
93964
 
    START WITH 1
93965
 
    INCREMENT BY 1
93966
 
    NO MINVALUE
93967
 
    NO MAXVALUE
93968
 
    CACHE 1;
93969
 
 
93970
 
 
93971
 
ALTER TABLE public.qryhead_qryhead_id_seq OWNER TO admin;
93972
 
 
93973
 
--
93974
 
--
93975
 
 
93976
 
ALTER SEQUENCE qryhead_qryhead_id_seq OWNED BY qryhead.qryhead_id;
93977
 
 
93978
 
 
93979
 
--
93980
 
--
93981
 
 
93982
 
CREATE TABLE qryitem (
93983
 
    qryitem_id integer NOT NULL,
93984
 
    qryitem_qryhead_id integer NOT NULL,
93985
 
    qryitem_name text NOT NULL,
93986
 
    qryitem_order integer NOT NULL,
93987
 
    qryitem_src text NOT NULL,
93988
 
    qryitem_group text,
93989
 
    qryitem_detail text NOT NULL,
93990
 
    qryitem_notes text DEFAULT ''::text NOT NULL,
93991
 
    qryitem_username text DEFAULT geteffectivextuser() NOT NULL,
93992
 
    qryitem_updated date DEFAULT ('now'::text)::date NOT NULL,
93993
 
    CONSTRAINT qryitem_qryitem_detail_check CHECK ((btrim(qryitem_detail) <> ''::text)),
93994
 
    CONSTRAINT qryitem_qryitem_src_check CHECK ((qryitem_src = ANY (ARRAY['REL'::text, 'MQL'::text, 'CUSTOM'::text])))
93995
 
);
93996
 
 
93997
 
 
93998
 
ALTER TABLE public.qryitem OWNER TO admin;
93999
 
 
94000
 
--
94001
 
--
94002
 
 
94003
 
COMMENT ON TABLE qryitem IS 'The description of a query to be run as part of a set (see qryhead).';
94004
 
 
94005
 
 
94006
 
--
94007
 
--
94008
 
 
94009
 
COMMENT ON COLUMN qryitem.qryitem_id IS 'The primary key, holding an internal value used to cross-reference this table.';
94010
 
 
94011
 
 
94012
 
--
94013
 
--
94014
 
 
94015
 
COMMENT ON COLUMN qryitem.qryitem_qryhead_id IS 'The primary key of the query set to which this individual query belongs.';
94016
 
 
94017
 
 
94018
 
--
94019
 
--
94020
 
 
94021
 
COMMENT ON COLUMN qryitem.qryitem_order IS 'The order in which query items within a query set should be run.';
94022
 
 
94023
 
 
94024
 
--
94025
 
--
94026
 
 
94027
 
COMMENT ON COLUMN qryitem.qryitem_src IS 'The source of the query. If the qryitem_src is "REL" then the qryitem_group and _detail name a particular table or view and all rows will be returned. If the source is "MQL" then the qryitem_group and _detail name a pre-defined MetaSQL query in the metasql table. If the source is "CUSTOM" then the qryitem_detail contains the full MetaSQL text of the query to run.';
94028
 
 
94029
 
 
94030
 
--
94031
 
--
94032
 
 
94033
 
COMMENT ON COLUMN qryitem.qryitem_group IS 'Information to help find the query to run. If the qryitem_src is "REL" then this is the schema in which to find the table or view to query and all rows will be returned (the qryitem_detail names the table or view). If the qryitem_src is "MQL" then this is the group of the query in the metasql table to run (the name is in qryitem_detail). If the qryitem_src IS "CUSTOM" then this ignored.';
94034
 
 
94035
 
 
94036
 
--
94037
 
--
94038
 
 
94039
 
COMMENT ON COLUMN qryitem.qryitem_detail IS 'The particular query to run. If the qryitem_src is "REL" then this is the name of the table or view to query and all rows will be returned. If the qryitem_src is "MQL" then this is the name of the query in the metasql table to run. If the qryitem_src IS "CUSTOM" then this is the actual MetaSQL query text to be parsed and run.';
94040
 
 
94041
 
 
94042
 
--
94043
 
--
94044
 
 
94045
 
COMMENT ON COLUMN qryitem.qryitem_notes IS 'General information about this query.';
94046
 
 
94047
 
 
94048
 
--
94049
 
--
94050
 
 
94051
 
COMMENT ON COLUMN qryitem.qryitem_username IS 'The name of the user who last modified this qryitem record.';
94052
 
 
94053
 
 
94054
 
--
94055
 
--
94056
 
 
94057
 
COMMENT ON COLUMN qryitem.qryitem_updated IS 'The date this qryitem was last modified.';
94058
 
 
94059
 
 
94060
 
--
94061
 
--
94062
 
 
94063
 
CREATE SEQUENCE qryitem_qryitem_id_seq
94064
 
    START WITH 1
94065
 
    INCREMENT BY 1
94066
 
    NO MINVALUE
94067
 
    NO MAXVALUE
94068
 
    CACHE 1;
94069
 
 
94070
 
 
94071
 
ALTER TABLE public.qryitem_qryitem_id_seq OWNER TO admin;
94072
 
 
94073
 
--
94074
 
--
94075
 
 
94076
 
ALTER SEQUENCE qryitem_qryitem_id_seq OWNED BY qryitem.qryitem_id;
94077
 
 
94078
 
 
94079
 
--
94080
 
--
94081
 
 
94082
 
CREATE SEQUENCE quhead_quhead_id_seq
94083
 
    START WITH 1
94084
 
    INCREMENT BY 1
94085
 
    NO MINVALUE
94086
 
    NO MAXVALUE
94087
 
    CACHE 1;
94088
 
 
94089
 
 
94090
 
ALTER TABLE public.quhead_quhead_id_seq OWNER TO admin;
94091
 
 
94092
 
--
94093
 
--
94094
 
 
94095
 
CREATE SEQUENCE quitem_quitem_id_seq
94096
 
    START WITH 1
94097
 
    INCREMENT BY 1
94098
 
    NO MINVALUE
94099
 
    NO MAXVALUE
94100
 
    CACHE 1;
94101
 
 
94102
 
 
94103
 
ALTER TABLE public.quitem_quitem_id_seq OWNER TO admin;
94104
 
 
94105
 
--
94106
 
--
94107
 
 
94108
 
CREATE TABLE rcalitem (
94109
 
    rcalitem_id integer DEFAULT nextval(('"xcalitem_xcalitem_id_seq"'::text)::regclass) NOT NULL,
94110
 
    rcalitem_calhead_id integer,
94111
 
    rcalitem_offsettype character(1),
94112
 
    rcalitem_offsetcount integer,
94113
 
    rcalitem_periodtype character(1),
94114
 
    rcalitem_periodcount integer,
94115
 
    rcalitem_name text
94116
 
);
94117
 
 
94118
 
 
94119
 
ALTER TABLE public.rcalitem OWNER TO admin;
94120
 
 
94121
 
--
94122
 
--
94123
 
 
94124
 
COMMENT ON TABLE rcalitem IS 'Relative Calendar Item information';
94125
 
 
94126
 
 
94127
 
--
94128
 
--
94129
 
 
94130
 
CREATE TABLE recur (
94131
 
    recur_id integer NOT NULL,
94132
 
    recur_parent_id integer NOT NULL,
94133
 
    recur_parent_type text NOT NULL,
94134
 
    recur_period text NOT NULL,
94135
 
    recur_freq integer DEFAULT 1 NOT NULL,
94136
 
    recur_start timestamp with time zone DEFAULT now(),
94137
 
    recur_end timestamp with time zone,
94138
 
    recur_max integer,
94139
 
    recur_data text,
94140
 
    CONSTRAINT recur_recur_period_check CHECK ((recur_period = ANY (ARRAY['m'::text, 'H'::text, 'D'::text, 'W'::text, 'M'::text, 'Y'::text, 'C'::text])))
94141
 
);
94142
 
 
94143
 
 
94144
 
ALTER TABLE public.recur OWNER TO admin;
94145
 
 
94146
 
--
94147
 
--
94148
 
 
94149
 
COMMENT ON TABLE recur IS 'Track recurring events and objects.';
94150
 
 
94151
 
 
94152
 
--
94153
 
--
94154
 
 
94155
 
COMMENT ON COLUMN recur.recur_id IS 'Internal ID of this recurrence record.';
94156
 
 
94157
 
 
94158
 
--
94159
 
--
94160
 
 
94161
 
COMMENT ON COLUMN recur.recur_parent_id IS 'The internal ID of the event/object that recurs.';
94162
 
 
94163
 
 
94164
 
--
94165
 
--
94166
 
 
94167
 
COMMENT ON COLUMN recur.recur_parent_type IS 'The table in which the parent event or object is stored.';
94168
 
 
94169
 
 
94170
 
--
94171
 
--
94172
 
 
94173
 
COMMENT ON COLUMN recur.recur_period IS 'With recur_freq, how often this event recurs. Values are "m" for every minute, "H" for every hour, "D" for daily, "W" for weekly, "M" for monthly, "Y" for yearly, and "C" for customized or complex.';
94174
 
 
94175
 
 
94176
 
--
94177
 
--
94178
 
 
94179
 
COMMENT ON COLUMN recur.recur_freq IS 'With recur_period, how often this event recurs. Values are integers counts of recur_periods. For example, if recur_freq = 2 and recur_period = w then the event recurs every 2 weeks.';
94180
 
 
94181
 
 
94182
 
--
94183
 
--
94184
 
 
94185
 
COMMENT ON COLUMN recur.recur_start IS 'The first date/time when the event should occur.';
94186
 
 
94187
 
 
94188
 
--
94189
 
--
94190
 
 
94191
 
COMMENT ON COLUMN recur.recur_end IS 'The last date/time when the event should occur. NULL means there is no end date/time and the event should recur forever.';
94192
 
 
94193
 
 
94194
 
--
94195
 
--
94196
 
 
94197
 
COMMENT ON COLUMN recur.recur_max IS 'The maximum number of recurrence events to create at one time. If this is NULL then when new events are created, a system-wide default will limit the number.';
94198
 
 
94199
 
 
94200
 
--
94201
 
--
94202
 
 
94203
 
COMMENT ON COLUMN recur.recur_data IS 'Not yet used and format still undetermined. Additional data to describe how to apply the period and frequency, particularly when period = "C".';
94204
 
 
94205
 
 
94206
 
--
94207
 
--
94208
 
 
94209
 
CREATE SEQUENCE recur_recur_id_seq
94210
 
    START WITH 1
94211
 
    INCREMENT BY 1
94212
 
    NO MINVALUE
94213
 
    NO MAXVALUE
94214
 
    CACHE 1;
94215
 
 
94216
 
 
94217
 
ALTER TABLE public.recur_recur_id_seq OWNER TO admin;
94218
 
 
94219
 
--
94220
 
--
94221
 
 
94222
 
ALTER SEQUENCE recur_recur_id_seq OWNED BY recur.recur_id;
94223
 
 
94224
 
 
94225
 
--
94226
 
--
94227
 
 
94228
 
CREATE TABLE recurtype (
94229
 
    recurtype_id integer NOT NULL,
94230
 
    recurtype_type text NOT NULL,
94231
 
    recurtype_table text NOT NULL,
94232
 
    recurtype_donecheck text NOT NULL,
94233
 
    recurtype_schedcol text NOT NULL,
94234
 
    recurtype_limit text,
94235
 
    recurtype_copyfunc text NOT NULL,
94236
 
    recurtype_copyargs text[] NOT NULL,
94237
 
    recurtype_delfunc text
94238
 
);
94239
 
 
94240
 
 
94241
 
ALTER TABLE public.recurtype OWNER TO admin;
94242
 
 
94243
 
--
94244
 
--
94245
 
 
94246
 
COMMENT ON TABLE recurtype IS 'Describes the properties of recurring items/events in way that can be used by stored procedures to maintain the recurrence.';
94247
 
 
94248
 
 
94249
 
--
94250
 
--
94251
 
 
94252
 
COMMENT ON COLUMN recurtype.recurtype_id IS 'The internal id of this recurrence description.';
94253
 
 
94254
 
 
94255
 
--
94256
 
--
94257
 
 
94258
 
COMMENT ON COLUMN recurtype.recurtype_type IS 'A code value used by the RecurrenceWidget and the code that uses it to describe the item/event that will recur. Examples include "INCDT" for CRM Incidents and "J" for Projects.';
94259
 
 
94260
 
 
94261
 
--
94262
 
--
94263
 
 
94264
 
COMMENT ON COLUMN recurtype.recurtype_table IS 'The table that holds the item/event that will recur.';
94265
 
 
94266
 
 
94267
 
--
94268
 
--
94269
 
 
94270
 
COMMENT ON COLUMN recurtype.recurtype_donecheck IS 'A boolean expression that returns TRUE if an individual item/event record in the recurtype_table has already been completed.';
94271
 
 
94272
 
 
94273
 
--
94274
 
--
94275
 
 
94276
 
COMMENT ON COLUMN recurtype.recurtype_schedcol IS 'The name of the column in the recurtype_table holding the date or timestamp by which the item is scheduled to be completed or at which the event is supposed to occur.';
94277
 
 
94278
 
 
94279
 
--
94280
 
--
94281
 
 
94282
 
COMMENT ON COLUMN recurtype.recurtype_limit IS 'A boolean expression that returns TRUE if the current user should see the row in the recurtype_table. NULL indicates there is no specific limitation. For example, the maintainance of recurring TODO items should restricted to those items belonging to the user unless s/he has been granted the privilege to modify other people''s todo lists.';
94283
 
 
94284
 
 
94285
 
--
94286
 
--
94287
 
 
94288
 
COMMENT ON COLUMN recurtype.recurtype_copyfunc IS 'The name of the function to copy an existing item/event record. The copy function is expected to take at least 2 arguments: the id of the item to copy and the new date/timestamp. If the function accepts more than 2, it must be able to accept NULL values for the 3rd and following arguments.';
94289
 
 
94290
 
 
94291
 
--
94292
 
--
94293
 
 
94294
 
COMMENT ON COLUMN recurtype.recurtype_copyargs IS 'An abbreviated argument list for the copy function. This is used to determine whether the second argument must be cast to a date or a timestamp, and to figure out how many additional arguments to pass.';
94295
 
 
94296
 
 
94297
 
--
94298
 
--
94299
 
 
94300
 
COMMENT ON COLUMN recurtype.recurtype_delfunc IS 'The name of the function to delete an existing item/event record. The function is expected to take exactly one argument: the id of the item to delete. NULL indicates there is no delete function and that an SQL DELETE statement can be used. In this case, the id column name will be built as the recurtype_table concatenated with the "_id" suffix.';
94301
 
 
94302
 
 
94303
 
--
94304
 
--
94305
 
 
94306
 
CREATE SEQUENCE recurtype_recurtype_id_seq
94307
 
    START WITH 1
94308
 
    INCREMENT BY 1
94309
 
    NO MINVALUE
94310
 
    NO MAXVALUE
94311
 
    CACHE 1;
94312
 
 
94313
 
 
94314
 
ALTER TABLE public.recurtype_recurtype_id_seq OWNER TO admin;
94315
 
 
94316
 
--
94317
 
--
94318
 
 
94319
 
ALTER SEQUENCE recurtype_recurtype_id_seq OWNED BY recurtype.recurtype_id;
94320
 
 
94321
 
 
94322
 
--
94323
 
--
94324
 
 
94325
 
CREATE SEQUENCE recv_recv_id_seq
94326
 
    START WITH 1
94327
 
    INCREMENT BY 1
94328
 
    NO MINVALUE
94329
 
    NO MAXVALUE
94330
 
    CACHE 1;
94331
 
 
94332
 
 
94333
 
ALTER TABLE public.recv_recv_id_seq OWNER TO admin;
94334
 
 
94335
 
--
94336
 
--
94337
 
 
94338
 
ALTER SEQUENCE recv_recv_id_seq OWNED BY recv.recv_id;
94339
 
 
94340
 
 
94341
 
--
94342
 
--
94343
 
 
94344
 
CREATE VIEW remitto AS
94345
 
    SELECT (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_name'::text)) AS remitto_name, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_address1'::text)) AS remitto_address1, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_address2'::text)) AS remitto_address2, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_address3'::text)) AS remitto_address3, (((((SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_city'::text)) || '  '::text) || (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_state'::text))) || '  '::text) || (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_zipcode'::text))) AS remitto_citystatezip, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_country'::text)) AS remitto_country, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_phone'::text)) AS remitto_phone;
94346
 
 
94347
 
 
94348
 
ALTER TABLE public.remitto OWNER TO admin;
94349
 
 
94350
 
--
94351
 
--
94352
 
 
94353
 
CREATE TABLE rjctcode (
94354
 
    rjctcode_id integer DEFAULT nextval(('"rjctcode_rjctcode_id_seq"'::text)::regclass) NOT NULL,
94355
 
    rjctcode_code text NOT NULL,
94356
 
    rjctcode_descrip text,
94357
 
    CONSTRAINT rjctcode_rjctcode_code_check CHECK ((rjctcode_code <> ''::text))
94358
 
);
94359
 
 
94360
 
 
94361
 
ALTER TABLE public.rjctcode OWNER TO admin;
94362
 
 
94363
 
--
94364
 
--
94365
 
 
94366
 
COMMENT ON TABLE rjctcode IS 'Reject Code information';
94367
 
 
94368
 
 
94369
 
--
94370
 
--
94371
 
 
94372
 
CREATE SEQUENCE rjctcode_rjctcode_id_seq
94373
 
    START WITH 1
94374
 
    INCREMENT BY 1
94375
 
    NO MINVALUE
94376
 
    MAXVALUE 2147483647
94377
 
    CACHE 1;
94378
 
 
94379
 
 
94380
 
ALTER TABLE public.rjctcode_rjctcode_id_seq OWNER TO admin;
94381
 
 
94382
 
--
94383
 
--
94384
 
 
94385
 
CREATE SEQUENCE rsncode_rsncode_id_seq
94386
 
    START WITH 1
94387
 
    INCREMENT BY 1
94388
 
    NO MINVALUE
94389
 
    NO MAXVALUE
94390
 
    CACHE 1;
94391
 
 
94392
 
 
94393
 
ALTER TABLE public.rsncode_rsncode_id_seq OWNER TO admin;
94394
 
 
94395
 
--
94396
 
--
94397
 
 
94398
 
ALTER SEQUENCE rsncode_rsncode_id_seq OWNED BY rsncode.rsncode_id;
94399
 
 
94400
 
 
94401
 
--
94402
 
--
94403
 
 
94404
 
CREATE TABLE sale (
94405
 
    sale_id integer DEFAULT nextval(('"sale_sale_id_seq"'::text)::regclass) NOT NULL,
94406
 
    sale_name text NOT NULL,
94407
 
    sale_descrip text,
94408
 
    sale_ipshead_id integer,
94409
 
    sale_startdate date,
94410
 
    sale_enddate date,
94411
 
    CONSTRAINT sale_sale_name_check CHECK ((sale_name <> ''::text))
94412
 
);
94413
 
 
94414
 
 
94415
 
ALTER TABLE public.sale OWNER TO admin;
94416
 
 
94417
 
--
94418
 
--
94419
 
 
94420
 
COMMENT ON TABLE sale IS 'Sale information';
94421
 
 
94422
 
 
94423
 
--
94424
 
--
94425
 
 
94426
 
CREATE SEQUENCE sale_sale_id_seq
94427
 
    START WITH 1
94428
 
    INCREMENT BY 1
94429
 
    NO MINVALUE
94430
 
    NO MAXVALUE
94431
 
    CACHE 1;
94432
 
 
94433
 
 
94434
 
ALTER TABLE public.sale_sale_id_seq OWNER TO admin;
94435
 
 
94436
 
--
94437
 
--
94438
 
 
94439
 
CREATE SEQUENCE salesaccnt_salesaccnt_id_seq
94440
 
    START WITH 1
94441
 
    INCREMENT BY 1
94442
 
    NO MINVALUE
94443
 
    MAXVALUE 2147483647
94444
 
    CACHE 1;
94445
 
 
94446
 
 
94447
 
ALTER TABLE public.salesaccnt_salesaccnt_id_seq OWNER TO admin;
94448
 
 
94449
 
--
94450
 
--
94451
 
 
94452
 
CREATE SEQUENCE salescat_salescat_id_seq
94453
 
    START WITH 1
94454
 
    INCREMENT BY 1
94455
 
    NO MINVALUE
94456
 
    NO MAXVALUE
94457
 
    CACHE 1;
94458
 
 
94459
 
 
94460
 
ALTER TABLE public.salescat_salescat_id_seq OWNER TO admin;
94461
 
 
94462
 
--
94463
 
--
94464
 
 
94465
 
ALTER SEQUENCE salescat_salescat_id_seq OWNED BY salescat.salescat_id;
94466
 
 
94467
 
 
94468
 
--
94469
 
--
94470
 
 
94471
 
CREATE VIEW saleshistory AS
94472
 
    SELECT data.cohist_id, data.cohist_cust_id, data.cohist_itemsite_id, data.cohist_shipdate, data.cohist_shipvia, data.cohist_ordernumber, data.cohist_orderdate, data.cohist_invcnumber, data.cohist_invcdate, data.cohist_qtyshipped, data.cohist_unitprice, data.cohist_shipto_id, data.cohist_salesrep_id, data.cohist_duedate, data.cohist_imported, data.cohist_billtoname, data.cohist_billtoaddress1, data.cohist_billtoaddress2, data.cohist_billtoaddress3, data.cohist_billtocity, data.cohist_billtostate, data.cohist_billtozip, data.cohist_shiptoname, data.cohist_shiptoaddress1, data.cohist_shiptoaddress2, data.cohist_shiptoaddress3, data.cohist_shiptocity, data.cohist_shiptostate, data.cohist_shiptozip, data.cohist_commission, data.cohist_commissionpaid, data.cohist_unitcost, data.cohist_misc_type, data.cohist_misc_descrip, data.cohist_misc_id, data.cohist_doctype, data.cohist_promisedate, data.cohist_ponumber, data.cohist_curr_id, data.cohist_sequence, data.cohist_taxtype_id, data.cohist_taxzone_id, data.cohist_cohead_ccpay_id, data.cohist_saletype_id, data.cohist_shipzone_id, data.cohead_id, data.cust_id, data.cust_number, data.cust_name, data.cust_curr_id, data.custtype_id, data.custtype_code, data.custtype_descrip, data.salesrep_id, data.salesrep_number, data.salesrep_name, data.shipzone_id, data.shipzone_name, data.shipzone_descrip, data.saletype_code, data.saletype_descr, data.itemsite_id, data.warehous_id, data.warehous_code, data.warehous_descrip, data.item_id, data.item_number, data.item_descrip1, data.item_descrip2, data.itemdescription, data.itemnumber, data.prodcat_id, data.prodcat_code, data.basecommission, data.baseunitprice, data.custunitprice, round((data.cohist_qtyshipped * data.cohist_unitprice), 2) AS extprice, round((data.cohist_qtyshipped * data.baseunitprice), 2) AS baseextprice, round((data.cohist_qtyshipped * data.custunitprice), 2) AS custextprice, round((data.cohist_qtyshipped * data.cohist_unitcost), 4) AS extcost, round(((data.cohist_qtyshipped * data.baseunitprice) - (data.cohist_qtyshipped * data.cohist_unitcost)), 2) AS margin, CASE WHEN ((data.cohist_qtyshipped * data.baseunitprice) > 0.0) THEN (round(((data.cohist_qtyshipped * data.baseunitprice) - (data.cohist_qtyshipped * data.cohist_unitcost)), 2) / round((data.cohist_qtyshipped * data.baseunitprice), 2)) ELSE 0.0 END AS marginpercent, currconcat(data.cohist_curr_id) AS currabbr, 'qty'::text AS cohist_qtyshipped_xtnumericrole, 'salesprice'::text AS cohist_unitprice_xtnumericrole, 'salesprice'::text AS baseunitprice_xtnumericrole, 'curr'::text AS custunitprice_xtnumericrole, 'curr'::text AS custextprice_xtnumericrole, 'curr'::text AS extprice_xtnumericrole, 'curr'::text AS baseextprice_xtnumericrole, 'cost'::text AS cohist_unitcost_xtnumericrole, 'curr'::text AS extcost_xtnumericrole, 'curr'::text AS margin_xtnumericrole, 'percent'::text AS marginpercent_xtnumericrole, 'curr'::text AS cohist_commission_xtnumericrole, 'curr'::text AS basecommission_xtnumericrole FROM (SELECT cohist.cohist_id, cohist.cohist_cust_id, cohist.cohist_itemsite_id, cohist.cohist_shipdate, cohist.cohist_shipvia, cohist.cohist_ordernumber, cohist.cohist_orderdate, cohist.cohist_invcnumber, cohist.cohist_invcdate, cohist.cohist_qtyshipped, cohist.cohist_unitprice, cohist.cohist_shipto_id, cohist.cohist_salesrep_id, cohist.cohist_duedate, cohist.cohist_imported, cohist.cohist_billtoname, cohist.cohist_billtoaddress1, cohist.cohist_billtoaddress2, cohist.cohist_billtoaddress3, cohist.cohist_billtocity, cohist.cohist_billtostate, cohist.cohist_billtozip, cohist.cohist_shiptoname, cohist.cohist_shiptoaddress1, cohist.cohist_shiptoaddress2, cohist.cohist_shiptoaddress3, cohist.cohist_shiptocity, cohist.cohist_shiptostate, cohist.cohist_shiptozip, cohist.cohist_commission, cohist.cohist_commissionpaid, cohist.cohist_unitcost, cohist.cohist_misc_type, cohist.cohist_misc_descrip, cohist.cohist_misc_id, cohist.cohist_doctype, cohist.cohist_promisedate, cohist.cohist_ponumber, cohist.cohist_curr_id, cohist.cohist_sequence, cohist.cohist_taxtype_id, cohist.cohist_taxzone_id, cohist.cohist_cohead_ccpay_id, cohist.cohist_saletype_id, cohist.cohist_shipzone_id, COALESCE(cohead.cohead_id, (-1)) AS cohead_id, custinfo.cust_id, custinfo.cust_number, custinfo.cust_name, custinfo.cust_curr_id, custtype.custtype_id, custtype.custtype_code, custtype.custtype_descrip, salesrep.salesrep_id, salesrep.salesrep_number, salesrep.salesrep_name, shipzone.shipzone_id, shipzone.shipzone_name, shipzone.shipzone_descrip, saletype.saletype_code, saletype.saletype_descr, itemsite.itemsite_id, site.warehous_id, site.warehous_code, site.warehous_descrip, item.item_id, item.item_number, item.item_descrip1, item.item_descrip2, ((item.item_descrip1 || ' '::text) || item.item_descrip2) AS itemdescription, COALESCE(item.item_number, cohist.cohist_misc_descrip) AS itemnumber, prodcat.prodcat_id, prodcat.prodcat_code, currtobase(cohist.cohist_curr_id, cohist.cohist_commission, cohist.cohist_invcdate) AS basecommission, currtobase(cohist.cohist_curr_id, cohist.cohist_unitprice, cohist.cohist_invcdate) AS baseunitprice, currtocurr(cohist.cohist_curr_id, custinfo.cust_curr_id, cohist.cohist_unitprice, cohist.cohist_invcdate) AS custunitprice FROM (((((((((((cohist JOIN custinfo ON ((custinfo.cust_id = cohist.cohist_cust_id))) LEFT JOIN cohead ON ((cohead.cohead_number = cohist.cohist_ordernumber))) LEFT JOIN custtype ON ((custtype.custtype_id = custinfo.cust_custtype_id))) LEFT JOIN salesrep ON ((salesrep.salesrep_id = cohist.cohist_salesrep_id))) LEFT JOIN shiptoinfo ON ((shiptoinfo.shipto_id = cohist.cohist_shipto_id))) LEFT JOIN shipzone ON ((shipzone.shipzone_id = shiptoinfo.shipto_shipzone_id))) LEFT JOIN saletype ON ((saletype.saletype_id = cohist.cohist_saletype_id))) JOIN itemsite ON ((itemsite.itemsite_id = cohist.cohist_itemsite_id))) JOIN site() site(warehous_id, warehous_code, warehous_descrip, warehous_fob, warehous_active, warehous_counttag_prefix, warehous_counttag_number, warehous_bol_prefix, warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, warehous_aislesize, warehous_aislealpha, warehous_racksize, warehous_rackalpha, warehous_binsize, warehous_binalpha, warehous_locationsize, warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, warehous_shipping_commission, warehous_cntct_id, warehous_addr_id, warehous_transit, warehous_shipform_id, warehous_shipvia_id, warehous_shipcomments, warehous_costcat_id, warehous_sitetype_id, warehous_taxzone_id, warehous_sequence) ON ((site.warehous_id = itemsite.itemsite_warehous_id))) JOIN item ON ((item.item_id = itemsite.itemsite_item_id))) JOIN prodcat ON ((prodcat.prodcat_id = item.item_prodcat_id)))) data;
94473
 
 
94474
 
 
94475
 
ALTER TABLE public.saleshistory OWNER TO admin;
94476
 
 
94477
 
--
94478
 
--
94479
 
 
94480
 
COMMENT ON VIEW saleshistory IS 'Single point for sales history calculations.';
94481
 
 
94482
 
 
94483
 
--
94484
 
--
94485
 
 
94486
 
CREATE VIEW saleshistorymisc AS
94487
 
    SELECT data.cohist_id, data.cohist_cust_id, data.cohist_itemsite_id, data.cohist_shipdate, data.cohist_shipvia, data.cohist_ordernumber, data.cohist_orderdate, data.cohist_invcnumber, data.cohist_invcdate, data.cohist_qtyshipped, data.cohist_unitprice, data.cohist_shipto_id, data.cohist_salesrep_id, data.cohist_duedate, data.cohist_imported, data.cohist_billtoname, data.cohist_billtoaddress1, data.cohist_billtoaddress2, data.cohist_billtoaddress3, data.cohist_billtocity, data.cohist_billtostate, data.cohist_billtozip, data.cohist_shiptoname, data.cohist_shiptoaddress1, data.cohist_shiptoaddress2, data.cohist_shiptoaddress3, data.cohist_shiptocity, data.cohist_shiptostate, data.cohist_shiptozip, data.cohist_commission, data.cohist_commissionpaid, data.cohist_unitcost, data.cohist_misc_type, data.cohist_misc_descrip, data.cohist_misc_id, data.cohist_doctype, data.cohist_promisedate, data.cohist_ponumber, data.cohist_curr_id, data.cohist_sequence, data.cohist_taxtype_id, data.cohist_taxzone_id, data.cohist_cohead_ccpay_id, data.cohist_saletype_id, data.cohist_shipzone_id, data.cohead_id, data.cust_id, data.cust_number, data.cust_name, data.cust_curr_id, data.custtype_id, data.custtype_code, data.custtype_descrip, data.salesrep_id, data.salesrep_number, data.salesrep_name, data.shipzone_id, data.shipzone_name, data.shipzone_descrip, data.saletype_code, data.saletype_descr, data.itemsite_id, data.warehous_id, data.warehous_code, data.warehous_descrip, data.item_id, data.item_number, data.item_descrip1, data.item_descrip2, data.itemdescription, data.itemnumber, data.prodcat_id, data.prodcat_code, data.basecommission, data.baseunitprice, data.custunitprice, round((data.cohist_qtyshipped * data.cohist_unitprice), 2) AS extprice, round((data.cohist_qtyshipped * data.baseunitprice), 2) AS baseextprice, round((data.cohist_qtyshipped * data.custunitprice), 2) AS custextprice, round((data.cohist_qtyshipped * data.cohist_unitcost), 4) AS extcost, round(((data.cohist_qtyshipped * data.baseunitprice) - (data.cohist_qtyshipped * data.cohist_unitcost)), 2) AS margin, CASE WHEN ((data.cohist_qtyshipped * data.baseunitprice) > 0.0) THEN (round(((data.cohist_qtyshipped * data.baseunitprice) - (data.cohist_qtyshipped * data.cohist_unitcost)), 2) / round((data.cohist_qtyshipped * data.baseunitprice), 2)) ELSE 0.0 END AS marginpercent, currconcat(data.cohist_curr_id) AS currabbr, 'qty'::text AS cohist_qtyshipped_xtnumericrole, 'salesprice'::text AS cohist_unitprice_xtnumericrole, 'salesprice'::text AS baseunitprice_xtnumericrole, 'curr'::text AS custunitprice_xtnumericrole, 'curr'::text AS custextprice_xtnumericrole, 'curr'::text AS extprice_xtnumericrole, 'curr'::text AS baseextprice_xtnumericrole, 'cost'::text AS cohist_unitcost_xtnumericrole, 'curr'::text AS extcost_xtnumericrole, 'curr'::text AS margin_xtnumericrole, 'percent'::text AS marginpercent_xtnumericrole, 'curr'::text AS cohist_commission_xtnumericrole, 'curr'::text AS basecommission_xtnumericrole FROM (SELECT cohist.cohist_id, cohist.cohist_cust_id, cohist.cohist_itemsite_id, cohist.cohist_shipdate, cohist.cohist_shipvia, cohist.cohist_ordernumber, cohist.cohist_orderdate, cohist.cohist_invcnumber, cohist.cohist_invcdate, cohist.cohist_qtyshipped, cohist.cohist_unitprice, cohist.cohist_shipto_id, cohist.cohist_salesrep_id, cohist.cohist_duedate, cohist.cohist_imported, cohist.cohist_billtoname, cohist.cohist_billtoaddress1, cohist.cohist_billtoaddress2, cohist.cohist_billtoaddress3, cohist.cohist_billtocity, cohist.cohist_billtostate, cohist.cohist_billtozip, cohist.cohist_shiptoname, cohist.cohist_shiptoaddress1, cohist.cohist_shiptoaddress2, cohist.cohist_shiptoaddress3, cohist.cohist_shiptocity, cohist.cohist_shiptostate, cohist.cohist_shiptozip, cohist.cohist_commission, cohist.cohist_commissionpaid, cohist.cohist_unitcost, cohist.cohist_misc_type, cohist.cohist_misc_descrip, cohist.cohist_misc_id, cohist.cohist_doctype, cohist.cohist_promisedate, cohist.cohist_ponumber, cohist.cohist_curr_id, cohist.cohist_sequence, cohist.cohist_taxtype_id, cohist.cohist_taxzone_id, cohist.cohist_cohead_ccpay_id, cohist.cohist_saletype_id, cohist.cohist_shipzone_id, COALESCE(cohead.cohead_id, (-1)) AS cohead_id, custinfo.cust_id, custinfo.cust_number, custinfo.cust_name, custinfo.cust_curr_id, custtype.custtype_id, custtype.custtype_code, custtype.custtype_descrip, salesrep.salesrep_id, salesrep.salesrep_number, salesrep.salesrep_name, shipzone.shipzone_id, shipzone.shipzone_name, shipzone.shipzone_descrip, saletype.saletype_code, saletype.saletype_descr, itemsite.itemsite_id, site.warehous_id, site.warehous_code, site.warehous_descrip, item.item_id, item.item_number, item.item_descrip1, item.item_descrip2, ((item.item_descrip1 || ' '::text) || item.item_descrip2) AS itemdescription, COALESCE(item.item_number, cohist.cohist_misc_descrip) AS itemnumber, prodcat.prodcat_id, prodcat.prodcat_code, currtobase(cohist.cohist_curr_id, cohist.cohist_commission, cohist.cohist_invcdate) AS basecommission, currtobase(cohist.cohist_curr_id, cohist.cohist_unitprice, cohist.cohist_invcdate) AS baseunitprice, currtocurr(cohist.cohist_curr_id, custinfo.cust_curr_id, cohist.cohist_unitprice, cohist.cohist_invcdate) AS custunitprice FROM (((((((((((cohist JOIN custinfo ON ((custinfo.cust_id = cohist.cohist_cust_id))) LEFT JOIN cohead ON ((cohead.cohead_number = cohist.cohist_ordernumber))) LEFT JOIN custtype ON ((custtype.custtype_id = custinfo.cust_custtype_id))) LEFT JOIN salesrep ON ((salesrep.salesrep_id = cohist.cohist_salesrep_id))) LEFT JOIN shiptoinfo ON ((shiptoinfo.shipto_id = cohist.cohist_shipto_id))) LEFT JOIN shipzone ON ((shipzone.shipzone_id = shiptoinfo.shipto_shipzone_id))) LEFT JOIN saletype ON ((saletype.saletype_id = cohist.cohist_saletype_id))) LEFT JOIN itemsite ON ((itemsite.itemsite_id = cohist.cohist_itemsite_id))) LEFT JOIN site() site(warehous_id, warehous_code, warehous_descrip, warehous_fob, warehous_active, warehous_counttag_prefix, warehous_counttag_number, warehous_bol_prefix, warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, warehous_aislesize, warehous_aislealpha, warehous_racksize, warehous_rackalpha, warehous_binsize, warehous_binalpha, warehous_locationsize, warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, warehous_shipping_commission, warehous_cntct_id, warehous_addr_id, warehous_transit, warehous_shipform_id, warehous_shipvia_id, warehous_shipcomments, warehous_costcat_id, warehous_sitetype_id, warehous_taxzone_id, warehous_sequence) ON ((site.warehous_id = itemsite.itemsite_warehous_id))) LEFT JOIN item ON ((item.item_id = itemsite.itemsite_item_id))) LEFT JOIN prodcat ON ((prodcat.prodcat_id = item.item_prodcat_id))) WHERE ((COALESCE(cohist.cohist_misc_type, ''::bpchar) <> 'F'::bpchar) AND (COALESCE(cohist.cohist_misc_type, ''::bpchar) <> 'T'::bpchar))) data;
94488
 
 
94489
 
 
94490
 
ALTER TABLE public.saleshistorymisc OWNER TO admin;
94491
 
 
94492
 
--
94493
 
--
94494
 
 
94495
 
COMMENT ON VIEW saleshistorymisc IS 'Single point for sales history (including misc. items) calculations.';
94496
 
 
94497
 
 
94498
 
--
94499
 
--
94500
 
 
94501
 
CREATE SEQUENCE salesrep_salesrep_id_seq
94502
 
    START WITH 1
94503
 
    INCREMENT BY 1
94504
 
    NO MINVALUE
94505
 
    NO MAXVALUE
94506
 
    CACHE 1;
94507
 
 
94508
 
 
94509
 
ALTER TABLE public.salesrep_salesrep_id_seq OWNER TO admin;
94510
 
 
94511
 
--
94512
 
--
94513
 
 
94514
 
CREATE SEQUENCE saletype_saletype_id_seq
94515
 
    START WITH 1
94516
 
    INCREMENT BY 1
94517
 
    NO MINVALUE
94518
 
    NO MAXVALUE
94519
 
    CACHE 1;
94520
 
 
94521
 
 
94522
 
ALTER TABLE public.saletype_saletype_id_seq OWNER TO admin;
94523
 
 
94524
 
--
94525
 
--
94526
 
 
94527
 
ALTER SEQUENCE saletype_saletype_id_seq OWNED BY saletype.saletype_id;
94528
 
 
94529
 
 
94530
 
--
94531
 
--
94532
 
 
94533
 
CREATE TABLE schemaord (
94534
 
    schemaord_id integer NOT NULL,
94535
 
    schemaord_name text NOT NULL,
94536
 
    schemaord_order integer NOT NULL,
94537
 
    CONSTRAINT schemaord_schemaord_name_check CHECK ((length(schemaord_name) > 0)),
94538
 
    CONSTRAINT schemaord_schemaord_name_check1 CHECK ((schemaord_name <> ''::text))
94539
 
);
94540
 
 
94541
 
 
94542
 
ALTER TABLE public.schemaord OWNER TO admin;
94543
 
 
94544
 
--
94545
 
--
94546
 
 
94547
 
COMMENT ON TABLE schemaord IS 'Set the order in which db schemas will appear in the search path after login';
94548
 
 
94549
 
 
94550
 
--
94551
 
--
94552
 
 
94553
 
CREATE SEQUENCE schemaord_schemaord_id_seq
94554
 
    START WITH 1
94555
 
    INCREMENT BY 1
94556
 
    NO MINVALUE
94557
 
    NO MAXVALUE
94558
 
    CACHE 1;
94559
 
 
94560
 
 
94561
 
ALTER TABLE public.schemaord_schemaord_id_seq OWNER TO admin;
94562
 
 
94563
 
--
94564
 
--
94565
 
 
94566
 
ALTER SEQUENCE schemaord_schemaord_id_seq OWNED BY schemaord.schemaord_id;
94567
 
 
94568
 
 
94569
 
--
94570
 
--
94571
 
 
94572
 
CREATE TABLE sequence (
94573
 
    sequence_value integer
94574
 
);
94575
 
 
94576
 
 
94577
 
ALTER TABLE public.sequence OWNER TO admin;
94578
 
 
94579
 
--
94580
 
--
94581
 
 
94582
 
COMMENT ON TABLE sequence IS 'Pre-populated list of sequence numbers (1-1000) used for printing Labels and other uses';
94583
 
 
94584
 
 
94585
 
--
94586
 
--
94587
 
 
94588
 
CREATE SEQUENCE shift_shift_id_seq
94589
 
    START WITH 1
94590
 
    INCREMENT BY 1
94591
 
    NO MINVALUE
94592
 
    NO MAXVALUE
94593
 
    CACHE 1;
94594
 
 
94595
 
 
94596
 
ALTER TABLE public.shift_shift_id_seq OWNER TO admin;
94597
 
 
94598
 
--
94599
 
--
94600
 
 
94601
 
ALTER SEQUENCE shift_shift_id_seq OWNED BY shift.shift_id;
94602
 
 
94603
 
 
94604
 
--
94605
 
--
94606
 
 
94607
 
CREATE SEQUENCE shipchrg_shipchrg_id_seq
94608
 
    START WITH 1
94609
 
    INCREMENT BY 1
94610
 
    NO MINVALUE
94611
 
    NO MAXVALUE
94612
 
    CACHE 1;
94613
 
 
94614
 
 
94615
 
ALTER TABLE public.shipchrg_shipchrg_id_seq OWNER TO admin;
94616
 
 
94617
 
--
94618
 
--
94619
 
 
94620
 
ALTER SEQUENCE shipchrg_shipchrg_id_seq OWNED BY shipchrg.shipchrg_id;
94621
 
 
94622
 
 
94623
 
--
94624
 
--
94625
 
 
94626
 
CREATE TABLE shipdatasum (
94627
 
    shipdatasum_cohead_number text NOT NULL,
94628
 
    shipdatasum_cosmisc_tracknum text NOT NULL,
94629
 
    shipdatasum_cosmisc_packnum_tracknum text NOT NULL,
94630
 
    shipdatasum_weight numeric(16,4),
94631
 
    shipdatasum_base_freight numeric(16,4),
94632
 
    shipdatasum_total_freight numeric(16,4),
94633
 
    shipdatasum_shipper text DEFAULT 'UPS'::text,
94634
 
    shipdatasum_billing_option text,
94635
 
    shipdatasum_package_type text,
94636
 
    shipdatasum_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL,
94637
 
    shipdatasum_shipped boolean DEFAULT false,
94638
 
    shipdatasum_shiphead_number text,
94639
 
    shipdatasum_base_freight_curr_id integer DEFAULT basecurrid(),
94640
 
    shipdatasum_total_freight_curr_id integer DEFAULT basecurrid()
94641
 
);
94642
 
 
94643
 
 
94644
 
ALTER TABLE public.shipdatasum OWNER TO admin;
94645
 
 
94646
 
--
94647
 
--
94648
 
 
94649
 
COMMENT ON TABLE shipdatasum IS 'Shipping Interface information.';
94650
 
 
94651
 
 
94652
 
--
94653
 
--
94654
 
 
94655
 
CREATE SEQUENCE shipform_shipform_id_seq
94656
 
    START WITH 1
94657
 
    INCREMENT BY 1
94658
 
    NO MINVALUE
94659
 
    MAXVALUE 2147483647
94660
 
    CACHE 1;
94661
 
 
94662
 
 
94663
 
ALTER TABLE public.shipform_shipform_id_seq OWNER TO admin;
94664
 
 
94665
 
--
94666
 
--
94667
 
 
94668
 
CREATE SEQUENCE shiphead_shiphead_id_seq
94669
 
    START WITH 1
94670
 
    INCREMENT BY 1
94671
 
    NO MINVALUE
94672
 
    NO MAXVALUE
94673
 
    CACHE 1;
94674
 
 
94675
 
 
94676
 
ALTER TABLE public.shiphead_shiphead_id_seq OWNER TO admin;
94677
 
 
94678
 
--
94679
 
--
94680
 
 
94681
 
ALTER SEQUENCE shiphead_shiphead_id_seq OWNED BY shiphead.shiphead_id;
94682
 
 
94683
 
 
94684
 
--
94685
 
--
94686
 
 
94687
 
CREATE SEQUENCE shipitem_shipitem_id_seq
94688
 
    START WITH 1
94689
 
    INCREMENT BY 1
94690
 
    NO MINVALUE
94691
 
    NO MAXVALUE
94692
 
    CACHE 1;
94693
 
 
94694
 
 
94695
 
ALTER TABLE public.shipitem_shipitem_id_seq OWNER TO admin;
94696
 
 
94697
 
--
94698
 
--
94699
 
 
94700
 
ALTER SEQUENCE shipitem_shipitem_id_seq OWNED BY shipitem.shipitem_id;
94701
 
 
94702
 
 
94703
 
--
94704
 
--
94705
 
 
94706
 
CREATE SEQUENCE shipment_number_seq
94707
 
    START WITH 1
94708
 
    INCREMENT BY 1
94709
 
    NO MINVALUE
94710
 
    NO MAXVALUE
94711
 
    CACHE 1;
94712
 
 
94713
 
 
94714
 
ALTER TABLE public.shipment_number_seq OWNER TO admin;
94715
 
 
94716
 
--
94717
 
--
94718
 
 
94719
 
CREATE VIEW shipto AS
94720
 
    SELECT shiptoinfo.shipto_id, shiptoinfo.shipto_cust_id, shiptoinfo.shipto_name, m.addr_line1 AS shipto_address1, m.addr_line2 AS shipto_address2, m.addr_line3 AS shipto_address3, m.addr_city AS shipto_city, m.addr_state AS shipto_state, m.addr_postalcode AS shipto_zipcode, shiptoinfo.shipto_taxzone_id, shiptoinfo.shipto_salesrep_id, c1.cntct_phone AS shipto_phone, shiptoinfo.shipto_comments, shiptoinfo.shipto_shipcomments, btrim(((c1.cntct_first_name || ' '::text) || c1.cntct_last_name)) AS shipto_contact, c1.cntct_fax AS shipto_fax, c1.cntct_email AS shipto_email, shiptoinfo.shipto_shipzone_id, shiptoinfo.shipto_shipvia, shiptoinfo.shipto_commission, shiptoinfo.shipto_shipform_id, shiptoinfo.shipto_shipchrg_id, shiptoinfo.shipto_active, shiptoinfo.shipto_default, shiptoinfo.shipto_num, shiptoinfo.shipto_ediprofile_id, m.addr_country AS shipto_country FROM ((shiptoinfo LEFT JOIN cntct c1 ON ((shiptoinfo.shipto_cntct_id = c1.cntct_id))) LEFT JOIN addr m ON ((shiptoinfo.shipto_addr_id = m.addr_id)));
94721
 
 
94722
 
 
94723
 
ALTER TABLE public.shipto OWNER TO admin;
94724
 
 
94725
 
--
94726
 
--
94727
 
 
94728
 
CREATE SEQUENCE shipto_shipto_id_seq
94729
 
    START WITH 1
94730
 
    INCREMENT BY 1
94731
 
    NO MINVALUE
94732
 
    MAXVALUE 2147483647
94733
 
    CACHE 1;
94734
 
 
94735
 
 
94736
 
ALTER TABLE public.shipto_shipto_id_seq OWNER TO admin;
94737
 
 
94738
 
--
94739
 
--
94740
 
 
94741
 
CREATE SEQUENCE shipvia_shipvia_id_seq
94742
 
    START WITH 1
94743
 
    INCREMENT BY 1
94744
 
    NO MINVALUE
94745
 
    MAXVALUE 2147483647
94746
 
    CACHE 1;
94747
 
 
94748
 
 
94749
 
ALTER TABLE public.shipvia_shipvia_id_seq OWNER TO admin;
94750
 
 
94751
 
--
94752
 
--
94753
 
 
94754
 
CREATE SEQUENCE shipzone_shipzone_id_seq
94755
 
    START WITH 1
94756
 
    INCREMENT BY 1
94757
 
    NO MINVALUE
94758
 
    MAXVALUE 2147483647
94759
 
    CACHE 1;
94760
 
 
94761
 
 
94762
 
ALTER TABLE public.shipzone_shipzone_id_seq OWNER TO admin;
94763
 
 
94764
 
--
94765
 
--
94766
 
 
94767
 
CREATE SEQUENCE sitetype_sitetype_id_seq
94768
 
    START WITH 1
94769
 
    INCREMENT BY 1
94770
 
    NO MINVALUE
94771
 
    NO MAXVALUE
94772
 
    CACHE 1;
94773
 
 
94774
 
 
94775
 
ALTER TABLE public.sitetype_sitetype_id_seq OWNER TO admin;
94776
 
 
94777
 
--
94778
 
--
94779
 
 
94780
 
ALTER SEQUENCE sitetype_sitetype_id_seq OWNED BY sitetype.sitetype_id;
94781
 
 
94782
 
 
94783
 
--
94784
 
--
94785
 
 
94786
 
CREATE TABLE sltrans (
94787
 
    sltrans_id integer DEFAULT nextval('gltrans_gltrans_id_seq'::regclass) NOT NULL,
94788
 
    sltrans_created timestamp with time zone,
94789
 
    sltrans_date date NOT NULL,
94790
 
    sltrans_sequence integer,
94791
 
    sltrans_accnt_id integer NOT NULL,
94792
 
    sltrans_source text,
94793
 
    sltrans_docnumber text,
94794
 
    sltrans_misc_id integer,
94795
 
    sltrans_amount numeric(20,2) NOT NULL,
94796
 
    sltrans_notes text,
94797
 
    sltrans_journalnumber integer,
94798
 
    sltrans_posted boolean NOT NULL,
94799
 
    sltrans_doctype text,
94800
 
    sltrans_username text DEFAULT geteffectivextuser() NOT NULL,
94801
 
    sltrans_gltrans_journalnumber integer,
94802
 
    sltrans_rec boolean DEFAULT false NOT NULL
94803
 
);
94804
 
 
94805
 
 
94806
 
ALTER TABLE public.sltrans OWNER TO admin;
94807
 
 
94808
 
--
94809
 
--
94810
 
 
94811
 
COMMENT ON TABLE sltrans IS 'Journal transaction information';
94812
 
 
94813
 
 
94814
 
--
94815
 
--
94816
 
 
94817
 
CREATE TABLE sltrans_backup (
94818
 
    sltrans_old_id integer,
94819
 
    sltrans_new_id integer
94820
 
);
94821
 
 
94822
 
 
94823
 
ALTER TABLE public.sltrans_backup OWNER TO admin;
94824
 
 
94825
 
--
94826
 
--
94827
 
 
94828
 
COMMENT ON TABLE sltrans_backup IS 'backup cross references of old and new ids for sltrans 4.0 upgrade.';
94829
 
 
94830
 
 
94831
 
--
94832
 
--
94833
 
 
94834
 
CREATE VIEW sopack AS
94835
 
    SELECT pack.pack_id AS sopack_id, pack.pack_head_id AS sopack_sohead_id, pack.pack_printed AS sopack_printed, pack.pack_shiphead_id AS sopack_cosmisc_id FROM pack WHERE (pack.pack_head_type = 'SO'::text);
94836
 
 
94837
 
 
94838
 
ALTER TABLE public.sopack OWNER TO admin;
94839
 
 
94840
 
--
94841
 
--
94842
 
 
94843
 
CREATE SEQUENCE sopack_sopack_id_seq
94844
 
    START WITH 1
94845
 
    INCREMENT BY 1
94846
 
    NO MINVALUE
94847
 
    NO MAXVALUE
94848
 
    CACHE 1;
94849
 
 
94850
 
 
94851
 
ALTER TABLE public.sopack_sopack_id_seq OWNER TO admin;
94852
 
 
94853
 
--
94854
 
--
94855
 
 
94856
 
CREATE TABLE source (
94857
 
    source_id integer NOT NULL,
94858
 
    source_module text,
94859
 
    source_name text NOT NULL,
94860
 
    source_descrip text,
94861
 
    CONSTRAINT source_source_name_check CHECK ((source_name <> ''::text))
94862
 
);
94863
 
 
94864
 
 
94865
 
ALTER TABLE public.source OWNER TO admin;
94866
 
 
94867
 
--
94868
 
--
94869
 
 
94870
 
COMMENT ON TABLE source IS 'Tax class information';
94871
 
 
94872
 
 
94873
 
--
94874
 
--
94875
 
 
94876
 
COMMENT ON COLUMN source.source_id IS 'Primary key';
94877
 
 
94878
 
 
94879
 
--
94880
 
--
94881
 
 
94882
 
COMMENT ON COLUMN source.source_module IS 'Application module';
94883
 
 
94884
 
 
94885
 
--
94886
 
--
94887
 
 
94888
 
COMMENT ON COLUMN source.source_name IS 'Name';
94889
 
 
94890
 
 
94891
 
--
94892
 
--
94893
 
 
94894
 
COMMENT ON COLUMN source.source_descrip IS 'Description';
94895
 
 
94896
 
 
94897
 
--
94898
 
--
94899
 
 
94900
 
CREATE SEQUENCE source_source_id_seq
94901
 
    START WITH 1
94902
 
    INCREMENT BY 1
94903
 
    NO MINVALUE
94904
 
    NO MAXVALUE
94905
 
    CACHE 1;
94906
 
 
94907
 
 
94908
 
ALTER TABLE public.source_source_id_seq OWNER TO admin;
94909
 
 
94910
 
--
94911
 
--
94912
 
 
94913
 
ALTER SEQUENCE source_source_id_seq OWNED BY source.source_id;
94914
 
 
94915
 
 
94916
 
--
94917
 
--
94918
 
 
94919
 
CREATE TABLE state (
94920
 
    state_id integer NOT NULL,
94921
 
    state_name text NOT NULL,
94922
 
    state_abbr text,
94923
 
    state_country_id integer,
94924
 
    CONSTRAINT state_state_name_check CHECK ((state_name <> ''::text))
94925
 
);
94926
 
 
94927
 
 
94928
 
ALTER TABLE public.state OWNER TO admin;
94929
 
 
94930
 
--
94931
 
--
94932
 
 
94933
 
COMMENT ON TABLE state IS 'List of states, provinces, and territories associated with various countries.';
94934
 
 
94935
 
 
94936
 
--
94937
 
--
94938
 
 
94939
 
CREATE SEQUENCE state_state_id_seq
94940
 
    START WITH 1
94941
 
    INCREMENT BY 1
94942
 
    NO MINVALUE
94943
 
    NO MAXVALUE
94944
 
    CACHE 1;
94945
 
 
94946
 
 
94947
 
ALTER TABLE public.state_state_id_seq OWNER TO admin;
94948
 
 
94949
 
--
94950
 
--
94951
 
 
94952
 
ALTER SEQUENCE state_state_id_seq OWNED BY state.state_id;
94953
 
 
94954
 
 
94955
 
--
94956
 
--
94957
 
 
94958
 
CREATE TABLE status (
94959
 
    status_id integer NOT NULL,
94960
 
    status_type text NOT NULL,
94961
 
    status_code character(1) NOT NULL,
94962
 
    status_name text,
94963
 
    status_seq integer,
94964
 
    status_color text DEFAULT 'white'::text
94965
 
);
94966
 
 
94967
 
 
94968
 
ALTER TABLE public.status OWNER TO admin;
94969
 
 
94970
 
--
94971
 
--
94972
 
 
94973
 
CREATE SEQUENCE status_status_id_seq
94974
 
    START WITH 1
94975
 
    INCREMENT BY 1
94976
 
    NO MINVALUE
94977
 
    NO MAXVALUE
94978
 
    CACHE 1;
94979
 
 
94980
 
 
94981
 
ALTER TABLE public.status_status_id_seq OWNER TO admin;
94982
 
 
94983
 
--
94984
 
--
94985
 
 
94986
 
ALTER SEQUENCE status_status_id_seq OWNED BY status.status_id;
94987
 
 
94988
 
 
94989
 
--
94990
 
--
94991
 
 
94992
 
CREATE TABLE stdjrnl (
94993
 
    stdjrnl_id integer NOT NULL,
94994
 
    stdjrnl_name text NOT NULL,
94995
 
    stdjrnl_descrip text,
94996
 
    stdjrnl_notes text,
94997
 
    CONSTRAINT stdjrnl_stdjrnl_name_check CHECK ((stdjrnl_name <> ''::text))
94998
 
);
94999
 
 
95000
 
 
95001
 
ALTER TABLE public.stdjrnl OWNER TO admin;
95002
 
 
95003
 
--
95004
 
--
95005
 
 
95006
 
COMMENT ON TABLE stdjrnl IS 'Standard Journal information';
95007
 
 
95008
 
 
95009
 
--
95010
 
--
95011
 
 
95012
 
CREATE SEQUENCE stdjrnl_stdjrnl_id_seq
95013
 
    START WITH 1
95014
 
    INCREMENT BY 1
95015
 
    NO MINVALUE
95016
 
    NO MAXVALUE
95017
 
    CACHE 1;
95018
 
 
95019
 
 
95020
 
ALTER TABLE public.stdjrnl_stdjrnl_id_seq OWNER TO admin;
95021
 
 
95022
 
--
95023
 
--
95024
 
 
95025
 
ALTER SEQUENCE stdjrnl_stdjrnl_id_seq OWNED BY stdjrnl.stdjrnl_id;
95026
 
 
95027
 
 
95028
 
--
95029
 
--
95030
 
 
95031
 
CREATE TABLE stdjrnlgrp (
95032
 
    stdjrnlgrp_id integer NOT NULL,
95033
 
    stdjrnlgrp_name text NOT NULL,
95034
 
    stdjrnlgrp_descrip text,
95035
 
    CONSTRAINT stdjrnlgrp_stdjrnlgrp_name_check CHECK ((stdjrnlgrp_name <> ''::text))
95036
 
);
95037
 
 
95038
 
 
95039
 
ALTER TABLE public.stdjrnlgrp OWNER TO admin;
95040
 
 
95041
 
--
95042
 
--
95043
 
 
95044
 
COMMENT ON TABLE stdjrnlgrp IS 'Standard Journal Group information';
95045
 
 
95046
 
 
95047
 
--
95048
 
--
95049
 
 
95050
 
CREATE SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq
95051
 
    START WITH 1
95052
 
    INCREMENT BY 1
95053
 
    NO MINVALUE
95054
 
    NO MAXVALUE
95055
 
    CACHE 1;
95056
 
 
95057
 
 
95058
 
ALTER TABLE public.stdjrnlgrp_stdjrnlgrp_id_seq OWNER TO admin;
95059
 
 
95060
 
--
95061
 
--
95062
 
 
95063
 
ALTER SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq OWNED BY stdjrnlgrp.stdjrnlgrp_id;
95064
 
 
95065
 
 
95066
 
--
95067
 
--
95068
 
 
95069
 
CREATE TABLE stdjrnlgrpitem (
95070
 
    stdjrnlgrpitem_id integer NOT NULL,
95071
 
    stdjrnlgrpitem_stdjrnl_id integer,
95072
 
    stdjrnlgrpitem_toapply integer,
95073
 
    stdjrnlgrpitem_applied integer,
95074
 
    stdjrnlgrpitem_effective date,
95075
 
    stdjrnlgrpitem_expires date,
95076
 
    stdjrnlgrpitem_stdjrnlgrp_id integer
95077
 
);
95078
 
 
95079
 
 
95080
 
ALTER TABLE public.stdjrnlgrpitem OWNER TO admin;
95081
 
 
95082
 
--
95083
 
--
95084
 
 
95085
 
COMMENT ON TABLE stdjrnlgrpitem IS 'Standard Journal Group Item information';
95086
 
 
95087
 
 
95088
 
--
95089
 
--
95090
 
 
95091
 
CREATE SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq
95092
 
    START WITH 1
95093
 
    INCREMENT BY 1
95094
 
    NO MINVALUE
95095
 
    NO MAXVALUE
95096
 
    CACHE 1;
95097
 
 
95098
 
 
95099
 
ALTER TABLE public.stdjrnlgrpitem_stdjrnlgrpitem_id_seq OWNER TO admin;
95100
 
 
95101
 
--
95102
 
--
95103
 
 
95104
 
ALTER SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq OWNED BY stdjrnlgrpitem.stdjrnlgrpitem_id;
95105
 
 
95106
 
 
95107
 
--
95108
 
--
95109
 
 
95110
 
CREATE TABLE stdjrnlitem (
95111
 
    stdjrnlitem_id integer NOT NULL,
95112
 
    stdjrnlitem_stdjrnl_id integer NOT NULL,
95113
 
    stdjrnlitem_accnt_id integer NOT NULL,
95114
 
    stdjrnlitem_amount numeric(20,2) NOT NULL,
95115
 
    stdjrnlitem_notes text
95116
 
);
95117
 
 
95118
 
 
95119
 
ALTER TABLE public.stdjrnlitem OWNER TO admin;
95120
 
 
95121
 
--
95122
 
--
95123
 
 
95124
 
COMMENT ON TABLE stdjrnlitem IS 'Standard Journal Item information';
95125
 
 
95126
 
 
95127
 
--
95128
 
--
95129
 
 
95130
 
CREATE SEQUENCE stdjrnlitem_stdjrnlitem_id_seq
95131
 
    START WITH 1
95132
 
    INCREMENT BY 1
95133
 
    NO MINVALUE
95134
 
    NO MAXVALUE
95135
 
    CACHE 1;
95136
 
 
95137
 
 
95138
 
ALTER TABLE public.stdjrnlitem_stdjrnlitem_id_seq OWNER TO admin;
95139
 
 
95140
 
--
95141
 
--
95142
 
 
95143
 
ALTER SEQUENCE stdjrnlitem_stdjrnlitem_id_seq OWNED BY stdjrnlitem.stdjrnlitem_id;
95144
 
 
95145
 
 
95146
 
--
95147
 
--
95148
 
 
95149
 
CREATE TABLE subaccnt (
95150
 
    subaccnt_id integer NOT NULL,
95151
 
    subaccnt_number text NOT NULL,
95152
 
    subaccnt_descrip text,
95153
 
    CONSTRAINT subaccnt_subaccnt_number_check CHECK ((subaccnt_number <> ''::text))
95154
 
);
95155
 
 
95156
 
 
95157
 
ALTER TABLE public.subaccnt OWNER TO admin;
95158
 
 
95159
 
--
95160
 
--
95161
 
 
95162
 
COMMENT ON TABLE subaccnt IS 'Subaccount information';
95163
 
 
95164
 
 
95165
 
--
95166
 
--
95167
 
 
95168
 
CREATE SEQUENCE subaccnt_subaccnt_id_seq
95169
 
    START WITH 1
95170
 
    INCREMENT BY 1
95171
 
    NO MINVALUE
95172
 
    NO MAXVALUE
95173
 
    CACHE 1;
95174
 
 
95175
 
 
95176
 
ALTER TABLE public.subaccnt_subaccnt_id_seq OWNER TO admin;
95177
 
 
95178
 
--
95179
 
--
95180
 
 
95181
 
ALTER SEQUENCE subaccnt_subaccnt_id_seq OWNED BY subaccnt.subaccnt_id;
95182
 
 
95183
 
 
95184
 
--
95185
 
--
95186
 
 
95187
 
CREATE TABLE subaccnttype (
95188
 
    subaccnttype_id integer NOT NULL,
95189
 
    subaccnttype_accnt_type character(1) NOT NULL,
95190
 
    subaccnttype_code text NOT NULL,
95191
 
    subaccnttype_descrip text
95192
 
);
95193
 
 
95194
 
 
95195
 
ALTER TABLE public.subaccnttype OWNER TO admin;
95196
 
 
95197
 
--
95198
 
--
95199
 
 
95200
 
COMMENT ON TABLE subaccnttype IS 'User defined Sub Account Types.';
95201
 
 
95202
 
 
95203
 
--
95204
 
--
95205
 
 
95206
 
CREATE SEQUENCE subaccnttype_subaccnttype_id_seq
95207
 
    START WITH 1
95208
 
    INCREMENT BY 1
95209
 
    NO MINVALUE
95210
 
    NO MAXVALUE
95211
 
    CACHE 1;
95212
 
 
95213
 
 
95214
 
ALTER TABLE public.subaccnttype_subaccnttype_id_seq OWNER TO admin;
95215
 
 
95216
 
--
95217
 
--
95218
 
 
95219
 
ALTER SEQUENCE subaccnttype_subaccnttype_id_seq OWNED BY subaccnttype.subaccnttype_id;
95220
 
 
95221
 
 
95222
 
--
95223
 
--
95224
 
 
95225
 
CREATE SEQUENCE tax_tax_id_seq
95226
 
    START WITH 1
95227
 
    INCREMENT BY 1
95228
 
    NO MINVALUE
95229
 
    NO MAXVALUE
95230
 
    CACHE 1;
95231
 
 
95232
 
 
95233
 
ALTER TABLE public.tax_tax_id_seq OWNER TO admin;
95234
 
 
95235
 
--
95236
 
--
95237
 
 
95238
 
CREATE TABLE taxass (
95239
 
    taxass_id integer NOT NULL,
95240
 
    taxass_taxzone_id integer,
95241
 
    taxass_taxtype_id integer,
95242
 
    taxass_tax_id integer NOT NULL
95243
 
);
95244
 
 
95245
 
 
95246
 
ALTER TABLE public.taxass OWNER TO admin;
95247
 
 
95248
 
--
95249
 
--
95250
 
 
95251
 
COMMENT ON TABLE taxass IS 'The tax assignment table associates different tax zones and tax types to a given set of tax codes.';
95252
 
 
95253
 
 
95254
 
--
95255
 
--
95256
 
 
95257
 
COMMENT ON COLUMN taxass.taxass_taxzone_id IS 'The id of the tax zone. If NULL any tax zone will apply.';
95258
 
 
95259
 
 
95260
 
--
95261
 
--
95262
 
 
95263
 
COMMENT ON COLUMN taxass.taxass_taxtype_id IS 'The id of the tax type. If NULL any tax type will apply.';
95264
 
 
95265
 
 
95266
 
--
95267
 
--
95268
 
 
95269
 
COMMENT ON COLUMN taxass.taxass_tax_id IS 'The id of the tax code.';
95270
 
 
95271
 
 
95272
 
--
95273
 
--
95274
 
 
95275
 
CREATE SEQUENCE taxass_taxass_id_seq
95276
 
    START WITH 1
95277
 
    INCREMENT BY 1
95278
 
    NO MINVALUE
95279
 
    NO MAXVALUE
95280
 
    CACHE 1;
95281
 
 
95282
 
 
95283
 
ALTER TABLE public.taxass_taxass_id_seq OWNER TO admin;
95284
 
 
95285
 
--
95286
 
--
95287
 
 
95288
 
ALTER SEQUENCE taxass_taxass_id_seq OWNED BY taxass.taxass_id;
95289
 
 
95290
 
 
95291
 
--
95292
 
--
95293
 
 
95294
 
CREATE SEQUENCE taxauth_taxauth_id_seq
95295
 
    START WITH 1
95296
 
    INCREMENT BY 1
95297
 
    NO MINVALUE
95298
 
    NO MAXVALUE
95299
 
    CACHE 1;
95300
 
 
95301
 
 
95302
 
ALTER TABLE public.taxauth_taxauth_id_seq OWNER TO admin;
95303
 
 
95304
 
--
95305
 
--
95306
 
 
95307
 
ALTER SEQUENCE taxauth_taxauth_id_seq OWNED BY taxauth.taxauth_id;
95308
 
 
95309
 
 
95310
 
--
95311
 
--
95312
 
 
95313
 
CREATE TABLE taxclass (
95314
 
    taxclass_id integer NOT NULL,
95315
 
    taxclass_code text NOT NULL,
95316
 
    taxclass_descrip text,
95317
 
    taxclass_sequence integer,
95318
 
    CONSTRAINT taxclass_taxclass_code_check CHECK ((taxclass_code <> ''::text))
95319
 
);
95320
 
 
95321
 
 
95322
 
ALTER TABLE public.taxclass OWNER TO admin;
95323
 
 
95324
 
--
95325
 
--
95326
 
 
95327
 
COMMENT ON TABLE taxclass IS 'Tax class information';
95328
 
 
95329
 
 
95330
 
--
95331
 
--
95332
 
 
95333
 
COMMENT ON COLUMN taxclass.taxclass_id IS 'Primary key';
95334
 
 
95335
 
 
95336
 
--
95337
 
--
95338
 
 
95339
 
COMMENT ON COLUMN taxclass.taxclass_code IS 'Code';
95340
 
 
95341
 
 
95342
 
--
95343
 
--
95344
 
 
95345
 
COMMENT ON COLUMN taxclass.taxclass_descrip IS 'Description';
95346
 
 
95347
 
 
95348
 
--
95349
 
--
95350
 
 
95351
 
COMMENT ON COLUMN taxclass.taxclass_sequence IS 'Group sequence';
95352
 
 
95353
 
 
95354
 
--
95355
 
--
95356
 
 
95357
 
CREATE SEQUENCE taxclass_taxclass_id_seq
95358
 
    START WITH 1
95359
 
    INCREMENT BY 1
95360
 
    NO MINVALUE
95361
 
    NO MAXVALUE
95362
 
    CACHE 1;
95363
 
 
95364
 
 
95365
 
ALTER TABLE public.taxclass_taxclass_id_seq OWNER TO admin;
95366
 
 
95367
 
--
95368
 
--
95369
 
 
95370
 
ALTER SEQUENCE taxclass_taxclass_id_seq OWNED BY taxclass.taxclass_id;
95371
 
 
95372
 
 
95373
 
--
95374
 
--
95375
 
 
95376
 
CREATE SEQUENCE taxhist_taxhist_id_seq
95377
 
    START WITH 1
95378
 
    INCREMENT BY 1
95379
 
    NO MINVALUE
95380
 
    NO MAXVALUE
95381
 
    CACHE 1;
95382
 
 
95383
 
 
95384
 
ALTER TABLE public.taxhist_taxhist_id_seq OWNER TO admin;
95385
 
 
95386
 
--
95387
 
--
95388
 
 
95389
 
ALTER SEQUENCE taxhist_taxhist_id_seq OWNED BY taxhist.taxhist_id;
95390
 
 
95391
 
 
95392
 
--
95393
 
--
95394
 
 
95395
 
CREATE TABLE taxpay (
95396
 
    taxpay_id integer NOT NULL,
95397
 
    taxpay_taxhist_id integer NOT NULL,
95398
 
    taxpay_apply_id integer NOT NULL,
95399
 
    taxpay_distdate date NOT NULL,
95400
 
    taxpay_tax numeric NOT NULL
95401
 
);
95402
 
 
95403
 
 
95404
 
ALTER TABLE public.taxpay OWNER TO admin;
95405
 
 
95406
 
--
95407
 
--
95408
 
 
95409
 
CREATE SEQUENCE taxpay_taxpay_id_seq
95410
 
    START WITH 1
95411
 
    INCREMENT BY 1
95412
 
    NO MINVALUE
95413
 
    NO MAXVALUE
95414
 
    CACHE 1;
95415
 
 
95416
 
 
95417
 
ALTER TABLE public.taxpay_taxpay_id_seq OWNER TO admin;
95418
 
 
95419
 
--
95420
 
--
95421
 
 
95422
 
ALTER SEQUENCE taxpay_taxpay_id_seq OWNED BY taxpay.taxpay_id;
95423
 
 
95424
 
 
95425
 
--
95426
 
--
95427
 
 
95428
 
CREATE TABLE taxrate (
95429
 
    taxrate_id integer NOT NULL,
95430
 
    taxrate_tax_id integer NOT NULL,
95431
 
    taxrate_percent numeric(10,6) NOT NULL,
95432
 
    taxrate_curr_id integer,
95433
 
    taxrate_amount numeric(16,2) NOT NULL,
95434
 
    taxrate_effective date,
95435
 
    taxrate_expires date
95436
 
);
95437
 
 
95438
 
 
95439
 
ALTER TABLE public.taxrate OWNER TO admin;
95440
 
 
95441
 
--
95442
 
--
95443
 
 
95444
 
COMMENT ON TABLE taxrate IS 'Tax rates.';
95445
 
 
95446
 
 
95447
 
--
95448
 
--
95449
 
 
95450
 
COMMENT ON COLUMN taxrate.taxrate_id IS 'Primary key.';
95451
 
 
95452
 
 
95453
 
--
95454
 
--
95455
 
 
95456
 
COMMENT ON COLUMN taxrate.taxrate_tax_id IS 'The id of the parent tax code.';
95457
 
 
95458
 
 
95459
 
--
95460
 
--
95461
 
 
95462
 
COMMENT ON COLUMN taxrate.taxrate_percent IS 'Tax rate percentage.';
95463
 
 
95464
 
 
95465
 
--
95466
 
--
95467
 
 
95468
 
COMMENT ON COLUMN taxrate.taxrate_curr_id IS 'The currency id of the flat rate amount.';
95469
 
 
95470
 
 
95471
 
--
95472
 
--
95473
 
 
95474
 
COMMENT ON COLUMN taxrate.taxrate_amount IS 'Flat tax rate amount.';
95475
 
 
95476
 
 
95477
 
--
95478
 
--
95479
 
 
95480
 
COMMENT ON COLUMN taxrate.taxrate_effective IS 'The effective date of the tax rate.  NULL value means always.';
95481
 
 
95482
 
 
95483
 
--
95484
 
--
95485
 
 
95486
 
COMMENT ON COLUMN taxrate.taxrate_expires IS 'The expire date of the tax rate.  NULL value means never.';
95487
 
 
95488
 
 
95489
 
--
95490
 
--
95491
 
 
95492
 
CREATE SEQUENCE taxrate_taxrate_id_seq
95493
 
    START WITH 1
95494
 
    INCREMENT BY 1
95495
 
    NO MINVALUE
95496
 
    NO MAXVALUE
95497
 
    CACHE 1;
95498
 
 
95499
 
 
95500
 
ALTER TABLE public.taxrate_taxrate_id_seq OWNER TO admin;
95501
 
 
95502
 
--
95503
 
--
95504
 
 
95505
 
ALTER SEQUENCE taxrate_taxrate_id_seq OWNED BY taxrate.taxrate_id;
95506
 
 
95507
 
 
95508
 
--
95509
 
--
95510
 
 
95511
 
CREATE SEQUENCE taxreg_taxreg_id_seq
95512
 
    START WITH 1
95513
 
    INCREMENT BY 1
95514
 
    NO MINVALUE
95515
 
    NO MAXVALUE
95516
 
    CACHE 1;
95517
 
 
95518
 
 
95519
 
ALTER TABLE public.taxreg_taxreg_id_seq OWNER TO admin;
95520
 
 
95521
 
--
95522
 
--
95523
 
 
95524
 
ALTER SEQUENCE taxreg_taxreg_id_seq OWNED BY taxreg.taxreg_id;
95525
 
 
95526
 
 
95527
 
--
95528
 
--
95529
 
 
95530
 
CREATE SEQUENCE taxtype_taxtype_id_seq
95531
 
    START WITH 1
95532
 
    INCREMENT BY 1
95533
 
    NO MINVALUE
95534
 
    NO MAXVALUE
95535
 
    CACHE 1;
95536
 
 
95537
 
 
95538
 
ALTER TABLE public.taxtype_taxtype_id_seq OWNER TO admin;
95539
 
 
95540
 
--
95541
 
--
95542
 
 
95543
 
ALTER SEQUENCE taxtype_taxtype_id_seq OWNED BY taxtype.taxtype_id;
95544
 
 
95545
 
 
95546
 
--
95547
 
--
95548
 
 
95549
 
CREATE SEQUENCE taxzone_taxzone_id_seq
95550
 
    START WITH 1
95551
 
    INCREMENT BY 1
95552
 
    NO MINVALUE
95553
 
    NO MAXVALUE
95554
 
    CACHE 1;
95555
 
 
95556
 
 
95557
 
ALTER TABLE public.taxzone_taxzone_id_seq OWNER TO admin;
95558
 
 
95559
 
--
95560
 
--
95561
 
 
95562
 
ALTER SEQUENCE taxzone_taxzone_id_seq OWNED BY taxzone.taxzone_id;
95563
 
 
95564
 
 
95565
 
--
95566
 
--
95567
 
 
95568
 
CREATE SEQUENCE terms_terms_id_seq
95569
 
    START WITH 1
95570
 
    INCREMENT BY 1
95571
 
    NO MINVALUE
95572
 
    MAXVALUE 2147483647
95573
 
    CACHE 1;
95574
 
 
95575
 
 
95576
 
ALTER TABLE public.terms_terms_id_seq OWNER TO admin;
95577
 
 
95578
 
--
95579
 
--
95580
 
 
95581
 
CREATE SEQUENCE todoitem_todoitem_id_seq
95582
 
    START WITH 1
95583
 
    INCREMENT BY 1
95584
 
    NO MINVALUE
95585
 
    NO MAXVALUE
95586
 
    CACHE 1;
95587
 
 
95588
 
 
95589
 
ALTER TABLE public.todoitem_todoitem_id_seq OWNER TO admin;
95590
 
 
95591
 
--
95592
 
--
95593
 
 
95594
 
ALTER SEQUENCE todoitem_todoitem_id_seq OWNED BY todoitem.todoitem_id;
95595
 
 
95596
 
 
95597
 
--
95598
 
--
95599
 
 
95600
 
CREATE TABLE trgthist (
95601
 
    trgthist_src_cntct_id integer NOT NULL,
95602
 
    trgthist_trgt_cntct_id integer NOT NULL,
95603
 
    trgthist_col text NOT NULL,
95604
 
    trgthist_value text NOT NULL
95605
 
);
95606
 
 
95607
 
 
95608
 
ALTER TABLE public.trgthist OWNER TO admin;
95609
 
 
95610
 
--
95611
 
--
95612
 
 
95613
 
CREATE TABLE trialbal (
95614
 
    trialbal_id integer NOT NULL,
95615
 
    trialbal_period_id integer,
95616
 
    trialbal_accnt_id integer,
95617
 
    trialbal_beginning numeric(20,2),
95618
 
    trialbal_ending numeric(20,2),
95619
 
    trialbal_credits numeric(20,2),
95620
 
    trialbal_debits numeric(20,2),
95621
 
    trialbal_dirty boolean,
95622
 
    trialbal_yearend numeric(20,2) DEFAULT 0.00 NOT NULL
95623
 
);
95624
 
 
95625
 
 
95626
 
ALTER TABLE public.trialbal OWNER TO admin;
95627
 
 
95628
 
--
95629
 
--
95630
 
 
95631
 
COMMENT ON TABLE trialbal IS 'Trial Balance information';
95632
 
 
95633
 
 
95634
 
--
95635
 
--
95636
 
 
95637
 
CREATE SEQUENCE trialbal_trialbal_id_seq
95638
 
    START WITH 1
95639
 
    INCREMENT BY 1
95640
 
    NO MINVALUE
95641
 
    NO MAXVALUE
95642
 
    CACHE 1;
95643
 
 
95644
 
 
95645
 
ALTER TABLE public.trialbal_trialbal_id_seq OWNER TO admin;
95646
 
 
95647
 
--
95648
 
--
95649
 
 
95650
 
ALTER SEQUENCE trialbal_trialbal_id_seq OWNED BY trialbal.trialbal_id;
95651
 
 
95652
 
 
95653
 
--
95654
 
--
95655
 
 
95656
 
CREATE SEQUENCE uom_uom_id_seq
95657
 
    START WITH 1
95658
 
    INCREMENT BY 1
95659
 
    NO MINVALUE
95660
 
    NO MAXVALUE
95661
 
    CACHE 1;
95662
 
 
95663
 
 
95664
 
ALTER TABLE public.uom_uom_id_seq OWNER TO admin;
95665
 
 
95666
 
--
95667
 
--
95668
 
 
95669
 
ALTER SEQUENCE uom_uom_id_seq OWNED BY uom.uom_id;
95670
 
 
95671
 
 
95672
 
--
95673
 
--
95674
 
 
95675
 
CREATE TABLE uomconv (
95676
 
    uomconv_id integer NOT NULL,
95677
 
    uomconv_from_uom_id integer NOT NULL,
95678
 
    uomconv_from_value numeric(20,10) NOT NULL,
95679
 
    uomconv_to_uom_id integer NOT NULL,
95680
 
    uomconv_to_value numeric(20,10) NOT NULL,
95681
 
    uomconv_fractional boolean DEFAULT false NOT NULL
95682
 
);
95683
 
 
95684
 
 
95685
 
ALTER TABLE public.uomconv OWNER TO admin;
95686
 
 
95687
 
--
95688
 
--
95689
 
 
95690
 
COMMENT ON TABLE uomconv IS 'UOM conversion information. From Unit to To Unit with a value per ratio.';
95691
 
 
95692
 
 
95693
 
--
95694
 
--
95695
 
 
95696
 
CREATE SEQUENCE uomconv_uomconv_id_seq
95697
 
    START WITH 1
95698
 
    INCREMENT BY 1
95699
 
    NO MINVALUE
95700
 
    NO MAXVALUE
95701
 
    CACHE 1;
95702
 
 
95703
 
 
95704
 
ALTER TABLE public.uomconv_uomconv_id_seq OWNER TO admin;
95705
 
 
95706
 
--
95707
 
--
95708
 
 
95709
 
ALTER SEQUENCE uomconv_uomconv_id_seq OWNED BY uomconv.uomconv_id;
95710
 
 
95711
 
 
95712
 
--
95713
 
--
95714
 
 
95715
 
CREATE TABLE uomtype (
95716
 
    uomtype_id integer NOT NULL,
95717
 
    uomtype_name text NOT NULL,
95718
 
    uomtype_descrip text,
95719
 
    uomtype_multiple boolean DEFAULT false NOT NULL,
95720
 
    CONSTRAINT uomtype_uomtype_name_check CHECK ((uomtype_name <> ''::text))
95721
 
);
95722
 
 
95723
 
 
95724
 
ALTER TABLE public.uomtype OWNER TO admin;
95725
 
 
95726
 
--
95727
 
--
95728
 
 
95729
 
COMMENT ON TABLE uomtype IS 'UOM Type values.';
95730
 
 
95731
 
 
95732
 
--
95733
 
--
95734
 
 
95735
 
CREATE SEQUENCE uomtype_uomtype_id_seq
95736
 
    START WITH 1
95737
 
    INCREMENT BY 1
95738
 
    NO MINVALUE
95739
 
    NO MAXVALUE
95740
 
    CACHE 1;
95741
 
 
95742
 
 
95743
 
ALTER TABLE public.uomtype_uomtype_id_seq OWNER TO admin;
95744
 
 
95745
 
--
95746
 
--
95747
 
 
95748
 
ALTER SEQUENCE uomtype_uomtype_id_seq OWNED BY uomtype.uomtype_id;
95749
 
 
95750
 
 
95751
 
--
95752
 
--
95753
 
 
95754
 
CREATE SEQUENCE urlinfo_url_id_seq
95755
 
    START WITH 1
95756
 
    INCREMENT BY 1
95757
 
    NO MINVALUE
95758
 
    NO MAXVALUE
95759
 
    CACHE 1;
95760
 
 
95761
 
 
95762
 
ALTER TABLE public.urlinfo_url_id_seq OWNER TO admin;
95763
 
 
95764
 
--
95765
 
--
95766
 
 
95767
 
ALTER SEQUENCE urlinfo_url_id_seq OWNED BY urlinfo.url_id;
95768
 
 
95769
 
 
95770
 
--
95771
 
--
95772
 
 
95773
 
CREATE TABLE usrpref (
95774
 
    usrpref_id integer DEFAULT nextval(('usrpref_usrpref_id_seq'::text)::regclass) NOT NULL,
95775
 
    usrpref_name text,
95776
 
    usrpref_value text,
95777
 
    usrpref_username text
95778
 
);
95779
 
 
95780
 
 
95781
 
ALTER TABLE public.usrpref OWNER TO admin;
95782
 
 
95783
 
--
95784
 
--
95785
 
 
95786
 
COMMENT ON TABLE usrpref IS 'User Preferences information';
95787
 
 
95788
 
 
95789
 
--
95790
 
--
95791
 
 
95792
 
CREATE VIEW usr AS
95793
 
    SELECT (pg_user.usesysid)::integer AS usr_id, (pg_user.usename)::text AS usr_username, COALESCE((SELECT usrpref.usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'propername'::text))), ''::text) AS usr_propername, NULL::text AS usr_passwd, COALESCE((SELECT (usrpref.usrpref_value)::integer AS usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'locale_id'::text))), COALESCE((SELECT locale.locale_id FROM locale WHERE (lower(locale.locale_code) = 'default'::text) LIMIT 1), (SELECT locale.locale_id FROM locale ORDER BY locale.locale_id LIMIT 1))) AS usr_locale_id, COALESCE((SELECT usrpref.usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'initials'::text))), ''::text) AS usr_initials, COALESCE((SELECT CASE WHEN (usrpref.usrpref_value = 't'::text) THEN true ELSE false END AS "case" FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'agent'::text))), false) AS usr_agent, COALESCE((SELECT CASE WHEN (usrpref.usrpref_value = 't'::text) THEN true ELSE false END AS "case" FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'active'::text))), usercanlogin((pg_user.usename)::text)) AS usr_active, COALESCE((SELECT usrpref.usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'email'::text))), ''::text) AS usr_email, COALESCE((SELECT usrpref.usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'window'::text))), ''::text) AS usr_window FROM pg_user;
95794
 
 
95795
 
 
95796
 
ALTER TABLE public.usr OWNER TO admin;
95797
 
 
95798
 
--
95799
 
--
95800
 
 
95801
 
CREATE TABLE usr_bak (
95802
 
    usr_id integer DEFAULT nextval(('usr_usr_id_seq'::text)::regclass) NOT NULL,
95803
 
    usr_username text NOT NULL,
95804
 
    usr_propername text,
95805
 
    usr_passwd text,
95806
 
    usr_locale_id integer NOT NULL,
95807
 
    usr_initials text,
95808
 
    usr_agent boolean NOT NULL,
95809
 
    usr_active boolean NOT NULL,
95810
 
    usr_email text,
95811
 
    usr_window text
95812
 
);
95813
 
 
95814
 
 
95815
 
ALTER TABLE public.usr_bak OWNER TO admin;
95816
 
 
95817
 
--
95818
 
--
95819
 
 
95820
 
COMMENT ON TABLE usr_bak IS 'User information';
95821
 
 
95822
 
 
95823
 
--
95824
 
--
95825
 
 
95826
 
CREATE SEQUENCE usr_usr_id_seq
95827
 
    START WITH 1
95828
 
    INCREMENT BY 1
95829
 
    NO MINVALUE
95830
 
    MAXVALUE 2147483647
95831
 
    CACHE 1;
95832
 
 
95833
 
 
95834
 
ALTER TABLE public.usr_usr_id_seq OWNER TO admin;
95835
 
 
95836
 
--
95837
 
--
95838
 
 
95839
 
CREATE SEQUENCE usrgrp_usrgrp_id_seq
95840
 
    START WITH 1
95841
 
    INCREMENT BY 1
95842
 
    NO MINVALUE
95843
 
    NO MAXVALUE
95844
 
    CACHE 1;
95845
 
 
95846
 
 
95847
 
ALTER TABLE public.usrgrp_usrgrp_id_seq OWNER TO admin;
95848
 
 
95849
 
--
95850
 
--
95851
 
 
95852
 
ALTER SEQUENCE usrgrp_usrgrp_id_seq OWNED BY usrgrp.usrgrp_id;
95853
 
 
95854
 
 
95855
 
--
95856
 
--
95857
 
 
95858
 
CREATE SEQUENCE usrpref_usrpref_id_seq
95859
 
    START WITH 1
95860
 
    INCREMENT BY 1
95861
 
    NO MINVALUE
95862
 
    MAXVALUE 2147483647
95863
 
    CACHE 1;
95864
 
 
95865
 
 
95866
 
ALTER TABLE public.usrpref_usrpref_id_seq OWNER TO admin;
95867
 
 
95868
 
--
95869
 
--
95870
 
 
95871
 
CREATE SEQUENCE usrpriv_usrpriv_id_seq
95872
 
    START WITH 1
95873
 
    INCREMENT BY 1
95874
 
    NO MINVALUE
95875
 
    MAXVALUE 2147483647
95876
 
    CACHE 1;
95877
 
 
95878
 
 
95879
 
ALTER TABLE public.usrpriv_usrpriv_id_seq OWNER TO admin;
95880
 
 
95881
 
--
95882
 
--
95883
 
 
95884
 
CREATE VIEW vend AS
95885
 
    SELECT vendinfo.vend_id, vendinfo.vend_name, m.addr_line1 AS vend_address1, m.addr_line2 AS vend_address2, m.addr_line3 AS vend_address3, m.addr_city AS vend_city, m.addr_state AS vend_state, m.addr_postalcode AS vend_zip, btrim(((c1.cntct_first_name || ' '::text) || c1.cntct_last_name)) AS vend_contact1, c1.cntct_phone AS vend_phone1, btrim(((c2.cntct_first_name || ' '::text) || c2.cntct_last_name)) AS vend_contact2, c2.cntct_phone AS vend_phone2, vendinfo.vend_lastpurchdate, vendinfo.vend_active, vendinfo.vend_po, vendinfo.vend_comments, vendinfo.vend_pocomments, vendinfo.vend_number, c1.cntct_fax AS vend_fax1, c2.cntct_fax AS vend_fax2, c1.cntct_email AS vend_email1, c2.cntct_email AS vend_email2, vendinfo.vend_1099, vendinfo.vend_exported, vendinfo.vend_fobsource, vendinfo.vend_fob, vendinfo.vend_terms_id, vendinfo.vend_shipvia, vendinfo.vend_vendtype_id, vendinfo.vend_qualified, vendinfo.vend_ediemail, vendinfo.vend_ediemailbody, vendinfo.vend_edisubject, vendinfo.vend_edifilename, vendinfo.vend_accntnum, vendinfo.vend_emailpodelivery, vendinfo.vend_restrictpurch, vendinfo.vend_edicc, m.addr_country AS vend_country, vendinfo.vend_curr_id, vendinfo.vend_taxzone_id FROM (((vendinfo LEFT JOIN cntct c1 ON ((vendinfo.vend_cntct1_id = c1.cntct_id))) LEFT JOIN addr m ON ((vendinfo.vend_addr_id = m.addr_id))) LEFT JOIN cntct c2 ON ((vendinfo.vend_cntct2_id = c2.cntct_id)));
95886
 
 
95887
 
 
95888
 
ALTER TABLE public.vend OWNER TO admin;
95889
 
 
95890
 
--
95891
 
--
95892
 
 
95893
 
CREATE SEQUENCE vend_vend_id_seq
95894
 
    START WITH 1
95895
 
    INCREMENT BY 1
95896
 
    NO MINVALUE
95897
 
    MAXVALUE 2147483647
95898
 
    CACHE 1;
95899
 
 
95900
 
 
95901
 
ALTER TABLE public.vend_vend_id_seq OWNER TO admin;
95902
 
 
95903
 
--
95904
 
--
95905
 
 
95906
 
CREATE VIEW vendaddr AS
95907
 
    SELECT vendaddrinfo.vendaddr_id, vendaddrinfo.vendaddr_vend_id, vendaddrinfo.vendaddr_code, vendaddrinfo.vendaddr_name, m.addr_line1 AS vendaddr_address1, m.addr_line2 AS vendaddr_address2, m.addr_line3 AS vendaddr_address3, btrim(((c1.cntct_first_name || ' '::text) || c1.cntct_last_name)) AS vendaddr_contact1, c1.cntct_phone AS vendaddr_phone1, c1.cntct_fax AS vendaddr_fax1, m.addr_city AS vendaddr_city, m.addr_state AS vendaddr_state, m.addr_postalcode AS vendaddr_zipcode, m.addr_country AS vendaddr_country FROM ((vendaddrinfo LEFT JOIN cntct c1 ON ((vendaddrinfo.vendaddr_cntct_id = c1.cntct_id))) LEFT JOIN addr m ON ((vendaddrinfo.vendaddr_addr_id = m.addr_id)));
95908
 
 
95909
 
 
95910
 
ALTER TABLE public.vendaddr OWNER TO admin;
95911
 
 
95912
 
--
95913
 
--
95914
 
 
95915
 
CREATE SEQUENCE vendaddr_vendaddr_id_seq
95916
 
    START WITH 1
95917
 
    INCREMENT BY 1
95918
 
    NO MINVALUE
95919
 
    MAXVALUE 2147483647
95920
 
    CACHE 1;
95921
 
 
95922
 
 
95923
 
ALTER TABLE public.vendaddr_vendaddr_id_seq OWNER TO admin;
95924
 
 
95925
 
--
95926
 
--
95927
 
 
95928
 
CREATE SEQUENCE vendtype_vendtype_id_seq
95929
 
    START WITH 1
95930
 
    INCREMENT BY 1
95931
 
    NO MINVALUE
95932
 
    NO MAXVALUE
95933
 
    CACHE 1;
95934
 
 
95935
 
 
95936
 
ALTER TABLE public.vendtype_vendtype_id_seq OWNER TO admin;
95937
 
 
95938
 
--
95939
 
--
95940
 
 
95941
 
ALTER SEQUENCE vendtype_vendtype_id_seq OWNED BY vendtype.vendtype_id;
95942
 
 
95943
 
 
95944
 
--
95945
 
--
95946
 
 
95947
 
CREATE TABLE vodist (
95948
 
    vodist_id integer DEFAULT nextval(('"vodist_vodist_id_seq"'::text)::regclass) NOT NULL,
95949
 
    vodist_poitem_id integer,
95950
 
    vodist_vohead_id integer,
95951
 
    vodist_costelem_id integer,
95952
 
    vodist_accnt_id integer,
95953
 
    vodist_amount numeric(18,6),
95954
 
    vodist_qty numeric(18,6),
95955
 
    vodist_expcat_id integer DEFAULT (-1),
95956
 
    vodist_tax_id integer DEFAULT (-1),
95957
 
    vodist_discountable boolean DEFAULT true NOT NULL,
95958
 
    vodist_notes text
95959
 
);
95960
 
 
95961
 
 
95962
 
ALTER TABLE public.vodist OWNER TO admin;
95963
 
 
95964
 
--
95965
 
--
95966
 
 
95967
 
COMMENT ON TABLE vodist IS 'Voucher distribution information';
95968
 
 
95969
 
 
95970
 
--
95971
 
--
95972
 
 
95973
 
CREATE SEQUENCE vodist_vodist_id_seq
95974
 
    START WITH 1
95975
 
    INCREMENT BY 1
95976
 
    NO MINVALUE
95977
 
    NO MAXVALUE
95978
 
    CACHE 1;
95979
 
 
95980
 
 
95981
 
ALTER TABLE public.vodist_vodist_id_seq OWNER TO admin;
95982
 
 
95983
 
--
95984
 
--
95985
 
 
95986
 
CREATE TABLE vohead (
95987
 
    vohead_id integer DEFAULT nextval(('vohead_vohead_id_seq'::text)::regclass) NOT NULL,
95988
 
    vohead_number text NOT NULL,
95989
 
    vohead_pohead_id integer,
95990
 
    vohead_posted boolean,
95991
 
    vohead_duedate date,
95992
 
    vohead_invcnumber text,
95993
 
    vohead_amount numeric(16,4),
95994
 
    vohead_docdate date,
95995
 
    vohead_1099 boolean,
95996
 
    vohead_distdate date,
95997
 
    vohead_reference text,
95998
 
    vohead_terms_id integer,
95999
 
    vohead_vend_id integer,
96000
 
    vohead_curr_id integer DEFAULT basecurrid(),
96001
 
    vohead_adjtaxtype_id integer,
96002
 
    vohead_freighttaxtype_id integer,
96003
 
    vohead_gldistdate date,
96004
 
    vohead_misc boolean,
96005
 
    vohead_taxzone_id integer,
96006
 
    vohead_taxtype_id integer,
96007
 
    vohead_notes text,
96008
 
    vohead_recurring_vohead_id integer,
96009
 
    CONSTRAINT vohead_vohead_number_check CHECK ((vohead_number <> ''::text))
96010
 
);
96011
 
 
96012
 
 
96013
 
ALTER TABLE public.vohead OWNER TO admin;
96014
 
 
96015
 
--
96016
 
--
96017
 
 
96018
 
COMMENT ON TABLE vohead IS 'Voucher header information';
96019
 
 
96020
 
 
96021
 
--
96022
 
--
96023
 
 
96024
 
CREATE SEQUENCE vohead_vohead_id_seq
96025
 
    START WITH 1
96026
 
    INCREMENT BY 1
96027
 
    NO MINVALUE
96028
 
    NO MAXVALUE
96029
 
    CACHE 1;
96030
 
 
96031
 
 
96032
 
ALTER TABLE public.vohead_vohead_id_seq OWNER TO admin;
96033
 
 
96034
 
--
96035
 
--
96036
 
 
96037
 
CREATE TABLE voheadtax (
96038
 
)
96039
 
INHERITS (taxhist);
96040
 
 
96041
 
 
96042
 
ALTER TABLE public.voheadtax OWNER TO admin;
96043
 
 
96044
 
--
96045
 
--
96046
 
 
96047
 
CREATE TABLE voitem (
96048
 
    voitem_id integer DEFAULT nextval(('"voitem_voitem_id_seq"'::text)::regclass) NOT NULL,
96049
 
    voitem_vohead_id integer,
96050
 
    voitem_poitem_id integer,
96051
 
    voitem_close boolean,
96052
 
    voitem_qty numeric(18,6),
96053
 
    voitem_freight numeric(16,4) DEFAULT 0.0 NOT NULL,
96054
 
    voitem_taxtype_id integer
96055
 
);
96056
 
 
96057
 
 
96058
 
ALTER TABLE public.voitem OWNER TO admin;
96059
 
 
96060
 
--
96061
 
--
96062
 
 
96063
 
COMMENT ON TABLE voitem IS 'Voucher Line Item information';
96064
 
 
96065
 
 
96066
 
--
96067
 
--
96068
 
 
96069
 
CREATE SEQUENCE voitem_voitem_id_seq
96070
 
    START WITH 1
96071
 
    INCREMENT BY 1
96072
 
    NO MINVALUE
96073
 
    NO MAXVALUE
96074
 
    CACHE 1;
96075
 
 
96076
 
 
96077
 
ALTER TABLE public.voitem_voitem_id_seq OWNER TO admin;
96078
 
 
96079
 
--
96080
 
--
96081
 
 
96082
 
CREATE TABLE voitemtax (
96083
 
)
96084
 
INHERITS (taxhist);
96085
 
 
96086
 
 
96087
 
ALTER TABLE public.voitemtax OWNER TO admin;
96088
 
 
96089
 
--
96090
 
--
96091
 
 
96092
 
CREATE VIEW warehous AS
96093
 
    SELECT whsinfo.warehous_id, whsinfo.warehous_code, whsinfo.warehous_descrip, m.addr_line1 AS warehous_addr1, m.addr_line2 AS warehous_addr2, m.addr_line3 AS warehous_addr3, m.addr_city AS warehous_addr4, m.addr_city AS warehous_city, m.addr_state AS warehous_state, m.addr_postalcode AS warehous_zip, m.addr_country AS warehous_country, whsinfo.warehous_fob, whsinfo.warehous_active, whsinfo.warehous_sitetype_id, whsinfo.warehous_counttag_prefix, whsinfo.warehous_counttag_number, whsinfo.warehous_bol_prefix, whsinfo.warehous_bol_number, whsinfo.warehous_shipping, whsinfo.warehous_useslips, whsinfo.warehous_usezones, whsinfo.warehous_aislesize, whsinfo.warehous_aislealpha, whsinfo.warehous_racksize, whsinfo.warehous_rackalpha, whsinfo.warehous_binsize, whsinfo.warehous_binalpha, whsinfo.warehous_locationsize, whsinfo.warehous_locationalpha, whsinfo.warehous_enforcearbl, whsinfo.warehous_default_accnt_id, whsinfo.warehous_shipping_commission FROM ((whsinfo LEFT JOIN cntct c1 ON ((whsinfo.warehous_cntct_id = c1.cntct_id))) LEFT JOIN addr m ON ((whsinfo.warehous_addr_id = m.addr_id)));
96094
 
 
96095
 
 
96096
 
ALTER TABLE public.warehous OWNER TO admin;
96097
 
 
96098
 
--
96099
 
--
96100
 
 
96101
 
CREATE SEQUENCE warehous_warehous_id_seq
96102
 
    START WITH 1
96103
 
    INCREMENT BY 1
96104
 
    NO MINVALUE
96105
 
    MAXVALUE 2147483647
96106
 
    CACHE 1;
96107
 
 
96108
 
 
96109
 
ALTER TABLE public.warehous_warehous_id_seq OWNER TO admin;
96110
 
 
96111
 
--
96112
 
--
96113
 
 
96114
 
CREATE SEQUENCE whsezone_whsezone_id_seq
96115
 
    START WITH 1
96116
 
    INCREMENT BY 1
96117
 
    NO MINVALUE
96118
 
    NO MAXVALUE
96119
 
    CACHE 1;
96120
 
 
96121
 
 
96122
 
ALTER TABLE public.whsezone_whsezone_id_seq OWNER TO admin;
96123
 
 
96124
 
--
96125
 
--
96126
 
 
96127
 
ALTER SEQUENCE whsezone_whsezone_id_seq OWNED BY whsezone.whsezone_id;
96128
 
 
96129
 
 
96130
 
--
96131
 
--
96132
 
 
96133
 
CREATE SEQUENCE wo_wo_id_seq
96134
 
    START WITH 1
96135
 
    INCREMENT BY 1
96136
 
    NO MINVALUE
96137
 
    MAXVALUE 2147483647
96138
 
    CACHE 1;
96139
 
 
96140
 
 
96141
 
ALTER TABLE public.wo_wo_id_seq OWNER TO admin;
96142
 
 
96143
 
--
96144
 
--
96145
 
 
96146
 
CREATE SEQUENCE womatl_womatl_id_seq
96147
 
    START WITH 1
96148
 
    INCREMENT BY 1
96149
 
    NO MINVALUE
96150
 
    MAXVALUE 2147483647
96151
 
    CACHE 1;
96152
 
 
96153
 
 
96154
 
ALTER TABLE public.womatl_womatl_id_seq OWNER TO admin;
96155
 
 
96156
 
--
96157
 
--
96158
 
 
96159
 
CREATE TABLE womatlpost (
96160
 
    womatlpost_id integer NOT NULL,
96161
 
    womatlpost_womatl_id integer,
96162
 
    womatlpost_invhist_id integer
96163
 
);
96164
 
 
96165
 
 
96166
 
ALTER TABLE public.womatlpost OWNER TO admin;
96167
 
 
96168
 
--
96169
 
--
96170
 
 
96171
 
COMMENT ON TABLE womatlpost IS 'Table to tie work order to work order material transactions for efficient queries';
96172
 
 
96173
 
 
96174
 
--
96175
 
--
96176
 
 
96177
 
CREATE SEQUENCE womatlpost_womatlpost_id_seq
96178
 
    START WITH 1
96179
 
    INCREMENT BY 1
96180
 
    NO MINVALUE
96181
 
    NO MAXVALUE
96182
 
    CACHE 1;
96183
 
 
96184
 
 
96185
 
ALTER TABLE public.womatlpost_womatlpost_id_seq OWNER TO admin;
96186
 
 
96187
 
--
96188
 
--
96189
 
 
96190
 
ALTER SEQUENCE womatlpost_womatlpost_id_seq OWNED BY womatlpost.womatlpost_id;
96191
 
 
96192
 
 
96193
 
--
96194
 
--
96195
 
 
96196
 
CREATE TABLE womatlvar (
96197
 
    womatlvar_id integer DEFAULT nextval(('"womatlvar_womatlvar_id_seq"'::text)::regclass) NOT NULL,
96198
 
    womatlvar_number integer,
96199
 
    womatlvar_subnumber integer,
96200
 
    womatlvar_posted date,
96201
 
    womatlvar_parent_itemsite_id integer,
96202
 
    womatlvar_component_itemsite_id integer,
96203
 
    womatlvar_qtyord numeric(18,6),
96204
 
    womatlvar_qtyrcv numeric(18,6),
96205
 
    womatlvar_qtyiss numeric(18,6),
96206
 
    womatlvar_qtyper numeric(18,6),
96207
 
    womatlvar_scrap numeric(18,6),
96208
 
    womatlvar_wipscrap numeric(18,6),
96209
 
    womatlvar_bomitem_id integer,
96210
 
    womatlvar_ref text,
96211
 
    womatlvar_notes text,
96212
 
    womatlvar_qtyfxd numeric(20,8) DEFAULT 0 NOT NULL
96213
 
);
96214
 
 
96215
 
 
96216
 
ALTER TABLE public.womatlvar OWNER TO admin;
96217
 
 
96218
 
--
96219
 
--
96220
 
 
96221
 
COMMENT ON TABLE womatlvar IS 'Work Order Material Requirements Variance information';
96222
 
 
96223
 
 
96224
 
--
96225
 
--
96226
 
 
96227
 
COMMENT ON COLUMN womatlvar.womatlvar_qtyfxd IS 'The fixed quantity required';
96228
 
 
96229
 
 
96230
 
--
96231
 
--
96232
 
 
96233
 
CREATE SEQUENCE womatlvar_womatlvar_id_seq
96234
 
    START WITH 1
96235
 
    INCREMENT BY 1
96236
 
    NO MINVALUE
96237
 
    MAXVALUE 2147483647
96238
 
    CACHE 1;
96239
 
 
96240
 
 
96241
 
ALTER TABLE public.womatlvar_womatlvar_id_seq OWNER TO admin;
96242
 
 
96243
 
--
96244
 
--
96245
 
 
96246
 
CREATE SEQUENCE xcalitem_xcalitem_id_seq
96247
 
    START WITH 1
96248
 
    INCREMENT BY 1
96249
 
    NO MINVALUE
96250
 
    NO MAXVALUE
96251
 
    CACHE 1;
96252
 
 
96253
 
 
96254
 
ALTER TABLE public.xcalitem_xcalitem_id_seq OWNER TO admin;
96255
 
 
96256
 
--
96257
 
--
96258
 
 
96259
 
CREATE TABLE xsltmap (
96260
 
    xsltmap_id integer NOT NULL,
96261
 
    xsltmap_name text NOT NULL,
96262
 
    xsltmap_doctype text NOT NULL,
96263
 
    xsltmap_system text NOT NULL,
96264
 
    xsltmap_import text NOT NULL,
96265
 
    xsltmap_export text DEFAULT ''::text NOT NULL,
96266
 
    CONSTRAINT xsltmap_check CHECK (((xsltmap_doctype <> ''::text) OR (xsltmap_system <> ''::text))),
96267
 
    CONSTRAINT xsltmap_xsltmap_importexport_check CHECK (((xsltmap_import <> ''::text) OR (xsltmap_export <> ''::text))),
96268
 
    CONSTRAINT xsltmap_xsltmap_name_check CHECK ((xsltmap_name <> ''::text))
96269
 
);
96270
 
 
96271
 
 
96272
 
ALTER TABLE public.xsltmap OWNER TO admin;
96273
 
 
96274
 
--
96275
 
--
96276
 
 
96277
 
COMMENT ON TABLE xsltmap IS 'Mapping of XML System identifiers to XSLT transformation files';
96278
 
 
96279
 
 
96280
 
--
96281
 
--
96282
 
 
96283
 
CREATE SEQUENCE xsltmap_xsltmap_id_seq
96284
 
    START WITH 1
96285
 
    INCREMENT BY 1
96286
 
    NO MINVALUE
96287
 
    NO MAXVALUE
96288
 
    CACHE 1;
96289
 
 
96290
 
 
96291
 
ALTER TABLE public.xsltmap_xsltmap_id_seq OWNER TO admin;
96292
 
 
96293
 
--
96294
 
--
96295
 
 
96296
 
ALTER SEQUENCE xsltmap_xsltmap_id_seq OWNED BY xsltmap.xsltmap_id;
96297
 
 
96298
 
 
96299
 
--
96300
 
--
96301
 
 
96302
 
CREATE TABLE yearperiod (
96303
 
    yearperiod_id integer NOT NULL,
96304
 
    yearperiod_start date NOT NULL,
96305
 
    yearperiod_end date NOT NULL,
96306
 
    yearperiod_closed boolean DEFAULT false NOT NULL
96307
 
);
96308
 
 
96309
 
 
96310
 
ALTER TABLE public.yearperiod OWNER TO admin;
96311
 
 
96312
 
--
96313
 
--
96314
 
 
96315
 
COMMENT ON TABLE yearperiod IS 'Accounting Year Periods information';
96316
 
 
96317
 
 
96318
 
--
96319
 
--
96320
 
 
96321
 
CREATE SEQUENCE yearperiod_yearperiod_id_seq
96322
 
    START WITH 1
96323
 
    INCREMENT BY 1
96324
 
    NO MINVALUE
96325
 
    NO MAXVALUE
96326
 
    CACHE 1;
96327
 
 
96328
 
 
96329
 
ALTER TABLE public.yearperiod_yearperiod_id_seq OWNER TO admin;
96330
 
 
96331
 
--
96332
 
--
96333
 
 
96334
 
ALTER SEQUENCE yearperiod_yearperiod_id_seq OWNED BY yearperiod.yearperiod_id;
96335
 
 
96336
 
 
96337
 
SET search_path = te, pg_catalog;
96338
 
 
96339
 
--
96340
 
--
96341
 
 
96342
 
CREATE TABLE pkgcmd (
96343
 
    cmd_id integer DEFAULT nextval('public.cmd_cmd_id_seq'::regclass)
96344
 
)
96345
 
INHERITS (public.cmd);
96346
 
 
96347
 
 
96348
 
ALTER TABLE te.pkgcmd OWNER TO admin;
96349
 
 
96350
 
--
96351
 
--
96352
 
 
96353
 
CREATE TABLE pkgcmdarg (
96354
 
    cmdarg_id integer DEFAULT nextval('public.cmdarg_cmdarg_id_seq'::regclass)
96355
 
)
96356
 
INHERITS (public.cmdarg);
96357
 
 
96358
 
 
96359
 
ALTER TABLE te.pkgcmdarg OWNER TO admin;
96360
 
 
96361
 
--
96362
 
--
96363
 
 
96364
 
CREATE TABLE pkgimage (
96365
 
    image_id integer DEFAULT nextval('public.image_image_id_seq'::regclass)
96366
 
)
96367
 
INHERITS (public.image);
96368
 
 
96369
 
 
96370
 
ALTER TABLE te.pkgimage OWNER TO admin;
96371
 
 
96372
 
--
96373
 
--
96374
 
 
96375
 
CREATE TABLE pkgmetasql (
96376
 
    metasql_id integer DEFAULT nextval('public.metasql_metasql_id_seq'::regclass)
96377
 
)
96378
 
INHERITS (public.metasql);
96379
 
 
96380
 
 
96381
 
ALTER TABLE te.pkgmetasql OWNER TO admin;
96382
 
 
96383
 
--
96384
 
--
96385
 
 
96386
 
CREATE TABLE pkgpriv (
96387
 
    priv_id integer DEFAULT nextval('public.priv_priv_id_seq'::regclass)
96388
 
)
96389
 
INHERITS (public.priv);
96390
 
 
96391
 
 
96392
 
ALTER TABLE te.pkgpriv OWNER TO admin;
96393
 
 
96394
 
--
96395
 
--
96396
 
 
96397
 
CREATE TABLE pkgreport (
96398
 
    report_id integer DEFAULT nextval('public.report_report_id_seq'::regclass)
96399
 
)
96400
 
INHERITS (public.report);
96401
 
 
96402
 
 
96403
 
ALTER TABLE te.pkgreport OWNER TO admin;
96404
 
 
96405
 
--
96406
 
--
96407
 
 
96408
 
CREATE TABLE pkgscript (
96409
 
    script_id integer DEFAULT nextval('public.script_script_id_seq'::regclass)
96410
 
)
96411
 
INHERITS (public.script);
96412
 
 
96413
 
 
96414
 
ALTER TABLE te.pkgscript OWNER TO admin;
96415
 
 
96416
 
--
96417
 
--
96418
 
 
96419
 
CREATE TABLE pkguiform (
96420
 
    uiform_id integer DEFAULT nextval('public.uiform_uiform_id_seq'::regclass)
96421
 
)
96422
 
INHERITS (public.uiform);
96423
 
 
96424
 
 
96425
 
ALTER TABLE te.pkguiform OWNER TO admin;
96426
 
 
96427
 
--
96428
 
--
96429
 
 
96430
 
CREATE TABLE tecustrate (
96431
 
    tecustrate_cust_id integer NOT NULL,
96432
 
    tecustrate_rate numeric(16,4) NOT NULL,
96433
 
    tecustrate_id integer NOT NULL,
96434
 
    tecustrate_curr_id integer DEFAULT public.basecurrid() NOT NULL
96435
 
);
96436
 
 
96437
 
 
96438
 
ALTER TABLE te.tecustrate OWNER TO admin;
96439
 
 
96440
 
--
96441
 
--
96442
 
 
96443
 
COMMENT ON TABLE tecustrate IS 'Default Customer Billing rate for Time/Expense';
96444
 
 
96445
 
 
96446
 
--
96447
 
--
96448
 
 
96449
 
CREATE SEQUENCE tecustrate_tecustrate_id_seq
96450
 
    START WITH 1
96451
 
    INCREMENT BY 1
96452
 
    NO MINVALUE
96453
 
    NO MAXVALUE
96454
 
    CACHE 1;
96455
 
 
96456
 
 
96457
 
ALTER TABLE te.tecustrate_tecustrate_id_seq OWNER TO admin;
96458
 
 
96459
 
--
96460
 
--
96461
 
 
96462
 
ALTER SEQUENCE tecustrate_tecustrate_id_seq OWNED BY tecustrate.tecustrate_id;
96463
 
 
96464
 
 
96465
 
--
96466
 
--
96467
 
 
96468
 
CREATE TABLE teemp (
96469
 
    teemp_id integer NOT NULL,
96470
 
    teemp_emp_id integer,
96471
 
    teemp_contractor boolean DEFAULT false
96472
 
);
96473
 
 
96474
 
 
96475
 
ALTER TABLE te.teemp OWNER TO admin;
96476
 
 
96477
 
--
96478
 
--
96479
 
 
96480
 
CREATE SEQUENCE teemp_teemp_id_seq
96481
 
    START WITH 1
96482
 
    INCREMENT BY 1
96483
 
    NO MINVALUE
96484
 
    NO MAXVALUE
96485
 
    CACHE 1;
96486
 
 
96487
 
 
96488
 
ALTER TABLE te.teemp_teemp_id_seq OWNER TO admin;
96489
 
 
96490
 
--
96491
 
--
96492
 
 
96493
 
ALTER SEQUENCE teemp_teemp_id_seq OWNED BY teemp.teemp_id;
96494
 
 
96495
 
 
96496
 
--
96497
 
--
96498
 
 
96499
 
CREATE TABLE teexp (
96500
 
    teexp_id integer NOT NULL,
96501
 
    teexp_expcat_id integer,
96502
 
    teexp_accnt_id integer
96503
 
);
96504
 
 
96505
 
 
96506
 
ALTER TABLE te.teexp OWNER TO admin;
96507
 
 
96508
 
--
96509
 
--
96510
 
 
96511
 
COMMENT ON TABLE teexp IS 'Expense/Item';
96512
 
 
96513
 
 
96514
 
--
96515
 
--
96516
 
 
96517
 
CREATE SEQUENCE timesheet_seq
96518
 
    START WITH 1000
96519
 
    INCREMENT BY 1
96520
 
    NO MINVALUE
96521
 
    NO MAXVALUE
96522
 
    CACHE 1;
96523
 
 
96524
 
 
96525
 
ALTER TABLE te.timesheet_seq OWNER TO admin;
96526
 
 
96527
 
--
96528
 
--
96529
 
 
96530
 
CREATE TABLE tehead (
96531
 
    tehead_id integer NOT NULL,
96532
 
    tehead_number text DEFAULT nextval('timesheet_seq'::regclass),
96533
 
    tehead_weekending date,
96534
 
    tehead_lastupdated timestamp without time zone DEFAULT now() NOT NULL,
96535
 
    tehead_notes text,
96536
 
    tehead_status character(1) DEFAULT 'O'::bpchar NOT NULL,
96537
 
    tehead_emp_id integer,
96538
 
    tehead_warehous_id integer NOT NULL,
96539
 
    tehead_username text DEFAULT "current_user"() NOT NULL,
96540
 
    CONSTRAINT tehead_tehead_status_check CHECK ((tehead_status = ANY (ARRAY['O'::bpchar, 'A'::bpchar, 'C'::bpchar])))
96541
 
);
96542
 
 
96543
 
 
96544
 
ALTER TABLE te.tehead OWNER TO admin;
96545
 
 
96546
 
--
96547
 
--
96548
 
 
96549
 
COMMENT ON TABLE tehead IS 'time/expense header';
96550
 
 
96551
 
 
96552
 
--
96553
 
--
96554
 
 
96555
 
CREATE SEQUENCE tehead_tehead_id_seq
96556
 
    START WITH 1
96557
 
    INCREMENT BY 1
96558
 
    NO MINVALUE
96559
 
    NO MAXVALUE
96560
 
    CACHE 1;
96561
 
 
96562
 
 
96563
 
ALTER TABLE te.tehead_tehead_id_seq OWNER TO admin;
96564
 
 
96565
 
--
96566
 
--
96567
 
 
96568
 
ALTER SEQUENCE tehead_tehead_id_seq OWNED BY tehead.tehead_id;
96569
 
 
96570
 
 
96571
 
--
96572
 
--
96573
 
 
96574
 
CREATE TABLE teitem (
96575
 
    teitem_id integer NOT NULL,
96576
 
    teitem_tehead_id integer,
96577
 
    teitem_linenumber integer NOT NULL,
96578
 
    teitem_type character(1) NOT NULL,
96579
 
    teitem_workdate date,
96580
 
    teitem_cust_id integer,
96581
 
    teitem_vend_id integer,
96582
 
    teitem_po text,
96583
 
    teitem_item_id integer NOT NULL,
96584
 
    teitem_qty numeric NOT NULL,
96585
 
    teitem_rate numeric NOT NULL,
96586
 
    teitem_total numeric NOT NULL,
96587
 
    teitem_prjtask_id numeric,
96588
 
    teitem_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL,
96589
 
    teitem_billable boolean,
96590
 
    teitem_prepaid boolean,
96591
 
    teitem_notes text,
96592
 
    teitem_posted boolean DEFAULT false,
96593
 
    teitem_curr_id integer DEFAULT public.basecurrid() NOT NULL,
96594
 
    teitem_uom_id integer,
96595
 
    teitem_invcitem_id integer,
96596
 
    teitem_vodist_id integer,
96597
 
    teitem_postedvalue numeric DEFAULT 0 NOT NULL,
96598
 
    teitem_empcost numeric
96599
 
);
96600
 
 
96601
 
 
96602
 
ALTER TABLE te.teitem OWNER TO admin;
96603
 
 
96604
 
--
96605
 
--
96606
 
 
96607
 
COMMENT ON TABLE teitem IS 'time/expense detail';
96608
 
 
96609
 
 
96610
 
--
96611
 
--
96612
 
 
96613
 
COMMENT ON COLUMN teitem.teitem_type IS 'T or E';
96614
 
 
96615
 
 
96616
 
--
96617
 
--
96618
 
 
96619
 
COMMENT ON COLUMN teitem.teitem_vend_id IS 'future use - for payment of vendor for expenses';
96620
 
 
96621
 
 
96622
 
--
96623
 
--
96624
 
 
96625
 
COMMENT ON COLUMN teitem.teitem_prepaid IS 'Used for expenses only.  CC paid expenses would be prepaid.';
96626
 
 
96627
 
 
96628
 
--
96629
 
--
96630
 
 
96631
 
CREATE SEQUENCE teitem_teitem_id_seq
96632
 
    START WITH 1
96633
 
    INCREMENT BY 1
96634
 
    NO MINVALUE
96635
 
    NO MAXVALUE
96636
 
    CACHE 1;
96637
 
 
96638
 
 
96639
 
ALTER TABLE te.teitem_teitem_id_seq OWNER TO admin;
96640
 
 
96641
 
--
96642
 
--
96643
 
 
96644
 
ALTER SEQUENCE teitem_teitem_id_seq OWNED BY teitem.teitem_id;
96645
 
 
96646
 
 
96647
 
--
96648
 
--
96649
 
 
96650
 
CREATE TABLE teprj (
96651
 
    teprj_id integer NOT NULL,
96652
 
    teprj_prj_id integer,
96653
 
    teprj_cust_id integer,
96654
 
    teprj_rate numeric,
96655
 
    teprj_curr_id integer
96656
 
);
96657
 
 
96658
 
 
96659
 
ALTER TABLE te.teprj OWNER TO admin;
96660
 
 
96661
 
--
96662
 
--
96663
 
 
96664
 
COMMENT ON TABLE teprj IS 't/e information for projects';
96665
 
 
96666
 
 
96667
 
--
96668
 
--
96669
 
 
96670
 
CREATE SEQUENCE teprj_teprj_id_seq
96671
 
    START WITH 1
96672
 
    INCREMENT BY 1
96673
 
    NO MINVALUE
96674
 
    NO MAXVALUE
96675
 
    CACHE 1;
96676
 
 
96677
 
 
96678
 
ALTER TABLE te.teprj_teprj_id_seq OWNER TO admin;
96679
 
 
96680
 
--
96681
 
--
96682
 
 
96683
 
ALTER SEQUENCE teprj_teprj_id_seq OWNED BY teprj.teprj_id;
96684
 
 
96685
 
 
96686
 
--
96687
 
--
96688
 
 
96689
 
CREATE TABLE teprjtask (
96690
 
    teprjtask_id integer NOT NULL,
96691
 
    teprjtask_cust_id integer,
96692
 
    teprjtask_rate numeric,
96693
 
    teprjtask_item_id integer,
96694
 
    teprjtask_prjtask_id integer,
96695
 
    teprjtask_curr_id integer DEFAULT public.basecurrid()
96696
 
);
96697
 
 
96698
 
 
96699
 
ALTER TABLE te.teprjtask OWNER TO admin;
96700
 
 
96701
 
--
96702
 
--
96703
 
 
96704
 
COMMENT ON TABLE teprjtask IS 't/e information for tasks';
96705
 
 
96706
 
 
96707
 
--
96708
 
--
96709
 
 
96710
 
CREATE SEQUENCE teprjtask_teprjtask_id_seq
96711
 
    START WITH 1
96712
 
    INCREMENT BY 1
96713
 
    NO MINVALUE
96714
 
    NO MAXVALUE
96715
 
    CACHE 1;
96716
 
 
96717
 
 
96718
 
ALTER TABLE te.teprjtask_teprjtask_id_seq OWNER TO admin;
96719
 
 
96720
 
--
96721
 
--
96722
 
 
96723
 
ALTER SEQUENCE teprjtask_teprjtask_id_seq OWNED BY teprjtask.teprjtask_id;
96724
 
 
96725
 
 
96726
 
SET search_path = xtdesktop, pg_catalog;
96727
 
 
96728
 
--
96729
 
--
96730
 
 
96731
 
CREATE TABLE pkgcmd (
96732
 
    cmd_id integer DEFAULT nextval('public.cmd_cmd_id_seq'::regclass)
96733
 
)
96734
 
INHERITS (public.cmd);
96735
 
 
96736
 
 
96737
 
ALTER TABLE xtdesktop.pkgcmd OWNER TO admin;
96738
 
 
96739
 
--
96740
 
--
96741
 
 
96742
 
CREATE TABLE pkgcmdarg (
96743
 
    cmdarg_id integer DEFAULT nextval('public.cmdarg_cmdarg_id_seq'::regclass)
96744
 
)
96745
 
INHERITS (public.cmdarg);
96746
 
 
96747
 
 
96748
 
ALTER TABLE xtdesktop.pkgcmdarg OWNER TO admin;
96749
 
 
96750
 
--
96751
 
--
96752
 
 
96753
 
CREATE TABLE pkgimage (
96754
 
    image_id integer DEFAULT nextval('public.image_image_id_seq'::regclass)
96755
 
)
96756
 
INHERITS (public.image);
96757
 
 
96758
 
 
96759
 
ALTER TABLE xtdesktop.pkgimage OWNER TO admin;
96760
 
 
96761
 
--
96762
 
--
96763
 
 
96764
 
CREATE TABLE pkgmetasql (
96765
 
    metasql_id integer DEFAULT nextval('public.metasql_metasql_id_seq'::regclass)
96766
 
)
96767
 
INHERITS (public.metasql);
96768
 
 
96769
 
 
96770
 
ALTER TABLE xtdesktop.pkgmetasql OWNER TO admin;
96771
 
 
96772
 
--
96773
 
--
96774
 
 
96775
 
CREATE TABLE pkgpriv (
96776
 
    priv_id integer DEFAULT nextval('public.priv_priv_id_seq'::regclass)
96777
 
)
96778
 
INHERITS (public.priv);
96779
 
 
96780
 
 
96781
 
ALTER TABLE xtdesktop.pkgpriv OWNER TO admin;
96782
 
 
96783
 
--
96784
 
--
96785
 
 
96786
 
CREATE TABLE pkgreport (
96787
 
    report_id integer DEFAULT nextval('public.report_report_id_seq'::regclass)
96788
 
)
96789
 
INHERITS (public.report);
96790
 
 
96791
 
 
96792
 
ALTER TABLE xtdesktop.pkgreport OWNER TO admin;
96793
 
 
96794
 
--
96795
 
--
96796
 
 
96797
 
CREATE TABLE pkgscript (
96798
 
    script_id integer DEFAULT nextval('public.script_script_id_seq'::regclass)
96799
 
)
96800
 
INHERITS (public.script);
96801
 
 
96802
 
 
96803
 
ALTER TABLE xtdesktop.pkgscript OWNER TO admin;
96804
 
 
96805
 
--
96806
 
--
96807
 
 
96808
 
CREATE TABLE pkguiform (
96809
 
    uiform_id integer DEFAULT nextval('public.uiform_uiform_id_seq'::regclass)
96810
 
)
96811
 
INHERITS (public.uiform);
96812
 
 
96813
 
 
96814
 
ALTER TABLE xtdesktop.pkguiform OWNER TO admin;
96815
 
 
96816
 
SET search_path = fixcountry, pg_catalog;
96817
 
 
96818
 
--
96819
 
--
96820
 
 
96821
 
ALTER TABLE ONLY pkgmetasql ALTER COLUMN metasql_grade SET DEFAULT 0;
96822
 
 
96823
 
 
96824
 
--
96825
 
--
96826
 
 
96827
 
ALTER TABLE ONLY pkgscript ALTER COLUMN script_enabled SET DEFAULT false;
96828
 
 
96829
 
 
96830
 
--
96831
 
--
96832
 
 
96833
 
ALTER TABLE ONLY pkguiform ALTER COLUMN uiform_enabled SET DEFAULT false;
96834
 
 
96835
 
 
96836
 
SET search_path = public, pg_catalog;
96837
 
 
96838
 
--
96839
 
--
96840
 
 
96841
 
ALTER TABLE ONLY addr ALTER COLUMN addr_id SET DEFAULT nextval('addr_addr_id_seq'::regclass);
96842
 
 
96843
 
 
96844
 
--
96845
 
--
96846
 
 
96847
 
ALTER TABLE ONLY alarm ALTER COLUMN alarm_id SET DEFAULT nextval('alarm_alarm_id_seq'::regclass);
96848
 
 
96849
 
 
96850
 
--
96851
 
--
96852
 
 
96853
 
ALTER TABLE ONLY apaccnt ALTER COLUMN apaccnt_id SET DEFAULT nextval('apaccnt_apaccnt_id_seq'::regclass);
96854
 
 
96855
 
 
96856
 
--
96857
 
--
96858
 
 
96859
 
ALTER TABLE ONLY apapply ALTER COLUMN apapply_id SET DEFAULT nextval('apapply_apapply_id_seq'::regclass);
96860
 
 
96861
 
 
96862
 
--
96863
 
--
96864
 
 
96865
 
ALTER TABLE ONLY apcreditapply ALTER COLUMN apcreditapply_id SET DEFAULT nextval('apcreditapply_apcreditapply_id_seq'::regclass);
96866
 
 
96867
 
 
96868
 
--
96869
 
--
96870
 
 
96871
 
ALTER TABLE ONLY apopentax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass);
96872
 
 
96873
 
 
96874
 
--
96875
 
--
96876
 
 
96877
 
ALTER TABLE ONLY apselect ALTER COLUMN apselect_id SET DEFAULT nextval('apselect_apselect_id_seq'::regclass);
96878
 
 
96879
 
 
96880
 
--
96881
 
--
96882
 
 
96883
 
ALTER TABLE ONLY arapply ALTER COLUMN arapply_id SET DEFAULT nextval('arapply_arapply_id_seq'::regclass);
96884
 
 
96885
 
 
96886
 
--
96887
 
--
96888
 
 
96889
 
ALTER TABLE ONLY aropentax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass);
96890
 
 
96891
 
 
96892
 
--
96893
 
--
96894
 
 
96895
 
ALTER TABLE ONLY asohist ALTER COLUMN asohist_id SET DEFAULT nextval('asohist_asohist_id_seq'::regclass);
96896
 
 
96897
 
 
96898
 
--
96899
 
--
96900
 
 
96901
 
ALTER TABLE ONLY asohisttax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass);
96902
 
 
96903
 
 
96904
 
--
96905
 
--
96906
 
 
96907
 
ALTER TABLE ONLY atlasmap ALTER COLUMN atlasmap_id SET DEFAULT nextval('atlasmap_atlasmap_id_seq'::regclass);
96908
 
 
96909
 
 
96910
 
--
96911
 
--
96912
 
 
96913
 
ALTER TABLE ONLY bankaccnt ALTER COLUMN bankaccnt_id SET DEFAULT nextval('bankaccnt_bankaccnt_id_seq'::regclass);
96914
 
 
96915
 
 
96916
 
--
96917
 
--
96918
 
 
96919
 
ALTER TABLE ONLY bankadj ALTER COLUMN bankadj_id SET DEFAULT nextval('bankadj_bankadj_id_seq'::regclass);
96920
 
 
96921
 
 
96922
 
--
96923
 
--
96924
 
 
96925
 
ALTER TABLE ONLY bankadjtype ALTER COLUMN bankadjtype_id SET DEFAULT nextval('bankadjtype_bankadjtype_id_seq'::regclass);
96926
 
 
96927
 
 
96928
 
--
96929
 
--
96930
 
 
96931
 
ALTER TABLE ONLY bankrec ALTER COLUMN bankrec_id SET DEFAULT nextval('bankrec_bankrec_id_seq'::regclass);
96932
 
 
96933
 
 
96934
 
--
96935
 
--
96936
 
 
96937
 
ALTER TABLE ONLY bankrecimport ALTER COLUMN bankrecimport_id SET DEFAULT nextval('bankrecimport_bankrecimport_id_seq'::regclass);
96938
 
 
96939
 
 
96940
 
--
96941
 
--
96942
 
 
96943
 
ALTER TABLE ONLY bankrecitem ALTER COLUMN bankrecitem_id SET DEFAULT nextval('bankrecitem_bankrecitem_id_seq'::regclass);
96944
 
 
96945
 
 
96946
 
--
96947
 
--
96948
 
 
96949
 
ALTER TABLE ONLY bomitemcost ALTER COLUMN bomitemcost_id SET DEFAULT nextval('bomitemcost_bomitemcost_id_seq'::regclass);
96950
 
 
96951
 
 
96952
 
--
96953
 
--
96954
 
 
96955
 
ALTER TABLE ONLY bomitemsub ALTER COLUMN bomitemsub_id SET DEFAULT nextval('bomitemsub_bomitemsub_id_seq'::regclass);
96956
 
 
96957
 
 
96958
 
--
96959
 
--
96960
 
 
96961
 
ALTER TABLE ONLY bomwork ALTER COLUMN bomwork_id SET DEFAULT nextval('bomwork_bomwork_id_seq'::regclass);
96962
 
 
96963
 
 
96964
 
--
96965
 
--
96966
 
 
96967
 
ALTER TABLE ONLY budghead ALTER COLUMN budghead_id SET DEFAULT nextval('budghead_budghead_id_seq'::regclass);
96968
 
 
96969
 
 
96970
 
--
96971
 
--
96972
 
 
96973
 
ALTER TABLE ONLY budgitem ALTER COLUMN budgitem_id SET DEFAULT nextval('budgitem_budgitem_id_seq'::regclass);
96974
 
 
96975
 
 
96976
 
--
96977
 
--
96978
 
 
96979
 
ALTER TABLE ONLY cashrcpt ALTER COLUMN cashrcpt_id SET DEFAULT nextval('cashrcpt_cashrcpt_id_seq'::regclass);
96980
 
 
96981
 
 
96982
 
--
96983
 
--
96984
 
 
96985
 
ALTER TABLE ONLY cashrcptitem ALTER COLUMN cashrcptitem_id SET DEFAULT nextval('cashrcptitem_cashrcptitem_id_seq'::regclass);
96986
 
 
96987
 
 
96988
 
--
96989
 
--
96990
 
 
96991
 
ALTER TABLE ONLY cashrcptmisc ALTER COLUMN cashrcptmisc_id SET DEFAULT nextval('cashrcptmisc_cashrcptmisc_id_seq'::regclass);
96992
 
 
96993
 
 
96994
 
--
96995
 
--
96996
 
 
96997
 
ALTER TABLE ONLY ccard ALTER COLUMN ccard_id SET DEFAULT nextval('ccard_ccard_id_seq'::regclass);
96998
 
 
96999
 
 
97000
 
--
97001
 
--
97002
 
 
97003
 
ALTER TABLE ONLY ccardaud ALTER COLUMN ccardaud_id SET DEFAULT nextval('ccardaud_ccardaud_id_seq'::regclass);
97004
 
 
97005
 
 
97006
 
--
97007
 
--
97008
 
 
97009
 
ALTER TABLE ONLY ccbank ALTER COLUMN ccbank_id SET DEFAULT nextval('ccbank_ccbank_id_seq'::regclass);
97010
 
 
97011
 
 
97012
 
--
97013
 
--
97014
 
 
97015
 
ALTER TABLE ONLY ccpay ALTER COLUMN ccpay_id SET DEFAULT nextval('ccpay_ccpay_id_seq'::regclass);
97016
 
 
97017
 
 
97018
 
--
97019
 
--
97020
 
 
97021
 
ALTER TABLE ONLY "char" ALTER COLUMN char_id SET DEFAULT nextval('char_char_id_seq'::regclass);
97022
 
 
97023
 
 
97024
 
--
97025
 
--
97026
 
 
97027
 
ALTER TABLE ONLY charass ALTER COLUMN charass_id SET DEFAULT nextval('charass_charass_id_seq'::regclass);
97028
 
 
97029
 
 
97030
 
--
97031
 
--
97032
 
 
97033
 
ALTER TABLE ONLY charopt ALTER COLUMN charopt_id SET DEFAULT nextval('charopt_charopt_id_seq'::regclass);
97034
 
 
97035
 
 
97036
 
--
97037
 
--
97038
 
 
97039
 
ALTER TABLE ONLY checkhead ALTER COLUMN checkhead_id SET DEFAULT nextval('checkhead_checkhead_id_seq'::regclass);
97040
 
 
97041
 
 
97042
 
--
97043
 
--
97044
 
 
97045
 
ALTER TABLE ONLY checkitem ALTER COLUMN checkitem_id SET DEFAULT nextval('checkitem_checkitem_id_seq'::regclass);
97046
 
 
97047
 
 
97048
 
--
97049
 
--
97050
 
 
97051
 
ALTER TABLE ONLY cmd ALTER COLUMN cmd_id SET DEFAULT nextval('cmd_cmd_id_seq'::regclass);
97052
 
 
97053
 
 
97054
 
--
97055
 
--
97056
 
 
97057
 
ALTER TABLE ONLY cmdarg ALTER COLUMN cmdarg_id SET DEFAULT nextval('cmdarg_cmdarg_id_seq'::regclass);
97058
 
 
97059
 
 
97060
 
--
97061
 
--
97062
 
 
97063
 
ALTER TABLE ONLY cmheadtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass);
97064
 
 
97065
 
 
97066
 
--
97067
 
--
97068
 
 
97069
 
ALTER TABLE ONLY cmitemtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass);
97070
 
 
97071
 
 
97072
 
--
97073
 
--
97074
 
 
97075
 
ALTER TABLE ONLY cmnttype ALTER COLUMN cmnttype_id SET DEFAULT nextval('cmnttype_cmnttype_id_seq'::regclass);
97076
 
 
97077
 
 
97078
 
--
97079
 
--
97080
 
 
97081
 
ALTER TABLE ONLY cmnttypesource ALTER COLUMN cmnttypesource_id SET DEFAULT nextval('cmnttypesource_cmnttypesource_id_seq'::regclass);
97082
 
 
97083
 
 
97084
 
--
97085
 
--
97086
 
 
97087
 
ALTER TABLE ONLY cntct ALTER COLUMN cntct_id SET DEFAULT nextval('cntct_cntct_id_seq'::regclass);
97088
 
 
97089
 
 
97090
 
--
97091
 
--
97092
 
 
97093
 
ALTER TABLE ONLY cntctaddr ALTER COLUMN cntctaddr_id SET DEFAULT nextval('cntctaddr_cntctaddr_id_seq'::regclass);
97094
 
 
97095
 
 
97096
 
--
97097
 
--
97098
 
 
97099
 
ALTER TABLE ONLY cntctdata ALTER COLUMN cntctdata_id SET DEFAULT nextval('cntctdata_cntctdata_id_seq'::regclass);
97100
 
 
97101
 
 
97102
 
--
97103
 
--
97104
 
 
97105
 
ALTER TABLE ONLY cntcteml ALTER COLUMN cntcteml_id SET DEFAULT nextval('cntcteml_cntcteml_id_seq'::regclass);
97106
 
 
97107
 
 
97108
 
--
97109
 
--
97110
 
 
97111
 
ALTER TABLE ONLY cobilltax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass);
97112
 
 
97113
 
 
97114
 
--
97115
 
--
97116
 
 
97117
 
ALTER TABLE ONLY cobmisctax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass);
97118
 
 
97119
 
 
97120
 
--
97121
 
--
97122
 
 
97123
 
ALTER TABLE ONLY cohisttax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass);
97124
 
 
97125
 
 
97126
 
--
97127
 
--
97128
 
 
97129
 
ALTER TABLE ONLY company ALTER COLUMN company_id SET DEFAULT nextval('company_company_id_seq'::regclass);
97130
 
 
97131
 
 
97132
 
--
97133
 
--
97134
 
 
97135
 
ALTER TABLE ONLY contrct ALTER COLUMN contrct_id SET DEFAULT nextval('contrct_contrct_id_seq'::regclass);
97136
 
 
97137
 
 
97138
 
--
97139
 
--
97140
 
 
97141
 
ALTER TABLE ONLY country ALTER COLUMN country_id SET DEFAULT nextval('country_country_id_seq'::regclass);
97142
 
 
97143
 
 
97144
 
--
97145
 
--
97146
 
 
97147
 
ALTER TABLE ONLY crmacct ALTER COLUMN crmacct_id SET DEFAULT nextval('crmacct_crmacct_id_seq'::regclass);
97148
 
 
97149
 
 
97150
 
--
97151
 
--
97152
 
 
97153
 
ALTER TABLE ONLY curr_rate ALTER COLUMN curr_rate_id SET DEFAULT nextval('curr_rate_curr_rate_id_seq'::regclass);
97154
 
 
97155
 
 
97156
 
--
97157
 
--
97158
 
 
97159
 
ALTER TABLE ONLY curr_symbol ALTER COLUMN curr_id SET DEFAULT nextval('curr_symbol_curr_id_seq'::regclass);
97160
 
 
97161
 
 
97162
 
--
97163
 
--
97164
 
 
97165
 
ALTER TABLE ONLY dept ALTER COLUMN dept_id SET DEFAULT nextval('dept_dept_id_seq'::regclass);
97166
 
 
97167
 
 
97168
 
--
97169
 
--
97170
 
 
97171
 
ALTER TABLE ONLY docass ALTER COLUMN docass_id SET DEFAULT nextval('docass_docass_id_seq'::regclass);
97172
 
 
97173
 
 
97174
 
--
97175
 
--
97176
 
 
97177
 
ALTER TABLE ONLY emp ALTER COLUMN emp_id SET DEFAULT nextval('emp_emp_id_seq'::regclass);
97178
 
 
97179
 
 
97180
 
--
97181
 
--
97182
 
 
97183
 
ALTER TABLE ONLY empgrp ALTER COLUMN empgrp_id SET DEFAULT nextval('empgrp_empgrp_id_seq'::regclass);
97184
 
 
97185
 
 
97186
 
--
97187
 
--
97188
 
 
97189
 
ALTER TABLE ONLY empgrpitem ALTER COLUMN empgrpitem_id SET DEFAULT nextval('empgrpitem_empgrpitem_id_seq'::regclass);
97190
 
 
97191
 
 
97192
 
--
97193
 
--
97194
 
 
97195
 
ALTER TABLE ONLY expcat ALTER COLUMN expcat_id SET DEFAULT nextval('expcat_expcat_id_seq'::regclass);
97196
 
 
97197
 
 
97198
 
--
97199
 
--
97200
 
 
97201
 
ALTER TABLE ONLY file ALTER COLUMN file_id SET DEFAULT nextval('file_file_id_seq'::regclass);
97202
 
 
97203
 
 
97204
 
--
97205
 
--
97206
 
 
97207
 
ALTER TABLE ONLY filter ALTER COLUMN filter_id SET DEFAULT nextval('filter_filter_id_seq'::regclass);
97208
 
 
97209
 
 
97210
 
--
97211
 
--
97212
 
 
97213
 
ALTER TABLE ONLY fincharg ALTER COLUMN fincharg_id SET DEFAULT nextval('fincharg_fincharg_id_seq'::regclass);
97214
 
 
97215
 
 
97216
 
--
97217
 
--
97218
 
 
97219
 
ALTER TABLE ONLY flcol ALTER COLUMN flcol_id SET DEFAULT nextval('flcol_flcol_id_seq'::regclass);
97220
 
 
97221
 
 
97222
 
--
97223
 
--
97224
 
 
97225
 
ALTER TABLE ONLY flgrp ALTER COLUMN flgrp_id SET DEFAULT nextval('flgrp_flgrp_id_seq'::regclass);
97226
 
 
97227
 
 
97228
 
--
97229
 
--
97230
 
 
97231
 
ALTER TABLE ONLY flhead ALTER COLUMN flhead_id SET DEFAULT nextval('flhead_flhead_id_seq'::regclass);
97232
 
 
97233
 
 
97234
 
--
97235
 
--
97236
 
 
97237
 
ALTER TABLE ONLY flitem ALTER COLUMN flitem_id SET DEFAULT nextval('flitem_flitem_id_seq'::regclass);
97238
 
 
97239
 
 
97240
 
--
97241
 
--
97242
 
 
97243
 
ALTER TABLE ONLY flnotes ALTER COLUMN flnotes_id SET DEFAULT nextval('flnotes_flnotes_id_seq'::regclass);
97244
 
 
97245
 
 
97246
 
--
97247
 
--
97248
 
 
97249
 
ALTER TABLE ONLY flrpt ALTER COLUMN flrpt_id SET DEFAULT nextval('flrpt_flrpt_id_seq'::regclass);
97250
 
 
97251
 
 
97252
 
--
97253
 
--
97254
 
 
97255
 
ALTER TABLE ONLY flspec ALTER COLUMN flspec_id SET DEFAULT nextval('flspec_flspec_id_seq'::regclass);
97256
 
 
97257
 
 
97258
 
--
97259
 
--
97260
 
 
97261
 
ALTER TABLE ONLY freightclass ALTER COLUMN freightclass_id SET DEFAULT nextval('freightclass_freightclass_id_seq'::regclass);
97262
 
 
97263
 
 
97264
 
--
97265
 
--
97266
 
 
97267
 
ALTER TABLE ONLY grp ALTER COLUMN grp_id SET DEFAULT nextval('grp_grp_id_seq'::regclass);
97268
 
 
97269
 
 
97270
 
--
97271
 
--
97272
 
 
97273
 
ALTER TABLE ONLY grppriv ALTER COLUMN grppriv_id SET DEFAULT nextval('grppriv_grppriv_id_seq'::regclass);
97274
 
 
97275
 
 
97276
 
--
97277
 
--
97278
 
 
97279
 
ALTER TABLE ONLY hnfc ALTER COLUMN hnfc_id SET DEFAULT nextval('hnfc_hnfc_id_seq'::regclass);
97280
 
 
97281
 
 
97282
 
--
97283
 
--
97284
 
 
97285
 
ALTER TABLE ONLY incdt ALTER COLUMN incdt_id SET DEFAULT nextval('incdt_incdt_id_seq'::regclass);
97286
 
 
97287
 
 
97288
 
--
97289
 
--
97290
 
 
97291
 
ALTER TABLE ONLY incdtcat ALTER COLUMN incdtcat_id SET DEFAULT nextval('incdtcat_incdtcat_id_seq'::regclass);
97292
 
 
97293
 
 
97294
 
--
97295
 
--
97296
 
 
97297
 
ALTER TABLE ONLY incdthist ALTER COLUMN incdthist_id SET DEFAULT nextval('incdthist_incdthist_id_seq'::regclass);
97298
 
 
97299
 
 
97300
 
--
97301
 
--
97302
 
 
97303
 
ALTER TABLE ONLY incdtpriority ALTER COLUMN incdtpriority_id SET DEFAULT nextval('incdtpriority_incdtpriority_id_seq'::regclass);
97304
 
 
97305
 
 
97306
 
--
97307
 
--
97308
 
 
97309
 
ALTER TABLE ONLY incdtresolution ALTER COLUMN incdtresolution_id SET DEFAULT nextval('incdtresolution_incdtresolution_id_seq'::regclass);
97310
 
 
97311
 
 
97312
 
--
97313
 
--
97314
 
 
97315
 
ALTER TABLE ONLY incdtseverity ALTER COLUMN incdtseverity_id SET DEFAULT nextval('incdtseverity_incdtseverity_id_seq'::regclass);
97316
 
 
97317
 
 
97318
 
--
97319
 
--
97320
 
 
97321
 
ALTER TABLE ONLY invbal ALTER COLUMN invbal_id SET DEFAULT nextval('invbal_invbal_id_seq'::regclass);
97322
 
 
97323
 
 
97324
 
--
97325
 
--
97326
 
 
97327
 
ALTER TABLE ONLY invchead ALTER COLUMN invchead_id SET DEFAULT nextval('invchead_invchead_id_seq'::regclass);
97328
 
 
97329
 
 
97330
 
--
97331
 
--
97332
 
 
97333
 
ALTER TABLE ONLY invcheadtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass);
97334
 
 
97335
 
 
97336
 
--
97337
 
--
97338
 
 
97339
 
ALTER TABLE ONLY invcitem ALTER COLUMN invcitem_id SET DEFAULT nextval('invcitem_invcitem_id_seq'::regclass);
97340
 
 
97341
 
 
97342
 
--
97343
 
--
97344
 
 
97345
 
ALTER TABLE ONLY invcitemtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass);
97346
 
 
97347
 
 
97348
 
--
97349
 
--
97350
 
 
97351
 
ALTER TABLE ONLY invhistexpcat ALTER COLUMN invhistexpcat_id SET DEFAULT nextval('invhistexpcat_invhistexpcat_id_seq'::regclass);
97352
 
 
97353
 
 
97354
 
--
97355
 
--
97356
 
 
97357
 
ALTER TABLE ONLY ipsass ALTER COLUMN ipsass_id SET DEFAULT nextval('ipsass_ipsass_id_seq'::regclass);
97358
 
 
97359
 
 
97360
 
--
97361
 
--
97362
 
 
97363
 
ALTER TABLE ONLY ipsfreight ALTER COLUMN ipsfreight_id SET DEFAULT nextval('ipsfreight_ipsfreight_id_seq'::regclass);
97364
 
 
97365
 
 
97366
 
--
97367
 
--
97368
 
 
97369
 
ALTER TABLE ONLY ipsitemchar ALTER COLUMN ipsitemchar_id SET DEFAULT nextval('ipsitemchar_ipsitemchar_id_seq'::regclass);
97370
 
 
97371
 
 
97372
 
--
97373
 
--
97374
 
 
97375
 
ALTER TABLE ONLY ipsprodcat_bak ALTER COLUMN ipsprodcat_id SET DEFAULT nextval('ipsprodcat_ipsprodcat_id_seq'::regclass);
97376
 
 
97377
 
 
97378
 
--
97379
 
--
97380
 
 
97381
 
ALTER TABLE ONLY itemlocpost ALTER COLUMN itemlocpost_id SET DEFAULT nextval('itemlocpost_itemlocpost_id_seq'::regclass);
97382
 
 
97383
 
 
97384
 
--
97385
 
--
97386
 
 
97387
 
ALTER TABLE ONLY itemtax ALTER COLUMN itemtax_id SET DEFAULT nextval('itemtax_itemtax_id_seq'::regclass);
97388
 
 
97389
 
 
97390
 
--
97391
 
--
97392
 
 
97393
 
ALTER TABLE ONLY itemtrans ALTER COLUMN itemtrans_id SET DEFAULT nextval('itemtrans_itemtrans_id_seq'::regclass);
97394
 
 
97395
 
 
97396
 
--
97397
 
--
97398
 
 
97399
 
ALTER TABLE ONLY itemuom ALTER COLUMN itemuom_id SET DEFAULT nextval('itemuom_itemuom_id_seq'::regclass);
97400
 
 
97401
 
 
97402
 
--
97403
 
--
97404
 
 
97405
 
ALTER TABLE ONLY itemuomconv ALTER COLUMN itemuomconv_id SET DEFAULT nextval('itemuomconv_itemuomconv_id_seq'::regclass);
97406
 
 
97407
 
 
97408
 
--
97409
 
--
97410
 
 
97411
 
ALTER TABLE ONLY labeldef ALTER COLUMN labeldef_id SET DEFAULT nextval('labeldef_labeldef_id_seq'::regclass);
97412
 
 
97413
 
 
97414
 
--
97415
 
--
97416
 
 
97417
 
ALTER TABLE ONLY lang ALTER COLUMN lang_id SET DEFAULT nextval('lang_lang_id_seq'::regclass);
97418
 
 
97419
 
 
97420
 
--
97421
 
--
97422
 
 
97423
 
ALTER TABLE ONLY metasql ALTER COLUMN metasql_id SET DEFAULT nextval('metasql_metasql_id_seq'::regclass);
97424
 
 
97425
 
 
97426
 
--
97427
 
--
97428
 
 
97429
 
ALTER TABLE ONLY metricenc ALTER COLUMN metricenc_id SET DEFAULT nextval('metricenc_metricenc_id_seq'::regclass);
97430
 
 
97431
 
 
97432
 
--
97433
 
--
97434
 
 
97435
 
ALTER TABLE ONLY ophead ALTER COLUMN ophead_id SET DEFAULT nextval('ophead_ophead_id_seq'::regclass);
97436
 
 
97437
 
 
97438
 
--
97439
 
--
97440
 
 
97441
 
ALTER TABLE ONLY opsource ALTER COLUMN opsource_id SET DEFAULT nextval('opsource_opsource_id_seq'::regclass);
97442
 
 
97443
 
 
97444
 
--
97445
 
--
97446
 
 
97447
 
ALTER TABLE ONLY opstage ALTER COLUMN opstage_id SET DEFAULT nextval('opstage_opstage_id_seq'::regclass);
97448
 
 
97449
 
 
97450
 
--
97451
 
--
97452
 
 
97453
 
ALTER TABLE ONLY optype ALTER COLUMN optype_id SET DEFAULT nextval('optype_optype_id_seq'::regclass);
97454
 
 
97455
 
 
97456
 
--
97457
 
--
97458
 
 
97459
 
ALTER TABLE ONLY pack ALTER COLUMN pack_id SET DEFAULT nextval('pack_pack_id_seq'::regclass);
97460
 
 
97461
 
 
97462
 
--
97463
 
--
97464
 
 
97465
 
ALTER TABLE ONLY payco ALTER COLUMN payco_id SET DEFAULT nextval('payco_payco_id_seq'::regclass);
97466
 
 
97467
 
 
97468
 
--
97469
 
--
97470
 
 
97471
 
ALTER TABLE ONLY period ALTER COLUMN period_id SET DEFAULT nextval('period_period_id_seq'::regclass);
97472
 
 
97473
 
 
97474
 
--
97475
 
--
97476
 
 
97477
 
ALTER TABLE ONLY pkgdep ALTER COLUMN pkgdep_id SET DEFAULT nextval('pkgdep_pkgdep_id_seq'::regclass);
97478
 
 
97479
 
 
97480
 
--
97481
 
--
97482
 
 
97483
 
ALTER TABLE ONLY pkghead ALTER COLUMN pkghead_id SET DEFAULT nextval('pkghead_pkghead_id_seq'::regclass);
97484
 
 
97485
 
 
97486
 
--
97487
 
--
97488
 
 
97489
 
ALTER TABLE ONLY pkgitem ALTER COLUMN pkgitem_id SET DEFAULT nextval('pkgitem_pkgitem_id_seq'::regclass);
97490
 
 
97491
 
 
97492
 
--
97493
 
--
97494
 
 
97495
 
ALTER TABLE ONLY potype ALTER COLUMN potype_id SET DEFAULT nextval('potype_potype_id_seq'::regclass);
97496
 
 
97497
 
 
97498
 
--
97499
 
--
97500
 
 
97501
 
ALTER TABLE ONLY prftcntr ALTER COLUMN prftcntr_id SET DEFAULT nextval('prftcntr_prftcntr_id_seq'::regclass);
97502
 
 
97503
 
 
97504
 
--
97505
 
--
97506
 
 
97507
 
ALTER TABLE ONLY prj ALTER COLUMN prj_id SET DEFAULT nextval('prj_prj_id_seq'::regclass);
97508
 
 
97509
 
 
97510
 
--
97511
 
--
97512
 
 
97513
 
ALTER TABLE ONLY prjtask ALTER COLUMN prjtask_id SET DEFAULT nextval('prjtask_prjtask_id_seq'::regclass);
97514
 
 
97515
 
 
97516
 
--
97517
 
--
97518
 
 
97519
 
ALTER TABLE ONLY prjtaskuser ALTER COLUMN prjtaskuser_id SET DEFAULT nextval('prjtaskuser_prjtaskuser_id_seq'::regclass);
97520
 
 
97521
 
 
97522
 
--
97523
 
--
97524
 
 
97525
 
ALTER TABLE ONLY prjtype ALTER COLUMN prjtype_id SET DEFAULT nextval('prjtype_prjtype_id_seq'::regclass);
97526
 
 
97527
 
 
97528
 
--
97529
 
--
97530
 
 
97531
 
ALTER TABLE ONLY qryhead ALTER COLUMN qryhead_id SET DEFAULT nextval('qryhead_qryhead_id_seq'::regclass);
97532
 
 
97533
 
 
97534
 
--
97535
 
--
97536
 
 
97537
 
ALTER TABLE ONLY qryitem ALTER COLUMN qryitem_id SET DEFAULT nextval('qryitem_qryitem_id_seq'::regclass);
97538
 
 
97539
 
 
97540
 
--
97541
 
--
97542
 
 
97543
 
ALTER TABLE ONLY recur ALTER COLUMN recur_id SET DEFAULT nextval('recur_recur_id_seq'::regclass);
97544
 
 
97545
 
 
97546
 
--
97547
 
--
97548
 
 
97549
 
ALTER TABLE ONLY recurtype ALTER COLUMN recurtype_id SET DEFAULT nextval('recurtype_recurtype_id_seq'::regclass);
97550
 
 
97551
 
 
97552
 
--
97553
 
--
97554
 
 
97555
 
ALTER TABLE ONLY recv ALTER COLUMN recv_id SET DEFAULT nextval('recv_recv_id_seq'::regclass);
97556
 
 
97557
 
 
97558
 
--
97559
 
--
97560
 
 
97561
 
ALTER TABLE ONLY rsncode ALTER COLUMN rsncode_id SET DEFAULT nextval('rsncode_rsncode_id_seq'::regclass);
97562
 
 
97563
 
 
97564
 
--
97565
 
--
97566
 
 
97567
 
ALTER TABLE ONLY salescat ALTER COLUMN salescat_id SET DEFAULT nextval('salescat_salescat_id_seq'::regclass);
97568
 
 
97569
 
 
97570
 
--
97571
 
--
97572
 
 
97573
 
ALTER TABLE ONLY saletype ALTER COLUMN saletype_id SET DEFAULT nextval('saletype_saletype_id_seq'::regclass);
97574
 
 
97575
 
 
97576
 
--
97577
 
--
97578
 
 
97579
 
ALTER TABLE ONLY schemaord ALTER COLUMN schemaord_id SET DEFAULT nextval('schemaord_schemaord_id_seq'::regclass);
97580
 
 
97581
 
 
97582
 
--
97583
 
--
97584
 
 
97585
 
ALTER TABLE ONLY script ALTER COLUMN script_id SET DEFAULT nextval('script_script_id_seq'::regclass);
97586
 
 
97587
 
 
97588
 
--
97589
 
--
97590
 
 
97591
 
ALTER TABLE ONLY shift ALTER COLUMN shift_id SET DEFAULT nextval('shift_shift_id_seq'::regclass);
97592
 
 
97593
 
 
97594
 
--
97595
 
--
97596
 
 
97597
 
ALTER TABLE ONLY shipchrg ALTER COLUMN shipchrg_id SET DEFAULT nextval('shipchrg_shipchrg_id_seq'::regclass);
97598
 
 
97599
 
 
97600
 
--
97601
 
--
97602
 
 
97603
 
ALTER TABLE ONLY shiphead ALTER COLUMN shiphead_id SET DEFAULT nextval('shiphead_shiphead_id_seq'::regclass);
97604
 
 
97605
 
 
97606
 
--
97607
 
--
97608
 
 
97609
 
ALTER TABLE ONLY shipitem ALTER COLUMN shipitem_id SET DEFAULT nextval('shipitem_shipitem_id_seq'::regclass);
97610
 
 
97611
 
 
97612
 
--
97613
 
--
97614
 
 
97615
 
ALTER TABLE ONLY sitetype ALTER COLUMN sitetype_id SET DEFAULT nextval('sitetype_sitetype_id_seq'::regclass);
97616
 
 
97617
 
 
97618
 
--
97619
 
--
97620
 
 
97621
 
ALTER TABLE ONLY source ALTER COLUMN source_id SET DEFAULT nextval('source_source_id_seq'::regclass);
97622
 
 
97623
 
 
97624
 
--
97625
 
--
97626
 
 
97627
 
ALTER TABLE ONLY state ALTER COLUMN state_id SET DEFAULT nextval('state_state_id_seq'::regclass);
97628
 
 
97629
 
 
97630
 
--
97631
 
--
97632
 
 
97633
 
ALTER TABLE ONLY status ALTER COLUMN status_id SET DEFAULT nextval('status_status_id_seq'::regclass);
97634
 
 
97635
 
 
97636
 
--
97637
 
--
97638
 
 
97639
 
ALTER TABLE ONLY stdjrnl ALTER COLUMN stdjrnl_id SET DEFAULT nextval('stdjrnl_stdjrnl_id_seq'::regclass);
97640
 
 
97641
 
 
97642
 
--
97643
 
--
97644
 
 
97645
 
ALTER TABLE ONLY stdjrnlgrp ALTER COLUMN stdjrnlgrp_id SET DEFAULT nextval('stdjrnlgrp_stdjrnlgrp_id_seq'::regclass);
97646
 
 
97647
 
 
97648
 
--
97649
 
--
97650
 
 
97651
 
ALTER TABLE ONLY stdjrnlgrpitem ALTER COLUMN stdjrnlgrpitem_id SET DEFAULT nextval('stdjrnlgrpitem_stdjrnlgrpitem_id_seq'::regclass);
97652
 
 
97653
 
 
97654
 
--
97655
 
--
97656
 
 
97657
 
ALTER TABLE ONLY stdjrnlitem ALTER COLUMN stdjrnlitem_id SET DEFAULT nextval('stdjrnlitem_stdjrnlitem_id_seq'::regclass);
97658
 
 
97659
 
 
97660
 
--
97661
 
--
97662
 
 
97663
 
ALTER TABLE ONLY subaccnt ALTER COLUMN subaccnt_id SET DEFAULT nextval('subaccnt_subaccnt_id_seq'::regclass);
97664
 
 
97665
 
 
97666
 
--
97667
 
--
97668
 
 
97669
 
ALTER TABLE ONLY subaccnttype ALTER COLUMN subaccnttype_id SET DEFAULT nextval('subaccnttype_subaccnttype_id_seq'::regclass);
97670
 
 
97671
 
 
97672
 
--
97673
 
--
97674
 
 
97675
 
ALTER TABLE ONLY taxass ALTER COLUMN taxass_id SET DEFAULT nextval('taxass_taxass_id_seq'::regclass);
97676
 
 
97677
 
 
97678
 
--
97679
 
--
97680
 
 
97681
 
ALTER TABLE ONLY taxauth ALTER COLUMN taxauth_id SET DEFAULT nextval('taxauth_taxauth_id_seq'::regclass);
97682
 
 
97683
 
 
97684
 
--
97685
 
--
97686
 
 
97687
 
ALTER TABLE ONLY taxclass ALTER COLUMN taxclass_id SET DEFAULT nextval('taxclass_taxclass_id_seq'::regclass);
97688
 
 
97689
 
 
97690
 
--
97691
 
--
97692
 
 
97693
 
ALTER TABLE ONLY taxhist ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass);
97694
 
 
97695
 
 
97696
 
--
97697
 
--
97698
 
 
97699
 
ALTER TABLE ONLY taxpay ALTER COLUMN taxpay_id SET DEFAULT nextval('taxpay_taxpay_id_seq'::regclass);
97700
 
 
97701
 
 
97702
 
--
97703
 
--
97704
 
 
97705
 
ALTER TABLE ONLY taxrate ALTER COLUMN taxrate_id SET DEFAULT nextval('taxrate_taxrate_id_seq'::regclass);
97706
 
 
97707
 
 
97708
 
--
97709
 
--
97710
 
 
97711
 
ALTER TABLE ONLY taxreg ALTER COLUMN taxreg_id SET DEFAULT nextval('taxreg_taxreg_id_seq'::regclass);
97712
 
 
97713
 
 
97714
 
--
97715
 
--
97716
 
 
97717
 
ALTER TABLE ONLY taxtype ALTER COLUMN taxtype_id SET DEFAULT nextval('taxtype_taxtype_id_seq'::regclass);
97718
 
 
97719
 
 
97720
 
--
97721
 
--
97722
 
 
97723
 
ALTER TABLE ONLY taxzone ALTER COLUMN taxzone_id SET DEFAULT nextval('taxzone_taxzone_id_seq'::regclass);
97724
 
 
97725
 
 
97726
 
--
97727
 
--
97728
 
 
97729
 
ALTER TABLE ONLY todoitem ALTER COLUMN todoitem_id SET DEFAULT nextval('todoitem_todoitem_id_seq'::regclass);
97730
 
 
97731
 
 
97732
 
--
97733
 
--
97734
 
 
97735
 
ALTER TABLE ONLY trialbal ALTER COLUMN trialbal_id SET DEFAULT nextval('trialbal_trialbal_id_seq'::regclass);
97736
 
 
97737
 
 
97738
 
--
97739
 
--
97740
 
 
97741
 
ALTER TABLE ONLY uiform ALTER COLUMN uiform_id SET DEFAULT nextval('uiform_uiform_id_seq'::regclass);
97742
 
 
97743
 
 
97744
 
--
97745
 
--
97746
 
 
97747
 
ALTER TABLE ONLY uom ALTER COLUMN uom_id SET DEFAULT nextval('uom_uom_id_seq'::regclass);
97748
 
 
97749
 
 
97750
 
--
97751
 
--
97752
 
 
97753
 
ALTER TABLE ONLY uomconv ALTER COLUMN uomconv_id SET DEFAULT nextval('uomconv_uomconv_id_seq'::regclass);
97754
 
 
97755
 
 
97756
 
--
97757
 
--
97758
 
 
97759
 
ALTER TABLE ONLY uomtype ALTER COLUMN uomtype_id SET DEFAULT nextval('uomtype_uomtype_id_seq'::regclass);
97760
 
 
97761
 
 
97762
 
--
97763
 
--
97764
 
 
97765
 
ALTER TABLE ONLY urlinfo ALTER COLUMN url_id SET DEFAULT nextval('urlinfo_url_id_seq'::regclass);
97766
 
 
97767
 
 
97768
 
--
97769
 
--
97770
 
 
97771
 
ALTER TABLE ONLY usrgrp ALTER COLUMN usrgrp_id SET DEFAULT nextval('usrgrp_usrgrp_id_seq'::regclass);
97772
 
 
97773
 
 
97774
 
--
97775
 
--
97776
 
 
97777
 
ALTER TABLE ONLY vendtype ALTER COLUMN vendtype_id SET DEFAULT nextval('vendtype_vendtype_id_seq'::regclass);
97778
 
 
97779
 
 
97780
 
--
97781
 
--
97782
 
 
97783
 
ALTER TABLE ONLY voheadtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass);
97784
 
 
97785
 
 
97786
 
--
97787
 
--
97788
 
 
97789
 
ALTER TABLE ONLY voitemtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass);
97790
 
 
97791
 
 
97792
 
--
97793
 
--
97794
 
 
97795
 
ALTER TABLE ONLY whsezone ALTER COLUMN whsezone_id SET DEFAULT nextval('whsezone_whsezone_id_seq'::regclass);
97796
 
 
97797
 
 
97798
 
--
97799
 
--
97800
 
 
97801
 
ALTER TABLE ONLY womatlpost ALTER COLUMN womatlpost_id SET DEFAULT nextval('womatlpost_womatlpost_id_seq'::regclass);
97802
 
 
97803
 
 
97804
 
--
97805
 
--
97806
 
 
97807
 
ALTER TABLE ONLY xsltmap ALTER COLUMN xsltmap_id SET DEFAULT nextval('xsltmap_xsltmap_id_seq'::regclass);
97808
 
 
97809
 
 
97810
 
--
97811
 
--
97812
 
 
97813
 
ALTER TABLE ONLY yearperiod ALTER COLUMN yearperiod_id SET DEFAULT nextval('yearperiod_yearperiod_id_seq'::regclass);
97814
 
 
97815
 
 
97816
 
SET search_path = te, pg_catalog;
97817
 
 
97818
 
--
97819
 
--
97820
 
 
97821
 
ALTER TABLE ONLY pkgmetasql ALTER COLUMN metasql_grade SET DEFAULT 0;
97822
 
 
97823
 
 
97824
 
--
97825
 
--
97826
 
 
97827
 
ALTER TABLE ONLY pkgscript ALTER COLUMN script_enabled SET DEFAULT false;
97828
 
 
97829
 
 
97830
 
--
97831
 
--
97832
 
 
97833
 
ALTER TABLE ONLY pkguiform ALTER COLUMN uiform_enabled SET DEFAULT false;
97834
 
 
97835
 
 
97836
 
--
97837
 
--
97838
 
 
97839
 
ALTER TABLE ONLY tecustrate ALTER COLUMN tecustrate_id SET DEFAULT nextval('tecustrate_tecustrate_id_seq'::regclass);
97840
 
 
97841
 
 
97842
 
--
97843
 
--
97844
 
 
97845
 
ALTER TABLE ONLY teemp ALTER COLUMN teemp_id SET DEFAULT nextval('teemp_teemp_id_seq'::regclass);
97846
 
 
97847
 
 
97848
 
--
97849
 
--
97850
 
 
97851
 
ALTER TABLE ONLY tehead ALTER COLUMN tehead_id SET DEFAULT nextval('tehead_tehead_id_seq'::regclass);
97852
 
 
97853
 
 
97854
 
--
97855
 
--
97856
 
 
97857
 
ALTER TABLE ONLY teitem ALTER COLUMN teitem_id SET DEFAULT nextval('teitem_teitem_id_seq'::regclass);
97858
 
 
97859
 
 
97860
 
--
97861
 
--
97862
 
 
97863
 
ALTER TABLE ONLY teprj ALTER COLUMN teprj_id SET DEFAULT nextval('teprj_teprj_id_seq'::regclass);
97864
 
 
97865
 
 
97866
 
--
97867
 
--
97868
 
 
97869
 
ALTER TABLE ONLY teprjtask ALTER COLUMN teprjtask_id SET DEFAULT nextval('teprjtask_teprjtask_id_seq'::regclass);
97870
 
 
97871
 
 
97872
 
SET search_path = xtdesktop, pg_catalog;
97873
 
 
97874
 
--
97875
 
--
97876
 
 
97877
 
ALTER TABLE ONLY pkgmetasql ALTER COLUMN metasql_grade SET DEFAULT 0;
97878
 
 
97879
 
 
97880
 
--
97881
 
--
97882
 
 
97883
 
ALTER TABLE ONLY pkgscript ALTER COLUMN script_enabled SET DEFAULT false;
97884
 
 
97885
 
 
97886
 
--
97887
 
--
97888
 
 
97889
 
ALTER TABLE ONLY pkguiform ALTER COLUMN uiform_enabled SET DEFAULT false;
97890
 
 
97891
 
 
97892
 
SET search_path = fixcountry, pg_catalog;
97893
 
 
97894
 
--
97895
 
--
97896
 
 
97897
 
COPY pkgcmd (cmd_id, cmd_module, cmd_title, cmd_descrip, cmd_privname, cmd_executable, cmd_name) FROM stdin;
97898
 
\.
97899
 
 
97900
 
 
97901
 
--
97902
 
--
97903
 
 
97904
 
COPY pkgcmdarg (cmdarg_id, cmdarg_cmd_id, cmdarg_order, cmdarg_arg) FROM stdin;
97905
 
\.
97906
 
 
97907
 
 
97908
 
--
97909
 
--
97910
 
 
97911
 
COPY pkgimage (image_id, image_name, image_descrip, image_data) FROM stdin;
97912
 
\.
97913
 
 
97914
 
 
97915
 
--
97916
 
--
97917
 
 
97918
 
COPY pkgmetasql (metasql_id, metasql_group, metasql_name, metasql_notes, metasql_query, metasql_lastuser, metasql_lastupdate, metasql_grade) FROM stdin;
97919
 
449     fixcountry      strictcountrycheck      select details about countries used throughout the database that do not match country.country_name a copy of crm_strictcountrycheck to avoid problems later if someone disables or removes the fixCountry package       -- Group: fixcountry\n-- Name:  strictcountrycheck\n-- Notes: select details about countries used throughout the database\n--        that do not match country.country_name\n--        a copy of crm_strictcountrycheck to avoid problems later if\n--        someone disables or removes the fixCountry package\n<? if exists("count") ?>\nSELECT SUM(counter) AS counter FROM (\n<? endif ?>\n  SELECT <? if exists("count") ?> COUNT(*) AS counter\n         <? else ?> addr_id, 'Address' AS type, addr_number AS number, addr_country AS country, '' AS detail\n         <? endif ?>\n    FROM addr\n   WHERE addr_country != ''\n     AND addr_country NOT IN (SELECT country_name\n                                FROM country\n                               WHERE country_name IS NOT NULL)\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> cmhead_id, 'Credit Memo', cmhead_number, cmhead_billtocountry, 'Bill-To'\n         <? endif ?>\n    FROM cmhead\n   WHERE cmhead_billtocountry != ''\n     AND cmhead_billtocountry NOT IN (SELECT country_name\n                                        FROM country\n                                       WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (NOT cmhead_posted) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> cmhead_id, 'Credit Memo', cmhead_number, cmhead_billtocountry, 'Ship-To'\n         <? endif ?>\n    FROM cmhead\n    WHERE cmhead_shipto_country != ''\n      AND cmhead_shipto_country NOT IN (SELECT country_name\n                                          FROM country\n                                         WHERE country_name IS NOT NULL)\n      <? if not exists("showAll") ?> AND (NOT cmhead_posted) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> invchead_id, 'Invoice', invchead_invcnumber, invchead_billto_country, 'Bill-To'\n         <? endif ?>\n    FROM invchead\n   WHERE invchead_billto_country != ''\n     AND invchead_billto_country NOT IN (SELECT country_name\n                                           FROM country\n                                          WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (NOT invchead_posted) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> invchead_id, 'Invoice', invchead_invcnumber, invchead_shipto_country, 'Ship-To'\n         <? endif ?>\n    FROM invchead\n   WHERE invchead_shipto_country != ''\n     AND invchead_shipto_country NOT IN (SELECT country_name\n                                           FROM country\n                                          WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (NOT invchead_posted) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> quhead_id, 'Quote', CAST(quhead_number AS TEXT), quhead_billtocountry, 'Bill-To'\n         <? endif ?>\n    FROM quhead\n   WHERE quhead_billtocountry != ''\n     AND quhead_billtocountry NOT IN (SELECT country_name\n                                        FROM country\n                                       WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (quhead_expire>=CURRENT_DATE) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> quhead_id, 'Quote', CAST(quhead_number AS TEXT), quhead_shiptocountry, 'Ship-To'\n         <? endif ?>\n    FROM quhead\n   WHERE quhead_shiptocountry != ''\n     AND quhead_shiptocountry NOT IN (SELECT country_name\n                                        FROM country\n                                       WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (quhead_expire>=CURRENT_DATE) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> cohead_id, 'Sales Order', cohead_number, cohead_billtocountry, 'Bill-To'\n         <? endif ?>\n    FROM cohead\n   WHERE cohead_billtocountry != ''\n     AND cohead_billtocountry NOT IN (SELECT country_name\n                                        FROM country\n                                       WHERE country_name IS NOT NULL)\n    <? if not exists("showAll") ?>\n     AND cohead_id IN (SELECT coitem_cohead_id\n                         FROM coitem\n                        WHERE COALESCE(coitem_status, 'O')='O')\n    <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> cohead_id, 'Sales Order', cohead_number, cohead_shiptocountry, 'Ship-To'\n         <? endif ?>\n    FROM cohead\n   WHERE cohead_shiptocountry != ''\n     AND cohead_shiptocountry NOT IN (SELECT country_name\n                                       FROM country\n                                      WHERE country_name IS NOT NULL)\n    <? if not exists("showAll") ?>\n     AND cohead_id IN (SELECT coitem_cohead_id\n                         FROM coitem\n                        WHERE COALESCE(coitem_status, 'O')='O')\n    <? endif ?>\n\n<? if exists("count") ?>\n) AS dummy;\n<? endif ?>\n   \N      \N      0
97920
 
\.
97921
 
 
97922
 
 
97923
 
--
97924
 
--
97925
 
 
97926
 
COPY pkgpriv (priv_id, priv_module, priv_name, priv_descrip, priv_seq) FROM stdin;
97927
 
\.
97928
 
 
97929
 
 
97930
 
--
97931
 
--
97932
 
 
97933
 
COPY pkgreport (report_id, report_name, report_sys, report_source, report_descrip, report_grade, report_loaddate) FROM stdin;
97934
 
\.
97935
 
 
97936
 
 
97937
 
--
97938
 
--
97939
 
 
97940
 
COPY pkgscript (script_id, script_name, script_order, script_enabled, script_source, script_notes) FROM stdin;
97941
 
124     initMenu        0       t       function sFixCountries()\n{\n  try {\n  var newdlg = toolbox.openWindow("fixCountries", 0, Qt.Window, Qt.NonModal);\n  } catch(e) { print("sFixCountries exception: " + e); }\n}\n\nvar _crmutilsmenu = mainwindow.findChild("menu.crm.utilities");\nvar fixCountriesAction = _crmutilsmenu.addAction(\n                  qsTr("Fix Countries before setting Strict Countries option"));\nfixCountriesAction.enabled = privileges.value("MaintainAddresses")   &&\n                             privileges.value("MaintainCreditMemos") &&\n                             privileges.value("MaintainMiscInvoices")&&\n                             privileges.value("MaintainSalesOrders") &&\n                             privileges.value("MaintainQuotes");\n\nfixCountriesAction.triggered.connect(sFixCountries);\n        
97942
 
125     fixCountries    0       t       var _addCountry = mywindow.findChild("_addCountry");\nvar _edit       = mywindow.findChild("_edit");\nvar _fixAbbr    = mywindow.findChild("_fixAbbr");\nvar _fixBulk    = mywindow.findChild("_fixBulk");\nvar _fixCase    = mywindow.findChild("_fixCase");\nvar _list       = mywindow.findChild("_list");\nvar _query      = mywindow.findChild("_query");\nvar _showAll    = mywindow.findChild("_showAll");\n\n_list.addColumn("Record Type", -1, Qt.AlignLeft, true, "type");\n_list.addColumn("Number",      -1, Qt.AlignLeft, true, "number");\n_list.addColumn("Country",     -1, Qt.AlignLeft, true, "country");\n_list.addColumn("Details",     -1, Qt.AlignLeft, true, "detail");\n\nfunction sAddCountry()\n{\n  try {\n  var params = new Object;;\n  params.mode = "new";\n\n  var newdlg = toolbox.openWindow("country", mywindow, Qt.Dialog, Qt.WindowModal);\n  toolbox.lastWindow().set(params);\n  newdlg.exec();\n  } catch (e) { print("sAddCountry exception: " + e); }\n}\n\nfunction openEditorWindow(pwindow, pidname, pparent)\n{\n  try {\n  var params = new Object;\n  params[pidname] = _list.id();\n  if (pidname == 'quhead_id')\n    params.mode = "editQuote";\n  else\n    params.mode = "edit";\n\n  var newdlg = toolbox.openWindow(pwindow, pparent, Qt.Dialog, Qt.WindowModal);\n  toolbox.lastWindow().set(params);\n  newdlg.exec();\n  } catch(e) { print("openEditorWindow exception (" + e.lineNumber + "): " + e); }\n}\n\nfunction sEdit()\n{\n  try {\n  var currentItem = _list.currentItem();\n\n  switch (currentItem.text(0))\n  {\n    case 'Address':\n      openEditorWindow("address", "addr_id", mywindow);\n      break;\n\n    case 'Credit Memo':\n      openEditorWindow("creditMemo", "cmhead_id", 0);\n      break;\n\n    case 'Invoice':\n      openEditorWindow("invoice", "invchead_id", mywindow);\n      break;\n\n    case 'Quote':\n      openEditorWindow("salesOrder", "quhead_id", 0);\n      break;\n\n    case 'Sales Order':\n      openEditorWindow("salesOrder", "sohead_id", 0);\n      break;\n  }\n  sFillList();\n  } catch (e) { print("sEdit() exception: " + e); }\n}\n\nfunction sFixBulk()\n{\n  print("sFixBulk() entered");\n  try {\n    var params = new Object;\n    if (_showAll.checked)\n      params.showAll = true;\n\n    var newdlg = toolbox.openWindow("bulkFixCountry", mywindow,\n                                    Qt.WindowModal, Qt.Dialog);\n    toolbox.lastWindow().set(params);\n\n    sFillList();\n  } catch (e) { print("sFixBulk() exception: " + e); }\n}\n\nfunction sFixCase()\n{\n  try {\n  if (QMessageBox.question(mywindow, qsTr("Are you sure?"),\n                           qsTr("<p>Are you sure that you want to change all "\n                              + "countries that appear to be correct except "\n                              + "for upper- and lower-case differences in a "\n                              + "batch?<p>(This change will obey the status "\n                              + "of the 'Show closed records' check box."),\n                           QMessageBox.Yes, QMessageBox.No) == QMessageBox.No)\n    return;\n\n  var params = new Object;\n  if (_showAll.checked)\n    params.showAll = true;\n\n  var qry = toolbox.executeQuery(\n      "UPDATE addr SET addr_country = country_name"\n    + "  FROM country "\n    + " WHERE addr_country != ''"\n    + "   AND UPPER(addr_country) = UPPER(country_name)"\n    + "   AND addr_country != country_name;", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Address: " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE cmhead SET cmhead_billtocountry = country_name"\n    + "  FROM country "\n    + " WHERE cmhead_billtocountry != ''"\n    + "   AND UPPER(cmhead_billtocountry) = UPPER(country_name)"\n    + "   AND cmhead_billtocountry != country_name"\n    + '  <? if not exists("showAll") ?>'\n    + "   AND NOT cmhead_posted"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Credit Memo (Bill-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE cmhead SET cmhead_shipto_country = country_name"\n    + "  FROM country "\n    + " WHERE cmhead_shipto_country != ''"\n    + "   AND UPPER(cmhead_shipto_country) = UPPER(country_name)"\n    + "   AND cmhead_shipto_country != country_name"\n    + '  <? if not exists("showAll") ?>'\n    + "   AND NOT cmhead_posted"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Credit Memo (Ship-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE invchead SET invchead_billto_country = country_name"\n    + "  FROM country "\n    + " WHERE invchead_billto_country != ''"\n    + "   AND UPPER(invchead_billto_country) = UPPER(country_name)"\n    + "   AND invchead_billto_country != country_name"\n    + '  <? if not exists("showAll") ?>'\n    + "   AND NOT invchead_posted"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Invoice (Bill-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE invchead SET invchead_shipto_country = country_name"\n    + "  FROM country "\n    + " WHERE invchead_shipto_country != ''"\n    + "   AND UPPER(invchead_shipto_country) = UPPER(country_name)"\n    + "   AND invchead_shipto_country != country_name"\n    + '  <? if not exists("showAll") ?>'\n    + "   AND NOT invchead_posted"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Invoice (Ship-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE quhead SET quhead_billtocountry = country_name"\n    + "  FROM country"\n    + " WHERE quhead_billtocountry != ''"\n    + "   AND UPPER(quhead_billtocountry) = UPPER(country_name)"\n    + "   AND quhead_billtocountry != country_name"\n    + '  <? if not exists("showAll") ?>'\n    + "   AND quhead_expire >= CURRENT_DATE"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Quote (Bill-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE quhead SET quhead_shiptocountry = country_name"\n    + "  FROM country"\n    + " WHERE quhead_shiptocountry != ''"\n    + "   AND UPPER(quhead_shiptocountry) = UPPER(country_name)"\n    + "   AND quhead_shiptocountry != country_name"\n    + '  <? if not exists("showAll") ?>'\n    + "   AND quhead_expire >= CURRENT_DATE"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Quote (Ship-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE cohead SET cohead_billtocountry = country_name"\n    + '  FROM country <? if not exists("showAll") ?>, coitem<? endif ?>'\n    + " WHERE cohead_billtocountry != ''"\n    + "   AND UPPER(cohead_billtocountry) = UPPER(country_name)"\n    + "   AND cohead_billtocountry != country_name"\n    + '   <? if not exists("showAll") ?>'\n    + "   AND cohead_id=coitem_cohead_id AND COALESCE(coitem_status, 'O')='O'"\n    + "   <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Sales Order (Bill-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE cohead SET cohead_shiptocountry = country_name"\n    + '  FROM country <? if not exists("showAll") ?>, coitem<? endif ?>'\n    + " WHERE cohead_shiptocountry != ''"\n    + "   AND UPPER(cohead_shiptocountry) = UPPER(country_name)"\n    + "   AND cohead_shiptocountry != country_name"\n    + '   <? if not exists("showAll") ?>'\n    + "   AND cohead_id=coitem_cohead_id AND COALESCE(coitem_status, 'O')='O'"\n    + "   <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Sales Order (Ship-To): " + qry.lastError().text);\n\n  } catch (e) { QMessageBox.critical(mywindow, "sFixCase() exception", e); }\n\n  sFillList();\n}\n\nfunction sFixAbbr()\n{\n  try {\n  if (QMessageBox.question(mywindow, qsTr("Are you sure?"),\n                           qsTr("<p>Are you sure that you want to replace all "\n                              + "country abbreviations to the corresponding "\n                              + "full country names?<p>(This change will obey "\n                              + "the status of the 'Show closed records' "\n                              + "check box."),\n                       QMessageBox.Yes, QMessageBox.No) == QMessageBox.No)\n    return;\n\n  var params = new Object;\n  if (_showAll.checked)\n    params.showAll = true;\n\n  var qry = toolbox.executeQuery(\n      "UPDATE addr SET addr_country = country_name"\n    + "  FROM country "\n    + " WHERE addr_country != ''"\n    + "   AND UPPER(addr_country) = UPPER(country_abbr);", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Address: " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE cmhead SET cmhead_billtocountry = country_name"\n    + "  FROM country "\n    + " WHERE cmhead_billtocountry != ''"\n    + "   AND UPPER(cmhead_billtocountry) = UPPER(country_abbr)"\n    + '  <? if not exists("showAll") ?>'\n    + "   AND NOT cmhead_posted"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Credit Memo (Bill-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE cmhead SET cmhead_shipto_country = country_name"\n    + "  FROM country "\n    + " WHERE cmhead_shipto_country != ''"\n    + "   AND UPPER(cmhead_shipto_country) = UPPER(country_abbr)"\n    + '  <? if not exists("showAll") ?>'\n    + "   AND NOT cmhead_posted"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Credit Memo (Ship-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE invchead SET invchead_billto_country = country_name"\n    + "  FROM country "\n    + " WHERE invchead_billto_country != ''"\n    + "   AND UPPER(invchead_billto_country) = UPPER(country_abbr)"\n    + '  <? if not exists("showAll") ?>'\n    + "   AND NOT invchead_posted"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Invoice (Bill-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE invchead SET invchead_shipto_country = country_name"\n    + "  FROM country "\n    + " WHERE invchead_shipto_country != ''"\n    + "   AND UPPER(invchead_shipto_country) = UPPER(country_abbr)"\n    + '  <? if not exists("showAll") ?>'\n    + "   AND NOT invchead_posted"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Invoice (Ship-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE quhead SET quhead_billtocountry = country_name"\n    + "  FROM country"\n    + " WHERE quhead_billtocountry != ''"\n    + "   AND UPPER(quhead_billtocountry) = UPPER(country_abbr)"\n    + '  <? if not exists("showAll") ?>'\n    + "   AND quhead_expire >= CURRENT_DATE"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Quote (Bill-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE quhead SET quhead_shiptocountry = country_name"\n    + "  FROM country"\n    + " WHERE quhead_shiptocountry != ''"\n    + "   AND UPPER(quhead_shiptocountry) = UPPER(country_abbr)"\n    + '  <? if not exists("showAll") ?>'\n    + "   AND quhead_expire >= CURRENT_DATE"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Quote (Ship-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE cohead SET cohead_billtocountry = country_name"\n    + '  FROM country <? if not exists("showAll") ?>, coitem<? endif ?>'\n    + " WHERE cohead_billtocountry != ''"\n    + "   AND UPPER(cohead_billtocountry) = UPPER(country_abbr)"\n    + '   <? if not exists("showAll") ?>'\n    + "   AND cohead_id=coitem_cohead_id AND COALESCE(coitem_status, 'O')='O'"\n    + "   <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Sales Order (Bill-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      "UPDATE cohead SET cohead_shiptocountry = country_name"\n    + '  FROM country <? if not exists("showAll") ?>, coitem<? endif ?>'\n    + " WHERE cohead_shiptocountry != ''"\n    + "   AND UPPER(cohead_shiptocountry) = UPPER(country_abbr)"\n    + '   <? if not exists("showAll") ?>'\n    + "   AND cohead_id=coitem_cohead_id AND COALESCE(coitem_status, 'O')='O'"\n    + "   <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Sales Order (Ship-To): " + qry.lastError().text);\n\n  } catch (e)\n  {\n    QMessageBox.critical(mywindow, "sFixAbbr() exception", e);\n  }\n  sFillList();\n}\n\nfunction sFillList()\n{\n  try {\n  var params = new Object;\n  if (_showAll.checked)\n    params.showAll = true;\n\n  var qry = toolbox.executeDbQuery('fixcountry', 'strictcountrycheck', params);\n  _list.populate(qry);\n  if (qry.lastError().type != 0)\n  {\n    QMessageBox.critical(mywindow, qsTr("Database Error"),\n                         qry.lastError().text);\n    return;\n  }\n  } catch (e) { print("sFillList exception: " + e); }\n}\n\n_addCountry.clicked.connect(sAddCountry);\n_edit.clicked.connect(sEdit);\n_fixAbbr.clicked.connect(sFixAbbr);\n_fixBulk.clicked.connect(sFixBulk);\n_fixCase.clicked.connect(sFixCase);\n_query.clicked.connect(sFillList);\n_showAll.toggled.connect(sFillList);\n\nsFillList();\n\nif (QMessageBox.question(mywindow, qsTr("Backed Up?"),\n                         qsTr("<p>Have you backed up your database? "\n                            + "You really should back up your database "\n                            + "before running this utility."),\n                         QMessageBox.Yes, QMessageBox.No) == QMessageBox.No)\n  mywindow.close()\n\n  
97943
 
126     bulkFixCountry  0       t       var _buttons    = mywindow.findChild("_buttons");\nvar _oldCountry = mywindow.findChild("_oldCountry");\nvar _newCountry = mywindow.findChild("_newCountry");\nvar _params;\n\nfunction set(params)\n{\n  _params = params;\n  var qry = toolbox.executeQuery(\n      "SELECT MIN(id), country, country AS code "\n    + "  FROM ("\n    + "  SELECT addr_id AS id, addr_country AS country"\n    + "    FROM addr"\n    + "   WHERE addr_country != ''"\n    + "     AND addr_country NOT IN (SELECT country_name"\n    + "                                FROM country"\n    + "                               WHERE country_name IS NOT NULL)"\n    + "  UNION ALL"\n    + "  SELECT cmhead_id, cmhead_billtocountry"\n    + "    FROM cmhead"\n    + "   WHERE cmhead_billtocountry != ''"\n    + "     AND cmhead_billtocountry NOT IN (SELECT country_name"\n    + "                                        FROM country"\n    + "                                       WHERE country_name IS NOT NULL)"\n    + '     <? if not exists("showAll") ?> AND (NOT cmhead_posted) <? endif ?>'\n    + "  UNION ALL"\n    + "  SELECT cmhead_id, cmhead_shipto_country"\n    + "    FROM cmhead"\n    + "    WHERE cmhead_shipto_country != ''"\n    + "      AND cmhead_shipto_country NOT IN (SELECT country_name"\n    + "                                          FROM country"\n    + "                                         WHERE country_name IS NOT NULL)"\n    + '      <? if not exists("showAll") ?> AND (NOT cmhead_posted) <? endif ?>'\n    + "  UNION ALL"\n    + "  SELECT invchead_id, invchead_billto_country"\n    + "    FROM invchead"\n    + "   WHERE invchead_billto_country != ''"\n    + "     AND invchead_billto_country NOT IN (SELECT country_name"\n    + "                                           FROM country"\n    + "                                          WHERE country_name IS NOT NULL)"\n    + '     <? if not exists("showAll") ?> AND (NOT invchead_posted) <? endif ?>'\n    + "  UNION ALL"\n    + "  SELECT invchead_id, invchead_shipto_country"\n    + "    FROM invchead"\n    + "   WHERE invchead_shipto_country != ''"\n    + "     AND invchead_shipto_country NOT IN (SELECT country_name"\n    + "                                           FROM country"\n    + "                                          WHERE country_name IS NOT NULL)"\n    + '     <? if not exists("showAll") ?> AND (NOT invchead_posted) <? endif ?>'\n    + "  UNION ALL"\n    + "  SELECT quhead_id, quhead_billtocountry"\n    + "    FROM quhead"\n    + "   WHERE quhead_billtocountry != ''"\n    + "     AND quhead_billtocountry NOT IN (SELECT country_name"\n    + "                                        FROM country"\n    + "                                       WHERE country_name IS NOT NULL)"\n    + '     <? if not exists("showAll") ?> AND (quhead_expire>=CURRENT_DATE) <? endif ?>'\n    + "  UNION ALL"\n    + "  SELECT quhead_id, quhead_shiptocountry"\n    + "    FROM quhead"\n    + "   WHERE quhead_shiptocountry != ''"\n    + "     AND quhead_shiptocountry NOT IN (SELECT country_name"\n    + "                                        FROM country"\n    + "                                       WHERE country_name IS NOT NULL)"\n    + '     <? if not exists("showAll") ?> AND (quhead_expire>=CURRENT_DATE) <? endif ?>'\n    + "  UNION ALL"\n    + "  SELECT cohead_id, cohead_billtocountry"\n    + "    FROM cohead"\n    + "   WHERE cohead_billtocountry != ''"\n    + "     AND cohead_billtocountry NOT IN (SELECT country_name"\n    + "                                        FROM country"\n    + "                                       WHERE country_name IS NOT NULL)"\n    + '    <? if not exists("showAll") ?>'\n    + "     AND cohead_id IN (SELECT coitem_cohead_id"\n    + "                         FROM coitem"\n    + "                        WHERE COALESCE(coitem_status, 'O')='O')"\n    + '    <? endif ?>'\n    + "  UNION ALL"\n    + "  SELECT cohead_id, cohead_shiptocountry"\n    + "    FROM cohead"\n    + "   WHERE cohead_shiptocountry != ''"\n    + "     AND cohead_shiptocountry NOT IN (SELECT country_name"\n    + "                                       FROM country"\n    + "                                      WHERE country_name IS NOT NULL)"\n    + '    <? if not exists("showAll") ?>'\n    + "     AND cohead_id IN (SELECT coitem_cohead_id"\n    + "                         FROM coitem"\n    + "                        WHERE COALESCE(coitem_status, 'O')='O')"\n    + '    <? endif ?>'\n    + ") AS dummy "\n    + "GROUP BY country "\n    + "ORDER BY country;",\n\n                                 params);\n  _oldCountry.populate(qry);\n  if (qry.lastError().type != 0)\n    toolbox.messageBox("warning", mywindow, qsTr("Database Error"),\n                       qry.lastError().text);\n}\n\nfunction sSave()\n{\n  try {\n  var params = _params;\n  params.oldCountry = _oldCountry.currentText;\n  params.newCountry = _newCountry.currentText;\n\n  var qry = toolbox.executeQuery(\n      'UPDATE addr SET addr_country = <? value("newCountry") ?>'\n    + ' WHERE addr_country = <? value("oldCountry") ?>;', params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Address: " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      'UPDATE cmhead SET cmhead_billtocountry = <? value("newCountry") ?>'\n    + ' WHERE cmhead_billtocountry = <? value("oldCountry") ?>'\n    + '  <? if not exists("showAll") ?>'\n    + "   AND NOT cmhead_posted"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Credit Memo (Bill-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      'UPDATE cmhead SET cmhead_shipto_country = <? value("newCountry") ?>'\n    + ' WHERE cmhead_shipto_country = <? value("oldCountry") ?>'\n    + '  <? if not exists("showAll") ?>'\n    + "   AND NOT cmhead_posted"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Credit Memo (Ship-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      'UPDATE invchead SET invchead_billto_country = <? value("newCountry") ?>'\n    + ' WHERE invchead_billto_country = <? value("oldCountry") ?>'\n    + '  <? if not exists("showAll") ?>'\n    + "   AND NOT invchead_posted"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Invoice (Bill-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      'UPDATE invchead SET invchead_shipto_country = <? value("newCountry") ?>'\n    + ' WHERE invchead_shipto_country = <? value("oldCountry") ?>'\n    + '  <? if not exists("showAll") ?>'\n    + "   AND NOT invchead_posted"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Invoice (Ship-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      'UPDATE quhead SET quhead_billtocountry = <? value("newCountry") ?>'\n    + ' WHERE quhead_billtocountry = <? value("oldCountry") ?>'\n    + '  <? if not exists("showAll") ?>'\n    + "   AND quhead_expire >= CURRENT_DATE"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Quote (Bill-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      'UPDATE quhead SET quhead_shiptocountry = <? value("newCountry") ?>'\n    + ' WHERE quhead_shiptocountry = <? value("oldCountry") ?>'\n    + '  <? if not exists("showAll") ?>'\n    + "   AND quhead_expire >= CURRENT_DATE"\n    + "  <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Quote (Ship-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      'UPDATE cohead SET cohead_billtocountry = <? value("newCountry") ?>'\n    + ' WHERE cohead_billtocountry = <? value("oldCountry") ?>'\n    + '   <? if not exists("showAll") ?>'\n    + "   AND cohead_id IN (SELECT coitem_cohead_id"\n    + "                     FROM coitem"\n    + "                     WHERE COALESCE(coitem_status, 'O')='O')"\n    + "   <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Sales Order (Bill-To): " + qry.lastError().text);\n\n  qry = toolbox.executeQuery(\n      'UPDATE cohead SET cohead_shiptocountry = <? value("newCountry") ?>'\n    + ' WHERE cohead_shiptocountry = <? value("oldCountry") ?>'\n    + '   <? if not exists("showAll") ?>'\n    + "   AND cohead_id IN (SELECT coitem_cohead_id"\n    + "                     FROM coitem"\n    + "                     WHERE COALESCE(coitem_status, 'O')='O')"\n    + "   <? endif ?>", params);\n  if (qry.lastError().type != 0)\n    throw new Error("Error updating Sales Order (Ship-To): " + qry.lastError().text);\n\n  }\n  catch (e)\n  {\n     toolbox.messageBox("critical", mywindow,\n                        "bulkFixCountry::sSave() exception", e);\n\n  }\n  mywindow.close();\n}\n\n_buttons.accepted.connect(sSave);\n_buttons.rejected.connect(mywindow, "close()");\n     
97944
 
\.
97945
 
 
97946
 
 
97947
 
--
97948
 
--
97949
 
 
97950
 
COPY pkguiform (uiform_id, uiform_name, uiform_order, uiform_enabled, uiform_source, uiform_notes) FROM stdin;
97951
 
58      fixCountries    0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <class>fixCountries</class>\n <widget class="QWidget" name="fixCountries">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>800</width>\n    <height>600</height>\n   </rect>\n  </property>\n  <property name="maximumSize">\n   <size>\n    <width>1000</width>\n    <height>16777215</height>\n   </size>\n  </property>\n  <property name="windowTitle">\n   <string>fixCountries</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout">\n   <item row="1" column="1">\n    <layout class="QVBoxLayout" name="verticalLayout">\n     <item>\n      <widget class="QPushButton" name="_query">\n       <property name="text">\n        <string>Query</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <spacer name="verticalSpacer">\n       <property name="orientation">\n        <enum>Qt::Vertical</enum>\n       </property>\n       <property name="sizeType">\n        <enum>QSizePolicy::Fixed</enum>\n       </property>\n       <property name="sizeHint" stdset="0">\n        <size>\n         <width>20</width>\n         <height>15</height>\n        </size>\n       </property>\n      </spacer>\n     </item>\n     <item>\n      <widget class="QPushButton" name="_fixCase">\n       <property name="text">\n        <string>Fix Case Differences</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <widget class="QPushButton" name="_fixAbbr">\n       <property name="text">\n        <string>Replace Abbreviations</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <widget class="QPushButton" name="_fixBulk">\n       <property name="text">\n        <string>Bulk Replace</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <spacer name="verticalSpacer_3">\n       <property name="orientation">\n        <enum>Qt::Vertical</enum>\n       </property>\n       <property name="sizeType">\n        <enum>QSizePolicy::Fixed</enum>\n       </property>\n       <property name="sizeHint" stdset="0">\n        <size>\n         <width>20</width>\n         <height>15</height>\n        </size>\n       </property>\n      </spacer>\n     </item>\n     <item>\n      <widget class="QPushButton" name="_edit">\n       <property name="enabled">\n        <bool>false</bool>\n       </property>\n       <property name="text">\n        <string>Edit Selection</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <widget class="QPushButton" name="_addCountry">\n       <property name="text">\n        <string>Add Country</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <spacer name="verticalSpacer_2">\n       <property name="orientation">\n        <enum>Qt::Vertical</enum>\n       </property>\n       <property name="sizeHint" stdset="0">\n        <size>\n         <width>20</width>\n         <height>40</height>\n        </size>\n       </property>\n      </spacer>\n     </item>\n    </layout>\n   </item>\n   <item row="1" column="0">\n    <widget class="XTreeWidget" name="_list">\n     <property name="sizePolicy">\n      <sizepolicy hsizetype="Expanding" vsizetype="Expanding">\n       <horstretch>0</horstretch>\n       <verstretch>3</verstretch>\n      </sizepolicy>\n     </property>\n    </widget>\n   </item>\n   <item row="2" column="0">\n    <widget class="XCheckBox" name="_showAll">\n     <property name="text">\n      <string>Show closed records</string>\n     </property>\n     <property name="forgetful">\n      <bool>true</bool>\n     </property>\n    </widget>\n   </item>\n   <item row="0" column="0" colspan="2">\n    <widget class="QLabel" name="label">\n     <property name="text">\n      <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;\n&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;\np, li { white-space: pre-wrap; }\n&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;You must fix the countries in the following records before turning on Strict Country Checking (System &amp;gt; Configure Modules &amp;gt; CRM...).&lt;/p&gt;\n&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Here is a short description of your options (assume the &lt;span style=&quot; font-style:italic;&quot;&gt;country&lt;/span&gt; table has a country named 'Homeland' with the abbreviation 'HL'):&lt;/p&gt;\n&lt;ul style=&quot;-qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Query&lt;/span&gt; will requery the database for records with invalid countries.&lt;/li&gt;\n&lt;li style=&quot; font-weight:600;&quot; style=&quot; margin-top:1px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Fix Case Differences&lt;span style=&quot; font-weight:400;&quot;&gt; will change all occurrences of 'HOMELAND' or 'HomeLand' to 'Homeland'.&lt;/span&gt;&lt;/li&gt;\n&lt;li style=&quot; margin-top:1px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Replace Abbreviations&lt;/span&gt; will change all occurrences of 'HL' to 'Homeland'.&lt;/li&gt;\n&lt;li style=&quot; margin-top:1px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Bulk Replace&lt;/span&gt; will replace all occurrences of an invalid country that you choose with a valid country that you choose.&lt;/li&gt;\n&lt;li style=&quot; margin-top:1px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Edit Selection&lt;/span&gt; will open the selected record for you to fix. If a changed address remains on the list, delete duplicates with CRM &amp;gt; Address &amp;gt; List....&lt;/li&gt;\n&lt;li style=&quot; margin-top:1px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Add Country&lt;/span&gt; is for the rare case where you must add a new country. Try not to use this.&lt;/li&gt;\n&lt;li style=&quot; margin-top:1px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Show closed records&lt;/span&gt; will show historical data, such as closed sales orders and posted credit memos &amp;amp; invoices. These will continue to print properly if you don't fix them, but you will have to change the country if you edit and save them with Strict Country Checking turned on.&lt;/li&gt;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>\n     </property>\n     <property name="textFormat">\n      <enum>Qt::RichText</enum>\n     </property>\n     <property name="wordWrap">\n      <bool>true</bool>\n     </property>\n    </widget>\n   </item>\n  </layout>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>XCheckBox</class>\n   <extends>QCheckBox</extends>\n   <header>xcheckbox.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>xtreewidget.h</header>\n  </customwidget>\n </customwidgets>\n <tabstops>\n  <tabstop>_list</tabstop>\n  <tabstop>_showAll</tabstop>\n  <tabstop>_query</tabstop>\n  <tabstop>_fixCase</tabstop>\n  <tabstop>_fixAbbr</tabstop>\n  <tabstop>_edit</tabstop>\n  <tabstop>_addCountry</tabstop>\n </tabstops>\n <resources/>\n <connections>\n  <connection>\n   <sender>_list</sender>\n   <signal>valid(bool)</signal>\n   <receiver>_edit</receiver>\n   <slot>setEnabled(bool)</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>551</x>\n     <y>512</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>616</x>\n     <y>503</y>\n    </hint>\n   </hints>\n  </connection>\n </connections>\n</ui>\n       
97952
 
59      bulkFixCountry  0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <class>bulkFixCountry</class>\n <widget class="QWidget" name="bulkFixCountry">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>427</width>\n    <height>162</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Bulk Fix Invalid Country</string>\n  </property>\n  <layout class="QHBoxLayout" name="horizontalLayout">\n   <item>\n    <layout class="QFormLayout" name="formLayout">\n     <item row="0" column="0">\n      <widget class="QLabel" name="_oldCountryLit">\n       <property name="text">\n        <string>Replace all instances of this:</string>\n       </property>\n       <property name="buddy">\n        <cstring>_oldCountry</cstring>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="0">\n      <widget class="QLabel" name="_newCountryLit">\n       <property name="text">\n        <string>with this country:</string>\n       </property>\n       <property name="buddy">\n        <cstring>_newCountry</cstring>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="1">\n      <widget class="XComboBox" name="_newCountry">\n       <property name="allowNull">\n        <bool>true</bool>\n       </property>\n       <property name="type">\n        <enum>XComboBox::Countries</enum>\n       </property>\n      </widget>\n     </item>\n     <item row="0" column="1">\n      <widget class="XComboBox" name="_oldCountry"/>\n     </item>\n    </layout>\n   </item>\n   <item>\n    <widget class="QDialogButtonBox" name="_buttons">\n     <property name="orientation">\n      <enum>Qt::Vertical</enum>\n     </property>\n     <property name="standardButtons">\n      <set>QDialogButtonBox::Cancel|QDialogButtonBox::SaveAll</set>\n     </property>\n     <property name="centerButtons">\n      <bool>false</bool>\n     </property>\n    </widget>\n   </item>\n  </layout>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>XComboBox</class>\n   <extends>QComboBox</extends>\n   <header>xcombobox.h</header>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections/>\n</ui>\n      
97953
 
\.
97954
 
 
97955
 
 
97956
 
SET search_path = public, pg_catalog;
97957
 
 
97958
 
--
97959
 
--
97960
 
 
97961
 
COPY acalitem (acalitem_id, acalitem_calhead_id, acalitem_periodstart, acalitem_periodlength, acalitem_name) FROM stdin;
97962
 
\.
97963
 
 
97964
 
 
97965
 
--
97966
 
--
97967
 
 
97968
 
COPY accnt (accnt_id, accnt_number, accnt_descrip, accnt_comments, accnt_profit, accnt_sub, accnt_type, accnt_extref, accnt_company, accnt_forwardupdate, accnt_subaccnttype_code, accnt_curr_id, accnt_active, accnt_name) FROM stdin;
97969
 
\.
97970
 
 
97971
 
 
97972
 
--
97973
 
--
97974
 
 
97975
 
SELECT pg_catalog.setval('accnt_accnt_id_seq', 83, true);
97976
 
 
97977
 
 
97978
 
--
97979
 
--
97980
 
 
97981
 
COPY addr (addr_id, addr_active, addr_line1, addr_line2, addr_line3, addr_city, addr_state, addr_postalcode, addr_country, addr_notes, addr_number) FROM stdin;
97982
 
\.
97983
 
 
97984
 
 
97985
 
--
97986
 
--
97987
 
 
97988
 
SELECT pg_catalog.setval('addr_addr_id_seq', 1, false);
97989
 
 
97990
 
 
97991
 
--
97992
 
--
97993
 
 
97994
 
COPY alarm (alarm_id, alarm_number, alarm_event, alarm_email, alarm_sysmsg, alarm_trigger, alarm_time, alarm_time_offset, alarm_time_qualifier, alarm_creator, alarm_event_recipient, alarm_email_recipient, alarm_sysmsg_recipient, alarm_source, alarm_source_id) FROM stdin;
97995
 
\.
97996
 
 
97997
 
 
97998
 
--
97999
 
--
98000
 
 
98001
 
SELECT pg_catalog.setval('alarm_alarm_id_seq', 1, false);
98002
 
 
98003
 
 
98004
 
--
98005
 
--
98006
 
 
98007
 
COPY apaccnt (apaccnt_id, apaccnt_vendtype_id, apaccnt_vendtype, apaccnt_ap_accnt_id, apaccnt_prepaid_accnt_id, apaccnt_discount_accnt_id) FROM stdin;
98008
 
\.
98009
 
 
98010
 
 
98011
 
--
98012
 
--
98013
 
 
98014
 
SELECT pg_catalog.setval('apaccnt_apaccnt_id_seq', 19, true);
98015
 
 
98016
 
 
98017
 
--
98018
 
--
98019
 
 
98020
 
COPY apapply (apapply_id, apapply_vend_id, apapply_postdate, apapply_username, apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber, apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber, apapply_journalnumber, apapply_amount, apapply_curr_id, apapply_target_paid, apapply_checkhead_id) FROM stdin;
98021
 
\.
98022
 
 
98023
 
 
98024
 
--
98025
 
--
98026
 
 
98027
 
SELECT pg_catalog.setval('apapply_apapply_id_seq', 1, false);
98028
 
 
98029
 
 
98030
 
--
98031
 
--
98032
 
 
98033
 
COPY apcreditapply (apcreditapply_id, apcreditapply_source_apopen_id, apcreditapply_target_apopen_id, apcreditapply_amount, apcreditapply_curr_id) FROM stdin;
98034
 
\.
98035
 
 
98036
 
 
98037
 
--
98038
 
--
98039
 
 
98040
 
SELECT pg_catalog.setval('apcreditapply_apcreditapply_id_seq', 1, false);
98041
 
 
98042
 
 
98043
 
--
98044
 
--
98045
 
 
98046
 
COPY apopen (apopen_id, apopen_docdate, apopen_duedate, apopen_terms_id, apopen_vend_id, apopen_doctype, apopen_docnumber, apopen_amount, apopen_notes, apopen_posted, apopen_reference, apopen_invcnumber, apopen_ponumber, apopen_journalnumber, apopen_paid, apopen_open, apopen_username, apopen_discount, apopen_accnt_id, apopen_curr_id, apopen_closedate, apopen_distdate, apopen_void, apopen_curr_rate, apopen_discountable_amount, apopen_status) FROM stdin;
98047
 
\.
98048
 
 
98049
 
 
98050
 
--
98051
 
--
98052
 
 
98053
 
SELECT pg_catalog.setval('apopen_apopen_id_seq', 70, true);
98054
 
 
98055
 
 
98056
 
--
98057
 
--
98058
 
 
98059
 
COPY apopentax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin;
98060
 
\.
98061
 
 
98062
 
 
98063
 
--
98064
 
--
98065
 
 
98066
 
COPY apselect (apselect_id, apselect_apopen_id, apselect_amount, apselect_bankaccnt_id, apselect_curr_id, apselect_date, apselect_discount) FROM stdin;
98067
 
\.
98068
 
 
98069
 
 
98070
 
--
98071
 
--
98072
 
 
98073
 
SELECT pg_catalog.setval('apselect_apselect_id_seq', 501, true);
98074
 
 
98075
 
 
98076
 
--
98077
 
--
98078
 
 
98079
 
COPY araccnt (araccnt_id, araccnt_custtype_id, araccnt_custtype, araccnt_freight_accnt_id, araccnt_ar_accnt_id, araccnt_prepaid_accnt_id, araccnt_deferred_accnt_id, araccnt_discount_accnt_id) FROM stdin;
98080
 
\.
98081
 
 
98082
 
 
98083
 
--
98084
 
--
98085
 
 
98086
 
SELECT pg_catalog.setval('araccnt_araccnt_id_seq', 37, true);
98087
 
 
98088
 
 
98089
 
--
98090
 
--
98091
 
 
98092
 
COPY arapply (arapply_id, arapply_postdate, arapply_cust_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_applied, arapply_closed, arapply_journalnumber, arapply_source_aropen_id, arapply_target_aropen_id, arapply_username, arapply_curr_id, arapply_distdate, arapply_target_paid, arapply_reftype, arapply_ref_id) FROM stdin;
98093
 
\.
98094
 
 
98095
 
 
98096
 
--
98097
 
--
98098
 
 
98099
 
SELECT pg_catalog.setval('arapply_arapply_id_seq', 1, false);
98100
 
 
98101
 
 
98102
 
--
98103
 
--
98104
 
 
98105
 
COPY arcreditapply (arcreditapply_id, arcreditapply_source_aropen_id, arcreditapply_target_aropen_id, arcreditapply_amount, arcreditapply_curr_id, arcreditapply_reftype, arcreditapply_ref_id) FROM stdin;
98106
 
\.
98107
 
 
98108
 
 
98109
 
--
98110
 
--
98111
 
 
98112
 
SELECT pg_catalog.setval('arcreditapply_arcreditapply_id_seq', 1, false);
98113
 
 
98114
 
 
98115
 
--
98116
 
--
98117
 
 
98118
 
COPY aropen (aropen_id, aropen_docdate, aropen_duedate, aropen_terms_id, aropen_cust_id, aropen_doctype, aropen_docnumber, aropen_applyto, aropen_ponumber, aropen_amount, aropen_notes, aropen_posted, aropen_salesrep_id, aropen_commission_due, aropen_commission_paid, aropen_ordernumber, aropen_cobmisc_id, aropen_journalnumber, aropen_paid, aropen_open, aropen_username, aropen_rsncode_id, aropen_salescat_id, aropen_accnt_id, aropen_curr_id, aropen_closedate, aropen_distdate, aropen_curr_rate, aropen_discount, aropen_fincharg_date, aropen_fincharg_amount) FROM stdin;
98119
 
\.
98120
 
 
98121
 
 
98122
 
--
98123
 
--
98124
 
 
98125
 
SELECT pg_catalog.setval('aropen_aropen_id_seq', 292, true);
98126
 
 
98127
 
 
98128
 
--
98129
 
--
98130
 
 
98131
 
COPY aropenalloc (aropenalloc_aropen_id, aropenalloc_doctype, aropenalloc_doc_id, aropenalloc_amount, aropenalloc_curr_id) FROM stdin;
98132
 
\.
98133
 
 
98134
 
 
98135
 
--
98136
 
--
98137
 
 
98138
 
COPY aropentax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin;
98139
 
\.
98140
 
 
98141
 
 
98142
 
--
98143
 
--
98144
 
 
98145
 
COPY asohist (asohist_id, asohist_cust_id, asohist_itemsite_id, asohist_shipdate, asohist_invcdate, asohist_duedate, asohist_promisedate, asohist_ordernumber, asohist_invcnumber, asohist_qtyshipped, asohist_unitprice, asohist_unitcost, asohist_billtoname, asohist_billtoaddress1, asohist_billtoaddress2, asohist_billtoaddress3, asohist_billtocity, asohist_billtostate, asohist_billtozip, asohist_shiptoname, asohist_shiptoaddress1, asohist_shiptoaddress2, asohist_shiptoaddress3, asohist_shiptocity, asohist_shiptostate, asohist_shiptozip, asohist_shipto_id, asohist_shipvia, asohist_salesrep_id, asohist_misc_type, asohist_misc_descrip, asohist_misc_id, asohist_commission, asohist_commissionpaid, asohist_doctype, asohist_orderdate, asohist_imported, asohist_ponumber, asohist_curr_id, asohist_taxtype_id, asohist_taxzone_id) FROM stdin;
98146
 
\.
98147
 
 
98148
 
 
98149
 
--
98150
 
--
98151
 
 
98152
 
SELECT pg_catalog.setval('asohist_asohist_id_seq', 1, false);
98153
 
 
98154
 
 
98155
 
--
98156
 
--
98157
 
 
98158
 
COPY asohisttax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin;
98159
 
\.
98160
 
 
98161
 
 
98162
 
--
98163
 
--
98164
 
 
98165
 
COPY atlasmap (atlasmap_id, atlasmap_name, atlasmap_filter, atlasmap_filtertype, atlasmap_atlas, atlasmap_map, atlasmap_headerline) FROM stdin;
98166
 
\.
98167
 
 
98168
 
 
98169
 
--
98170
 
--
98171
 
 
98172
 
SELECT pg_catalog.setval('atlasmap_atlasmap_id_seq', 1, false);
98173
 
 
98174
 
 
98175
 
--
98176
 
--
98177
 
 
98178
 
COPY backup_usr (usr_id, usr_username, usr_propername, usr_passwd, usr_locale_id, usr_initials, usr_agent, usr_active, usr_email, usr_dept_id, usr_shift_id, usr_window) FROM stdin;
98179
 
1       mfgadmin        OpenMFG Administrator   \N      3       ADMIN   t       t       chris@openmfg.com       \N      \N      
98180
 
2       admin   Administrator           3       ADMIN   t       t       admin@xtuple.com        \N      \N      \N
98181
 
\.
98182
 
 
98183
 
 
98184
 
--
98185
 
--
98186
 
 
98187
 
COPY bankaccnt (bankaccnt_id, bankaccnt_name, bankaccnt_descrip, bankaccnt_bankname, bankaccnt_accntnumber, bankaccnt_ar, bankaccnt_ap, bankaccnt_nextchknum, bankaccnt_type, bankaccnt_accnt_id, bankaccnt_check_form_id, bankaccnt_userec, bankaccnt_rec_accnt_id, bankaccnt_curr_id, bankaccnt_notes, bankaccnt_routing, bankaccnt_ach_enabled, bankaccnt_ach_origin, bankaccnt_ach_genchecknum, bankaccnt_ach_leadtime, bankaccnt_ach_lastdate, bankaccnt_ach_lastfileid, bankaccnt_ach_origintype, bankaccnt_ach_originname, bankaccnt_ach_desttype, bankaccnt_ach_fed_dest, bankaccnt_ach_destname, bankaccnt_ach_dest) FROM stdin;
98188
 
\.
98189
 
 
98190
 
 
98191
 
--
98192
 
--
98193
 
 
98194
 
SELECT pg_catalog.setval('bankaccnt_bankaccnt_id_seq', 12, true);
98195
 
 
98196
 
 
98197
 
--
98198
 
--
98199
 
 
98200
 
COPY bankadj (bankadj_id, bankadj_bankaccnt_id, bankadj_bankadjtype_id, bankadj_created, bankadj_username, bankadj_date, bankadj_docnumber, bankadj_amount, bankadj_notes, bankadj_sequence, bankadj_posted, bankadj_curr_id, bankadj_curr_rate) FROM stdin;
98201
 
\.
98202
 
 
98203
 
 
98204
 
--
98205
 
--
98206
 
 
98207
 
SELECT pg_catalog.setval('bankadj_bankadj_id_seq', 1, false);
98208
 
 
98209
 
 
98210
 
--
98211
 
--
98212
 
 
98213
 
COPY bankadjtype (bankadjtype_id, bankadjtype_name, bankadjtype_descrip, bankadjtype_accnt_id, bankadjtype_iscredit) FROM stdin;
98214
 
\.
98215
 
 
98216
 
 
98217
 
--
98218
 
--
98219
 
 
98220
 
SELECT pg_catalog.setval('bankadjtype_bankadjtype_id_seq', 1, false);
98221
 
 
98222
 
 
98223
 
--
98224
 
--
98225
 
 
98226
 
COPY bankrec (bankrec_id, bankrec_created, bankrec_username, bankrec_bankaccnt_id, bankrec_opendate, bankrec_enddate, bankrec_openbal, bankrec_endbal, bankrec_posted, bankrec_postdate) FROM stdin;
98227
 
\.
98228
 
 
98229
 
 
98230
 
--
98231
 
--
98232
 
 
98233
 
SELECT pg_catalog.setval('bankrec_bankrec_id_seq', 1, false);
98234
 
 
98235
 
 
98236
 
--
98237
 
--
98238
 
 
98239
 
COPY bankrecimport (bankrecimport_id, bankrecimport_reference, bankrecimport_descrip, bankrecimport_comment, bankrecimport_debit_amount, bankrecimport_credit_amount, bankrecimport_effdate, bankrecimport_curr_rate) FROM stdin;
98240
 
\.
98241
 
 
98242
 
 
98243
 
--
98244
 
--
98245
 
 
98246
 
SELECT pg_catalog.setval('bankrecimport_bankrecimport_id_seq', 1, false);
98247
 
 
98248
 
 
98249
 
--
98250
 
--
98251
 
 
98252
 
COPY bankrecitem (bankrecitem_id, bankrecitem_bankrec_id, bankrecitem_source, bankrecitem_source_id, bankrecitem_cleared, bankrecitem_curr_rate, bankrecitem_amount, bankrecitem_effdate) FROM stdin;
98253
 
\.
98254
 
 
98255
 
 
98256
 
--
98257
 
--
98258
 
 
98259
 
SELECT pg_catalog.setval('bankrecitem_bankrecitem_id_seq', 1, false);
98260
 
 
98261
 
 
98262
 
--
98263
 
--
98264
 
 
98265
 
COPY bomhead (bomhead_id, bomhead_item_id, bomhead_serial, bomhead_docnum, bomhead_revision, bomhead_revisiondate, bomhead_batchsize, bomhead_requiredqtyper, bomhead_rev_id) FROM stdin;
98266
 
\.
98267
 
 
98268
 
 
98269
 
--
98270
 
--
98271
 
 
98272
 
SELECT pg_catalog.setval('bomhead_bomhead_id_seq', 54, true);
98273
 
 
98274
 
 
98275
 
--
98276
 
--
98277
 
 
98278
 
COPY bomitem (bomitem_id, bomitem_parent_item_id, bomitem_seqnumber, bomitem_item_id, bomitem_qtyper, bomitem_scrap, bomitem_status, bomitem_effective, bomitem_expires, bomitem_createwo, bomitem_issuemethod, bomitem_schedatwooper, bomitem_ecn, bomitem_moddate, bomitem_subtype, bomitem_uom_id, bomitem_rev_id, bomitem_booitem_seq_id, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref, bomitem_qtyfxd, bomitem_issuewo) FROM stdin;
98279
 
\.
98280
 
 
98281
 
 
98282
 
--
98283
 
--
98284
 
 
98285
 
SELECT pg_catalog.setval('bomitem_bomitem_id_seq', 167, true);
98286
 
 
98287
 
 
98288
 
--
98289
 
--
98290
 
 
98291
 
COPY bomitemcost (bomitemcost_id, bomitemcost_bomitem_id, bomitemcost_costelem_id, bomitemcost_lowlevel, bomitemcost_stdcost, bomitemcost_posted, bomitemcost_actcost, bomitemcost_updated, bomitemcost_curr_id) FROM stdin;
98292
 
\.
98293
 
 
98294
 
 
98295
 
--
98296
 
--
98297
 
 
98298
 
SELECT pg_catalog.setval('bomitemcost_bomitemcost_id_seq', 1, false);
98299
 
 
98300
 
 
98301
 
--
98302
 
--
98303
 
 
98304
 
COPY bomitemsub (bomitemsub_id, bomitemsub_bomitem_id, bomitemsub_item_id, bomitemsub_uomratio, bomitemsub_rank) FROM stdin;
98305
 
\.
98306
 
 
98307
 
 
98308
 
--
98309
 
--
98310
 
 
98311
 
SELECT pg_catalog.setval('bomitemsub_bomitemsub_id_seq', 1, false);
98312
 
 
98313
 
 
98314
 
--
98315
 
--
98316
 
 
98317
 
COPY bomwork (bomwork_id, bomwork_set_id, bomwork_seqnumber, bomwork_item_id, bomwork_item_type, bomwork_qtyper, bomwork_scrap, bomwork_status, bomwork_level, bomwork_parent_id, bomwork_effective, bomwork_expires, bomwork_stdunitcost, bomwork_actunitcost, bomwork_parent_seqnumber, bomwork_createwo, bomwork_issuemethod, bomwork_char_id, bomwork_value, bomwork_notes, bomwork_ref, bomwork_bomitem_id, bomwork_ecn, bomwork_qtyfxd, bomwork_qtyreq) FROM stdin;
98318
 
\.
98319
 
 
98320
 
 
98321
 
--
98322
 
--
98323
 
 
98324
 
SELECT pg_catalog.setval('bomwork_bomwork_id_seq', 1, false);
98325
 
 
98326
 
 
98327
 
--
98328
 
--
98329
 
 
98330
 
COPY budghead (budghead_id, budghead_name, budghead_descrip) FROM stdin;
98331
 
1       Default Default budget for conversion
98332
 
\.
98333
 
 
98334
 
 
98335
 
--
98336
 
--
98337
 
 
98338
 
SELECT pg_catalog.setval('budghead_budghead_id_seq', 2, true);
98339
 
 
98340
 
 
98341
 
--
98342
 
--
98343
 
 
98344
 
COPY budgitem (budgitem_id, budgitem_budghead_id, budgitem_period_id, budgitem_accnt_id, budgitem_amount) FROM stdin;
98345
 
\.
98346
 
 
98347
 
 
98348
 
--
98349
 
--
98350
 
 
98351
 
SELECT pg_catalog.setval('budgitem_budgitem_id_seq', 1, true);
98352
 
 
98353
 
 
98354
 
--
98355
 
--
98356
 
 
98357
 
COPY calhead (calhead_id, calhead_type, calhead_name, calhead_descrip, calhead_origin) FROM stdin;
98358
 
\.
98359
 
 
98360
 
 
98361
 
--
98362
 
--
98363
 
 
98364
 
SELECT pg_catalog.setval('calhead_calhead_id_seq', 46, true);
98365
 
 
98366
 
 
98367
 
--
98368
 
--
98369
 
 
98370
 
SELECT pg_catalog.setval('carrier_carrier_id_seq', 15, true);
98371
 
 
98372
 
 
98373
 
--
98374
 
--
98375
 
 
98376
 
COPY cashrcpt (cashrcpt_id, cashrcpt_cust_id, cashrcpt_amount, cashrcpt_fundstype, cashrcpt_docnumber, cashrcpt_bankaccnt_id, cashrcpt_notes, cashrcpt_distdate, cashrcpt_salescat_id, cashrcpt_curr_id, cashrcpt_usecustdeposit, cashrcpt_void, cashrcpt_number, cashrcpt_docdate, cashrcpt_posted, cashrcpt_posteddate, cashrcpt_postedby, cashrcpt_applydate, cashrcpt_discount, cashrcpt_curr_rate, cashrcpt_alt_curr_rate) FROM stdin;
98377
 
\.
98378
 
 
98379
 
 
98380
 
--
98381
 
--
98382
 
 
98383
 
SELECT pg_catalog.setval('cashrcpt_cashrcpt_id_seq', 112, true);
98384
 
 
98385
 
 
98386
 
--
98387
 
--
98388
 
 
98389
 
COPY cashrcptitem (cashrcptitem_id, cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount, cashrcptitem_discount, cashrcptitem_applied) FROM stdin;
98390
 
\.
98391
 
 
98392
 
 
98393
 
--
98394
 
--
98395
 
 
98396
 
SELECT pg_catalog.setval('cashrcptitem_cashrcptitem_id_seq', 170, true);
98397
 
 
98398
 
 
98399
 
--
98400
 
--
98401
 
 
98402
 
COPY cashrcptmisc (cashrcptmisc_id, cashrcptmisc_cashrcpt_id, cashrcptmisc_accnt_id, cashrcptmisc_amount, cashrcptmisc_notes) FROM stdin;
98403
 
\.
98404
 
 
98405
 
 
98406
 
--
98407
 
--
98408
 
 
98409
 
SELECT pg_catalog.setval('cashrcptmisc_cashrcptmisc_id_seq', 26, true);
98410
 
 
98411
 
 
98412
 
--
98413
 
--
98414
 
 
98415
 
COPY ccard (ccard_id, ccard_seq, ccard_cust_id, ccard_active, ccard_name, ccard_address1, ccard_address2, ccard_city, ccard_state, ccard_zip, ccard_country, ccard_number, ccard_debit, ccard_month_expired, ccard_year_expired, ccard_type, ccard_date_added, ccard_lastupdated, ccard_added_by_username, ccard_last_updated_by_username) FROM stdin;
98416
 
\.
98417
 
 
98418
 
 
98419
 
--
98420
 
--
98421
 
 
98422
 
SELECT pg_catalog.setval('ccard_ccard_id_seq', 1, false);
98423
 
 
98424
 
 
98425
 
--
98426
 
--
98427
 
 
98428
 
COPY ccardaud (ccardaud_id, ccardaud_ccard_id, ccardaud_ccard_seq_old, ccardaud_ccard_seq_new, ccardaud_ccard_cust_id_old, ccardaud_ccard_cust_id_new, ccardaud_ccard_active_old, ccardaud_ccard_active_new, ccardaud_ccard_name_old, ccardaud_ccard_name_new, ccardaud_ccard_address1_old, ccardaud_ccard_address1_new, ccardaud_ccard_address2_old, ccardaud_ccard_address2_new, ccardaud_ccard_city_old, ccardaud_ccard_city_new, ccardaud_ccard_state_old, ccardaud_ccard_state_new, ccardaud_ccard_zip_old, ccardaud_ccard_zip_new, ccardaud_ccard_country_old, ccardaud_ccard_country_new, ccardaud_ccard_number_old, ccardaud_ccard_number_new, ccardaud_ccard_debit_old, ccardaud_ccard_debit_new, ccardaud_ccard_month_expired_old, ccardaud_ccard_month_expired_new, ccardaud_ccard_year_expired_old, ccardaud_ccard_year_expired_new, ccardaud_ccard_type_old, ccardaud_ccard_type_new, ccardaud_ccard_last_updated, ccardaud_ccard_last_updated_by_username) FROM stdin;
98429
 
\.
98430
 
 
98431
 
 
98432
 
--
98433
 
--
98434
 
 
98435
 
SELECT pg_catalog.setval('ccardaud_ccardaud_id_seq', 1, false);
98436
 
 
98437
 
 
98438
 
--
98439
 
--
98440
 
 
98441
 
COPY ccbank (ccbank_id, ccbank_ccard_type, ccbank_bankaccnt_id) FROM stdin;
98442
 
1       A       \N
98443
 
2       D       \N
98444
 
3       M       \N
98445
 
4       P       \N
98446
 
5       V       \N
98447
 
\.
98448
 
 
98449
 
 
98450
 
--
98451
 
--
98452
 
 
98453
 
SELECT pg_catalog.setval('ccbank_ccbank_id_seq', 5, true);
98454
 
 
98455
 
 
98456
 
--
98457
 
--
98458
 
 
98459
 
COPY ccpay (ccpay_id, ccpay_ccard_id, ccpay_cust_id, ccpay_amount, ccpay_auth, ccpay_status, ccpay_type, ccpay_auth_charge, ccpay_order_number, ccpay_order_number_seq, ccpay_r_avs, ccpay_r_ordernum, ccpay_r_error, ccpay_r_approved, ccpay_r_code, ccpay_r_message, ccpay_yp_r_time, ccpay_r_ref, ccpay_yp_r_tdate, ccpay_r_tax, ccpay_r_shipping, ccpay_yp_r_score, ccpay_transaction_datetime, ccpay_by_username, ccpay_curr_id, ccpay_ccpay_id, ccpay_card_pan_trunc, ccpay_card_type) FROM stdin;
98460
 
\.
98461
 
 
98462
 
 
98463
 
--
98464
 
--
98465
 
 
98466
 
SELECT pg_catalog.setval('ccpay_ccpay_id_seq', 1, false);
98467
 
 
98468
 
 
98469
 
--
98470
 
--
98471
 
 
98472
 
COPY "char" (char_id, char_name, char_items, char_options, char_attributes, char_lotserial, char_notes, char_customers, char_crmaccounts, char_addresses, char_contacts, char_opportunity, char_employees, char_mask, char_validator, char_incidents, char_type, char_order, char_search, char_quotes, char_salesorders, char_invoices, char_vendors, char_purchaseorders, char_vouchers, char_projects, char_tasks) FROM stdin;
98473
 
\.
98474
 
 
98475
 
 
98476
 
--
98477
 
--
98478
 
 
98479
 
SELECT pg_catalog.setval('char_char_id_seq', 11, true);
98480
 
 
98481
 
 
98482
 
--
98483
 
--
98484
 
 
98485
 
COPY charass (charass_id, charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price) FROM stdin;
98486
 
\.
98487
 
 
98488
 
 
98489
 
--
98490
 
--
98491
 
 
98492
 
SELECT pg_catalog.setval('charass_charass_id_seq', 1, false);
98493
 
 
98494
 
 
98495
 
--
98496
 
--
98497
 
 
98498
 
COPY charopt (charopt_id, charopt_char_id, charopt_value, charopt_order) FROM stdin;
98499
 
\.
98500
 
 
98501
 
 
98502
 
--
98503
 
--
98504
 
 
98505
 
SELECT pg_catalog.setval('charopt_charopt_id_seq', 1, false);
98506
 
 
98507
 
 
98508
 
--
98509
 
--
98510
 
 
98511
 
COPY checkhead (checkhead_id, checkhead_recip_id, checkhead_recip_type, checkhead_bankaccnt_id, checkhead_printed, checkhead_checkdate, checkhead_number, checkhead_amount, checkhead_void, checkhead_replaced, checkhead_posted, checkhead_rec, checkhead_misc, checkhead_expcat_id, checkhead_for, checkhead_notes, checkhead_journalnumber, checkhead_curr_id, checkhead_deleted, checkhead_ach_batch, checkhead_curr_rate, checkhead_alt_curr_rate) FROM stdin;
98512
 
\.
98513
 
 
98514
 
 
98515
 
--
98516
 
--
98517
 
 
98518
 
SELECT pg_catalog.setval('checkhead_checkhead_id_seq', 1, false);
98519
 
 
98520
 
 
98521
 
--
98522
 
--
98523
 
 
98524
 
COPY checkitem (checkitem_id, checkitem_checkhead_id, checkitem_amount, checkitem_discount, checkitem_ponumber, checkitem_vouchernumber, checkitem_invcnumber, checkitem_apopen_id, checkitem_aropen_id, checkitem_docdate, checkitem_curr_id, checkitem_cmnumber, checkitem_ranumber, checkitem_curr_rate) FROM stdin;
98525
 
\.
98526
 
 
98527
 
 
98528
 
--
98529
 
--
98530
 
 
98531
 
SELECT pg_catalog.setval('checkitem_checkitem_id_seq', 1, false);
98532
 
 
98533
 
 
98534
 
--
98535
 
--
98536
 
 
98537
 
COPY classcode (classcode_id, classcode_code, classcode_descrip, classcode_mfg, classcode_creator, classcode_created, classcode_modifier, classcode_modified, classcode_type) FROM stdin;
98538
 
\.
98539
 
 
98540
 
 
98541
 
--
98542
 
--
98543
 
 
98544
 
SELECT pg_catalog.setval('classcode_classcode_id_seq', 32, true);
98545
 
 
98546
 
 
98547
 
--
98548
 
--
98549
 
 
98550
 
COPY cmd (cmd_id, cmd_module, cmd_title, cmd_descrip, cmd_privname, cmd_executable, cmd_name) FROM stdin;
98551
 
\.
98552
 
 
98553
 
 
98554
 
--
98555
 
--
98556
 
 
98557
 
SELECT pg_catalog.setval('cmd_cmd_id_seq', 6, true);
98558
 
 
98559
 
 
98560
 
--
98561
 
--
98562
 
 
98563
 
COPY cmdarg (cmdarg_id, cmdarg_cmd_id, cmdarg_order, cmdarg_arg) FROM stdin;
98564
 
\.
98565
 
 
98566
 
 
98567
 
--
98568
 
--
98569
 
 
98570
 
SELECT pg_catalog.setval('cmdarg_cmdarg_id_seq', 6, true);
98571
 
 
98572
 
 
98573
 
--
98574
 
--
98575
 
 
98576
 
COPY cmhead (cmhead_id, cmhead_number, cmhead_posted, cmhead_invcnumber, cmhead_custponumber, cmhead_cust_id, cmhead_docdate, cmhead_shipto_id, cmhead_shipto_name, cmhead_shipto_address1, cmhead_shipto_address2, cmhead_shipto_address3, cmhead_shipto_city, cmhead_shipto_state, cmhead_shipto_zipcode, cmhead_salesrep_id, cmhead_freight, cmhead_misc, cmhead_comments, cmhead_printed, cmhead_billtoname, cmhead_billtoaddress1, cmhead_billtoaddress2, cmhead_billtoaddress3, cmhead_billtocity, cmhead_billtostate, cmhead_billtozip, cmhead_hold, cmhead_commission, cmhead_misc_accnt_id, cmhead_misc_descrip, cmhead_rsncode_id, cmhead_curr_id, cmhead_freighttaxtype_id, cmhead_gldistdate, cmhead_billtocountry, cmhead_shipto_country, cmhead_rahead_id, cmhead_taxzone_id, cmhead_prj_id, cmhead_void, cmhead_saletype_id, cmhead_shipzone_id) FROM stdin;
98577
 
\.
98578
 
 
98579
 
 
98580
 
--
98581
 
--
98582
 
 
98583
 
SELECT pg_catalog.setval('cmhead_cmhead_id_seq', 206, true);
98584
 
 
98585
 
 
98586
 
--
98587
 
--
98588
 
 
98589
 
COPY cmheadtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin;
98590
 
\.
98591
 
 
98592
 
 
98593
 
--
98594
 
--
98595
 
 
98596
 
COPY cmitem (cmitem_id, cmitem_cmhead_id, cmitem_linenumber, cmitem_itemsite_id, cmitem_qtycredit, cmitem_qtyreturned, cmitem_unitprice, cmitem_comments, cmitem_rsncode_id, cmitem_taxtype_id, cmitem_qty_uom_id, cmitem_qty_invuomratio, cmitem_price_uom_id, cmitem_price_invuomratio, cmitem_raitem_id, cmitem_updateinv) FROM stdin;
98597
 
\.
98598
 
 
98599
 
 
98600
 
--
98601
 
--
98602
 
 
98603
 
SELECT pg_catalog.setval('cmitem_cmitem_id_seq', 83, true);
98604
 
 
98605
 
 
98606
 
--
98607
 
--
98608
 
 
98609
 
COPY cmitemtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin;
98610
 
\.
98611
 
 
98612
 
 
98613
 
--
98614
 
--
98615
 
 
98616
 
COPY cmnttype (cmnttype_id, cmnttype_name, cmnttype_descrip, cmnttype_usedin, cmnttype_sys, cmnttype_editable, cmnttype_order) FROM stdin;
98617
 
1       General General Comment ICVPL   t       f       \N
98618
 
2       ChangeLog       Change Log      ICVP    t       f       \N
98619
 
3       Notes to Comment        Used by certain triggers to automatically create/update comment with content of notes.  \N      t       f       \N
98620
 
\.
98621
 
 
98622
 
 
98623
 
--
98624
 
--
98625
 
 
98626
 
SELECT pg_catalog.setval('cmnttype_cmnttype_id_seq', 3, true);
98627
 
 
98628
 
 
98629
 
--
98630
 
--
98631
 
 
98632
 
COPY cmnttypesource (cmnttypesource_id, cmnttypesource_cmnttype_id, cmnttypesource_source_id) FROM stdin;
98633
 
76      1       1
98634
 
77      2       1
98635
 
78      1       2
98636
 
79      2       2
98637
 
80      1       3
98638
 
81      2       3
98639
 
82      1       4
98640
 
83      2       4
98641
 
84      1       5
98642
 
85      2       5
98643
 
86      1       6
98644
 
87      2       6
98645
 
88      1       7
98646
 
89      2       7
98647
 
90      1       8
98648
 
91      2       8
98649
 
92      1       9
98650
 
93      2       9
98651
 
94      1       10
98652
 
95      2       10
98653
 
96      1       11
98654
 
97      2       11
98655
 
98      1       12
98656
 
99      2       12
98657
 
100     1       13
98658
 
101     2       13
98659
 
102     1       14
98660
 
103     2       14
98661
 
104     1       15
98662
 
105     2       15
98663
 
106     1       16
98664
 
107     2       16
98665
 
108     1       17
98666
 
109     2       17
98667
 
110     1       18
98668
 
111     2       18
98669
 
112     1       19
98670
 
113     2       19
98671
 
114     1       20
98672
 
115     2       20
98673
 
116     1       21
98674
 
117     2       21
98675
 
118     1       22
98676
 
119     2       22
98677
 
120     1       23
98678
 
121     2       23
98679
 
122     1       24
98680
 
123     2       24
98681
 
124     1       25
98682
 
125     2       25
98683
 
126     1       26
98684
 
127     2       26
98685
 
128     1       27
98686
 
129     2       27
98687
 
130     1       28
98688
 
131     2       28
98689
 
132     1       29
98690
 
133     2       29
98691
 
134     1       30
98692
 
135     2       30
98693
 
136     1       31
98694
 
137     2       31
98695
 
138     1       32
98696
 
139     2       32
98697
 
140     1       33
98698
 
141     2       33
98699
 
142     1       34
98700
 
143     2       34
98701
 
144     3       12
98702
 
\.
98703
 
 
98704
 
 
98705
 
--
98706
 
--
98707
 
 
98708
 
SELECT pg_catalog.setval('cmnttypesource_cmnttypesource_id_seq', 144, true);
98709
 
 
98710
 
 
98711
 
--
98712
 
--
98713
 
 
98714
 
COPY cntct (cntct_id, cntct_crmacct_id, cntct_addr_id, cntct_first_name, cntct_last_name, cntct_honorific, cntct_initials, cntct_active, cntct_phone, cntct_phone2, cntct_fax, cntct_email, cntct_webaddr, cntct_notes, cntct_title, cntct_number, cntct_middle, cntct_suffix, cntct_owner_username, cntct_name) FROM stdin;
98715
 
\.
98716
 
 
98717
 
 
98718
 
--
98719
 
--
98720
 
 
98721
 
SELECT pg_catalog.setval('cntct_cntct_id_seq', 1, false);
98722
 
 
98723
 
 
98724
 
--
98725
 
--
98726
 
 
98727
 
COPY cntctaddr (cntctaddr_id, cntctaddr_cntct_id, cntctaddr_primary, cntctaddr_addr_id, cntctaddr_type) FROM stdin;
98728
 
\.
98729
 
 
98730
 
 
98731
 
--
98732
 
--
98733
 
 
98734
 
SELECT pg_catalog.setval('cntctaddr_cntctaddr_id_seq', 1, false);
98735
 
 
98736
 
 
98737
 
--
98738
 
--
98739
 
 
98740
 
COPY cntctdata (cntctdata_id, cntctdata_cntct_id, cntctdata_primary, cntctdata_text, cntctdata_type) FROM stdin;
98741
 
\.
98742
 
 
98743
 
 
98744
 
--
98745
 
--
98746
 
 
98747
 
SELECT pg_catalog.setval('cntctdata_cntctdata_id_seq', 1, false);
98748
 
 
98749
 
 
98750
 
--
98751
 
--
98752
 
 
98753
 
COPY cntcteml (cntcteml_id, cntcteml_cntct_id, cntcteml_primary, cntcteml_email) FROM stdin;
98754
 
\.
98755
 
 
98756
 
 
98757
 
--
98758
 
--
98759
 
 
98760
 
SELECT pg_catalog.setval('cntcteml_cntcteml_id_seq', 1, false);
98761
 
 
98762
 
 
98763
 
--
98764
 
--
98765
 
 
98766
 
COPY cntctmrgd (cntctmrgd_cntct_id, cntctmrgd_error) FROM stdin;
98767
 
\.
98768
 
 
98769
 
 
98770
 
--
98771
 
--
98772
 
 
98773
 
COPY cntctsel (cntctsel_cntct_id, cntctsel_target, cntctsel_mrg_crmacct_id, cntctsel_mrg_addr_id, cntctsel_mrg_first_name, cntctsel_mrg_last_name, cntctsel_mrg_honorific, cntctsel_mrg_initials, cntctsel_mrg_phone, cntctsel_mrg_phone2, cntctsel_mrg_fax, cntctsel_mrg_email, cntctsel_mrg_webaddr, cntctsel_mrg_notes, cntctsel_mrg_title, cntctsel_mrg_middle, cntctsel_mrg_suffix, cntctsel_mrg_owner_username) FROM stdin;
98774
 
\.
98775
 
 
98776
 
 
98777
 
--
98778
 
--
98779
 
 
98780
 
COPY cntslip (cntslip_id, cntslip_cnttag_id, cntslip_entered, cntslip_posted, cntslip_number, cntslip_qty, cntslip_comments, cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, cntslip_username) FROM stdin;
98781
 
\.
98782
 
 
98783
 
 
98784
 
--
98785
 
--
98786
 
 
98787
 
SELECT pg_catalog.setval('cntslip_cntslip_id_seq', 97, true);
98788
 
 
98789
 
 
98790
 
--
98791
 
--
98792
 
 
98793
 
COPY cobill (cobill_id, cobill_coitem_id, cobill_selectdate, cobill_qty, cobill_invcnum, cobill_toclose, cobill_cobmisc_id, cobill_select_username, cobill_invcitem_id, cobill_taxtype_id) FROM stdin;
98794
 
\.
98795
 
 
98796
 
 
98797
 
--
98798
 
--
98799
 
 
98800
 
SELECT pg_catalog.setval('cobill_cobill_id_seq', 528, true);
98801
 
 
98802
 
 
98803
 
--
98804
 
--
98805
 
 
98806
 
COPY cobilltax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin;
98807
 
\.
98808
 
 
98809
 
 
98810
 
--
98811
 
--
98812
 
 
98813
 
COPY cobmisc (cobmisc_id, cobmisc_cohead_id, cobmisc_shipvia, cobmisc_freight, cobmisc_misc, cobmisc_payment, cobmisc_paymentref, cobmisc_notes, cobmisc_shipdate, cobmisc_invcnumber, cobmisc_invcdate, cobmisc_posted, cobmisc_misc_accnt_id, cobmisc_misc_descrip, cobmisc_closeorder, cobmisc_curr_id, cobmisc_invchead_id, cobmisc_taxzone_id, cobmisc_taxtype_id) FROM stdin;
98814
 
\.
98815
 
 
98816
 
 
98817
 
--
98818
 
--
98819
 
 
98820
 
SELECT pg_catalog.setval('cobmisc_cobmisc_id_seq', 204, true);
98821
 
 
98822
 
 
98823
 
--
98824
 
--
98825
 
 
98826
 
COPY cobmisctax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin;
98827
 
\.
98828
 
 
98829
 
 
98830
 
--
98831
 
--
98832
 
 
98833
 
COPY cohead (cohead_id, cohead_number, cohead_cust_id, cohead_custponumber, cohead_type, cohead_orderdate, cohead_warehous_id, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_shiptoaddress4, cohead_shiptoaddress5, cohead_salesrep_id, cohead_terms_id, cohead_fob, cohead_shipvia, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_freight, cohead_misc, cohead_imported, cohead_ordercomments, cohead_shipcomments, cohead_shiptophone, cohead_shipchrg_id, cohead_shipform_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_misc_accnt_id, cohead_misc_descrip, cohead_commission, cohead_miscdate, cohead_holdtype, cohead_packdate, cohead_prj_id, cohead_wasquote, cohead_lastupdated, cohead_shipcomplete, cohead_created, cohead_creator, cohead_quote_number, cohead_billtocountry, cohead_shiptocountry, cohead_curr_id, cohead_calcfreight, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_taxzone_id, cohead_taxtype_id, cohead_ophead_id, cohead_status, cohead_saletype_id, cohead_shipzone_id) FROM stdin;
98834
 
\.
98835
 
 
98836
 
 
98837
 
--
98838
 
--
98839
 
 
98840
 
SELECT pg_catalog.setval('cohead_cohead_id_seq', 2952, true);
98841
 
 
98842
 
 
98843
 
--
98844
 
--
98845
 
 
98846
 
COPY cohist (cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_orderdate, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_shipto_id, cohist_salesrep_id, cohist_duedate, cohist_imported, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_commission, cohist_commissionpaid, cohist_unitcost, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_doctype, cohist_promisedate, cohist_ponumber, cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id, cohist_cohead_ccpay_id, cohist_saletype_id, cohist_shipzone_id) FROM stdin;
98847
 
\.
98848
 
 
98849
 
 
98850
 
--
98851
 
--
98852
 
 
98853
 
SELECT pg_catalog.setval('cohist_cohist_id_seq', 493, true);
98854
 
 
98855
 
 
98856
 
--
98857
 
--
98858
 
 
98859
 
COPY cohisttax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin;
98860
 
\.
98861
 
 
98862
 
 
98863
 
--
98864
 
--
98865
 
 
98866
 
COPY coitem (coitem_id, coitem_cohead_id, coitem_linenumber, coitem_itemsite_id, coitem_status, coitem_scheddate, coitem_promdate, coitem_qtyord, coitem_unitcost, coitem_price, coitem_custprice, coitem_qtyshipped, coitem_order_id, coitem_memo, coitem_imported, coitem_qtyreturned, coitem_closedate, coitem_custpn, coitem_order_type, coitem_close_username, coitem_lastupdated, coitem_substitute_item_id, coitem_created, coitem_creator, coitem_prcost, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_price_uom_id, coitem_price_invuomratio, coitem_warranty, coitem_cos_accnt_id, coitem_qtyreserved, coitem_subnumber, coitem_firm, coitem_taxtype_id, coitem_rev_accnt_id, coitem_pricemode) FROM stdin;
98867
 
\.
98868
 
 
98869
 
 
98870
 
--
98871
 
--
98872
 
 
98873
 
SELECT pg_catalog.setval('coitem_coitem_id_seq', 564, true);
98874
 
 
98875
 
 
98876
 
--
98877
 
--
98878
 
 
98879
 
COPY comment (comment_id, comment_source_id, comment_date, comment_user, comment_text, comment_cmnttype_id, comment_source, comment_public) FROM stdin;
98880
 
39      1       2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98881
 
40      2       2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98882
 
41      3       2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98883
 
42      4       2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98884
 
43      5       2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98885
 
44      6       2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98886
 
45      7       2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98887
 
46      8       2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98888
 
47      9       2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98889
 
48      10      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98890
 
49      11      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98891
 
50      12      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98892
 
51      13      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98893
 
52      14      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98894
 
53      15      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98895
 
54      16      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98896
 
55      17      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98897
 
56      18      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98898
 
57      19      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98899
 
58      20      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98900
 
59      21      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98901
 
60      22      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98902
 
61      23      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98903
 
62      24      2011-08-19 15:12:05.633058+00   admin   Created by admin        2       CRMA    f
98904
 
\.
98905
 
 
98906
 
 
98907
 
--
98908
 
--
98909
 
 
98910
 
SELECT pg_catalog.setval('comment_comment_id_seq', 62, true);
98911
 
 
98912
 
 
98913
 
--
98914
 
--
98915
 
 
98916
 
COPY company (company_id, company_number, company_descrip, company_external, company_server, company_port, company_database, company_curr_id, company_yearend_accnt_id, company_gainloss_accnt_id, company_dscrp_accnt_id, company_unrlzgainloss_accnt_id) FROM stdin;
98917
 
\.
98918
 
 
98919
 
 
98920
 
--
98921
 
--
98922
 
 
98923
 
SELECT pg_catalog.setval('company_company_id_seq', 1, false);
98924
 
 
98925
 
 
98926
 
--
98927
 
--
98928
 
 
98929
 
COPY contrct (contrct_id, contrct_number, contrct_vend_id, contrct_descrip, contrct_effective, contrct_expires, contrct_note) FROM stdin;
98930
 
\.
98931
 
 
98932
 
 
98933
 
--
98934
 
--
98935
 
 
98936
 
SELECT pg_catalog.setval('contrct_contrct_id_seq', 1, false);
98937
 
 
98938
 
 
98939
 
--
98940
 
--
98941
 
 
98942
 
SELECT pg_catalog.setval('coship_coship_id_seq', 441, true);
98943
 
 
98944
 
 
98945
 
--
98946
 
--
98947
 
 
98948
 
SELECT pg_catalog.setval('cosmisc_cosmisc_id_seq', 202, true);
98949
 
 
98950
 
 
98951
 
--
98952
 
--
98953
 
 
98954
 
SELECT pg_catalog.setval('cosrc_cosrc_id_seq', 1, false);
98955
 
 
98956
 
 
98957
 
--
98958
 
--
98959
 
 
98960
 
COPY costcat (costcat_id, costcat_code, costcat_descrip, costcat_asset_accnt_id, costcat_liability_accnt_id, costcat_adjustment_accnt_id, costcat_matusage_accnt_id, costcat_purchprice_accnt_id, costcat_laboroverhead_accnt_id, costcat_scrap_accnt_id, costcat_invcost_accnt_id, costcat_wip_accnt_id, costcat_shipasset_accnt_id, costcat_mfgscrap_accnt_id, costcat_transform_accnt_id, costcat_freight_accnt_id, costcat_toliability_accnt_id, costcat_exp_accnt_id) FROM stdin;
98961
 
\.
98962
 
 
98963
 
 
98964
 
--
98965
 
--
98966
 
 
98967
 
SELECT pg_catalog.setval('costcat_costcat_id_seq', 29, true);
98968
 
 
98969
 
 
98970
 
--
98971
 
--
98972
 
 
98973
 
COPY costelem (costelem_id, costelem_type, costelem_sys, costelem_po, costelem_active, costelem_exp_accnt_id, costelem_cost_item_id) FROM stdin;
98974
 
3       Material        t       t       t       \N      -1
98975
 
4       Direct Labor    t       f       t       \N      -1
98976
 
5       Overhead        t       f       t       \N      -1
98977
 
6       Machine Overhead        t       f       t       \N      -1
98978
 
\.
98979
 
 
98980
 
 
98981
 
--
98982
 
--
98983
 
 
98984
 
SELECT pg_catalog.setval('costelem_costelem_id_seq', 20, true);
98985
 
 
98986
 
 
98987
 
--
98988
 
--
98989
 
 
98990
 
COPY costhist (costhist_id, costhist_item_id, costhist_costelem_id, costhist_type, costhist_date, costhist_oldcost, costhist_newcost, costhist_lowlevel, costhist_oldcurr_id, costhist_newcurr_id, costhist_username) FROM stdin;
98991
 
\.
98992
 
 
98993
 
 
98994
 
--
98995
 
--
98996
 
 
98997
 
SELECT pg_catalog.setval('costhist_costhist_id_seq', 992, true);
98998
 
 
98999
 
 
99000
 
--
99001
 
--
99002
 
 
99003
 
COPY costupdate (costupdate_item_id, costupdate_lowlevel_code, costupdate_item_type) FROM stdin;
99004
 
\.
99005
 
 
99006
 
 
99007
 
--
99008
 
--
99009
 
 
99010
 
COPY country (country_id, country_abbr, country_name, country_curr_abbr, country_curr_name, country_curr_number, country_curr_symbol, country_qt_number) FROM stdin;
99011
 
214     \N      \N      XTS     Code reserved for testing       963     \N      \N
99012
 
5       AD      Andorra EUR     Euro    978     Ć¢Ā‚Ā¬     5
99013
 
228     AE      United Arab Emirates    AED     UAE Dirham      784     \N      223
99014
 
1       AF      Afghanistan     AFN     Afghani 971     \N      1
99015
 
9       AG      Antigua And Barbuda     XCD     East Caribbean Dollar   951     $       9
99016
 
7       AI      Anguilla        XCD     East Caribbean Dollar   951     $       7
99017
 
2       AL      Albania ALL     Lek     8       \N      2
99018
 
11      AM      Armenia AMD     Armenian Dram   51      \N      11
99019
 
154     AN      Netherlands Antilles    ANG     Netherlands Antillian Guilder   532     Ć†Ā’      152
99020
 
6       AO      Angola  AOA     Kwanza  973     \N      6
99021
 
8       AQ      Antarctica      \N      \N      \N      \N      8
99022
 
10      AR      Argentina       ARS     Argentine Peso  32      $       10
99023
 
4       AS      American Samoa  USD     US Dollar       840     $       4
99024
 
14      AT      Austria EUR     Euro    978     Ć¢Ā‚Ā¬     14
99025
 
13      AU      Australia       AUD     Australian Dollar       36      $       13
99026
 
12      AW      Aruba   AWG     Aruban Guilder  533     Ć†Ā’      12
99027
 
15      AZ      Azerbaijan      AZN     Azerbaijanian Manat     944     \N      15
99028
 
27      BA      Bosnia And Herzegovina  BAM     Convertible Marks       977     \N      27
99029
 
19      BB      Barbados        BBD     Barbados Dollar 52      $       19
99030
 
18      BD      Bangladesh      BDT     Taka    50      \N      18
99031
 
21      BE      Belgium EUR     Euro    978     Ć¢Ā‚Ā¬     21
99032
 
35      BF      Burkina Faso    XOF     CFA Franc BCEAO 952     \N      34
99033
 
34      BG      Bulgaria        BGN     Bulgarian Lev   975     \N      33
99034
 
17      BH      Bahrain BHD     Bahraini Dinar  48      \N      17
99035
 
36      BI      Burundi BIF     Burundi Franc   108     \N      35
99036
 
23      BJ      Benin   XOF     CFA Franc BCEAO 952     \N      23
99037
 
24      BM      Bermuda BMD     Bermudian Dollar        60      $       24
99038
 
33      BN      Brunei Darussalam       BND     Brunei Dollar   96      $       32
99039
 
26      BO      Bolivia BOB     Boliviano       68      $       26
99040
 
30      BR      Brazil  BRL     Brazilian Real  986     R$      30
99041
 
16      BS      Bahamas BSD     Bahamian Dollar 44      $       16
99042
 
25      BT      Bhutan  BTN     Ngultrum        64      \N      25
99043
 
29      BV      Bouvet Island   NOK     Norwegian Krone 578     \N      29
99044
 
28      BW      Botswana        BWP     Pula    72      \N      28
99045
 
20      BY      Belarus BYR     Belarussian Ruble       974     \N      20
99046
 
22      BZ      Belize  BZD     Belize Dollar   84      $       22
99047
 
39      CA      Canada  CAD     Canadian Dollar 124     $       38
99048
 
47      CC      Cocos (Keeling) Islands AUD     Australian Dollar       36      $       46
99049
 
51      CD      Congo, The Democratic Republic Of       CDF     Franc Congolais 976     \N      49
99050
 
42      CF      Central African Republic        XAF     CFA Franc BEAC  950     \N      41
99051
 
50      CG      Congo   XAF     CFA Franc BEAC  950     \N      50
99052
 
209     CH      Switzerland     CHF     Swiss Franc     756     \N      206
99053
 
107     CI      Ivory Coast     XOF     CFA Frank BCEA  952     \N      53
99054
 
52      CK      Cook Islands    NZD     New Zealand Dollar      554     $       51
99055
 
44      CL      Chile   CLP     Chilean Peso    152     $       43
99056
 
38      CM      Cameroon        XAF     CFA Franc BEAC  950     \N      37
99057
 
45      CN      China   CNY     Yuan Renminbi   156     \N      44
99058
 
48      CO      Colombia        COP     Colombian Peso  170     Ć¢Ā‚Ā±     47
99059
 
53      CR      Costa Rica      CRC     Costa Rican Colon       188     Ć¢Ā‚Ā”     52
99060
 
55      CU      Cuba    CUP     Cuban Peso      192     Ć¢Ā‚Ā±     55
99061
 
40      CV      Cape Verde      CVE     Cape Verde Escudo       132     \N      39
99062
 
46      CX      Christmas Island        AUD     Australian Dollar       36      $       45
99063
 
56      CY      Cyprus  CYP     Cyprus Pound    196     Ć‚Ā£      56
99064
 
57      CZ      Czech Republic  CZK     Czech Koruna    203     \N      57
99065
 
81      DE      Germany EUR     Euro    978     Ć¢Ā‚Ā¬     82
99066
 
59      DJ      Djibouti        DJF     Djibouti Franc  262     \N      59
99067
 
58      DK      Denmark DKK     Danish Krone    208     kr      58
99068
 
60      DM      Dominica        XCD     East Caribbean Dollar   951     $       60
99069
 
61      DO      Dominican Republic      DOP     Dominican Peso  214     Ć¢Ā‚Ā±     61
99070
 
3       DZ      Algeria DZD     Algerian Dinar  12      \N      3
99071
 
63      EC      Ecuador USD     US Dollar       840     $       63
99072
 
68      EE      Estonia EEK     Kroon   233     \N      68
99073
 
64      EG      Egypt   EGP     Egyptian Pound  818     Ć‚Ā£      64
99074
 
239     EH      Western Sahara  MAD     Moroccan Dirham 504     \N      236
99075
 
67      ER      Eritrea ERN     Nakfa   232     \N      67
99076
 
202     ES      Spain   EUR     Euro    978     Ć¢Ā‚Ā¬     197
99077
 
69      ET      Ethiopia        ETB     Ethiopian Birr  230     \N      69
99078
 
73      FI      Finland EUR     Euro    978     Ć¢Ā‚Ā¬     73
99079
 
72      FJ      Fiji    FJD     Fiji Dollar     242     $       72
99080
 
70      FK      Falkland Islands (Malvinas)     FKP     Falkland Islands Pound  238     Ć‚Ā£      70
99081
 
141     FM      Micronesia, Federated States Of USD     US Dollar       840     $       140
99082
 
71      FO      Faroe Islands   DKK     Danish Krone    208     \N      71
99083
 
74      FR      France  EUR     Euro    978     Ć¢Ā‚Ā¬     74
99084
 
78      GA      Gabon   XAF     CFA Franc BEAC  950     \N      79
99085
 
86      GD      Grenada XCD     East Caribbean Dollar   951     $       87
99086
 
80      GE      Georgia GEL     Lari    981     \N      81
99087
 
75      GF      French Guiana   EUR     Euro    978     Ć¢Ā‚Ā¬     76
99088
 
82      GH      Ghana   GHC     Cedi    288     \N      83
99089
 
83      GI      Gibraltar       GIP     Gibraltar Pound 292     Ć‚Ā£      84
99090
 
85      GL      Greenland       DKK     Danish Krone    208     \N      86
99091
 
79      GM      Gambia  GMD     Dalasi  270     \N      80
99092
 
90      GN      Guinea  GNF     Guinea Franc    324     \N      91
99093
 
87      GP      Guadeloupe      EUR     Euro    978     Ć¢Ā‚Ā¬     88
99094
 
66      GQ      Equatorial Guinea       XAF     CFA Franc BEAC  950     \N      66
99095
 
84      GR      Greece  EUR     Euro    978     Ć¢Ā‚Ā¬     85
99096
 
201     GS      South Georgia And The South Sandwich Islands    GBP     Pound Sterling  826     \N      196
99097
 
89      GT      Guatemala       GTQ     Quetzal 320     \N      90
99098
 
88      GU      Guam    USD     US Dollar       840     $       89
99099
 
91      GW      Guinea-Bissau   XOF     CFA Franc BCEAO 952     \N      92
99100
 
92      GY      Guyana  GYD     Guyana Dollar   328     $       93
99101
 
97      HK      Hong Kong       HKD     Hong Kong Dollar        344     $       97
99102
 
94      HM      Heard Island And Mcdonald Islands       AUD     Australian Dollar       36      $       95
99103
 
96      HN      Honduras        HNL     Lempira 340     \N      96
99104
 
54      HR      Croatia HRK     Croatian Kuna   191     \N      54
99105
 
93      HT      Haiti   HTG     Gourde  332     \N      94
99106
 
98      HU      Hungary HUF     Forint  348     \N      98
99107
 
101     ID      Indonesia       IDR     Indonesia Rupiah        360     \N      101
99108
 
104     IE      Ireland EUR     Euro    978     Ć¢Ā‚Ā¬     104
99109
 
105     IL      Israel  ILS     New Israeli Sheqel      376     Ć¢Ā‚ĀŖ     105
99110
 
100     IN      India   INR     Indian Rupee    356     Ć¢Ā‚ĀØ     100
99111
 
31      IO      British Indian Ocean Territory  USD     US Dollar       840     $       31
99112
 
103     IQ      Iraq    IQD     Iraqi Dinar     368     \N      103
99113
 
102     IR      Iran    IRR     Iranian Rial    364     ĆÆĀ·Ā¼     102
99114
 
99      IS      Iceland ISK     Iceland Krona   352     \N      99
99115
 
106     IT      Italy   EUR     Euro    978     Ć¢Ā‚Ā¬     106
99116
 
108     JM      Jamaica JMD     Jamaican Dollar 388     $       107
99117
 
110     JO      Jordan  JOD     Jordanian Dinar 400     \N      109
99118
 
109     JP      Japan   JPY     Yen     392     Ć‚Ā„      108
99119
 
112     KE      Kenya   KES     Kenyan Shilling 404     \N      111
99120
 
117     KG      Kyrgyzstan      KGS     Som     417     \N      116
99121
 
37      KH      Cambodia        KHR     Riel    116     Ć”ĀŸĀ›     36
99122
 
113     KI      Kiribati        AUD     Australian Dollar       36      $       112
99123
 
49      KM      Comoros KMF     Comoro Franc    174     \N      48
99124
 
183     KN      Saint Kitts And Nevis   XCD     East Caribbean Dollar   951     $       180
99125
 
114     KP      Korea, Democratic Peoples Republic Of   KPW     North Korean Won        408     Ć¢Ā‚Ā©     113
99126
 
115     KR      Korea, Republic Of      KRW     South Korean Won        410     Ć¢Ā‚Ā©     114
99127
 
116     KW      Kuwait  KWD     Kuwaiti Dinar   414     \N      115
99128
 
41      KY      Cayman Islands  KYD     Cayman Islands Dollar   136     $       40
99129
 
111     KZ      Kazakhstan      KZT     Tenge   398     \N      110
99130
 
118     LA      Laos    LAK     Kip     418     Ć¢Ā‚Ā­     117
99131
 
120     LB      Lebanon LBP     Lebanese Pound  422     Ć‚Ā£      119
99132
 
184     LC      Saint Lucia     XCD     East Caribbean Dollar   951     $       181
99133
 
124     LI      Liechtenstein   CHF     Swiss Franc     756     \N      123
99134
 
203     LK      Sri Lanka       LKR     Sri Lanka Rupee 144     Ć ĀÆĀ¹     198
99135
 
122     LR      Liberia LRD     Liberian Dollar 430     $       121
99136
 
121     LS      Lesotho LSL     Loti    426     \N      120
99137
 
125     LT      Lithuania       LTL     Lithuanian Litas        440     \N      124
99138
 
126     LU      Luxembourg      EUR     Euro    978     Ć¢Ā‚Ā¬     125
99139
 
119     LV      Latvia  LVL     Latvian Lats    428     \N      118
99140
 
123     LY      Libyan Arab Jamahiriya  LYD     Libyan Dinar    434     \N      122
99141
 
147     MA      Morocco MAD     Moroccan Dirham 504     \N      145
99142
 
143     MC      Monaco  EUR     Euro    978     Ć¢Ā‚Ā¬     142
99143
 
142     MD      Moldova MDL     Moldovan Leu    498     \N      141
99144
 
145     ME      Montenegro      EUR     Euro    978     Ć¢Ā‚Ā¬     241
99145
 
129     MG      Madagascar      MGA     Malagascy Ariary        969     \N      128
99146
 
135     MH      Marshall Islands        USD     US Dollar       840     $       134
99147
 
128     MK      Macedonia, Former Yugoslav Republic Of  MKD     Denar   807     \N      127
99148
 
133     ML      Mali    XOF     CFA Franc BCEAO 952     \N      132
99149
 
149     MM      Myanmar MMK     Kyat    104     \N      147
99150
 
144     MN      Mongolia        MNT     Tugrik  496     Ć¢Ā‚Ā®     143
99151
 
127     MO      Macao   MOP     Pataca  446     \N      126
99152
 
162     MP      Northern Mariana Islands        USD     US Dollar       840     $       160
99153
 
136     MQ      Martinique      EUR     Euro    978     Ć¢Ā‚Ā¬     135
99154
 
137     MR      Mauritania      MRO     Ouguiya 478     \N      136
99155
 
146     MS      Montserrat      XCD     East Caribbean Dollar   951     $       144
99156
 
134     MT      Malta   MTL     Maltese Lira    470     Ć¢Ā‚Ā¤     133
99157
 
138     MU      Mauritius       MUR     Mauritius Rupee 480     Ć¢Ā‚ĀØ     137
99158
 
132     MV      Maldives        MVR     Rufiyaa 462     \N      131
99159
 
130     MW      Malawi  MWK     Malawi Kwacha   454     \N      129
99160
 
140     MX      Mexico  MXN     Mexican Peso    484     $       139
99161
 
131     MY      Malaysia        MYR     Malaysian Ringgit       458     \N      130
99162
 
148     MZ      Mozambique      MZN     Metical 943     \N      146
99163
 
150     NA      Namibia NAD     Namibian Dollar 516     $       148
99164
 
155     NC      New Caledonia   XPF     CFP Franc       953     \N      153
99165
 
158     NE      Niger   XOF     CFA Franc BCEAO 952     \N      156
99166
 
161     NF      Norfolk Island  AUD     Australian Dollar       36      $       159
99167
 
159     NG      Nigeria NGN     Naira   566     Ć¢Ā‚Ā¦     157
99168
 
157     NI      Nicaragua       NIO     Cordoba Oro     558     \N      155
99169
 
153     NL      Netherlands     EUR     Euro    978     Ć¢Ā‚Ā¬     151
99170
 
163     NO      Norway  NOK     Norwegian Krone 578     \N      161
99171
 
152     NP      Nepal   NPR     Nepalese Rupee  524     Ć¢Ā‚ĀØ     150
99172
 
151     NR      Nauru   AUD     Australian Dollar       36      $       149
99173
 
160     NU      Niue    NZD     New Zealand Dollar      554     $       158
99174
 
156     NZ      New Zealand     NZD     New Zealand Dollar      554     $       154
99175
 
164     OM      Oman    OMR     Rial Omani      512     ĆÆĀ·Ā¼     162
99176
 
168     PA      Panama  PAB     Balboa  590     \N      166
99177
 
171     PE      Peru    PEN     Nuevo Sol       604     S/.     169
99178
 
76      PF      French Polynesia        XPF     CFP Franc       953     \N      77
99179
 
169     PG      Papua New Guinea        PGK     Kina    598     \N      167
99180
 
172     PH      Philippines     PHP     Philippine Peso 608     Ć¢Ā‚Ā±     170
99181
 
165     PK      Pakistan        PKR     Pakistan Rupee  586     Ć¢Ā‚ĀØ     163
99182
 
174     PL      Poland  PLN     Zloty   985     \N      172
99183
 
185     PM      Saint Pierre And Miquelon       EUR     Euro    978     Ć¢Ā‚Ā¬     200
99184
 
173     PN      Pitcairn        NZD     New Zealand Dollar      554     $       171
99185
 
176     PR      Puerto Rico     USD     US Dollar       840     $       174
99186
 
167     PS      Palestinian Territories \N      \N      \N      \N      165
99187
 
175     PT      Portugal        EUR     Euro    978     Ć¢Ā‚Ā¬     173
99188
 
166     PW      Palau   USD     US Dollar       840     $       164
99189
 
170     PY      Paraguay        PYG     Guarani 600     \N      168
99190
 
177     QA      Qatar   QAR     Qatari Rial     634     \N      175
99191
 
178     RE      Reunion EUR     Euro    978     Ć¢Ā‚Ā¬     176
99192
 
179     RO      Romania RON     New Leu 946     \N      177
99193
 
192     RS      Serbia  RSD     Serbian Dinar   941     \N      241
99194
 
180     RU      Russian Federation      RUB     Russian Ruble   643     \N      178
99195
 
181     RW      Rwanda  RWF     Rwanda Franc    646     \N      179
99196
 
190     SA      Saudi Arabia    SAR     Saudi Riyal     682     ĆÆĀ·Ā¼     186
99197
 
198     SB      Solomon Islands SBD     Solomon Islands Dollar  90      $       193
99198
 
193     SC      Seychelles      SCR     Seychelles Rupee        690     Ć¢Ā‚ĀØ     188
99199
 
204     SD      Sudan   SDD     Sudanese Dinar  736     \N      201
99200
 
208     SE      Sweden  SEK     Swedish Krona   752     kr      205
99201
 
195     SG      Singapore       SGD     Singapore Dollar        702     $       190
99202
 
182     SH      Saint Helena    SHP     Saint Helena Pound      654     Ć‚Ā£      199
99203
 
197     SI      Slovenia        SIT     Tolar   705     \N      192
99204
 
206     SJ      Svalbard And Jan Mayen  NOK     Norwegian Krone 578     \N      203
99205
 
196     SK      Slovakia        SKK     Slovak Koruna   703     \N      191
99206
 
194     SL      Sierra Leone    SLL     Leone   694     \N      189
99207
 
188     SM      San Marino      EUR     Euro    978     Ć¢Ā‚Ā¬     184
99208
 
191     SN      Senegal XOF     CFA Franc BCEAO 952     \N      187
99209
 
199     SO      Somalia SOS     Somali Shilling 706     \N      194
99210
 
205     SR      Suriname        SRD     Surinam Dollar  968     $       202
99211
 
189     ST      Sao Tome And Principe   STD     Dobra   678     \N      185
99212
 
65      SV      El Salvador     SVC     El Salvador Colon       222     Ć¢Ā‚Ā”     65
99213
 
210     SY      Syria   SYP     Syrian Pound    760     Ć‚Ā£      207
99214
 
207     SZ      Swaziland       SZL     Lilangeni       748     \N      204
99215
 
224     TC      Turks And Caicos Islands        USD     US Dollar       840     $       219
99216
 
43      TD      Chad    XAF     CFA Franc BEAC  950     \N      42
99217
 
77      TF      French Southern Territories     EUR     Euro    978     Ć¢Ā‚Ā¬     78
99218
 
217     TG      Togo    XOF     CFA Franc BCEAO 952     \N      212
99219
 
215     TH      Thailand        THB     Baht    764     Ć ĀøĀæ     211
99220
 
212     TJ      Tajikistan      TJS     Somoni  972     \N      209
99221
 
218     TK      Tokelau NZD     New Zealand Dollar      554     $       213
99222
 
216     TL      Timor-Leste     USD     US Dollar       840     $       62
99223
 
223     TM      Turkmenistan    TMM     Turkmenistan Manat      795     \N      218
99224
 
221     TN      Tunisia TND     Tunisian Dinar  788     \N      216
99225
 
219     TO      Tonga   TOP     Paanga  776     \N      214
99226
 
62      TP      East Timor      IDR     Indonesia Rupiah        360     \N      62
99227
 
222     TR      Turkey  TRY     New Turkish Lira        949     Ć¢Ā‚Ā¤     217
99228
 
220     TT      Trinidad And Tobago     TTD     Trinidad and Tobago Dollar      780     $       215
99229
 
225     TV      Tuvalu  AUD     Australian Dollar       36      $       220
99230
 
211     TW      Taiwan  TWD     New Taiwan Dollar       901     $       208
99231
 
213     TZ      Tanzania        TZS     Tanzanian Shilling      834     \N      210
99232
 
227     UA      Ukraine UAH     Hryvnia 980     \N      222
99233
 
226     UG      Uganda  UGX     Uganda Shilling 800     \N      221
99234
 
229     UK      United Kingdom  GBP     Pound Sterling  826     Ć‚Ā£      224
99235
 
232     UM      U.S. Minor Outlying Islands     USD     US Dollar       840     $       226
99236
 
230     US      United States   USD     US Dollar       840     $       225
99237
 
231     UY      Uruguay UYU     Peso Uruguayo   858     Ć¢Ā‚Ā±     227
99238
 
234     UZ      Uzbekistan      UZS     Uzbekistan Sum  860     \N      228
99239
 
95      VA      Holy See (Vatican City State)   EUR     Euro    978     Ć¢Ā‚Ā¬     230
99240
 
186     VC      Saint Vincent And The Grenadines        XCD     East Caribbean Dollar   951     $       182
99241
 
236     VE      Venezuela       VEB     Bolivar 862     \N      231
99242
 
32      VG      British Virgin Islands  USD     US Dollar       840     $       233
99243
 
233     VI      U.S. Virgin Islands     USD     US Dollar       840     $       234
99244
 
237     VN      Viet Nam        VND     Dong    704     Ć¢Ā‚Ā«     232
99245
 
235     VU      Vanuatu VUV     Vatu    548     \N      229
99246
 
238     WF      Wallis And Futuna       XPF     CFP Franc       953     \N      235
99247
 
187     WS      Samoa   WST     Tala    882     \N      183
99248
 
240     YE      Yemen   YER     Yemeni Rial     886     ĆÆĀ·Ā¼     237
99249
 
139     YT      Mayotte EUR     Euro    978     Ć¢Ā‚Ā¬     138
99250
 
200     ZA      South Africa    ZAR     Rand    710     R       195
99251
 
241     ZM      Zambia  ZMK     Zambian Kwacha  894     \N      239
99252
 
242     ZW      Zimbabwe        ZWD     Zimbabwe Dollar 716     $       240
99253
 
\.
99254
 
 
99255
 
 
99256
 
--
99257
 
--
99258
 
 
99259
 
SELECT pg_catalog.setval('country_country_id_seq', 242, true);
99260
 
 
99261
 
 
99262
 
--
99263
 
--
99264
 
 
99265
 
COPY crmacct (crmacct_id, crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_cust_id, crmacct_competitor_id, crmacct_partner_id, crmacct_prospect_id, crmacct_vend_id, crmacct_cntct_id_1, crmacct_cntct_id_2, crmacct_parent_id, crmacct_notes, crmacct_taxauth_id, crmacct_owner_username, crmacct_emp_id, crmacct_salesrep_id, crmacct_usr_username) FROM stdin;
99266
 
1       ADMIN   Administrator   t       I       \N      \N      \N      \N      \N      \N      \N      \N      \N      \N      \N      2       \N      admin
99267
 
2       MFGADMIN        OpenMFG Administrator   t       I       \N      \N      \N      \N      \N      \N      \N      \N      \N      \N      \N      1       \N      mfgadmin
99268
 
\.
99269
 
 
99270
 
 
99271
 
--
99272
 
--
99273
 
 
99274
 
SELECT pg_catalog.setval('crmacct_crmacct_id_seq', 24, true);
99275
 
 
99276
 
 
99277
 
--
99278
 
--
99279
 
 
99280
 
COPY crmacctsel (crmacctsel_src_crmacct_id, crmacctsel_dest_crmacct_id, crmacctsel_mrg_crmacct_active, crmacctsel_mrg_crmacct_cntct_id_1, crmacctsel_mrg_crmacct_cntct_id_2, crmacctsel_mrg_crmacct_competitor_id, crmacctsel_mrg_crmacct_cust_id, crmacctsel_mrg_crmacct_emp_id, crmacctsel_mrg_crmacct_name, crmacctsel_mrg_crmacct_notes, crmacctsel_mrg_crmacct_owner_username, crmacctsel_mrg_crmacct_parent_id, crmacctsel_mrg_crmacct_partner_id, crmacctsel_mrg_crmacct_prospect_id, crmacctsel_mrg_crmacct_salesrep_id, crmacctsel_mrg_crmacct_taxauth_id, crmacctsel_mrg_crmacct_type, crmacctsel_mrg_crmacct_usr_username, crmacctsel_mrg_crmacct_vend_id, crmacctsel_mrg_crmacct_number) FROM stdin;
99281
 
\.
99282
 
 
99283
 
 
99284
 
--
99285
 
--
99286
 
 
99287
 
COPY curr_rate (curr_rate_id, curr_id, curr_rate, curr_effective, curr_expires) FROM stdin;
99288
 
2       2       1.00000000      1970-01-01      2100-01-01
99289
 
\.
99290
 
 
99291
 
 
99292
 
--
99293
 
--
99294
 
 
99295
 
SELECT pg_catalog.setval('curr_rate_curr_rate_id_seq', 2, true);
99296
 
 
99297
 
 
99298
 
--
99299
 
--
99300
 
 
99301
 
COPY curr_symbol (curr_id, curr_base, curr_name, curr_symbol, curr_abbr) FROM stdin;
99302
 
2       f       US Dollars      $       USD
99303
 
\.
99304
 
 
99305
 
 
99306
 
--
99307
 
--
99308
 
 
99309
 
SELECT pg_catalog.setval('curr_symbol_curr_id_seq', 2, true);
99310
 
 
99311
 
 
99312
 
--
99313
 
--
99314
 
 
99315
 
SELECT pg_catalog.setval('cust_cust_id_seq', 94, true);
99316
 
 
99317
 
 
99318
 
--
99319
 
--
99320
 
 
99321
 
SELECT pg_catalog.setval('cust_serial_seq', 1, false);
99322
 
 
99323
 
 
99324
 
--
99325
 
--
99326
 
 
99327
 
COPY custform (custform_id, custform_custtype_id, custform_custtype, custform_invoice_report_id, custform_creditmemo_report_id, custform_quote_report_id, custform_packinglist_report_id, custform_statement_report_id, custform_sopicklist_report_id, custform_invoice_report_name, custform_creditmemo_report_name, custform_quote_report_name, custform_packinglist_report_name, custform_statement_report_name, custform_sopicklist_report_name) FROM stdin;
99328
 
\.
99329
 
 
99330
 
 
99331
 
--
99332
 
--
99333
 
 
99334
 
SELECT pg_catalog.setval('custform_custform_id_seq', 7, true);
99335
 
 
99336
 
 
99337
 
--
99338
 
--
99339
 
 
99340
 
COPY custgrp (custgrp_id, custgrp_name, custgrp_descrip) FROM stdin;
99341
 
\.
99342
 
 
99343
 
 
99344
 
--
99345
 
--
99346
 
 
99347
 
SELECT pg_catalog.setval('custgrp_custgrp_id_seq', 24, true);
99348
 
 
99349
 
 
99350
 
--
99351
 
--
99352
 
 
99353
 
COPY custgrpitem (custgrpitem_id, custgrpitem_custgrp_id, custgrpitem_cust_id) FROM stdin;
99354
 
\.
99355
 
 
99356
 
 
99357
 
--
99358
 
--
99359
 
 
99360
 
SELECT pg_catalog.setval('custgrpitem_custgrpitem_id_seq', 47, true);
99361
 
 
99362
 
 
99363
 
--
99364
 
--
99365
 
 
99366
 
COPY custinfo (cust_id, cust_active, cust_custtype_id, cust_salesrep_id, cust_commprcnt, cust_name, cust_creditlmt, cust_creditrating, cust_financecharge, cust_backorder, cust_partialship, cust_terms_id, cust_discntprcnt, cust_balmethod, cust_ffshipto, cust_shipform_id, cust_shipvia, cust_blanketpos, cust_shipchrg_id, cust_creditstatus, cust_comments, cust_ffbillto, cust_usespos, cust_number, cust_dateadded, cust_exported, cust_emaildelivery, cust_ediemail, cust_edisubject, cust_edifilename, cust_ediemailbody, cust_autoupdatestatus, cust_autoholdorders, cust_edicc, cust_ediprofile_id, cust_preferred_warehous_id, cust_curr_id, cust_creditlmt_curr_id, cust_cntct_id, cust_corrcntct_id, cust_soemaildelivery, cust_soediemail, cust_soedisubject, cust_soedifilename, cust_soediemailbody, cust_soedicc, cust_soediprofile_id, cust_gracedays, cust_ediemailhtml, cust_soediemailhtml, cust_taxzone_id, cust_statementcycle) FROM stdin;
99367
 
\.
99368
 
 
99369
 
 
99370
 
--
99371
 
--
99372
 
 
99373
 
COPY custtype (custtype_id, custtype_code, custtype_descrip, custtype_char) FROM stdin;
99374
 
\.
99375
 
 
99376
 
 
99377
 
--
99378
 
--
99379
 
 
99380
 
SELECT pg_catalog.setval('custtype_custtype_id_seq', 17, true);
99381
 
 
99382
 
 
99383
 
--
99384
 
--
99385
 
 
99386
 
COPY dept (dept_id, dept_number, dept_name) FROM stdin;
99387
 
\.
99388
 
 
99389
 
 
99390
 
--
99391
 
--
99392
 
 
99393
 
SELECT pg_catalog.setval('dept_dept_id_seq', 1, false);
99394
 
 
99395
 
 
99396
 
--
99397
 
--
99398
 
 
99399
 
COPY destination (destination_id, destination_name, destination_city, destination_state, destination_comments) FROM stdin;
99400
 
\.
99401
 
 
99402
 
 
99403
 
--
99404
 
--
99405
 
 
99406
 
SELECT pg_catalog.setval('destination_destination_id_seq', 12, true);
99407
 
 
99408
 
 
99409
 
--
99410
 
--
99411
 
 
99412
 
COPY docass (docass_id, docass_source_id, docass_source_type, docass_target_id, docass_target_type, docass_purpose) FROM stdin;
99413
 
\.
99414
 
 
99415
 
 
99416
 
--
99417
 
--
99418
 
 
99419
 
SELECT pg_catalog.setval('docass_docass_id_seq', 1, true);
99420
 
 
99421
 
 
99422
 
--
99423
 
--
99424
 
 
99425
 
COPY emp (emp_id, emp_code, emp_number, emp_active, emp_cntct_id, emp_warehous_id, emp_mgr_emp_id, emp_wage_type, emp_wage, emp_wage_curr_id, emp_wage_period, emp_dept_id, emp_shift_id, emp_notes, emp_image_id, emp_username, emp_extrate, emp_extrate_period, emp_startdate, emp_name) FROM stdin;
99426
 
2       ADMIN   admin   t       \N      \N      \N      H       \N      \N      H       \N      \N      \N      \N      admin   \N      H       \N      Administrator
99427
 
1       MFGADMIN        mfgadmin        t       \N      \N      \N      H       \N      \N      H       \N      \N      \N      \N      mfgadmin        \N      H       \N      OpenMFG Administrator
99428
 
\.
99429
 
 
99430
 
 
99431
 
--
99432
 
--
99433
 
 
99434
 
SELECT pg_catalog.setval('emp_emp_id_seq', 2, true);
99435
 
 
99436
 
 
99437
 
--
99438
 
--
99439
 
 
99440
 
COPY empgrp (empgrp_id, empgrp_name, empgrp_descrip) FROM stdin;
99441
 
\.
99442
 
 
99443
 
 
99444
 
--
99445
 
--
99446
 
 
99447
 
SELECT pg_catalog.setval('empgrp_empgrp_id_seq', 1, false);
99448
 
 
99449
 
 
99450
 
--
99451
 
--
99452
 
 
99453
 
COPY empgrpitem (empgrpitem_id, empgrpitem_empgrp_id, empgrpitem_emp_id) FROM stdin;
99454
 
\.
99455
 
 
99456
 
 
99457
 
--
99458
 
--
99459
 
 
99460
 
SELECT pg_catalog.setval('empgrpitem_empgrpitem_id_seq', 1, false);
99461
 
 
99462
 
 
99463
 
--
99464
 
--
99465
 
 
99466
 
COPY evntlog (evntlog_id, evntlog_evnttime, evntlog_evnttype_id, evntlog_ord_id, evntlog_dispatched, evntlog_action, evntlog_warehous_id, evntlog_number, evntlog_newvalue, evntlog_oldvalue, evntlog_newdate, evntlog_olddate, evntlog_ordtype, evntlog_username) FROM stdin;
99467
 
\.
99468
 
 
99469
 
 
99470
 
--
99471
 
--
99472
 
 
99473
 
SELECT pg_catalog.setval('evntlog_evntlog_id_seq', 262, true);
99474
 
 
99475
 
 
99476
 
--
99477
 
--
99478
 
 
99479
 
COPY evntnot (evntnot_id, evntnot_evnttype_id, evntnot_warehous_id, evntnot_username) FROM stdin;
99480
 
\.
99481
 
 
99482
 
 
99483
 
--
99484
 
--
99485
 
 
99486
 
SELECT pg_catalog.setval('evntnot_evntnot_id_seq', 781, true);
99487
 
 
99488
 
 
99489
 
--
99490
 
--
99491
 
 
99492
 
COPY evnttype (evnttype_id, evnttype_name, evnttype_descrip, evnttype_module) FROM stdin;
99493
 
1       WoDueDateChanged        Work Order Due Date Changed     W/O
99494
 
2       WoQtyChanged    Work Order Qty. Changed W/O
99495
 
3       WoCreated       Work Order Created      W/O
99496
 
4       QOHBelowZero    QOH Dropped to a Negative Value I/M
99497
 
5       RWoDueDateRequestChange Request to Change Released Due Date     W/O
99498
 
6       RWoQtyRequestChange     Request to Change Released W/O Qty.     W/O
99499
 
7       RWoRequestCancel        Request to Cancel Released W/O  W/O
99500
 
8       WoCancelled     Work Order Canceled     W/O
99501
 
9       CannotDistributeTransToGL       Cannot Distribute an Inventory Transaction to the G/L   G/L
99502
 
10      SoitemQtyChanged        Sales Order Qty. Changed        S/O
99503
 
11      SoitemCreated   Sales Order Item Added  S/O
99504
 
12      SoitemSchedDateChanged  Sales Order Item Ship Date Changed      S/O
99505
 
13      SoitemCancelled Sales Order Item Cancelled      S/O
99506
 
14      SoReleased      Sales Order Released    S/O
99507
 
33      POitemCreate    Purchase Order Purchased Item Line Added        P/O
99508
 
16      CannotConvertQuote      Cannot Convert a Quote to a Sales Order S/O
99509
 
17      DetachCCPayFromSO       Detached Credit Card payment from S/O   S/O
99510
 
18      WODoubleClockIn User clocked in to a Work Order without having previously clocked out   W/O
99511
 
19      WODoubleClockOut        User clocked out of a Work Order without having previously clocked in   W/O
99512
 
20      WOClockInOnClosedJob    User clocked in to a closed Work Order  W/O
99513
 
21      WOClockOutWNoClockIn    User clocked out of a Work Order on which s/he was not clocked in       W/O
99514
 
22      NewIncident     New Incident Created    CRM
99515
 
23      UpdatedIncident Incident Modified       CRM
99516
 
24      ClosedIncident  Incident Closed CRM
99517
 
25      ReopenedIncident        Incident Which had been closed previously is being reopened     CRM
99518
 
27      ToitemCreated   Transfer Order Item Created     I/M
99519
 
29      ToitemQtyChanged        Transfer Order Item Qty. Changed        I/M
99520
 
30      ToitemSchedDateChanged  Transfer Order Item Ship Date Changed   I/M
99521
 
31      ToitemNoDestItemSite    Transfer Order Item created without an Item Site at the Destination Warehouse.  I/M
99522
 
32      ToitemNoTransitItemSite Transfer Order Item created without an Item Site at the Transit Warehouse.      I/M
99523
 
28      ToitemCancelled Transfer Order Item Cancelled   I/M
99524
 
15      SoNotesChanged  Sales Order Order Comments Changed      S/O
99525
 
34      TodoAlarm       To-Do Item Alarm        CRM
99526
 
35      IncidentAlarm   Incident Alarm  CRM
99527
 
36      TaskAlarm       Project Task Alarm      CRM
99528
 
37      CostExceedsMaxDesired   Cost Exceeds Max Desired        P/D
99529
 
38      PoItemCreatedBySo       Purchase Order Item Created by a Sales Order    P/O
99530
 
39      PoItemUpdatedBySo       Purchase Order Item Updated by a Sales Order    P/O
99531
 
40      PoItemSoCancelled       The Sales Order item has been cancelled for a linked Purchase Item      P/O
99532
 
41      PoItemDropShipped       A Purchase Order Item has been Drop Shipped     P/O
99533
 
42      CashReceiptPosted       A Cash Receipt has been posted  G/L
99534
 
45      NewCustomer     A new Customer has been created S/O
99535
 
\.
99536
 
 
99537
 
 
99538
 
--
99539
 
--
99540
 
 
99541
 
SELECT pg_catalog.setval('evnttype_evnttype_id_seq', 45, true);
99542
 
 
99543
 
 
99544
 
--
99545
 
--
99546
 
 
99547
 
COPY expcat (expcat_id, expcat_code, expcat_descrip, expcat_exp_accnt_id, expcat_liability_accnt_id, expcat_active, expcat_purchprice_accnt_id, expcat_freight_accnt_id) FROM stdin;
99548
 
\.
99549
 
 
99550
 
 
99551
 
--
99552
 
--
99553
 
 
99554
 
SELECT pg_catalog.setval('expcat_expcat_id_seq', 14, true);
99555
 
 
99556
 
 
99557
 
--
99558
 
--
99559
 
 
99560
 
COPY file (file_id, file_title, file_stream, file_descrip) FROM stdin;
99561
 
\.
99562
 
 
99563
 
 
99564
 
--
99565
 
--
99566
 
 
99567
 
SELECT pg_catalog.setval('file_file_id_seq', 1, false);
99568
 
 
99569
 
 
99570
 
--
99571
 
--
99572
 
 
99573
 
COPY filter (filter_id, filter_screen, filter_value, filter_username, filter_name, filter_selected) FROM stdin;
99574
 
\.
99575
 
 
99576
 
 
99577
 
--
99578
 
--
99579
 
 
99580
 
SELECT pg_catalog.setval('filter_filter_id_seq', 1, false);
99581
 
 
99582
 
 
99583
 
--
99584
 
--
99585
 
 
99586
 
COPY fincharg (fincharg_id, fincharg_mincharg, fincharg_graceperiod, fincharg_assessoverdue, fincharg_calcfrom, fincharg_markoninvoice, fincharg_air, fincharg_accnt_id, fincharg_salescat_id, fincharg_lastfc_statementcyclefrom, fincharg_lastfc_custidfrom, fincharg_lastfc_custidto, fincharg_lastfc_statementcycleto) FROM stdin;
99587
 
\.
99588
 
 
99589
 
 
99590
 
--
99591
 
--
99592
 
 
99593
 
SELECT pg_catalog.setval('fincharg_fincharg_id_seq', 1, false);
99594
 
 
99595
 
 
99596
 
--
99597
 
--
99598
 
 
99599
 
COPY flcol (flcol_id, flcol_flhead_id, flcol_name, flcol_descrip, flcol_report_id, flcol_month, flcol_quarter, flcol_year, flcol_showdb, flcol_prcnt, flcol_priortype, flcol_priormonth, flcol_priorquarter, flcol_prioryear, flcol_priorprcnt, flcol_priordiff, flcol_priordiffprcnt, flcol_budget, flcol_budgetprcnt, flcol_budgetdiff, flcol_budgetdiffprcnt) FROM stdin;
99600
 
1       6       Current Current Month   335     t       f       f       f       t       P       f       f       N       f       f       f       f       f       f       f
99601
 
2       6       Current, Budget Current to Budget       336     t       f       f       f       f       P       f       f       N       f       f       f       t       f       t       t
99602
 
3       6       Current, Prior Month    Current to Prior Month End      337     t       f       f       f       f       P       t       f       N       f       t       t       f       f       f       f
99603
 
4       6       Current, Prior Quarter  Current to Prior Quarter End    346     t       f       f       f       f       P       f       t       N       f       t       t       f       f       f       f
99604
 
5       6       Current, Prior Year     Current to Prior Year End       338     t       f       f       f       f       P       f       f       F       f       t       t       f       f       f       f
99605
 
6       6       Current, Year Ago       Current to Month Prior Year     337     t       f       f       f       f       Y       t       f       N       f       t       t       f       f       f       f
99606
 
7       7       Month   Current Month   335     t       f       f       f       t       P       f       f       N       f       f       f       f       f       f       f
99607
 
8       7       Month, Budget   Current Month to Budget 336     t       f       f       f       f       P       f       f       N       f       f       f       t       f       t       t
99608
 
9       7       Month, Prior Month      Current Month to Prior Month    337     t       f       f       f       f       P       t       f       N       f       t       t       f       f       f       f
99609
 
10      7       Month, YTD      Month and Year to Date  334     t       f       t       f       t       P       f       f       N       f       f       f       f       f       f       f
99610
 
11      7       Month, QTD      Month and Quarter to Date       339     t       t       f       f       t       P       f       f       N       f       f       f       f       f       f       f
99611
 
12      7       QTD, Budget     Quarter to Date to Budget       341     f       t       f       f       f       P       f       f       N       f       f       f       t       f       t       t
99612
 
13      7       QTD, Prior Quarter      Quarter to Date to Prior Quarter        342     f       t       f       f       f       P       f       t       N       f       t       t       f       f       f       f
99613
 
14      7       YTD     Year To Date    343     f       f       t       f       t       P       f       f       N       f       f       f       f       f       f       f
99614
 
15      7       YTD, Budget     Year to Date to Budget  344     f       f       t       f       f       P       f       f       N       f       f       f       t       f       t       t
99615
 
16      7       YTD, Prior Full Year    Year to Date to Prior Full Year 345     f       f       t       f       f       P       f       f       F       f       t       t       f       f       f       f
99616
 
17      7       Month, Prior Year Month Current Month to Same Month Prior Year  337     t       f       f       f       f       Y       t       f       N       f       t       t       f       f       f       f
99617
 
19      7       YTD, Prior Year YTD     Year to Date to Year to Date Prior Year 345     f       f       t       f       f       P       f       f       D       f       t       t       f       f       f       f
99618
 
20      7       QTD     Quarter to Date 340     f       t       f       f       t       P       f       f       N       f       f       f       f       f       f       f
99619
 
18      7       QTD, Prior Year Quarter Quarter to Date to Same Quarter Prior Year      342     f       t       f       f       f       Y       f       t       N       f       t       t       f       f       f       f
99620
 
\.
99621
 
 
99622
 
 
99623
 
--
99624
 
--
99625
 
 
99626
 
SELECT pg_catalog.setval('flcol_flcol_id_seq', 20, true);
99627
 
 
99628
 
 
99629
 
--
99630
 
--
99631
 
 
99632
 
COPY flgrp (flgrp_id, flgrp_flhead_id, flgrp_flgrp_id, flgrp_order, flgrp_name, flgrp_descrip, flgrp_subtotal, flgrp_summarize, flgrp_subtract, flgrp_showstart, flgrp_showend, flgrp_showdelta, flgrp_showbudget, flgrp_showstartprcnt, flgrp_showendprcnt, flgrp_showdeltaprcnt, flgrp_showbudgetprcnt, flgrp_prcnt_flgrp_id, flgrp_showdiff, flgrp_showdiffprcnt, flgrp_showcustom, flgrp_showcustomprcnt, flgrp_usealtsubtotal, flgrp_altsubtotal) FROM stdin;
99633
 
2       3       -1      1       Revenue Revenue t       f       f       f       t       f       t       f       t       f       t       3       t       t       t       t       f       \N
99634
 
3       3       2       1       Sales   Sales   t       f       f       f       t       f       f       f       f       f       f       3       t       t       t       t       f       \N
99635
 
4       3       2       2       Cost of Goods Sold      Cost of Goods Sold      f       f       f       f       f       f       f       f       f       f       f       3       f       f       f       f       f       \N
99636
 
5       3       2       3       Gross Margin on Sales....................       Gross Margin on Sales....................       f       f       f       f       f       f       f       f       f       f       f       3       f       f       f       f       f       \N
99637
 
6       3       -1      2       Expenses        Expenses        f       f       t       f       f       f       f       f       f       f       f       3       f       f       f       f       f       \N
99638
 
7       3       6       1       Expenses        Expenses        t       f       f       f       t       f       t       f       t       f       t       3       t       t       t       t       f       \N
99639
 
8       3       -1      3       Net Income..............................        Net Income..............................        f       f       f       f       f       f       f       f       f       f       f       3       f       f       f       f       f       \N
99640
 
9       4       -1      2       Liabilities and Owner's Equity  Liabilities and Owner's Equity  t       f       t       f       t       f       f       f       f       f       f       -1      f       f       t       f       f       \N
99641
 
10      4       9       1       Liabilities     Liabilities     t       f       f       f       t       f       f       f       f       f       f       -1      f       f       t       f       f       \N
99642
 
11      4       10      1       Current Liabilities     Current Liabilities     t       f       f       f       t       f       f       f       f       f       f       -1      f       f       t       f       f       \N
99643
 
12      4       10      2       Long-Term Liabilities   Long-Term Liabilites    t       f       f       f       t       f       f       f       f       f       f       -1      f       f       t       f       f       \N
99644
 
13      4       9       2       Owner's Equity  Owner's Equity  t       f       f       f       t       f       f       f       f       f       f       -1      f       f       t       f       f       \N
99645
 
14      4       13      1       Shareholders' Equity    Shareholders' Equity    t       f       f       f       t       f       f       f       f       f       f       -1      f       f       t       f       f       \N
99646
 
15      4       13      2       Profit / Loss   Profit / Loss   t       t       f       f       t       f       f       f       f       f       f       -1      f       f       t       f       f       \N
99647
 
16      4       13      3       Retained Earnings       Retained Earnings       t       f       f       f       t       f       f       f       f       f       f       -1      f       f       t       f       f       \N
99648
 
17      4       -1      1       Assets  Assets  t       f       f       f       t       f       f       f       f       f       f       -1      f       f       t       f       f       \N
99649
 
18      4       17      1       Current Assets  Current Assets  t       f       f       f       t       f       f       f       f       f       f       -1      f       f       t       f       f       \N
99650
 
19      4       17      2       Fixed Assets    Fixed Assets    t       f       f       f       t       f       f       f       f       f       f       -1      f       f       t       f       f       \N
99651
 
20      4       17      3       Other Assets    Other Assets    t       f       f       f       t       f       f       f       f       f       f       -1      f       f       t       f       f       \N
99652
 
21      5       -1      1       Cash Flows      Cash Flows      t       f       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99653
 
22      5       21      1       Cash Flows from Operating Activities    Cash Flows from Operating Activities    t       f       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99654
 
23      5       22      1       Cash Flows From Operating Activities    Cash Flows From Operating Activities    t       f       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99655
 
24      5       23      1       Net Income      Net Income      f       t       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99656
 
25      5       22      2       Charges Not Using Cash  Charges Not Using Cash  t       f       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99657
 
26      5       22      3       Change in Current Assets        Change in Current Assets        f       f       t       f       f       f       f       f       f       f       f       -1      f       f       f       f       f       \N
99658
 
27      5       22      4       Short-Term Investments  Short-Term Investments  t       f       t       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99659
 
28      5       22      5       Net Receivables Net Receivables t       f       t       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99660
 
29      5       22      6       Inventory       Inventory       t       f       t       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99661
 
30      5       22      8       Change in Current Liabilities   Change in Current Liabilities   f       f       f       f       f       f       f       f       f       f       f       -1      f       f       f       f       f       \N
99662
 
31      5       22      9       Accounts Payable        Accounts Payable        t       f       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99663
 
32      5       22      7       Prepaid Expenses        Prepaid Expenses        t       f       t       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99664
 
33      5       22      10      Notes Payable Current   Notes Payable Current   t       f       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99665
 
34      5       22      11      Current Maturities on Long-Term Debt    Current Maturities on Long-Term Debt    t       f       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99666
 
35      5       22      12      Taxes Payable   Tases Payable   t       f       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99667
 
36      5       22      13      Other Current Liabilities       Other Current Liabilities       t       f       t       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99668
 
37      5       22      14      Total Cash Flows from Operating Activities..........    Total Cash Flows from Operating Activities..........    f       f       f       f       f       f       f       f       f       f       f       -1      f       f       f       f       f       \N
99669
 
38      5       21      2       Cash Flows from Investing Activities    Cash Flows from Investing Activities    t       f       t       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99670
 
39      5       38      1       Property, Plant, and Equipment  Property, Plant, and Equipment  t       f       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99671
 
40      5       38      2       Other Assets    Other Assets    t       f       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99672
 
41      5       38      3       Total Cash Flows from Investing Activities..........    Total Cash Flows from Investing Activities..........    f       f       f       f       f       f       f       f       f       f       f       -1      f       f       f       f       f       \N
99673
 
42      5       21      3       Cash Flows from Financing Activities    Cash Flows from Financing Activities    t       f       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99674
 
43      5       42      1       Long-Term Debt  Long-Term Debt  t       f       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99675
 
44      5       42      2       Common Stock and Equity Common Stock and Equity t       f       f       f       f       f       f       f       f       f       f       -1      t       f       t       f       f       \N
99676
 
45      5       42      3       Total Cash Flows from Financing Activities..........    Total Cash Flows from Financing Activities..........    f       f       f       f       f       f       f       f       f       f       f       -1      f       f       f       f       f       \N
99677
 
46      5       -1      2       Cash Position   Cash Position   f       f       f       f       f       f       f       f       f       f       f       -1      f       f       f       f       f       \N
99678
 
47      6       -1      1       ASSETS  ASSETS  t       f       f       f       t       f       t       f       f       f       f       -1      f       f       f       f       t       Total Assets
99679
 
48      6       -1      2       LIABILITIES AND OWNERS EQUITY   LIABILITIES AND OWNERS EQUITY   t       f       t       f       t       f       t       f       f       f       f       -1      f       f       f       f       t       Total Liabilities and Owners Equity
99680
 
49      6       48      1       LIABILITIES     LIABILITIES     t       f       f       f       t       f       t       f       t       f       t       -1      f       f       f       f       t       Total Liabilities
99681
 
50      6       48      2       OWNERS EQUITY   OWNERS EQUITY   t       f       f       f       t       f       t       f       t       f       t       -1      f       f       f       f       t       Total Owners Equity
99682
 
51      6       50      2       Net Income              f       t       f       f       t       f       t       f       t       f       t       -1      f       f       f       f       f       
99683
 
52      7       -1      1       INCOME  INCOME  t       f       f       f       f       f       t       f       f       f       f       -1      t       f       f       f       t       Net Income
99684
 
53      7       52      2       REVENUE REVENUE t       f       f       f       f       f       t       f       f       f       f       -1      t       f       f       f       t       Total Net Revenue
99685
 
54      7       52      3       EXPENSES        EXPENSES        t       f       t       f       f       f       t       f       f       f       f       -1      t       f       f       f       t       Total Net Expenses
99686
 
\.
99687
 
 
99688
 
 
99689
 
--
99690
 
--
99691
 
 
99692
 
SELECT pg_catalog.setval('flgrp_flgrp_id_seq', 54, true);
99693
 
 
99694
 
 
99695
 
--
99696
 
--
99697
 
 
99698
 
COPY flhead (flhead_id, flhead_name, flhead_descrip, flhead_showtotal, flhead_showstart, flhead_showend, flhead_showdelta, flhead_showbudget, flhead_showdiff, flhead_showcustom, flhead_custom_label, flhead_usealttotal, flhead_alttotal, flhead_usealtbegin, flhead_altbegin, flhead_usealtend, flhead_altend, flhead_usealtdebits, flhead_altdebits, flhead_usealtcredits, flhead_altcredits, flhead_usealtbudget, flhead_altbudget, flhead_usealtdiff, flhead_altdiff, flhead_type, flhead_active, flhead_sys, flhead_notes) FROM stdin;
99699
 
3       Income Statement (OpenMFG)      Income Statement Template       t       t       t       f       t       t       t       Statement       f       \N      f       \N      f       \N      f       \N      f       \N      f       \N      f       \N      A       t       f       
99700
 
4       Balance Sheet (OpenMFG) Balance Sheet Template  t       f       t       f       f       f       t       Statement       f       \N      f       \N      f       \N      f       \N      f       \N      f       \N      f       \N      A       t       f       
99701
 
5       Statement of Cash Flows (OpenMFG)       Statement of Cash Flows Template        t       f       f       f       f       t       t       Statement       f       \N      f       \N      f       \N      f       \N      f       \N      f       \N      f       \N      A       t       f       
99702
 
6       Basic Balance Sheet     Balance Sheet Template  f       f       f       f       f       f       f       \N      f       \N      f       \N      f       \N      f       \N      f       \N      f       \N      f       \N      B       t       t       
99703
 
7       Basic Income Statement  Income Statement Template       f       f       f       f       f       f       f               f               f               f               f               f               f               f               I       t       t       
99704
 
\.
99705
 
 
99706
 
 
99707
 
--
99708
 
--
99709
 
 
99710
 
SELECT pg_catalog.setval('flhead_flhead_id_seq', 7, true);
99711
 
 
99712
 
 
99713
 
--
99714
 
--
99715
 
 
99716
 
COPY flitem (flitem_id, flitem_flhead_id, flitem_flgrp_id, flitem_order, flitem_accnt_id, flitem_showstart, flitem_showend, flitem_showdelta, flitem_showbudget, flitem_subtract, flitem_showstartprcnt, flitem_showendprcnt, flitem_showdeltaprcnt, flitem_showbudgetprcnt, flitem_prcnt_flgrp_id, flitem_showdiff, flitem_showdiffprcnt, flitem_showcustom, flitem_showcustomprcnt, flitem_custom_source, flitem_company, flitem_profit, flitem_number, flitem_sub, flitem_type, flitem_subaccnttype_code) FROM stdin;
99717
 
2       6       47      1       -1      f       t       f       t       f       f       t       f       t       -1      t       f       f       f       S       All     All     All     All     A       All
99718
 
3       6       49      1       -1      f       t       f       t       f       f       t       f       t       -1      t       f       f       f       S       All     All     All     All     L       All
99719
 
4       6       50      1       -1      f       t       f       t       f       f       t       f       t       -1      t       f       f       f       S       All     All     All     All     Q       All
99720
 
5       6       51      1       -1      f       t       f       t       f       f       f       f       f       -1      t       f       f       f       S       All     All     All     All     R       All
99721
 
6       6       51      2       -1      f       t       f       t       t       f       f       f       f       -1      t       f       f       f       S       All     All     All     All     E       All
99722
 
7       7       53      1       -1      f       f       f       t       f       f       f       f       t       -1      t       t       f       f       S       All     All     All     All     R       All
99723
 
8       7       54      1       -1      f       f       f       t       f       f       f       f       t       -1      t       t       f       f       S       All     All     All     All     E       All
99724
 
\.
99725
 
 
99726
 
 
99727
 
--
99728
 
--
99729
 
 
99730
 
SELECT pg_catalog.setval('flitem_flitem_id_seq', 8, true);
99731
 
 
99732
 
 
99733
 
--
99734
 
--
99735
 
 
99736
 
COPY flnotes (flnotes_id, flnotes_flhead_id, flnotes_period_id, flnotes_notes) FROM stdin;
99737
 
\.
99738
 
 
99739
 
 
99740
 
--
99741
 
--
99742
 
 
99743
 
SELECT pg_catalog.setval('flnotes_flnotes_id_seq', 1, false);
99744
 
 
99745
 
 
99746
 
--
99747
 
--
99748
 
 
99749
 
COPY flrpt (flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_beginning, flrpt_ending, flrpt_debits, flrpt_credits, flrpt_budget, flrpt_beginningprcnt, flrpt_endingprcnt, flrpt_debitsprcnt, flrpt_creditsprcnt, flrpt_budgetprcnt, flrpt_parent_id, flrpt_diff, flrpt_diffprcnt, flrpt_custom, flrpt_customprcnt, flrpt_altname, flrpt_accnt_id, flrpt_interval, flrpt_id) FROM stdin;
99750
 
\.
99751
 
 
99752
 
 
99753
 
--
99754
 
--
99755
 
 
99756
 
SELECT pg_catalog.setval('flrpt_flrpt_id_seq', 1, false);
99757
 
 
99758
 
 
99759
 
--
99760
 
--
99761
 
 
99762
 
COPY flspec (flspec_id, flspec_flhead_id, flspec_flgrp_id, flspec_order, flspec_name, flspec_type, flspec_showstart, flspec_showend, flspec_showdelta, flspec_showbudget, flspec_subtract, flspec_showstartprcnt, flspec_showendprcnt, flspec_showdeltaprcnt, flspec_showbudgetprcnt, flspec_showdiff, flspec_showdiffprcnt, flspec_prcnt_flgrp_id, flspec_showcustom, flspec_showcustomprcnt, flspec_custom_source) FROM stdin;
99763
 
\.
99764
 
 
99765
 
 
99766
 
--
99767
 
--
99768
 
 
99769
 
SELECT pg_catalog.setval('flspec_flspec_id_seq', 1, false);
99770
 
 
99771
 
 
99772
 
--
99773
 
--
99774
 
 
99775
 
COPY form (form_id, form_name, form_descrip, form_report_id, form_key, form_report_name) FROM stdin;
99776
 
\.
99777
 
 
99778
 
 
99779
 
--
99780
 
--
99781
 
 
99782
 
SELECT pg_catalog.setval('form_form_id_seq', 18, true);
99783
 
 
99784
 
 
99785
 
--
99786
 
--
99787
 
 
99788
 
COPY freightclass (freightclass_id, freightclass_code, freightclass_descrip) FROM stdin;
99789
 
\.
99790
 
 
99791
 
 
99792
 
--
99793
 
--
99794
 
 
99795
 
SELECT pg_catalog.setval('freightclass_freightclass_id_seq', 1, false);
99796
 
 
99797
 
 
99798
 
--
99799
 
--
99800
 
 
99801
 
COPY glseries (glseries_id, glseries_sequence, glseries_doctype, glseries_docnumber, glseries_accnt_id, glseries_amount, glseries_source, glseries_distdate, glseries_notes, glseries_misc_id) FROM stdin;
99802
 
\.
99803
 
 
99804
 
 
99805
 
--
99806
 
--
99807
 
 
99808
 
SELECT pg_catalog.setval('glseries_glseries_id_seq', 1563, true);
99809
 
 
99810
 
 
99811
 
--
99812
 
--
99813
 
 
99814
 
COPY gltrans (gltrans_id, gltrans_exported, gltrans_created, gltrans_date, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_docnumber, gltrans_misc_id, gltrans_amount, gltrans_notes, gltrans_journalnumber, gltrans_posted, gltrans_doctype, gltrans_rec, gltrans_username, gltrans_deleted) FROM stdin;
99815
 
\.
99816
 
 
99817
 
 
99818
 
--
99819
 
--
99820
 
 
99821
 
SELECT pg_catalog.setval('gltrans_gltrans_id_seq', 7008, true);
99822
 
 
99823
 
 
99824
 
--
99825
 
--
99826
 
 
99827
 
SELECT pg_catalog.setval('gltrans_sequence_seq', 3583, true);
99828
 
 
99829
 
 
99830
 
--
99831
 
--
99832
 
 
99833
 
COPY grp (grp_id, grp_name, grp_descrip) FROM stdin;
99834
 
\.
99835
 
 
99836
 
 
99837
 
--
99838
 
--
99839
 
 
99840
 
SELECT pg_catalog.setval('grp_grp_id_seq', 1, false);
99841
 
 
99842
 
 
99843
 
--
99844
 
--
99845
 
 
99846
 
COPY grppriv (grppriv_id, grppriv_grp_id, grppriv_priv_id) FROM stdin;
99847
 
\.
99848
 
 
99849
 
 
99850
 
--
99851
 
--
99852
 
 
99853
 
SELECT pg_catalog.setval('grppriv_grppriv_id_seq', 1, false);
99854
 
 
99855
 
 
99856
 
--
99857
 
--
99858
 
 
99859
 
COPY hnfc (hnfc_id, hnfc_code) FROM stdin;
99860
 
1       Dr
99861
 
2       Miss
99862
 
3       Mr
99863
 
4       Mrs
99864
 
5       Ms
99865
 
\.
99866
 
 
99867
 
 
99868
 
--
99869
 
--
99870
 
 
99871
 
SELECT pg_catalog.setval('hnfc_hnfc_id_seq', 5, true);
99872
 
 
99873
 
 
99874
 
--
99875
 
--
99876
 
 
99877
 
COPY image (image_id, image_name, image_descrip, image_data) FROM stdin;
99878
 
14      Blue Pinstripe Background       Blue Pinstripe Background       begin 644 internal\nMB5!.1PT*&@H````-24A$4@````(````""`(```#]U)IS````"7!(67,```L2\nM```+$@'2W7[\\````%DE$050(F6-DLNUD8&!@\\?+R8F!@```-9P&L)F@250``\n*``!)14Y$KD)@@@``\n`\nend\n
99879
 
\.
99880
 
 
99881
 
 
99882
 
--
99883
 
--
99884
 
 
99885
 
SELECT pg_catalog.setval('image_image_id_seq', 6629, true);
99886
 
 
99887
 
 
99888
 
--
99889
 
--
99890
 
 
99891
 
COPY imageass (imageass_id, imageass_source_id, imageass_source, imageass_image_id, imageass_purpose) FROM stdin;
99892
 
\.
99893
 
 
99894
 
 
99895
 
--
99896
 
--
99897
 
 
99898
 
COPY incdt (incdt_id, incdt_number, incdt_crmacct_id, incdt_cntct_id, incdt_summary, incdt_descrip, incdt_item_id, incdt_timestamp, incdt_status, incdt_assigned_username, incdt_incdtcat_id, incdt_incdtseverity_id, incdt_incdtpriority_id, incdt_incdtresolution_id, incdt_lotserial, incdt_ls_id, incdt_aropen_id, incdt_owner_username, incdt_recurring_incdt_id, incdt_updated, incdt_prj_id, incdt_public) FROM stdin;
99899
 
\.
99900
 
 
99901
 
 
99902
 
--
99903
 
--
99904
 
 
99905
 
SELECT pg_catalog.setval('incdt_incdt_id_seq', 1, false);
99906
 
 
99907
 
 
99908
 
--
99909
 
--
99910
 
 
99911
 
COPY incdtcat (incdtcat_id, incdtcat_name, incdtcat_order, incdtcat_descrip, incdtcat_ediprofile_id) FROM stdin;
99912
 
\.
99913
 
 
99914
 
 
99915
 
--
99916
 
--
99917
 
 
99918
 
SELECT pg_catalog.setval('incdtcat_incdtcat_id_seq', 1, false);
99919
 
 
99920
 
 
99921
 
--
99922
 
--
99923
 
 
99924
 
COPY incdthist (incdthist_id, incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_timestamp, incdthist_username, incdthist_descrip) FROM stdin;
99925
 
\.
99926
 
 
99927
 
 
99928
 
--
99929
 
--
99930
 
 
99931
 
SELECT pg_catalog.setval('incdthist_incdthist_id_seq', 1, false);
99932
 
 
99933
 
 
99934
 
--
99935
 
--
99936
 
 
99937
 
COPY incdtpriority (incdtpriority_id, incdtpriority_name, incdtpriority_order, incdtpriority_descrip) FROM stdin;
99938
 
2       High    1       \N
99939
 
3       Normal  2       \N
99940
 
4       Low     3       \N
99941
 
5       Very Low        4       \N
99942
 
1       Very High       0       \N
99943
 
\.
99944
 
 
99945
 
 
99946
 
--
99947
 
--
99948
 
 
99949
 
SELECT pg_catalog.setval('incdtpriority_incdtpriority_id_seq', 5, true);
99950
 
 
99951
 
 
99952
 
--
99953
 
--
99954
 
 
99955
 
COPY incdtresolution (incdtresolution_id, incdtresolution_name, incdtresolution_order, incdtresolution_descrip) FROM stdin;
99956
 
1       Fixed   0       \N
99957
 
2       Duplicate       1       \N
99958
 
3       Not Fixable     2       \N
99959
 
4       Won't Fix       3       \N
99960
 
\.
99961
 
 
99962
 
 
99963
 
--
99964
 
--
99965
 
 
99966
 
SELECT pg_catalog.setval('incdtresolution_incdtresolution_id_seq', 4, true);
99967
 
 
99968
 
 
99969
 
--
99970
 
--
99971
 
 
99972
 
COPY incdtseverity (incdtseverity_id, incdtseverity_name, incdtseverity_order, incdtseverity_descrip) FROM stdin;
99973
 
1       Trivial 0       \N
99974
 
2       Minor   1       \N
99975
 
3       Normal  2       \N
99976
 
4       Severe  3       \N
99977
 
5       Critical        4       \N
99978
 
\.
99979
 
 
99980
 
 
99981
 
--
99982
 
--
99983
 
 
99984
 
SELECT pg_catalog.setval('incdtseverity_incdtseverity_id_seq', 5, true);
99985
 
 
99986
 
 
99987
 
--
99988
 
--
99989
 
 
99990
 
COPY invbal (invbal_id, invbal_period_id, invbal_itemsite_id, invbal_qoh_beginning, invbal_qoh_ending, invbal_qty_in, invbal_qty_out, invbal_value_beginning, invbal_value_ending, invbal_value_in, invbal_value_out, invbal_nn_beginning, invbal_nn_ending, invbal_nn_in, invbal_nn_out, invbal_nnval_beginning, invbal_nnval_ending, invbal_nnval_in, invbal_nnval_out, invbal_dirty) FROM stdin;
99991
 
\.
99992
 
 
99993
 
 
99994
 
--
99995
 
--
99996
 
 
99997
 
SELECT pg_catalog.setval('invbal_invbal_id_seq', 1, false);
99998
 
 
99999
 
 
100000
 
--
100001
 
--
100002
 
 
100003
 
SELECT pg_catalog.setval('invc_invc_id_seq', 1, false);
100004
 
 
100005
 
 
100006
 
--
100007
 
--
100008
 
 
100009
 
COPY invchead (invchead_id, invchead_cust_id, invchead_shipto_id, invchead_ordernumber, invchead_orderdate, invchead_posted, invchead_printed, invchead_invcnumber, invchead_invcdate, invchead_shipdate, invchead_ponumber, invchead_shipvia, invchead_fob, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_phone, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_phone, invchead_salesrep_id, invchead_commission, invchead_terms_id, invchead_freight, invchead_misc_amount, invchead_misc_descrip, invchead_misc_accnt_id, invchead_payment, invchead_paymentref, invchead_notes, invchead_billto_country, invchead_shipto_country, invchead_prj_id, invchead_curr_id, invchead_gldistdate, invchead_recurring, invchead_recurring_interval, invchead_recurring_type, invchead_recurring_until, invchead_recurring_invchead_id, invchead_shipchrg_id, invchead_taxzone_id, invchead_void, invchead_saletype_id, invchead_shipzone_id) FROM stdin;
100010
 
\.
100011
 
 
100012
 
 
100013
 
--
100014
 
--
100015
 
 
100016
 
SELECT pg_catalog.setval('invchead_invchead_id_seq', 1, false);
100017
 
 
100018
 
 
100019
 
--
100020
 
--
100021
 
 
100022
 
COPY invcheadtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin;
100023
 
\.
100024
 
 
100025
 
 
100026
 
--
100027
 
--
100028
 
 
100029
 
COPY invcitem (invcitem_id, invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_custprice, invcitem_price, invcitem_notes, invcitem_salescat_id, invcitem_taxtype_id, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_coitem_id, invcitem_updateinv, invcitem_rev_accnt_id) FROM stdin;
100030
 
\.
100031
 
 
100032
 
 
100033
 
--
100034
 
--
100035
 
 
100036
 
SELECT pg_catalog.setval('invcitem_invcitem_id_seq', 1, false);
100037
 
 
100038
 
 
100039
 
--
100040
 
--
100041
 
 
100042
 
COPY invcitemtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin;
100043
 
\.
100044
 
 
100045
 
 
100046
 
--
100047
 
--
100048
 
 
100049
 
COPY invcnt (invcnt_id, invcnt_itemsite_id, invcnt_tagdate, invcnt_cntdate, invcnt_qoh_before, invcnt_qoh_after, invcnt_matcost, invcnt_posted, invcnt_postdate, invcnt_comments, invcnt_priority, invcnt_tagnumber, invcnt_invhist_id, invcnt_location_id, invcnt_cnt_username, invcnt_post_username, invcnt_tag_username) FROM stdin;
100050
 
\.
100051
 
 
100052
 
 
100053
 
--
100054
 
--
100055
 
 
100056
 
SELECT pg_catalog.setval('invcnt_invcnt_id_seq', 213, true);
100057
 
 
100058
 
 
100059
 
--
100060
 
--
100061
 
 
100062
 
COPY invdetail (invdetail_id, invdetail_transtype, invdetail_invhist_id, invdetail_location_id, invdetail_qty, invdetail_comments, invdetail_qty_before, invdetail_qty_after, invdetail_invcitem_id, invdetail_expiration, invdetail_warrpurc, invdetail_ls_id) FROM stdin;
100063
 
\.
100064
 
 
100065
 
 
100066
 
--
100067
 
--
100068
 
 
100069
 
SELECT pg_catalog.setval('invdetail_invdetail_id_seq', 1326, true);
100070
 
 
100071
 
 
100072
 
--
100073
 
--
100074
 
 
100075
 
COPY invhist (invhist_id, invhist_itemsite_id, invhist_transdate, invhist_transtype, invhist_invqty, invhist_invuom, invhist_ordnumber, invhist_docnumber, invhist_qoh_before, invhist_qoh_after, invhist_unitcost, invhist_acct_id, invhist_xfer_warehous_id, invhist_comments, invhist_posted, invhist_imported, invhist_hasdetail, invhist_ordtype, invhist_analyze, invhist_user, invhist_created, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series) FROM stdin;
100076
 
\.
100077
 
 
100078
 
 
100079
 
--
100080
 
--
100081
 
 
100082
 
SELECT pg_catalog.setval('invhist_invhist_id_seq', 2859, true);
100083
 
 
100084
 
 
100085
 
--
100086
 
--
100087
 
 
100088
 
COPY invhistexpcat (invhistexpcat_id, invhistexpcat_invhist_id, invhistexpcat_expcat_id) FROM stdin;
100089
 
\.
100090
 
 
100091
 
 
100092
 
--
100093
 
--
100094
 
 
100095
 
SELECT pg_catalog.setval('invhistexpcat_invhistexpcat_id_seq', 1, false);
100096
 
 
100097
 
 
100098
 
--
100099
 
--
100100
 
 
100101
 
COPY ipsass (ipsass_id, ipsass_ipshead_id, ipsass_cust_id, ipsass_custtype_id, ipsass_custtype_pattern, ipsass_shipto_id, ipsass_shipto_pattern) FROM stdin;
100102
 
\.
100103
 
 
100104
 
 
100105
 
--
100106
 
--
100107
 
 
100108
 
SELECT pg_catalog.setval('ipsass_ipsass_id_seq', 1, false);
100109
 
 
100110
 
 
100111
 
--
100112
 
--
100113
 
 
100114
 
SELECT pg_catalog.setval('ipsctyp_ipsctyp_id_seq', 16, true);
100115
 
 
100116
 
 
100117
 
--
100118
 
--
100119
 
 
100120
 
SELECT pg_catalog.setval('ipscust_ipscust_id_seq', 21, true);
100121
 
 
100122
 
 
100123
 
--
100124
 
--
100125
 
 
100126
 
COPY ipsfreight (ipsfreight_id, ipsfreight_ipshead_id, ipsfreight_qtybreak, ipsfreight_price, ipsfreight_type, ipsfreight_warehous_id, ipsfreight_shipzone_id, ipsfreight_freightclass_id, ipsfreight_shipvia) FROM stdin;
100127
 
\.
100128
 
 
100129
 
 
100130
 
--
100131
 
--
100132
 
 
100133
 
SELECT pg_catalog.setval('ipsfreight_ipsfreight_id_seq', 1, false);
100134
 
 
100135
 
 
100136
 
--
100137
 
--
100138
 
 
100139
 
COPY ipshead (ipshead_id, ipshead_name, ipshead_descrip, ipshead_effective, ipshead_expires, ipshead_curr_id, ipshead_updated) FROM stdin;
100140
 
\.
100141
 
 
100142
 
 
100143
 
--
100144
 
--
100145
 
 
100146
 
SELECT pg_catalog.setval('ipshead_ipshead_id_seq', 58, true);
100147
 
 
100148
 
 
100149
 
--
100150
 
--
100151
 
 
100152
 
SELECT pg_catalog.setval('ipsitem_ipsitem_id_seq', 75, true);
100153
 
 
100154
 
 
100155
 
--
100156
 
--
100157
 
 
100158
 
COPY ipsitemchar (ipsitemchar_id, ipsitemchar_ipsitem_id, ipsitemchar_char_id, ipsitemchar_value, ipsitemchar_price) FROM stdin;
100159
 
\.
100160
 
 
100161
 
 
100162
 
--
100163
 
--
100164
 
 
100165
 
SELECT pg_catalog.setval('ipsitemchar_ipsitemchar_id_seq', 1, false);
100166
 
 
100167
 
 
100168
 
--
100169
 
--
100170
 
 
100171
 
COPY ipsiteminfo (ipsitem_id, ipsitem_ipshead_id, ipsitem_item_id, ipsitem_qtybreak, ipsitem_price, ipsitem_qty_uom_id, ipsitem_price_uom_id, ipsitem_discntprcnt, ipsitem_fixedamtdiscount, ipsitem_prodcat_id, ipsitem_type, ipsitem_warehous_id) FROM stdin;
100172
 
\.
100173
 
 
100174
 
 
100175
 
--
100176
 
--
100177
 
 
100178
 
COPY ipsprodcat_bak (ipsprodcat_id, ipsprodcat_ipshead_id, ipsprodcat_prodcat_id, ipsprodcat_qtybreak, ipsprodcat_discntprcnt, ipsprodcat_fixedamtdiscount) FROM stdin;
100179
 
\.
100180
 
 
100181
 
 
100182
 
--
100183
 
--
100184
 
 
100185
 
SELECT pg_catalog.setval('ipsprodcat_ipsprodcat_id_seq', 1, false);
100186
 
 
100187
 
 
100188
 
--
100189
 
--
100190
 
 
100191
 
COPY item (item_id, item_number, item_descrip1, item_descrip2, item_classcode_id, item_picklist, item_comments, item_sold, item_fractional, item_active, item_type, item_prodweight, item_packweight, item_prodcat_id, item_exclusive, item_listprice, item_config, item_extdescrip, item_upccode, item_maxcost, item_inv_uom_id, item_price_uom_id, item_warrdays, item_freightclass_id, item_tax_recoverable, item_listcost) FROM stdin;
100192
 
\.
100193
 
 
100194
 
 
100195
 
--
100196
 
--
100197
 
 
100198
 
SELECT pg_catalog.setval('item_item_id_seq', 299, true);
100199
 
 
100200
 
 
100201
 
--
100202
 
--
100203
 
 
100204
 
COPY itemalias (itemalias_id, itemalias_item_id, itemalias_number, itemalias_comments, itemalias_usedescrip, itemalias_descrip1, itemalias_descrip2, itemalias_crmacct_id) FROM stdin;
100205
 
\.
100206
 
 
100207
 
 
100208
 
--
100209
 
--
100210
 
 
100211
 
SELECT pg_catalog.setval('itemalias_itemalias_id_seq', 15, true);
100212
 
 
100213
 
 
100214
 
--
100215
 
--
100216
 
 
100217
 
SELECT pg_catalog.setval('itematr_itematr_id_seq', 29, true);
100218
 
 
100219
 
 
100220
 
--
100221
 
--
100222
 
 
100223
 
COPY itemcost (itemcost_id, itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated, itemcost_curr_id) FROM stdin;
100224
 
\.
100225
 
 
100226
 
 
100227
 
--
100228
 
--
100229
 
 
100230
 
SELECT pg_catalog.setval('itemcost_itemcost_id_seq', 299, true);
100231
 
 
100232
 
 
100233
 
--
100234
 
--
100235
 
 
100236
 
SELECT pg_catalog.setval('itemfrez_itemfrez_seq', 1, false);
100237
 
 
100238
 
 
100239
 
--
100240
 
--
100241
 
 
100242
 
COPY itemgrp (itemgrp_id, itemgrp_name, itemgrp_descrip, itemgrp_catalog) FROM stdin;
100243
 
\.
100244
 
 
100245
 
 
100246
 
--
100247
 
--
100248
 
 
100249
 
SELECT pg_catalog.setval('itemgrp_itemgrp_id_seq', 19, true);
100250
 
 
100251
 
 
100252
 
--
100253
 
--
100254
 
 
100255
 
COPY itemgrpitem (itemgrpitem_id, itemgrpitem_itemgrp_id, itemgrpitem_item_id, itemgrpitem_item_type) FROM stdin;
100256
 
\.
100257
 
 
100258
 
 
100259
 
--
100260
 
--
100261
 
 
100262
 
SELECT pg_catalog.setval('itemgrpitem_itemgrpitem_id_seq', 112, true);
100263
 
 
100264
 
 
100265
 
--
100266
 
--
100267
 
 
100268
 
SELECT pg_catalog.setval('itemimage_itemimage_id_seq', 20, true);
100269
 
 
100270
 
 
100271
 
--
100272
 
--
100273
 
 
100274
 
COPY itemloc (itemloc_id, itemloc_itemsite_id, itemloc_location_id, itemloc_qty, itemloc_expiration, itemloc_consolflag, itemloc_ls_id, itemloc_warrpurc) FROM stdin;
100275
 
\.
100276
 
 
100277
 
 
100278
 
--
100279
 
--
100280
 
 
100281
 
SELECT pg_catalog.setval('itemloc_itemloc_id_seq', 511, true);
100282
 
 
100283
 
 
100284
 
--
100285
 
--
100286
 
 
100287
 
SELECT pg_catalog.setval('itemloc_series_seq', 1022, true);
100288
 
 
100289
 
 
100290
 
--
100291
 
--
100292
 
 
100293
 
COPY itemlocdist (itemlocdist_id, itemlocdist_itemlocdist_id, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_qty, itemlocdist_series, itemlocdist_invhist_id, itemlocdist_itemsite_id, itemlocdist_reqlotserial, itemlocdist_flush, itemlocdist_expiration, itemlocdist_distlotserial, itemlocdist_warranty, itemlocdist_ls_id, itemlocdist_order_type, itemlocdist_order_id) FROM stdin;
100294
 
\.
100295
 
 
100296
 
 
100297
 
--
100298
 
--
100299
 
 
100300
 
SELECT pg_catalog.setval('itemlocdist_itemlocdist_id_seq', 2133, true);
100301
 
 
100302
 
 
100303
 
--
100304
 
--
100305
 
 
100306
 
COPY itemlocpost (itemlocpost_id, itemlocpost_itemlocseries, itemlocpost_glseq) FROM stdin;
100307
 
\.
100308
 
 
100309
 
 
100310
 
--
100311
 
--
100312
 
 
100313
 
SELECT pg_catalog.setval('itemlocpost_itemlocpost_id_seq', 1, false);
100314
 
 
100315
 
 
100316
 
--
100317
 
--
100318
 
 
100319
 
SELECT pg_catalog.setval('itemopn_itemopn_id_seq', 39, true);
100320
 
 
100321
 
 
100322
 
--
100323
 
--
100324
 
 
100325
 
COPY itemsite (itemsite_id, itemsite_item_id, itemsite_warehous_id, itemsite_qtyonhand, itemsite_reorderlevel, itemsite_ordertoqty, itemsite_cyclecountfreq, itemsite_datelastcount, itemsite_datelastused, itemsite_loccntrl, itemsite_safetystock, itemsite_minordqty, itemsite_multordqty, itemsite_leadtime, itemsite_abcclass, itemsite_issuemethod, itemsite_controlmethod, itemsite_active, itemsite_plancode_id, itemsite_costcat_id, itemsite_eventfence, itemsite_sold, itemsite_stocked, itemsite_freeze, itemsite_location_id, itemsite_useparams, itemsite_useparamsmanual, itemsite_soldranking, itemsite_createpr, itemsite_location, itemsite_location_comments, itemsite_notes, itemsite_perishable, itemsite_autoabcclass, itemsite_ordergroup, itemsite_disallowblankwip, itemsite_maxordqty, itemsite_mps_timefence, itemsite_createwo, itemsite_warrpurc, itemsite_autoreg, itemsite_costmethod, itemsite_value, itemsite_ordergroup_first, itemsite_supply_itemsite_id, itemsite_planning_type, itemsite_wosupply, itemsite_posupply, itemsite_lsseq_id, itemsite_cosdefault, itemsite_createsopr, itemsite_createsopo, itemsite_dropship, itemsite_recvlocation_id, itemsite_issuelocation_id, itemsite_location_dist, itemsite_recvlocation_dist, itemsite_issuelocation_dist) FROM stdin;
100326
 
\.
100327
 
 
100328
 
 
100329
 
--
100330
 
--
100331
 
 
100332
 
SELECT pg_catalog.setval('itemsite_itemsite_id_seq', 292, true);
100333
 
 
100334
 
 
100335
 
--
100336
 
--
100337
 
 
100338
 
COPY itemsrc (itemsrc_id, itemsrc_item_id, itemsrc_vend_id, itemsrc_vend_item_number, itemsrc_vend_item_descrip, itemsrc_comments, itemsrc_vend_uom, itemsrc_invvendoruomratio, itemsrc_minordqty, itemsrc_multordqty, itemsrc_leadtime, itemsrc_ranking, itemsrc_active, itemsrc_manuf_name, itemsrc_manuf_item_number, itemsrc_manuf_item_descrip, itemsrc_default, itemsrc_upccode, itemsrc_effective, itemsrc_expires, itemsrc_contrct_id, itemsrc_contrct_max, itemsrc_contrct_min) FROM stdin;
100339
 
\.
100340
 
 
100341
 
 
100342
 
--
100343
 
--
100344
 
 
100345
 
SELECT pg_catalog.setval('itemsrc_itemsrc_id_seq', 83, true);
100346
 
 
100347
 
 
100348
 
--
100349
 
--
100350
 
 
100351
 
COPY itemsrcp (itemsrcp_id, itemsrcp_itemsrc_id, itemsrcp_qtybreak, itemsrcp_price, itemsrcp_updated, itemsrcp_curr_id, itemsrcp_dropship, itemsrcp_warehous_id, itemsrcp_type, itemsrcp_discntprcnt, itemsrcp_fixedamtdiscount) FROM stdin;
100352
 
\.
100353
 
 
100354
 
 
100355
 
--
100356
 
--
100357
 
 
100358
 
SELECT pg_catalog.setval('itemsrcp_itemsrcp_id_seq', 84, true);
100359
 
 
100360
 
 
100361
 
--
100362
 
--
100363
 
 
100364
 
COPY itemsub (itemsub_id, itemsub_parent_item_id, itemsub_sub_item_id, itemsub_uomratio, itemsub_rank) FROM stdin;
100365
 
\.
100366
 
 
100367
 
 
100368
 
--
100369
 
--
100370
 
 
100371
 
SELECT pg_catalog.setval('itemsub_itemsub_id_seq', 16, true);
100372
 
 
100373
 
 
100374
 
--
100375
 
--
100376
 
 
100377
 
COPY itemtax (itemtax_id, itemtax_item_id, itemtax_taxtype_id, itemtax_taxzone_id) FROM stdin;
100378
 
\.
100379
 
 
100380
 
 
100381
 
--
100382
 
--
100383
 
 
100384
 
SELECT pg_catalog.setval('itemtax_itemtax_id_seq', 1, false);
100385
 
 
100386
 
 
100387
 
--
100388
 
--
100389
 
 
100390
 
COPY itemtrans (itemtrans_id, itemtrans_source_item_id, itemtrans_target_item_id) FROM stdin;
100391
 
\.
100392
 
 
100393
 
 
100394
 
--
100395
 
--
100396
 
 
100397
 
SELECT pg_catalog.setval('itemtrans_itemtrans_id_seq', 1, false);
100398
 
 
100399
 
 
100400
 
--
100401
 
--
100402
 
 
100403
 
COPY itemuom (itemuom_id, itemuom_itemuomconv_id, itemuom_uomtype_id) FROM stdin;
100404
 
\.
100405
 
 
100406
 
 
100407
 
--
100408
 
--
100409
 
 
100410
 
SELECT pg_catalog.setval('itemuom_itemuom_id_seq', 1, false);
100411
 
 
100412
 
 
100413
 
--
100414
 
--
100415
 
 
100416
 
COPY itemuomconv (itemuomconv_id, itemuomconv_item_id, itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value, itemuomconv_fractional) FROM stdin;
100417
 
\.
100418
 
 
100419
 
 
100420
 
--
100421
 
--
100422
 
 
100423
 
SELECT pg_catalog.setval('itemuomconv_itemuomconv_id_seq', 1, false);
100424
 
 
100425
 
 
100426
 
--
100427
 
--
100428
 
 
100429
 
SELECT pg_catalog.setval('journal_number_seq', 2274, true);
100430
 
 
100431
 
 
100432
 
--
100433
 
--
100434
 
 
100435
 
COPY jrnluse (jrnluse_id, jrnluse_date, jrnluse_number, jrnluse_use) FROM stdin;
100436
 
\.
100437
 
 
100438
 
 
100439
 
--
100440
 
--
100441
 
 
100442
 
SELECT pg_catalog.setval('jrnluse_jrnluse_id_seq', 280, true);
100443
 
 
100444
 
 
100445
 
--
100446
 
--
100447
 
 
100448
 
COPY labeldef (labeldef_id, labeldef_name, labeldef_papersize, labeldef_columns, labeldef_rows, labeldef_width, labeldef_height, labeldef_start_offset_x, labeldef_start_offset_y, labeldef_horizontal_gap, labeldef_vertical_gap) FROM stdin;
100449
 
1       Avery 5263      Letter  2       5       400     200     25      50      0       0
100450
 
2       Avery 5264      Letter  2       3       400     333     25      75      0       0
100451
 
3       Avery 8460      Letter  3       10      262     100     32      50      0       0
100452
 
4       CILS ALP1-9200-1        Letter  3       7       200     100     62      62      81      50
100453
 
\.
100454
 
 
100455
 
 
100456
 
--
100457
 
--
100458
 
 
100459
 
SELECT pg_catalog.setval('labeldef_labeldef_id_seq', 4, true);
100460
 
 
100461
 
 
100462
 
--
100463
 
--
100464
 
 
100465
 
COPY labelform (labelform_id, labelform_name, labelform_report_id, labelform_perpage, labelform_report_name) FROM stdin;
100466
 
\.
100467
 
 
100468
 
 
100469
 
--
100470
 
--
100471
 
 
100472
 
SELECT pg_catalog.setval('labelform_labelform_id_seq', 6, true);
100473
 
 
100474
 
 
100475
 
--
100476
 
--
100477
 
 
100478
 
COPY lang (lang_id, lang_qt_number, lang_abbr3, lang_abbr2, lang_name) FROM stdin;
100479
 
1       3       \N      \N      Afan
100480
 
2       156     \N      \N      Atsam
100481
 
3       16      \N      \N      Bhutani
100482
 
4       22      \N      \N      Byelorussian
100483
 
5       23      \N      \N      Cambodian
100484
 
6       158     \N      \N      Jju
100485
 
7       154     \N      \N      Koro
100486
 
8       68      \N      \N      Kurundi
100487
 
9       69      \N      \N      Laothian
100488
 
10      101     \N      \N      SerboCroatian
100489
 
11      102     \N      \N      Sesotho
100490
 
12      103     \N      \N      Setswana
100491
 
13      107     \N      \N      Siswati
100492
 
14      164     \N      \N      Tyap
100493
 
15      \N      ace     \N      Achinese
100494
 
16      \N      ach     \N      Acoli
100495
 
17      \N      ada     \N      Adangme
100496
 
18      \N      ady     \N      Adyghe; Adygei
100497
 
19      \N      afa     \N      Afro-Asiatic.(Other)
100498
 
20      \N      afh     \N      Afrihili
100499
 
21      \N      ain     \N      Ainu
100500
 
22      \N      akk     \N      Akkadian
100501
 
23      \N      ale     \N      Aleut
100502
 
24      \N      alg     \N      Algonquian languages
100503
 
25      \N      alt     \N      Southern Altai
100504
 
26      \N      ang     \N      English, Old (ca.450-1100)
100505
 
27      \N      anp     \N      Angika
100506
 
28      \N      apa     \N      Apache languages
100507
 
29      \N      arc     \N      Official Aramaic (700-300 BCE); Imperial Aramaic (700-300 BCE)
100508
 
30      \N      arn     \N      Mapudungun; Mapuche
100509
 
31      \N      arp     \N      Arapaho
100510
 
32      \N      art     \N      Artificial (Other)
100511
 
33      \N      arw     \N      Arawak
100512
 
34      \N      ast     \N      Asturian; Bable; Leonese; Asturleonese
100513
 
35      \N      ath     \N      Athapascan languages
100514
 
36      \N      aus     \N      Australian languages
100515
 
37      \N      awa     \N      Awadhi
100516
 
38      \N      bad     \N      Banda languages
100517
 
39      \N      bai     \N      Bamileke languages
100518
 
40      \N      bal     \N      Baluchi
100519
 
41      \N      ban     \N      Balinese
100520
 
42      \N      bas     \N      Basa
100521
 
43      \N      bat     \N      Baltic (Other)
100522
 
44      \N      bej     \N      Beja; Bedawiyet
100523
 
45      \N      bem     \N      Bemba
100524
 
46      \N      ber     \N      Berber (Other)
100525
 
47      \N      bho     \N      Bhojpuri
100526
 
48      \N      bik     \N      Bikol
100527
 
49      \N      bin     \N      Bini; Edo
100528
 
50      \N      bla     \N      Siksika
100529
 
51      \N      bnt     \N      Bantu (Other)
100530
 
52      \N      bra     \N      Braj
100531
 
53      \N      btk     \N      Batak languages
100532
 
54      \N      bua     \N      Buriat
100533
 
55      \N      bug     \N      Buginese
100534
 
56      152     byn     \N      Blin; Bilin
100535
 
57      \N      cad     \N      Caddo
100536
 
58      \N      cai     \N      Central American Indian (Other)
100537
 
59      \N      car     \N      Galibi Carib
100538
 
60      \N      cau     \N      Caucasian (Other)
100539
 
61      \N      ceb     \N      Cebuano
100540
 
62      \N      cel     \N      Celtic (Other)
100541
 
63      \N      chb     \N      Chibcha
100542
 
64      \N      chg     \N      Chagatai
100543
 
65      \N      chk     \N      Chuukese
100544
 
66      \N      chm     \N      Mari
100545
 
67      \N      chn     \N      Chinook jargon
100546
 
68      \N      cho     \N      Choctaw
100547
 
69      \N      chp     \N      Chipewyan; Dene Suline
100548
 
70      \N      chr     \N      Cherokee
100549
 
71      \N      chy     \N      Cheyenne
100550
 
72      \N      cmc     \N      Chamic languages
100551
 
73      \N      cop     \N      Coptic
100552
 
74      \N      cpe     \N      Creoles and pidgins, English-based (Other)
100553
 
75      \N      cpf     \N      Creoles and pidgins, French-based (Other)
100554
 
76      \N      cpp     \N      Creoles and pidgins, Portuguese-based (Other)
100555
 
77      \N      crh     \N      Crimean Tatar; Crimean Turkish
100556
 
78      \N      crp     \N      Creoles and pidgins (Other)
100557
 
79      \N      csb     \N      Kashubian
100558
 
80      \N      cus     \N      Cushitic (Other)
100559
 
81      \N      dak     \N      Dakota
100560
 
82      \N      dar     \N      Dargwa
100561
 
83      \N      day     \N      Land Dayak languages
100562
 
84      \N      del     \N      Delaware
100563
 
85      \N      den     \N      Slave (Athapascan)
100564
 
86      \N      dgr     \N      Dogrib
100565
 
87      \N      din     \N      Dinka
100566
 
88      \N      doi     \N      Dogri
100567
 
89      \N      dra     \N      Dravidian (Other)
100568
 
90      \N      dsb     \N      Lower Sorbian
100569
 
91      \N      dua     \N      Duala
100570
 
92      \N      dum     \N      Dutch, Middle (ca.1050-1350)
100571
 
93      \N      dyu     \N      Dyula
100572
 
94      \N      efi     \N      Efik
100573
 
95      \N      egy     \N      Egyptian (Ancient)
100574
 
96      \N      eka     \N      Ekajuk
100575
 
97      \N      elx     \N      Elamite
100576
 
98      \N      enm     \N      English, Middle (1100-1500)
100577
 
99      \N      ewo     \N      Ewondo
100578
 
100     \N      fan     \N      Fang
100579
 
101     \N      fat     \N      Fanti
100580
 
102     \N      fil     \N      Filipino; Pilipino
100581
 
103     \N      fiu     \N      Finno-Ugrian (Other)
100582
 
104     \N      fon     \N      Fon
100583
 
105     \N      frm     \N      French, Middle (ca.1400-1600)
100584
 
106     \N      fro     \N      French, Old (842-ca.1400)
100585
 
107     38      frr     \N      Northern Frisian
100586
 
108     38      frs     \N      Eastern Frisian
100587
 
109     159     fur     \N      Friulian
100588
 
110     148     gaa     \N      Ga
100589
 
111     \N      gay     \N      Gayo
100590
 
112     \N      gba     \N      Gbaya
100591
 
113     \N      gem     \N      Germanic (Other)
100592
 
114     153     gez     \N      Geez
100593
 
115     \N      gil     \N      Gilbertese
100594
 
116     \N      gmh     \N      German, Middle High (ca.1050-1500)
100595
 
117     \N      goh     \N      German, Old High (ca.750-1050)
100596
 
118     \N      gon     \N      Gondi
100597
 
119     \N      gor     \N      Gorontalo
100598
 
120     \N      got     \N      Gothic
100599
 
121     \N      grb     \N      Grebo
100600
 
122     \N      grc     \N      Greek, Ancient (to 1453)
100601
 
123     \N      gsw     \N      Swiss German; Alemannic; Alsatian
100602
 
124     \N      gwi     \N      Gwich'in
100603
 
125     \N      hai     \N      Haida
100604
 
126     163     haw     \N      Hawaiian
100605
 
127     \N      hil     \N      Hiligaynon
100606
 
128     \N      him     \N      Himachali
100607
 
129     \N      hit     \N      Hittite
100608
 
130     \N      hmn     \N      Hmong
100609
 
131     \N      hsb     \N      Upper Sorbian
100610
 
132     \N      hup     \N      Hupa hupa
100611
 
133     \N      iba     \N      Iban
100612
 
134     \N      ijo     \N      Ijo languages
100613
 
135     \N      ilo     \N      Iloko
100614
 
136     \N      inc     \N      Indic (Other)
100615
 
137     \N      ine     \N      Indo-European (Other)
100616
 
138     \N      inh     \N      Ingush
100617
 
139     \N      ira     \N      Iranian (Other)
100618
 
140     \N      iro     \N      Iroquoian languages
100619
 
141     \N      jbo     \N      Lojban
100620
 
142     \N      jpr     \N      Judeo-Persian
100621
 
143     \N      jrb     \N      Judeo-Arabic
100622
 
144     \N      kaa     \N      Kara-Kalpak
100623
 
145     \N      kab     \N      Kabyle
100624
 
146     \N      kac     \N      Kachin; Jingpho
100625
 
147     150     kam     \N      Kamba
100626
 
148     \N      kar     \N      Karen languages
100627
 
149     \N      kaw     \N      Kawi
100628
 
150     \N      kbd     \N      Kabardian
100629
 
151     \N      kha     \N      Khasi
100630
 
152     \N      khi     \N      Khoisan (Other)
100631
 
153     \N      kho     \N      Khotanese
100632
 
154     \N      kmb     \N      Kimbundu
100633
 
155     147     kok     \N      Konkani
100634
 
156     \N      kos     \N      Kosraean
100635
 
157     \N      kpe     \N      Kpelle
100636
 
158     \N      krc     \N      Karachay-Balkar
100637
 
159     \N      krl     \N      Karelian
100638
 
160     \N      kro     \N      Kru languages
100639
 
161     \N      kru     \N      Kurukh
100640
 
162     \N      kum     \N      Kumyk
100641
 
163     \N      kut     \N      Kutenai
100642
 
164     \N      lad     \N      Ladino
100643
 
165     \N      lah     \N      Lahnda
100644
 
166     \N      lam     \N      Lamba
100645
 
167     \N      lez     \N      Lezghian
100646
 
168     \N      lol     \N      Mongo
100647
 
169     \N      loz     \N      Lozi
100648
 
170     \N      lua     \N      Luba-Lulua
100649
 
171     \N      lui     \N      Luiseno
100650
 
172     \N      lun     \N      Lunda
100651
 
173     \N      luo     \N      Luo (Kenya and Tanzania)
100652
 
174     \N      lus     \N      Lushai
100653
 
175     \N      mad     \N      Madurese
100654
 
176     \N      mag     \N      Magahi
100655
 
177     \N      mai     \N      Maithili
100656
 
178     \N      mak     \N      Makasar
100657
 
179     \N      man     \N      Mandingo
100658
 
180     \N      map     \N      Austronesian (Other)
100659
 
181     \N      mas     \N      Masai
100660
 
182     \N      mdf     \N      Moksha
100661
 
183     \N      mdr     \N      Mandar
100662
 
184     \N      men     \N      Mende
100663
 
185     \N      mga     \N      Irish, Middle (900-1200)
100664
 
186     \N      mic     \N      Mi'kmaq; Micmac
100665
 
187     \N      min     \N      Minangkabau
100666
 
188     \N      mis     \N      Uncoded languages
100667
 
189     \N      mkh     \N      Mon-Khmer (Other)
100668
 
190     \N      mnc     \N      Manchu
100669
 
191     \N      mni     \N      Manipuri
100670
 
192     \N      mno     \N      Manobo languages
100671
 
193     \N      moh     \N      Mohawk
100672
 
194     \N      mos     \N      Mossi
100673
 
195     \N      mul     \N      Multiple languages
100674
 
196     \N      mun     \N      Munda languages
100675
 
197     \N      mus     \N      Creek
100676
 
198     \N      mwl     \N      Mirandese
100677
 
199     \N      mwr     \N      Marwari
100678
 
200     \N      myn     \N      Mayan languages
100679
 
201     \N      myv     \N      Erzya
100680
 
202     \N      nah     \N      Nahuatl languages
100681
 
203     \N      nai     \N      North American Indian
100682
 
204     \N      nap     \N      Neapolitan
100683
 
205     \N      nds     \N      Low German; Low Saxon; German, Low; Saxon, Low
100684
 
206     \N      new     \N      Nepal Bhasa; Newari
100685
 
207     \N      nia     \N      Nias
100686
 
208     \N      nic     \N      Niger-Kordofanian (Other)
100687
 
209     \N      niu     \N      Niuean
100688
 
210     \N      nog     \N      Nogai
100689
 
211     \N      non     \N      Norse, Old
100690
 
212     \N      nqo     \N      N'Ko
100691
 
213     \N      nso     \N      Pedi; Sepedi; Northern Sotho
100692
 
214     \N      nub     \N      Nubian languages
100693
 
215     \N      nwc     \N      Classical Newari; Old Newari; Classical Nepal Bhasa
100694
 
216     \N      nym     \N      Nyamwezi
100695
 
217     \N      nyn     \N      Nyankole
100696
 
218     \N      nyo     \N      Nyoro
100697
 
219     \N      nzi     \N      Nzima
100698
 
220     \N      osa     \N      Osage
100699
 
221     \N      ota     \N      Turkish, Ottoman (1500-1928)
100700
 
222     \N      oto     \N      Otomian languages
100701
 
223     \N      paa     \N      Papuan (Other)
100702
 
224     \N      pag     \N      Pangasinan
100703
 
225     \N      pal     \N      Pahlavi
100704
 
226     \N      pam     \N      Pampanga; Kapampangan
100705
 
227     \N      pap     \N      Papiamento
100706
 
228     \N      pau     \N      Palauan
100707
 
229     \N      peo     \N      Persian, Old (ca.600-400 B.C.)
100708
 
230     \N      phi     \N      Philippine (Other)
100709
 
231     \N      phn     \N      Phoenician
100710
 
232     \N      pon     \N      Pohnpeian
100711
 
233     \N      pra     \N      Prakrit languages
100712
 
234     \N      pro     \N      Provencal, Old (to 1500)
100713
 
235     \N      raj     \N      Rajasthani
100714
 
236     \N      rap     \N      Rapanui
100715
 
237     \N      rar     \N      Rarotongan; Cook Islands Maori
100716
 
238     \N      roa     \N      Romance (Other)
100717
 
239     \N      rom     \N      Romany
100718
 
240     \N      rup     \N      Aromanian; Arumanian; Macedo-Romanian
100719
 
241     \N      sad     \N      Sandawe
100720
 
242     \N      sah     \N      Yakut
100721
 
243     \N      sai     \N      South American Indian (Other)
100722
 
244     \N      sal     \N      Salishan languages
100723
 
245     \N      sam     \N      Samaritan Aramaic
100724
 
246     \N      sas     \N      Sasak
100725
 
247     \N      sat     \N      Santali
100726
 
248     \N      scn     \N      Sicilian
100727
 
249     \N      sco     \N      Scots
100728
 
250     \N      sel     \N      Selkup
100729
 
251     \N      sem     \N      Semitic (Other)
100730
 
252     \N      sga     \N      Irish, Old (to 900)
100731
 
253     \N      sgn     \N      Sign languages
100732
 
254     \N      shn     \N      Shan
100733
 
255     155     sid     \N      Sidamo
100734
 
256     \N      sio     \N      Siouan languages
100735
 
257     \N      sit     \N      Sino-Tibetan (Other)
100736
 
258     \N      sla     \N      Slavic (Other)
100737
 
259     \N      sma     \N      Southern Sami
100738
 
260     \N      smi     \N      Sami languages (Other)
100739
 
261     \N      smj     \N      Lule Sami
100740
 
262     \N      smn     \N      Inari Sami
100741
 
263     \N      sms     \N      Skolt Sami
100742
 
264     \N      snk     \N      Soninke
100743
 
265     \N      sog     \N      Sogdian
100744
 
266     \N      son     \N      Songhai languages
100745
 
267     \N      srn     \N      Sranan Tongo
100746
 
268     \N      srr     \N      Serer
100747
 
269     \N      ssa     \N      Nilo-Saharan (Other)
100748
 
270     \N      suk     \N      Sukuma
100749
 
271     \N      sus     \N      Susu
100750
 
272     \N      sux     \N      Sumerian
100751
 
273     \N      syc     \N      Classical Syriac
100752
 
274     151     syr     \N      Syriac
100753
 
275     \N      tai     \N      Tai (Other)
100754
 
276     \N      tem     \N      Timne
100755
 
277     \N      ter     \N      Tereno
100756
 
278     \N      tet     \N      Tetum
100757
 
279     157     tig     \N      Tigre
100758
 
280     \N      tiv     \N      Tiv
100759
 
281     \N      tkl     \N      Tokelau
100760
 
282     \N      tlh     \N      Klingon
100761
 
283     \N      tli     \N      Tlingit
100762
 
284     \N      tmh     \N      Tamashek
100763
 
285     \N      tog     \N      Tonga (Nyasa)
100764
 
286     \N      tpi     \N      Tok Pisin
100765
 
287     \N      tsi     \N      Tsimshian
100766
 
288     \N      tum     \N      Tumbuka
100767
 
289     \N      tup     \N      Tupi languages
100768
 
290     \N      tut     \N      Altaic (Other)
100769
 
291     \N      tvl     \N      Tuvalu
100770
 
292     \N      tyv     \N      Tuvinian
100771
 
293     \N      udm     \N      Udmurt
100772
 
294     \N      uga     \N      Ugaritic
100773
 
295     \N      umb     \N      Umbundu
100774
 
296     \N      und     \N      Undetermined
100775
 
297     \N      vai     \N      Vai
100776
 
298     \N      vot     \N      Votic
100777
 
299     \N      wak     \N      Wakashan languages
100778
 
300     162     wal     \N      Walamo
100779
 
301     \N      war     \N      Waray
100780
 
302     \N      was     \N      Washo
100781
 
303     \N      wen     \N      Sorbian languages
100782
 
304     \N      xal     \N      Kalmyk; Oirat
100783
 
305     \N      yao     \N      Yao
100784
 
306     \N      yap     \N      Yapese
100785
 
307     \N      ypk     \N      Yupik languages
100786
 
308     \N      zap     \N      Zapotec
100787
 
309     \N      zbl     \N      Blissymbols; Blissymbolics; Bliss
100788
 
310     \N      zen     \N      Zenaga
100789
 
311     \N      znd     \N      Zande languages
100790
 
312     \N      zun     \N      Zuni
100791
 
313     \N      zxx     \N      No linguistic content
100792
 
314     \N      zza     \N      Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki
100793
 
315     4       aar     aa      Afar
100794
 
316     2       abk     ab      Abkhazian
100795
 
317     \N      ave     ae      Avestan
100796
 
318     5       afr     af      Afrikaans
100797
 
319     146     aka     ak      Akan
100798
 
320     7       amh     am      Amharic
100799
 
321     \N      arg     an      Aragonese
100800
 
322     8       ara     ar      Arabic
100801
 
323     10      asm     as      Assamese
100802
 
324     \N      ava     av      Avaric
100803
 
325     11      aym     ay      Aymara
100804
 
326     12      aze     az      Azerbaijani
100805
 
327     13      bak     ba      Bashkir
100806
 
328     \N      bel     be      Belarusian
100807
 
329     20      bul     bg      Bulgarian
100808
 
330     17      bih     bh      Bihari
100809
 
331     18      bis     bi      Bislama
100810
 
332     \N      bam     bm      Bambara
100811
 
333     15      ben     bn      Bengali
100812
 
334     121     bod     bo      Tibetan
100813
 
335     19      bre     br      Breton
100814
 
336     142     bos     bs      Bosnian
100815
 
337     24      cat     ca      Catalan; Valencian
100816
 
338     \N      che     ce      Chechen
100817
 
339     \N      cha     ch      Chamorro
100818
 
340     26      cos     co      Corsican
100819
 
341     \N      cre     cr      Cree
100820
 
342     28      ces     cs      Czech
100821
 
343     \N      chu     cu      Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic
100822
 
344     \N      chv     cv      Chuvash
100823
 
345     134     cym     cy      Welsh
100824
 
346     29      dan     da      Danish
100825
 
347     42      deu     de      German
100826
 
348     143     div     dv      Divehi; Dhivehi; Maldivian
100827
 
349     \N      dzo     dz      Dzongkha
100828
 
350     161     ewe     ee      Ewe
100829
 
351     42      ell     el      Greek, Modern (1453-)
100830
 
352     31      eng     en      English
100831
 
353     32      epo     eo      Esperanto
100832
 
354     111     spa     es      Spanish; Castilian
100833
 
355     33      est     et      Estonian
100834
 
356     14      eus     eu      Basque
100835
 
357     89      fas     fa      Persian
100836
 
358     \N      ful     ff      Fulah
100837
 
359     36      fin     fi      Finnish
100838
 
360     35      fij     fj      Fijian
100839
 
361     34      fao     fo      Faroese
100840
 
362     37      fra     fr      French
100841
 
363     38      fry     fy      Western Frisian
100842
 
364     57      gle     ga      Irish
100843
 
365     39      gla     gd      Gaelic; Scottish Gaelic
100844
 
366     40      glg     gl      Galician
100845
 
367     45      grn     gn      Guarani
100846
 
368     46      guj     gu      Gujarati
100847
 
369     144     glv     gv      Manx
100848
 
370     47      hau     ha      Hausa
100849
 
371     48      heb     he      Hebrew
100850
 
372     49      hin     hi      Hindi
100851
 
373     \N      hmo     ho      Hiri Motu
100852
 
374     27      hrv     hr      Croatian
100853
 
375     \N      hat     ht      Haitian; Haitian Creole
100854
 
376     50      hun     hu      Hungarian
100855
 
377     9       hye     hy      Armenian
100856
 
378     \N      her     hz      Herero
100857
 
379     53      ina     ia      Interlingua (International Auxiliary language Association)
100858
 
380     52      ind     id      Indonesian
100859
 
381     54      ile     ie      Interlingue; Occidental
100860
 
382     149     ibo     ig      Igbo
100861
 
383     \N      iii     ii      Sichuan Yi; Nuosu
100862
 
384     56      ipk     ik      Inupiaq
100863
 
385     \N      ido     io      Ido
100864
 
386     51      isl     is      Icelandic
100865
 
387     58      ita     it      Italian
100866
 
388     55      iku     iu      Inuktitut
100867
 
389     59      jpn     ja      Japanese
100868
 
390     60      jav     jv      Javanese
100869
 
391     41      kat     ka      Georgian
100870
 
392     \N      kon     kg      Kongo
100871
 
393     \N      kik     ki      Kikuyu; Gikuyu
100872
 
394     \N      kua     kj      Kuanyama; Kwanyama
100873
 
395     63      kaz     kk      Kazakh
100874
 
396     44      kal     kl      Kalaallisut; Greenlandic
100875
 
397     \N      khm     km      Central Khmer
100876
 
398     61      kan     kn      Kannada
100877
 
399     66      kor     ko      Korean
100878
 
400     \N      kau     kr      Kanuri
100879
 
401     62      kas     ks      Kashmiri
100880
 
402     67      kur     ku      Kurdish
100881
 
403     \N      kom     kv      Komi
100882
 
404     145     cor     kw      Cornish
100883
 
405     65      kir     ky      Kirghiz; Kyrgyz
100884
 
406     70      lat     la      Latin
100885
 
407     \N      ltz     lb      Luxembourgish; Letzeburgesch
100886
 
408     \N      lug     lg      Ganda
100887
 
409     \N      lim     li      Limburgan; Limburger; Limburgish
100888
 
410     72      lin     ln      Lingala
100889
 
411     \N      lao     lo      Lao
100890
 
412     73      lit     lt      Lithuanian
100891
 
413     \N      lub     lu      Luba-Katanga
100892
 
414     71      lav     lv      Latvian
100893
 
415     75      mlg     mg      Malagasy
100894
 
416     \N      mah     mh      Marshallese
100895
 
417     79      mri     mi      Maori
100896
 
418     74      mkd     mk      Macedonian
100897
 
419     77      mal     ml      Malayalam
100898
 
420     82      mon     mn      Mongolian
100899
 
421     81      mol     mo      Moldavian
100900
 
422     80      mar     mr      Marathi
100901
 
423     76      msa     ms      Malay
100902
 
424     78      mlt     mt      Maltese
100903
 
425     21      mya     my      Burmese
100904
 
426     83      nau     na      Nauru
100905
 
427     85      nob     nb      Bokmal, Norwegian; Norwegian Bokmal
100906
 
428     \N      nde     nd      Ndebele, North; North Ndebele
100907
 
429     84      nep     ne      Nepali
100908
 
430     \N      ndo     ng      Ndonga
100909
 
431     30      nld     nl      Dutch; Flemish
100910
 
432     141     nno     nn      Norwegian Nynorsk; Nynorsk, Norwegian
100911
 
433     141     nor     no      Norwegian
100912
 
434     \N      nbl     nr      Ndebele, South; South Ndebele
100913
 
435     \N      nav     nv      Navajo; Navaho
100914
 
436     165     nya     ny      Chichewa; Chewa; Nyanja
100915
 
437     86      oci     oc      Occitan (post 1500); Provencal
100916
 
438     \N      oji     oj      Ojibwa
100917
 
439     \N      orm     om      Oromo
100918
 
440     87      ori     or      Oriya
100919
 
441     \N      oss     os      Ossetian; Ossetic
100920
 
442     92      pan     pa      Panjabi; Punjabi
100921
 
443     \N      pli     pi      Pali
100922
 
444     90      pol     pl      Polish
100923
 
445     88      pus     ps      Pushto; Pashto
100924
 
446     91      por     pt      Portuguese
100925
 
447     93      que     qu      Quechua
100926
 
448     94      roh     rm      Romansh
100927
 
449     \N      run     rn      Rundi
100928
 
450     95      ron     ro      Romanian
100929
 
451     96      rus     ru      Russian
100930
 
452     64      kin     rw      Kinyarwanda
100931
 
453     99      san     sa      Sanskrit
100932
 
454     \N      srd     sc      Sardinian
100933
 
455     105     snd     sd      Sindhi
100934
 
456     \N      sme     se      Northern Sami
100935
 
457     98      sag     sg      Sango
100936
 
458     106     sin     si      Sinhala; Sinhalese
100937
 
459     108     slk     sk      Slovak
100938
 
460     109     slv     sl      Slovenian
100939
 
461     97      smo     sm      Samoan
100940
 
462     104     sna     sn      Shona
100941
 
463     110     som     so      Somali
100942
 
464     6       sqi     sq      Albanian
100943
 
465     100     srp     sr      Serbian
100944
 
466     \N      ssw     ss      Swati
100945
 
467     \N      sot     st      Sotho, Southern
100946
 
468     112     sun     su      Sundanese
100947
 
469     114     swe     sv      Swedish
100948
 
470     113     swa     sw      Swahili
100949
 
471     117     tam     ta      Tamil
100950
 
472     119     tel     te      Telugu
100951
 
473     116     tgk     tg      Tajik
100952
 
474     120     tha     th      Thai
100953
 
475     122     tir     ti      Tigrinya
100954
 
476     126     tuk     tk      Turkmen
100955
 
477     115     tgl     tl      Tagalog
100956
 
478     \N      tsn     tn      Tswana
100957
 
479     123     ton     to      Tonga (Tonga Islands)
100958
 
480     125     tur     tr      Turkish
100959
 
481     124     tso     ts      Tsonga
100960
 
482     118     tat     tt      Tatar
100961
 
483     127     twi     tw      Twi
100962
 
484     \N      tah     ty      Tahitian
100963
 
485     128     uig     ug      Uighur; Uyghur
100964
 
486     129     ukr     uk      Ukrainian
100965
 
487     130     urd     ur      Urdu
100966
 
488     131     uzb     uz      Uzbek
100967
 
489     160     ven     ve      Venda
100968
 
490     132     vie     vi      Vietnamese
100969
 
491     133     vol     vo      Volapak
100970
 
492     \N      wln     wa      Walloon
100971
 
493     135     wol     wo      Wolof
100972
 
494     136     xho     xh      Xhosa
100973
 
495     137     yid     yi      Yiddish
100974
 
496     138     yor     yo      Yoruba
100975
 
497     139     zha     za      Zhuang; Chuang
100976
 
498     25      zho     zh      Chinese
100977
 
499     140     zul     zu      Zulu
100978
 
\.
100979
 
 
100980
 
 
100981
 
--
100982
 
--
100983
 
 
100984
 
SELECT pg_catalog.setval('lang_lang_id_seq', 499, true);
100985
 
 
100986
 
 
100987
 
--
100988
 
--
100989
 
 
100990
 
COPY locale (locale_id, locale_code, locale_descrip, locale_lang_file, locale_dateformat, locale_currformat, locale_qtyformat, locale_comments, locale_qtyperformat, locale_salespriceformat, locale_extpriceformat, locale_timeformat, locale_timestampformat, local_costformat, locale_costformat, locale_purchpriceformat, locale_uomratioformat, locale_intervalformat, locale_lang_id, locale_country_id, locale_error_color, locale_warning_color, locale_emphasis_color, locale_altemphasis_color, locale_expired_color, locale_future_color, locale_curr_scale, locale_salesprice_scale, locale_purchprice_scale, locale_extprice_scale, locale_cost_scale, locale_qty_scale, locale_qtyper_scale, locale_uomratio_scale, locale_percent_scale, locale_weight_scale) FROM stdin;
100991
 
3       Default Default Locale          DD Mon YYYY     999,999,990.00  .-              999,999,990.0000        999,999,990.0000        999,999,990.00  HH:MI:SS        DD Mon YYYY HH:MI:SS    \N      999,999,990.0000        999,999,990.0000        999,999,990.00000       HH:MI:SS        -1      -1                                                      2       4       4       2       4       2       4       5       2       2
100992
 
4       Spanish Locale for Mexican Spanish      OpenMFG.mx.sp   DD Mon YYYY     999999990.00    .-              999999990.0000  999999990.0000  999999990.00    HH:MI:SS        DD Mon YYYY HH:MI:SS    \N      999999990.0000                  HH:MI:SS        -1      -1                                                      2       4       0       2       4       2       4       0       2       2
100993
 
\.
100994
 
 
100995
 
 
100996
 
--
100997
 
--
100998
 
 
100999
 
SELECT pg_catalog.setval('locale_locale_id_seq', 27, true);
101000
 
 
101001
 
 
101002
 
--
101003
 
--
101004
 
 
101005
 
COPY location (location_id, location_warehous_id, location_name, location_descrip, location_restrict, location_netable, location_whsezone_id, location_aisle, location_rack, location_bin, location_formatname, location_usable) FROM stdin;
101006
 
\.
101007
 
 
101008
 
 
101009
 
--
101010
 
--
101011
 
 
101012
 
SELECT pg_catalog.setval('location_location_id_seq', 121, true);
101013
 
 
101014
 
 
101015
 
--
101016
 
--
101017
 
 
101018
 
COPY locitem (locitem_id, locitem_location_id, locitem_item_id) FROM stdin;
101019
 
\.
101020
 
 
101021
 
 
101022
 
--
101023
 
--
101024
 
 
101025
 
SELECT pg_catalog.setval('locitem_locitem_id_seq', 21, true);
101026
 
 
101027
 
 
101028
 
--
101029
 
--
101030
 
 
101031
 
SELECT pg_catalog.setval('log_log_id_seq', 747, true);
101032
 
 
101033
 
 
101034
 
--
101035
 
--
101036
 
 
101037
 
COPY metasql (metasql_id, metasql_group, metasql_name, metasql_notes, metasql_query, metasql_lastuser, metasql_lastupdate, metasql_grade) FROM stdin;
101038
 
2       enterPoReceipt  poItemReceivingsFillList                -- Group:enterPoReceipt\n-- Name:poItemReceivingsFillList\n-- Notes:\n\n<? if exists("pohead_id") ?>\nSELECT poitem_id, poitem_linenumber,\n       formatDate(poitem_duedate),\n       COALESCE(item_number, <? value("nonInventory") ?>),\n       COALESCE(uom_name, <? value("na") ?>),\n       warehous_code,\n       poitem_vend_item_number,\n       poitem_vend_uom,\n       formatQty(poitem_qty_ordered),\n       formatQty(poitem_qty_received),\n       formatQty(qtyToReceive(<? value("ordertype") ?>, poitem_id))\nFROM poitem \n  LEFT OUTER JOIN \n     ( itemsite \n<? if exists("selectedOnly") ?>\n       JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n<? endif ?>\n       JOIN item ON (itemsite_item_id=item_id) \n       JOIN uom ON (item_inv_uom_id=uom_id)\n       JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n     ) ON (poitem_itemsite_id=itemsite_id) \nWHERE ( (poitem_status <> 'C')\n<? if exists("selectedOnly") ?>\n AND (usrsite_username=current_user) \n<? endif ?>\n AND (poitem_pohead_id=<? value("pohead_id") ?>) )\nORDER BY poitem_linenumber;\n<? elseif exists("rahead_id") ?>\nSELECT raitem_id, raitem_linenumber,\n       formatDate(rahead_expiredate),\n       COALESCE(item_number, <? value("nonInventory") ?>),\n       COALESCE(iu.uom_name, <? value("na") ?>),\n       warehous_code,\n       '' AS vend_item_number,\n       ru.uom_name,\n       formatQty(raitem_qtyauthorized),\n       formatQty(raitem_qtyreceived),\n       formatQty(qtyToReceive(<? value("ordertype") ?>, raitem_id))\nFROM rahead, raitem \n  LEFT OUTER JOIN \n     ( itemsite \n<? if exists("selectedOnly") ?>\n       JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n<? endif ?>\n       JOIN item ON (itemsite_item_id=item_id) \n       JOIN uom iu ON (item_inv_uom_id=uom_id)\n       JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n     ) ON (raitem_itemsite_id=itemsite_id), uom ru\nWHERE ( (raitem_status <> 'C')\n AND (raitem_qtyauthorized > 0)\n AND (raitem_disposition IN ('R','P','V'))\n AND (raitem_rahead_id=rahead_id)\n AND (raitem_qty_uom_id=ru.uom_id)\n<? if exists("selectedOnly") ?>\n AND (usrsite_username=current_user) \n<? endif ?>\n AND (rahead_id=<? value("rahead_id") ?>) )\nORDER BY raitem_linenumber;\n<? elseif exists("tohead_id") ?>\nSELECT toitem_id, toitem_linenumber,\n       formatDate(toitem_duedate),\n       COALESCE(item_number, <? value("nonInventory") ?>),\n       COALESCE(uom_name, <? value("na") ?>),\n       warehous_code,\n       '',\n       toitem_uom,\n       formatQty(toitem_qty_ordered),\n       formatQty(toitem_qty_received),\n       formatQty(qtyToReceive(<? value("ordertype") ?>, toitem_id))\nFROM tohead, itemsite\n<? if exists("selectedOnly") ?>\n       JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n<? endif ?>\n, whsinfo, toitem, item JOIN uom ON (item_inv_uom_id=uom_id)\nWHERE ((toitem_item_id=item_id)\n  AND  (tohead_id=toitem_tohead_id)\n  AND  (tohead_dest_warehous_id=itemsite_warehous_id)\n  AND  (tohead_dest_warehous_id=warehous_id)\n  AND  (toitem_item_id=itemsite_item_id)\n  AND  (toitem_status <> 'C')\n<? if exists("selectedOnly") ?>\n AND (usrsite_username=current_user) \n<? endif ?>\n  AND  (toitem_tohead_id=<? value("tohead_id") ?>) )\nORDER BY toitem_linenumber;\n<? endif ?>\n     admin   2008-09-03      0
101039
 
43      breederDistributionVariance     detail  used by dspBreederDistributionVarianceByItem, dspBreederDistributionVarianceByWarehouse -- Group: breederDistributionVariance\n-- Name: detail\n-- Notes: used by dspBreederDistributionVarianceByItem, dspBreederDistributionVarianceByWarehouse\n\nSELECT brdvar_id, brdvar_postdate,\n       pi.item_number AS pitem_number,\n       ci.item_number AS citem_number,\n       brdvar_stdqtyper,\n       brdvar_stdqtyper * brdvar_wo_qty AS stdqty,\n       brdvar_actqtyper,\n       brdvar_actqtyper * brdvar_wo_qty AS actqty,\n       brdvar_actqtyper-brdvar_stdqtyper AS qtypervariance,\n       (brdvar_actqtyper-brdvar_stdqtyper) / brdvar_stdqtyper AS percentvariance,\n       'qtyper'   AS brdvar_stdqtyper_xtnumericrole,\n       'qty'     AS stdqty_xtnumericrole,\n       'qtyper'  AS brdvar_actqtyper_xtnumericrole,\n       'qty'     AS actqty_xtnumericrole,\n       'qtyper'  AS qtypervariance_xtnumericrole,\n       'percent' AS percentvariance_xtnumericrole \nFROM brdvar, itemsite AS ps, itemsite AS cs, item AS ci, item AS pi\nWHERE ( (brdvar_parent_itemsite_id=ps.itemsite_id)\n    AND (brdvar_itemsite_id=cs.itemsite_id)\n<? if exists("item_id") ?>\n    AND (ps.itemsite_item_id=<? value("item_id") ?>)\n    AND (pi.item_id=ci.item_id)\n<? else ?>\n    AND (ps.itemsite_item_id=pi.item_id)\n<? endif ?>\n    AND (cs.itemsite_item_id=ci.item_id)\n    AND (brdvar_postdate BETWEEN <? value("startDate") ?>\n                             AND <? value("endDate") ?>)\n<? if exists("warehous_id") ?>\n    AND (ps.itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n) \nORDER BY brdvar_postdate, pitem_number\n<? if not exists("item_id") ?>\n     , citem_number \n<? endif ?>\n;\n   admin   2008-11-07      0
101040
 
61      manufacture     laborvariance   shared by dspLaborVarianceBy*   -- Group: manufacture\n-- Name:  laborvariance\n-- Notes: shared by dspLaborVarianceBy*\n\nSELECT woopervar.*,\n       item_number, wrkcnt_code,\n       (woopervar_sutime - woopervar_stdsutime) AS suvar,\n       (woopervar_rntime - woopervar_stdrntime) AS rnvar,\n       'qty' AS woopervar_qtyord_xtnumericrole,\n       'qty' AS woopervar_qtyrcv_xtnumericrole,\n       '1'   AS woopervar_stdsutime_xtnumericrole,\n       '1'   AS woopervar_stdrntime_xtnumericrole,\n       '1'   AS woopervar_sutime_xtnumericrole,\n       '1'   AS woopervar_rntime_xtnumericrole,\n       '1'   AS suvar_xtnumericrole,\n       '1'   AS rnvar_xtnumericrole\nFROM woopervar\n<? if exists("wo_id") ?>\n     JOIN wo ON ((woopervar_number=wo_number)\n             AND (woopervar_subnumber=wo_subnumber))\n<? endif ?>\n     JOIN itemsite ON (woopervar_parent_itemsite_id=itemsite_id)\n     JOIN item ON (itemsite_item_id=item_id)\n     LEFT OUTER JOIN wrkcnt ON (woopervar_wrkcnt_id=wrkcnt_id)\nWHERE (true\n<? if exists("startDate") ?>\n   AND (woopervar_posted BETWEEN <? value("startDate") ?>\n                             AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("booitem_id") ?>\n   AND (woopervar_booitem_id=<? value("booitem_id") ?>)\n<? endif ?>\n<? if exists("wrkcnt_id") ?>\n   AND (wrkcnt_id=<? value("wrkcnt_id") ?>)\n<? endif ?>\n<? if exists("wo_id") ?>\n   AND (wo_id=<? value("wo_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nORDER BY woopervar_posted DESC, woopervar_seqnumber;\n    admin   2008-11-07      0
101041
 
248     gleries checkeditable           -- Group: gleries\n-- Name:  checkeditable\n-- Notes: \nSELECT gltrans_id \nFROM accnt, gltrans \n  LEFT OUTER JOIN period ON (gltrans_date BETWEEN period_start AND period_end) \nWHERE ( (gltrans_accnt_id=accnt_id) \n  AND (gltrans_sequence=<? value("glSequence") ?>) \n  AND ( (gltrans_deleted) \n     OR (period_freeze) \n     OR (gltrans_rec) \n     OR (period_closed AND NOT accnt_closedpost) ) )\nLIMIT 1;      admin   2010-09-10      0
101042
 
484     assessFinanceCharges    detail   Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: assessFinanceCharges\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT aropen_id, aropen_docnumber, aropen_duedate, aropen_docdate,\n       aropen_amount, aropen_paid, balance, aropen_fincharg_date, aropen_fincharg_amount,\n       cust_number, cust_name,\n       CASE WHEN (currToLocal(aropen_curr_id, fincharg_mincharg, aropen_distdate) >\n                  (CASE WHEN (fincharg_assessoverdue)\n                        THEN (balance + prevfincharge)\n                        ELSE balance END * fincharg_air / 100.0 / 365 * CASE WHEN (fincharg_calcfrom=1)\n                                                                             THEN duedateoverdue\n                                                                             ELSE docdateoverdue END))\n            THEN currToLocal(aropen_curr_id, fincharg_mincharg, aropen_distdate)\n            ELSE (CASE WHEN (fincharg_assessoverdue)\n                       THEN (balance + prevfincharge)\n                       ELSE balance END * fincharg_air / 100.0 / 365 * CASE WHEN (fincharg_calcfrom=1)\n                                                                            THEN duedateoverdue\n                                                                            ELSE docdateoverdue END)\n       END AS fincharge\nFROM fincharg,\n     (SELECT *,\n             (aropen_amount - aropen_paid) AS balance,\n             COALESCE(aropen_fincharg_amount, 0.0) AS prevfincharge,\n             (<? value("assessmentDate") ?> - COALESCE(aropen_fincharg_date, aropen_duedate)) AS duedateoverdue,\n             (<? value("assessmentDate") ?> - COALESCE(aropen_fincharg_date, aropen_docdate)) AS docdateoverdue\n      FROM aropen JOIN custinfo ON (cust_id=aropen_cust_id)\n                  LEFT OUTER JOIN terms ON (terms_id=aropen_terms_id)\n                  LEFT OUTER JOIN custtype ON (cust_custtype_id=custtype_id)\n                  LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n      WHERE ((aropen_doctype='I')\n        AND  (aropen_open)\n        AND  (COALESCE(terms_fincharg, FALSE))\n        AND  (COALESCE(cust_financecharge, TRUE))\n      <? if exists("cust_id") ?>\n        AND   (aropen_cust_id=<? value("cust_id") ?>)\n      <? endif ?>\n      <? if exists("custtype_id") ?>\n        AND   (custtype_id=<? value("custtype_id") ?>)\n      <? endif ?>\n      <? if exists("custtype_pattern") ?>\n        AND   (custtype_code~<? value("custtype_pattern") ?>)\n      <? endif ?>\n      <? if exists("custgrp_id") ?>\n        AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n      <? endif ?>\n      )) AS data\nWHERE ((COALESCE(aropen_fincharg_date, aropen_duedate) + COALESCE(cust_gracedays, fincharg_graceperiod)) < <? value("assessmentDate") ?>)\nORDER BY cust_number, aropen_docnumber;\n admin   2014-03-20      0
101043
 
481     contrct itemsources     Selection of Contract Related Item Sources      -- Group: contrct\n-- Name:  itemsources\n-- Notes: Selection of Contract Related Item Sources\nSELECT itemsrc_id,\n\t-1 AS pohead_id, \n\t' ' AS seq,\n\t' ' AS poitem_ordnumber, \n        item_number,\n\titem_descrip1,\n\titemsrc_vend_uom,\n\titemsrc_vend_item_number,\n\tmin(contisrc_min) AS contisrc_min,\n\tsum(poitem_qty_unreleased) AS poitem_qty_unreleased,\n\tsum(poitem_qty_ordered)    AS poitem_qty_ordered,\n\tsum(poitem_qty_received)   AS poitem_qty_received,\n\tsum(poitem_qty_returned)   AS poitem_qty_returned,\n\tnull AS poitem_duedate,\n\tnull AS poitem_status,\n\t0 AS xtindentrole \n\tFROM (SELECT contrct_id, \n\t\titemsrc_id,\n\t\tpohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\titem_number,\n\t\titem_descrip1,\n\t\titemsrc_vend_uom,\n\t\titemsrc_vend_item_number,\n\t\tcontisrc_min,\n\t\tCASE WHEN poitem_status = 'U' THEN poitem_qty_ordered\n\t\t  ELSE 0\n\t\tEND AS poitem_qty_unreleased,\n\t\tCASE WHEN poitem_status = 'O' THEN poitem_qty_ordered\n\t\t     WHEN poitem_status = 'C' THEN poitem_qty_ordered\n                  ELSE 0\n\t\tEND AS poitem_qty_ordered,\n\t\tpoitem_qty_received,\n\t\tpoitem_qty_returned,\n\t\tpoitem_duedate, \n\t\tpoitem_status\n\t\tFROM contrct JOIN itemsrc  ON (itemsrc_contrct_id  = contrct_id)\n\t\t  LEFT OUTER JOIN contisrc ON (contisrc_itemsrc_id = itemsrc_id)\n\t\t  LEFT OUTER JOIN poitem   ON (poitem_itemsrc_id   = itemsrc_id)\n\t\t  LEFT OUTER JOIN pohead   ON (pohead_id           = poitem_pohead_id)\n\t\t\t     JOIN item     ON (itemsrc_item_id     = item_id)\n\t\tWHERE (contrct_id = <? value("contrct_id") ?>)) AS dummy1\n\tWHERE (contrct_id = <? value("contrct_id") ?>)\n\tGROUP BY itemsrc_id, itemsrc_vend_item_number, itemsrc_vend_uom, item_number, item_descrip1\n\nUNION  -- PO Line Items\n\nSELECT itemsrc_id,\n\tpohead_id, \n\tpohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS seq,\n        pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber,  \n        null AS item_number,\n\tnull AS item_descrip1,\n\tnull AS itemsrc_vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS contisrc_min,\n\tCASE WHEN poitem_status = 'U' THEN poitem_qty_ordered\n\t  ELSE 0\n\tEND AS poitem_qty_unreleased,\n\tCASE WHEN poitem_status = 'O' THEN poitem_qty_ordered\n\t     WHEN poitem_status = 'C' THEN poitem_qty_ordered\n          ELSE 0\n\tEND AS poitem_qty_ordered,\n\tpoitem_qty_received,\n\tpoitem_qty_returned,\n\tpoitem_duedate, \n\tCASE WHEN poitem_status = 'O' THEN 'Open'\n\t     WHEN poitem_status = 'C' THEN 'Closed'\n\t     ELSE 'Unreleased'\n\tEND AS poitem_status,\n\t1 AS xtindentrole \n\tFROM contrct JOIN itemsrc  ON (itemsrc_contrct_id  = contrct_id)\n\t  LEFT OUTER JOIN contisrc ON (contisrc_itemsrc_id = itemsrc_id)\n\t\t     JOIN poitem   ON (poitem_itemsrc_id   = itemsrc_id)\n\t\t     JOIN pohead   ON (pohead_id           = poitem_pohead_id)\n\t\t     JOIN itemsite ON (poitem_itemsite_id  = itemsite_id)\n\t\t     JOIN item     ON (itemsite_item_id    = item_id)\n\tWHERE (contrct_id = <? value("contrct_id") ?>)\n\nUNION -- Receipts\n\nSELECT itemsrc_id,\n\tpohead_id,  \n\tpoitem_ordnumber || 'R' || to_char(recv_date, 'YYYYMMDDHH24:MI:SS') AS seq,\n\t'Receipt' AS poitem_ordnumber,\n\tnull AS item_number,\n\tnull AS item_descrip1,\n\trecv_vend_uom AS vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS contisrc_min,\n\tnull AS poitem_qty_unreleased,\n\tnull AS poitem_qty_ordered,\n\trecv_qty AS poitem_qty_received,\n\tnull AS poitem_qty_returned,\n\trecv_date AS poitem_duedate,\n\trecv_trans_usr_name AS username,\n\t2 AS xtindentrole\n  FROM recv JOIN (SELECT pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\t\t    poitem_pohead_id, poitem_linenumber, poitem_id, pohead_id, \n\t\t\t    poitem_itemsrc_id\n\t\t\tFROM poitem JOIN pohead ON (pohead_id = poitem_pohead_id)) AS dummy ON (poitem_id   = recv_orderitem_id)\n               JOIN itemsite ON (itemsite_id = recv_itemsite_id)\n               JOIN item     ON (item_id     = itemsite_item_id)\n               JOIN itemsrc  ON (poitem_itemsrc_id = itemsrc_id)\n  WHERE (itemsrc_contrct_id = <? value("contrct_id") ?>) \n\nUNION -- Returns\n\nSELECT itemsrc_id, \n\tpohead_id,  \n\tpoitem_ordnumber || 'R' || to_char(poreject_date, 'YYYYMMDDHH24:MI:SS') AS seq,\n\t'Return' AS poitem_ordnumber,\n\tnull AS item_number,\n\tnull AS item_descrip1,\n\tporeject_vend_uom AS vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS contisrc_min,\n\tnull AS poitem_qty_unreleased,\n\tnull AS poitem_qty_ordered,\n\tnull AS poitem_qty_received,\n\tporeject_qty AS poitem_qty_returned,\n\tporeject_date AS poitem_duedate,\n\tporeject_trans_username AS username,\n\t2 AS xtindentrole \n  FROM poreject JOIN (SELECT pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\t\t    poitem_pohead_id, poitem_linenumber, poitem_id, pohead_id, \n\t\t\t    poitem_itemsrc_id\n\t\t\tFROM poitem JOIN pohead ON (pohead_id = poitem_pohead_id)) AS dummy ON (poitem_id   = poreject_poitem_id)\n               JOIN itemsite ON (itemsite_id = poreject_itemsite_id)\n               JOIN item     ON (item_id     = itemsite_item_id)\n               JOIN itemsrc  ON (poitem_itemsrc_id = itemsrc_id)\n  WHERE (itemsrc_contrct_id = <? value("contrct_id") ?>) \n\nORDER BY itemsrc_id, seq, poitem_ordnumber, poitem_duedate, xtindentrole;\n     admin   2013-11-11      0
101044
 
417     bookings        detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: bookings\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT   coitem_id AS id, coitem_cohead_id AS altId,\n         formatSoLineNumber(coitem_id) AS f_linenumber,\n         getSoSchedDate(cohead_id) AS sort_scheddate,\n         coitem.*, cohead.*,\n         cust_number, cust_name,\n         item_number, item_descrip1, (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n         uom_name,\n         warehous_code,\n         qtyAtShipping(coitem_id) AS qtyatshipping,\n-- TODO - not needed, remove? (very slow)\n--         qtyAvailable(itemsite_id, coitem_scheddate) AS qtyavailable,\n--         (qtyAvailable(itemsite_id, coitem_scheddate) < 0.0) AS stockout,\n--         CASE WHEN (itemsite_useparams) THEN (qtyAvailable(itemsite_id, coitem_scheddate) <= itemsite_reorderlevel)\n--              ELSE (qtyAvailable(itemsite_id, coitem_scheddate) <= 0.0)\n--         END AS reorder,\n         noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qtybalance,\n         currtobase(cohead_curr_id, coitem_price, cohead_orderdate) AS baseunitprice,\n         round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (coitem_price / coitem_price_invuomratio), 2) AS extprice,\n         round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextprice,\n         round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                     (coitem_price / coitem_price_invuomratio), 2) AS extpricebalance,\n         round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                     (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextpricebalance,\n         round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (coitem_unitcost / coitem_price_invuomratio), 2) AS extcost,\n         CASE WHEN (coitem_price = 0.0) THEN 0.0\n              ELSE ROUND(coitem_qtyord * coitem_qty_invuomratio * (coitem_price - coitem_unitcost) / coitem_price_invuomratio,2)\n         END AS margin,\n         CASE WHEN (coitem_price = 0.0) THEN 0.0\n              ELSE ((coitem_price - coitem_unitcost) / coitem_price)\n         END AS marginpercent,\n         curr_abbr AS currAbbr,\n-- TODO - not needed, remove? (very slow)\n--         CASE WHEN (qtyAvailable(itemsite_id, coitem_scheddate) < 0.0) THEN 'error'\n--              WHEN itemsite_useparams AND (qtyAvailable(itemsite_id, coitem_scheddate) <= itemsite_reorderlevel) THEN 'warning'\n--              WHEN NOT itemsite_useparams AND (qtyAvailable(itemsite_id, coitem_scheddate) <= 0.0) THEN 'warning'\n--         END AS qtyavailable_qtforegroundrole,\n       'qty' AS coitem_qtyord_xtnumericrole,\n       'qty' AS coitem_qtyshipped_xtnumericrole,\n       'qty' AS coitem_qtyreturned_xtnumericrole,\n       'qty' AS qtyatshipping_xtnumericrole,\n       'qty' AS qtybalance_xtnumericrole,\n       'qty' AS qtyavailable_xtnumericrole,\n       'salesprice' AS coitem_price_xtnumericrole,\n       'salesprice' AS baseunitprice_xtnumericrole,\n       'cost' AS coitem_unitcost_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS extcost_xtnumericrole,\n       'curr' AS margin_xtnumericrole,\n       'percent' AS marginpercent_xtnumericrole,\n       'curr' AS baseextprice_xtnumericrole,\n       'curr' AS extpricebalance_xtnumericrole,\n       'curr' AS baseextpricebalance_xtnumericrole,\n       0 AS coitem_qtyord_xttotalrole,\n       0 AS coitem_qtyshipped_xttotalrole,\n       0 AS coitem_qtyreturned_xttotalrole,\n       0 AS qtybalance_xttotalrole,\n       0 AS baseextprice_xttotalrole,\n       0 AS baseextpricebalance_xttotalrole\n  FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n              JOIN custinfo ON (cust_id=cohead_cust_id)\n              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n              JOIN site() ON (warehous_id=itemsite_warehous_id)\n              JOIN item ON (item_id=itemsite_item_id)\n              JOIN uom ON (uom_id=coitem_qty_uom_id)\n              JOIN curr_symbol ON (curr_id=cohead_curr_id)\n<? foreach("char_id_text_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> \n          ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='SO') \n         AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=cohead_id)\n         AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> \n          ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> \n          ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='SO') \n         AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=cohead_id)\n         AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> \n          ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> \n          ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='SO') \n         AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=cohead_id)\n         AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> \n          ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\n  WHERE ( (coitem_status<>'X')\n  <? if exists("cohead_id") ?>\n    AND  (coitem_cohead_id=<? value("cohead_id") ?>)\n  <? endif ?>\n  <? if exists("openOnly") ?>\n    AND  (coitem_status<>'C')\n  <? endif ?>\n  <? if exists("startDate") ?>\n    AND  (cohead_orderdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n  <? endif ?>\n\n  <? if exists("salesrep_id") ?>\n    AND  (cohead_salesrep_id=<? value("salesrep_id") ?>)\n  <? endif ?>\n  <? if exists("shipto_id") ?>\n    AND  (cohead_shipto_id=<? value("shipto_id") ?>)\n  <? endif ?>\n  <? if exists("cust_id") ?>\n    AND  (cohead_cust_id=<? value("cust_id") ?>)\n  <? elseif exists("custtype_id") ?>\n    AND  (cust_custtype_id=<? value("custtype_id") ?>)\n  <? elseif exists("custtype_pattern") ?>\n    AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                               FROM custtype\n                               WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? elseif exists("custgrp") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem))\n  <? elseif exists("custgrp_id") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem\n                     WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n  <? elseif exists("custgrp_pattern") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrp, custgrpitem\n                     WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                       AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n  <? endif ?>\n\n  <? if exists("item_id") ?>\n    AND  (itemsite_item_id=<? value("item_id") ?>)\n  <? elseif exists("prodcat_id") ?>\n    AND (item_prodcat_id=<? value("prodcat_id") ?>)\n  <? elseif exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                             FROM prodcat\n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n  <? endif ?>\n\n  <? if exists("warehous_id") ?>\n    AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n  <? literal("charClause") ?>\n        )\n\n<? if exists("orderByScheddate") ?>\n  ORDER BY sort_scheddate, cohead_number, coitem_linenumber, coitem_subnumber\n<? elseif exists("orderByOrderdate") ?>\n  ORDER BY cohead_orderdate, cohead_number, coitem_linenumber, coitem_subnumber\n<? else ?>\n  ORDER BY cohead_number, coitem_linenumber, coitem_subnumber\n<? endif ?>\n;\n  admin   2014-10-06      0
101045
 
425     contactmerge    restore  Restore a contact that was previously merged\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: contactmerge\n-- Name: restore\n-- Notes: Restore a contact that was previously merged\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctrestore(cntctmrgd_cntct_id) AS result\nFROM cntctmrgd\n<? if exists("cntct_id") ?>\nWHERE (cntctmrgd_cntct_id=<? value("cntct_id") ?>)\n<? endif ?>\n;\n       admin   2014-10-06      0
101046
 
419     contactmerge    delete   Delete a contact\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: contactmerge\n-- Name: delete\n-- Notes: Delete a contact\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM cntct WHERE (cntct_id=<? value("cntct_id") ?>);\n   admin   2014-10-06      0
101047
 
482     contract        itemsources     Selection of Contract Related Item Sources      -- Group: contract\n-- Name:  itemsources\n-- Notes: Selection of Contract Related Item Sources\nSELECT itemsrc_id,\n\t-1 AS pohead_id, \n\t' ' AS seq,\n\t' ' AS poitem_ordnumber, \n        item_number,\n\titem_descrip1,\n\titemsrc_vend_uom,\n\titemsrc_vend_item_number,\n\titemsrc_contrct_min,\n\tsum(poitem_qty_unreleased) AS poitem_qty_unreleased,\n\tsum(poitem_qty_ordered)    AS poitem_qty_ordered,\n\tsum(poitem_qty_received)   AS poitem_qty_received,\n\tsum(poitem_qty_returned)   AS poitem_qty_returned,\n\tnull AS poitem_duedate,\n\tnull AS poitem_status,\n\t0 AS xtindentrole \n\tFROM (SELECT contrct_id, \n\t\titemsrc_id,\n\t\tpohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\titem_number,\n\t\titem_descrip1,\n\t\titemsrc_vend_uom,\n\t\titemsrc_vend_item_number,\n\t\titemsrc_contrct_min,\n\t\tCASE WHEN poitem_status = 'U' THEN poitem_qty_ordered\n\t\t  ELSE 0\n\t\tEND AS poitem_qty_unreleased,\n\t\tCASE WHEN poitem_status = 'O' THEN poitem_qty_ordered\n\t\t     WHEN poitem_status = 'C' THEN poitem_qty_ordered\n                  ELSE 0\n\t\tEND AS poitem_qty_ordered,\n\t\tpoitem_qty_received,\n\t\tpoitem_qty_returned,\n\t\tpoitem_duedate, \n\t\tpoitem_status\n\t\tFROM contrct JOIN itemsrc  ON (itemsrc_contrct_id  = contrct_id)\n\t\t  LEFT OUTER JOIN poitem   ON (poitem_itemsrc_id   = itemsrc_id)\n\t\t  LEFT OUTER JOIN pohead   ON (pohead_id           = poitem_pohead_id)\n\t\t\t     JOIN item     ON (itemsrc_item_id     = item_id)\n\t\tWHERE (contrct_id = <? value("contrct_id") ?>)) AS dummy1\n\tWHERE (contrct_id = <? value("contrct_id") ?>)\n\tGROUP BY itemsrc_id, itemsrc_vend_item_number, itemsrc_vend_uom, itemsrc_contrct_min,\n                item_number, item_descrip1\n\nUNION  -- PO Line Items\n\nSELECT itemsrc_id,\n\tpohead_id, \n\tpohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS seq,\n        pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber,  \n        null AS item_number,\n\tnull AS item_descrip1,\n\tnull AS itemsrc_vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS itemsrc_contrct_min,\n\tCASE WHEN poitem_status = 'U' THEN poitem_qty_ordered\n\t  ELSE 0\n\tEND AS poitem_qty_unreleased,\n\tCASE WHEN poitem_status = 'O' THEN poitem_qty_ordered\n\t     WHEN poitem_status = 'C' THEN poitem_qty_ordered\n          ELSE 0\n\tEND AS poitem_qty_ordered,\n\tpoitem_qty_received,\n\tpoitem_qty_returned,\n\tpoitem_duedate, \n\tCASE WHEN poitem_status = 'O' THEN 'Open'\n\t     WHEN poitem_status = 'C' THEN 'Closed'\n\t     ELSE 'Unreleased'\n\tEND AS poitem_status,\n\t1 AS xtindentrole \n\tFROM contrct JOIN itemsrc  ON (itemsrc_contrct_id  = contrct_id)\n\t\t     JOIN poitem   ON (poitem_itemsrc_id   = itemsrc_id)\n\t\t     JOIN pohead   ON (pohead_id           = poitem_pohead_id)\n\t\t     JOIN itemsite ON (poitem_itemsite_id  = itemsite_id)\n\t\t     JOIN item     ON (itemsite_item_id    = item_id)\n\tWHERE (contrct_id = <? value("contrct_id") ?>)\n\nUNION -- Receipts\n\nSELECT itemsrc_id,\n\tpohead_id,  \n\tpoitem_ordnumber || 'R' || to_char(recv_date, 'YYYYMMDDHH24:MI:SS') AS seq,\n\t'Receipt' AS poitem_ordnumber,\n\tnull AS item_number,\n\tnull AS item_descrip1,\n\trecv_vend_uom AS vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS itemsrc_contrct_min,\n\tnull AS poitem_qty_unreleased,\n\tnull AS poitem_qty_ordered,\n\trecv_qty AS poitem_qty_received,\n\tnull AS poitem_qty_returned,\n\trecv_date AS poitem_duedate,\n\trecv_trans_usr_name AS username,\n\t2 AS xtindentrole\n  FROM recv JOIN (SELECT pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\t\t    poitem_pohead_id, poitem_linenumber, poitem_id, pohead_id, \n\t\t\t    poitem_itemsrc_id\n\t\t\tFROM poitem JOIN pohead ON (pohead_id = poitem_pohead_id)) AS dummy ON (poitem_id   = recv_orderitem_id)\n               JOIN itemsite ON (itemsite_id = recv_itemsite_id)\n               JOIN item     ON (item_id     = itemsite_item_id)\n               JOIN itemsrc  ON (poitem_itemsrc_id = itemsrc_id)\n  WHERE (itemsrc_contrct_id = <? value("contrct_id") ?>) \n\nUNION -- Returns\n\nSELECT itemsrc_id, \n\tpohead_id,  \n\tpoitem_ordnumber || 'R' || to_char(poreject_date, 'YYYYMMDDHH24:MI:SS') AS seq,\n\t'Return' AS poitem_ordnumber,\n\tnull AS item_number,\n\tnull AS item_descrip1,\n\tporeject_vend_uom AS vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS itemsrc_contrct_min,\n\tnull AS poitem_qty_unreleased,\n\tnull AS poitem_qty_ordered,\n\tnull AS poitem_qty_received,\n\tporeject_qty AS poitem_qty_returned,\n\tporeject_date AS poitem_duedate,\n\tporeject_trans_username AS username,\n\t2 AS xtindentrole \n  FROM poreject JOIN (SELECT pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\t\t    poitem_pohead_id, poitem_linenumber, poitem_id, pohead_id, \n\t\t\t    poitem_itemsrc_id\n\t\t\tFROM poitem JOIN pohead ON (pohead_id = poitem_pohead_id)) AS dummy ON (poitem_id   = poreject_poitem_id)\n               JOIN itemsite ON (itemsite_id = poreject_itemsite_id)\n               JOIN item     ON (item_id     = itemsite_item_id)\n               JOIN itemsrc  ON (poitem_itemsrc_id = itemsrc_id)\n  WHERE (itemsrc_contrct_id = <? value("contrct_id") ?>) \n\nORDER BY itemsrc_id, seq, poitem_ordnumber, poitem_duedate, xtindentrole;\n  admin   2014-03-20      0
101048
 
433     salesOrderItems list     used by salesOrder\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: salesOrderItems\n-- Name: list\n-- Notes: used by salesOrder\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT coitem_id, coitem_altid, groupby,\n       coitem_linenumber, coitem_subnumber, f_linenumber,\n       warehous_code, item_number, item_type, description,\n       item_number_cust, item_descrip1_cust, item_descrip2_cust, item_barcode,\n       prodweight, packweight,\n       enhanced_status, coitem_firm,\n       qty_uom, price_uom, ship_uom,\n       coitem_memo,\n-- always create formatted columns for scheduled reports\n       formatDate(coitem_scheddate) AS f_scheddate,\n       formatSalesPrice(coitem_price) AS f_price,\n       formatSalesPrice(coitem_custprice) AS f_custprice,\n       formatPrcnt(discountfromcust / 100) AS f_discountfromcust,\n       formatQty(coitem_qtyord) AS f_qtyord,\n       CASE WHEN (qtyshipped > 0.0) THEN formatQty(qtyshipped) ELSE NULL END AS f_qtyshipped,\n       CASE WHEN (qtyshipped > 0.0) THEN formatQty(balance) ELSE NULL END AS f_balance,\n       CASE WHEN (qtyatshipping > 0.0) THEN formatQty(qtyatshipping) ELSE NULL END AS f_qtyatshipping,\n       formatMoney(extprice) AS f_extprice,\n       CASE WHEN (extprice_shipped > 0.0) THEN formatMoney(extprice_shipped) ELSE NULL END AS f_extprice_shipped,\n-- end formatted columns\n       coitem_scheddate, coitem_price, coitem_custprice, discountfromcust,\n       coitem_unitcost, margin, marginpercent,\n       coitem_qtyord, qtyshipped, balance, qtyatshipping,\n       extprice, extprice_shipped,\n       CASE WHEN (discountfromcust=100.0) THEN 'N/A' END AS discountfromcust_qtdisplayrole,\n       CASE WHEN (margin=0.0) THEN 'N/A' END AS margin_qtdisplayrole,\n       CASE WHEN (marginpercent=0.0) THEN 'N/A' END AS marginpercent_qtdisplayrole,\n       'qty' AS coitem_qtyord_xtnumericrole,\n       'qty' AS qtyshipped_xtnumericrole,\n       'qty' AS balance_xtnumericrole,\n       'qty' AS qtyatshipping_xtnumericrole,\n       'qty' AS prodweight_xtnumericrole,\n       'qty' AS packweight_xtnumericrole,\n       'salesprice' AS coitem_price_xtnumericrole,\n       'salesprice' AS coitem_custprice_xtnumericrole,\n       'cost' AS coitem_unitcost_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS extprice_shipped_xtnumericrole,\n       'curr' AS margin_xtnumericrole,\n       'percent' AS marginpercent_xtnumericrole,\n       CASE WHEN fetchMetricBool('EnableSOShipping') AND\n                 coitem_scheddate > CURRENT_DATE AND\n                 (noNeg(coitem_qtyord) <> qtyAtShipping('SO', coitem_id)) THEN 'future'\n            WHEN fetchMetricBool('EnableSOShipping') AND\n                 (noNeg(coitem_qtyord) <> qtyAtShipping('SO', coitem_id)) THEN 'expired'\n            WHEN (coitem_status NOT IN ('C', 'X') AND\n                  EXISTS(SELECT coitem_id\n                         FROM coitem\n                         WHERE ((coitem_status='C')\n                           AND  (coitem_cohead_id=<? value("cohead_id") ?>)))) THEN 'error'\n       END AS coitem_scheddate_qtforegroundrole,\n       CASE WHEN coitem_subnumber = 0 THEN 0\n            ELSE 1\n       END AS xtindentrole,\n       spplytype, ordrnumbr,\n       availableqoh,\n       'qty' AS availableqoh_xtnumericrole\n<? if exists("includeReservations") ?>\n       ,\n       reserved,\n       reservable,\n       'qty' AS reserved_xtnumericrole,\n       'qty' AS reservable_xtnumericrole\n<? endif?>\nFROM (\nSELECT coitem_id,\n       CASE WHEN (coitem_status='C') THEN 1\n            WHEN (coitem_status='X') THEN 4\n            WHEN ( (coitem_status='O') AND ( (qtyAtShipping('SO', coitem_id) > 0) OR (coitem_qtyshipped > 0) ) ) THEN 2\n            ELSE 3\n       END AS coitem_altid, 1 AS groupby,\n       coitem_linenumber, coitem_subnumber, formatSoLineNumber(coitem_id) AS f_linenumber,\n       warehous_code, item_number, item_type,\n       (item_descrip1 || ' ' || item_descrip2) AS description,\n       CASE WHEN (coitem_custpn != '') THEN coitem_custpn\n            ELSE item_number\n       END AS item_number_cust,\n       CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip1\n            ELSE item_descrip1\n       END AS item_descrip1_cust,\n       CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip2\n            ELSE item_descrip2\n       END AS item_descrip2_cust,\n       formatitemsitebarcode(itemsite_id) AS item_barcode,\n       (coitem_qtyord * coitem_qty_invuomratio * item_prodweight) AS prodweight,\n       (coitem_qtyord * coitem_qty_invuomratio * item_packweight) AS packweight,\n       coitem_status, coitem_firm,\n       getSoitemStatus(coitem_id) AS enhanced_status,\n       quom.uom_name AS qty_uom, puom.uom_name AS price_uom,\n       itemSellingUOM(item_id) AS ship_uom,\n       coitem_memo,\n       coitem_scheddate, coitem_price, coitem_custprice, coitem_qtyord,\n       CASE WHEN (coitem_custprice = 0.0) THEN 100.0\n            ELSE ((1.0 - (coitem_price / coitem_custprice)) * 100.0)\n       END AS discountfromcust,\n       coitem_unitcost,\n       CASE WHEN (coitem_price = 0.0) THEN 0.0\n            ELSE ROUND(coitem_qtyord * coitem_qty_invuomratio * (coitem_price - coitem_unitcost) / coitem_price_invuomratio,2)\n       END AS margin,\n       CASE WHEN (coitem_price = 0.0) THEN 0.0\n            ELSE ((coitem_price - coitem_unitcost) / coitem_price)\n       END AS marginpercent,\n       noNeg(coitem_qtyshipped - coitem_qtyreturned) AS qtyshipped,\n       noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS balance,\n       qtyAtShipping('SO', coitem_id) AS qtyatshipping,\n       ROUND((coitem_qtyord * coitem_qty_invuomratio) *\n             (coitem_price / coitem_price_invuomratio),2) AS extprice,\n       ROUND(((coitem_qtyshipped - coitem_qtyreturned) * coitem_qty_invuomratio) *\n              (coitem_price / coitem_price_invuomratio),2) AS extprice_shipped,\n       CASE WHEN coitem_order_type='W' THEN TEXT( 'WO')\n            WHEN coitem_order_type='P' THEN TEXT('PO' )\n            WHEN coitem_order_type='R' THEN TEXT('PR')\n            ELSE TEXT (' ')\n       END AS spplytype,\n       CASE WHEN coitem_order_type='W' THEN (wo_number || '-' || wo_subnumber)\n            WHEN coitem_order_type='P' THEN (pohead_number || '-' || poitem_linenumber)\n            WHEN coitem_order_type='R' THEN (pr_number || '-' || pr_subnumber)\n            ELSE TEXT (' ')\n       END AS ordrnumbr,\n       qtyAvailable(itemsite_id) AS availableqoh\n<? if exists("includeReservations") ?>\n       ,\n       coitem_qtyreserved AS reserved,\n       qtyAvailable(itemsite_id) - qtyReserved(itemsite_id) AS reservable\n<? endif?>\n  FROM cohead\n       JOIN coitem ON (coitem_cohead_id=cohead_id)\n       JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n       JOIN item ON (item_id=itemsite_item_id)\n       JOIN whsinfo ON (warehous_id=itemsite_warehous_id)\n       JOIN uom AS quom ON (quom.uom_id=coitem_qty_uom_id)\n       JOIN uom AS puom ON (puom.uom_id=coitem_price_uom_id)\n       LEFT OUTER JOIN itemalias ON ((itemalias_item_id=item_id) AND (itemalias_number=coitem_custpn))\n       LEFT OUTER JOIN wo ON (coitem_order_id = wo_id)\n       LEFT OUTER JOIN pr ON (coitem_order_id = pr_id)\n       LEFT OUTER JOIN (pohead JOIN poitem ON (pohead_id = poitem_pohead_id))\n         ON (coitem_order_id = poitem_id)\n WHERE (cohead_id=<? value("sohead_id") ?>)\n\n<? if exists("excludeCancelled") ?>\n AND (coitem_status != 'X')\n<? endif?>\n\n<? if exists("excludeClosed") ?>\n AND (coitem_status != 'C')\n<? endif?>\n\n<? if exists("excludeKits") ?>\n AND (item_type != 'K')\n<? endif?>\n\n) AS data\nORDER BY coitem_linenumber, coitem_subnumber;  admin   2014-10-06      0
101049
 
420     contactmerge    deselect         Removes contact selection\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: contactmerge\n-- Name: deselect\n-- Notes: Removes contact selection\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM cntctsel\nWHERE (cntctsel_cntct_id=<? value("cntct_id") ?>);\n   admin   2014-10-06      0
101050
 
104     taxHistory      detail  \n---------BEGIN SUMMARY----------\n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: taxHistory\n-- Name: detail\n-- Notes:\n-----------BEGIN SUMMARY----------\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("summary") ?>\nSELECT <? literal("groupBy") ?>, \n  <? literal("groupBy") ?>_descrip AS description, \n  SUM(salesbase) AS salesbase,\n  SUM(freightbase) AS freightbase, \n  CASE WHEN (SUM(freighttax) > 0) THEN true ELSE false END AS freighttax, \n  SUM(salestaxbase) AS salestaxbase,\n  SUM(purchasebase) AS purchasebase,\n  SUM(purchasetaxbase) * -1 AS purchasetaxbase, \n  SUM(salestaxbase) + SUM(purchasetaxbase) AS nettaxbase,\n  'curr' AS salesbase_xtnumericrole,\n  'curr' AS freightbase_xtnumericrole,\n  'curr' AS salestaxbase_xtnumericrole,\n  'curr' AS purchasebase_xtnumericrole,\n  'curr' AS purchasetaxbase_xtnumericrole,\n  'curr' AS nettaxbase_xtnumericrole,\n  0 AS salestaxbase_xttotalrole,\n  0 AS purchasetaxbase_xttotalrole,\n  0 AS nettaxbase_xttotalrole\nFROM (\n<? endif ?>\n------------END SUMMARY--------------\n<? if exists("showSales") ?>\n------------BEGIN SALES--------------\n-- All sales tax history including memos \nSELECT \n  COALESCE(taxpay_distdate, taxhist_distdate) AS taxhist_distdate,\n  taxhist_journalnumber, tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  COALESCE(taxzone_code,<? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n  cohist_invcnumber AS docnumber, \n  <? value("sales") ?> AS source,\n  CASE\n    WHEN (cohist_doctype='I') THEN\n      <? value("invoice") ?>\n    WHEN (cohist_doctype='C') THEN\n      <? value("creditmemo") ?> \n    WHEN (cohist_doctype='D') THEN\n      <? value("debitmemo") ?>\n    ELSE\n      <? value("other") ?>\n  END AS doctype,\n  item_number, COALESCE(item_descrip1,cohist_misc_descrip) AS description,\n  CASE\n    WHEN (cohist_doctype != 'C') THEN\n      cohist_ordernumber \n  END AS ordernumber, cohist_invcdate AS docdate,\n  cohist_billtoname AS name, \n  cohist_qtyshipped AS qty, \n  cohist_unitprice AS unitprice, (cohist_qtyshipped * cohist_unitprice) AS amount,\n  CASE\n    WHEN (cohist_misc_type IS NULL OR cohist_misc_type IN ('M','F')) THEN\n      currToBase(cohist_curr_id, cohist_qtyshipped * cohist_unitprice, cohist_invcdate) \n    ELSE 0\n  END AS salesbase,\n  CASE\n    WHEN (cohist_misc_type = 'F') THEN\n      currToBase(cohist_curr_id, cohist_qtyshipped * cohist_unitprice, cohist_invcdate) \n    ELSE 0\n  END AS freightbase,\n  CASE\n    WHEN (cohist_misc_type = 'F') THEN\n      COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate\n    ELSE 0\n  END AS freighttax,\n  0 AS purchasebase,\n  COALESCE(taxpay_tax, taxhist_tax) AS taxlocal,\n  COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS taxbase,\n  COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS salestaxbase,\n  0 AS purchasetaxbase,\n  'qty' AS qty_xtnumericrole,\n  'saleprice' AS unitprice_xtnumericrole,\n  'extprice' AS amount_xtnumericrole,\n  'curr' AS taxhist_tax_xtnumericrole,\n  'curr' AS taxbase_xtnumericrole,\n   0 AS taxbase_xttotalrole\nFROM cohisttax\n JOIN cohist ON (cohist_id=taxhist_parent_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (cohist_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (cohist_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN taxpay ON (taxpay_taxhist_id=taxhist_id)\nWHERE ((true)\n<? if exists("distDate") ?>\n AND (taxhist_distdate BETWEEN <? value("startDate") ?>\n                           AND <? value("endDate") ?>)\n<? else ?>\n AND (taxhist_docdate BETWEEN <? value("startDate") ?>\n                          AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (taxzone_id=<? value("taxzone_id") ?>)\n<? endif ?>\n<? if exists("cashbasedtax") ?>\n AND (taxpay_id IS NOT NULL)\n<? endif ?>\n)\n<? endif ?>\n--------------END SALES--------------------\n<? if exists("showPurchases") ?>\n<? if exists("showSales") ?>\n-- Union because sales and purchase shown together\nUNION ALL\n<? endif ?>\n<? endif ?>\n------------BEGIN PURCHASE----------------\n<? if exists("showPurchases") ?>\n-- A/P Memo history\nSELECT \n  COALESCE(taxpay_distdate, taxhist_distdate) AS taxhist_distdate,\n  taxhist_journalnumber, tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  <? value("none") ?> AS taxzone,'' AS taxzone_descrip, curr_abbr, \n  apopen_docnumber AS docnumber, \n  <? value("purchase") ?> AS source,\n  CASE\n    WHEN (apopen_doctype='C') THEN\n      <? value("creditmemo") ?> \n    WHEN (apopen_doctype='D') THEN\n      <? value("debitmemo") ?>\n    ELSE\n      <? value("other") ?>\n  END AS doctype,\n  '' AS item_number, apopen_notes AS description,\n  apopen_ponumber AS ordernumber, apopen_docdate AS docdate,\n  vend_name AS name, \n  1 AS qty, \n  apopen_amount AS unitprice, apopen_amount AS amount,\n  0 AS salesbase,\n  0 AS freightbase,\n  0 AS freighttax,\n  apopen_amount / apopen_curr_rate AS purchasebase,\n  COALESCE(taxpay_tax, taxhist_tax) AS taxlocal,\n  COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS taxbase,\n  0 AS salestaxbase,\n  COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS purchasetaxbase,\n  'qty' AS qty_xtnumericrole,\n  'purchaseprice' AS unitprice_xtnumericrole,\n  'extprice' AS extension_xtnumericrole,\n  'curr' AS taxhist_tax_xtnumericrole,\n  'curr' AS taxbase_xtnumericrole,\n   0 AS taxbase_xttotalrole\nFROM apopentax\n JOIN apopen ON (apopen_id=taxhist_parent_id)\n JOIN vendinfo ON (apopen_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxpay ON (taxpay_taxhist_id=taxhist_id)\nWHERE ((true)\n<? if exists("distDate") ?>\n AND (taxhist_distdate BETWEEN <? value("startDate") ?>\n                           AND <? value("endDate") ?>)\n<? else ?>\n AND (taxhist_docdate BETWEEN <? value("startDate") ?>\n                          AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (false)\n<? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n<? if exists("cashbasedtax") ?>\n AND (taxpay_id IS NOT NULL)\n<? endif ?>\n)\nUNION ALL\n--Voucher Header History\nSELECT \n  COALESCE(taxpay_distdate, taxhist_distdate) AS taxhist_distdate,\n  taxhist_journalnumber, tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  COALESCE(taxzone_code,<? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n  vohead_number AS docnumber, \n  <? value("purchase") ?> AS source,\n  <? value("voucher") ?>  AS doctype,\n  '', vohead_notes AS description,\n  pohead_number AS ordernumber, vohead_docdate AS docdate,\n  vend_name AS name, \n  1 AS qty, \n  0 AS unitprice, 0 AS amount,\n  0 AS salesbase,\n  0 AS freightbase,\n  0 AS freighttax,\n  0 AS purchasebase,\n  COALESCE(taxpay_tax, taxhist_tax) AS taxlocal,\n  COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS taxbase,\n  0 AS salestaxbase,\n  COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS purchasetaxbase,\n  'qty' AS qty_xtnumericrole,\n  'purchaseprice' AS unitprice_xtnumericrole,\n  'extprice' AS amount_xtnumericrole,\n  'curr' AS taxhist_tax_xtnumericrole,\n  'curr' AS taxbase_xtnumericrole,\n   0 AS taxbase_xttotalrole\nFROM voheadtax\n JOIN vohead ON (vohead_id=taxhist_parent_id)\n LEFT OUTER JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n LEFT OUTER JOIN taxpay ON (taxpay_taxhist_id=taxhist_id)\nWHERE ((true)\n<? if exists("distDate") ?>\n AND (taxhist_distdate BETWEEN <? value("startDate") ?>\n                           AND <? value("endDate") ?>)\n<? else ?>\n AND (taxhist_docdate BETWEEN <? value("startDate") ?>\n                          AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (taxzone_id=<? value("taxzone_id") ?>)\n<? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n<? if exists("cashbasedtax") ?>\n AND (taxpay_id IS NOT NULL)\n<? endif ?>\n)\nUNION ALL\n--Voucher Line Item\nSELECT \n  COALESCE(taxpay_distdate, taxhist_distdate) AS taxhist_distdate,\n  taxhist_journalnumber, tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  COALESCE(taxzone_code,<? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n  vohead_number AS docnumber, \n  <? value("purchase") ?> AS source,\n  <? value("voucher") ?>  AS doctype,\n  COALESCE(item_number,expcat_code), COALESCE(item_descrip1,expcat_descrip) AS description,\n  pohead_number AS ordernumber, vohead_docdate AS docdate,\n  vend_name AS name, \n  voitem_qty AS qty, \n  COALESCE(SUM(vodist_amount),0)/voitem_qty AS unitprice, COALESCE(SUM(vodist_amount),0) AS amount,\n  0 AS salesbase,\n  0 AS freightbase,\n  0 AS freighttax,\n  currToBase(vohead_curr_id, COALESCE(SUM(vodist_amount),0), vohead_distdate)  AS purchasebase,\n  COALESCE(taxpay_tax, taxhist_tax) AS taxlocal,\n  COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS taxbase,\n  0 AS salestaxbase,\n  COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS purchasetaxbase,\n  'qty' AS qty_xtnumericrole,\n  'purchaseprice' AS unitprice_xtnumericrole,\n  'extprice' AS amount_xtnumericrole,\n  'curr' AS taxhist_tax_xtnumericrole,\n  'curr' AS taxbase_xtnumericrole,\n   0 AS taxbase_xttotalrole\nFROM voitemtax\n JOIN voitem ON (voitem_id=taxhist_parent_id)\n JOIN vohead ON (vohead_id=voitem_vohead_id)\n JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN poitem ON (voitem_poitem_id=poitem_id)\n JOIN vodist ON ((vodist_poitem_id=poitem_id)\n            AND  (vodist_vohead_id=vohead_id))\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN expcat ON (expcat_id=poitem_expcat_id)\n LEFT OUTER JOIN taxpay ON (taxpay_taxhist_id=taxhist_id)\nWHERE ((true)\n<? if exists("distDate") ?>\n AND (taxhist_distdate BETWEEN <? value("startDate") ?>\n                           AND <? value("endDate") ?>)\n<? else ?>\n AND (taxhist_docdate BETWEEN <? value("startDate") ?>\n                          AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (taxzone_id=<? value("taxzone_id") ?>)\n<? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n<? if exists("cashbasedtax") ?>\n AND (taxpay_id IS NOT NULL)\n<? endif ?>\n)\nGROUP BY taxhist_id, taxpay_distdate,taxhist_distdate,tax_code,tax_descrip,\n  taxtype_name,taxtype_descrip,taxclass_code,taxclass_descrip,\n  taxauth_code,taxauth_descrip,taxzone,taxzone_descrip,curr_abbr,\n  vohead_number,pohead_number,item_number,item_descrip1,\n  vohead_curr_id,vohead_distdate,vohead_docdate,vend_name,\n  expcat_code,expcat_descrip,taxhist_tax,taxhist_curr_rate,\n  voitem_qty, taxhist_journalnumber, taxpay_tax\n<? endif ?>\n-------------END PURCHASE--------------\nORDER BY docdate DESC, docnumber DESC\n\n<? if exists("summary") ?>\n) AS data\nGROUP BY <? literal("groupBy") ?>, <? literal("groupBy") ?>_descrip\nORDER BY <? literal("groupBy") ?>\n<? endif ?>\n\n      admin   2014-10-06      0
101051
 
415     glseries        postjournal      \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: glseries\n-- Name:  postjournal\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT postJournals(<? value("sequence") ?>) AS result;\n     admin   2014-10-06      0
101052
 
429     invoices        print    used by printInvoices\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: invoices\n-- Name: print\n-- Notes: used by printInvoices\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT invchead_id,          invchead_id         AS docid,\n       invchead_invcnumber,  invchead_invcnumber AS docnumber,\n       invchead_ordernumber, invchead_posted     AS posted,\n       findCustomerForm(invchead_cust_id, 'I')   AS reportname\n  FROM invchead\n  WHERE (NOT invchead_printed)\n    AND (NOT invchead_posted)\n    AND (checkInvoiceSitePrivs(invchead_id))\n<? if exists("shipvia") ?>\n    AND (invchead_shipvia=<? value("shipvia") ?>) \n<? endif ?>\nORDER BY invchead_ordernumber;\n      admin   2014-10-06      0
101053
 
51      inventoryAvailability   byCustOrSO       query to get item availability by either customer id/type/pattern\n        or by cohead_id\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: inventoryAvailability\n-- Name:  byCustOrSO\n-- Notes: query to get item availability by either customer id/type/pattern\n--        or by cohead_id\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT id, altid, cohead_id,\n       item_number, descrip, uom_name,\n       qoh, sobalance, allocated, ordered,\n       atshipping,\n       CASE WHEN (xtindentrole=1) THEN\n<? if exists("useReservationNetting") ?>\n                  coitem_qtyreserved\n<? else ?>\n                  (qoh + ordered - sobalance)\n<? endif ?>\n            WHEN (xtindentrole=2) THEN (qoh + ordered - sobalance)\n       END AS orderavail,\n       (qoh + ordered - allocated) AS totalavail,\n       orderdate, duedate,\n       reorderlevel,\n<? if exists("sohead_id") ?> (xtindentrole - 1) AS <? endif ?> xtindentrole, \n       'qty' AS qoh_xtnumericrole,\n       'qty' AS sobalance_xtnumericrole,\n       'qty' AS allocated_xtnumericrole,\n       'qty' AS ordered_xtnumericrole,\n       'qty' AS orderavail_xtnumericrole,\n       'qty' AS totalavail_xtnumericrole,\n       'qty' AS atshipping_xtnumericrole,\n       CASE WHEN (pack_id IS NOT NULL) THEN 'altemphasis'\n       END AS qtforegroundrole,\n       CASE WHEN (qoh < 0) THEN 'error'\n            WHEN (qoh < reorderlevel) THEN 'warning'\n       END AS qoh_qtforegroundrole,\n       CASE WHEN (\n<? if exists("useReservationNetting") ?>\n                  coitem_qtyreserved < 0\n<? else ?>\n                  (qoh + ordered - sobalance) < 0\n<? endif ?>\n                 ) THEN 'error'\n            WHEN ((qoh + ordered - sobalance) <= reorderlevel) THEN 'warning'\n       END AS orderavail_qtforegroundrole,\n       CASE WHEN ((qoh + ordered - allocated) < 0) THEN 'error'\n            WHEN ((qoh + ordered - allocated) <= reorderlevel) THEN 'warning'\n       END AS totalavail_qtforegroundrole,\n       CASE WHEN (xtindentrole = 2 AND (orderdate <= CURRENT_DATE)\n              AND (descrip IN ('O','E','S','R'))) THEN 'error'\n       END AS atshipping_qtforegroundrole,\n       CASE WHEN (xtindentrole = 2 AND duedate<=CURRENT_DATE) THEN 'error'\n       END AS orderdate_qtforegroundrole,\n       CASE WHEN (xtindentrole = 2 AND duedate<=CURRENT_DATE) THEN 'error'\n       END AS duedate_qtforegroundrole,\n<? if exists("useReservationNetting") ?>\n       CASE WHEN (coitem_qtyreserved > 0\n              AND sobalance > coitem_qtyreserved) THEN 'emphasis'\n            WHEN ((sobalance <> 0)\n              AND ((sobalance - coitem_qtyreserved) = 0)) THEN 'altemphasis'\n       END AS qtforegroundrole,\n<? endif ?>\n       CASE WHEN (xtindentrole = 2) THEN ''\n       END AS sobalance_qtdisplayrole\nFROM (\n<? if not exists("sohead_id") ?>\n    SELECT cohead_id AS id, -2 AS altid, cohead_id, cohead_number,\n           cohead_number AS item_number,\n           '' AS trueitem_number,\n           (cust_number||'-'||cust_name) AS descrip,\n           '' AS uom_name, CAST(NULL AS NUMERIC) AS qoh,\n           CAST(NULL AS NUMERIC) AS sobalance,\n           CAST(NULL AS NUMERIC) AS allocated,\n           CAST(NULL AS NUMERIC) AS ordered,\n           CAST(NULL AS NUMERIC) AS atshipping,\n           CAST(NULL AS NUMERIC) AS coitem_qtyreserved,\n           cohead_orderdate AS orderdate, MIN(coitem_scheddate) AS duedate,\n           pack_id,\n           CAST(NULL AS NUMERIC) AS reorderlevel,\n           0 AS xtindentrole\n     FROM cohead\n     LEFT OUTER JOIN pack ON (pack_head_type='SO' AND pack_head_id=cohead_id)\n     JOIN custinfo ON (cohead_cust_id=cust_id)\n     JOIN coitem   ON (coitem_cohead_id=cohead_id)\n     JOIN itemsite ON (coitem_itemsite_id=itemsite_id)\n     WHERE ((coitem_status NOT IN ('C', 'X'))\n  <? if exists("custtype_id") ?>\n        AND (cust_custtype_id=<? value("custtype_id") ?>)\n  <? elseif exists("custtype_pattern") ?>\n        AND (cust_custtype_id IN (SELECT custtype_id\n                                  FROM custtype\n                                  WHERE(custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? endif ?>\n      )\n      GROUP BY cohead_id, item_number, cust_number,\n               cust_name, cohead_orderdate, pack_id, coitem_scheddate\n  <? if exists("onlyShowShortages") ?>\n      HAVING (MIN(noNeg(qtyAvailable(itemsite_id)) +\n                  qtyOrdered(itemsite_id, coitem_scheddate) -\n                  qtyAllocated(itemsite_id, coitem_scheddate)) < 0\n              OR MIN(noNeg(qtyAvailable(itemsite_id)) +\n                  qtyOrdered(itemsite_id, coitem_scheddate) -\n                  noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) < 0\n           )\n  <? endif ?>\n    UNION\n<? endif ?>\n    SELECT itemsite_id AS id, coitem_id AS altid, cohead_id, cohead_number,\n            item_number,\n            item_number AS trueitem_number,\n            (item_descrip1 || ' ' || item_descrip2) AS descrip,\n            uom_name, noNeg(qtyAvailable(itemsite_id)) AS qoh,\n            noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS sobalance,\n            qtyAllocated(itemsite_id, coitem_scheddate) AS allocated,\n            qtyOrdered(itemsite_id, coitem_scheddate) AS ordered,\n            qtyatshipping(coitem_id) AS atshipping,\n            itemuomtouom(item_id, coitem_qty_uom_id, null, coitem_qtyreserved) AS coitem_qtyreserved,\n            CAST(NULL AS DATE) AS orderdate, coitem_scheddate AS duedate,\n            CAST(NULL AS INTEGER) AS pack_id,\n            CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel\n                 ELSE 0.0 END AS reorderlevel,\n            1 AS xtindentrole\n     FROM cohead\n<? if not exists("sohead_id") ?> JOIN custinfo ON (cohead_cust_id=cust_id)<? endif ?>\n          , itemsite, item, uom, site(), coitem\n     WHERE ((coitem_cohead_id=cohead_id)\n        AND (coitem_itemsite_id=itemsite_id)\n        AND (itemsite_warehous_id=warehous_id)\n        AND (itemsite_item_id=item_id)\n        AND (item_inv_uom_id=uom_id)\n        AND (coitem_status NOT IN ('C', 'X'))\n<? if exists("sohead_id") ?>\n        AND (cohead_id=<? value("sohead_id") ?>)\n<? elseif exists("custtype_id") ?>\n        AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n        AND (cust_custtype_id IN (SELECT custtype_id\n                                  FROM custtype\n                                  WHERE(custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("onlyShowShortages") ?>\n        AND ((noNeg(qtyAvailable(itemsite_id)) + qtyOrdered(itemsite_id, coitem_scheddate) - qtyAllocated(itemsite_id, coitem_scheddate) < 0)\n          OR (noNeg(qtyAvailable(itemsite_id)) + qtyOrdered(itemsite_id, coitem_scheddate) - noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) < 0))\n<? endif ?>\n    )\n<? if exists("showWoSupply") ?>\n    UNION\n    SELECT  itemsite_id, -1, cohead_id, cohead_number,\n            formatwonumber(wo_id),\n            item_number AS trueitem_number,\n            wo_status,\n            NULL, NULL,\n            noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS sobalance,\n            NULL,\n            noNeg((wo_qtyord-wo_qtyrcv)) AS ordered,\n            NULL,\n            NULL,\n            wo_startdate, wo_duedate,\n            NULL AS pack_id,\n            CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel\n                 ELSE 0.0 END AS reorderlevel,\n            2 AS xtindentrole\n     FROM cohead\n<? if not exists("sohead_id") ?> JOIN custinfo ON (cohead_cust_id=cust_id)<? endif ?>\n          , itemsite, item, uom, site(), coitem\n          LEFT OUTER JOIN wo\n           ON ((coitem_itemsite_id=wo_itemsite_id)\n           AND (wo_status IN ('E','R','I'))\n           AND (wo_qtyord-wo_qtyrcv > 0)\n           AND (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned-qtyatshipping(coitem_id)) >\n            (SELECT qtyAvailable(itemsite_id) FROM itemsite WHERE (itemsite_id=coitem_itemsite_id))))\n     WHERE ((coitem_cohead_id=cohead_id)\n        AND (coitem_itemsite_id=itemsite_id)\n        AND (itemsite_warehous_id=warehous_id)\n        AND (itemsite_item_id=item_id)\n        AND (item_inv_uom_id=uom_id)\n        AND (coitem_status NOT IN ('C', 'X'))\n  <? if exists("sohead_id") ?>\n        AND (cohead_id=<? value("sohead_id") ?>)\n  <? elseif exists("custtype_id") ?>\n        AND (cust_custtype_id=<? value("custtype_id") ?>)\n  <? elseif exists("custtype_pattern") ?>\n        AND (cust_custtype_id IN (SELECT custtype_id\n                                  FROM custtype\n                                  WHERE(custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? endif ?>\n  <? if exists("onlyShowShortages") ?>\n        AND ((noNeg(qtyAvailable(itemsite_id)) + qtyOrdered(itemsite_id, coitem_scheddate) - qtyAllocated(itemsite_id, coitem_scheddate) < 0)\n          OR (noNeg(qtyAvailable(itemsite_id)) + qtyOrdered(itemsite_id, coitem_scheddate) - noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) < 0))\n  <? endif ?>\n  )\n<? endif ?>\n) AS data\nORDER BY duedate, cohead_number, trueitem_number,\n         xtindentrole;\n        admin   2014-10-06      0
101054
 
54      inventoryHistory        detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: inventoryHistory\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT invhist_id, invdetail_id, invhist_transdate AS sortdate,\n       formatDateTime(invhist_transdate) AS transdate,\n       CASE WHEN (level=0) THEN invhist_transdate END AS invhist_transdate,\n       CASE WHEN (level=0) THEN invhist_created END AS invhist_created,\n       CASE WHEN (level=0) THEN invhist_user END AS invhist_user,\n       CASE WHEN (level=0) THEN invhist_transtype END AS invhist_transtype,\n       CASE WHEN (level=0) THEN warehous_code END AS warehous_code,\n       CASE WHEN (level=0) THEN ordernumber\n            ELSE locationname\n       END AS orderlocation,\n       CASE WHEN (level=0) THEN item_number END AS item_number,\n       CASE WHEN (level=0) THEN invhist_invuom END AS invhist_invuom,\n       CASE WHEN (level=0 AND invhist_transtype IN ('EX','IM','SH','SI')) THEN (invhist_invqty * -1.0)\n            WHEN (level=0) THEN invhist_invqty\n            ELSE invdetail_qty\n       END AS transqty,\n       CASE WHEN (level=0) THEN invhist_value_after - invhist_value_before\n       END AS transvalue,\n       CASE WHEN (level=0) THEN locfrom END AS locfrom,\n       CASE WHEN (level=0) THEN invhist_qoh_before\n            ELSE invdetail_qty_before\n       END AS qohbefore,\n       CASE WHEN (level=0) THEN locto END AS locto,\n       CASE WHEN (level=0) THEN invhist_qoh_after\n            ELSE invdetail_qty_after\n       END AS qohafter,\n       CASE WHEN (level=0) THEN costmethod END AS costmethod,\n       CASE WHEN (level=0) THEN invhist_value_before END AS invhist_value_before,\n       CASE WHEN (level=0) THEN invhist_value_after END AS invhist_value_after,\n       'qty' AS transqty_xtnumericrole,\n       'curr' AS transvalue_xtnumericrole,\n       0 AS transvalue_xttotalrole,\n       'qty' AS qohbefore_xtnumericrole,\n       'qty' AS qohafter_xtnumericrole,\n       'curr' AS invhist_value_before_xtnumericrole,\n       'curr' AS invhist_value_after_xtnumericrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS qohbefore_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS qohafter_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS invhist_value_before_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS invhist_value_after_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS costmethod_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS locto_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS locfrom_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN 'warning' END AS qtforegroundrole,\n       level AS xtindentrole\nFROM (\nSELECT invhist.*, 0 AS level,\n       whs1.warehous_code AS warehous_code, item_number,\n       CASE WHEN (invhist_ordtype NOT LIKE '') THEN (invhist_ordtype || '-' || invhist_ordnumber)\n            ELSE invhist_ordnumber\n       END AS ordernumber,\n       CASE WHEN (invhist_costmethod='A') THEN <? value("average") ?>\n            WHEN (invhist_costmethod='S') THEN <? value("standard") ?>\n            WHEN (invhist_costmethod='J') THEN <? value("job") ?>\n            WHEN (invhist_costmethod='N') THEN <? value("none") ?>\n            ELSE <? value("unknown") ?>\n       END AS costmethod,\n       0 AS invdetail_id, '' AS locationname,\n       0 AS invdetail_qty, 0 AS invdetail_qty_before, 0 AS invdetail_qty_after,\n       CASE WHEN (invhist_transtype='TW' AND invhist_invqty < 0) THEN whs1.warehous_code\n            WHEN (invhist_transtype='TW') THEN whs2.warehous_code\n            WHEN (invhist_transtype='AD' AND invhist_invqty < 0) THEN whs1.warehous_code\n            WHEN (invhist_transtype='AD') THEN 'ADJ'\n            WHEN (invhist_transtype='EX') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IB') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IM' AND invhist_invqty < 0) THEN 'WIP'\n            WHEN (invhist_transtype='IM') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IT') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RB') THEN 'WIP'\n            WHEN (invhist_transtype='RM') THEN 'WIP'\n            WHEN (invhist_transtype='RP') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RR') THEN 'CUST'\n            WHEN (invhist_transtype='RS') THEN 'SHIP'\n            WHEN (invhist_transtype='SH') THEN whs1.warehous_code\n            WHEN (invhist_transtype='SI') THEN whs1.warehous_code\n            WHEN (invhist_transtype='SV') THEN whs1.warehous_code\n\t WHEN (invhist_transtype='TR') THEN whs2.warehous_code\n\t WHEN (invhist_transtype='TS') THEN whs1.warehous_code\n\t WHEN (invhist_transtype='RI') THEN whs1.warehous_code\n            ELSE ''\n       END AS locfrom,\n       CASE WHEN (invhist_transtype='TW' AND invhist_invqty < 0) THEN whs2.warehous_code\n            WHEN (invhist_transtype='TW') THEN whs1.warehous_code\n            WHEN (invhist_transtype='AD' AND invhist_invqty < 0) THEN 'ADJ'\n            WHEN (invhist_transtype='AD') THEN whs1.warehous_code\n            WHEN (invhist_transtype='CC') THEN whs1.warehous_code\n            WHEN (invhist_transtype='EX') THEN 'EXPENSE'\n            WHEN (invhist_transtype='IB') THEN 'WIP'\n            WHEN (invhist_transtype='IM' AND invhist_invqty < 0) THEN whs1.warehous_code\n            WHEN (invhist_transtype='IM') THEN 'WIP'\n            WHEN (invhist_transtype='NN') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RB') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RM') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RP') THEN 'PURCH'\n            WHEN (invhist_transtype='RR') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RS') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RT') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RX') THEN whs1.warehous_code\n            WHEN (invhist_transtype='SH') THEN 'SHIP'\n            WHEN (invhist_transtype='SI') THEN 'SCRAP'\n            WHEN (invhist_transtype='SV') THEN 'SHIP'\n            WHEN (invhist_transtype='TR') THEN whs1.warehous_code\n            WHEN (invhist_transtype='TS') THEN whs2.warehous_code\n            WHEN (invhist_transtype='RI') THEN 'WIP'\n            ELSE ''\n       END AS locto \nFROM itemsite, item, whsinfo AS whs1, invhist\n  LEFT OUTER JOIN whsinfo AS whs2 ON (invhist_xfer_warehous_id=whs2.warehous_id)\nWHERE ( (invhist_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id) \n  AND  (itemsite_warehous_id=whs1.warehous_id)\n  AND  (DATE(invhist_transdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?> )\n  AND  (transType(invhist_transtype, <? value("transType") ?>))\n<? if exists("orderNumber") ?>\n  AND  (invhist_ordnumber ~ <? value("orderNumber") ?>)\n<? endif ?>\n<? if exists("cohead_id") ?>\n  AND  (invhist_ordtype='SO')\n  AND  (invhist_ordnumber ~ (\n    SELECT cohead_number \n    FROM cohead \n    WHERE cohead_id=<? value("cohead_id") ?>))\n<? endif ?>\n<? if exists("pohead_id") ?>\n  AND  (invhist_ordtype='PO')\n  AND  (invhist_ordnumber ~ (\n    SELECT pohead_number \n    FROM pohead \n    WHERE pohead_id=<? value("pohead_id") ?>))\n<? endif ?>\n<? if exists("tohead_id") ?>\n  AND  (invhist_ordtype='TO')\n  AND  (invhist_ordnumber ~ (\n    SELECT tohead_number \n    FROM tohead \n    WHERE tohead_id=<? value("tohead_id") ?>))\n<? endif ?>\n<? if exists("wo_id") ?>\n  AND  (invhist_ordtype='WO')\n  AND  (invhist_ordnumber ~ formatWoNumber(<? value("wo_id") ?>))\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n  AND  (item_classcode_id=<? value("classcode_id") ?>)\n<? endif ?>\n<? if exists("itemgrp_id") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem\n\t\t   WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? endif ?>\n<? if exists("plancode_id") ?>\n  AND  (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? endif ?>\n<? if exists("classcode_pattern") ?>\n  AND  (item_classcode_id IN (SELECT classcode_id\n\t\t\t      FROM classcode\n\t\t\t      WHERE (classcode_code ~ <? value ("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp_pattern") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem, itemgrp\n\t\t   WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t     AND  (itemgrp_name ~ <? value ("itemgrp_pattern") ?>))))\n<? endif ?>\n<? if exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp") ?>\n  AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n<? endif ?>\n) \nUNION SELECT invhist.*, 1 AS level,\n             '' AS warehous_code, '' AS item_number,\n             '' AS ordernumber,\n             '' AS costmethod,\n             invdetail_id,\n             CASE WHEN (invdetail_location_id=-1) THEN formatlotserialnumber(invdetail_ls_id)\n                  WHEN (invdetail_ls_id IS NULL) THEN formatLocationName(invdetail_location_id)\n                  ELSE (formatLocationName(invdetail_location_id) || '-' || formatlotserialnumber(invdetail_ls_id))\n             END AS locationname,\n             invdetail_qty, invdetail_qty_before, invdetail_qty_after,\n             '' AS locfrom,\n             '' AS locto \nFROM itemsite, item, whsinfo AS whs1, invdetail, invhist LEFT OUTER JOIN\n     whsinfo AS whs2 ON (invhist_xfer_warehous_id=whs2.warehous_id)\nWHERE ((invhist_hasdetail)\n  AND (invhist_itemsite_id=itemsite_id)\n  AND (itemsite_item_id=item_id)\n  AND (itemsite_warehous_id=whs1.warehous_id)\n  AND (invdetail_invhist_id=invhist_id)\n  AND  (DATE(invhist_transdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?> )\n  AND (transType(invhist_transtype, <? value("transType") ?>))\n<? if exists("orderType") ?>\n  AND  (invhist_ordtype=<? value("orderType") ?>)\n<? endif ?>\n<? if exists("orderNumber") ?>\n  AND  (invhist_ordnumber ~ <? value("orderNumber") ?>)\n<? endif ?>\n<? if exists("cohead_id") ?>\n  AND  (invhist_ordtype='SO')\n  AND  (invhist_ordnumber ~ (\n    SELECT cohead_number \n    FROM cohead \n    WHERE cohead_id=<? value("cohead_id") ?>))\n<? endif ?>\n<? if exists("pohead_id") ?>\n  AND  (invhist_ordtype='PO')\n  AND  (invhist_ordnumber ~ (\n    SELECT pohead_number \n    FROM pohead \n    WHERE pohead_id=<? value("pohead_id") ?>))\n<? endif ?>\n<? if exists("tohead_id") ?>\n  AND  (invhist_ordtype='TO')\n  AND  (invhist_ordnumber ~ (\n    SELECT tohead_number \n    FROM tohead \n    WHERE tohead_id=<? value("tohead_id") ?>))\n<? endif ?>\n<? if exists("wo_id") ?>\n  AND  (invhist_ordtype='WO')\n  AND  (invhist_ordnumber ~ formatWoNumber(<? value("wo_id") ?>))\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n  AND  (item_classcode_id=<? value("classcode_id") ?>)\n<? endif ?>\n<? if exists("itemgrp_id") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem\n\t\t   WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? endif ?>\n<? if exists("plancode_id") ?>\n  AND  (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? endif ?>\n<? if exists("classcode_pattern") ?>\n  AND  (item_classcode_id IN (SELECT classcode_id\n\t\t\t      FROM classcode\n\t\t\t      WHERE (classcode_code ~ <? value ("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp_pattern") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem, itemgrp\n\t\t   WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t     AND  (itemgrp_name ~ <? value ("itemgrp_pattern") ?>))))\n<? endif ?>\n<? if exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp") ?>\n  AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n<? endif ?>\n)\n\n   ) AS data\nORDER BY sortdate DESC, invhist_id, level;\n      admin   2014-10-06      0
101055
 
59      maintainShipping        detail   used by maintainShipping\n        order header info\n        Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: maintainShipping\n-- Name: detail\n-- Notes: used by maintainShipping\n--        order header info\n--        Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\n-- order header info\nSELECT shiphead_id AS parent_id, cohead_id AS child_id,\n       shiphead_number, cohead_number AS linenumber,\n       'SO' AS ordertype,\n       CASE WHEN (shiphead_sfstatus='N') THEN <? value("notPrinted") ?>\n            WHEN (shiphead_sfstatus='D') THEN <? value("dirty") ?>\n            WHEN (shiphead_sfstatus='P') THEN <? value("printed") ?>\n            ELSE <? value("error") ?>\n       END AS sfstatus,\n       cust_number AS dest, cust_name AS description,\n       shiphead_shipvia, NULL AS uom_name,\n       NULL AS shipqty, NULL AS shipvalue,\n<? if exists("includeFormatted") ?>\n       NULL AS f_shipqty, NULL AS f_shipvalue,\n<? endif ?>\n       cohead_holdtype AS holdtype,\n       shiphead_notes AS notes,\n       shiphead_number AS shiphead_number_qtdisplayrole,\n       'SO' AS ordertype_qtdisplayrole,\n       'qty' AS shipqty_xtnumericrole,\n       'cost' AS shipvalue_xtnumericrole,\n       0 AS shipvalue_xttotalrole,\n       0 AS xtindentrole,\n       shiphead_id AS seq1, shiphead_order_id AS seq2,\n       0 AS seq3, 0 AS seq4\nFROM shiphead, custinfo, cohead\n <? if exists("warehous_id") ?>\n      JOIN coitem ON (coitem_cohead_id=cohead_id)\n      JOIN itemsite ON ((coitem_itemsite_id=itemsite_id)\n                    AND (itemsite_warehous_id=<? value("warehous_id") ?>))\n <? endif ?>\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='SO')\n AND (shiphead_order_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n<? if exists("cust_id") ?>\n AND (cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("cohead_id") ?>\n AND (cohead_id=<? value("cohead_id") ?>)\n<? endif ?>\n) \n-- order line info\nUNION ALL\nSELECT cohead_id AS parent_id, coitem_id AS child_id,\n       '' AS shiphead_number, CAST(coitem_linenumber AS TEXT) AS linenumber,\n       'SO Item' AS ordertype,\n       NULL AS sfstatus,\n       item_number AS dest, (item_descrip1 || ' ' || item_descrip2) AS description,\n       NULL AS shiphead_shipvia, uom_name,\n       qtyAtShipping('SO', coitem_id) AS shipqty,\n       valueAtShipping('SO', coitem_id) AS shipvalue,\n<? if exists("includeFormatted") ?>\n       formatQty(qtyAtShipping('SO', coitem_id)) AS f_shipqty,\n       formatCost(valueAtShipping('SO', coitem_id)) AS f_shipvalue,\n<? endif ?>\n       cohead_holdtype AS holdtype,\n       '' as notes,\n       NULL AS shiphead_number_qtdisplayrole,\n       NULL AS ordertype_qtdisplayrole,\n       'qty' AS shipqty_xtnumericrole,\n       'cost' AS shipvalue_xtnumericrole,\n       0 AS shipvalue_xttotalrole,\n       1 AS xtindentrole,\n       shiphead_id AS seq1, shiphead_order_id AS seq2,\n       coitem_id AS seq3, 0 AS seq4\nFROM shiphead, cohead, coitem, uom, itemsite, item\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='SO')\n AND (shiphead_order_id=cohead_id)\n AND (cohead_id=coitem_cohead_id)\n AND (coitem_qty_uom_id=uom_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n <? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n <? endif ?>\n<? if exists("cust_id") ?>\n AND (cohead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("cohead_id") ?>\n AND (cohead_id=<? value("cohead_id") ?>)\n<? endif ?>\n) \n-- shipitem info\nUNION ALL\nSELECT shiphead_id AS parent_id, shipitem_id AS child_id,\n       '' AS shiphead_number, '' AS linenumber,\n       'SO Ship' AS ordertype,\n       NULL AS sfstatus,\n       '' AS dest,\n       formatDate(shipitem_transdate) || ' by ' || shipitem_trans_username AS description,\n       '' AS shiphead_shipvia, '' AS uom_name,\n       shipitem_qty AS shipqty,\n       NULL AS shipvalue,\n<? if exists("includeFormatted") ?>\n       formatQty(shipitem_qty) AS f_shipqty,\n       NULL AS f_shipvalue,\n<? endif ?>\n       '' AS holdtype,\n       '' AS notes,\n       NULL AS shiphead_number_qtdisplayrole,\n       NULL AS ordertype_qtdisplayrole,\n       'qty' AS shipqty_xtnumericrole,\n       'cost' AS shipvalue_xtnumericrole,\n       0 AS shipvalue_xttotalrole,\n       2 AS xtindentrole,\n       shiphead_id AS seq1, shiphead_order_id AS seq2,\n       shipitem_orderitem_id AS seq3, shipitem_id AS seq4\nFROM shiphead JOIN cohead ON (cohead_id=shiphead_order_id)\n              JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n <? if exists("warehous_id") ?>\n      JOIN coitem ON ((shipitem_orderitem_id=coitem_id)\n                  AND (shiphead_order_type='SO'))\n      JOIN itemsite ON ((coitem_itemsite_id=itemsite_id)\n                    AND (itemsite_warehous_id=<? value("warehous_id") ?>))\n <? endif ?>\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='SO')\n<? if exists("cust_id") ?>\n AND (cohead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("cohead_id") ?>\n AND (cohead_id=<? value("cohead_id") ?>)\n<? endif ?>\n) \n<? if exists("includeDistributions") ?>\n-- distribution info\nUNION ALL\nSELECT shiphead_id AS parent_id, shipitem_id AS child_id,\n       '' AS shiphead_number, '' AS linenumber,\n       'SO Dist' AS ordertype,\n       NULL AS sfstatus,\n       formatLocationName(invdetail_location_id) AS dest,\n       formatLotSerialNumber(invdetail_ls_id) AS description,\n       formatDate(invdetail_expiration) AS shiphead_shipvia, '' AS uom_name,\n       invdetail_qty AS shipqty,\n       NULL AS shipvalue,\n<? if exists("includeFormatted") ?>\n       formatQty(invdetail_qty) AS f_shipqty,\n       NULL AS f_shipvalue,\n<? endif ?>\n       '' AS holdtype,\n       '' AS notes,\n       NULL AS shiphead_number_qtdisplayrole,\n       NULL AS ordertype_qtdisplayrole,\n       'qty' AS shipqty_xtnumericrole,\n       'cost' AS shipvalue_xtnumericrole,\n       0 AS shipvalue_xttotalrole,\n       3 AS xtindentrole,\n       shiphead_id AS seq1, shiphead_order_id AS seq2,\n       shipitem_orderitem_id AS seq3, shipitem_id AS seq4\nFROM shiphead JOIN cohead ON (cohead_id=shiphead_order_id)\n              JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n              LEFT OUTER JOIN invhist ON (invhist_id=shipitem_invhist_id)\n              LEFT OUTER JOIN invdetail ON (invdetail_invhist_id=invhist_id)\n <? if exists("warehous_id") ?>\n      JOIN coitem ON ((shipitem_orderitem_id=coitem_id)\n                  AND (shiphead_order_type='SO'))\n      JOIN itemsite ON ((coitem_itemsite_id=itemsite_id)\n                    AND (itemsite_warehous_id=<? value("warehous_id") ?>))\n <? endif ?>\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='SO')\n<? if exists("cust_id") ?>\n AND (cohead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("cohead_id") ?>\n AND (cohead_id=<? value("cohead_id") ?>)\n<? endif ?>\n) \n<? endif ?>\n\n<? if exists("MultiWhs") ?>\nUNION ALL\n-- order header info\nSELECT shiphead_id AS parent_id, tohead_id AS child_id,\n       shiphead_number, tohead_number AS linenumber,\n       'TO' AS ordertype,\n       CASE WHEN (shiphead_sfstatus='N') THEN <? value("notPrinted") ?>\n            WHEN (shiphead_sfstatus='D') THEN <? value("dirty") ?>\n            WHEN (shiphead_sfstatus='P') THEN <? value("printed") ?>\n            ELSE <? value("error") ?>\n       END AS sfstatus,\n       tohead_destname AS dest, tohead_destcntct_name AS description,\n       shiphead_shipvia, NULL AS uom_name,\n       NULL AS shipqty, NULL AS shipvalue,\n<? if exists("includeFormatted") ?>\n       NULL AS f_shipqty, NULL AS f_shipvalue,\n<? endif ?>\n       'TO' AS holdtype,\n       shiphead_notes AS notes,\n       shiphead_number AS shiphead_number_qtdisplayrole,\n       'TO' AS ordertype_qtdisplayrole,\n       'qty' AS shipqty_xtnumericrole,\n       'cost' AS shipvalue_xtnumericrole,\n       0 AS shipvalue_xttotalrole,\n       0 AS xtindentrole,\n       shiphead_id AS seq1, shiphead_order_id AS seq2,\n       0 AS seq3, 0 AS seq4\nFROM shiphead, tohead\n <? if exists("warehous_id") ?>\n      JOIN toitem ON (toitem_tohead_id=tohead_id)\n      JOIN itemsite ON ((toitem_item_id=itemsite_item_id)\n                    AND (itemsite_warehous_id=<? value("warehous_id") ?>))\n <? endif ?>\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='TO')\n AND (shiphead_order_id=tohead_id)\n<? if exists("cust_id") ?>\n AND FALSE\n<? endif ?>\n<? if exists("cohead_id") ?>\n AND FALSE\n<? endif ?>\n) \n-- order line info\nUNION ALL\nSELECT tohead_id AS parent_id, toitem_id AS child_id,\n       '' AS shiphead_number, CAST(toitem_linenumber AS TEXT) AS linenumber,\n       'TO' AS ordertype,\n       NULL AS sfstatus,\n       item_number AS dest, (item_descrip1 || ' ' || item_descrip2) AS description,\n       NULL AS shiphead_shipvia, toitem_uom AS uom_name,\n       qtyAtShipping('TO', toitem_id) AS shipqty,\n       valueAtShipping('TO', toitem_id) AS shipvalue,\n<? if exists("includeFormatted") ?>\n       formatQty(qtyAtShipping('TO', toitem_id)) AS f_shipqty,\n       formatCost(valueAtShipping('TO', toitem_id)) AS f_shipvalue,\n<? endif ?>\n       'TO' AS holdtype,\n       '' AS notes,\n       NULL AS shiphead_number_qtdisplayrole,\n       NULL AS ordertype_qtdisplayrole,\n       'qty' AS shipqty_xtnumericrole,\n       'cost' AS shipvalue_xtnumericrole,\n       0 AS shipvalue_xttotalrole,\n       1 AS xtindentrole,\n       shiphead_id AS seq1, shiphead_order_id AS seq2,\n       toitem_id AS seq3, 0 AS seq4\nFROM shiphead, tohead, item, toitem\n <? if exists("warehous_id") ?>\n      JOIN itemsite ON ((toitem_item_id=itemsite_item_id)\n                    AND (itemsite_warehous_id=<? value("warehous_id") ?>))\n <? endif ?>\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='TO')\n AND (shiphead_order_id=tohead_id)\n AND (tohead_id=toitem_tohead_id)\n AND (toitem_item_id=item_id)\n<? if exists("cust_id") ?>\n AND FALSE\n<? endif ?>\n<? if exists("cohead_id") ?>\n AND FALSE\n<? endif ?>\n) \n-- shipitem info\nUNION\nSELECT shiphead_id AS parent_id, shipitem_id AS child_id,\n       '' AS shiphead_number, '' AS linenumber,\n       'TO' AS ordertype,\n       NULL AS sfstatus,\n       '' AS dest,\n       formatDate(shipitem_transdate) || ' by ' || shipitem_trans_username AS description,\n       '' AS shiphead_shipvia, '' AS uom_name,\n       shipitem_qty AS shipqty,\n       NULL AS shipvalue,\n<? if exists("includeFormatted") ?>\n       formatQty(shipitem_qty) AS f_shipqty,\n       NULL AS f_shipvalue,\n<? endif ?>\n       '' AS holdtype,\n       '' AS notes,\n       NULL AS shiphead_number_qtdisplayrole,\n       NULL AS ordertype_qtdisplayrole,\n       'qty' AS shipqty_xtnumericrole,\n       'cost' AS shipvalue_xtnumericrole,\n       0 AS shipvalue_xttotalrole,\n       2 AS xtindentrole,\n       shiphead_id AS seq1, shiphead_order_id AS seq2,\n       shipitem_orderitem_id AS seq3, shipitem_id AS seq4\nFROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n <? if exists("warehous_id") ?>\n      JOIN toitem ON ((shipitem_orderitem_id=toitem_id)\n                  AND (shiphead_order_type='TO'))\n      JOIN itemsite ON ((toitem_item_id=itemsite_item_id)\n                    AND (itemsite_warehous_id=<? value("warehous_id") ?>))\n <? endif ?>\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='TO')\n<? if exists("cust_id") ?>\n AND FALSE\n<? endif ?>\n<? if exists("cohead_id") ?>\n AND FALSE\n<? endif ?>\n) \n\n<? endif ?>\nORDER BY seq1, seq2, seq3, seq4, xtindentrole;\n       admin   2014-10-06      0
101056
 
426     contactmerge    search   Search for contacts\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: contactmerge\n-- Name: search\n-- Notes: Search for contacts\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntct_id,\n  CASE\n    WHEN (cntctsel_cntct_id IS NOT NULL AND cntctsel_target) THEN\n      1 -- Selected as target contact\n    WHEN (cntctsel_cntct_id IS NOT NULL AND NOT cntctsel_target) THEN\n      2 -- Selected as contact to merge\n    WHEN (cntctmrgd_cntct_id IS NOT NULL AND cntctUsed(cntctmrgd_cntct_id)=false) THEN\n      3 -- Already merged contact\n    WHEN (cntctmrgd_cntct_id IS NOT NULL) THEN\n      4 -- Already merged contact, but still has relationships\n    ELSE\n      0 -- No status\n  END AS status,\n  cntctdups.*, \n  cntctdup_level AS xtindentrole,\n  CASE\n    WHEN (cntctsel_cntct_id IS NOT NULL AND cntctsel_target) THEN\n      'altemphasis' -- Selected as target contact\n    WHEN (cntctsel_cntct_id IS NOT NULL AND NOT cntctsel_target) THEN\n      'emphasis' -- Selected as contact to merge\n    WHEN (cntctmrgd_cntct_id IS NOT NULL AND cntctUsed(cntctmrgd_cntct_id)=false) THEN\n      'warning' -- Already merged contact\n    WHEN (cntctmrgd_cntct_id IS NOT NULL) THEN\n      'error' -- Already merged contact, but still has relationships\n  END AS qtforegroundrole\nFROM cntctdups(\n  <? value("searchText") ?>, \n  <? value("searchContactName") ?>, \n  <? value("searchPhone") ?>, \n  <? value("searchEmail") ?>, \n  <? value("searchNumber") ?>, \n  <? value("searchName") ?>, \n  <? value("showInactive") ?>, \n  <? value("ignoreBlanks") ?>,\n  <? value("IndentedDups") ?>, \n  <? value("CheckHnfc") ?>, \n  <? value("CheckFirst") ?>, \n  <? value("CheckMiddle") ?>, \n  <? value("CheckLast") ?>, \n  <? value("CheckSuffix") ?>, \n  <? value("CheckPhone") ?>, \n  <? value("CheckEmail") ?>)\n  LEFT OUTER JOIN cntctsel ON (cntct_id=cntctsel_cntct_id)\n  LEFT OUTER JOIN cntctmrgd ON (cntct_id=cntctmrgd_cntct_id);\n  admin   2014-10-06      0
101057
 
428     contactmerge    select   Processes contact selections\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: contactmerge\n-- Name: select\n-- Notes: Processes contact selections\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctselect(\n  <? value("cntct_id") ?>, \n  <? value("target") ?>) AS result;\n     admin   2014-10-06      0
101058
 
479     salesAccounts   detail   Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: salesAccounts\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT salesaccnt_id,\n       CASE WHEN (salesaccnt_warehous_id=-1) THEN <? value("any") ?>\n            ELSE (SELECT warehous_code FROM whsinfo WHERE (warehous_id=salesaccnt_warehous_id))\n       END AS warehouscode,\n       CASE WHEN ((salesaccnt_custtype_id=-1) AND (salesaccnt_custtype='.*')) THEN <? value("any") ?>\n            WHEN (salesaccnt_custtype_id=-1) THEN salesaccnt_custtype\n            ELSE (SELECT custtype_code FROM custtype WHERE (custtype_id=salesaccnt_custtype_id))\n       END AS custtypecode,\n       CASE WHEN (salesaccnt_shipzone_id=-1) THEN <? value("any") ?>\n            ELSE (SELECT shipzone_name FROM shipzone WHERE (shipzone_id=salesaccnt_shipzone_id))\n       END AS shipzonecode,\n       CASE WHEN (salesaccnt_saletype_id=-1) THEN <? value("any") ?>\n            ELSE (SELECT saletype_code FROM saletype WHERE (saletype_id=salesaccnt_saletype_id))\n       END AS saletypecode,\n       CASE WHEN ((salesaccnt_custtype_id=-1) AND (salesaccnt_custtype='.*')) THEN <? value("any") ?>\n            WHEN (salesaccnt_custtype_id=-1) THEN salesaccnt_custtype\n            ELSE (SELECT custtype_code FROM custtype WHERE (custtype_id=salesaccnt_custtype_id))\n       END AS custtypecode,\n       CASE WHEN ((salesaccnt_prodcat_id=-1) AND (salesaccnt_prodcat='.*')) THEN <? value("any") ?>\n            WHEN (salesaccnt_prodcat_id=-1) THEN salesaccnt_prodcat\n            ELSE (SELECT prodcat_code FROM prodcat WHERE (prodcat_id=salesaccnt_prodcat_id))\n       END AS prodcatcode,\n       CASE WHEN (salesaccnt_sales_accnt_id IS NULL) THEN <? value("notapplicable") ?>\n            WHEN (salesaccnt_sales_accnt_id = -1) THEN <? value("notapplicable") ?>\n            ELSE formatGLAccount(salesaccnt_sales_accnt_id) END AS salesaccount,\n       CASE WHEN (salesaccnt_credit_accnt_id IS NULL) THEN <? value("notapplicable") ?>\n            WHEN (salesaccnt_credit_accnt_id = -1) THEN <? value("notapplicable") ?>\n            ELSE formatGLAccount(salesaccnt_credit_accnt_id) END AS creditaccount,\n       CASE WHEN (salesaccnt_cos_accnt_id IS NULL) THEN <? value("notapplicable") ?>\n            WHEN (salesaccnt_cos_accnt_id = -1) THEN <? value("notapplicable") ?>\n            ELSE formatGLAccount(salesaccnt_cos_accnt_id) END AS cosaccount,\n       CASE WHEN (salesaccnt_returns_accnt_id IS NULL) THEN <? value("notapplicable") ?>\n            WHEN (salesaccnt_returns_accnt_id = -1) THEN <? value("notapplicable") ?>\n            ELSE formatGLAccount(salesaccnt_returns_accnt_id) END AS returnsaccount,\n       CASE WHEN (salesaccnt_cor_accnt_id IS NULL) THEN <? value("notapplicable") ?>\n            WHEN (salesaccnt_cor_accnt_id = -1) THEN <? value("notapplicable") ?>\n            ELSE formatGLAccount(salesaccnt_cor_accnt_id) END AS coraccount,\n       CASE WHEN (salesaccnt_cow_accnt_id IS NULL) THEN <? value("notapplicable") ?>\n            WHEN (salesaccnt_cow_accnt_id = -1) THEN <? value("notapplicable") ?>\n            ELSE formatGLAccount(salesaccnt_cow_accnt_id) END AS cowaccount\nFROM salesaccnt\nORDER BY warehouscode, custtypecode, prodcatcode\n;\n admin   2014-03-20      0
101059
 
427     contactmerge    selectcol        Selects a specific column\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: contactmerge\n-- Name: selectcol\n-- Notes: Selects a specific column\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctselectcol(<? value("cntct_id") ?>, <? value("col_number") ?>);\n        admin   2014-10-06      0
101060
 
286     summarizedBankrecHistory        detail   used by dspSummarizedBankrecHistory\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: summarizedBankrecHistory\n-- Name: detail\n-- Notes: used by dspSummarizedBankrecHistory\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       'curr' AS bankrec_openbal_xtnumericrole,\n       'curr' AS bankrec_endbal_xtnumericrole\nFROM bankrec\nWHERE (bankrec_bankaccnt_id=<? value("bankaccntid") ?>)\nORDER BY bankrec_created;\n    admin   2014-10-06      0
101061
 
103     taxBreakdown    detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: taxBreakdown\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("invchead_id") ?>\n  SELECT head.*, linetax.*, freighttax.*, adjtax.* \n  FROM\n  (SELECT \n      invchead_invcnumber AS number, invchead_taxzone_id AS taxzone_id, \n      invchead_curr_id AS curr_id, invchead_curr_id AS tax_curr_id, invchead_invcdate AS date, \n      SUM(ROUND(((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price) / \n      (CASE WHEN(item_id IS NULL) THEN 1 ELSE invcitem_price_invuomratio END)), 2)) AS line, \n      invchead_freight AS freight, \n      getFreightTaxTypeId() AS freightTax, getAdjustmentTaxTypeId() AS adjTax \n  FROM invchead\n      LEFT OUTER JOIN invcitem ON (invcitem_invchead_id=invchead_id)  \n      LEFT OUTER JOIN item ON (invcitem_item_id=item_id) \n  WHERE (invchead_id=<? value("invchead_id") ?>) \n  GROUP BY number, taxzone_id, curr_id, tax_curr_id, date, freight, freightTax, adjTax) head, \n  (SELECT ROUND(SUM(group_tax), 2) AS total_tax FROM\n    (SELECT ROUND(SUM(invcitemtax.taxhist_tax),2) AS group_tax \n     FROM invcitemtax \n     LEFT OUTER JOIN invcitem ON (taxhist_parent_id = invcitem_id) \n     WHERE (invcitem_invchead_id=<? value("invchead_id") ?>)\n     GROUP BY taxhist_tax_id) AS data\n  ) linetax,\n  (SELECT ROUND(SUM(group_tax), 2) AS freighttaxamt FROM\n    (SELECT ROUND(SUM(taxhist_tax),2) AS group_tax \n     FROM invchead \n     LEFT OUTER JOIN invcheadtax ON (taxhist_parent_id = invchead_id \n     AND taxhist_taxtype_id = getfreighttaxtypeid()) \n     WHERE (invchead_id=<? value("invchead_id") ?>)\n     GROUP BY taxhist_tax_id) AS data\n  ) freighttax,  \n  (SELECT ROUND(SUM(group_tax), 2) AS adjtaxamt FROM\n    (SELECT  ROUND(SUM(taxhist_tax),2) AS group_tax \n     FROM invchead \n     LEFT OUTER JOIN invcheadtax ON (taxhist_parent_id = invchead_id \n                                 AND taxhist_taxtype_id = getadjustmenttaxtypeid()) \n     WHERE (invchead_id=<? value("invchead_id") ?>)\n     GROUP BY taxhist_tax_id) AS data\n  ) adjtax;\n<? elseif exists("cmhead_id") ?>\n  SELECT head.*, linetax.*, freighttax.*, adjtax.* \n  FROM\n  (SELECT \n      cmhead_number AS number, cmhead_taxzone_id AS taxzone_id, \n      cmhead_curr_id AS curr_id, cmhead_curr_id AS tax_curr_id, cmhead_docdate AS date, \n      SUM(ROUND(((cmitem_qtycredit * cmitem_qty_invuomratio) * (cmitem_unitprice) / \n      cmitem_price_invuomratio), 2)) AS line, \n      cmhead_freight AS freight, \n      getFreightTaxTypeId() AS freightTax, getAdjustmentTaxTypeId() AS adjTax \n  FROM cmhead \n      LEFT OUTER JOIN cmitem ON (cmitem_cmhead_id=cmhead_id) \n  WHERE (cmhead_id=<? value("cmhead_id") ?>) \n  GROUP BY number, taxzone_id, curr_id, tax_curr_id, date, freight, freightTax, adjTax) head, \n  (SELECT ROUND(SUM(group_tax), 2) AS total_tax FROM\n    (SELECT ROUND(SUM(cmitemtax.taxhist_tax * -1),2) AS group_tax \n     FROM cmitemtax \n     LEFT OUTER JOIN cmitem ON (taxhist_parent_id = cmitem_id) \n     WHERE (cmitem_cmhead_id=<? value("cmhead_id") ?>)\n     GROUP BY taxhist_tax_id) AS data\n  ) linetax,\n  (SELECT ROUND(SUM(group_tax), 2) AS freighttaxamt FROM\n    (SELECT ROUND(SUM(taxhist_tax * -1),2) AS group_tax \n     FROM cmhead \n     LEFT OUTER JOIN cmheadtax ON (taxhist_parent_id = cmhead_id \n                               AND taxhist_taxtype_id = getfreighttaxtypeid()) \n     WHERE (cmhead_id=<? value("cmhead_id") ?>)\n     GROUP BY taxhist_tax_id) AS data\n  ) freighttax, \n  (SELECT ROUND(SUM(group_tax), 2) AS adjtaxamt FROM\n    (SELECT  ROUND(SUM(taxhist_tax * -1),2) AS group_tax \n     FROM cmhead \n     LEFT OUTER JOIN cmheadtax ON (taxhist_parent_id = cmhead_id \n                               AND taxhist_taxtype_id = getadjustmenttaxtypeid()) \n     WHERE (cmhead_id=<? value("cmhead_id") ?>)\n     GROUP BY taxhist_tax_id) AS data\n  ) adjtax;\n<? elseif exists("cobmisc_id") ?>\n SELECT head.*, linetax.*, frighttax.*, adjtax.*   \n FROM \n   (SELECT cohead_number AS number, cobmisc_taxzone_id AS taxzone_id, \n      cobmisc_curr_id AS curr_id, cobmisc_curr_id AS tax_curr_id, \n     cobmisc_invcdate AS date, SUM(ROUND((cobill_qty * coitem_price) / \n     (CASE WHEN(item_id IS NULL) THEN 1 ELSE coitem_price_invuomratio END), 2)) AS line, \n     cobmisc_freight AS freight, \n     getFreightTaxTypeId() AS freightTax, getAdjustmentTaxTypeId() AS adjTax \t         \n    FROM cobmisc\n     JOIN cohead  ON (cobmisc_cohead_id=cohead_id) \n     LEFT OUTER JOIN cobill ON (cobill_cobmisc_id=cobmisc_id) \n     LEFT OUTER JOIN coitem ON (cobill_coitem_id=coitem_id) \n     LEFT OUTER JOIN itemsite ON (coitem_itemsite_id=itemsite_id) \n     LEFT OUTER JOIN item ON (itemsite_item_id=item_id) \n    WHERE (cobmisc_id=<? value("cobmisc_id") ?>) \n    GROUP BY number, cobmisc_taxzone_id, curr_id, tax_curr_id, \n      date, freight, freightTax,adjTax) head, \n   (SELECT ROUND(SUM(group_tax), 2) AS total_tax FROM\n     (SELECT ROUND(SUM(cobilltax.taxhist_tax),2) AS group_tax\n      FROM cobilltax\n      LEFT OUTER JOIN cobill ON (cobill_id=taxhist_parent_id) \n      WHERE (cobill_cobmisc_id=<? value("cobmisc_id") ?>)\n      GROUP BY taxhist_tax_id) AS data\n   ) linetax, \n   (SELECT ROUND(SUM(group_tax), 2) AS freighttaxamt FROM\n     (SELECT ROUND(SUM(taxhist_tax),2) AS group_tax\n      FROM cobmisctax\n      LEFT OUTER JOIN cobmisc ON (taxhist_parent_id = cobmisc_id AND taxhist_taxtype_id = getfreighttaxtypeid()) \n      WHERE (cobmisc_id=<? value("cobmisc_id") ?>)\n      GROUP BY taxhist_tax_id) AS data\n   ) frighttax, \n   (SELECT ROUND(SUM(group_tax), 2) AS adjtaxamt FROM\n     (SELECT  ROUND(SUM(taxhist_tax),2) AS group_tax\n      FROM cobmisctax\n      LEFT OUTER JOIN cobmisc ON (taxhist_parent_id = cobmisc_id AND taxhist_taxtype_id = getadjustmenttaxtypeid()) \n      WHERE (cobmisc_id=<? value("cobmisc_id") ?>)\n      GROUP BY taxhist_tax_id) AS data\n   ) adjtax;\n<? elseif exists("cohead_id") ?>\n  SELECT cohead_number AS number,\n         cohead_taxzone_id AS taxzone_id,\n         cohead_curr_id AS curr_id,\n         cohead_curr_id AS tax_curr_id,\n         cohead_orderdate AS date,\n         SUM(ROUND((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio),\n                    2)) AS line,\n         ROUND(SUM(calculateTax(cohead_taxzone_id, coitem_taxtype_id, cohead_orderdate, cohead_curr_id, ROUND((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price /\n                        coitem_price_invuomratio), 2))),2) as total_tax,   \n         cohead_freight AS freight,\n         getFreightTaxTypeId() AS freightTax, \n         ROUND(calculateTax(cohead_taxzone_id, getfreighttaxtypeid(), cohead_orderdate, cohead_curr_id, cohead_freight), 2) AS freighttaxamt\n  FROM coitem, item, itemsite, cohead \n  LEFT OUTER JOIN taxzone ON (cohead_taxzone_id=taxzone_id) \n  LEFT OUTER JOIN taxtype ON (taxtype_id=getFreightTaxTypeId())\n  WHERE ((coitem_cohead_id=<? value("cohead_id") ?>)\n    AND  (coitem_cohead_id=cohead_id)\n    AND  (coitem_status != 'X')\n    AND  (coitem_itemsite_id=itemsite_id)\n    AND  (itemsite_item_id=item_id))\n  GROUP BY number, cohead_taxzone_id, curr_id, tax_curr_id,\n         date, freight, freightTax,freighttaxamt;\n<? elseif exists("quhead_id") ?>\n  SELECT quhead_number AS number,\n         quhead_taxzone_id AS taxzone_id,\n         quhead_curr_id AS curr_id,\n         quhead_curr_id AS tax_curr_id,\n         quhead_quotedate AS date,\n         SUM(ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio),\n                    2)) AS line,\n         ROUND(SUM(calculateTax(quhead_taxzone_id, quitem_taxtype_id, quhead_quotedate, quhead_curr_id, ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price /\n                        quitem_price_invuomratio), 2))),2) as total_tax,  \n         quhead_freight AS freight,\n         taxtype_id AS freightTax,\n         ROUND(calculateTax(quhead_taxzone_id, getfreighttaxtypeid(), quhead_quotedate, quhead_curr_id, quhead_freight), 2) AS freighttaxamt\n  FROM quitem, item, quhead \n    LEFT OUTER JOIN taxzone ON (quhead_taxzone_id=taxzone_id) \n    LEFT OUTER JOIN taxtype ON (taxtype_id=getFreightTaxTypeId())\n  WHERE ((quitem_quhead_id=<? value("quhead_id") ?>)\n    AND  (quitem_quhead_id=quhead_id)\n    AND  (quitem_item_id=item_id))\n  GROUP BY number, quhead_taxzone_id, curr_id, tax_curr_id,\n         date, freight, freightTax,freighttaxamt;\n<? elseif exists("rahead_id") ?>\n  SELECT rahead_number AS number,\n         rahead_taxzone_id AS taxzone_id,\n         rahead_curr_id AS curr_id,\n         rahead_curr_id AS tax_curr_id,\n         rahead_authdate AS date,\n         COALESCE(SUM(ROUND((raitem_qtyauthorized * raitem_qty_invuomratio) * (raitem_unitprice / raitem_price_invuomratio),\n                    2)),0) AS line,\n         COALESCE(ROUND(SUM(calculateTax(rahead_taxzone_id, raitem_taxtype_id, rahead_authdate, rahead_curr_id, ROUND((raitem_qtyauthorized * raitem_qty_invuomratio) * (raitem_unitprice /\n                        raitem_price_invuomratio), 2))),2),0) as total_tax,   \n         rahead_freight AS freight,\n         taxtype_id AS freightTax,\n         ROUND(calculateTax(rahead_taxzone_id, getfreighttaxtypeid(), rahead_authdate, rahead_curr_id, rahead_freight), 2) AS freighttaxamt\n  FROM rahead \n    LEFT OUTER JOIN raitem ON (raitem_rahead_id=rahead_id)\n    LEFT OUTER JOIN taxzone ON (rahead_taxzone_id=taxzone_id) \n    LEFT OUTER JOIN taxtype ON (taxtype_id=getFreightTaxTypeId())\n  WHERE (raitem_rahead_id=<? value("rahead_id") ?>)\n  GROUP BY number, rahead_taxzone_id, curr_id, tax_curr_id,\n         date, freight, freightTax;\n<? elseif exists("tohead_id") ?>\n  SELECT tohead_number AS number,\n         tohead_taxzone_id AS taxzone_id,\n         tohead_freight_curr_id AS curr_id,\n         tohead_freight_curr_id AS tax_curr_id,\n         tohead_orderdate AS date,\n-------- SUM(ROUND(toitem_freight, 2)) AS line,\n-------- COALESCE(ROUND(SUM(calculateTax(tohead_taxzone_id, getfreighttaxtypeid(), tohead_orderdate, baseCurrId(), toitem_freight)),2),0) as total_tax,\n         0.0 AS line, 0.0 AS total_tax,  \n         tohead_freight +  SUM(ROUND(toitem_freight, 2)) AS freight,\n         getFreightTaxTypeId() AS freightTax,\n         COALESCE(ROUND(SUM(calculateTax(tohead_taxzone_id, getfreighttaxtypeid(), tohead_orderdate, baseCurrId(), toitem_freight)),2),0) +\n         COALESCE(ROUND(calculateTax(tohead_taxzone_id, getfreighttaxtypeid(), tohead_orderdate, baseCurrId(), tohead_freight),2),0) AS freighttaxamt \n  FROM toitem, tohead \n  WHERE ((toitem_tohead_id=<? value("tohead_id") ?>)\n    AND  (toitem_tohead_id=tohead_id)\n    AND  (toitem_status!='X')) \n  GROUP BY number, taxzone_id, curr_id, tax_curr_id,\n         date,\t\ttohead_freight,\tfreightTax\n<? elseif exists("pohead_id") ?>\n  SELECT pohead_number AS number,\n         pohead_taxzone_id AS taxzone_id,\n         pohead_curr_id AS curr_id,\n         pohead_curr_id AS tax_curr_id,\n         pohead_orderdate AS date,\n         COALESCE(SUM(ROUND(poitem_unitprice * poitem_qty_ordered, 2)),0) AS line,\n         (SELECT SUM(tax) AS tax \n          FROM (\n            SELECT ROUND(SUM(taxdetail_tax),2) AS tax \n            FROM tax \n              JOIN calculateTaxDetailSummary('PO', <? value("pohead_id") ?>, 'T') ON (taxdetail_tax_id=tax_id)\n            GROUP BY tax_id) data\n         ) as total_tax,\n         (COALESCE(SUM(poitem_freight),0)+COALESCE(pohead_freight,0)) AS freight,\n         taxtype_id AS freightTax,\n         0 AS freighttaxamt\n  FROM pohead \n    LEFT OUTER JOIN poitem ON (poitem_pohead_id=pohead_id)\n    LEFT OUTER JOIN taxzone ON (pohead_taxzone_id=taxzone_id) \n    LEFT OUTER JOIN taxtype ON (taxtype_id=getFreightTaxTypeId())\n  WHERE (poitem_pohead_id=<? value("pohead_id") ?>)\n  GROUP BY number, pohead_taxzone_id, curr_id, tax_curr_id,\n         date, pohead_freight, freightTax;\n<? elseif exists("vohead_id") ?>\n  SELECT head.*, linetax.*, adjtax.* \n  FROM\n  (SELECT \n      vohead_number AS number, vohead_taxzone_id AS taxzone_id, \n      vohead_curr_id AS curr_id, vohead_curr_id AS tax_curr_id, vohead_docdate AS date, \n      COALESCE(SUM(ROUND(voitem_qty * poitem_unitprice, 2)), 0) AS line, \n      COALESCE(SUM(voitem_freight), 0) AS freight,  \n      getAdjustmentTaxTypeId() AS adjTax \n  FROM voitem \n      LEFT OUTER JOIN poitem ON (voitem_poitem_id=poitem_id) \n      LEFT OUTER JOIN vohead ON (voitem_vohead_id=vohead_id) \n  WHERE (voitem_vohead_id=<? value("vohead_id") ?>) \n  GROUP BY number, taxzone_id, curr_id, tax_curr_id, date, adjTax) head, \n  (SELECT SUM(voitemtax.taxhist_tax * -1) AS total_tax \n   FROM voitemtax \n    LEFT OUTER JOIN voitem ON (taxhist_parent_id = voitem_id) \n   WHERE (voitem_vohead_id=<? value("vohead_id") ?>)) linetax,\n  (SELECT  SUM(taxhist_tax * -1) AS adjtaxamt \n   FROM vohead \n    LEFT OUTER JOIN voheadtax ON (taxhist_parent_id = vohead_id \n                                AND taxhist_taxtype_id = getadjustmenttaxtypeid()) \n   WHERE vohead_id=<? value("vohead_id") ?>) adjtax;\n<? endif ?>;\n    admin   2014-10-06      0
101062
 
102     todolist        detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: todolist\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT * FROM (\n/*        ---------TO DO-------------- */\n  SELECT todoitem_id AS id, \n         1 AS altId, \n         <? value("todo") ?> AS type, \n         CAST(incdt_number AS text) AS number,\n         todoitem_name AS name,\n         CASE WHEN (todoitem_active AND todoitem_status != 'C') THEN TRUE\n              ELSE FALSE\n         END AS active,\n         CASE WHEN (todoitem_status='C') THEN <? value("complete") ?>\n              WHEN (todoitem_status='D') THEN <? value("deferred") ?>\n              WHEN (todoitem_status='P') THEN <? value("pending") ?>\n              WHEN (todoitem_status='I') THEN <? value("inprocess") ?>\n              WHEN (todoitem_status='N') THEN <? value("new") ?>\n              ELSE '?'\n         END AS stage,\n         incdtpriority_name AS priority, \n         incdtpriority_order AS seq,\n         todoitem_owner_username AS owner, \n         todoitem_username AS assigned, \n         firstLine(todoitem_description) AS notes, \n         todoitem_start_date as start, \n         todoitem_due_date AS due, \n         formatDate(todoitem_due_date) AS f_due, \n         todoitem_start_date is not null AS hasStartDate,\n         todoitem_due_date is not null AS hasDueDate,\n         crmacct_id,\n         crmacct_number, \n         crmacct_name, \n         CASE WHEN (todoitem_ophead_id IS NOT NULL) THEN\n           'OPP'\n              WHEN (todoitem_incdt_id IS NOT NULL) THEN\n           'INCDT'\n         END AS parent,\n         CASE WHEN (todoitem_ophead_id IS NOT NULL) THEN\n           <? value("opportunity") ?> || '-' || ophead_number\n              WHEN (todoitem_incdt_id IS NOT NULL) THEN\n           <? value("incident") ?> || '-' || incdt_number\n         END AS parent_qtdisplayrole,\n         CASE WHEN (todoitem_ophead_id IS NOT NULL) THEN\n           <? value("opportunity") ?> || '-' || ophead_number\n              WHEN (todoitem_incdt_id IS NOT NULL) THEN\n           <? value("incident") ?> || '-' || incdt_number\n         END AS f_parent,\n         COALESCE(todoitem_ophead_id, todoitem_incdt_id) AS parent_xtidrole,\n         COALESCE(crmacct_cust_id,-1) > 0 AS cust_qtdisplayrole,\n         crmacct_cust_id AS cust,\n         CASE WHEN (todoitem_active AND todoitem_due_date < CURRENT_DATE) THEN 'expired'\n              WHEN (todoitem_active AND todoitem_due_date > CURRENT_DATE) THEN 'future'\n         END AS due_qtforegroundrole \n<? if exists("hasContext") ?>\n    FROM todoitem\n<? else ?>\n    FROM todoitem() \n<? endif ?>\n      LEFT OUTER JOIN incdt ON (incdt_id=todoitem_incdt_id) \n      LEFT OUTER JOIN ophead ON (ophead_id=todoitem_ophead_id)\n      LEFT OUTER JOIN crmacct ON (crmacct_id=todoitem_crmacct_id) \n      LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=todoitem_priority_id) \n<? if not exists("todoList")?>\n    WHERE false\n<? else ?>\n    WHERE true\n<? endif ?>\n<? if exists("startStartDate") ?>\n  AND (todoitem_start_date <= <? value("startStartDate") ?>)\n<? endif ?>\n<? if exists("startEndDate") ?>\n  AND (todoitem_start_date >= <? value("startEndDate") ?>)\n<? endif ?>\n<? if exists("dueStartDate") ?>\n  AND (todoitem_due_date <= <? value("dueStartDate") ?>)\n<? endif ?>\n<? if exists("dueEndDate") ?>\n  AND (todoitem_due_date >= <? value("dueEndDate") ?>)\n<? endif ?>\n<? if exists("crmacct_id") ?>\n  AND (crmacct_id =<? value("crmacct_id") ?>)\n<? endif ?>\n<? if exists("completedonly") ?>\n  AND (todoitem_status = 'C')\t\t\t\n<? elseif not exists("completed") ?>\n  AND (todoitem_status != 'C')\t\t\t\n<? endif ?>\n<? if exists("username") ?>\n  AND (<? value("username") ?> IN (todoitem_username, todoitem_owner_username))\n<? endif ?>\n<? if exists("assigned_username") ?> \n  AND (todoitem_username=<? value("assigned_username") ?>) \n<? elseif exists("assigned_usr_pattern") ?>\n  AND (todoitem_username ~ <? value("assigned_usr_pattern") ?>) \n<? endif ?>\n<? if exists("owner_username") ?> \n  AND (todoitem_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (todoitem_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\nUNION ALL\n/*        ---------INCIDENT-------------- */\n  SELECT incdt_id AS id, \n         2 AS altId, \n         <? value("incident") ?> AS type, \n         CAST(incdt_number AS text) AS number,\n         incdt_summary AS name, \n         incdt_status != 'L' AS active,\n         CASE WHEN (incdt_status='N') THEN <? value("new") ?>\n              WHEN (incdt_status='F') THEN <? value("feedback") ?>\n              WHEN (incdt_status='C') THEN <? value("confirmed") ?>\n              WHEN (incdt_status='A') THEN <? value("assigned") ?>\n              WHEN (incdt_status='R') THEN <? value("resolved") ?>\n              WHEN (incdt_status='L') THEN <? value("closed") ?>\n              ELSE '?'\n         END AS stage,\n         incdtpriority_name AS priority,\n         incdtpriority_order AS seq,\n         incdt_owner_username AS owner, \n         incdt_assigned_username AS assigned,\n         firstLine(incdt_descrip) AS notes, \n         CAST(incdt_timestamp AS date) AS start, \n         null AS due, \n         null AS f_due, \n         false AS hasStartDate,\n         false AS hasDueDate,\n         crmacct_id,\n         crmacct_number, \n         crmacct_name,\n         '' AS parent,\n         '' AS parent_qtdisplay_role,\n         '' AS f_parent,\n         NULL AS parent_xtidrole,\n         COALESCE(crmacct_cust_id,-1) > 0 AS cust_qtdisplayrole,\n         COALESCE(crmacct_cust_id,-1) AS cust,\n         NULL AS due_qtforegroundrole \n<? if exists("hasContext") ?>\n         FROM incdt\n<? else ?>\n         FROM incdt()\n<? endif ?>\n           LEFT OUTER JOIN crmacct ON (crmacct_id=incdt_crmacct_id) \n           LEFT OUTER JOIN custinfo ON (cust_id=crmacct_cust_id)\n           LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=incdt_incdtpriority_id) \n<? if not exists("incidents")?>\n    WHERE false\n<? else ?>\n    WHERE true\n<? endif ?>\n<? if exists("startStartDate") ?>\n  AND (incdt_timestamp::date <= <? value("startStartDate") ?>)\n<? endif ?>\n<? if exists("startEndDate") ?>\n  AND (incdt_timestamp::date >= <? value("startEndDate") ?>)\n<? endif ?>\n<? if exists("dueStartDate") ?>\n  AND false\n<? endif ?>\n<? if exists("dueEndDate") ?>\n  AND false\n<? endif ?>\n<? if exists("crmacct_id") ?>\n  AND (crmacct_id =<? value("crmacct_id") ?>)\n<? endif ?>\n<? if exists("completedonly") ?>\n  AND (incdt_status = 'L')\t\t\t\n<? elseif not exists("completed") ?>\n  AND (incdt_status != 'L')\t\t\t\n<? endif ?>\n<? if exists("username") ?>\n  AND (<? value("username") ?> IN (incdt_assigned_username, incdt_owner_username))\n<? endif ?>\n<? if exists("assigned_username") ?> \n  AND (incdt_assigned_username=<? value("assigned_username") ?>) \n<? elseif exists("assigned_usr_pattern") ?>\n  AND (incdt_assigned_username ~ <? value("assigned_usr_pattern") ?>) \n<? endif ?>\n<? if exists("owner_username") ?> \n  AND (incdt_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (incdt_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\nUNION ALL\n/*        ---------PROJECT TASK-------------- */\n    SELECT prjtask_id AS id, \n           3 AS altId, \n           <? value("task") ?> AS type,\n           prjtask_number AS number,\n           prjtask_name AS name, \n           prjtask_status != 'C' AS active,\n           CASE WHEN (prjtask_status='P') THEN <? value("concept") ?>\n                WHEN (prjtask_status='O') THEN <? value("inprocess") ?>\n                WHEN (prjtask_status='C') THEN <? value("complete") ?>\n                ELSE '?'\n           END AS stage,\n           NULL AS priority, \n           NULL AS seq, \n           prjtask_owner_username AS owner, \n           prjtask_username AS assigned, \n           firstLine(prjtask_descrip) AS notes, \n           prjtask_start_date AS start, \n           prjtask_due_date AS due, \n           formatDate(prjtask_due_date) AS f_due, \n           prjtask_start_date is not null AS hasStartDate,\n           prjtask_due_date is not null AS hasDueDate,\n           NULL AS crmacct_id,\n           '' AS crmacct_number, \n           '' AS crmacct_name,\n           'PRJ' AS parent,\n           <? value("project") ?> || '-' || prj_number AS parent_qtdisplay_role,\n           <? value("project") ?> || '-' || prj_number AS f_parent,\n           prjtask_prj_id AS parent_xtidrole,\n           false AS cust_qtdisplayrole, \n           null AS cust,\n           CASE WHEN (prjtask_status != 'C' AND prjtask_due_date < CURRENT_DATE) THEN 'expired'\n                WHEN (prjtask_status != 'C' AND prjtask_due_date > CURRENT_DATE) THEN 'future'\n           END AS due_qtforegroundrole \n<? if exists("hasContext") ?>\n     FROM prjtask\n<? else ?>\n     FROM prjtask()\n<? endif ?>\n       JOIN prj ON (prj_id=prjtask_prj_id)\n<? if not exists("projects")?>\n    WHERE false\n<? else ?>\n    WHERE true\n<? endif ?>\n<? if exists("startStartDate") ?>\n  AND (prjtask_start_date <= <? value("startStartDate") ?>)\n<? endif ?>\n<? if exists("startEndDate") ?>\n  AND (prjtask_start_date >= <? value("startEndDate") ?>)\n<? endif ?>\n<? if exists("dueStartDate") ?>\n  AND (prjtask_due_date <= <? value("dueStartDate") ?>)\n<? endif ?>\n<? if exists("dueEndDate") ?>\n  AND (prjtask_due_date >= <? value("dueEndDate") ?>)\n<? endif ?>\n<? if exists("completedonly") ?>\n  AND (prjtask_status = 'C')\t\t\t\n<? elseif not exists("completed") ?>\n  AND (prjtask_status != 'C')\t\t\t\n<? endif ?>\n<? if exists("username") ?>\n  AND (<? value("username") ?> IN (prjtask_username, prjtask_owner_username))\n<? endif ?>\n<? if exists("assigned_username") ?> \n  AND (prjtask_username=<? value("assigned_username") ?>) \n<? elseif exists("assigned_usr_pattern") ?>\n  AND (prjtask_username ~ <? value("assigned_usr_pattern") ?>) \n<? endif ?>\n<? if exists("owner_username") ?> \n  AND (prjtask_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (prjtask_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\nUNION ALL\n/*        ---------PROJECT-------------- */\n    SELECT prj_id AS id, \n           4 AS altId, \n           <? value("project") ?> AS type,\n           prj_number AS number,\n           prj_name AS name, \n           prj_status != 'C' AS active,\n           CASE WHEN (prj_status='P') THEN <? value("concept") ?>\n                WHEN (prj_status='O') THEN <? value("inprocess") ?>\n                WHEN (prj_status='C') THEN <? value("complete") ?>\n                ELSE '?'\n           END AS stage,\n           NULL AS priority, \n           NULL AS seq,\n           prj_owner_username AS owner, \n           prj_username AS assigned,\n           firstLine(prj_descrip) AS notes, \n           prj_start_date AS start, \n           prj_due_date AS due, \n           formatDate(prj_due_date) AS f_due, \n           prj_start_date IS NOT NULL AS hasStartDate,\n           prj_due_date IS NOT NULL AS hasDueDate,\n           null AS crmacct_id,\n           '' AS crmacct_number, \n           '' AS crmacct_name,\n           '' AS parent,\n           '' AS parent_qtdisplayrole,\n           '' AS f_parent,\n           NULL AS parent_xtidrole,\n           false AS cust_qtdisplayrole, \n           null AS cust,\n           CASE WHEN (prj_status != 'C'AND prj_due_date < CURRENT_DATE) THEN 'expired'\n                WHEN (prj_status != 'C'AND prj_due_date > CURRENT_DATE) THEN 'future'\n           END AS due_qtforegroundrole \n<? if exists("hasContext") ?>\n       FROM prj\n<? else ?>\n       FROM prj()\n<? endif ?>\n<? if not exists("projects")?>\n    WHERE false\n<? else ?>\n    WHERE true\n<? endif ?>\n<? if exists("startStartDate") ?>\n  AND (prj_start_date <= <? value("startStartDate") ?>)\n<? endif ?>\n<? if exists("startEndDate") ?>\n  AND (prj_start_date >= <? value("startEndDate") ?>)\n<? endif ?>\n<? if exists("dueStartDate") ?>\n  AND (prj_due_date <= <? value("dueStartDate") ?>)\n<? endif ?>\n<? if exists("dueEndDate") ?>\n  AND (prj_due_date >= <? value("dueEndDate") ?>)\n<? endif ?>\n<? if exists("completedonly") ?>\n  AND (prj_status = 'C')\t\t\t\n<? elseif not exists("completed") ?>\n  AND (prj_status != 'C')\t\t\t\n<? endif ?>\n<? if exists("username") ?>\n  AND (<? value("username") ?> IN (prj_username, prj_owner_username))\n<? endif ?>\n<? if exists("assigned_username") ?> \n  AND (prj_username=<? value("assigned_username") ?>) \n<? elseif exists("assigned_usr_pattern") ?>\n  AND (prj_username ~ <? value("assigned_usr_pattern") ?>) \n<? endif ?>\n<? if exists("owner_username") ?> \n  AND (prj_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (prj_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\nUNION ALL\n/*        ---------OPPORTUNITY-------------- */\n  SELECT ophead_id AS id, \n         5 AS altId, \n         <? value("opportunity") ?> AS type, \n         ophead_number AS number,\n         ophead_name AS name, \n         ophead_active AS active,\n         opstage_descrip AS stage,         \n         incdtpriority_name AS priority, \n         incdtpriority_order AS seq,\n         ophead_owner_username AS owner, \n         ophead_username AS assigned, \n         firstLine(ophead_notes) AS notes, \n         ophead_start_date AS start, \n         ophead_target_date AS due, \n         formatDate(ophead_target_date) AS f_due,\n         ophead_start_date is not null AS hasStartDate,\n         ophead_target_date is not null AS hasDueDate,\n         crmacct_id,\n         crmacct_number, \n         crmacct_name, \n         '' AS parent,\n         '' AS parent_qtdisplayrole,\n         '' AS f_parent,\n         NULL AS parent_xtidrole,\n         COALESCE(crmacct_cust_id,-1) > 0 AS cust_qtdisplayrole,\n         crmacct_cust_id AS cust,\n         CASE WHEN (ophead_active AND ophead_target_date < CURRENT_DATE) THEN 'expired'\n              WHEN (ophead_active AND ophead_target_date > CURRENT_DATE) THEN 'future'\n         END AS due_qtforegroundrole \n<? if exists("hasContext") ?>\n    FROM ophead\n<? else ?>\n    FROM ophead()\n<? endif ?>\n      JOIN opstage ON (ophead_opstage_id=opstage_id)\n      LEFT OUTER JOIN crmacct ON (crmacct_id=ophead_crmacct_id) \n      LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=ophead_priority_id) \n<? if not exists("opportunities")?>\n    WHERE false\n<? else ?>\n    WHERE true\n<? endif ?>\n<? if exists("startStartDate") ?>\n  AND (ophead_start_date <= <? value("startStartDate") ?>)\n<? endif ?>\n<? if exists("startEndDate") ?>\n  AND (ophead_start_date >= <? value("startEndDate") ?>)\n<? endif ?>\n<? if exists("dueStartDate") ?>\n  AND (ophead_target_date <= <? value("dueStartDate") ?>)\n<? endif ?>\n<? if exists("dueEndDate") ?>\n  AND (ophead_target_date >= <? value("dueEndDate") ?>)\n<? endif ?>\n<? if exists("crmacct_id") ?>\n  AND (crmacct_id =<? value("crmacct_id") ?>)\n<? endif ?>\n<? if exists("completedonly") ?>\n  AND (NOT ophead_active)\t\t\t\n<? elseif not exists("completed") ?>\n  AND (ophead_active)\t\t\t\n<? endif ?>\n<? if exists("username") ?>\n  AND (<? value("username") ?> IN (ophead_username, ophead_owner_username))\n<? endif ?>\n<? if exists("assigned_username") ?> \n  AND (ophead_username=<? value("assigned_username") ?>) \n<? elseif exists("assigned_usr_pattern") ?>\n  AND (ophead_username ~ <? value("assigned_usr_pattern") ?>) \n<? endif ?>\n<? if exists("owner_username") ?> \n  AND (ophead_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (ophead_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\n) AS data\nORDER BY hasDueDate desc, due, hasStartDate desc, start\n       admin   2014-10-06      0
101063
 
434     accountNumbers  detail   used by accountNumbers\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: accountNumbers\n-- Name: detail\n-- Notes: used by accountNumbers\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT accnt_id, *,\n       CASE WHEN(accnt_type='A') THEN <? value("asset") ?>\n            WHEN(accnt_type='E') THEN <? value("expense") ?>\n            WHEN(accnt_type='L') THEN <? value("liability") ?>\n            WHEN(accnt_type='Q') THEN <? value("equity") ?>\n            WHEN(accnt_type='R') THEN <? value("revenue") ?>\n            ELSE accnt_type\n       END AS accnt_type_qtdisplayrole,\n       accnt_active \n  FROM (ONLY accnt LEFT OUTER JOIN\n             company ON (accnt_company=company_number)) \n       LEFT OUTER JOIN subaccnttype ON (accnt_type=subaccnttype_accnt_type AND accnt_subaccnttype_code=subaccnttype_code)\n WHERE true\n<? if not exists("showExternal") ?>\n  AND (NOT COALESCE(company_external, false)) \n<? endif ?>\n<? if not exists("showInactive") ?>\n  AND COALESCE(accnt_active, false)\n<? endif ?>\nORDER BY accnt_number, accnt_sub, accnt_profit;\n\n        admin   2014-10-06      0
101064
 
230     addresses       detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: addresses\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (addr_country, addr_state, addr_city, addr_line1, addr_number) \n  addr_id, addr_line1, addr_line2, addr_line3, \n  addr_city, addr_state, addr_country, addr_postalcode \n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\nFROM addr \n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='ADDR') \n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=addr_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='ADDR') \n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=addr_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='ADDR') \n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=addr_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE true\n<? if not exists("showInactive") ?> \n AND addr_active \n<? endif ?>\n<? literal("charClause") ?>\nORDER BY addr_country, addr_state, addr_city, addr_line1, addr_number;\n        admin   2014-10-06      0
101065
 
35      allocations     detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: allocations\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT source_id, type, order_number, item_number, totalqty, relievedqty, balanceqty, duedate,\n       balanceqty AS runningbal,\n       'qty' AS totalqty_xtnumericrole,\n       'qty' AS relievedqty_xtnumericrole,\n       'qty' AS balanceqty_xtnumericrole,\n       0 AS runningbal_xtrunningrole,\n       'qty' AS runningbal_xtnumericrole,\n       CASE WHEN (duedate < CURRENT_DATE) THEN 'error'\n       END AS duedate_qtforegroundrole\nFROM\n(\nSELECT womatl_id AS source_id, TEXT('W/O') AS type,\n       formatWoNumber(wo_id) AS order_number,\n       paritem.item_number,\n       itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq)  AS totalqty,\n       itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyiss) AS relievedqty,\n       itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, noNeg(womatl_qtyreq - womatl_qtyiss)) AS balanceqty,\n       womatl_duedate AS duedate\n\nFROM womatl, wo, itemsite AS parent, itemsite AS component, item AS paritem, item AS compitem\nWHERE ((womatl_wo_id=wo_id)\n  AND (wo_status<>'C')\n  AND (wo_itemsite_id=parent.itemsite_id)\n  AND (womatl_itemsite_id=component.itemsite_id)\n  AND (parent.itemsite_item_id=paritem.item_id)\n  AND (component.itemsite_item_id=compitem.item_id)\n  AND (compitem.item_type != 'T')\n  AND (component.itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND (component.itemsite_item_id=<? value("item_id") ?>)\n<? if exists("leadTime") ?>\n  AND (womatl_duedate <= (CURRENT_DATE + component.itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND (womatl_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND (womatl_duedate <= <? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND (womatl_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n)\n\nUNION \n\n-- Special handling for tools\nSELECT womatl_id AS source_id, TEXT('W/O') AS type,\n       formatWoNumber(wo_id) AS order_number,\n       paritem.item_number,\n       itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq)  AS totalqty,\n       COALESCE(sum(invhist_invqty),0) AS relievedqty,\n       noNeg(itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) - COALESCE(sum(invhist_invqty),0)) AS balanceqty,\n       womatl_duedate AS duedate\n\nFROM itemsite AS parent, itemsite AS component, item paritem, item AS compitem, wo, womatl\n  LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n  LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id)\n                          AND (invhist_invqty > 0))\nWHERE ((womatl_wo_id=wo_id)\n  AND (wo_status<>'C')\n  AND (wo_itemsite_id=parent.itemsite_id)\n  AND (womatl_itemsite_id=component.itemsite_id)\n  AND (parent.itemsite_item_id=paritem.item_id)\n  AND (component.itemsite_item_id=compitem.item_id)\n  AND (compitem.item_type='T')\n  AND (component.itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND (component.itemsite_item_id=<? value("item_id") ?>)\n<? if exists("leadTime") ?>\n  AND (womatl_duedate <= (CURRENT_DATE + component.itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND (womatl_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND (womatl_duedate <= <? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND (womatl_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n)\nGROUP BY womatl_id, wo_id, paritem.item_number, womatl_uom_id, womatl_qtyreq, womatl_duedate, component.itemsite_item_id\n\nUNION \nSELECT coitem_id AS source_id, TEXT('S/O') AS type,\n       formatSoNumber(coitem_id) AS order_number,\n       item_number,\n       itemuomtouom(itemsite_item_id, coitem_qty_uom_id, NULL, coitem_qtyord) AS totalqty,\n       itemuomtouom(itemsite_item_id, coitem_qty_uom_id, NULL, (coitem_qtyshipped + qtyAtShipping(coitem_id)) - coitem_qtyreturned) as relievedqty,\n       itemuomtouom(itemsite_item_id, coitem_qty_uom_id, NULL, noNeg(coitem_qtyord - (coitem_qtyshipped + qtyAtShipping(coitem_id)) + coitem_qtyreturned)) AS balanceqty,\n       coitem_scheddate as duedate\nFROM cohead, coitem, itemsite, item \nWHERE ( (coitem_cohead_id=cohead_id)\n  AND  (coitem_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (item_sold)\n  AND  (coitem_status NOT IN ('C','X'))\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n<? if exists("leadTime") ?>\n  AND  (coitem_scheddate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND  (coitem_scheddate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND  (coitem_scheddate <= <? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND  (coitem_scheddate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n)\n\n<? if exists("MultiWhs") ?>\nUNION \nSELECT toitem_id AS source_id, TEXT('T/O') AS type,\n       TEXT(tohead_number) AS order_number,\n       item_number,\n       toitem_qty_ordered AS totalqty,\n       (toitem_qty_shipped + qtyAtShipping(toitem_id)) as relievedqty,\n       noNeg(toitem_qty_ordered - (toitem_qty_shipped + qtyAtShipping(toitem_id))) AS balanceqty,\n       toitem_schedshipdate as duedate\nFROM tohead, toitem, itemsite, item \nWHERE ((toitem_tohead_id=tohead_id)\n  AND  (toitem_item_id=itemsite_item_id)\n  AND  (tohead_src_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=item_id)\n  AND  (toitem_status NOT IN ('C','X'))\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n<? if exists("leadTime") ?>\n  AND  (toitem_schedshipdate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND  (toitem_schedshipdate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND  (toitem_schedshipdate <= <? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND  (toitem_schedshipdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n)\n<? endif ?>\n) AS dummy\n\nORDER BY duedate;\n   admin   2014-10-06      0
101066
 
36      apAging detail   used by dspTimePhasedOpenAPItems\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: apAging\n-- Name: detail\n-- Notes: used by dspTimePhasedOpenAPItems\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT apaging_vend_id, apaging_vend_number, apaging_vend_name,\n       SUM(apaging_total_val) AS apaging_total_val_sum,\n       SUM(apaging_cur_val) AS apaging_cur_val_sum,\n       SUM(apaging_thirty_val) AS apaging_thirty_val_sum,\n       SUM(apaging_sixty_val) AS apaging_sixty_val_sum,\n       SUM(apaging_ninety_val) AS apaging_ninety_val_sum,\n       SUM(apaging_plus_val) AS apaging_plus_val_sum,\n       'curr' AS apaging_total_val_sum_xtnumericrole,\n       'curr' AS apaging_cur_val_sum_xtnumericrole,\n       'curr' AS apaging_thirty_val_sum_xtnumericrole,\n       'curr' AS apaging_sixty_val_sum_xtnumericrole,\n       'curr' AS apaging_ninety_val_sum_xtnumericrole,\n       'curr' AS apaging_plus_val_sum_xtnumericrole,\n       0 AS apaging_total_val_sum_xttotalrole,\n       0 AS apaging_cur_val_sum_xttotalrole,\n       0 AS apaging_thirty_val_sum_xttotalrole,\n       0 AS apaging_sixty_val_sum_xttotalrole,\n       0 AS apaging_ninety_val_sum_xttotalrole,\n       0 AS apaging_plus_val_sum_xttotalrole\n\nFROM apaging(<? value("relDate") ?>, <? value("useDocDate") ?>)\n<? if exists("vend_id") ?>\nWHERE (apaging_vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\nWHERE (apaging_vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\nWHERE (apaging_vendtype_code ~ <? value("vendtype_pattern") ?>)\n<? endif ?>\nGROUP BY apaging_vend_number,apaging_vend_id,apaging_vend_name\nORDER BY apaging_vend_number;\n   admin   2014-10-06      0
101067
 
94      apApplications  detail   used by dspAPApplications\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: apApplications\n-- Name: detail\n-- Notes: used by dspAPApplications\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT apapply.*,\n       vend_number, vend_name,\n       CASE \n         WHEN apapply_source_doctype = 'K' THEN\n            apapply_checkhead_id\n         ELSE\n            apapply_source_apopen_id \n       END AS apapply_source_docnumber_xtidrole,\n       CASE WHEN (apapply_source_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (apapply_source_doctype='K') THEN <? value("check") ?>\n            ELSE apapply_source_doctype\n       END AS apapply_source_doctype_qtdisplayrole,\n       CASE WHEN (apapply_target_doctype='D') THEN apapply_target_apopen_id\n            WHEN (apapply_target_doctype='V') THEN (SELECT vohead_id\n                                                    FROM vohead\n                                                    WHERE (vohead_number=apapply_target_docnumber))\n       END AS apapply_target_docnumber_xtidrole,\n       CASE WHEN (apapply_target_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (apapply_target_doctype='D') THEN <? value("debitMemo") ?>\n            WHEN (apapply_target_doctype='V') THEN <? value("voucher") ?>\n            WHEN (apapply_target_doctype='K') THEN <? value("check") ?>\n            ELSE apapply_target_doctype\n       END AS apapply_target_doctype_qtdisplayrole,\n       formatDate(apapply_postdate) AS f_postdate,-- for openrpt\n       formatMoney(apapply_amount) AS f_amount,   -- for openrpt\n       currConcat(apapply_curr_id) AS currAbbr,\n       currtobase(apapply_curr_id,apapply_amount,apapply_postdate) AS base_applied,\n       'curr' AS apapply_amount_xtnumericrole,\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole\nFROM apapply, vendinfo\nWHERE ( (apapply_vend_id=vend_id)\n  AND   (apapply_postdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("doctypeList") ?>\n  AND   (apapply_source_doctype IN (<? literal("doctypeList") ?>))\n<? endif ?>\n<? if exists("vend_id") ?>\n  AND   (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n  AND   (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n  AND   (vend_vendtype_id IN (SELECT vendtype_id FROM vendtype\n                              WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n      )\nORDER BY apapply_postdate, apapply_source_docnumber;\n   admin   2014-10-06      0
101068
 
129     apOpenItems     detail  \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: apOpenItems\n-- Name:  detail\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT apopen_id, apopen_ponumber, apopen_docnumber,\n                    CASE WHEN (apopen_doctype='C') THEN <? value("creditMemo") ?>\n                         WHEN (apopen_doctype='D') THEN <? value("debitMemo") ?>\n                         WHEN (apopen_doctype='V') THEN <? value("voucher") ?>\n                         ELSE <? value("other") ?>\n                    END AS f_doctype,\n                    CASE WHEN (apopen_doctype='C') THEN 'emphasis' END AS f_doctype_qtforegroundrole,\n                    vend_number, vend_name,\n                    apopen_invcnumber AS invoicenumber,\n                    apopen_docdate, apopen_duedate, apopen_amount, apopen_status,\n<? if exists("isReport") ?>\n                    formatDate(apopen_docdate) AS f_docdate,\n                    formatDate(apopen_duedate) AS f_duedate,\n                    formatMoney(apopen_amount) AS f_amount,\n                    formatMoney(apopen_paid - COALESCE(SUM(apapply_target_paid),0)) AS f_paid,\n                    formatMoney((apopen_amount - apopen_paid + COALESCE(SUM(apapply_target_paid),0)) *\n                    CASE WHEN apopen_doctype IN ('D', 'V') THEN 1 ELSE -1\n                    END) AS f_balance,\n                    formatMoney((apopen_amount - apopen_paid + COALESCE(SUM(apapply_target_paid),0))\n                    / apopen_curr_rate * (CASE WHEN apopen_doctype IN ('D', 'V') THEN 1 ELSE -1\n                         END)) AS f_base_balance,\n<? endif ?>\n                    apopen_paid - COALESCE(SUM(apapply_target_paid),0) AS paid,\n                    (apopen_amount - apopen_paid + COALESCE(SUM(apapply_target_paid),0)) *\n                    CASE WHEN apopen_doctype IN ('D', 'V') THEN 1 ELSE -1\n                    END AS balance,\n                    currConcat(apopen_curr_id) AS currAbbr,\n                    (apopen_amount - apopen_paid + COALESCE(SUM(apapply_target_paid),0))\n                    / apopen_curr_rate * (CASE WHEN apopen_doctype IN ('D', 'V') THEN 1 ELSE -1\n                         END) AS base_balance,\n                    'curr' AS apopen_amount_xtnumericrole,\n                    'curr' AS paid_xtnumericrole,\n                    'curr' AS balance_xtnumericrole,\n                    'curr' AS base_balance_xtnumericrole,\n                    0 AS base_balance_xttotalrole\n             FROM apopen\n               JOIN vendinfo ON (vend_id=apopen_vend_id)\n               JOIN vendtype ON (vendtype_id=vend_vendtype_id)\n               LEFT OUTER JOIN apapply ON (((apopen_id=apapply_target_apopen_id)\n                                       OR (apopen_id=apapply_source_apopen_id))\n                                       AND (apapply_postdate > <? value("asofDate") ?>))\n              WHERE ( (COALESCE(apopen_closedate,date <? value("asofDate") ?> + integer '1')><? value("asofDate") ?>)\n                AND   (CASE WHEN (<? value("useDocDate") ?>) THEN apopen_docdate ELSE apopen_distdate END<=<? value("asofDate") ?>)\n<? if exists("vend_id") ?>\n                AND   (apopen_vend_id=<? value("vend_id") ?>)\n<? endif ?>\n<? if exists("vendtype_id") ?>\n                AND   (vendtype_id=<? value("vendtype_id") ?>)\n<? endif ?>\n<? if exists("vendtype_pattern") ?>\n                AND   (vendtype_code~<? value("vendtype_pattern") ?>)\n<? endif ?>\n                AND   (apopen_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) )\n              GROUP BY apopen_id, apopen_ponumber, apopen_docnumber,apopen_doctype, apopen_invcnumber, apopen_docdate,\n                apopen_duedate, apopen_docdate, apopen_amount, apopen_paid, apopen_curr_id, apopen_curr_rate,\n                apopen.apopen_status, vend_number, vend_name\n              ORDER BY apopen_docdate;       admin   2014-10-06      0
101069
 
308     apOpenItems     selectedpayments         \n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: apOpenItems\n-- Name:  selectedpayments\n-- Notes: \n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       CASE WHEN (apopen_doctype='V') THEN <? value("voucher") ?>\n            WHEN (apopen_doctype='D') THEN <? value("debitmemo") ?>\n            WHEN (apopen_doctype='C') THEN <? value("creditmemo") ?>\n       END AS doctype,\n       CASE WHEN (apopen_doctype='C') THEN 'emphasis' END AS doctype_qtforegroundrole,\n       'curr' AS apselect_amount_xtnumericrole,\n       'curr' AS apselect_amount_base_xtnumericrole,\n       'curr' AS apselect_running_base_xtnumericrole,\n       0 AS apselect_running_base_xtrunninginit,\n       1 AS apselect_running_base_xtrunningrole\nFROM (\n-- Vouchers and Debits\nSELECT apopen_id, apselect_id,\n       (bankaccnt_name || '-' || bankaccnt_descrip) AS f_bank,\n       (vend_number || '-' || vend_name) AS f_vendor,\n       apopen_docnumber, apopen_ponumber, apselect_amount,\n       apopen_invcnumber, apopen_doctype,\n       currToBase(apselect_curr_id, apselect_amount, CURRENT_DATE) AS apselect_amount_base,\n       currToBase(apselect_curr_id, apselect_amount, CURRENT_DATE) AS apselect_running_base,\n       currConcat(apselect_curr_id) AS currAbbr\nFROM apopen, apselect, vendinfo, bankaccnt\nWHERE ( (apopen_vend_id=vend_id)\n  AND   (apselect_apopen_id=apopen_id)\n  AND   (apselect_bankaccnt_id=bankaccnt_id)\n  AND   (apopen_doctype IN ('V', 'D'))\n<? if exists("bankaccntid") ?>\n  AND   (bankaccnt_id=<? value("bankaccntid") ?>)\n<? endif ?>\n<? if exists("vend_id") ?>\n  AND (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n  AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n  AND (vend_vendtype_id IN (SELECT vendtype_id\n                            FROM vendtype\n                            WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n )\nUNION\n-- Credits\nSELECT apopen_id, apselect_id,\n       (bankaccnt_name || '-' || bankaccnt_descrip) AS f_bank,\n       (vend_number || '-' || vend_name) AS f_vendor,\n       apopen_docnumber, apopen_ponumber, -apselect_amount,\n       apopen_invcnumber, apopen_doctype,\n       currToBase(apselect_curr_id, apselect_amount, CURRENT_DATE) * -1.0 AS apselect_amount_base,\n       currToBase(apselect_curr_id, apselect_amount, CURRENT_DATE) * -1.0 AS apselect_running_base,\n       currConcat(apselect_curr_id) AS currAbbr\nFROM apopen, apselect, vendinfo, bankaccnt\nWHERE ( (apopen_vend_id=vend_id)\n  AND   (apselect_apopen_id=apopen_id)\n  AND   (apselect_bankaccnt_id=bankaccnt_id)\n  AND   (apopen_doctype='C')\n<? if exists("bankaccntid") ?>\n  AND   (bankaccnt_id=<? value("bankaccntid") ?>)\n<? endif ?>\n<? if exists("vend_id") ?>\n  AND (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n  AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n  AND (vend_vendtype_id IN (SELECT vendtype_id\n                            FROM vendtype\n                            WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n )\nORDER BY f_bank, f_vendor, apopen_docnumber\n) AS data; admin   2014-10-06      0
101070
 
309     apOpenItems     selectpayments   \n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: apOpenItems\n-- Name:  selectpayments\n-- Notes: \n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       CASE WHEN (apopen_doctype='V') THEN <? value("voucher") ?>\n            WHEN (apopen_doctype='D') THEN <? value("debitMemo") ?>\n            WHEN (apopen_doctype='C') THEN <? value("creditMemo") ?>\n       END AS doctype,\n       CASE WHEN (apopen_doctype='C') THEN 'emphasis' END AS doctype_qtforegroundrole,\n       CASE WHEN (apopen_duedate < CURRENT_DATE) THEN 'error'\n            WHEN(apopen_duedate > CURRENT_DATE) THEN 'emphasis'\n            WHEN(CURRENT_DATE <= determineDiscountDate(apopen_terms_id, apopen_docdate)) THEN 'altemphasis'\n       END AS apopen_duedate_qtforegroundrole,\n       CASE WHEN (apopen_status = 'H') THEN 'error' END AS qtforegroundrole,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS selected_xtnumericrole,\n       'curr' AS running_selected_xtnumericrole,\n       'curr' AS running_amount_xtnumericrole,\n       'curr' AS discount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS base_selected_xtnumericrole,\n       'curr' AS base_discount_xtnumericrole,\n       0      AS base_amount_xttotalrole,\n       0      AS base_selected_xttotalrole,\n       0      AS base_discount_xttotalrole,\n       0      AS running_selected_xtrunninginit,\n       0      AS running_amount_xtrunninginit,\n       1      AS running_selected_xtrunningrole,\n       1      AS running_amount_xtrunningrole\n FROM (\n-- Vouchers and Debits\nSELECT apopen_id, COALESCE(apselect_id, -1) AS apselectid,\n       (vend_number || '-' || vend_name) AS vendor,\n       apopen_doctype, apopen_docnumber, apopen_ponumber, apopen_invcnumber,\n       apopen_duedate, apopen_terms_id, apopen_docdate, apopen_status,\n       (apopen_amount - apopen_paid - apCheckPending(apopen_id)) AS amount,\n       ((apopen_amount - apopen_paid - apCheckPending(apopen_id)) / apopen_curr_rate) AS base_amount,\n       ((apopen_amount - apopen_paid - apCheckPending(apopen_id)) / apopen_curr_rate) AS running_amount,\n       COALESCE(apselect_amount, 0.0) AS selected,\n       (COALESCE(apselect_amount, 0.0) / apopen_curr_rate) AS base_selected,\n       (COALESCE(apselect_amount, 0.0) / apopen_curr_rate) AS running_selected,\n       COALESCE(apselect_discount,0.0) AS discount,\n       (COALESCE(apselect_discount,0.0) / apopen_curr_rate)AS base_discount,\n       currConcat(apopen_curr_id) AS curr_concat\nFROM vendinfo JOIN apopen ON (apopen_vend_id=vend_id)\n              LEFT OUTER JOIN apselect ON (apselect_apopen_id=apopen_id)\nWHERE ( (apopen_open)\n AND (apopen_doctype IN ('V', 'D'))\n<? if exists("vend_id") ?>\n AND (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n AND (vend_vendtype_id IN (SELECT vendtype_id\n                           FROM vendtype\n                           WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n<? if exists("olderDate") ?>\n AND (apopen_duedate <= <? value("olderDate") ?>)\n<? elseif exists("startDate") ?>\n AND (apopen_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("curr_id") ?>\n AND (apopen_curr_id=<? value("curr_id") ?>)\n<? endif ?>\n)\nUNION\n-- Credits\nSELECT apopen_id, COALESCE(apselect_id, -1) AS apselectid,\n       (vend_number || '-' || vend_name) AS vendor,\n       apopen_doctype, apopen_docnumber, apopen_ponumber, apopen_invcnumber,\n       apopen_duedate, apopen_terms_id, apopen_docdate, apopen_status,\n       (apopen_amount - apopen_paid - apCheckPending(apopen_id))  * -1.0 AS amount,\n       ((apopen_amount - apopen_paid - apCheckPending(apopen_id)) / apopen_curr_rate) * -1.0 AS base_amount,\n       ((apopen_amount - apopen_paid - apCheckPending(apopen_id)) / apopen_curr_rate) * -1.0 AS running_amount,\n       COALESCE(apselect_amount, 0.0) * -1.0 AS selected,\n       (COALESCE(apselect_amount, 0.0) / apopen_curr_rate) * -1.0 AS base_selected,\n       (COALESCE(apselect_amount, 0.0) / apopen_curr_rate) * -1.0 AS running_selected,\n       COALESCE(apselect_discount,0.0) AS discount,\n       (COALESCE(apselect_discount,0.0) / apopen_curr_rate)AS base_discount,\n       currConcat(apopen_curr_id) AS curr_concat\nFROM vendinfo JOIN apopen ON (apopen_vend_id=vend_id)\n              LEFT OUTER JOIN apselect ON (apselect_apopen_id=apopen_id)\nWHERE ( (apopen_open)\n AND (apopen_doctype = 'C')\n<? if exists("vend_id") ?>\n AND (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n AND (vend_vendtype_id IN (SELECT vendtype_id\n                           FROM vendtype\n                           WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n<? if exists("olderDate") ?>\n AND (apopen_duedate <= <? value("olderDate") ?>)\n<? elseif exists("startDate") ?>\n AND (apopen_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("curr_id") ?>\n AND (apopen_curr_id=<? value("curr_id") ?>)\n<? endif ?>\n)\nORDER BY apopen_duedate, amount DESC) AS data\nWHERE (amount != 0);     admin   2014-10-06      0
101071
 
37      arAging detail   used by dspTimePhasedOpenARItems\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: arAging\n-- Name: detail\n-- Notes: used by dspTimePhasedOpenARItems\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT araging_cust_id, araging_cust_number, araging_cust_name,\n       SUM(araging_total_val) AS araging_total_val_sum,\n       SUM(araging_cur_val) AS araging_cur_val_sum,\n       SUM(araging_thirty_val) AS araging_thirty_val_sum,\n       SUM(araging_sixty_val) AS araging_sixty_val_sum,\n       SUM(araging_ninety_val) AS araging_ninety_val_sum,\n       SUM(araging_plus_val) AS araging_plus_val_sum,\n       'curr' AS araging_total_val_sum_xtnumericrole,\n       'curr' AS araging_cur_val_sum_xtnumericrole,\n       'curr' AS araging_thirty_val_sum_xtnumericrole,\n       'curr' AS araging_sixty_val_sum_xtnumericrole,\n       'curr' AS araging_ninety_val_sum_xtnumericrole,\n       'curr' AS araging_plus_val_sum_xtnumericrole,\n       0 AS araging_total_val_sum_xttotalrole,\n       0 AS araging_cur_val_sum_xttotalrole,\n       0 AS araging_thirty_val_sum_xttotalrole,\n       0 AS araging_sixty_val_sum_xttotalrole,\n       0 AS araging_ninety_val_sum_xttotalrole,\n       0 AS araging_plus_val_sum_xttotalrole\n\nFROM araging(<? value("relDate") ?>, <? value("useDocDate") ?>) \n<? if exists("cust_id") ?>\nWHERE (araging_cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\nWHERE (araging_cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\nLEFT OUTER JOIN custgrpitem ON (araging_cust_id = custgrpitem_cust_id)\nWHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\nWHERE (araging_custtype_code ~ <? value("custtype_pattern") ?>)\n<? endif ?>\nGROUP BY araging_cust_number,araging_cust_id,araging_cust_name\nORDER BY araging_cust_number;\n     admin   2014-10-06      0
101072
 
38      arApplications  detail   used by dspARApplications\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: arApplications\n-- Name: detail\n-- Notes: used by dspARApplications\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT arapply.*,\n       cust_number, cust_name,\n       CASE WHEN (arapply_source_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (arapply_source_doctype='R') THEN <? value("cashdeposit") ?>\n            WHEN (arapply_fundstype='C') THEN <? value("check") ?>\n            WHEN (arapply_fundstype='T') THEN <? value("certifiedCheck") ?>\n            WHEN (arapply_fundstype='M') THEN <? value("masterCard") ?>\n            WHEN (arapply_fundstype='V') THEN <? value("visa") ?>\n            WHEN (arapply_fundstype='A') THEN <? value("americanExpress") ?>\n            WHEN (arapply_fundstype='D') THEN <? value("discoverCard") ?>\n            WHEN (arapply_fundstype='R') THEN <? value("otherCreditCard") ?>\n            WHEN (arapply_fundstype='K') THEN <? value("cash") ?>\n            WHEN (arapply_fundstype='W') THEN <? value("wireTransfer") ?>\n            WHEN (arapply_fundstype='O') THEN <? value("other") ?>\n       END AS doctype,\n       CASE WHEN (arapply_source_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (arapply_source_doctype='R') THEN <? value("cashdeposit") ?>\n            WHEN (arapply_source_doctype='K') THEN <? value("apcheck") ?>\n            ELSE <? value("other") ?>\n       END AS sourcedoctype,\n       CASE WHEN (arapply_target_doctype='D') THEN <? value("debitMemo") ?>\n            WHEN (arapply_target_doctype='I') THEN <? value("invoice") ?>\n            WHEN (arapply_target_doctype='K') THEN <? value("apcheck") ?>\n            ELSE <? value("other") ?>\n       END AS targetdoctype,\n       CASE WHEN (arapply_source_doctype IN ('C','R')) THEN TEXT(arapply_source_docnumber)\n            ELSE arapply_refnumber\n       END AS source,\n       TEXT(arapply_target_docnumber) AS target,\n       currConcat(arapply_curr_id) AS currAbbr,\n       currtobase(arapply_curr_id,arapply_applied,arapply_postdate) AS base_applied,\n       'curr' AS arapply_applied_xtnumericrole,\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole\nFROM arapply, custinfo\nWHERE ( (arapply_cust_id=cust_id)\n  AND   (arapply_postdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n  AND   (arapply_source_doctype IN (\n<? if exists("includeCreditMemos") ?>\n  <? if exists("includeCashReceipts") ?>\n            'K', 'C', 'R'\n  <? else ?>\n            'C', 'R'\n  <? endif ?>\n<? else ?>\n            'K'\n<? endif ?> ))\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype\n                              WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n      )\nORDER BY arapply_postdate, source;\n   admin   2014-10-06      0
101073
 
39      arHistory       detail   used by dspCustomerARHistory, dspCustomerInformation\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: arHistory\n-- Name: detail\n-- Notes: used by dspCustomerARHistory, dspCustomerInformation\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT aropen_id, applyid,\n       sortdate, sortnumber, type,\n       docnumber, open, documenttype,\n       docdate, duedate, amount, balance, base_balance, currAbbr,\n       formatBoolYN(open) AS f_open,\n       formatDate(docdate) AS f_docdate, formatDate(duedate) AS f_duedate,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       type AS xtindentrole\n  FROM (\n    SELECT 0 AS type, aropen_id, -1 AS applyid,\n           aropen_docdate AS sortdate, (aropen_docnumber || aropen_doctype) AS sortnumber,\n           aropen_docnumber AS docnumber,\n           aropen_open AS open,\n           CASE WHEN (aropen_doctype='I') THEN <? value("invoice") ?>\n                WHEN (aropen_doctype='C') THEN <? value("creditMemo") ?>\n                WHEN (aropen_doctype='D') THEN <? value("debitMemo") ?>\n                WHEN (aropen_doctype='R') then <? value("cashdeposit") ?>\n                ELSE <? value("other") ?>\n           END AS documenttype,\n           aropen_docdate AS docdate,\n           aropen_duedate AS duedate,\n           aropen_amount AS amount,\n           (aropen_amount - aropen_paid) AS balance,\n           CASE WHEN (aropen_doctype IN ('C', 'R')) THEN\n                        (currtobase(aropen_curr_id,(aropen_amount - aropen_paid),aropen_docdate) * -1.0)\n                ELSE currtobase(aropen_curr_id,(aropen_amount - aropen_paid),aropen_docdate)\n           END AS base_balance,\n           currConcat(aropen_curr_id) AS currAbbr\n     FROM aropen\n    WHERE ( (aropen_cust_id=<? value("cust_id") ?>) \n    <? if exists("startDate") ?>\n      AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? endif ?> )\n\n    UNION\n    SELECT 1 AS type, -1 AS aropen_id, arapply_source_aropen_id AS applyid,\n           aropen_docdate AS sortdate, (aropen_docnumber || aropen_doctype) AS sortnumber,\n           CASE WHEN (arapply_source_doctype IN ('C','R')) THEN arapply_source_docnumber\n                WHEN (arapply_source_doctype='K') THEN arapply_refnumber\n                ELSE <? value("error") ?>\n           END AS docnumber,\n           NULL AS open,\n           CASE WHEN (arapply_source_doctype='C') THEN <? value("creditMemo") ?>\n                WHEN (arapply_source_doctype='R') THEN <? value("cashdeposit") ?>\n                WHEN (arapply_fundstype='C') THEN <? value("check") ?>\n                WHEN (arapply_fundstype='T') THEN <? value("certifiedCheck") ?>\n                WHEN (arapply_fundstype='M') THEN <? value("masterCard") ?>\n                WHEN (arapply_fundstype='V') THEN <? value("visa") ?>\n                WHEN (arapply_fundstype='A') THEN <? value("americanExpres") ?>\n                WHEN (arapply_fundstype='D') THEN <? value("discoverCard") ?>\n                WHEN (arapply_fundstype='R') THEN <? value("otherCreditCard") ?>\n                WHEN (arapply_fundstype='K') THEN <? value("cash") ?>\n                WHEN (arapply_fundstype='W') THEN <? value("wireTransfer") ?>\n                WHEN (arapply_fundstype='O') THEN <? value("other") ?>\n           END AS documenttype,\n           COALESCE(cashrcpt_docdate, arapply_postdate) AS docdate,\n           arapply_distdate AS duedate,\n           arapply_applied AS amount,\n           0 AS balance,\n           0 AS base_balance,\n           currConcat(arapply_curr_id) AS currAbbr\n     FROM arapply JOIN aropen ON (arapply_target_aropen_id=aropen_id)\n                  LEFT OUTER JOIN cashrcptitem ON ( (arapply_reftype='CR') AND\n                                                    (arapply_ref_id=cashrcptitem_id) )\n                  LEFT OUTER JOIN cashrcpt ON (cashrcpt_id=cashrcptitem_cashrcpt_id)\n    WHERE ( (arapply_target_doctype IN ('I', 'D'))\n      AND   (arapply_cust_id=<? value("cust_id") ?>)\n      AND   (aropen_cust_id=<? value("cust_id") ?>)\n    <? if exists("startDate") ?>\n      AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? endif ?> )\n\n    UNION\n    SELECT 2 AS type, -1 AS aropen_id, arapply_target_aropen_id AS applyid,\n           aropen_docdate AS sortdate, (aropen_docnumber || aropen_doctype) AS sortnumber,\n           arapply_target_docnumber AS docnumber,\n           NULL AS open,\n           CASE WHEN (arapply_target_doctype='I') THEN <? value("invoice") ?>\n                WHEN (arapply_target_doctype='D') THEN <? value("debitMemo") ?>\n                ELSE <? value("other") ?>\n           END AS documenttype,\n           arapply_postdate AS docdate,\n           arapply_distdate AS duedate,\n           arapply_applied AS amount,\n           0 AS balance,\n           0 AS base_balance,\n           currConcat(arapply_curr_id) AS currAbbr\n     FROM arapply, aropen\n    WHERE ( (arapply_source_doctype IN ('K', 'C', 'R'))\n      AND  (arapply_source_aropen_id=aropen_id)\n      AND  (arapply_cust_id=<? value("cust_id") ?>)\n      AND  (aropen_cust_id=<? value("cust_id") ?>)\n    <? if exists("startDate") ?>\n      AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? endif ?> )\n\n    UNION\n    SELECT 0 AS type, -1 AS aropen_id, -1 AS applyid,\n           invchead_invcdate AS sortdate, (invchead_invcnumber || 'I') AS sortnumber,\n           invchead_invcnumber AS docnumber,\n           false AS open,\n           <? value("zeroinvoice") ?> AS documenttype,\n           invchead_invcdate AS docdate,\n           invchead_invcdate AS duedate,\n           0 AS amount,\n           0 AS balance,\n           0 AS base_balance,\n           currConcat(invchead_curr_id) AS currAbbr\n     FROM invchead\n    WHERE ( (invchead_cust_id=<? value("cust_id") ?>) \n    <? if exists("startDate") ?>\n      AND   (invchead_invcdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? endif ?>\n      AND   (invchead_posted)\n      AND   ((SELECT SUM(invcitem_price)\n              FROM invcitem\n             WHERE (invcitem_invchead_id=invchead_id))=0) )\n  ) AS data\n  ORDER BY sortdate, sortnumber, type;\n    admin   2014-10-06      0
101074
 
40      arOpenApplications      detail   used by applyARCreditMemo, cashReceipt\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: arOpenApplications\n-- Name: detail\n-- Notes: used by applyARCreditMemo, cashReceipt\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS applied_xtnumericrole,\n       'curr' AS pending_xtnumericrole,\n       currConcat(balance_curr) AS balance_curr_qtdisplayrole,\n       CASE WHEN (doctype='D') THEN <? value("debitMemo") ?>\n            WHEN (doctype='I') THEN <? value("invoice") ?>\n            WHEN (doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (doctype='R') THEN <? value("cashdeposit") ?>\n       END AS doctype_qtdisplayrole,\n       CASE WHEN (doctype='C') THEN 'emphasis'\n            WHEN (doctype='R') THEN 'altemphasis'\n       END AS doctype_qtforegroundrole,\n<? if exists("cashrcpt_id") ?>\n    CASE WHEN (pending - currtobase(cashrcpt_curr_id, applied, cashrcpt_distdate) - discount > balance) \n    AND doctype IN ('I','D')\n    AND NOT cashrcpt_posted\n<? else ?>\n    CASE WHEN (pending - applied - discount > balance)\n<? endif ?>  \n       THEN 'error' END AS qtforegroundrole\nFROM (SELECT\n      aropen_id,\n<? if exists("cashrcpt_id") ?>\n       COALESCE(s.cashrcptitem_id, -1) AS alt_id,\n       COALESCE(cashrcpt_posted,FALSE) AS cashrcpt_posted,\n       cashrcpt_curr_id,\n       cashrcpt_distdate,\n<? endif ?>\n       aropen_doctype AS doctype,\n       aropen_docnumber, aropen_ordernumber,\n       aropen_docdate, aropen_duedate,\n       (aropen_amount - aropen_paid - calcpendingarapplications(aropen_id)) *\n       (CASE WHEN aropen_doctype IN ('C','R') THEN -1 ELSE 1 END ) AS balance,\n       aropen_curr_id AS balance_curr,\n<? if exists("cashrcpt_id") ?>\n       COALESCE(s.cashrcptitem_amount, 0.0) AS applied,\n       COALESCE(s.cashrcptitem_discount, 0.0) AS discount,\n--       (SELECT COALESCE(SUM(p.cashrcptitem_amount), 0)\n--                      FROM cashrcptitem p\n--                     WHERE (p.cashrcptitem_aropen_id=aropen_id)\n--                     AND (p.cashrcptitem_cashrcpt_id=<? value("cashrcpt_id") ?>))\n--                   AS applied,\n--       (SELECT COALESCE(SUM(p.cashrcptitem_discount), 0)\n--                      FROM cashrcptitem p\n--                     WHERE (p.cashrcptitem_aropen_id=aropen_id)\n--                     AND (p.cashrcptitem_cashrcpt_id=<? value("cashrcpt_id") ?>))\n--                   AS discount,\n       currConcat(cashrcpt_curr_id) AS applied_curr,\n<? elseif exists("source_aropen_id") ?>\n       COALESCE(arcreditapply_amount, 0) AS applied,\n       0 AS discount,\n       currConcat(arcreditapply_curr_id) AS applied_curr,\n<? endif ?>\n       calcpendingarapplications(aropen_id) AS pending,\n       currConcat(aropen_curr_id) AS pending_curr\n FROM aropen LEFT OUTER JOIN\n <? if exists("cashrcpt_id") ?>\n      cashrcptitem s ON (s.cashrcptitem_aropen_id=aropen_id\n                     AND cashrcptitem_cashrcpt_id=<? value("cashrcpt_id") ?>)\n        LEFT OUTER JOIN\n      cashrcpt ON (cashrcptitem_cashrcpt_id = cashrcpt_id\n               AND cashrcpt_id=<? value("cashrcpt_id") ?>)\n<? elseif exists("source_aropen_id") ?>\n      arcreditapply ON ((arcreditapply_source_aropen_id=<? value("source_aropen_id") ?>)\n                    AND (arcreditapply_target_aropen_id=aropen_id) )\n<? endif ?>\n WHERE (\n<? if exists("posted") ?> \n   (s.cashrcptitem_aropen_id=aropen_id)\n<? else ?>\n   (aropen_open)\n<? endif ?>\n<? if exists("noCredits") ?>\n   AND (aropen_doctype IN ('D', 'I'))\n<? elseif exists("cashrcpt_id") ?>\n<? else ?>\n   AND (aropen_doctype IN ('D', 'I'))\n<? endif ?>\n   AND (aropen_cust_id=<? value("cust_id") ?>) )\n ) AS dummy\n ORDER BY aropen_duedate, balance;\n    admin   2014-10-06      0
101075
 
42      arOpenItems     detail   used by arWorkBench, dspAROpenItems\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: arOpenItems\n-- Name: detail\n-- Notes: used by arWorkBench, dspAROpenItems\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("totalOnly") ?>\nSELECT SUM(CASE WHEN (aropen_doctype IN ('C', 'R')) THEN\n                    (aropen_amount - aropen_paid) / aropen_curr_rate * -1\n                ELSE (aropen_amount - aropen_paid) / aropen_curr_rate\n           END) AS total_balance\nFROM aropen JOIN custinfo ON (aropen_cust_id=cust_id)\n            LEFT OUTER JOIN custtype ON (cust_custtype_id=custtype_id)\n            LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (aropen_open)\n<? if exists("cust_id") ?>\n  AND   (aropen_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n      )\n;\n<? else ?>\n\n-- Get unposted invoices\n<? if exists("showUnposted") ?>\n<? if not exists("creditsOnly") ?>\nSELECT -1 AS id,\n       0 AS altId,\n       invchead_invcnumber AS docnumber,\n       invchead_id AS docnumber_xtidrole,\n       invchead_posted AS posted,\n       invchead_invcdate AS docdate,\n       NULL::date AS aropen_duedate,\n       invchead_ordernumber AS ordernumber,\n       cohead_id AS ordernumber_xtidrole,\n       <? value("invoice") ?>  AS doctype,\n       NULL AS doctype_qtforegroundrole,\n       invoicetotal(invchead_id) AS amount,\n       currtobase(invchead_curr_id, invoicetotal(invchead_id), invchead_invcdate) AS base_amount,\n       0 AS paid,\n       0 AS base_paid,\n       0 AS balance,\n       currConcat(invchead_curr_id) AS currAbbr,\n       0 AS base_balance,\n<? if exists("includeFormatted") ?>\n       formatDate(invchead_invcdate) AS f_docdate,\n       NULL::text AS f_duedate,\n       formatMoney(0) AS f_amount,\n       formatMoney(0) AS f_paid,\n       formatMoney(0) AS f_balance,\n<? endif ?>\n       cust_id, cust_number, cust_name,\n       (invchead_recurring_invchead_id IS NOT NULL) AS recurring,\n       false AS open,\n       NULL AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       NULL::text AS aropen_docnumber_qtdisplayrole,\n       NULL::text AS aropen_docdate_qtdisplayrole,\n       0 AS xtindentrole,\n       '' AS aropen_duedate_qtforegroundrole,\n       NULL::integer AS ccard_number_xtidrole,\n       firstLine(invchead_notes) AS notes\nFROM invchead\n           LEFT OUTER JOIN cohead ON (invchead_ordernumber=cohead_number)\n           JOIN custinfo ON (invchead_cust_id=cust_id)\n           JOIN custtype ON (cust_custtype_id=custtype_id)\n\t   LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((NOT invchead_posted)\n<? if exists("cust_id") ?>\n  AND   (invchead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (invchead_invcdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n  GROUP BY id,                      altId,                  invchead_id,\n           invchead_invcdate,       invchead_posted,        invchead_curr_id,\n           invchead_recurring,      invchead_invcnumber,    invchead_posted,\n           invchead_ordernumber,    cohead_id,\n           cust_id,                 cust_number,            cust_name,\n           invchead_recurring_invchead_id, invchead_notes\n\nUNION\n<? endif ?>\n<? endif ?>\n\n-- Get unposted credit memos\n<? if exists("showUnposted") ?>\n<? if not exists("debitsOnly") ?>\nSELECT -1 AS id,\n       1 AS altId,\n       cmhead_number AS docnumber,\n       cmhead_id AS docnumber_xtidrole,\n       cmhead_posted AS posted,\n       cmhead_docdate AS docdate,\n       NULL::date AS aropen_duedate,\n       NULL::text AS ordernumber,\n       -1 AS ordernumber_xtidrole,\n       <? value("return") ?>  AS doctype,\n       CASE WHEN (NOT cmhead_posted) THEN 'emphasis'\n       END AS doctype_qtforegroundrole,\n       creditmemototal(cmhead_id) AS amount,\n       currtobase(cmhead_curr_id, creditmemototal(cmhead_id), cmhead_docdate) AS base_amount,\n       0 AS paid,\n       0 AS base_paid,\n       0 AS balance,\n       currConcat(cmhead_curr_id) AS currAbbr,\n       0  AS base_balance,\n<? if exists("includeFormatted") ?>\n       formatDate(cmhead_docdate) AS f_docdate,\n       NULL::text AS f_duedate,\n       formatMoney(creditmemototal(cmhead_id)) AS f_amount,\n       formatMoney(0) AS f_paid,\n       formatMoney(0) AS f_balance,\n<? endif ?>\n       cust_id, cust_number, cust_name,\n       false AS recurring,\n       false AS open,\n       NULL AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       NULL::text AS aropen_docnumber_qtdisplayrole,\n       NULL::text AS aropen_docdate_qtdisplayrole,\n       0 AS xtindentrole,\n       '' AS aropen_duedate_qtforegroundrole,\n       NULL::integer AS ccard_number_xtidrole,\n       firstLine(cmhead_comments) AS notes\nFROM cmhead\n            JOIN custinfo ON (cmhead_cust_id=cust_id)\n            JOIN custtype ON (cust_custtype_id=custtype_id)\n\t    LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((NOT cmhead_posted)\n<? if exists("cust_id") ?>\n  AND   (cmhead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (cmhead_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n  GROUP BY id,                      altId,                  cmhead_id,\n           cmhead_docdate,          cmhead_posted,          cmhead_curr_id,\n           cmhead_number,           cmhead_posted,          cmhead_comments,\n           cust_id,                 cust_number,            cust_name\n\nUNION\n<? endif ?>\n<? endif ?>\n\n-- Get Posted AR Open\nSELECT aropen_id AS id,\n       CASE WHEN (aropen_doctype='I') THEN 0\n            WHEN (aropen_doctype='C') THEN 1\n            WHEN (aropen_doctype='D') THEN 2\n            WHEN (aropen_doctype='R') THEN 3\n            ELSE -1\n       END AS altId,\n       aropen_docnumber AS docnumber,\n       COALESCE(invchead_id,cmhead_id,-1) AS docnumber_xtidrole,\n       true AS posted,\n       aropen_docdate AS docdate,\n       aropen_duedate,\n       aropen_ordernumber AS ordernumber,\n       COALESCE(cohead_id,-1) AS ordernumber_xtidrole,\n       CASE WHEN (aropen_doctype='I') THEN <? value("invoice") ?>\n            WHEN (aropen_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (aropen_doctype='D') THEN <? value("debitMemo") ?>\n            WHEN (aropen_doctype='R') THEN <? value("cashdeposit") ?>\n            ELSE <? value("other") ?>\n       END AS doctype,\n       CASE WHEN (aropen_doctype='C') THEN 'emphasis' \n         ELSE CASE WHEN(aropen_doctype='R')THEN 'altemphasis'\n         END\n       END AS doctype_qtforegroundrole,\n       aropen_amount AS amount,\n       aropen_amount/aropen_curr_rate AS base_amount,\n       (aropen_paid - (COALESCE(SUM(arapply_target_paid),0))) AS paid,\n       (aropen_paid - (COALESCE(SUM(arapply_target_paid),0))/aropen_curr_rate) AS base_paid,\n        (((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0))) *\n        CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END) AS balance,\n       currConcat(aropen_curr_id) AS currAbbr,\n        (((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0)))/aropen_curr_rate *\n        CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END)  AS base_balance,\n<? if exists("includeFormatted") ?>\n       formatDate(aropen_docdate) AS f_docdate,\n       formatDate(aropen_duedate) AS f_duedate,\n       formatMoney(aropen_amount) AS f_amount,\n       formatMoney(aropen_paid - (COALESCE(SUM(arapply_target_paid),0))) AS f_paid,\n       formatMoney((((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0))) *\n        CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END)) AS f_balance,\n<? endif ?>\n       cust_id, cust_number, cust_name,\n       COALESCE(invchead_recurring_invchead_id IS NOT NULL, false) AS recurring,\n       aropen_open AS open,\n       formatccnumber(decrypt(setbytea(ccard_number),\n                              setbytea(<? value("key") ?>), 'bf')) AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr'AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       NULL AS aropen_docnumber_qtdisplayrole,\n       NULL AS aropen_docdate_qtdisplayrole,\n       0 AS xtindentrole,\n       CASE WHEN ((COALESCE(aropen_duedate,current_date) < current_date) AND COALESCE(aropen_open,FALSE)) THEN 'error' \n       END AS aropen_duedate_qtforegroundrole,\n       ccpay_id AS ccard_number_xtidrole,\n       firstLine(aropen_notes) AS notes\nFROM aropen \n<? if exists("incidentsOnly") ?>\n            JOIN incdt ON (incdt_aropen_id=aropen_id)\n<? endif ?>\n            JOIN custinfo ON (aropen_cust_id=cust_id)\n            JOIN custtype ON (cust_custtype_id=custtype_id)\n\t    LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n            LEFT OUTER JOIN invchead ON ((aropen_docnumber=invchead_invcnumber)\n                                   AND (aropen_doctype='I'))\n            LEFT OUTER JOIN cohead ON (invchead_ordernumber=cohead_number)\n            LEFT OUTER JOIN cmhead ON ((aropen_docnumber=cmhead_number)\n                                   AND (aropen_doctype='C'))\n            LEFT OUTER JOIN arapply ON (((aropen_id=arapply_source_aropen_id)\n                             OR (aropen_id=arapply_target_aropen_id))\n                             AND (arapply_distdate>COALESCE(<? value("asofDate") ?>,current_date)))\n            LEFT OUTER JOIN payaropen ON (payaropen_aropen_id=aropen_id)\n            LEFT OUTER JOIN ccpay     ON (payaropen_ccpay_id=ccpay_id)\n            LEFT OUTER JOIN ccard     ON (ccpay_ccard_id=ccard_id)\nWHERE ((true)\n<? if not exists("showClosed") ?>\n  AND (aropen_docdate <= COALESCE(<? value("asofDate") ?>, current_date))\n  AND (COALESCE(aropen_closedate, DATE(<? value("asofDate") ?>) + 1, current_date + 1) > COALESCE(<? value("asofDate") ?>, current_date)) \n<? endif ?>\n<? if exists("debitsOnly") ?>\n  AND   (aropen_doctype IN ('D','I'))\n<? elseif exists("creditsOnly") ?>\n  AND   (aropen_doctype IN ('C', 'R'))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND   (aropen_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("startDueDate") ?>\n  AND   (aropen_duedate >= <? value("startDueDate") ?>)\n<? endif ?>\n<? if exists("endDueDate") ?>\n  AND   (aropen_duedate <= <? value("endDueDate") ?>)\n<? endif ?>\n      )\n  GROUP BY id,                      altId,\t            invchead_id,\n           aropen_docdate,          aropen_duedate,         aropen_doctype,         \n           aropen_docnumber,        aropen_amount,          \n           aropen_notes,            aropen_posted,          aropen_ordernumber,\n           aropen_paid,             aropen_open,            aropen_curr_id,\n           aropen_closedate,        aropen_curr_rate,       cmhead_id,\n           cust_id, \t\t    cust_number,            cust_name,\n           cohead_id,               ccpay_id,               ccard_number,\n           invchead_recurring_invchead_id\nUNION\nSELECT -1,\n       4 AS altId,\n       aropen_docnumber AS docnumber,\n       -1 AS docnumber_xtidrole,\n       NULL AS posted, \n       aropen_docdate AS docdate,\n       NULL AS aropen_duedate,\n       CAST(incdt_number AS text) AS ordernumber,\n       incdt_id AS ordernumber_xtidrole,\n       NULL AS doctype,\n       NULL AS doctype_qtforegroundrole,\n       NULL AS amount,\n       NULL AS base_amount,\n       NULL AS paid,\n       NULL AS base_paid,\n       NULL AS balance,\n       NULL AS currAbbr,\n       NULL AS base_balance,\n<? if exists("includeFormatted") ?>\n       NULL AS f_docdate,\n       NULL AS f_duedate,\n       NULL AS f_amount,\n       NULL AS f_paid,\n       NULL AS f_balance,\n<? endif ?>\n       NULL,incdt_assigned_username, incdt_summary,\n       NULL AS recurring, NULL AS open,\n       NULL AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       '' AS aropen_docnumber_qtdisplayrole,\n       '' AS aropen_docdate_qtdisplayrole,\n       1 AS xtindentrole,\n       CASE WHEN ((COALESCE(aropen_duedate,current_date) < current_date) AND COALESCE(aropen_open,FALSE)) THEN 'error' \n       END AS aropen_duedate_qtforegroundrole,\n       NULL::integer AS ccard_xtidrole,\n       firstLine(incdt_descrip) AS notes\nFROM incdt JOIN aropen ON (aropen_id=incdt_aropen_id)\n           JOIN custinfo ON (aropen_cust_id=cust_id)\n           JOIN custtype ON (cust_custtype_id=custtype_id)\n\t   LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((true)\n<? if not exists("showClosed") ?>\n  AND (aropen_docdate <= COALESCE(<? value("asofDate") ?>, current_date))\n  AND (COALESCE(aropen_closedate, DATE(<? value("asofDate") ?>) + 1, current_date + 1) > COALESCE(<? value("asofDate") ?>, current_date)) \n<? endif ?>\n<? if exists("debitsOnly") ?>\n  AND   (NOT aropen_doctype IN ('C', 'R'))\n<? endif ?>\n<? if exists("creditsOnly") ?>\n  AND   (aropen_doctype IN ('C', 'R'))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND   (aropen_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("startDueDate") ?>\n  AND   (aropen_duedate >= <? value("startDueDate") ?>)\n<? endif ?>\n<? if exists("endDueDate") ?>\n  AND   (aropen_duedate <= <? value("endDueDate") ?>)\n<? endif ?>\n      )\n\nORDER BY\n  docdate DESC, docnumber DESC, xtindentrole\n;\n<? endif ?>\n      admin   2014-10-06      0
101076
 
231     arOpenItems     f_detail         This version for printed reports that need a way to include formatted values\n        since there is no good way to differentiate different printed parameters in \n        display class.  Used to be printed version got an extra parameter. Formatted\n        values slow things down considerably on screen version otherwise. This\n        should go away if/when we get OpenRPT to do its own formatting.\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: arOpenItems\n-- Name:  f_detail\n-- Notes: This version for printed reports that need a way to include formatted values\n--        since there is no good way to differentiate different printed parameters in \n--        display class.  Used to be printed version got an extra parameter. Formatted\n--        values slow things down considerably on screen version otherwise. This\n--        should go away if/when we get OpenRPT to do its own formatting.\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("totalOnly") ?>\nSELECT SUM(CASE WHEN (aropen_doctype IN ('C', 'R')) THEN\n                    (aropen_amount - aropen_paid) / aropen_curr_rate * -1\n                ELSE (aropen_amount - aropen_paid) / aropen_curr_rate\n           END) AS total_balance\nFROM aropen JOIN custinfo ON (aropen_cust_id=cust_id)\n            LEFT OUTER JOIN custtype ON (cust_custtype_id=custtype_id)\n            LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (aropen_open)\n<? if exists("cust_id") ?>\n  AND   (aropen_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n      )\n;\n<? else ?>\n\n-- Get unposted invoices\n<? if exists("showUnposted") ?>\n<? if not exists("creditsOnly") ?>\nSELECT -1 AS id,\n       0 AS altId,\n       invchead_invcnumber AS docnumber,\n       invchead_id AS docnumber_xtidrole,\n       invchead_posted AS posted,\n       invchead_invcdate AS docdate,\n       NULL::date AS aropen_duedate,\n       invchead_ordernumber AS ordernumber,\n       cohead_id AS ordernumber_xtidrole,\n       <? value("invoice") ?>  AS doctype,\n       NULL AS doctype_qtforegroundrole,\n       invoicetotal(invchead_id) AS amount,\n       currtobase(invchead_curr_id, invoicetotal(invchead_id), invchead_invcdate) AS base_amount,\n       0 AS paid,\n       0 AS base_paid,\n       0 AS balance,\n       currConcat(invchead_curr_id) AS currAbbr,\n       0 AS base_balance,\n       formatDate(invchead_invcdate) AS f_docdate,\n       NULL::text AS f_duedate,\n       formatMoney(invoicetotal(invchead_id)) AS f_amount,\n       formatMoney(0) AS f_paid,\n       formatMoney(0) AS f_balance,\n       cust_id, cust_number, cust_name,\n       (invchead_recurring_invchead_id IS NOT NULL) AS recurring,\n       false AS open,\n       NULL AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       NULL::text AS aropen_docnumber_qtdisplayrole,\n       NULL::text AS aropen_docdate_qtdisplayrole,\n       0 AS xtindentrole,\n       '' AS aropen_duedate_qtforegroundrole,\n       NULL::integer AS ccard_number_xtidrole,\n       firstLine(invchead_notes) AS notes\nFROM invchead\n           LEFT OUTER JOIN cohead ON (invchead_ordernumber=cohead_number)\n           JOIN custinfo ON (invchead_cust_id=cust_id)\n           JOIN custtype ON (cust_custtype_id=custtype_id)\n\t   LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((NOT invchead_posted)\n<? if exists("cust_id") ?>\n  AND   (invchead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (invchead_invcdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n  GROUP BY id,                      altId,                  invchead_id,\n           invchead_invcdate,       invchead_posted,        invchead_curr_id,\n           invchead_recurring,      invchead_invcnumber,    invchead_posted,\n           invchead_ordernumber,    cohead_id,\n           cust_id,                 cust_number,            cust_name,\n           invchead_recurring_invchead_id, invchead_notes\n\nUNION\n<? endif ?>\n<? endif ?>\n\n-- Get unposted credit memos\n<? if exists("showUnposted") ?>\n<? if not exists("debitsOnly") ?>\nSELECT -1 AS id,\n       1 AS altId,\n       cmhead_number AS docnumber,\n       cmhead_id AS docnumber_xtidrole,\n       cmhead_posted AS posted,\n       cmhead_docdate AS docdate,\n       NULL::date AS aropen_duedate,\n       NULL::text AS ordernumber,\n       -1 AS ordernumber_xtidrole,\n       <? value("return") ?>  AS doctype,\n       CASE WHEN (NOT cmhead_posted) THEN 'emphasis'\n       END AS doctype_qtforegroundrole,\n       creditmemototal(cmhead_id) AS amount,\n       currtobase(cmhead_curr_id, creditmemototal(cmhead_id), cmhead_docdate) AS base_amount,\n       0 AS paid,\n       0 AS base_paid,\n       0 AS balance,\n       currConcat(cmhead_curr_id) AS currAbbr,\n       0  AS base_balance,\n       formatDate(cmhead_docdate) AS f_docdate,\n       NULL::text AS f_duedate,\n       formatMoney(creditmemototal(cmhead_id)) AS f_amount,\n       formatMoney(0) AS f_paid,\n       formatMoney(0) AS f_balance,\n       cust_id, cust_number, cust_name,\n       false AS recurring,\n       false AS open,\n       NULL AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       NULL::text AS aropen_docnumber_qtdisplayrole,\n       NULL::text AS aropen_docdate_qtdisplayrole,\n       0 AS xtindentrole,\n       '' AS aropen_duedate_qtforegroundrole,\n       NULL::integer AS ccard_number_xtidrole,\n       firstLine(cmhead_comments) AS notes\nFROM cmhead\n            JOIN custinfo ON (cmhead_cust_id=cust_id)\n            JOIN custtype ON (cust_custtype_id=custtype_id)\n\t    LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((NOT cmhead_posted)\n<? if exists("cust_id") ?>\n  AND   (cmhead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (cmhead_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n  GROUP BY id,                      altId,                  cmhead_id,\n           cmhead_docdate,          cmhead_posted,          cmhead_curr_id,\n           cmhead_number,           cmhead_posted,          cmhead_comments,\n           cust_id,                 cust_number,            cust_name\n\nUNION\n<? endif ?>\n<? endif ?>\n\n-- Get Posted AR Open\nSELECT aropen_id AS id,\n       CASE WHEN (aropen_doctype='I') THEN 0\n            WHEN (aropen_doctype='C') THEN 1\n            WHEN (aropen_doctype='D') THEN 2\n            WHEN (aropen_doctype='R') THEN 3\n            ELSE -1\n       END AS altId,\n       aropen_docnumber AS docnumber,\n       COALESCE(invchead_id,cmhead_id,-1) AS docnumber_xtidrole,\n       true AS posted,\n       aropen_docdate AS docdate,\n       aropen_duedate,\n       aropen_ordernumber AS ordernumber,\n       COALESCE(cohead_id,-1) AS ordernumber_xtidrole,\n       CASE WHEN (aropen_doctype='I') THEN <? value("invoice") ?>\n            WHEN (aropen_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (aropen_doctype='D') THEN <? value("debitMemo") ?>\n            WHEN (aropen_doctype='R') THEN <? value("cashdeposit") ?>\n            ELSE <? value("other") ?>\n       END AS doctype,\n       CASE WHEN (aropen_doctype='C') THEN 'emphasis' \n         ELSE CASE WHEN(aropen_doctype='R')THEN 'altemphasis'\n         END\n       END AS doctype_qtforegroundrole,\n       aropen_amount AS amount,\n       aropen_amount/aropen_curr_rate AS base_amount,\n       (aropen_paid - (COALESCE(SUM(arapply_target_paid),0))) AS paid,\n       (aropen_paid - (COALESCE(SUM(arapply_target_paid),0))/aropen_curr_rate) AS base_paid,\n        (((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0))) *\n        CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END) AS balance,\n       currConcat(aropen_curr_id) AS currAbbr,\n        (((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0)))/aropen_curr_rate *\n        CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END)  AS base_balance,\n       formatDate(aropen_docdate) AS f_docdate,\n       formatDate(aropen_duedate) AS f_duedate,\n       formatMoney(aropen_amount) AS f_amount,\n       formatMoney(aropen_paid - (COALESCE(SUM(arapply_target_paid),0))) AS f_paid,\n       formatMoney((((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0))) *\n        CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END)) AS f_balance,\n       cust_id, cust_number, cust_name,\n       COALESCE(invchead_recurring_invchead_id IS NOT NULL, false) AS recurring,\n       aropen_open AS open,\n       formatccnumber(decrypt(setbytea(ccard_number),\n                              setbytea(<? value("key") ?>), 'bf')) AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr'AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       NULL AS aropen_docnumber_qtdisplayrole,\n       NULL AS aropen_docdate_qtdisplayrole,\n       0 AS xtindentrole,\n       CASE WHEN ((COALESCE(aropen_duedate,current_date) < current_date) AND COALESCE(aropen_open,FALSE)) THEN 'error' \n       END AS aropen_duedate_qtforegroundrole,\n       ccpay_id AS ccard_number_xtidrole,\n       firstLine(aropen_notes) AS notes\nFROM aropen \n<? if exists("incidentsOnly") ?>\n            JOIN incdt ON (incdt_aropen_id=aropen_id)\n<? endif ?>\n            JOIN custinfo ON (aropen_cust_id=cust_id)\n            JOIN custtype ON (cust_custtype_id=custtype_id)\n\t    LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n            LEFT OUTER JOIN invchead ON ((aropen_docnumber=invchead_invcnumber)\n                                   AND (aropen_doctype='I'))\n            LEFT OUTER JOIN cohead ON (invchead_ordernumber=cohead_number)\n            LEFT OUTER JOIN cmhead ON ((aropen_docnumber=cmhead_number)\n                                   AND (aropen_doctype='C'))\n            LEFT OUTER JOIN arapply ON (((aropen_id=arapply_source_aropen_id)\n                             OR (aropen_id=arapply_target_aropen_id))\n                             AND (arapply_distdate>COALESCE(<? value("asofDate") ?>,current_date)))\n            LEFT OUTER JOIN payaropen ON (payaropen_aropen_id=aropen_id)\n            LEFT OUTER JOIN ccpay     ON (payaropen_ccpay_id=ccpay_id)\n            LEFT OUTER JOIN ccard     ON (ccpay_ccard_id=ccard_id)\nWHERE ((true)\n<? if not exists("showClosed") ?>\n  AND (aropen_docdate <= COALESCE(<? value("asofDate") ?>, current_date))\n  AND (COALESCE(aropen_closedate, DATE(<? value("asofDate") ?>) + 1, current_date + 1) > COALESCE(<? value("asofDate") ?>, current_date)) \n<? endif ?>\n<? if exists("debitsOnly") ?>\n  AND   (aropen_doctype IN ('D','I'))\n<? elseif exists("creditsOnly") ?>\n  AND   (aropen_doctype IN ('C', 'R'))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND   (aropen_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("startDueDate") ?>\n  AND   (aropen_duedate >= <? value("startDueDate") ?>)\n<? endif ?>\n<? if exists("endDueDate") ?>\n  AND   (aropen_duedate <= <? value("endDueDate") ?>)\n<? endif ?>\n      )\n  GROUP BY id,                      altId,\t            invchead_id,\n           aropen_docdate,          aropen_duedate,         aropen_doctype,         \n           aropen_docnumber,        aropen_amount,          \n           aropen_notes,            aropen_posted,          aropen_ordernumber,\n           aropen_paid,             aropen_open,            aropen_curr_id,\n           aropen_closedate,        aropen_curr_rate,       cmhead_id,\n           cust_id, \t\t    cust_number,            cust_name,\n           cohead_id,               ccpay_id,               ccard_number,\n           invchead_recurring_invchead_id\nUNION\nSELECT -1,\n       4 AS altId,\n       aropen_docnumber AS docnumber,\n       -1 AS docnumber_xtidrole,\n       NULL AS posted, \n       aropen_docdate AS docdate,\n       NULL AS aropen_duedate,\n       CAST(incdt_number AS text) AS ordernumber,\n       incdt_id AS ordernumber_xtidrole,\n       NULL AS doctype,\n       NULL AS doctype_qtforegroundrole,\n       NULL AS amount,\n       NULL AS base_amount,\n       NULL AS paid,\n       NULL AS base_paid,\n       NULL AS balance,\n       NULL AS currAbbr,\n       NULL AS base_balance,\n       NULL AS f_docdate,\n       NULL AS f_duedate,\n       NULL AS f_amount,\n       NULL AS f_paid,\n       NULL AS f_balance,\n       NULL,incdt_assigned_username, incdt_summary,\n       NULL AS recurring, NULL AS open,\n       NULL AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       '' AS aropen_docnumber_qtdisplayrole,\n       '' AS aropen_docdate_qtdisplayrole,\n       1 AS xtindentrole,\n       CASE WHEN ((COALESCE(aropen_duedate,current_date) < current_date) AND COALESCE(aropen_open,FALSE)) THEN 'error' \n       END AS aropen_duedate_qtforegroundrole,\n       NULL::integer AS ccard_xtidrole,\n       firstLine(incdt_descrip) AS notes\nFROM incdt JOIN aropen ON (aropen_id=incdt_aropen_id)\n           JOIN custinfo ON (aropen_cust_id=cust_id)\n           JOIN custtype ON (cust_custtype_id=custtype_id)\n\t   LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((true)\n<? if not exists("showClosed") ?>\n  AND (aropen_docdate <= COALESCE(<? value("asofDate") ?>, current_date))\n  AND (COALESCE(aropen_closedate, DATE(<? value("asofDate") ?>) + 1, current_date + 1) > COALESCE(<? value("asofDate") ?>, current_date)) \n<? endif ?>\n<? if exists("debitsOnly") ?>\n  AND   (NOT aropen_doctype IN ('C', 'R'))\n<? endif ?>\n<? if exists("creditsOnly") ?>\n  AND   (aropen_doctype IN ('C', 'R'))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND   (aropen_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("startDueDate") ?>\n  AND   (aropen_duedate >= <? value("startDueDate") ?>)\n<? endif ?>\n<? if exists("endDueDate") ?>\n  AND   (aropen_duedate <= <? value("endDueDate") ?>)\n<? endif ?>\n      )\n\nORDER BY\n  docdate DESC, docnumber DESC, xtindentrole\n;\n<? endif ?>\n     admin   2014-10-06      0
101077
 
435     backlog detail  \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: backlog\n-- Name: detail\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n       cohead_id, coitem_id, *, currconcat(cohead_curr_id) AS currAbbr,\n       CASE WHEN xtindentrole = 0 THEN cohead_number\n       END AS coitem_linenumber_qtdisplayrole,\n       CASE WHEN xtindentrole = 0 THEN cust_name\n       END AS item_number_qtdisplayrole,\n       CASE WHEN (coitem_scheddate <= current_date AND qtybalance > 0) THEN 'error' \n            WHEN (qtybalance > 0) THEN 'emphasis' \n       END AS coitem_scheddate_qtforegroundrole,\n       'qty' AS coitem_qtyord_xtnumericrole,\n       'qty' AS coitem_qtyshipped_xtnumericrole,\n       'qty' AS coitem_qtyreturned_xtnumericrole,\n       'qty' AS qtyatshipping_xtnumericrole,\n       'qty' AS qtybalance_xtnumericrole,\n       'qty' AS qtyavailable_xtnumericrole,\n       'salesprice' AS coitem_price_xtnumericrole,\n       'salesprice' AS baseunitprice_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS baseextprice_xtnumericrole,\n       'curr' AS extpricebalance_xtnumericrole,\n       'curr' AS baseextpricebalance_xtnumericrole,\n       0 AS coitem_qtyord_xttotalrole,\n       0 AS coitem_qtyshipped_xttotalrole,\n       0 AS coitem_qtyreturned_xttotalrole,\n       0 AS qtybalance_xttotalrole,\n       0 AS baseextprice_xttotalrole,\n       0 AS baseextpricebalance_xttotalrole\nFROM (\n  SELECT\n         0 AS xtindentrole,\n         -- dummy coitem record\n         -1            AS coitem_id,        NULL::INTEGER AS coitem_cohead_id,\n         -1            AS coitem_linenumber,NULL::INTEGER AS coitem_itemsite_id,\n         NULL::TEXT    AS coitem_status,    NULL::DATE    AS coitem_scheddate,\n         getSoSchedDate(cohead_id) AS sort_scheddate,\n         NULL::DATE    AS coitem_promdate,  NULL::NUMERIC AS coitem_qtyord,\n         NULL::NUMERIC AS coitem_unitcost,  NULL::NUMERIC AS coitem_price,\n         NULL::NUMERIC AS coitem_custprice, NULL::NUMERIC AS coitem_qtyshipped,\n         NULL::INTEGER AS coitem_order_id,  NULL::TEXT    AS coitem_memo,\n         NULL::BOOLEAN AS coitem_imported,  NULL::NUMERIC AS coitem_qtyreturned,\n         NULL::TIMESTAMP AS coitem_closedate, NULL::BOOLEAN AS coitem_firm,\n         NULL::TEXT    AS coitem_custpn,    NULL::TEXT    AS coitem_order_type,\n         NULL::TEXT    AS coitem_close_username,\n         NULL::TIMESTAMP AS coitem_lastupdated,\n         NULL::INTEGER AS coitem_substitute_item_id,\n         NULL::TIMESTAMP AS coitem_created, NULL::TEXT    AS coitem_creator,\n         NULL::NUMERIC AS coitem_prcost,\n         NULL::INTEGER AS coitem_qty_uom_id,\n         NULL::NUMERIC AS coitem_qty_invuomratio,\n         NULL::INTEGER AS coitem_price_uom_id,\n         NULL::NUMERIC AS coitem_price_invuomratio,\n         NULL::BOOLEAN AS coitem_warranty,\n         NULL::INTEGER AS coitem_cos_accnt_id,\n         NULL::NUMERIC AS coitem_qtyreserved,\n         NULL::INTEGER AS coitem_subnumber,\n         cohead.*,\n         cust_number, cust_name,\n         NULL::TEXT AS item_number, NULL::TEXT AS item_descrip1,\n         NULL::TEXT AS itemdescription,\n         NULL::TEXT AS uom_name,\n         NULL::TEXT AS warehous_code,\n         NULL::NUMERIC AS qtybalance,\n         NULL::NUMERIC AS baseunitprice,\n         NULL::NUMERIC AS extprice,\n         NULL::NUMERIC AS baseextprice,\n         NULL::NUMERIC AS extpricebalance,\n         NULL::NUMERIC AS baseextpricebalance\n\n  FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n              JOIN custinfo ON (cust_id=cohead_cust_id)\n              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n              JOIN site() ON (warehous_id=itemsite_warehous_id)\n              JOIN item ON (item_id=itemsite_item_id)\n              JOIN uom ON (uom_id=coitem_qty_uom_id)\n<? foreach("char_id_text_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> \n          ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='SO') \n         AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=cohead_id)\n         AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> \n          ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> \n          ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='SO') \n         AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=cohead_id)\n         AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> \n          ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> \n          ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='SO') \n         AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=cohead_id)\n         AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> \n          ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\n  WHERE ( (coitem_status='O')\n  <? if exists("cohead_id") ?>\n    AND  (coitem_cohead_id=<? value("cohead_id") ?>)\n  <? endif ?>\n  <? if exists("startDate") ?>\n    AND  (cohead_orderdate >= <? value("startDate") ?>)\n  <? endif ?>\n  <? if exists("endDate") ?>\n    AND  (cohead_orderdate <= <? value("endDate") ?>)\n  <? endif ?>\n  <? if exists("startDateSched") ?>\n    AND  (coitem_scheddate >= <? value("startDateSched") ?>)\n  <? endif ?>\n  <? if exists("endDateSched") ?>\n    AND  (coitem_scheddate <= <? value("endDateSched") ?>)\n  <? endif ?>\n  <? if exists("salesrep_id") ?>\n    AND  (cohead_salesrep_id=<? value("salesrep_id") ?>)\n  <? endif ?>\n  <? if exists("shipto_id") ?>\n    AND  (cohead_shipto_id=<? value("shipto_id") ?>)\n  <? endif ?>\n  <? if exists("cust_id") ?>\n    AND  (cohead_cust_id=<? value("cust_id") ?>)\n  <? endif ?>\n  <? if exists("custtype_id") ?>\n    AND  (cust_custtype_id=<? value("custtype_id") ?>)\n  <? endif ?>\n  <? if exists("custtype_pattern") ?>\n    AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                               FROM custtype\n                               WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? endif ?>\n  <? if exists("custgrp") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem))\n  <? endif ?>\n  <? if exists("custgrp_id") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem\n                     WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n  <? endif ?>\n  <? if exists("custgrp_pattern") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrp, custgrpitem\n                     WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                       AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n  <? endif ?>\n\n  <? if exists("item_id") ?>\n    AND  (itemsite_item_id=<? value("item_id") ?>)\n  <? endif ?>\n  <? if exists("prodcat_id") ?>\n    AND (item_prodcat_id=<? value("prodcat_id") ?>)\n  <? endif ?>\n  <? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                             FROM prodcat\n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n  <? endif ?>\n\n  <? if exists("warehous_id") ?>\n    AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n  <? literal("charClause") ?>\n        )\n\n  UNION\n\n  SELECT \n         1 AS xtindentrole,\n         coitem_id,        coitem_cohead_id,\n         coitem_linenumber,coitem_itemsite_id,\n         coitem_status,    coitem_scheddate,\n         getSoSchedDate(cohead_id) AS sort_scheddate,\n         coitem_promdate,  coitem_qtyord,\n         coitem_unitcost,  coitem_price,\n         coitem_custprice, coitem_qtyshipped,\n         coitem_order_id,  coitem_memo,\n         coitem_imported,  coitem_qtyreturned,\n         coitem_closedate, coitem_firm,\n         coitem_custpn,    coitem_order_type,\n         coitem_close_username,\n         coitem_lastupdated,\n         coitem_substitute_item_id,\n         coitem_created,   coitem_creator,\n         coitem_prcost,\n         coitem_qty_uom_id,\n         coitem_qty_invuomratio,\n         coitem_price_uom_id,\n         coitem_price_invuomratio,\n         coitem_warranty,\n         coitem_cos_accnt_id,\n         coitem_qtyreserved,\n         coitem_subnumber,\n         cohead.*,\n         cust_number, cust_name,\n         item_number, item_descrip1, (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n         uom_name,\n         warehous_code,\n         noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qtybalance,\n         currtobase(cohead_curr_id, coitem_price, cohead_orderdate) AS baseunitprice,\n         round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (coitem_price / coitem_price_invuomratio), 2) AS extprice,\n         round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextprice,\n         round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                     (coitem_price / coitem_price_invuomratio), 2) AS extpricebalance,\n         round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                     (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextpricebalance\n\n  FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n              JOIN custinfo ON (cust_id=cohead_cust_id)\n              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n              JOIN site() ON (warehous_id=itemsite_warehous_id)\n              JOIN item ON (item_id=itemsite_item_id)\n              JOIN uom ON (uom_id=coitem_qty_uom_id)\n<? foreach("char_id_text_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> \n          ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='SO') \n         AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=cohead_id)\n         AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> \n          ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> \n          ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='SO') \n         AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=cohead_id)\n         AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> \n          ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> \n          ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='SO') \n         AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=cohead_id)\n         AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> \n          ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\n  WHERE ( (coitem_status='O')\n  <? if exists("cohead_id") ?>\n    AND  (coitem_cohead_id=<? value("cohead_id") ?>)\n  <? endif ?>\n  <? if exists("startDate") ?>\n    AND  (cohead_orderdate >= <? value("startDate") ?>)\n  <? endif ?>\n  <? if exists("endDate") ?>\n    AND  (cohead_orderdate <= <? value("endDate") ?>)\n  <? endif ?>\n  <? if exists("startDateSched") ?>\n    AND  (coitem_scheddate >= <? value("startDateSched") ?>)\n  <? endif ?>\n  <? if exists("endDateSched") ?>\n    AND  (coitem_scheddate <= <? value("endDateSched") ?>)\n  <? endif ?>\n  <? if exists("salesrep_id") ?>\n    AND  (cohead_salesrep_id=<? value("salesrep_id") ?>)\n  <? endif ?>\n  <? if exists("shipto_id") ?>\n    AND  (cohead_shipto_id=<? value("shipto_id") ?>)\n  <? endif ?>\n  <? if exists("cust_id") ?>\n    AND  (cohead_cust_id=<? value("cust_id") ?>)\n  <? endif ?>\n  <? if exists("custtype_id") ?>\n    AND  (cust_custtype_id=<? value("custtype_id") ?>)\n  <? endif ?>\n  <? if exists("custtype_pattern") ?>\n    AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                               FROM custtype\n                               WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? endif ?>\n  <? if exists("custgrp") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem))\n  <? endif ?>\n  <? if exists("custgrp_id") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem\n                     WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n  <? endif ?>\n  <? if exists("custgrp_pattern") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrp, custgrpitem\n                     WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                       AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n  <? endif ?>\n\n  <? if exists("item_id") ?>\n    AND  (itemsite_item_id=<? value("item_id") ?>)\n  <? endif ?>\n  <? if exists("prodcat_id") ?>\n    AND (item_prodcat_id=<? value("prodcat_id") ?>)\n  <? endif ?>\n  <? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                             FROM prodcat\n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n  <? endif ?>\n\n  <? if exists("warehous_id") ?>\n    AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n  <? literal("charClause") ?>\n        )\n\n) AS dummy\nORDER BY cohead_number, xtindentrole, coitem_linenumber;\n   admin   2014-10-06      0
101078
 
444     bankrec checks   used by reconcileBankaccount\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: bankrec\n-- Name: checks\n-- Notes: used by reconcileBankaccount\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("summary") ?>\nSELECT COALESCE(SUM(amount),0.0) AS cleared_amount\n  FROM ( SELECT COALESCE( bankrecitem_amount,\n                          currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) ) AS amount\n           FROM (bankaccnt CROSS JOIN gltrans)\n                       JOIN bankrecitem ON ((bankrecitem_source='GL')\n                                        AND (bankrecitem_source_id=gltrans_id)\n                                        AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                        AND (bankrecitem_cleared))\n          WHERE ((gltrans_accnt_id=bankaccnt_accnt_id)\n            AND (NOT gltrans_deleted)\n            AND (NOT gltrans_rec)\n            AND (gltrans_amount > 0)\n            AND (gltrans_doctype != 'JP')\n            AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n          UNION ALL\n         SELECT COALESCE( bankrecitem_amount,\n                          currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) ) AS amount\n           FROM (bankaccnt CROSS JOIN sltrans)\n                       JOIN bankrecitem ON ((bankrecitem_source='SL')\n                                        AND (bankrecitem_source_id=sltrans_id)\n                                        AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                        AND (bankrecitem_cleared))\n          WHERE ((sltrans_accnt_id=bankaccnt_accnt_id)\n            AND (NOT sltrans_rec)\n            AND (sltrans_amount > 0)\n            AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n          UNION ALL\n         SELECT CASE WHEN(bankadjtype_iscredit=false) THEN (bankadj_amount * -1) ELSE bankadj_amount END AS amount\n           FROM bankadj, bankadjtype, bankrecitem\n          WHERE ( (bankrecitem_source='AD')\n            AND (bankrecitem_source_id=bankadj_id)\n            AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n            AND (bankrecitem_cleared)\n            AND (bankadj_bankadjtype_id=bankadjtype_id)\n            AND (NOT bankadj_posted)\n            AND (((bankadjtype_iscredit=true) AND (bankadj_amount > 0)) OR ((bankadjtype_iscredit=false) AND (bankadj_amount < 0)))\n            AND (bankadj_bankaccnt_id=<? value("bankaccntid") ?>) ) ) AS data;\n<? else ?>\nSELECT gltrans_id AS id, 1 AS altid,\n       COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n       COALESCE(bankrecitem_effdate, gltrans_date) AS transdate,\n       gltrans_doctype AS doc_type,\n       gltrans_docnumber AS doc_number,\n       gltrans_notes AS notes,\n       (SELECT currConcat(COALESCE(checkhead_curr_id, baseCurrId()))) AS doc_curr,\n       COALESCE(bankrecitem_curr_rate, checkhead_curr_rate, currRate(bankaccnt_curr_id, gltrans_date)) AS doc_exchrate,\n       gltrans_amount AS base_amount,\n       CASE WHEN (bankaccnt_curr_id=checkhead_curr_id) THEN\n         COALESCE( bankrecitem_amount,\n                   checkhead_amount,\n                   currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) )\n            ELSE\n         COALESCE( bankrecitem_amount,\n                   currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) )\n       END AS amount,\n       gltrans_date AS sortdate,\n       'uomratio' AS doc_exchrate_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS amount_xtnumericrole\n  FROM (bankaccnt CROSS JOIN gltrans)\n              LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='GL')\n                                          AND (bankrecitem_source_id=gltrans_id)\n                                          AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                          AND (bankrecitem_cleared))\n              LEFT OUTER JOIN checkhead ON ((gltrans_doctype='CK')\n                                        AND (gltrans_misc_id=checkhead_id))\n WHERE ((gltrans_accnt_id=bankaccnt_accnt_id)\n   AND (NOT gltrans_deleted)\n   AND (NOT gltrans_rec)\n   AND (NOT COALESCE(checkhead_void, false))\n   AND (gltrans_amount > 0)\n   AND (gltrans_doctype != 'JP')\n   AND (bankaccnt_id=<? value("bankaccntid") ?>)\n<? if exists("source") ?>\n   AND ('GL' = <? value("source") ?>)\n<? endif ?>\n<? if exists("sourceid") ?>\n   AND (gltrans_id = <? value("sourceid") ?>)\n<? endif ?>\n )\n UNION ALL\nSELECT sltrans_id AS id, 2 AS altid,\n       COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n       COALESCE(bankrecitem_effdate, sltrans_date) AS transdate,\n       sltrans_doctype AS doc_type,\n       sltrans_docnumber AS doc_number,\n       sltrans_notes AS notes,\n       (SELECT currConcat(COALESCE(checkhead_curr_id, baseCurrId()))) AS doc_curr,\n       COALESCE(bankrecitem_curr_rate, checkhead_curr_rate, currRate(bankaccnt_curr_id, sltrans_date)) AS doc_exchrate,\n       sltrans_amount AS base_amount,\n       CASE WHEN (bankaccnt_curr_id=checkhead_curr_id) THEN\n         COALESCE( bankrecitem_amount,\n                   checkhead_amount,\n                   currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) )\n            ELSE\n         COALESCE( bankrecitem_amount,\n                   currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) )\n       END AS amount,\n       sltrans_date AS sortdate,\n       'uomratio' AS doc_exchrate_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS amount_xtnumericrole\n  FROM (bankaccnt CROSS JOIN sltrans)\n              LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='SL')\n                                          AND (bankrecitem_source_id=sltrans_id)\n                                          AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                          AND (bankrecitem_cleared))\n              LEFT OUTER JOIN checkhead ON ((sltrans_doctype='CK')\n                                        AND (sltrans_misc_id=checkhead_id))\n WHERE ((sltrans_accnt_id=bankaccnt_accnt_id)\n   AND (NOT sltrans_rec)\n   AND (NOT COALESCE(checkhead_void, false))\n   AND (sltrans_amount > 0)\n   AND (bankaccnt_id=<? value("bankaccntid") ?>)\n<? if exists("source") ?>\n   AND ('SL' = <? value("source") ?>)\n<? endif ?>\n<? if exists("sourceid") ?>\n   AND (sltrans_id = <? value("sourceid") ?>)\n<? endif ?>\n )\n UNION ALL\nSELECT bankadj_id AS id, 3 AS altid,\n       COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n       COALESCE(bankrecitem_effdate, bankadj_date) AS transdate,\n       'ADJ' AS doc_type,\n       bankadj_docnumber AS doc_number,\n       bankadjtype_name AS notes,\n       (SELECT currConcat(bankadj_curr_id)) AS doc_curr,\n       1.0 AS doc_exchrate,\n       CASE WHEN(bankadjtype_iscredit=false) THEN (bankadj_amount * -1.0) ELSE bankadj_amount END AS base_amount,\n       CASE WHEN(bankadjtype_iscredit=false) THEN (bankadj_amount * -1.0) ELSE bankadj_amount END AS amount,\n       bankadj_date AS sortdate,\n       'uomratio' AS doc_exchrate_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS amount_xtnumericrole\n  FROM (bankadjtype CROSS JOIN bankadj)\n               LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='AD')\n                                           AND (bankrecitem_source_id=bankadj_id)\n                                           AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                           AND (bankrecitem_cleared))\n WHERE ( (((bankadjtype_iscredit=true) AND (bankadj_amount > 0)) OR ((bankadjtype_iscredit=false) AND (bankadj_amount < 0)))\n   AND (bankadj_bankadjtype_id=bankadjtype_id)\n   AND (NOT bankadj_posted)\n   AND (bankadj_bankaccnt_id=<? value("bankaccntid") ?>)\n<? if exists("source") ?>\n   AND ('AD' = <? value("source") ?>)\n<? endif ?>\n<? if exists("sourceid") ?>\n   AND (bankadj_id = <? value("sourceid") ?>)\n<? endif ?>\n )\nORDER BY sortdate;\n<? endif ?>\n    admin   2014-10-06      0
101079
 
445     bankrec clearedbalance   used by reconcileBankaccount\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: bankrec\n-- Name: clearedbalance\n-- Notes: used by reconcileBankaccount\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT (COALESCE(SUM(amount),0.0) + <? value("begBal") ?>) AS cleared_amount,\n       <? value("endBal") ?> AS end_amount,\n       (<? value("endBal") ?> - (<? value("begBal") ?> + (COALESCE(SUM(amount),0.0)))) AS diff_amount,\n       round(<? value("endBal") ?> - (<? value("begBal") ?> + COALESCE(SUM(amount),0.0)), 2) AS diff_value\n  FROM ( SELECT CASE WHEN (gltrans_amount > 0) THEN bankrecitem_amount * -1.0\n                     ELSE bankrecitem_amount END AS amount\n           FROM bankaccnt, gltrans, bankrecitem\n          WHERE ((gltrans_accnt_id=bankaccnt_accnt_id)\n            AND (bankrecitem_source='GL')\n            AND (bankrecitem_source_id=gltrans_id)\n            AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n            AND (bankrecitem_cleared)\n            AND (NOT gltrans_deleted)\n            AND (NOT gltrans_rec)\n            AND (bankaccnt_id=<? value("bankaccntid") ?>) ) \n          UNION ALL\n         SELECT CASE WHEN (sltrans_amount > 0) THEN bankrecitem_amount * -1.0\n                     ELSE bankrecitem_amount END AS amount\n           FROM bankaccnt, sltrans, bankrecitem\n          WHERE ((sltrans_accnt_id=bankaccnt_accnt_id)\n            AND (bankrecitem_source='SL')\n            AND (bankrecitem_source_id=sltrans_id)\n            AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n            AND (bankrecitem_cleared)\n            AND (NOT sltrans_rec)\n            AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n          UNION ALL\n         SELECT CASE WHEN(bankadjtype_iscredit=true) THEN (bankadj_amount * -1) ELSE bankadj_amount END AS amount\n           FROM bankadj, bankadjtype, bankrecitem\n          WHERE ( (bankrecitem_source='AD')\n            AND (bankrecitem_source_id=bankadj_id)\n            AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n            AND (bankrecitem_cleared)\n            AND (bankadj_bankadjtype_id=bankadjtype_id)\n            AND (NOT bankadj_posted)\n            AND (bankadj_bankaccnt_id=<? value("bankaccntid") ?>) ) ) AS data;\n     admin   2014-10-06      0
101080
 
446     bankrec receipts         used by reconcileBankaccount\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: bankrec\n-- Name: receipts\n-- Notes: used by reconcileBankaccount\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("summary") ?>\nSELECT COALESCE(SUM(amount),0.0) AS cleared_amount\n  FROM ( SELECT COALESCE( bankrecitem_amount,\n                          (currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) ) AS amount\n           FROM (bankaccnt CROSS JOIN gltrans)\n                      JOIN bankrecitem ON ((bankrecitem_source='GL')\n                                       AND (bankrecitem_source_id=gltrans_id)\n                                       AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                       AND (bankrecitem_cleared))\n          WHERE ((gltrans_accnt_id=bankaccnt_accnt_id)\n            AND (NOT gltrans_deleted)\n            AND (NOT gltrans_rec)\n            AND (gltrans_amount < 0)\n            AND (gltrans_doctype != 'JP')\n            AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n          UNION ALL\n         SELECT COALESCE( bankrecitem_amount,\n                          (currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) ) AS amount\n           FROM (bankaccnt CROSS JOIN sltrans)\n                      JOIN bankrecitem ON ((bankrecitem_source='SL')\n                                       AND (bankrecitem_source_id=sltrans_id)\n                                       AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                       AND (bankrecitem_cleared))\n          WHERE ((sltrans_accnt_id=bankaccnt_accnt_id)\n            AND (NOT sltrans_rec)\n            AND (sltrans_amount < 0)\n            AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n          UNION ALL\n         SELECT CASE WHEN(bankadjtype_iscredit=true) THEN (bankadj_amount * -1) ELSE bankadj_amount END AS amount\n           FROM bankrecitem, bankadj, bankadjtype\n          WHERE ( (bankrecitem_source='AD')\n            AND (bankrecitem_source_id=bankadj_id)\n            AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n            AND (bankrecitem_cleared)\n            AND (bankadj_bankadjtype_id=bankadjtype_id)\n            AND (NOT bankadj_posted)\n            AND (((bankadjtype_iscredit=false) AND (bankadj_amount > 0)) OR (bankadjtype_iscredit=true AND (bankadj_amount < 0)))\n            AND (bankadj_bankaccnt_id=<? value("bankaccntid") ?>) ) ) AS data;\n<? else ?>\nSELECT gltrans_id AS id, 1 AS altid,\n       jrnluse_use AS use, gltrans_journalnumber AS jrnlnum,\n       COALESCE(date(jrnluse_date), gltrans_date) AS f_jrnldate,\n       COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n       COALESCE(bankrecitem_effdate, gltrans_date) AS f_date,\n       gltrans_doctype AS doc_type,\n       gltrans_docnumber AS docnumber,\n       gltrans_notes AS notes,\n       currConcat(COALESCE(cashrcpt_curr_id, baseCurrId())) AS doc_curr,\n       COALESCE(bankrecitem_curr_rate, cashrcpt_curr_rate, currRate(bankaccnt_curr_id, gltrans_date)) AS doc_exchrate,\n       (gltrans_amount * -1.0) AS base_amount,\n       CASE WHEN (bankaccnt_curr_id=cashrcpt_curr_id) THEN\n         COALESCE( bankrecitem_amount,\n                   cashrcpt_amount,\n                   (currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) )\n            ELSE\n         COALESCE( bankrecitem_amount,\n                   (currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) )\n       END AS amount,\n       COALESCE(date(jrnluse_date), gltrans_date) AS jrnldate,\n       gltrans_date AS sortdate,\n       'uomratio' AS doc_exchrate_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS amount_xtnumericrole\n  FROM bankaccnt\n  JOIN gltrans ON (bankaccnt_accnt_id=gltrans_accnt_id)\n  LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='GL')\n                              AND (bankrecitem_source_id=gltrans_id)\n                              AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                              AND (bankrecitem_cleared))\n  LEFT OUTER JOIN jrnluse ON (jrnluse_number=gltrans_journalnumber AND jrnluse_use='C/R')\n  LEFT OUTER JOIN cashrcpt  ON ((gltrans_source='A/R')\n                            AND (gltrans_doctype='CR')\n                            AND (gltrans_misc_id=cashrcpt_id))\n  LEFT OUTER JOIN checkhead ON ((gltrans_doctype='CK')\n                            AND (gltrans_misc_id=checkhead_id))\n WHERE ((NOT gltrans_deleted)\n   AND (NOT gltrans_rec)\n   AND (NOT COALESCE(checkhead_void, false))\n   AND (gltrans_amount < 0)\n   AND (gltrans_doctype != 'JP')\n   AND (bankaccnt_id=<? value("bankaccntid") ?>)\n<? if exists("source") ?>\n   AND ('GL' = <? value("source") ?>)\n<? endif ?>\n<? if exists("sourceid") ?>\n   AND (gltrans_id = <? value("sourceid") ?>)\n<? endif ?>\n )\n UNION ALL\nSELECT sltrans_id AS id, 2 AS altid,\n       jrnluse_use AS use, sltrans_journalnumber AS jrnlnum,\n       COALESCE(date(jrnluse_date), sltrans_date) AS f_jrnldate,\n       COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n       COALESCE(bankrecitem_effdate, sltrans_date) AS f_date,\n       sltrans_doctype AS doc_type,\n       sltrans_docnumber AS docnumber,\n       sltrans_notes AS notes,\n       currConcat(COALESCE(cashrcpt_curr_id, baseCurrId())) AS doc_curr,\n       COALESCE(bankrecitem_curr_rate, cashrcpt_curr_rate, currRate(bankaccnt_curr_id, sltrans_date)) AS doc_exchrate,\n       (sltrans_amount * -1.0) AS base_amount,\n       CASE WHEN (bankaccnt_curr_id=cashrcpt_curr_id) THEN\n         COALESCE( bankrecitem_amount,\n                   cashrcpt_amount,\n                   (currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) )\n            ELSE\n         COALESCE( bankrecitem_amount,\n                   (currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) )\n       END AS amount,\n       COALESCE(date(jrnluse_date), sltrans_date) AS jrnldate,\n       sltrans_date AS sortdate,\n       'uomratio' AS doc_exchrate_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS amount_xtnumericrole\n  FROM bankaccnt\n  JOIN sltrans ON (bankaccnt_accnt_id=sltrans_accnt_id)\n  LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='SL')\n                              AND (bankrecitem_source_id=sltrans_id)\n                              AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                              AND (bankrecitem_cleared))\n  LEFT OUTER JOIN jrnluse ON (jrnluse_number=sltrans_journalnumber AND jrnluse_use='C/R')\n  LEFT OUTER JOIN cashrcpt  ON ((sltrans_source='A/R')\n                            AND (sltrans_doctype='CR')\n                            AND (sltrans_misc_id=cashrcpt_id))\n  LEFT OUTER JOIN checkhead ON ((sltrans_doctype='CK')\n                            AND (sltrans_misc_id=checkhead_id))\n WHERE ((NOT sltrans_rec)\n   AND (NOT COALESCE(checkhead_void, false))\n   AND (sltrans_amount < 0)\n   AND (bankaccnt_id=<? value("bankaccntid") ?>)\n<? if exists("source") ?>\n   AND ('SL' = <? value("source") ?>)\n<? endif ?>\n<? if exists("sourceid") ?>\n   AND (sltrans_id = <? value("sourceid") ?>)\n<? endif ?>\n )\n UNION ALL\nSELECT bankadj_id AS id, 3 AS altid,\n       '' AS use, NULL AS jrnlnum, bankadj_date AS f_jrnldate,\n       COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n       COALESCE(bankrecitem_effdate, bankadj_date) AS f_date,\n       'ADJ' AS doc_type,\n       bankadj_docnumber AS docnumber,\n       bankadjtype_name AS notes,\n       currConcat(bankadj_curr_id) AS doc_curr,\n       1.0 AS doc_exchrate,\n       CASE WHEN(bankadjtype_iscredit=true) THEN (bankadj_amount * -1.0) ELSE bankadj_amount END AS base_amount,\n       CASE WHEN(bankadjtype_iscredit=true) THEN (bankadj_amount * -1.0) ELSE bankadj_amount END AS amount,\n       bankadj_date AS jrnldate,\n       bankadj_date AS sortdate,\n       'uomratio' AS doc_exchrate_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS amount_xtnumericrole\n  FROM (bankadjtype CROSS JOIN bankadj)\n               LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='AD')\n                                           AND (bankrecitem_source_id=bankadj_id)\n                                           AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>))\n WHERE ( (((bankadjtype_iscredit=false) AND (bankadj_amount > 0)) OR ((bankadjtype_iscredit=true) AND (bankadj_amount < 0)))\n   AND (bankadj_bankadjtype_id=bankadjtype_id)\n   AND (NOT bankadj_posted)\n   AND (bankadj_bankaccnt_id=<? value("bankaccntid") ?>)\n<? if exists("source") ?>\n   AND ('AD' = <? value("source") ?>)\n<? endif ?>\n<? if exists("sourceid") ?>\n   AND (bankadj_id = <? value("sourceid") ?>)\n<? endif ?>\n )\nORDER BY jrnldate, jrnlnum, sortdate;\n<? endif ?>\n   admin   2014-10-06      0
101081
 
105     bankrecHistory  reconciled       \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: bankrecHistory\n-- Name: reconciled\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("treeView") ?>\nSELECT -1 AS gltrans_id, bankrec_opendate AS gltrans_date, formatDate(bankrec_opendate) AS f_date,\n       <? value("openingBalance") ?> AS gltrans_docnumber, <? value("openingBalance") ?> AS type, 0 AS sort, NULL AS gltrans_notes, \n       bankrec_openbal AS amount, formatMoney(bankrec_openbal) AS f_amount,\n       'curr' AS amount_xtnumericrole,\n       0 AS xtindentrole\n  FROM bankrec\n  WHERE (bankrec_id=<? value("bankrec_id") ?>)\n  \nUNION\n<? endif ?>\n\nSELECT gltrans_id, gltrans_date, formatDate(gltrans_date) AS f_date,\n       gltrans_docnumber,\n       CASE WHEN gltrans_doctype = 'CK' THEN <? value("Checks") ?>\n            WHEN gltrans_doctype = 'CR' THEN <? value("Deposits") ?>\n            ELSE <? value("Adjustments") ?> END AS type,\n       CASE WHEN gltrans_doctype = 'CK' THEN 1\n            WHEN gltrans_doctype = 'CR' THEN 2\n            ELSE '3' END AS sort,\n       gltrans_notes AS notes,\n       COALESCE( bankrecitem_amount,\n                 (currtolocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) ) AS amount,\n       formatMoney(COALESCE( bankrecitem_amount,\n                             (currtolocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) ) ) AS f_amount,\n       'curr' AS amount_xtnumericrole,\n       1 AS xtindentrole\n  FROM gltrans, bankrecitem \n    JOIN bankrec ON (bankrecitem_bankrec_id=bankrec_id)\n    JOIN bankaccnt ON (bankaccnt_id=bankrec_bankaccnt_id)\n WHERE ((bankrecitem_bankrec_id=<? value("bankrec_id") ?>)\n   AND (bankrecitem_source='GL')\n   AND (bankrecitem_source_id=gltrans_id)\n   AND (NOT gltrans_deleted) ) \n\nUNION\n\nSELECT sltrans_id, sltrans_date, formatDate(sltrans_date) AS f_date,\n       sltrans_docnumber,\n       CASE WHEN sltrans_doctype = 'CK' THEN <? value("Checks") ?>\n            WHEN sltrans_doctype = 'CR' THEN <? value("Deposits") ?>\n            ELSE <? value("Adjustments") ?> END AS type,\n       CASE WHEN sltrans_doctype = 'CK' THEN 1\n            WHEN sltrans_doctype = 'CR' THEN 2\n            ELSE '3' END AS sort,\n       sltrans_notes AS notes,\n       COALESCE( bankrecitem_amount,\n                 (currtolocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) ) AS amount,\n       formatMoney(COALESCE( bankrecitem_amount,\n                             (currtolocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) ) ) AS f_amount,\n       'curr' AS amount_xtnumericrole,\n       1 AS xtindentrole\n  FROM sltrans, bankrecitem \n    JOIN bankrec ON (bankrecitem_bankrec_id=bankrec_id)\n    JOIN bankaccnt ON (bankaccnt_id=bankrec_bankaccnt_id)\n WHERE ((bankrecitem_bankrec_id=<? value("bankrec_id") ?>)\n   AND (bankrecitem_source='SL')\n   AND (bankrecitem_source_id=sltrans_id) ) \n\n<? if exists("treeView") ?>\nUNION\n\nSELECT -1 AS gltrans_id, bankrec_enddate, formatDate(bankrec_enddate) AS f_date,\n       <? value("closingBalance") ?>, <? value("closingBalance") ?> AS type, 7 AS sort, NULL, \n       bankrec_endbal AS amount, formatMoney(bankrec_endbal) AS f_amount,\n       'curr' AS amount_xtnumericrole,\n       0 AS xtindentrole\n  FROM bankrec\n  WHERE (bankrec_id=<? value("bankrec_id") ?>)\n\nUNION\nSELECT -1, NULL, NULL, <? value("Checks") ?>, NULL, 1, NULL, NULL, NULL, 'curr', 0 \nUNION\nSELECT -1, NULL, NULL, <? value("Deposits") ?>, NULL, 2, NULL, NULL, NULL, 'curr', 0 \nUNION\nSELECT -1, NULL, NULL, <? value("Adjustments") ?>, NULL, 3, NULL, NULL, NULL, 'curr', 0 \n<? endif ?>\n\nORDER BY  sort, xtindentrole, type, f_date, gltrans_id\n  admin   2014-10-06      0
101082
 
106     bankrecHistory  unreconciled     \n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: bankrecHistory\n-- Name: unreconciled\n-- Notes: \n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_id, gltrans_date, formatDate(gltrans_date) AS f_date,\n      gltrans_docnumber,\n       CASE WHEN gltrans_doctype = 'CK' THEN <? value("Checks") ?>\n            WHEN gltrans_doctype = 'CR' THEN <? value("Deposits") ?>\n            ELSE <? value("Adjustments") ?> END AS type,\n       CASE WHEN gltrans_doctype = 'CK' THEN 1\n            WHEN gltrans_doctype = 'CR' THEN 2\n            ELSE '3' END AS sort,\n      gltrans_notes AS notes,\n      currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1 AS amount,\n      formatMoney(currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1) AS f_amount,\n      CASE WHEN gltrans_doctype = 'CK' THEN \n        currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1\n      ELSE 0 END AS rtcheck,\n      CASE WHEN gltrans_doctype = 'CR' THEN \n        currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1\n      ELSE 0 END AS rtdep,\n      CASE WHEN gltrans_doctype NOT IN ('CK','CR') THEN \n        currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1\n      ELSE 0 END AS rtadj,\n      'curr' AS amount_xtnumericrole,\n      1 AS xtindentrole\n FROM gltrans\n   JOIN bankaccnt ON (bankaccnt_accnt_id = gltrans_accnt_id)\n   JOIN bankrec selrec ON ((selrec.bankrec_bankaccnt_id = bankaccnt_id)\n                       AND (selrec.bankrec_id=<? value("bankrec_id") ?>))\n   LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='GL')\n\n                              AND (bankrecitem_source_id=gltrans_id))\n   LEFT OUTER JOIN bankrec actrec ON (actrec.bankrec_id = bankrecitem_bankrec_id)\n   LEFT OUTER JOIN checkhead ON ((gltrans_doctype='CK')\n                             AND (gltrans_misc_id=checkhead_id))\n<? if exists("showUnreconciled") ?>\n WHERE ((COALESCE(actrec.bankrec_postdate,endoftime()) > COALESCE(selrec.bankrec_postdate,now()))\n  AND (NOT gltrans_deleted)\n  AND (NOT COALESCE(checkhead_void, false)))\n  AND (gltrans_doctype != 'JP')\n<? else ?>\n WHERE (false)\n<? endif ?>\n\nUNION\n\nSELECT sltrans_id, sltrans_date, formatDate(sltrans_date) AS f_date,\n      sltrans_docnumber,\n       CASE WHEN sltrans_doctype = 'CK' THEN <? value("Checks") ?>\n            WHEN sltrans_doctype = 'CR' THEN <? value("Deposits") ?>\n            ELSE <? value("Adjustments") ?> END AS type,\n       CASE WHEN sltrans_doctype = 'CK' THEN 1\n            WHEN sltrans_doctype = 'CR' THEN 2\n            ELSE '3' END AS sort,\n      sltrans_notes AS notes,\n      currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1 AS amount,\n      formatMoney(currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1) AS f_amount,\n      CASE WHEN sltrans_doctype = 'CK' THEN \n        currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1\n      ELSE 0 END AS rtcheck,\n      CASE WHEN sltrans_doctype = 'CR' THEN \n        currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1\n      ELSE 0 END AS rtdep,\n      CASE WHEN sltrans_doctype NOT IN ('CK','CR') THEN \n        currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1\n      ELSE 0 END AS rtadj,\n      'curr' AS amount_xtnumericrole,\n      1 AS xtindentrole\n FROM sltrans\n   JOIN bankaccnt ON (bankaccnt_accnt_id = sltrans_accnt_id)\n   JOIN bankrec selrec ON ((selrec.bankrec_bankaccnt_id = bankaccnt_id)\n                       AND (selrec.bankrec_id=<? value("bankrec_id") ?>))\n   LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='SL')\n\n                              AND (bankrecitem_source_id=sltrans_id))\n   LEFT OUTER JOIN bankrec actrec ON (actrec.bankrec_id = bankrecitem_bankrec_id)\n   LEFT OUTER JOIN checkhead ON ((sltrans_doctype='CK')\n                             AND (sltrans_misc_id=checkhead_id))\n<? if exists("showUnreconciled") ?>\n WHERE ((COALESCE(actrec.bankrec_postdate,endoftime()) > COALESCE(selrec.bankrec_postdate,now()))\n  AND (NOT COALESCE(checkhead_void, false)))\n<? if exists("treeView") ?>\nUNION\nSELECT -1, NULL, NULL, <? value("Checks") ?>, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL,'curr', 0 \nUNION\nSELECT -1, NULL, NULL, <? value("Deposits") ?>, NULL, 2, NULL, NULL, NULL, NULL, NULL, NULL, 'curr', 0 \nUNION\nSELECT -1, NULL, NULL, <? value("Adjustments") ?>, NULL, 3, NULL, NULL, NULL, NULL, NULL, NULL, 'curr', 0\n<? endif ?>\n\nORDER BY  sort, xtindentrole, type, f_date, gltrans_id\n<? else ?>\n WHERE (false)\n<? endif ?>\n    admin   2014-10-06      0
101083
 
232     billingSelections       detail   used by dspBillingSelections\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: billingSelections\n-- Name: detail\n-- Notes: used by dspBillingSelections\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cobmisc_id, cohead_id,\n       cohead_number, cust_number, cust_name,\n       sum(round(coitem_price*cobill_qty,2)) AS subtotal,\n       cobmisc_misc, cobmisc_freight, calcCobmiscTax(cobmisc_id) AS cobmisc_tax, cobmisc_payment,\n       (sum(round(coitem_price * cobill_qty, 2)) +\n                  cobmisc_misc + cobmisc_freight +\n                  calcCobmiscTax(cobmisc_id)) AS total,\n       'curr' AS subtotal_xtnumericrole,\n       'curr' AS total_xtnumericrole,\n       'curr' AS cobmisc_misc_xtnumericrole,\n       'curr' AS cobmisc_freight_xtnumericrole,\n       'curr' AS cobmisc_tax_xtnumericrole,\n       'curr' AS cobmisc_payment_xtnumericrole\nFROM cobmisc, cohead, custinfo, coitem, cobill\nWHERE ((cobmisc_cohead_id=cohead_id)\n   AND (cohead_cust_id=cust_id)\n   AND (coitem_cohead_id=cohead_id)\n   AND (cobill_coitem_id=coitem_id) AND (COALESCE(cobill_invcnum,0) = 0)\n   AND (NOT cobmisc_posted))\nGROUP BY cobmisc_id, cohead_id, cohead_number, cust_number,\n         cust_name, cobmisc_misc, cobmisc_freight, cobmisc_tax, cobmisc_payment\nORDER BY cohead_number;\n    admin   2014-10-06      0
101084
 
233     bom     detail   used by dspIndentedBOM, dspSingleLevelBOM, dspSummarizedBOM\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: bom\n-- Name: detail\n-- Notes: used by dspIndentedBOM, dspSingleLevelBOM, dspSummarizedBOM\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT <? if exists("bySingleLvl") ?>\n         bomitem_item_id AS itemid, bomitem.*, item_number,\n         invuom.uom_name AS invuomname, issueuom.uom_name AS issueuomname,\n         (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n         (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS invqtyfxd,\n         (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS invqtyper,\n         'qty' AS bomitem_qtyfxd_xtnumericrole,\n         'qty' AS invqtyfxd_xtnumericrole,\n         'qtyper' AS bomitem_qtyper_xtnumericrole,\n         'qtyper' AS invqtyper_xtnumericrole,\n         'percent' AS bomitem_scrap_xtnumericrole,\n         CASE WHEN COALESCE(bomitem_effective, startOfTime()) = startOfTime() \n           THEN <? value("always") ?>\n         END AS bomitem_effective_qtdisplayrole,\n         CASE WHEN COALESCE(bomitem_expires, endOfTime()) = endOfTime() \n           THEN <? value("never") ?>\n         END AS bomitem_expires_qtdisplayrole,\n         CASE WHEN (bomitem_expires < CURRENT_DATE) THEN 'expired'\n              WHEN (bomitem_effective >= CURRENT_DATE) THEN 'future'\n              WHEN (item_type='M') THEN 'altemphasis'\n         END AS qtforegroundrole\n       <? else ?>\n         <? if exists("bySummarized") ?>\n           item_id AS itemid,\n         <? else ?>\n           bomdata_item_id AS itemid,\n         <? endif ?>\n         *,'percent' AS bomdata_scrap_xtnumericrole,\n         'qtyper' AS bomdata_qtyreq_xtnumericrole,\n         CASE WHEN COALESCE(bomdata_effective, startOfTime()) <=\n                   startOfTime() THEN <? value("always") ?>\n         END AS bomdata_effective_qtdisplayrole,\n         CASE WHEN COALESCE(bomdata_expires, endOfTime()) >=\n                   endOfTime() THEN <? value("never") ?>\n         END AS bomdata_expires_qtdisplayrole,\n         CASE WHEN (bomdata_expired) THEN 'expired'\n              WHEN (bomdata_future) THEN 'future'\n         END AS qtforegroundrole\n         <? if not exists("bySummarized") ?>\n           , bomdata_bomwork_level - 1 AS xtindentrole\n         <? endif ?>\n       <? endif ?>\nFROM <? if exists("bySingleLvl") ?>\n       bomitem(<? value("item_id") ?>,<? value("revision_id") ?>),\n       item, uom AS issueuom, uom AS invuom\n     <? elseif exists("byIndented") ?>\n       indentedBOM(<? value("item_id") ?>,\n                   <? value("revision_id") ?>,\n                   <? value("expiredDays") ?>,\n                   <? value("futureDays") ?>)\n     <? elseif exists("bySummarized") ?>\n       summarizedBOM(<? value("item_id") ?>,\n                     <? value("revision_id") ?>,\n                     <? value("expiredDays") ?>,\n                     <? value("futureDays") ?>)\n       JOIN item ON (bomdata_item_number=item_number)\n     <? endif ?>\nWHERE ((TRUE)\n<? if exists("byIndented") ?>\n   AND (bomdata_item_id > 0)\n<? elseif exists("bySingleLvl") ?>\n   AND (bomitem_item_id=item_id)\n   AND (item_inv_uom_id=invuom.uom_id)\n   AND (bomitem_uom_id=issueuom.uom_id)\n  <? if exists("expiredDays") ?>\n   AND (bomitem_expires > (CURRENT_DATE - <? value("expiredDays") ?>))\n  <? else ?>\n   AND (bomitem_expires > CURRENT_DATE)\n  <? endif ?>\n  <? if exists("effectiveDays") ?>\n   AND (bomitem_effective <= (CURRENT_DATE + <? value("effectiveDays") ?>))\n  <? else ?>\n   AND (bomitem_effective <= CURRENT_DATE)\n  <? endif ?>\n<? endif ?>\n      )\n<? if exists("bySingleLvl") ?>\n ORDER BY bomitem_seqnumber, bomitem_effective\n<? endif ?>\n;\n   admin   2014-10-06      0
101085
 
117     bomItems        detail   used by bom, booItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: bomItems\n-- Name: detail\n-- Notes: used by bom, booItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT bomitem_id, item_id, *,\n       (item_descrip1 || ' ' || item_descrip2) AS item_description,\n       CASE WHEN (item_type='P') THEN text(<? value("purchased") ?>)\n            WHEN (item_type='M') THEN text(<? value("manufactured") ?>)\n            WHEN (item_type='J') THEN text(<? value("job") ?>)\n            WHEN (item_type='F') THEN text(<? value("phantom") ?>)\n            WHEN (item_type='B') THEN text(<? value("breeder") ?>)\n            WHEN (item_type='C') THEN text(<? value("coProduct") ?>)\n            WHEN (item_type='Y') THEN text(<? value("byProduct") ?>)\n            WHEN (item_type='R') THEN text(<? value("reference") ?>)\n            WHEN (item_type='S') THEN text(<? value("costing") ?>)\n            WHEN (item_type='T') THEN text(<? value("tooling") ?>)\n            WHEN (item_type='A') THEN text(<? value("assortment") ?>)\n            WHEN (item_type='O') THEN text(<? value("outside") ?>)\n            WHEN (item_type='L') THEN text(<? value("planning") ?>)\n            WHEN (item_type='K') THEN text(<? value("kit") ?>)\n            ELSE text(<? value("error") ?>)\n       END AS itemtype,\n       uom_name AS issueuom,\n       CASE WHEN (bomitem_issuemethod = 'S') THEN <? value("push") ?>\n            WHEN (bomitem_issuemethod = 'L') THEN <? value("pull") ?>\n            WHEN (bomitem_issuemethod = 'M') THEN <? value("mixed") ?>\n            ELSE <? value("error") ?>\n       END AS issuemethod,\n       'qty' AS bomitem_qtyfxd_xtnumericrole,\n       'qtyper' AS bomitem_qtyper_xtnumericrole,\n       'percent' AS bomitem_scrap_xtnumericrole,\n       CASE WHEN (bomitem_effective = startOfTime()) THEN NULL\n            ELSE bomitem_effective END AS effective,\n       CASE WHEN (bomitem_expires = endOfTime()) THEN NULL\n            ELSE bomitem_expires END AS expires,\n       <? value("always") ?> AS effective_xtnullrole,\n       <? value("never") ?>  AS expires_xtnullrole,\n       CASE WHEN (bomitem_expires <= CURRENT_DATE) THEN 'expired'\n            WHEN (bomitem_effective > CURRENT_DATE) THEN 'future'\n            WHEN (item_type='M') THEN 'altemphasis'\n       END AS qtforegroundrole\n<? if exists("booitem_id") ?>\nFROM bomitem(<? value("item_id") ?>), item, uom, xtmfg.booitem\n<? else ?>\nFROM bomitem(<? value("item_id") ?>, <? value("revision_id") ?>), item, uom\n<? endif ?>\nWHERE ((bomitem_item_id=item_id)\n  AND (bomitem_uom_id=uom_id)\n<? if not exists("showExpired") ?>\n  AND (bomitem_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n  AND (bomitem_effective <= CURRENT_DATE)\n<? endif ?>\n<? if exists("booitem_id") ?>\n  AND (booitem_id = <? value("booitem_id") ?>)\n  AND (bomitem_booitem_seq_id = booitem_seq_id)\n<? endif ?>\n  )\nORDER BY bomitem_seqnumber, bomitem_effective;\n   admin   2014-10-06      0
101086
 
234     briefEarnedCommission   detail   used by dspBriefEarnedCommissions\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: briefEarnedCommission\n-- Name: detail\n-- Notes: used by dspBriefEarnedCommissions\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohist_salesrep_id, salesrep_number, salesrep_name, cust_number, cust_name,\n       cohist_ordernumber, cohist_orderdate, cohist_invcnumber, cohist_invcdate, currAbbr,\n       SUM(extprice) AS sumextprice,\n       SUM(cohist_commission) AS sumcommission,\n       SUM(baseextprice) AS sumbaseextprice,\n       SUM(basecommission) AS sumbasecommission,\n<? if exists("isReport") ?>\n       formatDate(cohist_orderdate) AS f_orderdate,\n       formatDate(cohist_invcdate) AS f_invcdate,\n       formatMoney(SUM(extprice)) AS f_sumextprice,\n       formatMoney(SUM(baseextprice)) AS f_sumbaseextprice,\n       formatMoney(SUM(cohist_commission)) AS f_sumcommission,\n       formatMoney(SUM(basecommission)) AS f_sumbasecommission,\n<? endif ?>\n       <? value("return") ?> AS cohist_invcdate_xtnullrole,\n       'curr' AS sumextprice_xtnumericrole,\n       'curr' AS sumcommission_xtnumericrole,\n       'curr' AS sumbaseextprice_xtnumericrole,\n       'curr' AS sumbasecommission_xtnumericrole,\n       0 AS sumbaseextprice_xttotalrole,\n       0 AS sumbasecommission_xttotalrole\n<? if exists("includeMisc") ?>\nFROM saleshistorymisc\n<? else ?>\nFROM saleshistory\n<? endif ?>\nWHERE ((cohist_commission <> 0)\n    AND(cohist_invcdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? if exists("salesrep_id") ?>\n    AND (cohist_salesrep_id=<? value("salesrep_id") ?>)\n    <? endif ?>\n      )\nGROUP BY cohist_salesrep_id, salesrep_number, salesrep_name, cust_number, cust_name,\n         cohist_ordernumber, cohist_orderdate, cohist_invcnumber, cohist_invcdate, currAbbr\nORDER BY salesrep_number, cust_number, cohist_invcdate;\n   admin   2014-10-06      0
101087
 
235     briefSalesHistory       detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: briefSalesHistory\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohead_id, cust_id, cohist_ponumber,\n       custtype_id, custtype_code,\n       cohist_cust_id, cohist_ordernumber,\n       cust_number, cust_name, currAbbr,\n       cohist_orderdate, cohist_invcdate,\n       CASE WHEN (COALESCE(cohist_invcnumber, '-1') IN ('', '-1')) THEN  <? value("credit") ?>\n            ELSE cohist_invcnumber\n       END AS invoicenumber,\n       SUM(extprice) AS extprice,\n       SUM(baseextprice) AS baseextprice,\n       SUM(extcost) AS extcost,\n       SUM(margin) AS margin,\n       CASE WHEN (SUM(baseextprice) > 0.0) THEN\n            ROUND(SUM(margin) / SUM(baseextprice), 4)\n            ELSE 0.0\n       END AS marginpercent,\n<? if exists("isReport") ?>\n       formatDate(cohist_orderdate) AS f_orderdate,\n       formatDate(cohist_invcdate) AS f_invcdate,\n       formatMoney(SUM(extprice)) AS f_extprice,\n       formatMoney(SUM(baseextprice)) AS f_baseextprice,\n       formatMoney(SUM(extcost)) AS f_extcost,\n       formatMoney(SUM(margin)) AS f_margin,\n<? endif ?>\n       <? value("return") ?> AS cohist_invcdate_xtnullrole,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS baseextprice_xtnumericrole,\n       'curr' AS extcost_xtnumericrole,\n       'curr' AS margin_xtnumericrole,\n       'percent' AS marginpercent_xtnumericrole,\n       0 AS baseextprice_xttotalrole,\n       0 AS extcost_xttotalrole,\n       0 AS margin_xttotalrole\n<? if exists("includeMisc") ?>\n  FROM saleshistorymisc\n<? else ?>\n  FROM saleshistory\n<? endif ?>\nWHERE ( (true)\n<? if exists("startDate") ?>\n  AND  (cohist_invcdate >= <? value("startDate") ?>)\n<? endif ?>\n<? if exists("endDate") ?>\n  AND  (cohist_invcdate <= <? value("endDate") ?>)\n<? endif ?>\n<? if exists("shipStartDate") ?>\n  AND  (cohist_shipdate >= <? value("shipStartDate") ?>)\n<? endif ?>\n<? if exists("shipEndDate") ?>\n  AND  (cohist_shipdate <= <? value("shipEndDate") ?>)\n<? endif ?>\n<? if exists("cust_id") ?>\n   AND (cohist_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("shipto_id") ?>\n   AND (cohist_shipto_id=<? value("shipto_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n   AND (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n   AND (custtype_code ~ <? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrpitem\n                   WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n<? endif ?>\n<? if exists("custgrp_pattern") ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrp, custgrpitem\n                   WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                     AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND  (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("prodcat_id") ?>\n   AND (prodcat_id=<? value("prodcat_id") ?>)\n<? endif ?>\n<? if exists("prodcat_pattern") ?>\n   AND (prodcat_id IN (SELECT prodcat_id\n                       FROM prodcat\n                       WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? endif ?>\n<? if exists("salesrep_id") ?>\n   AND (cohist_salesrep_id=<? value("salesrep_id") ?>)\n<? endif ?>\n<? if exists("shipzone_id") ?>\n  AND (cohist_shipzone_id=<? value("shipzone_id") ?>)\n<? endif ?>\n<? if exists("saletype_id") ?>\n  AND (cohist_saletype_id=<? value("saletype_id") ?>)\n<? endif ?>\n      )\nGROUP BY cohead_id, cust_id, cust_number, custtype_id,\n         cohist_cust_id, custtype_code, currAbbr,\n         cust_name, cohist_ordernumber, cohist_ponumber,\n         cohist_invcnumber, cohist_orderdate, cohist_invcdate\nORDER BY cohist_invcdate, cohist_orderdate;\n admin   2014-10-06      0
101088
 
244     detailedInventoryHistory        detail   used by dspDetailedInventoryHistoryByLocation, dspDetailedInventoryHistoryByLotSerial\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: detailedInventoryHistory\n-- Name: detail\n-- Notes: used by dspDetailedInventoryHistoryByLocation, dspDetailedInventoryHistoryByLotSerial\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n<? if exists("byLocation") ?>\n       invhist_id, invhist_transdate, invhist_transtype,\n       (invhist_ordtype || '-' || invhist_ordnumber) AS ordernumber,\n       invhist_invuom,\n       item_number, formatlotserialnumber(invdetail_ls_id) AS lotserial,\n       CASE WHEN invhist_posted THEN invdetail_qty\n       END AS transqty,\n       CASE WHEN invhist_posted THEN invdetail_qty_before\n       END AS qohbefore,\n       CASE WHEN invhist_posted THEN invdetail_qty_after\n       END AS qohafter,\n       invhist_posted,\n       'qty' AS transqty_xtnumericrole,\n       'qty' AS qohbefore_xtnumericrole,\n       'qty' AS qohafter_xtnumericrole,\n       CASE WHEN NOT invhist_posted THEN 'warning'\n       END AS qtforegroundrole\n<? else ?>\n       *\n<? endif ?>\nFROM <? if exists("byLocation") ?>\n       invdetail, invhist, itemsite, item\n     <? else ?>\n       lshist (<? value("itemid") ?>,<? value("warehouseid") ?>,<? value("lotSerial") ?>,\n               <? value("pattern") ?>,<? value("transType") ?>,<? value("startDate") ?>,\n               <? value("endDate") ?>,<? value("trace") ?>,1)\n     <? endif ?>\nWHERE (\n<? if exists("byLocation") ?>\n        (invdetail_invhist_id=invhist_id)\n    AND (invhist_itemsite_id=itemsite_id)\n    AND (itemsite_item_id=item_id)\n    AND (invdetail_location_id=<? value("location_id") ?>)\n    AND (DATE(invhist_transdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    AND (transType(invhist_transtype, <? value("transType") ?>))\n<? else ?>\n        (TRUE)\n<? endif ?>\n      )\n<? if exists("byLocation") ?>\nORDER BY invhist_transdate DESC, invhist_transtype\n<? endif ?>\n;\n    admin   2014-10-06      0
101089
 
44      capacityUOMs    detail   used by dspCapacityUOMsByClassCode, dspCapacityUOMsByProductCategory\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: capacityUOMs\n-- Name: detail\n-- Notes: used by dspCapacityUOMsByClassCode, dspCapacityUOMsByProductCategory\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT item_id, item_number,\n<? if exists("getclasscode") ?>\n       classcode_code,\n<? endif ?>\n       (item_descrip1 || ' ' || item_descrip2) AS descrip,\n       uom_name,\n       itemcapuom(item_id)       AS capuom,\n       itemcapinvrat(item_id)    AS capinvrat,\n       itemaltcapuom(item_id)    AS altcapuom,\n       itemaltcapinvrat(item_id) AS altcapinvrat,\n       'uomratio' AS capinvrat_xtnumericrole,\n       'uomratio' AS altcapinvrat_xtnumericrole\nFROM item\n     JOIN uom ON (item_inv_uom_id=uom_id)\n<? if exists("getclasscode") ?>\n     LEFT OUTER JOIN classcode ON (item_classcode_id=classcode_id)\n<? endif ?>\nWHERE (\n<? if exists("getclasscode") ?> true <? else ?> item_sold <? endif ?>\n<? if exists("prodcat_id") ?>\n   AND (item_prodcat_id=<? value("prodcat_id") ?>)\n<? elseif exists("prodcat_pattern") ?>\n   AND (item_prodcat_id IN (SELECT prodcat_id\n                            FROM prodcat\n                            WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? elseif exists("classcode_id") ?>\n   AND (classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n   AND (classcode_code ~ <? value("classcode_pattern") ?>)\n<? endif ?>\n)\nORDER BY <? if exists("getclasscode") ?> classcode_code, <? endif ?>\n         item_number;\n      admin   2014-10-06      0
101090
 
45      cashReceipts    detail   used by dspCashReceipts\n There are 2 display modes for this query:\n 1) Legacy mode which uses A/R Application information\n 2) Version 3.3.0 upgrade mode which uses Cash Receipt information\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: cashReceipts\n-- Name: detail\n-- Notes: used by dspCashReceipts\n-- There are 2 display modes for this query:\n-- 1) Legacy mode which uses A/R Application information\n-- 2) Version 3.3.0 upgrade mode which uses Cash Receipt information\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("LegacyDisplayMode") ?>\n\n-- Posted cash receipts\nSELECT arapply_id, 1 AS type, '' AS cashrcpt_number, cust_number, cust_name,\n       false AS voided, true AS posted, arapply_postdate AS postdate,\n       ( CASE WHEN (arapply_source_doctype='C') THEN <? value("creditMemo") ?>\n              WHEN (arapply_source_doctype='R') THEN <? value("cashdeposit") ?>\n              WHEN (arapply_fundstype='C') THEN <? value("check") ?>\n              WHEN (arapply_fundstype='T') THEN <? value("certifiedCheck") ?>\n              WHEN (arapply_fundstype='M') THEN <? value("masterCard") ?>\n              WHEN (arapply_fundstype='V') THEN <? value("visa") ?>\n              WHEN (arapply_fundstype='A') THEN <? value("americanExpress") ?>\n              WHEN (arapply_fundstype='D') THEN <? value("discoverCard") ?>\n              WHEN (arapply_fundstype='R') THEN <? value("otherCreditCard") ?>\n              WHEN (arapply_fundstype='K') THEN <? value("cash") ?>\n              WHEN (arapply_fundstype='W') THEN <? value("wireTransfer") ?>\n              WHEN (arapply_fundstype='O') THEN <? value("other") ?>\n         END || ' ' ||\n         CASE WHEN (arapply_source_doctype IN ('C','R')) THEN TEXT(arapply_source_docnumber)\n              ELSE arapply_refnumber\n         END ) AS source,\n       COALESCE(cashrcptitem_cashrcpt_id,cashrcptmisc_cashrcpt_id,-1) AS source_xtidrole,\n       ( CASE WHEN (arapply_target_doctype='D') THEN <? value("debitMemo") ?>\n              WHEN (arapply_target_doctype='I') THEN <? value("invoice") ?>\n              ELSE <? value("other") ?>\n         END || ' ' || TEXT(arapply_target_docnumber) ) AS target,\n       COALESCE(arapply_target_aropen_id,-1) AS target_xtidrole,\n       arapply_applied AS applied,\n       'curr' AS applied_xtnumericrole,\n       currtobase(arapply_curr_id,arapply_applied,arapply_postdate) AS base_applied,\n<? if exists("includeFormatted") ?>\n       formatDate(arapply_postdate) AS f_postdate,\n       formatMoney(arapply_applied) AS f_applied,\n       formatMoney(currtobase(arapply_curr_id,arapply_applied,arapply_postdate)) AS f_base_applied,\n<? endif ?>\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole,\n       currConcat(arapply_curr_id) AS currAbbr,\n       arapply_postdate AS sortdate\nFROM custinfo LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id), arapply\n  LEFT OUTER JOIN cashrcptitem ON ((arapply_reftype='CRA')\n                               AND (arapply_ref_id=cashrcptitem_id))\n  LEFT OUTER JOIN cashrcptmisc ON ((arapply_reftype='CRD')\n                               AND (arapply_ref_id=cashrcptmisc_id))\nWHERE ( (arapply_cust_id=cust_id)\n  AND   (arapply_postdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n  AND   (arapply_source_doctype ='K')\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n      )\n\n-- Unposted cash receipts\nUNION\nSELECT cashrcpt_id, 2 AS type, '' AS cashrcpt_number, cust_number, cust_name,\n       false AS voided, false AS posted, cashrcpt_distdate AS postdate,\n       ( CASE WHEN (cashrcpt_fundstype='C') THEN <? value("check") ?>\n              WHEN (cashrcpt_fundstype='T') THEN <? value("certifiedCheck") ?>\n              WHEN (cashrcpt_fundstype='M') THEN <? value("masterCard") ?>\n              WHEN (cashrcpt_fundstype='V') THEN <? value("visa") ?>\n              WHEN (cashrcpt_fundstype='A') THEN <? value("americanExpress") ?>\n              WHEN (cashrcpt_fundstype='D') THEN <? value("discoverCard") ?>\n              WHEN (cashrcpt_fundstype='R') THEN <? value("otherCreditCard") ?>\n              WHEN (cashrcpt_fundstype='K') THEN <? value("cash") ?>\n              WHEN (cashrcpt_fundstype='W') THEN <? value("wireTransfer") ?>\n              WHEN (cashrcpt_fundstype='O') THEN <? value("other") ?>\n         END || ' ' || cashrcpt_docnumber ) AS source,\n      cashrcpt_id AS source_xtidrole,\n       <? value("unposted") ?> AS target,\n       -1 AS target_xtidrole,\n       cashrcpt_amount AS applied,\n       'curr' AS applied_xtnumericrole,\n       (cashrcpt_amount / cashrcpt_curr_rate) AS base_applied,\n<? if exists("includeFormatted") ?>\n       formatDate(cashrcpt_distdate) AS f_postdate,\n       formatMoney(cashrcpt_amount) AS f_applied,\n       formatMoney(cashrcpt_amount / cashrcpt_curr_rate) AS f_base_applied,\n<? endif ?>\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole,\n       currConcat(cashrcpt_curr_id) AS currAbbr,\n       cashrcpt_distdate AS sortdate\nFROM cashrcpt, custinfo LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (NOT cashrcpt_posted)\n  AND   (cashrcpt_cust_id=cust_id)\n  AND   (cashrcpt_distdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n      )\n\n-- Cash Advance\nUNION\nSELECT aropen_id, 3 AS type, '' AS cashrcpt_number, cust_number, cust_name,\n       false AS voided, true AS posted, aropen_docdate AS postdate,\n       ( CASE WHEN (substr(aropen_notes, 16, 1)='C') THEN <? value("check") ?>\n              WHEN (substr(aropen_notes, 16, 1)='T') THEN <? value("certifiedCheck") ?>\n              WHEN (substr(aropen_notes, 16, 1)='M') THEN <? value("masterCard") ?>\n              WHEN (substr(aropen_notes, 16, 1)='V') THEN <? value("visa") ?>\n              WHEN (substr(aropen_notes, 16, 1)='A') THEN <? value("americanExpress") ?>\n              WHEN (substr(aropen_notes, 16, 1)='D') THEN <? value("discoverCard") ?>\n              WHEN (substr(aropen_notes, 16, 1)='R') THEN <? value("otherCreditCard") ?>\n              WHEN (substr(aropen_notes, 16, 1)='K') THEN <? value("cash") ?>\n              WHEN (substr(aropen_notes, 16, 1)='W') THEN <? value("wireTransfer") ?>\n              WHEN (substr(aropen_notes, 16, 1)='O') THEN <? value("other") ?>\n         END || ' ' ||\n         substr(aropen_notes, 18) ) AS source,\n       cashrcptitem_cashrcpt_id AS source_xtidrole,\n       CASE WHEN aropen_doctype = 'R' THEN\n         <? value("cashdeposit") ?> \n       ELSE <? value("creditMemo") ?> \n       END AS target,\n       aropen_id AS target_xtidrole,\n       aropen_amount AS applied,\n       'curr' AS applied_xtnumericrole,\n       aropen_amount / aropen_curr_rate AS base_applied,\n<? if exists("includeFormatted") ?>\n       formatDate(aropen_docdate) AS f_postdate,\n       formatMoney(aropen_amount) AS f_applied,\n       formatMoney(aropen_amount / aropen_curr_rate) AS f_base_applied,\n<? endif ?>\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole,\n       currConcat(aropen_curr_id) AS currAbbr,\n       aropen_duedate AS sortdate\nFROM custinfo LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id), aropen\n  JOIN cashrcptitem ON (aropen_id=cashrcptitem_aropen_id)\nWHERE ( (aropen_cust_id=cust_id)\n  AND   (aropen_doctype IN ('R','C'))\n  AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n      )\nORDER BY sortdate, source;\n\n<? else ?>\n\n--  New Display Mode\n\nSELECT id, type, cashrcpt_number, cust_number, cust_name,\n       postdate, posted, voided,\n       source, source_xtidrole,\n       posted,\n       target, target_xtidrole,\n       applied,\n       base_applied,\n<? if exists("includeFormatted") ?>\n       formatDate(postdate) AS f_postdate,\n       formatMoney(applied) AS f_applied,\n       formatMoney(base_applied) AS f_base_applied,\n<? endif ?>\n       currAbbr,\n       sortdate,\n       'curr' AS applied_xtnumericrole,\n       'curr' AS base_applied_xtnumericrole,\n       base_applied_xttotalrole,\n       type AS xtindentrole\nFROM (\n\n--  Cash Receipt headers\nSELECT cashrcpt_id AS id, 0 AS type, cashrcpt_number, cust_number, cust_name,\n       cashrcpt_distdate AS postdate, cashrcpt_posted AS posted, cashrcpt_void AS voided,\n       ( CASE WHEN (cashrcpt_fundstype='C') THEN <? value("check") ?>\n              WHEN (cashrcpt_fundstype='T') THEN <? value("certifiedCheck") ?>\n              WHEN (cashrcpt_fundstype='M') THEN <? value("masterCard") ?>\n              WHEN (cashrcpt_fundstype='V') THEN <? value("visa") ?>\n              WHEN (cashrcpt_fundstype='A') THEN <? value("americanExpress") ?>\n              WHEN (cashrcpt_fundstype='D') THEN <? value("discoverCard") ?>\n              WHEN (cashrcpt_fundstype='R') THEN <? value("otherCreditCard") ?>\n              WHEN (cashrcpt_fundstype='K') THEN <? value("cash") ?>\n              WHEN (cashrcpt_fundstype='W') THEN <? value("wireTransfer") ?>\n              WHEN (cashrcpt_fundstype='O') THEN <? value("other") ?>\n         END || ' ' || cashrcpt_docnumber ) AS source,\n       cashrcpt_id AS source_xtidrole,\n       CASE WHEN (cashrcpt_void) THEN <? value("voided") ?>\n            WHEN (NOT cashrcpt_posted) THEN <? value("unposted") ?>\n            ELSE                           ''\n       END AS target,\n       -1 AS target_xtidrole,\n       cashrcpt_amount AS applied,\n       (cashrcpt_amount / cashrcpt_curr_rate) AS base_applied,\n       currConcat(cashrcpt_curr_id) AS currAbbr,\n       cashrcpt_distdate AS sortdate,\n       0 AS base_applied_xttotalrole,\n       -1 AS arapply_id\nFROM cashrcpt JOIN custinfo ON (cust_id=cashrcpt_cust_id) LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (cashrcpt_distdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("fundstype") ?>\n  AND   (cashrcpt_fundstype=<? value("fundstype") ?>)\n<? endif ?>\n      )\n\n--  Cash Receipt items\nUNION\nSELECT cashrcpt_id AS id, 1 AS type, '', '', '',\n       cashrcpt_distdate AS postdate, cashrcpt_posted AS posted, cashrcpt_void AS voided,\n       '' AS source,\n       cashrcpt_id AS source_xtidrole,\n       ( CASE WHEN (aropen_doctype='D') THEN <? value("debitMemo") ?>\n              WHEN (aropen_doctype='I') THEN <? value("invoice") ?>\n              WHEN (aropen_doctype='C') THEN <? value("creditMemo") ?>\n              WHEN (aropen_doctype='R') THEN <? value("cashdeposit") ?>\n              ELSE <? value("other") ?>\n         END || ' ' || TEXT(aropen_docnumber) ) AS target,\n       aropen_id AS target_xtidrole,\n       COALESCE(arapply_applied, cashrcptitem_amount) AS applied,\n       (COALESCE(arapply_applied,cashrcptitem_amount) / cashrcpt_curr_rate) AS base_applied,\n       currConcat(cashrcpt_curr_id) AS currAbbr,\n       cashrcpt_distdate AS sortdate,\n       -1 AS base_applied_xttotalrole,\n       arapply_id\nFROM cashrcpt JOIN custinfo ON (cust_id=cashrcpt_cust_id)\n              LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n              JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id)\n              JOIN aropen ON (aropen_id=cashrcptitem_aropen_id)\n              LEFT OUTER JOIN arapply ON ((arapply_target_aropen_id=aropen_id OR\n                                          arapply_source_aropen_id=aropen_id) AND\n                                          arapply_reftype='CRA' AND\n                                          arapply_ref_id=cashrcptitem_id)\nWHERE ( (cashrcpt_distdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("fundstype") ?>\n  AND   (cashrcpt_fundstype=<? value("fundstype") ?>)\n<? endif ?>\n      )\n\n--  Cash Receipt misc\nUNION\nSELECT cashrcpt_id AS id, 1 AS type, '', '', '',\n       cashrcpt_distdate AS postdate, cashrcpt_posted AS posted, cashrcpt_void AS voided,\n       '' AS source,\n       cashrcpt_id AS source_xtidrole,\n       formatGLAccount(cashrcptmisc_accnt_id) AS target,\n       -1 AS target_xtidrole,\n       COALESCE(arapply_applied, cashrcptmisc_amount) AS applied,\n       (COALESCE(arapply_applied, cashrcptmisc_amount) / cashrcpt_curr_rate) AS base_applied,\n       currConcat(cashrcpt_curr_id) AS currAbbr,\n       cashrcpt_distdate AS sortdate,\n       -1 AS base_applied_xttotalrole,\n       arapply_id\nFROM cashrcpt JOIN custinfo ON (cust_id=cashrcpt_cust_id)\n              LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n              JOIN cashrcptmisc ON (cashrcptmisc_cashrcpt_id=cashrcpt_id)\n              LEFT OUTER JOIN arapply ON (arapply_reftype='CRD' AND\n                                          arapply_ref_id=cashrcptmisc_id)\nWHERE ( (cashrcpt_distdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("fundstype") ?>\n  AND   (cashrcpt_fundstype=<? value("fundstype") ?>)\n<? endif ?>\n      )\n  ) AS data\nORDER BY sortdate, id, type, target;\n\n<? endif ?>\n\n   admin   2014-10-06      0
101091
 
96      ccpayments      list     list credit card payments, optionally by customer\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: ccpayments\n-- Name:  list\n-- Notes: list credit card payments, optionally by customer\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ccpay_id AS id, \n       CASE WHEN ((ccpay_status = 'A') AND \n                 (date_part('day', CURRENT_TIMESTAMP - ccpay_transaction_datetime) < COALESCE(<? value("ccValidDays") ?>,0))) THEN\n         1\n       ELSE 0\n       END AS altid, cohead_id,\n       ccpay.*,\n       cust_number, cust_name,       \n       ccpay_type AS type,       \n       CASE WHEN (ccpay_type='A') THEN <? value("preauth") ?>\n            WHEN (ccpay_type='C') THEN <? value("charge") ?>\n            WHEN (ccpay_type='R') THEN <? value("refund") ?>\n            ELSE ccpay_type\n       END AS type_qtdisplayrole,\n       ccpay_status AS status,\n       CASE WHEN (ccpay_status='A') THEN <? value("authorized") ?>\n            WHEN (ccpay_status='C') THEN <? value("approved") ?>\n            WHEN (ccpay_status='D') THEN <? value("declined") ?>\n            WHEN (ccpay_status='V') THEN <? value("voided") ?>\n            WHEN (ccpay_status='X') THEN <? value("noapproval") ?>\n            ELSE ccpay_status\n       END AS status_qtdisplayrole,\n       currConcat(ccpay_curr_id) AS currAbbr,\n       COALESCE(cohead_number, ccpay_order_number) AS docnumber,\n       ABS(COALESCE(payco_amount, ccpay_amount)) AS allocated,\n       currConcat(COALESCE(payco_curr_id, ccpay_curr_id)) AS payco_currAbbr,\n       cust_number, cust_name,\n       'curr' AS ccpay_amount_xtnumericrole,\n       'curr' AS allocated_xtnumericrole,\n        CASE WHEN ((ccpay_status = 'A')\n              AND (date_part('day', CURRENT_TIMESTAMP - ccpay_transaction_datetime) >= COALESCE(<? value("ccValidDays") ?>,0))) THEN\n          'error'\n        END AS qtforegroundrole\n  FROM ccpay LEFT OUTER JOIN \n       (payco JOIN cohead ON (payco_cohead_id=cohead_id))\n         ON (payco_ccpay_id=ccpay_id)\n      JOIN custinfo ON (ccpay_cust_id=cust_id)\n      JOIN custtype ON (cust_custtype_id=custtype_id)\n      LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n  WHERE ((true)\n<? if exists("processed") ?>\n  AND (ccpay_status != 'A')\n<? elseif exists("authorizations") ?>\n  AND (ccpay_status = 'A')\n<? endif ?>\n<? if exists("validOnly") ?>\n  AND ((ccpay_status != 'A')\n  OR (date_part('day', CURRENT_TIMESTAMP - ccpay_transaction_datetime) < <? value("ccValidDays") ?>))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND   (ccpay_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>)\n ORDER BY ccpay_transaction_datetime;\n        admin   2014-10-06      0
101092
 
456     charass populate         Populate characteristic assignments combobox\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: charass\n-- Name:  populate\n-- Notes: Populate characteristic assignments combobox\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("name") ?>\nSELECT -1 AS charass_char_id, '' AS char_name\nUNION\nSELECT DISTINCT charass_char_id, char_name\n<? else ?>\nSELECT -1 AS charass_id, '' AS charass_value\nUNION\nSELECT DISTINCT charass_id, charass_value\n<? endif ?>\nFROM charass, char\nWHERE ((charass_char_id=char_id)\n  AND (charass_target_type=<? value("type") ?>)\n  AND (charass_target_id= <? value("id") ?>))\n<? if exists("char") ?>\n  AND (charass_char_id= <? value("char") ?>)\n  AND (COALESCE(charass_value,'')!='')\n<? endif ?>\n<? if exists("name") ?>\nORDER BY char_name;\n<? else ?>\nORDER BY charass_value;\n<? endif ?>\n        admin   2014-10-06      0
101093
 
46      checkRegister   detail   used by dspCheckRegister and viewCheckRun;\n        shows all the checks for a given date range, bank account, \n        check number(optional), and recipient(optional), optionally restricted\n        to 'new' (un-posted/replaced/deleted) checks for viewing check runs.\n        fills in the check item detail if showDetail is passed.\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: checkRegister\n-- Name: detail\n-- Notes: used by dspCheckRegister and viewCheckRun;\n--        shows all the checks for a given date range, bank account, \n--        check number(optional), and recipient(optional), optionally restricted\n--        to 'new' (un-posted/replaced/deleted) checks for viewing check runs.\n--        fills in the check item detail if showDetail is passed.\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT checkhead_id AS checkid,\n       CASE WHEN(checkhead_void) THEN -1\n            WHEN(checkhead_posted) THEN 1\n            ELSE 0\n       END AS extra,\n       -1 AS checkitem_id,\n       checkhead_void, checkhead_misc,\n       checkhead_printed, checkhead_posted,\n       CASE when checkhead_number = -1 THEN\n         'Unspecified'\n       ELSE TEXT(checkhead_number) END AS number,\n       COALESCE((SELECT checkrecip_number || '-' || checkrecip_name\n                 FROM checkrecip\n                 WHERE ((checkhead_recip_id=checkrecip_id)\n\t\t   AND  (checkhead_recip_type=checkrecip_type)))\n                ,\n\t\tcheckhead_recip_type || '-' || checkhead_recip_id ) AS description,\n       checkhead_checkdate AS checkdate,\n       checkhead_amount AS amount, \n       checkhead_amount / checkhead_curr_rate AS base_amount, \n       currConcat(checkhead_curr_id) AS currAbbr,\n       checkhead_number,\n       checkhead_ach_batch,\n       1 AS orderby,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       NULL AS checkhead_void_qtdisplayrole,    NULL AS checkhead_misc_qtdisplayrole,\n       NULL AS checkhead_printed_qtdisplayrole, NULL AS checkhead_posted_qtdisplayrole,\n       0 AS xtindentrole\n  FROM checkhead\n WHERE ((checkhead_bankaccnt_id=<? value("bankaccnt_id") ?>)\n   <? if exists("startDate") ?>\n     AND (checkhead_checkdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n   <? elseif exists("newOnly") ?>\n     AND (NOT checkhead_posted)\n     AND (NOT checkhead_replaced)\n     AND (NOT checkhead_deleted)\n   <? endif ?>\n   <? if exists("check_number") ?>\n      AND   (CAST(checkhead_number AS text) ~ <? value("check_number") ?>)\n   <? endif ?>\n   <? if exists("recip") ?>\n      <? if exists("recip_type_v") ?>\n         AND   (checkhead_recip_type = 'V' )\n      <? endif ?>\n      <? if exists("recip_type_c") ?>\n         AND   (checkhead_recip_type = 'C' )\n      <? endif ?>\n      <? if exists("recip_type_t") ?>\n         AND   (checkhead_recip_type = 'T' )\n      <? endif ?>\n      <? if exists("recip_id") ?>\n         AND   (checkhead_recip_id = <? value("recip_id") ?> )\n      <? endif ?>\n   <? endif ?>\n   <? if exists("vend_id") ?>\n     AND (checkhead_recip_type = 'V')\n     AND (checkhead_recip_id = <? value("vend_id") ?>)\n   <? elseif exists("vendtype_id") ?>\n     AND (checkhead_recip_type = 'V')\n     AND (checkhead_recip_id IN (SELECT vend_id\n                                 FROM vendinfo\n                                 WHERE (vend_vendtype_id=<? value("vendtype_id") ?>)))\n   <? elseif exists("vendtype_pattern") ?>\n     AND (checkhead_recip_type = 'V')\n     AND (checkhead_recip_id IN (SELECT vend_id\n                                 FROM vendinfo, vendtype\n                                 WHERE  (vend_vendtype_id=vendtype_id)\n                                   AND  (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n   <? endif ?>\n)\n<? if exists("showDetail") ?>\nUNION\nSELECT checkitem_checkhead_id AS checkid, 0 AS extra, checkitem_id,\n       checkhead_void, checkhead_misc,\n       checkhead_printed, checkhead_posted,\n       (CASE apopen_doctype WHEN 'V' THEN <? value("voucher") ?>\n                            WHEN 'D' THEN <? value("debitMemo") ?>\n                            WHEN 'C' THEN <? value("creditMemo") ?>\n                            ELSE ''\n        END || '-' || CAST(COALESCE(checkitem_ranumber, checkitem_vouchernumber) AS TEXT)) AS number,\n       CAST(COALESCE(checkitem_invcnumber, checkitem_cmnumber) AS TEXT) AS description,\n       CAST(NULL AS DATE) AS checkdate,\n       checkitem_amount AS amount,\n       currtobase(checkhead_curr_id,checkitem_amount,checkhead_checkdate) AS base_amount, \n       currConcat(checkitem_curr_id) AS currAbbr, \n       checkhead_number, \n       NULL AS checkhead_ach_batch,\n       2 AS orderby,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       '' AS checkhead_void_qtdisplayrole,    '' AS checkhead_misc_qtdisplayrole,\n       '' AS checkhead_printed_qtdisplayrole, '' AS checkhead_posted_qtdisplayrole,\n       1 AS xtindentrole\n  FROM checkhead JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)\n                 LEFT OUTER JOIN apopen ON (apopen_id=checkitem_apopen_id)\n WHERE ((checkhead_bankaccnt_id=<? value("bankaccnt_id") ?>)\n   <? if exists("startDate") ?>\n     AND   (checkhead_checkdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n   <? elseif exists("newOnly") ?>\n     AND (NOT checkhead_posted)\n     AND (NOT checkhead_replaced)\n     AND (NOT checkhead_deleted)\n   <? endif ?>\n   <? if exists("check_number") ?>\n      AND   (CAST(checkhead_number AS text) ~ <? value("check_number") ?>)\n   <? endif ?>\n   <? if exists("recip") ?>\n      <? if exists("recip_type_v") ?>\n         AND   (checkhead_recip_type = 'V' )\n      <? endif ?>\n      <? if exists("recip_type_c") ?>\n         AND   (checkhead_recip_type = 'C' )\n      <? endif ?>\n      <? if exists("recip_type_t") ?>\n         AND   (checkhead_recip_type = 'T' )\n      <? endif ?>\n      <? if exists("recip_id") ?>\n         AND   (checkhead_recip_id = <? value("recip_id") ?> )\n      <? endif ?>\n   <? endif ?>\n   <? if exists("vend_id") ?>\n     AND (checkhead_recip_type = 'V')\n     AND (checkhead_recip_id = <? value("vend_id") ?>)\n   <? elseif exists("vendtype_id") ?>\n     AND (checkhead_recip_type = 'V')\n     AND (checkhead_recip_id IN (SELECT vend_id\n                                 FROM vendinfo\n                                 WHERE (vend_vendtype_id=<? value("vendtype_id") ?>)))\n   <? elseif exists("vendtype_pattern") ?>\n     AND (checkhead_recip_type = 'V')\n     AND (checkhead_recip_id IN (SELECT vend_id\n                                 FROM vendinfo, vendtype\n                                 WHERE  (vend_vendtype_id=vendtype_id)\n                                   AND  (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n   <? endif ?>\n   )\n<? endif ?>\n ORDER BY checkhead_number, checkid, orderby;\n      admin   2014-10-06      0
101094
 
97      checks  detail   used by printChecks\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: checks\n-- Name: detail\n-- Notes: used by printChecks\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT checkhead.*, form_report_name AS report_name\nFROM checkhead\nLEFT OUTER JOIN vendinfo ON((checkhead_recip_id = vend_id)\n                        AND (checkhead_recip_type = 'V'))\nLEFT OUTER JOIN custinfo ON((checkhead_recip_id = cust_id)\n                        AND (checkhead_recip_type = 'C'))\nLEFT OUTER JOIN taxauth ON((checkhead_recip_id = taxauth_id)\n                       AND (checkhead_recip_type = 'T')),\n     bankaccnt, form\nWHERE ( (checkhead_bankaccnt_id=bankaccnt_id)\n  AND   (bankaccnt_check_form_id=form_id)\n<? if exists("toPrintOnly") ?>\n  AND   (NOT checkhead_printed)\n  AND   (NOT checkhead_void)\n<? endif ?>\n<? if exists("bankaccnt_id") ?>\n  AND   (bankaccnt_id=<? value("bankaccnt_id" ?>)\n<? endif ?>\n      )\n<? if exists("orderByName") ?>\nORDER BY checkhead_recip_type DESC, COALESCE(vend_name, cust_name, taxauth_name)\n<? else ?>\nORDER BY checkhead_recip_type DESC, COALESCE(vend_number, cust_number, taxauth_code)\n<? endif ?>\n<? if exists("numtoprint") ?>\nLIMIT <? value("numtoprint") ?>\n<? endif ?>\n;\n        admin   2014-10-06      0
101095
 
361     glseries        checkeditable    \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: glseries\n-- Name:  checkeditable\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_id \nFROM accnt, gltrans \n  LEFT OUTER JOIN period ON (gltrans_date BETWEEN period_start AND period_end) \nWHERE ( (gltrans_accnt_id=accnt_id) \n  AND (gltrans_sequence=<? value("glSequence") ?>) \n  AND ( (gltrans_deleted) \n     OR (period_closed) \n     OR (gltrans_rec) \n     OR (period_freeze AND NOT checkPrivilege('PostFrozenPeriod')) ) )\nLIMIT 1;\n      admin   2014-10-06      0
101096
 
450     contact muststayactive   This query determines whether a given contact should be kept\n        active because other active records depend on it.\n        Todo - should this be moved to the cntctAfterTrigger?\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: contact\n-- Name:  muststayactive\n-- Notes: This query determines whether a given contact should be kept\n--        active because other active records depend on it.\n--        Todo - should this be moved to the cntctAfterTrigger?\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT EXISTS(\n SELECT 1\n   FROM crmacct\n  WHERE(crmacct_active\n    AND (<? value("id") ?> IN (crmacct_cntct_id_1, crmacct_cntct_id_2)))\n UNION SELECT 3\n   FROM custinfo\n  WHERE (cust_active\n    AND (<? value("id") ?> IN (cust_cntct_id, cust_corrcntct_id)))\n UNION SELECT 5\n   FROM vendinfo\n  WHERE (vend_active\n    AND (<? value("id") ?> IN (vend_cntct1_id, vend_cntct2_id)))\n UNION SELECT 7\n   FROM prospect\n  WHERE (prospect_active AND (prospect_cntct_id=<? value("id") ?>))\n UNION SELECT 8\n   FROM shiptoinfo\n  WHERE (shipto_active AND (shipto_cntct_id=<? value("id") ?>))\n UNION SELECT 9\n   FROM vendaddrinfo\n   JOIN vendinfo ON (vendaddr_vend_id=vend_id)\n  WHERE (vend_active AND (vendaddr_cntct_id=<? value("id") ?>))\n UNION SELECT 10\n   FROM whsinfo\n  WHERE (warehous_active AND (warehous_cntct_id=<? value("id") ?>))\n UNION SELECT 11\n   FROM emp\n  WHERE (emp_active AND (emp_cntct_id=<? value("id") ?>))\n UNION SELECT 21\n   FROM todoitem\n  WHERE (todoitem_completed_date IS NOT NULL\n    AND (todoitem_cntct_id=<? value("id") ?>))\n) AS inuse;\n     admin   2014-10-06      0
101097
 
438     contact uses     Find and report uses of the contact\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: contact\n-- Name:  uses\n-- Notes: Find and report uses of the contact\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if not exists('core') ?>\nSELECT <? value("id") ?>::text || '.' || type_id::text || '.' || type_code::text,\n       <? value("id") ?> AS contact,\n       *\nFROM (\n<? endif ?>\n  SELECT crmacct_id AS type_id, 1 AS type_code, <? value("crmacct") ?> AS type,\n         crmacct_number AS number,\n         crmacct_name AS name, <? value("primary") ?> AS role,\n         (crmacct_active) AS active,\n         crmacct_owner_username AS owner\n    FROM crmacct WHERE (crmacct_cntct_id_1=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT crmacct_id AS type_id, 2 AS type_code, <? value("crmacct") ?> AS type,\n         crmacct_number AS number,\n         crmacct_name AS name, <? value("secondary") ?> AS role,\n         (crmacct_active) AS active,\n         crmacct_owner_username AS owner\n    FROM crmacct WHERE (crmacct_cntct_id_2=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT cust_id AS type_id, 3 AS type_code, <? value("cust") ?> AS type,\n         cust_number AS number,\n         cust_name AS name, <? value("billing") ?> AS role,\n         (cust_active) AS active,\n         '' AS owner\n    FROM custinfo WHERE (cust_cntct_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT cust_id AS type_id, 4 AS type_code, <? value("cust") ?> AS type,\n         cust_number AS number,\n         cust_name AS name, <? value("correspond") ?> AS role,\n         (cust_active) AS active,\n         '' AS owner\n    FROM custinfo WHERE (cust_corrcntct_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT vend_id AS type_id, 5 AS type_code, <? value("vend") ?> AS type,\n         vend_number AS number,\n         vend_name AS name, <? value("primary") ?> AS role,\n         (vend_active) AS active,\n         '' AS owner\n    FROM vendinfo WHERE (vend_cntct1_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT vend_id AS type_id, 6 AS type_code, <? value("vend") ?> AS type,\n         vend_number AS number,\n         vend_name AS name, <? value("secondary") ?> AS role,\n         (vend_active) AS active,\n         '' AS owner\n    FROM vendinfo WHERE (vend_cntct2_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT prospect_id AS type_id, 7 AS type_code, <? value("prospect") ?> AS type,\n         prospect_number AS number,\n         prospect_name AS name, '' AS role,\n         (prospect_active) AS active,\n         '' AS owner\n    FROM prospect WHERE (prospect_cntct_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT shipto_id AS type_id, 8 AS type_code, <? value("shipto") ?> AS type,\n         shipto_num AS number,\n         shipto_name AS name, <? value("shipto") ?> AS role,\n         (shipto_active) AS active,\n         '' AS owner\n    FROM shiptoinfo WHERE (shipto_cntct_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT vendaddr_id AS type_id, 9 AS type_code, <? value("vendaddr") ?> AS type,\n         vendaddr_code AS number,\n         vendaddr_name AS name, '' AS role,\n         (true) AS active,\n         '' AS owner\n    FROM vendaddrinfo WHERE (vendaddr_cntct_id=<? value("id") ?>)\n   \n  UNION ALL\n  SELECT warehous_id AS type_id, 10 AS type_code, <? value("whs") ?> AS type,\n         warehous_code AS number,\n         warehous_descrip AS name, '' AS role,\n         (warehous_active) AS active,\n         '' AS owner\n    FROM whsinfo WHERE (warehous_cntct_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT emp_id AS type_id, 11 AS type_code, <? value("emp") ?> AS type,\n         emp_code AS number,\n         emp_number AS name, '' AS role,\n         (emp_active) AS active,\n         '' AS owner\n    FROM emp WHERE (emp_cntct_id=<? value("id") ?>)\n\n<? if exists("showOrders") ?>\n  UNION ALL\n  SELECT cohead_id AS id, 12 AS altId, <? value("cohead") ?> AS type,\n         cohead_number AS number,\n         cust_number AS name, <? value("billing") ?> AS role,\n         (cohead_status = 'O') AS active,\n         '' AS owner\n    FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n   WHERE (<? value("id") ?>=cohead_billto_cntct_id)\n\n  UNION ALL\n  SELECT cohead_id AS id, 13 AS altId, <? value("cohead") ?> AS type,\n         cohead_number AS number,\n         cust_number AS name,  <? value("shipto") ?> AS role,\n         (cohead_status = 'O') AS active,\n         '' AS owner\n    FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n   WHERE (<? value("id") ?>=cohead_shipto_cntct_id)\n<? endif ?>\n\n  UNION ALL\n  SELECT incdt_id AS id, 14 AS altId, <? value("incdt") ?> AS type,\n         incdt_number::TEXT AS number,\n         incdt_summary AS name, '' AS role,\n         (incdt_status NOT IN ('R', 'L')) AS active,\n         incdt_owner_username AS owner\n    FROM incdt\n   WHERE (incdt_cntct_id=<? value("id") ?>)\n\n<? if exists("lsreg") ?>\n  UNION ALL\n  SELECT lsreg_id AS id, 15 AS altId, <? value("lsreg") ?> AS type,\n         ls_number AS number,\n         item_number AS name, '' AS role,\n         (lsreg_expiredate > current_date) AS active,\n         '' AS owner\n    FROM lsreg JOIN ls ON (lsreg_ls_id=ls_id) JOIN item ON (ls_item_id=item_id)\n   WHERE (lsreg_cntct_id=<? value("id") ?>)\n<? endif ?>\n\n  UNION ALL\n  SELECT ophead_id AS id, 16 AS altId, <? value("ophead") ?> AS type,\n         ophead_number AS number,\n         ophead_name AS name, '' AS role,\n         ophead_active AS active,\n         ophead_owner_username AS owner\n    FROM ophead\n   WHERE (ophead_cntct_id=<? value("id") ?>)\n\n<? if exists("showOrders") ?>\n  UNION ALL\n  SELECT pohead_id AS id, 17 AS altId, <? value("pohead") ?> AS type,\n         pohead_number AS number,\n         vend_number AS name, <? value("vendcntct") ?> AS role,\n         (pohead_status != 'C') AS active,\n         '' AS owner\n    FROM pohead JOIN vendinfo ON (pohead_vend_id=vend_id)\n   WHERE (<? value("id") ?>=pohead_vend_cntct_id)\n\n  UNION ALL\n  SELECT pohead_id AS id, 18 AS altId, <? value("pohead") ?> AS type,\n         pohead_number AS number,\n         vend_number AS name, <? value("shipto") ?> AS role,\n         (pohead_status != 'C') AS active,\n         '' AS owner\n    FROM pohead JOIN vendinfo ON (pohead_vend_id=vend_id)\n   WHERE (<? value("id") ?>=pohead_shipto_cntct_id)\n\n  UNION ALL\n  SELECT quhead_id AS id, 19 AS altId, <? value("quhead") ?> AS type,\n         quhead_number AS number,\n         COALESCE(cust_number, prospect_number) AS name,\n         <? value("billing") ?> AS role,\n         (quhead_status = 'O') AS active,\n         '' AS owner\n    FROM quhead LEFT OUTER JOIN custinfo ON (quhead_cust_id=cust_id)\n                LEFT OUTER JOIN prospect ON (quhead_cust_id=prospect_id)\n   WHERE (<? value("id") ?>=quhead_billto_cntct_id)\n\n  UNION ALL\n  SELECT quhead_id AS id, 20 AS altId, <? value("quhead") ?> AS type,\n         quhead_number AS number,\n         COALESCE(cust_number, prospect_number) AS name,\n         <? value("shipto") ?> AS role,\n         (quhead_status = 'O') AS active,\n         '' AS owner\n    FROM quhead LEFT OUTER JOIN custinfo ON (quhead_cust_id=cust_id)\n                LEFT OUTER JOIN prospect ON (quhead_cust_id=prospect_id)\n   WHERE (<? value("id") ?>=quhead_shipto_cntct_id)\n<? endif ?>\n\n  UNION ALL\n  SELECT todoitem_id, 21 AS altId, <? value("todo") ?> AS type,\n         todoitem_seq::TEXT AS number,\n         todoitem_name AS name, '' AS role,\n         (todoitem_completed_date IS NULL) AS active,\n         todoitem_owner_username AS owner\n    FROM todoitem\n   WHERE todoitem_cntct_id=<? value("id") ?>\n\n<? if exists("showOrders") ?>\n  <? if exists("tohead") ?>\n  UNION ALL\n  SELECT tohead_id, 22 AS altId, <? value("tohead") ?> AS type,\n         tohead_number AS number,\n         tohead_srcname || ' -> ' || tohead_destname AS name,\n         <? value("from") ?>  AS role,\n         (tohead_status = 'O') AS active,\n         '' AS owner\n    FROM tohead\n   WHERE (<? value("id") ?>=tohead_srccntct_id)\n  UNION ALL\n  SELECT tohead_id, 23 AS altId, <? value("tohead") ?> AS type,\n         tohead_number AS number,\n         tohead_srcname || ' -> ' || tohead_destname AS name,\n         <? value("dest") ?> AS role,\n         (tohead_status = 'O') AS active,\n         '' AS owner\n    FROM tohead\n   WHERE (<? value("id") ?>=tohead_destcntct_id)\n  <? endif ?>\n<? endif ?>\n\n<? if not exists('core') ?>\n) AS innerq\n<? endif ?>\n  ORDER BY type, number;\n      admin   2014-10-06      0
101098
 
418     contactmerge    contactused      Checks to see if this contact is used anywhere\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: contactmerge\n-- Name: contactused\n-- Notes: Checks to see if this contact is used anywhere\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctused(<? value("cntct_id") ?>) AS used;\n admin   2014-10-06      0
101099
 
422     contactmerge    merge    Merge contact selections\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: contactmerge\n-- Name: merge\n-- Notes: Merge contact selections\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctmerge(\n  src.cntctsel_cntct_id, \n  trgt.cntctsel_cntct_id,\n  <? value("purge") ?>::boolean) AS result\nFROM cntctsel src, cntctsel trgt\nWHERE ((trgt.cntctsel_target)\nAND (NOT src.cntctsel_target));\n admin   2014-10-06      0
101100
 
421     contactmerge    merged    Lists all merged contacts\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: contactmerge\n-- Name: merged\n-- Notes:  Lists all merged contacts\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntct_id,\n  CASE\n    WHEN (cntctUsed(cntctmrgd_cntct_id)=false) THEN\n      3 -- Already merged contact\n    ELSE\n      4 -- Already merged contact, but still has relationships\n  END AS status,\n  cntct.*,crmacct_number,crmacct_name,addr.*, \n 0 AS xtindentrole,\n  CASE\n    WHEN (cntctUsed(cntctmrgd_cntct_id)=false) THEN\n      'warning' -- Already merged contact\n    ELSE\n      'error'  -- Already merged contact, but still has relationships\n  END AS qtforegroundrole\nFROM cntct\n  JOIN cntctmrgd ON (cntct_id=cntctmrgd_cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n  LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id);\n        admin   2014-10-06      0
101101
 
423     contactmerge    populate         Queries selected contact info\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: contactmerge\n-- Name: populate\n-- Notes: Queries selected contact info\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntct.*,\n  crmacct_number,\n  crmacct_name,\n  addr.*,\n  CASE WHEN cntctsel_mrg_first_name THEN 'emphasis' END AS cntct_first_name_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_last_name THEN 'emphasis' END AS cntct_last_name_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_honorific THEN 'emphasis' END AS cntct_honorific_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_initials THEN 'emphasis' END AS cntct_initials_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_phone THEN 'emphasis' END AS cntct_phone_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_phone2 THEN 'emphasis' END AS cntct_phone2_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_fax THEN 'emphasis' END AS cntct_fax_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_email THEN 'emphasis' END AS cntct_email_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_webaddr THEN 'emphasis' END AS cntct_webaddr_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_notes THEN 'emphasis' END AS cntct_notes_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_title THEN 'emphasis' END AS cntct_title_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_middle THEN 'emphasis' END AS cntct_middle_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_suffix THEN 'emphasis' END AS cntct_suffix_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_owner_username THEN 'emphasis' END AS cntct_owner_username_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_crmacct_id THEN 'emphasis' END AS crmacct_number_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_crmacct_id THEN 'emphasis' END AS crmacct_name_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_line1_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_line2_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_line3_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_city_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_state_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_postalcode_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_country_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_notes_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_number_qtforegroundrole\nFROM cntctsel\n  JOIN cntct ON (cntctsel_cntct_id=cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n  LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id)\nWHERE (cntctsel_target=<? value("target") ?>);\n   admin   2014-10-06      0
101102
 
424     contactmerge    purge    Purge contact(s) that was/were previously merged\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: contactmerge\n-- Name: purge\n-- Notes: Purge contact(s) that was/were previously merged\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM cntct WHERE cntct_id IN\n(SELECT cntctmrgd_cntct_id\n  FROM cntctmrgd\n  WHERE (NOT cntctmrgd_error)\n<? if exists("cntct_id") ?>\nAND (cntctmrgd_cntct_id=<? value("cntct_id") ?>)\n<? endif ?>)\nAND (NOT cntctUsed(cntct_id));\n  admin   2014-10-06      0
101103
 
99      contacts        detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: contacts\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (length(cntct_last_name)=0, length(cntct_first_name)=0, cntct_last_name, cntct_first_name, cntct_number) \n  cntct_id AS id\n<? if not exists("idOnly") ?> \n, addr_id AS altId, addr.*,\n  crmacct_id, crmacct_number, crmacct_name,\n  cntct.* \n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\n<? endif ?>\n<? if exists("hasContext") ?>\nFROM cntct\n<? else ?>\nFROM cntct()\n<? endif ?>\n  LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id) \n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) \n  LEFT OUTER JOIN cntcteml ON (cntcteml_cntct_id=cntct_id)\n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='CNTCT') \n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=cntct_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='CNTCT') \n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=cntct_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='CNTCT') \n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=cntct_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE true\n<? if exists("owner_username") ?> \n  AND (cntct_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (cntct_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\n<? if exists("activeOnly") ?> \n  AND cntct_active\n<? endif ?>\n<? if exists("search_pattern") ?>\n  AND (\n (crmacct_number ~* <? value("search_pattern") ?>)\n  OR (crmacct_name ~* <? value("search_pattern") ?>)\n  OR (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* <? value("search_pattern") ?>)\n  OR (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* <? value("search_pattern") ?>)\n  OR (COALESCE(cntcteml_email,'') ~* <? value("search_pattern") ?>)\n  OR (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* <? value("search_pattern") ?>)\n  OR (COALESCE(addr_city,'') ~* <? value("search_pattern") ?>)\n  OR (COALESCE(addr_state,'') ~* <? value("search_pattern") ?>)\n  OR (COALESCE(addr_postalcode,'') ~* <? value("search_pattern") ?>)\n  OR (COALESCE(addr_country,'') ~* <? value("search_pattern") ?>)\n)\n<? endif ?>\n<? if exists("cntct_id") ?>\n  AND (cntct_id=<? value("cntct_id")?>)\n<? endif ?>\n<? if exists("crmacct_id") ?>\n  AND (crmacct_id=<? value("crmacct_id")?>)\n<? endif ?>\n<? if exists("cntct_name_pattern") ?>\n  AND (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* <? value("cntct_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_phone_pattern") ?>\n  AND (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* <? value("cntct_phone_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_email_pattern") ?>\n  AND (COALESCE(cntcteml_email,'') ~* <? value("cntct_email_pattern") ?>)\n<? endif ?>\n<? if exists("addr_street_pattern") ?>\n  AND (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* <? value("addr_street_pattern") ?>)\n<? endif ?>\n<? if exists("addr_city_pattern") ?>\n  AND (COALESCE(addr_city,'') ~* <? value("addr_city_pattern") ?>)\n<? endif ?>\n<? if exists("addr_state_pattern") ?>\n  AND (COALESCE(addr_state,'') ~* <? value("addr_state_pattern") ?>)\n<? endif ?>\n<? if exists("addr_postalcode_pattern") ?>\n  AND (COALESCE(addr_postalcode,'') ~* <? value("addr_postalcode_pattern") ?>)\n<? endif ?>\n<? if exists("addr_country_pattern") ?>\n  AND (COALESCE(addr_country,'') ~* <? value("addr_country_pattern") ?>)\n<? endif ?>\n<? if exists("id") ?>\n  AND (cntct_id=<? literal("id") ?>)\n<? endif ?>\n<? if exists("addr_id") ?>\n  AND (addr_id=<? value("addr_id") ?>)\n<? endif ?>\n<? literal("charClause") ?>\nORDER BY length(cntct_last_name)=0, length(cntct_first_name)=0, cntct_last_name, cntct_first_name, cntct_number, cntcteml_primary desc;\n     admin   2014-10-06      0
101104
 
474     contracts       detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: contracts\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT contrct_id, \n       vend_number, vend_name, \n       contrct.*,\n       CASE WHEN COALESCE(contrct_effective, startOfTime()) <=\n                 startOfTime() THEN <? value("always") ?>\n       END AS contrct_effective_qtdisplayrole,\n       CASE WHEN COALESCE(contrct_expires, endOfTime()) >=\n                 endOfTime() THEN <? value("never") ?>\n       END AS contrct_expires_qtdisplayrole,\n       CASE WHEN (COALESCE(contrct_expires, endOfTime()) < CURRENT_DATE) THEN 'expired'\n            WHEN (COALESCE(contrct_effective, startOfTime()) > CURRENT_DATE) THEN 'future'\n       END AS qtforegroundrole,\n       (SELECT count(*) FROM itemsrc WHERE (itemsrc_contrct_id=contrct_id)) AS item_count \nFROM contrct JOIN vendinfo ON (vend_id=contrct_vend_id)\nWHERE ((true)\n<? if exists("vend_id") ?>\n  AND (contrct_vend_id=<? value("vend_id") ?>)\n<? endif ?>\n<? if exists("effectiveStartDate") ?>\n  AND (contrct_effective >= <? value("effectiveStartDate") ?>)\n<? endif ?>\n<? if exists("effectiveEndDate") ?>\n  AND (contrct_effective <= <? value("effectiveEndDate") ?>)\n<? endif ?>\n<? if exists("expireStartDate") ?>\n  AND (contrct_expires >= <? value("expireStartDate") ?>)\n<? endif ?>\n<? if exists("expireEndDate") ?>\n  AND (contrct_expires <= <? value("expireEndDate") ?>)\n<? endif ?>\n<? if exists("search_pattern") ?>\n  AND ( (contrct_number ~* <? value("search_pattern") ?>)\n    OR  (COALESCE(contrct_descrip,'') ~* <? value("search_pattern") ?>) )\n<? endif ?>\n)\nORDER By vend_number, contrct_number\n;\n        admin   2014-10-06      0
101105
 
236     costedBOM       detail   used by dspCostedIndentedBOM, dspCostedSingleLevelBOM, dspCostedSummarizedBOM\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: costedBOM\n-- Name: detail\n-- Notes: used by dspCostedIndentedBOM, dspCostedSingleLevelBOM, dspCostedSummarizedBOM\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n<? if exists("indentedBOM") ?>\n       bomdata_bomwork_id AS id,\n<? elseif exists("singleLevelBOM") ?>\n       bomdata_bomitem_id AS id,\n<? elseif exists("summarizedBOM") ?>\n       -1,\n<? endif ?>\n       \n<? if exists("indentedBOM") ?>\n       CASE WHEN bomdata_bomwork_parent_id = -1 AND bomdata_bomwork_id = -1 THEN -1\n         ELSE bomdata_item_id\n       END AS altid,\n<? elseif exists("singleLevelBOM") ?>\n       CASE WHEN (bomdata_bomitem_id = -1) THEN -1\n         ELSE bomdata_item_id\n       END AS altid,\n<? endif ?>\n       *,\n\n<? if exists("useStandardCosts") ?>\n       bomdata_stdunitcost AS unitcost,\n       bomdata_stdextendedcost AS extendedcost,\n<? elseif exists("useActualCosts") ?>\n       bomdata_actunitcost AS unitcost,\n       bomdata_actextendedcost AS extendedcost,\n<? endif ?>\n\n       'qty' AS bomdata_batchsize_xtnumericrole,\n       'qty' AS bomdata_qtyfxd_xtnumericrole,\n       'qtyper' AS bomdata_qtyper_xtnumericrole,\n       'percent' AS bomdata_scrap_xtnumericrole,\n       'qtyper' AS bomdata_qtyreq_xtnumericrole,\n       'cost' AS unitcost_xtnumericrole,\n       'cost' AS extendedcost_xtnumericrole,\n       CASE WHEN COALESCE(bomdata_effective, startOfTime()) <= startOfTime() THEN <? value("always") ?>\n         END AS bomdata_effective_qtdisplayrole,\n       CASE WHEN COALESCE(bomdata_expires, endOfTime()) <= endOfTime() THEN <? value("never") ?>\n         END AS bomdata_expires_qtdisplayrole,\n       CASE WHEN bomdata_expired THEN 'expired'\n            WHEN bomdata_future  THEN 'future'\n       END AS qtforegroundrole\n<? if exists("indentedBOM") ?>\n       , bomdata_bomwork_level - 1 AS xtindentrole\n<? elseif exists("singleLevelBOM") ?>\n       , 0 AS extendedcost_xttotalrole\n<? endif ?>\nFROM\n<? if exists("indentedBOM") ?>\n     indentedbom(<? value("item_id") ?>, <? value("revision_id") ?>, 0, 0);\n<? elseif exists("singleLevelBOM") ?>\n     singlelevelbom(<? value("item_id") ?>, <? value("revision_id") ?>, 0, 0);\n<? elseif exists("summarizedBOM") ?>\n     summarizedBOM(<? value("item_id") ?>, <? value("revision_id") ?>, <? value("expiredDays") ?>, <? value("futureDays") ?>);\n<? endif ?>\n      admin   2014-10-06      0
101106
 
112     costelem        unusedbyitem     list the cost elements that can be applied to an item that have\n        not already been applied to that item. takes an item_id and type.\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: costelem\n-- Name:  unusedbyitem\n-- Notes: list the cost elements that can be applied to an item that have\n--        not already been applied to that item. takes an item_id and type.\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("item_id") ?>\n\nSELECT costelem_id, costelem_type\nFROM costelem\nWHERE ((costelem_active)\n   AND (NOT costelem_sys\n        OR (CASE WHEN fetchMetricBool('Routings') AND\n                     (<? value("itemtype") ?> IN ('M', 'F', 'B', 'C', 'T')) THEN\n               costelem_type IN ('Direct Labor', 'Overhead', 'Machine Overhead')\n                 WHEN (<? value("itemtype") ?> IN ('O', 'P')) THEN\n                                                   costelem_type IN ('Material')\n            END))\n   AND (costelem_id NOT IN (SELECT itemcost_costelem_id\n                            FROM itemcost\n                            WHERE ((NOT itemcost_lowlevel)\n                               AND (itemcost_item_id=<? value("item_id") ?>))))\n      )\nORDER BY costelem_type;\n\n<? elseif exists("bomitem_id") ?>\n\nSELECT costelem_id, costelem_type\nFROM costelem\nWHERE ((costelem_active)\n   AND (NOT costelem_sys\n        OR (CASE WHEN fetchMetricBool('Routings') AND\n                     (<? value("itemtype") ?> IN ('M', 'F', 'B', 'C', 'T')) THEN\n               costelem_type IN ('Direct Labor', 'Overhead', 'Machine Overhead')\n                 WHEN (<? value("itemtype") ?> IN ('O', 'P')) THEN\n                                                   costelem_type IN ('Material')\n            END))\n   AND (costelem_id NOT IN (SELECT bomitemcost_costelem_id\n                            FROM bomitemcost\n                            WHERE ((NOT bomitemcost_lowlevel)\n                               AND (bomitemcost_bomitem_id=<? value("bomitem_id") ?>))))\n      )\nORDER BY costelem_type;\n\n\n<? endif ?>\n       admin   2014-10-06      0
101107
 
237     countSlip       detail   used by dspCountSlipEditList, dspCountSlipsByWarehouse\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: countSlip\n-- Name: detail\n-- Notes: used by dspCountSlipEditList, dspCountSlipsByWarehouse\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntslip_id,\n       CASE WHEN (cntslip_posted) THEN 1\n         ELSE 0\n       END,\n       cntslip_username AS user,\n<? if exists("numericSlips") ?>\n       toNumeric(cntslip_number, 0) AS cntslip_number,\n       cntslip_number AS cntslip_number_qtdisplayrole,\n<? else ?>\n       cntslip_number,\n<? endif ?>\n       CASE WHEN (cntslip_location_id=-1) THEN ''\n         ELSE formatLocationName(cntslip_location_id)\n       END AS locname,\n       invcnt_tagnumber,\n<? if exists("byWarehouse") ?>\n       warehous_code,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS descrip,\n<? endif ?>\n       cntslip_lotserial, cntslip_posted,\n       cntslip_entered, cntslip_qty,\n       'qty' AS cntslip_qty_xtnumericrole,\n       cntslip_posted AS posted\nFROM cntslip, invcnt\n<? if exists("byWarehouse") ?>\n     JOIN itemsite ON (invcnt_itemsite_id=itemsite_id)\n     JOIN item ON (itemsite_item_id=item_id)\n     JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n<? endif ?>\nWHERE ((cntslip_cnttag_id=invcnt_id)\n<? if exists("byWarehouse") ?>\n   AND (cntslip_entered BETWEEN <? value("startDate") ?> AND  (<? value("endDate") ?>::DATE + 1))\n  <? if not exists("showUnposted") ?>\n    AND (cntslip_posted)\n  <? endif ?>\n  <? if exists("warehous_id") ?>\n    AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n<? else ?>\n    AND (NOT invcnt_posted)\n    AND (invcnt_id=<? value("cnttag_id") ?>)\n<? endif ?>\n      )\nORDER BY cntslip_number;\n        admin   2014-10-06      0
101108
 
238     countTag        detail   used by dspCountTagEditList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: countTag\n-- Name: detail\n-- Notes: used by dspCountTagEditList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       CASE WHEN (xtindentrole = 1) THEN NULL\n     <? if exists("varianceValue") ?>\n            WHEN (ABS(variancecost) >  <? value("varianceValue") ?>) THEN 'error'\n     <? elseif exists("variancePercent") ?>\n            WHEN (ABS(varianceprcnt * 100.0) >  <? value("variancePercent") ?>) THEN 'error'\n     <? else ?>\n            ELSE NULL\n     <? endif ?>\n       END AS qtforegroundrole,\n       CASE WHEN (xtindentrole = 1) THEN NULL\n            WHEN (qohafter IS NOT NULL) THEN 'emphasis'\n       END AS qohafter_qtforegroundrole,\n       CASE WHEN (xtindentrole = 0) THEN NULL ELSE '' END AS invcnt_priority_qtdisplayrole,\n       'qty' AS qoh_xtnumericrole,\n       'qty' AS qohafter_xtnumericrole,\n       'qty' AS variance_xtnumericrole,\n       'percent' AS varianceprcnt_xtnumericrole,\n       'curr' AS variancecost_xtnumericrole\nFROM (\n      SELECT invcnt_id, -1 AS cntslip_id, invcnt_priority,\n             COALESCE(invcnt_tagnumber, 'Misc.') AS tagnumber,\n             invcnt_tagdate AS tagdate,\n             item_number, (item_descrip1 || item_descrip2) AS item_descrip, warehous_code,\n\t     CASE WHEN (location_id IS NOT NULL) THEN\n               formatLocationName(location_id)\n               ELSE <? value("all") ?> END AS loc_specific,\n             qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) AS qoh,\n      <? if exists("showSlips") ?>\n             calcTotalSlipQty(invcnt_id) AS qohafter,\n             (calcTotalSlipQty(invcnt_id) - qtyAtLocation(invcnt_itemsite_id, invcnt_location_id)) AS variance,\n             CASE WHEN (calcTotalSlipQty(invcnt_id) IS NULL) THEN NULL\n                  WHEN ((qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) = 0) AND (calcTotalSlipQty(invcnt_id) > 0)) THEN 1\n                  WHEN ((qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) = 0) AND (calcTotalSlipQty(invcnt_id) < 0)) THEN -1\n                  WHEN ((qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) = 0) AND (calcTotalSlipQty(invcnt_id) = 0)) THEN 0\n               ELSE ((1 - (calcTotalSlipQty(invcnt_id) / qtyAtLocation(invcnt_itemsite_id, invcnt_location_id))) * -1)\n             END AS varianceprcnt,\n             (itemCost(itemsite_id) * (calcTotalSlipQty(invcnt_id) - qtyAtLocation(invcnt_itemsite_id, invcnt_location_id))) AS variancecost,\n      <? else ?>\n             COALESCE(invcnt_qoh_after, 0.0) AS qohafter,\n             (invcnt_qoh_after - qtyAtLocation(invcnt_itemsite_id, invcnt_location_id)) AS variance,\n             CASE WHEN (invcnt_qoh_after IS NULL) THEN NULL\n                  WHEN ((qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) = 0) AND (invcnt_qoh_after > 0)) THEN 1\n                  WHEN ((qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) = 0) AND (invcnt_qoh_after < 0)) THEN -1\n                  WHEN ((qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) = 0) AND (invcnt_qoh_after = 0)) THEN 0\n               ELSE ((1 - (invcnt_qoh_after / qtyAtLocation(invcnt_itemsite_id, invcnt_location_id))) * -1)\n             END AS varianceprcnt,\n             (itemCost(itemsite_id) * (invcnt_qoh_after - qtyAtLocation(invcnt_itemsite_id, invcnt_location_id))) AS variancecost,\n      <? endif ?>\n             item_number AS orderby,\n             0 AS xtindentrole\n      FROM invcnt LEFT OUTER JOIN location ON (invcnt_location_id=location_id),\n     item, whsinfo, itemsite\n      WHERE ((invcnt_itemsite_id=itemsite_id)\n         AND (itemsite_item_id=item_id)\n         AND (itemsite_warehous_id=warehous_id)\n         AND (NOT invcnt_posted)\n      <? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n      <? endif ?>\n      <? if exists("classcode_id") ?>\n         AND (item_classcode_id=<? value("classcode_id") ?>)\n      <? elseif exists("classcode_pattern") ?>\n         AND (item_classcode_id IN (SELECT classcode_id FROM classcode WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n      <? elseif exists("plancode_id") ?>\n         AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n      <? elseif exists("plancode_pattern") ?>\n         AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n      <? endif ?>\n      <? if exists("showSlips") ?>\n            )\n      UNION\n      SELECT invcnt_id, cntslip_id, invcnt_priority,\n             cntslip_number AS tagnumber,\n             cntslip_entered AS tagdate,\n             CASE WHEN (cntslip_posted) THEN <? value("posted") ?>\n               ELSE <? value("unposted") ?>\n             END AS item_number,\n             '' AS item_descrip,\n             '' AS warehous_code,\n             '' AS loc_specific,\n             NULL AS qoh,\n             cntslip_qty AS qohafter,\n             NULL AS variance, NULL AS varianceprcnt, 0 AS variancecost,\n             item_number AS orderby,\n             1 AS xtindentrole\n      FROM cntslip, invcnt, itemsite, item\n      WHERE ((cntslip_cnttag_id=invcnt_id)\n         AND (invcnt_itemsite_id=itemsite_id)\n         AND (itemsite_item_id=item_id)\n         AND (NOT invcnt_posted)\n       <? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n       <? endif ?>\n       <? if exists("classcode_id") ?>\n         AND (item_classcode_id=<? value("classcode_id") ?>)\n       <? elseif exists("classcode_pattern") ?>\n         AND (item_classcode_id IN (SELECT classcode_id FROM classcode WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n       <? elseif exists("plancode_id") ?>\n         AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n       <? elseif exists("plancode_pattern") ?>\n         AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n       <? endif ?>\n       <? endif ?>\n            )\n) AS dummy\nORDER BY invcnt_priority DESC, orderby, invcnt_id, cntslip_id;\n     admin   2014-10-06      0
101109
 
436     countTags       create   used by createCountTagsByParameterList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: countTags\n-- Name: create\n-- Notes: used by createCountTagsByParameterList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT createCountTag(itemsite_id, <? value("comments") ?>, <? value("priority") ?>, <? value("freeze") ?>, <? value("location_id") ?>)\nFROM ( SELECT itemsite_id\n       FROM itemsite JOIN item ON (item_id=itemsite_item_id)\n<? if exists("location_id") ?>\n                     JOIN itemloc ON ( (itemloc_location_id=<? value("location_id") ?>)\n                                   AND (itemloc_itemsite_id = itemsite_id)\n                                   AND (validLocation(<? value("location_id") ?>, itemsite_id)) )\n<? endif ?>\n       WHERE (itemsite_active)\n         AND (item_active)\n<? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n         AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n         AND (item_classcode_id IN (SELECT classcode_id\n                                    FROM classcode\n                                    WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("plancode_id") ?>\n  AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n                                FROM plancode\n                                WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n<? if exists("ignoreZeroBalance") ?>\n         AND (itemsite_qtyonhand <> 0.0)\n<? endif ?>\n       ORDER BY item_number ) AS data;\n       admin   2014-10-06      0
101110
 
47      countTags       detail   used by dspCountTagsByClassCode, dspCountTagsByItem, dspCountTagsByWarehouse\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: countTags\n-- Name: detail\n-- Notes: used by dspCountTagsByClassCode, dspCountTagsByItem, dspCountTagsByWarehouse\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT invcnt_id, invcnt_tagnumber, warehous_code,\n       item_number, (item_descrip1 || item_descrip2) AS item_descrip,\n       invcnt_tagdate,\n       CASE WHEN invcnt_tagdate IS NOT NULL THEN invcnt_tag_username\n       END AS creator,\n       invcnt_cntdate,\n       CASE WHEN invcnt_cntdate IS NOT NULL THEN invcnt_cnt_username\n       END AS counter,\n       invcnt_postdate,\n       CASE WHEN invcnt_postdate IS NOT NULL THEN invcnt_post_username\n       END AS poster,\n       CASE WHEN (NOT invcnt_posted) THEN NULL\n            ELSE invcnt_qoh_before\n       END AS qohbefore,\n       invcnt_qoh_after,\n       CASE WHEN (NOT invcnt_posted) THEN NULL\n            ELSE (invcnt_qoh_after - invcnt_qoh_before)\n       END AS variance,\n       CASE WHEN (NOT invcnt_posted) THEN NULL\n            WHEN ((invcnt_qoh_before = 0) AND (invcnt_qoh_after = 0)) THEN 0\n            WHEN (invcnt_qoh_before = 0) THEN 1\n            ELSE ((1 - (invcnt_qoh_after / invcnt_qoh_before)) * -1)\n       END AS percent,\n      'qty' AS qohbefore_xtnumericrole,\n      'qty' AS invcnt_qoh_after_xtnumericrole,\n      'qty' AS variance_xtnumericrole,\n      'percent' AS percent_xtnumericrole \nFROM invcnt, itemsite, item, whsinfo\nWHERE ((invcnt_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (itemsite_warehous_id=warehous_id)\n  AND  (DATE(invcnt_tagdate) BETWEEN <? value("startDate") ?>\n                                 AND <? value("endDate") ?>)\n<? if not exists("showUnposted") ?>\n  AND  invcnt_posted\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n  AND  (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n  AND  (item_classcode_id IN (SELECT classcode_id\n                             FROM classcode\n                             WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("item_id") ?>\n  AND  (item_id=<? value("item_id") ?>)\n<? endif ?>\n)\nORDER BY invcnt_tagdate;\n   admin   2014-10-06      0
101111
 
48      creditCards     detail   used by cashReceipt, customer, salesOrder\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: creditCards\n-- Name: detail\n-- Notes: used by cashReceipt, customer, salesOrder\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ccard_id, ccard_seq,\n       CASE WHEN (ccard_type='M') THEN <? value("masterCard") ?>\n            WHEN (ccard_type='V') THEN <? value("visa") ?>\n            WHEN (ccard_type='A') THEN <? value("americanExpress") ?>\n            WHEN (ccard_type='D') THEN <? value("discover") ?>\n            ELSE <? value("other") ?>\n       END AS type,\n       formatccnumber(decrypt(setbytea(ccard_number),\n                              setbytea(<? value("key") ?>), 'bf')) AS f_number,\n       ccard_active,\n       formatbytea(decrypt(setbytea(ccard_name),\n                           setbytea(<? value("key") ?>), 'bf')) AS ccard_name,\n       formatbytea(decrypt(setbytea(ccard_month_expired),\n                           setbytea(<? value("key") ?>), 'bf')) ||\n                   '-' ||\n                   formatbytea(decrypt(setbytea(ccard_year_expired),\n                                       setbytea(<? value("key") ?>),\n                                       'bf')) AS expiration \nFROM ccard \nWHERE ((ccard_cust_id=<? value("cust_id") ?>) \n<? if exists("ccard_type") ?>\n AND   (ccard_type=<? value("ccard_type") ?>)\n<? endif ?>\n<? if exists("activeonly") ?>\n AND   (ccard_active)\n<? endif ?>\n)\nORDER BY ccard_seq;\n   admin   2014-10-06      0
101112
 
249     glseries        detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: glseries\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *, \n                          CASE WHEN <? literal("table") ?>_id = -1 THEN 0\n                          ELSE 1 END AS xtindentrole,\n                          CASE WHEN <? literal("table") ?>_id = -1 THEN <? literal("table") ?>_date\n                          END AS transdate,   \n                          'curr' AS debit_xtnumericrole,\n                          'curr' AS credit_xtnumericrole \n                   FROM (SELECT DISTINCT \n                          <? literal("table") ?>_sequence AS sequence, \n                          -1 AS <? literal("table") ?>_id, \n                          <? literal("table") ?>_date, \n                          <? literal("table") ?>_source AS source, \n                          <? literal("table") ?>_journalnumber AS journalnumber,\n                          <? literal("table") ?>_doctype AS doctype, '' AS docnumber,\n                          -1 AS accnt_id, firstLine(<? literal("table") ?>_notes) AS accnt_id_qtdisplayrole,\n                          0.0 AS amount,\n                          CAST(NULL AS NUMERIC) AS debit,\n                          CAST(NULL AS NUMERIC) AS credit,\n                          <? literal("table") ?>_posted AS posted \n                   FROM <? literal("table") ?> \n                   WHERE ( (true) \n                   <? if exists("gltrans") ?>\n                    AND (NOT gltrans_deleted) \n                   <? endif ?>\n                    AND (<? literal("table") ?>_date BETWEEN <? value("startDate") ?>\n                                            AND <? value("endDate") ?>)\n                   <? if exists("source") ?>\n                      AND (<? literal("table") ?>_source=<? value("source") ?>)\n                   <? endif ?>\n                   <? if exists("startJrnlnum") ?>\n                      AND (<? literal("table") ?>_journalnumber BETWEEN <? value("startJrnlnum") ?>\n                                                     AND <? value("endJrnlnum") ?>)\n                   <? endif ?>\n                   ) \n                   UNION ALL \n                   SELECT <? literal("table") ?>_sequence AS sequence, \n                          <? literal("table") ?>_id, \n                          <? literal("table") ?>_date, \n                          NULL, NULL,\n                          NULL, <? literal("table") ?>_docnumber AS docnumber,\n                          accnt_id, (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS accnt_id_qtdisplayrole,\n                          <? literal("table") ?>_amount,\n                          CASE WHEN (<? literal("table") ?>_amount < 0) THEN (<? literal("table") ?>_amount * -1)\n                          END AS debit,\n                          CASE WHEN (<? literal("table") ?>_amount > 0) THEN <? literal("table") ?>_amount \n                          END AS credit,\n                          NULL AS posted \n                   FROM <? literal("table") ?> JOIN accnt ON (<? literal("table") ?>_accnt_id=accnt_id) \n                   WHERE ( (true) \n                   <? if exists("gltrans") ?>\n                    AND (NOT gltrans_deleted) \n                   <? endif ?>\n                     AND (<? literal("table") ?>_date BETWEEN <? value("startDate") ?>\n                                            AND <? value("endDate") ?>)\n                   <? if exists("source") ?>\n                      AND (<? literal("table") ?>_source=<? value("source") ?>)\n                   <? endif ?>\n                   <? if exists("startJrnlnum") ?>\n                      AND (<? literal("table") ?>_journalnumber BETWEEN <? value("startJrnlnum") ?>\n                                                     AND <? value("endJrnlnum") ?>)\n                   <? endif ?>\n                    ) \n                   ) AS dummy \n                   ORDER BY sequence,\n                            xtindentrole, amount;\n      admin   2014-10-06      0
101113
 
310     creditMemo      editlist         used by creditMemoEditList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: creditMemo\n-- Name: editlist\n-- Notes: used by creditMemoEditList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       ('C/M-' || formatCreditMemoNumber(cmhead_id)) AS docnumber,\n       currConcat(curr_id) AS currabbr,\n       CASE WHEN seq != 0 THEN ''\n       END AS docnumber_qtdisplayrole,\n       'qty' AS qtytobill_xtnumericrole,\n       'price' AS price_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       CASE WHEN namedescrip = <? value("notassigned") ?> THEN 'error' END AS qtforegroundrole\nFROM (\n\nSELECT cmhead_id, -1 AS altid,\n       cmhead_number AS ordernumber,\n       cust_number AS custitemnumber,\n       cmhead_billtoname AS namedescrip,\n       CAST(NULL AS TEXT) AS uom_name,\n       CAST(NULL AS NUMERIC) AS qtytobill,\n       CAST(NULL AS NUMERIC) AS price,\n       CAST(NULL AS NUMERIC) AS extprice,\n       cmhead_curr_id AS curr_id,\n       0 AS cmitem_linenumber, 0 AS xtindentrole, 0 AS seq\nFROM cmhead JOIN custinfo ON (cmhead_cust_id=cust_id)\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold))\n\nUNION\nSELECT cmhead_id, cmitem_id,\n       NULL, item_number,\n       item_descrip1,\n       uom_name, cmitem_qtycredit * cmitem_qty_invuomratio,\n       cmitem_unitprice / cmitem_price_invuomratio,\n       cmitem_qtycredit * cmitem_qty_invuomratio * cmitem_unitprice / cmitem_price_invuomratio,\n       cmhead_curr_id AS curr_id,\n       cmitem_linenumber, 1 AS xtindentrole, 1 AS seq\nFROM cmhead, cmitem, itemsite, item, uom\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold)\n  AND  (cmhead_id=cmitem_cmhead_id)\n  AND  (cmitem_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (item_inv_uom_id=uom_id))\n\nUNION\nSELECT cmhead_id, -1,\n       NULL, <? value("debit") ?>,\n       COALESCE((SELECT formatGLAccountLong(accnt_id)\n                 FROM accnt, salesaccnt\n                 WHERE ((salesaccnt_sales_accnt_id=accnt_id)\n                    AND (salesaccnt_id=findSalesAccnt(itemsite_id, 'IS', cmhead_cust_id,\n                                                      cmhead_saletype_id, cmhead_shipzone_id)))), <? value("notassigned") ?>),\n       NULL, NULL, NULL,\n       cmitem_qtycredit * cmitem_qty_invuomratio * cmitem_unitprice / cmitem_price_invuomratio,\n       cmhead_curr_id AS curr_id,\n       cmitem_linenumber, 2 AS xtindentrole, 2 AS seq\nFROM cmhead, cmitem, itemsite, item, uom\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold)\n  AND  (cmhead_id=cmitem_cmhead_id)\n  AND  (cmitem_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (item_inv_uom_id=uom_id))\n\nUNION\nSELECT cmhead_id, -1,\n       NULL, <? value("debit") ?>,\n       CASE WHEN (accnt_id IS NULL) THEN <? value("notassigned") ?>\n            ELSE formatGLAccountLong(accnt_id)\n       END,\n       NULL, NULL, cmhead_freight,\n       cmhead_freight,\n       cmhead_curr_id AS curr_id,\n       99999, 1 AS xtindentrole, 3 AS seq\nFROM cmhead LEFT OUTER JOIN accnt ON (accnt_id=findFreightAccount(cmhead_cust_id))\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold)\n  AND  (cmhead_freight <> 0))\n\nUNION\nSELECT cmhead_id, -1,\n       NULL, <? value("debit") ?>,\n       formatGLAccountLong(cmhead_misc_accnt_id),\n       NULL, NULL, cmhead_misc,\n       cmhead_misc,\n       cmhead_curr_id AS curr_id,\n       99999, 1 AS xtindentrole, 4 AS seq\nFROM cmhead LEFT OUTER JOIN accnt ON (accnt_id=findFreightAccount(cmhead_cust_id))\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold)\n  AND  (cmhead_misc <> 0))\n\nUNION\nSELECT cmhead_id, -1,\n       NULL, <? value("debit") ?>,\n       CASE WHEN (tax_sales_accnt_id IS NULL) THEN <? value("taxes") ?>\n            ELSE formatGLAccountLong(tax_sales_accnt_id)\n       END,\n       NULL, NULL, SUM(taxhist_tax * -1.0),\n       SUM(taxhist_tax * -1.0),\n       cmhead_curr_id AS curr_id,\n       99999, 1 AS xtindentrole, 5 AS seq\nFROM cmhead JOIN cmheadtax ON ((taxhist_parent_id=cmhead_id) AND (taxhist_tax <> 0.0))\n            JOIN tax ON (tax_id=taxhist_tax_id)\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold))\nGROUP BY cmhead_id, tax_sales_accnt_id, cmhead_curr_id\n\nUNION\nSELECT cmhead_id, -1,\n       NULL, <? value("debit") ?>,\n       CASE WHEN (tax_sales_accnt_id IS NULL) THEN <? value("taxes") ?>\n            ELSE formatGLAccountLong(tax_sales_accnt_id)\n       END,\n       NULL, NULL, SUM(taxhist_tax * -1.0),\n       SUM(taxhist_tax * -1.0),\n       cmhead_curr_id AS curr_id,\n       99999, 1 AS xtindentrole, 5 AS seq\nFROM cmhead JOIN cmitem ON (cmitem_cmhead_id=cmhead_id)\n            JOIN cmitemtax ON ((taxhist_parent_id=cmitem_id) AND (taxhist_tax <> 0.0))\n            JOIN tax ON (tax_id=taxhist_tax_id)\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold))\nGROUP BY cmhead_id, tax_sales_accnt_id, cmhead_curr_id\n\nUNION\nSELECT cmhead_id, -1,\n       NULL, <? value("credit") ?>,\n       CASE WHEN (accnt_id IS NULL) THEN <? value("notassigned") ?>\n            ELSE formatGLAccountLong(accnt_id)\n       END,\n       NULL, NULL, NULL,\n       SUM((cmitem_qtycredit * cmitem_qty_invuomratio) *\n           (cmitem_unitprice / cmitem_price_invuomratio)) +\n           cmhead_freight + cmhead_misc +\n           (SELECT COALESCE(SUM(taxhist_tax * -1.0), 0.0) FROM cmheadtax WHERE (taxhist_parent_id=cmhead_id)) +\n           (SELECT COALESCE(SUM(taxhist_tax * -1.0), 0.0) FROM cmitem JOIN cmitemtax ON (taxhist_parent_id=cmitem_id)\n                                    WHERE (cmitem_cmhead_id=cmhead_id))\n            AS extprice,\n       cmhead_curr_id AS curr_id,\n       99999, 1 AS xtindentrole, 6 AS seq\nFROM cmhead LEFT OUTER JOIN cmitem ON (cmhead_id=cmitem_cmhead_id)\n            LEFT OUTER JOIN accnt ON (accnt_id=findARAccount(cmhead_cust_id))\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold))\nGROUP BY cmhead_id, cmhead_cust_id, cmhead_freight, cmhead_misc, accnt_id, cmhead_curr_id\n\n) AS dummy\nORDER BY docnumber, cmitem_linenumber, seq;\n      admin   2014-10-06      0
101114
 
49      creditMemoCreditCards   detail   used by arWorkBench, returnAuthorization, returnAuthorizationWorkbench\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: creditMemoCreditCards\n-- Name: detail\n-- Notes: used by arWorkBench, returnAuthorization, returnAuthorizationWorkbench\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cmhead_number, cmhead_freight, cmhead_curr_id,\n       SUM(ROUND((cmitem_qtycredit * cmitem_qty_invuomratio) * \n                 (cmitem_unitprice / cmitem_price_invuomratio), 2)) +\n       cmhead_freight + cmhead_misc +\n       COALESCE( (SELECT SUM(tax) * -1 AS tax FROM\n                 (SELECT ROUND(SUM(taxdetail_tax), 2) AS tax\n                  FROM tax\n                   JOIN calculateTaxDetailSummary('CM', <? value("cmhead_id") ?>, 'T') ON (taxdetail_tax_id=tax_id)\n                  GROUP BY tax_id) AS data), 0) AS total,\n       COALESCE( (SELECT SUM(tax) * -1 AS tax FROM\n                 (SELECT ROUND(SUM(taxdetail_tax), 2) AS tax\n                  FROM tax\n                   JOIN calculateTaxDetailSummary('CM', <? value("cmhead_id") ?>, 'T') ON (taxdetail_tax_id=tax_id)\n                  GROUP BY tax_id) AS data), 0) AS tax_in_cmcurr,\n       ccard_id, ccard_seq, ccpay_id,\n       cohead_number\nFROM ccard, cmitem, cmhead LEFT OUTER JOIN\n     rahead ON (cmhead_rahead_id=rahead_id) LEFT OUTER JOIN\n     cohead ON (rahead_orig_cohead_id=cohead_id) LEFT OUTER JOIN\n     ccpay  ON (ccpay_order_number=cohead_number AND ccpay_type='C')\nWHERE ((cmitem_cmhead_id=cmhead_id)\n  AND  (cmhead_cust_id=ccard_cust_id)\n  AND  (ccard_active)\n  AND  (ccpay_ccard_id=ccard_id OR ccpay_ccard_id IS NULL)\n  AND  (cmhead_id=<? value("cmhead_id") ?>))\nGROUP BY cmhead_number, cmhead_curr_id, cmhead_freight,\n         cmhead_misc, ccard_id, ccard_seq, ccpay_id,\n\t cohead_number\nORDER BY ccpay_id DESC, ccard_seq \nLIMIT 1;\n     admin   2014-10-06      0
101115
 
114     crm     strictcountrycheck       select details about countries used throughout the database\n        that do not match country.country_name\n\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: crm\n-- Name:  strictcountrycheck\n-- Notes: select details about countries used throughout the database\n--        that do not match country.country_name\n--\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("count") ?>\nSELECT SUM(counter) AS counter FROM (\n<? endif ?>\n  SELECT <? if exists("count") ?> COUNT(*) AS counter\n         <? else ?> addr_id, 'Address' AS type, addr_number AS number, addr_country AS country, '' AS detail\n         <? endif ?>\n    FROM addr\n   WHERE addr_country != ''\n     AND addr_country NOT IN (SELECT country_name\n                                FROM country\n                               WHERE country_name IS NOT NULL)\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> cmhead_id, 'Credit Memo', cmhead_number, cmhead_billtocountry, 'Bill-To'\n         <? endif ?>\n    FROM cmhead\n   WHERE cmhead_billtocountry != ''\n     AND cmhead_billtocountry NOT IN (SELECT country_name\n                                        FROM country\n                                       WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (NOT cmhead_posted) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> cmhead_id, 'Credit Memo', cmhead_number, cmhead_billtocountry, 'Ship-To'\n         <? endif ?>\n    FROM cmhead\n    WHERE cmhead_shipto_country != ''\n      AND cmhead_shipto_country NOT IN (SELECT country_name\n                                          FROM country\n                                         WHERE country_name IS NOT NULL)\n      <? if not exists("showAll") ?> AND (NOT cmhead_posted) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> invchead_id, 'Invoice', invchead_invcnumber, invchead_billto_country, 'Bill-To'\n         <? endif ?>\n    FROM invchead\n   WHERE invchead_billto_country != ''\n     AND invchead_billto_country NOT IN (SELECT country_name\n                                           FROM country\n                                          WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (NOT invchead_posted) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> invchead_id, 'Invoice', invchead_invcnumber, invchead_shipto_country, 'Ship-To'\n         <? endif ?>\n    FROM invchead\n   WHERE invchead_shipto_country != ''\n     AND invchead_shipto_country NOT IN (SELECT country_name\n                                           FROM country\n                                          WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (NOT invchead_posted) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> quhead_id, 'Quote', quhead_number, quhead_billtocountry, 'Bill-To'\n         <? endif ?>\n    FROM quhead\n   WHERE quhead_billtocountry != ''\n     AND quhead_billtocountry NOT IN (SELECT country_name\n                                        FROM country\n                                       WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (quhead_expire>=CURRENT_DATE) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> quhead_id, 'Quote', quhead_number, quhead_shiptocountry, 'Ship-To'\n         <? endif ?>\n    FROM quhead\n   WHERE quhead_shiptocountry != ''\n     AND quhead_shiptocountry NOT IN (SELECT country_name\n                                        FROM country\n                                       WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (quhead_expire>=CURRENT_DATE) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> cohead_id, 'Sales Order', cohead_number, cohead_billtocountry, 'Bill-To'\n         <? endif ?>\n    FROM cohead\n   WHERE cohead_billtocountry != ''\n     AND cohead_billtocountry NOT IN (SELECT country_name\n                                        FROM country\n                                       WHERE country_name IS NOT NULL)\n    <? if not exists("showAll") ?>\n     AND cohead_id IN (SELECT coitem_cohead_id\n                         FROM coitem\n                        WHERE COALESCE(coitem_status, 'O')='O')\n    <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> cohead_id, 'Sales Order', cohead_number, cohead_shiptocountry, 'Ship-To'\n         <? endif ?>\n    FROM cohead\n   WHERE cohead_shiptocountry != ''\n     AND cohead_shiptocountry NOT IN (SELECT country_name\n                                       FROM country\n                                      WHERE country_name IS NOT NULL)\n    <? if not exists("showAll") ?>\n     AND cohead_id IN (SELECT coitem_cohead_id\n                         FROM coitem\n                        WHERE COALESCE(coitem_status, 'O')='O')\n    <? endif ?>\n\n<? if exists("count") ?>\n) AS dummy;\n<? endif ?>\n    admin   2014-10-06      0
101116
 
447     crmaccountmerge pickdatasources  Show the records the user has selected to merge crm accounts. Emphasize\n        the particular fields in each record that s/he has selected.\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: crmaccountmerge\n-- Name:  pickdatasources\n-- Notes: Show the records the user has selected to merge crm accounts. Emphasize\n--        the particular fields in each record that s/he has selected.\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT c.crmacct_id,\n       crmacctsel_dest_crmacct_id,\n       c.crmacct_active,\n       formatCntctName(c.crmacct_cntct_id_1) AS primary,\n       formatCntctName(c.crmacct_cntct_id_2) AS secondary,\n       c.crmacct_competitor_id IS NOT NULL   AS competitor,\n       c.crmacct_cust_id       IS NOT NULL   AS cust,\n       c.crmacct_emp_id        IS NOT NULL   AS emp,\n       c.crmacct_name,\n       c.crmacct_number,\n       c.crmacct_owner_username              AS owner,\n       p.crmacct_number                      AS parent,\n       c.crmacct_partner_id    IS NOT NULL   AS partner,\n       c.crmacct_prospect_id   IS NOT NULL   AS prospect,\n       c.crmacct_salesrep_id   IS NOT NULL   AS salesrep,\n       c.crmacct_taxauth_id    IS NOT NULL   AS taxauth,\n       c.crmacct_type,\n       c.crmacct_usr_username  IS NOT NULL   AS usr,\n       c.crmacct_vend_id       IS NOT NULL   AS vend,\n       trim(firstline(c.crmacct_notes))      AS notes,\n\n       CASE crmacctsel_src_crmacct_id=crmacctsel_dest_crmacct_id\n            WHEN true THEN '#ccc'\n       END AS qtbackgroundrole,\n\n       CASE WHEN c.crmacct_active IS NULL THEN <? value('na') ?> END AS crmacct_active_qtdisplayrole,\n       CASE WHEN COALESCE(formatCntctName(c.crmacct_cntct_id_1), '') = '' THEN <? value('na') ?> END AS primary_qtdisplayrole,\n       CASE WHEN COALESCE(formatCntctName(c.crmacct_cntct_id_2), '') = '' THEN <? value('na') ?> END AS secondary_qtdisplayrole,\n       CASE WHEN COALESCE(c.crmacct_name,           '') = '' THEN <? value('na') ?>  END AS crmacct_name_qtdisplayrole,\n       CASE WHEN COALESCE(c.crmacct_number,         '') = '' THEN <? value('na') ?>  END AS crmacct_number_qtdisplayrole,\n       CASE WHEN COALESCE(c.crmacct_owner_username, '') = '' THEN <? value('na') ?>  END AS owner_qtdisplayrole,\n       CASE WHEN COALESCE(p.crmacct_number,         '') = '' THEN <? value('na') ?>  END AS parent_qtdisplayrole,\n       CASE c.crmacct_type WHEN 'I' THEN <? value('individual') ?>\n                           WHEN 'O' THEN <? value('organization') ?>\n                           ELSE <? value('na') ?> END AS crmacct_type_qtdisplayrole,\n       CASE WHEN COALESCE(TRIM(firstline(c.crmacct_notes)), '') = '' THEN <? value('na') ?> END AS notes_qtdisplayrole,\n\n       CASE WHEN crmacctsel_mrg_crmacct_number         THEN 'emphasis' END AS crmacct_number_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_active         THEN 'emphasis' END AS crmacct_active_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_cntct_id_1     THEN 'emphasis' END AS primary_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_cntct_id_2     THEN 'emphasis' END AS secondary_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_competitor_id  THEN 'emphasis' END AS competitor_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_cust_id        THEN 'emphasis' END AS cust_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_emp_id         THEN 'emphasis' END AS emp_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_name           THEN 'emphasis' END AS crmacct_name_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_owner_username THEN 'emphasis' END AS owner_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_parent_id      THEN 'emphasis' END AS parent_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_partner_id     THEN 'emphasis' END AS partner_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_prospect_id    THEN 'emphasis' END AS prospect_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_salesrep_id    THEN 'emphasis' END AS salesrep_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_taxauth_id     THEN 'emphasis' END AS taxauth_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_type           THEN 'emphasis' END AS crmacct_type_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_usr_username   THEN 'emphasis' END AS usr_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_vend_id        THEN 'emphasis' END AS vend_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_notes          THEN 'emphasis' END AS notes_qtforegroundrole,\n\n       c.crmacct_cntct_id_1   AS primary_xtidrole,\n       c.crmacct_cntct_id_2   AS secondary_xtidrole,\n       c.crmacct_cust_id      AS cust_xtidrole,\n       c.crmacct_emp_id       AS emp_xtidrole,\n       c.crmacct_parent_id    AS parent_xtidrole,\n       c.crmacct_prospect_id  AS prospect_xtidrole,\n       c.crmacct_salesrep_id  AS salesrep_xtidrole,\n       c.crmacct_taxauth_id   AS taxauth_xtidrole,\n       c.crmacct_usr_username AS usr_xtidrole,\n       c.crmacct_vend_id      AS vend_xtidrole,\n\n       c.crmacct_notes AS notes_qttooltiprole\n\n  FROM crmacct c\n  JOIN crmacctsel ON (c.crmacct_id=crmacctsel_src_crmacct_id)\n  LEFT OUTER JOIN crmacct p ON (c.crmacct_parent_id=p.crmacct_id)\n WHERE crmacctsel_dest_crmacct_id=<? value('destid') ?>\n ORDER BY qtbackgroundrole DESC, c.crmacct_number;\n      admin   2014-10-06      0
101117
 
448     crmaccountmerge wip      show an indented list of crm account merges that have\n        data to purge. this includes those that have been started\n        but not completed as well as those that have been completed\n        but neither purged nor undone.\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: crmaccountmerge\n-- Name:  wip\n-- Notes: show an indented list of crm account merges that have\n--        data to purge. this includes those that have been started\n--        but not completed as well as those that have been completed\n--        but neither purged nor undone.\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n       d.crmacct_id,     d.crmacct_id,\n       d.crmacct_number, d.crmacct_name,\n       d.crmacct_number AS destnumber,\n       <? value('mergedKey') ?>    AS status,\n       <? value('mergedParent') ?> AS status_qtdisplayrole,\n       0 AS xtindentrole\n  FROM crmacct d\n  JOIN mrgundo ON (d.crmacct_id=mrgundo_base_id\n               AND mrgundo_base_schema='public'\n               AND mrgundo_base_table='crmacct')\n<? if exists('destid') ?>\n WHERE d.crmacct_id = <? value("destid") ?>\n<? endif ?>\nUNION ALL\nSELECT s.crmacct_id,     d.crmacct_id,\n       s.crmacct_number, s.crmacct_name,\n       d.crmacct_number AS destnumber,\n       <? value('mergedKey') ?> AS status,\n       <? value('merged') ?>    AS status_qtdisplayrole,\n<? if exists('sourceAccountOnly') ?>\n       0\n<? else ?>\n       1\n<? endif ?>\n  FROM crmacct s\n  JOIN mrgundo ON (mrgundo_schema='public'\n               AND mrgundo_table='crmacct'\n               AND mrgundo_pkey_col='crmacct_id'\n               AND mrgundo_pkey_id=s.crmacct_id\n               AND mrgundo_col IS NULL)\n  JOIN crmacct d ON (mrgundo_base_id=d.crmacct_id\n                 AND mrgundo_base_schema='public')\n<? if exists('destid') ?>\n WHERE d.crmacct_id = <? value("destid") ?>\n<? endif ?>\nUNION\nSELECT s.crmacct_id,     d.crmacct_id,\n       s.crmacct_number, s.crmacct_name,\n       d.crmacct_number AS destnumber, \n       <? value('selectedKey') ?> AS status,\n       <? value('selected') ?>    AS status_qtdisplayrole,\n       CASE WHEN s.crmacct_id=d.crmacct_id THEN 0\n            ELSE 1\n       END\n  FROM crmacct d\n  JOIN crmacctsel ON (d.crmacct_id=crmacctsel_dest_crmacct_id)\n  JOIN crmacct s  ON (crmacctsel_src_crmacct_id=s.crmacct_id)\n<? if exists('destid') ?>\n WHERE d.crmacct_id = <? value("destid") ?>\n<? endif ?>\n\nORDER BY destnumber, xtindentrole, crmacct_number;\n       admin   2014-10-06      0
101118
 
239     crmaccounts     detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: crmaccounts\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (crmacct_number)\n  crmacct_id AS id, crmacct_number, crmacct_name, crmacct_owner_username,\n  cntct.*, addr.*,\n  (crmacct_cust_id       IS NOT NULL) AS cust,\n  (crmacct_prospect_id   IS NOT NULL) AS prospect,\n  (crmacct_vend_id       IS NOT NULL) AS vend,\n  (crmacct_competitor_id IS NOT NULL) AS competitor,\n  (crmacct_partner_id    IS NOT NULL) AS partner,\n  (crmacct_taxauth_id    IS NOT NULL) AS taxauth,\n  (crmacct_usr_username  IS NOT NULL) AS usr,\n  (crmacct_emp_id        IS NOT NULL) AS emp,\n  (crmacct_salesrep_id   IS NOT NULL) AS salesrep\n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\nFROM crmacct() LEFT OUTER JOIN\n  cntct ON (crmacct_cntct_id_1=cntct_id) LEFT OUTER JOIN\n  addr ON (cntct_addr_id=addr_id) \n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='CRMACCT') \n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=crmacct_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='CRMACCT') \n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=crmacct_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='CRMACCT') \n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=crmacct_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE true\n<? if exists("owner_username") ?> \n  AND (crmacct_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (crmacct_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\n<? if not exists("showInactive") ?> \n  AND crmacct_active \n<? endif ?>\n<? if exists("search_pattern") ?>\n  AND ((crmacct_number ~* <? value("search_pattern") ?>)\n       OR (crmacct_name ~* <? value("search_pattern") ?>)\n       OR (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(cntct_email,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_city,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_state,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_postalcode,'') ~* <? value("search_pattern") ?>)\n       OR (addr_country ~* <? value("search_pattern") ?>))\n<? endif ?>\n<? if exists("crmacct_number_pattern") ?>\n  AND (crmacct_number ~* <? value("crmacct_number_pattern") ?>)\n<? endif ?>\n<? if exists("crmacct_name_pattern") ?>\n  AND (crmacct_name ~* <? value("crmacct_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_name_pattern") ?>\n  AND (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* <? value("cntct_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_phone_pattern") ?>\n  AND (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* <? value("cntct_phone_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_email_pattern") ?>\n  AND (COALESCE(cntct_email,'') ~* <? value("cntct_email_pattern") ?>)\n<? endif ?>\n<? if exists("addr_street_pattern") ?>\n  AND (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* <? value("addr_street_pattern") ?>)\n<? endif ?>\n<? if exists("addr_city_pattern") ?>\n  AND (COALESCE(addr_city,'') ~* <? value("addr_city_pattern") ?>)\n<? endif ?>\n<? if exists("addr_state_pattern") ?>\n  AND (COALESCE(addr_state,'') ~* <? value("addr_state_pattern") ?>)\n<? endif ?>\n<? if exists("addr_postalcode_pattern") ?>\n  AND (COALESCE(addr_postalcode,'') ~* <? value("addr_postalcode_pattern") ?>)\n<? endif ?>\n<? if exists("addr_country_pattern") ?>\n  AND (COALESCE(addr_country,'') ~* <? value("addr_country_pattern") ?>)\n<? endif ?>\n<? if exists("id") ?>\n  AND (crmacct_id=<? value("id") ?>)\n<? endif ?>\n<? literal("charClause") ?>\n\n<? if exists("excludeMergeWIP") ?>\n  AND (crmacct_id NOT IN (SELECT mrgundo_base_id\n                            FROM mrgundo\n                           WHERE (mrgundo_base_schema='public')\n                             AND (mrgundo_base_table='crmacct')\n                          UNION\n                          SELECT crmacctsel_src_crmacct_id\n                            FROM crmacctsel\n                          UNION\n                          SELECT crmacctsel_dest_crmacct_id\n                            FROM crmacctsel))\n<? endif ?>\nORDER BY crmacct_number; \n admin   2014-10-06      0
101119
 
95      currencyConversions     detail   used by currencyConversions\n        the N in round(curr_rate, N) has to be SCALE - 1 of curr_rates\n        NUMERIC(p, SCALE) type definition\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: currencyConversions\n-- Name: detail\n-- Notes: used by currencyConversions\n--        the N in round(curr_rate, N) has to be SCALE - 1 of curr_rates\n--        NUMERIC(p, SCALE) type definition\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT curr_rate_id, currConcat(curr_id) AS f_curr,\n<? if exists("invert") ?>\n       round((1.0 / curr_rate),5) AS rate,\n<? else ?>\n       round(curr_rate,5) AS rate,\n<? endif ?>\n       'uomratio' AS rate_xtnumericrole,\n       curr_effective, curr_expires\nFROM curr_symbol NATURAL JOIN curr_rate\nWHERE ( (curr_base = FALSE)\n  AND   (curr_expires >= <? value("startDate") ?>)\n  AND   (curr_effective <= <? value("endDate") ?>)\n<? if exists("curr_id") ?>\n  AND   (curr_id = <? value("curr_id") ?>)\n<? endif ?>\n<? if exists("currConcat_pattern") ?>\n  AND   (currConcat(curr_id) ~ <? value("currConcat_pattern") ?>)\n<? endif ?>\n      )\nORDER BY f_curr, curr_effective, curr_expires;\n    admin   2014-10-06      0
101120
 
242     customers       detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: customers\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON ( cust_number ) \n  cust_id, cust_custtype_id, \n  cust_active, cust_number, cust_name,\n  custtype_code,\n  bill_cntct.cntct_first_name AS bill_first_name,\n  bill_cntct.cntct_last_name AS bill_last_name,\n  bill_cntct.cntct_title AS bill_title,\n  bill_cntct.cntct_phone AS bill_phone,\n  bill_cntct.cntct_fax AS bill_fax,\n  bill_cntct.cntct_email AS bill_email,\n  bill_addr.addr_line1 AS bill_line1,\n  bill_addr.addr_line2 AS bill_line2,\n  bill_addr.addr_line3 AS bill_line3,\n  bill_addr.addr_city AS bill_city,\n  bill_addr.addr_state AS bill_state,\n  bill_addr.addr_postalcode AS bill_postalcode,\n  bill_addr.addr_country AS bill_country,\n  corr_cntct.cntct_first_name AS corr_first_name,\n  corr_cntct.cntct_last_name AS corr_last_name,\n  corr_cntct.cntct_phone AS corr_phone,\n  corr_cntct.cntct_fax AS corr_fax,\n  corr_cntct.cntct_email AS corr_email,\n  corr_addr.addr_line1 AS corr_line1,\n  corr_addr.addr_line2 AS corr_line2,\n  corr_addr.addr_line3 AS corr_line3,\n  corr_addr.addr_city AS corr_city,\n  corr_addr.addr_state AS corr_state,\n  corr_addr.addr_postalcode AS corr_postalcode,\n  corr_addr.addr_country AS corr_country\n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\nFROM custinfo\n  JOIN custtype ON (cust_custtype_id=custtype_id)\n  LEFT OUTER JOIN cntct bill_cntct ON (cust_cntct_id=bill_cntct.cntct_id) \n  LEFT OUTER JOIN addr bill_addr ON (bill_cntct.cntct_addr_id=bill_addr.addr_id)\n  LEFT OUTER JOIN cntct corr_cntct ON (cust_corrcntct_id=corr_cntct.cntct_id) \n  LEFT OUTER JOIN addr corr_addr ON (corr_cntct.cntct_addr_id=corr_addr.addr_id)\n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='C') \n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=cust_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='C') \n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=cust_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='C') \n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=cust_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE true\n<? if not exists("showInactive") ?> \n  AND cust_active \n<? endif ?>\n<? if exists("search_pattern") ?>\n  AND ((cust_number ~* <? value("search_pattern") ?>)\n       OR (cust_name ~* <? value("search_pattern") ?>)\n       OR (custtype_code ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_cntct.cntct_first_name,'') || ' ' || COALESCE(bill_cntct.cntct_last_name,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_cntct.cntct_phone,'') || ' ' || COALESCE(bill_cntct.cntct_phone2,'') || ' ' || COALESCE(bill_cntct.cntct_fax, '') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_cntct.cntct_email, '') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_line1,'') || ' ' || COALESCE(bill_addr.addr_line2,'') || ' ' || COALESCE(bill_addr.addr_line3,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_city,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_state,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_postalcode,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_country,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_cntct.cntct_first_name,'') || ' ' || COALESCE(corr_cntct.cntct_last_name,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_cntct.cntct_phone,'') || ' ' || COALESCE(corr_cntct.cntct_phone2,'') || ' ' || COALESCE(corr_cntct.cntct_fax, '') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_cntct.cntct_email, '') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_line1,'') || ' ' || COALESCE(corr_addr.addr_line2,'') || ' ' || COALESCE(corr_addr.addr_line3,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_city,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_state,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_postalcode,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_country,'') ~* <? value("search_pattern") ?>))\n<? endif ?>\n<? if exists("cust_number_pattern") ?>\n  AND (cust_number ~* <? value("cust_number_pattern") ?>)\n<? endif ?>\n<? if exists("cust_name_pattern") ?>\n  AND (cust_name ~* <? value("cust_name_pattern") ?>)\n<? endif ?>\n<? if exists("custtype_code_pattern") ?>\n  AND (custtype_code ~* <? value("custtype_code_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_name_pattern") ?>\n  AND (COALESCE(bill_cntct.cntct_first_name,'') || ' ' || COALESCE(bill_cntct.cntct_last_name, '') ~* <? value("cntct_name_pattern") ?> \n   OR  COALESCE(corr_cntct.cntct_first_name,'') || ' ' || COALESCE(corr_cntct.cntct_last_name, '') ~* <? value("cntct_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_phone_pattern") ?>\n  AND (COALESCE(bill_cntct.cntct_phone,'') || ' ' || COALESCE(bill_cntct.cntct_phone2,'') || ' ' || COALESCE(bill_cntct.cntct_fax,'') ~* <? value("cntct_phone_pattern") ?>\n   OR  COALESCE(corr_cntct.cntct_phone,'') || ' ' || COALESCE(corr_cntct.cntct_phone2,'') || ' ' || COALESCE(corr_cntct.cntct_fax,'') ~* <? value("cntct_phone_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_email_pattern") ?>\n  AND (COALESCE(bill_cntct.cntct_email,'') ~* <? value("cntct_email_pattern") ?>\n   OR  COALESCE(corr_cntct.cntct_email,'') ~* <? value("cntct_email_pattern") ?>)\n<? endif ?>\n<? if exists("addr_street_pattern") ?>\n  AND (COALESCE(bill_addr.addr_line1,'') || ' ' || COALESCE(bill_addr.addr_line2,'') || ' ' || COALESCE(bill_addr.addr_line3,'') ~* <? value("addr_street_pattern") ?>\n   OR  COALESCE(corr_addr.addr_line1,'') || ' ' || COALESCE(corr_addr.addr_line2,'') || ' ' || COALESCE(corr_addr.addr_line3,'') ~* <? value("addr_street_pattern") ?>)\n<? endif ?>\n<? if exists("addr_city_pattern") ?>\n  AND (COALESCE(bill_addr.addr_city,'') ~* <? value("addr_city_pattern") ?>\n   OR  COALESCE(corr_addr.addr_city,'') ~* <? value("addr_city_pattern") ?>)\n<? endif ?>\n<? if exists("addr_state_pattern") ?>\n  AND (COALESCE(bill_addr.addr_state,'') ~* <? value("addr_state_pattern") ?>\n   OR  COALESCE(corr_addr.addr_state,'') ~* <? value("addr_state_pattern") ?>)\n<? endif ?>\n<? if exists("addr_postalcode_pattern") ?>\n  AND (COALESCE(bill_addr.addr_postalcode,'') ~* <? value("addr_postalcode_pattern") ?>\n   OR  COALESCE(corr_addr.addr_postalcode,'') ~* <? value("addr_postalcode_pattern") ?>)\n<? endif ?>\n<? if exists("addr_country_pattern") ?>\n  AND (COALESCE(bill_addr.addr_country,'') ~* <? value("addr_country_pattern") ?>\n   OR  COALESCE(corr_addr.addr_country,'') ~* <? value("addr_country_pattern") ?>)\n<? endif ?>\n<? if exists("salesrep_id") ?>\n  AND (cust_salesrep_id = <? value("salesrep_id") ?>)\n<? endif ?>\n<? literal("charClause") ?>\nORDER BY cust_number; \n        admin   2014-10-06      0
101121
 
439     customers       statement        used by printStatementsByCustomerType\nSELECT cust_id, (cust_number || '-' || cust_name) AS customer,\n       findCustomerForm(cust_id, 'S') AS reportname\nFROM\n<? if exists("asofDate") ?>\n  (SELECT araging_cust_id FROM araging(<? value ("asofDate") ?>, true))AS data,\n<? endif ?>\n  custinfo, custtype, aropen\nWHERE (cust_custtype_id=custtype_id)\n AND (aropen_cust_id=cust_id)\n AND (aropen_open)\n<? if exists("graceDays") ?>\n AND (aropen_duedate < (CURRENT_DATE - <? value ("graceDays") ?>))\n<? endif ?>\n<? if exists("custtype_id") ?>\n AND (custtype_id=<? value ("custtype_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n AND (custtype_code ~ <? value ("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("asofDate") ?>\n AND (cust_id = araging_cust_id)\n<? endif ?>\nGROUP BY cust_id, cust_number, cust_name\nHAVING (SUM((aropen_amount - aropen_paid) *\n             CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1\n                  ELSE 1 END) > 0)\nORDER BY cust_number;\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: customers\n-- Name:  statement\n-- Notes: used by printStatementsByCustomerType\n--SELECT cust_id, (cust_number || '-' || cust_name) AS customer,\n--       findCustomerForm(cust_id, 'S') AS reportname\n--FROM\n--<? if exists("asofDate") ?>\n--  (SELECT araging_cust_id FROM araging(<? value ("asofDate") ?>, true))AS data,\n--<? endif ?>\n--  custinfo, custtype, aropen\n--WHERE (cust_custtype_id=custtype_id)\n-- AND (aropen_cust_id=cust_id)\n-- AND (aropen_open)\n--<? if exists("graceDays") ?>\n-- AND (aropen_duedate < (CURRENT_DATE - <? value ("graceDays") ?>))\n--<? endif ?>\n--<? if exists("custtype_id") ?>\n-- AND (custtype_id=<? value ("custtype_id") ?>)\n--<? elseif exists("custtype_pattern") ?>\n-- AND (custtype_code ~ <? value ("custtype_pattern") ?>)\n--<? endif ?>\n--<? if exists("asofDate") ?>\n-- AND (cust_id = araging_cust_id)\n--<? endif ?>\n--GROUP BY cust_id, cust_number, cust_name\n--HAVING (SUM((aropen_amount - aropen_paid) *\n--             CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1\n--                  ELSE 1 END) > 0)\n--ORDER BY cust_number;\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT araging_cust_id AS cust_id,\n       (araging_cust_number || '-' || araging_cust_name) AS customer,\n       findCustomerForm(araging_cust_id, 'S') AS reportname\nFROM araging(<? value ("asofDate") ?>, true)\nWHERE (true)\n<? if exists("graceDays") ?>\n AND (COALESCE(araging_duedate, startOfTime()) < (CURRENT_DATE - <? value ("graceDays") ?>))\n<? endif ?>\n<? if exists("custtype_id") ?>\n AND (araging_cust_custtype_id=<? value ("custtype_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n AND (araging_custtype_code ~ <? value ("custtype_pattern") ?>)\n<? endif ?>\nGROUP BY araging_cust_id, araging_cust_number, araging_cust_name\nORDER BY araging_cust_number;\n    admin   2014-10-06      0
101122
 
243     depositesRegister       detail   used by dspDepositsRegister\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: depositesRegister\n-- Name: detail\n-- Notes: used by dspDepositsRegister\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT trans_id, trans_date, trans_source,\n       CASE WHEN (trans_doctype='IN') THEN <? value("invoice") ?>\n            WHEN (trans_doctype='CM') THEN <? value("creditmemo") ?>\n         ELSE trans_doctype\n       END AS doctype,\n       trans_docnumber, firstLine(trans_notes) AS f_notes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS f_accnt,\n       CASE WHEN (trans_amount < 0) THEN formatMoney(ABS(trans_amount))\n         ELSE ''\n       END AS f_debit,\n       CASE WHEN (trans_amount < 0) THEN ABS(trans_amount)\n         ELSE 0\n       END AS debit,\n       CASE WHEN (trans_amount > 0) THEN trans_amount\n         ELSE 0\n       END AS credit,\n       (aropen_amount - aropen_paid) AS balance,\n       currtobase(aropen_curr_id,(aropen_amount - aropen_paid),aropen_docdate) AS base_balance,\n       currconcat(aropen_curr_id) AS currAbbr,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS debit_xttotalrole,\n       0 AS credit_xttotalrole,\n       0 AS base_balance_xttotalrole\nFROM (\nSELECT gltrans_id AS trans_id, gltrans_date AS trans_date, gltrans_created AS trans_created,\n       gltrans_source AS trans_source, gltrans_doctype AS trans_doctype, gltrans_sequence AS trans_sequence,\n       gltrans_docnumber AS trans_docnumber, gltrans_notes AS trans_notes, gltrans_amount AS trans_amount,\n       accnt_id, accnt_descrip,\n       aropen_amount, aropen_paid, aropen_curr_id, aropen_docdate\nFROM gltrans LEFT OUTER JOIN aropen ON ((text(gltrans_docnumber) = 'I-' || text(aropen_docnumber))\n                                    AND (aropen_doctype='I')), accnt\nWHERE ((gltrans_accnt_id=accnt_id)\n   AND (gltrans_doctype = 'CR')\n   AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) )\nUNION\nSELECT sltrans_id AS trans_id, sltrans_date AS trans_date, sltrans_created AS trans_created,\n       sltrans_source AS trans_source, sltrans_doctype AS trans_doctype, sltrans_sequence AS trans_sequence,\n       sltrans_docnumber AS trans_docnumber, sltrans_notes AS trans_notes, sltrans_amount AS trans_amount,\n       accnt_id, accnt_descrip,\n       aropen_amount, aropen_paid, aropen_curr_id, aropen_docdate\nFROM sltrans LEFT OUTER JOIN aropen ON ((text(sltrans_docnumber) = 'I-' || text(aropen_docnumber))\n                                    AND (aropen_doctype='I')), accnt\nWHERE ((sltrans_accnt_id=accnt_id)\n   AND (sltrans_doctype = 'CR')\n   AND (sltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) )\n     ) AS data\nORDER BY trans_created DESC, trans_sequence, trans_amount;\n        admin   2014-10-06      0
101123
 
118     distributeInventory     locations        \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: distributeInventory\n-- Name: locations\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT id, type, locationname, defaultlocation,\n           location_netable, location_usable, lotserial, f_expiration, expired,\n           qty, qtytagged, (qty + qtytagged) AS balance,\n           'qty' AS qty_xtnumericrole,\n           'qty' AS qtytagged_xtnumericrole,\n           'qty' AS balance_xtnumericrole,\n           CASE WHEN expired THEN 'error' END AS qtforegroundrole, \n           CASE WHEN defaultlocation AND expired = false THEN 'altemphasis' \n                WHEN expired THEN 'error' \n                ELSE null END AS defaultlocation_qtforegroundrole, \n           CASE WHEN expired THEN 'error' \n                WHEN qty > 0 AND expired = false THEN 'altemphasis' \n                ELSE null END AS qty_qtforegroundrole \nFROM ( \n  <? if exists("cNoIncludeLotSerial") ?>\n    SELECT location_id AS id, <? value("locationType") ?> AS type,\n           formatLocationName(location_id) AS locationname,\n           CASE WHEN (<? value("transtype") ?> = 'R' AND location_id=itemsite_recvlocation_id) THEN TRUE\n                WHEN (<? value("transtype") ?> = 'I' AND location_id=itemsite_issuelocation_id) THEN TRUE\n                WHEN (<? value("transtype") ?> = 'O' AND location_id=itemsite_location_id) THEN TRUE\n                ELSE FALSE\n           END AS defaultlocation,\n           COALESCE(location_netable, true) AS location_netable,\n           COALESCE(location_usable, true) AS location_usable,\n           TEXT('') AS lotserial,\n           TEXT(<? value("na") ?>) AS f_expiration, FALSE AS expired,\n           qtyLocation(location_id, NULL, NULL, NULL,\n                       itemsite_id, itemlocdist_order_type, itemlocdist_order_id, itemlocdist_id) AS qty,\n           itemlocdistQty(location_id, itemlocdist_id) AS qtytagged \n    FROM itemlocdist, location, itemsite \n    WHERE ( (itemlocdist_itemsite_id=itemsite_id)\n      AND (itemsite_loccntrl)\n      AND (itemsite_warehous_id=location_warehous_id)\n      AND (validLocation(location_id, itemsite_id))\n      AND (itemlocdist_id=<? value("itemlocdist_id") ?>) ) \n  <? elseif exists("cIncludeLotSerial") ?>\n    SELECT itemloc_id AS id, <? value("itemlocType") ?> AS type,\n           COALESCE(formatLocationName(location_id),\n           <? value("undefined") ?>) AS locationname,\n           (location_id IS NOT NULL AND\n             CASE WHEN (<? value("transtype") ?> = 'R' AND location_id=itemsite_recvlocation_id) THEN TRUE\n                  WHEN (<? value("transtype") ?> = 'I' AND location_id=itemsite_issuelocation_id) THEN TRUE\n                  WHEN (<? value("transtype") ?> = 'O' AND location_id=itemsite_location_id) THEN TRUE\n                  ELSE FALSE\n             END) AS defaultlocation,\n           COALESCE(location_netable, true) AS location_netable,\n           COALESCE(location_usable, true) AS location_usable,\n           ls_number AS lotserial,\n           CASE WHEN (itemsite_perishable) THEN formatDate(itemloc_expiration)\n                ELSE <? value("na") ?>\n           END AS f_expiration,\n           CASE WHEN (itemsite_perishable) THEN (itemloc_expiration < CURRENT_DATE)\n                ELSE FALSE \n           END AS expired,\n           qtyLocation(itemloc_location_id, itemloc_ls_id, itemloc_expiration,\n                       itemloc_warrpurc, itemsite_id, itemlocdist_order_type,\n                       itemlocdist_order_id, itemlocdist_id) AS qty,\n           ( SELECT COALESCE(SUM(target.itemlocdist_qty), 0)\n             FROM itemlocdist AS target\n             WHERE ( (target.itemlocdist_source_type='I')\n               AND (target.itemlocdist_source_id=itemloc_id)\n               AND (target.itemlocdist_itemlocdist_id=source.itemlocdist_id)) ) AS qtytagged \n    FROM itemlocdist AS source, itemsite, itemloc \n         LEFT OUTER JOIN location ON (itemloc_location_id=location_id) \n         LEFT OUTER JOIN ls ON (itemloc_ls_id=ls_id) \n   WHERE ( (source.itemlocdist_itemsite_id=itemsite_id)\n     AND (itemloc_itemsite_id=itemsite_id)\n     AND (source.itemlocdist_id=<? value("itemlocdist_id") ?>) ) \n    UNION \n    SELECT location_id AS id, <? value("locationType") ?> AS type,\n           formatLocationName(location_id) AS locationname,\n           CASE WHEN (<? value("transtype") ?> = 'R' AND location_id=itemsite_recvlocation_id) THEN TRUE\n                WHEN (<? value("transtype") ?> = 'I' AND location_id=itemsite_issuelocation_id) THEN TRUE\n                WHEN (<? value("transtype") ?> = 'O' AND location_id=itemsite_location_id) THEN TRUE\n                ELSE FALSE\n           END AS defaultlocation,\n           COALESCE(location_netable, true) AS location_netable,\n           COALESCE(location_usable, true) AS location_usable,\n           TEXT('') AS lotserial,\n           TEXT(<? value("na") ?>) AS f_expiration, FALSE AS expired,\n           qtyLocation(location_id, NULL, NULL, NULL,\n                       itemsite_id, itemlocdist_order_type, itemlocdist_order_id, itemlocdist_id) AS qty,\n           itemlocdistQty(location_id, itemlocdist_id) AS qtytagged \n    FROM itemlocdist, location, itemsite \n    WHERE ( (itemlocdist_itemsite_id=itemsite_id)\n      AND (itemsite_loccntrl)\n      AND (itemsite_warehous_id=location_warehous_id)\n      AND (validLocation(location_id, itemsite_id))\n      AND (itemsite_id=<? value("itemsite_id") ?> ) \n      AND (location_id NOT IN (SELECT DISTINCT itemloc_location_id\n                               FROM itemloc\n                               WHERE (itemloc_itemsite_id=itemsite_id)))\n      AND (itemlocdist_id=<? value("itemlocdist_id") ?>) ) \n  <? endif ?>\n  ) AS data \nWHERE ((TRUE) \n   AND ( (<? value("transtype") ?> != 'I') OR (<? value("transtype") ?> = 'I' AND location_usable) )\n<? if exists("showOnlyTagged") ?>\n  AND (qtytagged != 0) \n<? endif ?>\n<? if exists("showQtyOnly") ?>\n  AND (qty > 0) \n<? endif ?>\n) ORDER BY locationname;\n  admin   2014-10-06      0
101124
 
465     employees       detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: employees\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT emp_id, warehous_code, emp_active, emp_code, emp_number,\n  cntct_first_name, cntct_last_name\n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\nFROM emp\n  LEFT OUTER JOIN cntct ON (emp_cntct_id=cntct_id)\n  LEFT OUTER JOIN whsinfo ON (emp_warehous_id=warehous_id)\n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='EMP') \n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=emp_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='EMP') \n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=emp_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='EMP') \n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=emp_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE (true)\n<? if exists("warehous_id") ?>\n  AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("activeOnly") ?> \n  AND emp_active \n<? endif ?>\n<? if exists("search_pattern") ?>\n  AND ((emp_code ~* <? value("search_pattern") ?>)\n       OR (emp_number ~* <? value("search_pattern") ?>)\n       OR (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(cntct_email,'') ~* <? value("search_pattern") ?>))\n<? endif ?>\n<? literal("charClause") ?>\nORDER BY emp_code;\n       admin   2014-10-06      0
101125
 
50      events  detail   used by eventManager\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: events\n-- Name: detail\n-- Notes: used by eventManager\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT evntlog_id, evntlog_ord_id, evntlog_newdate,\n       evntlog_newvalue, warehous_code,\n       evntlog_evnttime,\n       evntlog_dispatched,\n       evnttype_name, evntlog_number \n  FROM evnttype, evntlog LEFT OUTER JOIN whsinfo ON (evntlog_warehous_id=warehous_id)\nWHERE ( (evntlog_evnttype_id=evnttype_id)\n AND (evntlog_username=<? value("username") ?>)\n<? if exists("warehous_id") ?>\n AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if not exists("showAcknowledged") ?>\n AND (evntlog_dispatched IS NULL)\n<? endif ?>\n) \nORDER BY evntlog_evnttime;\n       admin   2014-10-06      0
101126
 
245     expiredInventory        detail   used by dspExpiredInventoryByClassCode\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: expiredInventory\n-- Name: detail\n-- Notes: used by dspExpiredInventoryByClassCode\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, itemloc_id, warehous_code, item_number, uom_name,\n       ls_number, itemloc_expiration,\n       itemloc_qty, costmethod, cost,\n       noNeg(cost * itemloc_qty) AS value,\n       'qty' AS itemloc_qty_xtnumericrole,\n       'cost' AS cost_xtnumericrole,\n       'curr' AS value_xtnumericrole,\n       'red' AS qtforegroundrole \nFROM ( SELECT itemsite_id, itemloc_id, warehous_code, item_number,\n              uom_name, ls_number,\n              CASE WHEN <? value("expiretype") ?>='Perishability' THEN \n                   itemloc_expiration\n                ELSE itemloc_warrpurc\n              END AS itemloc_expiration,\n              itemloc_qty,\n              CASE WHEN(itemsite_costmethod='A') THEN 'Average'\n                   WHEN(itemsite_costmethod='S') THEN 'Standard'\n                   WHEN(itemsite_costmethod='J') THEN 'Job'\n                   WHEN(itemsite_costmethod='N') THEN 'None'\n                ELSE 'UNKNOWN'\n              END AS costmethod,\n            <? if exists("useStandardCosts") ?>\n              stdcost(itemsite_item_id) AS cost\n            <? elseif exists("useActualCosts") ?>\n              actcost(itemsite_item_id) AS cost\n            <? else ?>\n              (itemsite_value / CASE WHEN(itemsite_qtyonhand=0) THEN 1 ELSE itemsite_qtyonhand END) AS cost\n            <? endif ?>\n       FROM itemloc, itemsite, item, whsinfo, uom, ls\n       WHERE ((itemloc_itemsite_id=itemsite_id)\n          AND (itemsite_item_id=item_id)\n          AND (item_inv_uom_id=uom_id)\n          AND (itemsite_warehous_id=warehous_id)\n          AND (itemloc_ls_id=ls_id)\n        <? if exists("perishability") ?>\n          AND (itemsite_perishable)\n          AND (itemloc_expiration < (CURRENT_DATE + <? value("thresholdDays") ?>))\n        <? else ?>\n          AND (itemsite_warrpurc)\n          AND (itemloc_warrpurc < (CURRENT_DATE + <? value("thresholdDays") ?>))\n        <? endif ?>\n        <? if exists("warehous_id") ?>\n          AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n        <? endif ?>\n        <? if exists("classcode_id") ?>\n          AND (item_classcode_id=<? value("classcode_id") ?>)\n        <? elseif exists("classcode_pattern") ?>\n          AND (item_classcode_id IN (SELECT classcode_id\n                                     FROM classcode\n                                     WHERE classcode_code ~ <? value("classcode_pattern") ?>))\n        <? endif ?>\n             )\n     ) AS data\nORDER BY warehous_code, item_number;\n    admin   2014-10-06      0
101127
 
246     freightPrices   detail   used by dspFreightPricesByCustomer, dspFreightPricesByCustomerType\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: freightPrices\n-- Name: detail\n-- Notes: used by dspFreightPricesByCustomer, dspFreightPricesByCustomerType\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemid, sourcetype, ipshead_name, source, ipsfreight_qtybreak, ipsfreight_price,\n       CASE WHEN (ipsfreight_type = 'F') THEN <? value("flatrate") ?>\n         ELSE <? value("peruom") ?>\n       END AS method,\n       currConcat(ipshead_curr_id) AS currConcat,\n       warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia,\n       'qty' AS ipsfreight_qtybreak_xtnumericrole,\n       <? value("na") ?> AS ipsfreight_qtybreak_xtnullrole,\n       'salesprice' AS ipsfreight_price_xtnumericrole,\n       <? value("any") ?> AS warehous_code_xtnullrole,\n       <? value("any") ?> AS shipzone_name_xtnullrole,\n       <? value("any") ?> AS freightclass_code_xtnullrole,\n       <? value("any") ?> AS ipsfreight_shipvia_xtnullrole\nFROM (SELECT ipsfreight_id AS itemid, 1 AS sourcetype,\n             ipshead_name,\n<? if exists("byCust") ?>\n             <? value("customer") ?> AS source,\n<? elseif exists("byCustType") ?>\n             <? value("custType") ?> AS source,\n<? endif ?>\n             ipsfreight_qtybreak, ipsfreight_price,\n             ipsfreight_type, ipshead_curr_id,\n             warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\n      FROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n           JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n           LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n           LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n           LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\n      WHERE ((true)\n<? if exists("byCust") ?>\n         AND (ipsass_cust_id=<? value("cust_id") ?>)\n         AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0)\n<? elseif exists("byCustType") ?>\n         AND (ipsass_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n            )\n\n      UNION\n\n      SELECT ipsfreight_id AS itemid, 2 AS sourcetype,\n             ipshead_name,\n<? if exists("byCust") ?>\n             <? value("custType") ?> AS source,\n<? elseif exists("byCustType") ?>\n             <? value("custTypePattern") ?> AS source,\n<? endif ?>\n             ipsfreight_qtybreak, ipsfreight_price,\n             ipsfreight_type, ipshead_curr_id,\n             warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\n      FROM ipsass\n<? if exists("byCustType") ?>\n           JOIN custtype ON ((coalesce(length(ipsass_custtype_pattern), 0) > 0) AND\n                                         (custtype_code ~ ipsass_custtype_pattern))\n<? endif ?>\n           JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n           JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n<? if exists("byCust") ?>\n           JOIN custinfo ON (cust_custtype_id=ipsass_custtype_id)\n<? endif ?>\n           LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n           LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n           LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\n      WHERE ((true)\n<? if exists("byCust") ?>\n         AND (cust_id=<? value("cust_id") ?>)\n<? elseif exists("byCustType") ?>\n         AND (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n            )\n\n      UNION\n\n      SELECT ipsfreight_id AS itemid, 3 AS sourcetype,\n             ipshead_name,\n<? if exists("byCust") ?>\n             <? value("custTypePattern") ?> AS source,\n<? elseif exists("byCustType") ?>\n             (<? value("sale") ?> || '-' || sale_name) AS source,\n<? endif ?>\n             ipsfreight_qtybreak, ipsfreight_price,\n             ipsfreight_type, ipshead_curr_id,\n             warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\n      FROM\n<? if exists("byCust") ?>\n           custinfo JOIN custtype ON (custtype_id=cust_custtype_id)\n                JOIN ipsass ON ((coalesce(length(ipsass_custtype_pattern), 0) > 0) AND\n                                (custtype_code ~ ipsass_custtype_pattern))\n                JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n<? elseif exists("byCustType") ?>\n           sale JOIN ipshead ON (ipshead_id=sale_ipshead_id)\n<? endif ?>\n                JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n                LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n                LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n                LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\n      WHERE ((true)\n<? if exists("byCust") ?>\n         AND (cust_id=<? value("cust_id") ?>)\n<? elseif exists("byCustType") ?>\n         AND (true)\n<? endif ?>\n<? if not exists("showExpired") ?>\n  <? if exists("byCust") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n  <? elseif exists("byCustType") ?>\n         AND (sale_enddate > CURRENT_DATE)\n  <? endif ?>\n<? endif ?>\n<? if not exists("showFuture") ?>\n  <? if exists("byCust") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n  <? elseif exists("byCustType") ?>\n         AND (sale_startdate <= CURRENT_DATE)\n  <? endif ?>\n<? endif ?>\n            )\n\n<? if exists("byCust") ?>\n      UNION\n\n      SELECT ipsfreight_id AS itemid, 4 AS sourcetype,\n             ipshead_name, (<? value("sale") ?> || '-' || sale_name) AS source,\n             ipsfreight_qtybreak, ipsfreight_price,\n             ipsfreight_type, ipshead_curr_id,\n             warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\n      FROM sale JOIN ipshead ON (ipshead_id=sale_ipshead_id)\n                JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n                LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n                LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n                LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\n      WHERE ((true)\n  <? if not exists("showExpired") ?>\n         AND (sale_enddate > CURRENT_DATE)\n  <? endif ?>\n  <? if not exists("showFuture") ?>\n         AND (sale_startdate <= CURRENT_DATE)\n  <? endif ?>\n            )\n<? endif ?>\n     ) AS data\nORDER BY ipsfreight_qtybreak, ipsfreight_price;\n  admin   2014-10-06      0
101128
 
247     frozenItemSites detail   used by dspFrozenItemSites\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: frozenItemSites\n-- Name: detail\n-- Notes: used by dspFrozenItemSites\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, warehous_code, item_number,\n        (item_descrip1 || ' ' || item_descrip2) AS descrip,\n        COALESCE((SELECT invcnt_tagnumber\n                  FROM invcnt\n                  WHERE ((NOT invcnt_posted)\n                          AND (invcnt_itemsite_id=itemsite_id)) LIMIT 1), '') AS cnttag\nFROM itemsite, item, whsinfo\nWHERE ( (itemsite_item_id=item_id)\n    AND (itemsite_warehous_id=warehous_id)\n    AND (itemsite_freeze)\n<? if exists("warehous_id") ?>\n    AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nORDER BY warehous_code, item_number;\n    admin   2014-10-06      0
101129
 
133     gltransactions  detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: gltransactions\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_id, gltrans_accnt_id,gltrans_date,gltrans_created,gltrans_source,\n       gltrans_doctype,gltrans_journalnumber,gltrans_posted,gltrans_username,\n       CASE WHEN(gltrans_docnumber='Misc.' AND\n              invhist_docnumber IS NOT NULL) THEN\n              (gltrans_docnumber || ' - ' || invhist_docnumber)\n            ELSE gltrans_docnumber\n       END AS docnumber,\n       firstLine(gltrans_notes) AS notes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       CASE WHEN (gltrans_amount < 0) THEN ABS(gltrans_amount)\n            ELSE NULL\n       END AS debit,\n       CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n            ELSE NULL\n       END AS credit,\n       CASE WHEN accnt_type IN ('A','E') THEN \n         gltrans_amount * -1 \n       ELSE gltrans_amount END AS running,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       'curr' AS running_xtnumericrole,\n       0 AS running_xtrunningrole,\n       gltrans_deleted AS xtdeletedrole,\n<? value("beginningBalance") ?> AS running_xtrunninginit \nFROM gltrans JOIN accnt ON (gltrans_accnt_id=accnt_id) \n     LEFT OUTER JOIN invhist ON (gltrans_misc_id=invhist_id\n                            AND gltrans_docnumber='Misc.') \n<? if exists("company_id") ?>\n     JOIN company ON (accnt_company=company_number) \n<? endif ?>\n<? if exists("prfcntr_id") ?>\n     JOIN prftcntr ON (accnt_profit=prftcntr_number) \n<? endif ?>\n<? if exists("subaccnt_id") ?>\n     JOIN subaccnt ON (accnt_sub=subaccnt_number) \n<? endif ?>\n<? if exists("subType") ?>\n     JOIN subaccnttype ON (subaccnttype_code=accnt_subaccnttype_code) \n<? endif ?>\nWHERE (\n<? if exists("startDate") ?>\n  <? if exists("endDate") ?>\n       (gltrans_date BETWEEN <? value("startDate") ?>\n                         AND <? value("endDate") ?>)\n  <? else ?>\n       (gltrans_date BETWEEN <? value("startDate") ?>\n                         AND endoftime())\n  <? endif ?>\n<? else ?>\n  <? if exists("endDate") ?>\n       (gltrans_date BETWEEN startoftime()\n                         AND <? value("endDate") ?>)\n  <? else ?>\n       (gltrans_date BETWEEN startoftime()\n                         AND endoftime())\n  <? endif ?>\n<? endif ?>\n<? if not exists("showDeleted") ?>\n   AND (NOT gltrans_deleted)\n<? endif ?>\n<? if exists("company_id") ?>\n   AND (company_id=<? value("company_id") ?>)\n<? endif ?>\n<? if exists("prfcntr_id") ?>\n   AND (prftcntr_id=<? value("prfcntr_id") ?>)\n<? endif ?>\n<? if exists("accnt_number") ?>\n   AND (accnt_number=<? value("accnt_number") ?>)\n<? endif ?>\n<? if exists("subaccnt_id") ?>\n   AND (subaccnt_id=<? value("subaccnt_id") ?>)\n<? endif ?>\n<? if exists("subType") ?>\n   AND (subaccnttype_id=<? value("subType") ?>)\n<? endif ?>\n<? if exists("accntType") ?>\n   AND (accnt_type= <? value("accntType") ?>)\n<? endif ?>\n<? if exists("accnt_id") ?>\n   AND (gltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n<? if exists("docnum") ?>\n   AND (gltrans_docnumber = case when <? value("docnum") ?> = '' then \n gltrans_docnumber else \n<? value("docnum") ?> end ) \n<? endif ?>\n<? if exists("source") ?>\n   AND (gltrans_source=<? value("source") ?>)\n<? endif ?>\n) \nORDER BY\n<? if exists("beginningBalance") ?>\n   gltrans_date,\n<? else ?>\n   gltrans_created DESC,\n<? endif ?>\n   gltrans_sequence, gltrans_amount;\n        admin   2014-10-06      0
101130
 
100     incidents       detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: incidents \n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (incdt_number) incdt_id AS id,\nincdt_number, DATE(incdt_timestamp) AS incdt_timestamp,\ncrmacct_name,\nincdtcat_name, incdtseverity_name,  \nincdtpriority_name, crmacct_name, \nCASE WHEN(incdt_status='N') THEN <? value("new") ?>\nWHEN(incdt_status='F') THEN <? value("feedback") ?>\nWHEN(incdt_status='C') THEN <? value("confirmed") ?>\nWHEN(incdt_status='A') THEN <? value("assigned") ?>\nWHEN(incdt_status='R') THEN <? value("resolved") ?>\nWHEN(incdt_status='L') THEN <? value("closed") ?>\nELSE incdt_status\nEND,\nincdt_assigned_username, incdt_owner_username,\nincdt_summary, cntct_name, incdt_updated::date AS incdt_updated,\nprj_number, incdt_public,\nitem_number,\n<? if exists("LotSerialControl") ?>\nls_number,\n<? endif ?>\nstatus_color AS qtbackgroundrole \n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\nFROM crmacct, status, incdt()\n  JOIN cntct ON (incdt_cntct_id=cntct_id)\n  LEFT OUTER JOIN incdtcat ON (incdtcat_id=incdt_incdtcat_id) \n  LEFT OUTER JOIN incdtseverity ON (incdtseverity_id=incdt_incdtseverity_id) \n  LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=incdt_incdtpriority_id) \n  LEFT OUTER JOIN prj ON (incdt_prj_id=prj_id)\n  LEFT OUTER JOIN item ON (item_id=incdt_item_id)\n<? if exists("LotSerialControl") ?>\n  LEFT OUTER JOIN ls ON (ls_id=incdt_ls_id)\n<? endif ?>\n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='INCDT') \n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=incdt_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='INCDT') \n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=incdt_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='INCDT') \n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=incdt_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE ((incdt_crmacct_id=crmacct_id)\nAND (status_type='INCDT')\nAND (incdt_status=status_code)\n<? if exists("statuslist") ?>\nAND (status_seq IN (-1\n  <? foreach("statuslist") ?> , <? value("statuslist") ?> <? endforeach ?>\n  ))\n<? endif ?>\n<? if exists("status_equal") ?> \nAND (status_seq = <? value("status_equal") ?>) \n<? endif ?>\n<? if exists("status_above") ?> \nAND (status_seq < <? value("status_above") ?>) \n<? endif ?>\n<? if exists("cntct_id") ?> \nAND (incdt_cntct_id = <? value("cntct_id") ?>) \n<? endif ?>\n<? if exists("username") ?>\nAND (<? value("username") ?> IN (incdt_assigned_username, incdt_owner_username))\n<? endif ?>\n<? if exists("owner_username") ?> \nAND (incdt_owner_username=<? value("owner_username") ?>) \n<? endif ?>\n<? if exists("owner_usr_pattern" ?>\nAND (incdt_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\n<? if exists("assigned_username") ?> \nAND (incdt_assigned_username=<? value("assigned_username") ?>) \n<? endif ?>\n<? if exists("assigned_usr_pattern" ?>\nAND (incdt_assigned_username ~ <? value("assigned_usr_pattern") ?>) \n<? endif ?>\n<? if exists("incdtpriority_id_list") ?>\nAND (incdt_incdtpriority_id IN (-1\n  <? foreach("incdtpriority_id_list") ?> , <? value("incdtpriority_id_list") ?> <? endforeach ?>\n  ))\n<? endif ?>\n<? if exists("categorylist") ?>\nAND (incdt_incdtcat_id IN (-1\n  <? foreach("categorylist") ?> , <? value("categorylist") ?> <? endforeach ?>\n  ))\n<? endif ?>\n<? if exists("category_id") ?> \nAND (incdt_incdtcat_id=<? value("category_id") ?>) \n<? endif ?> \n<? if exists("severity_id") ?> \nAND (incdt_incdtseverity_id=<? value("severity_id") ?>) \n<? endif ?>\n<? if exists("crmAccountId") ?> \nAND (incdt_crmacct_id=<? value("crmAccountId") ?>) \n<? endif ?> \n<? if exists("prj_id") ?> \nAND (incdt_prj_id=<? value("prj_id") ?>) \n<? endif ?> \n<? if exists("public") ?> \nAND (incdt_public=<? value("public") ?>) \n<? endif ?> \n)\n \n<? if exists("search_pattern") ?> \nAND ((incdt_number::text ~* <? value("search_pattern") ?>)\nOR (incdt_summary ~* <? value("search_pattern") ?>)\nOR (incdt_descrip ~* <? value("search_pattern") ?>)\nOR (incdt_id IN (SELECT comment_source_id\nFROM comment\nWHERE((comment_source='INCDT')\nAND (comment_text ~* <? value("search_pattern") ?>)))))\n<? endif ?>\n<? if exists("item_id") ?>\nAND (incdt_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("lspattern") ?>\nAND (ls_number ~* <? value("lspattern") ?>)\n<? endif ?>\n<? if exists("id") ?>\nAND (incdt_id=<? value("id") ?>)\n<? endif ?>\nAND (incdt_timestamp BETWEEN COALESCE(<? value("startDate") ?>, startOfTime()) AND COALESCE(<? value("endDate") ?>, endOfTime())+1) \n<? literal("charClause") ?>\nORDER BY incdt_number;\n       admin   2014-10-06      0
101131
 
252     invalidBillsofMaterials detail   used by dspInvalidBillsOfMaterials\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: invalidBillsofMaterials\n-- Name: detail\n-- Notes: used by dspInvalidBillsOfMaterials\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, parent.item_id AS pitem_id,\n       component.item_id AS citem_id,\n       warehous_id, warehous_code,\n       parent.item_number AS parentitem,\n       component.item_number AS componentitem,\n       (component.item_descrip1 || ' ' || component.item_descrip2) AS descrip\nFROM bomitem, itemsite, item AS parent, item AS component, whsinfo\nWHERE ((bomitem_parent_item_id=parent.item_id)\n   AND (bomitem_item_id=component.item_id)\n   AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1))\n   AND (itemsite_item_id=parent.item_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (parent.item_type='M')\n   AND (itemsite_wosupply)\n   AND (itemsite_active)\n   AND (component.item_id NOT IN ( SELECT itemsite_item_id\n                                   FROM itemsite\n                                   WHERE ((itemsite_warehous_id=warehous_id)\n                                      AND (itemsite_active)) ) ) \n<? if exists("warehous_id") ?>\n   AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nORDER BY warehous_code, parentitem, componentitem;\n       admin   2014-10-06      0
101132
 
52      inventoryAvailability   general  \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: inventoryAvailability\n-- Name:  general\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, altId,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       uom_name,\n       warehous_id, warehous_code, itemsite_leadtime,\n       qoh, allocated, noNeg(qoh - allocated) AS unallocated, \n       ordered, requests, reorderlevel, outlevel,\n       (qoh - allocated + ordered) AS available,\n       vend_number,\n       'qty' AS qoh_xtnumericrole,\n       'qty' AS allocated_xtnumericrole,\n       'qty' AS unallocated_xtnumericrole,       \n       'qty' AS ordered_xtnumericrole,\n       'qty' AS requests_xtnumericrole,\n       'qty' AS reorderlevel_xtnumericrole,\n       'qty' AS outlevel_xtnumericrole,\n       'qty' AS available_xtnumericrole,\n       <? if exists("byDates") ?>\n         'grey' AS qoh_qtforegroundrole,\n       <? endif ?>\n       CASE WHEN ((qoh - allocated + ordered) < 0) THEN 'error'\n            WHEN ((qoh - allocated + ordered) <= reorderlevel) THEN 'warning'\n       END AS available_qtforegroundrole\nFROM (SELECT \n           <? if reExists("[vV]end") ?>\n             DISTINCT\n           <? endif ?>\n             itemsite_id,\n             CASE WHEN (item_type IN ('P', 'O')) THEN 1\n                  WHEN (item_type IN ('M')) THEN 2\n                  ELSE 0\n             END AS altId,\n             item_number, item_descrip1, item_descrip2, item_inv_uom_id,\n             warehous_id, warehous_code, itemsite_leadtime,\n             qtyAvailable(itemsite_id) AS qoh,\n             CASE WHEN itemsite_useparams THEN itemsite_reorderlevel\n                  ELSE 0.0\n             END AS reorderlevel,\n             CASE WHEN itemsite_useparams THEN itemsite_ordertoqty\n                  ELSE 0.0\n             END AS outlevel,\n             <? if exists("byVend") ?>\n               vend_number,\n             <? else ?>\n               NULL AS vend_number,\n             <? endif ?>\n             <? if exists("byLeadTime") ?>\n               qtyAllocated(itemsite_id, itemsite_leadtime) AS allocated,\n               qtyOrdered(itemsite_id,   itemsite_leadtime) AS ordered, \n               qtypr(itemsite_id,   itemsite_leadtime) AS requests\n             <? elseif exists("byDays") ?>\n               qtyAllocated(itemsite_id, CAST(<? value("byDays") ?> AS INTEGER)) AS allocated,\n               qtyOrdered(itemsite_id,   CAST(<? value("byDays") ?> AS INTEGER)) AS ordered,\n               qtypr(itemsite_id,   CAST(<? value("byDays") ?> AS INTEGER)) AS requests  \n             <? elseif exists("byDate") ?>\n               qtyAllocated(itemsite_id, (<? value("byDate") ?> - CURRENT_DATE)) AS allocated,\n               qtyOrdered(itemsite_id,   (<? value("byDate") ?> - CURRENT_DATE)) AS ordered,\n               qtypr(itemsite_id,   (<? value("byDate") ?> - CURRENT_DATE)) AS requests \n             <? elseif exists("byDates") ?>\n               qtyAllocated(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS allocated,\n               qtyOrdered(itemsite_id,   <? value("startDate") ?>, <? value("endDate") ?>) AS ordered,\n               qtypr(itemsite_id,   <? value("startDate") ?>, <? value("endDate") ?>) AS requests\n             <? endif ?>\n      FROM item, itemsite, whsinfo\n           <? if reExists("[vV]end") ?>\n             , vendinfo JOIN itemsrc ON (itemsrc_vend_id=vend_id)\n           <? endif ?>\n      WHERE ( (itemsite_active)\n          AND (itemsite_item_id=item_id)\n          AND (itemsite_warehous_id=warehous_id)\n          <? if exists("warehous_id") ?>\n            AND (warehous_id=<? value("warehous_id") ?>)\n          <? endif ?>\n          <? if exists("item_id") ?>\n            AND (item_id=<? value("item_id") ?>)\n          <? elseif exists("classcode_id") ?>\n            AND (item_classcode_id=<? value("classcode_id") ?>)\n          <? elseif exists("classcode_pattern") ?>\n            AND (item_classcode_id IN (SELECT classcode_id\n                                       FROM classcode\n                                       WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n          <? elseif exists("plancode_id") ?>\n            AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n          <? elseif exists("plancode_pattern") ?>\n            AND (itemsite_plancode_id IN (SELECT plancode_id\n                                          FROM plancode\n                                          WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n          <? elseif exists("itemgrp_id") ?>\n            AND (item_id IN (SELECT itemgrpitem_item_id\n                             FROM itemgrpitem\n                             WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n          <? elseif exists("itemgrp_pattern") ?>\n            AND (item_id IN (SELECT itemgrpitem_item_id\n                             FROM itemgrpitem, itemgrp\n                             WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n                                    AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>) ) ))\n          <? elseif exists("itemgrp") ?>\n            AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n          <? endif ?>\n          <? if reExists("[vV]end") ?>\n            AND (itemsrc_item_id=item_id)\n          <? endif ?>\n          <? if exists("vend_id") ?>\n            AND (vend_id=<? value("vend_id") ?>)\n          <? elseif exists("vendtype_id") ?>\n            AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n          <? elseif exists("vendtype_pattern") ?>\n            AND (vend_vendtype_id IN (SELECT vendtype_id\n                                      FROM vendtype\n                                      WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n          <? endif ?>\n      ) ) AS data, uom\nWHERE ((item_inv_uom_id=uom_id)\n<? if exists("showReorder") ?>\n  AND ((qoh - allocated + ordered) <= reorderlevel) \n  <? if exists("ignoreReorderAtZero") ?>\n    AND NOT ( ((qoh - allocated + ordered) = 0) AND (reorderlevel = 0))\n  <? endif ?>\n<? elseif exists("showShortages") ?>\n  AND ((qoh - allocated + ordered) < 0) \n<? endif ?>\n)\n\nORDER BY\n<? if exists("ListNumericItemNumbersFirst") ?>\n  toNumeric(item_number, 999999999999999),\n<? elseif exists("byVend") ?>\n  vend_number,\n<? endif ?>\n  item_number, warehous_code DESC;\n admin   2014-10-06      0
101133
 
253     inventoryAvailabilitybyWorkorder        detail   used by dspInventoryAvailabilityByWorkOrder\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: inventoryAvailabilitybyWorkorder\n-- Name: detail\n-- Notes: used by dspInventoryAvailabilityByWorkOrder\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *, 'qty' AS woinvav_qoh_xtnumericrole,\n       'qty' AS woinvav_balance_xtnumericrole,\n       'qty' AS woinvav_allocated_xtnumericrole,\n       'qty' AS woinvav_ordered_xtnumericrole,\n       'qty' AS woinvav_woavail_xtnumericrole,\n       'qty' AS woinvav_totalavail_xtnumericrole,\n       CASE WHEN (woinvav_womatl_id) = -1 THEN 'altemphasis'\n            WHEN (woinvav_qoh < 0) THEN 'error'\n            WHEN (woinvav_qoh < woinvav_reorderlevel) THEN 'warning'\n            WHEN ((woinvav_qoh - woinvav_balance) < 0) THEN 'altemphasis'\n            WHEN ((woinvav_qoh - woinvav_allocated) < 0) THEN 'altemphasis'\n       END AS woinvav_qoh_qtforegroundrole,\n       CASE WHEN (woinvav_womatl_id) = -1 THEN 'altemphasis'\n            WHEN ((woinvav_qoh + woinvav_ordered - woinvav_balance) < 0) THEN 'error'\n            WHEN ((woinvav_qoh + woinvav_ordered - woinvav_balance) < woinvav_reorderlevel) THEN 'warning'\n       END AS woinvav_woavail_qtforegroundrole,\n       CASE WHEN (woinvav_womatl_id) = -1 THEN 'altemphasis'\n            WHEN ((woinvav_qoh + woinvav_ordered - woinvav_allocated) < 0) THEN 'error'\n            WHEN ((woinvav_qoh + woinvav_ordered - woinvav_allocated) < woinvav_reorderlevel) THEN 'warning'\n       END AS woinvav_totalavail_qtforegroundrole,\n       CASE WHEN (woinvav_womatl_id = -1) THEN 'altemphasis'\n         ELSE null\n       END AS qtforegroundrole,\n       woinvav_level AS xtindentrole\nFROM woinvavail(<? value("wo_id") ?>,\n<? if exists("IndentedParentChild") ?>\n                true,\n<? else ?>\n                false,\n<? endif ?>\n<? if exists("summarizedParentChild") ?>\n                true,\n<? else ?>\n                false,\n<? endif ?>\n<? if exists("onlyShowShortages") ?>\n                true,\n<? else ?>\n                false,\n<? endif ?>\n<? if exists("onlyShowInsufficientInventory") ?>\n                true\n<? else ?>\n                false\n<? endif ?>\n               ) AS data;\n     admin   2014-10-06      0
101134
 
254     inventoryLocator        detail   used by dspInventoryLocator\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n Lot/Serial Characteristics additions by Specter Vision Solutions, Inc.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: inventoryLocator\n-- Name: detail\n-- Notes: used by dspInventoryLocator\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- Lot/Serial Characteristics additions by Specter Vision Solutions, Inc.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       <? value("na") ?> AS locationname_xtnullrole,\n       <? value("na") ?> AS netable_xtnullrole,\n       <? value("na") ?> AS usable_xtnullrole,\n       <? value("na") ?> AS lotserial_xtnullrole,\n       <? value("na") ?> AS expiration_xtnullrole,\n       <? value("na") ?> AS warranty_xtnullrole,\n       CASE WHEN (itemsite_perishable\n                  AND itemloc_expiration <= CURRENT_DATE) THEN 'error'\n            WHEN (itemsite_warrpurc\n                  AND itemloc_warrpurc <= CURRENT_DATE) THEN 'error'\n       END AS qtforegroundrole,\n       'qty' AS qoh_xtnumericrole\nFROM (SELECT itemloc_id, 1 AS type, warehous_code,\n             itemsite_perishable, itemloc_expiration,\n             itemsite_warrpurc, itemloc_warrpurc,\n             CASE WHEN (location_id IS NOT NULL) THEN\n                        (formatLocationName(location_id) || '-' || firstLine(location_descrip))\n             END AS locationname,\n             CASE WHEN (location_id IS NOT NULL) THEN location_netable\n             END AS netable,\n             CASE WHEN (location_id IS NOT NULL) THEN location_usable\n             END AS usable,\n             CASE WHEN (itemsite_controlmethod IN ('L', 'S')) THEN\n                        formatlotserialnumber(itemloc_ls_id)\n             END AS lotserial,\n             CASE WHEN (itemsite_perishable) THEN itemloc_expiration\n             END AS expiration,\n             CASE WHEN (itemsite_warrpurc) THEN itemloc_warrpurc\n             END AS warranty,\n             itemloc_qty AS qoh\n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , CASE WHEN (charass_alias<? literal("char_id_date_list") ?>.charass_value = '') THEN NULL::date\n         ELSE charass_alias<? literal("char_id_date_list") ?>.charass_value::date \n    END AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\n      FROM itemsite, whsinfo,\n           itemloc LEFT OUTER JOIN location ON (itemloc_location_id=location_id)\n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='LS')\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=itemloc_ls_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='LS')\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=itemloc_ls_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='LS')\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=itemloc_ls_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\n      WHERE ((itemsite_loccntrl OR (itemsite_controlmethod IN ('L', 'S')))\n         AND (itemloc_itemsite_id=itemsite_id)\n         AND (itemsite_warehous_id=warehous_id)\n         AND (itemsite_item_id=<? value("item_id") ?>)\n      <? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n      <? endif ?>\n      <? if exists("site") ?>\n         AND (itemsite_warehous_id=<? value("site")?>)\n      <? endif ?>\n      <? if exists("lot_serial") ?>\n         AND (formatlotserialnumber(itemloc_ls_id)=<? value("lot_serial")?>)\n      <? endif ?>\n      <? if exists("_location_name") ?>\n         AND (formatLocationName(location_id)=<? value("_location_name")?>)\n      <? endif ?>\n      <? literal("charClause") ?>\n            )\n      UNION\n      SELECT itemsite_id, 2 AS type, warehous_code,\n             itemsite_perishable, NULL AS itemloc_expiration,\n             itemsite_warrpurc, NULL AS itemloc_warrpurc,\n             NULL AS locationname,\n             NULL AS netable,\n             NULL AS usable,\n             NULL AS lotserial,\n             NULL AS expiration,\n             NULL AS warranty,\n             itemsite_qtyonhand AS qoh\n<? foreach("char_id_text_list" ?>\n          , NULL AS char<? value("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list" ?>\n          , NULL AS char<? value("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list" ?>\n          , NULL AS char<? value("char_id_date_list") ?>\n<? endforeach ?>\n      FROM itemsite, whsinfo\n      WHERE ((NOT itemsite_loccntrl)\n         AND (itemsite_controlmethod NOT IN ('L', 'S'))\n         AND (itemsite_warehous_id=warehous_id)\n         AND (itemsite_item_id=<? value("item_id") ?>)\n      <? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n      <? endif ?>\n            )\n     ) AS dummy\nORDER BY warehous_code, locationname, lotserial;\n     admin   2014-10-06      0
101135
 
255     invoiceInformation      detail   used by dspInvoiceInformation\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: invoiceInformation\n-- Name: detail\n-- Notes: used by dspInvoiceInformation\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT arapply_id,\n       CASE WHEN (arapply_source_doctype = 'C') THEN <? value("creditMemo") ?>\n            WHEN (arapply_source_doctype = 'R') THEN <? value("cashdeposit") ?>\n            WHEN (arapply_fundstype='C') THEN <? value("check") ?>\n            WHEN (arapply_fundstype='T') THEN <? value("certifiedCheck") ?>\n            WHEN (arapply_fundstype='M') THEN <? value("masterCard") ?>\n            WHEN (arapply_fundstype='V') THEN <? value("visa") ?>\n            WHEN (arapply_fundstype='A') THEN <? value("americanExpress") ?>\n            WHEN (arapply_fundstype='D') THEN <? value("discoverCard") ?>\n            WHEN (arapply_fundstype='R') THEN <? value("otherCreditCard") ?>\n            WHEN (arapply_fundstype='K') THEN <? value("cash") ?>\n            WHEN (arapply_fundstype='W') THEN <? value("wireTransfer") ?>\n            WHEN (arapply_fundstype='O') THEN <? value("other") ?>\n       END AS doctype,\n       CASE WHEN (arapply_source_doctype IN ('C','R')) THEN arapply_source_docnumber\n            WHEN (arapply_source_doctype = 'K') THEN arapply_refnumber\n         ELSE <? value("error") ?>\n       END AS docnumber,\n       arapply_postdate, arapply_applied,\n       currConcat(arapply_curr_id) AS currabbr,\n       currToBase(arapply_curr_id, arapply_applied, arapply_postdate) AS baseapplied,\n       'curr' AS arapply_applied_xtnumericrole,\n       'curr' AS baseapplied_xtnumericrole\nFROM arapply\nWHERE ((arapply_target_doctype='I')\n   AND (arapply_target_docnumber=<? value("aropen_docnumber") ?>))\nORDER BY arapply_postdate;\n   admin   2014-10-06      0
101136
 
256     invoiceRegister detail   used by dspInvoiceRegister\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: invoiceRegister\n-- Name: detail\n-- Notes: used by dspInvoiceRegister\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT *\nFROM (\n-- G/L Transactions\nSELECT DISTINCT\n       -1 AS gltrans_id, -1 AS altId,\n       gltrans_date,  '' AS gltrans_source,\n       '' AS doctype, '' AS gltrans_docnumber,\n       '' AS notes,   '' AS account,\n       CAST(NULL AS NUMERIC) AS debit,\n       CAST(NULL AS NUMERIC) AS credit,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       0 AS xtindentrole,\n       gltrans_date AS transdate\nFROM gltrans\nWHERE ((gltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n   AND (gltrans_source = 'A/R')\n   AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("accnt_id") ?>\n   AND (gltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n      )\n\nUNION\n-- Journals\nSELECT DISTINCT\n       -1 AS gltrans_id, -1 AS altId,\n       sltrans_date AS gltrans_date,  '' AS gltrans_source,\n       '' AS doctype, '' AS gltrans_docnumber,\n       '' AS notes,   '' AS account,\n       CAST(NULL AS NUMERIC) AS debit,\n       CAST(NULL AS NUMERIC) AS credit,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       0 AS xtindentrole,\n       sltrans_date AS transdate\nFROM sltrans\nWHERE ((sltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n   AND (sltrans_source = 'A/R')\n   AND (sltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("accnt_id") ?>\n   AND (sltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n      )\n) AS data\n\nUNION\n-- G/L Transactions\nSELECT gltrans_id,\n       CASE WHEN(gltrans_doctype='IN') THEN 1\n            WHEN(gltrans_doctype='CM') THEN 2\n            WHEN(gltrans_doctype='DM') THEN 3\n            WHEN(gltrans_doctype='CD') THEN 4\n         ELSE -1\n       END AS altId,\n       gltrans_date, gltrans_source,\n       CASE WHEN(gltrans_doctype='IN') THEN <? value("invoice") ?>\n            WHEN(gltrans_doctype='CM') THEN <? value("creditmemo") ?>\n            WHEN(gltrans_doctype='DM') THEN <? value("debitmemo") ?>\n            WHEN(gltrans_doctype='CD') THEN <? value("cashdeposit") ?>\n         ELSE gltrans_doctype\n       END AS doctype,\n       gltrans_docnumber,\n       CASE WHEN(gltrans_doctype='IN') THEN\n                 (SELECT invchead_shipto_name\n                  FROM aropen LEFT OUTER JOIN\n                       invchead\n                       ON (invchead_id=aropen_cobmisc_id\n                       AND invchead_cust_id=aropen_cust_id)\n                  WHERE ((aropen_docnumber=gltrans_docnumber)\n                     AND (aropen_doctype='I')))\n         ELSE firstLine(gltrans_notes)\n       END AS f_notes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS f_accnt,\n       CASE WHEN (gltrans_amount < 0) THEN ABS(gltrans_amount)\n         ELSE 0\n       END AS debit,\n       CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n         ELSE 0\n       END AS credit,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       1 AS xtindentrole,\n       NULL AS transdate\nFROM gltrans, accnt\nWHERE ((gltrans_accnt_id=accnt_id)\n   AND (gltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n   AND (gltrans_source = 'A/R')\n   AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("accnt_id") ?>\n   AND (gltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n   )\n\nUNION\n-- Journals\nSELECT sltrans_id,\n       CASE WHEN(sltrans_doctype='IN') THEN 1\n            WHEN(sltrans_doctype='CM') THEN 2\n            WHEN(sltrans_doctype='DM') THEN 3\n            WHEN(sltrans_doctype='CD') THEN 4\n         ELSE -1\n       END AS altId,\n       sltrans_date AS gltrans_date, sltrans_source AS gltrans_date,\n       CASE WHEN(sltrans_doctype='IN') THEN <? value("invoice") ?>\n            WHEN(sltrans_doctype='CM') THEN <? value("creditmemo") ?>\n            WHEN(sltrans_doctype='DM') THEN <? value("debitmemo") ?>\n            WHEN(sltrans_doctype='CD') THEN <? value("cashdeposit") ?>\n         ELSE sltrans_doctype\n       END AS doctype,\n       sltrans_docnumber AS gltrans_docnumber,\n       CASE WHEN(sltrans_doctype='IN') THEN\n                 (SELECT invchead_shipto_name\n                  FROM aropen LEFT OUTER JOIN\n                       invchead\n                       ON (invchead_id=aropen_cobmisc_id\n                       AND invchead_cust_id=aropen_cust_id)\n                  WHERE ((aropen_docnumber=sltrans_docnumber)\n                     AND (aropen_doctype='I')))\n         ELSE firstLine(sltrans_notes)\n       END AS f_notes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS f_accnt,\n       CASE WHEN (sltrans_amount < 0) THEN ABS(sltrans_amount)\n         ELSE 0\n       END AS debit,\n       CASE WHEN (sltrans_amount > 0) THEN sltrans_amount\n         ELSE 0\n       END AS credit,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       1 AS xtindentrole,\n       NULL AS transdate\nFROM sltrans, accnt\nWHERE ((sltrans_accnt_id=accnt_id)\n   AND (sltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n   AND (sltrans_source = 'A/R')\n   AND (sltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("accnt_id") ?>\n   AND (sltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n      )\nORDER BY gltrans_date, gltrans_docnumber, xtindentrole;\n       admin   2014-10-06      0
101137
 
55      invoices        detail   used by reprintInvoices, unpostedInvoices, dspRecurringInvoices\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: invoices\n-- Name: detail\n-- Notes: used by reprintInvoices, unpostedInvoices, dspRecurringInvoices\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT invchead_id, cust_id,\n       invchead.*,\n       cust_number, cust_name,\n       (TEXT(cust_number) || ' - ' || cust_name) AS customer,\n       COALESCE(invchead_gldistdate, invchead_invcdate) AS gldistdate,\n       invoicetotal(invchead_id) AS extprice,\n       CASE WHEN (aropen_open) THEN (aropen_amount - aropen_paid)\n            ELSE 0\n       END AS balance,\n       (invchead_recurring_invchead_id IS NOT NULL) AS isRecurring,\n       recur_freq,\n       recur_period,\n       CASE WHEN (recur_period='D') THEN <? value("day") ?>\n            WHEN (recur_period='W') THEN <? value("week") ?>\n            WHEN (recur_period='M') THEN <? value("month") ?>\n            WHEN (recur_period='Y') THEN <? value("year") ?>\n            WHEN (recur_period='m') THEN <? value("minute") ?>\n            WHEN (recur_period='H') THEN <? value("hour") ?>\n            ELSE <? value("none") ?>\n       END AS recur_period_qtdisplayrole,\n       recur_end,\n       <? if exists('getForm') ?>\n         invchead_invcnumber AS docnumber,\n         findCustomerForm(cust_id, 'I') AS reportname,\n       <? endif ?>\n       CASE WHEN (calcInvoiceAmt(invchead_id,'S') != 0.0)\n              THEN calcInvoiceAmt(invchead_id,'M')\n            ELSE 0.0\n       END AS margin,\n       CASE WHEN (calcInvoiceAmt(invchead_id,'S') != 0.0)\n              THEN (calcInvoiceAmt(invchead_id,'M') / calcInvoiceAmt(invchead_id,'S'))\n            ELSE 1.0\n       END AS marginpercent,\n       'percent' AS marginpercent_xtnumericrole,\n       'curr' AS margin_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS balance_xtnumericrole,\n       CASE WHEN (aropen_id IS NULL) THEN 'Unposted' END AS balance_qtdisplayrole\nFROM invchead JOIN custinfo ON (cust_id=invchead_cust_id)\n              LEFT OUTER JOIN aropen ON ( (aropen_doctype='I') AND (aropen_docnumber=invchead_invcnumber) )\n              LEFT OUTER JOIN recur ON (invchead_recurring_invchead_id=recur_parent_id AND recur_parent_type='I')\nWHERE ( (true)\n<? if exists("unpostedOnly") ?>\n  AND   (NOT invchead_posted)\n<? endif ?>\n<? if exists("postedOnly") ?>\n  AND   (invchead_posted)\n<? endif ?>\n<? if exists("recurringOnly") ?>\n  AND   (invchead_recurring_invchead_id IS NOT NULL)\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND   (invchead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (invchead_invcdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("invc_pattern") ?>\n  AND   (invchead_invcnumber ~ <? value("invc_pattern") ?>)\n<? endif ?>\n<? if exists("balanceOnly") ?>\n  AND   (aropen_open AND (aropen_amount - aropen_paid > 0))\n<? endif ?>\n  AND   (checkInvoiceSitePrivs(invchead_id)) )\nORDER BY invchead_invcnumber\n;\n       admin   2014-10-06      0
101138
 
477     itemSources     search   \n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: itemSources\n-- Name: search\n-- Notes: \n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\n  SELECT itemsrc_id AS id,\n         1 AS altid,\n         item_number,\n         (item_descrip1 || ' ' || item_descrip2) AS item_descrip,\n         vend_name,\n         itemsrc_vend_item_number,\n         itemsrc_vend_item_descrip,\n         itemsrc_manuf_name,\n         itemsrc_manuf_item_number,\n         itemsrc_manuf_item_descrip,\n         contrct_number\n    FROM vendinfo JOIN itemsrc ON (itemsrc_vend_id=vend_id)\n                  JOIN item ON (item_id=itemsrc_item_id)\n       LEFT OUTER JOIN contrct ON (itemsrc_contrct_id = contrct_id)\n   WHERE (vend_id=<? value("vend_id") ?>)\n     AND ( (FALSE)\n<? if exists("searchNumber") ?>\n        OR (item_number ~* <? value("searchNumber") ?>)\n<? endif ?>\n<? if exists("searchVendNumber") ?>\n        OR (itemsrc_vend_item_number ~* <? value("searchVendNumber") ?>)\n<? endif ?>\n<? if exists("searchDescrip1") ?>\n        OR (item_descrip1 ~* <? value("searchDescrip1") ?>)\n<? endif ?>\n<? if exists("searchDescrip2") ?>\n        OR (item_descrip2 ~* <? value("searchDescrip2") ?>)\n<? endif ?>\n<? if exists("searchVendDescrip") ?>\n        OR (itemsrc_vend_item_descrip ~* <? value("searchVendDescrip") ?>)\n<? endif ?>\n<? if exists("searchManufName") ?>\n        OR (itemsrc_manuf_name ~* <? value("searchManufName") ?>)\n<? endif ?>\n<? if exists("searchManufNumber") ?>\n        OR (itemsrc_manuf_item_number ~* <? value("searchManufNumber") ?>)\n<? endif ?>\n       )\n  UNION\n  SELECT DISTINCT poitem_expcat_id AS id,\n                  2 AS altid,\n                  <? value("non") ?> AS item_number,\n                  (expcat_code || ' ' || expcat_descrip) AS item_descrip,\n                  vend_name,\n                  poitem_vend_item_number,\n                  poitem_vend_item_descrip,\n                  poitem_manuf_name,\n                  poitem_manuf_item_number,\n                  poitem_manuf_item_descrip,\n                  null AS contrct_id \n    FROM vendinfo JOIN pohead ON (pohead_vend_id=vend_id)\n                  JOIN poitem ON (poitem_pohead_id=pohead_id)\n                  LEFT OUTER JOIN expcat ON (poitem_expcat_id=expcat_id)\n   WHERE (vend_id=<? value("vend_id") ?>)\n     AND (COALESCE(poitem_vend_item_number, '')!='')\n     AND (poitem_itemsite_id IS NULL)\n     AND ( (FALSE)\n<? if exists("searchVendNumber") ?>\n        OR (poitem_vend_item_number ~* <? value("searchVendNumber") ?>)\n<? endif ?>\n<? if exists("searchDescrip1") ?>\n        OR (expcat_code ~* <? value("searchDescrip1") ?>)\n        OR (expcat_descrip ~* <? value("searchDescrip1") ?>)\n<? endif ?>\n<? if exists("searchVendDescrip") ?>\n        OR (poitem_vend_item_descrip ~* <? value("searchVendDescrip") ?>)\n<? endif ?>\n<? if exists("searchManufName") ?>\n        OR (poitem_manuf_name ~* <? value("searchManufName") ?>)\n<? endif ?>\n<? if exists("searchManufNumber") ?>\n        OR (poitem_manuf_item_number ~* <? value("searchManufNumber") ?>)\n<? endif ?>\n       )\n  ORDER BY item_number, vend_name;\n       admin   2014-10-06      0
101139
 
475     issueToShipping detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: issueToShipping\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       noNeg(qtyord - qtyshipped + qtyreturned) AS balance,\n       indent AS xtindentrole,\n       'qty' AS qtyord_xtnumericrole,\n       'qty' AS qtyshipped_xtnumericrole,\n       'qty' AS qtyreturned_xtnumericrole,\n       'qty' AS balance_xtnumericrole,\n       'qty' AS atshipping_xtnumericrole,\n       CASE WHEN (scheddate > CURRENT_DATE AND\n                  noNeg(qtyord - qtyshipped + qtyreturned) <> atshipping) THEN 'future'\n            WHEN (noNeg(qtyord - qtyshipped + qtyreturned) <> atshipping) THEN 'expired'\n       END AS qtforegroundrole \nFROM (\n<? if exists("sohead_id") ?>\nSELECT coitem_id AS lineitem_id, \n       CASE WHEN (itemsite_costmethod = 'J') THEN 1 \n            ELSE 0 \n       END AS job, 0 AS indent,\n       getOpenShipment('SO', <? value("sohead_id") ?>, <? value("warehous_id") ?>) AS shiphead_number, \n       formatSoLineNumber(coitem_id) AS linenumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       warehous_code,\n       coitem_scheddate AS scheddate,\n       uom_name,\n       coitem_qtyord AS qtyord,\n       coitem_qtyshipped AS qtyshipped,\n       coitem_qtyreturned AS qtyreturned,\n       qtyAtShipping(coitem_id) AS atshipping, \n       coitem_scheddate AS seq1, coitem_linenumber AS seq2, coitem_subnumber AS seq3 \nFROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n            JOIN item ON (item_id=itemsite_item_id)\n            JOIN site() ON (warehous_id=itemsite_warehous_id)\n            JOIN uom ON (uom_id=coitem_qty_uom_id)\nWHERE ( (coitem_status NOT IN ('C','X'))\n  AND   (item_type != 'K')\n<? if exists("warehous_id") ?>\n  AND   (itemsite_warehous_id=<? value("warehous_id") ?>) \n<? endif ?>\n  AND   (coitem_cohead_id=<? value("sohead_id") ?>) ) \n\n<? if exists("includeReservations") ?>\nUNION ALL\nSELECT coitem_id AS lineitem_id, \n       CASE WHEN (itemsite_costmethod = 'J') THEN 1 \n            ELSE 0 \n       END AS job, 1 AS indent,\n       '' AS shiphead_number, \n       '' AS linenumber, formatLocationName(itemloc_location_id) AS item_number,\n       formatLotSerialNumber(itemloc_ls_id) AS itemdescrip,\n       '' AS warehous_code,\n       NULL AS scheddate,\n       '' AS uom_name,\n       reserve_qty AS qtyord,\n       NULL AS qtyshipped,\n       NULL AS qtyreturned,\n       NULL AS atshipping, \n       coitem_scheddate AS seq1, coitem_linenumber AS seq2, coitem_subnumber AS seq3 \nFROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n            JOIN item ON (item_id=itemsite_item_id)\n            JOIN site() ON (warehous_id=itemsite_warehous_id)\n            JOIN reserve ON (reserve_demand_id=coitem_id AND\n                             reserve_demand_type='SO' AND\n                             reserve_supply_type='I')\n            JOIN itemloc ON (itemloc_id=reserve_supply_id)\nWHERE ( (coitem_status NOT IN ('C','X'))\n  AND   (item_type != 'K')\n  AND   ((itemsite_controlmethod IN ('L', 'S')) OR (itemsite_loccntrl))\n<? if exists("warehous_id") ?>\n  AND   (itemsite_warehous_id=<? value("warehous_id") ?>) \n<? endif ?>\n  AND   (coitem_cohead_id=<? value("sohead_id") ?>) ) \nUNION ALL\nSELECT coitem_id AS lineitem_id, \n       CASE WHEN (itemsite_costmethod = 'J') THEN 1 \n            ELSE 0 \n       END AS job, 1 AS indent,\n       '' AS shiphead_number, \n       '' AS linenumber, 'N/A',\n       'N/A' AS itemdescrip,\n       '' AS warehous_code,\n       NULL AS scheddate,\n       '' AS uom_name,\n       coitem_qtyreserved AS qtyord,\n       NULL AS qtyshipped,\n       NULL AS qtyreturned,\n       NULL AS atshipping, \n       coitem_scheddate AS seq1, coitem_linenumber AS seq2, coitem_subnumber AS seq3 \nFROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n            JOIN item ON (item_id=itemsite_item_id)\n            JOIN site() ON (warehous_id=itemsite_warehous_id)\nWHERE ( (coitem_status NOT IN ('C','X'))\n  AND   (item_type != 'K')\n  AND   ((itemsite_controlmethod = 'R') AND (NOT itemsite_loccntrl))\n  AND   (coitem_qtyreserved > 0.0)\n<? if exists("warehous_id") ?>\n  AND   (itemsite_warehous_id=<? value("warehous_id") ?>) \n<? endif ?>\n  AND   (coitem_cohead_id=<? value("sohead_id") ?>) ) \n<? endif ?>\n\n<? elseif exists("tohead_id") ?>\n\nSELECT toitem_id AS lineitem_id, \n       0 AS lsJob, 0 AS indent,\n       getOpenShipment('TO', <? value("tohead_id") ?>, <? value("warehous_id") ?>) AS shiphead_number, \n       toitem_linenumber AS linenumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       tohead_srcname AS warehous_code,\n       toitem_schedshipdate AS scheddate,\n       uom_name,\n       toitem_qty_ordered AS qtyord,\n       toitem_qty_shipped AS qtyshipped,\n       0 AS qtyreturned,\n       qtyAtShipping('TO', toitem_id) AS atshipping, \n       toitem_schedshipdate AS seq1, toitem_linenumber AS seq2, 0 AS seq3 \nFROM item, tohead, site(), uom, toitem\nWHERE ( (toitem_item_id=item_id)\n AND (toitem_status NOT IN ('C','X'))\n AND (toitem_tohead_id=tohead_id)\n AND (tohead_src_warehous_id=warehous_id)\n AND (item_inv_uom_id=uom_id)\n<? if exists("warehous_id") ?>\n  AND   (tohead_src_warehous_id=<? value("warehous_id") ?>) \n<? endif ?>\n AND (tohead_id=<? value("tohead_id") ?>) ) \n<? endif ?>\n) AS sub \nORDER BY seq1, seq2, seq3, indent;\n  admin   2014-10-06      0
101140
 
257     itemCost        detail   used by dspItemCostSummary, dspItemCostsByClassCode, dspItemCostHistory\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemCost\n-- Name: detail\n-- Notes: used by dspItemCostSummary, dspItemCostsByClassCode, dspItemCostHistory\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n      <? if exists("byHistory") ?>\n        costhist_id, costelem_type,\n        formatBoolYN(costhist_lowlevel) AS lowlevel,\n        CASE WHEN costhist_type='A' THEN <? value("actual") ?>\n             WHEN costhist_type='S' THEN <? value("standard") ?>\n             WHEN costhist_type='D' THEN <? value("delete") ?>\n             WHEN costhist_type='N' THEN <? value("new") ?>\n        END AS type,\n        costhist_date,\n        costhist_username AS username,\n        costhist_oldcost,\n        currConcat(costhist_oldcurr_id) AS oldcurr, \n\tcosthist_newcost,\n        currConcat(costhist_newcurr_id) AS newcurr,\n        'cost' AS costhist_oldcost_xtnumericrole,\n        'cost' AS costhist_newcost_xtnumericrole\n      <? elseif exists("byClassCode") ?>\n        item_id, item_number, description, item_active, \n        uom_name, scost, acost, \n        CASE WHEN (scost = 0) THEN NULL  \n          ELSE ((acost - scost) / scost)      \n        END AS percent_variance,\n        'percent' AS percent_variance_xtnumericrole, \n        CASE WHEN (scost = 0) THEN NULL \n             WHEN (((acost - scost) / scost) < 0) THEN 'error' \n          ELSE NULL \n        END AS percent_variance_qtforegroundrole, \n        <? if exists("onlyShowDiffCosts") ?>\n          CASE WHEN (scost != acost\n                     AND ABS(scost - acost) < 10 ^ (-1 * <? value("costscale") ?>))\n               THEN 'altemphasis' \n          END AS qtforegroundrole,\n        <? endif ?> \n        'cost' AS scost_xtnumericrole,\n        'cost' AS acost_xtnumericrole \n      <? elseif exists("bySummrey") ?>\n        itemcost_id,\n        CASE WHEN (costelem_sys) THEN 1\n          ELSE 0\n        END,\n        costelem_type, formatBoolYN(itemcost_lowlevel) AS lowlevel,\n        itemcost_stdcost,\n        currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS itemcost_actcost,\n        itemcost_updated, itemcost_posted,\n        'cost' AS itemcost_stdcost_xtnumericrole,\n        'cost' AS itemcost_actcost_xtnumericrole,\n        0 AS itemcost_stdcost_xttotalrole,\n        0 AS itemcost_actcost_xttotalrole,\n        CASE WHEN COALESCE(itemcost_posted, endOfTime()) >= endOfTime() \n             THEN <? value("never") ?>\n        END AS itemcost_posted_qtdisplayrole,\n        CASE WHEN COALESCE(itemcost_updated, endOfTime()) >= endOfTime()\n             THEN <? value("never") ?>\n        END AS itemcost_updated_qtdisplayrole\n      <? endif ?>\nFROM <? if exists("byClassCode") ?>\n       (SELECT item_id, item_number, item_active,\n               (item_descrip1 || ' ' || item_descrip2) AS description,\n               uom_name, stdcost(item_id) AS scost, actcost(item_id) AS acost\n        FROM item, classcode, uom\n        WHERE ((item_classcode_id=classcode_id)\n          AND  (item_inv_uom_id=uom_id)\n          <? if exists("classcode_id") ?>\n            AND (classcode_id=<? value("classcode_id") ?>)\n          <? elseif exists("classcode_pattern") ?>\n            AND (classcode_code ~ <? value("classcode_pattern") ?>)\n          <? endif ?> \n              ) ) AS data \n     <? elseif exists("byHistory") ?>\n       costhist,costelem\n     <? elseif exists("bySummrey") ?>\n       itemcost, costelem\n     <? endif ?>   \nWHERE ( <? if exists("byHistory") ?>\n         (costhist_costelem_id=costelem_id)\n     AND (costhist_item_id=<? value("item_id") ?>)\n        <? elseif exists("byClassCode") ?> \n          true \n          <? if exists("onlyShowZeroCosts") ?>\n            AND ((scost=0) OR (acost=0)) \n          <? endif ?> \n          <? if exists("onlyShowDiffCosts") ?>\n            AND (scost != acost) \n            AND (ABS(scost - acost) > 10 ^ (-1 * <? value("costscale") ?>))\n          <? endif ?>\n          <? if exists("onlyShowActive") ?>\n            AND (item_active) \n          <? endif ?> \n        <? elseif exists("bySummrey") ?>\n          (itemcost_costelem_id=costelem_id)\n      AND (itemcost_item_id=<? value("item_id") ?>)\n        <? endif ?>\n      ) \nORDER BY <? if exists("byHistory") ?>\n           costhist_date, costelem_type;\n         <? elseif exists("byClassCode") ?> \n           item_number;\n         <? elseif exists("bySummrey") ?>\n           itemcost_lowlevel, costelem_type;\n         <? endif ?>\n   admin   2014-10-06      0
101141
 
457     itemCost        list     used by maintainItemCosts, bomItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: itemCost\n-- Name: list\n-- Notes: used by maintainItemCosts, bomItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n-- The order of checking for item_id first is important.\n\n<? if exists("item_id") ?>\n\nSELECT itemcost_id,\n       CASE WHEN (costelem_sys) THEN 1\n            ELSE 0\n       END,\n       CASE WHEN itemcost_costelem_id = -1 THEN :error\n\t    ELSE costelem_type\n       END AS costelem_type, itemcost_lowlevel,\n       itemcost_stdcost, currConcat(baseCurrID()) AS baseCurr,\n       itemcost_posted,\n       itemcost_actcost, currConcat(itemcost_curr_id) AS costCurr,\n       itemcost_updated,\n       currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actcostBase,\n       itemcost_curr_id,\n       CASE WHEN (COALESCE(itemcost_posted, startOfTime()) <= startOfTime()) THEN :never\n       END AS itemcost_posted_qtdisplayrole,\n       'cost' AS itemcost_stdcost_xtnumericrole,\n       'cost' AS itemcost_actcost_xtnumericrole\nFROM itemcost LEFT OUTER JOIN costelem ON (itemcost_costelem_id=costelem_id)\nWHERE (itemcost_item_id=<? value("item_id") ?>)\nORDER BY itemcost_lowlevel, costelem_type;\n\n<? elseif exists("bomitem_id") ?>\n\nSELECT bomitemcost_id AS itemcost_id,\n       CASE WHEN (costelem_sys) THEN 1\n            ELSE 0\n       END,\n       CASE WHEN bomitemcost_costelem_id = -1 THEN :error\n\t    ELSE costelem_type\n       END AS costelem_type,\n       bomitemcost_lowlevel AS itemcost_lowlevel,\n       bomitemcost_stdcost AS itemcost_stdcost, currConcat(baseCurrID()) AS baseCurr,\n       bomitemcost_posted AS itemcost_posted,\n       bomitemcost_actcost AS itemcost_actcost,\n       currConcat(bomitemcost_curr_id) AS costCurr,\n       bomitemcost_updated AS itemcost_updated,\n       currToBase(bomitemcost_curr_id, bomitemcost_actcost, CURRENT_DATE) AS actcostBase,\n       bomitemcost_curr_id AS itemcost_curr_id,\n       CASE WHEN (COALESCE(bomitemcost_posted, startOfTime()) <= startOfTime()) THEN :never\n       END AS itemcost_posted_qtdisplayrole,\n       'cost' AS itemcost_stdcost_xtnumericrole,\n       'cost' AS itemcost_actcost_xtnumericrole\nFROM bomitemcost LEFT OUTER JOIN costelem ON (bomitemcost_costelem_id=costelem_id)\nWHERE (bomitemcost_bomitem_id=<? value("bomitem_id") ?>)\nORDER BY bomitemcost_lowlevel, costelem_type;\n\n<? endif ?>\n     admin   2014-10-06      0
101142
 
430     itemPricingSchedule     detail   used by itemPricingSchedule\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: itemPricingSchedule\n-- Name: detail\n-- Notes: used by itemPricingSchedule\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT ipsitem_id AS id, 1 AS altid,\n       CASE WHEN (ipsitem_item_id IS NOT NULL) THEN <? value("item") ?>\n            ELSE <? value("prodcat") ?>\n       END AS target,\n       COALESCE(item_number, prodcat_code) AS number,\n       COALESCE(item_descrip1 || ' ' || item_descrip2, prodcat_descrip) AS descrip,\n       qty.uom_name AS qtyuom, ipsitem_qtybreak AS qtybreak,\n       price.uom_name AS priceuom,\n       ((COALESCE(ipsitem_discntprcnt, 0.0) * 100) + ipsitem_price) AS price,\n       (COALESCE(ipsitem_fixedamtdiscount, 0.0) + 0.00) AS fixedAmt,\n       noNeg(CASE WHEN (ipsitem_item_id IS NULL) THEN\n                   NULL\n                  WHEN (ipsitem_type='N') THEN\n                   ipsitem_price\n                  WHEN (ipsitem_type='D') THEN\n                   (item_listprice - (item_listprice * COALESCE(ipsitem_discntprcnt, 0.0)) - COALESCE(ipsitem_fixedamtdiscount, 0.0))\n                  WHEN ((ipsitem_type = 'M') AND fetchMetricBool('Long30Markups') AND fetchMetricBool('WholesalePriceCosting')) THEN\n                   (item_listcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n                  WHEN ((ipsitem_type = 'M') AND fetchMetricBool('Long30Markups')) THEN\n                   (itemCost(itemsite_id) / itemuomtouomratio(item_id, ipsitem_qty_uom_id, ipsitem_price_uom_id) /\n                   (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n                  WHEN (ipsitem_type = 'M' AND fetchMetricBool('WholesalePriceCosting')) THEN\n                   (item_listcost + (item_listcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n                  WHEN (ipsitem_type = 'M') THEN\n                   (itemCost(itemsite_id) / itemuomtouomratio(item_id, ipsitem_qty_uom_id, ipsitem_price_uom_id) +\n                    (itemCost(itemsite_id) / itemuomtouomratio(item_id, ipsitem_qty_uom_id, ipsitem_price_uom_id) * ipsitem_discntprcnt) +\n                    ipsitem_fixedamtdiscount)\n                  ELSE 0.0\n             END) AS netPrice,\n       CASE WHEN (ipsitem_type='N') THEN <? value("nominal") ?>\n            WHEN (ipsitem_type='D') THEN <? value("discount") ?>\n            WHEN (ipsitem_type='M') THEN <? value("markup") ?>\n            ELSE 'error'\n       END AS type,\n       CASE WHEN (ipsitem_type='N') THEN <? value("price") ?>\n            WHEN ((ipsitem_type IN ('D', 'M')) AND (COALESCE(ipsitem_discntprcnt, 0.0)=0.0) AND (COALESCE(ipsitem_fixedamtdiscount, 0.0)<>0.0)) THEN <? value("fixed") ?>\n            WHEN ((ipsitem_type IN ('D', 'M')) AND (COALESCE(ipsitem_discntprcnt, 0.0)<>0.0) AND (COALESCE(ipsitem_fixedamtdiscount, 0.0)=0.0)) THEN <? value("percent") ?>\n            WHEN (ipsitem_type IN ('D', 'M')) THEN <? value("mixed") ?>\n            ELSE 'error'\n       END AS method,\n       'qty' AS qtybreak_xtnumericrole,\n       'salesprice' AS netPrice_xtnumericrole,\n       'salesprice' AS price_xtnumericrole\nFROM ipsiteminfo LEFT OUTER JOIN item ON (item_id=ipsitem_item_id)\n                 LEFT OUTER JOIN prodcat ON (prodcat_id=ipsitem_prodcat_id)\n                 LEFT OUTER JOIN uom AS qty ON (qty.uom_id=ipsitem_qty_uom_id)\n                 LEFT OUTER JOIN uom AS price ON (price.uom_id=ipsitem_price_uom_id)\n                 LEFT OUTER JOIN itemsite ON (itemsite_item_id=item_id AND itemsite_warehous_id=<? value("warehous_id") ?>)\nWHERE (ipsitem_ipshead_id=<? value("ipshead_id") ?>)\n\nUNION\n\nSELECT ipsfreight_id AS id, 2 AS altid, <? value("freight") ?> AS type,\n       CASE WHEN (ipsfreight_type='F') THEN <? value("flatrate") ?>\n            ELSE <? value("peruom") ?>\n       END AS number,\n       ('From ' || COALESCE(warehous_code, <? value("allsites") ?>) || ' To ' || COALESCE(shipzone_name, <? value("allzones") ?>)) AS descrip,\n       CASE WHEN (ipsfreight_type='P') THEN uom_name END AS qtyuom,\n       CASE WHEN (ipsfreight_type='P') THEN ipsfreight_qtybreak END AS qtybreak,\n       uom_name AS priceuom, ipsfreight_price AS price,\n       0.00 AS fixedAmt,\n       NULL AS netPrice,\n       NULL AS type,\n       NULL AS method,\n       'weight' AS qtybreak_xtnumericrole,\n       'salesprice' AS netPrice_xtnumericrole,\n       'salesprice' AS price_xtnumericrole\nFROM ipsfreight LEFT OUTER JOIN uom ON (uom_item_weight)\n                LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n                LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\nWHERE ( (ipsfreight_ipshead_id=<? value("ipshead_id") ?>) )\nORDER BY altid, number, qtybreak;\n admin   2014-10-06      0
101143
 
56      itemReceipt     populateEdit     used by enterPoitemReceipt, splitReceipt\n----PURCHASE ORDER----------\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: itemReceipt\n-- Name: populateEdit\n-- Notes: used by enterPoitemReceipt, splitReceipt\n------PURCHASE ORDER----------\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_number AS order_number, poitem_linenumber AS orderitem_linenumber,\n       (poitem_itemsite_id > 0) AS inventoryitem,\n       COALESCE(poitem_itemsite_id, -1) AS itemsiteid,\n       COALESCE(poitem_vend_item_number, '') AS vend_item_number,\n       COALESCE(poitem_vend_uom, '') AS vend_uom,\n       COALESCE(poitem_vend_item_descrip, '') AS vend_item_descrip,\n       poitem_invvenduomratio AS orderitem_qty_invuomratio,\n       poitem_duedate AS duedate,\n       poitem_qty_ordered AS orderitem_qty_ordered,\n       recv_qty AS qtyreceived,\n       poitem_qty_returned AS qtyreturned,\n       qtyToReceive('PO', poitem_id) AS qtytoreceive,\n       (poitem_qty_ordered) AS receivable,\n       recv_notes AS notes, recv_freight, recv_order_type,\n       recv_freight_curr_id AS curr_id, recv_date AS effective,\n       recv_purchcost, recv_purchcost_curr_id,\n       CASE WHEN (itemsite_costmethod='A' AND NOT(recv_posted)) THEN TRUE\n            ELSE FALSE\n       END AS costmethod_average,\n       'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n       'qty' AS orderitem_qty_ordered_xtnumericrole, \n       'qty' AS qtyreceived_xtnumericrole, \n       'qty' AS qtyreturned_xtnumericrole, \n       'qty' AS qtytoreceive_xtnumericrole, \n       'qty' AS receivable_xtnumericrole,\n       'purchprice' AS recv_purchcost_xtnumericrole \nFROM recv \n  JOIN  poitem ON ((recv_orderitem_id=poitem_id)\n               AND (recv_order_type='PO'))\n  JOIN  pohead ON (poitem_pohead_id=pohead_id)\n  LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\nWHERE (recv_id=<? value("recv_id") ?>)\n<? if exists ("EnableReturnAuth") ?>\nUNION\n-------RETURN AUTHORIZATIONS-----------\nSELECT rahead_number AS order_number, raitem_linenumber AS orderitem_linenumber,\n       (raitem_itemsite_id > 0) AS inventoryitem,\n       COALESCE(raitem_itemsite_id, -1) AS itemsiteid,\n       '' AS vend_item_number,\n       '' AS vend_uom,\n       '' AS vend_item_descrip,\n       raitem_qty_invuomratio AS orderitem_qty_invuomratio,\n       raitem_scheddate AS duedate,\n       raitem_qtyauthorized AS orderitem_qty_ordered,\n       recv_qty AS qtyreceived,\n       0 AS qtyreturned,\n       qtyToReceive('RA', raitem_id) AS qtytoreceive,\n       (raitem_qtyauthorized) AS receivable,\n       recv_notes AS notes, recv_freight, recv_order_type,\n       recv_freight_curr_id AS curr_id, recv_date AS effective,\n       NULL AS recv_purchcost, NULL AS recv_purchcost_curr_id,\n       NULL AS costmethod_average,\n       'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n       'qty' AS orderitem_qty_ordered_xtnumericrole, \n       'qty' AS qtyreceived_xtnumericrole, \n       'qty' AS qtyreturned_xtnumericrole, \n       'qty' AS qtytoreceive_xtnumericrole, \n       'qty' AS receivable_xtnumericrole,\n       'purchprice' AS recv_purchcost_xtnumericrole \nFROM recv\n  JOIN  raitem ON ((recv_orderitem_id=raitem_id)\n               AND (recv_order_type='RA'))\n  JOIN  rahead ON (raitem_rahead_id=rahead_id)\nWHERE (recv_id=<? value("recv_id") ?>)\n<? endif ?>\n<? if exists ("MultiWhs") ?>\nUNION\n----------TRANSFER ORDERS---------\nSELECT tohead_number AS order_number, toitem_linenumber AS orderitem_linenumber,\n       (itemsite_id > 0) AS inventoryitem,\n       itemsite_id AS itemsiteid,\n       '' AS vend_item_number,\n       '' AS vend_uom,\n       '' AS vend_item_descrip,\n       1 AS orderitem_qty_invuomratio,\n       toitem_duedate AS duedate,\n       toitem_qty_ordered AS orderitem_qty_ordered,\n       recv_qty AS qtyreceived,\n       0 AS qtyreturned,\n       qtyToReceive('TO', toitem_id) AS qtytoreceive,\n       (toitem_qty_ordered) AS receivable,\n       recv_notes AS notes, recv_freight, recv_order_type,\n       recv_freight_curr_id AS curr_id, recv_date AS effective,\n       NULL AS recv_purchcost, NULL AS recv_purchcost_curr_id,\n       NULL AS costmethod_average,\n       'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n       'qty' AS orderitem_qty_ordered_xtnumericrole, \n       'qty' AS qtyreceived_xtnumericrole, \n       'qty' AS qtyreturned_xtnumericrole, \n       'qty' AS qtytoreceive_xtnumericrole, \n       'qty' AS receivable_xtnumericrole,\n       'purchprice' AS recv_purchcost_xtnumericrole \nFROM itemsite, recv\n  JOIN  toitem ON ((recv_orderitem_id=toitem_id)\n               AND (recv_order_type='TO'))\n  JOIN  tohead ON (toitem_tohead_id=tohead_id)\nWHERE ((recv_id=<? value("recv_id") ?>)\n  AND  (tohead_dest_warehous_id=itemsite_warehous_id)\n  AND  (toitem_item_id=itemsite_item_id))\n<? endif ?>;\n  admin   2014-10-06      0
101144
 
57      itemReceipt     populateNew      used by enterPoitemReceipt\n-------PURCHASE ORDERS-------------\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemReceipt\n-- Name: populateNew\n-- Notes: used by enterPoitemReceipt\n---------PURCHASE ORDERS-------------\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_number AS order_number, poitem_linenumber AS orderitem_linenumber,\n       (poitem_itemsite_id > 0) AS inventoryitem,\n       COALESCE(poitem_itemsite_id, -1) AS itemsiteid,\n       COALESCE(poitem_vend_item_number, '') AS vend_item_number,\n       COALESCE(poitem_vend_uom, '') AS vend_uom,\n       COALESCE(poitem_vend_item_descrip, '') AS vend_item_descrip,\n       poitem_invvenduomratio AS orderitem_qty_invuomratio,\n       poitem_duedate AS duedate,\n       poitem_qty_ordered AS orderitem_qty_ordered,\n       poitem_qty_received AS qtyreceived,\n       poitem_qty_returned AS qtyreturned,\n       qtyToReceive('PO', poitem_id) AS qtytoreceive,\n       (poitem_qty_ordered - poitem_qty_received) AS receivable,\n       ( SELECT recv_notes\n           FROM recv\n          WHERE ((recv_orderitem_id=poitem_id)\n\t    AND  (recv_order_type='PO')\n            AND  (NOT recv_posted))\n\t  LIMIT 1 ) AS notes,\n       COALESCE(freightForRecv('PO', poitem_id, false),\n\t\tpoitem_freight - freightForRecv('PO', poitem_id, true),\n\t\tfreightForRecv('PO', poitem_id, true)) AS recv_freight,\n       pohead_curr_id AS curr_id, CURRENT_DATE AS effective, \n       poitem_unitprice AS recv_purchcost,\n       pohead_curr_id AS recv_purchcost_curr_id,\n       CASE WHEN (itemsite_costmethod='A') THEN TRUE \n\t    ELSE FALSE \n       END AS costmethod_average,\n       'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n       'qty' AS orderitem_qty_ordered_xtnumericrole, \n       'qty' AS qtyreceived_xtnumericrole, \n       'qty' AS qtyreturned_xtnumericrole, \n       'qty' AS qtytoreceive_xtnumericrole, \n       'qty' AS receivable_xtnumericrole,\n       'purchprice' AS recv_purchcost_xtnumericrole \nFROM pohead\n  JOIN poitem ON (pohead_id=poitem_pohead_id)\n  LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\nWHERE ((poitem_status <> 'C')\n  AND  (poitem_id=<? value("orderitem_id") ?>)\n  AND  ('PO'=<? value("ordertype") ?>) )\n<? if exists ("EnableReturnAuth") ?>\nUNION\n---------RETURN AUTHORIZATIONS-------------\nSELECT rahead_number AS order_number, raitem_linenumber AS orderitem_linenumber,\n       (raitem_itemsite_id > 0) AS inventoryitem,\n       COALESCE(raitem_itemsite_id, -1) AS itemsiteid,\n       '' AS vend_item_number,\n       '' AS vend_uom,\n       '' AS vend_item_descrip,\n       raitem_qty_invuomratio AS orderitem_qty_invuomratio,\n       raitem_scheddate AS duedate,\n       raitem_qtyauthorized AS orderitem_qty_ordered,\n       raitem_qtyreceived AS qtyreceived,\n       0 AS qtyreturned,\n       qtyToReceive('RA', raitem_id) AS qtytoreceive,\n       (raitem_qtyauthorized - raitem_qtyreceived) AS receivable,\n       ( SELECT recv_notes\n           FROM recv\n          WHERE ((recv_orderitem_id=raitem_id)\n\t    AND  (recv_order_type='RA')\n            AND  (NOT recv_posted))\n\t  LIMIT 1 ) AS notes,\n       COALESCE(freightForRecv('RA', raitem_id, false),\n\t\tfreightForRecv('RA', raitem_id, true)) AS recv_freight,\n       rahead_curr_id AS curr_id, CURRENT_DATE AS effective, \n       NULL AS recv_purchcost, NULL AS recv_purchcost_curr_id,\n       NULL AS costmethod_average,\n       'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n       'qty' AS orderitem_qty_ordered_xtnumericrole, \n       'qty' AS qtyreceived_xtnumericrole, \n       'qty' AS qtyreturned_xtnumericrole, \n       'qty' AS qtytoreceive_xtnumericrole, \n       'qty' AS receivable_xtnumericrole,\n       'purchprice' AS recv_purchcost_xtnumericrole \nFROM rahead\n  JOIN raitem ON (rahead_id=raitem_rahead_id)\nWHERE ((raitem_status <> 'C')\n  AND  (raitem_id=<? value("orderitem_id") ?>)\n  AND  ('RA'=<? value("ordertype") ?>) )\n<? endif ?>\n<? if exists ("MultiWhs") ?>\nUNION\n-------------TRANSFER ORDERS--------------\nSELECT tohead_number AS order_number, toitem_linenumber AS orderitem_linenumber,\n       (itemsite_id > 0) AS inventoryitem,\n       COALESCE(itemsite_id, -1) AS itemsiteid,\n       '' AS vend_item_number,\n       '' AS vend_uom,\n       '' AS vend_item_descrip,\n       1 AS orderitem_qty_invuomratio,\n       toitem_duedate AS duedate,\n       toitem_qty_ordered AS orderitem_qty_ordered,\n       toitem_qty_received AS qtyreceived,\n       toitem_qty_shipped AS qtyreturned,\n       qtyToReceive('TO', toitem_id) AS qtytoreceive,\n       (toitem_qty_ordered - toitem_qty_received) AS receivable,\n       ( SELECT recv_notes\n           FROM recv\n          WHERE ((recv_orderitem_id=toitem_id)\n\t    AND  (recv_order_type='TO')\n            AND  (NOT recv_posted))\n\t  LIMIT 1 ) AS notes,\n       COALESCE(freightForRecv('TO', toitem_id, false),\n\t\tfreightForRecv('TO', toitem_id, true)) AS recv_freight,\n       baseCurrId() AS curr_id, CURRENT_DATE AS effective, \n       NULL AS recv_purchcost, NULL AS recv_purchcost_curr_id,\n       NULL AS costmethod_average,\n       'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n       'qty' AS orderitem_qty_ordered_xtnumericrole, \n       'qty' AS qtyreceived_xtnumericrole, \n       'qty' AS qtyreturned_xtnumericrole, \n       'qty' AS qtytoreceive_xtnumericrole, \n       'qty' AS receivable_xtnumericrole,\n       'purchprice' AS recv_purchcost_xtnumericrole \nFROM itemsite, tohead\n  JOIN toitem ON (tohead_id=toitem_tohead_id) \nWHERE ((toitem_status NOT IN ('C', 'X'))\n  AND  (toitem_id=<? value("orderitem_id") ?>)\n  AND  ('TO'=<? value("ordertype") ?>)\n  AND  (tohead_dest_warehous_id=itemsite_warehous_id)\n  AND  (toitem_item_id=itemsite_item_id))\n<? endif ?>;\n admin   2014-10-06      0
101145
 
58      itemReceipt     sourceItemSite   used by enterPoitemReceipt\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: itemReceipt\n-- Name: sourceItemSite\n-- Notes: used by enterPoitemReceipt\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("poitem_id") ?>\t\t\t-- this should never be called\n  SELECT -1 AS itemsite_id, -1 AS warehous_id;\n<? elseif exists("toitem_id") ?>\n  SELECT itemsite_id, tohead_dest_warehous_id AS warehous_id\n  FROM tohead, toitem, itemsite \n  WHERE ((itemsite_item_id=toitem_item_id)\n    AND  (itemsite_warehous_id=tohead_src_warehous_id)\n    AND  (toitem_tohead_id=tohead_id)\n    AND  (toitem_id=<? value("toitem_id") ?>));\n<? elseif exists("recv_id") ?>\t\t\t-- this should never be called\n  SELECT itemsite_id, tohead_dest_warehous_id AS warehous_id\n  FROM tohead, toitem, itemsite, recv\n  WHERE ((itemsite_item_id=toitem_item_id)\n    AND  (itemsite_warehous_id=tohead_src_warehous_id)\n    AND  (toitem_tohead_id=tohead_id)\n    AND  (toitem_id=recv_orderitem_id)\n    AND  (recv_id=<? value("recv_id") ?>));\n<? endif ?>\n admin   2014-10-06      0
101146
 
259     itemSites       detail  \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: itemSites\n-- Name: detail\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id,warehous_code,itemsite_qtyonhand, itemsite_active, \n       CASE WHEN ( (itemsite_loccntrl) OR\n                   (itemsite_controlmethod IN ('L', 'S')) ) THEN 1\n            ELSE 0\n       END AS altId,\n       CASE WHEN itemsite_controlmethod='R' THEN <? value("regular") ?>\n                           WHEN itemsite_controlmethod='N' THEN <? value("none") ?>\n                           WHEN itemsite_controlmethod='L' THEN <? value("lot") ?>\n                           WHEN itemsite_controlmethod='S' THEN <? value("serial") ?>\n                      END AS controlmethod,\n         itemsite_loccntrl,\n         item_number,\n         (item_descrip1 || ' ' || item_descrip2) AS description, \n         uom_name,\n         CASE WHEN (itemsite_sold) THEN TEXT(itemsite_soldranking)\n         END AS soldranking,\n         CASE WHEN (itemsite_datelastcount=startOfTime()) THEN NULL\n           ELSE itemsite_datelastcount\n         END AS datelastcount,\n         CASE WHEN (itemsite_datelastused=startOfTime()) THEN NULL\n           ELSE itemsite_datelastused\n         END AS datelastused,\n         itemsite_abcclass, itemsite_cyclecountfreq,\n         'qty' AS itemsite_qtyonhand_xtnumericrole,\n        <? value("na") ?> AS soldranking_xtnullrole,\n        <? value("never") ?> AS datelastused_xtnullrole,\n        <? value("never") ?> AS datelastcount_xtnullrole             \nFROM item, uom, itemsite, whsinfo\nWHERE ((itemsite_warehous_id=warehous_id)\n         AND (itemsite_item_id=item_id)\n         AND(item_inv_uom_id=uom_id)\n       <? if exists("search_pattern") ?>\n         AND ((item_number ~* <? value("search_pattern") ?>)\n           OR (COALESCE(item_descrip1,'') || ' ' || COALESCE(item_descrip2,'') ~* <? value("search_pattern") ?>)\n           OR (warehous_code ~* <? value("search_pattern") ?>))\n       <? endif ?>\n       <? if exists("item_id") ?>\n         AND (item_id=<? value("item_id") ?>)\n       <? endif ?>\n       <? if exists("classcode_id") ?>\n         AND (item_classcode_id=<? value("classcode_id") ?>)\n       <? endif ?>\n       <? if exists("itemgrp_id") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id \n                          FROM itemgrpitem \n                          WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n       <? endif ?>\n       <? if exists("plancode_id") ?>\n         AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n       <? endif ?>\n       <? if exists("costcat_id") ?>\n         AND (itemsite_costcat_id=<? value("costcat_id") ?>)\n       <? endif ?>\n       <? if exists("classcode_pattern") ?>\n         AND (item_classcode_id IN (SELECT classcode_id \n                                    FROM classcode \n                                    WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n       <? endif ?>\n       <? if exists("itemgrp_pattern") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id \n                          FROM itemgrpitem, itemgrp \n                          WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id) \n                              AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>) ) ))\n       <? endif ?>\n       <? if exists("plancode_pattern") ?>\n         AND (itemsite_plancode_id IN (SELECT plancode_id \n                                       FROM plancode \n                                       WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n       <? endif ?>\n       <? if exists("costcat_pattern") ?>\n         AND (itemsite_costcat_id IN (SELECT costcat_id \n                                      FROM costcat \n                                      WHERE (costcat_code ~ <? value("costcat_pattern") ?>)))\n       <? endif ?>\n     <? if exists("warehous_id") ?>\n       AND (warehous_id=<? value("warehous_id") ?>)\n     <? endif ?>\n   <? if not exists("showInactive") ?>\n     AND (itemsite_active)\n   <? endif ?>\n       )\nORDER BY item_number, warehous_code;\n  admin   2014-10-06      0
101147
 
260     itemSources     detail   \n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: itemSources\n-- Name: detail\n-- Notes: \n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n<? if not exists("defaultOnly") ?>\n  SELECT itemsrc_id, \n       vend_name, \n       item_number, uom_name,\n       (item_descrip1 || ' ' || item_descrip2) AS item_descrip,\n       contrct_number,\n       COALESCE( (SELECT SUM(poitem_qty_ordered)\n                  FROM poitem\n                  WHERE (poitem_itemsrc_id=itemsrc_id)), 0.0) AS purchased_qty,\n       itemsrc.*,\n       'qty' AS itemsrc_invvendoruomratio_xtnumericrole,\n       CASE WHEN COALESCE(itemsrc_effective, startOfTime()) <=\n                 startOfTime() THEN <? value("always") ?>\n       END AS itemsrc_effective_qtdisplayrole,\n       CASE WHEN COALESCE(itemsrc_expires, endOfTime()) >=\n                 endOfTime() THEN <? value("never") ?>\n       END AS itemsrc_expires_qtdisplayrole,\n       CASE WHEN (COALESCE(itemsrc_expires, endOfTime()) < CURRENT_DATE) THEN 'expired'\n            WHEN (COALESCE(itemsrc_effective, startOfTime()) > CURRENT_DATE) THEN 'future'\n       END AS qtforegroundrole\n  FROM itemsrc JOIN vendinfo ON (vend_id=itemsrc_vend_id AND vend_active)\n               JOIN item ON (item_id=itemsrc_item_id)\n               JOIN uom ON (uom_id=item_inv_uom_id)\n               LEFT OUTER JOIN contrct ON (contrct_id=itemsrc_contrct_id) \n  WHERE ((true)\n<? if not exists("showInactive") ?>\n   AND (itemsrc_active)\n<? endif ?>\n<? if exists("item_id") ?>\n   AND (itemsrc_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("vend_id") ?>\n   AND (itemsrc_vend_id=<? value("vend_id") ?>)\n<? endif ?>\n<? if exists("contrct_id") ?>\n   AND (itemsrc_contrct_id=<? value("contrct_id") ?>)\n<? endif ?>\n<? if exists("contract_number_pattern") ?>\n   AND (contrct_number ~* <? value("contract_number_pattern") ?>)\n<? endif ?>\n<? if not exists("showExpired") ?>\n   AND (itemsrc_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n   AND (itemsrc_effective <= CURRENT_DATE)\n<? endif ?>\n)\n<? if exists("item_id") ?>\nORDER BY itemsrc_contrct_id, itemsrc_ranking, vend_name,\n         itemsrc_vend_item_number, itemsrc_manuf_name,\n         itemsrc_manuf_item_number\n<? else ?>\nORDER By item_number, vend_name\n<? endif ?>\n<? else ?>\n  SELECT itemsrc_id, 0 AS ranked FROM itemsrc, contrct \n    WHERE ((itemsrc_item_id= <? value("item_id") ?>) AND (itemsrc_default) \n           AND (contrct_id = itemsrc_contrct_id)) \n  UNION \n  SELECT itemsrc_id, 2 AS ranked \n    FROM itemsrc JOIN (SELECT * FROM \n                        (SELECT CASE WHEN ((itemsrc_item_id=<? value("item_id") ?>) AND (NOT itemsrc_default)\n                                            AND (contrct_id = itemsrc_contrct_id)) THEN -1\n                                     ELSE itemsrc_id\n                                END AS dummy_id FROM itemsrc, contrct \n                           WHERE ((itemsrc_item_id=<? value("item_id") ?>) AND (NOT itemsrc_default) \n                                  AND (contrct_id = itemsrc_contrct_id))\n                         UNION \n                         SELECT itemsrc_id AS dummy_id \n                           FROM itemsrc \n                           WHERE ((itemsrc_item_id=<? value("item_id") ?>) AND (itemsrc_default))\n                         ) AS dummy\n                       LIMIT 1) AS dummy2\n                        ON (itemsrc_id=dummy_id)\n    WHERE ((itemsrc_item_id=<? value("item_id") ?>) AND (itemsrc_default) AND (COALESCE(itemsrc_contrct_id,0)=0))\n\nORDER by ranked\n<? endif ?>\n;\n   admin   2014-10-06      0
101148
 
476     itemSources     prices   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: itemSources\n-- Name: prices\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsrcp_id, itemsrc_id,\n       vend_number, vend_name,\n       currConcat(vend_curr_id) AS vend_curr,\n       item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS item_descrip,\n       warehous_code, uom_name,\n       contrct_number,\n       itemsrc.*,\n       (itemsrc_vend_item_number || '/' || itemsrc_manuf_item_number) AS itemsrc_descrip,\n       itemsrcp.*,\n       currConcat(itemsrcp_curr_id) AS item_curr,\n       noNeg(CASE WHEN (itemsrcp_type='N') THEN currToBase(itemsrcp_curr_id, itemsrcp_price, itemsrcp_updated)\n                  WHEN (itemsrcp_type='D') THEN (item_listcost - (item_listcost * COALESCE(itemsrcp_discntprcnt, 0.0)) - COALESCE(itemsrcp_fixedamtdiscount, 0.0))\n                  ELSE 0.0\n             END) AS price_base,\n       noNeg(CASE WHEN (itemsrcp_type='N') THEN itemsrcp_price\n                  WHEN (itemsrcp_type='D') THEN (item_listcost - (item_listcost * COALESCE(itemsrcp_discntprcnt, 0.0)) - COALESCE(itemsrcp_fixedamtdiscount, 0.0))\n                  ELSE 0.0\n             END) AS price_local,\n       CASE WHEN (itemsrcp_type='N') THEN <? value("nominal") ?>\n            WHEN (itemsrcp_type='D') THEN <? value("discount") ?>\n            ELSE 'error'\n       END AS type,\n       CASE WHEN (itemsrcp_type='N') THEN <? value("price") ?>\n            WHEN ((itemsrcp_type='D') AND (COALESCE(itemsrcp_discntprcnt, 0.0)=0.0) AND (COALESCE(itemsrcp_fixedamtdiscount, 0.0)<>0.0)) THEN <? value("fixed") ?>\n            WHEN ((itemsrcp_type='D') AND (COALESCE(itemsrcp_discntprcnt, 0.0)<>0.0) AND (COALESCE(itemsrcp_fixedamtdiscount, 0.0)=0.0)) THEN <? value("percent") ?>\n            WHEN (itemsrcp_type='D') THEN <? value("mixed") ?>\n            ELSE 'error'\n       END AS method,\n       'qty' AS itemsrc_invvendoruomratio_xtnumericrole,\n       'qty' AS itemsrc_minordqty_xtnumericrole,\n       'qty' AS itemsrc_ordqtymult_xtnumericrole,\n       'qty' AS itemsrcp_qtybreak_xtnumericrole,\n       'purchprice' AS price_local_xtnumericrole,\n       'purchprice' AS price_base_xtnumericrole,\n       'percent' AS itemsrcp_discntprcnt_xtnumericrole,\n       CASE WHEN (warehous_code IS NULL) THEN <? value("all") ?>\n       END AS warehous_code_qtdisplayrole,\n       CASE WHEN (itemsrcp_dropship) THEN <? value("dropship") ?>\n            ELSE <? value("stock") ?>\n       END AS itemsrcp_dropship_qtdisplayrole,\n       CASE WHEN COALESCE(itemsrc_effective, startOfTime()) <=\n                 startOfTime() THEN <? value("always") ?>\n       END AS itemsrc_effective_qtdisplayrole,\n       CASE WHEN COALESCE(itemsrc_expires, endOfTime()) >=\n                 endOfTime() THEN <? value("never") ?>\n       END AS itemsrc_expires_qtdisplayrole,\n       CASE WHEN (COALESCE(itemsrc_expires, endOfTime()) < CURRENT_DATE) THEN 'expired'\n            WHEN (COALESCE(itemsrc_effective, startOfTime()) > CURRENT_DATE) THEN 'future'\n       END AS qtforegroundrole\nFROM itemsrc JOIN vendinfo ON (vend_id=itemsrc_vend_id AND vend_active)\n             JOIN item ON (item_id=itemsrc_item_id)\n             JOIN uom ON (uom_id=item_inv_uom_id)\n             JOIN itemsrcp ON (itemsrcp_itemsrc_id=itemsrc_id)\n             LEFT OUTER JOIN contrct ON (contrct_id=itemsrc_contrct_id)\n             LEFT OUTER JOIN whsinfo ON (warehous_id=itemsrcp_warehous_id)\nWHERE ((true)\n<? if not exists("showInactive") ?>\n   AND (itemsrc_active)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND (itemsrc_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("vend_id") ?>\n  AND (itemsrc_vend_id=<? value("vend_id") ?>)\n<? endif ?>\n<? if exists("itemsrc_id") ?>\n  AND (itemsrc_id=<? value("itemsrc_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND (itemsrcp_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("showDropShip") ?>\n   AND (itemsrcp_dropship)\n<? endif ?>\n<? if exists("search_pattern") ?>\n  AND ( (item_number ~* <? value("search_pattern") ?>)\n    OR  (COALESCE(item_descrip1,'') || COALESCE(item_descrip2,'') ~* <? value("search_pattern") ?>) )\n<? endif ?>\n<? if exists("item_number_pattern") ?>\n  AND (item_number ~* <? value("item_number_pattern") ?>)\n<? endif ?>\n<? if exists("item_descrip_pattern") ?>\n  AND (COALESCE(item_descrip1,'') || COALESCE(item_descrip2,'') ~* <? value("item_descrip_pattern") ?>)\n<? endif ?>\n<? if exists("contrct_id") ?>\n  AND (itemsrc_contrct_id=<? value("contrct_id") ?>)\n<? endif ?>\n<? if exists("contract_number_pattern") ?>\n  AND (contrct_number ~* <? value("contract_number_pattern") ?>)\n<? endif ?>\n<? if exists("vend_name_pattern") ?>\n  AND (vend_name ~* <? value("vend_name_pattern") ?>)\n<? endif ?>\n<? if exists("vend_item_number_pattern") ?>\n  AND (itemsrc_vend_item_number ~* <? value("vend_item_number_pattern") ?>)\n<? endif ?>\n<? if exists("manuf_pattern") ?>\n  AND (itemsrc_manuf_name ~* <? value("manuf_pattern") ?>)\n<? endif ?>\n<? if exists("manuf_item_number_pattern") ?>\n  AND (itemsrc_manuf_item_number ~* <? value("manuf_item_number_pattern") ?>)\n<? endif ?>\n<? if exists("effectiveStartDate") ?>\n  AND (COALESCE(contrct_effective, itemsrc_effective) >= <? value("effectiveStartDate") ?>)\n<? endif ?>\n<? if exists("effectiveEndDate") ?>\n  AND (COALESCE(contrct_effective, itemsrc_effective) <= <? value("effectiveEndDate") ?>)\n<? endif ?>\n<? if exists("expireStartDate") ?>\n  AND (COALESCE(contrct_expires, itemsrc_expires) >= <? value("expireStartDate") ?>)\n<? endif ?>\n<? if exists("expireEndDate") ?>\n  AND (COALESCE(contrct_expires, itemsrc_expires) <= <? value("expireEndDate") ?>)\n<? endif ?>\n)\nORDER By item_number, vend_name, itemsrcp_qtybreak\n;\n admin   2014-10-06      0
101149
 
113     itemcostdetail  detail   dspItemCostDetail\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: itemcostdetail\n-- Name:  detail\n-- Notes: dspItemCostDetail\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT id, item.item_id, seqnumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n       qtyper,       'qtyper' AS qtyper_xtnumericrole,\n       scrap,        'scrap' AS scrap_xtnumericrole,\n       cost,         'cost' AS cost_xtnumericrole,\n       extendedcost, 'cost' AS extendedcost_xtnumericrole,\n       0 AS extendedcost_xttotalrole \nFROM uom, item, (\n<? if exists("useBOM") ?>\n     SELECT bomitem_id AS id, bomitem_seqnumber AS seqnumber,\n            (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper,\n            bomitem_scrap AS scrap,\n            bomitem_item_id AS item_id,\n  <? if exists("standardCost") ?>\n            itemcost_stdcost AS cost,\n            (itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL,\n                          (bomitem_qtyfxd/bomhead_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * itemcost_stdcost) AS extendedcost\n  <? elseif exists("actualCost") ?>\n            currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n            (itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL,\n                          (bomitem_qtyfxd/bomhead_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') *\n             currToBase(itemcost_curr_id, itemcost_actcost, NULL)) AS extendedcost \n  <? endif ?>\n    FROM bomitem\n         JOIN itemcost ON (itemcost_item_id=bomitem_item_id)\n         JOIN costelem ON (itemcost_costelem_id=costelem_id)\n         JOIN bomhead ON (bomhead_item_id=bomitem_parent_item_id AND bomhead_rev_id=bomitem_rev_id)\n  <? if exists("includeRevisionControl") ?>\n    LEFT OUTER JOIN rev ON ((bomitem_rev_id=rev_id) AND (COALESCE(rev_status, 'A')='A')) \n  <? endif ?>\n    WHERE ((CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires-1))\n     AND (bomitem_parent_item_id=<? value("item_id") ?>)\n     AND (costelem_id=<? value("costelem_id") ?>) ) \n<? elseif exists("useBBOM") ?>\n     SELECT bbomitem_id AS id, bbomitem_seqnumber AS seqnumber,\n            bbomitem_qtyper AS qtyper,\n            bbomitem_costabsorb AS scrap,\n            bbomitem_parent_item_id AS item_id,\n  <? if exists("standardCost") ?>\n            itemcost_stdcost AS cost,\n            (itemcost_stdcost / bbomitem_qtyper *\n             bbomitem_costabsorb) AS extendedcost \n  <? elseif exists("actualCost") ?>\n            currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n            (currToBase(itemcost_curr_id, itemcost_actcost, NULL) / bbomitem_qtyper *\n             bbomitem_costabsorb) AS extendedcost \n  <? endif ?>\n    FROM xtmfg.bbomitem\n         JOIN itemcost ON (itemcost_item_id=bbomitem_parent_item_id)\n    WHERE ((CURRENT_DATE BETWEEN bbomitem_effective AND (bbomitem_expires-1))\n     AND (itemcost_costelem_id=<? value("costelem_id") ?>)\n     AND (bbomitem_item_id=<? value("item_id") ?>) )\n    UNION\n    SELECT source.bbomitem_id, source.bbomitem_seqnumber AS seqnumber,\n           source.bbomitem_qtyper, target.bbomitem_costabsorb,\n           item_id,\n  <? if exists("standardCost") ?>\n           itemcost_stdcost AS cost,\n           (itemcost_stdcost * source.bbomitem_qtyper /\n            target.bbomitem_qtyper * target.bbomitem_costabsorb) AS extendedcost \n  <? elseif exists("actualCost") ?>\n           currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n           (currToBase(itemcost_curr_id, itemcost_actcost, NULL) * source.bbomitem_qtyper /\n            target.bbomitem_qtyper * target.bbomitem_costabsorb) AS extendedcost \n  <? endif ?>\n    FROM xtmfg.bbomitem AS source\n         JOIN item     ON (source.bbomitem_item_id=item_id)\n         JOIN itemcost ON (source.bbomitem_item_id=itemcost_item_id)\n         JOIN xtmfg.bbomitem AS target\n              ON (source.bbomitem_parent_item_id=target.bbomitem_parent_item_id)\n    WHERE ((CURRENT_DATE BETWEEN source.bbomitem_effective\n                            AND (source.bbomitem_expires-1))\n     AND (CURRENT_DATE BETWEEN target.bbomitem_effective\n                          AND (target.bbomitem_expires-1))\n     AND (item_type='Y')\n     AND (target.bbomitem_item_id=<? value("item_id") ?>)\n     AND (itemcost_costelem_id=<? value("costelem_id") ?>) )\n<? endif ?>\n) AS data \nWHERE ((data.item_id=item.item_id)\n   AND (item_inv_uom_id=uom_id)) \nORDER BY seqnumber;\n  admin   2014-10-06      0
101150
 
258     items   detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: items\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n SELECT\n        <? if exists("ListNumericItemNumbersFirst") ?>\n         DISTINCT ON ( toNumeric(item_number, 999999999999999), item_number )\n        <? else ?>\n         DISTINCT ON ( item_number )\n        <? endif ?>\n               item.*, classcode.*, uom.*, prodcat.*, freightclass.*,\n               <? foreach("char_id_text_list") ?>\n                      charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>,\n               <? endforeach ?>\n               <? foreach("char_id_list_list") ?>\n                      charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>,\n               <? endforeach ?>\n               <? foreach("char_id_date_list") ?>\n                      charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>,\n               <? endforeach ?>\n                      (COALESCE(item_descrip1,'') || ' ' || COALESCE(item_descrip2,'')) as item_descrip,\n                      CASE WHEN (item_type='P') THEN text(<? value("purchased") ?>)\n                           WHEN (item_type='M') THEN text(<? value("manufactured") ?>)\n                           WHEN (item_type='F') THEN text(<? value("phantom") ?>)\n                           WHEN (item_type='B') THEN text(<? value("breeder") ?>)\n                           WHEN (item_type='C') THEN text(<? value("coProduct") ?>)\n                           WHEN (item_type='Y') THEN text(<? value("byProduct") ?>)\n                           WHEN (item_type='R') THEN text(<? value("reference") ?>)\n                           WHEN (item_type='S') THEN text(<? value("costing") ?>)\n                           WHEN (item_type='T') THEN text(<? value("tooling") ?>)\n                           WHEN (item_type='A') THEN text(<? value("assortment") ?>)\n                           WHEN (item_type='O') THEN text(<? value("outside") ?>)\n                           WHEN (item_type='L') THEN text(<? value("planning") ?>)\n                           WHEN (item_type='K') THEN text(<? value("kit") ?>)\n                           ELSE text(<? value("error") ?>)\n                      END AS f_item_type,\n                      CASE WHEN (item_type='P') THEN text(<? value("purchased") ?>)\n                           WHEN (item_type='M') THEN text(<? value("manufactured") ?>)\n                           WHEN (item_type='F') THEN text(<? value("phantom") ?>)\n                           WHEN (item_type='B') THEN text(<? value("breeder") ?>)\n                           WHEN (item_type='C') THEN text(<? value("coProduct") ?>)\n                           WHEN (item_type='Y') THEN text(<? value("byProduct") ?>)\n                           WHEN (item_type='R') THEN text(<? value("reference") ?>)\n                           WHEN (item_type='S') THEN text(<? value("costing") ?>)\n                           WHEN (item_type='T') THEN text(<? value("tooling") ?>)\n                           WHEN (item_type='A') THEN text(<? value("assortment") ?>)\n                           WHEN (item_type='O') THEN text(<? value("outside") ?>)\n                           WHEN (item_type='L') THEN text(<? value("planning") ?>)\n                           WHEN (item_type='K') THEN text(<? value("kit") ?>)\n                           ELSE text(<? value("error") ?>)\n                      END AS item_type_qtdisplayrole\n               FROM item\n                 JOIN classcode ON (item_classcode_id=classcode_id)\n                 JOIN uom ON (item_inv_uom_id=uom_id)\n                 LEFT OUTER JOIN prodcat ON (item_prodcat_id=prodcat_id)\n                 LEFT OUTER JOIN freightclass ON (item_freightclass_id=freightclass_id)\n               <? if exists("itemgrp_id") ?>\n                 JOIN itemgrpitem ON (item_id=itemgrpitem_item_id)\n                 JOIN itemgrp ON (itemgrp_id=itemgrpitem_itemgrp_id)\n               <? endif ?>\n               <? foreach("char_id_text_list") ?>\n                 LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> \n                   ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='I') \n                   AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=item_id)\n                   AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n                 LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> \n                   ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n               <? endforeach ?>\n               <? foreach("char_id_list_list") ?>\n                 LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> \n                   ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='I') \n                   AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=item_id)\n                   AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n                 LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> \n                   ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n               <? endforeach ?>\n               <? foreach("char_id_date_list") ?>\n                 LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> \n                   ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='I') \n                   AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=item_id)\n                   AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n                 LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> \n                   ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n               <? endforeach ?>\n               WHERE ( true\n               <? if exists("search_pattern") ?>\n                AND ( (item_number ~* <? value("search_pattern") ?>)\n                      OR  (COALESCE(item_descrip1,'') || COALESCE(item_descrip2,'') ~* <? value("search_pattern") ?>) )\n               <? endif ?>\n               <? if exists("showPurchased") ?>\n                AND (item_type IN ('P', 'O'))\n               <? elseif exists("showManufactured") ?>\n                AND (item_type IN ('M', 'F', 'B','K'))\n               <? elseif exists("showSold") ?>\n                AND (item_sold)\n               <? endif ?>\n               <? if exists("item_type") ?>\n                AND (item_type=<? value("item_type") ?>)\n               <? endif ?>\n               <? if not exists("showInactive") ?>\n                AND (item_active)\n               <? endif ?>\n               <? if exists("classcode_id") ?>\n                AND (item_classcode_id=<? value("classcode_id") ?>)\n               <? endif ?>\n               <? if exists("prodcat_id") ?>\n                AND (item_prodcat_id=<? value("prodcat_id") ?>)\n               <? endif ?>\n               <? if exists("freightclass_id") ?>\n                AND (item_freightclass_id=<? value("freightclass_id") ?>)\n               <? endif ?>\n               <? if exists("itemgrp_id") ?>\n                AND (itemgrp_id=<? value("itemgrp_id") ?>)\n               <? endif ?>\n               <? if exists("item_number_pattern") ?>\n                AND (item_number ~* <? value("item_number_pattern") ?>)\n               <? endif ?>\n               <? if exists("item_descrip_pattern") ?>\n                AND (COALESCE(item_descrip1,'') || COALESCE(item_descrip2,'') ~* <? value("item_descrip_pattern") ?>)\n               <? endif ?>\n               <? if exists("classcode_pattern") ?>\n                AND (classcode_code ~* <? value("classcode_pattern") ?>)\n               <? endif ?>\n               <? if exists("prodcat_pattern") ?>\n                AND (prodcat_code  ~* <? value("prodcat_pattern") ?>)\n               <? endif ?>\n               <? if exists("freightclass_pattern") ?>\n                AND (freightclass_code ~* <? value("freightclass_pattern") ?>)\n               <? endif ?>\n               <? literal("charClause") ?>\n               ) ORDER BY\n               <? if exists("ListNumericItemNumbersFirst") ?>\n                toNumeric(item_number, 999999999999999),\n               <? endif ?>\n                item_number;\n  admin   2014-10-06      0
101151
 
261     itemsWithoutItemSources detail   used by dspItemsWithoutItemSources\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: itemsWithoutItemSources\n-- Name: detail\n-- Notes: used by dspItemsWithoutItemSources\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT item_id, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS descrip,\n       CASE WHEN (item_type = 'P') THEN <? value("purchased") ?>\n            WHEN (item_type = 'O') THEN <? value("outside") ?>\n       END AS type \nFROM item \nWHERE ( (item_type IN ('P', 'O'))\n    AND (item_active)\n    AND (item_id NOT IN (SELECT DISTINCT itemsrc_item_id\n                         FROM itemsrc \n                         WHERE (itemsrc_active))) ) \nORDER BY item_number;\n     admin   2014-10-06      0
101152
 
412     journals        detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: journals\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT sltrans.*,\n       CASE WHEN(sltrans_docnumber='Misc.' AND\n              invhist_docnumber IS NOT NULL) THEN\n              (sltrans_docnumber || ' - ' || invhist_docnumber)\n            ELSE sltrans_docnumber\n       END AS docnumber,\n       firstLine(sltrans_notes) AS notes,\n       sltrans_journalnumber,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       CASE WHEN (sltrans_amount < 0) THEN ABS(sltrans_amount)\n            ELSE NULL\n       END AS debit,\n       CASE WHEN (sltrans_amount > 0) THEN sltrans_amount\n            ELSE NULL\n       END AS credit,\n       sltrans_gltrans_journalnumber,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole\nFROM sltrans JOIN accnt ON (sltrans_accnt_id=accnt_id) \n     LEFT OUTER JOIN invhist ON (sltrans_misc_id=invhist_id\n                            AND sltrans_docnumber='Misc.') \n<? if exists("company_id") ?>\n     JOIN company ON (accnt_company=company_number) \n<? endif ?>\n<? if exists("prfcntr_id") ?>\n     JOIN prftcntr ON (accnt_profit=prftcntr_number) \n<? endif ?>\n<? if exists("subaccnt_id") ?>\n     JOIN subaccnt ON (accnt_sub=subaccnt_number) \n<? endif ?>\n<? if exists("subType") ?>\n     JOIN subaccnttype ON (subaccnttype_code=accnt_subaccnttype_code) \n<? endif ?>\nWHERE (\n<? if exists("startDate") ?>\n  <? if exists("endDate") ?>\n       (sltrans_date BETWEEN <? value("startDate") ?>\n                         AND <? value("endDate") ?>)\n  <? else ?>\n       (sltrans_date BETWEEN <? value("startDate") ?>\n                         AND endoftime())\n  <? endif ?>\n<? else ?>\n  <? if exists("endDate") ?>\n       (sltrans_date BETWEEN startoftime()\n                         AND <? value("endDate") ?>)\n  <? else ?>\n       (sltrans_date BETWEEN startoftime()\n                         AND endoftime())\n  <? endif ?>\n<? endif ?>\n<? if exists("company_id") ?>\n   AND (company_id=<? value("company_id") ?>)\n<? endif ?>\n<? if exists("prfcntr_id") ?>\n   AND (prftcntr_id=<? value("prfcntr_id") ?>)\n<? endif ?>\n<? if exists("accnt_number") ?>\n   AND (accnt_number=<? value("accnt_number") ?>)\n<? endif ?>\n<? if exists("subaccnt_id") ?>\n   AND (subaccnt_id=<? value("subaccnt_id") ?>)\n<? endif ?>\n<? if exists("subType") ?>\n   AND (subaccnttype_id=<? value("subType") ?>)\n<? endif ?>\n<? if exists("accntType") ?>\n   AND (accnt_type= <? value("accntType") ?>)\n<? endif ?>\n<? if exists("accnt_id") ?>\n   AND (sltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n<? if exists("docnum") ?>\n   AND (sltrans_docnumber = case when <? value("docnum") ?> = '' then \n sltrans_docnumber else \n<? value("docnum") ?> end ) \n<? endif ?>\n<? if exists("source") ?>\n   AND (sltrans_source=<? value("source") ?>)\n<? endif ?>\n<? if exists("source_pattern") ?>\n   AND (sltrans_source ~* <? value("source_pattern") ?>)\n<? endif ?>\n<? if exists("posted") ?>\n   AND (sltrans_posted=<? value("posted") ?>)\n<? endif ?>\n<? if exists("journalnumber") ?>\n   AND (sltrans_gltrans_journalnumber::text=<? value("journalnumber") ?>)\n<? endif ?>\n) \nORDER BY sltrans_created,\n   sltrans_sequence, sltrans_amount;\n admin   2014-10-06      0
101153
 
60      manufacture     jobcosting       used by dspJobCosting\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: manufacture\n-- Name: jobcosting\n-- Notes: used by dspJobCosting\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *, 0 AS cost_xttotalrole,\n       'qty' AS qty_xtnumericrole,\n       'cost' AS cost_xtnumericrole\nFROM (\n  SELECT womatl_id AS id, 3 AS sort,\n         <? value("material") ?> AS type, item_number AS code,\n         item_descrip1 AS descrip,\n         (SUM(COALESCE(invhist_invqty,0))) AS qty,\n         uom_name AS uom,\n         SUM(COALESCE(invhist_invqty * invhist_unitcost,0)) AS cost,\n         NULL as wooper_seqnumber\n  FROM womatl\n    LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n    LEFT OUTER JOIN invhist ON (womatlpost_invhist_id=invhist_id),\n    itemsite, item, uom\n  WHERE ((womatl_wo_id=<? value("wo_id") ?>)\n     AND (womatl_itemsite_id=itemsite_id)\n     AND (itemsite_item_id=item_id)\n     AND (item_inv_uom_id=uom_id))\n  GROUP BY womatl_id, item_number, item_descrip1, uom_name\n  ) AS data\nORDER BY sort, code;\n  admin   2014-10-06      0
101154
 
458     packingList     getreport        get the reportname should be used for a packing list or pick list\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: packingList\n-- Name:  getreport\n-- Notes: get the reportname should be used for a packing list or pick list\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists('sohead_id') ?>\nSELECT findCustomerForm(cohead_cust_id,\n                       <? value('form') ?>) AS reportname\n  FROM cohead \n WHERE (cohead_id=<? value('sohead_id' ?>);\n<? elseif exists('tohead_id') ?>\nSELECT findTOForm(<? value('tohead_id') ?>,\n                  <? value('form') ?>) AS reportname;\n<? endif ?>\n    admin   2014-10-06      0
101155
 
451     metasqls        detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: metasqls\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists('byPackage') ?>\nSELECT metasql_id, metasql_group, metasql_name,\n       firstline(metasql_notes) AS metasql_notes, metasql_grade,\n       CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n       CASE nspname WHEN 'public' THEN 0\n                                  ELSE 1 END AS xtindentrole,\n       metasql_notes AS metasql_notes_qttooltiprole \n  FROM metasql\n  JOIN pg_class     ON (metasql.tableoid=pg_class.oid)\n  JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n UNION \nSELECT -1, pkghead_name, NULL,\n       firstline(pkghead_descrip), NULL,\n       pkghead_name, 0, pkghead_descrip\n  FROM metasql, pg_class, pg_namespace\n       RIGHT OUTER JOIN pkghead ON (nspname=pkghead_name)\n WHERE ((metasql.tableoid=pg_class.oid)\n    AND (relnamespace=pg_namespace.oid))\nORDER BY pkgname, xtindentrole, metasql_group, metasql_name,\n         metasql_grade DESC, metasql_id;\n<? else ?>\nSELECT metasql_id, metasql_group, metasql_name,\n       firstline(metasql_notes) AS metasql_notes,\n       metasql_grade,\n       CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n       metasql_notes AS metasql_notes_qttooltiprole \n  FROM metasql\n  JOIN pg_class     ON (metasql.tableoid=pg_class.oid)\n  JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nORDER BY metasql_group, metasql_name,\n         metasql_grade DESC, metasql_id;\n <? endif ?>\n     admin   2014-10-06      0
101156
 
262     mrpDetail       detail   used by dspMRPDetail\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: mrpDetail\n-- Name: detail\n-- Notes: used by dspMRPDetail\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT qtyNetable(itemsite_id) AS qoh, formatQty(qtyNetable(itemsite_id)) AS f_qoh,\n       qtyAllocated(itemsite_id, findPeriodStart(<? value("cursorId") ?>),\n                       findPeriodEnd(<? value("cursorId") ?>)) AS allocations<? value("counter") ?>,\n       qtyOrdered(itemsite_id, findPeriodStart(<? value("cursorId") ?>),\n                       findPeriodEnd(<? value("cursorId") ?>)) AS orders<? value("counter") ?>,\n       qtyFirmedAllocated(itemsite_id, findPeriodStart(<? value("cursorId") ?>),\n                       findPeriodEnd(<? value("cursorId") ?>)) AS firmedallocations<? value("counter") ?>,\n       qtyFirmed(itemsite_id, findPeriodStart(<? value("cursorId") ?>),\n                       findPeriodEnd(<? value("cursorId") ?>)) AS firmedorders<? value("counter") ?>\nFROM itemsite\nWHERE (itemsite_id=<? value("itemsite_id") ?>);\n        admin   2014-10-06      0
101157
 
263     mrpDetail       item     used by dspMRPDetail\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: mrpDetail\n-- Name: item\n-- Notes: used by dspMRPDetail\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, item_type, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS descrip,\n       warehous_code\nFROM itemsite, item, whsinfo\nWHERE ( (itemsite_active)\n    AND (itemsite_item_id=item_id)\n    AND (itemsite_warehous_id=warehous_id)\n    AND (itemsite_planning_type='M')\n<? if exists("plancode_id") ?>\n    AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n    AND (itemsite_plancode_id IN (SELECT plancode_id \n                                  FROM plancode \n                                  WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?>\n    AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nORDER BY item_number, warehous_code;\n      admin   2014-10-06      0
101158
 
440     openVouchers    populate         used by openVouchers\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: openVouchers\n-- Name: populate\n-- Notes: used by openVouchers\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT vohead_id, COALESCE(pohead_id, -1), vohead_number,\n       COALESCE(TEXT(pohead_number), TEXT(<? value("misc") ?>)) AS ponumber,\n       (vend_number || '-' || vend_name) AS vendor, vendtype_code, vohead_invcnumber,\n       vohead_distdate, COALESCE(vohead_gldistdate, vohead_distdate) AS postdate,\n       vohead_amount, 'curr' AS vohead_amount_xtnumericrole,\n       formatDate(vohead_distdate) AS f_distdate,\n       formatDate(COALESCE(vohead_gldistdate, vohead_distdate)) AS f_postdate,\n       formatMoney(vohead_amount) AS f_amount\n  FROM vendinfo JOIN vendtype ON (vendtype_id=vend_vendtype_id)\n                JOIN vohead ON (vohead_vend_id=vend_id)\n                LEFT OUTER JOIN pohead ON (vohead_pohead_id=pohead_id) \n WHERE (NOT vohead_posted)\n<? if exists("vend_id") ?>\n AND (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n AND (vendtype_code ~ <? value("vendtype_pattern") ?>)\n<? endif ?>\n ORDER BY vohead_number;\n \n  admin   2014-10-06      0
101159
 
264     openpurchaseorders      detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: openpurchaseorders\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n       pohead_id AS id, COALESCE(pohead_cohead_id, -1) AS altid,\n       pohead.*,\n       calcPurchaseOrderDueDate(pohead_id) AS min_duedate,\n       calcPurchaseOrderAmt(pohead_id) AS order_total,\n       vend_name, vend_number, vendtype_code,\n<? foreach("char_id_text_list") ?>\n       charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>,\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n       charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>,\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n       charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>,\n<? endforeach ?>\n       CASE WHEN(pohead_status='C') THEN <? value("closed") ?>\n            WHEN(pohead_status='U') THEN <? value("unposted") ?>\n            WHEN(pohead_status='O') THEN <? value("open") ?>\n            ELSE pohead_status\n       END AS pohead_status_qtdisplayrole,\n       'currency' AS order_total_xtnumericrole\nFROM pohead \n     JOIN vendinfo ON (pohead_vend_id=vend_id)\n     JOIN vendtype ON (vend_vendtype_id=vendtype_id)\n<? if exists("pohead_agent_usr_id") ?>\n     JOIN usr ON (pohead_agent_username=usr_username)\n<? endif ?> \n<? if exists("warehous_id") ?>\n     JOIN poitem ON (poitem_pohead_id=pohead_id) \n     JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n<? endif ?> \n<? foreach("char_id_text_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> \n          ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='PO') \n         AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=pohead_id)\n         AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> \n          ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> \n          ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='PO') \n         AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=pohead_id)\n         AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> \n          ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> \n          ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='PO') \n         AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=pohead_id)\n         AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> \n          ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE ( true\n<? if exists("search_pattern") ?> \n  AND ((pohead_number::text ~* <? value("search_pattern") ?>) \n    OR (vend_number ~* <? value("search_pattern") ?>)\n    OR (vend_name ~* <? value("search_pattern") ?>)\n    OR (pohead_agent_username ~* <? value("search_pattern") ?>)\n    OR (vendtype_code ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_vend_cntct_first_name,'') || ' ' || COALESCE(pohead_vend_cntct_last_name,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_vend_cntct_phone,'') ||' ' || COALESCE(pohead_vend_cntct_fax,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_vend_cntct_email,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_vendaddress1,'') || ' ' || COALESCE(pohead_vendaddress2,'') || ' ' || COALESCE(pohead_vendaddress3,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_vendcity,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_vendstate,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_vendzipcode,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_vendcountry,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_shipto_cntct_first_name,'') || ' ' || COALESCE(pohead_shipto_cntct_last_name,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_shipto_cntct_phone,'') || ' ' || COALESCE(pohead_shipto_cntct_fax,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_shipto_cntct_email,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_shiptoaddress1,'') || ' ' || COALESCE(pohead_vendaddress2,'') || ' ' || COALESCE(pohead_vendaddress3,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_shiptocity,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_shiptostate,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_shiptozipcode,'') ~* <? value("search_pattern") ?>)\n    OR (COALESCE(pohead_shiptocountry,'') ~* <? value("search_pattern") ?>)\n    )\n<? endif ?> \n<? if exists("showUnreleased") ?> \n  AND (pohead_status ='U') \n<? endif ?> \n<? if exists("showOpen") ?>\n  AND (pohead_status='O' )\n<? endif ?> \n<? if exists("showBoth") ?> \n  AND (pohead_status IN ('U', 'O') ) \n<? endif ?> \n<? if exists("shownothing") ?> \n  AND (pohead_status NOT IN ('U', 'O', 'C')) \n<? endif ?> \n<? if exists("vend_id") ?>\n  AND (vend_id=<? value("vend_id") ?>)\n<? endif ?> \n<? if exists("vendtype_id") ?>\n  AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? endif ?> \n<? if exists("vendtype_pattern") ?>\n  AND (vendtype_code ~* <? value("vendtype_pattern") ?>)\n<? endif ?> \n<? if exists("pohead_agent_usr_id") ?>\n  AND (usr_id  = <? value("pohead_agent_usr_id") ?>)\n<? endif ?> \n<? if exists("warehous_id") ?>\n  AND (itemsite_warehous_id = <? value("warehous_id") ?>)\n<? endif ?> \n<? literal("charClause") ?>\n ) \nORDER BY pohead_number;\n admin   2014-10-06      0
101160
 
229     pricelist       detail   This query displays price lists and the data used to perform\n        price calculations. It avoids price calculations where possible.\n        The UNION sets the sourcecode column to show how the price list entry\n        was derived:  customer vs customer type vs customer type regex ..., etc.\n        Then the outer query modifies the sourcecode to indicate\n        item vs product category.\n        TODO: possible improvements include removing OUTER JOINs with uom table\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: pricelist\n-- Name:  detail\n-- Notes: This query displays price lists and the data used to perform\n--        price calculations. It avoids price calculations where possible.\n--        The UNION sets the sourcecode column to show how the price list entry\n--        was derived:  customer vs customer type vs customer type regex ..., etc.\n--        Then the outer query modifies the sourcecode to indicate\n--        item vs product category.\n--        TODO: possible improvements include removing OUTER JOINs with uom table\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT sourcecode + CASE WHEN source='P' THEN 10 ELSE 0 END AS source,\n       sourceid, schedulename, type,\n       invqty AS qty_break,\n       CASE WHEN (qtybreak = -1) THEN <? value('na') ?>\n       END             AS qty_break_qtdisplayrole,\n       invuom.uom_name AS qty_uom,\n       price,\n       currConcat(curr_id) AS currency,\n       priceuom.uom_name   AS price_uom,\n       currToCurr(curr_id, <? value('curr_id') ?>,\n                  price,   <? value('effective') ?>) AS base_price,\n       discountpercent,\n       discountfixed,\n       CASE WHEN (price_type='N') THEN <? value('nominal') ?>\n            WHEN (price_type='D') THEN <? value('discount') ?>\n            WHEN (price_type='M') THEN <? value('markup') ?>\n       END AS price_type,\n       'qty'        AS qty_break_xtnumericrole,\n       'salesprice' AS price_xtnumericrole,\n       'salesprice' AS base_price_xtnumericrole,\n       'percent'    AS discountpercent_xtnumericrole,\n       'salesprice' AS discountfixed_xtnumericrole\nFROM ( \n\n    SELECT 4 AS sourcecode,\n           ipsitem_id AS sourceid,\n           CASE WHEN (ipsitem_item_id=<? value('item_id') ?>) THEN 'I'\n                WHEN (ipsitem_prodcat_id=<? value('prodcat_id') ?>) THEN 'P'\n                ELSE 'Error'\n           END AS source,\n           ipshead_id,\n           ipshead_name AS schedulename,\n           (<? value('sale') ?> || '-' || sale_name) AS type,\n           CASE WHEN (ipsitem_item_id=<? value('item_id') ?>) THEN itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak)\n                ELSE ipsitem_qtybreak\n           END AS invqty,\n           ipsitem_qtybreak AS qtybreak,\n           CASE WHEN (ipsitem_type = 'N') THEN\n                 (ipsitem_price * itemuomtouomratio(<? value('item_id') ?>, NULL, ipsitem_price_uom_id)) * iteminvpricerat(ipsitem_item_id)\n                WHEN (ipsitem_type = 'D') THEN\n                 noNeg(<? value('item_listprice') ?> - (<? value('item_listprice') ?> * ipsitem_discntprcnt) - ipsitem_fixedamtdiscount)\n                WHEN ((ipsitem_type = 'M') AND fetchMetricBool('Long30Markups') AND fetchMetricBool('WholesalePriceCosting')) THEN\n                 (<? value('item_listcost') ?> / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n                WHEN ((ipsitem_type = 'M') AND fetchMetricBool('Long30Markups')) THEN\n                 (<? value('item_unitcost') ?> / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n                WHEN (ipsitem_type = 'M' AND fetchMetricBool('WholesalePriceCosting')) THEN\n                 (<? value('item_listcost') ?> + (<? value('item_listcost') ?> * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n                WHEN (ipsitem_type = 'M') THEN\n                 (<? value('item_unitcost') ?> + (<? value('item_unitcost') ?> * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n                ELSE 0.00\n           END AS price,\n           ipsitem_qty_uom_id AS qtybreak_uom_id,\n           ipsitem_price_uom_id AS price_uom_id,\n           ipsitem_discntprcnt AS discountpercent,\n           ipsitem_fixedamtdiscount AS discountfixed,\n           ipshead_curr_id AS curr_id,\n           ipsitem_type AS price_type\n    FROM sale JOIN ipshead ON (ipshead_id=sale_ipshead_id)\n              JOIN ipsiteminfo ON (ipsitem_ipshead_id=ipshead_id)\n              JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)\n   WHERE ((ipsitem_item_id=<? value('item_id') ?>) OR (ipsitem_prodcat_id=<? value('prodcat_id') ?>))\n      AND (<? value('asof') ?> BETWEEN sale_startdate AND sale_enddate)\n      AND ( ((COALESCE(ipsass_shipto_id, -1) > 0) AND (ipsass_shipto_id=<? value('shipto_id') ?>))\n       OR   ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (<? value('shipto_num') ?> ~ ipsass_shipto_pattern))\n       OR   (ipsass_cust_id=<? value('cust_id') ?>)\n       OR   (ipsass_custtype_id=<? value('custtype_id') ?>)\n       OR   ((COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND (<? value('custtype_code') ?> ~ ipsass_custtype_pattern)) )\n\n    UNION\n\n    SELECT CASE WHEN (COALESCE(ipsass_shipto_id, -1) > 0) THEN 6\n                WHEN (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) THEN 7\n                WHEN (COALESCE(ipsass_cust_id, -1) > 0) THEN 1\n                WHEN (COALESCE(ipsass_custtype_id, -1) > 0) THEN 2\n                WHEN (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) THEN 3\n                ELSE 99\n           END AS sourcecode,\n           ipsitem_id AS sourceid,\n           CASE WHEN (ipsitem_item_id=<? value('item_id') ?>) THEN 'I'\n                WHEN (ipsitem_prodcat_id=<? value('prodcat_id') ?>) THEN 'P'\n                ELSE 'Error'\n           END AS source,\n           ipshead_id,\n           ipshead_name AS schedulename,\n           CASE WHEN (COALESCE(ipsass_shipto_id, -1) > 0) THEN <? value('shipTo') ?>\n                WHEN (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) THEN <? value('shipToPattern') ?>\n                WHEN (COALESCE(ipsass_cust_id, -1) > 0) THEN <? value('customer') ?>\n                WHEN (COALESCE(ipsass_custtype_id, -1) > 0) THEN <? value('custType') ?>\n                WHEN (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) THEN <? value('custTypePattern') ?>\n                ELSE 'Error'\n           END AS type,\n           CASE WHEN (ipsitem_item_id=<? value('item_id') ?>) THEN itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak)\n                ELSE ipsitem_qtybreak\n           END AS invqty,\n           ipsitem_qtybreak AS qtybreak,\n           CASE WHEN ipsitem_type = 'N' THEN\n                 (ipsitem_price * itemuomtouomratio(<? value('item_id') ?>, NULL, ipsitem_price_uom_id)) * iteminvpricerat(ipsitem_item_id)\n                WHEN ipsitem_type = 'D' THEN\n                 noNeg(<? value('item_listprice') ?> - (<? value('item_listprice') ?> * ipsitem_discntprcnt) - ipsitem_fixedamtdiscount)\n                WHEN ((ipsitem_type = 'M') AND fetchMetricBool('Long30Markups') AND fetchMetricBool('WholesalePriceCosting')) THEN\n                 (<? value('item_listcost') ?> / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n                WHEN ((ipsitem_type = 'M') AND fetchMetricBool('Long30Markups')) THEN\n                 (<? value('item_unitcost') ?> / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n                WHEN (ipsitem_type = 'M' AND fetchMetricBool('WholesalePriceCosting')) THEN\n                 (<? value('item_listcost') ?> + (<? value('item_listcost') ?> * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n                WHEN (ipsitem_type = 'M') THEN\n                 (<? value('item_unitcost') ?> + (<? value('item_unitcost') ?> * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n                ELSE 0.00\n           END AS price,\n           ipsitem_qty_uom_id AS qtybreak_uom_id,\n           ipsitem_price_uom_id AS price_uom_id,\n           ipsitem_discntprcnt AS discountpercent,\n           ipsitem_fixedamtdiscount AS discountfixed,\n           ipshead_curr_id AS curr_id,\n           ipsitem_type AS price_type\n    FROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n                JOIN ipsiteminfo ON (ipsitem_ipshead_id=ipshead_id)\n    WHERE ((ipsitem_item_id=<? value('item_id') ?>) OR (ipsitem_prodcat_id=<? value('prodcat_id') ?>))\n      AND (<? value('asof') ?> BETWEEN ipshead_effective AND ipshead_expires)\n      AND ( ((COALESCE(ipsass_shipto_id, -1) > 0) AND (ipsass_shipto_id=<? value('shipto_id') ?>))\n       OR   ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (<? value('shipto_num') ?> ~ ipsass_shipto_pattern))\n       OR   (ipsass_cust_id=<? value('cust_id') ?>)\n       OR   (ipsass_custtype_id=<? value('custtype_id') ?>)\n       OR   ((COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND (<? value('custtype_code') ?> ~ ipsass_custtype_pattern))\n          )\n\n    UNION\n\n    SELECT 5 AS sourcecode,\n           item_id AS sourceid,\n           NULL AS source,\n           NULL AS ipshead_id,\n           '' AS schedulename,\n           <? value('listPrice') ?> AS type,\n           -1 AS invqty,\n           -1 AS qtybreak,\n           (item_listprice - (item_listprice * cust_discntprcnt)) AS price,\n           item_inv_uom_id   AS qtybreak_uom_id,\n           item_price_uom_id AS price_uom_id,\n           cust_discntprcnt  AS discountpercent,\n           NULL              AS discountfixed,\n           baseCurrId() AS curr_id,\n           NULL AS price_type\n    FROM item, custinfo\n    WHERE (item_sold\n      AND (NOT item_exclusive)\n       AND (item_id=<? value('item_id') ?>)\n       AND (cust_id=<? value('cust_id') ?>) ) ) AS data\n\n  LEFT OUTER JOIN uom AS invuom ON (invuom.uom_id=qtybreak_uom_id)\n  LEFT OUTER JOIN uom AS priceuom ON (priceuom.uom_id=price_uom_id)\n\n ORDER BY price_uom_id, price;\n  admin   2014-10-06      0
101161
 
265     opensalesorders detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: opensalesorders\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n       cohead.*,\n       COALESCE(cust_number, :error) AS cust_number,\n       getSoSchedDate(cohead_id) AS scheddate, \n       getSoStatus(cohead_id) AS status,\n<? foreach("char_id_text_list") ?>\n       charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>,\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n       charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>,\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n       charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>,\n<? endforeach ?>\n       firstline(cohead_ordercomments) AS notes,\n       calcSalesOrderAmt(cohead_id) AS ordertotal,\n       CASE WHEN (calcSalesOrderAmt(cohead_id,'S') != 0.0)\n              THEN calcSalesOrderAmt(cohead_id,'M')\n            ELSE 0.0\n       END AS ordermargin,\n       CASE WHEN (calcSalesOrderAmt(cohead_id,'S') != 0.0)\n              THEN (calcSalesOrderAmt(cohead_id,'M') / calcSalesOrderAmt(cohead_id,'S'))\n            ELSE 1.0\n       END AS ordermarginpercent,\n       'percent' AS ordermarginpercent_xtnumericrole,\n       'extprice' AS ordertotal_xtnumericrole,\n       'extprice' AS ordermargin_xtnumericrole\nFROM cohead \n     JOIN custinfo ON (cohead_cust_id=cust_id) \n     JOIN custtype ON (cust_custtype_id=custtype_id)\n<? if exists("selectedSites") ?> \n     JOIN coitem ON (coitem_cohead_id=cohead_id) \n     JOIN itemsite ON (coitem_itemsite_id=itemsite_id) \n     JOIN site() ON (itemsite_warehous_id=warehous_id) \n<? elseif  exists("warehous_id") ?> \n     LEFT OUTER JOIN coitem ON (coitem_cohead_id=cohead_id) \n     LEFT OUTER JOIN itemsite ON (coitem_itemsite_id=itemsite_id) \n     LEFT OUTER JOIN whsinfo ON (itemsite_warehous_id=warehous_id) \n<? endif ?> \n<? foreach("char_id_text_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> \n          ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='SO') \n         AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=cohead_id)\n         AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> \n          ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> \n          ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='SO') \n         AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=cohead_id)\n         AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> \n          ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n     LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> \n          ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='SO') \n         AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=cohead_id)\n         AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n     LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> \n          ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE((true) \n<? if exists("cust_id") ?>\n  AND (cust_id=<? value("cust_id") ?> )\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND (custtype_code ~* <? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("poNumber") ?>\n  AND  (cohead_custponumber~*<? value("poNumber") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND (cohead_orderdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if not exists("showClosed") ?> \n  AND (cohead_status='O')\n<? endif ?>\n<? if  exists("warehous_id") ?>\n  AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if  exists("salesrep_id") ?>\n  AND (cohead_salesrep_id=<? value("salesrep_id") ?>)\n<? endif ?>\n<? literal("charClause") ?>\n  ) \nORDER BY cohead_number;\n        admin   2014-10-06      0
101162
 
63      opportunities   detail   used by opportunityList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: opportunities\n-- Name: detail\n-- Notes: used by opportunityList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (incdtpriority_order, ophead_target_date, ophead_name, ophead_id) \n       ophead_id AS id,\n       CASE WHEN (ophead_active) THEN 0 ELSE 1 END AS altId,\n       ophead_number,\n       ophead_name,\n       ophead_active,\n       crmacct_number,\n       ophead_owner_username,\n       ophead_username,\n       opstage_name,\n       incdtpriority_name,\n       opsource_name,\n       optype_name,\n       (ophead_probability_prcnt * .01) AS ophead_probability_prcnt,\n       ophead_amount,\n       currConcat(ophead_curr_id) As f_currency,\n       ophead_target_date,\n       ophead_actual_date,\n       formatMoney(ophead_amount) AS f_amount,\n       formatMoney(COALESCE(ophead_amount,0) * COALESCE(ophead_probability_prcnt * 0.01)) AS f_value,\t\n       formatDate(ophead_target_date) AS f_targetdate,\n       formatDate(ophead_actual_date) AS f_actualdate,\n       'extprice' AS ophead_amount_xtnumericrole,\n       'percent' AS ophead_probability_prcnt_xtnumericrole\n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\nFROM ophead()\n  LEFT OUTER JOIN incdtpriority ON (ophead_priority_id=incdtpriority_id)\n  LEFT OUTER JOIN crmacct ON (ophead_crmacct_id=crmacct_id)\n  LEFT OUTER JOIN opstage ON (ophead_opstage_id=opstage_id)\n  LEFT OUTER JOIN opsource ON (ophead_opsource_id=opsource_id)\n  LEFT OUTER JOIN optype ON (ophead_optype_id=optype_id)\n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='OPP') \n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=ophead_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='OPP') \n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=ophead_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='OPP') \n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=ophead_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE((true)\n<? if exists("startDate") ?>\n   AND ((ophead_target_date >= <? value("startDate") ?>)\n    OR (<? value("startDate") ?> <= startOfTime()) AND (ophead_target_date IS NULL))\n<? endif ?>\n<? if exists("endDate") ?>\n   AND ((ophead_target_date <= <? value("endDate") ?>)\n    OR (<? value("endDate") ?> >= endOfTime()) AND (ophead_target_date IS NULL))\n<? endif ?>\n<? if exists("opsource_id") ?>\n   AND (ophead_opsource_id=<? value("opsource_id") ?>)\n<? endif ?>\n<? if exists("opsource_pattern") ?>\n   AND (opsource_name ~ <? value("opsource_pattern") ?>)\n<? endif ?>\n<? if exists("opstage_id") ?>\n   AND (ophead_opstage_id=<? value("opstage_id") ?>)\n<? endif ?>\n<? if exists("opstage_pattern") ?>\n   AND (opstage_name ~ <? value("opstage_pattern") ?>)\n<? endif ?>\n<? if exists("optype_id") ?>\n   AND (ophead_optype_id=<? value("optype_id") ?>)\n<? endif ?>\n<? if exists("optype_pattern") ?>\n   AND (optype_name ~ <? value("optype_pattern") ?>)\n<? endif ?>\n<? if exists("username") ?>\n   AND (<? value("username") ?> IN (ophead_username, ophead_owner_username))\n<? endif ?>\n<? if exists("assigned_username") ?>\n   AND (ophead_username=<? value("assigned_username") ?>)\n<? endif ?>\n<? if exists("assigned_usr_pattern") ?>\n   AND (ophead_username ~ <? value("assigned_usr_pattern") ?>)\n<? endif ?>\n<? if exists("owner_username") ?>\n   AND (ophead_owner_username=<? value("owner_username") ?>)\n<? endif ?>\n<? if exists("owner_usr_pattern") ?>\n   AND (ophead_owner_username ~ <? value("owner_usr_pattern") ?>)\n<? endif ?>\n<? if exists("crmacct_id") ?>\n   AND (ophead_crmacct_id = <? value("crmacct_id") ?>)\n<? endif ?>\n<? if exists("search_pattern") ?> \n   AND (ophead_name ~* <? value("search_pattern") ?>)\n<? endif ?>\n<? if exists("activeOnly") ?> \n   AND (ophead_active)\n<? endif ?>\n<? if exists("id") ?>\n   AND (ophead_id=<? value("id") ?>\n<? endif ?>\n<? literal("charClause") ?>\n )\nORDER BY incdtpriority_order, ophead_target_date, ophead_name, ophead_id;\n      admin   2014-10-06      0
101163
 
62      opportunitiesByCRM      detail   used by crmaccount\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: opportunitiesByCRM\n-- Name: detail\n-- Notes: used by crmaccount\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ophead_id, *,\n       currConcat(ophead_curr_id) AS ophead_currabbr,\n       'currval' AS ophead_amount_xtnumericrole\n  FROM ophead\n       LEFT OUTER JOIN crmacct ON (ophead_crmacct_id=crmacct_id)\n       LEFT OUTER JOIN opstage ON (ophead_opstage_id=opstage_id)\n       LEFT OUTER JOIN opsource ON (ophead_opsource_id=opsource_id)\n       LEFT OUTER JOIN optype ON (ophead_optype_id=optype_id)\n WHERE((crmacct_id=<? value("crmacct_id") ?>)\n<? if exists("username") ?>\n   AND (ophead_owner_username=<? value("username") ?>)\n<? elseif exists("usr_pattern") ?>\n   AND (ophead_owner_username ~ <? value("username_pattern") ?>)\n<? endif ?>\n )\n ORDER BY ophead_target_date;\n admin   2014-10-06      0
101164
 
266     orderActivityByProject  detail   All projects\n -- Group: orderActivityByProject\n-- Name:  detail\n-- Notes: All projects\n\nSELECT *, \n  formatQty(qty) AS f_qty,\n  formatMoney(value) AS f_value,\n  'curr' AS qty_xtnumericrole,\n  'curr' AS value_xtnumericrole,\n  CASE WHEN COALESCE(hrs_balance,0) < 0 THEN 'red' END AS hrs_balance_qtforegroundrole,\n  CASE WHEN COALESCE(exp_balance,0) < 0 THEN 'red' END AS exp_balance_qtforegroundrole\nFROM (\nSELECT prj_id AS id,\n       1 AS type,\n       '0' AS subtype,\n       0 AS section,\n       NULL  AS section_qtdisplayrole,\n       prj_number AS name,\n       CASE                         \n           WHEN prj_status = 'C' THEN <? value('complete') ?>\n           WHEN prj_status = 'O' THEN <? value('inprocess') ?>\n           WHEN prj_status = 'P' THEN <? value('planning') ?>\n       END AS status,\n       prjtype_code AS project_type,\n       prj_name AS item,\n       firstline(prj_descrip) AS descrip,\n       crmacct_name AS customer, \n       cntct_name AS contact,\n       addr_city AS city,\n       addr_state AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       prj_due_date AS due,\n       prj_assigned_date AS assigned,\n       prj_start_date AS started,\n       prj_completed_date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n       CASE WHEN (prj_status = 'O' AND prj_due_date < current_date) THEN 'red' \n         WHEN (prj_status = 'O' AND prj_due_date BETWEEN current_date AND current_date + (fetchmetricvalue('ProjectDueDateWarning')||' days')::interval) THEN 'orange' \n         END AS due_qtforegroundrole,\n       0 AS xtindentrole\n  FROM prj\n  LEFT OUTER JOIN prjtype ON (prj_prjtype_id=prjtype_id)\n  LEFT OUTER JOIN crmacct ON (prj_crmacct_id=crmacct_id)\n  LEFT OUTER JOIN cntct ON (crmacct_cntct_id_1=cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n\n WHERE (prj_id = <? value("prj_id") ?> )\n \nUNION ALL\n----- TASKS -----\nSELECT DISTINCT -1 AS id, \n       3 AS type,\n       '0' AS subtype,\n       1 AS section,\n       'Tasks' AS section_qtdisplayrole,\n       'Tasks' AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n       NULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n\nUNION ALL\n\nSELECT prjtask_id AS id,\n       5 AS type,\n       '0' AS subtype,\n       1 AS section,\n       NULL AS section_qtdisplayrole,\n       prjtask_number AS name,\n       CASE                         \n           WHEN prjtask_status = 'C' THEN <? value('complete') ?>\n           WHEN prjtask_status = 'O' THEN <? value('inprocess') ?>\n           WHEN prjtask_status = 'P' THEN <? value('planning') ?>\n       END AS status,\n       NULL::text AS project_type,\n       prjtask_name AS item,\n       prjtask_descrip AS descrip,\n       cust_name as customer,\n       cntct_name AS contact,\n       addr_city AS city,\n       addr_state AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       prjtask_due_date AS due,\n       prjtask_assigned_date AS assigned,\n       prjtask_start_date AS started,\n       prjtask_completed_date AS completed,\n       prjtask_hours_budget AS hrs_budget,\n       prjtask_hours_actual AS hrs_actual,\n       (prjtask_hours_budget-prjtask_hours_actual) AS hrs_balance,\n       prjtask_exp_budget AS exp_budget,\n       prjtask_exp_actual AS exp_actual,\n       (prjtask_exp_budget-prjtask_exp_actual) AS exp_balance,\n       CASE WHEN (prjtask_status = 'O' AND prjtask_due_date < current_date) THEN 'red' \n         WHEN (prjtask_status = 'O' AND prjtask_due_date BETWEEN current_date AND current_date + (fetchmetricvalue('ProjectDueDateWarning')||' days')::interval) THEN 'orange' \n         END AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM prjtask\n  LEFT OUTER JOIN te.teprjtask ON (prjtask_id = teprjtask_prjtask_id)\n  LEFT OUTER JOIN custinfo ON (teprjtask_cust_id=cust_id)\n  LEFT OUTER JOIN cntct ON (cust_corrcntct_id=cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n\n WHERE (prjtask_prj_id = <? value("prj_id") ?> )\n GROUP BY prjtask_prj_id, custinfo.cust_name, prjtask.prjtask_id, addr.addr_city, addr.addr_state, cntct_name, prjtask.prjtask_number, prjtask.prjtask_status, prjtask_username, prjtask.prjtask_owner_username, prjtask_name, prjtask_descrip, prjtask_due_date, prjtask_assigned_date, prjtask_start_date, prjtask_completed_date, prjtask_hours_budget, prjtask_hours_actual, prjtask_exp_budget, prjtask_exp_actual\n\n<? if exists("showIn") ?>\nUNION ALL\n----- INCIDENTS -----\n\nSELECT DISTINCT -1 AS id, \n       100 AS type,\n       '0' AS subtype,\n       1 AS section,\n       'Incidents' AS section_qtdisplayrole,\n       'Incidents' AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n       NULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n    FROM incdt\nUNION ALL\n\nSELECT incdt_id AS id,\n       105 AS type,\n       '0' AS subtype,\n       1 AS section,\n       NULL AS section_qtdisplayrole,\n       incdt_number::text AS name,\n       CASE                         \n           WHEN incdt_status = 'L' THEN <? value('closed') ?>\n           WHEN incdt_status = 'N' THEN <? value('new') ?>\n           WHEN incdt_status = 'F' THEN <? value('feedback') ?>\n           WHEN incdt_status = 'A' THEN <? value('assigned') ?>\t\n           WHEN incdt_status = 'R' THEN <? value('resolved') ?>\n           WHEN incdt_status = 'C' THEN <? value('confirmed') ?>\n       END AS status,\n       NULL::text AS project_type,\n       incdt_number::text AS item,\n       incdt_summary AS descrip,\n       crmacct_number AS customer,\n       crmacct_name AS contact,\n       addr_city AS city,\n       addr_state AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n       NULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM incdt\n  LEFT OUTER JOIN crmacct ON (incdt_crmacct_id=crmacct_id)\n  LEFT OUTER JOIN cntct ON (incdt_cntct_id=cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n\n WHERE (incdt_prj_id = <? value("prj_id") ?> )\n GROUP BY incdt_id, incdt_prj_id, incdt_number, crmacct_number, crmacct_name, addr.addr_city, addr.addr_state, cntct_name, incdt_number, incdt_status, incdt_assigned_username, incdt_owner_username, incdt_number, incdt_summary \n<? endif ?>\n   \n<? if exists("showSo") ?>\nUNION ALL\n\n----- QUOTES -----\nSELECT DISTINCT -1 AS id, \n       10 AS type,\n       '0' AS subtype,\n       2 AS section,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       <? value("quotes") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value, \n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n       NULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n  FROM quhead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=quhead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (quhead_prj_id = <? value("prj_id") ?>)\n<? if exists("owner_username") ?>\n   AND (quhead_owner_username=<? value("owner_username") ?>)\n<? endif ?>\n\nUNION ALL\n\nSELECT quhead_id AS id, \n       15 AS type,\n       quhead_number AS subtype,\n       2 AS section,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       quhead_number AS name,\n       CASE WHEN (quhead_status = 'C') THEN \n         <? value("converted") ?>\n            WHEN (quhead_status = 'X') THEN\n         <? value("canceled") ?>\n            WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n         <? value("open") ?>\n            ELSE\n         <? value("expired") ?>\n       END AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       cust_name AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL::text AS uom,\n       NULL AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n       NULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM quhead\n  JOIN custinfo ON (quhead_cust_id=cust_id)\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=quhead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (quhead_prj_id = <? value("prj_id") ?>)\n<? if exists("owner_username") ?>\n   AND (quhead_owner_username=<? value("owner_username") ?>)\n<? endif ?>\nGROUP BY quhead_id, quhead_number, quhead_status, quhead_expire, quhead_freight, quhead_misc, custinfo.cust_name\n\nUNION ALL\n\nSELECT quitem_id AS id, \n       17 AS type,\n       quhead_number AS subtype,\n       2 AS section,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       quitem_linenumber::text AS name, \n       CASE WHEN (quhead_status = 'C') THEN \n         <? value("converted") ?>\n            WHEN (quhead_status = 'X') THEN\n         <? value("canceled") ?>\n            WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n         <? value("open") ?>\n            ELSE\n         <? value("Expired") ?>\n       END AS status,\n       NULL::text AS project_type,\n       item_number AS item,\n       item_descrip1 || ' ' || item_descrip2 AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       quitem_qtyord,\n       uom_name AS uom,\n       (quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n       NULL::text AS due_qtforegroundrole,\n       3 AS xtindentrole\n  FROM quhead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=quhead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n    JOIN uom ON (quitem_qty_uom_id = uom_id)\n    JOIN itemsite ON (quitem_itemsite_id = itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n WHERE (quhead_prj_id = <? value("prj_id") ?>)\n<? if exists("owner_username") ?>\n   AND (quhead_owner_username=<? value("owner_username") ?>)\n<? endif ?>\n\nUNION ALL\n\nSELECT quhead_id AS id, \n       18 AS type,\n       quhead_number AS subtype,\n       2 AS section,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       <? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM quhead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=quhead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (quhead_prj_id = <? value("prj_id") ?>)\n<? if exists("owner_username") ?>\n   AND (quhead_owner_username=<? value("owner_username") ?>)\n<? endif ?>\nGROUP BY quhead_id, quhead_number\n\nUNION ALL\n\nSELECT -1 AS id, \n       19 AS type,\n       MAX(quhead_number) AS subtype,\n       2 AS section,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("quotes") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM quhead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=quhead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (quhead_prj_id = <? value("prj_id") ?>)\n<? if exists("owner_username") ?>\n   AND (quhead_owner_username=<? value("owner_username") ?>)\n<? endif ?>\n\nUNION ALL\n\n------ SALES ORDERS ------\nSELECT DISTINCT -1 AS id, \n       20 AS type,\n       '0' AS subtype,\n       3 AS section,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       <? value("sos") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n  FROM cohead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=cohead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (cohead_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT cohead_id AS id, \n       25 AS type,\n       cohead_number::text AS subtype,\n       3 AS section,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       cohead_number::text AS name,\n      COALESCE((SELECT \n                  CASE WHEN (coitem_status = 'O') THEN\n                    <? value("open") ?>\n                       WHEN (coitem_status = 'C') THEN\n                    <? value("closed" ?>\n                      ELSE\n                    <? value("canceled") ?>\n                  END\n                FROM \n               (SELECT coitem_status,\n                   CASE \n                     WHEN (coitem_status = 'O') THEN 1\n                     WHEN (coitem_status = 'C') then 2\n                     ELSE  3\n                  END AS type\n                  FROM coitem\n                 WHERE (coitem_cohead_id=cohead_id)\n                 ORDER BY type\n                 LIMIT 1) AS sts) ,'O')\n        AS status,\n       NULL::text AS project_type,\n       shipto_num AS item,\n       shipto_name AS descrip,\n       cust_name AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL::text AS uom,\n       NULL AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM cohead\n    JOIN custinfo ON (cust_id = cohead_cust_id)\n    LEFT OUTER JOIN shiptoinfo ON (cohead_shipto_id = shipto_id)\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=cohead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (cohead_prj_id = <? value("prj_id") ?>)\nGROUP BY cohead_id, cohead_number, shipto_num, shipto_name, cust_name\n\nUNION ALL\n\nSELECT coitem_id AS id, \n       27 AS type,\n       cohead_number::text AS subtype,\n       3 AS section,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       coitem_linenumber::text AS name, \n       CASE WHEN (coitem_status = 'O') THEN\n         <? value("open") ?>\n            WHEN (coitem_status = 'C') THEN\n         <? value("closed") ?>\n            WHEN (coitem_status = 'X') THEN\n         <? value("canceled") ?>\n       END AS status,\n       NULL::text AS project_type,\n       item_number AS item,\n       item_descrip1 || ' ' || item_descrip2 AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       coitem_qtyord,\n       uom_name AS uom,\n       (coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       3 AS xtindentrole\n  FROM cohead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=cohead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n    JOIN uom ON (coitem_qty_uom_id = uom_id)\n    JOIN itemsite ON (coitem_itemsite_id = itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n WHERE (cohead_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT cohead_id AS id, \n       28 AS type,\n       cohead_number::text AS subtype,\n       3 AS section,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM cohead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=cohead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (cohead_prj_id = <? value("prj_id") ?>)\nGROUP BY cohead_id, cohead_number\n\nUNION ALL\n\nSELECT -1 AS id, \n       29 AS type,\n       MAX(cohead_number::text) AS subtype,\n       3 AS section,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("sos") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \t\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM cohead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=cohead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (cohead_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\n------ INVOICES -------\nSELECT DISTINCT -1 AS id, \n       30 AS type,\n       '0' AS subtype,\n       4 AS section,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       <? value("invoices") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n  FROM invchead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=invchead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (invchead_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT invchead_id AS id,\n       35 AS type,\n       invchead_invcnumber::text AS subtype,\n       4 AS section,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       invchead_invcnumber::text AS name,\n       CASE WHEN (invchead_posted) THEN\n         <? value("posted") ?>\n       ELSE <? value("unposted") ?>\n       END AS status,\n       NULL::text AS project_type,\n       shipto_num AS item,\n       shipto_name AS descrip,\n       cust_name AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL::text AS uom,\n       NULL AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM invchead\n    JOIN custinfo ON (cust_id=invchead_cust_id)\n    LEFT OUTER JOIN shiptoinfo ON (invchead_shipto_id = shipto_id)\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=invchead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (invchead_prj_id = <? value("prj_id") ?>)\nGROUP BY invchead_id, invchead_invcnumber, shipto_num, shipto_name, invchead_freight, invchead_misc_amount, invchead_posted, cust_name\n\nUNION ALL\n\nSELECT invcitem_id AS id, \n       37 AS type,\n       invchead_invcnumber::text AS subtype,\n       4 AS section,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       invcitem_linenumber::text AS name, \n       CASE WHEN (invchead_posted) THEN\n         <? value("posted") ?>\n       ELSE <? value("unposted") ?>\n       END AS status,\n       NULL::text AS project_type,\n       COALESCE(item_number,invcitem_number) AS item,\n       COALESCE(item_descrip1 || ' ' || item_descrip2,invcitem_descrip) AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       invcitem_billed AS qty,\n       uom_name AS uom,\n       (invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       3 AS xtindentrole\n  FROM invchead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=invchead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n    LEFT OUTER JOIN item ON (invcitem_item_id = item_id)\n    LEFT OUTER JOIN uom ON (invcitem_qty_uom_id = uom_id)\n WHERE (invchead_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT invchead_id AS id, \n       38 AS type,\n       invchead_invcnumber::text AS subtype,\n       4 AS section,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       <? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n       \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM invchead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=invchead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (invchead_prj_id = <? value("prj_id") ?>)\nGROUP BY invchead_id, invchead_invcnumber\n\nUNION ALL\n\nSELECT -1 AS id, \n       39 AS type,\n       MAX(invchead_invcnumber::text) AS subtype,\n       4 AS section,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("invoices") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM invchead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=invchead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (invchead_prj_id = <? value("prj_id") ?>)\n\n<? endif ?>\n\n\n<? if exists("showWo") ?>\nUNION ALL\n\n------ WORK ORDERS -------\nSELECT DISTINCT -1 AS id, \n       40 AS type,\n       '0' AS subtype,\n       5 AS section,\n       <? value("wos") ?> AS section_qtdisplayrole,\n       <? value("wos") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n  FROM wo\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=wo_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (wo_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT wo_id AS id, \n       45 AS type,\n       formatWoNumber(wo_id) AS subtype,\n       5 AS section,\n       <? value("wos") ?> AS section_qtdisplayrole,\n       formatWoNumber(wo_id) AS name,\n       CASE WHEN (wo_status = 'O') THEN\n         <? value("open") ?>\n            WHEN (wo_status = 'E') THEN\n         <? value("exploded") ?>\n            WHEN (wo_status = 'R') THEN\n         <? value("released") ?>\n            WHEN (wo_status = 'I') THEN\n         <? value("inprocess") ?>\n            WHEN (wo_status = 'C') THEN\n         <? value("closed") ?>\n       END AS status,\n       NULL::text AS project_type,\n       item_number AS item,\n       item_descrip1 || ' ' || item_descrip2 AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       wo_qtyord AS qty,\n       uom_name AS uom,\n       wo_postedvalue AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n       \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM wo\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=wo_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN itemsite ON (itemsite_id=wo_itemsite_id)\n    JOIN item ON (itemsite_item_id=item_id)\n    JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (wo_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT -1 AS id, \n       49 AS type,\n       MAX(formatWoNumber(wo_id)) AS subtype,\n       5 AS section,\n       <? value("wos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("wos") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL::text AS uom,\n       SUM(wo_postedvalue) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM wo\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=wo_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (wo_prj_id = <? value("prj_id") ?>)\n\n<? endif ?>\n\n\n<? if exists("showPo") ?>\n UNION ALL\n\n------ PURCHASE REQUESTS ------\nSELECT DISTINCT -1 AS id, \n       50 AS type,\n       '0' AS subtype,\n       6 AS section,\n       <? value("prs") ?> AS section_qtdisplayrole,\n       <? value("prs") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n  FROM pr\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=pr_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (pr_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT pr_id AS id, \n       55 AS type,\n       pr_number::text || '-' || pr_subnumber::text AS subtype,\n       6 AS section,\n       <? value("prs") ?> AS section_qtdisplayrole,\n       pr_number::text || '-' || pr_subnumber::text AS name,\n       <? value("open") ?> AS status, \n       NULL::text AS project_type,\n       item_number AS item,\n       (item_descrip1 || ' ' || item_descrip2) AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       pr_qtyreq AS qty,\n       uom_name AS uom,\n       stdcost(item_id) * pr_qtyreq AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM pr\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=pr_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN itemsite ON (itemsite_id = pr_itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n    JOIN uom ON (item_inv_uom_id = uom_id)\n WHERE (pr_prj_id=<? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT -1 AS id, \n       59 AS type,\n       MAX(pr_number::text || '-' || pr_subnumber::text) AS subtype,\n       6 AS section,\n       <? value("prs") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("prs") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,       \n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL::text AS uom,\n       SUM(stdcost(item_id) * pr_qtyreq) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM pr\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=pr_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN itemsite ON (itemsite_id = pr_itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n WHERE (pr_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\n------ PURCHASE ORDERS ------\nSELECT DISTINCT -1 AS id, \n       60 AS type,\n       '0' AS subtype,\n       7 AS section,\n       <? value("pos") ?> AS section_qtdisplayrole,\n       <? value("pos") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n  FROM poitem\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=poitem_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (poitem_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT pohead_id AS id,\n       65 AS type,\n       pohead_number::text AS subtype,\n       7 AS section,\n       <? value("pos") ?> AS section_qtdisplayrole,\n       pohead_number::text AS name,\n       CASE WHEN (pohead_status = 'U') THEN\n         <? value("unreleased") ?>\n            WHEN (pohead_status = 'O') THEN\n         <? value("open") ?>\n            WHEN (pohead_status = 'C') THEN\n         <? value("closed") ?>\n       END AS status,\n       NULL::text AS project_type,\n       NULL AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL AS uom,\n       NULL AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=poitem_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (poitem_prj_id = <? value("prj_id") ?>)\nGROUP BY pohead_id, pohead_number, pohead_freight, pohead_status\n\nUNION ALL\n\nSELECT poitem_id AS id, \n       67 AS type,\n       pohead_number::text AS subtype,\n       7 AS section,\n       <? value("pos") ?> AS section_qtdisplayrole,\n       poitem_linenumber::text AS name, \n       CASE WHEN (poitem_status = 'U') THEN\n         <? value("unreleased") ?>\n            WHEN (poitem_status = 'O') THEN\n         <? value("open") ?>\n            WHEN (poitem_status = 'C') THEN\n         <? value("closed") ?>\n       END AS status,\n       NULL::text AS project_type,\n       COALESCE(item_number,poitem_vend_item_number) AS item,\n       COALESCE((item_descrip1 || ' ' || item_descrip2),poitem_vend_item_descrip) AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       poitem_qty_ordered,\n       poitem_vend_uom AS uom,\n       (poitem_qty_ordered * poitem_unitprice) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       3 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=poitem_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n    LEFT OUTER JOIN item ON (itemsite_item_id = item_id)\n WHERE (poitem_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT pohead_id AS id, \n       68 AS type,\n       pohead_number::text AS subtype,\n       7 AS section,\n       <? value("pos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL::text AS uom,\n       SUM(poitem_qty_ordered * poitem_unitprice) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=poitem_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (poitem_prj_id = <? value("prj_id") ?>)\nGROUP BY pohead_id, pohead_number\n\nUNION ALL\n\nSELECT -1 AS id, \n       69 AS type,\n       MAX(pohead_number::text) AS subtype,\n       7 AS section,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("pos") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,       \n       NULL AS qty,\n       NULL::text AS uom,\n       SUM(poitem_qty_ordered * poitem_unitprice) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n        \n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=poitem_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (poitem_prj_id = <? value("prj_id") ?>)\n\n<? endif ?>\n\n) data\nORDER BY section, subtype, type, id;\n  admin   2014-10-06      0
101165
 
64      orders  detail   used by dspOrders\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: orders\n-- Name: detail\n-- Notes: used by dspOrders\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT source_id, type, order_type, order_status, order_number, duedate,\n       totalqty, relievedqty, balanceqty, balanceqty AS runningbalanceqty,\n       'qty' AS totalqty_xtnumericrole,\n       'qty' AS relievedqty_xtnumericrole,\n       'qty' AS balanceqty_xtnumericrole,\n       0 AS runningbalanceqty_xtrunningrole,\n       CASE WHEN (late) THEN 'error' END AS duedate_qtforegroundrole\nFROM\n(\nSELECT poitem_id AS source_id, 1 AS type, TEXT('P/O') AS order_type,\n       pohead_status AS order_status,\n       TEXT(pohead_number) AS order_number,\n       poitem_qty_ordered AS totalqty,\n       poitem_qty_received AS relievedqty,\n       noNeg(poitem_qty_ordered - poitem_qty_received) AS balanceqty,\n       poitem_duedate AS duedate,\n       (poitem_duedate < CURRENT_DATE) AS late\nFROM pohead, poitem, itemsite\nWHERE ((poitem_pohead_id=pohead_id)\n  AND  (poitem_status IN ('O','U'))\n  AND  (poitem_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? if exists("useLeadTime") ?>\n  AND  (poitem_duedate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND  (poitem_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND  (poitem_duedate<=<? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND  (poitem_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n\nUNION\nSELECT wo_id AS source_id, 2 AS type, TEXT('W/O') AS order_type,\n       wo_status AS order_status,\n       formatWONumber(wo_id) AS order_number,\n       wo_qtyord AS totalqty,\n       wo_qtyrcv AS relievedqty,\n       noNeg(wo_qtyord - wo_qtyrcv) AS balanceqty,\n       wo_duedate AS duedate,\n       (wo_duedate < CURRENT_DATE) AS late \nFROM wo, itemsite\nWHERE ((wo_status<>'C')\n  AND  (wo_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (<? value("itemType") ?> NOT IN ('C', 'Y'))\n<? if exists("useLeadTime") ?>\n  AND  (wo_duedate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND  (wo_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND  (wo_duedate<=<? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND  (wo_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n\n-- Tooling is also supply on Work Orders\nUNION\nSELECT wo_id AS source_id, 2 AS type, TEXT('W/O') AS order_type,\n       wo_status AS order_status,\n       formatWONumber(wo_id) AS order_number,\n       womatl_qtyreq AS totalqty,\n       COALESCE(sum(abs(invhist_invqty)),0) AS relievedqty,\n       noNeg(womatl_qtyreq - COALESCE(sum(abs(invhist_invqty)),0)) AS balanceqty,\n       wo_duedate AS duedate,\n       (wo_duedate < CURRENT_DATE) AS late \nFROM womatl\n  JOIN wo ON (wo_id=womatl_wo_id)\n  JOIN itemsite ON (itemsite_id=womatl_itemsite_id)\n  JOIN item ON (item_id=itemsite_item_id)\n  LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n  LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id)\n                          AND (invhist_invqty < 0))\nWHERE ((wo_status<>'C')\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (item_type = 'T')\n<? if exists("useLeadTime") ?>\n  AND  (wo_duedate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND  (wo_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND  (wo_duedate<=<? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND  (wo_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\nGROUP BY wo_id, wo_status, womatl_qtyreq, wo_duedate\n\n<? if exists("Manufacturing") ?>\nUNION\nSELECT wo_id AS source_id, 2 AS type, TEXT('W/O') AS order_type,\n       wo_status AS order_status,\n       formatWONumber(wo_id) AS order_number,\n       wo_qtyord AS totalqty,\n       wo_qtyrcv AS relievedqty,\n       noNeg(wo_qtyord - wo_qtyrcv) AS balanceqty,\n       wo_duedate AS duedate,\n       (wo_duedate < CURRENT_DATE) AS late\nFROM wo, xtmfg.brddist, itemsite\nWHERE ((brddist_wo_id=wo_id)\n  AND  (wo_status<>'C')\n  AND  (brddist_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (<? value("itemType") ?> IN ('C', 'Y'))\n<? if exists("useLeadTime") ?>\n  AND (wo_duedate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND (wo_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND (wo_duedate<=<? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND (wo_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n     )\n<? endif ?>\n\n<? if exists("Standard") ?>\nUNION\nSELECT toitem_id AS source_id, 3 AS type, TEXT('T/O') AS order_type,\n       tohead_status AS order_status,\n       TEXT(tohead_number) AS order_number,\n       toitem_qty_ordered AS totalqty,\n       toitem_qty_received AS relievedqty,\n       noNeg(toitem_qty_ordered - toitem_qty_received) AS balanceqty,\n       toitem_duedate AS duedate,\n       (toitem_duedate < CURRENT_DATE) AS late\nFROM tohead, toitem, itemsite\nWHERE ((toitem_tohead_id=tohead_id)\n  AND  (toitem_status='O')\n  AND  (toitem_item_id=itemsite_item_id)\n  AND  (tohead_dest_warehous_id=itemsite_warehous_id)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? if exists("useLeadTime") ?>\n  AND  (toitem_duedate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND  (toitem_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND  (toitem_duedate<=<? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND  (toitem_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n<? endif ?>\n\n) AS data\n\nORDER BY duedate;\n        admin   2014-10-06      0
101166
 
111     package items    replace the not-so-old pkgitem table with direct query of catalogs\n        and tables so we never miss anything and do not have to maintain the\n        data\n TODO: is there a better sort order?\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: package\n-- Name:  items\n-- Notes: replace the not-so-old pkgitem table with direct query of catalogs\n--        and tables so we never miss anything and do not have to maintain the\n--        data\n-- TODO: is there a better sort order?\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       CASE WHEN pkgitem_type='C' THEN <? value("script") ?>\n            WHEN pkgitem_type='D' THEN <? value("cmd") ?>\n            WHEN pkgitem_type='F' THEN <? value("function") ?>\n            WHEN pkgitem_type='G' THEN <? value("trigger") ?>\n            WHEN pkgitem_type='I' THEN <? value("image") ?>\n            WHEN pkgitem_type='M' THEN <? value("metasql") ?>\n            WHEN pkgitem_type='P' THEN <? value("priv") ?>\n            WHEN pkgitem_type='R' THEN <? value("report") ?>\n            WHEN pkgitem_type='S' THEN <? value("schema") ?>\n            WHEN pkgitem_type='T' THEN <? value("table") ?>\n            WHEN pkgitem_type='U' THEN <? value("uiform") ?>\n            WHEN pkgitem_type='V' THEN <? value("view") ?>\n            WHEN pkgitem_type='sequence' THEN <? value("sequence") ?>\n            WHEN pkgitem_type='index'    THEN <? value("index") ?>\n       ELSE pkgitem_type END AS pkgitem_type_qtdisplayrole\nFROM (\nSELECT script_id AS pkgitem_id, 'C' AS pkgitem_type,\n       script_id AS pkgitem_item_id,\n       script_name AS pkgitem_name,\n       script_notes AS pkgitem_descrip\n  FROM <? literal("pkgname") ?>.pkgscript \nUNION \nSELECT cmd_id AS pkgitem_id, 'D' AS pkgitem_type,\n       cmd_id AS pkgitem_item_id,\n       cmd_name AS pkgitem_name,\n       cmd_descrip AS pkgitem_descrip \n  FROM <? literal("pkgname") ?>.pkgcmd \nUNION \nSELECT pg_proc.oid AS pkgitem_id, 'F' AS pkgitem_type,\n       pg_proc.oid AS pkgitem_item_id,\n       proname || '(' || oidvectortypes(proargtypes)\n               || ')' AS pkgitem_name,\n       pg_catalog.obj_description(pg_proc.oid, 'pg_proc') AS pkgitem_descrip \n  FROM pg_proc\n       JOIN pg_namespace ON (pronamespace=pg_namespace.oid)\n WHERE (nspname=<? value("pkgname") ?>) \nUNION \nSELECT t.oid AS pkgitem_id, 'G' AS pkgitem_type,\n       t.oid AS pkgitem_item_id,\n       tgname AS pkgitem_name,\n       pg_catalog.obj_description(t.oid, 'pg_trigger') AS pkgitem_descrip \n  FROM pg_trigger t\n       JOIN pg_class ON (tgrelid=pg_class.oid)\n       JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=<? value("pkgname") ?>) \n<? if not exists("showsystemdetails") ?>\n    AND (tgconstraint = 0)\n   AND  (tgname !~ '^pkg(cmd(arg)?|image|metasql|priv|report|script|uiform)')\n<? endif ?>\n    )\nUNION \nSELECT image_id AS pkgitem_id, 'I' AS pkgitem_type,\n       image_id AS pkgitem_item_id,\n       image_name AS pkgitem_name,\n       image_descrip AS pkgitem_descrip \n  FROM <? literal("pkgname") ?>.pkgimage \nUNION \nSELECT metasql_id AS pkgitem_id, 'M' AS pkgitem_type,\n       metasql_id AS pkgitem_item_id,\n       metasql_group || '-' || metasql_name AS pkgitem_name,\n       metasql_notes AS pkgitem_descrip \n  FROM <? literal("pkgname") ?>.pkgmetasql \nUNION \nSELECT priv_id AS pkgitem_id, 'P' AS pkgitem_type,\n       priv_id AS pkgitem_item_id,\n       priv_module || '.' || priv_name AS pkgitem_name,\n       priv_descrip AS pkgitem_descrip \n  FROM <? literal("pkgname") ?>.pkgpriv \nUNION \nSELECT report_id AS pkgitem_id, 'R' AS pkgitem_type,\n       report_id AS pkgitem_item_id,\n       report_name AS pkgitem_name,\n       report_descrip AS pkgitem_descrip \n  FROM <? literal("pkgname") ?>.pkgreport \nUNION \nSELECT n.oid AS pkgitem_id, 'S' AS pkgitem_type,\n       n.oid AS pkgitem_item_id,\n       nspname AS pkgitem_name,\n       pg_catalog.obj_description(n.oid, 'pg_namespace') AS pkgitem_descrip \n  FROM pg_namespace n\n WHERE (nspname=<? value("pkgname") ?>) \nUNION \nSELECT c.oid AS pkgitem_id, 'T' AS pkgitem_type,\n       c.oid AS pkgitem_item_id,\n       relname AS pkgitem_name,\n       pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n  FROM pg_class c\n       JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=<? value("pkgname") ?>)\n   AND  (relkind='r')\n<? if not exists("showsystemdetails") ?>\n   AND  (relname !~ '^pkg(cmd(arg)?|image|metasql|priv|report|script|uiform)$')\n<? endif ?>\n   )\nUNION \nSELECT uiform_id AS pkgitem_id, 'U' AS pkgitem_type,\n       uiform_id AS pkgitem_item_id,\n       uiform_name AS pkgitem_name,\n       uiform_notes AS pkgitem_descrip \n  FROM <? literal("pkgname") ?>.pkguiform \nUNION \nSELECT c.oid AS pkgitem_id, 'V' AS pkgitem_type,\n       c.oid AS pkgitem_item_id,\n       relname AS pkgitem_name,\n       pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n  FROM pg_class c\n       JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=<? value("pkgname") ?>)\n   AND  (relkind='v'))\n<? if exists("showsystemdetails") ?>\nUNION\nSELECT c.oid AS pkgitem_id, 'sequence' AS pkgitem_type,\n       c.oid AS pkgitem_item_id,\n       relname AS pkgitem_name,\n       pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n  FROM pg_class c\n       JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=<? value("pkgname") ?>)\n   AND  (relkind='S'))\nUNION\nSELECT c.oid AS pkgitem_id, 'index' AS pkgitem_type,\n       c.oid AS pkgitem_item_id,\n       relname AS pkgitem_name,\n       pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n  FROM pg_class c\n       JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=<? value("pkgname") ?>)\n   AND  (relkind='i'))\n<? endif ?>\n) AS pkgitem \nORDER BY pkgitem_type_qtdisplayrole, pkgitem_name;\n  admin   2014-10-06      0
101167
 
69      packingList     shipment         used by printPackingList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: packingList\n-- Name: shipment\n-- Notes: used by printPackingList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT shiphead_order_id, shiphead_order_type, shiphead_shipform_id, cohead_number AS number\nFROM shiphead, cohead\nWHERE ((shiphead_id=<? value("shiphead_id") ?>)\n  AND  (cohead_id=shiphead_order_id)\n  AND  (shiphead_order_type='SO'))\n<? if exists("MultiWhs") ?>\nUNION\nSELECT shiphead_order_id, shiphead_order_type, shiphead_shipform_id, tohead_number AS number\nFROM shiphead, tohead\nWHERE ((shiphead_id=<? value("shiphead_id") ?>)\n  AND  (tohead_id=shiphead_order_id)\n  AND  (shiphead_order_type='TO'))\n<? endif ?>\n;\n   admin   2014-10-06      0
101168
 
485     packingListBatch        clear    used by packingListBatch\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: packingListBatch\n-- Name: clear\n-- Notes: used by packingListBatch\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM pack WHERE pack_id IN\n  (SELECT pack_id\n   FROM pack JOIN cohead ON (cohead_id=pack_head_id)\n             JOIN coitem ON (coitem_cohead_id=cohead_id)\n             JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n   WHERE ( (checkSOSitePrivs(cohead_id))\n     AND   (pack_head_type='SO')\n     AND   (pack_printed) \n<? if exists("warehous_id") ?>\n     AND   (itemsite_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n         )\n  );\n\n<? if exists("MultiWhs") ?>\nDELETE FROM pack WHERE pack_id IN\n  (SELECT pack_id\n   FROM pack JOIN tohead ON (tohead_id=pack_head_id)\n   WHERE ( (pack_head_type='TO')\n     AND   (pack_printed)\n<? if exists("warehous_id") ?>\n     AND   (tohead_src_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n         )\n  );\n<? endif ?>\n  admin   2014-10-06      0
101169
 
67      packingListBatch        detail   used by packingListBatch\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: packingListBatch\n-- Name: detail\n-- Notes: used by packingListBatch\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n       cohead_id, pack_shiphead_id, \n       cohead_number AS order_number, pack_head_type,\n       cohead_shipvia AS shipvia,\n       formatShipmentNumber(pack_shiphead_id) AS shipment_number, \n       cust_number AS number, cohead_billtoname AS name,\n       CASE WHEN (cohead_holdtype='N') THEN <? value("none") ?>\n            WHEN (cohead_holdtype='C') THEN <? value("credit") ?>\n            WHEN (cohead_holdtype='S') THEN <? value("ship") ?>\n            WHEN (cohead_holdtype='P') THEN <? value("pack") ?>\n            WHEN (cohead_holdtype='R') THEN <? value("return") ?>\n            ELSE <? value("other") ?>\n       END AS f_holdtype,\n       pack_printed\nFROM pack JOIN cohead ON (cohead_id=pack_head_id)\n          JOIN custinfo ON (cust_id=cohead_cust_id)\n          JOIN coitem ON (coitem_cohead_id=cohead_id)\n          JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\nWHERE ( (pack_head_type='SO')\n  AND   (checkSOSitePrivs(cohead_id))\n<? if exists("warehous_id") ?>\n  AND   (itemsite_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n      )\n\n<? if exists("MultiWhs") ?>\nUNION ALL \nSELECT tohead_id, pack_shiphead_id, \n       tohead_number AS order_number, pack_head_type,\n       tohead_shipvia AS shipvia,\n       formatShipmentNumber(pack_shiphead_id) AS shipment_number, \n       tohead_destname AS number, tohead_destcntct_name AS name,\n       '' AS f_holdtype,\n       pack_printed\nFROM pack JOIN tohead ON (tohead_id=pack_head_id) \nWHERE ( (pack_head_type='TO') \n<? if exists("warehous_id") ?>\n  AND   (tohead_src_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n      )\n<? endif ?>\nORDER BY 3;\n     admin   2014-10-06      0
101170
 
68      packingListBatch        print    used by packingListBatch\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: packingListBatch\n-- Name: print\n-- Notes: used by packingListBatch\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n       pack_id, pack_head_id, pack_head_type, pack_shiphead_id,\n       COALESCE(shipform_report_name, findCustomerForm(cohead_cust_id, 'P')) AS packform,\n       findCustomerForm(cohead_cust_id, 'L') AS pickform \nFROM pack JOIN cohead ON (cohead_id=pack_head_id)\n          JOIN coitem ON (coitem_cohead_id=cohead_id)\n          JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n          LEFT OUTER JOIN shipform ON (shipform_id=cohead_shipform_id)\nWHERE ( (checkSOSitePrivs(cohead_id))\n  AND   (pack_head_type='SO')\n  AND   (NOT pack_printed) \n<? if exists("warehous_id") ?>\n  AND   (itemsite_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n      )\n\n<? if exists("MultiWhs") ?>\nUNION ALL\nSELECT pack_id, pack_head_id, pack_head_type, pack_shiphead_id,\n       COALESCE(shipform_report_name, findTOForm(tohead_id, 'P')) AS packform,\n       findTOForm(tohead_id, 'L') AS pickform \nFROM pack JOIN tohead ON (tohead_id=pack_head_id)\n          LEFT OUTER JOIN shipform ON (shipform_id=tohead_shipform_id)\nWHERE ( (pack_head_type='TO')\n  AND   (NOT pack_printed)\n<? if exists("warehous_id") ?>\n  AND   (tohead_src_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n      )\n<? endif ?>\n;\n  admin   2014-10-06      0
101171
 
65      packingListBatchByShipVia       print    used by printPackingListBatchByShipVia\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: packingListBatchByShipVia\n-- Name: print\n-- Notes: used by printPackingListBatchByShipVia\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT pack_head_id, pack_head_type, pack_shiphead_id, getSoStatus(cohead_id) AS orderhead_status,\n       COALESCE(shipform_report_name, findCustomerForm(cohead_cust_id, 'P')) AS packform,\n       findCustomerForm(cohead_cust_id, 'L') AS pickform\nFROM pack JOIN cohead ON (cohead_id=pack_head_id)\n          JOIN coitem ON (coitem_cohead_id=cohead_id)\n          JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n          LEFT OUTER JOIN shipform ON (shipform_id=cohead_shipform_id)\nWHERE ( (NOT pack_printed)\n  AND   (pack_head_type='SO')\n  AND   (getSoStatus(cohead_id) <> 'C') \n<? if exists("shipvia") ?>\n  AND   (cohead_shipvia=<? value("shipvia") ?>)\n<? endif ?>\n  AND   (checkSOSitePrivs(cohead_id))\n  AND\t(coitem_scheddate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("warehous_id") ?>\n  AND   (itemsite_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n      )\n\n<? if exists("MultiWhs") ?>\nUNION ALL\nSELECT DISTINCT pack_head_id, pack_head_type, pack_shiphead_id, tohead_status AS orderhead_status,\n       COALESCE(shipform_report_name, findTOForm(tohead_id, 'P')) AS packform,\n       findTOForm(tohead_id, 'L') AS pickform\nFROM pack JOIN tohead ON (tohead_id=pack_head_id)\n          JOIN toitem ON (toitem_tohead_id = tohead_id) \n          LEFT OUTER JOIN shipform ON (shipform_id=tohead_shipform_id)\nWHERE ( (NOT pack_printed)\n  AND   (pack_head_type='TO')\n  AND   (tohead_status <> 'C') \n<? if exists("shipvia") ?>\n  AND   (tohead_shipvia=<? value("shipvia") ?>)\n<? endif ?>\n  AND\t(toitem_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("warehous_id") ?>\n  AND   (tohead_src_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n      )\n<? endif ?>\n\n;\n admin   2014-10-06      0
101172
 
66      packingListBatchByShipVia       shipVia  used by printPackingListBatchByShipVia\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: packingListBatchByShipVia\n-- Name: shipVia\n-- Notes: used by printPackingListBatchByShipVia\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT max(id), shipvia\nFROM (\nSELECT max(cohead_id) AS id, cohead_shipvia AS shipvia\nFROM pack JOIN cohead ON (cohead_id=pack_head_id)\n          JOIN coitem ON (coitem_cohead_id=cohead_id AND coitem_status='O')\n          JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\nWHERE ( (NOT pack_printed)\n  AND   (pack_head_type='SO')\n<? if exists("warehous_id") ?>\n  AND   (itemsite_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n      )\nGROUP BY cohead_shipvia\n<? if exists("MultiWhs") ?>\nUNION\nSELECT max(tohead_id) AS id, tohead_shipvia AS shipvia\nFROM pack JOIN tohead ON (tohead_id=pack_head_id AND tohead_status='O')\nWHERE ( (NOT pack_printed)\n  AND   (pack_head_type='TO')\n<? if exists("warehous_id") ?>\n  AND   (tohead_src_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n      )\nGROUP BY tohead_shipvia\n<? endif ?>\n) data\nGROUP BY shipvia\nORDER BY shipvia\n      admin   2014-10-06      0
101173
 
276     prices  detail   used by dspPricesByCustomerType, dspPricesByCustomer, dspPricesByItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: prices\n-- Name: detail\n-- Notes: used by dspPricesByCustomerType, dspPricesByCustomer, dspPricesByItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemid, sourcetype, schedulename, type,\n<? if not exists("byItem") ?>\n       itemnumber, itemdescrip, priceuom,\n<? else ?>\n       typename,\n<? endif ?>\n       CASE WHEN (qtybreak <> -1) THEN qtybreak END AS f_qtybreak,\n       price,\n       currConcat(curr_id) AS currConcat,\n       'qty' AS f_qtybreak_xtnumericrole,\n       <? value("na") ?> AS f_qtybreak_xtnullrole,\n       'salesprice' AS price_xtnumericrole\n<? if exists("showCosts") ?>\n  <? if exists("byItem") ?>\n       , CASE WHEN (<? value("cost") ?> <> 0) THEN <? value("cost") ?> END AS f_cost,\n       CASE WHEN ((price <> 0) AND (<? value("cost") ?> <> 0)) THEN ((price - <? value("cost") ?>) /  price) END AS f_margin,\n  <? else ?>\n       , CASE WHEN (cost IS NOT NULL) THEN cost END AS f_cost,\n      CASE WHEN ((price <> 0) AND (cost <>0)) THEN ((price - cost) / price) END AS f_margin,\n  <? endif ?>\n       'cost' AS f_cost_xtnumericrole,\n       <? value("costna") ?> AS f_cost_xtnullrole,\n       'percent' AS f_margin_xtnumericrole,\n       <? value("na") ?> AS f_margin_xtnullrole,\n  <? if exists("byItem") ?>\n       CASE WHEN (<? value("cost") ?> > price) THEN 'error' END AS f_margin_qtforegroundrole\n  <? else ?>\n       CASE WHEN (cost > price) THEN 'error' END AS f_margin_qtforegroundrole\n  <? endif ?>\n<? endif ?>\nFROM (\n<? if not exists("byCustomerType") ?>\n      SELECT\n  <? if exists("byCustomer") ?>\n             ipsprice_id AS itemid, 1 AS sourcetype,\n             ipshead_name AS schedulename, <? value("customer") ?> AS type,\n             item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n             (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n             ipsprice_qtybreak AS qtybreak,\n             ipsprice_price AS price, ipshead_curr_id AS curr_id,\n             ipshead_updated AS effective\n    <? if exists("useStandardCosts") ?>\n             , (stdcost(item_id) * iteminvpricerat(item_id)) AS cost\n    <? elseif exists("useActualCosts") ?>\n             , (actcost(item_id) * iteminvpricerat(item_id)) AS cost\n    <? endif ?>\n  <? else ?>\n             ipsprice_id AS itemid, 1 AS sourcetype,\n             ipshead_name AS schedulename, <? value("customer") ?> AS type,\n             cust_name AS typename,\n             ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n  <? endif ?>\n      FROM ipsass, ipshead, ipsprice, item,\n  <? if exists("byCustomer") ?>\n           uom\n  <? else ?>\n          custinfo\n  <? endif ?>\n      WHERE ((ipsass_ipshead_id=ipshead_id)\n         AND (ipsprice_ipshead_id=ipshead_id)\n         AND (ipsprice_item_id=item_id)\n  <? if exists("byCustomer") ?>\n         AND (item_price_uom_id=uom_id)\n         AND (ipsass_cust_id=<? value("cust_id") ?>)\n         <? if exists("item_id") ?>\n         AND (item_id=<? value("item_id") ?>)\n         <? endif ?>\n  <? else ?>\n         AND (ipsass_cust_id=cust_id)\n         AND (item_id=<? value("item_id") ?>)\n  <? endif ?>\n         AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0)\n  <? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n  <? endif ?>\n  <? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n  <? endif ?>\n            )\n\n      UNION\n<? endif ?>\n\n      SELECT\n<? if exists("byItem") ?>\n             ipsprice_id AS itemid, 2 AS sourcetype,\n             ipshead_name AS schedulename, <? value("custType") ?> AS type,\n             (custtype_code || '-' || custtype_descrip) AS typename,\n             ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n<? else ?>\n             ipsprice_id AS itemid,\n  <? if exists("byCustomerType") ?>\n             1 AS sourcetype,\n  <? elseif exists("byCustomer") ?>\n             2 AS sourcetype,\n  <? endif ?>\n             ipshead_name AS schedulename, <? value("custType") ?> AS type,\n             item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n             (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n             ipsprice_qtybreak AS qtybreak,\n             ipsprice_price AS price, ipshead_curr_id AS curr_id,\n             ipshead_updated AS effective\n  <? if exists("showCosts") ?>\n    <? if exists("useStandardCosts") ?>\n             , (stdcost(\n      <? if exists("byCustomerType") ?>\n                ipsprice_item_id\n      <? elseif exists("byCustomer") ?>\n                item_id\n      <? endif ?>\n                     ) * iteminvpricerat(item_id)) AS cost\n    <? elseif exists("useActualCosts") ?>\n             , (actcost(\n      <? if exists("byCustomerType") ?>\n                ipsprice_item_id\n      <? elseif exists("byCustomer") ?>\n                item_id\n      <? endif ?>\n                     ) * iteminvpricerat(item_id)) AS cost\n    <? endif ?>\n  <? endif ?>\n<? endif ?>\n      FROM ipsass, ipshead, ipsprice, item,\n<? if exists("byItem") ?>\n           custtype\n<? else ?>\n           uom\n<? endif ?>\n<? if exists("byCustomer") ?>\n           , custinfo\n<? endif ?>\n      WHERE ((ipsass_ipshead_id=ipshead_id)\n         AND (ipsprice_ipshead_id=ipshead_id)\n         AND (ipsprice_item_id=item_id)\n<? if not exists("byItem") ?>\n         AND (item_price_uom_id=uom_id)\n<? endif ?>\n<? if exists("byCustomerType") ?>\n         AND (ipsass_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("byCustomer") ?>\n         AND (ipsass_custtype_id=cust_custtype_id)\n         AND (cust_id=<? value("cust_id") ?>)\n         <? if exists("item_id") ?>\n         AND (item_id=<? value("item_id") ?>)\n         <? endif ?>\n<? else ?>\n         AND (ipsass_custtype_id=custtype_id)\n         AND (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n            )\n\n      UNION\n\n      SELECT\n<? if exists("byItem") ?>\n             ipsprice_id AS itemid, 3 AS sourcetype,\n             ipshead_name AS schedulename, <? value("custTypePattern") ?> AS type,\n             (custtype_code || '-' || custtype_descrip) AS typename,\n             ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n<? else ?>\n             ipsprice_id AS itemid,\n  <? if exists("byCustomerType") ?>\n             2 AS sourcetype,\n  <? elseif exists("byCustomer") ?>\n             3 AS sourcetype,\n  <? endif ?>\n             ipshead_name AS schedulename, <? value("custTypePattern") ?> AS type,\n             item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n             (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n             ipsprice_qtybreak AS qtybreak,\n             ipsprice_price AS price, ipshead_curr_id AS curr_id,\n             ipshead_updated AS effective\n  <? if exists("showCosts") ?>\n    <? if exists("useStandardCosts") ?>\n             , (stdcost(\n      <? if exists("byCustomerType") ?>\n                ipsprice_item_id\n      <? elseif exists("byCustomer") ?>\n                item_id\n      <? endif ?>\n                     ) * iteminvpricerat(item_id)) AS cost\n    <? elseif exists("useActualCosts") ?>\n             , (actcost(\n      <? if exists("byCustomerType") ?>\n                ipsprice_item_id\n      <? elseif exists("byCustomer") ?>\n                item_id\n      <? endif ?>\n                     ) * iteminvpricerat(item_id)) AS cost\n    <? endif ?>\n  <? endif ?>\n<? endif ?>\n      FROM ipsass, ipshead, ipsprice, item, custtype\n<? if not exists("byItem") ?>\n           , uom\n<? endif ?>\n<? if exists("byCustomer") ?>\n           , custinfo\n<? endif ?>\n      WHERE ((ipsass_ipshead_id=ipshead_id)\n         AND (ipsprice_ipshead_id=ipshead_id)\n         AND (ipsprice_item_id=item_id)\n<? if not exists("byItem") ?>\n         AND (item_price_uom_id=uom_id)\n<? endif ?>\n         AND (coalesce(length(ipsass_custtype_pattern), 0) > 0)\n         AND (custtype_code ~ ipsass_custtype_pattern)\n<? if exists("byCustomerType") ?>\n         AND (custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("byCustomer") ?>\n         AND (cust_id=<? value("cust_id") ?>)\n         <? if exists("item_id") ?>\n         AND (item_id=<? value("item_id") ?>)\n         <? endif ?>\n<? else ?>\n         AND (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n            )\n\n      UNION\n\n      SELECT\n<? if exists("byItem") ?>\n             ipsprice_id AS itemid, 4 AS sourcetype,\n             ipshead_name AS schedulename, <? value("sale") ?> AS type,\n             sale_name AS typename,\n             ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n<? else ?>\n             ipsprice_id AS itemid,\n<? if exists("byCustomerType") ?>\n             3\n<? elseif exists("byCustomer") ?>\n             4\n<? endif ?> AS sourcetype,\n             ipshead_name AS schedulename, (<? value("sale") ?> || '-' || sale_name) AS type,\n             item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n             (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n             ipsprice_qtybreak AS qtybreak,\n             ipsprice_price AS price, ipshead_curr_id AS curr_id,\n             ipshead_updated AS effective\n<? if exists("showCosts") ?>\n  <? if exists("useStandardCosts") ?>\n             , (stdcost(\n    <? if exists("byCustomerType") ?>\n                ipsprice_item_id\n    <? elseif exists("byCustomer") ?>\n                item_id\n    <? endif ?>\n                     ) * iteminvpricerat(item_id)) AS cost\n    <? elseif exists("useActualCosts") ?>\n             , (actcost(\n    <? if exists("byCustomerType") ?>\n                ipsprice_item_id\n    <? elseif exists("byCustomer") ?>\n                item_id\n    <? endif ?>\n                     ) * iteminvpricerat(item_id)) AS cost\n    <? endif ?>\n  <? endif ?>\n<? endif ?>\n      FROM sale, ipshead, ipsprice, item\n<? if not exists("byItem") ?>\n           , uom\n<? endif ?>\n      WHERE ((sale_ipshead_id=ipshead_id)\n         AND (ipsprice_ipshead_id=ipshead_id)\n<? if not exists("byItem") ?>\n         AND (item_price_uom_id=uom_id)\n<? endif ?>\n<? if exists("byItem") ?>\n         AND (ipsprice_item_id=<? value("item_id") ?>)\n  <? if not exists("showExpired") ?>\n         AND (sale_enddate > CURRENT_DATE)\n  <? endif ?>\n  <? if not exists("showFuture") ?>\n         AND (sale_startdate <= CURRENT_DATE)\n  <? endif ?>\n<? else ?>\n         AND (ipsprice_item_id=item_id)\n  <? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n  <? endif ?>\n  <? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n  <? endif ?>\n<? endif ?>\n            )\n\n<? if exists("byItem") ?>\n\n      UNION\n\n      SELECT ipsprice_id AS itemid, 5 AS sourcetype,\n             ipshead_name AS schedulename, <? value("shipTo") ?> AS type,\n             (cust_name || '-' || shipto_num) AS typename,\n             ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n      FROM ipsass, ipshead, ipsprice, custinfo, shiptoinfo, item\n      WHERE ((ipsass_ipshead_id=ipshead_id)\n         AND (ipsprice_ipshead_id=ipshead_id)\n         AND (ipsass_shipto_id=shipto_id)\n         AND (shipto_cust_id=cust_id)\n         AND (ipsprice_item_id=item_id)\n         AND (item_id=<? value("item_id") ?>)\n  <? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n  <? endif ?>\n  <? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n  <? endif ?>\n            )\n\n      UNION\n\n      SELECT ipsprice_id AS itemid, 6 AS sourcetype,\n             ipshead_name AS schedulename, <? value("shipToPattern") ?> AS type,\n             (cust_name || '-' || shipto_num) AS typename,\n             ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n      FROM ipsass, ipshead, ipsprice, custinfo, shiptoinfo, item\n      WHERE ((ipsass_ipshead_id=ipshead_id)\n         AND (ipsprice_ipshead_id=ipshead_id)\n         AND (COALESCE(LENGTH(ipsass_shipto_pattern),0) > 0)\n         AND (shipto_num ~ ipsass_shipto_pattern)\n         AND (ipsass_cust_id=cust_id)\n         AND (shipto_cust_id=cust_id)\n         AND (ipsprice_item_id=item_id)\n         AND (item_id=:item_id)\n  <? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n  <? endif ?>\n  <? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n  <? endif ?>\n            )\n<? endif ?>\n\n      UNION\n\n      SELECT\n<? if exists("byItem") ?>\n             item_id AS itemid, 0 AS sourcetype,\n             <? value("listPrice") ?> AS schedulename, <? value("na") ?> AS type,\n             '' AS typename,\n             -1 AS qtybreak, item_listprice AS price, baseCurrId() AS curr_id\n<? else ?>\n             item_id AS itemid, 0 AS sourcetype,\n             '' AS schedulename, <? value("listPrice") ?> AS type,\n             item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n             (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n             -1 AS qtybreak,\n  <? if exists("byCustomerType") ?>\n             item_listprice AS price,\n  <? elseif exists("byCustomer") ?>\n             (item_listprice - (item_listprice * cust_discntprcnt)) AS price,\n  <? endif ?>\n             baseCurrId() AS curr_id,\n             CURRENT_DATE AS effective\n  <? if exists("useStandardCosts") ?>\n             , (stdcost(item_id) * iteminvpricerat(item_id)) AS cost\n  <? elseif exists("useActualCosts") ?>\n             , (actcost(item_id) * iteminvpricerat(item_id)) AS cost\n  <? endif ?>\n<? endif ?>\n<? if exists("byCustomerType") ?>\n      FROM item JOIN uom ON (item_price_uom_id=uom_id)\n<? elseif exists("byCustomer") ?>\n      FROM custinfo, item JOIN uom ON (item_price_uom_id=uom_id)\n<? else ?>\n      FROM item\n<? endif ?>\n      WHERE (\n<? if not exists("byItem") ?>\n             (item_sold)\n         AND (item_active)\n<? else ?>\n             (item_id=<? value("item_id") ?>)\n<? endif ?>\n         AND (NOT item_exclusive)\n<? if exists("byCustomer") ?>\n         AND (cust_id=<? value("cust_id") ?>)\n         <? if exists("item_id") ?>\n         AND (item_id=<? value("item_id") ?>)\n         <? endif ?>\n<? endif ?>\n            )\n     ) AS data\nORDER BY\n<? if not exists("byItem") ?>\n         itemnumber,\n<? endif ?>\n         price;\n      admin   2014-10-06      0
101174
 
267     partiallyShippedOrders  detail   used by dspPartiallyShippedOrders\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: partiallyShippedOrders\n-- Name: detail\n-- Notes: used by dspPartiallyShippedOrders\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT CASE WHEN (cohead_holdtype IN ('P', 'C', 'R')) THEN -1\n         ELSE cohead_id\n       END AS _coheadid, cohead_id,\n       cohead_holdtype, cohead_number, cust_name,\n       CASE WHEN (cohead_holdtype='N') THEN <? value("none") ?>\n            WHEN (cohead_holdtype='C') THEN <? value("credit") ?>\n            WHEN (cohead_holdtype='S') THEN <? value("ship") ?>\n            WHEN (cohead_holdtype='P') THEN <? value("pack") ?>\n            WHEN (cohead_holdtype='R') THEN <? value("return") ?>\n         ELSE <? value("other") ?>\n       END AS f_holdtype,\n       cohead_orderdate,\n       (MIN(coitem_scheddate)) AS minscheddate,\n       cohead_packdate,\n       SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                  (coitem_price / coitem_price_invuomratio) ) AS extprice,\n       currConcat(cohead_curr_id) AS currAbbr,\n       SUM(currToBase(cohead_curr_id,\n          (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n          (coitem_price / coitem_price_invuomratio),\n          CURRENT_DATE)) AS extprice_base,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS extprice_base_xtnumericrole,\n       <? if exists("singlecurrency") ?>\n         0 AS extprice_xttotalrole \n       <? else ?>\n         0 AS extprice_base_xttotalrole \n       <? endif ?>\nFROM cohead, itemsite, item, custinfo, coitem\nWHERE ( (coitem_cohead_id=cohead_id)\n    AND (cohead_cust_id=cust_id)\n    AND (coitem_itemsite_id=itemsite_id)\n    AND (itemsite_item_id=item_id)\n    AND (coitem_status='O')\n    AND (cohead_id IN ( SELECT DISTINCT coitem_cohead_id\n                        FROM coitem\n                        WHERE (coitem_qtyshipped > 0) ))\n    AND (coitem_qtyshipped < coitem_qtyord)\n    AND (coitem_scheddate BETWEEN <? value("startDate") ?>\n                              AND <? value("endDate") ?>)\n    <? if exists("warehous_id") ?>\n      AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n    <? endif ?>\n      ) \nGROUP BY cohead_id, cohead_number, cust_name,\n         cohead_holdtype, cohead_orderdate, cohead_packdate,\n         cohead_curr_id \nORDER BY minscheddate, cohead_number;\n    admin   2014-10-06      0
101175
 
268     pendingAvailability     detail   used by dspPendingAvailability\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: pendingAvailability\n-- Name: detail\n-- Notes: used by dspPendingAvailability\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("showIndented") ?>\n\n-- Indented BOM\nSELECT itemsite_id, reorderlevel,\n       bomdata_bomwork_level,\n       bomdata_bomwork_id,\n       bomdata_bomwork_parent_id,\n       bomdata_bomwork_seqnumber AS bomitem_seqnumber,\n       bomdata_item_number AS item_number,\n       bomdata_itemdescription AS item_descrip,\n       bomdata_uom_name AS uom_name,\n       pendalloc,\n       ordered,\n       qoh,\n       (totalalloc + pendalloc) AS totalalloc,\n       (qoh + ordered - (totalalloc + pendalloc)) AS totalavail,\n       'qty' AS pendalloc_xtnumericrole,\n       'qty' AS ordered_xtnumericrole,\n       'qty' AS qoh_xtnumericrole,\n       'qty' AS totalalloc_xtnumericrole,\n       'qty' AS totalavail_xtnumericrole,\n       CASE WHEN (qoh < pendalloc) THEN 'error' END AS qoh_qtforegroundrole,\n       CASE WHEN ((qoh + ordered - (totalalloc + pendalloc)) < reorderlevel)  THEN 'error'\n            WHEN ((qoh + ordered - (totalalloc + pendalloc)) = reorderlevel) THEN 'warning'\n       END AS totalavail_qtforegroundrole,\n       bomdata_bomwork_level - 1 AS xtindentrole\n  FROM ( SELECT itemsite_id,\n                CASE WHEN(itemsite_useparams)\n                     THEN itemsite_reorderlevel\n                     ELSE 0.0\n                     END AS reorderlevel,\n                ib.*,\n                ((bomdata_qtyreq::NUMERIC * <? value("buildQty") ?>) * (1 + bomdata_scrap::NUMERIC)) AS pendalloc,\n                qtyAllocated(itemsite_id, DATE(<? value("buildDate") ?>)) AS totalalloc,\n                noNeg(qtyAvailable(itemsite_id)) AS qoh,\n                qtyOrdered(itemsite_id, DATE(<? value("buildDate") ?>)) AS ordered\n           FROM indentedBOM(<? value("item_id") ?>,\n                            getActiveRevId('BOM', <? value("item_id") ?>),\n                            0,0) ib LEFT OUTER JOIN\n                itemsite ON ((itemsite_item_id=bomdata_item_id)\n                         AND (itemsite_warehous_id=<? value("warehous_id") ?>))\n          WHERE (bomdata_item_id > 0)\n       <? if not exists("effective") ?>\n           AND (CURRENT_DATE BETWEEN bomdata_effective AND (bomdata_expires-1))\n       <? else ?>\n           AND (<? value("effective") ?> BETWEEN bomdata_effective AND (bomdata_expires-1))\n       <? endif ?>\n       ) AS data\n<? if exists("showShortages") ?>\n  WHERE ((qoh + ordered - (totalalloc + pendalloc)) < 0)\n<? endif ?>   \nORDER BY bomworkSequence(bomdata_bomwork_id);\n\n<? else ?>\n\n-- Single Level BOM\nSELECT itemsite_id, bomitem_seqnumber, item_number, item_descrip, uom_name,\n       pendalloc, (totalalloc + pendalloc) AS totalalloc,\n       qoh, (qoh + ordered - (totalalloc + pendalloc)) AS totalavail,\n       reorderlevel,\n       'qty' AS pendalloc_xtnumericrole,\n       'qty' AS totalalloc_xtnumericrole,\n       'qty' AS qoh_xtnumericrole,\n       'qty' AS totalavail_xtnumericrole,\n       CASE WHEN (qoh < pendalloc) THEN 'error' END AS qoh_qtforegroundrole,\n       CASE WHEN ((qoh + ordered - (totalalloc + pendalloc)) < reorderlevel) THEN 'error'\n            WHEN ((qoh + ordered - (totalalloc + pendalloc)) = reorderlevel) THEN 'warning'\n       END AS totalavail_qtforegroundrole\nFROM ( SELECT itemsite_id, bomitem_seqnumber, item_number,\n              (item_descrip1 || ' ' || item_descrip2) AS item_descrip, uom_name,\n              ((itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL,\n                            (bomitem_qtyfxd + bomitem_qtyper * <? value("buildQty") ?>) * (1 + bomitem_scrap)))) AS pendalloc,\n              qtyAllocated(itemsite_id, DATE(<? value("buildDate") ?>)) AS totalalloc,\n              noNeg(qtyAvailable(itemsite_id)) AS qoh,\n              qtyOrdered(itemsite_id, DATE(<? value("buildDate") ?>)) AS ordered,\n              CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel\n       FROM itemsite, item, bomitem(<? value("item_id") ?>), uom\n       WHERE ( (bomitem_item_id=itemsite_item_id)\n           AND (itemsite_item_id=item_id)\n           AND (item_inv_uom_id=uom_id)\n           AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n       <? if not exists("effective") ?>\n           AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires-1))\n       <? else ?>\n           AND (<? value("effective") ?> BETWEEN bomitem_effective AND (bomitem_expires-1))\n       <? endif ?>\n             )\n     ) AS data\n<? if exists("showShortages") ?>\n  WHERE ((qoh + ordered - (totalalloc + pendalloc)) < 0)\n<? endif ?>   \nORDER BY bomitem_seqnumber;\n\n<? endif ?>   \n    admin   2014-10-06      0
101176
 
269     pendingBOMChanges       detail   used by dspPendingBOMChanges\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: pendingBOMChanges\n-- Name: detail\n-- Notes: used by dspPendingBOMChanges\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT bomitem_id, actiondate, action,\n       bomitem_seqnumber, item_number, description,\n       uom_name, qtyfxd, qtyper,\n       bomitem_scrap, actiondate,\n       'qty' AS qtyfxd_xtnumericrole,\n       'qtyper' AS qtyper_xtnumericrole,\n       'percent' AS bomitem_scrap_xtnumericrole \nFROM (SELECT bomitem_id, <? value("effective") ?> AS action,\n             bomitem_seqnumber, item_number, (item_descrip1 || ' ' || item_descrip2) AS description,\n             uom_name,\n             (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd,\n             (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper,\n             bomitem_scrap, bomitem_effective AS actiondate \n      FROM bomitem(<? value("item_id") ?>,<? value("revision_id") ?>), item, uom \n      WHERE ((bomitem_item_id=item_id)\n         AND (item_inv_uom_id=uom_id)\n         AND (bomitem_effective BETWEEN CURRENT_DATE AND <? value("cutOffDate") ?>)) \n      UNION \n      SELECT bomitem_id, <? value("expires") ?> AS action, \n             bomitem_seqnumber, item_number, (item_descrip1 || ' ' || item_descrip2) AS description,\n             uom_name,\n             (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd,\n             (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper,\n             bomitem_scrap, bomitem_expires AS actiondate \n      FROM bomitem(<? value("item_id") ?>,<? value("revision_id") ?>), item, uom \n      WHERE ((bomitem_item_id=item_id)\n         AND (item_inv_uom_id=uom_id)\n       <? if exists("cutOffDate") ?>\n         AND (bomitem_expires BETWEEN CURRENT_DATE AND <? value("cutOffDate") ?>) )\n       <? endif ?> \n     ) AS data \nORDER BY action, actiondate, bomitem_seqnumber;\n  admin   2014-10-06      0
101177
 
270     poDeliveryDateVariances detail   used by dspPoDeliveryDateVariancesByItem, dspPoDeliveryDateVariancesByVendor\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: poDeliveryDateVariances\n-- Name: detail\n-- Notes: used by dspPoDeliveryDateVariancesByItem, dspPoDeliveryDateVariancesByVendor\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT <? if exists("byItem") ?>\n         recv.*, vend_name,\n         firstLine(recv_vend_item_number) AS itemnumber,\n         firstLine(recv_vend_item_descrip) AS itemdescrip,\n         DATE(recv_rlsd_duedate) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS req_leadtime,\n         DATE(recv_duedate) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS agrd_leadtime,\n         DATE(recv_date) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS real_leadtime,\n         DATE(recv_date) - DATE(recv_rlsd_duedate) AS req_diff,\n\t DATE(recv_date) - DATE(recv_duedate) AS argd_diff,\n         DATE(recv_date) AS receivedate,\n         formatDate(COALESCE(pohead_released, pohead_orderdate)) AS orderdate,\n         formatDate(recv_date) AS f_recv_date,\n         recv_rlsd_duedate AS release_duedate,  \n\t recv_duedate AS argd_duedate,\n         CASE WHEN (DATE(recv_date) - DATE(recv_rlsd_duedate) > 0) THEN 'error'\n              END AS req_diff_qtforegroundrole,\n         CASE WHEN (DATE(recv_date) - DATE(recv_duedate) > 0) THEN 'error'\n              END AS argd_diff_qtforegroundrole, \n\t CASE WHEN (DATE(recv_date) > DATE(recv_duedate)) THEN 'error'\t\t\t   \n              END AS receivedate_qtforegroundrole,\t\t\t  \n         'qty' AS recv_qty_xtnumericrole\n       <? elseif exists("byVendor") ?>\n         recv_id, recv_order_number, vend_name,\n         DATE(recv_date) AS receivedate,\n         formatDate(COALESCE(pohead_released, pohead_orderdate)) AS orderdate,\n         firstLine(recv_vend_item_number) AS venditemnumber,\n         firstLine(recv_vend_item_descrip) AS venditemdescrip,\n         recv_qty, recv_duedate, recv_date,\n         formatDate(recv_date) AS f_recv_date,\n         DATE(recv_rlsd_duedate) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS req_leadtime,\n         DATE(recv_duedate) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS agrd_leadtime,\n   DATE(recv_date) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS real_leadtime,\n   DATE(recv_date) - DATE(recv_rlsd_duedate) AS req_diff,\n         DATE(recv_date) - DATE(recv_duedate) AS argd_diff,\n         firstLine(item.item_number) AS  itemnumber,\n         recv_rlsd_duedate AS release_duedate,\n   recv_duedate AS argd_duedate,\n   CASE WHEN (DATE(recv_date) - DATE(recv_rlsd_duedate) > 0) THEN 'error'\n              END AS req_diff_qtforegroundrole,\n   CASE WHEN (DATE(recv_date) - DATE(recv_duedate) > 0) THEN 'error'\n              END AS argd_diff_qtforegroundrole,\n   CASE WHEN (DATE(recv_date) > DATE(recv_duedate)) THEN 'error'\n              END AS receivedate_qtforegroundrole,\n         'qty' AS recv_qty_xtnumericrole\n       <? endif ?>\n\nFROM recv LEFT OUTER JOIN vendinfo ON (vend_id=recv_vend_id)\n          LEFT OUTER JOIN pohead ON (pohead_number=recv_order_number AND recv_order_type='PO')\n          LEFT OUTER JOIN (itemsite JOIN item ON (item_id=itemsite_item_id)) ON (itemsite_id=recv_itemsite_id)\nWHERE ( TRUE\n<? if exists("item_id") ?>\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND  (DATE(recv_date) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n  AND (recv_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n<? if exists("vend_id") ?>\n  AND (vend_id=<? value("vend_id") ?>)\n<? endif ?>\n<? if exists("selectedPurchasingAgent") ?>\n  AND (recv_agent_username=<? value("username") ?>)\n<? endif ?>\n      )\nORDER BY\n  recv_date DESC;\n  admin   2014-10-06      0
101178
 
271     poHistory       detail   used by dspPoHistory\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: poHistory\n-- Name: detail\n-- Notes: used by dspPoHistory\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT poitem_id, poitem.*,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS itemnumber,\n       COALESCE(uom_name, <? value("na") ?>) AS uomname,\n       CASE WHEN (LENGTH(TRIM(BOTH '    ' FROM poitem_vend_item_descrip)) <= 0)\n            THEN(item_descrip1 || ' ' || item_descrip2)\n         ELSE poitem_vend_item_descrip\n       END AS itemdescription,\n       'qty' AS poitem_qty_ordered_xtnumericrole,\n       'qty' AS poitem_qty_received_xtnumericrole,\n       'qty' AS poitem_qty_returned_xtnumericrole\nFROM poitem LEFT OUTER JOIN\n     ( itemsite JOIN item\n       ON (itemsite_item_id=item_id) JOIN uom ON (item_inv_uom_id=uom_id))\n       ON (poitem_itemsite_id=itemsite_id)\nWHERE (poitem_pohead_id=<? value("pohead_id") ?>)\nORDER BY poitem_linenumber;\n  admin   2014-10-06      0
101179
 
272     poItems detail   used by dspPoItemsByVendor, dspPoItemsByItem, dspPoItemsByDate\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: poItems\n-- Name: detail\n-- Notes: used by dspPoItemsByVendor, dspPoItemsByItem, dspPoItemsByDate\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_id, poitem_id, pohead_number, poitem_status,\n       CASE WHEN(poitem_status='C') THEN <? value("closed") ?>\n            WHEN(poitem_status='U') THEN <? value("unposted") ?>\n            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) \n                                   AND (poitem_qty_ordered>(poitem_qty_received-poitem_qty_returned))) \n            THEN <? value("partial") ?>\n            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) \n                                   AND (poitem_qty_ordered<=(poitem_qty_received-poitem_qty_returned))) \n            THEN <? value("received") ?>\n            WHEN(poitem_status='O') THEN <? value("open") ?>\n         ELSE poitem_status\n       END AS f_poitem_status,\n       vend_name,\n       (SELECT warehous_code\n          FROM whsinfo\n         WHERE (COALESCE(itemsite_warehous_id, pohead_warehous_id)=warehous_id)) AS warehous_code,\n       COALESCE(item_number, <? value("nonInv") ?>) AS itemnumber,\n       poitem_vend_item_number, poitem_vend_uom,\n       COALESCE(item_descrip1, firstLine(poitem_vend_item_descrip)) AS itemdescrip,\n       COALESCE(uom_name, poitem_vend_uom) AS itemuom,\n       poitem_duedate, poitem_qty_ordered, poitem_qty_received, poitem_qty_returned,\n       CASE WHEN (poitem_duedate < CURRENT_DATE) THEN 'error' END AS poitem_duedate_qtforegroundrole,\n       'qty' AS poitem_qty_ordered_xtnumericrole,\n       'qty' AS poitem_qty_received_xtnumericrole,\n       'qty' AS poitem_qty_returned_xtnumericrole \n  FROM pohead\n  JOIN poitem   ON (pohead_id=poitem_pohead_id)\n  JOIN vendinfo ON (pohead_vend_id=vend_id)\n  LEFT OUTER JOIN (itemsite\n                   JOIN item ON (itemsite_item_id=item_id)\n                   JOIN uom ON (item_inv_uom_id=uom_id))\n         ON (poitem_itemsite_id=itemsite_id)\nWHERE (TRUE\n<? if exists("byDate") ?>\n   AND (poitem_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND (((itemsite_id IS NULL) AND\n        (pohead_warehous_id=<? value("warehous_id") ?>) )\n       OR\n       ((itemsite_id IS NOT NULL) AND\n        (itemsite_warehous_id=<? value("warehous_id") ?>) ) )\n<? endif ?>\n<? if exists("agentUsername") ?>\n   AND (pohead_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n<? if exists("openItems") ?>\n   AND (poitem_status='O')\n<? endif ?>\n<? if exists("closedItems") ?>\n   AND (poitem_status='C')\n<? endif ?>\n<? if exists("poNumber") ?>\n  AND (pohead_number=<? value("poNumber") ?>)\n<? endif ?>\n<? if exists("vend_id") ?>\n  AND (pohead_vend_id=<? value("vend_id") ?>) \n<? elseif exists("vendtype_id") ?>\n  AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n  AND (vend_vendtype_id IN (SELECT vendtype_id\n                              FROM vendtype\n                             WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n<? if exists("item_id") ?>\n  AND (itemsite_item_id=<? value("item_id") ?>) \n<? endif ?>\n      )\nORDER BY poitem_duedate, pohead_number, poitem_linenumber\n;\n   admin   2014-10-06      0
101180
 
432     poItems list     used by purchaseOrder\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: poItems\n-- Name: list\n-- Notes: used by purchaseOrder\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT poitem.*,\n       CASE WHEN(poitem_status='C') THEN <? value("closed") ?>\n            WHEN(poitem_status='U') THEN <? value("unposted") ?>\n            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered>(poitem_qty_received-poitem_qty_returned))) THEN <? value("partial") ?>\n            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered<=(poitem_qty_received-poitem_qty_returned))) THEN <? value("received") ?>\n            WHEN(poitem_status='O') THEN <? value("open") ?>\n            ELSE poitem_status\n       END AS poitemstatus,\n       CASE WHEN (poitem_order_type='S') THEN <? value("so") ?>\n            WHEN (poitem_order_type='W') THEN <? value("wo") ?>\n            ELSE ''\n       END AS demand_type,\n       CASE WHEN (poitem_order_type='S') THEN formatSoNumber(coitem_id)\n            WHEN (poitem_order_type='W') THEN formatWoNumber(womatl_wo_id)\n            ELSE ''\n       END AS order_number,\n       CASE WHEN (itemsite_id IS NULL) THEN poitem_vend_item_number\n            ELSE item_number\n       END AS item_number,\n       CASE WHEN (itemsite_id IS NULL) THEN firstLine(poitem_vend_item_descrip)\n            ELSE (item_descrip1 || ' ' || item_descrip2)\n       END AS item_descrip,\n       contrct_number, \n       poitem_rlsd_duedate AS orgl_duedate,\n       (poitem_unitprice * poitem_qty_ordered) AS extprice,\n       CASE WHEN(poitem_status='C') THEN <? value("closed") ?>\n            WHEN(poitem_status='U') THEN <? value("unposted") ?>\n            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered>(poitem_qty_received-poitem_qty_returned))) THEN <? value("partial") ?>\n            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered<=(poitem_qty_received-poitem_qty_returned))) THEN <? value("received") ?>\n            WHEN(poitem_status='O') THEN <? value("open") ?>\n            ELSE poitem_status\n       END AS poitem_status_qtdisplayrole,\n       'qty' AS poitem_qty_ordered_xtnumericrole,\n       'qty' AS poitem_qty_received_xtnumericrole,\n       'qty' AS poitem_qty_returned_xtnumericrole,\n       'qty' AS poitem_qty_vouchered_xtnumericrole,\n       'purchprice' AS poitem_unitprice_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS poitem_freight_xtnumericrole,\n       'curr' AS poitem_freight_received_xtnumericrole,\n       'curr' AS poitem_freight_vouchered_xtnumericrole,\n       'curr' AS poitem_stdcost_xtnumericrole\nFROM pohead JOIN poitem  ON (poitem_pohead_id=pohead_id)\n            LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n            LEFT OUTER JOIN item     ON (itemsite_item_id=item_id)\n            LEFT OUTER JOIN coitem   ON (poitem_order_type='S' AND poitem_order_id = coitem_id)\n            LEFT OUTER JOIN womatl   ON (poitem_order_type='W' AND poitem_order_id = womatl_id)\n            LEFT OUTER JOIN itemsrc  ON (poitem_itemsrc_id=itemsrc_id)\n            LEFT OUTER JOIN contrct  ON (itemsrc_contrct_id=contrct_id)\nWHERE (poitem_pohead_id=<? value("pohead_id") ?>)\nORDER BY poitem_linenumber;\n  admin   2014-10-06      0
101181
 
130     poPriceVariances        detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: poPriceVariances\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *\n<? if exists("includeFormatted") ?>,\n  formatDate(distdate)        AS f_date,\n  formatQty(recv_qty)       AS f_qty,\n  formatCost(recv_recvcost) AS f_recv_recvcost,\n  formatMoney(recv_value)   AS f_recv_value,\n  formatPrice(vouchercost)    AS f_vouchercost,\n  formatMoney(voucher_value)  AS f_voucher_value,\n  formatMoney(variance)       AS f_variance, \n  formatPrcnt(varprcnt/100)       AS f_varprcnt\n<? endif ?>\n FROM (\nSELECT recv_id, recv_order_number, recv_date, recv_order_type,\n  DATE(recv_date) AS receivedate,\n  vohead_distdate AS distdate,\n  vend_number, vend_name,\n  COALESCE(item_number, (<? value("nonInv") ?> || recv_vend_item_number)) AS itemnumber,\n  firstLine(COALESCE(item_descrip1, recv_vend_item_descrip)) AS itemdescrip,\n  recv_qty,\n  recv_purchcost,\n  currConcat(recv_freight_curr_id) AS poCurrAbbr,\n<? if exists("baseCurr") ?>\n  COALESCE((recv_value / CASE WHEN (recv_qty <> 0.0) THEN recv_qty ELSE 1.0 END), 0.0) AS recv_recvcost,\n  COALESCE(recv_value, 0.0) AS recv_value,\n  COALESCE(currToBase(vohead_curr_id, SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, vohead_distdate), 0.0) AS vouchercost,\n  COALESCE(currToBase(vohead_curr_id, SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, vohead_distdate) * recv_qty, 0.0) AS voucher_value,\n  COALESCE(currToBase(vohead_curr_id, SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, vohead_distdate) * recv_qty - recv_value, 0.0) AS variance,\n  CASE WHEN (COALESCE(recv_value, 0.0) <> 0.0) THEN\n    ((currToBase(vohead_curr_id, SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, vohead_distdate) *\n     recv_qty / recv_value) -1.0) * 100.0\n       ELSE 100.0 END AS varprcnt,     \n  currConcat(baseCurrId()) AS currAbbr,\n  '0' AS recv_value_xttotalrole,\n  '0' AS voucher_value_xttotalrole,\n  '0' AS variance_xttotalrole,\n<? else ?> -- local Currency\n  COALESCE(currToLocal(vohead_curr_id, (recv_value / CASE WHEN (recv_qty <> 0.0) THEN recv_qty ELSE 1.0 END), vohead_distdate), 0.0) AS recv_recvcost,\n  COALESCE(currToLocal(vohead_curr_id, recv_value, vohead_distdate), 0.0) AS recv_value,\n  COALESCE(SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, 0.0)  AS vouchercost,\n  COALESCE(SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END * recv_qty, 0.0) AS voucher_value,\n  COALESCE(SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END * recv_qty - currToLocal(vohead_curr_id, recv_value, vohead_distdate), 0.0) AS variance,\n  CASE WHEN (COALESCE(recv_value, 0.0) <> 0.0) THEN\n    ((SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END *\n     recv_qty / currToLocal(vohead_curr_id, recv_value, vohead_distdate)) -1.0) * 100.0\n       ELSE 100.0 END AS varprcnt,       \n  currConcat(vohead_curr_id) AS currAbbr,\n<? endif ?>\n  'qty' AS recv_qty_xtnumericrole,\n  'purchprice' AS recv_purchcost_xtnumericrole,\n  'curr' AS recv_value_xtnumericrole,\n  'purchprice' AS vouchercost_xtnumericrole,\n  'curr' AS  voucher_value_xtnumericrole,\n  'cost' AS recv_recvcost_xtnumericrole,\n  'curr' AS variance_xtnumericrole,\n  'prcnt' AS varprcnt_xtnumericrole\nFROM vendinfo\n  JOIN vendtype ON (vend_vendtype_id=vendtype_id), recv\n  LEFT OUTER JOIN (\n    itemsite JOIN item ON (itemsite_item_id=item_id) )\n    ON (recv_itemsite_id=itemsite_id)\n  JOIN vodist ON ((vodist_poitem_id=recv_orderitem_id)\n              AND (vodist_vohead_id=recv_vohead_id))\n  JOIN vohead ON ((vodist_vohead_id=vohead_id) \n              AND (vohead_posted))\nWHERE ( (recv_vend_id=vend_id)\nAND  (recv_order_type='PO')\n<? if exists("vend_id") ?>\n  AND (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n  AND (vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n  AND (vendtype_code ~ <? value("vendtype_pattern") ?>)\n<? endif ?>\n  AND (DATE(vohead_distdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) \n<? if exists("MultiWhs") ?>\n  AND (itemsite_warehous_id=<? value("MultiWhs") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n  AND (recv_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n )\nGROUP BY recv_id, recv_order_number, recv_order_type, recv_date, item_number, recv_vend_item_number,\n         item_descrip1, recv_vend_item_descrip, recv_qty, recv_purchcost, recv_recvcost,\n         vohead_curr_id, recv_freight_curr_id, vohead_docdate, vend_number, vend_name,\n         recv_value, vohead_distdate\n) data\n<? if exists("notZero") ?>\nWHERE (variance != 0)\n<? endif ?>\nORDER BY distdate, recv_order_number DESC;\n     admin   2014-10-06      0
101182
 
273     poReturns       detail   used by dspPoReturnsByVendor\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: poReturns\n-- Name: detail\n-- Notes: used by dspPoReturnsByVendor\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT poreject_id, poreject_ponumber, vend_name,\n       poreject_date, poreject_qty,\n       poreject_vend_item_number, poreject_vend_item_descrip,\n       rjctcode_code,\n       'qty' AS poreject_qty_xtnumericrole \nFROM poreject, vendinfo, itemsite, rjctcode\nWHERE ((poreject_posted)\n   AND (poreject_vend_id=vend_id)\n   AND (poreject_rjctcode_id=rjctcode_id)\n   AND (poreject_itemsite_id=itemsite_id)\n   AND (vend_id=<? value("vend_id") ?>)\n   AND (DATE(poreject_date) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("username") ?>\n   AND (poreject_agent_username=<? value("username") ?>)\n<? endif ?>\n      ) \nORDER BY poreject_date DESC;\n      admin   2014-10-06      0
101183
 
441     postCountTags   post     \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: postCountTags\n-- Name:  post\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT MIN(postCountTag(invcnt_id, <? value('thaw') ?>)) AS result\n  FROM invcnt, itemsite, item\n WHERE ((invcnt_itemsite_id=itemsite_id)\n    AND (invcnt_qoh_after IS NOT NULL)\n    AND (NOT invcnt_posted)\n    AND (itemsite_item_id=item_id)\n<? if exists('warehous_id') ?>\n    AND (itemsite_warehous_id=<? value('warehous_id') ?>)\n<? endif ?>\n\n<? if exists('classcode_id') ?>\n    AND (item_classcode_id=<? value('classcode_id') ?>)\n<? elseif exists('classcode_pattern') ?>\n    AND (item_classcode_id IN (SELECT classcode_id\n                                 FROM classcode\n                                WHERE (classcode_code ~ <? value('classcode_pattern') ?>)))\n<? elseif exists('plancode_id') ?>\n    AND (itemsite_plancode_id=<? value('plancode_id') ?>)\n<? elseif exists('plancode_pattern') ?>\n    AND (itemsite_plancode_id IN (SELECT plancode_id\n                                    FROM plancode\n                                   WHERE (plancode_code ~ <? value('plancode_pattern') ?>)))\n<? endif ?>\n);\n  admin   2014-10-06      0
101184
 
414     postJournals    detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: postJournals\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *\nFROM (\n  SELECT 0 AS id,\n  sltrans_source,\n  0 AS xtindentrole,\n  CASE WHEN sltrans_source = 'A/P' THEN <? value("AP") ?>\n       WHEN sltrans_source = 'A/R' THEN <? value("AR") ?>\n       WHEN sltrans_source = 'G/L' THEN <? value("GL") ?>\n       WHEN sltrans_source = 'I/M' THEN <? value("IM") ?>\n       WHEN sltrans_source = 'P/D' THEN <? value("PD") ?>\n       WHEN sltrans_source = 'S/O' THEN <? value("SO") ?>\n       WHEN sltrans_source = 'S/R' THEN <? value("SR") ?>\n       WHEN sltrans_source = 'W/O' THEN <? value("WO") ?>\n       ELSE <? value("Other" ?>\n  END AS description, \n  NULL AS debit, \n  NULL AS credit, \n  count(sltrans_id) AS journals\n  FROM sltrans\n  WHERE ((NOT sltrans_posted)\n   AND (sltrans_amount > 0)\n   AND (sltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>))\n  GROUP BY sltrans_source\n<? if exists("preview") ?>\nUNION ALL\n  SELECT \n    sltrans_accnt_id AS id,\n    sltrans_source,\n    1 AS xtindentrole,\n    formatGLAccountLong(sltrans_accnt_id) AS description,\n    CASE WHEN SUM(sltrans_amount) < 0 THEN ABS(SUM(sltrans_amount))\n    END AS debit,\n    CASE WHEN SUM(sltrans_amount) > 0 THEN SUM(sltrans_amount)\n    END AS credit,\n    NULL AS journals\n    FROM sltrans\n    WHERE ((NOT sltrans_posted)\n     AND (sltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>))\n  GROUP BY sltrans_accnt_id, sltrans_source\n<? endif ?>\n) data\nORDER BY sltrans_source, xtindentrole\n  admin   2014-10-06      0
101185
 
413     postJournals    post     \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: postJournals\n-- Name:  post\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT * \nFROM postJournals(\nARRAY[\n<? foreach("source_list") ?>\n  <? if not isfirst("source_list") ?>\n,\n  <? endif ?>\n  <? value("source_list") ?>\n<? endforeach ?>\n],  \n<? value("startDate") ?>, \n<? value("endDate") ?>, \n<? value("distDate") ?>) AS result;\n  admin   2014-10-06      0
101186
 
442     pricingFreight  detail   used by itemPricingScheduleItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: pricingFreight\n-- Name: detail\n-- Notes: used by itemPricingScheduleItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ipsfreight.*\n  FROM ipsfreight\n WHERE ( (true)\n<? if exists("checkDup") ?>\n <? if exists("ipshead_id") ?>\n   AND (ipsfreight_ipshead_id=<? value("ipshead_id") ?>)\n <? endif ?>\n <? if exists("warehous_id") ?>\n   AND (ipsfreight_warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n   AND (ipsfreight_warehous_id IS NULL)\n <? endif ?>\n <? if exists("shipzone_id") ?>\n   AND (ipsfreight_shipzone_id=<? value("shipzone_id") ?>)\n <? else ?>\n   AND (ipsfreight_shipzone_id IS NULL)\n <? endif ?>\n <? if exists("freightclass_id") ?>\n   AND (ipsfreight_freightclass_id=<? value("freightclass_id") ?>)\n <? else ?>\n   AND (ipsfreight_freightclass_id IS NULL)\n <? endif ?>\n <? if exists("shipvia") ?>\n   AND (ipsfreight_shipvia=<? value("shipvia") ?>)\n <? else ?>\n   AND (ipsfreight_shipvia IS NULL)\n <? endif ?>\n <? if exists("qtybreak") ?>\n   AND (ipsfreight_qtybreak=<? value("qtybreak") ?>)\n <? endif ?>\n   AND (ipsfreight_id <> <? value("ipsfreight_id") ?>)\n<? elseif exists("ipsfreight_id") ?>\n   AND (ipsfreight_id=<? value("ipsfreight_id") ?>)\n<? endif ?>\n      );\n admin   2014-10-06      0
101187
 
459     projectTasks    detail   \n Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: projectTasks\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT prjtask_id, prjtask_number, prjtask_name,\n       COALESCE(prjtask_hours_budget - prjtask_hours_actual, 0.0) as prjtaskhrbal,\n       COALESCE(prjtask_exp_budget - prjtask_exp_actual, 0.0) as prjtaskexpbal,\n       firstLine(prjtask_descrip) AS prjtask_descrip,\n       totalhrbud, totalhract, totalhrbal,\n       totalexpbud, totalexpact, totalexpbal\nFROM (SELECT COALESCE(SUM(prjtask_hours_budget), 0.0) AS totalhrbud,\n             COALESCE(SUM(prjtask_hours_actual), 0.0) AS totalhract,\n             COALESCE(SUM(prjtask_hours_budget - prjtask_hours_actual), 0.0) AS totalhrbal,\n             COALESCE(SUM(prjtask_exp_budget), 0.0) AS totalexpbud,\n             COALESCE(SUM(prjtask_exp_actual), 0.0) AS totalexpact,\n             COALESCE(SUM(prjtask_exp_budget - prjtask_exp_actual), 0.0) AS totalexpbal\n      FROM prjtask\n      WHERE prjtask_prj_id = <? value("prj_id") ?>) foo, prjtask\nWHERE (prjtask_prj_id=<? value("prj_id") ?>)\nORDER BY prjtask_number;\n     admin   2014-10-06      0
101188
 
480     projects        detail_nohierarchy       Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n\n        Non-hierarchical view to support CSV export from Project List screen\n    -- Group: projects\n-- Name:  detail_nohierarchy\n-- Notes: Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n--\n--        Non-hierarchical view to support CSV export from Project List screen\n\nSELECT prj_id AS id, 1 AS altId,\n  prj.*, crmacct_name, cntct_name,\n  addr_city, addr_state,\n  prjtype_descr AS project_type,\n  CASE WHEN (prj_status='P') THEN <? value("planning") ?>\n       WHEN (prj_status='O') THEN <? value("open") ?>\n       WHEN (prj_status='C') THEN <? value("complete") ?>\n       ELSE <? value("undefined") ?> END AS project_status\n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\nFROM prj()\nLEFT JOIN prjtype ON (prj_prjtype_id=prjtype_id)\nLEFT JOIN crmacct ON (prj_crmacct_id=crmacct_id)\nLEFT JOIN cntct ON (crmacct_cntct_id_1=cntct_id)\nLEFT JOIN addr ON (cntct_addr_id=addr_id)\n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='PROJ')\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=prj_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='PROJ')\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=prj_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='PROJ')\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=prj_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE (true)\n<? if exists("search_pattern") ?>\n   AND ( (prj_number ~* <? value("search_pattern") ?>)\n     OR  (prj_name ~* <? value("search_pattern") ?>)\n     OR  (prj_descrip ~* <? value("search_pattern") ?>) )\n<? endif ?>\n<? if exists("username") ?>\n  AND (prj_username=<? value("username") ?> OR prj_owner_username=<? value("username") ?>)\n<? endif ?>\n<? if exists("assigned_username") ?>\n  AND (prj_username=<? value("assigned_username") ?>)\n<? elseif exists("assigned_usr_pattern") ?>\n  AND (prj_username ~ <? value("assigned_usr_pattern") ?>)\n<? endif ?>\n<? if exists("owner_username") ?>\n  AND (prj_owner_username=<? value("owner_username") ?>)\n<? elseif exists("owner_usr_pattern") ?>\n  AND (prj_owner_username ~ <? value("owner_usr_pattern") ?>)\n<? endif ?>\n<? if exists("crmacct_id") ?>\n  AND (prj_crmacct_id=<? value("crmacct_id") ?>)\n<? endif ?>\n<? if exists("cntct_id") ?>\n  AND (prj_cntct_id=<? value("cntct_id") ?>)\n<? endif ?>\n<? if exists("prjtype_id") ?>\n  AND (prj_prjtype_id=<? value("prjtype_id") ?>)\n<? endif ?>\n<? if exists("prjstatus") ?>\n  AND (prj_status=<? value("prjstatus") ?>)\n<? elseif not exists("showComplete") ?>\n  AND (prj_status <> 'C')\n<? endif ?>\n<? if exists("startStartDate") ?>\n  AND (prj_start_date >= <? value("startStartDate") ?>)\n<? endif ?>\n<? if exists("startEndDate") ?>\n  AND (prj_start_date <= <? value("startEndDate") ?>)\n<? endif ?>\n<? if exists("dueStartDate") ?>\n  AND (prj_due_date >= <? value("dueStartDate") ?>)\n<? endif ?>\n<? if exists("dueEndDate") ?>\n  AND (prj_due_date <= <? value("dueEndDate") ?>)\n<? endif ?>\n<? if exists("assignedStartDate") ?>\n  AND (prj_assigned_date >= <? value("assignedStartDate") ?>)\n<? endif ?>\n<? if exists("assignedEndDate") ?>\n  AND (prj_assigned_date <= <? value("assignedEndDate") ?>)\n<? endif ?>\n<? if exists("completedStartDate") ?>\n  AND (prj_completed_date >= <? value("completedStartDate") ?>)\n<? endif ?>\n<? if exists("completedEndDate") ?>\n  AND (prj_completed_date <= <? value("completedEndDate") ?>)\n<? endif ?>\n<? if exists("id") ?>\n  AND (prj_id=<? value("id") ?>)\n<? endif ?>\n<? if exists("prj_id") ?>\n  AND (prj_id=<? value("prj_id") ?>)\n<? endif ?>\n<? if exists("project_task") ?>\n  AND prj_id IN (SELECT DISTINCT prjtask_prj_id FROM prjtask where ((prjtask_number ~* <? value("project_task") ?>)\n\t\t\t\t\t\tOR (prjtask_name ~* <? value("project_task") ?>)\n\t\t\t\t\t\tOR (prjtask_descrip ~* <? value("project_task") ?>)))\n<? endif ?>\n<? if exists("cohead_id") ?>\n  AND prj_id IN (SELECT cohead_prj_id FROM cohead where cohead_id=<? value("cohead_id") ?>)\n<? endif ?>\n<? if exists("wo_id") ?>\n  AND prj_id IN (SELECT wo_prj_id FROM wo WHERE wo_id=<? value("wo_id") ?>)\n<? endif ?>\n<? if exists("pohead_id") ?>\n  AND prj_id IN (SELECT poitem_prj_id FROM pohead JOIN poitem ON (pohead_id=poitem_pohead_id)\n\t\t\tWHERE pohead_id=<? value("pohead_id") ?>)\n<? endif ?>\n<? literal("charClause") ?>\nORDER BY prj_number;     admin   2014-10-06      0
101189
 
277     projects        detail  \n        Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n\n        xTuple version 4.2.0 - Modified to significantly amend the display of this screen and its filters.\n        xTuple version 4.3.0 - Add Incidents to hierarchy display\n  -- Group: projects\n-- Name:  detail\n-- Notes:\n--        Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n--\n--        xTuple version 4.2.0 - Modified to significantly amend the display of this screen and its filters.\n--        xTuple version 4.3.0 - Add Incidents to hierarchy display\nSELECT *,\n  formatQty(qty) AS f_qty,\n  formatMoney(value) AS f_value,\n  'curr' AS qty_xtnumericrole,\n  'curr' AS value_xtnumericrole,\n  CASE WHEN COALESCE(hrs_balance,0) < 0 THEN 'red' END AS hrs_balance_qtforegroundrole,\n  CASE WHEN COALESCE(exp_balance,0) < 0 THEN 'red' END AS exp_balance_qtforegroundrole\nFROM (\nSELECT prj_id AS id,\n       1 AS type,\n       '0' AS subtype,\n       0 AS section,\n       prj_id AS project,\n       NULL  AS section_qtdisplayrole,\n       prj_number AS name,\n       CASE\n           WHEN prj_status = 'C' THEN <? value('complete') ?>\n           WHEN prj_status = 'O' THEN <? value('inprocess') ?>\n           WHEN prj_status = 'P' THEN <? value('planning') ?>\n       END AS status,\n       COALESCE(prjtype_descr, 'Undefined') AS project_type,\n       prj_username,\n       prj_owner_username,\n       prj_name AS item,\n       firstline(prj_descrip) AS descrip,\n       crmacct_name AS customer,\n       cntct_name AS contact,\n       addr_city AS city,\n       addr_state AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       prj_due_date AS due,\n       prj_assigned_date AS assigned,\n       prj_start_date AS started,\n       prj_completed_date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n       CASE WHEN (prj_status = 'O' AND prj_due_date < current_date) THEN 'red'\n         WHEN (prj_status = 'O' AND prj_due_date BETWEEN current_date AND current_date + (fetchmetricvalue('ProjectDueDateWarning')||' days')::interval) THEN 'orange'\n         END AS due_qtforegroundrole,\n       0 AS xtindentrole\n  FROM prj()\n  LEFT OUTER JOIN prjtype ON (prj_prjtype_id=prjtype_id)\n  LEFT OUTER JOIN crmacct ON (prj_crmacct_id=crmacct_id)\n  LEFT OUTER JOIN cntct ON (crmacct_cntct_id_1=cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n\n WHERE (1=1 )\n\nUNION ALL\n----- TASKS -----\nSELECT DISTINCT -1 AS id,\n       3 AS type,\n       '0' AS subtype,\n       1 AS section,\n       prjtask_prj_id AS project,\n       <? value('tasks') ?> AS section_qtdisplayrole,\n       <? value('tasks') ?> AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n       NULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n    FROM prjtask\nUNION ALL\n\nSELECT prjtask_id AS id,\n       5 AS type,\n       '0' AS subtype,\n       1 AS section,\n       prjtask_prj_id AS project,\n       NULL AS section_qtdisplayrole,\n       prjtask_number AS name,\n       CASE\n           WHEN prjtask_status = 'C' THEN <? value('complete') ?>\n           WHEN prjtask_status = 'O' THEN <? value('inprocess') ?>\n           WHEN prjtask_status = 'P' THEN <? value('planning') ?>\n       END AS status,\n       NULL::text AS project_type,\n       prjtask_username AS prj_username,\n       prjtask_owner_username AS prj_owner_username,\n       prjtask_name AS item,\n       prjtask_descrip AS descrip,\n       cust_name as customer,\n       cntct_name AS contact,\n       addr_city AS city,\n       addr_state AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       prjtask_due_date AS due,\n       prjtask_assigned_date AS assigned,\n       prjtask_start_date AS started,\n       prjtask_completed_date AS completed,\n       prjtask_hours_budget AS hrs_budget,\n       prjtask_hours_actual AS hrs_actual,\n       (prjtask_hours_budget-prjtask_hours_actual) AS hrs_balance,\n       prjtask_exp_budget AS exp_budget,\n       prjtask_exp_actual AS exp_actual,\n       (prjtask_exp_budget-prjtask_exp_actual) AS exp_balance,\n       CASE WHEN (prjtask_status = 'O' AND prjtask_due_date < current_date) THEN 'red'\n         WHEN (prjtask_status = 'O' AND prjtask_due_date BETWEEN current_date AND current_date + (fetchmetricvalue('ProjectDueDateWarning')||' days')::interval) THEN 'orange'\n         END AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM prjtask\n  LEFT OUTER JOIN te.teprjtask ON (prjtask_id = teprjtask_prjtask_id)\n  LEFT OUTER JOIN custinfo ON (teprjtask_cust_id=cust_id)\n  LEFT OUTER JOIN cntct ON (cust_corrcntct_id=cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n\n WHERE (1=1 )\n GROUP BY prjtask_prj_id, custinfo.cust_name, prjtask.prjtask_id, addr.addr_city, addr.addr_state, cntct_name, prjtask.prjtask_number, prjtask.prjtask_status, prjtask_username, prjtask.prjtask_owner_username, prjtask_name, prjtask_descrip, prjtask_due_date, prjtask_assigned_date, prjtask_start_date, prjtask_completed_date, prjtask_hours_budget, prjtask_hours_actual, prjtask_exp_budget, prjtask_exp_actual\n\n<? if exists("showIn") ?>\n\nUNION ALL\n----- INCIDENTS -----\nSELECT DISTINCT -1 AS id,\n       100 AS type,\n       '0' AS subtype,\n       1 AS section,\n       incdt_prj_id AS project,\n       'Incidents' AS section_qtdisplayrole,\n       'Incidents' AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n       NULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n    FROM incdt\nUNION ALL\n\nSELECT incdt_id AS id,\n       105 AS type,\n       '0' AS subtype,\n       1 AS section,\n       incdt_prj_id AS project,\n       NULL AS section_qtdisplayrole,\n       incdt_number::text AS name,\n       CASE\n           WHEN incdt_status = 'L' THEN <? value('closed') ?>\n           WHEN incdt_status = 'N' THEN <? value('new') ?>\n           WHEN incdt_status = 'F' THEN <? value('feedback') ?>\n           WHEN incdt_status = 'A' THEN <? value('assigned') ?>\n           WHEN incdt_status = 'R' THEN <? value('resolved') ?>\n           WHEN incdt_status = 'C' THEN <? value('confirmed') ?>\n       END AS status,\n       NULL::text AS project_type,\n       incdt_assigned_username AS prj_username,\n       incdt_owner_username AS prj_owner_username,\n       incdt_number::text AS item,\n       incdt_summary AS descrip,\n       crmacct_number AS customer,\n       crmacct_name AS contact,\n       addr_city AS city,\n       addr_state AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n       NULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM incdt\n  LEFT OUTER JOIN crmacct ON (incdt_crmacct_id=crmacct_id)\n  LEFT OUTER JOIN cntct ON (incdt_cntct_id=cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n\n WHERE (1=1 )\n GROUP BY incdt_id, incdt_prj_id, incdt_number, crmacct_number, crmacct_name, addr.addr_city, addr.addr_state, cntct_name, incdt_number, incdt_status, incdt_assigned_username, incdt_owner_username, incdt_number, incdt_summary\n<? endif ?>\n\n<? if exists("showSo") ?>\nUNION ALL\n\n----- QUOTES -----\nSELECT DISTINCT -1 AS id,\n       10 AS type,\n       '0' AS subtype,\n       1 AS section,\n       prj_id AS project,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       <? value("quotes") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n       NULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n  FROM quhead\n  JOIN prj() ON (quhead_prj_id=prj_id)\n WHERE (1=1)\nUNION ALL\n\nSELECT quhead_id AS id,\n       15 AS type,\n       quhead_number AS subtype,\n       1 AS section,\n       prj_id AS project,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       quhead_number AS name,\n       CASE WHEN (quhead_status = 'C') THEN\n         <? value("converted") ?>\n            WHEN (quhead_status = 'X') THEN\n         <? value("canceled") ?>\n            WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n         <? value("open") ?>\n            ELSE\n         <? value("expired") ?>\n       END AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       cust_name AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL::text AS uom,\n       NULL AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n       NULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM quhead\n  JOIN prj() ON (quhead_prj_id=prj_id)\n  JOIN custinfo ON (quhead_cust_id=cust_id)\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (1=1)\nGROUP BY prj_id, quhead_id, quhead_number, quhead_status, quhead_expire, quhead_freight, quhead_misc, custinfo.cust_name\n\nUNION ALL\n\nSELECT quitem_id AS id,\n       17 AS type,\n       quhead_number AS subtype,\n       1 AS section,\n       prj_id AS project,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       quitem_linenumber::text AS name,\n       CASE WHEN (quhead_status = 'C') THEN\n         <? value("converted") ?>\n            WHEN (quhead_status = 'X') THEN\n         <? value("canceled") ?>\n            WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n         <? value("open") ?>\n            ELSE\n         <? value("expired") ?>\n       END AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       item_number AS item,\n       item_descrip1 || ' ' || item_descrip2 AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       quitem_qtyord,\n       uom_name AS uom,\n       (quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n       NULL::text AS due_qtforegroundrole,\n       3 AS xtindentrole\n  FROM quhead\n  JOIN prj() ON (quhead_prj_id=prj_id)\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n    JOIN uom ON (quitem_qty_uom_id = uom_id)\n    JOIN itemsite ON (quitem_itemsite_id = itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT quhead_id AS id,\n       18 AS type,\n       quhead_number AS subtype,\n       1 AS section,\n       prj_id AS project,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       <? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM quhead\n    JOIN prj() ON (quhead_prj_id=prj_id)\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (1=1)\nGROUP BY prj_id, quhead_id, quhead_number\n\nUNION ALL\n\nSELECT -1 AS id,\n       19 AS type,\n       MAX(quhead_number) AS subtype,\n       1 AS section,\n       prj_id AS project,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("quotes") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM quhead\n    JOIN prj() ON (quhead_prj_id=prj_id)\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (1=1)\n GROUP BY prj_id\n\nUNION ALL\n\n------ SALES ORDERS ------\nSELECT DISTINCT -1 AS id,\n       20 AS type,\n       '0' AS subtype,\n       2 AS section,\n       prj_id AS project,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       <? value("sos") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n  FROM cohead\n    JOIN prj() ON (cohead_prj_id=prj_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT cohead_id AS id,\n       25 AS type,\n       cohead_number::text AS subtype,\n       2 AS section,\n       prj_id AS project,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       cohead_number::text AS name,\n      COALESCE((SELECT\n                  CASE WHEN (coitem_status = 'O') THEN\n                    <? value("open") ?>\n                       WHEN (coitem_status = 'C') THEN\n                    <? value("closed" ?>\n                      ELSE\n                    <? value("canceled") ?>\n                  END\n                FROM\n               (SELECT coitem_status,\n                   CASE\n                     WHEN (coitem_status = 'O') THEN 1\n                     WHEN (coitem_status = 'C') then 2\n                     ELSE  3\n                  END AS type\n                  FROM coitem\n                 WHERE (coitem_cohead_id=cohead_id)\n                 ORDER BY type\n                 LIMIT 1) AS sts) ,'O')\n        AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       shipto_num AS item,\n       shipto_name AS descrip,\n       cust_name AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL::text AS uom,\n       NULL AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM cohead\n    JOIN prj() ON (cohead_prj_id=prj_id)\n    JOIN custinfo ON (cust_id = cohead_cust_id)\n    LEFT OUTER JOIN shiptoinfo ON (cohead_shipto_id = shipto_id)\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (1=1)\nGROUP BY prj_id,cohead_id, cohead_number, shipto_num, shipto_name, cust_name\n\nUNION ALL\n\nSELECT coitem_id AS id,\n       27 AS type,\n       cohead_number::text AS subtype,\n       2 AS section,\n       prj_id AS project,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       coitem_linenumber::text AS name,\n       CASE WHEN (coitem_status = 'O') THEN\n         <? value("open") ?>\n            WHEN (coitem_status = 'C') THEN\n         <? value("closed" ?>\n            WHEN (coitem_status = 'X') THEN\n         <? value("canceled") ?>\n       END AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       item_number AS item,\n       item_descrip1 || ' ' || item_descrip2 AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       coitem_qtyord,\n       uom_name AS uom,\n       (coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       3 AS xtindentrole\n  FROM cohead\n    JOIN prj() ON (cohead_prj_id=prj_id)\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n    JOIN uom ON (coitem_qty_uom_id = uom_id)\n    JOIN itemsite ON (coitem_itemsite_id = itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT cohead_id AS id,\n       28 AS type,\n       cohead_number::text AS subtype,\n       2 AS section,\n       prj_id AS project,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM cohead\n    JOIN prj() ON (cohead_prj_id=prj_id)\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (1=1)\nGROUP BY prj_id,cohead_id, cohead_number\n\nUNION ALL\n\nSELECT -1 AS id,\n       29 AS type,\n       MAX(cohead_number::text) AS subtype,\n       2 AS section,\n       prj_id AS project,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("sos") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM cohead\n    JOIN prj() ON (cohead_prj_id=prj_id)\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (1=1)\n GROUP BY prj_id\n\nUNION ALL\n\n------ INVOICES -------\nSELECT DISTINCT -1 AS id,\n       30 AS type,\n       '0' AS subtype,\n       3 AS section,\n       prj_id AS project,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       <? value("invoices") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n  FROM invchead\n  JOIN prj() ON (invchead_prj_id=prj_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT invchead_id AS id,\n       35 AS type,\n       invchead_invcnumber::text AS subtype,\n       3 AS section,\n       prj_id AS project,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       invchead_invcnumber::text AS name,\n       CASE WHEN (invchead_posted) THEN\n         <? value("posted") ?>\n       ELSE <? value("unposted") ?>\n       END AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       shipto_num AS item,\n       shipto_name AS descrip,\n       cust_name AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL::text AS uom,\n       NULL AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM invchead\n    JOIN prj() ON (invchead_prj_id=prj_id)\n    JOIN custinfo ON (cust_id=invchead_cust_id)\n    LEFT OUTER JOIN shiptoinfo ON (invchead_shipto_id = shipto_id)\n\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (1=1)\nGROUP BY prj_id,invchead_id, invchead_invcnumber, shipto_num, shipto_name, invchead_freight, invchead_misc_amount, invchead_posted, cust_name\n\nUNION ALL\n\nSELECT invcitem_id AS id,\n       37 AS type,\n       invchead_invcnumber::text AS subtype,\n       3 AS section,\n       prj_id AS project,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       invcitem_linenumber::text AS name,\n       CASE WHEN (invchead_posted) THEN\n         <? value("posted") ?>\n       ELSE <? value("unposted") ?>\n       END AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       COALESCE(item_number,invcitem_number) AS item,\n       COALESCE(item_descrip1 || ' ' || item_descrip2,invcitem_descrip) AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       invcitem_billed AS qty,\n       uom_name AS uom,\n       (invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       3 AS xtindentrole\n  FROM invchead\n    JOIN prj() ON (invchead_prj_id=prj_id)\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n    LEFT OUTER JOIN item ON (invcitem_item_id = item_id)\n    LEFT OUTER JOIN uom ON (invcitem_qty_uom_id = uom_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT invchead_id AS id,\n       38 AS type,\n       invchead_invcnumber::text AS subtype,\n       3 AS section,\n       prj_id AS project,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       <? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM invchead\n    JOIN prj() ON (invchead_prj_id=prj_id)\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (1=1)\nGROUP BY prj_id,invchead_id, invchead_invcnumber\n\nUNION ALL\n\nSELECT -1 AS id,\n       39 AS type,\n       MAX(invchead_invcnumber::text) AS subtype,\n       3 AS section,\n       prj_id AS project,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("invoices") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM invchead\n    JOIN prj() ON (invchead_prj_id=prj_id)\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (1=1)\n GROUP BY prj_id\n\n<? endif ?>\n\n<? if exists("showWo") ?>\nUNION ALL\n\n------ WORK ORDERS -------\nSELECT DISTINCT -1 AS id,\n       40 AS type,\n       '0' AS subtype,\n       4 AS section,\n       prj_id AS project,\n       <? value("wos") ?> AS section_qtdisplayrole,\n       <? value("wos") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n  FROM wo\n  JOIN prj() ON (wo_prj_id=prj_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT wo_id AS id,\n       45 AS type,\n       formatWoNumber(wo_id) AS subtype,\n       4 AS section,\n       prj_id AS project,\n       <? value("wos") ?> AS section_qtdisplayrole,\n       formatWoNumber(wo_id) AS name,\n       CASE WHEN (wo_status = 'O') THEN\n         <? value("open") ?>\n            WHEN (wo_status = 'E') THEN\n         <? value("exploded") ?>\n            WHEN (wo_status = 'R') THEN\n         <? value("released") ?>\n            WHEN (wo_status = 'I') THEN\n         <? value("inprocess") ?>\n            WHEN (wo_status = 'C') THEN\n         <? value("closed" ?>\n       END AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       item_number AS item,\n       item_descrip1 || ' ' || item_descrip2 AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       wo_qtyord AS qty,\n       uom_name AS uom,\n       wo_postedvalue AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM wo\n    JOIN prj() ON (wo_prj_id=prj_id)\n    JOIN itemsite ON (itemsite_id=wo_itemsite_id)\n    JOIN item ON (itemsite_item_id=item_id)\n    JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT -1 AS id,\n       49 AS type,\n       MAX(formatWoNumber(wo_id)) AS subtype,\n       4 AS section,\n       prj_id AS project,\n       <? value("wos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("wos") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM(wo_postedvalue) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM wo\n     JOIN prj() ON (wo_prj_id=prj_id)\n WHERE (1=1)\n GROUP BY prj_id\n\n<? endif ?>\n\n\n<? if exists("showPo") ?>\n UNION ALL\n------ PURCHASE REQUESTS ------\nSELECT DISTINCT -1 AS id,\n       50 AS type,\n       '0' AS subtype,\n       5 AS section,\n       prj_id AS project,\n       <? value("prs") ?> AS section_qtdisplayrole,\n       <? value("prs") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n  FROM pr\n    JOIN prj() ON (pr_prj_id=prj_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT pr_id AS id,\n       55 AS type,\n       pr_number::text || '-' || pr_subnumber::text AS subtype,\n       5 AS section,\n       prj_id AS project,\n       <? value("prs") ?> AS section_qtdisplayrole,\n       pr_number::text || '-' || pr_subnumber::text AS name,\n       <? value("open") ?> AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       item_number AS item,\n       (item_descrip1 || ' ' || item_descrip2) AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       pr_qtyreq AS qty,\n       uom_name AS uom,\n       stdcost(item_id) * pr_qtyreq AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM pr\n    JOIN prj() ON (pr_prj_id=prj_id)\n    JOIN itemsite ON (itemsite_id = pr_itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n    JOIN uom ON (item_inv_uom_id = uom_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT -1 AS id,\n       59 AS type,\n       MAX(pr_number::text || '-' || pr_subnumber::text) AS subtype,\n       5 AS section,\n       prj_id AS project,\n       <? value("prs") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("prs") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM(stdcost(item_id) * pr_qtyreq) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM pr\n    JOIN prj() ON (pr_prj_id=prj_id)\n    JOIN itemsite ON (itemsite_id = pr_itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n WHERE (1=1)\n GROUP BY prj_id\n\nUNION ALL\n\n------ PURCHASE ORDERS ------\nSELECT DISTINCT -1 AS id,\n       60 AS type,\n       '0' AS subtype,\n       6 AS section,\n       prj_id AS project,\n       <? value("pos") ?> AS section_qtdisplayrole,\n       <? value("pos") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       1 AS xtindentrole\n  FROM poitem\n    JOIN prj() ON (poitem_prj_id=prj_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT pohead_id AS id,\n       65 AS type,\n       pohead_number::text AS subtype,\n       6 AS section,\n       prj_id AS project,\n       <? value("pos") ?> AS section_qtdisplayrole,\n       pohead_number::text AS name,\n       CASE WHEN (pohead_status = 'U') THEN\n         <? value("unreleased") ?>\n            WHEN (pohead_status = 'O') THEN\n         <? value("open") ?>\n            WHEN (pohead_status = 'C') THEN\n         <? value("closed" ?>\n       END AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL AS uom,\n       NULL AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n    JOIN prj() ON (poitem_prj_id=prj_id)\n WHERE (1=1)\nGROUP BY prj_id,pohead_id, pohead_number, pohead_freight, pohead_status\n\nUNION ALL\n\nSELECT poitem_id AS id,\n       67 AS type,\n       pohead_number::text AS subtype,\n       6 AS section,\n       prj_id AS project,\n       <? value("pos") ?> AS section_qtdisplayrole,\n       poitem_linenumber::text AS name,\n       CASE WHEN (poitem_status = 'U') THEN\n         <? value("unreleased") ?>\n            WHEN (poitem_status = 'O') THEN\n         <? value("open") ?>\n            WHEN (poitem_status = 'C') THEN\n         <? value("closed" ?>\n       END AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       COALESCE(item_number,poitem_vend_item_number) AS item,\n       COALESCE((item_descrip1 || ' ' || item_descrip2),poitem_vend_item_descrip) AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       poitem_qty_ordered,\n       poitem_vend_uom AS uom,\n       (poitem_qty_ordered * poitem_unitprice) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       3 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n    JOIN prj() ON (poitem_prj_id=prj_id)\n    LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n    LEFT OUTER JOIN item ON (itemsite_item_id = item_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT pohead_id AS id,\n       68 AS type,\n       pohead_number::text AS subtype,\n       6 AS section,\n       prj_id AS project,\n       <? value("pos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM(poitem_qty_ordered * poitem_unitprice) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n    JOIN prj() ON (poitem_prj_id=prj_id)\n WHERE (1=1)\nGROUP BY prj_id,pohead_id, pohead_number\n\nUNION ALL\n\nSELECT -1 AS id,\n       69 AS type,\n       MAX(pohead_number::text) AS subtype,\n       6 AS section,\n       prj_id AS project,\n       'qty' AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("pos") ?> AS name,\n       NULL AS status,\n       NULL::text AS project_type,\n       NULL::text AS prj_username,\n       NULL::text AS prj_owner_username,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::text AS customer,\n       NULL::text AS contact,\n       NULL::text AS city,\n       NULL::text AS state,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM(poitem_qty_ordered * poitem_unitprice) AS value,\n       NULL::date AS due,\n       NULL::date AS assigned,\n       NULL::date AS started,\n       NULL::date AS completed,\n       NULL::numeric AS hrs_budget,\n       NULL::numeric AS hrs_actual,\n       NULL::numeric AS hrs_balance,\n       NULL::numeric AS exp_budget,\n       NULL::numeric AS exp_actual,\n       NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n       2 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n    JOIN prj() ON (poitem_prj_id=prj_id)\n WHERE (1=1)\n GROUP BY prj_id\n\n<? endif ?>\n\n) data\n\nWHERE (true)\n<? if exists("search_pattern") ?>\n   AND project IN (SELECT prj_id FROM prj WHERE ( (prj_number ~* <? value("search_pattern") ?>)\n     OR  (prj_name ~* <? value("search_pattern") ?>)\n     OR  (prj_descrip ~* <? value("search_pattern") ?>) ))\n<? endif ?>\n<? if exists("username") ?>\n  AND (prj_username=<? value("username") ?> OR prj_owner_username=<? value("username") ?>)\n<? endif ?>\n<? if exists("assigned_username") ?>\n  AND (prj_username=<? value("assigned_username") ?>)\n<? elseif exists("assigned_usr_pattern") ?>\n  AND (prj_username ~ <? value("assigned_usr_pattern") ?>)\n<? endif ?>\n<? if exists("owner_username") ?>\n  AND (prj_owner_username=<? value("owner_username") ?>)\n<? elseif exists("owner_usr_pattern") ?>\n  AND (prj_owner_username ~ <? value("owner_usr_pattern") ?>)\n<? endif ?>\n<? if exists("crmacct_id") ?>\n  AND project IN (SELECT prj_id FROM prj WHERE (prj_crmacct_id=<? value("crmacct_id") ?>))\n<? endif ?>\n<? if exists("cntct_id") ?>\n  AND project IN (SELECT prj_id FROM prj WHERE (prj_cntct_id=<? value("cntct_id") ?>))\n<? endif ?>\n<? if exists("startStartDate") ?>\n  AND project IN (SELECT prj_id FROM prj WHERE (prj_start_date >= <? value("startStartDate") ?>))\n<? endif ?>\n<? if exists("startEndDate") ?>\n  AND project IN (SELECT prj_id FROM prj WHERE (prj_start_date <= <? value("startEndDate") ?>))\n<? endif ?>\n<? if exists("dueStartDate") ?>\n  AND project IN (SELECT prj_id FROM prj WHERE (prj_due_date >= <? value("dueStartDate") ?>))\n<? endif ?>\n<? if exists("dueEndDate") ?>\n  AND project IN (SELECT prj_id FROM prj WHERE (prj_due_date <= <? value("dueEndDate") ?>))\n<? endif ?>\n<? if exists("assignedStartDate") ?>\n  AND project IN (SELECT prj_id FROM prj WHERE (prj_assigned_date >= <? value("assignedStartDate") ?>))\n<? endif ?>\n<? if exists("assignedEndDate") ?>\n  AND project IN (SELECT prj_id FROM prj WHERE (prj_assigned_date <= <? value("assignedEndDate") ?>))\n<? endif ?>\n<? if exists("completedStartDate") ?>\n  AND project IN (SELECT prj_id FROM prj WHERE (prj_completed_date >= <? value("completedStartDate") ?>))\n<? endif ?>\n<? if exists("completedEndDate") ?>\n  AND project IN (SELECT prj_id FROM prj WHERE (prj_completed_date <= <? value("completedEndDate") ?>))\n<? endif ?>\n<? if not exists("showComplete") ?>\n  AND project IN (SELECT prj_id FROM prj WHERE prj_status <> 'C')\n<? endif ?>\n<? if exists("prj_id") ?>\n  AND (project=<? value("prj_id") ?>)\n<? endif ?>\n<? if exists("prjtype_id") ?>\n  AND project IN (SELECT prj_id FROM prj WHERE (prj_prjtype_id=<? value("prjtype_id") ?>))\n<? endif ?>\n<? if exists("project_task") ?>\n  AND project IN (SELECT DISTINCT prjtask_prj_id FROM prjtask where ((prjtask_number ~* <? value("project_task") ?>)\n\t\t\t\t\t\tOR (prjtask_name ~* <? value("project_task") ?>)\n\t\t\t\t\t\tOR (prjtask_descrip ~* <? value("project_task") ?>)))\n<? endif ?>\n<? if exists("cohead_id") ?>\n  AND project IN (SELECT cohead_prj_id FROM cohead where cohead_id=<? value("cohead_id") ?>)\n<? endif ?>\n<? if exists("wo_id") ?>\n  AND project IN (SELECT wo_prj_id FROM wo WHERE wo_id=<? value("wo_id") ?>)\n<? endif ?>\n<? if exists("pohead_id") ?>\n  AND project IN (SELECT poitem_prj_id FROM pohead JOIN poitem ON (pohead_id=poitem_pohead_id)\n\t\t\tWHERE pohead_id=<? value("pohead_id") ?>)\n<? endif ?>\n\nORDER BY project, section, subtype, type, id;\n      admin   2014-10-06      0
101190
 
278     prospects       detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: prospects\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  prospect.*,\n  cntct.*, addr.*\nFROM prospect \n  LEFT OUTER JOIN cntct ON (prospect_cntct_id=cntct_id) \n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) \nWHERE true\n<? if not exists("showInactive") ?> \n  AND prospect_active \n<? endif ?>\n<? if exists("owner_username") ?> \n  AND (prospect_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (prospect_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\n<? if exists("search_pattern") ?>\n  AND ((prospect_number ~* <? value("search_pattern") ?>)\n       OR (prospect_name ~* <? value("search_pattern") ?>)\n       OR (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(cntct_email,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_city,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_state,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_postalcode,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_country,'') ~* <? value("search_pattern") ?>))\n<? endif ?>\n<? if exists("prospect_number_pattern") ?>\n  AND (prospect_number ~* <? value("prospect_number_pattern") ?>)\n<? endif ?>\n<? if exists("prospect_name_pattern") ?>\n  AND (prospect_name ~* <? value("prospect_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_name_pattern") ?>\n  AND (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* <? value("cntct_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_phone_pattern") ?>\n  AND (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* <? value("cntct_phone_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_email_pattern") ?>\n  AND (COALESCE(cntct_email,'') ~* <? value("cntct_email_pattern") ?>)\n<? endif ?>\n<? if exists("addr_street_pattern") ?>\n  AND (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* <? value("addr_street_pattern") ?>)\n<? endif ?>\n<? if exists("addr_city_pattern") ?>\n  AND (COALESCE(addr_city,'') ~* <? value("addr_city_pattern") ?>)\n<? endif ?>\n<? if exists("addr_state_pattern") ?>\n  AND (COALESCE(addr_state,'') ~* <? value("addr_state_pattern") ?>)\n<? endif ?>\n<? if exists("addr_postalcode_pattern") ?>\n  AND (COALESCE(addr_postalcode,'') ~* <? value("addr_postalcode_pattern") ?>)\n<? endif ?>\n<? if exists("addr_country_pattern") ?>\n  AND (COALESCE(addr_country,'') ~* <? value("addr_country_pattern") ?>)\n<? endif ?>\n<? if exists("id") ?>\n  AND (prospect_id=<? value("id") ?>\n<? endif ?>\nORDER BY prospect_number; \n    admin   2014-10-06      0
101191
 
73      purchase        purchaserequests        \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: purchase\n-- Name:  purchaserequests\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pr_id, itemsite_id, itemsite_qtyonhand, itemsite_reorderlevel,\n       qtyNetable(itemsite_id) AS netableqoh, qtyNetable(itemsite_id, FALSE) AS nonnetableqoh,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS description,\n       pr.*,\n       CASE WHEN (pr_order_type='W') THEN ('W/O ' || ( SELECT formatWoNumber(womatl_wo_id)\n                                                       FROM womatl\n                                                       WHERE (womatl_id=pr_order_id) ) )\n            WHEN (pr_order_type='S') THEN ('S/O ' || (SELECT formatSoNumber(pr_order_id)))\n            WHEN (pr_order_type='F') THEN ('Planned Order')\n            WHEN (pr_order_type='M') THEN <? value("manual") ?>\n            ELSE <? value("other") ?>\n       END AS parent,\n       'qty' AS itemsite_qtyonhand_xtnumericrole, \n       'qty' AS itemsite_reorderlevel_xtnumericrole,\n       'qty' AS pr_qtyreq_xtnumericrole \nFROM pr, itemsite, item \nWHERE ((pr_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n<? if exists("startDate") ?>\n   AND (pr_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? elseif exists("plancode_id") ?>\n   AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n   AND (itemsite_plancode_id IN (SELECT plancode_id FROM\n                                 plancode\n                                 WHERE (plancode_code ~ <? value("plancode_pattern") ?>) ) )\n<? endif ?>\n) \nORDER BY pr_duedate;\n      admin   2014-10-06      0
101192
 
443     purchaseOrderItems      detail   used by purchaseOrderItem\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: purchaseOrderItems\n-- Name: detail\n-- Notes: used by purchaseOrderItem\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_number, pohead_taxzone_id,\n       pohead_curr_id, pohead_orderdate,\n       COALESCE(pohead_cohead_id, -1) AS pohead_cohead_id,\n       poitem_linenumber, poitem_vend_item_number,\n       poitem_vend_item_descrip, poitem_vend_uom,\n       poitem_invvenduomratio, poitem_status,\n       poitem_duedate, poitem_qty_ordered,\n       poitem_qty_received, poitem_unitprice,\n       poitem_freight, poitem_taxtype_id,\n       poitem_tax_recoverable, poitem_comments,\n       poitem_prj_id, poitem_bom_rev_id,\n       poitem_boo_rev_id, poitem_manuf_name,\n       poitem_manuf_item_number, poitem_manuf_item_descrip,\n       COALESCE(poitem_itemsite_id, -1) AS poitem_itemsite_id,\n       COALESCE(poitem_itemsrc_id, -1) AS poitem_itemsrc_id,\n       COALESCE(poitem_expcat_id, -1) AS poitem_expcat_id,\n       COALESCE(poitem_order_id, -1) AS poitem_order_id,\n       CASE WHEN (poitem_order_type='S') THEN TEXT(<? value("sonum") ?>)\n            WHEN (poitem_order_type='W') THEN TEXT(<? value("wonum") ?>)\n            ELSE ''\n       END AS demand_type,\n       CASE WHEN (poitem_order_type='S') THEN formatSoNumber(coitem_id)\n            WHEN (poitem_order_type='W') THEN formatWoNumber(womatl_wo_id)\n            ELSE ''\n       END AS order_number,\n       poitem_unitprice * poitem_qty_ordered AS extended_price,\n       COALESCE(coitem_prcost, 0.0) AS override_cost,\n       contrct_number,\n       itemsrc.*\n  FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id)\n              LEFT OUTER JOIN itemsrc ON (itemsrc_id=poitem_itemsrc_id)\n              LEFT OUTER JOIN coitem  ON (poitem_order_type='S' AND coitem_id=poitem_order_id)\n              LEFT OUTER JOIN womatl  ON (poitem_order_type='W' AND womatl_id=poitem_order_id)\n              LEFT OUTER JOIN contrct ON (itemsrc_contrct_id=contrct_id)\n WHERE ( (TRUE)\n<? if exists("poitem_id") ?>\n   AND (poitem_id=<? value("poitem_id") ?>)\n<? endif ?>\n);\n    admin   2014-10-06      0
101193
 
72      purchaseOrders  detail   used by dspPosByVendor, dspPOsByDate\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: purchaseOrders\n-- Name: detail\n-- Notes: used by dspPosByVendor, dspPOsByDate\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_id, pohead_number,\n       warehous_code AS warehousecode,\n       poitem_status, pohead_orderdate,\n       CASE WHEN(poitem_status='C') THEN TEXT(<? value("closed") ?>)\n            WHEN(poitem_status='U') THEN TEXT(<? value("unposted") ?>)\n            WHEN(poitem_status='O'\n                AND (SUM(poitem_qty_received-poitem_qty_returned) > 0) \n                AND (SUM(poitem_qty_ordered)>SUM(poitem_qty_received-poitem_qty_returned))) \n              THEN TEXT(<? value("partial") ?>)\n            WHEN(poitem_status='O'\n                AND (SUM(poitem_qty_received-poitem_qty_returned) > 0) \n                AND (SUM(poitem_qty_ordered)<=SUM(poitem_qty_received-poitem_qty_returned))) \n              THEN TEXT(<? value("received") ?>)\n            WHEN(poitem_status='O') THEN TEXT(<? value("open") ?>)\n            ELSE poitem_status\n       END AS poitem_status_qtdisplayrole,\n<? if exists("byDate") ?>\n       vend_name,\n       MIN(poitem_duedate) AS minDueDate,\n       CASE WHEN (MIN(poitem_duedate) < CURRENT_DATE) THEN 'error'\n       END AS minDueDate_qtforegroundrole,\n<? else ?>\n       vend_number,\n<? endif ?>\n<? if exists("byReceiptDate") ?>\n       MIN(date(recv_date)) AS sortDate,\n<? elseif exists("byDueDate") ?>\n       MIN(poitem_duedate) AS sortDate,\n<? else ?>\n       pohead_orderdate AS sortDate,\n<? endif ?>\n       CASE WHEN (MIN(poitem_duedate) < CURRENT_DATE) THEN 'error' END AS sortDate_qtforegroundrole,\n-- Report formatting\n  formatDate(pohead_orderdate) AS f_orderdate,\n  formatDate(MIN(poitem_duedate)) AS f_duedate, \n       CASE WHEN(poitem_status='C') THEN TEXT(<? value("closed") ?>)\n            WHEN(poitem_status='U') THEN TEXT(<? value("unposted") ?>)\n            WHEN(poitem_status='O'\n                AND (SUM(poitem_qty_received-poitem_qty_returned) > 0) \n                AND (SUM(poitem_qty_ordered)>SUM(poitem_qty_received-poitem_qty_returned))) \n              THEN TEXT(<? value("partial") ?>)\n            WHEN(poitem_status='O'\n                AND (SUM(poitem_qty_received-poitem_qty_returned) > 0) \n                AND (SUM(poitem_qty_ordered)<=SUM(poitem_qty_received-poitem_qty_returned))) \n              THEN TEXT(<? value("received") ?>)\n            WHEN(poitem_status='O') THEN TEXT(<? value("open") ?>)\n            ELSE poitem_status\n       END AS f_status\n-- End Report formatting\n  FROM vendinfo, poitem,\n<? if exists("byReceiptDate") ?>\n       recv,\n<? endif ?>\n       pohead LEFT OUTER JOIN whsinfo ON (pohead_warehous_id=warehous_id)\n WHERE ((poitem_pohead_id=pohead_id)\n   AND  (pohead_vend_id=vend_id)\n<? if exists("byReceiptDate") ?>\n   AND  (recv_itemsite_id=poitem_itemsite_id)\n   AND  (recv_order_number=pohead_number)\n   AND  (date(recv_date) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n   AND  (recv_order_type='PO')\n<? elseif exists("byDueDate") ?>\n   AND  (poitem_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? else ?>\n   AND  (pohead_orderdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("vend_id") ?>\n   AND  (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n   AND  (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n   AND (vend_vendtype_id IN (SELECT vendtype_id\n                               FROM vendtype\n                              WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (pohead_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if not exists("showClosed") ?>\n   AND (poitem_status!='C')\n<? endif ?>\n<? if exists("agentUsername") ?>\n   AND (pohead_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n<? if exists("descrip_pattern") ?>\n  AND ((poitem_vend_item_descrip ~* <? value("descrip_pattern") ?>)\n    OR (poitem_itemsite_id IN (\n      SELECT itemsite_id\n        FROM itemsite, item\n       WHERE ((itemsite_item_id=item_id)\n         AND  ((item_descrip1 ~* <? value("descrip_pattern") ?>)\n            OR (item_descrip2 ~* <? value("descrip_pattern") ?>)))\n                              )))\n<? endif ?>\n\n)\nGROUP BY pohead_id, pohead_number, warehous_code,\n         poitem_status, pohead_orderdate,\n<? if exists("byDate") ?>\n         vend_name \n<? else ?>\n         vend_number\n<? endif ?>\nORDER BY\n<? if exists("byDate") ?>\n  minDueDate\n<? else ?>\n  sortDate\n<? endif ?>;\n       admin   2014-10-06      0
101194
 
279     qoh     detail   \n Quantity on Hand By Location\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: qoh\n-- Name: detail\n-- Notes: \n-- Quantity on Hand By Location\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("byLocation") ?>\nSELECT itemloc_id, alt_id, warehous_code, item_number,\n       f_descrip, f_lotserial, uom_name,\n       qoh, reservedqty,\n       'qty' AS qoh_xtnumericrole,\n       'qty' AS reservedqty_xtnumericrole,\n       level AS xtindentrole\nFROM (\n      SELECT itemloc_id, 0 AS alt_id, 0 AS level, item_number AS sortkey, warehous_code, item_number,\n             (item_descrip1 || ' ' || item_descrip2) AS f_descrip,\n             formatlotserialnumber(itemloc_ls_id) AS f_lotserial, uom_name,\n             itemloc_qty AS qoh,\n  <? if exists("EnableSOReservationsByLocation") ?>\n             qtyReservedLocation(itemloc_id) AS reservedqty\n  <? else ?>\n             0 AS reservedqty\n  <? endif ?>\n      FROM itemloc, itemsite, whsinfo, item, uom\n      WHERE ((itemloc_itemsite_id=itemsite_id)\n         AND (itemsite_item_id=item_id)\n         AND (item_inv_uom_id=uom_id)\n         AND (itemsite_warehous_id=warehous_id)\n         AND (itemloc_location_id=<? value("location_id") ?>))\n      UNION\n      SELECT -1 AS itemloc_id, 0 AS alt_id, 0 AS level, item_number AS sortkey, warehous_code, item_number,\n             (item_descrip1 || ' ' || item_descrip2) AS f_descrip,\n             <? value("na") ?> AS f_lotserial, uom_name,\n             itemsite_qtyonhand AS qoh,\n             0 AS reservedqty\n      FROM itemsite, whsinfo, item, uom\n      WHERE ((itemsite_item_id=item_id)\n         AND (item_inv_uom_id=uom_id)\n         AND (itemsite_warehous_id=warehous_id)\n         AND (NOT itemsite_loccntrl)\n         AND (itemsite_location_id=<? value("location_id") ?>))\n  <? if exists("EnableSOReservationsByLocation") ?>\n      UNION\n      SELECT itemloc_id, -1 AS alt_id, 1 AS level, item_number AS sortkey, '' AS warehous_code, '' AS item_number,\n             (reserve_demand_type || '-' || formatSOItemNumber(reserve_demand_id)) AS f_descrip,\n             '' AS f_lotserial, '' AS uom_name,\n             NULL AS qoh,\n             reserve_qty AS reservedqty\n      FROM reserve, itemloc, itemsite, item\n      WHERE ((reserve_supply_id=itemloc_id)\n         AND (reserve_supply_type='I')\n         AND (itemsite_id=itemloc_itemsite_id)\n         AND(item_id=itemsite_item_id)\n         AND(itemloc_location_id=<? value("location_id") ?>))\n  <? endif ?>\n  <? if exists("ShowDemand") ?>\n      UNION\n      SELECT itemloc_id, coitem_cohead_id AS alt_id, 1 AS level, item_number AS sortkey, '' AS warehous_code, '' AS item_number,\n             (<? value("so") ?>|| '-' || formatSOItemNumber(coitem_id)) AS f_descrip,\n             '' AS f_lotserial, '' AS uom_name,\n             itemUOMtoUOM(item_id, coitem_qty_uom_id, NULL, (coitem_qtyord - coitem_qtyshipped - qtyAtShipping(coitem_id))) AS qoh,\n             0 AS reservedqty\n      FROM itemloc JOIN itemsite ON (itemsite_id=itemloc_itemsite_id)\n                   JOIN item ON (item_id=itemsite_item_id)\n                   JOIN coitem ON (coitem_itemsite_id=itemloc_itemsite_id AND coitem_status='O')\n      WHERE ((coitem_qtyord > (coitem_qtyshipped + qtyAtShipping(coitem_id)))\n         AND(itemloc_location_id=<? value("location_id") ?>))\n      UNION\n      SELECT itemloc_id, -1 AS alt_id, 1 AS level, item_number AS sortkey, '' AS warehous_code, '' AS item_number,\n             (<? value("wo") ?>|| '-' || formatWONumber(womatl_wo_id)) AS f_descrip,\n             '' AS f_lotserial, '' AS uom_name,\n             (womatl_qtyreq - womatl_qtyiss) AS qoh,\n             0 AS reservedqty\n      FROM itemloc JOIN itemsite ON (itemsite_id=itemloc_itemsite_id)\n                   JOIN item ON (item_id=itemsite_item_id)\n                   JOIN womatl ON (womatl_itemsite_id=itemloc_itemsite_id)\n      WHERE ((womatl_qtyreq > womatl_qtyiss)\n         AND(itemloc_location_id=<? value("location_id") ?>))\n      UNION\n      SELECT itemloc_id, -1 AS alt_id, 1 AS level, item_number AS sortkey, '' AS warehous_code, '' AS item_number,\n             (<? value("to") ?>|| '-' || formatTONumber(toitem_id)) AS f_descrip,\n             '' AS f_lotserial, '' AS uom_name,\n             (toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id)) AS qoh,\n             0 AS reservedqty\n      FROM itemloc JOIN itemsite ON (itemsite_id=itemloc_itemsite_id)\n                   JOIN item ON (item_id=itemsite_item_id)\n                   JOIN toitem ON (toitem_item_id=item_id AND toitem_status='O')\n                   JOIN tohead ON (tohead_id=toitem_tohead_id AND tohead_src_warehous_id=itemsite_warehous_id)\n      WHERE ((toitem_qty_ordered > (toitem_qty_shipped + qtyAtShipping('TO', toitem_id)))\n         AND(itemloc_location_id=<? value("location_id") ?>))\n  <? endif ?>\n     ) AS data\nORDER BY\n         sortkey, itemloc_id, level;\n<? else ?>\n<? if exists("asOf") ?>\nSELECT forwardupdateinvbalance(invbal_id)\nFROM (\n      SELECT DISTINCT ON (itemsite_id) invbal_id\n      FROM invbal, itemsite, item, whsinfo, classcode, uom, costcat, period\n      WHERE ((invbal_dirty)\n         AND (invbal_period_id=period_id)\n         AND (itemsite_item_id=item_id)\n         AND (itemsite_warehous_id=warehous_id)\n         AND (itemsite_active)\n         AND (item_inv_uom_id=uom_id)\n         AND (item_classcode_id=classcode_id)\n         AND (itemsite_costcat_id=costcat_id)\n  <? if exists("item_id") ?>\n         AND (itemsite_item_id=<? value("item_id") ?>)\n  <? endif ?>\n  <? if exists("classcode_id") ?>\n         AND (classcode_id=<? value("classcode_id") ?>)\n  <? endif ?>\n  <? if exists("classcode_pattern") ?>\n         AND (classcode_id IN (SELECT classcode_id\n                               FROM classcode\n                               WHERE classcode_code ~ <? value("classcode_pattern") ?>))\n  <? endif ?>\n  <? if exists("costcat_id") ?>\n         AND (costcat_id=<? value("costcat_id") ?>)\n  <? endif ?>\n  <? if exists("costcat_pattern") ?>\n         AND (costcat_id IN (SELECT costcat_id\n                               FROM costcat\n                               WHERE costcat_code ~ <? value("costcat_pattern") ?>))\n  <? endif ?>\n  <? if exists("itemgrp_id") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id\n                          FROM itemgrpitem\n                          WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n  <? endif ?>\n  <? if exists("itemgrp_pattern") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id\n                          FROM itemgrpitem, itemgrp\n                          WHERE ((itemgrpitem_itemgrp_id=itemgrp_id)\n                             AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>))))\n  <? endif ?>\n  <? if exists("showPositive") ?>\n       AND (itemsite_qtyonhand > 0)\n  <? elseif exists("showNegative") ?>\n       AND (itemsite_qtyonhand < 0)\n  <? endif ?>\n  <? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n            )\n       ORDER BY itemsite_id, period_start\n     ) AS data\n;\n<? endif ?>\n--  Quantity on Hand\nSELECT itemsite_id, detail,warehous_code,\n       classcode_code, item_number, uom_name,\n       costcat_code,\n       item_descrip1, item_descrip2,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       defaultlocation,\n       reorderlevel, formatQty(reorderlevel) AS f_reorderlevel,\n       qoh, formatQty(qoh) AS f_qoh,\n       availqoh, formatQty(availqoh) AS f_availqoh,\n       nonavailqoh, formatQty(nonavailqoh) AS f_nonavailqoh,\n       netqoh, formatQty(netqoh) AS f_netqoh,\n       nonnetqoh, formatQty(nonnetqoh) AS f_nonnetqoh,\n       cost, (cost * qoh) AS value,\n       (cost * availqoh) AS availvalue,\n       (cost * nonavailqoh) AS nonavailvalue,\n       (cost * netqoh) AS netvalue,\n       (cost * nonnetqoh) AS nonnetvalue,\n       CASE WHEN(itemsite_costmethod='A') THEN 'Average'\n            WHEN(itemsite_costmethod='S') THEN 'Standard'\n            WHEN(itemsite_costmethod='J') THEN 'Job'\n            WHEN(itemsite_costmethod='N') THEN 'None'\n         ELSE 'UNKNOWN'\n       END AS costmethod,\n  <? if exists("showValue") ?>\n       formatMoney(cost) AS f_cost, (cost * qoh) AS f_value,\n       formatMoney(cost * availqoh) AS f_availvalue,\n       formatMoney(cost * nonavailqoh) AS f_nonavailvalue,\n       formatMoney(cost * netqoh) AS f_netvalue,\n       formatMoney(cost * nonnetqoh) AS f_nonnetvalue,\n       CASE WHEN(itemsite_costmethod='A') THEN 'Average'\n            WHEN(itemsite_costmethod='S') THEN 'Standard'\n            WHEN(itemsite_costmethod='J') THEN 'Job'\n            WHEN(itemsite_costmethod='N') THEN 'None'\n         ELSE 'UNKNOWN'\n       END AS f_costmethod,\n  <? endif ?>\n       'qty' AS reorderlevel_xtnumericrole,\n       'qty' AS qoh_xtnumericrole,\n       'qty' AS availqoh_xtnumericrole,\n       'qty' AS nonavailqoh_xtnumericrole,\n       'qty' AS netqoh_xtnumericrole,\n       'qty' AS nonnetqoh_xtnumericrole,\n       0 AS qoh_xttotalrole,\n       0 AS availqoh_xttotalrole,\n       0 AS nonavailqoh_xttotalrole,\n       0 AS netqoh_xttotalrole,\n       0 AS nonnetqoh_xttotalrole,\n       'cost' AS cost_xtnumericrole,\n       'curr' AS value_xtnumericrole,\n       'curr' AS availvalue_xtnumericrole,\n       'curr' AS nonavailvalue_xtnumericrole,\n       'curr' AS netvalue_xtnumericrole,\n       'curr' AS nonnetvalue_xtnumericrole,\n       0 AS value_xttotalrole,\n       0 AS availvalue_xttotalrole,\n       0 AS nonavailvalue_xttotalrole,\n       0 AS netvalue_xttotalrole,\n       0 AS nonnetvalue_xttotalrole,\n       <? value("na") ?> AS availqoh_xtnullrole,\n       <? value("na") ?> AS nonavailqoh_xtnullrole,\n       <? value("na") ?> AS availvalue_xtnullrole,\n       <? value("na") ?> AS nonavailvalue_xtnullrole,\n       <? value("na") ?> AS netqoh_xtnullrole,\n       <? value("na") ?> AS nonnetqoh_xtnullrole,\n       <? value("na") ?> AS netvalue_xtnullrole,\n       <? value("na") ?> AS nonnetvalue_xtnullrole,\n       CASE WHEN (qoh < 0) THEN 'error' END AS qoh_qtforegroundrole,\n       CASE WHEN (reorderlevel > qoh) THEN 'warning' END AS qoh_qtforegroundrole\nFROM (\n      SELECT itemsite_id, itemsite_loccntrl, itemsite_costmethod,\n             ((itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S')) ) AS detail,\n             classcode_code, item_number, uom_name, item_descrip1, item_descrip2,\n             costcat_code, \n             CASE WHEN (NOT useDefaultLocation(itemsite_id)) THEN <? value("none") ?>\n               ELSE defaultLocationName(itemsite_id)\n             END AS defaultlocation,\n             warehous_code,\n             CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel,\n  <? if exists("asOf") ?>\n             COALESCE(invbal_qoh_ending,0) AS qoh,\n             COALESCE(invbal_qoh_ending,0) AS availqoh,\n             COALESCE(invbal_nn_ending,0) AS nonavailqoh,\n             COALESCE(invbal_qoh_ending,0) AS netqoh,\n             COALESCE(invbal_nn_ending,0) AS nonnetqoh,\n  <? else ?>\n             itemsite_qtyonhand AS qoh,\n             qtyAvailable(itemsite_id) AS availqoh,\n             qtyAvailable(itemsite_id, FALSE) AS nonavailqoh,\n             qtyNetable(itemsite_id) AS netqoh,\n             qtyNetable(itemsite_id, FALSE) AS nonnetqoh,\n  <? endif ?>\n  <? if exists("useStandardCosts") ?>\n             stdcost(item_id) AS cost\n  <? elseif exists("useActualCosts") ?>\n             actcost(item_id) AS cost\n  <? else ?>\n    <? if exists("asOf") ?>\n             COALESCE((invbal_value_ending / CASE WHEN(invbal_qoh_ending=0) THEN 1\n                                                  ELSE invbal_qoh_ending END),0) AS cost\n    <? else ?>\n             (itemsite_value / CASE WHEN(itemsite_qtyonhand=0) THEN 1\n                                    ELSE itemsite_qtyonhand END) AS cost\n    <? endif ?>\n  <? endif ?>\n      FROM item, whsinfo, classcode, uom, costcat, itemsite\n  <? if exists("asOf") ?>\n        LEFT OUTER JOIN invbal ON ((itemsite_id=invbal_itemsite_id)\n                               AND (invbal_period_id=<? value("asOf") ?>))\n  <? endif ?>\n      WHERE ((itemsite_item_id=item_id)\n         AND (itemsite_warehous_id=warehous_id)\n         AND (itemsite_active)\n         AND (item_inv_uom_id=uom_id)\n         AND (item_classcode_id=classcode_id)\n         AND (itemsite_costcat_id=costcat_id)\n  <? if exists("item_id") ?>\n         AND (itemsite_item_id=<? value("item_id") ?>)\n  <? endif ?>\n  <? if exists("classcode_id") ?>\n         AND (classcode_id=<? value("classcode_id") ?>)\n  <? endif ?>\n  <? if exists("classcode_pattern") ?>\n         AND (classcode_id IN (SELECT classcode_id\n                               FROM classcode\n                               WHERE classcode_code ~ <? value("classcode_pattern") ?>))\n  <? endif ?>\n  <? if exists("costcat_id") ?>\n         AND (costcat_id=<? value("costcat_id") ?>)\n  <? endif ?>\n  <? if exists("costcat_pattern") ?>\n         AND (costcat_id IN (SELECT costcat_id\n                               FROM costcat\n                               WHERE costcat_code ~ <? value("costcat_pattern") ?>))\n  <? endif ?>\n  <? if exists("itemgrp_id") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id\n                          FROM itemgrpitem\n                          WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n  <? endif ?>\n  <? if exists("itemgrp_pattern") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id\n                          FROM itemgrpitem, itemgrp\n                          WHERE ((itemgrpitem_itemgrp_id=itemgrp_id)\n                             AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>))))\n  <? endif ?>\n  <? if exists("showPositive") ?>\n    <? if exists("asOf") ?>\n       AND (COALESCE(invbal_qoh_ending,0) > 0)\n    <? else ?>\n       AND (itemsite_qtyonhand > 0)\n    <? endif ?>\n  <? elseif exists("showNegative") ?>\n    <? if exists("asOf") ?>\n       AND (COALESCE(invbal_qoh_ending,0) < 0)\n    <? else ?>\n       AND (itemsite_qtyonhand < 0)\n    <? endif ?>\n  <? endif ?>\n  <? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n            )\n     ) AS data\nORDER BY warehous_code, item_number;\n<? endif ?>\n     admin   2014-10-06      0
101195
 
74      quoteItems      detail   used by dspQuotesByItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: quoteItems\n-- Name: detail\n-- Notes: used by dspQuotesByItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT quitem_id, quhead_id,\n       quitem.*, quhead.*,\n       COALESCE(cust_number, prospect_number) AS cust_number,\n       COALESCE(cust_name, prospect_name) AS cust_name,\n       'qty' AS quitem_qtyord_xtnumericrole\nFROM quitem JOIN quhead ON (quhead_id=quitem_quhead_id)\n            LEFT OUTER JOIN custinfo ON (cust_id=quhead_cust_id)\n            LEFT OUTER JOIN prospect ON (prospect_id=quhead_cust_id)\n            JOIN itemsite ON (itemsite_id=quitem_itemsite_id)\n            JOIN site() ON (warehous_id=itemsite_warehous_id)\nWHERE ( (1=1)\n<? if exists("item_id") ?>\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("showConverted") ?>\n  AND (quhead_status IN ('C','O'))\n<? else ?>\n  AND (quhead_status NOT IN ('C','X'))\n<? endif ?>\n<? if exists("startDate") ?>\n  AND  (quhead_quotedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\nORDER BY quhead_number;\n\n      admin   2014-10-06      0
101196
 
483     quoteItems      list     used by salesOrder\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: quoteItems\n-- Name: list\n-- Notes: used by salesOrder\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT quitem_id,\n       quitem_linenumber AS f_linenumber,\n       0 AS coitem_subnumber, item_type,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS description,\n       warehous_code, '' AS enhanced_status,\n       quitem_scheddate AS coitem_scheddate,\n       quom.uom_name AS qty_uom,\n       quitem_qtyord AS coitem_qtyord,\n       0 AS qtyshipped, 0 AS qtyatshipping, 0 AS balance,\n       puom.uom_name AS price_uom,\n       quitem_price AS coitem_price,\n       ROUND((quitem_qtyord * quitem_qty_invuomratio) *\n             (quitem_price / quitem_price_invuomratio),2) AS extprice,\n       quitem_custprice AS coitem_custprice,\n       CASE WHEN (quitem_custprice = 0.0) THEN 100.0\n            ELSE ((1.0 - (quitem_price / quitem_custprice)) * 100.0)\n       END AS discountfromcust,\n       quitem_unitcost AS coitem_unitcost,\n       CASE WHEN (quitem_price = 0.0) THEN 0.0\n            ELSE ROUND((quitem_qtyord * quitem_qty_invuomratio) *\n                 ((quitem_price / quitem_price_invuomratio) - (quitem_unitcost / quitem_price_invuomratio)),2)\n       END AS margin,\n       CASE WHEN (quitem_price = 0.0) THEN 0.0\n            ELSE ((quitem_price - quitem_unitcost) / quitem_price)\n       END AS marginpercent,\n       CASE WHEN (quitem_custpn != '') THEN quitem_custpn\n            ELSE item_number\n       END AS item_number_cust,\n       (quitem_qtyord * quitem_qty_invuomratio * item_prodweight) AS prodweight,\n       (quitem_qtyord * quitem_qty_invuomratio * item_packweight) AS packweight,\n       itemsite_qtyonhand,\n       'qty' AS coitem_qtyord_xtnumericrole,\n       'qty' AS qtyshipped_xtnumericrole,\n       'qty' AS balance_xtnumericrole,\n       'qty' AS qtyatshipping_xtnumericrole,\n       'qty' AS prodweight_xtnumericrole,\n       'qty' AS packweight_xtnumericrole,\n       'qty' AS itemsite_qtyonhand_xtnumericrole,\n       'salesprice' AS coitem_price_xtnumericrole,\n       'cost' AS coitem_unitcost_xtnumericrole,\n       'curr' AS margin_xtnumericrole,\n       'percent' AS marginpercent_xtnumericrole,\n       'curr' AS extprice_xtnumericrole\n  FROM item, uom AS quom, uom AS puom,\n       quitem LEFT OUTER JOIN (itemsite JOIN whsinfo ON (itemsite_warehous_id=warehous_id)) ON (quitem_itemsite_id=itemsite_id)\n WHERE ( (quitem_item_id=item_id)\n   AND   (quitem_qty_uom_id=quom.uom_id)\n   AND   (quitem_price_uom_id=puom.uom_id)\n   AND   (quitem_quhead_id=<? value("quhead_id") ?>) )\nORDER BY quitem_linenumber; admin   2014-10-06      0
101197
 
75      quotes  detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: quotes\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT quhead.*, firstline(quhead_ordercomments) AS notes, quhead_id AS id,\n       calcQuoteAmt(quhead_id) AS ordertotal,\n       'extprice' AS ordertotal_xtnumericrole,\n       <? foreach("char_id_text_list") ?>\n         charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>,\n       <? endforeach ?>\n       <? foreach("char_id_list_list") ?>\n         charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>,\n       <? endforeach ?>\n       <? foreach("char_id_date_list") ?>\n         charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>,\n       <? endforeach ?>\n       CASE WHEN quhead_status = 'O' THEN <? value("open") ?>\n            WHEN quhead_status = 'C' THEN <? value("converted") ?>\n            ELSE <? value("undefined") ?>\n       END AS quhead_status_qtdisplayrole,\n<? if exists("customersOnly") ?>\n       cust_id, cust_number, cust_name,\n<? endif ?>\n       ( SELECT MIN(quitem_scheddate)\n           FROM quitem\n          WHERE (quitem_quhead_id=quhead_id) ) AS min_scheddate,\n  CASE WHEN (quhead_expire < current_date) THEN\n    'error'\n   END AS quhead_expire_qtforegroundrole\nFROM quhead\n<? if not exists("customersOnly") ?>\n  LEFT OUTER \n<? endif ?>\n  JOIN custinfo ON (quhead_cust_id=cust_id)\n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> \n             ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='QU') \n            AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=quhead_id)\n            AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> \n             ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> \n             ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='QU') \n            AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=quhead_id)\n            AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> \n             ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> \n             ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='QU') \n            AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=quhead_id)\n            AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> \n             ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE (checkQuoteSitePrivs(quhead_id, <? value("warehous_id") ?>))\n<? if exists("owner_username") ?> \n  AND (quhead_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (quhead_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\n<? if exists("showConverted") ?>\n  AND (quhead_status IN ('C','O'))\n<? else ?>\n  AND (quhead_status NOT IN ('C','X'))\n<? endif ?>\n<? if not exists("showExpired") ?>\n  AND ((quhead_expire IS NULL) OR (quhead_expire >= CURRENT_DATE))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND  (quhead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND  (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND  (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("poNumber") ?>\n  AND  (quhead_custponumber=<? value("poNumber") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND  (quhead_quotedate >= <? value("startDate") ?> )\n<? endif ?>\n<? if exists("endDate") ?>\n  AND  (quhead_quotedate <= <? value("endDate") ?>)\n<? endif ?>\n<? if exists("salesrep_id") ?>\n  AND  (quhead_salesrep_id = <? value("salesrep_id") ?>)\n<? endif ?>\n<? if exists("id") ?>\n  AND  (quhead_id = <? value("id") ?>)\n<? endif ?>\n<? literal("charClause") ?>\n<? if exists("orderByCust") ?>\nORDER BY cust_number, quhead_number;\n<? else ?>\nORDER BY quhead_number;\n<? endif ?>\n\n      admin   2014-10-06      0
101198
 
76      receipt detail   used by enterPoReceipt\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: receipt\n-- Name: detail\n-- Notes: used by enterPoReceipt\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("pohead_id") ?>\nSELECT poitem_id AS orderitem_id, COALESCE(poitem_itemsite_id,-1) AS itemsite_id, poitem_linenumber AS linenumber,\n       poitem_duedate AS duedate,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS item_number,\n       CASE WHEN (LENGTH(TRIM(BOTH '    ' FROM poitem_vend_item_descrip)) <= 0) THEN\n                 (item_descrip1 || ' ' || item_descrip2)\n            ELSE poitem_vend_item_descrip\n       END AS itemdescription,\n       COALESCE(uom_name, <? value("na") ?>) AS inv_uom,\n       warehous_code,\n       poitem_vend_item_number AS vend_item_number,\n       poitem_vend_uom AS vend_uom,\n       poitem_manuf_name AS manuf_name,\n       poitem_manuf_item_number AS manuf_item_number,\n       poitem_qty_ordered AS qty_ordered,\n       poitem_qty_received AS qty_received,\n       poitem_qty_returned AS qty_returned,\n       qtyToReceive(<? value("ordertype") ?>, poitem_id) AS qty_toreceive,\n       'qty' AS qty_ordered_xtnumericrole,\n       'qty' AS qty_received_xtnumericrole,\n       'qty' AS qty_returned_xtnumericrole,\n       'qty' AS qty_toreceive_xtnumericrole\nFROM poitem \n  LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id) \n<? if exists("selectedOnly") ?>\n  LEFT OUTER JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n<? endif ?>\n  LEFT OUTER JOIN item ON (itemsite_item_id=item_id) \n  LEFT OUTER JOIN uom ON (item_inv_uom_id=uom_id)\n  LEFT OUTER JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n  LEFT OUTER JOIN itemsrc ON (itemsrc_id=poitem_itemsrc_id)\nWHERE ( (poitem_status <> 'C')\n<? if exists("selectedOnly") ?>\n AND (usrsite_username=getEffectiveXtUser()) \n<? endif ?>\n<? if exists("bc") ?>\n AND ( (item_number=<? value("bc") ?>) OR\n       (item_upccode=<? value("bc") ?>) OR \n       (poitem_vend_item_number=<? value("bc") ?>) OR \n       (poitem_manuf_item_number=<? value("bc") ?>) OR \n       (COALESCE(itemsrc_upccode, '')=<? value("bc") ?>) ) \n<? endif ?>\n AND (poitem_pohead_id=<? value("pohead_id") ?>) )\nORDER BY poitem_linenumber;\n<? elseif exists("rahead_id") ?>\nSELECT raitem_id AS orderitem_id, itemsite_id, raitem_linenumber AS linenumber,\n       rahead_expiredate AS duedate,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n       COALESCE(iu.uom_name, <? value("na") ?>) AS inv_uom,\n       warehous_code,\n       '' AS vend_item_number,\n       ru.uom_name AS vend_uom,\n       '' AS manuf_name,\n       '' AS manuf_item_number,\n       raitem_qtyauthorized AS qty_ordered,\n       raitem_qtyreceived AS qty_received,\n       0 AS qty_returned,\n       qtyToReceive(<? value("ordertype") ?>, raitem_id) AS qty_toreceive,\n       'qty' AS qty_ordered_xtnumericrole,\n       'qty' AS qty_received_xtnumericrole,\n       'qty' AS qty_returned_xtnumericrole,\n       'qty' AS qty_toreceive_xtnumericrole\n\nFROM rahead, raitem \n  LEFT OUTER JOIN \n     ( itemsite \n<? if exists("selectedOnly") ?>\n       JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n<? endif ?>\n       JOIN item ON (itemsite_item_id=item_id) \n       JOIN uom iu ON (item_inv_uom_id=uom_id)\n       JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n     ) ON (raitem_itemsite_id=itemsite_id), uom ru\nWHERE ( (raitem_status <> 'C')\n AND (item_type <> 'K')\n AND (raitem_qtyauthorized > 0)\n AND (raitem_disposition IN ('R','P','V'))\n AND (raitem_rahead_id=rahead_id)\n AND (raitem_qty_uom_id=ru.uom_id)\n<? if exists("selectedOnly") ?>\n AND (usrsite_username=getEffectiveXtUser()) \n<? endif ?>\n<? if exists("bc") ?>\n AND ( (item_number=<? value("bc") ?>) OR\n       (item_upccode=<? value("bc") ?>) )\n<? endif ?>\n AND (rahead_id=<? value("rahead_id") ?>) )\nORDER BY raitem_linenumber;\n<? elseif exists("tohead_id") ?>\nSELECT toitem_id AS orderitem_id, itemsite_id, toitem_linenumber AS linenumber,\n       toitem_duedate AS duedate,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n       COALESCE(uom_name, <? value("na") ?>) AS inv_uom,\n       warehous_code,\n       ''  AS vend_item_number,\n       toitem_uom AS vend_uom,\n       '' AS manuf_name,\n       '' AS manuf_item_number,\n       toitem_qty_ordered AS qty_ordered,\n       toitem_qty_received AS qty_received,\n       0 AS qty_returned,\n       qtyToReceive(<? value("ordertype") ?>, toitem_id) AS qty_toreceive,\n       'qty' AS qty_ordered_xtnumericrole,\n       'qty' AS qty_received_xtnumericrole,\n       'qty' AS qty_returned_xtnumericrole,\n       'qty' AS qty_toreceive_xtnumericrole\nFROM tohead, itemsite\n<? if exists("selectedOnly") ?>\n       JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n<? endif ?>\n, whsinfo, toitem, item JOIN uom ON (item_inv_uom_id=uom_id)\nWHERE ((toitem_item_id=item_id)\n  AND  (tohead_id=toitem_tohead_id)\n  AND  (tohead_dest_warehous_id=itemsite_warehous_id)\n  AND  (tohead_dest_warehous_id=warehous_id)\n  AND  (toitem_item_id=itemsite_item_id)\n  AND  (toitem_status NOT IN ('C','X'))\n  AND  (toitem_qty_shipped > toitem_qty_received)\n<? if exists("selectedOnly") ?>\n AND (usrsite_username=getEffectiveXtUser()) \n<? endif ?>\n<? if exists("bc") ?>\n AND ( (item_number=<? value("bc") ?>) OR\n       (item_upccode=<? value("bc") ?>) )\n<? endif ?>\n  AND  (toitem_tohead_id=<? value("tohead_id") ?>) )\nORDER BY toitem_linenumber;\n<? endif ?>\n  admin   2014-10-06      0
101199
 
77      receipt receiveAll       used by enterPoReceipt, returnAuthorization, shipOrder\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: receipt\n-- Name: receiveAll\n-- Notes: used by enterPoReceipt, returnAuthorization, shipOrder\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists ("shiphead_id") ?>\n  SELECT enterReceipt(<? value("ordertype") ?>,\n                      shipitem_orderitem_id,\n                      shipitem_qty,\n                      (orderitem_freight - orderitem_freight_received),\n                      '',\n                      orderitem_freight_curr_id,\n                      CURRENT_DATE) AS result\n  FROM shipitem, orderitemData(<? value("ordertype") ?>,\n                               <? value("orderid") ?>,\n                               NULL) AS orderitem\n       LEFT OUTER JOIN recv ON ((recv_orderitem_id=orderitem_id)\n                            AND (recv_order_type=orderitem_orderhead_type))\n  <? if exists("EnableReturnAuth") ?>\n       LEFT OUTER JOIN raitem ON ((raitem_id=orderitem_id)\n                              AND ('RA' = orderitem_orderhead_type))\n  <? endif ?>\n  WHERE ( (shipitem_shiphead_id=<? value("shiphead_id") ?>)\n    AND   (shipitem_orderitem_id=orderitem_id)\n  <? if exists("EnableReturnAuth") ?>\n    AND   ((orderitem_orderhead_type != 'RA') OR (raitem_disposition IN (NULL,'R','V','P')))\n  <? endif?>\n        )\n\n<? else ?>\n  SELECT enterReceipt(orderitem_orderhead_type,\n                      orderitem_id,\n<? if exists("tohead_id") ?>\n                      (orderitem_qty_shipped - orderitem_qty_received),\n<? else ?>\n                      (orderitem_qty_ordered - orderitem_qty_received),\n<? endif ?>\n                      (orderitem_freight - orderitem_freight_received),\n                      '',\n                      orderitem_freight_curr_id,\n                      CURRENT_DATE) AS result\n  FROM orderitemData(<? value("ordertype") ?>,\n                     <? value("orderid") ?>,\n                     NULL) AS orderitem\n       LEFT OUTER JOIN recv ON ((recv_orderitem_id=orderitem_id)\n                            AND (recv_order_type=orderitem_orderhead_type))\n<? if exists("EnableReturnAuth") ?>\n       LEFT OUTER JOIN raitem ON ((raitem_id=orderitem_id)\n                              AND ('RA' = orderitem_orderhead_type))\n<? endif ?>\n  WHERE (orderitem_status NOT IN ('C', 'X'))\n<? if exists("tohead_id") ?>\n    AND (orderitem_qty_shipped > orderitem_qty_received)\n<? endif ?>\n<? if exists("EnableReturnAuth") ?>\n    AND (((orderitem_orderhead_type != 'RA') OR (raitem_disposition IN (NULL,'R','V','P'))))\n<? endif ?>\n<? endif ?>\n      admin   2014-10-06      0
101200
 
78      receivings      detail   used by dspPoItemReceivingsByDate, dspPoItemReceivingsByItem, dspPoItemReceivingsByVendor\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: receivings\n-- Name: detail\n-- Notes: used by dspPoItemReceivingsByDate, dspPoItemReceivingsByItem, dspPoItemReceivingsByVendor\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT recv_id, 1 AS altid, recv_order_number AS ponumber,\n       vend_name,\n       recv_duedate           AS duedate,\n       recv_date              AS recvdate,\n       recv_vend_item_number  AS itemnumber,\n       recv_vend_item_descrip AS itemdescrip,\n       COALESCE(item_number,\n                (<? value("nonInv") ?> || recv_vend_item_number)) AS venditemnumber,\n       COALESCE(item_descrip1, recv_vend_item_descrip) AS venditemdescrip,\n       CASE WHEN (recv_vohead_id IS NOT NULL) THEN\n         <? value("received") ?>  \n       ELSE <? value("unvouchered") ?>\n       END AS sense,\n       recv_qty               AS qty,\n       currToBase(recv_purchcost_curr_id, recv_purchcost, CAST(recv_date AS DATE)) AS purchcost,\n       CASE WHEN (recv_qty > 0) THEN\n         COALESCE(recv_value,0) / recv_qty\n       ELSE 0 END  AS recvcost,\n       recv_value             AS value,\n       recv_invoiced          AS invoiced,\n       recv_date              AS sortdate,\n<? if exists("isReport") ?>\n       formatDate(recv_duedate)       AS f_duedate,\n       formatDate(recv_date)          AS f_recvdate,\n       formatQty(recv_qty)            AS f_qty,\n  <? if exists("showVariances") ?>\n       formatCost(currToBase(recv_purchcost_curr_id, recv_purchcost, CAST(recv_date AS DATE))) AS f_purchcost,\n       formatCost(CASE WHEN (recv_qty > 0) THEN COALESCE(recv_value,0) / recv_qty\n                       ELSE 0\n                  END)                AS f_recvcost,\n       formatMoney(recv_value)        AS f_value,\n  <? else ?>\n       NULL                           AS f_purchcost,\n       NULL                           AS f_recvcost,\n       NULL                           AS f_value,\n  <? endif ?>\n<? endif ?>\n       'qty'                  AS qty_xtnumericrole,\n       'cost'                 AS purchcost_xtnumericrole,\n       'cost'                 AS recvcost_xtnumericrole,\n       'curr'                 AS value_xtnumericrole,\n        <? value("na") ?>     AS duedate_xtnullrole,\n        <? value("na") ?>     AS purchcost_xtnullrole,\n        <? value("na") ?>     AS recvcost_xtnullrole\nFROM vendinfo, recv LEFT OUTER JOIN\n    (itemsite JOIN\n     item ON (itemsite_item_id=item_id)) ON (recv_itemsite_id=itemsite_id)\nWHERE ( (recv_vend_id=vend_id)\n AND (recv_order_type='PO')\n AND (recv_posted)\n AND (DATE(recv_date) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("vend_id") ?>\n AND (vend_id=<? value ("vend_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n AND (recv_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n<? if not exists("showUnvouchered") ?>\n AND (recv_vohead_id IS NOT NULL)\n AND (recv_invoiced)\n<? endif ?>\n)\nUNION\nSELECT poreject_id, 2, poreject_ponumber,\n       vend_name,\n       NULL,\n       poreject_date,\n       poreject_vend_item_number,\n       poreject_vend_item_descrip,\n       COALESCE(item_number,\n                (<? value("nonInv") ?> || poreject_vend_item_number)),\n       COALESCE(item_descrip1, poreject_vend_item_descrip),\n       <? value("returned") ?>,\n       poreject_qty,\n       NULL,\n       NULL,\n       poreject_value,\n       poreject_invoiced,\n       poreject_date,\n<? if exists("isReport") ?>\n       NULL                           AS f_duedate,\n       formatDate(poreject_date)      AS f_recvdate,\n       formatQty(poreject_qty)        AS f_qty,\n       NULL                           AS f_purchcost,\n       NULL                           AS f_recvcost,\n       formatMoney(poreject_value)    AS f_value,\n<? endif ?>\n       'qty',\n       'cost',\n       'cost',\n       'curr',\n        <? value("na") ?>     AS duedate_xtnullrole,\n        <? value("na") ?>     AS purchcost_xtnullrole,\n        <? value("na") ?>     AS recvcost_xtnullrole\nFROM vendinfo, poreject LEFT OUTER JOIN\n    (itemsite JOIN\n     item ON (itemsite_item_id=item_id)) ON (poreject_itemsite_id=itemsite_id)\nWHERE ( (poreject_vend_id=vend_id)\n AND (poreject_posted)\n AND (DATE(poreject_date) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("vend_id") ?>\n AND (vend_id=<? value ("vend_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n AND (poreject_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n<? if not exists("showUnvouchered") ?>\n AND (poreject_vohead_id IS NOT NULL)\n AND (poreject_invoiced)\n<? endif ?>\n)\nORDER BY sortdate DESC;\n  admin   2014-10-06      0
101201
 
280     reorderExceptionsByPlannerCode  detail   used by dspReorderExceptionsByPlannerCode\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: reorderExceptionsByPlannerCode\n-- Name: detail\n-- Notes: used by dspReorderExceptionsByPlannerCode\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, itemtype, warehous_code, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       reorderdate, reorderlevel,\n       (qtyNetable(itemsite_id) - qtyAllocated(itemsite_id, reorderdate) +\n         qtyOrdered(itemsite_id, reorderdate)) AS projavail,\n       'qty' AS reorderlevel_xtnumericrole,\n       'qty' AS projavail_xtnumericrole\nFROM (SELECT itemsite_id,\n             CASE WHEN (item_type IN ('M', 'B', 'T')) THEN 1\n                  WHEN (item_type IN ('P', 'O')) THEN 2\n               ELSE 3\n             END AS itemtype,\n             warehous_code, item_number, item_descrip1,\n             item_descrip2,\n             reorderDate(itemsite_id,\n                         <? value("lookAheadDays") ?>,\n                         <? value("includePlannedOrders") ?>)\n             AS reorderdate,\n             reorderlevel\n      FROM (SELECT itemsite_id, itemsite_item_id,\n                   itemsite_warehous_id,\n                   CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel\n                     ELSE 0.0\n                   END AS reorderlevel\n            FROM itemsite\n            WHERE ((true)\n            <? if exists("warehous_id") ?>\n               AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n            <? endif ?>\n            <? if exists("plancode_id") ?>\n               AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n            <? elseif exists("plancode_pattern") ?>\n               AND (itemsite_plancode_id IN (SELECT plancode_id\n                                             FROM plancode\n                                             WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n            <? endif ?>\n                  )\n           ) AS itemsitedata, item, whsinfo\n      WHERE ((itemsite_item_id=item_id)\n         AND (itemsite_warehous_id=warehous_id))\n     ) AS data\nWHERE (reorderdate IS NOT NULL)\nORDER BY reorderdate, item_number;\n   admin   2014-10-06      0
101202
 
452     reports detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: reports\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists('byPackage') ?>\n  SELECT report_id, report_name,\n         firstline(report_descrip) AS report_descrip, report_grade,\n         CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n         CASE nspname WHEN 'public' THEN 0\n                      ELSE 1        END AS xtindentrole,\n         report_descrip AS report_descrip_qttooltiprole\n    FROM report\n    JOIN pg_class     ON (report.tableoid=pg_class.oid)\n    JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n  UNION\n  SELECT -1, pkghead_name,\n         firstline(pkghead_descrip), NULL,\n         pkghead_name, 0, pkghead_descrip\n    FROM report, pg_class, pg_namespace\n    RIGHT OUTER JOIN pkghead ON (nspname=pkghead_name)\n   WHERE ((report.tableoid=pg_class.oid)\n      AND (relnamespace=pg_namespace.oid))\n  ORDER BY pkgname, xtindentrole, report_name,\n           report_grade DESC, report_id;\n<? else ?>\n  SELECT report_id, report_name,\n         firstline(report_descrip) AS report_descrip,\n         report_grade,\n         CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n         report_descrip AS report_descrip_qttooltiprole\n    FROM report\n    JOIN pg_class     ON (report.tableoid=pg_class.oid)\n    JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n  ORDER BY report_name,\n           report_grade DESC, report_id;\n<? endif ?>\n admin   2014-10-06      0
101203
 
79      reservations    detail   used by dspReservations\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: reservations\n-- Name: detail\n-- Notes: used by dspReservations\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT source_id, order_number, scheddate,\n       totalqty, relievedqty, reservedqty, balanceqty,\n       CASE WHEN (scheddate < CURRENT_DATE) THEN 'error' END AS scheddate_qtforegroundrold,\n       'qty' AS totalqty_xtnumericrole,\n       'qty' AS relievedqty_xtnumericrole,\n       'qty' AS reservedqty_xtnumericrole,\n       'qty' AS balanceqty_xtnumericrole,\n       0 AS balanceqty_xtrunningrole,\n       level AS xtindentrole\nFROM (\nSELECT coitem_scheddate AS sortkey, 0 AS level, coitem_id AS source_id,\n       formatSoNumber(coitem_id) AS order_number,\n       (coitem_qtyord * coitem_qty_invuomratio) AS totalqty,\n       ((coitem_qtyshipped + qtyAtShipping(coitem_id) - coitem_qtyreturned) * coitem_qty_invuomratio) as relievedqty,\n       (coitem_qtyreserved * coitem_qty_invuomratio) AS reservedqty,\n       (coitem_qtyreserved * coitem_qty_invuomratio) AS balanceqty,\n       coitem_scheddate AS scheddate\nFROM cohead, coitem, itemsite, item \nWHERE((coitem_cohead_id=cohead_id)\n  AND (coitem_itemsite_id=itemsite_id)\n  AND (coitem_qtyreserved > 0)\n  AND (itemsite_item_id=item_id)\n  AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND (itemsite_item_id=<? value("item_id") ?>))\nUNION\nSELECT coitem_scheddate AS sortkey, 1 AS level, coitem_id AS source_id,\n      (formatLocationName(itemloc_location_id) || ' ' || formatLotSerialNumber(itemloc_ls_id)) AS order_number,\n       NULL AS totalqty, NULL AS relievedqty,\n       (reserve_qty * coitem_qty_invuomratio) AS reservedqty,\n       NULL AS balanceqty, NULL AS scheddate\nFROM reserve, itemloc, coitem, itemsite\nWHERE ( (itemloc_id=reserve_supply_id)\n  AND (reserve_supply_type='I')\n  AND (coitem_id=reserve_demand_id)\n  AND (reserve_demand_type='SO')\n  AND (itemsite_id=coitem_itemsite_id)\n  AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND (itemsite_item_id=<? value("item_id") ?>) )\n    ) AS data\nORDER BY sortkey, source_id, level;\n        admin   2014-10-06      0
101204
 
101     returnAuthorizations    detail  \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: returnAuthorizations\n-- Name: detail\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT rahead_id, rahead_number, rahead_billtoname,\n       rahead_authdate,rahead_expiredate,\n       COALESCE(cust_number, 'Undefined') AS custnumber,\n       CASE\n       WHEN rahead_disposition = 'C' THEN\n         <? value("credit") ?>\n       WHEN rahead_disposition = 'R' THEN\n         <? value("return") ?>\n       WHEN rahead_disposition = 'P' THEN\n         <? value("replace") ?>\n       WHEN rahead_disposition = 'V' THEN\n         <? value("service") ?>\n       WHEN rahead_disposition = 'M' THEN\n         <? value("substitute") ?>\n       END AS disposition,\n       formatDate(rahead_authdate) AS f_authorized,\n       formatDate(rahead_expiredate) AS f_expires,\n       CASE WHEN (rahead_expiredate < current_date) THEN\n         'error'\n       END AS rahead_expiredate_qtforegroundrole\n  FROM rahead LEFT OUTER JOIN custinfo ON (rahead_cust_id=cust_id)\n               <? if exists("selectedSites") ?> \n                   JOIN raitem ON (raitem_rahead_id=rahead_id) \n                   JOIN itemsite ON (raitem_itemsite_id=itemsite_id) \n                   JOIN site() ON (itemsite_warehous_id=warehous_id) \n               <? else ?> \n                   LEFT OUTER JOIN raitem ON (raitem_rahead_id=rahead_id) \n                   LEFT OUTER JOIN itemsite ON (raitem_itemsite_id=itemsite_id) \n                   LEFT OUTER JOIN whsinfo ON (itemsite_warehous_id=warehous_id) \n               <? endif ?> \n WHERE ((true)\n<? if not exists("showClosed") ?> \n   AND ((raitem_status = 'O') OR (raitem_status IS NULL)) \n<? endif ?>\n<? if not exists("showUnauthorized") ?> \n   AND (raitem_qtyauthorized > 0) \n<? endif ?>\n<? if not exists("showExpired") ?>\n   AND (COALESCE(rahead_expiredate,CURRENT_DATE) >= CURRENT_DATE)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("cust_id") ?>\n   AND (rahead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n      )\n GROUP BY cust_number,rahead_id,rahead_number,rahead_authdate,rahead_expiredate,\n   rahead_billtoname,rahead_disposition\n ORDER BY rahead_number\n      admin   2014-10-06      0
101205
 
80      runningAvailability     detail   used by dspRunningAvailability, itemAvailabilityWorkbench\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: runningAvailability\n-- Name: detail\n-- Notes: used by dspRunningAvailability, itemAvailabilityWorkbench\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT orderid, altorderid, ordertype, ordernumber, sequence, item_number,\n       duedate, amount, qtyordered,  qtyreceived, balance,\n       balance AS runningavail, balance AS runningnetable,\n<? if exists("isReport") ?>\n       CASE WHEN duedate = startOfTime() THEN ''\n            ELSE formatDate(duedate) END AS f_duedate,\n       formatMoney(amount) AS f_amount,\n       formatQty(qtyordered) AS f_qtyordered,\n       formatQty(qtyreceived) AS f_qtyreceived,\n       formatQty(balance) AS f_balance,\n<? endif ?>\n       notes,\n       1 AS runningavail_xtrunningrole,\n       1 AS runningnetable_xtrunningrole,\n       <? value("qoh") ?> AS runningavail_xtrunninginit,\n       <? value("netableqoh") ?> AS runningnetable_xtrunninginit,\n       CASE WHEN late THEN 'error' END AS duedate_qtforegroundrole,\n       CASE WHEN duedate = startOfTime() THEN '' END AS duedate_qtdisplayrole,\n       CASE WHEN ordertype ~ <? value("plannedPo") ?> OR\n                 ordertype ~ <? value("plannedWo") ?> OR\n                 ordertype ~ <? value("plannedTo") ?> THEN\n          'emphasis' END AS qtforegroundrole,\n      'currency' AS amount_xtnumericrole,\n      'qty' AS qtyordered_xtnumericrole,\n      'qty' AS qtyreceived_xtnumericrole,\n      'qty' AS balance_xtnumericrole\nFROM (\n<? if exists("isReport") ?>\nSELECT -1 AS orderid, -1 AS altorderid, 'QOH' AS ordertype,\n       NULL AS ordernumber,\n       0 AS sequence,\n       '' AS item_number,\n       startOfTime() AS duedate,\n       FALSE AS late,\n       0 AS amount,\n       0 AS qtyordered,\n       0 AS qtyreceived,\n       <? value("qoh") ?> AS balance,\n       '' AS notes\nUNION\n<? endif ?>\n<? if exists("MultiWhs") ?>\nSELECT tohead_id AS orderid, toitem_id AS altorderid, 'T/O' AS ordertype,\n       TEXT(tohead_number) AS ordernumber,\n       1 AS sequence,\n       tohead_srcname || '/' || tohead_destname AS item_number,\n       toitem_duedate AS duedate,\n       (toitem_duedate < CURRENT_DATE) AS late,\n       (toitem_stdcost * toitem_qty_ordered) AS amount,\n       toitem_qty_ordered AS qtyordered,\n       toitem_qty_received AS qtyreceived,\n       noNeg(toitem_qty_ordered - toitem_qty_received) AS balance,\n       tohead_ordercomments AS notes\nFROM tohead, toitem\nWHERE ((toitem_tohead_id=tohead_id)\n  AND  (toitem_status NOT IN ('C', 'X'))\n  AND  (toitem_item_id=<? value("item_id") ?>)\n  AND  (tohead_dest_warehous_id=<? value("warehous_id") ?>)\n  AND  (toitem_qty_ordered > toitem_qty_received) )\n\nUNION\nSELECT tohead_id AS orderid, toitem_id AS altorderid, 'T/O' AS ordertype,\n       TEXT(tohead_number) AS ordernumber,\n       1 AS sequence,\n       tohead_srcname || '/' || tohead_destname AS item_number,\n       toitem_duedate AS duedate,\n       (toitem_duedate < CURRENT_DATE) AS late,\n       (toitem_stdcost * toitem_qty_ordered) AS amount,\n       toitem_qty_ordered AS qtyordered,\n       toitem_qty_received AS qtyreceived,\n       -1 * noNeg(toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id)) AS balance,\n       tohead_ordercomments AS notes\n       -- TODO: old code had ^^^^ for formatted balance and vvvv used to calc running avail! which is right?\n       -- -1 * noNeg(toitem_qty_ordered - toitem_qty_received) AS balance\nFROM tohead, toitem\nWHERE ((toitem_tohead_id=tohead_id)\n  AND  (toitem_status NOT IN ('C', 'X'))\n  AND  (toitem_item_id=<? value("item_id") ?>)\n  AND  (tohead_src_warehous_id=<? value("warehous_id") ?>)\n  AND  (toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id)) > 0 )\n\nUNION\n<? endif ?>\nSELECT wo_id AS orderid, -1 AS altorderid,\n       'W/O' AS ordertype,\n       formatWoNumber(wo_id) AS ordernumber,\n       1 AS sequence,\n       item_number,\n       wo_duedate AS duedate,\n       (wo_duedate < CURRENT_DATE) AS late,\n       (itemCost(wo_itemsite_id) * wo_qtyord) AS amount,\n       wo_qtyord AS qtyordered,\n       wo_qtyrcv AS qtyreceived,\n       noNeg(wo_qtyord - wo_qtyrcv) AS balance,\n       wo_prodnotes AS notes\nFROM wo, itemsite, item\nWHERE ((wo_status<>'C')\n  AND  (wo_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (item_type NOT IN ('C', 'Y')))\n\nUNION\n\n-- Tools on work orders to be returned\nSELECT wo_id AS orderid, -1 AS altorderid,\n       'W/O' AS ordertype,\n       formatWoNumber(wo_id) AS ordernumber,\n       1 AS sequence,\n       item_number,\n       wo_duedate AS duedate,\n       (wo_duedate < CURRENT_DATE) AS late,\n       (womatl_cost * womatl_qtyreq) AS amount,\n       womatl_qtyreq AS qtyordered,\n       COALESCE(SUM(abs(invhist_invqty)),0) AS qtyreceived,\n       noNeg(womatl_qtyreq - COALESCE(SUM(abs(invhist_invqty)),0)) AS balance,\n       wo_prodnotes AS notes\nFROM womatl\n  JOIN wo ON (wo_id=womatl_wo_id)\n  JOIN itemsite ON (womatl_itemsite_id=itemsite_id)\n  JOIN item ON (itemsite_item_id=item_id)\n  LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n  LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id)\n                          AND (invhist_invqty < 0))\nWHERE ((wo_status<>'C')\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (item_type = 'T'))\nGROUP BY wo_id, wo_duedate, item_number, womatl_qtyreq, womatl_cost, wo_prodnotes\n\n<? if exists("Manufacturing") ?>\nUNION\nSELECT wo_id AS orderid, -1 AS altorderid,\n       'W/O' AS ordertype,\n       formatWoNumber(wo_id) AS ordernumber,\n       1 AS sequence,\n       item_number,\n       wo_duedate AS duedate,\n       (wo_duedate < CURRENT_DATE) AS late,\n       (itemCost(wo_itemsite_id) * wo_qtyord * brddist_stdqtyper) AS amount,\n       (wo_qtyord * brddist_stdqtyper) AS qtyordered,\n       (wo_qtyrcv * brddist_stdqtyper) AS qtyreceived,\n       noNeg((wo_qtyord - wo_qtyrcv) * brddist_stdqtyper) AS balance,\n       wo_prodnotes AS notes\nFROM xtmfg.brddist, wo, itemsite, item\nWHERE ((wo_status<>'C')\n  AND  (brddist_wo_id=wo_id)\n  AND  (wo_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (brddist_itemsite_id=itemsite_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (item_type IN ('C', 'Y')) )\n<? endif ?>\n\nUNION\nSELECT wo_id AS orderid, womatl_id AS altorderid,\n      'W/O' AS ordertype,\n      formatWoNumber(wo_id) AS ordernumber,\n      2 AS sequence,\n      woi.item_number,\n      womatl_duedate AS duedate,\n      FALSE AS late,\n      (itemCost(womatl_itemsite_id) * itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq)) AS amount,\n      itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS qtyordered,\n      itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyiss) AS qtyreceived,\n      itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, (noNeg(womatl_qtyreq - womatl_qtyiss) * -1)) AS balance,\n      wo_prodnotes AS notes\nFROM womatl, wo, itemsite AS wois, item AS woi, itemsite AS womatlis, item AS womatli\nWHERE ((wo_status<>'C')\n  AND  (wo_itemsite_id=wois.itemsite_id)\n  AND  (wois.itemsite_item_id=woi.item_id)\n  AND  (womatlis.itemsite_item_id=womatli.item_id)\n  AND  (womatli.item_type != 'T')\n  AND  (womatl_wo_id=wo_id)\n  AND  (womatlis.itemsite_item_id=<? value("item_id") ?>)\n  AND  (womatlis.itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (womatl_itemsite_id=womatlis.itemsite_id) )\n\nUNION\n-- Special handling for tools\nSELECT wo_id AS orderid, womatl_id AS altorderid,\n      'W/O' AS ordertype,\n      formatWoNumber(wo_id) AS ordernumber,\n      2 AS sequence,\n      woi.item_number,\n      womatl_duedate AS duedate,\n      FALSE AS late,\n      (womatl_cost * itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq)) AS amount,\n      itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS qtyordered,\n      COALESCE(SUM(invhist_invqty),0) AS qtyreceived,\n      (itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, (noNeg(womatl_qtyreq))) - COALESCE(SUM(invhist_invqty),0)) * -1 AS balance,\n      wo_prodnotes AS notes\nFROM itemsite AS wois, item AS woi, itemsite AS womatlis, item AS womatli, wo, womatl\n  LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n  LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id)\n                          AND (invhist_invqty > 0))\nWHERE ((wo_status<>'C')\n  AND  (wo_itemsite_id=wois.itemsite_id)\n  AND  (wois.itemsite_item_id=woi.item_id)\n  AND  (womatlis.itemsite_item_id=womatli.item_id)\n  AND  (womatli.item_type = 'T')\n  AND  (womatl_wo_id=wo_id)\n  AND  (womatlis.itemsite_item_id=<? value("item_id") ?>)\n  AND  (womatlis.itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (womatl_itemsite_id=womatlis.itemsite_id) )\nGROUP BY wo_id, woi.item_number, womatl_id, womatl_duedate, womatlis.itemsite_item_id, womatl_uom_id, womatl_qtyreq, womatl_cost, wo_prodnotes\n\nUNION\nSELECT pohead_id AS orderid, poitem_id AS altorderid,\n      'P/O' AS ordertype,\n      TEXT(pohead_number) AS ordernumber,\n      1 AS sequence,\n      vend_name AS item_number,\n      poitem_duedate AS duedate,\n      (poitem_duedate < CURRENT_DATE) AS late,\n      (poitem_unitprice * poitem_qty_ordered) AS amount,\n      (poitem_qty_ordered * poitem_invvenduomratio) AS qtyordered,\n      (NoNeg(poitem_qty_received - poitem_qty_returned) * poitem_invvenduomratio) AS qtyreceived,\n      (noNeg(poitem_qty_ordered - poitem_qty_received) * poitem_invvenduomratio) AS balance,\n       pohead_comments AS notes\nFROM pohead, vendinfo, poitem, itemsite, item\nWHERE ((vend_id=pohead_vend_id)\n  AND  (poitem_pohead_id=pohead_id)\n  AND  (poitem_status <> 'C')\n  AND  (poitem_itemsite_id=itemsite_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=item_id)\n  AND  (item_id=<? value("item_id") ?>) )\n\nUNION\nSELECT cohead_id AS orderid, coitem_id AS altorderid,\n       'S/O' AS ordertype,\n       TEXT(cohead_number) AS ordernumber,\n       2 AS sequence,\n       cust_name AS item_number,\n       coitem_scheddate AS duedate,\n       (coitem_scheddate < CURRENT_DATE) AS late,\n       (coitem_price * coitem_qtyord) AS amount,\n       (coitem_qtyord * coitem_qty_invuomratio) AS qtyordered,\n       (coitem_qty_invuomratio * (coitem_qtyshipped - coitem_qtyreturned + qtyAtShipping(coitem_id))) AS qtyreceived,\n       (coitem_qty_invuomratio * noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping(coitem_id)) * -1) AS balance,\n       cohead_ordercomments AS notes\nFROM coitem, cohead, custinfo, itemsite, item\nWHERE ((coitem_status='O')\n  AND  (cohead_cust_id=cust_id)\n  AND  (coitem_cohead_id=cohead_id)\n  AND  (coitem_itemsite_id=itemsite_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=item_id)\n  AND  (item_id=<? value("item_id") ?>))\n\n<? if exists("showPlanned") ?>\n<? if exists("showMRPplan") ?>\nUNION\nSELECT planord_id AS orderid, -1 AS altorderid,\n       CASE WHEN (planord_firm) THEN <? value("firmPo") ?> \n \t   ELSE <? value("plannedPo") ?> \n       END AS ordertype,\n       CAST(planord_number AS text) AS ordernumber,\n       1 AS sequence,\n       '' AS item_number,\n       planord_duedate AS duedate,\n       FALSE AS late,\n       (itemCost(planord_itemsite_id) * planord_qty) AS amount,\n       planord_qty AS qtyordered,\n       NULL AS qtyreceived,\n       planord_qty AS balance,\n       planord_comments AS notes\nFROM planord, itemsite\nWHERE ((planord_type='P')\n  AND  (planord_itemsite_id=itemsite_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>) )\n\nUNION\nSELECT planord_id AS orderid, -1 AS altorderid,\n       CASE WHEN (planord_firm) THEN <? value("firmWo") ?> \n\t    ELSE <? value("plannedWo") ?> \n       END AS ordertype,\n       CAST(planord_number AS text) AS ordernumber,\n       1 AS sequence,\n       '' AS item_number,\n       planord_duedate AS duedate,\n       FALSE AS late,\n       (itemCost(planord_itemsite_id) * planord_qty) AS amount,\n       planord_qty AS qtyordered,\n       NULL AS qtyreceived,\n       planord_qty AS balance,\n       planord_comments AS notes\nFROM planord, itemsite\nWHERE ((planord_type='W')\n  AND  (planord_itemsite_id=itemsite_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>) )\n\nUNION\n-- Tools on Planned Work Orders\nSELECT planord_id AS orderid, -1 AS altorderid,\n       CASE WHEN (planord_firm) THEN <? value("firmWo") ?> \n\t    ELSE <? value("plannedWo") ?> \n       END AS ordertype,\n       CAST(planord_number AS text) AS ordernumber,\n       1 AS sequence,\n       item_number,\n       planord_duedate AS duedate,\n       FALSE AS late,\n       (itemCost(planreq_itemsite_id) * planreq_qty) AS amount,\n       planreq_qty AS qtyordered,\n       NULL AS qtyreceived,\n       planreq_qty AS balance,\n       planord_comments AS notes\nFROM planreq\n  JOIN itemsite ON (itemsite_id=planreq_itemsite_id)\n  JOIN item ON (item_id=itemsite_item_id)\n  JOIN planord ON ((planreq_source_id=planord_id)\n              AND (planreq_source='P'))\nWHERE ((itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (item_type='T') )\n\nUNION\nSELECT planord_id AS orderid, -1 AS altorderid,\n       CASE WHEN (planord_firm) THEN <? value("firmTo") ?> \n\t    ELSE <? value("plannedTo") ?> \n       END AS ordertype,\n       CAST(planord_number AS text) AS ordernumber,\n       1 AS sequence,\n       srcwhsinfo.warehous_code || '/' || whsinfo.warehous_code AS item_number,\n       planord_duedate AS duedate,\n       FALSE AS late,\n       (itemCost(planord_itemsite_id) * planord_qty) AS amount,\n       planord_qty AS qtyordered,\n       NULL AS qtyreceived,\n       planord_qty AS balance,\n       planord_comments AS notes\nFROM planord JOIN itemsite ON (itemsite.itemsite_id=planord_itemsite_id)\n             JOIN whsinfo ON (whsinfo.warehous_id=itemsite.itemsite_warehous_id)\n             JOIN itemsite srcitemsite ON (srcitemsite.itemsite_id=planord_supply_itemsite_id)\n             JOIN whsinfo srcwhsinfo ON (srcwhsinfo.warehous_id=srcitemsite.itemsite_warehous_id)\nWHERE ((planord_type='T')\n  AND  (itemsite.itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite.itemsite_item_id=<? value("item_id") ?>) )\n\nUNION\nSELECT planord_id AS orderid, -1 AS altorderid,\n       CASE WHEN (planord_firm) THEN <? value("firmTo") ?> \n\t    ELSE <? value("plannedTo") ?> \n       END AS ordertype,\n       CAST(planord_number AS text) AS ordernumber,\n       1 AS sequence,\n       srcwhsinfo.warehous_code || '/' || whsinfo.warehous_code AS item_number,\n       planord_duedate AS duedate,\n       FALSE AS late,\n       (itemCost(planord_itemsite_id) * planord_qty) AS amount,\n       planord_qty AS qtyordered,\n       NULL AS qtyreceived,\n       (planord_qty * -1) AS balance,\n       planord_comments AS notes\nFROM planord JOIN itemsite ON (itemsite.itemsite_id=planord_itemsite_id)\n             JOIN whsinfo ON (whsinfo.warehous_id=itemsite.itemsite_warehous_id)\n             JOIN itemsite srcitemsite ON (srcitemsite.itemsite_id=planord_supply_itemsite_id)\n             JOIN whsinfo srcwhsinfo ON (srcwhsinfo.warehous_id=srcitemsite.itemsite_warehous_id)\nWHERE ((planord_type='T')\n  AND  (srcitemsite.itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (srcitemsite.itemsite_item_id=<? value("item_id") ?>) )\n\nUNION\nSELECT planreq_id AS orderid, -1 AS altorderid,\n       CASE WHEN (planord_firm) THEN <? value("firmWoReq") ?> \n\t    ELSE <? value("plannedWoReq") ?> \n       END AS ordertype,\n       CAST(planord_number AS text) AS ordernumber,\n       1 AS sequence,\n--get the planned order number for the higher level demand\n             (SELECT item_number\n                FROM item, itemsite\n               WHERE((itemsite_item_id=item_id)\n                 AND (itemsite_id=planord_itemsite_id))\n             ) AS item_number,\n       planord_startdate AS duedate,\n       FALSE AS late,\n       (itemCost(planreq_itemsite_id) * planreq_qty) AS amount,\n       planreq_qty AS f_qtyordered,\n       NULL AS qtyreceived,\n       (planreq_qty * -1) AS balance,\n       planreq_notes AS notes\nFROM planreq, planord, itemsite, item\nWHERE ((planreq_source='P')\n  AND  (planreq_source_id=planord_id)\n  AND  (planreq_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>) )\n<? endif ?>\n\nUNION\nSELECT pr_id AS orderid, -1 AS altorderid,\n       <? value("pr") ?> AS ordertype,\n       CAST(pr_number AS text) AS ordernumber,       \n       1 AS sequence,\n       '' AS item_number,\n       pr_duedate AS duedate,\n       FALSE AS late,\n       (itemCost(pr_itemsite_id) * pr_qtyreq) AS amount,\n       pr_qtyreq AS qtyordered,\n       NULL AS qtyreceived,\n       pr_qtyreq AS balance,\n       pr_releasenote AS notes\nFROM pr, itemsite, item\nWHERE ((pr_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (pr_itemsite_id=itemsite_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>) )\n<? endif ?>\n) AS dummy\n\nORDER BY duedate, sequence;\n\n  admin   2014-10-06      0
101206
 
81      salesHistory    detail   \n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: salesHistory\n-- Name: detail\n-- Notes: \n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       CASE WHEN (COALESCE(cohist_invcnumber, '-1') IN ('', '-1')) THEN  <? value("credit") ?>\n            ELSE cohist_invcnumber\n       END AS invoicenumber,\n<? if exists("isReport") ?>\n       formatDate(cohist_orderdate) AS f_orderdate,\n       formatDate(cohist_invcdate) AS f_invcdate,\n       formatQty(cohist_qtyshipped) AS f_qtyshipped,\n       formatBoolYN(cohist_commissionpaid) AS f_commissionpaid,\n       formatSalesPrice(baseunitprice) AS f_baseunitprice,\n       formatMoney(extprice) AS f_extprice,\n       formatMoney(baseextprice) AS f_baseextprice,\n       formatMoney(extcost) AS f_extcost,\n       formatMoney(margin) AS f_margin,\n       formatPrcnt(marginpercent) AS f_marginpercent,\n       formatMoney(basecommission) AS f_basecommission,\n<? endif ?>\n       <? value("return") ?> AS cohist_invcdate_xtnullrole,\n       0 AS cohist_qtyshipped_xttotalrole,\n       0 AS baseextprice_xttotalrole,\n       0 AS extcost_xttotalrole,\n       0 AS margin_xttotalrole,\n       0 AS basecommission_xttotalrole\n<? if exists("includeMisc") ?>\n  FROM saleshistorymisc\n<? else ?>\n  FROM saleshistory\n<? endif ?>\nWHERE ( (true)\n<? if exists("startDate") ?>\n  AND  (cohist_invcdate >= <? value("startDate") ?>)\n<? endif ?>\n<? if exists("endDate") ?>\n  AND  (cohist_invcdate <= <? value("endDate") ?>)\n<? endif ?>\n<? if exists("shipStartDate") ?>\n  AND  (cohist_shipdate >= <? value("shipStartDate") ?>)\n<? endif ?>\n<? if exists("shipEndDate") ?>\n  AND  (cohist_shipdate <= <? value("shipEndDate") ?>)\n<? endif ?>\n<? if exists("salesrep_id") ?>\n  AND  (cohist_salesrep_id=<? value("salesrep_id") ?>)\n<? endif ?>\n<? if exists("shipto_id") ?>\n  AND  (cohist_shipto_id=<? value("shipto_id") ?>)\n<? endif ?>\n<? if exists("billToName") ?>\n  AND  (UPPER(cohist_billtoname) ~ UPPER(<? value("billToName") ?>))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND  (cohist_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND  (custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND  (custtype_id IN (SELECT DISTINCT custtype_id\n                        FROM custtype\n                        WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("by_custgrp") ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrpitem))\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrpitem\n                   WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n<? endif ?>\n<? if exists("custgrp_pattern") ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrp, custgrpitem\n                   WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                     AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n<? endif ?>\n\n<? if exists("item_id") ?>\n  AND  (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("prodcat_id") ?>\n  AND (prodcat_id=<? value("prodcat_id") ?>)\n<? endif ?>\n<? if exists("prodcat_pattern") ?>\n  AND (prodcat_id IN (SELECT DISTINCT prodcat_id\n                      FROM prodcat\n                      WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? endif ?>\n\n<? if exists("warehous_id") ?>\n  AND  (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("shipzone_id") ?>\n  AND (cohist_shipzone_id=<? value("shipzone_id") ?>)\n<? endif ?>\n<? if exists("saletype_id") ?>\n  AND (cohist_saletype_id=<? value("saletype_id") ?>)\n<? endif ?>\n<? if exists("cohead_id") ?>\n  AND (cohead_id=<? value("cohead_id") ?>)\n<? endif ?>\n      )\nORDER BY cohist_invcdate, itemnumber;\n\n       admin   2014-10-06      0
101207
 
82      salesOrderItems detail   used by dspBacklogByCustomer, dspBacklogByItem, dspBacklogByParameterList, dspBacklogBySalesOrder, dspBookingsByCustomer, dspBookingsByCustomerGroup, dspBookingsByItem, dspBookingsByProductCategory, dspBookingsBySalesRep, dspBookingsByShipTo, dspSalesOrdersByItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: salesOrderItems\n-- Name: detail\n-- Notes: used by dspBacklogByCustomer, dspBacklogByItem, dspBacklogByParameterList, dspBacklogBySalesOrder, dspBookingsByCustomer, dspBookingsByCustomerGroup, dspBookingsByItem, dspBookingsByProductCategory, dspBookingsBySalesRep, dspBookingsByShipTo, dspSalesOrdersByItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n       cohead_id, coitem_id, *, currconcat(cohead_curr_id) AS currAbbr,\n<? if exists("item_id") ?>\n       CASE WHEN xtindentrole = 0 THEN cust_name\n       END AS item_number_qtdisplayrole,\n<? elseif exists("salesrep_id") ?>\n-- no alterations to displayroles\n<? elseif not exists("cohead_id") ?>\n       CASE WHEN xtindentrole = 0 THEN cohead_number\n       END AS coitem_linenumber_qtdisplayrole,\n       CASE WHEN xtindentrole = 0 THEN cust_name\n       END AS item_number_qtdisplayrole,\n <? endif ?>\n       'qty' AS coitem_qtyord_xtnumericrole,\n       'qty' AS coitem_qtyshipped_xtnumericrole,\n       'qty' AS coitem_qtyreturned_xtnumericrole,\n       'qty' AS qtyatshipping_xtnumericrole,\n       'qty' AS qtybalance_xtnumericrole,\n       'qty' AS qtyavailable_xtnumericrole,\n       'salesprice' AS coitem_price_xtnumericrole,\n       'salesprice' AS baseunitprice_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS baseextprice_xtnumericrole,\n       'curr' AS extpricebalance_xtnumericrole,\n       'curr' AS baseextpricebalance_xtnumericrole,\n       0 AS coitem_qtyord_xttotalrole,\n       0 AS coitem_qtyshipped_xttotalrole,\n       0 AS coitem_qtyreturned_xttotalrole,\n       0 AS qtybalance_xttotalrole,\n       0 AS baseextprice_xttotalrole,\n       0 AS baseextpricebalance_xttotalrole\nFROM (\n  <? if not exists("cohead_id") ?> -- get cohead info\n  <? if not exists("item_id") ?>\n  <? if not exists("salesrep_id") ?>\n  SELECT \n         0 AS xtindentrole,\n         -- dummy coitem record\n         -1            AS coitem_id,        NULL::INTEGER AS coitem_cohead_id,\n         -1            AS coitem_linenumber,NULL::INTEGER AS coitem_itemsite_id,\n         NULL::TEXT    AS coitem_status,    NULL::DATE AS coitem_scheddate,\n         getSoSchedDate(cohead_id) AS sort_scheddate,\n         NULL::DATE    AS coitem_promdate,  NULL::NUMERIC AS coitem_qtyord,\n         NULL::NUMERIC AS coitem_unitcost,  NULL::NUMERIC AS coitem_price,\n         NULL::NUMERIC AS coitem_custprice, NULL::NUMERIC AS coitem_qtyshipped,\n         NULL::INTEGER AS coitem_order_id,  NULL::TEXT    AS coitem_memo,\n         NULL::BOOLEAN AS coitem_imported,  NULL::NUMERIC AS coitem_qtyreturned,\n         NULL::TIMESTAMP AS coitem_closedate,\n         NULL::TEXT    AS coitem_custpn,    NULL::TEXT    AS coitem_order_type,\n         NULL::TEXT    AS coitem_close_username,\n         NULL::TIMESTAMP AS coitem_lastupdated,\n         NULL::INTEGER AS coitem_substitute_item_id,\n         NULL::TIMESTAMP AS coitem_created, NULL::TEXT    AS coitem_creator,\n         NULL::NUMERIC AS coitem_prcost,\n         NULL::INTEGER AS coitem_qty_uom_id,\n         NULL::NUMERIC AS coitem_qty_invuomratio,\n         NULL::INTEGER AS coitem_price_uom_id,\n         NULL::NUMERIC AS coitem_price_invuomratio,\n         NULL::BOOLEAN AS coitem_warranty,\n         NULL::INTEGER AS coitem_cos_accnt_id,\n         NULL::NUMERIC AS coitem_qtyreserved,\n         NULL::INTEGER AS coitem_subnumber,\n         cohead.*,\n         cust_number, cust_name,\n         NULL::TEXT AS item_number, NULL::TEXT AS item_descrip1,\n         NULL::TEXT AS itemdescription,\n         NULL::TEXT AS uom_name,\n         NULL::TEXT AS warehous_code,\n         NULL::NUMERIC AS qtyatshipping,\n         NULL::NUMERIC AS qtyavailable,\n         NULL::BOOLEAN AS stockout,\n         NULL::BOOLEAN AS reorder,\n         NULL::NUMERIC AS qtybalance,\n         NULL::NUMERIC AS baseunitprice,\n         NULL::NUMERIC AS extprice,\n         NULL::NUMERIC AS baseextprice,\n         NULL::NUMERIC AS extpricebalance,\n         NULL::NUMERIC AS baseextpricebalance,\n         NULL::TEXT    AS qtyavailable_qtforegroundrole\n\n  FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n              JOIN custinfo ON (cust_id=cohead_cust_id)\n              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n              JOIN site() ON (warehous_id=itemsite_warehous_id)\n              JOIN item ON (item_id=itemsite_item_id)\n              JOIN uom ON (uom_id=coitem_qty_uom_id)\n  WHERE ( (coitem_status<>'X')\n  <? if exists("cohead_id") ?>\n    AND  (coitem_cohead_id=<? value("cohead_id") ?>)\n  <? endif ?>\n  <? if exists("openOnly") ?>\n    AND  (coitem_status<>'C')\n  <? endif ?>\n  <? if exists("startDate") ?>\n    <? if exists("orderByOrderdate") ?>\n    AND  (cohead_orderdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? else ?>\n    AND  (coitem_scheddate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? endif ?>\n  <? endif ?>\n\n  <? if exists("salesrep_id") ?>\n    AND  (cohead_salesrep_id=<? value("salesrep_id") ?>)\n  <? endif ?>\n  <? if exists("shipto_id") ?>\n    AND  (cohead_shipto_id=<? value("shipto_id") ?>)\n  <? endif ?>\n  <? if exists("cust_id") ?>\n    AND  (cohead_cust_id=<? value("cust_id") ?>)\n  <? elseif exists("custtype_id") ?>\n    AND  (cust_custtype_id=<? value("custtype_id") ?>)\n  <? elseif exists("custtype_pattern") ?>\n    AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                               FROM custtype\n                               WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? elseif exists("custgrp") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem))\n  <? elseif exists("custgrp_id") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem\n                     WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n  <? elseif exists("custgrp_pattern") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrp, custgrpitem\n                     WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                       AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n  <? endif ?>\n\n  <? if exists("item_id") ?>\n    AND  (itemsite_item_id=<? value("item_id") ?>)\n  <? elseif exists("prodcat_id") ?>\n    AND (item_prodcat_id=<? value("prodcat_id") ?>)\n  <? elseif exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                             FROM prodcat\n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n  <? endif ?>\n\n  <? if exists("warehous_id") ?>\n    AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n        )\n\n  UNION\n  <? endif ?> -- endif not exists "salesrep_id"\n  <? endif ?> -- endif not exists "item_id"\n  <? endif ?> -- endif not exists "cohead_id"\n\n  SELECT \n         <? if exists("cohead_id") ?> 0\n         <? elseif exists("item_id") ?> 0\n         <? elseif exists("salesrep_id") ?> 0\n         <? else ?> 1 <? endif ?> AS xtindentrole,\n         coitem_id,        coitem_cohead_id,\n         coitem_linenumber,coitem_itemsite_id,\n         coitem_status,    coitem_scheddate,\n         getSoSchedDate(cohead_id) AS sort_scheddate,\n         coitem_promdate,  coitem_qtyord,\n         coitem_unitcost,  coitem_price,\n         coitem_custprice, coitem_qtyshipped,\n         coitem_order_id,  coitem_memo,\n         coitem_imported,  coitem_qtyreturned,\n         coitem_closedate,\n         coitem_custpn,    coitem_order_type,\n         coitem_close_username,\n         coitem_lastupdated,\n         coitem_substitute_item_id,\n         coitem_created,   coitem_creator,\n         coitem_prcost,\n         coitem_qty_uom_id,\n         coitem_qty_invuomratio,\n         coitem_price_uom_id,\n         coitem_price_invuomratio,\n         coitem_warranty,\n         coitem_cos_accnt_id,\n         coitem_qtyreserved,\n         coitem_subnumber,\n         cohead.*,\n         cust_number, cust_name,\n         item_number, item_descrip1, (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n         uom_name,\n         warehous_code,\n         ( SELECT SUM(shipitem_qty)\n             FROM shipitem JOIN shiphead ON ( (shipitem_shiphead_id=shiphead_id) AND (shiphead_order_type='SO') AND (NOT shiphead_shipped) )\n            WHERE (shipitem_orderitem_id=coitem_id) ) AS qtyatshipping,\n         qtyAvailable(itemsite_id, coitem_scheddate) AS qtyavailable,\n         (qtyAvailable(itemsite_id, coitem_scheddate) < 0.0) AS stockout,\n         CASE WHEN (itemsite_useparams) THEN (qtyAvailable(itemsite_id, coitem_scheddate) <= itemsite_reorderlevel)\n              ELSE (qtyAvailable(itemsite_id, coitem_scheddate) <= 0.0)\n         END AS reorder,\n         noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qtybalance,\n         currtobase(cohead_curr_id, coitem_price, cohead_orderdate) AS baseunitprice,\n         round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (coitem_price / coitem_price_invuomratio), 2) AS extprice,\n         round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextprice,\n         round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                     (coitem_price / coitem_price_invuomratio), 2) AS extpricebalance,\n         round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                     (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextpricebalance,\n         CASE WHEN (qtyAvailable(itemsite_id, coitem_scheddate) < 0.0) THEN 'error'\n              WHEN itemsite_useparams AND (qtyAvailable(itemsite_id, coitem_scheddate) <= itemsite_reorderlevel) THEN 'warning'\n              WHEN NOT itemsite_useparams AND (qtyAvailable(itemsite_id, coitem_scheddate) <= 0.0) THEN 'warning'\n         END AS qtyavailable_qtforegroundrole\n\n  FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n              JOIN custinfo ON (cust_id=cohead_cust_id)\n              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n              JOIN site() ON (warehous_id=itemsite_warehous_id)\n              JOIN item ON (item_id=itemsite_item_id)\n              JOIN uom ON (uom_id=coitem_qty_uom_id)\n  WHERE ( (coitem_status<>'X')\n  <? if exists("cohead_id") ?>\n    AND  (coitem_cohead_id=<? value("cohead_id") ?>)\n  <? endif ?>\n  <? if exists("openOnly") ?>\n    AND  (coitem_status<>'C')\n  <? endif ?>\n  <? if exists("startDate") ?>\n    <? if exists("orderByOrderdate") ?>\n    AND  (cohead_orderdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? else ?>\n    AND  (coitem_scheddate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? endif ?>\n  <? endif ?>\n\n  <? if exists("salesrep_id") ?>\n    AND  (cohead_salesrep_id=<? value("salesrep_id") ?>)\n  <? endif ?>\n  <? if exists("shipto_id") ?>\n    AND  (cohead_shipto_id=<? value("shipto_id") ?>)\n  <? endif ?>\n  <? if exists("cust_id") ?>\n    AND  (cohead_cust_id=<? value("cust_id") ?>)\n  <? elseif exists("custtype_id") ?>\n    AND  (cust_custtype_id=<? value("custtype_id") ?>)\n  <? elseif exists("custtype_pattern") ?>\n    AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                               FROM custtype\n                               WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? elseif exists("custgrp") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem))\n  <? elseif exists("custgrp_id") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem\n                     WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n  <? elseif exists("custgrp_pattern") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrp, custgrpitem\n                     WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                       AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n  <? endif ?>\n\n  <? if exists("item_id") ?>\n    AND  (itemsite_item_id=<? value("item_id") ?>)\n  <? elseif exists("prodcat_id") ?>\n    AND (item_prodcat_id=<? value("prodcat_id") ?>)\n  <? elseif exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                             FROM prodcat\n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n  <? endif ?>\n\n  <? if exists("warehous_id") ?>\n    AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n        )\n\n) AS dummy\n\n<? if exists("orderByScheddate") ?>\n  ORDER BY sort_scheddate, cohead_number, coitem_linenumber\n<? elseif exists("orderByOrderdate") ?>\n  ORDER BY cohead_orderdate, cohead_number, coitem_linenumber\n<? else ?>\n  ORDER BY cohead_number, coitem_linenumber\n<? endif ?>\n;\n    admin   2014-10-06      0
101208
 
281     salesOrderStatus        detail   used by dspSalesOrderStatus\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: salesOrderStatus\n-- Name: detail\n-- Notes: used by dspSalesOrderStatus\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT coitem_id, coitem_linenumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       warehous_code,\n       coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned,\n       SUM(COALESCE(cobill_qty, 0)) AS invoiced,\n       noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS balance,\n       CASE WHEN (coitem_status='C') THEN coitem_closedate END AS closedate,\n       CASE WHEN (coitem_status='C') THEN coitem_close_username END AS closeuser,\n       CASE WHEN (coitem_order_id=-1) THEN ''\n            WHEN (coitem_order_type='W') THEN ( SELECT (formatWoNumber(wo_id) || '/' || wo_status)\n                                                FROM wo\n                                                WHERE (wo_id=coitem_order_id) )\n         ELSE ''\n       END AS childinfo,\n       'qty' AS coitem_qtyord_xtnumericrole,\n       'qty' AS coitem_qtyshipped_xtnumericrole,\n       'qty' AS coitem_qtyreturned_xtnumericrole,\n       'qty' AS invoiced_xtnumericrole,\n       'qty' AS balance_xtnumericrole \nFROM itemsite, item, whsinfo, coitem LEFT OUTER JOIN\n     cobill ON (coitem_id=cobill_coitem_id AND\n                cobill_invcitem_id IS NOT NULL)\nWHERE ( (coitem_itemsite_id=itemsite_id)\n    AND (coitem_status <> 'X')\n    AND (itemsite_item_id=item_id)\n    AND (itemsite_warehous_id=warehous_id)\n    AND (coitem_cohead_id=<? value("sohead_id") ?>) ) \nGROUP BY coitem_id, coitem_linenumber, item_number, \n         item_descrip1, item_descrip2, warehous_code, \n         coitem_qtyord, coitem_qtyshipped, coitem_status, \n         coitem_closedate, coitem_close_username, \n         coitem_qtyreturned, coitem_order_id, \n         coitem_order_type \nORDER BY coitem_linenumber;\n      admin   2014-10-06      0
101209
 
83      salesOrders     detail   used by dspSalesOrdersByCustomer, dspSalesOrdersByCustomerPO, dspSalesOrdersByParameterList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: salesOrders\n-- Name: detail\n-- Notes: used by dspSalesOrdersByCustomer, dspSalesOrdersByCustomerPO, dspSalesOrdersByParameterList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohead_id, cust_id,\n       cohead.*,\n       cust_number, cust_name,\n       getSoSchedDate(cohead_id) AS min_scheddate,\n       CASE\n         WHEN ( (SELECT COUNT(*)\n                   FROM coitem\n                  WHERE ((coitem_status<>'X') AND (coitem_cohead_id=cohead_id))) = 0) THEN <? value("noLines") ?>\n         WHEN ( ( (SELECT COUNT(*)\n                     FROM coitem\n                    WHERE ((coitem_status='C')\n                      AND (coitem_cohead_id=cohead_id))) > 0)\n                      AND ( (SELECT COUNT(*)\n                               FROM coitem\n                              WHERE ((coitem_status NOT IN ('C','X'))\n                                AND (coitem_cohead_id=cohead_id))) = 0) ) THEN <? value("closed") ?>\n         WHEN ( ( (SELECT COUNT(*)\n                     FROM coitem\n                    WHERE ((coitem_status='C')\n                      AND (coitem_cohead_id=cohead_id))) = 0)\n                      AND ( (SELECT COUNT(*)\n                               FROM coitem\n                              WHERE ((coitem_status NOT IN ('C','X'))\n                                AND (coitem_cohead_id=cohead_id))) > 0) ) THEN <? value("open") ?>\n         ELSE <? value("partial") ?>\n       END AS order_status\nFROM cohead JOIN custinfo ON (cust_id=cohead_cust_id)\nWHERE ( (1=1)\n<? if exists("cust_id") ?>\n  AND  (cohead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND  (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND  (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("poNumber") ?>\n  AND  (cohead_custponumber~*<? value("poNumber") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND  (cohead_orderdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n  AND   ((SELECT COUNT(*)\n         FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n                     JOIN site() ON (warehous_id=itemsite_warehous_id)\n        WHERE (coitem_cohead_id=cohead_id)) > 0) )\n<? if exists("orderByCust") ?>\n  ORDER BY cust_number, cohead_number;\n<? else ?>\nORDER BY cohead_number;\n<? endif ?>\n\n       admin   2014-10-06      0
101210
 
297     trialBalances   detail   used by dspTrialBalances\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: trialBalances\n-- Name: detail\n-- Notes: used by dspTrialBalances\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT accnt_id, period_id, accnt_descrip, trialbal_dirty,\n      period_start, period_end,\n       formatGLAccount(accnt_id) AS account,\n      (trialbal_debits) AS debits,\n       (trialbal_credits) AS credits,\n       trialbal_beginning AS beginning,\n       trialbal_ending AS ending,\n       (trialbal_debits - trialbal_credits) AS diff,\n       CASE WHEN ((trialbal_beginning*-1.0)<0.0) THEN 'CR' END AS beginningsense,\n       CASE WHEN ((trialbal_ending*-1.0)<0.0) THEN 'CR' END AS endingsense,\n       CASE WHEN ((trialbal_debits - trialbal_credits)<0.0) THEN 'CR' END AS diffsense,\n       'curr' AS beginning_xtnumericrole,\n       'curr' AS debits_xtnumericrole,\n       'curr' AS credits_xtnumericrole,\n       'curr' AS ending_xtnumericrole,\n       'curr' AS diff_xtnumericrole,\n       0 AS beginning_xttotalrole,\n       0 AS debits_xttotalrole,\n       0 AS credits_xttotalrole,\n       0 AS ending_xttotalrole,\n       0 AS diff_xttotalrole,\n       CASE WHEN (trialbal_beginning < 0.0) THEN ABS(trialbal_beginning) END AS beginning_qtdisplayrole,\n       CASE WHEN (trialbal_ending < 0.0) THEN ABS(trialbal_ending) END AS ending_qtdisplayrole,\n       CASE WHEN ((trialbal_debits - trialbal_credits) < 0.0) THEN ABS(trialbal_debits - trialbal_credits) END AS diff_qtdisplayrole,\n       CASE WHEN (trialbal_dirty) THEN 'warning' END AS ending_qtforegroundrole\nFROM trialbal, accnt, period\n<? if exists("company_id") ?>\n   ,company\n<? endif ?>\nWHERE ((trialbal_accnt_id=accnt_id)\n   AND (trialbal_period_id=period_id)\n<? if exists("accnt_id") ?>\n   AND (trialbal_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n<? if exists("company_id") ?>\n   AND (accnt_company=company_number)\n   AND (company_id=<? value("company_id") ?>)\n<? endif ?>\n<? if exists("period_id") ?>\n   AND (period_id=<? value("period_id") ?>)\n<? endif ?>\n<? if not exists("showZero") ?>\n   AND (abs(trialbal_beginning)+abs(trialbal_ending)+abs(trialbal_debits)+abs(trialbal_credits) > 0)\n<? endif ?>\n      )\nORDER BY period_start, formatGLAccount(accnt_id);\n       admin   2014-10-06      0
101211
 
478     saletype        table    maintain saletype table\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: saletype\n-- Name: table\n-- Notes: maintain saletype table\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("ViewMode") ?>\n  SELECT *\n    FROM saletype\n   WHERE true\n  <? if exists("saletype_id") ?>\n    AND (saletype_id=<? value("saletype_id") ?>) \n  <? endif ?>\n  <? if exists("saletype_code") ?>\n    AND (UPPER(saletype_code)=UPPER(<? value("saletype_code") ?>)) \n  <? endif ?>\n  ORDER BY saletype_code;\n\n<? elseif exists("NewMode") ?>\n  INSERT INTO saletype\n    ( saletype_code,\n      saletype_descr,\n      saletype_active )\n  VALUES\n    ( UPPER(<? value("saletype_code") ?>),\n      <? value("saletype_descr") ?>,\n      <? value("saletype_active") ?> )\n  RETURNING saletype_id;\n\n<? elseif exists("EditMode") ?>\n  UPDATE saletype\n    SET saletype_code=UPPER(<? value("saletype_code") ?>),\n        saletype_descr=<? value("saletype_descr") ?>,\n        saletype_active=<? value("saletype_active") ?>\n  WHERE (saletype_id=<? value("saletype_id") ?>);\n\n<? elseif exists("DeleteMode") ?>\n  DELETE FROM saletype WHERE saletype_id=<? value("saletype_id") ?>;\n\n<? elseif exists("DeleteUnusedMode") ?>\n  SELECT deleteUnusedSaleTypes() AS result;\n\n<? else ?>\n  RAISE EXCEPTION 'saletype invalid mode';\n<? endif ?>\n        admin   2014-10-06      0
101212
 
84      schedule        plannedorders    used by dpsPlannedOrdersByItem, dspPlannedOrdersByPlannerCode, dspPlannedRevenueExpensesByPlannerCode\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: schedule\n-- Name:  plannedorders\n-- Notes: used by dpsPlannedOrdersByItem, dspPlannedOrdersByPlannerCode, dspPlannedRevenueExpensesByPlannerCode\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n SELECT *,\n        plorevenue - plocost AS profit,\n        formatMoney(plorevenue - plocost) AS f_profit,\n        CASE WHEN plocost > plorevenue THEN 'error'\n        END AS plorevenue_xtforegroundrole,\n        CASE WHEN (planord_firm) THEN 'emphasis'\n        END AS qtforegroundrole,\n        'qty' AS planord_qty_xtnumericrole,\n        'curr' AS plocost_xtnumericrole,\n        'curr' AS plorevenue_xtnumericrole,\n        'curr' AS profit_xtnumericrole,\n        0 AS plocost_xttotalrole,\n        0 AS plorevenue_xttotalrole,\n        0 AS profit_xttotalrole\n FROM (\n SELECT planord_id, planord_itemsite_id,\n        planord.*,\n        (select plancode_code from plancode where plancode_id = itemsite.itemsite_plancode_id) as plancode,\n        formatPloNumber(planord_id) AS ordernum,\n        CASE WHEN (planord_type='P') THEN 'P/O'\n             WHEN (planord_type='W') THEN 'W/O'\n             WHEN (planord_type='T') THEN 'T/O'\n             ELSE '?'\n        END AS ordtype,\n        formatDate(planord_duedate) AS f_duedate,\n        formatDate(planord_startdate) AS f_startdate,\n        formatQty(planord_qty) AS f_qty,\n        formatboolYN(planord_firm) AS f_firm,\n        whsinfo.warehous_code AS warehous_code,\n        supplywhsinfo.warehous_code AS supply_warehous_code,\n        item_number,\n        (item_descrip1 || ' ' || item_descrip2) AS item_descrip,\n        firstline(planord_comments) AS comments,\n        uom_name,\n        (classcode_code || '-' || classcode_descrip) AS f_classcode,\n <? if exists("useActualCost") ?>\n        (actcost(item_id) * planord_qty)\n <? elseif exists("useStandardCost") ?>\n        (stdcost(item_id) * planord_qty)\n <? else ?>\n        0\n <? endif ?> AS plocost,\n <? if exists("useListPrice") ?>\n        (item_listprice * planord_qty)\n <? elseif exists("useAveragePrice") ?>\n        (CASE WHEN(averageSalesPrice(itemsite.itemsite_id,\n                                <? value("startEvalDate") ?>,\n                                <? value("endEvalDate") ?>)=0)\n                                THEN item_listprice\n              ELSE averageSalesPrice(itemsite.itemsite_id,\n                                <? value("startEvalDate") ?>,\n                                <? value("endEvalDate") ?>)\n              END * planord_qty)\n <? else ?>\n         0\n <? endif ?> AS plorevenue,\n <? if exists("useActualCost") ?>\n        formatMoney(actcost(item_id) * planord_qty)\n <? elseif exists("useStandardCost") ?>\n        formatMoney(stdcost(item_id) * planord_qty)\n <? else ?>\n        formatMoney(0)\n <? endif ?> AS f_plocost,\n <? if exists("useListPrice") ?>\n        formatMoney(item_listprice * planord_qty)\n <? elseif exists("useAveragePrice") ?>\n        formatMoney(CASE WHEN(averageSalesPrice(itemsite.itemsite_id,\n                                                <? value("startEvalDate") ?>,\n                                                <? value("endEvalDate") ?>)=0)\n                                 THEN item_listprice\n                         ELSE averageSalesPrice(itemsite.itemsite_id,\n                                                <? value("startEvalDate") ?>,\n                                                <? value("endEvalDate") ?>)\n                    END * planord_qty)\n <? else ?>\n         formatMoney(0)\n <? endif ?> AS f_plorevenue\n FROM planord JOIN itemsite ON (planord_itemsite_id=itemsite.itemsite_id)\n              JOIN whsinfo ON (itemsite.itemsite_warehous_id=whsinfo.warehous_id)\n              JOIN item ON (itemsite.itemsite_item_id=item_id)\n              JOIN uom ON (item_inv_uom_id=uom_id)\n              LEFT OUTER JOIN classcode ON (classcode_id=item_classcode_id)\n              LEFT OUTER JOIN itemsite supplyitemsite ON (planord_supply_itemsite_id=supplyitemsite.itemsite_id)\n              LEFT OUTER JOIN whsinfo supplywhsinfo ON (supplyitemsite.itemsite_warehous_id=supplywhsinfo.warehous_id)\n <? if exists("itemgrp_id") ?>\n              JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n              JOIN itemgrp ON (itemgrp_id=itemgrpitem_itemgrp_id AND itemgrp_id=<? value("itemgrp_id") ?>)\n <? endif ?>\n WHERE (TRUE\n <? if exists("item_id") ?>\n    AND (itemsite.itemsite_item_id=<? value("item_id") ?>)\n <? endif ?>\n <? if exists("classcode_id") ?>\n    AND (item.item_classcode_id=<? value("classcode_id") ?>)\n <? endif ?>\n <? if exists("plancode_id") ?>\n    AND (itemsite.itemsite_plancode_id=<? value("plancode_id") ?>)\n <? elseif exists("plancode_pattern") ?>\n    AND (itemsite.itemsite_plancode_id IN (SELECT plancode_id\n                                           FROM plancode\n                                           WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n <? endif ?>\n <? if exists("warehous_id") ?>\n    AND (itemsite.itemsite_warehous_id=<? value("warehous_id") ?>)\n <? endif ?>\n <? if exists("startDate") ?>\n    AND (planord_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n <? endif ?>\n <? if exists("soldOnly") ?>\n    AND (item_sold)\n <? endif ?>\n <? if exists("type_list") ?>\n    AND (\n   <? foreach("type_list") ?>\n    (planord_type=<? value("type_list") ?>) OR\n   <? endforeach ?>\n    FALSE )\n <? endif ?>\n  ) ) AS data\n ORDER BY planord_duedate, item_number;\n        admin   2014-10-06      0
101213
 
453     scripts detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: scripts\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists('byPackage') ?>\nSELECT script_id, script_name, script_enabled,\n       firstline(script_notes) AS script_notes, script_order,\n       CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n       CASE nspname WHEN 'public' THEN 0\n                                  ELSE 1 END AS xtindentrole,\n       script_notes AS script_notes_qttooltiprole\n  FROM script\n  JOIN pg_class     ON (script.tableoid=pg_class.oid)\n  JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n UNION \nSELECT -1, pkghead_name, NULL,\n       firstline(pkghead_descrip), NULL,\n       pkghead_name, 0, pkghead_descrip \n  FROM script, pg_class, pg_namespace\n     RIGHT OUTER JOIN pkghead ON (nspname=pkghead_name)\n   WHERE ((script.tableoid=pg_class.oid)\n     AND  (relnamespace=pg_namespace.oid))\n   ORDER BY pkgname, xtindentrole, script_name, script_order, script_id;\n<? else ?>\nSELECT script_id, script_name, script_enabled,\n       firstline(script_notes) AS script_notes, script_order,\n       CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n       script_notes AS script_notes_qttooltiprole\n  FROM script\n  JOIN pg_class     ON (script.tableoid=pg_class.oid)\n  JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nORDER BY script_name, script_order, script_id;\n<? endif ?>\n       admin   2014-10-06      0
101214
 
131     selectPayments  applyallcredits  used by selectPayments\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: selectPayments\n-- Name: applyallcredits\n-- Notes: used by selectPayments\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT applyapcredits(vend_id) AS result\nFROM vendinfo\nWHERE ((TRUE)\n<? if exists("vend_id") ?>\n   AND (vend_id = <? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n   AND (vend_vendtype_id = <? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n   AND (vend_vendtype_id IN (SELECT vendtype_id\n                             FROM vendtype\n                             WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n      );\n     admin   2014-10-06      0
101215
 
85      shipments       detail   used by dspShipmentsByDate, dspShipmentsBySalesOrder, dspShipmentsByShipment\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: shipments\n-- Name: detail\n-- Notes: used by dspShipmentsByDate, dspShipmentsBySalesOrder, dspShipmentsByShipment\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT shiphead_id, lineitem_id,\n       CASE WHEN (level=0) THEN order_number\n            ELSE item_number\n       END AS order_item,\n       CASE WHEN (level=0) THEN customer\n            ELSE itemdescription\n       END AS cust_desc,\n       shiphead_order_type,\n       shiphead_number, \n       order_number, \n       customer,\n       shiphead_shipdate,\n       formatDate(shiphead_shipdate) AS f_shipdate,\n       shiphead_tracknum,\n       shiphead_freight,\n       freight_curr_abbr,\n       linenumber,\n       item_number,\n       itemdescription,\n       warehous_code,\n       qtyord,\n       formatQty(qtyord) AS f_qtyord,\n       qtyshipped,\n       formatQty(qtyshipped) AS f_qtyshipped,\n       notes,\n       'qty' AS qtyord_xtnumericrole,\n       'qty' AS qtyshipped_xtnumericrole,\n       'curr' AS shiphead_freight_xtnumericrole,\n       CASE WHEN (COALESCE(linenumber, 0) = 0) THEN '' END AS linenumber_qtdisplayrole,\n       CASE WHEN (COALESCE(qtyord, 0) = 0) THEN '' END AS qtyord_qtdisplayrole,\n       CASE WHEN (COALESCE(qtyshipped, 0) = 0) THEN '' END AS qtyshipped_qtdisplayrole,\n       CASE WHEN (COALESCE(shiphead_freight, 0) = 0) THEN '' END AS shiphead_freight_qtdisplayrole,\n       level AS xtindentrole\nFROM (\nSELECT DISTINCT\n       shiphead_id, -1 AS lineitem_id, cohead_number AS sortkey1, shiphead_number AS sortkey2, 0 AS level,\n       shiphead_order_type,\n       shiphead_number,\n       cohead_number AS order_number, \n       (cust_number || '-' || cust_name) AS customer,\n       shiphead_shipdate,\n       shiphead_tracknum,\n       shiphead_freight,\n       currConcat(shiphead_freight_curr_id) AS freight_curr_abbr, \n       0 AS linenumber, '' AS item_number,\n       '' AS itemdescription,\n       '' AS warehous_code,\n       0 AS qtyord,\n       0 AS qtyshipped,\n       firstline(shiphead_notes) AS notes\nFROM shiphead JOIN cohead ON (cohead_id=shiphead_order_id)\n              JOIN custinfo ON (cust_id=cohead_cust_id)\n<? if exists("warehous_id") ?>\n              JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n              JOIN coitem ON (coitem_id=shipitem_orderitem_id)\n              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n<? endif ?>\nWHERE ( (shiphead_order_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='SO')\n<? if exists("startDate") ?>\n AND (shiphead_shipdate BETWEEN <? value("startDate") ?> and <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("sohead_id") ?>\n AND (cohead_id = <? value("sohead_id") ?>)\n<? endif ?>\n<? if exists("shiphead_id") ?>\n AND (shiphead_id = <? value("shiphead_id") ?>)\n<? endif ?>\n      ) \nUNION\nSELECT shiphead_id, coitem_id AS lineitem_id, cohead_number AS sortkey1, shiphead_number AS sortkey2, 1 AS level,\n       '' AS shiphead_order_type,\n       '' AS shiphead_number,\n       '' AS order_number, \n       '' AS customer,\n       CAST(NULL AS DATE) AS shiphead_shipdate,\n       '' AS shiphead_tracknum,\n       0 AS shiphead_freight,\n       '' AS freight_curr_abbr, \n       coitem_linenumber AS linenumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n       warehous_code,\n       coitem_qtyord AS qtyord,\n       SUM(shipitem_qty) AS qtyshipped,\n       '' AS notes\nFROM shipitem, shiphead, coitem, cohead, custinfo, itemsite, item, whsinfo\nWHERE ( (shipitem_shiphead_id=shiphead_id)\n AND (shipitem_orderitem_id=coitem_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (coitem_status <> 'X')\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (shiphead_order_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='SO')\n<? if exists("startDate") ?>\n AND (shiphead_shipdate BETWEEN <? value("startDate") ?> and <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("sohead_id") ?>\n AND (cohead_id = <? value("sohead_id") ?>)\n<? endif ?>\n<? if exists("shiphead_id") ?>\n AND (shiphead_id = <? value("shiphead_id") ?>)\n<? endif ?>\n      ) \nGROUP BY shiphead_id, coitem_id, shiphead_order_type, shiphead_number,\n         cohead_number, cust_number, cust_name, shiphead_shipdate,\n         coitem_linenumber, item_number, item_descrip1, item_descrip2,\n         warehous_code, shiphead_tracknum, coitem_qtyord, \n         shiphead_freight, shiphead_freight_curr_id \n<? if exists("MultiWhs") ?>\nUNION\nSELECT shiphead_id, -1 AS lineitem_id, tohead_number AS sortkey1, shiphead_number AS sortkey2, 0 AS level,\n       shiphead_order_type,\n       shiphead_number,\n       tohead_number AS order_number, \n       tohead_destname AS customer,\n       shiphead_shipdate,\n       shiphead_tracknum,\n       shiphead_freight,\n       currConcat(shiphead_freight_curr_id) AS freight_curr_abbr, \n       0 AS linenumber, '' AS item_number,\n       '' AS itemdescription,\n       '' AS warehous_code,\n       0 AS qtyord,\n       0 AS qtyshipped,\n       firstline(shiphead_notes) AS notes\nFROM shiphead, tohead \nWHERE ( (shiphead_order_id=tohead_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='TO')\n<? if exists("startDate") ?>\n AND (shiphead_shipdate BETWEEN <? value("startDate") ?> and <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (tohead_src_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("tohead_id") ?>\n AND (tohead_id = <? value("tohead_id") ?>)\n<? endif ?>\n<? if exists("shiphead_id") ?>\n AND (shiphead_id = <? value("shiphead_id") ?>)\n<? endif ?>\n      ) \nUNION\nSELECT shiphead_id, toitem_id AS lineitem_id, tohead_number AS sortkey1, shiphead_number AS sortkey2, 1 AS level,\n       '' AS shiphead_order_type,\n       '' AS shiphead_number,\n       '' AS order_number, \n       '' AS customer,\n       CAST(NULL AS DATE) AS shiphead_shipdate,\n       '' AS shiphead_tracknum,\n       0 AS shiphead_freight,\n       '' AS freight_curr_abbr, \n       toitem_linenumber AS linenumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n       tohead_srcname AS warehous_code,\n       toitem_qty_ordered AS qtyord,\n       SUM(shipitem_qty) AS qtyshipped,\n       '' AS notes\nFROM shipitem, shiphead, toitem, tohead, item \nWHERE ( (shipitem_shiphead_id=shiphead_id)\n AND (shipitem_orderitem_id=toitem_id)\n AND (toitem_status <> 'X')\n AND (toitem_item_id=item_id)\n AND (shiphead_order_id=tohead_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='TO')\n<? if exists("startDate") ?>\n AND (shiphead_shipdate BETWEEN <? value("startDate") ?> and <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (tohead_src_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("tohead_id") ?>\n AND (tohead_id = <? value("tohead_id") ?>)\n<? endif ?>\n<? if exists("shiphead_id") ?>\n AND (shiphead_id = <? value("shiphead_id") ?>)\n<? endif ?>\n      ) \nGROUP BY shiphead_id, toitem_id, shiphead_order_type, shiphead_number,\n         tohead_number, shiphead_shipdate,\n         toitem_linenumber, item_number, item_descrip1, item_descrip2,\n         tohead_srcname, shiphead_tracknum, toitem_qty_ordered, \n         shiphead_freight, shiphead_freight_curr_id, notes\n<? endif ?>\n   ) AS data\nORDER BY sortkey1, sortkey2, level, linenumber DESC;\n     admin   2014-10-06      0
101216
 
86      shippingForm    shipment         used by printShippingForm\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: shippingForm\n-- Name: shipment\n-- Notes: used by printShippingForm\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohead_id AS order_id, cohead_shiptoname AS shipto, \n       cohead_shiptoaddress1 AS addr1, shiphead_order_type, \n       shiphead_id, shiphead_shipchrg_id, shiphead_shipped, \n\tCOALESCE(shiphead_shipform_id, cohead_shipform_id) AS shipform_id \nFROM cohead, shiphead \nWHERE ((cohead_id=shiphead_order_id)\n  AND  (shiphead_order_type='SO')\n  AND  (shiphead_id=<? value("shiphead_id") ?> )\n<? if exists("sohead_id") ?>\n  AND  (cohead_id=<? value("sohead_id") ?> )\n<? endif ?>\n) \n<? if exists("MultiWhs") ?>\nUNION \nSELECT tohead_id AS order_id, tohead_destname AS shipto, \n       tohead_destaddress1 AS addr1, shiphead_order_type, \n       shiphead_id, shiphead_shipchrg_id, shiphead_shipped, \n\tCOALESCE(shiphead_shipform_id, tohead_shipform_id) AS shipform_id \nFROM tohead, shiphead \nWHERE ((tohead_id=shiphead_order_id)\n  AND  (shiphead_order_type='TO')\n  AND  (shiphead_id=<? value("shiphead_id") ?> )\n<? if exists("tohead_id") ?>\n  AND  (tohead_id=<? value("tohead_id") ?> )\n<? endif ?>\n) \nORDER BY shiphead_shipped \n<? endif ?>\nLIMIT 1;\n   admin   2014-10-06      0
101217
 
282     slowMovingInventoryByClassCode  detail   used by dspSlowMovingInventoryByClassCode\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: slowMovingInventoryByClassCode\n-- Name: detail\n-- Notes: used by dspSlowMovingInventoryByClassCode\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, warehous_code, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n       itemsite_qtyonhand, itemsite_datelastused, cost,\n       noNeg(cost * itemsite_qtyonhand) AS value,\n       CASE WHEN (COALESCE(itemsite_datelastused, startOfTime()) <= startOfTime()) THEN 'N/A'\n       END AS itemsite_datelastused_qtdisplayrole,\n       'qty' AS itemsite_qtyonhand_xtnumericrole,\n       'cost' AS cost_xtnumericrole,\n       'curr' AS value_xtnumericrole,\n       0 AS itemsite_qtyonhand_xttotalrole,\n       0 AS value_xttotalrole\nFROM ( SELECT itemsite_id, warehous_code, item_number,\n              item_descrip1, item_descrip2, uom_name,\n              itemsite_qtyonhand, itemsite_datelastused,\n            <? if exists("useActualCosts") ?>\n              actcost(itemsite_item_id) \n            <? else ?>\n              stdcost(itemsite_item_id) \n            <? endif ?> AS cost \n       FROM itemsite, item, whsinfo, uom\n       WHERE ((itemsite_item_id=item_id)\n          AND (item_inv_uom_id=uom_id)\n          AND (itemsite_warehous_id=warehous_id)\n          AND (itemsite_active)\n          AND (itemsite_datelastused < <? value("cutoffDate") ?>)\n        <? if exists("warehous_id") ?>\n          AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n        <? endif ?>\n        <? if exists("classcode_id") ?>\n          AND (item_classcode_id=<? value("classcode_id") ?>)\n        <? elseif exists("classcode_pattern") ?>\n          AND (item_classcode_id IN (SELECT classcode_id FROM classcode WHERE classcode_code ~ <? value("classcode_pattern") ?>))\n        <? endif ?>\n              )\n     ) AS data \nORDER BY warehous_code, \n     <? if exists("sortByItem") ?>\n       item_number\n     <? elseif exists("sortByDate") ?>\n       itemsite_datelastused\n     <? else ?>\n       noNeg(cost * itemsite_qtyonhand) DESC\n     <? endif ?>\n;\n admin   2014-10-06      0
101218
 
283     standardJournalHistory  detail   used by dspStandardJournalHistory\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: standardJournalHistory\n-- Name: detail\n-- Notes: used by dspStandardJournalHistory\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_sequence, gltrans_id,\n       sortdate, sortdoc, level, gltrans_amount,\n       gltrans_date, gltrans_journalnumber, gltrans_posted,\n       gltrans_docnumber, account,\n       debit, credit,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       CASE WHEN (debit = 0) THEN '' END AS debit_qtdisplayrole,\n       CASE WHEN (credit = 0) THEN '' END AS credit_qtdisplayrole,\n       level AS xtindentrole \nFROM (SELECT DISTINCT gltrans_sequence, -1 AS gltrans_id,\n             gltrans_date AS sortdate, gltrans_docnumber AS sortdoc, 0 AS level, 0 AS gltrans_amount,\n             gltrans_date, gltrans_journalnumber, gltrans_posted,\n             NULL AS gltrans_docnumber,\n             NULL AS account,\n             0 AS debit, 0 AS credit\n      FROM gltrans, accnt \n      WHERE ( (gltrans_accnt_id=accnt_id)\n          AND (NOT gltrans_deleted) \n          AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n          AND (gltrans_doctype='ST') ) \n      UNION \n      SELECT DISTINCT gltrans_sequence, -1 AS gltrans_id,\n             gltrans_date AS sortdate, gltrans_docnumber AS sortdoc, 1 AS level, 0 AS gltrans_amount,\n             CAST(NULL AS DATE) AS gltrans_date, CAST(NULL AS INTEGER) AS gltrans_journalnumber, \n             CAST(NULL AS BOOLEAN) AS gltrans_posted,\n             CASE WHEN (COALESCE(gltrans_docnumber, '') = '') THEN 'Unnamed'\n               ELSE gltrans_docnumber\n             END AS gltrans_docnumber,\n             NULL AS account,\n             0 AS debit, 0 AS credit \n      FROM gltrans, accnt \n      WHERE ( (gltrans_accnt_id=accnt_id)\n          AND (NOT gltrans_deleted)\n          AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n          AND (gltrans_doctype='ST') ) \n      UNION \n      SELECT gltrans_sequence, gltrans_id,\n             gltrans_date AS sortdate, gltrans_docnumber AS sortdoc, 2 AS level, gltrans_amount,\n             CAST(NULL AS DATE) AS gltrans_date, CAST(NULL AS INTEGER) AS gltrans_journalnumber,\n             CAST(NULL AS BOOLEAN) AS gltrans_posted,\n             NULL AS gltrans_docnumber,\n             (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n             CASE WHEN (gltrans_amount < 0) THEN (gltrans_amount * -1)\n             END AS debit,\n             CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n             END AS credit \n      FROM gltrans, accnt \n      WHERE ( (gltrans_accnt_id=accnt_id)\n          AND (NOT gltrans_deleted) \n          AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n          AND (gltrans_doctype='ST') ) \n      ) AS data \nORDER BY sortdate, gltrans_sequence, sortdoc, level, gltrans_amount;\n  admin   2014-10-06      0
101219
 
285     substituteAvailability  detail   used by dspSubstituteAvailabilityByItem\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: substituteAvailability\n-- Name: detail\n-- Notes: used by dspSubstituteAvailabilityByItem\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT s_itemsite_id, warehous_code, item_number, itemdescrip,\n       availableqoh, reorderlevel, leadtime, itemsub_rank,\n       allocated, ordered, available,\n       'qty' AS availableqoh_xtnumericrole,\n       'qty' AS allocated_xtnumericrole,\n       'qty' AS ordered_xtnumericrole,\n       'qty' AS reorderlevel_xtnumericrole,\n       'qty' AS available_xtnumericrole,\n       CASE WHEN (reorderlevel >= available) THEN 'error' END AS available_qtforegroundrole\nFROM (SELECT sub.itemsite_id AS s_itemsite_id,\n             warehous_code, item_number,\n             (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n<? if exists("normalize") ?>\n             (qtyAvailable(sub.itemsite_id) * itemsub_uomratio) AS availableqoh,\n             (CASE WHEN(sub.itemsite_useparams)\n                   THEN sub.itemsite_reorderlevel\n                ELSE 0.0\n             END * itemsub_uomratio) AS reorderlevel,\n             sub.itemsite_leadtime AS leadtime, itemsub_rank,\n<? else ?>\n             (qtyAvailable(sub.itemsite_id)) AS availableqoh,\n             CASE WHEN(sub.itemsite_useparams) THEN sub.itemsite_reorderlevel\n               ELSE 0.0\n             END AS reorderlevel,\n             sub.itemsite_leadtime AS leadtime, itemsub_rank,\n<? endif ?>\n<? if exists("leadTime") ?>\n  <? if exists("normalize") ?>\n             (qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime) * itemsub_uomratio) AS allocated,\n             (qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime) * itemsub_uomratio) AS ordered,\n             ((qtyAvailable(sub.itemsite_id) * itemsub_uomratio)\n              + (qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime) * itemsub_uomratio)\n              - (qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime) * itemsub_uomratio)) AS available\n  <? else ?>\n             (qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime)) AS allocated,\n             (qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime)) AS ordered,\n             (qtyAvailable(sub.itemsite_id) + qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime)\n              - qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime)) AS available\n  <? endif ?>\n<? elseif exists("byDays") ?>\n  <? if exists("normalize") ?>\n             (qtyAllocated(sub.itemsite_id, <? value("days") ?>) * itemsub_uomratio) AS allocated,\n             (qtyOrdered(sub.itemsite_id, <? value("days") ?>) * itemsub_uomratio) AS ordered,\n             ((qtyAvailable(sub.itemsite_id) * itemsub_uomratio) + (qtyOrdered(sub.itemsite_id, <? value("days") ?>) * itemsub_uomratio)\n              - (qtyAllocated(sub.itemsite_id, <? value("days") ?>) * itemsub_uomratio)) AS available\n  <? else ?>\n             (qtyAllocated(sub.itemsite_id, <? value("days") ?>)) AS allocated,\n             (qtyOrdered(sub.itemsite_id, <? value("days") ?>)) AS ordered,\n             (qtyAvailable(sub.itemsite_id) + qtyOrdered(sub.itemsite_id, <? value("days") ?>)\n              - qtyAllocated(sub.itemsite_id, <? value("days") ?>)) AS available\n  <? endif ?>\n<? elseif exists("byDate") ?>\n  <? if exists("normalize") ?>\n             (qtyAllocated(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE)) * itemsub_uomratio) AS allocated,\n             (qtyOrdered(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE)) * itemsub_uomratio) AS ordered,\n             ((qtyAvailable(sub.itemsite_id) * itemsub_uomratio) + (qtyOrdered(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE)) * itemsub_uomratio)\n              - (qtyAllocated(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE)) * itemsub_uomratio)) AS available\n  <? else ?>\n             (qtyAllocated(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE))) AS allocated,\n             (qtyOrdered(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE))) AS ordered,\n             (qtyAvailable(sub.itemsite_id) + qtyOrdered(sub.itemsite_id,\n             (<? value("date") ?> - CURRENT_DATE)) - qtyAllocated(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE))) AS available\n  <? endif ?>\n<? endif ?>\n      FROM item, itemsite AS sub, itemsite AS root, whsinfo, itemsub\n      WHERE ((sub.itemsite_item_id=item_id)\n         AND (root.itemsite_item_id=itemsub_parent_item_id)\n         AND (sub.itemsite_item_id=itemsub_sub_item_id)\n         AND (root.itemsite_warehous_id=sub.itemsite_warehous_id)\n         AND (sub.itemsite_warehous_id=warehous_id)\n         AND (root.itemsite_item_id=<? value("item_id") ?>)\n<? if exists("warehous_id") ?>\n         AND (root.itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n            )\n     ) AS data\nORDER BY itemsub_rank;\n  admin   2014-10-06      0
101220
 
107     summarizedBacklogByWarehouse    counts   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: summarizedBacklogByWarehouse\n-- Name: counts\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT COUNT(coitem.*) AS totalitems \n         FROM cohead, coitem, itemsite, custinfo\n\t\t     WHERE ( (coitem_cohead_id=cohead_id)\n\t\t      AND (coitem_itemsite_id=itemsite_id)\n\t\t      AND (cohead_cust_id=cust_id)\n\t\t      AND (coitem_status NOT IN ('C','X'))\n\t\t      AND (coitem_scheddate BETWEEN <? value("startDate") ?>\n\t\t                                AND <? value("endDate") ?>)\n\t\t     <? if exists("warehous_id") ?>\n\t\t      AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n\t\t     <? endif ?>\n\t\t     <? if exists("custtype_id") ?>\n\t\t      AND (cust_custtype_id=<? value("custtype_id") ?>)\n\t\t     <? elseif exists("custtype_pattern") ?>\n\t\t      AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n\t\t       WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n\t\t     <? endif ?>\n\t\t     );\n      admin   2014-10-06      0
101221
 
454     uiforms detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: uiforms\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists('byPackage') ?>\nSELECT uiform_id, uiform_name, uiform_enabled,\n       firstline(uiform_notes) AS uiform_notes, uiform_order,\n       CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n       CASE nspname WHEN 'public' THEN 0\n                                  ELSE 1 END AS xtindentrole,\n       uiform_notes AS uiform_notes_qttooltiprole\n  FROM uiform\n  JOIN pg_class     ON (uiform.tableoid=pg_class.oid)\n  JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION \nSELECT -1, pkghead_name, NULL,\n       firstline(pkghead_descrip), NULL,\n       pkghead_name, 0, pkghead_descrip\n  FROM uiform, pg_class, pg_namespace\n  RIGHT OUTER JOIN pkghead ON (nspname=pkghead_name) \n WHERE ((uiform.tableoid=pg_class.oid)\n    AND (relnamespace=pg_namespace.oid))\n ORDER BY pkgname, xtindentrole, uiform_name,\n          uiform_order, uiform_id;\n<? else ?>\nSELECT uiform_id, uiform_name, uiform_enabled,\n       firstline(uiform_notes) AS uiform_notes,\n       uiform_order,\n       CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n       uiform_notes AS uiform_notes_qttooltiprole\n  FROM uiform\n  JOIN pg_class     ON (uiform.tableoid=pg_class.oid)\n  JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nORDER BY uiform_name, uiform_order, uiform_id;\n<? endif ?>\n      admin   2014-10-06      0
101222
 
108     summarizedBacklogByWarehouse    detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: summarizedBacklogByWarehouse\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT * FROM (\n(SELECT cohead_id, 0 AS xtindentrole, salesrep_name, cohead_holdtype, cohead_number, \n   coheadstatecolor(cohead_id) AS qtforegroundrole, \n   cust_name,       \n   cohead_created, cohead_orderdate, cohead_packdate, pack_head_id,       \n          CASE WHEN (cohead_holdtype='N') THEN <? value("none") ?>\n               WHEN (cohead_holdtype='C') THEN <? value("credit") ?>\n               WHEN (cohead_holdtype='S') THEN <? value("ship") ?>\n               WHEN (cohead_holdtype='P') THEN <? value("pack") ?>\n               WHEN (cohead_holdtype='R') THEN <? value("return") ?>\n               ELSE <? value("other") ?>\n   END AS f_holdtype,       \n   MIN(coitem_scheddate) AS scheddate,       \n   SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *            \n               (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio) ) AS sales, \n   SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * stdcost(item_id) ) AS cost,\n   SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n               ((currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio) - stdcost(item_id)) ) AS margin,\n   'curr' AS sales_xtnumericrole,\n   'curr' AS cost_xtnumericrole,\n   'curr' AS margin_xtnumericrole,\n    NULL AS shiphead_id, \n    NULL AS shiphead_number, \n    NULL AS shipstatus,\n    NULL AS shipvia,\n    CASE WHEN (pack_head_id IS NOT NULL) THEN TRUE\n    ELSE FALSE\n    END AS packed \n   <? if exists("showPrices") ?> \n    , 0 AS sales_xttotalrole, 0 AS cost_xttotalrole, 0 AS margin_xttotalrole \n   <? endif ?>,\n   cohead_number AS seq\n   FROM coitem, itemsite, item, custinfo, cohead\n     LEFT OUTER JOIN pack ON (cohead_id = pack_head_id), salesrep \n   WHERE ( (coitem_cohead_id=cohead_id)\n    AND (salesrep_id = cohead_salesrep_id) \n    AND (cohead_cust_id=cust_id)\n    AND (coitem_itemsite_id=itemsite_id)\n    AND (itemsite_item_id=item_id)\n    AND (coitem_status NOT IN ('C','X'))\n    AND (coitem_scheddate BETWEEN <? value("startDate") ?>\n                              AND <? value("endDate") ?>)\n   <? if exists("warehous_id") ?>\n    AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n   <? endif ?>\n   <? if exists("custtype_id") ?>\n    AND (cust_custtype_id=<? value("custtype_id") ?>)\n   <? elseif exists("custtype_pattern") ?>\n    AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n     WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n   <? endif ?>\n   ) \n   GROUP BY cohead_id, salesrep_number, salesrep_name, cohead_number, cust_name,\n            cohead_holdtype, cohead_orderdate, cohead_packdate,\n            cohead_created, pack_head_id )\n   UNION \n   (SELECT cohead_id, 1 AS xtindentrole, NULL, NULL, \n   shiphead_number AS cohead_number, \n   CASE WHEN (shiphead_shipped IS NULL) THEN ''           \n   WHEN (shiphead_shipped) THEN 'altemphasis'            \n   WHEN (NOT shiphead_shipped) THEN 'emphasis' \n   WHEN ( (COALESCE(cobmisc_cohead_id,0) > 0)       \n   AND (SUM(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) > 0)       \n   ) THEN 'error'       \n   END AS qtforegroundrole, \n   COALESCE(shiphead_shipvia, ''), NULL, shiphead_shipdate AS cohead_orderdate, \n   NULL, NULL,\n   CASE WHEN (shiphead_shipped) THEN <? value("yes") ?>         \n   ELSE <? value("no") ?>       \n   END AS f_holdtype,  MIN(coitem_scheddate), NULL, NULL, NULL, NULL, NULL, NULL, NULL,        \n   formatShipmentNumber(shiphead_id) AS shiphead_number,        \n   NULL,       \n   COALESCE(shiphead_shipvia, '') AS shipvia           \n   <? if exists("showPrices") ?> \n    , NULL, NULL, NULL \n   <? endif ?>\n   , NULL,\n   cohead_number AS seq \n   FROM coitem, itemsite, item, custinfo, cohead\n   LEFT OUTER JOIN shiphead ON ((shiphead_order_id=cohead_id)   \n                            AND (shiphead_order_type='SO'))\n   LEFT OUTER JOIN (SELECT DISTINCT cobmisc_cohead_id FROM cobmisc) AS cobmisc ON (cobmisc_cohead_id=cohead_id)   \n   LEFT OUTER JOIN pack ON (cohead_id = pack_head_id), salesrep \n   WHERE ( (coitem_cohead_id=cohead_id)\n    AND (salesrep_id = cohead_salesrep_id) \n    AND (cohead_cust_id=cust_id)\n    AND (coitem_itemsite_id=itemsite_id)\n    AND (itemsite_item_id=item_id)\n    AND (coitem_status NOT IN ('C','X'))\n    AND (coitem_scheddate BETWEEN <? value("startDate") ?>\n                              AND <? value("endDate") ?>)\n   <? if exists("warehous_id") ?>\n    AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n   <? endif ?>\n   <? if exists("custtype_id") ?>\n    AND (cust_custtype_id=<? value("custtype_id") ?>)\n   <? elseif exists("custtype_pattern") ?>\n    AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n     WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n   <? endif ?>\n   AND ((SELECT (count(*)>0) FROM shipitem WHERE ((shipitem_shiphead_id=shiphead_id) AND (NOT shipitem_invoiced))))) \n   GROUP BY cohead_id, salesrep_number, salesrep_name, cohead_number, cust_name,         \n   cohead_holdtype, cohead_orderdate, cohead_packdate,         \n   shiphead_shipped, shiphead_shipvia, shiphead_shipdate,         \n   shiphead_id, cobmisc_cohead_id, cohead_created, pack_head_id,\n   shiphead_number )) AS data\n  ORDER BY seq, cohead_number;\n\n\n  admin   2014-10-06      0
101223
 
109     summarizedBacklogByWarehouse    qtys     \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: summarizedBacklogByWarehouse\n-- Name: qtys\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT formatQty(COALESCE(SUM(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned), 0)) AS f_totalqty \n         FROM cohead, coitem, itemsite, item, custinfo\n\t\t     WHERE ( (coitem_cohead_id=cohead_id)\n\t\t      AND (coitem_itemsite_id=itemsite_id)\n\t\t      AND (itemsite_item_id=item_id)\n\t\t      AND (cohead_cust_id=cust_id)\n\t\t      AND (coitem_status NOT IN ('C','X'))\n\t\t      AND (coitem_scheddate BETWEEN <? value("startDate") ?>\n\t\t                                AND <? value("endDate") ?>)\n\t\t     <? if exists("warehous_id") ?>\n\t\t      AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n\t\t     <? endif ?>\n\t\t     <? if exists("custtype_id") ?>\n\t\t      AND (cust_custtype_id=<? value("custtype_id") ?>)\n\t\t     <? elseif exists("custtype_pattern") ?>\n\t\t      AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n\t\t       WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n\t\t     <? endif ?>\n\t\t     );\n    admin   2014-10-06      0
101224
 
110     summarizedBacklogByWarehouse    totals   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: summarizedBacklogByWarehouse\n-- Name: totals\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT COUNT(cohead_id) AS totalorders \n\t\t     FROM ( SELECT DISTINCT cohead_id \n                FROM cohead, coitem, itemsite, custinfo\n\t\t            WHERE ( (coitem_cohead_id=cohead_id)\n\t\t             AND (coitem_itemsite_id=itemsite_id)\n\t\t             AND (cohead_cust_id=cust_id)\n\t\t             AND (coitem_status NOT IN ('C','X'))\n\t\t      AND (coitem_scheddate BETWEEN <? value("startDate") ?>\n\t\t                                AND <? value("endDate") ?>)\n\t\t     <? if exists("warehous_id") ?>\n\t\t      AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n\t\t     <? endif ?>\n\t\t     <? if exists("custtype_id") ?>\n\t\t      AND (cust_custtype_id=<? value("custtype_id") ?>)\n\t\t     <? elseif exists("custtype_pattern") ?>\n\t\t      AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n\t\t       WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n\t\t     <? endif ?>\n\t\t     ) ) AS data;\n   admin   2014-10-06      0
101225
 
287     summarizedGLTransactions        detail   used by dspSummarizedGLTransactions\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: summarizedGLTransactions\n-- Name: detail\n-- Notes: used by dspSummarizedGLTransactions\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT accnt_id, gltrans_id,\n       account, accnt_descrip,\n       gltrans_date, gltrans_source, gltrans_doctype, gltrans_docnumber,\n       f_notes,\n       debit, credit,\n       gltrans_username, gltrans_created,\n       CASE WHEN (level=0) THEN accnt_descrip\n            ELSE f_notes \n       END AS descrip_notes, \n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       0 AS debit_xtnumericrole,\n       0 AS credit_xtnumericrole,\n       CASE WHEN (debit=0) THEN '' END AS debit_qtdisplayrole,\n       CASE WHEN (credit=0) THEN '' END AS credit_qtdisplayrole,\n       level AS xtindentrole \nFROM ( \nSELECT DISTINCT accnt_id, -1 AS gltrans_id, 0 AS level,\n       accnt_number, accnt_profit, accnt_sub, \n      formatGLAccount(accnt_id) AS account, accnt_descrip,\n       CAST(NULL AS DATE) AS gltrans_date, '' AS gltrans_source, '' AS gltrans_doctype, '' AS gltrans_docnumber,\n         '' AS f_notes,\n       SUM( CASE WHEN (gltrans_amount < 0) THEN (gltrans_amount * -1) \n                        ELSE 0 \n                   END ) AS debit, \n       SUM( CASE WHEN (gltrans_amount > 0) THEN gltrans_amount \n                       ELSE 0 \n                  END ) AS credit, \n       '' AS gltrans_username, CAST(NULL AS TIMESTAMP) AS gltrans_created \nFROM gltrans, accnt \nWHERE ( (gltrans_accnt_id=accnt_id)\n AND (NOT gltrans_deleted) \n AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) \n\n  \n<? if exists("source") ?>\n     AND (gltrans_source=<? value("source") ?>)\n<? endif ?>\n  \n<? if exists("unpostedTransactions") ?>\n     AND (NOT gltrans_posted)\n<? elseif exists("postedTransactions") ?>\n       AND (gltrans_posted)\n<? endif ?>\n  ) GROUP BY accnt_id, accnt_number, accnt_profit, accnt_sub, accnt_descrip \n               UNION \n               SELECT accnt_id, gltrans_id, 1 AS level,\n                      accnt_number, accnt_profit, accnt_sub, \n                      '' AS account, '' AS accnt_descrip,\n                      gltrans_date, gltrans_source, gltrans_doctype, gltrans_docnumber,\n                      firstLine(gltrans_notes) AS f_notes,\n                      CASE WHEN (gltrans_amount < 0) THEN (gltrans_amount * -1)\n                           ELSE 0\n                      END AS debit,\n                      CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n                           ELSE 0\n                      END AS credit,\n                      gltrans_username, gltrans_created \n               FROM gltrans, accnt \n               WHERE ((gltrans_accnt_id=accnt_id)\n                AND (NOT gltrans_deleted) \n                AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) \n\n<? if exists("source") ?>\n     AND (gltrans_source=<? value("source") ?>)\n<? endif ?>\n\n<? if exists("unpostedTransactions") ?>\n     AND (NOT gltrans_posted)\n<? elseif exists("postedTransactions") ?>\n       AND (gltrans_posted)\n<? endif ?>\n\n)) AS data \n ORDER BY accnt_number, accnt_profit, accnt_sub, level, gltrans_date DESC, gltrans_created;\n       admin   2014-10-06      0
101226
 
288     summarizedSalesHistory  detail  \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: summarizedSalesHistory\n-- Name: detail\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT 1 AS dummy,\n-- Columns added to match columns of Printed Report\n<? foreach("groupLitList") ?>\n  <? literal("groupLitList") ?>\n  <? if not isLast("groupLitList") ?>\n  || E'\\n' ||\n  <? endif ?>\n<? endforeach ?> AS groupsLit,\n<? foreach("groupList") ?>\n  substring(<? literal("groupList") ?> from 1 for 15)\n  <? if not isLast("groupList") ?>\n  || E'\\n' ||\n  <? endif ?>\n<? endforeach ?> AS groups,\n<? foreach("groupDescripList") ?>\n  substring(<? literal("groupDescripList") ?> from 1 for 30)\n  <? if not isLast("groupDescripList") ?>\n  || E'\\n' ||\n  <? endif ?>\n<? endforeach ?> AS groupsDescrip,\n-- End of columns for printed report\n       <? if exists("byCustomer") ?>\n         cust_number, cohist_cust_id AS cust_number_xtidrole, cust_name,\n       <? endif ?>\n       <? if exists("byCustomerType") ?>\n         custtype_code, custtype_id AS custtype_code_xtidrole,\n       <? endif ?>\n       <? if exists("byItem") ?>\n         item_number, item_id AS item_number_xtidrole, itemdescription,\n       <? endif ?>\n       <? if exists("bySalesRep") ?>\n         salesrep_number, salesrep_id AS salesrep_number_xtidrole, salesrep_name,\n       <? endif ?>\n       <? if exists("byShippingZone") ?>\n         shipzone_name, shipzone_id AS shipzone_name_xtidrole,\n       <? endif ?>\n       <? if exists("bySite") ?>\n         warehous_code, warehous_id AS warehous_code_xtidrole,\n       <? endif ?>\n       <? if exists("byCurrency") ?>\n         currAbbr,\n         MIN(custunitprice) AS minprice, MAX(custunitprice) AS maxprice,\n         AVG(custunitprice) AS avgprice,\n         SUM(custextprice) AS totalsales,\n         CASE WHEN (SUM(cohist_qtyshipped) = 0) THEN 0\n         ELSE SUM(custextprice) / SUM(cohist_qtyshipped)\n         END AS wtavgprice,\n       <? else ?>\n         currConcat(baseCurrId()) AS currAbbr,\n         MIN(baseunitprice) AS minprice, MAX(baseunitprice) AS maxprice,\n         AVG(baseunitprice) AS avgprice,\n         SUM(baseextprice) AS totalsales,\n         CASE WHEN (SUM(cohist_qtyshipped) = 0) THEN 0\n         ELSE SUM(baseextprice) / SUM(cohist_qtyshipped)\n         END AS wtavgprice,\n       <? endif ?>\n         SUM(cohist_qtyshipped) AS totalunits,\n         MIN(cohist_invcdate) AS firstdate,\n         MAX(cohist_invcdate) AS lastdate,\n         SUM(cohist_qtyshipped) AS qtyshipped,\n         'salesprice' AS minprice_xtnumericrole,\n         'salesprice' AS maxprice_xtnumericrole,\n         'salesprice' AS avgprice_xtnumericrole,\n         'salesprice' AS wtavgprice_xtnumericrole,\n         'qty' AS qtyshipped_xtnumericrole,\n         'curr' AS extprice_xtnumericrole,\n         'qty' AS totalunits_xtnumericrole,\n         'curr' AS totalsales_xtnumericrole,\n         'qty' AS totalunits_xtnumericrole,\n         'curr' AS totalsales_xtnumericrole,\n         0 AS totalunits_xttotalrole,\n         0 AS totalsales_xttotalrole\nFROM saleshistorymisc\nWHERE ( (TRUE)\n<? if exists("startDate") ?>\n AND (cohist_invcdate >= <? value("startDate") ?>)\n<? endif ?>\n\n<? if exists("endDate") ?>\n AND (cohist_invcdate <= <? value("endDate") ?>)\n<? endif ?>\n\n<? if exists("shipStartDate") ?>\n AND (cohist_shipdate >= <? value("shipStartDate") ?>)\n<? endif ?>\n\n<? if exists("shipEndDate") ?>\n AND (cohist_shipdate <= <? value("shipEndDate") ?>)\n<? endif ?>\n\n<? if exists("warehous_id") ?>\n AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n\n<? if exists("item_id") ?>\n AND (item_id=<? value("item_id") ?>)\n<? endif ?>\n\n<? if exists("cust_id") ?>\n AND (cohist_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n\n<? if exists("shipto_id") ?>\n AND (cohist_shipto_id=<? value("shipto_id") ?>)\n<? endif ?>\n\n<? if exists("salesrep_id") ?>\n AND (salesrep_id=<? value("salesrep_id") ?>)\n<? endif ?>\n\n<? if exists("prodcat_id") ?>\n AND (prodcat_id=<? value("prodcat_id") ?>)\n<? endif ?>\n\n<? if exists("prodcat_pattern") ?>\n AND (prodcat_code ~ <? value("prodcat_pattern") ?>)\n<? endif ?>\n\n<? if exists("custtype_id") ?>\n AND (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n\n<? if exists("custtype_pattern") ?>\n   AND (custtype_code ~ <? value("custtype_pattern") ?>)\n<? endif ?>\n\n<? if exists("custgrp_id") ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrpitem\n                   WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n<? endif ?>\n\n<? if exists("custgrp_pattern") ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrp, custgrpitem\n                   WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                     AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n<? endif ?>\n\n<? if exists("shipzone_id") ?>\n AND (shipzone_id=<? value("shipzone_id") ?>)\n<? endif ?>\n\n<? if exists("curr_id") ?>\n AND cust_curr_id = <? value("curr_id") ?>\n<? endif ?>\n\n<? if exists("currConcat_pattern") ?>\n AND (currAbbr ~ <? value("currConcat_pattern") ?>)\n<? endif ?>\n)\nGROUP BY dummy\n<? if exists("bySalesRep") ?>\n , salesrep_id, salesrep_number, salesrep_name\n<? endif ?>\n<? if exists("byShippingZone") ?>\n , shipzone_id, shipzone_name, shipzone_descrip\n<? endif ?>\n<? if exists("byCustomer") ?>\n , cohist_cust_id, cust_number, cust_name\n<? endif ?>\n<? if exists("byCustomerType") ?>\n , custtype_id, custtype_code, custtype_descrip\n<? endif ?>\n<? if exists("byItem") ?>\n , item_id, item_number, itemdescription\n<? endif ?>\n<? if exists("bySite") ?>\n , warehous_id, warehous_code, warehous_descrip\n<? endif ?>\n<? if exists("byCurrency") ?>\n , cust_curr_id, currAbbr\n<? endif ?>\n ORDER BY dummy\n<? if exists("bySalesRep") ?>\n , salesrep_number\n<? endif ?>\n<? if exists("byShippingZone") ?>\n , shipzone_name\n<? endif ?>\n<? if exists("byCustomer") ?>\n , cust_number\n<? endif ?>\n<? if exists("byCustomerType") ?>\n , custtype_code\n<? endif ?>\n<? if exists("byItem") ?>\n , item_number\n<? endif ?>\n<? if exists("bySite") ?>\n , warehous_code\n<? endif ?>\n; admin   2014-10-06      0
101227
 
289     taxAuthorities  detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: taxAuthorities\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  taxauth_id, taxauth_code, taxauth_name,\n  addr.*\nFROM taxauth\n  LEFT OUTER JOIN addr ON (taxauth_addr_id=addr_id) \nWHERE true\n<? if exists("search_pattern") ?>\n  AND ((taxauth_code ~* <? value("search_pattern") ?>)\n       OR (taxauth_name ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_city,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_state,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_postalcode,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_country,'') ~* <? value("search_pattern") ?>))\n<? endif ?>\n<? if exists("taxauth_code_pattern") ?>\n  AND (taxauth_code ~* <? value("taxauth_code_pattern") ?>)\n<? endif ?>\n<? if exists("taxauth_name_pattern") ?>\n  AND (taxauth_name ~* <? value("taxauth_name_pattern") ?>)\n<? endif ?>\n<? if exists("addr_street_pattern") ?>\n  AND (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* <? value("addr_street_pattern") ?>)\n<? endif ?>\n<? if exists("addr_city_pattern") ?>\n  AND (COALESCE(addr_city,'') ~* <? value("addr_city_pattern") ?>)\n<? endif ?>\n<? if exists("addr_state_pattern") ?>\n  AND (COALESCE(addr_state,'') ~* <? value("addr_state_pattern") ?>)\n<? endif ?>\n<? if exists("addr_postalcode_pattern") ?>\n  AND (COALESCE(addr_postalcode,'') ~* <? value("addr_postalcode_pattern") ?>)\n<? endif ?>\n<? if exists("addr_country_pattern") ?>\n  AND (COALESCE(addr_country,'') ~* <? value("addr_country_pattern") ?>)\n<? endif ?>\nORDER BY taxauth_code; \n  admin   2014-10-06      0
101228
 
290     timePhasedAvailability  detail   used by dspTimePhasedAvailability\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: timePhasedAvailability\n-- Name: detail\n-- Notes: used by dspTimePhasedAvailability\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, itemtype,\n       item_number, uom_name, warehous_code,\n       reorderlevel \n       <? foreach("period_id_list") ?>\n         , bucket_<? literal("period_id_list") ?>,\n         'qty' AS bucket_<? literal("period_id_list") ?>_xtnumericrole,\n         CASE WHEN (bucket_<? literal("period_id_list") ?> < reorderlevel) THEN 'error' END AS   bucket_<? literal("period_id_list") ?>_qtforegroundrole \n       <? endforeach ?>\n FROM (SELECT itemsite_id,\n       CASE WHEN (item_type IN ('F', 'B', 'C', 'Y', 'R')) THEN 0\n            WHEN (item_type IN ('M')) THEN 1\n            WHEN (item_type IN ('P', 'O')) THEN 2\n            ELSE 0\n            END AS itemtype,\n            item_number, uom_name, warehous_code,\n            CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel \n\n       <? foreach("period_id_list") ?>\n       , qtyAvailable(itemsite_id, findPeriodStart(<? value("period_id_list") ?>)) AS bucket_<?  literal("period_id_list") ?> \n       <? endforeach ?>\n FROM itemsite, item, whsinfo, uom\n  WHERE ((itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id) \n   AND (itemsite_warehous_id=warehous_id) \n  <? if exists("warehous_id") ?>\n     AND (itemsite_warehous_id=<? value("warehous_id") ?>) \n  <? endif ?>\n  <? if exists("plancode_id") ?> \n     AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n   <? elseif exists("plancode_pattern") ?>\n     AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~         <?value("plancode_pattern") ?>)))\n <? endif ?>  \n )) AS data\n  ORDER BY item_number;\n  admin   2014-10-06      0
101229
 
291     timePhasedBookings      detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: timePhasedBookings\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n<? if exists("byCust") ?>\n  cust_id, cust_number, cust_name, \n<? elseif exists("byProdcat") ?>\n  prodcat_id, prodcat_code, prodcat_descrip,\n<? elseif exists("byItem") ?>\n  item_id, item_number, item_descrip1,\n<? endif ?>\n  uom, warehous_code\n-- Loop through each period bucket to find bookings for period\n<? foreach("period_id_list") ?>\n             , SUM(CASE WHEN (cohead_orderdate BETWEEN findPeriodStart(<? value("period_id_list") ?>) AND findPeriodEnd(<? value("period_id_list") ?>)) THEN\n                 amount ELSE 0 END) AS bucket_<? literal("period_id_list") ?>,\n  <? if exists("salesDollars") ?>\n             'curr' AS bucket_<? literal("period_id_list") ?>_xtnumericrole, \n             0 AS bucket_<? literal("period_id_list") ?>_xttotalrole\n  <? else ?>\n             'qty' AS bucket_<? literal("period_id_list") ?>_xtnumericrole, \n             0 AS bucket_<? literal("period_id_list") ?>_xttotalrole \n  <? endif ?>\n<? endforeach ?>\nFROM ( \n  SELECT cohead_orderdate,\n<? if exists("byCust") ?>\n         cust_id, cust_number, cust_name\n<? elseif exists("byProdcat") ?>\n         prodcat_id, prodcat_code, prodcat_descrip\n<? elseif exists("byItem") ?>\n         item_id, item_number, item_descrip1\n<? endif ?>\n       , warehous_code\n<? if exists("salesDollars") ?>\n       , round((coitem_qtyord * coitem_qty_invuomratio) * (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS amount\n       , <? value("baseCurrAbbr") ?>::text AS uom\n<? else ?>\n       , coitem_qtyord\n  <? if exists("capacityUnits") ?>\n       * itemcapinvrat(itemsite_item_id)\n  <? elseif exists("altCapacityUnits") ?>\n       * itemaltcapinvrat(itemsite_item_id)\n  <? endif ?>\n         AS amount\n  <? if exists("inventoryUnits") ?>\n       , uom_name AS uom\n  <? elseif exists("capacityUnits") ?>\n       , itemcapuom(item_id) AS uom\n  <? elseif exists("altCapacityUnits") ?>\n       , itemaltcapuom(item_id) AS uom\n  <? endif ?>\n<? endif ?>\n  FROM coitem\n   JOIN cohead ON (coitem_cohead_id=cohead_id)\n   JOIN itemsite ON (coitem_itemsite_id=itemsite_id)\n   JOIN item ON (itemsite_item_id=item_id)\n<? if exists("inventoryUnits") ?>\n   JOIN uom ON (item_inv_uom_id=uom_id)\n<? endif ?>\n   JOIN site() ON (itemsite_warehous_id=warehous_id)\n<? if reExists("[cC]ust") ?>\n   JOIN custinfo ON (cohead_cust_id=cust_id)\n<? endif ?> \n<? if reExists("[pP]rodcat") ?>\n   JOIN prodcat ON (item_prodcat_id=prodcat_id)\n<? endif ?>\n  WHERE ((coitem_status != 'X')\n    AND (cohead_orderdate BETWEEN \n<? foreach("period_id_list") ?>\n  <? if isFirst("period_id_list") ?>\n    findPeriodStart(<? value("period_id_list") ?>)\n  <? endif ?>\n  <? if isLast("period_id_list") ?>\n    AND findPeriodEnd(<? value("period_id_list") ?>)\n  <? endif ?>\n<? endforeach ?>)\n<? if exists("item_id") ?> \n    AND (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("cust_id") ?> \n    AND (cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?> \n    AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n    AND (cust_custtype_id IN (SELECT custtype_id \n                              FROM custtype \n                              WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("prodcat_id") ?> \n    AND (item_prodcat_id=<? value("prodcat_id") ?>) \n<? endif ?>\n<? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT prodcat_id  \n                             FROM prodcat \n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?> \n    AND(itemsite_warehous_id=<? value("warehous_id") ?>) \n<? endif ?>\n      )) data\nGROUP BY\n<? if exists("byCust") ?>\n  cust_id, cust_number, cust_name, \n<? elseif exists("byProdcat") ?>\n  prodcat_id, prodcat_code, prodcat_descrip,\n<? elseif exists("byItem") ?>\n  item_id, item_number, item_descrip1,\n<? endif ?>\n  uom, warehous_code\nORDER BY \n<? if exists("byCust") ?>\n  cust_number,\n<? elseif exists("byProdcat") ?>\n  prodcat_code,\n<? elseif exists("byItem") ?>\n  item_number,\n<? endif ?>\n  uom, warehous_code;\n        admin   2014-10-06      0
101230
 
294     timePhasedSales detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: timePhasedSales\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n<? if exists("byCust") ?>\n  cust_id, cust_number, cust_name, \n<? elseif exists("byProdcat") ?>\n  prodcat_id, prodcat_code, prodcat_descrip,\n<? elseif exists("byItem") ?>\n  item_id, item_number, item_descrip1,\n<? endif ?>\n  uom, warehous_code\n-- Loop through each period bucket to find bookings for period\n<? foreach("period_id_list") ?>\n             , SUM(CASE WHEN (cohist_invcdate BETWEEN findPeriodStart(<? value("period_id_list") ?>) AND findPeriodEnd(<? value("period_id_list") ?>)) THEN\n                 amount ELSE 0 END) AS bucket_<? literal("period_id_list") ?>,\n  <? if exists("salesDollars") ?>\n             'curr' AS bucket_<? literal("period_id_list") ?>_xtnumericrole, \n             0 AS bucket_<? literal("period_id_list") ?>_xttotalrole\n  <? else ?>\n             'qty' AS bucket_<? literal("period_id_list") ?>_xtnumericrole, \n             0 AS bucket_<? literal("period_id_list") ?>_xttotalrole \n  <? endif ?>\n<? endforeach ?>\nFROM ( \n  SELECT cohist_invcdate,\n<? if exists("byCust") ?>\n         cust_id, cust_number, cust_name\n<? elseif exists("byProdcat") ?>\n         prodcat_id, prodcat_code, prodcat_descrip\n<? elseif exists("byItem") ?>\n         item_id, item_number, item_descrip1\n<? endif ?>\n       , warehous_code\n<? if exists("salesDollars") ?>\n       , round((cohist_qtyshipped * currtobase(cohist_curr_id, cohist_unitprice, cohist_invcdate)), 2) AS amount\n       , <? value("baseCurrAbbr") ?>::text AS uom\n<? else ?>\n       , cohist_qtyshipped\n  <? if exists("capacityUnits") ?>\n       * itemcapinvrat(itemsite_item_id)\n  <? elseif exists("altCapacityUnits") ?>\n       * itemaltcapinvrat(itemsite_item_id)\n  <? endif ?>\n         AS amount\n  <? if exists("inventoryUnits") ?>\n       , uom_name AS uom\n  <? elseif exists("capacityUnits") ?>\n       , itemcapuom(item_id) AS uom\n  <? elseif exists("altCapacityUnits") ?>\n       , itemaltcapuom(item_id) AS uom\n  <? endif ?>\n<? endif ?>\n  FROM cohist JOIN itemsite ON (itemsite_id=cohist_itemsite_id)\n              JOIN item ON (item_id=itemsite_item_id)\n<? if exists("inventoryUnits") ?>\n   JOIN uom ON (item_inv_uom_id=uom_id)\n<? endif ?>\n   JOIN site() ON (itemsite_warehous_id=warehous_id)\n<? if reExists("[cC]ust") ?>\n   JOIN custinfo ON (cohist_cust_id=cust_id)\n<? endif ?> \n<? if reExists("custgrp") ?>\n   JOIN custgrpitem ON (cohist_cust_id=custgrpitem_cust_id)\n   JOIN custgrp ON (custgrp_id=custgrpitem_custgrp_id)\n<? endif ?> \n<? if reExists("[pP]rodcat") ?>\n   JOIN prodcat ON (item_prodcat_id=prodcat_id)\n<? endif ?>\n  WHERE ((cohist_invcdate BETWEEN \n<? foreach("period_id_list") ?>\n  <? if isFirst("period_id_list") ?>\n    findPeriodStart(<? value("period_id_list") ?>)\n  <? endif ?>\n  <? if isLast("period_id_list") ?>\n    AND findPeriodEnd(<? value("period_id_list") ?>)\n  <? endif ?>\n<? endforeach ?>)\n<? if exists("item_id") ?> \n    AND (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("cust_id") ?> \n    AND (cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?> \n    AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n    AND (cust_custtype_id IN (SELECT custtype_id \n                              FROM custtype \n                              WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("prodcat_id") ?> \n    AND (item_prodcat_id=<? value("prodcat_id") ?>) \n<? endif ?>\n<? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT prodcat_id  \n                             FROM prodcat \n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? endif ?>\n<? if exists("custgrp_id") ?> \n    AND (custgrp_id=<? value("custgrp_id") ?>) \n<? endif ?>\n<? if exists("custgrp_pattern") ?>\n    AND (custgrp_name  ~ <? value("custgrp_pattern") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?> \n    AND(itemsite_warehous_id=<? value("warehous_id") ?>) \n<? endif ?>\n      )) data\nGROUP BY\n<? if exists("byCust") ?>\n  cust_id, cust_number, cust_name, \n<? elseif exists("byProdcat") ?>\n  prodcat_id, prodcat_code, prodcat_descrip,\n<? elseif exists("byItem") ?>\n  item_id, item_number, item_descrip1,\n<? endif ?>\n  uom, warehous_code\nORDER BY \n<? if exists("byCust") ?>\n  cust_number,\n<? elseif exists("byProdcat") ?>\n  prodcat_code,\n<? elseif exists("byItem") ?>\n  item_number,\n<? endif ?>\n  uom, warehous_code;\n        admin   2014-10-06      0
101231
 
295     timePhasedUsageStatisticsByItem detail   used by dspTimePhasedUsageStatisticsByItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: timePhasedUsageStatisticsByItem\n-- Name: detail\n-- Notes: used by dspTimePhasedUsageStatisticsByItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT itemsite_id, <? value("received") ?> AS label, warehous_code\n     <? foreach("period_id_list") ?>\n       , summTransR(itemsite_id, <? value("period_id_list") ?>) AS bucket_<? literal("period_id_list") ?>\n     <? endforeach ?>\nFROM itemsite, whsinfo\nWHERE ((itemsite_warehous_id=warehous_id)\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nUNION ALL\nSELECT itemsite_id, <? value("issued") ?> AS label, warehous_code\n     <? foreach("period_id_list") ?>\n       , summTransI(itemsite_id, <? value("period_id_list") ?>) AS bucket_<? literal("period_id_list") ?>\n     <? endforeach ?>\nFROM itemsite, whsinfo\nWHERE ((itemsite_warehous_id=warehous_id)\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nUNION ALL\nSELECT itemsite_id, <? value("sold") ?> AS label, warehous_code\n     <? foreach("period_id_list") ?>\n       , summTransS(itemsite_id, <? value("period_id_list") ?>) AS bucket_<? literal("period_id_list") ?>\n     <? endforeach ?>\nFROM itemsite, whsinfo\nWHERE ((itemsite_warehous_id=warehous_id)\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nUNION ALL\nSELECT itemsite_id, <? value("scrap") ?> AS label, warehous_code\n     <? foreach("period_id_list") ?>\n       , summTransC(itemsite_id, <? value("period_id_list") ?>) AS bucket_<? literal("period_id_list") ?>\n     <? endforeach ?>\nFROM itemsite, whsinfo\nWHERE ((itemsite_warehous_id=warehous_id)\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nUNION ALL\nSELECT itemsite_id, <? value("adjustments") ?> AS label, warehous_code\n     <? foreach("period_id_list") ?>\n       , summTransA(itemsite_id, <? value("period_id_list") ?>) AS bucket_<? literal("period_id_list") ?>\n     <? endforeach ?>\nFROM itemsite, whsinfo\nWHERE ((itemsite_warehous_id=warehous_id)\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nORDER BY warehous_code;\n   admin   2014-10-06      0
101232
 
125     updateprices    selsched        \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: updateprices\n-- Name: selsched\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT selsched_ipshead_id, ipshead_name, ipshead_descrip\nFROM selsched\n JOIN ipshead ON (selsched_ipshead_id=ipshead_id)\nORDER BY ipshead_name\n        admin   2014-10-06      0
101233
 
298     unbalancedQOHByClassCode        detail   used by dspUnbalancedQOHByClassCode\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: unbalancedQOHByClassCode\n-- Name: detail\n-- Notes: used by dspUnbalancedQOHByClassCode\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, warehous_code, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n       itemsite_qtyonhand,\n       detailedQOH(itemsite_id, FALSE) AS detailedqoh,\n       'qty' AS itemsite_qtyonhand_xtnumericrole,\n       'qty' AS detailedqoh_xtnumericrole\nFROM whsinfo, item, itemsite, uom\nWHERE ( (itemsite_item_id=item_id)\n    AND (item_inv_uom_id=uom_id)\n    AND (itemsite_warehous_id=warehous_id)\n    AND ((itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S')))\n    AND (itemsite_qtyonhand <> detailedQOH(itemsite_id, FALSE))\n<? if exists("classcode_id") ?>\n    AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n    AND (item_classcode_id IN (SELECT classcode_id\n                               FROM classcode\n                               WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?>\n    AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nORDER BY item_number;\n      admin   2014-10-06      0
101234
 
299     undefinedManufacturedItems      detail   used by dspUndefinedManufacturedItems\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: undefinedManufacturedItems\n-- Name: detail\n-- Notes: used by dspUndefinedManufacturedItems\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT item_id, 2, item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       item_type, item_active, <? value("noBom") ?> AS exception\nFROM item\nWHERE ((item_type IN ('M', 'F'))\n   AND (item_id NOT IN (SELECT DISTINCT bomitem_parent_item_id\n                        FROM bomitem))\n<? if exists("notshowInactive") ?>\n   AND (item_active)\n<? endif ?>\n      )\nORDER BY item_number;\n      admin   2014-10-06      0
101235
 
300     uninvoicedReceivings    detail   used by dspUninvoicedReceivings\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: uninvoicedReceivings\n-- Name: detail\n-- Notes: used by dspUninvoicedReceivings\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT recv_id AS id,\n       CASE WHEN(poitem_status='C') THEN 2\n            ELSE 1\n       END AS doctype,\n       recv_date AS thedate,\n       recv_trans_usr_name AS f_user,\n       recv_order_number AS ponumber, poitem_linenumber,\n       vend_name,\n       COALESCE(item_number,\n       ('Misc. - ' || recv_vend_item_number)) AS itemnumber,\n       recv_qty AS qty, 'qty' AS qty_xtnumericrole,\n       'Receipt' AS type,\n       recv_value AS value,\n       'curr' AS value_xtnumericrole, 0 AS value_xttotalrole\nFROM recv, vendinfo,\n     poitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id))\n            ON (poitem_itemsite_id=itemsite_id)\nWHERE ((recv_orderitem_id=poitem_id)\n   AND (recv_order_type='PO')\n   AND (recv_vend_id=vend_id)\n   AND (recv_posted)\n   AND (recv_vohead_id IS NULL)\n   AND (NOT recv_invoiced)\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n   AND (recv_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n      )\n\nUNION\n\nSELECT poreject_id AS id,\n       3 AS doctype,\n       poreject_date AS thedate,\n       poreject_trans_username AS f_user,\n       poreject_ponumber AS ponumber, poitem_linenumber,\n       vend_name,\n       COALESCE(item_number,\n       ('Misc. - ' || poreject_vend_item_number)) AS itemnumber,\n       poreject_qty, 'qty' AS qty_xtnumericrole,\n       'Return' AS type,\n       poreject_value * -1 AS value,\n       'curr' AS value_xtnumericrole, 0 AS value_xtotalrole\nFROM poreject, vendinfo,\n     poitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id))\n            ON (poitem_itemsite_id=itemsite_id)\nWHERE ((poreject_poitem_id=poitem_id)\n   AND (poreject_vend_id=vend_id)\n   AND (poreject_posted)\n   AND (NOT poreject_invoiced)\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n   AND (poreject_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n      )\nORDER BY ponumber, poitem_linenumber;\n        admin   2014-10-06      0
101236
 
460     uninvoicedShipments     detail   used by uninvoicedShipments\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: uninvoicedShipments\n-- Name: detail\n-- Notes: used by uninvoicedShipments\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohead_id, shipitem_id, cohead_number, coitem_linenumber,\n       cust_number, cust_name,\n       item_number, description,\n       uom_name, shipped, selected,\n       CASE WHEN (level=0) THEN cohead_number\n            ELSE CAST(coitem_linenumber AS TEXT)\n       END AS orderline,\n       CASE WHEN (level=0) THEN cust_number\n            ELSE item_number\n       END AS custitem,\n       CASE WHEN (level=0) THEN cust_name\n            ELSE description\n       END AS custdescrip,\n       'qty' AS shipped_xtnumericrole,\n       'qty' AS selected_xtnumericrole,\n       level AS xtindentrole\nFROM (\nSELECT cohead_id, -1 AS shipitem_id, cohead_number, -1 AS coitem_linenumber, 0 AS level,\n       cust_number, cust_name,\n       '' AS item_number, '' AS description,\n       '' AS uom_name,\n       COALESCE(SUM(shipitem_qty), 0) AS shipped,\n       COALESCE(SUM(cobill_qty), 0) AS selected\nFROM cohead, custinfo, itemsite, item, whsinfo, shipitem, shiphead, uom,\n     coitem LEFT OUTER JOIN\n      ( cobill JOIN cobmisc\n        ON ( (cobill_cobmisc_id=cobmisc_id) AND (NOT cobmisc_posted) ) )\n     ON (cobill_coitem_id=coitem_id)\nWHERE ( (cohead_cust_id=cust_id)\n AND (shipitem_orderitem_id=coitem_id)\n AND (shipitem_shiphead_id=shiphead_id)\n AND (shiphead_order_type='SO')\n AND (coitem_cohead_id=cohead_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (coitem_qty_uom_id=uom_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (shiphead_shipped)\n AND (NOT shipitem_invoiced)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n  )\nGROUP BY cohead_id, cohead_number, cust_number, cust_name\n\nUNION\nSELECT cohead_id, shipitem_id, cohead_number, coitem_linenumber, 1 AS level,\n       cust_number, cust_name,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS description,\n       uom_name,\n       COALESCE(SUM(shipitem_qty), 0) AS shipped,\n       COALESCE(SUM(cobill_qty), 0) AS selected\nFROM cohead, custinfo, itemsite, item, whsinfo, shipitem, shiphead, uom,\n     coitem LEFT OUTER JOIN\n      ( cobill JOIN cobmisc\n        ON ( (cobill_cobmisc_id=cobmisc_id) AND (NOT cobmisc_posted) ) )\n     ON (cobill_coitem_id=coitem_id)\nWHERE ( (cohead_cust_id=cust_id)\n AND (shipitem_orderitem_id=coitem_id)\n AND (shipitem_shiphead_id=shiphead_id)\n AND (shiphead_order_type='SO')\n AND (coitem_cohead_id=cohead_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (coitem_qty_uom_id=uom_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (shiphead_shipped)\n AND (NOT shipitem_invoiced)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n  )\nGROUP BY cohead_number, cust_number, cust_name,\n         coitem_id, coitem_linenumber, item_number,\n         item_descrip1, item_descrip2, cohead_id, shipitem_id, uom_name\n         \n   ) AS data\n\n<? if exists("showUnselected") ?>\n WHERE (selected = 0)\n<? endif ?>\n\nORDER BY cohead_number DESC, level, coitem_linenumber DESC;\n     admin   2014-10-06      0
101237
 
88      unpostedCashReceipts    detail   Used by arWorkBench, cashReceiptsEditList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: unpostedCashReceipts\n-- Name: detail\n-- Notes: Used by arWorkBench, cashReceiptsEditList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n       cashrcpt_id, \n       cashrcpt_number,\n       cust_number,\n       cust_name,\n       cashrcpt_docnumber, \n       bankaccnt_name,\n       cashrcpt_distdate,\n       cashrcpt_amount, \n       currConcat(cashrcpt_curr_id) AS currabbr,\n       CASE\n              WHEN (cashrcpt_fundstype ='C') THEN <? value("check") ?>\n              WHEN (cashrcpt_fundstype ='T') THEN <? value("certifiedCheck") ?>\n              WHEN (cashrcpt_fundstype ='M') THEN <? value("masterCard") ?>\n              WHEN (cashrcpt_fundstype ='V') THEN <? value("visa") ?>\n              WHEN (cashrcpt_fundstype ='A') THEN <? value("americanExpress") ?>\n              WHEN (cashrcpt_fundstype ='D') THEN <? value("discoverCard") ?>\n              WHEN (cashrcpt_fundstype ='R') THEN <? value("otherCreditCard") ?>\n              WHEN (cashrcpt_fundstype ='K') THEN <? value("cash") ?>\n              WHEN (cashrcpt_fundstype ='W') THEN <? value("wireTransfer") ?>\n              WHEN (cashrcpt_fundstype ='O') THEN <? value("other") ?>\n         END AS cashrcpt_fundstype,\n       'curr' AS cashrcpt_amount_xtnumericrole \nFROM cashrcpt, bankaccnt, custinfo\n<? if exists("custgrp_id") ?>\n  JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n  JOIN custgrp ON (custgrp_id=custgrpitem_custgrp_id)\n<? endif ?>\n, custtype\nWHERE ( (NOT cashrcpt_posted)\n  AND   (NOT cashrcpt_void)\n  AND   (cashrcpt_bankaccnt_id=bankaccnt_id)\n  AND   (cashrcpt_cust_id=cust_id)\n  AND   (cust_custtype_id=custtype_id)\n<? if exists("cust_id") ?>\n  AND   (cashrcpt_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND  (custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n)\nORDER BY cashrcpt_distdate;\n\n admin   2014-10-06      0
101238
 
89      unpostedReceipts        detail   used by unpostedPoReceipts\n-------PURCHASE ORDERS----------\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: unpostedReceipts\n-- Name: detail\n-- Notes: used by unpostedPoReceipts\n---------PURCHASE ORDERS----------\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT recv_id, recv_orderitem_id, recv_order_number, recv_order_type,\n       vend_name AS orderhead_from,\n       poitem_linenumber AS orderitem_linenumber,\n       formatDate(recv_duedate) AS recv_duedate,\n       warehous_code,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS item_number,\n       COALESCE(uom_name, <? value("na") ?>) AS uom_name,\n       recv_vend_item_number,\n       recv_vend_uom,\n       poitem_qty_ordered AS orderitem_qty_ordered, \n       poitem_qty_received AS orderitem_qty_received,\n       recv_qty, recv_date,\n       COALESCE(recv_gldistdate, recv_date) AS recv_gldistdate,\n       'qty' AS orderitem_qty_ordered_xtnumericrole,\n       'qty' AS orderitem_qty_received_xtnumericrole,\n       'qty' AS recv_qty_xtnumericrole\nFROM pohead JOIN\n     poitem ON (poitem_pohead_id=pohead_id) JOIN \n     recv  ON ((recv_orderitem_id=poitem_id)\n\t   AND (recv_order_type='PO')) LEFT OUTER JOIN\n     (itemsite JOIN item ON (itemsite_item_id=item_id)\n\t       JOIN uom ON (item_inv_uom_id=uom_id)\n               JOIN site() ON (itemsite_warehous_id=warehous_id)\n       )\n      ON (recv_itemsite_id=itemsite_id) JOIN\n     vendinfo ON (pohead_vend_id=vend_id)\nWHERE (NOT recv_posted)\n<? if exists ("EnableReturnAuth") ?>\n-------RETURN AUTHORIZATIONS--------------\nUNION\nSELECT recv_id, recv_orderitem_id, recv_order_number, recv_order_type,\n       cust_name AS orderhead_from,\n       raitem_linenumber AS orderitem_linenumber,\n       formatDate(recv_duedate) AS recv_duedate,\n       warehous_code,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS item_number,\n       COALESCE(uom_name, <? value("na") ?>) AS uom_name,\n       recv_vend_item_number,\n       recv_vend_uom,\n       raitem_qtyauthorized AS orderitem_qty_ordered, \n       raitem_qtyreceived AS orderitem_qty_received,\n       recv_qty, recv_date,\n       COALESCE(recv_gldistdate, recv_date) AS recv_gldistdate,\n       'qty' AS orderitem_qty_ordered_xtnumericrole,\n       'qty' AS orderitem_qty_received_xtnumericrole,\n       'qty' AS recv_qty_xtnumericrole\nFROM rahead JOIN\n     raitem ON (raitem_rahead_id=rahead_id) JOIN \n     recv  ON ((recv_orderitem_id=raitem_id)\n\t   AND (recv_order_type='RA')) LEFT OUTER JOIN\n     (itemsite JOIN item ON (itemsite_item_id=item_id)\n\t       JOIN uom ON (item_inv_uom_id=uom_id)\n               JOIN site() ON (itemsite_warehous_id=warehous_id)\n       )\n      ON (recv_itemsite_id=itemsite_id) LEFT OUTER JOIN\n     custinfo ON (rahead_cust_id=cust_id)\nWHERE (NOT recv_posted)\n<? endif ?>\n<? if exists ("MultiWhs") ?>\n------TRANSFER ORDERS---------\nUNION\nSELECT recv_id, recv_orderitem_id, recv_order_number, recv_order_type,\n       tohead_srcname AS orderhead_from,\n       toitem_linenumber AS orderitem_linenumber,\n       formatDate(recv_duedate) AS recv_duedate,\n       warehous_code,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS item_number,\n       COALESCE(uom_name, <? value("na") ?>) AS uom_name,\n       recv_vend_item_number,\n       recv_vend_uom,\n       toitem_qty_ordered AS orderitem_qty_ordered, \n       toitem_qty_received AS orderitem_qty_received,\n       recv_qty, recv_date,\n       COALESCE(recv_gldistdate, recv_date) AS recv_gldistdate,\n       'qty' AS orderitem_qty_ordered_xtnumericrole,\n       'qty' AS orderitem_qty_received_xtnumericrole,\n       'qty' AS recv_qty_xtnumericrole\nFROM tohead JOIN\n     toitem ON (toitem_tohead_id=tohead_id) JOIN \n     recv  ON ((recv_orderitem_id=toitem_id)\n\t   AND (recv_order_type='TO')) LEFT OUTER JOIN\n     (itemsite JOIN item ON (itemsite_item_id=item_id)\n\t       JOIN uom ON (item_inv_uom_id=uom_id)\n               JOIN site() ON (itemsite_warehous_id=warehous_id)\n       )\n      ON (recv_itemsite_id=itemsite_id) \nWHERE (NOT recv_posted)\n<? endif ?>\nORDER BY recv_order_number, orderitem_linenumber;\n    admin   2014-10-06      0
101239
 
127     updateprices    update  \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: updateprices\n-- Name: update\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("nominal") ?>\nUPDATE ipsiteminfo SET\n  ipsitem_price=\n<? if exists("updateByValue") ?>\n  ipsitem_price + <? value("updateBy") ?>\n<? else ?>\n  roundSale(ipsitem_price * (1.0 + (<? value("updateBy") ?> / 100.0)))\n<? endif ?>\nFROM selsched, item\n<? if reExists("itemgrp") ?>\n  JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n  JOIN itemgrp ON (itemgrpitem_itemgrp_id=itemgrp_id)\n<? elseif reExists("prodcat") ?>\n  JOIN prodcat ON (prodcat_id=item_prodcat_id)\n<? endif ?>\nWHERE ( ipsitem_item_id=item_id\n  AND selsched_ipshead_id=ipsitem_ipshead_id\n  AND ipsitem_type='N'\n<? if exists("item_id") ?>\n  AND item_id=<? value("item_id") ?>\n<? elseif exists("itemgrp_id") ?>\n  AND itemgrp_id=<? value("itemgrp_id") ?>\n<? elseif exists("itemgrp_pattern") ?>\n  AND itemgrp_name ~ <? value("itemgrp_pattern") ?>\n<? elseif exists("prodcat_id") ?>\n  AND prodcat_id=<? value("prodcat_id") ?>\n<? elseif exists("prodcat_pattern") ?>\n  AND prodcat_code ~ <? value("prodcat_pattern") ?>\n<? endif ?>\n);\n<? endif ?>\n\n<? if exists("discount") ?>\nUPDATE ipsiteminfo SET\n  ipsitem_discntprcnt=\n<? if exists("updateByValue") ?>\n  ipsitem_discntprcnt + (<? value("updateBy") ?> / 100.0)\n<? else ?>\n  roundSale(ipsitem_discntprcnt * (1.0 + (<? value("updateBy") ?> / 100.0)))\n<? endif ?>\nFROM selsched, item\n<? if reExists("itemgrp") ?>\n  JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n  JOIN itemgrp ON (itemgrpitem_itemgrp_id=itemgrp_id)\n<? elseif reExists("prodcat") ?>\n  JOIN prodcat ON (prodcat_id=item_prodcat_id)\n<? endif ?>\nWHERE ( ipsitem_item_id=item_id\n  AND selsched_ipshead_id=ipsitem_ipshead_id\n  AND ipsitem_type='D'\n<? if exists("item_id") ?>\n  AND item_id=<? value("item_id") ?>\n<? elseif exists("itemgrp_id") ?>\n  AND itemgrp_id=<? value("itemgrp_id") ?>\n<? elseif exists("itemgrp_pattern") ?>\n  AND itemgrp_name ~ <? value("itemgrp_pattern") ?>\n<? elseif exists("prodcat_id") ?>\n  AND prodcat_id=<? value("prodcat_id") ?>\n<? elseif exists("prodcat_pattern") ?>\n  AND prodcat_code ~ <? value("prodcat_pattern") ?>\n<? endif ?>\n);\n<? endif ?>\n\n<? if exists("markup") ?>\nUPDATE ipsiteminfo SET\n  ipsitem_discntprcnt=\n<? if exists("updateByValue") ?>\n  ipsitem_discntprcnt + (<? value("updateBy") ?> / 100.0)\n<? else ?>\n  roundSale(ipsitem_discntprcnt * (1.0 + (<? value("updateBy") ?> / 100.0)))\n<? endif ?>\nFROM selsched, item\n<? if reExists("itemgrp") ?>\n  JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n  JOIN itemgrp ON (itemgrpitem_itemgrp_id=itemgrp_id)\n<? elseif reExists("prodcat") ?>\n  JOIN prodcat ON (prodcat_id=item_prodcat_id)\n<? endif ?>\nWHERE ( ipsitem_item_id=item_id\n  AND selsched_ipshead_id=ipsitem_ipshead_id\n  AND ipsitem_type='M'\n<? if exists("item_id") ?>\n  AND item_id=<? value("item_id") ?>\n<? elseif exists("itemgrp_id") ?>\n  AND itemgrp_id=<? value("itemgrp_id") ?>\n<? elseif exists("itemgrp_pattern") ?>\n  AND itemgrp_name ~ <? value("itemgrp_pattern") ?>\n<? elseif exists("prodcat_id") ?>\n  AND prodcat_id=<? value("prodcat_id") ?>\n<? elseif exists("prodcat_pattern") ?>\n  AND prodcat_code ~ <? value("prodcat_pattern") ?>\n<? endif ?>\n);\n<? endif ?>\n       admin   2014-10-06      0
101240
 
301     unusedPurchasedItems    detail   used by dspUnusedPurchasedItems.cpp\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: unusedPurchasedItems\n-- Name: detail\n-- Notes: used by dspUnusedPurchasedItems.cpp\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT item_id, item_number,\n                (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n                SUM(itemsite_qtyonhand) AS qoh,\n                MAX(itemsite_datelastcount) AS lastcount,\n                MAX(itemsite_datelastused) AS lastused,\n                'qty' AS qoh_xtnumericrole,\n                CASE WHEN (COALESCE(MAX(itemsite_datelastcount), startOfTime()) = startOfTime()) THEN 'Never' END AS lastcount_qtdisplayrole,\n                CASE WHEN (COALESCE(MAX(itemsite_datelastused), startOfTime()) = startOfTime()) THEN 'Never' END AS lastused_qtdisplayrole \nFROM item, itemsite, uom \nWHERE ((itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (item_id NOT IN (SELECT DISTINCT bomitem_item_id FROM bomitem))\n AND (NOT item_sold)\n AND (item_type IN ('P', 'O')) \n<? if exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>) \n<? elseif exists("classcode_pattern") ?>\n AND (item_classcode_id IN (SELECT classcode_id FROM classcode WHERE (classcode_code ~ <? value("classcode_pattern") ?>))) \n<? endif ?>\n<? if exists("includeUncontrolled") ?>\n AND (itemsite_controlmethod <> 'N')\n<? endif ?>\n) \nGROUP BY item_id, item_number, uom_name, item_descrip1, item_descrip2 \nORDER BY item_number;\n admin   2014-10-06      0
101241
 
461     uoms    item     used by bomItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: uoms\n-- Name: item\n-- Notes: used by bomItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT uom_id, uom_name\n  FROM item\n  JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE(item_id=<? value("item_id") ?>)\nUNION\nSELECT uom_id, uom_name\n  FROM item\n  JOIN itemuomconv ON (itemuomconv_item_id=item_id)\n  JOIN uom ON (itemuomconv_to_uom_id=uom_id),\n  itemuom, uomtype\n WHERE (itemuomconv_from_uom_id=item_inv_uom_id)\n   AND (item_id=<? value("item_id") ?>)\n   AND (itemuom_itemuomconv_id=itemuomconv_id)\n   AND (uomtype_id=itemuom_uomtype_id)\n<? if exists("uomtype") ?>\n   AND (uomtype_name=<? value("uomtype") ?>)\n<? endif ?>\nUNION\nSELECT uom_id, uom_name\n  FROM item\n  JOIN itemuomconv ON (itemuomconv_item_id=item_id)\n  JOIN uom ON (itemuomconv_from_uom_id=uom_id),\n  itemuom, uomtype\n WHERE (itemuomconv_to_uom_id=item_inv_uom_id)\n   AND (item_id=<? value("item_id") ?>)\n   AND (itemuom_itemuomconv_id=itemuomconv_id)\n   AND (uomtype_id=itemuom_uomtype_id)\n<? if exists("uomtype") ?>\n   AND (uomtype_name=<? value("uomtype") ?>)\n<? endif ?>\n ORDER BY uom_name;\n  admin   2014-10-06      0
101242
 
119     updateListPrices        update   Calculates and immediately updates list prices to the database\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: updateListPrices\n-- Name:  update\n-- Notes: Calculates and immediately updates list prices to the database\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE item SET item_listprice=\n<? if exists("byValue") ?>\n       item_listprice + <? value("updateBy") ?>\n<? else ?>\n       item_listprice * (1.0 + (<? value("updateBy") ?> / 100.0))\n<? endif ?>\nWHERE (item_sold)\n<? if exists("prodcat_id") ?>\n  AND (item_prodcat_id=<? value("prodcat_id") ?>)\n<? elseif exists("prodcat_pattern") ?>\n  AND (item_prodcat_id IN (SELECT prodcat_id FROM prodcat WHERE (prodcat_code ~ <? value("prodcat_pattern" ?>)))\n<? endif ?>\n       admin   2014-10-06      0
101243
 
120     updateprices    add     \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: updateprices\n-- Name: add\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n  INSERT INTO selsched\n<? if exists("ipshead_id") ?>\n  VALUES (<? value("ipshead_id") ?>);\n<? else ?>\n  SELECT ipshead_id\n  FROM ipshead\n  WHERE ( (ipshead_id NOT IN (\n  \tSELECT selsched_ipshead_id\n  \tFROM selsched\n  \tWHERE (selsched_ipshead_id=ipshead_id)))\n<? if not exists("showEffective") ?>\n  AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n<? if not exists("showExpired") ?>\n  AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showCurrent") ?>\n  AND (CURRENT_DATE NOT BETWEEN ipshead_effective AND ipshead_expires -1)\n<? endif ?>\n );\n\n       admin   2014-10-06      0
101244
 
121     updateprices    availsched      \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: updateprices\n-- Name: availsched\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ipshead_id, ipshead_name, ipshead_descrip,\n  ipshead_effective, ipshead_expires,\n  CASE WHEN COALESCE(ipshead_effective, startOfTime()) <= startOfTime() THEN \n\t'Always' END AS ipshead_effective_qtdisplayrole,\n  CASE WHEN COALESCE(ipshead_expires, endOfTime()) >= endOfTime() THEN \n\t'Never' END AS ipshead_expires_qtdisplayrole\nFROM ipshead\nWHERE ( (ipshead_id NOT IN (\n  \tSELECT selsched_ipshead_id\n  \tFROM selsched\n  \tWHERE (selsched_ipshead_id=ipshead_id)))\n<? if not exists("showEffective") ?>\n  AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n<? if not exists("showExpired") ?>\n  AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showCurrent") ?>\n  AND (CURRENT_DATE NOT BETWEEN ipshead_effective AND ipshead_expires -1)\n<? endif ?>\n )\nORDER BY ipshead_effective, ipshead_name;\n     admin   2014-10-06      0
101245
 
122     updateprices    createselsched  \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: updateprices\n-- Name: createselsched\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nCREATE TEMPORARY TABLE selsched (\n  selsched_ipshead_id INTEGER PRIMARY KEY );\n     admin   2014-10-06      0
101246
 
123     updateprices    dropselsched    \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: updateprices\n-- Name: dropselsched\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDROP TABLE selsched;\n  admin   2014-10-06      0
101247
 
124     updateprices    remove  \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: updateprices\n-- Name: remove\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM selsched\n<? if exists("ipshead_id") ?>\nWHERE (selsched_ipshead_id=<? value("ipshead_id") ?>)\n<? endif ?>\n;\n  admin   2014-10-06      0
101248
 
126     updateprices    updatechar       used by updatePrices\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: updateprices\n-- Name: updatechar\n-- Notes: used by updatePrices\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE ipsitemchar SET\n  ipsitemchar_price=\n<? if exists("updateByValue") ?>\n  ipsitemchar_price + <? value("updateBy") ?>\n<? else ?>\n  roundSale(ipsitemchar_price * (1.0 + (<? value("updateBy") ?> / 100.0)))\n<? endif ?>\nFROM selsched, ipsiteminfo, item\n<? if reExists("itemgrp") ?>\n  JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n  JOIN itemgrp ON (itemgrpitem_itemgrp_id=itemgrp_id)\n<? elseif reExists("prodcat") ?>\n  JOIN prodcat ON (prodcat_id=item_prodcat_id)\n<? endif ?>\nWHERE ( ipsitemchar_ipsitem_id=ipsitem_id\n  AND ipsitem_item_id=item_id\n  AND selsched_ipshead_id=ipsitem_ipshead_id\n<? if exists("item_id") ?>\n  AND item_id=<? value("item_id") ?>\n<? elseif exists("itemgrp_id") ?>\n  AND itemgrp_id=<? value("itemgrp_id") ?>\n<? elseif exists("itemgrp_pattern") ?>\n  AND itemgrp_name ~ <? value("itemgrp_pattern") ?>\n<? elseif exists("prodcat_id") ?>\n  AND prodcat_id=<? value("prodcat_id") ?>\n<? elseif exists("prodcat_pattern") ?>\n  AND prodcat_code ~ <? value("prodcat_pattern") ?>\n<? endif ?>\n);\n      admin   2014-10-06      0
101249
 
90      updateReorderLevels     post     itemsite with new reorder level\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: updateReorderLevels\n-- Name:  post\n-- Notes: itemsite with new reorder level\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE itemsite SET\n  itemsite_reorderlevel=<? value("itemsite_reorderlevel") ?>,\n  itemsite_stocked=CASE WHEN (<? value("itemsite_reorderlevel") ?> = 0) THEN false\n                        ELSE itemsite_stocked END,\n  itemsite_useparams=CASE WHEN (<? value("itemsite_reorderlevel") ?> = 0) THEN false\n                          ELSE itemsite_useparams END\nWHERE (itemsite_id=<? value("itemsite_id") ?>)\n  admin   2014-10-06      0
101250
 
91      updateReorderLevels     query    Calculates reorder point levels and returns a proposed result set\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: updateReorderLevels\n-- Name:  query\n-- Notes: Calculates reorder point levels and returns a proposed result set\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n  'qty' AS reordlvl_curr_level_xtnumericrole,\n  'qty' AS reordlvl_total_usage_xtnumericrole\nFROM updateReorderLevel((\n  SELECT array(\n    SELECT itemsite_id\n    FROM itemsite\n    JOIN item ON (itemsite_item_id=item_id)\n    LEFT OUTER JOIN plancode ON (itemsite_plancode_id=plancode_id)\n    LEFT OUTER JOIN classcode ON (item_classcode_id=classcode_id)\n    WHERE ( (itemsite_active)\n<? if exists("warehous_id") ?>\n     AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n     AND (item_id=<? value("item_id") ?>)\n<? elseif exists("classcode_id") ?>\n     AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n     AND (classcode_code ~ <? value("classcode_pattern") ?>)\n<? elseif exists("plancode_id") ?>\n     AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n     AND (plancode_code ~ <? value("plancode_pattern") ?>)\n<? endif ?>\n     )\n  )\n),\n<? value("daysOfStock") ?>, \n<? if exists("addLeadtime") ?>\n  true,\n<? else ?>\n  false,\n<? endif ?>\n\nARRAY[\n   <? foreach("period_id_list") ?>\n     <? if not isfirst("period_id_list") ?>\n      ,\n     <? endif ?>\n    <? value("period_id_list") ?>\n   <? endforeach ?> ]\n)\nORDER BY reordlvl_warehous_code, reordlvl_item_number;\n      admin   2014-10-06      0
101251
 
92      updateReorderLevels     update   Calculates and immediatly updates reorder point levels to the database\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: updateReorderLevels\n-- Name:  update\n-- Notes: Calculates and immediatly updates reorder point levels to the database\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT updateReorderLevel(itemsite_id,<? value("daysOfStock") ?>, \nARRAY[\n   <? foreach("period_id_list") ?>\n     <? if not isfirst("period_id_list") ?>\n      ,\n     <? endif ?>\n    <? value("period_id_list") ?>\n   <? endforeach ?> ]\n) AS result\nFROM itemsite\n  JOIN item ON (itemsite_item_id=item_id)\n  LEFT OUTER JOIN plancode ON (itemsite_plancode_id=plancode_id)\n  LEFT OUTER JOIN classcode ON (item_classcode_id=classcode_id)\nWHERE ( (itemsite_active)\n  AND (itemsite_useparams)\n<? if exists("warehous_id") ?>\n  AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND (item_id=<? value("item_id") ?>)\n<? elseif exists("classcode_id") ?>\n  AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n  AND (classcode_code ~ <? value("classcode_pattern") ?>)\n<? elseif exists("plancode_id") ?>\n  AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n  AND (plancode_code ~ <? value("plancode_pattern") ?>)\n<? endif ?>\n)\n     admin   2014-10-06      0
101252
 
134     usageStatistics detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: usageStatistics\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n  <? if exists("MultiWhs") ?>\n       formatQty(transfer) AS f_transfer,\n  <? endif ?>\n       formatQty(received) AS f_received,\n       formatQty(issued) AS f_issued,\n       formatQty(sold) AS f_sold,\n       formatQty(scrap) AS f_scrap,\n       formatQty(adjust) AS f_adjust,\n       'qty' AS received_xtnumericrole,\n       'qty' AS issued_xtnumericrole,\n       'qty' AS sold_xtnumericrole,\n       'qty' AS scrap_xtnumericrole,\n       'qty' AS adjust_xtnumericrole,\n       'qty' AS transfer_xtnumericrole\nFROM (\nSELECT itemsite_id, item_id, warehous_code,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n  <? if exists("MultiWhs") ?>\n       summTransT(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS transfer,\n  <? endif ?>\n       summTransR(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS received,\n       summTransI(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS issued,\n       summTransS(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS sold,\n       summTransC(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS scrap,\n       summTransA(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS adjust\nFROM item JOIN itemsite ON (itemsite_item_id=item_id)\n          JOIN whsinfo ON (warehous_id=itemsite_warehous_id)\nWHERE (1=1)\n\n<? if exists("item_id") ?>\n  AND  (item_id=<? value("item_id") ?>)\n<? endif ?>\n\n<? if exists("warehous_id")  ?>\n  AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n\n<? if exists("classcode_id") ?>\n  AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("itemgrp_id") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n                   FROM itemgrpitem\n\t\t   WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? elseif exists("plancode_id") ?>\n  AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n  AND (item_classcode_id IN (SELECT classcode_id\n\t\t\t     FROM classcode\n\t\t\t     WHERE (classcode_code ~ <? value ("classcode_pattern") ?>)))\n<? elseif exists("itemgrp_pattern") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem, itemgrp\n\t\t   WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t     AND  (itemgrp_name ~ <? value ("itemgrp_pattern") ?>))))\n<? elseif exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? elseif exists("itemgrp")?>\n  AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n<? endif ?>\n) AS data\n\nORDER BY warehous_code, item_number;\n       admin   2014-10-06      0
101253
 
302     validLocationsByItem    detail   used by dspValidLocationsByItem.cpp\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: validLocationsByItem\n-- Name: detail\n-- Notes: used by dspValidLocationsByItem.cpp\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT location_id, warehous_code,\n       formatLocationName(location_id) AS locationname,\n       firstLine(location_descrip) AS locationdescrip,\n       location_restrict, location_netable\nFROM itemsite, location, whsinfo\nWHERE ((validLocation(location_id, itemsite_id))\n   AND ((itemsite_loccntrl) OR (itemsite_location_id=location_id))\n   AND (itemsite_item_id=<? value("item_id") ?>)\n   AND (itemsite_warehous_id=warehous_id)\n<? if exists("warehous_id") ?>\n   AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nORDER BY warehous_code, locationname;\n admin   2014-10-06      0
101254
 
303     vendorAPHistory detail   used by dspVendorAPHistory\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: vendorAPHistory\n-- Name: detail\n-- Notes: used by dspVendorAPHistory\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT apopen_id, -1 AS applyid, 0 AS type,\n       apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n       apopen_docnumber AS docnumber,\n       formatBoolYN(apopen_open) AS f_open,\n       CASE WHEN (apopen_doctype='V') THEN <? value("voucher") ?>\n            WHEN (apopen_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (apopen_doctype='D') THEN <? value("debitMemo") ?>\n         ELSE <? value("other") ?>\n       END AS documenttype,\n       apopen_invcnumber AS invoicenumber,\n       apopen_ponumber AS ponumber,\n       apopen_docdate AS docdate, apopen_duedate AS duedate, apopen_amount AS amount,\n       (apopen_amount - apopen_paid) AS balance,\n       currconcat(apopen_curr_id) AS currAbbr,\n       CASE WHEN (apopen_doctype='C') THEN apopen_amount / apopen_curr_rate * -1.0\n         ELSE apopen_amount / apopen_curr_rate\n       END AS base_amount,\n       0 AS base_applied,\n       CASE WHEN (apopen_doctype='C') THEN (apopen_amount - apopen_paid) / apopen_curr_rate * -1.0\n         ELSE (apopen_amount - apopen_paid) / apopen_curr_rate\n       END AS base_balance,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       0 AS xtindentrole \nFROM apopen \nWHERE ( (apopen_vend_id=<? value("vend_id") ?>) \n    AND (apopen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) ) \n\nUNION \nSELECT apopen_id, apapply_source_apopen_id AS applyid, 1 AS type,\n       apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n       apapply_source_docnumber AS docnumber,\n       '' AS f_open,\n       CASE WHEN (apapply_source_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (apapply_source_doctype='K') THEN <? value("check") ?>\n         ELSE <? value("other") ?>\n       END AS documenttype,\n       ' ' AS invoicenumber,\n       '' AS ponumber,\n       apapply_postdate AS docdate, CAST(NULL AS DATE) AS duedate,\n       apapply_amount AS amount,\n       0 AS balance,\n       currconcat(apapply_curr_id) AS currAbbr,\n       0 AS base_amount,\n       (apapply_amount / apopen_curr_rate) AS base_applied, \n       0 AS base_balance,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       1 AS xtindentrole \nFROM apapply, apopen \nWHERE ( (apapply_target_apopen_id=apopen_id)\n    AND (apapply_vend_id=<? value("vend_id") ?>)\n    AND (apopen_vend_id=<? value("vend_id") ?>)\n    AND (apopen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) ) \n\nUNION \nSELECT apopen_id, apapply_target_apopen_id AS applyid, 2 AS type,\n       apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n       apapply_target_docnumber AS docnumber,\n       '' AS f_open,\n       CASE WHEN (apapply_target_doctype='V') THEN <? value("voucher") ?>\n            WHEN (apapply_target_doctype='D') THEN <? value("debitMemo") ?>\n         ELSE <? value("other") ?>\n       END AS documenttype,\n       apopen_invcnumber AS invoicenumber,\n       '' AS ponumber,\n       apapply_postdate AS docdate, CAST(NULL AS DATE) AS duedate,\n       apapply_amount AS amount,\n       0 AS balance,\n       currconcat(apapply_curr_id) AS currAbbr,\n       0 AS base_amount,\n       (apapply_amount / apopen_curr_rate) AS base_applied, \n       0 AS base_balance,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       1 AS xtindentrole \nFROM apapply, apopen \nWHERE ( (apapply_source_doctype IN ('C', 'K'))\n    AND (apapply_source_doctype=apopen_doctype)\n    AND (apapply_source_docnumber=apopen_docnumber)\n    AND (apapply_vend_id=<? value("vend_id") ?>)\n    AND (apopen_vend_id=<? value("vend_id") ?>)\n    AND (apopen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) ) \nORDER BY sortdate, apopen_id, type;\n       admin   2014-10-06      0
101255
 
304     vendors detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: vendors\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  vend_id, vend_vendtype_id, \n  vend_active, vend_number, vend_name,\n  vendtype_code,\n<? foreach("char_id_text_list") ?>\n  charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>,\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>,\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>,\n<? endforeach ?>\n  cntct.*, addr.*\nFROM vendinfo \n  JOIN vendtype ON (vend_vendtype_id=vendtype_id)\n  LEFT OUTER JOIN cntct ON (vend_cntct1_id=cntct_id) \n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) \n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> \n       ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='V') \n      AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=vend_id)\n      AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> \n       ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> \n       ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='V') \n      AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=vend_id)\n      AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> \n       ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> \n       ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='V') \n      AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=vend_id)\n      AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> \n       ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE true\n<? if not exists("showInactive") ?> \n  AND vend_active \n<? endif ?>\n<? if exists("search_pattern") ?>\n  AND ((vend_number ~* <? value("search_pattern") ?>)\n       OR (vend_name ~* <? value("search_pattern") ?>)\n       OR (vendtype_code ~* <? value("search_pattern") ?>)\n       OR (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(cntct_email,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_city,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_state,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_postalcode,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(addr_country,'') ~* <? value("search_pattern") ?>))\n<? endif ?>\n<? if exists("vend_number_pattern") ?>\n  AND (vend_number ~* <? value("vend_number_pattern") ?>)\n<? endif ?>\n<? if exists("vend_name_pattern") ?>\n  AND (vend_name ~* <? value("vend_name_pattern") ?>)\n<? endif ?>\n<? if exists("vendtype_code_pattern") ?>\n  AND (vendtype_code ~* <? value("vendtype_code_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_name_pattern") ?>\n  AND (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* <? value("cntct_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_phone_pattern") ?>\n  AND (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* <? value("cntct_phone_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_email_pattern") ?>\n  AND (COALESCE(cntct_email,'') ~* <? value("cntct_email_pattern") ?>)\n<? endif ?>\n<? if exists("addr_street_pattern") ?>\n  AND (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* <? value("addr_street_pattern") ?>)\n<? endif ?>\n<? if exists("addr_city_pattern") ?>\n  AND (COALESCE(addr_city,'') ~* <? value("addr_city_pattern") ?>)\n<? endif ?>\n<? if exists("addr_state_pattern") ?>\n  AND (COALESCE(addr_state,'') ~* <? value("addr_state_pattern") ?>)\n<? endif ?>\n<? if exists("addr_postalcode_pattern") ?>\n  AND (COALESCE(addr_postalcode,'') ~* <? value("addr_postalcode_pattern") ?>)\n<? endif ?>\n<? if exists("addr_country_pattern") ?>\n  AND (COALESCE(addr_country,'') ~* <? value("addr_country_pattern") ?>)\n<? endif ?>\n<? literal("charClause") ?>\nORDER BY vend_number; \n        admin   2014-10-06      0
101256
 
455     voucher editlist         used by voucheringEditList\n indent: order\n            line item\n              credit account\n            line item\n              credit account\n            debit account for entire order\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: voucher\n-- Name: editlist\n-- Notes: used by voucheringEditList\n-- indent: order\n--            line item\n--              credit account\n--            line item\n--              credit account\n--            debit account for entire order\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT orderid, seq,\n       CASE WHEN seq = 0 THEN vouchernumber\n            ELSE ''\n       END AS vouchernumber, ponumber, itemnumber,\n       vendnumber, description, itemtype, iteminvuom, f_qty, cost,\n       'curr' AS cost_xtnumericrole,\n       0 AS cost_xttotalrole,\n       CASE WHEN seq = 3 THEN 1\n            ELSE seq END AS xtindentrole,\n       CASE WHEN findAPAccount(vendid) < 0 THEN 'error'\n       END AS qtforegroundrole\nFROM (SELECT orderid,\n       CASE WHEN length(ponumber) > 0 THEN 0 ELSE 1 END AS seq,\n       vouchernumber, ponumber,\n       CASE WHEN (itemid = 1) THEN invoicenumber\n            ELSE itemnumber END AS itemnumber,\n       CASE WHEN (itemid = 1) THEN itemnumber\n            ELSE ''         END AS vendnumber,\n       vendid, description,\n       itemtype, iteminvuom, f_qty, cost\nFROM voucheringEditList\nUNION\n-- pull out the credits\nSELECT DISTINCT orderid, 2 AS seq, vouchernumber, '' AS ponumber,\n       <? value("credit") ?> AS itemnumber, '' AS vendnumber, vendid,\n       account AS description,\n       '' AS itemtype, '' AS iteminvuom, NULL as f_qty, cost\nFROM voucheringEditList\nWHERE itemid = 2\nUNION\n-- calculate the debits\nSELECT orderid, 3 AS seq, vouchernumber, '' AS ponumber,\n       <? value("debit") ?> AS itemnumber, '' AS vendnumber, vendid,\n       CASE WHEN findAPAccount(vendid) < 0 THEN <? value("notassigned") ?>\n            ELSE formatGLAccountLong(findAPAccount(vendid))\n       END AS description,\n       '' AS itemtype, '' AS iteminvuom, NULL as f_qty,\n       SUM(cost) AS cost\nFROM voucheringEditList\nWHERE itemid = 2\nGROUP BY orderid, vouchernumber, vendid\nORDER BY vouchernumber, ponumber desc, seq) AS sub;\n       admin   2014-10-06      0
101257
 
466     voucherItem     distributions    used by voucherItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: voucherItem\n-- Name: distributions\n-- Notes: used by voucherItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT vodist_id, vodist_amount,\n       COALESCE(costelem_type, <? value("none") ?>) AS costelem_type,\n       'currval' AS vodist_amount_xtnumericrole\nFROM vodist\n     LEFT OUTER JOIN costelem ON (vodist_costelem_id=costelem_id)\nWHERE ( (vodist_poitem_id=<? value("poitem_id") ?>)\n  AND   (vodist_vohead_id=<? value("vohead_id") ?>) );\n        admin   2014-10-06      0
101258
 
467     voucherItem     receipts         used by voucherItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n     -- Group: voucherItem\n-- Name: receipts\n-- Notes: used by voucherItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT recv_id AS item_id, 1 AS item_type, 'REC' AS action,\n       recv_date AS item_date,\n       recv_qty AS qty, 'qty' AS qty_xtnumericrole,\n       recv_purchcost AS unitprice,\n       'purchprice' AS unitprice_xtnumericrole,\n       formatBoolYN(recv_vohead_id=<? value("vohead_id") ?>) AS f_tagged,\n       <? value("receiving") ?> AS action_qtdisplayrole,\n       0 AS qty_xttotalrole\nFROM recv\nWHERE ( (NOT recv_invoiced)\n  AND   (recv_posted)\n  AND   ((recv_vohead_id IS NULL) OR (recv_vohead_id=<? value("vohead_id") ?>))\n  AND   (recv_order_type='PO')\n  AND   (recv_orderitem_id=<? value("poitem_id") ?>) )\n\nUNION\nSELECT poreject_id AS item_id, 2 AS item_type, 'REJ' AS action,\n       poreject_date AS item_date,\n       poreject_qty * -1 AS qty, 'qty',\n       COALESCE(recv_purchcost, poitem_unitprice) AS unitprice,\n       'purchprice' AS unitprice_xtnumericrole,\n       formatBoolYN(poreject_vohead_id=<? value("vohead_id") ?>) AS f_tagged,\n       <? value("reject") ?> AS action_qtdisplayrole,\n       0 AS qty_xttotalrole\nFROM poreject LEFT OUTER JOIN recv ON (recv_id=poreject_recv_id)\n              LEFT OUTER JOIN poitem ON (poitem_id=poreject_poitem_id)\nWHERE ( (poreject_posted)\n  AND   (NOT poreject_invoiced)\n  AND   ((poreject_vohead_id IS NULL) OR (poreject_vohead_id=<? value("vohead_id") ?>))\n  AND   (poreject_poitem_id=<? value("poitem_id") ?>) );\n     admin   2014-10-06      0
101259
 
305     voucherRegister detail   used by dspVoucherRegister\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n      -- Group: voucherRegister\n-- Name: detail\n-- Notes: used by dspVoucherRegister\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_id, gltrans_date,\n       vend_number, vend_name,\n       gltrans_doctype, gltrans_docnumber, firstLine(gltrans_notes) AS reference,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       CASE WHEN (gltrans_amount < 0) THEN ABS(gltrans_amount)\n         ELSE 0\n       END AS debit,\n       CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n         ELSE 0\n       END AS credit,\n       gltrans_username,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole\nFROM accnt, gltrans LEFT OUTER JOIN vohead JOIN vendinfo\n                               ON (vohead_vend_id=vend_id)\n                    ON (gltrans_doctype='VO' and gltrans_docnumber=vohead_number)\nWHERE ((gltrans_accnt_id=accnt_id)\n   AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n   AND (gltrans_source='A/P')\n<? if exists("accnt_id") ?>\n   AND (gltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n      )\nORDER BY gltrans_created DESC, gltrans_sequence, gltrans_amount;\n   admin   2014-10-06      0
101260
 
306     whereUsed       detail   used by dspSingleLevelWhereUsed, dspIndentedWhereUsed\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n   -- Group: whereUsed\n-- Name: detail\n-- Notes: used by dspSingleLevelWhereUsed, dspIndentedWhereUsed\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT <? if exists("byIndented") ?>\n         bomwork_id, item_id, bomwork_parent_id,\n         bomworkitemsequence(bomwork_id) AS seqord, \n         bomwork_seqnumber, item_number,\n         bomwork_qtyfxd ,bomwork_qtyper,\n         'qty' AS bomwork_qtyfxd_xtnumericrole,\n         'qtyper' AS bomwork_qtyper_xtnumericrole,\n         'scrap' AS bomwork_scrap_xtnumericrole,\n         bomwork_scrap,\n         bomwork_effective,\n         bomwork_expires,\n         CASE WHEN COALESCE(bomwork_effective,startOfTime())=startOfTime() \n              THEN 'Always' \n         END AS bomwork_effective_qtdisplayrole,\n         CASE WHEN COALESCE(bomwork_expires,endOfTime())=endOfTime() \n              THEN 'Never' \n         END AS bomwork_expires_qtdisplayrole,\n         bomwork_level - 1 AS xtindentrole, \n       <? else ?>\n         bomitem_parent_item_id, item_id, bomitem_seqnumber,\n         item_number,\n         itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd AS qtyfxd,\n         itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper AS qtyper,\n         'qty' AS qtyfxd_xtnumericrole,\n         'qtyper' AS qtyper_xtnumericrole,\n         'scrap' AS bomitem_scrap_xtnumericrole,\n         bomitem_scrap,\n         bomitem_effective, bomitem_expires,\n         CASE WHEN (COALESCE(bomitem_effective, startoftime()) = startoftime()) \n              THEN 'Always' \n         END AS bomitem_effective_qtdisplayrole,\n         CASE WHEN (COALESCE(bomitem_expires, endoftime()) = endoftime()) \n              THEN 'Never' \n         END AS bomitem_expires_qtdisplayrole,\n-- formatted for report\n         item_descrip1, item_descrip2,\n         formatQty(itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS f_qtyfxd,\n         formatQtyper(itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS f_qtyper,\n         formatScrap(bomitem_scrap) AS f_scrap,\n         formatDate(bomitem_effective, <? value("Always") ?>) AS f_effective,\n         formatDate(bomitem_expires, <? value("Never") ?>) AS f_expires,\n         formatBoolYN(bomitem_createwo) AS f_createwo,\n         CASE WHEN (bomitem_issuemethod='S') THEN <? value("Push") ?>\n              WHEN (bomitem_issuemethod='L') THEN <? value("Pull") ?>\n              WHEN (bomitem_issuemethod='M') THEN <? value("Mixed") ?>\n              ELSE <? value("Special") ?>\n         END AS f_issuemethod,\n         formatQtyper(itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * (bomitem_qtyfxd + bomitem_qtyper) * (1 + bomitem_scrap)) as f_qtyreq,\n       <? endif ?>\n       (item_descrip1 || ' ' || item_descrip2) AS descrip,\n       uom_name\nFROM item, uom, \n     <? if exists("byIndented") ?>\n       bomwork\n     <? else ?> \n       bomitem\n     <? endif ?>\nWHERE ((item_inv_uom_id=uom_id)\n        <? if exists("byIndented") ?>\n          AND (bomwork_item_id=item_id)\n          AND (bomwork_set_id=<? value("bomworkset_id") ?>)\n          <? if not exists("showExpired") ?>\n            AND (bomwork_expires > CURRENT_DATE)\n          <? endif ?>\n          <? if not exists("showFuture") ?>\n            AND (bomwork_effective <= CURRENT_DATE)\n          <? endif ?>\n        <? else ?>\n          AND (bomitem_parent_item_id=item_id)\n          AND (bomitem_item_id=<? value("item_id") ?>)\n          AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id))\n          <? if not exists("notEffective") ?>\n            AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires-1)) \n          <? else ?>\n           AND (<? value("effective") ?> BETWEEN bomitem_effective AND (bomitem_expires-1))\n          <? endif ?>\n        <? endif ?>         \n      )\n<? if exists("byIndented") ?>\nORDER BY seqord\n<? else ?>\nORDER BY item_number\n<? endif ?>\n;\n        admin   2014-10-06      0
101261
 
93      workOrderHistory        detail   used by dspWoHistoryByNumber, dspWoHistoryByItem, dspWoHistoryByClassCode\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n       -- Group: workOrderHistory\n-- Name: detail\n-- Notes: used by dspWoHistoryByNumber, dspWoHistoryByItem, dspWoHistoryByClassCode\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n<? if exists("woHistoryByClassCode") ?>\n       wo_id, formatWoNumber(wo_id) AS wonumber, wo_status,\n       wo_qtyord, wo_qtyrcv, wo_postedvalue,\n       wo_startdate, wo_duedate,\n<? elseif exists("woHistoryByItem") ?>\n       wo_id, formatWoNumber(wo_id) AS wonumber, wo_status,\n       wo_qtyord, wo_qtyrcv, wo_postedvalue,\n       wo_startdate, wo_duedate,\n<? else ?>\n       wo.*, COALESCE((prj_number || ' ' || prj_name), '') AS project,\n  <? if exists("revControl") ?>\n       COALESCE(bom.rev_number, '') AS bom_rev_number,\n       COALESCE(boo.rev_number, '') AS boo_rev_number,\n  <? endif ?>\n       'cost' AS wo_wipvalue_xtnumericrole,\n<? endif ?>\n<? if not exists("woHistoryByItem") ?>\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       item_descrip1, item_descrip2, uom_name,\n<? endif ?>\n       warehous_code,\n       formatDate(wo_startdate) AS f_wo_startdate,\n       formatDate(wo_duedate) AS f_wo_duedate,\n       formatQty(wo_qtyord) AS f_wo_qtyord,\n       formatQty(wo_qtyrcv) AS f_wo_qtyrcv,\n     <? if exists("showCosts") ?>\n       formatCost(wo_postedvalue) AS f_wo_postedvalue,\n     <? endif ?>\n       'qty' AS wo_qtyord_xtnumericrole,\n       'qty' AS wo_qtyrcv_xtnumericrole,\n       'cost' AS wo_postedvalue_xtnumericrole\nFROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)\n        JOIN whsinfo ON (warehous_id=itemsite_warehous_id)\n<? if not exists("woHistoryByItem") ?>\n        JOIN item ON (item_id=itemsite_item_id)\n        JOIN uom ON (uom_id=item_inv_uom_id)\n<? endif ?>\n<? if exists("revControl") ?>\n        LEFT OUTER JOIN rev bom ON (bom.rev_id=wo_bom_rev_id)\n        LEFT OUTER JOIN rev boo ON (boo.rev_id=wo_boo_rev_id)\n<? endif ?>\n        LEFT OUTER JOIN prj ON (prj_id=wo_prj_id)\nWHERE ((true)\n<? if exists("woHistoryByItem") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n   AND (wo_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("wo_number") ?>\n   AND (CAST(wo_number AS TEXT) ~ <? value("wo_number") ?>)\n<? endif ?>\n<? if exists("woHistoryByClassCode") ?>\n   AND (itemsite_item_id=item_id)\n   AND (wo_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n  <? if exists("classcode_id") ?>\n    AND (item_classcode_id=<? value("classcode_id") ?>)\n  <? elseif exists("classcode_pattern") ?>\n    AND (item_classcode_id IN (SELECT classcode_id FROM classcode\n                               WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n  <? endif ?>\n<? endif ?>\n<? if exists("showOnlyTopLevel") ?>\n   AND ((wo_ordtype<>'W') OR (wo_ordtype IS NULL))\n<? endif ?>\n      )\n\n<? if exists("woHistoryByItem") ?>\n  ORDER BY wo_startdate DESC, wo_number, wo_subnumber\n<? elseif exists("woHistoryByClassCode") ?>\n  ORDER BY item_number\n<? else ?>\n  ORDER BY wo_number, wo_subnumber\n<? endif ?>\n;\n    admin   2014-10-06      0
101262
 
132     workOrderMaterial       detail   used by dspWoMaterialsByItem, dspWoMaterialsByWorkOrder\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: workOrderMaterial\n-- Name: detail\n-- Notes: used by dspWoMaterialsByItem, dspWoMaterialsByWorkOrder\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT womatl.*, formatWONumber(wo_id) AS wonumber, item_number,\n       item_descrip1, item_descrip2,\n<? if exists("Manufacturing") ?>\n       formatwooperseq(womatl_wooper_id) AS wooperseq,\n<? endif ?>\n       CASE WHEN (womatl_issuemethod = 'S') THEN <? value("push") ?>\n            WHEN (womatl_issuemethod = 'L') THEN <? value("pull") ?>\n            WHEN (womatl_issuemethod = 'M') THEN <? value("mixed") ?>\n            ELSE <? value("error") ?>\n       END AS issuemethod,\n       uom_name,\n       noNeg(womatl_qtyreq - womatl_qtyiss) AS balance,\n<? if exists("isReport") ?>\n       formatDate(womatl_duedate) AS f_duedate,\n       formatQty(womatl_qtyfxd) AS f_qtyfxd,\n       formatQtyPer(womatl_qtyper) AS f_qtyper,\n       formatPrcnt(womatl_scrap) AS f_scrap,\n       formatQty(womatl_qtyreq) AS f_qtyreq,\n       formatQty(womatl_qtyiss) AS f_qtyiss,\n       formatQty(womatl_qtywipscrap) AS f_qtywipscrap,\n       formatQty(noNeg(womatl_qtyreq - womatl_qtyiss)) AS f_balance,\n<? endif ?>\n       CASE WHEN (womatl_duedate <= CURRENT_DATE) THEN 'error' END AS womatl_duedate_qtforegroundrole,\n       'qty' AS womatl_qtyfxd_xtnumericrole,\n       'qtyper' AS womatl_qtyper_xtnumericrole,\n       'percent' AS womatl_scrap_xtnumericrole,\n       'qty' AS womatl_qtyreq_xtnumericrole,\n       'qty' AS womatl_qtyiss_xtnumericrole,\n       'qty' AS womatl_qtywipscrap_xtnumericrole,\n       'qty' AS balance_xtnumericrole,\n       0 AS womatl_qtyreq_xttotalrole,\n       0 AS womatl_qtyiss_xttotalrole,\n       0 AS womatl_qtywipscrap_xttotalrole,\n       0 AS balance_xttotalrole\nFROM wo JOIN womatl ON (womatl_wo_id=wo_id)\n        JOIN uom ON (uom_id=womatl_uom_id)\n        JOIN itemsite parentsite ON (parentsite.itemsite_id=wo_itemsite_id)\n        JOIN itemsite componentsite ON (componentsite.itemsite_id=womatl_itemsite_id)\n<? if exists("item_id") ?>\n        JOIN item ON (item_id=parentsite.itemsite_item_id)\n<? elseif exists("wo_id") ?>\n        JOIN item ON (item_id=componentsite.itemsite_item_id)\n<? endif ?>\nWHERE (1=1)\n<? if exists("item_id") ?>\n  AND (componentsite.itemsite_item_id=<? value("item_id") ?>)\n  AND (wo_status <> 'C')\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND (componentsite.itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("wo_id") ?>\n  AND (wo_id=<? value("wo_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\nORDER BY wo_startdate, item_number\n<? endif ?>\n<? if exists("wo_id") ?>\n  <? if exists("Manufacturing") ?>\n  ORDER BY wooperseq, item_number\n  <? else ?>\n  ORDER BY item_number\n  <? endif ?>\n<? endif ?>\n;\n     admin   2014-10-06      0
101263
 
115     workOrderSchedule       detail   \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n        -- Group: workOrderSchedule\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT wo_id,\n       CASE WHEN (wo_ordid IS NULL) THEN -1\n            ELSE wo_ordid\n       END AS orderid,\n       wo.*, warehous_code, uom_name,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       item_descrip1, item_descrip2,\n       formatQty(wo_qtyord) AS ordered,\n       formatQty(wo_qtyrcv) AS received,\n       formatDate(wo_startdate) AS startdate,\n       formatDate(wo_duedate) AS duedate,\n       formatWONumber(wo_id) AS wonumber,\n       'qty' AS wo_qtyord_xtnumericrole,\n       'qty' AS wo_qtyrcv_xtnumericrole,\n       CASE WHEN ((wo_startdate<=CURRENT_DATE) AND (wo_status IN ('O','E','S','R'))) THEN 'error'\n       END AS wo_startdate_qtforegroundrole,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error'\n       END AS wo_duedate_qtforegroundrole,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'Overdue'\n            ELSE 'On Time'\n       END AS condition,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error' END AS condition_qtforegroundrole\nFROM itemsite, whsinfo, item, uom, wo\n<? if reExists("woSoStatus") ?>\n JOIN coitem ON ((coitem_order_id=wo_id)\n             AND (coitem_order_type='W'))\n<? endif ?>\nWHERE ( (wo_itemsite_id=itemsite_id)\n  AND (itemsite_item_id=item_id)\n  AND (item_inv_uom_id=uom_id)\n  AND (itemsite_warehous_id=warehous_id)\n<? if exists("search_pattern") ?>\n  AND ( (wo_number::TEXT ~* <? value("search_pattern") ?>)\n    OR  (item_number ~* <? value("search_pattern") ?>)\n    OR  (item_descrip1 || item_descrip2 ~* <? value("search_pattern") ?>) )\n<? endif ?>\n<? if exists("woSoStatus") ?>\n  AND (coitem_status <> 'X')\n<? elseif exists("woSoStatusMismatch") ?>\n  AND (coitem_status='C')\n<? endif ?>\n<? if exists("startDate") ?>\n  AND (wo_startdate >= <? value("startDate") ?>)\n<? endif ?>\n<? if exists("endDate") ?>\n  AND (wo_startdate <= <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("wo_id") ?>\n  AND (wo_number IN (SELECT wo_number\n                     FROM wo\n                     WHERE (wo_id=<? value("wo_id") ?>)))\n<? endif ?>\n<? if exists("status_list") ?>\n<? foreach("status_list") ?>\n  <? if isfirst("status_list") ?>\n    AND (wo_status=<? value("status_list") ?>\n  <? else ?>\n    OR wo_status=<? value("status_list") ?>\n  <? endif ?>\n  <? if islast("status_list") ?>\n    )\n  <? endif ?>\n<? endforeach ?>\n<? elseif exists("showOnlyRI") ?>\n  AND (wo_status IN ('R','I'))\n<? else ?>\n  AND (wo_status<>'C')\n<? endif ?>\n<? if exists("showOnlyTopLevel") ?>\n  AND (wo_ordtype<>'W')\n<? endif ?>\n<? if exists("classcode_id") ?>\n  AND (item_classcode_id=<? value("classcode_id") ?>)\n<? endif ?>\n<? if exists("itemgrp_id") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n                   FROM itemgrpitem\n                   WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? endif ?>\n<? if exists("plancode_id") ?>\n  AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? endif ?>\n<? if exists("wrkcnt_id") ?>\n  AND (wo_id IN (SELECT wooper_wo_id\n                 FROM wooper\n                 WHERE (wooper_wrkcnt_id=<? value("wrkcnt_id") ?>)))\n<? endif ?>\n<? if exists("classcode_pattern") ?>\n  AND (item_classcode_id IN (SELECT classcode_id\n                             FROM classcode\n                             WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp_pattern") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n                   FROM itemgrpitem, itemgrp\n                   WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id) AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>) ) ))\n<? endif ?>\n<? if exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n                                FROM plancode\n                                WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n<? if exists("wrkcnt_pattern") ?>\n  AND (wo_id IN (SELECT wooper_wo_id\n                 FROM wooper, wrkcnt\n                 WHERE ((wooper_wrkcnt_id=wrkcnt_id) AND (wrkcnt_code ~ <? value("wrkcnt_pattern") ?>))))\n<? endif ?>\n   )\nORDER BY \n<? if exists("sortByStartDate") ?>\n  wo_startdate,\n<? elseif exists("sortByDueDate") ?>\n  wo_duedate,\n<? elseif exists("sortByItemNumber") ?>\n  item_number,\n<? endif ?>\n  wo_number, wo_subnumber;\n     admin   2014-10-06      0
101264
 
116     workOrderSchedule       parameterlist    used by dspWoScheduleByParameterList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n    -- Group: workOrderSchedule\n-- Name: parameterlist\n-- Notes: used by dspWoScheduleByParameterList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT wo_id,\n       CASE WHEN (wo_ordid IS NULL) THEN -1\n            ELSE wo_ordid\n       END AS orderid,\n       wo.*, warehous_code, uom_name,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       item_descrip1, item_descrip2,\n       formatQty(wo_qtyord) AS ordered,\n       formatQty(wo_qtyrcv) AS received,\n       formatDate(wo_startdate) AS startdate,\n       formatDate(wo_duedate) AS duedate,\n       formatWONumber(wo_id) AS wonumber,\n       'qty' AS wo_qtyord_xtnumericrole,\n       'qty' AS wo_qtyrcv_xtnumericrole,\n       CASE WHEN ((wo_startdate<=CURRENT_DATE) AND (wo_status IN ('O','E','S','R'))) THEN 'error'\n       END AS wo_startdate_qtforegroundrole,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error'\n       END AS wo_duedate_qtforegroundrole,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'Overdue'\n            ELSE 'On Time'\n       END AS condition,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error' END AS condition_qtforegroundrole\nFROM wo, itemsite, whsinfo, item, uom\nWHERE ( (wo_itemsite_id=itemsite_id)\n  AND (itemsite_item_id=item_id)\n  AND (item_inv_uom_id=uom_id)\n  AND (itemsite_warehous_id=warehous_id)\n  AND (wo_startdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("warehous_id") ?>\n  AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("wo_id") ?>\n  AND (wo_number IN (SELECT wo_number\n                     FROM wo\n                     WHERE (wo_id=<? value("wo_id") ?>)))\n<? endif ?>\n<? if exists("status_list") ?>\n  AND (wo_status IN (\n<? foreach("status_list") ?>\n  <? if not isfirst("status_list") ?>\n    ,\n  <? endif ?>\n  <? value("status_list") ?>\n<? endforeach ?> ))\n<? elseif exists("showOnlyRI") ?>\n  AND (wo_status IN ('R','I'))\n<? else ?>\n  AND (wo_status<>'C')\n<? endif ?>\n<? if exists("showOnlyTopLevel") ?>\n  AND (wo_ordtype<>'W')\n<? endif ?>\n<? if exists("classcode_id") ?>\n  AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("itemgrp_id") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n                   FROM itemgrpitem\n                   WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? elseif exists("plancode_id") ?>\n  AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("wrkcnt_id") ?>\n  AND (wo_id IN (SELECT wooper_wo_id\n                 FROM wooper\n                 WHERE (wooper_wrkcnt_id=<? value("wrkcnt_id") ?>)))\n<? elseif exists("classcode_pattern") ?>\n  AND (item_classcode_id IN (SELECT classcode_id\n                             FROM classcode\n                             WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n<? elseif exists("itemgrp_pattern") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n                   FROM itemgrpitem, itemgrp\n                   WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id) AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>) ) ))\n<? elseif exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n                                FROM plancode\n                                WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? elseif exists("wrkcnt_pattern") ?>\n  AND (wo_id IN (SELECT wooper_wo_id\n                 FROM wooper, wrkcnt\n                 WHERE ((wooper_wrkcnt_id=wrkcnt_id) AND (wrkcnt_code ~ <? value("wrkcnt_pattern") ?>))))\n<? endif ?>\n<? if exists("wo_username") ?>\n  AND (wo_username=<? value("wo_username") ?>)\n<? endif ?>\n   )\nORDER BY \n<? if exists("sortByStartDate") ?>\n  wo_startdate,\n<? elseif exists("sortByDueDate") ?>\n  wo_duedate,\n<? elseif exists("sortByItemNumber") ?>\n  item_number,\n<? endif ?>\n  wo_number, wo_subnumber;\n    admin   2014-10-06      0
101265
 
128     workOrderVariance       material         used by dspMaterialUsageVarianceByBOMItem, dspMaterialUsageVarianceByComponentItem,\n                dspMaterialUsageVarianceByItem, dspMaterialUsageVarianceByWarehouse,\n                dspMaterialUsageVarianceByWorkOrder\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n  -- Group: workOrderVariance\n-- Name: material\n-- Notes: used by dspMaterialUsageVarianceByBOMItem, dspMaterialUsageVarianceByComponentItem,\n--                dspMaterialUsageVarianceByItem, dspMaterialUsageVarianceByWarehouse,\n--                dspMaterialUsageVarianceByWorkOrder\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT womatlvar_id, posted, \n       parentitemnumber, parentdescrip,\n       componentitemnumber, componentdescrip,\n       ordered, received,\n       projreq, projqtyper,\n       actiss, actqtyper,\n       (actqtyper - projqtyper) AS qtypervar,\n       CASE WHEN (actqtyper=projqtyper) THEN 0\n            WHEN (projqtyper=0) THEN actqtyper\n            ELSE ((1 - (actqtyper / projqtyper)) * -1)\n       END AS qtypervarpercent,\n       womatlvar_notes, womatlvar_ref,\n<? if exists("isReport") ?>\n       formatDate(posted) AS f_posted,\n       formatQty(ordered) AS f_ordered,\n       formatQty(received) AS f_received,\n       formatQty(projreq) AS f_projreq,\n       formatQtyPer(projqtyper) AS f_projqtyper,\n       formatQty(actiss) AS f_actiss,\n       formatQty(actqtyper) AS f_actqtyper,\n       formatQty(actqtyper - projqtyper) AS f_qtypervar,\n       CASE WHEN (actqtyper=projqtyper) THEN formatQty(0)\n            WHEN (projqtyper=0) THEN formatQty(actqtyper)\n            ELSE formatPrcnt((1 - (actqtyper / projqtyper)) * -1)\n       END AS f_qtypervarpercent,\n<? endif ?>\n       'qty' AS ordered_xtnumericrole,\n       'qty' AS received_xtnumericrole,\n       'qty' AS projreq_xtnumericrole,\n       'qtyper' AS projqtyper_xtnumericrole,\n       'qty' AS actiss_xtnumericrole,\n       'qtyper' AS actqtyper_xtnumericrole,\n       'qtyper' AS qtypervar_xtnumericrole,\n       'percent' AS qtypervarpercent_xtnumericrole\nFROM ( SELECT womatlvar_id, womatlvar_posted AS posted,\n              parentitem.item_number AS parentitemnumber,\n              parentitem.item_descrip1 || ' ' || parentitem.item_descrip2 as parentdescrip,\n              componentitem.item_number AS componentitemnumber,\n              componentitem.item_descrip1 || ' ' || componentitem.item_descrip2 as componentdescrip,\n              womatlvar_notes, womatlvar_ref,\n              womatlvar_qtyord AS ordered, womatlvar_qtyrcv AS received,\n              ((womatlvar_qtyfxd + womatlvar_qtyrcv * womatlvar_qtyper) * (1 + womatlvar_scrap)) AS projreq,\n              womatlvar_qtyper AS projqtyper,\n              (womatlvar_qtyiss) AS actiss, (NONEG(womatlvar_qtyiss - womatlvar_qtyfxd) / (womatlvar_qtyrcv * (1 + womatlvar_scrap))) AS actqtyper\n       FROM womatlvar LEFT OUTER JOIN wo ON ( (wo_number=womatlvar_number) AND\n                                              (wo_subnumber=womatlvar_subnumber) )\n                      LEFT OUTER JOIN itemsite parent ON (parent.itemsite_id=womatlvar_parent_itemsite_id)\n                      LEFT OUTER JOIN item parentitem ON (parentitem.item_id=parent.itemsite_item_id)\n                      LEFT OUTER JOIN itemsite component ON (component.itemsite_id=womatlvar_component_itemsite_id)\n                      LEFT OUTER JOIN item componentitem ON (componentitem.item_id=component.itemsite_item_id)\n       WHERE ( (1=1)\n<? if exists("startDate") ?>\n         AND   (womatlvar_posted BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("wo_id") ?>\n         AND   (wo_id=<? value("wo_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n         AND   (parent.itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n         AND   (parent.itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("bomitem_id") ?>\n         AND   (womatlvar_bomitem_id=<? value("bomitem_id") ?>)\n<? endif ?>\n<? if exists("component_item_id") ?>\n         AND   (component.itemsite_item_id=<? value("component_item_id") ?>)\n<? endif ?>\n             ) ) AS data\nORDER BY posted;\n  admin   2014-10-06      0
101266
 
\.
101267
 
 
101268
 
 
101269
 
--
101270
 
--
101271
 
 
101272
 
SELECT pg_catalog.setval('metasql_metasql_id_seq', 485, true);
101273
 
 
101274
 
 
101275
 
--
101276
 
--
101277
 
 
101278
 
COPY metric (metric_id, metric_name, metric_value, metric_module) FROM stdin;
101279
 
22      FreightAccount  1       \N
101280
 
23      DefaultARAccount        2       \N
101281
 
44      DefaultAPAccount        3       \N
101282
 
20      InvoiceCustomer t       \N
101283
 
21      InvoiceBilling  0       \N
101284
 
51      DatabaseName!   Schema Benchmark        \N
101285
 
70      InvoiceWatermark2               \N
101286
 
71      InvoiceShowPrices2      102     \N
101287
 
72      InvoiceWatermark3               \N
101288
 
73      InvoiceShowPrices3      102     \N
101289
 
49      AccountingSystemImportPath      C:/OpenMFG      \N
101290
 
50      AccountingSystemExportPath      C:/OpenMFG      \N
101291
 
78      CreditMemoWatermark2            \N
101292
 
79      CreditMemoShowPrices2   116     \N
101293
 
80      CreditMemoWatermark3            \N
101294
 
81      CreditMemoShowPrices3   116     \N
101295
 
48      AccountingSystem        Native  \N
101296
 
2       DefaultEventFence       10      \N
101297
 
62      MaxLocationNameSize     10      \N
101298
 
3       PostCountTagToDefault   f       \N
101299
 
4       CountSlipAuditing       B       \N
101300
 
14      AllowDiscounts  t       \N
101301
 
15      AllowASAPShipSchedules  t       \N
101302
 
16      CONumberGeneration      A       \N
101303
 
17      QUNumberGeneration      A       \N
101304
 
18      CMNumberGeneration      A       \N
101305
 
24      DefaultShipFormId       -1      \N
101306
 
26      DefaultPartialShipments t       \N
101307
 
27      DefaultBackOrders       t       \N
101308
 
28      DefaultFreeFormShiptos  t       \N
101309
 
31      DefaultBalanceMethod    B       \N
101310
 
32      BOLShipper      t       \N
101311
 
33      BOLCustomer     f       \N
101312
 
34      BOLTraffic      f       \N
101313
 
35      BOLBilling      f       \N
101314
 
36      BOLMisc 0       \N
101315
 
37      PONumberGeneration      A       \N
101316
 
38      VoucherNumberGeneration A       \N
101317
 
39      PrNumberGeneration      A       \N
101318
 
40      POAllowFFVendorAddresses        t       \N
101319
 
43      DefaultPOShipVia        UPS     \N
101320
 
53      CustListSerial  30      \N
101321
 
8       AutoExplodeSO   t       \N
101322
 
10      ExplodeSOEffective      E       \N
101323
 
11      SOExplosionLevel        M       \N
101324
 
84      AutoExplodeWO   t       \N
101325
 
86      ExplodeWOEffective      S       \N
101326
 
87      WOExplosionLevel        M       \N
101327
 
12      PostMaterialVariances   t       \N
101328
 
13      PostLaborVariances      t       \N
101329
 
90      ItemSiteChangeLog       t       \N
101330
 
91      WarehouseChangeLog      t       \N
101331
 
92      AllowInactiveBomItems   f       \N
101332
 
6       DefaultSoldItemsExclusive       f       \N
101333
 
93      ItemChangeLog   t       \N
101334
 
7       DefaultWomatlIssueMethod        M       \N
101335
 
94      DefaultMSCalendar       -1      \N
101336
 
85      WorkOrderChangeLog      t       \N
101337
 
9       WONumberGeneration      A       \N
101338
 
95      POChangeLog     t       \N
101339
 
96      VendorChangeLog t       \N
101340
 
97      CustomerChangeLog       t       \N
101341
 
98      SalesOrderChangeLog     t       \N
101342
 
99      RestrictCreditMemos     f       \N
101343
 
100     AutoSelectForBilling    t       \N
101344
 
101     AlwaysShowSaveAndAdd    t       \N
101345
 
102     DisableSalesOrderPriceOverride  f       \N
101346
 
103     AutoAllocateCreditMemos f       \N
101347
 
104     HideSOMiscCharge        f       \N
101348
 
105     EnableSOShipping        t       \N
101349
 
25      DefaultShipViaId        -1      \N
101350
 
106     DefaultCustType -1      \N
101351
 
29      SOCreditLimit   0       \N
101352
 
30      SOCreditRate    Not Checked     \N
101353
 
107     InvoiceDateSource       shipdate        \N
101354
 
64      InvoiceCopies   2       \N
101355
 
66      InvoiceWatermark0       Internal        \N
101356
 
67      InvoiceShowPrices0      f       \N
101357
 
68      InvoiceWatermark1       Customer        \N
101358
 
69      InvoiceShowPrices1      t       \N
101359
 
65      CreditMemoCopies        2       \N
101360
 
74      CreditMemoWatermark0    Internal        \N
101361
 
75      CreditMemoShowPrices0   t       \N
101362
 
76      CreditMemoWatermark1    Customer        \N
101363
 
77      CreditMemoShowPrices1   t       \N
101364
 
108     ShippingFormCopies      1       \N
101365
 
109     ShippingFormWatermark0  \N      \N
101366
 
110     ShippingFormShowPrices0 t       \N
101367
 
111     DisallowReceiptExcessQty        f       \N
101368
 
112     UseProjects     t       \N
101369
 
113     AutoCreateProjectsForOrders     f       \N
101370
 
114     HideApplyToBalance      f       \N
101371
 
54      remitto_name    Company Name    \N
101372
 
55      remitto_address1        Line 1  \N
101373
 
56      remitto_address2        Line 2  \N
101374
 
57      remitto_address3        Line 3  \N
101375
 
58      remitto_city    City    \N
101376
 
59      remitto_state   ST      \N
101377
 
60      remitto_zipcode 99999-9999      \N
101378
 
115     remitto_country Country \N
101379
 
61      remitto_phone   (800) 555-1212  \N
101380
 
45      GLMainSize      5       \N
101381
 
117     GLFFProfitCenters       t       \N
101382
 
118     GLFFSubaccounts t       \N
101383
 
119     YearEndEquityAccount    -1      \N
101384
 
120     CurrencyGainLossAccount -1      \N
101385
 
88      CurrencyExchangeSense   1       \N
101386
 
121     GLSeriesDiscrepancyAccount      -1      \N
101387
 
122     MandatoryGLEntryNotes   t       \N
101388
 
63      DatabaseName    Empty Database  \N
101389
 
52      DatabaseComments        Empty Database  \N
101390
 
125     UpdatePriceLineEdit     2       \N
101391
 
126     UseEarliestAvailDateOnPOItem    f       \N
101392
 
127     RequireStdCostForPOItem f       \N
101393
 
128     ShipmentNumberGeneration        A       \N
101394
 
129     WarnIfReceiptQtyDiffers f       \N
101395
 
130     ReceiptQtyTolerancePct          \N
101396
 
116     GLCompanySize   1       \N
101397
 
46      GLProfitSize    1       \N
101398
 
47      GLSubaccountSize        1       \N
101399
 
131     AllowManualGLAccountEntry       t       \N
101400
 
132     DefaultTaxAuthority     -1      \N
101401
 
145     TransferOrderChangeLog  f       \N
101402
 
146     EnableTOShipping        t       \N
101403
 
148     MultiWhs        f       \N
101404
 
149     BBOM    f       \N
101405
 
150     Transforms      f       \N
101406
 
151     Routings        f       \N
101407
 
152     BufferMgt       f       \N
101408
 
153     LotSerialControl        f       \N
101409
 
154     Application     PostBooks       \N
101410
 
155     CCConfirmPreauth        f       \N
101411
 
156     CCConfirmCharge f       \N
101412
 
157     CCConfirmChargePreauth  f       \N
101413
 
158     CCConfirmCredit f       \N
101414
 
159     CCEnablePreauth f       \N
101415
 
160     CCEnableCharge  f       \N
101416
 
161     CCAvsCheck      W       \N
101417
 
162     CCTestResult    P       \N
101418
 
164     RecurringInvoiceBuffer  7       \N
101419
 
165     EmployeeChangeLog       t       \N
101420
 
167     AllowAvgCostMethod      f       \N
101421
 
168     AllowStdCostMethod      t       \N
101422
 
1       InterfaceToGL   t       \N
101423
 
170     AutoUpdateLocaleHasRun  t       \N
101424
 
171     LegacyCashReceipts      f       \N
101425
 
172     VerboseCommentList      t       \N
101426
 
169     AllowJobCostMethod      t       \N
101427
 
175     EFTRoutingRegex ^\\d{9}$        \N
101428
 
176     EFTAccountRegex ^\\d{4,17}$     \N
101429
 
177     EFTFunction     formatAchChecks \N
101430
 
19      InvcNumberGeneration    A       \N
101431
 
180     CreditTaxDiscount       t       \N
101432
 
181     POCopies        1       \N
101433
 
182     POWatermark0    Vendor Copy     \N
101434
 
183     POWatermark1    Internal Copy #1        \N
101435
 
184     NumberIssueResetIntervalDays    1       \N
101436
 
185     InterfaceAPToGL t       \N
101437
 
186     InterfaceARToGL t       \N
101438
 
174     ACHSupported    t       \N
101439
 
187     AutoVersionUpdate       t       \N
101440
 
188     RegistrationKey 1GEHT-CTWEJ-ZGY8Z-MXJZK-ECVCQ   \N
101441
 
178     desktop/welcome http://welcome.xtuple.org/index.html    \N
101442
 
179     desktop/timer   900000  \N
101443
 
189     UnifiedBuild    true    \N
101444
 
173     ServerVersion   4.7.0   \N
101445
 
\.
101446
 
 
101447
 
 
101448
 
--
101449
 
--
101450
 
 
101451
 
SELECT pg_catalog.setval('metric_metric_id_seq', 189, true);
101452
 
 
101453
 
 
101454
 
--
101455
 
--
101456
 
 
101457
 
COPY metricenc (metricenc_id, metricenc_name, metricenc_value, metricenc_module) FROM stdin;
101458
 
\.
101459
 
 
101460
 
 
101461
 
--
101462
 
--
101463
 
 
101464
 
SELECT pg_catalog.setval('metricenc_metricenc_id_seq', 1, false);
101465
 
 
101466
 
 
101467
 
--
101468
 
--
101469
 
 
101470
 
SELECT pg_catalog.setval('misc_index_seq', 1166, true);
101471
 
 
101472
 
 
101473
 
--
101474
 
--
101475
 
 
101476
 
COPY mrghist (mrghist_cntct_id, mrghist_table, mrghist_pkey_col, mrghist_pkey_id, mrghist_cntct_col) FROM stdin;
101477
 
\.
101478
 
 
101479
 
 
101480
 
--
101481
 
--
101482
 
 
101483
 
COPY mrgundo (mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id, mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type) FROM stdin;
101484
 
\.
101485
 
 
101486
 
 
101487
 
--
101488
 
--
101489
 
 
101490
 
COPY msg (msg_id, msg_posted, msg_scheduled, msg_text, msg_expires, msg_username) FROM stdin;
101491
 
\.
101492
 
 
101493
 
 
101494
 
--
101495
 
--
101496
 
 
101497
 
SELECT pg_catalog.setval('msg_msg_id_seq', 16, true);
101498
 
 
101499
 
 
101500
 
--
101501
 
--
101502
 
 
101503
 
COPY msguser (msguser_id, msguser_msg_id, msguser_viewed, msguser_username) FROM stdin;
101504
 
\.
101505
 
 
101506
 
 
101507
 
--
101508
 
--
101509
 
 
101510
 
SELECT pg_catalog.setval('msguser_msguser_id_seq', 12, true);
101511
 
 
101512
 
 
101513
 
--
101514
 
--
101515
 
 
101516
 
SELECT pg_catalog.setval('nvend_nvend_id_seq', 1, false);
101517
 
 
101518
 
 
101519
 
--
101520
 
--
101521
 
 
101522
 
COPY obsolete_tax (tax_id, tax_code, tax_descrip, tax_ratea, tax_sales_accnt_id, tax_freight, tax_cumulative, tax_rateb, tax_salesb_accnt_id, tax_ratec, tax_salesc_accnt_id) FROM stdin;
101523
 
\.
101524
 
 
101525
 
 
101526
 
--
101527
 
--
101528
 
 
101529
 
COPY ophead (ophead_id, ophead_name, ophead_crmacct_id, ophead_owner_username, ophead_opstage_id, ophead_opsource_id, ophead_optype_id, ophead_probability_prcnt, ophead_amount, ophead_target_date, ophead_actual_date, ophead_notes, ophead_curr_id, ophead_active, ophead_cntct_id, ophead_username, ophead_start_date, ophead_assigned_date, ophead_priority_id, ophead_number) FROM stdin;
101530
 
\.
101531
 
 
101532
 
 
101533
 
--
101534
 
--
101535
 
 
101536
 
SELECT pg_catalog.setval('ophead_ophead_id_seq', 1, true);
101537
 
 
101538
 
 
101539
 
--
101540
 
--
101541
 
 
101542
 
COPY opsource (opsource_id, opsource_name, opsource_descrip) FROM stdin;
101543
 
\.
101544
 
 
101545
 
 
101546
 
--
101547
 
--
101548
 
 
101549
 
SELECT pg_catalog.setval('opsource_opsource_id_seq', 1, false);
101550
 
 
101551
 
 
101552
 
--
101553
 
--
101554
 
 
101555
 
COPY opstage (opstage_id, opstage_name, opstage_descrip, opstage_order, opstage_opinactive) FROM stdin;
101556
 
\.
101557
 
 
101558
 
 
101559
 
--
101560
 
--
101561
 
 
101562
 
SELECT pg_catalog.setval('opstage_opstage_id_seq', 1, false);
101563
 
 
101564
 
 
101565
 
--
101566
 
--
101567
 
 
101568
 
COPY optype (optype_id, optype_name, optype_descrip) FROM stdin;
101569
 
\.
101570
 
 
101571
 
 
101572
 
--
101573
 
--
101574
 
 
101575
 
SELECT pg_catalog.setval('optype_optype_id_seq', 1, false);
101576
 
 
101577
 
 
101578
 
--
101579
 
--
101580
 
 
101581
 
COPY orderseq (orderseq_id, orderseq_name, orderseq_number, orderseq_table, orderseq_numcol, orderseq_seqiss) FROM stdin;
101582
 
12      IncidentNumber  1       incdt   incdt_number    \N
101583
 
5       InvcNumber      1       invchead        invchead_invcnumber     \N
101584
 
10      PlanNumber      1       planord planord_number  \N
101585
 
6       PoNumber        1       pohead  pohead_number   \N
101586
 
8       PrNumber        1       pr      pr_number       \N
101587
 
3       QuNumber        1       quhead  quhead_number   \N
101588
 
2       SoNumber        1       cohead  cohead_number   \N
101589
 
7       VcNumber        1       vohead  vohead_number   \N
101590
 
1       WoNumber        1       wo      wo_number       \N
101591
 
15      ToNumber        100     tohead  tohead_number   \N
101592
 
20      LsRegNumber     1       lsreg   lsreg_number    \N
101593
 
18      AddressNumber   1       addr    addr_number     \N
101594
 
19      ContactNumber   1       cntct   cntct_number    \N
101595
 
21      AlarmNumber     1       alarm   alarm_number    \N
101596
 
23      CashRcptNumber  10000   cashrcpt        cashrcpt_number \N
101597
 
24      ACHBatch        1       checkhead       checkhead_ach_batch     \N
101598
 
13      APMemoNumber    1       apmemo  apopen_docnumber        \N
101599
 
11      ARMemoNumber    1       armemo  aropen_docnumber        \N
101600
 
4       CmNumber        1       armemo  aropen_docnumber        \N
101601
 
25      OpportunityNumber       1       ophead  ophead_number   \N
101602
 
26      CRMAccountNumber        0       crmacct crmacct_number  \N
101603
 
\.
101604
 
 
101605
 
 
101606
 
--
101607
 
--
101608
 
 
101609
 
SELECT pg_catalog.setval('orderseq_orderseq_id_seq', 26, true);
101610
 
 
101611
 
 
101612
 
--
101613
 
--
101614
 
 
101615
 
COPY pack (pack_id, pack_head_id, pack_head_type, pack_shiphead_id, pack_printed) FROM stdin;
101616
 
\.
101617
 
 
101618
 
 
101619
 
--
101620
 
--
101621
 
 
101622
 
SELECT pg_catalog.setval('pack_pack_id_seq', 1, true);
101623
 
 
101624
 
 
101625
 
--
101626
 
--
101627
 
 
101628
 
COPY payaropen (payaropen_ccpay_id, payaropen_aropen_id, payaropen_amount, payaropen_curr_id) FROM stdin;
101629
 
\.
101630
 
 
101631
 
 
101632
 
--
101633
 
--
101634
 
 
101635
 
COPY payco (payco_ccpay_id, payco_cohead_id, payco_amount, payco_curr_id, payco_id) FROM stdin;
101636
 
\.
101637
 
 
101638
 
 
101639
 
--
101640
 
--
101641
 
 
101642
 
SELECT pg_catalog.setval('payco_payco_id_seq', 1, false);
101643
 
 
101644
 
 
101645
 
--
101646
 
--
101647
 
 
101648
 
COPY period (period_id, period_start, period_end, period_closed, period_freeze, period_initial, period_name, period_yearperiod_id, period_quarter, period_number) FROM stdin;
101649
 
\.
101650
 
 
101651
 
 
101652
 
--
101653
 
--
101654
 
 
101655
 
SELECT pg_catalog.setval('period_period_id_seq', 27, true);
101656
 
 
101657
 
 
101658
 
--
101659
 
--
101660
 
 
101661
 
COPY pkgdep (pkgdep_id, pkgdep_pkghead_id, pkgdep_parent_pkghead_id) FROM stdin;
101662
 
\.
101663
 
 
101664
 
 
101665
 
--
101666
 
--
101667
 
 
101668
 
SELECT pg_catalog.setval('pkgdep_pkgdep_id_seq', 1, true);
101669
 
 
101670
 
 
101671
 
--
101672
 
--
101673
 
 
101674
 
COPY pkghead (pkghead_id, pkghead_name, pkghead_descrip, pkghead_version, pkghead_developer, pkghead_notes, pkghead_created, pkghead_updated, pkghead_indev) FROM stdin;
101675
 
7       fixcountry      xTuple package to fix non-standard countries    3.4.0   xTuple  \n  This package contains components to help fix addresses with non-standard countries.\n       2011-10-27 14:11:17.261723+00   2012-07-16 13:52:28.281582+00   f
101676
 
5       xtdesktop       xTuple Desktop  3.8.4   xTuple  \n        xTuple Desktop navigational interface for the xTuple main window.\n    \n        This package is an extension for xTuple ERP: PostBooks Edition,\n        a free and open source Enterprise Resource Planning software suite,\n        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n        It is licensed to you under the Common Public Attribution License\n        version 1.0, the full text of which (including xTuple-specific Exhibits)\n        is available at www.xtuple.com/CPAL.  By using this software, you agree\n        to be bound by its terms.\n       2010-06-18 15:45:51.129786+00   2014-02-14 21:39:30.737502+00   f
101677
 
6       te      Time and Expense System 2.2.0rc xTuple  Time and Expense System add-on package for xTuple ERP.\n\n        This file is part of the xtte package for xTuple ERP: PostBooks Edition,\n        a free and open source Enterprise Resource Planning software suite,\n        Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n        It is licensed to you under the Common Public Attribution License\n        version 1.0, the full text of which (including xTuple-specific Exhibits)\n        is available at www.xtuple.com/CPAL.  By using this software, you agree\n        to be bound by its terms.\n       2010-10-26 18:14:56.688819+00   2013-09-27 20:33:50.432224+00   f
101678
 
\.
101679
 
 
101680
 
 
101681
 
--
101682
 
--
101683
 
 
101684
 
SELECT pg_catalog.setval('pkghead_pkghead_id_seq', 7, true);
101685
 
 
101686
 
 
101687
 
--
101688
 
--
101689
 
 
101690
 
COPY pkgitem (pkgitem_id, pkgitem_pkghead_id, pkgitem_type, pkgitem_item_id, pkgitem_name, pkgitem_descrip) FROM stdin;
101691
 
\.
101692
 
 
101693
 
 
101694
 
--
101695
 
--
101696
 
 
101697
 
SELECT pg_catalog.setval('pkgitem_pkgitem_id_seq', 1, false);
101698
 
 
101699
 
 
101700
 
--
101701
 
--
101702
 
 
101703
 
COPY plancode (plancode_id, plancode_code, plancode_name, plancode_mpsexplosion, plancode_consumefcst, plancode_mrpexcp_resched, plancode_mrpexcp_delete) FROM stdin;
101704
 
\.
101705
 
 
101706
 
 
101707
 
--
101708
 
--
101709
 
 
101710
 
SELECT pg_catalog.setval('plancode_plancode_id_seq', 23, true);
101711
 
 
101712
 
 
101713
 
--
101714
 
--
101715
 
 
101716
 
SELECT pg_catalog.setval('planord_planord_id_seq', 1022, true);
101717
 
 
101718
 
 
101719
 
--
101720
 
--
101721
 
 
101722
 
COPY pohead (pohead_id, pohead_status, pohead_number, pohead_orderdate, pohead_vend_id, pohead_fob, pohead_shipvia, pohead_comments, pohead_freight, pohead_printed, pohead_terms_id, pohead_warehous_id, pohead_vendaddr_id, pohead_agent_username, pohead_curr_id, pohead_saved, pohead_taxzone_id, pohead_taxtype_id, pohead_dropship, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_cohead_id, pohead_released, pohead_shiptoname) FROM stdin;
101723
 
\.
101724
 
 
101725
 
 
101726
 
--
101727
 
--
101728
 
 
101729
 
SELECT pg_catalog.setval('pohead_pohead_id_seq', 344, true);
101730
 
 
101731
 
 
101732
 
--
101733
 
--
101734
 
 
101735
 
COPY poitem (poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_qty_received, poitem_qty_returned, poitem_qty_vouchered, poitem_unitprice, poitem_vend_item_number, poitem_comments, poitem_qty_toreceive, poitem_expcat_id, poitem_itemsrc_id, poitem_freight, poitem_freight_received, poitem_freight_vouchered, poitem_prj_id, poitem_stdcost, poitem_bom_rev_id, poitem_boo_rev_id, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id, poitem_tax_recoverable, poitem_rlsd_duedate, poitem_order_id, poitem_order_type) FROM stdin;
101736
 
\.
101737
 
 
101738
 
 
101739
 
--
101740
 
--
101741
 
 
101742
 
SELECT pg_catalog.setval('poitem_poitem_id_seq', 426, true);
101743
 
 
101744
 
 
101745
 
--
101746
 
--
101747
 
 
101748
 
SELECT pg_catalog.setval('porecv_porecv_id_seq', 127, true);
101749
 
 
101750
 
 
101751
 
--
101752
 
--
101753
 
 
101754
 
COPY poreject (poreject_id, poreject_date, poreject_ponumber, poreject_itemsite_id, poreject_vend_id, poreject_vend_item_number, poreject_vend_item_descrip, poreject_vend_uom, poreject_qty, poreject_posted, poreject_rjctcode_id, poreject_poitem_id, poreject_invoiced, poreject_vohead_id, poreject_agent_username, poreject_voitem_id, poreject_value, poreject_trans_username, poreject_recv_id) FROM stdin;
101755
 
\.
101756
 
 
101757
 
 
101758
 
--
101759
 
--
101760
 
 
101761
 
SELECT pg_catalog.setval('poreject_poreject_id_seq', 41, true);
101762
 
 
101763
 
 
101764
 
--
101765
 
--
101766
 
 
101767
 
COPY potype (potype_id, potype_name, potype_descrip) FROM stdin;
101768
 
\.
101769
 
 
101770
 
 
101771
 
--
101772
 
--
101773
 
 
101774
 
SELECT pg_catalog.setval('potype_potype_id_seq', 1, false);
101775
 
 
101776
 
 
101777
 
--
101778
 
--
101779
 
 
101780
 
COPY pr (pr_id, pr_number, pr_subnumber, pr_status, pr_order_type, pr_order_id, pr_poitem_id, pr_duedate, pr_itemsite_id, pr_qtyreq, pr_prj_id, pr_releasenote, pr_createdate) FROM stdin;
101781
 
\.
101782
 
 
101783
 
 
101784
 
--
101785
 
--
101786
 
 
101787
 
SELECT pg_catalog.setval('pr_pr_id_seq', 185, true);
101788
 
 
101789
 
 
101790
 
--
101791
 
--
101792
 
 
101793
 
COPY prftcntr (prftcntr_id, prftcntr_number, prftcntr_descrip) FROM stdin;
101794
 
\.
101795
 
 
101796
 
 
101797
 
--
101798
 
--
101799
 
 
101800
 
SELECT pg_catalog.setval('prftcntr_prftcntr_id_seq', 1, false);
101801
 
 
101802
 
 
101803
 
--
101804
 
--
101805
 
 
101806
 
COPY priv (priv_id, priv_module, priv_name, priv_descrip, priv_seq) FROM stdin;
101807
 
4       Products        ViewBOMs        Can View Bills of Materials     \N
101808
 
485     System  MaintainPreferencesSelf Can Maintain the preferences for their own user only.   \N
101809
 
486     System  MaintainPreferencesOthers       Can Maintain the preferences of other users.    \N
101810
 
182     Manufacture     ScrapWoMaterials        \N      \N
101811
 
306     Misc.   MaintainShippingChargeTypes     Can Add/Edit/Delete Shipping Charge Types       \N
101812
 
307     Misc.   ViewShippingChargeTypes Can View Shipping Charge Types  \N
101813
 
269     Misc.   MaintainExpenseCategories       Can Add/Edit/Delete Expense Categories  \N
101814
 
270     Misc.   ViewExpenseCategories   Can View Expense Categories     \N
101815
 
362     Misc.   MaintainSalesCategories Can Add/Edit/Delete Sales Categories    \N
101816
 
363     Misc.   ViewSalesCategories     Can View Sales Categories       \N
101817
 
446     CRM     MaintainTitles  Can Add/Edit/Delete Titles (Honorifics).        \N
101818
 
420     CRM     MaintainAddresses       Can Add/Edit/Delete Addresses   \N
101819
 
422     CRM     MaintainCompetitorMasters       Can Add/Edit/Delete Competitor Masters  \N
101820
 
426     CRM     MaintainPartners        Can Add/Edit/Delete Partner Masters     \N
101821
 
429     CRM     MaintainWarrantyTerms   Can Add/Edit/Delete Warranty Terms      \N
101822
 
447     CRM     ViewTitles      Can View Titles (Honorifics).   \N
101823
 
433     CRM     ViewAddresses   Can View Addresses      \N
101824
 
435     CRM     ViewCommLog     Can View the Communications Log \N
101825
 
436     CRM     ViewCompetitorMasters   Can View Competitor Masters     \N
101826
 
441     CRM     ViewPartners    Can View Partner Masters        \N
101827
 
444     CRM     ViewWarrantyTerms       Can View Warranty Terms \N
101828
 
448     CRM     MaintainIncidentCategories      Can Add/Edit/Delete Incident Categories \N
101829
 
449     CRM     MaintainIncidentPriorities      Can Add/Edit/Delete Incident Priorities \N
101830
 
450     CRM     MaintainIncidentSeverities      Can Add/Edit/Delete Incident Severities \N
101831
 
451     CRM     MaintainIncidentResolutions     Can Add/Edit/Delete Incident Resolutions        \N
101832
 
390     Products        PostStandardCosts       Can Post Product Standard Costs \N
101833
 
480     CRM     MaintainOpportunitySources      Can Add/Edit/Delete Opportunity Sources \N
101834
 
481     CRM     MaintainOpportunityStages       Can Add/Edit/Delete Opportunity Stages  \N
101835
 
482     CRM     MaintainOpportunityTypes        Can Add/Edit/Delete Opportunity Types   \N
101836
 
5       Products        MaintainBOMs    Can Add/Edit/Delete Bills of Materials  \N
101837
 
103     Products        EnterActualCosts        Can Enter Free Form Actual Costs        \N
101838
 
104     Products        UpdateActualCosts       Can Update Actual Costs via P/O or P/D  \N
101839
 
105     Products        PostActualCosts Can Post Actual Costs to Standard Costs \N
101840
 
106     Products        ViewCosts       Can View Actual and Standard Costs      \N
101841
 
107     Products        MaintainUserCostingElements     Can Add/Edit/Delete User Costing Elements       \N
101842
 
1       Products        ViewItemMasters Can View Item Masters   \N
101843
 
2       Products        MaintainItemMasters     Can Add/Edit/Delete Item Masters        \N
101844
 
134     Products        MaintainItemGroups      Can Add/Edit/Delete Item Groups \N
101845
 
143     Products        ViewClassCodes  Can View Class Codes    \N
101846
 
144     Products        MaintainClassCodes      Can Add/Edit/Delete Class Codes \N
101847
 
160     Products        ViewItemOptions Can View Item Options   \N
101848
 
31      Products        MaintainProductCategories       Add/Edit/Delete Product Categories      \N
101849
 
161     Products        DeleteCosts     Can Delete Item Costs   \N
101850
 
162     Products        CreateCosts     Can Create User Costs   \N
101851
 
163     Products        ViewProductCategories   Can View Product Categories     \N
101852
 
316     Products        MaintainUOMs    Can Add/Edit/Delete Unit of Measures    \N
101853
 
317     Products        ViewUOMs        Can View Unit of Measures       \N
101854
 
349     Products        DeleteItemMasters       Can Delete Item Masters \N
101855
 
10      Inventory       ViewInventoryHistory    Can View Inventory History      \N
101856
 
30      Inventory       ViewWarehouses  Can View Warehouses     \N
101857
 
29      Inventory       MaintainWarehouses      Can Add/Edit/Delete Warehouses  \N
101858
 
37      Inventory       UpdateABCClass  Can Run Update ABC Class Utility        \N
101859
 
42      Inventory       FreezeInventory Can Freeze Inventory    \N
101860
 
84      Inventory       EnterMiscCounts Can Enter Misc. Counts  \N
101861
 
82      Inventory       IssueCountTags  Can Issue Count Tags    \N
101862
 
83      Inventory       EnterCountTags  Can Enter Count Tags    \N
101863
 
85      Inventory       MaintainLocations       Can Add/Edit/Delete Warehouse Locations \N
101864
 
86      Inventory       ViewLocations   Can View Warehouse Locations    \N
101865
 
90      Inventory       ViewInventoryAvailability       Can View Inventory Availability \N
101866
 
116     Inventory       CreateAdjustmentTrans   Can Create an Adjustment Transaction    \N
101867
 
117     Inventory       CreateScrapTrans        Can Create a Scrap Transaction  \N
101868
 
118     Inventory       CreateReceiptTrans      Can Create a Misc. Receipt Transaction  \N
101869
 
14      Inventory       MaintainItemSites       Can Add/Edit/Delete Item Sites  \N
101870
 
15      Inventory       ViewItemSites   Can View Item Sites     \N
101871
 
128     Inventory       PostCountSlips  Can Post Count Slips    \N
101872
 
129     Inventory       EnterCountSlips Can Create and Enter Count Slips        \N
101873
 
131     Inventory       DeleteCountTags Delete Count Tags       \N
101874
 
130     Inventory       ZeroCountTags   Can Zero Uncounted Count Tags   \N
101875
 
132     Inventory       ViewCountTags   View Count Tags \N
101876
 
133     Inventory       PostCountTags   Can Post Count Tags     \N
101877
 
147     Inventory       PurgeCountSlips Can Purge Posted Count Slips    \N
101878
 
81      Inventory       PurgeCountTags  Cost Purge Posted Count Tags    \N
101879
 
148     Inventory       ViewInventoryValue      Can View Inventory Values       \N
101880
 
19      Inventory       RelocateInventory       Can Relocate Inventory  \N
101881
 
150     Inventory       ViewQOH Can View QOH    \N
101882
 
151     Inventory       UpdateCycleCountFreq    Can Update an Item Site's Cycle Count Frequency \N
101883
 
152     Inventory       UpdateLeadTime  Can Update an Item Site's Lead Time     \N
101884
 
154     Inventory       SummarizeInventoryTransactions  Can Summarized Inventory Transactions   \N
101885
 
153     Inventory       ThawInventory   Can Thaw Inventory      \N
101886
 
35      Inventory       MaintainCostCategories  Can Add/Edit/Delete Cost Categories     \N
101887
 
36      Inventory       ViewCostCategories      Can View Cost Categories        \N
101888
 
164     Inventory       DeleteCountSlips        Can Delete Count Slips  \N
101889
 
214     Inventory       ViewShipping    Can View Stock at Shipping      \N
101890
 
215     Inventory       PrintBillsOfLading      Can Print Bills of Lading       \N
101891
 
217     Inventory       ShipOrders      Can Ship Orders from Shipping   \N
101892
 
218     Inventory       ReturnStockFromShipping Can Return Stock from Shipping  \N
101893
 
517     Accounting      ViewTaxZones    Can view Tax Zones      \N
101894
 
219     Inventory       IssueStockToShipping    Can Issue Stock to Shipping     \N
101895
 
220     Inventory       PurgeShippingRecords    Can Purge Shipping Records      \N
101896
 
223     Inventory       ViewDestinations        Can View Destinations   \N
101897
 
224     Inventory       MaintainDestinations    Can Add/Edit/Delete Destinations        \N
101898
 
225     Inventory       EnterShippingInformation        Can Enter Shipping Information  \N
101899
 
216     Inventory       RecallOrders    Can Recall Orders to Shipping   \N
101900
 
222     Inventory       ViewCarriers    Can View Shippers       \N
101901
 
221     Inventory       MaintainCarriers        Can Add/Edit/Delete Shippers    \N
101902
 
226     Inventory       EnterReceipts   Can Enter Receipts      \N
101903
 
227     Inventory       EnterReturns    Can Enter Returns       \N
101904
 
241     Inventory       UpdateOUTLevels Can Update Order Up To Levels   \N
101905
 
238     Inventory       UpdateReorderLevels     Can Update Reorder Levels       \N
101906
 
255     Inventory       MaintainPackingListBatch        Can Modify Packing List Batch   \N
101907
 
256     Inventory       ViewPackingListBatch    Can View Packing List Batch     \N
101908
 
264     Inventory       MaintainCharacteristics Can Add/Edit/Delete Characteristics     \N
101909
 
265     Inventory       ViewCharacteristics     Can View Characteristics        \N
101910
 
350     Inventory       DeleteItemSites Can Delete Item Sites   \N
101911
 
351     Inventory       CreateExpenseTrans      Can Create an Expense Transaction       \N
101912
 
454     Inventory       RecallInvoicedShipment  Can recall shipments that have already been invoiced.   \N
101913
 
470     Inventory       ViewItemAvailabilityWorkbench   Can View Item Availability Workbench.   \N
101914
 
45      Purchase        ViewVendors     Can View Vendors        \N
101915
 
44      Purchase        MaintainVendors Can Add/Edit/Delete Vendors     \N
101916
 
48      Purchase        MaintainItemSources     Can Add/Edit/Delete P/O Item Sources    \N
101917
 
49      Purchase        ViewItemSources Can View P/O Item Sources       \N
101918
 
53      Purchase        MaintainPurchaseOrders  Can Add/Edit/Delete Purchase Orders     \N
101919
 
54      Purchase        ViewPurchaseOrders      Can View Orders \N
101920
 
46      Purchase        MaintainPlannerCodes    Can Add/Edit/Delete Planner Codes       \N
101921
 
47      Purchase        ViewPlannerCodes        Can View Planner Codes  \N
101922
 
120     Purchase        AssignItemsToPlannerCode        Can Assign Items to a Planner Code      \N
101923
 
189     Purchase        PrintPurchaseOrders     Can Print Purchase Orders       \N
101924
 
204     Purchase        MaintainRejectCodes     Can Add/Edit/Delete Reject Codes        \N
101925
 
205     Purchase        ViewRejectCodes Can View Reject Codes   \N
101926
 
207     Purchase        ViewVendorPerformance   Can View Vendor Performance     \N
101927
 
208     Purchase        ViewCashRequirements    Can View Cash Requirements      \N
101928
 
209     Purchase        ViewPurchaseRequests    Can View Purchase Requests      \N
101929
 
213     Purchase        MaintainPurchaseRequests        Can Add/Edit/Delete Purchase Requests   \N
101930
 
231     Purchase        ViewReceiptsReturns     View Receipts and Returns       \N
101931
 
244     Purchase        ViewBuyCard     Can View Buy Cards      \N
101932
 
245     Purchase        ViewVendorAddresses     Can View Vendor Addresses       \N
101933
 
246     Purchase        MaintainVendorAddresses Can Add/Edit/Delete Vendor Addresses    \N
101934
 
249     Purchase        MaintainVendorTypes     Can Add/Edit/Delete Vendor Types        \N
101935
 
250     Purchase        ViewVendorTypes Can View Vendor Types   \N
101936
 
353     Purchase        ReschedulePurchaseOrders        Can Reschedule Purchase Orders  \N
101937
 
354     Purchase        ChangePurchaseOrderQty  Can Change Purchase Order Item Quantities       \N
101938
 
368     Purchase        MaintainUninvoicedReceipts      Can Mark as invoiced and Correct Receiving on uninvoiced receipts       \N
101939
 
383     Purchase        ViewUninvoicedReceipts  User is allowed to View Uninvoiced Receivings.  \N
101940
 
452     Purchase        MaintainPostedPurchaseOrders    Can Edit Purchase Orders which have already been Posted \N
101941
 
17      Manufacture     ReturnWoMaterials       Can Return Work Order Materials \N
101942
 
16      Manufacture     IssueWoMaterials        Can Issue Work Order Materials  \N
101943
 
91      Manufacture     MaintainWoMaterials     Can Add/Edit/Delete Work Order Materials        \N
101944
 
27      Manufacture     PostProduction  Can Post Production     \N
101945
 
11      Manufacture     ViewWorkOrders  Can View Work Orders    \N
101946
 
93      Manufacture     ViewWoMaterials Can View Work Order Materials   \N
101947
 
12      Manufacture     MaintainWorkOrders      Can Add/Edit/Delete Work Orders \N
101948
 
13      Manufacture     ExplodeWorkOrders       Can Explode Work Orders \N
101949
 
26      Manufacture     ImplodeWorkOrders       Can Implode Work Orders \N
101950
 
75      Manufacture     RescheduleWorkOrders    Can Reschedule Work Orders      \N
101951
 
76      Manufacture     ChangeWorkOrderQty      Can Change Work Order Quantities        \N
101952
 
94      Manufacture     CloseWorkOrders Can Close Work Orders   \N
101953
 
125     Manufacture     PostMiscProduction      Can Make Miscellaneous Production Postings      \N
101954
 
140     Manufacture     PurgeWorkOrders Can Purge Closed Work Orders    \N
101955
 
173     Manufacture     ViewMaterialVariances   Can View W/O Material Variances \N
101956
 
176     Manufacture     PrintWorkOrderPaperWork Can Print Work Order Paper Work \N
101957
 
177     Manufacture     ReleaseWorkOrders       Can Release Work Orders \N
101958
 
178     Manufacture     RecallWorkOrders        Can Recall Work Orders  \N
101959
 
228     Manufacture     DeleteWorkOrders        Can Delete Open Work Orders     \N
101960
 
352     Manufacture     ReprioritizeWorkOrders  Can Reprioritize Work Orders    \N
101961
 
408     Manufacture     ChangeNonPickItems      Can change the Issue Items Not On Pick List flag on Post Production.    \N
101962
 
409     Manufacture     ChangeReceiveInventory  Can change the Receive Inventory List flag on Post Operations.  \N
101963
 
22      Sales   MaintainCustomerMasters Can Add/Edit/Delete Customer Masters    \N
101964
 
23      Sales   ViewCustomerMasters     Can View Customer Masters       \N
101965
 
51      Sales   ViewShipVias    Can View Ship Via's     \N
101966
 
55      Sales   ViewCustomerTypes       Can View Customer Types \N
101967
 
56      Sales   MaintainCustomerTypes   Can Add/Edit/Delete Customer Types      \N
101968
 
57      Sales   ViewSalesReps   Can View Sales Reps.    \N
101969
 
58      Sales   MaintainSalesReps       Can Add/Edit/Delete Sales Reps. \N
101970
 
61      Sales   ViewTerms       Can View Terms  \N
101971
 
59      Sales   MaintainTaxCodes        Can Add/Edit/Delete Tax Codes   \N
101972
 
60      Sales   ViewTaxCodes    Can View Tax Codes      \N
101973
 
50      Sales   MaintainShipVias        Can Add/Edit/Delete Ship Via's  \N
101974
 
88      Sales   MaintainShiptos Can Add/Edit/Delete Ship-Tos    \N
101975
 
89      Sales   ViewShiptos     Can View Ship-Tos       \N
101976
 
111     Sales   OverridePrice   Can Override Item Sales Prices  \N
101977
 
126     Sales   MaintainSalesAccount    Can Add/Edit/Delete Sales Account Assignments   \N
101978
 
127     Sales   ViewSalesAccount        Can View Sales Account Assignments      \N
101979
 
141     Sales   MaintainSalesOrders     Can Add/Edit/Delete Sales Orders        \N
101980
 
142     Sales   ViewSalesOrders Can View Sales Orders   \N
101981
 
180     Sales   MaintainPricingSchedules        Can Add/Edit/Delete Pricing Schedules   \N
101982
 
181     Sales   ViewPricingSchedules    Can View Pricing Schedules      \N
101983
 
190     Sales   SelectBilling   Can Select an Order for Billing \N
101984
 
192     Sales   MaintainShippingForms   Can Add/Edit/Delete Shipping Forms      \N
101985
 
193     Sales   MaintainShippingZones   Can Add/Edit/Delete Shipping Zones      \N
101986
 
194     Sales   AssignPricingSchedules  Can Assign Pricing Schedules    \N
101987
 
195     Sales   CreateSales     Can Create Sales        \N
101988
 
196     Sales   UpdatePricingSchedules  Can Update Pricing Schedules    \N
101989
 
197     Sales   MaintainCreditMemos     Can Add/Edit/Delete Unposted Credit Memos       \N
101990
 
198     Sales   ViewCreditMemos Can View Unposted Credit Memos  \N
101991
 
199     Sales   PrintCreditMemos        Print Credit Memos      \N
101992
 
200     Sales   PurgeCreditMemos        Purge Credit Memos      \N
101993
 
201     Sales   PurgeInvoices   Purge Invoices  \N
101994
 
232     Sales   MaintainQuotes  Can Add/Edit/Delete Quotes      \N
101995
 
203     Sales   ViewCommissions Can View Earned Commissions     \N
101996
 
233     Sales   ViewQuotes      Can View Quotes \N
101997
 
70      Sales   ViewCustomerPrices      Can View Customer Type Prices   \N
101998
 
234     Sales   ConvertQuotes   Can Convert Quotes to Sales Orders      \N
101999
 
235     Sales   PrintPackingLists       \N      \N
102000
 
211     Sales   ViewShippingZones       Can View Shipping Zones \N
102001
 
212     Sales   ViewSalesHistory        \N      \N
102002
 
239     Sales   PrintQuotes     Can Print Quotes        \N
102003
 
242     Sales   OverrideSODate  Can Override S/O Enter Dates    \N
102004
 
257     Sales   MaintainCustomerGroups  Can Add/Edit/Delete/Modify Customer Groups      \N
102005
 
258     Sales   ViewCustomerGroups      Can View Customer Groups        \N
102006
 
273     Sales   MaintainListPrices      Can Modify List Prices  \N
102007
 
274     Sales   ViewListPrices  Can View List Prices    \N
102008
 
281     Sales   EditSalesHistory        Can Edit Posted Sales History   \N
102009
 
336     Sales   CreateSOForHoldCustomer Can Create an Sales Order for a Customer on Credit Hold \N
102010
 
337     Sales   CreateSOForWarnCustomer Can Create an Sales Order for a Customer on Credit Warning      \N
102011
 
346     Sales   UpdateCustomerCreditStatus      Can Update a Customer's Credit Status   \N
102012
 
347     Sales   ArchiveSalesHistory     Can Archive Sales History       \N
102013
 
348     Sales   RestoreSalesHistory     Can Restore Sales History       \N
102014
 
355     Sales   AlterPackDate   Can Alter a Sales Order Pack Date       \N
102015
 
385     Sales   MaintainCustomerMastersCustomerType     Users are allowed to edit the Customer Type for a customer.     \N
102016
 
386     Sales   MaintainCustomerMastersCustomerTypeOnCreate     Users are allowed to edit the Customer Type for a customer when creating a new customer.        \N
102017
 
389     Sales   AllowSelectOrderEditing Users are allowed to edit some additional information on the Select Order for Billing screen.   \N
102018
 
393     Sales   ShowMarginsOnSalesOrder Users will see the margins on the Sales Order and Quote Screens for that older. \N
102019
 
459     Sales   MaintainProspectMasters Can Add/Edit/Delete Prospect information.       \N
102020
 
460     Sales   ViewProspectMasters     Can View Prospect information.  \N
102021
 
179     Accounting      MaintainChartOfAccounts Can Add/Edit/Delete Accounts in the Chart of Accounts   \N
102022
 
251     Accounting      MaintainStandardJournals        Can Add/Edit/Delete Standard Journals   \N
102023
 
252     Accounting      ViewStandardJournals    Can View Standard Journals      \N
102024
 
254     Accounting      PostStandardJournals    Can Post Standard Journals      \N
102025
 
260     Accounting      MaintainVendorAccounts  Can Add/Edit/Delete Vendor Account Assignments  \N
102026
 
261     Accounting      ViewVendorAccounts      Can View Vendor Account Assignments     \N
102027
 
262     Accounting      MaintainCheckFormats    Can Add/Edit/Delete A/P Check Formats   \N
102028
 
263     Accounting      ViewCheckFormats        Can View A/P Check Formats      \N
102029
 
266     Accounting      MaintainStandardJournalGroups   Can Add/Edit/Delete Standard Journal Groups     \N
102030
 
267     Accounting      ViewStandardJournalGroups       Can View Standard Journal Groups        \N
102031
 
268     Accounting      PostStandardJournalGroups       Can Post Standard Journal Groups        \N
102032
 
271     Accounting      MaintainAccountingPeriods       Can Add/Edit/Delete Accounting Periods  \N
102033
 
272     Accounting      ViewAccountingPeriods   Can View Accounting Periods     \N
102034
 
275     Accounting      MaintainARMemos Can Add/Edit/Delete A/R Credit/Demo Memos       \N
102035
 
276     Accounting      ViewARMemos     Can View A/R Credit/Demo Memos  \N
102036
 
277     Accounting      ApplyARMemos    Can Apply A/R Credit/Demo Memos \N
102037
 
278     Accounting      MaintainMiscInvoices    Can Add/Edit/Delete Misc. Invoices      \N
102038
 
279     Accounting      ViewMiscInvoices        Can View Misc. Invoices \N
102039
 
280     Accounting      PostMiscInvoices        Can Post Misc. Invoices \N
102040
 
294     Accounting      PostJournalEntries      Can Post Journal Entries        \N
102041
 
297     Accounting      ViewGLTransactions      Can View G/L Transactions       \N
102042
 
298     Accounting      ViewTrialBalances       Can View Trial Balances \N
102043
 
302     Accounting      MaintainCashReceipts    Can Add/Edit/Delete Cash Receipts       \N
102044
 
303     Accounting      ViewCashReceipts        Can View Cash Receipts  \N
102045
 
305     Accounting      PostCashReceipts        Can Post Cash Receipts  \N
102046
 
369     Accounting      MaintainPayments        Can Maintain Payment and Check information.     \N
102047
 
370     Accounting      ViewAPOpenItems Can view A/P Open Item infomation and related screens that use that information.        \N
102048
 
313     Accounting      MaintainFinancialLayouts        Can Add/Edit/Delete Financial Layouts   \N
102049
 
314     Accounting      ViewFinancialLayouts    Can View Financial Layouts      \N
102050
 
315     Accounting      ViewFinancialReports    Can View Financial Reports      \N
102051
 
371     Accounting      PrintAPJournals Can view A/P Open Item infomation and related screens that use that information.        \N
102052
 
372     Accounting      ViewAROpenItems Can view A/R Open Item infomation and related screens that use that information.        \N
102053
 
334     Accounting      EditAPOpenItem  Can Edit A/P Open Items \N
102054
 
335     Accounting      EditAROpenItem  Can Edit A/R Open Items \N
102055
 
373     Accounting      PrintARJournals Can view A/R Open Item infomation and related screens that use that information.        \N
102056
 
374     Accounting      MaintainAdjustmentTypes Can Add/Edit/Delete Adjustment Types    \N
102057
 
375     Accounting      ViewAdjustmentTypes     Can View Adjustment Types       \N
102058
 
376     Accounting      MaintainBankAdjustments Can Add/Edit/Delete Bank Adjustments    \N
102059
 
377     Accounting      ViewBankAdjustments     Can View Bank Adjustments       \N
102060
 
378     Accounting      PostBankAdjustments     Can Post Bank Adjustments       \N
102061
 
356     Accounting      MaintainAPMemos Can Add/Edit/Post A/P Memos     \N
102062
 
357     Accounting      ViewAPMemos     Can View A/P Memos      \N
102063
 
358     Accounting      ApplyAPMemos    Can Apply A/P Memos     \N
102064
 
379     Accounting      MaintainBankRec Can Maintain Bank Reconciliations       \N
102065
 
380     Accounting      ViewBankRec     Can View Bank Reconciliation Information        \N
102066
 
382     Accounting      MaintainReasonCodes     User is allowed to maintain the Reason Codes.   \N
102067
 
395     Accounting      CreateNewCurrency       Create New Currencies   \N
102068
 
396     Accounting      MaintainCurrencies      Modify Existing Currencies      \N
102069
 
397     Accounting      MaintainCurrencyRates   Add and Modify Currency Exchange Rates  \N
102070
 
398     Accounting      ViewCurrencyRates       View Currency Exchange Rates    \N
102071
 
407     Accounting      VoidPostedAPCheck       Can void a posted A/P Check.    \N
102072
 
455     Accounting      ChangeARInvcDistDate    Can distribute an Invoice to the G/L using a date other than the Invoice Date   \N
102073
 
456     Accounting      ChangePORecvPostDate    Can post a Purchase Order Receipt to the G/L using a date other than the actual Receipt Date    \N
102074
 
457     Accounting      ChangeSOMemoPostDate    Can post a Sales Order Credit Memo to the G/L using a date other than the Credit Memo Document Date     \N
102075
 
458     Accounting      ChangeVOPostDate        Can post a Voucher to the G/L using a date other than the Voucher Distribution Date     \N
102076
 
461     Accounting      MaintainTaxAuthorities  Can Add/Edit/Delete Tax Authorities.    \N
102077
 
462     Accounting      ViewTaxAuthorities      Can View Tax Authorities.       \N
102078
 
463     Accounting      MaintainTaxTypes        Can Add/Edit/Delete Tax Types.  \N
102079
 
464     Accounting      ViewTaxTypes    Can View Tax Types.     \N
102080
 
467     Accounting      OverrideTax     Can manually override the system-selected Tax Code and/or tax % for individual Invoice line items.      \N
102081
 
468     Accounting      MaintainTaxReconciliations      Can Add/Edit/Delete unposted Tax Reconciliation records and associated data.    \N
102082
 
469     Accounting      ViewTaxReconciliations  Can View Tax Reconciliation records and associated data.        \N
102083
 
475     Accounting      MaintainBudgets Can maintain budget information \N
102084
 
476     Accounting      ViewBudgets     Can view budget information, not affecting FRE ability to view budgets. \N
102085
 
100     System  DispatchOtherEvents     Can Dispatch Other User's Events        \N
102086
 
63      System  ConfigureIM     Configure I/M Module Parameters \N
102087
 
64      System  ConfigurePO     Configure P/O Module Parameters \N
102088
 
65      System  ConfigurePD     Configure P/D Module Parameters \N
102089
 
73      System  ConfigDatabaseInfo      Can Configure the Database Information  \N
102090
 
121     System  DeleteOwnEvents Can Delete Own Events   \N
102091
 
122     System  DeleteOtherEvents       Can Delete Other Users' Events  \N
102092
 
101     System  ViewOtherEvents Can View Other User's Events    \N
102093
 
87      System  ConfigureWO     Configure S/O Module Parameters \N
102094
 
123     System  DispatchOwnEvents       Can Dispatch Own Events \N
102095
 
124     System  ConfigureSR     Configure S/R Module Parameters \N
102096
 
68      System  ConfigureSO     Configure S/O Module Parameters \N
102097
 
166     System  MaintainImages  Can Add/Edit/Delete Images      \N
102098
 
167     System  MaintainReports Can Add/Edit/Delete Reports     \N
102099
 
168     System  MaintainForms   Can Add/Edit/Delete Forms       \N
102100
 
169     System  MaintainCalendars       Can Add/Edit/Delete Calendars   \N
102101
 
170     System  MaintainLocales Can Add/Edit/Delete Locales     \N
102102
 
236     System  ConfigureGL     Can Configure the G/L Module    \N
102103
 
248     System  ConfigureAR     Can Configure the A/R Module    \N
102104
 
253     System  MaintainBankAccounts    Can Add/Edit/Delete Bank Accounts       \N
102105
 
3       System  MaintainUsers   Can Add/Edit/List Users \N
102106
 
345     System  MaintainCommentTypes    Can Add/Edit/Delete Comment Types       \N
102107
 
359     System  ConfigureAP     Can Configure the A/P Module    \N
102108
 
388     System  ConfigureCC     User is allowed to alter the Credit Card Configuration. \N
102109
 
394     System  ConfigurePM     Users will be able to view and edit the configuration options for the P/M Module.       \N
102110
 
399     System  MaintainCustomCommands  User can Create/Edit/View Custom commands       \N
102111
 
403     System  MaintainDepartments     Can create and modify Department definitions.   \N
102112
 
404     System  ViewDepartments Can view Department definitions.        \N
102113
 
406     System  ViewShifts      Can view Shift definitions.     \N
102114
 
445     System  ConfigureCRM    Can change the CRM configuration module options.        \N
102115
 
453     System  MaintainCountries       Can Add/Edit/Delete Country information.        \N
102116
 
471     System  FixSerial       Can fix problems with serial values used to assign primary keys.        \N
102117
 
487     Accounting      PostPayments    Can Post Payments/Checks.       \N
102118
 
488     Accounting      ViewDepositsRegister    Can view the Deposits Register. \N
102119
 
489     Accounting      ViewInvoiceRegister     Can view the Invoice Register.  \N
102120
 
490     System  ConfigureImportExport   Can Change or Create Settings For Importing and Exporting Data  \N
102121
 
491     System  ImportXML       Can Import Data From XML Sources        \N
102122
 
187     Accounting      MaintainVouchers        Can Add/Edit/Delete Vouchers    \N
102123
 
188     Accounting      PostVouchers    Can Post Vouchers       \N
102124
 
259     Accounting      ViewVouchers    Can View Vouchers       \N
102125
 
492     Accounting      ProcessCreditCards      Can Process Credit Card Transactions    \N
102126
 
498     System  MaintainScripts Can Change or Create Scripts that are executed by windows when they are opened. \N
102127
 
500     Inventory       AlterTransactionDates   Can set the Transaction Date written to the G/L and Inventory History tables for inventory transactions.        \N
102128
 
501     System  MaintainEmployees       Can Change or Create Employee records.  \N
102129
 
502     System  ViewEmployees   Can view Employee records.      \N
102130
 
503     System  MaintainGroups  Can Change or Create Settings For Groups        \N
102131
 
504     System  MaintainEmployeeGroups  Can Change or Create Employee Groups.   \N
102132
 
505     System  ViewEmployeeGroups      Can view Employee Group records.        \N
102133
 
499     System  MaintainScreens Can Change or Create UI Forms that are executed by custom windows when they are opened. \N
102134
 
506     Inventory       MaintainExternalShipping        Can Change or Create External Shipping Records. \N
102135
 
507     System  fixACL  Can fix Access Control List problems at the database level.     \N
102136
 
509     System  ViewPackages    Can View installed Packages.    \N
102137
 
510     Accounting      SynchronizeCompanies    Can run company trial balance synchronization utility.  \N
102138
 
511     Inventory       MaintainSiteTypes       Can Change or Create Settings For Site Types    \N
102139
 
512     Inventory       ViewSiteTypes   Can View Settings For Site Types        \N
102140
 
62      Accounting      MaintainTerms   Can Add/Edit/Delete Terms       \N
102141
 
191     Accounting      PrintInvoices   Can Print Invoices      \N
102142
 
202     Accounting      PostARDocuments Can Post Invoices and Credit Memos      \N
102143
 
513     Products        MaintainFreightClasses  Can Add/Edit/Delete Freight Classes     \N
102144
 
514     Products        ViewFreightClasses      Can View Freight Classes        \N
102145
 
515     Sales   FirmSalesOrder  Can Firm a Sales Order line item to prevent editing     \N
102146
 
516     CRM     EditOwner       Can Edit Owner in CRM documents \N
102147
 
518     Accounting      MaintainTaxZones        Can Add/Edit/Delete Tax Zones   \N
102148
 
519     Accounting      ViewTaxClasses  Can view Tax Classes    \N
102149
 
520     Accounting      MaintainTaxClasses      Can Add/Edit/Delete Tax Classes \N
102150
 
522     System  EditOwnComments User is allowed to edit comments they have entered that are of an editable comment type.        \N
102151
 
523     System  EditOthersComments      User is allowed to edit iany comments entered that are of an editable comment type.     \N
102152
 
465     Accounting      MaintainTaxAssignments  Can Add/Edit/Delete Tax Assignments     \N
102153
 
466     Accounting      ViewTaxAssignments      Can View Tax Assignments        \N
102154
 
524     System  MaintainStates  User is allowed to edit the list of States and Provinces        \N
102155
 
525     System  MaintainMetaSQL User is allowed to edit MetaSQL statements with the MetaSQL editor.     \N
102156
 
526     System  ViewMetaSQL     User is allowed to view MetaSQL statements with the MetaSQL editor.     \N
102157
 
527     System  ExecuteMetaSQL  User is allowed to execute MetaSQL statements with the MetaSQL editor that change the database. \N
102158
 
137     Purchase        ReleasePurchaseOrders   Can Release Purchase Orders     \N
102159
 
528     Sys     ConfigureEncryption     Allowed to view and change the Encryption Key File      \N
102160
 
529     System  ExportXML       Can Export XML Files    \N
102161
 
604     Accounting      DeletePostedJournals    Can delete posted Standard Journals and Journal Entries \N
102162
 
605     Accounting      EditPostedJournals      Can edit posted Journal Entries \N
102163
 
606     Accounting      ViewJournals    Can view Journals       \N
102164
 
607     Accounting      PostJournals    Can post Journals       \N
102165
 
619     CRM     MergeContacts   Can use Contact Merge utility   \N
102166
 
620     System  MaintainTranslations    User is allowed to maintain/download translations to their local computer.      \N
102167
 
621     System  MaintainDictionaries    User is allowed to maintain/download spell check dictionaries to their local computer.  \N
102168
 
431     CRM     ReassignToDoItems       Can Reassign ToDoItems to other people  \N
102169
 
416     CRM     CloseAllIncidents       Can Close all Incidents after confirming that it has been satisfactorily resolved       \N
102170
 
631     CRM     ClosePersonalIncidents  Can Incidents when Owner or Assigned after confirming that it has been resolved \N
102171
 
425     CRM     MaintainAllToDoItems    Can Add/Edit/Delete all ToDoItems       0
102172
 
423     CRM     MaintainAllContacts     Can Add/Edit/Delete all Contacts        0
102173
 
419     CRM     MaintainAllCRMAccounts  Can Add/Edit/Delete all CRM Accounts    0
102174
 
483     CRM     MaintainAllOpportunities        Can Add/Edit/Delete all Opportunities   0
102175
 
424     CRM     MaintainAllIncidents    Can Add/Edit/Delete all Incidents       0
102176
 
392     CRM     MaintainAllProjects     Can Add/Edit/Delete all Projects        0
102177
 
440     CRM     ViewAllToDoItems        Can View all ToDoItems  1
102178
 
437     CRM     ViewAllContacts Can View all Contacts   1
102179
 
432     CRM     ViewAllCRMAccounts      Can View all CRM Accounts       1
102180
 
484     CRM     ViewAllOpportunities    Can View all Opportunities      1
102181
 
439     CRM     ViewAllIncidents        Can View all Incidents  1
102182
 
391     CRM     ViewAllProjects Can View all Projects   1
102183
 
427     CRM     MaintainPersonalToDoItems       Can Add/Edit/Delete ToDoItems when Owner or Assigned    2
102184
 
623     CRM     MaintainPersonalContacts        Can Add/Edit/Delete Contacts when Owner or Assigned     2
102185
 
625     CRM     MaintainPersonalCRMAccounts     Can Add/Edit/Delete CRM Accounts when Owner or Assigned 2
102186
 
627     CRM     MaintainPersonalOpportunities   Can Add/Edit/Delete Opportunities when Owner or Assigned        2
102187
 
629     CRM     MaintainPersonalIncidents       Can Add/Edit/Delete Incidents when Owner or Assigned    2
102188
 
633     CRM     MaintainPersonalProjects        Can Add/Edit/Delete Projects when Owner or Assigned     2
102189
 
442     CRM     ViewPersonalToDoItems   Can View ToDoItems when Owner or Assigned       4
102190
 
622     CRM     ViewPersonalContacts    Can View Contacts when Owner or Assigned        4
102191
 
624     CRM     ViewPersonalCRMAccounts Can View CRM Accounts when Owner or Assigned    4
102192
 
626     CRM     ViewPersonalOpportunities       Can View Opportunities when Owner or Assigned   4
102193
 
628     CRM     ViewPersonalIncidents   Can View Incidents when Owner or Assigned       4
102194
 
630     CRM     ViewPersonalIncidentHistory     Can View Incident History when Owner or Assigned        4
102195
 
632     CRM     ViewPersonalProjects    Can View Projects when Owner or Assigned        4
102196
 
634     Accounting      VoidPostedVouchers      Can void posted A/P Vouchers.   \N
102197
 
635     Accounting      VoidPostedARCreditMemos Can void posted A/R Credit Memos.       \N
102198
 
636     Accounting      VoidPostedInvoices      Can void posted A/R Invoices.   \N
102199
 
521     Accounting      VoidPostedCashReceipts  Can void posted A/R Cash Receipts.      \N
102200
 
637     Accounting      MaintainTaxRegistrations        Can Add/Edit/Delete Tax Registrations.  \N
102201
 
638     Accounting      ViewTaxRegistrations    Can View Tax Registrations.     \N
102202
 
639     Accounting      PostFrozenPeriod        Can Post into frozen Accounting Period  \N
102203
 
644     Sales   MaintainSaleTypes       Can Add/Edit/Delete Sale Types. \N
102204
 
645     Sales   ViewSaleTypes   Can View Sale Types.    \N
102205
 
648     Sales   ConvertQuotesInvoice    Can Convert Quote to Invoice.   \N
102206
 
649     System  MaintainRegistrationKey Can Configure the Registration Key.     \N
102207
 
651     CRM     MaintainProjectTypes    Maintain Project Types  \N
102208
 
650     Purchase        UnreleasePurchaseOrders Can Unrelease Purchase Orders.  \N
102209
 
652     Accounting      ChangeCashRecvPostDate  Can change the distribution date when posting Cash Receipts     \N
102210
 
\.
102211
 
 
102212
 
 
102213
 
--
102214
 
--
102215
 
 
102216
 
SELECT pg_catalog.setval('priv_priv_id_seq', 652, true);
102217
 
 
102218
 
 
102219
 
--
102220
 
--
102221
 
 
102222
 
COPY prj (prj_id, prj_number, prj_name, prj_descrip, prj_status, prj_so, prj_wo, prj_po, prj_owner_username, prj_start_date, prj_due_date, prj_assigned_date, prj_completed_date, prj_username, prj_recurring_prj_id, prj_crmacct_id, prj_cntct_id, prj_prjtype_id) FROM stdin;
102223
 
\.
102224
 
 
102225
 
 
102226
 
--
102227
 
--
102228
 
 
102229
 
SELECT pg_catalog.setval('prj_prj_id_seq', 1, false);
102230
 
 
102231
 
 
102232
 
--
102233
 
--
102234
 
 
102235
 
COPY prjtask (prjtask_id, prjtask_number, prjtask_name, prjtask_descrip, prjtask_prj_id, prjtask_anyuser, prjtask_status, prjtask_hours_budget, prjtask_hours_actual, prjtask_exp_budget, prjtask_exp_actual, prjtask_owner_username, prjtask_start_date, prjtask_due_date, prjtask_assigned_date, prjtask_completed_date, prjtask_username) FROM stdin;
102236
 
\.
102237
 
 
102238
 
 
102239
 
--
102240
 
--
102241
 
 
102242
 
SELECT pg_catalog.setval('prjtask_prjtask_id_seq', 1, false);
102243
 
 
102244
 
 
102245
 
--
102246
 
--
102247
 
 
102248
 
COPY prjtaskuser (prjtaskuser_id, prjtaskuser_prjtask_id, prjtaskuser_username) FROM stdin;
102249
 
\.
102250
 
 
102251
 
 
102252
 
--
102253
 
--
102254
 
 
102255
 
SELECT pg_catalog.setval('prjtaskuser_prjtaskuser_id_seq', 1, false);
102256
 
 
102257
 
 
102258
 
--
102259
 
--
102260
 
 
102261
 
COPY prjtype (prjtype_id, prjtype_code, prjtype_descr, prjtype_active) FROM stdin;
102262
 
1       Standard        Standard Projects       t
102263
 
\.
102264
 
 
102265
 
 
102266
 
--
102267
 
--
102268
 
 
102269
 
SELECT pg_catalog.setval('prjtype_prjtype_id_seq', 1, false);
102270
 
 
102271
 
 
102272
 
--
102273
 
--
102274
 
 
102275
 
COPY prodcat (prodcat_id, prodcat_code, prodcat_descrip) FROM stdin;
102276
 
\.
102277
 
 
102278
 
 
102279
 
--
102280
 
--
102281
 
 
102282
 
SELECT pg_catalog.setval('prodcat_prodcat_id_seq', 27, true);
102283
 
 
102284
 
 
102285
 
--
102286
 
--
102287
 
 
102288
 
COPY prospect (prospect_id, prospect_active, prospect_number, prospect_name, prospect_cntct_id, prospect_comments, prospect_created, prospect_salesrep_id, prospect_warehous_id, prospect_taxzone_id) FROM stdin;
102289
 
\.
102290
 
 
102291
 
 
102292
 
--
102293
 
--
102294
 
 
102295
 
COPY qryhead (qryhead_id, qryhead_name, qryhead_descrip, qryhead_notes, qryhead_username, qryhead_updated) FROM stdin;
102296
 
\.
102297
 
 
102298
 
 
102299
 
--
102300
 
--
102301
 
 
102302
 
SELECT pg_catalog.setval('qryhead_qryhead_id_seq', 1, false);
102303
 
 
102304
 
 
102305
 
--
102306
 
--
102307
 
 
102308
 
COPY qryitem (qryitem_id, qryitem_qryhead_id, qryitem_name, qryitem_order, qryitem_src, qryitem_group, qryitem_detail, qryitem_notes, qryitem_username, qryitem_updated) FROM stdin;
102309
 
\.
102310
 
 
102311
 
 
102312
 
--
102313
 
--
102314
 
 
102315
 
SELECT pg_catalog.setval('qryitem_qryitem_id_seq', 1, false);
102316
 
 
102317
 
 
102318
 
--
102319
 
--
102320
 
 
102321
 
COPY quhead (quhead_id, quhead_number, quhead_cust_id, quhead_quotedate, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptophone, quhead_salesrep_id, quhead_terms_id, quhead_freight, quhead_ordercomments, quhead_shipcomments, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_commission, quhead_custponumber, quhead_fob, quhead_shipvia, quhead_warehous_id, quhead_packdate, quhead_prj_id, quhead_misc, quhead_misc_accnt_id, quhead_misc_descrip, quhead_billtocountry, quhead_shiptocountry, quhead_curr_id, quhead_imported, quhead_expire, quhead_calcfreight, quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name, quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title, quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle, quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone, quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email, quhead_taxzone_id, quhead_taxtype_id, quhead_ophead_id, quhead_status, quhead_saletype_id, quhead_shipzone_id) FROM stdin;
102322
 
\.
102323
 
 
102324
 
 
102325
 
--
102326
 
--
102327
 
 
102328
 
SELECT pg_catalog.setval('quhead_quhead_id_seq', 86, true);
102329
 
 
102330
 
 
102331
 
--
102332
 
--
102333
 
 
102334
 
COPY quitem (quitem_id, quitem_quhead_id, quitem_linenumber, quitem_itemsite_id, quitem_scheddate, quitem_qtyord, quitem_unitcost, quitem_price, quitem_custprice, quitem_memo, quitem_custpn, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_imported, quitem_qty_uom_id, quitem_qty_invuomratio, quitem_price_uom_id, quitem_price_invuomratio, quitem_promdate, quitem_taxtype_id, quitem_dropship, quitem_itemsrc_id, quitem_pricemode) FROM stdin;
102335
 
\.
102336
 
 
102337
 
 
102338
 
--
102339
 
--
102340
 
 
102341
 
SELECT pg_catalog.setval('quitem_quitem_id_seq', 89, true);
102342
 
 
102343
 
 
102344
 
--
102345
 
--
102346
 
 
102347
 
COPY rcalitem (rcalitem_id, rcalitem_calhead_id, rcalitem_offsettype, rcalitem_offsetcount, rcalitem_periodtype, rcalitem_periodcount, rcalitem_name) FROM stdin;
102348
 
\.
102349
 
 
102350
 
 
102351
 
--
102352
 
--
102353
 
 
102354
 
COPY recur (recur_id, recur_parent_id, recur_parent_type, recur_period, recur_freq, recur_start, recur_end, recur_max, recur_data) FROM stdin;
102355
 
\.
102356
 
 
102357
 
 
102358
 
--
102359
 
--
102360
 
 
102361
 
SELECT pg_catalog.setval('recur_recur_id_seq', 1, false);
102362
 
 
102363
 
 
102364
 
--
102365
 
--
102366
 
 
102367
 
COPY recurtype (recurtype_id, recurtype_type, recurtype_table, recurtype_donecheck, recurtype_schedcol, recurtype_limit, recurtype_copyfunc, recurtype_copyargs, recurtype_delfunc) FROM stdin;
102368
 
4       I       invchead        invchead_posted invchead_invcdate       \N      copyinvoice     {integer,date}  deleteinvoice
102369
 
3       J       prj     (prj_completed_date IS NOT NULL OR prj_status = 'C')    prj_due_date    \N      copyprj {int,date}      \N
102370
 
5       V       vohead  vohead_posted   vohead_docdate  \N      copyvoucher     {integer,date}  \N
102371
 
2       INCDT   incdt   incdt_status IN ('R', 'L')      incdt_timestamp \N      copyincdt       {int,timestamp} deleteincident
102372
 
1       TODO    todoitem        todoitem_completed_date IS NOT NULL     todoitem_due_date       checkprivilege('MaintainAllToDoItems') OR (checkprivilege('MaintainPersonalToDoItems') AND CURRENT_USER IN (todoitem_owner_username, todoitem_username))        copytodoitem    {int,date,NULL} \N
102373
 
\.
102374
 
 
102375
 
 
102376
 
--
102377
 
--
102378
 
 
102379
 
SELECT pg_catalog.setval('recurtype_recurtype_id_seq', 5, true);
102380
 
 
102381
 
 
102382
 
--
102383
 
--
102384
 
 
102385
 
COPY recv (recv_id, recv_order_type, recv_order_number, recv_orderitem_id, recv_agent_username, recv_itemsite_id, recv_vend_id, recv_vend_item_number, recv_vend_item_descrip, recv_vend_uom, recv_purchcost, recv_purchcost_curr_id, recv_duedate, recv_qty, recv_recvcost, recv_recvcost_curr_id, recv_freight, recv_freight_curr_id, recv_date, recv_value, recv_posted, recv_invoiced, recv_vohead_id, recv_voitem_id, recv_trans_usr_name, recv_notes, recv_gldistdate, recv_splitfrom_id, recv_rlsd_duedate) FROM stdin;
102386
 
\.
102387
 
 
102388
 
 
102389
 
--
102390
 
--
102391
 
 
102392
 
SELECT pg_catalog.setval('recv_recv_id_seq', 1, true);
102393
 
 
102394
 
 
102395
 
--
102396
 
--
102397
 
 
102398
 
COPY report (report_id, report_name, report_sys, report_source, report_descrip, report_grade, report_loaddate) FROM stdin;
102399
 
453     BacklogByParameterList  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Backlog By Parameter List</title>\n <name>BacklogByParameterList</name>\n <description></description>\n <parameter default="01-01-2020" active="true" listtype="static" type="string" name="endDate">\n  <description></description>\n </parameter>\n <parameter default="t" active="true" listtype="static" type="string" name="showPrices">\n  <description></description>\n </parameter>\n <parameter default="01-01-1990" active="true" listtype="static" type="string" name="startDate">\n  <description></description>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT CASE WHEN (checkPrivilege('ViewCustomerPrices') \n             AND isMultiCurr()) THEN\n         text('Amount(base)')\n       WHEN (checkPrivilege('ViewCustomerPrices')) THEN\n         text('Amount')\n       ELSE\n         text('')\n       END\n       AS lbl_baseamount,\n       CASE WHEN (checkPrivilege('ViewCustomerPrices') \n         AND isMultiCurr()) THEN\n         text('Amount(foreign)')\n       ELSE\n         text('')\n       END\n       AS lbl_foreignamount;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT cohead_number, coitem_linenumber, cust_name,\n       formatDate(cohead_orderdate) AS f_orderdate,\n       formatDate(coitem_scheddate) AS f_scheddate,\n       item_number, uom_name,\n       item_descrip1, item_descrip2,\n       formatQty(coitem_qtyord) AS f_qtyord,\n       formatQty(coitem_qtyshipped) AS f_qtyship,\n       formatQty(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) AS f_balance, \n       CASE WHEN (checkPrivilege('ViewCustomerPrices')) THEN\nformatMoney(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n                * (currtobase(cohead_curr_id,coitem_price,cohead_orderdate) / coitem_price_invuomratio),2))\n       ELSE\n         text('')\n       END\n       AS f_ammount,\n       CASE WHEN (checkPrivilege('ViewCustomerPrices') AND isMultiCurr()) THEN\nformatMoney(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n                * (coitem_price / coitem_price_invuomratio),2))\n       ELSE\n         text('')\n       END\n       AS foreign_ammount,\nround((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n    * (currtobase(cohead_curr_id,coitem_price,cohead_orderdate) / coitem_price_invuomratio),2) AS backlog \n  FROM cohead, coitem, itemsite, item, cust, uom\n WHERE ((coitem_cohead_id=cohead_id)\n   AND (cohead_cust_id=cust_id)\n   AND (coitem_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (coitem_status='O')\n  &lt;? if exists("cohead_id") ?>\n    AND  (coitem_cohead_id=&lt;? value("cohead_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("startDate") ?>\n    AND  (cohead_orderdate >= &lt;? value("startDate") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("endDate") ?>\n    AND  (cohead_orderdate &lt;= &lt;? value("endDate") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("startDateSched") ?>\n    AND  (coitem_scheddate >= &lt;? value("startDateSched") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("endDateSched") ?>\n    AND  (coitem_scheddate >= &lt;? value("endDateSched") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("salesrep_id") ?>\n    AND  (cohead_salesrep_id=&lt;? value("salesrep_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("shipto_id") ?>\n    AND  (cohead_shipto_id=&lt;? value("shipto_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("cust_id") ?>\n    AND  (cohead_cust_id=&lt;? value("cust_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("custtype_id") ?>\n    AND  (cust_custtype_id=&lt;? value("custtype_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("custtype_pattern") ?>\n    AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                               FROM custtype\n                               WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n  &lt;? endif ?>\n  &lt;? if exists("custgrp") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem))\n  &lt;? endif ?>\n  &lt;? if exists("custgrp_id") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem\n                     WHERE (custgrpitem_custgrp_id=&lt;? value("custgrp_id") ?>)))\n  &lt;? endif ?>\n  &lt;? if exists("custgrp_pattern") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrp, custgrpitem\n                     WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                       AND   (custgrp_name ~ &lt;? value("custgrp_pattern") ?>) )) )\n  &lt;? endif ?>\n\n  &lt;? if exists("item_id") ?>\n    AND  (itemsite_item_id=&lt;? value("item_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("prodcat_id") ?>\n    AND (item_prodcat_id=&lt;? value("prodcat_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                             FROM prodcat\n                             WHERE (prodcat_code ~ &lt;? value("prodcat_pattern") ?>)))\n  &lt;? endif ?>\n\n  &lt;? if exists("warehous_id") ?>\n    AND  (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n  &lt;? endif ?>\n)\nORDER BY coitem_scheddate, cohead_number, coitem_linenumber;</sql>\n </querysource>\n <querysource>\n  <name>total</name>\n  <sql>SELECT now()\n WHERE 't' =\nCASE WHEN (checkPrivilege('ViewCustomerPrices') \n  't'\nELSE\n  'f'\nEND</sql>\n </querysource>\n <rpthead>\n  <height>226</height>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>185</y>\n    <width>102</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>185</y>\n    <width>110</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>200</y>\n    <width>102</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>185</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_baseamount</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_foreignamount</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>0</y>\n    <width>465</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Backlog</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>507</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scheduled</string>\n  </label>\n  <label>\n   <rect>\n    <x>507</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Ordered</string>\n  </label>\n  <text>\n   <rect>\n    <x>5</x>\n    <y>28</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>507</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>0</y>\n    <width>102</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>15</y>\n    <width>102</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>507</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scheduled</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_baseamount</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_foreignamount</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>0</y>\n    <width>110</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>52</height>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>30</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>coitem_linenumber</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>15</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>507</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyship</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>671</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>foreign_ammount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>0</y>\n     <width>140</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ammount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>450</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>225</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_orderdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>507</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyord</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>225</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_scheddate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>112</x>\n     <y>0</y>\n     <width>110</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_number</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>totals</name>\n  <detail>\n   <key>\n    <query>total</query>\n   </key>\n   <height>18</height>\n   <label>\n    <rect>\n     <x>230</x>\n     <y>0</y>\n     <width>415</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Total:</string>\n   </label>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>backlog</column>\n    </data>\n    <format builtin="true">money</format>\n    <tracktotal/>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n  \N      0       2011-02-16 10:08:43.701392
102400
 
29      TimePhasedUsageStatisticsByItem \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Phased Usage Statistics By Item</title>\n <name>TimePhasedUsageStatisticsByItem</name>\n <description/>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number, item_descrip1, item_descrip2,\n       CASE WHEN (%2=-1) THEN 'All Warehouses'\n                  ELSE ( SELECT warehous_code\n                                 FROM warehous\n                              WHERE (warehous_id=%2) )\n       END AS warehouse\nFROM item\nWHERE (item_id=%1);</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT findPeriodStart(rcalitem_id) AS pstart,\n       findPeriodEnd(rcalitem_id) AS pend,\n       (formatDate(findPeriodStart(rcalitem_id)) || '-' || formatDate(findPeriodEnd(rcalitem_id))) AS period,\n       warehous_code,\n       formatQty(summTransR(itemsite_id, rcalitem_id)) AS received,\n       formatQty(summTransI(itemsite_id, rcalitem_id)) AS issued,\n       formatQty(summTransS(itemsite_id, rcalitem_id)) AS sold,\n       formatQty(summTransC(itemsite_id, rcalitem_id)) AS scrap,\n       formatQty(summTransA(itemsite_id, rcalitem_id)) AS adjustments\n  FROM rcalitem, itemsite, warehous\n WHERE ((rcalitem_id in (%4))\n   AND (itemsite_warehous_id=warehous_id)\n   AND (itemsite_item_id=%1)\n   AND ((%2=-1) OR (itemsite_warehous_id=%2)) )\n UNION\nSELECT findPeriodStart(acalitem_id) AS pstart,\n       findPeriodEnd(acalitem_id) AS pend,\n       (formatDate(findPeriodStart(acalitem_id)) || '-' || formatDate(findPeriodEnd(acalitem_id))) AS period,\n       warehous_code,\n       formatQty(summTransR(itemsite_id, acalitem_id)) AS received,\n       formatQty(summTransI(itemsite_id, acalitem_id)) AS issued,\n       formatQty(summTransS(itemsite_id, acalitem_id)) AS sold,\n       formatQty(summTransC(itemsite_id, acalitem_id)) AS scrap,\n       formatQty(summTransA(itemsite_id, acalitem_id)) AS adjustments\n  FROM acalitem, itemsite, warehous\n WHERE ((acalitem_id IN (%4))\n   AND (itemsite_warehous_id=warehous_id)\n   AND (itemsite_item_id=%1)\n   AND ((%2=-1) OR (itemsite_warehous_id=%2)) )\nORDER BY pstart, warehous_code;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Adjusted</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Whs.</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>80</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Number:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>120</y>\n    <width>385</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>740</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issued</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>140</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Warehouse:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>385</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>10</y>\n    <width>485</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time Phased Usage Statistics By Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issued</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Whs.</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>740</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Adjusted</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>pstart</column>\n   <head>\n    <height>6</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>5</y>\n      <width>250</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>period</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sold</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>405</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>issued</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>adjustments</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>received</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>690</x>\n    <y>0</y>\n    <width>51</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n           0       2004-02-10 10:24:16.076157
102401
 
481     ContractActivity        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Contract Activity Summary Report</title>\n <name>ContractActivity</name>\n <description></description>\n <parameter default="11" active="true" listtype="static" type="integer" name="contrct_id">\n  <description></description>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>25</rightmargin>\n <leftmargin>25</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>select contrct_id,\n  contrct_number,\n  contrct_vend_id,\n  contrct_descrip,\n  contrct_effective,\n  contrct_expires,\n  contrct_note,\n  vend_number,\n  vend_name\n  from contrct JOIN vendinfo ON (vend_id = contrct_vend_id)\n  where contrct_id = &lt;? value("contrct_id") ?>;\n   </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>-- Group: contrct\n-- Name:  itemsources\n-- Notes: Selection of Contract Related Item Sources\nSELECT itemsrc_id,\n\t-1 AS pohead_id, \n\t' ' AS seq,\n\t' ' AS poitem_ordnumber, \n        item_number,\n\titem_descrip1,\n\titemsrc_vend_uom,\n\titemsrc_vend_item_number,\n\titemsrc_contrct_min,\n\tsum(poitem_qty_unreleased) AS poitem_qty_unreleased,\n\tsum(poitem_qty_ordered)    AS poitem_qty_ordered,\n\tsum(poitem_qty_received)   AS poitem_qty_received,\n\tsum(poitem_qty_returned)   AS poitem_qty_returned,\n\tnull AS poitem_duedate,\n\tnull AS poitem_status,\n\t0 AS xtindentrole \n\tFROM (SELECT contrct_id, \n\t\titemsrc_id,\n\t\tpohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\titem_number,\n\t\titem_descrip1,\n\t\titemsrc_vend_uom,\n\t\titemsrc_vend_item_number,\n\t\titemsrc_contrct_min,\n\t\tCASE WHEN poitem_status = 'U' THEN poitem_qty_ordered\n\t\t  ELSE 0\n\t\tEND AS poitem_qty_unreleased,\n\t\tCASE WHEN poitem_status = 'O' THEN poitem_qty_ordered\n\t\t     WHEN poitem_status = 'C' THEN poitem_qty_ordered\n                  ELSE 0\n\t\tEND AS poitem_qty_ordered,\n\t\tpoitem_qty_received,\n\t\tpoitem_qty_returned,\n\t\tpoitem_duedate, \n\t\tpoitem_status\n\t\tFROM contrct JOIN itemsrc    ON (itemsrc_contrct_id  = contrct_id)\n\t\t  LEFT OUTER JOIN poitem     ON (poitem_itemsrc_id   = itemsrc_id)\n\t\t  LEFT OUTER JOIN pohead     ON (pohead_id           = poitem_pohead_id)\n\t\t\t   JOIN item       ON (itemsrc_item_id     = item_id)\n\t\tWHERE (contrct_id = &lt;? value("contrct_id") ?>)) AS dummy1\n\tWHERE (contrct_id = &lt;? value("contrct_id") ?>)\n\tGROUP BY itemsrc_id, itemsrc_vend_item_number, itemsrc_vend_uom, itemsrc_contrct_min,\n                item_number, item_descrip1\n\nUNION  -- PO Line Items\n\nSELECT itemsrc_id,\n\tpohead_id, \n\tpohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS seq,\n        pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber,  \n        null AS item_number,\n\tnull AS item_descrip1,\n\tnull AS itemsrc_vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS itemsrc_contrct_min,\n\tCASE WHEN poitem_status = 'U' THEN poitem_qty_ordered\n\t  ELSE 0\n\tEND AS poitem_qty_unreleased,\n\tCASE WHEN poitem_status = 'O' THEN poitem_qty_ordered\n\t     WHEN poitem_status = 'C' THEN poitem_qty_ordered\n          ELSE 0\n\tEND AS poitem_qty_ordered,\n\tpoitem_qty_received,\n\tpoitem_qty_returned,\n\tto_char(poitem_duedate, 'YYYY-MM-DD HH24:MI:SS'), \n\tCASE WHEN poitem_status = 'O' THEN 'Open'\n\t     WHEN poitem_status = 'C' THEN 'Closed'\n\t     ELSE 'Unreleased'\n\tEND AS poitem_status,\n\t1 AS xtindentrole \n\tFROM contrct JOIN itemsrc  ON (itemsrc_contrct_id  = contrct_id)\n\t\t   JOIN poitem   ON (poitem_itemsrc_id   = itemsrc_id)\n\t\t   JOIN pohead   ON (pohead_id           = poitem_pohead_id)\n\t\t   JOIN item     ON (itemsrc_item_id     = item_id)\n\tWHERE (contrct_id = &lt;? value("contrct_id") ?>)\n\nUNION -- Receipts\n\nSELECT itemsrc_id,\n\tpohead_id,  \n\tpoitem_ordnumber || 'R' || to_char(recv_date, 'YYYYMMDDHH24:MI:SS') AS seq,\n\t'Receipt' AS poitem_ordnumber,\n\tnull AS item_number,\n\tnull AS item_descrip1,\n\trecv_vend_uom AS vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS itemsrc_contrct_min,\n\tnull AS poitem_qty_unreleased,\n\tnull AS poitem_qty_ordered,\n\trecv_qty AS poitem_qty_received,\n\tnull AS poitem_qty_returned,\n\tto_char(recv_date, 'YYYY-MM-DD HH24:MI:SS') AS poitem_duedate,\n\trecv_trans_usr_name AS username,\n\t2 AS xtindentrole\n  FROM recv JOIN (SELECT pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\t\t    poitem_pohead_id, poitem_linenumber, poitem_id, pohead_id, \n\t\t\t    poitem_itemsrc_id\n\t\t\tFROM poitem JOIN pohead ON (pohead_id = poitem_pohead_id)) AS dummy ON (poitem_id   = recv_orderitem_id)\n               JOIN itemsite ON (itemsite_id = recv_itemsite_id)\n               JOIN item     ON (item_id     = itemsite_item_id)\n               JOIN itemsrc  ON (poitem_itemsrc_id = itemsrc_id)\n  WHERE (itemsrc_contrct_id = &lt;? value("contrct_id") ?>) \n\nUNION -- Returns\n\nSELECT itemsrc_id, \n\tpohead_id,  \n\tpoitem_ordnumber || 'R' || to_char(poreject_date, 'YYYYMMDDHH24:MI:SS') AS seq,\n\t'Return' AS poitem_ordnumber,\n\tnull AS item_number,\n\tnull AS item_descrip1,\n\tporeject_vend_uom AS vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS itemsrc_contrct_min,\n\tnull AS poitem_qty_unreleased,\n\tnull AS poitem_qty_ordered,\n\tnull AS poitem_qty_received,\n\tporeject_qty AS poitem_qty_returned,\n\tto_char(poreject_date, 'YYYY-MM-DD HH24:MI:SS') AS poitem_duedate,\n\tporeject_trans_username AS username,\n\t2 AS xtindentrole \n  FROM poreject JOIN (SELECT pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\t\t    poitem_pohead_id, poitem_linenumber, poitem_id, pohead_id, \n\t\t\t    poitem_itemsrc_id\n\t\t\tFROM poitem JOIN pohead ON (pohead_id = poitem_pohead_id)) AS dummy ON (poitem_id   = poreject_poitem_id)\n               JOIN itemsite ON (itemsite_id = poreject_itemsite_id)\n               JOIN item     ON (item_id     = itemsite_item_id)\n               JOIN itemsrc  ON (poitem_itemsrc_id = itemsrc_id)\n  WHERE (itemsrc_contrct_id = &lt;? value("contrct_id") ?>) \n\nORDER BY itemsrc_id, seq, poitem_ordnumber, poitem_duedate, xtindentrole;\n</sql>\n </querysource>\n <rpthead>\n  <height>183</height>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>55</y>\n    <width>598</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>contrct_descrip</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>85</x>\n    <y>120</y>\n    <width>275</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>205</x>\n    <y>10</y>\n    <width>171</width>\n    <height>35</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>contrct_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>55</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Description:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>120</y>\n    <width>73</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>10</y>\n    <width>152</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>CONTRACT</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>140</y>\n    <width>79.8</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Effective:</string>\n  </label>\n  <field>\n   <rect>\n    <x>85</x>\n    <y>140</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>contrct_effective</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>160</y>\n    <width>79.8</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Expires:</string>\n  </label>\n  <field>\n   <rect>\n    <x>85</x>\n    <y>160</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>contrct_expires</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>85</x>\n    <y>100</y>\n    <width>140</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>100</y>\n    <width>72</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor:</string>\n  </label>\n  <label>\n   <rect>\n    <x>335</x>\n    <y>100</y>\n    <width>72</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Notes:</string>\n  </label>\n  <text>\n   <rect>\n    <x>415</x>\n    <y>100</y>\n    <width>330</width>\n    <height>20</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>contrct_note</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>1045</xend>\n   <yend>30</yend>\n   <weight>1</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>ItemSource</name>\n   <column>itemsrc_id</column>\n   <head>\n    <height>30</height>\n    <line>\n     <xstart>3.5</xstart>\n     <ystart>23.5</ystart>\n     <xend>1043.5</xend>\n     <yend>23.5</yend>\n     <weight>1</weight>\n    </line>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>5</y>\n      <width>79.8</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Item #</string>\n    </label>\n    <label>\n     <rect>\n      <x>85</x>\n      <y>5</y>\n      <width>79.8</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Description</string>\n    </label>\n    <label>\n     <rect>\n      <x>265</x>\n      <y>5</y>\n      <width>95</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Vendor Part #</string>\n    </label>\n    <label>\n     <rect>\n      <x>360</x>\n      <y>5</y>\n      <width>95</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Description</string>\n    </label>\n    <label>\n     <rect>\n      <x>460</x>\n      <y>5</y>\n      <width>65</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Order/Oper</string>\n    </label>\n    <label>\n     <rect>\n      <x>555</x>\n      <y>5</y>\n      <width>55</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Cont Qty</string>\n    </label>\n    <label>\n     <rect>\n      <x>620</x>\n      <y>5</y>\n      <width>55</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Unrel Qty</string>\n    </label>\n    <label>\n     <rect>\n      <x>690</x>\n      <y>5</y>\n      <width>55</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Order Qty</string>\n    </label>\n    <label>\n     <rect>\n      <x>760</x>\n      <y>5</y>\n      <width>55</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Rcpt Qty</string>\n    </label>\n    <label>\n     <rect>\n      <x>830</x>\n      <y>5</y>\n      <width>55</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Rtrn Qty</string>\n    </label>\n    <label>\n     <rect>\n      <x>920</x>\n      <y>5</y>\n      <width>55</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Date</string>\n    </label>\n    <label>\n     <rect>\n      <x>995</x>\n      <y>5</y>\n      <width>55</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Stat/User</string>\n    </label>\n   </head>\n   <foot>\n    <height>10</height>\n   </foot>\n  </group>\n  <group>\n   <name>PurchaseOrder</name>\n   <column>pohead_id</column>\n   <foot>\n    <height>10</height>\n    <line>\n     <xstart>458.5</xstart>\n     <ystart>3.5</ystart>\n     <xend>1043.5</xend>\n     <yend>3.5</yend>\n     <weight>1</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>25</height>\n   <field>\n    <rect>\n     <x>885</x>\n     <y>5</y>\n     <width>110</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>5</y>\n     <width>65</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>810</x>\n     <y>5</y>\n     <width>65</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_qty_returned</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n   <field>\n    <rect>\n     <x>345</x>\n     <y>5</y>\n     <width>155</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>740</x>\n     <y>5</y>\n     <width>65</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_qty_received</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>5</y>\n     <width>65</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsrc_contrct_min</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>5</y>\n     <width>65</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_qty_ordered</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n   <field>\n    <rect>\n     <x>80</x>\n     <y>5</y>\n     <width>185</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>1000</x>\n     <y>5</y>\n     <width>45</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>460</x>\n     <y>5</y>\n     <width>65</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_ordnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>275</x>\n     <y>5</y>\n     <width>65</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsrc_vend_item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>5</y>\n     <width>65</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_qty_unreleased</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>27.4814</height>\n  <label>\n   <rect>\n    <x>910</x>\n    <y>7.4814</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>1000</x>\n    <y>7.4814</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>7.4814</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>7.4814</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>27.5186</height>\n </rptfoot>\n</report>\n     \N      0       2014-03-20 16:30:39.072368
102402
 
202     PurchaseRequestsByPlannerCode   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Purchase Requests By Planner Code</title>\n <name>PurchaseRequestsByPlannerCode</name>\n <description/>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT CASE WHEN('%1'='-1') THEN 'All Planner Codes'\n            WHEN((SELECT count(*)\n                    FROM plancode\n                   WHERE plancode_code = '%1') = 1) THEN\n                        (SELECT ()\n                           FROM plancode\n                          WHERE plancode_code = '%1')\n            ELSE '%1'::text\n       END AS plancode,\n       CASE WHEN(%2=-1) THEN 'All Warehouses'\n            ELSE (SELECT warehous_code\n                    FROM warehous\n                   WHERE warehous_id=%2)\n       END AS warehouse;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT item_number,\n       (item_descrip1 || ' ' || item_descrip2) as item_descrip,\n       pr_status,\n       CASE WHEN (pr_order_type='W') THEN ('W/O ' || ( SELECT formatWoNumber(womatl_wo_id)\n                                                         FROM womatl\n                                                        WHERE (womatl_id=pr_order_id) ) )\n            WHEN (pr_order_type='S') THEN ('S/O ' || (SELECT formatSoNumber(pr_order_id)))\n            WHEN (pr_order_type='F') THEN ('Planned Order')\n            WHEN (pr_order_type='M') THEN 'Manual'\n            ELSE 'Other'\n       END AS f_type,\n       formatDate(pr_duedate) AS f_duedate,\n       formatQty(pr_qtyreq) AS f_qtyreq\n  FROM pr, itemsite, item\n WHERE ( (pr_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (itemsite_warehous_id=%2)\n   AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ '%1') ) )\n)\nORDER BY pr_duedate;</sql>\n </querysource>\n <rpthead>\n  <height>171</height>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purchase Requests By Planner Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>65</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Planner Code:</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>65</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>plancode</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Parameter Query</query>\n    <column>3</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>85</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>165</ystart>\n   <xend>745</xend>\n   <yend>165</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>150</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Warehouse:</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>150</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Order</string>\n  </label>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Parameter Query</query>\n    <column>4</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>150</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Order</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>340</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>pr_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>135</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_type</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>105</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2004-02-10 10:24:16.076157
102403
 
204     APAssignments Master List       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>A/P Account Assignments Master List</title>\n <name>APAssignments Master List</name>\n <description/>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT CASE WHEN apaccnt_vendtype_id=-1 THEN apaccnt_vendtype\n            ELSE (SELECT vendtype_code FROM vendtype WHERE (vendtype_id=apaccnt_vendtype_id))\n       END AS vendtypecode,\n       formatGLAccount(apaccnt_ap_accnt_id) AS f_account\nFROM apaccnt\nORDER BY vendtypecode;</sql>\n </querysource>\n <rpthead>\n  <height>77</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>10</y>\n    <width>495</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>A/P Account Assignments Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>120</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>A/P Account</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>22</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>120</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>A/P Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Venbor Type</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>venttypecode</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>120</x>\n     <y>0</y>\n     <width>500</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_account</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n              0       2004-02-10 10:24:16.076157
102404
 
270     CheckFormat     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Sample Check Format</title>\n <name>CheckFormat</name>\n <description>OpenMFG Sample A/P Check Format</description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>Head</name>\n  <sql>SELECT vend_name,\n       vend_address1,\n       vend_address3,\n       vend_address3,\n       vend_city,\n       vend_state,\n       vend_zip,\n       formatDate(apchk_checkdate) AS f_checkdate,\n       formatMoney(apchk_amount) AS f_amount,\n       spellAmount(apchk_amount) AS f_words,\n       CASE WHEN(apchk_void) THEN text('V O I D')\n            ELSE text('')\n       END AS f_void,\n       apchk_for\n  FROM apchk, vend\n WHERE ( (apchk_vend_id=vend_id)\n   AND (apchk_id=&lt;? value(&quot;apchk_id&quot;) ?>) );</sql>\n </querysource>\n <querysource>\n  <name>Detail</name>\n  <sql>SELECT apchkitem_invcnumber, apchkitem_ponumber,\n       formatMoney(apchkitem_amount) AS f_amount\nFROM apchkitem\nWHERE (apchkitem_apchk_id=%1)\nORDER BY apchkitem_invcnumber;</sql>\n </querysource>\n <pghead>\n  <firstpage/>\n  <height>197</height>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>175</y>\n    <width>83</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica [Urw]</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>75</y>\n    <width>20</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica [Urw]</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>$</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>155</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica [Urw]</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Memo:</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>175</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica [Urw]</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Invoice #</string>\n  </label>\n  <field>\n   <rect>\n    <x>300</x>\n    <y>75</y>\n    <width>150</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>f_void</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>60</x>\n    <y>30</y>\n    <width>150</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>f_void</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>395</x>\n    <y>175</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica [Urw]</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <field>\n   <rect>\n    <x>60</x>\n    <y>155</y>\n    <width>325</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Head</query>\n    <column>apchk_for</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>30</y>\n    <width>150</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>f_void</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>60</x>\n    <y>120</y>\n    <width>150</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>f_void</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>85</x>\n    <y>75</y>\n    <width>185</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Head</query>\n    <column>vend_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>20</y>\n    <width>121</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Head</query>\n    <column>f_checkdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>45</x>\n    <y>100</y>\n    <width>675</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Head</query>\n    <column>f_words</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>120</y>\n    <width>150</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>f_void</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>75</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Head</query>\n    <column>f_amount</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>Apchkitem</name>\n  <detail>\n   <key>\n    <query>Detail</query>\n   </key>\n   <height>22</height>\n   <field>\n    <rect>\n     <x>509</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica [Urw]</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>390</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica [Urw]</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>apchkitem_ponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica [Urw]</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>apchkitem_invcnumber</column>\n    </data>\n   </field>\n  </detail>\n </section>\n</report>\n       OpenMFG Sample A/P Check Format 0       2004-08-26 10:48:34.979983
102405
 
416     ListOpenReturnAuthorizations    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>List Open Return Authorizations</title>\n <name>ListOpenReturnAuthorizations</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM warehous\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Warehouses')\n       &lt;? endif ?>\n       AS warehouse;\n</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>returnAuthorizations</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>200</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>5</y>\n    <width>475</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>List Open Return Authorizations</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>195</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Created</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>104</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>104</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Warehouse:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>R/A #</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Disposition</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Disposition</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>R/A #</string>\n  </label>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Created</string>\n  </label>\n  <label>\n   <rect>\n    <x>195</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>custnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>disposition</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>535</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_authorized</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_expires</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>rahead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>195</x>\n     <y>0</y>\n     <width>225</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>rahead_billtoname</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n     \N      0       2012-11-07 15:38:54.982573
102406
 
138     ExpediteExceptionsByPlannerCode \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Expedite Exceptions by Planner Code</title>\n <name>ExpediteExceptionsByPlannerCode</name>\n <description/>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("plancode_id") ?>\n         ( SELECT (plancode_code || '-' || plancode_name)\n             FROM plancode\n            WHERE (plancode_id=&lt;? value("plancode_id") ?>) )\n       &lt;? elseif exists("plancode_pattern") ?>\n         text(&lt;? value("plancode_pattern") ?>)\n       &lt;? else ?>\n         text('All Planner Codes')\n       &lt;? endif ?>\n       AS plannercode,\n       &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM warehous\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT planord_id AS order_id, 1 AS order_code,\n       CASE WHEN (planord_type='W') THEN ('PW/O-' || formatPloNumber(planord_id))\n            WHEN (planord_type='P') THEN ('PP/O-' || formatPloNumber(planord_id))\n            ELSE text(planord_number)\n       END AS order_number,\n       warehous_code, item_number, item_descrip1, item_descrip2,\n       CASE WHEN (planord_type='W') THEN formatDate(planord_startdate)\n            ELSE formatDate(planord_duedate)\n       END AS f_keydate,\n       CASE WHEN (planord_type='W') THEN planord_startdate\n            ELSE planord_duedate\n       END AS keydate, 'Release Order' AS exception \n  FROM planord, itemsite, item, warehous \n WHERE ( (planord_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND ( ( (planord_type='W') AND (planord_startdate &lt;= (CURRENT_DATE + &lt;? value("lookAheadDays") ?>)) )\n      OR ( (planord_type='P') AND (planord_duedate &lt;= (CURRENT_DATE + &lt;? value("lookAheadDays") ?>)) ) ) \n&lt;? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("plancode_id") ?>\n   AND (itemsite_plancode_id=&lt;? value("plancode_id") ?>)\n&lt;? elseif exists("plancode_pattern") ?>\n   AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ &lt;? value("plancode_pattern") ?>)))\n&lt;? endif ?>\n)\n\nUNION SELECT wo_id AS order_id, 2 AS order_code, ('W/O-' || formatWoNumber(wo_id)) AS order_number,\n             warehous_code, item_number, item_descrip1, item_descrip2,\n             formatDate(wo_startdate) AS f_keydate, wo_startdate AS keydate, 'Start Production' AS exception \nFROM wo, itemsite, item, warehous \nWHERE ( (wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (wo_status IN ('O', 'E', 'R'))\n AND (wo_startdate &lt;= (CURRENT_DATE + &lt;? value("lookAheadDays") ?>))\n&lt;? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("plancode_id") ?>\n AND (itemsite_plancode_id=&lt;? value("plancode_id") ?>)\n&lt;? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ &lt;? value("plancode_pattern")?>)))\n&lt;? endif ?>\n)\n\nUNION SELECT wo_id AS order_id, 2 AS order_code, ('W/O-' || formatWoNumber(wo_id)) AS order_number,\n             warehous_code, item_number, item_descrip1, item_descrip2,\n             formatDate(wo_startdate) AS f_keydate, wo_startdate AS keydate, 'Expedite Production' AS exception \nFROM wo, itemsite, item, warehous \nWHERE ( (wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (wo_status='I')\n AND (wo_startdate &lt;= (CURRENT_DATE + &lt;? value("lookAheadDays") ?>))\n&lt;? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("plancode_id") ?>\n AND (itemsite_plancode_id=&lt;? value("plancode_id") ?>)\n&lt;? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ &lt;? value("plancode_pattern") ?>)))\n&lt;? endif ?>\n)\norder by keydate;</sql>\n </querysource>\n <rpthead>\n  <height>223</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>100</y>\n    <width>114</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Planner Code(s):</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Parameter Query</query>\n    <column>lookAheadDays</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Type/#</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>185</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Exception</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>120</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start/Due Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>385</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>plannercode</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>185</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>140</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Look Ahead Days:</string>\n  </label>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>200</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>10</y>\n    <width>484</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Expedite Exceptions by Planner Code</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>42</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Type/#</string>\n  </label>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>20</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start/Due Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>5</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>5</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>5</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Exception</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>53</height>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_keydate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>595</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>exception</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>105</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>0</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>95</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>order_number</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n      \N      0       2008-07-25 16:12:17.804536
102407
 
51      SequencedBOM    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Sequenced Bill of Materials</title>\n <name>SequencedBOM</name>\n <description/>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       uom_name AS item_invuom,\n       item_descrip1,\n       item_descrip2\n  FROM item, uom\n WHERE ((item_id=&lt;? value("item_id") ?>)\n AND (item_inv_uom_id=uom_id));\n    </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT text(booitem_seqnumber) AS booseqnumber, bomitem_seqnumber,\n       item_number, uom_name AS item_invuom, item_descrip1, item_descrip2,\n       formatQtyPer(bomitem_qtyper) AS qtyper,\n       formatScrap(bomitem_scrap) AS scrap,\n       formatQtyPer(bomitem_qtyper + (1 * bomitem_scrap)) AS qtyreq,\n       formatDate(bomitem_effective, 'Always') AS effective,\n       formatDate(bomitem_expires, 'Never') AS expires,\n       formatBoolYN(bomitem_createwo) AS createchild,\n       CASE WHEN (bomitem_issuemethod='S') THEN 'Push'\n            WHEN (bomitem_issuemethod='L') THEN 'Pull'\n            WHEN (bomitem_issuemethod='M') THEN 'Mixed'\n            ELSE 'Special'\n       END AS issuemethod\n  FROM booitem(&lt;? value("item_id") ?>), bomitem(&lt;? value("item_id") ?>,&lt;? value("revision_id") ?>), item, uom\n WHERE ((bomitem_item_id=item_id)\n   AND (bomitem_booitem_seq_id=booitem_seq_id)\n   AND (item_inv_uom_id=uom_id)\n&lt;? if not exists("showExpired") ?>\n   AND (bomitem_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n   AND (bomitem_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n)\nUNION\nSELECT text('') AS booseqnumber, bomitem_seqnumber,\n       item_number, uom_name AS item_invuom, item_descrip1, item_descrip2,\n       formatQtyPer(bomitem_qtyper) AS qtyper,\n       formatScrap(bomitem_scrap) AS scrap,\n       formatQtyPer(bomitem_qtyper + (1 * bomitem_scrap)) AS qtyreq,\n       formatDate(bomitem_effective, 'Always') AS effective,\n       formatDate(bomitem_expires, 'Never') AS expires,\n       formatBoolYN(bomitem_createwo) AS createchild,\n       CASE WHEN (bomitem_issuemethod='S') THEN 'Push'\n            WHEN (bomitem_issuemethod='L') THEN 'Pull'\n            WHEN (bomitem_issuemethod='M') THEN 'Mixed'\n            ELSE 'Special'\n       END AS issuemethod\n  FROM bomitem(&lt;? value("item_id") ?>,&lt;? value("revision_id") ?>), item, uom\n WHERE ((bomitem_item_id=item_id)\n   AND (bomitem_booitem_seq_id=-1)\n   AND (item_inv_uom_id=uom_id)\n&lt;? if not exists("showExpired") ?>\n   AND (bomitem_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n   AND (bomitem_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n)\nORDER BY booseqnumber, bomitem_seqnumber;\n</sql>\n </querysource>\n <querysource>\n  <name>bomhead</name>\n  <sql>SELECT bomhead_docnum, bomhead_revision,\nformatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=&lt;? value("item_id") ?>)\nAND (bomhead_rev_id=&lt;? value("revision_id") ?>));</sql>\n </querysource>\n <rpthead>\n  <height>233</height>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>160</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>505</x>\n    <y>160</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_revision</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>140</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>120</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <field>\n   <rect>\n    <x>505</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>f_revisiondate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>75</x>\n    <y>200</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <field>\n   <rect>\n    <x>505</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_docnum</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>200</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>120</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Document</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>140</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>75</x>\n    <y>215</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Required</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sequenced Bill of Materials</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>160</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>BOO Seq. #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>228</ystart>\n   <xend>745</xend>\n   <yend>228</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>215</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>BOM Seq. #</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>15</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>BOM Seq. #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>75</x>\n    <y>15</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>BOO Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Required</string>\n  </label>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>75</x>\n    <y>0</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>57</height>\n   <field>\n    <rect>\n     <x>675</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>issuemethod</column>\n    </data>\n   </field>\n   <line>\n    <xstart>3</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>75</x>\n     <y>0</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>65</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>booseqnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>443</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>75</x>\n     <y>15</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>675</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>expires</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>65</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bomitem_seqnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>403</x>\n     <y>0</y>\n     <width>37</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_invuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>525</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>effective</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createchild</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>75</x>\n     <y>30</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n \N      0       2008-08-08 12:40:01.283663
102408
 
415     AROpenItem      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>AROpenItem</title>\n <name>AROpenItem</name>\n <description>A report showing details of a single AR Open Item</description>\n <parameter default="-1" active="true" listtype="static" type="integer" name="aropen_id">\n  <description></description>\n </parameter>\n <parameter default="-1" active="false" listtype="static" type="integer" name="docTypeID">\n  <description></description>\n </parameter>\n <parameter default="-1" active="true" listtype="static" type="integer" name="docTypeRC">\n  <description></description>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT aropen_cust_id, aropen_docdate, aropen_duedate, \naropen_doctype,\nCASE WHEN (aropen_doctype = 'C' AND ((SELECT COUNT(*) AS num_rows FROM cmhead, aropen WHERE cmhead_number = aropen_ordernumber AND aropen_id = &lt;? value("aropen_id") ?> ) = 0)) THEN 'Misc. Credit Memo'\n     WHEN (aropen_doctype = 'D' AND ((SELECT COUNT(*) AS num_rows FROM cmhead, aropen WHERE cmhead_number = aropen_ordernumber AND aropen_id = &lt;? value("aropen_id") ?> ) = 0)) THEN 'Misc. Debit Memo'\n     WHEN (aropen_doctype = 'C' AND ((SELECT COUNT(*) AS num_rows FROM cmhead, aropen WHERE cmhead_number = aropen_ordernumber AND aropen_id = &lt;? value("aropen_id") ?> ) > 0)) THEN 'Credit Memo'\n     WHEN (aropen_doctype = 'D' AND ((SELECT COUNT(*) AS num_rows FROM cmhead, aropen WHERE cmhead_number = aropen_ordernumber AND aropen_id = &lt;? value("aropen_id") ?> ) > 0)) THEN 'Debit Memo'\n     END AS doc_name, \naropen_docnumber, \naropen_ordernumber, aropen_journalnumber, \naropen_amount, aropen_amount, \naropen_paid, \n(aropen_amount - aropen_paid) AS f_balance, \naropen_terms_id, aropen_salesrep_id, \naropen_commission_due, \naropen_notes, aropen_rsncode_id, aropen_salescat_id, \naropen_accnt_id, aropen_curr_id, cust_name, salesrep_name, terms_code, \nrsncode_code, formatboolyn(aropen_commission_paid) AS commission_paid \nFROM aropen \nJOIN custinfo ON(cust_id = aropen_cust_id)\nLEFT OUTER JOIN salesrep ON(aropen_salesrep_id = salesrep_id)\nLEFT OUTER JOIN terms ON(terms_id = aropen_terms_id)\nLEFT OUTER JOIN rsncode ON(rsncode_id = aropen_rsncode_id)\nWHERE (aropen_id=&lt;? value("aropen_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>applications</name>\n  <sql>&lt;? if exists("docTypeID") ?>\nSELECT arapply_id, arapply_source_aropen_id,\n     CASE WHEN (arapply_source_doctype = 'C') THEN &lt;? value("creditMemo") ?>\n       WHEN (arapply_source_doctype = 'R') THEN &lt;? value("cashdeposit") ?>\n       WHEN (arapply_fundstype='C') THEN &lt;? value("check") ?>\n       WHEN (arapply_fundstype='T') THEN &lt;? value("certifiedCheck") ?>\n       WHEN (arapply_fundstype='M') THEN &lt;? value("masterCard") ?>\n       WHEN (arapply_fundstype='V') THEN &lt;? value("visa") ?>\n       WHEN (arapply_fundstype='A') THEN &lt;? value("americanExpress") ?>\n       WHEN (arapply_fundstype='D') THEN &lt;? value("discoverCard") ?>       \n       WHEN (arapply_fundstype='R') THEN &lt;? value("otherCreditCard") ?>\n       WHEN (arapply_fundstype='K') THEN &lt;? value("cash") ?>\n       WHEN (arapply_fundstype='W') THEN &lt;? value("wireTransfer") ?>\n       WHEN (arapply_fundstype='O') THEN &lt;? value("other") ?>\n     END AS doctype,\n     CASE WHEN (arapply_source_doctype IN ('C','R')) THEN arapply_source_docnumber\n     WHEN (arapply_source_doctype = 'K') THEN arapply_refnumber\n     ELSE 'Other'\n     END AS docnumber,\narapply_postdate, arapply_applied, \ncurrConcat(arapply_curr_id) AS currabbr, \ncurrToBase(arapply_curr_id, arapply_applied, arapply_postdate) AS baseapplied, \n'curr' AS arapply_applied_xtnumericrole, \n'curr' AS baseapplied_xtnumericrole \nFROM arapply \nWHERE (arapply_target_aropen_id=&lt;? value("aropen_id") ?> ) \nORDER BY arapply_postdate\n\n&lt;? elseif exists("docTypeRC") ?>\n\nSELECT arapply_id, arapply_target_aropen_id, \n     CASE WHEN (arapply_target_doctype = 'I') THEN &lt;? value("invoice") ?>\n      WHEN (arapply_target_doctype = 'D') THEN &lt;? value("debitMemo") ?>\n      WHEN (arapply_target_doctype = 'K') THEN &lt;? value("apcheck") ?>\n      WHEN (arapply_target_doctype = 'R') THEN &lt;? value("cashreceipt") ?>\n      ELSE &lt;? value("other") ?>\n     END AS doctype, \narapply_target_docnumber AS docnumber, \narapply_postdate, arapply_applied, \ncurrConcat(arapply_curr_id) AS currabbr, \ncurrToBase(arapply_curr_id, arapply_applied, arapply_postdate) AS baseapplied, \n'curr' AS arapply_applied_xtnumericrole, \n'curr' AS baseapplied_xtnumericrole \nFROM arapply \nWHERE (arapply_source_aropen_id=&lt;? value("aropen_id") ?> )\nORDER BY arapply_postdate\n\n&lt;? endif ?></sql>\n </querysource>\n <rpthead>\n  <height>445</height>\n  <field>\n   <rect>\n    <x>492.06</x>\n    <y>160.717</y>\n    <width>196</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>aropen_paid</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>491.06</x>\n    <y>184.717</y>\n    <width>195</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>f_balance</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>167.902</x>\n    <y>68.2357</y>\n    <width>201</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>aropen_docdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>34.5239</x>\n    <y>44.9813</y>\n    <width>126.032</width>\n    <height>18.3</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Customer:</string>\n  </label>\n  <label>\n   <rect>\n    <x>18.2</x>\n    <y>184.717</y>\n    <width>142</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Order Number:</string>\n  </label>\n  <label>\n   <rect>\n    <x>60.5562</x>\n    <y>91.1645</y>\n    <width>100</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Due Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>169.06</x>\n    <y>233</y>\n    <width>175</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>rsncode_code</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>399.729</x>\n    <y>91.8</y>\n    <width>85.8</width>\n    <height>19.6</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Sales Rep.:</string>\n  </label>\n  <label>\n   <rect>\n    <x>434.029</x>\n    <y>68.9</y>\n    <width>51.5</width>\n    <height>18.4</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Terms:</string>\n  </label>\n  <field>\n   <rect>\n    <x>492.06</x>\n    <y>136</y>\n    <width>216</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>aropen_amount</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>494.06</x>\n    <y>68.8712</y>\n    <width>247.562</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>terms_code</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>416</x>\n    <y>185</y>\n    <width>67</width>\n    <height>18.2</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Balance:</string>\n  </label>\n  <label>\n   <rect>\n    <x>8.84</x>\n    <y>160.717</y>\n    <width>152</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Document Number:</string>\n  </label>\n  <field>\n   <rect>\n    <x>169.06</x>\n    <y>160.717</y>\n    <width>176</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>aropen_docnumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>167.902</x>\n    <y>91.1813</y>\n    <width>216</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>aropen_duedate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>167.902</x>\n    <y>44.9813</y>\n    <width>432.315</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>cust_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>17.3649</x>\n    <y>68.2645</y>\n    <width>143.191</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Document Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>14.2</x>\n    <y>233</y>\n    <width>146</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Reason Code:</string>\n  </label>\n  <label>\n   <rect>\n    <x>352</x>\n    <y>209</y>\n    <width>131</width>\n    <height>18.8</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Commission Due:</string>\n  </label>\n  <field>\n   <rect>\n    <x>169.06</x>\n    <y>136</y>\n    <width>175</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>aropen_doctype</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>87.7597</x>\n    <y>271.717</y>\n    <width>624</width>\n    <height>127.611</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <wordwrap/>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>aropen_notes</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>169.06</x>\n    <y>209</y>\n    <width>177</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>aropen_journalnumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>31.3131</x>\n    <y>136</y>\n    <width>133</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Document Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>490</x>\n    <y>233</y>\n    <width>199</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>commission_paid</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>422</x>\n    <y>136</y>\n    <width>61.4</width>\n    <height>17.2</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Amount:</string>\n  </label>\n  <label>\n   <rect>\n    <x>441</x>\n    <y>161</y>\n    <width>42.6</width>\n    <height>19.9</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Paid:</string>\n  </label>\n  <field>\n   <rect>\n    <x>494.06</x>\n    <y>91.8168</y>\n    <width>242.264</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>salesrep_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>351</x>\n    <y>233</y>\n    <width>132</width>\n    <height>20.8</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Commission Paid:</string>\n  </label>\n  <field>\n   <rect>\n    <x>491.06</x>\n    <y>209</y>\n    <width>198</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>aropen_commission_due</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>169.06</x>\n    <y>184.717</y>\n    <width>176</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>aropen_ordernumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>20.3924</x>\n    <y>267.207</y>\n    <width>100</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Notes:</string>\n  </label>\n  <label>\n   <rect>\n    <x>-5.68</x>\n    <y>209</y>\n    <width>166</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Journal Number:</string>\n  </label>\n  <label>\n   <rect>\n    <x>9</x>\n    <y>416.355</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Doc Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>123</x>\n    <y>416.355</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Doc Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>242</x>\n    <y>416.355</y>\n    <width>100</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Apply Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>351</x>\n    <y>416.355</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>470</x>\n    <y>416.355</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Currency</string>\n  </label>\n  <label>\n   <rect>\n    <x>608</x>\n    <y>416.355</y>\n    <width>100</width>\n    <height>19</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Base Amount</string>\n  </label>\n  <line>\n   <xstart>4</xstart>\n   <ystart>434</ystart>\n   <xend>737</xend>\n   <yend>434</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>30.7855</x>\n    <y>9.22414</y>\n    <width>698.682</width>\n    <height>37.1</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>20</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>doc_name</column>\n   </data>\n  </field>\n </rpthead>\n <section>\n  <name>applications_detail</name>\n  <detail>\n   <key>\n    <query>applications</query>\n   </key>\n   <height>23</height>\n   <field>\n    <rect>\n     <x>8</x>\n     <y>1.71311</y>\n     <width>100</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Sans Serif</face>\n     <size>12</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>applications</query>\n     <column>doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>124</x>\n     <y>1.71311</y>\n     <width>100</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Sans Serif</face>\n     <size>12</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>applications</query>\n     <column>docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>241</x>\n     <y>1.71311</y>\n     <width>100</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Sans Serif</face>\n     <size>12</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>applications</query>\n     <column>arapply_postdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>352</x>\n     <y>1.71311</y>\n     <width>100</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Sans Serif</face>\n     <size>12</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>applications</query>\n     <column>arapply_applied</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>474</x>\n     <y>1.71311</y>\n     <width>100</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Sans Serif</face>\n     <size>12</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>applications</query>\n     <column>currabbr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>611</x>\n     <y>1.71311</y>\n     <width>100</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Sans Serif</face>\n     <size>12</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>applications</query>\n     <column>baseapplied</column>\n    </data>\n   </field>\n  </detail>\n </section>\n</report>\n A report showing details of a single AR Open Item       0       2014-10-06 19:47:03.678943
102409
 
290     CashReceipts    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Cash Receipts</title>\n <name>CashReceipts</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("cust_id") ?>\n         (SELECT (cust_number || '-' || cust_name)\n            FROM custinfo\n           WHERE (cust_id=&lt;? value("cust_id") ?>) )\n       &lt;? elseif exists("custtype_id") ?>\n         (select (custtype_code||'-'||custtype_descrip)\n            FROM custtype\n           WHERE (custtype_id=&lt;? value("custtype_id") ?>) )\n       &lt;? elseif exists("custtype_pattern") ?>\n         text(&lt;? value("custtype_pattern") ?>)\n       &lt;? else ?>\n         text('All Customers')\n       &lt;? endif ?>\n       AS f_value,\n       &lt;? if exists("custtype_id") ?>\n         text('Cust. Type:')\n       &lt;? elseif exists("custtype_pattern") ?>\n         text('Cust. Type Pattern:')\n       &lt;? else ?>\n         text('Customer:')\n       &lt;? endif ?>\n       AS f_label,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate;</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>cashReceipts</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <querysource>\n  <name>foot</name>\n  <sql>SELECT formatMoney(SUM(base_applied)) AS f_base_applied_total\nFROM (\n&lt;? if exists("LegacyDisplayMode") ?>\n-- Posted cash receipts\nSELECT  currtobase(arapply_curr_id,arapply_applied,arapply_postdate) AS base_applied\nFROM custinfo LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id), arapply\nWHERE ( (arapply_cust_id=cust_id)\n  AND   (arapply_postdate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n  AND   (arapply_source_doctype ='K')\n&lt;? if exists("cust_id") ?>\n  AND   (cust_id=&lt;? value("cust_id") ?>)\n&lt;? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=&lt;? value("custgrp_id") ?>)\n&lt;? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n&lt;? endif ?>\n      )\n\n-- Unposted cash receipts\nUNION ALL\nSELECT currtobase(cashrcpt_curr_id,cashrcpt_amount,cashrcpt_distdate) AS base_applied\nFROM cashrcpt, custinfo LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (NOT cashrcpt_posted)\n  AND   (cashrcpt_cust_id=cust_id)\n  AND   (cashrcpt_distdate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n&lt;? if exists("cust_id") ?>\n  AND   (cust_id=&lt;? value("cust_id") ?>)\n&lt;? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=&lt;? value("custgrp_id") ?>)\n&lt;? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n&lt;? endif ?>\n      )\n\n-- Cash Advance\nUNION ALL\nSELECT aropen_amount / aropen_curr_rate AS base_applied\nFROM custinfo LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id), aropen\n  JOIN cashrcptitem ON (aropen_id=cashrcptitem_aropen_id)\nWHERE ( (aropen_cust_id=cust_id)\n  AND   (aropen_doctype IN ('R','C'))\n  AND   (aropen_docdate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n&lt;? if exists("cust_id") ?>\n  AND   (cust_id=&lt;? value("cust_id") ?>)\n&lt;? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=&lt;? value("custgrp_id") ?>)\n&lt;? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n&lt;? endif ?>\n      )\n&lt;? else ?>\n-- New mode\nSELECT (cashrcpt_amount / cashrcpt_curr_rate) AS base_applied\nFROM cashrcpt JOIN custinfo ON (cust_id=cashrcpt_cust_id)\n&lt;? if exists("custgrp_id") ?>\n LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n&lt;? endif ?>\nWHERE ( (cashrcpt_distdate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n&lt;? if exists("cust_id") ?>\n  AND   (cust_id=&lt;? value("cust_id") ?>)\n&lt;? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=&lt;? value("custgrp_id") ?>)\n&lt;? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n&lt;? endif ?>\n      )\n&lt;? endif ?>\n) data\n;\n</sql>\n </querysource>\n <rpthead>\n  <height>146</height>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>65</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_label</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>125</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>410</x>\n    <y>126</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Target</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>65</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_value</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>458</x>\n    <y>65</y>\n    <width>100</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>125</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>140</ystart>\n   <xend>745</xend>\n   <yend>140</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>126</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>210</x>\n    <y>126</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>126</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <label>\n   <rect>\n    <x>458</x>\n    <y>85</y>\n    <width>100</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>126</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>126</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Base Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>3.13521</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Cash Receipts</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>28</height>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>4</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>420</x>\n    <y>4</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Target</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>4</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>4</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>4</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Base Amount</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>20</height>\n   <field>\n    <rect>\n     <x>55</x>\n     <y>0</y>\n     <width>155</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>0</y>\n     <width>65</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_postdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>currAbbr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>0</y>\n     <width>110</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>target</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>285</x>\n     <y>0</y>\n     <width>115</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>source</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_base_applied</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>509</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_applied</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>595.676</x>\n    <y>2.59436</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>700.755</x>\n    <y>2</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>103</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>100</height>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>10</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Base Amount</string>\n  </label>\n  <field>\n   <rect>\n    <x>646</x>\n    <y>10.7068</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>f_base_applied_total</column>\n   </data>\n  </field>\n </rptfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102410
 
184     UsageStatisticsByItemGroup      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Item Usage Statistics by Item Group</title>\n <name>UsageStatisticsByItemGroup</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value("startDate") ?>) AS startdate,\n       formatDate(&lt;? value("endDate") ?>) AS enddate,\n       &lt;? if exists("itemgrp_id") ?>\n         ( SELECT (itemgrp_name || '-' || itemgrp_descrip)\n             FROM itemgrp\n            WHERE (itemgrp_id=&lt;? value("itemgrp_id") ?>) )\n       &lt;? elseif exists("itemgrp_pattern") ?>\n         text(&lt;? value("itemgrp_pattern") ?>)\n       &lt;? else ?>\n         text('All Item Groups')\n       &lt;? endif ?>\n       AS itemgroup,\n       &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM warehous\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse;</sql>\n </querysource>\n <querysource loadFromDb="true" >\n  <name>detail</name>\n  <mqlgroup>usageStatistics</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>188</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>188</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>10</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Usage Statistics By Item Group</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>200</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>188</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Adjustments</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>188</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Transfers</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>188</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issued</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>185</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>120</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>120</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>250</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>itemgroup</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>100</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Group(s):</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>120</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>100</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>100</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>188</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>0</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issued</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>15</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Transfers</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Adjustments</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <line>\n    <xstart>5</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>2</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_transfer</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>2</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_adjust</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>2</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_sold</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>30</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>15</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>2</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>345</x>\n     <y>2</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_issued</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>2</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_received</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n   \N      0       2010-06-01 10:42:21.492483
102411
 
447     QOHByParameterList      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Quantities on Hand by Parameter List</title>\n <name>QOHByParameterList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("onlyShowPositive") ?>\n         text('Only Showing Positive Quantities')\n       &lt;? elseif exists("onlyShowNegative") ?>\n         text('Only Showing Negative Quantities')\n       &lt;? else ?>\n         text('Showing All Quantities')\n       &lt;? endif ?>\n       AS showquantities,\n       &lt;? if exists("showValue") ?>\n         text('Unit Cost') AS lbl_unitcost,\n         text('Value') AS lbl_value,\n         text('NN Value') AS lbl_nnvalue,\n         text('Cost Method') AS lbl_costmethod,\n       &lt;? else ?>\n         text('') AS lbl_unitcost,\n         text('') AS lbl_value,\n         text('') AS lbl_nnvalue,\n         text('') AS lbl_costmethod,\n       &lt;? endif ?>\n       &lt;? if exists("showValue") ?>\n         &lt;? if exists("useActualCosts") ?>\n           text('Showing Actual Costs')\n         &lt;? elseif exists("useStandardCosts") ?>\n           text('Showing Standard Costs')\n         &lt;? else ?>\n           text('Showing Posted Costs')\n         &lt;? endif ?>\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS showvalues;\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT itemsite_id,\n       detail,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       uom_name,\n       warehous_code,\n       formatQty(reorderlevel) AS f_reorderlevel,\n       formatQty(qoh) AS f_qoh,\n       CASE WHEN (NOT useDefaultLocation(itemsite_id)) THEN 'None'\n                 ELSE defaultLocationName(itemsite_id)\n       END AS defaultlocation,\n       formatQty(nonnetable) AS f_nonnetable,\n       &lt;? if exists("showValue") ?>\n         formatCost(standardcost)\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_unitcost,\n       &lt;? if exists("showValue") ?>\n         formatExtPrice((standardcost * qoh))\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_value,\n       &lt;? if exists("showValue") ?>\n         CASE WHEN (itemsite_loccntrl) THEN formatExtPrice((standardcost * nonnetable))\n              ELSE 'N/A'\n         END\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_nonnetvalue,\n       standardcost,\n       qoh,\n       nonnetable,\n       qoh AS r_qoh,\n       nonnetable AS r_nonnetable,\n       &lt;? if exists("showValue") ?>\n         (standardcost * qoh)\n       &lt;? else ?>\n         0\n       &lt;? endif ?>\n       AS r_value,\n       &lt;? if exists("showValue") ?>\n         CASE WHEN (itemsite_loccntrl) THEN (standardcost * nonnetable)\n              ELSE 0\n         END\n       &lt;? else ?>\n         0\n       &lt;? endif ?>\n       AS r_nonnetvalue,\n       &lt;? if exists("showValue") ?>\n         &lt;? if exists("usePostedCosts") ?>\n           CASE WHEN(itemsite_costmethod='A') THEN text('Average')\n                WHEN(itemsite_costmethod='S') THEN text('Standard')\n                WHEN(itemsite_costmethod='J') THEN text('Job')\n                WHEN(itemsite_costmethod='N') THEN text('None')\n                ELSE text('UNKNOWN')\n           END\n         &lt;? else ?>\n           text('')\n         &lt;? endif ?>\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_costmethod\nFROM ( SELECT itemsite_id, itemsite_costmethod,\n              item_number,\n              item_descrip1, item_descrip2, itemsite_loccntrl,\n              warehous_code,\n              uom_name,\n              CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel,\n              itemsite_qtyonhand AS qoh,\n              CASE WHEN ((itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S'))) THEN 1\n                   ELSE 0\n              END AS detail,\n              itemsite_nnqoh AS nonnetable,\n              &lt;? if exists("useActualCosts") ?>\n                actcost(itemsite_item_id)\n              &lt;? elseif exists("useStandardCosts") ?>\n                stdcost(itemsite_item_id)\n              &lt;? else ?>\n                (itemsite_value / CASE WHEN(itemsite_qtyonhand=0) THEN 1 ELSE itemsite_qtyonhand END)\n              &lt;? endif ?>\n              AS standardcost\n         FROM itemsite, item, uom, warehous, costcat\n        WHERE ((itemsite_item_id=item_id)\n          AND (item_inv_uom_id=uom_id)\n          AND (itemsite_warehous_id=warehous_id)\n          AND (itemsite_costcat_id=costcat_id)\n          AND (itemsite_active)\n&lt;? if exists("classcode_id") ?>\n          AND (item_classcode_id=&lt;? value("classcode_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("classcode_pattern") ?>\n          AND (item_classcode_id IN (SELECT classcode_id\n                                       FROM classcode\n                                      WHERE (classcode_code ~ &lt;? value("classcode_pattern") ?>) ) )\n&lt;? endif ?>\n&lt;? if exists("costcat_id") ?>\n          AND (costcat_id=&lt;? value("costcat_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("costcat_pattern") ?>\n          AND (costcat_id IN (SELECT costcat_id\n                                       FROM costcat\n                                      WHERE (costcat_code ~ &lt;? value("costcat_pattern") ?>) ) )\n&lt;? endif ?>\n&lt;? if exists("itemgrp_id") ?>\n          AND (item_id IN (SELECT itemgrpitem_item_id FROM itemgrpitem WHERE (itemgrpitem_itemgrp_id=&lt;? value("itemgrp_id") ?>)))\n&lt;? endif ?>\n&lt;? if exists("itemgrp_pattern") ?>\n          AND (item_id IN (SELECT itemgrpitem_item_id\n                             FROM itemgrpitem, itemgrp\n                            WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n                              AND (itemgrp_name ~ &lt;? value("itemgrp_pattern") ?>) ) ))\n&lt;? endif ?>\n&lt;? if exists("onlyShowPositive") ?>\n          AND (itemsite_qtyonhand > 0)\n&lt;? elseif exists("onlyShowNegative") ?>\n          AND (itemsite_qtyonhand &lt; 0)\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n          AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n) ) AS data\nORDER BY warehous_code, item_number;\n</sql>\n </querysource>\n <rpthead>\n  <height>234</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_value</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>509</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unitcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>200</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <field>\n   <rect>\n    <x>185</x>\n    <y>43</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>showvalues</column>\n   </data>\n  </field>\n  <line>\n   <xstart>8</xstart>\n   <ystart>231.167</ystart>\n   <xend>748</xend>\n   <yend>231.167</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Non-Netable</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Lvl.</string>\n  </label>\n  <label>\n   <rect>\n    <x>104</x>\n    <y>200</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_nnvalue</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>215</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Default Location</string>\n  </label>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>43</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>showquantities</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_costmethod</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>104</x>\n    <y>215</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>58</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>8</y>\n    <width>240</width>\n    <height>35</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Quantity On Hand</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_value</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>0</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_nnvalue</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>509</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unitcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>104</x>\n    <y>15</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>104</x>\n    <y>0</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_costmethod</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Lvl.</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Non-Netable</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>15</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Default Location</string>\n  </label>\n  <line>\n   <xstart>10</xstart>\n   <ystart>33.3333</ystart>\n   <xend>750</xend>\n   <yend>33.3333</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>265</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_reorderlevel</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>104</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>104</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>defaultlocation</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_value</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>345</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qoh</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>104</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_nonnetvalue</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_costmethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_unitcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_nonnetable</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>425</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>r_nonnetable</column>\n   </data>\n   <format>%.02f</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>r_value</column>\n   </data>\n   <format>%.02f</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>r_nonnetvalue</column>\n   </data>\n   <format>%.02f</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>345</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>r_qoh</column>\n   </data>\n   <format>%.02f</format>\n   <tracktotal/>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Totals</string>\n  </label>\n </rptfoot>\n</report>\n     \N      0       2011-01-31 14:51:44.665252
102412
 
444     Bookings        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Bookings</title>\n <name>Bookings</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT cohead_number AS sonumber,\n       formatDate(cohead_orderdate) AS orddate,\n       cust_number, cust_name,\n       item_number, item_descrip1, item_descrip2,\n       formatQty(coitem_qtyord) AS ordered,\nformatPrice(currtobase(cohead_curr_id,coitem_price,cohead_orderdate) / coitem_price_invuomratio) AS unitprice,\nformatExtPrice(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n                   * (currtobase(cohead_curr_id,coitem_price,cohead_orderdate) / coitem_price_invuomratio),2)) AS f_extprice\n  FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n              JOIN custinfo ON (cust_id=cohead_cust_id)\n              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n              JOIN site() ON (warehous_id=itemsite_warehous_id)\n              JOIN item ON (item_id=itemsite_item_id)\n              JOIN uom ON (uom_id=coitem_qty_uom_id)\n              JOIN curr_symbol ON (curr_id=cohead_curr_id)\n  WHERE ( (coitem_status&lt;>'X')\n  &lt;? if exists("cohead_id") ?>\n    AND  (coitem_cohead_id=&lt;? value("cohead_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("openOnly") ?>\n    AND  (coitem_status&lt;>'C')\n  &lt;? endif ?>\n  &lt;? if exists("startDate") ?>\n    AND  (cohead_orderdate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n  &lt;? endif ?>\n\n  &lt;? if exists("salesrep_id") ?>\n    AND  (cohead_salesrep_id=&lt;? value("salesrep_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("shipto_id") ?>\n    AND  (cohead_shipto_id=&lt;? value("shipto_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("cust_id") ?>\n    AND  (cohead_cust_id=&lt;? value("cust_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("custtype_id") ?>\n    AND  (cust_custtype_id=&lt;? value("custtype_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("custtype_pattern") ?>\n    AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                               FROM custtype\n                               WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n  &lt;? endif ?>\n  &lt;? if exists("custgrp") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem))\n  &lt;? endif ?>\n  &lt;? if exists("custgrp_id") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem\n                     WHERE (custgrpitem_custgrp_id=&lt;? value("custgrp_id") ?>)))\n  &lt;? endif ?>\n  &lt;? if exists("custgrp_pattern") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrp, custgrpitem\n                     WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                       AND   (custgrp_name ~ &lt;? value("custgrp_pattern") ?>) )) )\n  &lt;? endif ?>\n\n  &lt;? if exists("item_id") ?>\n    AND  (itemsite_item_id=&lt;? value("item_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("prodcat_id") ?>\n    AND (item_prodcat_id=&lt;? value("prodcat_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                             FROM prodcat\n                             WHERE (prodcat_code ~ &lt;? value("prodcat_pattern") ?>)))\n  &lt;? endif ?>\n\n  &lt;? if exists("warehous_id") ?>\n    AND  (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n  &lt;? endif ?>\n)\nORDER BY cohead_orderdate;\n      </sql>\n </querysource>\n <rpthead>\n  <height>237</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ord. Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>233</ystart>\n   <xend>745</xend>\n   <yend>233</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Unit Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ext'd Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Bookings</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Name</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>41</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Unit Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ord. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ext'd Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>52</height>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>432</x>\n     <y>15</y>\n     <width>225</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sonumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>432</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_extprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>15</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>unitprice</column>\n    </data>\n   </field>\n   <line>\n    <xstart>4</xstart>\n    <ystart>47</ystart>\n    <xend>744</xend>\n    <yend>47</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>432</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>orddate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>102</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102413
 
445     BriefSalesHistory       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Brief Sales History</title>\n <name>BriefSalesHistory</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("startDate") ?>\n         formatDate(date(&lt;? value("startDate") ?>))\n       &lt;? else ?>\n         text('Earliest')\n       &lt;? endif ?> AS startDate,\n       &lt;? if exists("endDate") ?>\n         formatDate(date(&lt;? value("endDate") ?>))\n       &lt;? else ?>\n         text('Latest')\n       &lt;? endif ?> AS endDate,\n       &lt;? if exists("showPrices") ?>\n           text('Unit Price') AS lbl_unitprice,\n           text('Total') AS lbl_total,\n       &lt;? else ?>\n           text('') AS lbl_unitprice,\n           text('') AS lbl_total,\n       &lt;? endif ?>\n       &lt;? if exists("warehous_id") ?>\n         (SELECT warehous_code FROM whsinfo WHERE warehous_id=&lt;? value("warehous_id") ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("cust_id") ?>\n         (SELECT cust_name FROM custinfo WHERE cust_id=&lt;? value("cust_id") ?>)\n       &lt;? else ?>\n         text('All Customers')\n       &lt;? endif ?>\n         AS cust_name,\n       &lt;? if exists("custtype_id") ?>\n         (SELECT custtype_code FROM custtype WHERE custtype_id=&lt;? value("custtype_id") ?>)\n       &lt;? else ?>\n         text('All Customer Types')\n       &lt;? endif ?>\n         AS custtype_code,\n       &lt;? if exists("custtype_pattern") ?>\n           text(&lt;? value("custtype_pattern") ?>)\n       &lt;? else ?>\n           text('Not Applicable')\n       &lt;? endif ?>\n         AS custtype_pattern,\n       &lt;? if exists("custgrp_id") ?>\n         (SELECT custgrp_name FROM custgrp WHERE custgrp_id=&lt;? value("custgrp_id") ?>)\n       &lt;? else ?>\n         text('All Customer Groups')\n       &lt;? endif ?>\n         AS custgrp_name,\n       &lt;? if exists("custgrp_pattern") ?>\n           text(&lt;? value("custgrp_pattern") ?>)\n       &lt;? else ?>\n           text('Not Applicable')\n       &lt;? endif ?>\n         AS custgrp_pattern,\n      &lt;? if exists("prodcat_id") ?>\n         (SELECT prodcat_code FROM prodcat WHERE prodcat_id=&lt;? value("prodcat_id") ?>)\n       &lt;? else ?>\n         text('All Product Categories')\n       &lt;? endif ?>\n         AS prodcat_code,\n       &lt;? if exists("prodcat_pattern") ?>\n           text(&lt;? value("prodcat_pattern") ?>)\n       &lt;? else ?>\n           text('Not Applicable')\n       &lt;? endif ?>\n         AS prodcat_pattern,\n       &lt;? if exists("item_id") ?>\n         (SELECT item_number FROM item WHERE item_id=&lt;? value("item_id") ?>)\n       &lt;? else ?>\n         text('All Item Numbers')\n       &lt;? endif ?>\n         AS item_number,\n       &lt;? if exists("cohead_id") ?>\n         (SELECT cohead_number FROM cohead WHERE cohead_id=&lt;? value("cohead_id") ?>)\n       &lt;? else ?>\n         text('All Orders')\n       &lt;? endif ?>\n         AS docnumber; </sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>briefSalesHistory</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>355</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Invc. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Invoice #</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>5</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Brief Sales History</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ord. Date</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>218</ystart>\n   <xend>745</xend>\n   <yend>218</yend>\n   <weight>2</weight>\n  </line>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>38</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ord. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Invoice #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>355</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohist_ordernumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invoicenumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_baseextprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>355</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_invcdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_orderdate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>103</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Total:</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>baseextprice</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n </rptfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102414
 
211     CashReceiptsEditList    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Cash Receipt Edit List</title>\n <name>CashReceiptsEditList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT cashrcpt_id, 1 AS orderBy,\n       cust_number, cust_name,\n       formatDate(cashrcpt_distdate) AS f_distdate,\n       CASE WHEN (cashrcpt_fundstype = 'C') THEN &lt;? value("check") ?>\n            WHEN (cashrcpt_fundstype = 'T') THEN &lt;? value("certifiedCheck") ?>\n            WHEN (cashrcpt_fundstype = 'M') THEN &lt;? value("masterCard") ?>\n            WHEN (cashrcpt_fundstype = 'V') THEN &lt;? value("visa") ?>\n            WHEN (cashrcpt_fundstype = 'A') THEN &lt;? value("americanExpress") ?>\n            WHEN (cashrcpt_fundstype = 'D') THEN &lt;? value("discoverCard") ?>\n            WHEN (cashrcpt_fundstype = 'R') THEN &lt;? value("otherCreditCard") ?>\n            WHEN (cashrcpt_fundstype = 'K') THEN &lt;? value("cash") ?>\n            WHEN (cashrcpt_fundstype = 'W') THEN &lt;? value("wireTransfer") ?>\n            ELSE &lt;? value("other") ?>\n       END AS f_fundstype,\n       'C/R' AS doctype,\n       cashrcpt_docnumber AS docnumber,\n       cashrcpt_amount AS amount,\n       formatMoney(cashrcpt_amount) AS f_amount,\n       0 AS detailedamount,\n       formatMoney(0) AS f_detailedamount,\n       bankaccnt_name\nFROM cashrcpt, bankaccnt, custinfo\nWHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id)\n  AND   (cashrcpt_cust_id=cust_id)\n  AND   (NOT cashrcpt_posted)\n  AND   (NOT cashrcpt_void) )\n\nUNION\nSELECT cashrcpt_id, 2 AS orderBy,\n       '' AS cust_number, '' AS cust_name,\n       '' AS f_distdate,\n       '' AS f_fundstype,\n       aropen_doctype AS doctype,\n       aropen_docnumber AS docnumber,\n       0 AS amount,\n       formatMoney(0) AS f_amount,\n       cashrcptitem_amount AS detailedamount,\n       formatMoney(cashrcptitem_amount) AS f_detailedamount,\n       '' AS bankaccnt_name\nFROM cashrcptitem, cashrcpt, aropen\nWHERE ( (cashrcptitem_cashrcpt_id=cashrcpt_id)\n  AND   (cashrcptitem_aropen_id=aropen_id)\n  AND   (NOT cashrcpt_posted)\n  AND   (NOT cashrcpt_void) )\n\nUNION\nSELECT cashrcpt_id, 3 AS orderBy,\n       '' AS cust_number, '' AS cust_name,\n       '' AS f_distdate,\n       '' AS f_fundstype,\n       'Misc.' AS doctype,\n       (formatGLAccount(accnt_id) || '-' || accnt_descrip) AS docnumber,\n       0 AS amount,\n       formatMoney(0) AS f_amount,\n       cashrcptmisc_amount AS detailedamount,\n       formatMoney(cashrcptmisc_amount) AS f_detailedamount,\n       '' AS bankaccnt_name\nFROM cashrcptmisc, cashrcpt, accnt\nWHERE ( (cashrcptmisc_cashrcpt_id=cashrcpt_id)\n  AND   (cashrcptmisc_accnt_id=accnt_id)\n  AND   (NOT cashrcpt_posted)\n  AND   (NOT cashrcpt_void) )\n\nORDER BY cashrcpt_id, orderBy;\n\n</sql>\n </querysource>\n <rpthead>\n  <height>145</height>\n  <label>\n   <rect>\n    <x>80</x>\n    <y>100</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>113</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount Applied</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>100</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>113</y>\n    <width>155</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Document/Account Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>113</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>100</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Payment Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>100</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cust #</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>5</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Cash Receipts Edit List</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>130</ystart>\n   <xend>745</xend>\n   <yend>130</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>229</x>\n    <y>100</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Dist. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>415</x>\n    <y>100</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reference #</string>\n  </label>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>100</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Bank Account</string>\n  </label>\n </rpthead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>cashrcpt_id</column>\n   <head>\n    <height>18</height>\n    <field>\n     <rect>\n      <x>540</x>\n      <y>0</y>\n      <width>60</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_amount</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>85</x>\n      <y>0</y>\n      <width>130</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>cust_name</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>615</x>\n      <y>0</y>\n      <width>125</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>bankaccnt_name</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>0</y>\n      <width>60</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>cust_number</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>315</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_fundstype</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>409</x>\n      <y>0</y>\n      <width>110</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>docnumber</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>229</x>\n      <y>0</y>\n      <width>60</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_distdate</column>\n     </data>\n    </field>\n   </head>\n   <foot>\n    <height>41</height>\n    <field>\n     <rect>\n      <x>670</x>\n      <y>5</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>detailedamount</column>\n     </data>\n     <format builtin="true">extprice</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <line>\n     <xstart>5</xstart>\n     <ystart>25</ystart>\n     <xend>740</xend>\n     <yend>25</yend>\n     <weight>2</weight>\n    </line>\n    <label>\n     <rect>\n      <x>585</x>\n      <y>5</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Applications:</string>\n    </label>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>0</y>\n     <width>315</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>15</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_detailedamount</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>28</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>43</height>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>amount</column>\n   </data>\n   <format builtin="true">extprice</format>\n   <tracktotal/>\n  </field>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Total Receipts:</string>\n  </label>\n  <line>\n   <xstart>7</xstart>\n   <ystart>28</ystart>\n   <xend>742</xend>\n   <yend>28</yend>\n   <weight>2</weight>\n  </line>\n </rptfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102415
 
189     CostedIndentedBOM       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Costed Indented Bill of Materials</title>\n <name>CostedIndentedBOM</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       uom_name AS item_invuom,\n       item_descrip1,\n       item_descrip2,\n       &lt;? if exists("useActualCosts") ?>\n         text('Using Actual Costs') AS lbl_usecosts,\n         (SELECT formatCost(SUM(bomdata_actextendedcost))\n          FROM indentedbom(&lt;? value("item_id") ?>,&lt;? value("revision_id") ?>,0,0)\n          WHERE (bomdata_bomwork_level=1)) as t_extendedcost,\n       &lt;? else ?>\n         text('Using Standard Costs') AS lbl_usecosts,\n         (SELECT formatCost(SUM(bomdata_stdextendedcost))\n          FROM indentedbom(&lt;? value("item_id") ?>,&lt;? value("revision_id") ?>,0,0)\n          WHERE (bomdata_bomwork_level=1)) as t_extendedcost,\n       &lt;? endif ?>\n       formatCost(actcost(item_id)) AS f_actual,\n       formatCost(stdcost(item_id)) AS f_standard\n  FROM item JOIN uom ON (uom_id=item_inv_uom_id)\n WHERE (item_id=&lt;? value("item_id") ?>);\n    </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>select (REPEAT(' ',(bomdata_bomwork_level-1)*3) || bomdata_bomwork_seqnumber) AS f_seqnumber,\n       1 AS seq_ord,\n       bomdata_item_number AS item_number,\n       bomdata_uom_name AS item_invuom,\n       bomdata_item_descrip1 AS item_descrip1,\n       bomdata_item_descrip2 AS item_descrip2,\n       bomdata_createchild as createchild,\n       bomdata_issuemethod AS issuemethod,\n       formatQtyPer(bomdata_qtyreq) AS qtyreq,\n       formatScrap(bomdata_scrap) AS scrap,\n       CASE WHEN COALESCE(bomdata_effective, startOfTime()) &lt;= startOfTime() THEN\n                 &lt;? value("always") ?> \n            ELSE formatDate(bomdata_effective)\n       END AS effective,\n       CASE WHEN COALESCE(bomdata_expires, endOfTime()) &lt;= endOfTime() THEN\n                 &lt;? value("never") ?>\n            ELSE formatDate(bomdata_expires)\n       END AS expires,\n&lt;? if exists("useActualCosts") ?>\n       formatCost(bomdata_actunitcost) AS f_unitcost,\n       formatCost(bomdata_actextendedcost) AS f_extendedcost,\n       CASE WHEN(bomdata_bomwork_parent_id=-1) THEN bomdata_actextendedcost\n            ELSE 0\n       END AS extendedcost,\n&lt;? else ?>\n       formatCost(bomdata_stdunitcost) AS f_unitcost,\n       formatCost(bomdata_stdextendedcost) AS f_extendedcost,\n       CASE WHEN(bomdata_bomwork_parent_id=-1) THEN bomdata_stdextendedcost\n            ELSE 0\n       END AS extendedcost,\n&lt;? endif ?>\n       bomdata_bomwork_level\nFROM indentedBOM(&lt;? value("item_id") ?>,&lt;? value("revision_id") ?>,0,0);\n</sql>\n </querysource>\n <querysource>\n  <name>bomhead</name>\n  <sql>SELECT bomhead_docnum, bomhead_revision,\nformatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=&lt;? value("item_id") ?>)\nAND (bomhead_rev_id=&lt;? value("revision_id") ?>));</sql>\n </querysource>\n <rpthead>\n  <height>242</height>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>204</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>104</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>104</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Document #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>204</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Qty. Req.</string>\n  </label>\n  <label>\n   <rect>\n    <x>114</x>\n    <y>204</y>\n    <width>165</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>235</ystart>\n   <xend>745</xend>\n   <yend>235</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>104</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_docnum</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>204</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>220</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>145</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>204</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Unit Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>204</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>145</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_revision</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>204</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>419</x>\n    <y>204</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <field>\n   <rect>\n    <x>315</x>\n    <y>104</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_invuom</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>125</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>145</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision:</string>\n  </label>\n  <field>\n   <rect>\n    <x>350</x>\n    <y>60</y>\n    <width>205</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_usecosts</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>104</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>10</y>\n    <width>465</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Costed Indented Bill of Materials</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>125</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>114</x>\n    <y>220</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>104</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>220</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>125</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>f_revisiondate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>220</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext'd Cost</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>114</x>\n    <y>0</y>\n    <width>165</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext'd Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Qty. Req.</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>114</x>\n    <y>15</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>419</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Unit Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>52</height>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>effective</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>114</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>114</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>104</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_seqnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>expires</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_extendedcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>340</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyreq</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>275</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_invuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_unitcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>419</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>issuemethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createchild</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>114</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>47</height>\n  <label>\n   <rect>\n    <x>484</x>\n    <y>30</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Standard Cost:</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_actual</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>30</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_standard</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>t_extendedcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Actual Cost:</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Total Cost:</string>\n  </label>\n </rptfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102416
 
104     Alignment       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Alignment</title>\n <name>Alignment</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>0</topmargin>\n <bottommargin>0</bottommargin>\n <rightmargin>0</rightmargin>\n <leftmargin>0</leftmargin>\n <rpthead>\n  <height>1152</height>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>795</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>800</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>250</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>600</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>919</ystart>\n   <xend>850</xend>\n   <yend>919</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>580</xstart>\n   <ystart>0</ystart>\n   <xend>580</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>280</xstart>\n   <ystart>0</ystart>\n   <xend>280</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>470</ystart>\n   <xend>850</xend>\n   <yend>470</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>869</ystart>\n   <xend>850</xend>\n   <yend>869</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>800</ystart>\n   <xend>850</xend>\n   <yend>800</yend>\n   <weight>1</weight>\n  </line>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>195</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>200</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>459</ystart>\n   <xend>850</xend>\n   <yend>459</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>340</xstart>\n   <ystart>0</ystart>\n   <xend>340</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>690</ystart>\n   <xend>850</xend>\n   <yend>690</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>960</ystart>\n   <xend>850</xend>\n   <yend>960</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1090</ystart>\n   <xend>850</xend>\n   <yend>1090</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>380</ystart>\n   <xend>850</xend>\n   <yend>380</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>560</xstart>\n   <ystart>0</ystart>\n   <xend>560</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>300</ystart>\n   <xend>850</xend>\n   <yend>300</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1120</ystart>\n   <xend>850</xend>\n   <yend>1120</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>819</ystart>\n   <xend>850</xend>\n   <yend>819</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>350</xstart>\n   <ystart>0</ystart>\n   <xend>350</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>30</ystart>\n   <xend>850</xend>\n   <yend>30</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>170</xstart>\n   <ystart>0</ystart>\n   <xend>170</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>990</ystart>\n   <xend>850</xend>\n   <yend>990</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>760</ystart>\n   <xend>850</xend>\n   <yend>760</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>0</ystart>\n   <xend>0</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>220</ystart>\n   <xend>850</xend>\n   <yend>220</yend>\n   <weight>1</weight>\n  </line>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>595</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>600</string>\n  </label>\n  <line>\n   <xstart>360</xstart>\n   <ystart>0</ystart>\n   <xend>360</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>10</ystart>\n   <xend>850</xend>\n   <yend>10</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1150</ystart>\n   <xend>850</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>210</ystart>\n   <xend>850</xend>\n   <yend>210</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>570</ystart>\n   <xend>850</xend>\n   <yend>570</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>70</xstart>\n   <ystart>0</ystart>\n   <xend>70</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>100</ystart>\n   <xend>850</xend>\n   <yend>100</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>400</xstart>\n   <ystart>0</ystart>\n   <xend>400</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>540</xstart>\n   <ystart>0</ystart>\n   <xend>540</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>695</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>700</string>\n  </label>\n  <line>\n   <xstart>730</xstart>\n   <ystart>0</ystart>\n   <xend>730</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>250</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>300</string>\n  </label>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>250</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>700</string>\n  </label>\n  <line>\n   <xstart>20</xstart>\n   <ystart>0</ystart>\n   <xend>20</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>900</ystart>\n   <xend>850</xend>\n   <yend>900</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>220</xstart>\n   <ystart>0</ystart>\n   <xend>220</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>200</xstart>\n   <ystart>0</ystart>\n   <xend>200</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>509</ystart>\n   <xend>850</xend>\n   <yend>509</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>300</xstart>\n   <ystart>0</ystart>\n   <xend>300</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>740</ystart>\n   <xend>850</xend>\n   <yend>740</yend>\n   <weight>1</weight>\n  </line>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>395</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>400</string>\n  </label>\n  <line>\n   <xstart>490</xstart>\n   <ystart>0</ystart>\n   <xend>490</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>530</ystart>\n   <xend>850</xend>\n   <yend>530</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>930</ystart>\n   <xend>850</xend>\n   <yend>930</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>630</xstart>\n   <ystart>0</ystart>\n   <xend>630</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>980</ystart>\n   <xend>850</xend>\n   <yend>980</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>620</ystart>\n   <xend>850</xend>\n   <yend>620</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>780</xstart>\n   <ystart>0</ystart>\n   <xend>780</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>670</ystart>\n   <xend>850</xend>\n   <yend>670</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>420</xstart>\n   <ystart>0</ystart>\n   <xend>420</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>180</ystart>\n   <xend>850</xend>\n   <yend>180</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>150</ystart>\n   <xend>850</xend>\n   <yend>150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>730</ystart>\n   <xend>850</xend>\n   <yend>730</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>80</xstart>\n   <ystart>0</ystart>\n   <xend>80</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>400</ystart>\n   <xend>850</xend>\n   <yend>400</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>110</ystart>\n   <xend>850</xend>\n   <yend>110</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>310</ystart>\n   <xend>850</xend>\n   <yend>310</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>940</ystart>\n   <xend>850</xend>\n   <yend>940</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>640</ystart>\n   <xend>850</xend>\n   <yend>640</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1040</ystart>\n   <xend>850</xend>\n   <yend>1040</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>140</xstart>\n   <ystart>0</ystart>\n   <xend>140</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>295</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>300</string>\n  </label>\n  <line>\n   <xstart>440</xstart>\n   <ystart>0</ystart>\n   <xend>440</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>280</ystart>\n   <xend>850</xend>\n   <yend>280</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>660</ystart>\n   <xend>850</xend>\n   <yend>660</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>30</xstart>\n   <ystart>0</ystart>\n   <xend>30</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>130</xstart>\n   <ystart>0</ystart>\n   <xend>130</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>950</ystart>\n   <xend>850</xend>\n   <yend>950</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>40</ystart>\n   <xend>850</xend>\n   <yend>40</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>650</ystart>\n   <xend>850</xend>\n   <yend>650</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>700</ystart>\n   <xend>850</xend>\n   <yend>700</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>470</xstart>\n   <ystart>0</ystart>\n   <xend>470</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>130</ystart>\n   <xend>850</xend>\n   <yend>130</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>260</ystart>\n   <xend>850</xend>\n   <yend>260</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>360</ystart>\n   <xend>850</xend>\n   <yend>360</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>890</ystart>\n   <xend>850</xend>\n   <yend>890</yend>\n   <weight>1</weight>\n  </line>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>895</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>900</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>350</ystart>\n   <xend>850</xend>\n   <yend>350</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>480</ystart>\n   <xend>850</xend>\n   <yend>480</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>260</xstart>\n   <ystart>0</ystart>\n   <xend>260</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>1095</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>1100</string>\n  </label>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>250</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>200</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>250</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>400</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>370</ystart>\n   <xend>850</xend>\n   <yend>370</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>550</xstart>\n   <ystart>0</ystart>\n   <xend>550</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>250</xstart>\n   <ystart>0</ystart>\n   <xend>250</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>600</ystart>\n   <xend>850</xend>\n   <yend>600</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>600</xstart>\n   <ystart>0</ystart>\n   <xend>600</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>0</ystart>\n   <xend>850</xend>\n   <yend>0</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>509</xstart>\n   <ystart>0</ystart>\n   <xend>509</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>640</xstart>\n   <ystart>0</ystart>\n   <xend>640</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>409</xstart>\n   <ystart>0</ystart>\n   <xend>409</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>250</ystart>\n   <xend>850</xend>\n   <yend>250</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>480</xstart>\n   <ystart>0</ystart>\n   <xend>480</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>50</ystart>\n   <xend>850</xend>\n   <yend>50</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>720</ystart>\n   <xend>850</xend>\n   <yend>720</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1070</ystart>\n   <xend>850</xend>\n   <yend>1070</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>819</xstart>\n   <ystart>0</ystart>\n   <xend>819</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>770</ystart>\n   <xend>850</xend>\n   <yend>770</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>560</ystart>\n   <xend>850</xend>\n   <yend>560</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>20</ystart>\n   <xend>850</xend>\n   <yend>20</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>90</ystart>\n   <xend>850</xend>\n   <yend>90</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>860</ystart>\n   <xend>850</xend>\n   <yend>860</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>660</xstart>\n   <ystart>0</ystart>\n   <xend>660</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>790</xstart>\n   <ystart>0</ystart>\n   <xend>790</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>580</ystart>\n   <xend>850</xend>\n   <yend>580</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>459</xstart>\n   <ystart>0</ystart>\n   <xend>459</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>170</ystart>\n   <xend>850</xend>\n   <yend>170</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>50</xstart>\n   <ystart>0</ystart>\n   <xend>50</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <label>\n   <rect>\n    <x>750</x>\n    <y>250</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>800</string>\n  </label>\n  <line>\n   <xstart>150</xstart>\n   <ystart>0</ystart>\n   <xend>150</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1100</ystart>\n   <xend>850</xend>\n   <yend>1100</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>500</xstart>\n   <ystart>0</ystart>\n   <xend>500</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>70</ystart>\n   <xend>850</xend>\n   <yend>70</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>610</ystart>\n   <xend>850</xend>\n   <yend>610</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1140</ystart>\n   <xend>850</xend>\n   <yend>1140</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>110</xstart>\n   <ystart>0</ystart>\n   <xend>110</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>770</xstart>\n   <ystart>0</ystart>\n   <xend>770</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>590</ystart>\n   <xend>850</xend>\n   <yend>590</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>740</xstart>\n   <ystart>0</ystart>\n   <xend>740</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>630</ystart>\n   <xend>850</xend>\n   <yend>630</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1030</ystart>\n   <xend>850</xend>\n   <yend>1030</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>690</xstart>\n   <ystart>0</ystart>\n   <xend>690</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>95</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>100</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>550</ystart>\n   <xend>850</xend>\n   <yend>550</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>140</ystart>\n   <xend>850</xend>\n   <yend>140</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1050</ystart>\n   <xend>850</xend>\n   <yend>1050</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1019</ystart>\n   <xend>850</xend>\n   <yend>1019</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>520</xstart>\n   <ystart>0</ystart>\n   <xend>520</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1000</ystart>\n   <xend>850</xend>\n   <yend>1000</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>100</xstart>\n   <ystart>0</ystart>\n   <xend>100</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>450</xstart>\n   <ystart>0</ystart>\n   <xend>450</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>720</xstart>\n   <ystart>0</ystart>\n   <xend>720</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>160</xstart>\n   <ystart>0</ystart>\n   <xend>160</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>60</ystart>\n   <xend>850</xend>\n   <yend>60</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>450</ystart>\n   <xend>850</xend>\n   <yend>450</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>760</xstart>\n   <ystart>0</ystart>\n   <xend>760</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>420</ystart>\n   <xend>850</xend>\n   <yend>420</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>680</xstart>\n   <ystart>0</ystart>\n   <xend>680</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>850</ystart>\n   <xend>850</xend>\n   <yend>850</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>650</xstart>\n   <ystart>0</ystart>\n   <xend>650</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>620</xstart>\n   <ystart>0</ystart>\n   <xend>620</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>190</ystart>\n   <xend>850</xend>\n   <yend>190</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>409</ystart>\n   <xend>850</xend>\n   <yend>409</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>40</xstart>\n   <ystart>0</ystart>\n   <xend>40</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>700</xstart>\n   <ystart>0</ystart>\n   <xend>700</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1010</ystart>\n   <xend>850</xend>\n   <yend>1010</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>800</xstart>\n   <ystart>0</ystart>\n   <xend>800</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>240</xstart>\n   <ystart>0</ystart>\n   <xend>240</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>310</xstart>\n   <ystart>0</ystart>\n   <xend>310</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>710</xstart>\n   <ystart>0</ystart>\n   <xend>710</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>540</ystart>\n   <xend>850</xend>\n   <yend>540</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>10</xstart>\n   <ystart>0</ystart>\n   <xend>10</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>570</xstart>\n   <ystart>0</ystart>\n   <xend>570</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>810</ystart>\n   <xend>850</xend>\n   <yend>810</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1130</ystart>\n   <xend>850</xend>\n   <yend>1130</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>390</xstart>\n   <ystart>0</ystart>\n   <xend>390</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>229</xstart>\n   <ystart>0</ystart>\n   <xend>229</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>250</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>500</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>680</ystart>\n   <xend>850</xend>\n   <yend>680</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>270</ystart>\n   <xend>850</xend>\n   <yend>270</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>180</xstart>\n   <ystart>0</ystart>\n   <xend>180</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>850</xstart>\n   <ystart>0</ystart>\n   <xend>850</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>80</ystart>\n   <xend>850</xend>\n   <yend>80</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>240</ystart>\n   <xend>850</xend>\n   <yend>240</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>750</ystart>\n   <xend>850</xend>\n   <yend>750</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>160</ystart>\n   <xend>850</xend>\n   <yend>160</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>290</ystart>\n   <xend>850</xend>\n   <yend>290</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>910</ystart>\n   <xend>850</xend>\n   <yend>910</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>840</xstart>\n   <ystart>0</ystart>\n   <xend>840</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>229</ystart>\n   <xend>850</xend>\n   <yend>229</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>670</xstart>\n   <ystart>0</ystart>\n   <xend>670</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>330</ystart>\n   <xend>850</xend>\n   <yend>330</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>710</ystart>\n   <xend>850</xend>\n   <yend>710</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>840</ystart>\n   <xend>850</xend>\n   <yend>840</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>60</xstart>\n   <ystart>0</ystart>\n   <xend>60</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>790</ystart>\n   <xend>850</xend>\n   <yend>790</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1060</ystart>\n   <xend>850</xend>\n   <yend>1060</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>190</xstart>\n   <ystart>0</ystart>\n   <xend>190</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>590</xstart>\n   <ystart>0</ystart>\n   <xend>590</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>810</xstart>\n   <ystart>0</ystart>\n   <xend>810</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>530</xstart>\n   <ystart>0</ystart>\n   <xend>530</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>520</ystart>\n   <xend>850</xend>\n   <yend>520</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>340</ystart>\n   <xend>850</xend>\n   <yend>340</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>390</ystart>\n   <xend>850</xend>\n   <yend>390</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>90</xstart>\n   <ystart>0</ystart>\n   <xend>90</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>120</ystart>\n   <xend>850</xend>\n   <yend>120</yend>\n   <weight>1</weight>\n  </line>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>495</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>500</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>995</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>1000</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>830</ystart>\n   <xend>850</xend>\n   <yend>830</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>880</ystart>\n   <xend>850</xend>\n   <yend>880</yend>\n   <weight>1</weight>\n  </line>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>250</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>100</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>200</ystart>\n   <xend>850</xend>\n   <yend>200</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>830</xstart>\n   <ystart>0</ystart>\n   <xend>830</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>780</ystart>\n   <xend>850</xend>\n   <yend>780</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>500</ystart>\n   <xend>850</xend>\n   <yend>500</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>120</xstart>\n   <ystart>0</ystart>\n   <xend>120</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>440</ystart>\n   <xend>850</xend>\n   <yend>440</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>320</xstart>\n   <ystart>0</ystart>\n   <xend>320</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>370</xstart>\n   <ystart>0</ystart>\n   <xend>370</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>430</ystart>\n   <xend>850</xend>\n   <yend>430</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>210</xstart>\n   <ystart>0</ystart>\n   <xend>210</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>610</xstart>\n   <ystart>0</ystart>\n   <xend>610</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>290</xstart>\n   <ystart>0</ystart>\n   <xend>290</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>330</xstart>\n   <ystart>0</ystart>\n   <xend>330</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1080</ystart>\n   <xend>850</xend>\n   <yend>1080</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>430</xstart>\n   <ystart>0</ystart>\n   <xend>430</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>380</xstart>\n   <ystart>0</ystart>\n   <xend>380</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>750</xstart>\n   <ystart>0</ystart>\n   <xend>750</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>969</ystart>\n   <xend>850</xend>\n   <yend>969</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>490</ystart>\n   <xend>850</xend>\n   <yend>490</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>270</xstart>\n   <ystart>0</ystart>\n   <xend>270</xend>\n   <yend>1150</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>1110</ystart>\n   <xend>850</xend>\n   <yend>1110</yend>\n   <weight>1</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>320</ystart>\n   <xend>850</xend>\n   <yend>320</yend>\n   <weight>1</weight>\n  </line>\n </rpthead>\n</report>\n                0       2014-10-06 19:47:03.678943
102417
 
461     ItemSites       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Item Sites</title>\n <name>ItemSites</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT warehous_code,\n       formatBoolYN(itemsite_active) AS active,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       formatBoolYN(itemsite_wosupply) AS supplied,\n       formatBoolYN(itemsite_sold) AS sold,\n       itemsite_soldranking,\n       formatBoolYN(itemsite_stocked) AS stocked,\n       formatBoolYN(itemsite_createpr) AS createpr,\n       CASE WHEN (itemsite_controlmethod='N') THEN 'None'\n            WHEN (itemsite_controlmethod='R') THEN 'Regular'\n            WHEN (itemsite_controlmethod='L') THEN 'Lot #'\n            WHEN (itemsite_controlmethod='S') THEN 'Serial #'\n            ELSE '?'\n       END AS controlmethod,\n       formatBoolYN(itemsite_loccntrl) AS locationcontrol,\n       CASE WHEN (itemsite_location_id=-1) THEN 'None'\n            ELSE ( SELECT location_name\n                     FROM location\n                    WHERE (location_id=itemsite_location_id) )\n       END AS defaultlocation,\n       formatBoolYN(itemsite_useparams) AS enforceparams,\n       formatBoolYN(itemsite_useparamsmanual) AS onmanualorders,\n       formatQty(itemsite_reorderlevel) AS reorderlevel,\n       formatQty(itemsite_ordertoqty) AS orderupto,\n       formatQty(itemsite_multordqty) AS ordermult,\n       formatQty(itemsite_safetystock) AS safetystock,\n       itemsite_abcclass,\n       itemsite_cyclecountfreq,\n       itemsite_leadtime,\n       itemsite_eventfence,\n       formatQty(itemsite_qtyonhand) AS qoh,\n       formatDate(itemsite_datelastused, 'Never') AS lastused,\n       formatDate(itemsite_datelastcount, 'Never') AS lastcounted,\n       CASE WHEN(itemsite_plancode_id=-1) THEN 'Error'\n            ELSE (SELECT (plancode_code || '-' || plancode_name)\n                    FROM plancode\n                   WHERE (plancode_id=itemsite_plancode_id) )\n       END AS plannercode\n  FROM item, uom, itemsite, whsinfo\n WHERE ((itemsite_warehous_id=warehous_id)\n         AND (itemsite_item_id=item_id)\n         AND(item_inv_uom_id=uom_id)\n       &lt;? if exists("search_pattern") ?>\n         AND ((item_number ~* &lt;? value("search_pattern") ?>)\n           OR (item_descrip1 || ' ' || item_descrip2 ~* &lt;? value("search_pattern") ?>)\n           OR (warehous_code ~* &lt;? value("search_pattern") ?>))\n       &lt;? endif ?>\n       &lt;? if exists("item_id") ?>\n         AND (item_id=&lt;? value("item_id") ?>)\n       &lt;? endif ?>\n       &lt;? if exists("classcode_id") ?>\n         AND (item_classcode_id=&lt;? value("classcode_id") ?>)\n       &lt;? endif ?>\n       &lt;? if exists("itemgrp_id") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id \n                          FROM itemgrpitem \n                          WHERE (itemgrpitem_itemgrp_id=&lt;? value("itemgrp_id") ?>)))\n       &lt;? endif ?>\n       &lt;? if exists("plancode_id") ?>\n         AND (itemsite_plancode_id=&lt;? value("plancode_id") ?>)\n       &lt;? endif ?>\n       &lt;? if exists("costcat_id") ?>\n         AND (itemsite_costcat_id=&lt;? value("costcat_id") ?>)\n       &lt;? endif ?>\n       &lt;? if exists("classcode_pattern") ?>\n         AND (item_classcode_id IN (SELECT classcode_id \n                                    FROM classcode \n                                    WHERE (classcode_code ~ &lt;? value("classcode_pattern") ?>)))\n       &lt;? endif ?>\n       &lt;? if exists("itemgrp_pattern") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id \n                          FROM itemgrpitem, itemgrp \n                          WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id) \n                              AND (itemgrp_name ~ &lt;? value("itemgrp_pattern") ?>) ) ))\n       &lt;? endif ?>\n       &lt;? if exists("plancode_pattern") ?>\n         AND (itemsite_plancode_id IN (SELECT plancode_id \n                                       FROM plancode \n                                       WHERE (plancode_code ~ &lt;? value("plancode_pattern") ?>)))\n       &lt;? endif ?>\n       &lt;? if exists("costcat_pattern") ?>\n         AND (itemsite_costcat_id IN (SELECT costcat_id \n                                      FROM costcat \n                                      WHERE (costcat_code ~ &lt;? value("costcat_pattern") ?>)))\n       &lt;? endif ?>\n     &lt;? if exists("warehous_id") ?>\n       AND (warehous_id=&lt;? value("warehous_id") ?>)\n     &lt;? endif ?>\n   &lt;? if not exists("showInactive") ?>\n     AND (itemsite_active)\n   &lt;? endif ?>\n)\nORDER BY item_number, warehous_code;</sql>\n </querysource>\n <rpthead>\n  <height>281</height>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>254</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Counted</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>254</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Used</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create P/Rs</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>229</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Stocked</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>215</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>245</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Planner Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Up To</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>229</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lead Time</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>215</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ranking</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>245</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Event Fnc.</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>275</ystart>\n   <xend>745</xend>\n   <yend>275</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>254</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>200</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Enforce Params.</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Sites</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Lvl.</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>215</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cycle Cnt.</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>200</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>ABC Class</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>200</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Supplied</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>215</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>on Manual Ords.</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>215</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>200</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Location Cntrl.</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Control Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>229</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Default Loc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>229</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Mult.</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>245</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Safety Stock</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>38</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>81</height>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Location Cntrl.</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>45</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Planner Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>on Manual Ords.</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Control Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>15</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cycle Cnt.</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ranking</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>15</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create P/Rs</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>15</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>30</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Default Loc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>0</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>30</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lead Time</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>75</ystart>\n   <xend>745</xend>\n   <yend>75</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Enforce Params.</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Up To</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>55</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>45</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Event Fnc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>45</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Safety Stock</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>15</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Counted</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>30</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Stocked</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>ABC Class</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>30</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Mult.</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Used</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>0</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Supplied</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Lvl.</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>81</height>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>orderupto</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>enforceparams</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>60</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qoh</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>60</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>lastcounted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>45</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>safetystock</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>reorderlevel</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>409</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>controlmethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>0</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>280</x>\n     <y>0</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>supplied</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createpr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>280</x>\n     <y>30</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>stocked</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsite_soldranking</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>409</x>\n     <y>30</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>defaultlocation</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>409</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>locationcontrol</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>active</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>75</ystart>\n    <xend>745</xend>\n    <yend>75</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>15</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsite_cyclecountfreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>280</x>\n     <y>15</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sold</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>30</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsite_abcclass</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>15</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>15</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>onmanualorders</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>45</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>plannercode</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>345</x>\n     <y>60</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>lastused</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>45</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsite_eventfence</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>30</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ordermult</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>30</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsite_leadtime</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102418
 
339     FinancialReportMonthQuarter     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Month and Quarter</title>\n <name>FinancialReportMonthQuarter</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_month &lt;> 0) OR (flstmtitem_qtr &lt;> 0) OR (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n</sql>\n </querysource>\n <rpthead>\n  <height>167</height>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <line>\n   <xstart>0.00540306</xstart>\n   <ystart>162.686</ystart>\n   <xend>749.477</xend>\n   <yend>162.686</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>459</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>145</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>145</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n  <field>\n   <rect>\n    <x>99</x>\n    <y>59.6</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>59.5</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>4</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <line>\n   <xstart>0.393337</xstart>\n   <ystart>30</ystart>\n   <xend>750</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>459</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>460.395</x>\n    <y>14.2742</y>\n    <width>70</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n  <label>\n   <rect>\n    <x>661.636</x>\n    <y>14.2742</y>\n    <width>70</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>4</height>\n    <line>\n     <xstart>380</xstart>\n     <ystart>1</ystart>\n     <xend>740</xend>\n     <yend>1</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>19</height>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_qtrprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>459</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_monthprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>345</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_qtr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>380</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_month</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>9</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>22</height>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>7</height>\n </rptfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102419
 
334     FinancialReportMonthYear        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Month and Year</title>\n <name>FinancialReportMonthYear</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_month &lt;> 0) OR (flstmtitem_year &lt;> 0) OR (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n</sql>\n </querysource>\n <rpthead>\n  <height>166</height>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>660.651</x>\n    <y>145.302</y>\n    <width>70</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>460</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <line>\n   <xstart>2.08287</xstart>\n   <ystart>160</ystart>\n   <xend>748</xend>\n   <yend>160</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>460</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>145</y>\n    <width>70</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>460</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>99</x>\n    <y>59.6</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>59.5</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>3</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <field>\n   <rect>\n    <x>460</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <line>\n   <xstart>1.43183</xstart>\n   <ystart>30.3326</ystart>\n   <xend>748.17</xend>\n   <yend>30.3326</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>461.238</x>\n    <y>15.0901</y>\n    <width>70</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n  <label>\n   <rect>\n    <x>662.324</x>\n    <y>14.767</y>\n    <width>70</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>3</height>\n    <line>\n     <xstart>380</xstart>\n     <ystart>1</ystart>\n     <xend>740</xend>\n     <yend>1</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_yearprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_year</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>380</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_month</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>345</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>460</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_monthprcnt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>9</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>21</height>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>6</height>\n </rptfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102420
 
340     FinancialReportQuarter  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Quarter</title>\n <name>FinancialReportQuarter</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_qtr &lt;> 0) OR  (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n</sql>\n </querysource>\n <rpthead>\n  <height>168</height>\n  <line>\n   <xstart>1</xstart>\n   <ystart>160</ystart>\n   <xend>750</xend>\n   <yend>160</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>145</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>99</x>\n    <y>59.6</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>59.5</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>38</height>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <line>\n   <xstart>1</xstart>\n   <ystart>30</ystart>\n   <xend>749</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>670.717</x>\n    <y>14.9911</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>5</height>\n    <line>\n     <xstart>380</xstart>\n     <ystart>1</ystart>\n     <xend>740</xend>\n     <yend>1</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>20</height>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>550</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>590</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_qtr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_qtrprcnt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>9</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>23</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>8</height>\n </rptfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102421
 
345     FinancialReportYearPriorYear    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Year and Prior Year</title>\n <name>FinancialReportYearPriorYear</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_typedescrip2 || 'Diff.' AS f_diff,\n    flstmthead_typedescrip2 || ' % Diff.' AS f_diffprcnt,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_year &lt;> 0) OR (flstmtitem_pryear &lt;> 0) OR (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n</sql>\n </querysource>\n <rpthead>\n  <height>167</height>\n  <field>\n   <rect>\n    <x>650</x>\n    <y>130</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_pryear</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>145</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diff</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>145</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>459</x>\n    <y>130</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_pryear</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>130</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_pryear</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>650</x>\n    <y>145</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diffprcnt</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>459</x>\n    <y>145</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>130</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <line>\n   <xstart>0</xstart>\n   <ystart>160</ystart>\n   <xend>750</xend>\n   <yend>160</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <field>\n   <rect>\n    <x>99</x>\n    <y>59.6</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>59.5</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>4</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <field>\n   <rect>\n    <x>650</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_pryear</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>1</xstart>\n   <ystart>30</ystart>\n   <xend>749</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diff</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_pryear</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>459</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_pryear</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>650</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diffprcnt</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>459</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>4</height>\n    <line>\n     <xstart>360</xstart>\n     <ystart>0</ystart>\n     <xend>750</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>19</height>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>345</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>459</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_pryear</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>555</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_pryeardiff</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>360</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_year</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>650</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_pryeardiffprcnt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>9</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>22</height>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>7</height>\n </rptfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102422
 
344     FinancialReportYearBudget       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Year and Budget</title>\n <name>FinancialReportYearBudget</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_year &lt;> 0) OR (flstmtitem_yearbudget &lt;> 0) OR (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n</sql>\n </querysource>\n <rpthead>\n  <height>167</height>\n  <field>\n   <rect>\n    <x>465</x>\n    <y>130</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>130</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>145</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Budget</string>\n  </label>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>145</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>560</x>\n    <y>145</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>Budget Diff.</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>560</x>\n    <y>130</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>145</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% Diff.</string>\n  </label>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>3.53065</xstart>\n   <ystart>160</ystart>\n   <xend>749.738</xend>\n   <yend>160</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>650</x>\n    <y>130</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>99</x>\n    <y>59.6</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>59.5</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>4</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Budget</string>\n  </label>\n  <field>\n   <rect>\n    <x>355</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>650</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>355</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>-0.610015</xstart>\n   <ystart>29.5831</ystart>\n   <xend>748.788</xend>\n   <yend>29.5831</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>Budget Diff.</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% Diff.</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>4</height>\n    <line>\n     <xstart>355</xstart>\n     <ystart>0</ystart>\n     <xend>750</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>19</height>\n   <field>\n    <rect>\n     <x>459</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_yearbudget</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>560</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_yearbudgetdiff</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>650</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_yearbudgetdiffprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>360</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_year</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>345</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>9</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>22</height>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>7</height>\n </rptfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102423
 
409     FreightPricesByCustomer \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Freight Prices By Customer</title>\n <name>FreightPricesByCustomer</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT cust_name,\n       addr_line1 AS cust_address1,\n       addr_line2 AS cust_address2,\n       addr_line3 AS cust_address3,\n       &lt;? if exists("showExpired") ?>\n         text('Yes')\n       &lt;? else ?>\n         text('No')\n       &lt;? endif ?>\n       AS f_showexpired,\n       &lt;? if exists("showFuture") ?>\n         text('Yes')\n       &lt;? else ?>\n         text('No')\n       &lt;? endif ?>\n       AS f_showfuture\n   FROM custinfo\n   LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n   LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\nWHERE (cust_id=&lt;? value("cust_id") ?>);\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT itemid, sourcetype, ipshead_name, source,\n       formatQty(ipsfreight_qtybreak) AS f_qtybreak,\n       formatSalesPrice(ipsfreight_price) AS f_price,\n       CASE WHEN (ipsfreight_type = 'F') THEN 'Flat Rate'\n            ELSE 'Per UOM'\n       END AS method,\n       currConcat(ipshead_curr_id) AS currConcat,\n       CASE WHEN (warehous_code IS NULL) THEN 'Any' ELSE warehous_code END AS f_warehous,\n       CASE WHEN (shipzone_name IS NULL) THEN 'Any' ELSE shipzone_name END AS f_shipzone,\n       CASE WHEN (freightclass_code IS NULL) THEN 'Any' ELSE freightclass_code END AS f_freightclass,\n       CASE WHEN (ipsfreight_shipvia IS NULL) THEN 'Any' ELSE ipsfreight_shipvia END AS f_shipvia\n\nFROM ( SELECT ipsfreight_id AS itemid, 1 AS sourcetype,\n              ipshead_name, 'Customer' AS source,\n              ipsfreight_qtybreak, ipsfreight_price,\n              ipsfreight_type, ipshead_curr_id,\n              warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n            JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n            LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n            LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n            LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ( (ipsass_cust_id=&lt;? value("cust_id") ?>)\n AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0)\n\n&lt;? if not exists("showExpired") ?>\n     AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n     AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n\n)\nUNION SELECT ipsfreight_id AS itemid, 2 AS sourcetype,\n             ipshead_name, 'CustType' AS source,\n             ipsfreight_qtybreak, ipsfreight_price,\n             ipsfreight_type, ipshead_curr_id,\n             warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n            JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n            JOIN custinfo ON (cust_custtype_id=ipsass_custtype_id)\n            LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n            LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n            LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ( (cust_id=&lt;? value("cust_id") ?>)\n                  \n&lt;? if not exists("showExpired") ?>\n     AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n     AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n\n)\nUNION SELECT ipsfreight_id AS itemid, 3 AS sourcetype,\n             ipshead_name, 'CustTypePattern' AS source,\n             ipsfreight_qtybreak, ipsfreight_price,\n             ipsfreight_type, ipshead_curr_id,\n             warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM custinfo   JOIN custtype ON (custtype_id=cust_custtype_id)\n            JOIN ipsass ON ((coalesce(length(ipsass_custtype_pattern), 0) > 0) AND\n                            (custtype_code ~ ipsass_custtype_pattern))\n            JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n            JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n            LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n            LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n            LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ( (cust_id=&lt;? value("cust_id") ?>)\n                  \n&lt;? if not exists("showExpired") ?>\n     AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n     AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n\n)\nUNION SELECT ipsfreight_id AS itemid, 4 AS sourcetype,\n             ipshead_name, ('Sale' || '-' || sale_name) AS source,\n             ipsfreight_qtybreak, ipsfreight_price,\n             ipsfreight_type, ipshead_curr_id,\n             warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM sale JOIN ipshead ON (ipshead_id=sale_ipshead_id)\n          JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n          LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n          LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n          LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ((TRUE)\n                  \n&lt;? if not exists("showExpired") ?>\n     AND (sale_enddate > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n     AND (sale_startdate &lt;= CURRENT_DATE)\n&lt;? endif ?>\n\n) ) AS data\nORDER BY ipsfreight_qtybreak, ipsfreight_price;</sql>\n </querysource>\n <rpthead>\n  <height>234</height>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>140</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_address3</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>195</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Qty. Break</string>\n  </label>\n  <label>\n   <rect>\n    <x>145</x>\n    <y>209</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>195</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Schedule</string>\n  </label>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>100</y>\n    <width>113</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showexpired</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>195</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Method</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_address2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Freight Prices by Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>120</y>\n    <width>155</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show Future Prices:</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>209</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>To</string>\n  </label>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>120</y>\n    <width>113</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showfuture</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>195</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>From</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>100</y>\n    <width>155</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show Expired Prices:</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>195</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Freight Class</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>605</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_address1</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>228</ystart>\n   <xend>745</xend>\n   <yend>228</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>209</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>209</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship Via</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>209</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>To</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Freight Class</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Schedule</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship Via</string>\n  </label>\n  <label>\n   <rect>\n    <x>155</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Qty. Break</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>From</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_price</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>480</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_freightclass</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>15</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>currConcat</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ipshead_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>source</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>360</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_warehous</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>360</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_shipzone</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>method</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>480</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_shipvia</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtybreak</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102424
 
408     FreightPricesByCustomerType     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Freight Prices By Customer Type</title>\n <name>FreightPricesByCustomerType</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT (custtype_code || '-' || custtype_descrip) as custtype,\n       &lt;? if exists("showExpired") ?>\n         text('Yes')\n       &lt;? else ?>\n         text('No')\n       &lt;? endif ?>\n       AS f_showexpired,\n       &lt;? if exists("showFuture") ?>\n         text('Yes')\n       &lt;? else ?>\n         text('No')\n       &lt;? endif ?>\n       AS f_showfuture\n  FROM custtype\n WHERE (custtype_id=&lt;? value("custtype_id") ?>);\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT itemid, sourcetype, ipshead_name, source,\n       formatQty(ipsfreight_qtybreak) AS f_qtybreak,\n       formatSalesPrice(ipsfreight_price) AS f_price,\n       CASE WHEN (ipsfreight_type = 'F') THEN 'Flat Rate'\n            ELSE 'Per UOM'\n       END AS method,\n       currConcat(ipshead_curr_id) AS currConcat,\n       CASE WHEN (warehous_code IS NULL) THEN 'Any' ELSE warehous_code END AS f_warehous,\n       CASE WHEN (shipzone_name IS NULL) THEN 'Any' ELSE shipzone_name END AS f_shipzone,\n       CASE WHEN (freightclass_code IS NULL) THEN 'Any' ELSE freightclass_code END AS f_freightclass,\n       CASE WHEN (ipsfreight_shipvia IS NULL) THEN 'Any' ELSE ipsfreight_shipvia END AS f_shipvia\n\nFROM ( SELECT ipsfreight_id AS itemid, 1 AS sourcetype,\n              ipshead_name, 'CustType' AS source,\n              ipsfreight_qtybreak, ipsfreight_price,\n              ipsfreight_type, ipshead_curr_id,\n              warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n            JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n            LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n            LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n            LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ( (ipsass_custtype_id=&lt;? value("custtype_id") ?>)\n                  \n&lt;? if not exists("showExpired") ?>\n     AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n     AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n\n)\nUNION SELECT ipsfreight_id AS itemid, 2 AS sourcetype,\n             ipshead_name, 'CustTypePattern' AS source,\n             ipsfreight_qtybreak, ipsfreight_price,\n             ipsfreight_type, ipshead_curr_id,\n             warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM custtype JOIN ipsass ON ((coalesce(length(ipsass_custtype_pattern), 0) > 0) AND\n                              (custtype_code ~ ipsass_custtype_pattern))\n              JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n              JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n              LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n              LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n              LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ( (custtype_id=&lt;? value("custtype_id") ?>)\n                  \n&lt;? if not exists("showExpired") ?>\n     AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n     AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n\n)\nUNION SELECT ipsfreight_id AS itemid, 3 AS sourcetype,\n             ipshead_name, ('Sale' || '-' || sale_name) AS source,\n             ipsfreight_qtybreak, ipsfreight_price,\n             ipsfreight_type, ipshead_curr_id,\n             warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM sale JOIN ipshead ON (ipshead_id=sale_ipshead_id)\n          JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n          LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n          LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n          LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ((TRUE)\n\n&lt;? if not exists("showExpired") ?>\n     AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n     AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n\n) ) AS data\nORDER BY ipsfreight_qtybreak, ipsfreight_price;\n</sql>\n </querysource>\n <rpthead>\n  <height>233</height>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>195</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Schedule</string>\n  </label>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>195</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Qty. Break</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>195</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Freight Class</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>100</y>\n    <width>155</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show Expired Prices:</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>195</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>208</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>To</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>195</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>From</string>\n  </label>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>100</y>\n    <width>112</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showexpired</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>208</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship Via</string>\n  </label>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>120</y>\n    <width>112</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showfuture</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>10</y>\n    <width>405</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Freight Prices by Customer Type</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>227</ystart>\n   <xend>745</xend>\n   <yend>227</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>120</y>\n    <width>155</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show Future Prices:</string>\n  </label>\n  <label>\n   <rect>\n    <x>145</x>\n    <y>208</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Price</string>\n  </label>\n  <field>\n   <rect>\n    <x>125</x>\n    <y>80</y>\n    <width>535</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>custtype</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer Type:</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>208</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>208</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>From</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship Via</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Qty. Break</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>To</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <label>\n   <rect>\n    <x>155</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Freight Class</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Schedule</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <field>\n    <rect>\n     <x>360</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_shipzone</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>15</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>currConcat</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>480</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_shipvia</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_price</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>source</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>method</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>360</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_warehous</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ipshead_name</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtybreak</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>480</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_freightclass</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102425
 
430     InventoryHistory        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Inventory History</title>\n <name>InventoryHistory</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT invhist_id,\n       invhist_transdate,\n       formatDateTime(invhist_transdate) AS f_transdate,\n       invhist_transtype,\n       whs1.warehous_code AS warehous_code,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       formatQty(invhist_invqty) AS transqty,\n       (invhist_value_after-invhist_value_before) AS transvalue,\n       formatMoney(invhist_value_after-invhist_value_before) AS f_transvalue,\n       invhist_invuom,\n       CASE WHEN (invhist_ordtype NOT LIKE '') THEN (invhist_ordtype || '-' || invhist_ordnumber)\n            ELSE invhist_ordnumber\n       END AS ordernumber,\n       formatQty(invhist_qoh_before) AS qohbefore,\n       formatQty(invhist_qoh_after) AS qohafter,\n       CASE WHEN (invhist_costmethod='A') THEN &lt;? value("average") ?>\n            WHEN (invhist_costmethod='S') THEN &lt;? value("standard") ?>\n            WHEN (invhist_costmethod='J') THEN &lt;? value("job") ?>\n            WHEN (invhist_costmethod='N') THEN &lt;? value("none") ?>\n            ELSE &lt;? value("unknown") ?>\n       END AS costmethod,\n       formatMoney(invhist_value_before) AS valbefore,\n       formatMoney(invhist_value_after) AS valafter,\n       invhist_user AS username,\n       invhist_posted,\n       0 AS invdetail_id,\n       '' AS locationname,\n       '' AS detailqty,\n       '' AS locationqtybefore,\n       '' AS locationqtyafter,\n       CASE WHEN (invhist_transtype='TW') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IB') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IM') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IT') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RB') THEN 'WIP'\n            WHEN (invhist_transtype='RM') THEN 'WIP'\n            WHEN (invhist_transtype='RP') THEN 'PURCH'\n            WHEN (invhist_transtype='RR') THEN 'CUST'\n            WHEN (invhist_transtype='RS') THEN 'SHIP'\n            WHEN (invhist_transtype='SH') THEN whs1.warehous_code\n            WHEN (invhist_transtype='SI') THEN whs1.warehous_code\n            WHEN (invhist_transtype='SV') THEN whs1.warehous_code\n\t    WHEN (invhist_transtype='TR') THEN whs2.warehous_code\n\t    WHEN (invhist_transtype='TS') THEN whs1.warehous_code\n            ELSE ''\n       END AS locfrom,\n       CASE WHEN (invhist_transtype='TW') THEN whs2.warehous_code\n            WHEN (invhist_transtype='AD') THEN whs1.warehous_code\n            WHEN (invhist_transtype='CC') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IB') THEN 'WIP'\n            WHEN (invhist_transtype='IM') THEN 'WIP'\n            WHEN (invhist_transtype='NN') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RB') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RM') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RP') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RR') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RS') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RT') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RX') THEN whs1.warehous_code\n            WHEN (invhist_transtype='SH') THEN 'SHIP'\n            WHEN (invhist_transtype='SI') THEN 'SCRAP'\n            WHEN (invhist_transtype='SV') THEN 'SHIP'\n\t    WHEN (invhist_transtype='TR') THEN whs1.warehous_code\n\t    WHEN (invhist_transtype='TS') THEN whs2.warehous_code\n            ELSE ''\n       END AS locto\n  FROM itemsite, item, whsinfo AS whs1, invhist LEFT OUTER JOIN whsinfo AS whs2 ON (invhist_xfer_warehous_id=whs2.warehous_id)\n WHERE ( (NOT invhist_hasdetail)\n   AND (invhist_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (itemsite_warehous_id=whs1.warehous_id)\n  AND  (DATE(invhist_transdate) BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?> )\n   AND (transType(invhist_transtype, &lt;? value("transType") ?>))\n&lt;? if exists("orderType") ?>\n  AND  (invhist_ordtype=&lt;? value("orderType") ?>)\n&lt;? endif ?>\n&lt;? if exists("orderNumber") ?>\n  AND  (invhist_ordnumber ~ &lt;? value("orderNumber") ?>)\n&lt;? endif ?>\n&lt;? if exists("cohead_id") ?>\n  AND  (invhist_ordtype='SO')\n  AND  (invhist_ordnumber ~ (\n    SELECT cohead_number \n    FROM cohead \n    WHERE cohead_id=&lt;? value("cohead_id") ?>))\n&lt;? endif ?>\n&lt;? if exists("pohead_id") ?>\n  AND  (invhist_ordtype='PO')\n  AND  (invhist_ordnumber ~ (\n    SELECT pohead_number \n    FROM pohead \n    WHERE pohead_id=&lt;? value("pohead_id") ?>))\n&lt;? endif ?>\n&lt;? if exists("tohead_id") ?>\n  AND  (invhist_ordtype='TO')\n  AND  (invhist_ordnumber ~ (\n    SELECT tohead_number \n    FROM tohead \n    WHERE tohead_id=&lt;? value("tohead_id") ?>))\n&lt;? endif ?>\n&lt;? if exists("wo_id") ?>\n  AND  (invhist_ordtype='WO')\n  AND  (invhist_ordnumber ~ formatWoNumber(&lt;? value("wo_id") ?>))\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n  AND  (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("item_id") ?>\n  AND  (itemsite_item_id=&lt;? value("item_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("classcode_id") ?>\n  AND  (item_classcode_id=&lt;? value("classcode_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("itemgrp_id") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem\n\t\t   WHERE (itemgrpitem_itemgrp_id=&lt;? value("itemgrp_id") ?>)))\n&lt;? endif ?>\n&lt;? if exists("plancode_id") ?>\n  AND  (itemsite_plancode_id=&lt;? value("plancode_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("classcode_pattern") ?>\n  AND  (item_classcode_id IN (SELECT classcode_id\n\t\t\t      FROM classcode\n\t\t\t      WHERE (classcode_code ~ &lt;? value ("classcode_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("itemgrp_pattern") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem, itemgrp\n\t\t   WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t     AND  (itemgrp_name ~ &lt;? value ("itemgrp_pattern") ?>))))\n&lt;? endif ?>\n&lt;? if exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ &lt;? value("plancode_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("itemgrp") ?>\n  AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n&lt;? endif ?>\n)\nUNION\nSELECT invhist_id,\n       invhist_transdate,\n       formatDateTime(invhist_transdate) AS transdate,\n       invhist_transtype,\n       whs1.warehous_code AS warehous_code,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       formatQty(invhist_invqty) AS transqty,\n       0 AS transvalue,\n       formatMoney(invhist_value_after-invhist_value_before) AS f_transvalue,\n       invhist_invuom,\n       CASE WHEN (invhist_ordtype NOT LIKE '') THEN (invhist_ordtype || '-' || invhist_ordnumber)\n            ELSE invhist_ordnumber\n       END AS ordernumber,\n       formatQty(invhist_qoh_before) AS qohbefore,\n       formatQty(invhist_qoh_after) AS qohafter,\n       CASE WHEN(invhist_costmethod='A') THEN text('Average')\n            WHEN(invhist_costmethod='S') THEN text('Standard')\n            WHEN(invhist_costmethod='J') THEN text('Job')\n            WHEN(invhist_costmethod='N') THEN text('None')\n            ELSE 'UNKNOWN'\n       END AS costmethod,\n       formatMoney(invhist_value_before) AS valbefore,\n       formatMoney(invhist_value_after) AS valafter,\n       invhist_user AS username,\n       invhist_posted,\n       invdetail_id,\n       CASE WHEN (invdetail_location_id=-1) THEN formatlotserialnumber(invdetail_ls_id)\n            WHEN (invdetail_ls_id IS NULL) THEN formatLocationName(invdetail_location_id)\n            ELSE (formatLocationName(invdetail_location_id) || '-' || formatlotserialnumber(invdetail_ls_id))\n       END AS locationname,\n       formatQty(invdetail_qty) AS detailqty,\n       formatQty(invdetail_qty_before) AS locationqtybefore,\n       formatQty(invdetail_qty_after) AS locationqtyafter,\n       CASE WHEN (invhist_transtype='TW') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IB') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IM') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IT') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RB') THEN 'WIP'\n            WHEN (invhist_transtype='RM') THEN 'WIP'\n            WHEN (invhist_transtype='RP') THEN 'PURCH'\n            WHEN (invhist_transtype='RR') THEN 'CUST'\n            WHEN (invhist_transtype='RS') THEN 'SHIP'\n            WHEN (invhist_transtype='SH') THEN whs1.warehous_code\n            WHEN (invhist_transtype='SI') THEN whs1.warehous_code\n            WHEN (invhist_transtype='SV') THEN whs1.warehous_code\n\t    WHEN (invhist_transtype='TR') THEN whs2.warehous_code\n\t    WHEN (invhist_transtype='TS') THEN whs1.warehous_code\n            ELSE ''\n       END AS locfrom,\n       CASE WHEN (invhist_transtype='TW') THEN whs2.warehous_code\n            WHEN (invhist_transtype='AD') THEN whs1.warehous_code\n            WHEN (invhist_transtype='CC') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IB') THEN 'WIP'\n            WHEN (invhist_transtype='IM') THEN 'WIP'\n            WHEN (invhist_transtype='NN') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RB') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RM') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RP') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RR') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RS') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RT') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RX') THEN whs1.warehous_code\n            WHEN (invhist_transtype='SH') THEN 'SHIP'\n            WHEN (invhist_transtype='SI') THEN 'SCRAP'\n            WHEN (invhist_transtype='SV') THEN 'SHIP'\n\t    WHEN (invhist_transtype='TR') THEN whs1.warehous_code\n\t    WHEN (invhist_transtype='TS') THEN whs2.warehous_code\n            ELSE ''\n       END AS locto\n  FROM itemsite, item, whsinfo AS whs1, invdetail, invhist LEFT OUTER JOIN whsinfo AS whs2 ON (invhist_xfer_warehous_id=whs2.warehous_id)\n WHERE ((invhist_hasdetail)\n   AND (invhist_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (itemsite_warehous_id=whs1.warehous_id)\n   AND (invdetail_invhist_id=invhist_id)\n   AND  (DATE(invhist_transdate) BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?> )\n   AND (transType(invhist_transtype, &lt;? value("transType") ?>))\n&lt;? if exists("orderType") ?>\n  AND  (invhist_ordtype=&lt;? value("orderType") ?>)\n&lt;? endif ?>\n&lt;? if exists("orderNumber") ?>\n  AND  (invhist_ordnumber ~ &lt;? value("orderNumber") ?>)\n&lt;? endif ?>\n&lt;? if exists("cohead_id") ?>\n  AND  (invhist_ordtype='SO')\n  AND  (invhist_ordnumber ~ (\n    SELECT cohead_number \n    FROM cohead \n    WHERE cohead_id=&lt;? value("cohead_id") ?>))\n&lt;? endif ?>\n&lt;? if exists("pohead_id") ?>\n  AND  (invhist_ordtype='PO')\n  AND  (invhist_ordnumber ~ (\n    SELECT pohead_number \n    FROM pohead \n    WHERE pohead_id=&lt;? value("pohead_id") ?>))\n&lt;? endif ?>\n&lt;? if exists("tohead_id") ?>\n  AND  (invhist_ordtype='TO')\n  AND  (invhist_ordnumber ~ (\n    SELECT tohead_number \n    FROM tohead \n    WHERE tohead_id=&lt;? value("tohead_id") ?>))\n&lt;? endif ?>\n&lt;? if exists("wo_id") ?>\n  AND  (invhist_ordtype='WO')\n  AND  (invhist_ordnumber ~ formatWoNumber(&lt;? value("wo_id") ?>))\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n  AND  (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("item_id") ?>\n  AND  (itemsite_item_id=&lt;? value("item_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("classcode_id") ?>\n  AND  (item_classcode_id=&lt;? value("classcode_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("itemgrp_id") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem\n\t\t   WHERE (itemgrpitem_itemgrp_id=&lt;? value("itemgrp_id") ?>)))\n&lt;? endif ?>\n&lt;? if exists("plancode_id") ?>\n  AND  (itemsite_plancode_id=&lt;? value("plancode_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("classcode_pattern") ?>\n  AND  (item_classcode_id IN (SELECT classcode_id\n\t\t\t      FROM classcode\n\t\t\t      WHERE (classcode_code ~ &lt;? value ("classcode_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("itemgrp_pattern") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem, itemgrp\n\t\t   WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t     AND  (itemgrp_name ~ &lt;? value ("itemgrp_pattern") ?>))))\n&lt;? endif ?>\n&lt;? if exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ &lt;? value("plancode_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("itemgrp") ?>\n  AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n&lt;? endif ?>\n);</sql>\n </querysource>\n <querysource>\n  <name>footer</name>\n  <sql>SELECT formatMoney(sum(invhist_value_after-invhist_value_before)) AS transvalue_total\nFROM itemsite, item, whsinfo AS whs1, invhist LEFT OUTER JOIN\n     whsinfo AS whs2 ON (invhist_xfer_warehous_id=whs2.warehous_id)\nWHERE ( (invhist_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id) \n  AND  (itemsite_warehous_id=whs1.warehous_id)\n  AND  (DATE(invhist_transdate) BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?> )\n  AND  (transType(invhist_transtype, &lt;? value("transType") ?>))\n&lt;? if exists("orderType") ?>\n  AND  (invhist_ordtype=&lt;? value("orderType") ?>)\n&lt;? endif ?>\n&lt;? if exists("orderNumber") ?>\n  AND  (invhist_ordnumber ~ &lt;? value("orderNumber") ?>)\n  AND  (invhist_ordtype = 'SO')\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n  AND  (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("item_id") ?>\n  AND  (itemsite_item_id=&lt;? value("item_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("classcode_id") ?>\n  AND  (item_classcode_id=&lt;? value("classcode_id") ?>)\n&lt;? elseif exists("itemgrp_id") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem\n\t\t   WHERE (itemgrpitem_itemgrp_id=&lt;? value("itemgrp_id") ?>)))\n&lt;? elseif exists("plancode_id") ?>\n  AND  (itemsite_plancode_id=&lt;? value("plancode_id") ?>)\n&lt;? elseif exists("classcode_pattern") ?>\n  AND  (item_classcode_id IN (SELECT classcode_id\n\t\t\t      FROM classcode\n\t\t\t      WHERE (classcode_code ~ &lt;? value ("classcode_pattern") ?>)))\n&lt;? elseif exists("itemgrp_pattern") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem, itemgrp\n\t\t   WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t     AND  (itemgrp_name ~ &lt;? value ("itemgrp_pattern") ?>))))\n&lt;? elseif exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ &lt;? value("plancode_pattern") ?>)))\n&lt;? elseif exists("itemgrp") ?>\n  AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n&lt;? endif ?>\n)</sql>\n </querysource>\n <rpthead>\n  <height>242</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>50</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>211</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Area To</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>222</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Val. After</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH After</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>211</y>\n    <width>228</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>222</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Val. Before</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>200</y>\n    <width>130</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Time</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>237</ystart>\n   <xend>745</xend>\n   <yend>237</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5.68571</x>\n    <y>211</y>\n    <width>50</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>586</x>\n    <y>211</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Area From</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>200</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH Before</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>200</y>\n    <width>228</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>211</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cost Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>200</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>211</y>\n    <width>130</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>508</x>\n    <y>200</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>222</y>\n    <width>130</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Username</string>\n  </label>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>222</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Value</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>7</y>\n    <width>310</width>\n    <height>30</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Inventory History</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>37</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>2</height>\n </pghead>\n <pghead>\n  <height>51</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>32</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>12</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Area From</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>0</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH Before</string>\n  </label>\n  <label>\n   <rect>\n    <x>586.32</x>\n    <y>25</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Val. Before</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>0</y>\n    <width>228</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>12</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cost Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>12</y>\n    <width>32</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>0</y>\n    <width>130</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Time</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>12</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Area To</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>12</y>\n    <width>228</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>0</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>25</y>\n    <width>130</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Username</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>25</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Val. After</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>45</ystart>\n   <xend>745</xend>\n   <yend>45</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH After</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>12</y>\n    <width>130</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>508</x>\n    <y>0</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty</string>\n  </label>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>25</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Value</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>invhist_id</name>\n   <column>invhist_id</column>\n   <head>\n    <height>45</height>\n    <field>\n     <rect>\n      <x>60</x>\n      <y>0</y>\n      <width>132</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_transdate</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>200</x>\n      <y>0</y>\n      <width>228</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>item_number</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>200</x>\n      <y>25</y>\n      <width>228</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>item_descrip2</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>660</x>\n      <y>25</y>\n      <width>72</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>valafter</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>60</x>\n      <y>12</y>\n      <width>132</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>ordernumber</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>585</x>\n      <y>0</y>\n      <width>72</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>qohbefore</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>5</x>\n      <y>0</y>\n      <width>50</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>warehous_code</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>432</x>\n      <y>0</y>\n      <width>72</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>invhist_invuom</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>60</x>\n      <y>25</y>\n      <width>132</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>username</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>585</x>\n      <y>25</y>\n      <width>72</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>valbefore</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>660</x>\n      <y>12</y>\n      <width>72</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>locto</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>660</x>\n      <y>0</y>\n      <width>72</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>qohafter</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>5</x>\n      <y>12</y>\n      <width>50</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>invhist_transtype</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>510</x>\n      <y>0</y>\n      <width>72</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>transqty</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>585</x>\n      <y>12</y>\n      <width>72</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>locfrom</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>200</x>\n      <y>12</y>\n      <width>228</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>item_descrip1</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>510</x>\n      <y>12</y>\n      <width>72</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>costmethod</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>510</x>\n      <y>25</y>\n      <width>72</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_transvalue</column>\n     </data>\n    </field>\n   </head>\n   <foot>\n    <height>9</height>\n    <line>\n     <xstart>5</xstart>\n     <ystart>5</ystart>\n     <xend>745</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>72</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>locationqtybefore</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>228</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>locationname</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>508</x>\n     <y>0</y>\n     <width>72</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>detailqty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>72</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>locationqtyafter</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>14</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>612</x>\n    <y>0</y>\n    <width>85</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>20</height>\n  <field>\n   <rect>\n    <x>510</x>\n    <y>5</y>\n    <width>72</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>footer</query>\n    <column>transvalue_total</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>130</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Total:</string>\n  </label>\n </rptfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102426
 
59      CustomerInformation     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Customer Information</title>\n <name>CustomerInformation</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT cust_name, cust_number,\n       ba.addr_line1 AS cust_address1, ba.addr_line2 AS cust_address2, ba.addr_line3 AS cust_address3,\n       ba.addr_city AS cust_city, ba.addr_state AS cust_state, ba.addr_postalcode AS cust_zipcode,\n       (ba.addr_city || ', ' || ba.addr_state || ' ' || ba.addr_postalcode) AS citystatezip,\n       trim(bc.cntct_first_name || ' ' || bc.cntct_last_name) AS cust_contact, bc.cntct_phone AS cust_phone, bc.cntct_fax AS cust_fax, bc.cntct_email AS cust_email,\n       ca.addr_line1 AS cust_corraddress1, ca.addr_line2 AS cust_corraddress2, ca.addr_line3 AS cust_corraddress3,\n       ca.addr_city AS cust_corrcity, ca.addr_state AS cust_corrstate, ca.addr_postalcode AS cust_corrzipcode,\n       (ca.addr_city || ', ' || ca.addr_state || ' ' || ca.addr_postalcode) AS corrcitystatezip,\n       trim(cc.cntct_first_name || ' ' || cc.cntct_last_name) AS cust_corrcontact, cc.cntct_phone AS cust_corrphone,\n       cc.cntct_fax AS cust_corrfax, cc.cntct_email AS cust_corremail,\n       CASE WHEN (cust_creditstatus='G') THEN 'In Good Standing'\n            WHEN (cust_creditstatus='W') THEN 'On Credit Warning'\n            WHEN (cust_creditstatus='H') THEN 'On Credit Hold'\n            ELSE ('Unknown Status: ' || cust_creditstatus)\n       END AS f_creditstatus,\n       cust_comments\n FROM custinfo\n LEFT OUTER JOIN cntct cc ON (cust_corrcntct_id=cc.cntct_id)\n LEFT OUTER JOIN addr ca ON (cc.cntct_addr_id=ca.addr_id)\n LEFT OUTER JOIN cntct bc ON (cust_cntct_id=bc.cntct_id)\n LEFT OUTER JOIN addr ba ON (bc.cntct_addr_id=ba.addr_id)\n WHERE (cust_id=&lt;? value(&quot;cust_id&quot;) ?>);</sql>\n </querysource>\n <querysource>\n  <name>firstlastorderdate</name>\n  <sql>SELECT formatDate(MIN(cohist_invcdate)) AS firstdate,\n       formatDate(MAX(cohist_invcdate)) AS lastdate\n   FROM cohist\nWHERE (cohist_cust_id=&lt;? value(&quot;cust_id&quot;) ?>);</sql>\n </querysource>\n <querysource>\n  <name>lysales</name>\n  <sql>SELECT formatMoney(COALESCE(SUM(round(cohist_qtyshipped * cohist_unitprice,2)), 0)) AS lysales FROM cohist WHERE ( (cohist_invcdate BETWEEN (DATE_TRUNC('year', CURRENT_TIMESTAMP) - INTERVAL '1 year') AND                                 (DATE_TRUNC('year', CURRENT_TIMESTAMP) - INTERVAL '1 day')) AND (cohist_cust_id=&lt;? value(&quot;cust_id&quot;) ?>) );</sql>\n </querysource>\n <querysource>\n  <name>ytdsales</name>\n  <sql>SELECT formatExtPrice(SUM(round(cohist_qtyshipped * cohist_unitprice,2))) AS ytdsales\n  FROM cohist\n WHERE ((cohist_invcdate>=DATE_TRUNC('year', CURRENT_TIMESTAMP))\n   AND (cohist_cust_id=&lt;? value(&quot;cust_id&quot;) ?>) );</sql>\n </querysource>\n <querysource>\n  <name>backlog</name>\n  <sql>SELECT formatMoney( COALESCE( SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) ), 0 ) ) AS backlog FROM cohead, coitem, itemsite, item WHERE ( (coitem_cohead_id=cohead_id) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (coitem_status='O') AND (cohead_cust_id=&lt;? value(&quot;cust_id&quot;) ?>) );</sql>\n </querysource>\n <querysource>\n  <name>OpenBalance</name>\n  <sql>SELECT formatMoney( COALESCE( SUM( CASE WHEN (aropen_doctype IN ('I', 'D')) THEN (aropen_amount - aropen_paid)                                       ELSE ((aropen_amount - aropen_paid) * -1)                                   END ), 0 ) ) AS f_balance FROM aropen WHERE ( (aropen_open) AND (aropen_cust_id=&lt;? value(&quot;cust_id&quot;) ?>) );</sql>\n </querysource>\n <querysource>\n  <name>LateBalance</name>\n  <sql>SELECT formatMoney( noNeg( COALESCE( SUM( CASE WHEN (aropen_doctype IN ('I', 'D')) THEN (aropen_amount - aropen_paid)                                      ELSE ((aropen_amount - aropen_paid) * -1)                                   END ), 0 ) ) ) AS f_balance FROM aropen WHERE ( (aropen_open) AND (aropen_duedate &lt; CURRENT_DATE) AND (aropen_cust_id=&lt;? value(&quot;cust_id&quot;) ?>) );\n</sql>\n </querysource>\n <querysource>\n  <name>Comments</name>\n  <sql>SELECT comment_source_id AS cust_id,\n       comment_id,\n       formatDate(comment_date) AS f_date,\n       comment_user,\n       comment_text\n  FROM comment\n WHERE ( (comment_source='C')\n   AND (comment_source_id=&lt;? value(&quot;cust_id&quot;) ?>) )\nORDER BY comment_date;</sql>\n </querysource>\n <querysource>\n  <name>History</name>\n  <sql>SELECT aropen_cust_id AS cust_id,\n       aropen_id AS aropenid, -1 AS applyid,\n       aropen_docnumber AS sortnumber,\n       aropen_docnumber AS docnumber,\n       formatBoolYN(aropen_open) AS f_open,\n       CASE WHEN (aropen_doctype='I') THEN text('Invoice')\n            WHEN (aropen_doctype='C') THEN text('C/M')\n            WHEN (aropen_doctype='D') THEN text('D/M')\n            WHEN (aropen_doctype='R') THEN text('C/D')\n            ELSE text('Other')\n       END AS documenttype,\n       formatDate(aropen_docdate) AS f_docdate,\n       formatDate(aropen_duedate) AS f_duedate,\n       formatMoney(aropen_amount) AS f_amount,\n       formatMoney((aropen_amount - aropen_paid)) AS f_balance\nFROM aropen\nWHERE (aropen_cust_id=&lt;? value(&quot;cust_id&quot;) ?>)\n\nUNION\nSELECT aropen_cust_id AS cust_id,\n       -1 AS aropenid, arapply_source_aropen_id AS applyid,\n       aropen_docnumber AS sortnumber,\n       CASE WHEN (arapply_source_doctype='C') THEN arapply_source_docnumber\n            WHEN (arapply_source_doctype='K') THEN arapply_refnumber\n            ELSE :error\n       END AS docnumber,\n       '' AS f_open,\n       CASE WHEN (arapply_source_doctype='C') THEN text('C/M')\n            WHEN (arapply_fundstype='C') THEN text('Check')\n            WHEN (arapply_fundstype='T') THEN text('Certified Check')\n            WHEN (arapply_fundstype='M') THEN text('Master Card')\n            WHEN (arapply_fundstype='V') THEN text('Visa')\n            WHEN (arapply_fundstype='A') THEN text('American Express')\n            WHEN (arapply_fundstype='D') THEN text('Discover Card')\n            WHEN (arapply_fundstype='R') THEN text('Other Credit Card')\n            WHEN (arapply_fundstype='K') THEN text('Cash')\n            WHEN (arapply_fundstype='W') THEN text('Wire Transfer')\n            WHEN (arapply_fundstype='O') THEN text('Other')\n       END AS documenttype,\n       formatDate(arapply_postdate) AS f_docdate,\n       '' AS f_duedate,\n       formatMoney(arapply_applied) AS f_amount,\n       '' AS f_balance\nFROM arapply, aropen\nWHERE ( (arapply_target_doctype IN ('I', 'D'))\n AND (arapply_target_doctype=aropen_doctype)\n AND (arapply_target_docnumber=aropen_docnumber)\n AND (arapply_cust_id=&lt;? value(&quot;cust_id&quot;) ?>)\n AND (aropen_cust_id=&lt;? value(&quot;cust_id&quot;) ?>) )\n\nUNION\nSELECT aropen_cust_id AS cust_id,\n       -1 AS aropenid, arapply_target_aropen_id AS applyid,\n       aropen_docnumber AS sortnumber,\n       arapply_target_docnumber AS docnumber,\n       '' AS f_open,\n       CASE WHEN (arapply_target_doctype='I') THEN text('Invoice')\n            WHEN (arapply_target_doctype='D') THEN text('D/M')\n            ELSE text('Other')\n       END AS documenttype,\n       formatDate(arapply_postdate) AS f_docdate,\n       '' AS f_duedate,\n       formatMoney(arapply_applied) AS f_amount,\n       '' AS f_balance\nFROM arapply, aropen\nWHERE ( (arapply_source_doctype IN ('K', 'C'))\n AND (arapply_source_doctype=aropen_doctype)\n AND (arapply_source_docnumber=aropen_docnumber)\n AND (arapply_cust_id=&lt;? value(&quot;cust_id&quot;) ?>)\n AND (aropen_cust_id=&lt;? value(&quot;cust_id&quot;) ?>) )\n\nORDER BY sortnumber, applyid;</sql>\n </querysource>\n <rpthead>\n  <height>392</height>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>260</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>FAX:</string>\n  </label>\n  <text>\n   <rect>\n    <x>105</x>\n    <y>365</y>\n    <width>575</width>\n    <height>15</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>cust_comments</column>\n   </data>\n  </text>\n  <field>\n   <rect>\n    <x>105</x>\n    <y>305</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>firstlastorderdate</query>\n    <column>firstdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>345</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Credit Status:</string>\n  </label>\n  <line>\n   <xstart>370</xstart>\n   <ystart>160</ystart>\n   <xend>370</xend>\n   <yend>295</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>5</xstart>\n   <ystart>155</ystart>\n   <xend>360</xend>\n   <yend>155</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer Information</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>229</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_corrcontact</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>160</y>\n    <width>350</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_address1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>260</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_corrfax</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>305</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Last Year Sales:</string>\n  </label>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>175</y>\n    <width>350</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <bottom/>\n   <data>\n    <query>head</query>\n    <column>cust_address2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>204</y>\n    <width>350</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>corrcitystatezip</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>229</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_contact</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>75</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>190</y>\n    <width>350</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_address3</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>325</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Last Sales Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>600</x>\n    <y>345</y>\n    <width>140</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_creditstatus</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>295</ystart>\n   <xend>740</xend>\n   <yend>295</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>260</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>FAX:</string>\n  </label>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>229</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Contact Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>340</x>\n    <y>305</y>\n    <width>145</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>lysales</query>\n    <column>lysales</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>600</x>\n    <y>325</y>\n    <width>140</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>LateBalance</query>\n    <column>f_balance</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>275</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_email</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>275</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_corremail</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>260</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_fax</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>245</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Phone:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>75</y>\n    <width>295</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>190</y>\n    <width>350</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_corraddress3</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>325</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>YTD Sales:</string>\n  </label>\n  <field>\n   <rect>\n    <x>340</x>\n    <y>325</y>\n    <width>145</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>ytdsales</query>\n    <column>ytdsales</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>345</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Backlog:</string>\n  </label>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>275</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Email:</string>\n  </label>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>245</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_phone</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>140</y>\n    <width>135</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Billing Address</string>\n  </label>\n  <line>\n   <xstart>380</xstart>\n   <ystart>155</ystart>\n   <xend>735</xend>\n   <yend>155</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>229</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Contact Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>245</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Phone:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>140</y>\n    <width>170</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Correspondence Address</string>\n  </label>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>160</y>\n    <width>350</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_corraddress1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>340</x>\n    <y>345</y>\n    <width>145</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>backlog</query>\n    <column>backlog</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>325</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Late Balance:</string>\n  </label>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>175</y>\n    <width>350</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_corraddress2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>245</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_corrphone</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>105</x>\n    <y>325</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>firstlastorderdate</query>\n    <column>lastdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>600</x>\n    <y>305</y>\n    <width>140</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>OpenBalance</query>\n    <column>f_balance</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>365</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Notes:</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>95</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Number:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>95</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>204</y>\n    <width>350</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>citystatezip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>275</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Email:</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>305</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Open Balance:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>305</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>First Sales Date:</string>\n  </label>\n </rpthead>\n <section>\n  <name>Comments</name>\n  <group>\n   <name>Head</name>\n   <column>cust_id</column>\n   <head>\n    <height>46</height>\n    <line>\n     <xstart>55</xstart>\n     <ystart>40</ystart>\n     <xend>745</xend>\n     <yend>40</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>5</y>\n      <width>95</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Comments:</string>\n    </label>\n    <label>\n     <rect>\n      <x>260</x>\n      <y>25</y>\n      <width>95</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Comment</string>\n    </label>\n    <label>\n     <rect>\n      <x>160</x>\n      <y>25</y>\n      <width>95</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>User</string>\n    </label>\n    <label>\n     <rect>\n      <x>60</x>\n      <y>25</y>\n      <width>95</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Date</string>\n    </label>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>Comments</query>\n   </key>\n   <height>16</height>\n   <text>\n    <rect>\n     <x>260</x>\n     <y>0</y>\n     <width>484</width>\n     <height>15</height>\n    </rect>\n    <bottompad>5</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Comments</query>\n     <column>comment_text</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>95</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Comments</query>\n     <column>f_date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>160</x>\n     <y>0</y>\n     <width>95</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Comments</query>\n     <column>comment_user</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>History</name>\n  <group>\n   <name>Head</name>\n   <column>cust_id</column>\n   <head>\n    <height>46</height>\n    <label>\n     <rect>\n      <x>130</x>\n      <y>25</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Doc. Type</string>\n    </label>\n    <label>\n     <rect>\n      <x>210</x>\n      <y>25</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Doc. #</string>\n    </label>\n    <label>\n     <rect>\n      <x>380</x>\n      <y>25</y>\n      <width>85</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Due Date</string>\n    </label>\n    <label>\n     <rect>\n      <x>60</x>\n      <y>25</y>\n      <width>65</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Open</string>\n    </label>\n    <label>\n     <rect>\n      <x>470</x>\n      <y>25</y>\n      <width>85</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Amount</string>\n    </label>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>5</y>\n      <width>95</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>A/R History:</string>\n    </label>\n    <label>\n     <rect>\n      <x>290</x>\n      <y>25</y>\n      <width>85</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Doc. Date</string>\n    </label>\n    <label>\n     <rect>\n      <x>560</x>\n      <y>25</y>\n      <width>85</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Balance</string>\n    </label>\n    <line>\n     <xstart>55</xstart>\n     <ystart>40</ystart>\n     <xend>745</xend>\n     <yend>40</yend>\n     <weight>0</weight>\n    </line>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>History</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>65</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>History</query>\n     <column>f_open</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>290</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>History</query>\n     <column>f_docdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>210</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>History</query>\n     <column>docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>380</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>History</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>470</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>History</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>History</query>\n     <column>documenttype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>560</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>History</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102427
 
50      IndentedBOM     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Indented Bill of Materials</title>\n <name>IndentedBOM</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       uom_name AS item_invuom,\n       item_descrip1,\n       item_descrip2\n  FROM item, uom\n WHERE ((item_id=&lt;? value("item_id") ?>)\n AND (item_inv_uom_id=uom_id));\n    </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT (REPEAT(' ',(bomdata_bomwork_level-1)*3) || bomdata_bomwork_seqnumber) AS f_seqnumber,\n       bomdata_item_number AS item_number,\n       bomdata_uom_name AS item_invuom,\n       bomdata_item_descrip1 AS item_descrip1,\n       bomdata_item_descrip2 AS item_descrip2,\n       bomdata_issuemethod AS issuemethod,\n       bomdata_createchild AS createchild,\n       formatQtyPer(bomdata_qtyreq) AS qtyreq,\n       formatScrap(bomdata_scrap) AS scrap,\n       CASE WHEN COALESCE(bomdata_effective, startOfTime()) &lt;= startOfTime()\n            THEN &lt;? value("always") ?>\n            ELSE formatDate(bomdata_effective)\n       END AS effective,\n       CASE WHEN COALESCE(bomdata_expires, endOfTime()) >= endOfTime()\n            THEN &lt;? value("never") ?>\n            ELSE formatDate(bomdata_expires)\n       END AS expires\nFROM indentedBOM(&lt;? value("item_id") ?>,&lt;? value("revision_id") ?>,&lt;? value("expiredDays") ?>,&lt;? value("futureDays") ?>)\nWHERE (bomdata_item_id>0);</sql>\n </querysource>\n <querysource>\n  <name>bomhead</name>\n  <sql>SELECT bomhead_docnum, bomhead_revision,\nformatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=&lt;? value("item_id") ?>)\nAND (bomhead_rev_id=&lt;? value("revision_id") ?>));</sql>\n </querysource>\n <rpthead>\n  <height>242</height>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>103</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>203</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>203</y>\n    <width>165</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>203</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>203</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>103</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>125</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revsion Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>125</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>103</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_docnum</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>103</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>203</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Qty. Req.</string>\n  </label>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>220</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>125</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>f_revisiondate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>203</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>203</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>103</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Document #:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>235</ystart>\n   <xend>745</xend>\n   <yend>235</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>220</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>145</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>145</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_revision</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>315</x>\n    <y>103</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_invuom</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>145</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision:</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Indented Bill of Materials</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>220</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>0</y>\n    <width>165</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Qty. Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>15</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>53</height>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>issuemethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>effective</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>expires</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>275</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_invuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>103</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_seqnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createchild</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102428
 
208     IndentedWhereUsed       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Indented Where Used</title>\n <name>IndentedWhereUsed</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       uom_name AS item_invuom,\n       item_descrip1,\n       item_descrip2\n  FROM item, uom\n WHERE ((item_id=&lt;? value("item_id") ?>)\n AND (item_inv_uom_id=uom_id));\n    </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT (REPEAT(' ',(bomwork_level-1)*3) || bomwork_seqnumber) AS f_seqnumber,\n       bomworkitemsequence(bomwork_id) AS seqord,\n       item_number, uom_name AS item_invuom,\n       item_descrip1, item_descrip2,\n       formatQty(bomwork_qtyfxd) AS qtyfxd,\n       formatQtyPer(bomwork_qtyper) AS qtyper,\n       formatScrap(bomwork_scrap) AS scrap,\n       formatDate(bomwork_effective, 'Always') AS effective,\n       formatDate(bomwork_expires, 'Never') AS expires\n  FROM bomwork, item, uom\n WHERE ((bomwork_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (bomwork_set_id=&lt;? value("bomworkset_id") ?>)\n&lt;? if not exists("showExpired") ?>\n   AND (bomwork_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n   AND (bomwork_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n)\nORDER BY seqord;</sql>\n </querysource>\n <rpthead>\n  <height>242</height>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>145</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>203</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>125</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>203</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>220</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Indented Where Used</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>203</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>103</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <field>\n   <rect>\n    <x>315</x>\n    <y>103</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_invuom</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>235</ystart>\n   <xend>745</xend>\n   <yend>235</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>203</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>103</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>203</y>\n    <width>165</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>203</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>103</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>203</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>203</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Fxd. Qty.</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>15</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>0</y>\n    <width>165</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>-1</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Fxd. Qty.</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>52</height>\n   <field>\n    <rect>\n     <x>275</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_invuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>expires</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>103</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_seqnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>113</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>effective</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>113</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>113</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>345</x>\n     <y>1</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyfxd</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102429
 
364     InventoryAvailabilityByCustomerType     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Inventory Availability by Customer Type</title>\n <name>InventoryAvailabilityByCustomerType</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n       &lt;? if exists("onlyShowShortages") ?>\n         text('Only Showing Shortages')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_onlyShowShortages,\n      &lt;? if exists("showWoSupply") ?>\n         text('Show W/O Supply')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_showWoSupply,\n&lt;? if exists("custtype_id") ?>\n       (SELECT custtype_code from custtype where (custtype_id=&lt;? value("custtype_id") ?>))\n&lt;? elseif exists("custtype_pattern") ?>\n       &lt;? value("custtype_pattern") ?>\n&lt;? else ?>\n       text('All Customer Types')\n&lt;? endif ?>\n       AS f_custtype;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT itemsite_id, coitem_id,\n       cohead_id, cohead_number, (cust_number||'-'||cust_name) AS custname,\n       item_number, item_description, uom_name, item_picklist,\n       qoh, formatQty(qoh) AS f_qoh,sobalance,\n       formatQty(sobalance) AS f_sobalance,\n       formatQty(allocated) AS f_allocated,\n       ordered, formatQty(ordered) AS f_ordered,\n       (qoh + ordered - sobalance) AS woavail,\n&lt;? if exists("useReservationNetting") ?>\n       formatQty(coitem_qtyreserved) AS f_soavail,\n&lt;? else ?>\n       formatQty(qoh + ordered - sobalance) AS f_soavail,\n&lt;? endif ?>\n       (qoh + ordered - allocated) AS totalavail,\n       formatQty(qoh + ordered - allocated) AS f_totalavail,\n       atshipping,formatQty(atshipping) AS f_atshipping,\n       reorderlevel \n&lt;? if exists(showWoSupply) ?>,         \n       wo_id,\n       wo_status,\n       wo_number,\n       wo_ordered,\n       CASE WHEN (wo_id = -1) THEN NULL ELSE formatQty(wo_ordered) END AS f_wo_ordered,\n       formatdate(wo_startdate) AS f_wo_startdate, \n       formatdate(wo_duedate) AS f_wo_duedate,\n       COALESCE(wo_latestart,false) AS wo_latestart,\n       COALESCE(wo_latedue,false) AS wo_latedue \n&lt;? endif ?>\n       FROM ( SELECT itemsite_id, coitem_id,\n                     cohead_id, cohead_number, cust_number, cust_name,\n                     item_number, (item_descrip1 || ' ' || item_descrip2) AS item_description,\n                     uom_name, item_picklist,\n                     noNeg(qtyAvailable(itemsite_id)) AS qoh,\n                     noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS sobalance,\n                     qtyAllocated(itemsite_id, coitem_scheddate) AS allocated,\n                     qtyOrdered(itemsite_id, coitem_scheddate) AS ordered,\n                     qtyatshipping(coitem_id) AS atshipping,\n                     coitem_qtyreserved,\n                     CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel \n&lt;? if exists(showWoSupply) ?>,  \n                     COALESCE(wo_id,-1) AS wo_id,\n                     formatwonumber(wo_id) AS wo_number,\n                     noNeg((wo_qtyord-wo_qtyrcv)) AS wo_ordered,\n                     wo_status, wo_startdate, wo_duedate,\n                     ((wo_startdate &lt;= CURRENT_DATE) AND (wo_status IN ('O','E','S','R'))) AS wo_latestart,\n                     (wo_duedate&lt;=CURRENT_DATE) AS wo_latedue  \n&lt;? endif ?> \n                FROM cohead, itemsite, item, uom, custinfo, coitem\n&lt;? if exists(showWoSupply) ?> \n                LEFT OUTER JOIN wo\n                  ON ((coitem_itemsite_id=wo_itemsite_id)\n                  AND (wo_status IN ('E','R','I'))\n                  AND (wo_qtyord-wo_qtyrcv > 0)\n                  AND (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned-qtyatshipping(coitem_id)) > \n                        (SELECT qtyAvailable(itemsite_id) AS availableqoh FROM itemsite WHERE (itemsite_id=coitem_itemsite_id))))\n&lt;? endif ?>\n                WHERE((coitem_cohead_id=cohead_id)\n                  AND (cohead_cust_id=cust_id)\n                  AND (coitem_itemsite_id=itemsite_id)\n                  AND (itemsite_item_id=item_id)\n                  AND (item_inv_uom_id=uom_id)\n                  AND (coitem_status NOT IN ('C', 'X'))\n&lt;? if exists("custtype_id") ?>\n                  AND (cust_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? elseif exists("custtype_pattern") ?>\n                  AND (cust_custtype_id IN (SELECT custtype_id\n                                              FROM custtype\n                                             WHERE(custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n&lt;? endif ?>\n              )\n            ) AS data \n&lt;? if exists(onlyShowShortages) ?>\n      WHERE ( ((qoh + ordered - allocated) &lt; 0)\n           OR ((qoh + ordered - sobalance) &lt; 0) ) \n&lt;? endif ?>\n      ORDER BY cohead_id, cohead_number, item_number\n&lt;? if exists(showWoSupply) ?> ,\n               wo_duedate\n&lt;? endif ?>\n;</sql>\n </querysource>\n <rpthead>\n  <height>251</height>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>120</y>\n    <width>380</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showWoSupply</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>215</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>10</xstart>\n   <ystart>245</ystart>\n   <xend>750</xend>\n   <yend>245</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>100</y>\n    <width>102</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>209</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_custtype</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Available</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>230</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>230</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>100</y>\n    <width>380</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_onlyShowShortages</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>At Shipping</string>\n  </label>\n  <label>\n   <rect>\n    <x>185</x>\n    <y>230</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>This Allocated</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Orders</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>230</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty Due</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>This Available</string>\n  </label>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>230</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>W/O Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>10</y>\n    <width>500</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Inventory Availability by Customer Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Allocated</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>This Available</string>\n  </label>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>This Allocated</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Orders</string>\n  </label>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Allocated</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>20</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Available</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>At Shipping</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>cohead</name>\n   <column>cohead_id</column>\n   <head>\n    <height>26</height>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>0</y>\n      <width>55</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>S/O #:</string>\n    </label>\n    <field>\n     <rect>\n      <x>390</x>\n      <y>0</y>\n      <width>209</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>custname</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>300</x>\n      <y>0</y>\n      <width>80</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Customer:</string>\n    </label>\n    <field>\n     <rect>\n      <x>65</x>\n      <y>0</y>\n      <width>209</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>cohead_number</column>\n     </data>\n    </field>\n   </head>\n   <foot>\n    <height>6</height>\n    <line>\n     <xstart>5</xstart>\n     <ystart>0</ystart>\n     <xend>745</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>46</height>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_totalavail</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>30</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>wo_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>535</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>400</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>Item_description</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>30</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_wo_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>Item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_sobalance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>185</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>185</x>\n     <y>30</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>wo_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_soavail</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_allocated</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>30</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_wo_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>325</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qoh</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>535</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_atshipping</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>535</x>\n     <y>30</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_wo_startdate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102430
 
244     InventoryAvailabilityBySalesOrder       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Inventory Availability by Sales Order</title>\n <name>InventoryAvailabilityBySalesOrder</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT cohead_number,\n       formatDate(cohead_orderdate) AS orderdate,\n       cohead_custponumber,\n       cust_name,\n       cntct_phone AS cust_phone,\n       &lt;? if exists("onlyShowShortages") ?>\n         text('Only Showing Shortages')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_onlyShowShortages,\n      &lt;? if exists("showWoSupply") ?>\n         text('Show W/O Supply')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_showWoSupply\n  FROM cohead, custinfo\n  LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n WHERE ((cohead_cust_id=cust_id)\n   AND (cohead_id=&lt;? value("sohead_id") ?>) );</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT itemsite_id, coitem_id,\n                        item_number, item_description, uom_name, item_picklist,\n                        qoh, formatQty(qoh) AS f_qoh,sobalance,\n                        formatQty(sobalance) AS f_sobalance,\n                        formatQty(allocated) AS f_allocated,\n                        ordered, formatQty(ordered) AS f_ordered,\n                        (qoh + ordered - sobalance) AS woavail,\n                        formatQty(qoh + ordered - sobalance) AS f_soavail,\n                        (qoh + ordered - allocated) AS totalavail,\n                        formatQty(qoh + ordered - allocated) AS f_totalavail,\n                        atshipping,formatQty(atshipping) AS f_atshipping,\n                        reorderlevel \n                 &lt;? if exists(showWoSupply) ?>,         \n                        wo_id,\n                        wo_status,\n                        wo_number,\n                        wo_ordered,\n                        CASE WHEN (wo_id = -1) THEN NULL ELSE formatQty(wo_ordered) END AS f_wo_ordered,\n                        formatdate(wo_startdate) AS f_wo_startdate, \n                        formatdate(wo_duedate) AS f_wo_duedate,\n                        COALESCE(wo_latestart,false) AS wo_latestart,\n                        COALESCE(wo_latedue,false) AS wo_latedue \n                 &lt;? endif ?>\n                 FROM ( SELECT itemsite_id, coitem_id,\n                               item_number, (item_descrip1 || ' ' || item_descrip2) AS item_description,\n                               uom_name, item_picklist,\n                               noNeg(qtyAvailable(itemsite_id)) AS qoh,\n                               noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS sobalance,\n                               qtyAllocated(itemsite_id, coitem_scheddate) AS allocated,\n                               qtyOrdered(itemsite_id, coitem_scheddate) AS ordered,\n                               qtyatshipping(coitem_id) AS atshipping,\n                               CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel \n                 &lt;? if exists(showWoSupply) ?>,  \n                               COALESCE(wo_id,-1) AS wo_id,\n                               formatwonumber(wo_id) AS wo_number,\n                               noNeg((wo_qtyord-wo_qtyrcv)) AS wo_ordered,\n                               wo_status, wo_startdate, wo_duedate,\n                               ((wo_startdate &lt;= CURRENT_DATE) AND (wo_status IN ('O','E','S','R'))) AS wo_latestart,\n                               (wo_duedate&lt;=CURRENT_DATE) AS wo_latedue  \n                 &lt;? endif ?> \n                        FROM cohead, itemsite, item, uom, coitem \n                 &lt;? if exists(showWoSupply) ?> \n                             LEFT OUTER JOIN wo\n                              ON ((coitem_itemsite_id=wo_itemsite_id)\n                              AND (wo_status IN ('E','R','I'))\n                              AND (wo_qtyord-wo_qtyrcv > 0)\n                              AND (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned-qtyatshipping(coitem_id)) > \n                               (SELECT qtyAvailable(itemsite_id) AS availableqoh FROM itemsite WHERE (itemsite_id=coitem_itemsite_id))))\n                 &lt;? endif ?>\n                        WHERE ( (coitem_cohead_id=cohead_id)\n                         AND (coitem_itemsite_id=itemsite_id)\n                         AND (itemsite_item_id=item_id)\n                         AND (item_inv_uom_id=uom_id)\n                         AND (coitem_status NOT IN ('C', 'X'))\n                         AND (cohead_id=&lt;? value(sohead_id) ?>))\n                 ) AS data \n\t              &lt;? if exists(onlyShowShortages) ?>\n                 WHERE ( ((qoh + ordered - allocated) &lt; 0)\n                  OR ((qoh + ordered - sobalance) &lt; 0) ) \n                 &lt;? endif ?>\n                 ORDER BY item_number\n                 &lt;? if exists(showWoSupply) ?> ,\n                 wo_duedate\n                 &lt;? endif ?>\n                 ;</sql>\n </querysource>\n <rpthead>\n  <height>251</height>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>230</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty Due</string>\n  </label>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Allocated</string>\n  </label>\n  <label>\n   <rect>\n    <x>185</x>\n    <y>230</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>100</y>\n    <width>102</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer:</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>230</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>120</y>\n    <width>102</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Cust. Phone:</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>This Available</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>100</y>\n    <width>102</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sales Order #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>10</y>\n    <width>500</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Inventory Availability by Sales Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>140</y>\n    <width>102</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>P/O #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Orders</string>\n  </label>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>230</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>W/O Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>175</y>\n    <width>380</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showWoSupply</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>215</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>This Allocated</string>\n  </label>\n  <line>\n   <xstart>10</xstart>\n   <ystart>245</ystart>\n   <xend>750</xend>\n   <yend>245</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>120</y>\n    <width>102</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Order Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>100</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>230</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>120</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_phone</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>160</y>\n    <width>380</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_onlyShowShortages</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>120</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>orderdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Available</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>At Shipping</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>This Allocated</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>20</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>At Shipping</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Available</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>This Available</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Allocated</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Orders</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>coitem</name>\n   <column>coitem_id</column>\n   <head>\n    <height>31</height>\n    <field>\n     <rect>\n      <x>430</x>\n      <y>15</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_allocated</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>325</x>\n      <y>0</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_qoh</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>185</x>\n      <y>0</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>uom_name</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>640</x>\n      <y>0</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_soavail</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>535</x>\n      <y>15</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_atshipping</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>640</x>\n      <y>15</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_totalavail</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>535</x>\n      <y>0</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_ordered</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>0</y>\n      <width>150</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>Item_number</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>15</y>\n      <width>400</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>Item_description</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>430</x>\n      <y>0</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_sobalance</column>\n     </data>\n    </field>\n   </head>\n   <foot>\n    <height>6</height>\n    <line>\n     <xstart>5</xstart>\n     <ystart>0</ystart>\n     <xend>745</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>535</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_wo_startdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>wo_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_wo_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_wo_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>185</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>wo_status</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102431
 
257     InvoiceInformation      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Invoice Information</title>\n <name>InvoiceInformation</name>\n <description></description>\n <watermark>\n  <data>\n   <query>Parameter Query</query>\n   <column>watermark</column>\n  </data>\n  <opacity>25</opacity>\n </watermark>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>GroupHead</name>\n  <sql>SELECT invchead_id, invchead_ponumber,\n       formatDate(invchead_shipdate) AS f_shipdate,\n       formatDate(invchead_invcdate) AS f_invcdate,\n       formatMoney(invoiceTotal(invchead_id)) AS f_amount,\n       invchead_billto_name, invchead_billto_address1,\n       invchead_billto_address2, invchead_billto_address3,\n       ( invchead_billto_city || ' ' || invchead_billto_state || ', '\n         || invchead_billto_zipcode ) AS billtocitystatezip,\n       invchead_shipto_name, invchead_shipto_address1,\n       invchead_shipto_address2, invchead_shipto_address3,\n       ( invchead_shipto_city || ' ' || invchead_shipto_state || ', '\n         || invchead_shipto_zipcode ) AS shiptocitystatezip,\n       invchead_notes, invchead_invcnumber\nFROM invchead LEFT OUTER JOIN (invcitem LEFT OUTER JOIN item ON (invcitem_item_id=item_id) ) ON (invcitem_invchead_id=invchead_id)\nWHERE (invchead_id=&lt;? value("invchead_id") ?>)\nGROUP BY invchead_id, invchead_ponumber,\n         invchead_shipdate, invchead_invcdate,\n         invchead_misc_amount, invchead_freight,\n         invchead_billto_name, invchead_billto_address1,\n         invchead_billto_address2, invchead_billto_address3,\n         invchead_billto_city, invchead_billto_state, invchead_billto_zipcode,\n         invchead_shipto_name, invchead_shipto_address1,\n         invchead_shipto_address2, invchead_shipto_address3,\n         invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode,\n         invchead_notes, invchead_invcnumber;</sql>\n </querysource>\n <querysource>\n  <name>CustInfo</name>\n  <sql>SELECT cust_id,\n       cust_number,\n       cust_name,\n       addr_line1 AS cust_address1,\n       addr_line2 AS cust_address2,\n       addr_line3 AS cust_address3,\n       addr_city || ' ' || addr_state || ', ' || addr_postalcode AS custcitystatezip\nFROM invchead, custinfo\nLEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\nLEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\nWHERE ( (invchead_id=&lt;? value("invchead_id") ?>)\n AND (invchead_cust_id=cust_id) );</sql>\n </querysource>\n <querysource>\n  <name>Details</name>\n  <sql>SELECT 1 as grpnum,\n       arapply_id,\n       CASE WHEN (arapply_source_doctype = 'C') THEN text('C/M')\n            WHEN (arapply_fundstype='C') THEN text('Check')\n            WHEN (arapply_fundstype='T') THEN text('Certified Check')\n            WHEN (arapply_fundstype='M') THEN text('Master Card')\n            WHEN (arapply_fundstype='V') THEN text('Visa')\n            WHEN (arapply_fundstype='A') THEN text('American Express')\n            WHEN (arapply_fundstype='D') THEN text('Discover Card')\n            WHEN (arapply_fundstype='R') THEN text('Other Credit Card')\n            WHEN (arapply_fundstype='K') THEN text('Cash')\n            WHEN (arapply_fundstype='W') THEN text('Wire Transfer')\n            WHEN (arapply_fundstype='O') THEN text('Other')\n       END AS documenttype,\n       CASE WHEN (arapply_source_doctype = 'C') THEN arapply_source_docnumber\n            WHEN (arapply_source_doctype = 'R') THEN arapply_source_docnumber\n            WHEN (arapply_source_doctype = 'K') THEN arapply_refnumber\n            ELSE text('Error')\n       END AS docnumber,\n       formatDate(arapply_postdate) AS f_postdate,\n       formatMoney(arapply_applied) AS f_amount\n  FROM arapply, invchead\n WHERE ( (arapply_target_doctype='I')\n   AND (arapply_target_docnumber=invchead_invcnumber)\n   AND (invchead_id=&lt;? value("invchead_id") ?>) )\nORDER BY arapply_postdate;</sql>\n </querysource>\n <pghead>\n  <firstpage/>\n  <height>389</height>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>80</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>f_invcdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>155</x>\n    <y>140</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>CustInfo</query>\n    <column>cust_address2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>50</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Cust. P/O Number:</string>\n  </label>\n  <field>\n   <rect>\n    <x>155</x>\n    <y>80</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>CustInfo</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>25</x>\n    <y>280</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_billto_address2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>155</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>CustInfo</query>\n    <column>cust_address1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>125</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>f_amount</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>25</x>\n    <y>240</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_billto_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>155</x>\n    <y>25</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_invcnumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>155</x>\n    <y>160</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>CustInfo</query>\n    <column>cust_address3</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>155</x>\n    <y>100</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>CustInfo</query>\n    <column>cust_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>225</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ship To:</string>\n  </label>\n  <label>\n   <rect>\n    <x>457</x>\n    <y>125</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Invoice Amount:</string>\n  </label>\n  <field>\n   <rect>\n    <x>155</x>\n    <y>180</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>CustInfo</query>\n    <column>custcitystatezip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>350</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Notes:</string>\n  </label>\n  <field>\n   <rect>\n    <x>25</x>\n    <y>320</y>\n    <width>325</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>billtocitystatezip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>225</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bill To:</string>\n  </label>\n  <label>\n   <rect>\n    <x>457</x>\n    <y>100</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ship Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>320</y>\n    <width>325</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>shiptocitystatezip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>80</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>300</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_shipto_address3</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>25</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Invoice #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>280</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_shipto_address2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>155</x>\n    <y>50</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_ponumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>457</x>\n    <y>80</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Invoice Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>240</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_shipto_name</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>20</x>\n    <y>365</y>\n    <width>690</width>\n    <height>20</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_notes</column>\n   </data>\n  </text>\n  <field>\n   <rect>\n    <x>25</x>\n    <y>300</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_billto_address3</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>260</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_shipto_address1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>10</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>20</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Invoice Information</string>\n  </label>\n  <field>\n   <rect>\n    <x>25</x>\n    <y>260</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_billto_address1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>100</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>f_shipdate</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>details</name>\n  <group>\n   <name>header</name>\n   <column>grpnum</column>\n   <head>\n    <height>47</height>\n    <label>\n     <rect>\n      <x>540</x>\n      <y>25</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Apply Date</string>\n    </label>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>25</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Type</string>\n    </label>\n    <label>\n     <rect>\n      <x>110</x>\n      <y>25</y>\n      <width>150</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Doc./Ref. Number</string>\n    </label>\n    <line>\n     <xstart>5</xstart>\n     <ystart>40</ystart>\n     <xend>745</xend>\n     <yend>40</yend>\n     <weight>2</weight>\n    </line>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>5</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Applications:</string>\n    </label>\n    <label>\n     <rect>\n      <x>645</x>\n      <y>25</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Amount</string>\n    </label>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>Details</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Details</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>0</y>\n     <width>425</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Details</query>\n     <column>docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Details</query>\n     <column>documenttype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Details</query>\n     <column>f_postdate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102432
 
281     InvoiceRegister \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Invoice Register</title>\n <name>InvoiceRegister</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("accnt_id") ?>\n         ( SELECT (accnt_number || '-' || accnt_descrip)\n             FROM accnt\n            WHERE (accnt_id=&lt;? value("accnt_id") ?>) )\n       &lt;? else ?>\n         text('All Accounts')\n       &lt;? endif ?>\n       AS accnt</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT gltrans_id,\n       formatDate(gltrans_date) AS transdate,\n       gltrans_source,\n       CASE WHEN(gltrans_doctype='IN') THEN text('Invoice')\n            WHEN(gltrans_doctype='CM') THEN text('Credit Memo')\n            WHEN(gltrans_doctype='DM') THEN text('Debit Memo')\n            WHEN(gltrans_doctype='CD') THEN text('Customer Deposit')\n            ELSE gltrans_doctype\n       END AS doctype,\n       gltrans_docnumber,\n       CASE WHEN(gltrans_doctype='IN') THEN\n                (SELECT invchead_shipto_name\n                   FROM aropen LEFT OUTER JOIN\n                        invchead\n                          ON (invchead_id=aropen_cobmisc_id\n                          AND invchead_cust_id=aropen_cust_id)\n                  WHERE ((aropen_docnumber=gltrans_docnumber)\n                    AND  (aropen_doctype='I')))\n            ELSE firstLine(gltrans_notes)\n       END AS transnotes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       CASE WHEN (gltrans_amount &lt; 0) THEN formatMoney(ABS(gltrans_amount))\n            ELSE ''\n       END AS f_debit,\n       CASE WHEN (gltrans_amount &lt; 0) THEN ABS(gltrans_amount)\n            ELSE 0\n       END AS debit,\n       CASE WHEN (gltrans_amount > 0) THEN formatMoney(gltrans_amount)\n            ELSE ''\n       END AS f_credit,\n       CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n            ELSE 0\n       END AS credit\n  FROM gltrans, accnt\n WHERE ((gltrans_accnt_id=accnt_id)\n   AND (gltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n   AND (gltrans_source = 'A/R')\n   AND (gltrans_date BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n&lt;? if exists("accnt_id") ?>\n   AND (gltrans_accnt_id=&lt;? value("accnt_id") ?>)\n&lt;? endif ?>\n       )\nORDER BY gltrans_date, gltrans_docnumber;</sql>\n </querysource>\n <rpthead>\n  <height>205</height>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>90</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>545</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>170</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>10</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Invoice Register</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>185</y>\n    <width>104</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Account:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>70</y>\n    <width>290</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>accnt</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>170</y>\n    <width>104</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n  <field>\n   <rect>\n    <x>545</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>200</ystart>\n   <xend>745</xend>\n   <yend>200</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>508</x>\n    <y>185</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>5</y>\n    <width>104</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>5</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>508</x>\n    <y>20</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>20</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>20</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>20</y>\n    <width>104</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>bydate</name>\n   <column>transdate</column>\n   <head>\n    <height>21</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>transdate</column>\n     </data>\n    </field>\n   </head>\n   <foot>\n    <height>21</height>\n    <label>\n     <rect>\n      <x>160</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Subtotal:</string>\n    </label>\n    <field>\n     <rect>\n      <x>509</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>debit</column>\n     </data>\n     <tracktotal subtotal="true" builtin="true" >money</tracktotal>\n    </field>\n    <field>\n     <rect>\n      <x>600</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>credit</column>\n     </data>\n     <tracktotal subtotal="true" builtin="true" >money</tracktotal>\n    </field>\n    <line>\n     <xstart>5</xstart>\n     <ystart>15</ystart>\n     <xend>745</xend>\n     <yend>15</yend>\n     <weight>1</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>31</height>\n   <field>\n    <rect>\n     <x>95</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_source</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>160</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>160</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>509</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_debit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>15</y>\n     <width>260</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>account</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_credit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>0</y>\n     <width>260</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transnotes</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>21</height>\n  <field>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>credit</column>\n   </data>\n   <tracktotal builtin="true" >money</tracktotal>\n  </field>\n  <field>\n   <rect>\n    <x>509</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>debit</column>\n   </data>\n   <tracktotal builtin="true" >money</tracktotal>\n  </field>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Total:</string>\n  </label>\n </rptfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102433
 
443     Journals        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Journals</title>\n <name>Journals</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("source") ?>\n         text(&lt;? value("source") ?>)\n       &lt;? else ?>\n         text('All Sources')\n       &lt;? endif  ?>\n       AS source,\n       &lt;? if exists("accnt_id") ?>\n         ( SELECT (accnt_number || '-' || accnt_descrip)\n             FROM accnt\n            WHERE (accnt_id=&lt;? value("accnt_id") ?>) )\n       &lt;? else ?>\n         text('All Accounts')\n       &lt;? endif ?>\n       AS accnt,\n       &lt;? if exists("showUsernames") ?>\n         text('Username')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_username</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT sltrans_id,\n       sltrans_created, formatDate(sltrans_date) AS transdate,\n       sltrans_source, sltrans_doctype, sltrans_docnumber, invhist_docnumber,\n       firstLine(sltrans_notes) AS transnotes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n-- Debits:\n       CASE WHEN (sltrans_amount &lt; 0) THEN formatMoney(ABS(sltrans_amount))\n            ELSE ''\n       END AS f_debit,       \n       CASE WHEN (sltrans_amount &lt; 0) THEN ABS(sltrans_amount)\n            ELSE 0\n       END AS debit_amt, \n--Credits:\n       CASE WHEN (sltrans_amount > 0) THEN formatMoney(sltrans_amount)\n            ELSE ''\n       END AS f_credit,\n       CASE WHEN (sltrans_amount > 0) THEN sltrans_amount\n            ELSE 0\n       END AS credit_amt,\n--Balance:\n       sltrans_amount * -1 as balance_amt,\n--\n       sltrans_amount,\n       CASE WHEN accnt_type IN ('A','E') THEN \n         sltrans_amount * -1\n       ELSE sltrans_amount END AS running,\n       formatBoolYN(sltrans_posted) AS f_posted,\n       sltrans_username AS f_username,\n       sltrans_sequence\nFROM sltrans\n  JOIN accnt ON (sltrans_accnt_id=accnt_id) \n     LEFT OUTER JOIN invhist ON (sltrans_misc_id=invhist_id\n                            AND sltrans_docnumber='Misc.') \n&lt;? if exists("company_id") ?>\n     JOIN company ON (accnt_company=company_number) \n&lt;? endif ?>\n&lt;? if exists("prfcntr_id") ?>\n     JOIN prftcntr ON (accnt_profit=prftcntr_number) \n&lt;? endif ?>\n&lt;? if exists("subaccnt_id") ?>\n     JOIN subaccnt ON (accnt_sub=subaccnt_number) \n&lt;? endif ?>\n&lt;? if exists("subType") ?>\n     JOIN subaccnttype ON (subaccnttype_code=accnt_subaccnttype_code) \n&lt;? endif ?>\nWHERE (\n&lt;? if exists("startDate") ?>\n  &lt;? if exists("endDate") ?>\n       (sltrans_date BETWEEN &lt;? value("startDate") ?>\n                         AND &lt;? value("endDate") ?>)\n  &lt;? else ?>\n       (sltrans_date BETWEEN &lt;? value("startDate") ?>\n                         AND endoftime())\n  &lt;? endif ?>\n&lt;? else ?>\n  &lt;? if exists("endDate") ?>\n       (sltrans_date BETWEEN startoftime()\n                         AND &lt;? value("endDate") ?>)\n  &lt;? else ?>\n       (sltrans_date BETWEEN startoftime()\n                         AND endoftime())\n  &lt;? endif ?>\n&lt;? endif ?>\n&lt;? if exists("company_id") ?>\n   AND (company_id=&lt;? value("company_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("prfcntr_id") ?>\n   AND (prftcntr_id=&lt;? value("prfcntr_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("accnt_number") ?>\n   AND (accnt_number=&lt;? value("accnt_number") ?>)\n&lt;? endif ?>\n&lt;? if exists("subaccnt_id") ?>\n   AND (subaccnt_id=&lt;? value("subaccnt_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("subType") ?>\n   AND (subaccnttype_id=&lt;? value("subType") ?>)\n&lt;? endif ?>\n&lt;? if exists("accntType") ?>\n   AND (accnt_type= &lt;? value("accntType") ?>)\n&lt;? endif ?>\n&lt;? if exists("accnt_id") ?>\n   AND (sltrans_accnt_id=&lt;? value("accnt_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("docnum") ?>\n   AND (sltrans_docnumber = case when &lt;? value("docnum") ?> = '' then \n sltrans_docnumber else \n&lt;? value("docnum") ?> end ) \n&lt;? endif ?>\n&lt;? if exists("source") ?>\n   AND (sltrans_source=&lt;? value("source") ?>)\n&lt;? endif ?>\n&lt;? if exists("source_pattern") ?>\n   AND (sltrans_source ~* &lt;? value("source_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("journalnumber") ?>\n   AND (sltrans_gltrans_journalnumber=&lt;? value("journalnumber") ?>)\n&lt;? endif ?>\n&lt;? if exists("posted") ?>\n   AND (sltrans_posted=&lt;? value("posted") ?>)\n&lt;? endif ?>\n       )\nORDER BY sltrans_created,\n        sltrans_sequence, sltrans_amount;</sql>\n </querysource>\n <rpthead>\n  <height>205</height>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>170</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>185</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n  <label>\n   <rect>\n    <x>125</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>185</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>185</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>200</ystart>\n   <xend>1000</xend>\n   <yend>200</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>5</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Journals</string>\n  </label>\n  <label>\n   <rect>\n    <x>787.345</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>676.25</x>\n    <y>185.891</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>960</x>\n    <y>185</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>875</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Username</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>40</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>45</height>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>10</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>125</x>\n    <y>25</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>25</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>40</ystart>\n   <xend>1000</xend>\n   <yend>40</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>785.815</x>\n    <y>25.8923</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>25</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>25</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>674.738</x>\n    <y>25.8923</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>25</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n  <label>\n   <rect>\n    <x>960.892</x>\n    <y>25</y>\n    <width>40</width>\n    <height>16.7846</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>869.692</x>\n    <y>25.923</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Username</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>31</height>\n   <field>\n    <rect>\n     <x>882.19</x>\n     <y>-0.890523</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_username</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>790.907</x>\n     <y>-0.890523</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_credit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>15</y>\n     <width>265</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transnotes</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>954.846</x>\n     <y>-0.891</y>\n     <width>42.1539</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_posted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>12500</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>125</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sltrans_doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>180</x>\n     <y>15</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invhist_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>180</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sltrans_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>681.65</x>\n     <y>-0.890523</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_debit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>0</y>\n     <width>270</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>account</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sltrans_source</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <lastpage/>\n  <height>75</height>\n  <field>\n   <rect>\n    <x>765.907</x>\n    <y>8.08006</y>\n    <width>105</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>credit_amt</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n  <line>\n   <xstart>632.141</xstart>\n   <ystart>5.07044</ystart>\n   <xend>1000</xend>\n   <yend>5</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>960</x>\n    <y>60</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>60</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>598.701</x>\n    <y>8.21895</y>\n    <width>55</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Total:</string>\n  </label>\n  <field>\n   <rect>\n    <x>656.65</x>\n    <y>8.08006</y>\n    <width>105</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>debit_amt</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>60</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>868</x>\n    <y>60</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <pgfoot>\n  <height>15</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>868</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>960</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102434
 
95      MaterialUsageVarianceByItem     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Material Usage Variance By Item</title>\n <name>MaterialUsageVarianceByItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       uom_name,\n       &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate\n  FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=&lt;? value("item_id") ?>);\n</sql>\n </querysource>\n <querysource loadFromDb="true" >\n  <name>detail</name>\n  <mqlgroup>workOrderVariance</mqlgroup>\n  <mqlname>material</mqlname>\n </querysource>\n <rpthead>\n  <height>234</height>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>228</ystart>\n   <xend>745</xend>\n   <yend>228</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item</string>\n  </label>\n  <field>\n   <rect>\n    <x>605</x>\n    <y>90</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>605</x>\n    <y>110</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>155</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>90</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>90</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>uom_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. per Var.</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Produced</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>130</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>110</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>90</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Number:</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>110</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>155</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Issue</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Material Usage Variance By Item</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>90</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>90</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>200</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Req.</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Qty. per</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Issue</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Produced</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. per Var.</string>\n  </label>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Req.</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Qty. per</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>15</y>\n     <width>395</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>componentdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_actqtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>494</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_projqtyper</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_received</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtypervarpercent</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>componentitemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>494</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_projreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_posted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtypervar</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_actiss</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ordered</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102435
 
480     ProjectsList    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Projects Detailed List</title>\n <name>ProjectsList</name>\n <description>List of Projects and details</description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>projects</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>55</height>\n  <label>\n   <rect>\n    <x>395</x>\n    <y>5</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Project List</string>\n  </label>\n </rpthead>\n <section>\n  <name>section</name>\n  <group>\n   <name>project</name>\n   <column>project</column>\n   <head>\n    <height>55</height>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>5</y>\n      <width>105</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Project Number:</string>\n    </label>\n    <field>\n     <rect>\n      <x>115</x>\n      <y>25</y>\n      <width>415</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>item</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>115</x>\n      <y>5</y>\n      <width>300</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>name</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>25</x>\n      <y>25</y>\n      <width>80</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Name:</string>\n    </label>\n    <label>\n     <rect>\n      <x>455</x>\n      <y>5</y>\n      <width>80</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Project Type:</string>\n    </label>\n    <field>\n     <rect>\n      <x>540</x>\n      <y>5</y>\n      <width>205</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>project_type</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>635</x>\n      <y>25</y>\n      <width>110</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>status</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>535</x>\n      <y>25</y>\n      <width>95</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Project Status:</string>\n    </label>\n    <line>\n     <xstart>0</xstart>\n     <ystart>5</ystart>\n     <xend>750</xend>\n     <yend>5</yend>\n     <weight>2</weight>\n    </line>\n    <line>\n     <xstart>0</xstart>\n     <ystart>50</ystart>\n     <xend>750</xend>\n     <yend>50</yend>\n     <weight>2</weight>\n    </line>\n   </head>\n  </group>\n  <group>\n   <name>type</name>\n   <column>section</column>\n   <head>\n    <height>53</height>\n    <label>\n     <rect>\n      <x>395</x>\n      <y>30</y>\n      <width>135</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Quantity Ordered / Billed</string>\n    </label>\n    <line>\n     <xstart>0</xstart>\n     <ystart>45</ystart>\n     <xend>750</xend>\n     <yend>45</yend>\n     <weight>2</weight>\n    </line>\n    <label>\n     <rect>\n      <x>660</x>\n      <y>30</y>\n      <width>50</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Value</string>\n    </label>\n    <label>\n     <rect>\n      <x>209</x>\n      <y>30</y>\n      <width>85</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Status</string>\n    </label>\n    <line>\n     <xstart>77</xstart>\n     <ystart>45</ystart>\n     <xend>77</xend>\n     <yend>45</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>30</x>\n      <y>30</y>\n      <width>174</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Order Number - Line</string>\n    </label>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>5</y>\n      <width>90</width>\n      <height>16</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Order Type:</string>\n    </label>\n    <field>\n     <rect>\n      <x>90</x>\n      <y>5</y>\n      <width>610</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>section_qtdisplayrole</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>305</x>\n      <y>30</y>\n      <width>95</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Item</string>\n    </label>\n   </head>\n   <foot>\n    <height>33</height>\n    <line>\n     <xstart>305</xstart>\n     <ystart>5</ystart>\n     <xend>750</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>2</y>\n     <width>135</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>210</x>\n     <y>2</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>445</x>\n     <y>2</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>545</x>\n     <y>2</y>\n     <width>165</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_value</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>30</x>\n     <y>2</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>16</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>700</x>\n    <y>16</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>16</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>-11</ystart>\n   <xend>750</xend>\n   <yend>-11</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>75</x>\n    <y>16</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n  List of Projects and details    0       2014-03-20 16:30:39.072368
102436
 
362     ListTransferOrders      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>List Transfer Orders</title>\n <name>ListTransferOrders</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("src_warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("src_warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?> AS src_warehous_code,\n       &lt;? if exists("dest_warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("dest_warehous_id") ?>) )\n       &lt;? else ?>\n          text('All Sites')\n       &lt;? endif ?> AS dest_warehous_code,\n       CASE WHEN (&lt;? value ("tohead_status") ?>='C') THEN 'Closed'\n            WHEN (&lt;? value ("tohead_status") ?>='O') THEN 'Open'\n            ELSE text('All Statuses')\n            END AS status;\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT tohead_number,\n       tohead_srcname,\n       tohead_trnsname,\n       tohead_destname,\n       formatDate(tohead_orderdate) AS f_orderdate,\n       formatDate(MIN(toitem_schedshipdate)) AS f_scheddate,\n       formatDate(DATE(MAX(shipitem_shipdate))) AS f_shipdate,\n       CASE WHEN (tohead_status='C') THEN 'Closed'\n            WHEN (tohead_status='O') THEN 'Open'\n            ELSE tohead_status\n            END AS status\n  FROM tohead, toitem LEFT OUTER JOIN\n       (shipitem JOIN\n        shiphead ON (shipitem_shiphead_id=shiphead_id\n                    AND shiphead_order_type='TO')\n       ) ON (shipitem_orderitem_id=toitem_id)\n WHERE ((toitem_tohead_id=tohead_id)\n   AND  (toitem_status&lt;>'X')\n&lt;? if exists("tohead_status") ?>\n   AND (tohead_status=&lt;? value("tohead_status") ?>)\n&lt;? elseif exists("excludeClosed") ?>\n   AND (tohead_status &lt;> 'C')\n&lt;? endif ?>\n&lt;? if exists("src_warehous_id") ?>\n   AND  (tohead_src_warehous_id=&lt;? value("src_warehous_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("dest_warehous_id") ?>\n   AND  (tohead_dest_warehous_id=&lt;? value("dest_warehous_id") ?>)\n&lt;? endif ?>\n)\nGROUP BY tohead_number, tohead_srcname, tohead_trnsname, tohead_destname,\n         tohead_orderdate, tohead_status\nORDER BY tohead_number;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>T/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>200</y>\n    <width>100</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Transit</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>200</y>\n    <width>100</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>To</string>\n  </label>\n  <label>\n   <rect>\n    <x>700</x>\n    <y>200</y>\n    <width>50</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>200</y>\n    <width>100</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>From</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>List Transfer Orders</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>200</y>\n    <width>100</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Scheduled</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>105</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>From Site:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>150</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>status</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>130</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>To Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>105</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>src_warehous_code</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>130</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>dest_warehous_code</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>150</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Status:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>T/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>0</y>\n    <width>100</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>To</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>700</x>\n    <y>0</y>\n    <width>50</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>100</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Scheduled</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>From</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>0</y>\n    <width>100</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>0</y>\n    <width>100</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Transit</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>15</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>tohead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_shipdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>95</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>tohead_trnsname</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>0</y>\n     <width>95</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>tohead_destname</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>95</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>tohead_srcname</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_scheddate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>0</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_orderdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>700</x>\n     <y>0</y>\n     <width>50</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>status</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>15</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102437
 
94      MaterialUsageVarianceByBOMItem  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Material Usage Variance By BOM Item</title>\n <name>MaterialUsageVarianceByBOMItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT parent.item_number AS parent_number,\n       parent.item_descrip1 AS parent_descrip1,\n       parent.item_descrip2 AS parent_descrip2,\n       puom.uom_name AS parent_invuom,\n       child.item_number AS comp_number,\n       child.item_descrip1 AS comp_descrip1,\n       child.item_descrip2 AS comp_descrip2,\n       cuom.uom_name AS comp_invuom,\n       bomitem_seqnumber as comp_seqnumber,\n       &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse\n  FROM item as parent, item as child, uom AS puom, uom AS cuom, bomitem\n WHERE ((parent.item_id=&lt;? value("item_id") ?>)\n   AND (parent.item_inv_uom_id=puom.uom_id)\n   AND (bomitem_item_id=child.item_id)\n   AND (child.item_inv_uom_id=cuom.uom_id)\n   AND (bomitem_id=&lt;? value("bomitem_id") ?>) );\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT formatDate(posted) AS f_posted,\n       formatQty(ordered) AS f_ordered,\n       formatQty(received) AS f_produced,\n       formatQty(projreq) AS f_projreq,\n       formatQtyPer(projqtyper) AS f_projqtyper,\n       formatQty(actiss) AS f_actiss, \n       formatQtyPer(actqtyper) AS f_actqtyper,\n       formatQtyPer(actqtyper - projqtyper) AS f_qtypervar,\n       CASE WHEN (actqtyper=projqtyper) THEN formatPrcnt(0)\n            WHEN (projqtyper=0) THEN formatPrcnt(actqtyper)\n            ELSE formatPrcnt((1 - (actqtyper / projqtyper)) * -1)\n       END AS f_percent\n  FROM ( SELECT womatlvar_posted AS posted,\n                womatlvar_qtyord AS ordered,\n                womatlvar_qtyrcv AS received,\n                (womatlvar_qtyrcv * (womatlvar_qtyper * (1 + womatlvar_scrap))) AS projreq,\n                womatlvar_qtyper AS projqtyper,\n                (womatlvar_qtyiss) AS actiss, (womatlvar_qtyiss / (womatlvar_qtyrcv * (1 + womatlvar_scrap))) AS actqtyper \n           FROM womatlvar, itemsite AS component,\n                itemsite AS parent\n          WHERE ((womatlvar_parent_itemsite_id=parent.itemsite_id)\n            AND (womatlvar_component_itemsite_id=component.itemsite_id)\n            AND (womatlvar_bomitem_id=&lt;? value("bomitem_id") ?>)\n            AND (womatlvar_posted BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n&lt;? if exists("warehous_id") ?>\n            AND (component.itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n                )\n       ) AS data\nORDER BY posted;</sql>\n </querysource>\n <rpthead>\n  <height>237</height>\n  <field>\n   <rect>\n    <x>80</x>\n    <y>140</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>comp_seqnumber</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>227</ystart>\n   <xend>745</xend>\n   <yend>227</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>180</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Req.</string>\n  </label>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>60</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>parent_invuom</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>180</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>415</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Issue</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>60</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Number:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>60</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>parent_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>120</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>comp_invuom</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Produced</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>80</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>parent_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>120</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>comp_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>160</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>comp_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>60</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. per Var.</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>120</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>140</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Seq. #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>493</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>10</y>\n    <width>545</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Material Usage Variance By BOM Item</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>140</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>comp_descrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>parent_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>120</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Component Item:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>22</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>415</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Issue</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Req.</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Produced</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. per Var.</string>\n  </label>\n  <label>\n   <rect>\n    <x>493</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Qty. per</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>250</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_projreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_percent</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_produced</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>415</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_actiss</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_posted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_projqtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>493</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_actqtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtypervar</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102438
 
149     POHistory       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>P/O History</title>\n <name>POHistory</name>\n <description></description>\n <parameter default="529" active="true" listtype="dynamic" type="string" name="pohead_id" >\n  <description></description>\n  <query>select pohead_id, pohead_number from pohead order by pohead_number desc;</query>\n </parameter>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT pohead_number,&#xd;\n       vend_name&#xd;\n  FROM pohead, vendinfo&#xd;\n WHERE ((pohead_id=&lt;? value("pohead_id") ?>)&#xd;\n  AND  (pohead_vend_id=vend_id));</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT &#xd;\npoitem_linenumber as f_number, &#xd;\nitem_number as f_item, &#xd;\nuom_name as f_uom1,&#xd;\nformatDate(poitem_duedate) as f_duedate,&#xd;\npoitem_vend_item_number as f_vend_item,&#xd;\npoitem_vend_uom as f_uom2,&#xd;\nformatQty(poitem_qty_ordered) as f_ordered,&#xd;\nformatqty(poitem_qty_received) as f_received&#xd;\nFROM poitem, itemsite, item, uom&#xd;\nWHERE ((poitem_itemsite_id=itemsite_id)&#xd;\nAND (itemsite_item_id=item_id)&#xd;\nAND (item_inv_uom_id=uom_id)&#xd;\nAND (poitem_pohead_id=&lt;? value("pohead_id") ?>)) &#xd;\n&#xd;\nUNION&#xd;\n&#xd;\nSELECT &#xd;\npoitem_linenumber as f_number, &#xd;\npoitem_vend_item_number as f_item, &#xd;\nexpcat_code as f_uom1,&#xd;\nformatDate(poitem_duedate) as f_duedate,&#xd;\npoitem_vend_item_descrip as f_vend_item,&#xd;\nexpcat_descrip as f_uom2,&#xd;\nformatQty(poitem_qty_ordered) as f_ordered,&#xd;\nformatqty(poitem_qty_received) as f_received&#xd;\nFROM poitem, expcat&#xd;\nWHERE ((poitem_expcat_id = expcat_id)&#xd;\nAND (poitem_pohead_id=&lt;? value("pohead_id") ?>)) &#xd;\n&#xd;\nORDER BY f_number;</sql>\n </querysource>\n <rpthead>\n  <height>205</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>200</ystart>\n   <xend>990</xend>\n   <yend>200</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>940</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>5</y>\n    <width>530</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>P/O History</string>\n  </label>\n  <label>\n   <rect>\n    <x>730</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vend. Item #</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <field>\n   <rect>\n    <x>105</x>\n    <y>120</y>\n    <width>385</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>120</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor:</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>175</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor UOM or</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>175</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>UOM or</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <field>\n   <rect>\n    <x>105</x>\n    <y>100</y>\n    <width>385</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>pohead_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>840</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>100</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Exp. Cat. Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Exp. Cat. Descrip.</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>8</height>\n </pghead>\n <pghead>\n  <height>42</height>\n  <label>\n   <rect>\n    <x>40</x>\n    <y>22</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>22</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>22</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Exp. Cat. Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>22</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Exp. Cat. Descrip.</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>22</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vend. Item #</string>\n  </label>\n  <label>\n   <rect>\n    <x>725</x>\n    <y>22</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>835</x>\n    <y>22</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>935</x>\n    <y>22</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>37</ystart>\n   <xend>990</xend>\n   <yend>37</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>12</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>UOM or</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>12</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor UOM or</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>45</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_item</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>805</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>900</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_received</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>180</x>\n     <y>0</y>\n     <width>145</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_uom1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>730</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>525</x>\n     <y>0</y>\n     <width>195</width>\n     <height>15</height>\n    </rect>\n    <bottompad>1</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>f_vend_item</column>\n    </data>\n   </text>\n   <text>\n    <rect>\n     <x>325</x>\n     <y>0</y>\n     <width>190</width>\n     <height>15</height>\n    </rect>\n    <bottompad>1</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>f_uom2</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>32</height>\n  <label>\n   <rect>\n    <x>860</x>\n    <y>17</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>945</x>\n    <y>17</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>85</x>\n    <y>17</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>17</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102439
 
331     PurchaseOrder   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Purchase Order</title>\n <name>PurchaseOrder</name>\n <description>Selecting an Alt Address on the PO will cause the printed PO to display that address as the Ship To on the printed document.</description>\n <parameter default="999" active="true" listtype="static" type="string" name="pohead_id">\n  <description></description>\n </parameter>\n <watermark>\n  <data>\n   <query>Head</query>\n   <column>title</column>\n  </data>\n  <opacity>25</opacity>\n </watermark>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>28</topmargin>\n <bottommargin>28</bottommargin>\n <rightmargin>20</rightmargin>\n <leftmargin>20</leftmargin>\n <querysource>\n  <name>Head</name>\n  <sql>SELECT pohead_number,\n       formatDate(pohead_orderdate) AS f_orderdate,\n       pohead_fob,\n       pohead_shipvia,\n       terms_descrip,\n       vend_number,\n       vend_name,\n       warehous_descrip,\n       pohead_agent_username,\n       usr.usr_propername AS username,\n       pohead_comments,\n       text(&lt;? value("title") ?>) AS title\n FROM pohead\n   LEFT OUTER JOIN usr ON (pohead_agent_username = usr_username)\n   LEFT OUTER JOIN terms ON (pohead_terms_id = terms_id)\n   LEFT OUTER JOIN vendinfo ON (pohead_vend_id = vend_id)\n   LEFT OUTER JOIN whsinfo ON (pohead_warehous_id = warehous_id)\n WHERE (pohead_id=&lt;? value("pohead_id") ?>);</sql>\n </querysource>\n <querysource>\n  <name>Detail</name>\n  <sql>SELECT poitem_linenumber,\n       poitem_comments,\n       poitem_linenumber AS f_line,\n       item_number,\n       poitem_vend_item_number, \n       CASE WHEN (LENGTH(TRIM(BOTH '\t' FROM poitem_vend_item_descrip)) &lt;= 0) THEN\n          (item_descrip1 || '' || item_descrip2)\n       ELSE (poitem_vend_item_descrip)\n       END AS itemdescription,\n       formatQty(poitem_qty_ordered) AS f_ordered,\n       CASE WHEN (poitem_vend_uom LIKE '') THEN (uom_name)\n            ELSE (poitem_vend_uom)\n       END AS itemuom,\n       formatPurchPrice(poitem_unitprice) AS f_price,\n       formatExtPrice(poitem_unitprice * poitem_qty_ordered) AS f_extended,\n       formatDate(poitem_duedate) AS f_duedate,\n       characteristicsToString('PI', poitem_id, '=', ', ') AS poitem_characteristics\nFROM poitem\n\tLEFT OUTER JOIN itemsite ON (poitem_itemsite_id = itemsite_id)\n\tLEFT OUTER JOIN (item JOIN uom ON (item_inv_uom_id=uom_id)) ON (itemsite_item_id = item_id)\nWHERE \t(poitem_pohead_id=&lt;? value("pohead_id") ?>) \nORDER BY poitem_linenumber;</sql>\n </querysource>\n <querysource>\n  <name>Foot</name>\n  <sql>SELECT formatExtPrice(subtotal) AS f_subtotal,\n       formatExtPrice(totalfreight) AS f_totalfreight,\n       formatExtPrice(tax) AS f_tax,\n       formatExtPrice(subtotal + totalfreight + tax) AS f_totaldue\nFROM\n( SELECT COALESCE(SUM(poitem_qty_ordered * poitem_unitprice), 0) AS subtotal,\n         COALESCE(SUM(poitem_freight)+pohead_freight,0) AS totalfreight,\n         (SELECT COALESCE(SUM(tax), 0.0)\n          FROM (SELECT ROUND(SUM(taxdetail_tax),2) AS tax\n                FROM tax\n                     JOIN calculateTaxDetailSummary('PO', &lt;? value("pohead_id") ?>, 'T') ON (taxdetail_tax_id=tax_id)\n                GROUP BY tax_id) AS taxdata) AS tax\n  FROM pohead JOIN poitem ON (poitem_pohead_id=pohead_id)\n  WHERE (pohead_id=&lt;? value("pohead_id") ?>)\n  GROUP BY pohead_freight ) AS data;\n</sql>\n </querysource>\n <querysource>\n  <name>Logo</name>\n  <sql>SELECT image_data \nFROM image \nWHERE ((image_name='logo'));</sql>\n </querysource>\n <querysource>\n  <name>Currency</name>\n  <sql>SELECT\n curr_symbol\nFROM\n    pohead,\n    curr_symbol\nWHERE (pohead_id = &lt;? value("pohead_id") ?>) AND\n      pohead_curr_id = curr_id;</sql>\n </querysource>\n <querysource>\n  <name>Address</name>\n  <sql>SELECT\n     warehous_descrip,\n     formatAddr(addr_line1, addr_line2, addr_line3, ( addr_city || '  ' || addr_state || '  ' || addr_postalcode), addr_country) AS warehouse_address\nFROM\n     whsinfo, \n     addr, \n     pohead\nWHERE \n     addr_id = warehous_addr_id\n     and pohead_warehous_id = warehous_id\n     AND pohead_id=&lt;? value("pohead_id") ?> ;</sql>\n </querysource>\n <querysource>\n  <name>ShipToAddress</name>\n  <sql>SELECT pohead_number,\n       formatDate(pohead_orderdate) AS f_orderdate,\n       pohead_fob,\n       pohead_shipvia,\n       terms_descrip,\n       vend_number,\n       vend_name,\n       va.addr_line1 AS vend_address1,\n       va.addr_line2 AS vend_address2,\n       va.addr_line3 AS vend_address3,\n       (va.addr_city || '  '  || va.addr_state || '  ' || va.addr_postalcode) AS vendcitystatezip,\n       formatcntctname(pohead_vend_cntct_id) AS vend_contact,\n       formataddr(pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, (pohead_vendcity || '  '  || pohead_vendstate || '   ' || pohead_vendzipcode), pohead_vendcountry) as vend_address,\n       warehous_descrip,\n       wa.addr_line1 as warehous_addr1,\n       wa.addr_line2 as warehous_addr2,\n       wa.addr_line3 as warehous_addr3,\n       wa.addr_city  as warehous_addr4,\n       wa.addr_postalcode as zip,\n       wa.addr_state,\n       wa.addr_country,\n       pohead_shiptoname AS shipto_name,\n       formatcntctname(pohead_shipto_cntct_id) AS shipto_contact,\n       formataddr(pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, (pohead_shiptocity || ' ' || pohead_shiptostate || ' ' || pohead_shiptozipcode), pohead_shiptocountry) as shipto_address,\n       pohead_agent_username AS username,\n       pohead_comments,\n       text(&lt;? value("title") ?>) AS title\n FROM pohead\n   LEFT OUTER JOIN terms ON (pohead_terms_id = terms_id),\n   vendinfo\n   LEFT OUTER JOIN addr va ON (vend_addr_id=va.addr_id),\n   whsinfo\n   LEFT OUTER JOIN addr wa ON (warehous_addr_id = wa.addr_id)\n WHERE ((pohead_vend_id=vend_id)\n   AND (pohead_warehous_id = warehous_id)\n   AND (pohead_id=&lt;? value("pohead_id") ?>) );</sql>\n </querysource>\n <pghead>\n  <height>376</height>\n  <image>\n   <rect>\n    <x>290</x>\n    <y>10</y>\n    <width>225</width>\n    <height>75</height>\n   </rect>\n   <mode>stretch</mode>\n   <data>\n    <query>Logo</query>\n    <column>image_data</column>\n   </data>\n  </image>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>65</y>\n    <width>70</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>ORDER DATE</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>130</ystart>\n   <xend>270</xend>\n   <yend>130</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>5</xstart>\n   <ystart>315</ystart>\n   <xend>805</xend>\n   <yend>315</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>45</y>\n    <width>80</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O NUMBER</string>\n  </label>\n  <line>\n   <xstart>535</xstart>\n   <ystart>130</ystart>\n   <xend>810</xend>\n   <yend>130</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>535</xstart>\n   <ystart>0</ystart>\n   <xend>535</xend>\n   <yend>130</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>680</x>\n    <y>325</y>\n    <width>100</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>EXTENDED PRICE</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>345</y>\n    <width>100</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>REQ. DATE</string>\n  </label>\n  <label>\n   <rect>\n    <x>232</x>\n    <y>325</y>\n    <width>135</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>ITEM DESCRIPTION</string>\n  </label>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>60</y>\n    <width>140</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>f_orderdate</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>500</x>\n    <y>142</y>\n    <width>300</width>\n    <height>17</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>ShipToAddress</query>\n    <column>shipto_contact</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>325</y>\n    <width>85</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UNIT PRICE</string>\n  </label>\n  <text>\n   <rect>\n    <x>5</x>\n    <y>25</y>\n    <width>265</width>\n    <height>17</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Address</query>\n    <column>warehouse_address</column>\n   </data>\n  </text>\n  <field>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>267</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Address</query>\n    <column>warehous_descrip</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>40</y>\n    <width>126</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>pohead_number</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>360</ystart>\n   <xend>805</xend>\n   <yend>360</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>335</y>\n    <width>80</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>YOUR ITEM #</string>\n  </label>\n  <text>\n   <rect>\n    <x>75</x>\n    <y>155</y>\n    <width>300</width>\n    <height>17</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>ShipToAddress</query>\n    <column>vend_contact</column>\n   </data>\n  </text>\n  <line>\n   <xstart>270</xstart>\n   <ystart>0</ystart>\n   <xend>270</xend>\n   <yend>130</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>325</y>\n    <width>85</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>CURRENCY</string>\n  </label>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>345</y>\n    <width>80</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>5</x>\n    <y>290</y>\n    <width>187</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>pohead_fob</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>202</x>\n    <y>290</y>\n    <width>252</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>pohead_shipvia</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>290</x>\n    <y>265</y>\n    <width>75</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>SHIP VIA:</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>345</y>\n    <width>85</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QTY. ORDERED</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>252</width>\n    <height>32</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Purchase Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>155</y>\n    <width>17</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <bottom/>\n   <string>TO:</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>265</y>\n    <width>37</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>TERMS</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>320</y>\n    <width>37</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>LINE</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>265</y>\n    <width>60</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>F.O.B.</string>\n  </label>\n  <field>\n   <rect>\n    <x>655</x>\n    <y>290</y>\n    <width>117</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>username</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>442</x>\n    <y>290</y>\n    <width>202</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>terms_descrip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>142</y>\n    <width>17</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>TO:</string>\n  </label>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>85</y>\n    <width>35</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>285</ystart>\n   <xend>805</xend>\n   <yend>285</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>320</y>\n    <width>80</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>OUR ITEM #</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>85</y>\n    <width>35</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>PAGE</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>265</y>\n    <width>95</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>ORDERED BY</string>\n  </label>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>142</y>\n    <width>37</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>SHIP</string>\n  </label>\n  <field>\n   <rect>\n    <x>75</x>\n    <y>137</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Head</query>\n    <column>vend_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>107</y>\n    <width>140</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>107</y>\n    <width>75</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>PRINT DATE</string>\n  </label>\n  <text>\n   <rect>\n    <x>500</x>\n    <y>172</y>\n    <width>300</width>\n    <height>17</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>ShipToAddress</query>\n    <column>shipto_address</column>\n   </data>\n  </text>\n  <text>\n   <rect>\n    <x>75</x>\n    <y>172</y>\n    <width>300</width>\n    <height>17</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>ShipToAddress</query>\n    <column>vend_address</column>\n   </data>\n  </text>\n  <text>\n   <rect>\n    <x>500</x>\n    <y>157</y>\n    <width>300</width>\n    <height>17</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>ShipToAddress</query>\n    <column>shipto_name</column>\n   </data>\n  </text>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>Detail</query>\n   </key>\n   <height>107</height>\n   <field>\n    <rect>\n     <x>625</x>\n     <y>25</y>\n     <width>55</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>itemuom</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>50</x>\n     <y>65</y>\n     <width>605</width>\n     <height>17</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>poitem_comments</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>700</x>\n     <y>25</y>\n     <width>100</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>700</x>\n     <y>5</y>\n     <width>92</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_extended</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>45</y>\n     <width>750</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>poitem_characteristics</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>545</x>\n     <y>25</y>\n     <width>75</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>555</x>\n     <y>5</y>\n     <width>75</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_price</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>5</y>\n     <width>25</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <bottom/>\n    <data>\n     <query>Currency</query>\n     <column>curr_symbol</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>150</x>\n     <y>5</y>\n     <width>350</width>\n     <height>17</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>itemdescription</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>25</y>\n     <width>225</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>poitem_vend_item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>5</y>\n     <width>92</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>5</y>\n     <width>36</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_line</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <lastpage/>\n  <height>113</height>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>85</y>\n    <width>25</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <bottom/>\n   <data>\n    <query>Currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>35</x>\n    <y>10</y>\n    <width>530</width>\n    <height>17</height>\n   </rect>\n   <bottompad>14</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>pohead_comments</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>12</y>\n    <width>60</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <bottom/>\n   <string>SUB TOTAL</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>55</y>\n    <width>100</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <bottom/>\n   <data>\n    <query>Foot</query>\n    <column>f_tax</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>85</y>\n    <width>100</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <bottom/>\n   <data>\n    <query>Foot</query>\n    <column>f_totaldue</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>12</y>\n    <width>25</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <bottom/>\n   <data>\n    <query>Currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>55</y>\n    <width>25</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <bottom/>\n   <data>\n    <query>Currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <line>\n   <xstart>585</xstart>\n   <ystart>75</ystart>\n   <xend>806</xend>\n   <yend>75</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>35</y>\n    <width>60</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <bottom/>\n   <string>FREIGHT</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>55</y>\n    <width>60</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <bottom/>\n   <string>TAX</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>35</y>\n    <width>100</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <bottom/>\n   <data>\n    <query>Foot</query>\n    <column>f_totalfreight</column>\n   </data>\n  </field>\n  <line>\n   <xstart>10</xstart>\n   <ystart>5</ystart>\n   <xend>805</xend>\n   <yend>5</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>12</y>\n    <width>100</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <bottom/>\n   <data>\n    <query>Foot</query>\n    <column>f_subtotal</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>85</y>\n    <width>60</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <bottom/>\n   <string>TOTAL</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>35</y>\n    <width>25</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <bottom/>\n   <data>\n    <query>Currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n </pgfoot>\n <pgfoot>\n  <height>57</height>\n  <label>\n   <rect>\n    <x>32</x>\n    <y>37</y>\n    <width>37</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string></string>\n  </label>\n </pgfoot>\n</report>\n      Selecting an Alt Address on the PO will cause the printed PO to display that address as the Ship To on the printed document.    0       2014-10-06 19:47:03.678943
102440
 
161     PurchasePriceVariancesByItem    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Purchase Price Variances By Item</title>\n <name>PurchasePriceVariancesByItem</name>\n <description></description>\n <grid>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number, item_descrip1,\n       item_descrip2, uom_name,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("warehous_id") ?>\n         (SELECT warehous_code FROM whsinfo WHERE warehous_id=&lt;? value("warehous_id") ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("agentUsername") ?>\n       TEXT(&lt;? value("agentUsername" ?>)\n       &lt;? else ?>\n       TEXT('All Agents')\n       &lt;? endif ?>\n       AS agentUsername\n  FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=&lt;? value("item_id") ?>);</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>poPriceVariances</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>135</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>135</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>215</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>155</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purch. Agent:</string>\n  </label>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>65</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>155</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>agentUsername</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>65</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>85</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Dist. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>200</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Variance</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purchase Price Variances By Item</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>103</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>252</x>\n    <y>65</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>215</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>230</ystart>\n   <xend>745</xend>\n   <yend>230</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>310</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>uom_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>200</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>568</x>\n    <y>215</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vouchered</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>20</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>20</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>5</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Variance</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Dist Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>5</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>568</x>\n    <y>19.5</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vouchered</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>36</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>recv_order_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_varprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_variance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>30</ystart>\n    <xend>745</xend>\n    <yend>30</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_recv_value</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>15</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_voucher_value</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>103</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102441
 
162     PurchasePriceVariancesByVendor  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Purchase Price Variances By Vendor</title>\n <name>PurchasePriceVariancesByVendor</name>\n <description></description>\n <grid>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("warehous_id") ?>\n         (SELECT warehous_code FROM whsinfo WHERE warehous_id=&lt;? value("warehous_id") ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("agentUsername") ?>\n       TEXT(&lt;? value("agentUsername" ?>)\n       &lt;? else ?>\n       TEXT('All Agents')\n       &lt;? endif ?>\n       AS agentUsername;</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>poPriceVariances</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>200</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>64.8725</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purchase Price Variances By Vendor</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>568</x>\n    <y>215</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vouchered</string>\n  </label>\n  <field>\n   <rect>\n    <x>94.254</x>\n    <y>64.8725</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>4.25396</x>\n    <y>64.8725</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>215</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>215</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <field>\n   <rect>\n    <x>95.746</x>\n    <y>84.8725</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>agentUsername</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Dist. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>64.8725</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>4.25396</x>\n    <y>84.8725</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purch. Agent:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>230</ystart>\n   <xend>745</xend>\n   <yend>230</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>68.5</x>\n    <y>200</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>656</x>\n    <y>200</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Variance</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>20</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>5</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Dist. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>568</x>\n    <y>19.9</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vouchered</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>20</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>62.4769</x>\n    <y>4.2543</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>651.846</x>\n    <y>5.00033</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Variance</string>\n  </label>\n  <label>\n   <rect>\n    <x>62.4769</x>\n    <y>18.2543</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Name</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>36</height>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_varprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>6.49</x>\n     <y>-1.88608e-20</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>recv_order_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>30</ystart>\n    <xend>745</xend>\n    <yend>30</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>15</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_voucher_value</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_recv_value</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>69.9</x>\n     <y>0</y>\n     <width>143</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>-0.442</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_variance</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>103</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102442
 
458     QOH     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Quantities on Hand</title>\n <name>QOH</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("onlyShowPositive") ?>\n         text('Only Showing Positive Quantities')\n       &lt;? elseif exists("onlyShowNegative") ?>\n         text('Only Showing Negative Quantities')\n       &lt;? else ?>\n         text('Showing All Quantities')\n       &lt;? endif ?>\n       AS showquantities,\n       &lt;? if exists("showValue") ?>\n         text('Unit Cost') AS lbl_unitcost,\n         text('Value') AS lbl_value,\n         text('NN Value') AS lbl_nnvalue,\n         text('Cost Method') AS lbl_costmethod,\n       &lt;? else ?>\n         text('') AS lbl_unitcost,\n         text('') AS lbl_value,\n         text('') AS lbl_nnvalue,\n         text('') AS lbl_costmethod,\n       &lt;? endif ?>\n       &lt;? if exists("showValue") ?>\n         &lt;? if exists("useActualCosts") ?>\n           text('Showing Actual Costs')\n         &lt;? elseif exists("useStandardCosts") ?>\n           text('Showing Standard Costs')\n         &lt;? else ?>\n           text('Showing Posted Costs')\n         &lt;? endif ?>\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS showvalues;\n</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>qoh</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <querysource>\n  <name>total</name>\n  <sql>SELECT SUM(qoh) AS f_qoh,\n       SUM(nonnetable) AS f_nonnetable,\n       &lt;? if exists("showValue") ?>\n         FormatExtPrice(SUM(standardcost * qoh))\n       &lt;? else ?>\n         ''\n       &lt;? endif ?>\n       AS f_value,\n       &lt;? if exists("showValue") ?>\n         FormatExtPrice(SUM(CASE WHEN (itemsite_loccntrl) THEN (standardcost * nonnetable)\n                                 ELSE 0\n                            END))\n       &lt;? else ?>\n         ''\n       &lt;? endif ?>\n       AS f_nonnetvalue\nFROM ( SELECT itemsite_id, itemsite_costmethod,\n              item_number,\n              item_descrip1, item_descrip2, itemsite_loccntrl,\n              warehous_code,\n              uom_name,\n              CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel,\n              itemsite_qtyonhand AS qoh,\n              CASE WHEN ((itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S'))) THEN 1\n                   ELSE 0\n              END AS detail,\n              itemsite_nnqoh AS nonnetable,\n              &lt;? if exists("useActualCosts") ?>\n                actcost(itemsite_item_id)\n              &lt;? elseif exists("useStandardCosts") ?>\n                stdcost(itemsite_item_id)\n              &lt;? else ?>\n                (itemsite_value / CASE WHEN(itemsite_qtyonhand=0) THEN 1 ELSE itemsite_qtyonhand END)\n              &lt;? endif ?>\n              AS standardcost\n         FROM itemsite, item, uom, whsinfo, costcat\n        WHERE ((itemsite_item_id=item_id)\n          AND (item_inv_uom_id=uom_id)\n          AND (itemsite_warehous_id=warehous_id)\n          AND (itemsite_costcat_id=costcat_id)\n          AND (itemsite_active)\n&lt;? if exists("item_id") ?>\n          AND (item_id=&lt;? value("item_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("classcode_id") ?>\n          AND (item_classcode_id=&lt;? value("classcode_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("classcode_pattern") ?>\n          AND (item_classcode_id IN (SELECT classcode_id\n                                       FROM classcode\n                                      WHERE (classcode_code ~ &lt;? value("classcode_pattern") ?>) ) )\n&lt;? endif ?>\n&lt;? if exists("costcat_id") ?>\n          AND (costcat_id=&lt;? value("costcat_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("costcat_pattern") ?>\n          AND (costcat_id IN (SELECT costcat_id\n                                       FROM costcat\n                                      WHERE (costcat_code ~ &lt;? value("costcat_pattern") ?>) ) )\n&lt;? endif ?>\n&lt;? if exists("itemgrp_id") ?>\n          AND (item_id IN (SELECT itemgrpitem_item_id FROM itemgrpitem WHERE (itemgrpitem_itemgrp_id=&lt;? value("itemgrp_id") ?>)))\n&lt;? endif ?>\n&lt;? if exists("itemgrp_pattern") ?>\n          AND (item_id IN (SELECT itemgrpitem_item_id\n                             FROM itemgrpitem, itemgrp\n                            WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n                              AND (itemgrp_name ~ &lt;? value("itemgrp_pattern") ?>) ) ))\n&lt;? endif ?>\n&lt;? if exists("onlyShowPositive") ?>\n          AND (itemsite_qtyonhand > 0)\n&lt;? elseif exists("onlyShowNegative") ?>\n          AND (itemsite_qtyonhand &lt; 0)\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n          AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n) ) AS data\n;\n</sql>\n </querysource>\n <rpthead>\n  <height>234</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_value</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>509</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unitcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>200</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <field>\n   <rect>\n    <x>185</x>\n    <y>43</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>showvalues</column>\n   </data>\n  </field>\n  <line>\n   <xstart>8</xstart>\n   <ystart>231.167</ystart>\n   <xend>748</xend>\n   <yend>231.167</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Non-Netable</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Lvl.</string>\n  </label>\n  <label>\n   <rect>\n    <x>104</x>\n    <y>200</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_nnvalue</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>215</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Default Location</string>\n  </label>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>43</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>showquantities</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_costmethod</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>104</x>\n    <y>215</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>58</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>8</y>\n    <width>240</width>\n    <height>35</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Quantity On Hand</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_value</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>0</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_nnvalue</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>509</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unitcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>104</x>\n    <y>15</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>104</x>\n    <y>0</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_costmethod</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Lvl.</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Non-Netable</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>15</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Default Location</string>\n  </label>\n  <line>\n   <xstart>10</xstart>\n   <ystart>33.3333</ystart>\n   <xend>750</xend>\n   <yend>33.3333</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>265</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_reorderlevel</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>104</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>104</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>95</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>defaultlocation</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_value</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>345</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qoh</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>104</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_nnvalue</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>15</y>\n     <width>170</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_costmethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_cost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_nnqoh</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>425</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>nnqoh</column>\n   </data>\n   <format builtin="true">qty</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>f_value</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>f_nnvalue</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>345</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>qoh</column>\n   </data>\n   <format builtin="true">qty</format>\n   <tracktotal/>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Totals</string>\n  </label>\n </rptfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102443
 
163     RejectedMaterialByVendor        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Rejected Material By Vendor</title>\n <name>RejectedMaterialByVendor</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT vend_number, vend_name,\n       &lt;? if exists(&quot;warehous_id&quot;) ?>\n         (SELECT warehous_code\n            FROM whsinfo\n           WHERE warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists(&quot;agentUsername&quot;) ?>\n       TEXT(&lt;? value(&quot;agentUsername&quot; ?>)\n       &lt;? else ?>\n       TEXT('All Agents')\n       &lt;? endif ?>\n       AS agentUsername,\n       formatDate(&lt;? value(&quot;startDate&quot;) ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value(&quot;endDate&quot;) ?>, 'Latest') AS enddate\n  FROM vendinfo\n WHERE (vend_id=&lt;? value(&quot;vend_id&quot;) ?>);</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT poreject_id, poreject_ponumber, vend_name,\n       formatDate(poreject_date) as f_date,\n       poreject_vend_item_number as f_itemnum,\n       poreject_vend_item_descrip as f_itemdescrip,\n       formatQty(poreject_qty) as f_qty,\n       rjctcode_code as f_rejectcode\nFROM poreject, vendinfo, itemsite, rjctcode\nWHERE ( (poreject_posted)\n AND (poreject_vend_id=vend_id)\n AND (poreject_rjctcode_id=rjctcode_id)\n AND (poreject_itemsite_id=itemsite_id)\n AND (vend_id=&lt;? value(&quot;vend_id&quot;) ?>)\n AND (date(poreject_date) BETWEEN &lt;? value(&quot;startDate&quot;) ?> AND &lt;? value(&quot;endDate&quot;) ?>)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;agentUsername&quot;) ?>\n AND (poreject_agent_username=&lt;? value(&quot;agentUsername&quot;) ?>)\n&lt;? endif ?>\n )\nORDER BY poreject_date DESC;</sql>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>215</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>155</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purch. Agent:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>135</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>65</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor:</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Rejected Material By Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>85</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reject Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>442</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>65</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>492</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>200</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>442</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>135</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>155</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>agentUsername</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>492</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>5</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Item Number</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reject Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>20</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>36</height>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_rejectcode</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>492</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_itemnum</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poreject_ponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>15</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_itemdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_date</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>30</ystart>\n    <xend>745</xend>\n    <yend>30</yend>\n    <weight>0</weight>\n   </line>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>102</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102444
 
139     ReorderExceptionsByPlannerCode  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Reorder Exceptions by Planner Code</title>\n <name>ReorderExceptionsByPlannerCode</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;plancode_id&quot;) ?>\n         ( SELECT (plancode_code || '-' || plancode_name)\n             FROM plancode\n            WHERE plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)\n       &lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n         text(&lt;? value(&quot;plancode_pattern&quot;) ?>)\n       &lt;? else ?>\n         text('All Planner Codes')\n       &lt;? endif ?>\n       AS plannercode,\n       &lt;? if exists(&quot;includePlannedOrders&quot;) ?>\n         formatBoolYN(true)\n       &lt;? else ?>\n         formatBoolYN(false)\n       &lt;? endif ?>\n       AS includeplnord,\n       &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT warehous_code, item_number, item_descrip1, item_descrip2,\n       formatDate(reorderdate) AS f_reorderdate,\n       formatQty(reorderlevel) AS f_reorderlevel,\n       formatQty((qtyNetable(itemsite_id) - qtyAllocated(itemsite_id, reorderdate) + qtyOrdered(itemsite_id, reorderdate))) AS f_projavail,\n       reorderdate \n  FROM ( SELECT itemsite_id,\n                CASE WHEN (item_type IN ('M', 'B', 'T')) THEN 1\n                     WHEN (item_type IN ('P', 'O')) THEN 2\n                     ELSE 3\n                END AS itemtype,\n                warehous_code, item_number, item_descrip1, item_descrip2,\n                reorderDate(itemsite_id, &lt;? value(&quot;lookAheadDays&quot;) ?>, &lt;? if exists(&quot;includePlannedOrder&quot;) ?>true&lt;? else ?>false&lt;? endif ?>) AS reorderdate,\n                reorderlevel \n           FROM ( SELECT itemsite_id, itemsite_item_id, itemsite_warehous_id,\n                         CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel\n                    FROM itemsite \n                   WHERE ((true)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n                     AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;plancode_id&quot;) ?>\n                     AND (itemsite_plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)\n&lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n                     AND (itemsite_plancode_id IN (SELECT plancode_id\n                                                     FROM plancode\n                                                    WHERE (plancode_code ~ &lt;? value(&quot;plancode_pattern&quot;) ?>)))\n&lt;? endif ?>\n                         )\n                ) AS itemsitedate, item, whsinfo\n          WHERE ((itemsite_item_id=item_id)\n            AND (itemsite_warehous_id=warehous_id))\n       ) AS data \n WHERE (reorderdate IS NOT NULL) \nORDER BY reorderdate, item_number;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Exception Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>200</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Level</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>80</y>\n    <width>175</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Include Planned Orders:</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>10</y>\n    <width>484</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Reorder Exceptions by Planner Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>100</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Parameter Query</query>\n    <column>lookAheadDays</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Avail.</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>525</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>includeplnord</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>80</y>\n    <width>385</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>plannercode</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>120</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Look Ahead Days:</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>80</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Planner Code(s):</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>5</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Avail.</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Level</string>\n  </label>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Exception Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>20</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>385</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_reorderdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_reorderlevel</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>595</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_projavail</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>0</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102445
 
427     ReturnAuthorizationWorkbenchDueCredit   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Return Authorization Workbench Due Credit</title>\n <name>ReturnAuthorizationWorkbenchDueCredit</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n&lt;? if exists("cust_id") ?>\n       cust_number AS f_custtype\n  FROM custinfo\n WHERE(cust_id=&lt;? value("cust_id") ?>);\n&lt;? elseif exists("custtype_id") ?>\n       custtype_name AS f_custtype\n  FROM custtype\n WHERE(custtype_id=&lt;? value("custtype_id") ?>);\n&lt;? elseif exists("custgrp_id") ?>\n       custgrp_name AS f_custtype\n  FROM custgrp\n WHERE(custgrp_id=&lt;? value("custgrp_id") ?>);\n&lt;? else ?>\n       text('All Customer Types') AS f_custtype\n&lt;? endif ?></sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT DISTINCT rahead_id,\nCASE\n  WHEN rahead_creditmethod = 'M' THEN\n    1\n  WHEN rahead_creditmethod = 'K' THEN\n    2\n  WHEN rahead_creditmethod = 'C' THEN\n    3\nEND,\nrahead_number, cust_name,\nformatDate(rahead_authdate) AS f_authdate, formatDate(NULL) AS f_eligibledate,\nformatMoney(currtobase(rahead_curr_id,\n                       calcradueamt(rahead_id), current_date)) AS f_amount,\nCASE\n  WHEN rahead_creditmethod = 'M' THEN\n    &lt;? value("creditmemo") ?>\n  WHEN rahead_creditmethod = 'K' THEN\n    &lt;? value("check") ?>\n  WHEN rahead_creditmethod = 'C' THEN\n    &lt;? value("creditcard") ?>\nEND AS creditmethod, rahead_authdate\nFROM rahead, raitem, custtype, custinfo LEFT OUTER JOIN custgrpitem ON (cust_id=custgrpitem_cust_id)\nWHERE ( (rahead_id=raitem_rahead_id)\n AND (rahead_cust_id=cust_id)\n AND (cust_custtype_id=custtype_id)\n AND ((raitem_disposition = 'R' AND rahead_timing = 'R' AND raitem_qtyreceived > raitem_qtycredited)\n OR (raitem_disposition = 'R' AND rahead_timing = 'I' AND raitem_qtyauthorized > raitem_qtycredited)\n OR (raitem_disposition = 'C' AND raitem_qtyauthorized > raitem_qtycredited))\n AND (raitem_status = 'O')\n AND (rahead_creditmethod != 'N')\n AND (calcradueamt(rahead_id) > 0)\n AND (raitem_disposition IN ('C','R'))\n &lt;? if exists("cust_id") ?>\n AND (cust_id=&lt;? value("cust_id") ?>)\n &lt;? elseif exists("custtype_id") ?>\n AND (custtype_id=&lt;? value("custtype_id") ?>)\n &lt;? elseif exists("custtype_pattern") ?>\n AND (custtype_pattern=&lt;? value("custtype_pattern") ?>)\n &lt;? elseif exists("custgrp_id") ?>\n AND (custgrpitem_custgrp_id=&lt;? value("custgrp_id") ?>)\n &lt;? endif ?>\n AND (rahead_creditmethod IN ('$'\n &lt;? if exists("doM") ?>, 'M'&lt;? endif ?>\n &lt;? if exists("doK") ?>, 'K'&lt;? endif ?>\n &lt;? if exists("doC") ?>, 'C'&lt;? endif ?>\n ))\n ) \nORDER BY rahead_authdate,rahead_number;</sql>\n </querysource>\n <rpthead>\n  <height>223</height>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Auth. #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>165</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer/Cust Type:</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Authorized</string>\n  </label>\n  <label>\n   <rect>\n    <x>90</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>10</y>\n    <width>695</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Return Authorization Workbench Due Credit</string>\n  </label>\n  <field>\n   <rect>\n    <x>185</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_custtype</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Eligible</string>\n  </label>\n  <label>\n   <rect>\n    <x>410</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credited By</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>28</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Authorized</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Auth. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>90</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Eligible</string>\n  </label>\n  <label>\n   <rect>\n    <x>410</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credited By</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_eligibledate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>325</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>410</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>creditmethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>rahead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>90</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>170</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_authdate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102446
 
428     ReturnAuthorizationWorkbenchReview      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Return Authorization Workbench Review</title>\n <name>ReturnAuthorizationWorkbenchReview</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n&lt;? if exists("cust_id") ?>\n       (cust_number || '-' || cust_name) AS f_custtype\n  FROM custinfo\n WHERE(cust_id=&lt;? value("cust_id") ?>)\n&lt;? elseif exists("custtype_id") ?>\n       (custtype_code || '-' || custtype_descrip) AS f_custtype\n  FROM custtype\n WHERE(custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? elseif exists("custgrp_id") ?>\n       (custgrp_name || '-' || custgrp_descrip) AS f_custtype\n  FROM custgrp\n WHERE(custgrp_id=&lt;? value("custgrp_id") ?>)\n&lt;? else ?>\n       text('All Customer Types') AS f_custtype\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT * FROM (\nSELECT rahead_id, rahead_number, COALESCE(cust_name,text('Undefined')) AS custnumber,\nformatDate(rahead_authdate) AS f_authdate, COALESCE(formatDate(rahead_expiredate),text('Never')) AS f_expiredate,\nCASE\n  WHEN raitem_disposition = 'C' THEN\n    text('Credit')\n  WHEN raitem_disposition = 'R' THEN\n    text('Return')\n  WHEN raitem_disposition = 'P' THEN\n    text('Replace')\n  WHEN raitem_disposition = 'V' THEN\n    text('Service')\n  WHEN raitem_disposition = 'S' THEN\n    text('Shipment')\n  END AS disposition,\nCASE\n  WHEN rahead_creditmethod = 'N' THEN\n    text('None')\n  WHEN rahead_creditmethod = 'M' THEN\n    text('Memo')\n  WHEN rahead_creditmethod = 'K' THEN\n    text('Check')\n  WHEN rahead_creditmethod = 'C' THEN\n    text('Card')\nEND AS creditmethod,\nCASE\n  WHEN raitem_status = 'C' THEN\n    text('Closed')\n  WHEN raitem_disposition = 'C' THEN\n    text('Payment')\n  WHEN raitem_disposition = 'R'\n    AND SUM(raitem_qtyauthorized-raitem_qtycredited) > 0\n    AND SUM(raitem_qtyauthorized-raitem_qtyreceived) > 0 THEN\n    text('Receipt') || ',' || text('Payment')\n  WHEN raitem_disposition = 'R'\n    AND SUM(raitem_qtyreceived-raitem_qtycredited) > 0 THEN\n    text('Payment')\n  WHEN raitem_disposition = 'R'\n    AND SUM(raitem_qtyauthorized-raitem_qtyreceived) > 0 THEN\n    text('Receipt')\n  WHEN raitem_disposition IN ('P','V')\n    AND SUM(raitem_qtyauthorized-COALESCE(coitem_qtyshipped,0)) > 0\n    AND SUM(raitem_qtyauthorized-raitem_qtyreceived) > 0 THEN\n    text('Receipt') || ',' || text('Shipment')\n  WHEN raitem_disposition IN ('P','V')\n    AND SUM(raitem_qtyauthorized-COALESCE(coitem_qtyshipped,0)) > 0 THEN\n    text('Shipment')\n  WHEN raitem_disposition IN ('P','V')\n    AND SUM(raitem_qtyauthorized-raitem_qtyreceived) > 0 THEN\n    text('Receipt')\n  WHEN raitem_disposition = 'S' THEN\n    text('Shipment')\n  ELSE ''\nEND AS awaiting\nFROM rahead\n  LEFT OUTER JOIN custinfo ON (rahead_cust_id=cust_id)\n  LEFT OUTER JOIN custtype ON (cust_custtype_id=custtype_id)\n  LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id), \n raitem\n  LEFT OUTER JOIN coitem ON (raitem_new_coitem_id=coitem_id)\nWHERE ( (rahead_id=raitem_rahead_id)\n\n&lt;? if exists("cust_id") ?>\n  AND (cust_id=&lt;? value("cust_id")?>)\n&lt;? elseif exists("custtype_id") ?>\n  AND (custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? elseif exists("custgrp_id") ?>\n  AND (custgrpitem_custgrp_id=&lt;? value("custgrp_id") ?>)\n&lt;? elseif exists("custtype_pattern") ?>\n  AND (custtype_code ~ &lt;? value("custtype_pattern") ?>)\n&lt;? endif ?>\n\n&lt;? if not exists("showExpired") ?>\n  AND (COALESCE(rahead_expiredate,CURRENT_DATE) >= CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if exists("showClosed") ?>\n  AND (raitem_status='O' OR rahead_authdate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n&lt;? else ?>\n  AND (raitem_status = 'O')\n&lt;? endif ?>\n ) GROUP BY rahead_id,rahead_number,cust_name,rahead_expiredate,\n rahead_authdate,raitem_status,raitem_disposition,rahead_creditmethod,\n rahead_curr_id\n ORDER BY rahead_authdate,rahead_number\n) as data\n\nWHERE (FALSE)\n&lt;? if exists("showReceipts") ?>\n OR ((disposition IN ('Return','Replace','Service'))\n  AND (awaiting ~ 'Receipt'))\n&lt;? endif ?>\n&lt;? if exists("showShipments") ?>\n OR ((disposition IN ('Replace','Service','Shipment'))\n  AND (awaiting ~ 'Shipment'))\n&lt;? endif ?>\n&lt;? if exists("showPayments") ?>\n OR ((disposition IN ('Credit','Return'))\n  AND (awaiting ~ 'Payment'))\n&lt;? endif ?>\n&lt;? if exists("showClosed") ?>\n OR ((awaiting = 'Closed'))\n&lt;? endif ?>\n</sql>\n </querysource>\n <rpthead>\n  <height>223</height>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Disposition</string>\n  </label>\n  <label>\n   <rect>\n    <x>90</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Authorized</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Awaiting</string>\n  </label>\n  <field>\n   <rect>\n    <x>185</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_custtype</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>10</y>\n    <width>695</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Return Authorization Workbench Review</string>\n  </label>\n  <label>\n   <rect>\n    <x>7</x>\n    <y>80</y>\n    <width>173</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer/Cust Type/Group:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Auth. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>410</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credited By</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>28</height>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Authorized</string>\n  </label>\n  <label>\n   <rect>\n    <x>410</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credited By</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Auth. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Disposition</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>90</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Awaiting</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>rahead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>170</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_authdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_expiredate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>410</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>creditmethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>325</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>disposition</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>525</x>\n     <y>0</y>\n     <width>195</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>awaiting</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>90</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>custnumber</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102447
 
60      SalesOrderStatus        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Sales Order Status</title>\n <name>SalesOrderStatus</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n       --the following line was added for version 2.3:\n       (select uom_name from uom where uom_id = coitem_qty_uom_id) AS uom_orderuom,\n       coitem_linenumber,\n       item_number, item_descrip1,\n       item_descrip2,\n       warehous_code,\n       formatQty(coitem_qtyord) AS qtyord,\n       formatQty(coitem_qtyshipped) AS qtyship,\n       formatQty(coitem_qtyreturned) AS qtyret,\n       formatQty(SUM(COALESCE(shipitem_qty, 0))) AS qtyinvcd,\n       formatQty(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) AS f_balance,\n       CASE WHEN (coitem_status='C') THEN\n                ( formatDate(coitem_closedate) || ' (' || coitem_close_username || ')' )\n            ELSE ''\n       END AS f_dateuser,\n       CASE WHEN (coitem_order_id=-1) THEN ''\n            WHEN (coitem_order_type='W') THEN\n                ( SELECT (formatWoNumber(wo_id) || '/' || wo_status)\n                    FROM wo\n                   WHERE (wo_id=coitem_order_id) )\n            ELSE ''\n       END AS f_childord\n  FROM itemsite, item, whsinfo, coitem LEFT OUTER JOIN\n       shipitem ON (shipitem_orderitem_id=coitem_id\n              AND shipitem_invcitem_id IS NOT NULL)  \n WHERE ((coitem_itemsite_id=itemsite_id)\n   AND (coitem_status&lt;>'X')\n   AND (itemsite_item_id=item_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (coitem_cohead_id=&lt;? value("sohead_id") ?>)\n)\nGROUP BY uom_orderuom,\n         coitem_id, coitem_linenumber, item_number,\n         item_descrip1, item_descrip2, warehous_code,\n         coitem_qtyord, coitem_qtyshipped, coitem_status,\n         coitem_closedate, coitem_close_username,\n         coitem_qtyreturned, coitem_order_id,\n         coitem_order_type\nORDER BY coitem_linenumber;</sql>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT cohead_number,\n       formatDate(cohead_orderdate) AS orderdate,\n       cohead_custponumber,\n       cust_name, cntct_phone AS cust_phone\n  FROM cohead, custinfo, cntct\n WHERE ((cohead_cust_id=cust_id)\n   AND (cust_cntct_id=cntct_id)\n   AND (cohead_id=&lt;? value("sohead_id") ?>)\n);</sql>\n </querysource>\n <querysource>\n  <name>lastupdated</name>\n  <sql>SELECT formatDate(MAX(lastupdated)) AS f_lastupdated\n  FROM (SELECT cohead_lastupdated AS lastupdated\n          FROM cohead\n         WHERE (cohead_id=:sohead_id)\n         UNION\n        SELECT coitem_lastupdated AS lastupdated\n          FROM coitem\n         WHERE (coitem_cohead_id=&lt;? value("sohead_id") ?>) ) AS data;</sql>\n </querysource>\n <rpthead>\n  <height>224</height>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>75</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>S/O #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>469</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Qty. Invoiced</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>95</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer Phone:</string>\n  </label>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>5</y>\n    <width>355</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sales Order Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>204</x>\n    <y>185</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>112</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>P/O #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Child Ord./Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>390</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Qty. Returned</string>\n  </label>\n  <field>\n   <rect>\n    <x>112</x>\n    <y>95</y>\n    <width>220</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>orderdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>75</y>\n    <width>220</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_name</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Order Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>135</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Last Updated:</string>\n  </label>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>112</y>\n    <width>220</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>75</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>95</y>\n    <width>220</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_phone</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>135</y>\n    <width>220</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>lastupdated</query>\n    <column>f_lastupdated</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>112</x>\n    <y>75</y>\n    <width>220</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>25</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>229</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Qty. Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>200</y>\n    <width>100</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Close Date (User)</string>\n  </label>\n  <label>\n   <rect>\n    <x>310</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Qty. Shipped</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>0</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance/Close Date (User)</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>185</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Returned</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>25</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Child Ord./Status</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>54</height>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_childord</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>550</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_dateuser</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>550</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>25</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>coitem_linenumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>469</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyinvcd</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>35</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>229</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyord</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>170</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>390</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyret</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>35</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>310</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyship</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>35</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_orderuom</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>20</height>\n  <field>\n   <rect>\n    <x>715</x>\n    <y>0</y>\n    <width>30</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>635</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>80</x>\n    <y>0</y>\n    <width>140</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102448
 
247     SelectPaymentsList      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Approve Payments List</title>\n <name>SelectPaymentsList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT apopen_id, apselectid, vendor, apopen_docnumber, apopen_ponumber,\n              formatDate(apopen_duedate) AS f_duedate,\n              formatDate(apopen_docdate) AS f_docdate,\n              formatMoney(amount) AS f_amount,\n              f_selected, f_late, status\n FROM (SELECT apopen_id, COALESCE(apselect_id, -1) AS apselectid,\n       (vend_number || '-' || vend_name) AS vendor,\n       apopen_docnumber, apopen_ponumber,\n       apopen_duedate, apopen_docdate,\n       (apopen_amount - apopen_paid -\n                   COALESCE((SELECT SUM(checkitem_amount / checkitem_curr_rate)\n                             FROM checkitem, checkhead\n                             WHERE ((checkitem_checkhead_id=checkhead_id)\n                              AND (checkitem_apopen_id=apopen_id)\n                              AND (NOT checkhead_void)\n                              AND (NOT checkhead_posted))\n                           ), 0)) AS amount,\n       formatMoney(COALESCE(SUM(apselect_amount), 0)) AS f_selected,\n       formatBoolYN(apopen_duedate &lt;= CURRENT_DATE) AS f_late,\n       CASE WHEN (apopen_status='O') THEN TEXT('Open')\n                    ELSE CASE WHEN (apopen_status='H') THEN TEXT('On Hold')\n                      ELSE CASE WHEN (apopen_status='C') THEN TEXT('Close')\n                      END\n                    END\n                  END AS status\n  FROM vendinfo, apopen LEFT OUTER JOIN apselect ON (apselect_apopen_id=apopen_id)\n WHERE ( (apopen_open)\n   AND (apopen_doctype IN ('V', 'D'))\n   AND (apopen_vend_id=vend_id)\n&lt;? if exists("vend_id") ?>\n   AND (vend_id=&lt;? value("vend_id") ?>)\n&lt;? elseif exists("vendtype_id") ?>\n   AND (vend_vendtype_id=&lt;? value("vendtype_id") ?>)\n&lt;? elseif exists("vendtype_pattern") ?>\n   AND (vend_vendtype_id IN (SELECT vendtype_id\n                               FROM vendtype\n                              WHERE (vendtype_code ~ &lt;? value("vendtype_pattern") ?>)))\n&lt;? endif ?>\n       )\nGROUP BY apopen_id, apselect_id, vend_number, vend_name,\n         apopen_docnumber, apopen_ponumber,\n         apopen_duedate, apopen_docdate, apopen_amount, apopen_paid, apopen_curr_id, apopen_status) AS data\n WHERE (amount &lt;> 0.0)\nORDER BY apopen_duedate, amount DESC;</sql>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("vend_id") ?>\n         ( SELECT vend_name\n             FROM vendinfo\n            WHERE (vend_id=&lt;? value("vend_id") ?>) )\n       &lt;? elseif exists("vendtype_id") ?>\n         ( SELECT (vendtype_code || '-' || vendtype_descrip)\n             FROM vendtype\n            WHERE (vendtype_id=&lt;? value("vendtype_id") ?>) )\n       &lt;? elseif exists("vendtype_pattern") ?>\n         text(&lt;? value("vendtype_pattern") ?>)\n       &lt;? else ?>\n         text('All Vendors')\n       &lt;? endif ?>\n       AS f_value,\n       &lt;? if reExists("vendtype_.*") ?>\n         text('Vendor Type:')\n       &lt;? else ?>\n         text('Vendor:')\n       &lt;? endif ?>\n       AS f_label;\n       </sql>\n </querysource>\n <rpthead>\n  <height>141</height>\n  <field>\n   <rect>\n    <x>20</x>\n    <y>65</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_label</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>130</x>\n    <y>120</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Voucher #</string>\n  </label>\n  <label>\n   <rect>\n    <x>205</x>\n    <y>120</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>120</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Approved</string>\n  </label>\n  <label>\n   <rect>\n    <x>680</x>\n    <y>120</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Late</string>\n  </label>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>120</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>120</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>120</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <field>\n   <rect>\n    <x>150</x>\n    <y>65</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_value</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>120</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>135</ystart>\n   <xend>745</xend>\n   <yend>135</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>5</y>\n    <width>530</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Approve Payments List</string>\n  </label>\n  <label>\n   <rect>\n    <x>435</x>\n    <y>120</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>680</x>\n    <y>0</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Late</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Approved</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>130</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Voucher #</string>\n  </label>\n  <label>\n   <rect>\n    <x>470</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>205</x>\n     <y>-1</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>apopen_ponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>280</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>590</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_selected</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>360</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_docdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>680</x>\n     <y>0</y>\n     <width>65</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_late</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>apopen_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vendor</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>435</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>status</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102449
 
218     ShipmentsByDate \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Shipments By Date</title>\n <name>ShipmentsByDate</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(date(&lt;? value("startDate") ?>)) AS startDate,\n       formatDate(date(&lt;? value("endDate") ?>)) AS endDate;\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT shiphead_id, lineitem_id,\n       CASE WHEN (level=0) THEN order_number\n            ELSE item_number\n       END AS order_item,\n       CASE WHEN (level=0) THEN customer\n            ELSE itemdescription\n       END AS cust_desc,\n       shiphead_order_type,\n       shiphead_number, \n       order_number, \n       customer,\n       shiphead_shipdate AS f_shipdate,\n       shiphead_tracknum,\n       shiphead_freight,\n       freight_curr_abbr,\n       linenumber,\n       item_number,\n       itemdescription,\n       warehous_code,\n       formatQty(qtyord) AS f_qtyord,\n       formatQty(qtyshipped) AS f_qtyshipped\nFROM (\nSELECT shiphead_id, coitem_id AS lineitem_id, cohead_number AS sortkey1, shiphead_number AS sortkey2, 1 AS level,\n       shiphead_order_type,\n       shiphead_number,\n       cohead_number AS order_number, \n       (cust_number || '-' || cust_name) AS customer,\n       shiphead_shipdate,\n       shiphead_tracknum,\n       shiphead_freight,\n       currConcat(shiphead_freight_curr_id) AS freight_curr_abbr, \n       coitem_linenumber AS linenumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n       warehous_code,\n       coitem_qtyord AS qtyord,\n       SUM(shipitem_qty) AS qtyshipped\nFROM shipitem, shiphead, coitem, cohead, custinfo, itemsite, item, whsinfo\nWHERE ( (shipitem_shiphead_id=shiphead_id)\n AND (shipitem_orderitem_id=coitem_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (coitem_status &lt;> 'X')\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (shiphead_order_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='SO')\n&lt;? if exists("startDate") ?>\n AND (shiphead_shipdate BETWEEN &lt;? value("startDate") ?> and &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n AND (itemsite_warehous_id = &lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("sohead_id") ?>\n AND (cohead_id = &lt;? value("sohead_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("shiphead_id") ?>\n AND (shiphead_id = &lt;? value("shiphead_id") ?>)\n&lt;? endif ?>\n      ) \nGROUP BY shiphead_id, coitem_id, shiphead_order_type, shiphead_number,\n         cohead_number, cust_number, cust_name, shiphead_shipdate,\n         coitem_linenumber, item_number, item_descrip1, item_descrip2,\n         warehous_code, shiphead_tracknum, coitem_qtyord, \n         shiphead_freight, shiphead_freight_curr_id \n&lt;? if exists("MultiWhs") ?>\nUNION\nSELECT shiphead_id, toitem_id AS lineitem_id, tohead_number AS sortkey1, shiphead_number AS sortkey2, 1 AS level,\n       shiphead_order_type,\n       shiphead_number,\n       tohead_number AS order_number, \n       tohead_destname AS customer,\n       shiphead_shipdate,\n       shiphead_tracknum,\n       shiphead_freight,\n       currConcat(shiphead_freight_curr_id) AS freight_curr_abbr, \n       toitem_linenumber AS linenumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n       tohead_srcname AS warehous_code,\n       toitem_qty_ordered AS qtyord,\n       SUM(shipitem_qty) AS qtyshipped\nFROM shipitem, shiphead, toitem, tohead, item \nWHERE ( (shipitem_shiphead_id=shiphead_id)\n AND (shipitem_orderitem_id=toitem_id)\n AND (toitem_status &lt;> 'X')\n AND (toitem_item_id=item_id)\n AND (shiphead_order_id=tohead_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='TO')\n&lt;? if exists("startDate") ?>\n AND (shiphead_shipdate BETWEEN &lt;? value("startDate") ?> and &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n AND (tohead_src_warehous_id = &lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("tohead_id") ?>\n AND (tohead_id = &lt;? value("tohead_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("shiphead_id") ?>\n AND (shiphead_id = &lt;? value("shiphead_id") ?>)\n&lt;? endif ?>\n      ) \nGROUP BY shiphead_id, toitem_id, shiphead_order_type, shiphead_number,\n         tohead_number, tohead_destname, shiphead_shipdate,\n         toitem_linenumber, item_number, item_descrip1, item_descrip2,\n         tohead_srcname, shiphead_tracknum, toitem_qty_ordered, \n         shiphead_freight, shiphead_freight_curr_id \n&lt;? endif ?>\n   ) AS data\nORDER BY sortkey1, sortkey2, level, linenumber DESC;\n</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>200</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>185</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>185</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>10</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipments By Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipment #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>90</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>605</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>5</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>537</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>20</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>cohead_number</name>\n   <column>order_number</column>\n   <head>\n    <height>45</height>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>5</y>\n      <width>105</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Order #:</string>\n    </label>\n    <line>\n     <xstart>85</xstart>\n     <ystart>40</ystart>\n     <xend>745</xend>\n     <yend>40</yend>\n     <weight>2</weight>\n    </line>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>20</y>\n      <width>105</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Customer:</string>\n    </label>\n    <field>\n     <rect>\n      <x>114</x>\n      <y>5</y>\n      <width>140</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>order_number</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>114</x>\n      <y>20</y>\n      <width>300</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>customer</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>33</height>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>0</y>\n     <width>140</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyord</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>28</ystart>\n    <xend>745</xend>\n    <yend>28</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>95</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shiphead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyshipped</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>185</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>linenumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>105</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_shipdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>440</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>15</y>\n     <width>455</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemdescription</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>15</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102450
 
219     ShipmentsBySalesOrder   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Shipments By Sales Order</title>\n <name>ShipmentsBySalesOrder</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT cohead_number AS f_sonumber,\n       formatDate(cohead_orderdate) AS f_orderdate,\n       cohead_custponumber AS f_ponumber,\n       cust_name AS f_custname,\n       cntct_phone AS f_custphone\nFROM cohead, custinfo, cntct\nWHERE ((cohead_cust_id=cust_id)\n AND (cust_cntct_id=cntct_id)\n AND (cohead_id=&lt;? value("sohead_id") ?>));</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT shiphead_id,\n       coitem_id,\n       formatShipmentNumber(shiphead_id) AS shiphead_number,\n       formatDate(shiphead_shipdate) AS f_shipdate,\n       coitem_linenumber,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       uom_name,\n       warehous_code,\n       formatQty(coitem_qtyord) AS f_qtyord,\n       formatQty(SUM(shipitem_qty)) AS f_qtyshipped\n  FROM shipitem, shiphead, coitem, itemsite, item, uom, whsinfo\n WHERE ( (shipitem_shiphead_id=shiphead_id)\n   AND (shiphead_order_type='SO')\n   AND (shipitem_orderitem_id=coitem_id)\n   AND (shiphead_shipped)\n   AND (coitem_itemsite_id=itemsite_id)\n   AND (coitem_status&lt;>'X')\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (coitem_cohead_id=&lt;? value("sohead_id") ?>)\n)\nGROUP BY shiphead_id, coitem_id,\n         shiphead_shipdate, coitem_linenumber,\n         item_number, item_descrip1, item_descrip2,\n         uom_name, warehous_code, coitem_qtyord\nORDER BY shiphead_id DESC, coitem_linenumber DESC;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>155</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>P/O Number:</string>\n  </label>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_orderdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>155</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_ponumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>200</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>10</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipments By Sales Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>135</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_custphone</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>114</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_custname</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sales Order #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>185</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>114</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_sonumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>185</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>90</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Order Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipment #</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>135</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer Phone:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>140</x>\n    <y>5</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>419</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>140</x>\n    <y>20</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>15</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>185</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>coitem_linenumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyord</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>105</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_shipdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shiphead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyshipped</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>30</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>385</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>0</y>\n     <width>140</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>440</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n  </detail>\n </section>\n <pgfoot>\n  <height>15</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102451
 
424     ShipmentsByShipment     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Shipments By Shipment</title>\n <name>ShipmentsByShipment</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT shiphead_number AS f_shipnumber,\n       shiphead_tracknum AS f_tracknum,\n       formatMoney(shiphead_freight) AS freight,\n       ordernumber AS f_sonumber,\n       formatDate(orderdate) AS f_orderdate,\n       custponumber AS f_ponumber,\n       cust_name AS f_custname,\n       cntct_phone AS f_custphone\n  FROM custinfo JOIN cntct ON (cust_cntct_id=cntct_id), (SELECT shiphead_number,\n                     shiphead_tracknum,\n                     shiphead_freight,\n                     cohead_number AS ordernumber,\n                     cohead_cust_id AS order_cust_id,\n                     cohead_orderdate AS orderdate,\n                     cohead_custponumber AS custponumber\n                FROM cohead JOIN shiphead ON (shiphead_order_id=cohead_id AND shiphead_order_type='SO')\n               WHERE(shiphead_id=&lt;? value("shiphead_id") ?>)\n              UNION\n              SELECT shiphead_number,\n                     shiphead_tracknum,\n                     shiphead_freight,\n                     tohead_number AS ordernumber,\n                     NULL AS order_cust_id,\n                     tohead_orderdate AS orderdate,\n                     NULL AS custponumber\n                FROM tohead JOIN shiphead ON (shiphead_order_id=tohead_id AND shiphead_order_type='TO')\n               WHERE(shiphead_id=&lt;? value("shiphead_id") ?>) \n             ) AS taborder\n WHERE(order_cust_id=cust_id);\n</sql>\n </querysource>\n <querysource loadFromDb="true" >\n  <name>detail</name>\n  <mqlgroup>shipments</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>155</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>P/O Number:</string>\n  </label>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_orderdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>155</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_ponumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>200</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>10</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipments By Shipment</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>135</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_custphone</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>114</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_custname</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Order #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>185</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>114</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_sonumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>185</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>90</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Order Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipment #</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>135</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer Phone:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>49</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_shipnumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>49</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipment #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>540</x>\n    <y>129</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_tracknum</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>540</x>\n    <y>149</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_freight</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>410</x>\n    <y>129</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Tracking Number:</string>\n  </label>\n  <label>\n   <rect>\n    <x>410</x>\n    <y>149</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Freight:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>140</x>\n    <y>5</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>419</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>140</x>\n    <y>20</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>38</height>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>15</y>\n     <width>480</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_description</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>185</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>linenumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyord</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>105</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_shipdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shiphead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyshipped</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>0</y>\n     <width>140</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>440</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>33</ystart>\n    <xend>745</xend>\n    <yend>33</yend>\n    <weight>0</weight>\n   </line>\n  </detail>\n </section>\n <pgfoot>\n  <height>15</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102452
 
19      SubstituteAvailabilityByRootItem        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Substitue Availability By Root Item</title>\n <name>SubstituteAvailabilityByRootItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse\n  FROM item\n WHERE (item_id=&lt;? value(&quot;item_id&quot;) ?>);</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT warehous_code,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       formatQty(qtyAvailable(sub.itemsite_id)) AS f_qtyonhand,\n       formatQty(CASE WHEN(sub.itemsite_useparams) THEN sub.itemsite_reorderlevel ELSE 0.0 END) AS f_reorderlevel,\n       sub.itemsite_leadtime as leadtime,\n&lt;? if exists(&quot;byDays&quot;) ?>\n       formatQty(qtyAllocated(sub.itemsite_id, &lt;? value(&quot;byDays&quot;) ?>)) AS f_allocated,\n       formatQty(qtyOrdered(sub.itemsite_id, &lt;? value(&quot;byDays&quot;) ?>)) AS f_ordered,\n       formatQty(qtyAvailable(sub.itemsite_id) + qtyOrdered(sub.itemsite_id, &lt;? value(&quot;byDays&quot;) ?>) - qtyAllocated(sub.itemsite_id, &lt;? value(&quot;byDays&quot;) ?>)) as f_avail\n&lt;? elseif exists(&quot;byDate&quot;) ?>\n       formatQty(qtyAllocated(sub.itemsite_id, (&lt;? value(&quot;byDate&quot;) ?> - CURRENT_DATE))) AS f_allocated,\n       formatQty(qtyOrdered(sub.itemsite_id, (&lt;? value(&quot;byDate&quot;) ?> - CURRENT_DATE))) AS f_ordered,\n       formatQty(qtyAvailable(sub.itemsite_id) + qtyOrdered(sub.itemsite_id, (&lt;? value(&quot;byDate&quot;) ?> - CURRENT_DATE)) - qtyAllocated(sub.itemsite_id, (&lt;? value(&quot;byDate&quot;) ?> - CURRENT_DATE))) as f_avail\n&lt;? else ?>\n       formatQty(qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime)) AS f_allocated,\n       formatQty(qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime)) AS f_ordered,\n       formatQty(qtyAvailable(sub.itemsite_id) + qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime) - qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime)) as f_avail\n&lt;? endif ?>\n  FROM item, itemsite AS sub, itemsite AS root, whsinfo, itemsub\n WHERE ((sub.itemsite_item_id=item_id)\n   AND (root.itemsite_item_id=itemsub_parent_item_id)\n   AND (sub.itemsite_item_id=itemsub_sub_item_id)\n   AND (root.itemsite_warehous_id=sub.itemsite_warehous_id)\n   AND (sub.itemsite_warehous_id=warehous_id)\n   AND (root.itemsite_item_id=&lt;? value(&quot;item_id&quot;) ?>)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (root.itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n)\nORDER BY itemsub_rank;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>LT</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Substitute Availability By Root Item</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>385</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Level</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>120</y>\n    <width>385</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Allocated</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>80</y>\n    <width>385</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Available</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>185</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>200</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>On Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>140</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>80</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Number:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>20</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Allocated</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>5</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Level</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>20</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>LT</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Available</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>On Order</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>30</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>15</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyonhand</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>leadtime</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_avail</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_reorderlevel</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>434</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_allocated</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102453
 
420     TaxHistorySummary       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Tax History Summary</title>\n <name>TaxHistorySummary</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("showSales") ?>\n         'Yes'\n       &lt;? else ?>\n         'No'\n       &lt;? endif ?>\n       AS showSales,\n       &lt;? if exists("showPurchases") ?>\n         'Yes'\n       &lt;? else ?>\n         'No'\n       &lt;? endif ?>\n       AS showPurchases,\n       &lt;? value("groupProper") ?> AS group,\n       &lt;? value("groupProper") ?> || ':' AS selectionLit,\n       &lt;? value("selection") ?> AS selection,\n       &lt;? if exists("distDate") ?>\n         text('Distribution Date')\n       &lt;? else ?>\n         text('Document Date')\n       &lt;? endif ?>\n       AS basis,\n       formatDate(&lt;? value("startDate") ?>) AS startdate,\n       formatDate(&lt;? value("endDate") ?>) AS enddate;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>-----------BEGIN SUMMARY----------\nSELECT &lt;? literal("groupBy") ?> AS group, \n  &lt;? literal("groupBy") ?>_descrip AS description, \n  formatMoney(SUM(salesbase)) AS f_salesbase,\n  formatMoney(SUM(freightbase)) AS f_freightbase, \n  CASE WHEN (SUM(freighttax) > 0) THEN true ELSE false END AS freighttax, \n  SUM(salestaxbase) AS salestaxbase,\n  formatMoney(SUM(salestaxbase)) AS f_salestaxbase,\n  formatMoney(SUM(purchasebase)) AS f_purchasebase,\n  SUM(purchasetaxbase) * -1 AS purchasetaxbase, \n  formatMoney(SUM(purchasetaxbase) * -1) AS f_purchasetaxbase, \n  SUM(salestaxbase) + SUM(purchasetaxbase) AS nettaxbase,\n  formatMoney(SUM(salestaxbase) + SUM(purchasetaxbase)) AS f_nettaxbase\nFROM (\n------------END SUMMARY--------------\n&lt;? if exists("showSales") ?>\n------------BEGIN SALES--------------\n-- All sales tax history including memos \nSELECT \n  taxhist_distdate, \n  tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,&lt;? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,&lt;? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,&lt;? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  COALESCE(taxzone_code,&lt;? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n  CASE\n    WHEN (cohist_doctype != 'C') THEN\n      cohist_invcnumber\n    ELSE\n      cohist_ordernumber\n  END AS docnumber, \n  &lt;? value("sales") ?> AS source,\n  CASE\n    WHEN (cohist_doctype='I') THEN\n      &lt;? value("invoice") ?>\n    WHEN (cohist_doctype='C') THEN\n      &lt;? value("creditmemo") ?> \n    WHEN (cohist_doctype='D') THEN\n      &lt;? value("debitmemo") ?>\n    ELSE\n      &lt;? value("other") ?>\n  END AS doctype,\n  item_number, COALESCE(item_descrip1,cohist_misc_descrip) AS description,\n  CASE\n    WHEN (cohist_doctype != 'C') THEN\n      cohist_ordernumber \n  END AS ordernumber, cohist_invcdate AS docdate,\n  cohist_billtoname AS name, \n  cohist_qtyshipped AS qty, \n  cohist_unitprice AS unitprice, (cohist_qtyshipped * cohist_unitprice) AS amount,\n  CASE\n    WHEN (cohist_misc_type IS NULL OR cohist_misc_type IN ('M','F')) THEN\n      currToBase(cohist_curr_id, cohist_qtyshipped * cohist_unitprice, cohist_invcdate) \n    ELSE 0\n  END AS salesbase,\n  CASE\n    WHEN (cohist_misc_type = 'F') THEN\n      currToBase(cohist_curr_id, cohist_qtyshipped * cohist_unitprice, cohist_invcdate) \n    ELSE 0\n  END AS freightbase,\n  CASE\n    WHEN (cohist_misc_type = 'F') THEN\n      taxhist_tax / taxhist_curr_rate\n    ELSE 0\n  END AS freighttax,\n  0 AS purchasebase,\n  taxhist_tax AS taxlocal,\n  taxhist_tax / taxhist_curr_rate AS taxbase,\n  taxhist_tax / taxhist_curr_rate AS salestaxbase,\n  0 AS purchasetaxbase\nFROM cohisttax\n JOIN cohist ON (cohist_id=taxhist_parent_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (cohist_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (cohist_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n&lt;? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? else ?>\nWHERE ((taxhist_docdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("tax_id") ?>\n AND (taxhist_tax_id=&lt;? value("tax_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=&lt;? value("taxtype_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxclass_id") ?>\n AND (taxclass_id=&lt;? value("taxclass_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxauth_id") ?>\n AND (taxauth_id=&lt;? value("taxauth_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxzone_id") ?>\n AND (taxzone_id=&lt;? value("taxzone_id") ?>)\n&lt;? endif ?>\n)\n&lt;? endif ?>\n--------------END SALES--------------------\n&lt;? if exists("showPurchases") ?>\n&lt;? if exists("showSales") ?>\n-- Union because sales and purchase shown together\nUNION ALL\n&lt;? endif ?>\n&lt;? endif ?>\n------------BEGIN PURCHASE----------------\n&lt;? if exists("showPurchases") ?>\n-- A/P Memo history\nSELECT \n  taxhist_distdate, \n  tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,&lt;? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,&lt;? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,&lt;? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  &lt;? value("none") ?> AS taxzone,'' AS taxzone_descrip, curr_abbr, \n  apopen_docnumber AS docnumber, \n  &lt;? value("purchase") ?> AS source,\n  CASE\n    WHEN (apopen_doctype='C') THEN\n      &lt;? value("creditmemo") ?> \n    WHEN (apopen_doctype='D') THEN\n      &lt;? value("debitmemo") ?>\n    ELSE\n      &lt;? value("other") ?>\n  END AS doctype,\n  '' AS item_number, apopen_notes AS description,\n  apopen_ponumber AS ordernumber, apopen_docdate AS docdate,\n  vend_name AS name, \n  1 AS qty, \n  apopen_amount AS unitprice, apopen_amount AS amount,\n  0 AS salesbase,\n  0 AS freightbase,\n  0 AS freighttax,\n  apopen_amount / apopen_curr_rate AS purchasebase,\n  taxhist_tax AS taxlocal,\n  taxhist_tax / taxhist_curr_rate AS taxbase,\n  0 AS salestaxbase,\n  taxhist_tax / taxhist_curr_rate AS purchasetaxbase\nFROM apopentax\n JOIN apopen ON (apopen_id=taxhist_parent_id)\n JOIN vendinfo ON (apopen_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n&lt;? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? else ?>\nWHERE ((taxhist_docdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("tax_id") ?>\n AND (taxhist_tax_id=&lt;? value("tax_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=&lt;? value("taxtype_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxclass_id") ?>\n AND (taxclass_id=&lt;? value("taxclass_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxauth_id") ?>\n AND (taxauth_id=&lt;? value("taxauth_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxzone_id") ?>\n AND (false)\n&lt;? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nUNION ALL\n--Voucher Header History\nSELECT \n  taxhist_distdate, \n  tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,&lt;? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,&lt;? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,&lt;? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  COALESCE(taxzone_code,&lt;? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n  vohead_number AS docnumber, \n  &lt;? value("purchase") ?> AS source,\n  &lt;? value("voucher") ?>  AS doctype,\n  '', vohead_notes AS description,\n  pohead_number AS ordernumber, vohead_docdate AS docdate,\n  vend_name AS name, \n  1 AS qty, \n  0 AS unitprice, 0 AS amount,\n  0 AS salesbase,\n  0 AS freightbase,\n  0 AS freighttax,\n  0 AS purchasebase,\n  taxhist_tax AS taxlocal,\n  taxhist_tax / taxhist_curr_rate AS taxbase,\n  0 AS salestaxbase,\n  taxhist_tax / taxhist_curr_rate AS purchasetaxbase\nFROM voheadtax\n JOIN vohead ON (vohead_id=taxhist_parent_id)\n LEFT OUTER JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n&lt;? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? else ?>\nWHERE ((taxhist_docdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("tax_id") ?>\n AND (taxhist_tax_id=&lt;? value("tax_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=&lt;? value("taxtype_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxclass_id") ?>\n AND (_taxclass_id=&lt;? value("taxclass_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxauth_id") ?>\n AND (taxauth_id=&lt;? value("taxauth_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxzone_id") ?>\n AND (taxzone_id=&lt;? value("taxzone_id") ?>)\n&lt;? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nUNION ALL\n--Voucher Line Item\nSELECT \n  taxhist_distdate, \n  tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,&lt;? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,&lt;? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,&lt;? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  COALESCE(taxzone_code,&lt;? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n  vohead_number AS docnumber, \n  &lt;? value("purchase") ?> AS source,\n  &lt;? value("voucher") ?>  AS doctype,\n  COALESCE(item_number,expcat_code), COALESCE(item_descrip1,expcat_descrip) AS description,\n  pohead_number AS ordernumber, vohead_docdate AS docdate,\n  vend_name AS name, \n  voitem_qty AS qty, \n  COALESCE(SUM(vodist_amount),0)/voitem_qty AS unitprice, COALESCE(SUM(vodist_amount),0) AS amount,\n  0 AS salesbase,\n  0 AS freightbase,\n  0 AS freighttax,\n  currToBase(vohead_curr_id, COALESCE(SUM(vodist_amount),0), vohead_distdate)  AS purchasebase,\n  taxhist_tax AS taxlocal,\n  taxhist_tax / taxhist_curr_rate AS taxbase,\n  0 AS salestaxbase,\n  taxhist_tax / taxhist_curr_rate AS purchasetaxbase\nFROM voitemtax\n JOIN voitem ON (voitem_id=taxhist_parent_id)\n JOIN vohead ON (vohead_id=voitem_vohead_id)\n JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN poitem ON (voitem_poitem_id=poitem_id)\n JOIN vodist ON ((vodist_poitem_id=poitem_id)\n            AND  (vodist_vohead_id=vohead_id))\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN expcat ON (expcat_id=poitem_expcat_id)\n&lt;? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? else ?>\nWHERE ((taxhist_docdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("tax_id") ?>\n AND (taxhist_tax_id=&lt;? value("tax_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=&lt;? value("taxtype_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxclass_id") ?>\n AND (taxclass_id=&lt;? value("taxclass_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxauth_id") ?>\n AND (taxauth_id=&lt;? value("taxauth_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxzone_id") ?>\n AND (taxzone_id=&lt;? value("taxzone_id") ?>)\n&lt;? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nGROUP BY taxhist_id,taxhist_distdate,tax_code,tax_descrip,\n  taxtype_name,taxtype_descrip,taxclass_code,taxclass_descrip,\n  taxauth_code,taxauth_descrip,taxzone,taxzone_descrip,curr_abbr,\n  vohead_number,pohead_number,item_number,item_descrip1,\n  vohead_curr_id,vohead_distdate,vohead_docdate,vend_name,\n  expcat_code,expcat_descrip,taxhist_tax,taxhist_curr_rate,\n  voitem_qty\n&lt;? endif ?>\n-------------END PURCHASE--------------\nORDER BY docdate DESC, docnumber DESC\n\n) AS data\nGROUP BY &lt;? literal("groupBy") ?>, &lt;? literal("groupBy") ?>_descrip\nORDER BY &lt;? literal("groupBy") ?>\n\n</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Tax History Summary</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>199</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Freight</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>199</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Purchases</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>141</x>\n    <y>138</y>\n    <width>230</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>selection</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>199</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sales</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>199</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sales Tax</string>\n  </label>\n  <field>\n   <rect>\n    <x>460.577</x>\n    <y>137.571</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>199</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Taxed</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>199</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Purchase Tax</string>\n  </label>\n  <field>\n   <rect>\n    <x>460.577</x>\n    <y>116.571</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>350.577</x>\n    <y>137.571</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>350.577</x>\n    <y>116.571</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>350.577</x>\n    <y>95.9618</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Basis:</string>\n  </label>\n  <field>\n   <rect>\n    <x>461</x>\n    <y>96</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>basis</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>28.5</x>\n    <y>97</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purchases:</string>\n  </label>\n  <field>\n   <rect>\n    <x>141</x>\n    <y>117</y>\n    <width>230</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>group</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>65.6</x>\n    <y>138</y>\n    <width>65.9</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>selectionLit</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>4</x>\n    <y>199</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>group</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>652</x>\n    <y>199</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Net Tax</string>\n  </label>\n  <label>\n   <rect>\n    <x>277</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Freight</string>\n  </label>\n  <field>\n   <rect>\n    <x>141</x>\n    <y>97</y>\n    <width>230</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>showPurchases</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>28.5</x>\n    <y>76</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sales:</string>\n  </label>\n  <field>\n   <rect>\n    <x>141</x>\n    <y>76</y>\n    <width>230</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>showSales</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>28.5</x>\n    <y>117</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Freight</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Taxed</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sales Tax</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Purchase Tax</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>5</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Purchase</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sales</string>\n  </label>\n  <field>\n   <rect>\n    <x>0</x>\n    <y>2</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>group</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>649</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Net Tax</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>19</height>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_freightbase</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_salesbase</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>550</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_purchasetaxbase</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>450</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_purchasebase</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>group</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>350</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_salestaxbase</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>freighttax</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>650</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_nettaxbase</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>20</height>\n  <field>\n   <rect>\n    <x>650</x>\n    <y>3</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>nettaxbase</column>\n   </data>\n   <tracktotal builtin="true" >money</tracktotal>\n  </field>\n  <field>\n   <rect>\n    <x>350</x>\n    <y>3</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>salestaxbase</column>\n   </data>\n   <tracktotal builtin="true" >qty</tracktotal>\n  </field>\n  <field>\n   <rect>\n    <x>551</x>\n    <y>3</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>purchasetaxbase</column>\n   </data>\n   <tracktotal builtin="true" >money</tracktotal>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>3</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Total:</string>\n  </label>\n </rptfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102454
 
159     UninvoicedReceipts      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Uninvoiced Receipts</title>\n <name>UninvoicedReceipts</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("warehous_id") ?>&#xd;\n         ( SELECT warehous_code&#xd;\n             FROM whsinfo&#xd;\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )&#xd;\n       &lt;? else ?>&#xd;\n         text('All Sites')&#xd;\n       &lt;? endif ?>&#xd;\n       AS warehouse,&#xd;\n       &lt;? if exists("agentUsername") ?>&#xd;\n       TEXT(&lt;? value("agentUsername" ?>)&#xd;\n       &lt;? else ?>&#xd;\n       TEXT('All Agents')&#xd;\n       &lt;? endif ?>&#xd;\n       AS agentUsername;&#xd;\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT recv_id,\n       formatDate(recv_date) as f_date,\n       recv_trans_usr_name as f_user,\n       recv_order_number AS f_ponumber, poitem_linenumber,\n       vend_name, \n       COALESCE(item_number, ('Misc. - ' || recv_vend_item_number)) AS item_number,\n       formatQty(recv_qty) as f_qty,\n       'Receipt' AS f_type,\n       recv_value AS value,\n       formatMoney(recv_value) AS f_value\n  FROM recv\n    LEFT OUTER JOIN itemsite ON (recv_itemsite_id=itemsite_id)\n    LEFT OUTER JOIN item ON (itemsite_item_id=item_id),\n    poitem, vendinfo\n WHERE ((recv_orderitem_id=poitem_id)\n   AND  (recv_order_type='PO')\n   AND  (recv_vend_id=vend_id)\n   AND  (recv_posted)\n   AND  (recv_vohead_id IS NULL)\n   AND  (NOT recv_invoiced)\n&lt;? if exists("warehous_id") ?>\n   AND  (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("agentUsername") ?>\n   AND  (recv_agent_username=&lt;? value("agentUsername") ?>)\n&lt;? endif ?>\n)\nUNION\nSELECT poreject_id,\n       formatDate(poreject_date) as f_date,\n       poreject_trans_username as f_user,\n       poreject_ponumber AS f_ponumber, poitem_linenumber,\n       vend_name, \n       COALESCE(item_number, ('Misc. - ' || poreject_vend_item_number)) AS item_number,\n       formatQty(poreject_qty) as f_qty,\n       'Return' AS f_type,\n       poreject_value *-1 AS value,\n       formatMoney(poreject_value*-1) AS f_value\n  FROM poreject\n    LEFT OUTER JOIN itemsite ON (poreject_itemsite_id=itemsite_id)\n    LEFT OUTER JOIN item ON (itemsite_item_id=item_id),\n    poitem, vendinfo\n WHERE ((poreject_poitem_id=poitem_id)\n--   AND  (poreject_itemsite_id=itemsite_id)\n--   AND  (itemsite_item_id=item_id)\n   AND  (poreject_vend_id=vend_id)\n   AND  (poreject_posted)\n   AND  (NOT poreject_invoiced)\n&lt;? if exists("warehous_id") ?>\n   AND  (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("agentUsername") ?>\n   AND  (poreject_agent_username=&lt;? value("agentUsername") ?>)\n&lt;? endif ?>\n)\nORDER BY f_ponumber, poitem_linenumber;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>200</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <field>\n   <rect>\n    <x>145</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>By</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>200</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>110</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purch. Agent:</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Value</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>200</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Uninvoiced</string>\n  </label>\n  <label>\n   <rect>\n    <x>290</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>10</y>\n    <width>509</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Uninvoiced Receipts and Returns</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>90</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>145</x>\n    <y>110</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>agentUsername</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>29</height>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>5</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>5</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>By</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>5</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Uninvoiced</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Value</string>\n  </label>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_user</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>170</x>\n     <y>0</y>\n     <width>65</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>285</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_linenumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>590</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_type</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_value</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>104</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>37</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Total:</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>value</column>\n   </data>\n   <tracktotal builtin="true" >qty</tracktotal>\n  </field>\n </rptfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102455
 
194     WOHistoryByClassCode    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Work Order History By Class Code</title>\n <name>WOHistoryByClassCode</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>Detail</name>\n  <mqlgroup>workOrderHistory</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("classcode_id") ?>\n         ( SELECT (classcode_code||'-'||classcode_descrip)\n             FROM classcode\n            WHERE (classcode_id=&lt;? value("classcode_id") ?>) )\n       &lt;? elseif exists("classcode_pattern") ?>\n         text(&lt;? value("classcode_pattern") ?>)\n       &lt;? else ?>\n         text('All Class Codes')\n       &lt;? endif ?>\n       AS classcode,\n       &lt;? if exists("showOnlyTopLevel") ?>\n         text('Only Show Top level Work Orders')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS lbl_toplevel,\n       &lt;? if exists("showCosts") ?>\n         text('Cost')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS lbl_cost\n;</sql>\n </querysource>\n <rpthead>\n  <height>172</height>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>150</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>509</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>105</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>165</ystart>\n   <xend>740</xend>\n   <yend>165</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Class Code(s):</string>\n  </label>\n  <label>\n   <rect>\n    <x>125</x>\n    <y>150</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>10</y>\n    <width>484</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Work Order History By Class Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>150</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>85</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>classcode</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>229</x>\n    <y>150</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>365</x>\n    <y>85</y>\n    <width>355</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_toplevel</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>105</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>150</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>151</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_cost</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>32</height>\n  <label>\n   <rect>\n    <x>125</x>\n    <y>10</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>509</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>10</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>10</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>25</ystart>\n   <xend>740</xend>\n   <yend>25</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>229</x>\n    <y>10</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>10</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O #</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>8</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_cost</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>Detail</query>\n   </key>\n   <height>52</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>wonumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>509</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_wo_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>45</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>wo_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>125</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>229</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>125</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_wo_postedvalue</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_wo_qtyord</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>125</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>350</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_wo_qtyrcv</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>740</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_wo_startdate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>113</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102456
 
107     AccountNumberMasterList \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Chart of Accounts Master List</title>\n <name>AccountNumberMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>select accnt_company,\n       accnt_profit,\n       accnt_number,\n       accnt_sub,\n       accnt_descrip,\n       accnt_comments,\n       CASE WHEN(accnt_type='A') THEN text('Asset')\n            WHEN(accnt_type='L') THEN text('Liability')\n            WHEN(accnt_type='E') THEN text('Expense')\n            WHEN(accnt_type='R') THEN text('Revenue')\n            WHEN(accnt_type='Q') THEN text('Equity')\n            ELSE text(accnt_type)\n       END AS f_type\n  from accnt\nORDER BY accnt_number, accnt_sub, accnt_profit;</sql>\n </querysource>\n <rpthead>\n  <height>77</height>\n  <label>\n   <rect>\n    <x>115</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Profit Center</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sub</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Chart of Accounts Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Company</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account #</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>55</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>115</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Profit Center</string>\n  </label>\n  <line>\n   <xstart>10</xstart>\n   <ystart>15</ystart>\n   <xend>750</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sub</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account #</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Company</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>325</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>accnt_sub</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>220</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>accnt_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>115</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>accnt_profit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>accnt_company</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>494</x>\n     <y>0</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>accnt_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_type</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102457
 
237     AccountingPeriodsMasterList     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Accounting Periods Master List</title>\n <name>AccountingPeriodsMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT period_id,\n       formatDate(period_start) AS f_start,\n       formatDate(period_end) AS f_end,\n       formatBoolYN(period_closed) AS f_closed,\n       formatBoolYN(period_freeze) AS f_frozen\n  FROM period\nORDER BY period_start;</sql>\n </querysource>\n <rpthead>\n  <height>77</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Start</string>\n  </label>\n  <label>\n   <rect>\n    <x>114</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>End</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>420</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Closed</string>\n  </label>\n  <label>\n   <rect>\n    <x>515</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Frozen</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Accounting Periods Master List</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>22</height>\n  <label>\n   <rect>\n    <x>114</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>End</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>515</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Frozen</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Start</string>\n  </label>\n  <label>\n   <rect>\n    <x>420</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Closed</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>420</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_closed</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>114</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_end</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>515</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_frozen</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_start</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102458
 
283     APAging \N      <!DOCTYPE openRPTDef>\n<report>\n <title>AP 30 60 90 Aging</title>\n <name>APAging</name>\n <description>Enhanced AP Aging - Uses 30-60-90 columns - User provides Relative Date - all amounts in base currency based on Document Date.</description>\n <parameter default="" active="true" listtype="static" type="string" name="relDate" >\n  <description>Date Relative to Today</description>\n </parameter>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n\tapaging_docdate,\n\tapaging_duedate,\n\tapaging_ponumber,\n\tapaging_docnumber,\n        apaging_invcnumber,\n\tapaging_doctype,\n\tapaging_vend_id,\n\tapaging_vend_number,\n\tapaging_vend_name,\n\tapaging_vend_vendtype_id,\n\tapaging_vendtype_code,\n\tapaging_terms_descrip,\n\tformatMoney(apaging_apopen_amount) AS apaging_apopen_amount,\n\tapaging_cur_val,   formatMoney(apaging_cur_val)    AS apaging_cur_amt,\n\tapaging_thirty_val,formatMoney(apaging_thirty_val) AS apaging_thirty_amt,\n\tapaging_sixty_val, formatMoney(apaging_sixty_val)  AS apaging_sixty_amt,\n\tapaging_ninety_val,formatMoney(apaging_ninety_val) AS apaging_ninety_amt,\n\tapaging_plus_val,  formatMoney(apaging_plus_val)   AS apaging_plus_amt,\n\tapaging_total_val, formatMoney(apaging_total_val)  AS apaging_total_amt,\n\tapaging_disc_val,  formatMoney(apaging_disc_val)   AS apaging_disc_amt,\n\tapaging_discdate,\n\tapaging_discdays,\n\tapaging_discprcnt\nFROM apaging(&lt;? value("relDate") ?>, &lt;? value("useDocDate") ?>)\n&lt;? if exists("vend_id") ?>\n   WHERE (apaging_vend_id=&lt;? value("vend_id") ?>)\n&lt;? elseif exists("vendtype_id") ?>\n   WHERE (apaging_vend_vendtype_id=&lt;? value("vendtype_id") ?>)\n&lt;? elseif exists("vendtype_pattern") ?>\n   WHERE (apaging_vendtype_code ~ &lt;? value("vendtype_pattern") ?>)\n&lt;? endif ?>;</sql>\n </querysource>\n <rpthead>\n  <height>77</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>365</width>\n    <height>31</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Accounts Payable Aging Report</string>\n  </label>\n  <field>\n   <rect>\n    <x>45</x>\n    <y>40</y>\n    <width>110</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>relDate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>40</y>\n    <width>40</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>As of:</string>\n  </label>\n </rpthead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>Vendor</name>\n   <column>apaging_vend_number</column>\n   <pagebreak when="after foot" />\n   <head>\n    <height>113</height>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>70</y>\n      <width>15</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>y</string>\n    </label>\n    <label>\n     <rect>\n      <x>20</x>\n      <y>90</y>\n      <width>85</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Vendor Inv #</string>\n    </label>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>60</y>\n      <width>15</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>T</string>\n    </label>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>10</y>\n      <width>103</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Vendor Name:</string>\n    </label>\n    <label>\n     <rect>\n      <x>867</x>\n      <y>80</y>\n      <width>40</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Discount</string>\n    </label>\n    <label>\n     <rect>\n      <x>620</x>\n      <y>90</y>\n      <width>75</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <string>31+60 Days</string>\n    </label>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>25</y>\n      <width>103</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Vendor Number:</string>\n    </label>\n    <label>\n     <rect>\n      <x>942</x>\n      <y>90</y>\n      <width>45</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Discount</string>\n    </label>\n    <label>\n     <rect>\n      <x>867</x>\n      <y>90</y>\n      <width>40</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Date</string>\n    </label>\n    <field>\n     <rect>\n      <x>125</x>\n      <y>25</y>\n      <width>220</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <data>\n      <query>detail</query>\n      <column>apaging_vend_number</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>360</x>\n      <y>80</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Original</string>\n    </label>\n    <label>\n     <rect>\n      <x>360</x>\n      <y>90</y>\n      <width>80</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Invoice Amount</string>\n    </label>\n    <label>\n     <rect>\n      <x>775</x>\n      <y>90</y>\n      <width>75</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <string>90+ Days</string>\n    </label>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>90</y>\n      <width>15</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>e</string>\n    </label>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>80</y>\n      <width>15</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>p</string>\n    </label>\n    <label>\n     <rect>\n      <x>530</x>\n      <y>90</y>\n      <width>75</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <string>0+30 Days</string>\n    </label>\n    <line>\n     <xstart>0</xstart>\n     <ystart>105</ystart>\n     <xend>1000</xend>\n     <yend>105</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>125</x>\n      <y>40</y>\n      <width>220</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <data>\n      <query>detail</query>\n      <column>apaging_terms_descrip</column>\n     </data>\n    </field>\n    <line>\n     <xstart>0</xstart>\n     <ystart>5</ystart>\n     <xend>1000</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>270</x>\n      <y>90</y>\n      <width>60</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Due Date</string>\n    </label>\n    <label>\n     <rect>\n      <x>110</x>\n      <y>90</y>\n      <width>85</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Voucher #</string>\n    </label>\n    <label>\n     <rect>\n      <x>705</x>\n      <y>90</y>\n      <width>75</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <string>61+90 Days</string>\n    </label>\n    <label>\n     <rect>\n      <x>200</x>\n      <y>90</y>\n      <width>60</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Invoice Date</string>\n    </label>\n    <field>\n     <rect>\n      <x>125</x>\n      <y>10</y>\n      <width>220</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <data>\n      <query>detail</query>\n      <column>apaging_vend_name</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>450</x>\n      <y>90</y>\n      <width>75</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <string>Current</string>\n    </label>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>40</y>\n      <width>103</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Terms:</string>\n    </label>\n   </head>\n   <foot>\n    <height>96</height>\n    <label>\n     <rect>\n      <x>450</x>\n      <y>65</y>\n      <width>475</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>All amounts are in base currency as of the document date.</string>\n    </label>\n    <field>\n     <rect>\n      <x>0</x>\n      <y>50</y>\n      <width>220</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <data>\n      <query>detail</query>\n      <column>vend_name</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>530</x>\n      <y>5</y>\n      <width>75</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <data>\n      <query>detail</query>\n      <column>apaging_thirty_val</column>\n     </data>\n     <tracktotal subtotal="true" builtin="true" >qty</tracktotal>\n    </field>\n    <label>\n     <rect>\n      <x>450</x>\n      <y>55</y>\n      <width>55</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Note:</string>\n    </label>\n    <line>\n     <xstart>237</xstart>\n     <ystart>32</ystart>\n     <xend>237</xend>\n     <yend>32</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>450</x>\n      <y>5</y>\n      <width>75</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <data>\n      <query>detail</query>\n      <column>apaging_cur_val</column>\n     </data>\n     <tracktotal subtotal="true" builtin="true" >qty</tracktotal>\n    </field>\n    <field>\n     <rect>\n      <x>220</x>\n      <y>50</y>\n      <width>75</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <data>\n      <query>detail</query>\n      <column>apaging_total_val</column>\n     </data>\n     <tracktotal subtotal="true" builtin="true" >qty</tracktotal>\n    </field>\n    <field>\n     <rect>\n      <x>938</x>\n      <y>5</y>\n      <width>55</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <data>\n      <query>detail</query>\n      <column>apaging_disc_val</column>\n     </data>\n     <tracktotal subtotal="true" builtin="true" >qty</tracktotal>\n    </field>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>35</y>\n      <width>135</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Total For Vendor</string>\n    </label>\n    <field>\n     <rect>\n      <x>620</x>\n      <y>5</y>\n      <width>70</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <data>\n      <query>detail</query>\n      <column>apaging_sixty_val</column>\n     </data>\n     <tracktotal subtotal="true" builtin="true" >qty</tracktotal>\n    </field>\n    <field>\n     <rect>\n      <x>705</x>\n      <y>5</y>\n      <width>70</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <data>\n      <query>detail</query>\n      <column>apaging_ninety_val</column>\n     </data>\n     <tracktotal subtotal="true" builtin="true" >qty</tracktotal>\n    </field>\n    <line>\n     <xstart>0</xstart>\n     <ystart>0</ystart>\n     <xend>1000</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>780</x>\n      <y>5</y>\n      <width>75</width>\n      <height>12</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <data>\n      <query>detail</query>\n      <column>apaging_plus_val</column>\n     </data>\n     <tracktotal subtotal="true" builtin="true" >qty</tracktotal>\n    </field>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>860</x>\n     <y>0</y>\n     <width>70</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>apaging_discdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>939</x>\n     <y>0</y>\n     <width>55</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>apaging_disc_amt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>85</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>apaging_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>20</x>\n     <y>0</y>\n     <width>80</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>apaging_invcnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>15</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>apaging_doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>75</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>apaging_thirty_amt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>0</y>\n     <width>80</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>apaging_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>450</x>\n     <y>0</y>\n     <width>75</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>apaging_cur_amt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>795</x>\n     <y>0</y>\n     <width>55</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>apaging_plus_amt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>355</x>\n     <y>0</y>\n     <width>80</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>apaging_apopen_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>620</x>\n     <y>0</y>\n     <width>70</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>apaging_sixty_amt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>705</x>\n     <y>0</y>\n     <width>70</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>apaging_ninety_amt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>85</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>apaging_docdate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <lastpage/>\n  <height>102</height>\n  <field>\n   <rect>\n    <x>220</x>\n    <y>35</y>\n    <width>75</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>apaging_total_val</column>\n   </data>\n   <tracktotal builtin="true" >qty</tracktotal>\n  </field>\n  <field>\n   <rect>\n    <x>620</x>\n    <y>5</y>\n    <width>70</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>apaging_sixty_val</column>\n   </data>\n   <tracktotal builtin="true" >qty</tracktotal>\n  </field>\n  <field>\n   <rect>\n    <x>530</x>\n    <y>5</y>\n    <width>75</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>apaging_thirty_val</column>\n   </data>\n   <tracktotal builtin="true" >qty</tracktotal>\n  </field>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>45</y>\n    <width>475</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>All amounts are in base currency as of the document date.</string>\n  </label>\n  <field>\n   <rect>\n    <x>450</x>\n    <y>5</y>\n    <width>75</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>apaging_cur_val</column>\n   </data>\n   <tracktotal builtin="true" >qty</tracktotal>\n  </field>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>35</y>\n    <width>55</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Note:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>35</y>\n    <width>170</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Total For All Vendors</string>\n  </label>\n  <field>\n   <rect>\n    <x>710</x>\n    <y>5</y>\n    <width>70</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>apaging_ninety_val</column>\n   </data>\n   <tracktotal builtin="true" >qty</tracktotal>\n  </field>\n  <field>\n   <rect>\n    <x>780</x>\n    <y>5</y>\n    <width>75</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>apaging_plus_val</column>\n   </data>\n   <tracktotal builtin="true" >qty</tracktotal>\n  </field>\n  <label>\n   <rect>\n    <x>335</x>\n    <y>5</y>\n    <width>95</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Report Totals:</string>\n  </label>\n  <field>\n   <rect>\n    <x>942</x>\n    <y>5</y>\n    <width>55</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>apaging_disc_val</column>\n   </data>\n   <tracktotal builtin="true" >qty</tracktotal>\n  </field>\n  <label>\n   <rect>\n    <x>457</x>\n    <y>80</y>\n    <width>35</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Page: </string>\n  </label>\n  <field>\n   <rect>\n    <x>515</x>\n    <y>80</y>\n    <width>42</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <line>\n   <xstart>1</xstart>\n   <ystart>2</ystart>\n   <xend>1000</xend>\n   <yend>2</yend>\n   <weight>2</weight>\n  </line>\n </pgfoot>\n <pgfoot>\n  <height>47</height>\n  <field>\n   <rect>\n    <x>515</x>\n    <y>25</y>\n    <width>42</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>457</x>\n    <y>25</y>\n    <width>35</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Page: </string>\n  </label>\n </pgfoot>\n</report>\n        Enhanced AP Aging - Uses 30-60-90 columns - User provides Relative Date - all amounts in base currency based on Document Date.  0       2014-10-06 19:47:03.678943
102459
 
412     APApplications  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>A/P Applications</title>\n <name>APApplications</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate")   ?>, 'Latest')   AS enddate,\n       &lt;? if exists("showChecks") ?>\n         &lt;? if exists("showCreditMemos") ?>\n           'Show Checks and Credit Memos'\n         &lt;? else ?>\n           'Show Checks'\n         &lt;? endif ?>\n       &lt;? elseif exists("showCreditMemos") ?>\n          'Show Credit Memos'\n       &lt;? else ?>\n         ''\n       &lt;? endif ?> AS f_show,\n       &lt;? if exists("vend_id") ?>\n         'Vendor:' AS f_label, vend_number AS f_value\n       &lt;? elseif exists("vendtype_id") ?>\n         'Vendor Type:' AS f_label, vendtype_code AS f_value\n       &lt;? elseif exists("vendtype_pattern") ?>\n         'Vendor Type matches:' AS f_label,\n       &lt;? value("vendtype_pattern") ?> AS f_value\n       &lt;? else ?>\n         'Vendors:' AS f_label, 'All' AS f_value\n       &lt;? endif ?>\n&lt;? if exists("vend_id") ?>\n  FROM vendinfo\n  WHERE vend_id=&lt;? value("vend_id") ?>\n&lt;? elseif exists("vendtype_id") ?>\n  FROM vendtype\n  WHERE vendtype_id=&lt;? value("vendtype_id")\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>apApplications</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>146</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>140</ystart>\n   <xend>745</xend>\n   <yend>140</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>63</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>125</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>A/P Applications</string>\n  </label>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>83</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>462</x>\n    <y>63</y>\n    <width>100</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>291</x>\n    <y>125</y>\n    <width>159</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Source Document</string>\n  </label>\n  <label>\n   <rect>\n    <x>700</x>\n    <y>125</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>63</y>\n    <width>139</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_label</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>159</x>\n    <y>83</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_show</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>630</x>\n    <y>125</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>125</y>\n    <width>141</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Apply To Document</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>125</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>125</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor #</string>\n  </label>\n  <field>\n   <rect>\n    <x>157</x>\n    <y>63</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_value</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>462</x>\n    <y>83</y>\n    <width>100</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor #</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>462</x>\n    <y>5</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Apply To Document</string>\n  </label>\n  <label>\n   <rect>\n    <x>635</x>\n    <y>5</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>291</x>\n    <y>5</y>\n    <width>164</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Source Document</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>705</x>\n    <y>5</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>620</x>\n     <y>0</y>\n     <width>65</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>81</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_postdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>110</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>apapply_target_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>700</x>\n     <y>0</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>currAbbr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>340</x>\n     <y>0</y>\n     <width>110</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>apapply_source_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>90</x>\n     <y>0</y>\n     <width>115</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>291</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>apapply_source_doctype_qtdisplayrole</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>460</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>apapply_target_doctype_qtdisplayrole</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>104</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>base_applied</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>0</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Total Applications (base):</string>\n  </label>\n </rptfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102460
 
205     APAssignmentsMasterList \N      <!DOCTYPE openRPTDef>\n<report>\n <title>A/P Account Assignments Master List</title>\n <name>APAssignmentsMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT CASE WHEN (apaccnt_vendtype_id=-1) THEN apaccnt_vendtype\n            ELSE (SELECT vendtype_code FROM vendtype WHERE (vendtype_id=apaccnt_vendtype_id))\n       END AS vendtypecode,\n       formatGLAccount(apaccnt_ap_accnt_id) AS apaccnt,\n       formatGLAccount(apaccnt_prepaid_accnt_id) AS prepaidaccnt,\n       formatGLAccount(apaccnt_discount_accnt_id) AS discountaccnt\nFROM apaccnt\nORDER BY vendtypecode;</sql>\n </querysource>\n <rpthead>\n  <height>77</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>10</y>\n    <width>495</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>A/P Account Assignments Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>120</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>A/P Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>56</y>\n    <width>145</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Discount Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>56</y>\n    <width>135</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Prepaid Account</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>22</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>120</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>A/P Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>-2</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Prepaid Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>-2</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Discount Account</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vendtypecode</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>120</x>\n     <y>0</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>apaccnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>-1</y>\n     <width>190</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prepaidaccnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>-1</y>\n     <width>195</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>discountaccnt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102461
 
188     APCheck \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Sample Check Format - 3 Part - MC - Remit</title>\n <name>APCheck</name>\n <description>Sample Check Format - 3 Part - MC - Uses primary Vendor or address with names: REMIT, Remit, or remit if one exists.</description>\n <size>Letter</size>\n <portrait/>\n <topmargin>0</topmargin>\n <bottommargin>0</bottommargin>\n <rightmargin>0</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>Head</name>\n  <sql>SELECT\ncheckhead_id, checkhead_number, checkhead_for AS memo,\nformatDate(checkhead_checkdate) AS f_checkdate,\nformatMoney(checkhead_amount) AS f_amount,\nINITCAP(spellAmount(checkhead_amount, curr_id)) AS f_words,\nCASE WHEN(checkhead_void) THEN TEXT('V O I D')\n     ELSE TEXT('')\nEND AS f_void,\nCASE WHEN checkhead_recip_type = 'C' THEN (SELECT cust_number\n                                           FROM custinfo\n                                           WHERE (cust_id=checkhead_recip_id))\n     WHEN checkhead_recip_type = 'T' THEN (SELECT taxauth_code\n                                           FROM taxauth\n                                           WHERE (taxauth_id=checkhead_recip_id))\n     WHEN checkhead_recip_type = 'V' THEN (SELECT vend_number\n                                           FROM vendinfo\n                                           WHERE (vend_id=checkhead_recip_id))\n     ELSE 'Unknown Recipient Type'\nEND AS recip_number,\nformatAddr(CASE WHEN checkhead_recip_type = 'C' THEN\n                                         (SELECT cntct_addr_id\n                                          FROM cntct, custinfo\n                                          WHERE ((cust_cntct_id=cntct_id)\n                                            AND  (cust_id=checkhead_recip_id)))\n                WHEN checkhead_recip_type = 'T' THEN \n                                         (SELECT taxauth_addr_id\n                                          FROM taxauth\n                                          WHERE (taxauth_id=checkhead_recip_id))\n                WHEN checkhead_recip_type = 'V' THEN\n                        COALESCE((SELECT vendaddr_addr_id\n                                  FROM vendaddrinfo\n                                  WHERE ((UPPER(vendaddr_code)='REMIT')\n                                    AND  (vendaddr_vend_id=checkhead_recip_id))),\n                                 (SELECT vend_addr_id\n                                  FROM vendinfo\n                                  WHERE (vend_id=checkhead_recip_id)))\n           END) AS check_address,\nCASE WHEN checkhead_recip_type = 'C' THEN (SELECT cust_name\n                                           FROM custinfo\n                                           WHERE cust_id=checkhead_recip_id)\n     WHEN checkhead_recip_type = 'T' THEN (SELECT taxauth_name\n                                           FROM taxauth\n                                           WHERE taxauth_id=checkhead_recip_id)\n     WHEN checkhead_recip_type = 'V' THEN\n                         COALESCE((SELECT vendaddr_name\n                                   FROM vendaddrinfo\n                                   WHERE ((UPPER(vendaddr_code)='REMIT')\n                                     AND  (vendaddr_vend_id=checkhead_recip_id))),\n                                  (SELECT vend_name\n                                   FROM vendinfo\n                                   WHERE (vend_id=checkhead_recip_id)))\nEND AS recip_name, \ncurr_symbol, curr_abbr, curr_name\nFROM checkhead, curr_symbol\nWHERE ((checkhead_curr_id = curr_id)\n   AND (checkhead_id=&lt;? value("checkhead_id") ?>) );\n</sql>\n </querysource>\n <querysource>\n  <name>TopDetail2</name>\n  <sql>SELECT  --VOUCHER-------------\n  1 AS ord,\n  1 AS sequence_value,\n  checkitem_invcnumber,\n  checkitem_ponumber,\n  formatMoney(checkitem_amount) AS f_amount,\n  'Invoice#: ' || vohead_invcnumber AS doc_number,\n  formatDate(vohead_docdate) AS f_docdate,\n  vohead_reference AS doc_reference,\n  'Voucher: ' || checkitem_vouchernumber AS vouchernumber,\n  formatMoney(apopen_amount) AS amount,\n  formatMoney(checkitem_discount) AS disc_cred\nFROM checkitem, vohead, apopen\nWHERE ((checkitem_checkhead_id= &lt;? value("checkhead_id") ?>)\n  AND  (checkitem_vouchernumber = vohead_number)\n  AND  (apopen_docnumber = checkitem_vouchernumber)\n  AND  (apopen_doctype = 'V'))\n\nUNION\n\nSELECT --DEBIT MEMO -------------------------\n  2 AS ord,\n  1 AS sequence_value,\n  checkitem_invcnumber,\n  checkitem_ponumber,\n  formatMoney(checkitem_amount) AS f_amount,\n  'Debit Memo PO#: ' || checkitem_ponumber AS doc_number,\n  ''  AS f_docdate,\n  'Debit Memo: ' || checkitem_vouchernumber AS doc_reference,\n  checkitem_vouchernumber AS vouchernumber,\n  formatMoney(apopen_amount) AS amount,\n  formatMoney(checkitem_discount) AS disc_cred\nFROM checkitem, apopen\nWHERE ((checkitem_checkhead_id= &lt;? value("checkhead_id") ?>)\n  AND  (checkitem_vouchernumber = apopen_docnumber)\n  AND  (apopen_doctype = 'D'))\n\nUNION\n\nSELECT --CREDITs--------------------------\n  3 AS ord,\n  1 AS sequence_value,\n  checkitem_invcnumber,\n  checkitem_ponumber,\n  formatMoney(checkitem_amount) AS f_amount,\n  'Invoice#: ' || vohead_invcnumber AS doc_number,\n  formatDate(vohead_docdate) AS f_docdate,\n  'Credit Applied: ' || apapply_source_doctype || ' ' ||\n                        apapply_source_docnumber AS doc_reference,\n  'Voucher ' || checkitem_vouchernumber AS vouchernumber,\n  '' AS amount,\n  formatMoney((apapply_amount)) AS disc_cred\nFROM checkitem, vohead, apapply\nWHERE ((checkitem_checkhead_id=&lt;? value("checkhead_id") ?>)\n  AND  (checkitem_vouchernumber = vohead_number)\n  AND  (apapply_target_docnumber = checkitem_vouchernumber ))\n\nUNION \n\nSELECT --NON-VENDOR-----------------------\n  4 AS ord,\n  1 AS sequence_value,\n  checkitem_invcnumber,\n  checkitem_ponumber,\n  formatMoney(checkitem_amount) AS f_amount,\n  checkitem_invcnumber AS doc_number,\n  formatDate(checkitem_docdate) AS f_docdate,\n  '' AS doc_reference,\n  '' AS vouchernumber,\n  '' AS amount,\n  '' AS disc_cred\nFROM checkhead LEFT OUTER JOIN\n     checkitem ON (checkitem_checkhead_id=checkhead_id)\nWHERE ((checkhead_id=&lt;? value("checkhead_id") ?>) \n  AND  (checkhead_recip_type != 'V'))\n\nUNION \n\nSELECT --BLANK LINES FOR SPACING------------------\n 5 AS ord,\n sequence_value,\n '' AS checkkitem_invcnumber,\n '' AS checkitem_ponumber,\n '' AS f_amount,\n '' AS vohead_invcnumber,\n '' AS f_docdate,\n '' AS doc_reference,\n '' AS vouchernumber,\n '' AS amount,\n '' AS disc_cred\nFROM sequence\n\nORDER BY ord \nLIMIT 16;</sql>\n </querysource>\n <pghead>\n  <height>6</height>\n </pghead>\n <section>\n  <name>Top Detail Header</name>\n  <detail>\n   <key>\n    <query>Head</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>30</y>\n     <width>147</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Context Query</query>\n     <column>report_date</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>175</x>\n     <y>30</y>\n     <width>75</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Reference:</string>\n   </label>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>15</y>\n     <width>155</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <bottom/>\n    <data>\n     <query>Head</query>\n     <column>recip_name</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>640</x>\n     <y>15</y>\n     <width>61</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Check #</string>\n   </label>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>805</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <line>\n    <xstart>51</xstart>\n    <ystart>7</ystart>\n    <xend>51</xend>\n    <yend>7</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>705</x>\n     <y>15</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>checkhead_number</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>600</x>\n     <y>30</y>\n     <width>85</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Discount / Credit:</string>\n   </label>\n   <label>\n    <rect>\n     <x>5</x>\n     <y>30</y>\n     <width>111</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Invoice / Document:</string>\n   </label>\n   <field>\n    <rect>\n     <x>494</x>\n     <y>15</y>\n     <width>104</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <bottom/>\n    <data>\n     <query>Head</query>\n     <column>recip_number</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>530</x>\n     <y>30</y>\n     <width>45</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Amount:</string>\n   </label>\n  </detail>\n </section>\n <section>\n  <name>Top Detail</name>\n  <detail>\n   <key>\n    <query>TopDetail2</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>155</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>TopDetail2</query>\n     <column>doc_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>610</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>TopDetail2</query>\n     <column>disc_cred</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>310</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>TopDetail2</query>\n     <column>docdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>TopDetail2</query>\n     <column>doc_reference</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>468</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>TopDetail2</query>\n     <column>amount</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>Top Detail Amount</name>\n  <detail>\n   <key>\n    <query>Head</query>\n   </key>\n   <height>36</height>\n   <label>\n    <rect>\n     <x>20</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Memo:</string>\n   </label>\n   <field>\n    <rect>\n     <x>468</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>340</x>\n     <y>0</y>\n     <width>75</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Check Total:</string>\n   </label>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>15</y>\n     <width>690</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>memo</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>395</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>curr_symbol</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>Apchkitem</name>\n  <detail>\n   <key>\n    <query>Head</query>\n   </key>\n   <height>301</height>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>120</y>\n     <width>225</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>recip_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>420</x>\n     <y>100</y>\n     <width>121</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>f_checkdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>100</y>\n     <width>125</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>30</x>\n     <y>55</y>\n     <width>560</width>\n     <height>24</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>12</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>f_words</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>135</y>\n     <width>270</width>\n     <height>15</height>\n    </rect>\n    <bottompad>10</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>check_address</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>280</y>\n     <width>690</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>memo</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>20</x>\n     <y>280</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Memo:</string>\n   </label>\n   <field>\n    <rect>\n     <x>560</x>\n     <y>100</y>\n     <width>55</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>curr_symbol</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>Bottom Detail Header</name>\n  <detail>\n   <key>\n    <query>Head</query>\n   </key>\n   <height>41</height>\n   <label>\n    <rect>\n     <x>600</x>\n     <y>20</y>\n     <width>85</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Discount / Credit:</string>\n   </label>\n   <label>\n    <rect>\n     <x>175</x>\n     <y>20</y>\n     <width>75</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Reference:</string>\n   </label>\n   <label>\n    <rect>\n     <x>5</x>\n     <y>20</y>\n     <width>110</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Invoice / Document:</string>\n   </label>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>0</y>\n     <width>104</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <bottom/>\n    <data>\n     <query>Head</query>\n     <column>recip_number</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>530</x>\n     <y>20</y>\n     <width>45</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <string>Amount:</string>\n   </label>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>15</y>\n     <width>147</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Context Query</query>\n     <column>report_date</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>61</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Check #</string>\n   </label>\n   <field>\n    <rect>\n     <x>710</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>checkhead_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>0</xstart>\n    <ystart>35</ystart>\n    <xend>800</xend>\n    <yend>35</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>155</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <bottom/>\n    <data>\n     <query>Head</query>\n     <column>recip_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>Bottom Detail</name>\n  <detail>\n   <key>\n    <query>TopDetail2</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>155</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>TopDetail2</query>\n     <column>doc_reference</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>160</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>TopDetail2</query>\n     <column>doc_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>468</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>TopDetail2</query>\n     <column>amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>610</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>TopDetail2</query>\n     <column>disc_cred</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>340</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>TopDetail2</query>\n     <column>docdate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>Bottom Detail Amount</name>\n  <detail>\n   <key>\n    <query>Head</query>\n   </key>\n   <height>37</height>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>15</y>\n     <width>690</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>memo</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>408</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>curr_symbol</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>355</x>\n     <y>0</y>\n     <width>65</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Check Total:</string>\n   </label>\n   <label>\n    <rect>\n     <x>20</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Memo:</string>\n   </label>\n   <field>\n    <rect>\n     <x>468</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>Head</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n  </detail>\n </section>\n</report>\n   Sample Check Format - 3 Part - MC - Uses primary Vendor or address with names: REMIT, Remit, or remit if one exists.    0       2014-10-06 19:47:03.678943
102462
 
254     APOpenItemsByVendor     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Open Payables</title>\n <name>APOpenItemsByVendor</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n&lt;? if exists("vend_id") ?>\n       (SELECT vend_name FROM vendinfo WHERE vend_id=&lt;? value("vend_id") ?>)\n&lt;? elseif exists("vendtype_id") ?>\n       (SELECT vendtype_code FROM vendtype WHERE vendtype_id=&lt;? value("vendtype_id") ?>)\n&lt;? elseif exists("vendtype_pattern") ?>\n       ('Vendor Type pattern = ' || &lt;? value("vendtype_pattern") ?>)\n&lt;? else ?>\n       'All Vendors'\n&lt;? endif ?>\n       AS selection,\n       currConcat(baseCurrId()) AS baseCurr,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       formatDate(&lt;? value("asofDate") ?>) AS asofDate;</sql>\n </querysource>\n <querysource loadFromDb="true" >\n  <name>detail</name>\n  <mqlgroup>apOpenItems</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>166</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>160</ystart>\n   <xend>745</xend>\n   <yend>160</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>143</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>445</x>\n    <y>108</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>As of Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>143</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Paid</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>108</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>asofDate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>8</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Open Payables</string>\n  </label>\n  <label>\n   <rect>\n    <x>445</x>\n    <y>83</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>65</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>445</x>\n    <y>65</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>143</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>390</x>\n    <y>143</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>470</x>\n    <y>143</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>83</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>143</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>75</x>\n    <y>143</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc.#</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>143</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>143</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>baseCurr</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>143</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Curr</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>65</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Selection:</string>\n  </label>\n  <field>\n   <rect>\n    <x>110</x>\n    <y>65</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>selection</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>130</x>\n    <y>143</y>\n    <width>115</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>4</y>\n    <width>50</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Paid</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>4</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>4</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>75</x>\n    <y>4</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc.#</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>4</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>470</x>\n    <y>4</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>390</x>\n    <y>4</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>4</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>4</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Curr</string>\n  </label>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>4</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>baseCurr</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>130</x>\n    <y>4</y>\n    <width>115</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>2</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_docdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>250</x>\n     <y>2</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>apopen_ponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>2</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>2</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_paid</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>2</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>390</x>\n     <y>2</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>475</x>\n     <y>2</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>75</x>\n     <y>2</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>apopen_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>695</x>\n     <y>2</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_base_balance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>2</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>currAbbr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>2</y>\n     <width>115</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>102</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>130</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Total:</string>\n  </label>\n  <field>\n   <rect>\n    <x>642</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>base_balance</column>\n   </data>\n   <format builtin="true" >qty</format>\n   <tracktotal/>\n  </field>\n </rptfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102463
 
284     ARAging \N      <!DOCTYPE openRPTDef>\n<report>\n <title>AR 30 60 90 Aging</title>\n <name>ARAging</name>\n <description>Enhanced AR Aging - Uses 30-60-90 columns - User provides Relative Date - all amounts in base currency based on Document Date.</description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <landscape/>\n <topmargin>100</topmargin>\n <bottommargin>100</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n\taraging_docdate,\n\taraging_duedate,\n\taraging_ponumber,\n\taraging_docnumber,\n\taraging_doctype,\n\taraging_cust_id,\n\taraging_cust_number,\n\taraging_cust_name,\n\taraging_cust_custtype_id,\n\taraging_custtype_code,\n\taraging_terms_descrip,\n\tformatMoney(araging_aropen_amount) AS araging_aropen_amount,\n\taraging_cur_val,   formatMoney(araging_cur_val)    AS araging_cur_amt,\n\taraging_thirty_val,formatMoney(araging_thirty_val) AS araging_thirty_amt,\n\taraging_sixty_val, formatMoney(araging_sixty_val)  AS araging_sixty_amt,\n\taraging_ninety_val,formatMoney(araging_ninety_val) AS araging_ninety_amt,\n\taraging_plus_val,  formatMoney(araging_plus_val)   AS araging_plus_amt,\n\taraging_total_val, formatMoney(araging_total_val)  AS araging_total_amt\nFROM araging(&lt;? value("relDate") ?>, &lt;? value("useDocDate") ?>)\n&lt;? if exists("cust_id") ?>\n   WHERE (araging_cust_id=&lt;? value("cust_id") ?>)\n&lt;? elseif exists("custtype_id") ?>\n   WHERE (araging_cust_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? elseif exists("custgrp_id") ?>\n   LEFT OUTER JOIN custgrpitem ON (araging_cust_id=custgrpitem_cust_id)\n   WHERE (custgrpitem_custgrp_id=&lt;? value("custgrp_id") ?>)\n&lt;? elseif exists("custtype_pattern") ?>\n   WHERE (araging_custtype_code ~ &lt;? value("custtype_pattern") ?>)\n&lt;? endif ?>;</sql>\n </querysource>\n <rpthead>\n  <height>81</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>40</y>\n    <width>50</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>As of:</string>\n  </label>\n  <field>\n   <rect>\n    <x>60</x>\n    <y>40</y>\n    <width>110</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Parameter Query</query>\n    <column>relDate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>365</width>\n    <height>31</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Accounts Receivable Aging Report</string>\n  </label>\n </rpthead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>Customer</name>\n   <column>araging_cust_number</column>\n   <pagebreak when="after foot"/>\n   <head>\n    <height>113</height>\n    <label>\n     <rect>\n      <x>891</x>\n      <y>85</y>\n      <width>75</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>90+ Days</string>\n    </label>\n    <line>\n     <xstart>0</xstart>\n     <ystart>100</ystart>\n     <xend>980</xend>\n     <yend>100</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>740</x>\n      <y>85</y>\n      <width>75</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>31-60 Days</string>\n    </label>\n    <label>\n     <rect>\n      <x>35</x>\n      <y>85</y>\n      <width>85</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Invoice#</string>\n    </label>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>40</y>\n      <width>102</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Terms:</string>\n    </label>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>85</y>\n      <width>25</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Type</string>\n    </label>\n    <line>\n     <xstart>0</xstart>\n     <ystart>5</ystart>\n     <xend>967</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>125</x>\n      <y>40</y>\n      <width>220</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>araging_terms_descrip</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>825</x>\n      <y>85</y>\n      <width>75</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>61-90 Days</string>\n    </label>\n    <label>\n     <rect>\n      <x>125</x>\n      <y>85</y>\n      <width>60</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Doc Date</string>\n    </label>\n    <label>\n     <rect>\n      <x>490</x>\n      <y>75</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Original</string>\n    </label>\n    <label>\n     <rect>\n      <x>650</x>\n      <y>85</y>\n      <width>75</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>0-30 Days</string>\n    </label>\n    <label>\n     <rect>\n      <x>490</x>\n      <y>85</y>\n      <width>80</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Doc Amount</string>\n    </label>\n    <field>\n     <rect>\n      <x>125</x>\n      <y>25</y>\n      <width>220</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>araging_cust_number</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>35</x>\n      <y>75</y>\n      <width>85</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Debit Memo/</string>\n    </label>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>10</y>\n      <width>102</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Customer Name:</string>\n    </label>\n    <field>\n     <rect>\n      <x>125</x>\n      <y>10</y>\n      <width>220</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>araging_cust_name</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>570</x>\n      <y>85</y>\n      <width>75</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>0+Days</string>\n    </label>\n    <label>\n     <rect>\n      <x>215</x>\n      <y>85</y>\n      <width>60</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Due Date</string>\n    </label>\n    <label>\n     <rect>\n      <x>35</x>\n      <y>65</y>\n      <width>85</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Credit/</string>\n    </label>\n    <label>\n     <rect>\n      <x>340</x>\n      <y>85</y>\n      <width>85</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>PO Number</string>\n    </label>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>25</y>\n      <width>102</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Customer Number:</string>\n    </label>\n   </head>\n   <foot>\n    <height>111</height>\n    <field>\n     <rect>\n      <x>825</x>\n      <y>5</y>\n      <width>70</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>araging_ninety_val</column>\n     </data>\n     <format builtin="true">qty</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <field>\n     <rect>\n      <x>740</x>\n      <y>5</y>\n      <width>70</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>araging_sixty_val</column>\n     </data>\n     <format builtin="true">qty</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <field>\n     <rect>\n      <x>250</x>\n      <y>50</y>\n      <width>75</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>araging_total_val</column>\n     </data>\n     <format builtin="true">qty</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <field>\n     <rect>\n      <x>570</x>\n      <y>5</y>\n      <width>75</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>araging_cur_val</column>\n     </data>\n     <format builtin="true">qty</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <field>\n     <rect>\n      <x>650</x>\n      <y>5</y>\n      <width>75</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>araging_thirty_val</column>\n     </data>\n     <format builtin="true">qty</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>35</y>\n      <width>135</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Total For Customer</string>\n    </label>\n    <field>\n     <rect>\n      <x>5</x>\n      <y>50</y>\n      <width>220</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>araging_cust_name</column>\n     </data>\n    </field>\n    <line>\n     <xstart>0</xstart>\n     <ystart>5</ystart>\n     <xend>967</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>900</x>\n      <y>5</y>\n      <width>70</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>araging_plus_val</column>\n     </data>\n     <format builtin="true">qty</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <label>\n     <rect>\n      <x>570</x>\n      <y>75</y>\n      <width>440</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>All amounts are in base currency as of the document date.</string>\n    </label>\n    <label>\n     <rect>\n      <x>570</x>\n      <y>60</y>\n      <width>41</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Note:</string>\n    </label>\n    <line>\n     <xstart>237</xstart>\n     <ystart>31</ystart>\n     <xend>237</xend>\n     <yend>31</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>-35</x>\n      <y>12</y>\n      <width>41</width>\n      <height>11</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <string></string>\n    </label>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>740</x>\n     <y>0</y>\n     <width>70</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>araging_sixty_amt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>480</x>\n     <y>0</y>\n     <width>80</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>araging_aropen_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>25</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>araging_doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>40</x>\n     <y>0</y>\n     <width>61</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>araging_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>0</y>\n     <width>85</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>araging_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>910</x>\n     <y>0</y>\n     <width>55</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>araging_plus_amt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>825</x>\n     <y>0</y>\n     <width>70</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>araging_ninety_amt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>120</x>\n     <y>0</y>\n     <width>85</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>araging_docdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>340</x>\n     <y>0</y>\n     <width>61</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>araging_ponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>570</x>\n     <y>0</y>\n     <width>75</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>araging_cur_amt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>650</x>\n     <y>0</y>\n     <width>75</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>araging_thirty_amt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <lastpage/>\n  <height>103</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>50</y>\n    <width>170</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Total For All Customers</string>\n  </label>\n  <field>\n   <rect>\n    <x>650</x>\n    <y>5</y>\n    <width>75</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>araging_thirty_val</column>\n   </data>\n   <format builtin="true">qty</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>740</x>\n    <y>5</y>\n    <width>70</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>araging_sixty_val</column>\n   </data>\n   <format builtin="true">qty</format>\n   <tracktotal/>\n  </field>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>75</y>\n    <width>35</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Page: </string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>5</y>\n    <width>170</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report Totals:</string>\n  </label>\n  <field>\n   <rect>\n    <x>570</x>\n    <y>5</y>\n    <width>75</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>araging_cur_val</column>\n   </data>\n   <format builtin="true">qty</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>910</x>\n    <y>5</y>\n    <width>55</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>araging_plus_val</column>\n   </data>\n   <format builtin="true">qty</format>\n   <tracktotal/>\n  </field>\n  <line>\n   <xstart>1</xstart>\n   <ystart>1</ystart>\n   <xend>967</xend>\n   <yend>1</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>440</x>\n    <y>75</y>\n    <width>41</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>250</x>\n    <y>50</y>\n    <width>75</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>araging_total_val</column>\n   </data>\n   <format builtin="true">qty</format>\n   <tracktotal/>\n  </field>\n  <label>\n   <rect>\n    <x>570</x>\n    <y>65</y>\n    <width>440</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>All amounts are in base currency as of the document date.</string>\n  </label>\n  <label>\n   <rect>\n    <x>570</x>\n    <y>50</y>\n    <width>41</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Note:</string>\n  </label>\n  <field>\n   <rect>\n    <x>825</x>\n    <y>5</y>\n    <width>70</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>araging_ninety_val</column>\n   </data>\n   <format builtin="true">qty</format>\n   <tracktotal/>\n  </field>\n </pgfoot>\n <pgfoot>\n  <height>57</height>\n  <field>\n   <rect>\n    <x>440</x>\n    <y>20</y>\n    <width>41</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>20</y>\n    <width>35</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Page: </string>\n  </label>\n </pgfoot>\n</report>\n      Enhanced AR Aging - Uses 30-60-90 columns - User provides Relative Date - all amounts in base currency based on Document Date.  0       2014-10-06 19:47:03.678943
102464
 
262     ARApplications  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>A/R Applications</title>\n <name>ARApplications</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("cust_id") ?>\n         (SELECT (cust_number || '-' || cust_name)\n            FROM custinfo\n           WHERE (cust_id=&lt;? value("cust_id") ?>) )\n       &lt;? elseif exists("custtype_id") ?>\n         (select (custtype_code||'-'||custtype_descrip)\n            FROM custtype\n           WHERE (custtype_id=&lt;? value("custtype_id") ?>) )\n       &lt;? elseif exists("custtype_pattern") ?>\n         text(&lt;? value("custtype_pattern") ?>)\n       &lt;? else ?>\n         text('All Customers')\n       &lt;? endif ?>\n       AS f_value,\n       &lt;? if exists("custtype_id") ?>\n         text('Cust. Type:')\n       &lt;? elseif exists("custtype_pattern") ?>\n         text('Cust. Type Pattern:')\n       &lt;? else ?>\n         text('Customer:')\n       &lt;? endif ?>\n       AS f_label,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("includeCashReceipts") ?>\n         &lt;? if exists("includeCreditMemos") ?>\n           text('Show Cash Receipts and Credit Memos')\n         &lt;? else ?>\n           text('Show Cash Receipts')\n         &lt;? endif ?>\n       &lt;? elseif exists("includeCreditMemos") ?>\n         text('Show Credit Memos')\n       &lt;? else ?>\n         text('Error: No transaction type selected.')\n       &lt;? endif ?>\n       AS f_show;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT arapply_id,\n       formatDate(arapply_postdate) AS f_postdate,\n       formatMoney(arapply_applied) AS f_applied,\n       cust_number, cust_name,\n      (CASE WHEN (arapply_source_doctype='C') THEN &lt;? value("creditMemo") ?>\n            WHEN (arapply_source_doctype='R') THEN &lt;? value("cashdeposit") ?>\n            WHEN (arapply_fundstype='C') THEN &lt;? value("check") ?>\n            WHEN (arapply_fundstype='T') THEN &lt;? value("certifiedCheck") ?>\n            WHEN (arapply_fundstype='M') THEN &lt;? value("masterCard") ?>\n            WHEN (arapply_fundstype='V') THEN &lt;? value("visa") ?>\n            WHEN (arapply_fundstype='A') THEN &lt;? value("americanExpress") ?>\n            WHEN (arapply_fundstype='D') THEN &lt;? value("discoverCard") ?>\n            WHEN (arapply_fundstype='R') THEN &lt;? value("otherCreditCard") ?>\n            WHEN (arapply_fundstype='K') THEN &lt;? value("cash") ?>\n            WHEN (arapply_fundstype='W') THEN &lt;? value("wireTransfer") ?>\n            WHEN (arapply_fundstype='O') THEN &lt;? value("other") ?>\n       END || ' ' ||\n       CASE WHEN (arapply_source_doctype IN ('C','R')) THEN TEXT(arapply_source_docnumber)\n            ELSE arapply_refnumber\n       END) AS source,\n      (CASE WHEN (arapply_target_doctype='D') THEN &lt;? value("debitMemo") ?>\n            WHEN (arapply_target_doctype='I') THEN &lt;? value("invoice") ?>\n            WHEN (arapply_target_doctype='K') THEN &lt;? value("apcheck") ?>\n            ELSE &lt;? value("other") ?>\n       END || ' ' ||\n       TEXT(arapply_target_docnumber)) AS target,\n       currConcat(arapply_curr_id) AS currAbbr,\n       currtobase(arapply_curr_id,arapply_applied,arapply_postdate) AS base_applied\nFROM arapply, custinfo\nWHERE ( (arapply_cust_id=cust_id)\n  AND   (arapply_postdate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n  AND   (arapply_source_doctype IN (\n&lt;? if exists("includeCreditMemos") ?>\n  &lt;? if exists("includeCashReceipts") ?>\n            'K', 'C', 'R'\n  &lt;? else ?>\n            'C', 'R'\n  &lt;? endif ?>\n&lt;? else ?>\n            'K'\n&lt;? endif ?> ))\n&lt;? if exists("cust_id") ?>\n  AND   (cust_id=&lt;? value("cust_id") ?>)\n&lt;? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype\n                              WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n&lt;? endif ?>\n      )\nORDER BY arapply_postdate, source;\n</sql>\n </querysource>\n <rpthead>\n  <height>146</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>140</ystart>\n   <xend>745</xend>\n   <yend>140</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>125</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>A/R Applications</string>\n  </label>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>458</x>\n    <y>65</y>\n    <width>100</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>310</x>\n    <y>125</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>700</x>\n    <y>125</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>65</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_label</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>90</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_show</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>630</x>\n    <y>125</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>125</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Target</string>\n  </label>\n  <label>\n   <rect>\n    <x>234</x>\n    <y>125</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>125</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust. #</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>65</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_value</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>458</x>\n    <y>85</y>\n    <width>100</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>5</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Target</string>\n  </label>\n  <label>\n   <rect>\n    <x>635</x>\n    <y>5</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>5</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>705</x>\n    <y>5</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>620</x>\n     <y>0</y>\n     <width>65</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_applied</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>220</x>\n     <y>0</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_postdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>460</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>target</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>700</x>\n     <y>0</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>currAbbr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>source</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>90</x>\n     <y>0</y>\n     <width>115</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>104</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>base_applied</column>\n   </data>\n   <tracktotal builtin="true" >qty</tracktotal>\n  </field>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>0</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Total Applications (base):</string>\n  </label>\n </rptfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102465
 
288     AROpenItems     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>A/R Open Items</title>\n <name>AROpenItems</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \nCASE WHEN (&lt;? value("asofDate") ?> = endOfTime()) THEN 'Latest'\n     ELSE formatDate(&lt;? value("asofDate") ?>) END AS asOfDate,\n&lt;? if exists("creditsOnly") ?>\n  'Credits Only' AS type,\n&lt;? elseif exists("debitsOnly") ?>\n  'Debits Only' AS type,\n&lt;? else ?>\n  'Debits and Credits' AS type,\n&lt;? endif ?>\n&lt;? if exists("cust_id") ?>\n  (SELECT cust_name FROM custinfo WHERE cust_id=&lt;? value("cust_id") ?>) AS selection,\n&lt;? elseif exists("custtype_id") ?>\n  (SELECT custtype_code FROM custtype WHERE custtype_id=&lt;? value("custtype_id") ?>) AS selection,\n&lt;? elseif exists("custtype_pattern") ?>\n  ('Customer Type pattern = ' || &lt;? value("custtype_pattern") ?>) AS selection,\n&lt;? elseif exists("custgrp_id") ?>\n  (SELECT custgrp_name FROM custgrp WHERE \n custgrp_id=&lt;? value("custgrp_id") ?>) AS selection,\n&lt;? else ?>\n  'All Customers' AS selection,\n&lt;? endif ?>\n&lt;? if exists("startDate") ?>\n      'Start Doc Date:' AS start_label,\n      'End Doc Date:' AS end_label,\n&lt;? else ?>\n      'Start Due Date:' AS start_label,   \n      'End Due Date:' AS end_label,\n&lt;? endif ?>\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       currConcat(baseCurrId()) AS baseAbbr,\n&lt;? if exists("incidentsOnly") ?>\n  'Yes' AS incidentsOnly\n&lt;? else ?>\n  'No' AS incidentsOnly\n&lt;? endif ?>;</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>arOpenItems</mqlgroup>\n  <mqlname>f_detail</mqlname>\n </querysource>\n <rpthead>\n  <height>178</height>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>155</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>345.951</x>\n    <y>11.3379</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Open Receivables</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>155</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Document #</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>155</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>155</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <field>\n   <rect>\n    <x>514</x>\n    <y>69.7785</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>155</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>155</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>155</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Paid</string>\n  </label>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>155</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>700</x>\n    <y>155</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <field>\n   <rect>\n    <x>514</x>\n    <y>52.6662</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>170</ystart>\n   <xend>745</xend>\n   <yend>170</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>410</x>\n    <y>52.6662</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>start_label</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>410.317</x>\n    <y>69.7785</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>end_label</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>141.375</x>\n    <y>69.7785</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>type</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>142</x>\n    <y>52.6662</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>selection</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>141.375</x>\n    <y>88.4798</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>incidentsOnly</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>514.049</x>\n    <y>88.4798</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>asOfDate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>34.8028</x>\n    <y>52.6662</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Selection:</string>\n  </label>\n  <label>\n   <rect>\n    <x>35.1592</x>\n    <y>69.7785</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <label>\n   <rect>\n    <x>34.8631</x>\n    <y>88.4798</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Incidents Only:</string>\n  </label>\n  <label>\n   <rect>\n    <x>410.477</x>\n    <y>88.4798</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>As Of Date:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>52</height>\n  <label>\n   <rect>\n    <x>700</x>\n    <y>30</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>45</ystart>\n   <xend>745</xend>\n   <yend>45</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>30</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>30</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>30</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>30</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>30</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>30</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Paid</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>30</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>30</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Document #</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>350</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>0</y>\n     <width>77</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>700</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>currAbbr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>440</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_paid</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>78.9</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_docdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>104</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>700</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>baseAbbr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>base_balance</column>\n   </data>\n   <format builtin="true">qty</format>\n   <tracktotal/>\n  </field>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Total:</string>\n  </label>\n </rptfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102466
 
301     AccountingYearPeriodsMasterList \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Accounting Year Periods Master List</title>\n <name>AccountingYearPeriodsMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT yearperiod_id,\n       formatDate(yearperiod_start) AS f_start,\n       formatDate(yearperiod_end) AS f_end,\n       formatBoolYN(yearperiod_closed) AS f_closed\n  FROM yearperiod\nORDER BY yearperiod_start;</sql>\n </querysource>\n <rpthead>\n  <height>75</height>\n  <label>\n   <rect>\n    <x>420</x>\n    <y>54</y>\n    <width>80</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Closed</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>54</y>\n    <width>100</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Start</string>\n  </label>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>54</y>\n    <width>100</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>End</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>415</x>\n    <y>10</y>\n    <width>329</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Fiscal Years Master List</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>420</x>\n    <y>0</y>\n    <width>80</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Closed</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>14</ystart>\n   <xend>745</xend>\n   <yend>14</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>0</y>\n    <width>100</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>End</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>100</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Start</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>113</x>\n     <y>0</y>\n     <width>100</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_end</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_start</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>420</x>\n     <y>0</y>\n     <width>80</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_closed</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>15</height>\n  <label>\n   <rect>\n    <x>614</x>\n    <y>0</y>\n    <width>85</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102467
 
311     AddressesMasterList     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Addresses Master List</title>\n <name>AddressesMasterList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT * \nFROM (\nSELECT 'Contact' AS type, cntct_first_name AS first,\n       cntct_last_name AS last, crmacct_number, cntct_phone AS phone,\n       cntct_email AS email, cntct_fax AS fax, addr.*\nFROM addr, cntct LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id)\nWHERE (cntct_addr_id=addr_id)\nUNION\nSELECT 'Ship-To' AS type, shipto_num AS first,\n       shipto_name AS last, crmacct_number, '' AS phone,\n       '' AS email, '' AS fax, addr.*\nFROM addr, shiptoinfo LEFT OUTER JOIN crmacct ON (shipto_cust_id=crmacct_cust_id\n)\nWHERE (shipto_addr_id=addr_id)\nUNION\nSELECT 'Vendor' AS type, vend_number AS first,\n       vend_name AS last, crmacct_number, '' AS phone,\n       '' AS email, '' AS fax, addr.*\nFROM addr, vendinfo LEFT OUTER JOIN crmacct ON (vend_id=crmacct_vend_id)\nWHERE (vend_addr_id=addr_id)\nUNION\nSELECT 'Vendor Address' AS type, vendaddr_code AS first,\n       vendaddr_name AS last, crmacct_number, '' AS phone,\n       '' AS email, '' AS fax, addr.*\nFROM addr, vendaddrinfo LEFT OUTER JOIN crmacct ON (vendaddr_vend_id=crmacct_vend_id)\nWHERE (vendaddr_addr_id=addr_id)\nUNION\nSELECT 'Site' AS type, warehous_code AS first,\n       warehous_descrip AS last, '' AS crmacct_number, '' AS phone,\n       '' AS email, '' AS fax, addr.*\nFROM addr, whsinfo\nWHERE (warehous_addr_id=addr_id)\n\nUNION\nSELECT '' AS type, '' AS first, '' AS last,\n       '' AS crmacct_number, '' AS phone,\n       '' AS email,\n       '' AS fax, addr.*\nFROM addr\nWHERE addr_id NOT IN (\n            SELECT cntct_addr_id FROM cntct WHERE (cntct_addr_id IS NOT NULL)\n            UNION SELECT shipto_addr_id FROM shiptoinfo WHERE (shipto_addr_id IS NOT NULL) \n            UNION SELECT vend_addr_id FROM vendinfo WHERE (vend_addr_id IS NOT NULL)\n            UNION SELECT vendaddr_addr_id FROM vendaddrinfo WHERE (vendaddr_addr_id IS NOT NULL)\n            UNION SELECT warehous_addr_id FROM whsinfo WHERE (warehous_addr_id IS NOT NULL))\n) data\n&lt;? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias&lt;? literal("char_id_text_list") ?> ON ((charass_alias&lt;? literal("char_id_text_list") ?>.charass_target_type='ADDR') \n                                                                    AND  (charass_alias&lt;? literal("char_id_text_list") ?>.charass_target_id=addr_id)\n                                                                    AND  (charass_alias&lt;? literal("char_id_text_list") ?>.charass_char_id=&lt;? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias&lt;? literal("char_id_text_list") ?> ON (charass_alias&lt;? literal("char_id_text_list") ?>.charass_char_id=char_alias&lt;? literal("char_id_text_list") ?>.char_id)\n&lt;? endforeach ?>\n&lt;? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias&lt;? literal("char_id_list_list") ?> ON ((charass_alias&lt;? literal("char_id_list_list") ?>.charass_target_type='ADDR') \n                                                                    AND  (charass_alias&lt;? literal("char_id_list_list") ?>.charass_target_id=addr_id)\n                                                                    AND  (charass_alias&lt;? literal("char_id_list_list") ?>.charass_char_id=&lt;? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias&lt;? literal("char_id_list_list") ?> ON (charass_alias&lt;? literal("char_id_list_list") ?>.charass_char_id=char_alias&lt;? literal("char_id_list_list") ?>.char_id)\n&lt;? endforeach ?>\n&lt;? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias&lt;? literal("char_id_date_list") ?> ON ((charass_alias&lt;? literal("char_id_date_list") ?>.charass_target_type='ADDR') \n                                                                    AND  (charass_alias&lt;? literal("char_id_date_list") ?>.charass_target_id=addr_id)\n                                                                    AND  (charass_alias&lt;? literal("char_id_date_list") ?>.charass_char_id=&lt;? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias&lt;? literal("char_id_date_list") ?> ON (charass_alias&lt;? literal("char_id_date_list") ?>.charass_char_id=char_alias&lt;? literal("char_id_date_list") ?>.char_id)\n&lt;? endforeach ?>\nWHERE true\n&lt;? if not exists("showInactive") ?> AND addr_active &lt;? endif ?>\n&lt;? literal("charClause") ?>\nORDER BY addr_country, addr_state, addr_city,\n         addr_postalcode, addr_line1, addr_line2,\n         addr_line3, type, last, first;</sql>\n </querysource>\n <rpthead>\n  <height>156</height>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>136</y>\n    <width>95</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>First Name / Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>136</y>\n    <width>120</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Phone</string>\n  </label>\n  <label>\n   <rect>\n    <x>140</x>\n    <y>121</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Line 2</string>\n  </label>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>136</y>\n    <width>120</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Use of Address</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>136</y>\n    <width>120</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Last Name / Name</string>\n  </label>\n  <line>\n   <xstart>6.33333</xstart>\n   <ystart>150.333</ystart>\n   <xend>995.333</xend>\n   <yend>150.333</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>121</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Country</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>121</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Line 1</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>121</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>City</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>5</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Addresses Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>121</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>State/Province</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>121</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Line 3</string>\n  </label>\n  <label>\n   <rect>\n    <x>875</x>\n    <y>136</y>\n    <width>120</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Email Address</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>136</y>\n    <width>120</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>750</x>\n    <y>136</y>\n    <width>120</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Fax</string>\n  </label>\n  <label>\n   <rect>\n    <x>750</x>\n    <y>121</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Postal Code</string>\n  </label>\n  <text>\n   <rect>\n    <x>5</x>\n    <y>36</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>38</height>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>-1</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Line 3</string>\n  </label>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>19</y>\n    <width>120</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Phone</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>19</y>\n    <width>120</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>14</y>\n    <width>120</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Use of Address</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>-1</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>State/Province</string>\n  </label>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>-1</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Country</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>14</y>\n    <width>95</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>First Name / Number</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>31</ystart>\n   <xend>992</xend>\n   <yend>31</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>875</x>\n    <y>19</y>\n    <width>120</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Email Address</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>14</y>\n    <width>120</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Last Name / Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>-1</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>City</string>\n  </label>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>-1</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Line 2</string>\n  </label>\n  <label>\n   <rect>\n    <x>750</x>\n    <y>19</y>\n    <width>120</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Fax</string>\n  </label>\n  <label>\n   <rect>\n    <x>750</x>\n    <y>-1</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Postal Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>-1</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Line 1</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>Address</name>\n   <column>addr_id</column>\n   <head>\n    <height>22</height>\n    <field>\n     <rect>\n      <x>375</x>\n      <y>5</y>\n      <width>120</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>addr_city</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>750</x>\n      <y>5</y>\n      <width>120</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>addr_postalcode</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>625</x>\n      <y>5</y>\n      <width>120</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>addr_country</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>140</x>\n      <y>5</y>\n      <width>120</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>addr_line2</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>5</y>\n      <width>120</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>addr_line1</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>500</x>\n      <y>5</y>\n      <width>120</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>addr_state</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>270</x>\n      <y>5</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>addr_line3</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>12</height>\n   <field>\n    <rect>\n     <x>375</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>last</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>750</x>\n     <y>0</y>\n     <width>120</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>fax</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>crmacct_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>625</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>phone</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>first</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>875</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>email</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>140</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>type</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>-1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>855</x>\n    <y>-1</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>945</x>\n    <y>-1</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102468
 
291     AdjustmentTypes \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Adjustment Types</title>\n <name>AdjustmentTypes</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT bankadjtype_name, bankadjtype_descrip,\n       formatGLAccountLong(bankadjtype_accnt_id) AS f_accnt,\n       CASE WHEN(bankadjtype_iscredit) THEN text('Credit')\n            ELSE text('Debit')\n       END AS f_type\n  FROM bankadjtype;</sql>\n </querysource>\n <rpthead>\n  <height>121</height>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>5</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Adjustment Types</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>100</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>100</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Adj. Account #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>115</ystart>\n   <xend>745</xend>\n   <yend>115</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>100</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>100</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit/Credit</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>9</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit/Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Adj. Account #</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>155</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bankadjtype_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>0</y>\n     <width>170</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bankadjtype_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>340</x>\n     <y>0</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_accnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_type</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102469
 
460     Backlog \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Backlog</title>\n <name>Backlog</name>\n <description></description>\n <parameter default="01-01-2020" active="true" listtype="static" type="string" name="endDate">\n  <description></description>\n </parameter>\n <parameter default="t" active="true" listtype="static" type="string" name="showPrices">\n  <description></description>\n </parameter>\n <parameter default="01-01-1990" active="true" listtype="static" type="string" name="startDate">\n  <description></description>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT CASE WHEN (checkPrivilege('ViewCustomerPrices') AND isMultiCurr()) THEN text('Amount(base)')\n            WHEN (checkPrivilege('ViewCustomerPrices')) THEN text('Amount')\n            ELSE text('')\n       END AS lbl_baseamount,\n       CASE WHEN (checkPrivilege('ViewCustomerPrices') AND isMultiCurr()) THEN text('Amount(foreign)')\n            ELSE text('')\n       END AS lbl_foreignamount;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT cohead_number, coitem_linenumber, cust_name,\n       formatDate(cohead_orderdate) AS f_orderdate,\n       formatDate(coitem_scheddate) AS f_scheddate,\n       item_number, uom_name,\n       item_descrip1, item_descrip2,\n       formatQty(coitem_qtyord) AS f_qtyord,\n       formatQty(coitem_qtyshipped) AS f_qtyship,\n       formatQty(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) AS f_balance, \n       CASE WHEN (checkPrivilege('ViewCustomerPrices')) THEN\nformatMoney(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n                * (currtobase(cohead_curr_id,coitem_price,cohead_orderdate) / coitem_price_invuomratio),2))\n       ELSE\n         text('')\n       END\n       AS f_ammount,\n       CASE WHEN (checkPrivilege('ViewCustomerPrices') AND isMultiCurr()) THEN\nformatMoney(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n                * (coitem_price / coitem_price_invuomratio),2))\n       ELSE\n         text('')\n       END\n       AS foreign_ammount,\nround((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n    * (currtobase(cohead_curr_id,coitem_price,cohead_orderdate) / coitem_price_invuomratio),2) AS backlog \n  FROM cohead, coitem, itemsite, item, custinfo, uom\n WHERE ((coitem_cohead_id=cohead_id)\n   AND (cohead_cust_id=cust_id)\n   AND (coitem_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (coitem_status='O')\n  &lt;? if exists("cohead_id") ?>\n    AND  (coitem_cohead_id=&lt;? value("cohead_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("startDate") ?>\n    AND  (cohead_orderdate >= &lt;? value("startDate") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("endDate") ?>\n    AND  (cohead_orderdate &lt;= &lt;? value("endDate") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("startDateSched") ?>\n    AND  (coitem_scheddate >= &lt;? value("startDateSched") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("endDateSched") ?>\n    AND  (coitem_scheddate &lt;= &lt;? value("endDateSched") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("salesrep_id") ?>\n    AND  (cohead_salesrep_id=&lt;? value("salesrep_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("shipto_id") ?>\n    AND  (cohead_shipto_id=&lt;? value("shipto_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("cust_id") ?>\n    AND  (cohead_cust_id=&lt;? value("cust_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("custtype_id") ?>\n    AND  (cust_custtype_id=&lt;? value("custtype_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("custtype_pattern") ?>\n    AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                               FROM custtype\n                               WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n  &lt;? endif ?>\n  &lt;? if exists("custgrp") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem))\n  &lt;? endif ?>\n  &lt;? if exists("custgrp_id") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem\n                     WHERE (custgrpitem_custgrp_id=&lt;? value("custgrp_id") ?>)))\n  &lt;? endif ?>\n  &lt;? if exists("custgrp_pattern") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrp, custgrpitem\n                     WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                       AND   (custgrp_name ~ &lt;? value("custgrp_pattern") ?>) )) )\n  &lt;? endif ?>\n\n  &lt;? if exists("item_id") ?>\n    AND  (itemsite_item_id=&lt;? value("item_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("prodcat_id") ?>\n    AND (item_prodcat_id=&lt;? value("prodcat_id") ?>)\n  &lt;? endif ?>\n  &lt;? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                             FROM prodcat\n                             WHERE (prodcat_code ~ &lt;? value("prodcat_pattern") ?>)))\n  &lt;? endif ?>\n\n  &lt;? if exists("warehous_id") ?>\n    AND  (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n  &lt;? endif ?>\n)\nORDER BY coitem_scheddate, cohead_number, coitem_linenumber;</sql>\n </querysource>\n <querysource>\n  <name>total</name>\n  <sql>SELECT now()\n WHERE 't' = CASE WHEN (checkPrivilege('ViewCustomerPrices')) THEN 't'\n                  ELSE 'f'\n             END\n;</sql>\n </querysource>\n <rpthead>\n  <height>226</height>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>185</y>\n    <width>102</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>185</y>\n    <width>110</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>200</y>\n    <width>102</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>185</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_baseamount</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_foreignamount</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>0</y>\n    <width>465</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Backlog</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>507</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scheduled</string>\n  </label>\n  <label>\n   <rect>\n    <x>507</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Ordered</string>\n  </label>\n  <text>\n   <rect>\n    <x>5</x>\n    <y>28</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>507</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>0</y>\n    <width>102</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>15</y>\n    <width>102</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>507</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scheduled</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_baseamount</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_foreignamount</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>0</y>\n    <width>110</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>52</height>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>30</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>coitem_linenumber</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>15</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>507</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyship</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>671</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>foreign_ammount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>0</y>\n     <width>140</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ammount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>450</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>225</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_orderdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>507</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyord</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>225</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_scheddate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>112</x>\n     <y>0</y>\n     <width>110</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_number</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>totals</name>\n  <detail>\n   <key>\n    <query>total</query>\n   </key>\n   <height>18</height>\n   <label>\n    <rect>\n     <x>230</x>\n     <y>0</y>\n     <width>415</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Total:</string>\n   </label>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>backlog</column>\n    </data>\n    <format builtin="true">money</format>\n    <tracktotal/>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102470
 
240     BankAccountsMasterList  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Bank Accounts Master List</title>\n <name>BankAccountsMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT bankaccnt_id,\n       bankaccnt_name AS f_name,\n       bankaccnt_descrip AS f_descrip,\n       CASE WHEN (bankaccnt_type='K') THEN text('Checking')\n            WHEN (bankaccnt_type='C') THEN text('Cash')\n            WHEN (bankaccnt_type='R') THEN text('Credit Card')\n            ELSE text('?')\n       END AS f_type,\n       formatBoolYN(bankaccnt_ap) AS f_ap,\n       formatBoolYN(bankaccnt_ar) AS f_ar\n  FROM bankaccnt\nORDER BY bankaccnt_name;</sql>\n </querysource>\n <rpthead>\n  <height>77</height>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>A/R</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Bank Accounts Master List</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>A/P</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>22</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>A/P</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>A/R</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>495</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_type</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>95</x>\n     <y>0</y>\n     <width>395</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ar</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102471
 
292     BankAdjustmentEditList  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Bank Adjustment Edit List</title>\n <name>BankAdjustmentEditList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT bankadj_id, (bankaccnt_name || '-' || bankaccnt_descrip) AS f_bank,\n       bankadjtype_name, formatDate(bankadj_date) AS f_date, bankadj_docnumber,\n       formatMoney(bankadj_amount) AS f_amount\n  FROM bankadj LEFT OUTER JOIN bankaccnt ON (bankadj_bankaccnt_id=bankaccnt_id)\n               LEFT OUTER JOIN bankadjtype ON (bankadj_bankadjtype_id=bankadjtype_id)\n WHERE ( (NOT bankadj_posted)\n   AND   (bankadj_bankaccnt_id=&lt;? value(&quot;bankaccnt_id&quot;) ?>) );</sql>\n </querysource>\n <rpthead>\n  <height>121</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>115</ystart>\n   <xend>745</xend>\n   <yend>115</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>100</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>5</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Bank Adjustment Edit List</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>100</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Dist. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>100</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bank Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>100</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>100</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Adj. Type</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>9</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Dist. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Adj. Type</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bank Account</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>155</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_bank</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bankadjtype_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>340</x>\n     <y>0</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bankadj_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>250</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_date</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102472
 
293     BankrecHistory  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Bank Reconciliation History</title>\n <name>BankrecHistory</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>reconciled</name>\n  <mqlgroup>bankrecHistory</mqlgroup>\n  <mqlname>reconciled</mqlname>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT (bankaccnt_name || '-' || bankaccnt_descrip) AS f_bankaccnt,\n       (formatDate(bankrec_opendate) || '-' || formatDate(bankrec_enddate)) AS f_bankrec,\n       bankrec_username AS f_username, formatDate(bankrec_postdate) AS f_postdate,\n       formatDate(bankrec_opendate) AS f_opendate,\n       formatDate(bankrec_enddate) AS f_enddate,\n       formatMoney(bankrec_openbal) AS f_openbal,\n       formatMoney(bankrec_endbal) AS f_endbal,\n       text('Opening Balance') AS f_opendescrip,\n       text('Ending Balance') AS f_enddescrip\n  FROM bankrec, bankaccnt\n WHERE ((bankrec_bankaccnt_id=bankaccnt_id)\n   AND  (bankrec_id=&lt;? value("bankrec_id") ?>));</sql>\n </querysource>\n <querysource>\n  <name>Subtotal</name>\n  <sql>SELECT \n   formatMoney(COALESCE(MAX(selrec.bankrec_endbal) +\n   SUM(currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1),0)) AS amount\n--   SUM(currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date)),0)) AS amount\n FROM gltrans\n   JOIN bankaccnt ON (bankaccnt_accnt_id = gltrans_accnt_id)\n   JOIN bankrec selrec ON ((selrec.bankrec_bankaccnt_id = bankaccnt_id)\n                       AND (selrec.bankrec_id=&lt;? value("bankrec_id") ?>))\n   LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='GL')\n                              AND (bankrecitem_source_id=gltrans_id))\n   LEFT OUTER JOIN bankrec actrec ON (actrec.bankrec_id = bankrecitem_bankrec_id)\n WHERE ((COALESCE(actrec.bankrec_postdate,endoftime()) > COALESCE(selrec.bankrec_postdate,now()))\n AND (gltrans_doctype='CK'))</sql>\n </querysource>\n <querysource>\n  <name>ActualAmount</name>\n  <sql>SELECT \n   formatMoney(COALESCE(MAX(selrec.bankrec_endbal) +\n   SUM(currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1),0)) AS amount\n--   SUM(currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date)),0)) AS amount\n FROM gltrans\n   JOIN bankaccnt ON (bankaccnt_accnt_id = gltrans_accnt_id)\n   JOIN bankrec selrec ON ((selrec.bankrec_bankaccnt_id = bankaccnt_id)\n                       AND (selrec.bankrec_id=&lt;? value("bankrec_id") ?>))\n   LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='GL')\n\n                              AND (bankrecitem_source_id=gltrans_id))\n   LEFT OUTER JOIN bankrec actrec ON (actrec.bankrec_id = bankrecitem_bankrec_id)\n WHERE (COALESCE(actrec.bankrec_postdate,endoftime()) > COALESCE(selrec.bankrec_postdate,now()))</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>unreconciled</name>\n  <mqlgroup>bankrecHistory</mqlgroup>\n  <mqlname>unreconciled</mqlname>\n </querysource>\n <rpthead>\n  <height>166</height>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>100</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>50</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Posted By:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>148</y>\n    <width>535</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_opendescrip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Number/Notes</string>\n  </label>\n  <field>\n   <rect>\n    <x>145</x>\n    <y>65</y>\n    <width>220</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_bankrec</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>115</ystart>\n   <xend>745</xend>\n   <yend>115</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>65</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Date Posted:</string>\n  </label>\n  <field>\n   <rect>\n    <x>145</x>\n    <y>50</y>\n    <width>245</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_bankaccnt</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>65</y>\n    <width>220</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_postdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>100</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Dist. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>23</x>\n    <y>64</y>\n    <width>117</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Bank Rec. Post:</string>\n  </label>\n  <field>\n   <rect>\n    <x>9</x>\n    <y>148</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_opendate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>50</y>\n    <width>220</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_username</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>40</x>\n    <y>50</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Bark Account:</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>5</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Bank Reconciliation History</string>\n  </label>\n  <field>\n   <rect>\n    <x>644</x>\n    <y>148</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_openbal</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>125</y>\n    <width>121</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>9</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reconciled</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>0</height>\n </pghead>\n <pghead>\n  <height>31</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>0</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Number/Notes</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Dist. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n </pghead>\n <section>\n  <name>reconciled</name>\n  <group>\n   <name>reconciled-group</name>\n   <column>amount_xtnumericrole</column>\n   <foot>\n    <height>21</height>\n    <field>\n     <rect>\n      <x>645</x>\n      <y>3.28</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>f_endbal</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>3.28</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>f_enddate</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>100</x>\n      <y>3.28</y>\n      <width>200</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>f_enddescrip</column>\n     </data>\n    </field>\n   </foot>\n  </group>\n  <group>\n   <name>reconciled-type</name>\n   <column>sort</column>\n   <head>\n    <height>27</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>6.78</y>\n      <width>94</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>reconciled</query>\n      <column>type</column>\n     </data>\n    </field>\n   </head>\n   <foot>\n    <height>18</height>\n    <field>\n     <rect>\n      <x>645</x>\n      <y>2</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>reconciled</query>\n      <column>amount</column>\n     </data>\n     <format builtin="true">qty</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <field>\n     <rect>\n      <x>438</x>\n      <y>2</y>\n      <width>168</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>reconciled</query>\n      <column>type</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>399</x>\n      <y>2</y>\n      <width>49</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>TOTAL</string>\n    </label>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>reconciled</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>206</x>\n     <y>0</y>\n     <width>430</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>reconciled</query>\n     <column>notes</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>reconciled</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>reconciled</query>\n     <column>f_date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>-0.182</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>reconciled</query>\n     <column>gltrans_docnumber</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>unreconciled</name>\n  <group>\n   <name>unreconciled-group</name>\n   <column>amount_xtnumericrole</column>\n   <head>\n    <height>33</height>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>10.3</y>\n      <width>121</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>9</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Unreconciled</string>\n    </label>\n   </head>\n   <foot>\n    <height>136.499</height>\n    <label>\n     <rect>\n      <x>450</x>\n      <y>43</y>\n      <width>162</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Checks in Circulation:</string>\n    </label>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>12.5</y>\n      <width>235</width>\n      <height>15.5</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>9</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>General Legder Reconciliation</string>\n    </label>\n    <label>\n     <rect>\n      <x>450</x>\n      <y>73</y>\n      <width>163</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Deposits in Circulation:</string>\n    </label>\n    <label>\n     <rect>\n      <x>395</x>\n      <y>103</y>\n      <width>219</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Actual Account Balance:</string>\n    </label>\n    <label>\n     <rect>\n      <x>450</x>\n      <y>28</y>\n      <width>162</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Ending Reconciled Balance:</string>\n    </label>\n    <field>\n     <rect>\n      <x>640</x>\n      <y>28</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>f_endbal</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>640</x>\n      <y>43</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>unreconciled</query>\n      <column>rtcheck</column>\n     </data>\n     <format builtin="true">money</format>\n     <tracktotal/>\n    </field>\n    <label>\n     <rect>\n      <x>555</x>\n      <y>58</y>\n      <width>56</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Subtotal:</string>\n    </label>\n    <field>\n     <rect>\n      <x>640</x>\n      <y>58</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>Subtotal</query>\n      <column>amount</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>640</x>\n      <y>73</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>unreconciled</query>\n      <column>rtdep</column>\n     </data>\n     <format builtin="true">money</format>\n     <tracktotal/>\n    </field>\n    <field>\n     <rect>\n      <x>640</x>\n      <y>88</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>unreconciled</query>\n      <column>rtadj</column>\n     </data>\n     <format builtin="true">money</format>\n     <tracktotal/>\n    </field>\n    <field>\n     <rect>\n      <x>640</x>\n      <y>103</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>ActualAmount</query>\n      <column>amount</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>435</x>\n      <y>88</y>\n      <width>177</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Adjustments in Circulation:</string>\n    </label>\n   </foot>\n  </group>\n  <group>\n   <name>unreconciled-type</name>\n   <column>type</column>\n   <head>\n    <height>26.0233</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>4.9</y>\n      <width>94</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>unreconciled</query>\n      <column>type</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>unreconciled</query>\n   </key>\n   <height>21.9767</height>\n   <field>\n    <rect>\n     <x>204</x>\n     <y>0.687</y>\n     <width>430</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>unreconciled</query>\n     <column>notes</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0.687</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>unreconciled</query>\n     <column>f_date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>98.5</x>\n     <y>0.687</y>\n     <width>94</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>unreconciled</query>\n     <column>gltrans_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>643</x>\n     <y>0.687</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>unreconciled</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>15</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>80</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>143</height>\n </rptfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102473
 
263     BillingSelections       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Billing Selections</title>\n <name>BillingSelections</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT cobmisc_id,\n       cohead_id,\n       COALESCE(TEXT(cobmisc_invcnumber), '?') AS docnumber,\n       cohead_number,\n       cust_number,\n       cust_name\n  FROM cobmisc, cohead, custinfo\n WHERE ((cobmisc_cohead_id=cohead_id)\n   AND (cohead_cust_id=cust_id)\n   AND (NOT cobmisc_posted) )\nORDER BY docnumber;</sql>\n </querysource>\n <rpthead>\n  <height>123</height>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>99</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>8</x>\n    <y>99</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>112</ystart>\n   <xend>745</xend>\n   <yend>112</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>5</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Billing Selections</string>\n  </label>\n  <label>\n   <rect>\n    <x>218</x>\n    <y>99</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust Name</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>102</height>\n </pghead>\n <pghead>\n  <height>80</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>6</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order #</string>\n  </label>\n  <label>\n   <rect>\n    <x>216</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>111</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust. #</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>1</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>1</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>214</x>\n     <y>1</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102474
 
312     ContactsMasterList      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Contacts Master List</title>\n <name>ContactsMasterList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>contacts</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>143</height>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>5</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Contacts Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>545</x>\n    <y>123</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Phone 2</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>123</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>123</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Phone</string>\n  </label>\n  <line>\n   <xstart>6</xstart>\n   <ystart>137</ystart>\n   <xend>995</xend>\n   <yend>137</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>123</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>First Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>120</x>\n    <y>123</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Last Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>123</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Fax</string>\n  </label>\n  <label>\n   <rect>\n    <x>725</x>\n    <y>123</y>\n    <width>145</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Email</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>123</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account #</string>\n  </label>\n  <label>\n   <rect>\n    <x>875</x>\n    <y>123</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Web Address</string>\n  </label>\n  <text>\n   <rect>\n    <x>5</x>\n    <y>33</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>First Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>326</x>\n    <y>0</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>994</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Phone</string>\n  </label>\n  <label>\n   <rect>\n    <x>545</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Phone 2</string>\n  </label>\n  <label>\n   <rect>\n    <x>875</x>\n    <y>0</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Web Address</string>\n  </label>\n  <label>\n   <rect>\n    <x>120</x>\n    <y>0</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Last Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>725</x>\n    <y>0</y>\n    <width>145</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Email</string>\n  </label>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Fax</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>250</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>crmacct_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>cntct_first_name</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>725</x>\n     <y>0</y>\n     <width>145</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>cntct_email</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>875</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>cntct_webaddr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>545</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>cntct_phone2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>450</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>cntct_phone</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>120</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>cntct_last_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>625</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>cntct_fax</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>325</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>crmacct_name</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>945</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>855</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102475
 
155     BriefEarnedCommissions  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Brief Earned Commissions</title>\n <name>BriefEarnedCommissions</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("salesrep_id") ?>\n         ( SELECT salesrep_name\n             FROM salesrep\n            WHERE (salesrep_id=&lt;? value("salesrep_id") ?>) )\n       &lt;? else ?>\n         text('All Sales Reps')\n       &lt;? endif ?>\n       AS salesrep,\n       formatDate(&lt;? value("startDate") ?>) AS startdate,\n       formatDate(&lt;? value("endDate") ?>) AS enddate;</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>briefEarnedCommission</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>140</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cust. #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>385</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>salesrep</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Base Commision</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Base Ext. Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>100</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sales Rep:</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Invc. Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>200</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sales Rep.</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>120</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Brief Earned Commissions</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Invc. Date</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cust. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Invc. Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>5</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sales Rep.</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Commision</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Invc. Date</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>345</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohist_ordernumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_sumbaseextprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_sumbasecommission</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_invcdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>220</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>salesrep_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohist_invcnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>salesrep_number</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>468</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Totals:</string>\n  </label>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>sumbaseextprice</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>sumbasecommission</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n </rptfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102476
 
360     Budget  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Budget</title>\n <name>Budget</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT formatDate(period_start) AS f_firstperiod,\n       formatDate(period_end) AS f_lastperiod,\n       formatGLAccountLong(budgitem_accnt_id) AS f_accnt,\n       formatMoney(budgitem_amount) AS f_amount\n  FROM budgitem \n  JOIN period ON (budgitem_period_id=period_id)\n WHERE(budgitem_budghead_id=&lt;? value("budghead_id") ?>)\n ORDER BY period_start, f_accnt;</sql>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT budghead_name,\n       budghead_descrip\n  FROM budghead\n WHERE(budghead_id=&lt;? value("budghead_id") ?>);</sql>\n </querysource>\n <rpthead>\n  <height>161</height>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>140</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>140</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>160</x>\n    <y>80</y>\n    <width>375</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>budghead_descrip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>140</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <field>\n   <rect>\n    <x>160</x>\n    <y>65</y>\n    <width>375</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>budghead_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>140</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>End Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>155</ystart>\n   <xend>745</xend>\n   <yend>155</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>55</x>\n    <y>65</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Budget Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>55</x>\n    <y>80</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Description:</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Budget</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>End Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_lastperiod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_firstperiod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_accnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>370</x>\n     <y>0</y>\n     <width>375</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102477
 
359     BudgetsMasterList       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Budgets Master List</title>\n <name>BudgetsMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT formatDate(min(period_start)) AS f_firstperiod,\n       formatDate(max(period_end)) AS f_lastperiod,\n       budghead_name,\n       budghead_descrip\n  FROM budghead LEFT OUTER JOIN budgitem \n         JOIN period ON (budgitem_period_id=period_id)\n       ON (budgitem_budghead_id=budghead_id)\n GROUP BY budghead_name, budghead_descrip\n ORDER BY budghead_name;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>End Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Budgets Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>End Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>budghead_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_firstperiod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>370</x>\n     <y>0</y>\n     <width>375</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>budghead_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_lastperiod</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102478
 
160     BuyCard \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Buy Card</title>\n <name>BuyCard</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT vend_number, vend_name,\n       itemsrc_vend_item_number,\n       itemsrc_vend_item_descrip\n  FROM vendinfo, itemsrc\n WHERE ((vend_id=&lt;? value("vend_id") ?>)\n   AND  (itemsrc_id=&lt;? value("itemsrc_id") ?>) )</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT poitem_id, pohead_number, poitem_linenumber,\n       CASE WHEN(poitem_status='C') THEN TEXT('Closed')\n            WHEN(poitem_status='U') THEN TEXT('Unposted')\n            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered>(poitem_qty_received-poitem_qty_returned))) THEN TEXT('Partial')\n            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered=(poitem_qty_received-poitem_qty_returned))) THEN TEXT('Received')\n            WHEN(poitem_status='O') THEN TEXT('Open')\n            ELSE poitem_status\n       END AS poitemstatus,\n       formatDate(poitem_duedate) as f_duedate,\n       formatQty(poitem_qty_ordered) as f_qtyord,\n       formatQty(COALESCE(SUM(recv_qty), 0)) as f_qty,\n       formatPrice(poitem_unitprice) as f_unitprice\nFROM pohead, poitem LEFT OUTER JOIN recv ON (recv_orderitem_id=poitem_id)\nWHERE ( (poitem_pohead_id=pohead_id)\n AND (recv_order_type='PO')\n AND (pohead_vend_id=&lt;? value("vend_id") ?>)\n AND (poitem_vend_item_number=(select itemsrc_vend_item_number from itemsrc where itemsrc_id=&lt;? value("itemsrc_id") ?>)) ) \nGROUP BY poitem_id, pohead_number, poitem_linenumber,\n         poitem_status, poitem_qty_received, poitem_qty_returned,\n         poitem_duedate, poitem_qty_ordered, poitem_unitprice\nORDER BY pohead_number, poitem_linenumber;</sql>\n </querysource>\n <querysource>\n  <name>foot</name>\n  <sql>SELECT itemsrc_comments\n  FROM itemsrc\n WHERE itemsrc_id=&lt;? value("itensrc_id") ?>;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>114</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>itemsrc_vend_item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>114</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor Part #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>335</x>\n    <y>5</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Buy Card</string>\n  </label>\n  <label>\n   <rect>\n    <x>114</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>65</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>85</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Unit Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>135</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor Description:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>135</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>itemsrc_vend_item_descrip</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Unit Cost</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>114</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyord</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>455</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_unitprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>pohead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_linenumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>370</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>114</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitemstatus</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>104</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>31</height>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>5</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Comments:</string>\n  </label>\n  <text>\n   <rect>\n    <x>125</x>\n    <y>5</y>\n    <width>615</width>\n    <height>20</height>\n   </rect>\n   <bottompad>5</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>itemsrc_comments</column>\n   </data>\n  </text>\n </rptfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102479
 
370     CCReceipt       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Credit Card Receipt</title>\n <name>CCReceipt</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>100</topmargin>\n <bottommargin>100</bottommargin>\n <rightmargin>100</rightmargin>\n <leftmargin>100</leftmargin>\n <querysource>\n  <name>header</name>\n  <sql>SELECT remitto.*,\n       formatAddr(remitto_address1, remitto_address2,\n                  remitto_address3, remitto_citystatezip,\n                  remitto_country) AS remitto_addr\nFROM remitto;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT *,\n       formatbytea(decrypt(setbytea(ccard_name),\n                           setbytea(&lt;? value("key") ?>),\n                           'bf')) AS holder,\n       formatccnumber(decrypt(setbytea(ccard_number),\n                              setbytea(&lt;? value("key") ?>),\n                              'bf')) AS xxxx,\n       CASE WHEN (ccpay_type='A') THEN &lt;? value("preauth") ?>\n            WHEN (ccpay_type='C') THEN &lt;? value("charge") ?>\n            WHEN (ccpay_type='R') THEN &lt;? value("refund") ?>\n            ELSE ccpay_type\n       END AS type,\n       CASE WHEN (ccpay_status='A') THEN &lt;? value("authorized") ?>\n            WHEN (ccpay_status='C') THEN &lt;? value("approved") ?>\n            WHEN (ccpay_status='D') THEN &lt;? value("declined") ?>\n            WHEN (ccpay_status='R') THEN &lt;? value("reversed") ?>\n            WHEN (ccpay_status='V') THEN &lt;? value("voided") ?>\n            WHEN (ccpay_status='X') THEN &lt;? value("noapproval") ?>\n            ELSE ccpay_status\n       END AS status\n\nFROM ccpay JOIN\n     ccard ON (ccpay_ccard_id=ccard_id) JOIN\n     custinfo ON (ccard_cust_id=cust_id)\nWHERE (ccpay_id=&lt;? value("ccpay_id") ?>);</sql>\n </querysource>\n <pghead>\n  <height>101</height>\n  <text>\n   <rect>\n    <x>0</x>\n    <y>60</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <bottompad>40</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>header</query>\n    <column>remitto_addr</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>20</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Printed:</string>\n  </label>\n  <field>\n   <rect>\n    <x>0</x>\n    <y>40</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>header</query>\n    <column>remitto_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Credit Card Receipt</string>\n  </label>\n  <field>\n   <rect>\n    <x>160</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>Header</name>\n  <detail>\n   <key>\n    <query>header</query>\n   </key>\n   <height>101</height>\n  </detail>\n </section>\n <section>\n  <name>Detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>231</height>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>160</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ccpay_r_ref</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>160</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Approval Code:</string>\n   </label>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>200</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ccpay_r_ordernum</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>40</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Card Number:</string>\n   </label>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>140</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Status:</string>\n   </label>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>60</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ccpay_transaction_datetime</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>80</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>type</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>100</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ccpay_amount</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>200</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Order:</string>\n   </label>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Customer Name:</string>\n   </label>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>100</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Amount:</string>\n   </label>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>60</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Transaction Date:</string>\n   </label>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>180</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ccpay_by_username</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>20</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>holder</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>80</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Transaction Type:</string>\n   </label>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>180</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>By:</string>\n   </label>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>140</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>status</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>20</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Cardholder:</string>\n   </label>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>40</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>xxxx</column>\n    </data>\n   </field>\n  </detail>\n </section>\n</report>\n            0       2014-10-06 19:47:03.678943
102480
 
313     CRMAccountMasterList    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Accounts Master List</title>\n <name>CRMAccountMasterList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>crmaccounts</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>160</height>\n  <label>\n   <rect>\n    <x>115</x>\n    <y>125</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>125</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Competitor</string>\n  </label>\n  <label>\n   <rect>\n    <x>680</x>\n    <y>125</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Tax Auth</string>\n  </label>\n  <line>\n   <xstart>4.76465</xstart>\n   <ystart>156.293</ystart>\n   <xend>744.765</xend>\n   <yend>156.293</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>125</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Partner</string>\n  </label>\n  <label>\n   <rect>\n    <x>355</x>\n    <y>125</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Accounts</string>\n  </label>\n  <label>\n   <rect>\n    <x>420</x>\n    <y>125</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Prospect</string>\n  </label>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>125</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>125</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account #</string>\n  </label>\n  <label>\n   <rect>\n    <x>115</x>\n    <y>140</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Contact Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>140</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Phone</string>\n  </label>\n  <label>\n   <rect>\n    <x>420</x>\n    <y>140</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Email</string>\n  </label>\n  <text>\n   <rect>\n    <x>5</x>\n    <y>40</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>34</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account #</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Partner</string>\n  </label>\n  <label>\n   <rect>\n    <x>115</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account Name</string>\n  </label>\n  <line>\n   <xstart>4.23535</xstart>\n   <ystart>30.2931</ystart>\n   <xend>744.235</xend>\n   <yend>30.2931</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>419</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Prospect</string>\n  </label>\n  <label>\n   <rect>\n    <x>678.471</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Tax Auth</string>\n  </label>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>-7.10543e-15</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>355</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Competitor</string>\n  </label>\n  <label>\n   <rect>\n    <x>114.637</x>\n    <y>13.8197</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Contact Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>301</x>\n    <y>13.7586</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Phone</string>\n  </label>\n  <label>\n   <rect>\n    <x>418.235</x>\n    <y>13.7586</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Email</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>32</height>\n   <field>\n    <rect>\n     <x>550</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>competitor</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>crmacct_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>partner</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>418.235</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prospect</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>115</x>\n     <y>0</y>\n     <width>234</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>crmacct_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>680</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>taxauth</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>355</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>485</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>302.941</x>\n     <y>15.3526</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cntct_phone</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>115</x>\n     <y>15.3526</y>\n     <width>185</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cntct_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>417.941</x>\n     <y>15.3526</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cntct_email</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102481
 
56      CapacityUOMsByClassCode \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Capacity UOMs By Class Code</title>\n <name>CapacityUOMsByClassCode</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("classcode_id") ?>\n         ( SELECT (classcode_code || '-' || classcode_descrip)\n             FROM classcode\n            WHERE (classcode_id=&lt;? value("classcode_id") ?>) )\n       &lt;? elseif exists("classcode_pattern") ?>\n         text(&lt;? value("classcode_pattern") ?>)\n       &lt;? else ?>\n         text('All Class Codes')\n       &lt;? endif ?>\n       AS classcode;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT classcode_code,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       uom_name,\n       itemcapuom(item_id) AS capuom,\n       formatRatio(itemcapinvrat(item_id)) AS capratio,\n       itemaltcapuom(item_id) AS altcapuom,\n       formatRatio(itemaltcapinvrat(item_id)) AS altcapratio,\n       itemsellinguom(item_id) AS shipuom,\n       formatRatio(iteminvpricerat(item_id)) AS shipratio\n  FROM item, classcode, uom\n WHERE ((item_classcode_id=classcode_id)\n   AND (item_inv_uom_id=uom_id)\n&lt;? if exists("classcode_id") ?>\n   AND (classcode_id=&lt;? value("classcode_id") ?>)\n&lt;? elseif exists("classcode_pattern") ?>\n   AND (classcode_code ~ &lt;? value("classcode_pattern") ?>)\n&lt;? endif ?>\n)\nORDER BY classcode_code, item_number;\n    </sql>\n </querysource>\n <rpthead>\n  <height>234</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Class Code</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>120</y>\n    <width>565</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>classcode</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inventory UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv./Alt. Cap. Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>215</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Capacity UOMs by Class Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>120</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Class Code(s):</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipping UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv./Cap. Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Capacity UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv./Ship. Ratio</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>228</ystart>\n   <xend>745</xend>\n   <yend>228</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Alt. Capacity UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>200</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv./Ship. Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>0</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipping UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>15</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Class Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Alt. Capacity UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Capacity UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv./Cap. Ratio</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inventory UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv./Alt. Cap. Ratio</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipratio</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>classcode_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>capuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>altcapuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>altcapratio</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>15</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>capratio</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>30</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102482
 
57      CapacityUOMsByProductCategory   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Capacity UOMs by Product Category</title>\n <name>CapacityUOMsByProductCategory</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT prodcat_code,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       uom_name,\n       itemcapuom(item_id) AS capuom,\n       formatRatio(itemcapinvrat(item_id)) AS capratio,\n       itemaltcapuom(item_id) AS altcapuom,\n       formatRatio(itemaltcapinvrat(item_id)) AS altcapratio,\n       itemsellinguom(item_id) AS shipuom,\n       formatRatio(iteminvpricerat(item_id)) AS shipratio\n  FROM item, prodcat, uom\n WHERE ((item_sold)\n   AND (item_inv_uom_id=uom_id)\n   AND (item_prodcat_id=prodcat_id)\n&lt;? if exists("prodcat_id") ?>\n   AND (prodcat_id=&lt;? value("prodcat_id") ?>)\n&lt;? elseif exists("prodcat_pattern") ?>\n   AND (prodcat_code ~ &lt;? value("prodcat_pattern") ?>)\n&lt;? endif ?>\n)\nORDER BY prodcat_code, item_number;\n    </sql>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("prodcat_id") ?>\n         ( SELECT (prodcat_code||'-'||prodcat_descrip)\n             FROM prodcat\n            WHERE (prodcat_id=&lt;? value("prodcat_id") ?>) )\n       &lt;? elseif exists("prodcat_pattern") ?>\n         text(&lt;? value("prodcat_pattern") ?>)\n       &lt;? else ?>\n         text('All Product Categories')\n       &lt;? endif ?>\n       AS prodcat;</sql>\n </querysource>\n <rpthead>\n  <height>234</height>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>10</y>\n    <width>458</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Capacity UOMs by Product Category</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Alt. Capacity UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv./Alt. Cap. Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>215</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Prod. Cat.</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Capacity UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inventory UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipping UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>200</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>120</y>\n    <width>145</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Product Category(ies):</string>\n  </label>\n  <field>\n   <rect>\n    <x>160</x>\n    <y>120</y>\n    <width>483</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prodcat</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv./Cap. Ratio</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>228</ystart>\n   <xend>745</xend>\n   <yend>228</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv./Ship. Ratio</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv./Ship. Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Prod. Cat.</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inventory UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Capacity UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>0</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipping UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>15</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv./Cap. Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Alt. Capacity UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv./Alt. Cap. Ratio</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipratio</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prodcat_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>15</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>altcapratio</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>0</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>capratio</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>altcapuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>30</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>capuom</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102483
 
187     CharacteristicsMasterList       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Characteristics Master List</title>\n <name>CharacteristicsMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT char_id,\n       char_name,\n       formatBoolYN(char_items) AS f_items,\n       formatBoolYN(char_options) AS f_options,\n       formatBoolYN(char_attributes) AS f_attributes,\n       formatBoolYN(char_lotserial) AS f_lotserial,\n       char_notes\n  FROM char\nORDER BY char_name;</sql>\n </querysource>\n <rpthead>\n  <height>86</height>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>65</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lot/Serial</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>65</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Options</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>65</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>50</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>may be used for</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>65</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Attributes</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>65</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Notes</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>80</ystart>\n   <xend>745</xend>\n   <yend>80</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Characteristics Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>65</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Items</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>20</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Items</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>5</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>may be used for</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>20</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Attributes</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>20</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Options</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>20</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>20</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Notes</string>\n  </label>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>20</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lot/Serial</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_options</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>220</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_items</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>char_name</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>320</width>\n     <height>13</height>\n    </rect>\n    <bottompad>5</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>char_notes</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_attributes</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>370</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_lotserial</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102484
 
366     CheckMultiPage  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Sample Check Format - 3 Part - MC - Remit - Multi Page</title>\n <name>CheckMultiPage</name>\n <description>Sample Check Format - 3 Part - MC - Uses primary Vendor or address with names: REMIT, Remit, or remit if one exists. Multi-Page.</description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>0</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>Head</name>\n  <sql>SELECT\ncheckhead_id, checkhead_number, checkhead_for AS memo,\nformatDate(checkhead_checkdate) AS f_checkdate,\nformatMoney(checkhead_amount) AS f_amount,\nINITCAP(spellAmount(checkhead_amount, curr_id)) AS f_words,\nCASE WHEN(checkhead_void) THEN TEXT('V O I D')\n     ELSE TEXT('')\nEND AS f_void,\nCASE WHEN checkhead_recip_type = 'C' THEN (SELECT cust_number\n                                           FROM custinfo\n                                           WHERE (cust_id=checkhead_recip_id))\n     WHEN checkhead_recip_type = 'T' THEN (SELECT taxauth_code\n                                           FROM taxauth\n                                           WHERE (taxauth_id=checkhead_recip_id))\n     WHEN checkhead_recip_type = 'V' THEN (SELECT vend_number\n                                           FROM vendinfo\n                                           WHERE (vend_id=checkhead_recip_id))\n     ELSE 'Unknown Recipient Type'\nEND AS recip_number,\nformatAddr(CASE WHEN checkhead_recip_type = 'C' THEN\n                                         (SELECT cntct_addr_id\n                                          FROM cntct, custinfo\n                                          WHERE ((cust_cntct_id=cntct_id)\n                                            AND  (cust_id=checkhead_recip_id)))\n                WHEN checkhead_recip_type = 'T' THEN \n                                         (SELECT taxauth_addr_id\n                                          FROM taxauth\n                                          WHERE (taxauth_id=checkhead_recip_id))\n                WHEN checkhead_recip_type = 'V' THEN\n                        COALESCE((SELECT vendaddr_addr_id\n                                  FROM vendaddrinfo\n                                  WHERE ((UPPER(vendaddr_code)='REMIT')\n                                    AND  (vendaddr_vend_id=checkhead_recip_id))),\n                                 (SELECT vend_addr_id\n                                  FROM vendinfo\n                                  WHERE (vend_id=checkhead_recip_id)))\n           END) AS check_address,\nCASE WHEN checkhead_recip_type = 'C' THEN (SELECT cust_name\n                                           FROM custinfo\n                                           WHERE cust_id=checkhead_recip_id)\n     WHEN checkhead_recip_type = 'T' THEN (SELECT taxauth_name\n                                           FROM taxauth\n                                           WHERE taxauth_id=checkhead_recip_id)\n     WHEN checkhead_recip_type = 'V' THEN\n                         COALESCE((SELECT vendaddr_name\n                                   FROM vendaddrinfo\n                                   WHERE ((UPPER(vendaddr_code)='REMIT')\n                                     AND  (vendaddr_vend_id=checkhead_recip_id))),\n                                  (SELECT vend_name\n                                   FROM vendinfo\n                                   WHERE (vend_id=checkhead_recip_id)))\nEND AS recip_name, \ncurr_symbol, curr_abbr, curr_name\nFROM checkhead, curr_symbol\nWHERE ((checkhead_curr_id = curr_id)\n   AND (checkhead_id=&lt;? value("checkhead_id") ?>) );\n</sql>\n </querysource>\n <querysource>\n  <name>CheckDetail</name>\n  <sql>SELECT checkdata_page,\n       checkdata_checknumber,\n       checkdata_checkwords,\n       checkdata_checkdate,\n       checkdata_checkamount,\n       checkdata_checkcurrsymbol,\n       checkdata_checkcurrabbr,\n       checkdata_checkcurrname,\n       checkdata_checkpayto,\n       checkdata_checkaddress,\n       checkdata_checkmemo,\n       checkdata_docnumber,\n       checkdata_docreference,\n       checkdata_docdate,\n       checkdata_docamount,\n       checkdata_docdiscount,\n       checkdata_docnetamount\n  FROM checkDetailFormatted(&lt;? value("checkhead_id") ?>, 12);</sql>\n </querysource>\n <section>\n  <name>Check</name>\n  <group>\n   <name>Line Detail</name>\n   <column>checkdata_page</column>\n   <pagebreak when="after foot" />\n   <head>\n    <height>351</height>\n    <field>\n     <rect>\n      <x>175</x>\n      <y>50</y>\n      <width>120</width>\n      <height>250</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <wordwrap/>\n     <left/>\n     <top/>\n     <data>\n      <query>CheckDetail</query>\n      <column>checkdata_docreference</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>490</x>\n      <y>25</y>\n      <width>55</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Amount:</string>\n    </label>\n    <field>\n     <rect>\n      <x>555</x>\n      <y>50</y>\n      <width>80</width>\n      <height>250</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <wordwrap/>\n     <right/>\n     <top/>\n     <data>\n      <query>CheckDetail</query>\n      <column>checkdata_docdiscount</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>85</x>\n      <y>325</y>\n      <width>660</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Head</query>\n      <column>memo</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>645</x>\n      <y>50</y>\n      <width>100</width>\n      <height>250</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <wordwrap/>\n     <right/>\n     <top/>\n     <data>\n      <query>CheckDetail</query>\n      <column>checkdata_docnetamount</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>305</x>\n      <y>25</y>\n      <width>147</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Context Query</query>\n      <column>report_date</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>505</x>\n      <y>305</y>\n      <width>75</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Check Total:</string>\n    </label>\n    <label>\n     <rect>\n      <x>20</x>\n      <y>325</y>\n      <width>60</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Memo:</string>\n    </label>\n    <label>\n     <rect>\n      <x>675</x>\n      <y>25</y>\n      <width>70</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Net Amount:</string>\n    </label>\n    <field>\n     <rect>\n      <x>5</x>\n      <y>50</y>\n      <width>155</width>\n      <height>250</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <wordwrap/>\n     <left/>\n     <top/>\n     <data>\n      <query>CheckDetail</query>\n      <column>checkdata_docnumber</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>145</x>\n      <y>0</y>\n      <width>175</width>\n      <height>25</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Head</query>\n      <column>recip_name</column>\n     </data>\n    </field>\n    <line>\n     <xstart>5</xstart>\n     <ystart>45</ystart>\n     <xend>745</xend>\n     <yend>45</yend>\n     <weight>0</weight>\n    </line>\n    <line>\n     <xstart>450</xstart>\n     <ystart>305</ystart>\n     <xend>745</xend>\n     <yend>305</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>650</x>\n      <y>0</y>\n      <width>95</width>\n      <height>25</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Head</query>\n      <column>checkhead_number</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>640</x>\n      <y>305</y>\n      <width>104</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <data>\n      <query>Head</query>\n      <column>f_amount</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>444</x>\n      <y>50</y>\n      <width>100</width>\n      <height>250</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <wordwrap/>\n     <right/>\n     <top/>\n     <data>\n      <query>CheckDetail</query>\n      <column>checkdata_docamount</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>0</y>\n      <width>135</width>\n      <height>25</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Head</query>\n      <column>recip_number</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>580</x>\n      <y>305</y>\n      <width>55</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <data>\n      <query>Head</query>\n      <column>curr_symbol</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>310</x>\n      <y>50</y>\n      <width>100</width>\n      <height>250</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <wordwrap/>\n     <left/>\n     <top/>\n     <data>\n      <query>CheckDetail</query>\n      <column>checkdata_docdate</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>550</x>\n      <y>25</y>\n      <width>90</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Discount / Credit:</string>\n    </label>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>25</y>\n      <width>111</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Invoice / Document:</string>\n    </label>\n    <label>\n     <rect>\n      <x>590</x>\n      <y>0</y>\n      <width>61</width>\n      <height>25</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Check #</string>\n    </label>\n    <label>\n     <rect>\n      <x>175</x>\n      <y>25</y>\n      <width>75</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Reference:</string>\n    </label>\n   </head>\n   <foot>\n    <height>351</height>\n    <field>\n     <rect>\n      <x>645</x>\n      <y>0</y>\n      <width>95</width>\n      <height>25</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Head</query>\n      <column>checkhead_number</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>5</x>\n      <y>50</y>\n      <width>155</width>\n      <height>250</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <wordwrap/>\n     <left/>\n     <top/>\n     <data>\n      <query>CheckDetail</query>\n      <column>checkdata_docnumber</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>550</x>\n      <y>50</y>\n      <width>80</width>\n      <height>250</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <wordwrap/>\n     <right/>\n     <top/>\n     <data>\n      <query>CheckDetail</query>\n      <column>checkdata_docdiscount</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>170</x>\n      <y>25</y>\n      <width>75</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Reference:</string>\n    </label>\n    <label>\n     <rect>\n      <x>15</x>\n      <y>325</y>\n      <width>60</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Memo:</string>\n    </label>\n    <label>\n     <rect>\n      <x>585</x>\n      <y>0</y>\n      <width>61</width>\n      <height>25</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Check #</string>\n    </label>\n    <label>\n     <rect>\n      <x>670</x>\n      <y>25</y>\n      <width>70</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Net Amount:</string>\n    </label>\n    <line>\n     <xstart>445</xstart>\n     <ystart>305</ystart>\n     <xend>740</xend>\n     <yend>305</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>170</x>\n      <y>50</y>\n      <width>120</width>\n      <height>250</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <wordwrap/>\n     <left/>\n     <top/>\n     <data>\n      <query>CheckDetail</query>\n      <column>checkdata_docreference</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>440</x>\n      <y>50</y>\n      <width>100</width>\n      <height>250</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <wordwrap/>\n     <right/>\n     <top/>\n     <data>\n      <query>CheckDetail</query>\n      <column>checkdata_docamount</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>25</y>\n      <width>111</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Invoice / Document:</string>\n    </label>\n    <field>\n     <rect>\n      <x>80</x>\n      <y>325</y>\n      <width>660</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Head</query>\n      <column>memo</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>545</x>\n      <y>25</y>\n      <width>90</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Discount / Credit:</string>\n    </label>\n    <field>\n     <rect>\n      <x>575</x>\n      <y>305</y>\n      <width>55</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <data>\n      <query>Head</query>\n      <column>curr_symbol</column>\n     </data>\n    </field>\n    <line>\n     <xstart>5</xstart>\n     <ystart>45</ystart>\n     <xend>745</xend>\n     <yend>45</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>300</x>\n      <y>25</y>\n      <width>147</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Context Query</query>\n      <column>report_date</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>140</x>\n      <y>0</y>\n      <width>175</width>\n      <height>25</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Head</query>\n      <column>recip_name</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>640</x>\n      <y>50</y>\n      <width>100</width>\n      <height>250</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <wordwrap/>\n     <right/>\n     <top/>\n     <data>\n      <query>CheckDetail</query>\n      <column>checkdata_docnetamount</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>305</x>\n      <y>50</y>\n      <width>100</width>\n      <height>250</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <wordwrap/>\n     <left/>\n     <top/>\n     <data>\n      <query>CheckDetail</query>\n      <column>checkdata_docdate</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>485</x>\n      <y>25</y>\n      <width>55</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Amount:</string>\n    </label>\n    <label>\n     <rect>\n      <x>500</x>\n      <y>305</y>\n      <width>75</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Check Total:</string>\n    </label>\n    <field>\n     <rect>\n      <x>635</x>\n      <y>305</y>\n      <width>104</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <top/>\n     <data>\n      <query>Head</query>\n      <column>f_amount</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>5</x>\n      <y>0</y>\n      <width>135</width>\n      <height>25</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Head</query>\n      <column>recip_number</column>\n     </data>\n    </field>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>CheckDetail</query>\n   </key>\n   <height>292</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>100</y>\n     <width>225</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>CheckDetail</query>\n     <column>checkdata_checkpayto</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>15</x>\n     <y>40</y>\n     <width>560</width>\n     <height>30</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>12</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>CheckDetail</query>\n     <column>checkdata_checkwords</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>405</x>\n     <y>85</y>\n     <width>121</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>CheckDetail</query>\n     <column>checkdata_checkdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>80</x>\n     <y>260</y>\n     <width>650</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>CheckDetail</query>\n     <column>checkdata_checkmemo</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>5</x>\n     <y>260</y>\n     <width>75</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Memo:</string>\n   </label>\n   <text>\n    <rect>\n     <x>10</x>\n     <y>125</y>\n     <width>300</width>\n     <height>20</height>\n    </rect>\n    <bottompad>10</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>CheckDetail</query>\n     <column>checkdata_checkaddress</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>545</x>\n     <y>85</y>\n     <width>55</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>CheckDetail</query>\n     <column>checkdata_checkcurrsymbol</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>85</y>\n     <width>125</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>CheckDetail</query>\n     <column>checkdata_checkamount</column>\n    </data>\n   </field>\n  </detail>\n </section>\n</report>\n Sample Check Format - 3 Part - MC - Uses primary Vendor or address with names: REMIT, Remit, or remit if one exists. Multi-Page.        0       2014-10-06 19:47:03.678943
102485
 
277     CheckRegister   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Payment Register</title>\n <name>CheckRegister</name>\n <description></description>\n <parameter default="" active="false" type="" name="bankaccnt_id" ></parameter>\n <parameter default="" active="false" type="" name="endDate" ></parameter>\n <parameter default="" active="false" type="" name="startDate" ></parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT bankaccnt_name,\n       bankaccnt_descrip,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       curr_symbol\n  FROM bankaccnt, curr_symbol\n WHERE ((bankaccnt_id=&lt;? value("bankaccnt_id") ?>)\n   AND  (bankaccnt_curr_id = curr_id));</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT checkhead_id AS checkid,\n       CASE WHEN(checkhead_void) THEN -1\n            WHEN(checkhead_posted) THEN 1\n            ELSE 0\n       END AS extra,\n       -1 AS checkitem_id,\n       formatBoolYN(checkhead_void) AS f_void,\n       formatBoolYN(checkhead_misc) AS f_misc,\n       formatBoolYN(checkhead_printed) AS f_printed,\n       formatBoolYN(checkhead_posted) AS f_posted,\n       CASE when checkhead_number = -1 THEN\n         'Unspecified'\n       ELSE TEXT(checkhead_number) END AS number,\n       COALESCE(checkrecip_number || '-' || checkrecip_name,\n\t\tcheckhead_recip_type || '-' || checkhead_recip_id ) AS description,\n       formatDate(checkhead_checkdate) AS f_checkdate,\n       formatMoney(checkhead_amount) AS f_amount, \n       currConcat(checkhead_curr_id) AS currAbbr,\n       checkhead_number,\n       checkhead_ach_batch,\n       1 AS orderby\n  FROM checkhead LEFT OUTER JOIN\n       checkrecip ON ((checkhead_recip_id=checkrecip_id)\n\t\t AND  (checkhead_recip_type=checkrecip_type))\n WHERE ((checkhead_checkdate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n   AND   (checkhead_bankaccnt_id=&lt;? value("bankaccnt_id") ?>)\n   &lt;? if exists("check_number") ?>\n      AND   (CAST(checkhead_number AS text) ~ &lt;? value("check_number") ?>)\n   &lt;? endif ?>\n   &lt;? if exists("recip") ?>\n      &lt;? if exists("recip_type_v") ?>\n\t AND   (checkhead_recip_type = 'V' )\n      &lt;? endif ?>\n      &lt;? if exists("recip_type_c") ?>\n\t AND   (checkhead_recip_type = 'C' )\n      &lt;? endif ?>\n      &lt;? if exists("recip_type_t") ?>\n\t AND   (checkhead_recip_type = 'T' )\n      &lt;? endif ?>\n      &lt;? if exists("recip_id") ?>\n\t AND   (checkhead_recip_id = &lt;? value("recip_id") ?> )\n      &lt;? endif ?>\n   &lt;? endif ?> \n   )\n&lt;? if exists("showDetail") ?>\nUNION\nSELECT checkitem_checkhead_id AS checkid, 0 AS extra, checkitem_id,\n       '' AS f_void, '' AS f_misc, '' AS f_printed, '' AS f_posted,\n       checkitem_vouchernumber AS number,\n       checkitem_invcnumber AS description,\n       '' AS f_checkdate,\n       formatMoney(checkitem_amount) AS f_amount,\n       currConcat(checkitem_curr_id) AS currAbbr, \n       checkhead_number, \n       NULL,\n       2 AS orderby \n  FROM checkitem, checkhead \n WHERE ( (checkitem_checkhead_id=checkhead_id)\n   AND   (checkhead_checkdate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n   AND   (checkhead_bankaccnt_id=&lt;? value("bankaccnt_id") ?>)\n      &lt;? if exists("check_number") ?>\n      AND   (CAST(checkhead_number AS text) ~ &lt;? value("check_number") ?>)\n   &lt;? endif ?>\n   &lt;? if exists("recip") ?>\n      &lt;? if exists("recip_type_v") ?>\n         AND   (checkhead_recip_type = 'V' )\n      &lt;? endif ?>\n      &lt;? if exists("recip_type_c") ?>\n         AND   (checkhead_recip_type = 'C' )\n      &lt;? endif ?>\n      &lt;? if exists("recip_type_t") ?>\n         AND   (checkhead_recip_type = 'T' )\n      &lt;? endif ?>\n      &lt;? if exists("recip_id") ?>\n         AND   (checkhead_recip_id = &lt;? value("recip_id") ?> )\n      &lt;? endif ?>\n   &lt;? endif ?> )\n&lt;? endif ?>\n ORDER BY checkhead_number, checkid, orderby;</sql>\n </querysource>\n <querysource>\n  <name>total</name>\n  <sql>SELECT formatMoney(SUM(currToCurr(checkhead_curr_id, bankaccnt_curr_id, checkhead_amount, checkhead_checkdate))) AS f_amount,\n       currConcat(bankaccnt_curr_id) AS currAbbr\n  FROM checkhead, checkrecip, bankaccnt\n WHERE ( (checkhead_recip_id=checkrecip_id)\n   AND   (checkhead_recip_type=checkrecip_type)\n   AND   (NOT checkhead_void)\n   AND   (checkhead_checkdate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n   AND   (checkhead_bankaccnt_id=bankaccnt_id)\n   AND   (checkhead_bankaccnt_id=&lt;? value("bankaccnt_id") ?>)\n   &lt;? if exists("check_number") ?>\n      AND   (CAST(checkhead_number AS text) ~ &lt;? value("check_number") ?>)\n   &lt;? endif ?>\n   &lt;? if exists("recip") ?>\n      &lt;? if exists("recip_type_v") ?>\n         AND   (checkhead_recip_type = 'V' )\n      &lt;? endif ?>\n      &lt;? if exists("recip_type_c") ?>\n         AND   (checkhead_recip_type = 'C' )\n      &lt;? endif ?>\n      &lt;? if exists("recip_type_t") ?>\n         AND   (checkhead_recip_type = 'T' )\n      &lt;? endif ?>\n      &lt;? if exists("recip_id") ?>\n         AND   (checkhead_recip_id = &lt;? value("recip_id") ?> )\n      &lt;? endif ?>\n   &lt;? endif ?> )\nGROUP BY bankaccnt_curr_id;</sql>\n </querysource>\n <rpthead>\n  <height>168</height>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>140</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Payment Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>140</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Misc.</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>65</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>bankaccnt_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>441</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>140</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Recipient</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>85</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>bankaccnt_descrip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>140</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Payment #</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>140</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Void</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>155</ystart>\n   <xend>745</xend>\n   <yend>155</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>441</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>140</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>111</x>\n    <y>140</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Printed</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>65</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Bank Account:</string>\n  </label>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>140</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Payment Register</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>12</height>\n </pghead>\n <pghead>\n  <height>28</height>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Recipient</string>\n  </label>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>140</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Payment Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Misc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>111</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Printed</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Payment #</string>\n  </label>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Void</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>31</height>\n   <field>\n    <rect>\n     <x>111</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_printed</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>560</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_checkdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>170</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_posted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_void</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>225</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>description</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>225</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>checkhead_ach_batch</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>225</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>750</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>currAbbr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_misc</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>655</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>28</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>101</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>28</height>\n  <line>\n   <xstart>565</xstart>\n   <ystart>0</ystart>\n   <xend>745</xend>\n   <yend>0</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>750</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>655</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>total</query>\n    <column>f_amount</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Total:</string>\n  </label>\n </rptfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102486
 
43      ClassCodesMasterList    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Class Codes Master List</title>\n <name>ClassCodesMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>select classcode_code, classcode_descrip\n  from classcode\norder by classcode_code;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Class Codes Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Class Code</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Class Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n    <column></column>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>classcode_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>classcode_descrip</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102487
 
478     Contracts       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Contracts</title>\n <name>Contracts</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>contracts</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>90</x>\n    <y>53</y>\n    <width>135</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>630</x>\n    <y>10</y>\n    <width>115</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Contracts</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>53</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor #</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>53</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>235</x>\n    <y>53</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Contract #</string>\n  </label>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>53</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>53</y>\n    <width>135</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Contract Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>635</x>\n    <y>53</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Count</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>-1</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor #</string>\n  </label>\n  <label>\n   <rect>\n    <x>90</x>\n    <y>-1</y>\n    <width>135</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>235</x>\n    <y>-1</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Contract #</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>-1</y>\n    <width>135</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Contract Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>-1</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>-1</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>-1</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Count</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>22</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>2</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>90</x>\n     <y>2</y>\n     <width>135</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>235</x>\n     <y>2</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>contrct_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>2</y>\n     <width>135</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>contrct_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>470</x>\n     <y>2</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>contrct_effective</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>565</x>\n     <y>2</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>contrct_expires</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>655</x>\n     <y>2</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_count</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>25</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102488
 
32      CostCategoriesMasterList        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Cost Categories Master List</title>\n <name>CostCategoriesMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT costcat_code, costcat_descrip,\n       CASE WHEN (costcat_asset_accnt_id IS NOT NULL)      THEN formatGlAccountLong(costcat_asset_accnt_id)         ELSE '' END AS asset,\n       CASE WHEN (costcat_wip_accnt_id IS NOT NULL)        THEN formatGlAccountLong(costcat_wip_accnt_id)           ELSE '' END AS wip,\n       CASE WHEN (costcat_invcost_accnt_id IS NOT NULL)    THEN formatGlAccountLong(costcat_invcost_accnt_id)       ELSE '' END AS invcost,\n       CASE WHEN (costcat_purchprice_accnt_id IS NOT NULL) THEN formatGlAccountLong(costcat_purchprice_accnt_id)    ELSE '' END AS purchprice,\n       CASE WHEN (costcat_adjustment_accnt_id IS NOT NULL) THEN formatGlAccountLong(costcat_adjustment_accnt_id)    ELSE '' END AS adjustment,\n       CASE WHEN (costcat_scrap_accnt_id IS NOT NULL)      THEN formatGlAccountLong(costcat_scrap_accnt_id)         ELSE '' END AS scrap,\n       CASE WHEN fetchMetricBool('Routings')               THEN 'Labor and Overhead Costs:'                         ELSE '' END AS laboroverheadLit,\n       CASE WHEN (fetchMetricBool('Routings') AND\n              costcat_laboroverhead_accnt_id IS NOT NULL)  THEN formatGlAccountLong(costcat_laboroverhead_accnt_id) ELSE '' END AS laboroverhead,\n       CASE WHEN (costcat_liability_accnt_id IS NOT NULL)  THEN formatGlAccountLong(costcat_liability_accnt_id)     ELSE '' END AS liability,\n       CASE WHEN fetchMetricBool('MultiWhs')               THEN 'Transfer Order Liability Clearing:'                ELSE '' END AS toliabilityLit,\n       CASE WHEN (fetchMetricBool('MultiWhs') AND\n                costcat_toliability_accnt_id IS NOT NULL)  THEN formatGlAccountLong(costcat_toliability_accnt_id)   ELSE '' END AS toliability,\n       CASE WHEN fetchMetricBool('Transforms')             THEN 'Transform Clearing:'                               ELSE '' END AS transformLit,\n       CASE WHEN (fetchMetricBool('Transforms') AND\n                 costcat_transform_accnt_id IS NOT NULL)   THEN formatGlAccountLong(costcat_transform_accnt_id)     ELSE '' END AS transform\n  FROM costcat\nORDER BY costcat_code;</sql>\n </querysource>\n <rpthead>\n  <height>61</height>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Cost Categories Master List</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>55</ystart>\n   <xend>745</xend>\n   <yend>55</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>161</height>\n   <field>\n    <rect>\n     <x>415</x>\n     <y>55</y>\n     <width>160</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transformLit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>55</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transform</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>115</y>\n     <width>160</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Inventory Scrap:</string>\n   </label>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>55</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>wip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>70</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>toliability</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>415</x>\n     <y>70</y>\n     <width>160</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>toliabilityLit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>100</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>adjustment</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>84</y>\n     <width>160</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Purchase Price Variance:</string>\n   </label>\n   <field>\n    <rect>\n     <x>120</x>\n     <y>20</y>\n     <width>600</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>costcat_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>131</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>liability</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>40</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>asset</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>35</x>\n     <y>20</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Description:</string>\n   </label>\n   <line>\n    <xstart>20</xstart>\n    <ystart>150</ystart>\n    <xend>760</xend>\n    <yend>150</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>120</x>\n     <y>5</y>\n     <width>600</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>costcat_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>415</x>\n     <y>40</y>\n     <width>160</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>laboroverheadLit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>84</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>purchprice</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>25</x>\n     <y>5</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Category:</string>\n   </label>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>40</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>laboroverhead</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>70</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invcost</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>40</y>\n     <width>160</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Inventory Asset:</string>\n   </label>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>115</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>scrap</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>55</y>\n     <width>160</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>WIP Asset:</string>\n   </label>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>70</y>\n     <width>160</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Inventory Cost Variance:</string>\n   </label>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>131</y>\n     <width>160</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Liability Clearing:</string>\n   </label>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>100</y>\n     <width>160</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Inventory Adjustment:</string>\n   </label>\n  </detail>\n </section>\n <pgfoot>\n  <height>15</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102489
 
46      CostedSingleLevelBOM    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Costed Single Level Bill of Materials</title>\n <name>CostedSingleLevelBOM</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       uom_name AS item_invuom,\n       item_descrip1,\n       item_descrip2,\n       formatCost(stdcost(item_id)) AS standardcost,\n       formatCost(actcost(item_id)) AS actualcost,\n       &lt;? if exists("useActualCosts") ?>\n         text('Actual Cost')\n       &lt;? else ?>\n         text('Standard Cost')\n       &lt;? endif ?>\n       AS costtype\n  FROM item JOIN uom ON (uom_id=item_inv_uom_id)\n WHERE (item_id=&lt;? value("item_id") ?>);\n    </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT bomdata_bomwork_seqnumber AS orderby,\n  CASE WHEN bomdata_bomwork_seqnumber > 0 THEN\n    text(bomdata_bomwork_seqnumber)\n  ELSE NULL\n  END AS seqnumber,\n  bomdata_item_number AS item_number,\n  bomdata_uom_name AS item_invuom,\n  bomdata_item_descrip1 AS item_descrip1,\n  bomdata_item_descrip2 AS item_descrip2,\n  bomdata_issuemethod AS issuemethod,\n  formatQty(bomdata_qtyfxd) AS qtyfxd,\n  formatQtyPer(bomdata_qtyper) AS qtyper,\n  formatScrap(bomdata_scrap) AS scrap,\n  CASE\n    WHEN item_inv_uom_id IS NOT NULL THEN\n      formatqtyper((bomitem_qtyfxd + bomitem_qtyper) * (1 + bomitem_scrap) * itemuomtouomratio(bomitem_item_id,bomitem_uom_id,item_inv_uom_id)) \n    ELSE\n      ''\n  END AS qtyreq,\n  CASE WHEN COALESCE(bomdata_effective, startOfTime()) &lt;= startOfTime() THEN\n             &lt;? value("always") ?>\n       ELSE formatDate(bomdata_effective)\n  END AS effective,\n  CASE WHEN COALESCE(bomdata_expires, endOfTime()) >= endOfTime() THEN\n             &lt;? value("never") ?>\n       ELSE formatDate(bomdata_expires)\n  END AS expires,\n&lt;? if exists("useActualCosts") ?>\n  formatCost(bomdata_actunitcost)\n&lt;? else ?>\n  formatCost(bomdata_stdunitcost)\n&lt;? endif ?>\n  AS unitcost,\n&lt;? if exists("useActualCosts") ?>\n  formatCost(bomdata_actextendedcost)\n&lt;? else ?>\n  formatCost(bomdata_stdextendedcost)\n&lt;? endif ?>\n  AS extcost\nFROM singlelevelbom(&lt;? value("item_id") ?>,&lt;? value("revision_id") ?>,0,0)\n  LEFT OUTER JOIN bomitem ON (bomdata_bomitem_id=bomitem_id)\n  LEFT OUTER JOIN item ON (bomitem_item_id=item_id)\nORDER BY orderby;\n    </sql>\n </querysource>\n <querysource>\n  <name>bomhead</name>\n  <sql>SELECT bomhead_docnum, bomhead_revision,\nformatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=&lt;? value("item_id") ?>)\nAND (bomhead_rev_id=&lt;? value("revision_id") ?>));</sql>\n </querysource>\n <rpthead>\n  <height>217</height>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>180</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <field>\n   <rect>\n    <x>510</x>\n    <y>100</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>f_revisiondate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>415</x>\n    <y>120</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision:</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>180</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>180</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <field>\n   <rect>\n    <x>125</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>195</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Extended Cost</string>\n  </label>\n  <field>\n   <rect>\n    <x>510</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_revision</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>0</y>\n    <width>443</width>\n    <height>35</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Costed Single Level Bill of Materials</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>195</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Unit Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>50</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Cost Type:</string>\n  </label>\n  <label>\n   <rect>\n    <x>415</x>\n    <y>80</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Document #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>125</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>210</ystart>\n   <xend>745</xend>\n   <yend>210</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>415</x>\n    <y>100</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>180</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Required</string>\n  </label>\n  <field>\n   <rect>\n    <x>510</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_docnum</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>195</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>40</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>180</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>195</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>180</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <field>\n   <rect>\n    <x>430</x>\n    <y>50</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>costtype</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>180</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>195</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <field>\n   <rect>\n    <x>125</x>\n    <y>100</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>180</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>163</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Fxd. Qty.</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>15</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Unit Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Extended Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>0</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Required</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Per</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>53</height>\n   <field>\n    <rect>\n     <x>405</x>\n     <y>0</y>\n     <width>37</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_invuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>675</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>expires</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyfxd</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>0</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>31</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>unitcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>675</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>issuemethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>443</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>extcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>15</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>443</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>scrap</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>30</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>15</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>seqnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>effective</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createchild</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>525</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>16</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyper</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>53</height>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>5</y>\n    <width>103</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Total:</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>35</y>\n    <width>103</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Standard Cost:</string>\n  </label>\n  <field>\n   <rect>\n    <x>443</x>\n    <y>35</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>standardcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>20</y>\n    <width>103</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Actual Cost:</string>\n  </label>\n  <field>\n   <rect>\n    <x>443</x>\n    <y>20</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>actualcost</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>443</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>extcost</column>\n   </data>\n   <format>%9.4f</format>\n   <tracktotal/>\n  </field>\n </rptfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102490
 
315     CostedSummarizedBOM     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Costed Summarized Bill of Materials</title>\n <name>CostedSummarizedBOM</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       uom_name AS item_invuom,\n       item_descrip1,\n       item_descrip2,\n&lt;? if exists("useActualCosts") ?>\n       text('Actual Costs') AS f_costtype\n&lt;? else ?>\n       text('Standard Costs') AS f_costtype\n&lt;? endif ?>\n  FROM item JOIN uom ON (uom_id=item_inv_uom_id)\n WHERE (item_id=&lt;? value("item_id") ?>);\n    </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>select bomdata_item_number AS item_number,\n       bomdata_uom_name AS item_invuom,\n       bomdata_item_descrip1 AS item_descrip1,\n       bomdata_item_descrip2 AS item_descrip2,\n       formatQtyPer(bomdata_qtyreq) AS qtyreq,\n&lt;? if exists("useActualCosts") ?>\n       formatCost(bomdata_actunitcost) AS f_cost,\n       formatCost(bomdata_actextendedcost) AS f_extcost\n&lt;? else ?>\n       formatCost(bomdata_stdunitcost) AS f_cost,\n       formatCost(bomdata_stdextendedcost) AS f_extcost\n&lt;? endif ?>\n  FROM summarizedBOM(&lt;? value("item_id") ?>,&lt;? value("revision_id") ?>,&lt;? value("expiredDays") ?>,&lt;? value("futureDays") ?>);</sql>\n </querysource>\n <querysource>\n  <name>bomhead</name>\n  <sql>SELECT bomhead_docnum, bomhead_revision,\nformatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=&lt;? value("item_id") ?>)\nAND (bomhead_rev_id=&lt;? value("revision_id") ?>));</sql>\n </querysource>\n <rpthead>\n  <height>242</height>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>104</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>204</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Qty. Req.</string>\n  </label>\n  <field>\n   <rect>\n    <x>315</x>\n    <y>104</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_invuom</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>125</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>205</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext'd Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>125</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>145</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>204</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>145</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision:</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>50</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Cost Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>125</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>f_revisiondate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>204</y>\n    <width>165</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>220</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <field>\n   <rect>\n    <x>410</x>\n    <y>50</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_costtype</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>145</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_revision</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>205</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Unit Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>10</y>\n    <width>500</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Costed Summarized Bill of Materials</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>235</ystart>\n   <xend>745</xend>\n   <yend>235</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>104</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>104</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>104</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_docnum</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>104</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Document #:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Qty. Req.</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>0</y>\n    <width>165</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>15</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Unit Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext'd Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>52</height>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_extcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_cost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>113</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>113</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>113</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>275</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_invuom</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102491
 
34      CountSlipEditList       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Count Slip Edit List</title>\n <name>CountSlipEditList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       warehous_code as warehouse,\n       invcnt_tagnumber\n  FROM item, itemsite, invcnt, whsinfo\n WHERE ((itemsite_item_id=item_id)\n   AND (invcnt_itemsite_id=itemsite_id)\n   AND (invcnt_id=&lt;? value(&quot;cnttag_id&quot;) ?>)\n   AND (itemsite_warehous_id=warehous_id) );\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT cntslip_username AS f_username,\n       cntslip_number,\n       formatBoolYN(cntslip_posted) AS f_posted,\n       formatDateTime(cntslip_entered) AS f_entered,\n       formatQty(cntslip_qty) AS f_qty\n  FROM cntslip\n WHERE (cntslip_cnttag_id=&lt;? value(&quot;cnttag_id&quot;) ?>)\nORDER BY cntslip_number;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>95</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>200</y>\n    <width>114</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Entered</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Count Slip Edit List</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>95</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>75</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Count Tag #:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>135</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>200</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>75</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>invcnt_tagnumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>User</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Slip Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>155</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>114</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>155</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>0</y>\n    <width>114</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Entered</string>\n  </label>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>0</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Slip Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>User</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>0</y>\n     <width>275</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cntslip_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>114</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_entered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>455</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_posted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>0</y>\n     <width>105</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_username</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102492
 
36      CountSlipsByWarehouse   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Count Slips By Site</title>\n <name>CountSlipsByWarehouse</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       formatDate(&lt;? value("startDate") ?>) AS startdate,\n       formatDate(&lt;? value("endDate") ?>) AS enddate\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT invcnt_tagnumber AS tagnum,\n       &lt;? if exists("asNumeric") ?>\n         int4(cntslip_number)\n       &lt;? else ?>\n         cntslip_number\n       &lt;? endif ?>\n       AS slipnum,\n       warehous_code,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       formatDate(cntslip_entered) AS date_entered,\n       ('( ' || cntslip_username || ' )') AS enteredby,\n       formatQty(cntslip_qty) AS f_qtycounted,\n       formatBoolYN(cntslip_posted) AS f_posted\n  FROM cntslip, invcnt, itemsite, item, whsinfo\n WHERE ((cntslip_cnttag_id=invcnt_id)\n   AND (invcnt_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (cntslip_entered BETWEEN &lt;? value("startDate") ?> AND (&lt;? value("endDate") ?>::DATE + 1))\n&lt;? if not exists("showUnposted") ?>\n   AND (cntslip_posted)\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n)\nORDER BY slipnum;</sql>\n </querysource>\n <rpthead>\n  <height>191</height>\n  <field>\n   <rect>\n    <x>515</x>\n    <y>110</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>155</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>90</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>170</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tag Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>170</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>155</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>484</x>\n    <y>155</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Entered</string>\n  </label>\n  <label>\n   <rect>\n    <x>484</x>\n    <y>170</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>185</ystart>\n   <xend>745</xend>\n   <yend>185</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>90</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Count Slips By Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>155</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Counted</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>110</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>155</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Slip Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>515</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>155</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>0</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>15</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tag Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>484</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Entered</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>15</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>0</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Slip Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Counted</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>484</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>15</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>tagnum</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>0</y>\n     <width>245</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtycounted</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>15</y>\n     <width>245</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>30</y>\n     <width>245</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>484</x>\n     <y>15</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>enteredby</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>slipnum</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>484</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>date_entered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_posted</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>620</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>710</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102493
 
35      CountTagEditList        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Count Tag Edit List</title>\n <name>CountTagEditList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n                   FROM whsinfo\n                   WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("classcode_id") ?>\n         ( SELECT (classcode_code ||'-'||classcode_descrip)\n             FROM classcode\n            WHERE (classcode_id=&lt;? value("classcode_id") ?>) ) AS code,\n\t  text('Class Code:') AS codelbl\n       &lt;? elseif exists("classcode_pattern") ?>\n         text(&lt;? value("classcode_pattern") ?>) AS code,\n         text('Class Code:') AS codelbl\n       &lt;? elseif exists("plancode_id") ?>\n         ( SELECT (plancode_code ||'-'|| plancode_name)\n             FROM plancode\n            WHERE (plancode_id=&lt;? value("plancode_id") ?>) ) AS code,\n\t  text('Planner Code:') AS codelbl\n       &lt;? elseif exists("plancode_pattern") ?>\n         text(&lt;? value("plancode_pattern") ?>) AS code,\n         text('Planner Code:') AS codelbl\n       &lt;? else ?>\n         text('') AS code,\n         text('') AS codelbl\n       &lt;? endif ?>\n       </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT formatBoolYN(invcnt_priority) AS f_priority,\n       CASE WHEN (invcnt_tagnumber IS NULL) THEN 'Misc.'\n            ELSE invcnt_tagnumber\n       END AS f_tagnumber, \n       formatDate(invcnt_tagdate) AS f_tagdate,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       warehous_code,\n       CASE WHEN (invcnt_location_id IS NOT NULL)\n                 THEN (SELECT formatQty(SUM(itemloc_qty))\n                         FROM itemloc\n                        WHERE ((itemloc_itemsite_id=itemsite_id)\n                          AND  (itemloc_location_id=invcnt_location_id)) )\n            ELSE formatQty(itemsite_qtyonhand)\n       END AS f_qoh,\n       CASE WHEN (location_id IS NOT NULL)\n                 THEN location_name\n            ELSE 'All' END AS location_name,\n       CASE WHEN (invcnt_qoh_after IS NULL) THEN ''\n            ELSE formatQty(invcnt_qoh_after)\n       END AS f_cntqty,\n       CASE WHEN (invcnt_qoh_after IS NULL) THEN ''\n            ELSE formatQty(invcnt_qoh_after - itemsite_qtyonhand)\n       END AS f_variance,\n       CASE WHEN (invcnt_qoh_after IS NULL) THEN ''\n            WHEN ((itemsite_qtyonhand = 0) AND (invcnt_qoh_after > 0)) THEN formatPrcnt(1)\n            WHEN ((itemsite_qtyonhand = 0) AND (invcnt_qoh_after &lt; 0)) THEN formatPrcnt(-1)\n            WHEN ((itemsite_qtyonhand = 0) AND (invcnt_qoh_after = 0)) THEN formatPrcnt(0)\n            ELSE formatPrcnt((1 - (invcnt_qoh_after / itemsite_qtyonhand)) * -1)\n       END AS f_percent,\n       formatExtPrice(stdcost(item_id) * (invcnt_qoh_after - itemsite_qtyonhand)) AS f_amount\n  FROM invcnt LEFT OUTER JOIN location ON (invcnt_location_id=location_id),\n       item, whsinfo, itemsite\n WHERE ((invcnt_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (NOT invcnt_posted)\n&lt;? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("classcode_id") ?>\n   AND (item_classcode_id=&lt;? value("classcode_id") ?>)\n&lt;? elseif exists("classcode_pattern") ?>\n   AND (item_classcode_id IN ( SELECT classcode_id\n                                 FROM classcode\n                                WHERE (classcode_code ~ &lt;? value("classcode_pattern") ?>)))\n&lt;? elseif exists("plancode_id") ?>\n   AND (itemsite_plancode_id=&lt;? value("plancode_id") ?>)\n&lt;? elseif exists("plancode_pattern") ?>\n   AND (itemsite_plancode_id IN ( SELECT plancode_id\n                                 FROM plancode\n                                WHERE (plancode_code ~ &lt;? value("plancode_pattern") ?>)))\n&lt;? endif ?>\n)\nORDER BY f_priority DESC, item_number\n&lt;? if exists("maxTags") ?>\n    LIMIT &lt;? value("maxTags") ?>\n&lt;? endif ?></sql>\n </querysource>\n <rpthead>\n  <height>205</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Priority</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Count Tag Edit List</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tag Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>200</ystart>\n   <xend>745</xend>\n   <yend>200</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>170</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>330</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>170</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>170</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Variance</string>\n  </label>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>170</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>330</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>code</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>170</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Count Qty</string>\n  </label>\n  <field>\n   <rect>\n    <x>0</x>\n    <y>80</y>\n    <width>95</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>codelbl</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>170</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tag #</string>\n  </label>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>185</y>\n    <width>75</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Location</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>170</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>8</height>\n </pghead>\n <pghead>\n  <height>38</height>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tag Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Count Qty</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>15</y>\n    <width>75</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Location</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tag #</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>$</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>15</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Priority</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Variance</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>55</height>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_variance</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>295</x>\n     <y>15</y>\n     <width>104</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_tagdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>408</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>location_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_percent</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>494</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_cntqty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>225</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>295</x>\n     <y>0</y>\n     <width>104</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_tagnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>408</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qoh</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_priority</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>15</y>\n     <width>225</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>30</y>\n     <width>225</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>21</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102494
 
39      CountTagsByClassCode    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Count Tags By Class Code</title>\n <name>CountTagsByClassCode</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value(&quot;startDate&quot;) ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value(&quot;endDate&quot;) ?>, 'Latest') AS enddate,\n       &lt;? if exists(&quot;classcode_id&quot;) ?>\n         ( SELECT (classcode_code || '-' || classcode_descrip)\n             FROM classcode\n            WHERE (classcode_id=&lt;? value(&quot;classcode_id&quot;) ?>) )\n       &lt;? elseif exists(&quot;classcode_pattern&quot;) ?>\n         text(&lt;? value(&quot;classcode_pattern&quot;) ?>)\n       &lt;? else ?>\n         text('All Class Codes')\n       &lt;? endif ?>\n       AS classcode,\n       &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT invcnt_id, invcnt_tagnumber, warehous_code,\n       item_number, item_descrip1, item_descrip2,\n       formatDate(invcnt_tagdate) AS createddate,\n       invcnt_tag_username AS createdby,\n       CASE WHEN (invcnt_cntdate IS NULL) THEN ''\n            ELSE formatDate(invcnt_cntdate)\n       END AS entereddate,\n       CASE WHEN (invcnt_cntdate IS NULL) THEN ''\n            ELSE invcnt_cnt_username\n       END AS enteredby,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            ELSE formatDate(invcnt_postdate)\n       END AS posteddate,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            ELSE invcnt_post_username\n       END AS postedby,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            ELSE formatQty(invcnt_qoh_before)\n       END AS qohbefore,\n       CASE WHEN (invcnt_qoh_after IS NULL) THEN ''\n            ELSE formatQty(invcnt_qoh_after)\n       END AS qohafter,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            ELSE formatQty(invcnt_qoh_after - invcnt_qoh_before)\n       END AS variance,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            WHEN (invcnt_qoh_before=0) THEN formatScrap(1)\n            ELSE formatScrap((1 - (invcnt_qoh_after / invcnt_qoh_before)) * -1)\n       END AS percentage\n  FROM invcnt, itemsite, item, whsinfo\n WHERE ((invcnt_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (date(invcnt_tagdate) BETWEEN &lt;? value(&quot;startDate&quot;) ?> AND &lt;? value(&quot;endDate&quot;) ?>)\n&lt;? if not exists(&quot;showUnposted&quot;) ?>\n   AND (invcnt_posted)\n&lt;? endif ?>\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;classcode_id&quot;) ?>\n   AND (item_classcode_id=&lt;? value(&quot;classcode_id&quot;) ?>)\n&lt;? elseif exists(&quot;classcode_pattern&quot;) ?>\n   AND (item_classcode_id IN (SELECT classcode_id\n                                FROM classcode\n                               WHERE (classcode_code ~ &lt;? value(&quot;classcode_pattern&quot;) ?>)))\n&lt;? endif ?>\n)\nORDER BY invcnt_tagdate;</sql>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <label>\n   <rect>\n    <x>415</x>\n    <y>90</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>415</x>\n    <y>110</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Before</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>110</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>90</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>classcode</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>170</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>170</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Entered</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. After</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>170</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tag #</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>90</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Class Code:</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Count Tags By Class Code</string>\n  </label>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>110</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>170</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Created</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>170</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>110</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Variance</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>170</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>66</height>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tag #</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>45</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. After</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Entered</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>60</ystart>\n   <xend>745</xend>\n   <yend>60</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>45</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Before</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>45</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>45</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Variance</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Created</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>66</height>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>15</y>\n     <width>225</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>295</x>\n     <y>0</y>\n     <width>105</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invcnt_tagnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>409</x>\n     <y>45</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qohbefore</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>409</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createddate</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>60</ystart>\n    <xend>745</xend>\n    <yend>60</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>postedby</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>495</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>enteredby</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>30</y>\n     <width>225</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>45</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>variance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>409</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createdby</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>posteddate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>225</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>45</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>percentage</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>495</x>\n     <y>45</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qohafter</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>495</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>entereddate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102495
 
37      CountTagsByItem \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Count Tags By Item</title>\n <name>CountTagsByItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       formatDate(&lt;? value(&quot;startDate&quot;) ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value(&quot;endDate&quot;) ?>, 'Latest') AS enddate,\n       &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse\n  FROM item\n WHERE (item_id=&lt;? value(&quot;item_id&quot;) ?>);\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT invcnt_tagnumber, warehous_code,\n       formatDate(invcnt_tagdate) AS createddate,\n       invcnt_tag_username AS createdby,\n       CASE WHEN (invcnt_cntdate IS NULL) THEN ''\n            ELSE formatDate(invcnt_cntdate)\n       END AS entereddate,\n       CASE WHEN (invcnt_cntdate IS NULL) THEN ''\n            ELSE invcnt_cnt_username\n       END AS enteredby,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            ELSE formatDate(invcnt_postdate)\n       END AS posteddate,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            ELSE invcnt_post_username\n       END AS postedby,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            ELSE formatQty(invcnt_qoh_before)\n       END AS qohbefore,\n       CASE WHEN (invcnt_qoh_after IS NULL) THEN ''\n            ELSE formatQty(invcnt_qoh_after)\n       END AS qohafter,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            ELSE formatQty(invcnt_qoh_after - invcnt_qoh_before)\n       END AS variance,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            WHEN (invcnt_qoh_before=0) THEN formatScrap(1)\n            ELSE formatScrap((1 - (invcnt_qoh_after / invcnt_qoh_before)) * -1)\n       END AS percentage\n  FROM invcnt, itemsite, whsinfo\n WHERE ((invcnt_itemsite_id=itemsite_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (itemsite_item_id=&lt;? value(&quot;item_id&quot;) ?>)\n   AND (invcnt_tagdate BETWEEN &lt;? value(&quot;startDate&quot;) ?> AND &lt;? value(&quot;endDate&quot;) ?>)\n&lt;? if not exists(&quot;showUnposted&quot;) ?>\n   AND (invcnt_posted)\n&lt;? endif ?>\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n)\nORDER BY invcnt_tagdate;</sql>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Variance</string>\n  </label>\n  <field>\n   <rect>\n    <x>515</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Created</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>145</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>740</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tag #</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>145</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Count Tags By Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <field>\n   <rect>\n    <x>515</x>\n    <y>100</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. After</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Before</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Entered</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Before</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Created</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Variance</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>740</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. After</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Entered</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tag #</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>41</height>\n   <line>\n    <xstart>5</xstart>\n    <ystart>35</ystart>\n    <xend>740</xend>\n    <yend>35</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>409</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qohbefore</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>0</y>\n     <width>105</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invcnt_tagnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>enteredby</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createddate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>325</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>posteddate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>495</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qohafter</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>percentage</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createdby</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>325</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>postedby</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>variance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>entereddate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102496
 
38      CountTagsByWarehouse    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Count Tags By Site</title>\n <name>CountTagsByWarehouse</name>\n <description>With Barcoded Count Tag</description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT invcnt_id,\n       formatcounttagbarcode(invcnt_id) AS countag_barcode, \n       invcnt_tagnumber, \n       warehous_code,\n       item_number, item_descrip1, item_descrip2,\n       formatDate(invcnt_tagdate) AS createddate,\n       invcnt_tag_username AS createdby,\n       CASE WHEN (invcnt_cntdate IS NULL) THEN ''\n            ELSE formatDate(invcnt_cntdate)\n       END AS entereddate,\n       CASE WHEN (invcnt_cntdate IS NULL) THEN ''\n            ELSE invcnt_cnt_username\n       END AS enteredby,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            ELSE formatDate(invcnt_postdate)\n       END AS posteddate,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            ELSE invcnt_post_username\n       END AS postedby,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            ELSE formatQty(invcnt_qoh_before)\n       END AS qohbefore,\n       CASE WHEN (invcnt_qoh_after IS NULL) THEN ''\n            ELSE formatQty(invcnt_qoh_after)\n       END AS qohafter,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            ELSE formatQty(invcnt_qoh_after - invcnt_qoh_before)\n       END AS variance,\n       CASE WHEN (NOT invcnt_posted) THEN ''\n            WHEN ((invcnt_qoh_before = 0) AND (invcnt_qoh_after = 0)) THEN formatScrap(0)\n            WHEN (invcnt_qoh_before=0) THEN formatScrap(1)\n            ELSE formatScrap((1 - (invcnt_qoh_after / invcnt_qoh_before)) * -1)\n       END AS percentage\n  FROM invcnt, itemsite, item, whsinfo\n WHERE ((invcnt_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (DATE(invcnt_tagdate) BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n&lt;? if not exists("showUnposted") ?>\n   AND (invcnt_posted)\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n)\nORDER BY invcnt_tagdate;</sql>\n </querysource>\n <rpthead>\n  <height>246</height>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Count Tags By Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>220</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Before</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>220</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. After</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>175</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>175</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>190</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>494</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>190</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>190</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <field>\n   <rect>\n    <x>494</x>\n    <y>100</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>175</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>175</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Created</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>220</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>120</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>175</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Entered</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>235</ystart>\n   <xend>745</xend>\n   <yend>235</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>190</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>175</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tag #</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>220</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Variance</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>12</height>\n </pghead>\n <pghead>\n  <height>71</height>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>45</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Variance</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Entered</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tag #</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>45</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Before</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Created</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>45</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. After</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>( By )</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>60</ystart>\n   <xend>745</xend>\n   <yend>60</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>45</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>113</height>\n   <field>\n    <rect>\n     <x>419</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createdby</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>45</x>\n     <y>0</y>\n     <width>225</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>419</x>\n     <y>45</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qohbefore</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>419</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createddate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>40</y>\n     <width>225</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>590</x>\n     <y>45</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>variance</column>\n    </data>\n   </field>\n   <barcode>\n    <rect>\n     <x>300</x>\n     <y>70</y>\n     <width>370</width>\n     <height>30</height>\n    </rect>\n    <format>128</format>\n    <maxlength>12</maxlength>\n    <left/>\n    <data>\n     <query>detail</query>\n     <column>countag_barcode</column>\n    </data>\n   </barcode>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>45</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qohafter</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>295</x>\n     <y>0</y>\n     <width>104</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invcnt_tagnumber</column>\n    </data>\n   </field>\n   <line>\n    <xstart>15</xstart>\n    <ystart>105</ystart>\n    <xend>750</xend>\n    <yend>105</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>entereddate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>590</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>posteddate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>675</x>\n     <y>45</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>percentage</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>enteredby</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>590</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>postedby</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>25</y>\n     <width>225</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>24</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n    With Barcoded Count Tag 0       2014-10-06 19:47:03.678943
102497
 
3       CreditMemo      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Return</title>\n <name>CreditMemo</name>\n <description>Sales Module Return with Logo and CM Currency</description>\n <parameter default="" active="true" listtype="dynamic" type="string" name="cmhead_id" >\n  <description></description>\n  <query>select cmhead_id, cmhead_number from cmhead;</query>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>28</topmargin>\n <bottommargin>28</bottommargin>\n <rightmargin>0</rightmargin>\n <leftmargin>0</leftmargin>\n <querysource>\n  <name>GroupHead</name>\n  <sql>SELECT remitto.*,\n       cmhead_number,\n       formatDate(cmhead_docdate) AS docdate,\n       cust_number,\n       cust_name,\n       formatAddr(cmhead_billtoaddress1, cmhead_billtoaddress2, cmhead_billtoaddress3,\n                  COALESCE(cmhead_billtocity,'') || '  ' || COALESCE(cmhead_billtostate,'') || '  ' || COALESCE(cmhead_billtozip,''),\n                   cmhead_billtocountry)\n       AS f_custaddr,\n       cntct_phone AS cust_phone,\n       cmhead_shipto_name,\n       formatAddr(cmhead_shipto_address1, cmhead_shipto_address2, cmhead_shipto_address3,\n                  COALESCE(cmhead_shipto_city,'') ||'  '|| COALESCE(cmhead_shipto_state,'') || '  '|| COALESCE(cmhead_shipto_zipcode,''),\n                  cmhead_shipto_country)\n                  AS f_shiptoaddr,\n       CASE \n         WHEN (cmhead_invcnumber='-1') THEN ''\n         --note: must now set explicit type for Postgres 8.3+\n         --add ' '\n         ELSE text(cmhead_invcnumber)\n       END AS invcnumber,\n       cmhead_custponumber,\n       cmhead_comments,\n       cmhead_misc_descrip,\n       curr_symbol,\n       curr_name\n  FROM remitto, cmhead, curr_symbol, custinfo\n  LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n WHERE ((cmhead_cust_id=cust_id)\n       AND (cmhead_curr_id = curr_id)\n       AND (cmhead_id=&lt;? value("cmhead_id") ?>))\nORDER BY cmhead_number;</sql>\n </querysource>\n <querysource>\n  <name>Detail</name>\n  <sql>SELECT cmitem_linenumber,\n       formatQty(cmitem_qtycredit) AS qtycredit,\n       formatQty(cmitem_qtyreturned) AS qtyreturned,\n       uom_name,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       formatSalesPrice(cmitem_unitprice) AS unitprice,\n       formatMoney((cmitem_qtycredit * cmitem_qty_invuomratio) * (cmitem_unitprice / cmitem_price_invuomratio)) AS extprice,\n       cmitem_comments\n  FROM cmitem, itemsite, item, uom\n WHERE ((cmitem_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (cmitem_cmhead_id=&lt;? value("cmhead_id") ?>))\nORDER BY cmitem_linenumber;</sql>\n </querysource>\n <querysource>\n  <name>GroupFoot</name>\n  <sql>SELECT formatExtPrice(SUM((cmitem_qtycredit * cmitem_qty_invuomratio) * cmitem_unitprice / cmitem_price_invuomratio)) AS extprice\n  FROM cmhead, cmitem, itemsite, item\n WHERE ((cmitem_cmhead_id=cmhead_id)\n   AND (cmitem_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (cmhead_id=&lt;? value("cmhead_id") ?>));</sql>\n </querysource>\n <querysource>\n  <name>GroupExtended</name>\n  <sql>SELECT formatExtPrice( COALESCE(cmhead_freight,0.0) +\n                       ( SELECT COALESCE(SUM(tax * -1.0), 0)\n                         FROM ( SELECT ROUND(SUM(taxdetail_tax), 2) AS tax\n                                FROM tax JOIN calculateTaxDetailSummary('CM', cmhead_id, 'T')\n                                           ON (taxdetail_tax_id=tax_id)\n                                GROUP BY tax_id ) AS data ) +\n                       COALESCE(cmhead_misc,0.0) +\n                       ( SELECT COALESCE(SUM((cmitem_qtycredit * cmitem_qty_invuomratio) *\n                                              cmitem_unitprice / cmitem_price_invuomratio), 0.0)\n                         FROM cmitem\n                         WHERE (cmitem_cmhead_id=&lt;? value("cmhead_id") ?>) ) \n                     ) AS totaldue,\n       formatExtPrice(COALESCE(cmhead_freight,0.0)) AS freight,\n       ( SELECT formatExtPrice(COALESCE(SUM(tax * -1.0), 0))\n         FROM ( SELECT ROUND(SUM(taxdetail_tax), 2) AS tax\n                FROM tax JOIN calculateTaxDetailSummary('CM', cmhead_id, 'T')\n                           ON (taxdetail_tax_id=tax_id)\n                GROUP BY tax_id ) AS data ) AS tax,\n       formatExtPrice(COALESCE(cmhead_misc,0.0)) AS misc\n  FROM cmhead\n WHERE (cmhead_id=&lt;? value("cmhead_id") ?>);\n</sql>\n </querysource>\n <querysource>\n  <name>logo</name>\n  <sql>SELECT image_data \nFROM image \nWHERE ((image_name='logo'));</sql>\n </querysource>\n <pghead>\n  <firstpage/>\n  <height>451</height>\n  <field>\n   <rect>\n    <x>50</x>\n    <y>370</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>cmhead_custponumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>350</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P.O. Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>130</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>130</y>\n    <width>135</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>docdate</column>\n   </data>\n  </field>\n  <line>\n   <xstart>50</xstart>\n   <ystart>340</ystart>\n   <xend>800</xend>\n   <yend>340</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>419</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>419</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>110</y>\n    <width>145</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>cmhead_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>205</y>\n    <width>290</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>cust_name</column>\n   </data>\n  </field>\n  <line>\n   <xstart>50</xstart>\n   <ystart>445</ystart>\n   <xend>800</xend>\n   <yend>445</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>390</x>\n    <y>350</y>\n    <width>195</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Return Currency</string>\n  </label>\n  <field>\n   <rect>\n    <x>390</x>\n    <y>370</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>50</x>\n    <y>80</y>\n    <width>260</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>remitto_country</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>100</x>\n    <y>225</y>\n    <width>315</width>\n    <height>15</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>GroupHead</query>\n    <column>f_custaddr</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>205</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ship To:</string>\n  </label>\n  <label>\n   <rect>\n    <x>185</x>\n    <y>350</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Document Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>185</x>\n    <y>370</y>\n    <width>230</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>docdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>485</x>\n    <y>205</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>cmhead_shipto_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>419</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Unit Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>110</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Return #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>444</x>\n    <y>370</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>curr_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>50</x>\n    <y>95</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>remitto_phone</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>400</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Returned</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>170</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Apply To:</string>\n  </label>\n  <field>\n   <rect>\n    <x>50</x>\n    <y>50</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>remitto_address1</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>485</x>\n    <y>225</y>\n    <width>315</width>\n    <height>15</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>GroupHead</query>\n    <column>f_shiptoaddr</column>\n   </data>\n  </text>\n  <image>\n   <rect>\n    <x>270</x>\n    <y>0</y>\n    <width>355</width>\n    <height>111</height>\n   </rect>\n   <mode>stretch</mode>\n   <data>\n    <query>logo</query>\n    <column>image_data</column>\n   </data>\n  </image>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>150</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>150</y>\n    <width>180</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>50</x>\n    <y>30</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>remitto_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>419</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>635</x>\n    <y>15</y>\n    <width>175</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>20</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Return</string>\n  </label>\n  <field>\n   <rect>\n    <x>50</x>\n    <y>65</y>\n    <width>260</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>remitto_citystatezip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>205</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bill To:</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>419</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Credited</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>400</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>170</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invcnumber</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>Detail</query>\n   </key>\n   <height>82</height>\n   <text>\n    <rect>\n     <x>160</x>\n     <y>55</y>\n     <width>600</width>\n     <height>17</height>\n    </rect>\n    <bottompad>14</bottompad>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Detail</query>\n     <column>cmitem_comments</column>\n    </data>\n   </text>\n   <label>\n    <rect>\n     <x>120</x>\n     <y>55</y>\n     <width>55</width>\n     <height>10</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>6</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Notes:</string>\n   </label>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>5</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>extprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>25</y>\n     <width>120</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>qtycredit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>5</y>\n     <width>300</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>5</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>25</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>5</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>unitprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>40</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>5</y>\n     <width>120</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>qtyreturned</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <firstpage/>\n  <height>144</height>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>5</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Subtotal:</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>5</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupFoot</query>\n    <column>extprice</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>60</x>\n    <y>55</y>\n    <width>515</width>\n    <height>17</height>\n   </rect>\n   <bottompad>14</bottompad>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>GroupHead</query>\n    <column>cmhead_comments</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>45</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Comments</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupExtended</query>\n    <column>tax</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sales Tax:</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>25</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupExtended</query>\n    <column>misc</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>45</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Freight:</string>\n  </label>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Total Credit:</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>45</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupExtended</query>\n    <column>freight</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>15</y>\n    <width>100</width>\n    <height>10</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Misc. Comments:</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupExtended</query>\n    <column>totaldue</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>25</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Misc:</string>\n  </label>\n  <field>\n   <rect>\n    <x>60</x>\n    <y>25</y>\n    <width>525</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>cmhead_misc_descrip</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n       Sales Module Return with Logo and CM Currency   0       2014-10-06 19:47:03.678943
102498
 
264     CreditMemoEditList      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Return Edit List</title>\n <name>CreditMemoEditList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT orderid,\n       itemid,\n       documentnumber,\n       CASE WHEN(documentnumber='') THEN item\n            ELSE cust_number\n       END AS name,\n       CASE WHEN(documentnumber='') THEN itemdescrip\n            ELSE billtoname\n       END AS descrip,\n       ordernumber,\n       linenumber,\n       iteminvuom,\n       qtytobill,\n       price,\n       extprice,\n       sence,\n       account\n  FROM creditMemoEditList\nORDER BY ordernumber, linenumber;</sql>\n </querysource>\n <rpthead>\n  <height>136</height>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>5</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Return Edit List</string>\n  </label>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>100</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>112</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sales Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>100</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>100</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>100</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Price</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>130</ystart>\n   <xend>745</xend>\n   <yend>130</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>100</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>A/R Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>75</x>\n    <y>112</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name/Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>100</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order #</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>112</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. to Bill</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>100</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust./Item #</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>A/R Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Invoice #</string>\n  </label>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order #</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sales Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name/Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. to Bill</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust./Item #</string>\n  </label>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>31</height>\n   <field>\n    <rect>\n     <x>340</x>\n     <y>15</y>\n     <width>240</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sence</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>75</x>\n     <y>15</y>\n     <width>254</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>extprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>590</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>price</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>90</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ordernumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>285</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>iteminvuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>180</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>590</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtytobill</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>340</x>\n     <y>0</y>\n     <width>240</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>account</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>685</x>\n     <y>15</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shiptostate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>documentnumber</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102499
 
405     CurrencyConversionList  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Currency Exchange Rates</title>\n <name>CurrencyConversionList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>100</topmargin>\n <bottommargin>100</bottommargin>\n <rightmargin>100</rightmargin>\n <leftmargin>100</leftmargin>\n <querysource loadFromDb="true" >\n  <name>exchangeRates</name>\n  <mqlgroup>currencyConversions</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <querysource>\n  <name>baseCurrency</name>\n  <sql>SELECT\n\tcurr_name,\n\tcurrConcat(curr_id) AS currConcat\nFROM curr_symbol\nWHERE curr_base = TRUE;</sql>\n </querysource>\n <querysource>\n  <name>knownCurrencies</name>\n  <sql>SELECT\n\tcurr_name,\n\tcurrConcat(curr_id) AS currConcat,\n\tcurr_base\nFROM curr_symbol\nWHERE curr_base = FALSE\nORDER BY currConcat;</sql>\n </querysource>\n <rpthead>\n  <height>113</height>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>0</y>\n    <width>575</width>\n    <height>41</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency Exchange Rates</string>\n  </label>\n  <field>\n   <rect>\n    <x>0</x>\n    <y>60</y>\n    <width>151</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>baseCurrency</query>\n    <column>curr_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>40</y>\n    <width>140</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Base Currency:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>90</y>\n    <width>140</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Foreign Currencies:</string>\n  </label>\n  <field>\n   <rect>\n    <x>150</x>\n    <y>60</y>\n    <width>116</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>baseCurrency</query>\n    <column>currConcat</column>\n   </data>\n  </field>\n </rpthead>\n <section>\n  <name>Known Currencies</name>\n  <group>\n   <name>Known</name>\n   <column>curr_base</column>\n   <foot>\n    <height>61</height>\n    <label>\n     <rect>\n      <x>250</x>\n      <y>30</y>\n      <width>37</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Start</string>\n    </label>\n    <label>\n     <rect>\n      <x>350</x>\n      <y>30</y>\n      <width>37</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>End</string>\n    </label>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>30</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Currency</string>\n    </label>\n    <label>\n     <rect>\n      <x>100</x>\n      <y>30</y>\n      <width>110</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Exchange Rate</string>\n    </label>\n    <line>\n     <xstart>0</xstart>\n     <ystart>50</ystart>\n     <xend>407</xend>\n     <yend>50</yend>\n     <weight>2</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>knownCurrencies</query>\n   </key>\n   <height>21</height>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>0</y>\n     <width>126</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>knownCurrencies</query>\n     <column>currConcat</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>knownCurrencies</query>\n     <column>curr_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>Exchange Rates</name>\n  <group>\n   <name>By Currency</name>\n   <column>currConcat</column>\n   <foot>\n    <height>21</height>\n    <line>\n     <xstart>409</xstart>\n     <ystart>10</ystart>\n     <xend>5</xend>\n     <yend>10</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>exchangeRates</query>\n   </key>\n   <height>21</height>\n   <field>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>96</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>exchangeRates</query>\n     <column>f_curr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>exchangeRates</query>\n     <column>curr_expires</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>90</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>exchangeRates</query>\n     <column>rate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>230</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>exchangeRates</query>\n     <column>curr_effective</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>31</height>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>10</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102500
 
406     CustOrderAcknowledgement        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Customer Order Acknowledgement</title>\n <name>CustOrderAcknowledgement</name>\n <description>Customer Order Acknowledgement</description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>25</topmargin>\n <bottommargin>25</bottommargin>\n <rightmargin>25</rightmargin>\n <leftmargin>25</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>&lt;? if not exists("shiphead_id") ?>\n--Run query if no shiphead_id passed - No Shipment Pack List\nSELECT cust_number,\n       formatsobarcode(cohead_id) AS order_barcode,\n       formataddr(addr_line1, addr_line2, addr_line3, (addr_city || '  ' ||  addr_state || '  ' || addr_postalcode), addr_country) AS corr_address,\n       formataddr(cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, (cohead_billtocity || '  ' ||   cohead_billtostate || '  ' || cohead_billtozipcode), cohead_billtocountry) AS billing_address, \n\n  formataddr(cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, (cohead_shiptocity || '  ' ||   cohead_shiptostate || '  ' || cohead_shiptozipcode), cohead_shiptocountry) AS shipping_address,           \n\n       trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n       cohead_fob,\n       cohead_billtoname,\n       cohead_billtoaddress1,\n       cohead_billtoaddress2,\n       cohead_billtoaddress3,\n       (cohead_billtocity || '  ' || cohead_billtostate || '  ' || cohead_billtozipcode) AS billtocitystatezip,\n       cntct_phone AS cust_phone,\n       cohead_shiptoname,\n       cohead_shiptoaddress1,\n       cohead_shiptoaddress2,\n       cohead_shiptoaddress3,\n       (cohead_shiptocity || '  ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n       cohead_number,\n       cohead_shipvia,\n       cohead_shiptophone,\n       cohead_custponumber,\n       formatDate(cohead_orderdate) AS orderdate,\n       cohead_shipcomments, \n       terms_descrip\n  FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n  JOIN terms ON (cohead_terms_id=terms_id)\n  LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n WHERE (cohead_id=&lt;? value("sohead_id") ?>);\n\n-------------------\n&lt;? else ?>\n--Run New Query for Header with shipment number\n-----------------------------------------------\n\nSELECT shiphead_number,\n\n       cohead_number,\n       formatsobarcode(cohead_id) AS order_barcode,\n       cohead_shipvia,\n       cohead_shiptophone,\n       cohead_custponumber,\n       formatDate(cohead_orderdate) AS orderdate,\n       cohead_shipcomments,   \n       cohead_billtoname,\n       formataddr(cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3,\n                  (cohead_billtocity || '  ' ||   cohead_billtostate || '  ' || cohead_billtozipcode), cohead_billtocountry) AS billing_address,\n       cohead_shiptoname,\n       formataddr(cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3,\n                  (cohead_shiptocity || '  ' ||   cohead_shiptostate || '  ' || cohead_shiptozipcode), cohead_shiptocountry) AS shipping_address,           \n\n       cust_number,\n       trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n       cntct_phone AS cust_phone,\n       cohead_shipchrg_id,\n       shipchrg_descrip,\n\n       terms_descrip\n  FROM shiphead\n  JOIN cohead ON (cohead_id=shiphead_order_id)\n  JOIN custinfo ON (cohead_cust_id=cust_id)\n  JOIN terms ON (cohead_terms_id=terms_id)\n  JOIN shipchrg ON (cohead_shipchrg_id = shipchrg_id)\n  LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n WHERE (shiphead_id=&lt;? value("shiphead_id") ?>);\n\n&lt;? endif ?></sql>\n </querysource>\n <querysource>\n  <name>scheddate</name>\n  <sql>&lt;? if not exists("shiphead_id") ?>\n--Query without shipment number\n\nSELECT formatDate(MIN(coitem_scheddate)) AS scheddate\n  FROM coitem\n WHERE ((coitem_status &lt;> 'X') AND (coitem_cohead_id=&lt;? value("sohead_id") ?>));\n\n--\n&lt;? else ?>\n--------------------------\n\n\nSELECT formatDate(MIN(coitem_scheddate)) AS scheddate\n  FROM coitem, shipitem\n WHERE ((coitem_status &lt;> 'X')\n   AND  (coitem_id=shipitem_orderitem_id)\n   AND  (shipitem_shiphead_id=&lt;? value("shiphead_id") ?>));\n\n&lt;? endif ?></sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>salesOrderItems</mqlgroup>\n  <mqlname>list</mqlname>\n </querysource>\n <querysource>\n  <name>logo</name>\n  <sql>SELECT image_data \nFROM image \nWHERE ((image_name='logo'));</sql>\n </querysource>\n <querysource>\n  <name>footer</name>\n  <sql>SELECT formatMoney(calcSalesOrderAmt(cohead_id, 'S')) AS f_subtotal,\n       formatMoney(calcSalesOrderAmt(cohead_id, 'T')) AS f_total,\n       formatMoney(calcSalesOrderAmt(cohead_id, 'B')) AS f_balance,\n       formatMoney(calcSalesOrderAmt(cohead_id, 'X')) AS f_tax,\n       formatMoney(calcSalesOrderAmt(cohead_id, 'C')) AS f_credit,\n       formatMoney(cohead_freight) AS f_freight,\n       formatMoney(cohead_misc) AS f_misc\nFROM cohead\nWHERE (cohead_id=&lt;? value("sohead_id") ?>)\n;</sql>\n </querysource>\n <querysource>\n  <name>lastupdated</name>\n  <sql>SELECT formatDate(MAX(lastupdated)) AS f_lastupdated\n  FROM (SELECT cohead_lastupdated AS lastupdated\n          FROM cohead\n         WHERE (cohead_id=&lt;? value("sohead_id") ?>)\n         UNION\n        SELECT coitem_lastupdated AS lastupdated\n          FROM coitem\n         WHERE (coitem_cohead_id=&lt;? value("sohead_id") ?>) ) AS data;</sql>\n </querysource>\n <querysource>\n  <name>currency</name>\n  <sql>SELECT currConcat(curr_id) AS currConcat, curr_symbol\nFROM cohead, curr_symbol\nWHERE (cohead_id = &lt;? value("sohead_id") ?>)\n AND  (cohead_curr_id = curr_id);</sql>\n </querysource>\n <rpthead>\n  <height>426</height>\n  <image>\n   <rect>\n    <x>6</x>\n    <y>7</y>\n    <width>426</width>\n    <height>115</height>\n   </rect>\n   <mode>stretch</mode>\n   <data>\n    <query>logo</query>\n    <column>image_data</column>\n   </data>\n  </image>\n  <line>\n   <xstart>210</xstart>\n   <ystart>330</ystart>\n   <xend>330</xend>\n   <yend>330</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>305</y>\n    <width>140</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>PO Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>40</x>\n    <y>335</y>\n    <width>145</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>539</x>\n    <y>39</y>\n    <width>250</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Times New Roman</face>\n    <size>20</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>391</x>\n    <y>8</y>\n    <width>406</width>\n    <height>30</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sales Order Acknowledgement</string>\n  </label>\n  <line>\n   <xstart>470</xstart>\n   <ystart>330</ystart>\n   <xend>647</xend>\n   <yend>330</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>200</x>\n    <y>335</y>\n    <width>165</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>terms_descrip</column>\n   </data>\n  </field>\n  <line>\n   <xstart>45</xstart>\n   <ystart>330</ystart>\n   <xend>177</xend>\n   <yend>330</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>355</x>\n    <y>335</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>scheddate</query>\n    <column>scheddate</column>\n   </data>\n  </field>\n  <line>\n   <xstart>15</xstart>\n   <ystart>415</ystart>\n   <xend>785</xend>\n   <yend>415</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>390</y>\n    <width>67</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>9</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>535.987</x>\n    <y>140.037</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>9</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>SHIP TO:</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>305</y>\n    <width>57</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ship Via:</string>\n  </label>\n  <label>\n   <rect>\n    <x>230</x>\n    <y>310</y>\n    <width>57</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Terms</string>\n  </label>\n  <label>\n   <rect>\n    <x>130</x>\n    <y>390</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>9</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>360</xstart>\n   <ystart>330</ystart>\n   <xend>440</xend>\n   <yend>330</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>622</x>\n    <y>70</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>orderdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>305</y>\n    <width>70</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ship Date</string>\n  </label>\n  <line>\n   <xstart>269.976</xstart>\n   <ystart>160.037</ystart>\n   <xend>491.976</xend>\n   <yend>160.037</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>720</x>\n    <y>390</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>9</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <field>\n   <rect>\n    <x>535.987</x>\n    <y>170.037</y>\n    <width>254.338</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoname</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>335</y>\n    <width>195</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shipvia</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>390</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>9</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price</string>\n  </label>\n  <field>\n   <rect>\n    <x>655</x>\n    <y>335</y>\n    <width>95</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>cohead_fob</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>270.976</x>\n    <y>191.037</y>\n    <width>256</width>\n    <height>22.2821</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>billing_address</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>390</y>\n    <width>95</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>9</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <text>\n   <rect>\n    <x>535.987</x>\n    <y>190.037</y>\n    <width>253.562</width>\n    <height>20.2425</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>shipping_address</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>271.529</x>\n    <y>140.037</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>9</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>BILL TO:</string>\n  </label>\n  <line>\n   <xstart>670</xstart>\n   <ystart>330</ystart>\n   <xend>750</xend>\n   <yend>330</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>435</x>\n    <y>390</y>\n    <width>70</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>9</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>685</x>\n    <y>305</y>\n    <width>37</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>FOB</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>390</y>\n    <width>40</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>9</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>271.976</x>\n    <y>170.037</y>\n    <width>256</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_billtoname</column>\n   </data>\n  </field>\n  <line>\n   <xstart>535.987</xstart>\n   <ystart>160.037</ystart>\n   <xend>766.987</xend>\n   <yend>160.037</yend>\n   <weight>0</weight>\n  </line>\n  <text>\n   <rect>\n    <x>17.6809</x>\n    <y>192.59</y>\n    <width>222</width>\n    <height>21.011</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>billing_address</column>\n   </data>\n  </text>\n  <field>\n   <rect>\n    <x>17.6809</x>\n    <y>171.59</y>\n    <width>213</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_billtoname</column>\n   </data>\n  </field>\n  <line>\n   <xstart>15.8119</xstart>\n   <ystart>162.124</ystart>\n   <xend>224.257</xend>\n   <yend>162.137</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>14.7743</x>\n    <y>144.768</y>\n    <width>165.637</width>\n    <height>16.0854</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>9</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>CUSTOMER ADDRESS:</string>\n  </label>\n </rpthead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>groupby</column>\n   <foot>\n    <height>36</height>\n    <text>\n     <rect>\n      <x>37</x>\n      <y>7</y>\n      <width>707</width>\n      <height>21</height>\n     </rect>\n     <bottompad>14</bottompad>\n     <font>\n      <face>Arial</face>\n      <size>12</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>cohead_shipcomments</column>\n     </data>\n    </text>\n   </foot>\n  </group>\n  <group>\n   <name>lineitem</name>\n   <column>coitem_linenumber</column>\n   <foot>\n    <height>6</height>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>41</height>\n   <field>\n    <rect>\n     <x>15</x>\n     <y>0</y>\n     <width>85</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number_cust</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>5</y>\n     <width>27</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>qty_uom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>515</x>\n     <y>0</y>\n     <width>65</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>3</y>\n     <width>56</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_price</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>125</x>\n     <y>25</y>\n     <width>435</width>\n     <height>12</height>\n    </rect>\n    <bottompad>14</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>coitem_memo</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>705</x>\n     <y>3</y>\n     <width>82</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_extprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>435</x>\n     <y>0</y>\n     <width>65</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyord</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>102</x>\n     <y>0</y>\n     <width>325</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1_cust</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <lastpage/>\n  <height>233</height>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>48</y>\n    <width>115</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>MISCELLANEOUS</string>\n  </label>\n  <label>\n   <rect>\n    <x>390</x>\n    <y>138</y>\n    <width>170</width>\n    <height>30</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Balance Due:</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>28</y>\n    <width>97</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>footer</query>\n    <column>f_freight</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>48</y>\n    <width>97</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>footer</query>\n    <column>f_misc</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>33</y>\n    <width>115</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>FREIGHT</string>\n  </label>\n  <field>\n   <rect>\n    <x>605</x>\n    <y>133</y>\n    <width>172</width>\n    <height>32</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>16</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>footer</query>\n    <column>f_balance</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>13</y>\n    <width>115</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>SUBTOTAL</string>\n  </label>\n  <field>\n   <rect>\n    <x>675</x>\n    <y>8</y>\n    <width>92</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>footer</query>\n    <column>f_subtotal</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>68</y>\n    <width>115</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>TAX</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>68</y>\n    <width>97</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>footer</query>\n    <column>f_tax</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>88</y>\n    <width>102</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>footer</query>\n    <column>f_total</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>88</y>\n    <width>115</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>TOTAL</string>\n  </label>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>108</y>\n    <width>115</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>CREDITS</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>108</y>\n    <width>102</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>footer</query>\n    <column>f_credit</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>635</x>\n    <y>48</y>\n    <width>30</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>635</x>\n    <y>68</y>\n    <width>30</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>635</x>\n    <y>8</y>\n    <width>30</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>143</y>\n    <width>30</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n    <italic/>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>635</x>\n    <y>28</y>\n    <width>30</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>635</x>\n    <y>88</y>\n    <width>30</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>635</x>\n    <y>108</y>\n    <width>30</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>28</height>\n </rptfoot>\n</report>\n      Customer Order Acknowledgement  0       2014-10-06 19:47:03.678943
102501
 
342     FinancialReportQuarterPriorQuarter      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Quarter and Prior Quarter</title>\n <name>FinancialReportQuarterPriorQuarter</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_typedescrip2 || ' Diff.' AS f_diff,\n    flstmthead_typedescrip2 || ' % Diff.' AS f_diffprcnt,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_qtr &lt;> 0) OR (flstmtitem_prqtr &lt;> 0) OR (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n</sql>\n </querysource>\n <rpthead>\n  <height>167</height>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diff</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prqtr</column>\n   </data>\n  </field>\n  <line>\n   <xstart>0</xstart>\n   <ystart>159</ystart>\n   <xend>749</xend>\n   <yend>159</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prqtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diffprcnt</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prqtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>99</x>\n    <y>59.6</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>59.5</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>4</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prqtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diffprcnt</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prqtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diff</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prqtr</column>\n   </data>\n  </field>\n  <line>\n   <xstart>1</xstart>\n   <ystart>30</ystart>\n   <xend>748</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>4</height>\n    <line>\n     <xstart>380</xstart>\n     <ystart>1</ystart>\n     <xend>740</xend>\n     <yend>1</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>19</height>\n   <field>\n    <rect>\n     <x>380</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_qtr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_prqtrdiffprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_prqtr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>345</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_prqtrdiff</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>9</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>22</height>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>7</height>\n </rptfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102502
 
343     FinancialReportYear     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Year</title>\n <name>FinancialReportYear</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_year &lt;> 0) OR  (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n</sql>\n </querysource>\n <rpthead>\n  <height>167</height>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>145</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>1</xstart>\n   <ystart>160</ystart>\n   <xend>749</xend>\n   <yend>160</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <field>\n   <rect>\n    <x>570</x>\n    <y>130</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>130</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>570</x>\n    <y>145</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>99</x>\n    <y>59.6</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>59.5</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>4</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <field>\n   <rect>\n    <x>570</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <line>\n   <xstart>0</xstart>\n   <ystart>31</ystart>\n   <xend>751</xend>\n   <yend>31</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>570</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>660.457</x>\n    <y>14.5678</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>0.717997</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>4</height>\n    <line>\n     <xstart>390</xstart>\n     <ystart>0</ystart>\n     <xend>750</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>19</height>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_yearprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>550</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>570</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_year</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>9</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>22</height>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>7</height>\n </rptfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102503
 
348     FinancialTrend  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Trend</title>\n <name>FinancialTrend</name>\n <description>Financial Trend Report</description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flhead_id">\n  <description>Financial Report Layout</description>\n  <query>SELECT flhead_id, flhead_name FROM flhead WHERE (flhead_active)</query>\n </parameter>\n <parameter default="M" active="true" listtype="static" type="string" name="interval">\n  <description>Time period buckets</description>\n  <item value="M">Month</item>\n  <item value="Q">Quarter</item>\n  <item value="Y">Year</item>\n </parameter>\n <parameter default="" active="true" listtype="dynamic" type="integer" name="period_id_list">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <parameter default="true" active="false" listtype="static" type="bool" name="shownumbers">\n  <description>Display account numbers with description</description>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>25</rightmargin>\n <leftmargin>25</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    fltrendhead_username,\n    fltrendhead_flhead_name,\n    fltrendhead_typedescrip,\n    fltrendhead_fld1,\n    fltrendhead_fld2,\n    fltrendhead_fld3,\n    fltrendhead_fld4,\n    fltrendhead_fld5,\n    fltrendhead_fld6,\n    fltrendhead_fld7,\n    fltrendhead_fld8,\n    fltrendhead_fld9,\n    fltrendhead_fld10,\n    fltrendhead_fld11,\n    fltrendhead_fld12,\n    fltrendhead_grndttl\nFROM getfltrendhead(&lt;? value("flhead_id") ?>,ARRAY[\n   &lt;? foreach("period_id_list") ?>\n     &lt;? if not isfirst("period_id_list") ?>\n      ,\n     &lt;? endif ?>\n    &lt;? value("period_id_list") ?>\n   &lt;? endforeach ?>\n],&lt;? value("interval") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    fltrenditem_flhead_id,\n    fltrenditem_username,\n    fltrenditem_order,\n    fltrenditem_level,\n    fltrenditem_subgrp,\n    fltrenditem_type,\n    fltrenditem_type_id,\n    fltrenditem_parent_id,\n    fltrenditem_accnt_id,\n    fltrenditem_name,\n    fltrenditem_fld1,\n    fltrenditem_fld2,\n    fltrenditem_fld3,\n    fltrenditem_fld4,\n    fltrenditem_fld5,\n    fltrenditem_fld6,\n    fltrenditem_fld7,\n    fltrenditem_fld8,\n    fltrenditem_fld9,\n    fltrenditem_fld10,\n    fltrenditem_fld11,\n    fltrenditem_fld12,\n    fltrenditem_grndttl\nFROM\n   financialReport(&lt;? value("flhead_id") ?>, ARRAY[\n   &lt;? foreach("period_id_list") ?>\n     &lt;? if not isfirst("period_id_list") ?>\n      ,\n     &lt;? endif ?>\n    &lt;? value("period_id_list") ?>\n   &lt;? endforeach ?>\n],&lt;? value("interval") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((fltrenditem_fld1 &lt;> formatMoney(0) AND fltrenditem_fld1 IS NOT NULL) \n\tOR (fltrenditem_fld1 &lt;> formatMoney(0) AND fltrenditem_fld1 IS NOT NULL)\n\tOR (fltrenditem_fld2 &lt;> formatMoney(0) AND fltrenditem_fld2 IS NOT NULL)\n\tOR (fltrenditem_fld3 &lt;> formatMoney(0) AND fltrenditem_fld3 IS NOT NULL)\n\tOR (fltrenditem_fld4 &lt;> formatMoney(0) AND fltrenditem_fld4 IS NOT NULL)\n\tOR (fltrenditem_fld5 &lt;> formatMoney(0) AND fltrenditem_fld5 IS NOT NULL)\n\tOR (fltrenditem_fld6 &lt;> formatMoney(0) AND fltrenditem_fld6 IS NOT NULL)\n\tOR (fltrenditem_fld7 &lt;> formatMoney(0) AND fltrenditem_fld7 IS NOT NULL)\n\tOR (fltrenditem_fld8 &lt;> formatMoney(0) AND fltrenditem_fld8 IS NOT NULL)\n\tOR (fltrenditem_fld9 &lt;> formatMoney(0) AND fltrenditem_fld9 IS NOT NULL)\n\tOR (fltrenditem_fld10 &lt;> formatMoney(0) AND fltrenditem_fld10 IS NOT NULL)\n\tOR (fltrenditem_fld11 &lt;> formatMoney(0) AND fltrenditem_fld11 IS NOT NULL)\n\tOR (fltrenditem_fld12 &lt;> formatMoney(0) AND fltrenditem_fld12 IS NOT NULL)\n\tOR (fltrenditem_type &lt;> 'I'))\n&lt;? endif ?></sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, text('Notes') AS label, flhead_notes AS notes, \n  startOfTime() AS period_end\nFROM flhead\nWHERE ((flhead_id=&lt;? value("flhead_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, period_name AS label, flnotes_notes AS notes, \n  period_end\nFROM flnotes\n  JOIN period ON (flnotes_period_id=period_id)\nWHERE ((flnotes_flhead_id=&lt;? value("flhead_id") ?>)\n  AND (\n   &lt;? foreach("period_id_list") ?>\n     &lt;? if not isfirst("period_id_list") ?>\n      OR \n     &lt;? endif ?>\n    (flnotes_period_id=&lt;? value("period_id_list") ?>)\n   &lt;? endforeach ?>\n  )\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq, period_end;\n</sql>\n </querysource>\n <rpthead>\n  <height>149</height>\n  <field>\n   <rect>\n    <x>208</x>\n    <y>120</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>60</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_flhead_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>860</x>\n    <y>120</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld11</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>918</x>\n    <y>120</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld12</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>469</x>\n    <y>120</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld5</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>405</x>\n    <y>120</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld4</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>600</x>\n    <y>120</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld7</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>275</x>\n    <y>120</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>795</x>\n    <y>120</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld10</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>135</ystart>\n   <xend>1050</xend>\n   <yend>135</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>535</x>\n    <y>120</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld6</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>120</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld8</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>104</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_typedescrip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>120</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>989</x>\n    <y>120</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_grndttl</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>10</y>\n    <width>350</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Trend</string>\n  </label>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>60</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>340</x>\n    <y>120</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld3</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>730</x>\n    <y>120</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld9</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>40</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>20</x>\n    <y>40</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>10</height>\n </pghead>\n <pghead>\n  <height>43</height>\n  <field>\n   <rect>\n    <x>208</x>\n    <y>10</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>340</x>\n    <y>10</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld3</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>10</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld8</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>600</x>\n    <y>10</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld7</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>535</x>\n    <y>10</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld6</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>1050</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>405</x>\n    <y>10</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld4</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>730</x>\n    <y>10</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld9</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>795</x>\n    <y>10</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld10</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>918</x>\n    <y>10</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld12</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>860</x>\n    <y>10</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld11</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>280</x>\n    <y>10</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>469</x>\n    <y>10</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_fld5</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>985</x>\n    <y>10</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>fltrendhead_grndttl</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>8.5</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>fltrenditem_subgrp</column>\n   <foot>\n    <height>7</height>\n    <line>\n     <xstart>204</xstart>\n     <ystart>0</ystart>\n     <xend>1055</xend>\n     <yend>0</yend>\n     <weight>1</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>19</height>\n   <field>\n    <rect>\n     <x>925</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_fld12</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_fld8</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>340</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_fld3</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>469</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_fld5</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>860</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_fld11</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_fld7</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>535</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_fld6</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>405</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_fld4</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>730</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_fld9</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>208</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_fld1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>795</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_fld10</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>989</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_grndttl</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>195</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>275</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>fltrenditem_fld2</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>32</height>\n   <text>\n    <rect>\n     <x>10</x>\n     <y>17</y>\n     <width>1025</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>2</y>\n     <width>500</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>notes</query>\n     <column>label</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>29</height>\n  <label>\n   <rect>\n    <x>839</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>930</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n      Financial Trend Report  0       2014-10-06 19:47:03.678943
102504
 
241     CustomerARHistory       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Customer A/R History</title>\n <name>CustomerARHistory</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT cust_name,\n       formatDate(date(&lt;? value("startDate") ?>)) AS startDate,\n       formatDate(date(&lt;? value("endDate") ?>)) AS endDate\n  FROM custinfo\n WHERE (cust_id=&lt;? value("cust_id") ?>);\n    </sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>arHistory</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>156</height>\n  <label>\n   <rect>\n    <x>444</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>444</x>\n    <y>135</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>endDate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>135</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>135</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>444</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>135</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>5</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer A/R History</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startDate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>65</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>135</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Open</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>150</ystart>\n   <xend>745</xend>\n   <yend>150</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>135</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>135</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Date</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>444</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Open</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>amount</column>\n    </data>\n    <format builtin="true">extprice</format>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>balance</column>\n    </data>\n    <format builtin="true">extprice</format>\n   </field>\n   <field>\n    <rect>\n     <x>349</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_docdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>444</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_open</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>170</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>documenttype</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>104</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102505
 
477     CustomerBOL     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Drop Ship Bill of Lading</title>\n <name>CustomerBOL</name>\n <description></description>\n <size>\n  <width>850</width>\n  <height>1100</height>\n </size>\n <portrait/>\n <topmargin>0</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>0</rightmargin>\n <leftmargin>0</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT shiphead_shipvia, formatDate(shiphead_shipdate) AS shipdate,\n                cust_name, ca.addr_line1 AS cust_address1, ca.addr_line2 AS cust_address2,\n                (ca.addr_city || '  ' || ca.addr_state || '  ' || ca.addr_postalcode) AS custcitystatezip,\n                cust_number, cohead_number, cohead_fob, cohead_custponumber,\n                warehous_descrip, wa.addr_line1 AS warehous_addr1, wa.addr_line2 AS warehous_addr2, wa.addr_line3 AS warehous_addr3, wa.addr_city AS warehous_addr4, warehous_fob,\n                cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3,\n                (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n                cohead_shiptophone\n         FROM shiphead, cohead, whsinfo, custinfo\n         LEFT OUTER JOIN addr ca ON (cntct_addr_id=ca.addr_id)\n         LEFT OUTER JOIN addr wa ON (warehous_addr_id=wa.addr_id);\n         WHERE ((shiphead_order_id=cohead_id)\n          AND (cohead_cust_id=cust_id)\n          AND (cohead_warehous_id=warehous_id)\n          AND (shiphead_id=%1));</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT coitem_linenumber, formatQty(SUM(shipitem_qty)) AS invqty, uom_name, roundUp(SUM(shipitem_qty) / itemuomratiobytype(item_id, 'Selling'))::integer AS shipqty,\n                itemsellinguom(item_id) AS shipuom, item_number, item_descrip1, item_descrip2,\n                formatQty(SUM(shipitem_qty) * item_prodweight) AS netweight,\n                formatQty(SUM(shipitem_qty) * (item_prodweight + item_packweight)) AS grossweight\n         FROM shipitem, coitem, itemsite, item, uom\n         WHERE ((shipitem_orderitem_id=coitem_id)\n          AND (coitem_itemsite_id=itemsite_id)\n          AND (itemsite_item_id=item_id)\n          AND (item_inv_uom_id=uom_id)\n          AND (shipitem_shiphead_id=%1))\n         GROUP BY coitem_linenumber, item_number, uom_name, shipuom\n                  item_descrip1, item_descrip2, item_prodweight, item_packweight\n         ORDER BY coitem_linenumber;\n    </sql>\n </querysource>\n <querysource>\n  <name>foot</name>\n  <sql>SELECT formatQty(SUM(shipitem_qty * item_prodweight)) AS netweight,\n                formatQty(SUM(shipitem_qty * (item_prodweight + item_packweight))) AS grossweight,\n                CASE\n                 WHEN ('%3' = 'C') THEN 'X'\n                 ELSE ' '\n                END AS collectflag,\n                CASE\n                 WHEN ('%3' = 'C') THEN 'Therm-O-Rock East, Inc.'\n                 ELSE ' '\n                END AS section7,\n                CASE\n                 WHEN ('%3' = 'C') THEN cust_name\n                 ELSE ' '\n                END AS collect_name,\n                CASE\n                 WHEN ('%3' = 'C') THEN addr_line1\n                 ELSE ' '\n                END AS collect_address1,\n                CASE\n                 WHEN ('%3' = 'C') THEN addr_line2\n                 ELSE ' '\n                END AS collect_address2,\n                CASE\n                 WHEN ('%3' = 'C') THEN (addr_city || '  ' || addr_state || '  ' || addr_postalcode)\n                 ELSE ' '\n                END AS collect_address3\n         FROM shipitem, cohead, custinfo, coitem, itemsite, item\n         LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n         WHERE ((shipitem_orderitem_id=coitem_id)\n          AND (coitem_itemsite_id=itemsite_id)\n          AND (itemsite_item_id=item_id)\n          AND (coitem_cohead_id=cohead_id)\n          AND (cohead_cust_id=cust_id)\n          AND (shipitem_shiphead_id=%1))\n         GROUP BY cust_name, addr_line1, addr_line2, addr_city, addr_state, addr_postalcode;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT shiphead_notes\n         FROM shiphead\n         WHERE (shiphead_id=%1);</sql>\n </querysource>\n <pghead>\n  <firstpage/>\n  <height>318</height>\n  <field>\n   <rect>\n    <x>532</x>\n    <y>224</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shiptocitystatezip</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>532</x>\n    <y>205</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoaddress3</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>93</x>\n    <y>168</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_addr2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>93</x>\n    <y>205</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_addr4</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>532</x>\n    <y>168</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoaddress1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>93</x>\n    <y>149</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>532</x>\n    <y>149</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoname</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>532</x>\n    <y>242</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptophone</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>578</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shipdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>93</x>\n    <y>186</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_addr3</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>93</x>\n    <y>224</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>724-258-3670</string>\n  </label>\n  <field>\n   <rect>\n    <x>121</x>\n    <y>65</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shiphead_shipvia</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>532</x>\n    <y>186</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoaddress2</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n    <column>coitem_linenumber</column>\n   </key>\n   <height>54</height>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>40</y>\n     <width>300</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>94</x>\n     <y>5</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>30</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invqty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>25</y>\n     <width>300</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>94</x>\n     <y>30</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>5</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipqty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>5</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>netweight</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>5</y>\n     <width>300</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>25</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>grossweight</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <lastpage/>\n  <height>346</height>\n  <field>\n   <rect>\n    <x>614</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>230</x>\n    <y>200</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>collect_address3</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>100</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Order #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>20</x>\n    <y>180</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>collect_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>520</x>\n    <y>5</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>netweight</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>50</x>\n    <y>10</y>\n    <width>400</width>\n    <height>100</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>notes</query>\n    <column>shiphead_notes</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>614</x>\n    <y>120</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>20</x>\n    <y>200</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>collect_address1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>438</x>\n    <y>270</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>section7</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>520</x>\n    <y>25</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>grossweight</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>80</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>614</x>\n    <y>60</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_fob</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>230</x>\n    <y>180</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>collect_address2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>728</x>\n    <y>270</y>\n    <width>46</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>collectflag</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>614</x>\n    <y>100</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>480</x>\n    <y>120</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer P/O #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>60</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipped From:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102506
 
70      CustomerTypesMasterList \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Customer Types Master List</title>\n <name>CustomerTypesMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>select custtype_code, custtype_descrip\n  from custtype\norder by custtype_code;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type Code</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer Types Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>custtype_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>custtype_code</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102507
 
454     Customers       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Customers</title>\n <name>Customers</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>-- Group: customers\n-- Name:  detail\n-- Notes: \n\nSELECT DISTINCT ON ( cust_number )\n  cust_id, cust_custtype_id, \n  formatBoolYN(cust_active) as f_active,\n  formatAddr(bill_addr.addr_id) AS f_bill_addr,\n  formatAddr(corr_addr.addr_id) AS f_corr_addr,\n  bill_cntct.cntct_name AS bill_cntct_name,\n  corr_cntct.cntct_name AS corr_cntct_name,\n  cust_active, cust_number, cust_name,\n  custtype_code,\n  bill_cntct.cntct_first_name AS bill_first_name,\n  bill_cntct.cntct_last_name AS bill_last_name,\n  bill_cntct.cntct_phone AS bill_phone,\n  bill_cntct.cntct_fax AS bill_fax,\n  bill_cntct.cntct_email AS bill_email,\n  bill_addr.addr_line1 AS bill_line1,\n  bill_addr.addr_line2 AS bill_line2,\n  bill_addr.addr_line3 AS bill_line3,\n  bill_addr.addr_city AS bill_city,\n  bill_addr.addr_state AS bill_state,\n  bill_addr.addr_postalcode AS bill_postalcode,\n  bill_addr.addr_country AS bill_country,\n  corr_cntct.cntct_first_name AS corr_first_name,\n  corr_cntct.cntct_last_name AS corr_last_name,\n  corr_cntct.cntct_phone AS corr_phone,\n  corr_cntct.cntct_fax AS corr_fax,\n  corr_cntct.cntct_email AS corr_email,\n  corr_addr.addr_line1 AS corr_line1,\n  corr_addr.addr_line2 AS corr_line2,\n  corr_addr.addr_line3 AS corr_line3,\n  corr_addr.addr_city AS corr_city,\n  corr_addr.addr_state AS corr_state,\n  corr_addr.addr_postalcode AS corr_postalcode,\n  corr_addr.addr_country AS corr_country\n&lt;? foreach("char_id_list") ?>\n  , charass_alias&lt;? literal("char_id_list") ?>.charass_value AS char&lt;? literal("char_id_list") ?>\n&lt;? endforeach ?>\nFROM custinfo\n  JOIN custtype ON (cust_custtype_id=custtype_id)\n  LEFT OUTER JOIN cntct bill_cntct ON (cust_cntct_id=bill_cntct.cntct_id) \n  LEFT OUTER JOIN addr bill_addr ON (bill_cntct.cntct_addr_id=bill_addr.addr_id)\n  LEFT OUTER JOIN cntct corr_cntct ON (cust_corrcntct_id=corr_cntct.cntct_id) \n  LEFT OUTER JOIN addr corr_addr ON (corr_cntct.cntct_addr_id=corr_addr.addr_id)  \n&lt;? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias&lt;? literal("char_id_text_list") ?> ON ((charass_alias&lt;? literal("char_id_text_list") ?>.charass_target_type='C') \n                                                                    AND  (charass_alias&lt;? literal("char_id_text_list") ?>.charass_target_id=cust_id)\n                                                                    AND  (charass_alias&lt;? literal("char_id_text_list") ?>.charass_char_id=&lt;? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias&lt;? literal("char_id_text_list") ?> ON (charass_alias&lt;? literal("char_id_text_list") ?>.charass_char_id=char_alias&lt;? literal("char_id_text_list") ?>.char_id)\n&lt;? endforeach ?>\n&lt;? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias&lt;? literal("char_id_list_list") ?> ON ((charass_alias&lt;? literal("char_id_list_list") ?>.charass_target_type='C') \n                                                                    AND  (charass_alias&lt;? literal("char_id_list_list") ?>.charass_target_id=cust_id)\n                                                                    AND  (charass_alias&lt;? literal("char_id_list_list") ?>.charass_char_id=&lt;? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias&lt;? literal("char_id_list_list") ?> ON (charass_alias&lt;? literal("char_id_list_list") ?>.charass_char_id=char_alias&lt;? literal("char_id_list_list") ?>.char_id)\n&lt;? endforeach ?>\n&lt;? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias&lt;? literal("char_id_date_list") ?> ON ((charass_alias&lt;? literal("char_id_date_list") ?>.charass_target_type='C') \n                                                                    AND  (charass_alias&lt;? literal("char_id_date_list") ?>.charass_target_id=cust_id)\n                                                                    AND  (charass_alias&lt;? literal("char_id_date_list") ?>.charass_char_id=&lt;? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias&lt;? literal("char_id_date_list") ?> ON (charass_alias&lt;? literal("char_id_date_list") ?>.charass_char_id=char_alias&lt;? literal("char_id_date_list") ?>.char_id)\n&lt;? endforeach ?>\nWHERE true\n&lt;? if not exists("showInactive") ?> \n  AND cust_active \n&lt;? endif ?>\n&lt;? if exists("search_pattern") ?>\n  AND ((cust_number ~* &lt;? value("search_pattern") ?>)\n       OR (cust_name ~* &lt;? value("search_pattern") ?>)\n       OR (custtype_code ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(bill_cntct.cntct_first_name || ' ' || bill_cntct.cntct_last_name,'') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(bill_cntct.cntct_phone || ' ' || bill_cntct.cntct_phone2 || ' ' || bill_cntct.cntct_fax, '') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(bill_cntct.cntct_email, '') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_line1 || ' ' || bill_addr.addr_line2 || ' ' || bill_addr.addr_line3,'') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_city,'') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_state,'') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_postalcode,'') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_country,'') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(corr_cntct.cntct_first_name || ' ' || corr_cntct.cntct_last_name,'') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(corr_cntct.cntct_phone || ' ' || corr_cntct.cntct_phone2 || ' ' || corr_cntct.cntct_fax, '') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(corr_cntct.cntct_email, '') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_line1 || ' ' || corr_addr.addr_line2 || ' ' || corr_addr.addr_line3,'') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_city,'') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_state,'') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_postalcode,'') ~* &lt;? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_country,'') ~* &lt;? value("search_pattern") ?>))\n&lt;? endif ?>\n&lt;? if exists("cust_number_pattern") ?>\n  AND (cust_number ~* &lt;? value("cust_number_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("cust_name_pattern") ?>\n  AND (cust_name ~* &lt;? value("cust_name_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("custtype_code_pattern") ?>\n  AND (custtype_code ~* &lt;? value("custtype_code_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("cntct_name_pattern") ?>\n  AND (COALESCE(bill_cntct.cntct_first_name || ' ' || bill_cntct.cntct_last_name, '') ~* &lt;? value("cntct_name_pattern") ?> \n   OR  COALESCE(corr_cntct.cntct_first_name || ' ' || corr_cntct.cntct_last_name, '') ~* &lt;? value("cntct_name_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("cntct_phone_pattern") ?>\n  AND (COALESCE(bill_cntct.cntct_phone || ' ' || bill_cntct.cntct_phone2 || ' ' || bill_cntct.cntct_fax,'') ~* &lt;? value("cntct_phone_pattern") ?>\n   OR  COALESCE(corr_cntct.cntct_phone || ' ' || corr_cntct.cntct_phone2 || ' ' || corr_cntct.cntct_fax,'') ~* &lt;? value("cntct_phone_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("cntct_email_pattern") ?>\n  AND (COALESCE(bill_cntct.cntct_email,'') ~* &lt;? value("cntct_email_pattern") ?>\n   OR  COALESCE(corr_cntct.cntct_email,'') ~* &lt;? value("cntct_email_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("addr_street_pattern") ?>\n  AND (COALESCE(bill_addr.addr_line1 || ' ' || bill_addr.addr_line2 || ' ' || bill_addr.addr_line3,'') ~* &lt;? value("addr_street_pattern") ?>\n   OR  COALESCE(corr_addr.addr_line1 || ' ' || corr_addr.addr_line2 || ' ' || corr_addr.addr_line3,'') ~* &lt;? value("addr_street_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("addr_city_pattern") ?>\n  AND (COALESCE(bill_addr.addr_city,'') ~* &lt;? value("addr_city_pattern") ?>\n   OR  COALESCE(corr_addr.addr_city,'') ~* &lt;? value("addr_city_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("addr_state_pattern") ?>\n  AND (COALESCE(bill_addr.addr_state,'') ~* &lt;? value("addr_state_pattern") ?>\n   OR  COALESCE(corr_addr.addr_state,'') ~* &lt;? value("addr_state_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("addr_postalcode_pattern") ?>\n  AND (COALESCE(bill_addr.addr_postalcode,'') ~* &lt;? value("addr_postalcode_pattern") ?>\n   OR  COALESCE(corr_addr.addr_postalcode,'') ~* &lt;? value("addr_postalcode_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("addr_country_pattern") ?>\n  AND (COALESCE(bill_addr.addr_country,'') ~* &lt;? value("addr_country_pattern") ?>\n   OR  COALESCE(corr_addr.addr_country,'') ~* &lt;? value("addr_country_pattern") ?>)\n&lt;? endif ?>\n&lt;? literal("charClause") ?>\nORDER BY cust_number; </sql>\n </querysource>\n <rpthead>\n  <height>146</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>123</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>140</ystart>\n   <xend>745</xend>\n   <yend>140</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>155</x>\n    <y>123</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>480</x>\n    <y>123</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bill Address</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>123</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customers</string>\n  </label>\n  <text>\n   <rect>\n    <x>5</x>\n    <y>33</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>365</x>\n    <y>123</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>480</x>\n    <y>-1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bill Address</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>-1</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <label>\n   <rect>\n    <x>155</x>\n    <y>-1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>-1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Number</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>365</x>\n    <y>-1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>67</height>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>2</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>2</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_active</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>480</x>\n     <y>2</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_bill_addr</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>155</x>\n     <y>17</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bill_cntct_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>155</x>\n     <y>32</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bill_phone</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>155</x>\n     <y>47</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bill_email</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>75</x>\n     <y>17</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Contact:</string>\n   </label>\n   <label>\n    <rect>\n     <x>75</x>\n     <y>32</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Phone:</string>\n   </label>\n   <label>\n    <rect>\n     <x>75</x>\n     <y>47</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Email:</string>\n   </label>\n   <field>\n    <rect>\n     <x>365</x>\n     <y>2</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>custtype_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>155</x>\n     <y>2</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>105</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102508
 
165     DeliveryDateVariancesByItem     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Delivery Date Variances By Item</title>\n <name>DeliveryDateVariancesByItem</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number, item_descrip1,\n       item_descrip2, uom_name,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("warehous_id") ?>\n         (SELECT warehous_code FROM whsinfo WHERE warehous_id=&lt;? value("warehous_id") ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("agentUsername") ?>\n       TEXT(&lt;? value("agentUsername") ?>)\n       &lt;? else ?>\n       TEXT('All Agents')\n       &lt;? endif ?>\n       AS agentUsername\n  FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=&lt;? value("item_id") ?>);</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>poDeliveryDateVariances</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>185</height>\n  <field>\n   <rect>\n    <x>310</x>\n    <y>47</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>uom_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Delivery Date Variances By Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>196</x>\n    <y>152</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>442</x>\n    <y>47</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>153</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Agrd. Due Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>67</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>47</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <label>\n   <rect>\n    <x>442</x>\n    <y>67</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>129</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purch. Agent:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>153</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>153</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Recv. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>252</x>\n    <y>47</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>47</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>84</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>196</x>\n    <y>167</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>109</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>182</ystart>\n   <xend>745</xend>\n   <yend>182</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>47</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>492</x>\n    <y>153</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>153</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>109</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>129</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>agentUsername</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>67</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>167</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>581</x>\n    <y>167</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reqd. Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>167</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lead Time</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>39</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>492</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Recv. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>196</x>\n    <y>4</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>196</x>\n    <y>19</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>19</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>19</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lead Time</string>\n  </label>\n  <label>\n   <rect>\n    <x>581</x>\n    <y>19</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reqd. Due Date</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>32</height>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_recv_date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>195</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>venditemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>argd_duedate</column>\n    </data>\n   </field>\n   <line>\n    <xstart>7</xstart>\n    <ystart>31</ystart>\n    <xend>747</xend>\n    <yend>31</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>195</x>\n     <y>15</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>venditemdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>recv_order_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>492</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>recv_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>493</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>real_leadtime</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>orderdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>581</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>release_duedate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>102</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102509
 
164     DeliveryDateVariancesByVendor   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Delivery Date Variances By Vendor</title>\n <name>DeliveryDateVariancesByVendor</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT vend_name,\n       vend_number,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("warehous_id") ?>\n         (SELECT warehous_code FROM whsinfo WHERE warehous_id=&lt;? value("warehous_id") ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("agentUsername") ?>\n       TEXT(&lt;? value("agentUsername" ?>)\n       &lt;? else ?>\n       TEXT('All Agents')\n       &lt;? endif ?>\n       AS purchagent\n  FROM vendinfo\n WHERE (vend_id=&lt;? value("vend_id") ?>);</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>poDeliveryDateVariances</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>171</height>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>69</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>110</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>purchagent</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>65</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>110</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purch. Agent:</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>45</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor:</string>\n  </label>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>69</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>264.853</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Delivery Date Variances By Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>49</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>90</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>90</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>49</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>45</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>578</x>\n    <y>138</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>6</x>\n    <y>138</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>666</x>\n    <y>138</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Recv. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>318</x>\n    <y>139</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>152</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lead Time</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>139</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Agrd. Due Date</string>\n  </label>\n  <line>\n   <xstart>1</xstart>\n   <ystart>168</ystart>\n   <xend>741</xend>\n   <yend>168</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>153</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reqd. Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>666</x>\n    <y>152</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>63</x>\n    <y>152</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>63</x>\n    <y>136</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <line>\n   <xstart>4</xstart>\n   <ystart>-1</ystart>\n   <xend>744</xend>\n   <yend>-1</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>1</height>\n </pghead>\n <pghead>\n  <height>35</height>\n  <label>\n   <rect>\n    <x>3</x>\n    <y>4</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>18</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>314</x>\n    <y>3</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>492</x>\n    <y>19</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reqd. Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>663</x>\n    <y>4</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Recv. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>491</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Agrd. Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>4</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>577</x>\n    <y>18</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lead Time</string>\n  </label>\n  <label>\n   <rect>\n    <x>663</x>\n    <y>18</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>3</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>31</height>\n   <field>\n    <rect>\n     <x>578</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>recv_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>62</x>\n     <y>14</y>\n     <width>247</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>venditemdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>495</x>\n     <y>1</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>argd_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_recv_date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>319</x>\n     <y>0</y>\n     <width>162</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>venditemnumber</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>30</ystart>\n    <xend>745</xend>\n    <yend>30</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>recv_order_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>495</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>release_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>578</x>\n     <y>14</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>real_leadtime</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>14</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>orderdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>62</x>\n     <y>0</y>\n     <width>247</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemnumber</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>103</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102510
 
297     DepartmentsMasterList   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Departments Master List</title>\n <name>DepartmentsMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>100</topmargin>\n <bottommargin>100</bottommargin>\n <rightmargin>100</rightmargin>\n <leftmargin>100</leftmargin>\n <querysource>\n  <name>deptQuery</name>\n  <sql>SELECT dept_number, dept_name\nFROM dept\nORDER BY dept_number;</sql>\n </querysource>\n <pghead>\n  <firstpage/>\n  <height>103</height>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>80</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Department Name</string>\n  </label>\n  <line>\n   <xstart>2</xstart>\n   <ystart>100</ystart>\n   <xend>647</xend>\n   <yend>100</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>22</y>\n    <width>651</width>\n    <height>26</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>16</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <top/>\n   <string>Departments</string>\n  </label>\n  <line>\n   <xstart>1</xstart>\n   <ystart>72</ystart>\n   <xend>646</xend>\n   <yend>72</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Department Number</string>\n  </label>\n </pghead>\n <section>\n  <name>main</name>\n  <detail>\n   <key>\n    <query>deptQuery</query>\n   </key>\n   <height>31</height>\n   <field>\n    <rect>\n     <x>180</x>\n     <y>10</y>\n     <width>200</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>12</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>deptQuery</query>\n     <column>dept_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>15</x>\n     <y>10</y>\n     <width>150</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>12</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>deptQuery</query>\n     <column>dept_number</column>\n    </data>\n   </field>\n  </detail>\n </section>\n</report>\n              0       2014-10-06 19:47:03.678943
102511
 
289     DepositsRegister        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Deposits Register</title>\n <name>DepositsRegister</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("showUsernames") ?>\n         text('Username')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_username</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT trans_id,\n       trans_journalnumber,\n       formatDate(trans_date) AS transdate,\n       trans_source,\n       trans_doctype,\n       trans_docnumber,\n       firstLine(trans_notes) AS transnotes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       trans_username,\n       formatBoolYN(trans_posted) AS f_posted,\n-- Debits:\n       CASE WHEN (trans_amount &lt; 0) THEN formatMoney(ABS(trans_amount))\n            ELSE ''\n       END AS f_debit,       \n       CASE WHEN (trans_amount &lt; 0) THEN ABS(trans_amount)\n            ELSE 0\n       END AS debit_amt, \n--Credits:\n       CASE WHEN (trans_amount > 0) THEN formatMoney(trans_amount)\n            ELSE ''\n       END AS f_credit,\n       CASE WHEN (trans_amount > 0) THEN trans_amount\n            ELSE 0\n       END AS credit_amt,\n--Balance:\n       trans_amount * -1 as balance_amt,\n--AROPEN Amount\n       formatMoney(currtobase(aropen_curr_id,(aropen_amount - aropen_paid),aropen_docdate)) AS f_aropen_bal,\n       currtobase(aropen_curr_id,(aropen_amount - aropen_paid),aropen_docdate) AS aropen_bal\n\nFROM (\nSELECT gltrans_id AS trans_id, gltrans_date AS trans_date, gltrans_created AS trans_created,\n       gltrans_source AS trans_source, gltrans_doctype AS trans_doctype, gltrans_sequence AS trans_sequence,\n       gltrans_docnumber AS trans_docnumber, gltrans_notes AS trans_notes, gltrans_amount AS trans_amount,\n       gltrans_journalnumber AS trans_journalnumber, gltrans_username AS trans_username,\n       gltrans_posted AS trans_posted,\n       accnt_id, accnt_descrip,\n       aropen_amount, aropen_paid, aropen_curr_id, aropen_docdate\nFROM gltrans LEFT OUTER JOIN aropen ON ((text(gltrans_docnumber) = 'I-' || text(aropen_docnumber))\n                                    AND (aropen_doctype='I')), accnt\nWHERE ((gltrans_accnt_id=accnt_id)\n   AND (gltrans_doctype = 'CR')\n   AND (gltrans_date BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>) )\nUNION\nSELECT sltrans_id AS trans_id, sltrans_date AS trans_date, sltrans_created AS trans_created,\n       sltrans_source AS trans_source, sltrans_doctype AS trans_doctype, sltrans_sequence AS trans_sequence,\n       sltrans_docnumber AS trans_docnumber, sltrans_notes AS trans_notes, sltrans_amount AS trans_amount,\n       sltrans_journalnumber AS trans_journalnumber, sltrans_username AS trans_username,\n       sltrans_posted AS trans_posted,\n       accnt_id, accnt_descrip,\n       aropen_amount, aropen_paid, aropen_curr_id, aropen_docdate\nFROM sltrans LEFT OUTER JOIN aropen ON ((text(sltrans_docnumber) = 'I-' || text(aropen_docnumber))\n                                    AND (aropen_doctype='I')), accnt\nWHERE ((sltrans_accnt_id=accnt_id)\n   AND (sltrans_doctype = 'CR')\n   AND (sltrans_date BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>) )\n     ) AS data\n\nORDER BY trans_created DESC, trans_sequence, trans_amount;</sql>\n </querysource>\n <rpthead>\n  <height>206</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>185</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Jrnl</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>200</ystart>\n   <xend>1000</xend>\n   <yend>200</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>310</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>170</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>120</x>\n    <y>185</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>175</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n  <label>\n   <rect>\n    <x>800</x>\n    <y>175</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Current Base</string>\n  </label>\n  <field>\n   <rect>\n    <x>175</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>800</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Balance Due</string>\n  </label>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>90</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>5</y>\n    <width>465</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Deposits Register</string>\n  </label>\n  <label>\n   <rect>\n    <x>55</x>\n    <y>185</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>705</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>to A/R</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>185</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>892</x>\n    <y>185</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Username</string>\n  </label>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>960</x>\n    <y>185</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>705</x>\n    <y>175</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Total Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>202</x>\n    <y>185</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <field>\n   <rect>\n    <x>175</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>57</height>\n  <label>\n   <rect>\n    <x>802</x>\n    <y>25</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Current Base</string>\n  </label>\n  <label>\n   <rect>\n    <x>162</x>\n    <y>25</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>897</x>\n    <y>36</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Username</string>\n  </label>\n  <label>\n   <rect>\n    <x>705</x>\n    <y>25</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Total Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>162</x>\n    <y>36</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>36</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Jrnl</string>\n  </label>\n  <label>\n   <rect>\n    <x>56</x>\n    <y>36</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>802</x>\n    <y>36</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Balance Due</string>\n  </label>\n  <label>\n   <rect>\n    <x>122</x>\n    <y>36</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>50</ystart>\n   <xend>1000</xend>\n   <yend>50</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>492</x>\n    <y>36</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>25</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>961</x>\n    <y>36</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>707</x>\n    <y>36</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>to A/R</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>35</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>312</x>\n    <y>36</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>206</x>\n    <y>36</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>21</height>\n   <field>\n    <rect>\n     <x>12500</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>trans_doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>202</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>trans_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>892</x>\n     <y>0</y>\n     <width>65</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>trans_username</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>55</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>160</x>\n     <y>0</y>\n     <width>25</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>trans_doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>310</x>\n     <y>0</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>account</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>95</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transnotes</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>695</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_credit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>963</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_posted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_debit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>trans_journalnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>790</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_aropen_bal</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>120</x>\n     <y>0</y>\n     <width>25</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>trans_source</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <lastpage/>\n  <height>78</height>\n  <label>\n   <rect>\n    <x>867</x>\n    <y>60</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>25</y>\n    <width>75</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>credit_amt</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>600</x>\n    <y>25</y>\n    <width>80</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>debit_amt</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>960</x>\n    <y>60</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>60</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>60</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>10</y>\n    <width>55</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Total:</string>\n  </label>\n  <line>\n   <xstart>605</xstart>\n   <ystart>5</ystart>\n   <xend>1015</xend>\n   <yend>6</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>790</x>\n    <y>25</y>\n    <width>75</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>aropen_bal</column>\n   </data>\n   <format builtin="true">qty</format>\n   <tracktotal/>\n  </field>\n </pgfoot>\n <pgfoot>\n  <height>21</height>\n  <field>\n   <rect>\n    <x>960</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>867</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102512
 
25      DetailedInventoryHistoryByLocation      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Detailed Inventory History by Location</title>\n <name>DetailedInventoryHistoryByLocation</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatLocationName(location_id) AS locationname,\n       firstLine(location_descrip) as f_descrip,\n       formatBoolYN(location_netable) AS f_netable,\n       formatBoolYN(location_restrict) AS f_restrict,\n       warehous_code AS warehouse,\n       formatDate(&lt;? value("startDate") ?>) AS startdate,\n       formatDate(&lt;? value("endDate") ?>) AS enddate\n  FROM location, whsinfo\n WHERE ((location_id=&lt;? value("location_id") ?>)\n   AND (location_warehous_id=warehous_id) );\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT invhist_id,\n       formatDateTime(invhist_transdate) AS transdate,\n       invhist_transtype,\n       (invhist_ordtype || '-' || invhist_ordnumber) AS ordernumber,\n       invhist_invuom,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       formatlotserialnumber(invdetail_ls_id) AS invdetail_lotserial,\n       formatQty(invdetail_qty) AS transqty,\n       formatQty(invdetail_qty_before) AS qohbefore,\n       formatQty(invdetail_qty_after) AS qohafter,\n       invhist_user AS username,\n       (select warehous_code from whsinfo where warehous_id=itemsite_warehous_id) as warehous_code\n  FROM invdetail, invhist, itemsite, item\n WHERE ((invdetail_invhist_id=invhist_id)\n   AND (invhist_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (invdetail_location_id=&lt;? value("location_id") ?>)\n   AND (date(invhist_transdate) BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n   AND (transType(invhist_transtype, &lt;? value("transType") ?>))\n)\nORDER BY invhist_transdate DESC, invhist_transtype;</sql>\n </querysource>\n <rpthead>\n  <height>251</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Time</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>104</y>\n    <width>375</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_descrip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>215</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>130</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>85</y>\n    <width>375</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>locationname</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>228</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Username</string>\n  </label>\n  <field>\n   <rect>\n    <x>508</x>\n    <y>150</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>130</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>104</y>\n    <width>70</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Restricted:</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH After</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>85</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Location:</string>\n  </label>\n  <field>\n   <rect>\n    <x>508</x>\n    <y>130</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>600</x>\n    <y>104</y>\n    <width>65</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_restrict</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>200</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Lot/Serial #</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH Before</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>85</y>\n    <width>70</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Netable:</string>\n  </label>\n  <label>\n   <rect>\n    <x>241</x>\n    <y>10</y>\n    <width>483</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Detailed Inventory History by Location</string>\n  </label>\n  <label>\n   <rect>\n    <x>508</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Trans-Qty</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>130</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>600</x>\n    <y>85</y>\n    <width>65</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_netable</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>245</ystart>\n   <xend>745</xend>\n   <yend>245</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>200</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>433</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>215</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>150</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>51</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>15</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>0</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>433</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>30</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Username</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>0</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Lot/Serial #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>45</ystart>\n   <xend>745</xend>\n   <yend>45</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>15</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>508</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Trans-Qty</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH Before</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH After</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Time</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qohbefore</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>508</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transqty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>433</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invhist_invuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ordernumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qohafter</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>170</x>\n     <y>15</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invhist_transtype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>170</x>\n     <y>0</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>0</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invdetail_lotserial</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>30</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>username</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>170</x>\n     <y>30</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102513
 
66      EarnedCommissions       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Earned Commissions</title>\n <name>EarnedCommissions</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("salesrep_id") ?>\n         ( SELECT salesrep_name\n             FROM salesrep\n            WHERE (salesrep_id=&lt;? value("salesrep_id") ?>) )\n       &lt;? else ?>\n         text('All Sales Reps')\n       &lt;? endif ?>\n       AS salesrep,\n       formatDate(&lt;? value("startDate") ?>) AS startdate,\n       formatDate(&lt;? value("endDate") ?>) AS enddate;</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>salesHistory</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Invc. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>155</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cust. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>705</x>\n    <y>200</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Paid</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>200</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>120</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>103</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>395</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>200</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Base Ext. Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>100</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sales Rep:</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>140</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>385</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>salesrep</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>202</x>\n    <y>200</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship-to</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Earned Commissions</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sales Rep.</string>\n  </label>\n  <label>\n   <rect>\n    <x>635</x>\n    <y>200</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Base Commision</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sales Rep.</string>\n  </label>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Invc. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>635</x>\n    <y>0</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Commision</string>\n  </label>\n  <label>\n   <rect>\n    <x>103</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>155</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cust. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>0</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>395</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Paid</string>\n  </label>\n  <label>\n   <rect>\n    <x>202</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship-to</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>395</x>\n     <y>0</y>\n     <width>110</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>565</x>\n     <y>0</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_baseextprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>155</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>103</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohist_ordernumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>705</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_commissionpaid</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>salesrep_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_invcdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyshipped</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>635</x>\n     <y>0</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_basecommission</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>202</x>\n     <y>0</y>\n     <width>110</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohist_shiptoname</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Totals:</string>\n  </label>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>0</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>baseextprice</column>\n   </data>\n   <format builtin="true">qty</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>635</x>\n    <y>0</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>basecommission</column>\n   </data>\n   <format builtin="true">qty</format>\n   <tracktotal/>\n  </field>\n </rptfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102514
 
367     EmployeeList    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Employee List</title>\n <name>EmployeeList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>employees</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT 'Search for "' || &lt;? value("searchString") ?> ||\n       '"' ||\n&lt;? if exists("searchCode") ?> ' in Employee Code,' || &lt;? endif ?>\n&lt;? if exists("searchDept") ?> ' in Department, '    || &lt;? endif ?>\n&lt;? if exists("searchMgr") ?>  ' in Manager, '       || &lt;? endif ?>\n&lt;? if exists("searchNumber") ?> ' in Employee Number, ' || &lt;? endif ?>\n&lt;? if exists("searchShift") ?> ' in Shift, '            || &lt;? endif ?>\n&lt;? if exists("activeOnly") ?> ' Among Active Employees'\n&lt;? else ?> ' Among All Employees'\n&lt;? endif ?>\nAS filter;</sql>\n </querysource>\n <rpthead>\n  <height>131</height>\n  <text>\n   <rect>\n    <x>390</x>\n    <y>40</y>\n    <width>360</width>\n    <height>31</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>filter</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>100</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Manager</string>\n  </label>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>115</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Department</string>\n  </label>\n  <text>\n   <rect>\n    <x>747</x>\n    <y>65</y>\n    <width>42</width>\n    <height>12</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query></query>\n    <column></column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>100</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Employee Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>100</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Last</string>\n  </label>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>100</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <label>\n   <rect>\n    <x>310</x>\n    <y>115</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shift</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>5</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Employees List</string>\n  </label>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>100</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Employee Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>460</x>\n    <y>100</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>First</string>\n  </label>\n  <line>\n   <xstart>10</xstart>\n   <ystart>130</ystart>\n   <xend>750</xend>\n   <yend>130</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>15</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Employee Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>15</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Manager</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>15</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Employee Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>15</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shift</string>\n  </label>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>15</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Department</string>\n  </label>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>15</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>31</height>\n   <field>\n    <rect>\n     <x>460</x>\n     <y>0</y>\n     <width>130</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cntct_first_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>605</x>\n     <y>0</y>\n     <width>130</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <bottom/>\n    <data>\n     <query>detail</query>\n     <column>cntct_last_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>170</x>\n     <y>15</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>department</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>310</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shift</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>170</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>emp_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>375</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>manager_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>emp_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>112</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>emp_active</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102515
 
206     ExpenseCategoriesMasterList     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Expense Categories Master List</title>\n <name>ExpenseCategoriesMasterList</name>\n <description></description>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>28</rightmargin>\n <leftmargin>28</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n  expcat_code,\n  expcat_descrip,\n  formatGLAccountLong(expcat_exp_accnt_id) AS exp_accnt,\n  formatGLAccountLong(expcat_purchprice_accnt_id) AS ppv_accnt,\n  formatGLAccountLong(expcat_liability_accnt_id) AS poliab_accnt,\n  formatGLAccountLong(expcat_freight_accnt_id) AS polinefrgt_accnt\nFROM \n  expcat AS A\nORDER BY expcat_code;\n</sql>\n </querysource>\n <rpthead>\n  <height>90</height>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>6</xstart>\n   <ystart>85</ystart>\n   <xend>1036</xend>\n   <yend>85</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>11</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Expense Categories Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>70</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Expense Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>70</y>\n    <width>175</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Purchase Price Variance Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>70</y>\n    <width>175</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O Liability Clearing Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>780</x>\n    <y>70</y>\n    <width>175</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O Line Freight Account</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>33</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <line>\n   <xstart>6</xstart>\n   <ystart>30</ystart>\n   <xend>1036</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>3</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Expense Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>15</y>\n    <width>175</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Purchase Price Variance Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>15</y>\n    <width>175</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O Liability Clearing Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>780</x>\n    <y>15</y>\n    <width>175</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O Line Freight Account </string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>40</height>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>-1</y>\n     <width>490</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>expcat_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>130</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>expcat_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>14</y>\n     <width>230</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>exp_accnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>14</y>\n     <width>240</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ppv_accnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>14</y>\n     <width>230</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poliab_accnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>780</x>\n     <y>14</y>\n     <width>230</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>polinefrgt_accnt</column>\n    </data>\n   </field>\n   <line>\n    <xstart>6</xstart>\n    <ystart>30</ystart>\n    <xend>1036</xend>\n    <yend>30</yend>\n    <weight>1</weight>\n   </line>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>945</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>855</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102516
 
215     ExpiredInventoryByClassCode     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Expired Inventory By Class Code</title>\n <name>ExpiredInventoryByClassCode</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("warehous_id") ?>\n         (SELECT warehous_code\n            FROM whsinfo\n           WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Warehouses')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("classcode_id") ?>\n         (SELECT (classcode_code || '-' || classcode_descrip)\n            FROM classcode\n           WHERE (classcode_id=&lt;? value("classcode_id") ?>) )\n       &lt;? elseif exists("classcode_pattern") ?>\n         text(&lt;? value("classcode_pattern") ?>)\n       &lt;? else ?>\n         text('All Class Codes')\n       &lt;? endif ?>\n       AS classcode,\n       &lt;? if exists("perishability") ?> \n       'Perishability'\n       &lt;? else ?>\n       'Warranty'\n       &lt;? endif ?> AS expiretype,\n       &lt;? if exists("showValue") ?>\n           &lt;? if exists("useActualCosts") ?>\n             text('Show Inventory Value with Actual Costs')\n           &lt;? elseif exists("useStandardCosts") ?>\n             text('Show Inventory Value with Standard Costs')\n           &lt;? else ?>\n             text('Show Inventory Value with Posted Costs')\n           &lt;? endif ?>\n           AS showvalues,\n           text('Unit Cost') AS f_unitcost,\n           text('Value') AS f_value,\n       &lt;? else ?>\n           text('') AS showvalues,\n           text('') AS f_unitcost,\n           text('') AS f_value,\n       &lt;? endif ?>\n       int4(&lt;? value("thresholdDays") ?>) AS f_thresholddays;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT warehous_code,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       uom_name,\n       ls_number AS itemloc_lotserial,\n       formatQty(itemloc_qty) AS f_qoh,\n       formatDate(itemloc_expiration) AS f_expiration,\n       &lt;? if exists("showValue") ?>\n         formatCost(cost)\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_unitcost,\n       noNeg(cost * itemloc_qty) AS value,\n       &lt;? if exists("showValue") ?>\n         formatExtPrice(noNeg(cost * itemloc_qty))\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_value\n  FROM ( SELECT itemsite_id,\n                warehous_code,\n                item_number,\n                item_descrip1,\n                item_descrip2,\n                uom_name,\n                ls_number,\n                itemloc_qty,\n&lt;? if exists("perishability") ?>\n                itemloc_expiration,\n&lt;? elseif exists("warranty") ?>\n                itemloc_warrpurc AS itemloc_expiration,\n&lt;? endif ?>\n                &lt;? if exists("useActualCosts") ?>\n                  actcost(itemsite_item_id)\n                &lt;? elseif exists("useStandardCosts") ?>\n                  stdcost(itemsite_item_id)\n                &lt;? else ?>\n                  (itemsite_value / CASE WHEN(itemsite_qtyonhand=0) THEN 1 ELSE itemsite_qtyonhand END)\n                &lt;? endif ?>\n                AS cost\n           FROM itemloc, itemsite, item, whsinfo, uom, ls\n          WHERE ((itemloc_itemsite_id=itemsite_id)\n            AND (itemloc_ls_id=ls_id)\n            AND (itemsite_item_id=item_id)\n            AND (item_inv_uom_id=uom_id)\n            AND (itemsite_warehous_id=warehous_id)\n&lt;? if exists("perishability") ?>\n            AND (itemsite_perishable)\n            AND (itemloc_expiration &lt; (CURRENT_DATE + &lt;? value("thresholdDays") ?>))\n&lt;? elseif exists("warranty") ?>\n            AND (itemsite_warrpurc)\n            AND (itemloc_warrpurc &lt; (CURRENT_DATE + &lt;? value("thresholdDays") ?>))\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n            AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("classcode_id") ?>\n            AND (item_classcode_id=&lt;? value("classcode_id") ?>)\n&lt;? elseif exists("classcode_pattern") ?>\n            AND (item_classcode_id IN (SELECT classcode_id\n                                         FROM classcode\n                                        WHERE classcode_code ~ &lt;? value("classcode_pattern") ?>) )\n&lt;? endif ?>\n                )\n       ) AS data\nORDER BY warehous_code,\n&lt;? if exists("orderByInventoryValue") ?>\n  value DESC\n&lt;? elseif exists("orderByExpirationDate") ?>\n  itemloc_expiration\n&lt;? else ?>\n  item_number\n&lt;? endif ?></sql>\n </querysource>\n <rpthead>\n  <height>237</height>\n  <label>\n   <rect>\n    <x>227</x>\n    <y>10</y>\n    <width>492</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Expired Inventory By Class Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Whs.</string>\n  </label>\n  <field>\n   <rect>\n    <x>440</x>\n    <y>140</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>showvalues</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>575</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_unitcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>40</x>\n    <y>160</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Expire By:</string>\n  </label>\n  <label>\n   <rect>\n    <x>102</x>\n    <y>200</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>102</x>\n    <y>215</y>\n    <width>227</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>215</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Expiration</string>\n  </label>\n  <label>\n   <rect>\n    <x>417</x>\n    <y>120</y>\n    <width>112</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Threshold Days:</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>140</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Warehouse:</string>\n  </label>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_value</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>227</ystart>\n   <xend>745</xend>\n   <yend>227</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>classcode</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>120</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Class Code(s):</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>200</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Lot/Serial #</string>\n  </label>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>160</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>expiretype</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <field>\n   <rect>\n    <x>540</x>\n    <y>120</y>\n    <width>195</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_thresholddays</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>42</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>32</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>5</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Lot/Serial #</string>\n  </label>\n  <label>\n   <rect>\n    <x>102</x>\n    <y>20</y>\n    <width>227</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_value</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Whs.</string>\n  </label>\n  <label>\n   <rect>\n    <x>102</x>\n    <y>5</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>20</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Expiration</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <field>\n   <rect>\n    <x>575</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_unitcost</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>52</height>\n   <field>\n    <rect>\n     <x>350</x>\n     <y>15</y>\n     <width>135</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_expiration</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>102</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_value</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qoh</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>265</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_unitcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>102</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>102</x>\n     <y>15</y>\n     <width>240</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>350</x>\n     <y>0</y>\n     <width>135</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemloc_lotserial</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102517
 
285     FinancialReport \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report</title>\n <name>FinancialReport</name>\n <description>Ad Hoc Report</description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT flhead_name,\n       CASE WHEN(trim(BOTH FROM COALESCE(flhead_custom_label,''))='') THEN 'Custom'\n            ELSE flhead_custom_label\n       END AS custom_label,\n       CASE WHEN(flhead_usealtbegin) THEN flhead_altbegin\n            ELSE text('Begining')\n       END AS begining_label,\n       CASE WHEN(flhead_usealtend) THEN flhead_altend\n            ELSE text('Ending')\n       END AS ending_label,\n       CASE WHEN(flhead_usealtdebits) THEN flhead_altdebits\n            ELSE text('Debits')\n       END AS debits_label,\n       CASE WHEN(flhead_usealtcredits) THEN flhead_altcredits\n            ELSE text('Credits')\n       END AS credits_label,\n       CASE WHEN(flhead_usealtbudget) THEN flhead_altbudget\n            ELSE text('Budget')\n       END AS budget_label,\n       CASE WHEN(flhead_usealtdiff) THEN flhead_altdiff\n            ELSE text('Difference')\n       END AS diff_label\n  FROM flhead\n WHERE (flhead_id=&lt;? value("flhead_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT financialReport(&lt;? value("flhead_id") ?>, period_id,&lt;? value("interval") ?>,&lt;? value("prj_id") ?>)\n  FROM period\n WHERE (period_id IN (\n&lt;? foreach("period_id_list") ?>\n  &lt;? if not isfirst("period_id_list") ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value("period_id_list") ?>\n&lt;? endforeach ?>\n                     ));\nSELECT period_id, period_start, formatperiodname(period_id,&lt;? value("interval") ?>) AS f_period, flrpt_order,\n       ( repeat('   ', flrpt_level) || flgrp_name ) AS name,\n       CASE WHEN(flgrp_summarize AND flgrp_showstart) THEN formatMoney(flrpt_beginning)\n            ELSE NULL\n       END AS beginning,\n       CASE WHEN(flgrp_summarize AND flgrp_showdelta) THEN formatMoney(flrpt_debits)\n            ELSE NULL\n       END AS debits,\n       CASE WHEN(flgrp_summarize AND flgrp_showdelta) THEN formatMoney(flrpt_credits)\n            ELSE NULL\n       END AS credits,\n       CASE WHEN(flgrp_summarize AND flgrp_showend) THEN formatMoney(flrpt_ending)\n            ELSE NULL\n       END AS ending,\n       CASE WHEN(flgrp_summarize AND flgrp_showbudget) THEN formatMoney(flrpt_budget)\n            ELSE NULL\n       END AS budget,\n       CASE WHEN(flgrp_summarize AND flgrp_showdiff) THEN formatMoney(flrpt_diff)\n            ELSE NULL\n       END AS diff,\n       CASE WHEN(flgrp_summarize AND flgrp_showcustom) THEN formatMoney(flrpt_custom)\n            ELSE NULL\n       END AS custom,\n       CASE WHEN(flgrp_summarize AND flgrp_showstartprcnt) THEN formatPrcnt(flrpt_beginningprcnt)\n            ELSE NULL\n       END AS beginningprcnt,\n       CASE WHEN(flgrp_summarize AND flgrp_showdeltaprcnt) THEN formatPrcnt(flrpt_debitsprcnt)\n            ELSE NULL\n       END AS debitsprcnt,\n       CASE WHEN(flgrp_summarize AND flgrp_showdeltaprcnt) THEN formatPrcnt(flrpt_creditsprcnt)\n            ELSE NULL\n       END AS creditsprcnt,\n       CASE WHEN(flgrp_summarize AND flgrp_showendprcnt) THEN formatPrcnt(flrpt_endingprcnt)\n            ELSE NULL\n       END AS endingprcnt,\n       CASE WHEN(flgrp_summarize AND flgrp_showbudgetprcnt) THEN formatPrcnt(flrpt_budgetprcnt)\n            ELSE NULL\n       END AS budgetprcnt,\n       CASE WHEN(flgrp_summarize AND flgrp_showdiffprcnt) THEN formatPrcnt(flrpt_diffprcnt)\n            ELSE NULL\n       END AS diffprcnt,\n       CASE WHEN(flgrp_summarize AND flgrp_showcustomprcnt) THEN formatPrcnt(flrpt_customprcnt)\n            ELSE NULL\n       END AS customprcnt\n  FROM flrpt, flgrp, period\n WHERE ((flrpt_type='G')\n   AND  (flrpt_type_id=flgrp_id)\n   AND  (flrpt_flhead_id=&lt;? value("flhead_id") ?>)\n   AND  (flrpt_period_id=period_id)\n   AND  (flrpt_username=getEffectiveXtUser())\n   AND  (flrpt_interval=&lt;? value("interval") ?>)\n   AND  (period_id IN (\n&lt;? foreach("period_id_list") ?>\n  &lt;? if not isfirst("period_id_list") ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value("period_id_list") ?>\n&lt;? endforeach ?>\n                     )))\nUNION\nSELECT period_id, period_start, formatperiodname(period_id,&lt;? value("interval") ?>) AS f_period, flrpt_order,\n       ( repeat('   ', flrpt_level) ||\n         CASE WHEN(accnt_id IS NULL) THEN ('Unknown Account ID ' || flitem_accnt_id)\n              ELSE (formatGLAccount(accnt_id) || '-' || accnt_descrip)\n         END\n       ) AS name,\n       formatMoney(flrpt_beginning) AS beginning,\n       formatMoney(flrpt_debits) AS debits,\n       formatMoney(flrpt_credits) AS credits,\n       formatMoney(flrpt_ending) AS ending,\n       formatMoney(flrpt_budget) AS budget,\n       formatMoney(flrpt_diff) AS diff,\n       formatMoney(flrpt_custom) AS custom,\n       formatPrcnt(flrpt_beginningprcnt) AS beginningprcnt,\n       formatPrcnt(flrpt_debitsprcnt) AS debitsprcnt,\n       formatPrcnt(flrpt_creditsprcnt) AS creditsprcnt,\n       formatPrcnt(flrpt_endingprcnt) AS endingprcnt,\n       formatPrcnt(flrpt_budgetprcnt) AS budgetprcnt,\n       formatPrcnt(flrpt_diffprcnt) AS diffprcnt,\n       formatPrcnt(flrpt_customprcnt) AS customprcnt\n  FROM flrpt LEFT OUTER JOIN accnt ON (flrpt_accnt_id=accnt_id), flitem, period\n WHERE ((flrpt_type='I')\n   AND  (flrpt_type_id=flitem_id)\n   AND  (flrpt_flhead_id=&lt;? value("flhead_id") ?>)\n   AND  (flrpt_period_id=period_id)\n   AND  (flrpt_username=getEffectiveXtUser())\n   AND  (flrpt_interval=&lt;? value("interval") ?>)\n&lt;? if not exists("showzeros") ?>\n   AND ((flrpt_beginning &lt;> 0) \n    OR (flrpt_debits &lt;> 0)\n    OR (flrpt_credits &lt;> 0)\n    OR (flrpt_ending &lt;> 0)\n    OR (flrpt_budget &lt;> 0)\n    OR (flrpt_diff &lt;> 0)\n    OR (flrpt_custom &lt;> 0))\n&lt;? endif ?>\n   AND  (period_id IN (\n&lt;? foreach("period_id_list") ?>\n  &lt;? if not isfirst("period_id_list") ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value("period_id_list") ?>\n&lt;? endforeach ?>\n                     )))\nUNION\nSELECT period_id, period_start, formatperiodname(period_id,&lt;? value("interval") ?>) AS f_period, flrpt_order,\n       ( repeat('   ', flrpt_level) || flspec_name ) AS name,\n       formatMoney(flrpt_beginning) AS beginning,\n       formatMoney(flrpt_debits) AS debits,\n       formatMoney(flrpt_credits) AS credits,\n       formatMoney(flrpt_ending) AS ending,\n       formatMoney(flrpt_budget) AS budget,\n       formatMoney(flrpt_diff) AS diff,\n       formatMoney(flrpt_custom) AS custom,\n       formatPrcnt(flrpt_beginningprcnt) AS beginningprcnt,\n       formatPrcnt(flrpt_debitsprcnt) AS debitsprcnt,\n       formatPrcnt(flrpt_creditsprcnt) AS creditsprcnt,\n       formatPrcnt(flrpt_endingprcnt) AS endingprcnt,\n       formatPrcnt(flrpt_budgetprcnt) AS budgetprcnt,\n       formatPrcnt(flrpt_diffprcnt) AS diffprcnt,\n       formatPrcnt(flrpt_customprcnt) AS customprcnt\n  FROM flrpt, flspec, period\n WHERE ((flrpt_type='S')\n   AND  (flrpt_type_id=flspec_id)\n   AND  (flrpt_flhead_id=&lt;? value("flhead_id") ?>)\n   AND  (flrpt_period_id=period_id)\n   AND  (flrpt_username=getEffectiveXtUser())\n   AND  (flrpt_interval=&lt;? value("interval") ?>)\n   AND  (period_id IN (\n&lt;? foreach("period_id_list") ?>\n  &lt;? if not isfirst("period_id_list") ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value("period_id_list") ?>\n&lt;? endforeach ?>\n                     )))\nUNION\nSELECT period_id, period_start, formatperiodname(period_id,&lt;? value("interval") ?>) AS f_period, flrpt_order,\n       ( repeat('   ', flrpt_level) ||\n         CASE WHEN(flrpt_type='T' AND flrpt_level=0) THEN COALESCE(flrpt_altname,'Total')\n              WHEN(flrpt_type='T') THEN COALESCE(flrpt_altname,'Subtotal')\n              ELSE ('Type ' || flrpt_type || ' ' || text(flrpt_type_id))\n         END\n       ) AS name,\n       formatMoney(flrpt_beginning) AS beginning,\n       formatMoney(flrpt_debits) AS debits,\n       formatMoney(flrpt_credits) AS credits,\n       formatMoney(flrpt_ending) AS ending,\n       formatMoney(flrpt_budget) AS budget,\n       formatMoney(flrpt_diff) AS diff,\n       formatMoney(flrpt_custom) AS custom,\n       formatPrcnt(flrpt_beginningprcnt) AS beginningprcnt,\n       formatPrcnt(flrpt_debitsprcnt) AS debitsprcnt,\n       formatPrcnt(flrpt_creditsprcnt) AS creditsprcnt,\n       formatPrcnt(flrpt_endingprcnt) AS endingprcnt,\n       formatPrcnt(flrpt_budgetprcnt) AS budgetprcnt,\n       formatPrcnt(flrpt_diffprcnt) AS diffprcnt,\n       formatPrcnt(flrpt_customprcnt) AS customprcnt\n  FROM flrpt, period\n WHERE ((NOT (flrpt_type IN ('G','I','S')))\n   AND  (flrpt_flhead_id=&lt;? value("flhead_id") ?>)\n   AND  (flrpt_period_id=period_id)\n   AND  (flrpt_username=getEffectiveXtUser())\n   AND  (flrpt_interval=&lt;? value("interval") ?>)\n   AND  (period_id IN (\n&lt;? foreach("period_id_list") ?>\n  &lt;? if not isfirst("period_id_list") ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value("period_id_list") ?>\n&lt;? endforeach ?>\n                     )))\n ORDER BY period_start, flrpt_order;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT flhead_notes AS notes\nFROM flhead\nWHERE ((flhead_id=&lt;? value("flhead_id") ?>)\n  AND (length(flhead_notes) > 0))</sql>\n </querysource>\n <rpthead>\n  <height>136</height>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>104</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>104</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flhead_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>10</y>\n    <width>350</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>38</height>\n  <field>\n   <rect>\n    <x>775</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>diff_label</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>775</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>695</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <field>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>ending_label</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>855</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <field>\n   <rect>\n    <x>375</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>begining_label</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>debits_label</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>994</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>855</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>custom_label</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>budget_label</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <field>\n   <rect>\n    <x>535</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>credits_label</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>byPeriod</name>\n   <column>period_id</column>\n   <head>\n    <height>112</height>\n    <label>\n     <rect>\n      <x>455</x>\n      <y>95</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>%</string>\n    </label>\n    <label>\n     <rect>\n      <x>695</x>\n      <y>95</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>%</string>\n    </label>\n    <label>\n     <rect>\n      <x>855</x>\n      <y>95</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>%</string>\n    </label>\n    <label>\n     <rect>\n      <x>615</x>\n      <y>95</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>%</string>\n    </label>\n    <field>\n     <rect>\n      <x>855</x>\n      <y>80</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>custom_label</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>535</x>\n      <y>80</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>credits_label</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>455</x>\n      <y>80</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>debits_label</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>10</x>\n      <y>80</y>\n      <width>55</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Name</string>\n    </label>\n    <label>\n     <rect>\n      <x>375</x>\n      <y>95</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>%</string>\n    </label>\n    <label>\n     <rect>\n      <x>15</x>\n      <y>40</y>\n      <width>80</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Period:</string>\n    </label>\n    <field>\n     <rect>\n      <x>100</x>\n      <y>40</y>\n      <width>459</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_period</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>695</x>\n      <y>80</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>budget_label</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>775</x>\n      <y>95</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>%</string>\n    </label>\n    <field>\n     <rect>\n      <x>615</x>\n      <y>80</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>ending_label</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>775</x>\n      <y>80</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>diff_label</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>535</x>\n      <y>95</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>%</string>\n    </label>\n    <line>\n     <xstart>10</xstart>\n     <ystart>110</ystart>\n     <xend>1000</xend>\n     <yend>110</yend>\n     <weight>2</weight>\n    </line>\n    <field>\n     <rect>\n      <x>375</x>\n      <y>80</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>begining_label</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>33</height>\n   <field>\n    <rect>\n     <x>455</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>debits</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>375</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>beginningprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>350</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>855</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>customprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ending</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>775</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>diffprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>695</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>budget</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>endingprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>375</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>beginning</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>695</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>budgetprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>855</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>custom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>455</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>debitsprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>535</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>credits</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>775</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>diff</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>535</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>creditsprcnt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>head</query>\n   </key>\n   <height>26</height>\n   <text>\n    <rect>\n     <x>10</x>\n     <y>6</y>\n     <width>980</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>23</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>930</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>839</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n   Ad Hoc Report   0       2014-10-06 19:47:03.678943
102518
 
335     FinancialReportMonth    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Month</title>\n <name>FinancialReportMonth</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>-- Group: financialReport\n-- Name:  detail\n-- Notes: \nSELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_month &lt;> 0) OR  (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n</sql>\n </querysource>\n <rpthead>\n  <height>167</height>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <line>\n   <xstart>3.55207</xstart>\n   <ystart>162.602</ystart>\n   <xend>746.627</xend>\n   <yend>162.602</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>145</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <field>\n   <rect>\n    <x>590.695</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>99</x>\n    <y>59.6</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>59.5</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>4</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>2.82852</xstart>\n   <ystart>30.1086</ystart>\n   <xend>747.989</xend>\n   <yend>30.1086</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>673.526</x>\n    <y>14.8299</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>4</height>\n    <line>\n     <xstart>390</xstart>\n     <ystart>0</ystart>\n     <xend>750</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>19</height>\n   <field>\n    <rect>\n     <x>590</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_month</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>550</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_monthprcnt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>9</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>22</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>7</height>\n </rptfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102519
 
336     FinancialReportMonthBudget      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Month and Budget</title>\n <name>FinancialReportMonthBudget</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_month &lt;> 0) OR (flstmtitem_monthbudget &lt;> 0) OR (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n</sql>\n </querysource>\n <rpthead>\n  <height>167</height>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>145</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Budget</string>\n  </label>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Budget Diff.</string>\n  </label>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <line>\n   <xstart>3.0775</xstart>\n   <ystart>165</ystart>\n   <xend>748.368</xend>\n   <yend>165</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>99</x>\n    <y>59.6</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>59.5</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>4</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>15</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% Diff.</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>15</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Budget</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Budget Diff.</string>\n  </label>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <line>\n   <xstart>1.53875</xstart>\n   <ystart>35</ystart>\n   <xend>749.873</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_year</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>182</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% Diff.</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>4</height>\n    <line>\n     <xstart>380</xstart>\n     <ystart>1</ystart>\n     <xend>740</xend>\n     <yend>1</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>19</height>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_monthbudget</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>380</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_month</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_monthbudgetdiffprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_monthbudgetdiff</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>345</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>9</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>22</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>7</height>\n </rptfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102520
 
347     FinancialReportMonthDbCr        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Month with Debits and Credits</title>\n <name>FinancialReportMonthDbCr</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_monthdb &lt;> 0) OR (flstmtitem_monthcr &lt;> 0) OR (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n</sql>\n </querysource>\n <rpthead>\n  <height>167</height>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>145</y>\n    <width>75</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <line>\n   <xstart>2.62279</xstart>\n   <ystart>160</ystart>\n   <xend>749</xend>\n   <yend>160</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>145</y>\n    <width>70</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debits</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>145</y>\n    <width>70</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% of Group</string>\n  </label>\n  <field>\n   <rect>\n    <x>505</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>425</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>60</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>60</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>145</y>\n    <width>70</width>\n    <height>16</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credits</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>4</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <line>\n   <xstart>1.94814</xstart>\n   <ystart>31</ystart>\n   <xend>748.325</xend>\n   <yend>31</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>16</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debits</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>16</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_typedescrip_prcnt</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>505</x>\n    <y>1</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>1</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>425</x>\n    <y>1</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>1</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>16</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>1</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>16</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credits</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>4</height>\n    <line>\n     <xstart>390</xstart>\n     <ystart>0</ystart>\n     <xend>750</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>19</height>\n   <field>\n    <rect>\n     <x>420</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_monthdb</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>590</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_month</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_monthcr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_monthprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>390</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>10</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>22</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>7</height>\n </rptfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102521
 
337     FinancialReportMonthPriorMonth  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Month and Prior Month</title>\n <name>FinancialReportMonthPriorMonth</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_typedescrip2 || ' Diff.' AS f_diff,\n    flstmthead_typedescrip2 || ' % Diff.' AS f_diffprcnt,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_month &lt;> 0) OR (flstmtitem_prmonth &lt;> 0) OR (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n</sql>\n </querysource>\n <rpthead>\n  <height>170</height>\n  <line>\n   <xstart>2.82315</xstart>\n   <ystart>160.942</ystart>\n   <xend>760</xend>\n   <yend>160.942</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prmonth</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prmonth</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diffprcnt</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prmonth</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diff</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>99</x>\n    <y>59.6</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>59.5</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>40</height>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prmonth</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prmonth</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prmonth</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diffprcnt</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diff</column>\n   </data>\n  </field>\n  <line>\n   <xstart>0.0790882</xstart>\n   <ystart>31.4959</ystart>\n   <xend>747.149</xend>\n   <yend>31.4959</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>7</height>\n    <line>\n     <xstart>380</xstart>\n     <ystart>1</ystart>\n     <xend>740</xend>\n     <yend>1</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>22</height>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_prmonth</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>345</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>380</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_month</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_prmonthdiffprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_prmonthdiff</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>9</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>25</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>10</height>\n </rptfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102522
 
346     FinancialReportMonthPriorQuarter        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Month and Prior Quarter</title>\n <name>FinancialReportMonthPriorQuarter</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_typedescrip2 || 'Diff.' AS f_diff,\n    flstmthead_typedescrip2 || ' % Diff.' AS f_diffprcnt,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_month &lt;> 0) OR (flstmtitem_prqtr &lt;> 0) OR (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n</sql>\n </querysource>\n <rpthead>\n  <height>169</height>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prqtr</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prqtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prqtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <line>\n   <xstart>2.16957</xstart>\n   <ystart>162</ystart>\n   <xend>750</xend>\n   <yend>162</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diff</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diffprcnt</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>99</x>\n    <y>59.6</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>59.5</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>39</height>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prqtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prqtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diffprcnt</column>\n   </data>\n  </field>\n  <line>\n   <xstart>1.79722</xstart>\n   <ystart>31</ystart>\n   <xend>749.933</xend>\n   <yend>31</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diff</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_prqtr</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>6</height>\n    <line>\n     <xstart>380</xstart>\n     <ystart>1</ystart>\n     <xend>740</xend>\n     <yend>1</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>21</height>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_prqtrdiff</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>345</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>380</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_month</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_prqtr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_prqtrdiffprcnt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>9</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>24</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>9</height>\n </rptfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102523
 
338     FinancialReportMonthPriorYear   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Month and Prior Year</title>\n <name>FinancialReportMonthPriorYear</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_typedescrip2 || ' Diff.' AS f_diff,\n    flstmthead_typedescrip2 || ' % Diff.' AS f_diffprcnt,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_month &lt;> 0) OR (flstmtitem_pryear &lt;> 0) OR (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n</sql>\n </querysource>\n <rpthead>\n  <height>169</height>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_pryear</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <line>\n   <xstart>0.998194</xstart>\n   <ystart>160</ystart>\n   <xend>750</xend>\n   <yend>160</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_pryear</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diff</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_pryear</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diffprcnt</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>99</x>\n    <y>59.6</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>59.5</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>39</height>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diffprcnt</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_pryear</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_pryear</column>\n   </data>\n  </field>\n  <line>\n   <xstart>1.55252</xstart>\n   <ystart>30</ystart>\n   <xend>751</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_diff</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_month</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_pryear</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>6</height>\n    <line>\n     <xstart>380</xstart>\n     <ystart>1</ystart>\n     <xend>740</xend>\n     <yend>1</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>21</height>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_pryeardiffprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>345</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_pryeardiff</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_pryear</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>380</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_month</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>9</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>24</height>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>9</height>\n </rptfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102524
 
341     FinancialReportQuarterBudget    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Financial Report Quarter and Budget</title>\n <name>FinancialReportQuarterBudget</name>\n <description></description>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">\n  <description>Financial Report Column Layout</description>\n  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>\n </parameter>\n <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">\n  <description>Accounting Period Reference</description>\n  <query>SELECT period_id, \n  CASE\n    WHEN period_name &lt;> '' THEN period_name \n    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n  END \nFROM period \nORDER BY period_end DESC</query>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT \n    &lt;? value("project") ?> AS project,\n    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,\n    flstmthead_username,\n    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n    flstmthead_typedescrip1,\n    flstmthead_typedescrip2,\n    flstmthead_month,\n    flstmthead_qtr,\n    flstmthead_year,\n    flstmthead_prmonth,\n    flstmthead_prqtr,\n    flstmthead_pryear\nFROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n    flstmtitem_flhead_id,\n    flstmtitem_period_id,\n    flstmtitem_username,\n    flstmtitem_order,\n    flstmtitem_level,\n    flstmtitem_subgrp,\n    flstmtitem_type,\n    flstmtitem_type_id,\n    flstmtitem_parent_id,\n    flstmtitem_accnt_id,\n    flstmtitem_name,\n    formatMoney(flstmtitem_month) AS flstmtitem_month,\n    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n    formatMoney(flstmtitem_year) AS flstmtitem_year,\n    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,\n&lt;? if exists("shownumbers") ?>\n  true\n&lt;? else ?>\n  false\n&lt;? endif ?>\n,True,&lt;? value("prj_id") ?>)\n&lt;? if not exists("showzeros") ?>\n  WHERE ((flstmtitem_qtr &lt;> 0) OR (flstmtitem_qtrbudget &lt;> 0) OR (flstmtitem_type &lt;> 'I'))\n&lt;? endif ?>\n;</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=&lt;? value("flcol_id") ?>)\n  AND (flnotes_period_id=&lt;? value("period_id") ?>)\n  AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n</sql>\n </querysource>\n <rpthead>\n  <height>167</height>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <line>\n   <xstart>1</xstart>\n   <ystart>160</ystart>\n   <xend>749</xend>\n   <yend>160</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Financial Report</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>130</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>130</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>145</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Budget Diff.</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>145</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Budget</string>\n  </label>\n  <field>\n   <rect>\n    <x>99</x>\n    <y>59.6</y>\n    <width>459</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>15</x>\n    <y>59.5</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>4</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Budget Diff.</string>\n  </label>\n  <field>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>15</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% Diff.</string>\n  </label>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>15</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Budget</string>\n  </label>\n  <line>\n   <xstart>1.80678</xstart>\n   <ystart>30</ystart>\n   <xend>750</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>380</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_typedescrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>flstmthead_qtr</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>182</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% Diff.</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>subgrp</name>\n   <column>flstmtitem_subgrp</column>\n   <foot>\n    <height>4</height>\n    <line>\n     <xstart>380</xstart>\n     <ystart>1</ystart>\n     <xend>740</xend>\n     <yend>1</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>19</height>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_qtrbudgetdiffprcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_qtrbudgetdiff</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_qtrbudget</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>345</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>380</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>flstmtitem_qtr</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>24</height>\n   <text>\n    <rect>\n     <x>25</x>\n     <y>9</y>\n     <width>700</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>notes</query>\n     <column>notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>22</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>7</height>\n </rptfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102525
 
76      FreightAccountAssignmentsMasterList     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>A/R Account Assignments Master List</title>\n <name>FreightAccountAssignmentsMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT CASE WHEN araccnt_custtype_id=-1 THEN araccnt_custtype\n            ELSE (SELECT custtype_code FROM custtype WHERE (custtype_id=araccnt_custtype_id))\n       END AS custtypecode,\n       formatGLAccount(araccnt_ar_accnt_id) AS f_araccnt,\n       formatGLAccount(araccnt_freight_accnt_id) as f_freightaccnt,\n       formatGLAccount(araccnt_prepaid_accnt_id) AS f_prepaidaccnt,\n       formatGLAccount(araccnt_deferred_accnt_id) AS f_deferredaccnt\nFROM araccnt \nORDER BY custtypecode;</sql>\n </querysource>\n <rpthead>\n  <height>88</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>80</ystart>\n   <xend>745</xend>\n   <yend>80</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>10</y>\n    <width>530</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>A/R Account Assignments Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>130</x>\n    <y>65</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>A/R Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>290</x>\n    <y>64</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Freight Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>65</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Type Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>64</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Deferred Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>64</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Prepaid Account</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>8</height>\n </pghead>\n <pghead>\n  <height>28</height>\n  <label>\n   <rect>\n    <x>130</x>\n    <y>5</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>A/R Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Type Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>290</x>\n    <y>7</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Freight Account</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>7</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Prepaid Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>7</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Deferred Account</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>19</height>\n   <field>\n    <rect>\n     <x>290</x>\n     <y>1</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_freightaccnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>custtypecode</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>0</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_araccnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>610</x>\n     <y>1</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_deferredaccnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>450</x>\n     <y>1</y>\n     <width>125</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_prepaidaccnt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102526
 
407     FreightClassesMasterList        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Freight Classes Master List</title>\n <name>FreightClassesMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>select freightclass_code, freightclass_descrip\n  from freightclass\norder by freightclass_code;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Freight Classes Master List</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Freight Class</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Freight Class</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>freightclass_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>freightclass_code</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102527
 
33      FrozenItemSites \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Frozen Item Sites</title>\n <name>FrozenItemSites</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("warehous_id") ?>\n        ( SELECT warehous_code\n            FROM whsinfo\n           WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse;\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT warehous_code,\n       formatBoolYN(itemsite_active) AS active,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       formatBoolYN(itemsite_wosupply) AS supplied,\n       formatBoolYN(itemsite_sold) AS sold,\n       itemsite_soldranking,\n       formatBoolYN(itemsite_stocked) AS stocked,\n       formatBoolYN(itemsite_createpr) AS createpr,\n       CASE WHEN (itemsite_controlmethod='N') THEN 'None'\n            WHEN (itemsite_controlmethod='R') THEN 'Regular'\n            WHEN (itemsite_controlmethod='L') THEN 'Lot #'\n            WHEN (itemsite_controlmethod='S') THEN 'Serial #'\n            ELSE '?'\n       END AS controlmethod,\n       formatBoolYN(itemsite_loccntrl) AS locationcontrol,\n       CASE WHEN (itemsite_location_id=-1) THEN 'None'\n            ELSE formatLocationName(itemsite_location_id)\n       END AS defaultlocation,\n       formatBoolYN(itemsite_useparams) AS enforceparams,\n       formatBoolYN(itemsite_useparamsmanual) AS onmanualorders,\n       formatQty(itemsite_reorderlevel) AS reorderlevel,\n       formatQty(itemsite_ordertoqty) AS orderupto,\n       formatQty(itemsite_multordqty) AS ordermult,\n       formatQty(itemsite_safetystock) AS safetystock,\n       itemsite_abcclass,\n       itemsite_cyclecountfreq,\n       itemsite_leadtime,\n       itemsite_eventfence,\n       formatQty(itemsite_qtyonhand) AS qoh,\n       formatDate(itemsite_datelastused, 'Never') AS lastused,\n       formatDate(itemsite_datelastcount, 'Never') AS lastcounted,\n       COALESCE((SELECT invcnt_tagnumber\n                   FROM invcnt\n                  WHERE ((NOT invcnt_posted)\n                    AND (invcnt_itemsite_id=itemsite_id))), '') AS counttagnum\nFROM itemsite, whsinfo, item\nWHERE ((itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_freeze)\n&lt;? if exists("warehous_id") ?>\n AND (warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n)\nORDER BY item_number;</sql>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>155</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Lvl.</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Safety Stock</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>155</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create P/Rs</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Frozen Item Sites</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>170</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>on Manual Ords.</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>170</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cycle Cnt.</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>155</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Supplied</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Default Loc.</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>200</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Event Fnc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>155</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Enforce Params.</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Up To</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>155</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>210</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Counted</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>170</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Location Cntrl.</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>185</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lead Time</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>155</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>ABC Class</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>210</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Used</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>215</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cost Category</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>170</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Planner Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>210</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>170</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <field>\n   <rect>\n    <x>114</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>155</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Mult.</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>170</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>215</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Count Tag #</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>155</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Control Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>170</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ranking</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>185</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Stocked</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>81</height>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>on Manual Ords.</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>ABC Class</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Control Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create P/Rs</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ranking</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Counted</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Enforce Params.</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>45</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Planner Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Lvl.</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>30</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Default Loc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Location Cntrl.</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Used</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>15</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>15</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>45</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Safety Stock</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>60</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Count Tag #</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>0</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Supplied</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>60</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cost Category</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>75</ystart>\n   <xend>745</xend>\n   <yend>75</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Up To</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>55</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>30</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lead Time</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>15</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cycle Cnt.</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>15</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>30</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Mult.</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>30</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Stocked</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>45</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Event Fnc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>0</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>81</height>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>15</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>0</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>280</x>\n     <y>30</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>stocked</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>30</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>45</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsite_eventfence</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>15</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>onmanualorders</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>60</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>lastcounted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsite_abcclass</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>60</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qoh</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>60</y>\n     <width>145</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>counttagnum</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createpr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>30</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ordermult</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>30</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsite_leadtime</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>409</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>locationcontrol</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>280</x>\n     <y>0</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>supplied</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>280</x>\n     <y>15</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sold</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>reorderlevel</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>345</x>\n     <y>60</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>lastused</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>409</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>controlmethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>orderupto</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>409</x>\n     <y>30</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>defaultlocation</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>45</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>safetystock</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>enforceparams</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>active</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>75</ystart>\n    <xend>745</xend>\n    <yend>75</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>15</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsite_cyclecountfreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsite_soldranking</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102528
 
242     GLSeries        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>G/L Series</title>\n <name>GLSeries</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? value("title") ?> AS title,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("sourceLit") ?>\n         text(&lt;? value("sourceLit") ?>)\n       &lt;? else ?>\n         text('All Sources')\n       &lt;? endif  ?>\n       AS sourceLit,\n       &lt;? if exists("startJrnlnum") ?>\n         text('Start Journal Number:')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS startJrnlnumLit,\n       &lt;? if exists("endJrnlnum") ?>\n         text('End Journal Number:')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS endJrnlnumLit;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>&lt;? if exists("gltrans") ?>\nSELECT gltrans_id,\n       gltrans_sequence,\n       formatDate(gltrans_date) AS transdate,\n       gltrans_journalnumber,\n       gltrans_source,\n       gltrans_doctype,\n       gltrans_docnumber,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       firstLine(gltrans_notes) AS f_notes,\n       CASE WHEN (gltrans_amount &lt; 0) THEN formatMoney(gltrans_amount * -1)\n            ELSE ''\n       END AS f_debit,\n       CASE WHEN (gltrans_amount > 0) THEN formatMoney(gltrans_amount)\n            ELSE ''\n       END AS f_credit,\n       CASE WHEN (gltrans_amount &lt; 0) THEN (gltrans_amount * -1)\n            ELSE 0.0\n       END AS debit,\n       CASE WHEN (gltrans_amount > 0) THEN (gltrans_amount)\n            ELSE 0.0\n       END AS credit,\n       formatBoolYN(gltrans_posted) AS f_posted\n  FROM gltrans, accnt\n WHERE ((gltrans_accnt_id=accnt_id)\n   AND (NOT gltrans_deleted)\n&lt;? if exists("startDate") ?>\n   AND (gltrans_date BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("source") ?>\n   AND (gltrans_source=&lt;? value("source") ?>)\n&lt;? endif ?>\n&lt;? if exists("startJrnlnum") ?>\n   AND (gltrans_journalnumber BETWEEN &lt;? value("startJrnlnum") ?> AND &lt;? value("endJrnlnum") ?>)\n&lt;? endif ?>\n       )\nORDER BY gltrans_date, gltrans_sequence, gltrans_amount DESC;\n&lt;? else ?>\nSELECT sltrans_id AS gltrans_id,\n       sltrans_sequence AS gltrans_sequence,\n       formatDate(sltrans_date) AS transdate,\n       sltrans_journalnumber AS gltrans_journalnumber,\n       sltrans_source AS gltrans_source,\n       sltrans_doctype AS gltrans_doctype,\n       sltrans_docnumber AS gltrans_docnumber,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       firstLine(sltrans_notes) AS f_notes,\n       CASE WHEN (sltrans_amount &lt; 0) THEN formatMoney(sltrans_amount * -1)\n            ELSE ''\n       END AS f_debit,\n       CASE WHEN (sltrans_amount > 0) THEN formatMoney(sltrans_amount)\n            ELSE ''\n       END AS f_credit,\n       CASE WHEN (sltrans_amount &lt; 0) THEN (sltrans_amount * -1)\n            ELSE 0.0\n       END AS debit,\n       CASE WHEN (sltrans_amount > 0) THEN (sltrans_amount)\n            ELSE 0.0\n       END AS credit,\n       formatBoolYN(sltrans_posted) AS f_posted\n  FROM sltrans, accnt\n WHERE ((sltrans_accnt_id=accnt_id)\n&lt;? if exists("startDate") ?>\n   AND (sltrans_date BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("source") ?>\n   AND (sltrans_source=&lt;? value("source") ?>)\n&lt;? endif ?>\n&lt;? if exists("startJrnlnum") ?>\n   AND (sltrans_journalnumber BETWEEN &lt;? value("startJrnlnum") ?> AND &lt;? value("endJrnlnum") ?>)\n&lt;? endif ?>\n       )\nORDER BY sltrans_date, sltrans_sequence, sltrans_amount DESC;\n&lt;? endif ?></sql>\n </querysource>\n <querysource>\n  <name>summarized</name>\n  <sql>&lt;? if exists("gltrans") ?>\nSELECT (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       formatMoney(SUM(CASE WHEN (gltrans_amount &lt; 0) THEN (gltrans_amount * -1)\n                            ELSE 0.0\n                       END)) AS f_debit,\n       formatMoney(SUM(CASE WHEN (gltrans_amount > 0) THEN (gltrans_amount)\n                            ELSE 0.0\n                       END)) AS f_credit\n  FROM gltrans, accnt\n WHERE ((gltrans_accnt_id=accnt_id)\n   AND (NOT gltrans_deleted)\n&lt;? if exists("startDate") ?>\n   AND (gltrans_date BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("source") ?>\n   AND (gltrans_source=&lt;? value("source") ?>)\n&lt;? endif ?>\n&lt;? if exists("startJrnlnum") ?>\n   AND (gltrans_journalnumber BETWEEN &lt;? value("startJrnlnum") ?> AND &lt;? value("endJrnlnum") ?>)\n&lt;? endif ?>\n       )\nGROUP BY accnt_id, accnt_descrip\nORDER BY formatGLAccount(accnt_id);\n&lt;? else ?>\nSELECT (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       formatMoney(SUM(CASE WHEN (sltrans_amount &lt; 0) THEN (sltrans_amount * -1)\n                            ELSE 0.0\n                       END)) AS f_debit,\n       formatMoney(SUM(CASE WHEN (sltrans_amount > 0) THEN (sltrans_amount)\n                            ELSE 0.0\n                       END)) AS f_credit\n  FROM sltrans, accnt\n WHERE ((sltrans_accnt_id=accnt_id)\n&lt;? if exists("startDate") ?>\n   AND (sltrans_date BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("source") ?>\n   AND (sltrans_source=&lt;? value("source") ?>)\n&lt;? endif ?>\n&lt;? if exists("startJrnlnum") ?>\n   AND (sltrans_journalnumber BETWEEN &lt;? value("startJrnlnum") ?> AND &lt;? value("endJrnlnum") ?>)\n&lt;? endif ?>\n       )\nGROUP BY accnt_id, accnt_descrip\nORDER BY formatGLAccount(accnt_id);\n&lt;? endif ?></sql>\n </querysource>\n <rpthead>\n  <height>206</height>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>680</x>\n    <y>185</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <field>\n   <rect>\n    <x>545</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Parameter Query</query>\n    <column>startJrnlnum</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>70</y>\n    <width>290</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>sourceLit</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Source:</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>90</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>545</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Jrnl. #/Source</string>\n  </label>\n  <field>\n   <rect>\n    <x>340</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>endJrnlnumLit</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>200</ystart>\n   <xend>745</xend>\n   <yend>200</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>509</x>\n    <y>185</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <field>\n   <rect>\n    <x>545</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <field>\n   <rect>\n    <x>340</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startJrnlnumLit</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>545</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Parameter Query</query>\n    <column>endJrnlnum</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Notes/Account</string>\n  </label>\n  <field>\n   <rect>\n    <x>440</x>\n    <y>7</y>\n    <width>300</width>\n    <height>35</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>title</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>0</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Notes/Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Jrnl./Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>509</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>680</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>gltrans_sequence</column>\n   <head>\n    <height>16</height>\n    <field>\n     <rect>\n      <x>95</x>\n      <y>0</y>\n      <width>60</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>gltrans_journalnumber</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>680</x>\n      <y>0</y>\n      <width>60</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_posted</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>160</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>gltrans_doctype</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>330</x>\n      <y>0</y>\n      <width>175</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_notes</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>transdate</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>245</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>gltrans_docnumber</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>95</x>\n      <y>15</y>\n      <width>60</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>gltrans_source</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <field>\n    <rect>\n     <x>595</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_credit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>account</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>509</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_debit</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>summarized</name>\n  <group>\n   <name>summarized header</name>\n   <column></column>\n   <head>\n    <height>35</height>\n    <label>\n     <rect>\n      <x>30</x>\n      <y>5</y>\n      <width>205</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Summarized Distributions:</string>\n    </label>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>summarized</query>\n   </key>\n   <height>35</height>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>5</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>summarized</query>\n     <column>account</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>510</x>\n     <y>5</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>summarized</query>\n     <column>f_debit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>595</x>\n     <y>5</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>summarized</query>\n     <column>f_credit</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>35</height>\n  <field>\n   <rect>\n    <x>510</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>debit</column>\n   </data>\n   <format>%0.2f</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>595</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>credit</column>\n   </data>\n   <format>%0.2f</format>\n   <tracktotal/>\n  </field>\n  <label>\n   <rect>\n    <x>415</x>\n    <y>5</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n    <italic/>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Totals:</string>\n  </label>\n </rptfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102529
 
243     GLTransactions  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>G/L Transactions</title>\n <name>GLTransactions</name>\n <description>detail query modified to accomodate "Company", "Profit Center", "Account", "Sub", "Type" &amp; "Sub-Type" filters.</description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("source") ?>\n         text(&lt;? value("source") ?>)\n       &lt;? else ?>\n         text('All Sources')\n       &lt;? endif  ?>\n       AS source,\n       &lt;? if exists("accnt_id") ?>\n         ( SELECT (accnt_number || '-' || accnt_descrip)\n             FROM accnt\n            WHERE (accnt_id=&lt;? value("accnt_id") ?>) )\n       &lt;? else ?>\n         text('All Accounts')\n       &lt;? endif ?>\n       AS accnt,\n       &lt;? if exists("showUsernames") ?>\n         text('Username')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_username</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>&lt;? if exists("beginningBalance") ?>\nSELECT -1 AS gltrans_id,\n       &lt;? value("startDate") ?> AS gltrans_created, formatDate(&lt;? value("startDate") ?>) AS transdate,\n       '' AS gltrans_source, '' AS gltrans_doctype, '' AS gltrans_docnumber, '' AS invhist_docnumber,\n       'Beginning Balance' AS transnotes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       '' AS f_debit,\n       0.0 AS debit_amt,\n       '' AS f_credit,\n       0.0 AS credit_amt,\n       &lt;? value("beginningBalance") ?> AS balance_amt,\n       &lt;? value("beginningBalance") ?> AS gltrans_amount,\n       &lt;? value("beginningBalance") ?> AS running,\n       NULL AS f_posted,\n       NULL AS f_deleted,\n       NULL AS f_username,\n       -1 AS gltrans_sequence\n FROM accnt\n WHERE (accnt_id=&lt;? value("accnt_id") ?>)\nUNION\n&lt;? endif ?>\n\nSELECT gltrans_id,\n       gltrans_created, formatDate(gltrans_date) AS transdate,\n       gltrans_source, gltrans_doctype, gltrans_docnumber, invhist_docnumber,\n       firstLine(gltrans_notes) AS transnotes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n-- Debits:\n       CASE WHEN (gltrans_amount &lt; 0 AND NOT gltrans_deleted) THEN formatMoney(ABS(gltrans_amount))\n            ELSE ''\n       END AS f_debit,       \n       CASE WHEN (gltrans_amount &lt; 0 AND NOT gltrans_deleted) THEN ABS(gltrans_amount)\n            ELSE 0\n       END AS debit_amt, \n--Credits:\n       CASE WHEN (gltrans_amount > 0 AND NOT gltrans_deleted) THEN formatMoney(gltrans_amount)\n            ELSE ''\n       END AS f_credit,\n       CASE WHEN (gltrans_amount > 0 AND NOT gltrans_deleted) THEN gltrans_amount\n            ELSE 0\n       END AS credit_amt,\n--Balance:\n       CASE WHEN (accnt_type IN ('A','E') AND NOT gltrans_deleted) THEN \n         gltrans_amount * -1\n       WHEN (NOT gltrans_deleted) THEN \n         gltrans_amount \n       ELSE 0 END AS balance_amt,\n       gltrans_amount,\n       CASE WHEN (accnt_type IN ('A','E') AND NOT gltrans_deleted) THEN \n         gltrans_amount * -1\n       WHEN (NOT gltrans_deleted) THEN \n         gltrans_amount \n       ELSE 0 END AS running,\n       formatBoolYN(gltrans_posted) AS f_posted,\n       formatBoolYN(gltrans_deleted) AS f_deleted,\n       gltrans_username AS f_username,\n       gltrans_sequence\nFROM gltrans JOIN accnt ON (gltrans_accnt_id=accnt_id) \n     LEFT OUTER JOIN invhist ON (gltrans_misc_id=invhist_id\n                            AND gltrans_docnumber='Misc.') \n&lt;? if exists("company_id") ?>\n     JOIN company ON (accnt_company=company_number) \n&lt;? endif ?>\n&lt;? if exists("prfcntr_id") ?>\n     JOIN prftcntr ON (accnt_profit=prftcntr_number) \n&lt;? endif ?>\n&lt;? if exists("subaccnt_id") ?>\n     JOIN subaccnt ON (accnt_sub=subaccnt_number) \n&lt;? endif ?>\n&lt;? if exists("subType") ?>\n     JOIN subaccnttype ON (subaccnttype_code=accnt_subaccnttype_code) \n&lt;? endif ?>\nWHERE (\n&lt;? if exists("startDate") ?>\n  &lt;? if exists("endDate") ?>\n       (gltrans_date BETWEEN &lt;? value("startDate") ?>\n                         AND &lt;? value("endDate") ?>)\n  &lt;? else ?>\n       (gltrans_date BETWEEN &lt;? value("startDate") ?>\n                         AND endoftime())\n  &lt;? endif ?>\n&lt;? else ?>\n  &lt;? if exists("endDate") ?>\n       (gltrans_date BETWEEN startoftime()\n                         AND &lt;? value("endDate") ?>)\n  &lt;? else ?>\n       (gltrans_date BETWEEN startoftime()\n                         AND endoftime())\n  &lt;? endif ?>\n&lt;? endif ?>\n&lt;? if not exists("showDeleted") ?>\n   AND (NOT gltrans_deleted)\n&lt;? endif ?>\n&lt;? if exists("company_id") ?>\n   AND (company_id=&lt;? value("company_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("prfcntr_id") ?>\n   AND (prftcntr_id=&lt;? value("prfcntr_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("accnt_number") ?>\n   AND (accnt_number=&lt;? value("accnt_number") ?>)\n&lt;? endif ?>\n&lt;? if exists("subaccnt_id") ?>\n   AND (subaccnt_id=&lt;? value("subaccnt_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("subType") ?>\n   AND (subaccnttype_id=&lt;? value("subType") ?>)\n&lt;? endif ?>\n&lt;? if exists("accntType") ?>\n   AND (accnt_type= &lt;? value("accntType") ?>)\n&lt;? endif ?>\n&lt;? if exists("accnt_id") ?>\n   AND (gltrans_accnt_id=&lt;? value("accnt_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("docnum") ?>\n   AND (gltrans_docnumber = case when &lt;? value("docnum") ?> = '' then \n gltrans_docnumber else \n&lt;? value("docnum") ?> end ) \n&lt;? endif ?>\n&lt;? if exists("source") ?>\n   AND (gltrans_source=&lt;? value("source") ?>)\n&lt;? endif ?>\n       )\nORDER BY gltrans_created &lt;? if not exists("beginningBalance") ?> DESC &lt;? endif ?>,\n        gltrans_sequence, gltrans_amount\n\n;</sql>\n </querysource>\n <rpthead>\n  <height>205</height>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>170</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>780</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Running Total</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>185</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n  <label>\n   <rect>\n    <x>125</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>185</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>185</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>200</ystart>\n   <xend>1000</xend>\n   <yend>200</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>5</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>G/L Transactions</string>\n  </label>\n  <label>\n   <rect>\n    <x>960</x>\n    <y>170</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <field>\n   <rect>\n    <x>900</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_username</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>185</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>960</x>\n    <y>185</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Deleted</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>50</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>45</height>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>10</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>125</x>\n    <y>25</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>25</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>40</ystart>\n   <xend>1000</xend>\n   <yend>40</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>25</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>25</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>960</x>\n    <y>25</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>25</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>25</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <field>\n   <rect>\n    <x>900</x>\n    <y>25</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_username</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>780</x>\n    <y>25</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Running Total</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>25</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>30</height>\n   <field>\n    <rect>\n     <x>900</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_username</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>15</y>\n     <width>265</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transnotes</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>960</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_posted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>12500</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>125</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_source</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>180</x>\n     <y>15</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invhist_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>180</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>0</y>\n     <width>270</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>account</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>960</x>\n     <y>15</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_deleted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_debit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>780</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>running</column>\n    </data>\n    <format builtin="true">qty</format>\n    <tracktotal/>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_credit</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>41</height>\n  <field>\n   <rect>\n    <x>958</x>\n    <y>7</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>87</x>\n    <y>7</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>10</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>869</x>\n    <y>7</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>49</height>\n  <line>\n   <xstart>534</xstart>\n   <ystart>6</ystart>\n   <xend>999</xend>\n   <yend>6</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>9</y>\n    <width>55</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Total:</string>\n  </label>\n  <label>\n   <rect>\n    <x>780</x>\n    <y>9</y>\n    <width>55</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Balance:</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>25</y>\n    <width>100</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>credit_amt</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>540</x>\n    <y>25</y>\n    <width>100</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>debit_amt</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n  <field>\n   <rect>\n    <x>777</x>\n    <y>25</y>\n    <width>100</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>balance_amt</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n </rptfoot>\n</report>\n     detail query modified to accomodate "Company", "Profit Center", "Account", "Sub", "Type" &amp; "Sub-Type" filters.      0       2014-10-06 19:47:03.678943
102530
 
421     Image   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Image</title>\n <name>Image</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT image_name,\n       image_descrip,\n       image_data\n  FROM image\n WHERE (image_id=&lt;? value("image_id") ?>);</sql>\n </querysource>\n <rpthead>\n  <height>706</height>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>50</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Image Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>5</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Image</string>\n  </label>\n  <image>\n   <rect>\n    <x>10</x>\n    <y>110</y>\n    <width>730</width>\n    <height>600</height>\n   </rect>\n   <mode>stretch</mode>\n   <data>\n    <query>head</query>\n    <column>image_data</column>\n   </data>\n  </image>\n  <text>\n   <rect>\n    <x>130</x>\n    <y>65</y>\n    <width>360</width>\n    <height>15</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>image_descrip</column>\n   </data>\n  </text>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>50</y>\n    <width>140</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>image_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>65</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Image Description:</string>\n  </label>\n </rpthead>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102531
 
429     Incident        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Incident</title>\n <name>Incident</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>select incdt_number, incdt_summary,  \n       incdt_assigned_username, incdt_status, \n       incdt_owner_username, incdtseverity_name,\n       incdtpriority_name, incdtcat_name,\n       crmacct_name, cntct_first_name || ' ' ||cntct_last_name as f_name,    \n       cntct_phone,  cntct_email,cntct_title\n  from incdt left outer join incdtseverity on \n       (incdt_incdtseverity_id = incdtseverity_id)\n       left outer join incdtpriority on\n       (incdt_incdtpriority_id = incdtpriority_id) \n       left outer join incdtcat on\n       (incdt_incdtcat_id = incdtcat_id)\n       left outer join crmacct on \n       (incdt_crmacct_id = crmacct_id) \n       left outer join cntct on \n       (incdt_cntct_id = cntct_id) \n  where incdt_id = &lt;? value("incdt_id") ?>;\n   </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>select incdt_descrip \n  from incdt\n where incdt_id = &lt;? value("incdt_id") ?>;</sql>\n </querysource>\n <querysource>\n  <name>detail2</name>\n  <sql>select comment_date, comment_user, comment_text \n  from comment\n where comment_source_id = &lt;? value("incdt_id") ?> and comment_source  = 'INCDT'\norder by comment_date desc;</sql>\n </querysource>\n <querysource>\n  <name>detail3</name>\n  <sql>select url_title, url_url \nfrom url \nwhere url_source_id = &lt;? value("incdt_id") ?>\nand url_source  = 'INCDT'\n\n</sql>\n </querysource>\n <rpthead>\n  <height>268</height>\n  <field>\n   <rect>\n    <x>136</x>\n    <y>57</y>\n    <width>598</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>incdt_summary</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>128</x>\n    <y>123</y>\n    <width>251</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>370</x>\n    <y>10</y>\n    <width>171</width>\n    <height>35</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>incdt_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>540</x>\n    <y>144</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>incdtseverity_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>24</x>\n    <y>57</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Description:</string>\n  </label>\n  <field>\n   <rect>\n    <x>128</x>\n    <y>165</y>\n    <width>342</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cntct_title</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>27</x>\n    <y>123</y>\n    <width>98</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Contact Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>422.8</x>\n    <y>144</y>\n    <width>112</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Severity :</string>\n  </label>\n  <label>\n   <rect>\n    <x>13</x>\n    <y>165</y>\n    <width>112</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Contact Job Title:</string>\n  </label>\n  <label>\n   <rect>\n    <x>231</x>\n    <y>10</y>\n    <width>131</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>INCIDENT</string>\n  </label>\n  <field>\n   <rect>\n    <x>540</x>\n    <y>187</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>incdt_owner_username</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>468</x>\n    <y>187</y>\n    <width>66.8</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Owner:</string>\n  </label>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>208</y>\n    <width>79.8</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Assigned to:</string>\n  </label>\n  <field>\n   <rect>\n    <x>540</x>\n    <y>208</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>incdt_assigned_username</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>128</x>\n    <y>208</y>\n    <width>279</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cntct_email</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>208</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Contact Email:</string>\n  </label>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>105</y>\n    <width>79.8</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Category:</string>\n  </label>\n  <field>\n   <rect>\n    <x>540</x>\n    <y>105</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>incdtcat_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>123</y>\n    <width>79.8</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Status:</string>\n  </label>\n  <field>\n   <rect>\n    <x>540</x>\n    <y>123</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>incdt_status</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>128</x>\n    <y>105</y>\n    <width>263</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>crmacct_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>13</x>\n    <y>105</y>\n    <width>112</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>CRM Acnt Name :</string>\n  </label>\n  <field>\n   <rect>\n    <x>540</x>\n    <y>165</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>incdtpriority_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>468</x>\n    <y>165</y>\n    <width>66.8</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Priority:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10.9</x>\n    <y>243.624</y>\n    <width>114</width>\n    <height>20.5346</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Incident Notes:</string>\n  </label>\n  <field>\n   <rect>\n    <x>128</x>\n    <y>144</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cntct_phone</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>144</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Contact Phone:</string>\n  </label>\n  <field>\n   <rect>\n    <x>128</x>\n    <y>187</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cntct_phone</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>187</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Contact Phone:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>37</height>\n   <text>\n    <rect>\n     <x>10.9</x>\n     <y>8</y>\n     <width>730</width>\n     <height>17</height>\n    </rect>\n    <bottompad>14</bottompad>\n    <font>\n     <face>Helvetica</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>incdt_descrip</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <section>\n  <name>detail2</name>\n  <group>\n   <name>labour</name>\n   <column></column>\n   <head>\n    <height>33.9041</height>\n    <label>\n     <rect>\n      <x>10.9</x>\n      <y>10.42</y>\n      <width>114</width>\n      <height>20.5</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Comments:</string>\n    </label>\n    <line>\n     <xstart>2.90454</xstart>\n     <ystart>3.94806</ystart>\n     <xend>744.812</xend>\n     <yend>3.62203</yend>\n     <weight>1</weight>\n    </line>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail2</query>\n   </key>\n   <height>49.0959</height>\n   <field>\n    <rect>\n     <x>10.9</x>\n     <y>0.621</y>\n     <width>150</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail2</query>\n     <column>comment_date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>196</x>\n     <y>0.621</y>\n     <width>150</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail2</query>\n     <column>comment_user</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>10.9</x>\n     <y>23.1</y>\n     <width>730</width>\n     <height>17</height>\n    </rect>\n    <bottompad>14</bottompad>\n    <font>\n     <face>Helvetica</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail2</query>\n     <column>comment_text</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <section>\n  <name>jobcost_head</name>\n  <detail>\n   <key>\n    <query>head</query>\n   </key>\n   <height>47.4021</height>\n   <line>\n    <xstart>4.90454</xstart>\n    <ystart>5.44606</ystart>\n    <xend>746.812</xend>\n    <yend>5.12003</yend>\n    <weight>1</weight>\n   </line>\n   <label>\n    <rect>\n     <x>10.9</x>\n     <y>7.7823</y>\n     <width>114</width>\n     <height>20.5</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Documents:</string>\n   </label>\n   <label>\n    <rect>\n     <x>10.9</x>\n     <y>27.4</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Title</string>\n   </label>\n   <label>\n    <rect>\n     <x>289</x>\n     <y>27.4</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>URL</string>\n   </label>\n  </detail>\n </section>\n <section>\n  <name>detail3</name>\n  <group>\n   <name>detail3_footer</name>\n   <column></column>\n   <foot>\n    <height>39.6984</height>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail3</query>\n   </key>\n   <height>28.8318</height>\n   <field>\n    <rect>\n     <x>289</x>\n     <y>4.08</y>\n     <width>460</width>\n     <height>18</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail3</query>\n     <column>url_url</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10.9</x>\n     <y>2.9979</y>\n     <width>274.1</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail3</query>\n     <column>url_title</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>27.5186</height>\n </rptfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102532
 
316     IncidentCategoriesList  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Incident Categories</title>\n <name>IncidentCategoriesList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT incdtcat_name, incdtcat_order, incdtcat_descrip\n  FROM incdtcat\nORDER BY incdtcat_order, incdtcat_name;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Incident Categories</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>55</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>55</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>0</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>0</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <text>\n    <rect>\n     <x>250</x>\n     <y>0</y>\n     <width>500</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtcat_descrip</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtcat_order</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtcat_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102533
 
317     IncidentPrioritiesList  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Incident Priorities</title>\n <name>IncidentPrioritiesList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT incdtpriority_name, incdtpriority_order, incdtpriority_descrip\n  FROM incdtpriority\nORDER BY incdtpriority_order, incdtpriority_name;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Priorities</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>55</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>55</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>0</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>0</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtpriority_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtpriority_order</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>250</x>\n     <y>0</y>\n     <width>500</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtpriority_descrip</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102534
 
318     IncidentResolutionsList \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Incident Resolutions</title>\n <name>IncidentResolutionsList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT incdtresolution_name, incdtresolution_order, incdtresolution_descrip\n  FROM incdtresolution\nORDER BY incdtresolution_order, incdtresolution_name;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Incident Resolutions</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>55</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>55</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>0</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>0</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <text>\n    <rect>\n     <x>250</x>\n     <y>0</y>\n     <width>500</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtresolution_descrip</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtresolution_order</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtresolution_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102535
 
319     IncidentSeveritiesList  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Incident Severities</title>\n <name>IncidentSeveritiesList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT incdtseverity_name, incdtseverity_order, incdtseverity_descrip\n  FROM incdtseverity\nORDER BY incdtseverity_order, incdtseverity_name;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Incident Severities</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>55</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>55</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>0</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>0</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <text>\n    <rect>\n     <x>250</x>\n     <y>0</y>\n     <width>500</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtseverity_descrip</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtseverity_order</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtseverity_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102536
 
321     IncidentWorkbenchList   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Incident List</title>\n <name>IncidentWorkbenchList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>incidents</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>144</height>\n  <line>\n   <xstart>2</xstart>\n   <ystart>139</ystart>\n   <xend>742</xend>\n   <yend>139</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>122.5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Created</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Incident List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>122.5</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Incident</string>\n  </label>\n  <label>\n   <rect>\n    <x>690</x>\n    <y>122.5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Priority</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>122.5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>122.5</y>\n    <width>230</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Summary</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>122.5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Assigned To</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>122.5</y>\n    <width>110</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>122.5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Severity</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>39</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>690</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Priority</string>\n  </label>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Created</string>\n  </label>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Severity</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Incident</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>0</y>\n    <width>110</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Assigned To</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>0</y>\n    <width>230</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Summary</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>ByUser</name>\n   <column>usr_username</column>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>28</height>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>230</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdt_summary</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>110</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>crmacct_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdt_assigned_username</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>180</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdt_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>690</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtpriority_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>560</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdt_timestamp</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdtseverity_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdt_number</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>320</x>\n     <y>15</y>\n     <width>430</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>incdt_descrip</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>15</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102537
 
446     InventoryAvailability   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Inventory Availability</title>\n <name>InventoryAvailability</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("byDays") ?>\n         (text('Look ahead ') || text(&lt;? value("byDays") ?>) || text(' days'))\n       &lt;? elseif exists("byDate") ?>\n         (text('Cutoff date ') || formatDate(&lt;? value("byDate") ?>))\n       &lt;? elseif exists("byDates") ?>\n         (text('Dates from ') || formatDate(&lt;? value("startDate") ?>) || text(' to ') || formatDate(&lt;? value("endDate") ?>))\n       &lt;? else ?>\n         text('Item Site Lead Time')\n       &lt;? endif ?>\n       AS ltcriteria;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT item_number, item_descrip1, item_descrip2,\n       warehous_code, itemsite_leadtime,\n       formatQty(qtyonhand) AS f_qtyonhand,\n       formatQty(noNeg(qtyonhand - allocated)) AS f_unallocated,\n       formatQty(noNeg(allocated)) AS f_allocated,\n       formatQty(ordered) AS f_ordered,\n       formatQty(requests) AS f_requests,\n       formatQty(reorderlevel) AS f_reorderlevel,\n       (qtyonhand - allocated + ordered) AS available,\n       formatQty(qtyonhand - allocated + ordered) AS f_available\n  FROM (SELECT \n           &lt;? if reExists("[vV]end") ?>\n             DISTINCT\n           &lt;? endif ?>\n             itemsite_id,\n             CASE WHEN (item_type IN ('P', 'O')) THEN 1\n                  WHEN (item_type IN ('M')) THEN 2\n                  ELSE 0\n             END AS altId,\n             item_number, item_descrip1, item_descrip2, item_inv_uom_id,\n             warehous_id, warehous_code, itemsite_leadtime,\n             qtyAvailable(itemsite_id) AS qtyonhand,\n             CASE WHEN itemsite_useparams THEN itemsite_reorderlevel\n                  ELSE 0.0\n             END AS reorderlevel,\n             CASE WHEN itemsite_useparams THEN itemsite_ordertoqty\n                  ELSE 0.0\n             END AS outlevel,\n             &lt;? if exists("byVend") ?>\n               vend_number,\n             &lt;? else ?>\n               NULL AS vend_number,\n             &lt;? endif ?>\n             &lt;? if exists("byLeadTime") ?>\n               qtyAllocated(itemsite_id, itemsite_leadtime) AS allocated,\n               qtyOrdered(itemsite_id,   itemsite_leadtime) AS ordered, \n               qtypr(itemsite_id,   itemsite_leadtime) AS requests\n             &lt;? elseif exists("byDays") ?>\n               qtyAllocated(itemsite_id, CAST(&lt;? value("byDays") ?> AS INTEGER)) AS allocated,\n               qtyOrdered(itemsite_id,   CAST(&lt;? value("byDays") ?> AS INTEGER)) AS ordered,\n               qtypr(itemsite_id,   CAST(&lt;? value("byDays") ?> AS INTEGER)) AS requests  \n             &lt;? elseif exists("byDate") ?>\n               qtyAllocated(itemsite_id, (&lt;? value("byDate") ?> - CURRENT_DATE)) AS allocated,\n               qtyOrdered(itemsite_id,   (&lt;? value("byDate") ?> - CURRENT_DATE)) AS ordered,\n               qtypr(itemsite_id,   (&lt;? value("byDate") ?> - CURRENT_DATE)) AS requests \n             &lt;? elseif exists("byDates") ?>\n               qtyAllocated(itemsite_id, &lt;? value("startDate") ?>, &lt;? value("endDate") ?>) AS allocated,\n               qtyOrdered(itemsite_id,   &lt;? value("startDate") ?>, &lt;? value("endDate") ?>) AS ordered,\n               qtypr(itemsite_id,   &lt;? value("startDate") ?>, &lt;? value("endDate") ?>) AS requests\n             &lt;? endif ?>\n      FROM item, itemsite, whsinfo\n           &lt;? if reExists("[vV]end") ?>\n             , vendinfo JOIN itemsrc ON (itemsrc_vend_id=vend_id)\n           &lt;? endif ?>\n      WHERE ( (itemsite_active)\n          AND (itemsite_item_id=item_id)\n          AND (itemsite_warehous_id=warehous_id)\n          &lt;? if exists("warehous_id") ?>\n            AND (warehous_id=&lt;? value("warehous_id") ?>)\n          &lt;? endif ?>\n          &lt;? if exists("item_id") ?>\n            AND (item_id=&lt;? value("item_id") ?>)\n          &lt;? elseif exists("classcode_id") ?>\n            AND (item_classcode_id=&lt;? value("classcode_id") ?>)\n          &lt;? elseif exists("classcode_pattern") ?>\n            AND (item_classcode_id IN (SELECT classcode_id\n                                       FROM classcode\n                                       WHERE (classcode_code ~ &lt;? value("classcode_pattern") ?>)))\n          &lt;? elseif exists("plancode_id") ?>\n            AND (itemsite_plancode_id=&lt;? value("plancode_id") ?>)\n          &lt;? elseif exists("plancode_pattern") ?>\n            AND (itemsite_plancode_id IN (SELECT plancode_id\n                                          FROM plancode\n                                          WHERE (plancode_code ~ &lt;? value("plancode_pattern") ?>)))\n          &lt;? elseif exists("itemgrp_id") ?>\n            AND (item_id IN (SELECT itemgrpitem_item_id\n                             FROM itemgrpitem\n                             WHERE (itemgrpitem_itemgrp_id=&lt;? value("itemgrp_id") ?>)))\n          &lt;? elseif exists("itemgrp_pattern") ?>\n            AND (item_id IN (SELECT itemgrpitem_item_id\n                             FROM itemgrpitem, itemgrp\n                             WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n                                    AND (itemgrp_name ~ &lt;? value("itemgrp_pattern") ?>) ) ))\n          &lt;? elseif exists("itemgrp") ?>\n            AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n          &lt;? endif ?>\n          &lt;? if reExists("[vV]end") ?>\n            AND (itemsrc_item_id=item_id)\n          &lt;? endif ?>\n          &lt;? if exists("vend_id") ?>\n            AND (vend_id=&lt;? value("vend_id") ?>)\n          &lt;? elseif exists("vendtype_id") ?>\n            AND (vend_vendtype_id=&lt;? value("vendtype_id") ?>)\n          &lt;? elseif exists("vendtype_pattern") ?>\n            AND (vend_vendtype_id IN (SELECT vendtype_id\n                                      FROM vendtype\n                                      WHERE (vendtype_code ~ &lt;? value("vendtype_pattern") ?>)))\n          &lt;? endif ?>\n      ) ) AS data\n&lt;? if exists("showReorder") ?>\n WHERE ( ((qtyonhand - allocated + ordered) &lt;= reorderlevel)\n  &lt;? if exists("ignoreReorderAtZero") ?>\n   AND (NOT ( ((qtyonhand - allocated + ordered) = 0) AND (reorderlevel = 0)) )\n  &lt;? endif ?>\n  )\n&lt;? elseif exists("showShortages") ?>\n WHERE ((qtyonhand - allocated + ordered) &lt; 0)\n&lt;? endif ?>\nORDER BY item_number, warehous_code DESC;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Unallocated</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>178</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Level</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Inventory Availability</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>43</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Availability as of: </string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>178</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>LT</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>178</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>431</x>\n    <y>178</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Allocated</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>200</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>178</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>On Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>178</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Available</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>43</y>\n    <width>280</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>ltcriteria</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>189</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>PO Requests</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>63</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Unallocated</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>15</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>15</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>LT</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Level</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>0</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Available</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Allocated</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>On Order</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyonhand</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_available</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>434</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_allocated</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsite_leadtime</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ordered</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>15</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>30</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>434</x>\n     <y>30</y>\n     <width>100</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_unallocated</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>31</y>\n     <width>100</width>\n     <height>12</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_reorderlevel</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>14</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_requests</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102538
 
18      InventoryAvailabilityBySourceVendor     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Inventory Availability by Source Vendor</title>\n <name>InventoryAvailabilityBySourceVendor</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("byDays") ?>\n         (text('Look ahead ') || text(&lt;? value("byDays") ?>) || text(' days'))\n       &lt;? elseif exists("byDate") ?>\n         (text('Cutoff date ') || formatDate(&lt;? value("byDate") ?>))\n       &lt;? elseif exists("byDates") ?>\n         (text('Dates from ') || formatDate(&lt;? value("startDate") ?>) || text(' to ') || formatDate(&lt;? value("endDate") ?>))\n       &lt;? else ?>\n         text('Item Site Lead Time')\n       &lt;? endif ?>\n       AS ltcriteria</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       warehous_code,\n       vend_number,\n       itemsite_leadtime,\n       formatQty(qtyonhand) AS f_qtyonhand,\n       formatQty(noNeg(qtyonhand - allocated)) AS f_unallocated,\n       formatQty(noNeg(allocated)) AS f_allocated,\n       formatQty(ordered) AS f_ordered,\n       formatQty(reorderlevel) AS f_reorderlevel,\n       formatQty(outlevel) AS f_outlevel,\n       (qtyonhand - allocated + ordered) AS available,\n       formatQty(qtyonhand - allocated + ordered) AS f_available\n  FROM (SELECT \n           &lt;? if reExists("[vV]end") ?>\n             DISTINCT\n           &lt;? endif ?>\n             itemsite_id,\n             CASE WHEN (item_type IN ('P', 'O')) THEN 1\n                  WHEN (item_type IN ('M')) THEN 2\n                  ELSE 0\n             END AS altId,\n             item_number, item_descrip1, item_descrip2, item_inv_uom_id,\n             warehous_id, warehous_code, itemsite_leadtime,\n             qtyAvailable(itemsite_id) AS qtyonhand,\n             CASE WHEN itemsite_useparams THEN itemsite_reorderlevel\n                  ELSE 0.0\n             END AS reorderlevel,\n             CASE WHEN itemsite_useparams THEN itemsite_ordertoqty\n                  ELSE 0.0\n             END AS outlevel,\n             &lt;? if exists("byVend") ?>\n               vend_number,\n             &lt;? else ?>\n               NULL AS vend_number,\n             &lt;? endif ?>\n             &lt;? if exists("byLeadTime") ?>\n               qtyAllocated(itemsite_id, itemsite_leadtime) AS allocated,\n               qtyOrdered(itemsite_id,   itemsite_leadtime) AS ordered, \n               qtypr(itemsite_id,   itemsite_leadtime) AS requests\n             &lt;? elseif exists("byDays") ?>\n               qtyAllocated(itemsite_id, CAST(&lt;? value("byDays") ?> AS INTEGER)) AS allocated,\n               qtyOrdered(itemsite_id,   CAST(&lt;? value("byDays") ?> AS INTEGER)) AS ordered,\n               qtypr(itemsite_id,   CAST(&lt;? value("byDays") ?> AS INTEGER)) AS requests  \n             &lt;? elseif exists("byDate") ?>\n               qtyAllocated(itemsite_id, (&lt;? value("byDate") ?> - CURRENT_DATE)) AS allocated,\n               qtyOrdered(itemsite_id,   (&lt;? value("byDate") ?> - CURRENT_DATE)) AS ordered,\n               qtypr(itemsite_id,   (&lt;? value("byDate") ?> - CURRENT_DATE)) AS requests \n             &lt;? elseif exists("byDates") ?>\n               qtyAllocated(itemsite_id, &lt;? value("startDate") ?>, &lt;? value("endDate") ?>) AS allocated,\n               qtyOrdered(itemsite_id,   &lt;? value("startDate") ?>, &lt;? value("endDate") ?>) AS ordered,\n               qtypr(itemsite_id,   &lt;? value("startDate") ?>, &lt;? value("endDate") ?>) AS requests\n             &lt;? endif ?>\n      FROM item, itemsite, whsinfo\n           &lt;? if reExists("[vV]end") ?>\n             , vendinfo JOIN itemsrc ON (itemsrc_vend_id=vend_id)\n           &lt;? endif ?>\n      WHERE ( (itemsite_active)\n          AND (itemsite_item_id=item_id)\n          AND (itemsite_warehous_id=warehous_id)\n          &lt;? if exists("warehous_id") ?>\n            AND (warehous_id=&lt;? value("warehous_id") ?>)\n          &lt;? endif ?>\n          &lt;? if exists("item_id") ?>\n            AND (item_id=&lt;? value("item_id") ?>)\n          &lt;? elseif exists("classcode_id") ?>\n            AND (item_classcode_id=&lt;? value("classcode_id") ?>)\n          &lt;? elseif exists("classcode_pattern") ?>\n            AND (item_classcode_id IN (SELECT classcode_id\n                                       FROM classcode\n                                       WHERE (classcode_code ~ &lt;? value("classcode_pattern") ?>)))\n          &lt;? elseif exists("plancode_id") ?>\n            AND (itemsite_plancode_id=&lt;? value("plancode_id") ?>)\n          &lt;? elseif exists("plancode_pattern") ?>\n            AND (itemsite_plancode_id IN (SELECT plancode_id\n                                          FROM plancode\n                                          WHERE (plancode_code ~ &lt;? value("plancode_pattern") ?>)))\n          &lt;? elseif exists("itemgrp_id") ?>\n            AND (item_id IN (SELECT itemgrpitem_item_id\n                             FROM itemgrpitem\n                             WHERE (itemgrpitem_itemgrp_id=&lt;? value("itemgrp_id") ?>)))\n          &lt;? elseif exists("itemgrp_pattern") ?>\n            AND (item_id IN (SELECT itemgrpitem_item_id\n                             FROM itemgrpitem, itemgrp\n                             WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n                                    AND (itemgrp_name ~ &lt;? value("itemgrp_pattern") ?>) ) ))\n          &lt;? elseif exists("itemgrp") ?>\n            AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n          &lt;? endif ?>\n          &lt;? if reExists("[vV]end") ?>\n            AND (itemsrc_item_id=item_id)\n          &lt;? endif ?>\n          &lt;? if exists("vend_id") ?>\n            AND (vend_id=&lt;? value("vend_id") ?>)\n          &lt;? elseif exists("vendtype_id") ?>\n            AND (vend_vendtype_id=&lt;? value("vendtype_id") ?>)\n          &lt;? elseif exists("vendtype_pattern") ?>\n            AND (vend_vendtype_id IN (SELECT vendtype_id\n                                      FROM vendtype\n                                      WHERE (vendtype_code ~ &lt;? value("vendtype_pattern") ?>)))\n          &lt;? endif ?>\n      ) ) AS data\n&lt;? if exists("showReorder") ?>\n WHERE ( ((qtyonhand - allocated + ordered) &lt;= reorderlevel)\n  &lt;? if exists("ignoreReorderAtZero") ?>\n   AND (NOT ( ((qtyonhand - allocated + ordered) = 0) AND (reorderlevel = 0)))\n  &lt;? endif ?>\n  )\n&lt;? elseif exists("showShortages") ?>\n WHERE ((qtyonhand - allocated + ordered) &lt; 0)\n&lt;? endif ?>\nORDER BY vend_number, item_number, warehous_code DESC;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Allocated</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>On Order</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Available</string>\n  </label>\n  <label>\n   <rect>\n    <x>195</x>\n    <y>10</y>\n    <width>530</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Inventory Availability by Source Vendor</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>43</y>\n    <width>280</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>ltcriteria</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>LT</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>OUT Level</string>\n  </label>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Unallocated</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Level</string>\n  </label>\n  <label>\n   <rect>\n    <x>55</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor #</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>43</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Availability as of: </string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>200</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>63</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>On Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>0</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>15</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>LT</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>OUT Level</string>\n  </label>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Allocated</string>\n  </label>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Unallocated</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reorder Level</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>15</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>55</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor #</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Available</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_available</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyonhand</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>160</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>55</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_reorderlevel</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_outlevel</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>15</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemsite_leadtime</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>434</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_allocated</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>160</x>\n     <y>15</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>160</x>\n     <y>30</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>434</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_unallocated</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102539
 
1       Invoice \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Invoice</title>\n <name>Invoice</name>\n <description>With Logo - With Invoice Currency</description>\n <parameter default="97" active="true" listtype="dynamic" type="string" name="invchead_id">\n  <description></description>\n  <query>SELECT invchead_id, invchead_invcnumber FROM invchead ORDER BY invchead_invcnumber;</query>\n </parameter>\n <watermark>\n  <data>\n   <query>Parameter Query</query>\n   <column>watermark</column>\n  </data>\n  <opacity>25</opacity>\n </watermark>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>GroupHead</name>\n  <sql>SELECT \n\n--Due Date\nformatDate(determineDueDate(invchead_terms_id, invchead_invcdate)) AS due_date,\n--Discount Date\nformatDate(determineDiscountDate(invchead_terms_id, invchead_invcdate)) AS dis_date,\n\n      --remitto.*,\nremitto_name,\nformatAddr(remitto_address1, remitto_address2, remitto_address3, remitto_citystatezip, remitto_country) AS remitto_adr,\n      invchead_invcnumber AS invoicenumber,\n      formatDate(invchead_invcdate) AS f_invoicedate,\n      cust_number,\n      invchead_billto_name,\n      formatAddr(invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, ( invchead_billto_city || '  ' || invchead_billto_state || '  ' || invchead_billto_zipcode ), invchead_billto_country) AS f_billtoaddress,\n      invchead_billto_phone,\n      invchead_shipto_name,\n      formatAddr(invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, ( invchead_shipto_city || '  ' || invchead_shipto_state || ' ' || invchead_shipto_zipcode ), invchead_shipto_country) AS f_shiptoaddress,\n      invchead_ordernumber AS ordernumber,\n      invchead_ponumber,\n      formatDate(invchead_orderdate) AS f_orderdate,\n      formatDate(invchead_shipdate) AS f_shipdate,\n      invchead_fob, terms_descrip, invchead_shipvia\nFROM remitto, custinfo, invchead, terms\nWHERE ( (invchead_cust_id=cust_id)\nAND (invchead_terms_id=terms_id)\nAND (invchead_id=&lt;? value("invchead_id") ?>) )\nORDER BY ordernumber;</sql>\n </querysource>\n <querysource>\n  <name>Detail</name>\n  <sql>SELECT invcitem_linenumber,\n      formatQty(invcitem_billed) AS f_billed,\n      (select uom_name from uom where uom_id = invcitem_qty_uom_id) AS invuom,\n      CASE WHEN (item_number IS NULL) THEN invcitem_number\n           WHEN (invcitem_custpn != '') THEN invcitem_custpn\n           else item_number\n      END AS number,\n      CASE WHEN (item_number IS NULL) THEN invcitem_descrip\n           WHEN (invcitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip1\n           ELSE item_descrip1\n      END AS descrip1,\n      CASE WHEN (invcitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip2\n           ELSE item_descrip2\n      END AS descrip2,\n      CASE WHEN (&lt;? value("showcosts") ?>=FALSE) THEN '---'\n           ELSE formatPrice(invcitem_qty_invuomratio * invcitem_price / COALESCE(invcitem_price_invuomratio,1))\n      END AS f_unitprice,\n      CASE WHEN (&lt;? value("showcosts") ?>=FALSE) THEN '---'\n           ELSE formatMoney(round((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / COALESCE(invcitem_price_invuomratio,1)),2)) \n      END AS f_extprice,\n      invcitem_notes,\n      getInvcitemLotSerial(invcitem_id) AS lotserial,\n--Sub-select updated for 3.1 to support kitting\n      characteristicsToString('SI',invcitem_coitem_id, '=', ', ') \n      AS coitem_characteristics\nFROM invcitem LEFT OUTER JOIN (item JOIN uom ON (item_inv_uom_id=uom_id)) ON (invcitem_item_id=item_id) LEFT OUTER JOIN itemalias ON (itemalias_item_id=item_id AND itemalias_number=invcitem_custpn)\nWHERE (invcitem_invchead_id=&lt;? value("invchead_id") ?>)\nORDER BY invcitem_linenumber;</sql>\n </querysource>\n <querysource>\n  <name>foot</name>\n  <sql>SELECT formatMoney(SUM(round((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / COALESCE(invcitem_price_invuomratio,1)),2))) AS f_extprice&#xd;\nFROM invcitem LEFT OUTER JOIN item on (invcitem_item_id=item_id)&#xd;\nWHERE (invcitem_invchead_id=&lt;? value("invchead_id") ?>);</sql>\n </querysource>\n <querysource>\n  <name>GroupExtended</name>\n  <sql>SELECT *,\n       formatMoney(invchead_misc_amount) AS f_misc,\n       formatMoney(tax)                  AS f_tax,\n       formatMoney(invchead_freight)     AS f_freight,\n       formatMoney(invchead_payment)     AS f_payment,\n       formatMoney(noNeg(invchead_freight + invchead_misc_amount + tax +\n                         itemtotal - total_allocated)) AS f_totaldue,\n       formatMoney(noNeg(invchead_freight + invchead_misc_amount + tax +\n                         itemtotal - total_allocated)) AS f_netdue,\n       formatMoney(total_allocated) AS f_allocated\n FROM (SELECT invchead_misc_amount, invchead_freight,\n              invchead_payment, invchead_notes, invchead_misc_descrip,\n              (SELECT COALESCE(SUM(tax),0) \n                FROM (\n                SELECT ROUND(SUM(taxdetail_tax),2) AS tax \n                FROM tax \n                 JOIN calculateTaxDetailSummary('I', &lt;? value("invchead_id") ?>, 'T') ON (taxdetail_tax_id=tax_id)\n\t   GROUP BY tax_id) AS data) AS tax,\n              SUM(COALESCE(ROUND(invcitem_billed *\n                                 invcitem_qty_invuomratio *\n                                 invcitem_price /\n                                 COALESCE(invcitem_price_invuomratio,1), 2), 0))\n              AS itemtotal,\n              COALESCE(\n              CASE WHEN invchead_posted THEN\n                 (SELECT SUM(COALESCE(currToCurr(arapply_curr_id, t.aropen_curr_id,\n                                                 arapply_applied, t.aropen_docdate), 0))\n                  FROM arapply, aropen s, aropen t\n                  WHERE ( (s.aropen_id=arapply_source_aropen_id)\n                    AND   (arapply_target_aropen_id=t.aropen_id)\n                    AND   (arapply_target_doctype='I')\n                    AND   (arapply_target_docnumber=invchead_invcnumber)\n                    AND   (arapply_reftype='S')\n                    AND   (arapply_source_aropen_id=s.aropen_id)))\n              ELSE\n                 (SELECT SUM(COALESCE(CASE WHEN((aropen_amount - aropen_paid) >=\n                                                currToCurr(aropenalloc_curr_id, aropen_curr_id,\n                                                           aropenalloc_amount, aropen_docdate))\n                                           THEN currToCurr(aropenalloc_curr_id, invchead_curr_id,\n                                                           aropenalloc_amount, aropen_docdate)\n                                           ELSE currToCurr(aropen_curr_id, invchead_curr_id,\n                                                           aropen_amount - aropen_paid,\n                                                           aropen_docdate)\n                                      END, 0))\n                   FROM aropenalloc, aropen\n                        LEFT OUTER JOIN cohead ON (cohead_number=invchead_ordernumber)\n                  WHERE ( (aropenalloc_aropen_id=aropen_id)\n                    AND   ((aropenalloc_doctype='S' AND aropenalloc_doc_id=cohead_id) OR\n                           (aropenalloc_doctype='I' AND aropenalloc_doc_id=invchead_id))\n                    AND   ((aropen_amount - aropen_paid) > 0)))\n              END, 0) AS total_allocated\n       FROM invchead\n            LEFT OUTER JOIN invcitem ON (invcitem_invchead_id=invchead_id)\n       WHERE (invchead_id=&lt;? value("invchead_id") ?>)\n       GROUP BY invchead_freight, invchead_misc_amount, tax,\n                invchead_payment, invchead_notes, invchead_misc_descrip,\n                total_allocated\n ) AS dummy_outer\n ;</sql>\n </querysource>\n <querysource>\n  <name>allocatedCMs</name>\n  <sql>SELECT cohead_id,\n      aropen_docnumber,\n      formatMoney(aropen_amount) AS f_total,\n      formatMoney(aropen_paid) AS f_paid,\n      formatMoney(aropen_amount - aropen_paid) AS f_balance,\n      CASE WHEN((aropen_amount - aropen_paid) >= currToCurr(aropenalloc_curr_id,\n\t\t\t\t\t\t\t     aropen_curr_id,\n\t\t\t\t\t\t\t     aropenalloc_amount,\n\t\t\t\t\t\t\t     aropen_docdate))\n\t    THEN currToCurr(aropenalloc_curr_id, aropen_curr_id,\n\t\t\t    aropenalloc_amount, aropen_docdate)\n           ELSE (aropen_amount - aropen_paid)\n      END AS allocated,\n      CASE WHEN((aropen_amount - aropen_paid) >= currToCurr(aropenalloc_curr_id,\n\t\t\t\t\t\t\t     aropen_curr_id,\n\t\t\t\t\t\t\t     aropenalloc_amount,\n\t\t\t\t\t\t\t     aropen_docdate))\n\t    THEN formatMoney(currToCurr(aropenalloc_curr_id, aropen_curr_id,\n\t\t\t\t\taropenalloc_amount, aropen_docdate))\n           ELSE formatMoney(aropen_amount - aropen_paid)\n      END AS f_allocated,\n      CASE WHEN((aropen_amount - aropen_paid) >= currToCurr(aropenalloc_curr_id,\n\t\t\t\t\t\t\t     aropen_curr_id,\n\t\t\t\t\t\t\t     aropenalloc_amount,\n\t\t\t\t\t\t\t     aropen_docdate))\n\t    THEN currToCurr(aropenalloc_curr_id, invchead_curr_id,\n\t\t\t    aropenalloc_amount, aropen_docdate)\n           ELSE currToCurr(aropen_curr_id, invchead_curr_id,\n                           aropen_amount - aropen_paid, aropen_docdate)\n      END AS allocated_invccurr,\n      CASE WHEN((aropen_amount - aropen_paid) >= currToCurr(aropenalloc_curr_id,\n\t\t\t\t\t\t\t     aropen_curr_id,\n\t\t\t\t\t\t\t     aropenalloc_amount,\n\t\t\t\t\t\t\t     aropen_docdate))\n\t    THEN formatMoney(currToCurr(aropenalloc_curr_id, invchead_curr_id,\n\t\t\t\t\taropenalloc_amount, aropen_docdate))\n           ELSE formatMoney(currToCurr(aropen_curr_id, invchead_curr_id,\n                                       aropen_amount - aropen_paid,\n                                       aropen_docdate))\n      END AS f_allocated_invccurr,\n      curr_symbol AS aropen_currsymbol\n FROM invchead LEFT OUTER JOIN cohead ON (cohead_number=invchead_ordernumber)\n               JOIN aropenalloc ON ((aropenalloc_doctype='S' AND aropenalloc_doc_id=cohead_id) OR\n                                    (aropenalloc_doctype='I' AND aropenalloc_doc_id=invchead_id))\n               JOIN aropen ON (aropenalloc_aropen_id=aropen_id)\n               JOIN curr_symbol ON (aropen_curr_id=curr_id)\nWHERE  ((aropen_amount - aropen_paid) > 0)\n  AND   (NOT invchead_posted)\n  AND   (invchead_id=&lt;? value("invchead_id") ?>)\nUNION\nSELECT cohead_id,\n      arapply_source_docnumber AS aropen_docnumber,\n      formatMoney(s.aropen_amount) AS f_total,\n      formatMoney(s.aropen_paid -\n                  currToCurr(arapply_curr_id, s.aropen_curr_id,\n                             arapply_applied, arapply_postdate)) AS f_paid,\n      formatMoney(s.aropen_amount - s.aropen_paid +\n                  currToCurr(arapply_curr_id, s.aropen_curr_id,\n                             arapply_applied, arapply_postdate)) AS f_balance,\n      currToCurr(arapply_curr_id, s.aropen_curr_id,\n                 arapply_applied, arapply_postdate) AS allocated,\n      formatMoney(currToCurr(arapply_curr_id, s.aropen_curr_id,\n                             arapply_applied,\n                             arapply_postdate)) AS f_allocated,\n      currToCurr(arapply_curr_id, invchead_curr_id,\n                 arapply_applied, t.aropen_docdate) AS allocated_invccurr,\n      formatMoney(currToCurr(arapply_curr_id, invchead_curr_id,\n                             arapply_applied,\n                             t.aropen_docdate)) AS f_allocated_invccurr,\n      curr_symbol AS aropen_currsymbol\n FROM arapply, aropen s, aropen t, cohead, invchead, curr_symbol\nWHERE ( (s.aropen_id=arapply_source_aropen_id)\n  AND   (arapply_target_aropen_id=t.aropen_id)\n  AND   (arapply_target_doctype='I')\n  AND   (arapply_target_docnumber=invchead_invcnumber)\n  AND   (arapply_source_aropen_id=s.aropen_id)\n  AND   (arapply_curr_id=curr_id)\n  AND   (arapply_reftype='S')\n  AND   (cohead_number=invchead_ordernumber)\n  AND   (invchead_posted)\n  AND   (invchead_id=&lt;? value("invchead_id") ?>) )\nORDER BY aropen_docnumber;</sql>\n </querysource>\n <querysource>\n  <name>currency</name>\n  <sql>SELECT currConcat(curr_id) AS currConcat, curr_symbol\nFROM invchead, curr_symbol\nWHERE (invchead_id = &lt;? value("invchead_id") ?>)\n AND  (invchead_curr_id = curr_id);</sql>\n </querysource>\n <querysource>\n  <name>logo</name>\n  <sql>SELECT image_data &#xd;\nFROM image &#xd;\nWHERE ((image_name='logo'));</sql>\n </querysource>\n <querysource>\n  <name>tracknum</name>\n  <sql>select formatdate(shiphead_shipdate) AS f_shipdate, shiphead_tracknum, shiphead_shipvia from cohead, shiphead, invchead &#xd;\nwhere &#xd;\ncohead_id = shiphead_order_id&#xd;\nand shiphead_order_type = 'SO'&#xd;\nand cohead_number = invchead_ordernumber&#xd;\nand invchead_id = &lt;? value("invchead_id") ?>&#xd;\norder by shiphead_shipdate;</sql>\n </querysource>\n <pghead>\n  <firstpage/>\n  <height>360</height>\n  <image>\n   <rect>\n    <x>215</x>\n    <y>5</y>\n    <width>270</width>\n    <height>111</height>\n   </rect>\n   <mode>stretch</mode>\n   <data>\n    <query>logo</query>\n    <column>image_data</column>\n   </data>\n  </image>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>5</y>\n    <width>247</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>20</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Invoice</string>\n  </label>\n  <text>\n   <rect>\n    <x>430</x>\n    <y>220</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>f_shiptoaddress</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bill To:</string>\n  </label>\n  <field>\n   <rect>\n    <x>129</x>\n    <y>140</y>\n    <width>111</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invoicenumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>115</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>F.O.B.</string>\n  </label>\n  <field>\n   <rect>\n    <x>430</x>\n    <y>200</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Luciduxsans</face>\n    <size>12</size>\n    <weight>48</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_shipto_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>125</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order #</string>\n  </label>\n  <field>\n   <rect>\n    <x>55</x>\n    <y>200</y>\n    <width>270</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Luciduxsans</face>\n    <size>12</size>\n    <weight>48</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_billto_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>155</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P.O. Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>remitto_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>125</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>ordernumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>155</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_ponumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>650</x>\n    <y>100</y>\n    <width>95</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>f_orderdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>170</y>\n    <width>145</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>5</x>\n    <y>25</y>\n    <width>203</width>\n    <height>16</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>GroupHead</query>\n    <column>remitto_adr</column>\n   </data>\n  </text>\n  <text>\n   <rect>\n    <x>55</x>\n    <y>220</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>f_billtoaddress</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>200</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ship To:</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>100</y>\n    <width>70</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>170</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>350</ystart>\n   <xend>745</xend>\n   <yend>350</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>115</y>\n    <width>190</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>invchead_fob</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>140</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Invoice #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>620</x>\n    <y>40</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>f_invoicedate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>40</y>\n    <width>121</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Invoice Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>55</y>\n    <width>121</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Due Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>620</x>\n    <y>55</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>due_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>70</y>\n    <width>121</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Discount Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>615</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>dis_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>85</y>\n    <width>65</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Terms:</string>\n  </label>\n  <field>\n   <rect>\n    <x>545</x>\n    <y>85</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupHead</query>\n    <column>terms_descrip</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>tracknumber</name>\n  <group>\n   <name>tracknum</name>\n   <column>shiphead_shipdate</column>\n   <head>\n    <height>41</height>\n    <line>\n     <xstart>40</xstart>\n     <ystart>35</ystart>\n     <xend>745</xend>\n     <yend>35</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>390</x>\n      <y>15</y>\n      <width>70</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Sans Serif</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Tracking #</string>\n    </label>\n    <label>\n     <rect>\n      <x>40</x>\n      <y>0</y>\n      <width>240</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Sans Serif</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Shipment Details</string>\n    </label>\n    <label>\n     <rect>\n      <x>40</x>\n      <y>15</y>\n      <width>70</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Ship Date</string>\n    </label>\n    <label>\n     <rect>\n      <x>160</x>\n      <y>15</y>\n      <width>120</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Carrier</string>\n    </label>\n   </head>\n   <foot>\n    <height>12</height>\n    <line>\n     <xstart>40</xstart>\n     <ystart>5</ystart>\n     <xend>745</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>tracknum</query>\n   </key>\n   <height>21</height>\n   <field>\n    <rect>\n     <x>160</x>\n     <y>0</y>\n     <width>225</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Sans Serif</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>tracknum</query>\n     <column>shiphead_shipvia</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>390</x>\n     <y>0</y>\n     <width>280</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Sans Serif</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>tracknum</query>\n     <column>shiphead_tracknum</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>40</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Sans Serif</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>tracknum</query>\n     <column>f_shipdate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>ColumnHeadings</name>\n  <detail>\n   <key>\n    <query>GroupHead</query>\n   </key>\n   <height>41</height>\n   <label>\n    <rect>\n     <x>360</x>\n     <y>10</y>\n     <width>120</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Invoice Currency:</string>\n   </label>\n   <label>\n    <rect>\n     <x>575</x>\n     <y>10</y>\n     <width>75</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Unit Price</string>\n   </label>\n   <label>\n    <rect>\n     <x>40</x>\n     <y>15</y>\n     <width>120</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Qty. Shipped</string>\n   </label>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>10</y>\n     <width>71</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>currency</query>\n     <column>currConcat</column>\n    </data>\n   </field>\n   <line>\n    <xstart>40</xstart>\n    <ystart>35</ystart>\n    <xend>745</xend>\n    <yend>35</yend>\n    <weight>2</weight>\n   </line>\n   <label>\n    <rect>\n     <x>170</x>\n     <y>15</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <string>UOM</string>\n   </label>\n   <label>\n    <rect>\n     <x>255</x>\n     <y>15</y>\n     <width>120</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Item Description</string>\n   </label>\n   <label>\n    <rect>\n     <x>675</x>\n     <y>10</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Ext. Price</string>\n   </label>\n   <label>\n    <rect>\n     <x>255</x>\n     <y>0</y>\n     <width>120</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Item Number</string>\n   </label>\n  </detail>\n </section>\n <section>\n  <name>items</name>\n  <detail>\n   <key>\n    <query>Detail</query>\n   </key>\n   <height>93</height>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>5</y>\n     <width>120</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_billed</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>45</y>\n     <width>480</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>coitem_characteristics</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>440</x>\n     <y>70</y>\n     <width>365</width>\n     <height>14</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Detail</query>\n     <column>lotserial</column>\n    </data>\n   </text>\n   <label>\n    <rect>\n     <x>440</x>\n     <y>60</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>6</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Serial #/Lot Information:</string>\n   </label>\n   <field>\n    <rect>\n     <x>171</x>\n     <y>5</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>invuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>492</x>\n     <y>5</y>\n     <width>31</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>currency</query>\n     <column>curr_symbol</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>5</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_extprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>35</y>\n     <width>300</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>descrip2</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>70</x>\n     <y>60</y>\n     <width>40</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>6</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>Notes:</string>\n   </label>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>5</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_unitprice</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>70</x>\n     <y>70</y>\n     <width>365</width>\n     <height>14</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>Detail</query>\n     <column>invcitem_notes</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>5</y>\n     <width>220</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>25</y>\n     <width>300</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>descrip1</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>allocatedCMs</name>\n  <group>\n   <name>unnamed</name>\n   <column>cohead_id</column>\n   <head>\n    <height>41</height>\n    <label>\n     <rect>\n      <x>45</x>\n      <y>15</y>\n      <width>90</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Doc #</string>\n    </label>\n    <line>\n     <xstart>45</xstart>\n     <ystart>35</ystart>\n     <xend>750</xend>\n     <yend>35</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>180</x>\n      <y>15</y>\n      <width>90</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total Credit</string>\n    </label>\n    <label>\n     <rect>\n      <x>490</x>\n      <y>15</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Allocated</string>\n    </label>\n    <line>\n     <xstart>45</xstart>\n     <ystart>0</ystart>\n     <xend>750</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>45</x>\n      <y>0</y>\n      <width>240</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Sans Serif</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Pre-Allocated Credits</string>\n    </label>\n    <label>\n     <rect>\n      <x>600</x>\n      <y>15</y>\n      <width>140</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Allocated</string>\n    </label>\n    <label>\n     <rect>\n      <x>280</x>\n      <y>15</y>\n      <width>90</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Prev. Applied</string>\n    </label>\n    <label>\n     <rect>\n      <x>380</x>\n      <y>15</y>\n      <width>90</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Balance</string>\n    </label>\n   </head>\n   <foot>\n    <height>21</height>\n    <field>\n     <rect>\n      <x>600</x>\n      <y>0</y>\n      <width>31</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>currency</query>\n      <column>curr_symbol</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>340</x>\n      <y>0</y>\n      <width>240</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total Allocated:</string>\n    </label>\n    <field>\n     <rect>\n      <x>640</x>\n      <y>0</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>allocatedCMs</query>\n      <column>allocated_invccurr</column>\n     </data>\n     <format builtin="true">extprice</format>\n     <tracktotal/>\n    </field>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>allocatedCMs</query>\n   </key>\n   <height>21</height>\n   <field>\n    <rect>\n     <x>140</x>\n     <y>0</y>\n     <width>40</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>allocatedCMs</query>\n     <column>aropen_currsymbol</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>allocatedCMs</query>\n     <column>f_allocated_invccurr</column>\n    </data>\n   </field>\n   <line>\n    <xstart>590</xstart>\n    <ystart>0</ystart>\n    <xend>590</xend>\n    <yend>30</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>280</x>\n     <y>0</y>\n     <width>90</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>allocatedCMs</query>\n     <column>f_paid</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>180</x>\n     <y>0</y>\n     <width>90</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>allocatedCMs</query>\n     <column>f_total</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>480</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>allocatedCMs</query>\n     <column>f_allocated</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>31</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>currency</query>\n     <column>curr_symbol</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>40</x>\n     <y>0</y>\n     <width>90</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>allocatedCMs</query>\n     <column>aropen_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>380</x>\n     <y>0</y>\n     <width>90</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>allocatedCMs</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <firstpage/>\n  <height>167</height>\n  <field>\n   <rect>\n    <x>605</x>\n    <y>5</y>\n    <width>31</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>640</x>\n    <y>25</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupExtended</query>\n    <column>f_freight</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>20</x>\n    <y>25</y>\n    <width>540</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupExtended</query>\n    <column>invchead_notes</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>25</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Freight:</string>\n  </label>\n  <field>\n   <rect>\n    <x>605</x>\n    <y>85</y>\n    <width>31</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>5</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Subtotal:</string>\n  </label>\n  <field>\n   <rect>\n    <x>605</x>\n    <y>25</y>\n    <width>31</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>145</y>\n    <width>40</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>457</x>\n    <y>85</y>\n    <width>140</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Pre-Allocated Credit</string>\n  </label>\n  <field>\n   <rect>\n    <x>640</x>\n    <y>103</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupExtended</query>\n    <column>f_totaldue</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>640</x>\n    <y>5</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>f_extprice</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>605</x>\n    <y>103</y>\n    <width>31</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>640</x>\n    <y>45</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupExtended</query>\n    <column>f_misc</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>640</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupExtended</query>\n    <column>f_allocated</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>45</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Misc. Charge:</string>\n  </label>\n  <field>\n   <rect>\n    <x>640</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>GroupExtended</query>\n    <column>f_tax</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>605</x>\n    <y>45</y>\n    <width>31</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>605</x>\n    <y>65</y>\n    <width>31</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>currency</query>\n    <column>curr_symbol</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sales Tax:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>5</ystart>\n   <xend>745</xend>\n   <yend>5</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>325</x>\n    <y>145</y>\n    <width>20</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>20</x>\n    <y>45</y>\n    <width>540</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>GroupExtended</query>\n    <column>invchead_misc_descrip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>103</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Total Due:</string>\n  </label>\n </pgfoot>\n <pgfoot>\n  <height>27</height>\n  <field>\n   <rect>\n    <x>330</x>\n    <y>0</y>\n    <width>20</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Sans Serif</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>290</x>\n    <y>0</y>\n    <width>40</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n  With Logo - With Invoice Currency       0       2014-10-06 19:47:03.678943
102540
 
371     ItemCostDetail  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Item Costs Detail</title>\n <name>ItemCostDetail</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       costelem_type,\n&lt;? if exists("standardCost") ?>\n       text('Standard Cost')\n&lt;? else ?>\n       text('Actual Cost')\n&lt;? endif ?>\n       AS costtype\n  FROM item, costelem\n WHERE((item_id=&lt;? value("item_id") ?>)\n   AND (costelem_id=&lt;? value("costelem_id") ?>));\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT seqnumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n       formatQtyper(qtyper) AS f_qtyper,\n       formatScrap(bomitem_scrap) AS f_scrap,\n       formatCost(cost) AS f_cost,\n       formatCost(extendedcost) AS f_extendedcost,\n       extendedcost\n  FROM ( SELECT bomitem_seqnumber AS seqnumber,\n                itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper) AS qtyper, bomitem_scrap,\n                item_number, item_descrip1, item_descrip2, uom_name,\n&lt;? if exists("standardCost") ?>\n                itemcost_stdcost AS cost,\n                (itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper * (1 + bomitem_scrap)) *\n                 itemcost_stdcost) AS extendedcost\n&lt;? else ?>\n                currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n                (itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper * (1 + bomitem_scrap)) *\n                 currToBase(itemcost_curr_id, itemcost_actcost, NULL)) AS extendedcost\n&lt;? endif ?>\n           FROM bomitem, item, itemcost, costelem, uom\n          WHERE((bomitem_item_id=item_id)\n            AND (item_inv_uom_id=uom_id)\n            AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires-1))\n            AND (itemcost_item_id=item_id)\n            AND (itemcost_costelem_id=costelem_id)\n            AND (SELECT item_type!='C' FROM item WHERE item_id=&lt;? value("item_id") ?>)\n            AND (bomitem_parent_item_id=&lt;? value("item_id") ?>)\n            AND (costelem_id=&lt;? value("costelem_id") ?>) ) ) AS data\n\nUNION\n\nSELECT seqnumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n       formatQtyPer(bbomitem_qtyper) AS f_qtyper,\n       formatScrap(bbomitem_costabsorb) AS f_scrap,\n       formatCost(cost) AS f_cost,\n       formatCost(extendedcost) AS f_extendedcost,\n       extendedcost\n  FROM ( SELECT bbomitem_seqnumber AS seqnumber, bbomitem_qtyper, bbomitem_costabsorb,\n                item_number, item_descrip1, item_descrip2, uom_name,\n&lt;? if exists("standardCost") ?>\n                itemcost_stdcost AS cost,\n                (itemcost_stdcost / bbomitem_qtyper * bbomitem_costabsorb) AS extendedcost\n&lt;? else ?>\n                currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n                (currToBase(itemcost_curr_id, itemcost_actcost, NULL) / bbomitem_qtyper * bbomitem_costabsorb) AS extendedcost\n&lt;? endif ?>\n           FROM bbomitem, item, itemcost, uom\n          WHERE((bbomitem_parent_item_id=item_id)\n            AND (item_inv_uom_id=uom_id)\n            AND (CURRENT_DATE BETWEEN bbomitem_effective AND (bbomitem_expires-1))\n            AND (itemcost_item_id=bbomitem_parent_item_id)\n            AND (itemcost_costelem_id=&lt;? value("costelem_id") ?>)\n            AND (SELECT item_type='C' FROM item WHERE item_id=&lt;? value("item_id") ?>)\n            AND (bbomitem_item_id=&lt;? value("item_id") ?>) )\n\n          UNION\n\n         SELECT source.bbomitem_seqnumber AS seqnumber,\n                source.bbomitem_qtyper, target.bbomitem_costabsorb,\n                item_number, item_descrip1, item_descrip2, uom_name,\n&lt;? if exists("standardCost") ?>\n                itemcost_stdcost AS cost,\n                (itemcost_stdcost * source.bbomitem_qtyper / target.bbomitem_qtyper * target.bbomitem_costabsorb) AS extendedcost\n&lt;? else ?>\n                currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n                (currToBase(itemcost_curr_id, itemcost_actcost, NULL) * source.bbomitem_qtyper / target.bbomitem_qtyper * target.bbomitem_costabsorb) AS extendedcost\n&lt;? endif ?>\n           FROM item, itemcost, bbomitem AS target, bbomitem AS source, uom\n          WHERE ( (source.bbomitem_parent_item_id=target.bbomitem_parent_item_id)\n            AND (CURRENT_DATE BETWEEN source.bbomitem_effective AND (source.bbomitem_expires-1))\n            AND (CURRENT_DATE BETWEEN target.bbomitem_effective AND (target.bbomitem_expires-1))\n            AND (source.bbomitem_item_id=itemcost_item_id)\n            AND (source.bbomitem_item_id=item_id)\n            AND (item_inv_uom_id=uom_id)\n            AND (item_type='Y')\n            AND (SELECT item_type='C' FROM item WHERE item_id=&lt;? value("item_id") ?>)\n            AND (target.bbomitem_item_id=&lt;? value("item_id") ?>)\n            AND (itemcost_costelem_id=&lt;? value("costelem_id") ?>) ) ) AS data\n ORDER BY seqnumber;</sql>\n </querysource>\n <rpthead>\n  <height>223</height>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cost</string>\n  </label>\n  <field>\n   <rect>\n    <x>490</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>costelem_type</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Cost Detail</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Cost Type:</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>200</y>\n    <width>208</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Descrip</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>410</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty Per.</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>100</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Cost:</string>\n  </label>\n  <field>\n   <rect>\n    <x>490</x>\n    <y>100</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>costtype</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>28</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>410</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty Per.</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>5</y>\n    <width>185</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Descrip</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cost</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>220</x>\n     <y>0</y>\n     <width>185</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>494</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>seqnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>410</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_cost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_extendedcost</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Totals:</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>extendedcost</column>\n   </data>\n   <format builtin="true">qty</format>\n   <tracktotal/>\n  </field>\n </rptfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102541
 
170     ItemCostHistory \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Item Costs History</title>\n <name>ItemCostHistory</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2\n  FROM item\n WHERE (item_id=&lt;? value(&quot;item_id&quot;) ?>);\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT costhist_id,\n       costelem_type as f_element,\n       formatBoolYN(costhist_lowlevel) as f_lower,\n       CASE WHEN costhist_type='A' THEN 'Actual'\n            WHEN costhist_type='S' THEN 'Standard'\n            WHEN costhist_type='D' THEN 'Delete'\n            WHEN costhist_type='N' THEN 'New'\n       END as f_type,\n       formatDateTime(costhist_date) as f_time,\n       costhist_username as f_user,\n       formatCost(costhist_oldcost) as f_oldcost,\n       formatCost(costhist_newcost) as f_newcost\n  FROM costhist, costelem \n WHERE ((costhist_costelem_id=costelem_id)\n   AND (costhist_item_id=&lt;? value(&quot;item_id&quot;) ?>)\n)\nORDER BY costhist_date, costelem_type;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>365</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Time</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>New Cost</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>470</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>User</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>200</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lower</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Costs History</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Element</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>200</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Old Cost</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>5</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lower</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>New Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>5</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Old Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Element</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>470</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>User</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>365</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Time</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_element</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>470</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_user</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>0</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_lower</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>295</x>\n     <y>0</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_type</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_oldcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>365</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_time</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_newcost</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102542
 
169     ItemCostSummary \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Item Costs Summary</title>\n <name>ItemCostSummary</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2\n  FROM item\n WHERE (item_id=&lt;? value("item_id") ?>);\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT itemcost_id,\n       CASE WHEN (costelem_sys) THEN 1\n            ELSE 0\n       END,\n       costelem_type as f_element,\n       formatBoolYN(itemcost_lowlevel) as f_lower,\n       formatCost(itemcost_stdcost) as f_stdcost,\n       formatDate(itemcost_posted, 'Never') as f_posted,\n       formatcost(currToBase(itemcost_curr_id, itemcost_actcost, NULL)) as f_actcost,\n       formatDate(itemcost_updated, 'Never') as f_updated,\n       itemcost_stdcost AS stdcost, currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS actcost\n  FROM itemcost, costelem\n WHERE ((itemcost_costelem_id=costelem_id)\n   AND (itemcost_item_id=&lt;? value("item_id") ?>)\n)\nORDER BY itemcost_lowlevel, costelem_type;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Costs Summary</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Standard Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Updated</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>200</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lower</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Element</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>200</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Actual Cost</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Element</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>5</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Actual Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>5</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Lower</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Standard Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Updated</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_stdcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_element</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_updated</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>280</x>\n     <y>0</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_lower</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>409</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_posted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_actcost</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>490</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>actcost</column>\n   </data>\n   <format builtin="true">price</format>\n   <tracktotal/>\n  </field>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Totals:</string>\n  </label>\n  <field>\n   <rect>\n    <x>330</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>stdcost</column>\n   </data>\n   <format builtin="true">price</format>\n   <tracktotal/>\n  </field>\n </rptfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102543
 
168     ItemCostsByClassCode    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Item Costs By Class Code</title>\n <name>ItemCostsByClassCode</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("classcode_id") ?>\n         ( SELECT (classcode_code || '-' || classcode_descrip)\n             FROM classcode\n            WHERE (classcode_id=&lt;? value("classcode_id") ?>) )\n       &lt;? elseif exists("classcode_pattern") ?>\n         text(&lt;? value("classcode_pattern") ?>)\n       &lt;? else ?>\n         text('All Class Codes')\n       &lt;? endif ?>\n       AS classcode;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT item_id,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       uom_name as f_uom,\n       formatCost(scost) as f_stdcost,\n       formatCost(acost) as f_actcost,\n       classcode_code\n  FROM ( SELECT item_id,\n                item_number,\n                item_descrip1,\n                item_descrip2,\n                uom_name,\n                stdcost(item_id) AS scost,\n                actcost(item_id) AS acost,\n                classcode_code\n           FROM item, classcode, uom\n          WHERE ((item_classcode_id=classcode_id)\n            AND (item_inv_uom_id=uom_id)\n          &lt;? if exists("onlyShowActive") ?>\n            AND (item_active) \n          &lt;? endif ?> \n          &lt;? if exists("classcode_id") ?>\n            AND (classcode_id=&lt;? value("classcode_id") ?>)\n          &lt;? elseif exists("classcode_pattern") ?>\n            AND (classcode_code ~ &lt;? value("classcode_pattern") ?>)\n          &lt;? endif ?>\n          )\n       ) AS data\n WHERE ( (true)\n&lt;? if exists("onlyShowZeroCosts") ?>\n   AND ((scost=0) OR (acost=0))\n&lt;? endif ?>\n&lt;? if exists("onlyShowDiffCosts") ?>\n   AND (scost != acost)\n&lt;? endif ?>\n )\nORDER BY item_number</sql>\n </querysource>\n <rpthead>\n  <height>234</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>120</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Class Code(s):</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Class Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>215</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>10</y>\n    <width>380</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Costs by Class Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>228</ystart>\n   <xend>745</xend>\n   <yend>228</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Actual Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>200</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>120</y>\n    <width>565</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>classcode</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Standard Cost</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Actual Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Standard Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Class Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>15</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>0</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_uom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_stdcost</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>classcode_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>0</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>30</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>15</y>\n     <width>228</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_actcost</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102544
 
171     ItemMaster      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Item Master</title>\n <name>ItemMaster</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       formatBoolYN(item_active) AS f_item_active,\n       item_descrip1, item_descrip2,\n       CASE WHEN(item_type='P') THEN 'Purchased'\n            WHEN(item_type='M') THEN 'Manufactured'\n            WHEN(item_type='J') THEN 'Job'\n            WHEN(item_type='F') THEN 'Phantom'\n            WHEN(item_type='B') THEN 'Breeder'\n            WHEN(item_type='C') THEN 'Co-Product'\n            WHEN(item_type='Y') THEN 'By-Product'\n            WHEN(item_type='R') THEN 'Reference'\n            WHEN(item_type='T') THEN 'Tooling'\n            WHEN(item_type='O') THEN 'Outside Process'\n            WHEN(item_type='K') THEN 'Kit'\n            ELSE item_type\n       END AS f_item_type,\n       formatBoolYN(item_config) AS f_item_config,\n       (classcode_code||' - '||classcode_descrip) AS f_classcode,\n       CASE WHEN (COALESCE(freightclass_id, -1) &lt;> -1) THEN (freightclass_code||' - '||freightclass_descrip) END AS f_freightclass,\n       iuom.uom_name AS invuom,\n       formatBoolYN(item_picklist) AS f_item_picklist,\n       formatBoolYN(item_fractional) AS f_item_fractional,\n       itemcapuom(item_id) AS capuom, itemaltcapuom(item_id) AS altcapuom, puom.uom_name AS shipuom,\n       formatUOMRatio(itemcapinvrat(item_id)) AS f_capinvrat,\n       formatUOMRatio(itemaltcapinvrat(item_id)) AS f_altcapinvrat,\n       formatUOMRatio(iteminvpricerat(item_id)) AS f_shipinvrat,\n       formatWeight(item_prodweight) AS f_item_prodweight,\n       formatWeight(item_packweight) AS f_item_packweight,\n       formatBoolYN(item_sold) AS f_item_sold\n  FROM item JOIN classcode ON (classcode_id=item_classcode_id)\n            JOIN uom iuom ON (iuom.uom_id=item_inv_uom_id)\n            JOIN uom puom ON (puom.uom_id=item_price_uom_id)\n            LEFT OUTER JOIN freightclass ON (freightclass_id=item_freightclass_id)\n WHERE (item_id=&lt;? value("item_id") ?>)\n;</sql>\n </querysource>\n <querysource>\n  <name>sold</name>\n  <sql>SELECT uom_name,\n       formatUOMRatio(iteminvpricerat(item_id)) AS f_iteminvpricerat,\n       (prodcat_code||' - '||prodcat_descrip) AS f_prodcat,\n       formatBoolYN(item_exclusive) AS f_item_exclusive,\n       formatPrice(item_listprice) AS f_item_listprice,\n       formatExtPrice(item_listprice / iteminvpricerat(item_id)) AS f_extprice\n  FROM item, prodcat, uom\n WHERE ((item_id=&lt;? value("item_id") ?>)\n   AND  (item_price_uom_id=uom_id)\n   AND  (item_sold)\n   AND  (item_prodcat_id=prodcat_id) );</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT item_comments, item_extdescrip\n  FROM item\n WHERE (item_id=&lt;? value("item_id") ?>);</sql>\n </querysource>\n <querysource>\n  <name>itemchar</name>\n  <sql>SELECT 1 as one,\n       char_name as charass_name,\n       charass_value\n  FROM charass, char\n WHERE ((charass_target_type='I')\n   AND (charass_char_id=char_id)\n   AND (charass_target_id=&lt;? value("item_id") ?>))\nORDER BY char_name;</sql>\n </querysource>\n <querysource>\n  <name>imglist</name>\n  <sql>SELECT 1 as one,\n       image_name, firstLine(image_descrip) as f_descrip,\n       CASE WHEN (imageass_purpose='I') THEN 'Inventory Description'\n            WHEN (imageass_purpose='P') THEN 'Product Description'\n            WHEN (imageass_purpose='E') THEN 'Engineering Reference'\n            WHEN (imageass_purpose='M') THEN 'Miscellaneous'\n            ELSE 'Other'\n       END as f_purpose\nFROM imageass, image\nWHERE ( (imageass_image_id=image_id)\n AND (imageass_source='I')\n AND (imageass_source_id=&lt;? value("item_id") ?>) )\nORDER BY image_name;</sql>\n </querysource>\n <querysource>\n  <name>comments</name>\n  <sql>SELECT 1 as one,\n       formatDate(comment_date) as f_date,\n       comment_user,\n       comment_text\nFROM comment\nWHERE ( (comment_source='I')\n AND (comment_source_id=&lt;? value("item_id") ?>) )\nORDER BY comment_date;</sql>\n </querysource>\n <rpthead>\n  <height>333</height>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>310</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_item_sold</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>252</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipping/Inventory UOM Ratio:</string>\n  </label>\n  <field>\n   <rect>\n    <x>465</x>\n    <y>252</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_shipinvrat</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>285</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Product Weight:</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>285</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Packaging Weight:</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>135</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Configured:</string>\n  </label>\n  <field>\n   <rect>\n    <x>505</x>\n    <y>135</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_item_config</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>505</x>\n    <y>155</y>\n    <width>225</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_freightclass</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>227</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Alt. Capacity UOM:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>227</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>altcapuom</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>390</x>\n    <y>285</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_item_packweight</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>465</x>\n    <y>207</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_capinvrat</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>102</y>\n    <width>400</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>335</x>\n    <y>5</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Master</string>\n  </label>\n  <label>\n   <rect>\n    <x>482</x>\n    <y>185</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Fractional:</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>252</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipping UOM:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>155</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_classcode</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>135</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_item_type</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>65</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>185</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>invuom</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>310</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item is Sold:</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>185</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Pick List Item:</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>207</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Capacity/Inventory UOM Ratio:</string>\n  </label>\n  <field>\n   <rect>\n    <x>465</x>\n    <y>227</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_altcapinvrat</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>457</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Active:</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>185</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Inventory UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>155</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Class Code:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>252</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shipuom</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>285</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_item_prodweight</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>207</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>capuom</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>85</y>\n    <width>400</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_item_active</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>227</y>\n    <width>220</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Alt. Capacity/Inventory UOM Ratio:</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>155</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Freight Class:</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>135</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Type:</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>207</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Capacity UOM:</string>\n  </label>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>185</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_item_fractional</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>370</x>\n    <y>185</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_item_picklist</column>\n   </data>\n  </field>\n </rpthead>\n <section>\n  <name>sold</name>\n  <detail>\n   <key>\n    <query>sold</query>\n   </key>\n   <height>93</height>\n   <label>\n    <rect>\n     <x>65</x>\n     <y>65</y>\n     <width>140</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Ext. Price:</string>\n   </label>\n   <field>\n    <rect>\n     <x>207</x>\n     <y>45</y>\n     <width>200</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>sold</query>\n     <column>f_item_listprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>45</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>sold</query>\n     <column>f_item_exclusive</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>65</x>\n     <y>25</y>\n     <width>140</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Product Category:</string>\n   </label>\n   <label>\n    <rect>\n     <x>65</x>\n     <y>45</y>\n     <width>140</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>List Price:</string>\n   </label>\n   <label>\n    <rect>\n     <x>535</x>\n     <y>45</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Exclusive</string>\n   </label>\n   <field>\n    <rect>\n     <x>207</x>\n     <y>25</y>\n     <width>300</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>sold</query>\n     <column>f_prodcat</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>545</x>\n     <y>5</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>sold</query>\n     <column>f_iteminvpricerat</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>340</x>\n     <y>5</y>\n     <width>200</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Price/Inventory UOM Ratio:</string>\n   </label>\n   <field>\n    <rect>\n     <x>207</x>\n     <y>65</y>\n     <width>200</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>sold</query>\n     <column>f_extprice</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>535</x>\n     <y>25</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Taxable:</string>\n   </label>\n   <field>\n    <rect>\n     <x>207</x>\n     <y>5</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>sold</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>102</x>\n     <y>5</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Price UOM:</string>\n   </label>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>36</height>\n   <label>\n    <rect>\n     <x>15</x>\n     <y>5</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Notes:</string>\n   </label>\n   <text>\n    <rect>\n     <x>120</x>\n     <y>5</y>\n     <width>615</width>\n     <height>20</height>\n    </rect>\n    <bottompad>5</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>notes</query>\n     <column>item_comments</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <section>\n  <name>extdescrip</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>36</height>\n   <label>\n    <rect>\n     <x>5</x>\n     <y>5</y>\n     <width>110</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Ext. Description:</string>\n   </label>\n   <text>\n    <rect>\n     <x>120</x>\n     <y>5</y>\n     <width>615</width>\n     <height>20</height>\n    </rect>\n    <bottompad>5</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>notes</query>\n     <column>item_extdescrip</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <section>\n  <name>itemchar</name>\n  <group>\n   <name>itemchar</name>\n   <column>one</column>\n   <head>\n    <height>57</height>\n    <line>\n     <xstart>120</xstart>\n     <ystart>50</ystart>\n     <xend>690</xend>\n     <yend>50</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>300</x>\n      <y>35</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Value</string>\n    </label>\n    <label>\n     <rect>\n      <x>50</x>\n      <y>10</y>\n      <width>145</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Item Characteristics</string>\n    </label>\n    <label>\n     <rect>\n      <x>125</x>\n      <y>35</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Characteristic</string>\n    </label>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>itemchar</query>\n   </key>\n   <height>21</height>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>0</y>\n     <width>385</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>itemchar</query>\n     <column>charass_value</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>125</x>\n     <y>0</y>\n     <width>160</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>itemchar</query>\n     <column>charass_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>imglist</name>\n  <group>\n   <name>imglist</name>\n   <column>one</column>\n   <head>\n    <height>57</height>\n    <label>\n     <rect>\n      <x>575</x>\n      <y>35</y>\n      <width>110</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Purpose</string>\n    </label>\n    <label>\n     <rect>\n      <x>125</x>\n      <y>35</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Name</string>\n    </label>\n    <label>\n     <rect>\n      <x>50</x>\n      <y>10</y>\n      <width>145</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Image List:</string>\n    </label>\n    <label>\n     <rect>\n      <x>250</x>\n      <y>35</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Description</string>\n    </label>\n    <line>\n     <xstart>120</xstart>\n     <ystart>50</ystart>\n     <xend>690</xend>\n     <yend>50</yend>\n     <weight>0</weight>\n    </line>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>imglist</query>\n   </key>\n   <height>21</height>\n   <field>\n    <rect>\n     <x>565</x>\n     <y>0</y>\n     <width>130</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>imglist</query>\n     <column>f_purpose</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>125</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>imglist</query>\n     <column>image_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>250</x>\n     <y>0</y>\n     <width>315</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>imglist</query>\n     <column>f_descrip</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>comments</name>\n  <group>\n   <name>comments</name>\n   <column>one</column>\n   <head>\n    <height>57</height>\n    <label>\n     <rect>\n      <x>207</x>\n      <y>35</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>User</string>\n    </label>\n    <label>\n     <rect>\n      <x>315</x>\n      <y>35</y>\n      <width>110</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Comment</string>\n    </label>\n    <label>\n     <rect>\n      <x>50</x>\n      <y>10</y>\n      <width>145</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Comments:</string>\n    </label>\n    <line>\n     <xstart>120</xstart>\n     <ystart>50</ystart>\n     <xend>690</xend>\n     <yend>50</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>125</x>\n      <y>35</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Date</string>\n    </label>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>comments</query>\n   </key>\n   <height>21</height>\n   <text>\n    <rect>\n     <x>315</x>\n     <y>0</y>\n     <width>370</width>\n     <height>15</height>\n    </rect>\n    <bottompad>5</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>comments</query>\n     <column>comment_text</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>207</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>comments</query>\n     <column>comment_user</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>125</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>comments</query>\n     <column>f_date</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>102</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102545
 
456     ItemSources     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Item Sources</title>\n <name>ItemSources</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT item_number, vend_name,\n       item_descrip1, item_descrip2,\n       uom_name,\n       itemsrc_vend_item_number as f_venditem,\n       itemsrc_vend_uom as f_venduom,\n       formatQty(itemsrc_invvendoruomratio) as f_uomratio\nFROM itemsrc, vendinfo, item, uom\nWHERE ((itemsrc_vend_id=vend_id)\n  AND (itemsrc_item_id=item_id)\n  AND (item_inv_uom_id=uom_id)\n&lt;? if exists("item_id") ?>\n  AND (itemsrc_item_id=&lt;? value("item_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("vend_id") ?>\n  AND (itemsrc_vend_id=&lt;? value("vend_id") ?>)\n&lt;? endif ?>\n)\nORDER By item_number, vend_name;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>195</x>\n    <y>10</y>\n    <width>530</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Sources</string>\n  </label>\n  <label>\n   <rect>\n    <x>230</x>\n    <y>183</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>695</x>\n    <y>183</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>183</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vendor UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>183</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>230</x>\n    <y>198</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>435</x>\n    <y>183</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <text>\n   <rect>\n    <x>15</x>\n    <y>38</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>183</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>-1</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vendor UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>435</x>\n    <y>-1</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>230</x>\n    <y>14</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>695</x>\n    <y>-1</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>-1</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>-1</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>230</x>\n    <y>-1</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <field>\n    <rect>\n     <x>435</x>\n     <y>2</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>695</x>\n     <y>2</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_uomratio</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>230</x>\n     <y>2</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>2</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_venduom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>230</x>\n     <y>32</y>\n     <width>400</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>230</x>\n     <y>17</y>\n     <width>400</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>485</x>\n     <y>2</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_venditem</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>2</y>\n     <width>215</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102546
 
365     JobCosting      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Job Costing</title>\n <name>JobCosting</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatwonumber(&lt;? value("wo_id") ?>) AS wonumber;\n    </sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>manufacture</mqlgroup>\n  <mqlname>jobcosting</mqlname>\n </querysource>\n <rpthead>\n  <height>141</height>\n  <label>\n   <rect>\n    <x>635</x>\n    <y>115</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>70</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Work Order:</string>\n  </label>\n  <label>\n   <rect>\n    <x>80</x>\n    <y>115</y>\n    <width>219</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Work Center/Item</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>135</ystart>\n   <xend>740</xend>\n   <yend>135</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>115</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>115</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>555</x>\n    <y>115</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>115</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>wonumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Work Order Costing</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>9</height>\n </pghead>\n <pghead>\n  <height>29</height>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>214</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Work Center/Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>0</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>555</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>21</height>\n   <line>\n    <xstart>0</xstart>\n    <ystart>20</ystart>\n    <xend>740</xend>\n    <yend>20</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>630</x>\n     <y>0</y>\n     <width>29</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>80</x>\n     <y>0</y>\n     <width>219</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>0</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>15</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>type</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qty</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n   <field>\n    <rect>\n     <x>666</x>\n     <y>0</y>\n     <width>84</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cost</column>\n    </data>\n    <format builtin="true">cost</format>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>cost</column>\n   </data>\n   <format builtin="true">cost</format>\n   <tracktotal subtotal="true"/>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Cost:</string>\n  </label>\n </rptfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102547
 
79      ListOpenSalesOrders     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>List Open Sales Orders</title>\n <name>ListOpenSalesOrders</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse;\n</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>opensalesorders</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>173</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>153</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>153</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer P/O Number</string>\n  </label>\n  <line>\n   <xstart>4</xstart>\n   <ystart>168</ystart>\n   <xend>744</xend>\n   <yend>168</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>153</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>List Sales Orders</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>153</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>43</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>0</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer P/O Number</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>95</x>\n     <y>0</y>\n     <width>325</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_billtoname</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_custponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_orderdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_number</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102548
 
217     LocationDispatchList    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Location Dispatch List</title>\n <name>LocationDispatchList</name>\n <description></description>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT warehous_code\nFROM whsinfo\nWHERE (warehous_id=%1);</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT formatLocationBarcode(location_id) AS barcode,\n       formatLocationIssueBarcode(location_id) AS issuebarcode,\n       formatLocationContentsBarcode(location_id) AS contentsbarcode,\n       location_name, firstLine(location_descrip) AS description\nFROM location\nWHERE (location_id IN (%2))\nORDER BY location_name;</sql>\n </querysource>\n <rpthead>\n  <height>131</height>\n  <label>\n   <rect>\n    <x>335</x>\n    <y>100</y>\n    <width>280</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>View Contents</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>125</ystart>\n   <xend>985</xend>\n   <yend>125</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>395</x>\n    <y>35</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>5</y>\n    <width>284</width>\n    <height>31</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>16</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Location Dispatch List</string>\n  </label>\n  <field>\n   <rect>\n    <x>510</x>\n    <y>35</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_code</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>95</y>\n    <width>280</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Balance and Post</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>100</y>\n    <width>280</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>General Use</string>\n  </label>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>80</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Location</string>\n  </label>\n </rpthead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>location_name</column>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>71</height>\n   <field>\n    <rect>\n     <x>15</x>\n     <y>5</y>\n     <width>125</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>location_name</column>\n    </data>\n   </field>\n   <barcode>\n    <rect>\n     <x>335</x>\n     <y>30</y>\n     <width>280</width>\n     <height>25</height>\n    </rect>\n    <format>128</format>\n    <maxlength>20</maxlength>\n    <left/>\n    <data>\n     <query>detail</query>\n     <column>contentsbarcode</column>\n    </data>\n   </barcode>\n   <barcode>\n    <rect>\n     <x>5</x>\n     <y>30</y>\n     <width>280</width>\n     <height>25</height>\n    </rect>\n    <format>128</format>\n    <maxlength>20</maxlength>\n    <left/>\n    <data>\n     <query>detail</query>\n     <column>barcode</column>\n    </data>\n   </barcode>\n   <barcode>\n    <rect>\n     <x>670</x>\n     <y>30</y>\n     <width>280</width>\n     <height>25</height>\n    </rect>\n    <format>128</format>\n    <maxlength>20</maxlength>\n    <left/>\n    <data>\n     <query>detail</query>\n     <column>issuebarcode</column>\n    </data>\n   </barcode>\n   <field>\n    <rect>\n     <x>170</x>\n     <y>5</y>\n     <width>275</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>description</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>65</ystart>\n    <xend>985</xend>\n    <yend>65</yend>\n    <weight>0</weight>\n   </line>\n  </detail>\n </section>\n</report>\n            0       2014-10-06 19:47:03.678943
102549
 
96      MaterialUsageVarianceByComponentItem    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Material Usage Variance By Component Item</title>\n <name>MaterialUsageVarianceByComponentItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       uom_name,\n       &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate\n  FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=&lt;? value("component_item_id") ?>);\n</sql>\n </querysource>\n <querysource loadFromDb="true" >\n  <name>detail</name>\n  <mqlgroup>workOrderVariance</mqlgroup>\n  <mqlname>material</mqlname>\n </querysource>\n <rpthead>\n  <height>234</height>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>80</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>200</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Req.</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>10</y>\n    <width>545</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Material Usage Variance By Component Item</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>120</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>80</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Number:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>145</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>120</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>228</ystart>\n   <xend>745</xend>\n   <yend>228</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Produced</string>\n  </label>\n  <label>\n   <rect>\n    <x>480</x>\n    <y>120</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>80</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>340</x>\n    <y>80</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>uom_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Item</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>100</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Issue</string>\n  </label>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>480</x>\n    <y>100</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>145</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. per Var.</string>\n  </label>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>100</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Produced</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Issue</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. per Var.</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Req.</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_actqtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>15</y>\n     <width>400</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>parentdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_posted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>494</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_projqtyper</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>494</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_projreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_actiss</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtypervarpercent</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_received</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>parentitemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtypervar</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102550
 
98      MaterialUsageVarianceByWarehouse        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Material Usage Variance By Site</title>\n <name>MaterialUsageVarianceByWarehouse</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse;</sql>\n </querysource>\n <querysource loadFromDb="true" >\n  <name>detail</name>\n  <mqlgroup>workOrderVariance</mqlgroup>\n  <mqlname>material</mqlname>\n </querysource>\n <rpthead>\n  <height>234</height>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Issue</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Qty. per</string>\n  </label>\n  <field>\n   <rect>\n    <x>490</x>\n    <y>130</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Req.</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>110</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>380</x>\n    <y>110</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>490</x>\n    <y>110</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>444</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. per Var.</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>110</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>228</x>\n    <y>10</y>\n    <width>494</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Material Usage Variance By Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>215</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Qty. per</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>228</ystart>\n   <xend>745</xend>\n   <yend>228</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>444</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Produced</string>\n  </label>\n  <label>\n   <rect>\n    <x>380</x>\n    <y>130</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>444</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Produced</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>15</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. per Var.</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>444</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Req.</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Issue</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_projreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>15</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>parentdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>595</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_actqtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>444</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>265</x>\n     <y>15</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>componentdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>595</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_actiss</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtypervarpercent</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>265</x>\n     <y>0</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>componentitemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtypervar</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>0</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>parentitemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>444</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_received</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_posted</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_projqtyper</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102551
 
97      MaterialUsageVarianceByWorkOrder        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Material Usage Variance By Work Order</title>\n <name>MaterialUsageVarianceByWorkOrder</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatWONumber(wo_id) AS wonumber,\n       warehous_code, item_number, uom_name,\n       item_descrip1, item_descrip2,\n       wo_status\n  FROM wo, itemsite, item, whsinfo, uom\n WHERE ((wo_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (wo_id=&lt;? value("wo_id") ?>))</sql>\n </querysource>\n <querysource loadFromDb="true" >\n  <name>detail</name>\n  <mqlgroup>workOrderVariance</mqlgroup>\n  <mqlname>material</mqlname>\n </querysource>\n <rpthead>\n  <height>234</height>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>140</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>228</ystart>\n   <xend>745</xend>\n   <yend>228</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>120</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_code</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Produced</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>70</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>wonumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>165</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>wo_status</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. per Var.</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>100</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Number:</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Issue</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>200</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Req.</string>\n  </label>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>100</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>uom_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>70</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>165</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Status:</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>100</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>70</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Work Order #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>234</x>\n    <y>10</y>\n    <width>490</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Material Usage Variance By Work Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Qty. per</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. per Var.</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Req.</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Issue</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Produced</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Proj. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Act. Qty. per</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>%</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_actiss</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>15</y>\n     <width>375</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>componentdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>componentitemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_received</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtypervarpercent</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>494</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_projreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_actqtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_posted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>494</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_projqtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtypervar</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102552
 
426     MetaSQLMasterList       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>List of MetaSQL statements</title>\n <name>MetaSQLMasterList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>100</topmargin>\n <bottommargin>100</bottommargin>\n <rightmargin>100</rightmargin>\n <leftmargin>100</leftmargin>\n <querysource loadFromDb="true">\n  <name>Detail</name>\n  <mqlgroup>metasqls</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>100</height>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>10</y>\n    <width>300</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>16</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>MetaSQL Statements</string>\n  </label>\n </rpthead>\n <section>\n  <name>Detail</name>\n  <detail>\n   <key>\n    <query>Detail</query>\n   </key>\n   <height>27.4992</height>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>100</width>\n     <height>12.5</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>metasql_group</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>150</width>\n     <height>12.5</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>metasql_name</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>350</x>\n     <y>0</y>\n     <width>300</width>\n     <height>14</height>\n    </rect>\n    <bottompad>12</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>metasql_notes_qttooltiprole</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>100</width>\n     <height>12.5</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>pkgname</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>65.9806</height>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>22.5008</y>\n    <width>25</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>of</string>\n  </label>\n  <field>\n   <rect>\n    <x>330</x>\n    <y>22.5008</y>\n    <width>100</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_count</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>200</x>\n    <y>22.5008</y>\n    <width>100</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102553
 
103     OpenWorkOrdersWithClosedParentSalesOrders       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Open Work Orders With Closed Parent Sales Orders</title>\n <name>OpenWorkOrdersWithClosedParentSalesOrders</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT formatWONumber(wo_id) AS wonumber,\n       wo_status, item_number, uom_name,\n       item_descrip1, item_descrip2,\n       warehous_code,\n       cohead_number,\n       formatQty(wo_qtyord) AS qtyord,\n       formatQty(wo_qtyrcv) AS qtyrcv,\n       formatDate(wo_startdate) AS startdate,\n       formatDate(wo_duedate) AS duedate \n  FROM coitem, cohead, wo, itemsite, whsinfo, item, uom\n WHERE ((coitem_cohead_id=cohead_id)\n   AND (coitem_order_id=wo_id)\n   AND (coitem_status='C')\n   AND (wo_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (wo_status IN ('O', 'E', 'R', 'I'))\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n)\nORDER BY wo_duedate;</sql>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>110</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>200</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>15</y>\n    <width>686</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Open Work Orders With Closed Parent Sales Orders</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>110</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>265</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>wonumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>0</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>405</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyord</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>startdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>wo_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>duedate</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyrcv</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>620</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102554
 
286     OpenWorkOrdersWithParentSalesOrders     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Open Work Orders With Parent Sales Orders</title>\n <name>OpenWorkOrdersWithParentSalesOrders</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT formatWONumber(wo_id) AS wonumber,\n       wo_status, item_number, uom_name,\n       item_descrip1, item_descrip2,\n       warehous_code,\n       cohead_number,\n       formatQty(wo_qtyord) AS qtyord,\n       formatQty(wo_qtyrcv) AS qtyrcv,\n       formatDate(wo_startdate) AS startdate,\n       formatDate(wo_duedate) AS duedate \n  FROM coitem, cohead, wo, itemsite, whsinfo, item, uom\n WHERE ((coitem_cohead_id=cohead_id)\n   AND (coitem_order_id=wo_id)\n   AND (coitem_status&lt;>'X')\n   AND (wo_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (wo_status IN ('O', 'E', 'R', 'I'))\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n)\nORDER BY wo_duedate;</sql>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>230</ystart>\n   <xend>745</xend>\n   <yend>230</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>15</y>\n    <width>686</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Open Work Orders With Parent Sales Orders</string>\n  </label>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>110</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>110</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>200</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>wo_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>0</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>wonumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyrcv</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>startdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>265</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>405</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyord</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>duedate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>620</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102555
 
363     OpportunityList \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Opportunity List</title>\n <name>OpportunityList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>opportunities</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <querysource>\n  <name>queryParams</name>\n  <sql>SELECT\n  formatDate(&lt;? value("startDate") ?>,'Earliest') AS f_startDate,\n  formatDate(&lt;? value("endDate") ?>,'Latest') AS f_endDate,\n  &lt;? if exists("username") ?>\n    &lt;? value("username") ?> AS usr_username\n  &lt;? elseif exists("usr_pattern") ?>\n    &lt;? value("usr_pattern") ?> AS usr_username\n  &lt;? else ?>\n    text('All') AS usr_username\n  &lt;? endif ?>\n;</sql>\n </querysource>\n <rpthead>\n  <height>163</height>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>143</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>395</x>\n    <y>143</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>143</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Actual Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>128</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Stage</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Opportunity List</string>\n  </label>\n  <label>\n   <rect>\n    <x>480</x>\n    <y>143</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Curr.</string>\n  </label>\n  <line>\n   <xstart>5.66667</xstart>\n   <ystart>158.333</ystart>\n   <xend>745.667</xend>\n   <yend>158.333</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>143</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>CRM Acct #</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>143</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Target Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>143</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Prob. %</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>128</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>143</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Owner</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>128</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>43</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Stage</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>20</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>CRM Acct #</string>\n  </label>\n  <label>\n   <rect>\n    <x>395</x>\n    <y>20</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>20</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>305</x>\n    <y>20</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Prob. %</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Actual Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>480</x>\n    <y>20</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Curr.</string>\n  </label>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>20</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Owner</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Target Date</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>ByUser</name>\n   <column>usr</column>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>36</height>\n   <field>\n    <rect>\n     <x>220</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>opsource_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>395</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>50</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>crmacct_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>480</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_currency</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ophead_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ophead_probability_prcnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_actualdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>220</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>opstage_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_targetdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>135</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ophead_owner_username</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>optype_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102556
 
294     OrderActivityByProject  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Order Activity By Project</title>\n <name>OrderActivityByProject</name>\n <description>Order Activity Report</description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT prj_name, prj_number\n  FROM prj\n WHERE (prj_id=&lt;? value("prj_id") ?>);</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>-- Group: orderActivityByProject\n-- Name:  detail\n-- Notes: \n\nSELECT *, \n  formatQty(qty) AS f_qty,\n  formatMoney(value) AS f_value,\n  'curr' AS qty_xtnumericrole,\n  'curr' AS value_xtnumericrole\nFROM (\n&lt;? if exists("showSo") ?>\n----- QUOTES -----\nSELECT quhead_id AS id, \n       15 AS type,\n       quhead_number::text AS subtype,\n       1 AS section,\n       &lt;? value("quotes") ?> AS section_qtdisplayrole,\n       quhead_number::text AS name,\n       CASE WHEN (quhead_status = 'C') THEN \n         &lt;? value("converted") ?>\n            WHEN (quhead_status = 'X') THEN\n         &lt;? value("canceled") ?>\n            WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n         &lt;? value("open") ?>\n            ELSE\n         &lt;? value("expired") ?>\n       END AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       NULL AS value,\n       0.0 AS ordertotal,\n       1 AS xtindentrole\n  FROM quhead\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (quhead_prj_id = &lt;? value("prj_id") ?>)\nGROUP BY quhead_id, quhead_number, quhead_status, quhead_expire, quhead_freight, quhead_misc\n\nUNION ALL\n\nSELECT quitem_id AS id, \n       17 AS type,\n       quhead_number::text AS subtype,\n       1 AS section,\n       &lt;? value("quotes") ?> AS section_qtdisplayrole,\n       quitem_linenumber::text AS name, \n       CASE WHEN (quhead_status = 'C') THEN \n         &lt;? value("converted") ?>\n            WHEN (quhead_status = 'X') THEN\n         &lt;? value("canceled") ?>\n            WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n         &lt;? value("open") ?>\n            ELSE\n         &lt;? value("Expired") ?>\n       END AS status,\n       item_number AS item,\n       item_descrip1 || ' ' || item_descrip2 AS descrip,\n       quitem_qtyord,\n       uom_name AS uom,\n       (quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio) AS value,\n       0.0 AS ordertotal,\n       2 AS xtindentrole\n  FROM quhead\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n    JOIN uom ON (quitem_qty_uom_id = uom_id)\n    JOIN itemsite ON (quitem_itemsite_id = itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n WHERE (quhead_prj_id = &lt;? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT quhead_id AS id, \n       18 AS type,\n       quhead_number::text AS subtype,\n       1 AS section,\n       &lt;? value("quotes") ?> AS section_qtdisplayrole,\n       &lt;? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS value,\n       SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS ordertotal,\n       1 AS xtindentrole\n  FROM quhead\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (quhead_prj_id = &lt;? value("prj_id") ?>)\nGROUP BY quhead_id, quhead_number\n\nUNION ALL\n\n------ SALES ORDERS ------\nSELECT cohead_id AS id, \n       25 AS type,\n       cohead_number::text AS subtype,\n       2 AS section,\n       &lt;? value("sos") ?> AS section_qtdisplayrole,\n       cohead_number::text AS name,\n      COALESCE((SELECT \n                  CASE WHEN (coitem_status = 'O') THEN\n                    &lt;? value("open") ?>\n                       WHEN (coitem_status = 'C') THEN\n                    &lt;? value("closed" ?>\n                      ELSE\n                    &lt;? value("canceled") ?>\n                  END\n                FROM \n               (SELECT coitem_status,\n                   CASE \n                     WHEN (coitem_status = 'O') THEN 1\n                     WHEN (coitem_status = 'C') then 2\n                     ELSE  3\n                  END AS type\n                  FROM coitem\n                 WHERE (coitem_cohead_id=cohead_id)\n                 ORDER BY type\n                 LIMIT 1) AS sts) ,'O')\n        AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       NULL AS value,\n       0.0 AS ordertotal,\n       1 AS xtindentrole\n  FROM cohead\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (cohead_prj_id = &lt;? value("prj_id") ?>)\nGROUP BY cohead_id, cohead_number\n\nUNION ALL\n\nSELECT coitem_id AS id, \n       27 AS type,\n       cohead_number::text AS subtype,\n       2 AS section,\n       &lt;? value("sos") ?> AS section_qtdisplayrole,\n       coitem_linenumber::text AS name, \n       CASE WHEN (coitem_status = 'O') THEN\n         &lt;? value("open") ?>\n            WHEN (coitem_status = 'C') THEN\n         &lt;? value("closed") ?>\n            WHEN (coitem_status = 'X') THEN\n         &lt;? value("canceled") ?>\n       END AS status,\n       item_number AS item,\n       item_descrip1 || ' ' || item_descrip2 AS descrip,\n       coitem_qtyord,\n       uom_name AS uom,\n       (coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) AS value,\n       0.0 AS ordertotal,\n       2 AS xtindentrole\n  FROM cohead\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n    JOIN uom ON (coitem_qty_uom_id = uom_id)\n    JOIN itemsite ON (coitem_itemsite_id = itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n WHERE (cohead_prj_id = &lt;? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT cohead_id AS id, \n       28 AS type,\n       cohead_number::text AS subtype,\n       2 AS section,\n       &lt;? value("sos") ?> AS section_qtdisplayrole,\n       &lt;? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS value,\n       SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS ordertotal,\n       1 AS xtindentrole\n  FROM cohead\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (cohead_prj_id = &lt;? value("prj_id") ?>)\nGROUP BY cohead_id, cohead_number\n\nUNION ALL\n\n------ INVOICES -------\nSELECT invchead_id AS id,\n       35 AS type,\n       invchead_invcnumber::text AS subtype,\n       3 AS section,\n       &lt;? value("invoices") ?> AS section_qtdisplayrole,\n       invchead_invcnumber::text AS name,\n       CASE WHEN (invchead_posted) THEN\n         &lt;? value("posted") ?>\n       ELSE &lt;? value("unposted") ?>\n       END AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       NULL AS value,\n       0.0 AS ordertotal,\n       1 AS xtindentrole\n  FROM invchead\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (invchead_prj_id = &lt;? value("prj_id") ?>)\nGROUP BY invchead_id, invchead_invcnumber, invchead_freight, invchead_misc_amount, invchead_posted\n\nUNION ALL\n\nSELECT invcitem_id AS id, \n       37 AS type,\n       invchead_invcnumber::text AS subtype,\n       3 AS section,\n       &lt;? value("invoices") ?> AS section_qtdisplayrole,\n       invcitem_linenumber::text AS name, \n       CASE WHEN (invchead_posted) THEN\n         &lt;? value("posted") ?>\n       ELSE &lt;? value("unposted") ?>\n       END AS status,\n       COALESCE(item_number,invcitem_number) AS item,\n       COALESCE(item_descrip1 || ' ' || item_descrip2,invcitem_descrip) AS descrip,\n       invcitem_billed AS qty,\n       uom_name AS uom,\n       (invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio) AS value,\n       0.0 AS ordertotal,\n       2 AS xtindentrole\n  FROM invchead\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n    LEFT OUTER JOIN item ON (invcitem_item_id = item_id)\n    LEFT OUTER JOIN uom ON (invcitem_qty_uom_id = uom_id)\n WHERE (invchead_prj_id = &lt;? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT invchead_id AS id, \n       38 AS type,\n       invchead_invcnumber::text AS subtype,\n       3 AS section,\n       &lt;? value("invoices") ?> AS section_qtdisplayrole,\n       &lt;? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS value,\n       SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS ordertotal,\n       1 AS xtindentrole\n  FROM invchead\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (invchead_prj_id = &lt;? value("prj_id") ?>)\nGROUP BY invchead_id, invchead_invcnumber\n\n&lt;? endif ?>\n\n\n&lt;? if exists("showWo") ?>\n\n&lt;?   if exists("showSo") ?>\n\nUNION ALL\n\n&lt;?   endif ?>\n\n------ WORK ORDERS -------\nSELECT wo_id AS id, \n       45 AS type,\n       formatWoNumber(wo_id) AS subtype,\n       4 AS section,\n       &lt;? value("wos") ?> AS section_qtdisplayrole,\n       formatWoNumber(wo_id) AS name,\n       CASE WHEN (wo_status = 'O') THEN\n         &lt;? value("open") ?>\n            WHEN (wo_status = 'E') THEN\n         &lt;? value("exploded") ?>\n            WHEN (wo_status = 'R') THEN\n         &lt;? value("released") ?>\n            WHEN (wo_status = 'I') THEN\n         &lt;? value("inprocess") ?>\n            WHEN (wo_status = 'C') THEN\n         &lt;? value("closed") ?>\n       END AS status,\n       item_number AS item,\n       item_descrip1 || ' ' || item_descrip2 AS descrip,\n       wo_qtyord AS qty,\n       uom_name AS uom,\n       wo_postedvalue AS value,\n       wo_postedvalue AS ordertotal,\n       1 AS xtindentrole\n  FROM wo\n    JOIN itemsite ON (itemsite_id=wo_itemsite_id)\n    JOIN item ON (itemsite_item_id=item_id)\n    JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (wo_prj_id = &lt;? value("prj_id") ?>)\n\n&lt;? endif ?>\n\n\n&lt;? if exists("showPo") ?>\n&lt;?   if exists("showSo") ?>\n UNION ALL\n&lt;? elseif exists("showWo") ?>\n UNION ALL\n\n&lt;? endif ?>\n------ PURCHASE REQUESTS ------\nSELECT pr_id AS id, \n       55 AS type,\n       pr_number::text || '-' || pr_subnumber::text AS subtype,\n       5 AS section,\n       &lt;? value("prs") ?> AS section_qtdisplayrole,\n       pr_number::text || '-' || pr_subnumber::text AS name,\n       &lt;? value("open") ?> AS status, \n       item_number AS item,\n       (item_descrip1 || ' ' || item_descrip2) AS descrip,\n       pr_qtyreq AS qty,\n       uom_name AS uom,\n       stdcost(item_id) * pr_qtyreq AS value,\n       stdcost(item_id) * pr_qtyreq AS ordertotal,\n       1 AS xtindentrole\n  FROM pr\n    JOIN itemsite ON (itemsite_id = pr_itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n    JOIN uom ON (item_inv_uom_id = uom_id)\n WHERE (pr_prj_id=&lt;? value("prj_id") ?>)\n\nUNION ALL\n\n------ PURCHASE ORDERS ------\nSELECT pohead_id AS id,\n       65 AS type,\n       pohead_number::text AS subtype,\n       6 AS section,\n       &lt;? value("pos") ?> AS section_qtdisplayrole,\n       pohead_number::text AS name,\n       CASE WHEN (pohead_status = 'U') THEN\n         &lt;? value("unreleased") ?>\n            WHEN (pohead_status = 'O') THEN\n         &lt;? value("open") ?>\n            WHEN (pohead_status = 'C') THEN\n         &lt;? value("closed") ?>\n       END AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL AS uom,\n       NULL AS value,\n       0.0 AS ordertotal,\n       1 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n WHERE (poitem_prj_id = &lt;? value("prj_id") ?>)\nGROUP BY pohead_id, pohead_number, pohead_freight, pohead_status\n\nUNION ALL\n\nSELECT poitem_id AS id, \n       67 AS type,\n       pohead_number::text AS subtype,\n       6 AS section,\n       &lt;? value("pos") ?> AS section_qtdisplayrole,\n       poitem_linenumber::text AS name, \n       CASE WHEN (poitem_status = 'U') THEN\n         &lt;? value("unreleased") ?>\n            WHEN (poitem_status = 'O') THEN\n         &lt;? value("open") ?>\n            WHEN (poitem_status = 'C') THEN\n         &lt;? value("closed") ?>\n       END AS status,\n       COALESCE(item_number,poitem_vend_item_number) AS item,\n       COALESCE((item_descrip1 || ' ' || item_descrip2),poitem_vend_item_descrip) AS descrip,\n       poitem_qty_ordered,\n       poitem_vend_uom AS uom,\n       (poitem_qty_ordered * poitem_unitprice) AS value,\n       0.0 AS ordertotal,\n       2 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n    LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n    LEFT OUTER JOIN item ON (itemsite_item_id = item_id)\n WHERE (poitem_prj_id = &lt;? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT pohead_id AS id, \n       68 AS type,\n       pohead_number::text AS subtype,\n       6 AS section,\n       &lt;? value("pos") ?> AS section_qtdisplayrole,\n       &lt;? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM(poitem_qty_ordered * poitem_unitprice) AS value,\n       SUM(poitem_qty_ordered * poitem_unitprice) AS ordertotal,\n       1 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n WHERE (poitem_prj_id = &lt;? value("prj_id") ?>)\nGROUP BY pohead_id, pohead_number\n\n&lt;? endif ?>\n\n) data\nORDER BY section, subtype, type, id;</sql>\n </querysource>\n <rpthead>\n  <height>75</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>25</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Project Number:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>25</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>45</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>45</y>\n    <width>509</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>prj_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>397</x>\n    <y>5.85</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Order Activity by Project</string>\n  </label>\n </rpthead>\n <section>\n  <name>section</name>\n  <group>\n   <name>type</name>\n   <column>section</column>\n   <head>\n    <height>53</height>\n    <label>\n     <rect>\n      <x>395</x>\n      <y>30</y>\n      <width>135</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Quantity Ordered / Billed</string>\n    </label>\n    <line>\n     <xstart>0</xstart>\n     <ystart>45</ystart>\n     <xend>750</xend>\n     <yend>45</yend>\n     <weight>2</weight>\n    </line>\n    <label>\n     <rect>\n      <x>660</x>\n      <y>30</y>\n      <width>50</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Value</string>\n    </label>\n    <label>\n     <rect>\n      <x>209</x>\n      <y>30</y>\n      <width>85</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Status</string>\n    </label>\n    <line>\n     <xstart>77</xstart>\n     <ystart>45</ystart>\n     <xend>77</xend>\n     <yend>45</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>100</x>\n      <y>30</y>\n      <width>104</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Order Number - Line</string>\n    </label>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>5</y>\n      <width>90</width>\n      <height>16</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Order Type:</string>\n    </label>\n    <field>\n     <rect>\n      <x>90</x>\n      <y>5</y>\n      <width>610</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>section_qtdisplayrole</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>305</x>\n      <y>30</y>\n      <width>95</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Item</string>\n    </label>\n   </head>\n   <foot>\n    <height>33</height>\n    <label>\n     <rect>\n      <x>440</x>\n      <y>10</y>\n      <width>140</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <top/>\n     <string>Section Total:</string>\n    </label>\n    <line>\n     <xstart>305</xstart>\n     <ystart>5</ystart>\n     <xend>750</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>610</x>\n      <y>10</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>ordertotal</column>\n     </data>\n     <format builtin="true">money</format>\n     <tracktotal subtotal="true"/>\n    </field>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>305</x>\n     <y>0</y>\n     <width>135</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>95</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>209</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>444</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>544</x>\n     <y>0</y>\n     <width>165</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_value</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>700</x>\n    <y>15</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>15</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>5</ystart>\n   <xend>750</xend>\n   <yend>5</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>75</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n Order Activity Report   0       2014-10-06 19:47:03.678943
102557
 
147     POLineItemsByDate       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>P/O Line Items By Date</title>\n <name>POLineItemsByDate</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;warehous_id&quot;) ?>\n         (SELECT warehous_code FROM whsinfo WHERE warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists(&quot;agentUsername&quot;) ?>\n       TEXT(&lt;? value(&quot;agentUsername&quot; ?>)\n       &lt;? else ?>\n       TEXT('All Agents')\n       &lt;? endif ?>\n       AS agentUsername,\n       &lt;? if exists(&quot;openItems&quot;) ?>\n         text('Open Items')\n       &lt;? elseif exists(&quot;closedItems&quot;) ?>\n         text('Closed Items')\n       &lt;? else ?>\n         text('All Items')\n       &lt;? endif ?>\n       as f_whichitems,\n       formatDate(&lt;? value(&quot;startDate&quot;) ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value(&quot;endDate&quot;) ?>, 'Latest') AS enddate\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT CASE WHEN (itemsite_id IS NULL) THEN ( SELECT warehous_code\n                                              FROM whsinfo\n                                              WHERE (pohead_warehous_id=warehous_id) )\n            ELSE ( SELECT warehous_code\n                   FROM whsinfo\n                   WHERE (itemsite_warehous_id=warehous_id) )\n       END AS warehousecode,\n       pohead_number as f_ponumber,\n       poitem_linenumber as f_linenumber,\n       vend_name,\n       formatDate(poitem_duedate) as f_duedate,\n       COALESCE(item_number, (text('NonInv - ') || poitem_vend_item_number)) AS itemnumber,\n       COALESCE(uom_name, poitem_vend_uom) AS itemuom,\n       formatQty(poitem_qty_ordered) as f_ordered,\n       formatQty(poitem_qty_received) as f_received,\n       formatQty(poitem_qty_returned) as f_returned\n  FROM pohead, vendinfo,\n       poitem LEFT OUTER JOIN\n         (itemsite JOIN item\n           ON (itemsite_item_id=item_id) JOIN uom ON (item_inv_uom_id=uom_id))\n         ON (poitem_itemsite_id=itemsite_id) \n WHERE ((poitem_pohead_id=pohead_id)\n   AND (pohead_vend_id=vend_id)\n   AND (poitem_duedate BETWEEN &lt;? value(&quot;startDate&quot;) ?> AND &lt;? value(&quot;endDate&quot;) ?>)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND ( ( (itemsite_id IS NULL) AND (pohead_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) ) OR\n         ( (itemsite_id IS NOT NULL) AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) ) )\n&lt;? endif ?>\n&lt;? if exists(&quot;agentUsername&quot;) ?>\n   AND (pohead_agent_username=&lt;? value(&quot;agentUsername&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;openItems&quot;) ?>\n   AND (poitem_status='O')\n&lt;? elseif exists(&quot;closedItems&quot;) ?>\n   AND (poitem_status='C')\n&lt;? endif ?>\n)\nORDER BY poitem_duedate;</sql>\n </querysource>\n <rpthead>\n  <height>237</height>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>75</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>agentUsername</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>75</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purchasing Agent:</string>\n  </label>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>75</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Due Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>5</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>P/O Line Items By Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>443</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Due Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Returned</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>215</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>130</y>\n    <width>165</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_whichitems</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>130</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>95</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>75</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Returned</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>130</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>15</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>37</height>\n   <line>\n    <xstart>5</xstart>\n    <ystart>30</ystart>\n    <xend>745</xend>\n    <yend>30</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_returned</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>525</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>370</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>45</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_received</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehousecode</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>285</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>15</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_linenumber</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>103</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102558
 
148     POLineItemsByItem       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>P/O Line Items By Item</title>\n <name>POLineItemsByItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number, item_descrip1, item_descrip2, uom_name,\n       &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT warehous_code FROM whsinfo WHERE warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists(&quot;agentUsername&quot;) ?>\n       TEXT(&lt;? value(&quot;agentUsername&quot; ?>)\n       &lt;? else ?>\n       TEXT('All Agents')\n       &lt;? endif ?>\n       AS agentUsername,\n       &lt;? if exists(&quot;openItems&quot;) ?>\n         text('Open Items')\n       &lt;? elseif exists(&quot;closedItems&quot;) ?>\n         text('Closed Items')\n       &lt;? else ?>\n         text('All Items')\n       &lt;? endif ?>\n       AS f_whichitems\n  FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=&lt;? value(&quot;item_id&quot;) ?>);\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT warehous_code, pohead_number as f_ponumber, vend_name,\n       formatDate(poitem_duedate) as f_duedate,\n       poitem_vend_uom as uom_name, \n       formatQty(poitem_qty_ordered) as f_ordered,\n       formatQty(poitem_qty_received) as f_received,\n       formatQty(poitem_qty_returned) as f_returned \n  FROM pohead, poitem, vendinfo, itemsite, whsinfo\n WHERE ((poitem_pohead_id=pohead_id)\n   AND (pohead_vend_id=vend_id)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;agentUsername&quot;) ?>\n   AND (pohead_agent_username=&lt;? value(&quot;agentUsername&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;openItems&quot;) ?>\n   AND (poitem_status='O')\n&lt;? elseif exists(&quot;closedItems&quot;) ?>\n   AND (poitem_status='C')\n&lt;? endif ?>\n   AND (poitem_itemsite_id=itemsite_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (itemsite_item_id=&lt;? value(&quot;item_id&quot;) ?>)\n) \nORDER BY poitem_duedate;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>75</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Returned</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>5</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>P/O Line Items By Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>75</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <label>\n   <rect>\n    <x>493</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>325</x>\n    <y>75</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>uom_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>355</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>130</y>\n    <width>165</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_whichitems</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>110</x>\n    <y>112</y>\n    <width>250</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>535</x>\n    <y>95</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>110</x>\n    <y>75</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>110</x>\n    <y>95</y>\n    <width>250</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>535</x>\n    <y>75</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>agentUsername</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>75</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purchasing Agent:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Returned</string>\n  </label>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>493</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_received</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>440</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_returned</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>355</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>493</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>135</x>\n     <y>0</y>\n     <width>215</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>45</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ponumber</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>103</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102559
 
146     POLineItemsByVendor     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>P/O Line Items By Vendor</title>\n <name>POLineItemsByVendor</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT\n&lt;? if exists("vend_id") ?>\n       (SELECT ('Vendor = ' || vend_name) FROM vendinfo WHERE vend_id=&lt;? value("vend_id") ?>)\n&lt;? elseif exists("vendtype_id") ?>\n       (SELECT ('Vendor Type = ' || vendtype_code) FROM vendtype WHERE vendtype_id=&lt;? value("vendtype_id") ?>)\n&lt;? elseif exists("vendtype_pattern") ?>\n       ('Vendor Type pattern = ' || &lt;? value("vendtype_pattern") ?>)\n&lt;? else ?>\n       'All Vendors'\n&lt;? endif ?>\n       AS selection,\n       &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code FROM whsinfo WHERE warehous_id=&lt;? value("warehous_id") ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("agentUsername") ?>\n       TEXT(&lt;? value("agentUsername" ?>)\n       &lt;? else ?>\n       TEXT('All Agents')\n       &lt;? endif ?>\n       AS agentUsername,\n       &lt;? if exists("openItems") ?>\n         text('Open Items')\n       &lt;? elseif exists("closedItems") ?>\n         text('Closed Items')\n       &lt;? else ?>\n         text('All Items')\n       &lt;? endif ?>\n       AS f_whichitems\n;</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>poItems</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>224</height>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>535</x>\n    <y>75</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>agentUsername</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>130</y>\n    <width>165</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_whichitems</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>5</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>P/O Line Items By Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>75</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purchasing Agent:</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>75</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Selection:</string>\n  </label>\n  <field>\n   <rect>\n    <x>535</x>\n    <y>95</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>150</x>\n    <y>75</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>selection</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>493</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Returned</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>9</height>\n </pghead>\n <pghead>\n  <height>24</height>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>493</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Returned</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>19</height>\n   <field>\n    <rect>\n     <x>440</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>225</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>45</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>pohead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>135</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>493</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_qty_ordered</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_qty_received</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_qty_returned</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>19</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>103</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102560
 
350     POsByDate       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>P/Os By Date</title>\n <name>POsByDate</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("warehous_id") ?>\n         (SELECT warehous_code FROM whsinfo WHERE warehous_id=&lt;? value("warehous_id") ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("agentUsername") ?>\n       TEXT(&lt;? value("agentUsername" ?>)\n       &lt;? else ?>\n       TEXT('All Agents')\n       &lt;? endif ?>\n       AS agentUsername,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate\n</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>purchaseOrders</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>198</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>80</x>\n    <y>198</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>198</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>198</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>75</y>\n    <width>275</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>agentUsername</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>95</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>75</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>5</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>P/Os By Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>75</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purchasing Agent:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>198</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>442</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Order Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>75</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Order Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>198</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Date</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>80</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>2</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehousecode</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>325</x>\n     <y>2</y>\n     <width>230</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>650</x>\n     <y>2</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>80</x>\n     <y>2</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>pohead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>2</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>565</x>\n     <y>2</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_orderdate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>103</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102561
 
351     POsByVendor     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>P/Os By Vendor</title>\n <name>POsByVendor</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("warehous_id") ?>\n         (SELECT warehous_code FROM whsinfo WHERE warehous_id=&lt;? value("warehous_id") ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n&lt;? if exists("vend_id") ?>\n       (SELECT ('Vendor = ' || vend_name) FROM vendinfo WHERE vend_id=&lt;? value("vend_id") ?>)\n&lt;? elseif exists("vendtype_id") ?>\n       (SELECT ('Vendor Type = ' || vendtype_code) FROM vendtype WHERE vendtype_id=&lt;? value("vendtype_id") ?>)\n&lt;? elseif exists("vendtype_pattern") ?>\n       ('Vendor Type pattern = ' || &lt;? value("vendtype_pattern") ?>)\n&lt;? else ?>\n       'All Vendors'\n&lt;? endif ?>\n       AS selection,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("byReceiptDate") ?>\n         TEXT('By Receipt Date')\n       &lt;? elseif exists("byDueDate") ?>\n         TEXT('By Due Date')\n       &lt;? else ?>\n         TEXT('By Order Date')\n       &lt;? endif ?>\n       AS f_byDate,\n       &lt;? if exists("descrip_pattern") ?>\n         TEXT('Where Item Description contains ' || &lt;? value("descrip_pattern") ?>)\n       &lt;? else ?>\n         TEXT('')\n       &lt;? endif ?>\n       AS f_descrip\n</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>purchaseOrders</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>135</y>\n    <width>540</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_descrip</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>115</y>\n    <width>180</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_byDate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>442</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>95</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>442</x>\n    <y>75</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>80</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>5</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>P/Os By Vendor</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>75</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>selection</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>75</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Selection:</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>75</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>80</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>650</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_orderdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehousecode</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>80</x>\n     <y>0</y>\n     <width>110</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>pohead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_number</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>103</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102562
 
422     PackageMasterList       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Package Master List</title>\n <name>PackageMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT *, formatboolyn(packageIsEnabled(pkghead_name)) AS enabled\nFROM pkghead\nORDER BY pkghead_name, pkghead_version DESC;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Package Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Package</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Version</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>55</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Enabled</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Package</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Version</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Enabled</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>265</x>\n     <y>0</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>pkghead_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>pkghead_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>565</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>pkghead_version</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>enabled</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102563
 
328     PackingList-Shipment    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Packing List (Shipment)</title>\n <name>PackingList-Shipment</name>\n <description>Non-Hybrid version - driven only by shiphead_id parameter - Packing List showing the contents of a particular shipment - Shows RA# if SO is a replacement order for and RA</description>\n <parameter default="324" active="true" listtype="static" type="string" name="shiphead_id">\n  <description></description>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>25</topmargin>\n <bottommargin>25</bottommargin>\n <rightmargin>25</rightmargin>\n <leftmargin>25</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT shiphead_number, 'S/O #:' AS ordertype,\n       cohead_number AS ordernumber,\n       formatsobarcode(cohead_id) AS order_barcode,\n       COALESCE(shiphead_shipvia, cohead_shipvia) AS shipvia,\n       cohead_shiptophone AS shiptophone,\n       cohead_custponumber,\n       formatDate(cohead_orderdate) AS orderdate,\n       cohead_shipcomments AS shipcomments,   \n       cohead_billtoname AS billtoname,\n       formataddr(cohead_billtoaddress1, cohead_billtoaddress2,\n                  cohead_billtoaddress3,\n                  (cohead_billtocity || '  ' ||   cohead_billtostate ||\n                  '  ' || cohead_billtozipcode), cohead_billtocountry) AS billing_address,\n       cohead_shiptoname AS shiptoname,\n       formataddr(cohead_shiptoaddress1, cohead_shiptoaddress2,\n                  cohead_shiptoaddress3,\n                  (cohead_shiptocity || '  ' ||   cohead_shiptostate ||\n                  '  ' || cohead_shiptozipcode), cohead_shiptocountry) AS shipping_address,           \n\n       cust_number,\n       trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n       cntct_phone AS cust_phone,\n       terms_descrip\n  FROM shiphead\n  JOIN cohead ON (cohead_id=shiphead_order_id)\n  JOIN custinfo ON (cohead_cust_id=cust_id)\n  JOIN terms ON (cohead_terms_id=terms_id)\n  LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n WHERE (shiphead_id=&lt;? value("shiphead_id") ?>)\n\n&lt;? if exists("MultiWhs") ?>\nUNION\nSELECT shiphead_number, 'T/O #:' AS ordertype,\n       tohead_number AS ordernumber,\n       formattobarcode(tohead_id) AS order_barcode,\n       shiphead_shipvia AS shipvia,\n       tohead_destphone AS shiptophone,\n       TEXT(' ') AS cohead_custponumber,\n       formatDate(tohead_orderdate) AS orderdate,\n       tohead_shipcomments AS shipcomments,\n       tohead_srcname AS billtoname,\n       formataddr(tohead_srcaddress1, tohead_srcaddress2,\n                   tohead_srcaddress3,\n                  (tohead_srccity || ' ' || tohead_srcstate ||\n                   ' ' || tohead_srcpostalcode), tohead_srccountry) AS billing_address,\n       tohead_destname AS shiptoname,\n       formataddr(tohead_destaddress1, tohead_destaddress2,\n                   tohead_destaddress3,\n                  (tohead_destcity || ' ' || tohead_deststate ||\n                   ' ' || tohead_destpostalcode), tohead_destcountry) AS shipping_address,\n       'Transfer Order' AS cust_number,\n       tohead_destcntct_name AS cust_contact,\n       tohead_destphone AS cust_phone,\n       '' AS terms_descrip\n  FROM shiphead, tohead\n WHERE ((tohead_id=shiphead_order_id)\n   AND  (shiphead_order_type='TO')\n   AND  (shiphead_id=&lt;? value("shiphead_id") ?>)\n)\n&lt;? endif ?>;</sql>\n </querysource>\n <querysource>\n  <name>scheddate</name>\n  <sql>SELECT formatDate(MIN(coitem_scheddate)) AS scheddate\n  FROM coitem, shipitem\n WHERE ((coitem_status &lt;> 'X')\n   AND  (coitem_id=shipitem_orderitem_id)\n   AND  (shipitem_shiphead_id=&lt;? value("shiphead_id") ?>));</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT 1 AS groupby,\n       coitem_linenumber AS sortline, coitem_subnumber AS sortsubline,\n       formatsolinenumber(coitem_id) AS linenumber,\n       coitem_memo AS memo,\n       CASE WHEN (coitem_custpn != '') THEN coitem_custpn\n            ELSE item_number\n       END AS item_number,\n       formatitemsitebarcode(itemsite_id) AS item_barcode,\n       formatsoitembarcode(coitem_id) AS orderitem_barcode,\n--     In 2.3 replaced the next line:\n--     uom_name,\n--     with:\n       (select uom_name from uom where uom_id = coitem_qty_uom_id) AS uom_name,\n       itemsellinguom(item_id) AS shipuom,\n       CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip1\n            ELSE item_descrip1\n       END AS item_descrip1,\n       CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip2\n            ELSE item_descrip2\n       END AS item_descrip2,\n\n       formatQty(coitem_qtyord) AS ordered,\n       (SELECT formatQty(SUM(shipitem_qty)) FROM shipitem WHERE ((shipitem_shiphead_id=&lt;? value("shiphead_id") ?>) AND (shipitem_orderitem_id=coitem_id))) AS shipped,\n\n       CASE WHEN (coitem_status='O' AND (SELECT cust_creditstatus\n                                           FROM custinfo,cohead\n                                          WHERE coitem_cohead_id=cohead_id\n                                            AND (cust_id=cohead_cust_id))='H') THEN 'H'\n            WHEN (coitem_status='O' AND ((SELECT SUM(invcitem_billed)\n                                            FROM cohead, invchead, invcitem\n                                           WHERE ((invchead_ordernumber=cohead_number)\n                                             AND  (invcitem_invchead_id=invchead_id)\n                                             AND  (invcitem_item_id=item_id)\n                                             AND  (invcitem_warehous_id=itemsite_warehous_id)\n                                             AND  (invcitem_linenumber=coitem_linenumber)\n                                             AND  (cohead_id=coitem_cohead_id))) >= coitem_qtyord)) THEN 'I'\n            WHEN (coitem_status='O' AND ((SELECT SUM(invcitem_billed)\n                                            FROM cohead, invchead, invcitem\n                                           WHERE ((invchead_ordernumber=cohead_number)\n                                             AND  (invcitem_invchead_id=invchead_id)\n                                             AND  (invcitem_item_id=item_id)\n                                             AND  (invcitem_warehous_id=itemsite_warehous_id)\n                                             AND  (invcitem_linenumber=coitem_linenumber)\n                                             AND  (cohead_id=coitem_cohead_id))) > 0)) THEN 'P'\n            WHEN (coitem_status='O' AND (qtyAvailable(itemsite_id) - qtyAllocated(itemsite_id, CURRENT_DATE)\n                                         + qtyOrdered(itemsite_id, CURRENT_DATE))\n                                          >= (coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) THEN 'R'\n            ELSE coitem_status\n       END AS f_status,\n       CASE\n         WHEN (getPacklistItemLotSerial(shipitem_shiphead_id, coitem_id) = '') THEN\n           ''\n         ELSE\n           'Serial #/Lot Information:'\n       END AS lotserial_title,\n       getPacklistItemLotSerial(shipitem_shiphead_id, coitem_id) AS lotserial,\n       CASE\n         WHEN (getPacklistCharName(shipitem_shiphead_id, coitem_id) = '') THEN\n           ''\n         ELSE\n           'Characteristics:'\n       END AS char_title,\n       getPacklistCharName(shipitem_shiphead_id, coitem_id) AS char_name,\n       getPacklistCharValue(shipitem_shiphead_id, coitem_id) AS char_value\n  FROM shipitem\n       JOIN coitem ON (coitem_id=shipitem_orderitem_id)\n       JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n       JOIN item ON (item_id=itemsite_item_id)\n       JOIN uom ON (uom_id=item_inv_uom_id)\n       LEFT OUTER JOIN itemalias ON (itemalias_item_id=item_id AND itemalias_number=coitem_custpn) \n WHERE ( (coitem_status &lt;> 'X')\n   AND (shipitem_shiphead_id=&lt;? value("shiphead_id") ?>)\n)\n&lt;? if exists("MultiWhs") ?>\nUNION\nSELECT 2 AS groupby,\n       toitem_linenumber AS sortline, 0 AS sortsubline,\n       CAST(toitem_linenumber AS text) AS linenumber,\n       toitem_notes AS memo,\n       item_number,\n       formatitemsitebarcode(itemsite_id) AS item_barcode,\n       formattoitembarcode(toitem_id) AS orderitem_barcode,\n       uom_name,\n       itemsellinguom(item_id) AS shipuom,\n       item_descrip1,\n       item_descrip2,\n\n       formatQty(toitem_qty_ordered) AS ordered,\n\n       (SELECT formatQty(SUM(shipitem_qty))\n        FROM shipitem\n        WHERE ((shipitem_shiphead_id=&lt;? value("shiphead_id") ?>)\n          AND  (shipitem_orderitem_id=toitem_id))\n       ) AS shipped,\n\n       toitem_status AS f_status,\n       CASE\n         WHEN (getPacklistItemLotSerial(shiphead_id, toitem_id) = '') THEN\n           ''\n         ELSE\n           'Serial #/Lot Information:'\n       END AS lotserial_title,\n       getPacklistItemLotSerial(shiphead_id, toitem_id) AS lotserial,\n       '' AS char_title,\n       '' AS char_name,\n       '' AS char_value\n  FROM itemsite, item, toitem, tohead, shipitem, shiphead, uom\n WHERE ((toitem_item_id=item_id)\n   AND  (item_inv_uom_id=uom_id)\n   AND  (item_id=itemsite_item_id)\n   AND  (toitem_tohead_id=tohead_id)\n   AND  (toitem_status &lt;> 'X')\n   AND  (tohead_src_warehous_id=itemsite_warehous_id)\n   AND  (toitem_id=shipitem_orderitem_id)\n   AND  (shipitem_shiphead_id=shiphead_id)\n   AND  (shiphead_order_type='TO')\n   AND  (shiphead_id=&lt;? value("shiphead_id") ?>)\n)\n&lt;? endif ?>\nORDER BY sortline, sortsubline;</sql>\n </querysource>\n <querysource>\n  <name>logo</name>\n  <sql>SELECT image_data \nFROM image \nWHERE ((image_name='logo'));</sql>\n </querysource>\n <querysource>\n  <name>so_ra_relation</name>\n  <sql>--added in 2.3 to show RA link to S/O if the SO\n--was created as the result of a replacement RA\n&lt;? if exists("EnableReturnAuth") ?>\nselect \n'RA #' AS ratext,\nrahead_number\nfrom\nrahead, cohead, shiphead\nwhere \nrahead_new_cohead_id = cohead_id\nand cohead_id = shiphead_order_id\nand shiphead_id = &lt;? value("shiphead_id") ?>;\n&lt;? else ?>\nselect \n'' AS ratext,\n'' AS rahead_number\n&lt;? endif ?></sql>\n </querysource>\n <rpthead>\n  <height>463</height>\n  <image>\n   <rect>\n    <x>375</x>\n    <y>0</y>\n    <width>425</width>\n    <height>100</height>\n   </rect>\n   <mode>stretch</mode>\n   <data>\n    <query>logo</query>\n    <column>image_data</column>\n   </data>\n  </image>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>112</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>ordernumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>10</y>\n    <width>355</width>\n    <height>50</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>20</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipment Packing List</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>440</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>85</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipment #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>425</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Verified</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>175</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>202</y>\n    <width>307</width>\n    <height>25</height>\n   </rect>\n   <format>3of9</format>\n   <maxlength>20</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </barcode>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>400</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Terms:</string>\n  </label>\n  <field>\n   <rect>\n    <x>480</x>\n    <y>285</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shiptoname</column>\n   </data>\n  </field>\n  <line>\n   <xstart>0</xstart>\n   <ystart>425</ystart>\n   <xend>797</xend>\n   <yend>425</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>202</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer P/O #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>252</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sched. Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>231</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>400</y>\n    <width>95</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Attention:</string>\n  </label>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>175</y>\n    <width>177</width>\n    <height>25</height>\n   </rect>\n   <format>3of9</format>\n   <maxlength>10</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </barcode>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shiphead_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>145</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>so_ra_relation</query>\n    <column>ratext</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>112</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>ordertype</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>425</y>\n    <width>40</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <text>\n   <rect>\n    <x>480</x>\n    <y>305</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>shipping_address</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>285</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bill To:</string>\n  </label>\n  <field>\n   <rect>\n    <x>480</x>\n    <y>252</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shipvia</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>400</y>\n    <width>320</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>terms_descrip</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>231</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>orderdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>202</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </field>\n  <line>\n   <xstart>0</xstart>\n   <ystart>455</ystart>\n   <xend>797</xend>\n   <yend>455</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>252</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ship Via:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>425</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Line</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>425</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>112</y>\n    <width>231</width>\n    <height>25</height>\n   </rect>\n   <format>128</format>\n   <maxlength>10</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>order_barcode</column>\n   </data>\n  </barcode>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>285</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>billtoname</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>252</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>scheddate</query>\n    <column>scheddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>432</x>\n    <y>425</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>425</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>145</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>so_ra_relation</query>\n    <column>rahead_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>285</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ship To:</string>\n  </label>\n  <field>\n   <rect>\n    <x>112</x>\n    <y>400</y>\n    <width>250</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>cust_contact</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>90</x>\n    <y>305</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>billing_address</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>175</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n </rpthead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>characteristic</name>\n   <column>linenumber</column>\n   <foot>\n    <height>35</height>\n    <text>\n     <rect>\n      <x>130</x>\n      <y>5</y>\n      <width>195</width>\n      <height>17</height>\n     </rect>\n     <bottompad>14</bottompad>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>char_name</column>\n     </data>\n    </text>\n    <text>\n     <rect>\n      <x>10</x>\n      <y>5</y>\n      <width>103</width>\n      <height>17</height>\n     </rect>\n     <bottompad>14</bottompad>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>char_title</column>\n     </data>\n    </text>\n    <text>\n     <rect>\n      <x>370</x>\n      <y>5</y>\n      <width>195</width>\n      <height>17</height>\n     </rect>\n     <bottompad>14</bottompad>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>char_value</column>\n     </data>\n    </text>\n   </foot>\n  </group>\n  <group>\n   <name>lotserial</name>\n   <column>linenumber</column>\n   <foot>\n    <height>29</height>\n    <text>\n     <rect>\n      <x>10</x>\n      <y>5</y>\n      <width>185</width>\n      <height>17</height>\n     </rect>\n     <bottompad>14</bottompad>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>lotserial_title</column>\n     </data>\n    </text>\n    <text>\n     <rect>\n      <x>228</x>\n      <y>5</y>\n      <width>550</width>\n      <height>17</height>\n     </rect>\n     <bottompad>14</bottompad>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>lotserial</column>\n     </data>\n    </text>\n   </foot>\n  </group>\n  <group>\n   <name>line</name>\n   <column>linenumber</column>\n   <foot>\n    <height>82</height>\n    <label>\n     <rect>\n      <x>610</x>\n      <y>0</y>\n      <width>50</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Status:</string>\n    </label>\n    <field>\n     <rect>\n      <x>430</x>\n      <y>0</y>\n      <width>80</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>shipped</column>\n     </data>\n    </field>\n    <text>\n     <rect>\n      <x>70</x>\n      <y>55</y>\n      <width>665</width>\n      <height>17</height>\n     </rect>\n     <bottompad>14</bottompad>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>memo</column>\n     </data>\n    </text>\n    <field>\n     <rect>\n      <x>80</x>\n      <y>0</y>\n      <width>200</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>11</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>item_number</column>\n     </data>\n    </field>\n    <line>\n     <xstart>545</xstart>\n     <ystart>15</ystart>\n     <xend>595</xend>\n     <yend>15</yend>\n     <weight>1</weight>\n    </line>\n    <field>\n     <rect>\n      <x>290</x>\n      <y>0</y>\n      <width>40</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>uom_name</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>340</x>\n      <y>0</y>\n      <width>80</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>ordered</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>80</x>\n      <y>35</y>\n      <width>300</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>11</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>item_descrip2</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>670</x>\n      <y>0</y>\n      <width>50</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_status</column>\n     </data>\n    </field>\n    <barcode>\n     <rect>\n      <x>415</x>\n      <y>20</y>\n      <width>380</width>\n      <height>30</height>\n     </rect>\n     <format>128</format>\n     <maxlength>15</maxlength>\n     <right/>\n     <narrowBarWidth>0.01</narrowBarWidth>\n     <data>\n      <query>detail</query>\n      <column>item_barcode</column>\n     </data>\n    </barcode>\n    <field>\n     <rect>\n      <x>80</x>\n      <y>20</y>\n      <width>300</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>11</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>item_descrip1</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>5</x>\n      <y>0</y>\n      <width>42</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>11</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>linenumber</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>10</x>\n      <y>55</y>\n      <width>55</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Notes:</string>\n    </label>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>9</height>\n  </detail>\n </section>\n <section>\n  <name>packlist</name>\n  <detail>\n   <key>\n    <query>head</query>\n   </key>\n   <height>41</height>\n   <text>\n    <rect>\n     <x>5</x>\n     <y>10</y>\n     <width>625</width>\n     <height>17</height>\n    </rect>\n    <bottompad>14</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>head</query>\n     <column>shipcomments</column>\n    </data>\n   </text>\n   <line>\n    <xstart>5</xstart>\n    <ystart>5</ystart>\n    <xend>842</xend>\n    <yend>5</yend>\n    <weight>0</weight>\n   </line>\n  </detail>\n </section>\n <pgfoot>\n  <height>57</height>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>7</y>\n    <width>80</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>ordernumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>695</x>\n    <y>5</y>\n    <width>37</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>5</y>\n    <width>61</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Print Date: </string>\n  </label>\n  <field>\n   <rect>\n    <x>735</x>\n    <y>5</y>\n    <width>45</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>5</y>\n    <width>95</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>365</x>\n    <y>7</y>\n    <width>80</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>ordertype</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>94</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>45</y>\n    <width>160</width>\n    <height>35</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Completed By:</string>\n  </label>\n  <line>\n   <xstart>540</xstart>\n   <ystart>70</ystart>\n   <xend>790</xend>\n   <yend>70</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>415</x>\n    <y>45</y>\n    <width>165</width>\n    <height>30</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Checked By:</string>\n  </label>\n  <line>\n   <xstart>160</xstart>\n   <ystart>70</ystart>\n   <xend>407</xend>\n   <yend>70</yend>\n   <weight>0</weight>\n  </line>\n </rptfoot>\n</report>\n       Non-Hybrid version - driven only by shiphead_id parameter - Packing List showing the contents of a particular shipment - Shows RA# if SO is a replacement order for and RA      0       2014-10-06 19:47:03.678943
102564
 
327     PackingList     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Packing List</title>\n <name>PackingList</name>\n <description>Hybrid Packing List - use the shiphead_id if it is passed but use the order id and type if they're passed but not shiphead_id - Shows Lot/Serial</description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>25</topmargin>\n <bottommargin>25</bottommargin>\n <rightmargin>25</rightmargin>\n <leftmargin>25</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT COALESCE(shiphead_number::TEXT, 'Not Issued To Shipping') AS shiphead_number,\n       'S/O #:' AS ordertype,\n       cohead_number AS ordernumber,\n       formatsobarcode(cohead_id) AS order_barcode,\n       COALESCE(shiphead_shipvia, cohead_shipvia) AS shipvia,\n       cohead_shiptophone AS shiptophone,\n       cohead_custponumber,\n       formatDate(cohead_orderdate) AS orderdate,\n       cohead_shipcomments AS shipcomments,\n       cohead_billtoname AS billtoname,\n       formataddr(cohead_billtoaddress1,\n                  cohead_billtoaddress2,\n                  cohead_billtoaddress3,\n                  (cohead_billtocity || '  ' ||   cohead_billtostate || '  ' || cohead_billtozipcode),\n                  cohead_billtocountry) AS billing_address,\n       cohead_shiptoname AS shiptoname,\n       formataddr(cohead_shiptoaddress1,\n                  cohead_shiptoaddress2,\n                  cohead_shiptoaddress3,\n                  (cohead_shiptocity || '  ' ||   cohead_shiptostate || '  ' || cohead_shiptozipcode),\n                  cohead_shiptocountry) AS shipping_address,           \n       cust_number,\n       trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n       cntct_phone AS cust_phone,\n       terms_descrip\n  FROM cohead\n  JOIN custinfo ON (cohead_cust_id=cust_id)\n  JOIN terms ON (cohead_terms_id=terms_id)\n  LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n&lt;? if exists("shiphead_id") ?>\n   JOIN\n&lt;? else ?>\n   LEFT OUTER JOIN\n&lt;? endif ?>\n        shiphead ON (shiphead_order_type='SO') AND (shiphead_order_id=cohead_id)\nWHERE TRUE\n&lt;? if exists('shiphead_id') ?>\n    AND (shiphead_id=&lt;? value("shiphead_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("head_id") ?>\n   AND  (cohead_id=&lt;? value("head_id") ?>)\n   AND  (&lt;? value("head_type") ?>='SO')\n&lt;? endif ?>\n\n\n&lt;? if exists("MultiWhs") ?>\nUNION\nSELECT COALESCE(shiphead_number::TEXT, 'Not Issued To Shipping') AS shiphead_number,\n       'T/O #:' AS ordertype,\n       tohead_number AS ordernumber,\n       formattobarcode(tohead_id) AS order_barcode,\n       COALESCE(shiphead_shipvia, tohead_shipvia) AS shipvia,\n       tohead_destphone AS shiptophone,\n       TEXT(' ') AS cohead_custponumber,\n       formatDate(tohead_orderdate) AS orderdate,\n       tohead_shipcomments AS shipcomments,\n       tohead_srcname AS billtoname,\n       formataddr(tohead_srcaddress1,\n                  tohead_srcaddress2,\n                  tohead_srcaddress3,\n                  (tohead_srccity || ' ' || tohead_srcstate || ' ' || tohead_srcpostalcode),\n                  tohead_srccountry) AS billing_address,\n       tohead_destname AS shiptoname,\n       formataddr(tohead_destaddress1,\n                  tohead_destaddress2,\n                  tohead_destaddress3,\n                  (tohead_destcity || ' ' || tohead_deststate || ' ' || tohead_destpostalcode),\n                  tohead_destcountry) AS shipping_address,\n       'Transfer Order' AS cust_number,\n       tohead_destcntct_name AS cust_contact,\n       tohead_destphone AS cust_phone,\n       '' AS terms_descrip\n  FROM tohead \n&lt;? if exists("shiphead_id") ?>\n\tJOIN\n&lt;? else ?>\n\tLEFT OUTER JOIN\n&lt;? endif ?>\n       shiphead ON (shiphead_order_type='TO') AND (shiphead_order_id=tohead_id)\nWHERE TRUE\n&lt;? if exists('shiphead_id') ?>\n    AND (shiphead_id=&lt;? value("shiphead_id")?>)\n&lt;? endif ?>\n&lt;? if exists("head_id") ?>\n   AND (tohead_id=&lt;? value("head_id") ?>)\n   AND (&lt;? value("head_type") ?>='TO')\n&lt;? endif ?>\n&lt;? endif ?>;</sql>\n </querysource>\n <querysource>\n  <name>scheddate</name>\n  <sql>SELECT formatDate(MIN(orderitem_scheddate)) AS scheddate\n  FROM orderitem\n       &lt;? if exists("shiphead_id") ?>\n       JOIN shiphead ON ((orderitem_orderhead_type=shiphead_order_type)\n\t\t     AND (orderitem_orderhead_id=shiphead_order_id)\n\t\t     AND (shiphead_id=&lt;? value("shiphead_id")?>))\n       JOIN shipitem ON ((shiphead_id=shipitem_shiphead_id)\n\t\t     AND (shipitem_orderitem_id=orderitem_id))\n       &lt;? endif ?>\n WHERE ((orderitem_status &lt;> 'X')\n&lt;? if exists("head_id") ?>\n   AND  (orderitem_orderhead_type=&lt;? value("head_type") ?>)\n   AND  (orderitem_orderhead_id=&lt;? value("head_id") ?>)\n&lt;? endif ?>\n );</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT 1 AS groupby,\n       coitem_linenumber AS linenumber,\n       coitem_memo AS memo,\n       CASE WHEN (coitem_custpn != '') THEN coitem_custpn\n            ELSE item_number\n       END AS item_number,\n       formatitemsitebarcode(itemsite_id) AS item_barcode,\n       formatsoitembarcode(coitem_id) AS orderitem_barcode,\n       coitemuom.uom_name AS uom_name,\n       itemsellinguom(item_id) AS shipuom,\n       CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip1\n            ELSE item_descrip1\n       END AS item_descrip1,\n       CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip2\n            ELSE item_descrip2\n       END AS item_descrip2,\n       formatQty(coitem_qtyord) AS ordered,\n       formatQty(qtyAtShipping('SO', coitem_id)) AS atShipping,\n       getSoitemStatus(coitem_id) AS f_status\n  FROM coitem\n       JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n       JOIN item ON (item_id=itemsite_item_id)\n       JOIN uom invuom ON (invuom.uom_id = item_inv_uom_id)\n       JOIN uom coitemuom ON (coitemuom.uom_id = coitem_qty_uom_id) \n       LEFT OUTER JOIN itemalias ON (itemalias_item_id=item_id AND itemalias_number=coitem_custpn) \n WHERE ( (coitem_status &lt;> 'X')\n&lt;? if exists("shiphead_id") ?>\n   AND  (coitem_cohead_id IN (SELECT shiphead_order_id FROM shiphead\n\t\t\t      WHERE ((shiphead_id=&lt;? value("shiphead_id") ?>)\n\t\t\t        AND  (shiphead_order_type='SO'))))\n&lt;? endif ?>\n&lt;? if exists("head_id") ?>\n   AND  (&lt;? value("head_type") ?>='SO')\n   AND  (coitem_cohead_id=&lt;? value("head_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n)\n&lt;? if exists("MultiWhs") ?>\nUNION\nSELECT 2 AS groupby,\n       toitem_linenumber AS linenumber,\n       toitem_notes AS memo,\n       item_number,\n       formatitemsitebarcode(itemsite_id) AS item_barcode,\n       formattoitembarcode(toitem_id) AS orderitem_barcode,\n       uom_name,\n       itemsellinguom(item_id) AS shipuom,\n       item_descrip1,\n       item_descrip2,\n       formatQty(toitem_qty_ordered) AS ordered,\n       formatQty(qtyAtShipping('TO', toitem_id)) AS atShipping,\n       toitem_status AS f_status\n  FROM itemsite, item, toitem, tohead, uom\n WHERE ((toitem_item_id=item_id)\n   AND  (item_inv_uom_id=uom_id)\n   AND  (item_id=itemsite_item_id)\n   AND  (toitem_tohead_id=tohead_id)\n   AND  (toitem_status &lt;> 'X')\n   AND  (tohead_src_warehous_id=itemsite_warehous_id)\n&lt;? if exists("shiphead_id") ?>\n   AND  (toitem_tohead_id IN (SELECT shiphead_order_id FROM shiphead\n\t\t\t      WHERE ((shiphead_id=&lt;? value("shiphead_id") ?>)\n\t\t\t        AND  (shiphead_order_type='TO'))))\n&lt;? endif ?>\n&lt;? if exists("head_id") ?>\n   AND  (&lt;? value("head_type") ?>='TO')\n   AND  (toitem_tohead_id=&lt;? value("head_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n)\n&lt;? endif ?>\nORDER BY linenumber;</sql>\n </querysource>\n <querysource>\n  <name>logo</name>\n  <sql>SELECT image_data \nFROM image \nWHERE ((image_name='logo'));</sql>\n </querysource>\n <querysource>\n  <name>lotdetail</name>\n  <sql>SELECT * FROM \n(\n  SELECT\n    shiphead_number,\n    (cohead_number || '-' || coitem_linenumber) AS ordernumber,\n    item_number,\n    formatlotserialnumber(invdetail_ls_id) AS invdetail_lotserial,\n    SUM(invdetail_qty) * -1 AS lotqty,\n    SUM(invhist_invqty) as totalshipmentqty,\n    invhist_transtype,\n    formatdate(MAX(invhist_transdate)) AS invhistdate,\n    formatdate(MAX(shipitem_transdate)) AS shiptransdate\n  FROM shiphead\n    JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n    JOIN invhist ON (invhist_id=shipitem_invhist_id)\n    JOIN invdetail ON (invdetail_invhist_id=invhist_id)\n    JOIN cohead ON (cohead_id=shiphead_order_id)\n    JOIN coitem ON (coitem_id=shipitem_orderitem_id)\n    JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n    JOIN item ON (item_id=itemsite_item_id)\n  WHERE ( (shiphead_id = &lt;? value("shiphead_id") ?> )\n    AND ('SO'=shiphead_order_type) )\n  GROUP BY shiphead_number,cohead_number,item_number,invdetail_ls_id,\n    coitem_linenumber,invhist_transtype\n&lt;? if exists("MultiWhs") ?>\nUNION\n  SELECT\n    shiphead_number,\n    (tohead_number || '-' || toitem_linenumber) AS ordernumber,\n    item_number,\n    formatlotserialnumber(invdetail_ls_id) AS invdetail_lotserial,\n    SUM(invdetail_qty) * -1 AS lotqty,\n    SUM(invhist_invqty) as totalshipmentqty,\n    invhist_transtype,\n    formatdate(MAX(invhist_transdate)) AS invhistdate,\n    formatdate(MAX(shipitem_transdate)) AS shiptransdate\n  FROM shiphead\n    JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n    JOIN invhist ON (invhist_id=shipitem_invhist_id)\n    JOIN invdetail ON (invdetail_invhist_id=invhist_id)\n    JOIN tohead ON (tohead_id=shiphead_order_id)\n    JOIN toitem ON (toitem_id=shipitem_orderitem_id)\n    JOIN item ON (item_id=toitem_item_id)\n  WHERE ( (shiphead_id = &lt;? value("shiphead_id") ?> )\n    AND ('TO'=shiphead_order_type) )\n  GROUP BY shiphead_number,tohead_number,item_number,invdetail_ls_id,\n    toitem_linenumber,invhist_transtype\n&lt;? endif ?>\n) data\nORDER BY ordernumber;</sql>\n </querysource>\n <rpthead>\n  <height>451</height>\n  <image>\n   <rect>\n    <x>375</x>\n    <y>0</y>\n    <width>425</width>\n    <height>100</height>\n   </rect>\n   <mode>stretch</mode>\n   <data>\n    <query>logo</query>\n    <column>image_data</column>\n   </data>\n  </image>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>180</y>\n    <width>307</width>\n    <height>25</height>\n   </rect>\n   <format>3of9</format>\n   <maxlength>20</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </barcode>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>150</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>120</y>\n    <width>231</width>\n    <height>25</height>\n   </rect>\n   <format>128</format>\n   <maxlength>10</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>order_barcode</column>\n   </data>\n  </barcode>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>150</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>360</y>\n    <width>250</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>cust_contact</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>180</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer P/O #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>180</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>480</x>\n    <y>260</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shiptoname</column>\n   </data>\n  </field>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>150</y>\n    <width>177</width>\n    <height>25</height>\n   </rect>\n   <format>3of9</format>\n   <maxlength>10</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </barcode>\n  <text>\n   <rect>\n    <x>480</x>\n    <y>280</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>shipping_address</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>400</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Packed</string>\n  </label>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>400</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>120</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>ordertype</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>207</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>orderdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>260</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ship To:</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>227</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>scheddate</query>\n    <column>scheddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>360</y>\n    <width>95</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Attention:</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>390</ystart>\n   <xend>797</xend>\n   <yend>390</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>380</x>\n    <y>360</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Terms:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>260</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bill To:</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>400</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>430</ystart>\n   <xend>797</xend>\n   <yend>430</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>10</y>\n    <width>300</width>\n    <height>50</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>20</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>PACKING List</string>\n  </label>\n  <field>\n   <rect>\n    <x>480</x>\n    <y>227</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shipvia</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>90</x>\n    <y>280</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>billing_address</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>227</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ship Via:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>260</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>billtoname</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>90</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipment #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>457</x>\n    <y>360</y>\n    <width>320</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>terms_descrip</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>90</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shiphead_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>417</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>227</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sched. Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>120</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>ordernumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>207</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>227</x>\n    <y>400</y>\n    <width>40</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>457</x>\n    <y>400</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Verified</string>\n  </label>\n </rpthead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>groupby</column>\n   <foot>\n    <height>43</height>\n    <text>\n     <rect>\n      <x>50</x>\n      <y>5</y>\n      <width>625</width>\n      <height>17</height>\n     </rect>\n     <bottompad>14</bottompad>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>shipcomments</column>\n     </data>\n    </text>\n   </foot>\n  </group>\n  <group>\n   <name>lineitem</name>\n   <column>linenumber</column>\n   <foot>\n    <height>21</height>\n    <line>\n     <xstart>0</xstart>\n     <ystart>0</ystart>\n     <xend>837</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>81</height>\n   <field>\n    <rect>\n     <x>227</x>\n     <y>0</y>\n     <width>40</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>610</x>\n     <y>0</y>\n     <width>50</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_status</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>20</x>\n     <y>50</y>\n     <width>55</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Notes:</string>\n   </label>\n   <label>\n    <rect>\n     <x>550</x>\n     <y>0</y>\n     <width>50</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Status:</string>\n   </label>\n   <field>\n    <rect>\n     <x>280</x>\n     <y>0</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>20</x>\n     <y>0</y>\n     <width>200</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>90</x>\n     <y>50</y>\n     <width>560</width>\n     <height>17</height>\n    </rect>\n    <bottompad>14</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>memo</column>\n    </data>\n   </text>\n   <barcode>\n    <rect>\n     <x>507</x>\n     <y>30</y>\n     <width>280</width>\n     <height>30</height>\n    </rect>\n    <format>128</format>\n    <maxlength>15</maxlength>\n    <right/>\n    <narrowBarWidth>0.01</narrowBarWidth>\n    <data>\n     <query>detail</query>\n     <column>item_barcode</column>\n    </data>\n   </barcode>\n   <field>\n    <rect>\n     <x>20</x>\n     <y>35</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>20</x>\n     <y>20</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <line>\n    <xstart>470</xstart>\n    <ystart>20</ystart>\n    <xend>520</xend>\n    <yend>20</yend>\n    <weight>1</weight>\n   </line>\n   <field>\n    <rect>\n     <x>370</x>\n     <y>0</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>atShipping</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>lotdetail</name>\n  <group>\n   <name>lotdetail</name>\n   <column>ordernumber</column>\n   <head>\n    <height>48</height>\n    <label>\n     <rect>\n      <x>232</x>\n      <y>20</y>\n      <width>180</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Lot / Serial Number</string>\n    </label>\n    <label>\n     <rect>\n      <x>455</x>\n      <y>20</y>\n      <width>200</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Quantity</string>\n    </label>\n    <line>\n     <xstart>0</xstart>\n     <ystart>40</ystart>\n     <xend>797</xend>\n     <yend>40</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>25</x>\n      <y>20</y>\n      <width>200</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Item</string>\n    </label>\n    <label>\n     <rect>\n      <x>25</x>\n      <y>0</y>\n      <width>200</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Lot Detail Information:</string>\n    </label>\n   </head>\n   <foot>\n    <height>13</height>\n    <line>\n     <xstart>0</xstart>\n     <ystart>5</ystart>\n     <xend>797</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>lotdetail</query>\n   </key>\n   <height>23</height>\n   <field>\n    <rect>\n     <x>232</x>\n     <y>5</y>\n     <width>195</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>lotdetail</query>\n     <column>invdetail_lotserial</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>30</x>\n     <y>5</y>\n     <width>195</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>lotdetail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>457</x>\n     <y>5</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>lotdetail</query>\n     <column>lotqty</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>57</height>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>8</y>\n    <width>61</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Print Date: </string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>8</y>\n    <width>95</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>735</x>\n    <y>8</y>\n    <width>45</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>695</x>\n    <y>8</y>\n    <width>37</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>8</y>\n    <width>80</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>ordernumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>365</x>\n    <y>8</y>\n    <width>80</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>ordertype</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>57</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>10</y>\n    <width>160</width>\n    <height>35</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Completed By:</string>\n  </label>\n  <label>\n   <rect>\n    <x>417</x>\n    <y>10</y>\n    <width>165</width>\n    <height>30</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Checked By:</string>\n  </label>\n  <line>\n   <xstart>540</xstart>\n   <ystart>40</ystart>\n   <xend>790</xend>\n   <yend>40</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>160</xstart>\n   <ystart>40</ystart>\n   <xend>407</xend>\n   <yend>40</yend>\n   <weight>0</weight>\n  </line>\n </rptfoot>\n</report>\n     Hybrid Packing List - use the shiphead_id if it is passed but use the order id and type if they're passed but not shiphead_id - Shows Lot/Serial        0       2014-10-06 19:47:03.678943
102565
 
173     PackingListBatchEditList        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Packing List Batch Edit List</title>\n <name>PackingListBatchEditList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>packingListBatch</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>75</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>55</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Hold Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>115</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipment #</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Packing List Batch Edit List</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order #</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>55</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Printed</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ship Via</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>31</height>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Printed</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #</string>\n  </label>\n  <label>\n   <rect>\n    <x>115</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipment #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order #</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Hold Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ship Via</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>15</height>\n   <field>\n    <rect>\n     <x>115</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipment_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>675</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>pack_printed</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>220</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>order_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_holdtype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>160</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipvia</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>15</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102566
 
156     PartiallyShippedOrders  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Partially Shipped Orders</title>\n <name>PartiallyShippedOrders</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT CASE WHEN (cohead_holdtype IN ('P', 'C', 'R')) THEN -1\n            ELSE cohead_id\n       END AS _coheadid, cohead_id,\n       cohead_holdtype, cohead_number, cust_name,\n       CASE WHEN (cohead_holdtype='N') THEN &lt;? value(&quot;none&quot;) ?>\n            WHEN (cohead_holdtype='C') THEN &lt;? value(&quot;credit&quot;) ?>\n            WHEN (cohead_holdtype='S') THEN &lt;? value(&quot;ship&quot;) ?>\n            WHEN (cohead_holdtype='P') THEN &lt;? value(&quot;pack&quot;) ?>\n            WHEN (cohead_holdtype='R') THEN &lt;? value(&quot;return&quot;) ?>\n            ELSE &lt;? value(&quot;Other&quot;) ?>\n       END AS f_holdtype,\n       formatDate(cohead_orderdate) AS f_orderdate,\n       formatDate(MIN(coitem_scheddate)) AS f_scheddate,\n       formatDate(cohead_packdate) AS f_packdate,\n       &lt;? if exists(&quot;showPrices&quot;) ?>\n         formatExtPrice( SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                            (coitem_price / coitem_price_invuomratio) ) )\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_extprice,\n       SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n            (coitem_price / coitem_price_invuomratio) ) AS backlog,\n       MIN(coitem_scheddate) AS scheddate,\n       COALESCE(MIN(shipitem_id), 0) AS shipped\n  FROM cohead, itemsite, item, custinfo,\n       coitem LEFT OUTER JOIN shipitem ON (shipitem_orderitem_id=coitem_id) \n WHERE ( (coitem_cohead_id=cohead_id)\n   AND (cohead_cust_id=cust_id)\n   AND (coitem_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (coitem_status='O')\n   AND (cohead_id IN ( SELECT DISTINCT coitem_cohead_id\n                         FROM coitem\n                        WHERE (coitem_qtyshipped > 0) ))\n   AND (coitem_qtyshipped &lt; coitem_qtyord)\n   AND (coitem_scheddate BETWEEN &lt;? value(&quot;startDate&quot;) ?> AND &lt;? value(&quot;endDate&quot;) ?>)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n)\nGROUP BY cohead_id, cohead_number, cust_name, cohead_holdtype,\n         cohead_orderdate, cohead_packdate\nORDER BY scheddate, cohead_number;</sql>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT (warehous_code||'-'||warehous_descrip)\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists(&quot;showPrices&quot;) ?>\n         text('$ Amount')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_amount,\n       formatDate(&lt;? value(&quot;startDate&quot;) ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value(&quot;endDate&quot;) ?>, 'Latest') AS enddate;</sql>\n </querysource>\n <rpthead>\n  <height>205</height>\n  <label>\n   <rect>\n    <x>380</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>484</x>\n    <y>75</y>\n    <width>220</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>380</x>\n    <y>75</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>113</x>\n    <y>75</y>\n    <width>220</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>75</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>75</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scheduled</string>\n  </label>\n  <field>\n   <rect>\n    <x>484</x>\n    <y>95</y>\n    <width>220</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>200</ystart>\n   <xend>745</xend>\n   <yend>200</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>5</y>\n    <width>356</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Partially Shipped Orders</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Hold Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_amount</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Pack Date</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>8</height>\n </pghead>\n <pghead>\n  <height>28</height>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Hold Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scheduled</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Pack Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_amount</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>75</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_packdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>409</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_orderdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>75</x>\n     <y>0</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_extprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>325</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_holdtype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>495</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_scheddate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>65</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_number</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>19</height>\n  <field>\n   <rect>\n    <x>80</x>\n    <y>0</y>\n    <width>140</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>635</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>715</x>\n    <y>0</y>\n    <width>30</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102567
 
53      PendingBOMChanges       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Pending Bill of Material Changes</title>\n <name>PendingBOMChanges</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       uom_name,\n       item_descrip1,\n       item_descrip2,\n       CASE WHEN (&lt;? value("cutOffDate") ?> >= date('2099-12-31')) THEN text('Latest')\n            ELSE formatDate(&lt;? value("cutOffDate") ?>)\n       END AS cutoffdate\n  FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=&lt;? value("item_id") ?>);\n    </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT formatDate(bomitem_effective) as actiondate,\n       'Effective' AS action,\n       bomitem_seqnumber, item_number, uom_name,\n       item_descrip1, item_descrip2, uom_name,\n       formatQty(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyfxd)) AS qtyfxd,\n       formatQtyPer(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper)) AS qtyper,\n       formatScrap(bomitem_scrap) AS scrap,\n       formatQtyPer(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd + bomitem_qtyper) * (1 + bomitem_scrap))) AS qtyreq,\n       formatDate(bomitem_effective, 'Always') AS effective,\n       formatDate(bomitem_expires, 'Never') AS expires,\n       formatBoolYN(bomitem_createwo) AS createchild,\n       CASE WHEN (bomitem_issuemethod='S') THEN 'Push'\n            WHEN (bomitem_issuemethod='L') THEN 'Pull'\n            WHEN (bomitem_issuemethod='M') THEN 'Mixed'\n            ELSE 'Special'\n       END AS issuemethod\n  FROM bomitem(&lt;? value("item_id") ?>,&lt;? value("revision_id") ?>), item, uom\n WHERE ((bomitem_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (bomitem_effective BETWEEN CURRENT_DATE AND &lt;? value("cutOffDate") ?>)\n)\nUNION\nSELECT formatDate(bomitem_expires) as actiondate,\n       'Expires' AS action,\n       bomitem_seqnumber, item_number, uom_name,\n       item_descrip1, item_descrip2, uom_name,\n       formatQty(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyfxd)) AS qtyfxd,\n       formatQtyPer(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper)) AS qtyper,\n       formatScrap(bomitem_scrap) AS scrap,\n       formatQtyPer(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper + (1 * bomitem_scrap))) AS qtyreq,\n       formatDate(bomitem_effective, 'Always') AS effective,\n       formatDate(bomitem_expires, 'Never') AS expires,\n       formatBoolYN(bomitem_createwo) AS createchild,\n       CASE WHEN (bomitem_issuemethod='S') THEN 'Push'\n            WHEN (bomitem_issuemethod='L') THEN 'Pull'\n            WHEN (bomitem_issuemethod='M') THEN 'Mixed'\n            ELSE 'Special'\n       END AS issuemethod\nFROM bomitem(&lt;? value("item_id") ?>,&lt;? value("revision_id") ?>), item, uom\nWHERE ((bomitem_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (bomitem_expires BETWEEN CURRENT_DATE AND &lt;? value("cutOffDate") ?>)\n)\nORDER BY action, actiondate, bomitem_seqnumber;\n    </sql>\n </querysource>\n <querysource>\n  <name>bomhead</name>\n  <sql>SELECT bomhead_docnum, bomhead_revision, formatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=&lt;? value("item_id") ?>)\n  AND  (bomhead_rev_id=&lt;? value("revision_id") ?>));</sql>\n </querysource>\n <rpthead>\n  <height>234</height>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>120</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Required</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>140</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>10</y>\n    <width>405</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Pending Bill of Materials Changes</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>55</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Cutoff Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>f_revisiondate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>380</x>\n    <y>140</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>430</x>\n    <y>55</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cutoffdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>254</x>\n    <y>215</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>254</x>\n    <y>200</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>200</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>380</x>\n    <y>160</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision:</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>160</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_revision</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>380</x>\n    <y>120</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Document #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>160</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Action</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>484</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Per</string>\n  </label>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_docnum</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>213</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Fxd. Qty.</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Required</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Action</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>254</x>\n    <y>0</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>484</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>254</x>\n    <y>15</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>14</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Fxd. Qty.</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>53</height>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>actiondate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>action</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createchild</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>254</x>\n     <y>30</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>675</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>issuemethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>254</x>\n     <y>0</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>254</x>\n     <y>15</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>675</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyreq</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>560</x>\n     <y>0</y>\n     <width>38</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>484</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>204</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bomitem_seqnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>485</x>\n     <y>14</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyfxd</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102568
 
91      PendingWOMaterialAvailability   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Pending W/O Material Availability</title>\n <name>PendingWOMaterialAvailability</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number, item_descrip1, item_descrip2,\n       &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse\n  FROM item\nWHERE (item_id=&lt;? value("item_id") ?>);</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>pendingAvailability</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>234</height>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>140</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Pending W/O Material Availability</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>160</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>160</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>290</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>203</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>203</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Alloc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Available</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>198</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>213</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>100</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Number:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Pend. Alloc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>120</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Description:</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>203</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Level</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>115</x>\n    <y>14</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Pend. Alloc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Available</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>-1</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>290</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>115</x>\n    <y>-1</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Alloc.</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>-1</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Level</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>41</height>\n   <field>\n    <rect>\n     <x>290</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>405</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>pendalloc</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n   <line>\n    <xstart>6</xstart>\n    <ystart>32</ystart>\n    <xend>745</xend>\n    <yend>32</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>-1</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qoh</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>15</y>\n     <width>615</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>totalalloc</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>totalavail</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>-1</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bomitem_seqnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>15</x>\n     <y>-1</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bomdata_bomwork_level</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102569
 
81      PickList        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Pick List</title>\n <name>PickList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>28</bottommargin>\n <rightmargin>0</rightmargin>\n <leftmargin>0</leftmargin>\n <querysource>\n  <name>Head</name>\n  <sql>SELECT formatWoNumber(wo_id) AS wonumber, wo_prodnotes,\n                item_number, uom_name, item_descrip1, item_descrip2,\n                warehous_code, formatQty(wo_qtyord) AS qtyord,\n                formatQty(wo_qtyrcv) AS qtyrcv,\n                formatDate(wo_startdate) AS startdate,\n                formatDate(wo_duedate) AS duedate\n         FROM wo, itemsite, item, whsinfo, uom\n         WHERE ((wo_itemsite_id=itemsite_id)\n          AND (itemsite_item_id=item_id)\n          AND (item_inv_uom_id=uom_id)\n          AND (itemsite_warehous_id=warehous_id)\n          AND (wo_id=%1))\n    </sql>\n </querysource>\n <querysource>\n  <name>Detail</name>\n  <sql>SELECT item_number,\n       uom_name,\n       item_descrip1,\n       item_descrip2,\n       formatQty(womatl_qtyreq) AS qtyreq,\n       formatQty(womatl_qtyiss) AS qtyiss,\n       formatQty(noNeg(womatl_qtyreq - womatl_qtyiss)) AS qtybalance,\n       itemsite_location,\n       CASE WHEN (womatl_issuemethod='S') THEN text('Push')\n            WHEN (womatl_issuemethod='L') THEN text('Pull')\n            WHEN (womatl_issuemethod='M') THEN text('Mixed')\n            ELSE text(womatl_issuemethod)\n       END AS f_issuemethod\n  FROM womatl, itemsite, item, uom\n WHERE ((item_picklist)\n   AND (womatl_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (womatl_uom_id=uom_id)\n   AND (womatl_wo_id=%1) );\n    </sql>\n </querysource>\n <rpthead>\n  <height>246</height>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>225</y>\n    <width>300</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <field>\n   <rect>\n    <x>196</x>\n    <y>140</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>qtyord</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>653</x>\n    <y>65</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>wonumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>196</x>\n    <y>102</y>\n    <width>300</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>84</y>\n    <width>154</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>653</x>\n    <y>102</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>653</x>\n    <y>84</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>65</y>\n    <width>154</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Work Order #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>204</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. To Pick</string>\n  </label>\n  <field>\n   <rect>\n    <x>653</x>\n    <y>121</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>duedate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>121</y>\n    <width>154</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Due Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>196</x>\n    <y>65</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>37</x>\n    <y>121</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>37</x>\n    <y>65</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <label>\n   <rect>\n    <x>37</x>\n    <y>158</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Qty. Received:</string>\n  </label>\n  <label>\n   <rect>\n    <x>578</x>\n    <y>18</y>\n    <width>204</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>20</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Pick List</string>\n  </label>\n  <label>\n   <rect>\n    <x>681</x>\n    <y>204</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Picked</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>205</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Location</string>\n  </label>\n  <label>\n   <rect>\n    <x>354</x>\n    <y>204</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Required</string>\n  </label>\n  <field>\n   <rect>\n    <x>196</x>\n    <y>158</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>qtyrcv</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>196</x>\n    <y>84</y>\n    <width>300</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>195</x>\n    <y>120</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>warehous_code</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>220</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>204</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <line>\n   <xstart>10</xstart>\n   <ystart>240</ystart>\n   <xend>822</xend>\n   <yend>240</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>37</x>\n    <y>140</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Qty. Ordered:</string>\n  </label>\n  <label>\n   <rect>\n    <x>457</x>\n    <y>204</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Issued</string>\n  </label>\n  <label>\n   <rect>\n    <x>355</x>\n    <y>220</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>102</y>\n    <width>154</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>47</height>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>20</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>5</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <line>\n   <xstart>10</xstart>\n   <ystart>40</ystart>\n   <xend>822</xend>\n   <yend>40</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>5</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Location</string>\n  </label>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>20</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Picked</string>\n  </label>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>5</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Issued</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>5</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Required</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>25</y>\n    <width>300</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>545</x>\n    <y>5</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. To Pick</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>Detail</query>\n   </key>\n   <height>61</height>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>0</y>\n     <width>130</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>itemsite_location</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>45</x>\n     <y>0</y>\n     <width>160</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>680</xstart>\n    <ystart>30</ystart>\n    <xend>780</xend>\n    <yend>30</yend>\n    <weight>1</weight>\n   </line>\n   <field>\n    <rect>\n     <x>350</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>qtyreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>457</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>qtyiss</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>350</x>\n     <y>20</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>46</x>\n     <y>37</y>\n     <width>300</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>459</x>\n     <y>20</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>f_issuemethod</column>\n    </data>\n   </field>\n   <line>\n    <xstart>10</xstart>\n    <ystart>55</ystart>\n    <xend>822</xend>\n    <yend>55</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>569</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>qtybalance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>45</x>\n     <y>20</y>\n     <width>300</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <rptfoot>\n  <height>57</height>\n  <label>\n   <rect>\n    <x>46</x>\n    <y>9</y>\n    <width>139</width>\n    <height>22</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>48</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Production Notes:</string>\n  </label>\n  <text>\n   <rect>\n    <x>46</x>\n    <y>28</y>\n    <width>746</width>\n    <height>22</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>48</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Head</query>\n    <column>wo_prodnotes</column>\n   </data>\n  </text>\n </rptfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102570
 
369     PickListWOShowLocations \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Pick List WO Show Locations</title>\n <name>PickListWOShowLocations</name>\n <description>This WO Pick List Shows All Locations and Lots for Each Requirement</description>\n <parameter default="565" active="true" listtype="static" type="integer" name="wo_id" >\n  <description></description>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>28</bottommargin>\n <rightmargin>33</rightmargin>\n <leftmargin>33</leftmargin>\n <querysource>\n  <name>Head</name>\n  <sql>SELECT formatWoNumber(wo_id) AS wonumber, wo_prodnotes,\n                item_number, uom_name, item_descrip1, item_descrip2,\n                warehous_code, formatQty(wo_qtyord) AS qtyord,\n                formatQty(wo_qtyrcv) AS qtyrcv,\n                formatDate(wo_startdate) AS startdate,\n                formatDate(wo_duedate) AS duedate\n         FROM wo, itemsite, item, whsinfo, uom\n         WHERE ((wo_itemsite_id=itemsite_id)\n          AND (itemsite_item_id=item_id)\n          AND (item_inv_uom_id=uom_id)\n          AND (itemsite_warehous_id=warehous_id)\n          AND (wo_id=%1))\n    </sql>\n </querysource>\n <querysource>\n  <name>Detail</name>\n  <sql>SELECT\n     warehous_code, \n     wo_number,\n     womatl_id,\n     item_number,\n     item_descrip1,\n     item_descrip2, \n     uom_name,\n--   itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id) * womatl_qtyreq AS required_qty,\n     womatl_qtyreq AS required_qty,\n--   formatqty(itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id) * womatl_qtyreq) AS required_fmt,\n     formatqty(womatl_qtyreq) AS required_fmt,\n--   itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id) * womatl_qtyiss AS issued_qty,\n     womatl_qtyiss AS issued_qty,\n     formatqty(womatl_qtyiss) AS issued_fmt,\n--   (itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id) * womatl_qtyreq) - \n               (itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id)  * womatl_qtyiss) AS pick_qty,\n     womatl_qtyreq - womatl_qtyiss AS pick_qty,   \n    formatqty(womatl_qtyreq - womatl_qtyiss) AS pick_fmt,\n     CASE WHEN (womatl_issuemethod='S') THEN text('Push')\n            WHEN (womatl_issuemethod='L') THEN text('Pull')\n            WHEN (womatl_issuemethod='M') THEN text('Mixed')\n            ELSE text(womatl_issuemethod)\n     END AS f_issuemethod,\n     location_aisle || '-' || location_rack || '-' || location_bin || '-' || location_name  AS location_name,\n     formatlotserialnumber(itemloc_ls_id),\n--     itemloc_lotserial,\n     itemsite_location_comments AS location_comment,\n     itemloc_qty AS location_qty_qty,\n     itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id) * itemloc_qty AS loc_issue_uom_qty,\n     formatqty(itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id) * itemloc_qty) AS loc_issue_uom_fmt,\n     CASE WHEN itemloc_expiration = '1970-01-01' THEN text ('N/A')\n          WHEN itemloc_expiration = '2100-01-01' THEN text ('N/A')\n          ELSE CAST(formatdate(itemloc_expiration) AS text)\n     END AS expiration \n\nFROM\n\n     item, uom, whsinfo, womatl, wo, itemsite\n     LEFT OUTER JOIN itemloc  ON (itemloc_itemsite_id = itemsite_id)\n     LEFT OUTER JOIN location ON (itemloc_location_id = location_id)\n\n\nWHERE\n     itemsite_item_id = item_id\n     and \n     itemsite_warehous_id = warehous_id\n     and\n     womatl_uom_id = uom_id\n     and\n     itemsite_id = womatl_itemsite_id\n     and\n     womatl_wo_id = wo_id\n     and\n     wo_id = &lt;? value("wo_id") ?>\nORDER BY wo_number, womatl_id, item_number, itemloc_expiration, location_name;</sql>\n </querysource>\n <rpthead>\n  <height>188</height>\n  <field>\n   <rect>\n    <x>196</x>\n    <y>5</y>\n    <width>150</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>wonumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>196</x>\n    <y>140</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>qtyord</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>489</x>\n    <y>100</y>\n    <width>154</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>37</x>\n    <y>121</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>195</x>\n    <y>120</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>warehous_code</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>37</x>\n    <y>5</y>\n    <width>154</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Work Order #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>196</x>\n    <y>102</y>\n    <width>300</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>649</x>\n    <y>100</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>196</x>\n    <y>65</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>649</x>\n    <y>120</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>duedate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>649</x>\n    <y>80</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>196</x>\n    <y>84</y>\n    <width>300</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>489</x>\n    <y>120</y>\n    <width>154</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Due Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>196</x>\n    <y>158</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>Head</query>\n    <column>qtyrcv</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>489</x>\n    <y>80</y>\n    <width>154</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>37</x>\n    <y>140</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Qty. Ordered:</string>\n  </label>\n  <label>\n   <rect>\n    <x>37</x>\n    <y>158</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Qty. Received:</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>5</y>\n    <width>204</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>20</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>WO Pick List</string>\n  </label>\n  <label>\n   <rect>\n    <x>37</x>\n    <y>65</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>6</height>\n </pghead>\n <section>\n  <name>detail_group</name>\n  <group>\n   <name>detail_group</name>\n   <column>womatl_id</column>\n   <head>\n    <height>133</height>\n    <field>\n     <rect>\n      <x>208</x>\n      <y>40</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>Detail</query>\n      <column>required_fmt</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>330</x>\n      <y>55</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>Detail</query>\n      <column>f_issuemethod</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>330</x>\n      <y>15</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Issue Method</string>\n    </label>\n    <label>\n     <rect>\n      <x>330</x>\n      <y>0</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Qty. Issued</string>\n    </label>\n    <label>\n     <rect>\n      <x>465</x>\n      <y>15</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Qty. To Pick</string>\n    </label>\n    <line>\n     <xstart>10</xstart>\n     <ystart>35</ystart>\n     <xend>822</xend>\n     <yend>35</yend>\n     <weight>2</weight>\n    </line>\n    <label>\n     <rect>\n      <x>208</x>\n      <y>0</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Qty. Required</string>\n    </label>\n    <field>\n     <rect>\n      <x>575</x>\n      <y>40</y>\n      <width>45</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Detail</query>\n      <column>uom_name</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>660</x>\n      <y>15</y>\n      <width>120</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total Qty. Picked</string>\n    </label>\n    <field>\n     <rect>\n      <x>469</x>\n      <y>75</y>\n      <width>300</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Detail</query>\n      <column>location_comment</column>\n     </data>\n    </field>\n    <line>\n     <xstart>80</xstart>\n     <ystart>100</ystart>\n     <xend>817</xend>\n     <yend>100</yend>\n     <weight>1</weight>\n    </line>\n    <label>\n     <rect>\n      <x>240</x>\n      <y>100</y>\n      <width>125</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Lot</string>\n    </label>\n    <label>\n     <rect>\n      <x>37</x>\n      <y>0</y>\n      <width>150</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Item Number</string>\n    </label>\n    <field>\n     <rect>\n      <x>469</x>\n      <y>40</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>Detail</query>\n      <column>pick_fmt</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>37</x>\n      <y>60</y>\n      <width>195</width>\n      <height>14</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Detail</query>\n      <column>item_descrip1</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>37</x>\n      <y>40</y>\n      <width>160</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Detail</query>\n      <column>item_number</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>305</x>\n      <y>75</y>\n      <width>125</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Location Coment;</string>\n    </label>\n    <label>\n     <rect>\n      <x>540</x>\n      <y>104</y>\n      <width>90</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Expiration</string>\n    </label>\n    <label>\n     <rect>\n      <x>37</x>\n      <y>15</y>\n      <width>300</width>\n      <height>14</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Item Description</string>\n    </label>\n    <field>\n     <rect>\n      <x>208</x>\n      <y>55</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>Detail</query>\n      <column>uom_name</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>37</x>\n      <y>75</y>\n      <width>300</width>\n      <height>14</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Detail</query>\n      <column>item_descrip2</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>208</x>\n      <y>15</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Issue UOM</string>\n    </label>\n    <field>\n     <rect>\n      <x>330</x>\n      <y>40</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>Detail</query>\n      <column>issued_fmt</column>\n     </data>\n    </field>\n    <line>\n     <xstart>680</xstart>\n     <ystart>57</ystart>\n     <xend>780</xend>\n     <yend>57</yend>\n     <weight>1</weight>\n    </line>\n    <label>\n     <rect>\n      <x>405</x>\n      <y>104</y>\n      <width>125</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Qty / UOM</string>\n    </label>\n    <label>\n     <rect>\n      <x>645</x>\n      <y>104</y>\n      <width>140</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Loc / Lot Qty Picked</string>\n    </label>\n    <label>\n     <rect>\n      <x>80</x>\n      <y>100</y>\n      <width>125</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Location</string>\n    </label>\n   </head>\n   <foot>\n    <height>36</height>\n    <line>\n     <xstart>75</xstart>\n     <ystart>25</ystart>\n     <xend>825</xend>\n     <yend>25</yend>\n     <weight>1</weight>\n    </line>\n    <line>\n     <xstart>75</xstart>\n     <ystart>5</ystart>\n     <xend>822</xend>\n     <yend>5</yend>\n     <weight>1</weight>\n    </line>\n    <field>\n     <rect>\n      <x>465</x>\n      <y>5</y>\n      <width>50</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>Detail</query>\n      <column>uom_name</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>355</x>\n      <y>5</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>Detail</query>\n      <column>loc_issue_uom_qty</column>\n     </data>\n     <tracktotal subtotal="true" builtin="true" >qty</tracktotal>\n    </field>\n    <label>\n     <rect>\n      <x>185</x>\n      <y>5</y>\n      <width>165</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total All Lot/Locations:</string>\n    </label>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>Detail</query>\n   </key>\n   <height>21</height>\n   <field>\n    <rect>\n     <x>75</x>\n     <y>0</y>\n     <width>115</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>location_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>555</x>\n     <y>0</y>\n     <width>75</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>expiration</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>465</x>\n     <y>0</y>\n     <width>50</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <line>\n    <xstart>690</xstart>\n    <ystart>17</ystart>\n    <xend>790</xend>\n    <yend>17</yend>\n    <weight>1</weight>\n   </line>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>0</y>\n     <width>115</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>formatlotserialnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>355</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>loc_issue_uom_fmt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <rptfoot>\n  <height>57</height>\n  <text>\n   <rect>\n    <x>110</x>\n    <y>30</y>\n    <width>480</width>\n    <height>22</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>48</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Head</query>\n    <column>wo_prodnotes</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>10</y>\n    <width>194</width>\n    <height>22</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>48</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Production Notes:</string>\n  </label>\n </rptfoot>\n</report>\n  This WO Pick List Shows All Locations and Lots for Each Requirement     0       2014-10-06 19:47:03.678943
102571
 
329     PickingListSOClosedLines        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Picking List - SO</title>\n <name>PickingListSOClosedLines</name>\n <description>Shows Closed Lines -- With Barcodes formatitemsitebarcode(itemsite_id) -- SO # barcoded formatsobarcode(cohead_id) -- With Logo, place logo graphic in images DB with name "logo"\n</description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>25</topmargin>\n <bottommargin>25</bottommargin>\n <rightmargin>25</rightmargin>\n <leftmargin>25</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT cust_number,\n       formatsobarcode(cohead_id) AS order_barcode,\n       formataddr(cohead_billtoaddress1,\n                  cohead_billtoaddress2,\n                  cohead_billtoaddress3,\n                  (cohead_billtocity || '  ' ||   cohead_billtostate || '  ' || cohead_billtozipcode),\n                  cohead_billtocountry) AS billing_address, \n       formataddr(cohead_shiptoaddress1,\n                  cohead_shiptoaddress2,\n                  cohead_shiptoaddress3,\n                  (cohead_shiptocity || '  ' ||   cohead_shiptostate || '  ' || cohead_shiptozipcode),\n                  cohead_shiptocountry) AS shipping_address,           \n       trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n       cohead_billtoname,\n       cohead_billtoaddress1,\n       cohead_billtoaddress2,\n       cohead_billtoaddress3,\n       (cohead_billtocity || '  ' || cohead_billtostate || '  ' || cohead_billtozipcode) AS billtocitystatezip,\n       cntct_phone AS cust_phone,\n       cohead_shiptoname,\n       cohead_shiptoaddress1,\n       cohead_shiptoaddress2,\n       cohead_shiptoaddress3,\n       (cohead_shiptocity || '  ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n       cohead_number,\n       cohead_shipvia,\n       cohead_shiptophone,\n       cohead_custponumber,\n       formatDate(cohead_orderdate) AS orderdate,\n       formatDate(getSoSchedDate(cohead_id)) AS scheddate,\n       cohead_shipcomments, \n       terms_descrip\n  FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n              JOIN terms ON (cohead_terms_id=terms_id)\n              LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n  WHERE (cohead_id=&lt;? value("sohead_id") ?>);\n  </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT 1 AS groupby,\n       coitem_linenumber AS sortline,\n       coitem_subnumber AS sortsubline,\n       formatsolinenumber(coitem_id) AS linenumber,\n       coitem_memo,\n       item_number,\n       formatitemsitebarcode(itemsite_id) AS item_barcode,\n       coitemuom.uom_name AS uom_name,\n       itemsellinguom(item_id) AS shipuom,\n       item_descrip1,\n       item_descrip2,\n       formatQty(coitem_qtyord) AS ordered,\n       CASE WHEN (coitem_qtyreserved > 0.0)\n            THEN formatQty(coitem_qtyreserved)\n            ELSE NULL\n       END AS reserved,\n       CASE WHEN ((coitem_qtyshipped - coitem_qtyreturned) > 0.0)\n            THEN formatQty(coitem_qtyshipped - coitem_qtyreturned)\n            ELSE NULL\n       END AS shipped,\n       CASE WHEN (fetchMetricBool('RequireSOReservations'))\n            THEN formatQty(coitem_qtyreserved)\n            ELSE formatQty(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id)))\n       END AS balance,\n       CASE WHEN (qtyAtShipping('SO', coitem_id) > 0.0)\n            THEN formatQty(qtyAtShipping('SO', coitem_id))\n            ELSE NULL\n       END AS atShipping,\n       getSoitemStatus(coitem_id) AS f_status\n   FROM coitem JOIN itemsite ON (itemsite_id = coitem_itemsite_id)\n               JOIN item ON (item_id = itemsite_item_id)\n               JOIN whsinfo ON (warehous_id = itemsite_warehous_id)\n               JOIN uom invuom ON (invuom.uom_id = item_inv_uom_id)\n               JOIN uom coitemuom ON (coitemuom.uom_id = coitem_qty_uom_id) \n WHERE ( (coitem_cohead_id=&lt;? value("sohead_id") ?>)\n   AND   (coitem_status &lt;> 'X')\n   AND   (coitem_status &lt;> 'C')\n   AND   (item_type != 'K')\n   AND   ( (fetchMetricBool('RequireSOReservations') AND (coitem_qtyreserved > 0.0)) OR\n           (NOT fetchMetricBool('RequireSOReservations')) )\n&lt;? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n)\nORDER BY sortline, sortsubline;</sql>\n </querysource>\n <querysource>\n  <name>logo</name>\n  <sql>SELECT image_data \nFROM image \nWHERE ((image_name='logo'));</sql>\n </querysource>\n <querysource>\n  <name>site</name>\n  <sql>&lt;? if exists("warehous_id") ?>\n  SELECT warehous_code AS f_site\n  FROM whsinfo\n  WHERE (warehous_id=&lt;? value("warehous_id") ?>);\n&lt;? else ?>\n  SELECT text('') AS f_site;\n&lt;? endif ?>\n</sql>\n </querysource>\n <rpthead>\n  <height>477</height>\n  <image>\n   <rect>\n    <x>375</x>\n    <y>0</y>\n    <width>425</width>\n    <height>85</height>\n   </rect>\n   <mode>stretch</mode>\n   <data>\n    <query>logo</query>\n    <column>image_data</column>\n   </data>\n  </image>\n  <text>\n   <rect>\n    <x>465</x>\n    <y>280</y>\n    <width>305</width>\n    <height>20</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>shipping_address</column>\n   </data>\n  </text>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>400</y>\n    <width>252</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>cust_contact</column>\n   </data>\n  </field>\n  <line>\n   <xstart>25</xstart>\n   <ystart>425</ystart>\n   <xend>822</xend>\n   <yend>425</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>155</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>425</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reserved</string>\n  </label>\n  <text>\n   <rect>\n    <x>75</x>\n    <y>280</y>\n    <width>295</width>\n    <height>20</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>billing_address</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>425</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>At Shipping</string>\n  </label>\n  <label>\n   <rect>\n    <x>232</x>\n    <y>425</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>95</y>\n    <width>232</width>\n    <height>25</height>\n   </rect>\n   <format>128</format>\n   <maxlength>10</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>order_barcode</column>\n   </data>\n  </barcode>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>425</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>195</y>\n    <width>102</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>S/O Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>465</x>\n    <y>260</y>\n    <width>305</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoname</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>745</x>\n    <y>425</y>\n    <width>55</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Packed</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>95</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>432</x>\n    <y>215</y>\n    <width>331</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shipvia</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>125</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>260</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ship To:</string>\n  </label>\n  <field>\n   <rect>\n    <x>75</x>\n    <y>260</y>\n    <width>305</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_billtoname</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>175</x>\n    <y>195</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>orderdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>215</y>\n    <width>121</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sched. Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>125</y>\n    <width>122</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>545</x>\n    <y>425</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>155</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer P/O #:</string>\n  </label>\n  <line>\n   <xstart>25</xstart>\n   <ystart>465</ystart>\n   <xend>822</xend>\n   <yend>465</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>175</x>\n    <y>215</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>scheddate</column>\n   </data>\n  </field>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>160</y>\n    <width>307</width>\n    <height>25</height>\n   </rect>\n   <format>3of9</format>\n   <maxlength>20</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </barcode>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>330</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>20</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Picking List (SO)</string>\n  </label>\n  <field>\n   <rect>\n    <x>467</x>\n    <y>400</y>\n    <width>320</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>terms_descrip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>400</y>\n    <width>95</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Attention:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>260</y>\n    <width>65</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bill To:</string>\n  </label>\n  <label>\n   <rect>\n    <x>365</x>\n    <y>400</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Terms:</string>\n  </label>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>130</y>\n    <width>177</width>\n    <height>25</height>\n   </rect>\n   <format>3of9</format>\n   <maxlength>10</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </barcode>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>425</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>442</y>\n    <width>95</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>215</y>\n    <width>102</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ship Via:</string>\n  </label>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>65</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>site</query>\n    <column>f_site</column>\n   </data>\n  </field>\n </rpthead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>groupby</column>\n   <foot>\n    <height>73</height>\n    <text>\n     <rect>\n      <x>50</x>\n      <y>5</y>\n      <width>625</width>\n      <height>17</height>\n     </rect>\n     <bottompad>14</bottompad>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>cohead_shipcomments</column>\n     </data>\n    </text>\n   </foot>\n  </group>\n  <group>\n   <name>lineitem</name>\n   <column>linenumber</column>\n   <foot>\n    <height>28</height>\n    <line>\n     <xstart>5</xstart>\n     <ystart>5</ystart>\n     <xend>842</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>156</height>\n   <label>\n    <rect>\n     <x>565</x>\n     <y>103</y>\n     <width>60</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <string>Status:</string>\n   </label>\n   <line>\n    <xstart>415</xstart>\n    <ystart>80</ystart>\n    <xend>500</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <line>\n    <xstart>305</xstart>\n    <ystart>110</ystart>\n    <xend>395</xend>\n    <yend>110</yend>\n    <weight>0</weight>\n   </line>\n   <line>\n    <xstart>80</xstart>\n    <ystart>80</ystart>\n    <xend>170</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <line>\n    <xstart>745</xstart>\n    <ystart>15</ystart>\n    <xend>795</xend>\n    <yend>15</yend>\n    <weight>1</weight>\n   </line>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>200</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>100</x>\n     <y>120</y>\n     <width>700</width>\n     <height>17</height>\n    </rect>\n    <bottompad>14</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>coitem_memo</column>\n    </data>\n   </text>\n   <line>\n    <xstart>415</xstart>\n    <ystart>110</ystart>\n    <xend>500</xend>\n    <yend>110</yend>\n    <weight>0</weight>\n   </line>\n   <line>\n    <xstart>305</xstart>\n    <ystart>80</ystart>\n    <xend>395</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>630</x>\n     <y>103</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_status</column>\n    </data>\n   </field>\n   <barcode>\n    <rect>\n     <x>365</x>\n     <y>30</y>\n     <width>467</width>\n     <height>35</height>\n    </rect>\n    <format>128</format>\n    <maxlength>15</maxlength>\n    <left/>\n    <narrowBarWidth>0.01</narrowBarWidth>\n    <data>\n     <query>detail</query>\n     <column>item_barcode</column>\n    </data>\n   </barcode>\n   <label>\n    <rect>\n     <x>20</x>\n     <y>120</y>\n     <width>75</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Notes:</string>\n   </label>\n   <label>\n    <rect>\n     <x>25</x>\n     <y>65</y>\n     <width>47</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Carton:</string>\n   </label>\n   <line>\n    <xstart>190</xstart>\n    <ystart>80</ystart>\n    <xend>280</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>balance</column>\n    </data>\n   </field>\n   <line>\n    <xstart>80</xstart>\n    <ystart>110</ystart>\n    <xend>170</xend>\n    <yend>110</yend>\n    <weight>0</weight>\n   </line>\n   <line>\n    <xstart>632</xstart>\n    <ystart>80</ystart>\n    <xend>720</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <label>\n    <rect>\n     <x>25</x>\n     <y>95</y>\n     <width>47</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Qty:</string>\n   </label>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>40</y>\n     <width>295</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>reserved</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>227</x>\n     <y>0</y>\n     <width>85</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipped</column>\n    </data>\n   </field>\n   <line>\n    <xstart>190</xstart>\n    <ystart>110</ystart>\n    <xend>280</xend>\n    <yend>110</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>20</y>\n     <width>295</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>635</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>atshipping</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>565</x>\n     <y>70</y>\n     <width>60</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <string>Batch #:</string>\n   </label>\n   <field>\n    <rect>\n     <x>630</x>\n     <y>88</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>565</x>\n     <y>88</y>\n     <width>60</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <string>UOM:</string>\n   </label>\n  </detail>\n </section>\n <pgfoot>\n  <height>57</height>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>5</y>\n    <width>62</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Print Date: </string>\n  </label>\n  <label>\n   <rect>\n    <x>695</x>\n    <y>5</y>\n    <width>37</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>735</x>\n    <y>5</y>\n    <width>45</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>5</y>\n    <width>95</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>5</y>\n    <width>90</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Sales Order #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>5</y>\n    <width>80</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>113</height>\n  <label>\n   <rect>\n    <x>40</x>\n    <y>5</y>\n    <width>165</width>\n    <height>30</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Checked By:</string>\n  </label>\n  <line>\n   <xstart>186</xstart>\n   <ystart>90</ystart>\n   <xend>360</xend>\n   <yend>90</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>40</x>\n    <y>65</y>\n    <width>160</width>\n    <height>35</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Completed By:</string>\n  </label>\n  <line>\n   <xstart>185</xstart>\n   <ystart>25</ystart>\n   <xend>362</xend>\n   <yend>25</yend>\n   <weight>0</weight>\n  </line>\n </rptfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102572
 
368     PickingListSOLocsNoClosedLines  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Picking List SO With Locations</title>\n <name>PickingListSOLocsNoClosedLines</name>\n <description>This report definition shows location / lot / serial information on an SO Pick List.  If the item is not Location Controlled it shows the contents of its Location Comment in the corresponding Item Site record.</description>\n <parameter default="3349" active="true" listtype="static" type="string" name="sohead_id">\n  <description></description>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>25</topmargin>\n <bottommargin>25</bottommargin>\n <rightmargin>25</rightmargin>\n <leftmargin>25</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT cust_number,\n       formatsobarcode(cohead_id) AS order_barcode,\n\n       formataddr(cohead_billtoaddress1,\n                  cohead_billtoaddress2,\n                  cohead_billtoaddress3,\n                  (cohead_billtocity || '  ' ||   cohead_billtostate || '  ' || cohead_billtozipcode),\n                  cohead_billtocountry) AS billing_address, \n       formataddr(cohead_shiptoaddress1,\n                  cohead_shiptoaddress2,\n                  cohead_shiptoaddress3,\n                  (cohead_shiptocity || '  ' ||   cohead_shiptostate || '  ' || cohead_shiptozipcode),\n                  cohead_shiptocountry) AS shipping_address,           \n       trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n       cohead_billtoname,\n       cohead_billtoaddress1,\n       cohead_billtoaddress2,\n       cohead_billtoaddress3,\n       (cohead_billtocity || '  ' || cohead_billtostate || '  ' || cohead_billtozipcode) AS billtocitystatezip,\n       cntct_phone AS cust_phone,\n       cohead_shiptoname,\n       cohead_shiptoaddress1,\n       cohead_shiptoaddress2,\n       cohead_shiptoaddress3,\n       (cohead_shiptocity || '  ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n       cohead_number,\n       cohead_shipvia,\n       cohead_shiptophone,\n       cohead_custponumber,\n       formatDate(cohead_orderdate) AS orderdate,\n       formatDate(getSoSchedDate(cohead_id)) AS scheddate,\n       cohead_shipcomments, \n       terms_descrip\n  FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n              LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n              LEFT OUTER JOIN terms ON (cohead_terms_id=terms_id)\n WHERE (cohead_id=&lt;? value("sohead_id") ?>)\n;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n       coitem_linenumber AS sortline,\n       coitem_subnumber AS sortsubline,\n       formatsolinenumber(coitem_id) AS linenumber,\n       coitem_memo,\n       item_number,\n       formatitemsitebarcode(itemsite_id) AS item_barcode,\n       CASE WHEN (formatLocationName(location_id) = 'N/A') THEN itemsite_location_comments || ' ' || '(comment)'\n            ELSE formatLocationName(location_id)\n       END AS location_name,\n       itemsite_location_comments AS location_comment,\n       formatlotserialnumber(itemloc_ls_id),\n       formatDate(itemloc_expiration, 'N/A') AS expiration,\n       itemloc_qty AS location_qty_qty,\n       CASE WHEN fetchMetricBool('EnableSOReservationsByLocation')\n            THEN formatQty(qtyReservedLocation(itemloc_id, 'SO', coitem_id)) \n            ELSE  formatQty(0) \n       END AS location_reserved_qty,\n       itemuomtouomratio(item_id,item_inv_uom_id, coitem_qty_uom_id) * itemloc_qty AS loc_issue_uom_qty,\n       formatqty(itemuomtouomratio(item_id,item_inv_uom_id, coitem_qty_uom_id) * itemloc_qty) AS loc_issue_uom_fmt,\n       coitemuom.uom_name AS uom_name,\n       item_descrip1,\n       item_descrip2,\n       formatQty(coitem_qtyord) AS ordered,\n       CASE WHEN (coitem_qtyreserved > 0.0)\n            THEN formatQty(coitem_qtyreserved)\n            ELSE NULL\n       END AS reserved,\n       CASE WHEN ((coitem_qtyshipped - coitem_qtyreturned) > 0.0)\n            THEN formatQty(coitem_qtyshipped - coitem_qtyreturned)\n            ELSE NULL\n       END AS shipped,\n       CASE WHEN (fetchMetricBool('RequireSOReservations'))\n            THEN formatQty(coitem_qtyreserved)\n            ELSE formatQty(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id)))\n       END AS balance,\n       CASE WHEN (qtyAtShipping('SO', coitem_id) > 0.0)\n            THEN formatQty(qtyAtShipping('SO', coitem_id))\n            ELSE NULL\n       END AS atShipping,\n       formatQty(roundUp((coitem_qtyord * coitem_qty_invuomratio))) AS shipordered,\n       formatQty(roundUp(((coitem_qtyshipped - coitem_qtyreturned) * coitem_qty_invuomratio))) AS shipshipped,\n       formatQty(roundUp((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio))) AS shipbalance,\n       getSoitemStatus(coitem_id) AS f_status\n   FROM coitem JOIN cohead ON (cohead_id = coitem_cohead_id)\n               JOIN custinfo ON (cust_id = cohead_cust_id)\n               JOIN itemsite ON (itemsite_id = coitem_itemsite_id)\n               JOIN item ON (item_id = itemsite_item_id)\n               JOIN whsinfo ON (warehous_id = itemsite_warehous_id)\n               JOIN uom invuom ON (invuom.uom_id = item_inv_uom_id)\n               JOIN uom coitemuom ON (coitemuom.uom_id = coitem_qty_uom_id) \n               LEFT OUTER JOIN itemloc  ON (itemloc_itemsite_id = itemsite_id)\n               LEFT OUTER JOIN location ON (itemloc_location_id = location_id)\n WHERE ( (coitem_cohead_id=&lt;? value("sohead_id") ?>)\n   AND   (coitem_status &lt;> 'X')\n   AND   (coitem_status &lt;> 'C')\n   AND   (item_type != 'K')\n   AND   ( (fetchMetricBool('RequireSOReservations') AND (coitem_qtyreserved > 0.0)) OR\n           (NOT fetchMetricBool('RequireSOReservations')) )\n&lt;? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n)\nORDER BY sortline, sortsubline, expiration, location_name;</sql>\n </querysource>\n <querysource>\n  <name>logo</name>\n  <sql>SELECT image_data \nFROM image \nWHERE ((image_name='logo'));</sql>\n </querysource>\n <querysource>\n  <name>site</name>\n  <sql>&lt;? if exists("warehous_id") ?>\n  SELECT warehous_code AS f_site\n  FROM whsinfo\n  WHERE (warehous_id=&lt;? value("warehous_id") ?>);\n&lt;? else ?>\n  SELECT text('') AS f_site;\n&lt;? endif ?>\n</sql>\n </querysource>\n <rpthead>\n  <height>467</height>\n  <image>\n   <rect>\n    <x>375</x>\n    <y>5</y>\n    <width>425</width>\n    <height>85</height>\n   </rect>\n   <mode>stretch</mode>\n   <data>\n    <query>logo</query>\n    <column>image_data</column>\n   </data>\n  </image>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>125</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>380</x>\n    <y>400</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Terms:</string>\n  </label>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>260</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ship To:</string>\n  </label>\n  <label>\n   <rect>\n    <x>433</x>\n    <y>444</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <text>\n   <rect>\n    <x>75</x>\n    <y>280</y>\n    <width>295</width>\n    <height>20</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>billing_address</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>400</y>\n    <width>95</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Attention:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>425</ystart>\n   <xend>797</xend>\n   <yend>425</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>400</y>\n    <width>253</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>cust_contact</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>200</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>scheddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>400</y>\n    <width>320</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>terms_descrip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>155</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer P/O #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>220</y>\n    <width>390</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shipvia</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>155</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>233</x>\n    <y>444</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>125</y>\n    <width>122</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>95</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>444</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reserved</string>\n  </label>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>130</y>\n    <width>177</width>\n    <height>25</height>\n   </rect>\n   <format>3of9</format>\n   <maxlength>10</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </barcode>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>95</y>\n    <width>233</width>\n    <height>25</height>\n   </rect>\n   <format>128</format>\n   <maxlength>10</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>order_barcode</column>\n   </data>\n  </barcode>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>180</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>orderdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>330</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>20</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sales Order Pick List</string>\n  </label>\n  <field>\n   <rect>\n    <x>465</x>\n    <y>260</y>\n    <width>305</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoname</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>220</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ship Via:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>180</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>430</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>425</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>444</y>\n    <width>95</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>730</x>\n    <y>444</y>\n    <width>55</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Packed</string>\n  </label>\n  <label>\n   <rect>\n    <x>630</x>\n    <y>444</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>At Shipping</string>\n  </label>\n  <field>\n   <rect>\n    <x>75</x>\n    <y>260</y>\n    <width>305</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_billtoname</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>444</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>To Pick</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>260</y>\n    <width>65</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bill To:</string>\n  </label>\n  <text>\n   <rect>\n    <x>465</x>\n    <y>280</y>\n    <width>305</width>\n    <height>20</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>shipping_address</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sched. Date:</string>\n  </label>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>160</y>\n    <width>307</width>\n    <height>25</height>\n   </rect>\n   <format>3of9</format>\n   <maxlength>20</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </barcode>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>70</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>70</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>site</query>\n    <column>f_site</column>\n   </data>\n  </field>\n </rpthead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>lineitems</name>\n   <column>linenumber</column>\n   <head>\n    <height>132</height>\n    <line>\n     <xstart>5</xstart>\n     <ystart>5</ystart>\n     <xend>797</xend>\n     <yend>5</yend>\n     <weight>2</weight>\n    </line>\n    <label>\n     <rect>\n      <x>630</x>\n      <y>100</y>\n      <width>90</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Expiration</string>\n    </label>\n    <label>\n     <rect>\n      <x>30</x>\n      <y>80</y>\n      <width>48</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Qty:</string>\n    </label>\n    <field>\n     <rect>\n      <x>30</x>\n      <y>25</y>\n      <width>285</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>11</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>item_descrip1</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>20</x>\n      <y>10</y>\n      <width>200</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>11</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>item_number</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>415</x>\n      <y>100</y>\n      <width>205</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>QtyAtLocn   QtyReserved   UOM</string>\n    </label>\n    <barcode>\n     <rect>\n      <x>408</x>\n      <y>35</y>\n      <width>380</width>\n      <height>45</height>\n     </rect>\n     <format>128</format>\n     <maxlength>15</maxlength>\n     <left/>\n     <narrowBarWidth>0.01</narrowBarWidth>\n     <data>\n      <query>detail</query>\n      <column>item_barcode</column>\n     </data>\n    </barcode>\n    <label>\n     <rect>\n      <x>80</x>\n      <y>100</y>\n      <width>80</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Location:</string>\n    </label>\n    <label>\n     <rect>\n      <x>250</x>\n      <y>100</y>\n      <width>145</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Lot / Serial</string>\n    </label>\n    <label>\n     <rect>\n      <x>30</x>\n      <y>60</y>\n      <width>48</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Carton:</string>\n    </label>\n    <field>\n     <rect>\n      <x>225</x>\n      <y>10</y>\n      <width>85</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>ordered</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>660</x>\n      <y>100</y>\n      <width>135</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Qty Picked</string>\n    </label>\n    <field>\n     <rect>\n      <x>620</x>\n      <y>10</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>atshipping</column>\n     </data>\n    </field>\n    <line>\n     <xstart>135</xstart>\n     <ystart>75</ystart>\n     <xend>175</xend>\n     <yend>75</yend>\n     <weight>0</weight>\n    </line>\n    <line>\n     <xstart>75</xstart>\n     <ystart>75</ystart>\n     <xend>112</xend>\n     <yend>75</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>320</x>\n      <y>63</y>\n      <width>40</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Status:</string>\n    </label>\n    <label>\n     <rect>\n      <x>660</x>\n      <y>85</y>\n      <width>135</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Loc / Lot</string>\n    </label>\n    <line>\n     <xstart>75</xstart>\n     <ystart>95</ystart>\n     <xend>112</xend>\n     <yend>95</yend>\n     <weight>0</weight>\n    </line>\n    <line>\n     <xstart>252</xstart>\n     <ystart>75</ystart>\n     <xend>295</xend>\n     <yend>75</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>515</x>\n      <y>10</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>balance</column>\n     </data>\n    </field>\n    <line>\n     <xstart>252</xstart>\n     <ystart>95</ystart>\n     <xend>295</xend>\n     <yend>95</yend>\n     <weight>0</weight>\n    </line>\n    <line>\n     <xstart>615</xstart>\n     <ystart>30</ystart>\n     <xend>535</xend>\n     <yend>30</yend>\n     <weight>0</weight>\n    </line>\n    <line>\n     <xstart>135</xstart>\n     <ystart>95</ystart>\n     <xend>175</xend>\n     <yend>95</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>415</x>\n      <y>10</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>shipped</column>\n     </data>\n    </field>\n    <line>\n     <xstart>745</xstart>\n     <ystart>25</ystart>\n     <xend>795</xend>\n     <yend>25</yend>\n     <weight>1</weight>\n    </line>\n    <line>\n     <xstart>195</xstart>\n     <ystart>95</ystart>\n     <xend>235</xend>\n     <yend>95</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>365</x>\n      <y>63</y>\n      <width>25</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_status</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>30</x>\n      <y>40</y>\n      <width>285</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>11</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>item_descrip2</column>\n     </data>\n    </field>\n    <line>\n     <xstart>195</xstart>\n     <ystart>75</ystart>\n     <xend>235</xend>\n     <yend>75</yend>\n     <weight>0</weight>\n    </line>\n    <line>\n     <xstart>70</xstart>\n     <ystart>120</ystart>\n     <xend>793</xend>\n     <yend>120</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>305</x>\n      <y>10</y>\n      <width>100</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>reserved</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>365</x>\n      <y>43</y>\n      <width>25</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>uom_name</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>320</x>\n      <y>43</y>\n      <width>40</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>UOM:</string>\n    </label>\n   </head>\n   <foot>\n    <height>29</height>\n    <field>\n     <rect>\n      <x>490</x>\n      <y>5</y>\n      <width>50</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>uom_name</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>80</x>\n      <y>5</y>\n      <width>48</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Item:</string>\n    </label>\n    <line>\n     <xstart>70</xstart>\n     <ystart>5</ystart>\n     <xend>793</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>415</x>\n      <y>5</y>\n      <width>70</width>\n      <height>20</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>loc_issue_uom_qty</column>\n     </data>\n     <format builtin="true">qty</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <field>\n     <rect>\n      <x>110</x>\n      <y>5</y>\n      <width>135</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>item_number</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>250</x>\n      <y>5</y>\n      <width>145</width>\n      <height>17</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total, All Lot/Ser/Loc:</string>\n    </label>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>29</height>\n   <field>\n    <rect>\n     <x>250</x>\n     <y>0</y>\n     <width>145</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>formatlotserialnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>70</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>location_reserved_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>415</x>\n     <y>0</y>\n     <width>70</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>loc_issue_uom_fmt</column>\n    </data>\n   </field>\n   <line>\n    <xstart>745</xstart>\n    <ystart>15</ystart>\n    <xend>795</xend>\n    <yend>15</yend>\n    <weight>1</weight>\n   </line>\n   <field>\n    <rect>\n     <x>80</x>\n     <y>0</y>\n     <width>155</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>location_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>565</x>\n     <y>0</y>\n     <width>50</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>635</x>\n     <y>0</y>\n     <width>85</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>expiration</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>29</height>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>5</y>\n    <width>90</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Sales Order #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>62</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Print Date: </string>\n  </label>\n  <field>\n   <rect>\n    <x>750</x>\n    <y>5</y>\n    <width>45</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>430</x>\n    <y>5</y>\n    <width>80</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>705</x>\n    <y>5</y>\n    <width>37</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>70</x>\n    <y>5</y>\n    <width>95</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>94</height>\n  <line>\n   <xstart>0</xstart>\n   <ystart>0</ystart>\n   <xend>203</xend>\n   <yend>0</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>160</width>\n    <height>35</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Completed By:</string>\n  </label>\n  <text>\n   <rect>\n    <x>215</x>\n    <y>35</y>\n    <width>580</width>\n    <height>17</height>\n   </rect>\n   <bottompad>14</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shipcomments</column>\n   </data>\n  </text>\n  <line>\n   <xstart>202</xstart>\n   <ystart>0</ystart>\n   <xend>203</xend>\n   <yend>55</yend>\n   <weight>2</weight>\n  </line>\n  <line>\n   <xstart>155</xstart>\n   <ystart>25</ystart>\n   <xend>195</xend>\n   <yend>25</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>10</y>\n    <width>85</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Notes:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>25</y>\n    <width>165</width>\n    <height>30</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Checked By:</string>\n  </label>\n  <line>\n   <xstart>155</xstart>\n   <ystart>50</ystart>\n   <xend>195</xend>\n   <yend>50</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>0</xstart>\n   <ystart>55</ystart>\n   <xend>203</xend>\n   <yend>55</yend>\n   <weight>2</weight>\n  </line>\n </rptfoot>\n</report>\n   This report definition shows location / lot / serial information on an SO Pick List.  If the item is not Location Controlled it shows the contents of its Location Comment in the corresponding Item Site record.       0       2014-10-06 19:47:03.678943
102573
 
330     PickingListSONoClosedLines      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Picking List</title>\n <name>PickingListSONoClosedLines</name>\n <description>Omits Closed Lines -- With Barcodes formatitemsitebarcode(itemsite_id) -- SO # barcoded formatsobarcode(cohead_id) -- With Logo, place logo graphic in images DB with name "logo"</description>\n <parameter default="3203" active="true" listtype="static" type="string" name="sohead_id">\n  <description></description>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>25</topmargin>\n <bottommargin>25</bottommargin>\n <rightmargin>25</rightmargin>\n <leftmargin>25</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT cust_number,\n       formatsobarcode(cohead_id) AS order_barcode,\n       formataddr(cohead_billtoaddress1,\n                  cohead_billtoaddress2,\n                  cohead_billtoaddress3,\n                  (cohead_billtocity || '  ' ||   cohead_billtostate || '  ' || cohead_billtozipcode),\n                  cohead_billtocountry) AS billing_address, \n       formataddr(cohead_shiptoaddress1,\n                  cohead_shiptoaddress2,\n                  cohead_shiptoaddress3,\n                  (cohead_shiptocity || '  ' ||   cohead_shiptostate || '  ' || cohead_shiptozipcode),\n                  cohead_shiptocountry) AS shipping_address,           \n       trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n       cohead_billtoname,\n       cohead_billtoaddress1,\n       cohead_billtoaddress2,\n       cohead_billtoaddress3,\n       (cohead_billtocity || '  ' || cohead_billtostate || '  ' || cohead_billtozipcode) AS billtocitystatezip,\n       cntct_phone AS cust_phone,\n       cohead_shiptoname,\n       cohead_shiptoaddress1,\n       cohead_shiptoaddress2,\n       cohead_shiptoaddress3,\n       (cohead_shiptocity || '  ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n       cohead_number,\n       cohead_shipvia,\n       cohead_shiptophone,\n       cohead_custponumber,\n       formatDate(cohead_orderdate) AS orderdate,\n       formatDate(getSoSchedDate(cohead_id)) AS scheddate,\n       cohead_shipcomments, \n       terms_descrip\n  FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n              JOIN terms ON (cohead_terms_id=terms_id)\n              LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n              LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n WHERE (cohead_id=&lt;? value("sohead_id") ?>);</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT 1 AS groupby,\n       coitem_linenumber AS sortline,\n       coitem_subnumber AS sortsubline,\n       formatsolinenumber(coitem_id) AS linenumber,\n       coitem_memo,\n       item_number,\n       formatitemsitebarcode(itemsite_id) AS item_barcode,\n       uom_name AS item_invuom,\n       item_descrip1,\n       item_descrip2,\n       formatQty(coitem_qtyord) AS ordered,\n       CASE WHEN (coitem_qtyreserved > 0.0)\n            THEN formatQty(coitem_qtyreserved)\n            ELSE NULL\n       END AS reserved,\n       CASE WHEN ((coitem_qtyshipped - coitem_qtyreturned) > 0.0)\n            THEN formatQty(coitem_qtyshipped - coitem_qtyreturned)\n            ELSE NULL\n       END AS shipped,\n       CASE WHEN (fetchMetricBool('RequireSOReservations'))\n            THEN formatQty(coitem_qtyreserved)\n            ELSE formatQty(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id)))\n       END AS balance,\n       CASE WHEN (qtyAtShipping('SO', coitem_id) > 0.0)\n            THEN formatQty(qtyAtShipping('SO', coitem_id))\n            ELSE NULL\n       END AS atShipping,\n       getSoitemStatus(coitem_id) AS f_status\n  FROM coitem JOIN uom ON (uom_id=coitem_qty_uom_id)\n              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n              JOIN item ON (item_id=itemsite_item_id)\n WHERE ((coitem_cohead_id=&lt;? value("sohead_id") ?>)\n   AND (coitem_status &lt;> 'X')\n   AND (coitem_status &lt;> 'C')\n   AND (item_type != 'K')\n   AND   ( (fetchMetricBool('RequireSOReservations') AND (coitem_qtyreserved > 0.0)) OR\n           (NOT fetchMetricBool('RequireSOReservations')) )\n-- 1 REMOVE THIS AND CLOSED LINES WILL NOT DISPLAY ON PACKING LIST  \n&lt;? if exists("hide closed") ?>\n   AND (coitem_status &lt;> 'C')\n-- 2 REMOVE THIS AND CLOSED LINES WILL NOT DISPLAY ON PACKING LIST  \n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n)\nORDER BY sortline, sortsubline;</sql>\n </querysource>\n <querysource>\n  <name>logo</name>\n  <sql>SELECT image_data \nFROM image \nWHERE ((image_name='logo'));</sql>\n </querysource>\n <querysource>\n  <name>site</name>\n  <sql>&lt;? if exists("warehous_id") ?>\n  SELECT warehous_code AS f_site\n  FROM whsinfo\n  WHERE (warehous_id=&lt;? value("warehous_id") ?>);\n&lt;? else ?>\n  SELECT text('') AS f_site;\n&lt;? endif ?>\n</sql>\n </querysource>\n <rpthead>\n  <height>477</height>\n  <image>\n   <rect>\n    <x>375</x>\n    <y>0</y>\n    <width>425</width>\n    <height>85</height>\n   </rect>\n   <mode>stretch</mode>\n   <data>\n    <query>logo</query>\n    <column>image_data</column>\n   </data>\n  </image>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>400</y>\n    <width>253</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>cust_contact</column>\n   </data>\n  </field>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>160</y>\n    <width>307</width>\n    <height>25</height>\n   </rect>\n   <format>3of9</format>\n   <maxlength>20</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </barcode>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>425</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>At Shipping</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>260</y>\n    <width>65</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bill To:</string>\n  </label>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>260</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ship To:</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>215</y>\n    <width>121</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sched. Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>175</x>\n    <y>215</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>scheddate</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>465</x>\n    <y>280</y>\n    <width>305</width>\n    <height>20</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>shipping_address</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>125</y>\n    <width>122</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>425</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reserved</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>125</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>270</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>20</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Picking List (SO)</string>\n  </label>\n  <field>\n   <rect>\n    <x>433</x>\n    <y>215</y>\n    <width>331</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shipvia</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>253</x>\n    <y>425</y>\n    <width>55</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <field>\n   <rect>\n    <x>468</x>\n    <y>400</y>\n    <width>320</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>terms_descrip</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>155</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>215</y>\n    <width>102</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ship Via:</string>\n  </label>\n  <text>\n   <rect>\n    <x>75</x>\n    <y>280</y>\n    <width>295</width>\n    <height>20</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>billing_address</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>365</x>\n    <y>400</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Terms:</string>\n  </label>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>95</y>\n    <width>233</width>\n    <height>25</height>\n   </rect>\n   <format>128</format>\n   <maxlength>10</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>order_barcode</column>\n   </data>\n  </barcode>\n  <field>\n   <rect>\n    <x>175</x>\n    <y>195</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>orderdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>400</y>\n    <width>95</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Attention:</string>\n  </label>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>425</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n  <line>\n   <xstart>25</xstart>\n   <ystart>465</ystart>\n   <xend>823</xend>\n   <yend>465</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>95</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>155</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer P/O #:</string>\n  </label>\n  <line>\n   <xstart>25</xstart>\n   <ystart>425</ystart>\n   <xend>823</xend>\n   <yend>425</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>465</x>\n    <y>260</y>\n    <width>305</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoname</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>443</y>\n    <width>95</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>130</y>\n    <width>177</width>\n    <height>25</height>\n   </rect>\n   <format>3of9</format>\n   <maxlength>10</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </barcode>\n  <label>\n   <rect>\n    <x>745</x>\n    <y>425</y>\n    <width>55</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Packed</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>425</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>545</x>\n    <y>425</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <field>\n   <rect>\n    <x>75</x>\n    <y>260</y>\n    <width>305</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_billtoname</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>195</y>\n    <width>102</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>S/O Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>65</y>\n    <width>122</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>site</query>\n    <column>f_site</column>\n   </data>\n  </field>\n </rpthead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>groupby</column>\n   <foot>\n    <height>68</height>\n    <text>\n     <rect>\n      <x>50</x>\n      <y>5</y>\n      <width>625</width>\n      <height>17</height>\n     </rect>\n     <bottompad>14</bottompad>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>cohead_shipcomments</column>\n     </data>\n    </text>\n   </foot>\n  </group>\n  <group>\n   <name>lineitem</name>\n   <column>linenumber</column>\n   <foot>\n    <height>23</height>\n    <line>\n     <xstart>5</xstart>\n     <ystart>5</ystart>\n     <xend>843</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>148</height>\n   <label>\n    <rect>\n     <x>25</x>\n     <y>65</y>\n     <width>48</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Carton:</string>\n   </label>\n   <field>\n    <rect>\n     <x>630</x>\n     <y>98</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>40</y>\n     <width>295</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <line>\n    <xstart>190</xstart>\n    <ystart>110</ystart>\n    <xend>280</xend>\n    <yend>110</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>635</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>atshipping</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>20</y>\n     <width>295</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>565</x>\n     <y>98</y>\n     <width>60</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <string>Status:</string>\n   </label>\n   <text>\n    <rect>\n     <x>100</x>\n     <y>120</y>\n     <width>690</width>\n     <height>17</height>\n    </rect>\n    <bottompad>14</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>coitem_memo</column>\n    </data>\n   </text>\n   <line>\n    <xstart>415</xstart>\n    <ystart>110</ystart>\n    <xend>500</xend>\n    <yend>110</yend>\n    <weight>0</weight>\n   </line>\n   <label>\n    <rect>\n     <x>565</x>\n     <y>70</y>\n     <width>60</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <string>Batch #:</string>\n   </label>\n   <label>\n    <rect>\n     <x>20</x>\n     <y>120</y>\n     <width>75</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Notes:</string>\n   </label>\n   <line>\n    <xstart>415</xstart>\n    <ystart>80</ystart>\n    <xend>500</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <line>\n    <xstart>80</xstart>\n    <ystart>110</ystart>\n    <xend>170</xend>\n    <yend>110</yend>\n    <weight>0</weight>\n   </line>\n   <line>\n    <xstart>190</xstart>\n    <ystart>80</ystart>\n    <xend>280</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>balance</column>\n    </data>\n   </field>\n   <line>\n    <xstart>305</xstart>\n    <ystart>110</ystart>\n    <xend>395</xend>\n    <yend>110</yend>\n    <weight>0</weight>\n   </line>\n   <line>\n    <xstart>305</xstart>\n    <ystart>80</ystart>\n    <xend>395</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>200</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>25</x>\n     <y>95</y>\n     <width>48</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Qty:</string>\n   </label>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipped</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>228</x>\n     <y>0</y>\n     <width>85</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ordered</column>\n    </data>\n   </field>\n   <line>\n    <xstart>745</xstart>\n    <ystart>15</ystart>\n    <xend>795</xend>\n    <yend>15</yend>\n    <weight>1</weight>\n   </line>\n   <line>\n    <xstart>80</xstart>\n    <ystart>80</ystart>\n    <xend>170</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <barcode>\n    <rect>\n     <x>325</x>\n     <y>23</y>\n     <width>468</width>\n     <height>35</height>\n    </rect>\n    <format>128</format>\n    <maxlength>15</maxlength>\n    <left/>\n    <narrowBarWidth>0.01</narrowBarWidth>\n    <data>\n     <query>detail</query>\n     <column>item_barcode</column>\n    </data>\n   </barcode>\n   <line>\n    <xstart>632</xstart>\n    <ystart>80</ystart>\n    <xend>720</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>reserved</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>630</x>\n     <y>83</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_invuom</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>565</x>\n     <y>83</y>\n     <width>60</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <string>UOM:</string>\n   </label>\n  </detail>\n </section>\n <pgfoot>\n  <height>56</height>\n  <label>\n   <rect>\n    <x>695</x>\n    <y>5</y>\n    <width>37</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>5</y>\n    <width>80</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>5</y>\n    <width>95</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>735</x>\n    <y>5</y>\n    <width>45</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>5</y>\n    <width>90</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Sales Order #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>5</y>\n    <width>62</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Print Date: </string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>111</height>\n  <line>\n   <xstart>185</xstart>\n   <ystart>25</ystart>\n   <xend>363</xend>\n   <yend>25</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>40</x>\n    <y>65</y>\n    <width>160</width>\n    <height>35</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Completed By:</string>\n  </label>\n  <line>\n   <xstart>186</xstart>\n   <ystart>90</ystart>\n   <xend>360</xend>\n   <yend>90</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>40</x>\n    <y>5</y>\n    <width>165</width>\n    <height>30</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Checked By:</string>\n  </label>\n </rptfoot>\n</report>\n  Omits Closed Lines -- With Barcodes formatitemsitebarcode(itemsite_id) -- SO # barcoded formatsobarcode(cohead_id) -- With Logo, place logo graphic in images DB with name "logo"       0       2014-10-06 19:47:03.678943
102574
 
141     PlannerCodeMasterList   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Planner Code Master List</title>\n <name>PlannerCodeMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT plancode_id,\n       plancode_code,  \n       plancode_name\n  FROM plancode\nORDER BY plancode_code;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Planner Code Master List</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>plancode_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>plancode_code</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102575
 
68      PricesByCustomer        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Prices By Customer</title>\n <name>PricesByCustomer</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT cust_name,\n       addr_line1 AS cust_address1,\n       addr_line2 AS cust_address2,\n       addr_line3 AS cust_address3,\n       &lt;? if exists("showExpired") ?>\n         text('Yes')\n       &lt;? else ?>\n         text('No')\n       &lt;? endif ?>\n       AS f_showexpired,\n       &lt;? if exists("showFuture") ?>\n         text('Yes')\n       &lt;? else ?>\n         text('No')\n       &lt;? endif ?>\n       AS f_showfuture,\n       &lt;? if exists("showCosts") ?>\n         &lt;? if exists("actualCosts") ?>\n           text('Show Costs and Margins using Actual Costs')\n         &lt;? else ?>\n           text('Show Costs and Margins using Standard Costs')\n         &lt;? endif ?>\n         AS f_showcosts,\n         text('Cost') AS f_costlabel,\n         text('Margin') AS f_marginlabel\n       &lt;? else ?>\n         text('') AS f_showcosts,\n         text('') AS f_costlabel,\n         text('') AS f_marginlabel\n       &lt;? endif ?>\n   FROM custinfo\n   LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n   LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\nWHERE (cust_id=&lt;? value("cust_id") ?>);\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT itemid, sourcetype, schedulename, type, itemnumber,\n       item_descrip1, item_descrip2,\n       CASE WHEN (qtybreak = -1) THEN 'N/A'\n            ELSE formatQty(qtybreak)\n       END AS f_qtybreak,\n       price, formatPrice(price) AS f_price,\n       &lt;? if exists("showCosts") ?>\n         cost AS cost,\n         formatCost(cost) AS f_cost,\n         CASE WHEN ((price = 0) OR (cost = 0)) THEN 'N/A'\n              ELSE formatScrap((price - cost) / price)\n         END AS f_margin\n       &lt;? else ?>\n         0 AS cost,\n         text('') AS f_cost,\n         text('') AS f_margin\n       &lt;? endif ?>\nFROM (\n  SELECT ipsprice_id AS itemid, 1 AS sourcetype,\n         ipshead_name AS schedulename, 'Customer' AS type,\n         item_number AS itemnumber, item_descrip1, item_descrip2,\n         ipsprice_qtybreak AS qtybreak, ipsprice_price AS price,\n         &lt;? if exists("actualCosts") ?>\n           (actcost(item_id) * iteminvpricerat(item_id))\n         &lt;? else ?>\n           (stdcost(item_id) * iteminvpricerat(item_id))\n         &lt;? endif ?>\n         AS cost\n    FROM ipsass, ipshead, ipsprice, item\n   WHERE ((ipsass_ipshead_id=ipshead_id)\n     AND (ipsprice_ipshead_id=ipshead_id)\n     AND (ipsprice_item_id=item_id)\n     AND (ipsass_cust_id=&lt;? value("cust_id") ?>)\n&lt;? if not exists("showExpired") ?>\n     AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n     AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n  )\n\n  UNION\n  SELECT ipsprice_id AS itemid, 2 AS sourcetype,\n         ipshead_name AS schedulename, 'Cust. Type' AS type,\n         item_number AS itemnumber, item_descrip1, item_descrip2,\n         ipsprice_qtybreak AS qtybreak, ipsprice_price AS price,\n         &lt;? if exists("actualCosts") ?>\n           (actcost(item_id) * iteminvpricerat(item_id))\n         &lt;? else ?>\n           (stdcost(item_id) * iteminvpricerat(item_id))\n         &lt;? endif ?>\n         AS cost\n    FROM ipsass, ipshead, ipsprice, item, custinfo\n   WHERE ((ipsass_ipshead_id=ipshead_id)\n     AND (ipsprice_ipshead_id=ipshead_id)\n     AND (ipsprice_item_id=item_id)\n     AND (ipsass_custtype_id=cust_custtype_id)\n     AND (cust_id=&lt;? value("cust_id") ?>)\n&lt;? if not exists("showExpired") ?>\n     AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n     AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n  )\n\n  UNION\n  SELECT ipsprice_id AS itemid, 3 AS sourcetype,\n         ipshead_name AS schedulename, ('Sale' || '-' || sale_name) AS type,\n         item_number AS itemnumber, item_descrip1, item_descrip2,\n         ipsprice_qtybreak AS qtybreak, ipsprice_price AS price,\n         &lt;? if exists("actualCosts") ?>\n           (actcost(item_id) * iteminvpricerat(item_id))\n         &lt;? else ?>\n           (stdcost(item_id) * iteminvpricerat(item_id))\n         &lt;? endif ?>\n         AS cost\n    FROM sale, ipshead, ipsprice, item\n   WHERE ((sale_ipshead_id=ipshead_id)\n     AND (ipsprice_ipshead_id=ipshead_id)\n     AND (ipsprice_item_id=item_id)\n&lt;? if not exists("showExpired") ?>\n     AND (sale_enddate > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n     AND (sale_startdate &lt;= CURRENT_DATE)\n&lt;? endif ?>\n  )\n\n  UNION\n  SELECT item_id AS itemid, 0 AS sourcetype,\n         '' AS schedulename, 'List Price' AS type,\n         item_number AS itemnumber, item_descrip1, item_descrip2,\n         -1 AS qtybreak, (item_listprice - (item_listprice * cust_discntprcnt)) AS price,\n         &lt;? if exists("actualCosts") ?>\n           (actcost(item_id) * iteminvpricerat(item_id))\n         &lt;? else ?>\n           (stdcost(item_id) * iteminvpricerat(item_id))\n         &lt;? endif ?>\n         AS cost\n    FROM item, custinfo\n   WHERE ( (item_sold)\n     AND (item_active)\n     AND (cust_id=&lt;? value("cust_id") ?>)\n     AND (NOT item_exclusive) )\n) AS data\nORDER BY itemnumber, price;</sql>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>120</y>\n    <width>155</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show Future Prices:</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>100</y>\n    <width>155</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show Expired Prices:</string>\n  </label>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>120</y>\n    <width>114</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showfuture</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>605</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_marginlabel</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_costlabel</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>140</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_address3</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_address1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>405</x>\n    <y>140</y>\n    <width>335</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showcosts</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>195</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Schedule</string>\n  </label>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>100</y>\n    <width>114</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showexpired</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Break</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>215</y>\n    <width>155</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer:</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Prices by Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_address2</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_marginlabel</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>195</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Schedule</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Break</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>20</y>\n    <width>155</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price</string>\n  </label>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_costlabel</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>30</y>\n     <width>240</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtybreak</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_cost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>195</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>schedulename</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_price</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>240</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_margin</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>type</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102576
 
69      PricesByCustomerType    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Prices By Customer Type</title>\n <name>PricesByCustomerType</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT (custtype_code || '-' || custtype_descrip) as custtype,\n       &lt;? if exists("showExpired") ?>\n         text('Yes')\n       &lt;? else ?>\n         text('No')\n       &lt;? endif ?>\n       AS f_showexpired,\n       &lt;? if exists("showFuture") ?>\n         text('Yes')\n       &lt;? else ?>\n         text('No')\n       &lt;? endif ?>\n       AS f_showfuture,\n       &lt;? if exists("showCosts") ?>\n         &lt;? if exists("actualCosts") ?>\n           text('Show Costs and Margins using Actual Costs')\n         &lt;? else ?>\n           text('Show Costs and Margins using Standard Costs')\n         &lt;? endif ?>\n         AS f_showcosts,\n         text('Cost') AS f_costlabel,\n         text('Margin') AS f_marginlabel\n       &lt;? else ?>\n         text('') AS f_showcosts,\n         text('') AS f_costlabel,\n         text('') AS f_marginlabel\n       &lt;? endif ?>\n  FROM custtype\n WHERE (custtype_id=&lt;? value("custtype_id") ?>);\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT itemid, sourcetype, schedulename, type, itemnumber,\n       item_descrip1, item_descrip2,\n       CASE WHEN (qtybreak = -1) THEN 'N/A'\n            ELSE formatQty(qtybreak)\n       END AS f_qtybreak,\n       price, formatSalesPrice(price) AS f_price,\n       &lt;? if exists("showCosts") ?>\n         cost AS cost,\n         formatCost(cost) AS f_cost,\n         CASE WHEN ((price = 0) OR (cost = 0)) THEN 'N/A'\n              ELSE formatScrap((price - cost) / price)\n         END AS f_margin\n       &lt;? else ?>\n         0 AS cost,\n         '' AS f_cost,\n         '' AS f_margin\n       &lt;? endif ?>\nFROM (\n  SELECT ipsprice_id AS itemid, 2 AS sourcetype,\n         ipshead_name AS schedulename, 'Cust. Type' AS type,\n         item_number AS itemnumber, item_descrip1, item_descrip2,\n         ipsprice_qtybreak AS qtybreak, ipsprice_price AS price,\n         &lt;? if exists("actualCosts") ?>\n           (actcost(ipsprice_item_id) * iteminvpricerat(item_id))\n         &lt;? else ?>\n           (stdcost(ipsprice_item_id) * iteminvpricerat(item_id))\n         &lt;? endif ?>\n         AS cost\n    FROM ipsass, ipshead, ipsprice, item \n   WHERE ((ipsass_ipshead_id=ipshead_id)\n     AND (ipsprice_ipshead_id=ipshead_id)\n     AND (ipsprice_item_id=item_id)\n     AND (ipsass_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? if not exists("showExpired") ?>\n     AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n     AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n  )\n\n  UNION\n  SELECT ipsprice_id AS itemid, 3 AS sourcetype,\n         ipshead_name AS schedulename, ('Sale' || '-' || sale_name) AS type,\n         item_number AS itemnumber,\n         item_descrip1, item_descrip2,\n         ipsprice_qtybreak AS qtybreak, ipsprice_price AS price,\n         &lt;? if exists("actualCosts") ?>\n           (actcost(ipsprice_item_id) * iteminvpricerat(item_id))\n         &lt;? else ?>\n           (stdcost(ipsprice_item_id) * iteminvpricerat(item_id))\n         &lt;? endif ?>\n         AS cost\n    FROM sale, ipshead, ipsprice, item\n   WHERE ( (sale_ipshead_id=ipshead_id)\n     AND (ipsprice_ipshead_id=ipshead_id)\n     AND (ipsprice_item_id=item_id)\n&lt;? if not exists("showExpired") ?>\n     AND (sale_enddate > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists("showFuture") ?>\n     AND (sale_startdate &lt;= CURRENT_DATE)\n&lt;? endif ?>\n  )\n\n  UNION\n  SELECT item_id AS itemid, 0 AS sourcetype,\n         '' AS schedulename, 'List Price' AS type,\n         item_number AS itemnumber, item_descrip1, item_descrip2,\n         -1 AS qtybreak, item_listprice AS price,\n         &lt;? if exists("actualCosts") ?>\n           (actcost(item_id) * iteminvpricerat(item_id))\n         &lt;? else ?>\n           (stdcost(item_id) * iteminvpricerat(item_id))\n         &lt;? endif ?>\n         AS cost\n    FROM item\n   WHERE ( (item_sold)\n     AND (item_active)\n     AND (NOT item_exclusive) )\n) AS data\nORDER BY itemnumber, price;</sql>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Break</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Prices by Customer Type</string>\n  </label>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_costlabel</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_marginlabel</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>80</y>\n    <width>500</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>custtype</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>80</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>120</y>\n    <width>113</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showfuture</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>120</y>\n    <width>155</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show Future Prices:</string>\n  </label>\n  <label>\n   <rect>\n    <x>195</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Schedule</string>\n  </label>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>100</y>\n    <width>113</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showexpired</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>215</y>\n    <width>155</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>155</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price</string>\n  </label>\n  <field>\n   <rect>\n    <x>405</x>\n    <y>140</y>\n    <width>335</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showcosts</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>100</y>\n    <width>155</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show Expired Prices:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Break</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>155</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_marginlabel</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>195</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Schedule</string>\n  </label>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_costlabel</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>20</y>\n    <width>155</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <line>\n    <xstart>5</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtybreak</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>240</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>195</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>schedulename</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_price</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_margin</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>30</y>\n     <width>240</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_cost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>type</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102577
 
67      PricesByItem    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Prices By Item</title>\n <name>PricesByItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       &lt;? if exists(&quot;showExpired&quot;) ?>\n         text('Yes')\n       &lt;? else ?>\n         text('No')\n       &lt;? endif ?>\n       AS f_showexpired,\n       &lt;? if exists(&quot;showFuture&quot;) ?>\n         text('Yes')\n       &lt;? else ?>\n         text('No')\n       &lt;? endif ?>\n       AS f_showfuture,\n       &lt;? if exists(&quot;showCosts&quot;) ?>\n         &lt;? if exists(&quot;actualCosts&quot;) ?>\n           text('Show Costs and Margins using Actual Costs')\n         &lt;? else ?>\n           text('Show Costs and Margins using Standard Costs')\n         &lt;? endif ?>\n         AS f_showcosts,\n         text('Cost') AS f_costlabel,\n         text('Margin') AS f_marginlabel\n       &lt;? else ?>\n         text('') AS f_showcosts,\n         text('') AS f_costlabel,\n         text('') AS f_marginlabel\n       &lt;? endif ?>\n  FROM item\n WHERE (item_id=&lt;? value(&quot;item_id&quot;) ?>);\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT itemid, sourcetype, schedulename, type, typename,\n       CASE WHEN (qtybreak = -1) THEN 'N/A'\n            ELSE formatQty(qtybreak)\n       END AS f_qtybreak,\n       price, formatPrice(price) AS f_price,\n       &lt;? if exists(&quot;showCosts&quot;) ?>\n         cost AS cost,\n         formatCost(cost) AS f_cost,\n         CASE WHEN ((price = 0) OR (cost = 0)) THEN 'N/A'\n              ELSE formatScrap((price - cost) / price)\n         END AS f_margin\n       &lt;? else ?>\n         0 AS cost,\n         text('') AS f_cost,\n         text('') AS f_margin\n       &lt;? endif ?>\nFROM ( SELECT ipsprice_id AS itemid, 1 AS sourcetype,\n              ipshead_name AS schedulename, 'Customer' AS type,\n              cust_name AS typename,\n              ipsprice_qtybreak AS qtybreak,\n              ipsprice_price AS price,\n              &lt;? if exists(&quot;actualCosts&quot;) ?>\n                (actcost(item_id) * iteminvpricerat(item_id))\n              &lt;? else ?>\n                (stdcost(item_id) * iteminvpricerat(item_id))\n              &lt;? endif ?>\n              AS cost\n         FROM ipsass, ipshead, ipsprice, custinfo, item\n        WHERE ( (ipsass_ipshead_id=ipshead_id)\n          AND (ipsprice_ipshead_id=ipshead_id)\n          AND (ipsass_cust_id=cust_id)\n          AND (ipsprice_item_id=item_id)\n          AND (item_id=&lt;? value(&quot;item_id&quot;) ?>)\n&lt;? if not exists(&quot;showExpired&quot;) ?>\n          AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists(&quot;showFuture&quot;) ?>\n          AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n  )\n\n  UNION\n  SELECT ipsprice_id AS itemid, 2 AS sourcetype,\n         ipshead_name AS schedulename, 'Cust. Type' AS type,\n         (custtype_code || '-' || custtype_descrip) AS typename,\n         ipsprice_qtybreak AS qtybreak,\n         ipsprice_price AS price,\n         &lt;? if exists(&quot;actualCosts&quot;) ?>\n           (actcost(item_id) * iteminvpricerat(item_id))\n         &lt;? else ?>\n           (stdcost(item_id) * iteminvpricerat(item_id))\n         &lt;? endif ?>\n         AS cost\n    FROM ipsass, ipshead, ipsprice, custtype, item\n   WHERE ( (ipsass_ipshead_id=ipshead_id)\n     AND (ipsprice_ipshead_id=ipshead_id)\n     AND (ipsass_custtype_id=custtype_id)\n     AND (ipsprice_item_id=item_id)\n     AND (item_id=&lt;? value(&quot;item_id&quot;) ?>)\n&lt;? if not exists(&quot;showExpired&quot;) ?>\n     AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists(&quot;showFuture&quot;) ?>\n     AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n  )\n\n  UNION\n  SELECT ipsprice_id AS itemid, 3 AS sourcetype,\n         ipshead_name AS schedulename, 'Cust. Type Pattern' AS type,\n         (custtype_code || '-' || custtype_descrip) AS typename,\n         ipsprice_qtybreak AS qtybreak,\n         ipsprice_price AS price,\n         &lt;? if exists(&quot;actualCosts&quot;) ?>\n           (actcost(item_id) * iteminvpricerat(item_id))\n         &lt;? else ?>\n           (stdcost(item_id) * iteminvpricerat(item_id))\n         &lt;? endif ?>\n         AS cost\n    FROM ipsass, ipshead, ipsprice, custtype, item\n   WHERE ( (ipsass_ipshead_id=ipshead_id)\n     AND (ipsprice_ipshead_id=ipshead_id)\n     AND (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0)\n     AND (custtype_code ~ ipsass_custtype_pattern)\n     AND (ipsprice_item_id=item_id)\n     AND (item_id=&lt;? value(&quot;item_id&quot;) ?>)\n&lt;? if not exists(&quot;showExpired&quot;) ?>\n     AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists(&quot;showFuture&quot;) ?>\n     AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n  )\n\n  UNION\n  SELECT ipsprice_id AS itemid, 4 AS sourcetype,\n         ipshead_name AS schedulename, 'Sale' AS type,\n         sale_name AS typename,\n         ipsprice_qtybreak AS qtybreak,\n         ipsprice_price AS price,\n         &lt;? if exists(&quot;actualCosts&quot;) ?>\n           (actcost(item_id) * iteminvpricerat(item_id))\n         &lt;? else ?>\n           (stdcost(item_id) * iteminvpricerat(item_id))\n         &lt;? endif ?>\n         AS cost\n    FROM sale, ipshead, ipsprice, item\n   WHERE ( (sale_ipshead_id=ipshead_id)\n     AND (ipsprice_ipshead_id=ipshead_id)\n     AND (ipsprice_item_id=item_id)\n     AND (item_id=&lt;? value(&quot;item_id&quot;) ?>)\n&lt;? if not exists(&quot;showExpired&quot;) ?>\n     AND (sale_enddate > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists(&quot;showFuture&quot;) ?>\n     AND (sale_startdate &lt;= CURRENT_DATE)\n&lt;? endif ?>\n  )\n\n  UNION\n  SELECT ipsprice_id AS itemid, 5 AS sourcetype,\n         ipshead_name AS schedulename, 'Cust. Ship-To' AS type,\n         (cust_name || '-' || shipto_num) AS typename,\n         ipsprice_qtybreak AS qtybreak,\n         ipsprice_price AS price,\n         &lt;? if exists(&quot;actualCosts&quot;) ?>\n           (actcost(item_id) * iteminvpricerat(item_id))\n         &lt;? else ?>\n           (stdcost(item_id) * iteminvpricerat(item_id))\n         &lt;? endif ?>\n         AS cost\n    FROM ipsass, ipshead, ipsprice, custinfo, shiptoinfo, item\n   WHERE ( (ipsass_ipshead_id=ipshead_id)\n     AND (ipsprice_ipshead_id=ipshead_id)\n     AND (ipsass_shipto_id=shipto_id)\n     AND (shipto_cust_id=cust_id)\n     AND (ipsprice_item_id=item_id)\n     AND (item_id=&lt;? value(&quot;item_id&quot;) ?>)\n&lt;? if not exists(&quot;showExpired&quot;) ?>\n     AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists(&quot;showFuture&quot;) ?>\n     AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n  )\n\n  UNION\n  SELECT ipsprice_id AS itemid, 5 AS sourcetype,\n         ipshead_name AS schedulename, 'Cust. Ship-To Pattern' AS type,\n         (cust_name || '-' || shipto_num) AS typename,\n         ipsprice_qtybreak AS qtybreak,\n         ipsprice_price AS price,\n         &lt;? if exists(&quot;actualCosts&quot;) ?>\n           (actcost(item_id) * iteminvpricerat(item_id))\n         &lt;? else ?>\n           (stdcost(item_id) * iteminvpricerat(item_id))\n         &lt;? endif ?>\n         AS cost\n    FROM ipsass, ipshead, ipsprice, custinfo, shiptoinfo, item\n   WHERE ( (ipsass_ipshead_id=ipshead_id)\n     AND (ipsprice_ipshead_id=ipshead_id)\n     AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0)\n     AND (shipto_num ~ ipsass_shipto_pattern)\n     AND (shipto_cust_id=cust_id)\n     AND (ipsprice_item_id=item_id)\n     AND (item_id=&lt;? value(&quot;item_id&quot;) ?>)\n&lt;? if not exists(&quot;showExpired&quot;) ?>\n     AND (ipshead_expires > CURRENT_DATE)\n&lt;? endif ?>\n&lt;? if not exists(&quot;showFuture&quot;) ?>\n     AND (ipshead_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n  )\n\n  UNION\n  SELECT item_id AS itemid, 0 AS sourcetype,\n         'List Price' AS schedulename, 'N/A' AS type,\n         '' AS typename,\n         -1 AS qtybreak,\n         item_listprice AS price,\n         &lt;? if exists(&quot;actualCosts&quot;) ?>\n           (actcost(item_id) * iteminvpricerat(item_id))\n         &lt;? else ?>\n           (stdcost(item_id) * iteminvpricerat(item_id))\n         &lt;? endif ?>\n         AS cost\n    FROM item\n   WHERE ( (NOT item_exclusive)\n     AND (item_id=&lt;? value(&quot;item_id&quot;) ?>) ) ) AS data\nORDER BY price;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>80</y>\n    <width>114</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showexpired</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_marginlabel</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>200</y>\n    <width>155</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer/Customer Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Prices by Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>80</y>\n    <width>155</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show Expired Prices:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Break</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Schedule</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_costlabel</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>100</y>\n    <width>155</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show Future Prices:</string>\n  </label>\n  <field>\n   <rect>\n    <x>405</x>\n    <y>120</y>\n    <width>335</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showcosts</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <field>\n   <rect>\n    <x>565</x>\n    <y>100</y>\n    <width>114</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_showfuture</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>5</y>\n    <width>155</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer/Customer Type</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Schedule</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Break</string>\n  </label>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_costlabel</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_costlabel</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_price</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>135</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>type</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>schedulename</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_cost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtybreak</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_margin</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>0</y>\n     <width>185</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>typename</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102578
 
258     PricingScheduleAssignments      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Pricing Schedule Assignments</title>\n <name>PricingScheduleAssignments</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT ipsass_id,\n       CASE WHEN (ipsass_shipto_id != -1) THEN (SELECT shipto_num FROM shiptoinfo WHERE (shipto_id=ipsass_shipto_id))\n            WHEN (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) THEN ipsass_shipto_pattern\n            ELSE TEXT('ANY')\n       END AS shiptonum,\n       CASE WHEN (ipsass_shipto_id != -1) THEN (SELECT cust_number FROM shiptoinfo, custinfo WHERE ((shipto_cust_id=cust_id) AND (shipto_id=ipsass_shipto_id)))\n            WHEN (ipsass_cust_id=-1) THEN TEXT('Any')\n            ELSE (SELECT cust_number FROM custinfo WHERE (cust_id=ipsass_cust_id))\n       END AS custnumber,\n       CASE WHEN (ipsass_shipto_id != -1) THEN (SELECT cust_name FROM shiptoinfo, custinfo WHERE ((shipto_cust_id=cust_id) AND (shipto_id=ipsass_shipto_id)))\n            WHEN (ipsass_cust_id=-1) THEN ''\n            ELSE (SELECT cust_name FROM custinfo WHERE (cust_id=ipsass_cust_id))\n       END AS custname,\n       CASE WHEN (ipsass_cust_id != -1) THEN TEXT('N/A')\n            WHEN (ipsass_shipto_id != -1) THEN TEXT('N/A')\n            WHEN (COALESCE(LENGTH(ipsass_shipto_pattern),0) > 0) THEN TEXT('N/A')\n            WHEN (ipsass_custtype_id=-1) THEN ipsass_custtype_pattern\n            ELSE (SELECT custtype_code FROM custtype WHERE (custtype_id=ipsass_custtype_id))\n       END AS custtype,\n       ipshead_name\nFROM ipsass, ipshead\nWHERE (ipshead_id=ipsass_ipshead_id)\nORDER BY custname, custtype;\n</sql>\n </querysource>\n <rpthead>\n  <height>78</height>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>115</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Pricing Schedule</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust. Ship-To</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Pricing Schedule Assignments</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust. Type</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust. Ship-To</string>\n  </label>\n  <label>\n   <rect>\n    <x>115</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust. Type</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>335</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Pricing Schedule</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>465</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>custtype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shiptonum</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>0</y>\n     <width>205</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>custname</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>115</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>custnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ipshead_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102579
 
44      ProductCategoriesMasterList     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Product Categories Master List</title>\n <name>ProductCategoriesMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>select prodcat_code, prodcat_descrip\n  from prodcat\norder by prodcat_code;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Product Category</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Product Categories Master List</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Product Category</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prodcat_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prodcat_descrip</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102580
 
298     ProjectTaskList \N      <!DOCTYPE openRPTDef>\n<report>\n <title>ProjectTaskList</title>\n <name>ProjectTaskList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT prjtask_number, prjtask_name, prjtask_descrip,\n       CASE WHEN (prjtask_status='P') THEN 'Planning'\n\t  WHEN (prjtask_status='O') THEN 'In-Process'\n\t  ELSE 'Completed' END as status,\n       formatDate(prjtask_start_date) as f_start,\n       formatDate(prjtask_due_date) as f_due,\n       formatDate(prjtask_assigned_date) as f_assigned,\n       formatDate(prjtask_completed_date) as f_completed\n  FROM prjtask\n WHERE (prjtask_prj_id=&lt;?value("prj_id")?>)\n ORDER BY prjtask_number;</sql>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT (prj_number||'-'||prj_name) AS project\n  FROM prj\n WHERE (prj_id=&lt;? value("prj_id") ?>);</sql>\n </querysource>\n <rpthead>\n  <height>102</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>80</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>50</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Project:</string>\n  </label>\n  <field>\n   <rect>\n    <x>70</x>\n    <y>50</y>\n    <width>450</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>project</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>355</x>\n    <y>80</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>140</x>\n    <y>80</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>95</ystart>\n   <xend>745</xend>\n   <yend>95</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Project Task List</string>\n  </label>\n </rpthead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>43</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prjtask_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>18</y>\n     <width>70</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_start</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>225</x>\n     <y>18</y>\n     <width>70</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_assigned</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>375</x>\n     <y>18</y>\n     <width>70</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_due</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>525</x>\n     <y>18</y>\n     <width>70</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_completed</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>460</x>\n     <y>18</y>\n     <width>60</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Completed:</string>\n   </label>\n   <label>\n    <rect>\n     <x>5</x>\n     <y>18</y>\n     <width>60</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Start Date:</string>\n   </label>\n   <label>\n    <rect>\n     <x>310</x>\n     <y>18</y>\n     <width>60</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Due Date:</string>\n   </label>\n   <label>\n    <rect>\n     <x>160</x>\n     <y>18</y>\n     <width>60</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Assigned:</string>\n   </label>\n   <field>\n    <rect>\n     <x>140</x>\n     <y>-2</y>\n     <width>200</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prjtask_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>355</x>\n     <y>-2</y>\n     <width>385</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prjtask_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>18</y>\n     <width>90</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>status</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>615</x>\n     <y>18</y>\n     <width>45</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Status:</string>\n   </label>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102581
 
259     PurchaseOrderTypes      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Purchase Order Types</title>\n <name>PurchaseOrderTypes</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT potype_id,\n       potype_name,\n       potype_descrip\n  FROM potype\nORDER BY potype_name;</sql>\n </querysource>\n <rpthead>\n  <height>77</height>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purchase Order Types</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>22</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>potype_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>potype_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102582
 
145     PurchaseRequestsByItem  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Purchase Requests By Item</title>\n <name>PurchaseRequestsByItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       uom_name,\n       &lt;? if exists("warehous_id") ?>\n         (SELECT warehous_code\n            FROM whsinfo\n           WHERE warehous_id=&lt;? value("warehous_id") ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse\n  FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=&lt;? value("item_id") ?>);</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT pr_status,\n       pr_number || '-' || pr_subnumber AS pr_number,\n       CASE WHEN (pr_order_type='W') THEN ('W/O ' || ( SELECT formatWoNumber(womatl_wo_id)\n                                                       FROM womatl\n                                                       WHERE (womatl_id=pr_order_id) ) )\n            WHEN (pr_order_type='S') THEN ('S/O ' || (SELECT formatSoNumber(pr_order_id)))\n            WHEN (pr_order_type='F') THEN ('Planned Order')\n            WHEN (pr_order_type='M') THEN 'Manual'\n            ELSE 'Other'\n       END as f_type,\n       pr_createdate as f_createdate,\n       formatDate(pr_duedate) as f_duedate,\n       formatQty(pr_qtyreq) as f_qtyreq,\n        pr_releasenote as f_notes\n  FROM pr, itemsite \n WHERE ((pr_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=&lt;? value("item_id") ?>)\n&lt;? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n ) \nORDER BY pr_duedate;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>200</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>85</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>105</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>135</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>65</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>135</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>65</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <field>\n   <rect>\n    <x>355</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>uom_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purchase Requests By Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>65</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>200</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Purchase Request</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>457</x>\n    <y>198</y>\n    <width>80</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create Date</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>25</height>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>5</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>90</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Purchase Request</string>\n  </label>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>5</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>457</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create Date</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>39</height>\n   <field>\n    <rect>\n     <x>655</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>190</x>\n     <y>0</y>\n     <width>209</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_type</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>560</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>pr_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>105</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>pr_status</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>11</x>\n     <y>18</y>\n     <width>38</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>6</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Notes</string>\n   </label>\n   <text>\n    <rect>\n     <x>52</x>\n     <y>18</y>\n     <width>683</width>\n     <height>15</height>\n    </rect>\n    <bottompad>14</bottompad>\n    <font>\n     <face>Helvetica</face>\n     <size>6</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_notes</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>445</x>\n     <y>0</y>\n     <width>110</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_createdate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>15</height>\n  <field>\n   <rect>\n    <x>105</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102583
 
203     PurchaseReqsByPlannerCode       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Purchase Requests By Planner Code</title>\n <name>PurchaseReqsByPlannerCode</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;plancode_id&quot;) ?>\n         ( SELECT (plancode_code||'-'||plancode_name)\n             FROM plancode\n            WHERE plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)\n       &lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n         text(&lt;? value(&quot;plancode_pattern&quot;) ?>)\n       &lt;? else ?>\n         text('All Planner Codes')\n       &lt;? endif ?>\n       AS plancode,\n       &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       formatDate(&lt;? value(&quot;startDate&quot;) ?>) AS startdate,\n       formatDate(&lt;? value(&quot;endDate&quot;) ?>) AS enddate;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT item_number,\n       (item_descrip1 || ' ' || item_descrip2) as item_descrip,\n       pr_status,\n       CASE WHEN (pr_order_type='W') THEN ('W/O ' || ( SELECT formatWoNumber(womatl_wo_id)\n                                                         FROM womatl\n                                                        WHERE (womatl_id=pr_order_id) ) )\n            WHEN (pr_order_type='S') THEN ('S/O ' || (SELECT formatSoNumber(pr_order_id)))\n            WHEN (pr_order_type='F') THEN ('Planned Order')\n            WHEN (pr_order_type='M') THEN 'Manual'\n            ELSE 'Other'\n       END AS f_type,\n       formatDate(pr_duedate) AS f_duedate,\n       formatQty(pr_qtyreq) AS f_qtyreq\n  FROM pr, itemsite, item\n WHERE ((pr_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (pr_duedate BETWEEN &lt;? value(&quot;startDate&quot;) ?> and &lt;? value(&quot;endDate&quot;) ?>)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;plancode_id&quot;) ?>\n   AND (itemsite_plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)\n&lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n   AND (itemsite_plancode_id IN (SELECT plancode_id\n                                   FROM plancode\n                                  WHERE (plancode_code ~ &lt;? value(&quot;plancode_pattern&quot;) ?>) ) )\n&lt;? endif ?>\n)\nORDER BY pr_duedate;</sql>\n </querysource>\n <rpthead>\n  <height>171</height>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>150</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Order</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>65</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Planner Code:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>165</ystart>\n   <xend>745</xend>\n   <yend>165</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purchase Requests By Planner Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>150</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>150</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>65</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>plancode</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>85</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>135</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Order</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>135</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>340</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>pr_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_type</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>105</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102584
 
11      QOHByLocation   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Quantities on Hand by Location</title>\n <name>QOHByLocation</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT (location_name||'-'||firstLine(location_descrip)) AS f_location,\n       formatBoolYN(location_netable) AS f_netable,\n       formatBoolYN(location_restrict) AS f_restricted,\n       warehous_code,\n       formatDate(&lt;? value("asOf") ?>) AS asofdate\n  FROM location, whsinfo\n WHERE ((location_warehous_id=warehous_id)\n       AND (location_id=&lt;? value("location_id") ?>) );</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>qoh</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>234</height>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_code</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Lot/Serial #</string>\n  </label>\n  <label>\n   <rect>\n    <x>355</x>\n    <y>140</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Restricted:</string>\n  </label>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>435</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_restricted</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>10</y>\n    <width>410</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Quantities on Hand by Location</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>355</x>\n    <y>120</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Netable:</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>140</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_location</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>228</ystart>\n   <xend>745</xend>\n   <yend>228</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>200</y>\n    <width>230</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>215</y>\n    <width>230</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <field>\n   <rect>\n    <x>435</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_netable</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>120</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Location:</string>\n  </label>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>160</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>asofdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>160</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>As of:</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>213</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Reserved</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>5</y>\n    <width>230</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>325</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Lot/Serial #</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>20</y>\n    <width>230</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>230</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_lotserial</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>0</y>\n     <width>220</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>565</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>15</y>\n     <width>526</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qoh</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>14</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>reservedqty</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102585
 
172     Quote   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Quote</title>\n <name>Quote</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT quhead_number,\n       quhead_shipvia,\n       formatDate(quhead_quotedate) as f_orderdate,\n       formatDate(quhead_packdate) as f_packdate,\n       salesrep_name,\n       formatScrap(quhead_commission) as f_commission,\n       (terms_code||' - '||terms_descrip) as f_terms,\n       cust_number,\n       quhead_billtoname,\n       formatAddr(quhead_billtoaddress1,\n                  quhead_billtoaddress2,\n                  quhead_billtoaddress3,\n                 (quhead_billtocity || ', ' || quhead_billtostate || ' ' || quhead_billtozip),\n                  quhead_billtocountry) AS f_billtoaddress,\n       CASE WHEN(quhead_shipto_id=-1) THEN text('')\n            ELSE (SELECT text(shipto_num) FROM shiptoinfo WHERE (shipto_id=quhead_shipto_id))\n       END AS f_shiptonum,\n       quhead_shiptoname,\n       formatAddr(quhead_shiptoaddress1,\n                  quhead_shiptoaddress2,\n                  quhead_shiptoaddress3,\n                 (quhead_shiptocity || ', ' || quhead_shiptostate || ' ' || quhead_shiptozipcode),\n                  quhead_shiptocountry) AS f_shiptoaddress,\n       quhead_custponumber,\n       quhead_fob, saletype_code\nFROM quhead\n     LEFT OUTER JOIN custinfo ON (quhead_cust_id = cust_id)\n     LEFT OUTER JOIN terms ON (quhead_terms_id = terms_id)\n     LEFT OUTER JOIN salesrep ON (quhead_salesrep_id = salesrep_id)\n     LEFT OUTER JOIN saletype ON (quhead_saletype_id = saletype_id)\nWHERE (quhead_id = &lt;? value("quhead_id") ?>)\n</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT quhead_ordercomments,\n       quhead_shipcomments\n  FROM quhead\n WHERE (quhead_id=&lt;? value("quhead_id") ?>);</sql>\n </querysource>\n <querysource>\n  <name>items</name>\n  <sql>SELECT quitem_id,\n       quitem_linenumber,\n       quitem_custpn, \n       item_number,\n       item_descrip1,\n       --The following 2 lines are new in 2.3\n       (select uom_name from uom where uom_id = quitem_qty_uom_id) AS uom_ordered,\n       (select uom_name from uom where uom_id = quitem_price_uom_id) AS uom_pricing,\n       warehous_code,\n       formatQty(quitem_qtyord) as f_ordered,\n       formatPrice(quitem_price) as f_price,\n       --The following line was changed in 2.3 from:\n       --formatExtprice(quitem_qtyord * (quitem_price / iteminvpricerat(item_id))) as f_extprice\n       --To:\n       formatExtprice((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) as f_extprice,\n       quitem_memo,\n       char_name, \n       charass_value \nFROM quitem\n     JOIN item ON (item_id=quitem_item_id)\n     LEFT OUTER JOIN (itemsite JOIN whsinfo ON (itemsite_warehous_id=warehous_id)) ON (quitem_itemsite_id=itemsite_id)\n     LEFT OUTER JOIN charass ON ((charass_target_id = quitem_id) \n                            AND (charass_target_type = 'QI'))\n     LEFT OUTER JOIN char ON (charass_char_id = char_id)\nWHERE (quitem_quhead_id=&lt;? value("quhead_id") ?>) \nORDER BY quitem_linenumber;</sql>\n </querysource>\n <querysource>\n  <name>totals</name>\n  <sql>SELECT 1 as one,\n       formatExtPrice(subtotal) AS f_subtotal,\n       formatExtPrice(tax) AS f_tax,\n       formatExtPrice(quhead_freight) AS f_freight,\n       formatExtPrice(quhead_misc) AS f_misc,\n       formatExtPrice(subtotal + tax + quhead_freight + quhead_misc) AS f_total\n  FROM quhead,\n       (SELECT SUM(ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio),2)) AS subtotal\n          FROM quitem\n         WHERE (quitem_quhead_id=&lt;? value("quhead_id") ?>) ) AS subtot,\n       (SELECT COALESCE(SUM(tax),0.0) AS tax \n        FROM (\n          SELECT ROUND(SUM(taxdetail_tax),2) AS tax \n          FROM tax \n          JOIN calculateTaxDetailSummary('Q', &lt;? value("quhead_id") ?>, 'T') ON (taxdetail_tax_id=tax_id)\n\tGROUP BY tax_id) AS data) AS taxtot\n       \n\n\n WHERE (quhead_id=&lt;? value("quhead_id") ?>);\n</sql>\n </querysource>\n <querysource>\n  <name>logo</name>\n  <sql>SELECT image_data \nFROM image \nWHERE ((image_name='logo'));</sql>\n </querysource>\n <querysource>\n  <name>currency_info</name>\n  <sql>--this was added in version 2.3\nSELECT curr_name,\n       curr_symbol,\n       curr_abbr\nFROM quhead, curr_symbol\nWHERE ( (quhead_curr_id = curr_id)\n  AND   (quhead_id = &lt;? value("quhead_id") ?>) );</sql>\n </querysource>\n <querysource>\n  <name>address</name>\n  <sql>SELECT warehous_descrip,\n       formatAddr(addr_line1,\n                  addr_line2,\n                  addr_line3,\n                 (addr_city || '  ' || addr_state || '  ' || addr_postalcode),\n                  addr_country) AS warehouse_address\nFROM whsinfo, \n     addr, \n     quhead\nWHERE ( (addr_id = warehous_addr_id)\n  AND   (quhead_warehous_id = warehous_id)\n  AND   (quhead_id=&lt;? value("quhead_id") ?>) );</sql>\n </querysource>\n <querysource>\n  <name>contact_fax_phone</name>\n  <sql>SELECT cntct_fax,\n       cntct_phone\nFROM cntct, quhead, custinfo\nWHERE ( (cust_id = quhead_cust_id)\n  AND   (cust_cntct_id = cntct_id)\n  AND   (quhead_id = &lt;? value("quhead_id") ?>) );\n</sql>\n </querysource>\n <rpthead>\n  <height>427</height>\n  <image>\n   <rect>\n    <x>275</x>\n    <y>5</y>\n    <width>238</width>\n    <height>100</height>\n   </rect>\n   <mode>stretch</mode>\n   <data>\n    <query>logo</query>\n    <column>image_data</column>\n   </data>\n  </image>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>25</y>\n    <width>265</width>\n    <height>15</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>address</query>\n    <column>warehouse_address</column>\n   </data>\n  </text>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>175</y>\n    <width>206</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>440</x>\n    <y>215</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>quhead_shiptoname</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>145</y>\n    <width>103</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Pack Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>55</x>\n    <y>325</y>\n    <width>121</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>contact_fax_phone</query>\n    <column>cntct_phone</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>160</y>\n    <width>103</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Terms:</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>5</y>\n    <width>126</width>\n    <height>42</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Quote</string>\n  </label>\n  <field>\n   <rect>\n    <x>55</x>\n    <y>215</y>\n    <width>285</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>quhead_billtoname</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>208</x>\n    <y>325</y>\n    <width>121</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>contact_fax_phone</query>\n    <column>cntct_fax</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>440</x>\n    <y>190</y>\n    <width>206</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_shiptonum</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>130</y>\n    <width>206</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>quhead_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>155</x>\n    <y>415</y>\n    <width>103</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>415</y>\n    <width>103</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Extended Price</string>\n  </label>\n  <field>\n   <rect>\n    <x>440</x>\n    <y>145</y>\n    <width>103</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_packdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>190</y>\n    <width>103</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ship-To #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>390</x>\n    <y>350</y>\n    <width>103</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ship Via:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>160</y>\n    <width>206</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>saletype_code</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>415</y>\n    <width>112</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty Ordered, UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>215</y>\n    <width>52</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bill To:</string>\n  </label>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>130</y>\n    <width>103</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>415</y>\n    <width>50</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Line #</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>325</y>\n    <width>52</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Fax:</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>350</y>\n    <width>103</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer PO #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>145</y>\n    <width>206</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>salesrep_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>415</y>\n    <width>103</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price, UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>175</y>\n    <width>103</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>325</y>\n    <width>52</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Phone:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>130</y>\n    <width>103</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>215</y>\n    <width>56</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ship To:</string>\n  </label>\n  <field>\n   <rect>\n    <x>440</x>\n    <y>130</y>\n    <width>103</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_orderdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>160</y>\n    <width>103</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sale Type:</string>\n  </label>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>415</y>\n    <width>103</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>415</y>\n    <width>50</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>145</y>\n    <width>103</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sales Rep.:</string>\n  </label>\n  <field>\n   <rect>\n    <x>505</x>\n    <y>350</y>\n    <width>206</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>quhead_shipvia</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>370</y>\n    <width>206</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>quhead_fob</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>370</y>\n    <width>103</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>F.O.B.:</string>\n  </label>\n  <field>\n   <rect>\n    <x>440</x>\n    <y>160</y>\n    <width>262</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_terms</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>55</x>\n    <y>233</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_billtoaddress</column>\n   </data>\n  </text>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>350</y>\n    <width>206</width>\n    <height>21</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>quhead_custponumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>257</width>\n    <height>19</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>address</query>\n    <column>warehous_descrip</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>440</x>\n    <y>233</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_shiptoaddress</column>\n   </data>\n  </text>\n </rpthead>\n <section>\n  <name>lineitems</name>\n  <group>\n   <name>lineitems</name>\n   <column>quitem_linenumber</column>\n   <head>\n    <height>32</height>\n    <field>\n     <rect>\n      <x>155</x>\n      <y>0</y>\n      <width>225</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>items</query>\n      <column>item_descrip1</column>\n     </data>\n    </field>\n    <line>\n     <xstart>5</xstart>\n     <ystart>0</ystart>\n     <xend>783</xend>\n     <yend>0</yend>\n     <weight>2</weight>\n    </line>\n    <field>\n     <rect>\n      <x>665</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>items</query>\n      <column>f_extprice</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>385</x>\n      <y>15</y>\n      <width>125</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Option Description:</string>\n    </label>\n    <field>\n     <rect>\n      <x>5</x>\n      <y>0</y>\n      <width>25</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>items</query>\n      <column>quitem_linenumber</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>385</x>\n      <y>0</y>\n      <width>50</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>items</query>\n      <column>warehous_code</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>640</x>\n      <y>0</y>\n      <width>37</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>items</query>\n      <column>uom_pricing</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>525</x>\n      <y>0</y>\n      <width>37</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>items</query>\n      <column>uom_ordered</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>155</x>\n      <y>15</y>\n      <width>85</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Options:</string>\n    </label>\n    <field>\n     <rect>\n      <x>45</x>\n      <y>0</y>\n      <width>103</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>items</query>\n      <column>item_number</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>565</x>\n      <y>0</y>\n      <width>72</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>items</query>\n      <column>f_price</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>440</x>\n      <y>0</y>\n      <width>77</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>items</query>\n      <column>f_ordered</column>\n     </data>\n    </field>\n   </head>\n   <foot>\n    <height>33.8828</height>\n    <label>\n     <rect>\n      <x>155</x>\n      <y>0</y>\n      <width>130</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Additional Description:</string>\n    </label>\n    <text>\n     <rect>\n      <x>290</x>\n      <y>0</y>\n      <width>454.347</width>\n      <height>13.2412</height>\n     </rect>\n     <bottompad>10</bottompad>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <data>\n      <query>items</query>\n      <column>quitem_memo</column>\n     </data>\n    </text>\n    <label>\n     <rect>\n      <x>196.342</x>\n      <y>15.3707</y>\n      <width>85.6497</width>\n      <height>15.665</height>\n     </rect>\n     <font>\n      <face>Sans Serif</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <top/>\n     <string>Customer P/N:</string>\n    </label>\n    <text>\n     <rect>\n      <x>289.596</x>\n      <y>15.5884</y>\n      <width>199</width>\n      <height>17.1</height>\n     </rect>\n     <bottompad>0</bottompad>\n     <font>\n      <face>Sans Serif</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <data>\n      <query>items</query>\n      <column>quitem_custpn</column>\n     </data>\n    </text>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>items</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>385</x>\n     <y>0</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>items</query>\n     <column>charass_value</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>208</x>\n     <y>0</y>\n     <width>165</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>items</query>\n     <column>char_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>items</name>\n  <group>\n   <name>items</name>\n   <column>one</column>\n   <foot>\n    <height>87</height>\n    <label>\n     <rect>\n      <x>565</x>\n      <y>50</y>\n      <width>103</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Tax:</string>\n    </label>\n    <field>\n     <rect>\n      <x>670</x>\n      <y>65</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>totals</query>\n      <column>f_total</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>565</x>\n      <y>35</y>\n      <width>103</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Freight:</string>\n    </label>\n    <field>\n     <rect>\n      <x>670</x>\n      <y>50</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>totals</query>\n      <column>f_tax</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>565</x>\n      <y>20</y>\n      <width>103</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Misc. Charges:</string>\n    </label>\n    <field>\n     <rect>\n      <x>670</x>\n      <y>35</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>totals</query>\n      <column>f_freight</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>670</x>\n      <y>20</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>totals</query>\n      <column>f_misc</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>565</x>\n      <y>5</y>\n      <width>103</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Sub-Total:</string>\n    </label>\n    <label>\n     <rect>\n      <x>565</x>\n      <y>65</y>\n      <width>103</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total:</string>\n    </label>\n    <label>\n     <rect>\n      <x>10</x>\n      <y>10</y>\n      <width>208</width>\n      <height>18</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Note, this quotation is priced in:</string>\n    </label>\n    <field>\n     <rect>\n      <x>204</x>\n      <y>10</y>\n      <width>206</width>\n      <height>18</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>10</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>currency_info</query>\n      <column>curr_name</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>670</x>\n      <y>5</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>totals</query>\n      <column>f_subtotal</column>\n     </data>\n    </field>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>items</query>\n   </key>\n   <height>7</height>\n  </detail>\n </section>\n <section>\n  <name>notes</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>32</height>\n   <label>\n    <rect>\n     <x>10</x>\n     <y>5</y>\n     <width>132</width>\n     <height>18</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Order Comments:</string>\n   </label>\n   <text>\n    <rect>\n     <x>155</x>\n     <y>5</y>\n     <width>591</width>\n     <height>18</height>\n    </rect>\n    <bottompad>5</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>notes</query>\n     <column>quhead_ordercomments</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <section>\n  <name>extdescrip</name>\n  <detail>\n   <key>\n    <query>notes</query>\n   </key>\n   <height>32</height>\n   <label>\n    <rect>\n     <x>10</x>\n     <y>5</y>\n     <width>132</width>\n     <height>18</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Shipping Comments:</string>\n   </label>\n   <text>\n    <rect>\n     <x>155</x>\n     <y>5</y>\n     <width>591</width>\n     <height>21</height>\n    </rect>\n    <bottompad>5</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>notes</query>\n     <column>quhead_shipcomments</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>29</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>42</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>103</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>103</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Quote Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>103</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102586
 
278     ReasonCodeMasterList    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Reason Code Master List</title>\n <name>ReasonCodeMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT rsncode_code, rsncode_descrip\n   FROM rsncode\nORDER BY rsncode_code;</sql>\n </querysource>\n <rpthead>\n  <height>77</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Reason Code Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>22</height>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>rsncode_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>rsncode_descrip</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102587
 
181     ReceiptsReturnsByDate   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Receipts and Returns By Date</title>\n <name>ReceiptsReturnsByDate</name>\n <description></description>\n <grid>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("warehous_id") ?>\n         (SELECT warehous_code FROM whsinfo WHERE warehous_id=&lt;? value("warehous_id") ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("agentUsername") ?>\n       TEXT(&lt;? value("agentUsername" ?>)\n       &lt;? else ?>\n       TEXT('All Agents')\n       &lt;? endif ?>\n       AS agentUsername,\n       &lt;? if exists("showVariances") ?>\n         text('Purch. Cost') AS f_purchcost,\n         text('Recv. Cost') AS f_recvcost\n       &lt;? else ?>\n         text('') AS f_purchcost,\n         text('') AS f_recvcost\n       &lt;? endif ?></sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>receivings</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>200</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>195</x>\n    <y>10</y>\n    <width>530</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Receipts and Returns By Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_purchcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>418</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Rcvd/Rtnd</string>\n  </label>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_recvcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>70</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Recv. Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>95</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sched. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>70</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>95</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>agentUsername</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>95</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purch. Agent:</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>95</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>418</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Rcvd/Rtnd</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sched. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Recv. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>5</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>20</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_recvcost</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_purchcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>21</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>venditemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_recvcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>15</y>\n     <width>400</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>venditemdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_purchcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_recvdate</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>418</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sense</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102588
 
182     ReceiptsReturnsByItem   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Receipts and Returns By Item</title>\n <name>ReceiptsReturnsByItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("warehous_id") ?>\n         (SELECT warehous_code FROM whsinfo WHERE warehous_id=&lt;? value("warehous_id") ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("agentUsername") ?>\n       TEXT(&lt;? value("agentUsername" ?>)\n       &lt;? else ?>\n       TEXT('All Agents')\n       &lt;? endif ?>\n       AS agentUsername,\n       &lt;? if exists("showVariances") ?>\n         text('Purch. Cost') AS f_purchcost,\n         text('Recv. Cost') AS f_recvcost\n       &lt;? else ?>\n         text('') AS f_purchcost,\n         text('') AS f_recvcost\n       &lt;? endif ?>\n  FROM item\n WHERE (item_id=&lt;? value("item_id") ?>);</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>receivings</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sched. Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>155</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>agentUsername</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>155</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purch. Agent:</string>\n  </label>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_purchcost</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_recvcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>418</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Rcvd/Rtnd</string>\n  </label>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>200</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>195</x>\n    <y>10</y>\n    <width>530</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Receipts and Returns By Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>70</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>70</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>110</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vend. Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>90</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>135</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Recv. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>135</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_recvcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sched. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Recv. Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_purchcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>20</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>418</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Rcvd/Rtnd</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>5</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vend. Item Number</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>37</height>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>venditemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_recvdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>15</y>\n     <width>400</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>venditemdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>418</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sense</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_recvcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_purchcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qty</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>30</ystart>\n    <xend>745</xend>\n    <yend>30</yend>\n    <weight>0</weight>\n   </line>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102589
 
183     ReceiptsReturnsByVendor \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Receipts and Returns By Vendor</title>\n <name>ReceiptsReturnsByVendor</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT vend_name,\n       vend_number,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("warehous_id") ?>\n         (SELECT warehous_code FROM whsinfo WHERE warehous_id=&lt;? value("warehous_id") ?>)\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("agentUsername") ?>\n       TEXT(&lt;? value("agentUsername" ?>)\n       &lt;? else ?>\n       TEXT('All Agents')\n       &lt;? endif ?>\n       AS agentUsername,\n       &lt;? if exists("showVariances") ?>\n         text('Purch. Cost') AS f_purchcost,\n         text('Recv. Cost') AS f_recvcost\n       &lt;? else ?>\n         text('') AS f_purchcost,\n         text('') AS f_recvcost\n       &lt;? endif ?>\nFROM vendinfo\nWHERE (vend_id=&lt;? value("vend_id") ?>);</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>receivings</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>70</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor:</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>90</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>200</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>70</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>418</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Rcvd/Rtnd</string>\n  </label>\n  <label>\n   <rect>\n    <x>195</x>\n    <y>10</y>\n    <width>530</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Receipts and Returns By Vendor</string>\n  </label>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Recv. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>140</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purch. Agent:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>112</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_purchcost</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_recvcost</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>agentUsername</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>112</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sched. Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Recv. Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_recvcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>20</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>418</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Rcvd/Rtnd</string>\n  </label>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_purchcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>5</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sched. Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_purchcost</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>15</y>\n     <width>400</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>venditemdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_recvcost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>venditemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>418</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sense</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_recvdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>85</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102590
 
418     ReceivingLabel  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Receiving Label</title>\n <name>ReceivingLabel</name>\n <description></description>\n <parameter default="" active="false" listtype="static" type="integer" name="daysback" >\n  <description>must be a positive number or 0. used to specify how many day back from today the report takes into account when printing recieving labels</description>\n </parameter>\n <parameter default="" active="false" listtype="static" type="string" name="itemstring" >\n  <description>Item Number - Used to filter the item numbers by the first matching characters from the left of the string</description>\n </parameter>\n <parameter default="" active="false" listtype="static" type="integer" name="labelto" >\n  <description>used to specify the number of repeated sets of labels required</description>\n </parameter>\n <parameter default="" active="false" listtype="static" type="string" name="pohead_id" >\n  <description>used with the pirnt receiving label form</description>\n </parameter>\n <parameter default="" active="false" listtype="static" type="integer" name="ponumber" >\n  <description>used to filter the report by a PO number</description>\n </parameter>\n <labeltype>CILS ALP1-9200-1</labeltype>\n <size>Labels</size>\n <portrait/>\n <topmargin>10</topmargin>\n <bottommargin>0</bottommargin>\n <rightmargin>0</rightmargin>\n <leftmargin>10</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT formatDate(current_date) AS date, \n       COALESCE(item_number,poitem_vend_item_number) AS item_number, \n       COALESCE(item_descrip1, poitem_vend_item_descrip) AS item_descrip1,\n       &lt;? value("vendorItemLit") ?> AS vendoritemlit,\n       poitem_vend_item_number, \n       &lt;? value("ordertype") ?> || '#:' AS typenum,\n       pohead_number AS head_number   \n  FROM pohead, poitem  \n    LEFT OUTER JOIN itemsite ON (itemsite_id = poitem_itemsite_id)\n    LEFT OUTER JOIN item  ON (item_id = itemsite_item_id)  \n  WHERE ((pohead_id = poitem_pohead_id)\n    AND (poitem_id = &lt;? value("orderitemid") ?>)\n    AND ('PO' = &lt;? value("ordertype") ?>))\nUNION\nSELECT formatDate(current_date) AS date, \n       item_number AS item_number, \n       item_descrip1 AS item_descrip1,\n       NULL, NULL, \n       &lt;? value("ordertype") ?> || '#:' AS typenum,\n       rahead_number AS head_number\n  FROM rahead, raitem  \n    JOIN itemsite ON (itemsite_id = raitem_itemsite_id)\n    JOIN item  ON (item_id = itemsite_item_id)  \n  WHERE ((rahead_id = raitem_rahead_id)\n    AND (raitem_id = &lt;? value("orderitemid") ?>)\n    AND ('RA' = &lt;? value("ordertype") ?>))\nUNION\nSELECT formatDate(current_date) AS date, \n       item_number AS item_number, \n       item_descrip1 AS item_descrip1,\n       NULL, NULL, \n       &lt;? value("ordertype") ?> || '#:' AS typenum,\n       tohead_number AS head_number\n  FROM tohead, toitem  \n    JOIN item  ON (item_id = toitem_item_id)  \n  WHERE ((tohead_id = toitem_tohead_id)\n    AND (toitem_id = &lt;? value("orderitemid") ?>)\n    AND ('TO' = &lt;? value("ordertype") ?>))</sql>\n </querysource>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>698</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>5</y>\n     <width>190</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>5</x>\n     <y>20</y>\n     <width>175</width>\n     <height>10</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>7</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>80</x>\n     <y>50</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_vend_item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>35</x>\n     <y>65</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>head_number</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>85</x>\n     <y>65</y>\n     <width>25</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Date:</string>\n   </label>\n   <field>\n    <rect>\n     <x>115</x>\n     <y>65</y>\n     <width>65</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>65</y>\n     <width>25</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>typenum</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>50</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vendoritemlit</column>\n    </data>\n   </field>\n  </detail>\n </section>\n</report>\n          0       2014-10-06 19:47:03.678943
102591
 
462     ReceivingLabelOrder     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Receiving Label Order</title>\n <name>ReceivingLabelOrder</name>\n <description></description>\n <parameter default="" active="false" listtype="static" type="integer" name="daysback">\n  <description>must be a positive number or 0. used to specify how many day back from today the report takes into account when printing recieving labels</description>\n </parameter>\n <parameter default="" active="false" listtype="static" type="string" name="itemstring">\n  <description>Item Number - Used to filter the item numbers by the first matching characters from the left of the string</description>\n </parameter>\n <parameter default="" active="false" listtype="static" type="integer" name="labelto">\n  <description>used to specify the number of repeated sets of labels required</description>\n </parameter>\n <parameter default="" active="false" listtype="static" type="string" name="pohead_id">\n  <description>used with the pirnt receiving label form</description>\n </parameter>\n <parameter default="" active="false" listtype="static" type="integer" name="ponumber">\n  <description>used to filter the report by a PO number</description>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <labeltype>CILS ALP1-9200-1</labeltype>\n <size>Labels</size>\n <portrait/>\n <topmargin>10</topmargin>\n <bottommargin>0</bottommargin>\n <rightmargin>0</rightmargin>\n <leftmargin>10</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT formatDate(current_date) AS date, \n       COALESCE(item_number,poitem_vend_item_number) AS item_number, \n       COALESCE(item_descrip1, poitem_vend_item_descrip) AS item_descrip1,\n       &lt;? value("vendorItemLit") ?> AS vendoritemlit,\n       poitem_vend_item_number, \n       &lt;? value("orderhead_type") ?> || '#:' AS typenum,\n       pohead_number AS head_number   \n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n    LEFT OUTER JOIN itemsite ON (itemsite_id = poitem_itemsite_id)\n    LEFT OUTER JOIN item  ON (item_id = itemsite_item_id)  \n  WHERE ((pohead_id = &lt;? value("orderhead_id") ?>)\n    AND ('PO' = &lt;? value("orderhead_type") ?>))\nUNION\nSELECT formatDate(current_date) AS date, \n       item_number AS item_number, \n       item_descrip1 AS item_descrip1,\n       NULL, NULL, \n       &lt;? value("orderhead_type") ?> || '#:' AS typenum,\n       rahead_number AS head_number\n  FROM rahead\n    JOIN raitem ON (raitem_rahead_id = rahead_id)\n    JOIN itemsite ON (itemsite_id = raitem_itemsite_id)\n    JOIN item  ON (item_id = itemsite_item_id)  \n  WHERE ((rahead_id =  &lt;? value("orderhead_id") ?>)\n    AND ('RA' = &lt;? value("orderhead_type") ?>))\nUNION\nSELECT formatDate(current_date) AS date, \n       item_number AS item_number, \n       item_descrip1 AS item_descrip1,\n       NULL, NULL, \n       &lt;? value("orderhead_type") ?> || '#:' AS typenum,\n       tohead_number AS head_number\n  FROM tohead\n    JOIN toitem ON (toitem_tohead_id = tohead_id)\n    JOIN item  ON (item_id = toitem_item_id)  \n  WHERE ((tohead_id =  &lt;? value("orderhead_id") ?>)\n    AND ('TO' = &lt;? value("orderhead_type") ?>))</sql>\n </querysource>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>698</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>5</y>\n     <width>190</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>5</x>\n     <y>20</y>\n     <width>175</width>\n     <height>10</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>7</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>80</x>\n     <y>50</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_vend_item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>35</x>\n     <y>65</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>head_number</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>85</x>\n     <y>65</y>\n     <width>25</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Date:</string>\n   </label>\n   <field>\n    <rect>\n     <x>115</x>\n     <y>65</y>\n     <width>65</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>65</y>\n     <width>25</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>typenum</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>50</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Helvetica</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vendoritemlit</column>\n    </data>\n   </field>\n  </detail>\n </section>\n</report>\n               0       2014-10-06 19:47:03.678943
102592
 
140     RejectCodeMasterList    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Reject Code Master List</title>\n <name>RejectCodeMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT rjctcode_code, rjctcode_descrip\n   FROM rjctcode\nORDER BY rjctcode_code;</sql>\n </querysource>\n <rpthead>\n  <height>77</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Reject Code Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>22</height>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>rjctcode_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>rjctcode_descrip</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102593
 
105     ReportsMasterList       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Reports Master List</title>\n <name>ReportsMasterList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>reports</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Reports Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>-1</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>-1</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>80</x>\n     <y>2</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>report_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>0</x>\n     <y>2</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>pkgname</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>265</x>\n     <y>2</y>\n     <width>475</width>\n     <height>15</height>\n    </rect>\n    <bottompad>1</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>report_descrip_qttooltiprole</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>1</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>1</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102594
 
137     RunningAvailability     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Running Availability</title>\n <name>RunningAvailability</name>\n <description>Updated in 2.3 to show order number and item code on higherlevel planned work orders.</description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       uom_name,\n       warehous_code AS warehouse,\n       &lt;? if exists("showPlanned") ?>\n         text('Yes')\n       &lt;? else ?>\n         text('No')\n       &lt;? endif ?>\n       AS showplnord\n  FROM item, uom, whsinfo\n WHERE ((item_id=&lt;? value("item_id") ?>)\n   AND (item_inv_uom_id=uom_id)\n   AND (warehous_id=&lt;? value("warehous_id") ?>))</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>runningAvailability</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <querysource>\n  <name>info</name>\n  <sql>SELECT\n       formatQty(qtyAvailable(itemsite_id)) AS qoh,\n       formatQty(CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END) AS reorderlevel,\n       formatQty(CASE WHEN(itemsite_useparams) THEN itemsite_ordertoqty ELSE 0.0 END) AS ordertoqty,\n       formatQty(CASE WHEN(itemsite_useparams) THEN itemsite_multordqty ELSE 0.0 END) AS multorderqty \nFROM itemsite \nWHERE ((itemsite_item_id=&lt;? value("item_id") ?>)\n AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>));</sql>\n </querysource>\n <rpthead>\n  <height>238</height>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>215</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>125</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>75</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>95</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>467</x>\n    <y>125</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Reorder Level:</string>\n  </label>\n  <label>\n   <rect>\n    <x>467</x>\n    <y>145</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Order up to Qty.:</string>\n  </label>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>595</x>\n    <y>145</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>info</query>\n    <column>ordertoqty</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>365</x>\n    <y>125</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>info</query>\n    <column>qoh</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>555</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>310</x>\n    <y>125</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>QOH:</string>\n  </label>\n  <field>\n   <rect>\n    <x>305</x>\n    <y>55</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>uom_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>75</y>\n    <width>160</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show Planned Orders:</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Running Availability</string>\n  </label>\n  <field>\n   <rect>\n    <x>595</x>\n    <y>125</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>info</query>\n    <column>reorderlevel</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>595</x>\n    <y>75</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>showplnord</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>228</ystart>\n   <xend>740</xend>\n   <yend>228</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>55</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>145</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Order Multiple:</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Running Availability</string>\n  </label>\n  <field>\n   <rect>\n    <x>365</x>\n    <y>145</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>info</query>\n    <column>multorderqty</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Type/#</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>55</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>467</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>125</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>12</height>\n </pghead>\n <pghead>\n  <height>28</height>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>5</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order Type/#</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Running Availability</string>\n  </label>\n  <label>\n   <rect>\n    <x>555</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>467</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>22</height>\n   <field>\n    <rect>\n     <x>90</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ordernumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>285</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ordertype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>555</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>385</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>balance</column>\n    </data>\n    <format builtin="true">qty</format>\n    <tracktotal/>\n   </field>\n   <field>\n    <rect>\n     <x>467</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyreceived</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>22</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>102</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n       Updated in 2.3 to show order number and item code on higherlevel planned work orders.   0       2014-10-06 19:47:03.678943
102595
 
73      ShippingZonesMasterList \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Shipping Zones Master List</title>\n <name>ShippingZonesMasterList</name>\n <description></description>\n <size>\n  <width>850</width>\n  <height>1100</height>\n </size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>select shipzone_name, shipzone_descrip\n  from shipzone\norder by shipzone_name;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipping Zones Master List</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipzone_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipzone_descrip</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102596
 
49      SingleLevelBOM  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Single Level Bill of Materials</title>\n <name>SingleLevelBOM</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number, uom_name AS item_invuom, item_descrip1, item_descrip2\nFROM item, uom\nWHERE ((item_id=&lt;? value("item_id") ?>)\nAND (item_inv_uom_id=uom_id));\n    </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT bomitem_seqnumber, item_number,\n       invuom.uom_name AS invuomname, issueuom.uom_name AS issueuomname,\n       item_descrip1, item_descrip2,\n       formatBoolYN(bomitem_createwo) AS createchild,\n       CASE WHEN (bomitem_issuemethod='S') THEN 'Push'\n            WHEN (bomitem_issuemethod='L') THEN 'Pull'\n            WHEN (bomitem_issuemethod='M') THEN 'Mixed'\n            ELSE 'Special'\n       END AS issuemethod,\n       formatQty(bomitem_qtyfxd) AS issueqtyfxd,\n       formatQty(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyfxd)) AS invqtyfxd,\n       formatQtyPer(bomitem_qtyper) AS issueqtyper,\n       formatQtyPer(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper)) AS invqtyper,\n       formatScrap(bomitem_scrap) AS scrap,\n       formatQtyPer((bomitem_qtyfxd + bomitem_qtyper) * (1 + bomitem_scrap)) AS qtyreq,\n       formatDate(bomitem_effective, &lt;? value("always") ?>) AS effective,\n       formatDate(bomitem_expires, &lt;? value("never") ?>) AS expires,\n       bomitem_ecn\n&lt;? if exists("revision_id") ?>\n  FROM bomitem(&lt;? value("item_id") ?>,&lt;? value("revision_id") ?>)\n&lt;? else ?>\n  FROM bomitem(&lt;? value("item_id") ?>)\n&lt;? endif ?>\n, item, uom AS issueuom, uom AS invuom\nWHERE ((bomitem_item_id=item_id)\nAND (item_inv_uom_id=invuom.uom_id)\nAND (bomitem_uom_id=issueuom.uom_id)\n&lt;? if exists("expiredDays") ?>\n AND (bomitem_expires > (CURRENT_DATE - &lt;? value("expiredDays") ?>))\n&lt;? else ?>\n AND (bomitem_expires > CURRENT_DATE)\n&lt;? endif ?>\n\n&lt;? if exists("effectiveDays") ?>\n AND (bomitem_effective &lt;= (CURRENT_DATE + &lt;? value("effectiveDays") ?>))\n&lt;? else ?>\n AND (bomitem_effective &lt;= CURRENT_DATE)\n&lt;? endif ?>\n\n)\nORDER BY bomitem_seqnumber, bomitem_effective;\n</sql>\n </querysource>\n <querysource>\n  <name>bomhead</name>\n  <sql>SELECT bomhead_docnum, bomhead_revision,\n       formatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=&lt;? value("item_id") ?>)\n&lt;? if exists("revision_id") ?>\nAND (bomhead_rev_id=&lt;? value("revision_id") ?>)\n&lt;? else ?>\nAND (bomhead_rev_id=getActiveRevId('BOM',&lt;? value("item_id") ?>))\n&lt;? endif ?>\n);</sql>\n </querysource>\n <rpthead>\n  <height>208</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>175</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>395</x>\n    <y>176</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>110</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>90</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>190</y>\n    <width>130</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>175</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>470</x>\n    <y>186</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>ECN #</string>\n  </label>\n  <field>\n   <rect>\n    <x>482</x>\n    <y>130</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_revision</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>186</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>175</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Required</string>\n  </label>\n  <label>\n   <rect>\n    <x>380</x>\n    <y>90</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Document #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>380</x>\n    <y>110</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>175</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>175</y>\n    <width>227</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>186</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <label>\n   <rect>\n    <x>442</x>\n    <y>175</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>380</x>\n    <y>130</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision:</string>\n  </label>\n  <field>\n   <rect>\n    <x>482</x>\n    <y>110</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>f_revisiondate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>482</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_docnum</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>186</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv. Qty. Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>16</y>\n    <width>350</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Single Level Bill of Materials</string>\n  </label>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>130</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>202</ystart>\n   <xend>745</xend>\n   <yend>202</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>176</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Qty. Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>395</x>\n    <y>186</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv. UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>235</x>\n    <y>176</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Fxd. Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>235</x>\n    <y>186</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv. Fxd. Qty.</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>470</x>\n    <y>13</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>ECN #</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>13</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Required</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>13</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv. UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>13</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>442</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>15</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>13</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv. Qty. Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>-2</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Qty. Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>-2</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>-2</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Fxd. Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>13</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inv. Fxd. Qty.</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>57</height>\n   <field>\n    <rect>\n     <x>405</x>\n     <y>18</y>\n     <width>37</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invuomname</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>675</x>\n     <y>18</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>issuemethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>675</x>\n     <y>3</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>expires</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>440</x>\n     <y>3</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>15</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bomitem_seqnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>33</y>\n     <width>227</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>18</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invqtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>0</y>\n     <width>115</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>3</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>effective</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>455</x>\n     <y>18</y>\n     <width>135</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bomitem_ecn</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>525</x>\n     <y>3</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>18</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>createchild</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>33</y>\n     <width>227</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>3</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>issueqtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>405</x>\n     <y>3</y>\n     <width>37</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>issueuomname</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>235</x>\n     <y>3</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>issueqtyfxd</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>235</x>\n     <y>18</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invqtyfxd</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>21</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102597
 
71      SalesAccountAssignmentsMasterList       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Sales Account Assignments Master List</title>\n <name>SalesAccountAssignmentsMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT salesaccnt_id,\n       CASE WHEN salesaccnt_warehous_id=-1 THEN 'Any'::TEXT\n            ELSE (SELECT warehous_code FROM whsinfo WHERE (warehous_id=salesaccnt_warehous_id))\n       END AS warehouscode,\n       CASE WHEN salesaccnt_custtype_id=-1 THEN salesaccnt_custtype\n            ELSE (SELECT custtype_code FROM custtype WHERE (custtype_id=salesaccnt_custtype_id))\n       END AS custtypecode,\n       CASE WHEN salesaccnt_prodcat_id=-1 THEN salesaccnt_prodcat\n            ELSE (SELECT prodcat_code FROM prodcat WHERE (prodcat_id=salesaccnt_prodcat_id))\n       END AS prodcatcode,\n       formatGLAccount(salesaccnt_sales_accnt_id) AS salesaccnt,\n       formatGLAccount(salesaccnt_credit_accnt_id) AS creditaccnt,\n       formatGLAccount(salesaccnt_cos_accnt_id) AS costaccnt,\n       formatGLAccount(salesaccnt_returns_accnt_id) AS returnsaccnt,\n       formatGLAccount(salesaccnt_cor_accnt_id) AS coraccnt,\n       formatGLAccount(salesaccnt_cow_accnt_id) AS cowaccnt\n  FROM salesaccnt\nORDER BY warehouscode, custtypecode, prodcatcode;</sql>\n </querysource>\n <rpthead>\n  <height>87</height>\n  <line>\n   <xstart>0</xstart>\n   <ystart>81</ystart>\n   <xend>740</xend>\n   <yend>81</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>66</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Credit Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>230</x>\n    <y>66</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sales Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>10</y>\n    <width>530</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sales Account Assignments Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>66</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Type:</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>66</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>COS Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>155</x>\n    <y>66</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Product Cat:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>65</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>66</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Returns Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>570</x>\n    <y>66</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>COR Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>66</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>COW Accnt:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>27</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>3</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>3</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Type:</string>\n  </label>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>3</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Product Cat:</string>\n  </label>\n  <label>\n   <rect>\n    <x>230</x>\n    <y>3</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sales Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>3</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Credit Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>3</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>COS Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>3</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Returns Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>570</x>\n    <y>3</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>COR Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>3</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>COW Accnt:</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>230</x>\n     <y>-1</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>salesaccnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehouscode</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>-1</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>custtypecode</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>-1</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>creditaccnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>-1</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prodcatcode</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>-1</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>costaccnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>485</x>\n     <y>-1</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>returnsaccnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>570</x>\n     <y>-1</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>coraccnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>655</x>\n     <y>-1</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cowaccnt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>2</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102598
 
423     SalesCategoriesMasterList       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Sales Categories Master List</title>\n <name>SalesCategoriesMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT salescat_id, salescat_name, salescat_descrip,\n       formatGLAccount(salescat_sales_accnt_id) AS salesaccnt,\n       formatGLAccount(salescat_prepaid_accnt_id) AS prepaidaccnt,\n       formatGLAccount(salescat_ar_accnt_id) AS araccnt\n  FROM salescat\nORDER BY salescat_name;</sql>\n </querysource>\n <rpthead>\n  <height>87</height>\n  <line>\n   <xstart>0</xstart>\n   <ystart>81</ystart>\n   <xend>740</xend>\n   <yend>81</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>66</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Prepaid Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>230</x>\n    <y>66</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sales Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>10</y>\n    <width>530</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sales Categories Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>66</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description:</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>66</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>A/R Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>65</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>27</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>3</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>3</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description:</string>\n  </label>\n  <label>\n   <rect>\n    <x>230</x>\n    <y>3</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sales Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>3</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Prepaid Accnt:</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>3</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>A/R Accnt:</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>230</x>\n     <y>-1</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>salesaccnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>salescat_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>-1</y>\n     <width>155</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>salescat_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>-1</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prepaidaccnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>-1</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>araccnt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>2</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102599
 
448     SalesHistory    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Sales History</title>\n <name>SalesHistory</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>salesHistory</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("showPrices") ?>\n           text('Unit Price') AS lbl_unitprice,\n           text('Total') AS lbl_total\n       &lt;? else ?>\n           text('') AS lbl_unitprice,\n           text('') AS lbl_total\n       &lt;? endif ?>;</sql>\n </querysource>\n <rpthead>\n  <height>233</height>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>3</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sales History</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_total</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ord. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>355</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>355</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Invoice #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>230</ystart>\n   <xend>745</xend>\n   <yend>230</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unitprice</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>215</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Invc. Date</string>\n  </label>\n  <text>\n   <rect>\n    <x>15</x>\n    <y>48</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Invc. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Invoice #</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_total</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>355</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>355</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unitprice</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ord. Date</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>total</name>\n   <column></column>\n   <foot>\n    <height>39</height>\n    <field>\n     <rect>\n      <x>660</x>\n      <y>9</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>baseextprice</column>\n     </data>\n     <format builtin="true">money</format>\n     <tracktotal/>\n    </field>\n    <label>\n     <rect>\n      <x>570</x>\n      <y>9</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total Sales:</string>\n    </label>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>355</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohist_ordernumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>355</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_baseunitprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_orderdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyshipped</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_invcdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>355</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_baseextprice</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invoicenumber</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>103</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102600
 
404     SalesOrderAcknowledgement       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Sales Order Acknowledgement</title>\n <name>SalesOrderAcknowledgement</name>\n <description>Sales Order Acknowledgement Omits Closed Lines -- With Barcodes formatitemsitebarcode(itemsite_id) -- SO # barcoded formatsobarcode(cohead_id) -- With Logo, place logo graphic in images DB with name "logo"</description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>25</topmargin>\n <bottommargin>25</bottommargin>\n <rightmargin>25</rightmargin>\n <leftmargin>25</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT cust_number,\n       formatsobarcode(cohead_id) AS order_barcode,\n\n       formataddr(cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, (cohead_billtocity || '  ' ||   cohead_billtostate || '  ' || cohead_billtozipcode), cohead_billtocountry) AS billing_address, \n\n  formataddr(cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, (cohead_shiptocity || '  ' ||   cohead_shiptostate || '  ' || cohead_shiptozipcode), cohead_shiptocountry) AS shipping_address,           \n\n       trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n       cohead_billtoname,\n       cohead_billtoaddress1,\n       cohead_billtoaddress2,\n       cohead_billtoaddress3,\n       (cohead_billtocity || '  ' || cohead_billtostate || '  ' || cohead_billtozipcode) AS billtocitystatezip,\n       cntct_phone AS cust_phone,\n       cohead_shiptoname,\n       cohead_shiptoaddress1,\n       cohead_shiptoaddress2,\n       cohead_shiptoaddress3,\n       (cohead_shiptocity || '  ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n       cohead_number,\n       cohead_shipvia,\n       cohead_shiptophone,\n       cohead_custponumber,\n       formatDate(cohead_orderdate) AS orderdate,\n       cohead_shipcomments, \n       terms_descrip\n  FROM cohead, custinfo, terms, cntct\n WHERE ((cohead_cust_id=cust_id)\n   AND (cust_cntct_id=cntct_id)\n   AND (cohead_terms_id=terms_id)\n   AND (cohead_id=&lt;? value("sohead_id") ?>)\n);</sql>\n </querysource>\n <querysource>\n  <name>scheddate</name>\n  <sql>SELECT formatDate(MIN(coitem_scheddate)) AS scheddate\n  FROM coitem\n WHERE ((coitem_status &lt;> 'X') AND (coitem_cohead_id=&lt;? value("sohead_id") ?>));</sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>salesOrderItems</mqlgroup>\n  <mqlname>list</mqlname>\n </querysource>\n <querysource>\n  <name>logo</name>\n  <sql>SELECT image_data \nFROM image \nWHERE ((image_name='logo'));</sql>\n </querysource>\n <rpthead>\n  <height>477</height>\n  <image>\n   <rect>\n    <x>375</x>\n    <y>0</y>\n    <width>425</width>\n    <height>85</height>\n   </rect>\n   <mode>stretch</mode>\n   <data>\n    <query>logo</query>\n    <column>image_data</column>\n   </data>\n  </image>\n  <field>\n   <rect>\n    <x>120</x>\n    <y>400</y>\n    <width>253</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>cust_contact</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>365</x>\n    <y>400</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Terms:</string>\n  </label>\n  <field>\n   <rect>\n    <x>175</x>\n    <y>195</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>orderdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>215</y>\n    <width>102</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ship Via:</string>\n  </label>\n  <field>\n   <rect>\n    <x>469</x>\n    <y>400</y>\n    <width>320</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>terms_descrip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>444</y>\n    <width>95</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>130</y>\n    <width>177</width>\n    <height>25</height>\n   </rect>\n   <format>3of9</format>\n   <maxlength>10</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </barcode>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>160</y>\n    <width>307</width>\n    <height>25</height>\n   </rect>\n   <format>3of9</format>\n   <maxlength>20</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </barcode>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>425</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>155</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>50</x>\n    <y>215</y>\n    <width>121</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sched. Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>545</x>\n    <y>425</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <field>\n   <rect>\n    <x>433</x>\n    <y>215</y>\n    <width>331</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shipvia</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>425</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>At Shipping</string>\n  </label>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>95</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n  <barcode>\n   <rect>\n    <x>375</x>\n    <y>95</y>\n    <width>234</width>\n    <height>25</height>\n   </rect>\n   <format>128</format>\n   <maxlength>10</maxlength>\n   <left/>\n   <narrowBarWidth>0.01</narrowBarWidth>\n   <data>\n    <query>head</query>\n    <column>order_barcode</column>\n   </data>\n  </barcode>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>365</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Helvetica</face>\n    <size>16</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sales Order Acknowledgement</string>\n  </label>\n  <line>\n   <xstart>25</xstart>\n   <ystart>465</ystart>\n   <xend>823</xend>\n   <yend>465</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>155</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer P/O #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>75</x>\n    <y>260</y>\n    <width>305</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_billtoname</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>75</x>\n    <y>280</y>\n    <width>295</width>\n    <height>20</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>billing_address</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>260</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ship To:</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>400</y>\n    <width>95</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Attention:</string>\n  </label>\n  <label>\n   <rect>\n    <x>745</x>\n    <y>425</y>\n    <width>55</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Packed</string>\n  </label>\n  <text>\n   <rect>\n    <x>465</x>\n    <y>280</y>\n    <width>305</width>\n    <height>20</height>\n   </rect>\n   <bottompad>10</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>shipping_address</column>\n   </data>\n  </text>\n  <field>\n   <rect>\n    <x>170</x>\n    <y>125</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>260</y>\n    <width>65</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bill To:</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>425</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>465</x>\n    <y>260</y>\n    <width>305</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoname</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>425</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <field>\n   <rect>\n    <x>175</x>\n    <y>215</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>scheddate</query>\n    <column>scheddate</column>\n   </data>\n  </field>\n  <line>\n   <xstart>25</xstart>\n   <ystart>425</ystart>\n   <xend>823</xend>\n   <yend>425</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>195</y>\n    <width>102</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>S/O Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>253</x>\n    <y>425</y>\n    <width>35</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>95</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>125</y>\n    <width>122</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>helvetica</face>\n    <size>14</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n </rpthead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>groupby</column>\n   <foot>\n    <height>72</height>\n    <text>\n     <rect>\n      <x>50</x>\n      <y>5</y>\n      <width>625</width>\n      <height>17</height>\n     </rect>\n     <bottompad>14</bottompad>\n     <font>\n      <face>helvetica</face>\n      <size>10</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>head</query>\n      <column>cohead_shipcomments</column>\n     </data>\n    </text>\n   </foot>\n  </group>\n  <group>\n   <name>lineitem</name>\n   <column>coitem_linenumber</column>\n   <foot>\n    <height>28</height>\n    <line>\n     <xstart>5</xstart>\n     <ystart>5</ystart>\n     <xend>843</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>153</height>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyshipped</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>635</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyatshipping</column>\n    </data>\n   </field>\n   <barcode>\n    <rect>\n     <x>365</x>\n     <y>30</y>\n     <width>469</width>\n     <height>35</height>\n    </rect>\n    <format>128</format>\n    <maxlength>15</maxlength>\n    <left/>\n    <narrowBarWidth>0.01</narrowBarWidth>\n    <data>\n     <query>detail</query>\n     <column>item_barcode</column>\n    </data>\n   </barcode>\n   <field>\n    <rect>\n     <x>630</x>\n     <y>95</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>enhanced_status</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>100</x>\n     <y>120</y>\n     <width>700</width>\n     <height>17</height>\n    </rect>\n    <bottompad>14</bottompad>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>coitem_memo</column>\n    </data>\n   </text>\n   <line>\n    <xstart>80</xstart>\n    <ystart>80</ystart>\n    <xend>170</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <label>\n    <rect>\n     <x>25</x>\n     <y>95</y>\n     <width>48</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Qty:</string>\n   </label>\n   <label>\n    <rect>\n     <x>20</x>\n     <y>120</y>\n     <width>75</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Notes:</string>\n   </label>\n   <line>\n    <xstart>415</xstart>\n    <ystart>80</ystart>\n    <xend>500</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <label>\n    <rect>\n     <x>565</x>\n     <y>70</y>\n     <width>60</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <string>Batch #:</string>\n   </label>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>25</x>\n     <y>65</y>\n     <width>48</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Carton:</string>\n   </label>\n   <line>\n    <xstart>80</xstart>\n    <ystart>110</ystart>\n    <xend>170</xend>\n    <yend>110</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>40</y>\n     <width>295</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2_cust</column>\n    </data>\n   </field>\n   <line>\n    <xstart>305</xstart>\n    <ystart>110</ystart>\n    <xend>395</xend>\n    <yend>110</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>200</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number_cust</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>20</y>\n     <width>295</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1_cust</column>\n    </data>\n   </field>\n   <line>\n    <xstart>745</xstart>\n    <ystart>15</ystart>\n    <xend>795</xend>\n    <yend>15</yend>\n    <weight>1</weight>\n   </line>\n   <line>\n    <xstart>190</xstart>\n    <ystart>80</ystart>\n    <xend>280</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <line>\n    <xstart>632</xstart>\n    <ystart>80</ystart>\n    <xend>720</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <line>\n    <xstart>190</xstart>\n    <ystart>110</ystart>\n    <xend>280</xend>\n    <yend>110</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>228</x>\n     <y>0</y>\n     <width>85</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qty_uom</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>565</x>\n     <y>95</y>\n     <width>60</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <top/>\n    <string>Status:</string>\n   </label>\n   <line>\n    <xstart>415</xstart>\n    <ystart>110</ystart>\n    <xend>500</xend>\n    <yend>110</yend>\n    <weight>0</weight>\n   </line>\n   <line>\n    <xstart>305</xstart>\n    <ystart>80</ystart>\n    <xend>395</xend>\n    <yend>80</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>helvetica</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyord</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>57</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>5</y>\n    <width>95</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>695</x>\n    <y>5</y>\n    <width>37</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>455</x>\n    <y>5</y>\n    <width>80</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>5</y>\n    <width>90</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Sales Order #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>5</y>\n    <width>62</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Print Date: </string>\n  </label>\n  <field>\n   <rect>\n    <x>735</x>\n    <y>5</y>\n    <width>45</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>113</height>\n  <line>\n   <xstart>185</xstart>\n   <ystart>25</ystart>\n   <xend>363</xend>\n   <yend>25</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>186</xstart>\n   <ystart>90</ystart>\n   <xend>360</xend>\n   <yend>90</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>40</x>\n    <y>5</y>\n    <width>165</width>\n    <height>30</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Checked By:</string>\n  </label>\n  <label>\n   <rect>\n    <x>40</x>\n    <y>65</y>\n    <width>160</width>\n    <height>35</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Completed By:</string>\n  </label>\n </rptfoot>\n</report>\n   Sales Order Acknowledgement Omits Closed Lines -- With Barcodes formatitemsitebarcode(itemsite_id) -- SO # barcoded formatsobarcode(cohead_id) -- With Logo, place logo graphic in images DB with name "logo"   0       2014-10-06 19:47:03.678943
102601
 
72      SalesRepsMasterList     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Sales Reps Master List</title>\n <name>SalesRepsMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>select salesrep_number, salesrep_name,\n           formatBoolYN(salesrep_active) AS f_active,\n           formatScrap(salesrep_commission) AS f_commprcnt\n   from salesrep\norder by salesrep_name;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>55</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sales Reps. Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% Commission</string>\n  </label>\n  <label>\n   <rect>\n    <x>115</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>115</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>% Commission</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>610</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_active</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>salesrep_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>115</x>\n     <y>0</y>\n     <width>490</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>salesrep_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_commprcnt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102602
 
479     SaleTypesMasterList     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Sale Types Master List</title>\n <name>SaleTypesMasterList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>select *\n  from saletype\norder by saletype_code;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>58</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sale Types Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>58</y>\n    <width>30</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>-1</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>-1</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>-1</y>\n    <width>30</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>saletype_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>0</y>\n     <width>500</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>saletype_descr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>180</x>\n     <y>2</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>saletype_active</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102603
 
52      SingleLevelWhereUsed    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Single Level Where Used</title>\n <name>SingleLevelWhereUsed</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       uom_name,\n       item_descrip1,\n       item_descrip2,\n       &lt;? if exists("effective") ?>\n         formatDate(&lt;? value("effective") ?>)\n       &lt;? else ?>\n         text('Now')\n       &lt;? endif ?>\n       AS effective\n  FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=&lt;? value("item_id") ?>);\n    </sql>\n </querysource>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>whereUsed</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>241</height>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Single Level Where Used</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Required</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>235</ystart>\n   <xend>745</xend>\n   <yend>235</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>114</x>\n    <y>140</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>445</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>7</x>\n    <y>120</y>\n    <width>108</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Component Item:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>200</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>75</x>\n    <y>215</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <field>\n   <rect>\n    <x>450</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>effective</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>114</x>\n    <y>160</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>75</x>\n    <y>200</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>200</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>114</x>\n    <y>120</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>215</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>120</y>\n    <width>108</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Effective:</string>\n  </label>\n  <field>\n   <rect>\n    <x>450</x>\n    <y>138</y>\n    <width>185</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>uom_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>138</y>\n    <width>108</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>213</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Fxd. Qty.</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>75</x>\n    <y>15</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Effective</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>445</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>525</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty. Required</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>15</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Create W/O</string>\n  </label>\n  <label>\n   <rect>\n    <x>675</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Expires</string>\n  </label>\n  <label>\n   <rect>\n    <x>75</x>\n    <y>0</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Seq. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>14</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Fxd. Qty.</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>56</height>\n   <field>\n    <rect>\n     <x>444</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>75</x>\n     <y>15</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>75</x>\n     <y>30</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>404</x>\n     <y>0</y>\n     <width>38</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>675</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_issuemethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>675</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_expires</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>75</x>\n     <y>0</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>4</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>65</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bomitem_seqnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>525</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_createwo</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_effective</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>17</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyfxd</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102604
 
246     SelectedPaymentsList    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Selected Payments List</title>\n <name>SelectedPaymentsList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT apopen_id, apselect_id,\n       (bankaccnt_name || '-' || bankaccnt_descrip) AS bankaccnt,\n       (vend_number || '-' || vend_name) AS vendor,\n       apopen_docnumber,\n       apopen_ponumber,\n       formatMoney(apselect_amount) AS f_selected\n  FROM apselect, apopen, vendinfo, bankaccnt\n WHERE ((apopen_vend_id=vend_id)\n   AND (apselect_apopen_id=apopen_id)\n   AND (apselect_bankaccnt_id=bankaccnt_id)\n&lt;? if exists(&quot;vend_id&quot;) ?>\n   AND (vend_id=&lt;? value(&quot;vend_id&quot;) ?>)\n&lt;? elseif exists(&quot;vendtype_id&quot;) ?>\n   AND (vend_vendtype_id=&lt;? value(&quot;vendtype_id&quot;) ?>)\n&lt;? elseif exists(&quot;vendtype_pattern&quot;) ?>\n   AND (vend_vendtype_id IN (SELECT vendtype_id\n                               FROM vendtype\n                              WHERE (vendtype_code ~ &lt;? value(&quot;vendtype_pattern&quot;) ?>)))\n&lt;? endif ?>\n      )\nORDER BY bankaccnt_name, vend_number, apopen_docnumber;</sql>\n </querysource>\n <rpthead>\n  <height>141</height>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>5</y>\n    <width>530</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Selected Payments List</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>120</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Selected</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>120</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>120</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>365</x>\n    <y>120</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Voucher #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>135</ystart>\n   <xend>745</xend>\n   <yend>135</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>120</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bank Account</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Selected</string>\n  </label>\n  <label>\n   <rect>\n    <x>365</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Voucher #</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bank Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>0</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_selected</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>450</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>apopen_ponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>225</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>bankaccnt</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>365</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>apopen_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vendor</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102605
 
75      ShipToMasterList        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Ship-To Master List</title>\n <name>ShipToMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT cust_number, cust_name\n   FROM custinfo\nWHERE (cust_id=&lt;? value(&quot;cust_id&quot;) ?>);\n    </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT shipto_num AS num,\n       shipto_name AS name,\n       addr_line1 AS address,\n       (addr_city || ', ' || addr_state || '  ' || addr_postalcode)  AS citystatezip\n  FROM shiptoinfo\n  LEFT OUTER JOIN addr ON (shipto_addr_id=addr_id)\n WHERE (shipto_cust_id=&lt;? value(&quot;cust_id&quot;) ?>) \nORDER BY shipto_num;</sql>\n </querysource>\n <rpthead>\n  <height>171</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>165</ystart>\n   <xend>745</xend>\n   <yend>165</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>70</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>70</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>90</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>545</x>\n    <y>150</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>City, State, Zip</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>150</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Address</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>5</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Ship-To Addresses</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>545</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>City, State, Zip</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Number</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Address</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>num</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>address</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>545</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>citystatezip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>105</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102606
 
417     ShipmentsPending        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Shipments Pending</title>\n <name>ShipmentsPending</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse;\n</sql>\n </querysource>\n <querysource loadFromDb="true" >\n  <name>detail</name>\n  <mqlgroup>maintainShipping</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>200</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name/Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>185</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust./Item #</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship Via</string>\n  </label>\n  <label>\n   <rect>\n    <x>155</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order/Line #</string>\n  </label>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Type</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>10</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipments Pending</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipment #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Value at Ship</string>\n  </label>\n  <label>\n   <rect>\n    <x>520</x>\n    <y>185</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty at Ship</string>\n  </label>\n  <label>\n   <rect>\n    <x>470</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>605</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Value at Ship</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>5</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order/Line #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>110</x>\n    <y>5</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Order Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>415</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ship Via</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>5</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cust/Item #</string>\n  </label>\n  <label>\n   <rect>\n    <x>537</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty at Ship</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>20</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name/Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipment #</string>\n  </label>\n  <label>\n   <rect>\n    <x>475</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>33</height>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>0</y>\n     <width>140</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>dest</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_shipqty</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>28</ystart>\n    <xend>745</xend>\n    <yend>28</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>95</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shiphead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_shipvalue</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>160</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>linenumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>105</x>\n     <y>0</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ordertype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>390</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shiphead_shipvia</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>13</y>\n     <width>455</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>description</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>480</x>\n     <y>0</y>\n     <width>30</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>15</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>100</height>\n  <field>\n   <rect>\n    <x>600</x>\n    <y>10</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>shipvalue</column>\n   </data>\n   <tracktotal builtin="true" >cost</tracktotal>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>10</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Value at Ship</string>\n  </label>\n </rptfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102607
 
266     ShippingLabelsByInvoice \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Shipping Labels By Invoice</title>\n <name>ShippingLabelsByInvoice</name>\n <description></description>\n <labeltype>Avery 5263</labeltype>\n <size>Labels</size>\n <portrait/>\n <topmargin>100</topmargin>\n <bottommargin>100</bottommargin>\n <rightmargin>100</rightmargin>\n <leftmargin>100</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT sequence_value,\n       invchead_invcnumber,\n       cust_number,\n       invchead_ordernumber,\n       invchead_ponumber,\n       invchead_shipto_name,\n       invchead_shipto_address1,\n       invchead_shipto_address2,\n       invchead_shipto_address3,\n       (COALESCE(invchead_shipto_city,'') || ' ' || COALESCE(invchead_shipto_state,'') || ' ' || COALESCE(invchead_shipto_zipcode,'')) AS citystatezip\n  FROM invchead, custinfo, sequence\n WHERE ( (invchead_cust_id=cust_id)\n   AND (sequence_value BETWEEN &lt;? value(&quot;labelFrom&quot;) ?> AND &lt;? value(&quot;labelTo&quot;) ?>)\n   AND (invchead_id=&lt;? value(&quot;invchead_id&quot;) ?>) );\n       </sql>\n </querysource>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>201</height>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>125</y>\n     <width>155</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_number</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>5</x>\n     <y>140</y>\n     <width>90</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Invoice #:</string>\n   </label>\n   <label>\n    <rect>\n     <x>15</x>\n     <y>155</y>\n     <width>80</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>P/O #:</string>\n   </label>\n   <label>\n    <rect>\n     <x>5</x>\n     <y>125</y>\n     <width>90</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Customer #:</string>\n   </label>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>140</y>\n     <width>155</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invchead_invcnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>285</x>\n     <y>180</y>\n     <width>36</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sequence_value</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>30</x>\n     <y>85</y>\n     <width>285</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>citystatezip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>30</x>\n     <y>40</y>\n     <width>285</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invchead_shipto_address1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>340</x>\n     <y>180</y>\n     <width>36</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Parameter Query</query>\n     <column>labelTo</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>325</x>\n     <y>180</y>\n     <width>16</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <string> of </string>\n   </label>\n   <field>\n    <rect>\n     <x>30</x>\n     <y>25</y>\n     <width>285</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invchead_shipto_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>30</x>\n     <y>70</y>\n     <width>285</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invchead_shipto_address3</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>30</x>\n     <y>55</y>\n     <width>285</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invchead_shipto_address2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>155</y>\n     <width>155</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invchead_ponumber</column>\n    </data>\n   </field>\n  </detail>\n </section>\n</report>\n          0       2014-10-06 19:47:03.678943
102608
 
267     ShippingLabelsBySo      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Shippinig Labels By S/O</title>\n <name>ShippingLabelsBySo</name>\n <description></description>\n <size>Letter</size>\n <landscape/>\n <topmargin>100</topmargin>\n <bottommargin>100</bottommargin>\n <rightmargin>100</rightmargin>\n <leftmargin>100</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT sequence_value,&#xd;\n       cust_number,&#xd;\n       cohead_number,&#xd;\n&#xd;\nformataddr(cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, (cohead_shiptocity || '  ' ||   cohead_shiptostate || '  ' || cohead_shiptozipcode), cohead_shiptocountry) AS shipping_address,           &#xd;\n&#xd;\n&#xd;\n       cohead_custponumber,&#xd;\n       cohead_shiptoname,&#xd;\n       cohead_shiptoaddress1,&#xd;\n       cohead_shiptoaddress2,&#xd;\n       cohead_shiptoaddress3,&#xd;\n       (COALESCE(cohead_shiptocity,'') || ' ' || COALESCE(cohead_shiptostate,'') || ' ' || COALESCE(cohead_shiptozipcode,'')) AS citystatezip&#xd;\nFROM cohead, custinfo, sequence&#xd;\nWHERE ( (cohead_cust_id=cust_id)&#xd;\n AND (sequence_value BETWEEN &lt;? value("labelFrom") ?> AND &lt;? value("labelTo") ?>)&#xd;\n AND (cohead_id=&lt;? value("sohead_id") ?>) )&#xd;\nLIMIT &lt;? value("labelTo") ?>;&#xd;\n       </sql>\n </querysource>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>494</height>\n   <label>\n    <rect>\n     <x>630</x>\n     <y>25</y>\n     <width>90</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Order #:</string>\n   </label>\n   <field>\n    <rect>\n     <x>725</x>\n     <y>9</y>\n     <width>155</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>800</x>\n     <y>445</y>\n     <width>36</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Parameter Query</query>\n     <column>labelTo</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>15</x>\n     <y>119</y>\n     <width>880</width>\n     <height>55</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>36</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>shipping_address</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>9</x>\n     <y>65</y>\n     <width>884</width>\n     <height>50</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>36</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_shiptoname</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>725</x>\n     <y>40</y>\n     <width>155</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_custponumber</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>640</x>\n     <y>40</y>\n     <width>80</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>P/O #:</string>\n   </label>\n   <field>\n    <rect>\n     <x>725</x>\n     <y>25</y>\n     <width>155</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>735</x>\n     <y>445</y>\n     <width>36</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sequence_value</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>630</x>\n     <y>9</y>\n     <width>90</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Customer #:</string>\n   </label>\n   <label>\n    <rect>\n     <x>775</x>\n     <y>445</y>\n     <width>16</width>\n     <height>16</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <string> of </string>\n   </label>\n  </detail>\n </section>\n</report>\n               0       2014-10-06 19:47:03.678943
102609
 
425     SiteTypesMasterList     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Site Types Master List</title>\n <name>SiteTypesMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>select sitetype_name, sitetype_descrip\n  from sitetype\norder by sitetype_name;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Site Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site Types Master List</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Site Type</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sitetype_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sitetype_descrip</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102610
 
175     SlowMovingInventoryByClassCode  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Slow Moving Inventory By Class Code</title>\n <name>SlowMovingInventoryByClassCode</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;warehous_id&quot;) ?>\n         (SELECT warehous_code\n            FROM whsinfo\n           WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists(&quot;classcode_id&quot;) ?>\n         (SELECT (classcode_code || '-' || classcode_descrip)\n            FROM classcode\n           WHERE (classcode_id=&lt;? value(&quot;classcode_id&quot;) ?>) )\n       &lt;? elseif exists(&quot;classcode_pattern&quot;) ?>\n         text(&lt;? value(&quot;classcode_pattern&quot;) ?>)\n       &lt;? else ?>\n         text('All Class Codes')\n       &lt;? endif ?>\n       AS classcode,\n       &lt;? if exists(&quot;showValue&quot;) ?>\n           &lt;? if exists(&quot;useActualCosts&quot;) ?>\n             text('Show Inventory Value with Actual Costs')\n           &lt;? else ?>\n             text('Show Inventory Value with Standard Costs')\n           &lt;? endif ?>\n           AS showvalues,\n           text('Unit Cost') AS f_unitcost,\n           text('Value') AS f_value,\n       &lt;? else ?>\n           text('') AS showvalues,\n           text('') AS f_unitcost,\n           text('') AS f_value,\n       &lt;? endif ?>\n       formatDate(&lt;? value(&quot;cutoffDate&quot;) ?>) AS f_cutoff;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT warehous_code,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       uom_name,\n       formatQty(itemsite_qtyonhand) AS f_qoh,\n       formatDate(itemsite_datelastused) AS f_datelastused,\n       &lt;? if exists(&quot;showValue&quot;) ?>\n         formatCost(cost)\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_unitcost,\n       noNeg(cost * itemsite_qtyonhand) AS value,\n       &lt;? if exists(&quot;showValue&quot;) ?>\n         formatExtPrice(noNeg(cost * itemsite_qtyonhand))\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_value\n  FROM ( SELECT itemsite_id,\n                warehous_code,\n                item_number,\n                item_descrip1,\n                item_descrip2, uom_name,\n                itemsite_qtyonhand,\n                itemsite_datelastused,\n                &lt;? if exists(&quot;useActualCosts&quot;) ?>\n                  actcost(itemsite_item_id)\n                &lt;? else ?>\n                  stdcost(itemsite_item_id)\n                &lt;? endif ?>\n                AS cost\n           FROM itemsite, item, whsinfo, uom\n          WHERE ((itemsite_item_id=item_id)\n            AND (item_inv_uom_id=uom_id)\n            AND (itemsite_warehous_id=warehous_id)\n            AND (itemsite_active)\n            AND (itemsite_datelastused &lt; &lt;? value(&quot;cutoffDate&quot;) ?>)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n            AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;classcode_id&quot;) ?>\n            AND (item_classcode_id=&lt;? value(&quot;classcode_id&quot;) ?>)\n&lt;? elseif exists(&quot;classcode_pattern&quot;) ?>\n            AND (item_classcode_id IN (SELECT classcode_id\n                                         FROM classcode\n                                        WHERE classcode_code ~ &lt;? value(&quot;classcode_pattern&quot;) ?>) )\n&lt;? endif ?>\n                )\n       ) AS data\nORDER BY warehous_code,\n&lt;? if exists(&quot;orderByInventoryValue&quot;) ?>\n  value DESC\n&lt;? elseif exists(&quot;orderByDateLastUsed&quot;) ?>\n  itemsite_datelastused\n&lt;? else ?>\n  item_number\n&lt;? endif ?></sql>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <field>\n   <rect>\n    <x>575</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_unitcost</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>140</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>229</x>\n    <y>10</y>\n    <width>495</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Slow Moving Inventory By Class Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Movement</string>\n  </label>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>215</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>200</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>440</x>\n    <y>140</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>showvalues</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>140</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_value</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>120</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Cutoff Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>120</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Class Code(s):</string>\n  </label>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>classcode</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>540</x>\n    <y>120</y>\n    <width>195</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_cutoff</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>34</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>5</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_value</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Movement</string>\n  </label>\n  <field>\n   <rect>\n    <x>575</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_unitcost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>20</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>380</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_datelastused</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>105</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_value</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>105</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qoh</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>105</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>265</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_unitcost</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>16</height>\n </rptfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102611
 
195     StandardBOL     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Standard Bill of Lading</title>\n <name>StandardBOL</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>0</rightmargin>\n <leftmargin>0</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT shiphead_shipvia, formatDate(shiphead_shipdate) AS shipdate,\n                cust_name, cust_number, cohead_number, cohead_fob, cohead_custponumber,\n                warehous_descrip, addr_line1 AS warehous_addr1, addr_line2 AS warehous_addr2, addr_line3 AS warehous_addr3, addr_city AS warehous_addr4, warehous_fob,\n                cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3,\n                (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n                cohead_shiptophone\n         FROM shiphead, cohead, whsinfo, custinfo\n         LEFT OUTER JOIN addr ON (warehous_addr_id=addr_id)\n         WHERE ((shiphead_order_id=cohead_id)\n          AND (cohead_cust_id=cust_id)\n          AND (cohead_warehous_id=warehous_id)\n          AND (shiphead_id=%1));</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT coitem_linenumber, formatQty(SUM(shipitem_qty)) AS invqty, uom_name, roundUp(SUM(shipitem_qty) / itemuomratiobytype(item_id, 'Selling'))::integer AS shipqty,\n                itemsellinguom(item_id) AS shipuom, item_number, item_descrip1, item_descrip2,\n                formatQty(SUM(shipitem_qty) * item_prodweight) AS netweight,\n                formatQty(SUM(shipitem_qty) * (item_prodweight + item_packweight)) AS grossweight\n         FROM shipitem, coitem, itemsite, item, uom\n         WHERE ((shipitem_orderitem_id=coitem_id)\n          AND (coitem_itemsite_id=itemsite_id)\n          AND (itemsite_item_id=item_id)\n          AND (item_inv_uom_id=uom_id)\n          AND (shipitem_shiphead_id=%1))\n         GROUP BY coitem_linenumber, item_number, uom_name, shipuom,\n                  item_descrip1, item_descrip2, item_prodweight, item_packweight\n         ORDER BY coitem_linenumber;\n    </sql>\n </querysource>\n <querysource>\n  <name>foot</name>\n  <sql>SELECT formatQty(SUM(shipitem_qty * item_prodweight)) AS netweight,\n                formatQty(SUM(shipitem_qty * (item_prodweight + item_packweight))) AS grossweight,\n                CASE\n                 WHEN ('%3' = 'C') THEN 'X'\n                 ELSE ' '\n                END AS collectflag,\n                CASE\n                 WHEN ('%3' = 'C') THEN 'Therm-O-Rock East, Inc.'\n                 ELSE ' '\n                END AS section7,\n                CASE\n                 WHEN ('%3' = 'C') THEN 'Therm-O-Rock, East, Inc.'\n                 ELSE ' '\n                END AS collect_name,\n                CASE\n                 WHEN ('%3' = 'C') THEN 'Pine Street'\n                 ELSE ' '\n                END AS collect_address1,\n                CASE\n                 WHEN ('%3' = 'C') THEN ''\n                 ELSE ' '\n                END AS collect_address2,\n                CASE\n                 WHEN ('%3' = 'C') THEN 'New Eagle  PA  15067'\n                 ELSE ' '\n                END AS collect_address3\n         FROM shipitem, coitem, itemsite, item\n         WHERE ((shipitem_orderitem_id=coitem_id)\n          AND (coitem_itemsite_id=itemsite_id)\n          AND (itemsite_item_id=item_id)\n          AND (shipitem_shiphead_id=%1));</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT shiphead_notes\n         FROM shiphead\n         WHERE (shiphead_id=%1);</sql>\n </querysource>\n <pghead>\n  <firstpage/>\n  <height>242</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>125</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_addr2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>600</x>\n    <y>5</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shipdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>530</x>\n    <y>165</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shiptocitystatezip</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>165</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_addr4</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>530</x>\n    <y>145</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoaddress3</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>530</x>\n    <y>125</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoaddress2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>145</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_addr3</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>85</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_descrip</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>530</x>\n    <y>85</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoname</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>530</x>\n    <y>105</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoaddress1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>115</x>\n    <y>35</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shiphead_shipvia</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>105</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_addr1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>530</x>\n    <y>185</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptophone</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>57</height>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>40</y>\n     <width>300</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>95</x>\n     <y>30</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>30</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invqty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>5</y>\n     <width>300</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>5</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>netweight</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>5</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipqty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>25</y>\n     <width>100</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>grossweight</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>94</x>\n     <y>5</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>25</y>\n     <width>300</width>\n     <height>14</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <lastpage/>\n  <height>287</height>\n  <field>\n   <rect>\n    <x>230</x>\n    <y>180</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>collect_address2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>438</x>\n    <y>261</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>section7</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>80</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>520</x>\n    <y>5</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>netweight</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>614</x>\n    <y>60</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_fob</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>20</x>\n    <y>180</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>collect_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>100</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Order #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>520</x>\n    <y>25</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>grossweight</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>60</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipped From:</string>\n  </label>\n  <field>\n   <rect>\n    <x>230</x>\n    <y>200</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>collect_address3</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>728</x>\n    <y>261</y>\n    <width>46</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>collectflag</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>614</x>\n    <y>100</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>614</x>\n    <y>120</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>614</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>480</x>\n    <y>120</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer P/O #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>20</x>\n    <y>200</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>collect_address1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>50</x>\n    <y>10</y>\n    <width>400</width>\n    <height>100</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>notes</query>\n    <column>shiphead_notes</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102612
 
248     StandardJournalGroupMasterList  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Standard Journal Group Master List</title>\n <name>StandardJournalGroupMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT stdjrnlgrp_id,\n       stdjrnlgrp_name,\n       stdjrnlgrp_descrip\n  FROM stdjrnlgrp\nORDER BY stdjrnlgrp_name;</sql>\n </querysource>\n <rpthead>\n  <height>77</height>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Standard Journal Group Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>22</height>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>220</x>\n     <y>0</y>\n     <width>500</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>stdjrnlgrp_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>stdjrnlgrp_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102613
 
282     StandardJournalHistory  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Standard Journal History</title>\n <name>StandardJournalHistory</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("source") ?>\n         text(&lt;? value("source") ?>)\n       &lt;? else ?>\n         text('All Sources')\n       &lt;? endif  ?>\n       AS source,\n       &lt;? if exists("startJrnlnum") ?>\n         text('Start Journal Number:')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS startJrnlnumLit,\n       &lt;? if exists("endJrnlnum") ?>\n         text('End Journal Number:')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS endJrnlnumLit;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT formatDate(gltrans_date) AS transdate,\n       gltrans_journalnumber,\n       gltrans_docnumber,\n      (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       CASE WHEN (gltrans_amount &lt; 0) THEN formatMoney(gltrans_amount * -1)\n            ELSE ''\n       END AS f_debit,\n       CASE WHEN (gltrans_amount > 0) THEN formatMoney(gltrans_amount)\n            ELSE ''\n       END AS f_credit,\n       formatBoolYN(gltrans_posted) AS f_posted\n  FROM gltrans, accnt\n WHERE ( (gltrans_accnt_id=accnt_id)\n   AND   (NOT gltrans_deleted)\n   AND   (gltrans_date BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n   AND   (gltrans_doctype='ST') )\nORDER BY gltrans_date, gltrans_sequence, gltrans_docnumber, gltrans_amount;</sql>\n </querysource>\n <rpthead>\n  <height>162</height>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>140</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>680</x>\n    <y>140</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <field>\n   <rect>\n    <x>200</x>\n    <y>65</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>65</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>10</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Standard Journal History</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>85</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>200</x>\n    <y>85</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>140</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>140</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>155</ystart>\n   <xend>745</xend>\n   <yend>155</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>140</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>140</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Journal #</string>\n  </label>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>140</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Journal Name</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>0</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>509</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Journal #</string>\n  </label>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Journal Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>680</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>JournalSeries</name>\n   <column>gltrans_journalnumber</column>\n   <head>\n    <height>16</height>\n    <field>\n     <rect>\n      <x>680</x>\n      <y>0</y>\n      <width>60</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_posted</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>transdate</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>100</x>\n      <y>0</y>\n      <width>85</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>gltrans_journalnumber</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <group>\n   <name>JournalName</name>\n   <column>gltrans_docnumber</column>\n   <head>\n    <height>16</height>\n    <field>\n     <rect>\n      <x>190</x>\n      <y>0</y>\n      <width>130</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>gltrans_docnumber</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>595</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_credit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>175</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>account</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>509</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_debit</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102614
 
249     StandardJournalMasterList       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Standard Journal Master List</title>\n <name>StandardJournalMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT stdjrnl_id,\n       stdjrnl_name,\n       stdjrnl_descrip\n  FROM stdjrnl\nORDER BY stdjrnl_name;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Standard Journal Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>220</x>\n     <y>0</y>\n     <width>500</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>stdjrnl_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>stdjrnl_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102615
 
261     Statement       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Statement</title>\n <name>Statement</name>\n <description>"As of" date included</description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>100</topmargin>\n <bottommargin>100</bottommargin>\n <rightmargin>100</rightmargin>\n <leftmargin>100</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT CASE WHEN (araging_doctype = 'I') THEN &lt;? value("invoice") ?>\n            WHEN (araging_doctype = 'D') THEN &lt;? value("debit") ?>\n            WHEN (araging_doctype = 'C') THEN &lt;? value("credit") ?>\n            WHEN (araging_doctype = 'R') THEN &lt;? value("deposit") ?>\n            ELSE 'Misc.'\n       END AS doctype,\n       araging_docnumber AS f_docnumber,\n       formatDate(CAST(araging_docdate AS DATE)) AS f_docdate,\n       CASE WHEN (araging_doctype IN ('I','C','D')) THEN formatDate(araging_duedate)\n            ELSE ''\n       END AS f_duedate,\n       formatMoney(araging_aropen_amount) AS f_amount,\n       formatMoney(araging_aropen_amount - araging_total_val) AS f_applied,\n       formatMoney(araging_total_val) AS f_balance\nFROM araging(&lt;? value("asofdate") ?>, true, false)\nWHERE ((araging_cust_id = &lt;? value("cust_id") ?>)\n   AND (abs(araging_aropen_amount) > 0)\n      )\nORDER BY araging_duedate;</sql>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT cust_name, addr_line1 AS cust_address1, addr_line2 AS cust_address2, addr_line3 AS cust_address3,\n       (addr_city || '  ' || addr_state || '  ' || addr_postalcode) AS citystatezip,\n       formatDate(COALESCE(&lt;? value("asofdate") ?>, current_date)) AS asofdate\nFROM custinfo\nLEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\nLEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\nWHERE (cust_id = &lt;? value("cust_id") ?>);</sql>\n </querysource>\n <querysource>\n  <name>Currency</name>\n  <sql>SELECT currconcat(cust_curr_id) AS currAbbr\n  FROM custinfo\n WHERE (cust_id=&lt;? value("cust_id") ?>)\n</sql>\n </querysource>\n <querysource>\n  <name>foot</name>\n  <sql>SELECT formatMoney(SUM(araging_cur_val)) AS f_current,\n       formatMoney(SUM(araging_thirty_val)) AS f_thirty,\n       formatMoney(SUM(araging_sixty_val)) AS f_sixty,\n       formatMoney(SUM(araging_ninety_val)) AS f_ninety,\n       formatMoney(SUM(araging_plus_val)) AS f_plus,\n       formatMoney(SUM(araging_total_val)) AS f_total\nFROM araging(&lt;? value("asofdate") ?>, true, false)\nWHERE ((abs(araging_aropen_amount) > 0)\n   AND (araging_cust_id = &lt;? value("cust_id") ?>));</sql>\n </querysource>\n <pghead>\n  <height>277</height>\n  <line>\n   <xstart>475</xstart>\n   <ystart>245</ystart>\n   <xend>475</xend>\n   <yend>270</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>25</x>\n    <y>190</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>citystatezip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>545</x>\n    <y>250</y>\n    <width>95</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance Due</string>\n  </label>\n  <label>\n   <rect>\n    <x>14.2513</x>\n    <y>250</y>\n    <width>86.4477</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Document Type</string>\n  </label>\n  <line>\n   <xstart>10</xstart>\n   <ystart>245</ystart>\n   <xend>10</xend>\n   <yend>270</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>15</y>\n    <width>175</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>14</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Statement</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>250</y>\n    <width>90</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Document Date</string>\n  </label>\n  <line>\n   <xstart>445</xstart>\n   <ystart>40</ystart>\n   <xend>445</xend>\n   <yend>75</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>250</y>\n    <width>75</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <line>\n   <xstart>395</xstart>\n   <ystart>245</ystart>\n   <xend>395</xend>\n   <yend>270</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>445</xstart>\n   <ystart>75</ystart>\n   <xend>585</xend>\n   <yend>75</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>310</xstart>\n   <ystart>245</ystart>\n   <xend>310</xend>\n   <yend>270</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>123.972</xstart>\n   <ystart>244.219</ystart>\n   <xend>123.972</xend>\n   <yend>269.461</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>130</x>\n    <y>250</y>\n    <width>80</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Document No.</string>\n  </label>\n  <field>\n   <rect>\n    <x>25</x>\n    <y>150</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_address1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>25</x>\n    <y>165</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_address2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>442</x>\n    <y>40</y>\n    <width>140</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>STATEMENT DATE</string>\n  </label>\n  <line>\n   <xstart>10</xstart>\n   <ystart>244.541</ystart>\n   <xend>640</xend>\n   <yend>244.541</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>25</x>\n    <y>135</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_name</column>\n   </data>\n  </field>\n  <line>\n   <xstart>210</xstart>\n   <ystart>245.459</ystart>\n   <xend>210</xend>\n   <yend>270.459</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>60</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <line>\n   <xstart>640</xstart>\n   <ystart>245</ystart>\n   <xend>640</xend>\n   <yend>270</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>25</x>\n    <y>180</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_address3</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>407</x>\n    <y>250</y>\n    <width>60</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <line>\n   <xstart>545</xstart>\n   <ystart>245</ystart>\n   <xend>545</xend>\n   <yend>270</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>480</x>\n    <y>250</y>\n    <width>60</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Applied</string>\n  </label>\n  <line>\n   <xstart>585</xstart>\n   <ystart>40</ystart>\n   <xend>585</xend>\n   <yend>75</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>445</xstart>\n   <ystart>40</ystart>\n   <xend>585</xend>\n   <yend>40</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>10</xstart>\n   <ystart>270</ystart>\n   <xend>640</xend>\n   <yend>270</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>445</xstart>\n   <ystart>55</ystart>\n   <xend>585</xend>\n   <yend>55</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>50</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>As Of Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>105</x>\n    <y>50</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>asofdate</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>unnamed</name>\n   <column></column>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>20</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>12</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>395</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>480</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_applied</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>215</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_docdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>560</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>11</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <lastpage/>\n  <height>111</height>\n  <line>\n   <xstart>190</xstart>\n   <ystart>5</ystart>\n   <xend>190</xend>\n   <yend>35</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>10</xstart>\n   <ystart>5</ystart>\n   <xend>10</xend>\n   <yend>35</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>5</y>\n    <width>80</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>61 to 90 Days</string>\n  </label>\n  <line>\n   <xstart>100</xstart>\n   <ystart>5</ystart>\n   <xend>100</xend>\n   <yend>35</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>365</xstart>\n   <ystart>5</ystart>\n   <xend>365</xend>\n   <yend>35</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>195</x>\n    <y>5</y>\n    <width>85</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>31 to 60 Days</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>5</y>\n    <width>85</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Current</string>\n  </label>\n  <field>\n   <rect>\n    <x>190</x>\n    <y>15</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>f_sixty</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>365</x>\n    <y>15</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>f_plus</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>15</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>f_thirty</column>\n   </data>\n  </field>\n  <line>\n   <xstart>10</xstart>\n   <ystart>35</ystart>\n   <xend>640</xend>\n   <yend>35</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>15</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>f_current</column>\n   </data>\n  </field>\n  <line>\n   <xstart>640</xstart>\n   <ystart>5</ystart>\n   <xend>640</xend>\n   <yend>35</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>45</y>\n    <width>75</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Currency:</string>\n  </label>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>10</y>\n    <width>75</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Due</string>\n  </label>\n  <line>\n   <xstart>280</xstart>\n   <ystart>5</ystart>\n   <xend>280</xend>\n   <yend>35</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>5</y>\n    <width>85</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Over 90</string>\n  </label>\n  <label>\n   <rect>\n    <x>102</x>\n    <y>5</y>\n    <width>85</width>\n    <height>17</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>1 to 30 Days</string>\n  </label>\n  <field>\n   <rect>\n    <x>280</x>\n    <y>15</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>f_ninety</column>\n   </data>\n  </field>\n  <line>\n   <xstart>455</xstart>\n   <ystart>5</ystart>\n   <xend>455</xend>\n   <yend>35</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>45</y>\n    <width>67</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Currency</query>\n    <column>currAbbr</column>\n   </data>\n  </field>\n  <line>\n   <xstart>10</xstart>\n   <ystart>5</ystart>\n   <xend>640</xend>\n   <yend>5</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>544</x>\n    <y>15</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>11</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>f_total</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n      "As of" date included   0       2014-10-06 19:47:03.678943
102616
 
274     SubAccountTypeMasterList        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Subaccount Type Master List</title>\n <name>SubAccountTypeMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT subaccnttype_code, subaccnttype_descrip,\n       CASE WHEN(subaccnttype_accnt_type='A') THEN text('Asset')\n            WHEN(subaccnttype_accnt_type='L') THEN text('Liability')\n            WHEN(subaccnttype_accnt_type='E') THEN text('Expense')\n            WHEN(subaccnttype_accnt_type='R') THEN text('Revenue')\n            WHEN(subaccnttype_accnt_type='Q') THEN text('Equity')\n            ELSE text('ERROR')\n       END AS f_type\n  FROM subaccnttype\nORDER BY subaccnttype_code;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>120</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Subaccount Type Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>120</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>0</y>\n     <width>500</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>subaccnttype_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>120</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_type</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>subaccnttype_code</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102617
 
74      TermsMasterList \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Terms Master List</title>\n <name>TermsMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>select terms_code, terms_descrip,\n           terms_duedays, terms_discdays,\n           formatScrap(terms_discprcnt) AS f_discprcnt\n   from terms\norder by terms_code;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Days</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Terms Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Discount %</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Discnt. Days</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>495</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Days</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Discnt. Days</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Discount %</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>495</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>terms_duedays</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>terms_discdays</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>95</x>\n     <y>0</y>\n     <width>395</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>terms_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>terms_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_discprcnt</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102618
 
220     SummarizedBOM   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Summarized Bill of Materials</title>\n <name>SummarizedBOM</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       uom_name AS item_invuom,\n       item_descrip1,\n       item_descrip2\n  FROM item, uom\n WHERE ((item_id=&lt;? value("item_id") ?>)\n AND (item_inv_uom_id=uom_id));\n    </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>select bomdata_item_number AS item_number,\n       bomdata_uom_name AS item_invuom,\n       bomdata_item_descrip1 AS item_descrip1,\n       bomdata_item_descrip2 AS item_descrip2,\n       formatQtyPer(bomdata_qtyreq) AS qtyreq\n  FROM summarizedBOM(&lt;? value("item_id") ?>,&lt;? value("revision_id") ?>,&lt;? value("expiredDays") ?>,&lt;? value("futureDays") ?>)\n\n</sql>\n </querysource>\n <querysource>\n  <name>bomhead</name>\n  <sql>SELECT bomhead_docnum, bomhead_revision,\nformatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=&lt;? value("item_id") ?>)\nAND (bomhead_rev_id=&lt;? value("revision_id") ?>));</sql>\n </querysource>\n <rpthead>\n  <height>242</height>\n  <field>\n   <rect>\n    <x>315</x>\n    <y>103</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_invuom</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>103</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_docnum</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>103</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Summarized Bill of Materials</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>145</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>235</ystart>\n   <xend>745</xend>\n   <yend>235</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>145</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>103</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>125</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>220</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>203</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>125</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Revision Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>103</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Document #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>203</y>\n    <width>165</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>103</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>145</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>bomhead_revision</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>203</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Qty. Req.</string>\n  </label>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>125</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>bomhead</query>\n    <column>f_revisiondate</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>0</y>\n    <width>165</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>15</y>\n    <width>228</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ext. Qty. Req.</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>52</height>\n   <field>\n    <rect>\n     <x>112</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>112</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>112</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>275</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_invuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyreq</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102619
 
65      SummarizedBacklogByWarehouse    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Summarized Backlog By Site</title>\n <name>SummarizedBacklogByWarehouse</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("custtype_id") ?>\n         ( SELECT (custtype_code||'-'||custtype_descrip)\n             FROM custtype\n            WHERE (custtype_id=&lt;? value("custtype_id") ?>) )\n       &lt;? elseif exists("custtype_pattern") ?>\n         text(&lt;? value("custtype_pattern") ?>)\n       &lt;? else ?>\n         text('All Customer Types')\n       &lt;? endif ?>\n       AS custtype,\n       &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists("showPrices") ?>\n         text('Sales') AS lbl_sales,\n         text('Cost') AS lbl_cost,\n         text('Margin') AS lbl_margin,\n         text('Totals:') AS lbl_totals,\n       &lt;? else ?>\n         text('') AS lbl_sales,\n         text('') AS lbl_cost,\n         text('') AS lbl_margin,\n         text('') AS lbl_totals,\n       &lt;? endif ?>\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT CASE WHEN (cohead_holdtype='P') THEN -1\n            ELSE cohead_id\n       END AS _coheadid, cohead_id,\n       cohead_holdtype, cohead_number, cust_name,\n       CASE WHEN (cohead_holdtype='N') THEN &lt;? value("none") ?>\n            WHEN (cohead_holdtype='C') THEN &lt;? value("credit") ?>\n            WHEN (cohead_holdtype='S') THEN &lt;? value("ship") ?>\n            WHEN (cohead_holdtype='P') THEN &lt;? value("pack") ?>\n            WHEN (cohead_holdtype='R') THEN &lt;? value("return") ?>\n            ELSE &lt;? value("Other") ?>\n       END AS f_holdtype,\n       formatDate(cohead_orderdate) AS f_orderdate,\n       formatDate(MIN(coitem_scheddate)) AS f_scheddate,\n       formatDate(cohead_packdate) AS f_packdate,\n       &lt;? if exists("showPrices") ?>\n         formatMoney( SUM( round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                         (coitem_price / coitem_price_invuomratio),2) ) )\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_sales,\n       &lt;? if exists("showPrices") ?>\n         formatCost(SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * stdcost(item_id) ) )\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_cost,\n       &lt;? if exists("showPrices") ?>\n         formatMoney( SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                         ((coitem_price / coitem_price_invuomratio) - stdcost(item_id)) ) )\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_margin,\n       SUM( round( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n            (coitem_price / coitem_price_invuomratio),2) ) AS sales,\n       SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * stdcost(item_id) ) AS cost,\n       SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n            ((coitem_price / coitem_price_invuomratio) - stdcost(item_id)) ) AS margin,\n       MIN(coitem_scheddate) AS scheddate,\n       formatShipmentNumber(shiphead_id) AS shiphead_number,\n       CASE WHEN (shiphead_shipped IS NULL) THEN text('')\n            WHEN (shiphead_shipped) THEN text('Yes')\n            WHEN (NOT shiphead_shipped) THEN text('No')\n       END AS shipstatus,\n       COALESCE(shiphead_shipvia, '') AS shipvia,\n       CASE WHEN (shiphead_shipdate IS NULL) THEN text('')\n            ELSE formatDate(shiphead_shipdate)\n       END AS shipdate\n  FROM coitem, itemsite, item, custinfo,\n       cohead LEFT OUTER JOIN shiphead ON (shiphead_order_id=cohead_id AND shiphead_order_type='SO') \n WHERE ( (coitem_cohead_id=cohead_id)\n   AND (cohead_cust_id=cust_id)\n   AND (coitem_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (coitem_status NOT IN ('C','X'))\n   AND (coitem_scheddate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n&lt;? if exists("custtype_id") ?>\n   AND (cust_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? elseif exists("custtype_pattern") ?>\n   AND (cust_custtype_id IN (SELECT custtype_id\n                               FROM custtype\n                              WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n)\nGROUP BY cohead_id, cohead_number, cust_name, cohead_holdtype,\n         cohead_orderdate, cohead_packdate, shiphead_shipped,\n         shiphead_shipvia, shiphead_shipdate, shiphead_id\nORDER BY \n&lt;? if exists("orderByShipDate") ?>\n  scheddate,\n&lt;? elseif exists("orderByPackDate") ?>\n  cohead_packdate,\n&lt;? endif ?>\ncohead_number, shiphead_shipped;</sql>\n </querysource>\n <querysource>\n  <name>totals</name>\n  <sql>SELECT\n&lt;? if exists("showPrices") ?>\n       formatMoney( SUM( sales ) ) AS f_sales,\n       formatCost( SUM( cost ) ) AS f_cost,\n       formatMoney( SUM( margin ) ) AS f_margin\n  FROM (\nSELECT SUM( round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                         (coitem_price / coitem_price_invuomratio),2) ) AS sales,\n       SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * stdcost(item_id) ) AS cost,\n       SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                         ((coitem_price / coitem_price_invuomratio) - stdcost(item_id)) ) AS margin\n  FROM coitem, itemsite, item, custinfo,\n       cohead\n WHERE ( (coitem_cohead_id=cohead_id)\n   AND (cohead_cust_id=cust_id)\n   AND (coitem_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (coitem_status NOT IN ('C','X'))\n   AND (coitem_scheddate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n&lt;? if exists("custtype_id") ?>\n   AND (cust_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? elseif exists("custtype_pattern") ?>\n   AND (cust_custtype_id IN (SELECT custtype_id\n                               FROM custtype\n                              WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n)\nGROUP BY cohead_id, cohead_number, cust_name, cohead_holdtype,\n         cohead_orderdate, cohead_packdate\n) AS data\n&lt;? else ?>\n       text('') AS f_sales,\n       text('') AS f_cost,\n       text('') AS f_margin\n&lt;? endif ?></sql>\n </querysource>\n <rpthead>\n  <height>206</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>200</ystart>\n   <xend>745</xend>\n   <yend>200</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_margin</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>104</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>170</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Scheduled</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>170</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Hold Type</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>104</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>185</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipment #</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>85</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>custtype</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>170</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Pack Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>515</x>\n    <y>85</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>185</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>290</x>\n    <y>170</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>10</y>\n    <width>465</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Summarized Backlog By Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>510</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_sales</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>185</y>\n    <width>145</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipvia</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>85</y>\n    <width>104</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer Type:</string>\n  </label>\n  <field>\n   <rect>\n    <x>515</x>\n    <y>104</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_cost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>85</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>170</y>\n    <width>145</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>290</x>\n    <y>185</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>104</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>170</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>28</height>\n  <label>\n   <rect>\n    <x>433</x>\n    <y>5</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Pack Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>80</x>\n    <y>5</y>\n    <width>110</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer/Shipvia</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>S/O #/Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>5</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered/Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>5</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scheduled</string>\n  </label>\n  <field>\n   <rect>\n    <x>585</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_cost</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_margin</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>5</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Hold Type</string>\n  </label>\n  <field>\n   <rect>\n    <x>505</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_sales</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>unnamed</name>\n   <column>cohead_id</column>\n   <head>\n    <height>18</height>\n    <field>\n     <rect>\n      <x>70</x>\n      <y>0</y>\n      <width>145</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>cust_name</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>370</x>\n      <y>0</y>\n      <width>70</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_scheddate</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>510</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_sales</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>290</x>\n      <y>0</y>\n      <width>70</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_orderdate</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>670</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_margin</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>5</x>\n      <y>0</y>\n      <width>70</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>cohead_number</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>220</x>\n      <y>0</y>\n      <width>60</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_holdtype</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>590</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_cost</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>440</x>\n      <y>0</y>\n      <width>70</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_packdate</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>220</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shiphead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipstatus</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>0</y>\n     <width>145</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipvia</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>290</x>\n     <y>0</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipdate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>590</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>totals</query>\n    <column>f_cost</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>407</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_totals</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>510</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>totals</query>\n    <column>f_sales</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>totals</query>\n    <column>f_margin</column>\n   </data>\n  </field>\n </rptfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102620
 
295     SummarizedBankrecHistory        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Summarized Bank Reconciliation History</title>\n <name>SummarizedBankrecHistory</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT bankrec_id,\n       formatBoolYN(bankrec_posted) AS f_posted,\n       formatDate(bankrec_created) AS f_created,\n       formatDate(bankrec_postdate) AS f_postdate,\n       bankrec_username AS f_username,\n       formatDate(bankrec_opendate) AS f_opendate,\n       formatDate(bankrec_enddate) AS f_enddate,\n       formatMoney(bankrec_openbal) AS f_openbal,\n       formatMoney(bankrec_endbal) AS f_endbal\n  FROM bankrec\n WHERE (bankrec_bankaccnt_id=&lt;? value("bankaccntid") ?>)\n ORDER BY bankrec_created;</sql>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT (bankaccnt_name || '-' || bankaccnt_descrip) AS f_bankaccnt\n  FROM bankaccnt\n WHERE (bankaccnt_id=&lt;? value("bankaccntid") ?>);</sql>\n </querysource>\n <rpthead>\n  <height>121</height>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>100</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>100</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>User</string>\n  </label>\n  <label>\n   <rect>\n    <x>120</x>\n    <y>5</y>\n    <width>625</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Summarized Bank Reconciliation History</string>\n  </label>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>100</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>100</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>115</ystart>\n   <xend>745</xend>\n   <yend>115</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>145</x>\n    <y>60</y>\n    <width>220</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_bankaccnt</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>100</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Opening Bal.</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>100</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>End Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>100</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ending Bal.</string>\n  </label>\n  <label>\n   <rect>\n    <x>40</x>\n    <y>60</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Bank Account:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>180</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>User</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ending Bal.</string>\n  </label>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Opening Bal.</string>\n  </label>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>End Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_posted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>96</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_postdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>370</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_opendate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>655</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_endbal</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>560</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_openbal</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>180</x>\n     <y>0</y>\n     <width>185</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_username</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>465</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_enddate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102621
 
250     SummarizedGLTransactions        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Summarized G/L Transactions</title>\n <name>SummarizedGLTransactions</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,\n       &lt;? if exists("source") ?>\n         text(&lt;? value("source") ?>)\n       &lt;? else ?>\n         text('All Sources')\n       &lt;? endif  ?>\n       AS source,\n       &lt;? if exists("showUsernames") ?>\n         text('Username')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_username;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT data.accnt_id AS accnt_id,\n-- account information\n       formatGLAccount(data.accnt_id) AS account,\n       accnt_descrip,\n       f_debit,\n       f_credit,\n-- transactionn details\n       formatDate(gltrans_date) AS transdate,\n       gltrans_source,\n       gltrans_doctype,\n       gltrans_docnumber,\n       gltrans_notes,\n       f_debitdetail,\n       f_creditdetail,\n       &lt;? if exists("showUsernames") ?>\n         gltrans_username\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_username\n  FROM ( SELECT accnt_id,\n                accnt_number,\n                accnt_profit,\n                accnt_sub,\n                accnt_descrip,\n                formatMoney( SUM( CASE WHEN (gltrans_amount &lt; 0) THEN (gltrans_amount * -1)\n                                       ELSE 0\n                                  END ) ) AS f_debit,\n                formatMoney( SUM( CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n                                       ELSE 0\n                                  END ) ) AS f_credit\n           FROM gltrans, accnt\n          WHERE ( (gltrans_accnt_id=accnt_id)\n            AND (NOT gltrans_deleted)\n            AND (gltrans_date BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n         &lt;? if exists("source") ?>\n            AND (gltrans_source=&lt;? value("source") ?>)\n         &lt;? endif ?>\n         &lt;? if exists("unpostedTransactions") ?>\n            AND (NOT gltrans_posted)\n         &lt;? elseif exists("postedTransactions") ?>\n            AND (gltrans_posted)\n         &lt;? endif ?>\n         )\n         GROUP BY accnt_id, accnt_number, accnt_profit, accnt_sub, accnt_descrip\n       ) AS data LEFT OUTER JOIN\n       ( SELECT accnt_id,\n                gltrans_date,\n                gltrans_created,\n                gltrans_source,\n                gltrans_doctype,\n                gltrans_docnumber,\n                gltrans_notes,\n                gltrans_username,\n                CASE WHEN (gltrans_amount &lt; 0) THEN formatMoney(gltrans_amount * -1)\n                     ELSE ''\n                END AS f_debitdetail,\n                CASE WHEN (gltrans_amount > 0) THEN formatMoney(gltrans_amount)\n                     ELSE ''\n                END AS f_creditdetail\n           FROM gltrans, accnt\n          WHERE ((gltrans_accnt_id=accnt_id)\n            AND (NOT gltrans_deleted)\n            AND (gltrans_date BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)\n         &lt;? if exists("source") ?>\n            AND (gltrans_source=&lt;? value("source") ?>)\n         &lt;? endif ?>\n         &lt;? if exists("unpostedTransactions") ?>\n            AND (NOT gltrans_posted)\n         &lt;? elseif exists("postedTransactions") ?>\n            AND (gltrans_posted)\n         &lt;? endif ?>\n                )\n       ) AS data2 ON (data.accnt_id=data2.accnt_id)\nORDER BY accnt_number, accnt_profit, accnt_sub, gltrans_date DESC, gltrans_created;</sql>\n </querysource>\n <rpthead>\n  <height>201</height>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>185</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>200</ystart>\n   <xend>745</xend>\n   <yend>200</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>545</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>120</x>\n    <y>185</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Decription/Notes</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>70</y>\n    <width>290</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>source</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_username</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>185</y>\n    <width>36</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>90</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>10</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Summarized G/L Transactions</string>\n  </label>\n  <field>\n   <rect>\n    <x>545</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>185</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account/Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>509</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Source:</string>\n  </label>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>17</height>\n </pghead>\n <pghead>\n  <height>28</height>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>120</x>\n    <y>5</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Decription/Notes</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account/Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>5</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_username</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>509</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>330</x>\n    <y>5</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>accnt_id</column>\n   <head>\n    <height>23</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>0</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>account</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>595</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_credit</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>120</x>\n      <y>0</y>\n      <width>305</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>accnt_descrip</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>509</x>\n      <y>0</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_debit</column>\n     </data>\n    </field>\n   </head>\n   <foot>\n    <height>14</height>\n    <line>\n     <xstart>112</xstart>\n     <ystart>5</ystart>\n     <xend>744</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>24</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>transdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>375</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>595</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>f_creditdetail</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>36</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_source</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>434</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_docnumber</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>120</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <bottompad>5</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_notes</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>f_username</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>509</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>f_debitdetail</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>26</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102622
 
449     SummarizedSalesHistory  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Summarized Sales History</title>\n <name>SummarizedSalesHistory</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>summarizedSalesHistory</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>163</height>\n  <label>\n   <rect>\n    <x>605</x>\n    <y>143</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Sales</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>143</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>First Sale</string>\n  </label>\n  <label>\n   <rect>\n    <x>475</x>\n    <y>143</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Sale</string>\n  </label>\n  <line>\n   <xstart>3</xstart>\n   <ystart>159</ystart>\n   <xend>743</xend>\n   <yend>159</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>5</y>\n    <width>515</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Summarized Sales History</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>143</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>143</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>143</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Group</string>\n  </label>\n  <text>\n   <rect>\n    <x>15</x>\n    <y>40</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>11</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>143</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>695</x>\n    <y>143</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>475</x>\n    <y>-1</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Sale</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>-1</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>First Sale</string>\n  </label>\n  <label>\n   <rect>\n    <x>605</x>\n    <y>-1</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Sales</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>-1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>-1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>695</x>\n    <y>-1</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>-1</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>-1</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Group</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>605</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>totalsales</column>\n    </data>\n    <format builtin="true">extprice</format>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qtyshipped</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>405</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>firstdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>475</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>lastdate</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <bottompad>11</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>groupsLit</column>\n    </data>\n   </text>\n   <text>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <bottompad>11</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>groups</column>\n    </data>\n   </text>\n   <text>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>190</width>\n     <height>15</height>\n    </rect>\n    <bottompad>11</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>groupsDescrip</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>695</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>currAbbr</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>105</x>\n    <y>1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>1</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102623
 
352     TaxAuthoritiesMasterList        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Tax Authorities Master List</title>\n <name>TaxAuthoritiesMasterList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>taxAuthorities</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>128</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>120</ystart>\n   <xend>745</xend>\n   <yend>120</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>103</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Tax Authorities Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>103</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>38</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>taxauth_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>taxauth_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102624
 
419     TaxHistoryDetail        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Tax History Detail</title>\n <name>TaxHistoryDetail</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("showSales") ?>\n         'Yes'\n       &lt;? else ?>\n         'No'\n       &lt;? endif ?>\n       AS showSales,\n       &lt;? if exists("showPurchases") ?>\n         'Yes'\n       &lt;? else ?>\n         'No'\n       &lt;? endif ?>\n       AS showPurchases,\n       &lt;? if exists("groupProper") ?>\n         &lt;? value("groupProper") ?> || '=' || &lt;? value("selection") ?>\n       &lt;? else ?>\n        'All' \n       &lt;? endif ?>\n       AS selection,\n       &lt;? if exists("distDate") ?>\n         text('Distribution Date')\n       &lt;? else ?>\n         text('Document Date')\n       &lt;? endif ?>\n       AS basis,\n       formatDate(&lt;? value("startDate") ?>) AS startdate,\n       formatDate(&lt;? value("endDate") ?>) AS enddate,\n       'Tax ' || (SELECT curr_symbol \n        FROM curr_symbol\n        WHERE curr_base) AS taxbaseLit;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>&lt;? if exists("showSales") ?>\n------------BEGIN SALES--------------\n-- All sales tax history including memos \nSELECT \n  formatDate(taxhist_distdate) AS f_distdate, \n  tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,&lt;? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,&lt;? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,&lt;? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  COALESCE(taxzone_code,&lt;? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n  CASE\n    WHEN (cohist_doctype != 'C') THEN\n      cohist_invcnumber\n    ELSE\n      cohist_ordernumber\n  END AS docnumber, \n  &lt;? value("sales") ?> AS source,\n  CASE\n    WHEN (cohist_doctype='I') THEN\n      &lt;? value("invoice") ?>\n    WHEN (cohist_doctype='C') THEN\n      &lt;? value("creditmemo") ?> \n    WHEN (cohist_doctype='D') THEN\n      &lt;? value("debitmemo") ?>\n    ELSE\n      &lt;? value("other") ?>\n  END AS doctype,\n  item_number, COALESCE(item_descrip1,cohist_misc_descrip) AS description,\n  CASE\n    WHEN (cohist_doctype != 'C') THEN\n      cohist_ordernumber \n  END AS ordernumber, cohist_invcdate AS docdate,\n  cohist_billtoname AS name, \n  formatQty(cohist_qtyshipped) AS f_qty, \n  formatSalesPrice(cohist_unitprice) AS f_unitprice, \n  formatMoney(cohist_qtyshipped * cohist_unitprice) AS f_amount,\n  formatMoney(taxhist_tax) AS f_taxlocal,\n  taxhist_tax / taxhist_curr_rate AS taxbase,\n  formatMoney(taxhist_tax / taxhist_curr_rate) AS f_taxbase\nFROM cohisttax\n JOIN cohist ON (cohist_id=taxhist_parent_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (cohist_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (cohist_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n&lt;? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? else ?>\nWHERE ((taxhist_docdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("tax_id") ?>\n AND (taxhist_tax_id=&lt;? value("tax_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=&lt;? value("taxtype_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxclass_id") ?>\n AND (taxclass_id=&lt;? value("taxclass_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxauth_id") ?>\n AND (taxauth_id=&lt;? value("taxauth_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxzone_id") ?>\n AND (taxzone_id=&lt;? value("taxzone_id") ?>)\n&lt;? endif ?>\n)\n&lt;? endif ?>\n--------------END SALES--------------------\n&lt;? if exists("showPurchases") ?>\n&lt;? if exists("showSales") ?>\n-- Union because sales and purchase shown together\nUNION ALL\n&lt;? endif ?>\n&lt;? endif ?>\n------------BEGIN PURCHASE----------------\n&lt;? if exists("showPurchases") ?>\n-- A/P Memo history\nSELECT \n  formatDate(taxhist_distdate) AS f_distdate, \n  tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,&lt;? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,&lt;? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,&lt;? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  &lt;? value("none") ?> AS taxzone,'' AS taxzone_descrip, curr_abbr, \n  apopen_docnumber AS docnumber, \n  &lt;? value("purchase") ?> AS source,\n  CASE\n    WHEN (apopen_doctype='C') THEN\n      &lt;? value("creditmemo") ?> \n    WHEN (apopen_doctype='D') THEN\n      &lt;? value("debitmemo") ?>\n    ELSE\n      &lt;? value("other") ?>\n  END AS doctype,\n  '' AS item_number, apopen_notes AS description,\n  apopen_ponumber AS ordernumber, apopen_docdate AS docdate,\n  vend_name AS name, \n  formatQty(1) AS f_qty, \n  formatPurchPrice(apopen_amount) AS unitprice, formatMoney(apopen_amount) AS f_amount,\n  formatMoney(taxhist_tax) AS f_taxlocal,\n  taxhist_tax / taxhist_curr_rate AS taxbase,\n  formatMoney(taxhist_tax / taxhist_curr_rate) AS f_taxbase\nFROM apopentax\n JOIN apopen ON (apopen_id=taxhist_parent_id)\n JOIN vendinfo ON (apopen_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n&lt;? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? else ?>\nWHERE ((taxhist_docdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("tax_id") ?>\n AND (taxhist_tax_id=&lt;? value("tax_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=&lt;? value("taxtype_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxclass_id") ?>\n AND (taxclass_id=&lt;? value("taxclass_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxauth_id") ?>\n AND (taxauth_id=&lt;? value("taxauth_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxzone_id") ?>\n AND (false)\n&lt;? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nUNION ALL\n--Voucher Header History\nSELECT \n  formatDate(taxhist_distdate) AS f_distdate, \n  tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,&lt;? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,&lt;? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,&lt;? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  COALESCE(taxzone_code,&lt;? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n  vohead_number AS docnumber, \n  &lt;? value("purchase") ?> AS source,\n  &lt;? value("voucher") ?>  AS doctype,\n  '', vohead_notes AS description,\n  pohead_number AS ordernumber, vohead_docdate AS docdate,\n  vend_name AS name, \n  formatQty(1) AS f_qty, \n  formatPurchPrice(0) AS f_unitprice, formatMoney(0) AS f_amount,\n  formatMoney(taxhist_tax) AS f_taxlocal,\n  taxhist_tax / taxhist_curr_rate AS taxbase,\n  formatMoney(taxhist_tax / taxhist_curr_rate) AS f_taxbase\nFROM voheadtax\n JOIN vohead ON (vohead_id=taxhist_parent_id)\n LEFT OUTER JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n&lt;? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? else ?>\nWHERE ((taxhist_docdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("tax_id") ?>\n AND (taxhist_tax_id=&lt;? value("tax_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=&lt;? value("taxtype_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxclass_id") ?>\n AND (taxclass_id=&lt;? value("taxclass_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxauth_id") ?>\n AND (taxauth_id=&lt;? value("taxauth_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxzone_id") ?>\n AND (taxzone_id=&lt;? value("taxzone_id") ?>)\n&lt;? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nUNION ALL\n--Voucher Line Item\nSELECT \n  formatDate(taxhist_distdate) AS f_distdate, \n  tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,&lt;? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,&lt;? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,&lt;? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  COALESCE(taxzone_code,&lt;? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n  vohead_number AS docnumber, \n  &lt;? value("purchase") ?> AS source,\n  &lt;? value("voucher") ?>  AS doctype,\n  COALESCE(item_number,expcat_code), COALESCE(item_descrip1,expcat_descrip) AS description,\n  pohead_number AS ordernumber, vohead_docdate AS docdate,\n  vend_name AS name, \n  formatQty(voitem_qty) AS f_qty, \n  formatPurchPrice(COALESCE(SUM(vodist_amount),0)/voitem_qty) AS unitprice, \n  formatMoney(COALESCE(SUM(vodist_amount),0)) AS f_amount,\n  formatMoney(taxhist_tax) AS taxlocal,\n  taxhist_tax / taxhist_curr_rate AS taxbase,\n  formatMoney(taxhist_tax / taxhist_curr_rate) AS f_taxbase\nFROM voitemtax\n JOIN voitem ON (voitem_id=taxhist_parent_id)\n JOIN vohead ON (vohead_id=voitem_vohead_id)\n JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN poitem ON (voitem_poitem_id=poitem_id)\n JOIN vodist ON ((vodist_poitem_id=poitem_id)\n            AND  (vodist_vohead_id=vohead_id))\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN expcat ON (expcat_id=poitem_expcat_id)\n&lt;? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? else ?>\nWHERE ((taxhist_docdate BETWEEN &lt;? value("startDate") ?>\n                             AND &lt;? value("endDate") ?>)\n&lt;? endif ?>\n&lt;? if exists("tax_id") ?>\n AND (taxhist_tax_id=&lt;? value("tax_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=&lt;? value("taxtype_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxclass_id") ?>\n AND (taxclass_id=&lt;? value("taxclass_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxauth_id") ?>\n AND (taxauth_id=&lt;? value("taxauth_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("taxzone_id") ?>\n AND (taxzone_id=&lt;? value("taxzone_id") ?>)\n&lt;? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nGROUP BY taxhist_id,taxhist_distdate,tax_code,tax_descrip,\n  taxtype_name,taxtype_descrip,taxclass_code,taxclass_descrip,\n  taxauth_code,taxauth_descrip,taxzone,taxzone_descrip,curr_abbr,\n  vohead_number,pohead_number,item_number,item_descrip1,\n  vohead_curr_id,vohead_distdate,vohead_docdate,vend_name,\n  expcat_code,expcat_descrip,taxhist_tax,taxhist_curr_rate,\n  voitem_qty\n&lt;? endif ?>\n-------------END PURCHASE--------------\nORDER BY docdate DESC, docnumber DESC\n\n</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Tax History Detail</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>460.577</x>\n    <y>137.571</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>460.577</x>\n    <y>116.571</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>350.577</x>\n    <y>137.571</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>350.577</x>\n    <y>116.571</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>350.577</x>\n    <y>95.9618</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Basis:</string>\n  </label>\n  <field>\n   <rect>\n    <x>461</x>\n    <y>96</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>basis</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>28.5</x>\n    <y>117</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purchases:</string>\n  </label>\n  <field>\n   <rect>\n    <x>141</x>\n    <y>137</y>\n    <width>230</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>selection</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>141</x>\n    <y>117</y>\n    <width>230</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>showPurchases</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>28.5</x>\n    <y>96</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sales:</string>\n  </label>\n  <field>\n   <rect>\n    <x>141</x>\n    <y>96</y>\n    <width>230</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>showSales</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>28.5</x>\n    <y>137</y>\n    <width>103</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show:</string>\n  </label>\n  <label>\n   <rect>\n    <x>200.44</x>\n    <y>182.3</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Tax Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>100.44</x>\n    <y>182.3</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>300.44</x>\n    <y>200.3</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>5.44046</x>\n    <y>182.3</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc#</string>\n  </label>\n  <label>\n   <rect>\n    <x>300.44</x>\n    <y>182.3</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <bottom/>\n   <string>Item#</string>\n  </label>\n  <label>\n   <rect>\n    <x>100.44</x>\n    <y>200.3</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>500.44</x>\n    <y>182.3</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Tax</string>\n  </label>\n  <label>\n   <rect>\n    <x>200.44</x>\n    <y>200.3</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>575.44</x>\n    <y>182.3</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <field>\n   <rect>\n    <x>650</x>\n    <y>182</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>taxbaseLit</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>52</height>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>30</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <line>\n   <xstart>6</xstart>\n   <ystart>45</ystart>\n   <xend>746</xend>\n   <yend>45</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>12</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Tax Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>12</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <bottom/>\n   <string>Item#</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>12</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Tax</string>\n  </label>\n  <label>\n   <rect>\n    <x>300</x>\n    <y>30</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>12</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>12</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>12</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc#</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>30</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>650</x>\n    <y>12</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>taxbaseLit</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>37</height>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>tax</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>source</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>curr_abbr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_taxlocal</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>95</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>16.6</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>description</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>650</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_taxbase</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>16.6</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>docdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>16.6</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>doctype</column>\n    </data>\n   </field>\n   <line>\n    <xstart>6</xstart>\n    <ystart>33</ystart>\n    <xend>746</xend>\n    <yend>33</yend>\n    <weight>1</weight>\n   </line>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>23</height>\n  <field>\n   <rect>\n    <x>648</x>\n    <y>4</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>taxbase</column>\n   </data>\n   <tracktotal builtin="true" >money</tracktotal>\n  </field>\n  <label>\n   <rect>\n    <x>1</x>\n    <y>4</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Total:</string>\n  </label>\n </rptfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102625
 
353     TaxTypesMasterList      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Tax Types Master List</title>\n <name>TaxTypesMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>select taxtype_name, taxtype_descrip\n  from taxtype\norder by taxtype_name;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Tax Types Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tax Type</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Tax Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n    <column></column>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>taxtype_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>taxtype_descrip</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102626
 
136     TimePhasedAvailability  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Phased Availability</title>\n <name>TimePhasedAvailability</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists(&quot;plancode_id&quot;) ?>\n         ( SELECT (plancode_code || '-' || plancode_name)\n             FROM plancode\n            WHERE (plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>) )\n       &lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n         text(&lt;? value(&quot;plancode_pattern&quot;) ?>)\n       &lt;? else ?>\n         text('All Planner Codes')\n       &lt;? endif ?>\n       AS plncode;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT findPeriodStart(rcalitem_id) AS pstart,\n       findPeriodEnd(rcalitem_id) AS pend,\n       (formatDate(findPeriodStart(rcalitem_id)) || '-' || formatDate(findPeriodEnd(rcalitem_id))) AS period,\n       item_number,\n       uom_name AS f_uom,\n       warehous_code,\n       formatQty(qtyAvailable(itemsite_id, findPeriodStart(rcalitem_id))) AS f_unit\n  FROM rcalitem, itemsite, item, uom, whsinfo\n WHERE ((rcalitem_id in (\n&lt;? foreach(&quot;period_id_list&quot;) ?>\n  &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value(&quot;period_id_list&quot;) ?>\n&lt;? endforeach ?>\n                        ))\n   AND (itemsite_warehous_id=warehous_id)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;plancode_id&quot;) ?>\n   AND (itemsite_plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)\n&lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n   AND (itemsite_plancode_id IN ( SELECT plancode_id\n                                    FROM plancode\n                                   WHERE (plancode_code ~ &lt;? value(&quot;plancode_pattern&quot;) ?>)))\n&lt;? endif ?>\n  )\n UNION\nSELECT findPeriodStart(acalitem_id) AS pstart,\n       findPeriodEnd(acalitem_id) AS pend,\n       (formatDate(findPeriodStart(acalitem_id)) || '-' || formatDate(findPeriodEnd(acalitem_id))) AS period,\n       item_number,\n       uom_name AS f_uom,\n       warehous_code,\n       formatQty(qtyAvailable(itemsite_id, findPeriodStart(acalitem_id))) AS f_unit\n  FROM acalitem, itemsite, item, uom, whsinfo\n WHERE ((acalitem_id IN (\n&lt;? foreach(&quot;period_id_list&quot;) ?>\n  &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value(&quot;period_id_list&quot;) ?>\n&lt;? endforeach ?>\n                        ))\n   AND (itemsite_warehous_id=warehous_id)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;plancode_id&quot;) ?>\n   AND (itemsite_plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)\n&lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n   AND (itemsite_plancode_id IN ( SELECT plancode_id\n                                    FROM plancode\n                                   WHERE (plancode_code ~ &lt;? value(&quot;plancode_pattern&quot;) ?>)))\n&lt;? endif ?>\n  )\nORDER BY pstart, item_number, warehous_code;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>105</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>10</y>\n    <width>484</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time Phased Availability</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Planner Code:</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>105</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>80</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>plncode</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>pstart</column>\n   <head>\n    <height>6</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>5</y>\n      <width>250</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>period</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_unit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_uom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>690</x>\n    <y>0</y>\n    <width>51</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102627
 
450     TimePhasedBookings      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Phased Bookings</title>\n <name>TimePhasedBookings</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("byCust") ?>\n         text('Customer')\n       &lt;? elseif exists("byProdcat") ?>\n         text('Product Category')\n       &lt;? else ?>\n         text('Item')\n       &lt;? endif ?>\n          AS groupby,\n      &lt;? if exists("byCust") ?>\n         text('Name')\n       &lt;? else ?>\n         text('Description')\n       &lt;? endif ?>\n          AS groupbyDescrip,\n       &lt;? if exists("salesDollars") ?>\n         text('')\n       &lt;? else ?>\n         text('UOM')\n       &lt;? endif ?>\n       AS lbl_uom,\n       &lt;? if exists("inventoryUnits") ?>\n         text('Qty.')\n       &lt;? elseif exists("capacityUnits") ?>\n         text('Capacity')\n       &lt;? elseif exists("altCapacityUnits") ?>\n         text('Alt. Capacity')\n       &lt;? elseif exists("salesDollars") ?>\n         text('Sales')\n       &lt;? else ?>\n         text('ERROR')\n       &lt;? endif ?>\n       AS lbl_unittype;     </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT *, \n  coalesce(unit,0) AS unit, \n&lt;? if exists("salesDollars") ?>\n  formatExtPrice(coalesce(unit,0)) AS f_unit\n&lt;? else ?>\n  formatQty(coalesce(unit,0)) AS f_unit\n&lt;? endif ?>\nFROM\n-- Outer Table Query\n(SELECT DISTINCT\n       calitem_id,\n       findPeriodStart(calitem_id) AS pstart,\n       findPeriodEnd(calitem_id) AS pend,\n       (formatDate(findPeriodStart(calitem_id)) || '-' || formatDate(findPeriodEnd(calitem_id))) AS period,\n&lt;? if exists("byCust") ?>\n         cust_id, cust_number AS f_number, cust_name AS f_description\n&lt;? elseif exists("byProdcat") ?>\n         prodcat_id, prodcat_code AS f_number, prodcat_descrip AS f_description\n&lt;? elseif exists("byItem") ?>\n         item_id, item_number AS f_number, item_descrip1 AS f_description\n&lt;? endif ?>\n       , warehous_id, warehous_code\n&lt;? if exists("salesDollars") ?>\n       , &lt;? value("baseCurrAbbr") ?>::text AS f_uom\n&lt;? else ?>\n  &lt;? if exists("inventoryUnits") ?>\n       , uom_name AS f_uom\n  &lt;? elseif exists("capacityUnits") ?>\n       , itemcapuom(item_id) AS f_uom\n  &lt;? elseif exists("altCapacityUnits") ?>\n       , itemaltcapuom(item_id) AS f_uom\n  &lt;? endif ?>\n&lt;? endif ?>\nFROM coitem\n JOIN cohead ON (coitem_cohead_id=cohead_id)\n JOIN itemsite ON (coitem_itemsite_id=itemsite_id)\n JOIN item ON (itemsite_item_id=item_id)\n&lt;? if exists("inventoryUnits") ?>\n JOIN uom ON (item_inv_uom_id=uom_id)\n&lt;? endif ?>\n JOIN site() ON (itemsite_warehous_id=warehous_id)\n&lt;? if reExists("[cC]ust") ?>\n JOIN custinfo ON (cohead_cust_id=cust_id)\n&lt;? endif ?> \n&lt;? if reExists("[pP]rodcat") ?>\n JOIN prodcat ON (item_prodcat_id=prodcat_id)\n&lt;? endif ?>\n    ,   ( SELECT rcalitem_id AS calitem_id,\n                findPeriodStart(rcalitem_id) AS calitem_start,\n                findPeriodEnd(rcalitem_id) AS calitem_end\n           FROM rcalitem\n          WHERE (rcalitem_id IN (\n&lt;? foreach("period_id_list") ?>\n  &lt;? if not isfirst("period_id_list") ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value("period_id_list") ?>\n&lt;? endforeach ?>\n                                )\n                )\n          UNION\n         SELECT acalitem_id AS calitem_id,\n                findPeriodStart(acalitem_id) AS calitem_start,\n                findPeriodEnd(acalitem_id) AS calitem_end\n           FROM acalitem\n          WHERE (acalitem_id IN (\n&lt;? foreach("period_id_list") ?>\n  &lt;? if not isfirst("period_id_list") ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value("period_id_list") ?>\n&lt;? endforeach ?>\n                                )\n                )\n       ) AS calitem\nWHERE ((cohead_orderdate BETWEEN\n&lt;? foreach("period_id_list") ?>\n  &lt;? if isfirst("period_id_list") ?>\n    findPeriodStart(&lt;? value("period_id_list") ?>)\n  &lt;? endif ?>\n  &lt;? if isLast("period_id_list") ?>\n    AND findPeriodEnd(&lt;? value("period_id_list") ?>)\n  &lt;? endif ?>\n&lt;? endforeach ?>\n)\n    AND (coitem_status != 'X')\n&lt;? if exists("item_id") ?> \n    AND (item_id=&lt;? value("item_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("cust_id") ?> \n    AND (cust_id=&lt;? value("cust_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("custtype_id") ?> \n    AND (cust_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("custtype_pattern") ?>\n    AND (cust_custtype_id IN (SELECT custtype_id \n                              FROM custtype \n                              WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("prodcat_id") ?> \n    AND (item_prodcat_id=&lt;? value("prodcat_id") ?>) \n&lt;? endif ?>\n&lt;? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT prodcat_id  \n                             FROM prodcat \n                             WHERE (prodcat_code ~ &lt;? value("prodcat_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?> \n    AND(itemsite_warehous_id=&lt;? value("warehous_id") ?>) \n&lt;? endif ?>\n      )\nORDER BY pstart, f_number, f_description, f_uom, warehous_code) list\nLEFT OUTER JOIN\n-- Bookings calcuations\n-- Loop through each period bucket to find bookings for period\n(&lt;? foreach("period_id_list") ?>\n  SELECT \n       &lt;? value("period_id_list") ?> AS calitem_id,\n       warehous_id,\n&lt;? if exists("byCust") ?>\n         cust_id\n&lt;? elseif exists("byProdcat") ?>\n         prodcat_id \n&lt;? elseif exists("byItem") ?>\n         item_id\n&lt;? endif ?>\n&lt;? if exists("salesDollars") ?>\n       , sum(round((coitem_qtyord * coitem_qty_invuomratio) * (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2)) AS unit\n       , &lt;? value("baseCurrAbbr") ?>::text AS f_uom\n&lt;? else ?>\n       , sum(coitem_qtyord)\n  &lt;? if exists("capacityUnits") ?>\n       * itemcapinvrat(item_id)\n  &lt;? elseif exists("altCapacityUnits") ?>\n       * itemaltcapinvrat(item_id)\n  &lt;? endif ?>\n       AS unit\n  &lt;? if exists("inventoryUnits") ?>\n       , uom_name AS f_uom\n  &lt;? elseif exists("capacityUnits") ?>\n       , itemcapuom(item_id) AS f_uom\n  &lt;? elseif exists("altCapacityUnits") ?>\n       , itemaltcapuom(item_id) AS f_uom\n  &lt;? endif ?>\n&lt;? endif ?>\n  FROM coitem\n   JOIN cohead ON (coitem_cohead_id=cohead_id)\n   JOIN itemsite ON (coitem_itemsite_id=itemsite_id)\n   JOIN item ON (itemsite_item_id=item_id)\n&lt;? if exists("inventoryUnits") ?>\n   JOIN uom ON (item_inv_uom_id=uom_id)\n&lt;? endif ?>\n   JOIN site() ON (itemsite_warehous_id=warehous_id)\n&lt;? if reExists("[cC]ust") ?>\n   JOIN custinfo ON (cohead_cust_id=cust_id)\n&lt;? endif ?> \n&lt;? if reExists("[pP]rodcat") ?>\n   JOIN prodcat ON (item_prodcat_id=prodcat_id)\n&lt;? endif ?>\n  WHERE ((cohead_orderdate BETWEEN findPeriodStart(&lt;? value("period_id_list") ?>) AND findPeriodEnd(&lt;? value("period_id_list") ?>))\n    AND (coitem_status != 'X')\n&lt;? if exists("item_id") ?> \n    AND (item_id=&lt;? value("item_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("cust_id") ?> \n    AND (cust_id=&lt;? value("cust_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("custtype_id") ?> \n    AND (cust_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("custtype_pattern") ?>\n    AND (cust_custtype_id IN (SELECT custtype_id \n                              FROM custtype \n                              WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("prodcat_id") ?> \n    AND (item_prodcat_id=&lt;? value("prodcat_id") ?>) \n&lt;? endif ?>\n&lt;? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT prodcat_id  \n                             FROM prodcat \n                             WHERE (prodcat_code ~ &lt;? value("prodcat_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?> \n    AND(itemsite_warehous_id=&lt;? value("warehous_id") ?>) \n&lt;? endif ?>\n      )\nGROUP BY\n&lt;? if exists("byCust") ?>\n  cust_id, \n  &lt;? if exists("capacityUnits") ?>\n    item_id,\n  &lt;? elseif exists("altCapacityUnits") ?>\n    item_id,\n  &lt;? endif ?>\n&lt;? elseif exists("byProdcat") ?>\n  prodcat_id,\n  &lt;? if exists("capacityUnits") ?>\n    item_id,\n  &lt;? elseif exists("altCapacityUnits") ?>\n    item_id,\n  &lt;? endif ?>\n&lt;? elseif exists("byItem") ?>\n  item_id,\n&lt;? endif ?>\n  f_uom, warehous_id\n  &lt;? if isLast("period_id_list") ?>\n  &lt;? else ?>\nUNION\n  &lt;? endif ?>\n&lt;? endforeach ?> \n) bookings ON\n&lt;? if exists("byCust") ?>\n   (list.cust_id=bookings.cust_id)\n&lt;? elseif exists("byProdcat") ?>\n    (list.prodcat_id=bookings.prodcat_id)\n&lt;? elseif exists("byItem") ?>\n    (list.item_id=bookings.item_id)\n&lt;? endif ?>\n   AND (list.calitem_id=bookings.calitem_id)\n   AND (list.warehous_id=bookings.warehous_id)\n   AND (list.f_uom=bookings.f_uom)</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>3</y>\n    <width>385</width>\n    <height>33</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time Phased Bookings</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unittype</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>530</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_uom</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>220</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>groupby</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>330</x>\n    <y>200</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>groupbyDescrip</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>33</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>-1</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>-1</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <field>\n   <rect>\n    <x>530</x>\n    <y>-1</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_uom</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>-1</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unittype</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>215</x>\n    <y>-1</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>groupby</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>330</x>\n    <y>-1</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>groupbyDescrip</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>pstart</column>\n   <head>\n    <height>6</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>5</y>\n      <width>150</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>period</column>\n     </data>\n    </field>\n   </head>\n   <foot>\n    <height>31</height>\n    <field>\n     <rect>\n      <x>660</x>\n      <y>5</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>unit</column>\n     </data>\n     <format builtin="true">extprice</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <line>\n     <xstart>640</xstart>\n     <ystart>0</ystart>\n     <xend>745</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>530</x>\n      <y>5</y>\n      <width>110</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total:</string>\n    </label>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_unit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_uom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>220</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_description</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>-1</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>-1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>690</x>\n    <y>-1</y>\n    <width>51</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>-1</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102628
 
199     TimePhasedDemandByPlannerCode   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Phased Demand By Planner Code</title>\n <name>TimePhasedDemandByPlannerCode</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists(&quot;plancode_id&quot;) ?>\n         ( SELECT (plancode_code||'-'||plancode_name)\n             FROM plancode\n            WHERE plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)\n       &lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n         text(&lt;? value(&quot;plancode_pattern&quot;) ?>)\n       &lt;? else ?>\n         text('All Planner Codes')\n       &lt;? endif ?>\n       AS plancode,\n       &lt;? if exists(&quot;inventoryUnits&quot;) ?>\n         text('Qty.')\n       &lt;? elseif exists(&quot;capacityUnits&quot;) ?>\n         text('Capacity')\n       &lt;? elseif exists(&quot;altCapacityUnits&quot;) ?>\n         text('Alt. Capacity')\n       &lt;? else ?>\n         text('ERROR')\n       &lt;? endif ?>\n       AS lbl_unittype ;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT findPeriodStart(calitem_id) AS pstart,\n       findPeriodEnd(calitem_id) AS pend,\n       (formatDate(findPeriodStart(calitem_id)) || '-' || formatDate(findPeriodEnd(calitem_id))) AS period,\n       plancode_code,\n       &lt;? if exists(&quot;inventoryUnits&quot;) ?>\n         uom_name\n       &lt;? elseif exists(&quot;capacityUnits&quot;) ?>\n         itemcapuom(item_id)\n       &lt;? elseif exists(&quot;altCapacityUnits&quot;) ?>\n         itemaltcapuom(item_id)\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_uom,\n       warehous_code,\n       &lt;? if exists(&quot;inventoryUnits&quot;) ?>\n         formatQty(SUM(summDemand(itemsite_id, calitem_id)))\n       &lt;? elseif exists(&quot;capacityUnits&quot;) ?>\n         formatQty(SUM(summDemand(itemsite_id, calitem_id) * itemcapinvrat(item_id)))\n       &lt;? elseif exists(&quot;altCapacityUnits&quot;) ?>\n         formatQty(SUM(summDemand(itemsite_id, calitem_id) * itemaltcapinvrat(item_id)))\n       &lt;? else ?>\n         formatQty(SUM(summDemand(itemsite_id, calitem_id)))\n       &lt;? endif ?>\n       AS f_unit\n  FROM itemsite, item, uom, whsinfo, plancode,\n       (SELECT rcalitem_id AS calitem_id\n          FROM rcalitem\n         WHERE (rcalitem_id in (\n&lt;? foreach(&quot;period_id_list&quot;) ?>\n  &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value(&quot;period_id_list&quot;) ?>\n&lt;? endforeach ?>\n                               ))\n         UNION\n        SELECT acalitem_id as calitem_id\n          FROM acalitem\n         WHERE (acalitem_id in (\n&lt;? foreach(&quot;period_id_list&quot;) ?>\n  &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value(&quot;period_id_list&quot;) ?>\n&lt;? endforeach ?>\n                               ))\n        ) AS calitem\n WHERE ((itemsite_warehous_id=warehous_id)\n   AND (itemsite_active)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (itemsite_plancode_id=plancode_id)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;plancode_id&quot;) ?>\n   AND (plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)\n&lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n   AND (plancode_code ~ &lt;? value(&quot;plancode_pattern&quot;) ?>)\n&lt;? endif ?>\n  )\nGROUP BY pstart, pend, period, plancode_code, warehous_code, f_uom\nORDER BY pstart, plancode_code, warehous_code, f_uom;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>200</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Planner Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>145</x>\n    <y>10</y>\n    <width>580</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time Phased Demand By Planner Code</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Planner Code:</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unittype</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>105</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>105</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>plancode</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>0</y>\n    <width>114</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Planner Code</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unittype</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>pstart</column>\n   <head>\n    <height>6</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>5</y>\n      <width>250</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>period</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>plancode_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_uom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_unit</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>690</x>\n    <y>0</y>\n    <width>51</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102629
 
251     TimePhasedOpenAPItems   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Phased Open A/P Items</title>\n <name>TimePhasedOpenAPItems</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;vend_id&quot;) ?>\n         ( SELECT vend_name\n             FROM vendinfo\n            WHERE (vend_id=&lt;? value(&quot;vend_id&quot;) ?>) )\n       &lt;? elseif exists(&quot;vendtype_id&quot;) ?>\n         ( SELECT (vendtype_code || '-' || vendtype_descrip)\n             FROM vendtype\n            WHERE (vendtype_id=&lt;? value(&quot;vendtype_id&quot;) ?>) )\n       &lt;? elseif exists(&quot;vendtype_pattern&quot;) ?>\n         text(&lt;? value(&quot;vendtype_pattern&quot;) ?>)\n       &lt;? else ?>\n         text('All Vendors')\n       &lt;? endif ?>\n       AS f_value,\n       &lt;? if reExists(&quot;vendtype_.*&quot;) ?>\n         text('Vendor Type:')\n       &lt;? else ?>\n         text('Vendor:')\n       &lt;? endif ?>\n       AS f_label;\n       </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT pstart, pend,\n       period,\n       vend_number, vend_name,\n       value,\n       formatMoney(value) AS f_value\n  FROM (\n  SELECT calitem_start AS pstart,\n         calitem_end AS pend,\n         (formatDate(calitem_start) || '-' || formatDate(calitem_end)) AS period,\n         vend_number,\n         vend_name,\n         openAPItemsValue(vend_id, calitem_id) AS value\n    FROM vendinfo,\n         ( SELECT rcalitem_id AS calitem_id,\n                  findPeriodStart(rcalitem_id) AS calitem_start,\n                  findPeriodEnd(rcalitem_id) AS calitem_end\n             FROM rcalitem\n            WHERE (rcalitem_id IN (\n  &lt;? foreach(&quot;period_id_list&quot;) ?>\n    &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n      ,\n    &lt;? endif ?>\n    &lt;? value(&quot;period_id_list&quot;) ?>\n  &lt;? endforeach ?>\n                                  )\n                  )\n            UNION\n           SELECT acalitem_id AS calitem_id,\n                  findPeriodStart(acalitem_id) AS calitem_start,\n                  findPeriodEnd(acalitem_id) AS calitem_end\n             FROM acalitem\n            WHERE (acalitem_id IN (\n  &lt;? foreach(&quot;period_id_list&quot;) ?>\n    &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n      ,\n    &lt;? endif ?>\n    &lt;? value(&quot;period_id_list&quot;) ?>\n  &lt;? endforeach ?>\n                                  )\n                  )\n         ) AS calitem\n  &lt;? if exists(&quot;vend_id&quot;) ?>\n   WHERE (vend_id=&lt;? value(&quot;vend_id&quot;) ?>)\n  &lt;? elseif exists(&quot;vendtype_id&quot;) ?>\n   WHERE (vend_vendtype_id=&lt;? value(&quot;vendtype_id&quot;) ?>)\n  &lt;? elseif exists(&quot;vendtype_pattern&quot;) ?>\n   WHERE (vend_vendtype_id IN (SELECT vendtype_id\n                                 FROM vendtype\n                                WHERE (vendtype_code ~ &lt;? value(&quot;vendtype_pattern&quot;) ?>) ))\n  &lt;? endif ?>\n  ) AS data\n WHERE (value != 0)\nORDER BY pstart, pend, vend_number\n</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vend #</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>100</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_label</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vend Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>145</x>\n    <y>10</y>\n    <width>580</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time Phased Open A/P Items</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_value</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vend #</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vend Name</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>pstart</column>\n   <head>\n    <height>6</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>5</y>\n      <width>250</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>period</column>\n     </data>\n    </field>\n   </head>\n   <foot>\n    <height>31</height>\n    <field>\n     <rect>\n      <x>645</x>\n      <y>10</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>value</column>\n     </data>\n     <tracktotal subtotal="true" builtin="true" >money</tracktotal>\n    </field>\n    <line>\n     <xstart>635</xstart>\n     <ystart>5</ystart>\n     <xend>745</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>520</x>\n      <y>10</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total:</string>\n    </label>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>0</y>\n     <width>210</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_value</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>690</x>\n    <y>0</y>\n    <width>51</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102630
 
252     TimePhasedOpenARItems   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Phased Open A/R Items</title>\n <name>TimePhasedOpenARItems</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;cust_id&quot;) ?>\n         ( SELECT cust_name\n             FROM custinfo\n            WHERE (cust_id=&lt;? value(&quot;cust_id&quot;) ?>) )\n       &lt;? elseif exists(&quot;custtype_id&quot;) ?>\n         ( SELECT (custtype_code || '-' || custtype_descrip)\n             FROM custtype\n            WHERE (custtype_id=&lt;? value(&quot;custtype_id&quot;) ?>) )\n      &lt;? elseif exists(&quot;custgrp_id&quot;) ?>\n         ( SELECT (custgrp_name || '-' ||  custgrp_descrip)\n\t   FROM custgrp\n            WHERE (custgrp_id=&lt;? value(&quot;custgrp_id&quot;) ?>) )\n       &lt;? elseif exists(&quot;custtype_pattern&quot;) ?>\n         text(&lt;? value(&quot;custtype_pattern&quot;) ?>)\n       &lt;? else ?>\n         text('All Customers')\n       &lt;? endif ?>\n       AS f_value,\n       &lt;? if reExists(&quot;custtype_.*&quot;) ?>\n         text('Customer Type:')\n       &lt;? elseif exists(&quot;custgrp_id&quot;) ?>\n         text('Customer Group:')\n       &lt;? else ?>\n         text('Customer:')\n       &lt;? endif ?>\n       AS f_label;\n       </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT pstart, pend,\n       period,\n       cust_number, cust_name,\n       value,\n       formatMoney(value) AS f_value\n  FROM (\n  SELECT calitem_start AS pstart,\n         calitem_end AS pend,\n         (formatDate(calitem_start) || '-' || formatDate(calitem_end)) AS period,\n         cust_number,\n         cust_name,\n         openARItemsValue(cust_id, calitem_id) AS value\n    FROM custinfo LEFT OUTER JOIN custgrpitem ON (cust_id=custgrpitem_cust_id)\n         LEFT OUTER JOIN custgrp ON (custgrpitem_custgrp_id=custgrp_id),\n         ( SELECT rcalitem_id AS calitem_id,\n                  findPeriodStart(rcalitem_id) AS calitem_start,\n                  findPeriodEnd(rcalitem_id) AS calitem_end\n             FROM rcalitem\n            WHERE (rcalitem_id IN (\n  &lt;? foreach(&quot;period_id_list&quot;) ?>\n    &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n      ,\n    &lt;? endif ?>\n    &lt;? value(&quot;period_id_list&quot;) ?>\n  &lt;? endforeach ?>\n                                  )\n                  )\n            UNION\n           SELECT acalitem_id AS calitem_id,\n                  findPeriodStart(acalitem_id) AS calitem_start,\n                  findPeriodEnd(acalitem_id) AS calitem_end\n             FROM acalitem\n            WHERE (acalitem_id IN (\n  &lt;? foreach(&quot;period_id_list&quot;) ?>\n    &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n      ,\n    &lt;? endif ?>\n    &lt;? value(&quot;period_id_list&quot;) ?>\n  &lt;? endforeach ?>\n                                  )\n                  )\n           ) AS calitem\n  &lt;? if exists(&quot;cust_id&quot;) ?>\n   WHERE (cust_id=&lt;? value(&quot;cust_id&quot;) ?>)\n  &lt;? elseif exists(&quot;custtype_id&quot;) ?>\n   WHERE (cust_custtype_id=&lt;? value(&quot;custtype_id&quot;) ?>)\n  &lt;? elseif exists(&quot;custgrp_id&quot;) ?>\n   WHERE (custgrp_id=&lt;? value(&quot;custgrp_id&quot;) ?>)\n  &lt;? elseif exists(&quot;custtype_pattern&quot;) ?>\n   WHERE (cust_custtype_id IN (SELECT custtype_id\n                                 FROM custtype\n                                WHERE (custtype_code ~ &lt;? value(&quot;custtype_pattern&quot;) ?>) ))\n  &lt;? endif ?>\n  ) AS data\n WHERE (value != 0)\nORDER BY pstart, pend, cust_number\n</sql>\n </querysource>\n <rpthead>\n  <height>222</height>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>100</y>\n    <width>125</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_label</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>145</x>\n    <y>10</y>\n    <width>580</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time Phased Open A/R Items</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>100</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_value</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>22</height>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>pstart</column>\n   <head>\n    <height>7</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>5</y>\n      <width>250</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>period</column>\n     </data>\n    </field>\n   </head>\n   <foot>\n    <height>27</height>\n    <line>\n     <xstart>635</xstart>\n     <ystart>5</ystart>\n     <xend>745</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>645</x>\n      <y>5</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>value</column>\n     </data>\n     <tracktotal subtotal="true" builtin="true" >money</tracktotal>\n    </field>\n    <label>\n     <rect>\n      <x>520</x>\n      <y>5</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total:</string>\n    </label>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>0</y>\n     <width>210</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_value</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>690</x>\n    <y>0</y>\n    <width>51</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102631
 
273     TimePhasedPlannedRevenueExpensesByPlannerCode   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Phased Planned Revenue/Expenses By Planner Code</title>\n <name>TimePhasedPlannedRevenueExpensesByPlannerCode</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists(&quot;plancode_id&quot;) ?>\n         ( SELECT (plancode_code || '-' || plancode_name)\n             FROM plancode\n            WHERE (plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>) )\n       &lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n         text(&lt;? value(&quot;plancode_pattern&quot;) ?>)\n       &lt;? else ?>\n         text('All Planner Codes')\n       &lt;? endif ?>\n       AS plncode;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT (formatDate(calitem_startdate) || '-' || formatDate(calitem_enddate)) AS period,\n       formatMoney(COALESCE(cost,0.0)) AS f_cost,\n       formatMoney(COALESCE(revenue,0.0)) AS f_revenue,\n       formatMoney(COALESCE(revenue,0.0) - COALESCE(cost,0.0)) AS f_profit\n  FROM ( SELECT calitem_startdate,\n                calitem_enddate,\n                SUM(plannedCost(plancode_id, warehous_id,\n                    &lt;? if exists(&quot;actualCost&quot;) ?>'A'&lt;? else ?>'S'&lt;? endif ?>\n                    , calitem_id))\n                 AS cost,\n                &lt;? if exists(&quot;averagePrice&quot;) ?>\n                  SUM(plannedRevenue(plancode_id, warehous_id, 'A', calitem_id,\n                    &lt;? value(&quot;startEvalDate&quot;) ?>, &lt;? value(&quot;endEvalDate&quot;) ?>))\n                &lt;? else ?>\n                  SUM(plannedRevenue(plancode_id, warehous_id, 'L', calitem_id))\n                &lt;? endif ?>\n                AS revenue\n           FROM plancode, whsinfo,\n                ( SELECT rcalitem_id AS calitem_id,\n                         findPeriodStart(rcalitem_id) AS calitem_startdate,\n                         findPeriodEnd(rcalitem_id) AS calitem_enddate\n                    FROM rcalitem\n                   WHERE (rcalitem_id in (\n&lt;? foreach(&quot;period_id_list&quot;) ?>\n  &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value(&quot;period_id_list&quot;) ?>\n&lt;? endforeach ?>\n                                         ))\n                   UNION\n                  SELECT acalitem_id AS calitem_id,\n                         findPeriodStart(acalitem_id) AS calitem_startdate,\n                         findPeriodEnd(acalitem_id) AS calitem_enddate\n                    FROM acalitem\n                   WHERE (acalitem_id in (\n&lt;? foreach(&quot;period_id_list&quot;) ?>\n  &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value(&quot;period_id_list&quot;) ?>\n&lt;? endforeach ?>\n                                         ))\n                 ) AS calitem\n          WHERE ((TRUE)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n            AND  (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;plancode_id&quot;) ?>\n            AND  (plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)\n&lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n            AND  (plancode_code ~ &lt;? value(&quot;plancode_pattern&quot;) ?>)\n&lt;? endif ?>\n                )\n       GROUP BY calitem_startdate, calitem_enddate\n       ) AS data\nORDER BY calitem_startdate</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>105</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Planner Code:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>10</y>\n    <width>740</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time Phased Planned Revenue/Expenses By Planner Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>105</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Revenue</string>\n  </label>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Gross Profit</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>80</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>plncode</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Gross Profit</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Cost</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Revenue</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_cost</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>period</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_profit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>535</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_revenue</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>690</x>\n    <y>0</y>\n    <width>51</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102632
 
201     TimePhasedProductionByItem      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Phased Production By Item</title>\n <name>TimePhasedProductionByItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists(&quot;plancode_id&quot;) ?>\n         ( SELECT (plancode_code||'-'||plancode_name)\n             FROM plancode\n            WHERE plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)\n       &lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n         text(&lt;? value(&quot;plancode_pattern&quot;) ?>)\n       &lt;? else ?>\n         text('All Planner Codes')\n       &lt;? endif ?>\n       AS plancode ;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT findPeriodStart(calitem_id) AS pstart,\n       findPeriodEnd(calitem_id) AS pend,\n       (formatDate(findPeriodStart(calitem_id)) || '-' || formatDate(findPeriodEnd(calitem_id))) AS period,\n       item_number,\n       uom_name,\n       warehous_code,\n       formatQty(SUM(summProd(itemsite_id, calitem_id))) AS f_unit\n  FROM itemsite, item, uom, whsinfo,\n       (SELECT rcalitem_id AS calitem_id\n          FROM rcalitem\n         WHERE (rcalitem_id in (\n&lt;? foreach(&quot;period_id_list&quot;) ?>\n  &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value(&quot;period_id_list&quot;) ?>\n&lt;? endforeach ?>\n                               ))\n         UNION\n        SELECT acalitem_id as calitem_id\n          FROM acalitem\n         WHERE (acalitem_id in (\n&lt;? foreach(&quot;period_id_list&quot;) ?>\n  &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value(&quot;period_id_list&quot;) ?>\n&lt;? endforeach ?>\n                               ))\n        ) AS calitem\n WHERE ((itemsite_warehous_id=warehous_id)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;plancode_id&quot;) ?>\n   AND (itemsite_plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)\n&lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n   AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ &lt;? value(&quot;plancode_pattern&quot;) ?>)))\n&lt;? endif ?>\n  )\nGROUP BY pstart, pend, period, item_number, warehous_code, uom_name\nORDER BY pstart, item_number, warehous_code;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>plancode</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>145</x>\n    <y>10</y>\n    <width>580</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time Phased Production By Item</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>200</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Planner Code:</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>105</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>105</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>0</y>\n    <width>114</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty.</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>pstart</column>\n   <head>\n    <height>6</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>5</y>\n      <width>250</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>period</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_unit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>690</x>\n    <y>0</y>\n    <width>51</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n            0       2014-10-06 19:47:03.678943
102633
 
200     TimePhasedProductionByPlannerCode       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Phased Production By Planner Code</title>\n <name>TimePhasedProductionByPlannerCode</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;warehous_id&quot;) ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists(&quot;plancode_id&quot;) ?>\n         ( SELECT (plancode_code||'-'||plancode_name)\n             FROM plancode\n            WHERE plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)\n       &lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n         text(&lt;? value(&quot;plancode_pattern&quot;) ?>)\n       &lt;? else ?>\n         text('All Planner Codes')\n       &lt;? endif ?>\n       AS plancode,\n       &lt;? if exists(&quot;inventoryUnits&quot;) ?>\n         text('Qty.')\n       &lt;? elseif exists(&quot;capacityUnits&quot;) ?>\n         text('Capacity')\n       &lt;? elseif exists(&quot;altCapacityUnits&quot;) ?>\n         text('Alt. Capacity')\n       &lt;? else ?>\n         text('ERROR')\n       &lt;? endif ?>\n       AS lbl_unittype,\n       &lt;? if exists(&quot;showInactive&quot;) ?>\n         text('Showing Active and Inactive Item Sites')\n       &lt;? else ?>\n         text('Showing Active Item Sites Only')\n       &lt;? endif ?>\n       AS lbl_showing ;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT findPeriodStart(calitem_id) AS pstart,\n       findPeriodEnd(calitem_id) AS pend,\n       (formatDate(findPeriodStart(calitem_id)) || '-' || formatDate(findPeriodEnd(calitem_id))) AS period,\n       plancode_code,\n       &lt;? if exists(&quot;inventoryUnits&quot;) ?>\n         uom_name\n       &lt;? elseif exists(&quot;capacityUnits&quot;) ?>\n         itemcapuom(item_id)\n       &lt;? elseif exists(&quot;altCapacityUnits&quot;) ?>\n         itemaltcapuom(item_id)\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_uom,\n       warehous_code,\n       &lt;? if exists(&quot;inventoryUnits&quot;) ?>\n         formatQty(SUM(summProd(itemsite_id, calitem_id)))\n       &lt;? elseif exists(&quot;capacityUnits&quot;) ?>\n         formatQty(SUM(summProd(itemsite_id, calitem_id) * itemcapinvrat(item_id)))\n       &lt;? elseif exists(&quot;altCapacityUnits&quot;) ?>\n         formatQty(SUM(summProd(itemsite_id, calitem_id) * itemaltcapinvrat(item_id)))\n       &lt;? else ?>\n         formatQty(SUM(summProd(itemsite_id, calitem_id)))\n       &lt;? endif ?>\n       AS f_unit\n  FROM itemsite, item, uom, whsinfo, plancode,\n       (SELECT rcalitem_id AS calitem_id\n          FROM rcalitem\n         WHERE (rcalitem_id in (\n&lt;? foreach(&quot;period_id_list&quot;) ?>\n  &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value(&quot;period_id_list&quot;) ?>\n&lt;? endforeach ?>\n                               ))\n         UNION\n        SELECT acalitem_id as calitem_id\n          FROM acalitem\n         WHERE (acalitem_id in (\n&lt;? foreach(&quot;period_id_list&quot;) ?>\n  &lt;? if not isfirst(&quot;period_id_list&quot;) ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value(&quot;period_id_list&quot;) ?>\n&lt;? endforeach ?>\n                               ))\n        ) AS calitem\n WHERE ((itemsite_warehous_id=warehous_id)\n&lt;? if not exists(&quot;showInactive&quot;) ?>\n   AND (itemsite_active)\n&lt;? endif ?>\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (itemsite_plancode_id=plancode_id)\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n&lt;? if exists(&quot;plancode_id&quot;) ?>\n   AND (plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)\n&lt;? elseif exists(&quot;plancode_pattern&quot;) ?>\n   AND (plancode_code ~ &lt;? value(&quot;plancode_pattern&quot;) ?>)\n&lt;? endif ?>\n  )\nGROUP BY pstart, pend, period, plancode_code, warehous_code, f_uom\nORDER BY pstart, plancode_code, warehous_code, f_uom;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>105</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>plancode</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Planner Code:</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unittype</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>200</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Planner Code</string>\n  </label>\n  <field>\n   <rect>\n    <x>360</x>\n    <y>80</y>\n    <width>380</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_showing</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>105</y>\n    <width>105</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <label>\n   <rect>\n    <x>145</x>\n    <y>10</y>\n    <width>580</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time Phased Production By Planner Code</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unittype</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>250</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>0</y>\n    <width>114</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Planner Code</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>pstart</column>\n   <head>\n    <height>6</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>5</y>\n      <width>250</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>period</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_uom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_unit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>plancode_code</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>690</x>\n    <y>0</y>\n    <width>51</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102634
 
451     TimePhasedSalesHistory  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Phased Sales History</title>\n <name>TimePhasedSalesHistory</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("byCust") ?>\n         text('Customer')\n       &lt;? elseif exists("byProdcat") ?>\n         text('Product Category')\n       &lt;? else ?>\n         text('Item')\n       &lt;? endif ?>\n          AS groupby,\n      &lt;? if exists("byCust") ?>\n         text('Name')\n       &lt;? else ?>\n         text('Description')\n       &lt;? endif ?>\n          AS groupbyDescrip,\n       &lt;? if exists("salesDollars") ?>\n         text('')\n       &lt;? else ?>\n         text('UOM')\n       &lt;? endif ?>\n       AS lbl_uom,\n       &lt;? if exists("inventoryUnits") ?>\n         text('Qty.')\n       &lt;? elseif exists("capacityUnits") ?>\n         text('Capacity')\n       &lt;? elseif exists("altCapacityUnits") ?>\n         text('Alt. Capacity')\n       &lt;? elseif exists("salesDollars") ?>\n         text('Sales')\n       &lt;? else ?>\n         text('ERROR')\n       &lt;? endif ?>\n       AS lbl_unittype;     </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT *, \n  coalesce(unit,0) AS unit, \n&lt;? if exists("salesDollars") ?>\n  formatExtPrice(coalesce(unit,0)) AS f_unit\n&lt;? else ?>\n  formatQty(coalesce(unit,0)) AS f_unit\n&lt;? endif ?>\nFROM\n-- Outer Table Query\n(SELECT DISTINCT\n       calitem_id,\n       findPeriodStart(calitem_id) AS pstart,\n       findPeriodEnd(calitem_id) AS pend,\n       (formatDate(findPeriodStart(calitem_id)) || '-' || formatDate(findPeriodEnd(calitem_id))) AS period,\n&lt;? if exists("byCust") ?>\n         cust_id, cust_number AS f_number, cust_name AS f_description\n&lt;? elseif exists("byProdcat") ?>\n         prodcat_id, prodcat_code AS f_number, prodcat_descrip AS f_description\n&lt;? elseif exists("byItem") ?>\n         item_id, item_number AS f_number, item_descrip1 AS f_description\n&lt;? endif ?>\n       , warehous_id, warehous_code\n&lt;? if exists("salesDollars") ?>\n       , &lt;? value("baseCurrAbbr") ?>::text AS f_uom\n&lt;? else ?>\n  &lt;? if exists("inventoryUnits") ?>\n       , uom_name AS f_uom\n  &lt;? elseif exists("capacityUnits") ?>\n       , itemcapuom(item_id) AS f_uom\n  &lt;? elseif exists("altCapacityUnits") ?>\n       , itemaltcapuom(item_id) AS f_uom\n  &lt;? endif ?>\n&lt;? endif ?>\nFROM cohist JOIN itemsite ON (itemsite_id=cohist_itemsite_id)\n            JOIN item ON (item_id=itemsite_item_id)\n&lt;? if exists("inventoryUnits") ?>\n JOIN uom ON (item_inv_uom_id=uom_id)\n&lt;? endif ?>\n JOIN site() ON (itemsite_warehous_id=warehous_id)\n&lt;? if reExists("[cC]ust") ?>\n JOIN custinfo ON (cohist_cust_id=cust_id)\n&lt;? endif ?> \n&lt;? if reExists("[pP]rodcat") ?>\n JOIN prodcat ON (item_prodcat_id=prodcat_id)\n&lt;? endif ?>\n&lt;? if reExists("custgrp") ?>\n JOIN custgrpitem ON (custgrpitem_cust_id=cohist_cust_id)\n JOIN custgrp ON (custgrpitem_custgrp_id=custgrp_id)\n&lt;? endif ?>\n    ,   ( SELECT rcalitem_id AS calitem_id,\n                findPeriodStart(rcalitem_id) AS calitem_start,\n                findPeriodEnd(rcalitem_id) AS calitem_end\n           FROM rcalitem\n          WHERE (rcalitem_id IN (\n&lt;? foreach("period_id_list") ?>\n  &lt;? if not isfirst("period_id_list") ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value("period_id_list") ?>\n&lt;? endforeach ?>\n                                )\n                )\n          UNION\n         SELECT acalitem_id AS calitem_id,\n                findPeriodStart(acalitem_id) AS calitem_start,\n                findPeriodEnd(acalitem_id) AS calitem_end\n           FROM acalitem\n          WHERE (acalitem_id IN (\n&lt;? foreach("period_id_list") ?>\n  &lt;? if not isfirst("period_id_list") ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value("period_id_list") ?>\n&lt;? endforeach ?>\n                                )\n                )\n       ) AS calitem\nWHERE ((cohist_invcdate BETWEEN\n&lt;? foreach("period_id_list") ?>\n  &lt;? if isfirst("period_id_list") ?>\n    findPeriodStart(&lt;? value("period_id_list") ?>)\n  &lt;? endif ?>\n  &lt;? if isLast("period_id_list") ?>\n    AND findPeriodEnd(&lt;? value("period_id_list") ?>)\n  &lt;? endif ?>\n&lt;? endforeach ?>\n)\n&lt;? if exists("item_id") ?> \n    AND (item_id=&lt;? value("item_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("cust_id") ?> \n    AND (cust_id=&lt;? value("cust_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("custtype_id") ?> \n    AND (cust_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("custtype_pattern") ?>\n    AND (cust_custtype_id IN (SELECT custtype_id \n                              FROM custtype \n                              WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("custgrp_id") ?> \n    AND (custgrpitem_custgrp_id=&lt;? value("custgrp_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("custgrp_pattern") ?>\n    AND (cust_custgrp_name ~ &lt;? value("custgrp_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("prodcat_id") ?> \n    AND (item_prodcat_id=&lt;? value("prodcat_id") ?>) \n&lt;? endif ?>\n&lt;? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT prodcat_id  \n                             FROM prodcat \n                             WHERE (prodcat_code ~ &lt;? value("prodcat_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?> \n    AND(itemsite_warehous_id=&lt;? value("warehous_id") ?>) \n&lt;? endif ?>\n      )\nORDER BY pstart, f_number, f_description, f_uom, warehous_code) list\nLEFT OUTER JOIN\n-- Sales calcuations\n-- Loop through each period bucket to find bookings for period\n(&lt;? foreach("period_id_list") ?>\n  SELECT \n       &lt;? value("period_id_list") ?> AS calitem_id,\n       warehous_id,\n&lt;? if exists("byCust") ?>\n         cust_id\n&lt;? elseif exists("byProdcat") ?>\n         prodcat_id \n&lt;? elseif exists("byItem") ?>\n         item_id\n&lt;? endif ?>\n&lt;? if exists("salesDollars") ?>\n       , sum(round(cohist_qtyshipped * currtobase(cohist_curr_id, cohist_unitprice, cohist_invcdate), 2)) AS unit\n       , &lt;? value("baseCurrAbbr") ?>::text AS f_uom\n&lt;? else ?>\n       , sum(cohist_qtyshipped)\n  &lt;? if exists("capacityUnits") ?>\n       * itemcapinvrat(item_id)\n  &lt;? elseif exists("altCapacityUnits") ?>\n       * itemaltcapinvrat(item_id)\n  &lt;? endif ?>\n       AS unit\n  &lt;? if exists("inventoryUnits") ?>\n       , uom_name AS f_uom\n  &lt;? elseif exists("capacityUnits") ?>\n       , itemcapuom(item_id) AS f_uom\n  &lt;? elseif exists("altCapacityUnits") ?>\n       , itemaltcapuom(item_id) AS f_uom\n  &lt;? endif ?>\n&lt;? endif ?>\nFROM cohist JOIN itemsite ON (itemsite_id=cohist_itemsite_id)\n            JOIN item ON (item_id=itemsite_item_id)\n&lt;? if exists("inventoryUnits") ?>\n   JOIN uom ON (item_inv_uom_id=uom_id)\n&lt;? endif ?>\n   JOIN site() ON (itemsite_warehous_id=warehous_id)\n&lt;? if reExists("[cC]ust") ?>\n   JOIN custinfo ON (cohist_cust_id=cust_id)\n&lt;? endif ?> \n&lt;? if reExists("[pP]rodcat") ?>\n   JOIN prodcat ON (item_prodcat_id=prodcat_id)\n&lt;? endif ?>\n&lt;? if reExists("custgrp") ?>\n JOIN custgrpitem ON (custgrpitem_cust_id=cohist_cust_id)\n JOIN custgrp ON (custgrpitem_custgrp_id=custgrp_id)\n&lt;? endif ?>\n  WHERE ((cohist_invcdate BETWEEN findPeriodStart(&lt;? value("period_id_list") ?>) AND findPeriodEnd(&lt;? value("period_id_list") ?>))\n&lt;? if exists("item_id") ?> \n    AND (item_id=&lt;? value("item_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("cust_id") ?> \n    AND (cust_id=&lt;? value("cust_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("custtype_id") ?> \n    AND (cust_custtype_id=&lt;? value("custtype_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("custtype_pattern") ?>\n    AND (cust_custtype_id IN (SELECT custtype_id \n                              FROM custtype \n                              WHERE (custtype_code ~ &lt;? value("custtype_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("custgrp_id") ?> \n    AND (custgrpitem_custgrp_id=&lt;? value("custgrp_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("custgrp_pattern") ?>\n    AND (cust_custgrp_name ~ &lt;? value("custgrp_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("prodcat_id") ?> \n    AND (item_prodcat_id=&lt;? value("prodcat_id") ?>) \n&lt;? endif ?>\n&lt;? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT prodcat_id  \n                             FROM prodcat \n                             WHERE (prodcat_code ~ &lt;? value("prodcat_pattern") ?>)))\n&lt;? endif ?>\n&lt;? if exists("warehous_id") ?> \n    AND(itemsite_warehous_id=&lt;? value("warehous_id") ?>) \n&lt;? endif ?>\n      )\nGROUP BY\n&lt;? if exists("byCust") ?>\n  cust_id, \n  &lt;? if exists("capacityUnits") ?>\n    item_id,\n  &lt;? elseif exists("altCapacityUnits") ?>\n    item_id,\n  &lt;? endif ?>\n&lt;? elseif exists("byProdcat") ?>\n  prodcat_id,\n  &lt;? if exists("capacityUnits") ?>\n    item_id,\n  &lt;? elseif exists("altCapacityUnits") ?>\n    item_id,\n  &lt;? endif ?>\n&lt;? elseif exists("byItem") ?>\n  item_id,\n&lt;? endif ?>\n  f_uom, warehous_id\n  &lt;? if isLast("period_id_list") ?>\n  &lt;? else ?>\nUNION\n  &lt;? endif ?>\n&lt;? endforeach ?> \n) sales ON\n&lt;? if exists("byCust") ?>\n   (list.cust_id=sales.cust_id)\n&lt;? elseif exists("byProdcat") ?>\n    (list.prodcat_id=sales.prodcat_id)\n&lt;? elseif exists("byItem") ?>\n    (list.item_id=sales.item_id)\n&lt;? endif ?>\n   AND (list.calitem_id=sales.calitem_id)\n   AND (list.warehous_id=sales.warehous_id)\n   AND (list.f_uom=sales.f_uom)</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>340</x>\n    <y>3</y>\n    <width>385</width>\n    <height>33</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time Phased Sales History</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unittype</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>530</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_uom</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>200</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>220</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>groupby</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>330</x>\n    <y>200</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>groupbyDescrip</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>33</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>-1</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>-1</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <field>\n   <rect>\n    <x>530</x>\n    <y>-1</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_uom</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>-1</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_unittype</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>215</x>\n    <y>-1</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>groupby</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>330</x>\n    <y>-1</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>groupbyDescrip</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>pstart</column>\n   <head>\n    <height>6</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>5</y>\n      <width>150</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>period</column>\n     </data>\n    </field>\n   </head>\n   <foot>\n    <height>31</height>\n    <field>\n     <rect>\n      <x>660</x>\n      <y>5</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>unit</column>\n     </data>\n     <format builtin="true">extprice</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <line>\n     <xstart>640</xstart>\n     <ystart>0</ystart>\n     <xend>745</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n    <label>\n     <rect>\n      <x>530</x>\n      <y>5</y>\n      <width>110</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total:</string>\n    </label>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_unit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_uom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>220</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>330</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_description</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>-1</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>-1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>690</x>\n    <y>-1</y>\n    <width>51</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>-1</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102635
 
221     TimePhasedStatisticsByItem      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Phased Usage Statistics By Item</title>\n <name>TimePhasedStatisticsByItem</name>\n <description>Shows graph</description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Warehouses')\n       &lt;? endif ?>\n       AS warehouse\n  FROM item\n WHERE (item_id=&lt;? value("item_id") ?>);</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT calitem_pstart AS pstart,\n       calitem_pend AS pend,\n       (formatDate(calitem_pstart) || '-' || formatDate(calitem_pend)) AS period,\n       warehous_code,\n       formatQty(summTransR(itemsite_id, calitem_id)) AS received,\n       formatQty(summTransI(itemsite_id, calitem_id)) AS issued,\n       formatQty(summTransS(itemsite_id, calitem_id)) AS sold,\n       formatQty(summTransC(itemsite_id, calitem_id)) AS scrap,\n       formatQty(summTransA(itemsite_id, calitem_id)) AS adjustments,\n--\n       summTransR(itemsite_id, calitem_id) AS a_received,\n       summTransI(itemsite_id, calitem_id) AS a_issued,\n       summTransS(itemsite_id, calitem_id) AS a_sold,\n       summTransC(itemsite_id, calitem_id) AS a_scrap,\n       summTransA(itemsite_id, calitem_id) AS a_adjustments\n\n  FROM itemsite, whsinfo,\n\n       ( SELECT rcalitem_id as calitem_id,\n                findPeriodStart(rcalitem_id) as calitem_pstart,\n                findPeriodEnd(rcalitem_id) as calitem_pend\n           FROM rcalitem\n          WHERE (rcalitem_id in (\n&lt;? foreach("period_id_list") ?>\n  &lt;? if not isfirst("period_id_list") ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value("period_id_list") ?>\n&lt;? endforeach ?>\n                 ))\n          UNION\n         SELECT acalitem_id as calitem_id,\n                findPeriodStart(acalitem_id) as calitem_pstart,\n                findPeriodEnd(acalitem_id) as calitem_pend\n           FROM acalitem\n          WHERE (acalitem_id in (\n&lt;? foreach("period_id_list") ?>\n  &lt;? if not isfirst("period_id_list") ?>\n    ,\n  &lt;? endif ?>\n  &lt;? value("period_id_list") ?>\n&lt;? endforeach ?>\n                 ))\n       ORDER BY calitem_pstart, calitem_pend\n       ) as calitem\n\n WHERE ((itemsite_warehous_id=warehous_id)\n   AND (itemsite_item_id=&lt;? value("item_id") ?>)\n&lt;? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n)\nORDER BY calitem_pstart, warehous_code;</sql>\n </querysource>\n <colordef>\n  <name>Blue</name>\n  <red>0</red>\n  <green>0</green>\n  <blue>255</blue>\n </colordef>\n <colordef>\n  <name>BlueGreen</name>\n  <red>0</red>\n  <green>255</green>\n  <blue>255</blue>\n </colordef>\n <colordef>\n  <name>Green</name>\n  <red>0</red>\n  <green>255</green>\n  <blue>0</blue>\n </colordef>\n <colordef>\n  <name>Red</name>\n  <red>255</red>\n  <green>0</green>\n  <blue>0</blue>\n </colordef>\n <colordef>\n  <name>RedBlue</name>\n  <red>255</red>\n  <green>0</green>\n  <blue>255</blue>\n </colordef>\n <colordef>\n  <name>RedGreen</name>\n  <red>255</red>\n  <green>255</green>\n  <blue>0</blue>\n </colordef>\n <rpthead>\n  <height>683</height>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>63</y>\n    <width>385</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>613</y>\n    <width>300</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Scrapped (RedGreen/Line) Adjusted (RedBlue/Points&amp;Line)</string>\n  </label>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>43</y>\n    <width>104</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Warehouse:</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>655</y>\n    <width>80</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>50</y>\n    <width>200</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <line>\n   <xstart>0</xstart>\n   <ystart>675</ystart>\n   <xend>735</xend>\n   <yend>675</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>655</y>\n    <width>80</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issued</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>655</y>\n    <width>80</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Adjusted</string>\n  </label>\n  <label>\n   <rect>\n    <x>18</x>\n    <y>605</y>\n    <width>360</width>\n    <height>12</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Legend: Issued (Green/Bar) Received: (BlueGreen/Line) Sold: (Blue/Bar)</string>\n  </label>\n  <label>\n   <rect>\n    <x>268</x>\n    <y>655</y>\n    <width>35</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Whs.</string>\n  </label>\n  <label>\n   <rect>\n    <x>488</x>\n    <y>655</y>\n    <width>80</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <graph>\n   <rect>\n    <x>35</x>\n    <y>116</y>\n    <width>712</width>\n    <height>467</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <data>\n    <query>detail</query>\n    <column/>\n   </data>\n   <title>\n    <string>Time Phased Activity Graph</string>\n   </title>\n   <dataaxis>\n    <title>\n     <string>Date Range</string>\n    </title>\n    <column>period</column>\n   </dataaxis>\n   <valueaxis>\n    <title>\n     <string>Quantity</string>\n    </title>\n    <min>0</min>\n    <max>0</max>\n    <autominmax>true</autominmax>\n   </valueaxis>\n   <series>\n    <name>IssuedQuanity</name>\n    <column>a_issued</column>\n    <color>Green</color>\n    <style>\n     <bar/>\n    </style>\n   </series>\n   <series>\n    <name>Received</name>\n    <column>a_received</column>\n    <color>BlueGreen</color>\n    <style>\n     <line/>\n    </style>\n   </series>\n   <series>\n    <name>Sold</name>\n    <column>a_sold</column>\n    <color>Blue</color>\n    <style>\n     <bar/>\n    </style>\n   </series>\n   <series>\n    <name>Scrapped</name>\n    <column>a_scrap</column>\n    <color>RedGreen</color>\n    <style>\n     <line/>\n    </style>\n   </series>\n   <series>\n    <name>Adjusted</name>\n    <column>a_adjustments</column>\n    <color>RedBlue</color>\n    <style>\n     <line/>\n     <point/>\n    </style>\n   </series>\n  </graph>\n  <label>\n   <rect>\n    <x>318</x>\n    <y>655</y>\n    <width>80</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <field>\n   <rect>\n    <x>543</x>\n    <y>43</y>\n    <width>200</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>78</x>\n    <y>10</y>\n    <width>644</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time Phased Usage Statistics By Item with Graph</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>50</y>\n    <width>104</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Number:</string>\n  </label>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>80</y>\n    <width>385</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>18</x>\n    <y>655</y>\n    <width>250</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>9</height>\n </pghead>\n <pghead>\n  <height>23</height>\n  <label>\n   <rect>\n    <x>488</x>\n    <y>0</y>\n    <width>80</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>0</y>\n    <width>80</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>318</x>\n    <y>0</y>\n    <width>80</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>268</x>\n    <y>0</y>\n    <width>35</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Whs.</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>13</ystart>\n   <xend>738</xend>\n   <yend>13</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>0</y>\n    <width>80</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Adjusted</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>250</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>0</y>\n    <width>80</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issued</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>pstart</column>\n   <head>\n    <height>15</height>\n    <field>\n     <rect>\n      <x>10</x>\n      <y>5</y>\n      <width>250</width>\n      <height>13</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>period</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>405</x>\n     <y>0</y>\n     <width>80</width>\n     <height>13</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>issued</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>0</y>\n     <width>80</width>\n     <height>13</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>318</x>\n     <y>0</y>\n     <width>80</width>\n     <height>13</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>received</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>268</x>\n     <y>0</y>\n     <width>35</width>\n     <height>13</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>488</x>\n     <y>0</y>\n     <width>80</width>\n     <height>13</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sold</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>80</width>\n     <height>13</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>adjustments</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>688</x>\n    <y>0</y>\n    <width>51</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>85</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>93</x>\n    <y>0</y>\n    <width>100</width>\n    <height>13</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n       Shows graph     0       2014-10-06 19:47:03.678943
102636
 
320     TitleList       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Titles</title>\n <name>TitleList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT hnfc_code\n  FROM hnfc\nORDER BY hnfc_code;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Titles</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Title</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Title</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>hnfc_code</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102637
 
411     TodoItem        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>To-Do Item</title>\n <name>TodoItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT todoitem_id AS id,\n       'T' AS type, todoitem_seq AS seq, \n       todoitem_name AS name, \n       firstLine(todoitem_description) AS descrip, \n       todoitem_status AS status, todoitem_due_date AS due, \n       todoitem_username AS usr, incdt_number AS incdt \nFROM todoitem LEFT OUTER JOIN incdt ON (incdt_id=todoitem_incdt_id) \nWHERE (todoitem_id=&lt;? value("todoitem_id") ?>)\nORDER BY seq, usr;</sql>\n </querysource>\n <rpthead>\n  <height>141</height>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>20</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>User:</string>\n  </label>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>30</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>status</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>110</x>\n    <y>35</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>type</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>60</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Incident:</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>35</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Type:</string>\n  </label>\n  <label>\n   <rect>\n    <x>40</x>\n    <y>65</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>45</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>due</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>385</x>\n    <y>60</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>incdt</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>30</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Status:</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>45</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Due Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>110</x>\n    <y>20</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>usr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>110</x>\n    <y>65</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>name</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>110</x>\n    <y>80</y>\n    <width>600</width>\n    <height>15</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>descrip</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>50</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sequence:</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>To-Do Item</string>\n  </label>\n  <line>\n   <xstart>10</xstart>\n   <ystart>135</ystart>\n   <xend>750</xend>\n   <yend>135</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>110</x>\n    <y>50</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>seq</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102638
 
324     TodoList        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>To-Do List</title>\n <name>TodoList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>todolist</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <querysource>\n  <name>queryParams</name>\n  <sql>SELECT\n  &lt;? if exists("completed") ?> 'Yes' &lt;? else ?> 'No' &lt;? endif ?> AS showClosed,\n  &lt;? if exists("projects") ?>    'Yes' &lt;? else ?> 'No' &lt;? endif ?> AS showTasks,\n  &lt;? if exists("incidents") ?> 'Yes' &lt;? else ?> 'No' &lt;? endif ?> AS showIncdts;</sql>\n </querysource>\n <rpthead>\n  <height>141</height>\n  <field>\n   <rect>\n    <x>325</x>\n    <y>43</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>queryParams</query>\n    <column>showClosed</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>120</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>120</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Assigned To</string>\n  </label>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>43</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show Incidents:</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>120</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Priority</string>\n  </label>\n  <field>\n   <rect>\n    <x>110</x>\n    <y>43</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>queryParams</query>\n    <column>showIncdts</column>\n   </data>\n  </field>\n  <line>\n   <xstart>10</xstart>\n   <ystart>135</ystart>\n   <xend>750</xend>\n   <yend>135</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>120</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>235</x>\n    <y>43</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Completed:</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>To-Do List</string>\n  </label>\n  <label>\n   <rect>\n    <x>435</x>\n    <y>120</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>230</x>\n    <y>120</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>120</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent#</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>43</y>\n    <width>100.893</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Show Project Tasks:</string>\n  </label>\n  <field>\n   <rect>\n    <x>555</x>\n    <y>43</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>queryParams</query>\n    <column>showTasks</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>63</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>435</x>\n    <y>-1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>-1</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>165</x>\n    <y>-1</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Priority</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>-1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>230</x>\n    <y>-1</y>\n    <width>200</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>-1</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Assigned To</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>-1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent#</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>ByUser</name>\n   <column>assigned</column>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>31</height>\n   <field>\n    <rect>\n     <x>630</x>\n     <y>0</y>\n     <width>115</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_parent</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>assigned</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>230</x>\n     <y>15</y>\n     <width>520</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>notes</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>435</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>stage</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>type</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>165</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>priority</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>due</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>230</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>name</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>1</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>1</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102639
 
253     TrialBalances   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Trial Balances</title>\n <name>TrialBalances</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("accnt_id") ?>\n         ( SELECT (accnt_number || '-' || accnt_descrip)\n             FROM accnt\n            WHERE (accnt_id=&lt;? value("accnt_id") ?>) )\n       &lt;? else ?>\n         text('All Accounts')\n       &lt;? endif ?>\n       AS accnt,\n       &lt;? if exists("period_id") ?>\n         ( SELECT (formatDate(period_start) || '-' || formatDate(period_end))\n             FROM period\n            WHERE (period_id=&lt;? value("period_id") ?>) )\n       &lt;? else ?>\n         text('All Periods')\n       &lt;? endif ?>\n       AS period;\n       </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT accnt_id,\n       period_id,\n       formatDate(period_start) AS f_start,\n       formatDate(period_end) AS f_end,\n       formatGLAccount(accnt_id) AS f_account,\n       accnt_descrip,\n       formatMoney(abs(trialbal_beginning)) AS f_beginning,\n       CASE WHEN(trialbal_beginning>0) THEN text('CR')\n            ELSE text('')\n       END AS f_beginningcr,\n       formatMoney(trialbal_debits) AS f_debits,\n       formatMoney(trialbal_credits) AS f_credits,\n       formatMoney(abs(trialbal_debits - trialbal_credits)) AS f_diff,\n       CASE WHEN((trialbal_debits - trialbal_credits) &lt; 0) THEN text('CR')\n            ELSE text('')\n       END AS f_diffcr,\n       formatMoney(abs(trialbal_ending)) AS f_ending,\n       CASE WHEN(trialbal_ending>0) THEN text('CR')\n            ELSE text('')\n       END AS f_endingcr\n  FROM trialbal, accnt, period\n WHERE ((trialbal_accnt_id=accnt_id)\n   AND (trialbal_period_id=period_id)\n&lt;? if exists("accnt_id") ?>\n   AND (trialbal_accnt_id=&lt;? value("accnt_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("period_id") ?>\n   AND (period_id=&lt;? value("period_id") ?>)\n&lt;? endif ?>\n&lt;? if not exists("showZero") ?>\n   AND (abs(trialbal_beginning)+abs(trialbal_ending)+abs(trialbal_debits)+abs(trialbal_credits) > 0) \n&lt;? endif ?>\n       )\nORDER BY period_start, formatGLAccount(accnt_id);</sql>\n </querysource>\n <querysource>\n  <name>total</name>\n  <sql>SELECT formatMoney(abs(beginning)) AS f_beginning,\n       CASE WHEN(beginning&lt;0) THEN text('CR')\n            ELSE text('')\n       END AS f_beginningcr,\n       formatMoney(debits) AS f_debits,\n       formatMoney(credits) AS f_credits,\n       formatMoney(abs(debits - credits)) AS f_diff,\n       CASE WHEN((debits - credits) &lt; 0) THEN text('CR')\n            ELSE text('')\n       END AS f_diffcr,\n       formatMoney(abs(ending)) AS f_ending,\n       CASE WHEN(ending&lt;0) THEN text('CR')\n            ELSE text('')\n       END AS f_endingcr\n  FROM ( SELECT SUM(trialbal_beginning*-1) AS beginning,\n                SUM(trialbal_debits) AS debits,\n                SUM(trialbal_credits) AS credits,\n                SUM(trialbal_ending*-1) AS ending\n           FROM trialbal, accnt, period\n          WHERE ((trialbal_accnt_id=accnt_id)\n            AND  (trialbal_period_id=period_id)\n&lt;? if exists("accnt_id") ?>\n            AND  (trialbal_accnt_id=&lt;? value("accnt_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("period_id") ?>\n            AND  (period_id=&lt;? value("period_id") ?>)\n&lt;? endif ?>\n                )\n       ) AS data;</sql>\n </querysource>\n <rpthead>\n  <height>191</height>\n  <label>\n   <rect>\n    <x>860</x>\n    <y>155</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ending Bal.</string>\n  </label>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>155</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Beg. Bal.</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>155</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credits</string>\n  </label>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>155</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period End</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>170</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>155</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debits</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>155</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account #</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>155</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period Start</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>185</ystart>\n   <xend>990</xend>\n   <yend>185</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>720</x>\n    <y>155</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Difference</string>\n  </label>\n  <label>\n   <rect>\n    <x>635</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Trial Balances</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>38</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>720</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Difference</string>\n  </label>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Beg. Bal.</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>15</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period Start</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>990</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account #</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credits</string>\n  </label>\n  <label>\n   <rect>\n    <x>860</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ending Bal.</string>\n  </label>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Period End</string>\n  </label>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debits</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>31</height>\n   <field>\n    <rect>\n     <x>475</x>\n     <y>0</y>\n     <width>30</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_beginningcr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>105</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_end</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>965</x>\n     <y>0</y>\n     <width>30</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_endingcr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>510</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_debits</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>370</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_beginning</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_credits</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>15</y>\n     <width>140</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>accnt_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_start</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>860</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_ending</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>720</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_diff</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>825</x>\n     <y>0</y>\n     <width>30</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_diffcr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_account</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>21</height>\n  <field>\n   <rect>\n    <x>370</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>total</query>\n    <column>f_beginning</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>720</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>total</query>\n    <column>f_diff</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>510</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>total</query>\n    <column>f_debits</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>total</query>\n    <column>f_credits</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>860</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>total</query>\n    <column>f_ending</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>255</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Total:</string>\n  </label>\n  <field>\n   <rect>\n    <x>965</x>\n    <y>0</y>\n    <width>30</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>total</query>\n    <column>f_endingcr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>0</y>\n    <width>30</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>total</query>\n    <column>f_beginningcr</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>825</x>\n    <y>0</y>\n    <width>30</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>total</query>\n    <column>f_diffcr</column>\n   </data>\n  </field>\n </rptfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102640
 
223     UOMs    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Units of Measure</title>\n <name>UOMs</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT uom_name,\n       uom_descrip\n  FROM uom\nORDER BY uom_name;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Units of Measure</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_descrip</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102641
 
268     UnappliedAPCreditMemos  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Unapplied A/P Credit Memos</title>\n <name>UnappliedAPCreditMemos</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT apopen_id, apopen_docnumber,\n       (vend_number || '-' || vend_name) AS vendor,\n       formatMoney(apopen_amount) AS f_amount,\n       formatMoney(apopen_paid) AS f_paid,\n       formatMoney(apopen_amount - apopen_paid) AS f_balance\nFROM apopen, vendinfo\nWHERE ( (apopen_doctype='C')\n AND (apopen_open)\n AND (apopen_vend_id=vend_id)\n&lt;? if exists(&quot;vend_id&quot;) ?>\n   AND (vend_id=&lt;? value(&quot;vend_id&quot;) ?>)\n&lt;? elseif exists(&quot;vendtype_id&quot;) ?>\n   AND (vend_vendtype_id=&lt;? value(&quot;vendtype_id&quot;) ?>)\n&lt;? elseif exists(&quot;vendtype_pattern&quot;) ?>\n   AND (vend_vendtype_id IN (SELECT vendtype_id\n                               FROM vendtype\n                              WHERE (vendtype_code ~ &lt;? value(&quot;vendtype_pattern&quot;) ?>)))\n&lt;? endif ?>\n)\nORDER BY apopen_docnumber;</sql>\n </querysource>\n <rpthead>\n  <height>77</height>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Applied</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Unapplied A/P Credit Memos</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Applied</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>apopen_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_paid</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>434</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vendor</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102642
 
269     UnappliedARCreditMemos  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Unapplied A/R Credit Memos</title>\n <name>UnappliedARCreditMemos</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT aropen_id, aropen_docnumber,\n       (cust_number || '-' || cust_name) AS cust,\n       formatMoney(aropen_amount) AS f_amount,\n       formatMoney(aropen_paid) AS f_paid,\n       formatMoney(aropen_amount - aropen_paid) AS f_balance\nFROM aropen, custinfo\nWHERE ( (aropen_doctype IN ('C', 'R'))\n AND (aropen_open)\n AND (aropen_cust_id=cust_id) )\nORDER BY aropen_docnumber;</sql>\n </querysource>\n <rpthead>\n  <height>77</height>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Applied</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Unapplied A/R Credit Memos</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>55</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>26</height>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Applied</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer</string>\n  </label>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>aropen_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_paid</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>434</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>0</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102643
 
232     UniformBOL      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Uniform Bill of Lading</title>\n <name>UniformBOL</name>\n <description></description>\n <parameter default="324" active="true" listtype="static" type="string" name="shiphead_id">\n  <description></description>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>25</rightmargin>\n <leftmargin>25</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT shiphead_shipvia, formatDate(shiphead_shipdate) AS shipdate,\n                cust_name, cust_number, cohead_number, cohead_fob, cohead_custponumber,\n                warehous_descrip, addr_line1 AS warehous_addr1, addr_line2 AS warehous_addr2, addr_line3 AS warehous_addr3, addr_city AS warehous_addr4, warehous_fob,\n                cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3,\n                (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n                cohead_shiptophone\n         FROM shiphead JOIN cohead ON (cohead_id=shiphead_order_id)\n                       LEFT OUTER JOIN whsinfo ON (warehous_id=cohead_warehous_id)\n                       JOIN custinfo ON (cust_id=cohead_cust_id)\n                       LEFT OUTER JOIN addr ON (warehous_addr_id=addr_id)\n         WHERE (shiphead_id=&lt;? value("shiphead_id") ?>);</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT 1 as one,\n       coitem_linenumber,\n       formatQty(SUM(shipitem_qty)) AS invqty,\n       uom_name,\n       itemsellinguom(item_id) AS shipuom,\n       roundUp(SUM(shipitem_qty) / iteminvpricerat(item_id))::integer AS shipqty,\n       item_number, item_descrip1, item_descrip2,\n       formatQty(SUM(shipitem_qty) * item_prodweight) AS netweight,\n       formatQty(SUM(shipitem_qty) * (item_prodweight + item_packweight)) AS grossweight\n  FROM shipitem, coitem, itemsite, item, uom\n WHERE ((shipitem_orderitem_id=coitem_id)\n   AND (coitem_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (shipitem_shiphead_id=&lt;? value("shiphead_id") ?>))\nGROUP BY coitem_linenumber, item_number, item_id,\n         uom_name, shipuom,\n         item_descrip1,\n         item_descrip2, item_prodweight,\n         item_packweight\nORDER BY coitem_linenumber;\n    </sql>\n </querysource>\n <querysource>\n  <name>foot</name>\n  <sql>SELECT formatQty(SUM(shipitem_qty * item_prodweight)) AS netweight,\n       formatQty(SUM(shipitem_qty * (item_prodweight + item_packweight))) AS grossweight             \n  FROM shipitem, coitem, itemsite, item\n WHERE ((shipitem_orderitem_id=coitem_id)\n   AND (coitem_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (shipitem_shiphead_id=&lt;? value("shiphead_id") ?>));</sql>\n </querysource>\n <querysource>\n  <name>notes</name>\n  <sql>SELECT shiphead_notes\n  FROM shiphead\n WHERE (shiphead_id=&lt;? value("shiphead_id") ?>);</sql>\n </querysource>\n <querysource>\n  <name>legal1</name>\n  <sql>SELECT \n       text('*If the shipment moves between two ports by carrier by water, the law requires that the Bill Of Lading shall state whether it is ''carrier''s or shipper''s weight''.\\n\\nNOTE: Where the rate is dependent on value, shippers are required to state specifically in writing the agreed or declared value of the property. The agreed or declared value of the property is hereby specifically stated by the shipper to be not exceeding:\\n\\n_________________________\\n\\nper ______________________') AS legal3</sql>\n </querysource>\n <rpthead>\n  <height>42</height>\n  <label>\n   <rect>\n    <x>540</x>\n    <y>15</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>*Weight (Sub. to Corr.)</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>795</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>730</x>\n    <y>15</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>7</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ck. Column</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>15</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>No. Packages</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>15</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>7</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>CL or Rate</string>\n  </label>\n  <label>\n   <rect>\n    <x>145</x>\n    <y>15</y>\n    <width>380</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Kind of package, description of articles, special marks and exceptions</string>\n  </label>\n  <label>\n   <rect>\n    <x>100</x>\n    <y>15</y>\n    <width>40</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>HM?</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>332</height>\n  <field>\n   <rect>\n    <x>145</x>\n    <y>5</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cust_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>250</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Street</string>\n  </label>\n  <line>\n   <xstart>405</xstart>\n   <ystart>85</ystart>\n   <xend>405</xend>\n   <yend>185</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>419</x>\n    <y>160</y>\n    <width>370</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shiphead_shipvia</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>25</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Order #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>305</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_addr4</column>\n   </data>\n  </field>\n  <line>\n   <xstart>795</xstart>\n   <ystart>85</ystart>\n   <xend>795</xend>\n   <yend>185</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>405</xstart>\n   <ystart>185</ystart>\n   <xend>795</xend>\n   <yend>185</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>145</x>\n    <y>45</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_fob</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>5</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <line>\n   <xstart>405</xstart>\n   <ystart>150</ystart>\n   <xend>795</xend>\n   <yend>150</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>600</xstart>\n   <ystart>112</ystart>\n   <xend>600</xend>\n   <yend>150</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>285</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_addr3</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>190</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptophone</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>185</y>\n    <width>110</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Notes/Special Instructions</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>130</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoaddress2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>310</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>City, State, Zip</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>225</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_descrip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>605</x>\n    <y>112</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P.O. No.</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>53</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>To:</string>\n  </label>\n  <field>\n   <rect>\n    <x>145</x>\n    <y>25</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>170</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shiptocitystatezip</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>215</y>\n    <width>53</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>From:</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>50</y>\n    <width>50</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>112</y>\n    <width>65</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Street</string>\n  </label>\n  <field>\n   <rect>\n    <x>615</x>\n    <y>125</y>\n    <width>175</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_custponumber</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>150</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoaddress3</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>175</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>City, State, Zip</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>265</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_addr2</column>\n   </data>\n  </field>\n  <text>\n   <rect>\n    <x>415</x>\n    <y>200</y>\n    <width>380</width>\n    <height>15</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>notes</query>\n    <column>shiphead_notes</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>85</y>\n    <width>380</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>NOTE: Liability Limitation for loss or damage on this shipment</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>90</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoname</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>112</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipper's No.</string>\n  </label>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>100</y>\n    <width>380</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>may be applicable. See 49 U.S.C.  14706 (c)(1)(A) and (B).</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>228</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipper</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>245</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehous_addr1</column>\n   </data>\n  </field>\n  <line>\n   <xstart>405</xstart>\n   <ystart>85</ystart>\n   <xend>795</xend>\n   <yend>85</yend>\n   <weight>0</weight>\n  </line>\n  <field>\n   <rect>\n    <x>635</x>\n    <y>50</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>shipdate</column>\n   </data>\n  </field>\n  <line>\n   <xstart>405</xstart>\n   <ystart>112</ystart>\n   <xend>795</xend>\n   <yend>112</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>150</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Route</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>45</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Shipped From:</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>10</y>\n    <width>325</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Uniform Bill of Lading</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>110</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>cohead_shiptoaddress1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>95</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Consignee</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>52</height>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>35</y>\n     <width>380</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>540</x>\n     <y>0</y>\n     <width>120</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>grossweight</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>80</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipqty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>20</y>\n     <width>380</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>145</x>\n     <y>0</y>\n     <width>390</width>\n     <height>20</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <lastpage/>\n  <height>466</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>90</y>\n    <width>185</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>The fiber boxes used for this shipment conform</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>30</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Freight charges are PREPAID</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>90</ystart>\n   <xend>795</xend>\n   <yend>90</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>605</x>\n    <y>110</y>\n    <width>20</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>$</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>305</y>\n    <width>780</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>and carrier makes no guarantees concerning the delivery dates or times (Subject to terms and conditions of any applicable Gold Medal Service agreement).</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>110</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Bill Of Lading shall state whether it is</string>\n  </label>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>320</y>\n    <width>375</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>CARRIER CERTIFICATION</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>160</y>\n    <width>185</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>additional care or attention in handling or</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>170</y>\n    <width>185</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>stowing must be marked and packaged as to</string>\n  </label>\n  <label>\n   <rect>\n    <x>605</x>\n    <y>65</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>CHECK BOX IF COLLECT</string>\n  </label>\n  <line>\n   <xstart>220</xstart>\n   <ystart>80</ystart>\n   <xend>228</xend>\n   <yend>80</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>350</y>\n    <width>385</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>certifies that the above named materials are properly classified, described, packaged, marked and labeled,</string>\n  </label>\n  <line>\n   <xstart>560</xstart>\n   <ystart>75</ystart>\n   <xend>570</xend>\n   <yend>75</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>400</xstart>\n   <ystart>90</ystart>\n   <xend>400</xend>\n   <yend>245</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>315</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Hazardous Materials Emergency Response Phone Number:</string>\n  </label>\n  <label>\n   <rect>\n    <x>480</x>\n    <y>45</y>\n    <width>15</width>\n    <height>35</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>{</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>5</ystart>\n   <xend>5</xend>\n   <yend>445</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>210</xstart>\n   <ystart>220</ystart>\n   <xend>385</xend>\n   <yend>220</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>444</y>\n    <width>775</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>? Mark with "X" if appropriate to designate Hazardous Materials or Hazardous Substances as defined in the Department of Transportation Regulations governing the transportation of hazardous materials.</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>190</y>\n    <width>185</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>See Sec. 2(e) or NMFC item 360.</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>295</y>\n    <width>780</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>National Motor Freight Classification 100-X and successive issues. Note: It is also agreed that the carrier will not be liable for any consequential damages arising from the delay of delivery</string>\n  </label>\n  <label>\n   <rect>\n    <x>203</x>\n    <y>160</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>all other lawful charges.</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>340</y>\n    <width>385</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipper certifies by its signature, its agreement to all of the foregoing terms and conditions, and further</string>\n  </label>\n  <line>\n   <xstart>220</xstart>\n   <ystart>70</ystart>\n   <xend>228</xend>\n   <yend>70</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>220</xstart>\n   <ystart>55</ystart>\n   <xend>220</xend>\n   <yend>65</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>600</xstart>\n   <ystart>90</ystart>\n   <xend>600</xend>\n   <yend>245</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>120</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>'carrier's or shipper's weight'.</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>45</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>C.O.D. fee</string>\n  </label>\n  <label>\n   <rect>\n    <x>220</x>\n    <y>30</y>\n    <width>160</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>C.O.D. Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>30</y>\n    <width>185</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Collect On Delivery</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>100</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>carrier by water, the law requires that the</string>\n  </label>\n  <line>\n   <xstart>560</xstart>\n   <ystart>65</ystart>\n   <xend>560</xend>\n   <yend>75</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>203</x>\n    <y>220</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>(Signature of consigner)</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>60</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>to be paid by</string>\n  </label>\n  <line>\n   <xstart>560</xstart>\n   <ystart>60</ystart>\n   <xend>570</xend>\n   <yend>60</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>600</xstart>\n   <ystart>135</ystart>\n   <xend>795</xend>\n   <yend>135</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>560</xstart>\n   <ystart>50</ystart>\n   <xend>570</xend>\n   <yend>50</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>170</y>\n    <width>175</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>to apply in the prepayment of</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>170</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>property. The agreed or declared value of the</string>\n  </label>\n  <label>\n   <rect>\n    <x>203</x>\n    <y>110</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>without recourse on the consignor, the</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>375</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipper</string>\n  </label>\n  <field>\n   <rect>\n    <x>540</x>\n    <y>5</y>\n    <width>120</width>\n    <height>25</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>foot</query>\n    <column>grossweight</column>\n   </data>\n  </field>\n  <line>\n   <xstart>795</xstart>\n   <ystart>5</ystart>\n   <xend>795</xend>\n   <yend>445</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>190</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>shipper to be not exceeding:</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>60</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Consignee</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>20</width>\n    <height>30</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>$</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>228</y>\n    <width>30</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>per</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>350</y>\n    <width>385</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>information was made available and/or carrier has the DOT emergency response guidebook or equivelent</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>45</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>unless marked collect.</string>\n  </label>\n  <line>\n   <xstart>560</xstart>\n   <ystart>50</ystart>\n   <xend>560</xend>\n   <yend>60</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>765</xstart>\n   <ystart>70</ystart>\n   <xend>765</xend>\n   <yend>80</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>180</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>property is hereby specifically stated by the</string>\n  </label>\n  <line>\n   <xstart>570</xstart>\n   <ystart>75</ystart>\n   <xend>570</xend>\n   <yend>65</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>5</xstart>\n   <ystart>320</ystart>\n   <xend>795</xend>\n   <yend>320</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>228</xstart>\n   <ystart>65</ystart>\n   <xend>228</xend>\n   <yend>55</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>200</xstart>\n   <ystart>90</ystart>\n   <xend>200</xend>\n   <yend>245</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>265</y>\n    <width>780</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>except as noted (contents and condition of contents of packages unknown) marked, consigned, and destined as shown above, which said carrier agrees to carry to destination, if on its route,</string>\n  </label>\n  <label>\n   <rect>\n    <x>234</x>\n    <y>50</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Cash or Certified Check</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>408</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Authorized Signature</string>\n  </label>\n  <line>\n   <xstart>665</xstart>\n   <ystart>5</ystart>\n   <xend>665</xend>\n   <yend>30</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>360</y>\n    <width>385</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>document in the vehicle.</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>90</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>*If the shipment moves between two ports by</string>\n  </label>\n  <line>\n   <xstart>220</xstart>\n   <ystart>70</ystart>\n   <xend>220</xend>\n   <yend>80</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>100</y>\n    <width>185</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>to the specifications set forth in the box maker's</string>\n  </label>\n  <line>\n   <xstart>580</xstart>\n   <ystart>30</ystart>\n   <xend>580</xend>\n   <yend>90</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>5</xstart>\n   <ystart>340</ystart>\n   <xend>795</xend>\n   <yend>340</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>245</y>\n    <width>780</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>RECEIVED, subject to individually determined rates or contracts that have been agreed upon in writing between the carrier and shipper, if applicable, otherwise the rates, classifications and</string>\n  </label>\n  <line>\n   <xstart>210</xstart>\n   <ystart>30</ystart>\n   <xend>210</xend>\n   <yend>90</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>390</xstart>\n   <ystart>30</ystart>\n   <xend>390</xend>\n   <yend>90</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>220</xstart>\n   <ystart>65</ystart>\n   <xend>228</xend>\n   <yend>65</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>5</xstart>\n   <ystart>408</ystart>\n   <xend>795</xend>\n   <yend>408</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>433</xstart>\n   <ystart>240</ystart>\n   <xend>586</xend>\n   <yend>240</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>765</xstart>\n   <ystart>80</ystart>\n   <xend>775</xend>\n   <yend>80</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>253</y>\n    <width>780</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>rules (Estes Express Lines 105 series) that have been established by the carrier and are available to the shipper, on request. The property described above, in apparent good order,</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>375</ystart>\n   <xend>795</xend>\n   <yend>375</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>285</y>\n    <width>780</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>party at any time interested in all or any of said property, that every service to be performed thereunder shall be subject to all the terms and conditions of the Uniform Bill of Lading set forth in the</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>50</ystart>\n   <xend>210</xend>\n   <yend>50</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>120</y>\n    <width>185</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>of Consolidated Uniform or National Motor</string>\n  </label>\n  <line>\n   <xstart>408</xstart>\n   <ystart>220</ystart>\n   <xend>586</xend>\n   <yend>220</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>560</xstart>\n   <ystart>65</ystart>\n   <xend>570</xend>\n   <yend>65</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>670</xstart>\n   <ystart>170</ystart>\n   <xend>762</xend>\n   <yend>170</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>795</xend>\n   <yend>30</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>5</xstart>\n   <ystart>445</ystart>\n   <xend>795</xend>\n   <yend>445</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>203</x>\n    <y>120</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>consignor shall sign the following statement:</string>\n  </label>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>200</y>\n    <width>175</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>described hereof.</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>375</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Authorized Signature</string>\n  </label>\n  <label>\n   <rect>\n    <x>203</x>\n    <y>140</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>The carrier shall not make delivery of the</string>\n  </label>\n  <label>\n   <rect>\n    <x>203</x>\n    <y>90</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Subject to Section 7 of Conditions, if this</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>130</y>\n    <width>185</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Freight Classification.</string>\n  </label>\n  <line>\n   <xstart>775</xstart>\n   <ystart>80</ystart>\n   <xend>775</xend>\n   <yend>70</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>340</y>\n    <width>385</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Carrier acknowledges receipt of packages and required placards. Carrier certifies emergency response</string>\n  </label>\n  <label>\n   <rect>\n    <x>690</x>\n    <y>408</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <line>\n   <xstart>765</xstart>\n   <ystart>70</ystart>\n   <xend>775</xend>\n   <yend>70</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>5</xstart>\n   <ystart>245</ystart>\n   <xend>795</xend>\n   <yend>245</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>320</y>\n    <width>375</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>SHIPPER CERTIFICATION</string>\n  </label>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>155</y>\n    <width>75</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Received $</string>\n  </label>\n  <line>\n   <xstart>685</xstart>\n   <ystart>408</ystart>\n   <xend>685</xend>\n   <yend>445</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>605</x>\n    <y>90</y>\n    <width>185</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>9</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Charges Advanced</string>\n  </label>\n  <line>\n   <xstart>400</xstart>\n   <ystart>320</ystart>\n   <xend>400</xend>\n   <yend>445</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>408</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Carrier</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>45</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Shipper</string>\n  </label>\n  <line>\n   <xstart>228</xstart>\n   <ystart>80</ystart>\n   <xend>228</xend>\n   <yend>70</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>160</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>writing the agreed or declared value of the</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>275</y>\n    <width>780</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>otherwise to deliver to another carrier on the route to destination. It is mutually agreed, as to each carrier of all or any of said property over all or any portion of said route to destination and as to each</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>5</ystart>\n   <xend>795</xend>\n   <yend>5</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>150</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>shippers are required to state specifically in</string>\n  </label>\n  <line>\n   <xstart>535</xstart>\n   <ystart>5</ystart>\n   <xend>535</xend>\n   <yend>30</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>150</y>\n    <width>185</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>NOTE: Commodities requiring special or</string>\n  </label>\n  <label>\n   <rect>\n    <x>203</x>\n    <y>100</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>shipment is to be delivered to the consignee</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>110</y>\n    <width>185</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>certificate thereon, and all other requirements</string>\n  </label>\n  <label>\n   <rect>\n    <x>234</x>\n    <y>65</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Consignee Check Accepted</string>\n  </label>\n  <label>\n   <rect>\n    <x>203</x>\n    <y>150</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>shipment without payment of freight and</string>\n  </label>\n  <line>\n   <xstart>600</xstart>\n   <ystart>110</ystart>\n   <xend>795</xend>\n   <yend>110</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>220</xstart>\n   <ystart>55</ystart>\n   <xend>228</xend>\n   <yend>55</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>360</y>\n    <width>385</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>and are in proper condition for transportation according to the applicable regulations of the DOT.</string>\n  </label>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>185</y>\n    <width>175</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>the charges on the property</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>140</y>\n    <width>190</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>NOTE: Where the rate is dependent on value,</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>180</y>\n    <width>185</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>6</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>ensure safe transportation with ordinary care.</string>\n  </label>\n  <line>\n   <xstart>570</xstart>\n   <ystart>60</ystart>\n   <xend>570</xend>\n   <yend>50</yend>\n   <weight>0</weight>\n  </line>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102644
 
77      UninvoicedShipments     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Uninvoiced Shipments</title>\n <name>UninvoicedShipments</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse;\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT cohead_id, shipitem_id, cohead_number, coitem_linenumber,\n       item_number, item_descrip1, item_descrip2,\n       uom_name,\n       shipped, formatQty(shipped) AS f_shipped,\n       selected, formatQty(selected) AS f_selected\nFROM (\nSELECT cohead_id, shipitem_id, cohead_number, coitem_linenumber,\n       item_number, item_descrip1, item_descrip2,\n       uom_name,\n       COALESCE(SUM(shipitem_qty), 0) AS shipped,\n       COALESCE(SUM(cobill_qty), 0) AS selected\nFROM cohead, itemsite, item, uom,\n     whsinfo, shipitem, shiphead,\n     coitem LEFT OUTER JOIN\n      ( cobill JOIN cobmisc\n        ON ( (cobill_cobmisc_id=cobmisc_id) AND (NOT cobmisc_posted) ) )\n     ON (cobill_coitem_id=coitem_id)\nWHERE ( (shipitem_orderitem_id=coitem_id)\n AND (shipitem_shiphead_id=shiphead_id)\n AND (coitem_cohead_id=cohead_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (coitem_qty_uom_id=uom_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (shiphead_shipped)\n AND (NOT shipitem_invoiced)\n&lt;? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n )\nGROUP BY cohead_number, coitem_id, coitem_linenumber, item_number,\n         item_descrip1, item_descrip2, cohead_id, shipitem_id, uom_name\n) AS data\n&lt;? if exists("showUnselected") ?>\n WHERE (selected = 0)\n&lt;? endif ?>\n;</sql>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>104</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>200</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order #</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Selected</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Uninvoiced Shipments</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>104</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>215</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipped</string>\n  </label>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>0</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>#</string>\n  </label>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>15</y>\n    <width>300</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Order #</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Selected</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>57</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cohead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>494</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_selected</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>95</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>coitem_linenumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>580</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_shipped</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>0</y>\n     <width>229</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>50</ystart>\n    <xend>745</xend>\n    <yend>50</yend>\n    <weight>0</weight>\n   </line>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102645
 
356     UnpostedGLTransactions  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Unposted G/L Transactions</title>\n <name>UnpostedGLTransactions</name>\n <description></description>\n <size>Letter</size>\n <landscape/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>&lt;? if exists("period_id") ?>\nSELECT formatDate(period_start, 'Earliest') AS startdate,\n       formatDate(period_end, 'Latest') AS enddate,\n       period_name\nFROM period\nWHERE (period_id=&lt;? value("period_id") ?>);\n&lt;? else ?>\nSELECT 'Earliest' AS startdate,\n       'Latest' AS enddate,\n       'All Periods' AS period_name;\n&lt;? endif ?></sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT gltrans_id,\n       formatDate(gltrans_date) AS transdate,\n       gltrans_source,\n       gltrans_doctype,\n       gltrans_docnumber,\n       invhist_docnumber,\n       firstLine(gltrans_notes) AS transnotes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n-- Debits:\n       CASE WHEN (gltrans_amount &lt; 0) THEN formatMoney(ABS(gltrans_amount))\n            ELSE ''\n       END AS f_debit,       \n       CASE WHEN (gltrans_amount &lt; 0) THEN ABS(gltrans_amount)\n            ELSE 0\n       END AS debit_amt, \n--Credits:\n       CASE WHEN (gltrans_amount > 0) THEN formatMoney(gltrans_amount)\n            ELSE ''\n       END AS f_credit,\n       CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n            ELSE 0\n       END AS credit_amt,\n--Balance:\n       gltrans_amount * -1 as balance_amt\n--\n  FROM period, gltrans JOIN accnt ON (gltrans_accnt_id=accnt_id)\n       LEFT OUTER JOIN invhist ON (gltrans_misc_id=invhist_id AND gltrans_docnumber='Misc.')\nWHERE (NOT gltrans_posted\n  AND (NOT gltrans_deleted)\n  AND  (gltrans_date BETWEEN period_start AND period_end)\n&lt;? if exists("period_id") ?>\n  AND  (period_id=&lt;? value("period_id") ?>)\n&lt;? endif ?>\n)\nORDER BY gltrans_created, gltrans_sequence, gltrans_amount;</sql>\n </querysource>\n <rpthead>\n  <height>205</height>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>185</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>185</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>310</x>\n    <y>185</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n  <field>\n   <rect>\n    <x>545</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>70</y>\n    <width>290</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>period_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>204</x>\n    <y>185</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>125</x>\n    <y>185</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>605</x>\n    <y>185</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>408</x>\n    <y>90</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Period:</string>\n  </label>\n  <label>\n   <rect>\n    <x>720</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <field>\n   <rect>\n    <x>545</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <line>\n   <xstart>0</xstart>\n   <ystart>200</ystart>\n   <xend>1000</xend>\n   <yend>200</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>310</x>\n    <y>170</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>535</x>\n    <y>5</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Unposted G/L Transactions</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>5</height>\n </pghead>\n <pghead>\n  <height>45</height>\n  <label>\n   <rect>\n    <x>720</x>\n    <y>25</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>310</x>\n    <y>25</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n  <line>\n   <xstart>0</xstart>\n   <ystart>40</ystart>\n   <xend>1000</xend>\n   <yend>40</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>25</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>25</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>204</x>\n    <y>25</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>310</x>\n    <y>10</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>125</x>\n    <y>25</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>605</x>\n    <y>25</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>31</height>\n   <field>\n    <rect>\n     <x>310</x>\n     <y>0</y>\n     <width>270</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>account</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>12500</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>208</x>\n     <y>15</y>\n     <width>95</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invhist_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>125</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>204</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>310</x>\n     <y>15</y>\n     <width>265</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transnotes</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>720</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_credit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_source</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>605</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_debit</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <lastpage/>\n  <height>75</height>\n  <field>\n   <rect>\n    <x>835</x>\n    <y>25</y>\n    <width>105</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>balance_amt</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n  <label>\n   <rect>\n    <x>835</x>\n    <y>10</y>\n    <width>55</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <string>Balance:</string>\n  </label>\n  <label>\n   <rect>\n    <x>580</x>\n    <y>10</y>\n    <width>55</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <string>Total:</string>\n  </label>\n  <line>\n   <xstart>605</xstart>\n   <ystart>5</ystart>\n   <xend>1015</xend>\n   <yend>5</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>60</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>960</x>\n    <y>60</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>60</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>720</x>\n    <y>25</y>\n    <width>105</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>credit_amt</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n  <label>\n   <rect>\n    <x>868</x>\n    <y>60</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>605</x>\n    <y>25</y>\n    <width>105</width>\n    <height>14</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <top/>\n   <data>\n    <query>detail</query>\n    <column>debit_amt</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal/>\n  </field>\n </pgfoot>\n <pgfoot>\n  <height>15</height>\n  <label>\n   <rect>\n    <x>868</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>960</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102646
 
355     UnpostedGlSeries        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Unposted G/L Series Transactions</title>\n <name>UnpostedGlSeries</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT *, glseries_sequence,\n       (formatGLAccount(glseries_accnt_id) || ' - ' ||\n                        accnt_descrip) AS account,\n       CASE WHEN (glseries_amount &lt; 0) THEN\n           formatMoney(glseries_amount * -1)\n       ELSE '' END AS debit,\n       CASE WHEN (glseries_amount >= 0) THEN\n           formatMoney(glseries_amount)\n       ELSE '' END AS credit\nFROM glseries, accnt\nWHERE (glseries_accnt_id=accnt_id)\nORDER BY glseries_distdate, glseries_sequence, glseries_amount;</sql>\n </querysource>\n <rpthead>\n  <height>75</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>50</y>\n    <width>90</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Distribution Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>50</y>\n    <width>70</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>50</y>\n    <width>150</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>50</y>\n    <width>70</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Unposted G/L Series Transactions</string>\n  </label>\n  <label>\n   <rect>\n    <x>145</x>\n    <y>50</y>\n    <width>45</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>50</y>\n    <width>100</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>310</x>\n    <y>50</y>\n    <width>130</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>50</y>\n    <width>45</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>11</height>\n </pghead>\n <pghead>\n  <height>51</height>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>20</y>\n    <width>70</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>20</y>\n    <width>90</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Distribution Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>20</y>\n    <width>100</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>310</x>\n    <y>20</y>\n    <width>130</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>530</x>\n    <y>20</y>\n    <width>70</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>40</ystart>\n   <xend>740</xend>\n   <yend>40</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>20</y>\n    <width>45</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Source</string>\n  </label>\n  <label>\n   <rect>\n    <x>145</x>\n    <y>20</y>\n    <width>45</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>610</x>\n    <y>20</y>\n    <width>150</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>glseries_sequence</name>\n   <column>glseries_sequence</column>\n   <foot>\n    <height>11</height>\n    <line>\n     <xstart>10</xstart>\n     <ystart>0</ystart>\n     <xend>40</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>21</height>\n   <text>\n    <rect>\n     <x>610</x>\n     <y>0</y>\n     <width>150</width>\n     <height>11</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>glseries_notes</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>95</x>\n     <y>0</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>glseries_source</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>310</x>\n     <y>0</y>\n     <width>130</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>account</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>glseries_distdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>530</x>\n     <y>0</y>\n     <width>70</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>credit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>450</x>\n     <y>0</y>\n     <width>70</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>debit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>glseries_docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>145</x>\n     <y>0</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>glseries_doctype</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>15</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102647
 
357     UnpostedPoReceipts      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Unposted Purchase Order Receipts</title>\n <name>UnpostedPoReceipts</name>\n <description></description>\n <parameter default="" active="true" listtype="static" type="bool" name="MultiWhs" >\n  <description></description>\n </parameter>\n <parameter default="" active="true" listtype="static" type="string" name="na" >\n  <description></description>\n </parameter>\n <parameter default="" active="true" listtype="static" type="string" name="nonInventory" >\n  <description></description>\n </parameter>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT recv_id, recv_orderitem_id, recv_order_number, recv_order_type,\n       orderhead_from,\n       orderitem_linenumber,\n       formatDate(recv_duedate) AS recv_duedate,\n       warehous_code,\n       COALESCE(item_number, &lt;? value("nonInventory") ?>) AS item_number,\n       COALESCE(uom_name, &lt;? value("na") ?>) AS uom_name,\n       recv_vend_item_number,\n       recv_vend_uom,\n       formatQty(orderitem_qty_ordered)  AS qty_ordered,\n       formatQty(orderitem_qty_received) AS qty_received,\n       formatQty(recv_qty)     AS recv_qty,\n       formatDate(recv_date)   AS recv_date,\n       formatDate(COALESCE(recv_gldistdate, recv_date)) AS recv_gldistdate\nFROM orderhead JOIN\n     orderitem ON ((orderitem_orderhead_id=orderhead_id)\n\t       AND (orderitem_orderhead_type=orderhead_type)) JOIN \n     recv  ON ((recv_orderitem_id=orderitem_id)\n\t   AND (recv_order_type=orderitem_orderhead_type)) LEFT OUTER JOIN\n     (itemsite JOIN item ON (itemsite_item_id=item_id)\n\t       JOIN uom ON (item_inv_uom_id=uom_id)\n               JOIN site() ON (itemsite_warehous_id=warehous_id)\n       )\n      ON (recv_itemsite_id=itemsite_id) LEFT OUTER JOIN\n     vendinfo ON (orderhead_type='PO' AND orderhead_from_id=vend_id)\nWHERE (NOT recv_posted)\nORDER BY orderhead_from, recv_order_number, orderitem_linenumber;\n</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Unposted Purchase Order Receipts</string>\n  </label>\n </rpthead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>ponumber</name>\n   <column>recv_order_number</column>\n   <head>\n    <height>51</height>\n    <label>\n     <rect>\n      <x>130</x>\n      <y>31</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Item Number</string>\n    </label>\n    <label>\n     <rect>\n      <x>600</x>\n      <y>31</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Qty To Receive</string>\n    </label>\n    <label>\n     <rect>\n      <x>285</x>\n      <y>31</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Vendor Item Number</string>\n    </label>\n    <field>\n     <rect>\n      <x>100</x>\n      <y>0</y>\n      <width>27</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>recv_order_type</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>240</x>\n      <y>31</y>\n      <width>40</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>UOM</string>\n    </label>\n    <field>\n     <rect>\n      <x>100</x>\n      <y>15</y>\n      <width>200</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>orderhead_from</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>440</x>\n      <y>31</y>\n      <width>70</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Qty Ordered</string>\n    </label>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>0</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Order #:</string>\n    </label>\n    <label>\n     <rect>\n      <x>40</x>\n      <y>31</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Due Date</string>\n    </label>\n    <field>\n     <rect>\n      <x>135</x>\n      <y>0</y>\n      <width>100</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>recv_order_number</column>\n     </data>\n    </field>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>15</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Vendor:</string>\n    </label>\n    <label>\n     <rect>\n      <x>520</x>\n      <y>31</y>\n      <width>70</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Qty Received</string>\n    </label>\n    <label>\n     <rect>\n      <x>0</x>\n      <y>31</y>\n      <width>35</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Line #</string>\n    </label>\n    <label>\n     <rect>\n      <x>685</x>\n      <y>31</y>\n      <width>80</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Receipt Date</string>\n    </label>\n    <label>\n     <rect>\n      <x>395</x>\n      <y>31</y>\n      <width>40</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>UOM</string>\n    </label>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>21</height>\n   <field>\n    <rect>\n     <x>685</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>recv_date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>395</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>recv_vend_uom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>orderitem_linenumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>285</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>recv_vend_item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>520</x>\n     <y>0</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qty_received</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>40</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>recv_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>240</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>600</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>recv_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>440</x>\n     <y>0</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>qty_ordered</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102648
 
358     UnpostedReturnsForPO    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Unposted Returns For Purchase Order</title>\n <name>UnpostedReturnsForPO</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>100</topmargin>\n <bottommargin>100</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>address</name>\n  <sql>select formatAddr(&lt;? value("addr_id") ?>) AS f_addr;</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT poitem_linenumber,\n       COALESCE(item_number, 'Non-Inventory') AS item_number,\n       COALESCE(uom_name, 'N/A') AS uom_name,\n       poitem_vend_item_number, poitem_vend_uom,\n       formatQty(poitem_qty_ordered)  AS f_poitem_qty_ordered,\n       formatQty(poitem_qty_received) AS f_poitem_qty_received,\n       formatQty(poitem_qty_returned) AS f_poitem_qty_returned,\n       formatQty(SUM(COALESCE(poreject_qty, 0))) AS f_poreject_qty,\n       rjctcode_code\nFROM poreject LEFT OUTER JOIN rjctcode ON (poreject_rjctcode_id=rjctcode_id),\n     poitem LEFT OUTER JOIN\n     ( itemsite JOIN item\n       ON (itemsite_item_id=item_id) JOIN uom ON (item_inv_uom_id=uom_id)\n     ) ON (poitem_itemsite_id=itemsite_id)\nWHERE ((poreject_poitem_id=poitem_id)\n  AND  (NOT poreject_posted)\n  AND  (poitem_pohead_id=&lt;? value("pohead_id") ?>))\nGROUP BY\n        poitem_linenumber,\n        item_number,\n        uom_name,\n        poitem_vend_item_number,\n        poitem_vend_uom,\n        poitem_qty_ordered,\n        poitem_qty_received,\n        poitem_qty_returned,\n        rjctcode_code\nORDER BY poitem_linenumber;</sql>\n </querysource>\n <querysource>\n  <name>pohead</name>\n  <sql>SELECT *\nFROM pohead, vendinfo\nWHERE ((pohead_vend_id=vend_id)\n  AND  (pohead_id=&lt;? value("pohead_id") ?>));</sql>\n </querysource>\n <querysource>\n  <name>logo</name>\n  <sql>SELECT image_data \nFROM image \nWHERE ((image_name='logo'));</sql>\n </querysource>\n <rpthead>\n  <height>127</height>\n  <label>\n   <rect>\n    <x>290</x>\n    <y>10</y>\n    <width>450</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Purchase Order Returns</string>\n  </label>\n  <image>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>155</width>\n    <height>95</height>\n   </rect>\n   <mode>stretch</mode>\n   <data>\n    <query>logo</query>\n    <column>image_data</column>\n   </data>\n  </image>\n  <line>\n   <xstart>0</xstart>\n   <ystart>113</ystart>\n   <xend>740</xend>\n   <yend>113</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <section>\n  <name>Address</name>\n  <detail>\n   <key>\n    <query>address</query>\n   </key>\n   <height>23</height>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>To:</string>\n   </label>\n   <text>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>500</width>\n     <height>18</height>\n    </rect>\n    <bottompad>11</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>address</query>\n     <column>f_addr</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <section>\n  <name>POHead</name>\n  <detail>\n   <key>\n    <query>pohead</query>\n   </key>\n   <height>107</height>\n   <label>\n    <rect>\n     <x>1</x>\n     <y>80</y>\n     <width>35</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Line #</string>\n   </label>\n   <label>\n    <rect>\n     <x>200</x>\n     <y>80</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Vendor Item Number</string>\n   </label>\n   <label>\n    <rect>\n     <x>150</x>\n     <y>80</y>\n     <width>40</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <string>UOM</string>\n   </label>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>41</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>pohead</query>\n     <column>vend_number</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>310</x>\n     <y>80</y>\n     <width>40</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <string>UOM</string>\n   </label>\n   <label>\n    <rect>\n     <x>40</x>\n     <y>80</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Item Number</string>\n   </label>\n   <label>\n    <rect>\n     <x>340</x>\n     <y>80</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Qty Received</string>\n   </label>\n   <field>\n    <rect>\n     <x>100</x>\n     <y>30</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>pohead</query>\n     <column>pohead_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>0</xstart>\n    <ystart>95</ystart>\n    <xend>740</xend>\n    <yend>95</yend>\n    <weight>0</weight>\n   </line>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>30</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Purchase Order #:</string>\n   </label>\n   <label>\n    <rect>\n     <x>0</x>\n     <y>41</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Vendor:</string>\n   </label>\n   <label>\n    <rect>\n     <x>565</x>\n     <y>80</y>\n     <width>85</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Qty To Return</string>\n   </label>\n   <label>\n    <rect>\n     <x>450</x>\n     <y>80</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Previously Returned</string>\n   </label>\n  </detail>\n </section>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>42</height>\n   <field>\n    <rect>\n     <x>355</x>\n     <y>0</y>\n     <width>85</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_poitem_qty_received</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_vend_item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>570</x>\n     <y>0</y>\n     <width>85</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_poreject_qty</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>45</x>\n     <y>15</y>\n     <width>645</width>\n     <height>11</height>\n    </rect>\n    <bottompad>1</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>rjctcode_code</column>\n    </data>\n   </text>\n   <field>\n    <rect>\n     <x>310</x>\n     <y>0</y>\n     <width>40</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_vend_uom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>1</x>\n     <y>0</y>\n     <width>35</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>poitem_linenumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>459</x>\n     <y>0</y>\n     <width>90</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_poitem_qty_returned</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>1</x>\n     <y>15</y>\n     <width>60</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <string>Reason</string>\n   </label>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>0</y>\n     <width>40</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>40</x>\n     <y>0</y>\n     <width>100</width>\n     <height>11</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>23</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>700</x>\n    <y>0</y>\n    <width>40</width>\n    <height>11</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102649
 
464     UnpostedVouchers        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Unposted Vouchers</title>\n <name>UnpostedVouchers</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>openVouchers</mqlgroup>\n  <mqlname>populate</mqlname>\n </querysource>\n <rpthead>\n  <height>78</height>\n  <label>\n   <rect>\n    <x>150</x>\n    <y>58</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n  <label>\n   <rect>\n    <x>310</x>\n    <y>58</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vend. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>58</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Dist. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>58</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>58</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Voucher #</string>\n  </label>\n  <line>\n   <xstart>3.66667</xstart>\n   <ystart>74</ystart>\n   <xend>743.667</xend>\n   <yend>74</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>5</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Unposted Vouchers</string>\n  </label>\n  <label>\n   <rect>\n    <x>90</x>\n    <y>58</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>58</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Invc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>570</x>\n    <y>58</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>41</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>35</ystart>\n   <xend>745</xend>\n   <yend>35</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>19</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Dist. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>310</x>\n    <y>19</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vend. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>19</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>570</x>\n    <y>19</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Post Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>19</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>19</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Voucher #</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>19</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor Invc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>155</x>\n    <y>19</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Vendor</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>orderid</column>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>650</x>\n     <y>2</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>2</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vohead_invcnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>90</x>\n     <y>2</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>2</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vohead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>2</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_distdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>310</x>\n     <y>2</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vendtype_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>570</x>\n     <y>2</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_postdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>2</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vendor</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102650
 
222     UnusedPurchasedItems    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Unused Purchased Items</title>\n <name>UnusedPurchasedItems</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists(&quot;classcode_id&quot;) ?>\n         ( SELECT (classcode_code||'-'||classcode_descrip)\n             FROM classcode\n            WHERE (classcode_id=&lt;? value(&quot;classcode_id&quot;) ?>) )\n       &lt;? elseif exists(&quot;classcode_pattern&quot;) ?>\n         text(&lt;? value(&quot;classcode_pattern&quot;) ?>)\n       &lt;? else ?>\n         text('All Class Codes')\n       &lt;? endif ?>\n       AS classcode,\n       &lt;? if exists(&quot;includeUncontrolledItems&quot;) ?>\n         text('Showing Uncontrolled Items')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS lbl_showuncontrolled</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT DISTINCT item_id,\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       uom_name,\n       formatQty(SUM(itemsite_qtyonhand)) AS f_qoh,\n       formatDate(MAX(itemsite_datelastcount), 'Never') AS f_lastcntd,\n       formatDate(MAX(itemsite_datelastused), 'Never') AS f_lastused\n  FROM item, itemsite, uom\n WHERE ((itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (item_id NOT IN (SELECT DISTINCT bomitem_item_id FROM bomitem))\n   AND (NOT item_sold)\n   AND (item_type IN ('P', 'O'))\n&lt;? if exists(&quot;classcode_id&quot;) ?>\n   AND (item_classcode_id=&lt;? value(&quot;classcode_id&quot;) ?>)\n&lt;? elseif exists(&quot;classcode_pattern&quot;) ?>\n   AND (item_classcode_id IN (SELECT classcode_id\n                                FROM classcode\n                               WHERE (classcode_code ~ &lt;? value(&quot;classcode_pattern&quot;) ?>)))\n&lt;? endif ?>\n&lt;? if not exists(&quot;includeUncontrolledItems&quot;) ?>\n   AND (itemsite_controlmethod &lt;> 'N')\n&lt;? endif ?>\n)\nGROUP BY item_id, item_number, uom_name, item_descrip1, item_descrip2\nORDER BY item_number;</sql>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>classcode</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Cnt'd</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>440</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_showuncontrolled</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>10</y>\n    <width>409</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Unused Purchased Items</string>\n  </label>\n  <label>\n   <rect>\n    <x>509</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Used</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>120</y>\n    <width>110</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Class Code(s):</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>200</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>215</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>37</height>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>0</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>31</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>15</y>\n    <width>229</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>509</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Used</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Last Cnt'd</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total QOH</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>509</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_lastused</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_lastcntd</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>15</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>15</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qoh</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>225</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>15</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102651
 
459     UsageStatistics \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Item Usage Statistics</title>\n <name>UsageStatistics</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>usageStatistics</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>188</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Transfers</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>188</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>10</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Usage Statistics</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>188</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issued</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>200</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>188</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>188</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Adjustments</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>185</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>188</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>38</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>15</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>505</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>0</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>585</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Adjustments</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issued</string>\n  </label>\n  <label>\n   <rect>\n    <x>665</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Transfers</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>35</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>37</height>\n   <field>\n    <rect>\n     <x>425</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_sold</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>35</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <line>\n    <xstart>3</xstart>\n    <ystart>31</ystart>\n    <xend>743</xend>\n    <yend>31</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>665</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_transfer</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_adjust</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>345</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_issued</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>15</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemdescrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>185</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>260</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_received</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102652
 
106     UsersMasterList \N      <!DOCTYPE openRPTDef>\n<report>\n <title>User Accounts Master List</title>\n <name>UsersMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>select usr_username,\n       usr_propername,\n       usr_initials,\n       formatBoolYN(usr_active) AS f_active,\n       formatBoolYN(usr_agent) AS f_pa,\n       locale_code\n  FROM usr, locale\n WHERE ((usr_locale_id=locale_id)\n&lt;? if not exists(&quot;showInactive&quot;) ?>\n   AND (usr_active=true)\n&lt;? endif ?>\n)\nORDER BY usr_username;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>5</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>User Accounts Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>55</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Proper Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Username</string>\n  </label>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>40</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Purchasing</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>55</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Locale</string>\n  </label>\n  <label>\n   <rect>\n    <x>114</x>\n    <y>55</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>55</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Agent</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>55</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Initials</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>425</x>\n    <y>0</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Purchasing</string>\n  </label>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>15</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Initials</string>\n  </label>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>15</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Proper Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>114</x>\n    <y>15</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>434</x>\n    <y>15</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Agent</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>15</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Username</string>\n  </label>\n  <label>\n   <rect>\n    <x>500</x>\n    <y>15</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Locale</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>434</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_pa</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>114</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_active</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>375</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>usr_initials</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>170</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>usr_propername</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>usr_username</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>500</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>locale_code</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102653
 
8       ValidLocationsByItem    \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Valid Locations By Item</title>\n <name>ValidLocationsByItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n                   FROM whsinfo\n                   WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse\n  FROM item\n WHERE (item_id=&lt;? value("item_id") ?>);\n</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT warehous_code,\n       formatLocationName(location_id) AS locationname,\n       firstLine(location_descrip) as f_descrip,\n       formatBoolYN(location_restrict) AS restricted,\n       formatBoolYN(location_netable) AS netable\n  FROM itemsite, location, whsinfo\n WHERE ((validLocation(location_id, itemsite_id))\n   AND  ((itemsite_loccntrl) OR (itemsite_location_id=location_id))\n   AND  (itemsite_item_id=&lt;? value("item_id") ?>)\n   AND  (itemsite_warehous_id=warehous_id)\n&lt;? if exists("warehous_id") ?>\n   AND  (warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n)\n\nORDER BY warehous_code, locationname;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>555</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Restrict</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>145</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>200</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Location</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>145</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Netable</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>235</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Valid Locations By Item</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Netable</string>\n  </label>\n  <label>\n   <rect>\n    <x>235</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>555</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Restrict</string>\n  </label>\n  <label>\n   <rect>\n    <x>70</x>\n    <y>0</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Location</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>45</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>netable</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>555</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>restricted</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>70</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>locationname</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>235</x>\n     <y>0</y>\n     <width>310</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_descrip</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102654
 
236     VendorAPHistory \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Vendor AP History</title>\n <name>VendorAPHistory</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT vend_number,\n       vend_name,\n       formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate\n  FROM vendinfo\n WHERE (vend_id=&lt;? value("vend_id") ?>);</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT 1 AS type, apopen_id, -1 AS applyid,\n       apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n       apopen_docnumber AS docnumber,\n       formatBoolYN(apopen_open) AS f_open,\n       CASE WHEN (apopen_doctype='V') THEN text('Voucher')\n            WHEN (apopen_doctype='C') THEN text('C/M')\n            WHEN (apopen_doctype='D') THEN text('D/M')\n            ELSE text('Other')\n       END AS documenttype,\n       apopen_invcnumber AS invoicenumber,\n       apopen_ponumber AS ponumber,\n       formatDate(apopen_docdate) AS f_docdate,\n       formatDate(apopen_duedate) AS f_duedate,\n       formatMoney(apopen_amount) AS f_amount,\n       formatMoney((apopen_amount - apopen_paid)) AS f_balance\nFROM apopen\nWHERE ( (apopen_vend_id=&lt;? value("vend_id") ?>)\n AND (apopen_docdate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>) )\n\nUNION\nSELECT 2 AS type, apopen_id, apapply_source_apopen_id AS applyid,\n       apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n       apapply_source_docnumber AS docnumber,\n       '' AS f_open,\n       CASE WHEN (apapply_source_doctype='C') THEN text('C/M')\n            WHEN (apapply_source_doctype='K') THEN text('Check')\n            ELSE text('Other')\n       END AS documenttype,\n       '' AS invoicenumber,\n       '' AS ponumber,\n       formatDate(apapply_postdate) AS f_docdate,\n       '' AS f_duedate,\n       formatMoney(apapply_amount) AS f_amount,\n       '' AS f_balance\nFROM apapply, apopen\nWHERE ( (apapply_target_apopen_id=apopen_id)\n AND (apapply_vend_id=&lt;? value("vend_id") ?>)\n AND (apopen_vend_id=&lt;? value("vend_id") ?>)\n AND (apopen_docdate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>) )\n\nUNION\nSELECT 3 AS type, apopen_id, apapply_target_apopen_id AS applyid,\n       apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n       apapply_target_docnumber AS docnumber,\n       '' AS f_open,\n       CASE WHEN (apapply_target_doctype='V') THEN text('Voucher')\n            WHEN (apapply_target_doctype='D') THEN text('D/M')\n            ELSE text('Other')\n       END AS documenttype,\n       apopen_invcnumber AS invoicenumber,\n       '' AS ponumber,\n       formatDate(apapply_postdate) AS f_docdate,\n       '' AS f_duedate,\n       formatMoney(apapply_amount) AS f_amount,\n       '' AS f_balance\nFROM apapply, apopen\nWHERE ( (apapply_source_doctype IN ('C', 'K'))\n AND (apapply_source_doctype=apopen_doctype)\n AND (apapply_source_docnumber=apopen_docnumber)\n AND (apapply_vend_id=&lt;? value("vend_id") ?>)\n AND (apopen_vend_id=&lt;? value("vend_id") ?>)\n AND (apopen_docdate BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>) )\n\nORDER BY sortdate, apopen_id, type;</sql>\n </querysource>\n <rpthead>\n  <height>162</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>140</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Open</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>65</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>140</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>650</x>\n    <y>140</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>570</x>\n    <y>140</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>444</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>55</x>\n    <y>140</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>230</x>\n    <y>140</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Invoice #</string>\n  </label>\n  <label>\n   <rect>\n    <x>444</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>155</ystart>\n   <xend>745</xend>\n   <yend>155</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>5</y>\n    <width>475</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor History</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>65</y>\n    <width>60</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>85</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>145</x>\n    <y>140</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>485</x>\n    <y>140</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>140</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>P/O #</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>14</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>370</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>560</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>655</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Open</string>\n  </label>\n  <label>\n   <rect>\n    <x>465</x>\n    <y>0</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>0</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>60</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_docdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>570</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>655</x>\n     <y>0</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>315</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>ponumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>60</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>documenttype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>485</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_open</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>145</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>docnumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>230</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invoicenumber</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>104</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102655
 
300     VendorAddressList       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Vendor Address List</title>\n <name>VendorAddressList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT vend_number, vend_name\n  FROM vendinfo\n WHERE (vend_id=&lt;? value(&quot;vend_id&quot;) ?>);\n    </sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT vendaddr_code as num,\n       vendaddr_name as name,\n       addr_line1 AS address,\n       (addr_city || ', ' || addr_state || '  ' || addr_postalcode)  AS citystatezip\n  FROM vendaddrinfo\n  LEFT OUTER JOIN addr ON (vendaddr_addr_id=addr_id)\n WHERE (vendaddr_vend_id=&lt;? value(&quot;vend_id&quot;) ?>) \nORDER BY vendaddr_code;</sql>\n </querysource>\n <rpthead>\n  <height>171</height>\n  <label>\n   <rect>\n    <x>545</x>\n    <y>150</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>City, State, Zip</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Address</string>\n  </label>\n  <label>\n   <rect>\n    <x>345</x>\n    <y>5</y>\n    <width>400</width>\n    <height>40</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor Address List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>70</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>70</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>150</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Number</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>165</ystart>\n   <xend>745</xend>\n   <yend>165</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>90</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_name</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>545</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>City, State, Zip</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Address</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>17</height>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>num</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>545</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>citystatezip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>address</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>600</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>105</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102656
 
413     VendorInformation       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Vendor Information</title>\n <name>VendorInformation</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT vend_name,      vend_vendtype_id, vend_terms_id,\n       vend_shipvia,   vend_active,      vend_cntct1_id,\n       vend_cntct2_id, crmacct_id, vend_number,\n       MIN(pohead_orderdate) AS minpodate, \n       MAX(pohead_orderdate) AS maxpodate, \n       formatMoney(SUM(currToBase(pohead_curr_id,\n       (poitem_qty_ordered - poitem_qty_received) * poitem_unitprice,\n                              CURRENT_DATE))) AS backlog ,\n       c1.cntct_first_name || ' ' || c1.cntct_last_name AS contact1_name,\n       c1.cntct_phone AS contact1_phone, c1.cntct_phone2 AS contact1_phone, \n       formataddr(a1.addr_id) AS contact1_address,\n       c1.cntct_fax as contact1_fax, c1.cntct_email AS contct1_email,\n       c2.cntct_first_name || ' ' || c2.cntct_last_name AS contact2_name,\n       c2.cntct_phone AS contact2_phone, c2.cntct_phone2 AS contact2_phone, \n       c2.cntct_fax as contact2_fax, c2.cntct_email AS contct2_email,\n       formataddr(a2.addr_id) AS contact2_address,\n       vend_comments\n  FROM vendinfo\n    LEFT OUTER JOIN cntct c1 ON (vend_cntct1_id = c1.cntct_id)\n    LEFT OUTER JOIN addr  a1 ON (c1.cntct_addr_id = a1.addr_id)\n    LEFT OUTER JOIN cntct c2 ON (vend_cntct2_id = c2.cntct_id)\n    LEFT OUTER JOIN addr  a2 ON (c2.cntct_addr_id = a2.addr_id)\n    LEFT OUTER JOIN pohead ON (pohead_vend_id=vend_id)\n    LEFT OUTER JOIN poitem ON (poitem_pohead_id=pohead_id\n                               AND poitem_status='O')\n    JOIN crmacct ON (crmacct_vend_id=vend_id)\n    WHERE (vend_id=&lt;? value("vend_id") ?>) \n    GROUP BY vend_name, vend_vendtype_id, vend_terms_id,\n       vend_shipvia,   vend_active,vend_cntct1_id,\n       vend_cntct2_id, crmacct_id,\n       c1.cntct_first_name, c1.cntct_last_name,\n       c1.cntct_phone, c1.cntct_phone2, \n       a1.addr_id,c1.cntct_fax, c1.cntct_email,\n       c2.cntct_first_name,c2.cntct_last_name ,\n       c2.cntct_phone, c2.cntct_phone2, \n       c2.cntct_fax, c2.cntct_email,a2.addr_id,\n       vend_comments, vend_number;</sql>\n </querysource>\n <querysource>\n  <name>lypurch</name>\n  <sql>SELECT formatMoney(SUM(currToBase(vohead_curr_id,\n                                        vohead_amount,\n                                        vohead_gldistdate))) AS purchases \n                           FROM vohead \n                           WHERE (vohead_posted\n                             AND (vohead_gldistdate \n                                  BETWEEN (DATE_TRUNC('year', CURRENT_DATE) - INTERVAL '1 year')\n                                      AND (DATE_TRUNC('year', CURRENT_DATE) - INTERVAL '1 day'))\n                             AND (vohead_vend_id=&lt;? value("vend_id") ?>));</sql>\n </querysource>\n <querysource>\n  <name>ytdpurch</name>\n  <sql>SELECT formatMoney(SUM(currToBase(vohead_curr_id,\n                                        vohead_amount,\n                                        vohead_gldistdate))) AS purchases \n                           FROM vohead \n                           WHERE (vohead_posted\n                             AND (vohead_gldistdate \n                                  BETWEEN (DATE_TRUNC('year', CURRENT_DATE))\n                                      AND (CURRENT_DATE - INTERVAL '1 day'))\n                             AND (vohead_vend_id=&lt;? value("vend_id") ?>));</sql>\n </querysource>\n <querysource>\n  <name>backlog</name>\n  <sql>SELECT formatMoney( COALESCE( SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) ), 0 ) ) AS backlog FROM cohead, coitem, itemsite, item WHERE ( (coitem_cohead_id=cohead_id) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (coitem_status='O') AND (cohead_cust_id=&lt;? value("cust_id") ?>) );</sql>\n </querysource>\n <querysource>\n  <name>OpenBalance</name>\n  <sql>SELECT formatMoney(COALESCE(SUM((apopen_amount-apopen_paid) / apopen_curr_rate * \n                      CASE WHEN (apopen_doctype IN ('D','V')) THEN 1 \n                      ELSE -1 END), 0.0)) AS balance \n                    FROM apopen \n                    WHERE ((apopen_open)\n                       AND (apopen_vend_id=&lt;? value("vend_id") ?>));\n</sql>\n </querysource>\n <querysource>\n  <name>podate</name>\n  <sql>SELECT formatDate(MIN(pohead_orderdate)) AS firstpodate, formatDate(MAX(pohead_orderdate)) AS lastpodate\nFROM pohead\nWHERE (pohead_vend_id=&lt;? value("vend_id") ?>)</sql>\n </querysource>\n <rpthead>\n  <height>392</height>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>260</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>FAX:</string>\n  </label>\n  <text>\n   <rect>\n    <x>105</x>\n    <y>368</y>\n    <width>575</width>\n    <height>15</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>vend_comments</column>\n   </data>\n  </text>\n  <field>\n   <rect>\n    <x>134</x>\n    <y>305</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>podate</query>\n    <column>firstpodate</column>\n   </data>\n  </field>\n  <line>\n   <xstart>370</xstart>\n   <ystart>160</ystart>\n   <xend>370</xend>\n   <yend>295</yend>\n   <weight>0</weight>\n  </line>\n  <line>\n   <xstart>5</xstart>\n   <ystart>155</ystart>\n   <xend>360</xend>\n   <yend>155</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>375</x>\n    <y>10</y>\n    <width>350</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor Information</string>\n  </label>\n  <field>\n   <rect>\n    <x>99.8</x>\n    <y>229</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>contact1_name</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>260</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>contact1_fax</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>305</y>\n    <width>120</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Last Year Purchases:</string>\n  </label>\n  <field>\n   <rect>\n    <x>474</x>\n    <y>229</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>contact2_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>75</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>325</y>\n    <width>115</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Last Purchase Date:</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>295</ystart>\n   <xend>740</xend>\n   <yend>295</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>260</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>FAX:</string>\n  </label>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>229</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Contact Name:</string>\n  </label>\n  <field>\n   <rect>\n    <x>400</x>\n    <y>305</y>\n    <width>145</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>lypurch</query>\n    <column>purchases</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>275</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>contact2_email</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>275</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>contact1_email</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>260</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>contact2_fax</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>245</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Phone:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>75</y>\n    <width>295</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>290</x>\n    <y>325</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>YTD Purchases:</string>\n  </label>\n  <field>\n   <rect>\n    <x>400</x>\n    <y>325</y>\n    <width>145</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>ytdpurch</query>\n    <column>purchases</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>1.60714</x>\n    <y>345.214</y>\n    <width>118.393</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Backlog:</string>\n  </label>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>275</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Email:</string>\n  </label>\n  <field>\n   <rect>\n    <x>475</x>\n    <y>245</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>contact2_phone</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>140</y>\n    <width>135</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Contact 2</string>\n  </label>\n  <line>\n   <xstart>380</xstart>\n   <ystart>155</ystart>\n   <xend>735</xend>\n   <yend>155</yend>\n   <weight>0</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>229</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Contact Name:</string>\n  </label>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>245</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Phone:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>140</y>\n    <width>170</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Contact 1</string>\n  </label>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>344.893</y>\n    <width>103</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>backlog</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>245</y>\n    <width>260</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>contact1_phone</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>130</x>\n    <y>325</y>\n    <width>105</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>podate</query>\n    <column>lastpodate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>410</x>\n    <y>345</y>\n    <width>134.643</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>OpenBalance</query>\n    <column>balance</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>365</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Notes:</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>95</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Number:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>95</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>vend_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>275</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Email:</string>\n  </label>\n  <label>\n   <rect>\n    <x>286</x>\n    <y>345</y>\n    <width>104</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Open Balance:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>305</y>\n    <width>115</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>First Purchase Date:</string>\n  </label>\n  <text>\n   <rect>\n    <x>21</x>\n    <y>163</y>\n    <width>341</width>\n    <height>12</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>contact1_address</column>\n   </data>\n  </text>\n  <text>\n   <rect>\n    <x>399</x>\n    <y>164</y>\n    <width>333</width>\n    <height>12</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>head</query>\n    <column>contact2_address</column>\n   </data>\n  </text>\n </rpthead>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102657
 
142     VendorMasterList        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Vendor Master List</title>\n <name>VendorMasterList</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>vendors</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>153</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>118</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>118</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>133</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Address</string>\n  </label>\n  <line>\n   <xstart>8</xstart>\n   <ystart>149</ystart>\n   <xend>748</xend>\n   <yend>149</yend>\n   <weight>2</weight>\n  </line>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>43</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>15</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Address</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>91</height>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>30</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>addr_line2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>515</x>\n     <y>60</y>\n     <width>204</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>addr_zip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>15</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>addr_line1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>60</y>\n     <width>204</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>addr_city</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>45</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>addr_line3</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>370</x>\n     <y>60</y>\n     <width>140</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>addr_state</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n              0       2014-10-06 19:47:03.678943
102658
 
186     VendorTypesMasterList   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Vendor Types Master List</title>\n <name>VendorTypesMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT vendtype_id,\n       vendtype_code,\n       vendtype_descrip\n  FROM vendtype\nORDER BY vendtype_code;</sql>\n </querysource>\n <rpthead>\n  <height>76</height>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>55</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>70</ystart>\n   <xend>745</xend>\n   <yend>70</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Vendor Types Master List</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>55</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>175</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>175</x>\n     <y>0</y>\n     <width>565</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vendtype_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vendtype_code</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n             0       2014-10-06 19:47:03.678943
102659
 
260     ViewAPCheckRunEditList  \N      <!DOCTYPE openRPTDef>\n<report>\n <title>View Payment Run Edit List</title>\n <name>ViewAPCheckRunEditList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT CASE WHEN checkhead_void THEN 0\n                   ELSE checkhead_amount END AS amt_check,\n              CASE WHEN checkhead_void THEN 0\n                   ELSE currToBase(checkhead_curr_id,checkhead_amount,\n                                   checkhead_checkdate)\n              END AS base_amt_check,\n       checkhead_id AS primaryid,\n       -1 AS secondaryid,\n       formatBoolYN(checkhead_void) AS f_void,\n       formatBoolYN(checkhead_printed) AS f_printed,\n       TEXT(checkhead_number) AS number,\n       (checkrecip_number || '-' || checkrecip_name) AS description,\n       formatDate(checkhead_checkdate) AS f_checkdate,\n       formatMoney(checkhead_amount) AS f_amount,\n       formatMoney(currtobase(checkhead_curr_id,checkhead_amount,checkhead_checkdate)) AS f_baseamount,\n       currconcat(checkhead_curr_id) AS currAbbr,\n       checkhead_number,\n       1 AS orderby\n  FROM checkhead LEFT OUTER JOIN\n       checkrecip ON ((checkrecip_id=checkhead_recip_id)\n\t\t AND  (checkrecip_type=checkhead_recip_type))\n WHERE ((checkhead_bankaccnt_id=&lt;? value("bankaccnt_id") ?>)\n   AND  (NOT checkhead_posted)\n   AND  (NOT checkhead_replaced)\n   AND  (NOT checkhead_deleted)\n&lt;? if exists(&quot;vend_id&quot;) ?>\n   AND (checkrecip_type='V')\n   AND (checkrecip_id=&lt;? value(&quot;vend_id&quot;) ?>)\n&lt;? elseif exists(&quot;vendtype_id&quot;) ?>\n   AND (checkrecip_type='V')\n   AND (checkrecip_id IN (SELECT vend_id\n                          FROM vendinfo\n                          WHERE (vend_vendtype_id=&lt;? value(&quot;vendtype_id&quot;) ?>)))\n&lt;? elseif exists(&quot;vendtype_pattern&quot;) ?>\n   AND (checkrecip_type='V')\n   AND (checkrecip_id IN (SELECT vend_id\n                          FROM vendinfo, vendtype\n                          WHERE ((vend_vendtype_id=vendtype_id)\n                             AND (vendtype_code ~ &lt;? value(&quot;vendtype_pattern&quot;) ?>))))\n&lt;? endif ?>\n   )\n\nUNION SELECT 0 AS amt_check,\n             0 AS base_amt_check,\n             checkitem_checkhead_id AS primaryid,\n             checkitem_id AS secondaryid,\n             '' AS f_void,\n             '' AS f_printed,\n             CASE WHEN (checkitem_ranumber IS NOT NULL) THEN checkitem_ranumber::TEXT\n\t          ELSE checkitem_vouchernumber\n\t     END AS number,\n             CASE WHEN (checkitem_cmnumber IS NOT NULL) THEN checkitem_cmnumber::TEXT\n\t          ELSE checkitem_invcnumber\n\t     END AS description,\n             '' AS f_checkdate,\n             formatMoney(checkitem_amount) AS f_amount,\n             formatMoney(currtobase(checkitem_curr_id,checkitem_amount,checkhead_checkdate)) AS f_baseamount,\n             currconcat(checkitem_curr_id) AS currAbbr,\n             checkhead_number,\n             2 AS orderby\n        FROM checkitem, checkhead\n       WHERE ( (checkitem_checkhead_id=checkhead_id)\n         AND (checkhead_bankaccnt_id=&lt;? value("bankaccnt_id") ?>)\n         AND (NOT checkhead_posted)\n         AND (NOT checkhead_replaced)\n         AND (NOT checkhead_deleted)\n&lt;? if exists(&quot;vend_id&quot;) ?>\n         AND (checkhead_recip_type='V')\n         AND (checkhead_recip_id=&lt;? value(&quot;vend_id&quot;) ?>)\n&lt;? elseif exists(&quot;vendtype_id&quot;) ?>\n         AND (checkhead_recip_type='V')\n         AND (checkhead_recip_id IN (SELECT vend_id\n                                FROM vendinfo\n                                WHERE (vend_vendtype_id=&lt;? value(&quot;vendtype_id&quot;) ?>)))\n&lt;? elseif exists(&quot;vendtype_pattern&quot;) ?>\n         AND (checkhead_recip_type='V')\n         AND (checkhead_recip_id IN (SELECT vend_id\n                                FROM vendinfo, vendtype\n                                WHERE ((vend_vendtype_id=vendtype_id)\n                                   AND (vendtype_code ~ &lt;? value(&quot;vendtype_pattern&quot;) ?>))))\n&lt;? endif ?>\n              )\nORDER BY checkhead_number, primaryid, orderby;</sql>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT (bankaccnt_name || '-' || bankaccnt_descrip) AS bankaccnt\n  FROM bankaccnt\n WHERE (bankaccnt_id=&lt;? value("bankaccnt_id") ?>);</sql>\n </querysource>\n <rpthead>\n  <height>127</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>100</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Void</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>112</ystart>\n   <xend>745</xend>\n   <yend>112</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>100</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Printed</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>85</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Recipient</string>\n  </label>\n  <label>\n   <rect>\n    <x>455</x>\n    <y>100</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Payment Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>145</x>\n    <y>55</y>\n    <width>350</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>bankaccnt</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>130</x>\n    <y>83</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Payment #</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>100</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Invoice/Credit Memo #</string>\n  </label>\n  <label>\n   <rect>\n    <x>20</x>\n    <y>55</y>\n    <width>120</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Bank Account:</string>\n  </label>\n  <label>\n   <rect>\n    <x>130</x>\n    <y>100</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Voucher/Return Auth. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>280</x>\n    <y>5</y>\n    <width>465</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>A/P Payment Run Edit List</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>100</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>100</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>11</height>\n </pghead>\n <pghead>\n  <height>28</height>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>5</y>\n    <width>57</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Currency</string>\n  </label>\n  <label>\n   <rect>\n    <x>130</x>\n    <y>5</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Payment/Voucher #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>20</ystart>\n   <xend>745</xend>\n   <yend>20</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>5</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Recipient/Invoice #</string>\n  </label>\n  <label>\n   <rect>\n    <x>645</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Amount</string>\n  </label>\n  <label>\n   <rect>\n    <x>460</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Payment Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>65</x>\n    <y>5</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Printed</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>5</y>\n    <width>55</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Void</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>orderid</column>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>21</height>\n   <field>\n    <rect>\n     <x>130</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>585</x>\n     <y>0</y>\n     <width>53</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>currAbbr</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_void</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_printed</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>465</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_checkdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>0</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>description</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>645</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_amount</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>21</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>61</height>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>amt_check</column>\n   </data>\n   <tracktotal builtin="true" >qty</tracktotal>\n  </field>\n  <field>\n   <rect>\n    <x>645</x>\n    <y>20</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>base_amt_check</column>\n   </data>\n   <tracktotal builtin="true" >qty</tracktotal>\n  </field>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>20</y>\n    <width>145</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Total (Base):</string>\n  </label>\n  <line>\n   <xstart>567</xstart>\n   <ystart>2</ystart>\n   <xend>745</xend>\n   <yend>2</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>494</x>\n    <y>5</y>\n    <width>145</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Total:</string>\n  </label>\n </rptfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102660
 
287     VoucherRegister \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Voucher Register</title>\n <name>VoucherRegister</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatDate(&lt;? value(&quot;startDate&quot;) ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value(&quot;endDate&quot;) ?>, 'Latest') AS enddate,\n       &lt;? if exists(&quot;accnt_id&quot;) ?>\n         ( SELECT (accnt_number || '-' || accnt_descrip)\n             FROM accnt\n            WHERE (accnt_id=&lt;? value(&quot;accnt_id&quot;) ?>) )\n       &lt;? else ?>\n         text('All Accounts')\n       &lt;? endif ?>\n       AS accnt,\n       &lt;? if exists(&quot;showUsernames&quot;) ?>\n         text('Username')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_username</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT gltrans_id,\n       formatDate(gltrans_date) AS transdate,\n       vend_number, vend_name,\n       gltrans_doctype,\n       gltrans_docnumber,\n       firstLine(gltrans_notes) AS transnotes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       CASE WHEN (gltrans_amount &lt; 0) THEN formatMoney(ABS(gltrans_amount))\n            ELSE ''\n       END AS f_debit,\n       CASE WHEN (gltrans_amount > 0) THEN formatMoney(gltrans_amount)\n            ELSE ''\n       END AS f_credit,\n       &lt;? if exists(&quot;showUsernames&quot;) ?>\n         gltrans_username\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS f_username\n  FROM accnt, gltrans LEFT OUTER JOIN vohead JOIN vendinfo ON (vohead_vend_id=vend_id) ON (gltrans_doctype='VO' and gltrans_docnumber=vohead_number)\n WHERE ((gltrans_accnt_id=accnt_id)\n   AND (gltrans_date BETWEEN &lt;? value(&quot;startDate&quot;) ?> AND &lt;? value(&quot;endDate&quot;) ?>)\n&lt;? if exists(&quot;accnt_id&quot;) ?>\n   AND (gltrans_accnt_id=&lt;? value(&quot;accnt_id&quot;) ?>)\n&lt;? endif ?>\n   AND (gltrans_source='A/P')\n       )\nORDER BY gltrans_created DESC, gltrans_sequence, gltrans_amount;</sql>\n </querysource>\n <rpthead>\n  <height>221</height>\n  <field>\n   <rect>\n    <x>545</x>\n    <y>70</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>170</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>185</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>215</ystart>\n   <xend>745</xend>\n   <yend>215</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_username</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vend. Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>10</y>\n    <width>465</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Voucher Register</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>200</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>409</x>\n    <y>90</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>70</y>\n    <width>130</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Account:</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>185</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vend. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>545</x>\n    <y>90</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>70</y>\n    <width>290</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>accnt</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>56</height>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>20</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>160</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Doc. Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>35</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vend. #</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>20</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Account</string>\n  </label>\n  <label>\n   <rect>\n    <x>245</x>\n    <y>5</y>\n    <width>106</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Reference</string>\n  </label>\n  <label>\n   <rect>\n    <x>105</x>\n    <y>35</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vend. Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>510</x>\n    <y>35</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Debit</string>\n  </label>\n  <label>\n   <rect>\n    <x>595</x>\n    <y>35</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Credit</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>5</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_username</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>50</ystart>\n   <xend>745</xend>\n   <yend>50</yend>\n   <weight>2</weight>\n  </line>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>46</height>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>0</y>\n     <width>260</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transnotes</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>15</x>\n     <y>30</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>245</x>\n     <y>15</y>\n     <width>260</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>account</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>160</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_doctype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>transdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>510</x>\n     <y>30</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_debit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>105</x>\n     <y>30</y>\n     <width>265</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vend_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>595</x>\n     <y>30</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_credit</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>620</x>\n     <y>0</y>\n     <width>120</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_username</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>160</x>\n     <y>15</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>gltrans_docnumber</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n         0       2014-10-06 19:47:03.678943
102661
 
86      WOHistoryByItem \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Work Order History by Item</title>\n <name>WOHistoryByItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>Detail</name>\n  <sql>SELECT formatWONumber(wo_id) AS wonumber,\n       wo_status, warehous_code,\n       formatQty(wo_qtyord) AS ordered,\n       formatQty(wo_qtyrcv) AS received,\n       formatDate(wo_startdate) AS startdate,\n       formatDate(wo_duedate) AS duedate,\n       &lt;? if exists(&quot;showCosts&quot;) ?>\n         formatCost(wo_postedvalue)\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS value\n  FROM wo, itemsite, whsinfo\n WHERE ((wo_itemsite_id=itemsite_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (itemsite_item_id=&lt;? value(&quot;item_id&quot;) ?>)\n&lt;? if exists(&quot;showOnlyTopLevel&quot;) ?>\n   AND ((wo_ordtype&lt;>'W') OR (wo_ordtype IS NULL))\n&lt;? endif ?>\n&lt;? if exists(&quot;warehous_id&quot;) ?>\n   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)\n&lt;? endif ?>\n   AND (wo_duedate BETWEEN &lt;? value(&quot;startDate&quot;) ?> AND &lt;? value(&quot;endDate&quot;) ?>) )\nORDER BY wo_startdate DESC, wo_number, wo_subnumber;\n    </sql>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number,\n       item_descrip1,\n       item_descrip2,\n       &lt;? if exists(&quot;warehous_id&quot;) ?>\n         (SELECT warehous_code\n            FROM whsinfo\n           WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>))\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse,\n       &lt;? if exists(&quot;showOnlyTopLevel&quot;) ?>\n         text('Only Show Top Level Work Orders')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS lbl_toplevel,\n       &lt;? if exists(&quot;showCosts&quot;) ?>\n         text('Cost')\n       &lt;? else ?>\n         text('')\n       &lt;? endif ?>\n       AS lbl_cost,\n       formatDate(&lt;? value(&quot;startDate&quot;) ?>, 'Earliest') AS startdate,\n       formatDate(&lt;? value(&quot;endDate&quot;) ?>, 'Latest') AS enddate\n  FROM item\n WHERE (item_id=&lt;? value(&quot;item_id&quot;) ?>);</sql>\n </querysource>\n <rpthead>\n  <height>191</height>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>85</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>85</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>enddate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>445</x>\n    <y>105</y>\n    <width>250</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_toplevel</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>170</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>114</x>\n    <y>170</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>125</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>550</x>\n    <y>65</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>startdate</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>105</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>185</ystart>\n   <xend>740</xend>\n   <yend>185</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>170</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>10</y>\n    <width>484</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Work Order History By Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>235</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>125</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>65</y>\n    <width>305</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>445</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>End Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>445</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Start Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_cost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>65</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>31</height>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>10</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>114</x>\n    <y>10</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>25</ystart>\n   <xend>740</xend>\n   <yend>25</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>320</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <field>\n   <rect>\n    <x>660</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>lbl_cost</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>10</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>235</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>Detail</query>\n   </key>\n   <height>16</height>\n   <field>\n    <rect>\n     <x>405</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>startdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>170</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>wonumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>114</x>\n     <y>0</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>wo_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>235</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>320</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>received</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>value</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>114</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102662
 
87      WOHistoryByNumber       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Work Order History by Number</title>\n <name>WOHistoryByNumber</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>Detail</name>\n  <sql>SELECT formatWoNumber(wo_id) AS number,\n       wo_subnumber AS subnumber,\n       wo_status, warehous_code,\n       item_number, item_descrip1, item_descrip2, uom_name,\n       formatQty(wo_qtyord) AS ordered,\n       formatQty(wo_qtyrcv) AS received,\n       formatDate(wo_startdate) AS startdate,\n       formatDate(wo_duedate) AS duedate,\n       &lt;? if exists("showCosts") ?>\n         text('W/O Cost') AS lbl_value,\n         formatCost(wo_postedvalue) AS value\n       &lt;? else ?>\n         text('') AS lbl_value,\n         text('') AS value\n       &lt;? endif ?>\n  FROM wo, itemsite, whsinfo, item, uom\n WHERE ((wo_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (CAST(wo_number AS TEXT) ~ &lt;? value("woNumber") ?>)\n&lt;? if exists("showOnlyTopLevel") ?>\n   AND ((wo_ordtype&lt;>'W') OR (wo_ordtype IS NULL))\n&lt;? endif ?>\n )\nORDER BY wo_subnumber;\n    </sql>\n </querysource>\n <rpthead>\n  <height>172</height>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>150</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>508</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>30</x>\n    <y>85</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>W/O Pattern:</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>150</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>10</y>\n    <width>483</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Work Order History By W/O Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>150</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>125</x>\n    <y>150</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>85</y>\n    <width>170</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Parameter Query</query>\n    <column>woNumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>150</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>165</ystart>\n   <xend>740</xend>\n   <yend>165</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>228</x>\n    <y>150</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>670</x>\n    <y>151</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>Detail</query>\n    <column>lbl_value</column>\n   </data>\n  </field>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>7</height>\n </pghead>\n <pghead>\n  <height>32</height>\n  <label>\n   <rect>\n    <x>228</x>\n    <y>10</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>85</x>\n    <y>10</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>125</x>\n    <y>10</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>508</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>10</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>25</ystart>\n   <xend>740</xend>\n   <yend>25</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>45</x>\n    <y>10</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>270</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <field>\n   <rect>\n    <x>665</x>\n    <y>13</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>Detail</query>\n    <column>lbl_value</column>\n   </data>\n  </field>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>Detail</query>\n   </key>\n   <height>52</height>\n   <field>\n    <rect>\n     <x>125</x>\n     <y>15</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>5</x>\n     <y>0</y>\n     <width>55</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>125</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>350</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>received</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>70</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>value</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>65</x>\n     <y>0</y>\n     <width>20</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>wo_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>85</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>startdate</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>740</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>508</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>228</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>125</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102663
 
279     WOLabel \N      <!DOCTYPE openRPTDef>\n<report>\n <title>WO Order Label</title>\n <name>WOLabel</name>\n <description>Labels generated for use in labeling parts out of a work order</description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>\n  <width>400</width>\n  <height>333</height>\n </size>\n <portrait/>\n <topmargin>25</topmargin>\n <bottommargin>25</bottommargin>\n <rightmargin>25</rightmargin>\n <leftmargin>25</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n sequence_value,\n formatDate(wo_duedate) AS due_date, \n item_number,\n item_descrip1,\n COALESCE(prodcat_descrip, '') AS prodcat_descrip \n FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)\n         JOIN item ON (item_id=itemsite_item_id)\n         JOIN sequence ON (sequence.sequence_value BETWEEN 1 AND &lt;? value("labelTo") ?>)\n         LEFT OUTER JOIN prodcat ON (prodcat_id=item_prodcat_id)\nWHERE (wo_id=&lt;? value("wo_id") ?>);\n</sql>\n </querysource>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>218</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>150</y>\n     <width>330</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>12</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>95</y>\n     <width>330</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>12</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>prodcat_descrip</column>\n    </data>\n   </field>\n   <barcode>\n    <rect>\n     <x>10</x>\n     <y>180</y>\n     <width>330</width>\n     <height>25</height>\n    </rect>\n    <format>3of9</format>\n    <maxlength>5</maxlength>\n    <left/>\n    <narrowBarWidth>0.01</narrowBarWidth>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </barcode>\n   <field>\n    <rect>\n     <x>150</x>\n     <y>35</y>\n     <width>120</width>\n     <height>18</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>12</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>due_date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>75</x>\n     <y>125</y>\n     <width>265</width>\n     <height>18</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>12</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>10</x>\n     <y>125</y>\n     <width>61</width>\n     <height>18</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>12</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>PART #:</string>\n   </label>\n  </detail>\n </section>\n</report>\n       Labels generated for use in labeling parts out of a work order  0       2014-10-06 19:47:03.678943
102664
 
280     WOLabelForm     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>WO Order Label</title>\n <name>WOLabelForm</name>\n <description>Labels generated for use in labeling parts out of a work order</description>\n <size>\n  <width>275</width>\n  <height>212</height>\n </size>\n <portrait/>\n <topmargin>25</topmargin>\n <bottommargin>25</bottommargin>\n <rightmargin>25</rightmargin>\n <leftmargin>25</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT \n sequence_value,\n formatDate(wo_duedate) AS due_date, \n item_number,\n item_descrip1,\n prodcat_descrip \n FROM \n wo, \n itemsite,\n item,\n prodcat,\n sequence\nWHERE ( (wo_itemsite_id = itemsite_id)\nAND (wo_id=&lt;? value(&quot;wo_id&quot;) ?>)\nAND (item_prodcat_id = prodcat_id)\nAND (itemsite_item_id = item_id)\nAND (sequence.sequence_value \nBETWEEN 1 AND 1));</sql>\n </querysource>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>214</height>\n   <field>\n    <rect>\n     <x>21</x>\n     <y>91</y>\n     <width>192</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prodcat_descrip</column>\n    </data>\n   </field>\n   <barcode>\n    <rect>\n     <x>10</x>\n     <y>182</y>\n     <width>212</width>\n     <height>25</height>\n    </rect>\n    <format>3of9</format>\n    <maxlength>5</maxlength>\n    <center/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </barcode>\n   <label>\n    <rect>\n     <x>10</x>\n     <y>125</y>\n     <width>52</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <top/>\n    <string>PART #:</string>\n   </label>\n   <field>\n    <rect>\n     <x>62</x>\n     <y>122</y>\n     <width>265</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>145</x>\n     <y>5</y>\n     <width>77</width>\n     <height>17</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>9</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <top/>\n    <data>\n     <query>detail</query>\n     <column>due_date</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>20</x>\n     <y>151</y>\n     <width>185</width>\n     <height>25</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>10</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n  </detail>\n </section>\n</report>\n   Labels generated for use in labeling parts out of a work order  0       2014-10-06 19:47:03.678943
102665
 
90      WOMaterialAvailabilityByWorkOrder       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>W/O Material Availability By Work Order</title>\n <name>WOMaterialAvailabilityByWorkOrder</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatWONumber(wo_id) AS wonumber,\n       warehous_code as warehouse,\n       item_number, item_descrip1, item_descrip2, uom_name,\n       wo_status AS status,        \n       &lt;? if exists("onlyShowShortages") ?>\n         text('Only Show Shortages')\n       &lt;? elseif exists("onlyShowInsufficientInventory") ?>\n         text('Only Show Insufficient Inventory')\n       &lt;? else ?>\n         text('All Materials')\n       &lt;? endif ?>\n       AS itemfiltertext,\n       &lt;? if exists("IndentedParentChild") ?>\n         text('Indented Works Orders')\n       &lt;? elseif exists("summarizedParentChild") ?>\n         text('Summarized Parent/Child Orders')\n       &lt;? else ?>\n         text('Parent Order Only')\n       &lt;? endif ?>\n       AS wofiltertext\n  FROM wo, itemsite, item, uom, whsinfo\n WHERE ((wo_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (wo_id=&lt;? value("wo_id") ?>) );</sql>\n </querysource>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT *, (REPEAT(' ',(woinvav_level-1)*3) || woinvav_item_wo_number) AS itemwonumber FROM woinvavail(&lt;? value("wo_id") ?>,\n&lt;? if exists("IndentedParentChild") ?>\ntrue, \n &lt;? else ?>\nfalse, \n&lt;? endif ?>\n&lt;? if exists("summarizedParentChild") ?>\ntrue, \n &lt;? else ?>\nfalse, \n&lt;? endif ?>\n&lt;? if exists("onlyShowShortages") ?>\ntrue, \n &lt;? else ?>\nfalse, \n&lt;? endif ?>\n&lt;? if exists("onlyShowInsufficientInventory") ?>\ntrue) \n &lt;? else ?>\nfalse) \n&lt;? endif ?></sql>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>55</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Work Order #:</string>\n  </label>\n  <field>\n   <rect>\n    <x>325</x>\n    <y>100</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>uom_name</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>100</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Number:</string>\n  </label>\n  <label>\n   <rect>\n    <x>265</x>\n    <y>100</y>\n    <width>55</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>UOM:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>75</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>WO/Item Number</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>55</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>wonumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Alloc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>75</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>165</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Status:</string>\n  </label>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>5</y>\n    <width>558</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>W/O Material Availability By Work Order</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>165</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>status</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Avail.</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O Avail.</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O Alloc.</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>140</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>509</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Orders</string>\n  </label>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>215</y>\n    <width>125</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>55</y>\n    <width>70</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Filter:</string>\n  </label>\n  <field>\n   <rect>\n    <x>325</x>\n    <y>55</y>\n    <width>365</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>itemfiltertext</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>325</x>\n    <y>75</y>\n    <width>365</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>wofiltertext</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>250</x>\n    <y>75</y>\n    <width>70</width>\n    <height>18</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>WO Filter:</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O Alloc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Alloc.</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Total Avail.</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>WO/Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>205</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O Avail.</string>\n  </label>\n  <label>\n   <rect>\n    <x>509</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Orders</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Adj. QOH</string>\n  </label>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>32</height>\n   <field>\n    <rect>\n     <x>350</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>woinvav_balance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>woinvav_qoh</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>woinvav_totalavail</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>woinvav_allocated</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>509</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>woinvav_ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>170</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemwonumber</column>\n    </data>\n   </field>\n   <line>\n    <xstart>0</xstart>\n    <ystart>29</ystart>\n    <xend>750</xend>\n    <yend>29</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>190</x>\n     <y>15</y>\n     <width>555</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>woinvav_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>590</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>woinvav_woavail</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>190</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>woinvav_uomname</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>76</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>76</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>695</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102666
 
88      WOMaterialRequirementsByComponentItem   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>W/O Material Requirements By Component Item</title>\n <name>WOMaterialRequirementsByComponentItem</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT item_number, item_descrip1, item_descrip2,\n       &lt;? if exists("warehous_id") ?>\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) )\n       &lt;? else ?>\n         text('All Sites')\n       &lt;? endif ?>\n       AS warehouse\n  FROM item\n WHERE (item_id=&lt;? value("item_id") ?>);\n</sql>\n </querysource>\n <querysource loadFromDb="true" >\n  <name>detail</name>\n  <mqlgroup>workOrderMaterial</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <querysource>\n  <name>total</name>\n  <sql>SELECT formatQty(SUM(womatl_qtyreq)) AS required,\n       formatQty(SUM(womatl_qtyiss)) AS issued,\n       formatQty(SUM(noNeg(womatl_qtyreq - womatl_qtyiss))) AS balance\n    FROM wo, womatl, itemsite AS parentsite, itemsite AS componentsite, item, uom\nWHERE ((womatl_wo_id=wo_id)\n       AND (womatl_uom_id=uom_id)\n       AND (wo_status &lt;> 'C')\n       AND (wo_itemsite_id=parentsite.itemsite_id)\n       AND (womatl_itemsite_id=componentsite.itemsite_id)\n       AND (parentsite.itemsite_item_id=item_id)\n       AND (componentsite.itemsite_item_id=&lt;? value("item_id") ?>)\n&lt;? if exists("warehous_id") ?>\n       AND (componentsite.itemsite_warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n )\n;</sql>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>515</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issued</string>\n  </label>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Required</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>145</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap %</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>80</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>W/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>198</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Item #</string>\n  </label>\n  <label>\n   <rect>\n    <x>15</x>\n    <y>145</y>\n    <width>80</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>80</y>\n    <width>200</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>155</x>\n    <y>5</y>\n    <width>593</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>W/O Material Requirements By Component Item</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>213</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Fxd Qty</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>515</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issued</string>\n  </label>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap %</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Parent Item #</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>440</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Required</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>W/O #</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty Per</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>200</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>285</x>\n    <y>14</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Fxd Qty</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>wonumber</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>95</x>\n     <y>32</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>590</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>95</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>515</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyiss</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>issuemethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>360</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>400</x>\n     <y>32</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>440</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>280</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>280</x>\n     <y>17</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyfxd</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>620</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>595</x>\n    <y>1</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>total</query>\n    <column>balance</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>315</x>\n    <y>1</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Totals:</string>\n  </label>\n  <field>\n   <rect>\n    <x>520</x>\n    <y>1</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>total</query>\n    <column>issued</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>445</x>\n    <y>1</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>total</query>\n    <column>required</column>\n   </data>\n  </field>\n </rptfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102667
 
89      WOMaterialRequirementsByWorkOrder       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>W/O Material Requirements By Work Order</title>\n <name>WOMaterialRequirementsByWorkOrder</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>head</name>\n  <sql>SELECT formatWONumber(wo_id) AS wonumber,\n       warehous_code as warehouse,\n       item_number, item_descrip1,\n       item_descrip2, uom_name,\n       wo_status AS status\n  FROM wo, itemsite, item, uom, whsinfo\n WHERE ((wo_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (wo_id=&lt;? value("wo_id") ?>) );</sql>\n </querysource>\n <querysource loadFromDb="true" >\n  <name>detail</name>\n  <mqlgroup>workOrderMaterial</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>236</height>\n  <label>\n   <rect>\n    <x>509</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issued</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>165</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>status</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>100</y>\n    <width>150</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>75</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>100</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Item Number:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>55</y>\n    <width>90</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Work Order #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>215</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>5</y>\n    <width>558</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>W/O Material Requirements By Work Order</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>140</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip2</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Required</string>\n  </label>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty Per</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>75</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>warehouse</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>200</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap %</string>\n  </label>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>120</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>item_descrip1</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>100</x>\n    <y>55</y>\n    <width>300</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>wonumber</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>165</y>\n    <width>85</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Status:</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>200</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item #</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>229</ystart>\n   <xend>745</xend>\n   <yend>229</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>213</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Fxd Qty</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>430</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Required</string>\n  </label>\n  <label>\n   <rect>\n    <x>509</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issued</string>\n  </label>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Issue Method</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Qty Per</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>670</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>590</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Balance</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Scrap %</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Component Item #</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>14</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Fxd Qty</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>51</height>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>430</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyreq</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>190</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>issuemethod</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>350</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_scrap</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>509</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyiss</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>745</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>30</y>\n     <width>300</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_duedate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>590</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_balance</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>255</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>0</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyper</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>270</x>\n     <y>17</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qtyfxd</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>620</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102668
 
452     WOSchedule      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Work Order Schedule</title>\n <name>WOSchedule</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>Detail</name>\n  <mqlgroup>workOrderSchedule</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <querysource>\n  <name>Head</name>\n  <sql>SELECT formatDate(&lt;? value("startDate") ?>, 'Earliest') AS f_startdate,\n       formatDate(&lt;? value("endDate") ?>, 'Latest') AS f_enddate,\n&lt;? if exists("warehous_id") ?>\n       warehous_code\nFROM whsinfo\nWHERE (warehous_id=&lt;? value("warehous_id") ?>);\n&lt;? else ?>\n       TEXT('All Sites') AS warehous_code;\n&lt;? endif ?>\n</sql>\n </querysource>\n <rpthead>\n  <height>191</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>185</ystart>\n   <xend>740</xend>\n   <yend>185</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>170</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>140</x>\n    <y>170</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>170</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>240</x>\n    <y>10</y>\n    <width>484</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Work Order Schedule</string>\n  </label>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>170</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>170</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>38</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>31</height>\n  <label>\n   <rect>\n    <x>575</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Start Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>95</x>\n    <y>10</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>190</x>\n    <y>10</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>W/O Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>490</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Received</string>\n  </label>\n  <label>\n   <rect>\n    <x>360</x>\n    <y>10</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>140</x>\n    <y>10</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Site</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>25</ystart>\n   <xend>740</xend>\n   <yend>25</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>660</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Due Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>405</x>\n    <y>10</y>\n    <width>80</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Ordered</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>Detail</query>\n   </key>\n   <height>52</height>\n   <field>\n    <rect>\n     <x>405</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>ordered</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>190</x>\n     <y>30</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>360</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>uom_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>190</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>140</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>received</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>wonumber</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>45</ystart>\n    <xend>740</xend>\n    <yend>45</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>190</x>\n     <y>15</y>\n     <width>200</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>95</x>\n     <y>0</y>\n     <width>40</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>wo_status</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>575</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>startdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>660</x>\n     <y>0</y>\n     <width>80</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>Detail</query>\n     <column>duedate</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>17</height>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>112</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n </pgfoot>\n</report>\n          0       2014-10-06 19:47:03.678943
102669
 
414     WarehouseLocationMasterList     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Warehouse Location Master List</title>\n <name>WarehouseLocationMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT (warehous_code || ' ' || location_name) AS whs_bin,\n       warehous_code,\n       formatLocationName(location_id) AS locationname,\n       location_descrip,\n       formatBoolYN(location_netable) AS f_netable,\n       formatBoolYN(location_restrict) AS f_restrict,\n       item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdesc\n  FROM location LEFT OUTER JOIN\n       (SELECT locitem_location_id,\n               item_number,\n               item_descrip1,\n               item_descrip2\n          FROM locitem, item\n         WHERE locitem_item_id=item_id) AS itemlocation\n       ON (locitem_location_id=location_id and location_restrict=true), whsinfo\n WHERE ((location_warehous_id=warehous_id)\n&lt;? if exists("warehous_id") ?>\n   AND (warehous_id=&lt;? value("warehous_id") ?>)\n&lt;? endif ?>\n) ORDER BY warehous_code, location_name;</sql>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("warehous_id") ?>\n         text('Warehouse:') AS f_text,\n         ( SELECT warehous_code\n             FROM whsinfo\n            WHERE (warehous_id=&lt;? value("warehous_id") ?>) ) AS f_value\n       &lt;? else ?>\n         text('') AS f_text,\n         text('') AS f_value\n       &lt;? endif ?></sql>\n </querysource>\n <rpthead>\n  <height>102</height>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>85</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Whs.</string>\n  </label>\n  <field>\n   <rect>\n    <x>30</x>\n    <y>50</y>\n    <width>100</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_text</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>290</x>\n    <y>85</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Restricted Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>55</x>\n    <y>85</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Location</string>\n  </label>\n  <label>\n   <rect>\n    <x>395</x>\n    <y>85</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description:</string>\n  </label>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>85</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Restricted</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>38</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Warehouse Location Master List</string>\n  </label>\n  <field>\n   <rect>\n    <x>140</x>\n    <y>50</y>\n    <width>175</width>\n    <height>20</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_value</column>\n   </data>\n  </field>\n  <line>\n   <xstart>5</xstart>\n   <ystart>100</ystart>\n   <xend>745</xend>\n   <yend>100</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>85</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Netable</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>21</height>\n  <label>\n   <rect>\n    <x>290</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Restricted Item</string>\n  </label>\n  <label>\n   <rect>\n    <x>170</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Netable</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>15</ystart>\n   <xend>745</xend>\n   <yend>15</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>215</x>\n    <y>0</y>\n    <width>70</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Restricted</string>\n  </label>\n  <label>\n   <rect>\n    <x>395</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description:</string>\n  </label>\n  <label>\n   <rect>\n    <x>55</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Location</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Whs.</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <group>\n   <name>detail</name>\n   <column>locationname</column>\n   <head>\n    <height>21</height>\n    <field>\n     <rect>\n      <x>225</x>\n      <y>5</y>\n      <width>50</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_restrict</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>5</x>\n      <y>5</y>\n      <width>50</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>warehous_code</column>\n     </data>\n    </field>\n    <text>\n     <rect>\n      <x>395</x>\n      <y>5</y>\n      <width>350</width>\n      <height>15</height>\n     </rect>\n     <bottompad>0</bottompad>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <top/>\n     <data>\n      <query>detail</query>\n      <column>location_descrip</column>\n     </data>\n    </text>\n    <line>\n     <xstart>5</xstart>\n     <ystart>0</ystart>\n     <xend>745</xend>\n     <yend>0</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>55</x>\n      <y>5</y>\n      <width>114</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>locationname</column>\n     </data>\n    </field>\n    <field>\n     <rect>\n      <x>170</x>\n      <y>5</y>\n      <width>50</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <data>\n      <query>detail</query>\n      <column>f_netable</column>\n     </data>\n    </field>\n   </head>\n  </group>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>18</height>\n   <field>\n    <rect>\n     <x>290</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>395</x>\n     <y>0</y>\n     <width>350</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemdesc</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>18</height>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n                0       2014-10-06 19:47:03.678943
102670
 
30      WarehouseMasterList     \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Warehouse Master List</title>\n <name>WarehouseMasterList</name>\n <description></description>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT warehous_code,\n       formatBoolYN(warehous_active) AS f_active,\n       warehous_descrip,\n       addr_line1 AS warehous_addr1,\n       addr_line2 AS warehous_addr2,\n       addr_line3 AS warehous_addr3,\n       (addr_city || ',' || addr_state || ' ' || addr_postalcode) AS warehous_addr4,\n       warehous_fob,\n       warehous_bol_prefix,\n       warehous_bol_number,\n       formatBoolYN(warehous_shipping) AS f_shipping,\n       warehous_counttag_prefix,\n       warehous_counttag_number,\n       formatBoolYN(warehous_useslips) as f_useslips\n  FROM site() JOIN addr ON (addr_id=warehous_addr_id)\nLEFT OUTER JOIN sitetype ON (sitetype_id=warehous_sitetype_id) \nWHERE ((TRUE)\n&lt;? if not exists("showInactive") ?>\n  AND (warehous_active) \n&lt;? endif ?>\n) ORDER BY warehous_code;</sql>\n </querysource>\n <querysource>\n  <name>head</name>\n  <sql>SELECT &lt;? if exists("showInactive") ?>\n         text('Showing Active and Inactive Warehouses')\n       &lt;? else ?>\n         text('Showing Active Warehouses')\n       &lt;? endif ?>\n       AS f_show;</sql>\n </querysource>\n <rpthead>\n  <height>61</height>\n  <line>\n   <xstart>5</xstart>\n   <ystart>55</ystart>\n   <xend>745</xend>\n   <yend>55</yend>\n   <weight>2</weight>\n  </line>\n  <field>\n   <rect>\n    <x>10</x>\n    <y>40</y>\n    <width>450</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>head</query>\n    <column>f_show</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>10</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Warehouse Master List</string>\n  </label>\n </rpthead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>151</height>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>110</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_shipping</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>145</ystart>\n    <xend>745</xend>\n    <yend>145</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>120</x>\n     <y>5</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>295</x>\n     <y>90</y>\n     <width>450</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_fob</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>350</x>\n     <y>110</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_bol_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>120</x>\n     <y>25</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_active</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>295</x>\n     <y>5</y>\n     <width>450</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_descrip</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>295</x>\n     <y>110</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_bol_prefix</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>457</x>\n     <y>125</y>\n     <width>150</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Force the use of Count Slips:</string>\n   </label>\n   <label>\n    <rect>\n     <x>180</x>\n     <y>110</y>\n     <width>110</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Next Bill of Lading #:</string>\n   </label>\n   <field>\n    <rect>\n     <x>295</x>\n     <y>125</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_counttag_prefix</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>180</x>\n     <y>125</y>\n     <width>110</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Next Count Tag #:</string>\n   </label>\n   <field>\n    <rect>\n     <x>295</x>\n     <y>70</y>\n     <width>450</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_addr4</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>215</x>\n     <y>5</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Description:</string>\n   </label>\n   <line>\n    <xstart>350</xstart>\n    <ystart>140</ystart>\n    <xend>450</xend>\n    <yend>140</yend>\n    <weight>0</weight>\n   </line>\n   <label>\n    <rect>\n     <x>65</x>\n     <y>25</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Active:</string>\n   </label>\n   <line>\n    <xstart>295</xstart>\n    <ystart>125</ystart>\n    <xend>345</xend>\n    <yend>125</yend>\n    <weight>0</weight>\n   </line>\n   <label>\n    <rect>\n     <x>202</x>\n     <y>90</y>\n     <width>85</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Default F.O.B.:</string>\n   </label>\n   <label>\n    <rect>\n     <x>215</x>\n     <y>25</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Address:</string>\n   </label>\n   <field>\n    <rect>\n     <x>350</x>\n     <y>125</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_counttag_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>350</xstart>\n    <ystart>125</ystart>\n    <xend>450</xend>\n    <yend>125</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>295</x>\n     <y>25</y>\n     <width>450</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_addr1</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>65</x>\n     <y>5</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Code:</string>\n   </label>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>125</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_useslips</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>295</x>\n     <y>55</y>\n     <width>450</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_addr3</column>\n    </data>\n   </field>\n   <label>\n    <rect>\n     <x>507</x>\n     <y>110</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <string>Shipping Whs.:</string>\n   </label>\n   <field>\n    <rect>\n     <x>295</x>\n     <y>40</y>\n     <width>450</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>warehous_addr2</column>\n    </data>\n   </field>\n   <line>\n    <xstart>295</xstart>\n    <ystart>140</ystart>\n    <xend>345</xend>\n    <yend>140</yend>\n    <weight>0</weight>\n   </line>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>95</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n               0       2014-10-06 19:47:03.678943
102671
 
457     Items   \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Items</title>\n <name>Items</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>detail</name>\n  <sql>SELECT\n       &lt;? if exists("ListNumericItemNumbersFirst") ?>\n         DISTINCT ON ( toNumeric(item_number, 999999999999999), item_number )\n       &lt;? else ?>\n         DISTINCT ON ( item_number )\n       &lt;? endif ?>\n       item_number,\n       item_descrip1,\n       item_descrip2,\n       formatBoolYN(item_active) AS active,\n       CASE WHEN (item_type='M') THEN 'Manufactured'\n            WHEN (item_type='P') THEN 'Purchased'\n            WHEN (item_type='F') THEN 'Phantom'\n            WHEN (item_type='B') THEN 'Breeder'\n            WHEN (item_type='C') THEN 'Co-Product'\n            WHEN (item_type='Y') THEN 'By-Product'\n            WHEN (item_type='R') THEN 'Reference'\n            WHEN (item_type='T') THEN 'Tooling'\n            WHEN (item_type='O') THEN 'Outside Process'\n            WHEN (item_type='J') THEN 'Job'\n            WHEN (item_type='K') THEN 'Kit'\n            WHEN (item_type='L') THEN 'Planning'\n            ELSE item_type\n       END AS itemtype,\n       iuom.uom_name AS invuom,\n       itemcapuom(item_id) AS capuom,\n       itemaltcapuom(item_id) AS altcapuom,\n       puom.uom_name AS priceuom,\n       puom.uom_name AS shipuom,\n       formatRatio(itemcapinvrat(item_id)) AS capratio,\n       formatRatio(itemaltcapinvrat(item_id)) AS altcapratio,\n       formatRatio(iteminvpricerat(item_id)) AS shipratio,\n       formatRatio(iteminvpricerat(item_id)) AS priceratio,\n       formatBoolYN(item_sold) AS sold,\n       formatBoolYN(item_exclusive) AS exclusive,\n       formatBoolYN(item_picklist) AS picklist,\n       formatBoolYN(item_config) AS configured,\n       formatWeight(item_prodweight) AS prodweight,\n       formatWeight(item_packweight) AS packweight,\n       classcode_code\nFROM item\n  JOIN classcode ON (item_classcode_id=classcode_id)\n  JOIN prodcat ON (item_prodcat_id=prodcat_id)\n  JOIN uom iuom ON (item_inv_uom_id=iuom.uom_id)\n  JOIN uom puom ON (item_price_uom_id=puom.uom_id)\n&lt;? if exists("itemgrp_id") ?>\n  JOIN itemgrpitem ON (item_id=itemgrpitem_item_id)\n  JOIN itemgrp ON (itemgrp_id=itemgrpitem_itemgrp_id)\n&lt;? endif ?>\n&lt;? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias&lt;? literal("char_id_text_list") ?> \n    ON ((charass_alias&lt;? literal("char_id_text_list") ?>.charass_target_type='I') \n    AND  (charass_alias&lt;? literal("char_id_text_list") ?>.charass_target_id=item_id)\n    AND  (charass_alias&lt;? literal("char_id_text_list") ?>.charass_char_id=&lt;? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias&lt;? literal("char_id_text_list") ?> \n    ON (charass_alias&lt;? literal("char_id_text_list") ?>.charass_char_id=char_alias&lt;? literal("char_id_text_list") ?>.char_id)\n&lt;? endforeach ?>\n&lt;? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias&lt;? literal("char_id_list_list") ?> \n    ON ((charass_alias&lt;? literal("char_id_list_list") ?>.charass_target_type='I') \n    AND  (charass_alias&lt;? literal("char_id_list_list") ?>.charass_target_id=item_id)\n    AND  (charass_alias&lt;? literal("char_id_list_list") ?>.charass_char_id=&lt;? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias&lt;? literal("char_id_list_list") ?> \n    ON (charass_alias&lt;? literal("char_id_list_list") ?>.charass_char_id=char_alias&lt;? literal("char_id_list_list") ?>.char_id)\n&lt;? endforeach ?>\n&lt;? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias&lt;? literal("char_id_date_list") ?> \n    ON ((charass_alias&lt;? literal("char_id_date_list") ?>.charass_target_type='I') \n    AND  (charass_alias&lt;? literal("char_id_date_list") ?>.charass_target_id=item_id)\n    AND  (charass_alias&lt;? literal("char_id_date_list") ?>.charass_char_id=&lt;? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias&lt;? literal("char_id_date_list") ?> \n    ON (charass_alias&lt;? literal("char_id_date_list") ?>.charass_char_id=char_alias&lt;? literal("char_id_date_list") ?>.char_id)\n&lt;? endforeach ?>\nWHERE ( true\n&lt;? if exists("search_pattern") ?>\n AND ( (item_number ~* &lt;? value("search_pattern") ?>)\n       OR  (item_descrip1 || item_descrip2 ~* &lt;? value("search_pattern") ?>) )\n&lt;? endif ?>\n&lt;? if exists("showPurchased") ?>\n AND (item_type IN ('P', 'O'))\n&lt;? elseif exists("showManufactured") ?>\n AND (item_type IN ('M', 'F', 'B','K'))\n&lt;? elseif exists("showSold") ?>\n AND (item_sold)\n&lt;? endif ?>\n&lt;? if exists("item_type") ?>\n AND (item_type=&lt;? value("item_type") ?>)\n&lt;? endif ?>\n&lt;? if not exists("showInactive") ?>\n AND (item_active)\n&lt;? endif ?>\n&lt;? if exists("classcode_id") ?>\n AND (item_classcode_id=&lt;? value("classcode_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("prodcat_id") ?>\n AND (item_prodcat_id=&lt;? value("prodcat_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("freightclass_id") ?>\n AND (item_freightclass_id=&lt;? value("freightclass_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("itemgrp_id") ?>\n AND (itemgrp_id=&lt;? value("itemgrp_id") ?>)\n&lt;? endif ?>\n&lt;? if exists("item_number_pattern") ?>\n AND (item_number ~* &lt;? value("item_number_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("item_descrip_pattern") ?>\n AND (item_descrip1 || item_descrip2 ~* &lt;? value("item_descrip_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("classcode_pattern") ?>\n AND (classcode_code ~* &lt;? value("classcode_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("prodcat_pattern") ?>\n AND (prodcat_code  ~* &lt;? value("prodcat_pattern") ?>)\n&lt;? endif ?>\n&lt;? if exists("freightclass_pattern") ?>\n AND (freightclass_code ~* &lt;? value("freightclass_pattern") ?>)\n&lt;? endif ?>\n&lt;? literal("charClause") ?>\n) ORDER BY\n&lt;? if exists("ListNumericItemNumbersFirst") ?>\n toNumeric(item_number, 999999999999999),\n&lt;? endif ?>\n item_number;</sql>\n </querysource>\n <rpthead>\n  <height>241</height>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>160</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>205</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Configured</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>203</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>160</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Packaging Weight</string>\n  </label>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>160</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>220</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipping UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>203</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>104</x>\n    <y>220</y>\n    <width>66</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Class Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>190</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Pick List</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>190</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Alt. Capacity/Inventory Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>220</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipping/Inventory Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>160</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inventory UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>190</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description 2</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>190</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Alt. Capacity UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>175</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Capacity/Inventory Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>175</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Capacity UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>175</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Exclusive</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>220</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>175</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Product Weight</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>175</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description 1</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>203</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price/Inventory Ratio</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>235</ystart>\n   <xend>745</xend>\n   <yend>235</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>385</x>\n    <y>5</y>\n    <width>356</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Items</string>\n  </label>\n  <text>\n   <rect>\n    <x>10</x>\n    <y>28</y>\n    <width>725</width>\n    <height>15</height>\n   </rect>\n   <bottompad>12</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>10</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>Parameter Query</query>\n    <column>filter</column>\n   </data>\n  </text>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>81</height>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>45</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Configured</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description 1</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>75</ystart>\n   <xend>745</xend>\n   <yend>75</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>15</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Capacity/Inventory Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>30</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description 2</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Inventory UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>45</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>60</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Active</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Capacity UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Number</string>\n  </label>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>15</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Exclusive</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>45</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Price/Inventory Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>30</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Alt. Capacity UOM</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>60</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipping/Inventory Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Packaging Weight</string>\n  </label>\n  <label>\n   <rect>\n    <x>400</x>\n    <y>30</y>\n    <width>150</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Alt. Capacity/Inventory Ratio</string>\n  </label>\n  <label>\n   <rect>\n    <x>640</x>\n    <y>15</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Product Weight</string>\n  </label>\n  <label>\n   <rect>\n    <x>104</x>\n    <y>60</y>\n    <width>66</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Class Code</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>45</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>30</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Pick List</string>\n  </label>\n  <label>\n   <rect>\n    <x>565</x>\n    <y>0</y>\n    <width>60</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Sold</string>\n  </label>\n  <label>\n   <rect>\n    <x>275</x>\n    <y>60</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Shipping UOM</string>\n  </label>\n </pghead>\n <section>\n  <name>unnamed</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>81</height>\n   <field>\n    <rect>\n     <x>565</x>\n     <y>30</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>picklist</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>15</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>565</x>\n     <y>15</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>exclusive</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>433</x>\n     <y>45</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>priceratio</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>45</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>itemtype</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>packweight</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>30</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip2</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>433</x>\n     <y>30</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>altcapratio</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>275</x>\n     <y>60</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>0</y>\n     <width>250</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <line>\n    <xstart>5</xstart>\n    <ystart>75</ystart>\n    <xend>745</xend>\n    <yend>75</yend>\n    <weight>0</weight>\n   </line>\n   <field>\n    <rect>\n     <x>565</x>\n     <y>0</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>sold</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>565</x>\n     <y>45</y>\n     <width>60</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>configured</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>275</x>\n     <y>45</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>priceuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>275</x>\n     <y>0</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>60</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>active</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>433</x>\n     <y>15</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>capratio</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>104</x>\n     <y>60</y>\n     <width>66</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>classcode_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>275</x>\n     <y>30</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>altcapuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>275</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>capuom</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>640</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prodweight</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>433</x>\n     <y>60</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>40</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>shipratio</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>635</x>\n    <y>0</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>80</x>\n    <y>0</y>\n    <width>140</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>715</x>\n    <y>0</y>\n    <width>30</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n </pgfoot>\n</report>\n           0       2014-10-06 19:47:03.678943
102672
 
\.
102673
 
 
102674
 
 
102675
 
--
102676
 
--
102677
 
 
102678
 
SELECT pg_catalog.setval('report_report_id_seq', 481, true);
102679
 
 
102680
 
 
102681
 
--
102682
 
--
102683
 
 
102684
 
COPY rjctcode (rjctcode_id, rjctcode_code, rjctcode_descrip) FROM stdin;
102685
 
\.
102686
 
 
102687
 
 
102688
 
--
102689
 
--
102690
 
 
102691
 
SELECT pg_catalog.setval('rjctcode_rjctcode_id_seq', 16, true);
102692
 
 
102693
 
 
102694
 
--
102695
 
--
102696
 
 
102697
 
COPY rsncode (rsncode_id, rsncode_code, rsncode_descrip, rsncode_doctype) FROM stdin;
102698
 
\.
102699
 
 
102700
 
 
102701
 
--
102702
 
--
102703
 
 
102704
 
SELECT pg_catalog.setval('rsncode_rsncode_id_seq', 1, false);
102705
 
 
102706
 
 
102707
 
--
102708
 
--
102709
 
 
102710
 
COPY sale (sale_id, sale_name, sale_descrip, sale_ipshead_id, sale_startdate, sale_enddate) FROM stdin;
102711
 
\.
102712
 
 
102713
 
 
102714
 
--
102715
 
--
102716
 
 
102717
 
SELECT pg_catalog.setval('sale_sale_id_seq', 12, true);
102718
 
 
102719
 
 
102720
 
--
102721
 
--
102722
 
 
102723
 
COPY salesaccnt (salesaccnt_id, salesaccnt_custtype_id, salesaccnt_prodcat_id, salesaccnt_warehous_id, salesaccnt_sales_accnt_id, salesaccnt_credit_accnt_id, salesaccnt_cos_accnt_id, salesaccnt_custtype, salesaccnt_prodcat, salesaccnt_returns_accnt_id, salesaccnt_cor_accnt_id, salesaccnt_cow_accnt_id, salesaccnt_saletype_id, salesaccnt_shipzone_id) FROM stdin;
102724
 
\.
102725
 
 
102726
 
 
102727
 
--
102728
 
--
102729
 
 
102730
 
SELECT pg_catalog.setval('salesaccnt_salesaccnt_id_seq', 30, true);
102731
 
 
102732
 
 
102733
 
--
102734
 
--
102735
 
 
102736
 
COPY salescat (salescat_id, salescat_active, salescat_name, salescat_descrip, salescat_sales_accnt_id, salescat_prepaid_accnt_id, salescat_ar_accnt_id) FROM stdin;
102737
 
\.
102738
 
 
102739
 
 
102740
 
--
102741
 
--
102742
 
 
102743
 
SELECT pg_catalog.setval('salescat_salescat_id_seq', 1, false);
102744
 
 
102745
 
 
102746
 
--
102747
 
--
102748
 
 
102749
 
COPY salesrep (salesrep_id, salesrep_active, salesrep_number, salesrep_name, salesrep_commission, salesrep_method, salesrep_emp_id) FROM stdin;
102750
 
\.
102751
 
 
102752
 
 
102753
 
--
102754
 
--
102755
 
 
102756
 
SELECT pg_catalog.setval('salesrep_salesrep_id_seq', 28, true);
102757
 
 
102758
 
 
102759
 
--
102760
 
--
102761
 
 
102762
 
COPY saletype (saletype_id, saletype_code, saletype_descr, saletype_active) FROM stdin;
102763
 
1       CUST    Customer        t
102764
 
2       INT     Internet        t
102765
 
3       REP     Sales Rep       t
102766
 
\.
102767
 
 
102768
 
 
102769
 
--
102770
 
--
102771
 
 
102772
 
SELECT pg_catalog.setval('saletype_saletype_id_seq', 3, true);
102773
 
 
102774
 
 
102775
 
--
102776
 
--
102777
 
 
102778
 
COPY schemaord (schemaord_id, schemaord_name, schemaord_order) FROM stdin;
102779
 
\.
102780
 
 
102781
 
 
102782
 
--
102783
 
--
102784
 
 
102785
 
SELECT pg_catalog.setval('schemaord_schemaord_id_seq', 1, false);
102786
 
 
102787
 
 
102788
 
--
102789
 
--
102790
 
 
102791
 
COPY script (script_id, script_name, script_order, script_enabled, script_source, script_notes) FROM stdin;
102792
 
1       storedProcErrorLookup   0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2009 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\n/* This simplified version of xtuple/common/storedProcErrorLookup.cpp takes\n   an error structure, allowing packages to define their own errors.\n*/\nfunction storedProcErrorLookup(procName, returnVal, errorStruct)\n{\n  var message;\n\n  if (null != errorStruct)\n  {\n    if (procName in errorStruct &&\n      returnVal in errorStruct[procName])\n      message =  errorStruct[procName][returnVal];\n    else\n    {\n      procName = procName.toLowerCase();\n      for (var tmpProcName in errorStruct)\n        if (procName == tmpProcName.toLowerCase())\n        {\n          message = errorStruct[tmpProcName][returnVal];\n          break;\n        }\n    }\n\n    if (message != null)\n      return "<p>" + message\n           + qsTr("<br>(%1, %2)<br>").arg(procName).arg(returnVal);\n  }\n\n  return toolbox.storedProcErrorLookup(procName, returnVal);\n}\n     this scripted version of the error lookup routine allows packages to define their own messages
102793
 
\.
102794
 
 
102795
 
 
102796
 
--
102797
 
--
102798
 
 
102799
 
SELECT pg_catalog.setval('script_script_id_seq', 132, true);
102800
 
 
102801
 
 
102802
 
--
102803
 
--
102804
 
 
102805
 
COPY sequence (sequence_value) FROM stdin;
102806
 
1
102807
 
2
102808
 
3
102809
 
4
102810
 
5
102811
 
6
102812
 
7
102813
 
8
102814
 
9
102815
 
10
102816
 
11
102817
 
12
102818
 
13
102819
 
14
102820
 
15
102821
 
16
102822
 
17
102823
 
18
102824
 
19
102825
 
20
102826
 
21
102827
 
22
102828
 
23
102829
 
24
102830
 
25
102831
 
26
102832
 
27
102833
 
28
102834
 
29
102835
 
30
102836
 
31
102837
 
32
102838
 
33
102839
 
34
102840
 
35
102841
 
36
102842
 
37
102843
 
38
102844
 
39
102845
 
40
102846
 
41
102847
 
42
102848
 
43
102849
 
44
102850
 
45
102851
 
46
102852
 
47
102853
 
48
102854
 
49
102855
 
50
102856
 
51
102857
 
52
102858
 
53
102859
 
54
102860
 
55
102861
 
56
102862
 
57
102863
 
58
102864
 
59
102865
 
60
102866
 
61
102867
 
62
102868
 
63
102869
 
64
102870
 
65
102871
 
66
102872
 
67
102873
 
68
102874
 
69
102875
 
70
102876
 
71
102877
 
72
102878
 
73
102879
 
74
102880
 
75
102881
 
76
102882
 
77
102883
 
78
102884
 
79
102885
 
80
102886
 
81
102887
 
82
102888
 
83
102889
 
84
102890
 
85
102891
 
86
102892
 
87
102893
 
88
102894
 
89
102895
 
90
102896
 
91
102897
 
92
102898
 
93
102899
 
94
102900
 
95
102901
 
96
102902
 
97
102903
 
98
102904
 
99
102905
 
100
102906
 
101
102907
 
102
102908
 
103
102909
 
104
102910
 
105
102911
 
106
102912
 
107
102913
 
108
102914
 
109
102915
 
110
102916
 
111
102917
 
112
102918
 
113
102919
 
114
102920
 
115
102921
 
116
102922
 
117
102923
 
118
102924
 
119
102925
 
120
102926
 
121
102927
 
122
102928
 
123
102929
 
124
102930
 
125
102931
 
126
102932
 
127
102933
 
128
102934
 
129
102935
 
130
102936
 
131
102937
 
132
102938
 
133
102939
 
134
102940
 
135
102941
 
136
102942
 
137
102943
 
138
102944
 
139
102945
 
140
102946
 
141
102947
 
142
102948
 
143
102949
 
144
102950
 
145
102951
 
146
102952
 
147
102953
 
148
102954
 
149
102955
 
150
102956
 
151
102957
 
152
102958
 
153
102959
 
154
102960
 
155
102961
 
156
102962
 
157
102963
 
158
102964
 
159
102965
 
160
102966
 
161
102967
 
162
102968
 
163
102969
 
164
102970
 
165
102971
 
166
102972
 
167
102973
 
168
102974
 
169
102975
 
170
102976
 
171
102977
 
172
102978
 
173
102979
 
174
102980
 
175
102981
 
176
102982
 
177
102983
 
178
102984
 
179
102985
 
180
102986
 
181
102987
 
182
102988
 
183
102989
 
184
102990
 
185
102991
 
186
102992
 
187
102993
 
188
102994
 
189
102995
 
190
102996
 
191
102997
 
192
102998
 
193
102999
 
194
103000
 
195
103001
 
196
103002
 
197
103003
 
198
103004
 
199
103005
 
200
103006
 
201
103007
 
202
103008
 
203
103009
 
204
103010
 
205
103011
 
206
103012
 
207
103013
 
208
103014
 
209
103015
 
210
103016
 
211
103017
 
212
103018
 
213
103019
 
214
103020
 
215
103021
 
216
103022
 
217
103023
 
218
103024
 
219
103025
 
220
103026
 
221
103027
 
222
103028
 
223
103029
 
224
103030
 
225
103031
 
226
103032
 
227
103033
 
228
103034
 
229
103035
 
230
103036
 
231
103037
 
232
103038
 
233
103039
 
234
103040
 
235
103041
 
236
103042
 
237
103043
 
238
103044
 
239
103045
 
240
103046
 
241
103047
 
242
103048
 
243
103049
 
244
103050
 
245
103051
 
246
103052
 
247
103053
 
248
103054
 
249
103055
 
250
103056
 
251
103057
 
252
103058
 
253
103059
 
254
103060
 
255
103061
 
256
103062
 
257
103063
 
258
103064
 
259
103065
 
260
103066
 
261
103067
 
262
103068
 
263
103069
 
264
103070
 
265
103071
 
266
103072
 
267
103073
 
268
103074
 
269
103075
 
270
103076
 
271
103077
 
272
103078
 
273
103079
 
274
103080
 
275
103081
 
276
103082
 
277
103083
 
278
103084
 
279
103085
 
280
103086
 
281
103087
 
282
103088
 
283
103089
 
284
103090
 
285
103091
 
286
103092
 
287
103093
 
288
103094
 
289
103095
 
290
103096
 
291
103097
 
292
103098
 
293
103099
 
294
103100
 
295
103101
 
296
103102
 
297
103103
 
298
103104
 
299
103105
 
300
103106
 
301
103107
 
302
103108
 
303
103109
 
304
103110
 
305
103111
 
306
103112
 
307
103113
 
308
103114
 
309
103115
 
310
103116
 
311
103117
 
312
103118
 
313
103119
 
314
103120
 
315
103121
 
316
103122
 
317
103123
 
318
103124
 
319
103125
 
320
103126
 
321
103127
 
322
103128
 
323
103129
 
324
103130
 
325
103131
 
326
103132
 
327
103133
 
328
103134
 
329
103135
 
330
103136
 
331
103137
 
332
103138
 
333
103139
 
334
103140
 
335
103141
 
336
103142
 
337
103143
 
338
103144
 
339
103145
 
340
103146
 
341
103147
 
342
103148
 
343
103149
 
344
103150
 
345
103151
 
346
103152
 
347
103153
 
348
103154
 
349
103155
 
350
103156
 
351
103157
 
352
103158
 
353
103159
 
354
103160
 
355
103161
 
356
103162
 
357
103163
 
358
103164
 
359
103165
 
360
103166
 
361
103167
 
362
103168
 
363
103169
 
364
103170
 
365
103171
 
366
103172
 
367
103173
 
368
103174
 
369
103175
 
370
103176
 
371
103177
 
372
103178
 
373
103179
 
374
103180
 
375
103181
 
376
103182
 
377
103183
 
378
103184
 
379
103185
 
380
103186
 
381
103187
 
382
103188
 
383
103189
 
384
103190
 
385
103191
 
386
103192
 
387
103193
 
388
103194
 
389
103195
 
390
103196
 
391
103197
 
392
103198
 
393
103199
 
394
103200
 
395
103201
 
396
103202
 
397
103203
 
398
103204
 
399
103205
 
400
103206
 
401
103207
 
402
103208
 
403
103209
 
404
103210
 
405
103211
 
406
103212
 
407
103213
 
408
103214
 
409
103215
 
410
103216
 
411
103217
 
412
103218
 
413
103219
 
414
103220
 
415
103221
 
416
103222
 
417
103223
 
418
103224
 
419
103225
 
420
103226
 
421
103227
 
422
103228
 
423
103229
 
424
103230
 
425
103231
 
426
103232
 
427
103233
 
428
103234
 
429
103235
 
430
103236
 
431
103237
 
432
103238
 
433
103239
 
434
103240
 
435
103241
 
436
103242
 
437
103243
 
438
103244
 
439
103245
 
440
103246
 
441
103247
 
442
103248
 
443
103249
 
444
103250
 
445
103251
 
446
103252
 
447
103253
 
448
103254
 
449
103255
 
450
103256
 
451
103257
 
452
103258
 
453
103259
 
454
103260
 
455
103261
 
456
103262
 
457
103263
 
458
103264
 
459
103265
 
460
103266
 
461
103267
 
462
103268
 
463
103269
 
464
103270
 
465
103271
 
466
103272
 
467
103273
 
468
103274
 
469
103275
 
470
103276
 
471
103277
 
472
103278
 
473
103279
 
474
103280
 
475
103281
 
476
103282
 
477
103283
 
478
103284
 
479
103285
 
480
103286
 
481
103287
 
482
103288
 
483
103289
 
484
103290
 
485
103291
 
486
103292
 
487
103293
 
488
103294
 
489
103295
 
490
103296
 
491
103297
 
492
103298
 
493
103299
 
494
103300
 
495
103301
 
496
103302
 
497
103303
 
498
103304
 
499
103305
 
500
103306
 
501
103307
 
502
103308
 
503
103309
 
504
103310
 
505
103311
 
506
103312
 
507
103313
 
508
103314
 
509
103315
 
510
103316
 
511
103317
 
512
103318
 
513
103319
 
514
103320
 
515
103321
 
516
103322
 
517
103323
 
518
103324
 
519
103325
 
520
103326
 
521
103327
 
522
103328
 
523
103329
 
524
103330
 
525
103331
 
526
103332
 
527
103333
 
528
103334
 
529
103335
 
530
103336
 
531
103337
 
532
103338
 
533
103339
 
534
103340
 
535
103341
 
536
103342
 
537
103343
 
538
103344
 
539
103345
 
540
103346
 
541
103347
 
542
103348
 
543
103349
 
544
103350
 
545
103351
 
546
103352
 
547
103353
 
548
103354
 
549
103355
 
550
103356
 
551
103357
 
552
103358
 
553
103359
 
554
103360
 
555
103361
 
556
103362
 
557
103363
 
558
103364
 
559
103365
 
560
103366
 
561
103367
 
562
103368
 
563
103369
 
564
103370
 
565
103371
 
566
103372
 
567
103373
 
568
103374
 
569
103375
 
570
103376
 
571
103377
 
572
103378
 
573
103379
 
574
103380
 
575
103381
 
576
103382
 
577
103383
 
578
103384
 
579
103385
 
580
103386
 
581
103387
 
582
103388
 
583
103389
 
584
103390
 
585
103391
 
586
103392
 
587
103393
 
588
103394
 
589
103395
 
590
103396
 
591
103397
 
592
103398
 
593
103399
 
594
103400
 
595
103401
 
596
103402
 
597
103403
 
598
103404
 
599
103405
 
600
103406
 
601
103407
 
602
103408
 
603
103409
 
604
103410
 
605
103411
 
606
103412
 
607
103413
 
608
103414
 
609
103415
 
610
103416
 
611
103417
 
612
103418
 
613
103419
 
614
103420
 
615
103421
 
616
103422
 
617
103423
 
618
103424
 
619
103425
 
620
103426
 
621
103427
 
622
103428
 
623
103429
 
624
103430
 
625
103431
 
626
103432
 
627
103433
 
628
103434
 
629
103435
 
630
103436
 
631
103437
 
632
103438
 
633
103439
 
634
103440
 
635
103441
 
636
103442
 
637
103443
 
638
103444
 
639
103445
 
640
103446
 
641
103447
 
642
103448
 
643
103449
 
644
103450
 
645
103451
 
646
103452
 
647
103453
 
648
103454
 
649
103455
 
650
103456
 
651
103457
 
652
103458
 
653
103459
 
654
103460
 
655
103461
 
656
103462
 
657
103463
 
658
103464
 
659
103465
 
660
103466
 
661
103467
 
662
103468
 
663
103469
 
664
103470
 
665
103471
 
666
103472
 
667
103473
 
668
103474
 
669
103475
 
670
103476
 
671
103477
 
672
103478
 
673
103479
 
674
103480
 
675
103481
 
676
103482
 
677
103483
 
678
103484
 
679
103485
 
680
103486
 
681
103487
 
682
103488
 
683
103489
 
684
103490
 
685
103491
 
686
103492
 
687
103493
 
688
103494
 
689
103495
 
690
103496
 
691
103497
 
692
103498
 
693
103499
 
694
103500
 
695
103501
 
696
103502
 
697
103503
 
698
103504
 
699
103505
 
700
103506
 
701
103507
 
702
103508
 
703
103509
 
704
103510
 
705
103511
 
706
103512
 
707
103513
 
708
103514
 
709
103515
 
710
103516
 
711
103517
 
712
103518
 
713
103519
 
714
103520
 
715
103521
 
716
103522
 
717
103523
 
718
103524
 
719
103525
 
720
103526
 
721
103527
 
722
103528
 
723
103529
 
724
103530
 
725
103531
 
726
103532
 
727
103533
 
728
103534
 
729
103535
 
730
103536
 
731
103537
 
732
103538
 
733
103539
 
734
103540
 
735
103541
 
736
103542
 
737
103543
 
738
103544
 
739
103545
 
740
103546
 
741
103547
 
742
103548
 
743
103549
 
744
103550
 
745
103551
 
746
103552
 
747
103553
 
748
103554
 
749
103555
 
750
103556
 
751
103557
 
752
103558
 
753
103559
 
754
103560
 
755
103561
 
756
103562
 
757
103563
 
758
103564
 
759
103565
 
760
103566
 
761
103567
 
762
103568
 
763
103569
 
764
103570
 
765
103571
 
766
103572
 
767
103573
 
768
103574
 
769
103575
 
770
103576
 
771
103577
 
772
103578
 
773
103579
 
774
103580
 
775
103581
 
776
103582
 
777
103583
 
778
103584
 
779
103585
 
780
103586
 
781
103587
 
782
103588
 
783
103589
 
784
103590
 
785
103591
 
786
103592
 
787
103593
 
788
103594
 
789
103595
 
790
103596
 
791
103597
 
792
103598
 
793
103599
 
794
103600
 
795
103601
 
796
103602
 
797
103603
 
798
103604
 
799
103605
 
800
103606
 
801
103607
 
802
103608
 
803
103609
 
804
103610
 
805
103611
 
806
103612
 
807
103613
 
808
103614
 
809
103615
 
810
103616
 
811
103617
 
812
103618
 
813
103619
 
814
103620
 
815
103621
 
816
103622
 
817
103623
 
818
103624
 
819
103625
 
820
103626
 
821
103627
 
822
103628
 
823
103629
 
824
103630
 
825
103631
 
826
103632
 
827
103633
 
828
103634
 
829
103635
 
830
103636
 
831
103637
 
832
103638
 
833
103639
 
834
103640
 
835
103641
 
836
103642
 
837
103643
 
838
103644
 
839
103645
 
840
103646
 
841
103647
 
842
103648
 
843
103649
 
844
103650
 
845
103651
 
846
103652
 
847
103653
 
848
103654
 
849
103655
 
850
103656
 
851
103657
 
852
103658
 
853
103659
 
854
103660
 
855
103661
 
856
103662
 
857
103663
 
858
103664
 
859
103665
 
860
103666
 
861
103667
 
862
103668
 
863
103669
 
864
103670
 
865
103671
 
866
103672
 
867
103673
 
868
103674
 
869
103675
 
870
103676
 
871
103677
 
872
103678
 
873
103679
 
874
103680
 
875
103681
 
876
103682
 
877
103683
 
878
103684
 
879
103685
 
880
103686
 
881
103687
 
882
103688
 
883
103689
 
884
103690
 
885
103691
 
886
103692
 
887
103693
 
888
103694
 
889
103695
 
890
103696
 
891
103697
 
892
103698
 
893
103699
 
894
103700
 
895
103701
 
896
103702
 
897
103703
 
898
103704
 
899
103705
 
900
103706
 
901
103707
 
902
103708
 
903
103709
 
904
103710
 
905
103711
 
906
103712
 
907
103713
 
908
103714
 
909
103715
 
910
103716
 
911
103717
 
912
103718
 
913
103719
 
914
103720
 
915
103721
 
916
103722
 
917
103723
 
918
103724
 
919
103725
 
920
103726
 
921
103727
 
922
103728
 
923
103729
 
924
103730
 
925
103731
 
926
103732
 
927
103733
 
928
103734
 
929
103735
 
930
103736
 
931
103737
 
932
103738
 
933
103739
 
934
103740
 
935
103741
 
936
103742
 
937
103743
 
938
103744
 
939
103745
 
940
103746
 
941
103747
 
942
103748
 
943
103749
 
944
103750
 
945
103751
 
946
103752
 
947
103753
 
948
103754
 
949
103755
 
950
103756
 
951
103757
 
952
103758
 
953
103759
 
954
103760
 
955
103761
 
956
103762
 
957
103763
 
958
103764
 
959
103765
 
960
103766
 
961
103767
 
962
103768
 
963
103769
 
964
103770
 
965
103771
 
966
103772
 
967
103773
 
968
103774
 
969
103775
 
970
103776
 
971
103777
 
972
103778
 
973
103779
 
974
103780
 
975
103781
 
976
103782
 
977
103783
 
978
103784
 
979
103785
 
980
103786
 
981
103787
 
982
103788
 
983
103789
 
984
103790
 
985
103791
 
986
103792
 
987
103793
 
988
103794
 
989
103795
 
990
103796
 
991
103797
 
992
103798
 
993
103799
 
994
103800
 
995
103801
 
996
103802
 
997
103803
 
998
103804
 
999
103805
 
1000
103806
 
\.
103807
 
 
103808
 
 
103809
 
--
103810
 
--
103811
 
 
103812
 
COPY shift (shift_id, shift_number, shift_name) FROM stdin;
103813
 
\.
103814
 
 
103815
 
 
103816
 
--
103817
 
--
103818
 
 
103819
 
SELECT pg_catalog.setval('shift_shift_id_seq', 1, false);
103820
 
 
103821
 
 
103822
 
--
103823
 
--
103824
 
 
103825
 
COPY shipchrg (shipchrg_id, shipchrg_name, shipchrg_descrip, shipchrg_custfreight, shipchrg_handling) FROM stdin;
103826
 
\.
103827
 
 
103828
 
 
103829
 
--
103830
 
--
103831
 
 
103832
 
SELECT pg_catalog.setval('shipchrg_shipchrg_id_seq', 2, true);
103833
 
 
103834
 
 
103835
 
--
103836
 
--
103837
 
 
103838
 
COPY shipdata (shipdata_cohead_number, shipdata_cosmisc_tracknum, shipdata_cosmisc_packnum_tracknum, shipdata_weight, shipdata_base_freight, shipdata_total_freight, shipdata_shipper, shipdata_billing_option, shipdata_package_type, shipdata_void_ind, shipdata_lastupdated, shipdata_shiphead_number, shipdata_base_freight_curr_id, shipdata_total_freight_curr_id) FROM stdin;
103839
 
\.
103840
 
 
103841
 
 
103842
 
--
103843
 
--
103844
 
 
103845
 
COPY shipdatasum (shipdatasum_cohead_number, shipdatasum_cosmisc_tracknum, shipdatasum_cosmisc_packnum_tracknum, shipdatasum_weight, shipdatasum_base_freight, shipdatasum_total_freight, shipdatasum_shipper, shipdatasum_billing_option, shipdatasum_package_type, shipdatasum_lastupdated, shipdatasum_shipped, shipdatasum_shiphead_number, shipdatasum_base_freight_curr_id, shipdatasum_total_freight_curr_id) FROM stdin;
103846
 
\.
103847
 
 
103848
 
 
103849
 
--
103850
 
--
103851
 
 
103852
 
COPY shipform (shipform_id, shipform_name, shipform_report_id, shipform_report_name) FROM stdin;
103853
 
\.
103854
 
 
103855
 
 
103856
 
--
103857
 
--
103858
 
 
103859
 
SELECT pg_catalog.setval('shipform_shipform_id_seq', 11, true);
103860
 
 
103861
 
 
103862
 
--
103863
 
--
103864
 
 
103865
 
COPY shiphead (shiphead_id, shiphead_order_id, shiphead_order_type, shiphead_number, shiphead_shipvia, shiphead_freight, shiphead_freight_curr_id, shiphead_notes, shiphead_shipped, shiphead_shipdate, shiphead_shipchrg_id, shiphead_shipform_id, shiphead_sfstatus, shiphead_tracknum) FROM stdin;
103866
 
\.
103867
 
 
103868
 
 
103869
 
--
103870
 
--
103871
 
 
103872
 
SELECT pg_catalog.setval('shiphead_shiphead_id_seq', 1, false);
103873
 
 
103874
 
 
103875
 
--
103876
 
--
103877
 
 
103878
 
COPY shipitem (shipitem_id, shipitem_orderitem_id, shipitem_shiphead_id, shipitem_qty, shipitem_shipped, shipitem_shipdate, shipitem_transdate, shipitem_trans_username, shipitem_invoiced, shipitem_invcitem_id, shipitem_value, shipitem_invhist_id) FROM stdin;
103879
 
\.
103880
 
 
103881
 
 
103882
 
--
103883
 
--
103884
 
 
103885
 
SELECT pg_catalog.setval('shipitem_shipitem_id_seq', 1, false);
103886
 
 
103887
 
 
103888
 
--
103889
 
--
103890
 
 
103891
 
SELECT pg_catalog.setval('shipment_number_seq', 1, true);
103892
 
 
103893
 
 
103894
 
--
103895
 
--
103896
 
 
103897
 
SELECT pg_catalog.setval('shipto_shipto_id_seq', 30, true);
103898
 
 
103899
 
 
103900
 
--
103901
 
--
103902
 
 
103903
 
COPY shiptoinfo (shipto_id, shipto_cust_id, shipto_name, shipto_salesrep_id, shipto_comments, shipto_shipcomments, shipto_shipzone_id, shipto_shipvia, shipto_commission, shipto_shipform_id, shipto_shipchrg_id, shipto_active, shipto_default, shipto_num, shipto_ediprofile_id, shipto_cntct_id, shipto_addr_id, shipto_taxzone_id, shipto_preferred_warehous_id) FROM stdin;
103904
 
\.
103905
 
 
103906
 
 
103907
 
--
103908
 
--
103909
 
 
103910
 
COPY shipvia (shipvia_id, shipvia_code, shipvia_descrip) FROM stdin;
103911
 
\.
103912
 
 
103913
 
 
103914
 
--
103915
 
--
103916
 
 
103917
 
SELECT pg_catalog.setval('shipvia_shipvia_id_seq', 12, true);
103918
 
 
103919
 
 
103920
 
--
103921
 
--
103922
 
 
103923
 
COPY shipzone (shipzone_id, shipzone_name, shipzone_descrip) FROM stdin;
103924
 
\.
103925
 
 
103926
 
 
103927
 
--
103928
 
--
103929
 
 
103930
 
SELECT pg_catalog.setval('shipzone_shipzone_id_seq', 34, true);
103931
 
 
103932
 
 
103933
 
--
103934
 
--
103935
 
 
103936
 
COPY sitetype (sitetype_id, sitetype_name, sitetype_descrip) FROM stdin;
103937
 
1       WHSE    Warehouse
103938
 
\.
103939
 
 
103940
 
 
103941
 
--
103942
 
--
103943
 
 
103944
 
SELECT pg_catalog.setval('sitetype_sitetype_id_seq', 1, true);
103945
 
 
103946
 
 
103947
 
--
103948
 
--
103949
 
 
103950
 
COPY sltrans (sltrans_id, sltrans_created, sltrans_date, sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_docnumber, sltrans_misc_id, sltrans_amount, sltrans_notes, sltrans_journalnumber, sltrans_posted, sltrans_doctype, sltrans_username, sltrans_gltrans_journalnumber, sltrans_rec) FROM stdin;
103951
 
\.
103952
 
 
103953
 
 
103954
 
--
103955
 
--
103956
 
 
103957
 
COPY sltrans_backup (sltrans_old_id, sltrans_new_id) FROM stdin;
103958
 
\.
103959
 
 
103960
 
 
103961
 
--
103962
 
--
103963
 
 
103964
 
SELECT pg_catalog.setval('sopack_sopack_id_seq', 60, true);
103965
 
 
103966
 
 
103967
 
--
103968
 
--
103969
 
 
103970
 
COPY source (source_id, source_module, source_name, source_descrip) FROM stdin;
103971
 
1       CRM     ADDR    Address
103972
 
2       Products        BBH     Breeder Bill of Materials
103973
 
3       Products        BBI     Breeder Bill of Materials Item
103974
 
4       Products        BMH     Bill of Materials
103975
 
5       Products        BMI     Bill of Materials Item
103976
 
6       Products        BOH     Bill of Operations
103977
 
7       Products        BOI     Bill of Operations Item
103978
 
8       CRM     CRMA    CRM Account
103979
 
9       CRM     T       Contact
103980
 
10      Sales   C       Customer
103981
 
11      System  EMP     Employee
103982
 
12      CRM     INCDT   Incident
103983
 
13      Products        I       Item
103984
 
14      Inventory       IS      Item Site
103985
 
15      Purchase        IR      Item Source
103986
 
16      Inventory       L       Location
103987
 
17      Inventory       LS      Lot Serial
103988
 
18      CRM     OPP     Opportunity
103989
 
19      CRM     J       Project
103990
 
20      Purchase        P       Purchase Order
103991
 
21      Purchase        PI      Purchase Order Item
103992
 
22      Sales   RA      Return Authorization
103993
 
23      Sales   RI      Return Authorization Item
103994
 
24      Sales   Q       Quote
103995
 
25      Sales   QI      Quote Item
103996
 
26      Sales   S       Sales Order
103997
 
27      Sales   SI      Sales Order Item
103998
 
28      Inventory       TO      Transfer Order
103999
 
29      Inventory       TI      Transfer Order Item
104000
 
30      Purchase        V       Vendor
104001
 
31      Inventory       WH      Site
104002
 
32      Manufacture     W       Work Order
104003
 
33      CRM     TD      Todo Item
104004
 
34      CRM     TA      Tasks
104005
 
35      CRM     PSPCT   Prospect
104006
 
36      Sales   SR      Sales Rep
104007
 
37      Accounting      TAXAUTH Tax Authority
104008
 
38      System  USR     User
104009
 
\.
104010
 
 
104011
 
 
104012
 
--
104013
 
--
104014
 
 
104015
 
SELECT pg_catalog.setval('source_source_id_seq', 38, true);
104016
 
 
104017
 
 
104018
 
--
104019
 
--
104020
 
 
104021
 
COPY state (state_id, state_name, state_abbr, state_country_id) FROM stdin;
104022
 
1       Alabama AL      230
104023
 
2       Alaska  AK      230
104024
 
3       American Samoa  AS      230
104025
 
4       Arizona AZ      230
104026
 
5       Arkansas        AR      230
104027
 
6       California      CA      230
104028
 
7       Colorado        CO      230
104029
 
8       Connecticut     CT      230
104030
 
9       Delaware        DE      230
104031
 
10      District Of Columbia    DC      230
104032
 
11      Federated States Of Micronesia  FM      230
104033
 
12      Florida FL      230
104034
 
13      Georgia GA      230
104035
 
14      Guam    GU      230
104036
 
15      Hawaii  HI      230
104037
 
16      Idaho   ID      230
104038
 
17      Illinois        IL      230
104039
 
18      Indiana IN      230
104040
 
19      Iowa    IA      230
104041
 
20      Kansas  KS      230
104042
 
21      Kentucky        KY      230
104043
 
22      Louisiana       LA      230
104044
 
23      Maine   ME      230
104045
 
24      Marshall Islands        MH      230
104046
 
25      Maryland        MD      230
104047
 
26      Massachusetts   MA      230
104048
 
27      Michigan        MI      230
104049
 
28      Minnesota       MN      230
104050
 
29      Mississippi     MS      230
104051
 
30      Missouri        MO      230
104052
 
31      Montana MT      230
104053
 
32      Nebraska        NE      230
104054
 
33      Nevada  NV      230
104055
 
34      New Hampshire   NH      230
104056
 
35      New Jersey      NJ      230
104057
 
36      New Mexico      NM      230
104058
 
37      New York        NY      230
104059
 
38      North Carolina  NC      230
104060
 
39      North Dakota    ND      230
104061
 
40      Northern Mariana Islands        MP      230
104062
 
41      Ohio    OH      230
104063
 
42      Oklahoma        OK      230
104064
 
43      Oregon  OR      230
104065
 
44      Palau   PW      230
104066
 
45      Pennsylvania    PA      230
104067
 
46      Puerto Rico     PR      230
104068
 
47      Rhode Island    RI      230
104069
 
48      South Carolina  SC      230
104070
 
49      South Dakota    SD      230
104071
 
50      Tennessee       TN      230
104072
 
51      Texas   TX      230
104073
 
52      Utah    UT      230
104074
 
53      Vermont VT      230
104075
 
54      Virgin Islands  VI      230
104076
 
55      Virginia        VA      230
104077
 
56      Washington      WA      230
104078
 
57      West Virginia   WV      230
104079
 
58      Wisconsin       WI      230
104080
 
59      Wyoming WY      230
104081
 
60      Armed Forces Africa, Canada, Europe, Middle East        AE      230
104082
 
61      Armed Forces Americas (except Canada)   AA      230
104083
 
62      Armed Forces Pacific    AP      230
104084
 
63      Alberta AB      39
104085
 
64      British Columbia        BC      39
104086
 
65      Manitoba        MB      39
104087
 
66      New Brunswick   NB      39
104088
 
67      Newfoundland and Labrador       NL      39
104089
 
68      Northwest Territories   NT      39
104090
 
69      Nova Scotia     NS      39
104091
 
70      Nunavut NU      39
104092
 
71      Ontario ON      39
104093
 
72      Prince Edward Island    PE      39
104094
 
73      Quebec  QC      39
104095
 
74      Saskatchewan    SK      39
104096
 
75      Yukon   YT      39
104097
 
76      Aguascalientes  AGS     140
104098
 
77      Baja California BC      140
104099
 
78      Baja California Sur     BCS     140
104100
 
79      Campeche        CAM     140
104101
 
80      Coahuila        COAH    140
104102
 
81      Colima  COL     140
104103
 
82      Chiapas CHIS    140
104104
 
83      Chihuahua       CHIH    140
104105
 
84      Distrito Federal        DF      140
104106
 
85      Durango DGO     140
104107
 
86      Guanajuato      GTO     140
104108
 
87      Guerrero        GRO     140
104109
 
88      Hidalgo HGO     140
104110
 
89      Jalisco JAL     140
104111
 
90      Mexico  MEX     140
104112
 
91      Michoacan       MICH    140
104113
 
92      Morelos MOR     140
104114
 
93      Nayarit NAY     140
104115
 
94      Nuevo Leon      NL      140
104116
 
95      Oaxaca  OAX     140
104117
 
96      Puebla  PUE     140
104118
 
97      Queretaro       QRO     140
104119
 
98      Quintana Roo    Q ROO   140
104120
 
99      San Luis Potosi SLP     140
104121
 
100     Sinaloa SIN     140
104122
 
101     Sonora  SON     140
104123
 
102     Tabasco TAB     140
104124
 
103     Tamaulipas      TAMPS   140
104125
 
104     Tlaxcala        TLAX    140
104126
 
105     Veracruz        VER     140
104127
 
106     Yucatan YUC     140
104128
 
107     Zacatecas       ZAC     140
104129
 
108     Australian Capital Territory    ACT     13
104130
 
109     New South Wales NSW     13
104131
 
110     Northern Territory      NT      13
104132
 
111     Queensland      QLD     13
104133
 
112     South Australia SA      13
104134
 
113     Tasmania        TAS     13
104135
 
114     Victoria        VIC     13
104136
 
115     Western Australia       WA      13
104137
 
116     Schleswig-Holstein      SH      81
104138
 
117     Mecklenburg-Vorpommern  MV      81
104139
 
118     Hamburg HH      81
104140
 
119     Bremen  HB      81
104141
 
120     Berlin  BE      81
104142
 
121     Brandenburg     BB      81
104143
 
122     Niedersachsen   NI      81
104144
 
123     Nordrhein-Westfalen     NW      81
104145
 
124     Sachsen-Anhalt  ST      81
104146
 
125     Sachsen SN      81
104147
 
126     Hessen  HE      81
104148
 
127     ThƃĀ¼ringen      TH      81
104149
 
128     Bayern  BY      81
104150
 
129     Rheinland-Pfalz RP      81
104151
 
130     Saarland        SL      81
104152
 
131     Baden-WƃĀ¼rttemberg      BW      81
104153
 
132     Acre    AC      30
104154
 
133     Alagoas AL      30
104155
 
134     AmapƃĀ”  AP      30
104156
 
135     Amazonas        AM      30
104157
 
136     Bahia   VA      30
104158
 
137     CearƃĀ”  CE      30
104159
 
138     Distito Federal DF      30
104160
 
139     Espirito Santo  ES      30
104161
 
140     GoiƃĀ”s  GO      30
104162
 
141     MaranhƃĀ£o       MA      30
104163
 
142     Mato Grosso     MT      30
104164
 
143     Mato Grosso do Sul      MS      30
104165
 
144     Minas Gerais    MG      30
104166
 
145     ParƃĀ”   PA      30
104167
 
146     Paraiba PB      30
104168
 
147     ParanƃĀ” PR      30
104169
 
148     Pernambuco      PE      30
104170
 
149     Piaui   PI      30
104171
 
150     Rio de Janeiro  RJ      30
104172
 
151     Rio Grande do Norte     RN      30
104173
 
152     Rio Grande do Sul       RS      30
104174
 
153     RondƃĀ“nia       RO      30
104175
 
154     Roraima RR      30
104176
 
155     Santa Catarina  SC      30
104177
 
156     SƃĀ£o Paulo      SP      30
104178
 
157     Sergipe SE      30
104179
 
158     Tocantins       TO      30
104180
 
\.
104181
 
 
104182
 
 
104183
 
--
104184
 
--
104185
 
 
104186
 
SELECT pg_catalog.setval('state_state_id_seq', 158, true);
104187
 
 
104188
 
 
104189
 
--
104190
 
--
104191
 
 
104192
 
COPY status (status_id, status_type, status_code, status_name, status_seq, status_color) FROM stdin;
104193
 
1       INCDT   N       New     0       white
104194
 
2       INCDT   F       Feedback        1       white
104195
 
3       INCDT   C       Confirmed       2       white
104196
 
4       INCDT   A       Assigned        3       white
104197
 
5       INCDT   R       Resolved        4       white
104198
 
6       INCDT   L       Closed  5       white
104199
 
\.
104200
 
 
104201
 
 
104202
 
--
104203
 
--
104204
 
 
104205
 
SELECT pg_catalog.setval('status_status_id_seq', 6, true);
104206
 
 
104207
 
 
104208
 
--
104209
 
--
104210
 
 
104211
 
COPY stdjrnl (stdjrnl_id, stdjrnl_name, stdjrnl_descrip, stdjrnl_notes) FROM stdin;
104212
 
\.
104213
 
 
104214
 
 
104215
 
--
104216
 
--
104217
 
 
104218
 
SELECT pg_catalog.setval('stdjrnl_stdjrnl_id_seq', 30, true);
104219
 
 
104220
 
 
104221
 
--
104222
 
--
104223
 
 
104224
 
COPY stdjrnlgrp (stdjrnlgrp_id, stdjrnlgrp_name, stdjrnlgrp_descrip) FROM stdin;
104225
 
\.
104226
 
 
104227
 
 
104228
 
--
104229
 
--
104230
 
 
104231
 
SELECT pg_catalog.setval('stdjrnlgrp_stdjrnlgrp_id_seq', 12, true);
104232
 
 
104233
 
 
104234
 
--
104235
 
--
104236
 
 
104237
 
COPY stdjrnlgrpitem (stdjrnlgrpitem_id, stdjrnlgrpitem_stdjrnl_id, stdjrnlgrpitem_toapply, stdjrnlgrpitem_applied, stdjrnlgrpitem_effective, stdjrnlgrpitem_expires, stdjrnlgrpitem_stdjrnlgrp_id) FROM stdin;
104238
 
\.
104239
 
 
104240
 
 
104241
 
--
104242
 
--
104243
 
 
104244
 
SELECT pg_catalog.setval('stdjrnlgrpitem_stdjrnlgrpitem_id_seq', 18, true);
104245
 
 
104246
 
 
104247
 
--
104248
 
--
104249
 
 
104250
 
COPY stdjrnlitem (stdjrnlitem_id, stdjrnlitem_stdjrnl_id, stdjrnlitem_accnt_id, stdjrnlitem_amount, stdjrnlitem_notes) FROM stdin;
104251
 
\.
104252
 
 
104253
 
 
104254
 
--
104255
 
--
104256
 
 
104257
 
SELECT pg_catalog.setval('stdjrnlitem_stdjrnlitem_id_seq', 28, true);
104258
 
 
104259
 
 
104260
 
--
104261
 
--
104262
 
 
104263
 
COPY subaccnt (subaccnt_id, subaccnt_number, subaccnt_descrip) FROM stdin;
104264
 
\.
104265
 
 
104266
 
 
104267
 
--
104268
 
--
104269
 
 
104270
 
SELECT pg_catalog.setval('subaccnt_subaccnt_id_seq', 1, false);
104271
 
 
104272
 
 
104273
 
--
104274
 
--
104275
 
 
104276
 
COPY subaccnttype (subaccnttype_id, subaccnttype_accnt_type, subaccnttype_code, subaccnttype_descrip) FROM stdin;
104277
 
1       A       CA      Cash Assets
104278
 
2       A       AR      Accounts Receivable
104279
 
3       A       IN      Inventory
104280
 
4       A       CAS     Current Assets
104281
 
5       A       FA      Fixed Assets
104282
 
6       A       AD      Accumulated Depreciation
104283
 
7       L       CL      Current Liabilities
104284
 
8       L       AP      Accounts Payable
104285
 
9       L       LTL     Long Term Liabilities
104286
 
10      Q       EDC     Equity do not close
104287
 
11      Q       ERE     Equity Retained Earnings
104288
 
12      Q       EC      Equity close
104289
 
13      R       SI      Sales Income
104290
 
14      R       II      Interest Income
104291
 
15      R       IV      Investment Income
104292
 
16      R       RT      Returns
104293
 
17      E       COGS    Cost of Goods Sold
104294
 
18      E       EXP     Expenses
104295
 
\.
104296
 
 
104297
 
 
104298
 
--
104299
 
--
104300
 
 
104301
 
SELECT pg_catalog.setval('subaccnttype_subaccnttype_id_seq', 18, true);
104302
 
 
104303
 
 
104304
 
--
104305
 
--
104306
 
 
104307
 
COPY tax (tax_id, tax_code, tax_descrip, tax_sales_accnt_id, tax_taxclass_id, tax_taxauth_id, tax_basis_tax_id, tax_dist_accnt_id) FROM stdin;
104308
 
\.
104309
 
 
104310
 
 
104311
 
--
104312
 
--
104313
 
 
104314
 
SELECT pg_catalog.setval('tax_tax_id_seq', 11, true);
104315
 
 
104316
 
 
104317
 
--
104318
 
--
104319
 
 
104320
 
COPY taxass (taxass_id, taxass_taxzone_id, taxass_taxtype_id, taxass_tax_id) FROM stdin;
104321
 
\.
104322
 
 
104323
 
 
104324
 
--
104325
 
--
104326
 
 
104327
 
SELECT pg_catalog.setval('taxass_taxass_id_seq', 1, false);
104328
 
 
104329
 
 
104330
 
--
104331
 
--
104332
 
 
104333
 
COPY taxauth (taxauth_id, taxauth_code, taxauth_name, taxauth_extref, taxauth_addr_id, taxauth_curr_id, taxauth_county, taxauth_accnt_id) FROM stdin;
104334
 
\.
104335
 
 
104336
 
 
104337
 
--
104338
 
--
104339
 
 
104340
 
SELECT pg_catalog.setval('taxauth_taxauth_id_seq', 1, false);
104341
 
 
104342
 
 
104343
 
--
104344
 
--
104345
 
 
104346
 
COPY taxclass (taxclass_id, taxclass_code, taxclass_descrip, taxclass_sequence) FROM stdin;
104347
 
1       1       Legacy Class 1  0
104348
 
2       2       Legacy Class 2  0
104349
 
3       3       Legacy Class 3  0
104350
 
\.
104351
 
 
104352
 
 
104353
 
--
104354
 
--
104355
 
 
104356
 
SELECT pg_catalog.setval('taxclass_taxclass_id_seq', 3, true);
104357
 
 
104358
 
 
104359
 
--
104360
 
--
104361
 
 
104362
 
COPY taxhist (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin;
104363
 
\.
104364
 
 
104365
 
 
104366
 
--
104367
 
--
104368
 
 
104369
 
SELECT pg_catalog.setval('taxhist_taxhist_id_seq', 1, false);
104370
 
 
104371
 
 
104372
 
--
104373
 
--
104374
 
 
104375
 
COPY taxpay (taxpay_id, taxpay_taxhist_id, taxpay_apply_id, taxpay_distdate, taxpay_tax) FROM stdin;
104376
 
\.
104377
 
 
104378
 
 
104379
 
--
104380
 
--
104381
 
 
104382
 
SELECT pg_catalog.setval('taxpay_taxpay_id_seq', 1, false);
104383
 
 
104384
 
 
104385
 
--
104386
 
--
104387
 
 
104388
 
COPY taxrate (taxrate_id, taxrate_tax_id, taxrate_percent, taxrate_curr_id, taxrate_amount, taxrate_effective, taxrate_expires) FROM stdin;
104389
 
\.
104390
 
 
104391
 
 
104392
 
--
104393
 
--
104394
 
 
104395
 
SELECT pg_catalog.setval('taxrate_taxrate_id_seq', 1, false);
104396
 
 
104397
 
 
104398
 
--
104399
 
--
104400
 
 
104401
 
COPY taxreg (taxreg_id, taxreg_rel_id, taxreg_rel_type, taxreg_taxauth_id, taxreg_number, taxreg_taxzone_id, taxreg_effective, taxreg_expires, taxreg_notes) FROM stdin;
104402
 
\.
104403
 
 
104404
 
 
104405
 
--
104406
 
--
104407
 
 
104408
 
SELECT pg_catalog.setval('taxreg_taxreg_id_seq', 1, false);
104409
 
 
104410
 
 
104411
 
--
104412
 
--
104413
 
 
104414
 
COPY taxtype (taxtype_id, taxtype_name, taxtype_descrip, taxtype_sys) FROM stdin;
104415
 
1       Freight System Defined Freight Tax Type. DO NOT CHANGE. t
104416
 
2       Adjustment      System Defined Adjustment Tax Type. DO NOT CHANGE.      t
104417
 
\.
104418
 
 
104419
 
 
104420
 
--
104421
 
--
104422
 
 
104423
 
SELECT pg_catalog.setval('taxtype_taxtype_id_seq', 2, true);
104424
 
 
104425
 
 
104426
 
--
104427
 
--
104428
 
 
104429
 
COPY taxzone (taxzone_id, taxzone_code, taxzone_descrip) FROM stdin;
104430
 
\.
104431
 
 
104432
 
 
104433
 
--
104434
 
--
104435
 
 
104436
 
SELECT pg_catalog.setval('taxzone_taxzone_id_seq', 1, false);
104437
 
 
104438
 
 
104439
 
--
104440
 
--
104441
 
 
104442
 
COPY terms (terms_id, terms_code, terms_descrip, terms_type, terms_duedays, terms_discdays, terms_discprcnt, terms_cutoffday, terms_ap, terms_ar, terms_fincharg) FROM stdin;
104443
 
\.
104444
 
 
104445
 
 
104446
 
--
104447
 
--
104448
 
 
104449
 
SELECT pg_catalog.setval('terms_terms_id_seq', 41, true);
104450
 
 
104451
 
 
104452
 
--
104453
 
--
104454
 
 
104455
 
COPY todoitem (todoitem_id, todoitem_name, todoitem_description, todoitem_incdt_id, todoitem_creator_username, todoitem_status, todoitem_active, todoitem_start_date, todoitem_due_date, todoitem_assigned_date, todoitem_completed_date, todoitem_seq, todoitem_notes, todoitem_crmacct_id, todoitem_ophead_id, todoitem_owner_username, todoitem_priority_id, todoitem_username, todoitem_recurring_todoitem_id, todoitem_cntct_id) FROM stdin;
104456
 
\.
104457
 
 
104458
 
 
104459
 
--
104460
 
--
104461
 
 
104462
 
SELECT pg_catalog.setval('todoitem_todoitem_id_seq', 1, false);
104463
 
 
104464
 
 
104465
 
--
104466
 
--
104467
 
 
104468
 
COPY trgthist (trgthist_src_cntct_id, trgthist_trgt_cntct_id, trgthist_col, trgthist_value) FROM stdin;
104469
 
\.
104470
 
 
104471
 
 
104472
 
--
104473
 
--
104474
 
 
104475
 
COPY trialbal (trialbal_id, trialbal_period_id, trialbal_accnt_id, trialbal_beginning, trialbal_ending, trialbal_credits, trialbal_debits, trialbal_dirty, trialbal_yearend) FROM stdin;
104476
 
\.
104477
 
 
104478
 
 
104479
 
--
104480
 
--
104481
 
 
104482
 
SELECT pg_catalog.setval('trialbal_trialbal_id_seq', 8157, true);
104483
 
 
104484
 
 
104485
 
--
104486
 
--
104487
 
 
104488
 
COPY uiform (uiform_id, uiform_name, uiform_order, uiform_enabled, uiform_source, uiform_notes) FROM stdin;
104489
 
\.
104490
 
 
104491
 
 
104492
 
--
104493
 
--
104494
 
 
104495
 
SELECT pg_catalog.setval('uiform_uiform_id_seq', 64, true);
104496
 
 
104497
 
 
104498
 
--
104499
 
--
104500
 
 
104501
 
COPY uom (uom_id, uom_name, uom_descrip, uom_item_weight) FROM stdin;
104502
 
\.
104503
 
 
104504
 
 
104505
 
--
104506
 
--
104507
 
 
104508
 
SELECT pg_catalog.setval('uom_uom_id_seq', 3, true);
104509
 
 
104510
 
 
104511
 
--
104512
 
--
104513
 
 
104514
 
COPY uomconv (uomconv_id, uomconv_from_uom_id, uomconv_from_value, uomconv_to_uom_id, uomconv_to_value, uomconv_fractional) FROM stdin;
104515
 
\.
104516
 
 
104517
 
 
104518
 
--
104519
 
--
104520
 
 
104521
 
SELECT pg_catalog.setval('uomconv_uomconv_id_seq', 1, false);
104522
 
 
104523
 
 
104524
 
--
104525
 
--
104526
 
 
104527
 
COPY uomtype (uomtype_id, uomtype_name, uomtype_descrip, uomtype_multiple) FROM stdin;
104528
 
1       Selling Selling a.k.a. Pricing and Shipping UOMs.       t
104529
 
2       Capacity        Capacity UOMs.  f
104530
 
3       AltCapacity     Alternate Capacity UOMs.        f
104531
 
4       MaterialIssue   Material Issuing UOMs.  f
104532
 
\.
104533
 
 
104534
 
 
104535
 
--
104536
 
--
104537
 
 
104538
 
SELECT pg_catalog.setval('uomtype_uomtype_id_seq', 4, true);
104539
 
 
104540
 
 
104541
 
--
104542
 
--
104543
 
 
104544
 
COPY urlinfo (url_id, url_title, url_url) FROM stdin;
104545
 
\.
104546
 
 
104547
 
 
104548
 
--
104549
 
--
104550
 
 
104551
 
SELECT pg_catalog.setval('urlinfo_url_id_seq', 1, false);
104552
 
 
104553
 
 
104554
 
--
104555
 
--
104556
 
 
104557
 
COPY usr_bak (usr_id, usr_username, usr_propername, usr_passwd, usr_locale_id, usr_initials, usr_agent, usr_active, usr_email, usr_window) FROM stdin;
104558
 
1       mfgadmin        OpenMFG Administrator   \N      3       ADMIN   t       t       chris@openmfg.com       
104559
 
2       admin   Administrator           3       ADMIN   t       t       admin@xtuple.com        \N
104560
 
\.
104561
 
 
104562
 
 
104563
 
--
104564
 
--
104565
 
 
104566
 
SELECT pg_catalog.setval('usr_usr_id_seq', 9, true);
104567
 
 
104568
 
 
104569
 
--
104570
 
--
104571
 
 
104572
 
COPY usrgrp (usrgrp_id, usrgrp_grp_id, usrgrp_username) FROM stdin;
104573
 
\.
104574
 
 
104575
 
 
104576
 
--
104577
 
--
104578
 
 
104579
 
SELECT pg_catalog.setval('usrgrp_usrgrp_id_seq', 1, false);
104580
 
 
104581
 
 
104582
 
--
104583
 
--
104584
 
 
104585
 
COPY usrpref (usrpref_id, usrpref_name, usrpref_value, usrpref_username) FROM stdin;
104586
 
1       BackgroundImageid       14      mfgadmin
104587
 
2       ShowIMMenu      t       mfgadmin
104588
 
3       ShowPDMenu      t       mfgadmin
104589
 
4       ShowMSMenu      t       mfgadmin
104590
 
5       ShowCPMenu      t       mfgadmin
104591
 
6       ShowWOMenu      t       mfgadmin
104592
 
7       ShowPOMenu      t       mfgadmin
104593
 
8       ShowSOMenu      t       mfgadmin
104594
 
9       ShowSRMenu      t       mfgadmin
104595
 
10      ShowSAMenu      t       mfgadmin
104596
 
28      ShowGLMenu      t       mfgadmin
104597
 
34      UseCustCache    f       mfgadmin
104598
 
29      ShowAPMenu      t       mfgadmin
104599
 
27      ShowARMenu      t       mfgadmin
104600
 
48      ShowPDToolbar   t       mfgadmin
104601
 
51      ShowMSToolbar   t       mfgadmin
104602
 
52      ShowCPToolbar   t       mfgadmin
104603
 
49      ShowWOToolbar   t       mfgadmin
104604
 
30      ShowSOToolbar   t       mfgadmin
104605
 
53      ShowSRToolbar   t       mfgadmin
104606
 
73      UsedFixedWidthFonts     f       mfgadmin
104607
 
47      ShowIMToolbar   t       mfgadmin
104608
 
74      ShowSAToolbar   t       mfgadmin
104609
 
50      ShowPOToolbar   t       mfgadmin
104610
 
76      ShowGLToolbar   t       mfgadmin
104611
 
108     ToolbarPositions        \n\n\nI/M Tools,P/D Tools,W/O Tools,P/O Tools,S/O Tools,\n[I/M Tools,0,0,-1,-1,1][P/D Tools,0,0,-1,-1,1][W/O Tools,0,0,-1,-1,1][P/O Tools,0,0,-1,-1,1][S/O Tools,0,0,-1,-1,1]\n\n\n\n\n\n\n     mfgadmin
104612
 
109     ShowCRMMenu     t       mfgadmin
104613
 
110     ShowPMMenu      t       mfgadmin
104614
 
111     ShowCRMToolbar  t       mfgadmin
104615
 
112     ShowPMToolbar   t       mfgadmin
104616
 
75      ShowAPToolbar   t       mfgadmin
104617
 
113     ShowARToolbar   t       mfgadmin
104618
 
11      PreferredWarehouse      -1      mfgadmin
104619
 
114     UseItemCache    f       mfgadmin
104620
 
54      ShowRIWorkOrdersByDefault       f       mfgadmin
104621
 
115     ListNumericItemNumbersFirst     f       mfgadmin
104622
 
116     ShowSOItemAvailability  t       mfgadmin
104623
 
117     IdleTimeout     0       mfgadmin
104624
 
118     DefaultEllipsesAction   list    mfgadmin
104625
 
119     InterfaceWindowOption   Workspace       mfgadmin
104626
 
120     DisableExportContents   f       mfgadmin
104627
 
121     UseEnhancedAuthentication       f       mfgadmin
104628
 
122     BackgroundImageid       -1      admin
104629
 
123     ShowIMMenu      t       admin
104630
 
124     ShowPDMenu      t       admin
104631
 
125     ShowMSMenu      t       admin
104632
 
126     ShowCPMenu      t       admin
104633
 
127     ShowWOMenu      t       admin
104634
 
128     ShowPOMenu      t       admin
104635
 
129     ShowSOMenu      t       admin
104636
 
130     ShowSRMenu      t       admin
104637
 
131     ShowSAMenu      t       admin
104638
 
132     ShowGLMenu      t       admin
104639
 
133     UseCustCache    f       admin
104640
 
134     ShowAPMenu      t       admin
104641
 
135     ShowARMenu      t       admin
104642
 
136     ShowPDToolbar   t       admin
104643
 
137     ShowMSToolbar   t       admin
104644
 
138     ShowCPToolbar   t       admin
104645
 
139     ShowWOToolbar   t       admin
104646
 
140     ShowSOToolbar   t       admin
104647
 
141     ShowSRToolbar   t       admin
104648
 
142     UsedFixedWidthFonts     f       admin
104649
 
143     ShowIMToolbar   t       admin
104650
 
144     ShowSAToolbar   t       admin
104651
 
145     ShowPOToolbar   t       admin
104652
 
146     ShowGLToolbar   t       admin
104653
 
147     ToolbarPositions        \n\n\nI/M Tools,P/D Tools,W/O Tools,P/O Tools,S/O Tools,\n[I/M Tools,0,0,-1,-1,1][P/D Tools,0,0,-1,-1,1][W/O Tools,0,0,-1,-1,1][P/O Tools,0,0,-1,-1,1][S/O Tools,0,0,-1,-1,1]\n\n\n\n\n\n\n     admin
104654
 
148     ShowCRMMenu     t       admin
104655
 
149     ShowPMMenu      t       admin
104656
 
150     ShowCRMToolbar  t       admin
104657
 
151     ShowPMToolbar   t       admin
104658
 
152     ShowAPToolbar   t       admin
104659
 
153     ShowARToolbar   t       admin
104660
 
154     PreferredWarehouse      -1      admin
104661
 
155     UseItemCache    f       admin
104662
 
156     ShowRIWorkOrdersByDefault       f       admin
104663
 
157     ListNumericItemNumbersFirst     f       admin
104664
 
158     ShowSOItemAvailability  t       admin
104665
 
159     IdleTimeout     0       admin
104666
 
160     DefaultEllipsesAction   list    admin
104667
 
164     propername      OpenMFG Administrator   mfgadmin
104668
 
165     initials        ADMIN   mfgadmin
104669
 
166     email   chris@openmfg.com       mfgadmin
104670
 
167     locale_id       3       mfgadmin
104671
 
168     agent   t       mfgadmin
104672
 
169     active  t       mfgadmin
104673
 
170     window          mfgadmin
104674
 
177     window  \N      admin
104675
 
178     locales/_locale/columnsShown    0,on|1,on|      admin
104676
 
179     IngoreMissingTranslationFiles   f       admin
104677
 
161     InterfaceWindowOption   TopLevel        admin
104678
 
181     CopyListsPlainText      f       admin
104679
 
182     EmailEvents     f       admin
104680
 
183     AlarmEventDefault       f       admin
104681
 
184     AlarmEmailDefault       f       admin
104682
 
185     AlarmSysmsgDefault      f       admin
104683
 
186     EnableScriptDebug       f       admin
104684
 
187     userPreferences/_event/columnsShown     0,on|1,on|2,on| admin
104685
 
188     userPreferences/_warehouses/columnsShown        0,on|1,on|2,on| admin
104686
 
189     userPreferences/_hotkey/columnsShown    0,on|1,on|2,on| admin
104687
 
162     DisableExportContents   f       admin
104688
 
163     UseEnhancedAuthentication       f       admin
104689
 
190     selectedSites   f       admin
104690
 
171     propername      Administrator   admin
104691
 
173     email   admin@xtuple.com        admin
104692
 
172     initials        ADMIN   admin
104693
 
174     locale_id       3       admin
104694
 
175     agent   t       admin
104695
 
176     active  t       admin
104696
 
191     metasqls/_byPackage/checked     2       admin
104697
 
192     reports/_byPackage/checked      0       admin
104698
 
193     packages/_autoUpdate/checked    0       admin
104699
 
\.
104700
 
 
104701
 
 
104702
 
--
104703
 
--
104704
 
 
104705
 
SELECT pg_catalog.setval('usrpref_usrpref_id_seq', 193, true);
104706
 
 
104707
 
 
104708
 
--
104709
 
--
104710
 
 
104711
 
COPY usrpriv (usrpriv_id, usrpriv_priv_id, usrpriv_username) FROM stdin;
104712
 
1       3       mfgadmin
104713
 
3       5       mfgadmin
104714
 
11      45      mfgadmin
104715
 
12      44      mfgadmin
104716
 
13      100     mfgadmin
104717
 
14      48      mfgadmin
104718
 
15      49      mfgadmin
104719
 
16      53      mfgadmin
104720
 
17      54      mfgadmin
104721
 
18      63      mfgadmin
104722
 
19      64      mfgadmin
104723
 
20      65      mfgadmin
104724
 
21      73      mfgadmin
104725
 
26      4       mfgadmin
104726
 
28      17      mfgadmin
104727
 
29      16      mfgadmin
104728
 
30      91      mfgadmin
104729
 
31      27      mfgadmin
104730
 
33      11      mfgadmin
104731
 
34      93      mfgadmin
104732
 
35      12      mfgadmin
104733
 
36      13      mfgadmin
104734
 
37      26      mfgadmin
104735
 
38      75      mfgadmin
104736
 
39      76      mfgadmin
104737
 
40      94      mfgadmin
104738
 
41      121     mfgadmin
104739
 
42      122     mfgadmin
104740
 
43      101     mfgadmin
104741
 
45      87      mfgadmin
104742
 
46      103     mfgadmin
104743
 
47      104     mfgadmin
104744
 
48      105     mfgadmin
104745
 
50      107     mfgadmin
104746
 
51      1       mfgadmin
104747
 
52      2       mfgadmin
104748
 
60      123     mfgadmin
104749
 
63      120     mfgadmin
104750
 
65      124     mfgadmin
104751
 
66      125     mfgadmin
104752
 
75      134     mfgadmin
104753
 
78      137     mfgadmin
104754
 
80      140     mfgadmin
104755
 
81      22      mfgadmin
104756
 
82      23      mfgadmin
104757
 
83      51      mfgadmin
104758
 
84      55      mfgadmin
104759
 
85      56      mfgadmin
104760
 
86      57      mfgadmin
104761
 
87      58      mfgadmin
104762
 
88      61      mfgadmin
104763
 
89      62      mfgadmin
104764
 
90      59      mfgadmin
104765
 
91      60      mfgadmin
104766
 
92      50      mfgadmin
104767
 
93      88      mfgadmin
104768
 
94      89      mfgadmin
104769
 
96      126     mfgadmin
104770
 
97      127     mfgadmin
104771
 
98      141     mfgadmin
104772
 
99      142     mfgadmin
104773
 
100     143     mfgadmin
104774
 
101     144     mfgadmin
104775
 
118     160     mfgadmin
104776
 
119     31      mfgadmin
104777
 
123     161     mfgadmin
104778
 
124     162     mfgadmin
104779
 
125     163     mfgadmin
104780
 
127     68      mfgadmin
104781
 
129     166     mfgadmin
104782
 
130     167     mfgadmin
104783
 
131     168     mfgadmin
104784
 
132     169     mfgadmin
104785
 
133     170     mfgadmin
104786
 
135     173     mfgadmin
104787
 
138     176     mfgadmin
104788
 
139     177     mfgadmin
104789
 
140     178     mfgadmin
104790
 
142     180     mfgadmin
104791
 
143     181     mfgadmin
104792
 
144     182     mfgadmin
104793
 
147     189     mfgadmin
104794
 
148     190     mfgadmin
104795
 
149     191     mfgadmin
104796
 
150     192     mfgadmin
104797
 
151     193     mfgadmin
104798
 
152     194     mfgadmin
104799
 
153     195     mfgadmin
104800
 
154     196     mfgadmin
104801
 
155     197     mfgadmin
104802
 
156     198     mfgadmin
104803
 
157     199     mfgadmin
104804
 
158     200     mfgadmin
104805
 
159     201     mfgadmin
104806
 
160     202     mfgadmin
104807
 
161     232     mfgadmin
104808
 
162     203     mfgadmin
104809
 
164     205     mfgadmin
104810
 
165     233     mfgadmin
104811
 
166     207     mfgadmin
104812
 
167     208     mfgadmin
104813
 
168     209     mfgadmin
104814
 
170     234     mfgadmin
104815
 
171     235     mfgadmin
104816
 
172     211     mfgadmin
104817
 
173     212     mfgadmin
104818
 
174     213     mfgadmin
104819
 
177     236     mfgadmin
104820
 
188     228     mfgadmin
104821
 
189     231     mfgadmin
104822
 
194     239     mfgadmin
104823
 
195     242     mfgadmin
104824
 
391     246     mfgadmin
104825
 
392     244     mfgadmin
104826
 
393     245     mfgadmin
104827
 
397     248     mfgadmin
104828
 
401     249     mfgadmin
104829
 
402     250     mfgadmin
104830
 
410     253     mfgadmin
104831
 
748     258     mfgadmin
104832
 
749     257     mfgadmin
104833
 
750     204     mfgadmin
104834
 
809     187     mfgadmin
104835
 
810     188     mfgadmin
104836
 
811     259     mfgadmin
104837
 
825     262     mfgadmin
104838
 
827     263     mfgadmin
104839
 
828     261     mfgadmin
104840
 
829     269     mfgadmin
104841
 
839     214     mfgadmin
104842
 
840     274     mfgadmin
104843
 
841     47      mfgadmin
104844
 
842     46      mfgadmin
104845
 
843     256     mfgadmin
104846
 
844     255     mfgadmin
104847
 
846     276     mfgadmin
104848
 
847     275     mfgadmin
104849
 
848     277     mfgadmin
104850
 
849     278     mfgadmin
104851
 
850     280     mfgadmin
104852
 
851     215     mfgadmin
104853
 
852     217     mfgadmin
104854
 
853     218     mfgadmin
104855
 
854     219     mfgadmin
104856
 
855     220     mfgadmin
104857
 
856     223     mfgadmin
104858
 
857     224     mfgadmin
104859
 
858     225     mfgadmin
104860
 
859     216     mfgadmin
104861
 
860     222     mfgadmin
104862
 
861     221     mfgadmin
104863
 
862     226     mfgadmin
104864
 
863     227     mfgadmin
104865
 
872     10      mfgadmin
104866
 
873     30      mfgadmin
104867
 
874     29      mfgadmin
104868
 
875     37      mfgadmin
104869
 
876     42      mfgadmin
104870
 
877     84      mfgadmin
104871
 
878     82      mfgadmin
104872
 
879     83      mfgadmin
104873
 
880     85      mfgadmin
104874
 
881     86      mfgadmin
104875
 
882     90      mfgadmin
104876
 
883     116     mfgadmin
104877
 
884     117     mfgadmin
104878
 
885     118     mfgadmin
104879
 
887     14      mfgadmin
104880
 
888     15      mfgadmin
104881
 
889     128     mfgadmin
104882
 
890     129     mfgadmin
104883
 
891     131     mfgadmin
104884
 
892     130     mfgadmin
104885
 
893     132     mfgadmin
104886
 
894     133     mfgadmin
104887
 
895     147     mfgadmin
104888
 
896     81      mfgadmin
104889
 
897     148     mfgadmin
104890
 
898     19      mfgadmin
104891
 
900     150     mfgadmin
104892
 
901     151     mfgadmin
104893
 
902     152     mfgadmin
104894
 
903     154     mfgadmin
104895
 
904     153     mfgadmin
104896
 
905     35      mfgadmin
104897
 
906     36      mfgadmin
104898
 
907     164     mfgadmin
104899
 
908     241     mfgadmin
104900
 
909     238     mfgadmin
104901
 
910     264     mfgadmin
104902
 
911     265     mfgadmin
104903
 
912     179     mfgadmin
104904
 
913     251     mfgadmin
104905
 
914     252     mfgadmin
104906
 
915     254     mfgadmin
104907
 
916     266     mfgadmin
104908
 
917     267     mfgadmin
104909
 
918     268     mfgadmin
104910
 
919     271     mfgadmin
104911
 
920     272     mfgadmin
104912
 
1193    281     mfgadmin
104913
 
1195    106     mfgadmin
104914
 
1219    111     mfgadmin
104915
 
1220    260     mfgadmin
104916
 
1523    294     mfgadmin
104917
 
1537    297     mfgadmin
104918
 
1538    298     mfgadmin
104919
 
1552    279     mfgadmin
104920
 
1553    302     mfgadmin
104921
 
1554    303     mfgadmin
104922
 
1555    305     mfgadmin
104923
 
1556    70      mfgadmin
104924
 
1557    273     mfgadmin
104925
 
1563    306     mfgadmin
104926
 
1564    307     mfgadmin
104927
 
2039    389     mfgadmin
104928
 
1779    316     mfgadmin
104929
 
1780    317     mfgadmin
104930
 
2040    369     mfgadmin
104931
 
2041    370     mfgadmin
104932
 
2042    371     mfgadmin
104933
 
2043    334     mfgadmin
104934
 
2044    356     mfgadmin
104935
 
2045    357     mfgadmin
104936
 
2046    358     mfgadmin
104937
 
2047    407     mfgadmin
104938
 
2048    372     mfgadmin
104939
 
2049    335     mfgadmin
104940
 
2050    373     mfgadmin
104941
 
2051    382     mfgadmin
104942
 
2054    416     mfgadmin
104943
 
2057    446     mfgadmin
104944
 
2058    420     mfgadmin
104945
 
2060    422     mfgadmin
104946
 
2061    423     mfgadmin
104947
 
2062    424     mfgadmin
104948
 
2063    425     mfgadmin
104949
 
2064    426     mfgadmin
104950
 
2065    427     mfgadmin
104951
 
2067    429     mfgadmin
104952
 
2069    431     mfgadmin
104953
 
2070    447     mfgadmin
104954
 
2071    433     mfgadmin
104955
 
2073    435     mfgadmin
104956
 
2074    436     mfgadmin
104957
 
2075    437     mfgadmin
104958
 
2077    439     mfgadmin
104959
 
2078    440     mfgadmin
104960
 
2079    441     mfgadmin
104961
 
2080    442     mfgadmin
104962
 
2082    444     mfgadmin
104963
 
2083    419     mfgadmin
104964
 
2084    432     mfgadmin
104965
 
2085    448     mfgadmin
104966
 
2086    449     mfgadmin
104967
 
2087    450     mfgadmin
104968
 
2088    451     mfgadmin
104969
 
2089    313     mfgadmin
104970
 
2090    314     mfgadmin
104971
 
2091    315     mfgadmin
104972
 
2092    374     mfgadmin
104973
 
2093    375     mfgadmin
104974
 
2094    376     mfgadmin
104975
 
2095    377     mfgadmin
104976
 
2096    378     mfgadmin
104977
 
2097    379     mfgadmin
104978
 
2098    380     mfgadmin
104979
 
2099    395     mfgadmin
104980
 
2100    396     mfgadmin
104981
 
2101    397     mfgadmin
104982
 
2102    398     mfgadmin
104983
 
2103    350     mfgadmin
104984
 
2104    351     mfgadmin
104985
 
2109    270     mfgadmin
104986
 
2110    362     mfgadmin
104987
 
2111    363     mfgadmin
104988
 
2112    349     mfgadmin
104989
 
2113    390     mfgadmin
104990
 
2114    391     mfgadmin
104991
 
2115    392     mfgadmin
104992
 
2116    353     mfgadmin
104993
 
2117    354     mfgadmin
104994
 
2118    368     mfgadmin
104995
 
2119    383     mfgadmin
104996
 
2120    347     mfgadmin
104997
 
2121    348     mfgadmin
104998
 
2122    336     mfgadmin
104999
 
2123    337     mfgadmin
105000
 
2124    346     mfgadmin
105001
 
2125    355     mfgadmin
105002
 
2126    385     mfgadmin
105003
 
2127    386     mfgadmin
105004
 
2128    393     mfgadmin
105005
 
2129    345     mfgadmin
105006
 
2130    359     mfgadmin
105007
 
2135    388     mfgadmin
105008
 
2136    394     mfgadmin
105009
 
2137    399     mfgadmin
105010
 
2138    403     mfgadmin
105011
 
2139    404     mfgadmin
105012
 
2141    406     mfgadmin
105013
 
2142    445     mfgadmin
105014
 
2143    352     mfgadmin
105015
 
2147    408     mfgadmin
105016
 
2148    409     mfgadmin
105017
 
2150    452     mfgadmin
105018
 
2151    453     mfgadmin
105019
 
2152    454     mfgadmin
105020
 
2153    455     mfgadmin
105021
 
2154    456     mfgadmin
105022
 
2155    457     mfgadmin
105023
 
2156    458     mfgadmin
105024
 
2157    461     mfgadmin
105025
 
2158    462     mfgadmin
105026
 
2159    463     mfgadmin
105027
 
2160    464     mfgadmin
105028
 
2161    465     mfgadmin
105029
 
2162    466     mfgadmin
105030
 
2163    467     mfgadmin
105031
 
2164    468     mfgadmin
105032
 
2165    469     mfgadmin
105033
 
2166    470     mfgadmin
105034
 
2167    459     mfgadmin
105035
 
2168    460     mfgadmin
105036
 
2169    487     mfgadmin
105037
 
2170    488     mfgadmin
105038
 
2171    489     mfgadmin
105039
 
2172    4       admin
105040
 
2173    483     admin
105041
 
2174    484     admin
105042
 
2175    485     admin
105043
 
2176    486     admin
105044
 
2177    182     admin
105045
 
2178    306     admin
105046
 
2179    307     admin
105047
 
2180    269     admin
105048
 
2181    270     admin
105049
 
2182    362     admin
105050
 
2183    363     admin
105051
 
2185    416     admin
105052
 
2188    446     admin
105053
 
2189    420     admin
105054
 
2191    422     admin
105055
 
2192    423     admin
105056
 
2193    424     admin
105057
 
2194    425     admin
105058
 
2195    426     admin
105059
 
2196    427     admin
105060
 
2198    429     admin
105061
 
2200    431     admin
105062
 
2201    447     admin
105063
 
2202    433     admin
105064
 
2204    435     admin
105065
 
2205    436     admin
105066
 
2206    437     admin
105067
 
2208    439     admin
105068
 
2209    440     admin
105069
 
2210    441     admin
105070
 
2211    442     admin
105071
 
2213    444     admin
105072
 
2214    419     admin
105073
 
2215    432     admin
105074
 
2216    448     admin
105075
 
2217    449     admin
105076
 
2218    450     admin
105077
 
2219    451     admin
105078
 
2220    390     admin
105079
 
2221    480     admin
105080
 
2222    481     admin
105081
 
2223    482     admin
105082
 
2224    5       admin
105083
 
2225    103     admin
105084
 
2226    104     admin
105085
 
2227    105     admin
105086
 
2228    106     admin
105087
 
2229    107     admin
105088
 
2230    1       admin
105089
 
2231    2       admin
105090
 
2232    134     admin
105091
 
2233    143     admin
105092
 
2234    144     admin
105093
 
2238    160     admin
105094
 
2239    31      admin
105095
 
2240    161     admin
105096
 
2241    162     admin
105097
 
2242    163     admin
105098
 
2243    316     admin
105099
 
2244    317     admin
105100
 
2245    349     admin
105101
 
2246    10      admin
105102
 
2247    30      admin
105103
 
2248    29      admin
105104
 
2249    37      admin
105105
 
2250    42      admin
105106
 
2251    84      admin
105107
 
2252    82      admin
105108
 
2253    83      admin
105109
 
2254    85      admin
105110
 
2255    86      admin
105111
 
2256    90      admin
105112
 
2257    116     admin
105113
 
2258    117     admin
105114
 
2259    118     admin
105115
 
2260    14      admin
105116
 
2261    15      admin
105117
 
2262    128     admin
105118
 
2263    129     admin
105119
 
2264    131     admin
105120
 
2265    130     admin
105121
 
2266    132     admin
105122
 
2267    133     admin
105123
 
2268    147     admin
105124
 
2269    81      admin
105125
 
2270    148     admin
105126
 
2271    19      admin
105127
 
2272    150     admin
105128
 
2273    151     admin
105129
 
2274    152     admin
105130
 
2275    154     admin
105131
 
2276    153     admin
105132
 
2277    35      admin
105133
 
2278    36      admin
105134
 
2279    164     admin
105135
 
2280    214     admin
105136
 
2281    215     admin
105137
 
2282    217     admin
105138
 
2283    218     admin
105139
 
2284    219     admin
105140
 
2285    220     admin
105141
 
2286    223     admin
105142
 
2287    224     admin
105143
 
2288    225     admin
105144
 
2289    216     admin
105145
 
2290    222     admin
105146
 
2291    221     admin
105147
 
2292    226     admin
105148
 
2293    227     admin
105149
 
2294    241     admin
105150
 
2295    238     admin
105151
 
2296    255     admin
105152
 
2297    256     admin
105153
 
2298    264     admin
105154
 
2299    265     admin
105155
 
2300    350     admin
105156
 
2301    351     admin
105157
 
2302    454     admin
105158
 
2303    470     admin
105159
 
2304    45      admin
105160
 
2305    44      admin
105161
 
2306    48      admin
105162
 
2307    49      admin
105163
 
2308    53      admin
105164
 
2309    54      admin
105165
 
2310    46      admin
105166
 
2311    47      admin
105167
 
2312    120     admin
105168
 
2313    137     admin
105169
 
2314    189     admin
105170
 
2315    204     admin
105171
 
2316    205     admin
105172
 
2317    207     admin
105173
 
2318    208     admin
105174
 
2319    209     admin
105175
 
2320    213     admin
105176
 
2321    231     admin
105177
 
2322    244     admin
105178
 
2323    245     admin
105179
 
2324    246     admin
105180
 
2325    249     admin
105181
 
2326    250     admin
105182
 
2327    353     admin
105183
 
2328    354     admin
105184
 
2329    368     admin
105185
 
2330    383     admin
105186
 
2331    452     admin
105187
 
2332    17      admin
105188
 
2333    16      admin
105189
 
2334    91      admin
105190
 
2335    27      admin
105191
 
2336    11      admin
105192
 
2337    93      admin
105193
 
2338    12      admin
105194
 
2339    13      admin
105195
 
2340    26      admin
105196
 
2341    75      admin
105197
 
2342    76      admin
105198
 
2343    94      admin
105199
 
2344    125     admin
105200
 
2345    140     admin
105201
 
2346    173     admin
105202
 
2347    176     admin
105203
 
2348    177     admin
105204
 
2349    178     admin
105205
 
2350    228     admin
105206
 
2351    352     admin
105207
 
2352    408     admin
105208
 
2353    409     admin
105209
 
2354    391     admin
105210
 
2355    392     admin
105211
 
2356    22      admin
105212
 
2357    23      admin
105213
 
2358    51      admin
105214
 
2359    55      admin
105215
 
2360    56      admin
105216
 
2361    57      admin
105217
 
2362    58      admin
105218
 
2363    61      admin
105219
 
2364    62      admin
105220
 
2365    59      admin
105221
 
2366    60      admin
105222
 
2367    50      admin
105223
 
2368    88      admin
105224
 
2369    89      admin
105225
 
2370    111     admin
105226
 
2371    126     admin
105227
 
2372    127     admin
105228
 
2373    141     admin
105229
 
2374    142     admin
105230
 
2375    180     admin
105231
 
2376    181     admin
105232
 
2377    190     admin
105233
 
2378    191     admin
105234
 
2379    192     admin
105235
 
2380    193     admin
105236
 
2381    194     admin
105237
 
2382    195     admin
105238
 
2383    196     admin
105239
 
2384    197     admin
105240
 
2385    198     admin
105241
 
2386    199     admin
105242
 
2387    200     admin
105243
 
2388    201     admin
105244
 
2389    202     admin
105245
 
2390    232     admin
105246
 
2391    203     admin
105247
 
2392    233     admin
105248
 
2393    70      admin
105249
 
2394    234     admin
105250
 
2395    235     admin
105251
 
2396    211     admin
105252
 
2397    212     admin
105253
 
2398    239     admin
105254
 
2399    242     admin
105255
 
2400    257     admin
105256
 
2401    258     admin
105257
 
2402    273     admin
105258
 
2403    274     admin
105259
 
2404    281     admin
105260
 
2405    336     admin
105261
 
2406    337     admin
105262
 
2407    346     admin
105263
 
2408    347     admin
105264
 
2409    348     admin
105265
 
2410    355     admin
105266
 
2411    385     admin
105267
 
2412    386     admin
105268
 
2413    389     admin
105269
 
2414    393     admin
105270
 
2415    459     admin
105271
 
2416    460     admin
105272
 
2417    179     admin
105273
 
2418    251     admin
105274
 
2419    252     admin
105275
 
2420    254     admin
105276
 
2421    260     admin
105277
 
2422    261     admin
105278
 
2423    262     admin
105279
 
2424    263     admin
105280
 
2425    266     admin
105281
 
2426    267     admin
105282
 
2427    268     admin
105283
 
2428    271     admin
105284
 
2429    272     admin
105285
 
2430    275     admin
105286
 
2431    276     admin
105287
 
2432    277     admin
105288
 
2433    278     admin
105289
 
2434    279     admin
105290
 
2435    280     admin
105291
 
2436    294     admin
105292
 
2437    297     admin
105293
 
2438    298     admin
105294
 
2439    302     admin
105295
 
2440    303     admin
105296
 
2441    305     admin
105297
 
2442    369     admin
105298
 
2443    370     admin
105299
 
2444    313     admin
105300
 
2445    314     admin
105301
 
2446    315     admin
105302
 
2447    371     admin
105303
 
2448    372     admin
105304
 
2449    334     admin
105305
 
2450    335     admin
105306
 
2451    373     admin
105307
 
2452    374     admin
105308
 
2453    375     admin
105309
 
2454    376     admin
105310
 
2455    377     admin
105311
 
2456    378     admin
105312
 
2457    356     admin
105313
 
2458    357     admin
105314
 
2459    358     admin
105315
 
2460    379     admin
105316
 
2461    380     admin
105317
 
2462    382     admin
105318
 
2463    395     admin
105319
 
2464    396     admin
105320
 
2465    397     admin
105321
 
2466    398     admin
105322
 
2467    407     admin
105323
 
2468    455     admin
105324
 
2469    456     admin
105325
 
2470    457     admin
105326
 
2471    458     admin
105327
 
2472    461     admin
105328
 
2473    462     admin
105329
 
2474    463     admin
105330
 
2475    464     admin
105331
 
2476    465     admin
105332
 
2477    466     admin
105333
 
2478    467     admin
105334
 
2479    468     admin
105335
 
2480    469     admin
105336
 
2481    475     admin
105337
 
2482    476     admin
105338
 
2483    100     admin
105339
 
2484    63      admin
105340
 
2485    64      admin
105341
 
2486    65      admin
105342
 
2487    73      admin
105343
 
2488    121     admin
105344
 
2489    122     admin
105345
 
2490    101     admin
105346
 
2491    87      admin
105347
 
2492    123     admin
105348
 
2493    124     admin
105349
 
2494    68      admin
105350
 
2495    166     admin
105351
 
2496    167     admin
105352
 
2497    168     admin
105353
 
2498    169     admin
105354
 
2499    170     admin
105355
 
2500    236     admin
105356
 
2501    248     admin
105357
 
2502    253     admin
105358
 
2503    3       admin
105359
 
2504    345     admin
105360
 
2505    359     admin
105361
 
2506    388     admin
105362
 
2507    394     admin
105363
 
2508    399     admin
105364
 
2509    403     admin
105365
 
2510    404     admin
105366
 
2511    406     admin
105367
 
2512    445     admin
105368
 
2513    453     admin
105369
 
2514    471     admin
105370
 
2515    487     admin
105371
 
2516    488     admin
105372
 
2517    489     admin
105373
 
2518    490     admin
105374
 
2519    491     admin
105375
 
2520    187     admin
105376
 
2521    188     admin
105377
 
2522    259     admin
105378
 
2523    492     admin
105379
 
2548    510     admin
105380
 
2549    517     admin
105381
 
2550    518     admin
105382
 
2551    519     admin
105383
 
2552    520     admin
105384
 
2553    521     admin
105385
 
2554    516     admin
105386
 
2555    500     admin
105387
 
2556    506     admin
105388
 
2557    511     admin
105389
 
2558    512     admin
105390
 
2559    513     admin
105391
 
2560    514     admin
105392
 
2561    515     admin
105393
 
2566    528     admin
105394
 
2567    498     admin
105395
 
2568    501     admin
105396
 
2569    502     admin
105397
 
2570    503     admin
105398
 
2571    504     admin
105399
 
2572    505     admin
105400
 
2573    499     admin
105401
 
2574    507     admin
105402
 
2575    509     admin
105403
 
2576    522     admin
105404
 
2577    523     admin
105405
 
2578    524     admin
105406
 
2579    525     admin
105407
 
2580    526     admin
105408
 
2581    527     admin
105409
 
2582    529     admin
105410
 
2590    580     admin
105411
 
2591    581     admin
105412
 
2592    582     admin
105413
 
2593    583     admin
105414
 
2594    584     admin
105415
 
2595    585     admin
105416
 
2596    586     admin
105417
 
2597    587     admin
105418
 
2598    588     admin
105419
 
2599    589     admin
105420
 
2600    590     admin
105421
 
2601    591     admin
105422
 
2602    592     admin
105423
 
2603    593     admin
105424
 
2604    594     admin
105425
 
2605    595     admin
105426
 
2606    596     admin
105427
 
2607    597     admin
105428
 
2608    598     admin
105429
 
2609    599     admin
105430
 
2610    600     admin
105431
 
2611    601     admin
105432
 
2612    602     admin
105433
 
2613    603     admin
105434
 
2614    640     admin
105435
 
2615    641     admin
105436
 
2616    642     admin
105437
 
2617    643     admin
105438
 
\.
105439
 
 
105440
 
 
105441
 
--
105442
 
--
105443
 
 
105444
 
SELECT pg_catalog.setval('usrpriv_usrpriv_id_seq', 2617, true);
105445
 
 
105446
 
 
105447
 
--
105448
 
--
105449
 
 
105450
 
SELECT pg_catalog.setval('vend_vend_id_seq', 77, true);
105451
 
 
105452
 
 
105453
 
--
105454
 
--
105455
 
 
105456
 
SELECT pg_catalog.setval('vendaddr_vendaddr_id_seq', 33, true);
105457
 
 
105458
 
 
105459
 
--
105460
 
--
105461
 
 
105462
 
COPY vendaddrinfo (vendaddr_id, vendaddr_vend_id, vendaddr_code, vendaddr_name, vendaddr_comments, vendaddr_cntct_id, vendaddr_addr_id, vendaddr_taxzone_id) FROM stdin;
105463
 
\.
105464
 
 
105465
 
 
105466
 
--
105467
 
--
105468
 
 
105469
 
COPY vendinfo (vend_id, vend_name, vend_lastpurchdate, vend_active, vend_po, vend_comments, vend_pocomments, vend_number, vend_1099, vend_exported, vend_fobsource, vend_fob, vend_terms_id, vend_shipvia, vend_vendtype_id, vend_qualified, vend_ediemail, vend_ediemailbody, vend_edisubject, vend_edifilename, vend_accntnum, vend_emailpodelivery, vend_restrictpurch, vend_edicc, vend_curr_id, vend_cntct1_id, vend_cntct2_id, vend_addr_id, vend_match, vend_ach_enabled, vend_ach_accnttype, vend_ach_use_vendinfo, vend_ach_indiv_number, vend_ach_indiv_name, vend_ediemailhtml, vend_ach_routingnumber, vend_ach_accntnumber, vend_taxzone_id, vend_accnt_id, vend_expcat_id, vend_tax_id) FROM stdin;
105470
 
\.
105471
 
 
105472
 
 
105473
 
--
105474
 
--
105475
 
 
105476
 
COPY vendtype (vendtype_id, vendtype_code, vendtype_descrip) FROM stdin;
105477
 
\.
105478
 
 
105479
 
 
105480
 
--
105481
 
--
105482
 
 
105483
 
SELECT pg_catalog.setval('vendtype_vendtype_id_seq', 17, true);
105484
 
 
105485
 
 
105486
 
--
105487
 
--
105488
 
 
105489
 
COPY vodist (vodist_id, vodist_poitem_id, vodist_vohead_id, vodist_costelem_id, vodist_accnt_id, vodist_amount, vodist_qty, vodist_expcat_id, vodist_tax_id, vodist_discountable, vodist_notes) FROM stdin;
105490
 
\.
105491
 
 
105492
 
 
105493
 
--
105494
 
--
105495
 
 
105496
 
SELECT pg_catalog.setval('vodist_vodist_id_seq', 117, true);
105497
 
 
105498
 
 
105499
 
--
105500
 
--
105501
 
 
105502
 
COPY vohead (vohead_id, vohead_number, vohead_pohead_id, vohead_posted, vohead_duedate, vohead_invcnumber, vohead_amount, vohead_docdate, vohead_1099, vohead_distdate, vohead_reference, vohead_terms_id, vohead_vend_id, vohead_curr_id, vohead_adjtaxtype_id, vohead_freighttaxtype_id, vohead_gldistdate, vohead_misc, vohead_taxzone_id, vohead_taxtype_id, vohead_notes, vohead_recurring_vohead_id) FROM stdin;
105503
 
\.
105504
 
 
105505
 
 
105506
 
--
105507
 
--
105508
 
 
105509
 
SELECT pg_catalog.setval('vohead_vohead_id_seq', 174, true);
105510
 
 
105511
 
 
105512
 
--
105513
 
--
105514
 
 
105515
 
COPY voheadtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin;
105516
 
\.
105517
 
 
105518
 
 
105519
 
--
105520
 
--
105521
 
 
105522
 
COPY voitem (voitem_id, voitem_vohead_id, voitem_poitem_id, voitem_close, voitem_qty, voitem_freight, voitem_taxtype_id) FROM stdin;
105523
 
\.
105524
 
 
105525
 
 
105526
 
--
105527
 
--
105528
 
 
105529
 
SELECT pg_catalog.setval('voitem_voitem_id_seq', 110, true);
105530
 
 
105531
 
 
105532
 
--
105533
 
--
105534
 
 
105535
 
COPY voitemtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin;
105536
 
\.
105537
 
 
105538
 
 
105539
 
--
105540
 
--
105541
 
 
105542
 
SELECT pg_catalog.setval('warehous_warehous_id_seq', 34, true);
105543
 
 
105544
 
 
105545
 
--
105546
 
--
105547
 
 
105548
 
COPY whsezone (whsezone_id, whsezone_warehous_id, whsezone_name, whsezone_descrip) FROM stdin;
105549
 
\.
105550
 
 
105551
 
 
105552
 
--
105553
 
--
105554
 
 
105555
 
SELECT pg_catalog.setval('whsezone_whsezone_id_seq', 6, true);
105556
 
 
105557
 
 
105558
 
--
105559
 
--
105560
 
 
105561
 
COPY whsinfo (warehous_id, warehous_code, warehous_descrip, warehous_fob, warehous_active, warehous_counttag_prefix, warehous_counttag_number, warehous_bol_prefix, warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, warehous_aislesize, warehous_aislealpha, warehous_racksize, warehous_rackalpha, warehous_binsize, warehous_binalpha, warehous_locationsize, warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, warehous_shipping_commission, warehous_cntct_id, warehous_addr_id, warehous_transit, warehous_shipform_id, warehous_shipvia_id, warehous_shipcomments, warehous_costcat_id, warehous_sitetype_id, warehous_taxzone_id, warehous_sequence) FROM stdin;
105562
 
\.
105563
 
 
105564
 
 
105565
 
--
105566
 
--
105567
 
 
105568
 
COPY wo (wo_id, wo_number, wo_subnumber, wo_status, wo_itemsite_id, wo_startdate, wo_duedate, wo_ordtype, wo_ordid, wo_qtyord, wo_qtyrcv, wo_adhoc, wo_itemcfg_series, wo_imported, wo_wipvalue, wo_postedvalue, wo_prodnotes, wo_prj_id, wo_priority, wo_brdvalue, wo_bom_rev_id, wo_boo_rev_id, wo_cosmethod, wo_womatl_id, wo_username) FROM stdin;
105569
 
\.
105570
 
 
105571
 
 
105572
 
--
105573
 
--
105574
 
 
105575
 
SELECT pg_catalog.setval('wo_wo_id_seq', 445, true);
105576
 
 
105577
 
 
105578
 
--
105579
 
--
105580
 
 
105581
 
COPY womatl (womatl_id, womatl_wo_id, womatl_itemsite_id, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_lastissue, womatl_lastreturn, womatl_cost, womatl_picklist, womatl_status, womatl_imported, womatl_createwo, womatl_issuemethod, womatl_wooper_id, womatl_bomitem_id, womatl_duedate, womatl_schedatwooper, womatl_uom_id, womatl_notes, womatl_ref, womatl_scrapvalue, womatl_qtyfxd, womatl_issuewo, womatl_price) FROM stdin;
105582
 
\.
105583
 
 
105584
 
 
105585
 
--
105586
 
--
105587
 
 
105588
 
SELECT pg_catalog.setval('womatl_womatl_id_seq', 1292, true);
105589
 
 
105590
 
 
105591
 
--
105592
 
--
105593
 
 
105594
 
COPY womatlpost (womatlpost_id, womatlpost_womatl_id, womatlpost_invhist_id) FROM stdin;
105595
 
\.
105596
 
 
105597
 
 
105598
 
--
105599
 
--
105600
 
 
105601
 
SELECT pg_catalog.setval('womatlpost_womatlpost_id_seq', 1, false);
105602
 
 
105603
 
 
105604
 
--
105605
 
--
105606
 
 
105607
 
COPY womatlvar (womatlvar_id, womatlvar_number, womatlvar_subnumber, womatlvar_posted, womatlvar_parent_itemsite_id, womatlvar_component_itemsite_id, womatlvar_qtyord, womatlvar_qtyrcv, womatlvar_qtyiss, womatlvar_qtyper, womatlvar_scrap, womatlvar_wipscrap, womatlvar_bomitem_id, womatlvar_ref, womatlvar_notes, womatlvar_qtyfxd) FROM stdin;
105608
 
\.
105609
 
 
105610
 
 
105611
 
--
105612
 
--
105613
 
 
105614
 
SELECT pg_catalog.setval('womatlvar_womatlvar_id_seq', 44, true);
105615
 
 
105616
 
 
105617
 
--
105618
 
--
105619
 
 
105620
 
SELECT pg_catalog.setval('xcalitem_xcalitem_id_seq', 134, true);
105621
 
 
105622
 
 
105623
 
--
105624
 
--
105625
 
 
105626
 
COPY xsltmap (xsltmap_id, xsltmap_name, xsltmap_doctype, xsltmap_system, xsltmap_import, xsltmap_export) FROM stdin;
105627
 
1       Yahoo   OrderList       http://store.yahoo.com/doc/dtd/OrderList2.dtd   yahoo_to_xtupleapi.xsl  
105628
 
\.
105629
 
 
105630
 
 
105631
 
--
105632
 
--
105633
 
 
105634
 
SELECT pg_catalog.setval('xsltmap_xsltmap_id_seq', 1, true);
105635
 
 
105636
 
 
105637
 
--
105638
 
--
105639
 
 
105640
 
COPY yearperiod (yearperiod_id, yearperiod_start, yearperiod_end, yearperiod_closed) FROM stdin;
105641
 
\.
105642
 
 
105643
 
 
105644
 
--
105645
 
--
105646
 
 
105647
 
SELECT pg_catalog.setval('yearperiod_yearperiod_id_seq', 1, false);
105648
 
 
105649
 
 
105650
 
SET search_path = te, pg_catalog;
105651
 
 
105652
 
--
105653
 
--
105654
 
 
105655
 
COPY pkgcmd (cmd_id, cmd_module, cmd_title, cmd_descrip, cmd_privname, cmd_executable, cmd_name) FROM stdin;
105656
 
\.
105657
 
 
105658
 
 
105659
 
--
105660
 
--
105661
 
 
105662
 
COPY pkgcmdarg (cmdarg_id, cmdarg_cmd_id, cmdarg_order, cmdarg_arg) FROM stdin;
105663
 
\.
105664
 
 
105665
 
 
105666
 
--
105667
 
--
105668
 
 
105669
 
COPY pkgimage (image_id, image_name, image_descrip, image_data) FROM stdin;
105670
 
\.
105671
 
 
105672
 
 
105673
 
--
105674
 
--
105675
 
 
105676
 
COPY pkgmetasql (metasql_id, metasql_group, metasql_name, metasql_notes, metasql_query, metasql_lastuser, metasql_lastupdate, metasql_grade) FROM stdin;
105677
 
416     projects        detailte                -- Group: projects\n-- Name:  detailte\n-- Notes: \nSELECT prj_id, prj_number, prj_name,\n  CASE WHEN(prj_status='P') THEN <? value("planning") ?>\n       WHEN(prj_status='O') THEN <? value("open") ?>\n       WHEN(prj_status='C') THEN <? value("complete") ?>\n       ELSE <? value("undefined") ?>\n END AS prj_status, \n prj_username, \n  COALESCE(SUM(prjtask_hours_budget), 0.0) AS budget_hrs,\n  COALESCE(SUM(prjtask_hours_actual), 0.0) AS actual_hrs,\n  COALESCE(SUM(prjtask_hours_budget - prjtask_hours_actual), 0.0) AS balance_hrs, \n CASE WHEN COALESCE(SUM(prjtask_hours_budget - prjtask_hours_actual), 0.0) < 0 THEN \n   'error' END AS balance_hrs_qtforegroundrole, \n   'qty' AS budget_hrs_xtnumericrole, \n   'qty' AS actual_hrs_xtnumericrole, \n   'qty' AS balance_hrs_xtnumericrole \nFROM prj\nLEFT OUTER JOIN prjtask ON (prj_id=prjtask_prj_id)\n<? if not exists("showComplete") ?>\nWHERE (prj_status <> 'C')\n<? endif ?>\nGROUP BY prj_id, prj_number, prj_name, prj_status, prj_username \n ORDER BY prj_number;   \N      \N      0
105678
 
369     item    delteexp        Delete Item Expense Settings Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: item\n-- Name:  delteexp\n-- Notes: Delete Item Expense Settings\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM te.teexp\nWHERE (teexp_id=<? value("item_id") ?>);\n \N      \N      0
105679
 
370     item    insteexp        Insert item expense settings Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: item\n-- Name:  insteexp\n-- Notes: Insert item expense settings\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.teexp (\n  teexp_id,\n  teexp_expcat_id,\n  teexp_accnt_id )\nVALUES (\n  <? value("item_id") ?>,\n  <? value("expcat_id") ?>,\n  <? value("accnt_id") ?>);\n     \N      \N      0
105680
 
371     item    selteexp        Select Item Expense Settings Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: item\n-- Name:  selteexp\n-- Notes: Select Item Expense Settings\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  teexp_expcat_id,\n  teexp_accnt_id\nFROM te.teexp\nWHERE (teexp_id=<? value("item_id") ?>);\n \N      \N      0
105681
 
372     item    updteexp        Update item expense settings Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: item\n-- Name:  updteexp\n-- Notes: Update item expense settings\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.teexp SET\n  teexp_expcat_id=<? value("expcat_id") ?>,\n  teexp_accnt_id=<? value("accnt_id") ?>\nWHERE (teexp_id=<? value("item_id") ?>);\n   \N      \N      0
105682
 
373     project formatdates     Formats Dates for jsGantt Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: project\n-- Name:  formatdates\n-- Notes: Formats Dates for jsGantt\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n  EXTRACT('day' FROM start_date) || '/' || \n  EXTRACT('month' FROM start_date) || '/' || \n  EXTRACT('year' FROM start_date)  AS start_date,\n  EXTRACT('day' FROM due_date) || '/' || \n  EXTRACT('month' FROM due_date) || '/' || \n  EXTRACT('year' FROM due_date)  AS due_date\nFROM (\n  SELECT COALESCE(<? value("startDate") ?>,<? value("dueDate") ?>)::date AS start_date,\n  <? value("dueDate") ?>::date AS due_date\n) data\n    \N      \N      0
105683
 
374     project insteprj        Insert project time expense record Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: project\n-- Name:  insteprj\n-- Notes: Insert project time expense record\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.teprj (\n  teprj_prj_id,\n  teprj_cust_id,\n  teprj_rate,\n  teprj_curr_id )\nVALUES (\n  <? value("prj_id") ?>,\n  <? value("cust_id") ?>,\n  <? value("rate") ?>,\n  <? value("curr_id") ?> );\n       \N      \N      0
105684
 
375     project selteprj        Select Default Project Time Expense Info Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: project\n-- Name:  selteprj\n-- Notes: Select Default Project Time Expense Info\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT COALESCE(teprj_cust_id,-1) AS cust_id,\n  COALESCE(teprj_curr_id,-1) AS curr_id,\n  *\nFROM te.teprj\nWHERE (teprj_prj_id=<? value("prj_id") ?>);\n        \N      \N      0
105685
 
376     project updteprj        Update project time expense Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: project\n-- Name:  updteprj\n-- Notes: Update project time expense\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.teprj SET\n  teprj_cust_id=<? value("cust_id") ?>,\n  teprj_rate=<? value("rate") ?>,\n  teprj_curr_id=<? value("curr_id") ?>\nWHERE (teprj_id=<? value("teprj_id") ?>);\n   \N      \N      0
105686
 
378     projectGantt    jsgantt Loads jsGantt script file Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: projectGantt\n-- Name:  jsgantt\n-- Notes: Loads jsGantt script file\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT script_source FROM script WHERE script_name = 'jsGantt';\n    \N      \N      0
105687
 
379     projectGantt    jsganttcss      Loads jsGantt CSS file Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: projectGantt\n-- Name:  jsganttcss\n-- Notes: Loads jsGantt CSS file\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT script_source FROM script WHERE script_name = 'jsGanttCSS';\n \N      \N      0
105688
 
380     projectGantt    tasks   Load project tasks for jsGantt Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: projectGantt\n-- Name:  tasks\n-- Notes: Load project tasks for jsGantt\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  prjtask_id, \n  prjtask_name, \n  EXTRACT('day' FROM prjtask_start_date) || '/' || \n  EXTRACT('month' FROM prjtask_start_date) || '/' || \n  EXTRACT('year' FROM prjtask_start_date)  AS start_date,\n  EXTRACT('day' FROM prjtask_due_date) || '/' || \n  EXTRACT('month' FROM prjtask_due_date) || '/' || \n  EXTRACT('year' FROM prjtask_due_date)  AS due_date \nFROM (\n  SELECT \n    prjtask_id,\n    prjtask_name,\n    COALESCE(prjtask_start_date,prjtask_due_date) AS prjtask_start_date,\n    prjtask_due_date\n  FROM prjtask\n\n\n  WHERE (prjtask_prj_id = <? value("prj_id") ?>)\n) data;\n   \N      \N      0
105689
 
381     task    insteprjtask    Insert task time expense record Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: task\n-- Name:  insteprjtask\n-- Notes: Insert task time expense record\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.teprjtask (\n  teprjtask_prjtask_id,\n  teprjtask_cust_id,\n  teprjtask_rate,\n  teprjtask_curr_id,\n  teprjtask_item_id )\nVALUES (\n  <? value("prjtask_id") ?>,\n  <? value("cust_id") ?>,\n  <? value("rate") ?>,\n  <? value("curr_id") ?>,\n  <? value("item_id") ?> );\n    \N      \N      0
105690
 
382     task    selteprjtask    Select Default Task Time Expense Info Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: task\n-- Name:  selteprjtask\n-- Notes: Select Default Task Time Expense Info\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  COALESCE(teprjtask_cust_id,-1) AS cust_id,\n  COALESCE(teprjtask_curr_id,-1) AS curr_id,\n  COALESCE(teprjtask_item_id,-1) AS item_id,\n  *\nFROM te.teprjtask\nWHERE (teprjtask_prjtask_id=<? value("prjtask_id") ?>);\n        \N      \N      0
105691
 
383     task    updteprjtask    Update task time expense Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: task\n-- Name:  updteprjtask\n-- Notes: Update task time expense\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.teprjtask SET\n  teprjtask_cust_id=<? value("cust_id") ?>,\n  teprjtask_rate=<? value("rate") ?>,\n  teprjtask_curr_id=<? value("curr_id") ?>,\n  teprjtask_item_id=<? value("item_id") ?>\nWHERE (teprjtask_id=<? value("teprjtask_id") ?>);\n        \N      \N      0
105692
 
384     timeexpensehistory      detail   Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: timeexpensehistory\n-- Name:  detail\n-- Notes: \n--        Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n  teitem.*,\n  item_number, item_descrip1,\n  cust_number, cust_name,\n  tehead.*, tehead_number || '-' || teitem_linenumber::text AS f_sheet_number,\n  emp_code,\n  prj_number, prj_name,\n  prjtask_number, prjtask_name,\n  CASE WHEN (tehead_status='O') THEN \n    <? value("open") ?> \n  WHEN (tehead_status='A') THEN\n    <? value("approved") ?> \n  ELSE <? value("closed") ?>\n  END AS tehead_status_qtdisplayrole,\n  CASE WHEN (teitem_type='T') THEN\n    <? value("time") ?>\n       WHEN (teitem_type='E') THEN\n    <? value("expense") ?>\n       ELSE\n    <? value("error") ?>\n  END AS teitem_type_qtdisplayrole,\n<? if exists("timeOnly") ?>\n  '0' AS teitem_qty_xttotalrole,\n<? endif ?>\n<? if exists("expenseOnly") ?>\n  '0' AS teitem_total_xttotalrole,\n<? endif ?>\n<? if exists("includeFormatted") ?>\n  formatQty(teitem_qty) AS f_qty,\n  formatSalesPrice(teitem_rate) AS f_rate,\n  formatBoolYN(teitem_billable) AS f_billable,\n  formatExtPrice(teitem_total) AS f_total,\n  formatDate(teitem_workdate) AS f_workdate,\n<? endif ?>\n  'qty' AS teitem_qty_xtnumericrole,\n  'salesprice' AS teitem_rate_xtnumericrole,\n  'extprice' AS teitem_total_xtnumericrole\nFROM te.tehead\n  JOIN te.teitem ON (tehead_id = teitem_tehead_id)\n  JOIN emp ON (tehead_emp_id= emp_id)\n  JOIN item ON (teitem_item_id = item_id)\n  JOIN classcode ON (item_classcode_id=classcode_id)\n  LEFT OUTER JOIN custinfo ON (teitem_cust_id=cust_id)\n<? if exists("custtype_pattern") ?>\n  JOIN custtype ON (cust_custtype_id=custtype_id)\n<? endif ?>\n  JOIN prjtask ON (teitem_prjtask_id=prjtask_id)\n  JOIN prj ON (prjtask_prj_id=prj_id)\n<? if exists("custgrp_id") ?>\n  JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n<? endif ?>\n<? if exists("empgrp_id") ?>\n  JOIN empgrpitem ON (empgrpitem_emp_id=emp_id)\n<? endif ?>\n<? if exists("itemgrp_id") ?>\n  JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n<? endif ?>\nWHERE (true\n<? if exists("startDate") ?>\n  AND (teitem_workdate >= <? value("startDate") ?>)\n<? endif ?>\n<? if exists("endDate") ?>\n  AND (teitem_workdate <= <? value("endDate") ?>)\n<? endif ?>\n<? if exists("timeOnly") ?>\n  AND (teitem_type = 'T')\n<? endif ?>\n<? if exists("expenseOnly") ?>\n  AND (teitem_type = 'E')\n<? endif ?>\n<? if exists("prj_id") ?>\n  AND (prj_id = <? value("prj_id") ?>)\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND (cust_id = <? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND (cust_custtype_id = <? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND (custtype_code ~* <? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("emp_id") ?>\n  AND (emp_id = <? value("emp_id") ?>)\n<? endif ?>\n<? if exists("empgrp_id") ?>\n  AND   (empgrpitem_empgrp_id=<? value("empgrp_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND (item_id = <? value("item_id") ?>)\n<? endif ?>\n<? if exists("itemgrp_id") ?>\n  AND   (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n  AND (classcode_id = <? value("classcode_id") ?>)\n<? endif ?>\n<? if exists("classcode_pattern") ?>\n  AND (classcode_code ~* <? value("classcode_pattern") ?>)\n<? endif ?>\n) \nORDER BY tehead_number, teitem_linenumber;\n      \N      \N      0
105693
 
386     timeexpensesheet        delteitem        Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: timeexpensesheet\n-- Name:  delteitem\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM te.teitem\nWHERE teitem_id=<? value("teitem_id") ?>\n       \N      \N      0
105694
 
387     timeexpensesheet        detail   Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: timeexpensesheet\n-- Name:  detail\n-- Notes:\n--        Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n  teitem.*,\n  CASE WHEN (teitem_type = 'T') THEN\n    teitem_qty\n  END AS hours,\n  CASE WHEN (teitem_type = 'E') THEN\n    teitem_total\n  END AS expense,\n  item_number, item_descrip1,\n  cust_number, cust_name,\n  tehead.*, emp_code,\n  prj_number, prj_name,\n  prjtask_number, prjtask_name,\n  CASE WHEN teitem_type='E' THEN 0\n       ELSE COALESCE(teitem_empcost, te.calcRate(emp_wage, emp_wage_period))\n       END AS teitem_hrlycost,\n  CASE WHEN teitem_type='E' THEN 0\n       ELSE COALESCE(teitem_empcost, te.calcRate(emp_wage, emp_wage_period))\n       * teitem_qty END AS teitem_totalcost,\n  CASE WHEN (teitem_type='T') THEN\n    <? value("time") ?>\n       WHEN (teitem_type='E') THEN\n    <? value("expense") ?>\n       ELSE\n    <? value("error") ?>\n  END AS teitem_type_qtdisplayrole,\n  'qty' AS teitem_qty_xtnumericrole,\n  'qty' AS hours_xtnumericrole,\n  'qty' AS teitem_qty_xtnumericrole,\n  'qty' AS hours_xtnumericrole,\n  'extprice' AS expense_xtnumericrole,\n  '--' AS hours_xtnullrole,\n  '--' AS expense_xtnullrole,\n  'salesprice' AS teitem_rate_xtnumericrole,\n  'extprice' AS teitem_total_xtnumericrole,\n  0 AS hours_xttotalrole,\n  0 AS expense_xttotalrole,\n  firstLine(teitem_notes) AS f_notes\nFROM te.tehead\n  JOIN te.teitem ON (tehead_id = teitem_tehead_id)\n  JOIN emp ON (tehead_emp_id= emp_id)\n  JOIN item ON (teitem_item_id = item_id)\n  LEFT OUTER JOIN custinfo ON (teitem_cust_id=cust_id)\n  JOIN prjtask ON (teitem_prjtask_id=prjtask_id)\n  JOIN prj ON (prjtask_prj_id=prj_id)\nWHERE (tehead_id = <? value("tehead_id") ?>)\nORDER BY teitem_linenumber;\n    \N      \N      0
105695
 
388     timeexpensesheet        header   Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: timeexpensesheet\n-- Name:  header\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n  tehead.*, emp_code\nFROM te.tehead\n  JOIN emp ON (tehead_emp_id= emp_id)\nWHERE (tehead_id = <? value("tehead_id") ?>);\n       \N      \N      0
105696
 
389     timeexpensesheet        instehead        Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: timeexpensesheet\n-- Name:  instehead\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.tehead(\n  tehead_emp_id,\n  tehead_warehous_id,\n  tehead_weekending,\n  tehead_notes) \nVALUES (\n  <? value("emp_id") ?>,\n  <? value("warehous_id") ?>,\n  <? value("weekending") ?>,\n  <? value("notes") ?>)\nRETURNING *;\n       \N      \N      0
105697
 
390     timeexpensesheet        updtehead        Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: timeexpensesheet\n-- Name:  updtehead\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.tehead SET \n  tehead_emp_id = <? value("emp_id") ?>,\n  tehead_warehous_id = <? value("warehous_id") ?>,\n  tehead_notes = <? value("notes") ?> \nWHERE tehead_id=<? value("tehead_id") ?>;\n        \N      \N      0
105698
 
364     customer        seltecustrate   Select Default Customer Project Info Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: customer\n-- Name:  seltecustrate\n-- Notes: Select Default Customer Project Info\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *\nFROM te.tecustrate\nWHERE (tecustrate_cust_id=<? value("cust_id") ?>);\n      \N      \N      0
105699
 
391     timeexpensesheetitem    detail   Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: timeexpensesheetitem\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n (SELECT (COUNT(teitem_id) = 0)\n  FROM te.teitem maxte\n  WHERE ((maxte.teitem_tehead_id=tehead_id)\n   AND (maxte.teitem_linenumber > curr.teitem_linenumber))) AS ismax,\n COALESCE(curr.teitem_empcost, te.calcRate(emp_wage, emp_wage_period)) AS teitem_hrlycost\nFROM te.tehead\n  JOIN te.teitem curr ON (tehead_id = curr.teitem_tehead_id) \n  JOIN prjtask ON (prjtask_id=curr.teitem_prjtask_id)\n  JOIN prj ON (prj_id=prjtask_prj_id)\t\t\n  LEFT JOIN emp ON (tehead_emp_id = emp_id)\nWHERE (curr.teitem_id=<? value("teitem_id") ?>);\n    \N      \N      0
105700
 
392     timeexpensesheetitem    emptotals       Employee Hours Totals Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: timeexpensesheetitem\n-- Name:  emptotals\n-- Notes: Employee Hours Totals\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n  formatqty(coalesce(sum(day_hours),0)  + coalesce(<? value("hours") ?>,0)) as day_hours,\n  formatqty(coalesce(sum(sheet_hours),0) + coalesce(<? value("hours") ?>,0)) as sheet_hours\nFROM (\n  SELECT teitem_qty AS day_hours, 0 AS sheet_hours\n  FROM te.teitem\n   JOIN te.tehead ON (teitem_tehead_id=tehead_id)\n  WHERE ((tehead_emp_id=<? value("emp_id") ?>)\n   AND (teitem_id != <? value("teitem_id") ?>)\n   AND (teitem_workdate = <? value("workDate") ?>)\n   AND (teitem_type = 'T'))\n  UNION ALL\n  SELECT 0 AS day_hours, teitem_qty AS sheet_hours\n  FROM te.teitem\n   JOIN te.tehead ON (teitem_tehead_id=tehead_id)\n  WHERE ((tehead_emp_id=<? value("emp_id") ?>)\n   AND (teitem_id != <? value("teitem_id") ?>)\n   AND (tehead_id = <? value("tehead_id") ?>)\n   AND (teitem_type = 'T')) \n) AS data;\n      \N      \N      0
105701
 
393     timeexpensesheetitem    getcustinfo     Get customer currency rate Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: timeexpensesheetitem\n-- Name:  getcustinfo\n-- Notes: Get customer currency rate\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cust_curr_id \nFROM custinfo \nWHERE (cust_id=<? value("cust_id") ?>);\n \N      \N      0
105702
 
394     timeexpensesheetitem    gettask Get Project task list Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: timeexpensesheetitem\n-- Name: gettask\n-- Notes: Get Project task list\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  prjtask_id,\n  (prjtask_number || ' - ' || prjtask_name) AS name \nFROM prjtask \nWHERE (prjtask_prj_id = <? value("prj_id") ?>)\n<? if exists("active") ?>\n  AND (prjtask_status IN ('O','P'))\n<? endif ?>\nORDER by prjtask_number;\n      \N      \N      0
105703
 
395     timeexpensesheetitem    getterate       Get billing rate for Time Expense Item Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: timeexpensesheetitem\n-- Name:  getterate\n-- Notes: Get billing rate for Time Expense Item\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT COALESCE(rate,0) AS rate \nFROM (\n<? if exists("time") ?>\n-- Project Task Rate\nSELECT teprjtask_rate AS rate, \n  teprjtask_curr_id AS curr_id,\n  10 AS seq \nFROM te.teprjtask\nWHERE ((teprjtask_prjtask_id = <? value("task_id") ?>)\n  AND (teprjtask_curr_id IS NOT NULL))\nUNION\n\n-- Project Rate\nSELECT teprj_rate AS rate, \n  teprj_curr_id AS curr_id,\n  20 AS seq\nFROM te.teprj\nWHERE ((teprj_prj_id = <? value("prj_id") ?>)\n  AND (teprj_curr_id IS NOT NULL))\nUNION\n\n-- Employee Rate\nSELECT emp_extrate AS rate, \n  baseCurrId() AS curr_id,\n  30 AS seq\nFROM emp\nWHERE ((emp_id = <? value("emp_id") ?>)\n AND (emp_extrate > 0))\nUNION\n\n-- Customer Rate\nSELECT tecustrate_rate as rate, \n  tecustrate_curr_id,\n  40 AS seq\nFROM te.tecustrate\nWHERE ((tecustrate_cust_id = <? value("cust_id") ?>)\n  AND (tecustrate_curr_id IS NOT NULL))\nUNION\n<? endif ?>\n\n-- Item List Price\nSELECT item_listprice as rate, \n  baseCurrId(),\n  50 AS seq\nFROM item\nWHERE (item_id = <? value("item_id") ?>)\n) AS rates\nORDER BY seq\nLIMIT 1;\n   \N      \N      0
105704
 
396     timeexpensesheetitem    instask Insert a default Project Task Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: timeexpensesheetitem\n-- Name:  instask\n-- Notes: Insert a default Project Task\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO prjtask\nSELECT\n  nextval('prjtask_prjtask_id_seq'),\n  <? value("name") ?>,\n  <? value("name") ?>,\n  <? value("name") ?>,\n  <? value("prj_id") ?>,\n  null,\n  'O',\n  0,\n  0,\n  0,\n  0,\n  current_user,\n  <? value("startDate") ?>,\n  null,\n  <? value("startDate") ?>,\n  null,\n  current_user;\n     \N      \N      0
105705
 
397     timeexpensesheetitem    insteitem        Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: timeexpensesheetitem\n-- Name:  insteitem\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.teitem (\n  teitem_tehead_id,\n  teitem_linenumber,\n  teitem_type,\n  teitem_workdate,\n  teitem_cust_id,\n  teitem_po,\n  teitem_item_id,\n  teitem_uom_id,\n  teitem_qty,\n  teitem_rate,\n  teitem_total,\n  teitem_prjtask_id,\n  teitem_billable,\n  teitem_prepaid, \n  teitem_notes,\n  teitem_curr_id, \n  teitem_empcost )\nSELECT\n  <? value("teitem_tehead_id") ?>,\n  <? value("teitem_linenumber") ?>,\n  <? value("teitem_type") ?>,\n  <? value("teitem_workdate") ?>,\n  <? value("teitem_cust_id") ?>,\n  <? value("teitem_po") ?>,\n  <? value("teitem_item_id") ?>,\n  item_price_uom_id,\n  <? value("teitem_qty") ?>,\n  <? value("teitem_rate") ?>,\n  <? value("teitem_total") ?>,\n  <? value("teitem_prjtask_id") ?>,\n  <? value("teitem_billable") ?>,\n  <? value("teitem_prepaid") ?>,\n  <? value("teitem_notes") ?>,\n  <? value("teitem_curr_id") ?>,\n  <? value("teitem_empcost") ?>\nFROM item\nWHERE (item_id=<? value("teitem_item_id") ?>)\nRETURNING *;\n   \N      \N      0
105706
 
365     customer        updtecustrate   Update customer rate record Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: customer\n-- Name:  updtecustrate\n-- Notes: Update customer rate record\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.tecustrate SET\n  tecustrate_cust_id=<? value("cust_id") ?>,\n  tecustrate_rate=<? value("rate") ?>,\n  tecustrate_curr_id=<? value("curr_id") ?>\nWHERE (tecustrate_id=<? value("tecustrate_id") ?>)\nRETURNING *;\n  \N      \N      0
105707
 
398     timeexpensesheetitem    nextlinenum      Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: timeexpensesheetitem\n-- Name:  nextlinenum\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT  COALESCE(MAX(teitem_linenumber),0) +1 AS linenumber\nFROM te.teitem\nWHERE (teitem_tehead_id=<? value("tehead_id") ?>);\n \N      \N      0
105708
 
399     timeexpensesheetitem    taskbudg        Task Budget Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: timeexpensesheetitem\n-- Name:  taskbudg\n-- Notes: Task Budget\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n  formatqty(prjtask_hours_budget) as budget_hours,\n  formatqty(prjtask_hours_actual) as actual_hours,\n  formatmoney(prjtask_exp_budget) as budget_cost,\n  formatmoney(prjtask_exp_actual) as actual_cost \nFROM prjtask \nWHERE (prjtask_id = <? value("task_id") ?>)\n        \N      \N      0
105709
 
400     timeexpensesheetitem    taskdefaults    Project Task default values Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: timeexpensesheetitem\n-- Name:  taskdefaults\n-- Notes: Project Task default values\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  COALESCE(teprj_cust_id,teprjtask_cust_id,-1) AS cust_id,\n  COALESCE(teprjtask_item_id,-1) AS item_id\nFROM prjtask\n  JOIN prj ON (prj_id=prjtask_prj_id)\n  LEFT OUTER JOIN te.teprj ON (teprj_prj_id=prj_id)\n  LEFT OUTER JOIN te.teprjtask ON (teprjtask_prjtask_id=prjtask_id)\nWHERE (prjtask_id=<? value("prjtask_id") ?>)\n       \N      \N      0
105710
 
401     timeexpensesheetitem    taskrollup      Total hours and expenses including unapproved sheets Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: timeexpensesheetitem\n-- Name:  taskrollup\n-- Notes: Total hours and expenses including unapproved sheets\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  formatQty(SUM(total_hours)) AS total_hours,\n  formatMoney(SUM(total_expense)) AS total_expense\nFROM\n  (\n   SELECT \n     prjtask_hours_actual AS total_hours,\n     prjtask_exp_actual AS total_expense\n   FROM prjtask \n   WHERE prjtask_id = <? value("task_id") ?>\n   UNION\n   SELECT\n     SUM(teitem_qty) as total_hours,\n     0 as total_expense\n   FROM te.teitem \n     JOIN te.tehead ON (tehead_id=teitem_tehead_id)\n   WHERE teitem_prjtask_id = <? value("task_id") ?>\n    AND teitem_type = 'T' \n--    AND teitem_id != <? value("teitem_id") ?>\n    AND tehead_status = 'O'\n   UNION\n   SELECT \n     0 as total_hours,\n     SUM(teitem_total) AS total_expense\n   FROM te.teitem \n     JOIN te.tehead ON (tehead_id=teitem_tehead_id)\n   WHERE teitem_prjtask_id = <? value("task_id") ?>\n     AND teitem_type = 'E'\n--     AND teitem_id != <? value("teitem_id") ?>\n     AND tehead_status = 'O'\n) AS rollup;\n    \N      \N      0
105711
 
402     timeexpensesheetitem    teitemnext      Find Next Item Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: timeexpensesheetitem\n-- Name:  teitemnext\n-- Notes: Find Next Item\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT a.teitem_id\nFROM te.teitem AS a, te.teitem AS b\nWHERE ((a.teitem_tehead_id = b.teitem_tehead_id)\n  AND (a.teitem_linenumber > b.teitem_linenumber)\n  AND (b.teitem_id=<? value("teitem_id") ?>))\nORDER BY a.teitem_linenumber\nLIMIT 1;\n        \N      \N      0
105712
 
403     timeexpensesheetitem    teitemprev      Find previous item Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: timeexpensesheetitem\n-- Name:  teitemprev\n-- Notes: Find previous item\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("teitem_id") ?>\nSELECT a.teitem_id\nFROM te.teitem AS a, te.teitem AS b\nWHERE ( (a.teitem_tehead_id = b.teitem_tehead_id)\n  AND   (a.teitem_linenumber < b.teitem_linenumber)\n  AND   (b.teitem_id=<? value("teitem_id") ?>) ) \nORDER BY a.teitem_linenumber DESC\nLIMIT 1;\n<? else ?>\nSELECT teitem_id\nFROM te.teitem\nWHERE (teitem_tehead_id=<? value("tehead_id") ?>)\nORDER BY teitem_linenumber DESC\nLIMIT 1;\n<? endif ?>\n \N      \N      0
105713
 
404     timeexpensesheetitem    updteitem       Update Time Expense Item Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: timeexpensesheetitem\n-- Name:  updteitem\n-- Notes: Update Time Expense Item\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.teitem SET \n  teitem_tehead_id=<? value("teitem_tehead_id") ?>,\n  teitem_linenumber=<? value("teitem_linenumber") ?>,\n  teitem_type=<? value("teitem_type") ?>,\n  teitem_workdate=<? value("teitem_workdate") ?>,\n  teitem_cust_id=<? value("teitem_cust_id") ?>,\n  teitem_po=<? value("teitem_po") ?>,\n  teitem_item_id=<? value("teitem_item_id") ?>,\n  teitem_uom_id=item_price_uom_id,\n  teitem_qty=<? value("teitem_qty") ?>,\n  teitem_rate=<? value("teitem_rate") ?>,\n  teitem_total=<? value("teitem_total") ?>,\n  teitem_prjtask_id=<? value("teitem_prjtask_id") ?>,\n  teitem_billable=<? value("teitem_billable") ?>,\n  teitem_prepaid=<? value("teitem_prepaid") ?>, \n  teitem_notes=<? value("teitem_notes") ?>,\n  teitem_curr_id=<? value("teitem_curr_id") ?>,\n  teitem_empcost=<? value("teitem_empcost") ?>\nFROM item\nWHERE ((teitem_id=<? value("teitem_id") ?>)\n AND (teitem_item_id=item_id))\nRETURNING *;\n     \N      \N      0
105714
 
405     timeexpensesheets       approve Approve Time Expense Sheet Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: timeexpensesheets\n-- Name:  approve\n-- Notes: Approve Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.tehead SET \n  tehead_status = 'A' \nWHERE (tehead_id=<? value("tehead_id") ?>);\n   \N      \N      0
105715
 
362     customer        deltecustrate   Delete customer project defaults Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: customer\n-- Name:  deltecustrate\n-- Notes: Delete customer project defaults\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM te.tecustrate\nWHERE (tecustrate_cust_id=<? value("cust_id") ?>);\n     \N      \N      0
105716
 
363     customer        instecustrate   Insert customer rate record Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: customer\n-- Name:  instecustrate\n-- Notes: Insert customer rate record\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.tecustrate (\n  tecustrate_cust_id,\n  tecustrate_rate,\n  tecustrate_curr_id )\nVALUES (\n  <? value("cust_id") ?>,\n  <? value("rate") ?>,\n  <? value("curr_id") ?> )\nRETURNING *;\n  \N      \N      0
105717
 
377     projectGantt    getprj  Fetch Project Info Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: projectGantt\n-- Name:  getprj\n-- Notes: Fetch Project Info\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT prj_id\nFROM prj\nWHERE (prj_number=<? value("prjNumber") ?>);\n      \N      \N      0
105718
 
406     timeexpensesheets       close   Close Time Expense Sheet Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: timeexpensesheets\n-- Name:  close\n-- Notes: Close Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.tehead SET \n  tehead_status = 'C' \nWHERE (tehead_id=<? value("tehead_id") ?>);\n       \N      \N      0
105719
 
407     timeexpensesheets       detail  Time Expense Sheet List Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: timeexpensesheets\n-- Name:  detail\n-- Notes: Time Expense Sheet List\n--        Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n  tehead_id,\n  tehead_number,\n  tehead_weekending,\n  tehead_status,\n  emp_code,\n  invoiced,\n  vouchered,\n  posted,\n\n  SUM(tovoucher) AS total_e,\n  SUM(toinvoice) AS total_i,\n  \n  CASE WHEN (invoiced = 1) THEN <? value("yes") ?>\n       WHEN (invoiced = 0) THEN <? value("no") ?>\n       ELSE <? value("na") ?>\n  END AS invoiced_qtdisplayrole,\n  CASE WHEN (vouchered = 1) THEN <? value("yes") ?>\n       WHEN (vouchered = 0) THEN <? value("no") ?>\n       ELSE <? value("na") ?>\n  END AS vouchered_qtdisplayrole,\n  CASE WHEN (posted = 1) THEN <? value("yes") ?>\n       WHEN (posted = 0) THEN <? value("no") ?>\n       ELSE <? value("na") ?>\n  END AS posted_qtdisplayrole,\n  CASE WHEN (tehead_status='O') THEN\n       <? value("open") ?>\n  WHEN (tehead_status='A') THEN\n       <? value("approved") ?>\n  ELSE <? value("closed") ?>\n  END AS tehead_status_qtdisplayrole,\n  'curr' AS total_xtnumericrole,\n  CASE WHEN (invoiced = -1) THEN 'LightGray'\n       WHEN (invoiced = 0 AND tehead_status = 'A') THEN 'altemphasis'\n  END AS invoiced_qtforegroundrole,\n  CASE WHEN (vouchered = -1) THEN 'LightGray'\n       WHEN (vouchered = 0 AND tehead_status = 'A') THEN 'altemphasis'\n  END AS vouchered_qtforegroundrole,\n  CASE WHEN (posted = -1) THEN 'LightGray'\n       WHEN (posted = 0 AND tehead_status = 'A') THEN 'altemphasis'\n  END AS posted_qtforegroundrole,\n  CASE WHEN (tehead_status = 'O') THEN 'emphasis'\n       WHEN (tehead_status = 'A') THEN 'altemphasis'\n  END AS tehead_status_qtforegroundrole\n\n<? if exists("includeFormatted") ?> ,\n  formatMoney(SUM(toinvoice)) AS f_total,\n  formatDate(tehead_weekending) AS f_weekending\n<? endif ?>\n\nFROM (\n  SELECT\n    tehead_id,\n    tehead_number,\n    tehead_weekending,\n    tehead_status,\n    emp_code,  \n    CASE WHEN (teitem_type='E' AND teitem_prepaid = FALSE) \n            THEN teitem_total\n         WHEN (teitem_type='T' AND teemp_contractor = TRUE) \n            THEN COALESCE(teitem_empcost, te.calcRate(emp_wage, emp_wage_period))* teitem_qty\n         ELSE 0 \n    END as tovoucher,\n         \n    CASE WHEN (teitem_billable=TRUE) \n            THEN teitem_total\n         ELSE 0 \n    END AS toinvoice,\n\n    te.sheetstate(tehead_id, 'I') AS invoiced,\n    te.sheetstate(tehead_id, 'V') AS vouchered,\n    te.sheetstate(tehead_id, 'P') AS posted\n  FROM te.tehead\n    LEFT OUTER JOIN te.teitem ON (tehead_id=teitem_tehead_id)\n    JOIN emp ON (tehead_emp_id=emp_id)\n    LEFT OUTER JOIN te.teemp ON (tehead_emp_id=teemp_emp_id)\n  WHERE (\n        (tehead_weekending >= <? value("startDate") ?> )\n    AND (tehead_weekending <= <? value("endDate") ?> )\n    AND (tehead_status IN (<? literal("statusList") ?>))\n<? if exists("emp_id") ?>\n    AND \n        (tehead_emp_id=<? value("emp_id") ?>)\n<? endif ?>\n)) AS data\nGROUP BY\n    tehead_id,\n    tehead_number,\n    tehead_weekending,\n    tehead_status,\n    emp_code,\n    invoiced,\n    vouchered,\n    posted\nORDER BY tehead_number;\n \N      \N      0
105720
 
408     timeexpensesheets       invoice Invoice Time Expense Sheet Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: timeexpensesheets\n-- Name:  invoice\n-- Notes: Invoice Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT te.invoiceSheets(ARRAY[\n   <? foreach("tehead_ids") ?>\n     <? if not isfirst("tehead_ids") ?>\n      ,\n     <? endif ?>\n    <? value("tehead_ids") ?>\n   <? endforeach ?>\n]\n);\n        \N      \N      0
105721
 
409     timeexpensesheets       post    Post Time Expense Sheet Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: timeexpensesheets\n-- Name:  post\n-- Notes: Post Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT te.postSheet(<? value("tehead_id") ?>, <? value("phrase1") ?>, <? value("phrase2") ?>);\n     \N      \N      0
105722
 
410     timeexpensesheets       unapprove       Unapprove Time Expense Sheet Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: timeexpensesheets\n-- Name:  unapprove\n-- Notes: Unapprove Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.tehead SET \n  tehead_status = 'O' \nWHERE (tehead_id=<? value("tehead_id") ?>);\n       \N      \N      0
105723
 
411     timeexpensesheets       voucher Voucher Time Expense Sheet Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: timeexpensesheets\n-- Name:  voucher\n-- Notes: Voucher Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT te.voucherSheet(<? value("tehead_id") ?>);\n    \N      \N      0
105724
 
366     employee        insteemp        Insert employee time expense record Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: employee\n-- Name:  insteemp\n-- Notes: Insert employee time expense record\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.teemp (\n  teemp_emp_id,\n  teemp_contractor )\nVALUES (\n  <? value("emp_id") ?>,\n  <? value("contractor") ?>);\n    \N      \N      0
105725
 
367     employee        selteemp        Select Default Employee Time Expense Info Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: employee\n-- Name:  selteemp\n-- Notes: Select Default Employee Time Expense Info\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *\nFROM te.teemp\nWHERE (teemp_emp_id=<? value("emp_id") ?>);\n  \N      \N      0
105726
 
368     employee        updteemp        Update employee time expense Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: employee\n-- Name:  updteemp\n-- Notes: Update employee time expense\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.teemp SET\n  teemp_contractor=<? value("contractor") ?>\nWHERE (teemp_id=<? value("teemp_id") ?>);\n       \N      \N      0
105727
 
385     timeexpensesheet        deltehead       Delete Time Expense Sheet Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: timeexpensesheet\n-- Name:  deltehead\n-- Notes: Delete Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM docass WHERE (docass_source_id=<? value("tehead_id") ?> AND docass_source_type='TE');\nDELETE FROM te.tehead WHERE (tehead_id=<? value("tehead_id") ?>);\n \N      \N      0
105728
 
\.
105729
 
 
105730
 
 
105731
 
--
105732
 
--
105733
 
 
105734
 
COPY pkgpriv (priv_id, priv_module, priv_name, priv_descrip, priv_seq) FROM stdin;
105735
 
610     TE      MaintainTimeExpenseOthers       Allowed to Maintain Time/Exp Sheets for all users       \N
105736
 
611     TE      MaintainTimeExpenseSelf Allowed to Maintain Time/Exp Sheets     \N
105737
 
612     TE      MaintainTimeExpense     Allowed to Maintain Time/Exp Sheets     \N
105738
 
613     TE      CanViewRates    Allowed to view rates in the Time Entries       \N
105739
 
646     TE      MaintainEmpCostAll      Allowed to maintain employee costs for all users        \N
105740
 
647     TE      MaintainEmpCostSelf     Allowed to maintain own employee costs  \N
105741
 
614     TE      CanApprove      Allowed to Approve Time/Exp Sheets      \N
105742
 
615     TE      allowInvoicing  Allowed to Invoice Time/Exp Sheets      \N
105743
 
616     TE      allowVouchering Allowed to Voucher Time/Exp Sheets      \N
105744
 
617     TE      PostTimeSheets  Allowed to Post Time Sheets     \N
105745
 
618     TE      ViewTimeExpenseHistory  Allowed to view Time Expense Sheet history      \N
105746
 
\.
105747
 
 
105748
 
 
105749
 
--
105750
 
--
105751
 
 
105752
 
COPY pkgreport (report_id, report_name, report_sys, report_source, report_descrip, report_grade, report_loaddate) FROM stdin;
105753
 
440     TimeExpenseHistory      \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Expense History</title>\n <name>TimeExpenseHistory</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>timeexpensehistory</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>95</height>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>6.4</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time and Expense History</string>\n  </label>\n  <label>\n   <rect>\n    <x>547</x>\n    <y>58.3333</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Quantity</string>\n  </label>\n  <label>\n   <rect>\n    <x>625.333</x>\n    <y>58.3333</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Billable</string>\n  </label>\n  <line>\n   <xstart>3.33333</xstart>\n   <ystart>89.3333</ystart>\n   <xend>743.333</xend>\n   <yend>89.3333</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>395.333</x>\n    <y>72.3333</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item #</string>\n  </label>\n  <label>\n   <rect>\n    <x>204</x>\n    <y>58.3333</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Project #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>393.333</x>\n    <y>58.3333</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Task #</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>72.3333</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Work Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>478.333</x>\n    <y>58.3333</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>293.333</x>\n    <y>58.3333</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>478.333</x>\n    <y>72.3333</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>669.333</x>\n    <y>58.3</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Extended</string>\n  </label>\n  <label>\n   <rect>\n    <x>293.333</x>\n    <y>72.3333</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>58.3333</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sheet #</string>\n  </label>\n  <label>\n   <rect>\n    <x>203.333</x>\n    <y>72.3333</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>72.3333</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Employee #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>58.3</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>72.3</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>49</height>\n  <label>\n   <rect>\n    <x>294</x>\n    <y>9.33333</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>204</x>\n    <y>9.33333</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Project #</string>\n  </label>\n  <line>\n   <xstart>6.33333</xstart>\n   <ystart>41.3333</ystart>\n   <xend>746.333</xend>\n   <yend>41.3333</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>9.33333</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sheet #</string>\n  </label>\n  <label>\n   <rect>\n    <x>481.333</x>\n    <y>24</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Description</string>\n  </label>\n  <label>\n   <rect>\n    <x>398.333</x>\n    <y>24</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Item #</string>\n  </label>\n  <label>\n   <rect>\n    <x>396.333</x>\n    <y>9.33333</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Task #</string>\n  </label>\n  <label>\n   <rect>\n    <x>481.333</x>\n    <y>9.33333</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>203.333</x>\n    <y>24</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Customer #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>293.333</x>\n    <y>24</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Name</string>\n  </label>\n  <label>\n   <rect>\n    <x>25</x>\n    <y>24</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Work Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>669.333</x>\n    <y>9.33</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Extended</string>\n  </label>\n  <label>\n   <rect>\n    <x>549</x>\n    <y>9.33333</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Quantity</string>\n  </label>\n  <label>\n   <rect>\n    <x>627.333</x>\n    <y>9.33333</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Billable</string>\n  </label>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>24</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Employee #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>112</x>\n    <y>9.33</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Type</string>\n  </label>\n  <label>\n   <rect>\n    <x>628</x>\n    <y>24</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>40</height>\n   <field>\n    <rect>\n     <x>394</x>\n     <y>19</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>480</x>\n     <y>19</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>394</x>\n     <y>3.84333</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prjtask_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>479</x>\n     <y>3.84333</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prjtask_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>547</x>\n     <y>3.84333</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>626</x>\n     <y>3.84333</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_billable</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>204</x>\n     <y>19</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>294</x>\n     <y>3.84333</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prj_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>204</x>\n     <y>3.84333</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>prj_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>294</x>\n     <y>19</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>3.84333</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>tehead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>669.333</x>\n     <y>3.84333</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_total</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>25</x>\n     <y>19</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_workdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>111.667</x>\n     <y>4.33333</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>teitem_type_qtdisplayrole</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>111.667</x>\n     <y>19</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>emp_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>627</x>\n     <y>19</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>tehead_status_qtdisplayrole</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n <rptfoot>\n  <height>35</height>\n  <field>\n   <rect>\n    <x>549</x>\n    <y>4.33</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>teitem_qty</column>\n   </data>\n   <format builtin="true">money</format>\n   <tracktotal subtotal="true"/>\n  </field>\n  <label>\n   <rect>\n    <x>369</x>\n    <y>4.33</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Total:</string>\n  </label>\n  <field>\n   <rect>\n    <x>668</x>\n    <y>4</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <data>\n    <query>detail</query>\n    <column>teitem_total</column>\n   </data>\n   <format>%0.2f</format>\n   <tracktotal subtotal="true"/>\n  </field>\n </rptfoot>\n</report>\n  \N      0       \N
105754
 
441     TimeExpenseSheet        \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Expense Sheet</title>\n <name>TimeExpenseSheet</name>\n <description></description>\n <parameter default="2000" active="true" listtype="dynamic" type="string" name="tehead_id">\n  <description></description>\n  <query>SELECT tehead_id, tehead_number || '-' || tehead_username FROM tehead ORDER By tehead_number DESC;</query>\n </parameter>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource>\n  <name>header</name>\n  <sql>SELECT \n  tehead_number,\n  formatDate(tehead_weekending) AS f_weekending,\n  warehous_code,\n  emp_code || ' - ' || COALESCE(cntct_name,'') AS f_employee,\n  CASE WHEN (tehead_status='O') THEN \n    &lt;? value("open") ?> \n  WHEN (tehead_status='A') THEN\n    &lt;? value("approved") ?> \n  ELSE &lt;? value("closed") ?>\n  END AS f_status,\n  tehead_notes\nFROM te.tehead\n JOIN emp ON (tehead_emp_id=emp_id)\n JOIN whsinfo ON (warehous_id=tehead_warehous_id)\n LEFT OUTER JOIN cntct ON (emp_cntct_id=cntct_id)\nWHERE (tehead_id=&lt;? value("tehead_id") ?>);\n</sql>\n </querysource>\n <querysource>\n  <name>time</name>\n  <sql>SELECT\n  teitem_tehead_id,\n  formatDate(teitem_workdate) AS f_workdate,\n  prj_number,\n  prj_name,\n  prjtask_number,\n  prjtask_name,\n  cust_number,\n  cust_name,\n  item_number,\n  item_descrip1,\n  formatQty(teitem_qty) AS f_hours,\n  teitem_qty,\n  CASE WHEN (teitem_billable) THEN\n    formatMoney(teitem_total)\n  ELSE ' -- ' END AS f_billing_total,\n  CASE WHEN (teitem_billable) THEN\n    teitem_total\n  ELSE 0 END AS billing_total,\n  formatBoolYN(teitem_billable) AS f_billable,\n  teitem_notes\nFROM te.teitem\n  JOIN prjtask ON (teitem_prjtask_id=prjtask_id)\n  JOIN prj ON (prjtask_prj_id=prj_id)\n  JOIN item ON (item_id=teitem_item_id)\n  LEFT OUTER JOIN custinfo ON (cust_id=teitem_cust_id)\nWHERE ((teitem_tehead_id=&lt;? value("tehead_id") ?>)\n  AND (teitem_type='T'))\nORDER BY teitem_tehead_id, teitem_workdate, teitem_linenumber;</sql>\n </querysource>\n <querysource>\n  <name>expense</name>\n  <sql>SELECT\n  teitem_tehead_id,\n  formatDate(teitem_workdate) AS f_workdate,\n  prj_number,\n  prj_name,\n  prjtask_number,\n  prjtask_name,\n  cust_number,\n  cust_name,\n  item_number,\n  item_descrip1,\n  formatQty(teitem_qty) AS f_qty,\n  teitem_qty,\n  formatMoney(teitem_total) AS f_total,\n  teitem_total,\n  CASE WHEN (teitem_billable) THEN\n    formatMoney(teitem_total)\n  ELSE ' -- ' END AS f_billing_total,\n  CASE WHEN (teitem_type = 'E') THEN\n    teitem_total\n  ELSE 0 END AS expense_total,\n  CASE WHEN (teitem_billable) THEN\n    teitem_total\n  ELSE 0 END AS billing_total,\n  formatBoolYN(teitem_billable) AS f_billable,\n  teitem_notes\nFROM te.teitem\n  JOIN prjtask ON (teitem_prjtask_id=prjtask_id)\n  JOIN prj ON (prjtask_prj_id=prj_id)\n  JOIN item ON (item_id=teitem_item_id)\n  LEFT OUTER JOIN custinfo ON (cust_id=teitem_cust_id)\nWHERE ((teitem_tehead_id=&lt;? value("tehead_id") ?>)\n  AND (teitem_type='E'))\nORDER BY teitem_workdate, teitem_linenumber;</sql>\n </querysource>\n <querysource>\n  <name>prjsum</name>\n  <sql>SELECT\n  teitem_tehead_id,\n  prj_number,\n  SUM(teitem_qty) AS total_hours,\n  SUM(teitem_total) AS billing_total,\nCASE WHEN (\n            (checkprivilege('MaintainEmpCostAll') \n              OR \n              (checkprivilege('MaintainEmpCostSelf') \n               AND \n               current_user = (SELECT tehead_username \n                              FROM te.tehead \n                              WHERE teitem_tehead_id = tehead_id)\n              ) \n            )\n          )\n           THEN SUM(teitem_empcost * teitem_qty)\n           ELSE 0 END AS cost_total,\nCASE WHEN (\n            (checkprivilege('MaintainEmpCostAll') \n              OR\n              (checkprivilege('MaintainEmpCostSelf')\n               AND \n               current_user = (SELECT tehead_username \n                               FROM te.tehead \n                               WHERE teitem_tehead_id = tehead_id)\n              )\n            )\n           )\n           THEN 'Cost'\n           ELSE 'No Priv' END AS title\n\nFROM te.teitem\n  JOIN prjtask ON (teitem_prjtask_id=prjtask_id)\n  JOIN prj ON (prjtask_prj_id=prj_id)\n  JOIN item ON (item_id=teitem_item_id)\n  LEFT OUTER JOIN custinfo ON (cust_id=teitem_cust_id)\nWHERE ((teitem_tehead_id=&lt;? value("tehead_id") ?>)\n  AND (teitem_type='T'))\nGROUP BY teitem_tehead_id, prj_number;</sql>\n </querysource>\n <querysource>\n  <name>prjexpsum</name>\n  <sql>SELECT\n  teitem_tehead_id,\n  prj_number,\n  SUM(teitem_total) AS total\nFROM te.teitem\n  JOIN prjtask ON (teitem_prjtask_id=prjtask_id)\n  JOIN prj ON (prjtask_prj_id=prj_id)\n  JOIN item ON (item_id=teitem_item_id)\n  LEFT OUTER JOIN custinfo ON (cust_id=teitem_cust_id)\nWHERE ((teitem_tehead_id=&lt;? value("tehead_id") ?>)\n  AND (teitem_type='E'))\nGROUP BY teitem_tehead_id, prj_number;</sql>\n </querysource>\n <rpthead>\n  <height>110</height>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>5</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time and Expense Sheet</string>\n  </label>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>50</y>\n    <width>83</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Week Of:</string>\n  </label>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>65</y>\n    <width>83</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Site:</string>\n  </label>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>80</y>\n    <width>83</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Employee:</string>\n  </label>\n  <label>\n   <rect>\n    <x>35</x>\n    <y>35</y>\n    <width>83</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Sheet #:</string>\n  </label>\n  <label>\n   <rect>\n    <x>260</x>\n    <y>80</y>\n    <width>83</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Status:</string>\n  </label>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>35</y>\n    <width>175</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>header</query>\n    <column>tehead_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>50</y>\n    <width>175</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>header</query>\n    <column>f_weekending</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>65</y>\n    <width>175</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>header</query>\n    <column>warehous_code</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>135</x>\n    <y>80</y>\n    <width>175</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>header</query>\n    <column>f_employee</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>355</x>\n    <y>80</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>header</query>\n    <column>f_status</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>5</x>\n    <y>115</y>\n    <width>450</width>\n    <height>22</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>12</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Time</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>14</height>\n </pghead>\n <section>\n  <name>time</name>\n  <group>\n   <name>timefoot</name>\n   <column>teitem_tehead_id</column>\n   <head>\n    <height>70</height>\n    <label>\n     <rect>\n      <x>108.667</x>\n      <y>45.3333</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Customer #:</string>\n    </label>\n    <label>\n     <rect>\n      <x>198.667</x>\n      <y>31.3333</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Name</string>\n    </label>\n    <label>\n     <rect>\n      <x>383.667</x>\n      <y>45.3333</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Description</string>\n    </label>\n    <label>\n     <rect>\n      <x>198.667</x>\n      <y>45.3333</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Name</string>\n    </label>\n    <label>\n     <rect>\n      <x>9.33333</x>\n      <y>31.3333</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Work Date</string>\n    </label>\n    <label>\n     <rect>\n      <x>480</x>\n      <y>31.3</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Hours</string>\n    </label>\n    <label>\n     <rect>\n      <x>625.333</x>\n      <y>31.3333</y>\n      <width>50</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Billable</string>\n    </label>\n    <label>\n     <rect>\n      <x>300.667</x>\n      <y>45.3333</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Item #</string>\n    </label>\n    <label>\n     <rect>\n      <x>298.667</x>\n      <y>31.3333</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Task #</string>\n    </label>\n    <label>\n     <rect>\n      <x>383.667</x>\n      <y>30.6667</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Name</string>\n    </label>\n    <label>\n     <rect>\n      <x>109.333</x>\n      <y>31.3333</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Project #:</string>\n    </label>\n    <label>\n     <rect>\n      <x>655</x>\n      <y>31.3333</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Billing Total</string>\n    </label>\n    <line>\n     <xstart>3.33333</xstart>\n     <ystart>61.333</ystart>\n     <xend>743.333</xend>\n     <yend>61.333</yend>\n     <weight>2</weight>\n    </line>\n   </head>\n   <foot>\n    <height>15</height>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>time</query>\n   </key>\n   <height>45</height>\n   <field>\n    <rect>\n     <x>625</x>\n     <y>5</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>time</query>\n     <column>f_billable</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>5</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>time</query>\n     <column>prj_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>385</x>\n     <y>5</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>time</query>\n     <column>prjtask_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>5</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>time</query>\n     <column>prj_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>5</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>time</query>\n     <column>f_billing_total</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>5</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>time</query>\n     <column>f_hours</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>5</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>time</query>\n     <column>f_workdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>5</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>time</query>\n     <column>prjtask_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>time</query>\n     <column>cust_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>15</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>time</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>15</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>time</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>385</x>\n     <y>15</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>time</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <text>\n    <rect>\n     <x>10</x>\n     <y>30</y>\n     <width>370</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>time</query>\n     <column>teitem_notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <section>\n  <name>projsum</name>\n  <pagebreak when="at end"/>\n  <group>\n   <name>prj_sum</name>\n   <column>teitem_tehead_id</column>\n   <pagebreak when="after foot"/>\n   <head>\n    <height>50</height>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>10</y>\n      <width>190</width>\n      <height>22</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>12</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Project Time Summary</string>\n    </label>\n    <label>\n     <rect>\n      <x>380</x>\n      <y>30</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Project #</string>\n    </label>\n    <label>\n     <rect>\n      <x>465</x>\n      <y>30</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total Hours</string>\n    </label>\n    <label>\n     <rect>\n      <x>685</x>\n      <y>30</y>\n      <width>60</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Billing Total</string>\n    </label>\n    <line>\n     <xstart>3.33333</xstart>\n     <ystart>46.333</ystart>\n     <xend>743.333</xend>\n     <yend>46.333</yend>\n     <weight>2</weight>\n    </line>\n    <field>\n     <rect>\n      <x>615</x>\n      <y>30</y>\n      <width>50</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>prjsum</query>\n      <column>title</column>\n     </data>\n    </field>\n   </head>\n   <foot>\n    <height>30</height>\n    <field>\n     <rect>\n      <x>695</x>\n      <y>5</y>\n      <width>50</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>prjsum</query>\n      <column>billing_total</column>\n     </data>\n     <format builtin="true">money</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <field>\n     <rect>\n      <x>505</x>\n      <y>5</y>\n      <width>50</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>prjsum</query>\n      <column>total_hours</column>\n     </data>\n     <format builtin="true">qty</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <line>\n     <xstart>360</xstart>\n     <ystart>5</ystart>\n     <xend>745</xend>\n     <yend>5</yend>\n     <weight>2</weight>\n    </line>\n    <line>\n     <xstart>420</xstart>\n     <ystart>5</ystart>\n     <xend>520</xend>\n     <yend>5</yend>\n     <weight>0</weight>\n    </line>\n    <field>\n     <rect>\n      <x>615</x>\n      <y>5</y>\n      <width>50</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>prjsum</query>\n      <column>cost_total</column>\n     </data>\n     <format builtin="true">money</format>\n     <tracktotal subtotal="true"/>\n    </field>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>prjsum</query>\n   </key>\n   <height>25</height>\n   <field>\n    <rect>\n     <x>695</x>\n     <y>5</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>prjsum</query>\n     <column>billing_total</column>\n    </data>\n    <format builtin="true">money</format>\n   </field>\n   <field>\n    <rect>\n     <x>615</x>\n     <y>5</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>prjsum</query>\n     <column>cost_total</column>\n    </data>\n    <format builtin="true">money</format>\n   </field>\n   <field>\n    <rect>\n     <x>380</x>\n     <y>5</y>\n     <width>115</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>prjsum</query>\n     <column>prj_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>505</x>\n     <y>5</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>prjsum</query>\n     <column>total_hours</column>\n    </data>\n    <format builtin="true">qty</format>\n   </field>\n  </detail>\n </section>\n <section>\n  <name>expense</name>\n  <group>\n   <name>expdetail</name>\n   <column>teitem_tehead_id</column>\n   <head>\n    <height>65</height>\n    <label>\n     <rect>\n      <x>109.333</x>\n      <y>44</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Customer #:</string>\n    </label>\n    <label>\n     <rect>\n      <x>199.333</x>\n      <y>30</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Name</string>\n    </label>\n    <label>\n     <rect>\n      <x>384.333</x>\n      <y>44</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Description</string>\n    </label>\n    <label>\n     <rect>\n      <x>199.333</x>\n      <y>44</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Name</string>\n    </label>\n    <label>\n     <rect>\n      <x>10</x>\n      <y>30</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Work Date</string>\n    </label>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>5</y>\n      <width>450</width>\n      <height>22</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>12</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Expenses</string>\n    </label>\n    <label>\n     <rect>\n      <x>465</x>\n      <y>30</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Quantity</string>\n    </label>\n    <label>\n     <rect>\n      <x>625.333</x>\n      <y>30</y>\n      <width>50</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <hcenter/>\n     <vcenter/>\n     <string>Billable</string>\n    </label>\n    <label>\n     <rect>\n      <x>301.333</x>\n      <y>44</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Item #</string>\n    </label>\n    <label>\n     <rect>\n      <x>299.333</x>\n      <y>30</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Task #</string>\n    </label>\n    <label>\n     <rect>\n      <x>384.333</x>\n      <y>29.3333</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Name</string>\n    </label>\n    <label>\n     <rect>\n      <x>110</x>\n      <y>30</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Project #:</string>\n    </label>\n    <label>\n     <rect>\n      <x>670</x>\n      <y>30</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Billing Total</string>\n    </label>\n    <label>\n     <rect>\n      <x>550</x>\n      <y>30</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total</string>\n    </label>\n   </head>\n   <foot>\n    <height>35</height>\n    <field>\n     <rect>\n      <x>670</x>\n      <y>5</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>expense</query>\n      <column>billing_total</column>\n     </data>\n     <format builtin="true">money</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <label>\n     <rect>\n      <x>370</x>\n      <y>3.33</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Total Expenses:</string>\n    </label>\n    <field>\n     <rect>\n      <x>550</x>\n      <y>3.33</y>\n      <width>75</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>expense</query>\n      <column>expense_total</column>\n     </data>\n     <format builtin="true">money</format>\n     <tracktotal subtotal="true"/>\n    </field>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>expense</query>\n   </key>\n   <height>50</height>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>20</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>expense</query>\n     <column>item_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>385</x>\n     <y>20</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>expense</query>\n     <column>item_descrip1</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>300</x>\n     <y>5</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>expense</query>\n     <column>prjtask_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>385</x>\n     <y>5</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>expense</query>\n     <column>prjtask_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>490</x>\n     <y>5</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>expense</query>\n     <column>f_qty</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>625</x>\n     <y>5</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>expense</query>\n     <column>f_billable</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>670</x>\n     <y>5</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>expense</query>\n     <column>f_billing_total</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>20</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>expense</query>\n     <column>cust_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>5</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>expense</query>\n     <column>prj_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110</x>\n     <y>5</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>expense</query>\n     <column>prj_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>200</x>\n     <y>20</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>expense</query>\n     <column>cust_name</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>10</x>\n     <y>5</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>expense</query>\n     <column>f_workdate</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>550</x>\n     <y>5</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>expense</query>\n     <column>f_total</column>\n    </data>\n   </field>\n   <line>\n    <xstart>4.13052</xstart>\n    <ystart>-5.20281</ystart>\n    <xend>744.13</xend>\n    <yend>-5.20281</yend>\n    <weight>2</weight>\n   </line>\n   <text>\n    <rect>\n     <x>110</x>\n     <y>35</y>\n     <width>600</width>\n     <height>15</height>\n    </rect>\n    <bottompad>0</bottompad>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>normal</weight>\n    </font>\n    <left/>\n    <top/>\n    <data>\n     <query>expense</query>\n     <column>teitem_notes</column>\n    </data>\n   </text>\n  </detail>\n </section>\n <section>\n  <name>prjexpsum</name>\n  <group>\n   <name>prjexpsum</name>\n   <column>teitem_tehead_id</column>\n   <head>\n    <height>60</height>\n    <label>\n     <rect>\n      <x>5</x>\n      <y>5</y>\n      <width>230</width>\n      <height>22</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>12</size>\n      <weight>bold</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Project Expense Summary</string>\n    </label>\n    <label>\n     <rect>\n      <x>685</x>\n      <y>35</y>\n      <width>60</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <string>Expenses</string>\n    </label>\n    <label>\n     <rect>\n      <x>370</x>\n      <y>35</y>\n      <width>90</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>normal</weight>\n     </font>\n     <left/>\n     <vcenter/>\n     <string>Project #</string>\n    </label>\n    <line>\n     <xstart>4.13052</xstart>\n     <ystart>53.1454</ystart>\n     <xend>744.13</xend>\n     <yend>53.1454</yend>\n     <weight>2</weight>\n    </line>\n   </head>\n   <foot>\n    <height>40</height>\n    <field>\n     <rect>\n      <x>695</x>\n      <y>5</y>\n      <width>50</width>\n      <height>15</height>\n     </rect>\n     <font>\n      <face>Arial</face>\n      <size>8</size>\n      <weight>bold</weight>\n     </font>\n     <right/>\n     <vcenter/>\n     <data>\n      <query>prjexpsum</query>\n      <column>total</column>\n     </data>\n     <format builtin="true">money</format>\n     <tracktotal subtotal="true"/>\n    </field>\n    <line>\n     <xstart>655</xstart>\n     <ystart>5</ystart>\n     <xend>745</xend>\n     <yend>5</yend>\n     <weight>2</weight>\n    </line>\n   </foot>\n  </group>\n  <detail>\n   <key>\n    <query>prjexpsum</query>\n   </key>\n   <height>25</height>\n   <field>\n    <rect>\n     <x>370</x>\n     <y>5</y>\n     <width>115</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>prjexpsum</query>\n     <column>prj_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>695</x>\n     <y>5</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>prjexpsum</query>\n     <column>total</column>\n    </data>\n    <format builtin="true">money</format>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>25</height>\n  <field>\n   <rect>\n    <x>680</x>\n    <y>5</y>\n    <width>15</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>5</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>5</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n  <label>\n   <rect>\n    <x>630</x>\n    <y>5</y>\n    <width>45</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <label>\n   <rect>\n    <x>690</x>\n    <y>5</y>\n    <width>15</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>of</string>\n  </label>\n  <field>\n   <rect>\n    <x>710</x>\n    <y>5</y>\n    <width>20</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_count</column>\n   </data>\n  </field>\n </pgfoot>\n <rptfoot>\n  <height>30</height>\n  <text>\n   <rect>\n    <x>110</x>\n    <y>5</y>\n    <width>600</width>\n    <height>15</height>\n   </rect>\n   <bottompad>0</bottompad>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <top/>\n   <data>\n    <query>header</query>\n    <column>tehead_notes</column>\n   </data>\n  </text>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>5</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Notes:</string>\n  </label>\n </rptfoot>\n</report>\n \N      0       \N
105755
 
442     TimeExpenseSheets       \N      <!DOCTYPE openRPTDef>\n<report>\n <title>Time Expense Sheets</title>\n <name>TimeExpenseSheets</name>\n <description></description>\n <grid>\n  <snap/>\n  <show/>\n  <x>0.05</x>\n  <y>0.05</y>\n </grid>\n <size>Letter</size>\n <portrait/>\n <topmargin>50</topmargin>\n <bottommargin>50</bottommargin>\n <rightmargin>50</rightmargin>\n <leftmargin>50</leftmargin>\n <querysource loadFromDb="true">\n  <name>detail</name>\n  <mqlgroup>timeexpensesheets</mqlgroup>\n  <mqlname>detail</mqlname>\n </querysource>\n <rpthead>\n  <height>131</height>\n  <label>\n   <rect>\n    <x>113</x>\n    <y>112</y>\n    <width>83</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>112</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Employee</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>112</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Invoiced</string>\n  </label>\n  <line>\n   <xstart>10</xstart>\n   <ystart>130</ystart>\n   <xend>750</xend>\n   <yend>130</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>112</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vouchered</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>112</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>700</x>\n    <y>112</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>112</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Extended</string>\n  </label>\n  <label>\n   <rect>\n    <x>295</x>\n    <y>6.40117</y>\n    <width>450</width>\n    <height>37</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>18</size>\n    <weight>bold</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Time and Expense Sheets</string>\n  </label>\n  <label>\n   <rect>\n    <x>10</x>\n    <y>112</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sheet #</string>\n  </label>\n </rpthead>\n <pghead>\n  <firstpage/>\n  <height>6</height>\n </pghead>\n <pghead>\n  <height>36</height>\n  <label>\n   <rect>\n    <x>225</x>\n    <y>14.6</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Employee</string>\n  </label>\n  <label>\n   <rect>\n    <x>119</x>\n    <y>14.6</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Date</string>\n  </label>\n  <line>\n   <xstart>5</xstart>\n   <ystart>30</ystart>\n   <xend>745</xend>\n   <yend>30</yend>\n   <weight>2</weight>\n  </line>\n  <label>\n   <rect>\n    <x>450</x>\n    <y>14.6</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Extended</string>\n  </label>\n  <label>\n   <rect>\n    <x>698.599</x>\n    <y>14.5988</y>\n    <width>50</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Posted</string>\n  </label>\n  <label>\n   <rect>\n    <x>8.6</x>\n    <y>14.6</y>\n    <width>95</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <string>Sheet #</string>\n  </label>\n  <label>\n   <rect>\n    <x>625</x>\n    <y>14.6</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Vouchered</string>\n  </label>\n  <label>\n   <rect>\n    <x>350</x>\n    <y>14.6</y>\n    <width>90</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Status</string>\n  </label>\n  <label>\n   <rect>\n    <x>550</x>\n    <y>14.6</y>\n    <width>75</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <hcenter/>\n   <vcenter/>\n   <string>Invoiced</string>\n  </label>\n </pghead>\n <section>\n  <name>detail</name>\n  <detail>\n   <key>\n    <query>detail</query>\n   </key>\n   <height>22</height>\n   <field>\n    <rect>\n     <x>625</x>\n     <y>1.84</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>vouchered_qtdisplayrole</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>225</x>\n     <y>1.84</y>\n     <width>105</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>emp_code</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>550</x>\n     <y>1.84</y>\n     <width>75</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>invoiced_qtdisplayrole</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>110.599</x>\n     <y>1.84</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_weekending</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>700</x>\n     <y>1.84</y>\n     <width>50</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>posted_qtdisplayrole</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>450</x>\n     <y>1.84</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <right/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>f_total</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>8.59883</x>\n     <y>1.84</y>\n     <width>100</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <left/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>tehead_number</column>\n    </data>\n   </field>\n   <field>\n    <rect>\n     <x>350</x>\n     <y>1.84</y>\n     <width>90</width>\n     <height>15</height>\n    </rect>\n    <font>\n     <face>Arial</face>\n     <size>8</size>\n     <weight>bold</weight>\n    </font>\n    <hcenter/>\n    <vcenter/>\n    <data>\n     <query>detail</query>\n     <column>tehead_status_qtdisplayrole</column>\n    </data>\n   </field>\n  </detail>\n </section>\n <pgfoot>\n  <height>16</height>\n  <field>\n   <rect>\n    <x>90</x>\n    <y>0</y>\n    <width>100</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>report_date</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>615</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Page:</string>\n  </label>\n  <field>\n   <rect>\n    <x>705</x>\n    <y>0</y>\n    <width>40</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>bold</weight>\n   </font>\n   <left/>\n   <vcenter/>\n   <data>\n    <query>Context Query</query>\n    <column>page_number</column>\n   </data>\n  </field>\n  <label>\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>85</width>\n    <height>15</height>\n   </rect>\n   <font>\n    <face>Arial</face>\n    <size>8</size>\n    <weight>normal</weight>\n   </font>\n   <right/>\n   <vcenter/>\n   <string>Report Date:</string>\n  </label>\n </pgfoot>\n</report>\n       \N      0       \N
105756
 
\.
105757
 
 
105758
 
 
105759
 
--
105760
 
--
105761
 
 
105762
 
COPY pkgscript (script_id, script_name, script_order, script_enabled, script_source, script_notes) FROM stdin;
105763
 
109     dspTimeExpenseHistory   0       t       /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.dspTimeExpenseHistory = new Object;\n\nvar _close           = mywindow.findChild("_close");\nvar _print           = mywindow.findChild("_print");\nvar _query           = mywindow.findChild("_query");\nvar _list            = mywindow.findChild("_list");\nvar _parameterWidget = mywindow.findChild("_parameterWidget");\n\n_list.addColumn(qsTr("Sheet #"),      XTreeWidget.orderColumn, Qt.AlignLeft,  true,  "f_sheet_number");\n_list.addColumn(qsTr("Employee #"),   XTreeWidget.orderColumn, Qt.AlignLeft,  true,  "emp_code");\n_list.addColumn(qsTr("Work Date"),    XTreeWidget.dateColumn,  Qt.AlignLeft,  true,  "teitem_workdate");\n_list.addColumn(qsTr("Type"),         XTreeWidget.dateColumn,  Qt.AlignLeft,  true,  "teitem_type");\n_list.addColumn(qsTr("Status"),       XTreeWidget.dateColumn,  Qt.AlignLeft,  true,  "tehead_status");\n_list.addColumn(qsTr("Project#"),     XTreeWidget.orderColumn, Qt.AlignLeft,  true,  "prj_number");\n_list.addColumn(qsTr("Project Name"), -1,                      Qt.AlignLeft,  false, "prj_name");\n_list.addColumn(qsTr("Task#"),        XTreeWidget.orderColumn, Qt.AlignLeft,  false, "prjtask_number");\n_list.addColumn(qsTr("Task Name"),    -1,                      Qt.AlignLeft,  false, "prjtask_name");\n_list.addColumn(qsTr("Cust.#"),       XTreeWidget.orderColumn, Qt.AlignLeft,  false, "cust_number");\n_list.addColumn(qsTr("Cust. Name"),   -1,                      Qt.AlignLeft,  false, "cust_name");\n_list.addColumn(qsTr("PO"),           XTreeWidget.orderColumn, Qt.AlignLeft,  false, "teitem_po");\n_list.addColumn(qsTr("Item"),         XTreeWidget.itemColumn,  Qt.AlignLeft,  true,  "item_number");\n_list.addColumn(qsTr("Description"),  -1,                      Qt.AlignLeft,  true,  "item_descrip1");\n_list.addColumn(qsTr("Qty"),          XTreeWidget.qtyColumn,   Qt.AlignRight, true,  "teitem_qty");\nif (privileges.check("CanViewRates"))\n{\n  _list.addColumn(qsTr("Billable"),   XTreeWidget.qtyColumn,   Qt.AlignRight, false, "teitem_billable");\n  _list.addColumn(qsTr("Ext."),       XTreeWidget.moneyColumn, Qt.AlignRight, true,  "teitem_total");\n}\n\nvar teSql = "SELECT 1,'" + qsTr("Time") + "','T' "\n          + "UNION "\n          + "SELECT 2,'" + qsTr("Expense") +  "','E';";\n\nvar empGrpSql = "SELECT empgrp_id, empgrp_name, empgrp_name "\n              + "FROM empgrp "\n              + "ORDER BY empgrp_name;";\n\n_parameterWidget.append(qsTr("Start Date"), "startDate", ParameterWidget.Date, mainwindow.dbDate());\n_parameterWidget.append(qsTr("End Date"), "endDate",   ParameterWidget.Date, mainwindow.dbDate());\n_parameterWidget.appendComboBox(qsTr("Type"), "typeEnum", teSql);\n_parameterWidget.append(qsTr("Employee"), "emp_id",   ParameterWidget.Employee);\n_parameterWidget.appendComboBox(qsTr("Employee Group"), "empgrp_id", empGrpSql);\n_parameterWidget.append(qsTr("Project"), "prj_id",   ParameterWidget.Project);\n_parameterWidget.append(qsTr("Customer"), "cust_id",   ParameterWidget.Customer);\n_parameterWidget.appendComboBox(qsTr("Customer Type"), "custtype_id", XComboBox.CustomerTypes - 0);\n_parameterWidget.append(qsTr("Customer Type Pattern"), "custtype_pattern", ParameterWidget.Text);\n_parameterWidget.appendComboBox(qsTr("Customer Group"), "custgrp_id", XComboBox.CustomerGroups - 0);\n_parameterWidget.append(qsTr("Item"), "item_id",   ParameterWidget.Item);\n_parameterWidget.appendComboBox(qsTr("Item Group"), "itemgrp_id", XComboBox.ItemGroups - 0);\n_parameterWidget.appendComboBox(qsTr("Class Code"), "classcode_id", XComboBox.ClassCodes - 0);\n_parameterWidget.append(qsTr("Class Code Pattern"), "classcode_pattern", ParameterWidget.Text);\n\n_parameterWidget.applyDefaultFilterSet();\n\nxtte.dspTimeExpenseHistory.populateMenu = function(pMenu, pItem, pCol)\n{\n  if(pMenu == null)\n    pMenu = _booitem.findChild("_menu");\n\n  if(pMenu != null)\n  {\n    var editAct = pMenu.addAction(qsTr("Edit..."));\n    editAct.triggered.connect(xtte.dspTimeExpenseHistory.editItem);\n    editAct.enabled = (privileges.check("MaintainTimeExpense") &&\n                       pItem.rawValue("tehead_status") == 'O');\n\n    var viewAct = pMenu.addAction(qsTr("View..."));\n    viewAct.triggered.connect(xtte.dspTimeExpenseHistory.viewItem);\n  }\n}\n\nxtte.dspTimeExpenseHistory.getParams = function()\n{\n  var params = _parameterWidget.parameters();\n  params.open = qsTr("Open");\n  params.approved = qsTr("Approved");\n  params.closed = qsTr("Closed");\n  params.time = qsTr("Time");\n  params.expense = qsTr("Expense");\n\n  if("typeEnum" in params)\n  {\n    if (params.typeEnum == 1)\n      params.timeOnly = true;\n    else\n      params.expenseOnly = true;\n  }\n\n  return params;\n}\n\nxtte.dspTimeExpenseHistory.print = function()\n{\n  var params = xtte.dspTimeExpenseHistory.getParams();\n  params.includeFormatted = true;\n\n  toolbox.printReport("TimeExpenseHistory", params);\n}\n\nxtte.dspTimeExpenseHistory.fillList = function()\n{\n  var qry = toolbox.executeDbQuery("timeexpensehistory", "detail",   xtte.dspTimeExpenseHistory.getParams());\n  _list.populate(qry)\n  if(!qry.first())\n    xtte.errorCheck(qry);\n}\n\nxtte.dspTimeExpenseHistory.editItem = function()\n{\n  xtte.dspTimeExpenseHistory.openItem(xtte.editMode);\n}\n\n\nxtte.dspTimeExpenseHistory.viewItem = function()\n{\n  xtte.dspTimeExpenseHistory.openItem(xtte.viewMode);\n}\n\n\nxtte.dspTimeExpenseHistory.openItem = function(mode)\n{  \n  var params   = new Object;\n  params.mode = mode;\n  params.teitem_id = _list.id();\n\n  var wnd = toolbox.openWindow("timeExpenseSheetItem", mywindow);\n  toolbox.lastWindow().set(params);\n  if (wnd.exec() > 0)\n    xtte.timeExpenseSheet.fillList();\n}\n\n// Connections\n_print.clicked.connect(xtte.dspTimeExpenseHistory.print);\n_query.clicked.connect(xtte.dspTimeExpenseHistory.fillList);\n_list["populateMenu(QMenu *, XTreeWidgetItem *, int)"].connect(xtte.dspTimeExpenseHistory.populateMenu)\n_close.clicked.connect(mywindow, "close");\n\n     Time and Expense package
105764
 
113     jsGantt 0       t       /* \n   _        ___            _   _     _   ____  \n  (_)___   / _ \\__ _ _ __ | |_| |_  / | |___ \\ \n  | / __| / /_\\/ _` | '_ \\| __| __| | |   __) |\n  | \\__ \\/ /_\\\\ (_| | | | | |_| |_  | |_ / __/ \n _/ |___/\\____/\\__,_|_| |_|\\__|\\__| |_(_)_____|\n|__/ \n\nCopyright (c) 2009, Shlomy Gantz BlueBrick Inc. All rights reserved.\n \n*\n* Redistribution and use in source and binary forms, with or without\n* modification, are permitted provided that the following conditions are met:\n*     * Redistributions of source code must retain the above copyright\n*       notice, this list of conditions and the following disclaimer.\n*     * Redistributions in binary form must reproduce the above copyright\n*       notice, this list of conditions and the following disclaimer in the\n*       documentation and/or other materials provided with the distribution.\n*     * Neither the name of Shlomy Gantz or BlueBrick Inc. nor the\n*       names of its contributors may be used to endorse or promote products\n*       derived from this software without specific prior written permission.\n*\n* THIS SOFTWARE IS PROVIDED BY SHLOMY GANTZ/BLUEBRICK INC. ''AS IS'' AND ANY\n* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n* DISCLAIMED. IN NO EVENT SHALL SHLOMY GANTZ/BLUEBRICK INC. BE LIABLE FOR ANY\n* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\nvar JSGantt; if (!JSGantt) JSGantt = {};\n\nvar vTimeout = 0;\nvar vBenchTime = new Date().getTime();\n\nJSGantt.isIE = function () {\n\t\n\tif(typeof document.all != 'undefined')\n\t\treturn true;\n\telse\n\t\treturn false;\n}\n\n\nJSGantt.TaskItem = function(pID, pName, pStart, pEnd, pColor, pLink, pMile, pRes, pComp, pGroup, pParent, pOpen, pDepend, pCaption)\n{\n\n      var vID    = pID;\n      var vName  = pName;\n      var vStart = new Date();\t\n      var vEnd   = new Date();\n      var vColor = pColor;\n      var vLink  = pLink;\n      var vMile  = pMile;\n      var vRes   = pRes;\n      var vComp  = pComp;\n      var vGroup = pGroup;\n      var vParent = pParent;\n      var vOpen   = pOpen;\n      var vDepend = pDepend;\n      var vCaption = pCaption;\n      var vDuration = '';\n      var vLevel = 0;\n      var vNumKid = 0;\n      var vVisible  = 1;\n      var x1, y1, x2, y2;\n\n      if (vGroup != 1)\n      {  \n         vStart = JSGantt.parseDateStr(pStart,g.getDateInputFormat());\n         vEnd   = JSGantt.parseDateStr(pEnd,g.getDateInputFormat());\n      }\n\n      this.getID       = function(){ return vID };\n      this.getName     = function(){ return vName };\n      this.getStart    = function(){ return vStart};\n      this.getEnd      = function(){ return vEnd  };\n      this.getColor    = function(){ return vColor};\n      this.getLink     = function(){ return vLink };\n      this.getMile     = function(){ return vMile };\n      this.getDepend   = function(){ if(vDepend) return vDepend; else return null };\n      this.getCaption  = function(){ if(vCaption) return vCaption; else return ''; };\n      this.getResource = function(){ if(vRes) return vRes; else return '&nbsp';  };\n      this.getCompVal  = function(){ if(vComp) return vComp; else return 0; };\n      this.getCompStr  = function(){ if(vComp) return vComp+'%'; else return ''; };\n\n      this.getDuration = function(vFormat){ \n         if (vMile) \n            vDuration = '-';\n            else if (vFormat=='hour')\n            {\n                tmpPer =  Math.ceil((this.getEnd() - this.getStart()) /  ( 60 * 60 * 1000) );\n                if(tmpPer == 1)  \n                    vDuration = '1 Hour';\n                else\n                    vDuration = tmpPer + ' Hours';\n            }\n            \n            else if (vFormat=='minute')\n            {\n                tmpPer =  Math.ceil((this.getEnd() - this.getStart()) /  ( 60 * 1000) );\n                if(tmpPer == 1)  \n                    vDuration = '1 Minute';\n                else\n                    vDuration = tmpPer + ' Minutes';\n            }\n            \n \t\t   else { //if(vFormat == 'day') {\n            tmpPer =  Math.ceil((this.getEnd() - this.getStart()) /  (24 * 60 * 60 * 1000) + 1);\n            if(tmpPer == 1)  vDuration = '1 Day';\n            else             vDuration = tmpPer + ' Days';\n         }\n\n         //else if(vFormat == 'week') {\n         //   tmpPer =  ((this.getEnd() - this.getStart()) /  (24 * 60 * 60 * 1000) + 1)/7;\n         //   if(tmpPer == 1)  vDuration = '1 Week';\n         //   else             vDuration = tmpPer + ' Weeks'; \n         //}\n\n         //else if(vFormat == 'month') {\n         //   tmpPer =  ((this.getEnd() - this.getStart()) /  (24 * 60 * 60 * 1000) + 1)/30;\n         //   if(tmpPer == 1) vDuration = '1 Month';\n         //   else            vDuration = tmpPer + ' Months'; \n         //}\n\n         //else if(vFormat == 'quater') {\n         //   tmpPer =  ((this.getEnd() - this.getStart()) /  (24 * 60 * 60 * 1000) + 1)/120;\n         //   if(tmpPer == 1) vDuration = '1 Qtr';\n         //   else            vDuration = tmpPer + ' Qtrs'; \n         //}\n         return( vDuration )\n      };\n\n      this.getParent   = function(){ return vParent };\n      this.getGroup    = function(){ return vGroup };\n      this.getOpen     = function(){ return vOpen };\n      this.getLevel    = function(){ return vLevel };\n      this.getNumKids  = function(){ return vNumKid };\n      this.getStartX   = function(){ return x1 };\n      this.getStartY   = function(){ return y1 };\n      this.getEndX     = function(){ return x2 };\n      this.getEndY     = function(){ return y2 };\n      this.getVisible  = function(){ return vVisible };\n\t  this.setDepend   = function(pDepend){ vDepend = pDepend;};\n      this.setStart    = function(pStart){ vStart = pStart;};\n      this.setEnd      = function(pEnd)  { vEnd   = pEnd;  };\n      this.setLevel    = function(pLevel){ vLevel = pLevel;};\n      this.setNumKid   = function(pNumKid){ vNumKid = pNumKid;};\n      this.setCompVal  = function(pCompVal){ vComp = pCompVal;};\n      this.setStartX   = function(pX) {x1 = pX; };\n      this.setStartY   = function(pY) {y1 = pY; };\n      this.setEndX     = function(pX) {x2 = pX; };\n      this.setEndY     = function(pY) {y2 = pY; };\n      this.setOpen     = function(pOpen) {vOpen = pOpen; };\n      this.setVisible  = function(pVisible) {vVisible = pVisible; };\n\n  }\n\n\t\n  // function that loads the main gantt chart properties and functions\n  // pDiv: (required) this is a DIV object created in HTML\n  // pStart: UNUSED - future use to force minimum chart date\n  // pEnd: UNUSED - future use to force maximum chart date\n  // pWidth: UNUSED - future use to force chart width and cause objects to scale to fit within that width\n  // pShowRes: UNUSED - future use to turn on/off display of resource names\n  // pShowDur: UNUSED - future use to turn on/off display of task durations\n  // pFormat: (required) - used to indicate whether chart should be drawn in "day", "week", "month", or "quarter" format\n  // pCationType - what type of Caption to show:  Caption, Resource, Duration, Complete\nJSGantt.GanttChart =  function(pGanttVar, pDiv, pFormat)\n{\n\n      var vGanttVar = pGanttVar;\n      var vDiv      = pDiv;\n      var vFormat   = pFormat;\n      var vShowRes  = 1;\n      var vShowDur  = 1;\n      var vShowComp = 1;\n      var vShowStartDate = 1;\n      var vShowEndDate = 1;\n      var vDateInputFormat = "mm/dd/yyyy";\n      var vDateDisplayFormat = "mm/dd/yy";\n\t  var vNumUnits  = 0;\n      var vCaptionType;\n      var vDepId = 1;\n      var vTaskList     = new Array();\t\n\t  var vFormatArr\t= new Array("day","week","month","quarter");\n      var vQuarterArr   = new Array(1,1,1,2,2,2,3,3,3,4,4,4);\n      var vMonthDaysArr = new Array(31,28,31,30,31,30,31,31,30,31,30,31);\n      var vMonthArr     = new Array("January","February","March","April","May","June","July","August","September","October","November","December");\n\t  this.setFormatArr = function() \t {\n\t\t\t\t\t\t\t\t\t\t  vFormatArr = new Array();\n\t\t\t\t\t\t\t\t\t\t  for(var i = 0; i < arguments.length; i++) {vFormatArr[i] = arguments[i];}\n\t\t\t\t\t\t\t\t\t\t  if(vFormatArr.length>4){vFormatArr.length=4;}\n\t\t\t\t\t\t\t\t\t\t };\n      this.setShowRes  = function(pShow) { vShowRes  = pShow; };\n      this.setShowDur  = function(pShow) { vShowDur  = pShow; };\n      this.setShowComp = function(pShow) { vShowComp = pShow; };\n      this.setShowStartDate = function(pShow) { vShowStartDate = pShow; };\n      this.setShowEndDate = function(pShow) { vShowEndDate = pShow; };\n      this.setDateInputFormat = function(pShow) { vDateInputFormat = pShow; };\n      this.setDateDisplayFormat = function(pShow) { vDateDisplayFormat = pShow; };\n      this.setCaptionType = function(pType) { vCaptionType = pType };\n      this.setFormat = function(pFormat){ \n         vFormat = pFormat; \n         this.Draw(); \n      };\n\n      this.getShowRes  = function(){ return vShowRes };\n      this.getShowDur  = function(){ return vShowDur };\n      this.getShowComp = function(){ return vShowComp };\n\t   this.getShowStartDate = function(){ return vShowStartDate };\n\t   this.getShowEndDate = function(){ return vShowEndDate };\n      this.getDateInputFormat = function() { return vDateInputFormat };\n      this.getDateDisplayFormat = function() { return vDateDisplayFormat };\n      this.getCaptionType = function() { return vCaptionType };\n      this.CalcTaskXY = function () \n      {\n         var vList = this.getList();\n         var vTaskDiv;\n         var vParDiv;\n         var vLeft, vTop, vHeight, vWidth;\n\n         for(i = 0; i < vList.length; i++)\n         {\n            vID = vList[i].getID();\n            vTaskDiv = document.getElementById("taskbar_"+vID);\n            vBarDiv  = document.getElementById("bardiv_"+vID);\n            vParDiv  = document.getElementById("childgrid_"+vID);\n\n            if(vBarDiv) {\n               vList[i].setStartX( vBarDiv.offsetLeft );\n               vList[i].setStartY( vParDiv.offsetTop+vBarDiv.offsetTop+6 );\n               vList[i].setEndX( vBarDiv.offsetLeft + vBarDiv.offsetWidth );\n               vList[i].setEndY( vParDiv.offsetTop+vBarDiv.offsetTop+6 );\n            }\n         }\n      }\n\n      this.AddTaskItem = function(value)\n      {\n         vTaskList.push(value);\n      }\n\n      this.getList   = function() { return vTaskList };\n\n      this.clearDependencies = function()\n      {\n         var parent = document.getElementById('rightside');\n         var depLine;\n         var vMaxId = vDepId;\n         for ( i=1; i<vMaxId; i++ ) {\n            depLine = document.getElementById("line"+i);\n            if (depLine) { parent.removeChild(depLine); }\n         }\n         vDepId = 1;\n      }\n\n\n      // sLine: Draw a straight line (colored one-pixel wide DIV), need to parameterize doc item\n      this.sLine = function(x1,y1,x2,y2) {\n\n         vLeft = Math.min(x1,x2);\n         vTop  = Math.min(y1,y2);\n         vWid  = Math.abs(x2-x1) + 1;\n         vHgt  = Math.abs(y2-y1) + 1;\n\n         vDoc = document.getElementById('rightside');\n\n\t // retrieve DIV\n\t var oDiv = document.createElement('div');\n\n\t oDiv.id = "line"+vDepId++;\n         oDiv.style.position = "absolute";\n\t oDiv.style.margin = "0px";\n\t oDiv.style.padding = "0px";\n\t oDiv.style.overflow = "hidden";\n\t oDiv.style.border = "0px";\n\n\t // set attributes\n\t oDiv.style.zIndex = 0;\n\t oDiv.style.backgroundColor = "red";\n\t\n\t oDiv.style.left = vLeft + "px";\n\t oDiv.style.top = vTop + "px";\n\t oDiv.style.width = vWid + "px";\n\t oDiv.style.height = vHgt + "px";\n\n\t oDiv.style.visibility = "visible";\n\t\n\t vDoc.appendChild(oDiv);\n\n      }\n\n\n      // dLine: Draw a diaganol line (calc line x,y paisrs and draw multiple one-by-one sLines)\n      this.dLine = function(x1,y1,x2,y2) {\n\n         var dx = x2 - x1;\n         var dy = y2 - y1;\n         var x = x1;\n         var y = y1;\n\n         var n = Math.max(Math.abs(dx),Math.abs(dy));\n         dx = dx / n;\n         dy = dy / n;\n         for ( i = 0; i <= n; i++ )\n         {\n            vx = Math.round(x); \n            vy = Math.round(y);\n            this.sLine(vx,vy,vx,vy);\n            x += dx;\n            y += dy;\n         }\n\n      }\n\n      this.drawDependency =function(x1,y1,x2,y2)\n      {\n         if(x1 + 10 < x2)\n         { \n            this.sLine(x1,y1,x1+4,y1);\n            this.sLine(x1+4,y1,x1+4,y2);\n            this.sLine(x1+4,y2,x2,y2);\n            this.dLine(x2,y2,x2-3,y2-3);\n            this.dLine(x2,y2,x2-3,y2+3);\n            this.dLine(x2-1,y2,x2-3,y2-2);\n            this.dLine(x2-1,y2,x2-3,y2+2);\n         }\n         else\n         {\n            this.sLine(x1,y1,x1+4,y1);\n            this.sLine(x1+4,y1,x1+4,y2-10);\n            this.sLine(x1+4,y2-10,x2-8,y2-10);\n            this.sLine(x2-8,y2-10,x2-8,y2);\n            this.sLine(x2-8,y2,x2,y2);\n            this.dLine(x2,y2,x2-3,y2-3);\n            this.dLine(x2,y2,x2-3,y2+3);\n            this.dLine(x2-1,y2,x2-3,y2-2);\n            this.dLine(x2-1,y2,x2-3,y2+2);\n         }\n      }\n\n      this.DrawDependencies = function () {\n\n         //First recalculate the x,y\n         this.CalcTaskXY();\n\n         this.clearDependencies();\n\n         var vList = this.getList();\n         for(var i = 0; i < vList.length; i++)\n         {\n\n            vDepend = vList[i].getDepend();\n            if(vDepend) {\n         \n               var vDependStr = vDepend + '';\n               var vDepList = vDependStr.split(',');\n               var n = vDepList.length;\n\n               for(var k=0;k<n;k++) {\n                  var vTask = this.getArrayLocationByID(vDepList[k]);\n\n                  if(vList[vTask].getVisible()==1)\n                     this.drawDependency(vList[vTask].getEndX(),vList[vTask].getEndY(),vList[i].getStartX()-1,vList[i].getStartY())\n               }\n  \t    }\n         }\n      }\n\n\n      this.getArrayLocationByID = function(pId)  {\n\n         var vList = this.getList();\n         for(var i = 0; i < vList.length; i++)\n         {\n            if(vList[i].getID()==pId)\n               return i;\n         }\n      }\n\n\n   this.Draw = function()\n   {\n      var vMaxDate = new Date();\n      var vMinDate = new Date();\t\n      var vTmpDate = new Date();\n      var vNxtDate = new Date();\n      var vCurrDate = new Date();\n      var vTaskLeft = 0;\n      var vTaskRight = 0;\n      var vNumCols = 0;\n      var vID = 0;\n      var vMainTable = "";\n      var vLeftTable = "";\n      var vRightTable = "";\n      var vDateRowStr = "";\n      var vItemRowStr = "";\n      var vColWidth = 0;\n      var vColUnit = 0;\n      var vChartWidth = 0;\n      var vNumDays = 0;\n      var vDayWidth = 0;\n      var vStr = "";\n      var vNameWidth = 220;\t\n      var vStatusWidth = 70;\n      var vLeftWidth = 15 + 220 + 70 + 70 + 70 + 70 + 70;\n\n      if(vTaskList.length > 0)\n      {\n        \n\t\t   // Process all tasks preset parent date and completion %\n         JSGantt.processRows(vTaskList, 0, -1, 1, 1);\n\n         // get overall min/max dates plus padding\n         vMinDate = JSGantt.getMinDate(vTaskList, vFormat);\n         vMaxDate = JSGantt.getMaxDate(vTaskList, vFormat);\n\n         // Calculate chart width variables.  vColWidth can be altered manually to change each column width\n         // May be smart to make this a parameter of GanttChart or set it based on existing pWidth parameter\n         if(vFormat == 'day') {\n            vColWidth = 18;\n            vColUnit = 1;\n         }\n         else if(vFormat == 'week') {\n            vColWidth = 37;\n            vColUnit = 7;\n         }\n         else if(vFormat == 'month') {\n            vColWidth = 37;\n            vColUnit = 30;\n         }\n         else if(vFormat == 'quarter') {\n            vColWidth = 60;\n            vColUnit = 90;\n         }\n         \n         else if(vFormat=='hour')\n         {\n            vColWidth = 18;\n            vColUnit = 1;\n         }\n         \n         else if(vFormat=='minute')\n         {\n            vColWidth = 18;\n            vColUnit = 1;\n         }\n         \n         vNumDays = (Date.parse(vMaxDate) - Date.parse(vMinDate)) / ( 24 * 60 * 60 * 1000);\n         vNumUnits = vNumDays / vColUnit;\n          \n         \n         vChartWidth = vNumUnits * vColWidth + 1;\n         vDayWidth = (vColWidth / vColUnit) + (1/vColUnit);\n\n         vMainTable =\n            '<TABLE id=theTable cellSpacing=0 cellPadding=0 border=0><TBODY><TR>' +\n            '<TD vAlign=top bgColor=#ffffff>';\n\n         if(vShowRes !=1) vNameWidth+=vStatusWidth;\n         if(vShowDur !=1) vNameWidth+=vStatusWidth;\n         if(vShowComp!=1) vNameWidth+=vStatusWidth;\n\t\t   if(vShowStartDate!=1) vNameWidth+=vStatusWidth;\n\t\t   if(vShowEndDate!=1) vNameWidth+=vStatusWidth;\n        \n\t\t   // DRAW the Left-side of the chart (names, resources, comp%)\n         vLeftTable =\n            '<DIV class=scroll id=leftside style="width:' + vLeftWidth + 'px"><TABLE cellSpacing=0 cellPadding=0 border=0><TBODY>' +\n            '<TR style="HEIGHT: 17px">' +\n            '  <TD style="WIDTH: 15px; HEIGHT: 17px"></TD>' +\n            '  <TD style="WIDTH: ' + vNameWidth + 'px; HEIGHT: 17px"><NOBR></NOBR></TD>'; \n\n         if(vShowRes ==1) vLeftTable += '  <TD style="WIDTH: ' + vStatusWidth + 'px; HEIGHT: 17px"></TD>' ;\n         if(vShowDur ==1) vLeftTable += '  <TD style="WIDTH: ' + vStatusWidth + 'px; HEIGHT: 17px"></TD>' ;\n         if(vShowComp==1) vLeftTable += '  <TD style="WIDTH: ' + vStatusWidth + 'px; HEIGHT: 17px"></TD>' ;\n\t\t\tif(vShowStartDate==1) vLeftTable += '  <TD style="WIDTH: ' + vStatusWidth + 'px; HEIGHT: 17px"></TD>' ;\n\t\t\tif(vShowEndDate==1) vLeftTable += '  <TD style="WIDTH: ' + vStatusWidth + 'px; HEIGHT: 17px"></TD>' ;\n\n         vLeftTable +=\n            '<TR style="HEIGHT: 20px">' +\n            '  <TD style="BORDER-TOP: #efefef 1px solid; WIDTH: 15px; HEIGHT: 20px"></TD>' +\n            '  <TD style="BORDER-TOP: #efefef 1px solid; WIDTH: ' + vNameWidth + 'px; HEIGHT: 20px"><NOBR></NOBR></TD>' ;\n\n         if(vShowRes ==1) vLeftTable += '  <TD style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 60px; HEIGHT: 20px" align=center nowrap>Resource</TD>' ;\n         if(vShowDur ==1) vLeftTable += '  <TD style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 60px; HEIGHT: 20px" align=center nowrap>Duration</TD>' ;\n         if(vShowComp==1) vLeftTable += '  <TD style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 60px; HEIGHT: 20px" align=center nowrap>% Comp.</TD>' ;\n         if(vShowStartDate==1) vLeftTable += '  <TD style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 60px; HEIGHT: 20px" align=center nowrap>Start Date</TD>' ;\n         if(vShowEndDate==1) vLeftTable += '  <TD style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 60px; HEIGHT: 20px" align=center nowrap>End Date</TD>' ;\n \n         vLeftTable += '</TR>';\n\n            for(i = 0; i < vTaskList.length; i++)\n            {\n               if( vTaskList[i].getGroup()) {\n                  vBGColor = "f3f3f3";\n                  vRowType = "group";\n               } else {\n                  vBGColor  = "ffffff";\n                  vRowType  = "row";\n               }\n               \n               vID = vTaskList[i].getID();\n\n  \t\t         if(vTaskList[i].getVisible() == 0) \n                  vLeftTable += '<TR id=child_' + vID + ' bgcolor=#' + vBGColor + ' style="display:none"  onMouseover=g.mouseOver(this,' + vID + ',"left","' + vRowType + '") onMouseout=g.mouseOut(this,' + vID + ',"left","' + vRowType + '")>' ;\n\t\t\t      else\n                 vLeftTable += '<TR id=child_' + vID + ' bgcolor=#' + vBGColor + ' onMouseover=g.mouseOver(this,' + vID + ',"left","' + vRowType + '") onMouseout=g.mouseOut(this,' + vID + ',"left","' + vRowType + '")>' ;\n\n\t\t\t      vLeftTable += \n                  '  <TD class=gdatehead style="WIDTH: 15px; HEIGHT: 20px; BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;">&nbsp;</TD>' +\n                  '  <TD class=gname style="WIDTH: ' + vNameWidth + 'px; HEIGHT: 20px; BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px;" nowrap><NOBR><span style="color: #aaaaaa">';\n\n               for(j=1; j<vTaskList[i].getLevel(); j++) {\n                  vLeftTable += '&nbsp&nbsp&nbsp&nbsp';\n               }\n\n               vLeftTable += '</span>';\n\n               if( vTaskList[i].getGroup()) {\n                  if( vTaskList[i].getOpen() == 1) \n                     vLeftTable += '<SPAN id="group_' + vID + '" style="color:#000000; cursor:pointer; font-weight:bold; FONT-SIZE: 12px;" onclick="JSGantt.folder(' + vID + ','+vGanttVar+');'+vGanttVar+'.DrawDependencies();">&ndash;</span><span style="color:#000000">&nbsp</SPAN>' ;\n                  else\n                     vLeftTable += '<SPAN id="group_' + vID + '" style="color:#000000; cursor:pointer; font-weight:bold; FONT-SIZE: 12px;" onclick="JSGantt.folder(' + vID + ','+vGanttVar+');'+vGanttVar+'.DrawDependencies();">+</span><span style="color:#000000">&nbsp</SPAN>' ;\n\t\t\t\t \n               } else {\n\n                  vLeftTable += '<span style="color: #000000; font-weight:bold; FONT-SIZE: 12px;">&nbsp&nbsp&nbsp</span>';\n               }\n\n               vLeftTable += \n                  '<span onclick=JSGantt.taskLink("' + vTaskList[i].getLink() + '",300,200); style="cursor:pointer"> ' + vTaskList[i].getName() + '</span></NOBR></TD>' ;\n\n               if(vShowRes ==1) vLeftTable += '  <TD class=gname style="WIDTH: 60px; HEIGHT: 20px; TEXT-ALIGN: center; BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=center><NOBR>' + vTaskList[i].getResource() + '</NOBR></TD>' ;\n               if(vShowDur ==1) vLeftTable += '  <TD class=gname style="WIDTH: 60px; HEIGHT: 20px; TEXT-ALIGN: center; BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=center><NOBR>' + vTaskList[i].getDuration(vFormat) + '</NOBR></TD>' ;\n               if(vShowComp==1) vLeftTable += '  <TD class=gname style="WIDTH: 60px; HEIGHT: 20px; TEXT-ALIGN: center; BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=center><NOBR>' + vTaskList[i].getCompStr()  + '</NOBR></TD>' ;\n               if(vShowStartDate==1) vLeftTable += '  <TD class=gname style="WIDTH: 60px; HEIGHT: 20px; TEXT-ALIGN: center; BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=center><NOBR>' + JSGantt.formatDateStr( vTaskList[i].getStart(), vDateDisplayFormat) + '</NOBR></TD>' ;\n               if(vShowEndDate==1) vLeftTable += '  <TD class=gname style="WIDTH: 60px; HEIGHT: 20px; TEXT-ALIGN: center; BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=center><NOBR>' + JSGantt.formatDateStr( vTaskList[i].getEnd(), vDateDisplayFormat) + '</NOBR></TD>' ;\n\n               vLeftTable += '</TR>';\n\n            }\n\n            // DRAW the date format selector at bottom left.  Another potential GanttChart parameter to hide/show this selector\n            vLeftTable += '</TD></TR>' +\n              '<TR><TD border=1 colspan=5 align=left style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 11px; BORDER-LEFT: #efefef 1px solid; height=18px">&nbsp;&nbsp;Powered by <a href=http://www.jsgantt.com>jsGantt</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Format:';\n\t\t\n\t\t\tif (vFormatArr.join().indexOf("minute")!=-1) { \n            if (vFormat=='minute') vLeftTable += '<INPUT TYPE=RADIO NAME="radFormat" VALUE="minute" checked>Minute';\n            else                vLeftTable += '<INPUT TYPE=RADIO NAME="radFormat" onclick=JSGantt.changeFormat("minute",'+vGanttVar+'); VALUE="minute">Minute';\n\t\t\t}\n\t\t\t\n\t\t\tif (vFormatArr.join().indexOf("hour")!=-1) { \n            if (vFormat=='hour') vLeftTable += '<INPUT TYPE=RADIO NAME="radFormat" VALUE="hour" checked>Hour';\n            else                vLeftTable += '<INPUT TYPE=RADIO NAME="radFormat" onclick=JSGantt.changeFormat("hour",'+vGanttVar+'); VALUE="hour">Hour';\n\t\t\t}\n\t\t\t\n\t\t\tif (vFormatArr.join().indexOf("day")!=-1) { \n            if (vFormat=='day') vLeftTable += '<INPUT TYPE=RADIO NAME="radFormat" VALUE="day" checked>Day';\n            else                vLeftTable += '<INPUT TYPE=RADIO NAME="radFormat" onclick=JSGantt.changeFormat("day",'+vGanttVar+'); VALUE="day">Day';\n\t\t\t}\n\t\t\t\n\t\t\tif (vFormatArr.join().indexOf("week")!=-1) { \n            if (vFormat=='week') vLeftTable += '<INPUT TYPE=RADIO NAME="radFormat" VALUE="week" checked>Week';\n            else                vLeftTable += '<INPUT TYPE=RADIO NAME="radFormat" onclick=JSGantt.changeFormat("week",'+vGanttVar+') VALUE="week">Week';\n\t\t\t}\n\t\t\t\n\t\t\tif (vFormatArr.join().indexOf("month")!=-1) { \n            if (vFormat=='month') vLeftTable += '<INPUT TYPE=RADIO NAME="radFormat" VALUE="month" checked>Month';\n            else                vLeftTable += '<INPUT TYPE=RADIO NAME="radFormat" onclick=JSGantt.changeFormat("month",'+vGanttVar+') VALUE="month">Month';\n\t\t\t}\n\t\t\t\n\t\t\tif (vFormatArr.join().indexOf("quarter")!=-1) { \n            if (vFormat=='quarter') vLeftTable += '<INPUT TYPE=RADIO NAME="radFormat" VALUE="quarter" checked>Quarter';\n            else                vLeftTable += '<INPUT TYPE=RADIO NAME="radFormat" onclick=JSGantt.changeFormat("quarter",'+vGanttVar+') VALUE="quarter">Quarter';\n\t\t\t}\n\t\t\t\n//            vLeftTable += '<INPUT TYPE=RADIO NAME="other" VALUE="other" style="display:none"> .';\n\n            vLeftTable += '</TD></TR></TBODY></TABLE></TD>';\n\n            vMainTable += vLeftTable;\n\n            // Draw the Chart Rows\n            vRightTable = \n            '<TD style="width: ' + vChartWidth + 'px;" vAlign=top bgColor=#ffffff>' +\n            '<DIV class=scroll2 id=rightside>' +\n            '<TABLE style="width: ' + vChartWidth + 'px;" cellSpacing=0 cellPadding=0 border=0>' +\n            '<TBODY><TR style="HEIGHT: 18px">';\n\n            vTmpDate.setFullYear(vMinDate.getFullYear(), vMinDate.getMonth(), vMinDate.getDate());\n            vTmpDate.setHours(0);\n            vTmpDate.setMinutes(0);\n\n         // Major Date Header\n         while(Date.parse(vTmpDate) <= Date.parse(vMaxDate))\n         {\t\n            vStr = vTmpDate.getFullYear() + '';\n            vStr = vStr.substring(2,4);\n            \n            \n            if(vFormat == 'minute')\n            {\n                vRightTable += '<td class=gdatehead style="FONT-SIZE: 12px; HEIGHT: 19px;" align=center colspan=60>' ;\n                vRightTable += JSGantt.formatDateStr(vTmpDate, vDateDisplayFormat) + ' ' + vTmpDate.getHours() + ':00 -' + vTmpDate.getHours() + ':59 </td>';\n                vTmpDate.setHours(vTmpDate.getHours()+1);\n            }\n            \n            if(vFormat == 'hour')\n            {\n                vRightTable += '<td class=gdatehead style="FONT-SIZE: 12px; HEIGHT: 19px;" align=center colspan=24>' ;\n                vRightTable += JSGantt.formatDateStr(vTmpDate, vDateDisplayFormat) + '</td>';\n                vTmpDate.setDate(vTmpDate.getDate()+1);\n            }\n            \n  \t         if(vFormat == 'day')\n            {\n\t\t\t      vRightTable += '<td class=gdatehead style="FONT-SIZE: 12px; HEIGHT: 19px;" align=center colspan=7>' +\n\t\t\t      JSGantt.formatDateStr(vTmpDate,vDateDisplayFormat.substring(0,5)) + ' - ';\n               vTmpDate.setDate(vTmpDate.getDate()+6);\n\t\t         vRightTable += JSGantt.formatDateStr(vTmpDate, vDateDisplayFormat) + '</td>';\n               vTmpDate.setDate(vTmpDate.getDate()+1);\n            }\n            else if(vFormat == 'week')\n            {\n  \t\t         vRightTable += '<td class=gdatehead align=center style="FONT-SIZE: 12px; HEIGHT: 19px;" width='+vColWidth+'px>`'+ vStr + '</td>';\n               vTmpDate.setDate(vTmpDate.getDate()+7);\n            }\n            else if(vFormat == 'month')\n            {\n\t            vRightTable += '<td class=gdatehead align=center style="FONT-SIZE: 12px; HEIGHT: 19px;" width='+vColWidth+'px>`'+ vStr + '</td>';\n               vTmpDate.setDate(vTmpDate.getDate() + 1);\n               while(vTmpDate.getDate() > 1)\n               {\n                 vTmpDate.setDate(vTmpDate.getDate() + 1);\n               }\n            }\n            else if(vFormat == 'quarter')\n            {\n\t            vRightTable += '<td class=gdatehead align=center style="FONT-SIZE: 12px; HEIGHT: 19px;" width='+vColWidth+'px>`'+ vStr + '</td>';\n               vTmpDate.setDate(vTmpDate.getDate() + 81);\n               while(vTmpDate.getDate() > 1)\n               {\n                 vTmpDate.setDate(vTmpDate.getDate() + 1);\n               }\n            }\n\n         }\n\n         vRightTable += '</TR><TR>';\n\n         // Minor Date header and Cell Rows\n         vTmpDate.setFullYear(vMinDate.getFullYear(), vMinDate.getMonth(), vMinDate.getDate());\n         vNxtDate.setFullYear(vMinDate.getFullYear(), vMinDate.getMonth(), vMinDate.getDate());\n         vNumCols = 0;\n \n         while(Date.parse(vTmpDate) <= Date.parse(vMaxDate))\n         {\t\n            if (vFormat == 'minute')\n            {\n\t\t\t\n\t\t\t  if( vTmpDate.getMinutes() ==0 ) \n                  vWeekdayColor = "ccccff";\n               else\n                  vWeekdayColor = "ffffff";\n\t\t\t\t  \n\t\t\t\t  \n                vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;"  bgcolor=#' + vWeekdayColor + ' align=center><div style="width: '+vColWidth+'px">' + vTmpDate.getMinutes() + '</div></td>';\n                vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px; BORDER-LEFT: #efefef 1px solid; cursor: default;"  bgcolor=#' + vWeekdayColor + ' align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n                vTmpDate.setMinutes(vTmpDate.getMinutes() + 1);\n            }\n          \n            else if (vFormat == 'hour')\n            {\n\t\t\t\n\t\t\t   if(  vTmpDate.getHours() ==0  ) \n                  vWeekdayColor = "ccccff";\n               else\n                  vWeekdayColor = "ffffff";\n\t\t\t\t  \n\t\t\t\t  \n                vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;"  bgcolor=#' + vWeekdayColor + ' align=center><div style="width: '+vColWidth+'px">' + vTmpDate.getHours() + '</div></td>';\n                vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px;BORDER-LEFT: #efefef 1px solid; cursor: default;"  bgcolor=#' + vWeekdayColor + ' align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n                vTmpDate.setHours(vTmpDate.getHours() + 1);\n            }\n\n\t        else if(vFormat == 'day' )\n             {\n               if( JSGantt.formatDateStr(vCurrDate,'mm/dd/yyyy') == JSGantt.formatDateStr(vTmpDate,'mm/dd/yyyy')) {\n                  vWeekdayColor  = "ccccff";\n                  vWeekendColor  = "9999ff";\n                  vWeekdayGColor  = "bbbbff";\n                  vWeekendGColor = "8888ff";\n               } else {\n                  vWeekdayColor = "ffffff";\n                  vWeekendColor = "cfcfcf";\n                  vWeekdayGColor = "f3f3f3";\n                  vWeekendGColor = "c3c3c3";\n               }\n               \n               if(vTmpDate.getDay() % 6 == 0) {\n                  vDateRowStr  += '<td class="gheadwkend" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;" bgcolor=#' + vWeekendColor + ' align=center><div style="width: '+vColWidth+'px">' + vTmpDate.getDate() + '</div></td>';\n                  vItemRowStr  += '<td class="gheadwkend" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px;HEIGHT: 20px; BORDER-LEFT: #efefef 1px solid; cursor: default;"  bgcolor=#' + vWeekendColor + ' align=center><div style="width: '+vColWidth+'px">&nbsp</div></td>';\n               }\n               else {\n                  vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;"  bgcolor=#' + vWeekdayColor + ' align=center><div style="width: '+vColWidth+'px">' + vTmpDate.getDate() + '</div></td>';\n                  if( JSGantt.formatDateStr(vCurrDate,'mm/dd/yyyy') == JSGantt.formatDateStr(vTmpDate,'mm/dd/yyyy')) \n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px; BORDER-LEFT: #efefef 1px solid; cursor: default;"  bgcolor=#' + vWeekdayColor + ' align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n                  else\n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px;BORDER-LEFT: #efefef 1px solid; cursor: default;"  align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n               }\n\n               vTmpDate.setDate(vTmpDate.getDate() + 1);\n\n            }\n\n\t         else if(vFormat == 'week')\n            {\n\n               vNxtDate.setDate(vNxtDate.getDate() + 7);\n\n               if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n                  vWeekdayColor = "ccccff";\n               else\n                  vWeekdayColor = "ffffff";\n\n               if(vNxtDate <= vMaxDate) {\n                  vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;" bgcolor=#' + vWeekdayColor + ' align=center width:'+vColWidth+'px><div style="width: '+vColWidth+'px">' + (vTmpDate.getMonth()+1) + '/' + vTmpDate.getDate() + '</div></td>';\n                  if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px;BORDER-LEFT: #efefef 1px solid;" bgcolor=#' + vWeekdayColor + ' align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n                  else\n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px;BORDER-LEFT: #efefef 1px solid;" align=center><div style="width:'+ vColWidth +'px">&nbsp&nbsp</div></td>';\n\n               } else {\n                  vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid; bgcolor=#' + vWeekdayColor + ' BORDER-RIGHT: #efefef 1px solid;" align=center width:'+vColWidth+'px><div style="width: '+vColWidth+'px">' + (vTmpDate.getMonth()+1) + '/' + vTmpDate.getDate() + '</div></td>';\n                  if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px;BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" bgcolor=#' + vWeekdayColor + ' align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n                  else\n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px;BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n\n               }\n\n               vTmpDate.setDate(vTmpDate.getDate() + 7);\n\n            }\n\n\t         else if(vFormat == 'month')\n            {\n\n               vNxtDate.setFullYear(vTmpDate.getFullYear(), vTmpDate.getMonth(), vMonthDaysArr[vTmpDate.getMonth()]);\n               if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n                  vWeekdayColor = "ccccff";\n               else\n                  vWeekdayColor = "ffffff";\n\n               if(vNxtDate <= vMaxDate) {\n                  vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;" bgcolor=#' + vWeekdayColor + ' align=center width:'+vColWidth+'px><div style="width: '+vColWidth+'px">' + vMonthArr[vTmpDate.getMonth()].substr(0,3) + '</div></td>';\n                  if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px;BORDER-LEFT: #efefef 1px solid;" bgcolor=#' + vWeekdayColor + ' align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n                  else\n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px;BORDER-LEFT: #efefef 1px solid;" align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n               } else {\n                  vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" bgcolor=#' + vWeekdayColor + ' align=center width:'+vColWidth+'px><div style="width: '+vColWidth+'px">' + vMonthArr[vTmpDate.getMonth()].substr(0,3) + '</div></td>';\n                  if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px;BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" bgcolor=#' + vWeekdayColor + ' align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n                  else\n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px;BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n               }\n\n               vTmpDate.setDate(vTmpDate.getDate() + 1);\n\n               while(vTmpDate.getDate() > 1) \n               {\n                  vTmpDate.setDate(vTmpDate.getDate() + 1);\n               }\n\n            }\n\n\t         else if(vFormat == 'quarter')\n            {\n\n               vNxtDate.setDate(vNxtDate.getDate() + 122);\n               if( vTmpDate.getMonth()==0 || vTmpDate.getMonth()==1 || vTmpDate.getMonth()==2 )\n                  vNxtDate.setFullYear(vTmpDate.getFullYear(), 2, 31);\n               else if( vTmpDate.getMonth()==3 || vTmpDate.getMonth()==4 || vTmpDate.getMonth()==5 )\n                  vNxtDate.setFullYear(vTmpDate.getFullYear(), 5, 30);\n               else if( vTmpDate.getMonth()==6 || vTmpDate.getMonth()==7 || vTmpDate.getMonth()==8 )\n                  vNxtDate.setFullYear(vTmpDate.getFullYear(), 8, 30);\n               else if( vTmpDate.getMonth()==9 || vTmpDate.getMonth()==10 || vTmpDate.getMonth()==11 )\n                  vNxtDate.setFullYear(vTmpDate.getFullYear(), 11, 31);\n\n               if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n                  vWeekdayColor = "ccccff";\n               else\n                  vWeekdayColor = "ffffff";\n\n               if(vNxtDate <= vMaxDate) {\n                  vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;" bgcolor=#' + vWeekdayColor + ' align=center width:'+vColWidth+'px><div style="width: '+vColWidth+'px">Qtr. ' + vQuarterArr[vTmpDate.getMonth()] + '</div></td>';\n                  if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px;BORDER-LEFT: #efefef 1px solid;" bgcolor=#' + vWeekdayColor + ' align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n                  else\n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px;HEIGHT: 20px; BORDER-LEFT: #efefef 1px solid;" align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n               } else {\n                  vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" bgcolor=#' + vWeekdayColor + ' align=center width:'+vColWidth+'px><div style="width: '+vColWidth+'px">Qtr. ' + vQuarterArr[vTmpDate.getMonth()] + '</div></td>';\n                  if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px;BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" bgcolor=#' + vWeekdayColor + ' align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n                  else \n                     vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 20px;BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" align=center><div style="width: '+vColWidth+'px">&nbsp&nbsp</div></td>';\n               }\n\n               vTmpDate.setDate(vTmpDate.getDate() + 81);\n\n               while(vTmpDate.getDate() > 1) \n               {\n                  vTmpDate.setDate(vTmpDate.getDate() + 1);\n               }\n\n            }\n         }\n\n         vRightTable += vDateRowStr + '</TR>';\n         vRightTable += '</TBODY></TABLE>';\n\n         // Draw each row\n\n         for(i = 0; i < vTaskList.length; i++)\n\n         {\n\n            vTmpDate.setFullYear(vMinDate.getFullYear(), vMinDate.getMonth(), vMinDate.getDate());\n            vTaskStart = vTaskList[i].getStart();\n            vTaskEnd   = vTaskList[i].getEnd();\n\n            vNumCols = 0;\n            vID = vTaskList[i].getID();\n\n           // vNumUnits = Math.ceil((vTaskList[i].getEnd() - vTaskList[i].getStart()) / (24 * 60 * 60 * 1000)) + 1;\n            vNumUnits = (vTaskList[i].getEnd() - vTaskList[i].getStart()) / (24 * 60 * 60 * 1000) + 1;\n\t       if (vFormat=='hour')\n\t       {\n                vNumUnits = (vTaskList[i].getEnd() - vTaskList[i].getStart()) / (  60 * 1000) + 1;\n\t       }\n\t       else if (vFormat=='minute')\n\t       {\n                vNumUnits = (vTaskList[i].getEnd() - vTaskList[i].getStart()) / (  60 * 1000) + 1;\n\t       }\n\t       \n\t         if(vTaskList[i].getVisible() == 0) \n               vRightTable += '<DIV id=childgrid_' + vID + ' style="position:relative; display:none;">';\n            else\n\t\t         vRightTable += '<DIV id=childgrid_' + vID + ' style="position:relative">';\n            \n            if( vTaskList[i].getMile()) {\n\n               vRightTable += '<DIV><TABLE style="position:relative; top:0px; width: ' + vChartWidth + 'px;" cellSpacing=0 cellPadding=0 border=0>' +\n                  '<TR id=childrow_' + vID + ' class=yesdisplay style="HEIGHT: 20px" onMouseover=g.mouseOver(this,' + vID + ',"right","mile") onMouseout=g.mouseOut(this,' + vID + ',"right","mile")>' + vItemRowStr + '</TR></TABLE></DIV>';\n\n               // Build date string for Title\n               vDateRowStr = JSGantt.formatDateStr(vTaskStart,vDateDisplayFormat);\n\n               vTaskLeft = (Date.parse(vTaskList[i].getStart()) - Date.parse(vMinDate)) / (24 * 60 * 60 * 1000);\n               vTaskRight = 1\n\n  \t            vRightTable +=\n                  '<div id=bardiv_' + vID + ' style="position:absolute; top:0px; left:' + Math.ceil((vTaskLeft * (vDayWidth) + 1)) + 'px; height: 18px; width:160px; overflow:hidden;">' +\n                  '  <div id=taskbar_' + vID + ' title="' + vTaskList[i].getName() + ': ' + vDateRowStr + '" style="height: 16px; width:12px; overflow:hidden; cursor: pointer;" onclick=JSGantt.taskLink("' + vTaskList[i].getLink() + '",300,200);>';\n\n               if(vTaskList[i].getCompVal() < 100)\n \t\t            vRightTable += '&loz;</div>' ;\n               else\n \t\t            vRightTable += '&diams;</div>' ;\n\n                        if( g.getCaptionType() ) {\n                           vCaptionStr = '';\n                           switch( g.getCaptionType() ) {           \n                              case 'Caption':    vCaptionStr = vTaskList[i].getCaption();  break;\n                              case 'Resource':   vCaptionStr = vTaskList[i].getResource();  break;\n                              case 'Duration':   vCaptionStr = vTaskList[i].getDuration(vFormat);  break;\n                              case 'Complete':   vCaptionStr = vTaskList[i].getCompStr();  break;\n\t\t                     }\n                           //vRightTable += '<div style="FONT-SIZE:12px; position:absolute; left: 6px; top:1px;">' + vCaptionStr + '</div>';\n                           vRightTable += '<div style="FONT-SIZE:12px; position:absolute; top:2px; width:120px; left:12px">' + vCaptionStr + '</div>';\n\t                  }\n\n  \t            vRightTable += '</div>';\n\n\n            } else {\n\n               // Build date string for Title\n               vDateRowStr = JSGantt.formatDateStr(vTaskStart,vDateDisplayFormat) + ' - ' + JSGantt.formatDateStr(vTaskEnd,vDateDisplayFormat)\n\n                if (vFormat=='minute')\n                {\n                    vTaskRight = (Date.parse(vTaskList[i].getEnd()) - Date.parse(vTaskList[i].getStart())) / ( 60 * 1000) + 1/vColUnit;\n                    vTaskLeft = Math.ceil((Date.parse(vTaskList[i].getStart()) - Date.parse(vMinDate)) / ( 60 * 1000));\n                }\n                else if (vFormat=='hour')\n                {\n                    vTaskRight = (Date.parse(vTaskList[i].getEnd()) - Date.parse(vTaskList[i].getStart())) / ( 60 * 60 * 1000) + 1/vColUnit;\n                    vTaskLeft = (Date.parse(vTaskList[i].getStart()) - Date.parse(vMinDate)) / ( 60 * 60 * 1000);\n                }\n                else\n                {\n                    vTaskRight = (Date.parse(vTaskList[i].getEnd()) - Date.parse(vTaskList[i].getStart())) / (24 * 60 * 60 * 1000) + 1/vColUnit;\n                    vTaskLeft = Math.ceil((Date.parse(vTaskList[i].getStart()) - Date.parse(vMinDate)) / (24 * 60 * 60 * 1000));\n                    if (vFormat='day')\n                    {\n                        var tTime=new Date();\n                        tTime.setTime(Date.parse(vTaskList[i].getStart()));\n                        if (tTime.getMinutes() > 29)\n                            vTaskLeft+=.5\n                    }\n                }\n\n               // Draw Group Bar  which has outer div with inner group div and several small divs to left and right to create angled-end indicators\n               if( vTaskList[i].getGroup()) {\n                  vRightTable += '<DIV><TABLE style="position:relative; top:0px; width: ' + vChartWidth + 'px;" cellSpacing=0 cellPadding=0 border=0>' +\n                     '<TR id=childrow_' + vID + ' class=yesdisplay style="HEIGHT: 20px" bgColor=#f3f3f3 onMouseover=g.mouseOver(this,' + vID + ',"right","group") onMouseout=g.mouseOut(this,' + vID + ',"right","group")>' + vItemRowStr + '</TR></TABLE></DIV>';\n                  vRightTable +=\n                     '<div id=bardiv_' + vID + ' style="position:absolute; top:5px; left:' + Math.ceil(vTaskLeft * (vDayWidth) + 1) + 'px; height: 7px; width:' + Math.ceil((vTaskRight) * (vDayWidth) - 1) + 'px">' +\n                       '<div id=taskbar_' + vID + ' title="' + vTaskList[i].getName() + ': ' + vDateRowStr + '" class=gtask style="background-color:#000000; height: 7px; width:' + Math.ceil((vTaskRight) * (vDayWidth) -1) + 'px;  cursor: pointer;opacity:0.9;">' +\n                         '<div style="Z-INDEX: -4; float:left; background-color:#666666; height:3px; overflow: hidden; margin-top:1px; ' +\n                               'margin-left:1px; margin-right:1px; filter: alpha(opacity=80); opacity:0.8; width:' + vTaskList[i].getCompStr() + '; ' + \n                               'cursor: pointer;" onclick=JSGantt.taskLink("' + vTaskList[i].getLink() + '",300,200);>' +\n                           '</div>' +\n                        '</div>' +\n                        '<div style="Z-INDEX: -4; float:left; background-color:#000000; height:4px; overflow: hidden; width:1px;"></div>' +\n                        '<div style="Z-INDEX: -4; float:right; background-color:#000000; height:4px; overflow: hidden; width:1px;"></div>' +\n                        '<div style="Z-INDEX: -4; float:left; background-color:#000000; height:3px; overflow: hidden; width:1px;"></div>' +\n                        '<div style="Z-INDEX: -4; float:right; background-color:#000000; height:3px; overflow: hidden; width:1px;"></div>' +\n                        '<div style="Z-INDEX: -4; float:left; background-color:#000000; height:2px; overflow: hidden; width:1px;"></div>' +\n                        '<div style="Z-INDEX: -4; float:right; background-color:#000000; height:2px; overflow: hidden; width:1px;"></div>' +\n                        '<div style="Z-INDEX: -4; float:left; background-color:#000000; height:1px; overflow: hidden; width:1px;"></div>' +\n                        '<div style="Z-INDEX: -4; float:right; background-color:#000000; height:1px; overflow: hidden; width:1px;"></div>' ;\n\n                        if( g.getCaptionType() ) {\n                           vCaptionStr = '';\n                           switch( g.getCaptionType() ) {           \n                              case 'Caption':    vCaptionStr = vTaskList[i].getCaption();  break;\n                              case 'Resource':   vCaptionStr = vTaskList[i].getResource();  break;\n                              case 'Duration':   vCaptionStr = vTaskList[i].getDuration(vFormat);  break;\n                              case 'Complete':   vCaptionStr = vTaskList[i].getCompStr();  break;\n\t\t                     }\n                           //vRightTable += '<div style="FONT-SIZE:12px; position:absolute; left: 6px; top:1px;">' + vCaptionStr + '</div>';\n                           vRightTable += '<div style="FONT-SIZE:12px; position:absolute; top:-3px; width:120px; left:' + (Math.ceil((vTaskRight) * (vDayWidth) - 1) + 6) + 'px">' + vCaptionStr + '</div>';\n\t                  }\n\n                  vRightTable += '</div>' ;\n\n               } else {\n\n                  vDivStr = '<DIV><TABLE style="position:relative; top:0px; width: ' + vChartWidth + 'px;" cellSpacing=0 cellPadding=0 border=0>' +\n                     '<TR id=childrow_' + vID + ' class=yesdisplay style="HEIGHT: 20px" bgColor=#ffffff onMouseover=g.mouseOver(this,' + vID + ',"right","row") onMouseout=g.mouseOut(this,' + vID + ',"right","row")>' + vItemRowStr + '</TR></TABLE></DIV>';\n                  vRightTable += vDivStr;\n                  \n                  // Draw Task Bar  which has outer DIV with enclosed colored bar div, and opaque completion div\n\t            vRightTable +=\n                     '<div id=bardiv_' + vID + ' style="position:absolute; top:4px; left:' + Math.ceil(vTaskLeft * (vDayWidth) + 1) + 'px; height:18px; width:' + Math.ceil((vTaskRight) * (vDayWidth) - 1) + 'px">' +\n                        '<div id=taskbar_' + vID + ' title="' + vTaskList[i].getName() + ': ' + vDateRowStr + '" class=gtask style="background-color:#' + vTaskList[i].getColor() +'; height: 13px; width:' + Math.ceil((vTaskRight) * (vDayWidth) - 1) + 'px; cursor: pointer;opacity:0.9;" ' +\n                           'onclick=JSGantt.taskLink("' + vTaskList[i].getLink() + '",300,200); >' +\n                           '<div class=gcomplete style="Z-INDEX: -4; float:left; background-color:black; height:5px; overflow: auto; margin-top:4px; filter: alpha(opacity=40); opacity:0.4; width:' + vTaskList[i].getCompStr() + '; overflow:hidden">' +\n                           '</div>' +\n                        '</div>';\n\n                        if( g.getCaptionType() ) {\n                           vCaptionStr = '';\n                           switch( g.getCaptionType() ) {           \n                              case 'Caption':    vCaptionStr = vTaskList[i].getCaption();  break;\n                              case 'Resource':   vCaptionStr = vTaskList[i].getResource();  break;\n                              case 'Duration':   vCaptionStr = vTaskList[i].getDuration(vFormat);  break;\n                              case 'Complete':   vCaptionStr = vTaskList[i].getCompStr();  break;\n\t\t                     }\n                           //vRightTable += '<div style="FONT-SIZE:12px; position:absolute; left: 6px; top:-3px;">' + vCaptionStr + '</div>';\n                           vRightTable += '<div style="FONT-SIZE:12px; position:absolute; top:-3px; width:120px; left:' + (Math.ceil((vTaskRight) * (vDayWidth) - 1) + 6) + 'px">' + vCaptionStr + '</div>';\n\t                  }\n                  vRightTable += '</div>' ;\n\n                  \n\n               }\n            }\n\n            vRightTable += '</DIV>';\n\n         }\n\n         vMainTable += vRightTable + '</DIV></TD></TR></TBODY></TABLE></BODY></HTML>';\n\n\t\t   vDiv.innerHTML = vMainTable;\n\n      }\n\n   } //this.draw\n\n   this.mouseOver = function( pObj, pID, pPos, pType ) {\n      if( pPos == 'right' )  vID = 'child_' + pID;\n      else vID = 'childrow_' + pID;\n      \n      pObj.bgColor = "#ffffaa";\n      vRowObj = JSGantt.findObj(vID);\n      if (vRowObj) vRowObj.bgColor = "#ffffaa";\n   }\n\n   this.mouseOut = function( pObj, pID, pPos, pType ) {\n      if( pPos == 'right' )  vID = 'child_' + pID;\n      else vID = 'childrow_' + pID;\n      \n      pObj.bgColor = "#ffffff";\n      vRowObj = JSGantt.findObj(vID);\n      if (vRowObj) {\n         if( pType == "group") {\n            pObj.bgColor = "#f3f3f3";\n            vRowObj.bgColor = "#f3f3f3";\n         } else {\n            pObj.bgColor = "#ffffff";\n            vRowObj.bgColor = "#ffffff";\n         }\n      }\n   }\n\n} //GanttChart\t\t\n\n// Recursively process task tree ... set min, max dates of parent tasks and identfy task level.\nJSGantt.processRows = function(pList, pID, pRow, pLevel, pOpen)\n{\n\n   var vMinDate = new Date();\n   var vMaxDate = new Date();\n   var vMinSet  = 0;\n   var vMaxSet  = 0;\n   var vList    = pList;\n   var vLevel   = pLevel;\n   var i        = 0;\n   var vNumKid  = 0;\n   var vCompSum = 0;\n   var vVisible = pOpen;\n   \n   for(i = 0; i < pList.length; i++)\n   {\n      if(pList[i].getParent() == pID) {\n\t\t vVisible = pOpen;\n         pList[i].setVisible(vVisible);\n         if(vVisible==1 && pList[i].getOpen() == 0) \n            vVisible = 0;\n            \n         pList[i].setLevel(vLevel);\n         vNumKid++;\n\n         if(pList[i].getGroup() == 1) {\n            JSGantt.processRows(vList, pList[i].getID(), i, vLevel+1, vVisible);\n         }\n\n         if( vMinSet==0 || pList[i].getStart() < vMinDate) {\n            vMinDate = pList[i].getStart();\n            vMinSet = 1;\n         }\n\n         if( vMaxSet==0 || pList[i].getEnd() > vMaxDate) {\n            vMaxDate = pList[i].getEnd();\n            vMaxSet = 1;\n         }\n\n         vCompSum += pList[i].getCompVal();\n\n      }\n   }\n\n   if(pRow >= 0) {\n      pList[pRow].setStart(vMinDate);\n      pList[pRow].setEnd(vMaxDate);\n      pList[pRow].setNumKid(vNumKid);\n      pList[pRow].setCompVal(Math.ceil(vCompSum/vNumKid));\n   }\n\n}\n\n\n// Used to determine the minimum date of all tasks and set lower bound based on format\nJSGantt.getMinDate = function getMinDate(pList, pFormat)  \n      {\n\n         var vDate = new Date();\n\n         vDate.setFullYear(pList[0].getStart().getFullYear(), pList[0].getStart().getMonth(), pList[0].getStart().getDate());\n\n         // Parse all Task End dates to find min\n         for(i = 0; i < pList.length; i++)\n         {\n            if(Date.parse(pList[i].getStart()) < Date.parse(vDate))\n               vDate.setFullYear(pList[i].getStart().getFullYear(), pList[i].getStart().getMonth(), pList[i].getStart().getDate());\n         }\n\n         if ( pFormat== 'minute')\n         {\n            vDate.setHours(0);\n            vDate.setMinutes(0);\n         }\n\t\t else if (pFormat == 'hour' )\n         {\n            vDate.setHours(0);\n            vDate.setMinutes(0);\n         }\n         // Adjust min date to specific format boundaries (first of week or first of month)\n         else if (pFormat=='day')\n         {\n            vDate.setDate(vDate.getDate() - 1);\n            while(vDate.getDay() % 7 > 0)\n            {\n                vDate.setDate(vDate.getDate() - 1);\n            }\n\n         }\n\n         else if (pFormat=='week')\n         {\n            vDate.setDate(vDate.getDate() - 7);\n            while(vDate.getDay() % 7 > 0)\n            {\n                vDate.setDate(vDate.getDate() - 1);\n            }\n\n         }\n\n         else if (pFormat=='month')\n         {\n            while(vDate.getDate() > 1)\n            {\n                vDate.setDate(vDate.getDate() - 1);\n            }\n         }\n\n         else if (pFormat=='quarter')\n         {\n            if( vDate.getMonth()==0 || vDate.getMonth()==1 || vDate.getMonth()==2 )\n               vDate.setFullYear(vDate.getFullYear(), 0, 1);\n            else if( vDate.getMonth()==3 || vDate.getMonth()==4 || vDate.getMonth()==5 )\n               vDate.setFullYear(vDate.getFullYear(), 3, 1);\n            else if( vDate.getMonth()==6 || vDate.getMonth()==7 || vDate.getMonth()==8 )\n               vDate.setFullYear(vDate.getFullYear(), 6, 1);\n            else if( vDate.getMonth()==9 || vDate.getMonth()==10 || vDate.getMonth()==11 )\n               vDate.setFullYear(vDate.getFullYear(), 9, 1);\n\n         }\n\n         return(vDate);\n\n      }\n\n\n\n\n\n\n\n      // Used to determine the minimum date of all tasks and set lower bound based on format\n\nJSGantt.getMaxDate = function (pList, pFormat)\n{\n   var vDate = new Date();\n\n         vDate.setFullYear(pList[0].getEnd().getFullYear(), pList[0].getEnd().getMonth(), pList[0].getEnd().getDate());\n         \n         \n                // Parse all Task End dates to find max\n         for(i = 0; i < pList.length; i++)\n         {\n            if(Date.parse(pList[i].getEnd()) > Date.parse(vDate))\n            {\n                 //vDate.setFullYear(pList[0].getEnd().getFullYear(), pList[0].getEnd().getMonth(), pList[0].getEnd().getDate());\n                 vDate.setTime(Date.parse(pList[i].getEnd()));\n\t\t\t}\t\n\t     }\n\t     \n\t     if (pFormat == 'minute')\n         {\n            vDate.setHours(vDate.getHours() + 1);\n            vDate.setMinutes(59);\n         }\t\n\t     \n         if (pFormat == 'hour')\n         {\n            vDate.setHours(vDate.getHours() + 2);\n         }\t\t\t\t\n\t\t\t\t\n         // Adjust max date to specific format boundaries (end of week or end of month)\n         if (pFormat=='day')\n         {\n            vDate.setDate(vDate.getDate() + 1);\n\n            while(vDate.getDay() % 6 > 0)\n            {\n                vDate.setDate(vDate.getDate() + 1);\n            }\n\n         }\n\n         if (pFormat=='week')\n         {\n            //For weeks, what is the last logical boundary?\n            vDate.setDate(vDate.getDate() + 11);\n\n            while(vDate.getDay() % 6 > 0)\n            {\n                vDate.setDate(vDate.getDate() + 1);\n            }\n\n         }\n\n         // Set to last day of current Month\n         if (pFormat=='month')\n         {\n            while(vDate.getDay() > 1)\n            {\n                vDate.setDate(vDate.getDate() + 1);\n            }\n\n            vDate.setDate(vDate.getDate() - 1);\n         }\n\n         // Set to last day of current Quarter\n         if (pFormat=='quarter')\n         {\n            if( vDate.getMonth()==0 || vDate.getMonth()==1 || vDate.getMonth()==2 )\n               vDate.setFullYear(vDate.getFullYear(), 2, 31);\n            else if( vDate.getMonth()==3 || vDate.getMonth()==4 || vDate.getMonth()==5 )\n               vDate.setFullYear(vDate.getFullYear(), 5, 30);\n            else if( vDate.getMonth()==6 || vDate.getMonth()==7 || vDate.getMonth()==8 )\n               vDate.setFullYear(vDate.getFullYear(), 8, 30);\n            else if( vDate.getMonth()==9 || vDate.getMonth()==10 || vDate.getMonth()==11 )\n               vDate.setFullYear(vDate.getFullYear(), 11, 31);\n\n         }\n\n         return(vDate);\n\n      }\n\n\n\n\n\n\n\n      // This function finds the document id of the specified object\n\nJSGantt.findObj = function (theObj, theDoc)\n\n      {\n\n         var p, i, foundObj;\n\n         if(!theDoc) theDoc = document;\n\n         if( (p = theObj.indexOf("?")) > 0 && parent.frames.length){\n\n            theDoc = parent.frames[theObj.substring(p+1)].document;\n\n            theObj = theObj.substring(0,p);\n\n         }\n\n         if(!(foundObj = theDoc[theObj]) && theDoc.all) \n\n            foundObj = theDoc.all[theObj];\n\n\n\n         for (i=0; !foundObj && i < theDoc.forms.length; i++) \n\n            foundObj = theDoc.forms[i][theObj];\n\n\n\n         for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)\n\n            foundObj = JSGantt.findObj(theObj,theDoc.layers[i].document);\n\n\n\n         if(!foundObj && document.getElementById)\n\n            foundObj = document.getElementById(theObj);\n\n\n\n         return foundObj;\n\n      }\n\n\n\n\n\nJSGantt.changeFormat =      function(pFormat,ganttObj) {\n\n\n\n        if(ganttObj) \n\n\t\t{\n\n\t\tganttObj.setFormat(pFormat);\n\n\t\tganttObj.DrawDependencies();\n\n\t\t}\n\n        else\n\n           alert('Chart undefined');\n\n\n\n      }\n\n\n\n\n\n      // Function to open/close and hide/show children of specified task\n\nJSGantt.folder= function (pID,ganttObj) {\n\n   var vList = ganttObj.getList();\n\n   for(i = 0; i < vList.length; i++)\n   {\n      if(vList[i].getID() == pID) {\n\n         if( vList[i].getOpen() == 1 ) {\n            vList[i].setOpen(0);\n            JSGantt.hide(pID,ganttObj);\n\n            if (JSGantt.isIE()) \n               JSGantt.findObj('group_'+pID).innerText = '+';\n            else\n               JSGantt.findObj('group_'+pID).textContent = '+';\n\t\t\t\t\n         } else {\n\n            vList[i].setOpen(1);\n\n            JSGantt.show(pID, 1, ganttObj);\n\n               if (JSGantt.isIE()) \n                  JSGantt.findObj('group_'+pID).innerText = 'ƃĀ±';\n               else\n                  JSGantt.findObj('group_'+pID).textContent = 'ƃĀ±';\n\n         }\n\n      }\n   }\n}\n\nJSGantt.hide=     function (pID,ganttObj) {\n   var vList = ganttObj.getList();\n   var vID   = 0;\n\n   for(var i = 0; i < vList.length; i++)\n   {\n      if(vList[i].getParent() == pID) {\n         vID = vList[i].getID();\n         JSGantt.findObj('child_' + vID).style.display = "none";\n         JSGantt.findObj('childgrid_' + vID).style.display = "none";\n         vList[i].setVisible(0);\n         if(vList[i].getGroup() == 1) \n            JSGantt.hide(vID,ganttObj);\n      }\n\n   }\n}\n\n// Function to show children of specified task\nJSGantt.show =  function (pID, pTop, ganttObj) {\n   var vList = ganttObj.getList();\n   var vID   = 0;\n\n   for(var i = 0; i < vList.length; i++)\n   {\n      if(vList[i].getParent() == pID) {\n         vID = vList[i].getID();\n         if(pTop == 1) {\n            if (JSGantt.isIE()) { // IE;\n\n               if( JSGantt.findObj('group_'+pID).innerText == '+') {\n                  JSGantt.findObj('child_'+vID).style.display = "";\n                  JSGantt.findObj('childgrid_'+vID).style.display = "";\n                  vList[i].setVisible(1);\n               }\n\n            } else {\n \n               if( JSGantt.findObj('group_'+pID).textContent == '+') {\n                  JSGantt.findObj('child_'+vID).style.display = "";\n                  JSGantt.findObj('childgrid_'+vID).style.display = "";\n                  vList[i].setVisible(1);\n               }\n\n            }\n\n         } else {\n\n            if (JSGantt.isIE()) { // IE;\n               if( JSGantt.findObj('group_'+pID).innerText == 'ƃĀ±') {\n                  JSGantt.findObj('child_'+vID).style.display = "";\n                  JSGantt.findObj('childgrid_'+vID).style.display = "";\n                  vList[i].setVisible(1);\n               }\n\n            } else {\n\n               if( JSGantt.findObj('group_'+pID).textContent == 'ƃĀ±') {\n                  JSGantt.findObj('child_'+vID).style.display = "";\n                  JSGantt.findObj('childgrid_'+vID).style.display = "";\n                  vList[i].setVisible(1);\n               }\n            }\n         }\n\n         if(vList[i].getGroup() == 1) \n            JSGantt.show(vID, 0,ganttObj);\n\n      }\n   }\n}\n\n\n  \n\n\n  // function to open window to display task link\n\nJSGantt.taskLink = function(pRef,pWidth,pHeight) \n\n  {\n\n    if(pWidth)  vWidth =pWidth;  else vWidth =400;\n    if(pHeight) vHeight=pHeight; else vHeight=400;\n\n    var OpenWindow=window.open(pRef, "newwin", "height="+vHeight+",width="+vWidth); \n\n  }\n\nJSGantt.parseDateStr = function(pDateStr,pFormatStr) {\n   var vDate =new Date();\t\n   vDate.setTime( Date.parse(pDateStr));\n\n   switch(pFormatStr) \n   {\n\t  case 'mm/dd/yyyy':\n\t     var vDateParts = pDateStr.split('/');\n         vDate.setFullYear(parseInt(vDateParts[2], 10), parseInt(vDateParts[0], 10) - 1, parseInt(vDateParts[1], 10));\n         break;\n\t  case 'dd/mm/yyyy':\n\t     var vDateParts = pDateStr.split('/');\n         vDate.setFullYear(parseInt(vDateParts[2], 10), parseInt(vDateParts[1], 10) - 1, parseInt(vDateParts[0], 10));\n         break;\n\t  case 'yyyy-mm-dd':\n\t     var vDateParts = pDateStr.split('-');\n         vDate.setFullYear(parseInt(vDateParts[0], 10), parseInt(vDateParts[1], 10) - 1, parseInt(vDateParts[1], 10));\n         break;\n    }\n\n    return(vDate);\n    \n}\n\nJSGantt.formatDateStr = function(pDate,pFormatStr) {\n       vYear4Str = pDate.getFullYear() + '';\n \t   vYear2Str = vYear4Str.substring(2,4);\n       vMonthStr = (pDate.getMonth()+1) + '';\n       vDayStr   = pDate.getDate() + '';\n\n      var vDateStr = "";\t\n\n      switch(pFormatStr) {\n\t        case 'mm/dd/yyyy':\n               return( vMonthStr + '/' + vDayStr + '/' + vYear4Str );\n\t        case 'dd/mm/yyyy':\n               return( vDayStr + '/' + vMonthStr + '/' + vYear4Str );\n\t        case 'yyyy-mm-dd':\n               return( vYear4Str + '-' + vMonthStr + '-' + vDayStr );\n\t        case 'mm/dd/yy':\n               return( vMonthStr + '/' + vDayStr + '/' + vYear2Str );\n\t        case 'dd/mm/yy':\n               return( vDayStr + '/' + vMonthStr + '/' + vYear2Str );\n\t        case 'yy-mm-dd':\n               return( vYear2Str + '-' + vMonthStr + '-' + vDayStr );\n\t        case 'mm/dd':\n               return( vMonthStr + '/' + vDayStr );\n\t        case 'dd/mm':\n               return( vDayStr + '/' + vMonthStr );\n      }\t\t \n\t  \n}\n\nJSGantt.parseXML = function(ThisFile,pGanttVar){\n\tvar is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;   // Is this Chrome \n\t\n\ttry { //Internet Explorer  \n\t\txmlDoc=new ActiveXObject("Microsoft.XMLDOM");\n\t\t}\n\tcatch(e) {\n\t\ttry { //Firefox, Mozilla, Opera, Chrome etc. \n\t\t\tif (is_chrome==false) {  xmlDoc=document.implementation.createDocument("","",null); }\n\t\t}\n\t\tcatch(e) {\n\t\t\talert(e.message);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (is_chrome==false) { \t// can't use xmlDoc.load in chrome at the moment\n\t\txmlDoc.async=false;\n\t\txmlDoc.load(ThisFile);\t\t// we can use  loadxml\n\t\tJSGantt.AddXMLTask(pGanttVar)\n\t\txmlDoc=null;\t\t\t// a little tidying\n\t\tTask = null;\n\t}\n\telse {\n\t\tJSGantt.ChromeLoadXML(ThisFile,pGanttVar);\t\n\t\tta=null;\t// a little tidying\t\n\t}\n}\n\nJSGantt.AddXMLTask = function(pGanttVar){\n\n\tTask=xmlDoc.getElementsByTagName("task");\n\t\n\tvar n = xmlDoc.documentElement.childNodes.length;\t// the number of tasks. IE gets this right, but mozilla add extra ones (Whitespace)\n\t\n\tfor(var i=0;i<n;i++) {\n\t\n\t\t// optional parameters may not have an entry (Whitespace from mozilla also returns an error )\n\t\t// Task ID must NOT be zero other wise it will be skipped\n\t\ttry { pID = Task[i].getElementsByTagName("pID")[0].childNodes[0].nodeValue;\n\t\t} catch (error) {pID =0;}\n\t\tpID *= 1;\t// make sure that these are numbers rather than strings in order to make jsgantt.js behave as expected.\n\n\t\tif(pID!=0){\n\t \t\ttry { pName = Task[i].getElementsByTagName("pName")[0].childNodes[0].nodeValue;\n\t\t\t} catch (error) {pName ="No Task Name";}\t\t\t// If there is no corresponding entry in the XML file the set a default.\n\t\t\n\t\t\ttry { pColor = Task[i].getElementsByTagName("pColor")[0].childNodes[0].nodeValue;\n\t\t\t} catch (error) {pColor ="0000ff";}\n\t\t\t\n\t\t\ttry { pParent = Task[i].getElementsByTagName("pParent")[0].childNodes[0].nodeValue;\n\t\t\t} catch (error) {pParent =0;}\n\t\t\tpParent *= 1;\n\t\n\t\t\ttry { pStart = Task[i].getElementsByTagName("pStart")[0].childNodes[0].nodeValue;\n\t\t\t} catch (error) {pStart ="";}\n\n\t\t\ttry { pEnd = Task[i].getElementsByTagName("pEnd")[0].childNodes[0].nodeValue;\n\t\t\t} catch (error) { pEnd ="";}\n\n\t\t\ttry { pLink = Task[i].getElementsByTagName("pLink")[0].childNodes[0].nodeValue;\n\t\t\t} catch (error) { pLink ="";}\n\t\n\t\t\ttry { pMile = Task[i].getElementsByTagName("pMile")[0].childNodes[0].nodeValue;\n\t\t\t} catch (error) { pMile=0;}\n\t\t\tpMile *= 1;\n\n\t\t\ttry { pRes = Task[i].getElementsByTagName("pRes")[0].childNodes[0].nodeValue;\n\t\t\t} catch (error) { pRes ="";}\n\n\t\t\ttry { pComp = Task[i].getElementsByTagName("pComp")[0].childNodes[0].nodeValue;\n\t\t\t} catch (error) {pComp =0;}\n\t\t\tpComp *= 1;\n\n\t\t\ttry { pGroup = Task[i].getElementsByTagName("pGroup")[0].childNodes[0].nodeValue;\n\t\t\t} catch (error) {pGroup =0;}\n\t\t\tpGroup *= 1;\n\n\t\t\ttry { pOpen = Task[i].getElementsByTagName("pOpen")[0].childNodes[0].nodeValue;\n\t\t\t} catch (error) { pOpen =1;}\n\t\t\tpOpen *= 1;\n\n\t\t\ttry { pDepend = Task[i].getElementsByTagName("pDepend")[0].childNodes[0].nodeValue;\n\t\t\t} catch (error) { pDepend =0;}\n\t\t\t//pDepend *= 1;\n\t\t\tif (pDepend.length==0){pDepend=''} // need this to draw the dependency lines\n\t\t\t\n\t\t\ttry { pCaption = Task[i].getElementsByTagName("pCaption")[0].childNodes[0].nodeValue;\n\t\t\t} catch (error) { pCaption ="";}\n\t\t\t\n\t\t\t\n\t\t\t// Finally add the task\n\t\t\tpGanttVar.AddTaskItem(new JSGantt.TaskItem(pID , pName, pStart, pEnd, pColor,  pLink, pMile, pRes,  pComp, pGroup, pParent, pOpen, pDepend,pCaption));\n\t\t}\n\t}\n}\n\nJSGantt.ChromeLoadXML = function(ThisFile,pGanttVar){\n// Thanks to vodobas at mindlence,com for the initial pointers here.\n\tXMLLoader = new XMLHttpRequest();\n\tXMLLoader.onreadystatechange= function(){\n    JSGantt.ChromeXMLParse(pGanttVar);\n\t};\n\tXMLLoader.open("GET", ThisFile, false);\n\tXMLLoader.send(null);\n}\n\nJSGantt.ChromeXMLParse = function (pGanttVar){\n// Manually parse the file as it is loads quicker\n\tif (XMLLoader.readyState == 4) {\n\t\tvar ta=XMLLoader.responseText.split(/<task>/gi);\n\n\t\tvar n = ta.length;\t// the number of tasks. \n\t\tfor(var i=1;i<n;i++) {\n\t\t\tTask = ta[i].replace(/<[/]p/g, '<p');\t\n\t\t\tvar te = Task.split(/<pid>/i)\n\t\n\t\t\tif(te.length> 2){var pID=te[1];} else {var pID = 0;}\n\t\t\tpID *= 1;\n\t\n\t\t\tvar te = Task.split(/<pName>/i)\n\t\t\tif(te.length> 2){var pName=te[1];} else {var pName = "No Task Name";}\n\t\n\t\t\tvar te = Task.split(/<pstart>/i)\n\t\t\tif(te.length> 2){var pStart=te[1];} else {var pStart = "";}\n\t\n\t\t\tvar te = Task.split(/<pEnd>/i)\n\t\t\tif(te.length> 2){var pEnd=te[1];} else {var pEnd = "";}\n\t\n\t\t\tvar te = Task.split(/<pColor>/i)\n\t\t\tif(te.length> 2){var pColor=te[1];} else {var pColor = '0000ff';}\n\n\t\t\tvar te = Task.split(/<pLink>/i)\n\t\t\tif(te.length> 2){var pLink=te[1];} else {var pLink = "";}\n\t\n\t\t\tvar te = Task.split(/<pMile>/i)\n\t\t\tif(te.length> 2){var pMile=te[1];} else {var pMile = 0;}\n\t\t\tpMile  *= 1;\n\t\n\t\t\tvar te = Task.split(/<pRes>/i)\n\t\t\tif(te.length> 2){var pRes=te[1];} else {var pRes = "";}\t\n\t\n\t\t\tvar te = Task.split(/<pComp>/i)\n\t\t\tif(te.length> 2){var pComp=te[1];} else {var pComp = 0;}\t\n\t\t\tpComp  *= 1;\n\t\n\t\t\tvar te = Task.split(/<pGroup>/i)\n\t\t\tif(te.length> 2){var pGroup=te[1];} else {var pGroup = 0;}\t\n\t\t\tpGroup *= 1;\n\n\t\t\tvar te = Task.split(/<pParent>/i)\n\t\t\tif(te.length> 2){var pParent=te[1];} else {var pParent = 0;}\t\n\t\t\tpParent *= 1;\n\t\n\t\t\tvar te = Task.split(/<pOpen>/i)\n\t\t\tif(te.length> 2){var pOpen=te[1];} else {var pOpen = 1;}\n\t\t\tpOpen *= 1;\n\t\n\t\t\tvar te = Task.split(/<pDepend>/i)\n\t\t\tif(te.length> 2){var pDepend=te[1];} else {var pDepend = "";}\t\n\t\t\t//pDepend *= 1;\n\t\t\tif (pDepend.length==0){pDepend=''} // need this to draw the dependency lines\n\t\t\t\n\t\t\tvar te = Task.split(/<pCaption>/i)\n\t\t\tif(te.length> 2){var pCaption=te[1];} else {var pCaption = "";}\n\t\t\t\n\t\t\t// Finally add the task\n\t\t\tpGanttVar.AddTaskItem(new JSGantt.TaskItem(pID , pName, pStart, pEnd, pColor,  pLink, pMile, pRes,  pComp, pGroup, pParent, pOpen, pDepend,pCaption \t));\n\t\t}\n\t}\n}\n\nJSGantt.benchMark = function(pItem){\n   var vEndTime=new Date().getTime();\n   alert(pItem + ': Elapsed time: '+((vEndTime-vBenchTime)/1000)+' seconds.');\n   vBenchTime=new Date().getTime();\n}\n\n\n       Time and Expense package
105765
 
107     configureCRM    0       t       /*\n  This file is part of the xtprjaccnt Package for xTuple ERP,\n  and is Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.  It\n  is licensed to you under the xTuple End-User License Agreement ("the\n  EULA"), the full text of which is available at www.xtuple.com/EULA.\n  While the EULA gives you access to source code and encourages your\n  involvement in the development process, this Package is not free\n  software.  By using this software, you agree to be bound by the\n  terms of the EULA.\n*/\n\ninclude("xtte");\n\nxtte.configureCRM = new Object;\n\nvar _telayout = new QBoxLayout(mywindow);\nvar _tespcr = new QSpacerItem(10, 0, 1, 1 | 4);\nvar _laborAndOverheadLit = toolbox.createWidget("QLabel", mywindow, "_laborAndOverheadLit");\nvar _laborAndOverhead = toolbox.createWidget("GLCluster", mywindow, "_laborAndOverhead");\n_laborAndOverheadLit.text = qsTr("Project Labor And Overhead:");\n_laborAndOverheadLit.buddy= _laborAndOverhead;\n_laborAndOverhead.setType(0x02);  // Liability\n\n_telayout.addWidget(_laborAndOverheadLit);\n_telayout.addWidget(_laborAndOverhead);\n_telayout.addItem(_tespcr);\n\nvar _useProjects = mywindow.findChild("_useProjects")\nvar _layout = toolbox.widgetGetLayout(_useProjects);\n_layout.insertLayout(1, _telayout);\n\nxtte.configureCRM.save = function()\n{ \n  var id = -1;\n  if (_useProjects.checked)\n    id = _laborAndOverhead.id() \n    \n  metrics.set("PrjLaborAndOverhead", id);\n}\n// Initialize\n_laborAndOverhead.setEnabled(_useProjects.checked);\n_laborAndOverhead.setId(metrics.value("PrjLaborAndOverhead"));\n\n// Connections\nmywindow.saving.connect(xtte.configureCRM.save);\n_useProjects["toggled(bool)"].connect(_laborAndOverheadLit, "setEnabled(bool)");\n_useProjects["toggled(bool)"].connect(_laborAndOverhead, "setEnabled(bool)");\n\n  Time and Expense package
105766
 
115     projectGantt    0       t       /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.projectGantt = new Object;\n\nvar _webView = new QWebView(mywindow);\nvar _toolBar = mywindow.findChild("_toolBar");\nvar _layout = toolbox.widgetGetLayout(_toolBar);\nvar _prjid;\nvar _prjNumber;\nvar _prjName;\nvar _startDate;\nvar _dueDate;\nvar _jsCode;\nvar _cssCode;\nvar _jsPath;\nvar _cssPath;\nvar _qry;\nvar _page;\nvar _gantt;\n\nset = function (input) \n{ \n  if ("startDate" in input)\n    _startDate = input.startDate;\n\n  if ("dueDate" in input)\n    _dueDate = input.dueDate;\n\n  if ("prjName" in input)\n    _prjName = input.prjName;\n\n  if ("prjNumber" in input)\n  {\n    _prjNumber = input.prjNumber;\n    qry = toolbox.executeDbQuery("projectGantt","getprj",input);\n    if (qry.first())\n      _prjid = qry.value("prj_id");\n\n    xtte.projectGantt.populate();\n  }\n}\n\nxtte.projectGantt.populate = function()\n{\n\n    _page = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';\n    _page = _page + '<html><head>';\n    _page = _page + '<link rel="stylesheet" type="text/css" href="file:///' + _cssPath + '"/>';\n    _page = _page + '<script language="javascript" src="file:///' + _jsPath + '"></script>';\n    _page = _page + '</head><body bgcolor="#F0F0F0"><div class="gantt" id="GanttChartDIV"></div></body></html>';\n\n    _gantt = "<script>";\n    _gantt = _gantt + "var g = new JSGantt.GanttChart('g', document.getElementById('GanttChartDIV'), 'day');";\n    _gantt = _gantt + "g.setShowRes(0);";\n    _gantt = _gantt + "g.setShowDur(0);";\n    _gantt = _gantt + "g.setShowComp(0);";\n    _gantt = _gantt + "g.setDateInputFormat('dd/mm/yyyy');";\n    _gantt = _gantt + "g.setCaptionType('Resource');";\n    _gantt = _gantt + "if (g) {";\n    _gantt = _gantt + "g.AddTaskItem(new JSGantt.TaskItem(" + _prjid + ", \\"" + _prjName + "\\", '" + _startDate + "', '" + _dueDate + "', '000000', '', 0, '', 0, 1, 0, 1));";\n\n    var j = 0;\n    \n    params = new Object;\n    params.prj_id = _prjid;\n    qryTask = toolbox.executeDbQuery("projectGantt","tasks",params);\n    while(qryTask.next()) \n    {\n      j = j + 1;\n      var barColor = "000000";\n      if (j == 1) barColor = "4F81BD";\n      if (j == 2) barColor = "C0504D";\n      if (j == 3) barColor = "9BBB59";\n      if (j == 4) barColor = "8064A2";\n      if (j == 5) barColor = "4BACC6";\n      if (j == 6) { barColor = "F79646"; j = 0;}\n\n      _gantt = _gantt + "g.AddTaskItem(new JSGantt.TaskItem(" + _prjid + qryTask.value("prjtask_id") + ", '" + qryTask.value("prjtask_name") + "', '" + qryTask.value("start_date") + "', '" + qryTask.value("due_date") + "', '" + barColor + "', '', 0, '', 0, 0, " + _prjid + ", 1));";\n    }\n\n    _gantt = _gantt + "g.Draw();";\n    _gantt = _gantt + "g.DrawDependencies();";\n    _gantt = _gantt + "}";\n    _gantt = _gantt + "else {";\n    _gantt = _gantt + ' alert("not defined");';\n    _gantt = _gantt + "  }";\n    _gantt = _gantt + "</script>";\n     \n    var html = _page + _gantt;\n    _webView.setHtml(html);\n    // This snippet should make the link open in a new browser, but nothing happens. Why?\n    //_webView.page().linkDelegationPolicy = QWebPage.DelegateAllLinks;\n}\n\n// Initialize\nmywindow.findChild("_close").triggered.connect(mywindow, "close");\n\n_layout.addWidget(_webView, 1, 0);\n\n// Create jsGantt files on local OS if they don't already exist\nvar tmpdir = QDir.tempPath();\n_jsPath = tmpdir + "/jsgantt.js";\n_cssPath = tmpdir + "/jscantt.css";\n\nif (!QFile.exists(_jsPath))\n{\n  // Create jsGantt script\n  qry = toolbox.executeDbQuery("projectGantt","jsgantt");\n  if (qry.first());\n    _jsCode = qry.value("script_source");\n\n  toolbox.textStreamWrite(_jsPath, _jsCode);\n\n  // Create jsGantt style sheet\n  qry = toolbox.executeDbQuery("projectGantt","jsganttcss");\n  if (qry.first());\n    _cssCode = qry.value("script_source");\n\n  toolbox.textStreamWrite(_cssPath, _cssCode);\n}\n       Time and Expense package
105767
 
116     project 0       t       /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.project = new Object;\n\nvar _tab = mywindow.findChild("_tab"); \nvar _tebilling = toolbox.loadUi("tebilling", mywindow);\n_tab.insertTab(2, _tebilling, qsTr("Billing"));\n_tab.setEnabled(2, privileges.check("CanViewRates"));\n\nvar _buttonBox = mywindow.findChild("_buttonBox");\nvar _gantt = _buttonBox.addButton(qsTr("Gantt..."), QDialogButtonBox.ActionRole);\n\nvar _owner = mywindow.findChild("_owner");\nvar _assignedTo = mywindow.findChild("_assignedTo");\nvar _started = mywindow.findChild("_started");\nvar _due = mywindow.findChild("_due");\nvar _assigned = mywindow.findChild("_assigned");\nvar _completed = mywindow.findChild("_completed");\nvar _prjtask = mywindow.findChild("_prjtask");\nvar _newTask = mywindow.findChild("_newTask");\nvar _editTask = mywindow.findChild("_editTask");\nvar _viewTask = mywindow.findChild("_viewTask");\nvar _number = mywindow.findChild("_number");\nvar _name = mywindow.findChild("_name");\nvar _billingGroup = mywindow.findChild("_billingGroup");\nvar _itemGroup = _tebilling.findChild("_itemGroup");\nvar _useItem = _tebilling.findChild("_useItem");\nvar _cust = _tebilling.findChild("_cust");\nvar _rate = _tebilling.findChild("_rate");\nvar _mode = 'new';\nvar _teprjid = -1; \nvar _prjid = -1;\n\n//set = function(input)\nxtte.project.populated = function(input)\n{\n  if (_number.enabled)\n    _mode = "edit";\n  else\n    _mode = "view";\n\n  if (input.mode == "view")\n  {\n    _cust.enabled = false;\n    _billingGroup.enabled = false;\n  }\n\n  sql = "SELECT prj_id FROM prj WHERE prj_number=<? value('prj_number') ?>;";\n  var params = new Object;\n  params.prj_number = _number.text;\n \n  var data = toolbox.executeQuery(sql, params);\n  if (data.first())\n  {\n    _prjid = data.value("prj_id");\n    xtte.project.populate();\n  }\n}\n\nxtte.project.save = function(prjId)\n{\n  if (prjId <= 0)\n    return;\n\n  var params = new Object();\n  params.teprj_id\t= _teprjid;\n  params.prj_id\t= prjId;\n  if (_cust.isValid())\n    params.cust_id  \t= _cust.id();\n  if (_billingGroup.checked)\n  {\n    params.rate\t= _rate.localValue;\n    params.curr_id\t= _rate.id();\n  }\n\n  var query = "updteprj";\n  if (_teprjid == -1)\n    query = "insteprj";\n\n  var q = toolbox.executeDbQuery("project", query, params);\n  xtte.errorCheck(q);\n}\n\nxtte.project.populate = function()\n{\n  var params = new Object();\n  params.prj_id = _prjid;    \n\n  var q = toolbox.executeDbQuery("project", "selteprj", params);\n\n  if (q.first())\n  {\n    _teprjid = q.value("teprj_id");\n    _cust.setId(q.value("cust_id"));\n    if (q.value("curr_id") == -1)\n      _billingGroup.checked = false;\n    else\n    {\n      _billingGroup.checked = true;\n      _rate.setId(q.value("curr_id"));\n      _rate.localValue = q.value("teprj_rate");\n    }\n    return;\n  }\n  else\n    xtte.errorCheck(q);\n}\n\nxtte.project.newTask = function()\n{\n  if (_prjid == -1)\n  {\n    if (!mywindow.sSave(true))\n      return;\n    else\n    {\n      var params = new Object;\n      params.prjNumber = _number.text;\n\n      var q = toolbox.executeDbQuery("projectGantt", "getprj", params);\n      if (q.first())\n        _prjid = q.value("prj_id");\n      else\n        return;\n    }\n  }\n\n  xtte.project.openTask("new");\n}\n\nxtte.project.editTask = function()\n{\n  xtte.project.openTask("edit");\n}\n\nxtte.project.viewTask = function()\n{\n  xtte.project.openTask("view");\n}\n\nxtte.project.openTask = function(mode)\n{\n  params = new Object;\n  params.mode = mode;\n  if (mode == "new")\n  {\n  params.prj_id = _prjid;\n  params.prj_owner_username = _owner.username();\n  params.prj_username = _assignedTo.username();\n  params.prj_start_date = _started.date;\n  params.prj_due_date = _due.date;\n  params.prj_assigned_date = _assigned.date;\n  params.prj_completed_date = _completed.date;\n  }\n  else\n    params.prjtask_id = _prjtask.id();\n  if (_cust.isValid())\n    params.cust_id = _cust.id();\n\n  var win = toolbox.openWindow("task", mywindow, Qt.ApplicationModal);\n  toolbox.lastWindow().set(params);\n  var result = win.exec();\n  if(result != 0)\n    mywindow.populate();\n}\n\nxtte.project.gantt = function()\n{\n  if (!_due.isValid())\n  {\n    var msg = qsTr("You must enter a valid Due Date");\n    QMessageBox.critical(mywindow, qsTr("Invalid Date"), msg);\n    return;\n  }\n\n  var dparams = new Object;\n  dparams.startDate = _started.date;\n  dparams.dueDate = _due.date;\n\n  var qry = toolbox.executeDbQuery("project","formatdates",dparams);\n  if (qry.first())\n  {\n    var params = new Object;\n    params.prjNumber = _number.text;\n    params.prjName = _name.text;\n    params.startDate = qry.value("start_date");\n    params.dueDate = qry.value("due_date");\n\n    toolbox.openWindow("projectGantt", mywindow, Qt.ApplicationModal);\n    toolbox.lastWindow().set(params);\n  }\n}\n\n// Initialize\n_itemGroup.hide();\n_useItem.hide();\n\n// Connections\ntoolbox.coreDisconnect(_newTask, "clicked()", mywindow, "sNewTask()");\ntoolbox.coreDisconnect(_editTask, "clicked()", mywindow, "sEditTask()");\ntoolbox.coreDisconnect(_viewTask, "clicked()", mywindow, "sViewTask()");\n\nmywindow.populated.connect(xtte.project.populated);\n_newTask.clicked.connect(xtte.project.newTask);\n_editTask.clicked.connect(xtte.project.editTask);\n_viewTask.clicked.connect(xtte.project.viewTask);\n_gantt.clicked.connect(xtte.project.gantt);\nmydialog["finished(int)"].connect(xtte.project.save);\n\n   Time and Expense package
105768
 
119     timeExpenseSheet        0       t       /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ndebugger;\nvar _debug = false;\ninclude("xtte");\n\ntry\n{\n  if (_debug)\n    print("xtte.timeExpenseSheet script entered");\n\n  // Define Variables\n  xtte.timeExpenseSheet = new Object;\n\n  var _all                = mywindow.findChild("_all");\n  var _buttonBox          = mywindow.findChild("_buttonBox");\n  var _edit               = mywindow.findChild("_edit");\n  var _new                = mywindow.findChild("_new");\n  var _delete             = mywindow.findChild("_delete");\n  var _view               = mywindow.findChild("_view");\n  var _print              = mywindow.findChild("_print");\n  var _printSheet         = mywindow.findChild("_printSheet");\n  var _lines              = mywindow.findChild("_lines");\n  var _selected           = mywindow.findChild("_selected");\n  var _weekending         = mywindow.findChild("_weekending");\n  var _employee           = mywindow.findChild("_employee");\n  var _sheetNumberExtra   = mywindow.findChild("_sheetNumberExtra");\n  var _site               = mywindow.findChild("_site");\n  var _orderComments      = mywindow.findChild("_orderComments");\n  var _documents          = mywindow.findChild("_documents");\n\n  var _sheet;\n  var _id = -1;\n  var _type;\n  var _admin;\n\n  _lines.addColumn(qsTr("Type"),\t\tXTreeWidget.docTypeColumn,Qt.AlignLeft,    false,  "teitem_type");\n\n  //add logic to determine the next Sunday date and populate both start and end with it\n  _lines.addColumn(qsTr("Line #"),        XTreeWidget.seqColumn,    Qt.AlignLeft,    true,   "teitem_linenumber");\n  _lines.addColumn(qsTr("Sheet Date"),    XTreeWidget.dateColumn,   Qt.AlignLeft,    false,  "tehead_weekending");\n  _lines.addColumn(qsTr("Work Date"),     XTreeWidget.dateColumn,   Qt.AlignLeft,    true,   "teitem_workdate");\n  _lines.addColumn(qsTr("Project#"),      XTreeWidget.orderColumn,  Qt.AlignLeft,    true,   "prj_number");\n  _lines.addColumn(qsTr("Project Name"),  -1,                       Qt.AlignLeft,    false,  "prj_name");\n  _lines.addColumn(qsTr("Task#"),         XTreeWidget.orderColumn,  Qt.AlignLeft,    true,   "prjtask_number");\n  _lines.addColumn(qsTr("Task Name"),     -1,                       Qt.AlignLeft,    false,  "prjtask_name");\n  _lines.addColumn(qsTr("Cust.#"),        XTreeWidget.orderColumn,  Qt.AlignLeft,    false,  "cust_number");\n  _lines.addColumn(qsTr("Cust. Name"),    -1,                       Qt.AlignLeft,    false,  "cust_name");\n  _lines.addColumn(qsTr("PO"),            XTreeWidget.orderColumn,  Qt.AlignLeft,    false,  "teitem_po");\n  _lines.addColumn(qsTr("Item"),          XTreeWidget.itemColumn,   Qt.AlignLeft,    true,   "item_number");\n  _lines.addColumn(qsTr("Description"),   -1,                       Qt.AlignLeft,    true,   "item_descrip1");\n  _lines.addColumn(qsTr("Hours"),         XTreeWidget.qtyColumn,    Qt.AlignRight,   true,   "hours");\n  _lines.addColumn(qsTr("Expense"),       XTreeWidget.qtyColumn,    Qt.AlignRight,   true,   "expense");\n  _lines.addColumn(qsTr("Notes"),         -1,    Qt.AlignLeft,    false,  "f_notes");\n\n\n  if (privileges.check("CanViewRates"))\n  {\n    _lines.addColumn(qsTr("Billable"),    XTreeWidget.ynColumn,     Qt.AlignLeft,    true,   "teitem_billable");\n    _lines.addColumn(qsTr("Rate"),        XTreeWidget.priceColumn,  Qt.AlignRight,   false,  "teitem_rate");\n    _lines.addColumn(qsTr("Extended"),    XTreeWidget.moneyColumn,  Qt.AlignRight,   false,  "teitem_total");\n  }\n\n}\n\ncatch (e)\n{\n  QMessageBox.critical(mywindow, "timeExpenseSheet",\n                       qsTr("timeExpenseSheet.js exception: ") + e);\n}\n\nset = function(input)\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.set entered");\n\n    if("emp_id" in input)\n      _employee.setId(input.emp_id); \n    \n    if("sheet" in input)  \n      _sheet = input.sheet;\n\n    if ("tehead_id" in input)\n    {\n      _id = input.tehead_id;\n      _documents.setId(_id);\n    }\n\n    if("mode" in input)\n    {\n      if (input.mode <= xtte.editMode)\n      {\n        _lines["valid(bool)"].connect(_edit["setEnabled(bool)"]);\n        _lines["valid(bool)"].connect(_delete["setEnabled(bool)"]);\n        _lines.itemSelected.connect(_edit, "animateClick");\n      }\n\n      if (input.mode == xtte.newMode)\n      {\n        _mode = "new";\n        _weekending.enabled = true;\n      }\n      else if (input.mode == xtte.editMode)\n      {\n        _mode = "edit";\n        _weekending.enabled = false;\n        _employee.enabled = false;\n        _site.enabled = false;\n        var shortcut = _buttonBox.button(QDialogButtonBox.Cancel).shortcut;\n        _buttonBox.removeButton(_buttonBox.button(QDialogButtonBox.Cancel));\n        _buttonBox.addButton(QDialogButtonBox.Close);\n        _buttonBox.button(QDialogButtonBox.Close).shortcut = shortcut;\n\n        xtte.timeExpenseSheet.populate();\n      }\n      else if (input.mode == xtte.viewMode)\n      {\n        _mode = "view";\n        _new.enabled = false;\n        _orderComments.enabled = false;\n        var shortcut = _buttonBox.button(QDialogButtonBox.Cancel).shortcut;\n        _buttonBox.clear();\n        _buttonBox.addButton(QDialogButtonBox.Close);\n        _buttonBox.button(QDialogButtonBox.Close).shortcut = shortcut;\n        _lines.itemSelected.connect(_view, "animateClick");\n        _printSheet.hide();\n\n        xtte.timeExpenseSheet.populate();\n      }\n    }\n    return mainwindow.NoError;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "timeExpenseSheet",\n                         qsTr("set exception: ") + e);\n  }\n}\n\nxtte.timeExpenseSheet.populateMenu = function(pMenu, pItem, pCol)\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.populateMenu entered");\n\n    var tmpact;\n\n    if(pMenu == null)\n      pMenu = _lines.findChild("_menu");\n\n    if(pMenu != null)\n    {\n      var currentItem  = _lines.currentItem();\n      if (currentItem != null)\n      {\n        tmpact = pMenu.addAction(qsTr("Edit..."));\n        tmpact.triggered.connect(xtte.timeExpenseSheet.editItem);\n        tmpact.enabled = (_mode != "view" && privileges.check("MaintainTimeExpense"));\n\n        tmpact = pMenu.addAction(qsTr("View..."));\n        tmpact.triggered.connect(xtte.timeExpenseSheet.viewItem);\n\n        tmpact = pMenu.addAction(qsTr("Delete..."));\n        tmpact.triggered.connect(xtte.timeExpenseSheet.deleteItem);\n        tmpact.enabled = (_mode != "view" && privileges.check("MaintainTimeExpense"));\n      }\n    }\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "timeExpenseSheet",\n                         qsTr("populateMenu exception: ") + e);\n  }\n}\n\nxtte.timeExpenseSheet.deleteItem = function()\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.deleteItem entered");\n\n    var msg = qsTr("Are you sure you want to delete this line?");\n    if (QMessageBox.question(mywindow, mywindow.windowTitle, msg,\n          QMessageBox.Yes | QMessageBox.Escape,\n          QMessageBox.No | QMessageBox.Default) == QMessageBox.Yes)\n    {\n      var params   = new Object();\n      params.teitem_id = _lines.id();\n\n      q = toolbox.executeDbQuery("timeexpensesheet","delteitem", params );\n      xtte.errorCheck(q);\n      xtte.timeExpenseSheet.fillList();\n    }\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "timeExpenseSheet",\n                         qsTr("deleteItem exception: ") + e);\n  }\n}\n\nxtte.timeExpenseSheet.newItem = function()\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.newItem entered");\n\n    if (!xtte.timeExpenseSheet.save())\n      return;\n\n    xtte.timeExpenseSheet.openItem(xtte.newMode);\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "timeExpenseSheet",\n                         qsTr("newItem exception: ") + e);\n  }\n}\n\nxtte.timeExpenseSheet.editItem = function()\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.editItem entered");\n\n    xtte.timeExpenseSheet.openItem(xtte.editMode);\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "timeExpenseSheet",\n                         qsTr("editItem exception: ") + e);\n  }\n}\n\nxtte.timeExpenseSheet.viewItem = function()\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.viewItem entered");\n\n    xtte.timeExpenseSheet.openItem(xtte.viewMode);\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "timeExpenseSheet",\n                         qsTr("viewItem exception: ") + e);\n  }\n}\n\nxtte.timeExpenseSheet.openItem = function(mode)\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.openItem entered");\n\n    var params   = new Object;\n    params.tehead_id = _id;\n    params.site = _site.text;\n    params.weekending = _weekending.date;\n    params.emp_id = _employee.id();\n    params.mode = mode;\n    if (mode) // Not new\n      params.teitem_id = _lines.id();\n\n    var wnd = toolbox.openWindow("timeExpenseSheetItem", mywindow);\n    toolbox.lastWindow().set(params);\n    wnd.exec();\n\n    xtte.timeExpenseSheet.fillList();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "timeExpenseSheet",\n                         qsTr("openItem exception: ") + e);\n  }\n}\n\nxtte.timeExpenseSheet.accepted = function()\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.accepted entered");\n\n    if (!xtte.timeExpenseSheet.save())\n      return;\n\n    if (_printSheet.checked)\n      xtte.timeExpenseSheet.printSheet();\n\n    mywindow.close();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "timeExpenseSheet",\n                         qsTr("accepted exception: ") + e);\n  }\n}\n\nxtte.timeExpenseSheet.save = function()\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.save entered");\n\n    if (!_employee.isValid())\n      throw new Error(qsTr("Employee Required"));\n\n    if (_site.id() == -1)\n      throw new Error(qsTr("Site Required"));\n\n    if (!_weekending.isValid())\n      throw new Error(qsTr("Week Ending Date Required"));\n\n    var params   = new Object();\n    params.tehead_id = _id;\n    params.emp_id = _employee.id();\n    params.warehous_id = _site.id();\n    params.weekending = _weekending.date;\n    params.notes = _orderComments.plainText;\n\n    var query = "updtehead";\n    if (_id == -1)\n      query = "instehead";\n\n    q = toolbox.executeDbQuery("timeexpensesheet", query, params );\n    if (q.first())\n    {\n      _id = q.value("tehead_id");\n      _documents.setId(_id);\n      _sheetNumberExtra.text = q.value("tehead_number");\n    }\n    else if (!xtte.errorCheck(q))\n      return false;\n\n    _weekending.enabled = false;\n    _employee.enabled = false;\n    _site.enabled = false;\n\n    return true;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, qsTr("timeExpenseSheet"), e.message);\n    return false;\n  }\n}\n\nxtte.timeExpenseSheet.handleNewButton = function()\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.handleNewButton entered");\n\n    _new.enabled = (_weekending.isValid() &&\n                    _employee.isValid() &&\n                    _mode != "view");\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "timeExpenseSheet",\n                        qsTr("handleNewButton exception: ") + e);\n  }\n}\n\nxtte.timeExpenseSheet.populate = function()\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.populate entered");\n\n    var params = new Object;\n    params.type = _type;\n    params.emp = _employee.id();\n    params.tehead_id = _id;\n\n    q = toolbox.executeDbQuery("timeexpensesheet", "header", params);\n\n    if (q.first())\n    {\n      _weekending.date = q.value("tehead_weekending");\n      _sheetNumberExtra.text = q.value("tehead_number");\n      _employee.setId(q.value("tehead_emp_id"));\n      _site.setId(q.value("tehead_warehous_id"));\n      _orderComments.setPlainText(q.value("tehead_notes"));\n    }\n    else if (!xtte.errorCheck(q))\n      return;\n\n    if (_mode == "view")\n    {\n      _weekending.enabled = false;\n      _employee.enabled = false;\n      _site.enabled = false;\n    }\n\n    xtte.timeExpenseSheet.fillList();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "timeExpenseSheet",\n                         qsTr("populate exception: ") + e);\n  }\n}\n\nxtte.timeExpenseSheet.testCurrEmpId = function()\n{\n  var params = new Object;\n  params.emp_id = _employee.id();\n  qry = toolbox.executeQuery("SELECT crmacct_emp_id = <? value('emp_id') ?>::integer AS test "\n                     + "FROM  crmacct "\n                     + "WHERE crmacct_usr_username = getEffectiveXtUser();", params);\n  if (qry.first()) {\n    return qry.value("test");\n  }\n  else\n    QMessageBox.information(mywindow, "Database Error", qry.lastError().text);\n  return false;\n}\n\nxtte.timeExpenseSheet.fillList = function()\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.fillList entered");\n\n    if ( ( privileges.check("MaintainEmpCostSelf") && xtte.timeExpenseSheet.testCurrEmpId()) || privileges.check("MaintainEmpCostAll") )\n    {\n      _lines.addColumn(qsTr("Hourly Cost"),   XTreeWidget.priceColumn,  Qt.AlignRight,   false,  "teitem_hrlycost");\n      _lines.addColumn(qsTr("Total Cost"),   XTreeWidget.priceColumn,  Qt.AlignRight,   false,  "teitem_totalcost");\n    }\n\n    var params = new Object;\n    params.tehead_id = _id;\n    params.time = qsTr("Time");\n    params.expense = qsTr("Expense");\n    params.error = qsTr("Error");\n\n    q = toolbox.executeDbQuery("timeexpensesheet", "detail", params);\n\n    _lines.populate(q);\n\n    xtte.errorCheck(q);\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "timeExpenseSheet",\n                         qsTr("fillList exception: ") + e);\n  }\n}\n\nxtte.timeExpenseSheet.printSheet = function()\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.printSheet entered");\n\n    var params = new Object;\n    params.tehead_id = _id;\n    params.approved  = qsTr("Approved");\n    params.closed    = qsTr("Closed");\n    params.open      = qsTr("Open");\n\n    toolbox.printReport("TimeExpenseSheet", params);\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "timeExpenseSheet",\n                         qsTr("printSheet exception: ") + e);\n  }\n}\n\nxtte.timeExpenseSheet.close = function()\n{\n  try\n  {\n    if (_debug)\n      print("xtte.timeExpenseSheet.close entered");\n\n    if (_mode == "new" && _id != -1)\n    {\n      if (QMessageBox.question(mywindow,\n                         qsTr("Delete Sheet"),\n                         qsTr("<p>Are you sure you want to cancel this "\n                         + "sheet and discard all your changes?"),\n                          QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes)\n      {\n        var params = new Object;\n        params.tehead_id = _id;\n\n        toolbox.executeDbQuery("timeexpensesheet", "deltehead", params);\n      }\n      else\n        return;\n    }\n\n    mywindow.close();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "timeExpenseSheet",\n                         qsTr("close exception: ") + e);\n  }\n}\n\n// Initialize\n_employee.enabled = privileges.check("MaintainTimeExpenseOthers");\n_new.enabled = false;\n\n// Make connections\n_employee.newId.connect(xtte.timeExpenseSheet.handleNewButton);\n_weekending.newDate.connect(xtte.timeExpenseSheet.handleNewButton);\n_lines["valid(bool)"].connect(_view["setEnabled(bool)"]);\n\n_buttonBox.accepted.connect(xtte.timeExpenseSheet.accepted);\n_buttonBox.rejected.connect(xtte.timeExpenseSheet.close);\n\n_new.clicked.connect(xtte.timeExpenseSheet.newItem);\n_edit.clicked.connect(xtte.timeExpenseSheet.editItem);\n_delete.clicked.connect(xtte.timeExpenseSheet.deleteItem);\n_view.clicked.connect(xtte.timeExpenseSheet.viewItem);\n\n_lines["populateMenu(QMenu *, XTreeWidgetItem *, int)"].connect(xtte.timeExpenseSheet.populateMenu);      Time and Expense package
105769
 
120     timeExpenseSheetItem    0       t       /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\n\n// Define local variables\nxtte.timeExpenseSheetItem = new Object;\n\nvar _hours              = mywindow.findChild("_hours");\nvar _total              = mywindow.findChild("_total");\t\nvar _totalLit           = mywindow.findChild("_totalLit");\t\nvar _rate               = mywindow.findChild("_rate");\nvar _rateLit            = mywindow.findChild("_rateLit");\nvar _clients            = mywindow.findChild("_clients");\nvar _employee           = mywindow.findChild("_employee");\nvar _items              = mywindow.findChild("_items");\nvar _po                 = mywindow.findChild("_po");\nvar _project            = mywindow.findChild("_project");\nvar _task               = mywindow.findChild("_task");\nvar _linenumber         = mywindow.findChild("_linenumber");\nvar _sheet              = mywindow.findChild("_sheet");\nvar _buttonBox          = mywindow.findChild("_buttonBox");\nvar _weekending         = mywindow.findChild("_weekending");\nvar _workdate           = mywindow.findChild("_workdate");\nvar _type               = mywindow.findChild("_type");\nvar _qtyLabel           = mywindow.findChild("_qtyLabel");\nvar _billable           = mywindow.findChild("_billable");\nvar _prepaid            = mywindow.findChild("_prepaid");\nvar _actual             = mywindow.findChild("_actual");\nvar _budget             = mywindow.findChild("_budget");\nvar _actualCost         = mywindow.findChild("_actualCost");\nvar _budgetCost         = mywindow.findChild("_budgetCost");\nvar _notes              = mywindow.findChild("_notes");\nvar _sheetLit           = mywindow.findChild("_sheetLit");\nvar _dayHrs             = mywindow.findChild("_dayHrs");\nvar _weekHrs            = mywindow.findChild("_weekHrs");\n\nvar _empcostLit\t\t\t= mywindow.findChild("_empcostLit");\nvar _empcost\t\t\t= mywindow.findChild("_empcost");\nvar _totCostLit         = mywindow.findChild("_totCostLit");\nvar _totCost            = mywindow.findChild("_totCost");\n\nvar _cancel = _buttonBox.button(QDialogButtonBox.Cancel);\nvar _prev = _buttonBox.addButton(qsTr("Prev"), QDialogButtonBox.ActionRole);\nvar _next = _buttonBox.addButton(qsTr("Next"), QDialogButtonBox.ActionRole);\n\nvar _sheetnum;\nvar _linenum;\nvar _teitemid = -1;\nvar _headid = -1;\nvar _taskid = -1;\nvar _site;\nvar _mode = xtte.newMode;\nvar _modified = false;\nvar _populating = false;\nvar _last = true;\n\n\nset = function(input)\n{\n  if("emp_id" in input)\n    _employee.setId(input.emp_id);\n  \n  if("weekending" in input)\n    _weekending.date = input.weekending;\n\n  if ("tehead_id" in input)\n    _headid = input.tehead_id;\n\n  if ("site" in input)\n    _site = input.site;\n\n  if ("teitem_id" in input)\n    _teitemid = input.teitem_id;\n\n  if ("mode" in input)\n  {\n    _mode = input.mode;\n\n      if (input.mode == xtte.newMode)\n      {\n          xtte.timeExpenseSheetItem.clear();\n      }\n      else if (input.mode == xtte.viewMode)\n      {\n        var shortcut = _buttonBox.button(QDialogButtonBox.Cancel).shortcut;\n        _buttonBox.removeButton(_buttonBox.button(QDialogButtonBox.Cancel));\n        _buttonBox.removeButton(_buttonBox.button(QDialogButtonBox.Save));\n        _buttonBox.addButton(QDialogButtonBox.Close);\n        _buttonBox.button(QDialogButtonBox.Close).shortcut = shortcut;\n        _weekending.enabled = false;\n        _next.enabled = false;\n        _prepaid.enabled = false;\n        _type.enabled = false;\n        _weekending.enabled = false;\n        _workdate.enabled = false;\n        _hours.enabled = false;\n        _rate.enabled = false;\n        _items.enabled = false;\n        _employee.enabled = false;\n        _clients.enabled = false;\n        _po.enabled = false;\n        _project.enabled = false;\n        _task.enabled = false;\n        _notes.enabled = false;\n        _billable.enabled = false; \n        _empcost.enabled = false;\n      }\n      else if (input.mode == xtte.editMode)\n      {\n        _project.enabled = false;\n        _task.enabled = false;\n      }\n\n      xtte.timeExpenseSheetItem.populate();\n   }\n\n  \n  return mainwindow.NoError;\n}\n\nxtte.timeExpenseSheetItem.extension = function()\n{\n  _total.localValue = (_hours.toDouble() * _rate.localValue);\n  _totCost.localValue = (_hours.toDouble() * _empcost.localValue);\n  if (_type.code == 'T')\n    xtte.timeExpenseSheetItem.empTotals();\n  xtte.timeExpenseSheetItem.modified();\n}\n\nxtte.timeExpenseSheetItem.gettask = function()\n{\n  if (_project.isValid())\n  {\n    var params = new Object();\n    params.prj_id = _project.id();\n    params.name = qsTr("Default");\n    if (_mode == xtte.newMode)\n      params.active = true;\n    if (_workdate.isValid())\n      params.startDate = _workdate.date;\n\n    var qry = toolbox.executeDbQuery("timeexpensesheetitem", "gettask", params);\n    if(!xtte.errorCheck(qry))\n      return;\n\n    _task.populate(qry);\n\n    if(_taskid > 0)\n      _task.setId(_taskid);\n\n    if (!qry.first())\n    {\n      var msg = qsTr("No task found. A default task will be added");\n      QMessageBox.critical(mywindow, qsTr("task"), msg);\n      toolbox.executeDbQuery("timeexpensesheetitem","instask",params);\n\n      qry = toolbox.executeDbQuery("timeexpensesheetitem", "gettask", params);\n      _task.populate(qry);\n    }\n\n    xtte.timeExpenseSheetItem.getPrice();\n    xtte.timeExpenseSheetItem.budgTotals();\n    xtte.timeExpenseSheetItem.actTotals();\n  }\n}\n\nxtte.timeExpenseSheetItem.modified = function()\n{\n  if (_populating)\n    return;\n\n  _modified = true;\n}\n\nxtte.timeExpenseSheetItem.getPrice = function()\n{\n  if (_populating)\n    return;\n  var params = new Object();\n  params.emp_id = _employee.id();\n  if(_type.code == 'T')\n  {\n    var qry2 = toolbox.executeQuery("SELECT te.calcRate(emp_wage, emp_wage_period) as cost "\n                                + "FROM emp WHERE emp_id = <? value('emp_id') ?>", params);\n    if (qry2.first())\n    {\n      _empcost.setBaseValue(qry2.value("cost"));\n      _totCost.setBaseValue(qry2.value("cost") * _hours.toDouble());\n    }\n  else\n    xtte.errorCheck(qry2);\n  }\n  if (!_clients.isValid())\n    return;\n  if (_type.code == 'T' && !_billable.checked)\n  {\n    _rate.localValue = 0;\n    _rate.enabled = false;\n  }      \n  else if (_mode == xtte.editMode)\n  {\n    if (QMessageBox.question(mywindow,\n                       qsTr("Update Rate?"),\n                       qsTr("<p>Would you like to update the existing rate?"),\n                        QMessageBox.Ok, QMessageBox.Cancel) == QMessageBox.Cancel)\n    return;\n  }\n\n  params.item_id = _items.id();\n  params.task_id = _task.id();\n  params.prj_id = _project.id();\n  params.cust_id = _clients.id();\n  if (_type.code == "T")\n    params.time = true;\n  \n  if(_billable.checked)\n  {\n    var qry = toolbox.executeDbQuery("timeexpensesheetitem", "getterate", params);\n    if (qry.first())\n    {\n      _rate.setBaseValue(qry.value("rate"));\n      _rate.enabled = true;\n    }\n    else\n      xtte.errorCheck(qry);\n  }  \n  \n  xtte.timeExpenseSheetItem.modified();\n}\n\nxtte.timeExpenseSheetItem.populate = function()\n{\n  _modified = false;\n \n  // Edit or View mode\n  var params = new Object();\n  params.teitem_id = _teitemid;\n\n  qry = toolbox.executeDbQuery("timeexpensesheetitem","detail", params);\n  if (qry.first())\n  {\n    if (_mode == xtte.newMode)\n      _mode = xtte.editMode;\n    _populating = true; \n\n    _headid = qry.value("teitem_tehead_id");\n    _sheet.text = (qry.value("tehead_number"));\n    _sheetnum = (qry.value("tehead_number"));\n    _employee.setId(qry.value("tehead_emp_id"));\n    _weekending.date = (qry.value("tehead_weekending"));\n\n    _linenumber.text = (qry.value("teitem_linenumber"));\n    _linenum = (qry.value("teitem_linenumber"));\n    _workdate.date = (qry.value("teitem_workdate"));\n    _type.code = qry.value("teitem_type");\n    _clients.setId(qry.value("teitem_cust_id"));\n    _po.text = (qry.value("teitem_po"));\n    _items.setId(qry.value("teitem_item_id"));\n    _hours.text = (qry.value("teitem_qty"));\n    _rate.setId(qry.value("teitem_curr_id") - 0);\n    _rate.localValue = (qry.value("teitem_rate"));\n    _total.localValue = (qry.value("teitem_total"));\n    _project.setId(qry.value("prj_id"));\n    _task.setId(qry.value("teitem_prjtask_id"));\n    _billable.checked = qry.value("teitem_billable");\n    _prepaid.checked = qry.value("teitem_prepaid")\n    _notes.plainText = qry.value("teitem_notes");\n    _empcost.localValue = qry.value("teitem_hrlycost");\n    _totCost.localValue = qry.value("teitem_hrlycost")*qry.value("teitem_qty");\n\n    _last = qry.value("ismax");\n    if (_last && _mode == xtte.editMode)\n      _next.text = qsTr("New");\n    else\n      _next.text = qsTr("Next");\n\n    _next.enabled = !(_last && _mode == xtte.viewMode);\n    _prev.enabled = (_linenum > 1);\n\n    _populating = false;\n    _modified = false;\n  }\n  else if (!xtte.errorCheck)\n    return;\n\n  xtte.timeExpenseSheetItem.empTotals();\n}\n\nxtte.timeExpenseSheetItem.accepted = function()\n{\n  if (xtte.timeExpenseSheetItem.save())\n  {\n    if (_mode == xtte.newMode)\n      xtte.timeExpenseSheetItem.clear();\n    else\n      mywindow.close();\n  }\n}\n\nxtte.timeExpenseSheetItem.save = function()\n{\n  try\n  {\n    if (!_workdate.isValid())\n      throw new Error(qsTr("Work Date Required"));\n    \n    if (!_project.isValid())\n      throw new Error(qsTr("Project Required"));\n \n    if (!_items.isValid())\n      throw new Error(qsTr("Item Required"));\n\n    if (_task.id == -1)\n      throw new Error(qsTr("Task Required"));\n\n    if (_hours.toDouble < 0 && _billable.checked)\n      throw new Error(qsTr("Billing of negative amounts is not supported"));\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, qsTr("Processing Error"), e.message);\n    return false;\n  }\n\n  if (_hours.toDouble() <= 0 && _type.code == 'E' && !_prepaid.checked)\n  {\n    var msg = qsTr("The system only supports vouchering positive expense quantities.  "\n            +      "Do you want to save anyway?")\n    if (QMessageBox.question( mywindow, mywindow.windowTitle, msg, \n        QMessageBox.Yes | QMessageBox.Escape, QMessageBox.No | QMessageBox.Default) == QMessageBox.No)\n      return false;\n  }\n\n\n  var params = new Object();\n  params.teitem_tehead_id      = _headid;\n  params.teitem_linenumber     = _linenum;\n  params.teitem_type \t       = _type.code;\n  params.teitem_workdate       = _workdate.date;\n  params.teitem_cust_id        = _clients.id();\n  params.teitem_po             = _po.text;\n  params.teitem_item_id        = _items.id();\n  params.teitem_qty            = _hours.toDouble();\n  params.teitem_rate           = _rate.localValue;\n  params.teitem_total          = _total.localValue;\n  params.teitem_prjtask_id     = _task.id();\n  params.teitem_billable       = _billable.checked;\n  params.teitem_prepaid        = _prepaid.checked;\n  params.teitem_notes          = _notes.plainText;\n  params.teitem_id             = _teitemid;\n  params.teitem_curr_id        = _rate.id();\n  params.teitem_empcost        = _empcost.localValue;\n\n  var query = "updteitem";\n  if (_teitemid < 0)\n    query = "insteitem";\n\n  var q = toolbox.executeDbQuery("timeexpensesheetitem", query, params);\n  if (q.first())\n    _teitemid = q.value("teitem_id");\n  else if (!xtte.errorCheck(q))\n    return;\n\n  _prev.enabled = true;\n\n  return true;\n}\n\n\nxtte.timeExpenseSheetItem.typeChanged = function()\n{\n  if (_type.code == "T")\n  {\n    _qtyLabel.text = qsTr("Hours:");\n    _rateLit.text = qsTr("Rate:");\n    _rate.enabled = _clients.isValid();\n    _billable.visible = true;\n    _prepaid.visible = false;\n    _prepaid.checked = false;\n    _empcost.enabled = true;\n  } \n  else\n  {\n    _qtyLabel.text = qsTr("Qty:");\n    _rateLit.text = qsTr("Unit Cost:");\n    _billable.visible = true;\n    _prepaid.visible = true;\n    _empcost.enabled = false;\n    _empcost.localValue = 0;\n    _rate.enabled = true;\n    _rate.localValue = 0;\n\n     var params = new Object();\n     params.emp_id = _employee.id();\n\n     var qry = toolbox.executeQuery("SELECT COALESCE (crmacct_vend_id,-1) AS crmacct_vend_id FROM crmacct WHERE crmacct_emp_id= <? value('emp_id')?>;",params);\n\n     if (qry.first())\n     {\n       var vend_id= qry.value("crmacct_vend_id");\n       if(vend_id ==-1)\n       {\n         var msg = qsTr("The Employee is not a Vendor, this expense cannot be vouchered.  "\n                   +      "Do you want to continue?")\n         if (QMessageBox.question( mywindow, mywindow.windowTitle, msg,\n               QMessageBox.Yes | QMessageBox.Escape, QMessageBox.No | QMessageBox.Default) == QMessageBox.No)\n         {\n           _type.code= "T";\n           return false;\n         }\n       }\n     }\n  }\n  xtte.timeExpenseSheetItem.getPrice();\n  xtte.timeExpenseSheetItem.empTotals();\n  xtte.timeExpenseSheetItem.modified();\n}\n\nxtte.timeExpenseSheetItem.customerChanged = function()\n{\n  _billable.enabled = _clients.isValid();\n  _rate.enabled = (_clients.isValid() || _type.code == 'E');\n\n  if (_populating)\n    return;\n\n  if (!_clients.isValid())\n  {\n    _po.clear();\n    _rate.localValue = 0;\n    _billable.checked = false;\n  }\n\n  var params = new Object;\n  params.cust_id = _clients.id();\n\n  q = toolbox.executeDbQuery("timeexpensesheetitem", "getcustinfo", params);\n  if (q.first())\n    _rate.setId(q.value("cust_curr_id") - 0);\n  else if (!xtte.errorCheck(q))\n    return;\n\n  xtte.timeExpenseSheetItem.getPrice();\n}\n\nxtte.timeExpenseSheetItem.projectChanged = function()\n{\n  //enable and reset the task fields\n  _task.enabled = (_project.isValid() && _mode == xtte.newMode);\n\n  xtte.timeExpenseSheetItem.gettask();\n  xtte.timeExpenseSheetItem.modified();\n  xtte.timeExpenseSheetItem.getPrice();\n}\n\n\nxtte.timeExpenseSheetItem.taskChanged = function()\n{  \n  var custid = -1;\n  var itemid = -1;\n  var params = new Object;\n  params.prjtask_id = _task.id();\n\n  q = toolbox.executeDbQuery("timeexpensesheetitem", "taskdefaults", params);\n  if (q.first())\n  {\n    custid = q.value("cust_id");\n    itemid = q.value("item_id")\n  }\n  else if (!xtte.errorCheck(q))\n    return;\n\n  if (_populating)\n  {\n    // Disable if customer matches default, otherwise default must have changed\n    // so allow for editing so user can decide what to do\n    _clients.enabled = !(_clients.isValid() && _clients.id() == custid)\n    _items.enabled = !(_items.isValid() && _items.id() == itemid)\n  }\n  else\n  {\n    if (custid > 0)\n    {\n      _clients.setId(custid);\n      _clients.enabled = false;\n    }\n    else\n      _clients.enabled = true;\n\n    if (itemid > 0)\n    {\n      _items.setId(itemid);\n      _items.enabled = false;\n    }\n    else\n      _items.setId(-1);\n      _items.enabled = true;\n  }\n\n  xtte.timeExpenseSheetItem.getPrice();\n  xtte.timeExpenseSheetItem.budgTotals();\n  xtte.timeExpenseSheetItem.actTotals();\n  xtte.timeExpenseSheetItem.modified();\n}\n\nxtte.timeExpenseSheetItem.budgTotals = function()\n{\n  var params = new Object;\n  params.prj_id = _project.id();\n  params.task_id = _task.id();\n \n  var q = toolbox.executeDbQuery("timeexpensesheetitem", "taskbudg",params);\n  if (q.first())\n  {\n    _budget.text = q.value("budget_hours");        \n    _actual.text = q.value("actual_hours");       \n    _budgetCost.text = q.value("budget_cost");        \n    _actualCost.text = q.value("actual_cost");        \n    \n  }\n  else \n    xtte.errorCheck(q);\n}\n\n\nxtte.timeExpenseSheetItem.actTotals = function()\n{\n  var params = new Object;\n  params.task_id = _task.id();\n  params.teitem_id = _teitemid;\n\n  var expense = 0;\n  var hours = 0;  \n\n  // get the task actuals then add the current\n  var q = toolbox.executeDbQuery("timeexpensesheetitem","taskrollup",params);\n\n  if (q.first())\n  {\n      _actual.text = q.value("total_hours");\n      _actualCost.text = q.value("total_expense");\n  } \n  else\n    xtte.errorCheck(q);\n}\n\nxtte.timeExpenseSheetItem.empTotals = function()\n{\n  if (_populating)\n    return;\n\n  var params = new Object;\n  params.teitem_id = _teitemid;\n  params.tehead_id = _headid;\n  params.emp_id = _employee.id();\n  params.workDate = _workdate.date;\n  if (_type.code == 'T')\n    params.hours = _hours.toDouble() - 0;\n\n  var q = toolbox.executeDbQuery("timeexpensesheetitem", "emptotals", params);\n\n  if (q.first())\n  {\n    _dayHrs.setText(q.value("day_hours"));\n    _weekHrs.setText(q.value("sheet_hours"));\n  } \n  else\n    xtte.errorCheck(q);\n}\n\nxtte.timeExpenseSheetItem.prev = function()\n{\n  if ( (_modified) && (_mode != xtte.viewMode) )\n  {\n    if (QMessageBox.question(mywindow,\n                       qsTr("Unsaved Changed"),\n                       qsTr("<p>You have made some changes "\n                       + "which have not yet been saved!</p><p>"\n                       + "Would you like to save them now?"),\n                        QMessageBox.Save, QMessageBox.No) == QMessageBox.Save)\n    {\n      if (!xtte.timeExpenseSheetItem.save())\n        return;\n    }\n  }\n\n  var params = new Object;\n  if (_teitemid > 0)\n    params.teitem_id = _teitemid;\n  else\n    params.tehead_id = _headid;\n\n  var q = toolbox.executeDbQuery("timeexpensesheetitem", "teitemprev", params);\n\n  if (q.first())\n  {\n    _teitemid = q.value("teitem_id");\n    _modified = false;\n\n    if (_mode == xtte.newMode)\n      _mode = xtte.editMode;\n\n    _next.enabled = true;\n    xtte.timeExpenseSheetItem.populate();\n  }\n  else\n    xtte.errorCheck(q);\n}\n\n\nxtte.timeExpenseSheetItem.next = function()\n{\n  if ( (_modified) && (_mode != xtte.viewMode) )\n  {\n\n    if (QMessageBox.question(mywindow,\n                       qsTr("Unsaved Changed"),\n                       qsTr("<p>You have made some changes "\n                       + "which have not yet been saved!\\n" \n                       + "Would you like to save them now?"),\n                        QMessageBox.Save, QMessageBox.Cancel) != QMessageBox.Save)\n      return;\n\n    if (!xtte.timeExpenseSheetItem.save())\n      return;\n  }\n\n  if (_last)\n    xtte.timeExpenseSheetItem.clear();\n  else\n  {\n    var params = new Object;\n    params.teitem_id = _teitemid;\n    var q = toolbox.executeDbQuery("timeexpensesheetitem","teitemnext",params);\n\n    if (q.first())\n    {\n      _modified = false;\n      _teitemid = q.value("teitem_id");\n      _prev.enabled = true;\n      xtte.timeExpenseSheetItem.populate();\n    }\n    else if (xtte.errorCheck(q))\n      xtte.timeExpenseSheetItem.clear();\n  }\n}\n\nxtte.timeExpenseSheetItem.clear = function()\n{\n  var params = new Object();\n  params.tehead_id = _headid;\n\n  var q = toolbox.executeDbQuery("timeexpensesheet","header",params);\n\n  if (q.first())\n  {\n    _weekending.date = (q.value("tehead_weekending"));      \n    _sheet.text = (q.value("tehead_number"));\n    _sheetnum = (q.value("tehead_number"));\n    _employee.setId(q.value("tehead_emp_id"));\n  }\n  else if (!xtte.errorCheck(q))\n    return;\n\n  q = toolbox.executeDbQuery("timeexpensesheetitem", "nextlinenum", params);\n  if (q.first())\n  {\n    _linenumber.setText(q.value("linenumber"));\n    _linenum = (q.value("linenumber"));\n  } \n  else \n    xtte.errorCheck(q);\n\n  _mode = xtte.newMode;\n  _teitemid = -1;\n  _prev.enabled = true;\n  _type.enabled = true;\n  _workdate.clear();\n  _workdate.enabled = true;\n  _workdate.setFocus();\n  _hours.text = "0.0";\n  _hours.enabled = true;\n  _rate.localValue = 0;\n  _empcost.enabled = true;\n  _empcost.localValue = 0;\n  _items.enabled = true;\n  _items.setId(-1);\n  _employee.enabled = false;\n  _clients.enabled = true;\n  _po.clear();\n  _po.enabled = true;\n  _project.enabled = true;\n  _task.enabled = true;\n  _notes.clear();\n  _notes.enabled = true;\n  _next.text = qsTr("New");\n  _next.enabled = false;\n\n  xtte.timeExpenseSheetItem.getPrice();\n\n  _modified = false;\n}\n\n\nxtte.timeExpenseSheetItem.setSecurity = function()\n{\n  if (privileges.check("CanViewRates"))\n  {\n    _rate.visible = true;\n    _total.visible = true;\n    _rateLit.visible = true;\n    _totalLit.visible = true;\n  }\n  else\n  {\n    _rate.visible = false;\n    _total.visible = false;\n    _rateLit.visible = false;\n    _totalLit.visible = false;\n  }\n  if ( ( privileges.check("MaintainEmpCostSelf") && xtte.timeExpenseSheetItem.testCurrEmpId()) || privileges.check("MaintainEmpCostAll") ) \n  {\n    _empcostLit.visible = true;\n    _empcost.visible = true;\n    _totCostLit.visible = true;\n    _totCost.visible = true;\n  }\n  else\n  {\n    _empcostLit.visible = false;\n    _empcost.visible = false;\n    _totCostLit.visible = false;\n    _totCost.visible = false;\n  }\t\n}\n\nxtte.timeExpenseSheetItem.testCurrEmpId = function()\n{\n  var params = new Object;\n  params.emp_id = _employee.id();\n  qry = toolbox.executeQuery("SELECT crmacct_emp_id = <? value('emp_id') ?>::integer AS test "\n                     + "FROM  crmacct "\n                     + "WHERE crmacct_usr_username = getEffectiveXtUser();", params);\n  if (qry.first()) {\n    return qry.value("test");\n  }\n  else \n    QMessageBox.information(mywindow, "Database Error", qry.lastError().text);\n  return false;\n}\n\n// Initialize default states\n_hours.setValidator(mainwindow.transQtyVal());\n\n_prev.enabled = false;\n_next.enabled = false;\n_task.enabled = false;\n_weekending.enabled = false;\n_linenumber.enabled = true;\n_employee.enabled = false;\n_total.enabled = false;\n_total.readonly = true;\n_rate.enabled = false;\n_billable.visible = true;\n_billable.enabled = false;\n_prepaid.visible = false;\n_next.enabled = false;\n\n_type.append(1, qsTr("Time"), "T");\n_type.append(2, qsTr("Expense"), "E");\n\n_items.setQuery(xtte.itemSql);\n\n_project.setAllowedStatuses(0x02); // In process\n\n// Define connections\n_buttonBox.accepted.connect(xtte.timeExpenseSheetItem.accepted);\n_buttonBox.rejected.connect(mydialog, "reject");\n_prev.clicked.connect(xtte.timeExpenseSheetItem.prev);\n_next.clicked.connect(xtte.timeExpenseSheetItem.next);\n\n_task.newID.connect(xtte.timeExpenseSheetItem.taskChanged);\n_rate.valueChanged.connect(xtte.timeExpenseSheetItem.extension);\n_workdate.newDate.connect(xtte.timeExpenseSheetItem.empTotals);\n_hours.textChanged.connect(xtte.timeExpenseSheetItem.extension);\n_empcost.valueChanged.connect(xtte.timeExpenseSheetItem.extension);\n_hours.editingFinished.connect(xtte.timeExpenseSheetItem.actTotals);\n_rate.valueChanged.connect(xtte.timeExpenseSheetItem.actTotals);\n_type.newID.connect(xtte.timeExpenseSheetItem.typeChanged);\n_items["newId(int)"].connect(xtte.timeExpenseSheetItem.getPrice);\n_clients["newId(int)"].connect(xtte.timeExpenseSheetItem.customerChanged);\n_project["newId(int)"].connect(xtte.timeExpenseSheetItem.projectChanged);\n_employee.newId.connect(xtte.timeExpenseSheetItem.modified);\n_po.textChanged.connect(xtte.timeExpenseSheetItem.modified);\n_workdate.newDate.connect(xtte.timeExpenseSheetItem.modified);\n_billable.toggled.connect(xtte.timeExpenseSheetItem.getPrice);\n_prepaid.toggled.connect(xtte.timeExpenseSheetItem.modified);\n_notes.textChanged.connect(xtte.timeExpenseSheetItem.modified);\n\nxtte.timeExpenseSheetItem.getPrice();\n_employee["newId(int)"].connect(xtte.timeExpenseSheetItem.setSecurity);\n Time and Expense package
105770
 
121     timeExpenseSheets       0       t       /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\n\n// Define Variables\nxtte.timeExpenseSheets = new Object;\n\nvar _all              = mywindow.findChild("_all");\nvar _close            = mywindow.findChild("_close");\nvar _query            = mywindow.findChild("_query");\nvar _new              = mywindow.findChild("_new");\nvar _print            = mywindow.findChild("_print");\nvar _sheets           = mywindow.findChild("_sheets");\nvar _selected         = mywindow.findChild("_selected");\nvar _approve          = mywindow.findChild("_approve");\nvar _process          = mywindow.findChild("_process");\nvar _weekending       = mywindow.findChild("_weekending");\nvar _showAllEmployees = mywindow.findChild("_showAllEmployees");\nvar _employee         = mywindow.findChild("_employee");\nvar _selected         = mywindow.findChild("_selected");\nvar _open             = mywindow.findChild("_open");\nvar _approved         = mywindow.findChild("_approved");\nvar _closed           = mywindow.findChild("_closed");\nvar _invoice          = mywindow.findChild("_invoice");\nvar _voucher          = mywindow.findChild("_voucher");\nvar _post             = mywindow.findChild("_post");\n\n// Set up columns\n_sheets.addColumn(qsTr("Sheet#"), XTreeWidget.orderColumn, Qt.AlignLeft,    true, "tehead_number");\n_sheets.addColumn(qsTr("Date"),   XTreeWidget.dateColumn, Qt.AlignLeft,    true, "tehead_weekending");\n_sheets.addColumn(qsTr("Employee"),   -1, Qt.AlignLeft,    true, "emp_code");\n_sheets.addColumn(qsTr("Status"),     XTreeWidget.bigMoneyColumn, Qt.AlignCenter, true, "tehead_status");\nif (privileges.check("CanViewRates")) {\n  _sheets.addColumn(qsTr("To Invoice"),   XTreeWidget.bigMoneyColumn, Qt.AlignLeft,    true, "total_i");\n  _sheets.addColumn(qsTr("To Voucher"),   XTreeWidget.bigMoneyColumn, Qt.AlignLeft,    true, "total_e");\n}\n_sheets.addColumn(qsTr("Invoiced"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "invoiced");\n_sheets.addColumn(qsTr("Vouchered"),XTreeWidget.dateColumn, Qt.AlignLeft, true, "vouchered");\n_sheets.addColumn(qsTr("Posted"),   XTreeWidget.dateColumn, Qt.AlignLeft, true, "posted");\n\nxtte.timeExpenseSheets.populateMenu = function(pMenu, pItem, pCol)\n{\n  var tmpact;\n\n  if(pMenu == null)\n    pMenu = _sheets.findChild("_menu");\n\n  if(pMenu != null)\n  {\n    var currentItem  = _sheets.currentItem();\n    var selected = _sheets.selectedItems();\n\n    if (currentItem != null)\n    {\n      if (selected.length == 1) // Can only handle editing for a single select\n      {\n        var status = currentItem.rawValue("tehead_status");\n\n        tmpact = pMenu.addAction(qsTr("Print"));\n        tmpact.triggered.connect(xtte.timeExpenseSheets.printSheet);\n\n        pMenu.addSeparator();\n\n        tmpact = pMenu.addAction(qsTr("Edit..."));\n        tmpact.triggered.connect(xtte.timeExpenseSheets.editSheet);\n        tmpact.enabled = (status == 'O' && privileges.check("MaintainTimeExpense"));\n \n        tmpact = pMenu.addAction(qsTr("View..."));\n        tmpact.triggered.connect(xtte.timeExpenseSheets.viewSheet);\n  \n        tmpact = pMenu.addAction(qsTr("Delete"));\n        tmpact.triggered.connect(xtte.timeExpenseSheets.deleteSheet);\n        tmpact.enabled = (status == 'O' && privileges.check("MaintainTimeExpense"));\n      }\n\n      if (xtte.timeExpenseSheets.canApprove(selected))\n      {\n        pMenu.addSeparator();\n        tmpact = pMenu.addAction(qsTr("Approve"));\n        tmpact.enabled = privileges.check("CanApprove");\n        tmpact.triggered.connect(xtte.timeExpenseSheets.approveSheets);\n      }\n      else if (xtte.timeExpenseSheets.canUnapprove(selected))\n      {\n        pMenu.addSeparator();\n        tmpact = pMenu.addAction(qsTr("Unapprove"));\n        tmpact.enabled = privileges.check("CanApprove");\n        tmpact.triggered.connect(xtte.timeExpenseSheets.unapproveSheets);\n      }\n\n      if (status == 'A' || status == 'O')\n      {\n        tmpact = pMenu.addAction(qsTr("Close"));\n        tmpact.enabled = privileges.check("MaintainTimeExpense");\n        tmpact.triggered.connect(xtte.timeExpenseSheets.closeSheet);\n      }\n\n      if ((xtte.timeExpenseSheets.canProcess("invoiced", selected)) ||\n          (xtte.timeExpenseSheets.canProcess("vouchered", selected)) ||\n          (xtte.timeExpenseSheets.canProcess("posted", selected)))\n        pMenu.addSeparator();\n\n      if (xtte.timeExpenseSheets.canProcess("invoiced", selected))\n      {\n        tmpact = pMenu.addAction(qsTr("Invoice"));\n        tmpact.triggered.connect(xtte.timeExpenseSheets.invoiceSheets);\n        tmpact.enabled = privileges.check("allowInvoicing");\n      }\n\n      if (xtte.timeExpenseSheets.canProcess("vouchered", selected))\n      {\n        tmpact = pMenu.addAction(qsTr("Voucher"));\n        tmpact.triggered.connect(xtte.timeExpenseSheets.voucherSheets);\n        tmpact.enabled = privileges.check("allowVouchering");\n      }\n\n      if (xtte.timeExpenseSheets.canProcess("posted", selected))\n      {\n        tmpact = pMenu.addAction(qsTr("Post Time"));\n        tmpact.triggered.connect(xtte.timeExpenseSheets.postSheets);\n        tmpact.enabled = privileges.check("PostTimeSheets");\n      }\n    }\n  }\n}\n\nxtte.timeExpenseSheets.canApprove = function(selected)\n{\n  for (var i = 0; i < selected.length; i++)\n  {\n     if (selected[i].rawValue("tehead_status") != 'O')\n       return false;\n  }\n  return true;\n}\n\nxtte.timeExpenseSheets.canUnapprove = function(selected)\n{\n  for (var i = 0; i < selected.length; i++)\n  {\n     if ((selected[i].rawValue("tehead_status") != 'A') ||\n         (selected[i].rawValue("posted") > 0) ||\n         (selected[i].rawValue("vouchered") > 0) ||\n         (selected[i].rawValue("invoiced") > 0))\n       return false;\n  }\n  return true;\n}\n\nxtte.timeExpenseSheets.canProcess = function(process, selected)\n{\n  for (var i = 0; i < selected.length; i++)\n  {\n     if ((selected[i].rawValue("tehead_status") != 'A') ||\n         (selected[i].rawValue(process) != 0))\n       return false;\n  }\n  return true;\n}\n\nxtte.timeExpenseSheets.approve = function()\n{\n  toolbox.executeBegin();\n  for (var i = 0; i < _sheets.topLevelItemCount; i++)\n  {\n    var item = _sheets.topLevelItem(i);\n    if (item.rawValue("tehead_status") == "O")\n    {\n      var params   = new Object();\n      params.tehead_id = item.id(); \n \n      q = toolbox.executeDbQuery("timeexpensesheets", "approve", params );\n      if (!xtte.errorCheck(q))\n      {\n        toolbox.executeRollback();\n        return;\n      }\n    } \n  }\n  toolbox.executeCommit();\n  xtte.timeExpenseSheets.fillList();\n}\n\nxtte.timeExpenseSheets.approveSheets = function()\n{\n  toolbox.executeBegin();\n  var selected = _sheets.selectedItems();\n  for (var i = 0; i < selected.length; i++)\n  {\n    var params   = new Object();\n    params.tehead_id = selected[i].id();    \n\n    q = toolbox.executeDbQuery("timeexpensesheets", "approve", params );        \n    if (!xtte.errorCheck(q))\n    {\n      toolbox.executeRollback();\n      return;\n    }\n  }\n  toolbox.executeCommit();\n  xtte.timeExpenseSheets.fillList(); \n}\n\nxtte.timeExpenseSheets.unapproveSheets = function()\n{\n  toolbox.executeBegin();\n  var selected = _sheets.selectedItems();\n  for (var i = 0; i < selected.length; i++)\n  {\n    var params   = new Object();\n    params.tehead_id = selected[i].id();    \n\n    q = toolbox.executeDbQuery("timeexpensesheets", "unapprove", params );      \n    if (!xtte.errorCheck(q))\n    {\n      toolbox.executeRollback();\n      return;\n    }\n  }\n  toolbox.executeCommit();\n  xtte.timeExpenseSheets.fillList(); \n}\n\n\nxtte.timeExpenseSheets.invoiceSheets = function()\n{\n  xtte.timeExpenseSheets.processSheets(_sheets.selectedItems(), true, false, false);\n} \n\nxtte.timeExpenseSheets.voucherSheets = function()\n{\n  xtte.timeExpenseSheets.processSheets(_sheets.selectedItems(), false, true, false);\n}\n\nxtte.timeExpenseSheets.postSheets = function()\n{    \n  xtte.timeExpenseSheets.processSheets(_sheets.selectedItems(), false, false, true);\n}\n\nxtte.timeExpenseSheets.process = function()\n{\n  toolbox.executeBegin();\n\n  // First loop through and invoice\n  if (_invoice.checked)\n  {\n    var ids = [];\n    for (var i = 0; i < _sheets.topLevelItemCount; i++)\n    {\n      var item = _sheets.topLevelItem(i);\n      if ((item.rawValue("tehead_status") == 'A') &&\n          (item.rawValue("invoiced") == 0)) \n        ids[i] = item.id();\n    }\n\n    if (ids.length)\n    {\n      var params   = new Object();\n      params.tehead_ids = ids;    \n\n      q = toolbox.executeDbQuery("timeexpensesheets", "invoice", params );      \n      if (!xtte.errorCheck(q))\n      {\n        toolbox.executeRollback();\n        return;\n      }\n    }\n  }\n\n  // Now loop through and do the others\n  for (var i = 0; i < _sheets.topLevelItemCount; i++)\n  {\n    var item = _sheets.topLevelItem(i);\n    var params   = new Object();\n    params.tehead_id = item.id();  \n\n    if ((_voucher.checked) && \n        (item.rawValue("tehead_status") == 'A') &&\n        (item.rawValue("vouchered") == 0))\n    {\n      q = toolbox.executeDbQuery("timeexpensesheets", "voucher", params );      \n      if (!xtte.errorCheck(q))\n      {\n        toolbox.executeRollback();\n        return;\n      }\n    }\n\n    if ((_post.checked) && \n        (item.rawValue("tehead_status") == 'A') &&\n        (item.rawValue("posted") == 0))\n    {\n      if (metrics.value("PrjLaborAndOverhead") - 0 <= 0)\n      {\n        QMessageBox.critical(mywindow, qsTr("Setup Error"),\n                         qsTr("No Labor and Overhead Account defined in CRM Setup."));\n        {\n          toolbox.executeRollback();\n          return;\n        }\n      }\n\n      params.phrase1 = qsTr("Post Time Sheet for ");\n      params.phrase2 = qsTr(" to Project");\n\n      q = toolbox.executeDbQuery("timeexpensesheets", "post", params );   \n      if (!xtte.errorCheck(q))\n      {\n        toolbox.executeRollback();\n        return;\n      }\n    } \n  }\n\n  toolbox.executeCommit();\n\n  if (_invoice.checked)\n    mainwindow.invoicesUpdated(1, true);\n\n  if (_voucher.checked)\n    mainwindow.vouchersUpdated();\n\n  if (_post.checked)\n    mainwindow.glSeriesUpdated();\n\n  xtte.timeExpenseSheets.fillList();\n}\n\nxtte.timeExpenseSheets.processSheets = function(selected, invoice, voucher, post)\n{\n  toolbox.executeBegin();\n  if (invoice)\n  { \n    // Create an array so invoices can be consolidated\n    var ids = [];\n    for (var i = 0; i < selected.length; i++)\n      ids[i] = selected[i].id();\n      \n    var params   = new Object();\n    params.tehead_ids = ids;    \n\n    q = toolbox.executeDbQuery("timeexpensesheets", "invoice", params );        \n    if (!xtte.errorCheck(q))\n    {\n      toolbox.executeRollback();\n      return false;\n    }\n  }\n\n  for (var i = 0; i < selected.length; i++)\n  {\n    var params   = new Object();\n    params.tehead_id = selected[i].id();  \n\n    if (voucher)\n    {\n      q = toolbox.executeDbQuery("timeexpensesheets", "voucher", params );      \n      if (!xtte.errorCheck(q))\n      {\n        toolbox.executeRollback();\n        return false;\n      }\n    }\n\n    if (post)\n    {\n      if (metrics.value("PrjLaborAndOverhead") - 0 <= 0)\n      {\n        QMessageBox.critical(mywindow, qsTr("Setup Error"),\n                         qsTr("No Labor and Overhead Account defined in CRM Setup."));\n        {\n          toolbox.executeRollback();\n          return false;\n        }\n      }\n\n      params.phrase1 = qsTr("Post Time Sheet for ");\n      params.phrase2 = qsTr(" to Project");\n\n      q = toolbox.executeDbQuery("timeexpensesheets", "post", params );   \n      if (!xtte.errorCheck(q))\n      {\n        toolbox.executeRollback();   \n        return false;\n      }\n    }\n  }\n   \n  toolbox.executeCommit();\n\n  if (invoice)\n    mainwindow.invoicesUpdated(1, true);\n\n  if (voucher)\n    mainwindow.vouchersUpdated();\n\n  if (post)\n    mainwindow.glSeriesUpdated();\n\n  xtte.timeExpenseSheets.fillList(); \n  \n  return true;\n}\n\nxtte.timeExpenseSheets.deleteSheet = function()\n{\n  var msg = qsTr("This action can not be undone.  Are you sure you want to delete this sheet?");\n  if (QMessageBox.question( mywindow, mywindow.windowTitle, msg, \n      QMessageBox.Yes | QMessageBox.Escape, QMessageBox.No | QMessageBox.Default) == QMessageBox.Yes)\n  {\n    var params   = new Object();\n    params.tehead_id = _sheets.id();    \n\n    toolbox.executeDbQuery("timeexpensesheet", "deltehead", params );\n\n    xtte.timeExpenseSheets.fillList();\n  }\n}\n\nxtte.timeExpenseSheets.closeSheet = function()\n{\n  var msg = qsTr("This action can not be undone. Are you sure you want to close this sheet?");\n  if (QMessageBox.question( mywindow, mywindow.windowTitle, msg, \n      QMessageBox.Yes | QMessageBox.Escape, QMessageBox.No | QMessageBox.Default) == QMessageBox.Yes)\n  {\n    var params   = new Object();\n    params.tehead_id = _sheets.id();    \n\n    q = toolbox.executeDbQuery("timeexpensesheets", "close", params );  \n    if (xtte.errorCheck(q))\n      xtte.timeExpenseSheets.fillList(); \n  }\n}\n\nxtte.timeExpenseSheets.editSheet = function()\n{\n  if (_sheets.currentItem().rawValue("tehead_status") == 'O')\n    xtte.timeExpenseSheets.openSheet(xtte.editMode);\n  else\n    xtte.timeExpenseSheets.openSheet(xtte.viewMode);\n}\n\nxtte.timeExpenseSheets.newSheet = function()\n{\n  xtte.timeExpenseSheets.openSheet(xtte.newMode);\n}\n\nxtte.timeExpenseSheets.viewSheet = function()\n{\n  xtte.timeExpenseSheets.openSheet(xtte.viewMode);\n}\n\nxtte.timeExpenseSheets.openSheet = function(mode)\n{\n  var params   = new Object();\n  params.mode   = mode;\n  if (mode) // Not new\n    params.tehead_id = _sheets.id();\n  else // New\n  {\n    if (_selected)\n      params.emp_id = _employee.id();\n  }\n\n  var te = toolbox.openWindow("timeExpenseSheet", mywindow, Qt.ApplicationModal);\n  toolbox.lastWindow().set(params);\n  te.exec();\n  xtte.timeExpenseSheets.fillList();\n}\n\nxtte.timeExpenseSheets.getParams = function()\n{\n  params = new Object();\n\n  if (!_open.checked &&\n      !_approved.checked &&\n      !_closed.checked)\n  {\n    params.statusList = "";\n    return params;\n  }\n\n  params.startDate = _weekending.startDate;\n  params.endDate   = _weekending.endDate;\n  if (!_showAllEmployees.checked)\n    params.emp_id  = _employee.id();\n\n  var statusList = [];\n  var num = 0;\n  \n  if (_open.checked)\n  {\n    statusList[num] = "'O'";\n    num = num + 1;\n  }\n  if (_approved.checked)\n  {\n    statusList[num] = "'A'";\n    num = num + 1;\n  }\n  if (_closed.checked)\n    statusList[num] = "'C'";\n  \n  params.statusList  = statusList.toString();\n  params.approved  = qsTr("Approved");\n  params.closed    = qsTr("Closed");\n  params.open      = qsTr("Open");\n  params.yes       = qsTr("Yes");\n  params.no        = qsTr("No");\n  params.na        = qsTr("N/A");\n\n  return params;\n}\n\n\nxtte.timeExpenseSheets.fillList = function()\n{ \n  var params = xtte.timeExpenseSheets.getParams();\n  if (!params.statusList.length)\n    return;\n\n  q = toolbox.executeDbQuery("timeexpensesheets","detail", params);\n\n  _sheets.populate(q);\n  if (!xtte.errorCheck(q))\n    return;\n}\n\nxtte.timeExpenseSheets.printSheet = function()\n{\n  params = xtte.timeExpenseSheets.getParams();\n  params.tehead_id = _sheets.id();\n  toolbox.printReport("TimeExpenseSheet",params);\n}\n\nxtte.timeExpenseSheets.printReport = function()\n{\n  var params = xtte.timeExpenseSheets.getParams();\n  params.includeFormatted = true;\n\n  toolbox.printReport("TimeExpenseSheets",params);\n}\n\nxtte.timeExpenseSheets.populateEmployees = function()\n{\n  // getEffectiveXtUser and crmacct_emp_id were created in the same release\n  var q = toolbox.executeQuery("SELECT crmacct_emp_id AS emp_id"\n                             + "  FROM crmacct "\n                             + " WHERE crmacct_usr_username = getEffectiveXtUser();");\n  // if they don't exist, try the older relationship maintained in the emp table\n  if (q.lastError().type != QSqlError.NoError)\n      q = toolbox.executeQuery("SELECT emp_id "\n                             + "  FROM emp "\n                             + " WHERE emp_username = CURRENT_USER;");\n\n  if (q.first()) \n    _employee.setId(q.value("emp_id"));\n\n  if (privileges.check("MaintainTimeExpenseOthers"))\n    _showAllEmployees.visible = true;\n  else\n  {\n    _showAllEmployees.visible = false;\n    _employee.enabled = false;\n    if (privileges.check("MaintainTimeExpenseSelf"))\n    {\n      if (_employee.id() == -1)\n        QMessageBox.critical(mywindow, mywindow.windowTitle, \n                    qsTr("It appears that your current user isn't an active employee.") );                                            \n    }\n    else\n    {\n      QMessageBox.critical(mywindow, qsTr("Permissions Error"),\n                    qsTr("You do not have permissions to maintain time and expense entries"));\n      if (mywindow.windowModality)\n        mydialog.reject();\n      else\n        mywindow.close();\n    }\n  }\n}\n\n// Initialize\n_weekending.setStartNull(qsTr("Earliest"), startOfTime, true);\n_weekending.setEndNull(qsTr("Latest"),     endOfTime,   true);\n\n_approve.enabled = privileges.check("CanApprove");\n_selected.checked = true;\n_showAllEmployees.visible = false;\n\nif (!privileges.check("allowInvoicing"))\n{\n  _invoice.forgetful = true;\n  _invoice.checked = false;\n  _invoice.enabled = false;\n}\n\nif (!privileges.check("allowVouchering"))\n{\n  _voucher.forgetful = true;\n  _voucher.checked = false;\n  _voucher.enabled = false;\n}\n\nif (!privileges.check("PostTimeSheets"))\n{\n  _post.forgetful = true;\n  _post.checked = false;\n  _post.enabled = false;\n}\n\n// Make connections\n_new.triggered.connect(xtte.timeExpenseSheets.newSheet);\n_close.triggered.connect(mywindow, "close");\n_approve.triggered.connect(xtte.timeExpenseSheets.approve);\n_process.triggered.connect(xtte.timeExpenseSheets.process);\n_print.triggered.connect(xtte.timeExpenseSheets.printReport);\n_query.triggered.connect(xtte.timeExpenseSheets.fillList);\n\n_showAllEmployees["toggled(bool)"].connect(_employee["setDisabled(bool)"]);\n_employee["newId(int)"].connect(xtte.timeExpenseSheets.fillList);\n\nmainwindow.invoicesUpdated.connect(xtte.timeExpenseSheets.fillList);\nmainwindow.vouchersUpdated.connect(xtte.timeExpenseSheets.fillList);\n\n_sheets["populateMenu(QMenu *, XTreeWidgetItem *, int)"].connect(xtte.timeExpenseSheets.populateMenu);\nif (privileges.check("MaintainTimeExpense"))\n  _sheets.itemSelected.connect(xtte.timeExpenseSheets.editSheet);\nelse\n{\n  _new.enabled = false;\n  _sheets.itemSelected.connect(xtte.timeExpenseSheets.viewSheet);\n}\n\nxtte.timeExpenseSheets.populateEmployees();\n        Time and Expense package
105771
 
108     customer        0       t       /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.customer = new Object;\n\n\nif (privileges.check("CanViewRates"))\n{\n  var _custid = -1;\n  var _creditGroup = mywindow.findChild("_creditGroup");\n  var _layout = toolbox.widgetGetLayout(_creditGroup);\n  var _tecustomer = toolbox.loadUi("tecustomer", mywindow);\n  var groupBox_3 = mywindow.findChild("groupBox_3");\n  var groupBox_4 = mywindow.findChild("groupBox_4");\n  var _creditStatusGroup = mywindow.findChild("_creditStatusGroup");\n\n  _layout.addWidget(_tecustomer, 0, 0, 1, 3);\n  _layout.addWidget(groupBox_4, 1, 0, 1, 1);\n  _layout.addWidget(_creditStatusGroup, 1, 1, 1, 1);\n  _layout.addWidget(groupBox_3, 1, 2, 1, 1);\n  _layout.addWidget(_creditGroup, 2, 0, 1, 3);\n\n  var _number = mywindow.findChild("_number");\n  var _blanketPos = mywindow.findChild("_blanketPos");\n  var _billingGroup = mywindow.findChild("_billingGroup");\n  var _rate = _tecustomer.findChild("_rate");\n  var _tecustrateid = -1;\n  var _basecurrid = _rate.id();\n\n  xtte.customer.modeChanged = function(mode)\n  {\n    _billingGroup.enabled = (mode == mainwindow.cNew || mode == mainwindow.cEdit);\n  }\n\n  xtte.customer.save = function()\n  {\n\n    var params = new Object();\n    params.tecustrate_id = _tecustrateid;\n    params.cust_id       = _custid;\n    params.curr_id       = _rate.id();\n    params.rate          = _rate.localValue;\n\n    var query = "updtecustrate";\n    if (!_billingGroup.checked)\n      query = "deltecustrate";\n    else if (_tecustrateid == -1)\n      query = "instecustrate";\n\n    var q = toolbox.executeDbQuery("customer", query, params);\n    if (q.first())\n      _tecustrateid = q.value("tecustrate_id");\n    else\n      xtte.errorCheck(q);\n  }\n\n  xtte.customer.populate = function(custId)\n  {\n    if (_custid == custId)\n      return;\n\n    _custid = custId;\n\n    var params = new Object();\n    params.cust_id = _custid;\n\n    var q = toolbox.executeDbQuery("customer", "seltecustrate", params);\n\n    if (q.first())\n    {\n      _billingGroup.checked = true;\n      _tecustrateid = q.value("tecustrate_id");\n      _rate.setId(q.value("tecustrate_curr_id"));\n      _rate.localValue = q.value("tecustrate_rate");\n      return;\n    }\n    else\n      xtte.errorCheck(q);\n\n    _billingGroup.checked = false;\n    _tecustrateid = -1;\n    _rate.setId(_basecurrid);\n    _rate.localValue = 0;\n  }\n\n  // Initialize\n  QWidget.setTabOrder(_blanketPos, _rate);\n\n  mywindow["newId(int)"].connect(xtte.customer.populate);\n  mywindow["newMode(int)"].connect(xtte.customer.modeChanged);\n  mywindow["saved(int)"].connect(xtte.customer.save);\n\n  xtte.customer.populate();\n}\n  Time and Expense package
105772
 
110     employee        0       t       /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.employee = new Object;\n\nvar _externalRate = mywindow.findChild("_externalRate"); \nvar _layout = toolbox.widgetGetLayout(_externalRate);\nvar _contractor = toolbox.createWidget("QCheckBox", mywindow, "_contractor");\n_contractor.text = qsTr("Contractor");\n\n_layout.addWidget(_contractor, 1, 4);\n\nvar _teempid = -1; \nvar _empid = -1;\n\nset = function(input)\n{\n  if("emp_id" in input)\n  {\n    _empid = input.emp_id;\n    xtte.employee.populate();\n  }\n\n  if("mode" in input)\n  {\n    if (input.mode == "view")\n      _contractor.enabled = false;\n  }\n\n  return mainwindow.NoError;\n}\n\nxtte.employee.save = function(empId)\n{\n  if (empId <= 0)\n    return;\n\n  var params = new Object();\n  params.teemp_id\t= _teempid;\n  params.emp_id\t= empId;\n  params.contractor\t= _contractor.checked;\n\n  var query = "updteemp";\n  if (_teempid == -1)\n    query = "insteemp";\n\n  var q = toolbox.executeDbQuery("employee", query, params);\n  xtte.errorCheck(q);\n}\n\nxtte.employee.populate = function()\n{\n  var params = new Object();\n  params.emp_id = _empid;    \n\n  var q = toolbox.executeDbQuery("employee", "selteemp", params);\n\n  if (q.first())\n  {\n    _teempid = q.value("teemp_id");\n    _contractor.checked = (q.value("teemp_contractor"));\n  }\n  else\n    xtte.errorCheck(q);\n}\n\nmydialog["finished(int)"].connect(xtte.employee.save);\n\n\n     Time and Expense package
105773
 
114     jsGanttCSS      0       t       ..gantt { font-family:tahoma, arial, verdana; font-size:10px;}\n\n..gdatehead { BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; HEIGHT: 18px }\n\n..ghead { BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 24px; HEIGHT: 20px }\n\n..gname { BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; WIDTH: 18px; HEIGHT: 18px }\n\n..ghead A { FONT-SIZE: 10px; COLOR: #000000; TEXT-DECORATION: none }\n\n..gheadwkend A { FONT-SIZE: 10px; COLOR: #000000; TEXT-DECORATION: none }\n\n..gheadwkend { BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 24px; HEIGHT: 20px; background-color: #cfcfcf }\n\n..gfiller { BORDER-TOP: #efefef 1px solid; BORDER-LEFT: #efefef 1px solid; WIDTH: 18px; HEIGHT: 18px }\n\n..gfillerwkend { BORDER-LEFT: #efefef 1px solid; WIDTH: 18px; HEIGHT: 18px; BACKGROUND-COLOR: #cfcfcf }\n\n..gitem { BORDER-TOP: #cccccc 1px solid; WIDTH: 18px; HEIGHT: 18px }\n\n..gitemwkend { BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; WIDTH: 18px; HEIGHT: 18px }\n\n..gmilestone {\tBORDER-TOP: #efefef 1px solid; FONT-SIZE: 14px; OVERFLOW: hidden; BORDER-LEFT: #efefef 1px solid; WIDTH: 18px; HEIGHT: 18px}\n\n..gmilestonewkend {\tBORDER-TOP: #efefef 1px solid; BORDER-LEFT: #cccccc 1px solid; WIDTH: 18px; HEIGHT: 18px}\n\n..btn { BORDER-RIGHT: #ffffff; BORDER-TOP: #ffffff; FONT-WEIGHT: bold; FONT-SIZE: 10px; BORDER-LEFT: #ffffff; WIDTH: 12px; COLOR: #cccccc; BORDER-BOTTOM: #ffffff; BACKGROUND-COLOR: #ffffff }\n\n..hrcomplete { BORDER-RIGHT: #000000 2px solid; PADDING-RIGHT: 0px; BORDER-TOP: #000000 2px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; BORDER-LEFT: #000000 2px solid; WIDTH: 20px; COLOR: #000000; PADDING-TOP: 0px; BORDER-BOTTOM: #000000 2px solid; HEIGHT: 4px }\n\n..hrhalfcomplete { BORDER-RIGHT: #000000 2px solid; BORDER-TOP: #000000 2px solid; BORDER-LEFT: #000000 2px solid; WIDTH: 9px; COLOR: #000000; BORDER-BOTTOM: #000000 2px solid; HEIGHT: 4px }\n\n..gweekend { font-family:tahoma, arial, verdana; font-size:11px; background-color:#EEEEEE; text-align:center; }\n\n..gtask { font-family:tahoma, arial, verdana; font-size:11px; background-color:#00FF00; text-align:center; }\n\n..gday { font-family:tahoma, arial, verdana; font-size:11px; text-align:center; }\n\n..gcomplete { background-color:black; height:5px; overflow: auto; margin-top:4px; }\n\nDIV.scroll { BORDER-RIGHT: #efefef 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: #efefef 1px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; OVERFLOW: hidden; BORDER-LEFT: #efefef 1px solid; WIDTH: 420px; PADDING-TOP: 0px; BORDER-BOTTOM: #efefef 1px solid; BACKGROUND-COLOR: #ffffff }\n\nDIV.scroll2 { position:relative; PADDING-RIGHT: 0px; overflow:auto ;overflow-x:scroll;overflow-y:hidden; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; WIDTH: 482px; PADDING-TOP: 0px; BACKGROUND-COLOR: #ffffff }\n\n      Time and Expense package
105774
 
111     initMenu        0       t       /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.initMenu = new Object;\n\n// Define menu and action variables\nvar crmMenu = mainwindow.findChild("menu.crm.projects");\ncrmMenu.addSeparator();\n\nvar tesheetAction = crmMenu.addAction(qsTr("Time and Expense..."), mainwindow);\ntesheetAction.objectName = "pm.teSheets";\ntesheetAction.setData("MaintainTimeExpense");\ntesheetAction.enabled = privileges.value("MaintainTimeExpense");\n\nvar crmRptMenu = mainwindow.findChild("menu.crm.reports");\nvar orderActPrj = mainwindow.findChild("pm.dspOrderActivityByProject");\n\nvar historyAction = new QAction(qsTr("Time and Expense History"), mainwindow);\nhistoryAction.objectName = "pm.teHistory";\nhistoryAction.setData("ViewTimeExpenseHistory");\nhistoryAction.enabled = privileges.value("ViewTimeExpenseHistory");\ncrmRptMenu.insertAction(orderActPrj, historyAction);\n\n// Define function(s)\nxtte.initMenu.openSheets = function()\n{\n  toolbox.openWindow("timeExpenseSheets");\n}\n\nxtte.initMenu.openHistory = function()\n{\n  toolbox.openWindow("dspTimeExpenseHistory");\n}\n\n// Connect Actions\ntesheetAction.triggered.connect(xtte.initMenu.openSheets);\nhistoryAction.triggered.connect(xtte.initMenu.openHistory);\n      Time and Expense package
105775
 
112     item    0       t       /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.item = new Object;\n\nvar _tab = mywindow.findChild("_tab"); \nvar _expensePage = toolbox.loadUi("teexpense", mywindow);\n_tab.insertTab(2, _expensePage, "Project");\n\nvar _projectExpense = mywindow.findChild("_projectExpense");\nvar _itemtype = mywindow.findChild("_itemtype");\nvar _close = mywindow.findChild("_close");\nvar _description = mywindow.findChild("_description");\nvar _account = mywindow.findChild("_account");\nvar _expcat = mywindow.findChild("_expcat");\nvar _accountSelected = mywindow.findChild("_accountSelected");\nvar _expcatSelected = mywindow.findChild("_expcatSelected");\nvar _allowExpenseGroup = mywindow.findChild("_allowExpenseGroup");\nvar _inventoryUOM = mywindow.findChild("_inventoryUOM");\nvar _save = mywindow.findChild("_save");\n\nvar _saved = false;\nvar _isnew = true;\n\nxtte.item.clickswitch = function()\n{\n  if(_accountSelected.checked)\n  {\n    _account.enabled = true;\n    _expcat.enabled = false;\n    _expcat.setId(-1);\n  }\n  else\n  {\n    _account.enabled = false;\n    _expcat.enabled = true;\n    _account.setId(-1);\n  }\n}\n\nxtte.item.save = function(id)\n{\n  var params = new Object;\n  params.item_id = id;\n  params.expcat_id = _expcat.id();\n  params.accnt_id = _account.id();\n\n  var query = "updteexp";\n  if (!_projectExpense.checked)\n    query = "delteexp";\n  else if (_isnew)\n    query = "insteexp";\n\n  var q = toolbox.executeDbQuery("item", query, params);\n  xtte.errorCheck(q);\n}\n\nxtte.item.populate = function(itemId)\n{\n  var params = new Object;\n  params.item_id = itemId;\n\n  var q = toolbox.executeDbQuery("item", "selteexp", params);\n\n  if (q.first())\n  {\n    _projectExpense.checked = true;\n    _expcat.setId(q.value("teexp_expcat_id"));\n    _account.setId(q.value("teexp_accnt_id"));\n\n    if(_account.id() > 0)\n      _accountSelected.checked = true;\n    else\n      _expcatSelected.checked = true;\n\n    _isnew = false;\n  }\n  else if (!xtte.errorCheck(q))\n    return\n  else\n  {\n    _projectExpense.checked = false;\n    _isnew = true;\n  }\n\n  xtte.item.handleExpense();\n}\n\nxtte.item.handleExpense = function()\n{\n  _tab.setTabEnabled(_tab.indexOf(_expensePage), _itemtype.currentIndex == 3);\n}\n\nxtte.item.checkSave = function()\n{\n  if (_projectExpense.checked == true &&\n      !_expcat.isValid() && \n      !_account.isValid())\n  {\n    QMessageBox.critical(mywindow,\n                       qsTr("Can not save item"),\n                       qsTr("You must select a G/L Account or an expense account for Project Expense Items."));\n  }\n  else\n    mywindow.sSave();\n}\n\n// Initialize\n_expcat.enabled = false;\n_account.setType(0x01 | 0x02 | 0x04); // Asset, Liability, Expense\n\n// Connections\ntoolbox.coreDisconnect(_save, "clicked()", mywindow, "sSave()"); \n_save.clicked.connect(xtte.item.checkSave);\nmywindow["saved(int)"].connect(xtte.item.save);\nmywindow["newId(int)"].connect(xtte.item.populate);\n_accountSelected.toggled.connect(xtte.item.clickswitch);\n_expcatSelected.toggled.connect(xtte.item.clickswitch);\n_itemtype['currentIndexChanged(QString)'].connect(xtte.item.handleExpense);\n_inventoryUOM.newID.connect(xtte.item.handleExpense);\n\n     Time and Expense package
105776
 
117     task    0       t       /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.task = new Object;\n\nvar _tab = mywindow.findChild("_tab"); \nvar _tebilling = toolbox.loadUi("tebilling", mywindow);\n_tab.insertTab(2, _tebilling, qsTr("Billing"));\n_tab.setEnabled(2, privileges.check("CanViewRates"));\n\nvar _number = mywindow.findChild("_number");\nvar _actualHours = mywindow.findChild("_actualHours");\nvar _actualExp = mywindow.findChild("_actualExp");\nvar _billingGroup = _tebilling.findChild("_billingGroup");\nvar _itemGroup = _tebilling.findChild("_itemGroup");\nvar _cust = _tebilling.findChild("_cust");\nvar _rate = _tebilling.findChild("_rate");\nvar _item = _tebilling.findChild("_item");\nvar _useItem = _tebilling.findChild("_useItem");\nvar _teprjtaskid = -1; \nvar _prjtaskid = -1;\n\nset = function(input)\n{\n  if("prjtask_id" in input)\n  {\n    _prjtaskid = input.prjtask_id;\n    xtte.task.populate();\n  }\n\n  if("cust_id" in input)\n  {\n    _cust.setId(input.cust_id);\n    _cust.enabled = false;\n  }\n\n  if("mode" in input)\n  {\n    if (input.mode == "view")\n    {\n      _cust.enabled = false;\n      _billingGroup.enabled = false;\n      _itemGroup.enabled = false;\n    }\n  }\n\n  return mainwindow.NoError;\n}\n\nxtte.task.save = function(prjtaskId)\n{\n  if (prjtaskId <= 0)\n    return;\n\n  var params = new Object();\n  params.teprjtask_id\t= _teprjtaskid;\n  params.prjtask_id\t= prjtaskId;\n  if (_cust.isValid())\n    params.cust_id  \t= _cust.id();\n  if (_billingGroup.checked)\n  {\n    params.rate\t= _rate.localValue;\n    params.curr_id\t= _rate.id();\n  }\n  if (_useItem.checked && _item.isValid())\n    params.item_id\t= _item.id()\n\n  var query = "updteprjtask";\n  if (_teprjtaskid == -1)\n    query = "insteprjtask";\n\n  var q = toolbox.executeDbQuery("task", query, params);\n  xtte.errorCheck(q);\n}\n\nxtte.task.populate = function()\n{\n  var params = new Object();\n  params.prjtask_id = _prjtaskid;    \n\n  var q = toolbox.executeDbQuery("task", "selteprjtask", params);\n\n  if (q.first())\n  {\n    _teprjtaskid = q.value("teprjtask_id");\n\n    if (!_cust.isValid())\n      _cust.setId(q.value("cust_id"));\n\n    if (q.value("curr_id") == -1)\n      _billingGroup.checked = false;\n    else\n    {\n      _billingGroup.checked = true;\n      _rate.setId(q.value("curr_id"));\n      _rate.localValue = q.value("teprjtask_rate");\n    }\n\n    if (q.value("item_id") == -1)\n      _useItem.checked = false;\n    else\n    {\n      _useItem.checked = true;\n      _item.setId(q.value("item_id"));\n    }\n  }\n  else\n    xtte.errorCheck(q);\n}\n\n// Initialize\n_item.setQuery(xtte.itemSql);\n_useItem.checked = false;\n\n// Connections\nmydialog["finished(int)"].connect(xtte.task.save);\n\n Time and Expense package
105777
 
118     tebilling       0       t       /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _item\t\t= mywindow.findChild("_item");\n\n_item.populate("select item_id,item_number,item_descrip1,item_listprice from item where item_sold = true and item_active = true and item_type = 'R'");\n\n        Time and Expense package
105778
 
122     xtte    0       t       /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar xtte;\nif (!xtte)\n  xtte = new Object;\n\nxtte.itemSql = "SELECT item_id,item_number,item_descrip1,item_descrip2, "\n             + "       item_type,item_config,item_upccode, item_active,uom_name "\n             + "FROM item JOIN uom ON (uom_id=item_inv_uom_id) "\n             + "          JOIN te.teexp ON (teexp_id=item_id) "\n             + "WHERE item_type='R' "\n\nxtte.newMode \t= 0;\nxtte.editMode\t= 1;\nxtte.viewMode\t= 2;\n\nxtte.errorCheck = function (q)\n{\n  if (q.lastError().type != QSqlError.NoError)\n  {\n    QMessageBox.critical(mywindow,\n                        qsTr("Database Error"), q.lastError().text);\n    return false;\n  }\n\n  return true;\n}\n        Time and Expense package
105779
 
\.
105780
 
 
105781
 
 
105782
 
--
105783
 
--
105784
 
 
105785
 
COPY pkguiform (uiform_id, uiform_name, uiform_order, uiform_enabled, uiform_source, uiform_notes) FROM stdin;
105786
 
50      dspTimeExpenseHistory   0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>dspTimeExpenseHistory</class>\n <widget class="QWidget" name="dspTimeExpenseHistory">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>800</width>\n    <height>600</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Time and Expense History</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout_2">\n   <item row="0" column="0">\n    <widget class="ParameterWidget" name="_parameterWidget"/>\n   </item>\n   <item row="0" column="1">\n    <layout class="QVBoxLayout" name="verticalLayout">\n     <item>\n      <widget class="QPushButton" name="_close">\n       <property name="text">\n        <string>Close</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <widget class="QPushButton" name="_query">\n       <property name="text">\n        <string>Query</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <widget class="QPushButton" name="_print">\n       <property name="text">\n        <string>Print</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <spacer name="verticalSpacer">\n       <property name="orientation">\n        <enum>Qt::Vertical</enum>\n       </property>\n       <property name="sizeHint" stdset="0">\n        <size>\n         <width>20</width>\n         <height>0</height>\n        </size>\n       </property>\n      </spacer>\n     </item>\n    </layout>\n   </item>\n   <item row="1" column="0" colspan="2">\n    <widget class="QFrame" name="_frame">\n     <property name="sizePolicy">\n      <sizepolicy hsizetype="Preferred" vsizetype="Expanding">\n       <horstretch>0</horstretch>\n       <verstretch>1</verstretch>\n      </sizepolicy>\n     </property>\n     <property name="frameShape">\n      <enum>QFrame::NoFrame</enum>\n     </property>\n     <property name="frameShadow">\n      <enum>QFrame::Raised</enum>\n     </property>\n     <layout class="QGridLayout" name="gridLayout">\n      <property name="margin">\n       <number>0</number>\n      </property>\n      <item row="0" column="0">\n       <widget class="QLabel" name="_listLit">\n        <property name="text">\n         <string>Time Sheet Items</string>\n        </property>\n       </widget>\n      </item>\n      <item row="1" column="0">\n       <widget class="XTreeWidget" name="_list">\n        <property name="populateLinear">\n         <bool>false</bool>\n        </property>\n       </widget>\n      </item>\n     </layout>\n    </widget>\n   </item>\n  </layout>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>ParameterWidget</class>\n   <extends>QWidget</extends>\n   <header>parameterwidget.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>xtreewidget.h</header>\n   <container>1</container>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections/>\n</ui>\n    Time and Expense package
105787
 
52      tebilling       0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>tebilling</class>\n <widget class="QDialog" name="tebilling">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>396</width>\n    <height>334</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Billing</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout">\n   <item row="0" column="0">\n    <layout class="QVBoxLayout" name="verticalLayout_3">\n     <item>\n      <layout class="QVBoxLayout" name="verticalLayout_2">\n       <item>\n        <widget class="QGroupBox" name="_custGroup">\n         <property name="title">\n          <string/>\n         </property>\n         <layout class="QGridLayout" name="gridLayout_2">\n          <item row="0" column="0">\n           <widget class="CustCluster" name="_cust">\n            <property name="descriptionVisible">\n             <bool>false</bool>\n            </property>\n            <property name="orientation">\n             <enum>Qt::Horizontal</enum>\n            </property>\n           </widget>\n          </item>\n         </layout>\n        </widget>\n       </item>\n       <item>\n        <widget class="QGroupBox" name="_billingGroup">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Preferred" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>1</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="title">\n          <string>Use specified billing rate</string>\n         </property>\n         <property name="checkable">\n          <bool>true</bool>\n         </property>\n         <property name="checked">\n          <bool>false</bool>\n         </property>\n         <layout class="QHBoxLayout" name="horizontalLayout">\n          <item>\n           <widget class="QLabel" name="_rateLit">\n            <property name="text">\n             <string>Rate:</string>\n            </property>\n            <property name="alignment">\n             <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n            </property>\n           </widget>\n          </item>\n          <item>\n           <widget class="CurrCluster" name="_rate"/>\n          </item>\n          <item>\n           <spacer name="horizontalSpacer_2">\n            <property name="orientation">\n             <enum>Qt::Horizontal</enum>\n            </property>\n            <property name="sizeHint" stdset="0">\n             <size>\n              <width>112</width>\n              <height>20</height>\n             </size>\n            </property>\n           </spacer>\n          </item>\n         </layout>\n        </widget>\n       </item>\n       <item>\n        <layout class="QVBoxLayout" name="verticalLayout">\n         <property name="spacing">\n          <number>0</number>\n         </property>\n         <item>\n          <layout class="QHBoxLayout" name="horizontalLayout_2">\n           <item>\n            <spacer name="horizontalSpacer">\n             <property name="orientation">\n              <enum>Qt::Horizontal</enum>\n             </property>\n             <property name="sizeType">\n              <enum>QSizePolicy::Fixed</enum>\n             </property>\n             <property name="sizeHint" stdset="0">\n              <size>\n               <width>12</width>\n               <height>10</height>\n              </size>\n             </property>\n            </spacer>\n           </item>\n           <item>\n            <widget class="QCheckBox" name="_useItem">\n             <property name="focusPolicy">\n              <enum>Qt::StrongFocus</enum>\n             </property>\n             <property name="text">\n              <string>Use Specified item</string>\n             </property>\n             <property name="checked">\n              <bool>true</bool>\n             </property>\n            </widget>\n           </item>\n          </layout>\n         </item>\n         <item>\n          <widget class="QGroupBox" name="_itemGroup">\n           <property name="minimumSize">\n            <size>\n             <width>0</width>\n             <height>130</height>\n            </size>\n           </property>\n           <property name="title">\n            <string/>\n           </property>\n           <property name="checkable">\n            <bool>false</bool>\n           </property>\n           <property name="checked">\n            <bool>false</bool>\n           </property>\n           <layout class="QGridLayout" name="gridLayout_3">\n            <item row="0" column="0">\n             <widget class="ItemCluster" name="_item">\n              <property name="nameVisible">\n               <bool>true</bool>\n              </property>\n              <property name="descriptionVisible">\n               <bool>true</bool>\n              </property>\n             </widget>\n            </item>\n           </layout>\n          </widget>\n         </item>\n        </layout>\n       </item>\n      </layout>\n     </item>\n     <item>\n      <spacer name="verticalSpacer">\n       <property name="orientation">\n        <enum>Qt::Vertical</enum>\n       </property>\n       <property name="sizeHint" stdset="0">\n        <size>\n         <width>20</width>\n         <height>0</height>\n        </size>\n       </property>\n      </spacer>\n     </item>\n    </layout>\n   </item>\n  </layout>\n </widget>\n <layoutdefault spacing="6" margin="11"/>\n <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>\n <customwidgets>\n  <customwidget>\n   <class>CurrCluster</class>\n   <extends>CurrDisplay</extends>\n   <header>currcluster.h</header>\n  </customwidget>\n  <customwidget>\n   <class>CurrDisplay</class>\n   <extends>QWidget</extends>\n   <header>currcluster.h</header>\n  </customwidget>\n  <customwidget>\n   <class>CustCluster</class>\n   <extends>QWidget</extends>\n   <header>custcluster.h</header>\n  </customwidget>\n  <customwidget>\n   <class>ItemCluster</class>\n   <extends>QWidget</extends>\n   <header>itemcluster.h</header>\n   <container>1</container>\n  </customwidget>\n </customwidgets>\n <tabstops>\n  <tabstop>_rate</tabstop>\n </tabstops>\n <resources/>\n <connections>\n  <connection>\n   <sender>_billingGroup</sender>\n   <signal>toggled(bool)</signal>\n   <receiver>_rate</receiver>\n   <slot>setCurrencyEnabled(bool)</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>210</x>\n     <y>133</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>167</x>\n     <y>142</y>\n    </hint>\n   </hints>\n  </connection>\n  <connection>\n   <sender>_useItem</sender>\n   <signal>toggled(bool)</signal>\n   <receiver>_item</receiver>\n   <slot>setEnabled(bool)</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>200</x>\n     <y>189</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>196</x>\n     <y>250</y>\n    </hint>\n   </hints>\n  </connection>\n </connections>\n</ui>\n        Time and Expense package
105788
 
54      teexpense       0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>teexpense</class>\n <widget class="QDialog" name="teexpense">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>373</width>\n    <height>161</height>\n   </rect>\n  </property>\n  <property name="sizePolicy">\n   <sizepolicy hsizetype="Expanding" vsizetype="Expanding">\n    <horstretch>0</horstretch>\n    <verstretch>0</verstretch>\n   </sizepolicy>\n  </property>\n  <property name="minimumSize">\n   <size>\n    <width>0</width>\n    <height>0</height>\n   </size>\n  </property>\n  <property name="windowTitle">\n   <string>Expense Item Setup</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout">\n   <item row="0" column="0">\n    <layout class="QVBoxLayout" name="verticalLayout_2">\n     <property name="spacing">\n      <number>4</number>\n     </property>\n     <item>\n      <layout class="QHBoxLayout" name="horizontalLayout_2">\n       <item>\n        <spacer name="horizontalSpacer_2">\n         <property name="orientation">\n          <enum>Qt::Horizontal</enum>\n         </property>\n         <property name="sizeType">\n          <enum>QSizePolicy::Fixed</enum>\n         </property>\n         <property name="sizeHint" stdset="0">\n          <size>\n           <width>10</width>\n           <height>20</height>\n          </size>\n         </property>\n        </spacer>\n       </item>\n       <item>\n        <widget class="QCheckBox" name="_projectExpense">\n         <property name="text">\n          <string>Allow use as Expense Item on Projects</string>\n         </property>\n         <property name="checked">\n          <bool>false</bool>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </item>\n     <item>\n      <widget class="QGroupBox" name="_allowExpenseGroup">\n       <property name="enabled">\n        <bool>false</bool>\n       </property>\n       <property name="title">\n        <string/>\n       </property>\n       <property name="checked">\n        <bool>false</bool>\n       </property>\n       <layout class="QGridLayout" name="gridLayout_5">\n        <item row="0" column="0">\n         <layout class="QVBoxLayout" name="verticalLayout">\n          <item>\n           <layout class="QGridLayout" name="gridLayout_3">\n            <item row="0" column="0">\n             <widget class="QRadioButton" name="_accountSelected">\n              <property name="text">\n               <string>Account</string>\n              </property>\n              <property name="checked">\n               <bool>true</bool>\n              </property>\n             </widget>\n            </item>\n            <item row="1" column="0">\n             <widget class="QRadioButton" name="_expcatSelected">\n              <property name="text">\n               <string>Expense Category</string>\n              </property>\n             </widget>\n            </item>\n            <item row="0" column="1">\n             <layout class="QHBoxLayout" name="horizontalLayout">\n              <item>\n               <widget class="GLCluster" name="_account">\n                <property name="sizePolicy">\n                 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">\n                  <horstretch>0</horstretch>\n                  <verstretch>0</verstretch>\n                 </sizepolicy>\n                </property>\n               </widget>\n              </item>\n             </layout>\n            </item>\n            <item row="1" column="1">\n             <widget class="ExpenseCluster" name="_expcat">\n              <property name="sizePolicy">\n               <sizepolicy hsizetype="Expanding" vsizetype="Preferred">\n                <horstretch>0</horstretch>\n                <verstretch>0</verstretch>\n               </sizepolicy>\n              </property>\n              <property name="focusPolicy">\n               <enum>Qt::StrongFocus</enum>\n              </property>\n              <property name="label">\n               <string/>\n              </property>\n              <property name="nameVisible">\n               <bool>false</bool>\n              </property>\n              <property name="orientation">\n               <enum>Qt::Horizontal</enum>\n              </property>\n              <property name="infoVisible" stdset="0">\n               <bool>false</bool>\n              </property>\n              <property name="readonly" stdset="0">\n               <bool>true</bool>\n              </property>\n             </widget>\n            </item>\n           </layout>\n          </item>\n          <item>\n           <spacer name="verticalSpacer">\n            <property name="orientation">\n             <enum>Qt::Vertical</enum>\n            </property>\n            <property name="sizeHint" stdset="0">\n             <size>\n              <width>20</width>\n              <height>0</height>\n             </size>\n            </property>\n           </spacer>\n          </item>\n         </layout>\n        </item>\n       </layout>\n      </widget>\n     </item>\n    </layout>\n   </item>\n  </layout>\n </widget>\n <layoutdefault spacing="5" margin="5"/>\n <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>\n <customwidgets>\n  <customwidget>\n   <class>ExpenseCluster</class>\n   <extends>QWidget</extends>\n   <header>expensecluster.h</header>\n  </customwidget>\n  <customwidget>\n   <class>GLCluster</class>\n   <extends>QWidget</extends>\n   <header>glcluster.h</header>\n  </customwidget>\n </customwidgets>\n <tabstops>\n  <tabstop>_accountSelected</tabstop>\n  <tabstop>_account</tabstop>\n  <tabstop>_expcatSelected</tabstop>\n </tabstops>\n <resources/>\n <connections>\n  <connection>\n   <sender>_accountSelected</sender>\n   <signal>toggled(bool)</signal>\n   <receiver>_account</receiver>\n   <slot>setEnabled(bool)</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>75</x>\n     <y>64</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>283</x>\n     <y>68</y>\n    </hint>\n   </hints>\n  </connection>\n  <connection>\n   <sender>_expcatSelected</sender>\n   <signal>toggled(bool)</signal>\n   <receiver>_expcat</receiver>\n   <slot>setEnabled(bool)</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>130</x>\n     <y>126</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>448</x>\n     <y>140</y>\n    </hint>\n   </hints>\n  </connection>\n  <connection>\n   <sender>_projectExpense</sender>\n   <signal>toggled(bool)</signal>\n   <receiver>_allowExpenseGroup</receiver>\n   <slot>setEnabled(bool)</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>196</x>\n     <y>25</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>186</x>\n     <y>96</y>\n    </hint>\n   </hints>\n  </connection>\n </connections>\n</ui>\n        Time and Expense package
105789
 
55      timeExpenseSheet        0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>timeExpenseSheet</class>\n <widget class="QDialog" name="timeExpenseSheet">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>800</width>\n    <height>600</height>\n   </rect>\n  </property>\n  <property name="minimumSize">\n   <size>\n    <width>775</width>\n    <height>400</height>\n   </size>\n  </property>\n  <property name="windowTitle">\n   <string>Time and Expense</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout_2">\n   <item row="0" column="0">\n    <layout class="QHBoxLayout">\n     <property name="spacing">\n      <number>12</number>\n     </property>\n     <item>\n      <widget class="QLabel" name="_sheetNumberExtraLit">\n       <property name="text">\n        <string>Sheet #:</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <widget class="QLabel" name="_sheetNumberExtra">\n       <property name="text">\n        <string>...</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <spacer>\n       <property name="orientation">\n        <enum>Qt::Horizontal</enum>\n       </property>\n       <property name="sizeType">\n        <enum>QSizePolicy::Expanding</enum>\n       </property>\n       <property name="sizeHint" stdset="0">\n        <size>\n         <width>0</width>\n         <height>20</height>\n        </size>\n       </property>\n      </spacer>\n     </item>\n     <item>\n      <widget class="QDialogButtonBox" name="_buttonBox">\n       <property name="standardButtons">\n        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </item>\n   <item row="1" column="0">\n    <widget class="QTabWidget" name="_TimeExpenseInformation">\n     <property name="enabled">\n      <bool>true</bool>\n     </property>\n     <property name="currentIndex">\n      <number>0</number>\n     </property>\n     <widget class="QWidget" name="_headerPage">\n      <attribute name="title">\n       <string>S&amp;heet</string>\n      </attribute>\n      <layout class="QGridLayout" name="gridLayout">\n       <item row="0" column="0" colspan="2">\n        <layout class="QHBoxLayout" name="horizontalLayout">\n         <item>\n          <widget class="QLabel" name="_weekendingLit">\n           <property name="text">\n            <string>Week of Date:</string>\n           </property>\n           <property name="alignment">\n            <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <widget class="DLineEdit" name="_weekending">\n           <property name="enabled">\n            <bool>true</bool>\n           </property>\n           <property name="sizePolicy">\n            <sizepolicy hsizetype="Expanding" vsizetype="Fixed">\n             <horstretch>0</horstretch>\n             <verstretch>0</verstretch>\n            </sizepolicy>\n           </property>\n           <property name="focusPolicy">\n            <enum>Qt::StrongFocus</enum>\n           </property>\n           <property name="defaultDate">\n            <enum>XDateEdit::None</enum>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <widget class="QLabel" name="_siteLit">\n           <property name="text">\n            <string>Site:</string>\n           </property>\n           <property name="alignment">\n            <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n           </property>\n           <property name="margin">\n            <number>3</number>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <widget class="WComboBox" name="_site">\n           <property name="sizePolicy">\n            <sizepolicy hsizetype="Expanding" vsizetype="Fixed">\n             <horstretch>0</horstretch>\n             <verstretch>0</verstretch>\n            </sizepolicy>\n           </property>\n           <property name="maximumSize">\n            <size>\n             <width>200</width>\n             <height>16777215</height>\n            </size>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <widget class="QLabel" name="_originatedByLit">\n           <property name="text">\n            <string>Employee:</string>\n           </property>\n           <property name="alignment">\n            <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n           </property>\n           <property name="margin">\n            <number>3</number>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <widget class="EmpCluster" name="_employee"/>\n         </item>\n         <item>\n          <spacer name="horizontalSpacer_2">\n           <property name="orientation">\n            <enum>Qt::Horizontal</enum>\n           </property>\n           <property name="sizeHint" stdset="0">\n            <size>\n             <width>0</width>\n             <height>20</height>\n            </size>\n           </property>\n          </spacer>\n         </item>\n        </layout>\n       </item>\n       <item row="1" column="0">\n        <widget class="XTreeWidget" name="_lines">\n         <property name="focusPolicy">\n          <enum>Qt::StrongFocus</enum>\n         </property>\n         <property name="alternatingRowColors">\n          <bool>false</bool>\n         </property>\n         <property name="rootIsDecorated">\n          <bool>true</bool>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="1">\n        <layout class="QVBoxLayout" name="verticalLayout">\n         <item>\n          <widget class="QPushButton" name="_new">\n           <property name="enabled">\n            <bool>false</bool>\n           </property>\n           <property name="text">\n            <string>&amp;New</string>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <widget class="QPushButton" name="_edit">\n           <property name="enabled">\n            <bool>false</bool>\n           </property>\n           <property name="text">\n            <string>&amp;Edit</string>\n           </property>\n           <property name="autoDefault">\n            <bool>true</bool>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <widget class="QPushButton" name="_view">\n           <property name="enabled">\n            <bool>false</bool>\n           </property>\n           <property name="text">\n            <string>&amp;View</string>\n           </property>\n           <property name="autoDefault">\n            <bool>true</bool>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <widget class="QPushButton" name="_delete">\n           <property name="enabled">\n            <bool>false</bool>\n           </property>\n           <property name="text">\n            <string>&amp;Delete</string>\n           </property>\n           <property name="autoDefault">\n            <bool>true</bool>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <spacer>\n           <property name="orientation">\n            <enum>Qt::Vertical</enum>\n           </property>\n           <property name="sizeType">\n            <enum>QSizePolicy::Expanding</enum>\n           </property>\n           <property name="sizeHint" stdset="0">\n            <size>\n             <width>20</width>\n             <height>20</height>\n            </size>\n           </property>\n          </spacer>\n         </item>\n        </layout>\n       </item>\n      </layout>\n     </widget>\n     <widget class="QWidget" name="_sheetNotesPage">\n      <attribute name="title">\n       <string>Notes</string>\n      </attribute>\n      <layout class="QGridLayout">\n       <item row="0" column="0">\n        <widget class="QTextEdit" name="_orderComments">\n         <property name="focusPolicy">\n          <enum>Qt::ClickFocus</enum>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n     <widget class="QWidget" name="_sheetDocumentsPage">\n      <attribute name="title">\n       <string>Documents</string>\n      </attribute>\n      <layout class="QVBoxLayout" name="verticalLayout_2">\n       <item>\n        <widget class="Documents" name="_documents">\n         <property name="type">\n          <enum>Documents::TimeExpense</enum>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </widget>\n   </item>\n   <item row="2" column="0">\n    <widget class="XCheckBox" name="_printSheet">\n     <property name="text">\n      <string>Print on Save</string>\n     </property>\n    </widget>\n   </item>\n  </layout>\n </widget>\n <layoutdefault spacing="5" margin="5"/>\n <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>\n <customwidgets>\n  <customwidget>\n   <class>DLineEdit</class>\n   <extends>QWidget</extends>\n   <header>datecluster.h</header>\n   <container>1</container>\n  </customwidget>\n  <customwidget>\n   <class>Documents</class>\n   <extends>QWidget</extends>\n   <header>documents.h</header>\n  </customwidget>\n  <customwidget>\n   <class>EmpCluster</class>\n   <extends>QWidget</extends>\n   <header>empcluster.h</header>\n  </customwidget>\n  <customwidget>\n   <class>WComboBox</class>\n   <extends>XComboBox</extends>\n   <header>wcombobox.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XCheckBox</class>\n   <extends>QCheckBox</extends>\n   <header>xcheckbox.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XComboBox</class>\n   <extends>QComboBox</extends>\n   <header>xcombobox.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>xtreewidget.h</header>\n   <container>1</container>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections/>\n</ui>\n  Time and Expense package
105790
 
56      timeExpenseSheetItem    0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>timeExpenseSheetItem</class>\n <widget class="QDialog" name="timeExpenseSheetItem">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>825</width>\n    <height>626</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Time and Expense</string>\n  </property>\n  <property name="sizeGripEnabled">\n   <bool>false</bool>\n  </property>\n  <property name="screenTitle" stdset="0">\n   <string>Time and Expense</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout_8">\n   <item row="0" column="0">\n    <layout class="QHBoxLayout" name="horizontalLayout">\n     <item>\n      <widget class="QLabel" name="_sheetLit">\n       <property name="text">\n        <string>Sheet:</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <widget class="XLabel" name="_sheet">\n       <property name="minimumSize">\n        <size>\n         <width>80</width>\n         <height>0</height>\n        </size>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <widget class="QLabel" name="_linenumberLit">\n       <property name="text">\n        <string>Line #:</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <widget class="QLabel" name="_linenumber">\n       <property name="minimumSize">\n        <size>\n         <width>80</width>\n         <height>0</height>\n        </size>\n       </property>\n       <property name="text">\n        <string/>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <spacer name="horizontalSpacer">\n       <property name="orientation">\n        <enum>Qt::Horizontal</enum>\n       </property>\n       <property name="sizeHint" stdset="0">\n        <size>\n         <width>19</width>\n         <height>20</height>\n        </size>\n       </property>\n      </spacer>\n     </item>\n    </layout>\n   </item>\n   <item row="0" column="1" rowspan="2">\n    <widget class="QDialogButtonBox" name="_buttonBox">\n     <property name="orientation">\n      <enum>Qt::Vertical</enum>\n     </property>\n     <property name="standardButtons">\n      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>\n     </property>\n    </widget>\n   </item>\n   <item row="1" column="0">\n    <widget class="QGroupBox" name="_dateGroup">\n     <property name="sizePolicy">\n      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">\n       <horstretch>0</horstretch>\n       <verstretch>0</verstretch>\n      </sizepolicy>\n     </property>\n     <property name="title">\n      <string/>\n     </property>\n     <layout class="QGridLayout" name="gridLayout_7">\n      <item row="0" column="0">\n       <layout class="QHBoxLayout" name="horizontalLayout_8">\n        <item>\n         <layout class="QGridLayout" name="gridLayout_3">\n          <item row="0" column="0">\n           <widget class="QLabel" name="_weLit">\n            <property name="text">\n             <string>Week of:</string>\n            </property>\n            <property name="alignment">\n             <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n            </property>\n           </widget>\n          </item>\n          <item row="0" column="1">\n           <widget class="DLineEdit" name="_weekending">\n            <property name="focusPolicy">\n             <enum>Qt::NoFocus</enum>\n            </property>\n            <property name="defaultDate">\n             <enum>XDateEdit::Empty</enum>\n            </property>\n           </widget>\n          </item>\n          <item row="0" column="2">\n           <widget class="QLabel" name="_wkLit">\n            <property name="text">\n             <string>Work Date:</string>\n            </property>\n            <property name="alignment">\n             <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n            </property>\n           </widget>\n          </item>\n          <item row="1" column="0">\n           <widget class="QLabel" name="_projectLit">\n            <property name="text">\n             <string>Project #:</string>\n            </property>\n            <property name="alignment">\n             <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n            </property>\n           </widget>\n          </item>\n          <item row="1" column="1" colspan="5">\n           <widget class="ProjectCluster" name="_project">\n            <property name="focusPolicy">\n             <enum>Qt::StrongFocus</enum>\n            </property>\n            <property name="label">\n             <string/>\n            </property>\n            <property name="nameVisible">\n             <bool>true</bool>\n            </property>\n            <property name="orientation">\n             <enum>Qt::Horizontal</enum>\n            </property>\n            <property name="infoVisible" stdset="0">\n             <bool>false</bool>\n            </property>\n            <property name="listVisible" stdset="0">\n             <bool>false</bool>\n            </property>\n           </widget>\n          </item>\n          <item row="0" column="3">\n           <layout class="QHBoxLayout" name="horizontalLayout_9">\n            <item>\n             <widget class="DLineEdit" name="_workdate">\n              <property name="focusPolicy">\n               <enum>Qt::StrongFocus</enum>\n              </property>\n             </widget>\n            </item>\n            <item>\n             <spacer name="horizontalSpacer_9">\n              <property name="orientation">\n               <enum>Qt::Horizontal</enum>\n              </property>\n              <property name="sizeHint" stdset="0">\n               <size>\n                <width>0</width>\n                <height>20</height>\n               </size>\n              </property>\n             </spacer>\n            </item>\n           </layout>\n          </item>\n          <item row="2" column="0">\n           <widget class="QLabel" name="_taskLit">\n            <property name="text">\n             <string>Task:</string>\n            </property>\n            <property name="alignment">\n             <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n            </property>\n           </widget>\n          </item>\n          <item row="2" column="1" colspan="5">\n           <layout class="QHBoxLayout" name="horizontalLayout_4">\n            <item>\n             <widget class="XComboBox" name="_task">\n              <property name="focusPolicy">\n               <enum>Qt::StrongFocus</enum>\n              </property>\n              <property name="sizeAdjustPolicy">\n               <enum>QComboBox::AdjustToContents</enum>\n              </property>\n             </widget>\n            </item>\n            <item>\n             <spacer name="horizontalSpacer_2">\n              <property name="orientation">\n               <enum>Qt::Horizontal</enum>\n              </property>\n              <property name="sizeHint" stdset="0">\n               <size>\n                <width>0</width>\n                <height>13</height>\n               </size>\n              </property>\n             </spacer>\n            </item>\n           </layout>\n          </item>\n          <item row="0" column="4">\n           <widget class="QLabel" name="_typeLit">\n            <property name="text">\n             <string>Type:</string>\n            </property>\n           </widget>\n          </item>\n          <item row="0" column="5">\n           <widget class="XComboBox" name="_type"/>\n          </item>\n         </layout>\n        </item>\n        <item>\n         <spacer name="horizontalSpacer_8">\n          <property name="orientation">\n           <enum>Qt::Horizontal</enum>\n          </property>\n          <property name="sizeHint" stdset="0">\n           <size>\n            <width>0</width>\n            <height>20</height>\n           </size>\n          </property>\n         </spacer>\n        </item>\n       </layout>\n      </item>\n     </layout>\n    </widget>\n   </item>\n   <item row="2" column="0" colspan="2">\n    <layout class="QHBoxLayout" name="horizontalLayout_10">\n     <item>\n      <layout class="QVBoxLayout" name="verticalLayout_2">\n       <item>\n        <widget class="QGroupBox" name="_custGroup">\n         <property name="title">\n          <string/>\n         </property>\n         <layout class="QGridLayout" name="gridLayout_2">\n          <item row="0" column="0">\n           <widget class="CustCluster" name="_clients">\n            <property name="focusPolicy">\n             <enum>Qt::StrongFocus</enum>\n            </property>\n            <property name="type">\n             <enum>CLineEdit::AllCustomers</enum>\n            </property>\n           </widget>\n          </item>\n          <item row="1" column="0">\n           <layout class="QHBoxLayout" name="horizontalLayout_2">\n            <item>\n             <widget class="QLabel" name="label_2">\n              <property name="text">\n               <string>  Cust. PO#:</string>\n              </property>\n             </widget>\n            </item>\n            <item>\n             <widget class="XLineEdit" name="_po">\n              <property name="sizePolicy">\n               <sizepolicy hsizetype="Maximum" vsizetype="Fixed">\n                <horstretch>0</horstretch>\n                <verstretch>0</verstretch>\n               </sizepolicy>\n              </property>\n              <property name="focusPolicy">\n               <enum>Qt::StrongFocus</enum>\n              </property>\n             </widget>\n            </item>\n            <item>\n             <spacer name="horizontalSpacer_3">\n              <property name="orientation">\n               <enum>Qt::Horizontal</enum>\n              </property>\n              <property name="sizeHint" stdset="0">\n               <size>\n                <width>0</width>\n                <height>20</height>\n               </size>\n              </property>\n             </spacer>\n            </item>\n           </layout>\n          </item>\n         </layout>\n        </widget>\n       </item>\n       <item>\n        <widget class="QGroupBox" name="_itemGroup">\n         <property name="title">\n          <string/>\n         </property>\n         <layout class="QGridLayout" name="gridLayout_10">\n          <item row="0" column="0">\n           <widget class="ItemCluster" name="_items"/>\n          </item>\n         </layout>\n        </widget>\n       </item>\n      </layout>\n     </item>\n     <item>\n      <widget class="QGroupBox" name="_qtyGroup">\n       <property name="minimumSize">\n        <size>\n         <width>231</width>\n         <height>171</height>\n        </size>\n       </property>\n       <property name="title">\n        <string/>\n       </property>\n       <layout class="QGridLayout" name="gridLayout">\n        <item row="0" column="0">\n         <layout class="QVBoxLayout" name="verticalLayout_4">\n          <item>\n           <layout class="QVBoxLayout" name="verticalLayout_3">\n            <item>\n             <layout class="QGridLayout" name="gridLayout_5">\n              <item row="1" column="0">\n               <widget class="QLabel" name="_qtyLabel">\n                <property name="text">\n                 <string>Hours:</string>\n                </property>\n                <property name="alignment">\n                 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                </property>\n               </widget>\n              </item>\n              <item row="2" column="0">\n               <widget class="QLabel" name="_rateLit">\n                <property name="text">\n                 <string>Rate:</string>\n                </property>\n                <property name="alignment">\n                 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                </property>\n               </widget>\n              </item>\n              <item row="3" column="0">\n               <widget class="QLabel" name="_totalLit">\n                <property name="text">\n                 <string>Total:</string>\n                </property>\n                <property name="alignment">\n                 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                </property>\n               </widget>\n              </item>\n              <item row="0" column="1">\n               <widget class="EmpCluster" name="_employee">\n                <property name="label">\n                 <string/>\n                </property>\n               </widget>\n              </item>\n              <item row="0" column="0">\n               <widget class="QLabel" name="_qtyLabel_2">\n                <property name="text">\n                 <string>Employee:</string>\n                </property>\n                <property name="alignment">\n                 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                </property>\n               </widget>\n              </item>\n              <item row="1" column="1">\n               <layout class="QHBoxLayout" name="horizontalLayout_3">\n                <item>\n                 <widget class="XLineEdit" name="_hours"/>\n                </item>\n                <item>\n                 <widget class="QCheckBox" name="_billable">\n                  <property name="focusPolicy">\n                   <enum>Qt::StrongFocus</enum>\n                  </property>\n                  <property name="text">\n                   <string>Billable</string>\n                  </property>\n                 </widget>\n                </item>\n                <item>\n                 <spacer name="horizontalSpacer_4">\n                  <property name="orientation">\n                   <enum>Qt::Horizontal</enum>\n                  </property>\n                  <property name="sizeHint" stdset="0">\n                   <size>\n                    <width>40</width>\n                    <height>20</height>\n                   </size>\n                  </property>\n                 </spacer>\n                </item>\n               </layout>\n              </item>\n              <item row="2" column="1">\n               <layout class="QHBoxLayout" name="horizontalLayout_6">\n                <item>\n                 <widget class="CurrCluster" name="_rate">\n                  <property name="focusPolicy">\n                   <enum>Qt::StrongFocus</enum>\n                  </property>\n                  <property name="fieldNameValue">\n                   <string>timedtl_rate</string>\n                  </property>\n                 </widget>\n                </item>\n                <item>\n                 <spacer name="horizontalSpacer_6">\n                  <property name="orientation">\n                   <enum>Qt::Horizontal</enum>\n                  </property>\n                  <property name="sizeHint" stdset="0">\n                   <size>\n                    <width>40</width>\n                    <height>20</height>\n                   </size>\n                  </property>\n                 </spacer>\n                </item>\n               </layout>\n              </item>\n              <item row="3" column="1">\n               <layout class="QHBoxLayout" name="horizontalLayout_7">\n                <item>\n                 <widget class="CurrCluster" name="_total">\n                  <property name="focusPolicy">\n                   <enum>Qt::NoFocus</enum>\n                  </property>\n                  <property name="enabled">\n                   <bool>false</bool>\n                  </property>\n                 </widget>\n                </item>\n                <item>\n                 <spacer name="horizontalSpacer_7">\n                  <property name="orientation">\n                   <enum>Qt::Horizontal</enum>\n                  </property>\n                  <property name="sizeHint" stdset="0">\n                   <size>\n                    <width>40</width>\n                    <height>20</height>\n                   </size>\n                  </property>\n                 </spacer>\n                </item>\n               </layout>\n              </item>\n              <item row="7" column="1">\n               <widget class="QCheckBox" name="_prepaid">\n                <property name="focusPolicy">\n                 <enum>Qt::StrongFocus</enum>\n                </property>\n                <property name="text">\n                 <string>Prepaid (not reimbursable)</string>\n                </property>\n               </widget>\n              </item>\n              <item row="5" column="0">\n               <widget class="QLabel" name="_empcostLit">\n                <property name="text">\n                 <string>Hourly Cost:</string>\n                </property>\n                <property name="alignment">\n                 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                </property>\n               </widget>\n              </item>\n              <item row="5" column="1">\n               <layout class="QHBoxLayout" name="horizontalLayout_12">\n                <item>\n                 <widget class="CurrCluster" name="_empcost">\n                  <property name="enabled">\n                   <bool>false</bool>\n                  </property>\n                 </widget>\n                </item>\n                <item>\n                 <spacer name="horizontalSpacer_11">\n                  <property name="orientation">\n                   <enum>Qt::Horizontal</enum>\n                  </property>\n                  <property name="sizeHint" stdset="0">\n                   <size>\n                    <width>40</width>\n                    <height>20</height>\n                   </size>\n                  </property>\n                 </spacer>\n                </item>\n               </layout>\n              </item>\n              <item row="6" column="0">\n               <widget class="QLabel" name="_totCostLit">\n                <property name="text">\n                 <string>Total Cost:</string>\n                </property>\n                <property name="alignment">\n                 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                </property>\n               </widget>\n              </item>\n              <item row="6" column="1">\n               <layout class="QHBoxLayout" name="horizontalLayout_13">\n                <item>\n                 <widget class="CurrCluster" name="_totCost">\n                  <property name="enabled">\n                   <bool>false</bool>\n                  </property>\n                 </widget>\n                </item>\n                <item>\n                 <spacer name="horizontalSpacer_13">\n                  <property name="orientation">\n                   <enum>Qt::Horizontal</enum>\n                  </property>\n                  <property name="sizeHint" stdset="0">\n                   <size>\n                    <width>40</width>\n                    <height>20</height>\n                   </size>\n                  </property>\n                 </spacer>\n                </item>\n               </layout>\n              </item>\n             </layout>\n            </item>\n           </layout>\n          </item>\n          <item>\n           <spacer name="verticalSpacer_3">\n            <property name="orientation">\n             <enum>Qt::Vertical</enum>\n            </property>\n            <property name="sizeHint" stdset="0">\n             <size>\n              <width>20</width>\n              <height>0</height>\n             </size>\n            </property>\n           </spacer>\n          </item>\n         </layout>\n        </item>\n       </layout>\n      </widget>\n     </item>\n    </layout>\n   </item>\n   <item row="3" column="0" colspan="2">\n    <widget class="QTabWidget" name="_tab">\n     <property name="currentIndex">\n      <number>0</number>\n     </property>\n     <widget class="QWidget" name="_summaryTab">\n      <attribute name="title">\n       <string>Summary</string>\n      </attribute>\n      <layout class="QGridLayout" name="gridLayout_14">\n       <item row="0" column="0">\n        <widget class="QGroupBox" name="_projectGroup">\n         <property name="title">\n          <string>Task</string>\n         </property>\n         <layout class="QGridLayout" name="gridLayout_6">\n          <item row="0" column="0">\n           <layout class="QVBoxLayout" name="verticalLayout">\n            <item>\n             <layout class="QHBoxLayout" name="horizontalLayout_5">\n              <item>\n               <spacer name="horizontalSpacer_10">\n                <property name="orientation">\n                 <enum>Qt::Horizontal</enum>\n                </property>\n                <property name="sizeHint" stdset="0">\n                 <size>\n                  <width>40</width>\n                  <height>20</height>\n                 </size>\n                </property>\n               </spacer>\n              </item>\n              <item>\n               <layout class="QGridLayout" name="gridLayout_4">\n                <item row="0" column="0">\n                 <widget class="QLabel" name="_budgetLit">\n                  <property name="text">\n                   <string>Planned Hours:</string>\n                  </property>\n                  <property name="alignment">\n                   <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                  </property>\n                 </widget>\n                </item>\n                <item row="0" column="1">\n                 <widget class="XLabel" name="_budget"/>\n                </item>\n                <item row="0" column="2" rowspan="2">\n                 <widget class="Line" name="line">\n                  <property name="orientation">\n                   <enum>Qt::Vertical</enum>\n                  </property>\n                 </widget>\n                </item>\n                <item row="0" column="3">\n                 <widget class="QLabel" name="_budgetCostLit">\n                  <property name="text">\n                   <string>Planned Expense:</string>\n                  </property>\n                  <property name="alignment">\n                   <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                  </property>\n                 </widget>\n                </item>\n                <item row="0" column="4">\n                 <widget class="XLabel" name="_budgetCost"/>\n                </item>\n                <item row="1" column="0">\n                 <widget class="QLabel" name="_actualLit">\n                  <property name="text">\n                   <string>Actual Hours:</string>\n                  </property>\n                  <property name="alignment">\n                   <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                  </property>\n                 </widget>\n                </item>\n                <item row="1" column="1">\n                 <widget class="XLabel" name="_actual"/>\n                </item>\n                <item row="1" column="3">\n                 <widget class="QLabel" name="_actualCostLit">\n                  <property name="text">\n                   <string>Actual Expense:</string>\n                  </property>\n                  <property name="alignment">\n                   <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                  </property>\n                 </widget>\n                </item>\n                <item row="1" column="4">\n                 <widget class="XLabel" name="_actualCost"/>\n                </item>\n               </layout>\n              </item>\n              <item>\n               <spacer name="horizontalSpacer_5">\n                <property name="orientation">\n                 <enum>Qt::Horizontal</enum>\n                </property>\n                <property name="sizeHint" stdset="0">\n                 <size>\n                  <width>0</width>\n                  <height>20</height>\n                 </size>\n                </property>\n               </spacer>\n              </item>\n             </layout>\n            </item>\n            <item>\n             <spacer name="verticalSpacer_2">\n              <property name="orientation">\n               <enum>Qt::Vertical</enum>\n              </property>\n              <property name="sizeHint" stdset="0">\n               <size>\n                <width>20</width>\n                <height>0</height>\n               </size>\n              </property>\n             </spacer>\n            </item>\n           </layout>\n          </item>\n         </layout>\n        </widget>\n       </item>\n       <item row="0" column="1">\n        <widget class="QGroupBox" name="groupBox">\n         <property name="title">\n          <string>Employee</string>\n         </property>\n         <layout class="QGridLayout" name="gridLayout_13">\n          <item row="0" column="0">\n           <layout class="QVBoxLayout" name="verticalLayout_5">\n            <item>\n             <layout class="QHBoxLayout" name="horizontalLayout_11">\n              <item>\n               <layout class="QGridLayout" name="gridLayout_12">\n                <item row="0" column="0">\n                 <widget class="QLabel" name="_dayHrsLit">\n                  <property name="text">\n                   <string>Day Total:</string>\n                  </property>\n                  <property name="alignment">\n                   <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                  </property>\n                 </widget>\n                </item>\n                <item row="0" column="1">\n                 <widget class="XLabel" name="_dayHrs"/>\n                </item>\n                <item row="1" column="0">\n                 <widget class="QLabel" name="_weekHrsLit">\n                  <property name="text">\n                   <string>Sheet Total:</string>\n                  </property>\n                  <property name="alignment">\n                   <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                  </property>\n                 </widget>\n                </item>\n                <item row="1" column="1">\n                 <widget class="XLabel" name="_weekHrs"/>\n                </item>\n                <item row="1" column="2">\n                 <widget class="QLabel" name="_actualCostLit_2">\n                  <property name="text">\n                   <string>Hours</string>\n                  </property>\n                  <property name="alignment">\n                   <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                  </property>\n                 </widget>\n                </item>\n                <item row="0" column="2">\n                 <widget class="QLabel" name="_budgetCostLit_2">\n                  <property name="text">\n                   <string>Hours</string>\n                  </property>\n                  <property name="alignment">\n                   <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n                  </property>\n                 </widget>\n                </item>\n               </layout>\n              </item>\n              <item>\n               <spacer name="horizontalSpacer_12">\n                <property name="orientation">\n                 <enum>Qt::Horizontal</enum>\n                </property>\n                <property name="sizeHint" stdset="0">\n                 <size>\n                  <width>0</width>\n                  <height>20</height>\n                 </size>\n                </property>\n               </spacer>\n              </item>\n             </layout>\n            </item>\n            <item>\n             <spacer name="verticalSpacer_4">\n              <property name="orientation">\n               <enum>Qt::Vertical</enum>\n              </property>\n              <property name="sizeHint" stdset="0">\n               <size>\n                <width>20</width>\n                <height>0</height>\n               </size>\n              </property>\n             </spacer>\n            </item>\n           </layout>\n          </item>\n         </layout>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n     <widget class="QWidget" name="_notesTab">\n      <attribute name="title">\n       <string>Notes</string>\n      </attribute>\n      <layout class="QGridLayout" name="gridLayout_9">\n       <item row="0" column="0">\n        <widget class="XTextEdit" name="_notes">\n         <property name="focusPolicy">\n          <enum>Qt::StrongFocus</enum>\n         </property>\n         <property name="tabChangesFocus">\n          <bool>true</bool>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </widget>\n   </item>\n  </layout>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>CurrCluster</class>\n   <extends></extends>\n   <header>currcluster.h</header>\n  </customwidget>\n  <customwidget>\n   <class>CustCluster</class>\n   <extends></extends>\n   <header>custcluster.h</header>\n  </customwidget>\n  <customwidget>\n   <class>DLineEdit</class>\n   <extends></extends>\n   <header>datecluster.h</header>\n   <container>1</container>\n  </customwidget>\n  <customwidget>\n   <class>EmpCluster</class>\n   <extends></extends>\n   <header>empcluster.h</header>\n  </customwidget>\n  <customwidget>\n   <class>ItemCluster</class>\n   <extends></extends>\n   <header>itemcluster.h</header>\n   <container>1</container>\n  </customwidget>\n  <customwidget>\n   <class>ProjectCluster</class>\n   <extends></extends>\n   <header>projectcluster.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XComboBox</class>\n   <extends></extends>\n   <header>xcombobox.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XLabel</class>\n   <extends></extends>\n   <header>xlabel.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XLineEdit</class>\n   <extends></extends>\n   <header>xlineedit.h</header>\n   <container>1</container>\n  </customwidget>\n  <customwidget>\n   <class>XTextEdit</class>\n   <extends></extends>\n   <header>xtextedit.h</header>\n  </customwidget>\n </customwidgets>\n <tabstops>\n  <tabstop>_workdate</tabstop>\n  <tabstop>_type</tabstop>\n  <tabstop>_project</tabstop>\n  <tabstop>_task</tabstop>\n  <tabstop>_clients</tabstop>\n  <tabstop>_po</tabstop>\n  <tabstop>_items</tabstop>\n  <tabstop>_employee</tabstop>\n  <tabstop>_hours</tabstop>\n  <tabstop>_billable</tabstop>\n  <tabstop>_rate</tabstop>\n  <tabstop>_prepaid</tabstop>\n  <tabstop>_tab</tabstop>\n  <tabstop>_notes</tabstop>\n  <tabstop>_buttonBox</tabstop>\n </tabstops>\n <resources/>\n <connections>\n  <connection>\n   <sender>_rate</sender>\n   <signal>idChanged(int)</signal>\n   <receiver>_total</receiver>\n   <slot>setId(int)</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>598</x>\n     <y>292</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>598</x>\n     <y>330</y>\n    </hint>\n   </hints>\n  </connection>\n </connections>\n</ui>\n     Time and Expense package
105791
 
57      timeExpenseSheets       0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>timeExpenseSheets</class>\n <widget class="QWidget" name="timeExpenseSheets">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>800</width>\n    <height>600</height>\n   </rect>\n  </property>\n  <property name="sizePolicy">\n   <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">\n    <horstretch>0</horstretch>\n    <verstretch>0</verstretch>\n   </sizepolicy>\n  </property>\n  <property name="minimumSize">\n   <size>\n    <width>700</width>\n    <height>370</height>\n   </size>\n  </property>\n  <property name="windowTitle">\n   <string>Time and Expense Sheets</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout_5">\n   <property name="margin">\n    <number>0</number>\n   </property>\n   <property name="spacing">\n    <number>0</number>\n   </property>\n   <item row="0" column="0">\n    <widget class="QToolBar" name="_toolBar">\n     <property name="enabled">\n      <bool>true</bool>\n     </property>\n     <property name="orientation">\n      <enum>Qt::Horizontal</enum>\n     </property>\n     <property name="toolButtonStyle">\n      <enum>Qt::ToolButtonIconOnly</enum>\n     </property>\n     <addaction name="_new"/>\n     <addaction name="_close"/>\n     <addaction name="separator"/>\n     <addaction name="_approve"/>\n     <addaction name="_process"/>\n     <addaction name="separator"/>\n     <addaction name="_print"/>\n     <addaction name="separator"/>\n     <addaction name="_query"/>\n    </widget>\n   </item>\n   <item row="1" column="0">\n    <widget class="QFrame" name="frame">\n     <property name="frameShape">\n      <enum>QFrame::StyledPanel</enum>\n     </property>\n     <property name="frameShadow">\n      <enum>QFrame::Raised</enum>\n     </property>\n     <layout class="QGridLayout" name="gridLayout_3">\n      <item row="0" column="0">\n       <widget class="QGroupBox" name="_empGrp">\n        <property name="minimumSize">\n         <size>\n          <width>301</width>\n          <height>111</height>\n         </size>\n        </property>\n        <property name="baseSize">\n         <size>\n          <width>0</width>\n          <height>0</height>\n         </size>\n        </property>\n        <property name="title">\n         <string>Employees</string>\n        </property>\n        <layout class="QGridLayout" name="gridLayout">\n         <item row="0" column="0">\n          <layout class="QHBoxLayout" name="horizontalLayout_2">\n           <item>\n            <widget class="QRadioButton" name="_showAllEmployees">\n             <property name="text">\n              <string>All</string>\n             </property>\n            </widget>\n           </item>\n           <item>\n            <spacer name="horizontalSpacer">\n             <property name="orientation">\n              <enum>Qt::Horizontal</enum>\n             </property>\n             <property name="sizeType">\n              <enum>QSizePolicy::Preferred</enum>\n             </property>\n             <property name="sizeHint" stdset="0">\n              <size>\n               <width>40</width>\n               <height>10</height>\n              </size>\n             </property>\n            </spacer>\n           </item>\n          </layout>\n         </item>\n         <item row="1" column="0">\n          <layout class="QHBoxLayout" name="horizontalLayout">\n           <item>\n            <widget class="QRadioButton" name="_selected">\n             <property name="text">\n              <string>Selected:</string>\n             </property>\n            </widget>\n           </item>\n           <item>\n            <widget class="EmpCluster" name="_employee"/>\n           </item>\n           <item>\n            <spacer name="horizontalSpacer_2">\n             <property name="orientation">\n              <enum>Qt::Horizontal</enum>\n             </property>\n             <property name="sizeHint" stdset="0">\n              <size>\n               <width>40</width>\n               <height>10</height>\n              </size>\n             </property>\n            </spacer>\n           </item>\n          </layout>\n         </item>\n        </layout>\n       </widget>\n      </item>\n      <item row="0" column="2">\n       <widget class="QGroupBox" name="_weekendingGrp">\n        <property name="minimumSize">\n         <size>\n          <width>253</width>\n          <height>111</height>\n         </size>\n        </property>\n        <property name="title">\n         <string>Week of</string>\n        </property>\n        <layout class="QGridLayout" name="gridLayout_4">\n         <property name="verticalSpacing">\n          <number>5</number>\n         </property>\n         <item row="0" column="0">\n          <widget class="DateCluster" name="_weekending"/>\n         </item>\n        </layout>\n       </widget>\n      </item>\n      <item row="0" column="3">\n       <widget class="QGroupBox" name="_unposted">\n        <property name="title">\n         <string>Status</string>\n        </property>\n        <layout class="QVBoxLayout" name="verticalLayout">\n         <item>\n          <widget class="XCheckBox" name="_open">\n           <property name="text">\n            <string>Open</string>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <widget class="XCheckBox" name="_approved">\n           <property name="text">\n            <string>Approved</string>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <widget class="XCheckBox" name="_closed">\n           <property name="text">\n            <string>Closed</string>\n           </property>\n          </widget>\n         </item>\n        </layout>\n       </widget>\n      </item>\n     </layout>\n    </widget>\n   </item>\n   <item row="2" column="0">\n    <widget class="XTreeWidget" name="_sheets">\n     <property name="selectionMode">\n      <enum>QAbstractItemView::ExtendedSelection</enum>\n     </property>\n     <property name="populateLinear">\n      <bool>false</bool>\n     </property>\n    </widget>\n   </item>\n   <item row="3" column="0">\n    <layout class="QHBoxLayout" name="horizontalLayout_3">\n     <property name="spacing">\n      <number>12</number>\n     </property>\n     <property name="margin">\n      <number>6</number>\n     </property>\n     <item>\n      <widget class="QLabel" name="label">\n       <property name="text">\n        <string>When Processing:</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <widget class="XCheckBox" name="_invoice">\n       <property name="text">\n        <string>Invoice</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <widget class="XCheckBox" name="_voucher">\n       <property name="text">\n        <string>Voucher</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <widget class="XCheckBox" name="_post">\n       <property name="text">\n        <string>Post Time</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <spacer name="horizontalSpacer_5">\n       <property name="orientation">\n        <enum>Qt::Horizontal</enum>\n       </property>\n       <property name="sizeHint" stdset="0">\n        <size>\n         <width>40</width>\n         <height>0</height>\n        </size>\n       </property>\n      </spacer>\n     </item>\n    </layout>\n   </item>\n  </layout>\n  <action name="_new">\n   <property name="text">\n    <string>New</string>\n   </property>\n   <property name="shortcut">\n    <string>Ctrl+N</string>\n   </property>\n  </action>\n  <action name="_close">\n   <property name="text">\n    <string>Close</string>\n   </property>\n   <property name="shortcut">\n    <string>Ctrl+W</string>\n   </property>\n  </action>\n  <action name="_process">\n   <property name="text">\n    <string>Process</string>\n   </property>\n   <property name="toolTip">\n    <string>Process Approved</string>\n   </property>\n  </action>\n  <action name="_approve">\n   <property name="text">\n    <string>Approve</string>\n   </property>\n   <property name="toolTip">\n    <string>Approve All</string>\n   </property>\n  </action>\n  <action name="_query">\n   <property name="text">\n    <string>Query</string>\n   </property>\n   <property name="shortcut">\n    <string>Ctrl+R</string>\n   </property>\n  </action>\n  <action name="_print">\n   <property name="text">\n    <string>Print</string>\n   </property>\n   <property name="shortcut">\n    <string>Ctrl+P</string>\n   </property>\n  </action>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>DateCluster</class>\n   <extends>QWidget</extends>\n   <header>datecluster.h</header>\n   <container>1</container>\n  </customwidget>\n  <customwidget>\n   <class>EmpCluster</class>\n   <extends>QWidget</extends>\n   <header>empcluster.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XCheckBox</class>\n   <extends>QCheckBox</extends>\n   <header>xcheckbox.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>xtreewidget.h</header>\n   <container>1</container>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections/>\n</ui>\n     Time and Expense package
105792
 
53      tecustomer      0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>tecustomer</class>\n <widget class="QDialog" name="tecustomer">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>323</width>\n    <height>91</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Billing</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout">\n   <property name="leftMargin">\n    <number>0</number>\n   </property>\n   <property name="topMargin">\n    <number>6</number>\n   </property>\n   <property name="rightMargin">\n    <number>0</number>\n   </property>\n   <property name="bottomMargin">\n    <number>0</number>\n   </property>\n   <item row="0" column="0">\n    <widget class="QGroupBox" name="_billingGroup">\n     <property name="sizePolicy">\n      <sizepolicy hsizetype="Preferred" vsizetype="Preferred">\n       <horstretch>0</horstretch>\n       <verstretch>1</verstretch>\n      </sizepolicy>\n     </property>\n     <property name="title">\n      <string>Use specified billing rate</string>\n     </property>\n     <property name="checkable">\n      <bool>true</bool>\n     </property>\n     <property name="checked">\n      <bool>false</bool>\n     </property>\n     <layout class="QHBoxLayout" name="horizontalLayout">\n      <item>\n       <widget class="QLabel" name="_rateLit">\n        <property name="text">\n         <string>Rate:</string>\n        </property>\n        <property name="alignment">\n         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n        </property>\n       </widget>\n      </item>\n      <item>\n       <widget class="CurrCluster" name="_rate"/>\n      </item>\n      <item>\n       <spacer name="horizontalSpacer_2">\n        <property name="orientation">\n         <enum>Qt::Horizontal</enum>\n        </property>\n        <property name="sizeHint" stdset="0">\n         <size>\n          <width>41</width>\n          <height>20</height>\n         </size>\n        </property>\n       </spacer>\n      </item>\n     </layout>\n    </widget>\n   </item>\n  </layout>\n </widget>\n <layoutdefault spacing="6" margin="11"/>\n <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>\n <customwidgets>\n  <customwidget>\n   <class>CurrCluster</class>\n   <extends>CurrDisplay</extends>\n   <header>currcluster.h</header>\n  </customwidget>\n  <customwidget>\n   <class>CurrDisplay</class>\n   <extends>QWidget</extends>\n   <header>currcluster.h</header>\n  </customwidget>\n </customwidgets>\n <tabstops>\n  <tabstop>_rate</tabstop>\n </tabstops>\n <resources/>\n <connections>\n  <connection>\n   <sender>_billingGroup</sender>\n   <signal>toggled(bool)</signal>\n   <receiver>_rate</receiver>\n   <slot>setCurrencyEnabled(bool)</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>210</x>\n     <y>133</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>167</x>\n     <y>142</y>\n    </hint>\n   </hints>\n  </connection>\n </connections>\n</ui>\n      Time and Expense package
105793
 
51      projectGantt    0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>projectGantt</class>\n <widget class="QWidget" name="projectGantt">\n  <property name="windowModality">\n   <enum>Qt::NonModal</enum>\n  </property>\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>800</width>\n    <height>600</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Project Gantt</string>\n  </property>\n  <property name="statusTip">\n   <string/>\n  </property>\n  <layout class="QGridLayout" name="gridLayout">\n   <property name="margin">\n    <number>0</number>\n   </property>\n   <property name="spacing">\n    <number>0</number>\n   </property>\n   <item row="0" column="0">\n    <widget class="QToolBar" name="_toolBar">\n     <property name="enabled">\n      <bool>true</bool>\n     </property>\n     <property name="orientation">\n      <enum>Qt::Horizontal</enum>\n     </property>\n     <property name="toolButtonStyle">\n      <enum>Qt::ToolButtonIconOnly</enum>\n     </property>\n     <addaction name="_close"/>\n     <addaction name="separator"/>\n    </widget>\n   </item>\n  </layout>\n  <action name="_close">\n   <property name="text">\n    <string>Close</string>\n   </property>\n   <property name="shortcut">\n    <string>Ctrl+W</string>\n   </property>\n  </action>\n </widget>\n <resources/>\n <connections/>\n</ui>\n     Time and Expense package
105794
 
\.
105795
 
 
105796
 
 
105797
 
--
105798
 
--
105799
 
 
105800
 
COPY tecustrate (tecustrate_cust_id, tecustrate_rate, tecustrate_id, tecustrate_curr_id) FROM stdin;
105801
 
\.
105802
 
 
105803
 
 
105804
 
--
105805
 
--
105806
 
 
105807
 
SELECT pg_catalog.setval('tecustrate_tecustrate_id_seq', 1, false);
105808
 
 
105809
 
 
105810
 
--
105811
 
--
105812
 
 
105813
 
COPY teemp (teemp_id, teemp_emp_id, teemp_contractor) FROM stdin;
105814
 
\.
105815
 
 
105816
 
 
105817
 
--
105818
 
--
105819
 
 
105820
 
SELECT pg_catalog.setval('teemp_teemp_id_seq', 1, false);
105821
 
 
105822
 
 
105823
 
--
105824
 
--
105825
 
 
105826
 
COPY teexp (teexp_id, teexp_expcat_id, teexp_accnt_id) FROM stdin;
105827
 
\.
105828
 
 
105829
 
 
105830
 
--
105831
 
--
105832
 
 
105833
 
COPY tehead (tehead_id, tehead_number, tehead_weekending, tehead_lastupdated, tehead_notes, tehead_status, tehead_emp_id, tehead_warehous_id, tehead_username) FROM stdin;
105834
 
\.
105835
 
 
105836
 
 
105837
 
--
105838
 
--
105839
 
 
105840
 
SELECT pg_catalog.setval('tehead_tehead_id_seq', 1, false);
105841
 
 
105842
 
 
105843
 
--
105844
 
--
105845
 
 
105846
 
COPY teitem (teitem_id, teitem_tehead_id, teitem_linenumber, teitem_type, teitem_workdate, teitem_cust_id, teitem_vend_id, teitem_po, teitem_item_id, teitem_qty, teitem_rate, teitem_total, teitem_prjtask_id, teitem_lastupdated, teitem_billable, teitem_prepaid, teitem_notes, teitem_posted, teitem_curr_id, teitem_uom_id, teitem_invcitem_id, teitem_vodist_id, teitem_postedvalue, teitem_empcost) FROM stdin;
105847
 
\.
105848
 
 
105849
 
 
105850
 
--
105851
 
--
105852
 
 
105853
 
SELECT pg_catalog.setval('teitem_teitem_id_seq', 1, false);
105854
 
 
105855
 
 
105856
 
--
105857
 
--
105858
 
 
105859
 
COPY teprj (teprj_id, teprj_prj_id, teprj_cust_id, teprj_rate, teprj_curr_id) FROM stdin;
105860
 
\.
105861
 
 
105862
 
 
105863
 
--
105864
 
--
105865
 
 
105866
 
SELECT pg_catalog.setval('teprj_teprj_id_seq', 1, false);
105867
 
 
105868
 
 
105869
 
--
105870
 
--
105871
 
 
105872
 
COPY teprjtask (teprjtask_id, teprjtask_cust_id, teprjtask_rate, teprjtask_item_id, teprjtask_prjtask_id, teprjtask_curr_id) FROM stdin;
105873
 
\.
105874
 
 
105875
 
 
105876
 
--
105877
 
--
105878
 
 
105879
 
SELECT pg_catalog.setval('teprjtask_teprjtask_id_seq', 1, false);
105880
 
 
105881
 
 
105882
 
--
105883
 
--
105884
 
 
105885
 
SELECT pg_catalog.setval('timesheet_seq', 1000, false);
105886
 
 
105887
 
 
105888
 
SET search_path = xtdesktop, pg_catalog;
105889
 
 
105890
 
--
105891
 
--
105892
 
 
105893
 
COPY pkgcmd (cmd_id, cmd_module, cmd_title, cmd_descrip, cmd_privname, cmd_executable, cmd_name) FROM stdin;
105894
 
\.
105895
 
 
105896
 
 
105897
 
--
105898
 
--
105899
 
 
105900
 
COPY pkgcmdarg (cmdarg_id, cmdarg_cmd_id, cmdarg_order, cmdarg_arg) FROM stdin;
105901
 
\.
105902
 
 
105903
 
 
105904
 
--
105905
 
--
105906
 
 
105907
 
COPY pkgimage (image_id, image_name, image_descrip, image_data) FROM stdin;
105908
 
6544    ImgLeftArrow            begin 644 internal\nMB5!.1PT*&@H````-24A$4@```!`````0"`,````H+0]3````NE!,5$4```#_\nM___,S,R99@"MK:WSB;_;;::5BY(5#!6TA+3\\]/QE#&WAKO6[8^L:&2?DX_L$\nM!(0$!`P("!3T]/S#P\\2\\O]&BI*SBY.P$-,QRE/S+SM4P6:L&.9@:5L`82J,U\nM??P]:KM*>\\='6747-5XP68YJE<U^I-6)F:^_T>I^BIHC9+0E7)\\Y:Z>2LMG,\nMV^T$:=@]>+@V9)A3B<-FB[:?O=VRR>/D[/4E3'(]=*Q*>:I[N?:9R_M#3%39\nMY_3:KCHZ`````7123E,`0.;89@````EP2%ES```+$P``"Q,!`)J<&````$])\nM1$%4&)5C8"`2&*+ST00,U5`%#%5M#>$`R%=1U0,"#3`R40'RC7010`TDH&-A\nM`(<6*B`M!D8(`!)@,#=2-8<#!HB(.9K#S-$%&#`$\\```;J02#'C$':4`````\n(245.1*Y"8(((\n`\nend\n
105909
 
6545    gear_16         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```!`````0"`8````?\\_]A````"7!(67,```[$\nM```.Q`&5*PX;```#!$E$050XC:6376A;91C'_V_>]YR3\\Y&F25JSUB5=IE/;\nM364RI]$B.*8P/Y`A0THIZ(5>J'@AXI4?B"!>.5!!1*:XFX+M',P;9>!T.I55\nMF'5C;B.X-6V:[Y-DR3EO<C[>UZLQ-N:-_B[_/,^/!Q[^P/^$7!]LGUE`H]4G\nM3SPT,>0,A/GKF7I-`D'AT+X;"B+7!TQ3<?-X?(Q%U?EJ+URL<YDN_-@@S[QS\nMXI%7/OQ]T\\&CE[!EW^&K\\P`PGO\\`;V?/X:#Y^%C']=NEFM<M.D3O],6D,&*/\nMT6EKM=;'QW!$:?_APDP\\/;1^C>"YN6D4Y?2F;)5_^<W)ZB^W3(Z)_-;47::A\nM#MMN^,FY,N=+*UV=K+B'[HA+N\\-Q[06^("C7G=O*G2!CQ(W79G=GB6%&Z5HG\nM@*%(FJ%1JRT47"CS8(W(2":)#5MFCU9K]D`2`(CD/H(X]C+PPM=[]CX\\\\=6.\nMJ5&K>%F@RDFE[$ARON&G>ZZ/H.\\UQW5Q^LE)TW%=;W:][778QKT+H(2P[HL+\nM(SW+RJA155]IA5AU2>746O_IBFJ,$,;FI:X:FL)23=?=7FCZ9Q,J+,)HA]VY\nM.8$A@Z4;7"[\\?)%/5;HA]:,2S8`JC=S(K3'*,[*E*$Y?0P*1T`[%ZZ<NMH[$\nM--((!<`HHQB.:;UD2FV?;81_KC2]J8$6I$I^)"4=_S-B:I&^8K$$\\Q`3`:^U\nM:=%^*E]I?;X$N;@3M$5WP[:Y5^?AL68W.-`4:JS&Y73+IQ"$49]$(XDH0<X0\nM8K7.Z8Y1\\N!]COW7KGN&_SZYN!^L?GP.=4#FGO]^/9.BV@4G@.MZ(8C"35W1\nMDS1"8Y*V2K;X-.@/Z$UCROUIDQ6D$%??"`!)BR$,17+/MO@#58[BB77OI0%G\nMV8;GO^_K=)F[X7OC>A!<J@;)X,WYTD\\SCP(`Z!7!1/Y9O#&WK>=R[P<IQ&^G\nM#_SQG7E[LGSO1G57/JMU73[XEA*TEM_:VCV/X^B?^>+&9;I"[M4E2(#MW!S;\nHD+18]\\ARY_*HQ>3RNW?_V\\I_XQ^8Q6FM@=RAW0````!)14Y$KD)@@H#M\n`\nend\n
105910
 
6555    accounting_write_48             begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```,O$E$051H@>V8>ZQE97G&?]]EK;77OIU]SIPY<SG#7'`$\nM`D.!06`HI3I:+#2U:2NUIM;6M,6DJ;:)UE9LTP:3BL2DC4&3-C%IHO\\8VT1C\nM%$5;H`,Z(G)1<&!F&.9^SIDY][/W7GM=ON][^\\<^<P"U%BCP3^=)=M;:R9?W\nM?9[W?=YWK[W@/,[C/,[C/,[C/,[C_R_4RSG\\[1,]@I#$1DW&5F]/K.HD1JG8\nMZC*Q:M8:==H+LX\\.RORJ-&9'8@`X[0).*5(D=4$F2B>3I9/QPH>H="*%DX72\nMAZ.EDRFEJ&[:VGSE`CZU?Q9`:T4C,KK?B(U$AC2Q:DMBU?6QT>](K+HFL6I]\nM8G6<6$5B58B-'D1&S>5>#IU8*O<_<7)P_W</+_ZPGECSYHL[NZ_:DN[=V(ZN\nM(\\C.TLNZPH6T<*)*+Q0N%$4E9PHOWRM<^&KAY/NEERGG*7J%UZ671A#I`O*1\nMZ]>_B*_]20$A`+!):>X&2A>",UIM"D%=),)&JY6M6TT]4B1&$1E%I)6QFL@H\nMVI7B0A%NSBKY\\.+"XI-9;&U6C>P2:!A`*X52@M&*R$()1.BZ1G;X$';D<&L0\nMIGR00Z67,T`-J(+P9PH6?Y+O3PL00>#B2.FW1UHUK%;$>DBX::%.2:UT6"<8\nM,VP56A.T0EE#K"T3B6)[)VHG.MQ0T\\(%[8A1(Z@\\QU<5WGLD""H()@2B`*DH\nM4!9M3*1%;1-1VT(`,5!YF?=!=BBE?KZ`CS]X%@`OZDUQ*!H34F"\\)D'1LH:F\nM:-IQ1*M>(XEC\\L$`[QQ*"?6T1I$7E'E.ZH6==<MXJJG%BJUQ@>KUB%IUXEJ"\nM,0:40@`1R+*,7K]/4SP]YTF\\D`H42BB#8SK$8YG$5VKDL9\\KP'FA[R1JQ'I/\nM0P9<M:5#F1=$UC`Z.HHU!F/T<'`D4(LLRAHJ[S#&D"0Q@E"YG*94*/$0%..I\nMH6XUC7H=K0V"(#(D+PJT-H002&LU8FO8/)8R*`K*LL)YS?+I@5J0:,_#)XM_\nM_?L'SLH=;YGXV0)\\$)1B@X2PJY4(S6:3Y:JBT6QAK%VU&%!F^(4SF"A&B1`'\nMAXD,5BDBJ4@2BP-$!`"E-:BP]EU>]%$D!L94A3A%B!*T-0@)1FM0BK;-H`I7\nM[=H0C_H@"_]C!U8'^!(5W.1(S:!0..>PU@Z3K^XL'27(R'HR[S%*8Q28*('@\nM<2A4MH+RR:I%9%CQ5;L(,F2^!D%,1!6EJ!!098YHC745*NNATB:=FH6^NU"(\nM=@1YL0!][N9#]TZA%`2X3H>JWJG'..>'A[1Y/J>`*(V.:QAC4$HQ*$N*RN%0\nM+#M8BIJ4)N8<U]7"$R0\\WX'5%H@(HA0#T?0P]&V-'$-A$O)TA%PGM!*#"=5H\nM$*X6$3[\\S9F?%A`$E@<^#H%K8JEH-U**LL08BRBUYMESY=-*4985956!TL/-\nM(D*]GI+44I360W+GV+_P_OG:#RVF-'&28*W%6CL<<FT(2N."IYG&Q%*I$.2Z\nM(_.5"B^(LR:@+`J\\*S=Z[W<UM".MU<CSG"B.AZG.#=TY(4I1UT)=*IK*4U.@\nME,(5!5F_MVJ7%YQ'K=IIK9$OZHYQ%6YQCJ+77<L;0L"Y0%I+:&A/".'*\\3IC\nMSE=K`M9F(._W`"Z+5'VRTU18:ZG*DF:SR0OL_P(K"3B'#P'E/0J(:S7J19<H\nM'W#&Q6N$UX9W[?H3(E!8:VCH0.@O0)%`'%/3X&V$-I9.35%EY86#RN_4(O,O\nM$K#CO7>R9=M6#C[UU/6)#K5UC2%I[SUF=8#5ZMY6#"L]&!246(Q5*$!K3='/\nM<'&3**HC<TMK%A($E&+8>H52SXM!*20(?1<HTU&\\*4B,)O8>NDL8K?%%Q06'\nM'R9YZL<=M[)P8W?WVQ_>,ZJY;3$,!:@XY9_NO"M]\\TTW7;LN[3/6&J>J*E!J\nM;8!EF)6JJJBJ@B+/D1`@LBBUZFBE"&BZ+E"F;83Y<RY'4!1%B?>!LAS^&@>1\nM53MJE%;4:BDNBAGD.2A--+Z%N6[&J<>^QN;O?(7+'[N7)3%[_^[PZ;O?>-EU\nM!0_M'PI(FF-,1,W)(IA+QQH)(\\TZ>5$0Q0F"PE4EQ2"CR`<HH%9+2-,ZUAJ4\nM`JV&7G#.$4*)`KQSJQV`?K^/<1JM%5IKDB0>5EZ&R\\,Y3U$49-D*`D1Q0F1B\nM3BT?Y\\Z'G^:1F9S=9U=XNVMQX+)W;K^G??7HN`QFU@3$S5&BEMZ5.S;8T8UD\nM8BD6IE!`518H(*VGM-L=4##(<^:6NT/_*[!:D5A#FB34ZG5J*!:R^=4*"PKH\nMC'8((3#("P:]`85S^"`$`:,UM22FV6X#BBP;<&3F`/O3+]*^\\A!;#NQ@?^N7\nMV=>Z@4V3UVS=6)87A=">`;#O^M))[OWRE[GT3=?O*8M^?#;7'%LIV9K4J-=2\nMTK1&"('E7L;1V3.L5$"48..8.+8D1I-H18(0%1[I+Z-#("O=VJ#VBXJ39Q<(\nM2A-,1$F-TB@*"11>*/,*MY2#6Z9M8:R=\\)!\\C</5(_3Z`_9NW<9;WPWW[-])\nMJ[>N6=3=-2M'S^Y[Q^>/8SNIX4_>_X>-'Q^9OG9V:IE6L<"XM/$JXN1"G_G>\nM/$LE5+:&K;5`&[)!(%L1!$]B`XW8,-8P3#1C&FF#7NZ8&O2HB##*<J)*F>PT\nMB:QF(0N<[3D6^HZL#!1.,$JHQPF-I,Z<$^XY_$V^D7T.%5>,A`W\\0FN4T[.6\nMYM(D*]4,G8MV7O_66V^,3AT[7=D-HS5B*UL[[?HE9XX7//G$8RS-;J2U?C.F\nM5B>.1X@CBZLJ9F>7.+TP8*E0!%/#1A%IK&G$FD9B:,5"4BX02T%N6JR4@5P"\nMCQ]?X(>'C]+U,44R3L]I>KDG*X6\\]/@JQX:"T52Q9:3.PZ>.<3`?,)9XKMCX\nM1AXY->#HXY?"X`QJ<T1GI'DY_>4-$YW:*?O$OF]#<#O+=,.XR_M,9XO8]CA5\nM6Q'YBL'L(HM+7196<C*OT%&*3>K8Q"/6(@%\\&#[)+O=SEJ9FF#M^B(4STPR\\\nM!0)']A5T)C8SONTB.IL;2%0GG'N,D$`(GD%1T5WJ\\\\3CL_CMM[!K.B4_\\2B'\nMK]Q,O]K+2,M3FD.4Y3J63AS<_,@S,]N5-J?L0_=^'1$9L4G=1O46QECZV8#H\nMR'.(LG@,*JJMDD[!!A"/A$`(@A<AR/!:Y3GE("//,I;FSI!UET&@UFB2MCJ4\nMJYO,F)0@X$60$(;K6#R]><_I]9/47<RN[&J.S1H6SFXGZB^QI)ZCMS2/=\\<X\nM\\Z-N[/*LI93"2O"(2!2J0KE<(TF=?K>+*1RV5L<D=:P$D(!(Z!+",0GAJ$@X\nM*2)+05;_7`5IET6^.<^R;7G6W^K*<IU2VJ#`N<KE67\\N'V3'TV)P/$[#=`CT\nMADLJ:$7H9'/Y[M/)NNNDF:H],_-T]!+5-HT>'*/,^U15%^\\<OL@(5:F!2$2P\nMPP?\\L"@2CHJ$C820($$A022$@N#G1<(A"?Z_)(3[)?AG@G=+H:RJ<I#QX$?W\nML/=3]Y+=_5'T!S]I\\ZS7RK/^I/?N<F`+(,'[XWG6?RK/>E/=Q;F>>^L>K[]\\\nM+P_>?C-ZTS_"]-F6_/&O_XM<-K;GJE/S;"\\7E[^[.'4H=)@,13$65!F+!"4A\nMB(20B\\A)D&4`-7+#NY$0(A/7)DU<>X.)TPTF28V)Z\\XFZ8R)TQ,ZJDV;N)F%\nM*N?@9]_'JX;:7T#^:<-O?N.ON/'B.R:G5Z);JJ7JU#//W+%/3GQFTP43&UPQ\nMV.J+P80O,^.+@?/E8-J7^9'@JRF4\\J\\>F9>-F^$K`C?^VV_QB4,+]8\\^)>_Z\nMP(/R.[=^X0OPNZWUXQ]X25%>UHNM5P\\WP-[;86;J"GY[SQ>)DTM^Z<19+JS.\nM?._^^[[S>ZWVNJ,'#OSM2XJD__<CKP%V_#[\\X$<3O.W*3S+2O.2"IV?8[A9/\nM_?C)@W^]9\\_>HP<.?.(EA_JI]T*O.=K_`$<?3GC/'WR,"R=^M?GH:7:K7C9U\nM_.@=/WCL8_NLO0G(7G*XUU>`_2"L_`W<\\M7W<>6V]T>'Y]6U55=\\?_J?[WO@\nM2Y]OMY_$^_]X62'-:T3U9^`&^*./@_G%O;QMUZ=UMQJ[;F:.#7[VG@?W[?_(\nM^O4[N[.SGWG945^W&;"[_Y3&_H<NY"V7W67B>/,U<TN\\(5XY\\-23!VZ_^))+\nM9T^<_,]7%O=5YODS\\1NWOI=PQ78V54?>\\T1ZYIJ%IV?8YO+YYYY[]O;;;OOS\nM)S_TES<#C[^BV*^+@&:SC3WQ[U%K8M/NF\\IY%CO^]'W?.G''P:>?_?HCCWZ'\nM5TH>7B<+Y45)M]L?[76[VUU5?,OJV7<>?/;NS_W*KYWU9?F5_U/LUV6(9\\].\nM<^+HH=&JK*:5MG?5FYW#WW_H`9X[//UZI'_58'@-"O;?<,`@#IZ3WM$`````\n(245.1*Y"8(*5\n`\nend\n
105911
 
6556    accounting_zoom_48              begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```-+$E$051H@>V868QD5WG'?V>Y6U5U]3K=TS/M6>RQ9\\`#\nM>,!@&Y(8BQCR@,.2C22*$B4((@@O(!(B$2%")!+Q$!*41#R01$0()7E`H("8\nM$##&#C:#E_$,P1Z;V:>WZ:VJN^K67<XY7QZJ9[`QBT@BL)3Y2U=U2_ITSO__\nM??_O+!>NX1JNX1JNX1JNX1K^_T+].,%?NM`C"$ELU.[8ZGV)56.)42JVNDJL\nM6K%&S7MAY9%!51S)8O8G!H!Y%W!*D2&9"S)=.=E=.9DJ?8@J)U(Z6:]\\.%LY\nM65"*^NX]K?^Y@(\\\\N`*@M:(9&=UOQD8B0Y98-9=8=4=L]#V)52]/K-J16!TG\nM5I%8%6*C!Y%1JX67IRYTJ@>/7QS<^_6G-QYO)-;<>7#LI4?FLKMVMJ/;"'*@\nM\\C)9NI"53E3EA=*%LJQEN?3R4.G"YTHGQRHO"\\Y3]DJO*R_-(+(%R'OOV/$L\nMOO9[!80`P*S2?`RH7`C.:#4;@KI)A)U6*]NPFD:D2(PB,HI(*V,UD5&T:\\7U\nM(OQ"7LM[-M8W3N:QM7D]>EB@:0"M%$H)1BLB"Q40H1L:V>]#V%_`+P=AP0=Y\nMJO*R#*1`'81W*MCX7K[/%2""P,%(Z==&6C6M5L1Z2+AEH4%%6CFL$XP9E@JM\nM"5JAK"'6ENE$L6\\L:B<ZO"K5PG7MB'$CJ*+`US7>>R0(*@@F!*(`F2A0%FU,\nMI$7M%5%[0P`Q4'M9\\T'V*Z5^N(`_O?\\R`%[4K7$HF]-28KPF03%B#2W1M..(\nMD49*$L<4@P'>.902&EE*691414'FA0,-RU2F26/%GKA$]7I$(PWB-,$8`THA\nM@`CD>4ZOWZ<EGI[S)%[(!$HE5,&Q&.*)7.);-/+H#Q7@O-!W$C5C?7M3!AR9\nM&Z,J2B)K&!\\?QQJ#,7K8.!)((XNRAMH[C#$D28P@U*Z@)35*/`3%5&9H6$VS\nMT4!K@R"(#,F+`JT-(02R-"6VAET3&8.RI*IJG-=TYP=J7:+;OW&Q_(</?/6R\nM?/#5T]]?@`^"4LQ("(='$J'5:M&M:YJM$8RUVQ8#JAR_OHR)8I0(<7"8R&"5\nM(I*:)+$X0$0`4%J#"E?_R[,>16)@0M6(4X0H05N#D&"T!J5HVQSJ<.3P3#SN\nM@ZS_P`IL-_`A%=SNT=2@4#CGL-8.)]]>LW24(*,[R+W'*(U18*($@L>A4/DF\nMRB?;%I%AQK?M(LB0^54(8B+J*$.%@*H*1&NLJU%Y#Y6U&$LM]-WU0K0_R+,%\nMZ"LO[SZZ@%(0X#8=ZL98(\\8Y/PS2YKMS"HC2Z#C%&(-2BD%54=8.AZ+KH!.U\nMJ$S,%:[;B2=(^&X%MDL@(HA2#$33P]"W*06&TB04V2B%3AA)#";4XT%XF8CP\nMGB\\N/5=`$.@.?!P"+X^EIMW,**L*8RRBU%7/7DF?5HJJJJGJ&I0>KBPB-!H9\nM29JAM!Z2N\\+^F>_?S?W08DH3)PG66JRUPR;7AJ`T+GA:64PLM0I!;CN]5JOP\nMC'&N"JC*$N^JG=[[PTWMR-*4HBB(XG@XU96FNR)$*1I::$A-2WE2!4HI7%F2\nM]WO;=GE&/&K;3J!0H!0^!*K:X9Q'UQ6^NT;5[U^=-X2`<X$L36AJ3PCAEJD&\nM$\\[7S^V!HM\\#N#E2C=UC+86UEKJJ:+5:/,/^S["2@'/X$%#>HX`X36F46T3%\nM@&477R5\\M7FW;=/=W&)^<9E+EQ;I=+HX[XF"8RH6]NR:9F)Z)R0)J89@(Y2V\nMC"7@\\_)Z5Y0''*P]2\\#^W_HP<WOW<.I;W[HCT2&=;`Y)>^\\QVPVLMM=MQ3#3\nM@T%)A<58A0*TUI3]'!>WB*(&LMJY:B%!0"GJNF9A>95CWSS.HR=/L9&78"Q&\nM@2\\+M"N9G1SC]I>]F)>.3J%[G6&UM&4BBW`+_;'^YN9MXSMFOS'UNG>P>O1O\nMAP)4G/&7'_Z+[,Z[[W[%9-9G8F2*NJY!J:L-+$J!"'5=4]<E95$@(4!D46K;\nMT4H1T&RY0)6U$=:NN!Q!<?;\\`O?>?XQ'SBQQ_>$7<?/>.=(TP85`412L+RUR\nM[L1C?/;?OT:G"MQYU\\\\!8$S$1+6*KM?9ZO5N^]1;]YOK?OU#_FH%DM8$TU%K\nM=QG,"R>:":.M!D59$L4)@L+5%>4@IRP&*"!-$[*L@;4&I4"KH36<<X10H0#O\nMW'8%H-_O4_4]#SST*(\\M;/'Z-[^!/=/CU-ZS63I*YVDV$G9,M)F;V\\EC]]W'\nM`_=_G6:KR:$7'`2EB8UBJA5S:D%>,OTK?[8C;4\\N7140M\\:)1O3APC%CQW>2\nMBZ5<7T`!=56B@*R1T6Z/@8)!4;#:W1KZ7X'5BL0:LB0A;31(4:SG:\\-SE0A5\nM53._L,!#I^:YYTV_R('9";;*BK5^07=0T4HC6EE,,XO9.=EF)/UY_O,+7^3A\nM8X\\P=]T<K9$1ZJ2!'9]A4"[LG9B[_B9C[5#`K_[+18Y^YC.\\\\-8[;J_*?GRY\nMT)S;K-B3I#32C"Q+"2'0[>6<75EFLP:B!!O'Q+$E,9I$*Q*$J/1(OXL.@;QR\nM5YN^JAVG3I]G9/8Z;IR;HE?6.`P=IW%12J$-OH)>5="P,#XYP0TO.,13CQ]G\nM:7&9O5G&@HM8*Q1E'5K-R5TO+S;7OG;/)\\]CQS+#6]_VV\\W_.KWXBI6%+B/E\nM.E/2QJN(B^M]UGIK="JH;8I-1T`;\\D$@WQ0$3V(#S=@PT31,MV*:69->X5@8\nM]*B),,JR7L+\\Y75F]A^F]$+NAL]*#K4H&HFFE5J::40IPGJOPK<F:(^.<FEY\nME=E]US/N^]A^E\\HYQJ8G[KC[=7=&\\Q?F:SLSGA);V3/6;AQ:/E]R\\OBC=%9V\nM,K)C%R9M$,>CQ)'%U34K*QWFUP=T2D4P*3:*R&)-,]8T$\\-(+"35.K&4%&:$\nMS2I02&"M5S,H*ZK2TQG4=`M/OQ96^YZU0<"H$D.@&2DFVRF[)EK$K3'&Q\\<X\nMN18X^^T.O<L+G+NT2'`)8^W6B]2@.S,]EEZRQ[_V)0CN0)7-3+FBSV*^@6U/\nM4;<5D:\\9K&RPT=EB?;,@]PH=9=BD@4T\\8BT2P(?A2;;;+^@L++%Z_BG6EQ<9\nM>$L(GL>*`[32F.\\LK;`Y.$#EH?80:75UAZZ\\(^]7+%Y>1^UNTZJZQ-;2KV)<\nMI5GI.1:6+U,GDW0NGMKUS5-+^Y0VE^P#1S^/B(S:I&&CQ@C&6/KY@.CT&419\nM/`85I=ND,[`!Q",A$(+@10@R_*V+@FJ04^0YG=5E\\JTN(0B/CPIO?,7-'#M^\nMCK,KAYD:;5$XH7!A^WPTW*X5PE0K9B*!<J/+Z8M+/'QQ'O7$&>I\\BUYG%>_.\nM<?G$5NR*?$0IA97@$9$HU*5RA4:2!OVM+4SIL&D#DS2P$D`"(F&+$,Y)"&=%\nMPD41Z039OEP%:5=EL:O(\\[U%WM_CJFI2*6VT%IX\\MU#W7G9S=>.(-!]\\\\%C_\nMUB.'MWKYH#>_UMOT0:HXCHVV<:N1)CMNF&JW.Y<78[.ZR#?/KI(SBL_7\\.7P\nM\\N3+G%!7&HA$!#L\\X(<-D7!6).PDA`0)"@DB(90$OR82GI+@[Y,0[I7@GPS>\nM=4)5U]4@Y_[WW<Y='SE*_K'WH=_UY[;(>R-%WM_MO7L1,*>4DLU>_VQGJ^=N\nM.;3O(YO'3ESW'Y][>KF.DC.^'JPE4O<B'?*QD:;9,3N[:VFE<6M<Y8>>.G-^\nM88D)@$DDQ")!20@B(10B<A&D"Z!&7_46)(3(Q.EN$Z<WF#B;,4EF3-QP-LF6\nM3)Q=T%&Z:.)6'NJ"4W_S._RX^-VWO8M/?/RO^;M/?/KNHBP_^N1WSAT\\L[B^\nME*,N1I'I-B+CVXD='8FC_4;"[*6+%^H+2RMO7SOR:_=%FTLW^'(P[:O<^'+@\nM?#58]%5Q.OAZ`:7\\C_5=Z'^#/_[`AWG3FWZ3K]S[A8.(^OU.=_.>3G=KMJKK\nM./@@(&5=54_V>MV+49R\\7@_Z7]WU]+%W?/3$J>_<#CST`\\;]B0FX@K?_P7LI\nMBMSLF-FU*_AP$TI/]/LYZ^MKB^OKZT_,WGBHOFO?]-_?F(5?.O7/__CT\\7-+\nM[_Z].V[YMS=^^@M<D.>.]Q,7\\*.P\\%?O9V6C^QNS1>>3YT\\\\;KX]?L,3]S]R\nM\\BT[Q]HG/O'0HRQ^3[SYJ;#\\(;CEW".<.?'8<O+D(T=FBHT;S,C8#C4]M_>^\nM!Q_^T@LFQ_*3O?Q9\\<\\[`9V\\Y@UMU[]8\\<2H\\J^9Z*U.J)U[#MC)&?.IQ[_]\nMU9_)8G]Z^ZX.ST,!YVJP*/[D9A:^OJ96)ZE?.^H&B=ISTTLFHV3AD^<N/?:O\nM'_H@*]O]\\+P3`'!\\`'$!1[L\\>6.F6C-NZY59FB0RN^_(Q_[PCQY^W>%#%^X]\nM/T_@>2H`X"M;\\-Z=*ERH.#YJY(4SQ<;!9')FM&Z-'_S\\EQ_X\\HNSN/N$\\\\]?\nM`0"?[<([I]5@H58GV[A7-_OK.\\YY>UT0B?YI;>OH*PVB?_0P/UU\\L0NO'K??\nM.E6H]Y_7C8W](]&9O9&['PA:/0_W@>^'#QYHTQ<=_6Q;OV:/+RZ\\YT3^Q)L3\n>Y!WE3YO9_P'^&ZX+2WXT43Y:`````$E%3D2N0F""\n`\nend\n
105912
 
6557    availability_write_48           begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```*PTE$051H@>V8;8Q<9W7'?\\]S[YV9G9E]F[4=;^QL["3$\nM&+!#&DN.`(4T2MK05OD"K5"J"*$(":E2D2A%02!0O[2BJBHAD*`2;47:2D`+\nMI)&B"HNF!1+L4MMI8LC:7GL3>]>S.SNS.[L[;_<^K_UP[^RN\\0;B-62_^$A7\nM<^=JYMSS?_[GG.?\\'[AI-^VFW;2;=@,FMOI'?Q*`>X#W$>!Q@`-GP3IP+ONT\nMU]X[!]:"L7CO>1XXM^^#6XLCW"H`YT`('HH3_G;J,F@-HK\\</KOWZ5<A!/CT\nMBT#@O2<*)<6\\]][[CP#GMAK'E@%H#6$(\\PWXP<E;><?A!UB9/T>Y7"3,E^@L\nMOL9P90RE>OADA>)@B;C3(A="(&/*I8"<:^),O`[\\K01@#.!!*]BW_^W\\SA_]\nM->=_\\B5&*CLI5-[.I9-?9_RN]]!>;="JGF!DYVTLSD\\3TD$`411BS0K6;#WX\nM7PL`ZP"?$+>KZ*2-BB-$>PZC8SKUEUA=?`W56J#9?8EN)R"?'\\#I.L71.Q!6\nM8C4W4(DW",!GA8F+T9U9C&IC8K!)G:1]A97><;J='H2[D#9&ZP%D('`:K`O!\nM"(QA>U)(:_!!VDV$2U"=*QC5IE/[&:IS`9T,X?(.Z\\`;@12@C4!J@==@;8`W\nM`K/=#%@+^!C5OH3JUA#F$E9WL'888_M`!0)0&F0@\\"9EP-N4@6T!H#6XC`%<\nM0KMV@FYSBK`H,3I=;2,S`%X@Z7>N+(5L@#,B;;]R&P`8D[9VK4'WFK1KBR@5\nMH7,AUH#6`BW3`#T"Z5-0H>G70(`U`KU=-;`QA4S2)NF!UB.8+*\\W,D`?@(8H\nM6B]B8^7V%;$QX&0*P+N,"9,%KD%;@9;I,X1`.E)P1F`U.!=@;<J0W(X4ZK_8\nMV2R5#"B=!F0T&"<P60HA0&8@35:XUH=K;&U;#<A-&#!986HOT"*;D0)!8*YF\nMR+E@#<RV`.@S8&W*@E:@E4B+MP\\`4"IMG4*#4H*<!J/`N3`M8@TRV`8`?0:<\nM$Q2*0^3*!0:#40JE'%$NCY2W4@K+4-#(PJU$MDRH!RF6A_')#DJC>UE=>"5E\nMP&T3`(!00&409.`8*R_CD81Y0<[/XA&4!R3>S^"E8#"_C-<M$(+&I?^AN[*$\nML3<&X)H&E@F5,>_YM!#LP./=1H'2%R8>M[K"X4Z'HU<]SWZG%*_.SO#E("`\\\nM>)`_CR(F^G[ZE_?XD5%^-#+,>>N0=H/@V2!^A&J)>O78>VN[YN;'H]K%9_??\nM/_["%Y^K\\M3<)@Q8"T`)^/`K4TS,SD,0@!02*1Q""`(A$#@0DD!Z!!XA`J2P\nM2"FI#(6$4E5'1_G'`P<HX/GHN4M,G+\\$H00I4U\\@Q$)'OE_,V/>GODC](I'"\nM$PB@,$AC?MCLS0^S<_7ET`J_]ZEGJL?O*6%A$P#]U/`>7CX?<=O!)QG(1[1K\nMI]EY^WTTY\\\\2R82!H5TTJY.4A@:QWA*O+E(J!7B["@%H-8]2"*T!#V>F!/F=\nMCS.V>R]+K_^0L?U':"U=QB=U!L<F:,Z=8Z"40X0A[6:-H7+(@FGS]^IQ3@[L\nM#^];_!Z_NVQ6WA'SSP]5L"L7LA1^(P#.P4`NY."]'R"?BZC]O,'$X4>IY@6!\nM7::\\ZR`B7F!H,$"I#C*1#(1=G'!X\\FG/-]E.["$*!`<./<#XQ&%>-]/L._0(\nMC9E3),N3C-UV!*F7*>9CO#?0E=BBY=4#=S)<NL#>GQN.E]_']XN'DLJ##^R]\nMXV<KN6JEISCQ\\6L!I%M_7\\)Z='<.KT*TZI&T+J-Z3>A-DZR^3&^Y3M!;)8Y;\nM:#^.4'5$6"(JE-+=6*_/3'C0O3IQ:S;S-8/J-DA:518O?IO.8A5R74S2I&-O\nMX<>WEI@M1;3;<_SVQ.T\\^(=Q\\^_TP(F[@\\I'N_KU9T/-_*],(8''Q'6\\#+"F\nM1[=^DD[]-(&M@ZZA5043^G2EO4!*D`BL#;)-;0,`/$XMH;MS6)/06SI#N_93\nM;*^&6:EBDB%L('$63NJ8;\\=@STXRXG9Q>&C4_=<KD\\\\7&X\\%<:/Z-X]_[1/S\nMG[[_(YNGT$8&^@"<D"2=*DO3QXE7+0/%0;Q;'PM,MG$%$B02:X.UX)7*''NP\nMR1*Z6T#W%FE.GZ*[TB'*[T"X;(<V$,<A/ZCOY]5DGDH4<^_N.SD[]4+CU'\\^\nMK(*:>\\Y-?N-[?_F!,R3FZ5]>`_U5L[T%E%K&Q"N8H(6U1;01D*6(#K.=5P@"\nM!X$46!=D$^GZJ`%@U2*]Y@HJ;F*B5:P-P`I<5BM&P7]4'^;"^.=YU\\P)DIE3\nM+!]J85;NHF"'O[4P>?'9TV,/>EW_S%J\\O[2(\\9YX=8I>\\R):ES`^'=B",%55\nM2@M,E,TX2`(!7DJLRU(HJP'GLGFI/</JTBQ:Y3#9G.1E"L`:S^GY0_S#\\%,H\nM<PL'ND<H]F:IY(_BW73M<P]__,7VHP/^#S[;NRK>-P1@'6CMZ#0F44F,$8-H\nMGW46D^I:W1<N&0,A0+#.0+\\+]:?5[M)Y`GIHLR<;M04^$$06+C=&^&KADS1+\nM^WAHOL'=X23O?.=SW#V^AR7SDE<A1*+WB^&^<0TX#]XY5-Q%&XF1`N/3@,-,\nME.@^`YIT=`:P8HT!?14#'A5W"8,T\\+Y:(Q1T6WG^U3S)V5N.\\.[9!@=,E=WF\nMJ^P:K)(38PS()NH-SH]^10JMKZ*1H%VZDJ%)4T@;D5X:="`(O4!$,AV5,UW0\nM9P"_8?2V&]2:E#S3^!`_ONN/V5-M<I]9IMSY=_:/G<68/-:&:+->1V^:`>\\S\nMR9AU$RT%)IO[(YLRT.\\TVH!!H!T(*[`N?:FQK+V\\[\\N1+80$HQTGFD?YSFU_\nM1KZ>\\)ZD3;GY'<:'?XCW$FT$S@=KF^'U,>#7&5`:;)#1GK4[F^E>K5.!8A!H\nM"X%99T";+.@,@"%CP`NL]+R^O)=_&GV2MA[BO?4:M[@7F(C^A5PXO":$G`\\W\nM["77"6!-:2F!C20Z8TAKB569A`S37F^$(+!@7;9JFW0ADTV8!D&]-\\(W"Y]B\nMH?(V]IZ:X4#I"GO\\TPSEE^FH47)2(,D`Z*T`<%`L%BF7=U!P$3[<28X"H2F2\nM+PSB5(62KU#,>T:4PN=VD^-.\\L515+=V51=R#O+Y`@/%G0@1$IG=/#WW""_O\nM^WU*IZH<C99X6^4X]TZ,H_4(-MQ-0?8(H@((G1W-;'[^=2V`M`:\\\\[0&\\ZHM\nM[*(+O<#'"Q@O";U`QR(]K/*7Z+4ES@N\\/T_LTN=Q9SFTCJZV>&/PSM(IYW5'\nM^$6+A1_5CI:^?_L303BUQ%&]ZO;GO]N](_>LZRX&."_Q_@+*"9R7)+W5P%@Z\nMWF]>!=?J@;3:%[SG">=,WEKSBP+C*M%A-WF&0'A8QJ&=PSC/GSAKRWG?-5\\Y\nM\\_A#Q][UB2_HAAZX?[G)#M\\X%G1?_"NAFJK3OMI7%HOPT,&SLAF`&SA2NCX3\nM[_X642_>IQZ[[YO!6/'HD8MSW*T67CUYXN2'1RN[SOSD^#>`T]?M=\\N:^'KL\nML0\\]@;MG#^/ZXA/_-W#EZ-*DYW83+TY/7_C,QS[VIV<^^:E'@9>VY/LM`5`N\nM#Q%>_K=H<-?X;SVB%FF.V"O/'[O\\%^<F+SSWOZ=>9*O!`]S`D=*;MSA1M%J=\nMT7:KM<_HY%@HZQ\\\\=^'+7W_X]Q:L4L_<D.\\;.%)Z\\U9?F./R:^='M=)S0H9?\nK+)9'IG[ZPG\\S/37W5KS^UV8!OX$%^W]"3#QJ\\21!]0````!)14Y$KD)@@H9?\n`\nend\n
105913
 
6607    order_search_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```0C4E$051H@>V9:8PEUU7'?_=6U:NWK]T]O4S/]&SVC)UX\nML"4GD`1%(;%C)R`%L@F2*"#$$D4("80$?$!*!)&"!)'"MX0/@)`04@((R&9C\nM0SP0X\\0Q\\<QX/)ZU9SS3/;V]?:FJN_&AJA<OB13/?$'B2J4ZM;[SO^=__N?<\nM5_!_?(@?]X$O/+&.@`7KW))S..O`.G#.D=H."SC+SK%SKV,#SJ;/&&,8#OL,\nM^EV&_1ZC0;<W[/<OE5O3\\:G/?_A'^N._$<0"/BR$^!/KG'4`.!S@MN]P+K/)\nMKKZ.[79M(25A6$#E%2I1))/1J%#(_\\>M:U?^TKO_8T^5JLVD_^V_N#,`I`0<\nM0>B)XE(S)/#`6##.8:W#.+"6/;;#.(>Q670<F&SF[2N>"TA:.2;C(OUNOOSR\nMZMI'PV+E$:W5WVRNK7Q^YM$_N+G^[2_#>/,V`0B!`_*^X,&E(K6BC[$.;1W&\nMI/M$&;1Q&)LZOFMG]UEVCHTE.^<P-H<V1:*XRG=MQ/[R0JU0*/[6Y5QX?&MC\nM]5,+[_GTY9O__*?`Y'8`I*&74B`%///T%5Y^N8M%HHT/(L?;WC%/J1K048Z)\nM=BB3;MI8E'$DQJ&T0YO=:XG9<YP8>LKPP&R>V>FW4"I7'KIRZ?R?]SI;OW+B\nMXW_<?O%O?_<.`!`I/9[\\MY=H356XMASQQ%-;W!I[_/U?M[BK&;*J#>W($FM'\nME%@B;8F4(U*66%DFRA&KW7/1MITH;%_P4$$QG7/PIF.4*Y7WKZ_=^G@^'WYQ\nM\\8^^QF.???\\;!2!V``C`461US><;3X\\Y-\\S1N+N!7PX(/$$82$(#"(MS,DUT\nME]H`UEEP$D=VW4&J80&3VCZ^_)WK5/6`N_:UJ$C?\\^?F?BE7*/_MK+/MQ]YH\nM!#R9RJ`4`B$$*YV`KYQ:HUT(X605<7<3OYPCD(*\\+\\GG'`()6!`R>\\L>6VS;\nMV5ZDUUVIS$CFF"YH'CC1X@=7-UE?Z1P.HF@1:&_[\\X8H!"!$JDB]6I'V_CH<\nM;L#^*ARNX9>V(R#(V]0YATR+`WM`9)$0;$<ENY[IJW4Y"N4B^3"@6F]0&(I0\nM)5%!["E?;XA"`I=22`@^_O-+//`NC:R%N$I(L1RP4!+D?#A0@.E`IDFJTTUE\nMB:QTELP[MD5IMR?)+8EQE'Q)SI<$OD>Y7,':(MP>@.TD%@@!#Y_(\\S-&9[.6\nMX%R"F3AZSN$C*#J',:"MS>0TU7XCT_J@<1@!QG,8/U6B[;IAK$-(#]_S\\:3`\nMDQ+/DZ_PY\\>OQ`(@E5!K+!>WUDCR);0AFSU+H@S]=H>@TLAD$D;]'AH/Z^=W\nM9C_N=U%>B"9(HZ,->M0E#JHD&F)M.5'1/'S?$EY&V5>/'S^)A<")-`+@P/,)\nM*E4P8+1#:(N+-2J8(/)EE(;8."9>C,;'^D5B9XEQ3!BC*)*('#$6Y0Q*CYG(\nM(HEQC+5E48_PI<"3(OO-VP0@)3C'3@[(R1B_O4D\\&%`K5;"`UH:<&5)S>9P$\nM*V&0C_`\\CWQ1HG1*D38*@@B\\K,AIP[B@*%05V@J4MA2LP_<$GB=V!.3V`&1U\nM0(BT`RWZ`=5B`3L:,ETI(H1`:T.H)DPWRP`(!!VI"0*?4KF"L1;K8%W&A(4B\nM?A"F55AKML*$:J.*L0)C'8.>3?DO,@"O`G%;K00(G',XY^AHR_I0H2W$B:;3\nM3@C-9*=5&'9':.%!8$FT)3$PZ?;1OD*+7'I.&=2@3Y+S2$Q:G>^O)WQDO\\23\nMN\\)Q^P!$JN9"@+&6)$E`:WRCD!:PAM!IBBBT`",!SZ0J[QNT<&@/1CF+"RQ6\nM9M(:.";*X0HIZ%@Y:B'XGL#/>J_;!R!%F@.9(N2"@%*IQ+[RF'U3-804&&/8\nM##2SLRT`A)"T.SZ![U.I5'#.(85@?<.G4BX3YO-HZU!*L[8>T&S-8!P8XUC?\nMW,239!'@#E(HFXHXCAD,!JSUAVQY(=:!4H;.5I>KB9_I.0QZ79`^7CC&&(MQ\nM,.AL(<,!>"':6!)M&'?;R))"&4BTY4!!\\=ZY^52%7B>+;ZL;%4`NEZ-<*B'S\nM(\\9!`6T@-HJ^R!&[@,1";`1#':"=AW,^B4JK[&3D86.)$H)(R;06]`7Q1)!H\nMF"0"?P9R=Y1">U2(+`?B)*'D-(N!1882$TK:B<?45"Y=*P/=?(#G^93*^;0+\nM1=#9FE"I5,B%85JIM:6]I6BV&AB7+H2B83^KPN(.)W'V(F,T6BDF2M&.$@"4\nM-G3',688I8MXH#>*<4*34UXFHX)!=T(A\\?`"G:W<#-WVA!4UPEA0VE+W%,=]\nMN9,#=RZ)A<@H%%*N5+##,5NY(LH((JWIF!'K<6ZGB1OV/93PL1./1(F46CT/\nM+2'&4I`6904;ZX8H3&5V%&G>/6=XCY_V07>(0G(WB85`*<UP.":($YHF!@3*\nM-W1RAD919XL4Z$N'D)9\\$9R3K&UL\\.S99RF4:^0+!5:N7&!Q_Q(+TJ"2FTPF\nM$TX</\\[!J3)2"GSO1]0!]QS;/7@5J#F[YW^=;.],N@]NE,WS,T_4G9B'*"1P\nM:Q2\\*E6_S520MA=&&\\*P3:U0P\\@2(`A4B!\\$E,H%)J,A7_W:/S"8)+SYOI/\\\nMSS.G.'OV+'>]Z2<HA3YW'SO"ULV+O+!VD7L^],%LX@12OD9%LPBX;*TA^`2.\nMWR/M:-G9+-ER$"*).[+YP886==0:>).8GK9(8VE?E!EHA]6&,W._SVKCDRAC\nM&'8CE(D8W#C-:&69%R]=Y]CA)4Z_<(ZGG_X.LW-SU!M-5E=NP*5+A$&.TR]=\nM1'SS%%O],:9Q5Q8!]UH`UJ0S+02-1''PZ_\\)PU%6/*2'YUDD#B$DOB<0H@NN\nMA^\\)I+0(P),^4FB$@$:]1"T_HN@&-*3".$,@%1<N7*#S\\E4\\SZ=8J?*]Y]+0\nM'SJPP$/O?81:H\\5WHR'/??][(`3[YO8S'$_XQA.GF#XR(+]PDK0'<*\\$8'1:\nM;*2$T1C.+^=YZ-%?)5>HLWK^F\\P>O!<O5V'MZC,TFBV"8IWVK4N$GJ98;3+L\nM;V&3">5*@([;%,H-='R!@]4";UZ:PI..*U?'G%];1CB7RJ\\Q-%I3+,PO4"B4\nMN')]!7/E.M+S.;ATB&O7EM,6A92Z[>LOTJKNI]R<P^CDE0#T'@#&0*64XZ[[\nM/TA86<!TSK!T_)WXI47TZ";3^PY2:-T%1N.;-N6I17"*9*@HY-*%BN?GT&.X\nMV)[0N[H)5G/US'F0DO&H3Y+$:*4IEJJTNWURHXB3]QQC/!ZS?.,6N7R)1FN&\nM*)K0WKA%H5!DNBD9KEZBW)Q[15N=1L"D`)Q+;2D<R60=(4#KA&2RB7$2HR+4\nM9`.SUF'2N4#``#UXEM$P1OBSC)(;&"O)5Q<Q1J`L1$XR&B=<O'@9U=V@X$L:\nM]2*>C5B^?IV#2X>8F9FF7J\\SBA3-1IU;JRMT-FYQ^-!!]C7+Q(FBO;4)PP11\nM;+P6P*LC((7%Q%LH`=8DF+B+-3$Z[C%<.X^);S(9>,A2`^P`K24(@42D_W=:\nM'Z7A:*W(U-$I7KJPR>/7+V.,IEJI4*O7.7)T"L\\+6%Z^ROSL#"MK&]0;#?J]\nM-I<OO<3QNX]SY.A1XBBB-UAC,!@0ZRW_YLV;Q;U*)+<!:)/M=1H!'6VA)FL8\nMK8AZ%VE?^CNBWF6,&F&UPEJ154]0&K06Z3L,6.=CC"`(`@JAS[GS%VAWN\\BP\nMS#`VG#Y[CFZGPZ%#AVFVILC[\\.N?^"@?^X7WT2CGF9_?S]%CQ^CW>CQ_^BR]\nM48S,E8BC27&PN?+.A]]^/P^\\_5V[`,P>YVU&(1-OH2?K&!TQ6'F2J/,BUABL\nM$UF9SYS6H-4>6XL,`#@GB!/#J5/_1:TUR\\*!0Q1+%02",V?.L+:^QN*!`R0:\nM*N4BI4(>9>#@TB$VUC<X_?SS.&?(%XK,+2[1W+=`O]=YUV<^^YG2H--^902,\nMSH"8](\\F';69=,^CH@Y6QZG31NQQ-'76Z-T(;MO6!2D0"YXGV3<W3ZE<P3E+\nMDL04"R&><)P^?8:-]0VJM1J>YR$]CVJMSM;F)J?/G$$X0ZE8($EBK#442V5:\nM^^9':S>OZT&_^_H4,@8\\`<GH!H.5IU#Q&&-V'34F!:"TR`"EMC9RYWGG?+1)\nM1:$_&#&.#7X08*VC6,BS='"11JU*K].FVVW3JE<(`A_?\\SAY[W'Z_1[=3IMZ\nMM<+AI8.42T6LM7B>3W-JYM![/O"+LR??^M.OHT(BM<$PVCQ#,MY$F874V;V4\nMT2F%C!:X[;S1`NW`.($ES0$0_.#,"UR]=HUZK88)),XH>KV8>JW*!W[N4=[W\nMZ",,^SV,L4PF$Z:;-3[]:Y_D7_[U:\\31A%ZOG[8UR00UF:"2Y)CO!^^M5&M?\nMNN>!G]P3`;T;`:PF'FWMS*[)Z*$,:+.'0GMHLWW>:'`NP!C!<#3A\\2>>)!\\(\nMYO;-,EV?8G9V'N'GN+&RRMO>^B`GW_PFK+5<OWZ=IYYZBGJ]SL'%_;SS'3_%\nMRNHZ1OK,S2XPW9AF=F:&:BDG)X/NAY[_WG^7/<_/9-1D\\IG)*`ZTRKZ>[)GQ\nM5&GV\\#Z+@-+@&9$I4*I"SDK.G#G'C94&,FKQW%>[V-$(5QS0O,=2;NYC?;.-\nMYWF4RV7.GS_/S,P,@\\&`^?EYE'&46S-T;RDN/WD#.:[A%2VM>^LTFZVWOGSU\nMPH.^M/^^F\\1[<F`;U*ZZ[,ZZR>BD,C"[D=M5(4=:!YYY[BS]+<N+CZVCEZ<H\nM=4^@KDYQ[K$5-E>[^/D2`(U&@_ONNX]ZO<[,S`RU6@T_7Z:]UN?L8]>)K]0I\nM=4]@K\\UR_EN;V*A0G9G?__X7?O#L;B'+FCF,SB*0T4%G,ZM?;6=.;^<`1N!E\nMB>OPB6+HC/.L7%Y!,LW"T1K50IGBJ$9[V7'YS"76-S8`.'+D"$HIQN,QM5H-\nM@(W-32Z=O4!H]C-_I,Y,N<PH47278>7R*K6#]7N$$/D=`,YE`#(*F8SCR@B,\nM?KV93@')[#Z,P-<B73L0X)Q$"D=D>APX-,V1MW@4\\A&-48X5*]A83;\\);X\\@\nM"*C5:NEZ&Q@.^HRC+K/[%SGZ8)YZ)2+1@@U/<*77`YJ)[_MV1X5V(I`!4/I5\nM_%<9;;3(J)5N0H-2($QZW@F1BIN#Z7J.<BM/+#;)[QNP>*#.Q8M=HMP6M>D2\nMN<HT%S<4QI@L<NF'<"$]1*%%I54B"=O(1H?%$W.LKFX1A>N4F@'19/S]G_WH\nM+R>OH9#6(&6`\\')(P+,EI&^0.4-`%2^7PPO[!*9*4&@BQ(`0GUQYBGS80\\@`\nM/ZR@C6"N&7Q'>.P/:^&!YZ^>Y>;@%IL;FQ1;>;9&^GQS[M#7-P;::&-VOB%;\nM!T)8*C-+TCG[2+%9O/?BZF7Z=D2GVR77##"WU+5AI_]/PT%_5X6<26/G+.R;\nMKE`L-7#.HXJ/+ULXUZ)&B.\\%N$:%I@N07@BNSC0^PBL@J2%D0'_C`O$DHJB>\nM_,JUJ_=>C::K?]:HE0\\[IQA/NN["BV=/KZ^M_O9O?N3=WZXUI[EU8YF](Q?F\nM"?,%M%;_.![VOEBKEN^WM(318VY>O[+<;K?_<!0G9XLY/UUB/O[Y'0"?<H[?\nM<0Z3?FW/UL9[U\\=9V[UMO_IX^WX'TCD^=\\\\\\?_6^+S1/>%(^+(2;'HW&-^)H\nM\\DU@64B)LY8?-M*/6>Y`+LP_4BJ5%AUL&>,>SX7!.:.-Z[8W4P#?^MQ.$I>L\nHI?0:I]Z@#0R!\\6]\\Z8?Z^/_C?P$6V;R).I+A9`````!)14Y$KD)@@MQ.\n`\nend\n
105914
 
6608    order_write_48          begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```.Z$E$051H@=69::Q=5W7'?VOO,]SY^;[!0VS'CA.,(P(D\nMII`RB1(2:$I5BA"@ME2H:C^T0OT`J!65`*ET4*E*D>!#I4*A!3X442I`A:0A\nM`P14(!!*%-+82<B`X^$]OSN\\.Y^SIWXXY[[WXMA1L*U*W=+16>?L<^Y=_[W^\nM:]H'_I\\/^45?^/A=:PCL]2$<#('@`_@`(00*.>"!X-F\\#N$\\,A!\\\\8YSCM%H\nMP'#09S388#SL;XP&@\\<:2RO9=S[Z]N?4)[H8Q`)O%Y&_\\B'X`$`@`&'^1`BE\nM3#E['CELR:(4:5K%5`PF-^33\\;A:K7SKS%./?UK?\\#OWUEN+^>#;G[P\\`)0"\nM`G&JI79P,276X#RX$/`^X`)XSS8YX$+`^=(Z`5RY\\OX9[\\7D2PG328U!O](X\nM<7KUG6FM^:O6FL^MKY[ZZ,Y;_^SDVK<_!9/U2P0@0@`JD?#R@S46:A'.!ZP/\nM.%><<^.P+N!\\H?B67#[GV;QVGO)>P/D$ZVK,LA;W^1G[&GL7JM7:'_\\L28]T\nMSI[^H[TWO^=G)[_VM\\#T4@`4IE=*4`(_^-[CG#C1QZ.P+@))>-5KKJ#>BNF9\nMP-0&C"L.ZSS&!7(7,#9@W=9<[K9=YXX-XSBZN\\+NE5=0;S1O>?RQ8W^_T>O\\\nMWK7O^LONPU]X_V4`(`4][K[S.$O+39YZ<L9=]W8X,]%\\\\5^6.+R8<MHZNC-/\nM9@.SW#.SGID)S(PG,YZI"61FZ]YL+N<&/Q!NJ1I6D@#7O8!&L_GFM=4S[ZI4\nMTD_L__#7N>,C;[Y8`+()0(!`C=.K$;=];\\+_C!+:+VP3-6)B+:2Q(G6`>$)0\nMA:.'0@;PP4-0!,KY`$4,BYDN[.)3__5S6G;(X5U+-%6DHSU[?CNI-KZP._CN\nM'1=K`:V*,*A$$!%.]6+^[3NK=*LIO+2%O'"1J)$0*Z$2*2I)0%"`!U'EKVR3\nM92Z79RGF0[W!6"6L5"U'KUWB)T^LLW:J=RB>S?8#W;D^%T4A`)$B(FTLU.CN\nMVP&'VK"O!8<6B.IS"P@57R@74$5R8!N(TA+"W"KE?!E??4BH-FI4TIC6CC;5\nMD:0FGU5E6_JZ*`H)H:"0".]ZZT&.OMZB%E)",Z76B-E;%Y((KJS"2JP*)[7%\nM84I'-K9TYDW98VS8YN2>W`7JD2*)%'&D:32:>%^#2P,P=V)!!-YX;86;G"U7\nM+2>$'#<-;(1`A%`+`>?`>E^&TR+V.U7D!TO`"3@=<%$1B>9YP_F`*$VD([02\nMM%)HK9ZASR^>B06@"*'>>1[MK))7ZEA'N7J>W#@&W1YQLUV&21@/-K!H?%39\nM7/ULT,?H%$M<6,<Z[+A/%K?(+636<VW3\\L:7'$27E#UW_.).+$*0P@(00$?$\nMS18X<#8@UA,RBXFG2*6!L9"YP%1G6")\\5",+GHS`E`F&&KDD9'A,<!@[8:IJ\nMY"XPL9[]=DRD!*VD_,]+!*`4A,"F#ZCIA*B[3C8<LE!OX@%K'8D;L1`J!`5>\nMP;`R0VM-I:8PMJ!(%P/Q#'29Y*QC4C546P;K!6,]51^(M*"U;`:02P-0Y@&1\nMH@*M13&M6A4_'K'2K"$B6.M(S925Q08`@M!3ECB.J#>:.._Q`=941EJM$<5I\nMD86MI9/FM-HMG!><#PPW?,%_*0&<`^*22@D00@B$$.A9S]K(8#UDN:77S4G=\nM=+-4&/7'6-$0>W+KR1U,^P-L9+"2%/>,PPP'Y(DF=T5VOF%'SCOV*;3:"AR7\nM#D"*:"X"SGOR/`=KB9Q!><`[TF"I8;`"3@':%5$^<E@)6`WCQ!-BCU=E:(T#\nM4Q,(U0)T9@(+*41:B,K:Z](!*"E\\H(P(21Q3K]?9U9BP:WD!48)SCO78LGOW\nM$@`BBFXO(HXBFLTF(024"&MG(YJ-!FFE@O4!8RRK:S&+2SMQ`9P+K*VOHQ6E\nM!;B,%"J7(LLRAL,AJX,1'9WB`QCCZ'7Z/)%'93R'X48?5(1.)SCG<0&&O0XJ\nM'8).L<Z36\\>DWT75#<9!;CU75@UOVG-%$87.X\\675(T*D"0)C7H=51DSB:M8\nM!YDS#"0A"S&YA\\P)(QMC@R:$B-P4678ZUOA,8428&57D@H&0387<PC07HIV0\nM7%8*;8M"E#Z0Y3GU8-D?>U2J<*FBFVN6EY.B5P;ZE1BM(^J-2E&%(O0Z4YK-\nM)DF:%IG:>KH=P^)2&Q>*1F@V&I196"ZS$Y<_Y)S%&L/4&+JS'`!C'?U)AAO-\nMBB8>V!AG!+$D1I=A5!CVIU1SC8XM/A3YH]>=<LJ,<1Z,]>S0AB.1VO2!R^?$\nM(B6%4AK-)GXTH9/4,$Z864O/C5G+DLTB;C30&(GP4TUNI&AR^F"TPX@CLY[<\nM>.S`,DEL0;'<<_,5CIMCA8YT@4!'12:]>`NH+2<6P1C+:#0ASG(6708()G+T\nM$D>[9LLF!08J(,I3J8'W0D#H-S5I-29*$GP(..?9Z*8TVQ5"*!)9-4P)LRGM\nMGWR35SQP?UH_\\>"AREO>]WW9`Q\\X70((/V9>@[>`A>"W[>N4Y^"*<_QTPSVP\nM\\ZX=0:Z`64H<5JGJ%JVHRW)<E!?..M*TRT)U`:?J@!";%!W'-.I5?`B("*F=\nM4*]72=.4`#CGZ88)2\\O%.R$(I]>FW'?/5UBXY]\\Y?/_MJ<VFO_XWW_S:%X]6\nM<5L6"&6O(?PN@3^AJ&C9/#QE.P@S1;AZ_6UM*SLPJZ"G&1O6HYRG^Z@J00>\\\nM=3RXYP.<;K\\;XQRCW@PKAA!31B&8]H?8R&YE8NLP@QYY"L8)CE6>RDZSFDVY\nM877(K;-*?KB^ZRMO>/FR&][VHRT*>5>LM`CMW'#@&]^%T;A,'DJCM4<1$%%$\nM6A#I0]@@TH)2'@&TBE!B$8'VCCH+E3&U,*2M#"XXDL@2)*`3B]%%,3?*'))X\nM@BYZ!>M@2D#7A*[KTMOW59JMQXD>NHKO-5_+O:T;V?/J7[DR^?+#\\?`5?V#X\nM_A\\6`)PMDHU2,)[`L2<KW'+K[Y-4=W#ZV.WL/O`B=-)D]8D?T%Y<(J[MH'OF\nM,5)MJ;46&0TZ^'Q*HQECLR[51AN;/<*!5I47'UQ&B:?7U<1Q7&1B"@JMK6GJ\nM]3K5:A41P3O'V;,I2SL7^<RI+]&3_V8XFO+Z*P]PTSL#]_S@2%+M5G]KM&@_\nM/YWZU4T+V&T`G(-F/>'P#6\\C;>[%]1[DX)'7$=7W8\\<G6=EU@.K287"6R'5I\nM+.^'8,A'AFI2-"HZ2K`3>+0[9>.)=8*W#/M]@HK0Z;A8;0^C7@<7UP@J@1"P\nMSI$-^JQ5OL4W_3_A=,8.OXOK%Q9Y_&R=I'^ET6L;GWCW/[QW];VO>O<6A9PK\nM`(10R$H"^70-$;`V)Y^NXX+"F1EF>A:WVF/:>X28(7;X(\\:C#(EV,\\Z?QGE%\nMI;4?YP3C8>8%XQ0S(G*O";F0;W9OFB!@"9N=VW0$7W_X"7X6C5E,'-?O>0&=\nM::#WU%&NV;<TO?XW#A^?G3U%9C_'!2V@Q..R#D;`NQR7]?$NPV8;C%:/X;*3\nM3(<:56^#'V*M`A$44NQW^@ACX9H=-1:O7B)X0P@[<'X>C(O-7V$9O:U/%.#3\nMMVM<[2U<]^0"V8G[,3<=8MJ\\E1M?M(?V[BJBA.3</&`MN`#*%[*2@)UU(%B<\nM-<PV'F7:>XC91H=*,^"MP?NB4`L.C"W"IY9YV(UP3HBCF'HU`9+GE6.^\\^,.\nM'SL1,<A:O'!\\E"MW7L7BSA=SH%KAZ$O:/'AJ5B(]9U>BV#4HMPM+"KFL`S[#\nMV1G#4W=C9UV\\6\\('7:9YL%90#JS9#D!*``68YSN>/#'F3[_;Y[01;EKO\\;*]\nMPMO>>I0#AU:(5<S#G;S8VC]?*3&G4%!@7;'19&==\\O'3F%D/K[)":2=8*SA;\nMO&.MH%TABRY^K-A&C[%6MF?\\YQS#0<:';E_E^S;B^M4.UT437G1$L;04J"90\nMJ\\5(UZ#4L]J!9U/(.=`"^?AIIMV?8K(8EVXI[9Q@+1@K&">$4E:1PFY^K8FP\nMS],"X]&$#WW^(?[5[&3OJ3XO<P-V[QSRRZ^\\CI65G21)03\\EQ8[(N0@4E%'(\nMEH<#<(S7'V0V.HMQ4BA;KK@M@1@+;O/^UIRQ@J?P`?\\\\+'#[#S?X[*1-?&;$\nMJ[,1^Q;&O/%-5Z.4<.;,&5RA4+&5N>UXM@5*'W`.\\)9LW,&Y0J$Y0./`NBT0\nMUH$N9>4$.Z^;0HRS97GR'..!8WT^^,"$P=CSRK4N!U9&O/T=+R9)9C0:#9:6\nMEI"2],*\\@'RF$0H`K@R?91@E@#7EUY-M*VZM8-TS?2"4<]I)09M01"'KY#DI\nMM+8VY0-W=3B6*_8=.\\E+5Z:\\]C5+:#UF:6D7[79[4_GM%C@_`#O_KC6G4`EJ\nMDQI;JSZGC2G!A/(^I65\\$`)E%+H`A;*IY:__<Y7;\\XCZ`R=Y967&K;?LY<B1\nMA,7%)187%Y_UCHAL;B1<$(!(H31AKFQ)&3>GS#:Y=.CM`+0KJU<BG)7S4\\@'\nM_OF>5?ZQ`]$C'6ZT0][T^F5NNNEJO#>T6JWS@IY3Z()1*(020$DA5W+<.,%M\nMM\\`S?$!0Y7,X(;*%XP;B"U+HGA]W^,CQC-G:C!O[?=[PTAIO^<TC-!I5H,KY\nMC#:/_Q?<5IDGG>T`MJ)+*9N2-E:P9FM.+!@#XHK[001*"JT-+7K=$7Q19I\\Z\nM/>']W]W@=";\\TGJ/&_?##:^[BJZ/.'MZ1F#K0_B\\_RC.@=[$H2^TK;*=0M:"\nM4C&B$Q2@?1T5.53BB&FADP2=#HA=B[BZB,B0E(BDL4PEW4!43)0V<4ZQ?NKX\nM/7K,?<%:I96$'_[TX9OU='STT''/52[K[%AN?VGABO;@S(:1^3=D7S91\\^NY\nM7&XHSP*<.M<ZW/UW14V#\\$'O^0LCB]3J;4+06"I$92-O28ET3/`>%V*43B%X\nM/!&BJR@<HF*\\MSS]T&U88]XGPL?OG+R'2$?QRNXKOI@F\\5O[77?R[CM^_N?'\nM'W[D,TE2<7G^U?/R_OF,30J5`#HA\\)@*73?I=?'SWGA[?UR6W7/YW.OY\\P%4\nM"/0`LBQG%O)V=3B\\*FK5[XA4[\\/''_OD?3?_VLO"G=^X_Z*5WP3@R^@A\\#GO\nM^?*SE'H.>7Z]*9>\\+1UX!'#O7?\\!D%QS^+J/'3ST@MN65W9V,'"IRO]?#UT>\n8EW7\\+Y^L^Y,,G%8,`````$E%3D2N0F""\n`\nend\n
105915
 
6609    order_zoom_48           begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```/,DE$051H@=69:XPDUU7'?_=655>_>WIF9W>\\N[->>[T;\nM;^*LX\\1V(I.0$)P0)S$(HA#))""43[R$$$2`!'P(("5\\(`&D\\"$AB,@"@@(2\nM!F++X$#B$">VXZSCU^YZO6OO>V9GNJ>?U57W<?A0-3VS#R^)=S_`E4I]JJNZ\nM^O[O^9__.:<N_#\\?ZH?]P6<>64;!#B^R6P3Q`EY`1,AMP0/BF9Z+7,8&Q.>_\nM<<XQ'/89]-<8]GN,!FN]8;]_M#XWGS[ZZ0]?<3[A:T&LX,-*J3_V(EX`$`20\nM]3M$"IOBZF5LV;"5UL1Q!5,VF,R0):-1I5+^KW.O'/M"<-O/?:/6G,WZ7_^+\nM:P-`:T"(XD!5=\\_&1`$X#TX$[P4GX#V;;,&)X'SA'0%7K+R_X'<1V5R)9%RE\nMOU:NGSR[])&XVGB?M>9+*TMG/KWUGM\\]O?SUS\\-XY2H!*(4`Y5!QQ^XJK6J(\nM\\X+U@G/Y9V8<U@G.YQ/?L(O[/--SYRF^$YPO85V52=KD<3]A9WU'JU*I_MI+\nMI?CFU?-G?VG'W;_RTND'_@1(K@9`[GJM%5K!=QX[QLF3:W@TUH6@2MSU]NW4\nMFA%=(R16,"X_K/,8)V1.,%:P;N-:YC:=9XZ><;QYH<S"_)W4ZHWW'#MZZ$][\nMW=5?W/_1/^J\\</]O7@,`*J?'U_[C,'-;&KSR\\H1'OK'*N7'`E_]FCGVS,6>M\nMHS/QI%:89)Z)]4R,,#&>U'@2(Z1FX[O)NIT9?%_QGHIAOB1PRU[JC<8'EI?.\nM?;1<CO]\\\\0_^C8<_^8'7"D!-`2A`J')V*>3!Q\\8\\/RS1?EV;L!X1!8HXTL0.\nM4!X1G0>ZY#:`%P^B$8KK`KF&122M;7S^6R=HV@'[MLW1T&$07G?=?:5*_?X%\nM\\9V'7ZL'`IW+H%8*I11GNA%?>72)3B6&6YNHU\\T2UDM$6E$.->62H-"`!Z6+\nMIVRRU;I=?*K\\NM3JC'2)^8KES?OG.'A\\A>4SW1NCR601Z*S/YS51"$"I7)%Z\nMK2J=G3-P8QMV-N'&%F%MW0.*LL\\G)^@\\.;`)1.$)Q;I7BNN%OGHI4:E7*<<1\nMS9DVE:&*33:IJ$WIZS512"$YA93BHS^]FS?_F$6W8J014ZU'[*@I2B'LJL!\\\nMI/,@M?EABD`VM@CFJ>TQ5C8%N2=S0BW4E$)-%`;4ZPV\\K\\+5`5@/8H52\\-[]\nM9=[M;+%J&2(9+A%Z(H0HJB(X!];[0DYS[7<ZSP\\6P2EP@>#"7(G6\\X;S@M(!\nM81`2:$6@-4&@+YC/#Y^)%4`NH=YY7EQ=(BO7L(YB]3R9<?0[7:)&NY!)&/5[\nM6`)\\6)ZN?MI?PP0QEBCWCG78T1IIU"2SD%K/_H;EO0=V$Q24O7C\\\\$&L%*)R\nM#X!`$!(UFN#`64%9CZ06$R6H<AUC(75"$J180GQ8)15/BI`PQE`E4R52/$8<\nMQHY)=)7,"6/K6;0C0JT(M"K^\\RH!:`TB3&-`)V/"S@KI8$"KUL`#UCI*;DA+\nMRH@&KV%0GA`$`>6JQMB<(AT,1!,(BB1G'>.*H=(T6*\\PUE/Q0A@H@D!-!>3J\nM`!1Y0*F\\`JV&$<UJ!3\\:,M^HHI3"6D=L$N9GZP`H%%UMB:*06KV!\\QXOL*Q3\nMXDJ5,(KS+&PMJW%&L]W$>87SPJ#G<_ZK`L!%(*ZJE`"%B"`B=*UG>6BP'M+,\nMTNUDQ"Z9E@K#M1%6!1!Y,NO)'"1K?6QHL*J4?V<<9M`G*P5D+L_.M\\UD_.Q.\nM3:`WA./J`:A<S94"YSU9EH&UA,Z@/>`=L5BJ&*P"IX'`Y2H?.JP2;`"CDD<B\nMC]>%M$9"8@2IY*!3([1B"`-%6-1>5P]`JSP&"D4H11&U6HUM]3';MK106N&<\nM8R6R+"S,`:"4IM,-B<*01J.!B*"58OE\\2*->)RZ7L5XPQK*T'#$[MQ4GX)RP\nMO+)"H"D\\P#6D4+$4:9HR&`Q8Z@]9#6*\\@#&.[NH:Q[.PT',8]-9`AP3Q&.<\\\nM3F#0747'`PABK/-DUC%>ZZ!K!N,@LYY=%<-/7+<]5Z'+1/%55:,**)5*U&LU\nM='G$.*I@':3.T%<E4HG(/*1.,;015@)$0C*39]ED%.!3C5&*B=%Y+N@KTD21\nM64@R1;@52M>40IM4B"(&TBRC)I;%R*-CC8LUG2Q@RY92WBL#:^6((`BIU<MY\nM%8JBNYK0:#8HE>(\\4UM/9]4P.]?&2=X(38;](@NK:QS$Q8.<LUAC2(RA,\\D`\nM,-:Q-DYQPTG>Q`.]48HH2V0"G,^;^^':F&H*091B16$]=%<3SI@1SH.QGIG`\nM<'.HIS%P[8)8J8)",?5&`S\\<LUJJ8IQB8BU=-V(Y+4V+N&$_P*@0)A&!38E&\nM'<S*69+A,&]D"!E%+?K$C*HM4BN,4\\?=VQUWAWD==(THI#>"6"F,L0R'8Z(T\nM8]:E@,*$CF[)T:[:HDF!OA:,S>B-SW'VQ"L<.7*4SB!!1Q&A5O@T04Q*K=)D\nMWTW[N./V`T1AF;(;H[4B#*Z0!^0IUFOP)M`2O^F]3O$I+O^,3M7=TUL?F1&U\nM'28QD2Q1"9HTPPY;HKR\\<-81QQU:E19.UP!%V5?I]88\\^?WO\\\\1+Y]C[Q@/L\nMW;%`K5K!BC`>)RR?/,&QI[_+J6>?9/_6,K??>0?)R.:]AU)H?8F*%AZ0HM=0\nM?`SA$^05+=/#4[2#,-'(GI4/M:V:P2Q!D*3TK$<[3^=%78`6O'4\\<]WO<+;]\nM"QAK:9N$8T\\=Y)LO][CG@_>R?7Z&WGC"R;YA)?%X*:.VWDSC]EGZ+SS%@__^\nM*'_W_(2[;KV)F_<4#=2K4<B[?*65HIT9KO_J-V$X*I*'#@@"CT902A,&"J76\nM0'J$@4)KCP("':)5OEKMF1JM\\HBJ#&AK@]<&V^ORV.'3_.1/W<N^'7.L)1FC\nM\\9@L=<Q7(J(@Y[@M-7&MM['TY-<9GS]"BQWDU=05*.1LGFRTAM$8#KU<YCWW\nM?)Q298:SAQYBX?HW$)0:+!W_#NW9.:+J#)US1XD#2[4YR["_BL\\2ZHT(FW:H\nMU-O8]`C7-RL<N&$+W5Z??_CV<>86K^?6&[:19(96)6)0#EAH5YEK5*C'$7&H\nM&`T'-)LS_+?MHI[\\+CO#(13]]ZMZP&X"X!PT:B7VW?8AXL8.7/<9=M_\\3L+:\nM(G9TFOEMUU.9VP?.$KH.]2V+((9L:*B4\\D8E"$O8,;S82>@=6Z5N1YQ>[M+:\nMM9]1:AE,#*D33JQ-D(&CW'.4BD[+C`=$5<](-:C6&[QT:JD0CRMYP.4`1');\nM*R%+EE$*K,W(DA6<:)R98)+SN*4N2?<($0/LX$E&PQ05+C#*3N&\\IMQ<Q#F%\nM\\9!X16@<D\\Q003,VCM0)F1=T$#(1C?8*4\\2;M8K`:E18IC73`AUN4$C_@![0\nMRN/258P"[S)<NH9W*3;M,5PZA$M/DPP"=*T-?H"U^9,U*G_?Z4.,A9MFJMRY\nM9XZS2XYZ'-+O]U`(]9(FT(IVN4T8*EJ5$O4XI!(%:+80!`&'#O<YO!)SX/5[\nM@/\\EB*T%)Z!];FLEV,DJB,59PZ3W(DGW.2:]5<H-P5N#]WFA)@Z,S>4S4.NR\nM&^*<(@HC:I6(N7:3&W8N\\/"SQSF[=@L+K0H*A6B%#@)T&*+#"!4&Q*$&YQGT\nM!B3C,;MW[=P$X%(*Z74*69L?OJ"02U>QR3+.3AB<^1J3[@MXY_"BBC2?N]M:\nML&:3;54!(`<#T*Q7></^O<SKA&\\_<9#..&-MG-$=98Q2RVAB&4X,268QUO/L\nMH9<X_/PA*G%$J]7(`4SC8*.,N81"HL&Z_$63G73(1J<PDRY>I_FDG<):A;-,\nM)QL4X%60/RQ_C1YA;5YR``1!P/Y]-_#.M[Z)A[[Q!(_B6=S[.MK-*DIK`FW1\nM6F'2"=\\_>HP7GGZ&[ODEWO$S]TP3E[I2(MM,(><@4)"-3I%TGL6D$2[>F+1S\nM^4H;JS!.(86M0XV=[M:$V$T>`&BW&KSSKMLQQO"M)Y[FN5/'F5^\\GG:[22B.\nMLA(Z9T]S_O1I3IUXF8_=]R'>]*8#!$7GI%7^1N2R#<U4A51N@V.T\\@S9>`7C\nM=N23W4P9FU/(V1R`M:"MP@HX47CR&/!RX9\\M;-O"!]_W+A:W+_#=@\\]P\\M2+\nMG#HZP3I'7(JHQ!&-:D1S9H;G#C[#GOD6M[SU;81A.`WBRP*8JM`Z`&])1ZLX\nMEZ^N<WFR,PZLVP!A'03K`%Q>#N<>B'"V*$\\N&C/-!C_Z([=SVZW[65GMTNFL\nM\\=SSS[']N@6ZG?/<<<>=//?XD[163_/*%_Z,JK.\\_MUW3S,Q%SDA!^`*^2QD\nM%`%KBMV332MNK<*Z"V-`BFN!4SEM)%<AZ]0%%-H\\E%(T&W6:C3J[=^U`2<;*\nMR@I[;KR123KA+;OFB)Y^@/+Y%SGZX#\\SLV,GNK9[ZH%+`=CU?:UU"A6@IK39\nM6'57T,D48-8I1.$9+PJA4"&Y9.Z7#*TU,S,S+"PLD"0)[=E9ZEO:G#A[AJUG\nM#C&I-#GXE;^G\\8&/$P1-1/RK`U`JGS2R/MF",NLRN]DN`GHS@,`5U2MA'A^O\nMXH&+QYX]>S#&,!Z/:;5:`&S]C4^Q_%L?X;KC3S&IMCBJ9JC]^'V$Y0KBW<8"\nMK`-P;N-`UB>?2Z?;[($+8D!-8\\%NND^(KDBARXTHBFBU6M/MVM8;WT+]5S^)\nM*D4LGGB:]O''Z3[V(-8:W.2B3;[UI*/4!@!C+^*_*6AC59&X"OVW8`PHEW\\O\nM2D%!H>6!)5AQB+>7G;04^\\G3OH.-C7!!X0[<R_!]!]GYP&>XX=SS#`E+W_O:\nM`PM[;]I'!)C+4<A:T#I"!24T$/@:.G3HDB.B25`J$<1](M<DJLRBU("8D%)]\nM"^6XA](18=S`.<W*F</_&8QX7*R]S(OQ#1#3'?YI'BG.58!_U\\_+TB/WOWW[\nMZ1?NVEN?+:]:/O&WG_W4]^ZME%[YIR3;4"%QY)OL'K;--ZC6VH@$-`D)]1PB\nM<[2("8,(:3>8E0@=Q"`SS!.B@@J:%DI'],\\?(4M3QM_[XK]T#W[Q,Q__W`].\nMI0O&'WZ5!_[Z_1P1?4NY[+_<//;4ZX/2XEW[=LY_XB]/GO_UNP+<E$(%@%41\nMCFKIN'&W@U_OC3?WQT79O6Y??+Y^OX`6H?L:IYZ/WW\\_#\\TK?GMG\\.QC:_)[\nMK5;UKVYH1-U19!\\%O%:;6DH14/`E[_G'2R9U!7O]?&H7;R&*`!Y>%0#@<^>%\nM;:T*(ZW_]1UI>M^NTX=/?/;8^(7/Q<@OIU?[]/\\#XW\\`L./*LPG&87H`````\n(245.1*Y"8()I\n`\nend\n
105916
 
6610    payment_ok_48           begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```0*DE$051H@=69>71=Q7W'/W/GOOT][9(E2[(MV<@KV"(V\nM9C'4!@(EA)@8)TU[2!MH%@XD-(04,$Y3A^`LM)#UL"4Y@1P**3@M`8H3(`DF\nMF(`=P)8M&TNV),N2M3X]O?V^>^_,]`^14!*P16I.TSEGSOWK_K[?S_W-_&:Y\nM\\/^\\B7<M\\@V`8#Z:4_'9A>(P$Q2H`+Y[XF3>'8"-@`\\(-J#8C&($GTX4OT'Q\nM`H8#:`:0N-S]OY.R3X3?/VH""!'"Y\\R*2(60VJK/Y?/U;LD]SRCCH!G!8R=%\nM?LU'>`F?;CQ26!C^\\\\\\!P`*@2=KRY(:*!@(J0#Z4)^_DR>?SX5*Q--M3WFR#\nMN0S(``<1[,#G7M:RBY_^.0`8ED6"D9E1.\\+$:`I?^41C$61<(B*"F(SAE3R1\nMR6;*)R<GW^-K_V3@*6#7.Y&2)]S\\K4`1"/")FGCU666F#+?D(@,2.VRCM:;D\nME:B,5K*H81&KYJ^BX!<8F1@1Q`@0HH>%C+`4PY[CRUDG',`"$I0A65F3J"$4\nM"F,';*24V'+J*2S!:':4B<($",@6LQ#$0K(>P^,(OH3++/X!N/38<B<^`^\\%\nM8'$H$+IN?NW\\:"(6)Q0-(H,V6BN45F@UE858,$8L$&-']PYJ*VNIJ:RAX!02\nMRE5GHSF/%`4\\]K,`1==;RYW8#-S.5`6R6)&()JK+8^58EH64-K;]>I<V]NM9\nM<)5+WW@?1;^(';99TK2$BY=?3&MSJT!P"G`%DO"Q7)Y8``N(86%Q5EVBED@P\nM@B4EMBTQQI#.9L@7\\@C+PI825[OT3?1A!2Q<4Z+@%IA;.Y>6NI:I>`&6$.3O\nM,<3?;BB=>`"?&5;`>D]#>0,!.?7%M3:,C(XP-CY&:C)%J53"MFWR;HYD/DDP\nM%,0(D)8D74RSLVLG=35U!,/!&C1?0W`Y`KCDW080@&!1/!R?,Z-L!I:46)9%\nM)IM!&TU9HHQX+`X"I+1Q5`E7NX3"02S+(AP(\\]S^YQ!"L/;TM21B"8!]P+-O\nM)WGBUH$[F=H^6)Q1':^.ED?+<5T/I11**1*Q.-H8?-]'*876&H-!2$$@%"0<\nM"'-T\\BB'1@YQ[L)SZ1SH)#F9',-B`T%>PP$>?S<!)"`)HSBSJ;*)4#",4@JG\nM4&3@M0&<O$-U8S66%$3*(I3<$K[VL0,V03N(UIH#PP>HKZHGK_*\\U/62B^#K\nM./R<*/#H6\\O^20#&&'B]XD_V_+9V=-?6QO'.[7.V3KZ\\^)OSLRMF5<W"EA(I\nM):.#8PSW#@.0F<@@I:1M>1LR(/&T2S@41DI))I?!]5UB%3%>Z7T%I=5#P#V4\nM87CP[;V\\8X#LP%YV?>\\J9JZ\\;-U$U_8;)GIWS4P.'*P8&QZ.]I2GO42B.E!?\nM5H^E+2QAD1Y/@Y["U;ZFH;F!1'F"5#Z%AT]YN`*`HELD$`@PD!J@Z!5?Q&(3\nMDASW']O/.P;(#.ZG<>6E\\P=>>N1+/=NW+/)<!R%#'$WFS*O-OFJH:0Z61<IP\nMG"E#[2O;J:BJH.]@'U[)8^["5D+E(48R(PA+$`E&2.?3^-I'6(*26SJ*X";"\nM].$=W\\\\[`MC_^.UHK2(]+S^UH>>WOUR$"#*[_2P2=7.H.[R/2;\\C6!3U!.T`\nMKNT1"H:8OZB-UK964LD)?%^A4?3T]U)0!<+!,,(29)TLTI:XGNL8S*W\\@&U\\\nM`OCA\\3U-^T#SQ.U7XKLE`N'X%6.'7KXS+@KADY:=3:QV-EIKT(K\\4!='A_<P\nM-+>1D<5MY,MB).)EF-<KD>=['.H]1-_`8?8,["%NQU&>8BP]AM`"Y:F[4'P.\nM@<-=T_,U[0P,#HWB^BR)F<,WS:PI#\\]=^G[L2!G&:$+12M*'=]'3M9O#_4-$\nM#@QRRF"*_K9FW/9%!&IJ\\5R7_L$C9'-9/./A&0];VHQGQM%H,#R+X%8".'QG\nMNJZFN9!]=5T#AW<]&RO7(S<O7MC6MNCL2PF552.$(58_#^WFZ7CQ&5)%PZRY\nM)^$CJ5(ASLK5L6)?B?C!089&CC(R-HP0%GDO/S5TW"RN=D'0AV`#`8Z^TT/N\nM<3/PZPWST4XZ9M>N^'S5_%7KRNOGHMP":!]I!XF4U]/[PA9RON#<RSX)PF;B\nM@:]AM(\\M+)JC+;S6OY-DM4(@L"Q!NI3&-SXEMP200[")"EXD#7S[G0$<,P._\nMOFD^=>T?(%P[[^JFTSZXL;)Y<4C[#I8%EK2PI(67'2&33C*CH9%(.$0D&B-0\nM4TMO0Q5#98KM;@==]0'L0!#;ME$H,FX&5[DHHPP6]V!XB#SPC3?K]^SH8>]3\nM>T5N)%?I3#CSG*33.CDP&3/&\\-`W'SI^!H24N*DCR&#8"L:J`L8K8`D!PD(8\nM`(.?&\\&R;:)2XDX>04:J:&B>3<>I\\QBL*R/O%%&E$K)81$J;O%^@X!=^)_$S\nMX.L$<?GJ&[IWW'8'U_WC=:1'TRVQUMC'=HSL>-_AU.$&V[+-@KH%KYV4.NGN\nMY6N6/]9_J-\\[)L"JS?MX^;8:T/XNY:2=8+PRK$O>%``"C`;C$R\\K(Y=.X66.\nMXN63U(9#E.<=)D-U2%]A>SZVE-A2,N%,X!L?H`N+FY&,H=[0W/+(%BY;?QG9\nM5/;L[ESWMWZTXT?MG4.=A.P0QABTT4WKV]>?MG;1V@V/??^QNX\\[!V0@@%?(\nM'E1.>M2JK)]EO#R6):8*L)F"**NH))_+8-P,ONL2*+E435B,JQG84A((!/!\\\nM'R,<QHOC8$@C^"<B[*((;)[2NO'&&[EL_65DQC/+]TSLN>=;SWYK87-E,U>>\nM>27)?))M7=O8UK6-COZ.LME5L[_PX8]_N./X`,$@SMCHL'8S/9:T9QEI85D"\nM(::.7FA%-!8G%`XC@T&,`7P?-=S'0SMW4!Z?P<S(3"H"%>2]'"DGI;'X-GG^\nM`P%\\^0VMZS][/>F1=%-_J?^.>[??NW#QS,4T5C2R=>]6GM[_-*/I42ICE5R^\nMZG*_J;QI5[:0G3PN@&V'6+EY(-^[Y3,=8%9/[?&GJ@E&8;1/,"B)1*/(H,1H\nMC5&*!E%%(;F;O1,'D5H2EW'"A"BHPB$"?)\\&?#[WALY++[Y$7T>?W71JT_7W\nMO73?V=%@%%_YW/GLG70,=*!\\Q9+F)6RX<,/8!6T7W&$[]CT5M16IXP(L_-2C\nM]%9^"I3:C2H9RPX("XUE6PAMT,8B$(D2BT6Q`P:C?+3G4A.MH[&0H,?D44J1\nM=M.D-2#8@>3H']:_%:>MH)`NK-FR?\\O?[1W:2U-E$_>_>#]'DD<`.'_)^6QZ\nMWZ;.93.6W="QK>-G=2UUNK*Q<IHKL7(QRNW47B$3B"3*A2XBI<0*!#'!(*J4\nM)I&((50)Y=D(*8G&:Z@O)A3^L$0!"HWAFPCN)8C_/R=N1T<'D[V3T:'0T#5;\nM]FZIU+9F:_=61@HC6"&+#Y[\\039=M.GYEGC+IV/EL=V1&1'FG3(/F.9*+*2%\nM<;-]QLT-6#+(5"6UD+;$,B5L2Q.)A+$LB;`LA"4)1:LY1\\[^=S3/H?$P/('A\nM7]$<X!K@VJG8C8V-M+6U(<OEV<_T/G-N=Z:;_>G]3*@)[*C-^A7KV?S^S;]L\nMC;=>&:N,[?[Q`S^F_?3VWWN;5@8L8>$<?74B,>>,`PBQ&&,0&-!%A)JJ2L*R\nM0$Q-;B%M1#C!A6+63GQN!"X"'L5GC-";8S_\\\\,.D=J>"J:;4WS[>^W@BJ9.4\nM*"$CDO-;SN>+:[[X_*SPK*LB99'NE:>M9,?.'6]Z?UH``JA?\\WG/S8[L-MI?\nMAS%HKP@J"]I'*XW1&HS!&(,5B&`%(GBE;*8S_.&!Q9]X^'MO%WO!@@5$1?24\nM)_N??.^>]!Y44"$"@O;J=C:>L[%S=G#VM9&J2/?&#1O_R#Q,<P@U?^C[%,>Z\nM4<7,+N4676,,?B&-5\\SBE8HHKX3R/;12&.43B->AE9?W<N,]?C']MG&W;-E"\nM5545HVITW2^&?U'K!3UD5-)0W<"-9]PXMC"V\\(9X3?S5N^Z\\BZ]\\[2MO&6/:\nMVVGM.6BOV*6<;))@J$$[>80J@!!HWT=Y[N\\A(I6S*::.]'B9X=<F_WF?2/]U\nM9E%)E$[71H=C,O;J\\.#P3AF0GK8UA<%"8[?JOF1W;C>A>`A+6'Q\\T<?5.77G\nM?./^C?=O/?-C9W+U-5>_K:_I`_@^;FKPJ%=(]5J!A@;E*XQ;`J.G[CP]%^65\nM$,$$")O"\\/Z?QM<^G)N5'+OAU?2^:SJ3G4TYE1/+9BR;6-ZT_%_Z]_??,;]]\nMOJL<=7;'4,>"M$QC12U6UZUF_:SU/W=&G;L_</T'S.R6V<?T->V++>U[/';-\nMMJR72QY02J%\\']_S\\9P"OE/$+SGXKHL=KR<WN&>WDR_\\6TW+S$U/]OW7K=V3\nMW<UMM6VBI;J%WXS_INJ%R1>^,&?!G(^LCZP729V\\:$=NAVU%+694S."*UBM&\nM:E3-5ZN:JU(///C`<7U-.P/%S"3G?:4]H929K9P"7C$/6J-*SM3BY?L8*XB3\nM.MKO3/3=X%[PY$%TLEC2)>^5\\5?LG:F=##J#5,0K&!\\;CS7&&J]_L/_!PZ_Z\nMKYYQ4!TD$`NPMGXM[9'V'UYWZ74O?.BF#[%QX\\;C^IK6]?K>[UV`40&L0.0O\nM([7S/NOE1@/*R:&5CW*+*-=!>9Y17FFGEY_XS.Y[MS[3=M$:7<J&MI\\ZY]11\nM)=7*1_H>B>W+[V-0#9(D22P<JSZ][O2VK?FM"[<7M]LMB18^7?_I_56YJL^O\nM6K]JHKV]_?C&F.80R@V-,[KW%V$1KOBHY^0BSN0PGI/'*^;Q2B4\\IXCO%CM\\\nMM_`W5C#\\RX5_M8QYRU>3G$RZC][QZ+V7-%[RR<VG;^X[><;)B)`@;:5Y*ON4\nMW2?Z5NU1>\\(R)KFX]F+32NL/RAO+>PX<.#`M\\],&T!K"M2>M1`3/*X[WXQ9R\nM4[V8Q7,*>*4"GE-\\KIC3A[QLDO=LG/K-M7+U2N:=-4_'*^*/GAD]\\\\I-)V_J\nM6EJS%"MH,2R&N77T5CI-)ZUEK:R.K.[TQKV'^P_WLV;-FA,'\\,RU30SN>,7&\nM"EWNYB<KG$P2KYC#*V1?[SF\\8M'W'>=YH=(LNW[;F]Y?_;[5W'?/?937E?]J\nMF5SVR0US-W0MKER,#FKVZ7V40B56)U8S2\\UZL'IN]9&77WEYVN:G!:!\\EWA3\nMU1S/*9[G.7E\\U\\'-IRGET[CY#&XAB^<4CGJEXBM>R7G+&%=<=05//_DT975E\nMVY;H)5==UW!=;TNL!1$4U(1K6&6OZA.3XB=#1X=8MV[=B068VB:H03<W\\6W/\nM*?1'ZDZB;,X*[%@-RE>X3@'/*7;XKG/$=]\\:`.""BR_@^5\\]3UE=V:].-:=>\nM?W7EU>.5=B5+[:6TJM:MMWWTMH-[]D[CM^0?M&G=PCQVN<3-*A&M+5\\4J6Y>\nM'Z]O.T]85DLI,Q)W)@8L[;NW&&-N-WA<^-VQ8\\9Z_MGG>?S+CXN;?W+SM4]8\nM3]Q6;I5[YQ3.N=2.V<]$8]%W!^!W[3N-,#X("R\\D$:^/U-F16$((2P"'@8D+\nM[QJ=5IRN_5V8O(G6S*^YT[*LUJ'NH4L\\X:67+EWZC@'^S]KPX#"]!WM;#_<>\n?_@N`6VZYY4^*\\]_7<\\-],"VQK0````!)14Y$KD)@@@'^\n`\nend\n
105917
 
6611    printer_48              begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```(ODE$051H@>V96XQ=51G'?VOMR[G,G+E/AY9IF=:V8(#2\nM0@I*3!.()AHR1L4H^FXD/)CX8GB`-Q,?Y,'X8#2:&$P,/NB#&`5?K(`$,%PL\nM4(&2H+;#,--VF)[9Y[+W7C<?SMYGSCESSO1,D28F_9(O:ZUO[[/W_[^^RUI[\nM';@FU^0CB=CI#YQS`)/`$4!V7\\O:3.D8YQW7,P:$@W4G.`78DK\\S2/Z.[MY\\\nM^=%4\\UOC*'5B=<YE;::`S4$/L`%^V><O$T7QE5C3W"F>'1/(&'BII:0MI19Z\nMAW6;P&P&MFUS8.D99PH@2Q00"#?@E?]3`IWNM\\YU`QT`<CM[?JWKV1\\G@?QE\nMQCFT[0;5.=.=0"T]]_2$DLF>::\\6`0%HRQ8"@V9[$+%V3F3(\\R+PL1)P';.V\nMA0!]8G^`!W);/FX]_&H0R%IC0=EN$%?D`;$90E?-`Y"%D-E:=?I5H>T2&39#\nMR%X-`NTDSG*@"S"7#Z&^!/+)V3G^CQ!";I/`Y2K.=F$DLLFX:@3R6=/]/'`%\nM>2!$AR>N9@YT>F"HA8O^GA&=2;QS_%<60D+@^N;`=A[H1RHCD$V*\\^4V+QX@\nM._J)$(+)DMCURU_\\_(C25N9AI+.2JK=190;=*XBB:.+!![]]YU?ON[>TN+CX\nM\\1$(PP!@\\>D__OX'J58%*P0&@<W4(.AGV]X.%U;.':U%T>,3X^-[BX5P1P2V\nM;KYO_3I$#6]L]Z[[*J/E&\\#9?-/F$#9>.7-B84P_L/CEKZ%EZV4.T=[K@^AI\nML^M]6@`A)5Y]E9=?.Q4M-4L_BK1<$1VXTE2SOE%_1DKYIFY>@K>>[(*[)0?$\nMR!S.-:__W(D['CMQ]."A.-4DJ2).-8G2K%P\\RIF7_LRN0H(?&)32:*W01J.U\nM06N-5@JE5>N:4FBM45IAM,&83*W!&(NUAHU:DV3\\YLJ1PP<?[4QE(027H@8O\nM_?/L3Z.3[SS$9VYU<!D"\\_L/8JP[=M.--]XP/3M++4YI)`HO5DAEL%7#S&0%\nMSY,D24H<QS2;31J-!O5ZG5JM1A1%Q'&,RL!;:['9<BN$:+>Y`EP*-=4U0:G@\nM4PI]0M_#]R1B9(3)W?+NY`MSL^5B</Y2#]XN`B<>_@WWW'P]?W]WY<[1T5)X\nM/HII)(IFHJDGBF:J68\\VB"XL\\]33JT11C4:C09(D:*TQQN"<0PB!E!(I)9[G\nMM?O];$((BH60Z3)\\&'C$%M+4X&E'X$E"7S(W.[$P.35V"-B>P/S<.,^^NQHN\nM[!J[93U6)%'<"AUM2)7!.(%)(SXX]Q[OZW0+(-_W\\3ROB\\`P.C(RPLQTR,SU\nM4PCI`>`VDPHAQ)@4XA9C[?.GMB.P,#_%POSDF#%NP3E'&'B$Y;"540*$]+#+\nM,;YPR$(!Z7GXGD<8A@1A2!B&A$%`$`0$04@0MOJYS6]?"Y!28K1&*47@^U`.\nMD;M'\\8NC]%O2A."F:BWA^W]XA4<6[^A/X."^:8`I:]W,EB>T9@)]=IKX]N/M\nM6?<\\GR#PV\\!R]?V`(/`[6I_`#_"SOI2RE=Q9GL2I9F[/!(6QB?[[:L'>()"^\nMM4X/],#!?3,(P:QU;JP?`><<M0-[*9?O14JO[9F\\ZG5TM]@L@@1(<Z,3"-]'\nM!$5`4`E#/K%_CG*EDA_=],ILX,D",)A`L5+!0<47!-9M=:1*4]Y\\_AG&A"$,\nM"QACVA7&68NQ#N=LE\\TZUW?LG.L:*^LX?.QV9L;&VQ4K%Z^UX2MK1]"[\\G81\nM>'%9`(37%9'K*22F^V:C)-548NL7D)[?!M(&V`&N#;*/YM[LLA7*O'G1XVP(\nMSFXN=`Z8*8"R!*NQ\\$H]A;]K^-SKRUAKP[OW3WIG-B3KB>M:JIW5+)W?('KC\nM1?PPI%`H4"@4LS;7D&+6EU)F"UVNJMTWV:)GK44(\\((R_UA*D(TFN$T/6`='\nM9B2U1EQX]NVS_E31&TS@;T\\\\!M;(E0.'J=HRL>XYZ'`.'36QX_/MLND'`;[G\nMX^/C:P\\/']]X^"D(X3`&C!%8ZV5]B34>QMKVN@%``_0S?\\(6*^!:&Q&7;567\nM1@+JZ^][9TZ_*LO%XF`";O8`0HCDR*%]]N3I<_)BM=Y>*7,I3._'F]J'!E+R\nM<.AT>#;.CR]$[UOZBQ,2%2>$C74\\9VB*$F.F3B2*'-M[F&9EH?GZBDE'=HT!\nMO^Y/H'8AQN'BI=78U"/K)Y&C$[]PECW1:4:3\\TC/:]7Z(.BH]R%^X!-F=@0H\nMI5"I(DU34I62I@J5INVQ2A5:*Y179GGF+HX>7*4RW^34R0H/SUJ>7(75M0,T\nMDS1A+39-OS#8`\\G%%:QCY=1K]>KZ1GV72KLJ%L)9-JKG.'KD!KYX_S>004#+\nMV:(UU6*S[X1H?;A8AW4.D[76MM0XA[6@FQ&_^]5/>.>]_Y"RGU?%,B634/O0\nMX]E_+[%<VLT'I]_&&'N.ZD9#!=V5I8N`B=9PB+>6H]4?6F/OHN>TSUGC1@I^\nMY5L/?>>>VXY_JJ1,*\\F,ZVZM[3Y2Z:NT/N8]";['^J/?^^Y?=;2FJO$T&V?!\nM"<<3X1XP`GGN7QHI?^9[)E7K&]V3NB48"_-@C:`T*I#=&>_6W[+-U#Q0U_+Q\nM6!/V@C*7`]VKMO6;\\2)K>TIJ<?=$^(*8NE6V4DF#%X#5D,30J-H6W+7!'FC%\nMT1*`0W6O8ZKUY1VFSKN_J5VH^\\QR3B#_YC5#>,(XJ,9,3Q;"+]W[N'YA??D-\nM.UD:_D^.H3_JK07M.-!4[M.Q;H'<;L9[KQN[>:S2&V*I@6KB/OO4-_V9FN+B\nMT.AW0B`V(`7'FYK=>>P/,[M#W6>AFG#H4L(GG>.YG1`8ZJ.^J1R/G%0DAN.Q\nM1JKL9.&R:H94"QL)E5K*':MUQVK4=S-WY02L@Q]_/AA-M;M-F2SYAM"^9T/T\nM#[=80U-Q[+;KA-S)"=W0(908@H(O7IXNL9R5]_9BVSYBI\\=&C[W3UG,?($L!\nM[T8)/J*UZQY&ADKWNFZ](A3(*SD]&T8<<"F&AL8&'LR5=_P/\\#6Y)M?D_U'^\n5"V]#6$Q^&,Z+`````$E%3D2N0F""\n`\nend\n
105918
 
6612    reward_clock_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```4L4E$051H@>V9:9"E5WG??V=[E[OVWK./>C2C6=&"A+"%\nM(@%"R"!AHX2*';.8&`BQ@T-BNT(<$\\?(5*!2AB2*30H;4F4<XA@*'$"I"$D(\nM25@2DCR:T8Q&H]&,9NOIGNZ>[K[W]EW>]9R3#]T:+0@*EV/S)4_56_>YY\\,Y\nM__]Y_L]SGO>\\\\/_M)VOBE0._]>__&!769&=IKMKM=NI)DE2L==+C`6&-T?U*\nMI=8=&5\\WR+/,WWG'K_X$8+]H`F#+SC=R]M@#_-/?_-3Z:B6ZI=5>OK$LBLOB\nM.)J(X[BBM1;.><JR=&F6]XJBG`N"X)EJM?H=X/Z=V[>VOO#E;_#$M__DK[7X\nM;WSLX_2Z77'9[CW1OM=<$4JI.'OFM#UT\\,ED=F:V_."'/\\PM;[KN1Q-XWT<^\nMP9?^X-_QT=_^S#L;M>AW3YT^M7=B?%3_]+57LV%RG%ZOS_FY!1:7VPAE"**8\nME6Z/5JM%4>39\\-#P(U*JW_*N?&S+9;OXQS]WXX]<\\#-W_E>6EY?%55=?LZ5:\nMJ;U1&W,=WF^72C>MM2)-TRQ+TYDD30_T^_WO+B[,']RX>6ORR^^^_57G4SOW\nM7<VZ2_:.[-RQ[8];RTM7=;LK\\GV_^`MLV;2!^;DY_ORKW^2O#AYFN=5%:\\.Z\nM]9.,C8VR?MT$29+H,#!3C7JM>??=]_Q%F73=XX\\\\\\*H+O>>7/L"7_N?7`29W\nM[][[T69SZ/>EUN_O=GNOFY^;GSIW;F;#_-S\\^G:[O;FT=D\\0!#<%8?@/HKAR\nMY4JG<W[KU/:9FVZYU3_\\T/TO)Y"F";-GCH\\$0?@K&S9N'!DD`TKKR:TES7+`\nM<\\7E>]FZ=1-;MVYBR\\9U##7KV**@R'/JM0H'G]P_\\_6O_-F?YVEBYV;/_`#X\nMW_OT9_A/O_\\I]A\\X_/KAD='/*Z7>?^+X\\V/W?N<A^>V_W,_#SYSEP.E%GIY>\nMXLCI.8X^=Y*SITZ1)8.H5JOM"</PUEJ]X5965@Z^^>9;B^\\]<.^+$MJ\\;3?>\nMN<TFC![8O&5JV]:I;51K=1K-!LUFDV:S0;42$P:&P!BD%.1%29*D+"\\M<^CP\nMTYPX_OP]RTM+/UNI5++]C]S],O"?_/1G>=<O_"*GGC]Q?;W1_,+*2G?G??<]\nMP,/'9N@/;67+CAVL'ZE3#16#P8`21>H5\\[,S9&>/,5JVN7SW#D;'1O-!O__9\nMF7/3=\\1QG'SVT[^S&H%J;0AK;5-*]?X\\+X>7%I=HMU?H]P;TNGTZG17:[17:\nMG2Z=;H]>/R4O'$M+;:9G9FDMM^BTEIY?.#_S9UIK>V'N[$7P-]U\\"^]Y_P>9\nM/G-ZW]#PR!?;[<[>KWSM6SQTOF#SZV_B5]_U)MY]PQ[&18]JV67+6(-&V>::\nM*_:Q<>,ZU,0E+)::Z:-/$PJGZO7ZZY12@^\\]>-^C-]WR#O_4DX^AC0GPWJ.D\nM0@@PQB`09&E*M]O%.8]W``*E-&$H`(''XYVE+`NT"6D,CQ%&\\<MV_P,?_F><\nM/G6RL67K)7<,!LGE_^N;=_-7G9#K?^86WG_#94@!T\\M]%OH%B^T5RJ46E<8(\nMJ7740\\UKMHPPW+B68XT&1_;?#_BPT6S^J]=?=^/!>KUYSW4WWHPNRASO'$)*\nMA)"494E1Y%@7(81`2H&0X+VG=):B*-#&X#UH;3#:4!09_6X'K>1%\\&^\\Z:WL\nMN_PJSIP^^4XIY:V///(8CY]/>,V;;^/6O6-<:'5P*L1Y3UAK,K)!45I++@,6\nM^QF%]91Y2E3TV;9C&R?S`<<//\\SN'6942O7KITX>__YE._>M:*T->.^54CAG\nM45H1!`%&&X00JP\\2I11&:8+`H+4"H"@*BK(D#&/]EK?_W%:ES?@5UUZWWEI;\nM=PYYY^>^J&Z_[>8/S<\\M!`\\?/$9EQQMXQ]536&%9NK#$T,0ZK(>@6L='5<YU\nM$A;[&39-$%+B!SU:9Y_CS*$GV/&F=[*X.,7<W#SC$V,W1''UAB`,[]*V+'#.\nM":4-Q@1X!UF>8TQ.&(58Y[#.4MJ2HBPIBA)M'%)*PB`D#`*,T==DV>#;(Y6A\nML<T;M\\3U6E6!0"J)$((C1XXR)^K<L/=2JJ&B=(HDSYD[]"27[+D"A^#T<I_E\nMI"#0DCC28`OFSQYE]M`3;+WR#8RMWXC&,__@_V8H+V+O^9G/??:.N[14&BD]\nM"$%9%D25"I4XIE*)"<,0HPW&K$HE#`*"P*"DQ'E'7F3D14$81HT;KW]]XYJK\nM+L?;@F>.'N>YYT\\S,3&!M9:39V=08UO9-M$D+1P.P?SY6;[[E?_&C;?>3G//\nM3]&SBGHE)#"*O'V!UC./0U[PAI__92K#XQ2E1:U?3WMHE#S/<<Y?==OM[QW2\nMWCF\\=WAKD5)2%I8D29!2H[0F"`+*-:GD18$I"K0)4$)B3(`04*]7V7[I=HK2\nM<?3(4;YQU[V$4<3PR"B]7H^E[H#&]C&,+UCI6G04L^WR:]!QA:>_^RVR0T^Q\nM[NH;&1T?9W'F-$LG#C-UY;7LON):E#'D:88;]*E5*]3')_`7SF&=7:^,&=,(\nM`4@OE<9:"\\(3!(8P"C'&H)1":8U6:NW1X#U%69)E&2#HK/3XSH/?8].F352B\nMF+??>@LCPT,H)5E>:I.5GC`,F#U^".DLF_9=@PE#-N_<AQF>Y+M?_^_\\G__X\nM<:J5F$U[K^26]_T3UE]R*4*L%H^D3#E_\\FF:E^RBVFB0+2M\\7L1!&,<:`.^%\nM]PX3!"BE*8J2-$G1VA`$P<5D+<H2NQ:I(`B(HQBE)%DZ8/K,--V5+K5ZG7JM\nM1C_)&!EJ4MH2`0@A0$<,%J<IRA),0%&4N$J=Z__1ARB2+C./WL=;_N%[V+9K\nM-PJ'E&*UVOF8.`XQE$2!P0>&;K?GTB1Q&N\\!/`C*O"`('&$84JU5J51CHB@B\nM#,,7]:\\4UEGR/"?-4ISS)$G*L6>?I=%HTF@VJ=?K5&M5IB[92K->(50PR#-$\nM;8*19A.K`EQIZ166$JC%$;=_Y&,TKMK,4%,1&$6HU5JN>6S:8V1\\G'ALC,43\nMSQ,&`5F>==OMY:Z64N+7(B"D!`19EB%[?820**G19BV1@P!K'9%4!&MC?O64\nM(PQ#@B!`*;56?B59EB$:59J5D%9[D25Q*<.18=#-*/$():G'!B6A4JU2N^H&\nMJK//HO=>31P:M))8YU"C(\\3U)JU6%Y$F:*U)D^Q<.A@L26M+K"V]$`+G+-:6\nM**4(HY`H"@F"5:!::Y24"`&%+<GRG*(HD%(!@CPO2-.,+,M6)5<4]/H#BJ)D\nM<GP$%J<Y.=_FN8459CH)_;1`XI%2H*1``G[##K2`L'N!*#34(D,E-`1:$FE%\nMVEHB$HX\\SQ@D@\\<OO^;ZOE0Z0.E`>.^14J*UQCE/GN6D:4J6Y11Y05F66+>Z\nMV\\%:2=5:8VV)$!#%:[*K5(BBB"B*$$+23U(F)B=HYFUL:PZ/Q!49Y?(Y<.6+\nM7:4`$54H)K<A3AY&"$%[\\0*#;I=8*WQ9LG3J-,/U"G-S%]J#P>#N$\\\\>1A9%\nM1I&G?E5*JZ>K$!ZS5HG",,`$!J454@J<<V1Y3I;G6.LP)D0`:9+1[_49#)(U\nMXAE9GC-(,HPQ3&V<@.</X-(^HDC0M6&<#'`.G!>L7%B@-7N.8L-EI&>/D2Q=\nMP.N(LM<#ZYA^[GDJ-J??ZS-S_OS=O6[[\\5ZO@PQ,2!!$PGM06A'%,5)I;&G)\nMLX(\\SRF+`F?=6O^CB<)5>1FML+;`(]!&$5V47;!V^&D\\@KRT3$Y.L"%R%$>_\nMCU<AJM)$X+'.D64YTX?WLWQ^AB2LDT1#N"/?9Z)>IS$\\QG//GB29/<=HL\\H3\nM^P^>75E9^6RC.9+N?^2>U0CD18KW#EM:LC3%68L)]!J@B"`,4%HCA,!:2Y9G\nM9%E.:1U2*KRS6.M(L^QELBO*$N<<01"CC6'3Q@V,%FT&3SW$8'$>)035P%`S\nMBEJM!OTN$T:P]:=OIM$<96ZIPU,'GF$P?9;-XT/<]YV'.F?.G/V=)Q^Y^XE.\nM:PD`;8(0[_UJG<:CM4$(25&L'E2K%2@@"$I8RY/`K.H?/$61(^1JY0F#D"B,\nM",,`%:X>?%)(/!!6:I@D97QLE&!EA>3@@\\PO7DJY=1L3D^.,3>VF$D@Z_8S%\nM7+*2U$@?>9R&]$3"\\I6O?7/YZ2//_G9G:>'+^UY[(\\\\<_,M5`D6>X;PC"BN`\nMH"ARM`D0K$I*:X54$H3`>4]9KE:@LK2(M7;"6X<TAM0/L%%"9RS'-E.JHLD&\nM/<6VZCX:89,BSVEW.@1!B'$6._L\\*TLSI/4&<:U&&(;,:D4HH6H46GJ>G9[A\nMR8.'GYF=G?NW_5[K&W&U9H\\<>.AB\\FMC0CQX(14>OUHRS6HK[:Q;T[Y?)20E\nMQAA"$Y`JA7,EJ1@@MUC4IAP[D9-5,G1D:,:3K!_:S=3HM6RN[T/E`C<T3:YC\nM9D\\=I]OJ]+303A9%W66)<"O+9$:CE<8Y2[?;LW,+"V<7+RQ_K3_H_=&>*Z\\_\nM_M1C]_%2\\*L1*#*<M53K30(38*VER'-L&+'6`ZQU&V"M(R]R4C5@5I[FW.0)\nM5C8O(.(4$1CJT7K6U?>R:>AJUM5W40_'4,H`'JL=U5U0V=@FW="FLW!F)2HJ\nMA\\5,I.R\\%/8"99G;/,_S/,NSZ3S/GDS3])&5]N)I$T3VJU_\\O5?>%;PD`MH+\nM[\\$Y1ZU2(8ZKQ'&,T0:M--HH<M.G&\\W3C19IZP4&]0Y"*6K!)*.5W:QKO);Q\nMZFZJP1A*KH+N98Y2+-'G#&V>H54<HY<OD*]+")MB@W7]=6+7H*N<GHE%\\%2H\nMHD<CU7QB>*1^]%.7_X?.O?XO>*O\\^Z\\*_.+YL6'+=IQSFX,P?J!6']H6A#%1\nM7*'>:-)L-+$C*8,M%["-A#+(00IB,\\%PO)O1RI4,QSN)S1IH#PB'$WUR-4-?\nM/DM?G:"02[3.7^#L@6G".$(KA2TLZW:L9W)J@K(L2;.,(B^\\MZXEA3P1ZO")\nM2EAYM!;7#HS7Q\\_\\\\_4?[=]3WLTMYFTO)[!Y:C?@-VD3/AA&\\;9JK4&E6J=:\nMK5&KUCD5'^%@^!#U2HVIC7MYPYY_2:SVHN0(4ABD6.T%2]_#!_.4X0DR<X)2\nM+H`LZ,YWZ2\\/"*.0LX>F*=*"T0TC;-JY":TU)C#T6WV44GCGL<XRNGF4TI?D\nM16X%XH*4\\FAHPL?'ZF./&FT.#56&9C_XT(>RY=N6T:4M<-8*$X07;Q7RM5?*\nM,K)X[[&%I=WJT(XS+IN\\#N]KK"0%O;1DJ7\\2IY]EQ1YBD)PEJ#BJU2K5N$9D\nM*KC8<V%AD3PH&%TW2IF5#(TT&1X=(8XBCCUQC)GC,]2'ZPR/#6-+R^8-FYG8\nM.$%1%FJIM[1NKCVWS@O>9(S)E52S,XLS1S[0_,"=GWSJD_?H,(S!^QQ$M\\AS\nMXDJ%:FTU`G$<K[[`>T"`\\YY!7F*411M!8`L>.?(INOD!-FW8S/C8!&$>DY<%\nM26<1;32!"IBZ:HJQ\\3&TU$@AF2OGN&ON+D9G1I@4DXR,CM!K]QG?.\\[4GBFR\nM,N-\\ZSQ)D1"9B,LV7$:H0_J#?C!_8>&2\\_/G+^GUND_,+R[<HP&ZG<6%X;$-\nM_\\(Y]]%!?W"=<V+,>Z16!JO=Q4MXZSR]U**THR@=@]S2Z;4Y>WZ:F=GSU*HU\nM)L8GV;1A$^LGUU$U-1R.I$@X,7T":21+<HG]V7Y:IH6(!`W39,_D;O;NVT<\\\nM'G-N908I)8VXSL3P!!))K]_CS-P9%I<66>EU208#LB)'Y1GZ]/'#`'[]YIT/\nM.&<?$T)N]YYK;&GW%7FQ:1#U+D>S:Y4`=#.'*BVY]:2Y0TI#%`=H%6"=8VYA\nMCL6E"QP[46%L9(R1X6'2(F.F-</YWGD*7>"-1RCPPM/R+;YO'^.94T>IB`K;\nMUVUGT\\0FRO%QW)!CD"2T.VWZ_3Z#9$">9:NM3)XAI4*_D,U//_D@0`(<?LL[\nMWGOXOF_]*?PAZ*?,KPLA/H/T""GI918I5PEDA4490QS%:!4@E41)A902*02M\nM3HM.M[/:I@O%.C5)K]^GW^]3Y`6N=.#`>DO+M6C+-MEB1G!%P/#(,)V5#DF2\nMD*;)6O^5K?9;64J6YR@I7R3P4KOO6W\\*@#EB\\-KO#V1POU1<H4TXTLN<0%@*\nMZ\\D*AU+!:JY(@Y2K;8>4+R&RYBLED5(Q,2HHRH(D3TC+%.LLSCOB,&;7U$[V\nM[MA'K5)ED`SH#_IK@#.R+"7-T]7?M2BHET;@U:Q6C6G]P<J#T:]$/RLH=H7!\nMR)N20KS5>O?:O'0C>6F%T@&5*$9*LPI6J370\\B*AB_[:N%(UI!P%+5!5Q>CD\nM*)>.7\\I0U"3)$OK]/DGZPGO%"Z#3M0B\\,)9[I>0/?B/[8?:ZSS_'Y5L;G%M.\nM*Z7UN[/2OSDMDIO3P>^^5O@C(U(9\\3+@+_BO)/1*7RGV[MG#^,@$O7Z7P6#`\nM($D8)(,U_R7/ZO\\B3=.'\\B+_-U**QW]L`B^U7?_E60+Q)4K>5='N8[N,6GJ+\nMUOI6I=152JJZ?!42:DU.+P)_T=^V=8I&O7$Q45\\!^**?I,ES:9[=F679_PB,\nM::WTNS]^!'Z8W?@G;Z2;=ZBH2D,I]5JM].U:Z;<II;9)I=0/[O@/1F+=Q"1A\nM$-(?O))`\\H+?R;+TRUF>_><C!Y]Y;ON>[9SXUR>`5_G,^C>Q6[_Z=CQ>"B$W\nM:ZW?;K3^>:74ZY14%?F2""CU\\B2OUQH(`?V7[OKJKTW3]-$LSSZ59LF]2JGB\nMP$<.OFS-_Z<$7K#WWO]>LD&",J:AE+K1:/T^I?1;E))#WD.>92BMJ56JJ[>!\nM4I)F*9U.AZS(R;*409+,9UGVN:S(/A^%X?QB:YE#O_;4#ZSUMT+@!?O(_E\\C\nM3S.`2"OU4UKK#VJEWV:='5E:7F9Y>8E&O4$4Q5Q87""*8X3`IFGV0)YGGUCI\nM=Q\\.@]`]^$L/_M`U_E8)O-1^\\]!O``1*J=<;;3ZLE+ZUU^L./7GP`'/SY]FY\nM<Q=1&"ZG6?J'69[?J91>S-(^][[[_A\\Y[]\\9@1?L$Z<^`=Z'6NF_9TSP$?!O\nM/77F5-SIKAS(\\^SC@\\'@V\\88^XW;O_ECS?=W3@#@<^T[R8H2[ZD:K6^;GIF^\nM^N294W]4K51.=`=]OG[;UW[LN7XB!%ZP+Z9?H-?OL=Q:EI]XYQV.I__Z<_Q?\n4SY"4-VVJBH4`````245.1*Y"8((B\n`\nend\n
105919
 
6613    reward_write_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```2*DE$051H@>V9:;!=5W7G?WLZPYW>/$AZ3[;D9S\\-QI.P\nM;-P8XYC$;0,!3"BZDX8.94(2XL0,3@>'5(@INNFDR^EJ)5!-2)."!%+I="=M\nM<*IM`\\9RRJ,L2TC69,N6-?D->M-]=SKG['/V[@_W299M('9,X$NOJE-WW?UA\nMG_]_K__::^U]X/_;3]?$RP=N_T]?1H4569^?+C<:]6JGTRD5A9,>#XC"&-TJ\nME2J-_J'1=I:F?MMG/_I3@/VB"8"UDV_EV*$'^+7;/K^J7(JN7UQ:N":W]H(X\nMCH;C."YIK85SGCS/79)F36OSZ2`(]I?+Y>\\"]T].G+/XYU^_BQWW?O4G3^"#\nMM]S!U_[T,]SZZ3O?7:M$?W#D^2.;AX<&])NV;F'UR!#-9HNIZ5GF%I80RA!$\nM,<N-)HN+BUB;I7V]?0]+J6[W+G]L[04;^-"[KOFQ`JP"W[MV`_<=G(I&>J,P\nM;=8;#MPMQQ,`U.2%6Q@]=W/_Y/GKO[RX,']IH[$L/_B+_X:U8ZN9F9[F;_[V\nMFSRQ>R\\+BPVT-HRN&F%P<(!5H\\-T.AT=!F9=K5KIN>>>^_X^[S3<XP\\_\\&,E\nM\\!=77,)44ZRY\\JK+METF%CZYR<WKZY[)G_CR.'QK&?3.1[Y+N]6*>V+9.[EQ\nM$_7E.H_OW,W:M6,4-N.\\B75L'>A'2$E/3R^K1H=16K.PL$1_;XTP,#RQ8T?/\nM`]_^![4X>R+_L2$?^'68/RI^:>*]6]X_=.^G5L],W;1ZZIAPWN]\\7S^B)/$`\nMJE+K0T#O[.S,A^I+];Z>GEZ:S1;S"XMTDHS>_GY*Y3+E<ID@,*1IRE)]F4:S\nM2;/1Y(F=3W+HT.%GRY7:7X=1J9@Z?OAU8[_BCR?XR-^_B_ZKG[@AGACZZL[2\nME5=]=U]#'#Y5GSF2R]O&*M63MSS;P@,ZMQ;G'%)I9F=FJ->7J=1ZZ>\\?H+>W\nMETJU0KE<)HYCHC@BBB+",&*YOLP+4R_0:G4H\\HSZPBD$`Z\\;_/A-@TS>L)HG\nM[O_*%>LG1OYDA(?.77_D.4X^/^Z_<>K?91-;WOHK`[OV'SZ_AZ5#CW\\4;4R`\nM]QXE%4*`,0:!($T2&HT&SGF\\`Q`HI0E#`0@\\'N\\*\\MRB34BM;Y`PBE\\W@?RZ\nMG&_>_43?YDO&/QLMF_.6&@E7U[9R_I7)\\T>.]#VRII&O6EBJXYP&0-H\\P]J4\nMPA4((<GS'&LS"N<00B"E0$CPWI.[`FLM>5'@/6AM,-I@;4JK4<=FZ>M#OZK,\nMXN@RS2Q]YX&I$]<^^-0!LNDJ[:ET^7_>/;-='CM?+1P\\=GMY]>32,P=V`:"U\nM-N"]5TKA7('2BB`(,-H@A.@^2)12&*4)`H/6"@!K+3;/"<-8O^W&=YVCM!FZ\nM>.M5JXJBJ'J/%$+@P2HI%Z(H.EDNEX\\7N5\\00K@O_.%MK\\#?._A'^%OE2'S3\nM\\9M;[>^8`;W`P)K!QO_:=_2^YW;?V*PL+&\\[-?R&??J!CP,/=PD4N<4Y)Y0V\nM&!/@':19AC$98112.$?A"O(BQ^8YUN9HXY!2$@8A81!@C'YCFK;O[2_U#HZO\nM61M7*V6%$&2I)<FL;[;:MMEL-6V6G*A4*O<'0?"U]WWX4]_O[:FZ+]_YZ2[Z\nMZF=9VOMHR"]^Z/;!B9^]^M(#ES"_YZ'6]];S>+UU]93/VO^U<>&Y1^3_O0]K\nM'SY#6DNED=*#$.2Y)2J5*,4QI5),&(88;3"F*Y4P"`@"@Y(2YQV93<FL)0RC\nMVC5OOJ+VQDLOPA>6_0>>X9GGCM))4GKZ!L3Y$^<%:6;[E^I+_4N+"Q=52K7W\nM77[IYEN4Y/]L^\\K?\\5L?^1XT?A^NO^N7N>2<CX2SB5A;#+GFTMHO#58N?7ZL\nMU5J^?-M[CWSENMMQ^7]^2=2T=P[O';XHD%*2VX).IX.4&J4U01"0KT@ELQ9C\nM+=H$*"$Q)D`(J%;+3)PW@<T=!_8=X*Z[OTT4Q_3T]C$PJ.CKK1*&(>-K1GAJ\nMWWYJM<J:3JOU\\Y_\\C0_===T-_];SRW?`[BNNY:H+?K^:YO'5G654<^:>Z>G#\nMGY][[!-S;YJ]68Y\\^A\\@_^^OD)U&"$!ZJ31%48#P!($AC$*,,2BE4%JCE5IY\nM-'B/S7/2-`4$]>4FW]W^CXR-C5&*8FY\\^_7T]_6"]U2J%2J5$EEFF3DUSZKA\nM0>;GY]C^P(,:8/O4]?#4/>?Q_C?_H8Z"U5=.SU%JS.[_QQU[/C4Q,3DW]]@6\nM'N%)]\\B)'YSWW;W(>^&]PP0!2FFLS4DZ"5H;@B`XDZPVSRE6(A4$`7$4HY0D\nM3=H</WJ<QG*#2K5*M5*AU4D)PX"E1A.E%`A!J]7F^/$3/'WH&9;J30"?[SY0\nMX^9W?HY5?9=O.CK'NGQI?L_>0[?_ZD=NW7O;;_]K8->/W+@TW@-X$.29)0@<\nM81A2KI0IE>.5PA6^J'^E*%Q!EF4D:8)SGDXGX=#!@]1J/=1Z>JA6JY2K%<JE\nM,J5RF4JY3!3'+-?;M-LI>$>16P]K##?]S,?8M.87AHXL<!D->_3P<W_TZ&/_\nMX>XG=SW\\3X+O)K&4^)4(""D!09JFR&8+(21*:K192>0@H"@<D50$*V.^6^4(\nMPY`@"%!*=>L'W1JBI$2H;M+;W)+9#(3$&.UYRQ^_AZWK/ZY/+.LK.LLTETY\\\nM_=[[[OWBP,"ON?GY5^K]!YDLBIRBR+T0`N<*BB)'*448A4112!!T@6JMNV`$\nMV"(GS3*LM4BI`$&669(D)4W3%R5GN[)SA4-)11B&Q%&$DK#8Z7\\#;]G\\'VD7\nMO9M/S%%MGWKHT4=W?69R\\M+FJP4/()4.4#H0WGNDE&BM<<Z3I1E)DI"F&3:S\nMY'E.X;JK':QLJ5IKBB)'"(CB%=F52B_*+@P(C$$I2>$*TBPE31,Z2<C4YG=?\nM0JT\\L7K?%!?HY:.'#ASZG2U;KCQVZ-`W7C5X`&UMBG?.FW(5[[O5-0@CS,I.\nM%(8!)C`HK9!2X)PCS3+2+*,H',:$""#II"BY(CNE7I2=L12%(XPTH0F0!#Q;\nMNX*%C1?+GB=/LC5H->=>./J9G;M^[R$A;@`.O38"@0E7<@"45D1QC%2:(B_(\nM4DMF,D)K<85;Z7\\T41ABHQ"C%45A\\0BTD41G9!><D9U<R0EK+4F2L&=QB*<W\nM7$[IN07>HMHN7YSZPO>V_]DWRN4G@'M>$W@`:6U*9A.\\=Q1Y09HDN*+`!'H%\nM4$00!BBM$4)0%*>ED)$7#BD5WA44A2-)TY?(SN8Y;D5V86!HV!Z>6K>5L%%P\nM7=ZBE)SZUH,//O1?QL=NL.WV7[UF\\`#:!"'>>X00@$=K@Q`2:[N%JBN%@"#(\nM825/`M/5/WBLS1"RN\\IA$!*%$6$8H,)NX9-"GB%7+66\\M;F7%YX5V*7DX-XC\nM1WYW<L-%\\SMV?.*?!1Y`VRS%>4<4E@"!M1G:!`BZDM):(94$(7#>D^?='2C/\nMN^VW,0&^<$AC2'R;(NI0'\\PH>A+*HH?5>AWK*Q=2"BK,S9YBLT]9-;3,CF-/\nM[]Q_8,_!R8O._6>#[T;`A'CP0BH\\OJM=TVVE7>%6M.^[A*3$&$-H`A*E<"XG\nM$6WDV@(UEE$,9Z2E%!T9>N(15O5N9-W`5M96WT`ZOTSZ[+.4>X9HS"Y@HJ:#\nM_5[KOM='P-H45Q24JST$)J`H"FR64811]]9(=.^^O(>B<&0V(U%M7I#/<V+D\nM,,OCLX@X002&:K2*T>IFQGJW,%K=0#4<1"D#0I`&.4-ON@@_V('QW=0N]E>^\nM]V,W_784Q(^^.=I\\<*1G=+Z5MHH[M][YF@B(M>LWX;T?UR9XH%RIK:_U]A''\nM9>)2]QQ<+E>HU,J(LB.M-FF4YUC2L[1%':$4Y6"$@=)&1FN7,53>2#D81$D#\nM>,"1BP8MCK+$?I;RIVED,V2V0]K)<+E#"MF4J.<#%3P9!]'#I;"\\L[?4<WCC\nMF@WUY4[#?W3-;_QH`JO73N"<&P_"^(%*M7=]$,9$<8EJK8>>6@]%?T)[[2F*\nM6H<\\R$`*8C-,7[R1@=(E],63Q&8%M`>$PXD6F3I)2QZDI0YCY3R+4Z<XMNLX\nM81RAE:*P!:/GKV)DW3!YGI.D*3:SWA5N20GY3*C#':6P]$@EKNP:J@X=_:U5\nMM[;NR^_A>G/#2PF,K]L(^#%MPNUA%*\\O5VJ4RM7NRI>K'(GWL3M\\D&JIPKHU\nMF_E7FSY.K#:C9#]2&*0`\\.2^B0]FR,/#I.8PN9P%:6G,-&@MM`FCD&-[CF,3\nMR\\#J?L8FQ]!:8P)#:[&%4@KO/(4K&!@?(/<YF<T*@3@EI3P0FO#QP>K@(T:;\nM/;VEWA<^_."OI`OO6$#GA<45A3!!>.96(5LY4N91@?>>PA8L+=99BE,N&+D*\nM[RLL=RS-)&>^]1Q.'V2YV$.[<XR@Y"B7RY3C"I$IX6+/J=DYLL`R,#I`GN;T\nM]O?0-]!/'$4<VG&(D\\^<I-I7I6^PCR(O&%\\]SO":86QNU7QS?G1Z:7K4"ZXU\nMQF1*JA=.SIW<=W//S=L^]_W/W:?#,`;O,Q`-FV7$I1+E2C<"<1QW#_`>$."\\\nMIYWE&%6@C2`H+`_O^SR-;!=CJ\\<9&APFS&*RW-*ISZ&-)E`!ZRY=Q^#0(%IJ\nMI)!,Y]/</7TW`R?[&1$C]`_TTUQJ,;1YB'6;UI'F*5.+4W1LA\\A$7+#Z`D(=\nMTFJW@IE3L^=.S4R=VVPV=LS,S=ZG`1KUN=F^P=4?<\\[=VFZUKW).#'J/U,I0\nM:'?F$KYPGF92H+3#YHYV5E!O+G%LZC@G7YBB4JXP/#3"V.HQ5HV,4C85'(Z.\nM[7#X^&&DD<S+>7:F.UDTBXA(4#,];!K9R.8++R0>BCFQ?!(I);6XRG#?,!))\nML]7DZ/11YN;G6&XVZ+3;I#9#92GZ^6?V`OA5XY,/.%<\\)H2<\\)XW%GEQH<WL\nM6#MJ7H1F0Y<`-%*'R@NRPI-D#BD-41R@54#A'-.ST\\S-G^+0X1*#_8/T]_61\nMV)23BR>9:DYAM<4;CU#@A6?1+_)H\\1C[CQR@)$I,C$XP-CQ&/C2$ZW6T.QV6\nMZDNT6BW:G399FG9;F2Q%2K5RI`2>>G([0`?8^[9W?F#O=[[UE_`%T-\\WGQ!"\nMW(GT""EII@52=@FDMD`90QS%:!4@E41)A902*02+]47JC7JW31>*435"L]6B\nMU6IA,XO+'3@H?,&B6V1)+I'.I007!_3U]U%?KM/I=$B2SDK_E7;[K30AS3*4\nME"\\2.-N^\\ZV_!,#L,WCM=P8RN%\\J+M8F[&^F3B`*;.%)K4.IH)LKTB!EM^V0\nM\\BPB*[Y2$BD5PP,"FULZ68<D3RA<@?...(S9L&Z2S>=?2*54IMUITVJW5@!W\nMSQ%)EG1_5Z*@SH[`#[)*.6;Q3Y>W1[\\>_;S`;@B#_FL[5OQ<X=UE6>[ZL[P0\nM2@>4HA@I31>L4BN@Y1E"9_R5<:4J2#D`6J#*BH&1`<X;.H_>J(=.VJ'5:M%)\nM.BN=[6G0R4H$3H]E7BGYRF]D/\\PN_]+37'1.C1,+22DO_,8T]S^3V,[/)NT_\nMN$SX??U2&?$2X*?]EQ-ZN:\\4FS=M8JA_F&:K0;O=IMWIT.ZT5_RSGNY_FR3)\nM@YG-?E=*\\?BK)G"V;?B3@P3B:^3\\0DF[W]E@U/S;M-9O5TI=JJ2JRA]`0JW(\nMZ47@+_KKSUE'K5H[DZ@O`WS&[R2=IY,LW9:FZ3<"8Q:76XU7'X$?9M=\\]:TT\nMLCHE5:HII2[32K]'*WV#4FJ]5$J]<L5?&8G1X1'"(*35?CF!SFF_GJ;)U],L\nM_6_[=N]_>F+3!(<_U?V0\\KH)G&UO_]L;\\7@IA!S76M]HM'Z_4NIR)55)GA4!\nMI5Z:Y-5*#2&@=?:J=W^+)$D>2;/T\\TG:^;92RNZZ9?=+WOEC)7#:/G#_!TC;\nM'90Q-:74-4;K#RJEWZ:4[/4>LC1%:4VE5.[>!DI)DB;4ZW52FY&F">U.9R9-\nMTR^F-OU2%(8S<XL+[/G-[[_B7?\\B!$[;+3M_DRQ)`2*MU)5:ZP]KI6\\H7-$_\nMO[#`PL(\\M6J-*(HY-3=+%,<(09$DZ0-9EMZQW&H\\%`:AV_[OM__0=_R+$CC;\nM;MOS28!`*76%T>97E=)O;S8;O4_NWL7TS!23DQN(PG`A29,OI%FV32D]ER8M\nMOOU+]__(>7]B!$[;'4?N`.]#K?35Q@2W@/^Y(T>/Q/7&\\JXL2W^OW6[?:XPI\nM[GK/-U_5?#]Q`@!?7-I&:G.\\IVRT?L?QD\\>W/'?TR)^52Z7#C7:+OWO'_W[5\nM<_U4")RV_Y'\\.<U6DX7%!7G'NS_K>.JUS_'_`,'I$&U=>3H$`````$E%3D2N\n#0F""\n`\nend\n
105920
 
6614    script_write_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```,(TE$051H@>V9:XQ=UU7'?VN?Q[TSXYFQ[]B.[7$>N&D;\nMTJ"D35*%QJU*$A[E(P6DMH``M2B(0E#$AQ0A/M"*A@`55<O[`Z(@5"0D2A2E\nMI`W%I$Z=.$](XKJV8SOCQ\\0S'M]YWGO//6>OQ8=]SID[<3W.)(9/W=+6.?>>\nMU_JOYW^O#3\\8/QAO:\\AZ%__AD?WLV+5##KU\\J'7L\\-&FJEYTCXMBHCC!Q3%1\nM'..B"!=%B',XY\\`Y!$$``\\P44PM'[U'O\\=ZC18XO"M07N:H_+XA^^?._\\_8`\nM//0W_X2JW3`Z.OZW9T]/[VQ?:)N(8&;A87%!\\"0ABMX((,(YAXB`#`(HA5=%\nM2P#J?26\\:%%TU/O?%9%'5)4_?W!]$/&E+GSBT_>S,-]F>6GI(_FV;.^FT6$6\nMYA<`8V1XF,@Y)(J"T'%,%,6X*`"0R.%<A(A#7*6C`,',@O"JJ)8`"H_Z@BS+\nMZ'84,?U-]7Z?B"Q?S@*7!'#VM==X^HE]T<WOO?W]6:_+]AV[B..(HO#\\Z&TW\nML>?:2=0,1$KA@J:M$E8JC8?WF1EJ!.'-`@`?0'CO,57.S5[@^9>.D)O=ZHQW\nM`<]?#D!TJ0O;=DZ2INEXUNO>YXMBTCE'%"44A=+:/,8[WW$U:9*0)BE)DI`F\nM<3BF,4D\\,).8.(Z)XRC,*"*.7'GNB%Q$%#DB%^;KLQ?HY_D0<%"<O'#[WI_@\nMX+<?V[@%3`T1Z6>]WA<6YMN;AT=&BHFM0Q\\2<;\\X/3-'M]<G31*,R@I!XQ@8\nME256K5!-K:?ARZ.9X=4PA.90D^65CJC9+>G0$-G*RKH6N"2`9[_]'P`=X*L`\nMO_'`'P.<1OCYA>5.8W&YP\\26\\>!&QEH0I?M0"5_^KZR>#_Y?>&.EF['2[=%L\nM-G!1A)G=V%M9'A;G.NL!<.O"NWA,B<A"/R]HSR^5&655HVH6!*VU+:4U+IYJ\nMD!?*2B]G?KE+IY>C!L/-)E$4(\\[MB:)XJY/U1=P@`)MUSLV8P=S"$EZM=H%*\nMHUIK5FJM>S4*A=P;O<*SDA4L=OLL=C(Z68Y7ZF20I@EQ$N/$38B327'KBWA)\nM%WKC$.=0U241=U:<NVEAJ4/N?2A6X8X`$:/P2N&-7`U54*H,9/@Z?0:?1QR(\nMUI:)DY@T2>AGV8B8F[R<7!NP@'#\\\\(L]<>Z,<X[E3D;6SVO->U4ZO3[MY1[S\nM*QE+O9PL5W(U?.5*$@06"94:YX+FZPG..=(T19R+Q+E)%UTR46X,0!3%O.>V\nMO;@HFA(7D>4%O2S'J[+2[3.WV&&AD]$O%#,IB]CWGT'P-PHOI46$-(T1<8#L\nMCJ*$^__@+]\\^@"]^]K<(&5->%^?PJBPN=YE?ZC*_W"4OE*J8(1*$=`YQ@58@\nM#ES0O)3"AZ-;6PP1DB0)-,3)9'=ER:U6\\XO'FXX!"'&`V7GGQ*L1G9]?0J(8\nMB:)2!GG#++6-A.MFF`2UB3E0K86WTH4`XCC"10[Q<E6<I@U$NE<&0/A86\\3E\nMB$19[D,)@#H(A<K/5V>M82OO,$K-!W"K-22\\P[FHY%(R)B(-@2L#()B=)1')\nM1*19>"V#.+!-UEC!#;B1JZN7`)B"#EBJ=I]PFZNH.+))Q#76X\\P;J@-!H[*,\nM2%]$*+QB@4R$`!P@=96/U\\%;4FSJ&%C5OE6SK!TB4E'Q480Q60?!ABT`Y")2\nM(%)67W`5XX1:D%40T8`;*6(VD(%*$`P\\7[[+10Z$IB!#ZUE@8S$`8*(@*I0`\nMM+)`904N<B.)(BC]FXJ"BV"RRH>L/*E^!ZU+A$@L5PQ`X/LJ@E:R#K+-2@`J\nM,`-`Q+GPB*[Z_:KPU;G5)BB34B20K"?3QKA0G>I6_=W,T#(.E%5.-/A,7<!*\nMWZ_I=H4`NX@8EN"%RRAYHVRT&E;A6;6`K;I`Q?]9"S8\\:1?1Z8J]AO^LC@-`\nMS;E\\UP.?3/_SHW=_ZGOW7/_0\\9MDKWUR%P_N##=LR(7*]Q8(1?U?R4;5#"FG\nMV8!&U1!34.J@KZ^O8;.&UAV+"HWXX_.=X>03=WYZ/!WZW+:I<T->;/<#7SM[\nMX.81_(8!B!J&Q9C%%9Q*D#<*)6:(:LCY7A&QL(!71<M[=`#\\VO/`I[)DL?'*\nMKO3/GKSJE]Y]:-^_-']ROEBXL<<_WM7"+QQ[2Q8P@,3,4JRLP.4'98W@(3N)\nM*GA?P:\\[$:8ZL+@O%5`!4\\,4BG09>]\\+PQ_8VK[YNZ]<QX%G]_+8\\(]DK0]_\nM:/>>EQ?2LZUNGZ?NW5@,E)EB&$BMK*K51^M.P\\#TJGBO%(6GJ!I87O'J\\26(\nM`$0'K*`4VN?4CB=9WGJ2Q>5I?NP:XU=_KM<>NF'HJ7=%K5_IY^U6W.T!&PSB\nM\\$$;,[,&&%63J^KSF`Z"\\!<UKOP`B!I@=;\\/TQ2.Z\\OLS_Z=_8</<VJJ1W-A\nMLW_J?TY\\:_C\\>[1W].R??/RO[GO]Y"NAX[*Q2AS\\=*>I-LT,)Z"J(!J8I09_\nM)]0ZC$#V4%<^;L$"%8CZ6`(QI9]YGGUMAB-)1BLMN/FJZW7?H9?V/_'U#RZ,\nMS^NW]-#?_^L??N0ELN(K&P-P_V?_H@K4'686888,`!"O(#[0!O7@RW:B$0!5\nM-4,]WA?XPM>-K<IJ5GB>.0G3P[_`35.[Z4T]J\\]=DSWSZIF[OVN]B:]U#WW]\nMF\\]/?%CSV<_4<KUI`*I&Y$!-MYN%)J\\34.]#@5(?-.U]S8=<J?6Z\\E8`BA)$\nMZ5+>>U#/D:F"1]UN+$^YL7,KIX_;$W.M=Q^^SL53]SWW4X_]]I[C<.(S:^1Z\nM\\P`*S^Y;;N;DB_^]W;2LI0:^U'RHLKY>^X8"9?4*K"I0ICH@?%&V%3TSLWT>\nM7MK*RN@0=YV;X^K&/,.WI(^>Q/UU<_%<JH].PXG9B^1ZTP#,E"-/'VPD2;++\nMK*1"I4;Q#A,_P'&$FG0ZI5R"A<)6]4.+RHT\\*TM]'CDUS,F)"=Y[>HX]19LL\nM.J?7W9">O59/+7[A[^[ER6]\\?[G>/`!5Q&Q<5:]UJL%]+`2DX<*2L%Z5!=<1\nM9Z$[735]!YJZ(2L5%%G.OF/"<ZU=3)Z=YU9=(BO.T-HERX*=6'\\#8$,`/,`N\nM4[]#-<*)A`T*J1:YY8I*0`PL"D4-'5AM#=8*[]&BX,57"QX?NIK&[`IW]I9`\nMIVGM4D1X7;V^=CFY-I9&88^9C5.FT*!]"1:HZ;&$F#:'B`86BJR)@5`S"EX[\nMG?%POIVNPITS;<8;LVS:D9&DD&=Z7+V>?\\N=N5L_>!?+BPL3M]QVQZ]__)?O\nMG1@9'?,'GSSPOM.G3L68K@4@JWQ>#5QDB`TL':6B^255,,_"A3[_-CO&S.@F\nMKG[N-->/+=#8LL3(J"/K]3'35Y)F(\\O[_;<&8&AXA.;0T-[Y^?;OS<Z\\WO#>\nM4^0Y0?N"F>(+OZKYDD!*R4!=W<!:W:$Q4\\R,O%?PV,F4PZWMC#Q[AMN299JC\nM;<:W.8I^CGIOJOJR]?M(7EQ*Q$L#^-BOW<?RXCQ)VGA_DJ:-TU,G:<_-T;XP\nM!T`429D._<"J*YQ7/:AZJ3^X^C+#O.?`,>/`YDGBHW/<42PQL;W-Q*3#?`AL\nM55TPU4,&?/%S]VT<P)8M$VA6R+;)G=?MON:'N#`WP\\RY<PB-T#&0T"9I)!'-\nMH2;-9H-FLTFSF=)HI*1I2B--:*1AYT9$Z.>>HB@X\\-(BCS<W4<SUN&-^GG=>\nMU>&Z&T>0J&!EN4,_\\*CC9OHJETM!EP+0VKJ-NW[ZH[SP]'_E4R>.<>;T%",C\nMF]G2V@D8G6Z77M8G3A*2-"5.4N(DM,6C."&*H[!K66_V!29[H:U\\Y?Q.%M.4\nMVV>G^>&Q)1JM);IY3+Z2D_?[^*+`5)]9.K]X8:0U^M8`C(UOYM7#+]J6+:V'\nM1>3N1G-XO+/2KQ>)@4(7>%4*KT2%)^KGN(%M5E?W08.+.83ECA]JQ2Z10]/L\nM(<OC;1>ZPV,1O6Y6%K9"U/OSIOK5T8E1R_+U`QC6L=$_?_,91"06>,?,N=G6\nM]PX=-N_7!E2]3QQ7F]U!\\Q*5>\\3.!7<307V1].:F'TP<'VA?\\&>^LW_F3^_Y\nMV9N^DR8FI?`!0%&TM?!'1<1_Z?/WOW4`5W+\\S,<^A<&V;=NV?V/SV*:9[DK[\nM][_TY8<.WO/CM]KCCS[WMMZ]_N[!%1JS,]-,G3C2ROOYM+CXCX8W;3YZ</\\^\nCCA^=_O_X_!4;$?\\'"OM?^4,,"E"UB_8`````245.1*Y"8(+X\n`\nend\n
105921
 
6629    social          begin 644 internal\nMB5!.1PT*&@H````-24A$4@```"`````@"`8```!S>GKT````"7!(67,```[$\nM```.Q`&5*PX;````&71%6'13;V9T=V%R90!!9&]B92!);6%G95)E861Y<<EE\nM/```![9)1$%46(6MEUF,'$<9QW]5W3W3TS.SLT<27^O</A;+43@"4A*$HBB"\nMB$0HXA`/")"("1(/(!01A41!!"(>>,@+\\.8$>$$*4AXB(`B"HUC@Q,9V#GL=\nMASCQFMAKK[WKG=V=JX^JCX?JGIE=-B(2E/1U57=7?]^__O4=U6KQTCL>H``-\nMZ/H;SWU1B;I5E%((@(`(^<7=6R,(`E:PQ@DBB(`U%K&6++/]]R8Q$K=3:6QZ\nMMGW[-]X";"ZB<@#:]T,_.O#T>;5A1P.MD"QS<\\2`$<"XL;4.B\\U`<+W-Y]E<\nMQ*X1&7RS=/[D\\CV/W5R`T/GJ5;3OYP?5EMT-09`L<9--"EGFE(L=&+!9KG"-\nM0024<D(AY-]:![BQ96?]V4?V%Q-\\`#^H:*H3.Z6[3-998>[883943^'YD*6%\nM7H52'FTS1O7J6_#\\(#=:[([EU?)'>7!ZC%YF"3SWW'HEK#%\\864?7]\\ZQV@H\nMJ%)EBKSI,!KSM?8\\)`WH+>-+RJ:I7<S.;T(R\\)1&C$8RA610UTNT9HY@DU[N\nM'P9!.%[:S3=?'6,NAD0%M*Q/2T=T*''WPE]YX-I91OT>.';[]&C/+Y>LR2R]\nM%L1M2+IH&S.Y:Q>S\\U>!E/"\\$)$R5DIDMD0]B%D^_1IB4@3%R]S,GOTA*XLM\nMHBQU_J,]4(K[+OV1![?-4F&PK6)2^@P@8JUD0M*!I`5I&^(NVB9LVKZ#<Q<B\nM=%#&"RJ``V)LF5KHD[U[%$EC?KM_AMFFH9HE9*TV$J>06>Z>^S/?N>X]RBH!\nMFX+)P,1@4ND#D"*\\D@[$'=>;&&R&IX5-4]MY;P;\\($)[-9`(L67$5J`T#J=?\nMX\\F/S'"G.4FKE6%[*;;=XZZYO_#0C>]2"U+GS"8%DSBGLF:8`>L`V!1E,I3-\nM7&]2E#4$OF;3U#;.O-,B"&OHH`Y4$4+PZYCZ-7@7S_"+6\\^R<^44\\4K*IUJ'\nM>6C'66I>YJ+(&K?ZW+BR61^`;PLT)G4K1R':N%`2"_@$98^K=M[`S/%3;-WU\nM(?`KB*?!\\_&J8^!O)WSW$'MOBWGRR$6^>],*H^4,C'%Z;0Y"C&.YLRBKPA!!\nM85(7_TJ!>*"UBUNQX/F$4<#FW=OHM#O4M^_`>"&Z<07B!VAK4:9-</@`3]PQ\nMF3M;GC_(<T72A6X3XA6PTO<!WV2Q`;1++D76LF`]T(Z!'`E!%.'?N!LFI_""\nM$//F$9)7?D]P\\6W.S5SBBGL_QY()J9E%/#$NY)(N]):AU\\K9,$Y=P4":=-SM\nMTAQ4$BB%$(2N,BCR#P0IC:!V?09OPS;,OTZ2[/L=R<O/$YHV%Y92)K[T99+Q\nMJWGXE:W<EN[G*S?,.X=..HZ-7`]6"@".@?ZHM0#=)6>\\%$$Y@J`"I0H2CI.^\nM?1YYYQG,^=.8F9-(NT5EI,I\\NT+]OGM1C0:/'-C*OJ/S'*M.,6HO<\\^6YH!1\nMAGKZ#/0!J'[5,PDD>1_T$#^B^_<WR=YX/:^7'I1"RN$HR\\T6P:T?1D41CTW?\nMPI\\.GJ4>E5B*%3\\Y\\3$\\\\S?NWCRWIBC908T`I?MW8@9%IQ@'->+7+Y$>GH92\nM`X)1\\.J4;$"G+20[MG+E!GCJC3K/'[I,+2ICC,$D,<TDX/'IC_/B;&.H6-F!\nM_B(5%\\Z@1%!B*7K*#7K'>R0OO8[RJA`#72'H"MVNHK-MG,T[&I"EW#/R#VX.\nM7L.*A\\U2,`:5I5Q.(AX]?CL'YD9SW86PB@'7ABDJC]![.Z"W[QB4:I""]!1^\nMSSGU\\O4C3&ZO0)I`%G-C/>7QW=-<:Z:Q$N*+P5."3\\I"6N,')S[)X?E&7I+S\nMTMS/A*L`&*0\\3G=FE/BYHW@J0G6`MN"W+;TN')P<Y\\RUD[RT.,*AI3HG.@V.\nM7Q(N9F4^?\\U)1NUI8BJ(THC2:&6YD$WP[>E/\\X?9C8.M^(\\HR#/BPBF/I1>.\nMH*ZH(IXFLPZG,C![59V)+4)Y\\1R^!^-5((6H9#D;9TR$=>Z:.,:+%U?PM";4\nM!FL5)65HI15^<_IJ/GOEZ2$?',XR>>H=W;A$[<Y1I-U%A3Y**U"@1#%9[N*-\nM:\\KAD(8\\J4U%,=O"178&$7=LM"@$$8NQBL0JNIG/=>4+;J&.=P%D`$"4$(3*\nMEQ;^-77,14&,004:M#/HBR)M"T:!U^=.^M=F+T!4R/71,HA%;$9F%5WC,599\nM86MYR=4'4:L`N)NT.X=?VD@T!D&(=\\,$TLOR\\_+`54H"HH%`KV+`BB*J>M2*\nM<Z$(M.8PG16T9ZGH!$P1CKJ/O,^`E,+OJ\\[E7Y-U%7X(2J&*PZ709P$1MX4B\nMJ_92`Q%#37E0'0>50FL>3.'H_41DA[?`+G]OWS.UI[YZR)M[ZV>D\\5C_9*NT\nM&M;;/S\\,T0_#6/JC$>+638Q-NJS:6A@<SY628N%JZ,>D^#E1:V1MD_<9K\\8!\nMC/[T$[_$"[[&V*1CH;7@&-!>L_GHT2O)=U.&I`A2\\P$D^V_/F@\\??("D^ROF\nMST`X`N7:X/\\BMUEXUUH`'P3(VKGK?6.;CQ[90])ZFH4SKM+Z)7<NR-E;RT`!\nM8CTP]@.\\&Y[3U]7\\X;$]I-VG6)ESSJGZ42"#^%H?Q'K@WN_=>O/ZTOS1B?M)\nM>WOI+1>+9ST&AMMZBO^GUOSQ/^_'9'O)DG49>#^C_T^A^<2I^Q'[K<+@OP'#\n33-I\\2K+<&`````!)14Y$KD)@@N_'\n`\nend\n
105922
 
6615    spreadsheet_48          begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```*CTE$051H@>V938QLQU7'?Z>J[KT]/=WS]>:]%]LACO-A\nM64C@2-A\\2HA5!!&+*)N(B$6D[+)((B&Q88642)%@8;$`-@@I(*$LB(C$R@L0\nM6:``!MD+DB`3(^S$>>]-S^MYT]W3W?=6G9-%W;[=/6_F&2,+&<5'*G7=^NIS\nMZISSKU.GX#UZCWZR2?[ZW\\8(8%"IX=4,55!`K2T*AK5U0RW7S2"I8:S'Y3F6\nMYZ?5/".MYK9C33?6-\\MK&5Q,)YR=C9B,[S.;GJ?E9+3TH>3;?_KY*P4((B!"\nMP/A],7Z)O`X8F4/+`ZW]D\\VBMC',,K-&^VN`@&E;;]?!0+IEUXWM<,JJQ^[N\nM'JF)$F-S(=QX<30:?0-XH_?L;[-XY2^W-?`W+Y\\A(H6J?K,(\\AO[/9^9ZQBS\nM#4;7.W]YS&J'4ZO!I+0[WVK4++=I7J,;9VO-IE:+==-P,9MR?G;*Z>FICN?I\nMW__[M?_XPS=>>_7K_<%P>?;W?[36@!,0#!/AJ!]X_H.[.'G[MI@9-&*"J$I,\nM1DQMF^9Z5$BI_=;M_I3HVI.6Q-1G61_RRG?-38L;/U-5U9\\41?7,O1^^_N7'\nM?_/W+M[\\VZ]D`;P#$;`$3M;E[9(3(3@A.",F1W262S*\\6MMN1`&ON02!J.!5\nMB&)=>TS@!8(O.3X8\\I&C`1]X[!?[WQ[L_<X;1\\=G__*MO_N#9S_WQ_;*GWV>\nMX$00`>_^=XQ?)N_R>I($$4-$D79S9%42B`@.:\\?81CL(@HCB#'K]`8<]8]\\U\nM+)]YLCS8W__"DT]]]$41>?D5.A,"D[R+[P0Y$0J_TJ;#2=Y]$4-:IEVKC8[I\nMEH\\LJ"')D=38&_3YP?TIS?(,FR^HS)XXVA]^\\GP\\>OEWO_X:(>^88$F[1=X)\nM$H'@LS:<"$X4MS+3Q!;S3@67%"<057#)6J'AB:-=;A_T26HLFL3I=^[RH]/S\nMCSE?A1_>N1O#2F+O!">"`4T=J>NTP8QT)01'43A@`\\,O,6^7&A1#$516]78N\nMN20S$M*ME\\Q(JB158LK%N4`1/,/]`R:I*.<74RG+JO4!P,1P`IJ4%U[X!U25\nMJBJ8S93Q6+E[DK@W5C[S6T_SV<]\\&(`[\\\\3WSFJBTJ*,7?%+]]U$HTF72T:L\nM)I&_HU+7-?7%.<OIF'HR)EX\\X%._^CP?^<!/47C/SLXN.[U^UK)SK0]H5K>J\nM\\=KW'_#\\\\Q^DCH%_?OF$?_WNA!],$O.BX.=GVNUL8\\;Y!E-UVF:T7C&TR7#<\nMKF_VU5V?4#=]ZIA8U$OB_():A3)(!AL'F'1FRLIWLSD)\\W3`U[YYCU=/:NXL\nMP0X'\\%0?CG:0)_<[`8(3^I7KF"I6S+C,6$A&XX0BZ9IIM\\&T-XH-@0J_$E`H\nMO:,I"LJ=7>+>(;W!D,()W@E>!)PA0)"6>[="(1%F1WM\\Z]7[\\,0AW.S#C;8<\nM[6#OWUL+X(6=TA%<9M9'PSO#.\\4G"!&"@Y#<1I_ADQ%B/AM6WSXJWK7C8X9U\nM[QS.]]"JI.KU"7[CG&I-/VQ#1U;/IS[Y%$__ROMQNP7T<[%^@?8"OW:X'KY?\nM.)X9EEUXL`H9NH!N\\[L+(=;UU9BF]9=F98+)B*W6\\FD-'SKPA%8#V81:I+L,\nM?TZ$7_]9^(7%I(64?+"4OD!,L!I>'X&8Y*CL"@HY..GF;^^18&)KO/9@(4>U\nMFB2'(6JDC3##3!CVCDE6$%QK*:WO/B2`"'SM>W_!5^]\\E4``!5'!FT<R#B(J\nM#"^&3,H)9AMXN.I;#)F$A_M0&#0#%BR(1$BM@*N^.&1N%\\0<AV,*EHQ]?\\`+\nMG_YSGGS\\IW%.UJ?Z50)@$#42B=34J&K>[4TFDV#1F(=Y#K.3$5/$S)`DI#HQ\nM88+IM@"F1JH3R:4L@$),$4T*"5*3F,N<J'$])QDN"$*B##G>\\JW?7FE"BO&)\nM&Y_@XT]\\',,X/1TQ'`XIBJ(3T,PXOW_.S>.;B!/,C"8U@*&JG)T^X/#&`2N`\nMV#S8SL?G'.P?4)9%WJS4H):A^>STC,%P0"@"VIXM28WYQ8+W[;\\OF\\\\*1J_5\nM`-"3'GW7QWN/\\R5.AG@INGN!FF$IL*@/0-S&!<=(25G4@=GRN+OTU&JMXPK3\nMB6.JN_BBZFYBJW&3<ZCB$.<+HAKS1HD*S>*"VT>>,CB"M":$Y<C@*A,"$)>=\nMM,:8&A"W8_L'2V,\\5]16,7Q[ZB9E=MY0VH)D0M+LH$GSB;QXL"2=!]1E85=S\nMDT*:SK%22%*T_Y7G%&G!+W_8*()T(4^.6*_1@/>>LBSQSK%753PVZ%&696<*\nM9LJ)S3B^.<0YMRDWFI3[HX9;MV_F('%C71'AY)ZC/QA25A67@>K^J.3@\\("R\nM*+?F3*=3=HI`X5UG0M<[L4!*B<5B@0N!^O57V7GI15(1P'L(`7,>30[='T+P\nM&))-1)48E=EDQID73!5-BJ;<IVJ,Z\\1.51$05!7;[%LLN;.L<:HMK!J:E#H4\nM//>E+U+</'YK)\\;`.4=1%+A0$&8/"-_Y)T(9()10%E@H"5)2E."*`D6(4;$<\nMN4'T*`F-B924%!,I*BDIRR3H8H%K&E)48FK[HG(>*HJF0>HF.W!,I"81=P?$\nM^0(OK&'T6@$V5"<8[J//XK_\\5X2RW)01?_<N[N@0YQQN0Y4I*<OQF%NW;W<H\nMU/F5P+U[)^SN]*C*<FU>;64TOL_AT0W*HLB-EB=-9S-ZPSW,VE#BK4Q(-8>T\nMWCFF,7'6@+.,)"NG'%\\8;U;9QKN00;,3GX\\3?5VV>:/-T`%F#VI\\%9#@UIF*\nM-MR8/ZCQ=R:8"SGL:.=1S_GT<T..R`+XEOMK#[)\\<0EXY\\![%N(!1P)BBSI3\nM%5(4%+>=54C";`F3>4Z3K#(1J4VA+&:*U8IZ[7"^0YQI(ETDDLA&]@**E*BC\nM=I;Q:!AM!WGO<<XQ*`*/#W<HRK([D<R,$W:Y<;Q&H16I*J.]AINWCJY$H=&)\nM,!@.J:IJRR0!1B<%>WO[E.7#*#2H"HR5";4WQ$>9T'*Y;%'H/VF^\\2)<0J&F\nM,>)N#Q="/O4U(T9,RO2BIBC#U2BTC)P!@37*K.:>Q43/N`*%`L]]\\4O(\\8W6\nMA%;"O84)N5#@KT,AUR/T7(="*=\\KD:C0@&J#MLBSA4+JL*;!-7$+@5),3'S)\nM?+&X&H46"V"5('@4C&Z9D!">_MC5*'1R0G%\\C/.^,ZN5"=6C4V[=/+X2A4Y&\nM(P:#(555;ML/<#(Z97]_[VH4VMOK[@#_HX-LN5SBG6/21,97H=`T\\6:(F*1+\nM*)0X'R_IQ^M0:(FO/!+B.A^Z0J&S*7Y'KD:AGQMT*-3ECKC&B<NR[%#(%04+\nM%[B,0G,))'6HR18*I23,4V`RSZBSB4)1C68A:&,D]S`*V870+)1(VLJA]C"2\nM^#;'U,+H=;&0(-RZ=8NF:0!XZO''6%V?MC)`MW>[;,#E/!!V")<0:/UQC%V3\nM/C-;_]=Z6H;+@T$?U=8'WBJ<KJIJ"^;>+90TYU`?'0N]RVDS>_[_5`#!N4>%\nM$N]RNEX#`G4T[D[B.Y:A?GMDW7L;K)_G;"-YG!3J9'B7!VS&0B;PTD6M_K]&\nMR_30VO\\'M/G^MDZ.;23(R.>)&=X[><E,3`#YQ^]/5VL$WKGG@;=-(JT0FT^U\nD]G"]%=0T/S&\\1^_13SS]&(ZC*<&F'$M%`````$E%3D2N0F""\n`\nend\n
105923
 
6616    spreadsheet_write_48            begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```,YDE$051H@>V96XQ>UU7'?VOO?<XW\\\\U\\GHO'=]=CITZ4\nMIDWB-'$;MP55$+4A;=*0(GH!":0^($6"%Z3RP`-J5%`1?8A`M(`*A:((%6B4\nM2!4B5D0H`I$;8)<FL>/42>WX-K=O9K[[.7OOQ<,YWV4FXU1MG;S0)6V=??;M\nMK+77VO^U]CKP4_HI_?\\F^=9_UQ%`(8V*C:K$"!&(6I8(BI9U)6I15X40%64X\nMKIBCQ?S0GZ>$_MQRK,:1]56+M13:S0:KJTLTZBNTFNNQUUCN69?P])\\]N*4`\nM3@1$<"@/B7*,8AU0"@ZU&*CE1T9+U)%A6C"KE$\\%!#26]7(=%&2P[+"Q'$Y:\nM&6-B8ALA]^)]WA9FCR\\M+3T*G!^[]5?HGGQDHP8>.[&*B"0QQL<3)[\\P-68+\nMY@:,Z0BCPYW?/*:_PZ'48(B4.U]J5+5HB\\4:@W$ZU&PHM9CE.>U6D_7599:7\nMEV.]$UXX=_;TE\\^=/?/-ZF2MM_K4'P\\U8`0$1468K3J.'IS`R(]NBP6#B@_@\nM8\\0'Q8>R+19U'R&$\\CUN[`^!07N(*3Y4Z64SG'Q)33/9?G.E4OFJ2RHW+ESX\nMP1?W?OQWVQ>__?N%`-:`"&@`(\\/RHY(1P1G!&<4'@S=:E*#8J&6[X@5L+(H3\nM\\!%L%+SHH-T'L`+.ILQ-US@\\.\\F!/7=6GY[<]MOG9^=6GW[J^!\\=^=Q7],1?\nM/H@S(HB`-3\\>XYO)FF(]"8*((A*1<G.D7P*("`8MQ^A(.PB"2,0HC%4GF1E3\nMIDQ.[\\;Y='IJZK?F#UU_7$1.G&!@0J!2[.*U("-"8OO:-!@I=E]$D9)I4VIC\nMP'3)1R&H(L$0HK)MLLKK*TWRWBK:Z5)1W3<[5?O$^NK2B<]_\\RRNV#%!0QPL\nM<BU(!)PMM&%$,!(Q?3,-;&#>1,&$B!'P43!!2Z%AW^P$NZ:KA*AT\\\\#RBU>X\nMM+Q^FS$5=^'R%>_Z$ELC&!$4R#-/EH419F10G#,DB0%&,'P3\\[JI(:)$A"C]\nM>CF7H@15`C)8+Z@28B3$B`]%,<:1.$MM:II&2-).NREI6BG/`*"B&($8(@\\_\nM_!UBC%0J":U6I%Z/7%D,+-0CG_W,#?SZ9]\\)P.5.X-1JAH^4**-;/!F\\YU[)\nMP^92(%8>*-Y]),LRLO8ZO6:=K%''M]=XX&>/<OC`.TBL97Q\\@O&Q:J%E8\\HS\nM$`MUQZB<_?X:1X\\>)/..9T\\L\\E\\O-7B]$>@D">]KQ<'.YJJLCS"5A8V,9GV&\nM1AGV&^NC?=F@3\\CR*ID/=+,>OM,FBT+JI``;`Z@,S)3^V2W,2>B$:;[Q^`)G\nM%C,N]T!G)N%0%6;'D?FI@0#."-6*&3"5])DQ!6,N*+D1DA"'3)L1IJV2C`B4\nMV+Z`0FH->9*0CD_@M\\TP-EDC,8(U@A4!HPC@I.3>]%%(A-;L-O[MS`KLFX$=\nM5=A>EMEQ=/^VH0!6&$\\-SA3,6J]8HU@3L0&<!V?`!3/2I]B@.%_XAOZ[]1%K\nMRO&^@'5K#,:.$2LIE;$JSH[XJ=+TW4;H*-3SP/V'N.&#^S$3"52+HM6$..;X\nM\\,QP^%1BN+&6#L*#?L@P".A&WP<AQ+#>'Y.7YR7OFV!0?*FUPEO#==,65VJ@\nM,*$2Z3;#GQ'A[EO@_=U&"2F%8TEM@JB@&9Q;`E$IHK(MR!7!R6#^QCT25'2(\nMUQ;4%5%M#%*$(5$)(V&&JE`;FR-H@C.EI91G]PT"B,`W3OTM7[K\\)1P.(D@4\nMK%JDP$$D"K5VC4;:0'4$#_M]W1H-]\\8^(DSFDW3IXO$02@'[?;Y&1]OX(@Y'\nM(VA0INPT#W_JZ\\SOO0EC9.C5MQ(`!1\\]'D]&1HRQV.U1)H.@7NFX3A%F!\\4'\nMCZHB00A9H$$#C1L%T*B$+!!,*`2(X(,GA@@!0A[H2`<?_7!.4(P3A$#JBGC+\nMEN=V2Q.**/=LOX>/[/L(BK*\\O$2M5B-)DH&`JLKZRCH[YG8@1E!5\\I`#2HR1\nMU>4U9K9/TP>(4<>V7E]G>FJ:-$V*S0HY40MH7EU>9;(VB4L<L?0M(2J==I?=\nM4[L+\\^G#Z%4U`(S)&%53Q5J+L2E&:EA)!O>"J(H&1S>;!C$C%QPEA$@W<[1Z\nM<X-+3Q:U/+A"LV%HQ@EL4AG<Q/KC&NM0\\36,3?!1Z>01'R'OMMDU:TF=P4EI\nM0F@1&6QE0@!BBD.:H305\\!MC^[6>4N]$HO9C^-+KADAK/2?5+D&%$(L#&F+A\nMD;MK/<*Z(YI"V/[<$"$T.V@J!$G*;Q5SDM#C`X>%)+$89S'BRXCU*AJPUI*F\nM*=88ME4J[)D<(TW3@2FH1A:UQ=R.&L:84;F)(;*RE+-SUXXB2!Q95T187#!4\nM)VNDE0J;@6IE*65Z9IHT23?,:2XOT7W^2?S*!::J-W-Q]^VH&(S&+000""'0\nM[78QSI&=.\\/X\\\\<)B0-KP3G46&(PQ*D:.(LBA8G$B/>15J/%JA4T1F*(Q%#T\nMQ:C4L\\!XI8)#B#&BHWW='I=[&2;&(ED0E/5DG&PJ<M/%UW#/_1,'C]S']S]]\nMA$ZEALN:6YN0,88D23`NP;76<"\\^@TL=N!32!'4I3E*2%$R2$!&\\CV@1N8&W\nM1`+1!T*(!!\\(/A)"I!>$V.UB\\IS@(SZ4?3ZR[BHD>8YD.3$H2S3XA]OOYO3>\nM&SFZ\\#WNDVDF[G@`D@J5K(6YF@GU52<HYOI;L5_\\.UR:CLJ(O7(%,SN#,0;#\nM<*$0(KUZG9V[=@U0:'"N!!86%ID8'Z.2ID/S*BM+]15F9K=325)6_#+?:GV5\nM>?LZW1<J_.?)#_'\\]`?YQ+;;N2[WU&82.DV_M0G%6(2TUAB:/K":@]$"2?J'\nMLMY6+E8*&Q^$#+$XQ.OU0#7VRKS1:.@`K;4,6W&(,\\-,11EN=-8R[.4&&.'"\nMU".LS;U$<[W%AP_,<_>O"J=/O8O%,QWV5\\?9><L<YT^M;&U"Q<7%88T!:^F*\nM!0P!\\"7J-*,0O!`Q&[,*06CUH-$ITB3]3$0H4RC=5D2S2+1Q@/,#Q&D&M*V<\nM]<_QTMHCC"UD3,5=W+)MAKPSQ=C:/(?GJVS;/L:E,_7BXG\\U\\['68HQA,G'L\nMK8V3I.G`(ZDJBTRP?6Z(0GV*,;*T+6?'SMDM46AI49BLU:A4*AM,$F!Y,6$\\\nMG>3S3[S.:^?;S%8"M^ZY@<MK/5;/OHM[;]O+^'R-"ZL>`&.V\\@.E"?5ZO1*%\nM7B%_]#AL0J$\\5_S$&,:YPNM')9;7OV8[(TG=UBC4\\ZP"#BW:0QS,7?.1_TB.\nM\\C^[[^4]E\\;IOO8L%^=:K%?V\\KE[#W+?1_?SQ(OK@^S)UGY@Q(2,2[!70R$S\nMAALS`Q0*Q;T2\\1%RB#$GELBS`86B0?,<D_L-"*3!\\TQS#U_YT"\\1VQ-\\H'T'\nMZ7*;\\5T[F%YM\\+YW]+!6R@3!F\\1"&TU(<#<<V1J%%A=)YN8PU@[,JF]"V=(R\nM.W?,;8E"BTM+3$[6J%3209\\QPJOG6CS^1(-&,L7/75[D]MV!3_[&9SAP:(ZU\nMM2;5J71P!S#FS:+1TI'U>CVL,31R3WTK%&H&+CJ/2MB$0H'U>H^JOQH*];`5\nMBS@_R&SGK9S'_C?GN]49CIQ?8CXTN3!A>'+%H\\N7T:S#IV[?PPS#&UF18]KJ\nM#`!IF@Y0R"0)7>/8C$(=<81HB"H;4"@$H1,<C4Z!.J,HY*.2=X68*\\$4WC;/\nM(D^=[/+<Y#3[7J]S5!ODDSGFP%Y>6/3XJ(RA!+%ECHDRG+Y*+"0(.W?N),]S\nM``[MW4/_^K0A`[1K8I`-V)P'0F=@$P(-7^;0<CTK\\(_?N<*?5B<87VQQK-O@\nMW=>G//#+-U.M)H.4O8@P/5DEQC))]L/"Z4JEL@'FWBKZ[NDUOGS6T&I[CBVL\nM\\)Z#D?M_\\=WLWS.SY?@0BQSJZ(7&;#GR;:"%A0Z_\\^02IWK"_A<O<\\=4QL<_\nM]DX.'-B:^3Z-9M#?-!9Z*ZG7\\?S!$U?XY\\PQ<?("Q\\8[?/2N>=[[WGT_=&YA\nM0C(PH;=?`U'YZZ>N\\!?+X%Y>YD[?X.Z?V<Y==QT>PNZ;T&#WV:P!@<PK5QK^\nMFF6H-Y,U\\/3)%1XZW:.[T.7.M56.W33.L9^_GK4<8B\\?N30-?VOUSW^(D`7%\nMFF+`Z)52!9YO9]&^NM0+;_ST3T[&B+[ZVMJ>+SS;/'(I6CFZ5.>F6N?\\X=NN\nM_]ZZI-2O=`?_WX;)L9$$&84_4<5:(\\^KBHZBD`<>XMK]'G@#O?]@-7S];Q[]\nMO5IEYVW7G5(.^N[RRZ^]\\IM?^_./??N9'W2,,8*4S-+_\\4M9-Z4ZR@P(BD;!\nMRUO)\\"A]^M<>Q+DDV;E[[]]7TN3^U95PX5^.G_O"Z9=>^:LTK80L>^S'7OMM\nM.<19EM-JM6>:C<;!D/>..[/XR=.O_,G7[KIGX2=B'L!>(Q[?E!87+G'NU9=G\nM\\BR_),;]875R^LRS__ZOG#USZ>WX_#4CRUNP8?\\'6#O1AQRH-!8`````245.\n%1*Y"8(+]\n`\nend\n
105924
 
6617    spreadsheet_zoom_48             begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```-/DE$051H@>V9?XQ<UU7'/^>^^][,SN[L[.^UO?;:3AS'\nM"4F<N$D(26DCJ`*$(J(@J`BB5.*_"#6(2D@()'ZH2)%`*$*"(@$"%5`)HA%!\nME+9!(0&J)HX<Q\\;!/V+'F_6/S:Z]Z]G=^?W>N_?PQWLS.^O:28-<)1(]TM6\\\nM=W_-.?><\\[W?>Q]\\7[XO_[]%OGJXB@`*D5<"KXKWX`&O>?&@:/ZL>,V>5<%Y\nM1=GHEXW1;+SKCE-<=VS>5WW?_*K97`K->HW5U65JU2LTZNN^4UOI!#;DU3][\nM\\IH&6!$0P:+\\GB@_1#8/*)F&FG74_$_ZB]>^;IHIJ^2_"@BHSY_S>5"0WK0;\nME7EWHD*1P<%A7))*FB9-8>R%Y>7EYX#SQ?V_0/OHWVWVP#\\=645$0N_]\\Z&5\nMGZ@4@TRYGF+:I^C&RE_=I[O"+O>@\\^0KGWM4-:OSV1R]?KKA69=[,4X2FHTZ\nMZZLKK*RL^&K+_<^YLZ?^\\-S9T\\^6ALJ=U9?^>,,#1D!05(2QDN6^78,8^>"Q\nMF"FHI`Y2[TF=DKJ\\SF?/J0?G\\G>_N=TY>O7.1Z2N1"<>Y>@)-?5P_,Y"H?`E\nM&Q;V7;HX_\\5MG_[-YL*__'YF0&!`!-2!D8WR0<6(8(U@C9(Z0VHT*TX)O.;U\nM2BH0^*Q8@=1#X(54M%>?.@@$;!`Q,5)FS]@0LUL?*+TZ-/R%\\V,3JZ^^],(?\nMW/W+?ZI'_O))K!%!!`+S?U/\\:@E,-I\\X0401\\4B^.-(M#D0$@^9]M*\\>!$'$\nM8Q2*I2%&BTK%)'3V[8Q&*I7/[]Q]RPLB<N0(O1`"E6P5;X08$<*@ZTV#D6SU\nM113)E3:Y-WI*YWIDABKB#,XKPT,E+ERIDW16T5:;@NK,6*7\\T^NKRT=^_=FS\nMV&S%!'6^-\\F-$!&P0>8-(X(1C^F&J6.3\\L8+QGF,0.H%XS0W&F;&!ID>*>&\\\nMTDX<*\\>7>'=E_1YC"O;BXE)JNQ8'1C`B*)#$*7'L^I217K'6$(8&Z,/PJY37\nMJRH\\BD?PTGW.QY(5IXI#>O,Y59SW..])75:,L80VH%P9H>;"J-6L2Q05\\AP`\nM5!0CX)WGF6?^`^\\]A4)(H^&I5CU+EQV7JIXG?GXOGWOB9@`66XZ3JS&I)T<9\nMO<8OO?<D51)W=<D0*W%D[ZDGCF/BYCJ=>I6X5B5MKO'X)^YCS^P.PB!@8&"0\nM@6(I\\[(Q>0[XS-W>*V??7N.^^W81IY;7CESF]1,U+M0<K3#D_H;OK6RBRGJ?\nM4K';K&C<5:A?X73S<W];W&L3XJ1$G#K:<8>TU23V0F0E`QL#J/3"E&[N9N$D\nMM-P(7W[^$J<OQRQV0$>'8'<)Q@:0G96>`=8(I8+I*15VE3&98M8IB1%"YS>4\nM-GU*!TK89U`8=`T4HL"0A"'1P"#I\\"C%H3*A$0(C!")@%`&LY-J;+@J)T!@;\nMYC]/7X&949@LP7A>Q@;0[<,;!@3"0&2P)E,V2)7`*('Q!`YL"M:`=::O30F<\nM8M-L;^B^!ZDG,'G_-(/UP!A,4,07(@K%$C;HVZ?RT+>;H2-SS^./[6;O0]LQ\nM@R&4LJ*E$%^T/#RZT;T2&O:5HQX]Z%*&'J'K?^]1B(WG;I\\DSY>D&X).27.O\nM9;LUW#028',/9"&4(]W5\\&=$^/&[X`?;M1Q2LHTE"D)$!8WAW#*(2L;*KB$V\nM(R>]\\9O72%#1#;P.0&W&:KV3C(9XQ?71#%6A7)S`:8@U>:3DN?L=!HC`ET_^\nM#4\\O/HW%@@?Q0J`!DN$@XH5RLTPMJJ':AX?=MG:9FOW.-CP,)4.T:9.2@LL-\nM[+:E95K:),UX..I!G5()1GCF,W_%SFVW8XQL[.K7,@"%U*>DI,3$>.^SU>Y7\nMT@F:*BW;RFBV4U*7HJJ($USLJ%%#_68#U"LN=CCC,@,\\I"[%.P\\.7.)H28O4\nMIQMCG&*L(#@BF_&M(,_;:X:01WET_%$>F7D$15E96:9<+A.&8<]`567]RCJ3\nM$Y.($525Q"6`XKUG=66-T?$1N@#1O[&M5]<9J8P012$H)"Y%-8/FU94J0^4A\nM;&CQ^=[BO-)JMME2V9*%3Q=&K^L!H"A%2J9$$`28(,)(F4#"WKG`JZ+.THY'\nM0$S?`4=QSM..+8W.1._0$WO-$U>HUPQU/T@0%A#O($]RAV%]78G<,,984J^T\nM$D_J(6DWF1X+B*S!2AY":,8,KA5"`&*R)(U1Z@JDF[G]6D>IMCQ>NQP^WW6=\nMI[&>$&D;IX+S68(ZGR%0:RV&=<L0=73M$NWZ.NTXI4U(4RW-P6F*@^7\\O[)=\nM/'1M'KQ9":WT*$_&6*_C@2`(B**(P!B&"P6V#A6)HJ@7"JJ>R]I@8K*,,:;?\nM;KSS7%E.F)J>S$ABW\\KXU'%ZKL&;)TYQ^LP[5)L=)+`$!ERGA<8=1BO#?/R!\nMC_'@_?=@HP@1H5ZO,Q!:PL#T0NCZ22S@G*/=;F.L)3YWFH%#+^!""T$`UJ(F\nMP#N#KY3!!BB2A8CWI*FG46NP&@CJ/=YEQ0V4:>__)`>/GN*UHV^Q\\]9]W'_W\nM#@JBQ(TZM2M76'AGCN5WYOFW6HVE8T>Y>6D>[72(;<2]O_H4X>3$^R<Q"L88\nMPC#$V!#;6,,>/XB-+-@(HA"U$58BP@A,&.(1TM2C&7.#-,#C\\*G#.8]+4I([\nM'N+;Q][BU1,7^,E''V'[Q#"MM766+RX0+RY12MKL'BZRHSC#7+/-X3/G67_C\nM%;;'=9+!,FFK32!LP.AU#>@Z0@1!,;?L)_CB5[!1M"E-@J4ES-@HQAA,GRN=\nM\\W2J5::FIWLHU(E3#I^<X^`W#_+8SS[&K;.3--LQG5*%TN@4DP<,@P5+TFE1\nM+I>Y?6V=%[_V31K;M_')S_X,Q@B%H3*J.95XOQ#R/J.T@3'44\\=J`D8S).DF\nM9;6I+!2R&.]1!I\\E\\7K54?*=_-X(1JSGY-GS%"9GV#TSP7(]IIUZSJQT2%49\nMB"!L*;[C"9H=5$J$6W;3F#_!GW]KCJ'Q*7[NP!!C9`8$N?;7W<BR@XLE,`:"\nM@+8$@,$!:8XZ=2^X5/"8S;<*3FATH-;*KDE2#\\:F+%RJ,KGC-CJ)HYUZ6JE2\nM3S.DB<GY34?Q3I%`*(Q-8Z]<Y,WS589UG#CUO<AX;QC-.P5!@#&&H="RK3Q`\nM&$6]'4E5N<P@XQ,;*-05[SW+PPF34V,]%%JZM,++2<)8(<0(#!<"1DJ&2E$(\nMK:%2BA@J6.)&R,APF3`*F9OK\\/J5$7YQ=IP#]\\PP8`.4;@CE)\\3W"J%.IY.C\nMT!F2YUZ`JU`H291TL(BQ-MOUO>+SXU^]&1-&-D.AU-'>LH?!R/+NV3EJLV.0\nM=)"X3;.Z@ENKTA;'FD])T@Y5[QC=/DNU#1'*Q;_]:X*O5SCP^:>0B?$\\A+H+\nM_3XA9&Q(<#T4,D5LT?10R&7G2B3UD(#W"3[U^"2%9H==6^[F^"O'.;=W)],#\nM!M^L45]<Q%^YC'<=XJ1#XAT:&`;*(ZS6'<N+BXR=>)/ET)*VVT#W@N"]8'13\nM"`EV[]W71J'+EPDG)C!!T`NK;@C%RRM,34YL<"&$]ML7.')JCD-G+_#P0_<1\nMC6_!;-U-I6`I%RV#48!/.DQ6RLR?6V#QT&%F;MK)8__Z-1K-)L7AX=X9X+O:\nMR#J=#H$QU)*4ZK50J.Y8L"DJ[BH4<JQ7.Y32#13RJC3C`>[<?Q<'#Q[B&R\\K\nMP[,W,5@:8*AH*14LE6)((6US[.0<*_-SG+BPRK8#'^?RT3K::?"9CVV@4._N\nMB.LD<11%/10R84C;6*Y&H998G#=XE4THY)S0<I9:*[LNZ=Z'.BTR,#'#`P>:\nMO''L%.??/8^=W$ZI,L)`:(F2!EQ9(*TNL;!PD>B.3[%BQUE8BBFB.`GR.Z8<\nM1J_'A01A:FJ*)$D`V+UM*]WCTZ8;H.G!WFW`U?=`Z"ALXD%YW,DD:3++;7MV\nM<?B-8\\Q?F*>Q<BH[<]B`J8DQ!F_:3JVVQJ[.63YWVYU,[-R%$:$R5,+[/`?>\nMCTX7"@4*A<*UFFZ(?.+!4>ZYZS:65ZK4Z@V<<PP-EM@Z/458B'CMQ9<Q\\R<Y\nM_D>_P[Y?>I+;?^130!:ZTO/`^U")[Z6(",/E(8;+0]=L/[!CC/:W#E%8>HLS\nM7W^>RLQV9F[=!VR^/<^/QA\\]";?.4GUW@:F%DXR>>9VC__CWK"\\OY[NP9(0N\nMR'\\_;&6O)87Q2:9_[6F2;;O8.G<8>_P@KS_W#\\3M=G8>R%?>;`HA@3A5EFKI\nM#;NA_F"BO>]M`#I[-XW/_C8#S_P*L^>.<N;U45X9F4;W_QB!R3KV<R$5.-2,\nM?3"WW''7^8?OK?I]W]^RRS#![?^TVA_XZMBN0\\_?NV/AN'WSWXO$[<&SD_=^\nMXC77Z:B((-]^N]Z=PW+C/@]\\8!')C>C[5%O<6]8W'KIE[*Z5,W^Q?;#P4^_N\nM?9"#]>"UEPX=>R)=7'K[-U0_/(6_6_GG/4(UY8Z[!O390KER^XO1#H[/+_[)\nME\\XO/_5@@/M()G&_?&,-'AZU;YYJRV_-FU)U=SD\\NS-T_P7X[M'R(R^_NV>8\nMAIKPAX?-C\\ZZ]KDO_'?SQ.,%],G.AZW9#9#_!>AA7-`:7_3'`````$E%3D2N\n#0F""\n`\nend\n
105925
 
6618    stamp_48                begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```-K$E$051H@>V8:9`=U77'?[>[7[_7;W^S+]I7T&HA9,`L\nML6,$40H,9@F8@*4D.%!QQ66[C$F,DU`IBKAB*A5C2"`$%\\0XF!B,PV)<D`B<\nM8(-8)6.$A$::D4;2S+R9>6_>O*77>V\\^O!DM-A!KI,CYX%-UJKMO=]_[_Y]S\nM[[GG'OB-_'I%G)!>/KL5E#:PK'8,<R&F,1MAI!$"P$.I(93:C9('$2+D&\\M/\nMR+!PO`1N>!V4LK"LT[&L:[&LCV(8<]`RB0I-4"!,A17WP1Q"1EN0\\CM$:C,"\nME[M6_AH)?.95T#J'97T.T_I3+*,=?P+*>V"B'R:'H#X*L22T+H*NE="R"`R[\nM3A0]3"1OQ1`'<'VX?]U))O"'+X/6:2SK#BSK>F*6B5N$R?V@?#!$LV<50A1"\nMZ(&2D.Z!CI5@.A"&SQ#)/T:(_=RSYB02N.Y%L&.@]29,\\U[B<1OI@CL"0H,I\nMI@AH0$$40>1#X$'@0[(#6D^!2$,4?IVQTLT4<IK[9N8%XYC_T!H\\/X?6UR*$\nM#1HB%TP;;`?L),23D$B#DP$GU6RSDQ!SP"U#4`7#`+B,?'81>D;89T:@)6V1\nM2UEKDS%QYJ%&,P968DKCAZ]F',P$Q`Z_$[$$AF$"&@.]T#98G[0%;'KI)!#X\nMY&:6]3ATI,U5I\\U)IH36H"">S.*DT@C3!A$#+-`F:&/J:H&(D4AFR/<N1L0S\nM("496Y"T.*WQ#Q>!E#,B8!W3UZ9D;FN<D9+;>MZ2#&.N9L=H1"3C=!5R%%+@\nM!B%5/R14"A.%B44FYM":BA,92?K&-;+JXYB:SK3!T)AL8?T#%DI%__<$A.;=\nM_57JC;`1-^"Z,UKX[NL5WBZ&'!S71,KAE.XL"]MB]&1-VI(&;JC9-1[QQH&`\nM'4,NGAO2%H<%^1BE"8^&&WI86J'43/`?(X'O7<"NZ_Z32*K=Q;(7+9N;M3:=\nM66#K09^?#+@,3KC\\>,+GQ9A)W#8Q#4$H-;XO$5K1GA2<,<\\F;VOV%1L,EUQD\nM$/51<!1A>!((`)-5'^5&6_>.U(?FM#NS0PTK.FU6]R8H>9H#E8BQAB+2`LL4\nMV";D$@:MC@%*T3_BLO-`C?VC#>HUST6JEY#`HQ><'`(JDO#3`WO>G9?>O*0G\nMN3'IQ)BHAT1:$+=-%K=8K.VU2<0,8J;`#32#)9^^D1H#18^1LL?8A$>C$8"4\nM/T.K5XXG(3AF`CQU,<XE3T2[!R<?_'E;_!.K%Q4*O@1?0KD*`R.:0((?Z2E5\nM>(%DHA92G/"H-4)4&(&4$J7^!2'&D3/?"(Z=`.#6?.BOO/BSC/E(2SIV8SX3\nM)XB:P$.IF_>1)HP4GB\\Y4/(9G?")(ME,*:2"2/P893\\""I[=,&,",_:=\\=O?\nM105RR;)%A<?6+&E9H831M+AL6CZ(%#57,E!L4*Z%:*6:N[A4.*+N73OGX8>N\nMFO/#%R+X(8JR%K#A+XX=ASE3`KKS8KJZD^,'AVLCIN#"=,)(^$&$[T4$042M\nMYK/G0)7RA#N5#T401IA1@T\\O>=*XX>R154[+O$NE7SS3$%'9LMFW<3W1@\\\\=\nM&X[C.P^L_6?8.VEF5[7?NFQ!X2N9E&WXD<(-%/W#=<8J_A1;W50%EY\\)=VRT\nMZ)RU`JU@?.`9BML?J#5*.Y[42M^)P:L"Y'E?.!D$`$Z[%_RHNWM6]HGYO=G3\nMI=8,C;D,%AMH?7AQ&@)Z6RT>_:OYK)P+@5]MMELIHJ!*:??CE/J?*@;UT8>`\nM>R3T&:#/_?P'#S_C*71(6JXDWV76)BLR%[>-"Z)(,3A<(PKE(<O'3,'"WBSK\nM5S:XXO1AI#>"#BNHL(+TBFC9(-EZ"JGV52F4>U;D%3<(%<6`/==OH/[IWX$'\nM?O3>PQ^W!]ZX!TZ[<90/7WS;A4/AZL="%4L-CS<.?Z`TRQ>U\\*$E!=8O>)E+\nMUM6(U-2P&C2@%2BMP4B`B..6=S(Q^+QT)_>_IB)UIU(\\@:`F))QWTPDB\\-)=\nMH#2F9;+$,KFRY!>N^K/GOW1J7VF6J-2\\PQ]JS9<WK@%9X:+YC[!B=AVIFNU*\nM:?14&J15,[HJ+4`X2*FHCVVG-K[3"[WZ<U+R#2GY;R$(SK_Y</?'M`_\\Z&\\A\nM'0>EB"O%6M/D]PW3O-A*9&9UM\\X5G7G)]N+125G<MIC?FV/'.V_3*OX+5:FB\nME40IB9(**252<H0*I#)1VD:3Q'8*":VX6'F-<T%_S_>YZ_9/\\O..3M3U]_R*\nM!)[]&B1L"".R4<1'39/K#$-\\W(S9!3N1PHX[F&*,K#5,$,XZPOH0BQGT'ZQ2\nM+AT@9P]@$:(T2-UT_Z$`I4!(0(*.0$;3T5>@I0#(`Y_)Y=BP\\0^XM?<3W*]?\nM^U\\(//W7X'D@([H]S>^:)M<*P1F&@6.8`M.0"%5!!V50&EM,(.41'A"@E&;;\nMKA)Y627E:&RK:6D1-:_3!`P#E`%"@1!,E92:5M!:DW!BM'<FZ.X,9CD)_QK]\nM.@^C:;PG@<>^`EIAA"&+;)O+@:N%8)EA8!E&<S!#*`0*0?/9-$`K"4H<=<[S\nM0\\G6G>-\\>'9(+-8,ITH="7`*ICY:IS?N6-RA<W8GG5T)DO%QD"YH!M&X\\`L>\nM^,X706OL,.1#EL4U:"X%Y@B!F+;*>VISMI!A&-/?C8QU-L_"@(PD(R,5:BV*\nM(!0(@U^8\\TU5ZK!*"68L2;YG$>T]O:3BHXB@#Z+*U$B\\"6AQ^A2!'_PEI#.D\nM#N[G/"&X3FO6`VV(7[;4>XJ`4E40+ZSA4^?W\\O:[@QPL"WR5P(@Y1")+J!SJ\nMKHF(A41'`(^BH^^U2)+M64U+SRJ<^`2BL059'6QZW;!`1PW0;TT/;;UZ/Y@F\nM"1GQ=<]G4Z6,<^3B^B`]TFI[AS1];SU#T4F1[UU!OM=BLBXI37J(8(#+E_\\'\nMEO+Q_,-6/@0\\!"T<DEUGD)OU<>)V@)IX#G]R!Z:=QW3.1<>RJ'"?-OSMKQD$\nM[TSO\\9;G`1I;&&*-D\\&I^AJ_`<X'S,UI%5/SN>'"KD&8F]Q)C[Z#T9$Y3$9=\nMY(7!+'.<CRP;X))E-<(`U!%]R`BT2)#H/(?<O*NP$TG\\X@^H'7P!TTYC9\\Y!\nMQSN(HC)4=_8;T;[[38('/64-.4:S!F!5)J$\\C-NUL+V8[5A*9.QFS\\`PHR5%\nM9P9RJ:/GIA"'*R!:-Y_WCD!YLAEJD\\*GD-R%8!<(L`Q8NZ#YOQ<=[@LLXJWK\nM:%GZ61+Y4ZD??)2Q7=]&Z#KQW"J,U%Q"646/OU(D&/A74]7N-4)V^B:Z<.'A\nM`H95J\\.U?Z_#Q[_6.UR8OYJ.[$KBZ6WLV+Z--_MKM*5A:6\\SRAQ9N9G.TUP?\nM^O8W@1K&T8M;:VC)02$-KCOE10SBV:7D%UY#JO,<W-*;C/WT;XCJ[Q+/S">1\nM7X<2T"AMF]3>P+\\+6;E;1+R&@>R]])>7GW7U;4!R)8V*-]09F"0S[21;3V?9\nMZE:2SDMLV3;*COVP;C$LZ#X,WC2;ENP?AIH+\\=C1X*>E/0M:@B\\%L50OV=D;\nM2'6=2U`?9."E+^)7WL)V6DD6SD78&1J5O9YR!S83E;XI%,\\+`W_15>\\?/TR`\nMLQ?7<!MNP;3S%R1SLQUA))J+*E6@U2GCN36>WP;%">@N-,%J!<4*[!]KAGW3\nM;'K)-)KU7=-H>J6G!5*9%IRNCY&9<PE26XSL?)C1OD>009U$?CEV9A&A5X[<\nM\\EM;@FK_5R.O<7LDV>Y6D2LVO3_X0P3.6AA2JZB^R=*^-VJ5TES3SLRVG8+`\nM<##L`BESDJ[,)(-C\\-9`<ZX##(TWB5A'@C>:FY4A()U.,FO^"C*]'T,96<;V\nM;F9T]Y,$?IE$;BF)_%)D&.AZ><<[_N3NVT.W=HO4>DO0(%AW`_S3TQ\\,'H[(\nM1C_2#E=>)MC;KSO:>CIN[)ZW^D\\ZYYS:&;-,W.HPQ;TO4RL/,#:I&1R#I`V]\nMK9",@S":'0G1[#$6BY%O[:*C=S&)9!*WTH]7V8-I&J3R<TADNM#2):CM&Y3^\nMZ`.H\\%OU(@-.*ZR_Z?W!?B"!:=FT%L:&,!:OMLYJZUUP2^_\\5>?GV[IB@3?!\nM</\\K3([UH;6B5`,OA(X<Y%-3"]@0))PDV99.G'06Z5<(&B.8IDDRUXV3Z00=\nMXM<.C$NO^&](_Q]UQ-O"1%WTU6,#_KX$`'XK"\\O7076"?&MW=E/G[%,^WSUW\nMR5S+$@P/O$EI:`>&B%"Z&1K3#K2D(99H5J`-`[3TL&(VJ6P'B70;`HE?'ZZ'\nM[LC32.^;0O,R$%UYV\\R`3\\M['BGW^O!J/_3$\\#:_ZF_)F`=?J$Z4"L)(+,JU\nMS;>T2%`I3Q`&(::82@$`T]1$H8_6X&2Z2>9F(<P$C<F1H#K>_[Q7&[LY]*._\nMBR1[*B.HC7<>'WCX%4]D5ZP$KT&JO2?Y>QT]\\[[<WCO_%*U"RL4!O'H)K7PL\nMHTY+3I%P'`H="[#L.*%7EGYC=*L*ZW<+K1\\W#"8:=?C"MXX?^#$1`%C?`\\\\>\nM6,C5:W8O+G2TW=3>,_]3F7Q;.O1=)LLC!-5=M.0BLJT]Q.R$]ANC?2JHW8?6\nM#XDX0\\J%+SUPXH`?,X%IN6(EN'7BK9WV187VKC]OZ9AU6N![HC&^C71:8MOQ\nM(4'T;92\\+Z;8'0GT+0^?>.#3,J-#_=D]<-Y9)KO[Y.Q<:^YS=CS^1S$Q*IRX\nM_KXAN%MKMB)0MW__1,/]93FNLLIER\\'WL%K;.3>7A:3#3Z0DN..I$P7O-_+_\n77_X'437:/$%6J)X`````245.1*Y"8(+W\n`\nend\n
105926
 
6619    stamp_zoom_48           begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```/O4E$051H@>V:>;!D57W'/^?>V[?[]MYO?_/>S#`[LS,P\nM!I!`&65QE%'<2D-`2$JB%2N6&B-QBUNLBDM908U"*5%11`(8`^((&`8%81!F\nMWV?>F_?>O+W?ZWZ]]UW./2=_].`,<41G0/PGOZI3I^_IT_?W_9S?V:OA_^U/\nM:^(E><M[=X'2!I;5B6$NP33F(XPD0@"X*#6!4L=0X01"!-RR^B5Q"R\\6X-W;\nM02D+R]J(95V'9;T*PUB`#N.HP`0%PE1840_,24+Y-&%X)U(]BJ#)U];^"0%N\nM>@:TSF!9[\\.T_A[+Z,0KP=PQ*`U!91+J,Q")0_M2Z%D+;4O!L.M(>1<R_!2&\nM&*?IP>VO>)D!_F8;:)W$LKZ$9;V+B&72S$-E#)0'AFB]604@`PA<4"$DYT'7\nM6C`="((MR/!O$6*,6S>\\C`#7/P%V!+2^$=.\\C6C4)FQ"<QJ$!E.<`-"``BE!\nM>N"[X'L0[X+V<T%JD,$7F2W>3"ZC^>;91<$XXU]H#:Z70>OK$,(&#;()I@VV\nM`W8<HG&()<%)@9-HE=EQB#C0G`._"H8!\\&:RZ27HL])^=@"YI$4F85T0CXB+\nM?E-H1L"*G4C1D[D9!3,&D9/?B4@,PS`!C8%>8AM<&;<%W/C4RP#PID=9/<^A\nM*VFN.W]!/"&T!@71>!HGD428-H@(8($V01LG<@M$A%@\\1;9O&2*:@C`D90OB\nM$<YO?'TCA.%9`5AG5-L,6=@>9;K8;+]L>8K9IN;0C$2&47IR&7():/H!52\\@\nM4`H3A8E%*N+0GH@BC3@#!4U8]7!,37?28'(V;..*GUDH)?_X`$)S9*Q*O1$T\nMH@9<?V$;/]Q>9G\\^8**@D<KAW-XT2SHBS$N;=,0-FH'F:$&R8]SGT&03MQG0\nM$87%V0C%DDNC&;B86J'4V>@_0X![KN3H]?^##-5`ON3*50O2UHT7Y=@UX?&K\nMX2:CI2:_*'D\\$3&)VB:F(0A"C>>%"*WHC`LN/,<F:VN.YQM,%9N$OAR@S5$$\nMP<L``%2J'JHI=X],U2<7=#CS`PUKNFW6]\\4HNIKQLF2VH9!:8)D"VX1,S*#=\nM,4`IAJ:;'!ZO,3;3H%YSFX3J*4+@WBM?'@`E0WAR_-B1<Y*/+I\\7OR'N1"C5\nM`Z061&V396T6%_39Q"(&$5/0]#6C18^!Z1K#>9?I.9?9DDNCX4,8[D&K7[^8\nM#<$9`_"3S3AOO%\\.CE:^NZ\\C^H;U2W,Y+P0OA+DJ#$]K_!`\\J4\\DA>N'E&H!\nM^9)+K1&@`@EA&*+4'0A1(#S[A>#,`8!FS8.A\\A-[4^;=;<G(>[*I*+YL"0]"\nMW?HL-8%4N%[(>-%CIN0A9=C:4H0*I/@%RKX;%#R\\Z:P!SCIVQJM_B/+#Y:N6\nMYN[;L+QMC1)&J\\7#5LO[4E%KA@SG&\\S5`K12K54\\5#BB[EZWX*[OOWW!3Q^3\nM\\%,4<UK`ID^<N0[S;`%T]V9Z>N.%B:G:M"FX*ADS8IXO\\5R)[TMJ-8]CXU7F\nM2LT3^R$)@<24#=ZY_`'CW9=,KW/:SKDF]/(7&4+.63;';[@"^=U'SDS'BSL/\nM7/`M&*F8Z76=GUJU./?15,(V/*EH^HJAJ3JS9>\\$K6XE!6^Y"+YT@T5W_QJT\nM@L+P%O('OE-K%`\\]H)7^BC!X!@@O^\\#+`0"PX3;P96]O?_K^17WIC:'63,XV\nM&<TWT/KDX#0$]+5;W/O)1:Q="+Y7;95;":1?I3CX7Q2'?I+WZS/?!VX-8<``\nM?>G[7]C]67>AWUC[V\\CVF+5*.<Q$;>-**16C4S5D$/ZFY2.F8$E?FBO6-GCK\nMQBE"=QH=E%%!F=#-HU6=>-M*$IWK$JCFQ=+-;Q)*1H!C[]I$_9VOA>_\\[/3N\nM7W0$=MP*Y[]GAC_;_"]730;K[PM4)#%5:)RLH#2KE[9QWO(<5RS>QC6OJ"%5\nM*S*AM@B5@=8*H16F9:-%E$;Q"*71K6&S,O:LDNHK2G$_@II0<-F'7B*`I[X&\nM2F-:)LLMD[<5O=S;_VGKAU8.%/M%N>:>K*@U'[YA`X1EKEYT%VOF>U3D//*-\nM?B;G8I2J$AGXV(9+>Z)$?V:63%P2RI#:[$%JA<-NX-8?"4-N"4,>%P+_\\IM/\nMOOZ,UH&??0&245"*J%)<8)K\\E6&:FZU8JK^W?:'HSH8<R#]_4Q:U+1;U93AT\nM8!]98P_CC=>S<W0%.P^.4JQ,@@@P4*@`3&RZ<YVL[]S!BK;]&(:-[>1B6K%9\nMN8U+0=_C>7SM<V]B7U<WZJ9;_T"`A_\\58C8$DHR47&::O-,PQ&O,B)VS8PGL\nMJ(,I9DE;4_A!_RFM#Y&(P=!XA6*I2L5Y"]OV]K!S8!^+5\\QC3?]\\HE:`](LT\nM:P5F)N<X/J1YI+B.0E>=C=W;T$JA0P,@"]R4R;#IQK_F4WUOX';][.\\!>/`S\nMX+H02GI=S>M,D^N$X$+#P#%,@6F$"%5&^W.@-+8H$8:G1$"`4IH#QPJL7[*6\nM[<.3[!PYPNO?\\&KF=R3QO2+ETB"N/TT\\T:1[&2SJ#=FUSV/W[,6DK6F6M0VB\nMM2+F1.CLCM';[?<[,>]:O9V[T#1."W#?1T$KC"!@J6WS%N`=0K#*,+`,HW6<\nM-81"H!"TGDT#M`I!B>>=\\UPOI%AI<FZ_PT._.LS5FR]G65\\;C<8,C?HX;GT(\nMQW")63Z6EJ0S"GMUP-/[LNPM7,`Y[3/T+<K1W>,0CQ8@;()F%$T3_D\\$[OP@\nM:(T=!)QG65R+YAI@@1`((>!WIE9O(<44IC=(&.ENG84!)24].9/"S!CIK@Y6\nMS.^ET2B@E8O;G")F>,0MGYAPB6@?K22]*<&2>6T,CIU+;%Z=1<NGP1L`63[A\nMB9V`%AM/`/SXGR&9(C$QQF5"<+W67`%T<$+@[S4!Q:H@FMO`7U[>Q_XCHTS,\nM"3P5`SO&TGD1I@L%NOLZD=(G5`$Z]#&41T1(;'QL7"Q5QS0L8FTK6!Y;S&Q=\nM42Q-H6N[T(!A6*!E`_3>YUQ;S]P.IDDLE'S1];BQ/(<C.+GZOU!2ZF0:F=0,\nM[-U"WDF0[5M#ML^B4F]U'SL"]9J/K<$-?*0,$*'$,B*MG:F2&*9!LFT5V:XU\nMV#&'RE">;"9-J-.$SB5H,XL*CFO#._"L@7_PN37><EU`8PM#;'!2.%5/XS7`\nM.5'AA40+T<H;33@Z"@OCAYFGO\\3,]`(JLH>L,)AOYIFG-S$>7<3TS"P-UT-+\nMB1&&@$6H(EB9U:1[SB<5CQ!6GL#W?%RW@U@T0CJW&$F1L'KXF"&/WV[BW^$J\nM:](Q6G<`5KD"<U,T>Y9TYM-=*Y#&(,>&IY@I*KI3D$F<%!R&+='/W8!HW7H>\nMF8:Y2FNJC0N/7/PH@J,@P#)@H9/#RIS'@1T'.#Y3H#MI@%0$9@^)>1<2S?7B\nM-G;@3F_%L01.Q^7,-2UJQ?VD<T_FW9G1'R!KMQD!AST3G;OJY`6&4:O#=?^F\nM@VK=FC*3Z^E:?`TKUUQ,,I-DYPCL.PZ>#_H$@)3/SRLU&!AK"8U:8%L0,2%B\nMM<K:,M!M[6)A9HP>)\\6V9_90;`KJ9A_-V!KJ;H/)@;N9'GT,5W=BMK^.0Z,6\nM`T,5)D9V/Y!4!S?3J'VH4>=0YG7HW%7/'W[FO;^$E='[J);G-F9[SGM5Q.G$\nMM'/D<CEB1I&#PPWV#(%C0S9QLN6A%96A2<B76Z*M4Y)Y8FKMZX#.5(`I)TGT\nMO)K!@2*3#8&+HEG>2U`^B!""6&HQV.=P:*#&_OTE]NX]]*NG=XS<=._3J_>_\nM__-']9=_>/KYPP2X9%F-9J.9,^WLE?',?$<8,;1PB"=RM#MSN,T:6W=#O@2]\nM.8A&6A')EV%LMC7MFZ>(-D4KMPR8UP:)5!NISC6T=\\TG8F>9&LDS-GB8>JV*\nM#!-X09;\\M.;@_EF.'"IP8/\\!?W#@Z,?3Z<SC.[;]'!7^[CLO$^#B)0&ULAJH\nM%(_OJ)6+"TT[-=]V<@+#P;!S),P*/:D*H[.P=[C5UP$F"RV04UO<-%I[?T-`\nM,AFG?]$:4GU_@3+2U,>W$*D^2E=')_%8'UY54"D$%"8;:G:J6B\\6JKN*A=FG\nMHXZSHB,1SRX9V_OTMHG)XFH!,R\\$\\-A^"`JH]6O5X.#!R0<K<Z-UWY>K['A'\nM,F)G,>UV0K].NU/&L>'P>$N\\8T,L<DJKGQ`>M2-T=/4Q?_%Z['@[I>E]%$9^\nMB=^<(Y%JIROCTQ4=H,,Z,&J;?'W.Z_QJI5*Z;79VYI;V<Y;\\Z(I5B\\[=M*+W\nM:NO8_M<N$&+HLYLN/;)EWU'*IP'XK67JQ@M@=@)CV7G6Q1U]BS_6MVC=Y=F.\nMGHCOEI@:^C65V0&T5A1KX`;0E6F-#<,`80AB3IQT6S=.,DWHE?$;TYBF23S3\nMBY/J!AW@U\\8*H9?_SPC^-];EV)]W4>O>U_(_<<O'F9DK7]OKENX8V;/;/)!;\nM<O#Q[7O?T9--[[E]VPXF3Q>!4VW7)/08Z/8>-3HQ7'BP4AK+-YO>REBB/9O(\nM]N.Z(=52D:BIB%G0\\$!I<")@V1'L6)Q0NC0JTT@9$$OVXF07(8PH]?)XO58<\nM_+%7+WY0>N$W/9^I"_\\1_8TM)_V?-[R=8WMV3D</;=_0[<XM,5/93M'5O_`7\nM3SW[R,KV;&-OK?$\\O:<]4HYX\\,P0]$9P'W[&^W7&G'BL6BKFA!%;FNE89&D1\nMHSQ7(O`#3-&:4C5@FAH9>&@-3JJ7>*8?8<9H5*;]:F%HJUN;O3GPY)=ER+'R\nM%.J&K_RV[U(CX(UI61_U.9@1X6O::K-MHF?!4JN]V[QS]X''_MRQPT%Y\\BK^\nM!<_$@V5H`"O:F)H>KVQIU*:&?==;D<SU=22S?<C0))`"I4VDE-B6QK1BI-H6\nM8T82-&O%L%(<V=FLSGQ2>L%GE&9WM8Q\\S[_#@[M.[W,X``O!)U8S\\61!S+83\nM7)F1S:A8L'Q]>R0Z<<?PV,Y[/OMI9O0?`/"<'<C#0H?@WGT+=GWK<T<>;M;G\nM8E8DMB+3WF]'XVTM$'>.J*V(I;I0"ETIC@XTRODO!*[_D=#@<;^!^[[;X*'?\nM(?Q4V]4$VX6'RAQ:YHADMZR^THE%H[KWG`U?_?#-SUZUYMSC6T?&49S%F?BM\nM:Z%9)]K>;5^=Z^SY2%M7__F^YXI&83?)9(AM1R<%\\GNH\\)L1Q:`4Z(_==:9>\nM6O8?"P6ED/8+$_K;_8GHYLD5E["MI)]\\8,O6:S../?*CIG_FURH'\\M#E$*Y=\nMQ<'C0Z4MOE=1@=]8:8BZ9PI^$,KP`X&O[PQ""I^\\!Q[==W;B`?Z[#._M$LV)\nM0.Q-(U^5J!<[AT-KOM(Z\\KU"]:%7FNBSNA<:K<(3!S4K.JB4"MY6TZAOLR/<\nM;5E\\(Y",??Y^].,'SU[XJ98S!==U6_E=-3WIIG)79C*927^N^.V?S[G[%IHO\nMU7\\E_LCVZ:5IZMJ(7)HV7K,@=(__PY[&P3='T7_G_:F5O03VOX8VZ?-H&J1K\n,`````$E%3D2N0F""\n`\nend\n
105927
 
6620    store_house_48          begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```-@DE$051H@>V82Z]EQU6`OU55>^]SS[G/ONU^V$FZ;<=.\nMK$@.MB&1$"."I41"_``&,.4'\\".8(3&!(:.($1)B&JP,("C8V&#\\C-LFMKO;\nMW?>Z[SWWG'OVHUZ+P=[G<6\\[8AS))=59JU;5J:KU7KO@Z_9U^[K]5C>Y]>WO\nMH%E?,-:^;*U5$0$1!$$$0!C`!KZFB<AR<L`'^H`L:2++_3;^O]Q1+O]7UG36\nM=!!0)>4DFO.;JOJ^V]N_0M<T?W)PY<I?C2?;V3K7'W;AHCU<,W<19\\FL;#"]\nM^=\\-VHJ9C;G^LLM]E^>M&=L41@R!V>S,S,_G?YEB?-_=NO4TIZ<G\\OSSSW/E\nM\\-"XHKQTP&4IKB4CER_\\FRZVL?XQ`6S.73ACS9"(69T9O.?!@R_X_.X]B<'C\nM1ELCRKID/!DSF6Q3E.5CFUU@YL+AFQ+M&3.73?`Q*0_CI2`NKT4>.VM3:,%[\nM)I,QH]&(:`5W='1,US9\\^*L[[!V<,AJ-UA??N.B:F<TQ%^>^HB^96OK*_[?^\nM*_?<8*IM&AX=/R3&2--VN+.S4X+WA!CP74=959?4>'%3-C9=2_@R<Q>U=-&<\nM'C>7B_:^@7_%N.M:SDY/B#'BVQ87/_^$X`/7GK[-?BXQ30N:0;6'65>XJB++\nMN;Q<T\\_):GU&4T)31%/LYP"S$7%646K3SC><>VW[RXC4XP;(*>,Z#UE)*>%N\nM:V`>:EY]\\7O<NGT;]1TI!G((Y*^",9)C0#?H&CVAK@GS&;$^)W4-&@*2$X)B\nM`"M@`2.ZPB_``7<"]M(:MX'7&>X'\\`KS!*Y`&16.3]]\\@^;C#RE%>ILU@PH'\nMB"J:$RF$7C+&8JQ!C$6J$46U17%XM1_;OF/[D$Q.V)R0G#!#MSEA<AQ@/[8Y\nM876-NV'L<L(-]"(FZC;1I8QD<%8S$@,WOW6+;]R\\C@D>'22M,1";FG9Z2C<]\nMQ<_/2%V+:,:(8`8'-2(8LW966=%[<[`"!NVEN(2B:YH\\/N>6X\\TYZ4W(>K!9\nM,5EPBF*<X_,/WJ/Y[&.L[]"4,-9@K%W;H[68J]<HK>OIUJ[@9F?HV5C46A`A\nM;4A^+?T-J>>$&22]DKZNH1NTH9K(,2)MPN3<,]!X3QTBN2Q9-"WQT1$:0B\\U\nM$:P!NY2R#/B*]A5S0\\2P&UJP:._(@R8,CT-!!\\]6%$@;,`Q[&.`\\*5.O=$L?\nM^&1R2$R)+\\\\#(U<POO$L615G#<;852;LS40NX$;,FF:6IF0&'[J\\SJQP,8(U\nM9O5_8P;:I77&&C3WYEI6%<%W8"S'IU-"C#1MBRNOW41\\1SF>4%05.X=7:=J6\nMJG"XLD*5X8#EYH_WQ^?LXV/;X_8K:,OUU@[_&X1GK<6W+4)F=_^0DR^/V-W;\nMI;EWGQ`\\<GZ.>_;;S].V#;M[!Q16^.X+W^/^PX?LC`JJ[7U"C(-SF@M1:44S\nMZ^1D+JU9:NLB33:<W5S,N.;BO#&&L^DIQ(Z#_3U.CNZSNSWA=#3"&B%ZCQM/\nM)H@(D\\D$0V+_X(#I^8+MK8*MW3V:MEU7L_0V^EA3155)I`O3BO:)R%PRC=^D\nM07I\\F;&M[;60DU"6)9HSA2MPSI%2Q%F+VTB#%,6(F"*%<V`LJGWHDO7MA[RH\nMCS.DVN/"*D,KVD_G/I\\:[2\\H@_L.J>T2;C?VS!1%299^/)Y,4-55&8(([M'1\nM0]JN)83`>&N+C^_<H:X;K!7*ZLO!!Z3?4_6"*<C*B3?,994`-\\QC]7'"2AJK\nMWU6=M%%J+$4ET+4=.0=.IC/.3D^8S68\\/#HB>$_3+'"?O?X+8DJ,BH(M9WE0\nM%'W-LRR-AZ^@Z]=N\\(UGGNWY2(F<$BE%0DSD&$AAV3W)>Z+OH>:T_B#9L,7-\nM6FC-'%@$,="9Y5)%5#&FCTA1X:SK*%&.?,(]<7I,I\\K$&K8+B[.6;"T`14X4\nM.2&^X^7??9E7__@GW'WC=7S;$MN6V+7$IB6D2$PMH:O[FNA\\3G-Z0FB:OOA;\nM)L,E7-=T*QP!IU!F."_`CBU!+,%8O+%D$2I-D!*SD'`Y<R4+[LDKN]0A<F5[\nMPO6#/;;W]BEV]Q`1TOR,/)O2G3QB7#AF__U?_.W?_0T?A8P3I3""<T+A#*4S\nME,Y2%CTLKCIL<8V=L<5HZ&G.4#C!&=,G["'1(8IUCNNGGJUW[O)PY+A^[0!V\nM]F%G#W;V45=@%S.ZV93CTRG=^8SM8@N7ZCDY*SYUS.L9[=$7).L`*'.DS`GC\nM6]2WI*XA[!B>>NJ`%[__"J.J&JK+C"5C)&-(&!*:.N:=\\.35;4@MUDB?;363\nM4B"GA.9,RID8$^7.`5MW&^Q[=W&:,.=G=/4"?_R0SCHRPD@C&B/!1R1%0M/A\nM#G9W*$/DZF3,S8-])GM[V-V]WOK.9S"?$DX>8363VH;*";>_=8,__;._0),G\nMA984.W+HR+$EQQ:-'>?3AWSRZ3V>_N8UBJ)`4R"TY_CVG-"UQ!B)*1-3POM$\nM.9ZP-5*2P*BP'![LDK?WR=M[I.U]U#E</2?,IIC3*?Y\\CA0CW)?G"UJ%'#U:\nMSYD\\N-?':]859DJ)JR&@74MA^VQ:ST_HZCGD`!J1''NH$4/"BB*FH"P*)#6$\nM=@ZAQ4G"E!;G##$F0NRCU6A4,1I%.@.U"K^>U=AY@S$/L"+8(:(MLO*@RXC`\nM%_4"]\\5S+Z-`N[5%/#QD>_BP+XH"5_20G`EG7Y*;,PIGL`92Z-`<(/>7WKS\\\nMB@%;4!@E+$XH!,K*H6I)64DI$P9AB,!H-**J(DG@P<WG^/7SOX-SCJ(HA][C\nM(4:FTRD&>#2;X5YXY0<T3</!E4.NWWB2K<EDE9^6236T+3(_(;<-A>TU$WU#\nM3@')`2'U#)`PDK`D)+>H6*JJP'J+-7:(R$I*2DP9.Q2`H%35B+**=,#ADT]Q\nMY0]_TB<MU2$%*:JP6)S3E??QWC,N1KCQ9'N5Y<:3":.M,3DG4LKDW'>`U+5H\nM5U,X@Q$(OD4&\\U%)"`F1A.1(:$])S0G*/J/1B.0+K.V3?LY*RID04^_8(JAF\nMRJJD+$NL@<(YW&0'39&4$BEGTI![T)Z9G!*JBDNIOVR,B1`BS@527E^^[3S=\nM\\7N4\\\\_1ML-9P:#$KL8:,$24!)*!@*^/D3#'&<A8JJI"JQ+K[(J!7OH&00:-\nM6,JRHBP#1N#*UB.Z]#&GS37$F/[R>7G/0(J1F%+_4=]SV&?5E"(Q1G+.O0;"\nME-F]=WET=`+')X3%.<40#D-7(Z6#0?*JD79QA,0Y6U6!B!"SI2A+3.5P18$`\nM.6="S(/DE9PST=F5K5N!_:V.V[<^YK77W^4X?H_1Y("<4[\\VIN'R<<E`)J=>\nM17&#L^G)(\\;^;5Y]L>;N]!G>_L\\WZ6;'N)MC(-/5,R176.FE[YM'2)BQ514X\nM:T"4J-)?K'*4I1LB6J8+$5#R$$:M%:QS?="P\\-'G!>;T:5ZX]C.:=]_EP?0/\nMV+GZ+*I*C(-9Q5[(+N6E!E+/78R$X+E]^)!WWI[SSU\\*K_Z^<N#F:/`XMTV,\nMGH]_]0[&56!*LEC(D9TMP_X$#G>4[1$X:[!&:+QP4BOS-G$R]YPM(E82E56<\nM*`YAQ_51SQJXLJO</1;>^J7P5/DIHKNTV]_$6"'&,#`1-TPHY:'W)M2VGALW\nM/"__./*//U?>^%"9GT-AP!E!K&5G9X?)]AY%65)6(\\JJHC*1RD;&14)B3>E`\nMR$PF6^Q4.UREY'JTU!ZB;TE^@6\\7=(LIQCJ<*S#`M0/E]O<#;_]'QT]?$YYY\nM+O&=FY&<(<3$VNP3+@_>G5-O6S8F0O#\\R^OP_%7+CUX.W#^'MS*]TQI(JFB.\nM=/49]>D<0V14%4RV*G1<44PJ"FLHK9)3!-_T63LKN0ODUA/#4N.)'#QB',X-\nM)O29X#^%'_]>))TI[Y]F8HB(L&%"`P/>>T((=-[3M2T@-'7-LT]V?/2)X<Z]\nM"3_ZH>'Z`9CC_HVG4V5^WE!L[6"K)Y%B&V\\=P4;24#'N2(>33`B!IA$6J>#<\nM.\\Y:PZ(#)X%*.IPVV)1!+-856.DU\\.#4\\(N?.YXY$)@DFJ;!F/YMU/L.'P(A\nM>%Q=+VB;%CMDO:[KF,UF['^KX<]_DGCMK6W>O",L9N#,\\#0B,*X,-D_9HF7L\nMYHQ'!55AJ0I#51A4$U9Z;98F,*F$Z]L)52%FI?.!KNMHVX[%(J)B<46?8PYV\nME9=>4CYXR_`/KPE/W.QXJCQ#@*:NJ1<+8DRTS0)7+Q9T;3N\\!CC*LF(^F_&S\nM7R:F)XX?O"#<.X6W&$Q((*5$?3ZCL(IH0%*'AH)4%6A50"Z&CY1$UW5(V^)#\nM0!"R9E+,^)CP(='YB`\\!Q6"=H7#PT6>&^M>6/WI%26?*O]WIF)^=(0)-TU`O\nM%J@J=5WCFKHF!)^-,2K&)%<4+.8S7GI1N'LD?/)%X`??/>.)W:QFVC]`Q1CI\nMN@Y3%<2A+(@I$V/&V[3^S,R1KFW1-F)L_TJ=E54)[4/"AT@($<7@7(D%;EZ)\nMW'\\PY=__-?'M?7CNAN?^;(81Z+J6IJF-B,E=V^``C+'_E'/^WZYM-'C/8E%S\nMZYKEX!G#7__T$7<^^)`?MEVRTI='>4A`?==U%!L28$QY>!#.?6*,"9-U50OE\nMI(15V.[7J_:O$`+<//1,KG[(WW_:\\>DGAL/#2!?:OH0)`4",,?]CC.7K]G7[\n:NOV6M_\\#@*=@>"+)(0D`````245.1*Y"8(+#\n`\nend\n
105928
 
6621    taxes_add_48            begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```/\\DE$051H@>V9>[!D1UW'/]U]^LQ[YN[<Q][=9#=+-ED"\nM"4GEM2"2A""@!"LHI$I-5"R@2D#+LBQ*4#1(44(90;'D590&*!#+6*@@>4""\nMD!!"LED@V6P>N\\EFG_?N?<^=YWGTRS]F[F:#A+TA:_F/OZFNT]W3<TY_S^_[\nM^_:O>^#_[?_6Q*D&_-U="X`0'K_!$PH^@/<0`O@`/@2\\!\\^H/OK>$PA^U#ZI\nMI$E"9W6%3GN%[NJ*S]*T5:Z4\\F__]?4_$X#HE`BE0$`<@OB8"%Q!P`$$`N'D\nMUQ"`((;(&+5/O)\\3(XFTIEBND.<963)PWN8/+2PLW*POON&>:G,J;WWK;T\\O\nM`"E`@/1PYG1-;]_<B'`>G`^X$'`>_$EUYT_N&[9/KCNO,5:33A;I=BL<.7KL\nM)97&^#7&Y%^<GSGRX>DWO._XW-&G8>\\MIP>`D*.KATV-B%=NKV)<P#J/'4W8\nM6(]U`><#U@6L'Y9AFV']6?T:ZXH86Z=$PIEZHE&KUW]_7Z%X]M+"\\7>=M>/\\\nM(X?WKFO^IP:@1BP(0J`CQ?XGYOC.W0<(*-IML!3XC>MWH&N:F=23VD!N/;D-\nM9">N)_694=T%,N-8:%NN/C_BW+,NH5ZK7_/44_L_N+*T\\.[+W_V/R8.?>OL+\nM!R"%&`$)*`E'CJR2IX&E%<\\MM\\^158J\\Z;IS:$C!DH.>":0FD!A/DGO2/)#D\nM?M@>]26Y'X[)/6E:9,?R"M6XR]:)$K%^Z76]9/N_!N=NN^%8X`_/_.DZ<VH/\nMR.$-`L-X\\+[(7??UV7TD9Z%<X<R+I]`531P)2K'$C\\:)8>P@\\`@A$$(B!$A&\nM183AF+$)OO;T$IO5,J\\Z:P-S2:^J1?%UG_O`']S6;'[A5--;7Q"O786`7,?\\\nMUWP@/:L)V\\;@_'&BLJ80"8K:XX(`Y%"4PC/%!T\\8]7O`X_%!$`H:UYQBHC[-\nMN6?76+!+')YKG77=^_\\J6EQNV=,$0`S?6(#)+36N?,LY^*D*86.%J4T5ZN6(\nMD@QL+"F22)(93V8$:3RJVT!J/)D9QD5FAK&2C?H2XYDN*[025"I5&DT5)<E`\nM:!V?:GKK`"`!`@J!#_"*'55N.:NPQ@\\$G@(YN,!6"58'K`S#ZTAYA@HDAJKE\nMY+#N`M;+$^H4D#@$D9(4BT4*<0EQRF5VG4$L@"`"4D"KO<JQ7A^4'LEI8)`D\nMY+E%%LI#I<ERDD$"A0KY2(&R7@>G*^0.C`.3],B#P@1-:CW;:X&=YVY%R9'7\nME5A'GK`N&5U3H2$8XQRB5H>XA#<>8P.)5_1=ABJ,D4K/P`SH>0^R3B8\\&9Y!\nM-L#(*IF%S`7R)",E)J7`(/=450^MAJ(A1PIP>CPP6L@"HQLZ2W$P(,T6:12+\nM2!51LWTR<JI*XT4@#1D]EU(;2S%NN-"M!$NIGN/"D$K=B@6E(/(8ZRAXB)08\nM`1@^<QWS7]]"-J200`A00E)3BN`32DJBXPABA2:B4=3X$"@*1V0U8Y4"SGF,\nM"Y!HJI48C\\!YB(U&Z0)2QQCK<8E!*SD$()^1X1<,8.U&0QD5""&(HHA<1LQ9\nMB?>";A\\&J4<Y1V8=R<#0[QI$.SVA.H-6BBTFY$Z0V8#IIF1X4F%(,L?.IF'[\nMB\\0)JC)Z82_<`W(H-PH_7,B<(S<&87(V%@R1$O1B1Q8"U>HPM4YC02\\2U,<D\nMS@N<E[1*FFHC/D&A=BM&1`5$5""WGI(/1')((25&E#T='EA+)<)(C8242"G1\nM2E**%%HK@E;HX&D4HB&%<$0V8JP<$\\(P&Y6)IE&-04B<#Q2,)HH+*%T@MPZ7\nMYNA(#%5("D(X74&\\QL6U]$`(],D4<M#M!P:)1UE+YOP)"C&B4&X\\@]8`7XS)\nMG""SD/?Z9,&0B9A!YOCY*<MY9\\L302SD:0*@3JC04-Z<<YB3**2U8%`(9`)J\nM=8%Q@N0G4*A3CFDT2_@@R%V@LUHDB@M(720SGK(?H-0S%!J^LU,C6'<N%-:"\nM^<<I%$7X2(&S%")),9(4B/X'A1@H*K%"28D,GD(:*!0%NB"P0>,R34&KT4(V\nM=,%IHI`<`?`G*!1K?1*%`MV^9Y`&E/?/4J&3*92T!MB\\2[YX#)7UB+PAC@L(\nM%;$RL&QN5IEHC!')`CH*Z+B,.&DK^C,#6*,0ST6AZ"0*U7A."CW1[7'@P#[.\nM'!^G-C7%H<,'65PX0&5<L=P^QG<>>)QO_>!F*AM?C!.5C=^]^],7]1=6'N5J\nM$K[]@CS`R`/#H))2HI0BCA3%2*$BA5&2H,1)%-+#A6Q$(><\\R?(\\C7*!9K/*\nM_N./<,N#7V:E-\\>636>P9>,6+KSX'*PSM'H/<VQYYC)1S6]'\\@"&S[.3V]`,\nM^-X+`2"?O;`,?&`F=83<TNTYDM2AG"$SGF20,.@.$*UXM(UT//KH(7SO*`<>\nMV$,K.\\ZU5U[+FZY\\$UNGMV*]I3/HT$[:M`=M%MH+\\JF9IR;NWW?_&_<\\O><U\nMO6[OWS!\\D#?S)'N`IYX'@+4=&3X@@3`Z-BD*V%Z*T%K3(R*-/;7&,)7(TL"@\nM9FF.UT9!#!^_N\\<___`K[+SD8C[Q]G_BO+/.8[F[S&)W$>,-N<M)0TK7=$E"\nM0G.RR175*SAC\\QFE^QZ[[X;9A=D7AU[X72[FAV3`T74"6).R$ZD$X*S%>4]J\nM'58X4NO(G">V'A^&_=W,PL#@`RPL'>)[AV[C#5>_EIO>?1-""@[,':";=1%*\nML*VQC:27T.JUJ&^L<_3`8?JN3R\\,J(Y5N?2"2^%)+IN9F_D4`WZ;2]G/1F#W\nM.@#\\N$DI*99*K.:&6:_P1M#+!(,$%,,=5S)P]/L@3*#;[_$OMWR$+5,;^<@[\nM/T)F,Q:[B\\.4V_2(1<S<[!Q[?[27>^ZYA[?^\\6]AR#`BPXB4GF_3\\:M4FQ5T\nMJE]N(O-A6KR-:3KK\\L"S+5"MU>AVNXQ7*VQ0PY][7<:'$D(J?)`$'V%L$63,\nM%^_X3Y+EQ_FSW_L\\QAOF5^?IVSX#.V!@^Y15B1`:I%G*ZFH;C\\.JC+YO<[A[\nMD*.MHZSVV@R2#%D"$<2U081?9YS/\\@O/$T`(4"J5*)5*ZQJ_TEGA[A_\\!]==\nM_6:F)Z:979FE;_OT;9_4)Z0N07E!(."LPUI+D)ZE?);][<=I92V\\MI0J&J%`\nM*H$0Z!S[#C\\;_IT-+#YO"CT?>^#1!YA=G.6J2Z[B>.LXG;1#W_5)_(`\\I.0^\nMI1`B((QR+4';+',XW4<HY-2C,KFQ9*DABA1R[8@G<*&Q]N=$++[V,P,PWG"\\\nM,\\O>A;THJ;AP^A*F*E,G\\AB`>_?<R^;)S12+15;Z*Q@,><AQV.'*K@(R`AQ$\nM*B**(E">L4:5X"LXY\\ES2YKF=/O):/(!YWR!/+RR<G'AU``B&2,0P7B#\\3D'\nM6\\=X:.XA'IQ]D(.KQPBBSK;QRVB%`5L:.94H184%FG&)QPX]QO3X--VT2Z%8\nMX/R-Y^.<`Q%8^^@HXMC^60*!#<TQ+JA?RHZIEQ!"&$IP"`0',[TC?/2^O\\3:\nM!8QQN,R_>.4+_?@Y`5Q_Y_5\\^>8O\\Z>[?JE4](T++IJX<K*5'64A.8X--2:K\nM%_+2S;_*>&4;L=8LNWF>6KB5^60/2]TG*5C%CV9_R!7;KZ0]:#-1F&#VZ5EF\nMCLX,)Q7"<'\\A!-99:K4:5UUU%8_OWD\\T$H<0`LX[LB1CRT6;J%>J+/=6B/.(\nM3-NFWJ0*SPG@*U_]"K(AZP\\]O.<3TU.;WN!#;7RL?`F;&[_"6.E%1"HFZ&5F\nM_2X&Y@DZV4%6YF:9WS]'O=F@-E[#2D=F,CI)AVJ]RO']Q_GL9SY+FJ9X[X'A\nM!LD[1YJE%`H%QL;&T$H3`&LM69I"@/=_[+T4"AJM%5&DB)04*A+/K4)9G@$4\nM%Y<6=R9],W'-R_Z&#;7+6>JL<KCU?;+H87QYAF+548J*].9;R$0R.3Y%=;+*\nMAND-Q"IFM;]*.VDCVY*+=E[$GVQ[W_#(7H(-.5IK9AZ9XYMWW,G,S`SO_8OW\nM4)P:)HW>>:SS"!31N,`^DA,IA5(2I63/M8)95Q`[Y\\EL1!""3G*06^_[(VIU\nMR>9-9S(Y.8FO!\\K-"L4SBH128)?9Q6)KD5ZQSWQKGLZ@PT*ZP!,KCR.TQ\\J4\nM7EBA)U8X>^/97'OI6RGJ$G?<\\0W&7Q:S;^I.TBRGVTGHC,KRX39]VT,I120C\nMA!1'S9TN71<`#[0&%A$;6HDE-X:YA0ZM5H=ZK<[DQ"3%2I'YWAP+?I&.[!#D\nM4!K5LF+?L7W8HJ4GNB1TR6076714:C%3C0E<V>&])X1`;C-:O199;NBG*9TL\nMH9,F)&:`#X%25*9/'G#A!UMOFGAN"DDA"81<2O%$K`M;VZDON:ZADP6JE1H!\nM011II)2LMENH?H16,9O")L;2!H,LP10,;=/F]@=OAP90"91K,?5&B494QKOA\nMN2FLR:/#&$>GDV"L)4T->68QQF&L0Q,3ZQJS9G$VY-QKENQS`]!:DW6S55U7\nM;ZN6FY?94+UFJ6>N[*3^O$JU5I)"$JD(%44G-#Q2BBB*4"I"1()JL\\K,AAEV\nM?W<W9"`*`N<\\SGJ,<>2YQ1A+"."\\P^0YQCK:R0#GAM\\G24Z:YG@#VVKG\\N3Q\nM`V19]M6E![O[FB^I_I0@_D0&0(I=V?(/MWYSKL>=<:0G$M.^M%34K]>Z]CH=\nMZ1U1%,61&D[^&3`*I13-2I/MK]_.P2<.LMQ;)IB`,98\\'Y8LDV39\\"^`/#<D\nM28HUCDYG@+4.:QU)FF/3P(7-E[/:[3"[<OR`Z_O/G/'JICORH:7UY4*[WG$.\nM#,^:%E_UN5?=@8B^@=<;8QU?58CCZ[2.7ZUU-*'4L[U0T`6J&RKL?,U.[KKU\nM+DQN,)DCBPU:1T@EZ/4'C$TVN.P5ES"^L4E0@=75`<X/#]#*HLYKM_PB_4'"\nMG8?NZB;=]$,7WKCED5UO/PBL[_#K)]KO?/LW:;?["$E!1_JB.(Y_+8[CMT0J\nMVFJ=%5(J:M4:SEI6VZL\\O&M/ON='>[PO^6)<C2A7"I0K,6/5*A><\\3+JY1IQ\nM'+&8S#$_F*&H2EPT=3FOWW8MC\\[MY8N[;^XL+BU]H/^4^:1N2#/WZ?8+`W"R\nMO>O[[\\0Y)^,XWA''\\0T@;FBU5K8=GYL36D>4RJ5C29+>=/N7;N];;?]<5N6V\nM:J-$M5*F5-3HHJ)8B"D7BDQ4)]DQ<1Z7;7X%DZ5I;G_BZ]SVV->.=MK=&_-C\nM_DNJ)NSQOU\\]\\>S3`F#-;GSR1K(L$]5J98>.]#OF%Q9NF%N<>]Q:^_ZCJX<>\nMN/^&!P-OY!*JO$=5U36-1KTQO6&231LV,EF?H%D=IUEN$D+@R.HA'CW^2&=^\nM=>X.U_<?[=_K=A=>*L/2Y[K/>N9I!;!FGVQ_DFJEHN87YL\\[?/3P4KU>GW_D\nML;U\\_2U?AU\\&4HJ,<3EEKHF*ZO)BL7!FL1`78QV!")GUYIAU=C>&V^C+7;),\nMLO3QWD]\\UO\\*@'79A<`"@DLI4V)<%451*8$,,L6(E?1^TQ=3(H0'?OKAUG\\#\n4>6TU;$`D4RP`````245.1*Y"8()<\n`\nend\n
105929
 
6622    taxes_clock_48          begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```0I$E$051H@>V8>:Q=1WW'/S-SYIQ[[OKV9SM^MA/;+X[C\nM."1AR0:$52'04D@0$*,ND(JEA:(B5;11H46B*JTHJBH*$FIH&T0A;1$"`DF(\nML[!DL[,XMN,E7N+EV6^_[]WEG'N6F>D?]]HX@/$CN.H__4E'9V;NW'/F>W[?\nMW_<W\\X/_M_];$^>:\\(_W3P-"6&R_Q076@;7@'%@'UCFL!4NOW?O=XG"VUS_C\nMZL0QC85Y&HOS-!?F;=+IU(NE,'WP[V]]20"\\<R*4`@&^<^+SPO%J'`;`X7!G\nM?@8'.-%%1J]_^ON<GHFG-85BB31-2.+(V#Q]9GIZ^@Y]Q98?E0=&TOK6+YQ?\nM`%*``&EAY;**7KNBYF$L&.LPSF$LV#/:QIXYUNV?V396D^6:SG"!9K/$T6/'\nM+RG5!F_*LO3.J8FC?[/L+9\\\\.7GL$.RZZ_P`$+)WM["\\YG'MVC*9<>3&DO<6\nMG.66W#B,=>3&D=ONU>W3;;]H7).;`EE>)21FI1ZJ5:K5/]X7%"Z:G3[YX=7C\nMEQX]LFM)ZS\\W`-5C@1,"[2GV[YWDH8</XE`L+D).P'MO'4=7-!,=2R=WI+DE\nMS1W)Z?L98UFO;1Q)9IA>S'G=I1[K5U])M5*]Z<"!_7\\]/SO]D5=\\Y%_B;?_\\\nM@=\\<@!2B!\\2A)!P]ND#:<<S.6^[ZP21)J<#;;UE'30IF#;0R1R=SQ)DE3BV=\nMU!&GMMOOC<6I[<Y)+9U.@?&Y><I^DU5#(;[>>$LK7ON?SICO;SGN^/C*7ZTS\nMY_:`[#[`T8T':PO<_TB;[4=3IHLE5EXQ@BYI?$\\0^A+;FR>ZL8/`(H1`"(D0\nM(.E=PG7G]`WQG4.SK%!S7+^ZG\\FX5=:B\\*:O?OICWQ\\8^+=S+6]I07SJ+@2D\nMVN>!*4=G]0"LZ8-+!_&*FL`3%+3%.`'(KBBYGUW665QOW`(6BW4"%VC,P`A#\nMU66LOZC"=#[+D<GZZEMN_YPW,U?/SQ,`T?UB#H;'*KSFYG78D1)NM,3(\\A+5\nMHD<H':.A(O8D269),D''[[5S1R>S)%DW+I*L&RM);RS.+,N*"JT$I5*9VH#R\nMXC@26OOG6MX2`$@`AT)@'5P]7N:NU<$I?B"P!*1@'*LDY-J12]>]]Y2GJT"B\nMJUI&=MO&D5MY6IT<$H/`4Y)"H4#@AXASIMDE!K$`G'!(`?7%!8ZWVJ!T3TX=\nM41R3ICDR*':5)DF)HQB"$FE/@9)6`Z-+I`8R`UG<(G6*S&DZN65MQ?'*]:M0\nMLN=U)9:P3UB2C)Y2H2Z8S!A$I0I^B,TL6>Z(K:)M$E301T=:HBRB92W(*HFP\nM)%BB)"*399(<$N-(XX0./AT"HM125BVTZHJ&["G`^?%`+Y$Y>@\\T.84HHI/,\nM4"L4D,JCDK=)2"DKC16.CDMHF0Z5O@Z9Z2:Z>9<35E.,ZU*I6<I!*?`L66X(\nM+'A*]`!TW[F$]2\\MD74I)!`"E)!4E,+9F%!)M.^!K]!XU`H:ZQP%8?!R35\\I\nMP!A+9AS$FG+)QR(P%OQ,HW2`U#Y9;C%QAE:R"T#^3(9_8P"G'M2548$0`L_S\nM2*7'9"ZQ5M!L0]2Q*&-(<D,<9;2;&6*Q<UIUHGJ'O!"3&D&2.[)FAP1+1V3$\nMB>&5`QEK+Q2GJ4KO@_WF'I!=N5'8;B(SAC3+$%G*:)#A*4'+-R3.42YWM]8=\nM7]#R!-4^B;$"8R7U4%.N^:<IM%CW$5Z`\\`+2W!):AR>[%%*B1]GSX8%36PG7\nM4R,A)5)*M)*$GD)KA=,*[2RUP.M2"(.7>_05?9SK[D9EK*F5?1`28QU!IO'\\\nM`*4#TMQ@.BG:$UT5D@+GSE<0G^+BJ>V!$.@S*62@V79$L47E.8FQIRE$CT)I\nM9HGJ$;;@DQA!DD/::I.XC$3X1(GANI&<#1?)TT$LY'D"H$ZK4%?>C#%D9U!(\nM:T$4.!(!E:H@,X+XEU"H4?2I#818)TB-H[%0P/,#I"Z09):BC5#J9Q3J?K-S\nM(UCR7LB="N:?IY#G83T%)B?P)`5/$N#]`H6(%"5?H:1$.DO0<00%@0X$N=.8\nM1!-HU4MD71><)PK)'@![FD*^UF=0R-%L6Z*.0UG[(A4ZDT)Q/2)/FZ0SQU%)\nM"V4SM-8@)/.QX8+!"@/5*E+X"'D>`9RB$&>CD'<&A2J<E4)[FRT.'MS'RL$!\nMBD-#3)X\\@:]RKGS9)H24'#ATA*>??0Y57L:(<\\O=[//7U&=.[@`6W_.^/^`;\nM7_OJ2_4`/0]T@TI*B5(*WU,4/(7R%)F2."7.H)#N)K(>A8RQQ'-35`L^RT8&\nM&1H<8'2XGR#0>%J3=!)&1X;)L@Q7/TI5J:M<N?C=0(_M_-(=W_B/^OS<73>^\nM[1TSW_S:O_*#[WWK)0*0+TXLD75,=`PNS6FV#'''H$Q&DEGB*"9J1HBZWSM&\nM&G;N/,2(SEFW[B+*I2(FS]BS9Q_[]A_BY'R#.#.`0`E'M:#%\\N'^ZMC8RNMJ\nMM>K5M;[^=YV8F/C+K??=\\Y,/??3/W)?_Z>^6#N#4B0SKD(#KE4T*`M:&'EIK\nM6GAT?$NEUMU*)!U'5,D9&*S@7+<`('8.,K9R)<M&AWER^]-L_>DV#K8D8FB,\nM_E474RX7R;,,`TRV6QR9F6#'H6U<-%)5&RX>?VT8%K]^^V?^]N.?_N3'_OL/\nM_^@3?.6+GP>6D.P>/=@&"*USWUG1Y[\\QS.9(DH3%=AM=KN)IGW:K19)F5*I]\nM6&?I=!(6&TTJ?8,8:Y'.$LW-@A!LW?HP]SUU@'QL,V^X[DI>OVF,YM0Q&HU%\nM,B=I-EO4+KR4P[--]KTPP=SN[?2W)[E\\TP;"L##16%R\\;<V%Z^YY8.L/^.:=\nM7SFW!W[>I)04PI"%-..$5=A,T$H$40R*[HDKC@SM-I!V*Q$KO815RF/KUH>X\nM^ZG##+[\\37SPQBO9L*S"0IPSE1GJBTV$]D%)"EJR?J3"2'4M^T>&./S4XSSU\nM[&XV;QR_P-/^W^_:M>/PRK$U^Y9$H1>;HURIT&PV&2R7Z%?=OUM=Q+H0(176\nM29SUR/("3BB:[9BXV6'GCIW<NWT?E<M?QP=>MY'ADL?AV7:W5H1$^CYYFA'4\nM!FFG.:FQ6&<9JRK\\JZ_CP",I>_<?8'S]VDU:^Q]_YLDG/OJ>W_U0_FL!<`["\nM,"0,PR7.=^P_=(S)>IT'?KJ-:/E&MKQZ,P7E.'#X*'TCRS$.2H.C%`9&F(M2\nM)AL=XMD6"(%I+V";\\YQ\\X2!#ZRYANC[-S/0,U5KUYC5KQ^_0VM\\FS[V,EVY1\nMG#`[O\\C>O?LYV(1-EVUBU4`1XX4('5"?G\\?0K>Z=:'0X--<FR@V>5@2^PD1-\nMGOOQ/3079AD8'6%T\\U7,+S3)LWQ8"'73JM5K?_T8.&69S3C9.,&NZ5THJ=B\\\nM[$I&2B.G]S$`C5:;1K/%_@.',?TKV3@V1&H,!LG^YW;RY/W?X<8MMQ$L7\\MT\nM.R7P%8&OD3:G>6@7];T[N.2:&QB]Y&48*_!6KZ&YYRG2-,5:>^W##]Y7/"<`\nM3_H(A,ML1F93#M>/\\\\SD,VP[L8W#"\\=QHLJ:P9=3=Q%CM922UT&Y:4;""@N-\nMB&:CR=1\\@]+8!OJ*'G&:XX3DPDU7,C=]DL>^^TVJZU]&W\\974*J421>FF-C^\nM,,52D<MN?"?EP1'R/"=)<[Q:E?+0"*8Q@[%VM1\\$0V<%<.L/;^7K=WR=OWCB\nMQK!@:YLN'WK-<#TYQG1\\DMQ5&"YO9N.*=S!86H.O-7-FB@/3=S,5/\\MLXWE*\nM,N!5\\O7X484H,Y1*168.[V->6$8ON@05A%S]UG>Q;]?3//1?_TYRW[<96;Z"\nM+#=<\\?HW<\\DU-Q`$`=8YHF;$]///4EVUGLK``%EK#F==I5`H5=39`.RO[<?Y\nMKMIH-+^4D_U5++@0M4&,5GZ;U?UOI[^X&;1E0>SDA/LA1Z)[.73\\)QQXZAE<\nM:O$*'LOT&&K>9^?^PZCEZQB4$:V9"<K+QD#I[JFK-L+P^&7L_M&]['WL8=[V\nMP3_A56]^*\\6")M`2O[?C73AYE*!8(FVUL(UYXKC32I+T:V?U0)(F`(69V9E7\nMQNULZ*;+_H'^RBN8;2QPI/XHB;<#6YR@4#:$7H'65!T92X8'1R@/EQE8-D!G\nM(B*D'RTA,SFJ,D!)>UCED]EN@3?*#$/+5_#>/_\\L\\L$[&;]TG-!7^`J4E%@'\nM>=2D$/B4RR7FG27P?=(LC1<6YN,E!;$QEB3W<$+0B`]S]R-_2J4J6;%\\)</#\nMP]BJHSA0HG!!`1<ZGLB>8*H^Q1N3MW&]6$DY4$PV%TB*%](WM()6:D@[.:F#\nM8N#A25BQ=CV#XBT4I_;B77PIH2=12F*M10T-4'C5M;0[.20Q6FN23CK=B:/Y\nM)0&P0#W*$7Y&/<Y)LXS)Z0;U>H-JI<KPT#"%4H&IUB33=H:&;.!P/&)^S%7E\nM5S/2W\\?$[`GV3*VC5O0)`X_0UY1##WGJ((_#K-F,O^/[^$F38GD(7TNRW/9J\nM4I+&W$FTR4B=)8JBG8\\^?/?"60%((7&X5$JQU]?!JL6.#4TSHY$XRJ4*#H'G\nM::24+"S646T/K7R6N^7T=6JTDXB()B?U<98O6\\;>B9TDC3H=?QA/&71<1_C#\nM".%WRS6`J/1C!U?@3>Q#C8Z212WP?`J>Q&2&N2-'Z"L6V'/DA32*H_O>\\-8M\nM[JP`M-8DS61!5]7[R\\6!E^>N?--L*WM-HV,WE,J54`J)ISR4Y^$I#\\_S\\)3"\nM\\SR4\\A">H#18(O`$Q=U%QOI+'#F\\$P9NP+:;2!^<TJ?+[VDG)K8)Q0LVD.Z\\\nM'^_BJXCB&!/-,;1L!2^<F,3,SZ*5X-C$B>U1U'[(Y!EG52'SA($=D#]AXXV_\nM]_C!9E*Z-[?AM^)T_X\\]^?A,&.I*&!;[PC!482$D+!0HA"%A(20,"Q0+(4.5\nM04;&!LFGH$2%A1-'R"R4EJ\\BK/5W`2N!)V%J]Y.0IU16K84#3R.D8FC-.)4P\nMY/CD'$>>V<F*OC*//+:M?>3(L=MKM?YM\\[.32\\O$3]RV#KJUIIGKOWK]/0CO\nM7JP>];7_VL#W;]':OT%K;TBI%WNAX!=HFQ;QR@6"F2'6K1GC\\/&]M#U!:>,5\nM!*6`P%,(8\\CCB,;,%-I:!C9?2VGQ)&2&`T>G.+%G'Q>-]O/XX]OM<WOV?:79\nM6/AVEB4\\M^.1)16_?JG]_H/O8W&QC9`$VM.7^[[_;M_W;_:4MRHWN9!242E7\nMR/.<Q>8BXEB0#!Q<G:6MO#Q77\\!4A^D?OXS1L96,#%1PS5F*RC$^/HYSEKFY\nM.K-3,[B%>49K1;8]^;1YX,&?W+FP4/]$$`3S3S]V'["TZMTY[<./?@ACC/1]\nM?]SW_2T@MM3K\\VM.3DX*K3W",#S>23N?&WETPX2?%3_CG-V4)"E&2/S:(,7!\nM(4JU&H7`1TN!S%,"FU/1DC2)V;;]Z?:NW7N_W&PN?E;KH/[LMOM/O_N\\`#AE\nMGWK^4R1)(LKETKCV]&U3T]-;)F<F]^1Y?OO>H[L??TOZ`7=RY[&+E?(^`>*=\nMP*!2"M_7!$%`$/CXOH^G)&F2<G)R*GOAZ+&GYN;FO]")6M_V?#_9_>1#+WKG\nM>05PRKZX^$7*I9*:FI[:<.38D=EJM3JU\\[E=?._F[_$[[WX_2=+QB\\7*%2!^\nMRSEWC7.L$H*R=0Z3YUF2I#-1%#T;1?&]21)O[1\\<G9D\\\\0('=C_^"^_Z7P&P\nM%-MTU76TFG4QMG)=2?N%81T4RGF>$T=1UFHUYIJ-^KP?%,R^9Q_]E<_Y'T*`\n2VI(Q1&%\\`````$E%3D2N0F""\n`\nend\n
105930
 
6627    user_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```-[TE$051H@=69>XP=UUW'/^<Q,W=G[SZ]N[9W[21VVVSL\nM)$V;V`JI4E(WH:A(#6VE%M20-FJASQ0$+?Q10560*!1011%J4]1`)*HB$%(%\nME*!2F8=:A$J#TS9.E#2)8Z^]:^]FO7=W[V->YYP??\\S=74.<-&LG!48ZTNSL\nMG9GOY_P>YW=^`__/#_5R/#1-4_(\\5_OV[;/#P\\,I8$(($D+(G7.Y4DH>>^RQ\nME^1=+PG`;;?=AHAH:^V4UOI@',>O3I)D-HJBO2&$J;(LHUZO)^UVN]7K]8Z5\nM9?G7699]QUH;3IPX\\;\\'</OMMR,B1FM]8QS'=XV/C]\\Q,S.S;V9F)AT='<48\nM0Y9EM%HMEI:6.'WZ-*=.G6)Y>7FQ*(I/S,W-_=G.G3ME<7'QDC78RQ$?0AB)\nMHNB7=^[<^:%#APY-'3Y\\F-V[=Z.4HMUN<_[\\>187%^ET.H@((02\\]SCG=I9E\nM^5OCX^,/.^<>OF3UEPKPAC>\\@3S/DX&!@=^<G9V]]\\X[[S0'#AS8\\'U:K1;+\nMR\\LL+BXR/S_/F3-G.'GJ%*=/G^'\\R@I97E`4Q4R>YV_-LNS[@/^1`H00""$<\nMV;5KUWN/'#EBAH:&6%A8H*JJS9E?6EIB8>$L9^;G65A8H+/Z+%%HLW<PHQ4*\nMGE[-\\5X^.#$Q<:#7Z_UNH]$XMK*R\\O(#W'333<S.SG+\\^/$W3TY.#BTM+7'B\nMQ#.LK[?I]7JLM]=96UVEO;Y*E:TR$F6\\?D_@U;=$7#&^@U1WF9M?Y,,/%,RO\nM1U.WWGKK.]KMMCIZ].A=0/FR`Q1%P=>^]C4S/3T]/3\\_SS,G3Q'G<[QVNB0U\nM"9-:D^XR3,RF3$]-,[-KG+&1810>EZWBNDO$VK-O8IVYE0J`ZZ^_?O_1HT<'\nM?R0`69:AE)*UM;7\\^X\\\\0D.7?.PG$^Y\\QSV8H1FT35`(2BE$/+[*\\?D:(5M!\nM.8>*NC1'QGG7Z\\[QGR<[S,\\O,#DYN084V]5R20!YGE,41:B<>P(1[KXY<,<;\nMWXF=O![3&$69&/$EXC*DZJ&"H&T#;`,=-="V@;<I=]PPQGM.=OF'N6=Y_/$G\nMCHM(3ZGM9W6]W1OFY^?I=+H\\>W[]F\\-ZM?VVVU[)X/2KD2HCE&VD;$,H4`A:\nM:[2Q:&U1)D)IB](&I0PV2GC;31%Q<:X\\]KWC_[QKU^YMB]\\VP'4[0.3/^>S/\nM38V\\ZY:!Y3<=5,>OW'<UXCU2=>KA>N!+%!ZE%$IIE-;U.0I$0`(2/#N'%8?V\nMY">.7*U.?_[NYAC`+QW:'L"V;/8;;Y^DN[XR=N=[?_W^/9/-UW2__Z?-G?L/\nM3293!S&-473<Q,0IRB9H'0&"N`R?K^([YZC6YBA7YZC6%W#=1;+V,F=E?^L5\nMMW]L=6GNL2<?>O"^=T>-H<5?^-+2B]:TK1AH1(*+T*GJ7#4Y<>6^YMZK"?EY\nM0M%&:P-*(5JAE489BP*\\RY#>$KY]!M]=1*HVA!*1`"A>^:K9L1VCZ5AQ>L6/\nMI"&VR?;6M&VY4)2O\\.D'/W&^>_S+7UW[W@,T1G:C0D7(6X2R3:@Z2-5%7`?*\nM-21;(G3F"=DRXC(0CX3:?20X3#Q(<V2"XND'4>?^]>^^]5?%_)AN;0O`;.?'\nMWWA">'/^37RG\\\\10TU[1&-V[-Y3=-5]V4D50A`)<#\\HN4K61HDTH._BR@R_J\nM$<H.H>C@BS9F8.QL<]?!4+7/_F.Y\\O0G?_R.B;6;/K6V+8!MI]$?^XPP]X5K\nM%GW>^4"Q>NI5/E^[`KC?A6*$:@S5&(%D"'$)B!"JC%!T"%6O/J]R@L_QOFK[\nM;NL776?IE,O73XR^XM;SSWS];[<KY_+*Z=/W78L$E^IX\\"LF&?IIVQC!)$.H\nM*$5I"Q((+B>4'5R^CL]6<5D+UUNAR-H/=K/JG<;H[HV_'2Y9PR67TP`Z%$@\\\nMW!,)7PPN/^++:!A`^1*E#"*>X`I"V<,7;7S1)I1=7)5W2N>_F#9,=WG]D@O1\nM6L/EW#SSX:<07R&N."JN^(HOVKA\\O:YYLA:NU\\)G+5R^BL];A.`))J$HJ[]L\nM]\\+7.WG@ML]>EOZ79DLY=]^U('*%TOK+2D>O5]J"HLXVKB"X')U.H0=WT3KQ\nM;]]NKRR]RUIUXO#OR&6_^[(LL'%,#"F"S^<T^4?R[NJC+FOA\\W5\\E:.2$0:N\nM>B-VZ@;./OWPF:7EI8\\ZKT^<BR]?/%RF!3[_/@@>W1QF,$[4V'?_1?9<?S#Z\nM[)[=`S?OWM&D,32)&9JAT^GRY&/'6%IJS]VPJMX_-RN/]S2MJJ1C+.$]?_@C\nM`OC]=\\.`A0`-HYE-8FY-TN0FH\\)L\\&[ZT7]B[#77F6$[%)3WBB2"R@?:F2!*\nM,6.5'#A)Y[L'6>DVY&P(Z@?.A8>=XUL^\\%@CHK>T!A]_X&4`^*.?!Q$&%;PI\nM;:9W3^RY]M9=^V^92(<FU,G_N(_EQ7,\\\\C?PNAL:7#FK*<51.`\\"L5$TK6'D\nM/.A'"QX];,E&A'1T/\\H.27MEKM7KK'R[JMR70^#OM6(M+^"C7_KANGYH&OV#\nM]T$B4`6NC2+SR>G]A]XR>_-=`U-7'L)&"0N/?I50K=)($]QHQ9/?R0E/:G8V\nM84<,PQ9&K!!5@=4L<'+<XD83XMBCE6-\\YEHUM./*\\;7EDV]N+9VX/>NL?L,%\nM^=1;#O"0_J#B(_>]<*R\\8"GQ>_>`T5`)MR1)XX%K;OZ9-[[V31^/AD:GJ?(6\nM>?LL\\X_\\!57O'(.#":-7)+2;EJ[1.*40I1"KZ34L\\V,Q9ZY.*:X;I-&T:&V0\nM4&+C04!AC"5.!HWWY=6^S&__P0J/-ZQ^^B=N%!Y\\Z!(MH)2B\\K(OMN9SK[SQ\nMK==???AG*7OG*5P/"!3M!8KV::(XP481>W=;KMACJ(+&>84$:&F%M0IC%4TM\nMT.\\->>?PSN.R1=`IKLB0*F=@(,67O5=DO=[G"A?>:;1Z!)[?"L\\+\\)E[%-T<\nMG<;<NV/ZX.&]UQPA6U\\`GX-4*!7(UIX!R;%Q1!1%&&NQUI):@S%;&QFH]S$A\nM!(+W-8`Q..WPQ3*N\\KBRHJHJ7.70>(SA&H%?J3P?^,*'5/FA+UP<X@4MD$2R\nMW\\;1VW===2.N:.-"AI(*C4,IH>R>0VN%M1'66FP482*+L09C#-J830!$""(U\nM@/,XXU!:H<JJOT.#$(3@`T9Y(@,B_)3`=0J.;=L"_?<>:J2C>QOI"'EG$2TE\nMFA*E`EH)OEC%6(VU!A-9;-R'L!9KMP#J#H7T+1#PQJ$OW&;V_R\\B2.C_+GA\\\nM8$J$URG%L3^Y%][_QR\\2X--W@U808#:*!XPKNXA;1TN)40ZM`UI#\\+UZIJW!\nM6(NQ$3:*L%'M2L::33<2J6<W>(_;<*U-]Q*D[O;5%O`!8P+&"R(<:#8-Z^ON\nMQ5M`:YB>2CAS+M^==9YE^<PQAD<FB8Q@M$=KP>A`\\#E:&XRN7<;8>EAKL7'M\nM5AM6V&SNNMIU4'5HUCNT6KSI`QIO,%YCC"<(.UNKSD16^8L%\\\\5=2!1/S>6F\nMD:A)7^6</_,]\\E9*.M`@C@PV,MA(88T0Q1:E-5IKC-8U2&1K*T0UA-*U6N\\]\nM3E\\8U+(9V,;4@>_[L:.-P>B`5[(CLB1:2>]%6T!$,)H$85SUW^:*#H7O0&*@\nMD:!)P"2;/JZTV@31?9`-2QAC0,`YAT+U.RMU0`>_(5K7PK5&:[7Y'*W\\F-9J\nM0"EZ%[/`1:M1J?US0&!\\ZY8-GU44SB!*;SWOPH)DHQ>D:D'66J(X)DKB?JK=\nMR%`;L`9E#)6W*%4+WYB(N#&$UF9$(4WU/&O!Q0%$$*$IPK#0]]7^\\$%8Z<9`\nMM)4Y+AALG'/!-47?0OVA+AR@=$2K%Q&$S>L`27,*&P\\T$8;5\\Y1M%P4(02'"\nM<!^"4#?3$('*!5K=I.Z!2D""]`-1ME)E\\)L9QSM'55:XLL([3P@7`/<G1>N(\nMU6Y$Y?JP]302#XP2#XP.2&#LHNIYGA@(M;7&@C"P(3[T08I":!<-M+&$JO/?\nMQ`;G\\<:CC<<;MQFPP0>44OTL5*_$H9]])`24CN@4BCP.#"8U&"*8J$'2W)G(\nMXNGQBSO0"P"(L$,IDM`7[^MK=',(JH&Q$67NMTH#[_'>H9U&&TVU(3X(VO3S\nMODB=B:IZ-=X`5U&,Q]++/6F\\Y8;!E23-28MB\\ODL<%$7\\@%\\8"((-DC]=ZBO\nMT<W!QBDZ&JQGT]5NXIS#5?6HRHJJ*"F+DK(H*/.",B_K492XJL15%<XYO/<H\nMG6"BE%[F8".UBE#FZ]BX"8I)E.;^>U^$!7[U[1!J*TSI`-Z#UYM0=`MH3J28\nM.-T4KC8+-UV7!1L!'`+>F<VR8<,B(?3KH7[Q%ND!DH8A:WF"ETW7*K-UFC8%\nM'4TE`TV*\\KEMQ^<`*`7!*X+(I%=;PEV`RD%903J88I-17%6A3;V0]:L:X(*:\nMQIO-W+Y1TX5^T'N_!:%,2CI@Z%0>YV73O<J\\@](1R@Y,'OM62^\\_R',Z8,\\!\nM$`$G06NEIC:$&]_?V/2!!@<'B08F<,ZCJVJKXE1<4+1YC.L7=!<`;,'5<>/*\nM$F4&&1PT!.]PSJ)L2A)/H!L3*-L`W9@8FUJ/O#SW,]1%+:#JZUT1GO(!OP$B\nMKLYR:9KJ>'`*Y_!:.R[\\-"2A+ILE",'X>J'26[E](X4&W__H757H:%BGJ5)*\nM?*A*1&D%5@B5X]R)?S=EWEV+FT0NJ.)_KL87R4(*H`)^#8@VTF<(@$#ET8UT\nM3*>C>_&"VZCA@PD$YPG]A<@#B"%H06L%:B-?R.;:4:=>1SRXVR2=7%7.!^\\E\nMN"PCS];(LM,4)>B&<C92/9&7II?T?^KX+ZC82?[9#UV8`````$E%3D2N0F""\n`\nend\n
105931
 
6628    window_write_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```'6$E$051H@>V9VV\\<5QG`?]\\YL[ZL77N]\\07'CF^Q@Q,G\nM<9(VA(8V32IP(H*`"IX0CWWC?R@(!(B'/L$+0D(5*A(\\@`0\\M`*A-,VEI8DI\nMB92D:9M-<VGB[&;MM=?KW=F=F</#WM>[SOH:'OBDLW/FNYWO.F?G#/P?GBX(\nMO`K,B]_?.]39V;Y=:Z7R1&,*L\\*\\&J[(;TKFRW&E]WFTB!"+)4@F;2#/JW+S\nM_+V5&P(8%S(AR,Q``Y;?'\\!QV@Z<.K7GS5V[NH<\\+R]DRHPP%'6:/"V'-Z::\nMDV:9$Y5X$2$:33`]?8_.S@"B&XC-+S$;B3(XT(GV-;$03Q%Y^)#]0RYMC89X\nMPG`YU'1A;D&^#RILM;3VX;EFW.?;MOM16(OK>'C&X'E"T1DIIDQ`E*`D:X#D\nMK]0')N>0ZQI2*9=0"`(=?>P]/,+]QF=(1)<8OW>/8R\\,TKJCFTL?S=%Y\\1*O\nM?C7*<'<+]\\Y?(+)PZ/#<@MZ.$+82`SLQQCCOQ9J,$S5BI\\')&!QW>8GD02E!\nM:T$KP;($RU)8.H<3H5B$17`]<%U#QO5(9SQLVR.5,J0S`29Z?'SXP(,309*C\nM772X'A<_S;`8$%KW]:'OWL7Y]%UV['P1OQ/%/[P#5%!H=+"6IG8!<#=;&Y4!\nM7SF4E?`DN4H9R?ZD+)<^SZ%U>PLS2A.9V$Y[)$%33RN)@)_DL\\-\\%NIE^E_3\nM.*-?)NS?#XNMH%VL43F/B.`X3J%6)?\\K5=;+(ZL8*X9LC57U*Z>OBD[+"%$-\nMT:O@FFSI9EH%YV-P$&S'\\->>O;PE'ADT.OT?&5-I):*Q3LQ<1$1P73<7HEP]\nMY^J[>$\\YK>*:OQ2ZH0H-!)&2,%3P9.FY9TT)7U8F2Q`1E`B93$:TUEB]??VX\nMKDM/3P][]NPI+$!!L#:L1*^D5>-=::U:--NV"85")I5*N4HI+!'!&$,P&&1T\nM=)14*E53>#7SC<!5TI12W+IU"]NVL2P+8TS6@;P3R6221")1IJ#6O%[<1LKD\nM;?0\\#Y_/EW5`*852JL!4.M9CQ&;A*K-E53-\\-9'92KY24$KA>5[1`<CND)L=\nMR?4XER^CTD`ORT!IBK8BXJO!5;//JB16N]^*+-2+RV^V2JGRIU`MXS?3D=7B\nM2F'%#&Q%Q->2F=(,U'1@+8JKT>HU>K4.YZ&LA*KM`YL9R?7@EF4@;WRMZ/^O\nMX4HS4+8/U&J2IQ'Q4EI=/:!RKU"URJA>`S;58:6R0\\IMK;D//.TLY.=**;R4\nM3>+2.5KNWT3;($W;"GW[Q/]"FQ7Q>OB4:.:6;&Z__Q9=?_\\;@<MOT]X]C/KF\nM#T"J.%`*ZXUDO4;7PFFE>92:X2?3(<X]=#D4CO.*#M!^^"1&Z<*IR*IVXM48\nM58_1M=80A'EWEG^8W]$P<8-^&>&]9X[Q[_87^5;'/G:[$92JLP<VLB3JX1,$\nM!X<_S[[)#>L#%A-+'!\\8XN3W#->OC7'GMI^Q,0NML_VQXE^)>HW:2)Q6FHN1\nM<_SVYALXVB;@]3#9'B29:*%E<9@O=H;P639@(>(M?R-;CP'KS8Q20CKM\\H?S\nMU[CV*$&PP>5`[QCA>(;YVP>9VM]-H"'*G;OS!3UE/?`T(EZ&0_CCQ2COSW^=\nMO0^:L.]-DWIID$7_25XY.LC4D6V<.?-1SME->HRN5=;2B@M78OS\\%BRF6WE^\nMZ1"]P1UT!"<8:&YDZDL=B-3Y;W3+(IZO>ZWX[/X2KUVV>60:>/GQ8P[V&+[[\nMG>?H'PSB9KS<D5NY?<M*Z$E9V,B(E];]8CS#3\\\\N<)EF#LQ$F=`)CKW0Q?AX\nM5Y;7;V$,]65@*YJUN&;V<\\6OWYGC3W83?0]B'#:+'-C;PM&O#)08790I?:5<\nM]AC=Z@;6(OSE@UE^&;;PA1,<M>.,#PE34R-8EEY6+J5E7LB@2/&%IE+@2=%=\nM:_F)")967/UDD1]?=XG%'0Z&9]D=S'#Z]`CM[4TU;:G,@*KG5&X]F:DFJY00\nMCMC\\\\$*"3UR+_NLS/-MF,S75S\\!@1UG)5.HH=:!F#]2*6B6]7K[*>3KE\\OJ9\nM.?[I-=%RY7.>;TYRXM@7F)SLQ?/,$W6797(E`S:J6<LR`OS^W"QO+#9B?1SE\nMB!/GY1?:.'Y\\"*6$_,.REMXUG4JL-=*5=*V$LQ_&^,4=(159XD@LQHE]C9S^\nMQAC-S0V%8\\.:SI?86%9"^1MC#)[G5>WVE5)9#UX)W'YH\\]JTS4Q:\\UQDCJ-]\nM#J=.CM#>[L.V[9KK%0*@-9E,INQ\\M."`;=M<N7*%A84%(/=M>(51#T]^>)X'\nM&&)N`&5O9_B&RZA9(I6\\P=EWKW+FG>HRU70]?OR8R<G)@E-6SC,O'H_;KNNJ\nMRB_KM4JL&M3"YZ@L?#[K^YI]525[=:99-WK[]^VD^N?.VOJ44M+6UI9.I].F\nML)$!YX%O6Y:U8BVOIF%+KUHK,Q.>[7P4B?ZLJ;'A9F]7\\V_V3_0O:-T@QE!V\nM*E)-9R7>\\SS'&!/*AF4+(-C9`]`W-K[O^/#(KK<[N[JCOWK]1UNQ](:"SHT-\n7A?\\">74FVT/(N,,`````245.1*Y"8(+O\n`\nend\n
105932
 
6541    ImgUpArrow              begin 644 internal\nMB5!.1PT*&@H````-24A$4@```!`````0"`,````H+0]3````R5!,5$7NE<^5\nMBY*Z@K(<%!S\\]/QE#&T5#!>^8>H$!(0$!!`,#!04%!TT-#S+R]KT]/RYN;KC\nMY.V\\O]%ZDOAP=Y;.U.O6W/($-,P$%U>AI*SEZO==C?PP6:L%.)<:5L`]:KL6\nM2J%)>\\A/6VTO69%ZF<2-FJLC9+08.&`Y:Z=JELU_IM6KPM\\&:-HD8:,]>+@V\nM9)A4B<1->JUDB[:6MMIF=(.WSN=^C)LE3'(_=*E[N?:9ROO(VNQ#3%39Y_3K\nM]/PTDN-39G:IM+U1L?N>QN,76J[5`````7123E,`0.;89@````EP2%ES```+\nM$P``"Q,!`)J<&````%!)1$%4&)5C8,`!]/30^)*2*")Z5D"`)*)G`@9P$24G\nM*%""\\H'`"`A`-%R-)A`H(<Q@4%('`A0!<R!`%C#3!0(4`04@,$,6T`<"$@7`\n8`,P$`)G5$8O,2XSU`````$E%3D2N0F""\n`\nend\n
105933
 
6542    ImgRightArrow           begin 644 internal\nMB5!.1PT*&@H````-24A$4@```!`````0"`,````H+0]3````NE!,5$4```#_\nM___,S,R99@"MK:WSB;_;;::5BY(5#!6TA+3\\]/QE#&WAKO6[8^L:&2?DX_L$\nM!(0$!`P("!3T]/S#P\\2\\O]&BI*SBY.P$-,QRE/S+SM4P6:L&.9@:5L`82J,U\nM??P]:KM*>\\='6747-5XP68YJE<U^I-6)F:^_T>I^BIHC9+0E7)\\Y:Z>2LMG,\nMV^T$:=@]>+@V9)A3B<-FB[:?O=VRR>/D[/4E3'(]=*Q*>:I[N?:9R_M#3%39\nMY_3:KCHZ`````7123E,`0.;89@````EP2%ES```+$P``"Q,!`)J<&````$Q)\nM1$%4&)5C8"`>&&((H(L8JAE")6#`5A4LHF*BH:<'07JJ*B`!-5T$,`**J%@8\nM(*`.2,`(`0Q`6LSA0-7(',5:<S0^4"F:P]#Y.`$`?0\\1_AMJ7%X`````245.\n%1*Y"8(((\n`\nend\n
105934
 
6543    ImgDownArrow            begin 644 internal\nMB5!.1PT*&@H````-24A$4@```!`````0"`,````H+0]3````I5!,5$7NE<^5\nMBY*Z@K(<%!S\\]/QE#&T5#!>^8>H$!(0$!!`,#!04%!TT-#S+R]KT]/RYN;KC\nMY.V\\O]%ZDOAP=Y;.U.O6W/($-,P$%U>AI*SEZO==C?PP6:L%.)<:5L`]:KL6\nM2J%)>\\A/6VTO69%ZF<2-FJLC9+08.&`Y:Z=JELU_IM6KPM\\&:-HD8:,]>+@V\nM9)A4B<1->JUDB[:6MMIF=(.WSN=^C)LE3')SHH<D`````7123E,`0.;89@``\nM``EP2%ES```+$P``"Q,!`)J<&````%))1$%4&)5US$$*P"`,1-%<PD5WQ8TH\nM5*&4W/]H3H*H(_1M0CXA(J8Z6>H%%`)0^&`/L4#<PPL4,E!(0.&!&10LV!SE\nC'G3>-*?KAQZ[%]KML_SHVW(0'4R`)S(`````245.1*Y"8()(\n`\nend\n
105935
 
6546    reload_16               begin 644 internal\nMB5!.1PT*&@H````-24A$4@```!`````0"`8````?\\_]A````"7!(67,```[$\nM```.Q`&5*PX;```#6DE$050XC3W3RT\\<=0#`\\>_,;V9^PS[9I;N475X%FR5!\nM0Z"Q(%!*326E28U73UY[,=&#B1=.MO'6^`_HP4M/7DR,AJ*A"=@6;+NE+=:4\nMU[Z`LLN^V0>[.^.AT>_]>_PH_)<$!H`J;KQ,2:^<=CJ<O;9B<U(_29S63E=H\nML().B100>[MI`(P`SP"3B<'AP:^O7KQZ9>3\\B$=*2:Z28^=PAZ<[3TN;B<WE\nM0JGP+0T>$`$603`!LS.S[+7V/KYVZ=H/MV[>&I^?FI=NCQO=T#$Q\\?O]!+H"\nMTG`8D6*C.%>6Y=W!"X.O<OX<0NU6V=W>G9B;GOO^]LW;?5*1;&UMD;6.J51.\nM6/MYC8=+#S%5$W>WDX*2]V:KN<GTF_0C#)+"-FQWWU#?G87/%L8+J0+Q[3BQ\nMUS&.&QE,G\\&+U9<L_?H[Z\\OK.&P'C9XJF=.TMX5UQK;X1=#'E>LSU[^Z/'K9\nMW'B\\02%?()5*04<+-=1$[6S2\\UZ(8J+,\\P<O>3<R3.ULF5JCWM7"6E,UES;=\nM'^[W)E()-J(;K*ZNHCB@9=:HBCR%4!QK\\H@//[^(IFO$_TS1ZPKC=$FO-/49\nMM4VV]2M"(1:+L71OB7PY#Y$ZLA^RI!"N!NT=)KXQ07B@BW0R@ZOIPN&02*F?\nM4RW;4G*5'+ERCDPF@R8%1J=*5MVG*O+X?$Z"02_>]C:$4+$L"TT5&(:&80C4\nM6K,6BQW%P`,^OX_X=H)*Z81,XQ!5LS&DH-WCHK&KD]H]Q-_IPW8VT86&$"(F\nM[+`ML_7LC:R6E4$19'-]$U$T>&=H`(=7XE0]-#9<_+1PG^3>`>.?C-(:/*%6\nM;Q9+E?(=09BCJEV]<%`]B'1&@G1:078V8IR\\:F'NGZ&XIG#_QR?$MQ.\\_]$H\nM@7D'FI0<YH[NI8O'WRG,`TVF<')7#V@]8Z%1>M_T(@HZFJH#T.04$;)PC"GX\nM`P&B\\6?)Y\\D7GTK=6!&<`Q9)<)>8A369MHZ\\U4`)_:R""(#2W<08@K[1,.>[\nMAHDFHLEH,OIE<B'[6]LE'<$.\\!B(\\C<A'MD0/%6:H69;0ZKM"NZ`BPY_@$J]\nM7EI^_<?27XGU+_;_R2_Z;IBDORFC_,_Y`R`"5/'@8,ITREFWP]EOFH9BT=PK\nDUHO+I<KIBNJD:#UY*Q'@7S*):XDFM@ZB`````$E%3D2N0F""\n`\nend\n
105936
 
6547    home_32         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```"`````@"`8```!S>GKT````"7!(67,```[$\nM```.Q`&5*PX;```&X$E$0518A>V66XC?Q17'/V=^E_]M=_^;W>QNUI!$=W,S\nM7E.KU&B*%FO!M-0'*6JE0DJQJ%"17D`KI13Z4(JEU5I[`VFAEM(B@;;0!RT5\nM>XL2K#%73#3&O22[F]W_9?^_V\\R</OPWFFA(HA3ZT)Z7F8$Y,Y_YGC-G!O[+\nM)N_7X0[@MGJ=IK4CI4KETG:C\\??0^\\YVYSX00/!^)C\\&[``^UM]_S05;MSXQ\nM>-D57ZE5*ROML6/_NG_5JL;XP@)_?I\\`YZW`;Z.(I"@J0QLW?JXVONYAUUE8\nMY9H',.5QU+(S>?W0PY/'CS]7!_^9_R3`4\\"Z]>N9GYR\\L#HV]DA0Z[W3+1PJ\nMC]ZTR.BV2SCZZ]W,O-"'A,MF?&/^N_G4U)-!'#>/YCF?/P^`LX;@CR*$$!B1\nM3U1&1IZDDVP+96\\X?N\\`:^[Y-I5+O\\ZRJT<)PK^RN.MHC4[YAKA27A_D^:NC\nMJU?/WKFPP"\\^B`)_`DIQC+>V/ZCWW2]1^0&?MP;KUR:L^=(-U*_]&I0NQN8I\nM82BX]BY._.51)AY[D>2E&%&S3VSQB"F*'8C8CZB>/\\#S@$01%,5E$L??4H)M\nM03T-A^[J8>3N.ZA>=!>'CRSRS.]WT>X(FS8NYY8;UU(*YVD=?)J9I_[`XN]2\nM:`1-P3\\1H(\\",X4JUYP!X+00O%BM$H9A'-=JMYO"/F&LW5*]I#`KOCK&\\.WW\nM$0_?S(FY>;[WLW]0E*^@,K2>5Z<"1$\\P-N0P?>.4+AV"D:/HF\\U2<((M@;(Y\nM$O;WP^0]P`_/!/`\\\\-"55R(P6EZQXIN29-\\POKVBMBU@Z,O7TK=E.Q*O`=MB\nMSX$C_.2%&D?\\`*^U+<>DPIPU;+U@&BD:$/037K@:W=!$6W,23>AXZ.1F1-J1\nMR-X'1.SW3P$(`88'!K"'#U]<V;#AQW9Z^OH@/BZ5NWOIO?4F2L/7XXH`FTTB\nM..JU@FQH.;M;TN4W$0,]%6R^!U_,H-ZCJL1KK\\/>6R._<#?5'?F::(['!*XV\nM\\-"$R-S*I;P(`23/0:3I]QV<8+AQ.+J_?E'MNEN-J8R1=^91;U%UJ'<,EAS;\nMM_;RH^.7TRKUT=\\3<?OJ/?C6(?(BQ2_-4^^@NI+\\QCG29:_/C#XI!\\(VH7]7\nMU@G`WX!1P$"E^1UN"\\96_KSW@D]%`-Z_LV`7PN((>:OT8>;+:UGNIQB9?Q:;\nM',?9'.]RO+==)8"\\/4V>S>Y;]J)\\>NTOB[=2D63Y*;<B!-BR-'CIIR2JM,(D\nMEZ@UC2*H=TL+NJ6^P_N"07>093:E2!O,YFV\\S7"N0+W%>U!5P*"J2%"1V:OB\nMYLSF//GX@^W3%`A/'>0Y*&!U$3][$#$QZOV2"A;O4ER1XHH$9U.\\*_!>4>WZ\nMH>!\\MU4%58\\JA.68P%1QW@!G`RBZK>8=TLX^%(-J=\\'%U//R&[U`B'>*=R'>\nM@W<6[SW6P5`=+EX-_FT`4!4DCA%J7;AWV6D`6=Y-BB2#)`<1Q8A@C-!<%+2R\nMD:$50Q0>U&6H[\\9<78%K3S(],<7R/D$51`0C!F/`E$L$4L6I/3M`GH-1V#4]\nMCK_\\0<*XW#UEEE*9?QSO,MH;OD"T\\BJRM"#+/5GF23.HO_8#DD./\\W+P608W\nMW82W#N<-,O,RF]RS5$T)K^5S`X0>&F:8(SVWX'V)HIVC[18?TM^`G>6%B9#Y\nM!<%U%#*/9A:;*%=E$=[#1&4S$SV?)&\\FY!W'<&'85-J)U^C\\`$1@,5%V/#>)\nM[P302JF[G,WK^O!NBE?V-W@C/=:-4UI`8B%5QBZ"`6/8>WB1_6^^"<T.-',^\nM.NJ(-@]0^`0OI7/G@`KTT6&\\\\0IBR\\2$+.\\I,]A3Y7BSH)HV*#7F"+,"R163\nM><B%7BDA$C":O47:?H62$Z(P8F,_1'$O1>XYTZ?M/0H4P%B\\G_N&'\\($,6%8\nM(HY*S,^>(-:`+ZY\\G&2D1B@101`3!24,%2(_Q<X)QPWE7W%C[1F",":*2H0J\nMM%MC]`VL(BNFSJ%`L50G-<=HCN:0*:0*K8Y`V,-893_.>KR"]^`L-*>JM!-#\nM7GC4MM&BC5WR4PS](^,$<1TO\\^<.`="M@$OWV"]5S;P`M*`H%.NZFW<K'I0&\nM.M@4W"RD>?<0;_N*H!(C414UYTC"]&0A.EE$3NEG!1A?8&T70/5T"*]@W9G7\nM<,28H(J>*PG3_)W^Z=5,20N(U6$=N%,4.`G@+!06DDP1WMD<49P7U`2HO/<+\nM>B8%%$4543$AQH28,"+P!F^;%(7#>=!W`SBH]`PRLFH%(K+TS@I&C)3*-6V<\nMF")-VF<'L-U*N4MA.X@8#&I"D`A,2%88VDD7X-3-3ZIGPC+5WD&,`"((`B(R\nF,_WZ0G/_/QNJ9W@,_F__\\_9O.@?:"4TZGOH`````245.1*Y"8(*,\n`\nend\n
105937
 
6548    clients_32              begin 644 internal\nMB5!.1PT*&@H````-24A$4@```"`````@"`8```!S>GKT````"7!(67,```[$\nM```.Q`&5*PX;```(&DE$0518A>V66XQ=51G'?VM?SS[WN9PS,YTI[;2E4\\JT\nMA=IBZPS4MBJ*+45#0+FI(20%0:`&;P31!U`)*(D27\\!$,5ZB@1A,3%!>L-=T\nM:J=VRK2==MI)YWXY9_:Y[/O%AU%2*,68F/#"_W$E>_U_^_]]ZUL+/M2'^H`E\nM_I^;+5Z\\F/GY>67MVK7Y3":3J50J<:52F=$TK>ZZ+B=.G+CD&^7]-KS^^NL9\nM'!S4UJU;5VQJ:FIQ'"<Y.SM;FY^?'U)5M6;;-J=/GV;[]NV8IIG:L&'#S=W=\nMW;?D<KFKIJ:F\\D?[C]'?WW]D;&SL,451S[R7QWL"]/3T8)JFWMG9N6/7KEUW\nM=G1TK/4\\KVEX>%CM.W+$FYZ9^=OT]/3#BJ),]/;V\\L8;;\\B[=^]^?.NV[5]?\nMNF2I-CIZ@=+<'-6Y47#F%KN./6<T)K_=U=4U<^K4J7=XR>\\V[^WM9>_>O1PX\nM<.#!;=NV_VS3YLUK=2W1>&%T-#$X>$*;&!DRRG/35]5MSTNGTWU1%+F%0J$M\nMF\\W^*!%,%6='CE(:.49[8H:;KH8US26.C8KUJ]==-]/;V[-_W[Y][Y]`K5:C\nML[.SX:.;-MTU<F8@.3-\\F$K%1/@5>A;YW-F59%]?*/VR+__-:]9OF"D4"L^_\nM^.M7O8RTU[[_4SM9WW,3$B&2;^*7S]"9KW/PY'$.CX_7RJ69_UZ"4JF,&\\0<\nM/7Q`ZFE?Q:VWW8:L&B0D#]DOXY=.TZA6V']N4BZ;577-JB7\\\\9G;6ZW10]7N\nMKF6HBH2D&,0$Q,CHBN!SUPI[59C3MUR=U@<^ML&]\\X=][PWPT%;!BMZMC$R:\nMX=S9`T.?V;)N?6-A$4))$`<V834DE@U:&U-\\OMNJ_^ZM,Z>5:H(K&YH_WMS:\nMN5E8$X35+'*RD=B9):I>P+?F6+&TU5A9;+^]__";+V<EV;UL#_0L%WSWN>=I\nM5:OW?7)M]MY\\)F7(JH$DR<@2A/5)_-(0;OD<;<UI><>.G4MD\\ZV_M(<#_7JZ\nM83RL3Z\\DJ#?BUPAJDWCF!3QS+!3P*T/7?K#^X8.G2W_^&B\\=O$P)%!G&7GL"\nMS0[ZL\\7VL;@^E@C*6E(*3)`D0O,\\H35+Y%MQ)E,L*?[P/Z2QPZ5)T>*N7M7V\nM4VO\\:-(G>CJRYZ7(M_"J$P1N[;A3F7ZB/CL\\VB(N'3OO2&#_67A@0PU1N7`A\nMT=C^BE^;S.'7-Q*ZA'89OS:%7QG'JTU/!9Y]5[:X_!<=*U8ZJQ[H8\\^6`)5H\nMT+(JW:%37AE'(4ZH5.RZN<=M6W.H]>P(SQZ^Q/_RDW#TQ6LACM9(:NI/LI[I\nMC(D);1/?,;'*X\\^.G:U\\R\\J)<-=/8A*/)XJK5Z[>>&[NW-6/'JI^]H8KDC=@\nMY+$G3?,UU7SYI6NR_5H][JM.5@<Q\\'CR,@E<K+LVM=">/C8]73;J@5.ZD=!5\nM0JT!LQ8<+$_-[AEM2)BWS[AJ]Y>[[[AGTSTO;%ZR^<'CYM%/*P.U)8O&`E+3\nM)G(0)5Y?IEX77M&Q<UEFV:V.Y*RHV_7CRHW*?+0^@OV7',.[@:-"U[_2<=\\K\nM2WHG3-9?Z_]\\[2,[_BZ2^31..(%\\OM;QY)L//]47;1C(K_N#MNWFQ=^X9O&Z\nMW*'20=QTG8$O-E.J*S1($F9:,)X,D$)'6%&E("?E>Q5+:0OJP=VD*;VK";\\/\nM5(RNKD?NW;&SZZLK5Q56O/#[\\\\K(X").]659E;')JPIGZ\\L[1K)M7VHM).-6\nM\\87XZ,NSDG7+22;:3Y`Q=!JS6=2D@:^J&%%,F^,R7Z\\S6YVDJE0(]?`3A&Q!\nM\\.I%`-\\#GJ2EY?D'=NZ\\\\JF/;%RD#XY:#%<#:DMOY0EM*T6YCI`3C&>+5+04\nMF3`02FB(RD">DX,5VAYUR"S7R1M)FM(9THD$,5"U;11)(HPB7-_'=7S-#\\,K\nM48"GWP:0@.\\L7;:L87<F:^C'3YL<FW"P#!6:<I3S[913.L@"_`"J+M6RS:E9\nM"Q%!/-I$]->E='5-D]`T,H9!(9M%$@)5EO&"@)KCDM1T=%TE].)B(I_`\\JW_\nM``A`6^8X<?M;)RM8JLHY.R9*:Y!/0,&`7`(T&;P03!54":*8V`VA%N*.+"9T\nMCA#%$7$<OVVNRC**+*.[.G(DD='2I))R<>KN*<%SQ!?U@-0\\<'Q..S\\NH"6#\nMU9B$0@I2*N1T*"8AI8$;+H"$,=@!U#Q(>_AN"JL64<\\[5&P;69)0%86ZX^"%\nM`:J=(+`B%$6AR6AIGGIH2B7"NP@@+OA!*)=++G)"$&>TA60D`:H,20V:D^`$\nMX`9045$2,:$N$(:"+F<PS9!$O@9(V)[W=OQ5QR$9-^/9(78B1)<33322P,=3\nMX+%_`P1%B"`*,2@3DL/VPH7(G0`L'ZH>A-'"W\\>0D2RJD0.J1#'7$,V6Q)32\nM5/7",*;N.*BR3!!%.+Y/H]J)'T0D24FQ%]=$+'1<4,`'6H#A`O@0>J2E&GX<\nM8=<\\J+A@J"!+8/L+K#4/[(`&)<#RZOB^04YJL,S7=]Y?7_/C([(MRV$4H<@R\nM413A!2&Z8N!%(9Y=9VA^*(C]N"PD@0(!0AR4XSA7!!6PR.H"'Y@KVZ#+(,1"\nM$DEUH21.@*AZ%),RDZZ+;ZL(3U*;9C8ZP8._&1T:NN.2R7J"WUZR%A.C""$`\nM0Q$BK,6Q.P12F#*R1$)`R5[H]CA>J'M"60#P(X3ETYS74)R(G!R#'T2692F:\nM]K[OW$NDQ'&,$)('\\1X(5`@`%=F/%J).J0OW=,S""9`$!!'""9!#G=B3J,XY\nE_/-\\#=^S*D)(_Q/`A_K`]2^6(.KG=#/%80````!)14Y$KD)@@I!#\n`\nend\n
105938
 
6549    reward_32               begin 644 internal\nMB5!.1PT*&@H````-24A$4@```"`````@"`8```!S>GKT````"7!(67,```[$\nM```.Q`&5*PX;```'L$E$0518A<65:VP<5Q7'__<U.[NS3Z_7=NS&<>)'W!C3\nMI"TD!$$?E)0B-6K*A_(%PJ,%"2%5!?$,2(@66J2&5$)!0JBE@H($%8)0*J02\nMFDHH)"%5:$V>MN/$S\\3V;KRSN_.>O9</L^LDE$=<+'%&1SL:[=S_[_[/.7>`\nM_W,0`/CI@1/X]K>^@/L^_("8F9G.U.MADE+**"4*@&4DDN;P;=O=Z8OC^,'C\nMGU]=@$?W/`TI59HS\\F"M5MG9T5[HSV72&=</J.-XRO&"FN,X4S%-^Z-A&+]@\nMC,YY`<&37W]D50#82R_]'F^,_/V+%7-IW^!`[Z9[[MC>=GEN+G-A8C(=T_5T\nM?W]O:VL^WQL$_HY,.KEF9F;Z957WZD?__*=5`>!M68WLN/^C`UUKNUGIBHF3\nMY\\XC4`2;A@:1R690:,W#MAWXKH7QL;'>UPZ^JK6TY+Q540?``>#<Z9-D86$!\nM<[.7,#4YA;;V-F2S6?BA1,URX?D^QL8G</K46>7['JJ5ZFKI1P"$$@2^AW)Y\nM"2`485W"=7WD<CED<P1A&,)S?1`",,I`*%U=@"@(""&(KL9XD,8S0@`"$$K%\nMQG?<TFLDT\\GAV[8F&6.D7J_[4"@FD\\GISL[N)=NVU)-[/K-"!P@!I12$T$BL\nM(=[@`B$`I12:IFW:V+_^Y;[>GDP8U,6264%=$>EZON4Z[J3KE%_,9M(_>F+?\nM<TO?>.Q3-PX@E814$H!J[K3A1O1(*4!*B:1AQ.]\\_WOC5-7QAU=>15T2#&P<\nM0&=7IUXL%O.52F4S4>%"1UO^N14Y0`D%`8%2*DHIHU\\H1`P*A!#8CH/#1U]'\nM>WL!`X,;D4ZED$FGP`6''A.8-<MTY,V1;$N^Y4;U(P"EFF5@C5(T^H`0$(+E\nM/K`M"\\?_>AQM;>W(M^:1R:212J61,`R42B6,C4]@L5A2-<M>&0"@(*5<SFCW\nM$9AJW"BE4)<2ONV@6JU":!H8$Q":#A'3$88A"*%@E()S_I\\TKXM_FJ=(,=)4\nMRV50425`0,`8!64,E!!0&CE#FY/2*)J4<F4`A)#&;$<MW^C_Y29<_@\\AD4--\nMEQH61?>`E.KJ\\Y4`-!>B-!K'9A)*HB1H",F(9[DT!%>EU/+DKB26BZ74]7T0\nM[51%>8T@)""IA*?74-,``SJ42@%*18<8(:",K<P!X-J-*%QK($$THI+6@18?\nMN-F".7P!Q4T3L#?9,+:L1=O0,'+=&Z!G,Z`Q0A6`KQSZ\\HT[0"DEG'-0RJ+3\nML'$%\\+&(&2SR:<RL/P\\V))'/]J`K>RNZ,EO0:O1`$S&XN`+90L!:7:2WA1_3\nM,E;R0G#QZ.Y#NT\\5DH7YL\\4SP?Z[]V-=K.<M``0`Z>D??CZ9RGX\\D\\TCU]**\nM1"$&O]M$D+,0)B1T?0WRQCO19FQ!-MX#C<<A:1D.G4"5G,$5^RRFQT9!.0&C\nM#(5U!5!&W7HH9XC"FXRQ(QJ/'<LE<^?>T[VM-._,RT^W/'P58/W`+3\\QDNG=\nMR706+;D"*KE%'#=>P;K.0>S<]C1B=!!2ZE"D"EN.(4R,`HE9$%[%E9E%5!<M\nME&?+B"?BZ-_<#RD5RO-+X()#BVOH6-^!4(;5JEN[:,02)[KR78==SSMV9NS,\nM::Z44KV#6RS&&#@78(R!$,!S/5B5$*U&'RA+X\\+E$;P^\\3VD\\Q[2N03B?@)Z\nM7$=,CR.Y-H.^@3Y4217C<AR).0/VE(W.=6MP4]=-T&(:/.FE8K'8<(S%AHM7\nMBKNG9Z='%HJ+._G&X6T@E#X3!&'-\\[R[@B#HKLMZ&A3Q4$J4+!]"U%&JE3!R\nM[A`X!_(M>71V=&)-1P?B1@(EKX2R:>(\\SN,R+B'A&!AH[T<VE44I*"'K9Y$V\nMTG`=%[.79S&_,`^S:J9=S^-\\].0Q;-YZSU@8!E]5BF2H)PJ3Y-PN0O!=!<JN\nM6"$H#U#S@:21`N##<1U,3D]B?N$R=#T.-W1ANB8LSP)\\@EJ]AA/UO^$D.87!\nM#8-X]ZWO@IMQ439-F!435:L&R[;@NEXT!6\\<.]@<Q;+XG"@KJ!<%Y9U:+'G7\nMDJ,&)$*]"4!H`,XX&&/@C($QCK@>1VNF%5))>(&'@`30XSKZNOK0NW8#`,"L\nMF+#L2-BR+=0L"Z[GXBU?C>"'`0I?*UQ87%A\\+),:*#B!N-T-Y;UV$-YI&,D!\nMSD*=-0%X!-`$X3Q*H7,,W3R$;"+;V'4Y$K8LU*P:+*L6.*YSU/7<\\G\\]/(?V\nMCT+1?L+"O05.?GF[)NC]FA`?Y$+T<,99TPG.(RC&.`07V+!N/0@E*)MEF)4*\nMS$K#_EKUM&5;^VS;^E5,BU56='I_X(6[H0#**.T60KM7$]I#0HBMG/,$9PR4\nM,0@NP#E'-I.%[_LPS7(D7JV4+=OZF>W8SSSXH5T3+_SVYQC]TBC>QN<#^.1K\nMNV'9#ABE:2'$^S2A?4((L:->KZ=]WT<BD0#G'&6S#-=SE6591VW'?KQ:JQX4\nM0@N./')D>:VW!=",/>>^B4IE"0!TP<5V(<1G/<^[;W)Z*F563.1RN8J4]1_;\nMCK,WH>N7YHM%_.7AP]>M\\3\\!-&-O\\?NPJC4`2M=C^AU!$#QZ<>KB&K-:>:):\nMJ_Y.T[3@P`,'_N6[JP+0C.>#9U&MV0!4;O;27.JI[SPU_9&'=JE?[_S-OWWG\n5'XD"KSY"@AH;`````$E%3D2N0F""\n`\nend\n
105939
 
6550    accounting_32           begin 644 internal\nMB5!.1PT*&@H````-24A$4@```"`````@"`8```!S>GKT````"7!(67,```[$\nM```.Q`&5*PX;```%ADE$0518A>V6RZN>5Q6'GWU[O\\M[ON_+N24G'I(F:DPB\nM-J1I;$H(BB`%%04GCG4@*H@*3BP41PKBI"-QU)F(`RD.!#4@5;S6E@I!3*$-\nM";8<3\\[]N[W7O==R<$XB3OP'>A[8L-E[L]=O_?9BL>&88XYYKV,>35Y\\;>OQ\nMXJF%#G6CG,CMB5ZP5_O!/IUG=KF?V=0+=E,-=^_M-'=OWYT\\7,R]^>3%P>GU\nM8;C<)KE4-'*J:,46C6P5C;Q>MGIG8Y(F2WW#=@&J`BC?>'H)`/\\H:-L:5%GQ\nMSGQI7";-,[NN:I[UQGRD:UGH6LA0`DI44Q:-/GCGX?X?=S/O;IY?N&71LUZU\nMFZ&(@62A,6:BJG<&F7EUOTB;;2L2D[YD8/PH[F,!213%7.Z;]-V>D86^L8Q,\nM8LG`T!A\\J[AD\\,EAH'>Z8RXO97JY&X1EU^*JB!/%J])5I2,1CPZ--;?4<DNL\nMD-"]6LSOC-$W_D?`"Z\\\\Q!JH8[J^UJL7/CAT=$)@<9#3ZP2\\A5B6B"1"YJFJ\nMBE5:3G4BW0"K+K*0Y7CO44`4QI,Q&0V+P5%WH:P:WHKMXG[=>RHX\\\\8+KVSS\nMO4^L8A]E_^;4.U*ZL9H'5@9]5A>'Y'D/YQUI-L&T-4%:@H'<"$.;L*H8`UGP\nM&&O`@'(X>LZ2:\\O0PTJ><7HA8[7O#"D^^YU[JR9)`C@4$$49N7C2:KPRZGK:\nME##6(JJ'=9H/J4.7PG9HL90X&C7(4;:BBJH>!M>C)W6!TF:T&%(21)1!YK`2\nMG_KFZ=W%)/I?`4D42>EB1CK;SSPJ8(Q%!505:RQ&!:N"B(!U)-\\YLOOP(E4%\nM/7)`%6L=JDJKAN0"C<OH99[,I/=KBA]X+.!S/WP9:SW5?':][R3WSH`U@'F<\nMD:KB8X-O*YQ$0JSQQ1B-\\6B?QPYP]`3&&$(]QTYV<6V-E40_<_2M++95<4W4\nM\\/6?O89]9V./G__T)V&ZOWMS%!05Q3J/FL,V(:J4=<-,+97O4D:E5$/R&2*'\nMU@.D),08:9J&IFFIVY:F.Z0./=J4\\!+))#'TPFQ_Y^:+G_^8_?4O?X5OR.B,\nM3J[%F)Y<'72(,1)"CZJJ24V-:L(9@[,.ZX[ZEG&T-I",)2:A:1IB;''.(:*(\nM0A(YK(V0$6T@&5!1EO-`6U=7SWSA:\\OJ[;8/PQ6\\\\9<KTULO?,YT>D"*+<$[\nM!$.=E"8IQAHR9^AZ2S<XC'.(*DD2:@P1P[1L*:/0I$,G'YU/=46,0@+J[I!*\nMP[E\\]<P%;]GV6U/ATH6U9ZIRWIM/9[0GNFS,A'$3F29+(8XJ.9QW##J6E=RQ\nMV(6Z3$R3HV,=]V>*"9[MPK$S3\\SJA$BB9X6>;5EPPB@SY!W'?#9G-J^&2Z?/\nM?O1@;__/_EN?6N_\\;=,_\\^[;F]Q^=8^U\\Q<P+M"VD9U)R=8T49DN6:?+L.=8\nMRAW=9H_Z8(M[VQ7>P&Q_`SLX1=598:](3,M(K`IZIF9M&%@>Y63!HZEF\\\\$]\nMQKL33IV_>..+UY:<.?/IKRR'X<G;R81KP]&0T>K[2&HI(ZCO$?I#0CZBV\\]U\nMT/,L9&JF&V]S_^]_8O-?]Q$53JX_P;FK-QFL7V+>6IV5#4TQ-4TQ)A83;*SH\nM!O`6QEL;'.SM8C7^H3WX]V?\\>'_?VUEA0V]`6Y>,IP6A/](L'XU#/_NGJKRN\nMDMX2T;$HQ#8.R]GD7#&?/MG6Y7E`R_GL7CF;_J,7VP>BV4Q4C$HZ@:0/J:3K\nM95E>GNR,!VTQ-K&<TA9C8CESTC;6H[)OX'G0&X@,4:U1N:\\2[VAJWT33N-QY\nME[]^_[,`K#WW57[TFQ_SY8^_W`46`1WO/-S__0^^72_=>HZ]W[X$P)7G?X'O\nM](W$=H3$#Z-R!?0)%<E4]0#X"^C\\_WX6CCGFF/<$_P%EGRR9&.R,HP````!)\n'14Y$KD)@@J-R\n`\nend\n
105940
 
6551    order_32                begin 644 internal\nMB5!.1PT*&@H````-24A$4@```"`````@"`8```!S>GKT````"7!(67,```[$\nM```.Q`&5*PX;```'8DE$0518A<V7RZME1Q7&?ZNJ]MYGWW/?MQ]Y=$*W#1(2\nM<*(@*@8A`\\&9.)$,G$@R$<%)!/\\!01`C"`V9"(H0<.)`104AAB!$-,0'D;3I\nM[B0FIOO>F]N/<\\Y^U-M!G7OM))WV.K.@6`7[45]]WU>K5@EW:4__=@]`$KE)\nM223F3$H04R:1B8?C?!B%PW?ZOF/OZMM<W[^6;UW?MTJI_.<??OT#<YB[`5`"\nM"#N2Y;M(/I,A(9FL@`2Y/"]-`/)RG)DT#9O;.Z3@$\\F_M+N[^Q/@U>KA+V;_\nM]Y\\=S2'<I?W@N3U"RO=/:_7\\(_>UYYM*$6(FQ(3UJ8Q3?E^$&#,^99P/=(L%\nME]_\\)U=V%Z]??NW5;U_ZZY]^M'[BE)^]<.&_,Z"5$!*TM>;,%/[U^BZCS;A@\nM^.C#.\\1*,;,)&Q+6YQ)#QH6$\\AFT`;/!]GR3!\\^>.[>]O?WTYO8)_<<+7WWF\nMH<?/<O'9;]Z=@6=>V,>&?/^I]>KY!W-__KE?7^2EO_6\\<BWQXPN?19ULN33S\nM=#;1C9&%370VL;"1Q;@<CQ$_>Y?''JQPL>;U:_,KG?5?4"(7G_W&IU%W94`$\nM(X(6(2;#+_[@^/E5PXV/G:'>:&AKH:U5Z8UF4JO2JQ*;2FAJ!=,M?O5&P$AD\nM:\\6<JXSY5&7T<20H74E&KS;8AT[SP+WKG'IDA]6M"1.5.#6%SB1ZDU@U0E<E\nM^EK1V4C7J,+.1./73G/FW@E!]W+@YUO'!"!H79Q]_OZ6GSYUGJ`4RBBV\\P`A\nM<TZ#K1)>$J[*N$G"A8R/X(*4'HMY5R?".W7%VOHZ1LGQ&#!),$IP?F10'B\\5\nMP^"Y/.NP4?!2L9AWC`$<-<-@Z8<1JUH&Z[%]3T>+"HXO/;Q%9:JRL*7[[@K`\nM*"'IX@520GM'(K"J*K)$6BVHJF+J,JD6,(JN$A9:2)5FL)'1"+DV1!=9,64Q\nM6@2MC@%`2T&JE*"`C9R8.4N]6H&&+$)5"TVC0`1=*SK1=&A4HQAK3:<TJC$X\nM&VAK1:5EZ:UC2*`4Z`Q:0$3(`EV"&RXQMPF?,MD&YG./BT+2BF&P#(,C&L-@\nM/7WG<'H$;_G(R<*J5L=DP"@AY\\(`0,ZPJ865B681#2**9E*S:!I$%/5D@K4:\nM:PV3E54&ZYC/A:I=8QQ'-EN-^5\\8T`I2+E$`$;@>$E>'P&SN<4E(6IC/1FP2\nMHB2&860<1[Q.#-8S=!VCBJCH>>*3TR*!<#P3:A&26IH02"FQH:"M%=V*1I2B\nM;FH6=4U"J)L&:X7@->UT%>L\\BX70K!0&ME<TYL:A!,=BX%`"0$!$<2L)>RXS\nM'Q(^)I)Q+&:.,0I1"<,X,@Z6:,!:3]=U6)W1T?&UG0TJ(T<)[@A`SL`EA`V@\nM!3P0X(G7UO*7M_9$RPI"1@2V*F'2:A91@RCJIF%1^^6X>&`<-9/I&MY[^D[3\nMKJX3W,C6BL8L&3UB(+\\$O(+D@2?#NSQJ'3$E2!&^DR3[;FW:KSQV*NW7^'%$\nMQ4S2AB9X9M-'>6OG*RSF'I^$;&2Y"RS4FM%ZQKXG5H)$QYF==;12[Y4@!M`5\nMQ,AG?O\\7_?B-_EY4=C2U(45'92#'Y]`2$<DH,EI'MM>%^KX-MAM%XS4Q"[HV\nMC#HRF(B95#@'0UVA)PTY0*4%)<LSYM"$SD&KP%J8=6M\\_//?9W'U139//,#-\nMO8NTC:'O;Y+'=T@IX+L]*M-C*H\\-D'(FY[S<IF4<4T+2LCK*&2$7F7-&R?L8\nM\\![:!IPK9C/B4004%DD6-[O,.+L*=@_OYF1:DBS0&Z=Q`7J?L%EA(X00\\3X3\nMLZ$;(SXDK%>,WF/(B#;E9+W=A,Y!WX'W0(JX[DW<>)W%[IO,=R^B_=OT@Z4R\nM$ZRUH%J20!4,)U8F?.+\\:3A<X;*)W%[G'-:)0LH@UQ:EQKB=@6`*`^2$7[R%\nM6[Q#Z%YD[(5)+7@/.0O.059"4L(D&F*4DIT0Y$-K*RF[H>^9KJZ6]'X;`\\H[\nM"&')0$[T!R_377\\5[P/>@_-E8NM*=+X`"M$0PIVGM-9R<'``P#`,[.[NDE)"\nMB4(M5W^8W(SS9?7>0PJ.^>[+#,,$70O6"4*)50;K*/950DB&&.\\,((3`_OX^\nM(01FLQE55159RJ<?],"@"H@4(K8?<'Z"17"^?.#<?R3`"**$&*L/!5#7-;=N\nMW>+@X(![[KF'DR=/,IU.2U:5DF'-[1[0>LE`*M$YH982]1)(I@"0O`20/EP"\nM8PQGSYXEQLC&Q@;3Z?3HF5+O.PN<@\\HL`43P::F[@/,E;5HG!8`ODAP!B.6T\nMO)/Q3IXZ34P1K10Q'>:)<JH:A1Q)X'W1UKDE`UEP7N.5QGN-64:UC%H;$A69\nMAH.;??>/77OS:*LM6\\IELI3+O;$D*X@)YF-41JOYX:8QSI4[GG.PTK;4]19-\nMGF+T)LUZA=$5[09HTQ!C0IE5C`9G!P[>^,TOV\\_Q+5)XSR8LV;!<6./RXAK3\nMLK80T"('AZ!-"*`TQ,CO:AE]<GM18B[%1A)<A)0%&R$E*3^*@G=.QYB>O_R]\nAR948X<EG[NR'__OV;]%V7T^NS&(2`````$E%3D2N0F""\n`\nend\n
105941
 
6552    industry_32             begin 644 internal\nMB5!.1PT*&@H````-24A$4@```"`````@"`8```!S>GKT````"7!(67,```[$\nM```.Q`&5*PX;```&=TE$0518A>V62XP<1QW&?U7=/3W/GAG/V%Y[_5A[O<XZ\nMCFQD$\\DHD67D`(D4^1*)"Q=>,D(("7*P"`D(!8E('$"(`Y+-`0DDI!PX<7;,\nM2R`B10D.H!AV;:_7NSLS.SO/?E9W%8=9;-9VA`_FA/_2I^Y2?_KWK[[J*C4\\\nMKO_W$@]CBDX`8&T.L_P[#_;];`H4.$!JP)Q?^^^]Y<,`&`0&<3#3XO-!B-L[\nM^B&@$]\\YI<7IO"/Y8>,1`4PH3$$7BM_2!??"<(Q[>_X!S6P'85E/6(7BI=;8\nM/.M8@N_5'A&`\\3'.J;-%^_0+KPK/OC#T<?]Y>*LG7ZV1*Y;TW',OS-4/S%SJ\nM^!.(U[Q'`$`&HE@VQ9>^X+K/?.(56;&^,0@I_.705IO.,AI[]G'\\^7/S]3U3\nME]KA!.+E\\H/;VO^^>?5'/T>EVFG6O#/=UNW&VW^X,KZ^<.VR[3@!O`,23!0@\nM,T7E4R\\5XB!X)?CS[ZV!G[WQIUG"4PM`EH'1J.&`;;OV<OS4L_-!=/G22GOC\nM2[6<^.V72_`3WSPX@6IWB6KW9JFVL?1&8]3^Y3[7^O$NQVHV=38Q""`.T;T.\nMI#'>,V?=XI%C%RQ7?'.H*+QU`(S68`SI:$C<7:>6SW-T=FZ^6BK^="4V9PH2\nM/EO8NO'N)/"YMWZ`"0-RAPZ+CE7AN-L0BT8)/>J!.P$P<0B]-EE[!=-IX=5K\nM;MC<?B%H=^Q!8KYK215DQI"-1\\1)ROCZ(J7!B,,Y9\\ZWK(NKB3Y?<[CRZ9S@\nMS<1L!6BJ`<0IF)!(%*DF,8TD1J?IW:SB$+UTC30(N5K=SXHU16TNGRLE;[\\<\nM=C=$KC?^=E)V4?T-8LMAX\\AQ5C*!?7V!0^^].Q?YP<65V)ROVEQYT1+\\.C-W\nM`>Z>20*M->,;BP2M%I+)$@@))AC"J,N[.S_"]W_W/K;C<GCW+$\\W5G.[M/EZ\nMH#<,6F?I1I?>QY[C%VL#AK[/_%,G:=Y>X<EX>2[(THNKL3GOV5PYJP7VFP<%\nM!AJ_ZJ1?J4BQ<_^MUAYM#RG[@_JIZ?"UNL-`&7!S;-=Q6,J0_*T7LF?O?AKU\nM&OU>EUL*CC9WY,+4?"WH#3I&)=S,H+%CBH.5,KX_9E7:S`C!,2GG5):]?C/A\nMQ:)@:&_.NR:-.:\\UTVN=/D79Q[/P7(LO&L0D'+'I5#'>>)DD+I/?O8OB\\H#]\nM)%B6Q?9&,Y]D[#5*(:]?(VSL8_>N*:+5VS3Z&T@A:`K!TX+:;HSC&!#+QX"4\nM63ES\\#>R,35M8["$P9)@";`L@25`&HVR;+)<GK:?<GD`8VTQ$_>9)45D&I6D\nMQ)$BB17C%-YSR@QS!6KM-7;W^XA4H^*45*57=68^#G3MZ9R`Q,#IY^'D&1AV\nM(1A"-)YH<VQ,ADP4::389AO.E11AE&"$(5&")`-C0`B!E)("*2>&':)(H94F\nM!1*M`3";FNP"<W>/T^_07UJDDPE2E9+$$5X4,Y,,(>>",0@IZ>^<95WGB*.8\nM,%(41CVJK:6M1YP0B">/D[IEHC`FC!6BW4%^\\/<'G`,"",?0[W`ULOAC?IH;\nMMVZQNIYP9OLVONKT$)O,0DK>K\\[P5[O)XL(B:[T^9_)-/BF7M[Y?6G2>.,;M\nMZ5D6%J[3[O8YXGH<_L<'6WSR#D#@P[!'IE+:W1ZKK0X@L6R'>RM-,UJM#BMK\nM;002V[(G^?\\G`)"FFE9[G=75-B"Q;?N^7O8=C-"'C19*55GIQ.3</"6O1K$H\nM(-P:;9PH;JWTR.>+E*MU\\G*$N;>S@$0IEGMKN/D"Y5J=O$GN`[V[!,$(;@PP\nMVYY"V$UJ%8]BI4JAF&P!$$"::2S+H5(M4_)JN(FZ;V8"R#*-M')XE4U0?W`?\nMJ`UF@M%K@XJPISY*K;2=6J5,OE0A3P_6S83<:#`")^=2VU:D7O7(5SS<C1%H\nM/9&9R!B!X^:I>XW)9#R/0K_](4L@@'X'W#SSTN<S.\\$I:C([Q(LBJ-3!=4$+\nM,))C>W?0G&V0R[DH;2A0)K?W`(0Q(HH184*:*`XX4*M82#-&K0]0JTLD]R9E\nM3@*&G3CV=RA[#6H-0ZT.Y2J4/2AY4*I@BF4RZ9`)"V.[:)DCPR)5"N7[*#]`\nM!0&)'Z#&/LG81P41B1\\0#4:$P]'DVA_))(IOZ,R\\#HR$.;&)8DE)8J!O8`PD\nM@`+T)"&309A.'HV`X:8"(&+RF:A-I4"V*</D&[<VY<C)AM;:Z(?Z)7]<C^M_\n77?\\"8?DH/"FW\\@(`````245.1*Y"8(*V\n`\nend\n
105942
 
6553    gear_32         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```"`````@"`8```!S>GKT````"7!(67,```[$\nM```.Q`&5*PX;```'ETE$0518A>V766P=U1G'_]\\Y,W/GSKW>KQ,<F^`X7H03\nMQ8*2F":T$!+4D*300B'0EQ9H2:M`*5+]T/:AB%*%"J$24:FL21=H&TNL:1&[\nMA$I"0AHP*0W@>`G&NZ^OKSUW[FQGZ4-2IVGL$E#5OO!_')TY_]^<[W\\^?0-\\\nMIO^SZ),M_RJ`47)6?-UI:*TICZ0V^H<+0P2(:.\\-GPK`.-.%BRY_#%&LZJ]9\nMW_"]IL5E%WB!K-WW[L1$WZA_M6'0$`#@_)V`1@*^S]&PJHCGK@`P\\M\\!\\&,@\nM%D@2Y]=,>:)NWY%)O#]0X((;AB8"UN[&Y2L7XMB8=]6%K577C^4*]SWWXBVO\nM)<];)/V#\\Y\\./U.`H/H*1'M[\\^Y9%2N.#'IMAWIG,!/J&1A\\E^;&-%DFCKZ5\nM33>U9K:O7I[9V%A7NJFZK4:_,QYTG=W^C7CZ;[^?<]\\Y,U"_X7?@I-+<3JP:\nMR07[A=1%/UT&BP%"JILTZ$%-C(-S#XP]#]`Q$!T"P5Z<L79DTF;)@C(+CDE3\nM73U36TH<\\Z5WCN:`EZ_]>("2%3O@'GZ:W7S7'3_(NO&/7NV:N#<_$?X<U24V\nM%-WHE%C?:3F[M*6Y+@W'-E",%$:G(_1/A&)D*@SC6*6@%0S288E%]R"*MX.S\nMXE3GICE/X-0,-._`[=O6H&=@^=IEC54=?SXP4N;&^"$JG108JUW96G7=MLU+\nMC(::%"9<@0DWAAM(>*'">45A?#!<-`[VN<A.AQ!*_7)JJG@7+"/$$QOG+>TI\nM`+S<P9VWO^!LN^.2V_Q89T:G(TAB27"CX[(+SJ)[;EQ&.4]@?V\\!>5\\BDD"L\nM@$AJ"$6HJ7:PQC;Q9J^+D7RT`+9M`0CG=?]W`*T!U)?+5]\\:[2PO=U-3174A\nMN.&<VU#!.JYNQ/LC/MX=+")4@-"$2!T'B#4AD!HY3R+O$U(E-GA17R^%>AM"\nM_@)M3_*R9:5+.2%PDGQ@\\)&U\\V<`^`IPTT^`_0?3J*W<8B83.WY\\74NJJ:X4\nMAP>+B#4A!ITP)<0*R(<:1\\9"#.=C1+&"5@J0$I#R`Z;DW0WE_*)+FM,;XE#\\\nMX=>W+N^@JUX`GMHP1P8``$\\#CSX-?'E/`;'T%Y^5MFNJDGAWJ`A?'O_:4!,^\nMG);!D*NZ!1C+^KHE[Y,)9@'6"7/&`*)F+?`P,[A159I`J66OHHN?31DU*4^<\nM<&-S%F;SLX!E`8Q]KJ8JR;.>1#Y0\\`7@2Z`O+Z,#'X4_?;\\WN+1G3*S+,^M1\nMV`D@81U_S[+`$R8LVR3-#:,G)_!&OP<O5K4-*S(5%276Z1DPOO!;`-H$YPNE\nM[W,M)<&TEIHF1[8@X`N-^$2B!EWU7B&O'D*:3Z(E`T`_R7/^-Y7DME8*$`(&\nM&%+$D(M542DYT3T>D@F5$R"+.#L=8&%5$@F3U=77ENX^,E1<.%K0&D357J0Q\nM'2CX@A`3$!(AXH:#\\TK+$:HL[GX3^-F%K:6NGRB8%8AC!8!@<T**$7*&>!%"\nMW#XV$^GLE"])RC']+]&;!6!$2":,>/7RZDK!IA:/=\\]`$6'2$W`#B0`<,6G$\nM#$A9O)$1>T"U5?P1CUQ<Y_0,;JU,,)K1-H`8T!H5*0*+-<!X'RK*CVD_A+CO\nMW-.J/0N0G0[Q4<]4_H;-3<.K6S-+1PL*W=E83K@QRWF"R&*(22-D&EZD21?"\nM=4:0O;2,/,HPAK%D+60`@"L8!L<Y%0S=P[$$L;<@%3"'^2DA]`,)??A;A>Y!\nM]^#$=#@FI'Z,"-]U0W5T,!?!CQ3ROD+_9(S!:0$M`%7@5!15Z$,M\\H(?O]0:\nM:*KD<`S"I*]\\D#8PE'=P9R]0]LQI`*?T@=IKGX%?C)?$$H[;XW:CO26&##ML\nM)[$]76)S5QL(F3F;=%@68%J`:1R_=DKAG)3"FH7`ZWU%#(S[6)14A46.WCLS\nM$^SJ[IE^BAPSTCO;3R\\!``QU7@D`_;,/5KT&$#T<Q&I5,!-]#0D"+`[\\L]$(\nM`1`!6L$R&5HJ&-HRA*[!0`_D(@TE687-TIM;4U_J'^=1]U_&]J#1B.8LP9P*\nM8V"F6(24QW"RNP%2P-02*2:1,25:2A76U@!+4A*O]Q7EWT?#3@BQ@VL9+'`(\nMMD&3$S/Q_;=L;2IJ<:K%O!-1ZMKG`17:K"S1451JFYPUEP42S#8M890RAE*#\nMP90:[PU'&/=43Q#I!P']"+PX<)+*<[B^[9T![][GOK_O%7M+,[![S?P9F-7Z\nM3BQO60#/C]>UUI=W%B153O@:^0B%X8*^#8E$`,-H!^=+P-@Z$#E$)`G8RK5\\\nM-#822'IY<$;I*IO61%Z\\3X+<\\?O//\\UJWJFX^>97,)3U4ULNKKMU67U91R'6\nME7NZ\\B__]=#45:BV7927`5K7`WB-<;9X294%(?6N#_<,?ANKJB1^U?8?:GM2\nM\\V:@^Z%U2!%Y.Q\\X?$]7W_1U8[G@>;<0_&;C114NH@@L"H$HU-4)I=L7&;CR\nM7`=?K+?6F^WEC2E3G9$Y\\#%3\\?@3FP#:)A\\?6?F2?OOH&T@8HKL'P)\\V(K'U\nM`(34<EEU,OOYAB15INFCF8+:;S/M6P1X9PCP"7],3LJZ<2^TAEF?L1?;%A/'\nICGF3[N,'/&3*-;(W?=IM/]/_7O\\`%-RU"$4+NR,`````245.1*Y"8(+;\n`\nend\n
105943
 
6554    accounting_ok_48                begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```-XDE$051H@>V8>XQ=5W7&?_MQSKGGWCOCF?'X@<>.'PUV\nM<!ULAP!Q$Y1$D-"2I"%2@D"BHDB!5J`^((H(#ZF0@B@D34M14U1H`P5"19N`\nM`">U4XI-0NPF)/$K!+\\RML<S]HSG<6?FWG//:^_5/^[8>=%`HD;YH_ZDJ[./\nM[M%>W[?6M_;9^\\!9G,59G,59G,59G,7_7ZB7\\O`#QYIX(0J-&@BM7A%9U1,9\nMI4*K\\\\BJ4]:H82><>JR=IQOCD)61`6"X])1*$2-QZ65A7LI`7DI_YGR0ER)9\nM*9.Y\\X-Y*2-*45QQ3OWE"[AMQRD`K16UP.A6+302&.+(JJ6159M"HZ^)K'IC\nM9-6"R.HPLHK(*A\\:W0Z,&D^='#C6R'?L&FK_Y.&#4[NKD367KNFY8./2^/+%\nMW<&;\\7)N[F1^5OHX*T7E3LA*GV6%C&9.=F:E_T%6RB.YDY'2D34SIW,G-2\\R\nM"\\C-FQ8\\AZ]]O@#O`7B-TGP9R$OO2Z/5:[Q7JT58;+6R5:NI!HK(*`*C"+0R\nM5A,817>A6"7"[R:%W#0U.;4W":U-BGGK!&H&T$JAE&"T(K"0`P&ZJI&5SON5\nM*5SOA1'GY4#N9!2H`(47/JQ@ZOE\\7RA`!($U@=)7!EK5K%:$ND.X;J%*3B4O\nML:5@3*=4:(W7"F4-H;8LC!0K>H+N2/N+*UI8UAW0:P25IKBBP#F'>$%YP7A/\nMX"$6!<JBC0FTJ.4B:KGW(`8*)Q/.RTJEU(L+N/7!,0"<J`M#G]462H9QF@A%\nMES741=,=!G15*T1A2-INX\\H2I81J7"%+,_(T)7;"N55+?ZRIA(ISP@S5;!)T\nM50DK$<884`H!1"!)$IJM%G5Q-$M'Y(18(%-"[DM.^+`OD7"#1AY_40&E$UJE\nM!+507U23-AN7]I"G&8$U]/;V8HW!&-UI'/%4`HNRAL*5&&.(HA!!*,J4NA0H\nM<>`5_;&A:C6U:A6M#8(@TB$O"K0V>.^)*Q5":UC2%]/.,O*\\H'2:Z>&VFI3@\nMHO\\>RN[ZBVUC\\IG+%OYJ`<X+2K%(O%_7%0GU>IWIHJ!6[\\)8.V<Q($]PDZ.8\nM($2)$/H2$QBL4@12$$66$A`1`)36H/R9>WG.3Q$9Z%,%4BI\\$*&M08@P6H-2\nM=-L$"K]QW:*PUWF9_%\\K,-?`YRE?#LRK&!2*LBRQUG:"SZU9.HB0>0M(G,,H\nMC5%@@@B\\HT2ADAF4B^8L(IV,S]E%D`[S,Q#$!!1!C/(>E:>(UMBR0"5-5%RG\nMIV*A5:X2@I5>GBM`GQY\\=,L(2H&'-VM?5'NJ(67I.@]I\\TQ,`5$:'58PQJ"4\nMHIWG9$5)B6*ZA$90)S<AI[G.)1XO_ID*S)5`1!"E:(NFB:%E*Z08,A.1QO-(\nM=4179#"^Z/7"&T2$F_[CY`L%>('IM@N]YXVA%'378K(\\QQB+*'7&LZ?3IY4B\nMSPORH@"E.RN+"-5J3%2)45IWR)UF_^SQ,[GO6$QIPBC"6HNUMM/DVN"5IO2.\nM>AP22J&\\ES<?GBB4?]8\\9P3D688K\\\\7.N74U71)7*J1I2A"&G5"GF^ZT$*6H\nM:J$J!77EJ"A02E%F&4FK.6>79SV/FK/3F4(^ISJF+"BGQLF:LV?B>N\\I2T\\E\nMBJCJ$N?<AKZ8OJPL7B@@;37)D^9OEWDZT!,JK+44>4X01CP[<<\\$%BA+G/.X\nMHL#G*8$Q5+-9>M)I5&OZ#.$SS7OF^KRY4%AKJ&E/M35)968<\\HQ(01R%U*LU\nM5O366!B;52OJ^KSNT/"=O_T.,-?$*__@\\RQ=?@[[]^W;%&E?F5^K(P+..<Q<\nM`ZNY=5O1R72[G9%C,5:A`*TU62NA#.L$0149;YRQD""@%)W2*Y1Z1@Q*(5YH\nME9X\\[L69C,AH0N<(VS/H:LS@Y"$:^4&61$'/Z@4K;E_;M^JVL<47_O#8X6.%\nM!5!AS-]\\_@OQI5=<\\:;Y<8N^KGZ*H@"ESC2P=*)2%`5%D9&E*>(]!!:EYARM\nM%![-;.G)XVZ$B=,N1U!D68YSGCSOO(V]R)P=-4HK*I68,@A)TI3(!IR*<N[\\\nM\\5^S;W@?E:""X!&1BZ[?>,-=UZZ]]N,_^-H/OF(!HGH?"X/Z0.;-VKY:Q+QZ\nME33+.O9!418Y63LA2]LHH%*)B.,JUAJ4`JTZ7BC+$N]S%.#*<JX"T&JU,*5&\nM:X76FB@*.YF7SN)1EHXLRTB2&;Q`7V\\O(S.'^,O-GV'%_!7<>,F-3+0FV'Y@\nM.]L/;&?/L;W=R_N6?^I=-[YKCP4(Z[T$77I=6K+(]BXF$4LV.8("BCQ#`7$U\nMIKN[!Q2TTY3QZ5F<]R@%5BLB:XBCB$JU2@7%9#(QEV%!`3V]/7CO::<9[6:;\nMK"QQ7O`"1FLJ44BMNQNK#).M$>[XS]MY_=+7,]`SP/W[[N>!IQY@;'J,WEH/\nM[[WD?>72>4MWS2:S#?NN[PZQY7O?8^V%FR[*LU8XEFJ.S.2<$U6H5F+BN(+W\nMGNEFPN"I468*((BP84@86B*CB;0B0@@RA[2FT=Z3Y.691FUE!4-CDWBE\\28@\nMIT)N%)EX,B?D:4'12#%NAO5+ZWQMQS]0#:N4KN3.;7>RY_@>7.E8MVPM'WW;\nMIUFYX+)_7V;##W7-GS=E>V+#C1]\\7^W)PR?>=&IDFJYLDG[IQJF`H<D6$\\T)\nM&CD4MH*M=($V)&U/,B,(CLAZ:J&AKV986`^IQ36::<E(NTE!@%&68T7,0$^=\nMP&HF$\\]8LV2R59+DGJP4C!+B(&+MPEY^=O2'[#F^EV5]R_C&SF\\P-#$$P!7K\nMWLJ?7G8K6W<;OKEGU*Q8NW9V9O0X=E%OA=#*.3W=U?-&CV;LW?4XC5.+Z5JP\nM!%.I$H;S"`-+612<.M5@>+)-(U-X4\\$&`7&HJ86:6F3H"H4HGR24C-1T,9-[\nM4O$\\<722W0<'F74A6=1/L]0T4T>2"VGN<$5*EW&L>4N%?]O]+200[C]X/Z/)\nM*#K27/?Z=_)'O_-IOKMMF!W'FKSV_#>L7ZQG%_?UQ\\?MKI\\^`+X\\-X\\7]9=I\nMBQ/)%+:[GZ);$;B"]JDIIAJS3,ZD)$ZA@Q@;5;&10ZQ%/#C?V<E.MU(:(R<9\nM/WJ`R=$3M)T%/(=_FM&S<`G]RU?3LZ2&!%7\\Z6V$>,JRY'6OJ7%H:BO[9P[2\nMREM,NDELU7+=VG?R@3?>RCT[QGADWR_QE?DTAO8O>73_R15*F^/VH2V;$9%Y\nM-JK:H-J%,996TB8X_#2B+`Z#"BISI&.P'L0AWN.]X$3PTKD6:4K>3DB3A,;X\nM*,GL-`A4:G7BKA[RN97,F!@OX$00[XF,XL+ECJ__XAXF_209&28VO&W56WG/\nMZH]RVS=W<FAHA/;,!*X\\PMB>V;!,DRZE%%:\\0T0"7V2J3#4256G-SF*R$ENI\nM8J(J5CR(1\\3/XOT1\\7Y0Q`^)2,/+W.'*2W>>I4O2)%F>)JUSRCR?KY0V*"C+\nMHDR3UGC:3H[&6?MH&/L3WM,400KGN&1IUX99_=`[=D_OU2YTJ$!Q0?]&;EQW\nM"U^]YR![#QV!(L65)2Y+\\$6N@4!$L)T-OI\\2\\8,B?C'>1XA7B!?Q/L.["1%_\nM0+S;+M[_1+S[I7=EP^=%D;<3'KSE(BZ_;0O)EV]!_\\E?V31I=J5):\\"Y\\GQ@\nM*2!I.QL</'9\\S\\'#C1%YY)\\3ZG6A^2,VW_M=WG'=#0Q-'/O<+3^__^HR+#'*\nML+"RD)O>=$MKZX]G9G8='N[52D(G7HGW(MZG(C($,@U@!8]XOQG8A<AOB?A%\nM(MZ(2(GXD^+],5^6)Y26I&Q/L.?O_Y#GXR<WO[TSN/GM)9V#]Q2P3S('H58N\nMS5?/9LV+B[*L5G5UU\\GADX^:X.\\*9SW)<#)PP!W\\_=W-W43U"*TT'UA[H[NX\nM_^(O_/G.K_^K0I:+EX6(-X@O04Z`'!;Q(RCUTKX+O10<>?H(>9)WS5L\\[T-/\nM-9[Z\\),33RYMNJ;:L&C#Y(5]%]YV[*EC=ZS9N"9WJ7OW5T]\\]9MW[+_#"L)E\nM"R_CLZ_[['WQ1/S>S&93RU<N?]$X^D7_?9EX[+''&!L>"WJ7]'[FOB/W??9@\nMX^"RU0M6JY7S5[)C?$??PXV'/[7BO!7OOCZ^7DWXB=][I/F(U57-HIY%O'_5\nM^T?[7?_G^Y;U37WK[F_]VE@O^*SR?P&E5.=0`JW,9\\7CXX_;1Z<>93@=IJ?>\nMP_BI\\=I`;>"FNX_=??2)\\HE-A]PA@EK`M8NO96.\\\\:Z/O/,C#]]PRPU\\\\I.?\nM?"7H_688/#C(H5V'PO&)\\3^^>]_=8QN_LU'Z_Z5?EMZS5#8^L%&^>."+1:O9\nM>O!+0U]JK_GY&KGRR2OEB<83OV@<;ZP:&1GYC>.\\(A8"6/G:E4PT)O+OW_']\nM?[QFX)H/?NZBSQTY?]'YJ$@QK:?9.KO5'E%'+MGK]E9,S7#5@JMD%:O^:=[`\nMO*?W[]__2M%ZZ=AVWS9$A,9HX_+M(]OW7[WS:CGWP7-EW>/KY#V#[Y%-@YOD\nMZN&K9??L[KWCA\\:7'3UR]-6F_$+<]96[$!&F1Z<O_=FIG^V_=M^ULG;?6EE_\nM>+U<,'*!W#YSNTPUICXN(MQ[[[VO-MU?C:V;MYX6<?FVB6U/7S5XE6P8VB!7\nM3EXI.Y.=@XTCC=4CP[^Y]U\\5//A?#R(BS(S/7+>YL?G4Y2<NEYMG;I:QV;$[\nM/_&63^@M6[:\\VA1_/1[:]A`?>^O'U'1C^L^^/?/M[$?-'S5GQF;>EK22ES7?\nM*_8F?C$<>.H`TI)J_YK^.[76JTX</'%-H8KI]>O7OQIT7AY.#I]D\\-#@JJ.#\n@1R\\%N/766U_6//\\#[LK3K##A%88`````245.1*Y"8()T\n`\nend\n
105944
 
6596    inventory_48            begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```+S4E$051H@>V96XA=UWG'?VOMO<\\Y<\\Z9<V8TNHY&EY$M\nM2_%%DJTD#A@78EI:7TC3/BB]4-Q2\\F(,@93V)0^!AK904DHO#RFAE-"ZT$!(\nM"W5>ZN*$)DXL&B>UE,JZVI)GU!E=1C-S[F>M]7U]6/O,S2-Y/)X&`EVPV7N?\nMV7NM[[_^__^WOK4'?L:;^6D-].D_>YE6NU][Y.#V7VSW_<CYJ=NOG'Q@_]M?\nM^>:_T?SZ%S;=[T\\%P*'/?8TK?_$W]D_^Y2^_M*M>?GYJKMU[Z[:_<JE=^8U*\nM9FZ^^L+#F^X[W<(X[]J*:<+1S[]0[SKYI=-7;O_5U5[EM0,3$R]]LE(XJJHW\nM7_T0?=LMBW+==H+R[WZ5<V_?*!O#TZ>G>^.R;?^GGWOBOL\\]-%[8?N;<Q6?_\nM^;L7]PX_.,&C?_[6ID;8M(3^X!D@@=X"UBJV5(2A<CQ*0U`OPS%%GY:O/OR)\nM!\\:_\\/,/[WONS/7F4+\\TS/U[1_G)M04NSO:D4JV>J5=*?WKH^G>^^<R%WW)N\nMG\\7UXQBJ\\0BBDB56/O5'86L`_/'S!D53J_SF4+GV=+DZ7$Q,P*C#X+`XK/;X\nMH3QI;DS^_K$G/G)PLN,-9V<[7)X7R,H4BB6JI8QRT5(IIHV=<Z_\\8/+-%YK[\nM:DV#,3%X0`14F5?X&O!M@$]]299BV90'+.#['*CM&O_#!QY];G^W.4.W<1UU\nM+=2W(#28[NWA2NT4VX=W\\JV+'>9=2E*H4ADI4BDF>>#Y44B&*V-/_4*W\\6N$\nM6W]+*3-(/OMJ%1$098]!7\\?061G+I@"D"02HC.V^OUP:JC!U\\1P['GN!K%3#\nM&L48Y3\\NEYCK'Z73KU"IEKB_4J!62JB5$LH%2R$U%#)#(;.4,DNI6($G/D_W\nMRD.4:F5$+#+S;;*I?R2U($I=,1G0B=Q\\6``):DW`]Q9("V5V/GR*^_>-DUGH\nM!^55G6;B=I>=U8S1<L+(D*%>@N$BE#(%$P]K#=9"FO;1>HUMC_P*A_;OY^+-\nMP-7%%B/Z$D,%0Y`8]EK-;PI`8B,(2\\#@26R\\KA8@LU&WGWVT2KM70E50#8""\nM!L`#BM$XBP:-]UY1">S<OHW1$A1L0"20)9"ED$098=8@V#0#FH`U@M$(8&6S\nMUF"S1:[>.LNQB>.,U_=^X#$DG_$T@4)*9$#?^]SF`-@!@+`:0#[`^5OG^?(K\nM7^;(Z!'&"Q.8ED599_1U6KE<9F1D))K8@,T@3<%N)8!DP``"N"@A8_GQK1_S\nMH\\9IIKO3//7H4SRSYQG._?<Y+LU<VE"_JLJN7;MR`(J@V!1L`4RNPJT!8)<E\nM9)<84"9KDYS5'W%P[""G1D_1:_<H%HNDZ<:&454*A4)^#4)D(,E`+/&'K?!`\nM8H'<N*C'VC@Y]6*=YW<_3]!`0H*UEFJU2@CO74'O!J!8+`+1L()BL\\@`?BL!\nM)$`"9H6)#8""Q6)--$6_WV=Z>AKO_:KW1>0]?0X`C(^/,SX^'CW`,@,,&%C3\nM/B0#.8"[%"2E4HG)R<E5`1MCJ-?K9%FV[CL#N44/@,DB""SHE@$P!JQB3#2Q\nMN4M-N]A:Y,K;5U!9=E^2))PX<8)JM7K/,082,JEB,Q,!!+9&0M:"6C`Y`]8H\nMNB+']7V?E\\^\\S)O3;_*9CWZ&H[N/?N`Q-&?`IF"SN(*IW2H`AB43&W58$V=L\nML;^(M9[O7OL>WWCK&[SX\\1?95]M'M]O=<-])DI!E6<Y`E(_-`*-HT*UC@)P!\nMU&,,*(:+\\Y?XI]F_QQ8M7WSVB^QF-Z__X'6<<QOJ=V#B8\\<>62&A'`"1];7M\nM0S%@<@:,20DB/+;C,49'RW1,E\\/%P_1Z/0X<.'#7K+,>@%JM1A#P06/MDT09\nMJ8+9*A,;8C&)"BH>2`G1%!PI+>O=.<_MN7F\\#]CU1E_3@@A!#;71';B09Z%T\nM&<"&3*S_"<`H\\"20:5X%BL0T)@(8D5LWF)R;;Q6R+.#HHNU_Q<WN0/-%#043\nMA/W5!GV?<J-S$"^#57;]NDCRF>\\YR1E03!)!&&'=>OJ]`&+?]ZGR=WW'2+N+\nMJBSO3P='6H+M.Q<2E86X]9M^D=M3JY\\1450$LCW4#_\\#%/<"0I9EF+PN5M4H\nM&5&\\%PJE,CTORPQ8L`E(DD_*^P'(%TUC#<F_G\\;^U_DBH_42WCF*A90T550\\\nMB4TI9`&#H)I0*@C&!$*PE(H62X]B<8B)72GJ'-/OOHNSGBQ-.'GR)",C(W$\\\nM`1<4YQ47!.>%OI<E#V`C")/[[GT9&)0M:F!^`3[QY"D^]LG/\\O8;+Y'I'#L.\nM/\\NMJ3=HS;S!KL,_1Z\\]S\\SEU]B][SX4R\\RUM]@V4D;IH6Z.-!-$E<<__CAI\nM]1"H4"@4$%T3>!@`T'@MFLMU&<2&:J%!V6)-3)>E\\BCED4-DI5'2T*-8W4-6\nM&L$F!0K%$8)W&&-0W\\"[)N);^%Z+T)\\CR<H$R0C>T>WV2-,NJ-!L=_`A!NJ#\nM+%V[H!B;8;,2/BAA:=>6-[-Q"6%-?%%#@WY["M]?Q&@'U[Z.[]XA^`[-&Z_1\nMN'4>UVW3FKV(ZS?I=T;IIPF^.T^A.H1H0J?3XLR9,_CT-B)"$%T^<J\\,[FO;\nM=C)^\\$CTP-I-S$;V`P,)R0"`;^%;LX1^D\\3TZ#??I;MPGG[G!HO7?DBOUT?"\nM1$R!`;PWA&#P'I)@"2%!L8R-;2<4=Q%"B+,KBL^#]H'\\+!3+P]$#$LV]*H&L\nM@^&>#*`1@.O,X%T+$VYRY\\K76?R?"YAT+T)`-`_:QW?=BG,:+"()WH'K.8+T\nM(X!!X,+2S`]`:>HI^/Q^P((0];\\A#^0,6.+#&EJX]@S!-9'658),(<%BK"%`\nM#"X8O#=YX`8?(J`@EJ`)S@G-A45\\.D^00,B#%8&@`_G$A4QM@:&@]/J.;J>+\nM^+B`Z0#(^V8AOT9"H45O\\3*=^0N4TIC:@C>H-60:`7N_XNQ9`A."1<2B)(SM\nMV(,4)_!!2+(B@L7E!O:YC.ZT'(V@M&;G6+C3I==J+`,(&UR)!Q(R`PFY!HV9\nMU^@V9DAKVR%$>6`-WAJ<RV=]1?`A!Q/$()+2[3IFWGD;EW3!&`X=/4ZY6E_*\nM]S$;@?07V5E/N+[@6>BV:2TL(IYX?!``*U-5KSE-6SHXG^&]@3PXDOBU+,Z^\nM(2Q)*()P.0-!+$E2Y,'CCV,JDS@?\\&KHN;`J??J@M%LMO-W&FU=O\\L[4+`]N\nMWXUZLP0"OQ$)Y1X8['%=MX'+P/O"$@#GP20&;W(`8E9(:;4'1!.Z#J[.*[XW\nM,*?@))K4"_2=I]5J<>WZ/%/SL\\S/SW/RL8]RP)TG.$6=0?TF)*0:J5N21_YE\nMT'LPJ<&S`L`*&0TD)&)13>AT^UR^=)9N=@>1$'._QGVO\\T*KV63ASFWF;LVB\nM6(X_<IP'1V^0SLP07"XA!RJ#Z._Q<7?5%Q!=#L;ELVL&`(+!:PY`H^[#"@;\\\nMDH124G>;CW5^CT32N+>U@%4411)!,B'4`WZOPR89:9)BKROJ.M2V&4(?Q)L5\nM6>@>`)88R)\\3C:G2A[A`#0#8E0!8K?^!'Z*$+-:6>>"A7Z:R;0*;53!&4&FB\nMTHCGT`1I(J&)^@;!-Q#71)S']XJ$?A\\16HCZ#9<2AKS^UQ42\\F9)0C8LFSB8\nMY5GW(8)U;B"AE%ZWW9M_YUMGW9URUZ9)+,R,Q]B!,W-MJD<UH.+1$-`0D!!0\nM3U^%KUB;M&7-1[)[2DA7Y'GG(@!U\\3KQ!I<'ZFS.D@/GS)(/1",#W0XW+YRY\nM]MLG/L*51A]KT^6=EDGR/?;*0LTLLV\\$5(P$3T=,X,BOKRXF[LH`@#$):;%"\nM4D@H52ID0W629`<EDY%6QBC*'B0+D.QAJ%#`%AK4_6YJHP5*I8SAL8,H?;Q'\nM%QJTOG.:]N_\\]=H1-]+N_F7[;NN`4861:DIAJ(:Q*1/#"<:TH3)&I9Z@MHEA\nMC*I:U#B,J5,=&6&4C,2FZ/`A+'WFIG]""'$SM9G0WZ^M*R%C6%3E^T9ZU>[B\nME`[VPJOVQFOVR8._KWIV.?!9$3IK#?A_`B#_`G)!E5]5Q0QJ\\D'`2_<K?Q^4\nGNFNNE\\[QOQO=N^SE_[_]3+?_!1N,QJ^DNMX3`````$E%3D2N0F""\n`\nend\n
105945
 
6623    taxes_ok_48             begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```/=$E$051H@>V8>Y"=19G&?]W]?=^YGS/WD,DDDTPN!G(C\nM&..%2Z!$7''9**;<$K#61:U5RK*VW%HUXK)L7*E=4-%R`=U%`9?U6KJUB+(*\nMHE@L+@FK(28D3$)"DDDR<^9R9LXY<\\YWZ^[]XSLS"2K.`+'VGWVKNKJ_/CT]\nM[]/]O$^_W?#_]G]K8JX!7WBD#`AA,.T&FS(6C`%KP5@PUF(,&%KMUN\\&BS6M\nM[S.*WVQ2G9R@.C5!;7+"!+Y?R>8RX4]ON^9E`7#F1"@%`CQKQ6>%Y6(L&L!B\nML6<N@P6L2)#1^IY=G]F1.*Y+.ILC#`."9D.;.-Q=+I>_ZFZ\\]N?YCIZP\\I/;\nMSRX`*4"`--!W3L%=WEMRT`:TL6AKT0;,&6UMSNQ+OL]L:^,2Q2Y^=YI:+<>Q\nMXT/GYDJ=5T91^*\\C)X[=<LY;/GYJ^/AAV/OMLP-`R%9M8&')X0W+\\T3:$FM#\nMW'(XB@VQMFACB;4E-DE)ODG:+^AWB76:*"Z2H4F?VU4J%(L?>C:5'A@KG_I@\nM_ZHUQX[NG9?_<P-0+198(7`=Q>"!87[VV'-8%%-3$)/B7=>LPBVXG/`-?FP)\nM8T,86X+9^HR^J-76EB#2E*=B+EOCL++_`HJ%XI6'#@W^W<18^8;7W/"5YJX[\nMW_O*`4@A6D`L2L*Q8Y.$OF5LPO#MAX8)<FFV;EM!20K&--0CBQ]9FI&A&1K\\\nMT-(,3?+=ZFN&)AD3&GP_S:KQ"?)>C25=&3SWO&WUYO+O6*U_>.V0Y2_[?K_.\nMS+T#,IG`DL2#,6D>>6*:IXZ%E+,Y^C;VX.9</$>0\\22F-4XDL8/`((1`"(D0\nM(&D589,Q;5T\\<'B,7C7.1?WM##?K>5>DWW3/WW[XAQT=]\\WEWOR">*86`D+7\nMX]$1B]_?`4O;8$TG3M8EY0C2KD%;`<A$E.SI8JS!MOH-8#`8*[`I%]W10U?Q\nM'%8.%"C'8QP=KO1ON_$?G='Q2GR6`(ADQ2QT+RYPR3M68'IRV`4Y>A;F*&8=\nM,M*R(*-H.I(@,@21P/=:[=CB1X8@2N(BB))8"5I]S<AP3E;A*D$NEZ?4H9QF\nMLR%<UYO+O7D`D``6A<!8>-VJ/-_N3\\WP`X$A10C:LD1"[%IB:9.ZI3R)`HE$\nMM;1,VMH2&SFK3A:)1N`H23J=)N5E$',>L_,,8@%889$"*E.3#-6G0;DM.;4T\nMFDW",$:FLHG2!"'-1A-2.<*6`@7U*MK-$6J(-$3-.J%51-;%CPW+"Y;-*Y>@\nM9&O7E9A'GC`O&9U1H01,I#6B4`0O@XD,46QI&L6T#E"I-GQI:$0-ZL:`+!((\nM0X"A$32(9)X@AD!;PF:`CX=/BD9HR*LZKDI$0[84X.SL0.L@L[0FU#'I1@,_\nM&*643B.50R&>)B`DKUR,L/@VH*Y]"FT^D4X.N@D;DRF&:)M0J9:+02EP#%&L\nM21EPE&@!2/[G//R?WT&64$@@!"@A*2B%-4TR2N)Z#G@*%X=2VL582UIHG-BE\nM+9=":T.D+31=\\CD/@T`;\\"(7Y::0KD<4&W0SPE4R`2!/R_`K!C`S42*C`B$$\nMCN,02H?A6&*,H#8-#=^@M":(-<U&Q'0M0DSYLZK3J/C$Z2:A%@2Q):KY!!A\\\nM$=$,-)L[(I8O$[-4I;5@KWP'9"(W"I,<9%H31A$B"EF0BG"4H.YI`FO)YY/4\nMVO<$=4=0;)-H(]!&4LFXY$O>+(6F*A["22&<%&%LR!B+(Q,**=&B[-G8@9E4\nMPK;42$B)E!)723*.PG45UE6XUE!*.0F%T#BQ0UO6P]HD&Y5-EU+>`R'1QI**\nM7!POA7)3A+%&^R&N(Q(5D@)KSU80SW!Q)CT0`O=,"FFH35L:38.*8P)M9BE$\nMBT)A9&A4&IBT1Z`%00QA?9K`1@3"HQ%H+NR)63T@9X-8R+,$0,VJ4")O6FNB\nM,RCDNH)&RA((*!0%D18T?P>%JEF/4D<&8P6AME0GTSA>"NFF"2)#UC10ZC2%\nMDC6;&\\&\\<R$[$\\R_22''P3@*=$S*D:0=20KGMRA$0Y'S%$I*I#6D?$LJ+7!3\nM@MBZZ,`EY:K6099LP5FBD&P!,+,4\\ESW#`I9:M.&AF]1QKQ`A<ZD4+/2(`YK\nMA*-#J*".,A&>YX%4C$]'+.HLT%$J(H5W6D;G`4#.-4#)F7*:0GX0)!0B8HFC\nM69:RK,C`^@*<7Q2<WR;8T"ZX>('DLH6*R_L<5CIUO..[&<@9SNWK(B\\-\\629\nMM8M*_-D5KR:JG.3?OO7OC)9'<91$`IW*L/?'>T5]I-[N3_@K_'%_8')H,F>M\nMY1N?_\\9\\=X#6#B0K(J5$*87G*-*.0CF*2$FL$F=0R$T.LA:%M#8TQT<H9CP6\nM='?05BJ2<B1C8V.,3=;0QTX2A!%#0Z>H9P_3MZ:;$Z.3_,6EG4M]V?WG.T=V\nM7GFT<G2A(QV[NF?U@965E5_:=-FF!XX]=RR:/P#YPH.E82PG?(T-8VIU3=/7\nM*!T11(9FHTFCUD!4O-8U4K-W[Q%*IH'CIJC6IO%]GR#2G!H98]=3NQD;+3,R\nM?(+7]U^`$,+^]:7=%P_6GKWM:SN_=L&^4_M(.:DDGJSIV[9QV^:MYVW=_L#=\nM#WQIWC<RC$4"MO5LDA:P/./@NBYU''S/4"@EJ43@6QJ%F([.0K(#QE+[+Y=3\nMPR%A%!.$FLFI&I7Q"28F)JA,5*C5:D11!`*6M+FK!R?WW/6%GWY^U>+VQ5S_\nMANL9GQ[GL<''>&SP,?8<VU/L[^C_Y#O?]\\X]<Z<2+2F;324`'<=H8_!C32PT\nM?JP)M,&+#<8F_;4@AD:$-@:MDXN,;3VQ&--JVZ2MC<%H@S&64MJAKWUBU1=_\nM\\B76]*YA4=LB'MK[$`_O?YCR5)GV7#O7771=W%?JVUUKU";G!/";)J4DG<DP\nM&4:<-`H3">J!H-$$1>)HLZ&9G@;"UNTKTIQL6')*SN93M&HA$G&02I%*I5BW\nM-,NWGOHGLEZ.6,?<^;,[V3.T!QUKUBY>R_8W;Q^]8M45GW-\\Y\\MMW6V5EPC`\nMDB\\4J-5J=.9SM*ODSXV;Q=@,0BJ,E5CC$,5I#`J+16N'1D%1;IZ61C%36B",\nM-KQ^\\R:F"R=Y^M>[6=R^F/O^^SZ.CQ\\'X/*UEW/SE3?O.W_!^1_=\\]B>_^Q9\nMUF/:%[7/K4(O<-]")I,AD\\F\\)-C&&$JY-*>TF7UY;'D_.V\\VFV'+FU_+_8?O\nMP3J6APX^Q$AC!)F2O'W=V[GY+3<_OBR_[$.Y4N[IS((,*]:O`.9Q#IPM$ZV\\\nMO*4DL[%@C"&*(S:N7\\O)W#&>G7R6_5/[F=`3.%F';:_9QJ?_^-./#N0'KL^U\nMYY[^YOW?9./K-L[.^Y)C8,8B$W&J>I*]Y;THJ5A_S@7TY'IF\\YC?`D!RJDLA\nMDEJ>+KELCDT7K^,KQ[_(A)D@($!E%)<ONYR;+KOI\\27I)1_(%#,'7[OYM>S<\nMM?,%\\\\X)P)$>`F$C$Q&9D".5(78/[V;7R5T<F1S"BB)+.S=1L0T6ET)RCH^R\nM9;HS>3K3G;C2!9*5MW;F1=O.OF(;8UBQK)^ISC)/']Z#]C3"%6SLW,B-E]RX\nMK]_K_W"F(W/PQNTW_I;SOQ?`-0]?P]>_^G4^L?./,FE36KNAZY+N2G"<<O,4\nML2W0G5_/>;UOIS.W%,]U&=<C'"K_@)'F'L:J!\\G*%,O;E[.Z;34KBLMIJ`::\nMN"6A,P]>"8CU%ZSB1U/?)?9BE%#TI'OXV.L_-GIN[MR/YCORO[KKSKNXY1]N\nM^9U^JA<#,%@:Q'JV6*W6[HJ);FX*EJ%6BP6%/Z&_?2OMV?7@&B;%KSEI'^9H\nMXT<<'GJ<0[_<C0T-3L;!S_H,5@<9"<LLZ>_EO%>M)-^9I69K!,V09JU)(9-A\nMY9:%?'WX?B(5X:9<;EA[@[ZZ[^I;[OOD??>Z"URVOFWKBS/DQ7X(P@`@/3HV\nMNKDY'75=N>YSM!=>PUAUDJ.57Q`X3V.R)TCG-1DG37VD@FQ*NCM[R'?GZ5C0\nM065PDC<.O)&^["(.-@\\RD2FS;NEZNER/9R:?I3'HLS)X%4>]YZBJ*C(KN;3G\nM4K8MO>Y_FE/J[JW;WV7[^[I?U/G?"^!,T]H0Q`Y6"*K-(_S@B8]0*$IZ%_;1\nMW=V-*5JR'3G2B]+8C.7)\\$FFIJK\\_?I/$38BGI\\XRLK.553""D^./,FFWDWT\nM9GO8*9_@XO,V\\\\WI!Y%929?7R7N7?Y#Q2OO(]YX>F]S0EYW3MWD!,$"E$2.\\\nMB$HS)HPBALM5*I4JQ4*1[JYNTKDT(_5ARF:4JJCB*(<#JY^E)]7#GLH>=E5V\nM<<(_05N^C;%38VQ=N)5EF678MIB#)P[BYERVGO,VNN/U')STV;`HBRM?P8U,\nM"HG%AE**`YZ;6C+EFXRN150#2SY7P")P'!<I)9-3%=2T@ZL\\%MJ%M/DEIH,&\nM7Q[^,N^_Z/UL&=C";;MO8R@:(AVFZ8Z[6=RVF'>O>S>/1H]2=^LL;UO.Z\\(+\nMV?G,`;J6K@9L<G:\\7`"NZQ+4@DFWJ*[/9SLVQ39_Y5@]NJ3JF]6Y?"$CA<11\nM#LIQ<)2#XS@X2N$X#DHY"$>0Z\\@2]8>D.U+LN'`'M^^_G4/1(:;D%`_7'N:J\nM15>Q;W0?*J=X:^=;^=5]^^SQFGSDJE7K'PS"T,SG664^8]A\\]R&,07A.OJOA\nM__S5-O[L%:ZKW^0Z[BK'<3Q')<Z?!J-02M%>:F?%P`JJ]2J]]+*\\L(([CM_!\nM@>@`Z5R:=>WK>)[GZ4QU\\C&]??SS'[G[.S]_XO%;BL7"\\>?V_W(^KLT/P)EV\nMT3T7@;`"(Q9XKK<EY7G;7->[U'6=+J5>N`NY3);V]G:JM1H3DQ,L32VU%RZ[\nM,+ZK<I=[D(.X&1>545Q3N(;W!._YFZZNKD]???6[[/>^]XUY^_.2`<S8>WYZ\nM'5-3TPA)RG7<#9[G_:GG>>]PE+,DUK&04E'(%]!QS%1UBMIT/:S6I_[C(^O^\nMZL?9WNSV6Z=N'3CAG*`GU\\..]([G5Y=7O[GA-@9[%_6^)#]>=BYT[V7WSS2#\nM#_[B`SNUUD]YGO<OGN=="^+:2F5BZ3/[GQ&NZY#)9(:B*+Q5:W/ODC5+:HO'\nM%X_?T'[#/W^F^9FN#<X&!O3`0[>^^]9#6SZYY27[\\;)WX'?930=O(@@"D<_G\nM5KF.^[Z1<OG:X='A_7$<WSAX^,"3BWN7V(]W;N?[G_J^^,1W/_'A!^6#MY9D\nM*;JD<<G;G)SS2#8WM^[_00',V!U3=Y#/Y=1(>63UT>-'QXK%XLBOG]G+@^]X\nM$(#!_8/8:9OM>E77G5+*@5,'3UT5B6AJPX8-?PAW_C`V?&*8(X>.#!P]<G0+\n=P(X=.U[6//\\+Y:_XI3FH41L`````245.1*Y"8()W\n`\nend\n
105946
 
6624    taxes_zoom_48           begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```/"DE$051H@>V8::Q=5WF&GS7LO<\\^XYWMZSB^GN/$(1,A\nMH29``@TBH551B4J;H`K:/R&BI2H21>V/BE84%41II4(KT22MJJ8*2$4*0PH-\nMA(800F,;VW$2Q_-P[3O?<\\^XQ[56?YSCFYN"\\;5CB3_]CK;6L-=9>[WK>]?[\nM?7O#_]LOU\\3%!OS=4[.`$!8[:'&!=6`M.`?6@74.:\\'2K_?O6QS.]MLKKCB*\nM:"XMTFPLTEI:M$D<UXNE,'WZ\\_=?%@!]4812(,!W3GQ!.-Z.PP`X'&[E-CC`\nMB1XR^NWE_5D>B?8\\"L42:9J01%UC\\W3?[.SL(][-#SQ3'AI+Z]_[XI4%(`4(\nMD!;6KZUX6];5-,:"L0[C',:"75$W=F5?K[VR;JQ'EGO$HP5:K1*GSTQ>6ZH-\nMWYMEZ;_.G#W]5VOO^=34])GC</"K5P:`D/W2PGA-LVM+F<PX<F/)^PO.<DMN\nM',8Z<N/(;>_JM>G57]?OD9L"65XE)&*]-U*K5*L?>S4H;)Z?G?KHQ/:=IT\\=\nM7-7Z+PY`]5G@A,#3BL.'IOG!?Q_#H6@T("?@=^[?CE?Q.!M;XMR1YI8T=R3+\nMY8J^K%\\WCB0SS#9R[MJIV39Q"]5*]=ZC1P]_>G%^]J&W//1P],*7?_^-`Y!"\nM]($XE(33IY=(8\\?\\HN6K3TZ3E`K\\QGU;J4G!O(%VYH@S1Y19HM02IXXHM;UV\nMOR]*;6],:HGC`ML7%BG[+3:,A/C>=?>UHRU?<\\9\\^X%)QQ^M_\\4Z<W$/R-X$\nMCMYYL+;`4\\]UV'TZ9;988OW-8W@E#U\\+0E]B^^-$[^P@L`@A$$(B!$CZEW"]\nM,0,C/'%\\GG5J@3LF!IF.VF5/%.Y^],__\\-M#0_]RL>6M[A"?+X6`U//Y_HPC\nMGAB"C0.P<QA=]`BTH.!9C!.`[(F2>^VRSN+Z_1:P6*P3N,###(TQ4EW+MLT5\nM9O-Y3DW7)^[[L[_6<POU_`H!$+T=<S!Z=85W?&`K=JR$6U-B;+Q$M:@)I6--\nMJ(BT),DL22:(_7X]=\\29)<EZYR+)>F<EZ?=%F65M4>$I0:E4IC:D=!1UA>?Y\nM%UO>*@!(`(="8!V\\=7N9KTX$Y_F!P!*0@G%LD)![CERZ7ME7GIX"B9YJ&=FK\nM&T=NY;(Z.20&@5:20J%`X(>(BX;951YB`3CAD`+JC24FVQU07E].'=TH(DUS\nM9%#L*4V2$G4C"$JD?05*VDV,5R(UD!G(HC:I4V3.(\\XM6RJ.V[9M0,F^UY58\nM19ZP*AD]KT(],)DQB$H5_!";6;+<$5E%QR2H8(!86KI9E[:U(*LDPI)@Z29=\nM,EDFR2$QCC1*B/&)">BFEK)JXZF>:,B^`EP9#_0#F:,_H<DI=+O$R1RU0@&I\nM-)6\\0T)*67E8X8A=0MO$5`9B,M,+=(LN)ZRF&->C4JN4@U*@+5EN""QH)?H`\nM>L]<Q?I7%\\AZ%!((`4I(*DKA;$2H))ZOP5=X:&H%#^L<!6'0N<=`*<`82V8<\nM1![EDH]%8"SXF8?R`J3GD^46$V5X2O8`R-=D^`T#.#]13T8%0@BTUJ12,YU+\nMK!6T.M"-+<H8DMP0=3,ZK0S1B)=5IUN/R0L1J1$DN2-KQ2188I$1)8;;AC*V\nM;!++5*6_86_<`[(G-PK;"V3&D&89(DM9$V1H)6C[AL0YRN5>:AW[@K865`<D\nMQ@J,E=1#CW+-7Z90H^XC=(#0`6EN":U#RQZ%E.A3]DIXX'PJX?IJ)*1$2HFG\nM)*%6>)[">0K/66J![E$(@\\XU`T4?YWK9J(P\\:F4?A,181Y!Y:#]`>0%I;C!Q\nMBJ=%3X6DP+DK=8C/<_%\\>B`$WDH*&6AU'-W(HO*<Q-AE"M&G4)I9NO4NMN"3\nM&$&20]KND+B,1/AT$\\/;QG)V;);+AUC(*P1`+:M03]Z,,60K*.1Y@F[@2`14\nMJH+,"**?0Z%FT:<V%&*=(#6.YE(![0=(KT"268JVBU*O4:BW9Q='L.I<R)T_\nMS/^70EICM0*3$VA)04L"],]0B*ZBY"N4E$AG"6)'4!#X@2!S'B;Q"#S5#V0]\nM%UPA"LD^`+M,(=_S5E#(T>I8NK%#6?LZ%5I)H:C>)4];I'.3J*2#MBF>YY,[\nMQV(W9\\.:089K5:0(^C+J$*M`L&H*<2$*Z144JG!!"AUJM3EZ]%6N&AZBMG84\nM80U:":)NQ$*]3OWL<;[^1!>U_F9T>1RABV"S-P[@=102/0HII?"UHJ`52BLR\nM)7%*K*"0UPMD?0H98XD6IAFNAFR>6,?"_"('#AUEKMG%.+#6($W&[/PBM>D%\nMBF,3Y879Z5`Z<U$$JP<@7Q]8NM9Q-C:X-*?5-D2Q09F,)+-$W8ANJXNH^Z2Y\nM(TX-QXY-<\\>U$QP]=I(?OWJ6J[9NXTTWK05G65QJ,#,SP\\+9,[1GIJDNSNQ*\nMXO@31XX<_LROON^#Z5/?>OSR`9Q_(\\,Z).#ZGTT*`K:$&L_S:*.)?4NEUDLE\nMDMC1K>0,#5=PSI'GEB/J=HX>/<F/CLUSSZ_=R_A0A:56BV-GIEE<K)-G"6&E\nMS/C&-Y//G@V8/OG':]>.'QP8'/[:+;??Q=Z?//WS-_AB`$3_)_MI1"^?RS'6\nM$N>&*#?$N2$QMI<V]-NM)&>QFS'?2>FD.07/X]F73G'O>]_%CJM'R+*4F<4&\nMY^86,&F,S!-D'C$P,,"&F]XZ'12+>;5:_8/]^W\\Z$):JE^^!GT$L)84P9"G-\nM.&<5-A.T$T$W`D7OC2OJ&CH=(+7$F67<-RP=.D8X,LYU$VMI="-R:ZDW.RAL\nM[YL-AMQD>,)1'1R<<E+,#0T-[AH<&+A>2O7L%0+@*%<JM%HMALLE!E7O[]8K\nM8EV(D`KK),YJLKR`1>%P1)V,?Y]98&S-)C)C,,9BC,$YBQ:]>7-C<%F"QE+0\nMVH(]-C@X]*YB6-Q2"(M7!H!S$(8A81A>$NSCI\\X1)RD:B-*<W%B<=12THB,<\nM`HNS.7F6@',$GBI4RB4Q,%!SON_I8O'"S[MD"EV.*:THASZGYQ;IQ%DOEAB+\nM5A)K>QFL0R"E0@A!K:#"T>'AM87`,YUN]VRG&U]Y`)G-F&J>X^#L0914W+#V\nM%L9*8\\MYS$JKEHMLFUC'ON<.<6JNP9I:V(O0QO52!J60VD-Z`<5`4PLPY7+U\nMFJDSI\\^=/'GZE5JU<OD`M/01")?9C,RFG*A/LF]Z'R^<>X$32Y,X467C\\*W4\nM79>K:RDE':/<+*-AF>'",)[TJ)2*;-JPGHT'7N4G>UYDUVTW$4<Q"^V8S`D,\nM$BLTI6J-T8$R9R:GUK<;#>_@2Z_\\[=&7GCN]XX9?N>#Z+IALW/]?]_/8(X]Q\nM]_O?'19L[?H;1][QE7IRYL;9:(K<51@MW\\#Z@5L9+FW$]SP2,4,]?X69Z`#S\nMS2,49<"6P2WL&-C!UNI6GOG67K(V['OE%-'@583#8TAKD":&-,)S&15?,%@;\nM)F\\L<OCE@S_:M__`A\\)B\\>3N9[]]Z0""CP5D>58='AK^^[5CX_=L&+MY>*!X\nMBQ@IWL)`N`FM?)RW0**/TI6':"8G6)P^Q\\SA::I#-0;'!ZFMJ9&E&2(3$"L&\nMLE%&9]=SXL`<4QV#*-?P?8TG+)Y)\\4T*:<S9,Z?2R<G)CU2KU<>>_^%WR=+H\nMP@RYT(TD30`*<_-SMT6=;.3>-_T-@Y6W,-]<XE3]QR1Z/[9XED+9$.H"[9DZ\nM,I*,#H]1'BTSO&:8<P?/$7<21L:'V7#-.G19LS0_R<38**.'#?.32Z2M'&L=\nMSN0LM)H4:T-4!@;][8(/KSFV>_</T^C(3H%[R?W\\=:H+0GLS`"7@(TKZ(S=M\nM>X!2<1TS2Z_PQ',/,E=_$?(,[33"28)20&U-C?*F,OLK^]G=V(.*%,.%(3;M\nMW(0J*A!0K(9D@Q'SA;/4@QEDTR=:2#@W=8[)R5/<>N?[N//F&[A[7;!9'W_I\nMO1N$./&7][S]\\),'C]"X%`^L-`O4NSG"SZA'.6F6,3W;I%YO4JU4&1T9I5`J\nM,-.>9M;.T91-G'#,9#.,<I+#SQ[A^BW7L^GJC72SB-FY618;BS1%BX'$(VU#\nMEJ8X9U&^SWBUDEVS;X\\JA/DV?]?MG_ORGA=/_^[MMQQX^/F]3*T6@!02ATNE\nM%(=\\+]C0B&UH6AG-Q%$N57`(M/:04K+4J*,Z&D_YC+MQ!N(:W20BSW,RE5'>\nM5*)2+-/NM&FU6K3:33J=-IU.AXHQ"*&77[R5$"R5UNP]]HW'HW%E[]Q<J%S;\nMVGG-9[_UG:<_?-?XZ-QC4W.K`^!Y'DDK6?*JZO?*Q:%;<U>^=[Z=O:,9VQVE\nM<B640J*51FF-5AJM-5HIM-8HI1%:4!HJ<>WF:ZD&5=KM%O6E.NU.NP>DTR+I\nM9`BS4D><J\\]-/16L>__CQVQPL&B:_S9^8N^6[K7OO.>.7;?]R1>_^X,_?4_H\nMI]^-TN5_K.;3"[?]TU&L1?BZ/-*-GWFSR[_P'L\\S=WO:VZZU]K7J+?XU,`JE\nM%(.U0;9NWDJKW6:I4:?1;%!O+-%L-IU>"MWH_";T?,DMSBW&]86%R59K\\?MQ\nMU/VLASMS:/U^OGZ"^Z\\+W#^ZD:LJAS:_M?.CEXY]_//_\\].'=RK!R_82`*RT\nM.QZ]`X036+'&]_QW!KY_G^?Y=WJ>'E'J]5XHA44&!P=IMEHL->HL-1HT6XTS\nM:2?_RHV-=QU6<Z&:F9O.YN?GIAM+]>-1U)F64IF#>Y[F,^M@3P?OP3'Q%]L*\nM?+*QZ2:YOSQQYIGG]SYPW?KQ'W[JF9^070Z`\\_;AIS]$H]%!2`)/>S?ZOO]!\nMW_<_H)7>D)M<2*FHE"N8/*?1;-#JM--VI_W-;K?SF9/G3OYT=&C,[7UH[R]\\\nMQB,3@B7#\\.TE]^CZ4O#K4]>\\C>>7W'/?>/+I^VNA?^H_HO3R`:RTC_[X08PQ\nMTO?][;[O/P#B@7I]<>/4]+3P/$T8AI-Q$G^NW>W^LZ=UZSN__9U5S_W$5D$]\nMY_H;0O=X4*E=]SW_:EX^-?.E?S@S]_%="G/A.'`)MOOAW>QY9*][[R?OF7>.\nM']2JU?\\<&QU+PK"X*<VS%ZRU#QX_??3K(T/#R9._]>0ES3VH!!]:HV?WM=U4\nM7!E\\3ZU6FTKKBX\\^58\\/3J@W0*%?9%]J?(ERJ:1F9F=VG#IS:KY:K<Z\\^/)!\nMOOF!;U[6?)_>6J7CI/?VJGSW!A.?_L2![BN_&>`>2J[PPG\\9]K_M-C2="WSR\n-)`````!)14Y$KD)@@O?V\n`\nend\n
105947
 
6625    time_sheet_write_48             begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```0#$E$051H@=V9:9"=59G'?^==[WY[O;VDEW0G9.UL)"1@\nM9D`,:]!!5'#&`41Q1-%AF&$L9Z9&+;4L=<IQ5,K9IZB:8:P:](,+#*B`;!*!\nM$(@2.GNZT^E.[_=V]UW?]RSSX=Y.0M*$5`)?YJDZ];YUJ^XYS^_\\G^><YYQ7\nM\\`Z;N_5+A+_^,A_Z]B-+NII3:X>G\\^-/_N[(SF0L6CG\\O8]=</_B;?#QK';7\nMOS_)=+ZR]JHUG?]AC.DY.E4(=P[EO_Z+O]SVO4W?V</.>_LNJ'_K;?)S0>NX\nM^P'^^<XKZ<VD_G"N%-3]^(4#'SHXY_ZD:5'/)^]Z9#2S>5GC!8_QC@*,9DN(\nMUH][>X[G6U^;0C0OWR3[5BW6ZWN2]>'L\\9;-O7%Z[ON?"QKC;0NA;<`3P-]U\nMU,>:$X[]K][ZXOXMMZS?U-M\\3RR6N-%K;$]O7MXRLZC.B3V_YYC]])[)5Z/)\nMQG],))(/*:WF?O6)WG<>X!NW@X&HD62$P'=M<!SP7*CS,=[!I:V]S:ONZQAX\nML>E'J8OWO7##?5==O[:S:[8L>63/&-%4'=KR&,XI7"]"U'>#1-3Y27ONJ6^O\nM>?FVJ?9V2V"J8QG`&-`&8PQY;<P$(&_ZFCD_@*]_%(PA95GB6\\ET\\W6)5)-C\nM(4%7T&'`JY4V'*O.?^_@7/WRO3M%_W6?9O=UG^58KL)`3C$=.%2$1\\3WB$=<\nM8IY%U+.(>K9)58YD6U[\\5&6)O1O?LS#F)$`-(H_A.\\+H?S)"F/=]]22$<ZX`\nMEA`H95:DFSH^W+?UCU/YZ2,4I@<PJL31E@@[TG]`_W`'/WOM4:ZH<PD6;>?P\nMWB(5X^'Y<6()ESK/)NI9Q'R+F">J[YXMHO[*!F'^BN*NSY!P\\QA3%<)HA=$:\nM786X'<1_`S.G^G7.`(X-6N+7-W<YKNLQLN]Q&C=\\AO$6PWC/2_3Q-!VI7@X>\nMZ.7!@<M96>B@LRM%7<HG&;%(^A9QW\\9W!(XM<!V!ZUAXCL!W+>RZ:RF)[Z+2\nM/D;82*D1!^['GWX&(RRTP3<&^PR_SA7`ML"U0:#080$;0ZEY$4_7/46EF&4V\nM)[FZ^=UD+J^@_"Z6AB&+&RT:4I"*0-(7)#R#8X/!@`!A*2P+;%M@6V!Z+F%M\nM;R\\5;?/;H2+Y_3\\D(FJ35PNG\\P9P;#`66$(!$L<V_'SP!_Q\\\\A5L(]@8OY1\\\nMOLS<<!>;O&9NWYXFEM8870)JHZM:,P8Q_QL:@<%H33(:H2ENDP_`&(G!X-I@\nM.Z#U!0+8%A@;+#26"9DLU//"@>7D["R=L9!,=RL3IIL,6_C,78OIZ4Z<:]=G\nMF$&AM<$2!M=YNP$L3;'H\\$-Q-]F.&]GX\\J^IC.UAIFX#[8U;N.>V1;0T^N?M\nM?(T`90`!MET+(?$VA)`P8,*0AP;7L6/QE?2,Y.EU._C]]Z_"6=K-LI1UX<Y7\nM_4<;@Q%@N54%+'6!`!B+J%#\\:K"'!Y>^B_J9"ELKLVQ>G^#V6]=1+LWQZN[=\nM//'$`J.<2_?&$(U&V;AQ(^"A="WG7+"<ZOL%`*3XP?A=S(Y7TH<NO=$.`I?W\nMS$[2&I>\\Y[J5Q.,>CI.@KV\\U9J%1SM%LV\\9S7<J!0=="R').`=#G"[#T6SS^\nM\\^DV;MUVKZAO\\K<<G62Q/D3?N@Y:VNL!&!T=9=^^?>?MO#&&6"S&)9LV`5XU\nMB4]7X+P`ZKX"!W=$N?6C7Z"G:5OG@4G66F-TZ']C<?N]&%.M1C*9#/%X_+P!\nM`"S+PO-]RF6#,B"$0<PK(&H`IQ4_9P=P/@^Y+PIN>/A.UG=^+'HPRQ:5I]O_\nM):L:=B%.Z6U\\?)R]>_>^I9-O%F+S"FS>O!F$]X8D/D\\%/@B?_33L6'<UERW]\nM6\\9+D763TRQM>87-R_9AS1K$*;.1R62(1J-G==[SO+.J)(3`<6S*18W2X)R:\nM`Z*Z%YP[P"4?@9\\^NHR;+_L&QF[I/3#"JOC>N;[ZAV)U\\;@].ZLQQLQ7OTQ,\nM3+!OW[ZSSG![>SM]?7T(<?8BN%J!&HPP-04,6@CL<P;H^"[L>KF>3[SW:S2G\nM-V1>&F*M5QQ.!+_XS[86<X^*KXA;;6U(DV!L]#@EW\\*/)KCL75N)12-8EO6F\nM(&_E_+QI79WU^1P`@]%G]GDF0.P+<.R'#C=_Z2]8WG937?\\$5\\3+NK=%OGK#\nM>S^W0NA*M.+4(4-#&(0</G@0K35""%S')IU*T+6HE=:6)AS[C.+QG,P`:CX'\nMG&H>P#GD0%=/+T<O^R`]P9KW#UW<=4]LK&!OLTNL[C1<<57O5659\\0>/C'%D\nM8#?CD].4RA6,,7BN0SH9)Y-IIJFID<,#QVBL3V&;`,>"<]D93FYD%Z.-6U6`\nM&H!=I7I+@&W7WD2KNM\\IK;KTEH/EG:GQ0YI,2YQU&]NLUU]_S7_V^9T<G"Y3\nMBC80J<_@)2/5/ZH0-3&->^1UFES%\\B7=M+>WX[DVFR]>3>>B%O0"\\I]NEF4C\nM;)>@;)`U!81=#2-AJB%U5@#7BY*U$_7>[/B*S?4)XI>GJ6OP>>[YIWCVM4%*\nM+2M8?^U:MJ[J))P>(1:+,3HV!GX<E6CFX,@DQPX=8,>^W](Y?)Q5JU;PTJO]\nM'!T<)!X[>XVDC<'W(ZQ;OY%0>B<4$'95`:/!>BN`@2,'""I!9O6:M;'%O3TT\nM-C;ROX_^DJ>/Y&C>=`U_>O4&-G8U4`P5.R<.(0-!(NJA5)E,<X*V=(3A]B;Z\nMNQ8SLO,9RJ_L9O7*%<BPGANNN9Q4,G%&<AM3W;2D,A@$QG8)RAJEJZN0<&HJ\nM++")G0$P=+B?F5QN[HX[;NOOZNI:\\MACC_/LH6G:MES-/=>OIRD9X=#$'($V\nM%`.)+$Z3FQREI7<E9:F0QM"4\\%C3TT8L=@U#SS[&_OT'T&8)#S_V)$NZ6K"L\nMDU=1\\\\NEU@:E#:X?H6_])D)5+>8T(*P:@%I8N3<`_,L##X*A!=C4W[^79W8?\nM(+;ZW=QV^4KR4Z,4RW78GH_2AJ;NB]!:$VOK(1MHQJ<+U0-7J8`=Y*EW/<(-\nMES'ZW&,D1\\<0P+8K?H_E%_6@:DY+90A5]2F51FK`LJH*F&I!)ZR3;:%2XL1T\nM//'<RY3+%:0,/U0H%EI_\\^(NLNENKMJTDJ94%.7%*95*M5.AP?9\\9K7-D8)A\nMO&S(AXK`0&`,A_?W\\]2#]^,YALRZ+8Q-3).;F67GJZ^!96'9#L9R,,(!X6"$\nMC;8<M+`))03*5,MI:@[/MQK(@@!**<#4*Z6O'#T^QH'C.3)+5K"L-<5<.037\nM9]?S3W/P]=UH8*8B.9HK8H0@'G5)Q2-$39GIWSY+]O`>+KGQ([1T]9!9<A$B\nMGJ)4+'%D\\!C9F3R!-`2A)I":BM0$JOH>2$-%&4)9S8%35RXAJLZ>G@8G0DA*\nM!8).`3W#QX:9M>.L;\\_@6!:56H?Y8H'7'WJ`K=L_@.I8C>UZQ#T;UX*9HP<8\nM^]T+^'6-7''KI_#B*4(I\\=P4Z46=A&-'F9S*,C(Z1??B.('4U1#2\\R%4#2>E\nM3SY/77D-"^\\GIP"$@&@SF.3DY#0FFJ8^YC$U.88;3V&['N^ZX6;:>Y?QRJ\\>\nMH6+OH/OBK:3228[U[Z8T/DS?>ZZG<^5:$!9!I4(PDR,22U*7:65V?(ARN<S$\nMY#3M'9T$LAKWH>8-N:"TJ8:0.>T@7[O$>%,%PE`B!`FMC5,LE;$C=91G)A@8\nM.DJZO8OFQ<L1`KI7;\\"D6WCF1P_PDV]^CE@\\0=^[K^6:.SY%0Z8%C,88*)N0\nML9%#1!I;2:13%%T7K35SA1*!,@12$RJ06I\\$T`:E#*&LAH]6M<2=;YQYK#P%\nM($0((;76IK8B(R(Q9$Y3*94(M<$24"J'N.E&KOC(GY`;'L":'N;:/[J=MD7M\nMV`*$Y6",P;4@GHB#D?BNC>][E(HEI*XZ'ZC35B%]\\ADJ0Z@TH=08S8G&V4H)\nM*25`UD`EXGF.-5LD,`Z-+9W$F]H(I$*9ZFIC.Q9U#8W<^=5_H.'%ATBY(:[O\nMX-D"6XCJ+5I8)IE,$&EJ8V3_(2*^3[%0P/4BU226^C3GJ2J@#950DI_-$90K\nM&,4))<Y:"X6A!,$(QF23R43<&1IFLA"0;NT@4`(S6T(!ON?@VQ:.+4BD&HBO\nMV4IL=!_V1:N)>A:.9:&TP;+2^.LVD"\\%',V_0C3B8Q#$DVDJ877%.3'K"J8+\nM`6/9`CHLDRV4T4&%4KZ`4;P!XG0[L8Q**5%2C01!V)^N2Y-0>:;&Q]D[-LO`\nM5(')0HA4&DL(+$M@"8&-P70LQ],A?BE'U'-)1%VBGH/G6$0<"UDL8`IY;$L0\nMC26(I^NI2$4H34V):L@4RQ5:4C:M+<V4G3HFLG-(!5IR`F*^+0@0AI)\\/E\\,\nM@N!1W_=IKT]B1O9C='7[4Z4YU,SX&_\\M!"::1-8OPCK:#Y;%;#9+I5(F8EO8\nM0C`U,$A]S">;R]&]9"FN'R6LA<^)I@W%0I%C.<FNHWEV[MY#-!:CL:$9%9X)\nML2#`W7=^&*TUH90_EDKU=W5U$)L^BIP\\AM8*49S!BJ>K\\:T-QD!^>IKB3)9R\nM:R_!X3V49V:H*,B/3V`;P_CQ,<ICH\\2C'J/31>I[-S"8E0QF%4=SDJ&<9"@;\nM<NCX'(>.9]EU:(+G?O,2Z70]F]:L(.6[)P!.;0OF`$`H)?FYXI%H+')_)!K]\nMSI*.5N_@_I>0B01V>SLX'LIHI#84"WFF?K>#SI5]))8N0Q@;L?=E6BZYDC`:\nMX\\CH),?W]-/3UL3C3SY-I+6+H:)AX-!(K1:J;IZ%_!PSN6EFLY/,Y?-T=/=R\nM\\8I6EJ0*S!*B0S`N&`E&S^\\";_*%YO-_]@F^_,WO(Z7\\+RGE)8U-C1^K!`$3\nMKSU'D4N)]?02L6TBC@WE`L88"A.C)%>NI'']5IR)0?*E@"-#(TSN/\\C2UD9>\nM?'$GUNPO>=^R*9S<]ZOWG@(,HJHX"IF05-P`,A;Q1!I_V$:/0"(8PA:@0]!*\nM+'@F7O"$_==?_GN$$*U2RN]**6^>R<V(F5*`MV@I#4M7D&G-T)B,4ID>H2F=\nMI*N[BS"43&5SS(R-(V9G:*V/L_/EW12R!_GX]C(M#;)V.J]@*(.I@"EC3/7=\nMZ`I&E]&RA)9EM*J@90`R0"N-D>PRVER%(+OT`V_QC6QR+$<B'1D%\\5DEY50D\nM$KG#LNUH,#%`?F:4H+Z9;$,3L62<?"[/L<$1;!G@:TG2=P@K97[V[),FK9[G\nMH]OK:4HTHU0$"Z<J?NWKG3$*HZN9:;3$*!NC'8QR0"F0$BT%6F*,Y@6,F*M.\nM^2E%WD(`\\W;WGW\\1A(C*4-XBE;Q7*[U&"&$[CHWG>?B^7WMZ.+9%I5+A^.B8\nM'A@\\]KJOQQ[\\FQM^,YQ)%82B.OG"KC6K=E"WJE7F&5Z8^8U+8+001E$PAF>`\nMB66WO'$S>,M+FML^>1_I^C2ST[/M4LGM4LKM2ND^C&X"7&T,6BE9"8*I8K&T\nMIUP.'M-:/VR[]I!6FI>>^>E;#7%!=L[?B:^_Z0YBL3A:*T]KU2Q#F0FEC$HI\nMD5)5E))C2ID)WW<J<W,E=CW_\\#OI]_\\?^S\\G#ZU9M>$CQ0````!)14Y$KD)@\n!@E)5\n`\nend\n
105948
 
6626    trash_ok_48             begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```3F$E$051H@=69:9!<UW7??_>^^Y9>IKMGG\\$,!OLZ`$B(\nM`$12(BESDV31H2B++$K1!\\?%,$NEY"2TG(1E)PZ+6<3$JDI))=N18A>]I!Q5\nM4=3BD)3ILDQS!260(`&(Q([9>Y:>Z?WM]^9#-T`"`DE9Y4HJI^KT>_U>OW?_\nM_WNV>T_#_^<B_K8/M&)-5@G*?FJU$IUS!+DPU=DH,1F=ZHS6QC%&.Q8@`8D1\nM%B`%.)8TKBU#5UE!QE6^8UL!T`(:0`AH`"%^=ECO^\\M_<C9B(=3R]CZGIU^:\nM=<KH37ZLMP1QNKD>).L;83Q>;<>]?A!G@R#V?#]RXC"6:1A;(DD028J(.T?B\nM!*6U<8Q.;6/2K"W"G)+A2"G;&"IE%H;ZLG,C`SWG1X<+I_MZ<V<L2\\X`*T#\\\nM?J0NO_K(]_GJ@[?RK2/GO8-C_9N'\\MF#EN/>6)?VM9503Y1;2>]"*W8KC9!J\nM*Z+5#@G:`:D?01A#&$$00A!USL/X\\O,P>D>C&*(8.TW("BBZ%D.%#!/#/>GV\nMC0/-73M'YB<GQWZR>?/PB[V]^1>!GP#-*\\D(`/'`8YAO_@8W/O[LNFO7C_QB\nM7[%P=TLZ!Z93-7C6N-:,S%`+-$D00=`%$G5!A%$79`<007@YX)_ZWM7H*H3]\nMCHHT(9L13*POL'__>G/3S;NK'_W(Y.O;MX]_VW'L[[YQY*79/=<>0BD;,?;;\nM_YWR:M6]Z]"^^[>/#OV+EK#WO-;2ULG8IN;DT+D"Y'H@->\\`:/F(M@^-)J+9\nM1K0"\\$.$'W:!)I"D$%^A75<R<=(]QI@P@"#$A"&$88=$%"%TA#$A$."XL'/G\nM*)___*WIY^Z_X\\3(2/]C29)\\2P@1"X"[O_GDKTVN'_V/IUM)]MG%)G6W!WI*\nMD.W!V!XB3A'E1>1\\&;FT@JQ4$?46HN$CXA02`ZE`:`'F8OA:';WR.Q:F&]X8\nMB3%@=(I.8DSDH_T:VJ]BPAHF;H+V@1!C0I1*^.QG/\\:7O_QKC<'!TD/U>O,;\nMXL!__A_]M^S<]+2VW8./GRQ35Q["<A"--F)Q"6N^C%BN(!MMB#5<`FF!4)<?\nMKZ;F/:Y?TG<_*T&$8)KHM(Z.5M'M%=+F"MJOHN,F2B5\\\\QO_COONO?,5(<6G\nMU.B2#)W-HM&0&JJKJ*DYK/DRLEJ'*.D`$!=!*I"=F>O,JOB@1/8SB+E"`6DA\nM50:9[8/>+%KW8H(UXK4RCE\\EFW'QXS@TTDKD][_R#UJO/7EFUIM=X^#*')GC\nM;\\#B`L01"-D!+"Z"_;\\IAHY_&9`6)INEN&TC#W[I5U@WN8W_^MSK;_7WY.KJ\nM[.E5\\R\\?>F)F-,CAKMM#\\?HL;YXY0WFE2IQH!)*_15WYNX-O0*<&(0V%'H=K\nM=JWC4[?OPQL?Y%^]<(PCYZ9G?O_H:=0?/OX*!F:V;ADFBH;IRPXST;N=V<H"\nMTTOSE%<KU)H!4:S16@,"@03X.R%FNA_&&(PQ"&&P'2@5/";&B^R>'&#3GE&"\nMOAQ/+5=Y^<6W:*ZM&B7$3"L(42^_=)Y6*YIM-:-H:+C@"-%/3[Z'_MPHF_KV\nM4/?;-*,Z:WZ5M6:-:K-)LQ40A"E1;$BU0*>@C<&8#L'+U'05T77%#DA+@%(2\nMVU9D,R[%8H;!H1S#XQD&-N5Q)TK4"BX7XH1G5NLLG%TAKJUBQ0E2$!@AY@R@\nM3M8CXB@M/_',R=8OWK+5*?7F\\#R+GAZG$\\#:Q:*(9XTS5#"D0I/*A)2$6,>D\nM)B75,6$4H[4AU9HT-1@D0EH(82&$1-D*Y3C8KH.7\\W#R'DXQ`UD7T>,1YERJ\nMGL,9I7A>*):!=J.%:;80[0BI#;)K\\KYLOC%8ZELT@!JX:Q_"DLL_6:A7SSU]\nMJG>R-\\^.B7YR.0\\A!4H)1&2(DY1&H&F&FE9B:*<6@;$($:1*8I3$SBJ<K,+.\nM6.!8"-M".!W5MB2V+&)E$5F2P)+XEB3"(O(MXEB"8SKJ:5"B:ZV.JPF@J!1[\nMAT>Y;F!X=:S06XG2%*5L"P.UW'AQ68[V;'JMW.3H\\06*H<6`Z]'C>=B.(A&=\nMR.J\\T)"FAC`V-)*.MHW`V!)<U5''ZAP]"QP%;H<4WL5[%^^+3C!9LH-2=H-+\nM"*2!O-:,H-F:==G>FV<XF\\-2SF)J=,.2H`R0:--R)/.W[AHBW3G`F[,UUE9]\nM+E03=+6%J1@(06J)0:*11`A"`XD1F&[ZOCCP.T#>3\\6ES"P`J34J,&3"B"(Q\nM@TG`:-1DQ(3T*T/6M5&V`D`;,V?9GJ^C-@IAX0D_"5,UTYMSN&O?,-.5-L=F\nM:YQ::K)4"VCY,5&8DH2:)#`DH4%&!CL1N"ED4T%D!`F06@9C&[`-V"G8W1HH\nM#9;06#K%CCNWO+;!,08[-3AA@ANF%*R$8B8EYQDR.8F=42AE8>AL%JQ.[II.\nMVA5M63G4D8=OXL"C/T1K/;W2#%&69,-`EOZ\\PS43)=::$<N-@.5ZP&HSHA'$\nM^%%*'&FBI!.PG2(J,+H[G\\8@2!!"((B[B5=@&1"11AJ#2#N(3`(FA30!HP5.\nM%H0'1@@TXF)MOE*FA;#XC5\\805V\\HF%ZK1VGQAA+28D4`DL(BAE%QLDQ4O0(\nM8XT?)?A12A"FG%YH,+W<1@C(.)(]&P2V"B^M"#"FZU[='&\\$Y7(/2ZM)MP:(\nM2UFVHP+>"_([$F',S$7_NT0`PWS-C_TX-?F\\*[$MV;W<*3+Z8E47`MN2"`<R\nMCG5QPMFRSF++QO-D;`L_#@@2GR`)\\*.`5M2D';6IAS4&1F^AWMA!&"8?!/2]\nMI"5@WG2)=@D(A&"I&21U/TKS?3D;1WWP$L)1'9*EK,/X1)G(:=+4"2W=HI$T\nMF&_-<ZYZCN7V,G$:HZ1B(K_"[M&'F#JGL"U)8C1)^K-B%X"I`BN76T"`$&*U\nM'265>I"LVZ3D)0+O9U#7MK"$9,O&F&G[!:)V2#-NLA(L,]N>8:8Y33-NH8T&\nM*9#"8BZ<8L/P07:K3S`^Y/#\\X8!F_,'6,.\\L6)>`*N^V@`"D$,T@UN5J.]IK\nM6Q)769<JWU5?2,<"X_T9TN%G^4'E"8P1I"9ALS?)S<7[,3T2B2!2J[S0>H)F\nMT@1C.&8_R34[I\\FM?)8@++SO&`!YUZ'0DT7:BE"S4//CMJLNLX"@X14"&:S-\nMKC0CE)1XMD')]_$A`ZZRV+]=<3SW%OTZ@T%04`4.-![@S.L;.XL_`X.]%K?M\nMTQR-GP($J6F1*I^UN5Y2'5]UH6X,#!8R7+>CA+'G66R<P+9L]O9OG=S=O^'N\nME=GE[WWN['2L+J+I#]<(M9E>;H18$ES5#>2K^9`!2UCD78N@#;\\P],^87/<*\nMI_0+#,1[F3JZGJKO8W4SF6,K-I6V496#)&F*%(*=[9LYL6PA94*JS4^!WS%>\nMXMK)B">/_PXGYH[AVA[::+36V^[]T'U_</?NN__-][[YO=]3`#]Z^&,<>O2O\nMT,9,5YH1!G`=ZU*0OANY9UL,]:4LQ&_C.V4BITRMD"5S[@[6MP_0:DL6*C&R\nMFYWR&9N]6SS2=(`/6Y]#9^M83H*S="T[KJE16_8X<>*=]*D-;!TKLF=7DZ^_\nM^!@3O1OXU8\\\\0*55X;E3S_'<J><X-G.\\L*%OPV_>]\\!];ZHKJ,]66E$0QMKS\nM[*L1@%0;4I-R.OT;GE]^DH%B#QO<0?;W;N#P2V.THNB22P@!=3_BN\\]7<>48\nM&7N"G"O9O=4FWG"$8X7_Q4CQ(_3-?H+E2M1QFU*&&_8+_N3(U]BS;B]CI3&>\nM/OXTS[[U+$NU)7ISO7SAHU](QHOC1QOM1O4R`D*(<JT=-]?:L9?WU%5B0!"E\nM*?6:AY895ELM7-MAQ:U3[3W,EO%[.7K&8+T[^`UHHPE20Q`DC`YZ!-O_G%?]\nMIYFJ+C(5K7#CMGVLK@UCI.&V#_?RS)FOD;&S)&G"U__ZZ[PY^R9IDC*Y?I*'\nM/_[P\\IW;[_R*"M3OEP9+:Y=-L11BI1DF:TOU@"352"FNJ`4&2U@$ZAS?O?"G\nMK+6:U-HMTM`A(_+LWA7BV>H]4Z^04&L8_$"SVJK3#F+ZU#!ZY`T&!S7[MO;2\nM<%[FS?EC1#KF\\5<>Y_7IUTEURNU[;N=W/_\\'Y4_M_/0#YWYX[+%*I;(FG(M[\nMP^[L2BGJ09PNENL!<6JZKO!N!@+/B7ECZ2D:]0;-=DC=]]FL/X+_^J?1S0%*\nM><5[50\\AH+P<$[]]`U[2CZUS;,GN9"#KLFG7`C<>E'S[[?^)48:G3S_-7'L.\nMZ4H^<^`S_/9=7V.^.G[TT1^>_\\&+O1-ZZ[ZMG4E_]\\NE$'Z<ZOER+2!*-(9.\nM5_G2:AF!9HU6L\\(&9R-A.X;$9CRZB9FRYMLO++-2#Q%7),9._3'=<\\WB5(F-\nMZ2%*U@`9DV7(&6;+A.9L_"RG:J=YJ_86J^DJ*JOX[*%?YDNW?9DWIBU.+J[-\nM3ISY25CWPW>\\YM(@QF!+DZ;:3)=K`4&<HLWE&W>#09A^MO9>PZ[\\3H;$,`O5\nM)2XD1Q@NN>0]]=,I$;`MR6AOYI)%!X<3IL.WZ:%$UF1)PI2!GGZ^<_8[K.I5\nMZM2Q,A8?WW,G7[SA$5X]G;!4;R,1T_7)2<+V50B\\^INWHCL#3B\\W(OPH)=7F\nMBK:V(8@EZXLW,)Z=X+:1V\\CI`L\\L_S%>WP(#/1EL2Y+J3CKL/"+8N]WFQOTN\nM.A7TYEV2L</\\N/(*>5/`21V*=HFY<)XW:V^2.BDB(]B_\\5H>^O`CO'X*%FMM\nMI!#&8*:--ORG^SYT"='E:;0C,VNM*&F$L;*EO,(9!,:DZ&20T=PD;FKCN`XO\nM-9_G#?TM/KSY'S(P8!-$FF9=<6X^9'S08?BZPX3^(+MW3%#HJ_!D\\T_PVS&%\nM4A$=PH:Q;?RWTX^1.`F6L!AT!_GU@[_%V;-YII?7<#,*`P'&S%X)]J<(",%"\nM/8C;U59<*.6<J_"#(#'D[-W$9IF=!0_'<SC1/LI<YHL,KRLQ4BJRHW$OU?HX\nM^VZ<)NZ9HI1QV7?365XJO\\3Q$R<899R,]BC)#=1,B]?JK^'F7:20/+C['R$J\nMNSAVH8R3Z3J),4VC*5^9'JZH`R"D6/*CM+K6C@MY3[VSW[U,#'Z8(^]L([6F\nMV)S=C%!PN/X\\B\\D,:_0QHI:XZ<`F)K?F:*S<RNG%"S22>6X>NH/<CGZ.3QU#\nM13F&"_LX%CQ#0S602O*QH5LXY-[#=U]:PLC+!E\\UQE2NQ',9@;6WRR114I<;\nM!ZJO7EB=D+(/K[LJ%5W@T$FL49IB)1-8U@KK<AE0T*+!X=I?4VG520?JW+AE\nMC!^=.DJ4I&P?V,Y:O,:QRG$.C1QBJ[65J7,9O(S+X?:+R*QDP.GG"^,/\\M+?\nM^#3\\B&S.ZO8`!-4P6#R[MM;(V_9[$SCS9Z^01M569=NVI<9<C6/7K&/S2`_K\nM>S/T9NS.XDY<3+G0"A5%M1F_?097%MGB7$.N-(CC&OK,!.65%#]*>*WR*C^J\nMOLI<,$<I7V)Y>9F_/_8KM"[D"8LSG%D^@YVS^?3H/?CG-_'VU"R9K$`*2#"<\nM;]8YLE*>._M7_]O/[+_^O0FD40K\\49@L?&FF?WJ-LS,MS@SUT+NA0-]@AMZ\\\nM0R%KD[,M'"FQA*#I%W#5A]#&8*4PD@J2Q'`J3#@:SG+#CMNX:;R7KYQXE)EX\nM%B_R&$P&F2AMY)<./L@/Y%_2M)ML*6[F9GDW3QY>(<'04(HI:;C@MYBN+1,V\nM&]/VQSZIDY6E]R8`%CMW?MDL+M:F[KUG#]E,EN>>G^/X"Q7>TA)1=,@,.^3Z\nM'#(YA>=)'-M"66!)>:DGA1'0;04^]>,%KMNRAW^[_[_PU:G_P.GX+#59XR\\:\nMSW#7SD]R?/DH5D[QJ8%?XM73X_S%0(UVOI>:"&GY-70CQ$H3)&::T"?\\G7]^\nM!>++Y#!1=(@H2C9<?_W&NS]TW;C8O+F775O[&2OFR(06T6)*=29F=39F<2ZA\nMO)"PN)RRM*JI-`R5IF&M#:N!8#645"+!L<60AC_&_=?<R)(X2855`B?@;7V2\nMTYQF+#?*'>X7^??U=9SISU-3FC`*$&$;&?B(T(]$$G\\#.)4^]_WW(P!)<CU1\nM%->;3?/1;-9=5RQF4$J1RSD,#F49&\\LQOB['4'^64L[%4S8"1119-'Q)I6VQ\nMV+*8;RL68INR]B@+E]?J4`E&>'#R`&7K!"O6*JMJ%>VEW-WS:4Y6/LZ?UP!2\nM1-!&!FU$Z","'Q&'+XLD^BI"-#Z0@#&'D'*X.CL[_^+1HVOYJ:G6^B`@*X2%\nM$9+40-+MYV`)I"VQ'(G5;>8:2Y)*22P%VK)`2;`ML"W.MU)6@R%^=?M>IN0;\nM-.PF0]E!/FG]8[XZ-<2*`4S2`1VVC0C]91&%?R:2^%]3[+]@_!;Z"@+OL^E]\nM&(@<*.YSW>(G!P9+MPRMZ]E9&LP,>@7'L;,V6@DB(?$-M#0T-32UH&F@)22I\nM:X%G=QJ\\GMUI[+H6G]E5Y/Z#1_B]Z%$.Y@\\PLO8(#YVST)X*B8,ET5A[2S;7\nM?BB:M1_0K!]'J3CYIW=>%>7/\\!_+KP,O`_=D(3=.SMMI%=T];L'9;O<XZU7.\nM'I:>ZC&NE=6.E8V5I6(EK4A90KNJ`SJCP%,&3Z5X*I:>W7[X0$^X:_OWAPNR\nME#YU_H[O_>ZR_C&>=8(T/"D:M7GSB5&?[YR&>[:_+[J?[T\\B[W&(0L%PP:/@\nMY,G;>;)VGJS=2T;ER:@,GI)X70(=U7BJC:>:.&KUYA$G>N)V]5M*LG'Z]-+?\nM$U9<W;=WS\\\\%Y_^)E.?*G#]S?O/4^:E;`!YYY)&?ZSW_!^WD[*PX_:SC````\n)`$E%3D2N0F""\n`\nend\n
105949
 
6558    availability_zoom_48            begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```*I$E$051H@>V968Q<V5G'?^?<>VOMO=W=MC7V>)G!TQYB\nM9F1@HB$;($6#(`D*B$T@0!$2$%Y0%!X0+T@@Q#82`O&`B!`*3X@'(B4*6).0\nM;6;,X(S'LW@9Q_9T3W>[M^KJKJI;=>ML'P_W5G<;>Y+8#M-Y\\">5ZM:I>V]]\nM__O_MO\\I>&`/[($]L`=V'Z;N]4(Y!\\`/`>\\C0@A`@.#!!PBA>/>W'X<`WH/S\nMB`A?!JX<^;E[\\R.^5P`A@%+\\1-;GV:OS8"VHP>.0XECRCTHID/R#0B$B)+&F\nM5A81D5\\'KMRK'_<,P%J(8UA>A^?.'>3DJ0^PM7R%H:$:<;E.VKC!Z,0DQO20\nM_A:UX3I9VJ840Z0SANH1I=`DN&P'^+L)P#E`P!HX<O0Q/OP+?\\&;+_P-8Q-3\nM5"8>8^[</W+@D:?IM-9I+YUE;.H0C>7KQ*0H($EBO-O"NWMW_GL"P`=`^F2=\nM)6R_@\\D25.<FSF:D:^=I-6Y@VJLTN^?IIA'E<I5@UZB-'T-YC;?<1R;>)P`I\nM$I.08=,%G.G@,O#]-?J=1;9Z+])->Q!/HWV&M55TI`@6?(C!*9QC;T+(6I`H\nMKR8J]#'I(LYT2%=>QZ3?PO9'".6`#R!.H158I]!6(1:\\CQ"G<'O-@/>`9)C.\nM'*:[@G)S>)OB_2C.#X`J%&`LZ$@A+F=`?,[`G@"P%D+!`*%/9^4LW>95XIK&\nMV?QI.UT`$(5F4+F*$/(1P:F\\_.H]`.!<7MJM!=MKTEEI8$R"+<5X!]8JK,X=\nM%!1:<E"Q&^1`A'<*NU<YL#N$7+]#OP?6CN&*N-[-``,`%I)D)XF=UWN7Q,Y!\nMT#D`"043KG#<@O4*J_,UE$('<G!.X2V$$.%]SI#>BQ`:_'#P12@Y,#9WR%EP\nM0>&*$$*!+D"Z(G&]Q-ML[5D.Z#LPX(K$M**PJIB1(D7D;F4HA&@;S)X`&##@\nM?<Z"-6"-RI-W```P)B^=RH(QBI(%9R"$.$]B"SK:`P`#!D)05&HCE(8J#$?C\nM5.HEDE(9K0]2CX>@8M&5@R1^B-@.4QL:1;()ZN,'::]?I,]8]=_E7\\N_]3M?\nM]/_P]\\^Z??NF:336OFL_[CG_G_MS`'X_!/4LT0@Z*A$D0M"(*$1B!(6(1B3*\nMU]"@$^+1D\\C8:58:71J]X6NI+2]Z[U:R+'NQW=KZ_`M?_^JWCAX_+I_[M\\_>\nM/8!"J$R*\\`=*L0]!PFZ!,A`F0FAM<2I->>J6]>(\\8[BX\\#9_&T7$L[-\\.HXY\nMW/?#+/'+S&5/<6ENE69G"Z4L$9[@`)]($E>NGYQY_86/S'[!E"*#<V@1YD7X\nM*Z!S].=O]?>V$/(>@#KP2Z]>Y?#",D01:*71*J"4(E(*10"EB;2@$)2*T,JC\nMM69B)";69FE\\G'\\Z<8**!'YSH3%Z>*OR*5Z[>(CGW[C*\\1,'^.$G#U.*+/UL\nM@[358&UY4ZTLM(^_L73T>$5.\\_CD_S`^HBG'YC41_@[H_%]_;P/@BOE<!"Z\\\nMF7!H]A-4RPF=E9>9>O@TS>7+)+I/=62:YM(EZB/#>/%DK0;U>H3X%D1@S3+&\nMH*P!'Q0;I5_EJY<?Y=S\\$C_SL6<X<G":;MI@L[E`I,<IA8R'?K"./2%<.-_D\nMOQ>>)O)MWK>OB>TO2B'H;K-W!!`"5$LQLT_^%.52PLH;ZQP^]0Q+947D-QF:\nMGD5EJXP,1QB3HON::MPEJ(!0SFN^`VV@%3_.6O@@W[P^ST<^^@S'9RKTO:)O\nM4JS=9-_$%$ZM4B\\9(F71CWDN7![F6OLTI^U98K>M2+\\S@+SU#RX0;/<F8F*L\nMZ=%OSV-Z3>A=I]^Z0&]SC:C7(LO:6#F`,FNHN$Y2J>?=V()DT!K[<2[>Z#,Z\nM,\\T//#1)N[6*CF.ZW0:)WT"W%XG[#1+?`=]BNC[.T8,)-Q:/L]A\\G8?*A7"Z\nM&P9$0"&X;`W1$=[UZ*Z=(UU[F<BO@5W!F@E<+#B7UWVM0:/P/BJ:&O0$4GF4\nMQ=4FTX>.X)S!>X>$+J%WD\\2NH\\(*D8-2U,]#D#HSHX;USAAKFYK]DW<!8#<#\nM`P!!:?KI$AO77R1K>:JU823LC`6N:%R1!HW&^R@?%QST/1A7HF\\ZE`GTC<'9\nM#.W7B$**5H*2`$%0O@\\F12>:2J7*^-@H8:.XU[TP`(+OK6+,)B[;PD5MO*]A\nMG8(B1&Q<=%ZEB`)$6N%#A+-@')"!JJ]2KXRQMKY!FJ5X9]#>H'4);Q5.*<0K\nMK(^0$)-4IA`S0:52IEZ)L;8`<(>N==L4X@KJK<U19*VKM&Z>Q5J/*P8V9]7V\nM\\.8&,X[51>)J?"A"R(*WD*0O<&3_",MS<\\PO+].WGLPX>B;0=Q%]'Y/Y$CU?\nM@>H1*A.SI'X?S=6W&*O)=D%P]FX`.+`VD*Y?(NNVL$YOW\\@.!K:!<+$[0YIS\nM.PPX!RD0MY_GX;$%#E1*O/C2RZRW>VRTNZRWNG1=0M>6Z+HR-IJB-/X$5^8-\nM;R][^C?_B^&RW0%PARV8VP#8(C1RP1(P67?'P<+A[8ESP$#AN'5Y7@P8L!:,\nMAV#;].;^A2<>&44V4KYQ]A4NS=]D,X.N*]'U-5P\\23]ZB%>O95Q]*V/AXAD>\nM+E]`B+?O9>_`P+?M`\\A..#D--N1//7:Y,+=.[;`1*6)1J$3GHW*A"W)-#%GS\nM,I/^,_S8["]R_EJ?MR]M4!V.Z8Y4&4I*!`<VZ]%N>Y;>OLR3PU]C*.GA?;RM\nM_NYDW[8*2<@KB7-@M<(5<W_B<UFX.]P<"AM`>84/<<%&_IT4#R/IG&?&K'!J\nMZJ=IC,ZPLBFD*YYV4"C)J,H<);-*;>@8#?<>TM:K!(EQ]BX:V38#LL.`L>"C\nM0J07H>3M(!>*V$=A/41NAP%;E-(0<A`.(%VB+L\\Q4T[9ETP1:@<(O06Z6<1,\nM;0,Q3=SD,1Z;_AC7/]]D,6H0Q?<(8%MI&85/-)9!+&J\\*21DG(L6IQ21S^>>\nM(#M5R.T&4$RK5@":)+TVE2A#^6N(GT0'3:^745Y\\B1.]+A5ON;PQ15M5&)W.\nM\\FW([QI`@%JMQM#0/BHA0>(I2E2(78UR99A@)JC+!+6R,&8,4MI/B>.4:^.8\nM[LJV\\];F]RJ7*U1K4Z`2:FJ*:E0C'BN15";`CE+Q(]0J"<[V\\&Z*N:]]A:G%\nM);+J>WDC^='Z\\V?.#M4KE75H?0<`.4H)0GNX;#K*-T(L"LE6<:*)16$SE6]6\nMR1R]CB:(0N1-LI"O9^EF[`-=ZQ'GD.!)A\\HV5;+A)2A46,L[MVA<]A8BBD@4\nMO5011"-<Y=K^-GK)E0_<^&:Y._O!8QO33__>LV>^\\H<?KI;,F9YY9P!%RUX5\nMX=="<&7OW2UBY9;7KG]C=J^A4`*;!&P(N"!\\,G@_Y'TJN\\^[HU`JCEV-,"_J\nMJ9.F]R>'%UX;Z1Y[[V__QH\\\\<>DO7SK_F<<CQ<5WJ$K?-_:G!^'CHR1G'E5_\nM=N,]RK_RT2?EGW_E9^<_<>SP^__Z`T^1%.?=QW[`_Z]]N0V?WJ_"O.&5T4A.\nMSF3-$^7)F5$[-'[B"U_ZQI=.54M;EYS__@4`\\+DM^.2TZBU9]=H([D/U=&/J\nM+1\\?"B+)9QOM_WPZ0NYC2^G=L?_8@@^-QZ]?R=0?S>E:\\^AP<OWAQ'T="%K=\nMU\\[\\NV=__,@(J>CD_2/Z)P_[;/Y3KW8O?;R,_&Y_KSW['MC_`M.A.4O;WSF_\n,`````$E%3D2N0F""\n`\nend\n
105950
 
6559    balance_zoom_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```/84E$051H@>U99W1<U;7^SKEW[IT[53.C,I*ED2Q9DJMD\nM8SDVV`8<0&"S`&,,H22A.4"<8$(">8\\60@D)>0DOP*,^4TQYCT"HICMQMXQM\nMW"2K6+*Z-*,VFEYN/>^'C8V19#O$K.2MQ;?6S)][SC[?=_?>9^]S+O`MOL6W\nM^!;_3)!_-H&O8FC'V7`YS73]SK"WKGY`6?_1@:'R2B\\>?MX_ZGC^9!.X_4+`\nMY0`T`W:>PB8*""432',\\<.>KQY_O'_:B>U"9V]TJ/-W1)O>)6:X?^@>,WK'&\nMGU0!?[S!!,T@U"(:<P31]F]FJZ/<3"(=%E-JOV36FVM.0[O9`K]9XH;-9AJW\nMF)'TY%.-GT(UJ$#SFRIV-',02&2"V&6>+(9H]D!$\\YCI-RS@UQ=S^/7;.G)R\nM\\XM,/+E!)\\)U,5=%3K?-@Z3<6.ZD@7/S3'%DFQ3%:C+B5K,<L5KTL%DDPXD@\nMH@-OZ_'N@"%W!XQ4;_\\KQF"8RV7$'=0L2F-F,A+0=&[,M?\\A`0]="MSQ.L.;\nM_S'=^]?SO9?*<O2FKE1Z4ITEBW2XD^@Q'T!4C&"<.QNS;*=@AF8(A;$AMT6M\nM=:?3,?3V,]D_R(+^`=8=&#1:^H.L?6"8-3!=);.F#`R,\\W*A9)(OE\\QD\\.W-\nM^J@<OE82/[V"QTV/:7CC(9_7X2E<(DKVZX<CX<KMT1#78N?ASG;`YS"C4))0\nM8#+#91B&*34<ER/=`\\.AH8[`0'I_=Y_1V.EGS0>ZC8[:%F-@,(*X183^XCTF\nMM'<95Y>.ITE90Y>NXNSOWZ\\^M'P184]^R$Y,0/>6)<@OMW`?O#>X]$!GJC0<\nM#+YL$OC.<:8&Q*(JR?%:?:+%OL0LV:XV\\<94IH6XB&P"))'9!)KF=#T9"LD9\nMC.E<));:W3N0>CPPA/T-[>C>WHA@6D$*P`@V/ZHF4%7FF',*?_>T2=QCFW<;\nM05\\.N3<:-9[1#;0O?T0;P774$.KM2Z!O*)37TBP^R/4X)L"2ED_)V_Y,4N,K\nM[3;^`LKI%S(]5IB,A1.*JC6D570ETFB-Q%ES(*@W\\R"BP?@7JJ:Y,ZV25G?O\nMRM2+#]_`LZ??&4G@RRCV4:@J9CH=I'_N,KEG[9,"^H;8'JN5G%Y40-NG^#34\nM=YV`@):V$'C)",<CX3J;:)I@%UK/[PK2B3J#7=,12LK:RG!<:>X/H7-_%_IV\nM-!H154,:`)[].0^.8^7[>XDA"!P(XP@`\\,?)MJOF`W>LU.GCMW!SW4[RR:>/\nM"FCN9.`H-MLDW+QCCVZ_JIJ+W;GRZ%P8U>SOGJW%%6?HL52:/&/+A,T$O6-S\nM'7Z[YX`^4-?&DAC%_5^``6"'GA)0$$*/S?P0QN50W'$YBIUV*I67<G7!D($7\nM5VMX=4UFS_\\^$!K(<I.9%HFL!XX6,*KUBJPT[OKO0A1D&5.*\\_!HEIOVGS&#\nM<BN6<HECD?\\R"`$(I<`)"%@Z&UCX71.R/>1TIX/LW+)=2\\_\\OHS_^:N!5^\\/\nM0U&QD>=QVBM_5NGMEQQM;U3K^7D4=U[1-LYF)[GY>=QZ3<=>R4S.G#J1PXWG\nMG@A]@!(`Y,0\\D.4A>'VUDN&TD[(L#ZDI*3HRIZY%1[N?U3'`<O$%?''%I.,(\nM6#H;J*K@D)M%Y]JLI&%7K9J()E%#.5*VMUYS3IPP=E$YRC#%0?(G(&!B,8>B\nM`CK382?^:U?(?>J7HF17O8Y3*[BTHI%=@D#G%?IX_&SQ,02X700?K5,ENYW,\nML%G)QL("#LM_+_AU@P5L-CJKV'=B,4T)0`AW7`]<O0"X^[\\TSN4D<YQVLO&I\nMWPN8OTP^_'S-;F#O?@/#$58#@K+N7LTQM?Q(ZHZP/K&8P]1RKL)F0>SLQ::V\nM9)IAU:\\4I-+8P'$X;<,6C;O]TN.+H!2@)Y`#A>,H;KN:3K#;B*FTA&LPFT>6\nMI@\\VZ_C9G\\0^164!02!5WJPC-H^ROF06<.L3SR'#2>9;+&3SFC<5MOAV!74M\nM!IHZ63T#,<T\\A9]PRM3CA]'A',#88ZO+@(L7FI#E)G/M5GR^ITY37GA7'C%N\nM8ZV!E7?*B*>PB0%SVMIT^N"UW$@!4\\HH'KCFV@*KA7BL%K)+-0Z^C3^^IN.,\nMF51.R^QSGL/IQ44<KCOG.`*.D0,_N'H9KENV''.N?5IX;?/\\?*O#44Y%U^?Y\nM^3:\\L2EG5'M[FG3L;M0;5(V8\\@NXDJD3#PHX'$S54X!3JWAT]1AS)8GL"P:-\nMN/(E`[N;=)@%LE7RDI^WMNNN^55\\Z/DU8U=6>F@;)<81`4\\\\NPKI=)KWYN7-\nMT'5V83R>J(J)B[W]VAD9K1'[^'1_NN9[/XA\\L'73A@/C2TK8NW]Y^<C<MPV\\\nM]3"O#`3UG0)/YF>X2,LOEY(C`B:6$'R\\3K7,GL%/D\\SD62(15-]\\Q)T?;-"Q\nM[2/KP*I52I=-(K,<=O+I\\3W`'?9`_AG/068.5WZ![Q=]_8,W-C2WN7H'AI,,\nMC$@2;R-:L(@GPE+!)/[T1]_+JZDN>U>Y_V(S0A&&N&R'SOE`S$4LVVEU];2L\nM#;[Q:N^JO%*B'Q8PI8R#JJ'2;":AZA];.Y^_+W84H>TMP!-/*]!U;+*(;'%X\nMV%C[V`I.6_'8Z&WNP5WH<!U@$++='KO]/^L;6Z[:L'M_R)67=Z!@FB\\N\\`;G\nML*8G&_*`H*49\\7>$2_;U%)38S6=A6KX?,$=!P0/4!4YT@*DF(Y8T+5_TP[/T\nM[1O_=M`#URP`;OR#AI?NYN<*)FS^Y,DXKG]0'4%JQSX=H1AKNO1LGMKL7*DS\nM`XU?+>T'V1X40`F%02@#P'D\\GEOV-39?M;:V;>C<1=6I3(>%&PP.LY:.CHY@\nM7W?:;I9M5@O5[*XT"W23S"TMI06?;/(W\\.F>W38)Q,QW@*<[B*'I<265_+2O\nMIQ-/?G@H!R:7<GAD$GR2F3@I3VK#\\=&[A54?&WCM04$-1]EVBQGS.)$VWE!-\nM\\.RG(\\=3^L4?C'?>_V!B+)ZX=MVN_8F++CC7*,AVFGKZ!N,]@;Y`_?X#K5!3\nM>SBF)IFNRH"AB9R0:[,XES/[[.&:1GY%:\\.6$`ZU_E8>&.^`<7B=BZ8#LV9P\nM<&>0N8)(]A"#)2^_2QE!Z,M>Z.XSMLDJ\\S%%]RQ<,'J;22DY'#YVAWM>>V=O\nMGN#*C)?YO'PH&D_+<CK5'>CKU]54G.A*7)=343V=#&F)1"@1"S<9C&W+RO3,\nMR,_/G;S@O,L8``.`D=!@[!L&]@T?7(?W%1#\\Y7U%FEDI?2<:I^]Z/:G2KM6$\nM>#((HG$@'#WRBR8%Q%,2PG&+$8Y%F:8JLVTV^B$P,MR^R`$0CNJZ4>8?")*<\nMG!PCE98U65%515$459'3U-!EZ$J*J7)"DY,Q755E410%!KW5Y<JHMDA2B5FR\nM;![KA?**#G3LAUY>6>')M&JO,ZY=@^``;Z$0H<%L:)!T%6E=`Q-<L&47PV<K\nM0RRAD/H=JW>)H@B@:X1A2A@HX0!P1)9E*:TH3#.8GI`5J*JJ:9JN6T2>!IFA\nM,</0#%U3=$5.I1/Q>&[V^$R'S4I<&4Y#$$R\\Q2*-&1'\\,Q\\R/+1BNC(X&'I;\nM3FJ7D-P<H2M:BB&-1S2:P.!0'(E$`KJ2@*$3@`Z#$YJY5"*]*S(\\M(4W"6.&\nM$"@%H<2@'!VT22)MZ!M@L>1X358U0]$T0S`)PA=;%2&$$H[C",>;*J9.RY>L\nMF7FB:-(3R61O(ID>6P``[-RV!XQAK=V!Q8$`X??L:T)2!EI[&9HZ`%T'\\C(!\nMCP-PF`&1`Z$&!@E#$"0UNH!#(40)QU+)^-8";U:RIFFWN;UO..P0"9-5G:55\nM'2"<0"@O$),@057U.:=6>,O*)E:$HTIYP._W=W1T-3H=]F,+>',;`"`"8,U8\nMYY7.OC%MC"Z``@0$H!S7M'==3<G4L]=-\\MH7;MVV,SQSQA0M&DNI_9&XSCB3\nMQ&!H8`;+R_?8*J95E@4&(D6&JI7NJV]\\]$!]3=?$BE/'7N?OH_7W"0`8P$#N\nMNN</T50R^<#TR:7M7B2+MF[]G-_3VIN,*^`9;[90T6IW9WF]>>-\\D]LZ^R='\nM0M%Y^^KJMS>W''BB:MXBUE2[=<QU3OK=Z&$!!`#3P9@!0@A1U-CVE:M6+Z^:\nM5OXGVX'VJ6V!P<PD2#=OXB*2B=/-C#KE:'*\\QHS<IJXNM:>G^TFWR]GQV:9C\nM=BS?C`<8,V`2+.`%*[X(R4=NJT!5U;PUBI)>4ER0]WA5N2]=X<VH*'&8S\\H1\nMN',D9E2FHE%_7Z#W'<EJ(66^@FLJAYK+5"5%IASC^NVD"V`,4!0&7X$=.>X8\nMTO&#U^*<W(WO3/>AO;5U?V-#[6V:IBRPF$T79CAL5XH"?U4B'EW8U^<_SYY;\nM<,W"F5/?N_F<JG,JW=+[/QF?=_[+5RR";PP1)_7[P".WF-#F-_C3IG&7%>>3\nM9S+=L`4&L4TWL&SM+J-^8B%A5]XY=I4'`/^C=V,P%+DR-QU^J;-V+]?@*FG<\nMM+/N<F^&H_:YSW8A\\)7Q)W9"/P9^>A[PU(,<IN6CP")A4=$X>GN6A]YJMQ*'\nMB:<`07XPA$748.,BPPS?K2#]B^90]9,=H^]VTSMVHJUV=[_8M'-&3CI4PMDS\nMLDAV?N&&K9^OF>3)2-;%DR='P+FYP'V_F@.>%XNBZ>(K*#%^9Y'H3YPV3!<%\nMPQR-,00&#<23##S',AQ6=II98)?8[/QXR9'#JLK0?=YL7EVSX^@V))Q4<9%#\nM2W0K:'02_2QW?,A-O+X)O">'>W5OP_IYDJ"W:D<ZX*\\MX+*+G#C0V)HQ:\\'E\nM*XNGG'FKTY6;9S9;*2$`91HR'!;D>1THS,]`27$FBHNSD>%RFT"E2MXZ:0DQ\nM90PL_VW3#K7E-]A4=\\0;'2K`@^">*?#7!,F0!VJU4TN)Q%=6Z3&)_I<Z>G:_\nM\\<!]&#PTY6MOHXP1V!SV<;%(,,+U-+REI7H9T8<@<H!@]D"TV2#:'1#L=O`V\nM!TP6.QPF`[9D(V(#,4Y3$MX?GR>8W9G<B#[AA2##A`9@9P)OW)1-II6&_+\\<\nM/]QFC986W;NLI+#Y^GFS-_W[QFU0\\0\\D\\0W5`"6@Z^M`^OW`3!LP>3)06`QD\nM90-6`7`(@%,"/%;`;04"@T!S"-B^&X@PBLQB8F@RV&]>&?U4]WPA05B'9[:5\nMO9!O%2\\(E,_%9V%6L_JC=5<Z):'SK93RK_>5\\JMX;P)!2,/4"HG]6;0[)_]-\nM*$!#9_\\33W4/WG(:!_T;:R5.%CZ.`&>Z^'W[T^3N3FH)C;>;V@I-VB8`!B7_\nM@M^)1\\-]$QQ(,&J:[Z!G^?1TUR]JDXU+1+#E(^_`_O_A_P`7+.T"(LFS_@``\n*``!)14Y$KD)@@FJ:\n`\nend\n
105951
 
6560    bank_ok_48              begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```.L$E$051H@>V9:9!=Q77'?Z>[[[UOWKS9I-$,6D;2:$<6\nM%@*,S)8@`S(V14`)D!C;96>Q*\\1+C.,-$L<"8U,&%P456\\$FJ00GA%398`=#\nM0,8+8,PB@T%B)(0D&&VC&69?WG:W[GRX;V8D&8LJ$/:'N*NZ;M_;,Z?/__S/\nM.7VZ'_R^_;[]_V[R5@E^V3D$6AT4<K"WZAR+E3KNZQQWB3L3R\\XX)4[LO,2Z\nM34GJ[AT)TS,3ZWBAFASOY8XO@!<C1QBG1(E;DCKN&!F++N\\=**^)+?\\^6K+K\nM3\\I]A"=&HN.YY/%SH6=+,5AP\\':MY9N#0Y6S[_IN%Q/%F#_^HQ4L7-A\\((SM\nMU>-5=V^]+^Z"]MQQ6?>X`'AR+,9:BXB<H95LZNF=./F>^W:R<MDL.N8V\\..?\nM[^,=I\\YAV;+6@3AQ7ZC&]CM&2W+I_/HWO?:;!O"S@9"6UI#1H>`"I>0;W7M'\nMECW\\LV[.>L=<WGW*;+3`L_LFN/^1;CH7-K-R9?M8:MW&:F0W:271^Y<U_.X`\nM;.ZM8*T3;62#$KEUYZ[!CE\\]W\\<%9RW@G4N:T4!L'=447AJHL/F)_30U!*Q\\\nM6WO9B=P4Q>YF$<H?7=7TVP=P_\\$RUCJMM'P0^-J.'0-M^PZ.\\9ZSYG/B"?4X\nMZXA31VPALHXH=1P8BWGLN5ZPEA4KVR.EU3?#V%XG(F-7G]KRVP/PO;TE',XW\nM(E>EUFW<OJ._N52*N7#M7#J:?*+$48PMI<A2CAU1:HDM..<8#RW;]@Q3*84L\nM7MJ:&L_<&27V"R(,_/T9K6\\]@+OW3.`@KY5\\)H[3S[VT:ZC>-XIS3VHCT,*K\nMI83^<LIH-:6:9)9/4H=U&0`M@@->'2@1%JO,G]_LO,#<$R7N:J4X:"W<N*[M\nMK0%PY\\YQP#4JI;X4ALG'NO>.!C,:`E9T-#)<23E43"A%EL0Z4@O6.E*7C5/K\nM:CT;.Z!<BDG*5>:<4,#/>9OCU'U"";NM%6Z[L/WX`KBC:PP'K4JX,8R2#Q_J\nM*YG&>I^&0L!@*:$<9\\K:264=1R@\\-7;38VL=493BPHCVF77X.>\\7<6H_IH2M\nM#L4=%\\]^\\P`V;1_%QH`P3\\$M893\\2=]@13FMT%I1CE+2U)):1Y+:J7&:6A)K\nM2=,,C'5RU#,;6R>DUJ&LI:TY1Y`S6Y/4_8UOY(DP<=Q]><<;!_!D9'GL5R/4\nMU7E+;&K_*;7VPM'Q*E$8(FD$<0A)B"01DH38."2.0I*P2A*%)%&5-(Y!>RC/\nM1TP.,0&8`&=\\0GPBR7J(AU,^N?H\\B.Q.K'S\\^U?.^]&&[XWP@\\M^<X82@-:K\nMOH/1*AB:J-3%B<UFG(-J8M>?TK9T^9(%M_I![NS4.JQU"%D1)9(]E4Q;PCF'\nM=;6@M0Y7L[9CTNJ9Z-1E`1XECB@E&Z=9ZK5`DJ0')D:'_V[[@;X?&6.F#)WS\nM#(UU7ME!=.#6*S$`B]L;*87)AO4GS?U<4]YWN$PYYW#.INVV4IE7J51Q2#:!\nM`E&(*%"UITAM7@&U\\932-2#69N_69@%N'39-4=;BN13M4G)B<=;BE.V8.3/W\nMK<5MB_;65$%$&)RHRM[!B>L5\\@,@`U`*$Z(D;>L9*:\\9+4<$GJ$N"`B"'$%=\nM';[O8SP/SWCXGL;3"L\\H/"TH!48+6@FB!"6@E&3JB^#<=$#'Z72/$D><6*J)\nM(XPM86*I1I8X28CBA#B*L$G8DL1ABTLBG(T09TFM!9@YR8@!&"N'@#SQ8L_(\nMM:(4YYZZ]/*JU*WIKSC\\4FET(+;_K$PR)ZX.?"#M>TD7.I;A^0$-.<W:96V4\nM0L%&(97B&(,A>%JA-6B1C#"$U$)G>P.SFNO9/QA!=8(]_46JJ2:V4.KM)L*0\nMFS7_\\4*^\\,"BCH;WCY3B54,C)=*)P<'=`^&WDS@<3Y-0!)[)$G$-P(';W@_P\nMS#.E])E3\\TI^V%-9L75_94WWH0ERQ;'Q5[I^^8WBS!5K7%R]<F+KD[I``Q+D\nM:<I[G+-R%GT3CM)(B=Z>'K8..912*)&LU\\8.T$IH+.0Y-!*1*XVQ<^\\0H0H0\nM48R_V`5^GKPK;-EY[8E?N[^G?-KS^RNK/)?B"</;7MC[#2NZ]]`=5QT1Q$<<\nM:"8#V%HGD\\'H'#@19+(;'U$J&T^'+M:!B&"4PC>:P#/D`H^<7WL&'IY1M;C(\nM[.=[FIQO"'R#'P0$@4_@F<-B!U(K--;EO)O^]-S.GEL^LG#TX&B]<XZ[;[U[\nMFH'?U)P[X@T01.M?_SLR'Q<1C%%XGL$HE5E?92S@0*M)`)ELHS7B>2""Y_G@\nM^7@U`,Y!6]YCY?)ZZFS/O/[QKGOO>N&Y:'G;BI>6CBR]_;1UI]VW_^7]\\;$!\nM3*E=&P"B#*^U?236H43PC<$S!JVRC4XI08D"`5T#;VN![1F#\\0Q.!,_W$<_#\nMKP%8U!BH678___WD-]G>N]T+3*X]\\PK;<=F:RTZ_9.4EU]SW+_?=?DP`UAWU\nM04"TJ07FKP,0$3RC\\8S&:(6NL:!5!L#H:0:L<WA&@V=`!+\\&P&CMXO'2*<7!\nMKI-O_?'7Z9@QG[\\X\\R\\9*@WQZ*Y'>737HVS;OZUQP8P%_W#%7UVQ[75<R!WE\nM1H`^C`&A%@=93@<P1D^YD#X,A`"Z!B#;R,`S&O$,CHP!C,_B&;GYNT9?^?KM\nMCVWJ?-O<5<QMGLN#70_R\\(L/TS_63TM]"Q\\X^P/)O*9YST^4)T:/S<"O?9&:\nM"V40)BT[:56IN9!O-%HKC-)3;B3(5`PXLD+.:(7V,H/XOH_V?-Y[8N&B?WMZ\nM4Y#W\\R1IPJ9'-K'MX#;2)&55QRJN>?<U`^N7K;_%5,VWFF<UCQP3P)3?'\\V`\nM@%(J"\\*I'3>+`>,9M#%3RAM="V;)@G92L"-CP/,\\'&`\\GU/GMU`J/Y;?UMM%\nM1TL'=SYU)P>&#@!P_JKSV?C>C=M/;C_Y<]L>W?906V>;;9G;<NPL]%I-E$%$\nM307I-#K!QE7&GK^'V05'4%_`KRO@YPN87`$U8SZ>:3K"*,K7F$#C'#0W%CAM\nM@>4_7_@/G'$\\N/M!7BV_B@H4&TZZE(WON>[QSD+GQ^N;ZK?6M=>QY.U+@-=)\nMHT<1`9*ET<SZ&0B9GB*.0A:,;^'/EL\\@,4WD`@\\=^"QL\\]G;-I-NW]1D93NT\nM]@2=4Z2)X_15BSF4?I^7QG91BDH,I\\.8O&'#RDOYQ#LW'AH;;?SD8\\.C6\\<>\nM^"'O^^#[IG0[)H#7RC;*>%/*Z]J&A@,E@E8:O]!`GUF#GK..1[;WT56*^$QA\nMB,Z<H(W`9#6K!.TK3*`)?'A;1\\IMO_@?ANTP(2&Z3G->Y[NXZIU?X:=;)XJW\nMW??COL#W.73'7Q^ISS$!')7O!5#:RWRZ%IQ3@@1$:7+Y>N)4^.Z6$1[NAX$3\nMVNFW&FL=VE-3AM$B:$^A`D7GS!ROEAYGV]@+I'Z*U`EK%IS,I\\ZZD9^\\7.#`\nM:)E"8%"O8=%C,J!DF@5'EF64\\6K6G\\XJ`$8)J5;4%1KPW`C8?9RVN`'5KJBS\nM1=(T1;34Y(!2H'R%E],L;T[XWHX?DO@I6C2S@EE<<_9&>HH+Z1X=I""2I?/7\nM\\(C7=2$YXEW0IL:`U-)C#:&NE0S*SW/QLG[>M:"/8B6F7$VI;^J@KOELZILU\nM@PA&U0H]3]'6$.!)%\\]//$=0"%"B^.C*CR0+FLZ)GNTMY8V:K&B/WI!J1GX]\nM!@[_UTD&I@J[27HD8T`IC=4^XV-C%$<&J!8GF+W\\#TC6G,-3$T_Q])[;J#=;\nM6+\\H3V`4>,*2)L.>XE.,FR(JKSAW_KE<-O_RGQXHI4\\=KL-OU/&8#"!,<B"3\nM`+0YHER>G%.UO<'J@('A(D-C(;-/NX)?M>385>UC2>LR.EL6\\73_(]0W/LVI\nM'05\\3S,W*//4^..HO**]N9T_7_SA5UM=ZU<C9'!2[K$P&("95_\\O6HN<<<5=\nM^J*U<^1#'SI#TJD['4<8B4FMTTH)3ALL8,G*[<DK$^<<3H18!?0.5ZA&,8U#\nMXY3;+,\\-/\\<OA[?04^VAN=#,4/\\@E\\Z9S8G)0J)D-WO2E_'J/2Z=O8'.W-J'\nMKOO!\\UO6KCOYD[8F-W5.8HSI;5RM%OSC3\\!A]WWYO&D`[3/JL,Z=\\_:+EGU*\nM^5H]],N]IT2I4*HF%&/=NN2DU=]*G#1%J=7BLBU?:XT'='6/4(XAC1TV:*;2\nMOI:GHP[2).'9;H^S6D]G7>=LOK9U(P?C'G)1CEG)+#I:%G))^R=Y:'P+1;_(\nMXOPBSLE?RI<?W'_FC@'W7Z_\\;-?IL17*U107N=ES%BW_]LRT4BU%[G:$S4<R\nM4.\\3)7;>!2MF73*G.:?LY,4$X)"\\0RY$I'9XSP[M(M,I:CHFP,D"+&NF;AYB\nM:YF?>S=?.:.%FW=^B9>35QA38_QH?#,7S7DO+R3/H>L-%\\V\\F+Z#)Y#:@:5+\nM3VA>FJ0)RJ7X@0,_5V@I<.%`,:(4538?GDT-P&`QQ#JXOZN?.D_A&4W.]_"-\nMA^][&.VAC<F^>X[`4^0\\(3`*WPB>`5^#;Q1&"Y[*#OL.(;6*_6'"W/JU7+?F\nM%F[J_B(OQ;OHDSYNZ+^!O>QE4=-"5LMZ_G5WR+ZB(4D@35*2Q)(F,=8F"(XD\nMJWC=X16R`:AD1TEW8*1LM1)\\XY$++'4!Y`(AYROJ`DU#SJ&T(R"[B<CYBD*@\nMJ/<5^5K/^8HZ(QD8E97-4>*HQI8F;S5?7':C?/70%V4/>]AA=Z#K%.L:SF/B\nMT!SK^Q/,;LI1#F.JD5`)H0I4PI0P3DBM$X[*IV8RBP"_0.1*0-Q4@%J2VH63\nM2BQ>(IA8,-JB8D&4G?0HG&3E=P(D5O#2K#IUSA%;1Y@X^DJA6U6_O/73LS_]\nMV9O';^[L,3VTYF9QIC[[0-=@?$,QM".5V$HUL41)MG9B+?;(0\\FSQTA*;VW[\nM^4]_GOU&,#B^X8'1!P;6]:YSGQW_K.N?Z-]T[3G7JLV;-[^^D-]U>_R1Q_G\\\nM>9^7L=&QO[UK_*[P_N+]Q?'^\\?/+I?(;DO>6_5)_K+;KQ5VXDLNW+F_=I)1:\nMU+N[]^)8XK'5JU?_+M1Y8ZVOIX_N/=V+]G7O^T.`ZZ^__@W)^3]Q%"?97MC*\n-YP````!)14Y$KD)@@M1Y\n`\nend\n
105952
 
6561    bank_write_48           begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```.#$E$051H@>V9>XQ?1W7'/V=F[KV_?=F[7GO77GMMQTF,\nM8_)R#"0A@`(B(51`&VBJRM`6I#Z@T-*T"*54+2\\)E+9J04`*H:T*+4)M@400\nM6CDT"="01&F>QO$C=N+U<S?^K7?WM_M[W,<\\^L>]N^M'&B/BT#_@2*,[]\\[N\nMS/F><[YGSLP/?B&_D)]OD9=JXF="0&!Y@-X:C*4A<+Y2YWR=<S[C'NO94S@*\nMZ]=8'VZS+GQK.G.OMC[PX]2>Z^7.+8#=>2`K'+D-%[C`EZ<;^4WC]?:6PO-/\nM,RU__26UW^&!Z?Q<+GGN0NC15@$>`ERJM7QA\\D3G-5_[]YW,-0O>_K9-K%_?\nM?S@K_,VS:?A63RSANN':.5GWG`!XL%'@O4=$KM9*;CLZ/G?Y-[^]A\\T;5S"Z\nMNH__^N^#O'+K"!LW+J\\7-MR2%OZK1HO]E;4]+WKM%PW@OGK&P/*,F1/)=4K)\nMYP^,36_\\WGT'N.:5JWG3%:O0`H\\>G..N[Q_@O/7];-X\\W'`^?"S-_6U:2?[.\nMC7W_?P"VCW?P/H@V<J,2^<R>IR=''WMB@NNN6<=5%_2C@<('4@=[ZQVV/W"(\nMI7T)FU\\^W`XB?YD7X:]$:/_NQ4M_]@#N.M+&^Z"5EM\\`;MVUJSYT\\$B#-U^S\nMEHM6]A!\\H'"!PD/N`[D+'&X4_/#Q<?">39N'<Z75%[+"?UQ$&C=O'?C9`?C&\nM6(M`B(W(^YP/'WMJU_'^5JO@ABM7,[HT)K>!9N%IY9YV$<B=I_`00F`V\\^S8\nM/T6GE7'^A<N=B<Q7<NMO$:'^9U<O?^D!?'W_'`&ZM9(/%87[\\-ZG3_3$1G'M\nM)4,D6GBN93G>=LRDCM26EK<NX$,)0(L0@.?J+;)FRMJU_2%*S#=S&VY6BB/>\nMPZ=?/_32`/C*GED@+%%*?33+[/L/C,TDR_H2-HTN8:KC.-:TM'*/]0'GP?N`\nM"V7?^5"ULA^`=JO`ME-&5O82UZ+MA0M_H(1]W@N?O6'XW`+X\\LX&`98KX=-9\nM;M]];*)EEO3$]/4F3+8L[:)4UL\\K&SA%X85^6.Q['\\AS1\\ARA@>[B&O1CPKG\nMWZ^$)P.*+[]UU8L'<-M3,_@"$-8H^)LLM^^8F.RHH!5:*]JYPSF/\\P'K_$+?\nM.8_U'N=*,#[(:<^R[X/@?$!YSU!_C:1FGK0N_'YLY(',!KY^T^A/#^#!W//#\nMQZ;IZHHN\\,Y_SGE_P\\QL2IYEB,NAR,!FB,T1F^&+C"+/L%F*S3-LGN**`G2$\nMBF+$U!"3@$D()B8C)I>R940$%5/KZ0:1?=;+!^[8MN;N&[\\QS9V_^G]G*`%8\nM_KZO8K1*3LQUN@KKRY$0(+7^^BN&+GS9!>L^$R>UUS@?\\#X@E$642/E4LFB)\nM$`(^5*3U@5!9.S!O]7)J%TJ"YS:0.\\J^*U.O!ZQUA^=FIO[DJ<,3=QMC%@Q=\nMBPQ+NJ)V@/SP9[9A`,X?7D(KLS=>?\\GJ#R_MC@.A5"X$0O!NV'<Z:SJ=E("4\nM`R@0A8@"53U%JG$%5/T%I2L@WI?OWI<$]P'O',I[HN#0P5$33_">H/SHX&#M\nM2^</;1BK5$%$F)Q+96QR[A,*N1,H`;0R2V[=T-'I]I:9=DX2&;J2A"2ID71U\nM$<<Q)HJ(3$0<:2*MB(PBTH)28+2@E2!*4`)*2:F^""$L$KIPBRVW@<)Z4AO(\nM"D]F/6GN*:PE+RQ%GN-M-F"+;"#8G.!S)'B<]P"#\\QXQ`(UV!L@#NX].?T24\nMXMJM%]Z42M>6XYU`W&K-U`O_=\\K8D2*MO\\M-[-6]HQN)XH2^FN;*C4.T,L'G\nM&9UF@\\D,(JW0&K1(Z3`$Y^&\\X3Y6]/=P:#*'=([]QYND3E-X:(T?(,=06['V\nM_M[NWN]N&.U[YW2KN/C$=`LW-SFYKY[=;HMLUME,!!XI$W$%X/!GWPGPR",M\nM]\\C6;B7?.=K9].2ASI8#Q^:H-1NSS^[\\G\\\\W!S=M"46Z;>[)!W4O?4C2S=+N\nMB-=N7L'$7*`UW6+\\Z%&>/!%02J%$RE;U`Z"5L*2WFV/3.;56@SUC)\\A4@HAB\nM=O=.B+OI#KT/[_G(1;?>=;3]BB<.=2Z.@B-6,K5SY]CGO9CQ([>_]Q02FY-?\nM2@(KO`\\R3\\80((@@4L:_F!A1"A%!%JF+#R`B&"48H]&J3+/S(`(0&57QHK1?\nM'&E$&Q!%G"1(')-$9H$[(9Q$_#)MG)&%S!E?3I(03GD#!-'ZS+^CC'$1P1A%\nM%!F,4J7U50F``%K-`RCG-EHC400B1%$,44P4G:J2#X(N\\MHG&_?\\]C533_3J\nMB^4[YUVUZOY;OWN,6\\;/!F!![:H#B#+/:PGK`TJ$V!@B8Q8]H`0E"@1T!=Y7\nMQ(Z,P42&($(4QT@4+7B@%$4SS5DU^<CJE_?D'QT\\\\)QV$D9ON?/8@Y?UX.`L\nM`'PX[8.`:%,1\\TP`(D)D-)'1&*W0E1>T*@$8O>@!'P*1T1`9$"&N`,21KI;2\nM6)YC;[J7!WJ6ZEW3'=XTXQJ;4_[E#<MPC?WENF<)H7!:&`'Z)`\\(%0_*G`Y@\nMC%X((7T2"`%T!:#<R"`R&HD,@<H#)B8VI4IS_A!VY3^S=>@I]NS:P(.]KV5[\nM]Z79LFM?MV;#SD9\\;%DGYZ'WGL4#9WR1*H1*"/.6G;>J5"$4&XW6"J/T0A@)\nMLL"!0%G(&:W046F0N`(0189M=UX;Q6M7]<5+)YEK-7G]VO.X]J9T^DM%UT,;\nM];+WM(NQ;YN"B;-Z8"'N3_>`@%*J).'"CEMRP$0&;<R"\\D979):2M/,3EUE)\nM$T51F9'B&#$1-5/SWWCV!U>/N,%7==42EOHA+EW2[^_;L>?>[LFWZ73RV%]O\nM^^(')SY\\U6]Q=@#/(Z(,(FJ!I(OH!%^D-)[X)JMZ`TE/+W%7+W%W+Z;6BUJV\nMEL@L/<4H*M:81!,"1$F,Z`2QMIMGKW_WH7Q'_T"4<OFJ"[G_Z?'I^[_W:MM7\nM]W?XW5^YXU-O_C&9_>I/#F"!!E*FT=+Z)0A9'*+(,];-/LROOVP9UBREED3H\nM)&;]4,S8T"`'8E/-5>[0.A)TK4RQ42U"Q#!VH''#BK6?6K[LR`](#SW*[LM6\nMTVQ>3;#%OTWM_L0=CPV^*Q3U/UW0[04!/%^V429:4%Y7&QH!E`A::>+>/B;,\nM%O3(Z_G^4Q/L;.5\\J/<$Y]4$;03FJUDEZ%@M>J`KYKFQ#KN2X0V1@TM;6VFJ\nM$=)X$TOS^HE5+WOZ07?1'X9C__![I^CSP@!.R_<"*!V5,5V1<P&8@"A-K;N'\nMP@G?>GB:)UI@SA_FN)]AG0_H2$'F2NN+H".%J2F"AZ*(V=%6Y+V&UXS7N7"Y\nMQ[]A"],J(>F?Y9XGRT+Q#(.^$``EBUX(E4N4B2KK+V85`*,$I15=O7U$81K\\\nM05YQ?HLKAAMTT\\9[CZK*>A%0"E2L,#6-*RR[ZMW,KASADO$I-A0S,\\.7#HX/\nM;UB.,5#K>?[-\\^P>D%/_3430IO*`5.FQ0JBKDD'%W;QUXW'>L&Z"9L?23BUY\nM(R=?OP%M%)[Y<"L]H(SPU(X&SW3UL/KH#%O=7''TP,&_O?Z/K[I\\Y['\\1K40\nMQZ=O2#\\!`'6R]2L`8J+R*8O*(Y4'E,;KF-E&@TXG8ZZ5T6RG--L9?;9`&ZD`\nM5"!BQ=BN&1Y/(VJ3+:[)YYAMU+<?J1_\\G(G,[9`_;]B<HN,+#98<D'D=$1&4\nM-J>4R_-CJMH;O$ZH3S<Y/M6D/C57/5LX:Q=V8EV%T.3!)@\\<<F0MRQ7U*7IZ\nM"GCCIJ<?>^B3,R$$F3?B"V%0`(,W_P=#'_I/N?K7OF;>\\M'OF;SPXA;N=`)9\nM+L;YH`,0M,$#GK+<GK\\R"2$01"A4PL2)#N-3+<:GVDQ,M9F8;I/ECD!YR16`\nM=-;QT*Z,$UXSNGN"]4F+[++E#%PRHCYX^X],X8+X:EX7@A08<V3)96K=7]RC\nMUOWY/2<9&=C\\R?OP(;QN37_MC[IBK5;T=U^1.QEMI18I.NUV$7YH@RS-G;]2\nM@E<Z2M!:DT2&E0/=M`MPA<7;')7/,)`?PSF'=1YK'=9Z!LZ[&#^PBJ)CF9S.\nMV/U,DWTK5M#]R%&NU[,T1T!=-(S-_?Y6H[-S]?*>5Q5>1MJI(^2=YDSJ[L]<\nM2%NY^R*P_<`GW@A4'!CLB<FM7W/=IA6_/-)?4W[^8@((2'=`;D"D.KR7!XOY\nM`\\X"-ZKC8Y!U>+8L'$9LY:7".@KKL3V>R8,ISPP.HO>=X$H[1S*:L.SR4;P$\nM7&0O<+7D`NLL*CCB)$!<ZQWHY89Z,Z>5=[:?O#\\9@,EFA@]PU\\[C=$6*R&AJ\nM<41L(N(XPN@(;4SY/0HDD:(6"8E1Q$:(#,0:8J,P6HA4>=@O#SI2'N(=:*O8\nML6.:>_.(T.APY<P,PR.:8M,H4R&AW;&DA5`4X"K/.5O@O44(V++B#2=7R`:@\nM4]X%A</3;:^5$)N(6N+I2J"6"+58T95H^FH!I0,)Y4U$+5;T)HJ>6-%=M5JL\nMZ#)2@E%EV5RX0&8#SQYLRKT33II!\\<KZ-!</^S#XZO4A&NIGKF.92S5SJ:.=\nM*=)<Z&20`IW,D146YX-P6CXU"T2`'R&R#9"P0%"/K2Z<E/5$5C"%8+1'%8(H\nM/Q]1!"G+;PM8+T2NK$Y#"!0^X(*$W8\\__IL#SK]EPQ[/>IO6G\\/>NG+5P,%6\nMVZIV[ND494NM)[?EVM9[_*F'DD=/?GG)?B<^6;:]YP-HI<R*E2/_FL3QVV>F\nMW-%[[S[T\\;V[]_]C'"<NS^_\\J><^][\\\\/X^D:4:SU5G6G&MN<$5VMU'U=^S=\nM_[F_?^,O'7]1R@.<><7P$DC]^#B'#CP]4.3%N"AS:W=O_[Z'[_\\^S^X;_UDL\n=?\\Y$\\Q(8['\\!(!11!+FE,7X`````245.1*Y"8()S\n`\nend\n
105953
 
6562    barcode_back_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```)[TE$051H@>V9:VQ<Y9G'?^^YSID9VY/!27R+:SO@I@T)\nMQED"N#0LBMI*J.E%%2A+Q3?02H6J$E6E+EJ!:,4*NMO=_;!(?("*$K*TVZTJ\nM&JE0+FVZ60)QH&0=$IK$>+*NG7C&'GOFS)ES/^?=#\\;#)=M0M"3>#_E+,])Y\nMYSW/_']SWN>]/`.7=$F7=$FK*2&E!!@`A@"YJF[^?`E@"CBMO=-P&W`_$*^:\nMI8\\F#7@`^+L5`!TPWGE=$$DI<5T73=,P3?/C"*G#,LG[%$41GN>A*`IQ'#,W\nM-\\?P\\#"^[R.$X,"!`VS<N)'>WEXT36-\\?!S3--FP80.-1H.AH2$\\S\\,T36JU\nM&I5*A?[^?FJU&D\\]]11=75WLWKV;-$T)PY"77WZ9D9$1.CL[$4*PM+2$XSA(\nM*9F<G&3'CATM+T$04"P6W^?W'(!2J<3,S`QM;6UHFL;^_?L9&!C@\\.'##`T-\nM\\=)++Q$$`95*A<'!05Y]]54LRV)A88'IZ6EZ>WL9'Q]G>'B8UUY[C9,G3[)U\nMZU;R^3Q34U/8MHWKNAP[=HQ"H<#SSS]/H5#`MFTT36-Z>II2J41W=S?[]^]G\nM>'B8:K6*XSC8MLVN7;L00K3\\*A\\$",.0,`R)XY@T34G3%"DEON\\CI6S=[/L^\nM:9JV[DN2I-4_"(+6+Y:F::NOHB@((9!2MCY;B??![P000I`D";[OX_L^412=\nM,X[.`?A3>B_U^:[?V_[!/A="?S;`_U==`EAM70)8;5T"6&U=`EAMK3J`0""$\nM>'<E1WRD%?R<S=S%DD#@ASY5K\\J!HP=(E`1%4:C7ZA"`EEVV]F$P%QU`$0IS\nMU3F>&7^&0Z<.,;<XQ_%7CY//YI%"XH8N]6:=\\/<A1:/(U:>NILOJ^I,@%PU@\nMQ<`;TV^P[_O[R.?RW/KY6QG;,D9[OATO\\FBX#6INC3.+9WCKCV]QZ,0A[MES\nM#]</7<]7MGZ%G));/8`D33@R?X39:):[;[V;KW_AZZBJ2J5>H=*HT/`;.*&#\nM&[HD6D)?;Q_M:]HY=>84!X\\=Y-C<,>ZZX:YSGL0%3V(A!'$2\\]R1YZ@J51[]\nM[J/<^>4[J;MU)N<F.6N?92E8HA[5:<0-&HE-([&QDSI-'`K%#K9OW8YC.CQY\nM_$DFYR8O+H`B%,9/CO/T;Y[FH;L>XII/7T.I7&+>F<<.;1I1`R=NX"8.OG0)\nMI$>`1XA')'Q<V<`5#2Y;7^1H]2CW_MN]-+S&Q0$00E"I57AVXEENO_EVQK:,\nM42J7J'FUEGDW=G`3AZQEL7U@.[JA$"L^H7`YZT[SUN($QZL3_-&9`BOAF3>?\nMX2>'?@(L#\\L+F@.*4!A_>QS=U/G:35]C>F&:NE>GF31Q$Y<@\\0A2CV*NR*?;\nMKR2GYU`-L)TJ)^MO46F6\\0DQ+$%6F`A%T,#E\\8./<^WEUW*X=/CC!WBG4(80\nM@C`-.5T_S>XO[2:6,=5&E6;2Q$M=@M0GE#X]A1ZNL#:1VA(GVZ2>+C#E'B=0\nM&^3;,I@9C2"(T#0515E.X!/5X_S@^1^P]^#>#P=8,:2J*K!\\>)=2M@[H*X?^\nM]QI7516!H!$T2+2$39_81*5>P0YMFFF30'K$1&SLW,CZN!MGOHFNZ2111#D^\nMC99-*&3SQ$E"&$1XOH:B*"T_C<3G%[__>=&ZY3S3J)22OKX^QL;&,`R#D9$1\nM#,-@^_;MK;J095ELV;(%R[+HZ>FAN[L;3=,8'1TE#$(6F@M860M-UZBY-9S$\nMP4V;2#5A<]=FS&J6,XMGR>5R+"W56-M=9%?W;7AQ$Q#(5)*D*6DB<1*'/1./\nM,Q.?)0P38M^_POTAF?,"9#(9',?AZ-&C^+Y/$`1<=]UU3$U-,3P\\3*E4HE`H\nML&;-&F9G9^GIZ6'?OGT,#P^S?MUZ;-=&UW2\\T"-.8YS40='AJK57X;[M,UN9\nMPC`-YN?GL6V;PX?'45"(PI`PBHBBF#B.2>*8+]^^B_6%=53J%0Q#(\\RHG9G+\nM->L<`,,P,`P#3=/(Y7(((3AUZA2JJJ*J*H[C<.;,&<KE,J^\\\\@I""$S3)(HB\nM7-=E9F:&?#Y/3W</JJ:2I`FV9Q-K,8YLT-_6CVE;/+;G1^B&CA`"S_.P;9MR\nMN4R]7B<,PU:=20B!H1O<<//U&%D-3=?0]1A-5X5F:N<.H<'!0;J[NU%5E<7%\nM1:(H8L.&#32;39(DP;(L3-,D35.V;=M&M5K%LBS*Y3(='1WT]_?3T=%!\\;(B\nMFR[?A+??8ZFYA#0E3=%D8N8(8IWDQITW\\N`##S(S.]-:74='1QD=&5W.)P'O\nMO&%H.NO7=R&:`DU34!2!(A4GF4NC<P!T74?7=0`RF0P[=^[$,(Q6LBJ*0E]?\nM'XJBH"A**X&3)$'3-*(H0M.6PP[T#!"G,>5:&:O#PA5-8C7DM[,OL'G#9K[_\nMP^_QT'T/<^+D"73=X#OWWL.Z,8-F;)/&DB"(\\/V(*(AY6WN#I85Y5$5%5W4$\nMWHSWR]`][RRD*$JKDKPR"ZVTKVAE+[_29ACO%KB'>H<HMA4Y,GF$8E>1INK@\nM*PZ!TF2B.LY-`SMYX!_OXQ_N_R?^:V*"5(]Y4S^(K<V3)))FXM.0'G7?H]'P\nM<$(?2\\OB*RD#:X=.NW\\[D5[0A:RKV,6.D1T\\\\NPC*!4%VL!JTVGOL.CHR'&P\nM\\COB'I^_^?OO\\-C#3R`E>%Z,$P5("4&0$$62-($DEF@8Y/5V4E/C[NN_'?_[\nMQ$];.>`!=2#Y.`&$$-QRTRUB[W_LS=?"FDX$<9P21RE1&)-D#"867R<2/M_X\nMWAU\\8NT@Q^T7J(<N(`C#&,\\+\\;R`))(,MG^2R;,E_J+W6N]+5W[5_>S0C2V`\nM)X$7N`!_,5TU=)4DX4[@&\\2(.$J(HI@PC`F"$%U7.5'_`S^3C_&Y]B\\RO[2(\nMDW@@(8X3/#\\D#B0CEXWA-%UF%V=+(VNN^596SQ[*=F2Y\\.7CSP(1W11X@C8^\nM+]K`S!NTM67(YS/D<B;9K$DFHV&:!KJNH2C+)?@PBLBK'?QEW\\WX7LA/W_C7\nM1KD\\_\\V=#W[JQ_MNG6#I9P[JAQKXOTH#^G'P.8S*E2@,2$4N[X/%\\H*92DF:\nM2*(X(8PB@B!"30VVK?L,?[7I#LKU>9Y^?8]=6:C<YYV.'B^]N)`N_'AY2WWA\nMGP!`![`#\\!DDST,B+[Z::3?U]O8\\^:Q%UC+(9C)D,Q:=^4XV7G8%6]9=359K\nMX\\63S_'BB5__MUUOW!_-R;U*CKCR+W8K],4!6-$7`9]VVKF-''^=R6<V=Q;6\nMZ%UKUK&VHY,UV0+M5@=Q&G.F/LO4PJF%):?VJ]27_^P\\%Q_)C"IR:4_S?2$O\nM+@#`#<!_`KOH(L\\.,MRHF^HGC8Q>T'45(8AD(F>D3%\\7L7A1UL6$T$58>ZSY\nMOX:[^`#OU3;`1C!,5ND5IF8H"(\\T>CMM9J[6(G=O!)7SA_@?"A+W#7*P^=4`\n+````245.1*Y"8(),\n`\nend\n
105954
 
6563    barcode_ok_48           begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```'ODE$051H@>V96VP35QK'?V=F/&,[CC-U+K)S<8D)!J5`\nM4F`IL`N(4E5E6P1;MBKJ"P^M5*G[L`]556U?RK9J5BJM^H:V?:F0J"KM`T+;\nM"P4VW5`*1($-VA*@FP"Y8(<DQ([M.(ZO<_:AQ`N$6U&SR4-^DA]\\YISO_/]S\nMOIDSYQR89YYYYIE-A)028`$0`.2LJGEP!'`%Z--N%+P$O`WD9TW2ST,#_@RT\nM3!FP`?J-WXP@I2252J%I&H9A_!(A;?"3DUO(Y7),3DZB*`KY?)ZAH2&"P2#I\nM=!HA!,>/'V?APH74U-2@:1H='1T8AD%=71WCX^,$`@$F)R<Q#(-8+,;(R`A^\nMOY]8+,;^_?OQ>KWLW+D3R[+(9K.<.'&"YN9F*BHJ$$(P-C9&,IE$2LFE2Y?8\nML&%#44LFD\\'C\\=RB=YJ!WMY>0J$0I:6E:)I&6UL;"Q8LX/3ITP0"`5I;6\\ED\nM,HR,C%!?7T][>SL.AX/1T5$&!@:HJ:FAHZ.#8##(F3-GZ.[N9OGRY;A<+JY<\nMN4(BD2"52G'^_'E,T^3(D2.8IDDBD4#3-`8&!NCM[<7G\\]'6UD8P&"02B9!,\nM)DDD$FS=NA4A1%&O<KN!;#9+-ILEG\\]C61:692&E))U.(Z4L-DZGTUB656Q7\nM*!2*]3.93/&.6995K*LH"D((I)3%:U/Q;N\\30`A!H5`@G4Z33J?)Y7+3\\FB:\nM@;MQL^M[_;^Y_/8Z,\\$#&YBKS!N8;>8-S#;S!F:;>0.SS9PW<+_9?-K'W%SB\nMQF(+F\\U&J:L439TN=\\Z.@)02L\\S$Z7)2*"O0K_83=4?IB_05C<$<'0'+LE@8\nM6(A1:=#RSQ;.#Y[';K-C28M/3G["KK6[V-&\\H_R%QU\\0<\\Z`E!+#,,B69OGX\nMNX_Q>_R\\_.N7B4Q$.-9]C&/=Q^@*=5'EJOK]Y\\<__]N<,B"EI*JR"J54X<-_\nM?,C2FJ74F#4<ZCK$T8M'&8F/4.8LXY6-K]!0V=`_GAJ/S3D##4L:V/?W?3AM\nM3O*%/'O;]O)#Z`<*^0*-M8V\\M_T]GEO^')JB?0-TS2D#`L&ABX?HNM9%G:>.\nM?>W[N!JY"L"3CSW)^]O?9V7]REO:S)FWD*[K1+-1]OUK'](F.=1SB'`JC&(H\nM/+_J>?;\\=@^35R=O>0/!#!BXO8,'P;(L'O4_2N=X)]WQ;B[&+Q(M1-&<&CM^\nMM8.6+2U,#$\\P-#(TK>U]4VA*D*JJP$^+=REE<8$^M>B?JB>$0%75.\\Z@-YN;\nMBF=9%@)!6DUSL/<@42M*A@RJ0V5S_6;>W?0NR<$DR8GD'6/>U8"4DMK:6M:M\nM6X>NZS0W-Z/K.JM7KR[N"SD<#I8M6X;#X:"ZNAJ?SX>F::Q8L8),)G-+/-,T\nM<;O=5%55H6D:C8V-*(K"JE6K\\-?Y.=IWE'/Q<Q3T`L(F:/(TT?)4"]6.:LZF\nMSM[UD^*N*22EQ&ZWDTPF.7?N'#T]/71V=K)FS1I&1T<I*2FAO[\\?TS3Q>KV$\nMPV%<+A=??/$%@X.#*(I2O.-3VS*!^@!KUZZEM;654"A$(I&@MJ86C\\_#P;Z#\nM%(P"JE/%Z_&R>\\-NXCUQNGNZ492[9_JT$=!U'5W7T32-DI(2A!#T]/2@JBJJ\nMJI),)AD<'&1X>)A3ITXAA,`P#'*Y'*E4BE`HA,OEPNOUHNLZJJIBFB:E[E*"\nM2X)4E%<P.CI*.!S&-$W&HF-<B%W@[/A9#)>!(A1>?>Q5UE6NH_7?K;C=;MQN\nM-_E\\_H[[0M,,U-?7X_/Y4%65:#1*+I>CKJZ.B8D)"H4"#H<#PS"P+(N5*U<2\nMB41P.!P,#P]35E:&W^^GK*P,C\\?#^M^L9_&2Q43T"-^.?DO"G@`5%@06$(O$\nML"P+7[6/D]&3)+4DBJ:PL7(C+_I?)#00PC`,_'X_?K^?7"Y'-IN=EDK3#-AL\nM-FPV&P!VNYW-FS>CZWKQ8544A=K:6A1%*::)E))"H8"F:>1R.31-0U$4W(^X\nM^?KJUTPF)UE4L8BQW!C?#7_'$]XG>&;M,P@$58]6\\='9CU"<"N5Z.:\\M>8T:\nMLP;+;;$HN*CXL-ML-IQ.Y_U'X&8412GN)$\\%FBJ?0@B!$*)8INO_V^`6"+)6\nMEM/#ISDS=H9P.HSI,KD^=)U%GD4TN!KHF>SA<N$RMA(;V[W;6>-9,ZV/>S&C\nM,[&JJ.QZ?!?EE\\MY^_3;A/-A[%D[E?E*`L,!7G>]3L=$!TD]2;VCGI>J7T(5\nMZOT#W\\24@4D@#A1^<1-"95O#-DRG:=]];K?S<OXR<27.-_%OV)+:0F>V$ZU$\nM8VO%5MG@:$@\\H`;UAN;B$9,7\\#%S1TQ6-I5=V!YO_\\N>@3V+?\\S]B+W$SK)'\nMEM%''^5Z.2UE+1>6JDO_(.QBC)^.D.Z%`*X!TZ?FF>#3OWZ*E)+X<'SCB>LG\nM_K.M:YML[&J439>;Y(K!%?*#Q`=R+#;V)RDE!PX<^+]H^MD<^>K(E(E-;9&V\nM*\\_V/BN;KS;+IZ-/R_94>V^L+Q8<#`_.MLQ[<_S;XT@I28PF?O=5[*OKFZYM\nMDF\\DWI`CXR-[WUK_EG+X\\.'9EGA_OF_[GC<WORGBL?@?/TM\\EODR^64R,9)X\nM*C61>JAX,W^$<@>Z+W8C)Z2S8G'%7D51`M=ZKFW-B5R\\J:EI-N0\\'$/A(7HO\nC]0;Z>_LW`KSSSCL/%>>_SCA<3)0^(-H`````245.1*Y"8()I\n`\nend\n
105955
 
6564    book_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```+D4E$051H@>V9:XPDUU7'?_=1[^[I><^L[=CKS2Z[7CN)\nMUWDL3D)X*";&4A`0`G*T&,=.D(%`$"`$4HBP<)`2/E@*^4"P`\\:1@TC,(QCY\nM"\\@FQ,0"8[*VX\\!Z7S.SN[/S[NZ9[GI773Y4]T[/[,.[-GS;(QW=*E6IZO^[\nMYYYS;]V"JW;5KMI5NVIOPL3_W:,>`#:`FS4,NTC+PY)#0HF&$(R9THR;TDQ2\nMFAT8CB%X'$C)/OFFWJI?_Q87B(&?U+#'@3$?_#K";6C7&O4"/6&[>L)RY)14\nM<@HA)DICQHK"C!:EJ:=964O3TLNRTJ8T$@,8TT$(P9#_*)V_-+1^\\0T#"/@#\nM(`#:#5"C(!I26J.UFC\\Q/.Q/U.ON9+WN3@6!,^'[UKCK62.VK1O*EC4AA5>`\nME16H)"^)DI).F+.VGK+6SM@(<Y*TI"@-F-X;C8'J?`DI/DE6_`.VAC-WOU&`\nMAP'1@,Z7H7C?77?]@'_''6_U;%L[06!+I11E"5EFB.*2,"[H1`4;84XGJHZ[\nM24&KD[.XEK#43.E$.;D!A#A_D)H>1&'`F&-(<0_&/(^0</1GKQA`:[^.M-3!\nMR4;MPV?/+/KS\\R$'#DS3[>8L+L9L;&2$84$8ET1)0909HJPDSDKBW-#JYIQ:\nMBCFSFM!-2HP0X%H@1>5]`,%F%/H1*<K=&+Z(Y!"((^S]!ASYZ!4!J(-O.T1S\nMR+__@^^_]L=,5O#RRXLTFSGO?O<.EI=C.IV"*-T4'.>&I#"$N6%F*>9[LQWF\nMVQFID.!H<!4X"EQ=G3NJ:FV]V=JJ<DN!I:Y!R;=BJV?P[0ZGGK@R@-/['K"]\nM$?M7=DYY^_9>WV#V9)-77FDR,N*S:]<PRZL)<5H2Y88H-\\2%H1V7O'2BPY$S\nM(9$1/>';!&]O^Z*=`?&V!EN")?>@Y!BV>I9=]R2<^.KE`_`CG_*$)>_S)#NG\nMAVPF&C:OO;;"D2-=]NX;Q?4U:^O9N=YO1P4O'MU@;B7!V`,]W1=W09C^<1]@\nM`,B6%8R6MZ"EPE+/L??>@M<>NTR`#_^6S$OS,TE<[/&,X<;I@")).7:LS>F%\nMC)O?/D8W*>G$!6%F^-Y,E]GE9$!87[R^@*MJ2-D#T1B,0M^U!"TE6KX3+5JX\nM^@7VWV=X]<\\O`R"Y,^>6J8-16A[,NQEU#7NN&V)AOLG,Z9BH$-RPLTXKS#G;\nM3/GON2Z%EINB!L6[`SWMZ@M$Y$)Y(/NY`%I82'$0P4D\\_2HWW0>O?.5U`'[C\nM(?`M'RE_JKN>*A/E3-8LKAMW.7%BE5,K!6Y@46\\X'#T3LMS)-X=!?QP/]JAS\nM`>'N]FBI;8DL>U%0H*6'E`<Q',:6,[S]$W#XT4L`?.1WP+=6D.(#96'>LMY,\nM4%G!C5,^#CDSI]=9[$"M8;/6+6C'Y4`2*G#D^>+MP2&T;3@-WF,/B+<D:`%*\nM@A0-!+<AQ+]AJR7><3]\\]\\(0BI__75A/P@I"_D21%&YK+<$WL._Z(5J++19;\nM&>VL>E$W9S/L@R#VMBALR8MM$=E>C:Q>'B@)2E0NQ!2"?1B>Q5)M]MP/KSQR\nM'H#D%R:AX<)4_6GJ]B-,U^C675Y<2CD;&=Y[^_4,RX1V.Z;5R1&2W@S;\\_Z$\nMU7^Q&NC1OE!7@V=5'MA0=S:]9E<>#+AO@:?!T3^*);\\`8I11ZX(1D`#<.P4K\nMW9S`?IAA]]M,UVAY-M^9B\\@]E]MOFT)OK),F!::D6@J<9]N!>KVI>]'J@_@6\nM!-:F\\+I=G0?6IG"W!^MJL-1'4>*SE,;C4]^]"`!4X[.;G26P'F3<7V:ZQI+2\nM/'>\\RXZ=X^R_UH6-C4I\\?T'6=S/@#,`-1DD-@/C6IOA^[_<%NWJS]%8NT?(!\nME/AUXDSQRR]>!.#09/7`FR:>I>Y\\B:F@9#I@+H/_G`TY<.!:IH@AC*$`BK+R\nMLK<P*\\S`<0EE>3XDIHJ4%!6(9VV=I>V!?+`&7$L'(7X/K0[QU/?A$R\\,)/&@\nM_=T?P_M_U>#J5Q'<BF$W6<'J8L2(H]D]Y7+RV#*%[U4EKZH86_/@O.-M]XA>\nM9/H\\@Y`%V]H2\\A+R`DKC4IB#W#CV*IXZQMZ/P\\N/;@,`>.@A.-X)<?4)I+B3\nMP@R52<'*V9"]U]7QBX33BUT(O*W"I-B:W.><3=']/#&BBE2:0Y1`IPOK;6BO\nM(=NK6!NKN&$3+^W@EPDN);80B%+4BZQ\\%]WLWU%BGGWW7N23\\HDE^-@$_-G\\\nM;[(2?IZ9EN9$DYUES@=VN?S+MXXSI^LPUMBL[5Y__%I;5Z66`%V"R*`,4?D&\nM;M:DEJTS)'-JML)W71PW0'EU2KM.*GVZI4,W570B"+LE49B3=7.**(.X>)XT\nMOP>ECEW\\F_BQ1;!D@U;\\%RQT?IH33>1LB_=.VEQCI3S][3DZDU-0<WMU7H(-\nMPBY1.L>R,CPKH69G--R"$1=&`DTC<`@"'QT,$3H-5F3`<NFPEBG:*73B@CC*\nMR:(,PK3*N6X"48R,8V.Z863"J$NW_:?BQ;]_\\.(`+0-?7P!+WDHK_AM.MW=Q\nMO$ECK<N']@0L'5_D7U]K4^Z80OD*QP<O$/@UB1=8V+Z%]AR,8U-8#HFRB)0B\nM0A$"26DHBP+R'+(4T@21)-AI0E!DU$W.B(9Q3S-9=Y@:]@@</?NWW_S.I[__\nMTM$CPE(KQO%7+[TK\\5>K<'@>=H_]$JO1%YEI.9QLLM\\RO.<:F^>?.\\Z14*,F\nM1E">A7`UI:TH+54M^'2O3,@21($@QQ(YKBBHJY)A1S+F*2;K#M,-CQVC`>/#\nM`2,-GZ&:1^`[.(Z%UJI*)\\F3OL?=94&^;Z*2?NE=B;O'X/$E</03Y.:'F*X=\nM(LR86=C@+9'AEIMW,/M/QXBUH$@4PC8HV^`Z!M\\5U'Q%(]",UAW&&BX3PSYC\nMPP%C?9%UCYKOX'HVCJVQK$K4N2F%S2FGJEC,M=;)]6;QOXQME;LFX)N+77S]\nM.4:]=Q)F-X51QM&-E-IJ3I9F[+QF@QOV3#(\\Y#$\\Y-,8ZHD+7'S/QG4M'%MC\nM6QJM)5;/M58H+4$(C#$4Q:4'1%$:^9Z=@C]ZNGD%`.,"OKX&L^W_8=3['!/!\nME^FFP?Q\\">L9HWL]/GCG.Q@?;V!IU1.GMH@40O1ZLJQ*:,^JZBMZ%?C2XH6`\nMH\\WTAS_TY/SUKA)SYY[QN@``/S<*.VHP[#S)D/U5IFO$(QY)`_;?-L7P<!UC\nM#.;<&LGT2KY`R*JMYC.!D*(W18@MUU]'?[6I(3C@UZQ/+VP8S9^<N@(`@$,3\nML)XF!/87&/'^BZD:JEXR-N15`GLNSO7J-J'GO'=]`$3VKFWO\\7-K0ED!7%NW\nMF!QV/LZT=P?2P%/IY6PM#MB0`PL;)PFL/V0R>*S412/>B'MB-L6)WKD\\YYL@\nM<J!54J*51&N!4E7@BA*2K*2;EK3C@I6XX&R4<S8JF$\\*SG23$>+X,\\S,'.;T\nMS-DK`_C(,'QM!8:<?\\3(1\\J&]]L+<PN\\[5U[$$)N`:G*7M732LDJ>:VJ%0*R\nMK"0,<\\*HH-7)6&JES#=CYM=3%KLI*U%*.TT)\\S1/\\K1K\\F2-+%DDB\\^(*#IA\nM6JT`K:\\P`@`?&X?'EW(FAQ]F?.CVD__Q\\OM:R^M,7S^&4@JM)5HII!`464$G\nM3$G"G$X[I;4:L[H8L[P<L]I.6(L2UM.,L,R+A#PT,FLB\\B5$=@:3S5"D,^3)\nM+'%T6G0VEEA;:I*\\T(69HK_1=^4``,,>?..I>7;?\\&!3\\K47_OGP^`_^^`&2\nM,*';ZM)>W:"UTJ&U%K/>3NET<N*D+-+<1`;:*+.$8^:QRUFLXB2RF$&D9T21\nM+!"O-VG.=*^+G\\G.8I&3`5N^,K;8&_\\_\\)43<-^-DH.?_WU]=/FSKK1DEF<F\nM*XNHQ+018@6MSJ#4'%K,8#&#-J>$+A>PDS6<M8Z8_%9JDC',,R^]81EOZ@>'\nMV/\\9L-4$S?#73%;D:'D2+4X)+<YBL4J=#7-KDM*4AK]^^,V\\ZJI=M:MVU:[:\n8_X_]+]?7#U?>YEV.`````$E%3D2N0F""\n`\nend\n
105956
 
6565    cabinet_48              begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```+VDE$051H@=V:28]E1UJ&GX@XPYTR*VNTJVQ06VTW;2/$\nM(`3LD/H7L`"$0$)"]((M"R06O>DU&W:LV+#C%UBLD+"%&B%`W1B0VZZRVV6[\nM,K,JASN=(2*^"!81]]R;Y<YR559O(*6CB#/=\\[WQS6\\D_!__4Y?=^-N_?Q?`\nM$'DMQEC%&`DA$&,DADB,@1#C)><7YS'/-^^'D._]M'?R;^7G+/`%('_U_3__\nMJ7(6EP&((0)<!_XNA/!6C#%<)GR(6R$O$60[CUOAGP;XU#LZQO@1Q-\\%GEPF\nMYZ4`0@@`&G@UAG@OQ)"`$8EIDCY*W,[S0;Z^%7A'^'`1U`5M?!7TDHB^3,;G\nM`9"$B1'O/9]__I"N:\\DRY_L,@-B``Q0*E$HVJG;.U7!WYWQS?_N;&ZUN/_2B\nM`&1GQ6.DZWM^\\,_OL5S,F8PG**U12J'4[JA16J.UQAB#R7-M#,:8?%VCM1F>\nMT?G<:$U1%(PFTPL`XE4!2)!AOG'`$`)OO_TV?_2'?\\"XKO`2D'Q=)(\\A("(X\nM+SCGL-;1]Y:VZ^BZGMY:O//Y';EP]%W+>#I#@A`D;$WT2AH83"AK(004FO%X\nMS%MOOL'^;(IU#N\\$YWT2V'OZWM*T'<M5PW*YHNT\\UD>\\0,2@=8DI%'@A1%"!\nM;#H1I11&:YQSVXCW-2IX/A\\`)`10B@BT;8]6"NL\\W@O.>;J^9[Y8<S9?,%^L\nM:-L.ZQSB_;#"W@LB?AC%"WYG#")HH[,FY6?G`^3HH90"%%UO44H-@I^>+WER\nM<LYRO<99EX05&83WNV,6=C/?`/+>HQ"T-BDTO[P)20:P]0&E-*#H^Z3B^6+-\nMX>,3YHL5UEH.CPZ9S\\^3X)M5ED`(,OB0=Y:#@QO4]3@#VP(HC<)D#0PF=%4`\nM<B&,;LXU,<*JZ6G:EL/C$_J^1T2PUO+11S_FPP_^G>O7KW/[]FWNW+G#[/H^\nMG76TO:6S@>/'1X#BQ@V#<Q<!Z+K`:$.("?1+1:$+3APC)C;<G,Z9F6/F1S]D\nML5J!<Y0A8,3C?4555=Q^Y1YU78,J6*X:NL[2Y2ADK:-OUH2]:UAKOP*@+%3R\nM`=G1P,\\D#P3A[8-_Y7?^[!VJR2WJ^AQ%1"E2#HC"3^[_(XO5;W'WU7MXY_#>\nMXYS#>T=%A2E&B`BSV36,*>AZFTW-XT7PSC&JR^0#,87E%(%>T@="5$S5([YY\nM\\X@WOOW[Z&("@_`I`BH5J/I_X?7/[O/C_AV,5F`TQ`*M0+3&>XW6'JTTWOLA\nM^FPUX(AA])0/A)<WH1`U!^83PN$_<?_=?TL9F(A2&<0`QO.+]2UN[_]WKFL"\nMD0`Q)"VJF/4IQ"C$&#;Z'6JA>E1Q>^\\_N?VZXKU/?ATKQ=7S@&03"@"QIQJ_\nMP=[KO\\W>SW\\';2K$-43?$GQ'R.-,&KXI#<%WQ-`20Y>/AN#GB'U"<"?$L$X+\nMD((:2K.MB=3'5/$.[SWX%40T+V%".P"T</"-[W#C6[]'<_P?C._^)D5]'7%+\nMQ*T(=C6,P6^.)6)/\\>T9OOL,L<<0UB@MZ'(K]"X(%!@%IMM4I_(R``1C#+;K\nM^.1LQ0]^9+D=UK2GPOK]OV;ZRJ]ARBE16J+T1.D@KSBA0[I'N.8!P9^C\\"A3\nMH/0!VH#2"C8`%*"RD"J9YO%\\QFJ])C##:/U,,WJF!D:C,<='A_S#^X]Y_[_V\nM*-[]&Z+2J.!1^CU,4:&5&BI3/52H"MA#\\<O#/=@F1)'`T%^$C1^D?B`$021B\nM[6/J4<>-6Z\\BXEX<@$A`)/4!-V[>XGM_^1=,)Q-Z:['68JW#N718YU-!Y]P0\nMTYWW]-;1=AW-NF7=-+1=1]^G^)^</`[]1A(^F8T)`51'WS5#M7L%#0@2/"$&\nMC"DHC,$4!BT&;0S:"%HT2ANT">A@T#H0@F>U;CF?+UBL5G1=CQ<AQI0SRK*F\nMJD9I]3.`3:<F&4`0H34&V\\\\1\\4-(?T$`@2`"$;36+);+O*IY];W'.X\\3H>\\M\nM\\_F"QR=GS.<+NMX2`:,-IB@IJQ%&ZQUSVK9>0[.?*U"1!$"AF)_-$>=SR+T"\nM`)%4CVAM6*[6."]8ZW(B$MJVX_C)"4?')ZS6#1$HBI)Z-*8H"HJBR%V7P6BS\nMT\\6I"RL?8B!(!I`KUTTIX>79D>B9I81X(1)16K-:KW&Y_N^MY?#X,5]\\><BZ\nMZ>C[CJ9I*:N*HBB3X$613&^8&XPI4OMH#./QF/V]O:R!W)7M9&CODN.*R)`C\nM7EP#(9F00K%>-UCGF<^7?/J3AYR>S]'&,*I'S.=G+-=K;LVN)3OV`MZC<B?7\nM]QU]U]/W'=;V%&7-+_WJ;W#O[EUBC$.OX'VJG;SS=%V;[WFTOAS!,WMB$<EA\nM#I:K-<O5,0\\^_0QK'75=4Q8E15&BE,:8@KW]:TQ&%7O3$?NS*=?V9Q1&\\^3)\nM"4>'AQP>'7'XZ)"V60.1Z6Q&#!'G'=XYG"MPSJ"UHRS+!,!+JJNNI($<KV.,\nM/'SX.5\\>'A,C5'6=(U%B%>IZQ,F3QSQ\\\\.&6D3`%15%F-B+9OZYFO/:-M]"F\nM8&\\VHZIJ`(PS6*5!;?DE8S95Z55-2`)!)R?NNHZ/'WR"4IJR+'%.YV>2K8['\nM8]Y\\\\UN#K1?9_DUA*(J2JJJIZQ%E50WT2E$4G)^=HK4>`H;WVQXZABT3$L(5\nM3"BU@3+\\N%)0UP5%H2F-HC10Z(A1@E8AA4DL^(CXB,\\Q/8:00FE9458U9551\nMEA5%66&*$IT=FR%;I\\-[][(`PI`98XQ45<5T.F4VFS&=3IE.ITPFDW2,QXS'\nM8T:C$>/1B'I4,ZIKJKSB(:20&4),3BX!+V'(WM8Z>FOINS[Q1WV'4HH@,F3H\nM%P:0RFF/4H:R&K%>+3D].2%&,"8Y[89Q2RS<4^<;-LYH3&;BE-:I=LK?2(1!\nMN)#,O$\\1J&G6M&W#]=E-8O!7U8#%&,,KK_X<7=OPV:?WV=^?<O?>:X#:<:YM\nML394CG&'*<V];11!,M=S@13.)872FGH\\X^'GC_#.,9E=ARA7KT8W0BFE*:L1\nM157S"]]^A^_^Z9\\P'F5J403)YN"=QSJ'=0YG/=99NJZG;3N:-B6[KN]QSET@\nMM0:RR_>,)S,>/3K&.9<T(Y?705\\#0#:+-V1+12H#;MVXQOYL0N\\<SGFLM?0V\nMV7+7:6(,-$W+8KEBN5S3-"V]M;E:W1%:9`>()P9!*368U$4:_`4!;%K*5'!E\nMC>0.I.EZE&(H['KK:)J.L_,%)Z?GG"^6M&TWE-=)2U^E$L7+3A;V%`:,,?F;\nMESON<VK@XOY`R-1BC)&V[0B2:J*FZ7AR<L;1DU.6RW4RCV%E-X+[`<B65MQ>\nMDPQ`509C],XF25K`*P)XVH02.QTDL%HW]+WA]&S!EX>/F2^66.M8KI:T;9MK\nMFN03&])V4R9[[QB-)FAM!FI1<A-D3)5YH?A<M.)S:6`+(-'?(026RS6K=<.7\nMAX\\':M$YQ_T''W/_PP^8S:9<NW;`P<%U)I,)5D&($*/FY.R$Z:AE;_]@8.8D\nM4_-UUL"N"7T=A.=@YM@R!$HA$OCBT7%:]1Q-1/S`Z=?UB-$H);;QJ*:NRK3Z\nMWM)W%MNU5*;$YHV.#8OMG$,FJ<;:A%>>`\\)SA=&M!C0BPLGI>:I;+G#^GCNW\nM7^'@VD'JU)SE?-'A3U<#O1[$,YWL498U?:86=ZGW("$5<3P?K?A,`,,64V3H\nMG+36A!BPMK_`]6_X38VB-`4J*K12%*;8>6ZW8?%X;[<^(&'H?<W&!]B2RR^E\nM@6'#+42*HF`^7_#1A_\\#,.PT[LZ'LYRE2Z,HBQ(HM[OJ3[^3;]RX>9.R*M-G\nM=S+ZU0!<8*>3&6FC46B\\\\XS'8R:3$9/)F,EXG,;)F.EDLKTV'6.TH>\\M7=_O\nMC#U=GXJWKK?YO*=K.S[XT0]QUK)A=5]ZCVSP@1A`H)%`U_7,%TM,WC9-/8#>\nM*>)THF&,`1C"JLOA<J#?LP]LJ?@TWPK^4CX0``(Q'L88]V*,(>1J\\;)=>7;B\nM]U>2T5/%'<.="SOEPXI'HB;&0^"9*?D9_RL1`,Z`/PXA5!>$SA]3*HFD\\LY[\nM5`PDP`98&M463-P^%XFHJ!+UOE/V;-X#;);A_^_?_P+8B:=<[GC@@P````!)\n'14Y$KD)@@M46\n`\nend\n
105957
 
6566    calculation_write_48            begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```*NDE$051H@>V9;9!<59G'_\\]YZWO[=O=DALS$R4QFDB&$\nMR"8!,K#95``AQ)58K*(;M=S=H!0J?K#([I:K"VZA5NV+2PE:!5+"?K!4K+(P\nM[IJE3"J2A1A()3&&#.1ES,1,XC`SF<ET3[_?]WN.'WJ"X&X@H2?#E_U7==VJ\nM/M7W^?_N\\YSGG'L:^'^]NZ(+#6S:M`D`6)(D&:UU%8#9MFW;G!F[6+$+#C`&\nMQEA*"'&?E+)="#&7OBY:%W3%.0?GW#/&N`!6`OB?N;-U\\>(7&CAZ]"CZ^_O!\nM.0\\YY^]CC.V[[KKKS,#`P%SZ>UM=L(0`0$H)*>4Q*66LE%JME,+FS9OGRMM%\nMZ2T!GGKJ*7#.8\\[YLYSS.SGG\\S.9S%QYNRA=L(3.:]VZ=8CCN""$L`#<98P9\nM6K-F36W5JE4X?/CP'%A\\:UVPC;Y1]]]_/Y12Y'G>AB1)[HBBZ&`8A@=<U\\V[\nMKJM=U^7U>KW-==T>UW7GNZ[+?=\\O!4%P+`B"LT1DC#'O'@``;-FR!:=.G<*B\nM18MZHRC:&(;A59[G"<_SC.NZNEZO>_5ZO>2Z;NRZKO1]OR<(@IXHBIZ-X_C[\nM1!1>#HB+!CBO^^Z[#^O7K\\?V[=LMW_=SGN=QS_,BW_<KQ6(Q;&EIP;%CQZ"4\nM8K5:;44<QP]JK?=$4?0$8PR7*Q.SKEPN!]NV8=MVGV59/U%*7:.4FO4X;SN)\nMWZF"((#C.`!0Y)Q?P3E?+H38#P!)DLQ:G+=LH\\VJ7"[#MFU8EO6B95E+I92I\nM;#8[JS$N^P9G[=JU$$)TC(V-K2^52FLXYWL*A<*LW?^R9@``E%*P;;O=<9Q>\nM(BR=[7EPF0#^&L`F`K[(MV[]=V8@NQ)#=AC3LH%C'^$07V?`O0"V-!WIDMOH\nM!6^T^DD88%7.D1]MR:HVSEB+,<;QPX0CRE]OHDIOQ4LFDW3OODPZ54];O,X9\nM%:?+P6NU:O@,.$WAP&<O.>[LS('53^+.6WKPPJ&SF^^]:_D7K^S.H5#V\\;N)\nM&G[YRB1&IEIAI5L025I@6>JNUE8+7?/36-77"M>+H^_M.#DA&/TT?@>A9Z>$\nM"'CVAZ]F>]^36=/_WG:D;8&*'^.EP3S.%#VHK$)+CL!MAD@RC-9#'#A3PO97\nM)K"X)R<[%V;7WO.AJR`_^*-W"0``VNSN[@YG:1`E&!JMX.<'QS%<<,%L"9E1\nMR&0)S&;@C@1/2W!'8M*/<6;:0\\<"I_\\_?C+H,/O2EZ59*2'."$E6+;]BGC5_\nM?-K#SH$)G,J[X&D)DAS247`L@$4<9*G7)UZ2&/RVZ,'.IJ["PEP7L\\70W`/<\nM\\!0ZW^.@6`Y6*4O(%X]/87"\\!F9+L!0'J09`1AGP@($<!4)C/T3:X*P7H\\V6\nM[7:KM8QSNF2`YDM(,HSN'.;I3.I/)JL!#@X7810'MP78S$<Z$NF4`;,8>%J"\nM.0K,41".0I4(=8)*9=1*F9;(_=V.-]W^T>XV_-N">?8+?WG[9T]L6/KP\\`JZ\nMR7QF(;[1V1AO.@-,,.@5'3D(NO+86!6N-@V3M@1+"4!QJ$P*F5B#61P\\DP)H\nM9D>J#;0VJ`!@:;DBBA,F!->-P5W(/OH(_G[WBI8'<_L_UR+MK[>/3-H)F>Y_\nM_-GXOFL=)+,"0(*!Y51'-4PZJS4?E&(`"T$F`F(#@H&N5Q#41X$P`&P&X@*0\nM"H8)&,[A&0)9_"IE>`Z$TNIO]2'3_BAX,MTW].=]W_Y>O/0#QW=O51\\HQ>5K\nM?#R]O@U)^;>-^,UG0#(8H),)T^+8"3(9C:P#9&U"QB(X2B,K(V3;%^'#"8,G\nM/+@DX2)&W0BX1J"N)7PANF*P!024EMS0#J]RMG/)LH['E^`7&P>/+\\:^7]^$\nMG>F50=NMMW3W'2VK\\38OQ/[/ST(&)`,9]$(*.U0*M50*?DJB:"F(M(1,2W!+\nM@)1HP#*"88`Q`(R!CA,@3,#\\N(W%NH=0./'3'Q^0&S:M?"!`M+'BGL5M/;VX\nM]6-^\\<G(WK^,M]WC1F?^6T28:#H#]/ZG04I`1TF?DU'4O3"'W#P+J8R$41R1\nM8/`8H4J$*C0,",0(Q&=ZAS$P1#`@:)"%6/>%V`/K2G'SR<+XYM%Z`2VZ`ZMR\nM\\Y(77OW-\\^G\\A[B?'__F7WUWR\\27_NQ3:!I`*$)P<IK$DGF]=_1WXB_6+L)T\nM$*,0),B'":;B!/G$($H,ZL8`2H`4:P`0`&U@$@,3,1`GF$A?J3=GI/G"AD^/\nM!`/S6I6/:Q<LU;N/'WEISXZ;RRTE_;P^_OW_^M>-1Q#$/V@>@!B!=6=30K*%\nM/>T.[!0'10G`"(81P!F(#&(R`",P2X`I#A(,8-0`B#5TR``B&!8O*=QYW3T+\nM>C[XT=;7=L,?^;4^U!,</#5V^Z#QK_B9=WS'<R]?<:N.IA[XPT-L!@`,`*.T\nME+R]):,:)4($$($X@<!@F$$`#:9$`R#%09*#&#7F0*1!G($8H7ZZ_K[XQJ4W\nMUV+AK'+[,7)2[RJV+1]>S,3(ED-W[/S;OF'@]`-OLM!<!D``(T<(UI*QQ/DO\nMSX.!`+BQ0<@86(HW`&:R`-[(`$4:6A"B*1^E<JI=V"FLF<QC(55.G`Q+7UXL\nM<)HJDU)O/PN<GOI?'IKO0B";""DI9NJ:&ED@(B0PF(XTS$S9D#P/(D&2-1:R\nM,(%V8TP/A0BR65P_6L"2L%1\\]>B)!Q]ZZ*L#=]]]&X"]V/N+_SM^4P`SZRD9\nM`])_?-Y#P'28H)IH,"X`3F""@2G^>BG!&,`8E`Y74$UET#5>0G]2C4=.#G]S\nMW_Y_V';HY8,`]KZEAZ;V0D0`,?BQ-H$7)J`WO-]%VF"\\'D&;\\XFAQL1EU%B]\nM9\\JI^DH9^9J"/5G'.K^*\\MAK/]ZQ\\_G'VN=_(0G#9][60U,`!@`9E,-(YPO5\nM$)P(F#%<#1*4@QADS,R#-H`VC1_-9,L;JF#B1`A=B]$_-0TRE;%?U<K?6/Z)\nM#U>G\\H]?E(?F,F"`N.A5HD0?/351@^0S1X<&J`4QPDC#:`.3:)A8-ZY1`ATE\nM"$:J&-L]C2#A6#0X@<ZTCX'EK4/UAS]VIOZ9-1?MH2F`8-LG82W,:0*>.WRZ\nM&/E!#$X$HS7BN&$:,]=&OT^@PP1)T<?DKG.H:H7,*V=Q?<K#T-49A-=W[<V,\nME^K*EG,#`#1*@Q,]=^9<_<"N(^?0:@L88Y`B`B4:.M(PH88)$^@@@78C3.\\M\nM8#I(00X5\\*=Q%?EE%JHK.\\<XT7]RQ\\*IFWKG#D`;`^'(J5B;?]EZ8/3<X&@%\nM;9;$/,F0,H`.$Y@PAO9CZ"!&[4@)^2('G7-Q8ZD$L9AA8G5G1()_)\\K7!I#H\nM2XK?].%N<GPKQ,J/0_G)<!5F],0Y]P:E^+R.7`JU2&/*BQNK+B,DA1!38PR&\nM*=PX.H6NU@"#JSL\\M&<?0Y@\\S%(R'+YMR=P"`$!\\Y!G(M7]C;#<Y5B2\\>&K:\nMM5ZKA-TQ3+H>:6@TVNC5;@%M40FIP0*6P8T&>^R#P?(%_\\1B\\X31QCV]H>^2\nM8\\_:R=QYV?=O!Q*MF"6OE6FY4:;E.F:)7F%QY];R8,=B/Z^FBWILU_[2(_G/\nM??R'Q7O_.=^WY]L8OJ7K'<6;=8#SRGWE.7C3->06MEG&L5MZ\\T>[^]W?/=V6\nML4:\\>O&AQQY_^%<;WM]O=FT_U%2<RP;P1LUO7P``74NO7GG;XKYE.^:W=Q0>\nB?^1K<Q%Z5L5Q&?X1^CV.DL".RD=G6P````!)14Y$KD)@@GG;\n`\nend\n
105958
 
6567    calendar_month_zoom_48          begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```/C4E$051H@>V968Q=R5G'?W7VN]_;[L5+=\\_8'B\\S=A8<\nM.S.!9(*$2`(H(D!$4)`0$I%X0#R`$`)%D(<H$8N4A^0%%`%*0A*"!A1%$PA*\nM%&56VQG/>&R/[;'=[G:W>_/M[=Z^R]EJX>'<>]MM]W@F:,0#Y),^U:FJ4\\N_\nMZMNJ"GY*/Z7_WR2VY=[S]P`5C#F`Z=6)^QN]<6\\66'=QGXS)6"O0.OO^23L7\nMS`)KO/S[VXJ=NS.6)=!*O^\\7GQC_ZCL>V>4JI=$&M#9HD['19E!F3._;@$9@\nMA$#3YUYYOXTR:*702F&41BN=I>:>_G36IC^F,=#JIF)FL?6'MB6^UKT'US8`\nM(EL0]_!DM?K!$[O=)-4H;3)6!J6SO%8&90S*"%1OP@J!PD(!V@B4Z4^$K)W4\nM2*61J42E"IFDR$2B4HF2"MT?1QO,/2#6FC&W[[0]Q[:XE[8!H+>SS7;"2B/"\nM$@+36P6ES5V#D$U<"*2P4,)"(DB-16H$D8)0&KJIH14INK&F$Z9$H20,$](H\nM)@D39!1CH@23Q)A4@C$8P!)@6P+'MG`=BU1II-1H;1X,0&D#`IY^;I;3E^Y0\nM*7KD`P??L_%="R$$!H&V'8SKHFR7Q+*)A4.$36AL0FQ";1$9BU1#J@Q:`E)`\nM"B1`?%<::X@TQ`FD<OM*]G7D`:KBW%\\D:+1B&IOQ3E7@N)`+(.BQ?]=WX(#O\nM@N>#YX)M9PJK)*0IQ#'$#MA6QJ(W66/(Y*;'/X%R[P"`3!GN[</TRFT;+#M+\nM;0?<N]CSP/>W@'ENILEQ#%;4LT0:I,S8LK<LEN@Q^BU/_CX`7_BS#SP0`X"Q\nM;(R=`3"V<T]ZS[=E90NL;)`^1A4P4H%4&"E!*<P]WVB=;4A_O+XEZ^4_][L/\nM`/"ICS\\Z:+2\\&=%-U`!$9KK-P*0;^JG9D@+`&)TQ*:9G[XT161U@C(W!QN!E\nM[1!;;=GJ!Y/MA>_8#!<#1,]$?NY!.R!5MO)AHOB7%V<8*^=Q;&O0:7\\E3,_V\nM#P;L#=8'M"V_K>[NO+FKWYW[4L:0Q#&?.'60G.\\.%N0-`?1)&T/.M?FY\\8#`\nMV5HAW3.E6*+G4#/;OK5ZF9F54B$LT1-Y@U0J&UR(GM/2I%(BA#58&*4T2FF$\nM)0:.+4Q2KJ8^4F^!>TL`(!O$DC'5<GEKA]*4,`PI%<ND,L6V7#J=-I[K8=D6\nM:2JQ;9O-9I-JK488ACB.0QQG<IW/%XCC"-<-6%]?IUJMDJ8I0EC(-"5.8BKE\nM,E$<X7D>4S.S7([EUB[M`&";:^N'"_UP15@6CN,.V'9<+,O&LFTN7KA`&(59\nMG>>QNK;.V;-GL&P;V[%Q/8^+%R\\P<^L6GN?C>A[=;I?3IT]CV0Z.Z^('.:Y<\nMN<+L["Q^$.#Y/E)KSIXYBU(:QW&W0I4>OPF`GCF^RPIL)X/!8/4"-2E55FJR\nM.,:RK$&=,88XCFEM;F*,02!H-INLU.MHK0<#&`-KJRL#Q4V2A,6E!;IA=YO.\nMF3<`L$V$^C_TY1D8:']&(K-*0O#P_@,4"@72)$$`0>`S,3DY^%\\(P<3$),5B\nM<0!HS]Z]O/\\#3^+8]J#'\\?%QS"#TA6*QR(GWG"1?**#7-@83?R,1V@;`&-"B\nM#T30Z7182L,!&"E3XCBFW6IA@-5ZG3#L8MDVCN/@NQZWYV8)NUU:K19!X).F\nM"?/S<Q@#ON\\#,#M[BTZ[1;/9&`"^-3--*B6Y7(Y<$#`_-\\?JRAHP_M8!]$*A\nM@0@YCDN^$`SJTR1!"(M"L00"3*^!XSBXK@<B4W1C#*5R&8$8B)PQAGRA",:@\nMM$)K3;E<P;(S9]=U.Z1)2K%<0FN-4HJUS38Z,5MF^ZWJ0-_[>9Y'M5K#VVC@\nMUE<H5ZL4BR5RN1S3-V_B!S[E<H5JM8;2FN7E92K5&N5R&2$$T],W:6VVJ%1K\nM5&M#*"596%P@E\\M1J50IEDHL+RU37ZE3K=6HUFI$4<S4U!3"LLCG\\]LF_Z8`\nM^@K<MT)]^RZ3A.[J"JG,['D8A9P]<YK69HN^DU]:7.3EEUY"RBRBW%C?X/EG\nMG^7UJU<Q)HMO5NIU+IP_S^9F"X`XCKGV^E5F9V:R`XXQ+,S?YO4K5ZC7ZP-G\nM]R`KM%V$`'&7!>IT0ZY=GV9A=I%F8Q-]YQD\\SZ%:*9'+EW`];]"V7"DS/#+2\nM$Q>H5"KL'=]'N5+NJ;ZA-K2+R<F'\\#P/K11!$%"I5,GE\\UBVA9&&ZM`07N#C\nM.`YIJK8\\^UM3XBR",TIQ,(AYY=QEKER?9J,;8X1`&(V0"1Z:L=%=7'SM*B-#\nM95S7!>#AAQX:*'$0!!P[=APA!'-SLV`,CNLR/#+,:KU.M]LAE\\LS.C:*,8:9\nMFS=)TA3'=3ERY`AAM\\O*1A/#_D%H\\:8[T&DV,`:GN7I'S+SZ$E?K;8Z^\\R3O\nMWC.*YSHD2M'MM&G<66+ZPGF^^Y\\_XM2)8SSY@<=Q;&<@/K9M4ZY42)($R[*(\nMHPB`()<C35-LR\\9I.)0KE=ZY6A/',5$4X0<!::^?5I1@VG?YIAT`#`SR5[[Q\nM%%-7+GHYQ_FCYT^?._GJJN+CO_9+'#\\P3BX.B5=6\\*H52J4"Y4J15&LZS2:K\nM*ZOL?_AA%A=N\\_KK5YB8F,3W`Y32O'SN')9M,S8VAN?YW)J9X:4?_Y@]>_90\nM*!9P'(<S9TZSNKK*Y.1#",MB>OHF5RZ_1I#+XW@^EYH.\\VW%=+WQG:EZX_R9\nM;WUQ&X"!$N^;F.30D<>>N%-?_8T+"YO\\]J]_A,GA,L9H-I:6Z"PNDG>@%-B4\nM/(M:.<>1=SZ&Z^<X<_9E&AL;W)R:HM5J#4QG$B>9G3>`Z'G9A7DZG0X8L(1%\nM8V.#I<5%TI[Y3>*8QL8&C<8&QA@F=@^3JU:PBR7L8FEG$?KC/_TTAXX\\RLS4\nM]5^X/KM0G3ATA,F1,JUNMO6Z4J-6*5,(7%S'HEHK8R;V4BB6\\!'<GIKB\\",3\nMG#QYBGPACY**0K'(@8,'&!T=0RD%&/;M&^>]CS]!K59%2DDNG^/8\\>/$28(1\nMD*8IQ5*90T>/,C0\\3!BE.)Y#WO?1.\\E/'\\#J:IW?_-B'K,]^_@N'[VQT.'AH\nMC"A52"61,B7U/6P'NIT6KE`(WV.D6@(AJ%1*U(.`S<TVCQR89*5>)^QVR>5S\nMV+9-_<XR41AFGCCPJ=5JW%F^0Z?3Q@^R@XIMVTQ/W2!-4US/)Q?D:#6;;#3;\nMZ/&CJ)Y_>D,`OA?PR,'#5A+'?B(E"D$L-09!X/M4K`Z!95&NE7`M@RL,<;=+\nM/I]C]]@H*_,+I%*BM&9D9!0I)99MTVZU<#V7D9%1P-#I=.ET.NS9.T88=O&"\nM@+6U-800[!H9)DD24JE87U^C5AU&6R[+@WLIM2,`"Z#5VN3K7_N*M&QG+><(\nMEE<WB*1"]F_AEA:);EQ':(UM.ZRMK7/EZA765E?!@.<ZS,W>XNR9,ZRNK>+[\nM/HV-#9Y]YD=<>/557,_%<3VFIF[PPO//45^IX_D^<11QYL47>.7E<Q@#CNNR\nMNK+"C6O7V-QL8MDVJG?XZ?..`&I#0_SPA5>04CX_.5)5MVY,L=R,2*0F3B2)\nML#&E2I:7FEAI1L9V4RI7::PWZ+0[C([LPG:<P4HI)2F6BCB.@]$&HS6693$T\nM--03*4,J)?E\\`9E*TC3-+LZ4I%0N$^1R:*V12I%*19I*TO3^71C$RO_X]:>P\nM;7NW;3G?_L&9"X][C_P,/_NNP]C"$'<ZE`L^A4*`(S1%WZ7@VDQ/SW'UU8N,\nMC=0X=>(X4DD*A0)1&.)Z'DHI/,]#IA)C#%)*4ID2!#G:[1:>']#NM-%:X[@N\nM<1RCC2%)$OQ\\COGY)2XZCQ(%0TBE/B7@'[[\\JQ/WZP#`]__KN_S!I_]Z>7EN\nM^LM/O.O14\\^<.V<]V]EDU]Z]E/,^'2DIA%V*KDUH&2[.S;,\\=YNPU>#8X7'6\nMU]<PQK"VNDH4A@2Y7"^R-411"`9<SQM$FMU.!Z<7BBBM2.*85,K!+BJE:+:[\nMR-'#1'%"'&57G3LJ,<`WO_I/_,Y??HGBP7?6G=IN]3ZIK(N7KK!PYS;A\\`AQ\nM(4=8*;+4:=%:K;.VO,SZ:IU/_M;'>.S88[QVZ1)**28F)AD;&Z,;ALS-SK)[\nM]Q[V[ML'0+%80JG,NM7K=<J52G:@UYI.NTT8A>0*15(ET4HQ.SM/%,4TD@W"\nM=NN>P]4]``",L#$&W-H8XR?>3[529'YZAH6%FRPG*<:R<%T'6V@"%QS?Y_7S\nMESB\\=XREI266%A?)Y7+LWW\\`HSO,WII!",'HV"@8<%P'1'9'9%D6EFUG89Y2\nM6+;5*[-PA(T2`MOUR!O-_II'6P@*A3S?>Q"`NX^4=K[$L6-'>.+@./,OGB:4\nM"N?08;Q2@<W&.F$4838:3$3KO/PW?\\'&_N.,'SY*J7>+80P,#X\\P.CH*"`QZ\nM<';6O=08@V:KK'\\&WCVZ!]P\\[JX##*F`ZXOK/'7F#.5BX<$[T/=V_;N:5$K\\\nM74/L_\\B'`8,4@FZWR[Y]>U!*8UT]1^V'WT5T[U`41WGHL6,4AD=H;C:I#@UQ\nM\\O$GL"R;S58+K0UQJI!*H92DU>YD5_0]$0J[7:(H(M60WS5)J$LL:\\526_*#\nM5ZYQ8VD#VVZ^"8"^*!G0PF:)&LL-A39VSYEHE"YB.@:-@]9[.'CY&A,K4R2E\nM&J\\\\721]\\N-H)X_92'I'4X4R;N^`E#E';5RT&</$(KOXTII4YDBEP@KA'36+\nM4*0L=S27IV:Y/+V`6]J%V.&N9&<1,MDKBW2+Z-Y51Q1WB;L1<=@A"CO$89<X\nMBI@__BM\\]+F_8^_-<[1S59[^YR^QG*^ATP@C!(Z?QPD*.$$>V\\]C!X4L]0L(\nM/P=.@'%\\M..3$B",8*9MLY&D3-U>XO*%BT@GAQ,4=HRG'P!@Z_W+MAT*A2+%\nM?![!$,)H+`S":.SWGF)ASQ"'OO$9]L]?X.<G3Z+>^R1CCW\\0I?3@U29CB]18\nM)$80*XBD(4P-W533CE/::PV4<+FZO,G,S"T6YFXA;3=;?3^_8T!TW[4*<-W`\nMYPW8_3-Q]FAG8X2=B87(=L@(@Q86^O%/&N_I+Y]Z9&7FPX>JH^+\\^=/RM#?Q\nM;\\5W/WE-IHFEM1F\\F2F3O02E4I&D,F-I:+5C-AIMI.TR?^4RZRLK6/DR3J&$\nM%12P@L*K1M\\/X"=Y1'U#^M8!04/RT(F\\^>9(J?"^N2/OY\\7YS6]_\\T>G?V_4\nM$NO?W^DL^#:1_>:_O#GE!/QR531O)>)&U20?<CO-\\HQRCP1*MO[UBW_RW+]_\nMYUGJ;\\=`.]#][Y;_`_K:.OQ'`SYQ\\\\^?O9K8GUUR\\MTC)>>UO5;Z8[[_'>RW\nM99__%^AOC];XJZ-#^>^=J'WTTO%@OS&?Y#-ORQ[_'Z;_!O"KKK37;16M````\n)`$E%3D2N0F""\n`\nend\n
105959
 
6568    chat_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```.&$E$051H@=68>[!=57W'/^NQ'^><>^[[@4D(%R24AD<0\nMB4`@9A(!4:`69ZAC"V@KK:B4T3I:6Z?I./:AG:%V4*NE5!1QQCK*C*-8889:\nM)VBM5E0@!`-Y@+G)?3_.:^^SUZM_[`-)K8W8W-AQS:R9LQ^SS_?S^WU_O[7W\nM@E_Q(4[V']2VW</:H2K-S$1)K$:TEA-*BC&M9;]64FDE44HX)<6*E&)."#%C\nMK5^\\X.PQ<_]#3S/[\\,W_/P#C5WT6YT,<*;E12?$JI<1E<:3.3F,UGB:J%FD5\nM*26$DA(A"$(((P5M*>6,E.R14GQ;"/$P(3PIA#`/?.2J7P[`T(Y/XWQ0B59;\nMA!1OK23ZRC5CU?&SU@\\PN:;.Z$!*$BN<#QCK*8RGG5L:K8)&Q]#.+,9Z0B``\nMLP@>$HB[@N#;!/P7_WK[R0,8WO$90F!02G%[$LG;SCUS>.QUVT[C9;\\V2AHK\nM\\L+1R1UYX3#645B/L0%K/87U=`O'2MLPM]REDQN\\!^<#WH=9X*/`1Q&LW+MS\nMZ^H##&W_-"$PKJ2X8Z">O/&WKWZINNFU&XB49&8QHY59"NNQSF-=P+J`\\P'G\nM`GGA:.>65F;)NP[C`MX'?"BO.^<QUCL?PN>`=PN8_X?W;5D]@*'MG^GY7=S1\nMWQ>_XWUOOD"\\X<HS^,E,F[FEO">\\)]A[O`?C`IW<TNQ8.KG#^H`4(*1```'P\nM/4!;`E`8%YP+=P+O`<R=?_0*]&H`2`E2B"U*B1M_<]NDN.&*,SAPI,7<8E9&\nMVY?B0P!C`XVV8;EEZ%J/DI(X4=241"F)E&54?3@*8*RC,)YNX41AW,W.AR\\!\nMNX`3!QA]U;TDL<)8OZ._+QZ\\\\I*U+*SD3,]W,#8\\[V%<@&;',+N4DQ>>.%)4\nMDH@T4<21(M(2K21*"A`0PO/B/85Q%,8119*\\*X:,\\3ND9-?.?WS\\Q`&4$HP-\nMU9A>:+VDKZ*II1$S"QF=W.(\\+_AX>C%G;J6+5I)JJJFF$954D\\:*)%$DD2+2\nM"J7$"QDHB]O1+1QYUZ&D10B!DFYB=#AA>BX[<0`I!:VLB]9BSKK`D84.0_6$\nMK.L(`5P(3,UES"WGI(DFB54I.E:DB:*21E0319IHXE@1*8D09?<QQI,7%J4D\nM0I25X4-`$!:ZN4=H@3Q1@"-?OQ'O`UK)787U[>\\\\/DM>E*TR*QP+*UT.SW<0\nM0J!5:1.M)5$DB;0BB21)K*FDFKY*Q$!?PF`]I;\\64ZUH*HDFB<K[*HDFCF0K\nMTFH70K#SYO-.'`!`2`TB^J82XBO??7*.Q_<MENVQ:UEI%3@7$$(@!+U9VD0*\nMD$(@I4#)$C"*)$E<0I:KM"".)(-]$5H+A!!?%H)'E"H;Z/_90FO6K$DG)B;J\nM29+TN4,?5MW.4N9>^LX/YMU3Q[[QGT=>=<%9(XP.I810WA]"P/M>9SEF6N=+\nMKQN/E!8?`E(*K/48Z^BO*K143,UEY(7_5R'$SEHEZAA;/OA%K0/KUJWC\\LLO\nMY]EGGQT:&AK:,CX^OFU\\?'Q3M5I=V^UVZXN+BW)J:JHX/'5H=T>M^]KPIC^X\nMI%:);I@8J5;'!E-,+P/52M0K8$VU$E%)2NM4>K411PJMRHQ48LEP/<(8S\\'I\nM=F>AT?U\\8?P'M!+/Y87CEFO.>'$`V[=O9W9V5JQ=N_:JR<G)/]F\\>?/%&S=N\nM3&NU&HU&@\\.'#[-OWS[V[-G#GCU[F)V9.6Q$]<WGO?ZN-!+%'U8K>DM?-:HE\nML::::"H]7S\\_TT0=%:\\EL9;T5321%F2Y:R^WS2-YX3[I77A02)'==.7Z_Z;O\nMN`!;MVZE6JW2[79W;-JTZ;[KKKON)1LV;,`8P_3T-`</'F3OWJ?9\\]13[-NW\nMCX7Y.1K-)GG6N2_/\\G=?_<X'LS366Y)875-)])8T49-IH@<JB59IHD02]R*O\nM>X6MI=5*-I04^WW@6\\Z'![P/WTD2U3QTN,E[;]SX/S0>%V#SYLWLW;LWVKIU\nMZ^>NN.**&T9&QV@VFRPO+3,S<X3I(U-TEJ<9C1M,#G;IDPT>?'2!1_9']J*+\nM7O[HS,S,C4&HI\\]]W<=$K:('TUB?EL1J?:3E+5$DKXNC,O)Q)*>26'TJCM0/\nMI10'!!PLK%N60H3;7G_6<1URW"+.LHR1D9%ZH]'8L&O7(XSJ.3:<DJ!03&K!\nMQ>=7.&/-F:P;34E"B]!\\CBAT^.;>EEZ_?OV%]7K]G"1)GK[_PSL"L/0[.[^Y\nMU,K,D4JB_K1GFQ#'ZI$T5N^/(_7(PG(>=O[N><<5_`L!-!H-0@AF_X&#66=^\nM/V][ZV8NN_HF1%P'7X`K\\$43TY[#-J8PW3:O/'>$+=]MLG__@6ZM5EW*L@R`\nMJV[_%Y24M-K=-UKK-W<+UTH3?7?JPM\\T6\\61^:6,3[SWTE](_,\\%F)I>P!4O\nM:R;)]QZ]^=(UEVZ^9!LAJB-T!4(,(@-GD+J"U"E")XP.U[EE6\\R?/;![_V+1\nM]V-A.P"T.Y9GVLNG);&Z)8G5@311.YT/7VQVBN(+?[G]>#*..]3_=N']UX\\B\nMIU?$/1^_;D.M.##Y&UO/VKKFC',5@""44P1$<&`S?'<%UYG'MF:I^"5RG_['\nMNW[OVA^>WW]@_ISS+W;_?,]?<.?GGWB;]U1#"&]][/'9ARNUR#WPMS_[4_&$\nM`:Y[Q1CUZDKELE>_\\9]V7+CF38-R(8KZ)H24"B$D4BFD5&!S7/L(=N4Y;.,0\nMKC,/-F/K:V^:'!HYY8JY@X]^92%,+KWEKC#B`T,AA(]T<O.LCA7?_^SU)R0>\nMCF.AJNIPQ\\,A>^(3VWY463=YC4]KV-8T4BJD"(`%*0GM&7SS,+Z[3+`YWAFB\nM2C_].D^6CSR\\KY)/S4XF`QCKEXWS7VIGQDT_>.,)"_^Y`+?=,\\=59PWB6^V/\nM^I'ZH%3Q.7;IF8N%;:?D0Y#V(U6$*UJXHH4W&=[F>)NADL$?X+)G5.?PAU[]\nMFNW-!^[^!M,/W>A63?4QX^>NQ$?NO033;FDA_)B,*O?KZN@ENC:*3OL10N%,\nMALV6,*U93/,(W>;L0K>;7W_:16_X]_NNO<]>_O8JY_]]YV1H?W$``#_YY$9D\nM4B?8[N_+N/9QG0Y&,JH``F]S7+Z,:<]C.HODK:5/+:P4MU92:3;_E3]IPI\\?\nM+^IU^M1;G\\07;;PKON"ZK:^9SCRF-8-I'L$T#V-:<Z`K&.(?=[+B(_6J-C.-\nMDR\\>7B0`P+HM3Z"\\7TETX[U%:^'[ICF#[2P04$03F^@PL+S<6'E/LWK!$Z<,\nM6J[]V,F4?72\\B.^!]P-M+<Y;.TH\\MG9"_."T#UU_5WO#&9J!@0%DK8_9PX\\Q\nM?V"OS9[8,'GSD^^ZG*(X!(UIV)3#W<#G?]D`[P;6`\\O#23)\\Q=EG3UQ[^IF#\nM%^WZX<I+:G.M/K_DM<D+IIK36'\\8*6!#(D</6O%WE9K-TK'Z?$WV[9X[?.#!\nM;G;95^&<`U`-Y7-7=_R,A>R#0"%`777^>>L__I9;SK_]YC>=?>'01&WLH>\\M\nMI,%/RW4+NYE8-HPO>=8OP>2*PAZJ\\*7L(O&M^.7QT&AU</.%HQOZ:M'511ZN\nMR3,90O"[X34&OKZJ`#_5A3[`Z.B9S,_O_ZU++YV\\\\]9;7SXQ?DJ=9N:X]RL_\nMX:O?GH,:#/I]O-0?X'2US'`<:.@1=LO3^;$\\DZ*(B8WE9:?5B*VC,=WAN;V+\nMQ?)BZ\\X0BIV@,GCGR0+X(&!^_=13Q[Y\\^^V7;!@=K=/,/2T;^-37IGAFH8#^\nM!&H))!HB`4H`$KR'KH7<(#J&/N>1G8+0Z.*7<CKS[=R[XFT@/PV6U8(XI@;^\nMG"A*,2;<L''C^`9K!?N?;=&5DL6N9[[P4(_+68N@&I40NK<7:#UT'62:$"F:\nMS6X)%B0("5&4XMR;P=X/LK$JZOFI(C9F-DG3X4OK]91#ASITG*"K%0L6ND)"\nM)8):#/4$^J+R.);E7HGUD%MHJS(K`O#TMM@<%`ZL.P?+)(C'3@*``-**,6'L\nMJ:>6:#05+HGH)IHE)$;),N(576:@GD!?7)Y3`HR#S()61W=GK2^%Y[8W50WG\nM1Q&BA%M=``!9<\\[W[]Z]R/Z#%CU<Q0VDF'J"[4\\ADA`K2'5IH7I<9B224'AH\nM%:5X=XSPBH9,0ZPA4C'&#R,$%*L.$(!0!_I#@$['@C:(6)9BCVZEE1&/>B#U\nMN+12UY;/>#X3B4;&`A])B"0BED352)G"C00I5PW@F%<)#_@A\\)4>#(1`*E;0\nM(O0V[,,+EPB]WT*468E5":4E*('0DJKJ((0%)1%:,C:6$B5JO%+7H.XZ*0##\nM)8"'X,$8JG*11`8POC=[!5FX,NKM`E9R:)ORG/,00"#HEVV$;8,0!&!LO$)_\nM/1J]Z>WGEN"K"^``-P9.@X/@P.3T11D5*4JQ75O:(S.E\\$8!RSDL9+"<E360\nME?=)YQF,+;)HE_%P@5I%,3P0C]VU\\QT2'U8%H%<#MU%FP(V5!K<ED#'4$X%4\nMDKF&A=1"8LJBE:*TD+&E=1!EN^P8Z!A4X1A)-:+;>2%KINOHJZAAV!;A?7<5\nM`:!48\\?+I%C``!WJE005B3+BB0+=Z_&!LDUFN@1X?C$K'+0-D?>,#290%%!8\nM*!R=AF$PE<-02<&N)H``,B&$F`C!4K:(".C27QLBC10TNV7DC^WQ77MT-9:B\nM]+_QD!EB+3BEOX;H>K2U#-0U0WT*:8H!B&I@5U81($`9^D>%<"H$Z\\H,.**H\nM@I)`NV<?>6P&`B3N*(#OM='<HBN*:I2`483<@("90RW16&XN@+)ES9WXZ+6"\nMMQ]S;'NG4V`=6H]3JRZSTE`@(DBC\\F4N[2U.B>JM#0J\\*R&<)_:>B"':;0VS\nICX']$?!OP'G`*T.9Y3]>%8A?Z?%?#^3MDE]TA?8`````245.1*Y"8(+:\n`\nend\n
105960
 
6569    check_ok_48             begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```)<$E$051H@>V7>VS5Y1G'/^_[^YUSVM.6TD)+H<6V"'0K\nM(!1-E(D7U!$5M&Q#-Y*Y:$:,F<F,.J-#LZC1;%&BDBR,J`MS*B8F.MU$0MT<\nM'2IX@4*!$=I"RZ472D][+CT]U]_OV1_GPNFAI95(R))^DS?G][[GO3R7[_,\\\nM[PL3F,`$)C"!"4Q@`A/XOX4"*+SY+X0C=IG;;98K0PM:@:$0I4A_Z^1WLH_6\nMZ3EVQK@R-,I0*%.C##U\\[$+[R;V28PJM.K&EI_VV.9@`MU][&<UM`VNN65#Z\nM-`H['+.(6$(D;A.UA(AM$[&$J&43L850W"9D"1'+)@:(2C25\\:LXV])CV7,4\nM**62?97NHT"40FE0.F&DA"T52BNMM'I:%"\\#"06F3,XA/\\_A<CJ-22>]-@ZG\nM&TL+MA,TX`1,A%P@+A"U;2PXZR&M$M9)_F;W$[]ZE/&1YV/H<^;UQ2WZK#@8\nMVJ5$2"O@"\\6)VL(9?X32Z574S*Y`&&XUI8=;3269EOA/):RML]:,T#AGK_.=\nM<[9I#0T>'PW]_H0Q,A4(1!(*!*,610Y-KLO$;<:P+(N4D8<)H,!TF`3C.MUG\nM#,''$G"L]88&P]#)>$CR,*7`8(8"`+E.\\!X_1K\\G@"\\8I3<09<`6A@Q%7"F(\nM6=QSPQSR2RJ(6'+^PT>SME89_80UQ[7&3%"+Q)*4!RRBMN`+QY&DN[K/!/FF\nMN8MV7P1?<2[QBDFH&06H/`?B#^-UFTS*]$[&H>=3R#`U;?N^I/&]S8`@8G/U\nMK3]F\\;);L>V$`5/"I;12J8`V0)D*I;,HU!^,,639A'QA+!+NZO=%:&SJP3$]\nM'U=1$:ZJ0IPU4]#%;NR>`(Y\\%TK&Q_N4@FGZ.1VX"PH0$4!PNER$@P'ZND\\D\nM\\GIJ#4)>82%39U0D#)5.L5D*=/O#6%;"15HG,LUU2RZGNFH*.L>!+G2A)[G0\nM;@?*,J#0H-KA(A"2\\5,FZ1D1FUGSZYA]Q>+T7!#$MJF877..%W52IF$4RE;`\nM4@HQ2*>KJ"48!2643RY-;)3D)Q&!B*"4PA^31/X>KP>&*2@(@A+2V4X;"J6,\nMT977)/B:CH&,(%:&1HF@#)W46-'4^"&'OVQ`:8T";+&8L^A:KKYM#8H1+)])\nME7&FU-&\\EQU#.8;&;4)9KH/\\>)P@-F9F$"M3(TD%$M4O:^-D1=5*(78<3\\\\)\nMK'ATU#0X+*.,%=C)&@)RSAZ%.0[F54[#Y^N@O:^-<F7P2$DM=GY%V3TM+<;)\nMHR>LM`+8*044("RZ\\4X6WU0_7!D2')XR?2:DO#`&Y\\]G\\?!0@/#0(.[\\?'+S\nM"S*$%TJ<&CW8PFO;UW&H^Q`N1PXB-B(6JQ?_]+[>VOJ6[:__?5.20BI9SA,>\nMT%H1#8>(A`)C"C*6D"/]CX+</#=[_K65#S:]1/W]#[&T?C7Q:`04E!=-P@BW\nML+[A:2J+J_CETK5X@AX:6QII;&FD^>2A297%E4_=O?;N9C-!))U(B:E[AP*1\nM.+'HT+>FQ(@"I];K)!V58)J:*Y8NHW3F94ROK"8:#A&+A,ES:)R!,_RI\\446\nME%]!^>1RMAW<QB>'/Z'7UTN1>S(_7WIOO**P8E]@*.`]2R'A[.5)"3EY^;@+\nM"L:V\\K>Y_V0&-X+24YA>79E.B8:AJ#+#O+IM`[E.-W$KSL8=&VD^U8P5MYA?\nM4<LC]<]S^=SE6ZH'(@_EEA5YTUF(S"!6J7*8+/')=@Y&'!P.2:U/?:3&;1NQ\nM!=LBG2:GN1Q\\??A#FCL/,+-X)F_L?H.3GI,`W#+O)G[]DY?Y9\\E\\_AB/'RXH\nM='@;G8H,#PBDTRC8,K:EQ[S`95L]H_7W]1#T#:0IZ]":TC('[S2]B3B$;:W;\nM.#UT&NW2K)J_BN=6O\\(_\\LOY-!;'-!7>[#2:RD*D2CYGA1RMG8\\RJ7U&:\\5E\nMTRDN*TO7C3*7P>Z#K]+J:R48"])O]6.Z359]OYYGZC<PE#^=_E@<(UG(AKT'\nM,A\\5NSJZ.>+Q@<X(:IWU^,A\\>&0^.K*^R7Z\\)%]8I*B:W"_'-+A;`OSMR+OT\nM2S\\1(ABY!K=4W<0O;E_/ZZYI^&-QNI)%-E&))<L#0@2M_$<'`O91_V#&Q2EY\nMX(COU%1?CS`_V3>S^EES;$-QI9GK;.OYM[O9?P#+::$<BKHIBWCPAW\\(O>FN\nMB.RS+;21$-XPE$:I2"J@$FDT<;]^1VGU'V4H45D'8E[XPQRM":&LD"6"V.08\nMF@)#FSHY)R[(`T[?8Z^=^FA-W&EA*(/2G%(>7_)$;XG[\\M_LLN(')AE:ISR/\nM4@KH3"4#$\\#SNQL!>I+M.X-UJ!7M\\:O8O#DU(8E<8XGE*C#R]L5/=>X1PXR?\nM,:#</6-&8ZAIWO[!_;CR76BE65N[UKJ^]/I7WESW^EOOWOL#N?*J*T<]P_PN\nM!<Y$Q[$.C@Y%"PIK*WYUN'_O@X<\\ARH&K4&U:-JB_JLJKGKQQ.$3+]74U41#\nM8>OZ_=X#M3[#AW9K;BR]D=67K=X>[@UONO/1.Z6RNO*\\Y^B+(?R>/7OH[>QU\nM%,TH>N;CCH^?:_6VSIQ;,E=53ZEF5]^NXB^\\7SQ5];VJGZW.7:T\\MN>VKP:_\nM,K5;,VWR-.Z;==_IJ=;4WQ?/+!YX:\\M;8YYU43R@E,(P#(!@Q([$]O;M-;\\>\nM^)K.<">3\\R?3=Z8OKSRO_-$M)[8<;XHW+6FSVG#D.:@OJZ<NMV[SPZL>_N*N\nM)^[BR2>?O!CBC0_MK>VT[6MS]GGZ'MAR<$MOW3MU,O6O4Z7BO0JI^Z1.7FAY\nM(18<#.[<<')#J.:;&EE^:+DT>9O^ZSWEG=75U37N<RX*A0"JYU3C\\7JB'[ST\nMP:MWE-]Q__/7/-^Q8-H"E$OATSX:`@UFA^I8>L`ZD&/D&:PH62&SF/7GPO+"\nM8T>.'+E88GU[[/AX!R*"][1W66-7XY&5NU?*[)VS9?[>^;*F?8TL:5\\B*SM7\nMRO[`_@-];7TSCW<<O]0BGXO-FS8C(OA.^V[X_,SG1^H/UDOMP5I9>'2A+.Y:\nM+.O]ZV7`._!;$>']]]^_U.*.C(:M#2DEENWP[#BVHGV%+#JY2);W+Y?=0[O;\nMO1W>N5V=X^?^)<'.3W<B(OC[_#_:ZMUZ9EGW,GG,_YCT!GHWKKMNG=Z^??NE\nM%G%L?+;C,QZ_^7'E\\_H>>MO_=N2CP8\\&_;W^6X:"0Q>TWSB>)-\\]6@ZW($%Q\nM3ZV9NE%K/:N[M?N.F(KY%BY<>"G$N3#T=/;0WM8^ZWC[\\1L`GGWVV0O:YW]7\n3H<CXA8>/,0````!)14Y$KD)@@BG$\n`\nend\n
105961
 
6570    check_write_48          begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```(($E$051H@>V7?XQ4U17'/^>^-S.[P\\PLNPLKBR"["Q1*\nMJ>"*BD*%18Q@4FFH;:+6IFFJ2=.T)HVU@3:I-FFC:=.F:?^P21.-?UC;V%3:\nM8"M1"E1"51`*N(BNN[JP/]S?N[,[,^_-O'?[QWLS.S,[RRPHFS39D]R\\>^^[\nMY]SS/;_NO3!'<S1'<S1'<S1'<S1'_[<D`%5W/$O*<A>%P^:U8BB-$C`$+4*N\nMK_R^/T:IW!HW;UX,A1B"F`HQ5.'<E8Y]6?Z<H*0+5_=V[%R)"7#WINLXW39\\\nMW\\;/USV.X*;2#I:CL3(NMJ.Q7!?+T=B.B^5JDAF7I*.Q')<TH,5KDO<5)EMN\nMKGB-@(CX8\\F-$=`BB`)1GI$\\6PJB1(F2Q[7P:\\`#4#N_@LB\\0"@8-&(71EP"\nMP3".TKA!4$`0,-%4`AD-MNOBP*2'E'C6\\;_%8^^KIIDOO1Y#35DWD'$8<#)@\nMJ)!H30[`:#*#[6KZQRSJZAM8M6()FD*KB2JTFOB1YOT3S]JJB*=$8XJL2^TS\nMV92"`X.C'!@:\\XR1#R!N>0`F;(?J@*(R9!(VTSB.0];(!0H(F`&3B8S*C2FC\nM>#D%R_$;"@Q#^?G@QV$6P'@>`(#*((Q\\U,[08)S1"9N^N,VPJTD80D8$T@X/\nM;EE)9.$2+$=?>O/IK*TD;^Q9<T8\\IA=:>"Q9#SC8KF8TE4'[[NKIG^#XZ6XZ\nM1BU&:RK)+(DABZ/(O`!Z+,5(V"26[YV\\32\\%R#`5;:?>X/!?G@$T6KO<LF,W\nMS2T[<%W/@%GELJ@DF]`&B"F(*@JAH8DT"<<E.9K"P7/7T*C%X9.]!.HCA*JK\nM"354$5Q5BZH)X_;&"41"B)Y9W&<!YL(O&"`<C:*U!C3!4(C41)R!GDZOKF=Y\nMT,RKJF+!XB6>H7(EM@A`SU@*Q_%<I)17:;YPZW(:&VI1%0%450@5"Z'"`<0Q\nMH,J@,1`BGM0S#QG?,UJ[-*V]@177-^?6@D:[+DM6K)KB1>7K5!!"Q0`<$;1!\nMKES9CL:(+N3:^76>(#\\^L318&A%A+*V]^CU3#Q0`U&@THLE5.V4((L:E^91`\nM+@?RDE@,A6B-&,I'+)P\\O(]S;QQ`E$(`5SNL7+^)6W;>AU#"\\OFA,L.2.IWW\nM2N:0(6`:$#"]I,]/8C$5V@?@(2UB]D]4)8)V,PSV=N)D[&G+8$%%*9?8_AD"\nM4ZL9:&(UM=14Q:AXZR!;VD[1]YD-_'?MK9B93"$`W"P``33KM]Y#\\[9=A6#P\nM8KBV?BEDO5`FYB]E\\50B3BHQ3C@2H3(2G>H-A`G;IN?H2ZQ_Y46:W]J/W+Z+\nM=]?<2*4UGA]"XA_GG@>4$NQ4$BL9+ZM(.25+_4>@<EZ8$Z_MYZ6G?\\6NAQ]A\nM\\ZY[R=A6[K\\2(24C_.F=#DYW)]C0-\\8VF<^;6[Z"%8WB5H0F`6`JKR1F[QT"\nM6F=(VXG+#HF2"F?YE1^.HC%-Q?6;6ZA;>AWURQJQ4TG2=LI+:!&2S@#MH6>Y\nM9LT%EM+$L>CMO%JUB?KPC50FTS@C=E$(:28O3Z*IF!<A'(V6M_+EW'_RDQN-\nMJ%KJ&Y=Y)=%77`1<TASN?X$AU4H\\GF#K=0ULOQ_^>?:SA$XF&*]-X)X=*JQ"\nMY">Q9(]#_XCWVQ0J.5E(.LN?[63G71?M:EQGTA!:P%0&9P<.L>_=WZ-5BBKW\nM&M;%:NA)5A&)-S"R*8:[>CZJ,5KL`0VY,@JN+F_ILA>X8JOGM:&!7B9&AR?O\nM1/XZQ];L.WZ8<\\EQ:H(.Z^I7TC[A,O#A#:AUBW!O6X0RQ;LNE*I"9(]\\)I6<\nMKETJ9+)RIFLUB^JI6;2H`)P"7CG40Y=[+VN[:[`NG&!X:Q.)R$ZV;FZB?T,U\nM_P#_(,L[B?,?%<<^[.'\\X"BHO*1618^/_(='_J.CJ$_QXR5[FF9#-9_/5,1;\nM1SG49I.Q(ZQ.---=LXS^FK4L"%?PWLW5=.$=LE,!>$ELH63L@^&X^\\'8>-[%\nMR=^PY#LU.U8EUOMCLVA<:DU`Z?3%9$77V_'*#$&V#0Y06^ND+NR^*<7RA?0[\nM+A]K[[IA&*(0L;()Y951[W[]1U%R1`S14K0AYB=XF"O_*:FR_PO7J`I3ITYU\nM1R\\>2SQIU2VX]8:+@S3:(T,G^[H>T^NWG!"T$M/`T-JSO(@`7>7+QVR0^@Z`\nMXHLO/\\8OVZUK'SVEO_7(H?3.NY[>"QC!X%?+BC"NMH[3TP[XZ_/0M?9+M*SY\nM17@X%=F>&"75T_G\\OK\\?^,G"!2VI>/R9LE)F4,FO!FV"ECW0V[V.W1M?(!A:\nMO;FSCZ;TQ__YU\\&C]T=CM1VMK3^>D21UE34M38U?@^.GZ[AC_9-4158O/==+\nM0V;XXCMGSO]PX\\:6CM;6G\\]8E'D5U2Q-L9]!QQLA'OCZ7IKJ[HJ<Z*)9QA/=\nM'W4\\<?SMO4=,\\TX@,6-QLPO`_"Z,_0AV_NT;K%_V<.#]0;DY'=?.1,_3!P_]\nM^;E8[`R.\\^IEB9S%)-X$W_PI&+>U<,?:WZAXNN:6W@&N<?I?_O>18S]8N'!%\nMO+__=Y<M==9RP&S^-O..O=[$UL\\]902#BV\\:&&%Y<*SU[)G6/:M6K^GOO/#:\nME<G]E/4L2??<^R#NN@;JTQ\\\\<*KRXYN&SO6R+),:;&]OV_/00]\\[\\_U'=P`G\nMKTCVK`"(1&*8G2\\&HG7US7?:@PS/=[H.'NA\\XORYMOUOG3C*E2H/LQ1"*<LF\nM'I^H'H_'&S)IZX"I^K]\\ONVW?]A^=Y]CVR]](MFSDL3]?3UT=KQ7G;;3/:+,\nKI\\*1^>^_^?HAVM_OF8WM/S4RN`H&^Q]^&ONPU?-%.`````!)14Y$KD)@@J+,\n`\nend\n
105962
 
6571    check_zoom_48           begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```(ZTE$051H@>V966Q<5QG'?]^Y]\\Z=Q3/C\\6[':6P<QZ4I\nM:1(5NE'1$)8NT*+R0I%X`"206%Y`A9<BM>*1![8'Q$.A*H(*(1Z0`-%`2Y.6\nM-@E)G3JA=F@6QW;L.%['X_$L=SD\\W#OC\\<2)0X72(/F3CNXY9[YS[O?_EO\\Y\nM5P.;LBF;LBF;LBF;LBF;\\G\\K`I#>_QS%DM\\1CYM;Q%`:)6`(6H1J7X7]<(Q2\nM51V_9EX,A1B"F`HQU-JY=SL.]PKG!"47\\?6E\\P_U8P(\\?-\\M#)U9>.+N#[0]\nMC>`7'8^2IRFY/F5/4_)]2IZF[/F4?$W!]2EXFI+GXP!:@B8U3V&U5>?J=01$\nM)!Q+=8R`%D$4B`J<%/A2$"5*E#RMA1\\"`8#FQB@-"<N.1(S4^**/%8GC*8T?\nM`05$`!--#'`UE'T?#U8CI"3P3OBL'P=/=97Y]?4QU!5ZLZ['K.>"H6S1FBJ`\nM;,&E[&MFEDJT=?8PL+T;S5JOB5KK-0DS+?A-`F^KNC7K-*[8ZUKO66U*P8&Y\nM+`?FEP)GU`+(E0(`^;)'QE+$;).XZ>!Y'A4GKS%`P+1,\\JZJCMG`\\(T,W&B]\nMH<`P5%@/81Y6`"S7``"(16#QPCGFYW)D\\V4NY\\HL^)H50W!%P/'XPD?Z:6CM\nMIN3I:[_\\:MY64C,.O'E=:\\P@M0B65"+@4?8UV:*+#L,U-9/GV-`DY[,ELDTQ\nMW.X4TI5$$A9ZJ<ABW"15&YV:EUX+D&$JSIPXPL'?_Q+0:.USUX./LW??@_A^\nMX,"*<1544BEH`\\041-6ET'S>8<7S*62+>`3AFL^6.#AX":NS`3N3P>Y)$QEH\nM1C7%\\2_EL!IL1%]?WE<`5M,O8A%/)M%:`YJ(;5/,YYB=&@MXO;(&32*=IJ6K\nM.W!4E6+K`$PM%?&\\($1*!4QS_SU]]/8THZ(6*FVC4C8J;B&>`6F#7LLF5]#7\nMGS)A9+3V>=_M>]B^:V]5MQ*)[NT#5T11A3:M2:%Z`)X(VJ!*5V5/8R1;V=+8\nM%FP4YB<E#26-B+#DZ("_KS<"=9$`#;Z'UCX(*,-`F685T+J.40+5&J@I8C$4\nMHC5BJ!"Q,'CP#PP?.8`HA0"^]NC??1]W/?0$LMX+:@W<@%*-\\C+^XC3+EZ=8\nM7LKBN!XJ8A-K:2.U=1N)3%-0V/5K:T[I-44LID*'``*D=0M#IRD1M.\\R=VD,\nMSRU?E0;7,$K-[P8^G7&#Q?%SG/K7"#/+)3Q10:HX)2RO1'-;.RT[!DANZ<*T\nM3)*-&3+M[6$12PV-U@'`KP`00+/[@4?9^]''UH(AR.'FSJVK8=X@YRM]I5T2\nMBQ.,_/,PQR[,L_6V7=RYM0O#,G$02J[/PN0XET\\>9^[0*_3==3<[]W^,2-1&\nMJ9#M:FA4U];`ZG$>1$`IH5PL4"KD-J3%C0X@PD+LL!S>&1KDR$2.AQ]]A.ZV\nM#-/3TQPY]CK1MFZV]N\\@,;"#UBWMG#OT,A<&CY-L:Z5WSQU8D7C@!$.J-+KF\nM*H&I`DJLW#L$M'9QRBO73(GK`81`%(_B]"3_.'V1AS_]"`-=363++F4[06;[\nM3C)-&:*FH/!(-#<2W;>/<R__C=.O':*E9RNQA@0BNGJG$D/51<!4H%=92$03\nM33003R8W]O(&+(2"5'F)4Z>.TM"UC9V]'>2*#BB3LAFEJZ>'AJA%U#:Q+0/#\nM$'1'*\\[,-..#;^*L%#`,"4E&$*V@)@*JRD*5`JD:I`$?\\)&P4=]DG;GZIGVD\nMO,+DS`(='>VXGH^GP4<C"DP%I@&6(9AABUJ*MJU;2">3+,U>7K6I4@-F\\*R+\nM@(8JC8*O-_;TAA>X<(WV7$IE!T,4)=?'TQK'<7#S.8I:HU<,RI;",A1*0=0R\nMH%P@W9C$+17#`RU,<=F`A:@<^:P:>;5VK<*M[(,(OF&2B)A,SRV0+WOX@)@6\nMC9DF'*5HB$>(V2:1B(EA*-*F,)DODK-M(FUMP=GB!WN*JAQDZ[*0\\,;H%*?G\nMLH%RI:C5ZD<%-7VI_YBIZQ/J=VJ'[5WM'!\\ZPZG;!VA)QR@@3+D^></`1F-Z\nM'LKU:+8->EV8FYWC?&Z9\\=9F#CLN(G`Q/&2O!!`4<0DE2V<7<O[9I>6UIYZQ\nMYINTYCNU,E;KZ(>_F4+<$+9T=5N]PV<2!X\\.ZCL_M,?+H_7YLJ=UU-*F9VGE\nMF#H>LU1&1?3;H^.V>?K?O!F++5]J:?&4UA`:;QBB$"D%X:W0:'"_?D&4'!)#\nMM*PQ*##B77^8*\\6R:?I+CK-MSZV]/U@:'.Y[;?S\\J->0&O>57K)-"I8EQ63<\nM)IV,-5XN.[W62F'7A9&1UR]_<.]39B*:%=>52N01$>`BH0@W0+[TE6_R[,]_\nMPL^>?>'CQ5+I1R/OC`Z<O30[5?!ES+*,I9AEN&G;:DS:5J^![IH8'W,F)B:^\nMF$JE?G/XU0,XY<)5]S9N!(#!XT<I$V7__D^=.W-VY*5,.N4W-\\3ZTA&C/QTQ\nM^A.&ZK-$MY8*A='Y^=FC=BPVT)*(-_9-G#QR>')J?J?`S%7VOB$1J)6O?N-)\nMBL45H[6]J\\OW_!V(:LKG5YB?GYN:GY\\?[NR_U=G7T_:+_IC_V=._?>Z=$Z.7\nMOO7E>W;_\\3,O_)DQ?>5^-QS`1C+YXZ>86<A^OK.X^/R%H;>,MS-]PZ\\>/_FY\nMCL;4T+.'WV2J3O^&I-!_([M'CW-N:'#:'CF^I[VXT&<D&UNEK7O;P3>._?7]\nMS8TK)Y=7UNC?=``65QP>2[GY\\3+#:?'V-RW/-DG'+=O-YG;CUV^]_<J'8Q'O\nMK.M5]6\\Z`*,.F`C?V\\GDZW,RVXSSB;1;L.66'7<T6_;D\\Z,3@[_[_C/,A/5P\nMTP$`.%&`2!%>S#+2'Y.&=C=W;RQJV[JS9\\]/O_/=8Y^\\_=:QOU^XB,]-"@#@\nMY1P\\V2'^6)D3:4/?UEY<&+";V]-.0V;@3R^]]M*N6"0[['HW+P"`/V3AZVU2\nMF'3D9`KW@41^OG74,[?Z6EN_FLN]>*^!5N^UD1O)7[+P0,8\\=;HH3UU0\\87>\nMI'5NF^6^"L'?$C?=.;">/+,]15XKZ_Z4VG^+5QS[]M#*\\.,V^FNE]]JR_X'\\\n5!QU5?LH<2D+]`````$E%3D2N0F""\n`\nend\n
105963
 
6572    clients_48              begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```.H4E$051H@>V8>Y!>97W'/\\]S+N]]]]UK$I+L)BQ!""$1\nM<K6$4((*(3#@;;@4IWCOV,JTZNA0'$5F;-6AH]56';1TM+:U=%1&VV*=4JLB\nMCD!HC($DY++97;*;???^7L[MN?6/=Q.PDJ#6F?YA?C-GWO><]SWG?#_/]_O\\\nMS@7.U;DZ5^?J7/TVE_C_/'E'1T>P:M6JSG*Y7#'&!$F29&F:UGS?C[36'#QX\nM\\&6/X?^Z)Y=2XIR3W=W=02Z7DX`>'Q]7^7R>)$E><I^-&S>2)(F_=.G2#<N7\nM+[]V^?+E6RJ5RFJE5-?T]+0_,C*B1D=']\\_/S]^_;=NV[]7K=<;'QW\\S`)==\nM=AE)DGA]?7T#75U=&WMZ>C84B\\7SM=8]]7K=K]5JK?[^_J>;S>8_E,OEPW-S\nM<XR,C)S>_^JKKR9-T^ZAH:&[-V_>_/M;MV[MZ^WMI5ZO,S8VQJ%#AYB<G$1I\nM,Y"FZ:I''GGD!B'$\\,OI>MD([=BQ@TJE0JO5NJ"_O_\\/UZY=>]/:M6M7]O3T\nM^%IKIJ:F&!T=Y>#!@QPX<(!:K;8GBJ+?DU(>FIR<!&#[]NT\\]MACXL8;;[SO\nM-:]YS3W;MU\\IPC!DLE;CV-&C'#AXB,.'#C`U,4QK89834PV3&KY4+!3NKU0J\nM1XX=.W9&?2_K0!`$U.OUB]:L6?/EU[[VM5NV;-E"/I]G:FJ*D9$1:K4:P\\/'\nM.38\\PO3,',U6M#&)H[>V6JU[A!#:.4<<QUQPP05]^7S^YH6%NOCV-_Z>I%6G\nM7I\\G:\\U1\\6-VOT(P]#N=>&G"1[]6\\XZG@^_:NF53^:&''KH3T+\\6P-:M6WGT\nMT4?EKEV[WK-^_?HMU6H7^W[V#//S<XR/CS,R,L+X\\R/HQC@#89T+5S?9<Z3!\nM<Y%\\QX8-&_IKM=H'K;6U1J.!<RX\\?/A(:6'B.=Y]PTH&+UN/[RVE4@RH%$,"\nMD:$:$^B90URW88K/_:A%N5SN`;RS`7AG`^CIZ:%8+'96J]6[C;'G'=K[0R8/\nM/\\[S1_;2JCU'KS_#E1<&W+IC"3=NZ>6:BWU4:YKO']2%G==<L[94*CVV8L6*\nMPX>/'*41I;99G]E]Z[;BJMO>_%:6770EO>==0*EK"7Y8Q#F+U0DF:S)87N#@\nMZ#S[1M.';WW3FQYYXLDGSJCQK`XTFTVLM0P?/RZFQH=YW\\TKN';W&Q"Y#CQA\nM"7R!M`H3SY'53Z#G'3O637#^X\\\\S<7+2Y<)`"R&8F9[BP0_=(+_UR'_LV77E\nMNJNDET.WII%!#N$<4OHX+T!('Q!4"C[7790E)_><V/?QF^+PFH&;LYL_^/"O\nM[@`(4NW4POS<CNO6R4O?=>>M5`8VD>]<1ECH1/HY<."L`IU@LR:=?H,2\\_S[\nMWN;8Y&SCT]G"B;E;-]3SU[_I[9^]_O*.U_54O+)?Z!92"J202,]'.(V-IM$+\nM(ZCZ&*I9H[>K[&ZY\\Z[-SQPZWKKBZEU/94>^S8]?HB?),TE_R^4P.SO#O]R[\nM*;>NK_7DC5><;PJ5'FPT@XWG<"9!")">WQ;A>2`$#L'FU1ZOZ)S:^X:M7<T/\nM[&R)3S]**B>^U^RNY)9Y-A6F=1(;3>/2.40ZCVM-8!MCV'@:IV*<T73W+P\\Z\nMU9'^2K2_-KOG2\\@S],LS.G#+JP?Y^F?_)+]Y][O_ZHW;E]UV7CGN"#O.DT)*\nMQ*G1DQ[8#)O,HALGT/7GT:TII&YP]>[;>C9N?M551Y_[V7_]T;75^4KSP/YR\nM[TII=:1L,C>`2830+5S6P,:SJ&@6'<^BHQET/-?,50>^*VWZ-\\V#/_Y'I^;T\nM'0^JE]1Y1@=*ON;1'Z*"F2?HZPQ7%?.!;UHU;#*'2^N@(X2.<-$DIC&&C6HX\nMU<*9C"!78D5OL;^P\\%1'Q=6B1BMAR25KQGK7K_]CM3!VEXFF)DQS$MVJH1KC\nM9(V3Z&@:$\\]CDCI&I3^:/OR#._J6K_A4U^#RY))[HS/)/+,#C^QM\\.-/]KAT\nM8M](N=J_3@8%ST0S1>FL%#9&Z"8NG<?$,YAX%AW/+RYSR'RU5NCH'\\M.[KEO\nM^SO>_]38]Q]FPP=.\\O9U,ZAXIB:#TA*<O<(9A551>[]H&AW-H=)&(TN:]P2^\nM]]/CS_Z$2S[4.*/XLSH`H.,%UM_][$]-UGB=JH^_WC1.'%4+P^VH-"90C0E4\nM:QH=SV/2!C9K8E02I8W:>ZV.KD&WOCGZ[0>X[G/MXZU\\UW["0J\\5.OF,2>:^\nMIYJ39/43J/HXUB@H+C&9\\;[8J.E_B^.,S7]^5NW`+WDW.O;YBUEZ[<>9_,][\nM/^J%E0_[A2YD6`(AL"K&)`OHUA19<XJT.?N=1I3>XGFBOO%C[N</=`_0!-;C\nM??-@]PT#'<%7JQVE<MBYG,3KY?C!O4<G)X9ONN,.#K`3RSW`QWX#``!C#ZP'\nM9P>$%WY#!L6-TL\\!#JL23+*`=98TJL\\TYR9N#P/ON_M&%+<_"-P.3"%X)2MZ\nME_=>4:U4MPPO#%_XQN_8H5L&O35>P?.0`?.MC&I+I4=\\GGW_-G&L3.G9.(H?\nMUTW]!'<SRX>!3_P?`,S#98Z-7D`YWWJUMOZ#"&\\E#IP0^.7S2(U(YI]_^D_5\nML[6_+*S&7CH/A$!*_[(5R]ZY\\Q4[[[AJ]55#SS2?\\1_8^WEV_9WAMIRDI].2\nMQ]$5"`HQ?&6IY),[/#94+T<H&1^>.OS3J?FIS]O8_C,>,1_]>5V_Y.WTY_!N\nM?LY';JBL"O:,?NHM7_[O5<O#E96.+KS.5<S4%2/[GYQK[*O^[,T_^GH/\\F2=\nM][\\G);6#:P;7_/7;MKUMU\\:!C3*R$5]]_BN$58]]KR]@]ALN:3D&)=A.R;,7\nM^_S@0H]R01/+!H/5H8*3;IMPXI4U5[O4)O9>/D+KQ1!G`;@'R'SHN["G)[=S\nM8-65VX^<S-905TNGQ[*^4C'AY$P=;4=(E:'?L=1$`_^4[YZ;E'[GL/?%OWU"\nM;?_2AMT[7K5[=?\\JCC>'.9E.,)Z,TEDH$5R:Y_AE`1/")Q`2ZX$6#D]INK.,\nMII[C4&L_C2Q&Y55>YN1=UMJCA'R!#P/WG1'@/J``)$-+EJRX:^?.U6_XW:L'\nMSM-"BH]\\Y@`F,\\P>=@P!73E'23JJOH0ZXNFLH]MTYKO[>BL7KUM9O'YT]`]X\nM_`LMFC>-L'13@XET#"LSRKD\\Y5R>4BY'/@SP/0^!0!M#IC51$-!*$NIQG8B(\nM!@DZU"&:.TEYB(#9,SAP[^*F>./0T-(OO/.=EVW:N&D9J8&O_>L8TYE%+KN*\nM+V8^3Q]YCHN".LM"1S/HXBDQQ*,=KT(5JDQ;2Y(+6#:PE)/'ZGSKXY:+;I^F\nM\\]4G"7Q),0PIY_.4\\WF*84@8!$C1!DB4(O!]I!`XP#J'-A:M+5;9-3@&$6<$\nMD$"\\M+N[ZU.WW[YVT^!@%T='FK04/'VL">4`6UG"D>(M'`D=PC<(*;`R!.N!\nM,A`KDECQS&1*D"B,MF1IF2<?6,&JCOT$ETMR04`^""CF<E3R>0IAB"<EVEKB\nM-,43`N<<QEJ4UJ1*D2I%$MH"EJX7MYX7`7P$(3R<LZ]?MZ[_BFJUR-'A!@F"\nMN<PQ&1FHY*`C@%((A0"7\\W'^XK706$@UQ!ZNZ5%KI!`[B"U8!_4RH]\\:XOQU\nMA_!+DL#S7H`H%,CY/DIK?"FQSI$MNI$+?'*^3^#[9+X.K>]ZSP``SLT$8=A[\nMS9(E%7GB1$2D!:GO,9,Y(B&@N"B^DH-R"'D?`@E"@%X$:/G@>VTS'6`M*`NI\nM)3TZB*IU0D^"$`(I!+Z4Y'R?2CY/JC7*&&+?)_0]0N'C:1_/\\P@\\CTJNXC54\nMLP\\)%ON_`010+#@GED],1%B7)Y4>:>@SYP1*>E#PVQ#E18A2`#D/Y")`K"%8\nM7+<.M&O'*C60&$Q<)ILM86P+8RW:&-3BDFJ-L1;W(CVA"1$+$EEJP_86EV!2\nMVU<JE)C\\BTEXWR_,`:^HE.G\\R4\\FZ>K)\\+N+Z'*.N!"@"T%;7.BU1[X40$>N\nM#>3+MM"6:KMA[:)P#4G0!LM[N#0D;81DNIWI6"G"-$5*2:84#DB4(M,:936!\nMS>'F);9H,=;27>PB"=,E(W>.(.X7+S6)*0,=2EEJM1@2H,="CX1B")YHBPUD\nM>^0+?ALB[T-F7G`BU9#7B)R'"Q>A0P_/#TD7\\L191B!2/,]#`-I:0K\\M11E#\nME*8DF:(L.A&QA](&90W6.2I>I4]<+WRN:C_HOPC``%3!%=OA;2\\YV<2(`MJZ\nM%S:?;EJR[4HI:,,E?GL]D`C?(^\\G)-+@/(D,)-W=1=)ZGF:2(IV/$`)C+>EB\nMZSP%DRI%,TWHED6D\\TE31:8541I3E,4>5A"B?P'``G2#+8`%9T$;BG*6U.M%\nM:]<>7;TX*96%3$.BVA/6N'8G<FU0(005V20UX&2(`Y;T%QB-2C2B!*S$6$NF\nM-7$0X$N)%`+C'$IK6EE"H53!"P*R5%/UNJGZ54QJNBE1)"-Z"0#;"UYP&B!+\nM*/E-I!!$F6Y'(]60:(A4.TK07G>+GZD&91#64?4S9K(,;#?..#H[`\\JS:_;/\nM1>KKGDB=`)QS*&,(/`\\A!-;:=B?*4O(=163.)U$*'\\=4?4HLS"W,$I*V`W,:\nMX#V+$;+]8&3[/9(!E5+).80GF(ET>S)&JAT3;[$9*]O.>#O`[=]CC:<,W7G)\nML2P"4P5M,4;3-[ON^/C;WOMG,6LR>"MGJT,\\</I[PC333/_"?Q8!3H5;];_P\nM(DR#BZCD`Z0OH96T)ZXO.?V*0-OVJ+_X6K#H3J`M?=TY1)J"TI`:XH:BF!<]\nMD,]!G)U5_2]9BP`"*"/$=+]S"E!`!B14BKV$@81&UAYY(=JLVBUV&_7"A<NX\nM=C>*-:&$_DH1D1D\\I<F'@IP4%$+1"4$1S-D?=G\\U``=,>2`:0IAGG%.F#:$I\nMY$N$GH1FUH[*J=&W%M1BCS_E@'6G70CRDJY"`3*)S#0=@<0D2H[.-L;!]\\_R\nMNO/7!<`ZQ[U@/W8Z0GA$D8^0V>+5=%&L)]NF6=J"3\\7J%$"JL<ZCW@QQ)H=J\nK9$S,QDRH)I!9\\!8X-0O/U;DZ5[_=]3_M"9&"T<X]9@````!)14Y$KD)@@H=J\n`\nend\n
105964
 
6573    coin_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```1ZTE$051H@>V9=Y!D5W7&?^?>%SKWS/1,3]R=W9G=U2K'\nMA96$$382&!,<$!B,R2:XC"EL@RALDD6PP=@$XX+"0`F7C:'*!54V+KN,P"21\nM@PP2FT:S869V9KMW0N=^Z5[_\\7IF)2$;@1S^X5:]>EU=W?W.=\\YWOA,:?G;^\nM?X_\\3_W0TU_P:N(XQO4\\3X0REI*%K(AL/Z./2--:VXR-[8M@/_W1=S[BYSXB\nM`+>^Z#8`)<(4R#76VL/`%<"LB`P!_C8`$4*0!K`LPA&0;PE\\W6+/"(1__Z$_\nM^;\\#,#`\\*R*'K+7/!&Y62NWU/=?+9'PROH?K."!@C,480Q3'1%%,%,<DL<%8\nM&X-=!;X.?!JX<VYJJ'YB>9-/?NCM_SL`;GW1;5AK':7486OM*T7D";ELICQ6\nM&69L=)ALQB>.$[J]/KU^0!A%)'&"L19C+5B+M9;$&*(H)HX3DB3!6AM9N!OX\nMH,"G!-F*3<S'/_CC@3PL`+_V@M?@NAIC["[@50C/*^;SHW.STTQ-C!+%";7Z\nM!N<WMNAV^T1Q-##,[#Q":XU2"J4TH@0!1"2-4)*"'`#Y'/`6F\\1?$Z7MW_S5\nM[8\\,P*TOO@UCK7*4OME:^S;?=Z^=W[-++IJ?)0@C%DXN43N_0;?;I=MIT6DW\nMZ?7:A$&?)(EW'J.U@^_[9',%BJ5A"H42KN<C0FJ\\L5AV[LM8WH#(WP+Q'>][\nMTT\\'X)F_]5JLQ55*7HCE]LK(T/BAJRZA7"YR;.$4)\\^<I='89'.]QM9&G5ZO\nM0Y(D:*WQO`R>[Z.U!L!:2Q2%A&&(-08_DV%XI,I8=9)\\H;3SF>W+&-L$;@?>\nM!T0??>\\;?S(`O_Z2UV&M=47DE2+RYME=$X4;#EU)N]WE.]\\_2JU>YWSM++5S\nM*P3]+DII2N5A1JN3#(]4R1>*N-X%`%A+DB0$08^MS77JY\\ZRN5'#6JB.3S$U\nMO8=,-H<U!J4429(0)Z8#]@\\3R_N58#[R[C<\\/`#/?NGK,"86I=R7(KQK_]SN\nMPF,>?16GEU;Y[O>/4JNMLK*T2*NYA5**D=%Q=LWNHSH^1:E<HEPL4,QG\\7T7\nM`1)CZ?4#VIT>G6Y_D+PQS<8F2Z?O8V7Y%*[K,3=_D.&1,1#(^!Z]?D`4Q1O6\nM\\A(E\\JG8&C[R%Z]_@*W.0WE>E$*)]WC@S7.S4X6;KK^&^TXM\\ZV[?\\C9E=.L\nM+"T2A0'%4ID]\\Q>S:W:.F:D)YG=/LFNJ2JF8QW52SQMC,,82Q3&]?L#Z9I.5\nMM?.LUC;P/(^1RA@SN_=RY-Z[.7;T!^S;?PG5\\2GBQ#!4*M)HM4>B*'X+<,01\nM=>3!]NH'OW'5HQZ'(-/`!ZNCPP=OONDPJ^?.\\XWOWL/2F466S]R',0D34[NY\nMXIK#7'+)I=QXW65<?^TE[)D9)Y?+#-3%$">&)#$D28(Q%J44^6R&L<HPU=%A\nME%)T^P'97)[JQ!3=3INE,XOD\\P5RN0)*A&(A3Q"&8R`YX%\\//>:6Y-MWW?G0\nM`)[S\\M<3)XDHK5Z;\\;UG__R-UZ&4XBO?_!Y+IQ=9.K,`6';OW<_5UU[/M5=>\nMRDV'KV3W=!6E%&$4T>WV"8+P@LX;0S(H9G&<$"?)(-$5P^4B^5R63J>/*,U8\nM=9)6N\\G*\\BE&*J,XCDLVZ^,X#F$8[E,BWQ,E)P[=>`O?&H!X`(644KA*K@*>\nM?V!^ELGQ43[_Y6^SMKK*RO))K#',S,YSU36'.7SM95Q^<"^.UH1AC,4B6#8V\nMU@GZ`8DQ6`M(*J&>YZ6RJ5+M3XS!&,-0J<#^N1D63JV@E'#EU8?X^EU?X-3B\nM<2Z]_!JZO3XC0R7Z_:`81O%O6\\L7E*+S(Q%XWN^\\D2B,13OZM85\\[I:;;KB6\nMY=4:]QPYSLG[CM#IM*E4JEQSW8U<?]WE7'%P#H`H3H@3@U9"=:3`N=IYFJT.\nM01#2Z_?I=KHT6RT:C0:==H<HBD$4%CN@E\\%U%)[KTN[T<%R/?"[/XN)Q,IDL\nMA6(9UW7P?8]^/YP2X6LB<M^A&V_FFU_Y[(4(B!+\\K#N/Y6ESL]/DLC['%TY3\nMKZW2;&[A>3X'+KZ"RR[>S\\%]NXD'O$XUVV"M(C&&(`CI]GJ8Q`P^8PC#B%:[\nMP^96DTZGAW(<IF9F&!FIX#@:WW/Q/)?1D3*U\\UM,3$XS,[.'E9735,<GZ?<#\nMAH=+-%N=0AS'3S?&W.DXCMFAT`M>^<<(8*U]O.LY>_;OW<7R:IWSZQO4:V>Q\nMUC(^.<.^??LXN']WZODHWB[_6&.)XX0CQQ8Y5ULG#",2DQ!&$6MK=4Z>6F)]\nMLX$Q%L_W\\7V?;C]B?K]&:8T@>*Z#[[OXGDL4"_L/7,S:EU;8VEK''Y\\""X5\\\nMED:K\\UBMU"2PL@-`!*RUOH@\\J50L2+E4X.C"*;:VUNEVV[BNQ^R>?<S-3I//\nM9E+CS?VKIF%]?9VUU56B*"))#(U&BWN/'.?TT@H@9+)9,ID,ON_C9WR,28BC\nMB)SO88PEC&*"*,*2JM5(I4)U?()Z[1P3$U-$44PAGZ/=Z<U::R_=!J``E"BT\nMTC,B<O7XV`AA%+.^V:#9V,080ZD\\S,S,#!-C(\\1Q,E"8"]UD*>\\3!5TZG2Z]\nM7L#)TTM\\[HMW<>S$(M:"G\\G@^QZ>EUZ^ERI+',=HI7&T0CL*K=2@X5.XKLO,\nMS"SM=BM]5I*D;;KK9)52EVNMN%\\$!.`2I62B.CK,YE:3;K=+N]5`1!@=JS(V\nM6AF$-]YIO(P%UU%,5,O$X10+]YUF8?$,W[_G*/T@(#.@R[;AWOU`>)Z'`%HK\nMK!7$6*P8Q%A$TLA61L<0@:#?IY`OH!V-ZS@88^8\\U^6VM_QE"D!KA3'V$M?1\nM7JF89ZVV0;_?)PCZ:.TP.CI.J9!+&[+8[%`'($D2OGWW<8X?.\\X]1TYPY,@)\nMHCC>,=+U/#S/'=RWWW/Q/`_'=5(`VT8;008@C#7D<SE\\/T,8]A$1M%*XKD,4\nMQV-!&&JE5.*\\]`_>3C'OT>J$>US7P75=.MT>8=@G21)<UZ-4*J.U(HX3C!WH\nM^Z!-J-?KW+>PP(D3BQP[L4@<)SBN^P!/>]X@"N[]H^"3S^5PM,:(0:S%B$4,\nM@`4+KNOB^3YQ'*.4H)3"<30BDM=:*Q%)'"5"HQEHQU$CCN,@(H113!+'6&MQ\nM/8],)D.2)$3Q]I"2GGZOP^F3BRPLG.+8B9/$\\:"5=ET\\WWN`UW<HY*:ORT,E\nMBJ4"((B04@>+$4`,8A1&IWFQ762U4FBE44H2:U/J*U&"TB*B5$8I-6B^3-JG\nM2CI):<<A"--Y-D[2=J!4R'##-0=XQE,?AS4Q01"FR?=@HP<4VHZ`Z[F4RR6J\nM8Z.X3DHAK51ZUP],Y&V*>IZ'UGK@?5"B&I&)$A'!44JPB!61**6%18G@:`<1\nMM</U,(P(HVCGAYN='HO+Z^R=&:)2*2,R"+GGX?G^@^@R4)^,SWBU0G6\\BN,X\nM6&L'R2M@#&"VA1&P)'%,%$?D<CE<1^-HC4VCL5;*%4P8QBA!\\?7/GDN4DBUK\nM#5$4H1U-)I-!*SV0RX@H20B"=$A/DH1VI\\^)TVNTVST*N2R.XS[0X_[]DS;-\nM@7PNR^3D.-ELYH+'M=JAQS;'':W12M'I=C#&4,@7\\#T/E8H-2LF"M7#[:U^&\nM0L/CGKP;)6HI,99^$.)['KE<'L_SB*.(;J>%M99N/QA0R-#M!01AC$4H%O.X\nMGHMV4A'(9K,IE=P'4LB*8JO13A5E8&1*']D!D<OZ**U02JC7:N2R.7+Y'+FL\nM3Y(6SY92ZM[M?9EZ_]M>DR:1R`^!N-7NDLOZ9'-Y"L42B4DX?[X.0!"$Q'%"\nM&$8$880,*%<JYAD>*G'UY0=XSJU/X'G/?"*E8N$A\\R$((OK](/6X'EPJ-;B0\nMSY+QO'3UDL2<75UA?'P"W_,I%'*$00AP4D2.BSRHD(EPCXC4MYJMR9G)*AG?\nM8VQLG/7U.N?65@GZ?3S7H1^&:1LQ^%Z4)-SXZ"LY<&">H:%A\\ODLU9$<]QY?\nM8FEU8T"E"\\5,.PZ]?D0^EQTHC,%:(9OQJ0P76:MMHI6B7J_3;K>YXK(KR&9\\\nMLK[/6FT=@;LV-C?KE9$1=EH)$<'"*:7D>YU.#VLAD_&9F)@DE\\NSM;7)ZNI*\nM*K%AO)/HHH3EM0:;7>C&+B=7&RPN;P#"%9?,I?QW75S7';3)&68F1A@?35MD\nMI11*A%S&9_=4E2B*":,88PQ'CQYE;'2,<GF(H7*!.$D(PJBKE/K,1+5J'247\nM`&C/P7.=GHC\\4V*,:;3:E`IY2J4RT],S)$G"L6,_I-OM@K!-.42$VD:;E7J3\nM7A"C1(CBA/6M+@?WS5`=':98R#-9'>;2_=-<=_E>IB<K9#(^2J7?+Q7RS,].\nM(0(;C39*":?/G*%6KW'1@8O(97V&RR4:K3;&F&^)R%=%A-M^]_D7`+SSCUXQ\nM*"CR+R)R?+/1&O3H'GOW[J-8*E&OU3AZY%ZP.Y1++R4H2:\\TL83:9I>1H2*W\nM/ODPO_S$0SSV\\*7LFADG3!2=?KKL<AV'Z?%1+IK?A5**L^?6,<;2:#3X]G>^\nMP_S<')5*A;'*<"K;K4XD(G>XKK,E]]NE[$QD/_?X7Z*0SS?B)!FRUOZ"XVBR\nM&1]1&JTUYVKGV-C<8*@\\1*52V>E-MDN\\4K)3D&)CZ?9C@@2Z@:75BPGBM`71\nM*O7ZGIEQIJH5FITNBZ=7Z?5#.MTN__[%+Z*UYNJKKF9XJ,34^"@K:W6:[>[G\nM!=XJ(OW??_EO[`#8KAK\\Z>M?01`$B,C'1.2[S58'$<%U'?;,[F7OGCG"(.`;\nMW_@:2TM+;*O`0QUC+!O-/IO-/KT@];CG.)2*.68FQMB[:X)2(<_9VCH+IU;H\nM!2&M=HO/?^$+=+M='G7=(<JE(K,SX[0Z738;K741_LQQG$UYT"KK`5N)Q][R\nM5#S7:5IH(#PI,=;+97VLA='1,;K=+O7S==;65LEELU0J%1RMTY[D?I%0(FB=\nM%J6,YU'(9=*<*N1Q'8=6M\\?IE7.LU3<(HYB5LZO\\V^<^3QB&/.;Z&QBMC#"W\nM>PJE%`NGEI,@"-^1Q.9C2BG[RI<\\\\[\\&\\*4[/\\--MSP5K%U06HUB[:-`Q'4=\nMM.,P,3Y.'$?4ZG66EI?H]7L,E8?(Y;)HK78VSC(H2K[GXOMNV@)82Z?;H[[9\nMX/Q&DVZOS]96@^]\\[S_X\\EU?I3(\\S`V'#S-:&69N=IILQN?HPFE:G>['@3<Y\nMCNZ_XD6W_DBT'W*U>/N??Q@+XUJI#VNMG^*Y+MI1*%%8:U@\\N<C18T?I=#H,\nMCXQP\\**+.+!O'Z.CJ<(X6J<1&%1;4;(S0X1AQ/KF%L>.G>">(T>PQG+Y99<R\nMMV</I6*!N=V3B`CW'%MD8[/YC\\;:EPNLOOQYO_J0=/V1U2*DZN)HYYRU]E5`\nM(4F2QXF`:$$[#A<?O)BIJ2D6%A986E[B&]_\\)C_XP3U4JV-,3DPP,5YE:*B,\nM[Z=R:8VET^U2/[_.\\LI95L_5<+3FP+YY]LW/4RX6&:L,L7MZG&:KPP^/+YI&\nMJ_UI$?D]1V35Z/BAS/RO(P#PMO?<,1CW[+Q2ZMU:JR<[6BOM:%RMT4ZZ36BU\nM6ZRNK;&ZML968XM>KX<%7,=E>[ZP`-;B^SZCE1'V[-[-S,PTI4*1<BG/[JEQ\nM<EF?Q3-G.7GF;+?7#_\\:[%N!\\XF!E_WFTWYR``#O>-_'D)2_8UJIURBM7JJU\nM*KN.@^>Z*>\\'7:0UAB`,:+?;=#H=@C`$TD$DX_N42B7*I=)@3/0H%_,[B^"U\nMVCH+)Y?9V&H=-R9YN[7V$X@$+WK64_X[\\WX\\@.WSK@_\\'=985SOZ%J74J[52\nM-SJ.]CPW74BYCA[,"3+X^TAV"IRH"[-L-N-3+N89&2KAN0X;6RU.KZRQL=FH\nMQW'R#Q;>>^S$VK$#\\^.\\\\%E/?CBF/?P_^=[U@4_BNY!8.ZR4>JI6ZKE*J4=K\nMK8NNZY#Q/3*^EZY/7!?7<7`<C>OH%*3K(`C](*31;+/5;)MNK[^4&///P!W6\nMF+L1B9[_C"<]7)-^,@#;YST?^02^]DE,4E1*KE%*/5$I=;U2LD\\I->9H[3N.\nMQG$<M)*TX`DDB;%)DO23Q)RUUGX?^"QPIS%V483DN;?^XD]JRD\\'X/[G`W=\\\nMBL087-?)*:6FE<@^43(K(M,B4A01$<$*TD1D66`!6##6KKF>$S;K;5[VXE]Y\n>)";\\[/SL/-+SGVP_9I&"BT+8`````$E%3D2N0F""\n`\nend\n
105965
 
6574    coin_clock_48           begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```46$E$051H@>V::8QDUW7??^?>M]1>7=7[/CMGAK.0,]PI\nMBQ07<RA;CB`1$A(GLJS$BH$`=A#!%)38AD+!2N`$<6([L&!8L9$$B1,D%&%'\nM"\\7%)$U*%(><H4:SL&=Z>GJ9GMZ[JFM_V[WY4#U#4F1B.W*4+SG`PT,]/+Q[\nM_N?\\[]ENP?^7_[<B?UT?^OC/?8XXBG!3*4^$(I:"A;2(7%^C@TC-6EN+$]L1\nMP7[M#W_S1U[W1P+PV&<>!U`B#(,<M];>!1P!)D6D!_"O`Q`A!-D"KHIP`>2D\nMP*L6.R\\0_N??_V<_/@#;BJ=%Y'9K[2>`AY12.WW/]5(IGY3OX3H."!AC,<80\nMQ3%1%!/%,4EL,-;&8)>`5X&O`<_N&RNO79C?X+_\\_I?_[P!X[#./8ZUUE%)W\nM6FM_641^,I-.%?M[2_3WE4BG?.(XH=7NT.X$A%%$$B<8:S'6@K58:TF,(8IB\nMXC@A21*LM9&%-X&O"#PI2#4V,?_I*W\\QD+\\4@(]]^E=P78TQ=ASXAPB?RF>S\nM?;LF1QD9ZB.*$U;7-EG?K-)J=8CB:%LQ<V,)K35**932B!($$)&NAY(NR&T@\nMSP%?,DG\\7:6T_??_]HD?#<!C?_=QC+7*4?I!:^V7?=\\]OGO'N-RT>Y(@C)B^\nMLL#J^B:M5HM6LTZS4:/=;A`&'9(DOK&,U@Z^[Y/.Y,@72N1R!5S/1X2N\\L9B\nMN7&_BN77$/XC$/_1;W_Q_PS`)_[>Y[$65RGY>2Q/])9[!F^_Y2#%8IZIZ5FN\nMS%]C:ZM"96.5ZN8:[7:3)$G06N-Y*3S?1VL-@+66*`H)PQ!K#'XJ1:D\\0/_`\nM,-E<X<8[UR]C;`UX`OAM(/IW_^;7_VH`/OD+7\\!:ZXK(+XG(%R?'AW+WW'Z4\nM1J/%&V?>8G5MC?75:ZRN+!)T6BBE*11+]`T,4RH/D,WE<;VW`6`M29(0!&VJ\nME0W65JY1V5S%6A@8'&%D=`>I=`9K#$HIDB0A3DP3[#].++^K!//5W_JUOQR`\nMO_G9+V!,+$JYGT7XEWMW3>0^<.<MS"TL<>K,6ZRN+K&X,$.]5D4I1;EOD/')\nM/0P,CE`H%BCF<^2S:7S?18#$6-J=@$:S3;/5V=Z\\,;6M"@MSEUF\\.HOK>NS:\nMO9]2N1\\$4KY'NQ,01?&FM?R"$GDRMH:O_JM??9>NSOM97I1"B?<@\\,5=DR.Y\nM^^X^QN79JYQ\\\\SS7%N=87)@A"@/RA2([=A]@?'(78R-#[)X89GQD@$(^B^MT\nM+6^,P1A+%,>T.P$;E1J+R^LLK6[B>1[EWG[&)G9RX=R;3+WU`_;L/<C`X`AQ\nM8N@IY-FJ-\\I1%'\\)N."(NO##^NH??G#+'?<CR"CPE8&^TOZ'[KN+I95UOG?J\nM+`OS,UR=OXPQ"4,C$QPY=A<'#][,O;<=XN[C!]DQ-D@FD]J.+H8X,22)(4D2\nMC+$HI<BF4_3WEACH*Z&4HM4)2&>R#`R-T&HV6)B?(9O-D<GD4"+D<UF",.P'\nMR0#?NOT##R>OO_+L^P/XV5_\\5>(X$:75XRG?^UL?NO<VE%*\\_-II%N9F6)B?\nM!BP3._=RZ_&[.7[T9NZ[ZR@3HP,HI0BCB%:K0Q"$;\\=Y8TBVDUD<)\\1)LKW1\nM%:5BGFPF3;/9092F?V"8>J/&XM59RKU].(Y+.NWC.`YA&.Y1(J=%R:7;[WV8\nMD]L@WD4AI12N)[<`G]ZW>Y+AP3Z>__/765Y:8O'J%:PQC$WNYI9C=W'7\\4,<\nMWK\\31VO",,9B$2R;FQL$G8#$&*P%I!M"/<_KADW5C?V),1ACZ"GDV+MKC.G9\nM1902CMYZ.Z^^\\@*S,Q>Y^?`Q6NT.Y9X"G4Z0#Z/X%ZWE!:5HOL<#G_H'OTX4\nMQJ(=_?E<-O/P??<<Y^K2*F<O7.3*Y0LTFPUZ>P<X=MN]W'W;88[LWP5`%"?$\nMB4$K8:"<8V5UG5J]21"$M#L=6LT6M7J=K:TMFHTF412#*"QVFUX&UU%XKDNC\nMV<9Q/;*9+#,S%TFETN3R15S7P?<].IUP1(3OBLCEV^]]B-=>?N9M#X@2_+2[\nM&\\O/[)H<)9/VN3@]Q]KJ$K5:%<_SV7?@"(<.[&7_G@GB;5YW8[;!6D5B#$$0\nMTFJW,8G9?L<0AA'U1I-*M4:SV48Y#B-C8Y3+O3B.QO=</,^EKUQD=;W*T/`H\nM8V,[6%R<8V!PF$XGH%0J4*LW<W$<?]P8\\ZSC..8&A3[]2_\\4`:RU#[J>LV/O\nMSG&N+JVQOK')VNHUK+4,#H^Q9\\\\>]N^=Z%H^BJ^G?ZRQQ''"A:D95E8W",.(\nMQ"2$4<3R\\AI79A?8J&QAC,7S?7S?I]6)V+U7H[1&$#S7P?==?,\\EBH6]^PZP\nM_-(BU>H&_N`(6,AETVS5FQ_42@T#BS<`B("UUA>11POYG!0+.=Z:GJ5:W:#5\nM:N"Z'I,[]K!K<I1L.M55WKPS:QHV-C987EHBBB*2Q+"U5>?<A8O,+2P"0BJ=\nM)I5*X?L^?LK'F(0XBLCX'L98PB@FB"(LW6A5[NUE8'"(M=45AH9&B**87#9#\nMH]F>M-;>?!V``E"BT$J/B<BM@_UEPBAFH[)%;:N",89"L<38V!A#_67B.-F.\nM,&]7DX6L3Q2T:#9;M-L!5^86>.[%5YBZ-(.UX*=2^+Z'YW4OW^M&ECB.T4KC\nM:(5V%%JI[8)/X;HN8V.3-!KU[EI)TBW372>ME#JLM>(='A"`@TK)T$!?B4JU\nM1JO5HE'?0D3HZQ^@OZ]WV[WQC<++6'`=Q=!`D3@<8?KR'-,S\\YPY^Q:=(""U\nM39?KBGOO`.%Y'@)HK;!6$&.Q8A!C$>EZMK>O'Q$(.AURV1S:T;B.@S%FE^<X\nM//ZEW^D"T%IAC#WH.MHKY+,LKV[2Z70(@@Y:._3U#5+(9;H%66QN4`<@21)>\nM?_,B%Z<N<O;")2Y<N$04QS>4=#T/SW.W[]>?N7B>A^,Z70#7E3:";(,PUI#-\nM9/#]%&'804302N&Z#E$<]P=1I)52B?/9SWV9?-:CW@QWN*Z#Z[HT6VW"L$.2\nM)+BN1Z%01&M%'"<8NQW?M\\N$M;4U+D]/<^G2#%.79HCC!,=UWV5IS]OV@OM.\nM+_AD,QFT4EBQ7:7%@%&`!0.NZ^+Y/G$<HY2@E,)Q-"*2U5HK$4D<)<+65J`=\nM5Y4=QT%$"*.8)(ZQUN)Z'JE4BB1)B.+K34I7.NTF<U=FF)Z>9>K2%>)XNY1V\nM73S?>Y?5;U#([3[OZ2E0*A?Q7`<E7:63I)NMPS`BC&*L,=?IC5+=/:*51BE)\nMK.U2WQ$E*$=$E$HII;:++].M4Z7;26G'(0B[_2QTS5\\N9CEV8)2#._MYXL)%\nM@B#$=9WW*KU-H7=Z8&B@GUT[Q\\EFTL1Q1*O5HMWN$,<QUH+G:#S'Q=&6\\=$1\nM7"^-UGK;^J!$;7623N([/HY2@D6LB$1=6EB4"(YV$%$WN-ZU2H12W=U?:[:9\nMN;K!SK$>>GN+B&R[W//P?/^'Z.+ANA[97(:]>W8R/CI,H]'@]9-O,'5IAJ7-\nM&NTH`00MED+*9;B_Q/CX&(</WDP0AB1&<!P'V_7&<B&3,V$8XX#B&\\\\L)7_C\nMT=&JM88HBM".)I5*H97>#I<149(0!!&>VYTV-)HQ:QM;]/?XY#)I',=]M\\5_\nM2/E"(<_1PP?H+1?Y_IMG>.Z5DUQN**1OG-+$3>1R&>(H(@&6FPWFUA;Y_LQ)\nM=@T4V'_37E+I-*U6:[NJE6EKX8G/_WT<I>%C/S6!M78^,99.$.)['IE,%L_S\nMB**(5K..M8.T.@%*"8@0!&&7IPCY?!;7<]%.-PBDT^GN1G:[$2>;RW+HYGWT\nM%/,\\_?1S?/O4-/'X$1[Y\\#$>.#1.?66!6FV+R"KJ]0;%G<>YLEYG:G:12^=>\nM9_V[KW/TT'YRN1R)H:Z4.GNC`/V=W_@51$!$+@!QO=$BD_9)9[+D\\@42D["^\nMO@9`$(0W-ED01L@VY0KY+*6>`K<>WL?//O:3?.H3CU#(YW`]#]_WV;M[!WWE\nM$L\\__R)?/W6%PFT/\\X6?>Y1/?6`/.5_3BA(J6W6:[39H1<I5[!W(\\Q-'=G/P\nM0R?HC!S@U)GS5*M5HJ`=U"KKG7:S_G8U>L_])Q`1JT0>4TKRO:4B]4:+(`C8\nMV%C#&LODY$Y<ST64=*,1H)5B>*#`V%"9HT<.</MMMS`Y.<;^/:-<F5NFW@P8\nM&NKGIKV[.'?V/$^^=)K,T?OX[$.'&2RF6*F'-(*89K-)&`8D482?+V&\\#.WM\nM7B*K$U)#$VQ4:U3G+U,L%C)1&)HW7GOEZ3OON=]L`W@4"TVMU0=-8O;VEGKH\nM!"%*:5975V@VFY3+O?3U]6.-[6XVI5!:82U$1M$(+.M;;1JMD+'!(G&<L+"T\nMR;X].\\$:OO;U9U@I[^?OG+B'WA0L+JW@IK/$QN)F<F3*_439,BN1PTHCH!K$\nM5"H;U-:7N7;^%#T[#U!=7D:'+?R4/YG.9)_/9O/7%(#V'#S7:8O(GR;&F*UZ\nM@T(N2Z%09'1TC"1)F)HZ3ZO5@NX60$00$58W&RRNU6@',4JZWMFHMMB_9XS1\nMX0'R^2P7SK_%Y3H<.GR(B7*&Q$DCKD]E<Y.$;M-_K=9A9J-)*TYP7(WO:9)6\nMG?-__BWJU77*@P,,'CG.9K5.',7](OK#$Y.[NQ1ZY?EO\\($'?@H1UI12C\\9)\nMTE<NY@G"F$PFR]KZ*EO5*J[C,#HRAM9J.S,*2E]/,-TB3$1A$7:,ELCGLE3K\nM;5[^SFLL.(-\\Z,ZCE+(N,<*Y4Z_QS!__`8-C$T3I(M?J`:ZCR*9]?&5ISYYE\nM[?Q)QH_>R<'[3G2S>3I-=7Z&E+(D21+^X,RI)V]T9#_QX(?)9;-;<9+T6&L?\nM<!Q-.N4C2J.U9F5UA<W*)CW%'GI[>V_4)M=3O%+=WUHK8F-I=6(:K9#UC2K?\nM>?T,T?!-W'%@'"T0&TN^W$>KU63ZM1>IU.KXY7ZR:8]H:YWY5[X%49M]]SW*\nMR-[]N%H0+*[GTUBYANHTB),D#L/@O]\\`\\/+SW^#>^T^`R!6EU/UQ'`]G,VF,\nMM13R!<(P8&-]C?7U-4JE,J52"27R+@#7[R)"$"8T6VTJFQ7>.#^--W83?4F%\nMVL8*J4(9[?F,WW0S2:;`:T\\_Q:67OLGFI3/,??\\DNXX>X_`#'Z94+N$Z"A.T\nM6)OZ/NE\\@:!>P]8JQ%$<@OQ7Q3M%!,]UKHK(;QIKF[5&"]]S<5V7PX>/,CX^\nM2:U>Y\\677N#BQ2F,M;Q]?O$.L;8[\\S2&,(JPMEO+M)H--A9G:0<=PL00)8;R\nM[L-\\\\.?_$>U.P*O??(IC#YW@SD=^FE(Q2R[MD$^[]!3S>-JBXP[IE(_K.B1)\nM(G&<R+O&*B\\]^S^X[^&/@+732JL^K+T#1%S703L.0X.#Q''$ZMH:"U<7:'?:\nM]!1[R&32:*UN3)QE>T]$842M5F=J>I:X;Y+Q@1Y\\SR/=-X(5H1D96E%,L=3#\nM_F.W<V]/PI'['R;3VT_:4Z0\\!]?1A,TZC<UU"GV#U%=6D%:=2K6ZMKFY\\8?O\nM&6R]^,R?\\N"C'TV`4TKD@(5](H+2@NMZC`R/D$ZGJ50K+"PL,+>P0+O3P?>Z\nMK:+C.%TJB2((0QK-)O-S\\VRY189V[";7.TADH1[$-*($S]6D/$W?T""3/2GR\nMM6OXNP^1]9PN`"VXOD]Q<`3EI5B=>@L=ARPOKTW5MBI_\\!X```^<^!D<QVD"\nMKXG($6#'];"I'8?!@0%&1D;02E.I5)B=FV-Z^C(+5Z^RL=$=M7>"D$XG(`XC\nM:M4J2Y46C<(P]3"A$29$!CRG:^64ITFY&K=8)G_U+/[X'K*%/)F4T^T7`*TT\nMM?5-JE<NDX0=YA<6O_G2,T_^M_<%\\&=/_PD/G/@H6NL*\\+*([!21O4I$1`E:\nMA&PVP]CH&./CX_04>S#64MVJ,K^PP,7IRUQX:XKIF1D*^3RY;);%V1F2\\B@Z\nME<%1H%N;I-,I_)2'[SKXKL;/Y?";&Z3B-O[H3I)V$T2A14ABP\\R9<_AAF_GY\nMJ^'2\\O*_V'?P^/GW!0#P_+>>XN%'/XKJ@GA6=5UP2(244@I':[16I#,9!@<'\nMV;5C![MW[6)R8H+1X6$&!P88Z.\\GE\\WB>R[MK2K5RA:IX4F<L$Y*6_Q""<_5\nM>(Y&DA!)0OQ\\$7WA.ZB=AVBTVK0J%?+Y`@MSBU0N3^.*X8W39[Y7K5;^N4FB\nMUO\\2`,"SWWR*9[[Q)"<^\\EC+6ON"4NI-$1D!1@&ME,)UG&X#XKJD_!3%8I'^\nMOGZ&AX<8'1ZFV%.DV6SA.)JM:W-$!K+#$Z2+)1RM<;3@*%@Y]P;$(?F)W3!]\nM&E&:OAW[R*?37%W>8.[-'S#2D^,[KYYLSLTM_)-BL71R<WWYO=/I]Y-O?_U)\nM'OG()XWGR"6+_1,1F1+(&VO[$V-\\8RU:*WRO.XS-9M+DLQGRN0R]/05ZB@56\nMUS?P'8?&M5FBQ)`I#Y#/IDA[#HXUU!=G,%'`V.1.^@HYBO459'@/E^>763A[\nM@1U]!4Z?/F.^=_+4[]6V*K\\;QV'R@S=>_*L?L_[KK_XQOO9)3))72HXII1Y1\nM2MVME.Q12O4[6ON.HW$<!ZT$D6ZJ65U;M_.S<Z96J^F-RA9)H9_2OL,,CH\\Q\nM4,YCZ^MDM&7?OGU8:]C8J+"^LH:M;C)8S'#RC=/)\\W_V\\G^H5BN?\\WU_\\_2K\nMWP9^Q(/NW_NC)TF,P76=C%)J5(GL$263(C(J(GD1$1&L(#6EU/SYLV>I5*J_\nM;*T]%`0AB2B\\8B^9WCZRQ6)W<*4$%8?X)B;O*L*@S<G73S?/GGOK*_7ZUF^X\nMKE\\Y<_+M\\X&_MK\\:_$7RTQ__V]QQQT-<NO3F35H[GP/Y&-#;/1!TNR/'[3;4\nMT8HP"%E:7HEFYQ=.;6QL_E:GU7C*\\;S@W!LOO.N[/S8`U^6CG_P,0=#Q,IG\\\nMK2`?L=;>;2T3(N2,M21Q'`5!N-9JM<ZT6NVG@Z#]7*EW<&WYVBS3Y[[WGN_]\nMV`%<ET/'[Z51K\\CXV)ZLZZ7Z73^5B^.8=JL5-1JUC7JMLNGYJ63JS'?_M]_Y\n5G^JHSUJI.-;(`````$E%3D2N0F""\n`\nend\n
105966
 
6575    coin_stack_zoom_48              begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```/^TE$051H@=69>:QD1W7&?[7=NG7O[>ZWS/+>C&>QQPO&\nMF,48L1I$6!P,.*QRA&2R*'\\DY(\\D(H1(*$@018I(%(B0B!0I1`I1(@))P!!0\nMG&0,=L#$NSUX83S>9][SF[?V>O>J_-%O!HLQC!7LD5+2E5JEKE9]]YSO?-\\Y\nM#?_/EW@N7_K01S[-QD9?G+=W9R)%Z-5UW6O;UGKO!0$"(4@A"Z5U7VO3;UJ1\nM2TGXXF?_\\(6^_T\\'\\/I?_#`K3Z_(-[[I]1?TNMF;\\GSRFO%X?'%5E0L@>DK)\nM2$HI`$(@A!!*A.@;;99B%S^4)NGW`]R\\M'3RJ31UX8M_^<ES`^"]U_\\^O=F4\nMR:0\\>.C@>;_M??/^$\\>/'ZBJ4AXZ=#X777"0F5Z7.+;4=<MXDC/)"\\JZ83`<\nML[&YQ6@TA$#;Z_6.61M_.2^*OS9:GY@4)9_]].\\]KP#T3VZD'<=@F"]><FC_\nM%[,T?O/--W^7`P</<OV'/L"!?7O1$AX^>HP''GB(QYXX3EY4Q"YA87&1W8L+\nMS,WOH*IK-C<WU/+2B4O.VWO>)[-L[HK!</RK,]W.^O-Z^V<#0/!(VI?TNMEK\nMU]9.,AP-N>***]@Q/T]_,**<#/G6OQ_FOON/DG4R9N?FZ?0BTC2AFR5(*9%2\nMLKAKGO%P@!2P8[9WU>;FYB$1U`L/X)[;ODM9%"[60;WT92]C_[[]W'''G0@A\nMV+5CGLA(7OG*RUG8L\\CY!\\\\CSTL0BL7%W72Z'6P44545/SKV.#.]#A=>L)^[\nM[KQ+'#Y\\6%H;/=_W/Q-`?W,=0-[ZWS>QN;'&)9>^&.\\#]]__`(\\ECFZOQX[Y\nM60X>.D0<6^;F(Z22:*7))Q-65]>8Y`5:"7;MF./FFV_AWGN/$#!4U7,J>C\\?\nM`(`0?"`$CC[X(,>??(I="PLL+.ZAJ7O45<UX-,):BXTBM-%$QF",04B)4HJJ\nMK%E>7F;IQ!*;FUM8ZQB/1G@A7W@`35T#06`A[7000K&VNL[FY@#G$K).1I9E\nM)&F*<X[8Q<1QC+4Q-HY)DH2V;1%2DW6ZE&7)VNHR=5TAY3D`8&-'"`'O`U69\nMTYN=)TDRM(Y0VA!%!KG])H40*#%-G]A:DL016TM1EH3@*8H)H]$`I2+2=.8Y\nMRN;/":#()T#`Q@G>PV!K0%E4I)T.G4X78PQQ$N-<3&0CE-$@!77;,)[D5$U#\nM7=549840"FL3JG*%S?63B',2`1MO?PJ$T!*[#EI'-%7+>#3!MX&F::CKAJ1I\nM\\6U`(#':$!E#EJ3443U]$7W/9#)$2,7LC@7$"Q"",UY)VS8T31V4-A`$95'@\nM?4MD#4GB<(DC=FX[[RV1-6BCD5+0M"WC/*<_'#$:CZFJFCA.L39F,NZ33P;/\nM.X`S(N"]!X((;8OMQ&AM:7T@GQ2$`"$$$.*T8`DI$5(AE4)K@]$&E4B:LD-;\nMU^3C$64Q1@@)XAR4T<C&A!`"4E(6!;87DZ0=(FLQ)MHNGQ9C#)&)L%&$LY;$\nMQ20NQAA%7M245<EH-&22%T0V)6X%XEP`*"9C`H$D[:*T(9\\4U+4G25/2K(.U\nM$4I)M%8()0A`XUN*LL2'0-1ZFJ8A!+"1(TTSMC;7Z6^NGJ,RZA((01`\\4D"G\nMVT$I`T)2U\\W4.B`)`$&@I"(R$4HJG'4D:4)3UU3YA*$,Y/D([V%F;O<+D4'/\nM)F05A!"L2ZFJFN%P2)I-2^AI\\8I/"=B4S)&-4$K1^H9)GE,4.8/1B*(HT3HF\nMBB(&6\\OG)@*!``3A?8MS,5K'-'7#H#^@JFJJLJ9.6YJVI6T]K??X,#TEI<3&\nMCB1)J8J2IJH9CX93$DM];G0@,G;[,HJB*.AT8](LPUJ'B2*BR!)%$5$T)7!L\nM+<Y.A2UQ#J-/D;A@-!J0;Y/8UN$<D;B8$$(@=BFQ2BGR@J;QN*0AZV088Y!*\nM(I4$*?#!4[<-HJSP`:*VI6T:0&+M-!KKJROT^VOG)H7B."$P]3DA>)(TP1B+\nMD(JF;BF+$B$D0@@D4Q]$%-!2XFQ,FB94V_7?^X;Q>(!4AKGYQ=,DOOY7?@-C\nM(O;N/V`GD[$MRZHMB[+\\ZR_\\1;-CQR[6UU>?,X`S8KKGP$6$$'XICM.O1#8V\nMQEA<DI)V.J1IAG/),USHMB)OJ[*)#%H;RK)D8V.=_N8F@_Z`DRM/#U97EJY.\nMDN0'OWS=^_7"GCVO:-MP[6@TOG+0'\\Q65=4T;;M<%,7W^_W^-V^]Y3O'SC]T\nM8?CZ5[]T5@#J)S=ZLSN10EPJA/A@G*0JCAT@:1J/;[<)&TY!GXJ3V%9F8R*2\nMQ!$9@V];ZKIAV-]D:W.C#$%^Z3.?^?0PZ_0^L;'9_^Q]#QQ]VY&CCRT^MG0R\nM6UI=G]W8V+JDKJIW&6.NW;VXM]G:VOKA2Z]X;?/@#^_ZF0#.2"&E-2&$H)2A\nMKDHB$Y%F"=8E4\\]OM_U_-%5D:RVQM=-R&AD@4%8EX\\F8T6A(TWI<T@F[=R_,\nMU[7_W(^./7;]=^_^T=;,XMZ'SWO)OG'3U(.UC8V-M9,GQRMKZ]F,EE?NF.G^\nM^=S\\SEW'CAW]D[>^\\[KJ/__MR\\\\]`B[IT#3UI<9$'W0N4P%!T[1X[Q%"HK3"\nM:(TV&J440@J04T4.(2"DQ/M`4S=X[VF:FLWUU>J:=[Q]SWI_^)[#]ST^OOJ=\nM5Y=77'9QYN+(;HUR-2I*$3NG.C,SPV#TH]3-?!R9MTDA']JY:^$!;2S+)QY_\nM;A&(70I3G26$ED[6PT3QU+!)M6VG6YJZQ1N/0*"EPD8169+@$D=5U8RUHFDJ\nMRJK@Q2^YO+-K]\\+;_NGP[>K=UU[3O6CO_,SZ8$SI):V*]NU96$#2!MJF#2$4\nM35%0KZZDW:KZW5%>W/[TD>\\__IY?^QA?^]L_.WL$DJQ+T]0OTB;ZH)!:U4V#\nM`*RU)&E"FJ6D24*2.IR+L;'%1!%:*SS0M"V3?,+&QB9*:7;LV,G!@_O$N"CE\nMINQP[9NN%+4/:&,8URU98IGK).R<[8F=<[,R<W%D;12%X-'![YV=FWO+&Z[Y\nM0![']L$WOO5=[?=N^O;/CH!2TRW?MFBC<&Y*XLDXIVT]==U0)S5UT]`V'N\\#\nMA&T21Q9G'5HJ!M:QL'.6&__C1F9[KV90"@X<N(0`5'7#QN861X\\^3#X>TXD-\nML]V4Q5T[F.]ES,]TZ=J(IYM*#L?Y2^=FNY\\W1O=#"%\\[:PH)*2&$H+2AKFJT\nMKDBSF"1)L;&;DC;>)G(\\);&U$=9&Z&T_-!P-J:L2@*+(B2)+,1PC@V!2UHPF\nM.?W!$*,4Q)8DL?0Z&3.=!&LTUD8X">7&#'7KF9^;Z:RMKKYH_X&#9^=`5180\nM@E#:8&U,"(+)9$+3M"2MGT9):TS;;+>6-5(I@A#X`$(IFKKAGCMN)8[>P)6O\nM>C52*A*C6'KZ)(/\\($H;9N?F<-T.;5-C\\,SW,F921V04<6386-T@C@Q[%G;Q\nMT`/W<_B_#K-S]\\ZS`W@FB=NVIMOI8*U#2HTV!H'`MYZV]00_]3=::9RU4VXX\nM1YF/65M=X89__2J77G8YO4[*WEUSW'''PSQ\\R07L[CF\\]PPG%2&T=)UA4M94\nM98E1@KENQF0\\YLFG3O#D\\>,L+Z_@,6)U]<R6]`QS4A83BGP2A)!X#\\/^@-%H\nMA`\\M461PJ2/-$M(T(4ZF5EEIB0^>O"P9C$<,1^/I;U45]]U[#S=\\_09&HQ$7\nM]C2WWG8WRYLCEM:W>&)EG9/K?997MSBQNL'&,">*8AY^Y#@K)T[PY/%E?)CR\nML*DG(4GB,P"<$0&M#8#POB6*(ER2`I(BKPA^1%.WU%4S+:5-.R4Q`JDTL56D\nM+J'.2@@!:R.2I$OP\\/U;;^.-5[V.K0<?Y3LWCW%SNX@C3<]IJMA`%A.KEA_>\nM?Y3^\\@F6EY:8FY]G/!YR<F6,#XBMS;6S`Q!"3O]QD8JBR)%*D75Z)&E&O$UB\nM>\\H^)PFQ<SCG<'%,%&E\\\\)1E"4)0C"=H9>CV9BF*@F.//,;++S[`(T\\N<?SQ\nM-9KN++*3@;/4&RTKXP%Y?Y.EXT^Q<W&1-K0,AT.DLAAMB9/D[`"JJ@""T*=(\nM[&$T&E%5-4E2D6;9="*G);)2(`4(\\"'0>$^R[0^;ND*(J8KW^WWRHJ0H2E96\nM3G+@P'XN6[2,QD/*]0T*'R@):*T10N"RE'8X1`NPUE&7*XR&F^'9QC(_A<13\nM%C=-36^F@XT3E-)H;9AR8SIZQ(-\\QFAQ*G`)53'!1):B'*"4)'8.K2.$D(S'\nM.8\\]_A3=;I<L2^ED,4HK(AO3[?7(LHQ./>+"T.?(U_^96Y@!Z>C-[A1:GSF+\nM/H/$=552E7G0Q@""X6#`:#B@;9MM8;,DJ9O.0=W4P"FM"`2*JF0X&C,8C6C;\nM%JTCZKJFR'.\\;U!:$MF(R!J$A-9[D`(=68R-:-J645X0%P,N?N)V7L4&;YB+\nMR'S%>#((`7_V"$@I"4%(W[8BG9FVDMY#65:$,*9M/'7=/H/$GH!`2D4465SL\nMZ*090H!2DC3K(*7&MU#D)0+)U(;+J3E4"J4TQAATK,B<HU_-<.2N>[AP^4%>\nMEG0Y8698*PJA1X^>'8`V$80P#(%B.-C*Z$*W-TN:=K!Q?+H?CN-3)(ZG)':.\nM.(X0(E`W-5(JZJJ@R"=DW1YIFA$[MVW)+3;^\\;G31<`80O",=<QME[\\3MWZ"\nMA4?NY*H7OQF]([KX"S?>$KW=1=6->77ZOF>8N=GYW800GE9:;REE+O">V;*L\nM9%E6M&W#M&1N]\\1"`()`H/6>IO4@)/EDPOWWW854&J7-=NFM:5M_>BRIM$:J\nM:6N*F-IQOVW'E92,HXPU(@XN_Y#9<H@^<-%%<\\8N_=WCQ^_^RA]_BM7P4P!L\nMK:^P<^%`TS3M;<9$-RBE[U;:])742BFMI)!*"*FDE$()A=;3\\%L;^\\2Y(DW3\nM]:HH'SUR[]U955=1FF9TNAUBYS#&HK5&J6DO8;293C>LQ6U'-$L2E%*41<X)\nM+)M;6[QX_6&2V$9A\\>`K/O\\''[_CZI>\\Z,F;GCB!?[84`GCX@=MA6HF>O/+U\nMU_Q]\\/X?$6(66!1"[)5"[!)"9*?:22&$!P8!G@XA+*VL+&_F>?YQI<QO3L83\nMUS2>-.N0=2RQL[CD5,K9TU..0*"LJM,SIDF>TWBX=_]KVCV#Y=&KG[J_>\\F+\nM9O=M7G+H3[_Q[9L^]&X7/?$O>?7L`)ZY[OC>MP!:8&W[.7*V,Q=>^DJ`3P@I\nMOB.$O`[$J\\NRV@?CJ#W5$#7MC^VX$"BEB2*!BV.44J&IJHUBG!\\9NNXW'A*=\nM(Q<5QS_;?>3.RU2T[W47[]OYL;]Z:O5W7J=HSPK@_[*./7@G0/[2*W_AAM:W\nMWT*P1PCQ<B'$Y5*("X20>Z2072FE5$JAIT^NE%J50CPAA'A(2GF/TNKH#P9Z\nM].GF4?ZG$'_4ZR5_<W[';(Y-<PO@MS7TW*UWO._7\\6TK7)(8ESB;.">2),.E\nM"8F+Z]BYZIO_\\+GVO1_^.!_]K>M.G_O4A5W&09JKNO(M^]OBR8_>-WGP?9;P\n=D?)<WOX%6O\\+W8ESHCC(@H\\`````245.1*Y"8(*K\n`\nend\n
105967
 
6576    collection_account_clock_48             begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```09TE$051H@=69>9!<1WW'/]WOFG-G=_;P'EII=R6M)$N6\nM)9^R;"1\\88BAL(,+2$BX*N`D90A00`(A4!"@@!1.4:2H%!0$2(!PA3@0;(.-\nMC8U!MK$D2Y:L8W7L:G?VFMFY9]Z;][H[?^Q*%I"UD<"0=%77S-2;U_W]O._O\nMU\\=K^']>Q//=06S[.PE:D;CDNBO2+6/T_O_>4Y-][>C[W_=;:=_ZK;2R3!EZ\nMZQ>9_^:[L'NZ_O#J]?W_U-N1>E5ZS:JI5UR1/3Y[^=^P\\*-__HW[>%X=N/[#\nM_XF49&_>,O2]8JWYDTG?RZA89E6VJ^-6J<*FN>_3U*I5,;KAPMBFBR[VI+28\nM&#^I]NW=W<Q-Y:(_N_UV;KIV^^\\)X+J/P(_^EN&W?'';59O7?RW9><%7-@UG\nM.^N-QHZ[=QV][6VC?B.12+[0=ISM&+-&6G9&*25\\WP\\"WY]J^OZ>>KW^0'YN\nM=N_`X*KF&U]SZ^\\(X`\\^1L_*;LKU(+MEJ.M-5X_V_?ETTUJU8F6?6=63%'N/\nMS)HA+QS;N<(1*HI&2J6RM5`H4*W549%"2D$\\D2"12("@Y#?]^ZN5RJ<./7W@\nMI^T='>H3'_[%W#EG@(^^#HRAS1+RU<E4>H/G>5**"$F(),(FX(0:,3_)OG_3\nM]DT;=G:DD_;NR3HG:Y*A;)P;!P0KXB''CH[Q^.Y]C.4*E"-))!VDE%A&$=,!\nM77&+X<%>5JU:B6U;<]5J]1]FIG.?B<<3C8]\\X%WG#_#QUPNT,K?TC6SY][ZA\nM+5ZM<`SEES!1'5251DMQMW@#]O"MA#+.?&"#$V-MA\\TM*T.LQ@(_^.&#/')X\nMBGK[*E:N74M?-DW2LV@T&D18^,9B-C=%,'&8SJC$Y@UKZ>SJ;#7J]3NG)D]]\nM*!Z/-^_\\V/N!\\QB%;K[<00ASU>J+7_**5FV&)FFR%[^!U.`+2*^ZGF.)&WG4\nMO(`HEL6*M]'7F69]E\\V+>GVHS/&U;WV7AZ=#!J^\\GK^\\[5I>L^-"ND6-9%1E\nM95<;;5&)RR[>Q,!`+U;/$/G(YM333^$);:73Z<LMRVH\\_./[?G;]32\\S3^Y^\nM%/M<`2S+(,$($Z*"$O'>ZUBW[?5T)T$(F'^JP.C!`MFD34=<T)'0C,8#J);X\nM^G_=PQ-ECVM>?!.OWS&*%'!JH<Y</21?JA`5BB3:LOA*D_9L+EJ9I:/M"@ZW\nMM7'@B1\\!QFO+9-Y]Y?:=>]/IS`^V[[SQW`%L"PP@3(0E%$9H'&&(VXO1^*(U\nM";;U"8PQ@&&A6*58JO+`([MX;-KGHNM>RLT;NY@OEM&6AS8&+Y4AVV\\1*45+\nMNN3K`:$R1"V?6%AG9.T(QUL-CNY_A`UKG4XIK7><.'YTU^BZ395S!Y!+`$1(\nMH3#R%Z^W)>.T)>,`**4I+E28SLWPR-XC)-9>S<LN'48)16&^0'M/+\\J`FTQC\nM8DDFRTWR]0#E-Q%28AHUBA-'&-_W.&NOO85\\?IB9F5FZ>[IVQ.+)':[G?4_^\nMJL3G=L"6($R(1"&?91BHU1LLE,H</'B(&9'FDHVK27H62KHT6RT.[=M-J!0M\nMI3FY4&>N%F!;DE3"(^E`?>)I<OMVL6K+-KKZ!NC=M(5:$!*VPK@QO/@S=W[H\nM_$)(B],.:,Q9!+[OH[7&MFW",*14J5*MUC@Q,875M8J1G@Q^J-$(9J=S//"-\nM+[#SYEO)7+B-FK)()SQ<QZ)5FJ=X\\#%HA5S]JC>2Z.@FC!167Q^E]DY:K19:\nMFZTOO?5/V\\\\]B:5!LI@#$HTYRX'Q\\7'","23R3`[.XMP$E2K-0K5!FUKNG!,\nM2*6JL&-Q1C9?AAU/\\-0#WR78]R2]E^ZDL[N;_-1)"F/[&=YR!1LNO@++<6CY\nM`;I1)Y5,D.[NP<Q/HK3JLQRGZSP`?BD'S@)8MV[=F>^#@X,\\>>`(S4:#(#)X\nMGDONZ#ZD5JS8=!F.YS&X;A-.QP4\\\\!__QMW_^#Z2B3@K-F[AIM>^F;ZAU0@!\nMQAB:D<_T\\:?(#*TGV=9&L&!A6F'<]>+Q\\P<PBP!Z*8NT4LSG\\R2327S?Q[9M\nMHD@1*84`A!!@QVCD3Q%&$3@N81BA$VFN^:,W$3:K3/WL/FYXY9\\PLGX#%AHI\nM!<:`;>+$XQX.$3'7P;@.U6I-^\\VF/G<`(1;CWD1(U.)<+D`I13Z?QQA#N5PF\nM%HLM);C`LZ#1"A"I'K*9#,IRT9&B%BHB(!6/<>L=?TW;UD':,Q:N8^'9%I:4\nM:&-0?HUL=S?QKB[R8\\?P7)>@%51+I87J.0-("<8L.@"+3]<8@^.Z;-RX$8#>\nMWEX`U/@DMFV127@42WD*8C4=,8=&-2#"("Q).NY@24@DDZ2V[B"9.X2]\\5+B\nMGH-M29366)U9XND,Q6(5X3>Q;1N_&4SZC4;AW(=1J;&E-I8(L<2B`\\:`4A'3\nMT],4BT6.'CU*N52B7%S`&,,%75G(G^+X;(DC<Q6FRDWJ?HC$(*7`D@()F/ZU\nMV`*\\ZCPQSR$5<TAX#JXMB=D6?K%`3&A:K8!&L_'8YLNNJ2_K0&ID!Q]\\Y^WD\nM9O/I0F%^LS9Z3=SSVKY3M<R`>/S*=>6`;JN,`^C%21>E%$((;-L&(<AVM-.5\nMS=#=TTWFQ"1^<0:3'$:'`5%]`>(K`0]87(:(6(+P@A%BQ_<C5@Q1RL\\C;)=X\nM+('?:%$X<9*.=((C!^=+C4;CGK%#^Y>?!^YXXRO)%\\NKPZ!^9U]/]MK-F]:G\nMYF;GQ7RAA)=Z.6-1R%CM..OUA8QHA64[K%BQ`H#V]G8`,ID,RDC&3TTS/-##\nMT\\?VH+MZ$*[!3G6@I8O6H(V@,C]'5);$^T?Q?_H-1&$;QHVC:A4\\)\\:I(\\=(\nMJ!;56IVIZ>E[:M728U$87WXUNF9T([,S4R^Q;>L]_0/]7D]WES@Y?@K/BS$\\\nMM)+!%?TTHQB5,,7HFF&2CF9BXA1!$#`V-H9E68R-C9%.)<D7%F@&(6%E@7JQ\nM0'Q@-8FV=EQ;8%D"8333^W8A!:0'AQ$S)_`:)2X8W8QT/`X?.DYUXB395(P?\nMWO_0Q.S<W-N3J?3$8P]_?WD''G[P/I2*W)[>`9&?FV=\\?)+>WAXR[6T$K0#?\nM]YF;G:'B&[2^`=MR:6]OQ_,\\;-LFE4HQ,#!`,IGDAA=NQP]"_*:/R$U3?_(A\nMO(NN)+UB@*3KD+"AF4I!O4J/(^B\\ZD9,?HJ90ID31XX3Y><8[&[G.W?=71X?\nMGWC_[I_>\\_C&K2\\`GF4_D.GH1BN]!2%O,4C",*(51H2APB")M&$Z-TVD)5==\nM=05=;1Y""!J-!JE4BGJ]?F9.B,=B=&4SG!B?0"F-].LT9R8(&@V,L/`\\C[9L\nM)^W=/5BVRUQ3<Z*JR1T^0LROXZ"XZWOW+NS;?_"]Y<+<ES[W+U_5!_<^#+"\\\nM`T9K#`:C-5HIM-9HK3':H(W!Z,6JA<&8Q7LJE0JY7(Z!@0&FIJ;H[>VE4"B0\nM3":Q).S<?@F'CTWRQ)ZGD(TF)C=&I3"%GVXCGDKA>1XYV\\*3D'0L;`&')B?9\nMO7?_P5QNYN_JM>)=\\61*'=CST!F=RP(((1$H$`+#XEAOC,%@P!@,+$UBX@Q`\nM3T\\//3T]`'1W=P//S`D`0T-#7+1Y"T-#PSSTDUV,3TS@URI$S3I1R2%P;6S;\nM)5+0;)0H%&9FIW+E?ZTW:I^]<,LU1Y]\\]#[.%O_L`%(@E$!:$LNRD%(BA5S\\\nME!+;DMB61:A!GR98SDU`:4,8&;2PV+QE,RM'5G/\\Q`1C8\\?)34]3J]99J$>T\nMJD?9V/\\$ZS<5Z$S5OWWM;>]Y]YH+OV6^^?F__U_;7A9`:XTQYDSX++JRM*99\nMNAXIA3(VSR;?&(B4H:4T860((TU+&:3M,;1Z+?U#:PA:$4%+\\?/)B/+XIWGE\nMAL_3TPY10%`\\\\"[3L7'Y]I<%D%*B8?'I+X6)-N8,&`BDE`C]3`C]<E':$"I#\nM*S*$2P`MI1>WBV=]#R-#9`0:B38"'8&*!$JQM-I=_A$]JP-::\\(P0FE]YNF?\nM=L`8C8HB0BT79^*SBC$0Z;-$1TM"E\\2>+3Q49NF_AE:D"((0K<"<KLM*?PZ`\nMTW<*L10N8;18HT4@;18O"B%_P0%C6!*C"9>$GPF?)8C3OR-EJ`6:4CT@;+4H\nM+C1HU:OHB&<@SAM`+$(((;#D8B(_D\\P"N>3&Z1%*A1&-9H`1%EI*E!:$2XG;\nM.BU^*?Y/@T3*4*SY:!52#PT5/R*LU!8!EB">B^!9<P",$4(NVG"::TFX$`);\nMV(2!S[[#NSDTD>-D[13]J1%&VC82=^*X;AS+B8&TB!"$FE\\)G4:C22@<CLS6\nM&<_-LZ&]$QV"6:KZ.5Z]+3^,+NU4%I>[$FMI.+6EC92"0-8I9V:83Y_BV[FC\nMQ-,9>C,7D4J/,!WO)@SR3)_<15`-B)D^8DX7MIM!.'&,Y1(::#::Y*8+3!:;\nME,I5+MFZE57^XZ@69UP0Y^N`-AJCC3!G`EP0VDWF$N.<=)ZDX=:0:]L9;KN!\nMWO16.A/#.*XDD#GV!=_GU.S/*38GT6A2R6ZHML%<)U8MCNN#5(+0K].LY8E4\nMBXO7KF.MW<!N'$#;+$$(Q"^/$+\\NP))FM#:HI;E@?_`8TY4C;%OY*M9TOQ;/\nM6H5MN;289-(\\0,0):K53%*9FR!_/DTRE&%PW2!2U"),SB-0LV:X,NEQ!S4S3\nMUZB2KLZQ(5NC/Z-1081)M<C$+53+H!4(M92,YPH@I$1"S;)D8%F6)Z5%,VHP\nM,SM+V^8-K.RZ@N,S!]AS\\E/$VTNT95V2;4D<'#HR6?JW#S`OYYG0$\\ACDB1)\nM1B]91[H[1:NGAW#U$*YPF)F>9DWC`(.Q/%%80X4U5*!18:2,YMASO3Y?/HF%\nMC9'J!UJ9-P=!Z\\8H#->'IK4:24<E""G40^8K<SQQX+LXKJ&[LX?^OGXZLATT\nMHCH+^06.Z>.459ENT\\6%J8V<*D]P@7,!'9DL81!R8N8D,_.S.*KP]:O:GKZ_\nMI2VIE<$HA%$4C>'>Y]"_/,"Q0T\\`5*[<^?(OAV'T%;>12DYVC7W0LJRW57W#\nM3#FD'$`JV881/O5&C1/C)YB>R6$D^"T?ZN`U/1:B(KOD+D9'1KGRTC@J5)3*\nM)1:*16K5*C]LQ!YYL'CYYQ[[B\\>?2^^O#W"Z//KCNP#4@;=X%:74)V.NMT>)\nMS(USU=;5%=^L3*<SEI0>MNU@VS:V;>/8-K;M+"U'%$[*971HE/YL'[[O4R@N\nM4*U6J=:J5&L54V\\T6I9U?@>FO_9KE>#3`<#DM5\\Y^F407RTWQ<I&6+XFD8B]\nMV'6\\'8[C]#NV+:S3$)9]!J@SV\\F:%6LHE\\N4*V6JM0J56I5:O3;G!\\$7@B"X\nMZWP!?J-#OFV?W88!Q[&M-9[KO<1UO=M<U]WJV';,/@L@E4S1GNF@5"E1+"Y0\nM+!7#2K5Z;ZU>^]A":6%7/!93A]]]Y'</<+K\\\\;VO9F:Z3$=G/.NZWK6>Z[W.\nM=9P7&F/26FM2R11A%%*I5JC6:A.U>NV3M7KM2YX7*T_EQCGVWI/GW?=O]9CU\nMCL?O6-RU:1UW76^'8]NWU^OU%TU.32:%)97C./<T_<8'GCI\\</?PX)!Y\\+4/\nM_L9]/F\\'W1\\]]1&,-G'7]6Y<*"V\\>7)J\\N?U1OU3KNL6#QXYP+ZW[G^^NO[M\nME6^;;\\)6^,3TQ^/OV/MV^VU[_NKW+>G_7OD?<EBF%V>%$V@`````245.1*Y"\n"8(*;\n`\nend\n
105968
 
6577    collection_account_write_48             begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```.%$E$051H@=69>9!<Q7W'/]WOFMFY]CZTN])JM;J04!`R\nM($XA@8B-<<!V*CAQ;*>HPHY=Q,$I)Q5LXI2K8@J3V"EC%TE!01RG<"K&E.,*\nM)$$*1B1<$4+".CAD';O2GC,[.SLS;V9GYKWNSA\\SNQ*'D%E$G'35JWFSV]/]\nM^_3W]_OUK]^#_^=-O-\\31"[[,M5:*"[<=G&B9HP^\\/@^7_8THY^\\\\YR,;YV3\nM4<[0!K[X?3*/_#%V9_O'+E^SY'O=+?&;$T/+QCY^<>NQJ8O^E)F?_>U[GN-]\nM5>":O_AGI*3UPQ<,/);SYYX9K7@I%4DM:VUO^:A4P=Q?;>]ZSW/(<V#GV[=M\nMW^#).V_BR,3LJMUCE9YQN[NVX?P5>G5O4_^^_8>6_>6UHZR_Z_FS#I,`]FQ=\nMPUT]J<B#:[M2]_5'Y/?Z(PO_/_<*7'\\WG4L[R)>JK1<,M-]Z^:J>WY^8LY;U\nM+^TQ`UTQ\\9\\'TV9X1K_6DDK<VQ)W'@Z4]A^Y>>D9AWOXD@NH557ON@TK[NX=\nM__E:F1[^NY[]YKX'^C&WGEP$P%V?`6-(6D)^(A9/K/4\\3TH1(@F0A-A4.:X&\nMS3.M7UM_V?JU6UH2,7OO:(D17V)%8DC+(1YQB$>L:CN3.U?L_NVC`^YA85D2\nM`Q@#1F,TC*FB^,>;T@]UW=SQ^!VW3$U\\;-W^YX0PZO[;)_G\\30GT)T?`?K<`\nMEA!H;;9U+]]P;\\_`!9Z?/8JJS&+"$J@BY5J4`\\Z-M'4-<C`KR8P'""=)-.D1\nMBU@D(I*X9Q&/2"_N+;TA7/\\%:H>_2M*>PQB!`;0V&&W,D;5=6R_8<F+ECJF/\nM#+UX;!=7AA-3@VKV@0L[+/VIUZ>`10"XCHV284O/P$:OYD]0LUII^\\`M6$)C\nM"<.>21A-KR$N6FF*1%G>YM+<9)&*6#1Y$L^6N*X@XD@BKH7;_DET*H;E:6K&\nM0HWOP!O[$9-M"3%]Q>H/;8X]P]"Q(XP-]YL?9GZW-K3IZEO;]KUR9&6*V==W\nM?V$1"E@&"4:8`%6=)=J]C=6;?X^.&`@!F8-95KV2I35FTQ(5I"**9,20\\#2N\nM!0B0LGY9@&U!=&@;YPT,<'@:CL]DJ,D?L;._A:*JDA^=Y<KD1:S<7!D^?KSE\nM^=YBV#,SFT=K>W$*V!880)@02RB,T#C"$+7KX73=4!.;>P3&&#`&0^/3&.J_\nMI.[H"W_7Q!))DA&)+0*$UCPGX+'\\-/)`GC7>!LI>M?#(8U-/RQ,71V?4B3MB\nM2U;/[MWYXT4"R`8`(5(HS)L2<3(6)1F+OMMA&UR&7*6979E/,>N_3H<]0UMO\nM>_''AT9V''OY>C\\^4[@WTWG^(7O7EX#G%@FPH$"`1&'.82*NEJL\\.G411Y=M\nM9].K+S.]_]G24RO8G2]=.6%JY;\\NKA\\X+O]M!T'PW"E[%@.@Q;P"&B-/$50J\nM%;36V+9-K5;#\\SRJU2J>YU&KU;!M&V/,V_=Q/9[<-\\.3;@>=F3(#IHVDC#TF\nMX]<\\VU<J%RZZ]^/''[KF#G1X]QOM>;<`EC1(ZC$@T6]08&1DA"`(2*523$U-\nMT=?7QXD3)^CKZR.=3I-,)@F"X"U]QD9/<BR3X+YQCT@IX(JRSYKH3BZ[\\8'Q\nM4MM/OGO/URZ575]]',*WUDZ+`'A3#)P&L'KUZH7[_OY^`+J[NP%8LF3)6\\::\nM[^-78MSS[!23-<.V7)$!LY?+![_/\\JXL0F9Y?O15_?SHV]NS>`!3!]"-(-9*\nMD9F>)A:+4:E4L&T;(02U6HUH-(KO^R2328K%XD(?Q[9!-/%G.]+L"6W.'\\NR\nMFF$V]OT-*Y9.HD*)L0#T&>U9U$YLI``3(E'U8D2`4HKIZ6F,,>3S>3S/0TI)\nMN5RFI:6%3":#;=NDTVDZ.CHH%`HXEL,_O)3GD9)-^W"637*.A/,T:P<.(!R)\nM%"#.4O"_:P`IZVE<F!!0".KISW%=UJU;!YQRF]-;5U>]=&YO;U_H\\\\BN*;X]\nM/@<G"VR>*Y#L=5@ZF,+V#-(!A$!8YMP"V%)CC#:6"$`HM*@#*1623F>(1"),\nM3T_3T=%!-ILEF4Q2J5000N"Z+K[OT][6PK-[TWSE99M\\+F3]B0R;UML,;1FB\nM,NTA;+`<0!CD8A6(#U[%U[_\\.<:GIA/9;&:#-GHHZGG)GQ0MTRM>O&1UODJ'\nME<<!=&-C54HAA%CP?]NVD5)B619""*24.([-^&2%.Y\\I<,1MI_O@.%?V:CYZ\nMTTJR32D.IS7"!NF`$2P>X+9;?HOI7'Y%4"U]NZ>S=>N&]6OBZ:F,R&1G\\>(W\nM<B0,..(?8XT^CT&ML&R'OKX^`)J;FP%(I5)O&;=2#OGF4Z/L3721W#/*EE2-\nMW_CP`.LW]+#SM3DT(.<!>`\\Q,#DZ0JE<NJ2YI>4CO;W=PO,BS,SFB40B#"SM\nM)19KXOAPG+'9&&$84JMIQL;&B4:C3$Y.TMO;R_CX.%U=7>1R.:+1*!AX\\&<S\nM/%ALH^E(EJOM.7[]JG:NNGJ06F@(E$%#70&[[IJ+5N"_=OT'2H5N9W>OF$YG\nM&!D9I;N[DU1SDFJM2J52(3TU2:%BT/I:;,NEN;D9S_.P;9MX/$Y?7Q_1:!3/\nM\\W!=F]T'LMR?=J`\\Q];0YXIU4:Z_80U&6E0#70<P!F'55U[H]Z"`4B%::?QB\nMD4QF&J6A4JE2;"O3UMZ.Z[GD"SZA\\.JR6Q;1:)12J40\\'J=4*M'4U%3/]T[=\nM'W*Y42ZM#3-V!'J235QZ^7DXGJ!24P3A/`#G!L!HC<%@M$8KA=8:K35&UU?)\nMU$]-:&'JU3%0*!08'Q^GM[>7L;$QNKN[R6:SQ&(Q@C#DM4,'V6#-<<-U?0RN\nM&$1:):9G\\L13;:=<J+[-(V3].MMCAS,"""$1*!"B<5:MU_0+]3TT-C&Q`-#9\nMV4EG9R<`'1T=P*D](3N30TJXY.)-?&#31B)-350#32W45`)%$!I"95"G`=3M\nM6"R`%`@ED%8]#4HID4+6/Z7$MB2V91%HT.:=-QN`,`SYX/8M+%^QDE!!N1)2\nM4_55#T)#H#2!TFA]VEB-77Y1`%KK>NG;<!^HKX9H+(G6FE`IE+%Y)_.-@5!I\nMXJE6EB=:J06JX2Z:(#2G()0F4*`T&-TXM#7N%P4@I41#??4;;J(;M7S]>%C?\nMF(0^Y4)O;DK7C7NCP?5@#>?OPWD`0Z@T2H%6#>,-B+.(^XX*:*T)@A"E]<+J\nMSRM@C$:%(8&6Z#=-8@R$^C2C&QEFWEWF(>:-#Q=`-=5J@%9@YJ]WMO\\=:J'&\nM+X5HN$L0UJ^P#E3/%@(AY!L4,(8%8^93XYM7>OY[J`Q^53-;JA+4:N1FRM1*\nM173(*8A%`X@ZA!`"JU'/G`IF@6RH,9^A5!!2GJMBA(66$J4%@6ZL^+SQH3[-\nMY^L`.;^"5@&EP%"HA`0%OP[0@#@;P3O&`!@CA'Q#+IMW(R$$MK`)JA7VO[Z7\nMUTZ,,^R?9$E\\D,'D.J).%->-8CD1D!8A@D#S%M<IE^<(A,/AJ1(CXQG6-K>A\nM`S"-2R]V(Q.-'";EO`)U%6QI(Z6@*DOD4Y-D$B=Y=/P71!,INE/G$T\\,,A'M\nM(*A.,S'\\`M5BE8CI(>*T8[LIA!/%6"Z!@;GR'.,3649S<\\SFBURX<2/+*B^B\nM:BRHL/@@-AJCC3`+#BX([#G232,,.S^G[/K(E<TL3UY+=V(C;4W+<5Q)58ZS\nMO_JOG)S:0VYN%(TF'NN`8A+2;5A^%+<"4@F"2HDY?YI0U?BUE:M9:9>QRX?0\nM-@T(@7ASAOAE`1HVH[5!-?:"`]7=3!0.LWGIS0QU?!K/6H9MN=089=0\\1<AQ\nM?/\\DV;%)IH]-$XO'Z5_=3QC6"&*3B/@4K>TI=+Z`FIR@IUPD44RSMM5G24JC\nMJB$F7B,5M5`U@U8@5",8WRV`D!()OF7)JF59GI06<V&9R:DIDAO6LK3]8HY-\nM'F+?\\'>(-L^2;'6))6,X.+2D6EER62\\9F>&$/H$\\*HD18]6%JTETQ*EU=A*L\nM&,`5#I,3$PR5#]$?F28,?%3@HZH:%83*:(Z>[;G9F8-8V!BI=FAE/ENMUK:'\nM0;`F,+452%H*U8!L*2!32//2H7_!<0T=;9TLZ5E"2VL+Y;#$S/0,1_4Q\\BI/\nMAVGGO/@Z3N9/T.5TT9)J):@&')\\<9C(SA:.R_W1I\\M4G:]J26AF,0AA%SAB>\nM.(O]9P8X^MI+`(5+MMSX@R`('W;+\\=AH^Y&O6Y9U>[%BF,P'Y*L0CR4QHD*I\nM['-\\Y#@3D^,8"95:!4K@S7G,A#E>D"^P:G`5EVR*H@+%;'Z6F5P.OUAD9SGR\nM[*[<10_L_OR+9[/WEP>8;__]]$\\!U*$_\\`I*J6]%7&^?$JGMZ6+M\\D+%+$TD\nM4I:4'K;M8-LVMFWCV#:V[33*$843=UDUL(HEK3U4*A6RN1F*Q2)%OTC1+YA2\nMN5RSK,6],/VEGTI4OUL%&-WZ\\"]^`.*'^3FQM!SDKVAJBGS0=;RK',=9XMBV\nML.8A+'L!J*VUC:&^(?+Y//E"GJ)?H.`7\\4M^NE*M/E2M5G^Z6(#W]&QY\\_V;\nM,>`XMC7DN=Z'7-?[3==U-SJV';%/`XC'XC2G6I@MS)++S9";S06%8O$)O^3?\nM/3,[\\T(T$E&O_\\GA_WV`^?8[3WR"R8D\\+6W15M?UMGJN]QG7<:XVQB2TUL1C\nM<8(PH%`L4/3]$W[)_Y9?\\O_>\\R+YL?$1CGYE>-%SG]/7K+>]>%O]U*9UU'6]\nMJQS;_ERI5+IN=&PT)BRI',?Y][E*^<\\/OO[*WN7]`V;7IW>]YSG?MS?U=YW\\\nM!D:;J.MZVV=F9SX[.C:ZIU0N?<=UW=PKAP^Q_XL'WJ^ISUU[U#P"&^&>B6]&\nE_^CE+]FW[_O#7[5)__?:_P#II'^^>EO%T@````!)14Y$KD)@@CP"\n`\nend\n
105969
 
6578    company_write_48                begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```-84E$051H@>69:9!<U7F&GW/O[=O;=,\\NS;Y)@S9`F*!R\nM4I8)QB%18B>5D"()@3AQ3,I)P)`J5UQV7)6BRA7L4#B`RZI*,(X#%N8'MD.*\nMV&`[-DL<D%EDHV6TS2+-TK/T]/3>??O>>\\[)C]O3&B&0!FN</SE_IF>F[SG?\nM^WWO]Y[WZX;_[TM*CZ>?_6'RU,29\\,29Z?_S\\XW+W>"1KW^+8R<G;YZ9G?NB\nM4ZT.W_O%KU*ME#8BMG4M\\W(W&-I^+0CS^D(^__>%4N4#'<V1G)"U\\3_XPUO]\nMQQ]_;"-BO.BZ[`H,]@_0O;F+Z=EY4O,+5Y^:3#WZ[/,_^5(FL]SY]0/?V(@8\nM+[HN&X!E6EB6A6&$.';T",IWXK.IY3O>/';ZKMMONU4<./#X1L3YCNNR`0"@\nM->%PF-FY)3+I148&>\\3<0OKCG_N'+]QTVVU_PN+BXH8<\\W9K8P#4EQV.LIPK\nMT][903@:WURN.E]]ZMM/?VIB?+SCB2>?PBGE-O(X8(,!#`WV885L\\OD".W;N\nM)%VH];WPRJ'[GG_EIT\\90EWSC6\\]PW?^\\YF-/')C`;0T)VF*Q1D_,PM>E=&1\nM$32V>69F\\883XV<^,["I)9;)K&SDD>\\,8/^_/LE#CQSH>?G50[NUUF8FDUG?\nMAJ9!/);DT-&3Y+-INMJ;0</4V=2'?O+3H_M.3ISAH8<>W#``UCO]8WHNC=)Z\nMYY'CIQ_)Y@K/*.E]Q2TMCYV=2ZO1;3O>]AGI2X00;.ILPW&J3$[/D8BF230E\nM64Y7XZ<GI^_>-=K_8C:;6U\\V+@=`7V\\OPC`8GYKLRN<+=R/,WSMQ:N*)WDTM\nM7_Z71[\\V]_$[/GK!,QJ-$(*N31UXKHL`ILY,L;*2I2D692F]\\CY#^W^46ES9\nM?^>==[)___[+!O".%`J%0H1MFW`XPN'#A\\EETOVIQ95/'SIRZG[E.<DO/OCP\nMA9L)H_ZL16_W)MK;FFF*)W`\\P=S"(@+?RN;R?]7=D1@N%HN7'?Q%`8!&:XT=\nMLBD4'$Z</,F.T4'RA=(MIR=G/GO]WE_IUEHCQ)I'ZJ^U!H2@H[V5X<%>8K$F\nM-!'2F2+%4FE7-I?[V-D31\\5O?_C#OT@`J\\%H6EJ:D<K$<7V&MVP-E5WUR>_\\\nMX*7G]G_EL4]N[X]W`!K`=3VT4FBM4%)A&@;#@_UL&QTFF4Q@6#&65BK,I);^\nMU#'"[UG:`$5ZQQY8"Z"G>S.AD,7DV13#_5WT]0^9LW/S5R_GJ@^DTTO7=?=M\nM'0,(VS9>O9$-0R`,`XVFH[V5T2U#*"E9D!Z5DM?GUBJW-"62A_J&=S`[=?R\\\nM\\P#QPY<.MKSZLZ.%4KDJ[_N[NW]^`*O+,`RBT3A'CD^0C-MT=[:PG"TS,37W\nMN^%(XAI`"R,@E&6:1!)-&(:@5"KC>3[Q>(RAP3Z6TDO8X1@(HW7DBFLIE5\\!\nM8#XU2W=/']_\\C^_VA$+V[3.IQ2MG4LN?2#3%\\A>+:QT`!*I.BYZN30A@+I5B\nM?F&1YJ882LK(S-S"]F1S*THJ-.!Z'I6*A_1]?-]'2HE6&L,P4%(1LD/XTJ.:\nM3V.&;!X_\\`0OO_R*_;E_?.@C)\\>G[U+*VUVJ>*]=NWLWM5KUXHF]-(!`&D'0\nMW)Q@Z\\@`6X8'$4:$Z;DERL4LMA5T;[W\\*%7_J352*GS?)YU9P75=A"&(A&T$\nM@K!M\\3O[;N`CM]_&BR^_<>M*MO!@)KVX^_#A8X1"86P[A&%</,1U60DAQ*K`\nMD$S$Z6AO97"@ET2RA4+9IU`*LF1:9OU]&L,(7DDI*97+K*QDD5)B"$$X'$8(\nM]+>?^C>Q9\\]UH__T\\/Y[:Y[Z?%]?3U-Z>86JXV,8!EJK2\\:V+@KYOD0JA5(*\nMU_4`&!T9)!JQ02FL4!@@H!I!YH4.?I=2LIS)X7H^@>P:A,-A$$(_\\-"7;U[(\nME.ZO5*O#/?V#HNJXF*$PW5WQ1C4W`(#&M$P,PZAGSR86C:"DI"698'1T&(2%\nM)Q6%0@F%0"L=2*E25*H.A6(IJ*(0""/8HZTEN>/XJ:E?#86;1EI;XF26TP@S\nM0CP66SUV76M=%#+J%-+UUZ9I(I7$]3Q,PZ"_KQM#&-AVB-4+,*``Y`M%/,]'\nM`,(P$$(0B83Q?;FWD"_N<,HYSIR=06J3X:%^+,M"2KF^Z-<'0.#[/DKK@$)>\nMH"R^)_&E#`+T?1`0C48:@4/`_V*Q#&B4UGBNAR$$D7`8*7VK4,B)=*9`<[*-\nM7=M'Z>W:A&$(S#6-*U]]D<]O;HD^__L?_(N3O[;U_LDKQ5Y]1P]?Z%XW`(UI\nMFAA"U-5%HY3&EY)JU6%^?@G7]5CK*)36N)Y'H5C"J=6`@#ZF9085"(=Q/86O\nM+`8'!MBQ;0MA.X360?54/0.V".E/3(ID\\::K[FI.1A_NS"_^;4+HO_[TTRES\nMP`[.6E<32RE16J.50DJ%5#*0QN4LY4KEG'Q*50]"H:2D7*DB9:`D0@@LTZSW\nM0)BF>!/;1K>P97B`IGCL/+D,DB'4<\\YC6WH^],OW?LW?OF_LA6_:OY'S\\SL=\nM#MS8ALR/KQ>``*=6PW7=H`?JS5RI5,EF@QG7,DU`8!@&`@$:0E8(0Q@-<+I.\nMP:!7;-K;6^GH:,/S?9121.U077H%AC#PPJ7.UCVYA_<9WW__\\;$A7GE]+]^+\nM755KN^'ZOI&C>3O55G4Y^)?KH)"&IG@<R[+.NZ"R^0*UNJ1ZOL]:[==:8YH&\nMABG.VT@I56]B&Z44*RLY:JZ+Y_O!A5>OH(_/V=[7ABM6:6^A/,\\'!C1_?HN3\nMC6Z/'KS";/NHZV7;K*H#O,N96&N%YWE4JPZ%8OE<D81``[XO`PJQ>OF=[[4-\nMXUP/**5(+Z^0S>8#4:A;#@.#Y<0,KQH_%O]]XKB8F7:(Y%ODP<-3/XHM[U+.\nMZ=0#?_S/]RR<.78HJ/[Z`M=H'5@$*17E2I5:S6T$9ED6@D!U`JKHU>*]=2>,\nM>@^8IHE&LY3.T-O317-SD$O'\\3A>DTQ.2MI"/KN[MJH7QH[\\^*5GWY]OSJD?\nMJ;''_OV^WSQ"S7]\\_0`,PT"(8&2TPR%,TT1IU?B;[_M`,,4)40N:7:GS;E,I\nM)95*%0CN$:TU:*A4'?*%$IV=G6@IF:KUDQ_<QY6I:W&F7U=O#-1>FYC[X''M\nMM#]='7OV!X?:;U!>^C.-?===@=6?IF$$.JV#R4M`W>QQ;B)#!Y??FG%-"('G\nM^VBM<%UWS=Z*;+Z`4ZTPGFWB8-][T42XNO)+3)]6_Y5MVSXY9%C3][RQ[WM_\nM,S()4^>"7Q\\``;Z4@<^I4TB]Q:>L]D"E4D6I<[*Y)@6$+(NFICA+2VD<I]88\nM>@!<UV5VP>5)9S/EYC@W+BS3'RK-I4+5SPZ8G#8+BR'UW7F82E\\0WJ4!:`A9\nM5N#EM3[/F0J"J@34@(G)L[1W=`"!4IUGR(1HR*I3JZ'4N40X5<USN1XF>S;S\nMGMD,P]XRRDRE/G;/MM-.I9+_U*-_QO]\\_^W#6Y<*K:5076-6L6$8!I&P'5"J\nM_O[59G[K'JL78JU6:Y@[%!PI]W.H:RN]J1Q[=(EB_@2=72ZM+:TDDO9%8[LD\nM`"$$,[/S=4\\#6ND&32`P:-%H!(UF9*B?>"R*E`I#"(SS:%2GFE(X-1?/\\U"^\nM1ZK:Q=C.ZXDL5WF?4Z*R/$;'I@J&*9!2HR^4LG<'``%5QVF,A:SA;H!(X_F!\nM>XS%HEB6V5"@M6(JA,`T`PK5'(>P'<+1G8QMNPE/V5R[M$*K7(30#%*[%X3Q\nM<P/02M/7VT5;6PN^#(82WI+95?>XZH645"BUV@.!M:!N)58I5"H+CG??0&5S\nM'WUC*7:&BVSJJ2"L&K-S\\V\\1@<L``,&7%R'+"A3H`GX'0TKP3AH3&6)-IPB0\nM.K#B:$W-D;PIKF*B?Y3XF_/L"97H[,C1W6MCAVRBD>@EJ;.ZUG\\3U[T,0IQ7\nM`*UU8\\PT#-%0)B%$(_GHX&-'.V0A?<E$;9BEO;]%Z%2&]WH%8I$INOK:\\'U)\nM/![##EGK'BG7K4):TQAJUFXNQ*H;#:@DZG.#7W>9C=M-@$"3];HXO.U&R/GL\nMR>5H8PHC/$\\D;-7MBFI8D0T#8!H&AB'J"J2#9EZ#P#3K/5#7?B&H?_%GT!!7\nMI:AX<6:NN1DOT<9UZ1R#9HJ2.T;(5OA^,.&M)F4#`0@J50?7]5!:X]1<:J[7\nMF)Y\\WR>S$LP%TS,I*E4'I^8R,35#>CD;@-::?*&(M$QV#5H,CYUBQ%DDG7D=\nM.UP#+1JW_;M=E^P!80CFYY>0RF=`:^92"]2<&BW-2<*V12ZG22TLD4PVD\\L7\nML.UP@T;-S0F:DW&<:I5,)DLL*OEU]R@+\\3(_.W22SBZ3:"2)99G,+Z2Q(Q&*\nMI1+E4H7.S3T;`L`!YI16$:TUEFEBQV(T)^+8(0NW5F-^88E0)$KC$SP1-',D\nM',(TP]B6B1,)XWF>Z?FJ=65E.3<^?LR/QB7]?;L8Z.\\C'H]3\\WR4%GB>3]5Q\nM3`2+P"5+<BD`AX!]U#O1]3Q*I3+%8I%BL4BY5*)<*C,T/,2FS9O.H:ZYY+(Y\nM\\OD\\N5R><KFBYV?&NUJ;$U=$F]H.+J57O%@TRM296;*Y(HE$DGBBB60R";`Z\nF"#D:RO`N&N(7O$PV^%M1@/\\%87U/<01)D5P`````245.1*Y"8(*B\n`\nend\n
105970
 
6579    customers_48            begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```/DDE$051H@;V:>9`<U7W'/]W]^IQ[9F=/:;4('0A)B+6%\nM!!B0#8(8XF!\\VY0=*B9@P+&=2F)74CF<<CD7(?@HI^S@PL%G"#9EQR>%@>!+\nM"(M+`J%[I95V-3N[LSMW]W1/=[_\\L4+(+EFL!,JOZE?=-?5^_;Z?^KW?O-_K\nM:H4SM$*A8*U8L2*CJJK5:K5:[79[3M=UN6O7KC-]Y!F96.C`@8$!;KKI)K9M\nMVS8\\.CKZKN7+EV]2%&5X;&S,_O6VIZKU>O.NZ]]QXW?FYKY`N5P^FYI_PY2%\nM#MR\\>3/M=KOOJJNN^N;E5VRZ*I5,LF?/;I[9]@2[=OR:7?N.['*[W%R=FWW"\nMLBPZG<[9U'W<M(4.7+QX,1+ELJ0E/I&5DZ)^]$5$>XS109]KSW/9/WZTZ/2M\nM&;Y@[9H'J]5JM]5JG4W=QVW!2VCWGMVTO:"QKJ_IO_G2VZQ,WS*4L$W4G,`O\nMJ;SWTH-\\:<MT=49L#`SCA5,]2LWG\\X9IFKBNZRN*(FNUVMD%^(</+$.8CEBY\nM>MU%BY*=*&D;*#)$%28A$'4[C"Z"CUY;Z!E9K8P8'WCW_G7ONNMX_(TWWLC4\nMU%1A_?KUUR]9LN2*9K,U],RSS\\H=.Y[_UNY=.[\\^-#043TY.GCT`4Y/\\VWT[\nMXD>_O/3<GJQE=^?V2E4&BB)TXMH88?,HII#Q&RY8O-B74Y8JH^.QFS9MXHDM\nM6^SWON_&NR^]Y.+WFZ:N[MZYG8Q:0PUF5V=R^?+DY.1#MFWC>=YI`RRH!AY^\nMKLK!KVV4_LS1)PU3W1%[E4U*Z"9C=XZ@,4%0.TS@5G]L909NT2=VOAC-'9*?\nM?61^661S.1#V4,;P_VY%MI:WPS)+TW6N7!'2K4^DJW(@=?V[__#!B?&QN-%H\nMG#;`@FN@^/XGF;AG;;5;'_^N9N??0.1_#$4C\\AMT.^URQVW<%>U[Y(5['_.X\nMZ[&7X\\X=S%*MU8,UV=+<IHV_?TZR=P6R4Z53>IJW;=Q).ZR7UKY^E#<MJ?&>\nM/[OG[`$`++JU@AS[FW#L2.<;WN[_>8_N3?0'1B_-S.4/[TI<M*6//=SU6`NX\nM[WC,W7=<1&FJO&$H$YZK!G/$;@7"-F&K1,'RN.-M:S8%QL^6JP/=%T];/0M:\nM0AK)Y-\\3!,/I#1O>^GOW/V+?8:^Y]I;,4''YSE__5*T:2Y`;/CGTF<]YZ[_U\nM;6.D&Q;K87A9!:Z1\\"BWKJ^@M"?F,H[NRL[<ZY7(M:-V"7]V']UF>6<RT_-I\nM/9A^0KCCX6=_4#IM@%?8R&ZGKR]+K>8N>_O;+_S7JS>O?//!F<!:>LERSEMA\nMH_[\\?LSAE93RH]SWF>>8WC--N>Q/'!SS_LGKR'M`">$V*O>>AQHV==\\<^JQF\nM9N\\`B=\\H>W[UT.V1WO/5M#[&P$=/6SL`ZBGI%$&Y_(SYNM<-?W+#AI$;7#>T\nM]D\\''/85,$P*OD*GVF&LTL$U+7;O[S!5CA9%FOYI'/-*;!U83L_->Y7\\AS:9\nM>XI_NN5H,VX?/'20,6WM]'>=K^U;^>>;K?=\\4P)KSPA@`35PSG`B8;UQ?+S&\nMW&R'DI%C]G#`XF&?7DVCVG1YY$B5H[Z*'POF6CXX>@Y#NR[;G7LXU*Y;=-UU\nM%WRP9R!_[;@87<[YR41ERS<IC'YX^-#W^,[:M1N>'YN\\YP&XY;]UH;:ZX9^\\\nM=@!2&H!>?.JIJ<S!@QZ^#XE!%]."%WI'N+Q>HURN<"@LXD\\UB`T-,B8X`@RQ\nMN+9W?_];WK+J/S9?M?*Z(W5)T]!)#Z^GN&^"F=2((A-3`U*S!Z0,WB0L[=RN\nMHO\\MYG]&M/]HP0"G7$)@`E9?K2;M`P=:3$SXX>3N*8*:S[X]+=JU%H=>&*,=\nMF+0;=>K=*"9CQ:1,R%@]J9[,U3V%Y.8#!ZKLV-_@%T<CREZ,*B.>&JOR?"6B\nM5(7)V4@/'?U&,F*$I+Y@\\?"*2\\@"Y`!H`D0(>K7=$,7RDW-`DNUVD]W-#,U#\nM+6HS!C*M^]C"PQ)Y++W@AF+M8X\\=-FS;(79LD@F#G>D>!B8G>:%RB,J4@C14\nMR-K@Z'ETM0\\XP&ETXZ<`N//850[._]L*3PAC5JJB6)V,:&^M\\%_%'`=DD7*Y\nM3:Q9D!!=;#$S#R#RD>:L/GRD`<BN8;C:P.*\\NGO09.V1,H>T.FXS02V,(W(6\nM.+J-H?41RX6K/S6``;042,X#*'H]67!:OJ+BQ1!T8W[9&"0TD\\2F`%N`*50L\nM4<(2*S&U+%9R'82`,1L$1L_4UJ:Z56KTQ!9C4E">BHC320]'#W!$'D,;();P\nMCI_#@U>\\2@#%!*D;J-H`0@.AS>07IX-9-\\0+)(H5<G7O-CKV<GX2C(*I@B4T\nM+#&%+0(,S2:1'`0_-BQ[6K6,GDY78??S'G/9"RFK.I&A@ZUW<?0*MLACBD&"\nM")+&:Y`!VX18.@BUB*F!T$I]2U*9QI0';HRT;8ZD1@E2B\\#5P1)@"8$IYK!%\nM&UL8Y#,*FNNG^E,5'%WI>#&ZTV!9?H*Z[*=MVO.9<_0I''T%IC;()T;A\\Z<\\\nM3RP0(&F@0!JA%J2A@5"/9/J=HN9)$!%8&H>E3:P:D#9?!C"T%HX^ISAZCJ$,\nM<F^U55R:KKFHVNQ<%R49DRSVH$1)$!8X0N#H)6P=+-'/-_8;I(S@50/TC:0`\nM\\NU`IELQH*M'.D*[U+<$:`+5"+B2IW#--7S?N1@,%6RAH(LN";VD)?1SD^=D\nMJ#UGSQ67I+W)9@A2PS=AGYK!=VRP3+"%P-%G<?2.9HM>80DGBF00OEJ`T?6]\nM>)VHN*_D)5J-KHLI2E6IV(&M@ZT26S;C^NL(^E=`UP!+F\\^"H6DDC7'%%I?U\nM+\\U0ZW6F0L>(W$"!G""A-;A"WT,ENY*J98,C="Q1)Z'7\\EFCT)_6TWXD:WM?\nM+<`%ZWHH5;H#ASIS)K%Z5$GHL[.Q8@6V`;H&IDK%ET2Z.E\\O+P,X),VQV!)D\nM$RK64/K(+*KF6CI8*FW1QX["Q;AV`0P-;%U@"H^4,9TMF,.K>HV\\(N7AA0*<\nM="?>]RF%I-5F4-DVN*38(%6@K&2,U@RJ'24-R)BH3LQZ=R=KW`.0L>;K8-Z3\nM3C+:WY]HRX)QA,)@<+"$:GF.`3D;T_08GGD6RXGF-["<!3E+:EG]L./XR41X\nMN)AF:H'R?T<&I*+P_KT7FEZJ[Y)WK+X4/[F<C^^_*K&U,:B9CD9/SJ2829(X\nM_WWHZ0(78%)!85;309-]#[3_?6U!UC$FM_%T6K=O;=_MZ)9",6>RR.EG4-G`\nM.8441U2=FFG('N$.?$E^U7*FQH0UON6:39^Z^-';;WYO_,5[[S\\S`%#IQ+&2\nML,3X0*\\82P\\F]ETIPIU;O[+["]V)R;^J"$6K"Y6#N@`%_$@AUE3B_O3CPV],\nM?[MKU#:\\?K6V8]:(PI\\<*>?TV>W?4`Z5-M9#\\JZN<\\#4B.,#:(9&=BC]^,:-\nMW@MKSJUF!T3U\\>]/1#U_?,7T2&\\WZW]QX\\;*;4\\^Z9=6KF1PSYZ3*CWI@6;?\nM/PARJ]^)6]IN)H9&\\W;QO%;?E:5FRU-N`.4!0)?'0!6A<ME;^Q@=S5#H\\8\\L\nM6U?XJ=!-9=GBO-?VV_&VY_8/6NF$]]P3X^_<-]$T=VT-*3]M<\\/Z(K??MH&^\nM'F8&\\N8^2^B^(PC*Y4I*C6*M4:T6<NWV,\\J!`Y^(%66\\_^Z[%YZ!Y7\\=`O<#\nM^+"K!*`H'SD!5P&I`7H@'$7_P,=6*Y=M7$JCTUKL=KT/>E&'0V$33WJD5F=H\nM=5L,_X%#-NKBIJMA^>F\\=_Z`D[KFPC2AZQ>C5KL8N2Y>HT&B5B.LU\\EZ'D&S\nMV1-,3/P+,'[RE7(:AWHI7U*O`OI+7I+$`V/-0X8U4Z/A-VEWVS2#)E6_2MDM\nM4_$JM/P6?M<GDB$SC8$.+)OR]HZGJE_>3=</Z-;K=&=F\\$LE@FJ5T/>)XI@(\nMB./XE.?>TW@K80&2^<[T98!8AH6')Q\\QMB5:=/R`IM^D[M>I>E7:09LHC"!B\nMWB70%AZDIKR]3RZ?/O!#`JD0Q3&AE,>'G>CQ*Z@Z#0#[!`#!?!GHI1A_Q3/E\nM9\\&<@.X)L_[NJX^>*'>E1CN,"4XB.F*^AWTIY"QE0`!&"9V`0`7OMV:-3G(O\nM`27VR-K3W8[`;7(<(.3D(&<'0-%!$S&Z/DTJ[A">`/"[Q+]TKX0N>6<FJNH$\nMGD*4RA`["53+0M$T9!`0!0&AZ])I-HFCZ.1R3AM`.0:@:F`(L$2$8<R0BCQ"\nM!:4#:J2AQ,IQ)P(9R>,>AQ%2AAYYJ[+'."_^<>+-:L$,#EP0'WY2<1)((8A\\\nMG]#S"+M=)5*41@PSKPV`8X&4\\WV0?0Q`URLDPX[2U4F$#@6S2-;(DA`)',TA\nMCF(\\W\\/S/6KM&M.-:5PE;I,UJD_U;XJ>MJ]2,=3'[[SODEL>`*7!?)YSP`I@\nM%9"%N/N:`&3,EP'F>_\\NAE;%*;CRZ,VT&W4\\<_:7,^FOWZM*%56J$$$<=678\nM7-K7G;OA+V-AYC2MT!:]R6I7$,6VKF,)/G[3%DE?6G+GFN/3/;Y`60L'2)N_\nMG8$`76N0,MO(RY&A3J2*_>XYG[N/9_;`/>OFXZ[Y&4B682@?40T]5RB8[62O\nM6:MTZ394U<(2T`DA;R]8RID#`.@J6`(]H?N&)>I^PFB%8OXW3`WR=<B>T.06\nMQ'SMZRI&VF3ITF1;R9BM-(J_O1FGI"G`C^:[TK,*D/G-&L@6K4XJ(5J>;;2G\nM`TEDBOG^WK$A?8*80NK83`K9HL7J9>GF$RU:%P]9_M1,Q%2LH$:2N)`\\RP!I\nM$Y@'4!W!HD5)MR/I]/?9#;\\>,8<ZGX&"/5\\OQTPY^`-DV%5$WQ(&BHL(*D9[\nMK-1MCTK#'>EJN)6ZTOB+:UEQ]?4L]!!S9@`G%+&5,E@^DG1_N+_MG=]G-Y4<\nM_&HNF@<8$//9.F:)G_TC81BM*_0-]%J'SZ5D6XOC_WUTX*<]Q>SB)4NX*.&L\nM,A_]?"86U,\\N0-8Y%J&2Z[58NBC9=K]7"?1-@\\U+TCK[S2[E6)'D@9QS/$S7\nM#:0,IAU=^W;6%D8VF]JJ*;3U./QN2JBYGESV12EE%+W"AO6J`;3M7T'ZKM3[\nMSY$]8@E[GM;;//A4M'O=FGI4<.CK0%R9448^>*LR=^V'Y8&7N+-9#AX\\^'/;\nM<7[A^X'2[7;C5:M6X;KN;6$4*:[KQG$<\\Z,?_>B,`!;\\J8&4$L>V/U_L[?W(\nMX*)ADLG$B\\3AYE]MV?K)8E__AX8&!T@Y]G9-$U=+Y,Q##SUT1H).UQ:<`451\nMU%0J5;8L:WLZ86OY?&Y?O5Y7A*8>M0VQ(YU,J+E<;F\\8AE+*TWM!^VILP0`C\nM(R-QK5:[4U&4>\\(HTL(P;/?T]+0T3?MGX(MA&&IA&+:!UO\\GP/\\!23H,Y&L4\n.QEL`````245.1*Y"8((P\n`\nend\n
105971
 
6580    customers_add_48                begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```2;TE$051H@;6:>91D5UW'/_>]^[:JZJKNZNIUMLXD,PG,\nMEF8FD\\5D)F8&),$3%51B)"!$B"`<.9Z(>E""@"@817##')4@BXA@%)&,(6XA\nM3";)9$AFR4S/]/0LW=75:^VOWOZN?]0D`9?0$\\RM<\\_]X]W[.[_/_?[N?;][\nM7PE>8NGO[[<W;MQ8T#3-;K?;;==UJX9AJ./'C[]4DR^IR)5V'!D9X8X[[N#0\nMH4-KK[SRRI_<L&'#C4*(M5-34\\X33QZL-1JM>V]]P^U?J5;_F/GY^9?3Y^\\I\nM8J4=]^[=B^NZ0WOV[/G"#;MV[^G)Y9B8.,&A)Q_C^.$G.'YJ^G@GXLY:=?DQ\nMV[;Q??_E]/OYHJ^TXYHU:U"(ZW.V?%^O*LO&[+-(=XKQT8";K^@P>6YV(#.T\nM>>W6+9N_6JO5HG:[_7+Z_7Q9<0B=F#B!ZX7-;4.MX+77_8)=&+H,$;LDK1F"\nMBL9MUYWAT_L7:HORZM`TC[Z8*:VOK\\^P;9M.IQ,*(52]7G]Y`7[[S1N09D9>\nMOFGK5:M[_"3GF`@5HTF+&$@BG_'5\\)Z;^TOK-VECQAT_/;GMI^Y]?OSMM]_.\nMW-Q<_XX=.VY=MV[=KE:KO>K0=[ZC#A\\^\\L43QX]];M6J56FY7'[Y`"Q=\\;&_\nM>";]S\\]<<FFIUW:BZDFEJ5`(:9#6IXA;LUA2I==O7;,F4!5;4\\GS8W?OWLUC\nM^_<[M_W,[7]PW;77O,FR#.W$L6<H:'6T<'E3H:\\X7RZ7]SF.@^=Y%PVPHC7P\nMT--5SG_^&N4OEA\\W+>UPZBWM%G$GEW:JA,T9POIYPD[M&W9AY.W&S+%GD^I9\nM]8</=\\.BMZ\\/I#-:,(-[-O;6BTX\\S_I\\@YLVQD2-F7Q-C?3<^E-O_NK,^:FT\nMV6Q>-,"*UT#I30>8N6]++6J<>T!WBC]$$OP20B<)FD2^.^]WFO<FIQX^^NF'\nM/#[YR`OC+AWMI=YH1%MZ*]7=5[_NDMS@1I1?PZ\\\\Q4]<?0PW;E2V[!CGIK$Z\nM/_W+][U\\``"KW[&$FOJ->&K:_[QWXA_?:'@SPZ$Y2*MPPT/'LU?M'U(3?/*1\nM-G#_\\V/^X%U749F;W[FJ$%^JA572SA+$+G&[0K_M\\:Z?V+P[-/]S@S82/7O1\nMWK.B$-+)Y3Y(&*[)[]SY8S_RI8>==SF;;WY[8=7`AF-/?%.KF>M0.^]9]8E/\nM>CN^^!5S+(H'&G%\\_1*\\1L&_\\HX=2PAWIEK(&!WE5[>+I.,D;H5@^111:_Y8\nMKE#ZB!$M/";=\\_$?_E/EH@&^SXOLG0P-]5*O=RY[_>NO_+U7[[W\\M6<60WO]\nMM1NX8J.#]LB7L-9>3J4XSOV?>)J%B07FYX.9,U/>[WB^N@]$#+_`TE]>@18W\nMC<!:_0G=ZOU%4`3->2^HGWUGHI<^F[>F&'G/1?L.@/:B=$(R/W_(>M6KUMZS\nM<^?8CW<ZL3VY$'(^$&!:]`<"O^8SM>33L6Q.3/K,S2>K$]WX"!GK)AP#N(S2\nMG1.B>->-UL3`>Q^;;:7NF;-GF-*W+CS@_/6IR^_>:[_Q\\PK8\\I(`5K`&+EF;\nMS=HWGCM7I[KL4S'[6#X?LF9MP*"N4VMU>'BZQFR@$:22:CN`C-&'J=_2&U4?\nMBO77K;[EEJUO*XT4;SXGQS?PREQV:?\\7Z!]_U]JS_\\!7MFS9>62J?-_?PMN_\nM;$BM'<7O_O\\#4,H$C-+!@W.%,V<\\@@"RHQTL&XX.CG%#H\\[\\_!)GXP&"N2:I\nMJ4/!@HP$4ZZNGYP<_M$??<6?[]US^2W3#47+-,BOW<'`J1D6>\\:$RLZ-*-T9\nM42K\\86GKET7"^$VLSR2X;UTQP(N&$%B`/52O*^?TZ38S,T%</C%'6`\\X-='&\nMK;<Y>W0*-[1PFPT:49)2L%-Z+"C8`SVEPJM+_;F]IT_7.#S9Y%NS"?->BJ82\nM#D[5.+*44*E!>3DQXHQQ.P4Y1LY8L?/P?4/(!M0(Z!)D#$;5;<K!^<>K0(YG\nMG!8G6@5:9]O4%TU4W@API(<MB]A&?R>66_[MW\\Z;CI,AS3CDLB;'\\B5&RF6.\nM+IUE:4Z@3`UZ'<@810QM"#C-163C+P+P\\0NM6M7=;:4GI5E5FARLE1/<`TO\\\nMS4`?I]4`\\_,NJ6Y#5D8X<J$+((N)GMET?KH)J,@T._K(FJ)V8M1BR_0\\9_4&\nMG5:6>IPF]-F0,1P,?1"E5N[]BP.80%M`;A1T$$8CUY]I!T+#2R&,4AYMCA);\nM.5)+@B/!DAJVG,.65V#KO=BY;1`#YG(8FJ6Y`RWM@-(II3932C(_EY#F<QY9\nM(\\2114Q]E%3!&QZ!K^[Z`0&$!<HPT?01I`Y27RRNS8?+;HP7*H0=\\^K!)_&=\nM#3P8CH.E@2UU;#F'(T-,W2&;&X4@-6UG0;/-?C\\2G#CB4>V]DGG-(#$-<(R(\nMC+&$(XM8<I0P@9SY_Z"`8T&J,DAM`$L'J5>&UO84FG,>=%*4XS#=,T[8LQHZ\nM!M@2;"FQ9!5'NCC2I%@0Z)V@9[AGB8RA^5Z*D6ER67&&AAK&M9RN<AECCHRQ\nM$4L?Y7WC\\*D7/4^L$"!G(B"/U/J5J8/4I@O#F9+N*9`)V#KGE4.JF9"W7@`P\nM]389HRHR1A^K"JB3M?;`^GR]@Z8O5R-$+B4W4$(D.9`V9*0D8U1P#+#E,)^;\nM-.DQPQ\\88&BL!Z#HABK?3@%#F_:E?EU@2]`EFAER$P?I6)OY6N8:,#5PI,"0\nM$5FCHF>-2W.7%*@_[50'UN6]<BL&I1-8<$HK$&0<<!QP3$G&6"0C/>G(09DQ\nM,TFJPN@'!1C?,8CG)P.G*EZVW8PZ6+)24\\(.'0,<C=1V.&>\\BG!X(T0FV'I7\nM!5/7R9GGA".O'UY?H#Z8F8LS9M()!?1)LGJ37>8D2_DQ:DD%ZB=,IA[;3K87\nM9+H^G-SW_K13/<PX1P@YR2`=_OTE`&S=5J*R%(V<]:L6J38KLL;R<BJ<T#'!\nMT,'26`H4B:%UU\\L+`!ERUE1J2WJS&O:J_/EE-+UC=]>)*TL\\$OJTS]Q#/CG'\nM^H&BOG;#JFNS3D"<)DZU.'[W].)T6EXN5]V.^S@1][.3;V#0X=LK!#CU(<'?\nMV"ZCXIG1=0,#5+'F7,ML+Z(Y2:[KJ*8%[*@=P^V83*U9]]PN!*:>RV22I_JL\nM(.T/YK3^T?!L)<F\\PL\\8D,R23/\\IKG:4=^^YE5MON(<UPVN)TYAFITG#:]#H\nM-%AH+&B3Y<G2@8D#KSL\\=?BF=JO]]T3\\%J_G%(>!R>\\#H(3@32>OM+R>H6O?\nML.DZ@MP&\\2N3>[('FJ.:E=$I]5D,%')D7_DS&/E^MF*QA&!9-U"Z&OJR^R>;\nM^U5#F.4G>2IO.._H?,K1PN-H4Q_B-5<,\\H$[O\\@5ZZY@N;7,8FN1*(T(DQ!?\nM^;2B%I[R*`X4N2%W`ZM&5SG[G]W_L[,+LY>KMKJ+<0X1`-,O&D(:?IJ*K"W/\nMC0S*J?QH]M1-,CYVX*]._$DT4_[U)2GTAM0X8T@0$"2"5-=(A_/_L?;&_-]%\nM9GWG]DWZX64SB1^<7NBE_85_5K4O[_K973MRO_/.CR$TP>FYT[2"%D(7C!7&\nM\\-H>M7:-_%">Z=/G<!.7MNJ0Z\\VQ??-V.,6.\\ESY3^GP9K9SDB'@X/\\!(#08\nMO/HVOU-YYFZE&1\\-$]'^H[=\\O24\\\\91"I"'HP050(36N_[$AQL<+])=F+[UL\nM6[`K-':((VN*W^Z,79O&QJ'1WOL_]<9KMEZ=_<A='R6(`Q9;BW2B#NVHC2E,\nMYF;G./J=HSSRR".\\Y7UW$!$0B8!(^+33!LVT3JZ8Q?"-JR,9?90:;V.8YO^I\nMP(;WQ\\"7``(X7@$0XCW?=7X3H'3`"&5&&'?\\TB9Q_=7K:?KM-9W(>YN7^)R-\nM6_@$E*,*I=X2[_^YWR!*(^;K\\[BQ2R?NT(E=,KJ#4@7\\P*=>;Y"2$.L!;MK@\nM7.L,T[5IZNT&'2]`<T`H<:L2ZC;ZN8\\]%W&H5^HY[S7`>*Y6%.G(5.NL:2_6\nM:08MW,BE%;:H!34JU0J//O@H;]WU5H9+P\\Q69W%C%S=V\\5,//_'04X%"D<0)\nM<1RCM)2E<):3C>/4@AJI$>-D#80.FBX0`B,D_OET5CU`'XL7<2MA`XIN9OH"\nM0*KB_H?*#YM/9MOX04@K:-$(&M2"&NW)-H/>(+O&=U&I56CZ3=S$Q4L[A,HG\nM3'TL);MV!0@A:$3+G/,G4%9(7F8(HYC`CY!21]/$A<ED:Q3'UPI3?.TB`)SO\nM`I"`H<"HI`0;#\\U_!ZP9B(`$2"_4:=@XLA'+MJBZ52(B0A62$*-$BM`5FNR.\nMD;I$2@EZ2F\\AATJS)$E*&,;X?DC+]2XXKTB2U")4UV7'K8L!^.\\*2,"L8!`2\nM:N#1S9R?`XB!.HQ<,4++;V'9%IN&-I$D"0C%<S]#2F9.SJ)0]!5[V9S?SL;!\nM5Z"40BE%JA0J@7+[//?N_VWB>($H2DB"]/+J9UWSI0$(`W298A@+]*0^\\7<!\nMI!<@(B``TS)I=!J4K!*S4[.4I\\M=IY1"T`V;.(GIZ>EA]^[='#]X$JG+%V8[\nM30B\\@#7;1LAG<RRWJYBA)##BHC&B6RL'$!<`-!U,";9,,,U%>A*/6"!\\T!(=\nMD8INC43W!16'-+TFN7R.RLD*]WWZ/GS?)TW3KEE-(TT2_,#'LBQZ>WLQ=`,%\nMQ'%,X/N@X/V__ZM8EH%AZ$BI(W5-Z%)<Q-5BQ@:ENGF0<P'`,);(Q;Z(#+)Q\nMAGYK@%ZSEZS,8@N;PR</4VO7:'@-M(;&MIW;^/6Q7T-H@`:Q"C$,@_*1.1[:\nM]TW*Y3*_^L&[L0<%29*0)BEQDB+0D?V"^$B(U'5T74/7M7924]'*`0K6"P#=\nMW#_"U&MD^CMJ]D[<9@//6GYT,?^YO]24AJ:TM+G<?.-\\S_PMS4Z3!7^!$]7C\nM"",EUGS:JDI;5%D_M)Y;M[\\%VW#8M^]?Z-]B,C'XS>Z.UO1H7JC+YQJX<1M=\nMUY&:1&AB.OIFXJ\\<(&_]=P4"#+U!C^6B;D#%!HDF)SN7?/)^#DT@CET)/GIY\nMJ?S:B9D)+;9CVJ*%1XM`:Z'9"=D>D\\%"B223D*8I2BG".*#6KA&$$:[OTPP\\\nMFKZ'%W5(E<*1&5Q"1:*>6OOQTD6$4-[JMD8WZS2R1FC:LAEDS78L+V2BE@[%\nM!O1JJ$"!XMO+]>7I!P\\^N(X\\D%5D>DSR!8>"S)`FBB3IWD)TM\\>$*$IH-CVB\nM.,;W(\\(@)HH2HCC!P,0T>IB-%F=5R*/14OS]+K:^.X3L+D3>AH)-[TC6'UJ=\nM;0^,9EV]U[[PW(:,TVU=X!"3*E4/1$%$%$3$<4*2I"1Q2A0EA&%,%,4H!4F:\nM$(4A49S0:'9HM3Q<U\\?S0GP_)(U@K&<#KN<2!,$_+CW9FHCKZ<4JT`TA+2-9\nMO3K7\\<$?'G2:02.ABM95H-_IKI?CP`^1$O/G)-Q,S.4J4D113!AV:Q!H!$$,\nM0!A&>)Y/'"4TFQWB."&.$SP_)/856XM74V\\UF:U63B=N^NE5-Q:3\\Q]>NA@%\nMK`L*6-A]#AO&<IUSL?!&AIS6*\\9RSS]C1';5`&B!E;5.:,O:9X4G(((H2`B"\nM"-^/\\+R(MMNA=Z#`CFM>Q5OO^CF4#O5ZAT:S0ZW11@MM]J[Y<?)ZD2?//M'R\nM6OZ'MWY@S9'V1/<[],H5Z,T`**1&WZ#-^M4YM_,/2Z&Y>[1U;=Y@THJ83X6B\nM"/1ENF,.@S5L(3WYK=1(O^)EO+VIH7H#(T;70X0&4_-G^-C!#Y+/]&#V2A9/\nMS%'M-+%UAVV#U_":L5LY-G>4!Y[Y7'-YN7I/9RKZXM/O.T_UR^V+`]"?^2M4\nMT,$8OD25Y#HFGC)<OGHP.;YM<R/NSS#D0[JT*"ZY\\QVB^MIWJ^=.?1^:^Q#O\nMW?/>1P?.#ASP2MYMZ'PXUM.QU`0B2>`E')XY@FV99"R;4FZ`G0,WLF/T&@:<\nM81X\\_G6^\\>S7IIN-U@?"F?3S9K\\>5_[HA>_**_ZK@5**C.-\\:F!P\\#VCJ]>2\nMRV6?)8WW?GO_@7L&AH;O6C4Z0D_&>5K7Y6L4:G'?OGW?:V`G\\`2"US%.CKOU\nMG'Y+H9`O#/<-,-(WQ$"^1#'73S%31"G%^?I9CE6.-.?K<_L2-[W7?30Y:+U2\nM4TN?:7V/V14K((30>GIZYFW;?B:?=?1BL>]4H]$04M=F'5,>SN>R6E]?W\\DX\nMCI7ZWRYHG^C.`X)#+/.V)$FNJD:U6YKMYE7G%V=6VY9IFX8$H8(XC6;B)#Y(\nMQ#=PM2>T#%[K<9?6X__3[(H!QL;&TGJ]_G$AQ'UQDNAQ'+NE4JFMZ_KO`G\\6\nMQ[$>Q[$+M/]7@.?*UP'PV<JW6.#1>'N2:3N=?L_V;%T7:$KSB435/Q"Y8E`H\n;]?B+WU;_%TCA'_.X-T$X`````$E%3D2N0F""\n`\nend\n
105972
 
6581    customers_help_48               begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```2V$E$051H@;6:>;`=]77G/]W]Z_5N[[Y]UX(D!%J0B"P6\nMLYG%LK'C)3@&5"9>5`:;F'(R1:CRX(QG[-AQ8L:8#*Z)F7@%`W&`.&9B/!B;\nM,3!(""$A@=#V]/3V];Z[]^W;ZV_^>#+@E`/OV>%4_>K^T;]SZGSJ>T[WZ5]?\nMA=_1VMK:K'7KUN545;7J]7K===VBKNORR)$COVO(W\\G$4C?V]/1PPPTWL'__\nM_L$M6[9\\:.W:M9<IBC(X/#QL[WU^7ZE2J=WQOFMV/E0LWLWL[.Q;F?-OF++4\nMC5=>>26NZW9=<<45/[SXDDNOR*33'#MVE/W/[^;(H;T<.3%^I!&RJU1<V&U9\nM%LUF\\ZW,^U73EKIQ8&``B7)1VA*WM<A)49EZ!>$.L[77Y]WK&PR-3G4X71L'\nM-V_:^'"I5`KK]?I;F?>KMN02.GKL**X75,_IJOGONO!35JYK#4KD$M<F\\*=5\nMKKOP%'__[%QI7IP7&,;+;Q1*S>?SNF59-!J-0%$462Z7WUJ`+__)6H3AB#,W\nM;'Y;?Z89IVT#14:HPB0"XK#)UGZXY=UM[:LWJ"OU&SX\\=,X?W_&J_\\Z=.YF9\nMF6G;MFW;^U:L6'%)K5;OVW_@@#QTZ*7[CQXY?&]?7U\\R.3GYU@&8FN1O_N%@\nM\\JOOKCJCO<6RP^)QJ<I`481.4AXFJDUA"IE<M'E@P)?3EBKC5WTOO?12=C_[\nMK'W=]3N_?N$%YW_$-'7UZ.&#Y-0R:K"P(9=OG9V<G/R9;=MXGK=L@"7UP.,O\nM%AF[[WS9G)]\\SC#50XE7N%2)&NFD422H3A"4QP@:I9]:N9Y/ZA.'7XF+(_(;\nM3RR614L^#\\+NS1G^%]:UE%OM:);5V0J7KXL(*Q/9DNS)O.^/_^3AB;'AI%JM\nM+AM@R3W0_I$]3-RSJ1161O]9LUO?3NQ_%D4C]JN$37>VV:C>$9]XXN6_?]SC\nMKJ=>\\SNCMX5RI1)N:IDN7GK>>U:E.]<AFR6:TR_PP?,.XT:5Z4W;MG+YRC(?\nM_D_WO'4``/TW%I##GX^&QYOW>4?_Y5K=F^@.C$YJN8L?/Y)ZV[-=\\AAW/54'\nMOO>JS]=O?AO3,[/;^W+1&6I0)&D4('*)ZM.T61XW?W#CI8'QJ[5J3_C*LK-G\nM226DD4[_5X)@(+M]^_MW//B$?;.]\\=V?S/5UK#V\\]^=JR5B!W/Z%OCOO\\K;=\nM_Y"Q,HPZ*E%T40'>*>$7W+BM@.).%'..WI#-XA\\H<<..W6G\\A1.$M=G#Z5S[\nM7^GAW&[ACD7?>'1ZV0!O\\B#[-%U=+93+C35_]$=;OG;5E6>^Z]1\\8*V^8"WK\nMU]FH3SV(.7@FTZU;^=Z=+S)W;([967_BU+#WUUY3W@-*!)^B\\.WUJ%%5]\\W^\nM.S6SY4]!XE=G/;\\\\\\NE8:_]^UARFYY9EYPZ`^H9TBF!V=K]Y[KF#7]B^?>4'\nM&HW(&IH+&/,5,$S:?(5FJ<EPH4G#M#@ZU&1F-NZ/-?VO<,S+L75@#>V[CBFM\nM-UUF'NOXL]U3M<0]-7**86WSW#_;/SAQYJU76M?>)X%-OQ/`$GI@U6`J95TV\nM.EJFN-!DVLBS,!8P,.C3J6F4:@V>&"\\QY:OXB:!8]\\'1\\QC:U2UA\\?%(>T__\nMU5=O_D1[3^N[1\\76M9R=3A6>_2%M6V\\>'/DQ#VW:M/VEX<E[_A$^^2-=J/4P\nM^LQ_'("4!J"W[]LWDSMURL/W(=7;P+3@Y<Z57%PI,SM;8"3JP)^IDA@:Y$QP\nM!!BBOWQ\\J/N][SWK6U=><>;5XQ5)S=#)#FZCX\\0$\\YF5BDS-]$C-[I$R>(>P\nMM#6AHO\\EYG=CW(\\O&>`-2PA,P.HJEZ5]\\F2=B0D_FCPZ0U#V.7&LCENN,_+R\nM,&Y@XE8K5,(X(6<E9$S(61V9]MQ5[6WI*T^>+'%HJ,K34S&S7H(J8_8-EWBI\nM$#-=@LF%6(\\<?2<YL9*TON3DX4U+R`)D#V@"1`1ZT:V*SMGGBD":@W:-H[4<\nMM9$ZY7D#F=5];.%AB58LO:T1B4V__.688=L.B6.33AD<SK;3,SG)RX41"C,*\nMTE"AQ09';T57NX"3+&,:?P.`OSW]*_L6[[;"$\\(H2E5TEB9CW#T%'NC(<U)V\nM,#OKDF@6I$2(+>86`41KK#D;QL:K@`P-HZ'U#+2J1WM--HW/,J)5:-12E*,D\nM)F^!H]OH6B=2+CW[-P8P@+H"Z5[00-$KZ3:G[BLJ7@)!F/!,M9?(3).8`FP!\nMIE"QQ`R66(^EM6"ESX$(,!:"P&B?V5-3]TB-]L1B6`IF9V*2;-HCI0?8HA5#\nMZR61<,U3\\/`EOR>`8H+4#52M!Z&!T.9;![/!@AOA!1+%BKBJ\\WF:]EH>"[:"\nMJ8(E-"PQ@RT"#,TFE>X%/S$L>TZUC+9FJ'#T)8]BRQ9F59W8T,'60QR]@"U:\nM,44O00QIXS]``=N$1#H(M0-3`Z%-=PUF<M49#QH)TK89SVPER/1#0P=+@"4$\nMIBAB"Q=;&+3F%+2&G^G.%'!TM>DEZ$Z5-:T35&0WKFDO*N?H,SCZ.DRME]NV\nMPM^]X?O$$@'2!@ID$6J;-#00ZGBNVVG7/`DB!DMC3-HDJ@%9\\S4`0ZOCZ$7%\nMT?/TY9#'2_6.U=ER`U5;*(8HZ81T1SM*G`9A@2,$CCZ-K8,ENKEWR"!C!+\\W\nM0-?*#$"K&\\AL/0%T=;PIM`M]2X`F4(V`R]E'P]S(3YSSP5#!%@JZ"$GITUI*\nM/R.]*D?Y1;O8L2+K3=8BD!J^"2?4'+YC@V6!HPM2QCR.[@E'=(J4X<2Q#,+?\nM%V#KMDZ\\9MQQ8MI+U:MA`U-,EZ1B!;8.MDIBV8SJYQ)TKX/0`$M;5,'0--+&\nMJ&*+B[I7YRAW.C.18\\2-0(&\\(*55N<0X3J%E/24E`7].9^SD(+EL)'1E(-K[\nMY'71S,1!!MXS3%B>1[,2)G^Q?(#-Y[0S70A[1II%DT2=4E+ZPD*BV(%M@*Z!\nMJ5+P);&N+O;+:P`.:7,XL00M*16K+SNV@*HU+!TL%=?HX7G.Q#WU`F)NE`XK\nM%GUYYP]334-)&F3J_:W?G+$U=Z%8'0V:SA/(\\#ZE_](748Q8CO]\\:0`GOJCP\nM@.72JQSL7='101%SQC6-^CRJ':<7$U55GVVEP[@-@^&!%;^^"X&AI1TG?B%O\nM^DF;/Z.V]08CT[%S5M,1H$GBT:.,3+S`5>>LY$,W7,WF]2NP3%UQ/9]JO4FI\nMXJJ3L^7,RT,3&_<>'-YX_-3T=4W/^9\\D_O_@C.M+G'S@S0&DHO"1XUM,+]-U\nMP34;+L1/KU7^8NB*U)YJKVHZ&NUYDXY<FM39UZ-GV]B,20&%!4U':K+K1^XW\nM-[;)BF),/L\\+6=V^L7&G(U0?]?"O6,<LM]^^DQT7;\\8/0F8+52;G*M3=@+H7\nMT6C&2-5A]8K5M.5[6#$PU;W[Q>'_4E@HGTWD_CGK;ISF^#UO#``JS2114I88\nM[>D4P]G>U(G+171XSW>.?C.<F/Q<02A:1:B<T@4HX,<*B::2=&?_[^!EV7\\*\nMC?+V/]B@'5HPXNBQ\\=D6M7KP_FCL\\/GGGV'D[_[+FUC1U\\Y,H4(8)5B62;^3\nM(HHES2!AKNAQ<J)*J>CBAM#1.<CV<W/:OI=&KYTK%"5!^3.<^><+'+L3^'=>\nM:$Y\\69#?\\"$:TP?-5-_65KMC?;WK\\NE:W5,^`,J/`%V>!E6$RD7O[V+KUAQM\nM[?[XFG/:?BYT4UDST.JYOIL\\?^!$[P]^>"KT2\\X'OW_'IXV^KE:*Y3I]77G\\\nMILO8Z`A34U.$88AAZ`P,K*2S;Q5[CU7XZ7,3%"L^I4J3Z=D:PZ-S2=2L?XWR\nM*Y_';(L8NNNW*[#V]@AX$,"'(],`BG++ZW`5D!J@!\\)1]!L^NT&YZ+S55)OU\nM@4;H?<*+FXQ$-9I*DUK*I%S2^.+-'Z"W,\\_H9(%TRJ$P-\\W'/O91AH:&B..8\nM,`SQ/(]L-LN.'>_DOWWIRXR6V_GZCX]0J?J$7H1T,JJB&#=)==,O$>G'WZ"$\nM?DM?R%]GKP+ZK]>T).D9KHT8UGR9JE_##5UJ08V27V36G>>%!U6VK#Z?"[:L\nM871J@6K=1Q4FNA%SWGGG<>NMM]+9T4&<Q#SYY)/<>><W>."!![$MBT_]Y[_E\nMKB<MXD2B&AK"T(@-K25I<)-<./H4FV]O+N-4P@(DBY/I:P")C-H>GWS">#Y5\nMI^D'U/P:%;]"J5G"G0/]R%5\\[I8M%"LNY6J#NB=11<3&+:NX[OJ=//W<BQR>\nM2^@86,FN6_Z"\\;%QOO/=[_+<<WOYL[A*3Z=&"1N"F,0,47256./B1%U]%JIV\nM8!D`]NL`!(MMH$\\G^.OVSQX`<P)"(`:2TUO'>UGA]-/3D6-NH4K=BW&;&D77\nM8ZHRRO,'CN.;O1C9'D;*@G,;DL'!`0"<5`H)A(J/:,V`%RT^<S0%H`.<[8J5\nM60[`OU5``,8T.@&!"AZ+D_.O`1)@+DMW2RM!%-'P(EQ?Q0U4W"C$JX78`YN1\nM"H0:;!IHH<>*>.ZYO0#L>.=53'D1!:%BI&T2,T`1"HJB0"(AT=>G=GQX.0=;\nMKP-0=-!$@J[/D4F:1*\\#2%X'4;>PL@8UMTG=2VCX.FZHX2'Q5(5(A?6#+6Q;\nMW4J?WN3N.[[*T\\\\\\PT=ON(&=']_%EW8?(^QJ1R@6L5!`42"!)$R0<:ICX:__\nM5%DZ@'(:0-7`$&")&,.8)Q-[1`I*$]180TF4TPO"2!!%,96:A^NK-`(5-XYI\nMJ@H-32&?,;EF<QN//7P_MWW_!SB.P_^ZYQ[.ON#MW/72,+OM/%:NG<0-4!0@\nMD<@P1O,%1(8FSMBR#`#'`BD7YR#[-("N%TA'3274244.;68'+48+*9$BI=N<\nM&$Y1J32HU)HT0IU&(&C(B*:NX@D5/4ZHU6K<??<W.3$TQ&.//4:Q:X#/'CK%\nM>'L/9C9/XH7$*LA8H@8Q:C-"-35B-ZSL>N*3R=(!<N9K`(NS?XBAE7#:&G)J\nM%VZU@F<N/#.?O??;JE315!G7Q[:<'\\OZIQ8JKAJ3Q@TB7$6A'L!TE)`&5-'-\nM.]YQ&>O7KZ>]O9T'*AZ39YV-DW6084RD*<@H06W&*(:&,`48&I%01A_ZZLO+\nMZ(&L^6\\5\\-&U"AG315Z,C'1B50PU5MWU/?8?0_G%EY!Q='@A4[WVX-'Q-MWJ\nMH!9F*"4:)46A80L&;9VZ:O&Y+WZ%)(F))-2'I]`S%EK&(/$C5#]&%2J*IJ!H\nM"FE34-&4)L0'XH6Q90(`Z(M3IY[2`\\,253]EU"-Q>A(U-6BM0(L*80-D<LQK\nM^ON>VG=\\!WH5:?2@9M.(-@?-U!C(6;3;&J'?((EC;-OBG)YN#L02&<3(,$$F\nM"5)"DDBRND;:B%F(HU=DX.Z7L?=F!UNO+R%K$2)K0<ZBI2?5[.I/U3MZ4Z[6\nM8IV^;H%C0]9"SNU%2?6X)-&]21S[21PADQ@24.*$)$IH=PQ*XR>Y_IH/\\MX=\nM5_&+?WV4+DTE*GN$18^HTB1Q0^)FB)W`AHQ!K1'(*/`?:/GP1^>BL8/+56"Q\nMA%1'T-^?;C2AV=UI5_U*3!%U48$V>[%?F@7PYB'Q?X)E_F\\(KR$)D5%,$B4H\nM44(<1K2W][#SNFOQ/(^SSSJ+?0V?J.2!%R,32>2%I(*8=[3;C$S5*)0;3\\MJ\nMX=[Z3_\\1]U__^W(4,$\\K8&+E;=:N3#=&(\\7KZ;)K9ZU,OWJ-'K&H!B!+1S'B\nM2DTOO_B8".8@\\9%AC`QB"&)>&2WST'$?L>T/R5U^'7M%#X\\/%XDJ/L%"`W^A\nM05\\D^7AOEL0-.3!:'`GKU=N-%6MG&\\\\^`BSG"TV+`R`1*OE.B]7]:;?QXT)@\nM7-I;NR"K,V2&S":*I!7(.XL^U2$<+4\\4-(\\;Z?1]I63@O"3,K)5-`_R8$^-5\nM/O_($;2,CI8VT-(&JJTC+)TV1V?'0(ZK>M+\\GQ-%?G)HZE2]6/[,JB^_[YFA\nMCWX-?\\^/E@>@'?P.TF^@=Z^2[6(%QU[071[>%Q\\Y9V,E:G/H:D)2F%=6[;I1\nM*;[K,W+HM-]6O<3\\5VM/'[HU\\[1J;-^"ZOY-TC2O,`-=<Z0\\/18JF(J*K:IT\nMIPS.[DYS;E<:)99\\Z]DQ^<RIPEZ_4KDM_97W/W5RUS>H_>"V5_-:\\E\\-I)0X\nMMOUW'9V=M_3V#Y).IUXAB:[\\?\\_N^4)'5_=-?;T]9!S[14T3[Y3(^9_][&>_\nM&:#O_=!V(?B%=NRNCVOI[,><UM2Z?&=:='2E:&UU:,F99!P#/TD8JS23DT5W\nMI-9HW*\\T:M]2^]=-!$\\_3.,G7_F-L$M60%$4-9/)S%J6=3";LK76UOR)2J6B\nM"$V=L@UQ*)M.J?E\\_G@415+^M@/:R7]97`.?*#"RYXYX_;ON=PDN\\8+FV^>*\nMU36:8Z142X!0O5AC1!+O5J/&KQ@].$*F/:G>=?UOSVNI`"M7KJ1<+NM=75TM\nM?7U]6FMKJVO;=OW11Q_5N[JZ<OW]_5H^GW>!>I(D\\I%''GGSH&MV0=!4U-8V\nJ2\\UUZ(HI(*A$LC+OH2"C_=]^TQ#_'Q?BMQ+!<XD?`````$E%3D2N0F""\n`\nend\n
105973
 
6582    customers_write_48              begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```18$E$051H@;69>Y0<59W'OU5U;[WZW3T]/>^93#))S'M@\nM,@DQ(9@'$%3$M^2`>U961!:.KF=UQ5UUW:/NZB**JQYD%T%%5V-`!!<TA``!\nM2<AC(,^9R4SF/=/=,SW]KJJNY]T_)@D1(<X$\\COGGJK3Y_YN?3_U^_WZ_FXW\nMAXNT6"PF+URX,,3SO%PNE\\N:IF4II:R[N_MBE[PH([.=6%M;BYMOOAE=75U-\nMJU:M^E!;6]M5',<U#0P,*`<.'LH5"J6[K__@]IW9[`^03J<OI>8_,VZV$[=L\nMV0)-TQ*;-V_^Q88K-VX.^/WH[>U!U\\%]Z#YZ`-U]H]VZC5MRV>E]LBRC4JE<\nM2MWG3)CMQ,;&1C!PZ_TR^4*8C9/"Q$D0;0#M=2:V+=;1/SP15Q/+FE8L7_9(\nM+I>SR^7RI=1]SF:=0CV]/=`,J[@R43*O77>;'$HL`.=H<$MC,),\\/K9N$/>]\nM-)F;(FLL43Q^H:7X2"1"95F&KNL6QW$LG\\]?6H!O?+P-1%3)HJ4K5C<$*JY?\nM$<$Q!SR1X`!P[0K:&X`[M\\6J6I?R+?3FC_2O_/#=Y_RW;]^.5"H5Z^CHN+ZY\nMN?G*4JE<W_7**^SHT6._[.D^\\?/Z^GIO?'S\\T@%(`L.W_N>(]_R#\\^97A67%\nMSIYB/+,XCE!X^0$XI0E(A'GK5S0VFBPI\\\\P]Y[MQXT;L>^DEY6,W;K]GW15K\nM;Y(DRO><.((0GP=O32\\-1:+I\\?'Q/RB*`L,PY@PPJQK8]6H6(P^O996I\\9=%\nMB3_J&9F-G*/[/3T+JS@&*S\\"2\\\\]*8=J/TG'3IQTLT/L>[MGTB(<B0!$J0N)\nMYE<7AO-1Q4FC-5C`IH4.[,)8,,=J`]=_^../C(T,>,5B<<X`LZZ!JIOV8^S^\nMY3F[,/Q;08F^$Z[Y&7`"7+,(NZ*E*WKQ;K=O]_'[=AFX=^]K?O/KPL@7"O;R\nM<#*[<<V[Y_FK%X)5<J@D#^/]:TY`<PK)Y1WMV-22QT<^=_^E`P"`AELS8`/_\nMX@R,5AXV>G[W46J,U5AB-4JA#;NZ?:M?2K!>W+NW#."A<S[WW+X:R52ZLS[D\nMS.>M+#P]`S@:G'(2,=G`[>]?MM$2GV_C:^V3<U:/6:60`+__7V%9C<'.SO==\nM\\ZO=RNW*LFV?#-7'VTX<>)K/B<U@G5^M_^Z]1L<O=XHMMA,O.,[Z#'`U`Y[!\nMK1T9<-I8-J12G56REW.NKKA:$N9T'^Q2^H0_5/5U:D_N(]J(\\[TGDG,&^"L;\nMV:>12(21S^L+/O"!5?^Y=<NB:P>G++GUBC8L7JB`W_LK2$V+D(RVXZ'OOHK)\nMWDFDT^;8X(#Q[T:%W0]P#G`;,@\\L!N\\4J2DU?%>0PG\\/,)C%M&'FAS[M"E4_\nM#4H#J+USSMH!`/P%Z3B"=+I+NNRRIJ]V=K;<H.N.W#]I8<3D`%%"S.10R54P\nMD*E`EV3T]%>02KL-KD"_#E7:!(4"6("J6WJYZ*>NDGKCG]TW4?*TP:%!#`@K\nM)G^K_*QOT3]ND3_Z,`.P_*(`9E$#\\YI\\/OFJX>$\\LM,5),4(ID<L-#:9J!8$\nMY$HZ=H_F,&'R,#V";-D$5!J!*%P7MK.['.'=#===M^(35;71;<.DO0U+_+[,\nM2[]`K/WVIJ''L'/Y\\LYC`^/W_QKXY`Y*^++MW/'V`3`F`J!5APZE0H.#!DP3\nM\\-7ID&3@>'4+-A3R2*<S&'+B,%-%>*(`A"1`)8!(&O*G^FO>\\YYW_'C+YD77\nMC1882B)%L*D#\\;XQ3`5:..9+U3)!J67,>A>1A04V1[\\,Z4$7VM_.&N""*01(\nM`.1$/L^4TZ?+&!LSG?&>%*R\\B;[>,K1\\&4/'!Z!9$K1B`07;]1"2/00D("3'\nM`U6AK54Q_Y;3IW,XVE_$"Q,NTH8'GKDX-)##L8R+9`X8GW:IH]+M")$6^.FL\nMQ0-_-85D`*P6$`A`'(!FM2*I3K^<!>#'$:6$GE((I:$R\\E,B6)":4(@!F40A\nMTYCND.5[]HR(BJ+"4Q7X?2).!*M0.SZ.XYDA9%(<F,@#8050:1243P`XC3ET\nMXQ<`^/:9*ZN?^;8E!B%BEO&D.C?N0MN?P?_&(SC-XDBG-7B"#/B(#85,S@"0\nMJ"NH2T=&BP"8+8JZ4-L8Y7OJ)"P?36-(*$`O^9!W/!<1&5"I`BI4@['9J[\\P\nM@`B@S`'^.D``.%KPQ]2RR?$P/,"R/;Q8K(,C^>%)!%`((!$>,DE!)HLA"V'(\nM_I6``T"<MBRQ*K6_Q.]G`JH\\&0.,()URX07]!GS4@D*B$(4Z>`SXX%[@D2O?\nM(@`G`8R*X(5:$`$@PE2T*6A-:PX,BX&3'6RM/HB*TH:GK'9`X@&9")!)"@JQ\nM(`H*?/XZP/1$69GD93%6L3GT'#.0#:]"FJ=P10HHU(9*,U!(%!*I@^4"?O%M\nMB(`B`1Y30?@X)`$@0C+1%`@54P:@>V"*@M%`.ZQ``Z!30":`3`@DDH5"-"A$\nM1#3$0=#-0$T@`Y7R%<,#58M8$!U#@=5`DY29R*DT!94NA"34X0OMP/<O>)Z8\nM)8!?!`<$0?@8$P6`\\*.A&K5*,!A`7$`6,,(4>+P(!*77`$2A#)5F.95&4!\\"\nM.Y4KQUN#>1V\\,)VUP?D]^.-5X%P_0&1`)00J34*A@$QJ\\/-^$0'1>LL`B98`\nM`$0UBP7+'@#*CU:(L,Z4"2`0\\**%33@$75J&Q]6U@,@#"N%`B0T?30H^.M\\_\nM+X3\\JTHVWAPTQDL.P`28$M#'AV"J"B!+@$((5)J!2BN"0JJ)3%3799;S5@':\nM.ZIA5-QX7]+PE8NV#HDD<XR3+84""@]/5C!,+X-5LQ"P14`69J(@"@+\\XC"G\nMD/4UK2'DJ]64HXJN;G%`A,`G%'$E[44FO`@Y60%40B&3(GPT'PV+L9H@#9HN\nMRY]ZJP`K5E8AF;%KARI9"1X_P?GH]+3'*98B`E0`)!X9D\\&E_$R]O`:@PB\\-\nM>#)!V,=#K@^.3(,7=)D",@^-)'`TMA:Z$@-$`5`H@40,!,3)<$QJ>D>U&.$9\nM&SD+<$]#%*;M*6O77WY376&XC:9./SYO;>V+W_J_"7PQ^28[<=^_<?#+&NJX\nM@W7-\\2(",:2XD%B>`J^X?A$(2>!5#QWZ"2S33P,A>:8.9H9?];O]-3[-BXFC\nMB-590TGPLJ&*0$2!)!EHFGH%LNK.;&`1&8C(3`C3$54U_3YGI#J`%(#="-RS\nM#9^[[)90:>OR.T)!Y=YX(?WY`,=N_^)C$T*3>($(,([#3:=6248@<<4'EZZ#\nMZ6_C/M^_V;>_6,=+JH"JB(1XR`_?DAM!@S&L@(0,.$P+%$Q@B1W:#Y?%6($3\nMQP_B<)`JMVKWJ%3F$(](:%!K4,=U8EXL@%&>(B^)K(KHM?>QG\\IJ:H#(PR]=\nMO?'?UCYS]8]3GBUG6T]=W?J]!YT%UYQ\\;J=X3=XI+*G@X4U1N(7^"Z80CXKG\nM<3Z9#-=6DX%@G:]O$W%.[/])SP_ML?&[,H03"H3'("4`!Y@N!T_@X=4$GVNZ\nM*O@;6\\QW7KY4.#HMNLY3H^DPF3[R,#>47%-P$-4IQ6E)@.>=AB`*"-<'GUNS\nMQCB^;'XN7$MRSSX^YE;=MG:ZB><$/[<N_.UYV+6M^V0+]AU:CS^JR\\WH55<V\nMM!XOB!-1P\\+^V][X0-/W#8+(T@]!3QZ1?/7M426^N)S8E"R5#>X&@-L!@+(S\nMH!SAL?Y]";2WAQ"K,D<7K(P]3:C$+6B,&IJI>0=?[:^3@S[CU7TC'^H;*TK=\nM^QVD#RNXH2..3]_6B405IFJC<I]"B:D(G)5.9P*.4^%_(/ZZ.;=H.E'0#'ZA\nMMQ9L1,G]^)?\\"RLCUU3KA[K>G[>1ZCWRV3>.0-L_.P!^!0`FT)T$`(Z[\\[SS\nM&P<P`0"UB,K1FS^SE%N_IA7%2KE1MXU/&&X%0TX)!C,06!I"V2ZCZ;T*PJX%\nM/9ASTH>CQI):-7#UJB`<W8R[Y7+<U748Q2("N0+V\\CW8U7P`9H^#L%>-%<&P\nM^^S1GCUJYGJADIFX>_M]GTE]8>W?7"B%WJ`NV%GU/`!Z=B09O-J!TI`H3^51\nM-$O0;`TEJX2<F4-:3R-C9%`VRS!M$RYS,%6LK0`+4L:IX4#NOWM@FQ;L0@'V\nMU!3,9!)&MH0'-K3@Z#LM1(F-534+O.=.'GMQ[U,;"J&\\M\\<[^=/??G/;,9C.\nMS^8&<*:UQDQG^AJ`QYS8KO'=XD%?&1730LDLH6`6D#-RT"P-KN,"+F8&`Z`1\nM`PBDC%,OMTV>_CTLQL'U/#B,P0/P>/VU.-+Y92P;>QF5D8/>X4;ST.F)S=VL\nM$GO,./G4TUVQJSQ[ZJYSJN8`H)P'0#!3!C3IP5S8E7X%D,8`^XQ0[X)7$]27\nMMID`S?%@G<?VBG\\)[O_H73"%&BPR.L`=&=0FN<79)K%MZ!\\.;_WC9UL'@,&[\nM_DS56X@``2`F06'!X@$#,YWS^8)??\\\\`<)Z!L#)I5PCT$F"=F3(A5.%'[_T2\nMLO4MV)2<0EO^))J3C[J"$;S[O@T_ZO*>3`*#4W^AZN(`.`H(Q`.EDPAX%3CG\nM`;R9^+/WG*,CJDZY.0K+X.`%@M!H$`\\M^Q1Z.J_$JK$,%FL3J#[P,&+V!-ST\nM>.[S.]^5^[N=;ZQJ]@#<&0!>`$0"R,2%*$XAX!IP.'`5@'<%<!YW;L`%F,O.\nM#<]QP9AC("IG>L7%WI/^:_D8,8>/UJZ17GCW]IKZ\\2PZW))E'G[ZN;I2=\\81\nMA)+G.7_YVB\\*0)4!QF;Z(.4,`*49^)T*9U/X'!4Q*8ZP&(:/^*`**CS7@V$:\nM,$P#>2V/R>(D=,[3$!9SAVHVNH?E33PJILM6-U)E2L<[*R444B,[_GAPY([;\nM,%U\\%N"B@&>_+0`AZ36`F=[?ABCDH,9T-G$+M&(!AC3]XE3PYP_PC`?/>,`%\nM/-=F3JDU86=O^*)'I(@@Q#12[<_:E',]RZ%HKFF%S7#Y5`ZRG=[_[/ZNKS0L\nM65VX[.3O@)F<O:#-'B`HO3X")JA00$#2P#:`.10N3_KU>?<^A*Y>X/Z5,WY7\nM/P\\P+(#(W<F+-!*+25J@3BEDIBMVP:4R8@H:#X^B12J,G3C6^T]KU[YK\\#<[\nM/S9K67,#``#*`S(!]5%+E$G1](EEA\\Q\\!DD`H@4@?%Z3&R,S[Y'R$(,26EO]\nM6G;*T$2>L]`8AO_P."[CROK$\\.#7#G5]:2\\A6P'HEP`@].<U$([+E8"/E`U%\nMU"8M!E<B,_V]J@!!^3R`P)DG<0C'92R=[R\\_\\$S?.FQ:$J1]T^BT2\\S5DO?M\nM>>[7/PL&C\\%U=\\]:TMP`@A*`&0!>)6AH\\.L5H%)3K13-@HLL^)D(Q)29>CEC\nMW.`38([-D40SZJH;T'>(7X4UK1_@IW6Z.I]'R![?]\\+^?=]J:EIKC8S<,R?Q\nM<P,XKXCE@(BV%K_^^W[-6))02EP$^%/6G0&H)3/1.F.^Y[\\)QW%75B5JJMW3\nM*W%HU>T;^"99Z!B;0#,WC&3N#^A8/58!_!@9F;/^.0"$50!@(#PBU3):&_R:\nM_EC&$C?6E:X(4O1+-M(>QQ`%$%'/N5$J@C%K4B'\\CL5+EEXA-G#SLR=[T>Q4\nMLNGD@1?B<?8*QS5ZKNN^V9/?'@#AR$_`3!VT9AZK(LWH/4PU/'+([5ZYK.#$\nM5"0J@)>9XN;=<BN7O?8.UG^6.QS&AJTW[-6UTO[Z1&C'?.OX_%S8'=^S:^1K\nM$\\.''RQJ!YT;;]R$'3OV7%H`9_=WH"K*YGAUM:A,-*'D]\\W?LL5)_.D_OK\\\\\nMFZA!?5TMVE5EE="YK2J:[9\\Z"S`X.(CV4AF,<>%RL=1,@KY=A,]]I;?_OPYL\nMV7HYXS@`N#CQ<P+@.(X/!`)I69:/!'V*$(U&^@J%`D<$?D(1R=&@W\\='(I%3\nMCN,P]KH?:/<^\\WL`$!<L7/:=EM:VIZKBU=.P@=U/'KYHX>=TS79B2TL+\\OD\\\nM3202X?KZ>B$:C6J*HI2?>.()FD@D0@T-#4(D$M$`E#W/8X\\^^NCKESC[A^+%\n:)?N;V/\\#IU/(G@5P#>0`````245.1*Y"8((D\n`\nend\n
105974
 
6583    customers_zoom_48               begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```1YTE$051H@;6:>90<U77&OU?U:NV]>V9Z>G:-9M$NC1"2\nM480%DB"L,AC;V`KBV&`P9CG.<6+LQ$[(R;%CQR;&D-@X)&`2;,`L(C;@V)(`\nM(S"2T`*S2*/1K!K-3$_/]/1>55WKRQ\\CA"!&GF&YY]1YW:?JOOI^?>^M>N^>\nM)GB?%HO%Y+:VMA#'<7*I5"IIFI81!('U]O:^WRG?E]&Y7IA()+!]^W8</GRX\nM8=6J59]J;6V]@!#2,#0TI+Q^X&`VGR_>O?6:;4]E,O^&5"KU46I^AY&Y7KAE\nMRQ9HFA;?O'GS+\\[_^,;-`;\\??7W'</C`7O1VO8[>_I.]NHT;LYF9O;(LHUPN\nM?Y2Z3QL_UPOKZ^O!0#;X97IGF(W3_,114&T('34F+EVD8^#$1*4:7]:P8OFR\nMI[/9K%TJE3Y*W:=MSBETK.\\8-,,JK(P7S4O6WR*'XBT@C@:W.`8SR>&SZX?Q\nMT]>FLM-TG26*/6>;BHM$(H(LR]!UW2*$L%PN]]$"?.?Z5E!1I>U+5YQ;%RB[\nM?D4$80XX*L$!X-IE=-0!=UP:JVA>RC4)VS\\SL/+3=Y_VW[9M&R8G)V-KUJS9\nMVMC8^/%BL51[^(TW6%=7]Z/'>H\\\\4EM;ZXV/CW]T`!+/\\,__V>F]_+,%"RO"\nMLF)GCC..6810`5YN"$YQ`A)EWH85]?4F2\\H<<T_[;MRX$7M?>TWY[.>V_7#]\nM>1^[3I($[MB13H2X'#AK9FDH$DV-CX__5E$4&(8Q;X`YU<#.-S,8_?G'6'EZ\nM?+\\H<5V>D=Y('-WOZ1E8A3%8N5%8>O8W<BAQDS!VY*B;&6$_VCV;%N%(!*!*\nM34@T[VH+YZ**DT)S,(]-;0[L_%@PRQ*!K9^^_NFQT2&O4"C,&V#.-5!QW3Z,\nM/;`\\:^=//,,KT3^#:WX%A(=K%F"7M519+]SM]N_N^>E.`_?N>=MO84T8N7S>\nM7AY.9C:NNWR!OZH-K)Q%.7D(5Z\\[`LW))Y>OZ<"FIAP^\\]4'/CH``*B[.0TV\nM]"UGZ&3YY\\:Q7UTK&&/5EEB%8NC\\G;V^<U^+LS[<NZ<$X.'3/C^\\]5PD)U-K\nM:T/.0L[*P-/3@*/!*241DPW<>O6RC9;X<BN7L(_.6SWFE$(\\_/Y_@&75!]>N\nM_<2?/[Y;N559=NE-H=K*UB.O[^*R8B/8VKMJ[[G76//H4V*3[53F'6=#&KB8\nM`2_@YC5I$&TL$U(%G94SYQ!75UPM"7.F'W8Q=<0?JOBV8$_MI=JH\\Z-GD_,&\nM^!,OLB\\C'@\\CE]-;/OG)53^X:$O[)</3EMQ\\7BL6M2G@]CP.J:$=R6@''K[G\nM34SU32&5,L>&AXSO&F7V`$`<X!:D'UP$SBD(IE1W#R^%;P,8S$+*,',C7W;Y\nMBO\\*2D-(W#%O[0``[JQTA"*5.BRM7MUPU]JU35?INB,/3%D8-0D@2HB9!.5L\nM&4/I,G1)QK&!,B93;IW+"]^&*FV"(@!H0<6-?23ZI0NDOLJ_W#M1]+3AD6$,\nM\\2NFGE'^N[_]K[?(U_Z<`5C^O@#F4`,+&GP^^8(3)W+(S)21%".8&;50WV"B\nMBN>1+>K8?3*+"9.#Z5%D2B:@"A&(_&5A.[/3X2^ON^RR%3=4)**7GJ`=K5CB\nM]Z5?^P5B';<VC/P/GEJ^?&WWT/@#OP1N>D*@7,EV;O_P`!@3`0@5!P].AH:'\nM#9@FX*O1(<E`3U43SL_GD$JE,>)4PIPLP!-Y("0!*@5$6I<[/E!]Q16+_WW+\nMYO;+3N89BJ*`8,,:5/:/83K01)AO,L%X)<&8=2&5^1:;"'\\'Z6<NM"_,&>"L\nM*01(`.1X+L>4P<$2QL9,9_S8)*R<B?Z^$K1<"2,]0]`L"5HAC[SM>@C)'@(2\nM$)(K`Q6ABRIB_BV#@UET#13PRH2+E.&!8RX.#F71G7:1S`+C,Z[@J,(VA&@3\nM_,*<Q0-_,H5D`"P!\\!2@#B!DM`*M2NW/`/"C4RGB6#&$XD@)N6D1+"B84*@!\nMF48A"S'=H<M??'%45!05GJK`[Q-Q)%B!Q/@X>M(C2$\\2,)$#P@J@"E$(7!S`\nM(.:Q&C\\+P/=/C:QV]FE+#4K%#.-H57;<A;8OC<<J(QADE4BE-'B\\#/BH#85.\nMS0+0J,NK2T=/%@`P6Q1U/E$?Y8[52%A^,H41/@^]Z$/.\\5Q$9$`5%`A\\%1B;\nMN_JS`X@`2@3PUP`\\0(2\\/Z:63,+!\\`#+]O!JH0:.Y(<G44"A@$0YR'02,ET$\nMF0]#]J\\$'`#BC&6)%9/[BMP^QJ/"DS'$*%*3+KR@WX!/L*#0*$2^!AX#KMD#\nM//WQ#PA`)(`)(C@^`<H#E)^.-@2M&<V!83$0V<%%50=05EKQOU8'('&`3'G(\nM=!(*M2#R"GS^&L#T1%F9XF0Q5K8)CG4;R(17(<4)<$4!4`0;JI"&0J.0:`TL\nM%_"+'T($%`GPF`K*54+B`<HGXPV!4&'2`'0/3%%P,M`!*U`'Z`(@4T"F%!+-\nM0*$:%"HB&B+@=3-0'4A#%;BRX4%0"VB)CB'/JJ%)RFSD5&$2JM`&B:_!G1W`\nM?6?=3\\P1P"^"`$%0+L9$'J#<R5"U6L$;#*`N(/,890H\\3@2"TML`(E^"*F2(\nM*D10&P([GBU5-@=S.CA^)F.#^#WX*RM`7#]`94"E%*J0A"(`,JW&(P,B`J+U\nM@0'B30$`B&H6"Y8\\``)WLDSY]:9,`9Z"$RULPD'HTC+\\6OT8('*`0@D$:L,G\nM)'F?L-"_((3<FTJFLC%HC!<=@/$P)>`X"<$,**"J"$'E*9&Y?%F1RD25JGA%\nM5#V/6<X'!>A84P6C[%;V)PU?J6#KD&@RRXAL*0*@</!D!2>$U;"JVP!;!&1^\nM-@HBS\\,OGB`*W5#='$*N2IUT5-'5+0*$*8)"$9^.]&.FK1:*F`.Q2A+G&)=-\nM$+^0Y4,)-3W>_LPWK]__B1>WXU=//?+^`5:LK$`R;2=&RAD)'C=!?,+,C$<4\nM2Q$!@0<D#FF3P16XV7IY&T"%7QKR9(JPCX-<&QR=`<?KD@!_@.#JY75HD%WH\nM(YT8RY51)I0CEAX2X;C5/&H4@7OTAEOO_.&$Y3STR<_=9.QX[#_F#]#_CP2/\nMR1IJ2&=-8V4E,I`F-4DL38-37/^L4(XSL29[!)HN8JB^\\:VG$"#R?E5U#T4D\nMTXN9DURLQAJ9<-3%8ICBYM4,L5P7=AT<@=*^!G4=#7`E&9FIB1,SC(M8Y7RM\nMW/V'*K^''T1CE54#`\\>_L^7R:ZW=S_]R?@",$%QW?)5D!.+G7;-T/4Q_*_G:\nMP&;?OD(-)ZD\\*B(2*D-^^)9\\#D(PAA60D`;!#"^`\\2S^A/;C93&6)^+X`1P,\nM",J7C'O4+ZX$JO5N[!K*X?*M6Q%-))`R/70571B"X%XDGW1C51HF=&_P<+<I\nM!!7YK^+Q1$\\X$GMR];H+<7C_2_-)(0YESR,^F9Y(5-&A8(VO?Q-UCNQ[Z-B/\nM[;'QOTE3PN<IAV&!`@0P70*/Y^!5!W_?<$'P25O,K3UG*=\\U([K.Y&@RO'5%\nMYE<71K'Q\\><&U8NNN`(-%1%,3&8Q,I+%:&KF1'4@-U9;9[E5=K:<9W:)XUF7\nMK,C;@\\'@[9V=;^P*^(/OV7?YHQN:_N]01)9^"GJR4_+5=D25RD6E^*9DL620\nMJP#R!`"!G0(EE,.&3\\31T1%"K,(\\V;(RMHL*$FFICQJ:J7FOOW&\\9EGC&N[H\nMON36_:DR=]/5%V,B60+G.C!L"R(S]`K)2X=%S@SPL'2]+`'@WAP9K^\\9'"EW\nM=W=?QG'\\JR_]]HFY1Z#UFPZ`QP'`!'J3`$#('6?@$H#Q``2+JD38_I6E9,.Z\nM9A3*I7K=-FXPW#)&G"(,9B"X+(RR86,BG45]<R-L9C/3\\EB(,JXB3"&[LAJ"\nMTZ"Z%D1-0ZA4A&=9:/(<3$8C5%64A;+B>_6](C#G33UC;ZGG``AO'4D&+S%4\nM'!'EZ1P*9A&:K:%H%9$ULTCI*:3U-"Y1KD;9<N$X991,DUDV',?0139^$E9V\nM!D:Y"):=@3DY#I:>!@D&@8:%B#2W$T$4J:HJ[ZEK'ET)&0##[,KT;0"/.;&=\nMX[O%`[X2RJ:%HEE$WLPC:V2A61I<V\\6"ZL6HEI:B>W(2^>869CG4*1=*HCDX\nM"/?$,#Q+AV64(!@EP"S#U]P,.QB&((FFH>OCAO'>C>)Y`"AG`%#,EH&0]&"V\nM'4Z]`4AC@`W`!>"=,3I`3Z83JZK/PZN'CF)@*LW"3LPQ;`\\ERP$#!\\)1N(($\nMWO,@5R?@M2U"D5<Q/31<KN[NG%(4^<,`>'<$*``Q"0$6+`XP9L6^`^#4T6.^\nMB:F&,2SQ![!O?[=[3OMZRR[IL`HZ)%Z`RUP(@@?5[T=@Z6+TESV,R0RE7;]C\nMFT9[`2K@O5I>[P^`"`!//0C"%`)>&<X9`&>*/_79<'4\\,?((OM!Z&XJ'4V3?\nMP4.D5I#0[G$(^D(`#2&H"/"B(726=$Q),C*O[$%S[YL@`%S'?D]5<P<@IP`X\nM'A`I(%,7HCB-@&O`(2!E@'-Y$(^</N`"S&5@+L.`?@R/F0_ARO9K1?]H-I9*\nM%7"",`1YQ0T1SDF!BN6B2?*Z@?$C1]'\\QOX#P;)VP`2FSR9K[@"J##`VNPY2\nM3@$(0AI^ITQL`3Y'14RJ1%@,PT=]4'D5GNO!,`T8IH&<EL-`IA</IW?T;*N[\nMK9>JQ4\\YV@S1K3+1;)/W++UD6U:OIA7&9+__RN3J=446X/[UOIZ^L?5D]K?[\nM8``AZ6V`V;6_#9'/0HWI;.)&:(4\\#&GFU>G@(P]RC`/'.,`%/-=F3K$Y;F>N\nM^H9'I4B*CPW=K[<]+"KNE2&?+5<$"K\\_1]]W?R:3F<QD,KV)UD7VA4U5#[4J\nM[)J^W-%?W[:@YJLWGK?JN:L>^PU&_PC$W`&"TKLC8$+@\\PA(&MCY8(X`EZ,#\nM^H)['\\;A/N"!E;-^%[\\,,+1`)'=PHA")Q23-7R7ETC;L$8Z71^3ZX8.EAJ>P\nM+`A\\HQD3]WX+T]F^'8E4[BI%<5K%]>N^_Y-#W:/7KUO=]>"^PWAW]W1^```@\nMS*XZ!9]@B3(MF#ZQY-!3*U&)!Z)Y('Q&NRE&9\\,O<!"#$IJ;_1H)2:4@B-E9\nM]`),HH!I`Y'9^5^X_QYH'G:O(OJ+U8IP4;,<6%Q<VO[=YW_WTN<O3%1./YI\\\nM9TG\\B<;6&1:29R&",A"2$4[XRO$Z7ZFRQJ?Q8?G4>1E0E=GQ-$``J`@`,3_"\nM-0$L:PD7\\XI<6MT2,N-U02#F`U?I`V)^`,!#HQH60I\\:,/&W>=,:3`P?1JOD\nM7KIA_=JO[TQ.BQ<K[]SPSQT@*,W604@"%Y905^?7I8A<7M#@*X0JE;?/QY39\nM\\921X6>!_AV$9@XB@1&8Z5YM:+A;,\\<Z]:92+X*C>XEW>QW:?GH=`.`E'7AT\nM!OB+%AP<M,C?.Z91;!CK)DMJ8K=\\_MQ5VW^GFUARANKW5<1R0$1KDU]_;D`S\nMEL25(HD`?\\BXLRF4H+/1.&6^E_\\)CN.NC,435?+H0B05N=Y[Z87$KHK*<'UC\nM(\\[UJ8NE%^X+>13YXZ=\\?C;#T'(4.*3AR5NJR/+6[,2="S)#OD)KTUU?7-AX\nM_,8-ZU[YQI[]L.<5@;`*1'P,8161A!_-=7Y-[S$L,:@4SVL.(I[P`V&5(0H@\nMHIYV$P01/,]/J0+_9%BA3U:&`_MX`DWPG&<"E'NR(A+>Z0\\&79_/]X[;?7,"\nMN"),[!X#=T]8[/G(V%&TLT+]\\O:%W_O-GOV-5YY*I3E'@.]\\",S4(50O8!6T\nM$7V'!`U/'W1[5R[+.S$5\\3+@I:?)@AMO)IE+;F<#;W&'PQ@>'MZCJ.HKIFD1\nMV[:]Q8L70]?U6QS7);JN>Y[GX?GGG_]_][SA!,.O6\\C,@$G^5N7,A<'!0TMX\nML7Y]6WWEU^X_.?V5]3S<.0,XN_\\%JJ)LKJRJ$I6)!A3]OH5;MCCQ/WSOON69\nM>#5J:Q+H4)55_-I+*Z*9@>FW`(:'AP$`75U=#.]\\';W[^Q^UW^:!K]?1GKTY\nMYUNAD/K@@H"0U03G%0`>1^81`4((%P@$4K(L=P9]"A^-1OKS^3RA/#>AB+0K\nMZ/=QD4CDN.,XC,VS07LV^\\DT0SRD0..XY\\XWS6T-XWVC/QK2>W\\B@=UJSN//\nM'DU-3<CE<D(\\'@_7UM;RT6A44Q2E].RSSPKQ>#Q45U?'1R(1#4#)\\SRV8\\>.\n:#PWB;/9_KC?X%D$"^&0`````245.1*Y"8(+Q\n`\nend\n
105975
 
6584    dispatch_order_ok_48            begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```11TE$051H@>V8:9!<5W7'?_?>]WJ=F>X>:199JT>2L78C\nM"YO88`,V)JRV*38;0\\`!AY!*$2`&XY``AB(5.S9A*8<DD"I#0A&(33"+,0[&\nM`ANP,$(>2\\B2/)K1-OM,3_?T\\MZ[6S[T+!(2_F!4^<2MZKJW[WW]^OSO^?_/\nMN??`']H?VN_5Q&]/_-./Q@'.]=Y?:CW">7#>XSSXD\\;._8[Y4Y[Q-!MU*C/3\nMS%;*8K8\\.=UL-G?]ZE_?,]ZVXWIJ3WSM[`/X[,/C`-=YSU>%0)YFG#N#H=XO\nM@G"GKFEC:-1FJ59GJ$R,Z%CK_O'Q\\2\\>'3CPC5Q'87;\\@7_XO0`$OSTA!7B/\nMR*6DN&A-3F13`F/!.H]QOM5;AW7,?1;G%S]@'%CGL"Z-L5GBN$"YW)YZ^NCX\nMCO9BU]UX__*QD>.WK+KVXT-'#^Z'??]UM@`('!`JP8IBB+"&9F2P`IP4J$`B\nM@P!M/8F=,]YZ]-S86+\\`REBYV&<5;6G%3*7">1O6I]K:VMY\\8/_>4GER[,;U\nM6[:?.'2V`"@)PH-2@F8SX2M?>@RM'>,3EH,#AE=>O9ZW7;^.X[%AM&F)M2?6\nMCLC,]=H3&T>D';'VK>]SZXU&@[#:Y,:+4RSMV$A'1_M51XX<^<#HZ,B'7G;K\nMM^S#G[[V;'A@L=?:X5U`1Z'(=Q\\YSNYAS38C"`.)$X)8""(\\D1<TG:?IH&D]\nMD?$T#32UIYDXHL31U(Z&"9`4^-;/GB0O)9WI`G+UJNM6K>F[!^_['SX;'I!"\nM+`"04K%OP//(;XXQ+$/8OI1@39&T$F12DISU2$#@$$(B1"LJ2`$"OS"6`H1H\nMO;M.%[MFRERQ(LV*]I"1@<EEJ-2E>-?_'.Q_=@_(0#*DL@SW!K"V!*N+R)4=\nMA$J0#@294`+@`7!X+_&^]=WC\\`@\\<W.^-><(H;B$TM(L/1TAN4E!97;VG"!(\nM/Q?[SZ0!@?`>*03IM.3MUZ_E,BV0G5E<(<-+>P*4@IYL0%8Y$N-)S&(?&X\\V\nMGMC.SRVNQR>-5[<'*`GY?!L$:8(@/#L`YCT@!*1#R=LNSF.LQ7L'-'#>,U7V\nM@"#G/2D+QMK%T(G#"(\\1#AL(C/18Y3&!PWKF0K(CG1;438!2@E08(D[+2+\\7\nM`($48(UA:&H2D^]`F\\4=+4].$N0+:"=(+-0K%302JS*MG8YBHD8=D^IH>45[\nMS.PT4=A!;$$GFE>?FV9Y3^^<ULZ049\\K@!:%%L7L`*$4>`G>X[W#`D(J'!+G\nM/=J#$1(G`HSP:#2)$U@4B1=H'(F#V"MB#XFS@"=4`B7%@M#/"H"31>R]I\\U:\nM4LTZC4:#8K&$"SP364]G!T@E`$DY5(2I%)EL"F,]C::E6DW17LQ@K$,;Q]14\nMAGQ'%H<@B@)2PIUB_%D$,!=&I4`(T3JU&<UL%..B!.L<Y4BCZPE(B?-0K24(\nMY4G%$FT]S69,O1:3]A':.+2Q5"LQ*1-A',1QPKK.%#DE%T"HLP9``GYQ1X*@\nMM;MU%5(G)+:6*:,(8S6G`4]M%K3WN+`5A>*F):I;3,T0:T^B';IJB%*ZI8%8\nMT]46TA4L&B_DV0)P4B(#CW<>9RT]RE/*"GQ:,=Y0="X)D+*5QLK9%&$J33:7\nMQWM/'"EJ=2B6"ACKT<8Q.1'35BSBO""*8U+"HV1+<U+ZLT<AM9!-6Q2RSF&M\nMI988?#/&6DNY&6%J31`M"E5F(V1@">/6<3N.8AKU)I.FCG$MKU3*,6G=G*-0\nMS/.Z,K0%<H[_XBQJX'=0J*;29))'Z&S\\#QG3Q)?3&"<PUE.*$XP36`*\\]03:\nMD4LT=CI%;#,\\9M[%9#5+G(I)+"1QPKO;4_0N1*&6-\\X.`"%:!X"YB\\$BA6"U\nMW\\]@_S?8?ZQ(-B50PK7$CB50X)TC##S2./*A(YM6E(HYMFR]D:FX1*E4Q"%I\nM1C%IZ0CF!2S%V4UDGOD#V"*%ZHFA%E@F9J!OQ]]2RCE</(;*+*$^L8=<:37E\nMXT_0UM'.U,AAVG(:)2,B$W-TLL%DU"`;I[!>$$4QFWLS=`1RP0-G3P-2X+PX\nMG4*!I6(5`LBD`X+0XFQ+@)@J264OIG&<9C2.;@3$9I9T?BFQ$.P\\9CC12$C"\nM9HM"2<*R0HKEP4EYX`P4.KSK,(V9AEBS;4TQ"(,E>%S4C,8*RPOUKW_VZUSW\nM5]>=V0/S(H:Y.["U]$I'IX/C#DQS&.T\\IGX$'>VF/KD/82?0K@M$E20I$'B'\nM3"N"T//V+>U4;)'.SB((29(DM(6MS6I%H5-%?-?M=_'^F]]/9;QR;KXO_XY=\nM8[M>=:1\\9%D@`W]^]_E/KR^O_^*.E^ZX_^C`47U&#7C\\`H7<?!32AEQB\\0YL\nM-$9B/?71Q]#-<;PL@O%HU^)?G`@"(+`*ZRW'IYK,Z!:%'((DCKG@G!P=0K1.\nMO7IF1[YZZ#W_]K7OR=:F.=__F\\&\\SDY??\\_C]SQ_W\\@^TD$:[SW.NQ5O>/X;\nM+KIZX]4?N?]+]W_QC%'(>['@@<4H9$D[A?>@:T-8/8&-&VCM<%*`AM@)/)!H\nM00BDC,+@^,DQS5B<$)]$H=Z.-,OG!#P[.?+"XX</7)5*9:1#L';5<F;\\"%]X\nMZ#.L+*WBQDMN9*H^Q<Z#.]EY<"?]1_L[5G>N_NB;WO6F_C/F`<]\\./6G4*A=\nMP*B%QN23"*>1*DV2@)<"KT'[UH^31)!"8&R`4HZW;^F@QND4<MXCI?")=:/.\nMQ+F]8VVI)5TK>=F&+K[\\R\\^QZ9S-+"\\NYX&]#_#0_H<8KXQ3RI>XX44WF!6%\nM%7MF&[,SIP$0\\YF8TRDD8HNS$"5EI,RA`EH`%'@-B1?@(-:0`HQ1&"<8F&PR\nMR^D4*LPEL$!)GTZGL3[+&U^U@0>'OD`NS&.LX>Y'[J;_>#_66#:OW,Q'7O&1\nMB:O.N^JN(`K^I=A5+)\\&8!$)IU'(.X6S8$W+2Z$7)!J\\D_@$M)!@6AY(/!@;\nM8(S@)\\<UD^9T"JT0BT%#2,4+MYW#D>A1^D_TLZ*TDGM^<0_'IHX!\\/+-5_#Q\nM5W]BW[:N"S[4_Y/^'W2?V^U*RTNG1Z&3F^<D"BE'*&#,@M'@YJ[M20(^`!)(\nMI,`;T$:0`-8I%(JW;VDG4D5*IU%H_L@"N6R&2RYNY\\[=G\\$%G@<./<!88PR9\nMEER[Y1K>^I)/VY_72W=\\LVF^__?=DNS6=:T-?C8`IU`H,:22%H6,!NW`>4$<\nM"X23N!@2)?`)Q+$@9<':`.-;%&JHTRE4%(M:.W]='_WUQSE8.40]J3-MIPER\nM`==NO(8_O>CCW+D_4?OD]`N*KSW_*]_^::^?MW$!P!O?\\3Z"(%C]\\0_^Q<KW\nM_<TG\\[W=2ST>`C5/(8,R$H$@G2\\1TD80Y@A260@Z\\3J+#;I1-H>R17)A3+:P\nMC/'A,KN.:<K$)&&3>.XLU-,>LL*W2B]*2KI7=_A_?NI^IMTT,3$JJ[CBW"OX\nMRQ?<RH\\??A)]<)#\\'[_FJOI0?;5<FA\\ZA>F?__*]]#_5S]JU:V\\?/'SX74N[\nMECZ]<LVY%Q>S0E9GRN`AL@[5/(@M/XE06820\\Y6?><DOCD5K[+TG;M:0RR['\nMR#:",`0$WCFZ"SDZ.CH8G$HHI.2T63-4^.CCMRIM-=9;MBS9S.V7?8$GQSLX\nM.#&!;]:97=IIBUV=-TWF\\_^^Z:%'^?"[KVUY0!O-QHT;,]YS0>^R927AW1^-\nM'CO*R$E1J=560&Y5J\\C#?#UH43'S$QX6GJ%=X"L&Y\\JM%2%04C$S.86?\\\\#&\nMRR[HO*?\\,"9E4$+1G>GBYAVW<.#18PP-'B4C!6$0$/;7E+;NC6%U]AL#2M86\nM*&2,00CAG+5Q-IO%.X\\Q&ITD)#K&Z`2M=:LW&C,W-D;CG)NSU9_4^[EBEL,[\nM3U_?6IZ__0*"5,C3>_?SZSV[%]9ZNKMI=JQAS]@>TFUII)#<M/$F&GL=/W[D\nM)P@ID5(AI9KS+"_TWF]PUOYR`4`2QVBM$Z74T/P?"SQAH$BG<RB97SCV*BE0\nM2J!DZR2)6-CRA4WWWN.=(Y-)LW)%#[6V&L-RB)JML?E5ZWGA19MX9N`H29+P\nMO'5KV1\\\\1555D3G)2WI>PHM35_+@X9^R9$D);2Q::Y+$8*P#O/,>?8J(DR3!\nM&(LQYG`+@%\\@2+-1IUXMSQ6VSM!\\*]PN_$8H<FU%,ID,KWGE91S/'22R$>>5\nMSJ.LR_17^GG!NHMHG^KB9[_8S:8=FWF\\\\3@R)UF:7LI;>V_@^__Y(_8?>@;O\nM!0B%5,'\\.0B\\GP&F3@%PVRU_SE__W9T`@]ZCO?<A>)KU&DFCC(ZJ"[3`^U.J\nM4'ZN&"JDP'N/E(KI1HU,6R?EZ0HU66?W]*_8-;V+$]$)BFU%)B<F>?W6-[/J\nMR#+B);,\\,_4,83[DFF77$#\\5LV?WS]`Z(9]O(TCGJ58-*LRT+ECX2;RH+B3:\nM>4/B*`(XYJ'FO2\\9K:E,C7#X8#])'!&&(;.SLXR.CE*I5!:,[^CH8.W:M2BE\nMJ%0JE,MESCM_$STKUG/?MW_(BR_=P8NV7,9=!_^1X_HXF21#E^EB56$5UU[S\nM!GZ0^@ZUL,:ZXCJV5[?SN<]_CNF9:9(DH5*I4.KL9-UYFYFI55`JA?=^%.\\;\nM\\U<X-0_@\\BM?32J=Z@%ND%+D&K4J^_M_Q05;-K)RU2J:S2;I=)HP#&DVF\\1Q\nM3*%0X)WO?">E4HDXCLED,GCO.3QPB&PN3W?O<L8GR_0&*[CZHE<Q8`Y2IHQ.\nM::;E-*_HNY+[&]_FA#C!6SK?0O!X@`H5<1RCE"(,0T:&AVG4:ZQ:TT=;H4BA\nM6-ASR:67W-O5W>UW_N_W..D>)'">#4$0E((@9+9:04E'[[)EC(Z-LW[#5LY=\nM?SZ=2Y:0R60`V+QY,_E\\GNERA0U;MK.Z;SVE4@DI)<>/#)!*A704"OSFT"!#\nM.V?XX/);V-:U%9F2C(I1/C7^*?;Y??05^SA_XGR&!H<8&1VEK=#)AJT7<LZ*\nME;2UM7'\\V!&D\\/3V]M+3T[MJ:JJ<UUJ?ZH&V0C<38^-Z^,2)Z9'AX4>'!@[M\nM7+YL2:B39&5'J8N-VRY$&X?",7AX(-'&_,>."R^4]7J]IWO92L[;M)4XT6`U\nM0X.#M7J]_F4OT]^W.AYLR\\B-4Y/C05N<Y]H+7\\<A<8@I-<5T,(W+.%Y7>)TM\nM["X^]MACCW8VHSB]8>N%%)=TX8QE>G*,D9&1IX1,?VFVUGAT;'3L!]5J]=<3\nM$Q/NZ;U/+&K@A_=_%>``\\(D[[KB#)Y^4I-/IR2B*+@F5X.#^?:UKGW-$4326\nMQ/$G"X7"NZ(HVHHS'/C-7L)`8G1"',<#<1Q_[.)M?1.77W[Y.N?L-N_I=LYY\nM]XSC_1O>7[RC?D?[B>`$2S-+N51>>F3&SGS,&//Y;":S:6)LA,18<IF0>KV.\nM,>9[0\\\\\\]=&]3_X"G22G!,$S5F-NOOEFG'/$<?S=1J.Q9W)\\%!?-4ID<X?''\nM?T&2)/<!AZ,H^N]ZO3XT-3$*29VQ$T?8O7NWL=9^_<HKKYPHE\\L,#`P,'3X\\\nM>/7@X.!E0T-#ES_\\XX=?O#'9^)[WEMX[40I*;`NVT6?Z'NR_MW]G',??+)>G\nM7:T\\CC0-?OW$+H:'AX]Y[^^KU^NG&7]*%/KM%D410T-#AWMZ>OYL=G;VPP<.\nM'+AP9F8FJE:KWP'N*)5*?L>.';]Z\\,$';QH?'__`OGW[-I7+Y<KL[.S7O?=W\nM[]RYDZ@5V0QP?/Z]CS[R*'?^R9U';[WWUJZ9_,SM!5G0F4;FOJL^>)7[^6T_\nM_VRM5@N&AX=?7ZU6V\\OE\\M/6VKN,,4\\$P9E-?=9JS+9MVQ!"H)3*-!J-WEJM\nMEM1JM3&EE)V<G&3[]NTT&@URN5R^7J_WU.OU>K5:G0B"P$U/3__.]Q[<?Q!?\nM][FESUMZMY2R;^30R&NUT)6;;KH)I92JU^M=M5HM5ZO5QM>N75OK[^^G5JL]\nMFZG__VWTQ"B#SPSV'1D\\<CG`;;?=]IS>\\W\\TSD=FB_U)#P````!)14Y$KD)@\n!@JG_\n`\nend\n
105976
 
6585    dispatch_order_zoom_48          begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```0=DE$051H@>V9:9!=1W7'?]U][]OGS7M/,QH):[$\\DFW)\nMEH1MV2:8X+`X*2HF!@K*V`F4<1FR%Q6(`T42`R&5*N**"RHI$DQ,52"+X[`$\nMXA"6X++!&`S>)$N697NDD30:S?[F[7?I[I,/;Q;)LDUB]"$?Z*JN[MOWW7?/\nMO\\__?TYW7_AY^7GYF8IZ_L"GOCL#L$5$KG*"\\@)>!"\\@I_2]?Y'QTWXC]+H=\nM&HL+M!IUU:K/+?1ZO1\\_>N=OS93VW$C[D7\\^^P`^?=\\,P`TB?%$I]!G&^1<P\nM5&05A#_]7FHMW7:+9G.1QNS)-$[3?3,S,W]W;.S0/87R8&OFOS[Y,P$(GC^@\nM%8B@"AFMKCBWH/(9A77@O&"]]%OG<9ZENCJ^6L%Z<-[C?!;K\\L3Q(/7Z0.;I\nM8S-[!BK#GT'DFNF3$Q_>]-:/C1][YB`<^->S!4#A@=`H-E1"E+/T(HM3X+7"\nM!!H=!*1.2-R2\\4Y(E_K6R0HHZ_1JFS>4LH;%1H/SMV_+E$JEZP\\=W%^MSTW?\nMO&WGI2>>/5L`C`8E8(RBUTOXPM__@#3US,PZGAFSO.FZ;;SKQJU,Q):IGB-.\nMA3CU1':I3878>J+4$Z?2OUZZW^UV"9L];KXRPU!Y!^7RP"\\?/7KT`U-3)__H\nM]1_YJKOO+]YZ-CRPVJ:I1WQ`>;#"O?=/\\-ADRFZK"`.-5XI8*2*$2!0]+_0\\\nM])P06:%GH9<*O<03)9Y>ZNG:`,T@7WUH+T6MJ64'T9LWW;#IW//^`9%]]YT-\nM#VBE5@!H;3@P)MS_U'$F=0B7#A&<6R%K%+F,IN`$#2@\\2FF4ZD<%K4`A*WVM\nM0*G^?W<8YL>+==ZP(<N&@9"38W/K,9FK$+_O9=C_TA[0@6;<Y)E<%\\!H%397\nMT!O+A$:1#12Y4`,@`'A$-"+]:\\$C*(2E,>F/>4*HK*$ZE&>D'%*84S1:K5<$\nM0?;EV/]"&E`H$;129+.:=]\\XRFM3A:[E\\8,Y7C<28`R,Y`/RQI-8(;&K;6R%\nMU`JQ6QY;O1^?TM\\\\$&`T%(LE"+($07AV`"Q[0"G(AIIW75G$.H>(![IX$>;K\nM`B@*(F0<6.=60R<>JP2K/"Y06"TX(]C`XX2ED.S)9A4=&V",(A.&J#,RTL\\$\nM0*$5.&L9GY_#%LND=G5&ZW-S!,5!4J](''0:#5(TSN3Z,QW%1-T.-E/N>R45\nM;&N!*"P3.TB3E%_=DN6<D75+6GN!C/IR`?0IM"IF#RAC0#2((.)Q@-(&C\\:+\nMD`I8I?$JP"HA)27Q"H<A$46*)_$0BR$62+P#A-`HC%8K0C\\K`$X5L8A0<HY,\nMKT.WVZ52J>(#838OU,J@C0(T]=`09C+D\\AFL$[H]1[.98:"2PSI/:CWS\\SF*\nMY3P>110%9)0_S?BS"&`IC&J%4JJ_:K,IK2C&1PG.>^I12MI)0&N\\0+.=H(R0\nMB36I$WJ]F$X[)BL1J?6DUM%LQ&1LA/40QPE;:QD*1J^`,&<-@`9D=4:"H#^[\nM'1/2(21VCGEK"&.SI`&AW8)4!!_VHU#<<T0=AVU;XE1(4D_:M$29M*^!.&6X\nM%#(<K!JO]-D"<$HB`T&\\X)UCQ`C5O$*RAIFNH;8F0.M^&JOG,X29+/E"$1$A\nMC@SM#E2J@U@GI-8S-QM3JE3PHHCBF(P2C.YK3FLY>Q0R*]FT3R'G/<XYVHE%\nM>C'..>J]"-ON@>I3J-&*T($CC/O+[3B*Z79ZS-D.UO>]TJC'9-/>$H5B+AC.\nM40KT$O_56=3`BU"H;;+DDONI=?^=G.TA]2S6*ZP3JG&"]0I'@#@A2#V%),4M\nM9(A=CA_86YAKYHDS,8F#)$YX[T"&=2M1J.^-LP-`J?X"8&ECL$HAV"P'.;+O\nM'@X>KY#/*(SR?;'C"`R(]X2!H*VG&'KR64.U4F#GKIN9CZM4JQ4\\FEX4D]6>\nM8%G`6IW=1"8L+\\!6*=1)+.W`,;L(Y^WY4ZH%CX^G,;DU=&:?H%#=3'WB$4KE\nM`>9/'J942#$Z(K(QQ^:ZS$5=\\G$&)XHHBKAX),^`@0"/]FGPD6LW*1&1H:&U\nMS,_/OGP`1BN\\J#,I%#@:SJ"`7#8@"!W>]06(;9(T]F.[$_2B&=)N0&Q;9(M#\nMQ$KQP''+B6Y"&D;$#O+:D4UFF#AV'#<QC[2;-]SVYY_:^J';/OG0VW_]EGM_\nM^/W[G]LRNE6^]J4OOCP/+(L8EO;`SK%.>VH>)CS8WB2I%VSG*&GT&)VY`R@W\nM2^J'035)DD$"\\>BL(0B%=^\\<H.$J%`?*')N<8?SP$1Y^\\##S[9A8#&FOO4:Z\nMC3>4<MGK"OG<[^UYU6ONF#PQ\\?FWW?#>WE?^Y7/_5P`*058HY)>C4&HI)`[Q\nMX*)I$B=TIGY`VIM!=`6LD/H^_^)$$0"!,SAQ3,SUB.BR12L.[=_/`P=/L&/W\nM3EX[>AYM9Z@OS'=FCX]-1HW%:F=^>K,1;M]T[GF[+KG\\BL??].:W&!%YR!CS\nM>+?;X?=O?OM/`:!!1*UX8#4*.;+>(`)I>QR7SN+B+FGJ\\5I!"K%7")"DBA#(\nM6(/%\\[T3EG-J(<<?>H3[GEO@FFO?S,Z--40I#DY'6%&5XL#`VFJM2K)V1,V-\nM'<I+TGG?LX>>96"P@HC\\6XKYC="8Y*=ZP"R+6`,BIU%H0,&4@^[<7I1/T29+\nMDH!HA:202O_A)%%D4%@7$!C/.R\\L<&*QP]UC)[G^+==RX88A.G%*,_$L1A;Q\nMOI4EK=8;H0FRZQDXMXP[\\00G9QH\\/+N>!IG7S%MSOH;]9TSX\\P?44@+3G$FA\nM=NSP#J).G3CV)`G]FBY719I`G/;'K35$J:(3I8P=.49V>`/;SAEFH1WC14B\\\nMD`T#<J'V^5"+=P$[MHQPR<YM5#>.4AG(<+S=X[#-KF\\7<F^J6T7U3[[[TAY8\nM1<(9%!)O\\`Z<[7LI%$62@GB-))`J#;;O@43`NH`T5<POQAR?7F#P%>?3BAWU\nMR%/-:P*CR00&IY4/EG)!HY/2:L1,)076U0;)-E(R0P6"0OAK^KSJY_"R^+\\#\nM``BG4,AX0@73#FP*?FG;GB0@`9!`HA5B(;6*!'#>$&`XIZBPUC*8"\\D:H9;7\nMA$;A1!-HC]%(8#0J#'AJND,C=0SG<U1S%3(+%C-4)"B%KS3YX')Q_CLO2:'G\nMT\\F?LA;J)'T*V13BN#_3<:Q($[URG400QXHD!N<"8JNH]SR%;,#$]!SU;DHK\nMLL36G[+^44IK@\\\\&C+42AD=*#%5"PDQ(L3;`AIJFE'>EL)9[R_![+E&CWQL_\nMTP/ON.G]!$&P^6,?_-V-[__C3Q37K1T2!`*S3"&+L1J%(ENL$E(B"`L$F3P$\nM-23-XX*U&%?`N`J%,"8_N)[IR3HGZ[!AW5I^\\NAA]E]P`;5BEF&$#&;I^-$K\nMT0:5SS"2R[%U?0$FIS@VO\\@U&S<1S1Y@[XDICO_*M=<TQSN;]5!Q!8$"^.N[\nMOLR^)_<Q.CKZET<.'[YE:'CHZ8WG;KFRDE>ZN5@'@<AY3.\\97'TORN112B^?\nM_"S54_JJWQ<1XEZ;\\)Q?8NW()K[WHR>HE];SJCV[,,K3B5(2)^BTURT8GTL&\nMAO6:6H76S!3)V`&>ZZ;4]ER!MPFVVZ8U5'.5X=K[YHK%SU_TG0?YT'O?V@=P\nMQV?O1BF5$^'KC<;B-4K\\D@;Z-#J%5/V=A\\C*_5,5LSP@L/(;E`+QY')9JN42\nM/WSB*=JE=12'UY$--:6,IA#V:R4?TENLTYF;Y>B1(Y0J-4KE`42$,`CH==JD\nMSG^SW6R]PQC=OO-3'^]3R%J+4LI[Y^)\\/H]XP=J4-$E(TAB;)J1IVF]MBEWJ\nM6YOBO5^R54YI3^_WL0GE@1+G;]W&B=DY)IZ>1!<':><S%#(!!0W349NDW63B\nM^%&4-ECG:"S,H;5!:[/D65XE(MN]<S]9T4`2QZ1IFAACQONG:/T8$P:&;+:`\nMT<659:_1"F,41O?WLZB5*5^9]#X`6?'1J0"KM354JVLH3YR@V6P2+R9X[VDO\nM/:.44"B5R#K+VGQ`%.1(K2-)4JSS@'@1TM-$G"0)UCJLM8?[`%9?WNMVZ#3K\nM2P=;+U"69G?E&64H#E0Q08!XO^*-95#^N1,XZY:6[`IC#")+WQR<1[SE\\M%-\nM7+6^Q-ZOWL,CV7/HUM8CWN/%@\\@B,'\\:@#_[\\&_SA[?]%<`1$5(1"4'H==HD\nMW3IIU%REA<AIIU#+%%%:(2)H;9CO=@CS9?22<2P;?\\I_B/@54")@TP0E,8%V\nM=,=GV=K59%4="FOY[YD3N%*U_QPRAZCF2J)=-B2.(H#C`FT1J=HTI3%_DL//\nM[".)(\\(PI-5J,34U1:/16#&^7"XS.CJ*,89&HT&]7N?\\"R]BW<9M9//E%>JL\nM&KML_.J8<P[E(])>G>/'QIDMYMC^^'/\\@K38E2LS(65^/)]BBF7$^RE$NLM;\nMN!4`N7P.K;5+DM2)>+KM!L\\^O9]+=EV$"0(.'SY,+I?#&(-SCE:KQ>#@(#?=\nM=!/-9I-CQXZ1R^706K-_W^-X%7+ASLO(9'*K^A!9B5#"LK@A[G58G)NG49_G\nMS==>RY,'#O"56<=(\\P`;CSS*U1=>3;T>4:]L()O/]W;NW.F;S1;?_OH73LW$\nM"B]L#X*@&@0AK68#HSWKUJ]G:GJ&;=MWL67;A=36K"&7RP%P\\<474RP66:@W\nMV+[S4C:?MXUJM8K6FHFC8V3"D,'!0<KE008'!QFL5*A4*E2J5:K5&M5:C5JM\nM1J5:86;Z)#MV[&!J:HKR8(W:Y:_CNQNO('*.S1-/<LTK2FS-*=:.K-NT4%\\L\nMIFE?QV;9_-+@6F:G9]+)$R<63DY./C@^]NP#YZQ?$Z9)LK%<'6;'[LM(K<?@\nM.7)X+$FM_<<]EUVF.YW.R-KU&SG_HEW$20HN9?S(D7:GT[E+=/8;+HV/E+)Z\nMA]@H\\&G$"]5>N[GWQ/&C7QL>6K.]VXLRVW==1G7-6DY*0&-QGAWU<4JYD*8W\nM//;$DU_^;&W/O:6Q)^2Y`X^L4NC;7_\\BP"'@X[???CM[]VJRV>Q<%$6O#HWB\nMF8,'^FL7[XFB:#J)XT\\,#@[>$D71+KSET%/["0.-31/B.!Z+X_BC5^X^;_;J\nMJZ_>ZKW;+<+:E=!V>C'&Z"\\IU[DKBJ*K\\[G<A;/3)TFLHY#/\\4]U+6%+M:^;\nM.%AZY04U%0_(Y?4[WK.QD`N/GJ:!4\\NMM][*C3?>2!S']W:[W?<D2?+*H:%A\nM6ITV#S_\\(Y(D^0IP.(JB+W4ZG7<ZY\\ZMU=8P/;W`8X\\]9IUS=[_QC6^<K=?K\nMC(V-C8O(=<"+?L%02M7OO//.Q>NOO_[N.&[>IA0ZE\\_S^+ZG.'1\\\\M@WC/[X\nM:XOQ'Y3''MVI,QNO.G_C\\*U_>WSV_:\\VN!==3D=1Q/CX^.&1D9'?;+5:'SIT\nMZ-!EBXN+4;/9_`_@]FJU*GOV['GT6]_ZUOMF9F8^<.#`@8OJ]7JCU6K=+2*?\nM>>"!!XCZD<T"$R_VGN7RX(,/8HSY=+O=#B8G)]_6;#8'ZO7ZT^+='?_YT=%O\nMWO,WSRZ6!PMW;1D(ZYW0?I_^5]^7_JZP>_=N5#_9Y+K=[KIVNYVTV^UI8XR;\nMFYOCTDLOI=OM4B@4BIU.9Z33Z72:S>9L$`1^86'AI]E\\1KGRRBLQQIA.IS/<\nM;K<+[79[9G1TM/WZZ?TDZ/`7R_H-FUQT[(/[N@??ED5^)_X_O^+_7_D?]SLI\n1ESO!"%``````245.1*Y"8((7\n`\nend\n
105977
 
6586    execute_48              begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```+?TE$051H@>V9:XQ=UU7'?_L\\[OLU8X\\]'L<S$X\\S-7%B\nM1XV=Q$[PQ(Z#4^5!$B2:D#X4`04AI"I`I?*!+P55`:$B(5$!_5*H6B$(59%0\nM0*60QB1QU&"GL>.78GOL\\3RN[WON/>]S]MY\\\\-3-$+_F03[E+]TOY]R]U_JM\nMO?9>ZYP#G^@3K4ABM2<LE4JXKBO&QL;2Q6*Q:!A&3BEE2"E5DB2=)$FZ0@A]\nMZM2I5;&W*@#[]^\\G#$,[D\\F,93*9^XO%XKW%8O%3Z71Z*$F2HNNZ1KO=EHU&\nMH];M=E\\/@N!;N5SN@VZWR]34U(IL6RL9?.#``:24AF$8.]>M6_=;HZ.COS0^\nM/CZT:=,F(Y?+$88AK5:+:K7Z,T=''<>Y+TF2?;5:[?.&89Q>D?<K`7CDD4=P\nM',<H%`I?'!D9^9/]^_<//?#``_3U]>&Z+K5:C;FY.7J]'HU&@VJU2JU6Q_,\\\nMPC#<&8;AE^;GYW\\OE4H11=&R`9:50@\\]]!"V;1-%T8.;-V]^Y=EGGQT<'Q_'\nM,`P\\SZ/9;%*M5IF9F>'BQ8M,7KC(W.PLKC-/X'OT7)\\@",^:IOFU,`Q?%4(T\nMI93+`EC6"@1!P!MOO,'$Q,2OC8R,##J.PUN'W\\;U/+KS71K-!O5:C6:]1NBV\nM6)=UN?\\NQ6B_@9DHOG/(YS]/ZRV[=NWZMFF:WSQTZ-!+0/*Q`81AR,C(2#:*\nMHJU34U.<.7.:LJY22"4D4F.@&,N:[-V187S3;6P>JE!("U3803N7F*RZ_.BD\nMCVW;QCWWW#-QZ-"A/B%$76O]\\0!XG@>@&HU&TN[,,USR^/TOWL66'0\\C[#R&\nM(;`L&],TT2HA";HD;AV%0$4.$]O*C+WA<VEZAJU;MT8L,_H`YG(&I=-I9F9F\nMI!#&;A'W=GWY8)&)Q[]`=NA>TOV;L0OK,5)%,&PT&I0$%8$,49%'.150L3J\\\nM>5;CA_+'ERY=^@<AQ-+##QC+&52M5C%,FV:S\\]JV=7Z\\;^(A1+J""KOH<!Z=\nM!(!"&`:&:2-^]C,LA&&"8?/P+Z2YH])1/SGRWFO]:];*Y:0/+&,%7GHL1\\&)\nMQ9_]X>-;MVX0Z_9L,7?OV/E01=A9$`(!"*$1+$1')6@9H",7%7:1?@OI-S'B\nM>8(HKN_8L?W?O_K9.X/N6V=:7W@BPW^=6EHV+7D/5(H%=NW4`YONW/OW]^_9\nMNRTX]3U+1BY&U$,8)EHL`%@IA!`(])74"=M(KXKR&^C80RG)@?O'^V][Y,M_\nM/7?NZ-&''^7)?"7;AN#_%R!GQ?B1[QG-(]U<>7/.[AM"NC6L3`EM&&A#@&$@\nM3`.A%=JOH[I3**>*#GMH&8&2**496#]DY<(+5LXYWK$2@E)ZZ05MZ7N@T^:K\nMO]+G1!_\\\\S>]"S]NI?N&T6%'2Z^!\\ILHOX%RJZCN%'+^/-*MHB('+2.TBM$R\nM1LD(8:5U8>TP<?7=IMG\\Z=]\\]NEM?MYSE^S.DE?@*_\\&!W;V2)K)O^C80_KM\nMW2IHW1VWPH,$:]"9"F2*:#L':&3DHB(7&7NH.$`E(4J&**7_`Q4?D[%[.&K7\nM7W4LFR?_;LG^K[P;G?[6/6@E'S-2^7^RLGT%*UO!3!405@JT0L8^,N@B_3:Q\nMUR+Q&H1.R_7\\X%=-0[RZXX_5BNROJ!L%T$JAE3RD5?)#%7O/2N-*\\1*&>>5>\nM$B!#AR281X9=9.@21?&/>H%^W5ZQ]54`0$N$97M:1G^A(O:@U:"*`Q`&:(E*\nM`E3DD@1=M#`)I;CLA<DW\\AG#[?K+._L_K&45L@]KTV^?0,<A*@C>E)'[<N*U\nMO,1ODG@-8K=!XC:0D8O=/XY*K_,=QWWYW9/\\=]?3[/_&R@%6[9'RS`]^$Z,P\nM6%"M<]^UJC]YRC8T6!FLXD:L-9^B6;W`M*/?=#;L?=KTFXVG/O>GJV)W%;(0\nM8JVQA3#.A^HQ63^W^Z=_]23KF*'2MQ8=M9@[^:^<FVXQ_.)W/UT>FWCQ=U[\\\nMW%^>T#K<)E8>OY4`V,`H\\.F<;=_UP)X]=W8N77AP<./(@+GUESGQPS]'34X2\nMRTF4@KZ=SS!TQZYLNU/_(ZM3G=@FQ%'@!'`4N`#$'Q=`!MA;+I<_OV/'CHE=\nMNW8-M=MMLU`J(2P;5VJ*O_B[8`DRI[]'B@@Q_B3V[C\\@E2T1-;K%>[;?_7AG\nM;OKQP0T;Y.SL[&R]7G\\]CN/O`(=88B^QU&9NQ+;MER<F)K[VTDLO[7K^^>?+\nM8V-CQK%CQ]B]>S?E3:-X(D4S!&_-3@K&1M8/WHO]Z%<PLOU(*:G5FYA>AZG)\nM239NW&B,CHZ6<[G<]B`(G@Z"8!@X!LS?JD-+68$MF4SF;Y][[KE]+[SP`DHI\nM+E^^S)DS9PB"@$JEPKSC@EW$%@9WAI<IG#U+_:W#9*TQC+V/XB:*GNMB&08;\nM;[N-<^?.,30T1#:;961DI`C\\1JO5&M-:?PDXNYH`1>#K!P\\>W/?$$T\\P-S>'\nM[_M(*3E]^C1KUZY%QC%NMT>^;Y#1M7ER9AG_TGG\\ZBQQ$%(V#:36]+KS>$Z/\nM@8$!WG[[;1S'(4D2E%*8IHEMV_NB*/HZ\\.M`;[4`/C,\\//S4GCU[F)F9(0@"\nMHB@BBB*JU2K#P\\.XGHNJ7V;-\\#!&NDBW;Y#\\]GLIAPGM\\3NI^C%^SZ$],X73\nMZY%.IU%*<?'BQ:M&Q,]/I2>!SP#_N!H`%O#,EBU;TK[OT^ETKCKO^SY!$&!9\nM%KV>@^KVF%]3H=#?A^KVJ"0)*$U\\N8H_L(F+ITXP<_Q_,`5(*>GKZZ/1:%PU\nM]*&GL@SP#/!];O*\\?"L`_;9M;R^52M1JM471]SP/K3522CJ=#NE4"J?1P/$"\nMTITV(O!)?)]X;@9W;`?=ZBQ");A!"$"E4KF1W;N!?J"V4H"2E+)\\_OQYI)1H\nMK:\\"N*Y+.IT&KKRIL$P3K].AU^F2Z;002A'Y(<GL#+U.AZC3()5*$X010@A*\nMI=*-[%:`TFH`E)52^????Y^IJ2GR^3Q"".(XQO=]*I4*T]/3^+Z/95F,CHZ2\nMO>,NUCL=E(8H")#5.7JSL_3JE[DT?8DHBBF52HO2YQK*`^6;.7=+*01DE%)T\nM.ATZG<ZBF]UNEU=>>85MV[9Q^^VWHY2D/36)E4I06A,%(<'<++USI[`%9+,Y\nMFLUICAPY0JUVP^!F%FS?4+?2C:X%4O_WHF59&,:5X?W]_=QWWWT4"@5\\/Z`U\nM>1;1:9`DDBB,<"]=P/W@.%(FY'(YMF_?SLC(R!4'#`/+6AS'5"I%-IM-+=A>\nM,<#`M?Z7S69)I:YP34U-<?3H4<(PI-UNTYB=IM-J$@<A41#2KM?Q>QT\\ST-*\nMR?3T-,>/'[\\:B'P^OVCN=#K-P,"`L6#[AKJ5%%I_K8NY7(X@"`B"`*TU[[SS\nM#DHI!@<'"<*0]TS)@RH@"D(:F0RN8:!=EW:[S>'#APF"*RU/*I4BG\\\\S/__S\nM[D$(P88-&YB>GEYO&`9)<OV3]%8`KAF%?#Z/81A7#8=AR-&C1QD?'V?#T!#O\nM!AZW$Q`DBLMK*KB>1[O9Y+WWWENTC]+I-,5B<='<29(P.#A(-IL=<!SGPP5N\nMR0#6C0!,<W$O&`0!)T^>Q'%=O`T;.*%\\#`27+9O6A0N<.7,&UUW\\ZB27RWT$\nM((YCTNDTA4)A0`AA<8-B=C.`#+#F6C<*A<+5/?!A)4G"A<E)>CV'OC5ERIB<\nMG9UE=G;VFE]B\\OD\\Y7+Y(W/$<4P^GU^SX(.S7(`LUSG*BL4BU_NJHI2B7JOQ\nM6J]+VC!H^3Y*7?OU2:E4^DA!TUH3AB&%0J%_P8=E`Q2Y4@T_HD*A\\)'C;[$T\nM/=^_:3O9U]=W=05,TR27RY'+Y<AFLQ0*A=*"#_7KC;\\90`[P%R98]`HAD\\E0\nM*!1N,OSF*I?+5X]1(0293(;^_GX:C8:8F9GQ%WRXKFX&<`YX@FO4@2B*KIL6\nM2Y%2BC"\\TMPE24*]7J=>K[/P(5P!TRLV\\HD^T?7UOZUP[0I:UH+3`````$E%\n&3D2N0F""\n`\nend\n
105978
 
6587    export_database_write_48                begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```-]4E$051H@>V969!=Q7G'?]UGN\\OL^R)IM(V0$$)FD4`0\nM@W$%VYC8D-@$.PMV'!PG92>5%U/&54DEL5/V@U-^<.&XC$-<)*9B;%<J)#$0\nM8T#&$,*^:$="LF8$HYFY^[GW+'VZ.P]W1A9H!-)`PD/R59VY=>[4.>?_Z_[.\nM]^_^+OQ__!\\+:RW66L]:^P%K[<C"^3LMZ\\QC07!A7D\\]?#3;\\Q-C]=:7U7/+\nMAI!OL[XSCCD])0^JIW_U0/K4#T:<M3<`[G(@WC$`C&1$K">SZ>3>^/';2]DK\nM?P[T6FO.:C;>,0!C#*TL)$\\7K@VZ]T5/?O%HLO<.$)M"73ECB'<,0!M#,VM0\nM4V6T,?@4G)=:SU^_*WSL!ZX(/@0X9P+AGNV#O[5S+].52%P\\T>?W%OR\\*\\A)\nM@8=`8&'QD4((K;5)HB2)CAPOQ9^^Y9OZ8Q^_^K4`:8CC>A@,`)[-<3C:M[FB\nM2M_=7-S^M3Y_^#9K;5T(<5H]I_\\/T#26G2\\<H;.C&)"EZ_*^>Z[OB$U6Z[5:\nMJY%,90-:ZXY,ZYPQ1AIK,=J@C2;+M%)*M72FJX'OS^;SP?3H4->!D='.LB>]\nMSCV-ISY_N+5WLL?KQV"P6+`6"S1UC9PLJ"U=.WZXNK#QSU*3'/)EP%(@2P(\\\nMO/LH0@*606O,M4;%UPN=;L?HH22*'94IM#$+HRT14F)IETAM#"I56&WH+`;D\nM>@U.;T+LU$A$TZ8VLMIFHI%51-[IH,/M>AU`^ZZ)B0'8TG7),YN[MWW!D_Y/\nM`?-ZB%,`#ARK<:Q21DIY@3'FZ[/3O[C\\^+&CKB,E^7P>S_=!2`P"X;BXGH_G\nM^[B>CY"23"GRGDOG0$HI>(E$-!!"H(U&6XVQ&H-%6$"($Z(MBX:V>`;:9I23\nM639W7SQ[Q?"U7^GQ^V\\'FB=#G/(.3)<K&".D$/:/K357OGSP)>K5,FLF)FA&\nM$?6Y,M)UR>4+Y`M%"HZ'+QT\\/\\!Q'`9[NPCS^]B3/L>@&$,:CX:JHHPZ1:@Y\nM:=3MB=%?/#?45)6CX4OL+^\\:F@Z/?/7:E;^U=:)C_:W6VIE%B%,`YNL18:2<\nML?Y";\\YWF=Q\\/OMWO\\CQ^1)1DI)I0Z%81#HNCN,@I<`:0Y(D#/7U4/)W\\V+U\nM,<8+$QQK'"7*6FB3H6V&Q2(0"[DL$'`B]<!BK$';C$3'U-(*U;1$9A3&&@Y5\nM]@?A</U"H`^8.>T,-.*41IS:H"[IZ0@8&!JAMZ^?:K5"O5JA4:\\3QS'6&.(X\nM1BE%RVG242BB5T8\\.GLO?<$@!\\I[J"8E0M4@T3':9@LY*Y!"(H6+(^1B\\8*%\nME,F,0AF%L;K]I84+AG:8CZ[_Q+V;^RZ\\I:7"/06OX_0I!%#,^20JHQ):C+%T\nM%GS&1D<9'QM#:TVJ,I1*42I#:XTQFH$>GP=K=]",6\\R'>YF+9DAU`H#1%IUJ\nMC#$GGB%=B>LY"+E$'1'M6?4(N'KUAZ+K-_SVMU=UKOVRQ<X7O`[>\\!TX.;2Q\nMA/%"VN0\\BH%'(?#HS/E`?F%$P7,]II)GV'WH.5*=4D^K[3S6H"*%+P)6]*YA\nMO',5>5G$",V!^3U,U0[C%5\\G00BTRNCQ^[GAW)MF/SCYD;_L#?KO`&(I3O7=\nM,S(R;2V)RC`+GP)#IA1:*72F&.[MY(G*0QROSY*9#`3H1&,BR]95%[&][SVD\nM4Y)7]LQ1:T:L6K&"R\\X=X\\[9O\\5Z)\\^`126:M=V3W'319W:]=\\T'/N_+X'[`\nMGL[,SLJ)%V]AC$5EFB1)2>*80E?&\\Z\\^31BUD$*211ENYG/=^3<R.+>61^]Z\nMCK#5HJN[BT(^3YQJ"AFDL8*@?6=K##HR7++JW>93E_S1?1>/[;BEGE9W^_[2\nM!K8L@*7"]SR:ILQ4>8HLTV21PDU];MAV$V)?#P\\__PQ!/L]@=P\\]71UXKD-W\nM=S>I34@2#4JB$XV3>ERW]3?CF[;??/O:WLDO6>Q<E]_SAN*7!/`<B9""3.DS\nMD&\\)/(^YZ%6JM3H6BZY:;KC\\=W$.]K/O\\!2#HV.H-$$IA=8&WW,10F"T)8TS\nM5"FCU^GGDU=\\>O;&"W_G2_WY@>]PFGP_(X`T36G%,;W=7=J5X@U'P`*>ZS!;\nM/TXKC-$MR]7GO9^QQB;VSDS3.S!($L=8P&B-RA1%D0,@RS3A;(O-Z\\_CL^_[\nMT]W7;K[NEL`)[F.)Y<(;Q2F8#_[H3K[RAQ^Q+S[^B$E:33IR`<7`PW==I!1M\nM]^?$UA#I"*J-"N%\\Q&CG.%<.?Y"IHU4*75T88S#&8DW;8]-4$2<)]4:(P7#%\nMUJNX<>TGU<QCU2_?](F;?WRVXF&)&?B5:WZ=FV_]JKCGN]_P'GO@WUBW<0MK\nMUJ]GH*^78B[`=R7&:!+/(?(<.G(>K;!%5K=\\Y-J/4<@&&5U1Q!J-R11&:[`&\nM8PPJ3:G5:]3#!E>MNA3Q2L#=W[['E*K5BNLZ;YKO9P20Z^KCZ+%7>->[KZ9\\\nM[#"_V+^+P_M>H*>OG]'QE8R,CM#=U47@>;A2D`]\\TE2Q9?U6MG=N8^3(47K*\nM1SDR,LFA8B_U:HURM49IOD2I7*):J2*%):Q6V+5[-\\+WZ>CN/FV9/&L`:RTJ\nM:N`(R?#J#4RLVT#2J%`K':<R/\\<+TT<PUB*D@W0<5J]<B9OSN7SC-;S\\R$,,\nM[GF*SET/49VXF)WKKR)+4ZS.$$*0\\STF5HXCI21.%>.K5G'PY<,D2;JLT5\\2\nMH!WM96ZF#:F0Y'N'Z!\\9)^])7#0JB8A;+9(HHKNC2*DYP0^G^_@GO\\&.N08?\nMSHW0?\\W'N7)P@DPIE,IH1BU:K0B=98"ENZN3^?D2!PX>6I;P-P%X;6AC2)3"\nM6@?/=1!N'I%W\\-P\\\\^YQU(9#;%CQ<WC^'/ZC\\#X>P^$&.\\G`S*LTFR&-L$$8\nMAA1R/JO&Q\\@%`85\\CDJY`F`0(OT?!7A-6-M^(3--/:GQ,WT7F3I"U&KQX8WG\nM,G]CQ"./KN/P`8GMJ6%L3*H4UEKRN7Q["2X$4IPHT18X$]-YFP`60@K)L\\V?\nM\\4!Z'[)L&1-K(9]CZHBALS'(V/@T7@!)W,YMQW$H%/(GA`OQQAZS;`#/D4@I\nMR;+LM!<)(6@V4Q[</<5+JL5(/L?VX=4\\L[_$*P>V<]Y02/]`2IPL7&`MN<`G\nM%[37-5)*'*==-ATI\\?+YMP^@7JU2J]=9N6*%]EV'4P9)@%&&'[^049*?XMS#\nMH^CR7HZ</P*MR]BV+F.L-VZ+M[3_"$%'L8CGMI<1*E,<GVUP?&Z.GIYNXBA^\nMD_[(60`\\N_->=C_Q")=?>P.;ME[$R/`PGKN8L^`(P2.[6GP_Z:$0:39&.Y!R\nM%.-,,EZLLWHD(HK;*];%8S%=&LTF6$,2)S0:#4JE,HUZ0T91%"Q/_A(`EU_S\nM&_S^%_^:^^^ZPWGFYS]E=-4:UJZ?9&AP@.YBGD-'(NZ8R9%IRV6U*AM76;9L\nMWT10<-&I1,HB2=)>O!F38;3&&HW.-*U6BVJURGRYS,S,#+5J!5<ZHJ>[6[YM\nM,V`=CQ>>W\\6Z\\[>Q8O5:I@_MY<F?/8"?"^CH7,&_-#8Q%71SV<P\\*TR%U>?X\nM3$ST8(W!FAS6:.(X(6PVJ3<:U,,FY4J%4JE$M5*AV0S12N&Z#L/#PX2-D$JU\nMBI3+ZW(N684<-)F&7/<`6W=<A6-2ZG/S?'-GR-/C74Q.5]A"G<P<Y/@\\S#Z\\\nM'V,,6:86C*M]Z$QA3;M">H[#V/`0KCN&Q9(+`IK-)H\\_\\>3"OMHL)65Y`"PT\nM/(RU))DF<'V>F.GGF97KZ)ZN<:EN,+["<NF[+T/2WM2+Q:NL(4W;`*EJKSZC\nM**;9;!(M=#,Z.PH,#?0S-7V,M_K;S)OZ@!3PPH$6WZMUD%:;7%&K,C(2,7GA\nM`+$5I&E[?ZS2A#1-29.$)$F(HA:M9HLT32CF<_B>2T>Q0"&7(Y<+"/Q@H3.$\nM08CDS70L"T`*>'4FY1^F`\\I6LN'0+.>,)VRY9(#NGAQ1U';9)$E(XH0DCMM'\nM$I,L`$DAR`4!ON?@NBY"MF6+USKQ\\O*')38T[52P""EHA1G?WP>'@@[ZGG^5\nM;9TQFR[J9GRBA]>G;%L4"+D@;O$!4BYLA!8;6G+!R.0O>T+6+CN53ID!WW/H\nM'0B8G6IR_^Z,_RH,D7OQ.#O<)INVY-APWA#V+`9,RI.$.VWAQAJ.O3K#GGW[\nM<5V7?"ZW3/E+`#SWGR]STT;%=YX=T3_I&$9.U;@LJ7/NI&3SMI&V`'TV,RZP\nM6%*E:$418:/MP'/S\\^T&5E>7"IMA(I9I!*<`?.U?+;?]*#H_?G_O!6YDN;Q1\nMYUVK#)>\\9YS>GGR[TIC%J?_EWM@L'B<YL+66*(J)HQ8J3<FR#$&[%3/0UT>E\nM4FG.S]?^KERN[/)\\[ZT#?.9/;N5;CUPG?N^Z?_R#9[UC:],]&>,R>65TLN_E\nMGL'B!L]Q^O.^XTA\\LKR'2@.4*J!4BLX6^J191I*F**5.\\H64.(K;RX=R.9HO\nME:?+Y?*CM7KM[E;8?"A?R,>/__2^MPY@D7SNO7_1V:>.;?TU.<^QCNBEG0],\nM?^&CG_OL_<TH7:.4OC!5SE:!F30Z&S=9UFN-+EAC`V.M,-:B%_8+29)DC3",\nM&XVP7J_7YVKU^I%ZO;XW#,.GFLWFWC`,9_S`UT_N_,FRA"\\)4*O5L-:.]/7U\nM#7O"W)WW9__J\\*';=O_-K??SZ(,'=]WSQ-Y=.#XJ;GE9FG:D2=*1)'$QB>-B\nMDL0RBJ(3I31.XB2.6F$<1<U6JQ6&C3!R/=?\\\\YVWOR7!KX_7O#EC*]=@C=FX\nM?L/FK>,K5_^[XSCA]_[^&V_K`_\\WPN6=_`7_+.._`;1\\W/;1=!W6`````$E%\n&3D2N0F""\n`\nend\n
105979
 
6588    group_48                begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```-7TE$051H@>V7>8Q=U7W'/^?N;YTWNV?&.WAL`@P&CV.;\nMS28V`0/!A*`D8)(T`:5-E*9IJS2*4-14*C1*VH16+`UJ0IN$+"IEST:<!'!Q\nM`B088GN\\C<T8>_;UO7???7<YYY[^\\0P)A)1%4:5*\\Y6.[GGG2N]\\/^?W_>F=\nM!_.:U[SF-:]YS6M>\\_I_*_&'7JQ8L8)RN6RO6[=NR<*%"U<F2=(],C)B#0\\/\nM[YF<G/REYWGRZ-&C?S0?+2TM3E=75T8(84115#OCC#.BYY]_GM?;PWJMQ6W;\nMMA$$P8+UZ]??U-^_=ELFXW4>.7+4":-?,'CDA>DPC#Z,,!Y^`\\8,0)\\<+ZM4\nM*K%QXT9&1T>;5ZU:M6G)DB4;B\\7BRFJUVG;LV#'KX,&#)W;OWGW[T-#0CSH[\nM.QD?'W_C`&O6K.&!!Q[@(Q^YX6/+EB[YA*$C!@\\<Y,4C`W3H(YS5/MNZ<R;]\nM^YZ>GNFWG;9JUXX=.VAI:6%F9D;T]_=W+%JTZ.SV]O8^UW67U6JUXL3$A!P=\nM'=T]-S?W/<NR1BW+8OGRY01!T+MY\\^9;-VW:M+F[N]N9GIYFW\\``QUX\\CE^K\nMK_9K06\\FD[DB"(+#;ZH"?JV&$,+<L&'#RL6Y&59>T$=GC\\W%IRZE*`H,'PB9\nM_>:)/J.E;=WBA5V[SCWW7&JU6F;3IDT?7KUZ]4?[^OI6EDHES_=]AH:&V+-G\nM+^/C$Q^,HGC#U-3D#=ELSM^W;Y_8OGW[7RQ;MGQKM5IAY\\[#'#LZR-CQ08SZ\nM,!<NGN'QN<JI?J[KSJX%G9]R'&?O$T\\\\\\9H`YJL7/O>1\\]FR]2IC[,`3_3=<\nMM?:\\_O/?2=?"4R@4BX@T(J.F$+47P^>'@KOO?^2)_1_^T+6$47SCIDT7?>62\nM2R[MZ>[NL2I5G\\'!H^S;NX<7#N_#GQUA9JZR)(QE.55J7VMKJS!,ZZ^JXX>6\nM+K%>H"AF6=F>L.6<3JY8W\\U%ISE4ID?$L7K'\\F7+3MG=U]?W[)-//OG&*G!J\nM3Q-1?/SL+WSRXJL6M#DDY5&L7"M"U='U251]FO-6Y=P++KGX^C08>_2<C]^I\nMWK/MDO<&-=]]]*%O$==]@NHL.JZPJB"Y<K.!&[M\\_MM^?MSL_=*JWA75!QYX\nMX&L]G<WCUZX]DZNON1$[WXU6(:H^0SQWC%@';%O7P:^.CP1[]UO'1D:&WWB$\nMDI'_)HW"H6+[JL>HU0K)I-5EQ-VDL8^LG$"&95TLY/<7\\^%/FV?O][LZEN3W\nM'SCHZ;E#?.JZ]70N[,6Q!1G'P!$QRA\\EGMK/Y6>/\\^V]RBH4FPJ/??.S'9_:\nMMGCFX@VKT$HAHRJ&:2$,"T,8:*WH;!)<?58R$W6M=-_5.VW_>N/JY)I_>.[U\nM(_2])V?Y[ET?#69^O?,'AI,FR/"=.@F$K$T0S9T@J8Z.A]7)ZQ;?^/1]8L&Y\nM//382&*JB?Z/O6MY_Y;+KJ%IP4IRI4YL-PM:HY,Z*JJR.#?#WJ.3_J.[9__Q\nMVO-;SKOPG*6?R]G2-.T<IFEAFB:$LR0SATEF!XG+PRP[I;=XQIEGKMC_W*[[\nM7$L'WWI\\ZO4K`&#V_1-C=Z]-!>H>&4Q>HL*YK>@4&4<R5OJVX1W^4T]_1K#V\nM"T^R>?--&X;W[RR<<_HB+<.*,(6%86<QA$";)@*-EA%96W--OQ-LOV[SVOH+\nM#S^FO=Y'=*9I73)]H%O("KAYTOHL,AA'Q3ZIDE$FDSUD50:^?LO-1Z:^_+G,\nM&XO0IR^`\\0F,'^T=ZG&<=+D>#8XN6UQ(W6*;,3-1K9HC$Y6)]9DUQRKJR%J8\nM=9.)RRY:?\\9V'4XC_7$,(1`&&(:!"J=)_6%T.$VJ(M:=<WJ'V9G[RP/3^>_G\nMH['W!4GU6IWX=PD5N*F31R4!TI]"!C/(N+[+GQ[Z0'O/Z6/?^??S=,^?O$X3\nM?_9RZ%NW@HGAL26;/[CUSWN6]U\\Y.G#?PKV[G_&L\\1G1[$S1C&BNM5I?:6Y?\nMZK=VMP[<<]."KW6K\\OWI61O7&Z9]NIP]O,!0-432BC9,TMI8XS1EA$[3R'&]\nM$WIZ]S?4GH-'9EMZI>W$#Q)6WQMK?;DP'=*XA@S+)''=CZ+H=D^,#C_]^!$N\nMO>TUO3?2\\M+DJ@MM)D8FNU;V;_UZ[]G;KG=LT5H^OL,N=`AA->7)M><Q%Q>0\nMBS*&99N>96<7R2BX9+1:&6G+.']M*_\\(LGZ9(+5%FJ`B'QE,(_U)$G\\<&<X]\nMH;6^QA#6#SMZNY)%1[_"=.G!R)1RH%Z;VZ*3:@O"(#::J%2J_QP?FKY#6BJ]\nM\\%;]A]V_5(%;/@!M72OP*]/;FEH7;8G]$\\2504PCIK.G":\\WBV7;:*UQHYBZ\nM'U"K#B*D[]J&^M.=^_?>NWU]_\\-E&>V0P?256L4`R+""K$TA(S^02?A577YQ\nMJ-<=('J63.G,]ZRR#+<O\\YN)%3=7;7-QMX?PFIF=J:3!U.PI'^LW/AX[WD%Q\nM2_TYO4M/L`C-G7^@`EM6PYH-ES)\\;-^'/-=8I\\,Q5'T82P1D"SERA3RY0AXO\nMXV%:%B#0.D7)!)4D&8W^R5P0#G27G$&91)O2N-8JPS):)6`7TB2<^]=<9>:V\nMI?\\1IX45I8NVGK?UB]M7;[]).?+]XT</;^P?$,UM]01O?(Z%02+&,$_[6:^[\nM=55GWS5MV;;+@HX@']G10;%%U/G9:P"\\XTS8_>P>(V-''Y#^\\3/2^@D,7<7+\nM>F1R67*%//FF`EXVBQ`"I21)(E%)0JIB(TGT3Z_^PH\\/?_G!A>;;.[^_Q#4K\nMYQB62VBV,'1D</;`X^+V\\^[^S_'\\]3]Y]_O.W7;7N_O>W>]Y;O9'HX^(<JG.\nM6-%CRG*8+&5XIB?#0VMR5%HL\\D[.:O)*G7&:;*[%M<4J5#_G'=1Y[%412C5D\nM/>VH5+2E:8H?2-R<`)V^?(\\4PL"R+4S+Q+(L0N7@AQZ[7U@N!J:N^.3Z3?Y'\nM!YX/%^U_7K4VVS.,#\\^@U#Z:(]7L3ZS[-[M[?+QMS]^T^ME"Z[.,4EMPB$HZ\nM0ZF]0+`DPV\\<A_V&A1:@I*0]C*B$DXR$PY1%8"A7O0_)T[C<RM\\!?_L[`+$4\nMI!I/*DI2:<*Z35%Y)'%,'$6$]1##-+%LBSB*25/)X1,=_/`7E_*VMU_!^Z]>\nMNOK>'2,\\,U3DJ;%3:?_%$99G$CI=DTG5*AX6&YID:[YI07,W8_LDS_U\\%'M#\nM@K71I)AQ*65R%#P/U[9I^)'X=LB<64-J22T&/&V0<!D!7\\6F_HH*Q$J3:G)F\nM(DI1`HGA(LP<]=H8IF6#`)DDF*:%3B5#)PSNWWD!%UZZC5-.;69L+N*I0V54\nM^T)^G/T,NZQ9FNP$TW:8-EJH%(L02(X&B@6.0:Q*G/C.&HIRC.[W'Z*0\\2AE\nM<^0]#T,(ZG&,;9IHK9%*$262,$X(XJB+E!S&JP"T%J`Q$LE`/6;"S+K:=(K4\nM*T<Q+`O-;P%`<N]/SEJ1:SN[PW%,]@^6.5&5C,<:6CS2IF;*A<64/0M,`U0*\nM40)^S&0Y9&HJ!%^BDRSRD0VD6Z9P6S4YSZ,YE\\.Q;?QZG12(I"2(8CP[Q+4M\nM(CLI*)GF$4R]$@`-@F&IN2Y.$#G3P70*U,(8RPX1"%(ER68T]_Q@J?O0KO[O\nM7G:%N^7P8(7`,!D.4R+;@H(+)1>:7,@Y8!N-!JLGX%EH4Z`UD*00*L+9-FJ#\nM;8A5$PC`,DTRMDTB)8YI8ILF3N1@86);-B7/S<_&Y29-VO#\\$L"7_@N`%*@U\nMN(Z='`#5DP/@\\T!BN6[:_*M?35)JET19ARG#0-DF9&W(.U#RH,D#SVH`U&*P\nM3-#ZI'D)08+V76K36<(D(8AC*O4ZB91$4I(HA0;L:H94:P2P(-.92>JJ.4XC\nM0L+?`KQQI8"1BR+5M'?O-&8N@8X<JBV'[L@U3MP]"=+D-B"TACFS$:50-F`R\nM5@/.M0EF7:I!'5-;J#3%M1K/6A01)1)/%4@B16Q*'-MS2V93B[(4PPR_%0`-\nMZ"+HHM8:F:18LHZ!A]+ZMW_=A0#+:(`8`B(%K@6.B6U)I)6B;8-\\T476LLSX\nM`5)"/4E>;MXP24@238=5)"PG)*Y$B]3,DNUHR;:\\50`)Z&:P,I""4F1$A=0H\nM4DM22!3$*42-B%")P!00JT:4@+Q1IZH")!;%)ALO:?5GRO41I;1^"0"MB97$\nM2!T*7A-A(LEY1=S4,^?",KEB#FX";GYK`"T@/9`@8W)&%26@%B102\\"/P#,;\nM)Y^D#8!(@1]#J"B9"4%<0\\HBIJ/IG#U[]R]_VGG]BLM'PC1-L<S&_3)1$@>3\nMC)LC5C'5H$ZE^AO":A@<KQUOI/FM52!M!]."!`C).1IM"":K)[/MG#0OTP:0\nM*1KYKR4(/Z'5-1F/ZA!GB6)%IN#E]!T?JAZZ(SL+?_9[._Z:@[^WIE`OS]\\$\nMP"<00@(LT#H1$`,IQ:R#81LP%S::&!KFZ[+1J*9HQ">4&'5)US*'@Y'"C!6.\nMK;$,W0Q67HAD5O_O-^?7U)L`$`@!6C,HA/R&UG$*BDPFC^L84#T9'5,TFCE1\nM)P%._A;$"A$KVK(N1@*VE'BV(4Z\\6)X3*/E6S#=<O2E]\\G?F__+6=GR%OO2J\nDSY_^(WSGO.8UKWG]7^I_`-&_R"!F]V"Z`````$E%3D2N0F""\n`\nend\n
105980
 
6589    history_zoom_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```..$E$051H@>V9::Q=5W7'?VOO?<Z=WN3W;,<.CA-G("2!\nM-*(A@9"H4`J(4FB52A64-D4!E:E252IU5FD_M%^0D%!!96A*%41+JQ8$14!5\nM,08E)"20./$49W#LQ,_#>W[OW?F<L_=:_7"N'2?A.39$;3^PI77/UKWGW//_\nM[S7MO1;\\;/QL_%1#SO3CO9^&S=N0AW_$_&-[I*GZW'N<`^=/$P?B0&0B[IDO\nM,3M-%'0BII`BJ%*9VI*`ON=S/R6!K_X-F/&23HM/+QZ0K:O+F`B86?VP/!?\\\nM20*G$WG&.(W`2>"JH`DT(:HR-.7/$+YB:KSW>4B$]7[XR&]#KP>#(6^:W\\"-\nMG3FCNR(80G-J'N>S4X"=-YP_';@]K0&QIY?)[)D:2#;1@*$)8E%2#`>8\\`>F\nM?`>1'MA/1N#H<;C_0?SE+^:ZLH2%#1`RB)7C);]P*UM>?`.F%3!91DX34PP%\nM2_5\\(EA"53%53"?S=/([8W7Q81Z]^]^P,BX@;`!Z9U[_,Q`8%L+TK$POG;!+\nM8JQ7(7C0<:2_?(CF]`*FZ30"Z13(4R0F<].$69I<%4VQGJNBFM"4T*1,;=Q.\nMHS-3I6KYPYT-_N!@-3T?_O4)&((XRBK)1WH#YIH]B[,9-P&WK#SY$.5@!9\\W\nMB=4(P4BI!!01,(V4XR%9(Z,J1GCO)]HQ8E4B&*9*K$I2C`BU&?57G@*+3XIP\nM]V`MS2.L?>H6TN_>_A,0^-BW%&`(?![@$^\\0J-@OPLW#U2>GAFN+9)V-C/HG\nM`"-D'N\\=Y7B`#YYBU$=3#AA./%4Y9CSLXYR08H7W@10KLBRG*H:,>LMTC^Y%\nMQ&9\\X'U$Z9CQI\\#*F?S`K<_MN3K!["%$=L6B1^_X8V19H-EJTVRU:+7;..\\0\nM`4T5(H8/CKP1,(M`(LL#(?,X!\\6X3U7TZ*\\\\R6#E(*/N,5JS6YC=^I(%<>Z#\nMXGBS"`O/B6(_.0$(#5EVCMO,TKB_].C$22-ET2=6(ZIQ'Q\\$[R'+/5@DED,L\nMC?`N8K&'EBL03T!U%"V.H.4)L#&-IB<$1]Z:(F0Y(FQ`V"K/@W!=$WKV>._G\nMX!_>">+XB@B_VE]^_,VQ'`"&I<B@.\\`Y1ZQ&>)<HQZM@!5XBL1HS'@UIMC)T\nMDJV<"*'AT`":'"DI&@W-<GS>0(IQ2T2V/Q^NL];`IWX'G!-$>(?S_&+WZ%X6\nM]WP=U9*0>;(@:+F,%4]1]A[#I24"79P,P$8TFR!4.$F(*+$J@%2+382$<X[0\nM:('@1+C`/0_"LR8@DP\\19D5H.>]H3F_&B3'N':6WM)]Q]Q#%<`6S"DT5*564\nM18&FJHY,Q9@4*XQ$2A58I(Y.)T-O`C%"WJH3HO"BT!3^\\=;U<9VU"?D`8"`L\nM(H)IA5G%<.4`H^YA(.(\\^"`XT7KN!55!O:O](@54%4U*NY--$MK))&?U_QN$\nMO(F(@'#>N*?>!]9-"&=-X-;;X#/O!N"8",FT\\MVCNYG9?`EYYA$GB#.<4T0,\nM<8II9-`?X#WDN6<\\+HE5I"PJ6JT&J4JH&J9&52FI4LS`A;S^/[6-WDLNPFB]\nM4'K6!("3)G1"A!*T%<==L(01D<D&QTP1J5?6.:/5]H0@.`<A9)@%-.6802R%\nME!0,O$^,-($*Y@/.>U*,LSAK`J.?6@-P:F?9%:$0H97B"+-$BB4Q%I@EQ-59\nM.029F!&$$"B*B*E2E16Q2F198#2LT*1D(3`<%,1**8M$[@UQ'I%J2D0:]=M?\nM(`U@#!!*!#2.,8WXX'`^(,X1`B`![PV1>G,7@A""!QRI(9@:JE9'KE2;3[N=\nM80JQH51%B7,>I-Z^GVF<HP8,D*X(RP*;34O,:IM.L42<TF@%O%.*48D/T&@Z\nM4JI-J]\\;@TVVT$FIBH23.@<(0BQ2?:\\:XCT"3YE9[TPDSBD3"W#=F^:>$N&3\nM"-$T@D4$Q0<A;WA,(ZJ11M/3:#B<JS4A*.VVI]T)M%J.X*'9<C2:0K/A"0Y"\nM)CAG6.QC6B6$.UIS?G`F3/Y<"'SQ7KAA4X'`X^)X?=9L;>ULV(9S]?[G9.PW\nME&(T1C76&BI+1)2JC)1E12Q+RG'%<&24E3`>1V)5$:N*87>5\\>K!%8WE7YK*\nMQS5:<<LGUL=T;CY`;4:#+L>GYM@)O-PL@8)@A,S5><#7-AXR(\\NE]A%GQ`I2\nM](ST(JK.99SHS;#65ZHTQEN?*8[0#@\\0LJ6&J=R08O5Y1+IGPG-.&OCL^\\"4\nM+.1RI?,46;/SQO;LULP%(03!ASKJE$6!640U,1Z-$91B5#`N<T;M-[!OY7KN\nMV%7RP.-K'%P>L;A:<FC).+@RRXFT@ZPYG;73T2NT&@^[Q_RWWW83?/&^'X_I\nM'#4@&&P6^)`F_LJT>C!5H^N<;Z)6)S!%R7-W*IE!(`1%&C,4K5_GKEUM[MV_\nMCXM>O)T;KKV,W"?*\\1J#[@F6CRZS>*AB97@%%\\H:V_7.6Z;GT^V&[%\\/T3D1\nMT+H:D8O(R\\3)6ZOQ6CGN'4'"-H;]/JUV0)RA%A%)Y`V'<XJJ8`NOXP?[Y_C!\nMXX_PRV_Y)2[8.,UXO,KR\\B&JN,QL<\\S\\A0VV+0@/[R\\YU'\\%OCK:OL@_W(QG\nMP'1N&C`!R(!9X,]-*8K^<=JSYS$UW01)>`_@0(Q&[E!+)+^5I?)EW+G[/G[E\nMK:_GLO/GZ?5/L+9ZA-7E@S2EH.4CGDBKE;CJ8MAS8(I#RZ^*_6Y9^9`##[\\`\nM!.K1QL@P:^?MC>WF]););E,HRP)Q1@A&"%"5"E38W,7L/;#&U.9-7'[!%OK]\nM%5(UIM<]1L,5-"AH4"*QP)O2:`OGS^<<3!=/W?-4?[-S?N\\+0F!2SYHQ:!C@\nMLC9Y9R-(?3)KM0*@B%/RADR>\\3"[C<.[5]AZ_GG$6)%2!"J\\E#B)-'VDH06.\nM$:(ESN4L=`KZ<6LGSUL[FJW.=]?#=.X:,-8P^A@=D8"FA+C$8#`BQ8J\\X?#!\nM2-$A3HDQDE5"45;D0%&6Q%AA*9%[3Q4C6`560AQAY8BL,T^[V6"#FY$LST.[\nMW5H7SCGZ@*'*;N?EFX:\\75PX51MJMS)$/"$#Y^L]D(C0R!Q1NW0:FSFVM,R@\nM*#"MZT)9ED'N".)PZ@CF,0NTIL[#,4]NC6(X'#XU'(Y?&`).P652F=D]X-\\N\nM$E!-B"FCT0A06BU/THB(4A05(HDFN[APRV4\\],.]'#QV,9LZ#JTJ^L.(1"%S\nM`N9)FM%JSQ-F+J;H>PXO'CUTX,#!/;,ST^MC.EOPG_HM*"IDY8@Y,V;`@W@T\nMU96W5C/0Z62$`*VFI]7RS,WES,TU:.E^+MAP@FV=-O?<]P`KHS%KPR&KPR'C\nMY!C%P"AEI&R>]L8K>?QH9'%9V;]GYW\\]LNO.@X/!^LGXK#/Q6ZX!H)4WY6;G\nMV.&<>U7>FA8?LDG&+8@QDE*B*B.J2E4E8DQH+-#1$6:W7,?CCQ[GP+%C],H1\nMJA'O!!%'EK5QV0('%BN>.`*+^[ZG6\\??^-@KK]JT\\\\O??'!=7&=M0E;W!F9P\nM?$!5]FE*>P>KAZ_P^87XX&CD'N?K4Y@:.*DKUE"7X\\-X/UOE"[SZRC?RHT?Z\nM'-YWA.FYC.&4IYTY7(+1<$2OIQP^]!B7N^\\=NGKCXL[QF;+8.1&HD]A6,:XT\nMX\\:L/9^R9A--"><`-SF@4^_]1V4$4T*`E.JS+Z/[V>0.<^V6ZU@<G<^Q-:-_\nM-+&6*IQ%FGJ<1K5$>VH[1T:O/G[7/?=7'_WA/KE*L%WK5!?/-8Q>;,8L)A*R\nM3LB:4\\084:UJ<PC4@#7B?5UE$`,G=<_`3,BJ13;IE]@@,UPTLX%A$8A5Q*<N\nM'4X@9NBFBW3'PDT_OW=I_Y<^L./\\#[[K5==\\Y=?^Y:L<_#$DUCWK_-YK'+T!\nM"S_W4GO?;]QL"U,=TIW?DI<_\\2BOS?+`S'G;"7E&3!7>&VJ)$$`U@2A9)J@F\nM8DI@AO?@77U\\/-E?$I04E5@9F@PO4)61A?Q2O;9QK7MBYTYV;[ADSQWW/?BV\nM+7,S.V_[_@]9?!;.=9WXQDNAU>`-*?%W6S9S8XS<L'A(=@RZ1LB;-#JS,#$7\nMTX0PV8VJUJNOBF`XC"R`3,KK#J/N&4RZ,E6]K`Y(44G)Z*\\M6;I[Y]J+5E<:\nM;GINDVS>=N%W[KKWOZ]8F!L^V!\\^/X$/OZ-6^_04M[2:O#8+T._!TF$A)2%K\nM3I$UV]25`N-D`792>L1[CXC@O,-,<%(?Z)T(PJ38E4X6LFK1I*<D8:O=$1_:\nML)8NG>\\O+<B6[9>&A?/\\YQ[8_>T;6WEZ-#Y=Y_JQ/C`S`V6%;-[$12_:"BNK\nML'2LSO9U8R\\#`EFC1=[JD+?:Y*T.6?-I"8T.66.*T)A"1(A%74ZOBAYQW*4:\nM]2A'7<I1EV+0I1AV*?I=8M7'-!U8N8!_?O2`+%TIHT]N?_+!Z>'%KWSO.U]Q\nMS9X/W_.CVZ[RPFX]`X$-<_":Z^'^O51/'H8CQZ`)S$PJ-./^"<K1&CYX?.:>\nM>0T>YQW.^UI<W6<]:6IU3VS25HJ)=+I4]=64'VRZQI9O_P_^_?U;Y>K+5@[_\nMT8X3CW6ZEUWTH7=?<N'#[[KQ^CO^Y+MW4[&.$W_M;T$-O./F;H^/#@?,#I;%\nM_+.B@$QBO0]/]XN?TV*5TUJMD^=/]8A/7A,3LT(TL:3*K2)\\.WP'5A,+UW?L\nM,]LZC;<L7OYJOK]J=_[GU[[UF[.M_(DOC,KUH]#.?P(1`G#)TA'F']DEEIY5\nM8CU3GUA<[4>G$[#)QS,:W>GI7G&J":RHVGX12>_YK/'E2X65R$NO;MF_-J9G\nMK_Q&?@&[GSCZ\\;\\_=/SW;_"D=?/`U>\\$(`+[GK%\\_VNC?M_7U^"/MX6'[EJ-\nM?S$[V[YMQW2V,LCB'8`Z>9Y._?^7\\=>7SC`PE]TTXUZW/8T/_N'.X9Z;&]C[\n<B_]K9"_`^!^SUBV>APA13@````!)14Y$KD)@@MTT\n`\nend\n
105981
 
6590    industry_add_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```.Q$E$051H@>V9>9`<5WW'/Z^[9[I[9G9F3^U*UF7)M@[;\nMDK",9,`R"190X<:IHB`NCL(A0)(J4I2!).8P<8P3RJD*(2G`JAP02!544BY<\nM`9N82BCC&&QL#/B0)5GG[L[>,SO3T]/'N_+'[-J65P)A!?_E[]1O>OIX7;]/\nM_W[OO5^_@9?TDE[22WI)YR'Q0ANFNT$('&/88BPG@*3\\Z+FU/3`&P!A0$$*,\nM*VWYT.P+\\\\-Y8<UZ*GI8B_@CB_A(HBDT=YUK2P&(;0;Q#ZFVFXV`OQ]Z83Z<\nM%P`5+%`VEIN%Y6.I%?[LCG,/JH7]QO*51+-).O#7_;^^"^<',`DX#N[.5_@,\nMCGS22GMC;/%/7?:K(8RT](VML4.7;+O66+Z2:C;APE_\\FA#G!Y``1E/8^QK"\nM]WXT%`.#-PEE;TPL_M/;?SF$T1#4!KCR]][/V-9+]^M>)#8CX%.5%PO``2Q8\nMF5'<^]M4KO_C4/0/WB24_7AJ"9[<]LLAK)*$Y0J[W_8.QC9?O-]8OIP8-ED/\nM/GZ.$.<'X"YMLQ0;M_%W[J7ZN^\\/1:W_)JOM38DA?'3+62`$6*U1G8@P#+GB\nMM6]@U8:-S_0)Z\\"?G`.$]_P#-]W^CV2Y+`S5JN\\H^84-)X\\=,8_]XE%G\\M2)\nM^\\)RY?Y'?O0_*P'R%.((F^<$VW?1_^9W^3/?_K>/V<662(6X]<&+1;+WB%T)\nM8#0Z[H`VA(4"5UQU-7F:[Q^?JA_(C?A#5W#HPV7+E^*S`ZR(@$%@$`4#'[1P\nMJX7;1H:';NT?'+CVHLV;5C@!8&6*[;9[%K<)+[Z4H==?Y[NU_ANML7^>&,(?\nM7K0R$E;W`%0<H:(VH>NRZ_*=K!H:>8VQ'.AJMH#@AO#L`"LB\\,H??YTLS1@<\nM&:)2J[)F>H&)KF6X-<<%0V6^>2;\\/,-V>Q$PN41WVA1+)6I;+_.SGS[T,9OE\nMA:X1M]R[B?BUQY;8!:`U*NZ`TJANEVRA@=MLLJU_@&X[VC>59@=RPP<<Q*'W\nM!):OI><`\\*9C_PUM0(Z@BA<QDB9LVW@%=6E8O^]5?.(_[GSVXN>DD.U&F-8B\nMJGX".3^+3G-\\K1E8N\\[/3XU_E"QW,RMN_LY&XGK*4@H93+>#27/BD\\?IUNNH\nM3.(JS;9"@5RJ?5-2'\\@M'W"%./2.@N5;\\E<`X`AP+#@N=LEDU$;%,>GT].G7\nMBB5'9`;-6?3)(Y#EN-M?SF)IB'BQB3[R!%5E"_G$Q$>R+$=9<;,KB#7+G;A#\nM6I\\`;1A\\TW5$Q8!H?`+QDQ^S7<V3FVS?E-0',L,''"$.O=VUW*E7)L'9)2"=\nMGB*;FZ5U\\(G3S[G+%W2QTZ<0>49TQ7[^:D+SOF_<S:T_&^??^S;S>&TM`ZO7\nM%+QB\\2/&VL]671LBL-9H\\OE9'"%(WOI.;I]8X-,//,)=83^_V'L-4:G,Y84"\nM0XZSS\\"!5+/%",'ON,^Z<'8``4((A!"D,S.D\\_.T#QT\\`P"]_.]&F+$-W-4P\nM//'T,3I11*W6CR[7N-\\=8,XK,;H$D5D^YPBJ5BFK&O.P:P_?GVTQ,3F)48:^\nM:C_)R!B_&%F-`^PL>(P(L<_`@<2P!2NX=LD%#^!;FP06JBZ\\[JXF8<6AN&6Q\nMN\\J=FB&+),6DR05A9^?&XN+U4SN%4Q2@+#@&!&RV,D=82U0H<WARADLONYQ+\nMMFPE#'QDGA-903U5;*CU,3HZYHU/37_8U?E55DK/*LFLZ].5DCU7O8IRI4+<\nM;N&Z#@W'([(P)`2[7)?<Z'V3QGXNL5SO")%B;0_`]K[&$'Q!"-8HA#TR'PF_\nM$5$44'.@6.5MUO*VYQ?@`H1=^J%:"SBJGZ</'V;MVK5XE3X:"PNX28>R,&`M\nMY7*%U2.C?CXS?96P!L<8U-P,B]K'&MBT>1.^']!HS%.,VGC68H$*\\#(A<+#K\nMCF#]$)$^$X%E!RP(:Y?WED\\\\LSW3L>>0.)069UBO+.,.K+Y@#0B':M%C333#\nM^E+QF2;5<IGAX1%^%C5XG(C#1W[`D^4:N9+,A3.4"WWXS9@UC1FJC@/:8($^\nM8+>`S19<:[E[&>"*D@4#PB_B!B5<S\\5Q'%QWV5Q<U\\59_NVY2\\<<A+'05T-;\nM2X!A?SI.D@CJ]WV/4,#Z>(Y=)<-`H8#5AMQ:?J#:W%EL<FI]P/`%%[)V;!T[\nM@A!M-8U.@R?FCS&_6&?U^AC5\\-C9</`06*``C#SGN7D`%_OTQOZ]N^&-[P8E\nM068]4WEO7R^94;W]/`&58;,4D>6@>F/;VL#A^G[)7&<!JS65/H<"1:PR'#<9\nM?Y=.\\<10E3=?^T%NN?JMK!];AS**=K=-*VG1ZK:8:\\URI/XT/SKT(%\\[\\G.V\nMGNKR]N,N(VW0SPO^L_.`!H(2#*WN.9YV(>U`EO1J'2E`*^BT(%[L07CN,QUH\nM6=9:2JY@;;F(E@:E-$9;'E,)GTHF6+5G']]X_V?8NF$K"]$"<]$<TDARG9/:\nME$A&=&W"X/`@UY2OYH+5:WC@J0?X4JW.>WXN6-?HN;H2P*'G5-R")(;C3Z*L\nMP6B#M09K+2;K8I.((._BNH)GIV+`6O`*T#^*EAJE-%)JC#(<7YSCYL8DV_=?\nMQ^<_=!O"$1R=/DJ410A7L+&VD:23T.PTJ8Y6&3]ZDEC'=&R7OOX*5V[?S4]\\\nMP;\\ZDUS_B+6[F["P`D`L`T30C:A+P7<*&U&.(4XRNDE*-Y/42A=R@W>85>G\\\nMZ9W86LS`,/>.[F4ATR1)2C=)B;HQWY\\^RLCNJ[GM#_Z23&7,17-T99>.[%`4\nM1:;KTSS^Z./<=]]]O/?C[T:2(46&%"D=TZ)M%JGVESB^T>-?BK+TPW'"K$B+\nM1\\X$T.U`TB'*).U2">&XG)PYR<GQ2;)<LF[5,/HL+^#:PGRF<&M#-#N3'!V?\nMYN?UGQ)7NGSA?9]$&LG,X@RQBNFJ+ET54W)#K*V19BF+BRT,&N5FQ*;%R>@X\nMX\\UQ%CLMNDF&"&%BC=@R7K-O$4/<0?\\*``7=")((QUJR-"-.$B;KTQAMJ)0K\nME$NEI5)RI00":PR+BRU.G:HSTYBCGI_@@Z^[@;&A,>J-.K&*B55,:A)2G>`:\nM@<6BE48IA74,\\WF=PZV#-+,FIJ`(RP6$"XXK$()";M7OF[J]DP'F3@?0L@>0\nM=A#6)>K$C->G4<I0*E?P@Y`@+"'.`H`02*4Y-3U)L]FB*]J4:P'7[+J&J>84\nM[;1-K&,2TR6W*;E)\\:U';P;JE2XMN<#)]!#6SZEZ)7*IR%*)Y[DXCEC.UAU2\nMJ5>(HKAK90HE'6C.XGC]M/*8),TH52J$0=@#"$)$?I8("$$N%7,+3?P@I)4V\nMV+3A0GS?IQ$WD$ARFZ-16&$0KL7Q``V>Z^%Y'KB&_EH%:\\IH;<AS19KF1'&R\nMY+Q%:^.3VU>67^;?M7(4BEIPZC!B[0[R7.'[(4&X9$%(&(8(>4;_$0*DTE@<\nM@K)/W.APV=!%1&F$'_A<.GHI6FL0EN5/P?.8.%S'8AD8[.>RZFXN6;4-:VUO\nMY+,6JV&R<XK;'[@5I6:14J,SLZ7QU;CXO!12,#L."S.(]2Z%HD_)\\0C#$D&X\nM%($PA.ALJPT"U_4HE4H4@R(:A5\\LTNJV&/:'J1^K,SD^V7/*VM[KA!`HK>CK\nMZ^/5KWXU!Q\\^C.=ZSSYMH\\F2C'4[5U,M5UCH-"CF'EE!#196N_[I$<A2F!X'\nMHW$<AR"HX`.52H4@"/&*/D'@G;4/"*#H!Y0J5<*23\\'SR&1..VE3J5:8.CS%\nM'5^^@S1-,<;TVC@.1FO2+,7W??K[^RFX!2R@E")+4[!PT]]\\`M\\O4"BX>)Z+\nMYSK"]<1S1B&7WAS@.N`(^AS+ODVC",?M/77'06J#4`K/FEZ^B*57,F'!<1!8\nM=JP=8?7P(,5BD?\\]5J79:=)*6C@MAYU[=O)G&_\\4X?0>F+(YA4*!R<>F^:][\nM[F5R<I)/W'PCP2J!UAJC#4H;!"[>D$`]EN,MU6"NZW1TT\\KG=>(<W`"",@,3\nM!WE[WL+X(38H];9^B"WZ%,?60'$C!"6$6\\!Q7#SAXGH!5]=\\C%/`.![?&QWE\nM@>8IVMTVL^DL3S4.(@H&Y:1T;(..:+!I=!-OV?U>@D+(/?=\\CZ'+BQQ:=2]I\nMEA.U$]I+MG"R1:PZN*Z+YW@(1XS+>W7ZW'?B!O!%K*VBE:4UCT@CW""$9?.#\nMG@4E\\$/P?1`NU@B,!6-!:XNQ@H+C&29/7#*=S%QW:.*0JP)%1T0D1&1.A!-H\nMRGU%5M6&T26-,;UR)5<9S4Z3+)?$:4H[2VBG"8GL8JPE]$K$Y!9M'UG_^>%>\nM"HE'`)@'<UMOP3,Y2R<]=XDKP1HN$16QY^Z'[]Y`%2A;2GU%JK60FE?":(O6\nMO4*P-SSVZJ=V.T$J19I*\\DPAI48J38$BQ4(?=3E7MSGWRWEUGDN+OT0V!G[*\nMT];8.V4FD9E$*8W6!JT,4FKR7"&EPEK01B/S'*DTK7:7*$J(XY0DR4G3'"-A\nM8]_%Q$E,EF7?GO])=$@MFM\\<``>!5V%0?`7-(118:9%2D><]RS))EBD`\\ER2\nM)"E*:MKM+JU6#R+J),C4L&-P+T)[U!M31W5LOGS!;PWJN3O:9U@7^O]4!.SA\nM*9[FL^1\\"4E-9IJL*"D4/!Q7T(F[](_4N/*J*Q@:'<2ZEL7%+MIH<BDIB2K[\nMU[V>N)MP[XGO1TF4WK+CT^L>>^B&X\\!I!?UO0#-`$6CP%&5:.+S2N@0XRTLV\nMD,@N1SH'.9C_C'KY&`].W\\]\\-(]0'CN']O+.+3<PUU[@FX]^HSV_L/"9[E'Y\nM3W,_;)NYKT;`>?S)]VOI%4`+EPMY%V5N<2K.QDHMI%(N$08%"H%+X!<I^0'#\nME1$N&=[*E6NN8B0<X^ZG_I/O/GG7>+L5?3J?,%]W^X2:^N+B,[=^<0``]@`/\nM(7@C+Z/"C6[%?4.M5JV-#8RP>F"4D>HP@Y4A!DN#6&LYM7B")Z8>:\\\\L3M^C\nM8W-[?+]^V-_NV/E_CDZ[[8L'L*PW`2D!_;R<$F_P`O?E0>"O#?QB4"QX(&RF\nMC)Q06CV,Y+O$SD-.B63^;SMGO-V+#["L'<`L@MV4"!ER`Q&XKL"Q3HH4C?3'\nA,A:KA+4//G\\!ZG3]'R,#]?7;5S!:`````$E%3D2N0F""\n`\nend\n
105982
 
6591    industry_back_48                begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```.V4E$051H@>V9>[!=57G`?VN_SM[GG'ON.[GWYD%,"`D)\nM>1@J@4!D-*&=JA2Q4UM`JJ-5:VV'CHI.I474B<*4/JQVJHVO%FVG3CN,S*@X\nM,#JEEJ((Q!0(22#AON\\Y]W5>^[T>_>/<A,`E&J'R%]_,=];>:Z]UYOOM[_O6\nM^O;>\\*J\\*J_*J_*JO`P1+W5B<C$(@:4UF[3A62`N/79N<P\\.`3`$N$*(<:D,\nM?UA[:798+VU:1SP'8Q`?-(B;8H6[N/-<9PI`7*@1?Y\\HLT$+^$+_2[/A90%0\nMQ@`E;;A-&&Y.C"C4MI^[4PWLUX8OQ8KUN05W]/SR)KP\\@$G`LK!W7%:@;_#/\nM36X^$AH*8Q?]8@B=&[J&1DS_!1?NTX8O)8KUV/"I7Q+BY0'$@%:XN]](\\,X/\nM!:*W[Q8AS4=B0^'I+3\\?0BOPNWOYM>O?S=#FK?M5QQ,;$/`7Y5<*P`(,F#S%\nMV_T&RC?\\<2!Z^FX1TGPT,?A/7OCS(8S,"4IE+G[KVQG:L'&_-GPQUJPW#GST\nM'"%>'H"]U*8))FQ2V+&;RF^_.Q#=/;<896Z)-<%CF\\X"(<`HA6RW"(*`75>]\nMB17GK3N=$\\:"/ST'".>%';?<^172+'?[NRMO+Q;<\\T9/'-?_>_@Q:W+LV0>"\nM4OE'C_S/#Y<#9`F$+4R6X6_92<_5UQ6JW_Z7FTV](1(A#OQXHXAW'S?+`;1"\nMA6U0FL!UV77I%61)MG]\\>NI@IL4?V8*C'R@9_B$\\.\\`R#V@$&N%J>+^!`P8^\nM.SC0?Z"GKW??^1O6+S,"P.0))FIV-&P2;-Q*_V^\\K6!W]WS$://Q6!/\\U_G+\nM/6%4!T"&+62K26#;[-RV@Q7]@V_4AH.18A,(WA.<'6"9!_8\\]`W2)*5OL)]R\nM=X61F7DF(L-`8Y95_27^[<7PLQ03=3R@LQS5;N(5BW1OOJB0/OJ3FTV:N9$6\nMG[YO/>%5)Y;8!:`4,FR#5,@H(IU?P%Y<Y,*>7J)F:^]TDA[,-.^U$$=_WS?\\\nM<W(.`&\\Y\\0-H`OD@TCN?P23FPG6[F,HU:_=>SL?^X^[G!I\\10B9JH1MUY-2S\nMY',U5))14(K>U6L*V=CXAT@S.S7BMN^L(YQ*6`HAC8[:Z"0C'#U)-#6%3'-L\nMJ;C0=<ERN7<Z5P<SPWMM(8Z^W35\\*_\\%`%@"+`.6C5G2O-5$AB')S,SSQXHE\nM0_(4%FNHT>.09MA;7D>]V$]87T0=?X**-&XV,7%3FF9((VZS!:'B5!*W2:8F\nM0&GZWO(V6IY/:WP"\\?!#;)%S9#K=.YVK@ZGFO9801Z^U#7>KY4%P=A&0S$R3\nMSM9H''GB^=?L4P,BS,P8(DMI[=K/[1.*=WWS>QPX-,Z_=VW@\\>[5]`Z/N([G\nMW:2-^63%-@$"8[0BFZMA"4%\\S>]QY\\0\\MS[X"/<$/1S>_7I:Q1+;7)=^R]JK\nMX6"BV*2%X#?MYTPX.X``(01""))JE61NCN;1(R\\"0"?^HQ9ZZ#SN6=`\\\\?0)\nMVJT6W=T]J%(W/[)[F76*K%R"2`V?L005(Z61"W.P\\Q+NKS68F)Q$2TU7I8=X\nM<(C#@\\-8P`[785"(O1H.QII-&,&^)1,<@&^M%QBHV/#K]RP2E"V\\3?5HA3U=\nM)6WE>/$BJX+VCG5>_8;I'<+R!$@#E@8!&TR>(8RAY98X-EEEZT7;N&#39@*_\nM0)YEM(Q@*I&<U]W%RI5#SOCTS`=LE5UJ\\MPQ,J=F%XCRG$LNO9Q2N4S8;&#;\nM%@N60\\M`OQ#LM&TRK?9.:O.9V'"#)42",1T`T_D90O`Y(1B1"'-\\KB4*"RT\\\nM`=T6>!7>:@QO?6$!+D"8I0/9F,>2/3Q][!BK5Z_&*7>Q,#^/';<I"0W&4"J5\nM&1Y<6<BJ,Y=B-$)KY&R5AO(Q!LJE$E[!9W%A%K?5Q#$&`Y2!UPJ!A5ES'%,(\nM$,EI#YPRP(`PYM39J0NGVQ?K.X/$HEBOLE8:QBT87C4"PJ+B.8RTJJPM>J>G\nM=)5*K!E8R6BSS@DRGCKV8\\8&ALF`(`]`@JQ763M7I6)9H#0&Z`(N%K#!@&T,\nMWSL%L*MH0(,H>-A^$=NQL2P+VSZE-K9M8YTZ=NRE/@NA#71UHXS!1[,_&2>.\nM!5,/?)]`P-IPEIU%3:_KHI7"`JHFYUXOY@=].6$?5`:[*'79N);@T.Q/F6\\N\nMT*Y6V3@<4FBXG-\\0"`0&<('!,^Z;`["Q0&?MWWTQO/E&D#GD:4=EUCE72ZIE\nMYSR+0::8-$&D&<C.VK;:M[BA)V>V/8]1BG*7A8N'EIH<N"]O\\'5=IVO[3F[<\nM]SM<=M&E5$I=)'E",VI2C^I,+4SQU,11'CKZ8[YX_'&VC\\6\\>=2F)P?U`N<_\nMMP\\HP"]"_W#'\\"2"I`UIW*EU<@%*0KL!8;T#X=BG$^B4&&,HVH+5)0^5:Z14\nM2*G)C>&K28U[NAS>=_UMW'#5==BV3:U1H]:JT4I:M+,V41:A',6JD1&NZMG'\nMTVO.X[^//,A8SR3O."P86>R8NAS`HF-4V(`XA)-/(HU&*XTQ&F,,.HTP<0L_\nMB[!MP7-;,6`,."[TK$3E"BD5>:Z0N2+/<NZ:?(+O]9?YW(<_SYYMES&],,U"\nMN$"8AT1YU&EE1*1"(A41JI"0D.Z^"I=L>QT_#6R^88]QW:/&[*S#PC(`<0J@\nM!5&+J5SP'7<=TM*$<4H4)T1I3G?Q-;S'.<:*9.[Y26P,NG>`^U;N9CY5Q''2\nMF1.G/-MXAH<"BSO_Y$XNV?(Z3E9/TDI;IXV.942L(A*3D)J8E)B,F%PD1*9%\nM1(O>_@K'-Q3XFI<4+YC$3SP://)B`%$;XC:M-*=9+"(LF]'J**/CDZ19SIH5\nM`ZBS/(`K`W.IQ.[N9[$]R3/C,TS/SW"H^2`WO?.#[-EV&2>K)VEG;4+9,3Y5\nM,;&**`4EM@]LY\\'1!Y`J(1,1T]$8HPNCS#;G:4<AVE>,KQ*;QGK--=9*_I%@\nM&8"$J`5Q"\\L8TB0EC&,FIV;02E,NE2D5BTNEY'(1"(S6U.L-QL8FJ3>:U/))\nMUJ]?R[577LO8W!B-N$&X%":IBDEU3%^ICRV5BRBY)6P/FNUYCC6.4`NK)&1X\nM@:`H"@A+(`1NBGR?'C/?9ICJ\\P%4W@%(V@ACTVJ'C$_-(*6F6"I3\\`/\\H(@X\nM"P!"D$O%V,PD"XL-G(++7&N&]UQZ(])(YEOSA"HDUA&I3LA,PDC/"!N#S>BF\nMH5T,:>@Y3D1/DMHMRET^!=\\A37,<Q\\:REK8B;;;E4NW!X^[E(12W8;&&Y?30\nMR$+B)*58+A/X00?`#Q#963P@!%DNF9U?Q/>+1+01!<VF\\S93:]1H9DU"'9*:\nM&$G.AH$-K)3#M&=#7,=%Y3E5^2Q.4=%3+".5(DMSXL3!LJRE5#,HI3V39WO[\nMKZO<O7P5:C5@[!AB]7:R3%(H!/C!DOH!01`@\\A>U'R$@EPJ#1:E<HA[.42Z5\nM<%R'>E2GK=I$.L38BJU#6RG,%YE:F*94*K&X6&=PN(^KAZ\\GEB$@,-J@M$8K\nM0UNUN>OP5YB0TV290GIJ\\_2!!?\\%(22A-@[S5<1:&]<K4+0<@J"('RQY(`B@\nM=;:W#0+;=@B*14JE,CI1%#R/.(N16M+6;2P7=@SN('HF8;)V`J_@,3L[2[/9\nMY.&'?X*%19YE9'E.GDNDE"@IN>;&JUG9LX):HX;G.62^/>"?[P3/]T":P,PX\nM:(5E6?A^F0)0+I?Q_0#'*^#[SEES0`!>P:=4[J+2W4,0EU!U13-N(AU)V[18\nMV[660C/@RW=]%==S$4(0QS'-9I-JM4JCT2#+,I12:*T10N"Y'E>\\Z3*\\HH/C\nM.KBNQ'%MX12<,U8AF\\X>8%M@";HLP][U*Q&6W;GKED6N-$)*'*,[\\2*6'LF$\nM`<M"8-B^>I#A@3[*Q3)&C/-X+68Q7,04#*$(.3QQ"+'"<.6^*SGPR0-,3$Z<\nMOB&[=NUBU\\Y=&&.62L=.O^>XK%PYA`@%CF-A60++6&TUH_,7)'$&M@]^B=Z)\nM(UR;-="%`.,7.VTAP'@%O*$1\\-:!7T38+I9EXP@;V_&YHKN`MERP70K9,-_X\nM:4:U7B/H]HE$B+0S?CAY'UO7;.73?_4I;K_U#HX>.XKK>MS\\\\0^Q8H]'*)MH\nM:4C3G"3)R5/),\\YC+,[-8ELVKNUBD4S$]V31F<_$"\\#G,::"DH;&'")I8?L!\nMG-*"WU&_"(4`"@40-D8+M`%M0"F#-J)37B_,%I)VXW=_=N)GJWI7]!#:;1*K\nM36J%')[_"6]8MX]/_O6MW/F)O^%GAP^C7<GC[H,TG5F4,H0JH65B&DE,JQ73\nMSA("ITB$Q&@>7?>90>T`B$<`F`/]V<X+S_@L27KNXF^VZ'G*%?-[TL+B4P]_\nMD!F@"X(NETIW0'=WB0=K_XD<2?BSO[R9+]_Q=8R!.):T\\Q1C($T5>6[0"I0T\nM.'AT>=U,YW-5DYL?)E/YF=78_Z_(.4/[<@6*AG'-;QG7%(UCL%P+UW5P'1O/\nM<UE451INC7>\\^5U<\\)I-/!H^0#VJDZ:2.,Z(XXPH2LE3S;KR)FKU>:KSM6_5\nM#X5?LX6E?V4``/0#,TS1RP`.>W`!!QS7PG%L;+NS[#;T(E/J!*5*D2,+AVDE\nM(6F2DR098922IX8=?9>A,L%CHX^=C!OIA\\MK_:GJWS5^=1X`8`;8B2'C<3RV\nMX;`!QX`EL&T+R[(ZBQF"MFSRQ,(APC0BRR1)DA-&";XILW_--;C:Y]XCWVTM\nM+C0^=M7M6[[_^!>G2)[,?L4`T"D7U](FX6%L+L)BG;%,9]\\1G=)`&X-6AEPJ\nMLCPG37-L[7'QBLNY;O,?4&W,\\J^/W-6LS=5NC9_-OW+R_CD]]T\\MX&5\\Y/NE\nMI!MX/9#P&LK<+LKB6K]2<"N5,N5B0#'P*/H^13]@H#S`AOZ-;%OQ6HI.%_<?\nMNY?[CWY_M-EH?2*?,=^T2LC:%YJG__J5`3@E;P$2*E2XGA+O]\\O^UH&>7G>H\nM=P6#W0/T%GNH!-U(+9EJ3')B[OC<8KO^79V8OVW?*P_YNRRS>-?SW[6_L@``\nM5P`_`JYFB#*OQ^=*MV!O\\GRWQW5MA"`WRDP8HQ\\14MQO&N*P<$56__*+?R1X\nMY0'.E(N!)H(+*%JK1,'Q+$2,SI_1H?]:)X^^F<,O^'[\\?Y'4R4P<J(4L````\n)`$E%3D2N0F""\n`\nend\n
105983
 
6592    industry_clock_48               begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```/?4E$051H@>V9:9!<5W7'?_>M_5YW3\\^^:4:2-=I&DB4A\nM@>5-++8`@TUA[(I9#(1`B"&A0HH`J6"2D,60%%1224@%HDH^0)8R10K'E"%>\nM,#8X>),E6=8VDBQI-)I][]?]]GMO/LR,;5F6,5;B3_Y7G7[KO75^[YQSWWVW\nMX76]KM?UNE[714B\\VH;Q=A`"0RG6*<UI("KN>V5M=W<"T`G80HBA7&H^-?'J\nM_#!>7;,%.19:(WY'(SX;2>S9K:^TI0!$OT+\\0RQUGQ+PS997Y\\-%`5!"`T6E\nM^8K0?"'6PIW8_,J#JF&7TGP[DJS*#/BKQE_=A8L#&`8,`W/+%2[-;5_6F?Y\\\nM7>.>V?3+(52F*7=VZY:U_=<JS;=CR2I,^+-?$>+B`")`2>P=U^#]^N<\\T=1\\\nMN\\CUYR.->V+#RT,H"85*$V_\\T,?I7+]QEUR(1!\\"_JCT6@$8@`:=)3@[WD;I\nMUL]XHK'Y=I'K+\\::PN'^EX?0>897++']QEOH[%NS2VF^%2E6:0N^^`HA+@[`\nM7-PF,;I>Q=VR@X:;/^Z)2N/M6NK;(X6W;]T%(`1H*<EK`9[GL>WM[Z9]Q<KG\nM:D(;\\'NO`,)Z\\8G;O_'/)&EFMU0:;O%=>\\7@R>/JF0/[C.$SIW_F%4N///7H\nM3\\\\'2&.H!^@TI;!A*XWO^:`[_E___@4]-R]B(>YX?(V(=AS7YP,HB:S70"H\\\nMVV;;Y5>3QNFNH=&1W:D2OVT*!CY=U/QC_<(`YT5`(5`(6\\%M&N[0\\+6VUI8[\nM&IN;KEW=M^H\\)P!T%J/#ZH+5JWAK-M+RSIM<L]+X>:WTER*%]_/5YT="RP6`\nMO!Z0!U4\\TV3KI5MH;VF[1FEVAY)U(/B$=V&`\\R)PY6/_2A(G-+>U4*HTT#TV\nMS=E0TSH_R;*6(G>^%'Z:H,.%"*@T0]:J.+Y/9?TF-]G[Q!=TDMJA$G]^_RKJ\nM;S^YR"X`*<GK-<@E>1B23,]@SL[2W]A$6`UVCL;)[E3Q20,Q\\-&"YCOQ*P"X\nMX>2#4`6R-G)G-6UQ1/_*;8QDBN4[K^(/_O,'S]_\\@A3288":GR,?.4TV-8&,\nM4UPI:>KI==,S0Y\\C2<U$BZ_<LY+Z2,QB"BE46$/%*?7!4X0C(^1)AIE+^FV;\nM-,MWCF9R=ZKYI"G$P"VVYGO9+P'`$&!H,$STHF5!E;Q>)QX;._=>L>A(EL#L\nM!'+P."0IYH8W,>>W4)^;11X_1$.N[?3LV<\\F24JNQ5=,05VR5,0UXI&S(!7-\nM-]Q$X!0(ALXBGGR,#?D4J4IVCF9R=Z+XI"'$P/M,S0_D^4EP80F(QT9))B>8\nM/W+HW&OFT@TA>NP,(DT(MNWB+\\]*/O9O/^:._4-\\O]S'P4H/35W=MN4XGU5:\nM_VF#J3T$6BM).C6!(031>S_`-\\Y.\\\\>_>(J[O48.['@S@5_D4MNFQ3!V*M@=\nM2]8I(7B7^;P+%P80((1`"$$\\/DX\\-45UX,A+`+"0_V&`ZES!W3.*0R=.4@L"\nM*I5&9+'"(V83DY9/QR)$HOFJ(6C0>:[SF2G8>AD/3,QS=G@8E2O*#8U$;9T<\nM:.O"`+;8%FU"[%2P.U*L0PNN773!`OC>*H&&!A/><?<L7LG`63<7MINCXR1!\nMAA/-LLRK;5GIS-TZND48CH!<@Z%`0)_.4H36!':18\\/C;-QT*6O7K<<KN&1I\nM2J`%(W'.BDJ9CHY.:VAT[-.F3"_766;I/&/"=`FSC,LNOXIBJ42].H]I&LP8\nM%H&&%B'8:IJD2NX<5OJKD>960X@8K1<`],)/)X*_%8+N'*&/3P7"G0EP!%0,\nM<!JX46MN?/$$7(#0BSOY_#1&WLB)8\\?HZ>G!*I69F9[&C&H4A0*M*19+=+5U\nMN.GXV.5:2G26D8Z/,",+:`VK5JW"LFUF9Z:P@WDLK=%`"7B#$!CHWN-HUT/$\nMST5@R0$-0NNEHZ4+SVU?ZMP+2`S\\N7&6YYHA`[J6=8,P:'`LNH-QEOL.&@%H\nM2EZ!91U=3#M%6+\\5?^5ZKFQ;1IQF='9V4:W.XQQ):0OKE`2@-!I!&=@NH$^#\nMJ34_7@+8YFM0(%P'L^!C6B:&86":2V9BFB;&TKYE+IXS$$I#N8+4F@**7?$0\nM4208^=F]>`*6UR?9ZBN:;!N5YR`,U)K-^)==B[6JG]PKH^.$SCA&YA*E-2UM\nM11H;FLD[>A"//HQZ[!&8F44#-M#V@N=F`:QQ61C[=VR'ZS\\">099LF!YNG`L\nM%TWE"\\=I!'F"3F)$DD*^,+;U%`QN;<R8K$VCI:14-K!QD)E$%QO(KGX/V8Y=\nMS&::(X>/<NSXLXQ.5XDR"0A,H6DHV'2U-=.[HI?*31^&C=L0=]T)1P_#8DJ=\nM`P"`!`H^M'0M.!Z'$-<@B1;F.ID`F4-M'NIS"Q"6^5P!+4EKC6\\*>HH.,E/D\nMN23/<E1#,_'U'R-<NXVGGS[(3QYY@F=K!J*UEZ;EZRB5?/(L0P)C]1J#D\\,\\\nM??)Q5K4WL+Y_/86/W(9UYW<P]SUY3N8^#V"PX%1]'J(ZG#I,KA5**K16:*U1\nM28B.`@IIB&D*GG\\5`UJ#94-C!S*3Y+DDRQ:<S[5!M/-]!*NW\\L"]/^&^O2?(\nM>S?SSG=OXYI-O03C0U2K\\V3:(`AJ5"[9SJFI@('3PQP_M(>I_WF<+9LW4'[O\nM+;@(O+U/(!T7TN0%`&()((`P8"03W&.O)#<4]2@AC&+")*/B7\\(GK&.TQU/G\nM%K'6J*96[N_8P70BB:*8,(J)XH0MV[;3M7H=#S[P$/?L/47+&]_.;==M8WUG\nMF;DH9SR3S,X'"-L!TZ!@&ZQI+]/>T,>Q]E9.[7V<O?L/LGGC.MP;;NXX>_F;\nM>QS+GN?OOO:"%]D20%B#J$:09%1MG\\BK,%B-V'/R+/M.G>79R3GDBT>@I2S4\nM,)7D&)5F9J7FX)D1)F))9=D*#APXR+U[!BAOV<DGWK:!MJ+%J:DZDT%,CH'A\nM.,@LPRE6J*<Y09JCM**WP63=Y5>ANM=P=.`XD6$NSQN;/O/HP&'K`Q_]U(LC\nMD$,80!1@:$T2)]2CB.&1,914E(HEBKZ_.)4\\7P*!5HJYN7G.G!DF".J\\Y2UO\nM(T\\S'GSD"<*N#=RZ<S,%4W/BU!D:V[N0&HHM'12:VYD.4\\:J,=%4#81`UN=0\nMP0RCIY^E=74_$[,33$Y,TE!IN'EEW]I_L6WGR7,C(+-%@!I"*X):G<&A$?)<\nMX1=+^,42!<]'7```(<ARR9FA8:9FYNCH[*2GMY?#1X[R;`";+MW$\\F8?:7D(\nMVV5V9@8)2*49J<:<G*X3YA++-G$=$QD&'/[Y?Q/,3='<T4['YNW,S`7D6=XF\nMA/GNY2OZ7J(&HAK,3F!8C<RG=:(XP2^5\\`H>;L&C4/`0Z04B(`1IEC,Y/8OK\nM%NCN7H9AF`P</XELZF%#;RNIE$@,CAU^AJ<>N)OK;OU-W*X^)NHIKF/B.C:&\nMR@E.'F3VZ-/T7_%6.OJW(I7`6K&2X,A>TC1%*77EPS^]SS]_%`KFX<PQ1,]F\nMTC3'=3T*WJ(5/#S/0V0OZ3]"0)9+-`;%DD]S<S-1&#(^4Z78NYY&WR)*<[0P\nMN&33-J8G1GGLAW?2L&8KC1O>1+%<(IT;9WC/P_A%GTNONXE22SMYGI.D.5:E\nM@5)K.[(ZB51JA>.ZK>=&0.8P,033XXCE)K;CXAL6GN=3\\!8CX'D07&BU06":\nM%I[O4_1]"H4"]3`DS"3%HL_DJ0%FA*)C53^FZW'Y];_&P,%]//3][Y#<=Q?M\nM7=UDN>0-U[R#_BO>BNNZ**T)@Y")XP=H6+Z&<G,S66T:K72Y4"B6GZ\\!`TAB\nM&!L")3$,@X)?HM10H=+41*6QB5)#A8)_X1H0@.,6*);*-%0:L6R'-$W1&@S#\nM(*S7F!X^393$I%*1245SWZ6\\^3<^1Q0G//;CN]BVZSIVO/,&FBI%2IY%V;-I\nMK)1Q3(V9QW@%%]NVD%**/)?B^0B8++P#3`,,0=G0[%S5@3#,A:=N&&12(?(<\nM2ZN%?!&+GV1"@V$@T&SN::.KM1G/\\U"NPU0MP38@DSEFN9FB;:%,ATPIXDP3\nM9I+6KFX^^(=W8/STNZS=N!;/,7%,,`T#I2$/`PJN0ZE49$8K7,<AS=)H;FXF\nM>E$1IV`6H%"DZ>P1WI?.HUP/7?`7MJZ'=ER<SFYP5D+!1Y@VAF%B"1/3*G!U\nMQ449-LHP>3863(>"DFLR%LR1^)?0V-I-+96D<4ZJP7<M+`.Z^];0(MZ%/WX4\nM:]U&/&MA(JF4PFQMIK#C2NIQ#DF$;=LD<3H11^',"[^)9X"_1^L&9*Z9GT+$\nM`6;!@R5S"PM6\\,'UP'5!F&@E4!J4!BDU2@O0Z-1I;]>M_1]J:ZKXPU,C'!E?\nM3<5W\\%P+S[$I>1:&(3`-@8E&KMR,\\_2/<)(`O]2*8QMDN4(#0AA4IT>Q94:J\nM%6$8/O/HP_?,60#B*0"F0'UM8<$SND"1OG)]^<^^CJ[KIO9RLJ&KJ^/*@>%#\nM)-598J<-RY38T2S":4,(9^'3%1#E)E1+-];P`&9'!UE8`\\NA8!G(3#(].$BC\nM7^#(X.DTC,+[KKW^5GUQ2XLOHR.'#[*V_]+9>KW^'[Y?5+U-1=2I9T`I5'T.\nM`X4V;;1>F`>F<4045$F7K2<]OI^T7J=:CY@='<41@LF1,>3,%)8I&!H>V1.&\nM]8=JP=P+IY/_QP`'GV;]QLV$87C*M*S+2J72ROGA03(%Q:[E>)4F+-/$,@66\nM`>.'GH(\\I;R\\#T[L0Q@FK2O74O8\\SHY-,[C_&;H;2_SBL2?K@X-#MU<J34_.\nM3(U=Y.+N+]'@X"G\\8GFR%@1_(@1#JU?V4A@]2OW$,\\@DQ;4,7,M$2$D>A50G\nMQ[&5HGGSE337)B&3G#@SSNG]!UG5T<3!0T?4X2,#NX/JW%VS,Y,<?OH7_W\\1\nM`#BX?P^7]*WEFW_]%X,__-']9TS+NKKH%<K9U`C1S"18+I[OTUCVJ324:&MN\nMHJ>C'5EJ85A4.#;P+/6A(;HJ'D_LV2L??.B1[\\[/S]U>\\+S:_L?O!R[B3[Y?\nM1>__R&]QYW?_B=M^]TOO,BW[ZUJIC4F2(H6!4VG!;VFE6*E0<!UL0V#D*:[*\nM*=L&:1+QY)Y]]8.'CGXK".;OL&UW]L"3#SS7]VL"`'##S1_FLLMV<?SX_G6F\nM:?T^B)N`%M,T<1P;UW5Q70?'<;!,@S1)&1T;STZ?&=H[/3WS-W%8N\\MRG.30\nM4P^=T^]K!K"D&]__<9(D=GR__`80[]%:7Z$URX6@I+1&YGF6).ED&(8'PC"Z\nM-TFBGS2U=$R.C9SFQ*''S^OO-0=8TJ;M5U$+9D5OS^JB[13:;+=0RO.<*`RS\nF6JTZ'51G9QRW(`<.//JR_?PO*PJ.!!4*F7<`````245.1*Y"8()0\n`\nend\n
105984
 
6593    industry_close_48               begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```/&$E$051H@>V9>91<59W'/_>M]:JJNZIZ23KI#MD@(20D\nM,=&$`7L<!660.`(*SAC%R#;@H"!#<!3D.#,'1Y3#812%&#?(#.>001&0X\\DH\nM4=##%A,P,<1LG?2^5G=MK^JM]\\X?U<V2T((P\\A??<V[=M]UW?I_?[W>W5_"V\nMWM;;>EMOZTU(O-&&WFH0`DU*%DO%4:"6>N[UM=W<!D`;8`HA>J-8<>7(&[-#\nM>V/-ZK(,E$+\\DT)<4XLQ)U:^WI8"$$LDXMM>K!9*`7<VOS$;WA0`:120DHJO\nM",5&3PE[9/GK#ZJ"LZ1B4RUF0:C!K=D_WX0W!]`/:!KZBK^R:6J]287J>E=A\nM]RQ[;0@9*AK:9JOF14O.E(I-7LP"=/BW/Q/BS0'4`!ECKGT?SJ>N<T2NZ481\nMJ>MK"OO0*7\\:0L:0R.1XY\\<OH>WDI6?%]4@L1,"7TV\\5@`8H4*&/M?:]I-=?\nM[8ALTXTB4C=XBL0+2_XTA(I"G%2:U>==1-O"D\\Z2BKMKD@7*@!M>)\\2;`]`G\nM:]]#N27L%6MI_,@ECLAD;U2QNK$F<9Y;/`V$`!7'1)4RCN.PZOT?9,;<>2_V\nM":7!M:\\#PCCVPHVW?1\\_",WF3.-%2=N<V]UU4.[9_9S6WW/T"2>5_NW.IWYU\nM/$#@@5M&!0&)4U:2_=`_V,,/W;=1%8K"$^*69TX2M;4'U?$`,B9V*Q!+'--D\nMU6GO)O""LWH'!S8'4GQ&%^R_*J6XRYT>X+@(2`0284KX1P6W*/B/UI;F6[)-\nMN3-/7+C@.",`5.BAJJ5Z<4LX)RVE^>P+;#V3O5Y)]:6:Q/G-B<='0L5U@,@M\nM$Y5+.+K.RE-7,*.Y]7U2L;D:LQ@$ESK3`QP7@=.?_B]\\SZ>IM9ETII'90WGZ\nMJHJ6XBCMS2GN?S7\\P$=5ZQ&004A<*6$EDV1.7F;[NY[=J/S`K$KQ[[]8@/O^\nMKDEV`<0QD5N!*":J5O'SX^@3$RS)YJB6RIV#GK\\YD%RN(?9?G%#<Z[T.@'5=\nMVZ$$A*U$UHFT>C66S%O%0"@YH?,,OO#C!U]Z^&4II*IE9+%`-'"4<&R$V`NP\nMXYA<QQP[Z.F]#C_0?26^\\N@\\W`&/R122R&H%Z06XW4>H#@P0^2%Z%+/$-`G"\nMJ',PC#<'BLMU(?9?9"JVAJ\\!@"9`4Z#IJ,D2EDM$KHLW-/3*9\\6D(:$/$R/$\nMW0?!#]!/>1>%9#-N88+XX%X:(V4&?7W7^'Y`I,17=($;,]6)*W@#?1!+FM9=\nM0-E*4.[M0^QXFE.B,0+I=PZ&\\69?<KDFQ/[S=<6#\\?%),+T$>$.#^*,C%/?M\nM?>4]?>J!*FJH!Q'XE%>=Q=?Z8C;\\]\\^YY?E>'FA8R!\\R'>1FS38-R[I&*O6O\nMC;IR$"@E8X*Q$30AJ'WX[[FM+\\_-3^[D82?+[K5_33F9XE33I%G3.B5L]F(6\nM2R$X1W_)A.D!!`@A$$+@#0_CC8U1VK_O50"HYW^UC&R;R\\/CDKV'NJB4RV0R\nM6>)4AM_J.4:-)#,G(7S%5S5!HXHB%8V/P<HU_'*D2%]_/S*2-#1FJ;6VL;MU\nM%AJPPC1H%:)3PN::9#%*<.:D"0;`U@4"!8TZ?.#A"9RTAK6X4)VA#P[CET.L\nMV@3M3F7%/*NP?G"%T"P!D0)-@H"%*@P02E$V4QSH'V;ILE-9M/ADG(1-&`24\nME6#`BYB;:6#FS#:C=W#H*CT.3E-A:*@H9$2WJ88A:TX[@U0ZC5LJHNL:XYI!\nM64&S$*S4=0(9=_9+]=6:8KTFA(=2=0!5_VE#\\)]",#M"J(-C96&/E[$$9#2P\nM&CE/*<X[=@$N0*C)@ZB81XNR'#IP@(Z.#HQT`^/Y/'JM0DI(4(I4*LVLUIEV\nM,#QTFE(2(27AV#`3<0*E8$$ZA9E(,)$?Q2R7,)1"`6G@'4*@H>8<1-D.PGLQ\nM`E,&*!!*39U-W7BQ?K5K+R/12!:&.2%2]&HPJWTV"(U&RV!V>9@3DM:+31I2\nM*=I;9]"7+S!8]NA_\\BG,;!N!5%B6B31,K-$1YN:'2>L:1!(%-`"K!2Q4H"O%\nMSZ<`5B452!"VA9Y(HALZFJ:AZU-%1]=UM*EC0Y^\\IB&D@H8,L5(DD)SE]5*K\nM"0:>V(8CX`1WE)5)2<XTD7&,`,9<CSV#%8Z68O2<33K;PD++1BF%M_-WE/+C\nM5/*C)$,/US9)3_I/`2;0^C*_&0`GV=3'_K6KX=Q/0A1"Z-=+%-3/X\\DBH_IY\nM4(/(1_D>P@\\@JH]M'0F-]=F0T4H>%<>D&S1,+&0D\\6/%SNXQ=N=]VD_OY(*/\nM?I2YRY=CV#:^ZU(KE7`G)ICH[:5_[UX./_,,NP\\=I"V.:->U%[-7'0L`0`PD\nMDM`\\JVZX5P6O`GZMOM8)!<015(K@%NH0AOYB!YJ24HJD+NA(6<2A)(IBXEA2\nM#6-^N6^`T<997'CG32P_^VR"6HW2\\##%P4'\\<IFP4B&J5G&$8.["A;0V-]._\nM=R]=3SW%D<($'9J&/BV`1MTHMP@U%XZ\\0*0D,I8H)5%*(?TJJE8F$531=<%+\nM4S&@%!@F9&<2AS%1%!-.UEZEQO;G?T^Y8S%7?N<[I)N;^=V/?TS+W+D(*8E<\nM%^6ZB,FB5:L$/3T4]^^G;>Y<4FO6<'3'#D;'\\[0@E`G(XP#$%$`9JF4&0L&C\nMYCPB3>+6?*HUCZH?DDG.YU+C`#.\\L5=V8J60N19^,7,M>3^F5O/J;6H^P8'?\nM8:;;N.+..TDT-+!]TR9D$%`Z?)@Y2Y<BH@@J%83KHE>K>+V]6+[/S#ES&-VQ\nM`Z>UA=FY'".%`L4X-A+U$7P:@&H%:A7*?D@IF41H.MW#W73W]N,'(7-FM!!/\nMLP&/%8SY$7JFF8E*/X?ZABAV=3'CA=U<\\<T[ZL;??3>SER^G_?33\\?;L86#;\nM-EKFST?(&.&Z!'T]F`I:K[H*9]8L,M^^D_V;OPN>3T8J:K!P'-:D8=M4XKP,\nM(()J/0*:4OB>3SZ?IW]@"!E+TJDTJ61R<BEYO`0")26%0I&>GGX*$T6<WB.L\nM>D\\G\\U>O9ML==S!CT2*>&1[FWBU;$(L6L>`#'Z#\\^^>1^3&"GB.80M)RZ64<\nMJE38LG4KW@?/Y<0/K\\-6DI2F:!!D,G#%84A<=QQ`'-8!:A6$DI0K+MV]`T21\nM))E*DTRE23A)Q#0`"$$8Q?3T]I.?*.'(F(9*F>7G_"WNQ`0)QZ$T-(1CVVR]\nM_WY^^,,?XB]>S+P+/TIUWVY,(<E^^@H.NU4>?>01=N[:A5XI$?0=)6E!P@!'\nMAP:-SH6PI/U54ZA6@8D1-"-+,7"I>3[)=!HGX6`G'!()!Q%,$P$A",*(T7S=\nM6*N0ISF7)=,VB\\K8&`M6K^;P8X\\Q3PBNNO)*;K_C#J(XYO+++F/1QB]2T@T.\nM5*K\\]"<_H7]PD"]>\\BGBNV_'?WX'C@5Z7%\\L$].:@C4-@N=>BL#4*%0N0L\\!\nM1.`1!!&V[9!,IG!2*9*I%([C3)=!"`%A%*/02*4;,*LNF99FXC"D5B@052K,\nM7[*$^/GG65HJ\\L_77LM##SW$EBU;>$$8[!H:X6<//TS_X"`W7KH!YP=W8.YZ\nMDI1=]W["`-L`6P=3Y^1/)H^-0!S!2"_DAQ$GZ)B635(S<)PD"6<R`HX#Y>F^\nM-@ATW<!))DDF4P1AB-F8H%8N$U<J:*Z+[KJTS9]'_C>/L[+SW7S^LU?SS6]_\nM!UW7:6UMI5`L<O,E%]/PH]M1SSV%E8!PTO.BOMPA5I!2M%Y11KPR`KX'0[T@\nM8S1-(Y%,DV[,D,GER&1SI!LS))+3]P$!6':"5+J!QFP6.V$3AP%>L4A0+!*6\nM2L2E$M)U2=LFQH%]G-G92<><.=QSSSV,CX]S[>>OX^1&AW3/?E(6."_SO%7W\nM/*8&EHZ^3"!>BH!.?0[0-=`$#9JB<\\%,A*;7O:YIA+%$1!&&DG5WB,DMF5"@\nM:0@4RSM:F=721#*5XH][6BD>V$^U4$"O5C&K5337Q>_K)I5MI.6*JSD\\EN>4\nM)4OH.GR8!Q_\\*99MT_JQC]%VTS>HW+H1?WR\\[GD%L59?$!@:1#'%SWT">4PG\nM#D!/0")%KF\\?YP=%I.V@$LEZ;3LHR\\9JFPW6/$@D$;J)IND80D<W$KP[8R,U\nM$V5:)$]LY]%GGZ$Z/HX=15!Q\\8]VT=B4I>DSG^-0M<9O'G^<@<%![MUT%WL/\nM'&3SC^Y!QC'KUZ^G_5^^0?G6C<C1<2*]WHD-TT!'H<7QT9V/O')//`Y\\"Z4:\nMB2-%<0SAE=$3#DP5.U$OB238#M@V"!TE!5*!5!#'"JD$0C.4.+(OYXZ/K^_>\nMM:LQ:QC8$Q.T=70P\\[/7TE6M\\>OMV]FW?S]?^-1ZVA_8Q-Q%R^#3&[AK\\_<(\nMHX@-&S8P^X9O$'SM!L1H'DT3&,E&*)1K(?%SO?)-_#_P6CI7$\\20S"H><(0X\nM)R<E[=DLYVW=2K=E\\<#6K1SJZN*FRRYAY@/?)WQB&U8Z@7/Y=3QLS>#V;]W)\nMNG7KN.[SUY+^WJV,_.`N@DP30:*1T2/=._L"=8ZN,:J_MBEO3&4%*Q&A#])0\nMZMP$&);O8PE!XXH5//'LLUSSL0O)W?\\#2K_:AF&"I2+XPPZ6K5A.]K2_872B\nMP!E)#>^^381!@'G**BH]/;)<J=U^?@./_4_U%<O)_U]5@#E"4(6C"3C9AJ4)\nMH+IG#PU1R/GKU^-__RXF'OM?#&-RF-1`CR/BW3M8>NJIO&?U*OS;OD0X-H9S\nMYCK<H2$F#A]^?"3FYH,1[O65OV`*`;0#[P4\\6-(,]S7#RF:@T=!I:&K$JA1(\nM&`K'K$].4T.E(4`9)DK7L6;,(OUW'Z>T[P4&?OZS(V.U\\!.S3)Z\\N0#;X[]@\nM!`#*U#?C[X2Q<?B]!6LLF&DIA?`\\A)A<&DSN4)2$6-8G*BV3([/N(K(7?X;Q\nMIY]DX-&?'BEXX=47S&#[?47XGE]O\\Q>-P)0^")P.],**%OAZ3H@S<[:E)QV+\nMA*61,#5LV\\1.)DBVS:1AV0H:WK&&.)8,;;U7C3WS]-.E2-[PD09^>UL1-E9>\nM>O=;`@!P-O`N8!Q:6N'362$V9!Q[44,N8Z1GM)!LRI'(9;#2:62M2JV[*W:/\nM'#Y2K7CWE36^.U^C_Q$?OG[,!]ZW#&!*%P)_!/$AF-T$?YT4G&'KG&@:(F5J\nMH*%J2([$BJ=J&K_>+>AI4<@OUU[]?6\\YP,MU,>"!:(9$B\\`T-"A!-""I&:"V\n;'/OMZ57T?YC*+/`N5^DI`````$E%3D2N0F""\n`\nend\n
105985
 
6594    industry_next_48                begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```.PTE$051H@>V9>]!=577`?_L\\[CGGWOO=^SV3+R$ODT`>\nM!!)"(20QVD)H:T4KMH,"HM9'U59'JV+'4BW50=N.[=3:AS8M8]'6QX".=!BJ\nM,MHQHB`JR#LD$/*]W]^]W[WG??9>_>-^"8&/:(3*7ZR9=<]S[5F_O?;:>^US\nMX45Y45Z4%^5%>1ZBGJMA<CXHA64,FXSP)!!7[CT]VP.#``P"KE)JN-#".Z>>\nMFQ_6<S/K2,E!!/7'@GIOK''G=YRNI0+4%H/ZIT3+!J/@'_N>FP_/"X`J`E2,\nM<+T2KDU$>5/GGGY0!?8;X7.Q9GUNP5]W__(N/#^`4<"RL+?O]N@=^'/)Y8.A\nMX`UM^\\40)A>Z!E=*WUE;+C'"YQ+->FSXV"\\)\\?P`8L!HW%T7$[SI_8'JZ;U.\nM%?+!6/".;/WY$$:#7^_AUZYZ"X.;S]ZO.Y'8@(*/5%\\H``L0D#REM.LWJ%[]\nM[D!U]UZG"OE0(O@/;_GY$%+D!)4JY[_F"@8WG+G?")^-#>O%@0^=)L3S`[`7\nMCVF"A`MXVW=1^[VW!*K>?9UHN2XV!/=N.@6$`M&:HMTB"`)V7OH[+%N[[D1.\nMB`7O.PT(YYDWKOO4OY-FN=M7KUU1]MRUQYXX;!ZX_UYK=.C)[P65ZO=_\\L/O\nM+@7($@A;2);A;]U!]ZNN]":_\\5_72J.I$J5NN/M,%>\\Z+$L!C$:';="&P'79\nM>=%+R9)L__#XV(',J#^R%8?>51'^)3PUP)((&!0&Y1IXA\\`-`I\\<Z.^[H;NW\nMYY*-&]8O<0)`\\@2)%CH:+A"<>39]O_5:SZYW?U",_%EL"`YN7!H)T1V`(FQ1\nMM!8(;)L=YVQG6=_`Q48X$&DV@>*MP:D!ED1@SUU?)$U2>@?ZJ-9KK)R89202\nM^IO3G-%7X2O/AI^E2-2)@,ER='N!4KE,??,V+_WICZZ5-',CHS[^[?6$ESZQ\nMR*X`K2G"-A2:(HI(9^>PY^?9TMU#M-#:-YZD!S+#VRW4H3?ZPDW):0!<]L1W\nM8`'(!RA*&QE(8K:LV\\E8;EBS;R]_>LO7GWKYI"$D40O3;%",/4D^,X5.,CRM\nMZ5FUVLN&AM]/FMFIJ.MO6T<XEK`XA`PF:F.2C/#84:*Q,8HTQRXT6UR7+"_V\nMC>?Z0":\\W5;JT!6N\\-7\\%P!@*;`$+!M9U+RU0!&&)!,33W]7+3J2IS`_A3YV\nM&-(,>^L%-,I]A(UY].&'J!7B9B,C[TW3C$+4];8BU!Q/XC;)V`AH0^]EKZ55\nM\\FD-CZ#NN8NMQ0R92?>-Y_I`:GB[I=2ARVWAZWKI(#BU*$@FQDFGIV@^\\M#3\nMG]G'7XB0B2%4EM+:N9^_&M&\\^3]OYX;[AKFY:P,/UE?1LV*EZY1*[S4B?UFS\nM)4`A8C39S!264L2_^WH^-3++1W_P$VX-NKE_U\\MHE2N<X[KT6=8^`P<2S2:C\nM%*^PGW+AU``*E%(HI4@F)TEF9E@X],BS`-`9_U$+,[B66^<,#QUY@G:K1;W>\nMC:[4^;[=P[139ODB1"I\\PE+4I"BDF)N!'1=RQU23D=%13&'HJG43#PQR_\\`*\nM+&"[ZS"@U#X#!V+#)D1QR:(+#L!7URL$:C;\\YJWS!%6+TJ9&M,P>GR1MY93B\nM><X(VMO7E1I7CV]75DE!(6`94+!!\\@PE0LNM\\-CH)&=O.X>S-FTF\\#WR+*,E\nMBK&D8&V]B^7+!YWA\\8EWV3J[2/+<D2)GRO:(\\IP++]I+I5HE7&ABVQ9SED-+\nMH$\\I=M@VF='[1HU\\(A:NMI1*$.D`2.=G$,6GE6)E@9+#,RWES;4H*:A;4*KQ\nM&A%>\\\\P"7(&2Q9.B.8M5='/DL<=8M6H53K6+N=E9[+A-11D0H5*ILF)@N9=-\nM3ER$&"QCT-.3-+6/"'15*GB>S]S<-&YK`4<$`:K`>4IA(:L/(UZ`2DY$X+@#\nM`DKD^-7Q!R>.SW;O)!*+<F.2-84P;,&*,U:"LJB5'%:V)EE3+ITPZ:I46-V_\nMG*,+#1XEY9''[N*)ON5D(MBQA578F,84JV<GJ5D6:(,`7<#Y"C8(V"+<?AQ@\nM9UG`@/)*V'X9V[&Q+`O;/JXVMFUC'3]W[,5[%LH(=-71(O@8]B?#Q+%B['O?\nM)%"P)IQF1]G0X[H8K;&`,<FYK13RW;Z,N*=,?:!&M<O%5XH'Y^YG=F&6]M04\nM&U9$.`V734V%0B&`"PR<U&\\.P)D>G;E_U_GPRFN@R"%/.UIDG6N]J*;H7&<Q\nM%"F2)J@T@Z(SMZWR+:[NSIENSR):4^VR<"EA"D,.?#-O<J-IT'WN=MYRR17L\nMWG81M4H729:P$"_0B!J,S8WQZ/`A[CIT-_]ZY$'.'8JY[)A-3P[Z&<%_:AW0\nM@%^&OA4=QY,(DC:D<:?6R17H`MI-"!L=",<^D4#'140HVXI5E1(Z-Q2%IB@,\nMN0@W)E/<VN7PAU==S]677HEMVTPUIYAJ3=%*6K2S-E$6H1W-&6>LY-*>2SBR\nM9BUW/OP#1NJCO.$!Q<KYCJM+`2PZ3H5-B$,X^C"%&(PVB!A$!)-&2-S"SR)L\nM6_'44@R(@.-"]W)TKBD*39YKBER3I3DWC3W$[7U5/OV!S[#GG-V,SXTS%\\X1\nM9B%1'A'F(5$1$NF(4$>$14@H(;7>&A>><P$_+MM\\P1GBJI^*[&C`W!(`=1R@\nM!5&+L5QQF[N.PC*$<4H4)T1I3KW\\$M[J/,:R9.;I22R"Z>GGV\\MW,9MJXCCI\nMV,0I1XLCW!4H_O8]G^+"K1=P=.(HK;1%6'2<CXJ(1$>DDI"8D(R87,7D*B&2\nM%B$M>GIK'-[@<6,IJ:P?)TA+-+GGV0"B-L1M6FG.0KF,LFR.31[CV/`H:9:S\nM>ED_^A0;<"TPDQ;8]3[FVZ,\\/CS!V.P$]RW<R?O>]&[VG+.;HY-':6?M3H_K\nMCN.)2=`JY[PU.WE\\[C"'IA\\F)60\\'N+8[#%F%F9IQ1'&TXR<H38-=\\MKU6K^\nM&6\\)0`%1"^(6E@AIDA+&,:-C$QAMJ%:J5,KEQ5)RJ2@48@R-1I.AH5$:S1;3\nM^2@;UJ_E\\I=?SM#T$,VDV>EY'9*:A&Q1Q1+Z2GWT]?23F#9?>^1+3+0G2%6.\nM&R@JEH=E*92%DU*\\31Z7KS'(Q-,!=-X!2-HHL6FU0X;')B@*0[E2Q?,#_*",\nM.@4`2I$7FJ&)4>;FFSB>PTQKG+=>]$8**9AMSQ+J3L^G$I-+2B$9.2G*@BB)\nM<!9*[.K:Q\\SZ<;[UY'^3I"E95A#'.9:UN!09V987>B\\E;EDZA.(VS$]A.=TT\nMLY`X22E7JP1^T`'P`U1VB@@H19873,_.X_ME(MHH3]BT=C-3S2D6L@5"'9*2\nM4)!2D%%8&5KE.+;"2$&:"59A<;'_:OK/'N#6HU^FV5[`LJS%5!.T-JX4V;Z!\nMJ^JW+)V%6DT8>@RUZERRK,#S`OQ@4?V`(`A0^;/ZCU*0%QK!HE*MT`AGJ58J\nM.*Y#(VH0F8B-*S92PJ60`D$C2D!I+-N"T.+HDT?I[>TE2S->XF_CFK/>P<U/\nMWL3$_"3&"%H;LEQ3I.:LT8_-^L\\80@5,#</L)&J-C5OR*%L.05#&#Q8C$`30\nM.M77!H5M.P3E,I5*%9-HO%*).(O)=8YV-'9D\\Q^?O8DLRW!=]X262B4$H;>W\nMEV:S21`$:*T)YKJX>O,[N=GZ/(\\71\\ES!R]UR+VB3V]P_:='($U@8AB,QK(L\nM?+^*!U2K57P_P"EY^+YSRAQ00,GSJ52[J-6[*<=E=$.S$"^0.SE2$EKM%@</\nM'F1F=@8162Q9;!S'H5JM,C@X2+U>IUPN8]LV[5:;-USS!G:M>1E#<T.XKH/C\nMV-BN93F!K9X"L.FL`;8%EJ++$O:M7XZR[$ZO6Q:Y-JBBP!'3&2]J<4NF!"P+\nMA7#NJ@%6]/=2+5?!&N&!J83Y<!Y3,H@1RH-E]NS>P]S\\?,=<.NNX4HK9N1D.\nM'CQ(412("%U=-?[D`^\\C7#7)#\\;OP'4=;#OOU&=BM?2XR9^1Q!G8/O@5>D8>\nMX?*LB?$"Q"]WCEZ`E#Q*@RNAM`[\\,LIVL2P;1]G8CL]+ZQ[&<L%V\\?,5?.&>\nME,G&%$'-)\\D3[F_>QP57[B3,%S!VCN>[>+Y#K5IE>;2>JU[U)L8GQNGO'^"Z\nMO_@PRR_VN6/F%C(WPE(*R[)P;0=+J9'X:UET\\IYX#O@,(C5T(31G4$D+VP_@\nMN'I^1_TR>`%X'B@;,0HC8`2T%HRH3GD]-UU*VPNO^]GC/UO5L[R;T&YSS]@/\nM254;2CG5FD>]7J9>#UCN]O/;UIM1RF+UJM5<_\\F/XNUJ<V?K5@HG0PP8(P1V\nMF8@",?+C=7\\S8!P`]1,`9L!\\LO/!,SY%DIZ^!)LMUCX:J)D]46GNT#WO80+H\nM`K_F4*^5J;MED,XFQ&@H"L$HP]E;S^8/WG,-T=9C_"BYDUQR\\JQ35SFX='G=\nMC.<S$R:7_TW'\\Y.KL?]?*6:$F;TY:!KBR*O%E8JX@N5:N*Z#Z]JX[E/[#-=R\nM>/G*5[)W[QX>[?L^#R9WDQ6:.,Z(HI0LU:RK;F:J,</D[.27&S\\+/V_;MOF5\nM`0#0`PPQS@`]N.S%1>&`[5@X)VV:U.)DT-_5SX_"[_!H>"]Y;DCBC#!*R3-A\nM1^]N=`;W#MUW)&ZD'ZBN"<8G_K[QJXL``)/`^0@Y#^"P%9NSL`5LL&T+R[).\nME%7::`[-/\\!4,M%Q/LD(XP1?JNQ?_6H<X_/-1VYOS,\\UKEUWQ<`=X[<UB!_(\nM?L4``!/`5D(2[L9F$S8;Q0*LSBPL"$8$;0QYH<FR@C3-L8W'^0-[N'+SVYAL\nM3/.EGWYQ?G)ZZL/1X?P+"X_&,GUC"W@>?_+]4G(>L`)(64V-CZNJ>KU7\\[SN\nM6I5J)2#P2Y0#GXH?T%?M9V/?66Q;MH.*W<6W#_\\/WSGTK</-9NLCZ6%SL].G\nM].1GFR>:?F$`CLLK@)0*W?P^%=[I5_WS^KM[O,&>90S4^^FI=%,/ZA2F8*PY\nM*D_,')F<;\\U_P\\3R#U-_UWJX^W5E&E^)GM;D"PL`L`5X&+B,/KK8K0)>YGKV\nMEE+)[>XDMLH%,V*TN<<JK._J:0Y95?+&OT7/VMP+#W"R_#K0`&IXJ@=/N0J5\n@8LR\\Q.1HN?L7-_%_?->;9C^YM<P`````245.1*Y"8(*R\n`\nend\n
105986
 
6595    industry_ok_48          begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```-N$E$051H@>V9>W!<U7W'/^?>?=V[*ZUD/2W++_F%7\\@V\nM%`/!,`[&3(J)33+VA)(^"(&0I!TR"8:I33J4CI/2H9UFVKI0EZ$P@0X9`I3B\nM>K`[B8U-ZQ:#0;8!2\\*R+.MI2?M^W+WWGE__6,D&9(%CM^4?OC._O<^S^_W<\nMW^_L.6<7OM`7^D)?Z`M=@M3%-BQ>`4IA:,T"+9P$"M'#%]9V1R,`C4!0*=7C\nM^<*]0Q?GP[BX9F6%`HB@OB^H^PH^P<2R"VVI`+50H_ZNZ,L<K>!O:R[.PR4!\nM$$.`J!8>5L+FHJCPT.47GE2!-5IXHN#3XAKP:-5O;N'2`'H!P\\!LO2;,E+J'\nMQ)7[<T+XU)+/AM"N4-'8)#7S%]ZHA2>*/BV8\\,AO"'%I``5`^P17?AGK]W]H\nMJ>HI6Y4G]Q>$<.>B3X?0/D3BU5SY.]^B\\;+%:_QR)N:@X,>Q_R\\``Q`0UR&T\nM<C6Q._[04E53MBI/'B@*D?<6?CJ$>"Y6-,85&S;1.&?>&BT\\7M"T2``>N$"(\nM2P,PQ[9.$<FE";>NI/+KW[)4O&JK^+*UH+$.+Y@$0H'X/EXV@V59K+CIMZF?\nM.>MLGQ`#?G`!$(%/GMCZV),X)3=8$Z_<9(>#,[M/=.@C;8>-WE,G7[>BL0-O\nM_>>O)P*4BI#+(*42D47+J+KU]O#@OSRW69(I551JVW_-4X65'3(10/OXN2SX\nM&BL89,75UU$JEM;T]/?M*&GU/5-Q_+M1X>]SDP-,R(!&H5%!#=\\1V";PT[K:\nMFFU54ZIOG#NG98()`'&+2#Y=CEP::]YB:F[^6MB,5]TO6K84--;^N1,S(7X9\nMP,ME\\#)I+--DV=)6ZFOJOJR%'7F?!:"XRYH<8$(&KCWX<YRBPY2Z&F+Q2IH&\nM1CB=%VI39YA6$^7Y\\^&7'"1?SH`NN?C9-"';)G[9DK#S]G]O%J<4S&OU9WM:\nMR-UT8HQ=`;Z/E\\N"Y^/E\\S@CHYB)!`NKJLFG,ZOZB\\Z.DN9N`W7\\]R+",\\4+\nM`%AWXE>0!MPZO-!<ZHH%%LY:09^KF;'J2SSXRY?.W?R1$I)\\!IU*XO6=Q!T>\nMPB^6"/L^U<W3PZ53/3_$*9F.J(=WSB+75V2LA#0ZGT472^2ZN\\CW]>$Y+J;G\nMLS`8I.1ZJ_I=?T=)N-M4ZOBFH/`+]S,`,!08`H:)C(6;2>/E<A0'!CY^KQHS\nMXCJ0&,+O[@"GA+GHMTC:->22"?R.8U1Z$BR=/GV?XY3P1#UL*G(^XYTX2['O\nM-/B:*>N^1B84(=-S&O7F019YPY2TLZK?]7<XFKL-I8[?9@HO^1.+8'(I*`[T\nMXYP9(O7^L8]?,\\=OR",#IU`EA\\R*-?SY:9\\_>'87V][IX86*.1R--U,]M2D8\nM"(7NTR)_6FF*A4)$^Y2&AS"4HK#^&SQV>H0_^8^W>,6JHFWE]63L*$N#06H,\nM8Y6&'46?!5HIOF*>LS`Y@`*E%$HIBH.#%(>'21]__SP`E.L_GT$WSN254<VQ\nMSA-D,QGB\\2K\\:)P#9C5G`C8-8Q".\\!-#42F>)][H,"R[BG\\?2G&ZMQ?M:2HJ\nMJRC4-=)6-Q4#:`T&J%-JE88=!<T"1''CF(4`P"]:%`*5)JQ])8$5,P@M2.;K\nMS?Y!G(Q+J)!@FI5MG15*WM'?JHR0`D_`T*!@CK@EE`B98)3VWD$6+UG*_`67\nM847"N*42&5'T%3UFQBMH:&@,]/0/?-?T2U>+ZP;$<QDRP^1=EZNN_A+16(Q<\nM.H5I&HP:`3("-4JQS#0I:7]5KY:?%(0[#*6*B)0!I/S2B.)G2M'DH:1C.*/"\nMHQE""N(&A"K9(,*&3T[`%2@9V_%2(QA>%9WM[30W-Q.(53`Z,H)9R!)5&D2(\nM1F-,K6L(EP8'KA;1B-:4S@R2\\,.(%F:WM!`,A4@D1@AFT@1$$!&B6E@F@D*F\nM=RH5MJ!X-@/C!@24R/C1^(6SV_.=^PB)@9T<9(8G]!@P=5H3*(/*4("FS"`S\nM[-#9)K%HE&FU]9Q)I<N5>/P(E<T+*<3B-$QM))E(D#W1SHRA?F*&(A*O(1BO\nMIJ+D4C$XQ-Q$@J`98)?OE4VU+P$T\\U4XM->,V%/-@(EA&)CF>)B8IHDQOA\\P\nMQ\\X9:"WX%7'\\B(WO^G1G7?XUJ>@G@J5@1NX,RTR7VF``[?MXGL9S?7Q/4W`<\nME%9XGL]Q0KP3G8)G18GD<]1V=;)T6C-S-FYB='$SO48.$\\5LLW9PWJ)K?Y#6\nMX1<"VO$"`//"E+_[5UX!M_PN>"ZX3CF\\4OG8'POME8]+!?`<Q"FBG!)XY>^V\nMYHC!'54N9[(CB.\\3JS`($L+W](2DA<P`GO@82C'/+5([U$W&\\3!<EYG77H_]\nM_3MY<F0_1S_<1R001HM&BV[8:*>?6+]H_917_O&UQ\\^-`SX0L:%F:MEX,0_%\nM+#B%\\ES'5>![D$U!+EF&")AG.]"X1`3;5#1'0_BNQO-\\/,^?6'+GJ<8*0V$9\nM4+7R&M1]=_%HQ_/,C#=SUS5W,I(;85_[/O:U[^-(=UOES"DS']KT[4UMYP`,\nMRJ9R*2CDH.L]/-%H7R.B$1&TDT<*&2*E/*:I.#<4`R(0"$)5`[Y;-NVZ/IY;\nMWI))H;+IB11C;54P2*1A&F9E%;'OW<-?GGR%I8V+F%8UC5U'=['G_3T,I8:H\nMCE;SS>N^Z37'F]_)Y#/)<P!J'"`#^0Q]KF)G<!:>H<D5'/*%(GG')6[/YJY`\nM._7%X0DF='4M>QI6,N+X%`I%\\H4BN7P!7Q371_J9FYUDU2]"L+Z>4VLW<MFJ\nM:WGF]$M8`0O/]]B^=SMMI]OP/9_%,Y:P]<8',C?-6_MHP+>V5]56)B8"Y+-0\nMR))Q7-*VC3),N@>[Z>[IQ2FY3*^OQ9]D`>X+##L>9KR&1+:7SIY^$HD4P8C%\nM%7'_4W\\"\\05BC4VT^1_2UM?&].KI/'WP:7I&>@!8<_E-_'C!G:@=N]M?V[UE\nMN]78D/CZX;?X!(`'^0P4,A@B.$6'7*%`;]\\`VM?$HC&BMCTVE9PHA4*T)IE,\nM<>I4+\\EDFDC$PHI58)KI\\W6#LPH%0\\Q9.HLGWOPI$A!V=>QB,#^($3;8</EM\nM;&G:2-]#C]%_Z)"O06?[3P-\\`L!WRP#%+$I,,MD</7T#>)[&CL8(1RPBEHV:\nM!`"E<#V?4P.]C"126':4B&5A1:.8>O)5B8BFHF4N^].'Z$QWD"OE&/5'"=@!\nM-BR^C2WUW^#D_0\\Q?.P8RE#*T.<>Q;FYT'@)%;(P.H3A%$AE<Q2*#G8L1C1:\nMCDC$0DU2#$HI2J['F9$$D8A%-!K%CD:QHS%,TRQW]/,H$+90JZ_CA9Z=C.I1\nMTJ0Q+9.;E]S,'ZWX$>TO["9Y_`.4:4YH:WQLSW,ADX)3[:A2D5+)(QRVL.TH\nMUI@9R[(FJR"4`M?S$0SL:*P<=@S;CI8!SO?T?4WE94LX/,WE2+(-/^2C+,7R\nM6<OYT8H':3MX@N%$`L,X_X=^HH0\\&.J!D4'4#)-@*(QM!+`LFXAEC960!9G)\nMNJ/"-`-8MDW4MHF,W1^Q;8RD@?@^XG\\\\"\\HPB*Q:Q:[L&WA!%S-D4A>I8_.5\nM#]+S;H*AT23-P>"D_>?CXX!3A($>T#Z&81")Q`@#L5BY=`*A,)%(8-(^H(!0\nM.$(T5D%E106V;1,.1YC:V$#S[#CQV8TX'W:0.O)V>>06P6J8QF!K$X?[GB(<\nM"V,H@^\\LOI>JT2;>&VRCHC*.&0A.8O^C`";E,<`TP%!4&,*JE@:489:?NF'@\nM^AKE>01$E^M%C2W)E(!AH!`N;ZYC:NT4K(A%*!JC?M8LLO8(!]*GR#1;7+EF\nM(_-?;V7P^7]"W!R5*Z[B0.4@F8$TAFUP0_T-?-5>0_NQ#EJB(3SM0ZF(_YD`\nMBO*\\QXQ`)$KUZ?>YK91"ARTD8I>W80L)A0DU-D%H%D1LE!G$,$P"RL0,1+@N\nM'D8;07PC@#3/X.7,(4H9EWDU<TFX25Y/'::X9AE75&\\F\\\\XA(E]9RQOYIS%L\nM@]IP+??4WT[AJ9\\3?O<P1K&(DRO@#`\\CH3`4)J[J/[HF'@7^!I%*?$](#:.*\nM&<R(!>,1CI0C8D/8@G`8E(EHA1;0`KXO:%%(("3FS&_/+/C.^K>'WXJ]F7B3\nMWF(O5;$JAM4(,Z[<6*CL&_CUR2:YX</!SF@P&N2K4S?(_(&*5X_L?+'-+3J&\nMYY1P'1??<1'MCQ?Z*<"9M*;^M]35T47G.YVAX9'A>Y\\[^MS0\\G]>+K7/U$KS\nM+YME^9[E\\FC'7Y1RN?R^O^[Y67[!H06R]MA:.9P\\_%ZB)]'2W]=_P9]S:3\\M\nM?HIFSYO-2'*D]/)?O?P/MTZ[]9YM5V\\[N;1A*2JL2!DI]J1W!T_2=?U1_XAE\nM1DUNJ;M%6FAYLJJYZL0'QS_XO[+UFVOOO^U%1$@.)E?OZ]MW?-W!=3)W_UQ9\nM\\O82N;WK=KFFZQI9U[M.WLV\\>V2X<WAZ]\\GNS]OR1#WU^%.("*G!U`UOG'GC\nM^/JCZV71T472^F&KK.A;(8^E'Y-$,O''(L*++[[X>=L]OW;OW#T.L7KOR-X3\nMMW3=(LMZELG:T;5R,'^P*WDR.;^OM^_SMOGIVO^K_8@(Z>'T;3N3.\\^L[E\\M\nMF].;92@SM'W+JBW&:Z^]]GE;_&P=V'N`!V]\\4*62J?N>33_KO)I]-9L>2J_)\nMY_(7]7X7_3?KI:C]_78D)W;M@MKMAF&T]'?TW^HJ-]7:VOIYV+DX#?0.T-79\nCU=+=U7T#P".//')1[_,_R&BQ_!/ME<$`````245.1*Y"8()Y\n`\nend\n
105987
 
6597    inventory_categories_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```*<TE$051H@>V82XQEUU6&O[W/X]ZZ5=5=_8K=CCO&I+N5\nMQ"9"&,0`)D%(O(8)$X9,,LL,B)@P9,Z,S)@@F,``B2C`A*$'*(IL$B-C8EMN\nM=[>[JJOK5IW'WGL]&)Q3#[<+)?2``M%;.JI5J\\Z^M?[U_VNMO2\\\\7\\_7\\_5_\nM>H5GV>3_`L`6<!,GF,'QXWYJ_S1^,QSG(V!XY>O__5CJ9P+@`/PJSG=$J(M\\\nM.D@W,#_?=_:G.\\&=WIW?`]Y\\EEB>"8`*`$M5;O[U/X3ZX&A!VP1P6+00@A&)\nMM(T!1@P5;3W9(=2TM1"#\\\\*-+;;:=6_F;7@F+3PC`!$(`5+&U]T&O_&-/V6Q\nMO,2]M_Z26Z_]%JG?9_>]?^*%G_UEQOX)3S[^`==NOLK8KUGOW6/GRB9E>,!J\nM<X$,AY@Y%P)`%19MQ<Z-.RR6EWF\\L<VE*U]@:#98+Y:LMF_@;M15(,@>EG8)\nM/F+#8[P,F-]$9OE="``1B,&0X0'!.E1'2G^?W.^BI6/]T?<X?/P^97".'K[%\nM.!;$;S+:'NX1L_KB`00<&7=!>U0*Z>A]#A]\\G]Q_PE'^F#1F-+R,S>\\7#S2`\nM>T`O%`#'##B:=G%9(OF0)S_^&P[W/\\#\\);R:@A.FIP@4"PASE_(:43"](``J\nM$#!DW`,3).V3]1ZFAGA`90[:`^(@9;9#P$X8"!<$((#H)*'2WV/8?X>2%(WA\nM1"HEA"EH`F7>)TP,.!,#*E,S^!\\%H'H&"$ZW^Q;CX7V*WIJ"/\\YZF.SCH$]L\nM!R-@5IW4P+.N9V8`YH%FPKB^CX@A.F5?RAQHF&43P_1[86+%3QFX4`"BX.Z(\nM^)3U8P`RR>:$@3@%?=;V$#Y5Q!<&`.<TZQ80"90"$J9B%9D9L/F]&"@1"&`^\nM2^BB`.@9`$68LER.`V5BH(#6$X!20.J`6(`0<&].NM"%`?!C!N8"59V+.$Z%\nM*S*S\\93]OX.!^9A<"I0,)40*LUT'RLQ(@5/_W)%"##@UJB>GVXL!L-J\\Q-;V\nM%<0JEO$%-NL-FLN*U)]G%:^QD0UK7F(9/L^EXEC[$AOA-E6SI%E>IA2_.`;,\nM86>5B1S0A$AM!UB*U!Z):8_BD4@DE`=D#T`DC!\\Q>,")['UP2,EZ?$%ZIG4R\nM__S;OPW0$,*W"+Q&B#9UZW.W61_7KQ[$_5]S)[H[[IP\\YD[OX_??UG__"V,1\nMFU?^^/=#>_-U-S`SS!Q5FVYJ1`F7?N5[WO[,?=42)K^AJO-[>OQ4[OZFBOYY\nMK*+_X1_<!3[+0$W@-P]&^?4?/5H3<4*,5#%0`3$$8HQ4P8DA4H5K5&'R5S%2\nM!6CKFBO+ANCV[E<>ZY_]W>_^1^W"UP[73U[_\\,,?3B"-^>P0<*<._='OP-NG\nM?@^8.X&`,_W/MMG"G%61\\IW:ZY/,QL\\F-_#>XR/>89OJ%[Y&?_4+E!?O$+[T\nM2QRMKE.NW2*^\\A6.VDODRY\\CO'"+P[@D;^[`UB5\\<YM2-:24(77DY&@1/OKP\nMAZP/WN'.[1;3@:U-X\\[M#;#"]G;-[=L[Q!C9V5EQ^\\YUELL%UV]<YHM??)&7\nM7[Y.B$Y.!4E*R7(FX^>LB//EGW^#-[[Y1^Q_]Z_86"Q8OO8&C__Q;]G8VF3C\nMU;OLO?G/;"Y;EE>OLO?.O[*YL6`9%,V%=+!&4Z$9E9(ST0U1XZM?_3+?^/HO\nM\\O??W65G9X.?>WV3&'>Y>G7)W;M;F#YB9V?%R[<VR7F7G<LK=G96'*Q[/GGX\nM8W(13`P[4S3G`PB!*!G6C[%QP-W@X#&6!CPZW'L/VW^$5P8/WL7VCY#5)GE<\nM(UO7*<605%CD3"Y*-,'440T,`Y2BE&ST`TA1<G*>[$/?&U5E/'@`7:?4M2!:\nM$,F("J44BBB-5S\\!0#P%X&G`@\\&33[#N`/;OP0>'^$&/;6]CZ8@T%$)HT#YA\nMC2+%D"3D49%<"*ZH&6:1<0011]49!DC9.5@[\\3[T@['<<(;!R+F04H5J10B"\nMR"0=-86?AH%*,JSWIJSG#O;>Q^^_CV]O0TD4,7)2&#)#$D(L:)=@I6A19!1R\nM$K((T63N.I$Q30#&!/?OP^'::!I'!'3.\\C!D4DJD5)%SI*D+*M/?Q)3ZS/'U\nMLP!\\EI!F.'R,CST</("TC\\I$81H+XU"(L6!=9AR,2*'J,S$K%".G0AJ5DH3@\nM!57'+)!&$#$.UTZ,H&:HZ)F@:\\SJ,W9@8SDQD(M@IKC]!`:J$*BDP.['V*-[\nM:)PD,28A-@)=8AB-&`O:)X81JE`(?:+)2A`C)Z$9E*)"T%,&CCKHCHRM+2-G\nM)>=,RC60R2F14DO)IW;.@1AU8B<73`6KZ\\\\"<)];LSON3L@#O/<V^?$N]?9E\nM8I\\91Z&J"_29(3EU+$B?&7.D"8)W&<]&E(F!18*<"M$*IH8*[.Y"UPMM6^BZ\nM3,Y3ID4R*6=2RKA5I)Q9I$P_.,N%(ZJ4F8$S!)P"D#)==(.#B:+[>XQES3B6\nM.>@IZW5=L#XQID@;"K'+C%;1A(+WB9B52B<&T@A2"EA!U#CJG+V],LDC-Z@E\nM4DKDU.*>R"F1TY)<(BEE4EOH.V=K,Z`BY%QP'#M/0CE-7S4$!\\E*D<+`@F$T\nMJKI@?68<H:D%Z3*C5K11"'UBH*5%T"Y3%Z.VB8&LD$HAJJ!B#(/0':59W^TD\nMGY1)J5#DV,X,0YC>:3-=I^1<HZJ44E",.I[31G,20@C@/G61+(P1QA':>B[6\nM$FCK63;>L`B3G%(5211*GUAD!4X9*"4351&=NE;?9W+*TU356>LY,P[57`^%\nMK@_DE$F+0M\\KN3`#$!2;9M'3`,H,P-W1/'6/P9PQ!]I&J/K$J#6+6@A=(E6!\nM%&224U.QH*%TF5*,P,1`DZ:A%;0@HJ2D='TBY43*QU*:P/1]G)DI]+U32F:1\nM"GT/)5>H*CD+9H*?5\\0Y%68"D"*4L3`4892:15,(76;$638%[S-C6[,,!>DR\nM::,E4QC[1"Y&#$8>A68`R0*SA%)6^FZ224Z9OJLFV<Q9G\\!D^LYPGVJ@ZYR<\nMV[F("^[VJ>/W*8`\\?UME,P-C80!&/PYZ9(R0&D&[D=$:$C6Y&QG#DM$+PZB(\nM.!+F+B202YD9,-(H$P.S[KNN(HV)-&:Z(Y_KH-!U2HR9IBGTO2&BV`D`Q>Q<\nM!LX`*(IZI!"PV*"QP<(";Y98L\\2:%2PW\\>4&OMPF;EVB6:VPG37ME2O(WL.I\nM!F":Q#(-(C5#2B&@@&)6J"JGJIP0C+8)U`W4M;-81%:KBNWMBDN76KK.R'F:\nM)TUS'@.I3//`H"%P]<;GJ.N&ET)%53?8Z@X;L::J&NS:%7;JEEA5^"NW>+%I\nMJ>L&_])=JM6*AV__@%*4/+=G+YD86]K6@%TVMQK,![:V1[:V5S1UX>9-(<1M\nMZLK9WH*ZODI=1ZY?#[3M$8\\>'2(BJ#IG+UJG19R%$(*9^8^"^67M/]8L-@V@\nM^9F&D4W'`M79[[-_ND%)452M=O-W"U"*."+_YL:+GSSLU&R-VK1_NIW-GVWS\nM9YE^RF=FB!AF5KO[N^[N$XBG`*@H(82DQK=-K58U3)X*_M@^SW\\6K#EF7@3<\nMS<3$_L3,ZJ<#.PG<IKW_E>_8#Y08\\;.#[/EZOOZ_K_\\$6F)X%ST5*7@`````\n(245.1*Y"8((#\n`\nend\n
105988
 
6598    inventory_write_48              begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```-E4E$051H@>V9:VP<UWF&GW-F9G>YN[R+DDB1NLNZ6!=+\nM5F*YK@+;B5/+3M`T:)TV;>JZ@('6<%$@18`6_I&B11($<'ZD"!JX1I`&A1O$\nM:>"FB8VFO@:-U<9W2U:L^\\VD1$HDM=S[SKE\\_3&S)"5;LDJK`0+T`(.9(6?.\nM?.]YW_<[WSD+O^)-_;(^]*FO/4F]'G=M7KGH-QJQ[3DX-O7,CG7+3SSRQ--4\nM'W]HP?W^4@"L_O/O</SKC^BO_/#O_G9)=_X/1Z?K\\<$I>_QHO?#90D:=?_Y/\nM-R^X[_`:QGG9E@U#-GS^@>ZF\\7>^?'SJ&R?CPMX5RY8]=ELANT%$SC__`?H.\nMKEF4[]FVD/_C+W/V['1^H*_PR9HN_G;GX/*E']DZM&F@P+87WS@RO??@U,%X\nMXB>5ZQ]ZF?&??.-=/70">V_;P,J6R7UVI*=P9X<S>[I#>:IL@0\\@H2_<!000\nME]!:T+DL=!2@(P^Y#NC.PU9!]OA'-^^Z;NBACVT>^<3^,]6..-?)VF6]'#@]\nMPY&)EB\\4B_N["[FOKC[STW^]Z]#GC!G1&)-\\(PQ@SQW>?_?/-@VMW7+=5Y:=\nM>7.C/G?RVX/[Y.\\?'4'N?V>!$OKRO0I!0BW\\?L=PUYY\\H3,;*(<2@\\*@,2AI\nM\\8]NM[IM]>#66S:N6-6PBB89CHTW.#*ER&1S#"XNZGQ6;RMDPT=R`]QWXFQG\nM=42J*A,I1$`<//3#G?[\\1Y<LZ1^;NGGH[&GM15[]G3Y47B.P0``:L#$KNI8,\nM_<UUVS^QO%D=IUDY@Y@:8FO@*HRU!CG>=0^+.A?SU)$&)1,29(H4>K(4L@'Y\nMK*;0/C)!9Z'_]CN:E=_%37Z+7*0049Q>W,-+BS["J]/;>?;P"^RV9R=6N]*C\nM.P8"_[E#$RP80!B`@T+_TK7Y7$>!T2-O,[#C`:)<%UH)2@G_>2S'=+R!1ER@\nM4,RQMI"A*Q?0E0O(9S294)&)%)E(DXLTN6P!;OD\\S>/7T]%5Y*P_Q+%5;[(V\nM=X">XU.,GAJ1Q\\[_0;SNQEOO[W_]%T?7=5,Z]-(#'P!`@&CEL*T9PDR>Q9OO\nM8>W($)&&V`G/RQC#4TT6%R-Z\\P$]'8KN''1F(1<)J.306J$UA&&,='?1O^73\nM]"WMY'M'O\\!D:X;R9(O=W1]F_:[JV7=.]KVXK&('ITLS>!\\NG(%`)R`T#H4E\nMT,EU,0.1!N_A_NU%ZJT<(AX1!Z2BQ@*"$@%`(<F]%<0[!@<&^/'8O_'$P<=1\nM"C9DMQ%GRAQ[<5\\F=^:^_%1C]*^*0^M+KSW]+PL'$`8@`6CE49(`F-^T5NBH\nMS*G)M]@ZO(VA[F57W?>Y\\RV^^TS,]-EU#&1F&!KNX>3HZTR?NK'NIJ>_Q,I%\nM!U[Y]X>!O1\\`@+X,@&10.31YB(>?>9CUO>L9R@RC:AII__,*39SBJ\\_5>9G;\nMV'FAB_*!%YBXL<10L)P_V?S$F1VWGCPX'0?L^)&;BV4A`((V`SC`)!)2FC<F\nMW^#URDN,-<>X??OMW#5X%V__XFV.CA]]_TZ]YY]_5N%;F8T,E)LLET&*PUF&\nM^V!(CK)AX"1EKXDR%P_$@CW09D#/,B"LZEK%6_(Z*_M7<D_O/;3J+;+9+&%X\nMY<]H!0?>"?E183G9BF%W?8;!1;!A9Q\\[W-<I9A7B-8'G75/O@@&0&A>Q:)VH\nMISO;S;U+[\\6)(R!`:TVQ6,0Y=X6^%,=.5?GKUPUG\\\\+M4R76=<6LNV4-JE)`\nMS0A!%KP%KAF```A`S?.``A#0:+1*3!'',6-C8UAK+WK?>P^`4E"K.KYY:(#C\nM/4O8?&*"S;DZ'__8"H*1`0Z_+.@(@B@9,/R[8_F`#*0`+E-1Y7(Y5JU:-1MP\nM$K2BN[N;3";"&<^7GACE/Z(<BXY/<I.N<_/./G[MEA7L/1GC$50$.@4@UPR`\nM4J`%I3Q@4/J]GRO7RAP_<1SQ<\\8+@H`;;KB!0J'(]U^8X!]F\\@1C96ZJE]F^\nM/<>>/>L)`HT7$@"AH".5`'!<&PEI#:)!I0QH)8C,!1G;F"?W/\\F^L7U\\9N=G\nMV+!TP[OZ>/7`!1YZHTIIVK+Y]"0[-P=\\ZK<VTMF9!4!$\\(`.04<"2B'Z6@%0\nMS)I8B4$K\\`+EN(S6EI^=?I$?'/P!#W[X04:Z1F@VFQ>]>V[2\\)<O3'.DI5CZ\nMUEEV+6EQYYW7,3"0PQA#%$4I`XE\\=`0H09Q<.P9(&4`L2H&@.%(ZRO<F_@F=\nMU7SQ[B^RE*7\\_+]_CDD+?*6@43,\\NK_(LUVKZ=H_RJT],1O6-"B5CO#<<T<8\nM&AIBZ]8M\\R24`B!A_=*V<`84J)0!I4*<]^P8V$%O;YZ&:K(NNXY6J\\6*%2MF\nM3:Q1?/\\5R]/%+!U'I]BMJFQ9$W/7W=<311KOA:ZN+IP'ZP0OH()$1B*@KI6)\nMT_A!/.(M$.(24[`^-Z=W8RQ3TR6L=81:>.U@B:^-#J);BMMMC9LW1NS:5:1<\nMOH`(..]QHNCJ'<"XQ`,JG`-P52:65P#H!78#D?A$W]XG:<Q[0'D_>8Y5TZ5:\nM)HH<AB92_S%F8@!))S4$E/,L+U:(;<CYYBIR'9Y?=_L9.PI%'"M6]%$H=.#3\nM+.73D6\\9GS(@J"`!H7S*POL"2/I:(\\*W8T-/O8E(^O+\\(\\S!HL4S@?@9!/!C\nM#S(U>O$SW@OB/42#Y%=_A_/CXVQFFD]^?#F;-FY@:+`;[WTB&2]8Z\\GD\\K2L\nMGV-`@P[`!Z"O!D`Z:2JM")Y]"?WFH2R]W3FL,60S(6$HB+<$.B03.10>D8!<\nMQJ.4PSE-+JO1M,AF.QA>$B+6<N3(,2KE!H-+^KCCHS<S,C*<?,^#<8*Q@G$>\nM8SVQ];,>0"<@E.+JTFB[;!$%I1G8M?L>/G3;_9QX[3$BF69@W=U,CKY&;?PU\nMEJS["*UZB?%C>UDZL@9!,W[Z('T]>8068J8)(X\\`VZ[?PKK-BUF[9B5A&.+E\nMDL!=&X`DUUY2N<Z!T%=3"[7+%JV2=)G+]Y+O64V4ZR5T+;+%0:)<#SK(D,GV\nMX*Q!*878"M94\\;:&;=5P\\31!E,?Y"&<-/<4BO<6EU&JU1"XN"=0Z/WMMG*!T\nMA(YR6">XV55;VM352PBMDA?%58CKH]BXC)(&IGX&V[R`LPVJY_92F3R$:=:I\nM31S!Q%7B1B]Q&&";)3+%#KP$-!HU]N_;CPVG4LW+W)%ZI7W?U;>8H97K$P_X\nM64^FLK@TVBM(R+<!V!JV-H&+JP2J15Q]A^;,(>+&.<JG7Z75BO%N.$F!#JQ5\nM.*>P%@*G<2Y`T/3W+\\)EE^"<2T;7"S8-VCK2LR>;[TP\\X`679K[9Q/`>&*[(\nM`)(`,(UQK*FAW'DN''^<\\MG#J'`9'H>7-&B;O&OFG4.G\\3[`&C`M@_-Q`J`=\nMN&=VY-N@)+1D;'K?9L&3U!57Y8&4`4WRL+@:ICZ.,U5\\[13.C^*=1FF%@R0X\nMI[!6I8$KK$L`.:]Q$F",ISI3QH8EG'>X-%COP4E;/LE$)CI#AQ-:L:'9:.)M\nM,H%)&\\C[9B%[B81<C5;Y&(W287)ADMJ<58A61)(`MG;>V3(+QCF-]QHAH']@\nM$)\\=QCI/$&7Q:$QJ8)O*Z$+-4'%";6*:F0M-6K7*'`!WE3-Q6T*J+2%3H3*^\nMEV9EG+!K$;A$'FB%U0ICTE&?%[Q+P3BO\\#ZDV32,GSR!"9J@%*LW;"-?[)[-\nM]TDV`A^76=P=<&;&,M.L4YLIXVVRG/3_&P#S4U6K.D;=-S`VPEH%:7`$*IE!\nM+:EDU#P/*$S*@/.:(,BR:=M-J,(JC'584;2,NRA]6B?4:S6L[F/?J?.<')U@\nMTZ*EB%6S(+!7(Z'4`^TUKFE6,!%8FYD%8"RH0&%5"L"K>5*ZV`->`IH&3I4$\nMVVJ;TV-\\8E+K(3:66JW&Z3,E1DL3E$HE;MRQDQ7F$,X(8A1B%R`AD82Z67FD\nM.X/6@@H5EGD`YLFH+2'O-2(!C6;,L:-OT8PNX+U+<K^`%\\%83ZU:9>;"%-.3\nM$PB:;5NVL:GW'.'X.,ZD$C(@OAV]7![`13L@,A>,24=7M0$XA944@"2Z=_,8\nML+,2"@G-%!]J_`6!#Y.UK0:T(`@^\\/C(X[H==IE!!Q%A$*+/"&(:=/4I7`S>\nMJGE9Z`H`9AE(G_.2I$KKD@FJ#4#/!\\#%^F_[(9&01NL\\UUW_FQ3ZAM%1`:4\\\nMXJN(KR1G5P5?Q;LJ8BLX6\\&;*MY8;"N+BV.\\IX87>]6EA"*M_V6>A*R:E9!V\nM<R9V:F[4K4O`&M.64$BK66^53C[UEKF0;^HP2'8QE$7IMC-3;8I%Q"'>(LXA\nMSN&=0RRQ>+ZI=5#WEVR275%",B_/&Y,`$)-<!U9ATD"-3EDR8(R:]8&7A(%F\nM@_.']Y_^HQLV<KP2HW4XM])20;K&GE^HJ3GVE0?QRCM+PRO'^M][G[W1^9MH\nM2@6$V0)!)B!7*!!U=!,$`^141%CH)^L'\\9&#8)".3`:=J=!ME]+5FR&7B^CL\nM7XD08RTR4Z'VTY>HW_?N'R*OHEU^9_MR\\X`2@9YB2*:C"Z5#ACL#E*I#H9]"\nM=X#H*HI^BJ(195"JFV)/#[U$!#I$.E>CB9D>.X!SR0IS(:&_7WM/"2E%683_\nM4KY5;)9'I;T6OFAM?,DZN?W_BYZ="WS">QJ7&O#_!$"Z`W)8A$^+H-HU>3O@\nMV?OY?V^7NI=<SYZ37S>:<GDE_'_[E6W_`T7F?](3(-%#`````$E%3D2N0F""\n`\nend\n
105989
 
6599    inventory_zoom_48               begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```-[$E$051H@>V8:XP=Y7G'?^\\[EW/=L_?UKB]X;?`%`[:Q\nM`Z9)0`E5U0(I1(T$ZB4E1>)#*Z2T0NF'IFJD1FT_)'Q(52E*JUXB@E"(:$15\nM4-50("%`($""#<'WRWK7WK77NV?WW.;,>WGZ8<Y9KXT!=P-(D?I*HYDS.SOS\nM_-[G_W_>>09^Q8?ZJ![TV8>>I-E,*]>.#_UF*[5]^Z?./;UKTQ7'OO7]'U!_\nM[,LKON]'`K#QB]_FZ#>^I?_NB;__ZJK>XA].SC73_>?LT8.MGM\\K1^KL<W^\\\nM;<7W_D@`KG[P$42D_YZ/;WYZ9K']V(3I>7']:-^C:YC_R_C0C]]*G/@T-7,S\nMTZ=/[]BY._GNH]_A^6>>O*Q[?\\@`UU&\\[XLTYQ>+5V\\<^>SZ*]8_M&'MZN-[\nM^NI39N'<;\\]/'4_FY^;%&NM!ZB*RM]5J/3H[>_8_2J5R[5^^^;4/#^!+MP,!\nMI%6T%G0^!X42%(J0+T!O$;8+<IO_IVMOVKSZR[=>L^XS,XM)8;PHG#ZPE[W'\nMSM#.]1`6R_A6[6S[].%J0?E5?>5R3BF^G]1F_N*?]_S;Q%-36HF(#P/M[_H;\nM]\\$`_.V]"D%"+?Q^H52YK5CJR07*H<2@,&@,6MJ\\YFY69S9^:?O'KQ[?T!.'\nM]-L%?O#<BYR4"KMNV,U`?Q^IP'QBT]:9`V>#DT^'K;G&T$*]1Y=4=>^G!AX[\nM6@KKRGM5%?@V\\!S`G5_U2[&$*P'0@$U97UFU^J\\W7_^9*Y+Z-$GM%&(:B&V`\nMJS'5'N-HY6Z&>D9X^DB+WU@7L'_O:YS-C_+YVV]!:<U\\8CA333&HN+)VZYIB\nM=)J!D9<Y,=7B]-FA'<<;FW?L&'@=K\\`+8PIY&45K>2PK`@@#<%`:'+VJF"^4\nMF#ST-L.[_H0H7T$K02GA^2-YYM*M--LE-@W&]+2/\\8MSAOO^X&;*A8A:V]$P\nMGBC6#!1CRH68L'(+\\=P(5V^(,3\\]RM3D3C;9_51R3;Q7O8**@!;(!P`0(%HY\nM;'N!,"XR<NW=7+5N-9&&U`G/RA1KSR4,ER-V#PDG7YMDS?@XJWKS++8,H19"\nMY1@N:GH*4,Q[HD*9WIY=K!H>QB1EWE@\\1S7M9[C4Q/HL[(LUOR*`0&<0&H?"\nM$NCLN!Q#I,%[N/_Z,LUV'A%/L[[(&]4Z(YNOQ#M'@">OA8'($X>>2@@EY<@%\nM,-1;H5(.&1X9HF]@A'2VAS@4M%=X`741P8HS(`%HY5&2`2P?6BMTM,B)V3?9\nMOG8'!55"O,.+X%%$84@0:L9R,7$4TE^,Z<E'E'(A4:`0@2@(Z.LMDZ]ZHA"4\nM)P.X.)85`>AW`>A(\\\\#L`;[^]-?9TK^%-?$Z,#GZRP6.GYQB?ML&(@U*@W$.\nMK02?1"2Y@%JH*17R]);+B&DCIDXYGB>,%,J!R"5B60E`T,T`#C"9A)3FY[,_\nMYV>U5YA*IKCU^ENY?>QVWO[%VXAJL7GC.EY[^J>\\>?Q*KAKMQWM+K=5"B:,6\nM:PJA(E0P-C2`]S`[<X:9B=>Y9KB*CE16^BX!H-]YZC(`=`:AE4<O94#84-E`\nM5(X87S/.W5ON)@HC\\KD<@8)B/N2ZM?V\\\\<JKG)A=9'HQ82%Q.$*<"O%!3*5O\nM`-$AK[RZE[?>?)M`5RF7'#HBV\\)LOWRLV,1TC(M8M,XFIS?7R[VC]^+$$1"@\nMM:94+I-WCH'!0?*%$K7__B$O/?,,HUNN8=7(('&DB"4@<C`Q>9H3!P\\Q.W4*\nMRF-LV[8#U?X>.@8LX'F'"58L(0)0RSR@``0T&JVRQ*9IRM34%-9:`)J-)C?L\nMW,K`\\5,<>^L5FL=ZF"X5*<8AVAH:U7EJ"_.</C7)C;^UC;!013LY+R'_SEA^\nMR0QT`-[EA22?S[-APP:\\SYZLE$('`3?LLNP_>(3#1T]0K2Y@ZI9"(<]UNZYA\nM8*"79W_T$]R1UVG.',)="4$,RH)\\8`!*@1:4\\H!!O8N3%AN+'#UV%/'GW1<$\nM`3MW[F3S5>.TDH0T-8@7<KF80B&/H-A:R:..[.751Y[D5+J*P4_.H".%=Q_0\nM.J`UB`;5R8!6@BRK<:E->7+?D^R=VLL]'[N'K:-;+WF?8J%`L5"XX)P"1GH+\nM+/S7PUR;S')X?@\\G#_^(\\:WSJ(L7G!4#*)9,K,2@LY<M%M-%M+;\\>.(%'M__\nM.`_<^`#K*NM(DN2R[QT$(?F-6SFZ?@<]/WN!L:#`B6`78?R"7/MK"0NS'P1`\nMQP,*#V)1"@3%H>IAOCOS,#JG^<H=7V&445[^R<L88R[KOB+"ZM6KV;Y].^?N\nM?)"9??O8?.1YDMY!#K]Z4]^_/_QB7T^AN`C57Q)``0I4)P-*A3COV36\\B_[^\nM(BV5L"FWB7:[S?KUZY=,?#D`E4H%YX5V98RCOWX;PV>>9\\W$/EK;/K7U9''/\nM@]]XYOD__W0^;C^;I"L'Z,0/XA%O@1"7F8(M^?-Z-\\9R;JZ*M0ZMWA_">8\\3\nM1:5_&&,\\=C2D=0=4GEC@BI-OJ/JZW?=_8??VM[[VZAO_^/%`\\Y*7=P+(JP#T\nM`S<#D71>HKS/RICW@/)^]@P;YJJ-.(H<A@1I_B=F9ACI+&H(*.>YHEPCM2%G\nM6N-8'R_-]*6&]V"=T#8>ZP0O0N\\G(&TJ\\D].<%6YOS`]W/=7GZL4#NT<KCQK\nMSRY<`B"[]Y4B_&MJZ&LFB/CL_/(MS,/0R$(@?@$!_-0#G)N\\\\!KO!?$>HC%Z\nM-WT'<FL`3Q1%J$X]%!&<!^L%:SUQODC;>HP3O&1K0-^=,#OA2=\\ZA/2,K]DP\nM5/G\\0\\?.//^)$/L.@,ZBJ;0B^)]7T&\\<R-'?F\\<:0RX."4-!O"70(7'D4'A$\nM`O*Q1RF'<YI\\3J-ID\\L56+LJ1(QAZN1)C+9$8<#NW;OIZ^O+GN?!.,%8P3B/\nML9[4=C.0:37N@\\+GU*G)T[US.T+WMG6UA^2N<7O+4\\??F0'7:?Q%074!;KKY\nM;F[X]/T<>_T1(IEC>-,=S$Z^3F/Z=59MNH5VL\\KTD1<977<E@F9Z8C\\#?46$\nM-F+F""./%V'/C7L(RQM!/'$<X^6BP%T70+)C+QVY9O'T;&0BMV;FOO;CITY\\\nM<HRF>N(X<`D3=S*`5EFYS!?[*?9M),KW$[HVN?(84;X/'<3$N3Z<-2BE$%O#\nMFCK>-K#M!BZ=(XB*.!_AK"%)VH1A`N*I-UM8EP5JG5\\Z-DY0.D)'>:P37$?/\nMW:)QS9_:*?5G-(=WG8_W/0$4(*Y&VIS$IHLH:6&:I[#)/,ZVJ)]YD=KL`4S2\nMI#%S")/625O]I&&`3:K$Y0)>`EJM!OOV[<.&Y_#>X[R<WSI>Z?ZN#(RP>GQ+\nMY@%_41-S.0U-5T*^"V`;V,8,+JT3J#9I_23)P@'2UAD6)UZCW4[Q;FU6`AU8\nMJW!.82T$3N-<@*`9'!S"Y5;AG,MFUPNV$[1U=/:>7+$G\\X#/S'U!`;D$PWMF\nM`,D`3&L::QHH=Y;YHX^Q>/H@*ER#Q^&E$[3-_M<LVX=.XWV`-6#:!N?3#*`;\nMN&=IYKM0$EIBV_G=S8(G>Y6^G'[`=C*@R2X6U\\`TIW&FCF^<P/E)O-,HK7"0\nM!><4UJI.X`KK,B#G-4X"C/'4%Q:Q817G':X3K/?@I"N?;"$3'5-P0CLU)*T$\nM;T%<)Q.7`^#L11)R#=J+1VA5#Y(/L]+FK$*T(I(,V-IE>\\L2C',:[S5"P.#P\nM&#ZW%NL\\093#HS$=`]N.C.8;AIH3&C-S+,PGM!NU\\P"=[?TST`%070F9&K7I\nM%TEJTX25(7"9/-`*JQ7&=&9]6?"N`^.\\PON0)#%,'S^&"1)0BHU;=U`L]R[5\nM^ZP:@4\\7&>D-.+5@64B:-!86\\99L^[\\`+&\\:VO4IFKZ%L1'6*N@$1Z"R%=32\nMD8Q:Y@&%Z63`>4T0Y-BV8P^JM`%C'584;>,N*)_6"<U&`ZL'V'OB+,<G9]@V\nM-(I8M02!O1P)=3S0[7%-4L-$8&V\\!&`LJ$!A50?`JV52NM`#7@(2`R>J@FUW\nMS>DQ/C.I]9`:2Z/18.)4E<GJ#-5JE=V[/L9Z<P!G!#$*L2N0D$B6NB5YN&P6\nMK`45*BS+`);)J"LA[S4B`:TDY<CA-TFB>;QW6>T7\\"(8ZVG4ZRS,GV-N=@9!\nML^.Z'6SK/T,X/8TS'0D9$-^-_CT^[G8ST+VN&XSIS*[J`CB%E0Z`9+IWRS)@\nMER04$IISW-!ZD,"'T&E'T8(@^,#C(X_K==@U!AU$A$&(/B6(:5$94+@4O%7+\nMJM![`"QEH'.=EZQ46I<M4%T`O1R`"_7?]4,F(8W6139?<Q>E@;7HJ(12'O%U\nMQ->RO:N#K^-=';$UG*WA31UO++:=PZ4IWM/`BWW?IGXY0+<76%YA6`;0-;%3\nMYV?=N@S6F*Z$0MI)LUT]_M2;9KZ8Z##(OF(HB])=9W:T*181AWB+.(<XAW<.\nML:3B^:;60=-?()'WD9`LJ_/&9`!BLN/`*DPG4*,[63)@C%KR@9<L`TF+LP?W\nM37QAY]4<K:5H'8(*LT^%*NCTV&I9]5/GLZ\\\\B%?>65I>.;;\\[H4O$^^:`0"E\nM`L)<B2`.R)=*1(5>@F"8O(H(2X/D_!@^<A",48AC=%RCUXY2Z8_)YR-Z!L<1\nM4JQ%%FHT?O@*S3_ZAXN?>#GCTAW<NP(HA1*!OG)(7*B@=,C:G@"EFE`:I-0;\nM(+J.8I"R:$09E.JEW-='/Q&!#I&>C6A2YJ;>PKFLPUQ)Z.\\W+BDAI5@4X27E\nMV^5D<5*ZO?`%O?%%?7+W[Q=<>S[P&>]I76S`#P6@\\P7DH`B_(X+JOI-W`U[Z\nJO?Q\\]U7WHN.EO2!`\\BZ]_/^/7^GQOPN5OBO*VNH*`````$E%3D2N0F""\n`\nend\n
105990
 
6600    lamp_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```)G$E$051H@=V9:XQ=517'?VN?<^Z=QYUVIM.9:4N'M-0"\nM0I`4&D1Y1!2U)!@$!0E1H])(B,8/)"08_:`FQL08_6",Q1B#8/BB)J*!0)00\nM&@*T(91''[0\\6Q[M/#IS[]P[]Y['WGOYX9P[,T4T<SL7C*YDY<P].7/W_[_6\nM?ZV]SK[P/V[2C2^9VK41($+]9M1O4Y'S)`C688)(Q'B,.8D)CH@)]B'!2Q*%\nM33M39?3V-U:\\]HH(3.T:!Y$0;R]#_=>)^C\\5#)RQ/EA]9F!ZAL$8U%LTK>);\nMDZK)S(RZ9(^(W(L)'@1MK/G2O@^>P.2N<00%9`QO[Y12Y1O1QBN&REL_3S1Z\nM$=*S!O!@FV@VCT]J^-8D;NX5[/3SN.KA6+/&@R+F!U[]?B.&H2_N_6`(3.P:\nMQZ``6U#_RV#HG!U]%W]'2IL^BX2]BP]ZB]IY-&N@MH%F\\\\6U@:\\?(SN^&]<X\nM>A#X-LACJ#)T_9/O/X&I7>.`;L#[WT8;+KVF_XH?$ZXY%W)2^5?Z!)]4T606\nMM0WP*>HS\\%E^58^F5;+CC^-J1PZC?`WA:5%8_;G'.\\(3=@Y>>O'VA^'HA==4\nMKOP)P=#9IP)OGL"W)E`[#SA0+<AY0!'Q*!XI58@V7`G".:[^VL\\%;E8XUA%Z\nMP"P;_-UG%#BR&TW?V)?[+[EK"7C0M(:=.8";>Q6U<SGX]@HFY]=V$051).HC\nM&OLHIG_L8QASAXB$M4<^_?X00`V(CB+!M\\I;K^L)UVT'S4%J?!(WNQ]-3I)'\nM&BA`+GB;B`&,("9_1LH#A&LN0*+>6PC#[00=B:(#`@#>?=)4UF\\K;=X!/LL+\nM-:UAJX=RK8N"^-QI@P<1"L"<FI&"A.E;A^D;'1$3W)BM.H/Z8]=VE\\#4KG%$\nMU(!^)EQ[061Z1U`7H[:)J[V,9G66ZCP'GX.6!:""F-S;)*0MJ;"$Z5\\/8>FJ\nM4G-RK9I@V026G2]55F.B"X.AK:`67()/:_AX"E`419`BZK(`+O?B/H`*HGE:\nMBO]`59'R$!+U;,+&FT"FEXNK@QKPPQ*41TWO&M2U4!?C6Y.YE'"@GE,SH(5,\nM9(GN#1((!&;)_9RD!"$2A!5,L+&3.EC^DZH53-2/"="L!>IRZ:@K"KP=C[9V\nM6(B^&%G\\C$%\\D2\\MNJP!M`5")"8<S-/7;0(@"*(N06T+-$-=#.+SL4*ED%&1\nM5`D6"AA#04(`CXH@"*H"'@2+MS.($30P[6ATF8!($^]:FM8'U<Z#1N`MF"*,\nM(H@&>49<$U4+00!20N@#4P)C0`4*PG@%,C0]@;HY$.,0,]=!4#O)@)Q4GTUI\nM:WI]G@$+FH&7O&UJ@+<--#D&6H/0(*42IM0+#(`90H)^D!#Q&:H)ZNIH,H7/\nM9MM!FA>1M]^'#"BX;!9C#KC&VQ\\)[?FHE@";I]T;L%5<8S_01$H]2-`#&J!J\nM$=\\$9U%3`P1LBF8)FL6H3U@L?'D3X?7E!W697<B8%'HJ#OB'GSOJ?3P++LXW\nMLF+JM+//XY.9`HLNNG>H<ZBS:):B:8S:#'4.O%_B"JI/,#<WL3`7=HO`\\#<G\nM"YV;O_MX^J";/8RZ9&$W]HTW\\*V)',0"()='W=D<<):B:9)[EN;WK"V(.%!?\nM`_TC@VNTDQEY^?N`0-`[\\";>_L9.OV!]<RJ/?M;`U5\\'9_/6ZHMHV]S)EH*/\nM"^GD)+`9N"Q_WON_H/X)4/HOOK?[!$9VOH[/$L#<Z^.9O]J)/6C:R&?^N(IZ\nMC]H"?#OJ-D/;>D_?Y=F23#A[`/4_18*D?]L]RP8/';X/`!"5:JB_R\\V]>:;T\nM'MHNI1[4)HB4(;!@#8AA00=:2&IA,`)44760U\\9QO+]33'!0;=HQG([?R*;O\nM.Q<Q$7AWK90'_B#ERFI(D*BTZ&$$880$$1*$$`2(:8^@.2E5#\\XYU-\\9!N87\nMUBG]%__^_2<`</*^\\Q'O(PW#7TL0WBJE,A+FX`DC)(R0,(1\\O@%C3B6`HGFQ\nM[P9N0#A9N>3^TX'2X?M`8<-?.8`:D^']W>K<Y"EZMVFN[07/->^7Z+_X.U6;\nMW:U9>E*M/2WP<#HUT#9UJ/I]HOJP"E\\M;B*JJ&JN?>>*<2*?/A?J0@QXOP_\\\nM(XBPZO('/G@"+HTQ8=FJVC]A]2:@)^=0@/<.3``NR&>@=@%+@(3]:%9_`.1D\nM!X/G>]II20A@=.<;[5:YERQ[^139I.F[VF:\\<!4S`-[,:-QX5),FJZY^Z+]#\nM`,@WKU9S4EVVY[UTKUF";X-/8M0JTK,>'S<.^^;,8<TZ;YM=)3!RVS&(2HKW\nM>[%V<9=-D_?8O%I(N!H)!]%6]86AF_;73J?OO]M.OXA/M9=`&SA74>_!!*@S\nMB,D+6(V`*N'8.*C@6]4#,_=O0^3TNT_;ND7@.%`%*JCFTO*"BEWR>AD0K#X;\nMWYS,?&ON#4R)D5M?6?'"*ZL!H)B?J\\#LDL^+;=3F0UMIP^64-GX"C6LM;=6G\nMZ(+^H2L9$(`Z<$Q,>`$FRN\\9@Y@RIK*.:.,5])Y["[Y^%#?UW*2B[T@G0_]_\nML!43$+',)JN2GB"]Q_O2E96^\\D#0,XCI&\\'TC1)4-B!AB>9SO^+MEYZD/O/.\nM/=N_6STV?7>E&_B[\\Q/3SMMN)[8R>M9:\\]B'1YKG#>H)RKZ&J"7-'!,UQUMS\nM98Y4A[+]QYI?,*)_V_O4[FXLW9TBGDG[R6RF[V0C*FZ8^>H$U>D3..=P:JBL\nM&F3\\G#,YH][@N:,/+QZ]=,&Z0D!$B[-:)0Q@5:67LADA=9YF,V5H<)`-8R,<\nM36)4\\T.Y;EE70J%>4>_ST\\_V^WPQNGGO:;9:>.^[L=2_V(HS<,?W?P90&AX>\nMVGEB<GH<\\FFT?2B!0%_OXF]GVIY6NV0KSL!KK[[*RT<.]^Y_\\<4KXC@>$!&"\nM("`,`XPQ1%%$7U].((HB1D9'>P<'RERVXY85@P=8_D'\\O[%F[+CZNIN2YY]]\nM]MF1D=$=@ZOZUXA/\\Q,+P*LP,#"`B)!8@N&1==OZ5@W/G[5I\\[ZSS[^(YY]Y\nM8D7KKUA"QU[9Q\\L'7V3MV/KI(`@28PR9]Z1IBG7Y&:B(X+URZ-`A/S<?^TV;\nMSY(P#"B72BM=OCM=*$T3FLWF?*/1LS^S:\\]?MV$3WB;4YNK,S-9X[>C;'#]Q\nM@HF)B4/U1N/FP37K#DZ>.,Q#?_[=BM?N2D,;&]_"YBWGDB3QF;V]_3]:O7KP\nMAKZ^_@&O2AS'U.?FLOI<=4^:QM\\K1?V[DZS.2\\\\]W8VENT.@;1^_ZGH:C7KO\nME@]MO71L_;K+*I6!456?S,[,///66V\\]NF7+UND]>Y_BV2=6]A;V?V7_!*^9\n2MUB`]2>Z`````$E%3D2N0F""\n`\nend\n
105991
 
6601    money_bag_write_48              begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```.($E$051H@>V9>92>57W'/W=YGN?=9T\\FF2R3R48R0$(V\nM4I9`1`H&@XCB`E21:IH>+*)"%7HJ%3U:1#G'RK%6K59!:ZM44((2-`H$$B`D\nM@4#V9)),DEDRD]G>[5GNO?TC@>/2:#)$_:-^S[GG_>-9[O?S_G[WWN?^+OQ9\nM?];_;XG3]:*??K;`91__`3_[PG7*"SRIE+)]@YVFD&_BDK\\[<KJZ^2V];H`?\nM?B(@K(0B6\\A/]WW_2C_E+_*#(.\\%_I`?^.L\\WU^KM=II;3("@EE7;SP=OE_3\nMZP+X[X^!,:2"E'>#GTK=&J12;4$Z)8)4@)\\*\\(/`>9XWH#R]36OU)/`+:^Q+\nM45@]HI2VTY:O_],!W/\\1,(9L.J4^4=/4>K.244JIA%0Z32J=XE4(+_#Q/$V4\nM@,"5I7![DBA^.@JCG\\51]%202?>6AT>8>]TKH_(A1_/05V^"H1(^\\+%\\TZP/\nM-[:>GY)*H91$:X72&NU[>(%/D`KH'70\\\\D0_#_^R+_/RGO)9!KE2*O$=A+CY\nM:%>W%&+TB:!/Y>8[W@KE$M[1HIB3#=P-?K;IO6/:+O1,M0=G0J3G(:1$*HE2\nM"JTUQ0KLZ@R9-+&&,?7^2"[E=GG:;C(N>4I*\\;/F*:UVN*_O#PMPPT70VXM,\nMO,+\\<6V%E80]RQUQDTU"AKI?0HD(G`-`"($0`HZW:F19>'9#<7QS_ON^=O<[\nM$[UH;#2H58T5,QX:M?&3!KA^*3RY#G'9I=F5DV8N_J?&AH:F_OWKL.4#1-5A\nM^@\\\\2R:?)TAII+`(#-9";`3*0%.-+N<+\\N-^-O75I%R)O9D/OF[3IP2`@_;9\nM2&-LW]#1[F^8<D]*F*162F^B(YIFK1UOXZI.5(;M!YIYL7LNN\\54HO%C"%KS\nMC)U@NXR7?53LM_%_7/"6TVH>1C$+_>-R.'@(,6<NJ7Q6C,^EQ1*A4RLW'UZR\nM:.W.*WAV9SWAA#J858`S&J&]I<28S'*L_047>Z<=X)0&,<"G?@R`8R.5[]TF\nM]WST_G?M.7/BX:T-TY8_TME5;DS%SS'9'F1,SR$RY.CVK^J,*ZT=B1'L.NWV\nM3\\-*'`0K",-L,/N,^.ZT>>KFR8W;Q+BZB+$U4)>%=%J6\\QGQ0\\]7]WJ>WF02\nMXZZZ*SP=WH'3`'#3,I"2?*DB/U_(NA4M#8Y<5F*5`BD8D[)HK9!*'51:_8M2\nMZNO.N0%P++MC^$\\+<.>[P`G2SG)7/AO<4IN)=:`=+U2R/!Y*M(`538ZI>8M4\nM"B%5(I5Z7"IYITA[S]MJPAL_W/.Z`-1H'[SWKP4I7WB^Y+:Q8\\?>-F[<>-^%\nM_00:A)2LBR2[O0HF2B.%QT"B2=`RT&IZRE=_J84:]'Q_ZXU7%,PW5@V-&F!4\nM$;CG1BC%B+QF14U#\\^>GM%^2Z^]X@LK(00Z:%,]6?9Y/'-VY$IZ6!%(CE2`O\nM%!.MSWE>BBM:@E+6E_=))3_K'$.+;AS=$#_E;Z'/W0!*0$;RYFQ-TUTS%KP]\nM)S'T#_?R:#''?2.*]9%EBJ>8G>1)LI:TT4R.4\\2>8T--D<V106F=59[^J-3Z\nMBU[@C]WTG?91`9Q2!#[S'M`"C.6<7+[PG^WG73NS86P;.Y_])O=W'.`Q8IJ=\nMSWOJ?!;4P;:RYAX[@O'@%AJ94J-Y<=@R.>MQ44L`4B"$=%**'T@I;W;.=9_Y\nMCLVG!'"*$1"$"6.U[_]SVYQE,\\=./H?RP#[Z!PZRTTAB+!>F?,YO,.12@KGU\nMDL4FQW!-S`8BIM?ZO&=&EHLGI5&^QO-]/-\\3VM/72*WN\\0*_;L?#B_XP`)^Z\nM#L+(>5)P:\\O4<R^=//L2K`D9ZMU&UA69XPM2:%ZP,6L&/`Z4-48HEF12-(5I\nMMF1#=A4A"#Q\\W\\/S/+3GX?G>,1#/NU9I=8?V/'_/JO-.&N"D5N([WWW\\*Q-W\nM9:%APHJ9"ZX62BHJQ4%*_;OQE>.*^@AO),W/;<R7DQ*U(XK&BB;K/%*^1S36\nM\\?"^*L-.,J40,*G6HY#R$%+@CNT')(Z5P";GW'?W/W8ADR][BGLGU!/&-KWX\nM@OG7CQ_:/]WKWO.C*8O'K;U[U6$^WG62T^C%9PD2XR9XGKJO??$U4YI;YY"$\nM(Q3[=W-T_S-(Y<CXBO:"8+:?HF!]A)14%%0\\A](*5:<9;!)L22PO1(9M`PF5\nMDJ,IXU/(!$BED$KZ0HB94LG50LJ!K\\^=Q8_#RVO.G1W_[;Q,[NZ6SE<N\\DR8\nMOFO#R$,ST[@'ATX"X/9KX-/_!4MF\\Y&F\\=.N/?O"Z\\$93%QB\\-`&2OW;T4HA\nMM<+S%..RDGFU'A?5I+FDD.6R0HZS78;M98O-:29U*,:G/7K2@JV^X^6^B$PD\nMF%*?1BF%D'*,$")J6;KF\\=6[&MKBB4N_NJEYSHH]V[>DJIW[AB@F=TXLL#/>\nM!]]W)Y5"@MNO<;.$%.^==,:%!*D\\4;F/)"I3'CJ$`(04O[*1D4@I"7R![TL\\\nM7]%4T$P[D+`M(VBN\\?C0U";Z0L?3_14VUPO^)X[)]U0Y=U*>.#%88][Q\\"\\N\nM6CWKO-3-;:Q^\\[:MK:S;<`&/9<X*ZR]>,J'MY2'_<'TE8OW*WSV(;WTKY-(2\nM:WEG.E?7.JYU'B8),4E($HT0E?LYEKZO`LC70%[=E3DA2/F*=M\\CL)I#64<Q\nM@3-;<JR8T\\R5+H7?D.:)D9#(2CQ/8Z5LV>17OQ:*^/+A<A=+)SENO*8ZD#XC\nMO7Z&JG]?%`_4ZTH5.(E9Z.B(:7*.Y;6-D\\D4&DGB"B:)B*LCF*CT:X:%`"E`\nM2EX#$$(@I&!ZWB<]#%&CIF,H0DA)*M#,JL^2#@6E0L!P:/&U9D-U0#UX9-_D\nM9[9OUYW[JZ2&:LWZESK69/K:;777X<]?^Y4/=>][Y5A]Z7>FD$.`HQWA9M0V\nMM2*$P,2O1J"(-3'J-];"_45!.A"TUAV#$0B<@_$YCYJC$<46C[U],7'LV-I3\nM9%5OB?RBL>A7!BAD?,)8\\KTMC;Q<ZJ`^J#)G[#3[RZU;UC[YDPN':@;M&KOU\nM6S_\\S)NV$";?_OT`QR`X`T$NG:O#)C$F";%)B$FB8U>/2PCHJ4K^K3\\FU#%7\nM5W(L;-(TYAW:0<Z7U%>AX@M>+%>Y=V,WW6,"<G-K$;L&>&LA34U:\\N_K9K(^\nM7LZ976NI'MA@7Y@4/K_GT"7;7+7AH<K6GSR^L>%B&Q^Y_;5^?R>``)RC\\3@(\nM21(>:W&(LQ8GY/%JA`/GZ*Y`GS#LJRNSFPHSNK-,ZTM3ZWL(I>B4#N5!94Z:\nM'15)MNK(;>QG>4L="R9G>6)K(Y_NNY*BJ>?\\\\GRZ.LP3O?6S=K1*?>!#+US^\nMV"UM>Z'C]E_S>$*`FY8=(W!0L!9*0T=(HBHF#DF2*@Z'E#XN*>.<PSI'>XWA\nM[S,!SY4"-NN8WG1,CV])>3YI[9$-?`IQ@AF$>0<$ETRJ8=;L/#4YS:[.@'_8\nM]69Z=!-OZ.WG[)H#7/6V%W_^Q=WSOU0WW.G;1[N@X[>+Q"<$$!+N>?`L;GG+\nMECH%]':^PN3I"\\%%F#C$68<.\\L3Q`,XYG'-(9VG+6*;7>%SM4@P8Q8B3X!0I\nM-+M[#6OR(2H2G%-?PSGCTUAAZ.^7?&KS&W@^=29S#_8S(^GBC.9'N&3!(=ZX\nMZ*[AJ6]Z@J=7_]\\^3S@+.0<KW_22=HXFAV#@R'[V;W^*)*J2Q!%)$J%3M8#"\nM68<]WA)KL=:2\\RQ3"["P2?$78SP6-_NT-WC4;(]I[X+&M*`:Q825F*]LG,^#\nMP5):#@^RP`Y1:QYF2O->DL0UI].:G3\\Z]T0V3QP!:P'(6D>S<V",8=_VIW"F\nM3'U3"RX.$2I`^GFL&<99BW7VV*^U&&-)C(%$XH3$Q8+I-8H[LC4TYGV"0)%$\nM(3_=,9LOVZOQ^JJ<%Q;)E!^GI?E9K%7$L5Q0Z1^H%XBC)_)YP@@8*[!.C+&6\nM%NO`(HBCD(.[UM.Y8RTC`X>)HPK2R^)0V./&K;588['68(S%)`:3))@DP<-0\nMGP9K8HHC@VSNJ.5SP^]FJ))F_I$!ZDH;:$P]BN^%:.$P<3P_B9,/EDO%8.,#\nMLT\\^`M<O!4\\+*I&[0,IC$:B$D!C0RKKA@<,B*O6020<$GD0+A\\5B$XN1%BD-\nMU@C,KZS,"(&UCF*Q2+$X1"EJX`NE=[(GW\\:$+9V<6;./V;7?9\\K8`0)M26E)\nM&"K/67NM0#S@K-U["BDD&"RYC%8L(6'(&%2<,)Q8GDQY/.UK<:DQ]KRP6A[C\nMC)"!!N&!-`9K).973`LARD*(/<ZY3<52L;\\X,NA*)=GXW>I-;WFF;4E-=L-A\nM%JJ!J,%\\MV-2X?DM2=D]5TW,Y*B2F1($06<FD_U.?4/]OG*I=/(1`)#25:P5\nMMY6K?"&,\\8%!+=W!8H4HG^:;SHFIUHF%UC+7.-J,I4Y9*ZTQ6"E&K)&'A+3;\nMK30;;<(K0JDCWUY]OEWUTX<86O;(W[@WM%_C[>SGW'C8FG+7O]IH_=W:A'V9\nM&N+]'8B#^T=T3_^(F=C49S_XC?TGLOGZZD+WO1^21)#+.\\_7^+Y&:*U16L52\nMBLB!N^J3U>-WGP_O_QJ\\N&DIR^<]("MV_.)]W;3$W:O6_/S)]V5SA2,'.N\\Y\nM90^G[93R]TG/>X`@++>5EBWZGFK(+URPIYL94>_6#>LWO*NN?LR69]9]"SCU\nM`\\!3+NZ.1E>^_:^P<UH9%^^Y;G.Z9^'1;=U,3JK]>_?NOOT#'[AYRT=NO1S8\nM-*IW_U$`<KD"^L`/O/R8<?,NC?H9J#6'UJP^\\,D=VW:O>OZ%IQFM>1CE(=^I\nMJAI&C(R4ZHHC(ZU)'*[6\\LC;=NS^TM??N*S71-'K.V8:=6WT5'2DMXL#'3OK\nMXBCN$E+?G<G5[GIN[2_9NZOKC]']:9/B#_"'_2\\>QU$DQZ.LN@````!)14Y$\n$KD)@@E+?\n`\nend\n
105992
 
6602    notepad_zoom_48         begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```+H4E$051H@=69:8Q=UUW`?^?<Y:WSWNS.>!V[GMB.8^S$\nM%"=-TK2)"!"$FIB`:''5@@1\\X`N;J@JJ2*B!1*)&0J0;17PH$:6`*"TI"+<)\nMP@EI4H?8\\=B9)I/8$X^7\\<R;-S-OO_>>A0_WOIGQ]L8KJ$<Z.N?YCL_Y__[[\nM?0]^S(>X92?O_G.8/B+I&7(H+RBLM9SYZDV_YN8#//04G_^=G^/8R>FM]XX,\nM_:XR9OC8Y.P+WQN=_%(AX]?&]N^[J=?==(!M?_`<8Z=F,\\_LN_^Y[JR_\\\\1T\nMY4@I\\#XRV?(_6UU8^.O[FJ]R^`<O\\-C>CQ<\\+[6F4JD4@S",PC`JGY\\Z=V[G\nMKMVM;W[C.5YZ\\;O_/P`[/O-W.%(,/7K7QH-G%\\+G7BFE]S^X?>A[?5VIT>KY\nM\\[]YGSNQRO6\\7ZU6ZWM+I?+(0J6:CI0R8*O6F*/-9O,;I=+,=W*Y?/5OOOQG\nM_X<`CSQ-[\\AM5.9J/<.#Q5\\97C_\\U(;A#3/;-Q1^V)N5C[T^-ODC2E-?>GBU\nMV#<Z-OZ1H^,3C5JHRU90-TJ%1$$ZYXJAWD(^(^"?Y^;*G\\UDLN^_/_$>+[_X\nM_!6O=6Z&[/E?^PJA0!8S_D,/;%OSEY_XT.V_%2F5-Y+^P:*W\\^14)35Q9F'-\nM@T/R%UX[='C36S.-Z>UW[9P>V;JYTMO?5S*N-]&$L85F<[11K45IWWO$<[TM\nM4U-GOY_)Y!KOOGWTBG=WM,#3GQ(`>6'MXY[G;O-3ONLZ`D<89#)=J=&X]IOF\nMMWOZ1Q[]V,-WKAU45O+FF2JCYP.4F\\7WTSPQK#ES^"`3]/#$S]X?BN9,LU(Z\nMV3IW]JU*JUZJ^"*,/*&5P,CI&6_;7*78/3,S^[EO_?U?_>E/WOLP__/JBY>5\nMT>T$(`488_<6^]=^;?V6!WRC&D2-:718Q48UC*IAHRJ'HWO(K;V?M8/]'!BO\nM,=401#*-W]5-UG>YO5M0:+[#?Y0B?GW?`^0SOE^EQZ\\VWBCFQ/E5JWI"TB+$\nM$Q$"&,H''#]5)(R*^W[J@9__VVR^.'DE&3L"N*Y$*SVR8>N#?K[8S\\G1[Y+N\nMWXI,#2`Q>,)0"ER.U/;BI=?STCF!]+K(=OETIURROB3M2[;TA)QZXS1#PQL9\nM*&:8;X8(/TLS-TQ6E4EG+6D9X=LZ3NT=<HYA77^#0-^VJ:NK:X=TG.L#\\!R!\nM1.#Y*>KED^#E6?O37Z2OIQ='@",%+TU44*_/T=6586W>IR_GT9MUZ,DX%#,.\nM.5^2:\\WR_'R-@=LWHXW!D0($%`<WX?>NI:^_%X1#JW(6Y_B3Y+V`@8*A'!92\nMF71J=;ZK>&4E=P)PI`%KP88(H7$<B>_[;!S(XR?_<[X5\\<B&"KX3XKLA*0<\\\nM#5X3;`B!A)2(,$;3;`6T@A"E%!9+6C?IR?JL[\\M2#P6G%R16!60+:3).@>YB\nMP3J.$UAKKA<@7H752,SBY^5CQ^H\\6_M]K+58+-8"R_=`::Y*;U>&B9D90KT5\nMSW%P)+A=7632/MH8E!%H"WA9TMT?P)3[49K:;'GNI)25ZP<0`%8AK,)Q+DU;\nMKNOBNAV/03H>6S:M9_2_CO#>U)V,K.X%!$9*-()6I`DB0:`,/7UW$'H#S+5R\nMO'=B8FS\\W7?'AFY;=>6S.UWL.FT(';M0(KWM*.ZE(Y=-LWW;"%L&<QSZ[U<X\nM5:IQOAHP6PNH!XI:*Z(>1KA^!M)K&#T1<>)D"3G[GS^\\[Y>>G6W4KVR!C@".\nM)-&Z0J`7@^]:AQ""S1O7\\=`#>^A7\\[Q\\X`!OO7N*N7J+:BNBVE(TFP&EJ6E>\nM>;/"X;$Z?OD[_/*.5Z+',I]@_/BA*YY]E3&@XCCHB-MYI%,^>W;O`.#@RZ\\Q\nM\\>H+S'1U4R@62'LN0;U&8[Y,?6&.<V<GV;OC?7J+`3MSYSJ>>W4`:$!?-HBO\nM9>2R&3Y\\[VZ&UPUQ]/C;G#CQ/G/S"T0UA>NDZ.[-LRE]@/[N>R@ULASYP?<'\nMG_K:V<RC@N:_7<%O.U=B&?N[L#'`=7K0A1>Z#IN&US&\\?BVMH$481F`M)^8$\nMA\\?'6#?Q!1[.#-+C/,KK7__1$X_O&1S[_&M'GOEP-J4/-H)+9>QTF2,$CA0(\nM%)(;<Z%++I:";"9#=[%`=W>1=":-L8"C*80OX_[KL]P9S:3NVK;Y]S]SS^['\nMO_W%_8Q<1GL=19(R[H>P.H:X=2^@6$M<!Z1`]DU3SAXA,WV2]6>/]=RQ:=U3\nMO_<G7]CU\\0_NNE3&3H=*"8Y(TBAFF06N-9%>'8"Q%N%8W"SD?D92V2ATW]EQ\nM^X&@M.7N'7<\\<^CXVZL^.31P]0".B$TMDD(F17S)K7B5MMC8A21(%U*]%OL0\nM!Q<B/;YF\\BA;"NXC'[IG]Q_^^[F9U$?3_M4!++F0`C1"$%]RBRR@+>#$`$)"\nMSP[>.-$43T;U2G7#Z:-B^]I5O_'IW3_QJ1>;`?<F_MP10(CX((AC0`C0YE:(\nM'RO&6`L2A!M#2`>Q]Y3]QU.A>-:;/F4VSYW(;!KH?O(7"YF/[AHH\\$&YD@6(\nM+=`N9`*PUMYT`F,MD;9)$"<62``._X4PQYKL/Q>:Y\\/)=[#U\\IJ-_85/?OG\\\nM@NNO!"!$/.,LI&'1A6[.L!8B;0F516F#,78)P(GG;7M@5<:;'6W)SYW/]A[:\nMF=7_M%Y7]]N/#2LI5BAD0H+4Q#&06,#<)`.TM:ZT11M+I%D,8N&`-&"(]Z/D\nMF4L[QWJFIA[/-]3\\_5GJXML3P$H`+%D`JP'0]L;$MX`VL>"1MBAE$@`3GRT2\nM[1L0-DXD3X^7`>Q7X,S%YZT($*M=`0H$W(C\\QEJ4`:7,HO9CWX]78\\"Z20LC\nMDP2R0O7O#"!B+6`5UD9`K+WK8;A`ZSK6N-*6R-C%9[I]L"2V1#L&KQ<@I@"C\nM0Z1I`8F?7@.!!70B>"R\\60(QADB3N)!=C*]V^K:"%6MF9P`12V!4`TNT6.ZO\nM=AAK49HE;2<`L?!+S[2)/VN3O$=?0Z'O#)#D?*,"K-L6ZNH.;FM574;S2P!)\nM#)BE&#"&V`S)/3?L0G;9Q@)FA1BPEF7"&2+5%K8=N/'SY5#:D,1`$L@V2186\nM.GRCLC)`VUO:Q3<N]U?^>V/BH%P>K$N"Q[E>&7/A<[,,P(#1L=#M>4,6,,N$\nM;VOE<D'<#E1E;*SQ"_Q\\F2N9-M32LS9`J`S-1@.=,['6VQ`W`M`6>CG$Q978\nMV,3?U86I<<GG200U%VA=:5AH*II!A%:*V=D:06T!Y6FL7F:)&XJ!2[0?!UQ[\nM7#:W7^)"%VI^^7ZJ7"/E:&:K`=5(4JO5"+.JW;G$$"LDC8YU3MLX*[1]OSUM\nM`A*IN!$+E2%,W"9,_FWQF;YT'R5[&S7I[^LE]'L8GSP/TL5STABUU+U8=0,6\nM6*[]=E!I8VF$!F-$G&4N]NF+TJ2Z6/O)YU8KY%RYQOC"#$>/C9$O%-F^]7:<\nM>8E1+$+<4"MQJ?8%U4!RX.TF)%:(K12G/VV33)*LVMBE?9(B(Z5IU&LLS)68\nMKU29*4_0/S#(GKMWL3XUB2P+3)2XCV;%'\\&N#L"`D2##$KFS7Z=E,LFWSW%-\nM,+37>-_.7NT@$A9DVYQ!B*W7<&LUO/DY-N<+;.K=3/_<FP@]@XT:L04T6"T0\nM*P3!BEG(&#`"M)5XP6G6G?YCI)2XCL!U)=(12$\\B7(%PEZV.1#@BEES8N,$G\nM[I&M-3&\\C<NN,0:C+09#9K7%*('5`J-!F*2?N1X`%5?%LC;@&`%.%B^3)Y7.\nMD4KG\\=-YO'0>-YW#3>=Q4GD</X=,Y7'\\/-++(P184XNG7K[6,;J&5?%O;2:J\nM8:(Z.JRAPR966ZQA]B;4`?LM:\\7=VM@1%39M8`),,(=J.(2NQ',DCB>1GD2Z\nM$NDZB44DTI'QRXDP($V\\"AU;@CC1VR0[6&.P.IY&6V$-$QC^8:7&;L6^[U_^\nMR,$8ZSL.:=>QN-+B.?%O!ZX$+_D*7CI+[[++WVE%\\DPX<8LLEO7Z%]R^F.D$\nHU@K0!#(E@FC>LO73*S1$/\\[C?P'5WY."ZM%]GP````!)14Y$KD)@@MR^\n`\nend\n
105993
 
6603    order_add_48            begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```0Y$E$051H@=6:>ZQG577'/WN?U^]YW_-B9F#$\\%*!`D*1\nM%K%6;,4&J\\8^-6IIHFW3I&E]1FNU5A-:K8U-&H--J);:VE";4E"*%<NC(#C5\nMX@#S8(;7S+TS]\\Z]O]_]/<]C[[5W_SCGWKD#A`1F_NFY.3GKG'W.^:WO7FM]\nMUUK[7/A_OJF7^L"7OK>$@NW.^UW>XYT'Y\\%[3RE['.`=Z^?>OX`,>%<^(R(,\nMAWT&_56&_1ZCP6IOV.\\?;,UNRN^[\\5TOJD_X<A`K>)=2ZG/.>^<!\\'C`K]WA\nM?253C;Z`[$_(2FN2I(ZI&4QA*-+1J%ZO_=>Q9Y[\\V^"2W[RW.3%3]._YZ],#\nM0&O`$R6!:NR:28@"$`?B/<YYQ(-S;)`]XCWB*NMXD&KFW4G/112S,>FX07^U\nMUCI\\=/%7DT;[%ZTU7U]>7+AQ\\UL^/K]TSU=AO'R*`)3"`[50<?FN!I.-$'$>\nMZSPBY;$P@A6/N%+Q$W)UGV/]7!S5-8^X&"L-LGR"AUW&CM;VR7J]\\?N'XN3\\\nME>-'?V?[FW[OT/QM?PZDIP*@-+W6"JW@H0>?Y/#A51P:*R&HF*M^]@R:$Q%=\nMXTFMQTBY6W$8\\13B,=9CY<18(1O."Z%GA$NWUMBZZ0J:K?:U3Q[<]Y>][LK[\nM+WCWGW7VWO)'IP&`*MWC[O_<S^Q<FV>>SOC>O2L<&P=\\\\VNSG#N3<-0*G<R1\nM6T]6.#+KR(PG,X[<.%+CR<V):]F:7!A<7W%MW;`I]O":<VBUVV]=6CSV[EHM\nM^?+.3]W!77_ZUI<+0*T#4("GP='%D.\\\\..;Q8<ST>=.$K8@H4"21)A%`.;S7\nM9:#[4@9PWH'7>*IQ#R6'1:236_CJ`\\\\R80><NV66M@Z#<-NVWXCKK5NV>M>Y\nMZ^5:(-`E#6JE4$JQT(VX];Y%.O4$+IY`G3=#V(J)M*(6:FJQ1Z$!!TI7;]D@\nMJS6Y.JIRW#=;C'3,IKKET@MF^=^GEEE:Z)X=9=E.H+.FS\\MR(0"E2D;J33;H\nM[)B"LZ=AQP2</4G87+.`HN9*Y3RZ3`YL`%%90K%FE6J\\XE?G8^JM!K4D8F)J\nMFOI0):;(ZFI#^GI9+J3PI0LIQ;O?OHM+?\\ZB)Q-\\.Z'1BMC>5,0AG%F'39$N\nM@]26NZD"V=@JF-=EA[%^0Y`["O$T0TT<:J(PH-5JXUP#3@W`6A`KE((W7U#C\nMC6*K62OPOD!23\\][0A0-[Q$!ZUQ%IR7WBR[S@\\4C"B3P2%@RT5K>$.=1.B`,\nM0@*M"+0F"/1)^KST3*P`2@IUXGAB99&BUL0*U>PY"B/T.UVB]G1%DS#J][`$\nMN+"V/OMY?Q43)%BBTCI6L*-5\\FB"PD)N'1>T+6^^:!=!Y;+/W5YZ$"N%5Z4%\nMP$,0$K4G0$"L1UF'SRTF2E&U%L9"+IXTR+&$N+!![ATYGI0QA@:%BLEQ&"\\8\nM.R;5#0KQC*UCIQT1:D6@5?6;IPA`:_">]1C0Z9BPLTP^&##9;.,`:X58ADSZ\nM&EZ#TS"H901!0*VA,;9TD0X&H@R"*LE985PWU"<,UBF,==2=)PP40:#6">34\nM`%1Y0*FR`FV$$1.-.FXT9%.[@5(*:X7$I&R::0&@4'2U)8I"FJTVXAS.PY+.\nM2>H-PB@IL["UK"0%$],3B%.(\\PQZKO1_50%X#HA3*B5`X;W'>T_7.I:&!NL@\nM+RS=3D$BZ7JI,%P=854`D:.PCD(@7>UC0X-5<7G-"&;0IX@#"BFS\\R53!;^R\nM0Q/H$\\1QZ@!4R>9*@3A'411@+:$8M`.<D'A+`X-5(!H(I&3Y4+#*8P,8Q0X?\nM.9RNJ#7RI,;CZR7HW'@F$P@#15C57J<.0*LR!BI&B*.(9K/)EM:8+7.3**T0\nM$98CR]:MLP`HI>ET0Z(PI-UNX[U'*\\72\\9!VJT52JV&=QQC+XE+$S.QFQ(.(\nM9VEYF4!368#3Z$+55.1YSF`P8+$_9"5(<!Z,$;HKJSQ5A!6?PZ"W"CHD2,:(\nM.,3#H+N"3@80)%AQ%%88KW;038,1**SCS+KA%[:=4;+0"T3Q*56C"HCCF%:S\nMB:Z-&$=UK$`NAKZ*R7U$X2`7Q=!&6!_@?4AARBR;C@)<KC%*D1E=YH*^(D\\5\nMA86T4(2;(3ZM+K2!A:AB("\\*FMZR,W+H1".)IE,$S,W%9:\\,K-8B@B"DV:J5\nM52B*[DI*N]TF3I(R4UM'9\\4P,SN-^+(1RH;]*@NKTQS$U8M$+-884F/H9`4`\nMQ@JKXQP99F43#_1&.5Y98A.4-(IBV,NIVY@@*MM**\\)J)^>HS1#G*:PPI0WG\nMAWH]!DY?$"M5N5!"J]W&#<>LQ`V,*#)KZ<J(I3Q>+^*&_0"C0EQ:QL4@S5AX\nM^B#SBT^PTITG3?N(<P2$Q#/GTYR^@+!Q%M>=&7!MI`FT/ETNI$\\$L5(88QD.\nMQT1YP8SD@,*$0C<6IANV:E*@KSTZ`*?'_/O]MW/K/;<R&!QAV]04.S9OIS%;\nM1[S0'78Y?/@!GMD[(J[MX,JKWTYNSB(*7\\2%_(]8J\\$G@$GO-JSK5$<OY3$Z\nMTI)'-G]ORJLS($N(_"+U8(*)L,-<5)878H4DZ3!9GT1T$U#$MLY*_Q@WW?XW\nM/+#G`:Y[W5MXV^L_PYE;S\\0Z2W_<IY?VZ(U[+/6.<W#^`#_8]R`WW_<7S`\\?\nMX8U7?)@PV%%U;,^U@*]Z#<5[\\'R8LJ)E?7=4[2!D&O_*Y7=.6S6%680@S>E9\nMAQ9'YPE=@?8X*^S9]C&.3K\\7<9X#^Q[AEF]^C'-V[.#O_OCKG'_6^:P,5C@^\nM.(YQAD(*,I\\Q,`-2/V9FTRQ7MZ[AC#-V</?CW^>_G]S+.UY_(Z_<?A7&9B<#\nM<%+.M%),%X:SOGT_#$=5\\M`!0>#0>)32A(%"J57P/<)`H;5#`8$.T<JB%$Q/\nM-9FLC6CX`;.!<.C80?[QML_QNM=<PHV_>R-**PX=.\\0@'Z`"Q:[)7:3#E.ZP\nMR\\26"0X?>H:1C!CZ,>WI-I=?>#F[#_R0?[KO#\\+SME[3BFM->"VPNP(@MDPV\nM6L-H#/N>KG'M6VX@KD]Q=-^=;#WKU01QF\\6G'F)Z9I:H,47GV$&2P-*8F&'8\nM7\\$5*:UVA,T[U%O3V/P`NR8;!%MKW/2UO^+LV2D^_\\'/D]N<XX/CC,V8H1D2\nMJYAC"\\=X],>/<N^]]_+>C[P'0XY1.49E#%V/OENE/=OFJ?DG&@M['_\\@71YF\nM*_UU"]@-`$2@W8PY]Y)WDK2W(]T][#K_&L+F3NQHGDU;SJ(^>RZ()90.K;F=\nMX`W%T%"/RT8E"&/L&`YU,[[UT,T\\<O`1;O[DS1AG6%Q=9&1'C.V8L1W1".IX\nM/TF69ZRN]G`(-L@9N1[/#)[B</<PJ\\,>XS1'-4"AKO?*_QJSW,3/KUE`2@#>\nME[)6GB)=0BFPMJ!(EQ&O$9-ATN/(8I>T>X"(`7:PF]$P1X5;&15'$*>I3>Q$\nMG.9XO\\MM]]W%.][P=K;.;66AL\\#(CAC9$9E+R20E<`J/1ZQ@K<5KQW*QP('>\nM7KIY%Q=9ZLT(%8`.%$H1%=C?=@O^7YGF^`M:0"N'Y"L8!4X*)%_%28[->PP7\nM]R'Y/.D@0#>GP0VP5H-2:%2YWNE"O`M8?/81BO$2K[_D&HYVC]+/^HQD1.K&\nM%#ZC<!F)#TL6J1JDGEGAF6P_/BF8"!L4QI)GAC`,UFLA[[G(6/LZ%:O;3@#P\nMH%TI:^6QV0IXBUA#UGN"M/L866^%6MOCK,&Y,B%Y`6/+'P_4&NV&6`L//;Z;\nM'9LOHU:KT1EU,!@*7R!8O'*HP*-#0"`,0L(PA,`Q-=G"NR8BCJ*P9%G!8)16\nMRGM$7$+AKVI>DMRV[D+65<N%E0M)O@(N1VS&8.%N;-;!R2S.!X@KE;96H06L\nMV0A`X7U(9N#0\\2%;SMW*(!N0U!)>O>75B`@HS]I?%(8<.;"`QS,],\\5K)B[C\nMW,T7K#=*SGN\\P/SP6;[PP.>P=@EC!,G=>9VOC>*37,AKL%(N--FL0S$Z@LFZ\nM.)V72HO"6H78\\AEK%8&4L@K*@"J7T2.R`OH%G!''],8]YI(Y%IY<8/[P?/6A\nMPY??&I3"BJ7=;G/--=>P=_<!PB`\\,=M.R-.<G1=O8Z+98F78(2Y"\\LC.1-N"\nMY'DN)`*!@F)TA+3S*":/D.2$TB(*:\\%8A1&%KV0=:NSZUY<0*PKGH;`%_;1/\nM:Z+%T0-'N>DK-Y%E&<Z5&55IC1,ARS.2)&%J:HHHB/"`M98\\R\\##)[[X49(D\nM(HH"PC`@#+0*0O4<%E*E#,)H>0_%>!DCVTMEJQFW%1!C06P)P%K05F$]B%<X\nM'X*#1,/J:)5>VD/W-!=?<3$?W_6Q<BE4@_4%410QO^<8=]WY7>;GY_GHIS]$\nM;7/9U3EQ6'$H`L)9A=U3$`8!0:`)`CV4KC<GL]`:`&?)1RN(E+,K4B8[(V#E\nM!`@K$*P!$(5=JYM\\A/**377-T]U%^N,^2]D2^SI[49'#ZHRA[S!4'<[><C;7\nM7_9>:E&=.^_\\#V8OC-F_^;MD><&@G]*O]I5G>HSLD"`("'6(TNJP^:YD)0"I\nMZ+.B43Q84WT]V3#CUBJLG!P#OAH+1&%E[6->B'>:GWK%J_CAWB7V']F/K5F&\nM:D#*@%P/T#6AV8[9/#F'-`3G'-Y["IO3'7;)"\\,HR^CG*?TL)35CG/?4PP8C\nM"H_X_SGSS^=.9.+RN]::"U6@UMWFQ*Q+Y4ZF`K/F0E26<5[A"3'6<]6%/\\,W\nMGKR;.QZ^`SVEH>EIM&,F)NM,A@V<E)^E3M"C8(S0[Z<8:\\DR0Y%;C!&,%2)B\nMXJC-@CF^X`ON-\\NV7.M>=PE;*HW?<*V:V>?)&P)ZXY@()0#C.'O[.;SMZK<A\nMN6!R@[52-O3688Q0%!9CRIY!G&"*`F.%7G_,8)`R&F6D:4&6%3@#N]KG,$I'\nMY'G^;\\L_'.RWJ^X$`)$3.[Z:?2FI4S9:X+E*5_?9#?=YHC)'J(`/7/\\!SMM^\nM'A3@3;ET4A3EGN>&/+<`%(4A33.L$?K],;U>"6(P3#&9XZ*9GP8;LM!9."0C\nM_Y7M;YB1XS?U2P!RTJR6`(P%8S;XOZG<QBJL.3DVC*F`54<($8%CO8*H_DIN\nM^*5/T$ZFH`"3"WENR#)#FAJ&HS%3FR9Y[967\\OX/O`\\?P.KJF%Y_3+<W1!<U\nMWK3SEYG0,_QD_E&;^.DOON]//K)GN#\\[T0^LQ4!9O('6$2J(T4#@FNA0T+$0\nM,4$0QP1)GT@FB.HS*#4@(21NS5%+>B@=$29M1#3+"_N_'P[]PU=>>+VZ=/>M\nML_?LO^T=+O;3>60)@@*EX<G%I[AQ]Z>9:+2)IT*.[SM&9]RG%M2Y>/.5O'G7\nM]3QV[%&^]9._[\\TEYWWCAJL_<WNZNT_GGX=E'@&X^PME38/BD\\[Q6:-F:#2G\nM\\3[`4B.L&GE+0AA$>.<0'Z&#!+S#$:*".AI!Z0CG+$<>^P[6F#]4BB_=\\&.@\nM1\\`K^'6:?%:W]*[69)U6LT&]%A'5`FI)3".I,=?:Q+ESY_/:,ZYD4WTKW]EW\nM.]]^_+;#_=[@4_YH=`M-L?-?7CFY(Q-9![#B/0>U[\\BXV\\&M]<8;^^.J[%Z3\nMGWN^=K\\'[3U=`!X$KD"X@W_@K3SNE/O02&77A2J>G$JFV5;;PJ:).69:L\\PT\nM9O#BN6//'3QV=$]_<?78G3)R7QC=+[N35UF__.7!\\WMB)Z42"K[N'/_R/*5>\nM1%X[7Y>K58BJ4ABN_]+#)5NB^!$K_):(7-XQW>OZP_[ESQX_LJ.6Q+4X"D'Y\nMW#ISQ(K=C>';C/3#ND$Z>&C$X"&>M[WD_U8Y;=M%P!**RVA09S:HJ5H0*+37\nE&49ULA^8D=JLO'_(O^AK_@\\/0I2A$8X6F0````!)14Y$KD)@@C:H\n`\nend\n
105994
 
6604    order_clock_48          begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```1*TE$051H@=6:::P=9WG'?^\\[V]G//7?S=J_MV+$=)XXA\nMH10(M*R!A%")$E':)K2BM**HHJI`E4I5555;*M%6I8(O5=-6*O`%":D1%0V)\nMLI"DD,T8QXX3.W9LQ[%]?9=SSKUGF3DS[]8/,W<Q1$B)_:5'.IIGYIV9\\_R?\nMY?\\\\SZL#_\\\\_XHT^\\+5'%A"PS3JWTSF<=6`=..?(98<%G&7MW+G7D0%G\\V>,\nM,0P&/?J]90:]%8;]Y95!KW>Z-C&5/OG53_Y"??PW@UC`)X407['.60>`PP%N\nM]0[G"IEB]75DMRX+*8FB,JJD4)DB2X;#<KGTP\\NOGODW[Y9[GJ@VQK/>X]^X\nM-@"D!!Q!Y(G*SO&(P`-CP3B'M0[CP%HVR`[C',86WG%@"LO;*YX+R"9"DKA"\nM;[E4>VUN_E-1I7Z'UNJ;2_.7OCI]YY<O+CQ^'\\1+5PE`"!Q0\\@5OWUFA6?$Q\nMUJ&MPYC\\F"F#-@YC<\\77Y>(^R]JYL137',:&:%-AE#9XUHZ8J6UKELN5+[P2\nM1C>T%^<^O^U#?_3*Q>_]/9!<#8#<]5(*I(!GGCK#:Z\\M8Y%HXX,(N>T]6ZDV\nM`KK*D6B',OE7&XLRCLPXE'9HL[Z6F0WGF6%%&6[=7&+SU"]3K=5O/W/ZQ#^M\nM=-N?V7_OWW9>^O:7K@$`D8?'HP^?9&*RSJOG1CSR1)O+L<=W_G."O>,1<]K0\nM&5E2[1AEEI&VC)1CI"RILB3*D:KU:Z-5.5/8GN#VLF(J='!@#[5Z_:Z%^<OW\nMEDK1UV?_\\OL\\]-=WO5D`8@V``!P5YN9]'G@JYL5!2&M?"[\\6$'B"*)!$!A`6\nMYV2>Z"Z7`:RSX"2.8MU!SF$!27,3]_WX/`W=9^^F">K2]_PM6WX[+->^O=G9\nMSD-OU@.>S&E0"H$0@DO=@.\\^.4^G',%;&HA]X_BUD$`*2KZD%#H$$K`@9/&6\nM#;)8E8NCR-==M<90ADR5-;?NG^#(V246+G5W!:/1+-!9U>=-A1"`$#DCK30K\nM=&;&8%<+9AJPJXE?7?6`H&1SY1PR+PYL`%%X0K#JE6*]X%?K0LJU"J4HH#'6\nMHCP0D<I&9;&A?+VI$!*X/(2$X-Y?W\\FM[]?(9H2K1U1J`=NJ@M"'[668"F2>\nMI#K_JB*1E2Z2>4VV*.TV)+DE,XZJ+PE]2>![U&IUK*W`U0%836*!$/#A_24^\nM8'1AM0SG,DSB6'$.'T'%.8P!;6U!ISGW&YG7!XW#"#">P_@Y$ZW6#6,=0GKX\nMGH\\G!9Z4>)Z\\0I\\W7HD%0$ZAUEA.M>?)2E6TH;">)5.&7J=+4&\\5-`G#W@H:\nM#^N7UJR?]I917H0FR+VC#7JX3!HTR#2DVK*_KOGPP9UX1<C^[.>-)[$0.)%[\nM`!QX/D&]`0:,=@AM<:E&!0FB5$-I2(TC\\5(T/M:OD#I+BB,A1E$A$R$I%N4,\nM2L<DLD)F'+&VS.HAOA1X4A2_>94`I`3G6,L!F<3XG272?I]FM8X%M#:$9D#3\nME7`2K(1^:83G>90J$J7S$.F@(!B!5Q0Y;8C+BG)#H:U`:4O9.GQ/X'EBC4"N\nM#D!1!X3(.]"*']"HE+'#`5/U"D((M#9$*F%JO`:`0-"5FB#PJ=;J&&NQ#A9D\nM2E2NX`=17H6UIAUE-%H-C!48Z^BOV#S^10'@9T!<52L!`N<<SCFZVK(P4&@+\nM::;I=C(BDZRU"H/E(5IX$%@R;<D,),L]M*_0(LRO*8/J]\\A"C\\SDU?F6L8S?\nMF)%X<ITXKAZ`R-E<"##6DF49:(UO%-("UA`Y306%%F`DX)F<Y7V#%@[MP3"T\nMN,!B94&M@2-1#E?.0:?*T8S`]P1^T7M=/0`I\\APH&"$,`JK5*IMJ,9LFFP@I\nM,,:P%&@V;YX`0`A)I^L3^#[U>AWG'%((%A9]ZK4:4:F$M@ZE-/,+`>,3TQ@'\nMQC@6EI;P)(4'N(8A5)@B35/Z_3[SO0%M+\\(Z4,K0;2]S-O,+/H?^RC)('R^*\nM,<9B'/2[;634!R]"&TNF#?%R!UE5*`.9MFPO*SZR96O.0J^3Q5?5C0H@#$-J\nMU2JR-"0.RF@#J5'T1$CJ`C(+J1$,=(!V'L[Y9"JOLLG0PZ82)00C)?-:T!.D\nMB2#3D&0"?QK":QI"&UB((@?2+*/J-+.!1482$TDZF<?D9)C/RL!R*<#S?*JU\nM4MZ%(NBV$^KU.F$4Y95:6SIMQ?A$"^/R06@TZ!556%SC)"Y>9(Q&*T6B%)U1\nM!H#2AN4XQ0Q&^1`/K`Q3G-"$RBMH5-#K)I0R#S_0^7AI#)U.PH5LF(>BMK0\\\nMQ0V^7,N!:Y?$0A0A%%&KU[&#F'9801G!2&NZ9LA"&JXU<8.>AQ(^-O'(M$0;\nMD'%()3%$,D%:@]::4:QI=P?,CWSF$LG[-EL^%.1]T#4*(;F>Q$*@E&8PB`G2\nMC'&3`@+E&[JAH571Q9`"/>E`6**R9;D_9!!GU*H>0L<D<<PH3=#:X*3C.F^`\nM"CT6?<NT#-!*X?N_((3<859[\\`;0=';#ODYQ="8_!A=JYOGI1\\:<V`JCB,#-\nM4_8:-/P.DT'>7AAMB*(.S7(3(ZN`P%<1I2@D\\"/$*$:E?8X>.<G)4V>9Z_1(\nME`$$GG`T2@%;IEILG]W&R+9X],EG&=5VX'F5GS-H[@%7S!J"3^/X4_*.EK6O\nMI1@'821QNY?N;FDQAIH'+TE9T19I+)U3L@#ML-IP;,N?,=?Z790QJ'[*C%BA\nM&G@<.7*41W]TB%<&$C$Y2VO[/FJU"EHI#'!Y..#5Q8L\\?^80NZ8;[-M[/:7:\nM$J)U/:*Q-;?F1@#6Y)86@E:FV/$__PN#85$\\I(?G620.(22^)Q!B&=P*OB>0\nMTB(`3_I(H1$"6F-5FJ4A%=>G)3693HDJ/J44'GSP$1XZ?!H]>Y"/?/16/G!@\nMEO[\\:_1Z*R@GZ?<'-*][&V>7^IP\\=Y%3QP^Q]/1/>,N!?523N#0Z?_2ZF3T'\nMG_[4I_^`[WSKOAR`T7FQD1*&,9PX5^+V.S]+6!YC[L0/V+SC)KRPSOS99VB-\nM3Q!4QNA</DWD:2J-<0:]-C9+J-4#=-JA7&NATY?9T2QS\\W43S,TO<N'R"H\\\\\nM^@3?/WR6B5^ZG<_=<2LW;*ZSG&CFE:&[TD<$(7B24B#9,UUGNK&;EZ<G.7OX\nM&0X?/<[!&_>&GN?]^9''_NOPS.S.DVL>T!L`&`/U:LC>6^XFJF_#=(^Q\\X;W\nMXE=GT<.+3&W:07EB+QB-;SK4)F?!*;*!HASF@XKGA^@83K43TM-SE-,^1X^^\nMP(.'3E)_R_OY[/MO9*KJ<W9IB+8.C42&(3I31,T)AIDF,Q;K++,-C_"=[^;T\nMCS-.O'R:O7MV'PB"\\$^._.39+_SF[_RASCU@<@#.Y;(4CBQ90`C0.B-+EC!.\nM8M0(E2QBYKLDW9<)Z*/[AQ@.4H2_F6%V`6,EI<8LQ@B4S=N*>*G#8S]ZCGC+\nMC=SS*P<I>8[39\\\\S-KT%XZ`ZL8G2^#3M..-R;T2R-``A,,-E;+_#W+E7F+Q^\nM/PO=!187%FDT&W?OW+WW/X(@?.YU/2"%Q:1ME`!K,DRZC#4I.EUA,'\\"DUXD\nMZ7O(:@ML'ZTE"(%$Y`7)^F@CV!))%E7"4R=>YI4^''CG`;:/5]#6(8*8;J=#\nMM36.M8Y+_1$75Q(0$`0>GA3T%_N\\].0/\\.LMMK]]&G'P;70./4ZE4ID2POOH\nM]AV[-P!P(&TN2^'0HS8XC=&*T<HIDNYQ1BMM2G6'U0IK\\T;-&5`ZIT]/K-*N\nMCS&")%$,=<S+I\\]B6C/<.#M)9@P&R<LO'N,G#W^/.^[Y?:(MNUD89D2A1Q0&\nM2*OIGWF![HGGV?^N][%I_ULQ5N#OV$G_I<-D68:U]K;''WNHLA9"VA;;A44(\nMF;0--L7H$?U+CZ)'':R9P#H/8W.EM19(`UIM!""PSD=K&/6&]((^\\YT>U=D;\nM&*OX))G&"<EU!VZEO3#'T__]'1I[WLK8C6^G6J^1+<]S\\=#C5*H5;K[C$]0F\nMIM%:DV8:O]F@-CF-Z2UBK-T11M'D%2'D)&B3;S3I48=L>`$UZF)EFBMM!%H+\nMC,Z?T5K@F5P67LX(^39Z@#:2)!/$64RL#-5JA<6S)^D(RZ9=^_&B,N^\\ZY.<\nM?.&G_/"[WR1]Z'ZFMVQ%:<,M'_@P^]_U/J(HPCI'W(]9.'64QO8]U,?'48,V\nMSKIZJ52MRU4`NE#$&/`$9,,+]"\\]@4ICC%E7VAB!UJ"T*`#ELC9R[7GG_-RK\nMVI(I50Q`DG@XH'WQ'$DZRC>RC&5\\]\\W\\ZF>^2#)*>?J!^[GU0W?PCH]\\C%:S\nM2JWL4R\\'C#7KA)[#TR/*I8@@\\#'&"*V-N)*%1"Z#8;ATC"Q>0IEMN;*%Q74!\nM1&DP6N"*<ZD%VH%Q`DL.P.H4/`@D**/QZN-4`Q_KA2B;[T3'RC"Y92N_]>6O\nM(!_[%GMOVDLY]`@]\\&1>V77<IQ2%U&I5.LX2A2&9RI+EY4YR)0NM`K":=-C&\nMF-RZQN3%3AG09AV$-N"M`C`"O=HWN0!C!&$0()'4(H_+_672RG6,36YED!FR\nMD29S4(E\\?`E;=^]A0MQ)9?X$_KZ;*/OY+IRU%F]RG-([;F,XTI`F!$%`.LH6\nM1DG<R4/(K"MD3-X;:>76%=7K2:O-E3FPMK8!F'4^1D.C7B<(?*9:3<S2)5Z:\nM[_/B?)\\S[2'MH<IGXV)8\\7"8G0<)XQ5*:9]**:!>":B4`DI10*U2Q@P'!$;A\nMG"6.XV-//?[]Y;4<,!MR8`V46E5R73E3A),JP*Q=7Y,%CIR%FHT&C5J539NF\nM*??G2'M=1CK?P-(K"PBC$,4&F0!$O86=V(I_\\22>[Z'B(5A#R9?X`MJOOLI8\nMI42[W<WB)'[H@W?=X]:3>$W!P@-K82(V>&B#?(72ZVO&L`8@"D-V[9RA7J\\S\nMVZIBSQX#:['#9206YP5K'6\\V2DCZ/;)M-Y"=.D(V'-(;)G3GY@B%8/'294QG\nM"=\\3O';QTJ$X'OYPT%_F"@^8#2%DBI!21F#TZUEZ0]@4N;%ZGR-`F[PJ[[M^\nM)ULV3S$[NXWF\\#+9V1?PRG6\\L4UY@AJ+TIKS1P^Q=/XL:7,S<69(3AYALC7!\nMYNE-7)I;9.[X2\\Q.M3AZ[,5AM]/]>JLUN=1?Z>8`S!56S0$H#4IMB']5A(T6\nM16BMKRE5`"N.%"PTWU-<'$AF]AR@/M9B]XX92G,G&)X^ADDS(E\\2^1["&'02\nMTUN<)["6\\8.W,3Y8!&4X?7Z><T=>8->F%L=?.LG)4V?^O=->N+_;6>3%YW^\\\nMWHT6\\T#.*#)`>"$2\\&P5Z1MD:`AHX(4A7M0C,`V"\\CA"](GP"6N3E*(5A`SP\nMHSK&2)8NG7S,&[AGP^:TF-@\\4VTO+'Q\\9O/4MO;\\:9:3%<3>FPEF9Q@;K[/C\nMA@-4/,=X*41MV<<KX31+3_\\4M]QA6[/",\\\\<,L\\=>?%[M[SG@_\\LA$B_\\5>?\nM!XI]KD?_L1AR!']A+7^CQ#B5:@OG/#0E_&*0UT3X7H"S%N,"I!>!LUA\\A%=&\nM8A`RP%K-A>,/H)7ZHA!\\[7'UQSSW[,/\\ZGL_?J?G!__@K+TI33.,D(3-"2H3\nMDU2;S7SDE`*I,R*KJ0>2+$UX[M!/AR\\</_$O_?[*5X(@ZAY][N$K)S)CU@"T\nMG>.T=!T3=SO8U=EXXWQ<M-VK\\L^>K][O0#I'%^";]WV=C]U]+]NV[7W@U*DC\nM9SS/_Q*(3PCLA%U9(DM6$(L1)@H)PQ#?D_32C*.7Y]6Y\\Z\\=;K<[7QO%@_O]\nM,$PW*K_F@0?_+E=""*K64OTYI=ZD#`R`^'/_NOZ#'__4[Y&FH[!2J=\\"XM><\nM<^]RCNU"4+/.8;16:9HMQG%\\-(Z3!],T>:0UL6GQ\\J5SG#[^S,\\-]6_XWRK7\nMZG/@;>]FT.^*V9GKJT%8F@JB4DUK31+':C#HM?N];B>,2N;DT:=^X7O^#^3F\n21IIHX^#)`````$E%3D2N0F""\n`\nend\n
105995
 
6605    order_help_48           begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```1.DE$051H@=6::[`E577'?WOWZ[SO>^[<F;G#@##.H()0\nM*KX5%$8%8Y3X0BTDQ!C+&"L5M6),)16-1"DCDI@/HK$*8R028HP$412'5X$S\nM&A[R9F9@AIFYP[USSSGW//KTZ=ZO?.B^<^\\`90IFOJ2KNGIU[^X^^[_7_[_6\nMVKL/_#_?Q'-]X(J;%Q"PWCJWR3F<=6`=..?(;8<%G.7(N7//8@/.YL\\88^CW\nMN_2Z2_2['>+>4J??[>ZN34REMW_YW;^U/_[S02S@W4*(+UKGK`/`X0"W?(=S\nMA4W1^BRV6[&%E$11&552J$R1)7%<+I=N>6K?X]_RSOC`;=7&>-:]]1^/#P`I\nM`4<0>:*R:3PB\\,!8,,YAK<,XL)95ML,XA[&%=QR88N3M4<\\%9!,AR:!"=ZE4\nMVW]H_KU1I?X6K=5W%N?GOKSFK9\\]N'#K-V&P>(P`A,`!)5_P\\DT51BH^QCJT\nM=1B3'S-ET,9A;-[Q%;NXSW+DW%B*:PYC0[2I,$P;[+1#-M36CY3+E4_L":,M\nMS<.'/K;^S1_?<_!'EP/)L0#(72^E0`K8<=?C[-^_A$6BC0\\BY-6O74>U$=!6\nMCD0[E,EW;2S*.#+C4-JAS4I;9E:=9X:.,IRYML3:J5=0K=7/?7SW(U_MM)N7\nM;/W@W[8>_NZ?'0<`(J?'+W[^*!.3=?;M'7+S;4V>&GA\\_^H)-H]''-*&UM"2\nM:L<PLPRU9:@<0V5)E251CE2M7!LNVYG"=@7GEA53H8,7GT*M7C]_8?ZI#Y9*\nMT3_,_M4-W/3Y\\Y\\O`'$$@``<%0[-^]QXUX"'^B%C+QS#KP4$GB`*))$!A,4Y\nMF0O=Y3:`=1:<Q%&T.\\AC6$`R,LTW[WR2ANZQ>7J"NO0]?V;FHK!<^^Y:9ULW\nM/5\\/>#(/@U((A!#,M0.NNWV>5CF"TQN(%X[CUT("*2CYDE+H$$C`@I#%6U;9\nM8MDNCB)O=]4:L0R9*FO.W#K!O4\\LLC#7/BD8#F>!UG)_GA>%`(3((U)GI$)K\nMPRB<-`8;&G#2"'YUV0."DLT[YY!Y<F`5B,(3@F6O%.U%?+4NI%RK4(H"&J-C\nME/LB4MFP+%:EK^=%(8'+*20$'WSG)LX\\6R-'(EP]HE(+6%\\5A#YL+,-4('.1\nMZGQ7A9"5+L1\\Q+8H[5:)W)(91]67A+XD\\#UJM3K65N#8`"R+6"`$G+>UQ#E&\nM%Z.6X5R&21P=Y_`15)S#&-#6%N$TC_U&YOE!XS`"C.<P?AZ)EO.&L0XA/7S/\nMQY,"3TH\\3Q[5G^>>B05`'D*ML>QJSI.5JFA#,7J63!FZK39!?:P(DQ!W.V@\\\nMK%\\Z,OII=PGE16B"W#O:H.,ETJ!!IB'5EJUUS7FG;<(K*/OT[;F+6`B<R#T`\nM#CR?H-X``T8[A+:X5*."!%&JH32DQI%X*1H?ZU=(G27%D3!`42$3(2D6Y0Q*\nM#TADA<PX!MHRJV-\\*?"D*'[S&`%("<YQ1`,R&>"W%DE[/4:J=2R@M2$T?49<\nM"2?!2NB5AGB>1ZDB43JG2`L%P1"\\(LEIPZ"L*#<4V@J4MI2MP_<$GB>.!)!C\nM`U#D`2'R"K3B!S0J96S<9ZI>00B!UH9()4R-UP`0"-I2$P0^U5H=8RW6P8),\nMB<H5_"#*L[#6-*.,QE@#8P7&.GH=F_-?%`">!N*82@D0..=PSM'6EH6^0EM(\nM,TV[E1&9Y$BIT%^*T<*#P))I2V8@6>JB?84687Y-&52O2Q9Z9";/SF>,9KQG\nM@\\23*X'CV`&(/)H+`<9:LBP#K?&-0EK`&B*GJ:#0`HP$/)-'>=^@A4-[$(<6\nM%UBL+$)KX$B4PY5ST*ERC$3@>P*_J+V.'8`4N0:*B!`&`=5JE>G:@.G)$804\nM&&-8##1KUTX`((2DU?8)?)]ZO8YS#BD$"X=]ZK4:4:F$M@ZE-/,+`>,3:S`.\nMC'$L+"[B20H/<!PI5`Q%FJ;T>CWFNWV:7H1UH)2AW5SBB<POXCGT.DL@?;QH\nM@#$6XZ#7;B*C'G@1VE@R;1@LM9!5A3*0:<O&LF+;S+H\\"CV+BH^I&A5`&(;4\nMJE5D*680E-$&4J/HBI#4!6064B/HZP#M/)SSR52>99/8PZ82)01#)?-<T!6D\nMB2#3D&0"?PV$QY5"JZ(0A0;2+*/J-+.!1482$TE:F<?D9)C/E8&E4H#G^51K\nMI;P*1=!N)M3K=<(HRC.UMK2:BO&),8S+)T+#?K?(PN(XB[AXD3$:K12)4K2&\nM&0!*&Y8&*:8_S"?Q0"=.<4(3*J\\(HX+>TI"*]O&#/*QJ8VBWAQS2`XQU9,HR\nMZBFV^/*(!HZ?B(4H*!11J]>Q_0'-L((R@J'6M$W,0AH>*>+Z70\\E?&SBH8U'\nMJAVM0XJ%Y@&:K1Z#.$$;B[09_N0&PI$)\\$/.6^]XLY_70<>)0G)%Q$*@E*;?\nM'Q"D&>,F!03*-[1#PUA%%Y,4Z$J'D(Y2!7[SZ'[^]?J[>."1`X3",35:I5(*\nM\\:RE/T@Y<,^]Q%:R<<,DM0O.0(@M!-YOH9"[F^4:O`&,.+MJ7:<X.I,?@P,U\nM<]^:FT>=6`?#B,#-4_8:-/P6DT%>7AAMB*(6(^41C*P"@D"7<`Y^>MM]7'7M\nM+9RP;H(O?.Q\\7KIU$Z4H($Y2NOTA[4[,P?DV#^XZR([[]G#Y-W["8C/A]%>^\nM,J]$G3L*@`!P_U/,-00?Q_%I',:N!F#SYPK;:4;'M!@=]R4D28K6%FORR8@M\nMEE*L-AR:^7,.C5V,MH;%0_/\\X'LWT#[<Y3,?N8"WOOYTTDPQO]BEU1W0CS/Z\nMB68PU"2I(4DU2]V$!W?/\\:O[GV#3"S9R_CO>U)V8'-MFC/GE)\\^>6O&`-7GG\nMA&`L4YSPXSN@'Q?)0WIXGD7B$$+B>P(AEL!U\\#V!E!8!>-)'"HT0,#9:9:04\nM4W$]QJ6FF\\1<_U^WHP895W_YHYRP?I*G%CLH;2F5(C94JGG$R2P+K80]![JT\nM6S&Q@NGIC;Q,CK#S_GU<=]WMXJRSMOC6/HU"1N?)1DJ(!_#(WA+GOO52PO(H\nMAQ[Y"6M/>!%>6&?^B1V,C4\\05$9I/;6;R--4&N/TNTULEE"K!^BT1;DVADX?\nMXX21,J>=.,F55^_D\\-[]?.NR/V3MU"B'%I98/SU&.HQY<M]>YN;F4$H1A@&S\nMLYLX[>P3V?EHAQ_O.$`K,\\24&5^SCD=V+=8?>OC6=YB#O_XE)W]2L_O*'(!>\nM!<`8J%=#-I]Q(5%]/:9]/YNVO`&_.HN.#S(U?0+EB<U@-+YI49N<!:?(^HIR\nMF$]4/#]$#V!/>\\B]/[^7JZZ]A;_^XW>Q?GJ,?0<7J54K+"X<XL,?OIC=NW=C\nMC$$I19(D-!H-MFT[C[_YPA?9MS3)5W_X,)UNBDH,ME+#)OX?,//RG^%7;UKQ\nM@,D!.)?;4CBR9`$A0.N,+%G$.(E10U1R&#/?)FD_1D`/W?LU<3]%^&N)LP,8\nM*RDU9C%&,%2.__S9W;SXE%E>=<8I[)MKTNVG2#\\B"`UGG746G_K4IU@S-86Q\nMANW;MW/%%5_CFFO^C7*IQ!_]Q>5<N;V$L0X9>OBAAPF]43L0'W7-1V[CM,\\-\nMY;('EO<<@,6D352R@#49)EU"Q?O1:8?^_)VT]UQ#TMF%T2DZ[:&U1AF!UJ*@\nMHX^QDF`0<_"QO;SMC2^EU8E9Z@[HQII.7S.[\\43>]_Z+>/Q@D^T/SO-PO\\:E\nMG_@TOW?AA0#LV+&3DNDRL\\;#'ROG^V@)?R3"JU=>)Z=.VBK'UJVBD`-I<UL*\nMAQXVP6F,5@P[NTC:#S+L-"G5'58KK,T+-6=`Z3Q\\>F(Y[/HX*WAH]U,@-K)N\nMS1@+S2[]Q!`//5IQPEQG'[^ZYS'2:!UA8X:]2SYG#AP;-\\X"4*E6<8`2*?YX\nM'1*-"21X`F`**J\\0I?H]1RBD;;%<6%#(I$VP*48/Z<W]`CUL8<T$UGD8FW=:\nM:X$TH-5J``+K?+01/+1[CI'Z%I36#!)-G$KB3!)K1=)3E&=/PPE0'KQD=I29\nMDF;'CIT`;#OO7.82S:(O"6ME;)0A_'PQ+8_5P9;JMO<<+6(G09M\\H4D/6V3Q\nM`=2PC95IWNE5--$%`,_DMO!R0>7+Z`%:P?QBER@*Z,5#^HEED`;$RB/!D4B!\nMEK!EXR@O.VF<]<&0KW_E2]Q^QQU<_*$/<=$EE_*%NQY%34_BBQ+&+^H("U99\nMG*E.-?_NX^(9%#(F]U(6'R!I/8!*`TRTTFEC!%J#T@)E!*ZPI2_11[[6^&@#\nM6CNTI^GT$N)4,L@DL3$,I6#@"<;J$1>>-L&-__$]/G/U=ZA4*GSSJJLX]56O\nMX<K['^>N\\ABED4ELG.4EA'4X9?!2'W3H^2]XJ3@Z"HG<!D.\\>#_98!%EUN>=\nM+49\\6>Q*@]$Y`*U!:H%V8)S`XF.-H%XMLZLSI-,;,E`!@\\QGX#3#0)+XDL!8\nM>KT>7__Z/[%K]VYNO/%&6M.S?/(W3[!_<H:H,89-%$:",PZ9&>10(R,/$ZO.\nMI3__B#TZ#RP#L)HT;F),/KK&Y,E.&=!F!80VX"T#,`*]7#>Y`&,%&]=-LOW`\nM@&8GQE`CSC2Q$/0S.*0M-4#Z:SG[[#>R9<L6)B<GN::3<'#KJ50:%9PR:$_@\nMM$4.#2+T\\",?0@_MBWW7?>F!0@.F")]%(L.!5L77DU4CKK5`FZ,UX(HVSPBT\nM6?Z8YZ,4O.24C=@=CGL?WD]8GJ*GZK2M1UL(!F6?C>6`OBSQV<]?AK4&[:#_\nM^!Q!O817#[&I1J8&Z4N$)Q">H!;Y=#PQ!'./:3ZY(N+EHBVG4`'J"&U61MT4\nM=%(%F&4*47C&.H'#1RG'YA-G>/$I$3?>>C^RW,6%,\\A&#7^B@A=YS(Z4F"Q[\nMJ'2`-89RN<3I,VNYQSA<9G#*XJPM"DE'(_"HA8:FT0^Y++[;F81G)C)=>.`(\nM340AR*?9JP2]NLT8</AH#;5*F0_][FN)0A]K-,Z:_#.`L5AMF:R$M/?OX?T7\nMOI,+MIW+S3=<S[0GT4L)JI6@.T-LK#!#1=G"B^HAO4'F=)9>,_J>BQ?TD_>M\nM>,"Y8IVGH)`I.*Z,P*SVP-,Z+8O[,`)?BUP#!(56'+]SSIF\\_9S3N>YG>\\`J\nMG#98;1':8I1F<G*&B][W7I(DX=2M6_GU($6W$T@,SCITHJAFAK,GR^R=ZW%X\nM*;[==1?_I?_C[Q/?\\/>Y!\\Q1HYH#4!J46L5_5=!&"[0Z6AM*%<"*(_@8`_-=\nMQ7SB<?%%%[#YY+5@ACAE<)F!S/#0OB6N>RS%?]G;&3GG?>ST9[CI\\1:ZDY(U\nM!Z3-`>NUXY)U#6RLV+LP&&X9K5QQ]AM>/S^X\\P<KY?2R!O+B#:0,$%Z(!#Q;\nM1?H&&1H"&GAAB!=U"4R#H#R.$#TB?,+:)*6H@Y`!?E3'&,GBW*/;O9[=.34S\nM+=_UMK.\\KUQURS:MAB]RPQ!2PZ[]7?[R!P_CU0.\\6HA7"Y'E`+\\4,%$)V#8[\nMPKDS-7ZZJ\\E_/_#4WM>M';OV_5O7W1TKPP]_>>TJ`":O:1#YS&QZJDZE.H9S\nM'@U\\?#F!<Q.,$.%[`6ZLSK@+D%X$;I0I?(171C*"D`'=PX^1I2F#>[Y]??O>\nM;U]QZ?5OAZES(5GZ#E'I<CN,WA1E@5=QC@`($$1"4I:2M=604]?6.'.ZAC".\nM;]SYI+OCB<6=::?SF>U_\\JK;?G3IU^A^^T^?-J%9`=!TCMW2M<R@W<JGDG9E\nM7OPLT\\MGG"_?[T`Z1QN`_=?G:^P3K[Z/=/$#5@:7##OBP])C<SGT_,E&R'CH\nM,5KRJ2-8F.MQU<.'[9Y6O+<W&'Q/#'K?D!LV'VB_XW,,?G39,^?$/[WLB(BK\nMUE)]1J>>IPWT@<%'KUKUB[._#PN[!%O>LD[61UXO:^77^)7P9*\\25F7)!U\\F\nMQF.OP]PE]>!6]MVWE_JDC?_]LSS;]IS_K7)<MY,OA6PHY/A$28Y,!2+R(>MH\nAUSF<('#Z[G_^/U_QOQ0U-?Z(8@E_`````$E%3D2N0F""\n`\nend\n
105996
 
6606    order_next_48           begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```[$\nM```.Q`&5*PX;```0Z$E$051H@=69>ZQE=77'/[_?;^^SS_O<YSQ@!H911T:H\nM"E8((TJEHA!KU5!K>5BK-I6&6E]I4V.K1MM:;-54FX94FZBQ`BF2%%M%BH".\nM@`C*2V%@!N8]=^Z=>\\ZYY[7/WOOWZA][W\\<(L9&9I.E)?MEKO\\Y9W_7XKK5^\nM!_Z??\\2O^L+GO[>`@%.=]UN\\QSL/SH/WGESV.,`[5LZ]?PX9\\"Y_QUK+<-AG\nMT%]BV.\\Q&BSUAOW^GOKT;+KSNK?]4GV"YX-8P-N$$'_CO'<>`(\\'_/(3WA<R\nMQ=WGD/VJ+*0DBBKHLD9GFFP\\&E4JY;N/[G_FR^J<JWY0:TYE_>]_\\>0`D!+P\nMA)$2U2U3$:$"Z\\!ZCW,>Z\\$YUL@>ZSW6%=[Q8`O+N^/>"\\FF2XSC*OVE<OW@\nMW/S;HVKC4F/TUQ;GCURW[K*/'%[X_I<@7CQ!`$+@@7(@>.66*JUJ@'4>XSS6\nMYL=,6XSU6)<KOBH7SSE6SJVCN.:QKH2Q59*TR8]=PJ;ZJ:U*I?J^ITO1F>UC\nM<W]\\ZNNN??KPK9\\!QB<"('>]E`(IX/[[GN'@P24<$F,#$"5V7'@*M69(5WO&\nMQJ-MOHQU:.O)K$<;C[&K]S*[YCRS]+3EW`UE-LR>1ZW>N.29/;L^U^NVW[7]\nMZK_N//'U#Y\\$`"(/CSOO>)+IF0;[]R5\\[P=MCL:*F[XZS;:IB#ECZ22.U'B2\nMS)$81Z(]B7:DVC'6GE2O7DN6Y4SC^H)+*IK9DH>S7T2]T7CCPOS1J\\OEZ`N;\nM/_9?W/[)-SY?`&(%@``\\5>;F`[YS7\\SCPQ*3+YXDJ(>$2A"%DL@"PN&]S!/=\nMYS*`\\PZ\\Q%/<]Y!S6,BXM9XOW7N`IAFP;?TT#1FH8./&*TN5^M<W>->Y_?EZ\nM0,F<!J40""$XT@VY>><\\G4H$+VLB7CQ%4"\\12D$YD)1+'H$$'`A9?,L:62S+\nMQ5'D]WVMSDB6F*T8SMT^S<-[%UDXTMT:)LEFH+.LS_,*(0`A<D;JM:IT-DW`\nMUDG8U(2M+8+:L@<$99<KYY%Y<6`-B,(3@F6O%/<+?G6^1*5>I1R%-"<FJ0Q%\nMI+.D(M:4K^<50@*?AY`07/W6+9S[6H-L1?A&1+4><FI-4`K@M`K,AC)/4I,O\nM722R-D4RK\\@.;?R:)'=DUE,+)*5`$@:*>KV!<U4X,0#+22P0`EZ_O<S%UA16\nMR_`^PXX]/>\\)$%2]QUHPSA5TFG._E7E],'BL`*L\\-LB9:+EN6.<14A&H`"4%\nM2DJ4DL?I\\ZM78@&04ZBSCMWM>;)R#6,IK.?(M*7?Z1(V)@N:A%&_AT'A@O**\nM]=/^$EI%&,+<.\\9B1DND89/,0&H<VQN&U[]T"ZH(V5_\\_.I)+`1>Y!X`#RH@\nM;#3!@C4>81P^->APC"C7T092ZQFK%$.`"ZJDWI'B&1.CJ9*)$BD.[2W:Q(QE\nME<QZ8N/8;$8$4J"D*'[S!`%("=ZSD@-R'!-T%DD'`UJU!@XPQE*R0UJ^C)?@\nM)`S*"4HIRE6)-GF(=-`0)J"*(F<L<453:6J,$VCCJ#A/H`1*B14".3$`11T0\nM(N]`JT%(LUK!C8;,-JH((3#&$NDQLU-U``2"KC2$84"MWL`ZA_.P(%.B2I4@\nMC/(J;`SM**,YV<0Z@76>0<_E\\2\\*`+\\`XH1:"1!X[_'>TS6.A:'&.$@S0[>3\nM$=GQ2JLP7!IAA(+0D1E'9F&\\U,<$&B-*^35MT8,^64F1V;PZGS.1\\;N;)$JN\nM$L>)`Q`YFPL!UCFR+`-C"*Q&.L!9(F^HHC$"K`24S5D^L!CA,0I&)8</'4X6\nMU!IZQMKC*SGH5'M:$01*$!2]UXD#D"+/@8(12F%(K59C?3UF_4P+(0766A9#\nMPX8-TP`((>ET`\\(@H-%HX+U'"L'"L8!&O4Y4+F.<1VO#_$+(U/0ZK`=K/0N+\nMBRA)X0%.8@@5IDC3E,%@P'Q_2%M%.`]:6[KM)?9F0<'G,.@M@0Q048RU#NMA\nMT&TCHP&H"&,=F;'$2QUD3:,M9,9Q6D7SAHVGY"ST'%E\\0MVH`$JE$O5:#5D>\nM$8<5C(74:OJB1.I#,@>I%0Q-B/$*[P,RG5?9\\4CA4HD6@D3+O!;T!>E8D!D8\nM9X)@'91.:@BM82&*'$BSC)HW;`X=,I+82-+)%#,SI7Q6!I;*(4H%U.KEO`M%\nMT&V/:30:E*(HK]3&T6EKIJ8GL3X?A))AOZC"XB0G<?%%UAJ,UHRUII-D`&AC\nM68I3[##)AWB@-TKQPE#2JJ!1P6`IH:I#@E+>X1ICZ78SYDR2DX.V3"C-F8%<\nMR8&3E\\1"%"$446\\T<,.8=JF*MH+$&+IVQ$):6FGBAGV%%@%NK-!&H1UT%Q(6\nM^P=8[!YA,.Q@C`6M41,O(FIL@6":2S?!Z\\*\\#SI)(217DU@(M#8,AS%AFC%E\nM4T"@`TNW9)FLFF)(@;[T".FIU"1[C^SEAKMNXM['[D:X$3/-)HUJ#85GG(V9\nMW]^CKP53S:W8ZEMP;BMA\\$M"R/^4Y1Z\\";2\\6[.O4QR]S8_AH;I]9-WW)KPX\nM!9*(T,]344V:08>9,&\\OK+%$48=6I865-4`0FC)*21[<?1>?O>&S1&'$AW_G\nM][G@[`MHU)HD.J$_[K,4+W&D<X1=!Y[@_ET_XI^^^PD.]![BPE?\\*8%:A_?N\nM."H5`/XGQ:PAN!;/G^&Q;BT`E_<_A>P-$Y-&3$P%$L;C%&,<SN;#B"NV4IRQ\nMS&W\\"^8FWXFVEG[G&+??<3T_VW4;U[SUO5SUAJM02K'06Z`S[#!(!@RS(7$6\nMKZQ^W&?WX=W<^_-[J)9/XRVO_G1_R\\97OL'8Y$?OOWAFU0/.YLH)P62F.?W;\nM/X3AJ"@>4J&40^(10A(H@1!+X'L$2B"E0P!*!DAA$`(F)VJTRB.J?L"D-&0V\nMY=OWW\\BNW7?RQ0]]@1TOW<%<9X[.J,,H&Q'KF)$>$9L1L8T9V9B1&3'R(UK3\nM+<Y[V?D\\^-0#W/B##P0OWGA1O52NP<N`1PH`UN3%1DH8Q;!K7YE++GL/I<H$\nM<[MN8\\/I9Z%*#>;WWL_DU#1A=8+.T3U$RE!M3C'LMW'9F'HCQ*0=*O5)3/H4\nMIS<KO'SK.F[]X2W\\Y,&;N.[:SW#>6>>Q]^A>!NF`D<F5CTU,8F-2GY"X$1EC\nMM!BC14+L!XP8,#D[R5,'GZP>_-DCU]#C`3;36P%@U@"P%AJU$MO.N9RH<2JV\nM^QA;SKR(H+89,SK,[/K3J4QO`VL(;(?ZS&;PFFRHJ93R044%)4P,>[H)^W_Z\nM&'_WE4]SQ>NO9,=+=[!W?B_#;)A;W.:*)R[!"LTYIYW+TYW=/'GL<5)&S(T/\nML+^]G\\5^F\\$XQI<MPHLW>^'O9#/_S-*R!VP.P/M<EL*3C1<0`HS)R,:+6"^Q\nM.D&/CV'GNXR[3Q$RP`P>9#1,$<$&1MDAK).4FYNQ5F"\\Y/8';R-4DLM?>SD'\nMCAV@E_1RR]L1J4O(BN6E9[HTS?3D#(D;<LL3-W!T>)14:,**H"8CI!0(29!B\nM_M`_[6]A`T>?TP-2.&S:1@MP-L.F2SB;8M(>P_E=V/0PXX%"UB;!#3!&@A!(\nM1+[?Z0*,%:P+-,\\\\\\7U>=]YO8KRA/6PSLKGE4S]&^Q3C,S0I0D*<Q`3]$N<W\nM7LWBUCENW_<MDC0ERPSCL5[IA;SS9VMC7T6);ZX"\\"!=+DOA,4D;O,$:3=+;\nMS;C[<Y)>FW+#XXS&N;Q1\\Q:TR>E3B67:#7!.<GCQ,//=HVS?LIV%W@+]K,_(\nMCDA),*08,HS,L$(3*('SAC3S2".YN/S;S)PURZU[;Z0W[".+]M=[C[4N]"9[\nM]>R5K6^NA)!QQ79A$4(V;8-+L29A<.1.3-+!V6F<5UB7*VV,0%HP>BT`@?,!\nMWDGV''H&(01A&+(4+Q&[F!=N?"$E0HPW>"Q>>!`6J22,)'OW[65J:HHLS3BC\nM?#;OV/9>;M[W-8YVY_-=[&+3P*1NV^%/MLO'A9"78&R^T622#MGH$#KIXF2:\nM*VT%Q@BLR=\\Q1J!L+@N5)U2^C1YBC&"ANTB@%&,]1CN-#2PJ5GSU^J^191EA\nM&*ZL4JF$QS,U-46OUZ-2J6"MI=)I<-69UW"S_`I/F[UH'1"E`3HRT_8%8?E9\nM(60M*`'9Z!#CSL_0:8B-5I6V5F`,:"/05N`+6082L_)O35`\\YS`.^N,^.M#X\nMDF<P'+!SYTX6VXOY8",E2BF"(*!>K[-APP9:K1;5:A6E%,/!D*O?<37GG_8:\nM#G0.$(8!0:!0H91!18GC64CD,EA&BX^1Q8MH>VJN;&%Q4P#1!JS)`1@#T@B,\nM!^L%C@!CH5%IDNDVW5$75W)XYZENJ++C@AUTNEV6=V;R]ES0[BRR<^=.C#%X\nM[VDTFGSPPQ]@M&F>>^?N(`P#E-(H)5%>#NR<T\\>ST#(`9TA';:S-K6MM7NRT\nM!6-701@+:AF`%9CEOLF'&`.GS&S"N'GFE^:I-"LD.N'1WL.\\\\HIS&>D^3FFB\nM<DA4#FC6ZZR/MW+EF][)W-$Y9F9F^>C'/\\+ZB\\O<L?A-LC!&"H&4DE`%2"$.\nMC6_)XAR`+>BSH%$\\&%W\\>[+&XL8(C#T^!WQQ3UF!L<M_Y@5H[3ACXPN8;N[C\nMX3T/,[5ABI$:\\L"1^TC%$$J:>C.BU:K2:E58'\\YPJ?P#A)!LWK293WSZ8T3G\nM#[EG<"LFR/+FTGDJJDJ,P3O_X);/S+H5#RPW;7D(%:!6PF;5ZK8()UV`60XA\nM"L\\X+_`$:`/K)M=ST<LOXA^_]3GDO(0&E)L!K6:55EC-8];GS&>,QPG'62\\Y\nMBW>][QW$+]G/CY-[T%ZC,XO6EH"01C3!G%X\\ZK2_.YW3^5[W2DB87&G\\FFN%\nM99\\EKTGHM?>L!4^`-2"%XHI+KF"V-8O+',XXK/$8X]#:HK4A30U)JHE'";,S\nMZ_GH=7_.X3,>YH'!W<1I1AQGC,<91CO.:)Y)G"0DX^0_!T^,']=MNPK`VM6%\nM+ZQO<^JT:SWPBTH7SYDUSWE"C!5H8SEO^Z_S[DO?C3`"-!AMR3)#EAF21),D\nMFG&<T1_&[!H_S'>S&WBH>Q_#8<J@/Z8_&).ECG.F=Q"Z,@<7#^XQ(_?%F5<T\nMS>*_#G(`]CBKY@"T`:W7Q+\\NPL8(C#X^-[0N@!5'"+`6%@:&9]J>-U_T)UQX\nMUF60@4L=::I7E(_CE-$H9:D_X*;'O\\(CQW[*8)#2ZXWH]H8$NL*EFR]G,EC'\nM0P<?-66F_OZ*:S[XZ.CI='4>6,Z!O'D#*4.$*B$!Y6K(P")+EI`FJE1"17U"\nMVR2L3"'$@(B`4GV&<M1#R)`@:F"M9/'(DW>I@?NQ"F?E%1>_GX?VW7/!,.F]\nM2H=6C(,LGZ^+Z4D;0Y(&*"614E`+Z[QBPX5<LN5-/';D4?[]H1L[ZRJ_]HT_\nMNNB3WXGG>G2^\\?'5B>S.?\\A[&@1_Z1R?TF**:FT2[Q6&,D$QR!LB`A7BG</Z\nM$*DB\\`Y'@%`5)!8A0YPS'/KY=S!:?T@(/O^>^X"-0,IFFGQ*U,7O1<THFFC6\nMJ=<J5,HEJI4RM7*%Z?H,+YS>QMGK7DY--?COW;=QYY.W[^[U!G^5[G8W!]/"\nMSE_?.WXFMG8%0-M[]DC?L7&WDX^2;G4N?H[Q\\EGGR\\][D-[3!>"A8EW&07I<\nMZX6_*R&Y9LEQ3D`8392FF`IFF(PF:`4M%KM+?&/?O_EG%O?,=P?=_W!C_X6%\nMSPT>GWA[E?;U\\7%#O0#X[M_F2@A!S3EJSU+J><K`$(C?^R]K?G$[\\#CP6TS3\nMX`)1X35AI+:72N%$$"BD%-KC#CGK'I!&WF6/\\:2LHY>^?+SBQP'X/_O\\!K`$\nI-(G$))$(!2+%N:X?H['^_O_]*_X'!HIY!5TY']L`````245.1*Y"8(+\\\n`\nend\n
105997
 
\.
105998
 
 
105999
 
 
106000
 
--
106001
 
--
106002
 
 
106003
 
COPY pkgmetasql (metasql_id, metasql_group, metasql_name, metasql_notes, metasql_query, metasql_lastuser, metasql_lastupdate, metasql_grade) FROM stdin;
106004
 
228     desktop glforwardupdate  Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  glforwardupdate\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT MIN(forwardUpdateAccount(accnt_id)) AS result \nFROM accnt \nWHERE (accnt_id IN (<? literal("accnt_id_list") ?>))\n \N      \N      0
106005
 
471     desktop commentConsole  Comment Console Query - update for OPP in 3.8 Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: desktop\n-- Name:  commentConsole\n-- Notes: Comment Console Query - update for OPP in 3.8\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n    comment_source_id,\n    comment_date,\n    cmnttype_name,\n    firstLine(comment_text) AS comment_text,\n    comment_text AS comment_text_qttooltiprole,\n    comment_user,\n    CASE WHEN comment_source = 'OPP' THEN 'OPP-Opportunity'\n         WHEN comment_source = 'T' THEN 'T-Contact'\n         ELSE comment_source END AS comment_source,\n    CASE WHEN cmnttype_name = 'Email Received'              THEN 6.5\n         WHEN cmnttype_name = 'Email Sent'                  THEN 3.5\n         WHEN cmnttype_name = 'Internal Information'        THEN 1\n         WHEN cmnttype_name = 'Left Message'                THEN 1\n         WHEN cmnttype_name = 'Meeting'                     THEN 25\n         WHEN cmnttype_name = 'Outside Meeting'             THEN 35\n         WHEN cmnttype_name = 'Phone Call'                  THEN 7\n         WHEN cmnttype_name = 'Sample Confirmation'         THEN 1\n         WHEN cmnttype_name = 'Sample Request'              THEN 10\n         WHEN cmnttype_name = 'Sent Postcard'               THEN 1\n         WHEN cmnttype_name = 'Trade Show'                  THEN 15\n         ELSE 0 END AS points,\n    'qty' AS points_xttotalrole,\n    CASE\n-- Address\n        WHEN comment_source = 'ADDR' THEN\n              (SELECT addr_line1 || addr_line2 || addr_line3\n               FROM addr\n               WHERE ((addr_id = comment_source_id)\n                  AND (comment_source = 'ADDR')))\n\n-- BBOMHead\n <? if exists("xtmfg_exist") ?>\n        WHEN (comment_source = 'BBH')THEN\n                 (SELECT item_descrip1 || ' - ' || item_number\n                  FROM xtmfg.bbomitem, item\n                  WHERE ((comment_source_id = bbomitem_id)\n                     AND (item_id = bbomitem_parent_item_id)\n                     AND (comment_source = 'BBH')))\n <? endif ?>\n\n-- BBOMItem\n <? if exists("xtmfg_exist") ?>\n        WHEN (comment_source = 'BBI') THEN\n              (\n               (SELECT 'Parent - ' || item.item_descrip1 || ' - ' || item.item_number\n                FROM xtmfg.bbomitem, item\n                WHERE ((comment_source_id = bbomitem_id)\n                   AND (item_id = bbomitem_parent_item_id)\n                   AND (comment_source = 'BBI')))\n                || ' - ' ||\n               (SELECT 'BBOM Item - ' || item.item_descrip1 || ' - ' || item.item_number\n                FROM xtmfg.bbomitem, item\n                WHERE ((comment_source_id = bbomitem_id)\n                   AND (item_id = bbomitem_item_id)\n                   AND (comment_source = 'BBI')))\n              )\n <? endif ?>\n\n-- BOMHead\n          WHEN comment_source = 'BMH' THEN\n              (SELECT item_descrip1 || ' - ' || item_number\n               FROM bomhead, item\n               WHERE ((comment_source_id = bomhead_item_id)\n                  AND (bomhead_item_id = item_id)\n                  AND (comment_source = 'BMH')))\n\n-- BOM Item \n        WHEN comment_source = 'BMI' THEN\n              (\n               (SELECT 'Parent - ' || item.item_descrip1 || ' - ' || item.item_number FROM \n                                     public.bomitem, \n                                     public.item\n                                     WHERE bomitem.bomitem_parent_item_id = item.item_id AND \n                                           bomitem_id = comment_source_id\n                                           AND comment_source = 'BMI') \n               || ' - ' ||\n               (SELECT 'BOM Item - ' || item.item_descrip1 || ' - ' || item.item_number FROM \n                                     public.bomitem, \n                                     public.item\n                                     WHERE bomitem.bomitem_item_id = item.item_id AND \n                                           bomitem_id = comment_source_id\n                                           AND comment_source = 'BMI')\n                                           )\n\n-- BOOHead\n <? if exists("xtmfg_exist") ?>\n          WHEN (comment_source = 'BOH') THEN\n              (SELECT item_descrip1 || ' - ' || item_number\n               FROM xtmfg.boohead, item\n               WHERE ((comment_source_id = boohead_item_id)\n                  AND (item_id = boohead_item_id)\n                  AND (comment_source = 'BOH')))\n <? endif ?>\n\n-- BOOItem\n <? if exists("xtmfg_exist") ?>\n          WHEN (comment_source = 'BOI') THEN\n               (SELECT 'Item - ' || item.item_descrip1 || ' - ' ||item.item_number\n               || ' - ' ||\n                      'Operation - ' || booitem_descrip1\n               FROM xtmfg.booitem, item\n               WHERE ((xtmfg.booitem.booitem_item_id = item_id)\n                  AND (booitem_id = comment_source_id)\n                  AND (comment_source = 'BOI')))\n <? endif ?>\n\n-- T  Contact\n        WHEN comment_source = 'T' THEN\n             (SELECT cntct_first_name || ' ' || cntct_last_name FROM cntct \n                     WHERE cntct_id = comment_source_id \n                           AND comment_source = 'T'\n              )\n-- Opportunity\n-- Put this back in after 3.8.0\n/*\n\tWHEN comment_source = 'OPP'  THEN\n              (\n               SELECT ophead_name || ' Account: ' || crmacct_number || ' - ' || crmacct_name || ' Priority: ' || incdtpriority_name || ' - ' || ' Assigned To: ' || ophead_username\n               FROM ophead\n                    LEFT OUTER JOIN crmacct ON (ophead_crmacct_id = crmacct_id)\n                    LEFT OUTER JOIN incdtpriority ON (ophead_priority_id = incdtpriority_id)\n               WHERE \n                    comment_source = 'OPP'\n                    AND comment_source_id = ophead_id\n\t      )\n*/\n-- Customer\n        WHEN comment_source = 'C' THEN\n              (SELECT cust_number || ' - ' || cust_name FROM custinfo WHERE (cust_id = comment_source_id) AND (comment_source = 'C'))\n\n-- Credit Memo - Return Auth\n  <? if exists("xtmfg_exist") ?>\n        WHEN comment_source = 'CRMA' THEN\n              (SELECT 'Credit Memo:  ' || cmhead_number || '  Return Auth: ' || rahead_number || '  Customer  ' || cust_number || ' - ' || cust_name\n                       FROM rahead, cmhead, custinfo\n                       WHERE\n                            ((cmhead_rahead_id = rahead_id)\n                         AND (cmhead_cust_id = cust_id)\n                         AND (cmhead_id = comment_source_id)\n                         AND (comment_source = 'CRMA')))\n <? endif ?>\n\n-- Employee\n        WHEN comment_source = 'EMP' THEN\n              (SELECT emp_code || '-' || emp_name\n               FROM emp \n               WHERE((comment_source_id = emp_id)\n                 AND (comment_source = 'EMP')))\n\n-- Incident\n        WHEN comment_source = 'INCDT' THEN\n              (\n               SELECT incdt_number || ' - ' ||\n                      crmacct_number || ' - ' || \n                      crmacct_name || ' - ' || \n                      incdt_summary\n                FROM incdt, crmacct \n                WHERE \n                incdt_id = comment_source_id\n                AND crmacct_id = incdt_crmacct_id\n                AND (comment_source = 'INCDT')\n              )\n\n-- Item\n        WHEN comment_source = 'I' THEN\n              (SELECT item_number || ' - ' || item_descrip1 \n                      FROM item WHERE item_id = comment_source_id\n                                 AND (comment_source = 'I'))\n\n-- Item Site\n        WHEN comment_source = 'IS' THEN\n              (\n               SELECT item_number || ' - ' || item_descrip1 \n               FROM item, itemsite\n               WHERE itemsite_item_id = item_id\n                     AND itemsite_id = comment_source_id\n                     AND (comment_source = 'IS')\n              )\n\n-- ItemSource\n        WHEN comment_source = 'IR' THEN\n              (\n               SELECT item_number || ' - ' || item_descrip1 \n               FROM item, itemsrc\n               WHERE itemsrc_item_id = item_id\n                     AND itemsrc_id = comment_source_id\n                     AND (comment_source = 'IR')\n              )\n\n-- Location\n        WHEN comment_source = 'L' THEN\n              (SELECT location_name || ' - ' || location_descrip \n               FROM location \n               WHERE location_id = comment_source_id\n                AND (comment_source = 'L'))\n\n-- LotSerial\n  <? if exists("xtmfg_exist") ?>\n        WHEN comment_source = 'LS' THEN\n              (SELECT ls_number || '-' || item_number || '-' || item_descrip1 || item_descrip2\n               FROM ls, item \n               WHERE(ls_id = comment_source_id)\n                 AND(ls_item_id = item_id)\n                AND (comment_source = 'LS'))\n <? endif ?>\n-- Project \n        WHEN comment_source = 'J' THEN\n        (\n              SELECT  'Project#: ' || prj_number || ' - Descrip: ' || prj_descrip || \n                      ' - Status: ' || prj_status || ' - Owner: ' || prj_owner_username || '- Due: ' || prj_due_date\n              FROM prj\n              WHERE\n                   prj_id = comment_source_id\n              AND (comment_source = 'J')\n        )\n-- PO Head\n        WHEN comment_source = 'P' THEN\n              (\n               SELECT pohead_number || ' - ' || vend_number || ' - ' || vend_name\n               FROM pohead, vendinfo\n               WHERE pohead_vend_id = vend_id\n                     AND comment_source_id = pohead_id\n                     AND (comment_source = 'P')\n              )\n-- PO Item\n        WHEN comment_source = 'PI' THEN\n              (\n               SELECT pohead_number || ' - ' || vend_number || ' - ' || vend_name || ' - ' ||\n                      (\n                       SELECT item_number || ' - ' || item_descrip1\n                       FROM poitem, itemsite, item\n                       WHERE poitem_itemsite_id = itemsite_id\n                             AND itemsite_item_id = item_id\n                             AND comment_source_id = poitem_id\n                             AND comment_source = 'PI'\n                      )\n                      || ' - ' || poitem_vend_item_number \n                      || ' - ' || poitem_vend_item_descrip \n               FROM pohead, vendinfo, poitem\n               WHERE pohead_vend_id = vend_id\n                     AND poitem_pohead_id = pohead_id\n                     AND comment_source_id = poitem_id\n                     AND comment_source = 'PI'\n              )\n-- Quote Head\n        WHEN comment_source = 'Q' THEN\n        (\n               SELECT 'Quote#: ' || quhead_number || ' - Customer: ' ||  cust_number || ' - ' || cust_name\n               FROM quhead, custinfo\n               WHERE quhead_cust_id = cust_id \n                     AND quhead_id = comment_source_id\n                     AND comment_source = 'Q'\n        )\n-- Quote Item\n        WHEN comment_source = 'QI' THEN\n        (\n                SELECT 'Quote#:  ' || quhead_number || '  Customer  ' || cust_number || ' - ' || \n                        cust_name || '  Line #: ' || quitem_linenumber || ' - ' || ' Item#: ' || item_number || ' - ' || item_descrip1 || ' - Order Qty: '                        || formatQty(quitem_qtyord)\n                     FROM quhead, quitem, item, itemsite, custinfo\n              \n                 WHERE\n                      quitem_quhead_id = quhead_id\n                      AND quhead_cust_id = cust_id\n                      AND quitem_itemsite_id = itemsite_id\n                      AND itemsite_item_id = item_id\n                      AND quitem_id = comment_source_id\n                      AND comment_source = 'QI'\n        )\n-- Return Auth Head\n  <? if exists("xtmfg_exist") ?>\n        WHEN comment_source = 'RA' THEN\n              (\n               SELECT rahead_number || ' - ' || cust_number || ' - ' || cust_name\n               FROM rahead, custinfo\n               WHERE rahead_cust_id = cust_id \n                     AND rahead_id = comment_source_id\n                     AND comment_source = 'RA'\n              )\n <? endif ?>\n-- SO Head\n        WHEN comment_source = 'S' THEN\n              (\n               SELECT cohead_number || ' - ' ||  cust_number || ' - ' || cust_name\n               FROM cohead, custinfo\n               WHERE cohead_cust_id = cust_id \n                     AND cohead_id = comment_source_id\n                     AND comment_source = 'S'\n              )\n-- SO Item \n        WHEN comment_source = 'SI' THEN\n              (\n                SELECT 'Sales Order:  ' || cohead_number || '  Customer  ' || cust_number || ' - ' || \n                        cust_name || '  Line #: ' || coitem_linenumber || ' - ' || ' Item#: ' || item_number || ' - ' || item_descrip1 || ' - Order Qty: '                        || formatQty(coitem_qtyord)\n                     FROM cohead, coitem, item, itemsite, custinfo\n              \n                 WHERE\n                      coitem_cohead_id = cohead_id\n                      AND cohead_cust_id = cust_id\n                      AND coitem_itemsite_id = itemsite_id\n                      AND itemsite_item_id = item_id\n                      AND coitem_id = comment_source_id\n                      AND comment_source = 'SI'\n                )\n\n-- Task\n        WHEN comment_source = 'TA' THEN\n               (\n                 SELECT prj_number || '-' || prjtask_number || '-' || prjtask_name || '-' || prjtask_descrip\n                 FROM prjtask, prj\n                 WHERE((prjtask_prj_id = prj_id)\n                    AND(prjtask_id = comment_source_id)\n                    AND(comment_source = 'TA'))\n               )\n\n--TodoItem\n        WHEN comment_source = 'TD' THEN\n               (\n                 SELECT todoitem_name || '-' || todoitem_description\n                 FROM todoitem\n                 WHERE((todoitem_id = comment_source_id)\n                    AND(comment_source = 'TD'))\n               )\n\n--Transfer Order Header\n  <? if exists("xtmfg_exist") ?>\n        WHEN comment_source = 'TO' THEN\n              (\n               SELECT 'Transfer#: ' || tohead_number || ' - Status: ' || tohead_status || ' - Source / Dest: ' ||  \n                      (SELECT warehous_code FROM whsinfo WHERE warehous_id = tohead_src_warehous_id) || ' / ' ||\n                      (SELECT warehous_code FROM whsinfo WHERE warehous_id = tohead_dest_warehous_id) \n               FROM tohead\n               WHERE tohead_id = comment_source_id\n                 AND comment_source = 'TO'\n              )\n <? endif ?>\n--Transfer Order item\n  <? if exists("xtmfg_exist") ?>\n        WHEN comment_source = 'TI' THEN\n              (\n               SELECT 'Transfer#: ' || tohead_number || ' - Status: ' || tohead_status || ' - Source / Dest: ' ||  \n                      (SELECT warehous_code FROM whsinfo WHERE warehous_id = tohead_src_warehous_id) || ' / ' ||\n                      (SELECT warehous_code FROM whsinfo WHERE warehous_id = tohead_dest_warehous_id) ||\n                      ' - Item: ' || item_number || ' - ' || item_descrip1 || ' - Qty: ' || formatQty(toitem_qty_ordered)\n               FROM   tohead, toitem, item\n               WHERE \n                    toitem_item_id = item_id  \n                    AND toitem_tohead_id = tohead_id\n                    AND toitem_id = comment_source_id\n                    AND comment_source = 'TI'\n              )\n <? endif ?>\n-- Vendor\n        WHEN comment_source = 'V' THEN\n               (\n                 SELECT 'Vendor Name:  ' || vend_name || ' - Vendor Number: ' || vend_number\n                        FROM vendinfo\n                        WHERE vend_id = comment_source_id\n                          AND comment_source = 'V'\n               )\n\n-- Warehouse \n        WHEN comment_source = 'WH' THEN \n              (SELECT warehous_code || ' - ' || warehous_descrip \n                      FROM whsinfo WHERE warehous_id = comment_source_id\n                                     AND comment_source = 'WH')\n\n-- Work Order\n        WHEN comment_source = 'W' THEN\n              (\n              SELECT \n                         'WO#: ' || wo_number || ' - ' || \n                         wo_subnumber || ' - ' || \n                         'Status: ' || wo_status || ' - ' || \n                         'Ordered: ' || formatQty(wo_qtyord) || ' - ' || \n                         'Received: ' || formatQty(wo_qtyrcv) || ' - ' || \n                         'Item: ' || item_number || ' - ' || \n                         item_descrip1\n             FROM  wo, itemsite, item\n             WHERE wo_itemsite_id = itemsite_id\n                   AND itemsite_item_id = item_id\n                   AND wo_id = comment_source_id\n                   AND comment_source = 'W'\n               )\n-- Unknown\n    ELSE 'Unknown Comment Type'\n    END AS info\nFROM\n    comment, cmnttype\nWHERE\n    comment_cmnttype_id = cmnttype_id\n    <? if exists("commenttype_id") ?>\n         AND cmnttype_id IN (<? literal("commenttype_id") ?>)\n    <? endif ?>\n    --Example: these are the names given to the various comment types like 'General' or "ChangeLog' or those defined by the user.\n    --This query will give you a list of them: \n    --SELECT DISTINCT cmnttype_name, cmnttype_name  FROM cmnttype ORDER BY cmnttype_name;\n-- AND comment_text LIKE '%'\n    --Example: 'Created%' for all comments that start with the work 'Created'\n    --Example: '%question% for all comments that contain the word 'question' anywhere in the comment\n\n     <? if exists("usr_id") ?>\n         AND comment_user IN (SELECT usr_username FROM usr WHERE usr_id IN (<? literal("usr_id") ?>))\n    --  <? elseif exists("usrname") ?>\n     <? endif ?>\n     <? if not exists("show_all") ?>\n         <? if not exists("usr_id") ?>\n            AND comment_user = current_user\n            -- <? value("usrname") ?>\n          <? endif ?>\n     <? endif ?>\n    --This list will show you users who have at least one comment\n    --SELECT DISTINCT comment_user FROM comment ORDER BY comment_user;\n    <? if exists("source") ?>\n      AND comment_source IN (\n      <? foreach("source") ?>\n         <? value("source") ?>\n         <? if isLast("source") ?>\n         <? else ?>\n         ,\n         <? endif ?>\n      <? endforeach ?>\n                            )\n    <? endif ?>\n    --This query will show all comment sources for which there is a comment\n    --SELECT DISTINCT comment_source FROM comment ORDER BY comment_source;\n    --Example: Incidents = 'INCDT'\n   AND CAST(comment_date AS DATE) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>\nORDER BY \n    comment_date, comment_user, comment_source;\n    \N      \N      0
106006
 
468     desktop cmmntPrefSrc     Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group:desktop\n-- Name:cmmntPrefSrc\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT A.id AS id, A.cmntsource_name AS cmntsource_name, A.cmntsource_fullname AS cmntsource_fullname\nFROM (SELECT 1 AS id, '' AS cmntsource_name, 'All Sources' AS cmntsource_fullname\n      UNION\n      SELECT 2, 'ADDR', 'Address'\n      <? if exists("xtmfg_exist") ?>\n        UNION\n        SELECT 3, 'BBH', 'BBOMHead'\n        UNION\n        SELECT 4, 'BBI', 'BBOMItem'\n      <? endif ?>\n      UNION\n      SELECT 5, 'BMH', 'BOMHead'\n      UNION\n      SELECT 6, 'BMI', 'BOMItem'\n      <? if exists("xtmfg_exist") ?>\n        UNION\n        SELECT 7, 'BOH', 'BOOHead'\n        UNION\n        SELECT 8, 'BOI', 'BOOItem'\n        UNION\n        SELECT 9, 'CRMA', 'CRMAccount'\n      <? endif ?>\n      UNION\n      SELECT 10, 'T', 'Contact'\n      UNION\n      SELECT 11, 'C', 'Customer'\n      UNION\n      SELECT 12, 'EMP', 'Employee'\n      UNION\n      SELECT 13, 'INCDT', 'Incident'\n      UNION\n      SELECT 14, 'I', 'Item'\n      UNION\n      SELECT 15, 'IS', 'ItemSite'\n      UNION\n      SELECT 16, 'IR', 'ItemSource'\n      UNION\n      SELECT 17, 'L', 'Location'\n      <? if exists("xtmfg_exist") ?>\n        UNION\n        SELECT 18, 'LS', 'LotSerial'\n      <? endif ?>\n      UNION\n      SELECT 19, 'OPP', 'Opportunity'\n      UNION\n      SELECT 20, 'J', 'Project'\n      UNION\n      SELECT 21, 'P', 'PurchaseOrder'\n      UNION\n      SELECT 22, 'PI', 'PurchaseOrderItem'\n      <? if exists("xtmfg_exist") ?>\n        UNION\n        SELECT 23, 'RA', 'ReturnAuth'\n      <? endif ?>\n      UNION\n      SELECT 24, 'RI', 'ReturnAuthItem'\n      UNION\n      SELECT 25, 'Q', 'Quote'\n      UNION\n      SELECT 26, 'QI', 'QuoteItem'\n      UNION\n      SELECT 27, 'S', 'SalesOrder'\n      UNION\n      SELECT 28, 'SI', 'SalesOrderItem'\n      UNION\n      SELECT 29, 'TA', 'Task'\n      UNION\n      SELECT 30, 'TD', 'TodoItem'\n      <? if exists("xtmfg_exist") ?>\n        UNION\n        SELECT 31, 'TO', 'TransferOrder'\n        UNION\n        SELECT 32, 'TI', 'TransferOrderItem'\n      <? endif ?>\n      UNION\n      SELECT 33, 'V', 'Vendor'\n      UNION\n      SELECT 34, 'WH', 'Warehouse'\n      UNION\n      SELECT 35, 'W', 'WorkOrder') AS A\nWHERE ((true)\n<? if exists("sourceidlist") ?>\n   AND (A.id IN (<? literal("sourceidlist") ?>))\n<? endif ?>\n      )\nORDER BY A.id;\n        \N      \N      0
106007
 
469     desktop cmmntPrefType    Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group:desktop\n-- Name:cmmntPrefType\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT 0 AS id, 'All Types' AS commenttype_name\nUNION\nSELECT cmnttype_id AS id, cmnttype_name AS commenttype_name\nFROM cmnttype \nORDER BY commenttype_name;\n\n\n   \N      \N      0
106008
 
470     desktop cmmntPrefUser    Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group:desktop\n-- Name:cmmntPrefUser\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT usr_id, usr_username\nFROM usr \nWHERE (usr_username=current_user)\nUNION\nSELECT usr_id, usr_username AS usr_username\nFROM usr\nWHERE ((usr_active = true)\n    AND(usr_username <> current_user))\nORDER BY usr_username; \n\n\n\n    \N      \N      0
106009
 
208     desktop contacts         Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  contacts\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  cntct_id AS id, crmacct_number, crmacct_name,\n  cntct.*, addr.*\nFROM cntct \n  LEFT OUTER JOIN crmacct ON (crmacct_cntct_id_1=cntct_id) \n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) \nWHERE (cntct_owner_username=getEffectiveXtUser())\nORDER BY cntct_name;\n      \N      \N      0
106010
 
216     desktop payables         Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  payables\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT formatMoney(sum(apaging_cur_val)) AS cur_val,\n  formatMoney(sum(apaging_thirty_val)) AS thirty_val,\n  formatMoney(sum(apaging_sixty_val)) AS sixty_val,\n  formatMoney(sum(apaging_ninety_val)) AS ninety_val,\n  formatMoney(sum(apaging_plus_val)) AS plus_val,\n  formatMoney(sum(apaging_total_val)) AS total_val  \nFROM apaging(current_date, false);\n    \N      \N      0
106011
 
214     desktop mfgHist Summarized Manufacture History for Desktop Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: desktop\n-- Name:  mfgHist\n-- Notes: Summarized Manufacture History for Desktop\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT <? literal("group_id") ?>, <? literal("group_number") ?>,  <? literal("group_name") ?>,\n       sum(invhist_value_after-invhist_value_before) as amount, sum(invhist_qoh_after-invhist_qoh_before) AS qty,\n       'curr' AS amount_xtnumericrole,\n       'qty' AS qty_xtnumericrole,\n       0 AS amount_xttotalrole,\n       0 AS qty_xttotalrole\nFROM invhist\n  JOIN itemsite ON (itemsite_id=invhist_itemsite_id)\n  JOIN plancode ON (plancode_id=itemsite_plancode_id)\n  JOIN item ON (item_id=itemsite_item_id)\n  JOIN classcode ON (classcode_id=item_classcode_id)\nWHERE ((invhist_transtype = 'RM')\n  AND (invhist_ordtype = 'WO')\n  AND ((invhist_transdate > DATE <? value("startDate") ?> - 1 AND\n        invhist_transdate < DATE <? value("endDate") ?> + 1) )\n)\nGROUP BY <? literal("group_id") ?>, <? literal("group_number") ?>, <? literal("group_name") ?>\nORDER BY <? literal("group_number") ?>\n;\n    \N      \N      0
106012
 
209     desktop crmaccounts      Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  crmaccounts\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  crmacct_id AS id, crmacct_number, crmacct_name,\n  cntct.*, addr.*\nFROM crmacct \n  LEFT OUTER JOIN cntct ON (crmacct_cntct_id_1=cntct_id) \n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) \nWHERE (crmacct_owner_username=getEffectiveXtUser())\nORDER BY crmacct_number;\n   \N      \N      0
106013
 
210     desktop getDates         Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  getDates\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT date_trunc(<? value("timeFrame") ?>, current_date) AS startDate,\n       date_trunc(<? value("timeFrame") ?>, current_date) + <? value("interval") ?>  + '-1 day' AS endDate\n     \N      \N      0
106014
 
223     desktop salesHist       Summarized Sales History for Desktop Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: desktop\n-- Name:  salesHist\n-- Notes: Summarized Sales History for Desktop\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n--------- BOOKINGS -----------\n<? if exists("bookings") ?>\nSELECT <? literal("group_id") ?>, <? literal("group_number") ?>, <? literal("group_name") ?>,\n       sum(round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2)) AS amount,\n       sum(coitem_qtyord) AS qty,\n       'curr' AS amount_xtnumericrole,\n       'qty' AS qty_xtnumericrole,\n       0 AS amount_xttotalrole,\n       0 AS qty_xttotalrole\nFROM coitem\n  JOIN cohead ON (coitem_cohead_id=cohead_id)\n  JOIN custinfo ON (cust_id=cohead_cust_id)\n  JOIN salesrep ON (salesrep_id=cohead_salesrep_id)\n  JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n  JOIN item ON (item_id=itemsite_item_id)\n  JOIN prodcat ON (item_prodcat_id=prodcat_id)\nWHERE (cohead_orderdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\nAND (coitem_status != 'X')\nGROUP BY <? literal("group_id") ?>, <? literal("group_number") ?>, <? literal("group_name") ?>\nORDER BY <? literal("group_number") ?>;\n\n--------- SALES HISTORY -------\n<? elseif exists("sales") ?> \nSELECT <? literal("group_id") ?>, <? literal("group_number") ?>, <? literal("group_name") ?>,\n       sum(round((cohist_qtyshipped * currtobase(cohist_curr_id, cohist_unitprice, cohist_invcdate)), 2)) AS amount,\n       sum(cohist_qtyshipped) AS qty,\n       'curr' AS amount_xtnumericrole,\n       'qty' AS qty_xtnumericrole,\n       0 AS amount_xttotalrole,\n       0 AS qty_xttotalrole\nFROM cohist \n  JOIN custinfo ON (cust_id=cohist_cust_id)\n  JOIN salesrep ON (salesrep_id=cohist_salesrep_id)\n  JOIN itemsite ON (itemsite_id=cohist_itemsite_id)\n  JOIN item ON (item_id=itemsite_item_id)\n  JOIN prodcat ON (item_prodcat_id=prodcat_id)\nWHERE (cohist_invcdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\nGROUP BY <? literal("group_id") ?>, <? literal("group_number") ?>, <? literal("group_name") ?>\nORDER BY <? literal("group_number") ?>;\n<? endif ?>\n     \N      \N      0
106015
 
211     desktop glaccountBal    tweak Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: desktop\n-- Name:  glaccountBal\n-- Notes: tweak\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT accnt_id, formatGlAccount(accnt_id) AS accnt_id_qtdisplayrole, \n accnt_descrip, accnt_type,\n CASE WHEN(accnt_type='A') THEN <? value("asset") ?>\n WHEN(accnt_type='E') THEN <? value("expense") ?>\n WHEN(accnt_type='L') THEN <? value("liability") ?>\n WHEN(accnt_type='Q') THEN <? value("equity") ?>\n WHEN(accnt_type='R') THEN <? value("revenue") ?>\n ELSE accnt_type\n END AS accnt_type_qtdisplayrole,\n CASE WHEN(accnt_type IN ('A','E')) THEN trialbal_ending * -1 \n ELSE trialbal_ending\n END AS balance,\n period_id,\n 'curr' AS balance_xtnumericrole\nFROM accnt \nJOIN trialbal ON (accnt_id=trialbal_accnt_id)\nJOIN (SELECT period_id\n      FROM period\n      JOIN yearperiod ON (period_yearperiod_id=yearperiod_id)\n      WHERE (period_end >= current_date)\n      ORDER BY yearperiod_end asc, period_number asc\n      LIMIT 1) data\n  ON (trialbal_period_id=period_id)\nWHERE (accnt_id IN (<? literal("accnt_id_list") ?>))\nORDER BY accnt_company, accnt_profit, accnt_number, accnt_sub\n       \N      \N      0
106016
 
221     desktop receivables      Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  receivables\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT formatMoney(sum(araging_cur_val)) AS cur_val,\n  formatMoney(sum(araging_thirty_val)) AS thirty_val,\n  formatMoney(sum(araging_sixty_val)) AS sixty_val,\n  formatMoney(sum(araging_ninety_val)) AS ninety_val,\n  formatMoney(sum(araging_plus_val)) AS plus_val,\n  formatMoney(sum(araging_total_val)) AS total_val \nFROM araging(current_date, false);\n  \N      \N      0
106017
 
212     desktop glaccounts       Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  glaccounts\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT accnt_id, formatGlAccount(accnt_id) AS accnt_id_qtdisplayrole, \n  accnt_descrip, accnt_type,\n  CASE WHEN(accnt_type='A') THEN <? value("asset") ?>\n  WHEN(accnt_type='E') THEN <? value("expense") ?>\n  WHEN(accnt_type='L') THEN <? value("liability") ?>\n  WHEN(accnt_type='Q') THEN <? value("equity") ?>\n  WHEN(accnt_type='R') THEN <? value("revenue") ?>\n  ELSE accnt_type\nEND AS accnt_type_qtdisplayrole \nFROM accnt;\t\n      \N      \N      0
106018
 
207     desktop bankBal  Forward update balances if applicable Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name:  bankBal\n-- Notes: \n-- Forward update balances if applicable\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT forwardUpdateAccount(bankaccnt_accnt_id) AS result \nFROM bankaccnt \nWHERE (NOT fetchmetricbool('ManualForwardUpdate'));\n\n-- Return results\nSELECT bankaccnt_id, bankaccnt_name, trialbal_ending * -1 AS balance,\n  'curr' AS balance_xtnumericrole\nFROM bankaccnt\n JOIN accnt ON (bankaccnt_accnt_id=accnt_id)\n JOIN trialbal ON (accnt_id=trialbal_accnt_id)\n JOIN (SELECT period_id\n       FROM period\n       JOIN yearperiod ON (period_yearperiod_id=yearperiod_id)\n       JOIN trialbal ON (trialbal_period_id=period_id)\n       WHERE (period_start <= current_date)\n       ORDER BY yearperiod_end desc, period_number desc\n       LIMIT 1) data\n   ON (trialbal_period_id=period_id)\nORDER BY bankaccnt_name;\n \N      \N      0
106019
 
472     desktop messageHistory   Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  messageHistory\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  msg_id, \n  msg_posted AS sent,\n  CASE WHEN (msg_username = geteffectivextuser()) THEN 'me'\n       ELSE msg_username END AS from,\n  msg_text AS message,\n  CASE WHEN msguser_username = geteffectivextuser() THEN 'me'\n       ELSE msguser_username END AS to\nFROM msg a\nLEFT OUTER JOIN msguser ab ON a.msg_id = ab.msguser_msg_id\nWHERE (a.msg_username = geteffectivextuser())\n\nUNION\n\nSELECT \n  msg_id, \n  msg_posted AS sent,\n  CASE WHEN (msg_username = geteffectivextuser()) THEN 'me'\n       ELSE msg_username END AS from,\n  msg_text AS message,\n  CASE WHEN msguser_username = geteffectivextuser() THEN 'me'\n       ELSE msguser_username END AS to\nFROM msg c\nLEFT OUTER JOIN msguser cd ON c.msg_id = cd.msguser_msg_id\nWHERE (cd.msguser_username = geteffectivextuser())\n\nORDER BY msg_id DESC\nLIMIT <? value("limit") ?>\n     \N      \N      0
106020
 
213     desktop mfgAct   Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  mfgAct\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("planned") ?> \nSELECT 'L' AS activity, <? value("planned") ?> AS activity_qtdisplayrole, 0 AS seq,\n  COUNT(planord_id) AS count, COALESCE(sum(stdcost(item_id) * planord_qty),0) AS amount, \n  sum(planord_qty) AS qty,\n  'curr' AS amount_xtnumericrole, 'qty' AS qty_xtnumericrole\nFROM planord\n  JOIN itemsite ON (planord_itemsite_id = itemsite_id)\n  JOIN item ON (itemsite_item_id = item_id)\nWHERE (planord_type = 'W')\nHAVING (COUNT(planord_id) > 0)\nUNION\n<? endif ?>\nSELECT 'O' AS activity, <? value("open") ?> AS activity_qtdisplayrole, 4 AS seq,   \n  COUNT(wo_id) AS count, \n  SUM(round((wo_qtyord - wo_qtyrcv) * stdcost(itemsite_item_id),2)) AS amount, \n  SUM(wo_qtyord - wo_qtyrcv) AS qty,\n  'curr' AS amount_xtnumericrole, 'qty' AS qty_xtnumericrole\nFROM wo\n  JOIN itemsite ON (wo_itemsite_id=itemsite_id)\nWHERE (wo_status = 'O')\nHAVING (COUNT(wo_id) > 0)\nUNION ALL\nSELECT 'E' AS activity, <? value("exploded") ?> AS activity_qtdisplayrole, 4 AS seq,   \n  COUNT(wo_id) AS count, \n  SUM(round((wo_qtyord - wo_qtyrcv) * stdcost(itemsite_item_id),2)) AS amount, \n  SUM(wo_qtyord - wo_qtyrcv) AS qty,\n  'curr' AS amount_xtnumericrole, 'qty' AS qty_xtnumericrole\nFROM wo\n  JOIN itemsite ON (wo_itemsite_id=itemsite_id)\nWHERE (wo_status = 'E')\nHAVING (COUNT(wo_id) > 0)\nUNION ALL\nSELECT 'R' AS activity, <? value("released") ?> AS activity_qtdisplayrole, 4 AS seq,   \n  COUNT(wo_id) AS count, \n  SUM(round((wo_qtyord - wo_qtyrcv) * stdcost(itemsite_item_id),2)) AS amount, \n  SUM(wo_qtyord - wo_qtyrcv) AS qty,\n  'curr' AS amount_xtnumericrole, 'qty' AS qty_xtnumericrole\nFROM wo\n  JOIN itemsite ON (wo_itemsite_id=itemsite_id)\nWHERE (wo_status = 'R')\nHAVING (COUNT(wo_id) > 0)\nUNION ALL\nSELECT 'I' AS activity, <? value("inprocess") ?> AS activity_qtdisplayrole, 4 AS seq,   \n  COUNT(wo_id) AS count, \n  SUM(round((wo_qtyord - wo_qtyrcv) * stdcost(itemsite_item_id),2)) AS amount, \n  SUM(wo_qtyord - wo_qtyrcv) AS qty,\n  'curr' AS amount_xtnumericrole, 'qty' AS qty_xtnumericrole\nFROM wo\n  JOIN itemsite ON (wo_itemsite_id=itemsite_id)\nWHERE (wo_status = 'I')\nHAVING (COUNT(wo_id) > 0)\nORDER BY seq;\n \N      \N      0
106021
 
215     desktop mfgOpen  Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  mfgOpen\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT wo_id,\n       CASE WHEN (wo_ordid IS NULL) THEN -1\n            ELSE wo_ordid\n       END AS orderid, wo_status,\n       CASE WHEN (wo_status = 'E') THEN <? value("exploded") ?>\n         WHEN (wo_status = 'I') THEN <? value("inprocess") ?>\n         WHEN (wo_status = 'R') THEN <? value("released") ?>\n         WHEN (wo_status = 'O') THEN <? value("open") ?>\n       END AS wo_status_qtdisplayrole, \n       warehous_code, uom_name,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       wo_qtyord, wo_qtyrcv, wo_startdate, wo_duedate,\n       wo_number::TEXT || '-' || wo_subnumber::TEXT AS wonumber,\n       wo_postedvalue, wo_wipvalue,\n       'qty' AS wo_qtyord_xtnumericrole,\n       'qty' AS wo_qtyrcv_xtnumericrole,\n       'curr' AS wo_postedvalue_xtnumericrole,\n       'curr' AS wo_wipvalue_xtnumericrole,\n       CASE WHEN ((wo_startdate<=CURRENT_DATE) AND (wo_status IN ('O','E','S','R'))) THEN 'error'\n       END AS wo_startdate_qtforegroundrole,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error'\n       END AS wo_duedate_qtforegroundrole,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'Overdue'\n            ELSE 'On Time'\n       END AS condition,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error' END AS condition_qtforegroundrole\nFROM wo\n  JOIN itemsite ON (wo_itemsite_id=itemsite_id)\n  JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n  JOIN item ON (itemsite_item_id=item_id)\n  JOIN uom ON (item_inv_uom_id=uom_id)\nWHERE (wo_status != 'C')\nORDER BY wo_number, wo_subnumber;\n     \N      \N      0
106022
 
217     desktop pkgItems         Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  pkgItems\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\nSELECT *,\n       CASE WHEN pkgitem_type='P' THEN <? value("package") ?>\n            WHEN pkgitem_type='C' THEN <? value("script") ?>\n            WHEN pkgitem_type='D' THEN <? value("cmd") ?>\n            WHEN pkgitem_type='F' THEN <? value("procedure") ?>\n            WHEN pkgitem_type='G' THEN <? value("trigger") ?>\n            WHEN pkgitem_type='I' THEN <? value("image") ?>\n            WHEN pkgitem_type='M' THEN <? value("metasql") ?>\n            WHEN pkgitem_type='P' THEN <? value("priv") ?>\n            WHEN pkgitem_type='R' THEN <? value("report") ?>\n            WHEN pkgitem_type='S' THEN <? value("schema") ?>\n            WHEN pkgitem_type='T' THEN <? value("table") ?>\n            WHEN pkgitem_type='U' THEN <? value("uiform") ?>\n            WHEN pkgitem_type='V' THEN <? value("view") ?>\n            WHEN pkgitem_type='L' THEN <? value("folder") ?>\n            WHEN pkgitem_type='B' THEN <? value("database") ?>\n            WHEN pkgitem_type='C' THEN <? value("client") ?>\n       ELSE pkgitem_type END AS pkgitem_type_qtdisplayrole\nFROM (\n------ PACKAGE ------\nSELECT pkghead_id AS pkgitem_id, 0 AS seq,\n       0 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'P'::text AS pkgitem_type,\n       pkghead_name AS pkgitem_name,\n       pkghead_descrip AS pkgitem_descrip\n  FROM pkghead\nUNION\n\n------ CLIENT ------\nSELECT pkghead_id AS pkgitem_id, 1 AS seq,\n       1 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'L'::text AS pkgitem_type,\n       <? value("client") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION\n------ COMMANDS ------\nSELECT pkghead_id AS pkgitem_id, 2 AS seq,\n       2 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'L'::text AS pkgitem_type,\n       <? value("cmd") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION \nSELECT cmd_id AS pkgitem_id, 3 AS seq,\n       3 AS xtindentrole,\n       nspname AS pkgname,\n       'D' AS pkgitem_type,\n       cmd_name AS pkgitem_name,\n       cmd_descrip AS pkgitem_descrip \n  FROM cmd\n    JOIN pg_class ON (cmd.tableoid=pg_class.oid)\n    JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION\n------ IMAGES ------\nSELECT pkghead_id AS pkgitem_id, 4 AS seq,\n       2 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'L'::text AS pkgitem_type,\n       <? value("image") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION \nSELECT image_id AS pkgitem_id, 5 AS seq,\n       3 AS xtindentrole,\n       nspname AS pkgname,\n       'I'::text AS pkgitem_type,\n       image_name AS pkgitem_name,\n       image_descrip AS pkgitem_descrip \n  FROM image\n    JOIN pg_class ON (image.tableoid=pg_class.oid)\n    JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION \n------ METASQL ------\nSELECT pkghead_id AS pkgitem_id, 6 AS seq,\n       2 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'L'::text AS pkgitem_type,\n       <? value("metasql") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION\nSELECT metasql_id AS pkgitem_id, 7 AS seq,\n       3 AS xtindentrole,\n       nspname AS pkgname,\n       'M' AS pkgitem_type,\n       metasql_group || '-' || metasql_name AS pkgitem_name,\n       metasql_notes AS pkgitem_descrip \n  FROM metasql\n    JOIN pg_class ON (metasql.tableoid=pg_class.oid)\n    JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION\n------ PRIVILEGES ------\nSELECT pkghead_id AS pkgitem_id, 8 AS seq,\n       2 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'L'::text AS pkgitem_type,\n       <? value("priv") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION\nSELECT priv_id AS pkgitem_id, 9 AS seq,\n       3 AS xtindentrole,\n       nspname AS pkgname,\n       'P' AS pkgitem_type,\n       priv_module || '.' || priv_name AS pkgitem_name,\n       priv_descrip AS pkgitem_descrip \n  FROM priv\n    JOIN pg_class ON (priv.tableoid=pg_class.oid)\n    JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION \n------ REPORTS ------\nSELECT pkghead_id AS pkgitem_id, 10 AS seq,\n       2 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'L'::text AS pkgitem_type,\n       <? value("report") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION\nSELECT report_id AS pkgitem_id, 11 AS seq,\n       3 AS xtindentrole,\n       nspname AS pkgname,\n       'R' AS pkgitem_type,\n       report_name AS pkgitem_name,\n       report_descrip AS pkgitem_descrip \n  FROM report\n    JOIN pg_class ON (report.tableoid=pg_class.oid)\n    JOIN pg_namespace ON (relnamespace=pg_namespace.oid) \nUNION\n------ SCRIPTS ------\nSELECT pkghead_id AS pkgitem_id, 12 AS seq,\n       2 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'L'::text AS pkgitem_type,\n       <? value("script") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION\nSELECT script_id AS pkgitem_id, 13 AS seq,\n       3 AS xtindentrole,\n       nspname AS pkgname,\n       'C'::text AS pkgitem_type,\n       script_name AS pkgitem_name,\n       script_notes AS pkgitem_descrip\n  FROM script\n    JOIN pg_class ON (script.tableoid=pg_class.oid)\n    JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION\n------ SCREENS ------\nSELECT pkghead_id AS pkgitem_id, 14 AS seq,\n       2 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'L'::text AS pkgitem_type,\n       <? value("uiform") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION\nSELECT uiform_id AS pkgitem_id, 15 AS seq,\n       3 AS xtindentrole,\n       nspname AS pkgname,\n       'U'::text AS pkgitem_type,\n       uiform_name AS pkgitem_name,\n       uiform_notes AS pkgitem_descrip\n  FROM uiform\n    JOIN pg_class ON (uiform.tableoid=pg_class.oid)\n    JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION\n------ DATABASE ------\nSELECT pkghead_id AS pkgitem_id, 20 AS seq, \n       1 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'B'::text AS pkgitem_type,\n       <? value("database") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION\n------ FUNCTIONS ------\nSELECT pkghead_id AS pkgitem_id, 21 AS seq,\n       2 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'L'::text AS pkgitem_type,\n       <? value("procedure") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION\nSELECT pg_proc.oid AS pkgitem_id, 22 AS seq,\n       3 AS xtindentrole,\n       nspname AS pkgname,\n       'F' AS pkgitem_type,\n       proname || '(' || oidvectortypes(proargtypes)\n               || ')' AS pkgitem_name,\n       pg_catalog.obj_description(pg_proc.oid, 'pg_proc') AS pkgitem_descrip \n  FROM pg_proc\n       JOIN pg_namespace ON (pronamespace=pg_namespace.oid)\nUNION\n------ SCHEMA ------\nSELECT pkghead_id AS pkgitem_id, 27 AS seq,\n       2 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'L'::text AS pkgitem_type,\n       <? value("schema") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION\nSELECT n.oid AS pkgitem_id, 28 AS seq,\n       3 AS xtindentrole,\n       nspname AS pkgname,\n       'S' AS pkgitem_type,\n       nspname AS pkgitem_name,\n       pg_catalog.obj_description(n.oid, 'pg_namespace') AS pkgitem_descrip \n  FROM pg_namespace n\nUNION\n------ TABLES ------\nSELECT pkghead_id AS pkgitem_id, 29 AS seq,\n       2 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'L'::text AS pkgitem_type,\n       <? value("table") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION\nSELECT c.oid AS pkgitem_id, 30 AS seq,\n       3 AS xtindentrole,\n       nspname AS pkgname,\n       'T' AS pkgitem_type,\n       relname AS pkgitem_name,\n       pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n  FROM pg_class c\n       JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((relkind='r')\n   AND  (relname !~ '^pkg(cmd(arg)?|image|metasql|priv|report|script|uiform)$'))\nUNION\n------ TRIGGERS ------\nSELECT pkghead_id AS pkgitem_id, 31 AS seq,\n       2 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'L'::text AS pkgitem_type,\n       <? value("trigger") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION\nSELECT 0 AS pkgitem_id, 32 AS seq,\n       3 AS xtindentrole,\n       trigger_schema AS pkgname,\n       'G' AS pkgitem_type,\n       trigger_name AS pkgitem_name,\n       event_object_table AS pkgitem_descrip \n  FROM information_schema.triggers\n WHERE (trigger_name !~ '^pkg(cmd(arg)?|image|metasql|priv|report|script|uiform)')\nUNION\n------ VIEWS ------\nSELECT pkghead_id AS pkgitem_id, 33 AS seq,\n       2 AS xtindentrole,\n       pkghead_name AS pkgname,\n       'L'::text AS pkgitem_type,\n       <? value("view") ?> AS pkgitem_name,\n       '' AS pkgitem_descrip\n  FROM pkghead\nUNION\nSELECT c.oid AS pkgitem_id, 34 AS seq,\n       3 AS xtindentrole,\n       nspname AS pkgname,\n       'V' AS pkgitem_type,\n       relname AS pkgitem_name,\n       pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n  FROM pg_class c\n       JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((relkind='v'))\n) AS pkgitem \nWHERE (pkgname NOT IN ('api','public','pg_catalog'))\nORDER BY pkgname, seq, pkgitem_type_qtdisplayrole, pkgitem_name;\n     \N      \N      0
106023
 
218     desktop purchAct         Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  purchAct\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("planned") ?> \nSELECT 'L' AS activity, <? value("planned") ?> AS activity_qtdisplayrole, 0 AS seq,\n  COUNT(planord_id) AS count, COALESCE(sum(stdcost(item_id) * planord_qty),0) AS amount, \n  'curr' AS amount_xtnumericrole\nFROM planord\n  JOIN itemsite ON (planord_itemsite_id = itemsite_id)\n  JOIN item ON (itemsite_item_id = item_id)\nWHERE (planord_type = 'P')\nHAVING (COUNT(planord_id) > 0)\nUNION\n<? endif ?>\nSELECT 'Q' AS activity, <? value("request") ?> AS activity_qtdisplayrole, 2 AS seq,\n  COUNT(pr_id) AS count, COALESCE(sum(stdcost(item_id) * pr_qtyreq),0) AS amount, \n  'curr' AS amount_xtnumericrole\nFROM pr\n  JOIN itemsite ON (pr_itemsite_id = itemsite_id)\n  JOIN item ON (itemsite_item_id = item_id)\nHAVING (COUNT(pr_id) > 0)\nUNION\nSELECT 'U' AS activity, <? value("unreleased") ?> AS activity_qtdisplayrole, 3 AS seq,   \n  COUNT(pohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n  (SELECT pohead_id,\n    SUM(round((noNeg(poitem_qty_ordered - poitem_qty_received + poitem_qty_returned)) *            \n        currToBase(pohead_curr_id, poitem_unitprice, pohead_orderdate), 2) ) AS amount\n     FROM poitem\n       JOIN pohead ON (poitem_pohead_id=pohead_id)\n     WHERE (pohead_status = 'U')\n   GROUP BY pohead_id) data\nHAVING (COUNT(pohead_id) > 0)\nUNION\nSELECT 'O' AS activity, <? value("open") ?> AS activity_qtdisplayrole, 4 AS seq,   \n  COUNT(pohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n  (SELECT pohead_id,\n    SUM(round((noNeg(poitem_qty_ordered - poitem_qty_received + poitem_qty_returned)) *            \n        currToBase(pohead_curr_id, poitem_unitprice, pohead_orderdate), 2) ) AS amount\n     FROM poitem\n       JOIN pohead ON (poitem_pohead_id=pohead_id)\n     WHERE (pohead_status = 'O')\n   GROUP BY pohead_id) data\nHAVING (COUNT(pohead_id) > 0)\nUNION\nSELECT 'A' AS activity, <? value("receiving") ?> AS activity_qtdisplayrole, 5 AS seq,   \n  COUNT(recv_id) AS count, COALESCE(sum(recv_value),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM recv\nWHERE (NOT recv_posted)\nHAVING (COUNT(recv_id) > 0)\nUNION\nSELECT 'V' AS activity, <? value("received") ?> AS activity_qtdisplayrole, 6 AS seq,   \n  COUNT(recv_id) AS count, COALESCE(sum(recv_value),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM recv\nWHERE ((recv_posted)\n  AND (NOT recv_invoiced)\n  AND (recv_vohead_id IS NULL)\n  AND (recv_order_type = 'PO'))\nHAVING (COUNT(recv_id) > 0)\nUNION\nSELECT 'I' AS activity, <? value("vouchered") ?> AS activity_qtdisplayrole, 7 AS seq,   \n  COUNT(vohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n  (SELECT vohead_id,\n    SUM(round(currToBase(vohead_curr_id, vodist_amount, vohead_docdate), 2) ) AS amount\n     FROM vohead\n       JOIN vodist ON (vodist_vohead_id=vohead_id)\n     WHERE ((vohead_pohead_id != -1)\n       AND (NOT vohead_posted))\n   GROUP BY vohead_id) data\nHAVING (COUNT(vohead_id) > 0)\nORDER BY seq;\n   \N      \N      0
106024
 
219     desktop purchHist       Summarized Purchase History for Desktop Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: desktop\n-- Name:  purchHist\n-- Notes: Summarized Purchase History for Desktop\n--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\n--------- VARIANCES -----------\n<? if exists("variances") ?> \nSELECT <? literal("group_id") ?>, <? literal("group_number") ?>,  <? literal("group_name") ?>,\n  sum(qty) AS qty, sum(amount) AS amount,\n  'curr' AS amount_xtnumericrole,\n  'qty' AS qty_xtnumericrole,\n   0 AS amount_xttotalrole,\n   0 AS qty_xttotalrole\nFROM (\nSELECT vend_id, vend_number, vend_name,\n       pohead_agent_username, usr_propername,\n       COALESCE(item_id,-2) AS item_id,\n       COALESCE(item_number,<? value("nonInv") ?>) AS item_number,\n       item_descrip1,\n       recv_qty AS qty, \n       currToBase(vohead_curr_id, sum(vodist_amount) / sum(vodist_qty), vohead_distdate) * recv_qty - recv_value AS amount\nFROM recv\n  JOIN vendinfo ON (recv_vend_id=vend_id)\n  LEFT OUTER JOIN itemsite ON (recv_itemsite_id=itemsite_id)\n  LEFT OUTER JOIN item     ON (itemsite_item_id=item_id)\n  JOIN vodist ON ((vodist_poitem_id=recv_orderitem_id) \n              AND (vodist_vohead_id=recv_vohead_id))\n  JOIN vohead ON ((vodist_vohead_id=vohead_id) \n              AND (vohead_posted))\n  JOIN poitem ON (recv_orderitem_id=poitem_id)\n  JOIN pohead ON (poitem_pohead_id=pohead_id)\n  LEFT OUTER JOIN usr ON (pohead_agent_username=usr_username)\nWHERE (vohead_distdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>\n   AND (recv_order_type='PO'))\nGROUP BY recv_qty, recv_value, vohead_curr_id, vohead_distdate,\n  vend_id, vend_number, vend_name,\n  pohead_agent_username, usr_propername,\n  item_id, item_number, item_descrip1\n) data\nWHERE (amount > 0)\nGROUP BY <? literal("group_id") ?>, <? literal("group_number") ?>, <? literal("group_name") ?>\n\n--------- RECEIPTS -------\n<? elseif exists("receipts") ?> \nSELECT <? literal("group_id") ?>, <? literal("group_number") ?>,  <? literal("group_name") ?>,\n       sum(amount) as amount, sum(qty) AS qty,\n       'curr' AS amount_xtnumericrole,\n       'qty' AS qty_xtnumericrole,\n       0 AS amount_xttotalrole,\n       0 AS qty_xttotalrole\nFROM (\n  SELECT vend_id, vend_number, vend_name,\n         pohead_agent_username, usr_propername,\n         COALESCE(item_id,-2) AS item_id, COALESCE(item_number,<? value("nonInv") ?>) AS item_number,\n         item_descrip1,\n         coalesce(recv_value,0) AS amount,\n         recv_qty AS qty\n  FROM recv\n    JOIN vendinfo ON (vend_id=recv_vend_id)\n    LEFT OUTER JOIN itemsite ON (recv_itemsite_id=itemsite_id)\n    LEFT OUTER JOIN item     ON (itemsite_item_id=item_id)\n    JOIN poitem ON (recv_orderitem_id=poitem_id)\n    JOIN pohead ON (poitem_pohead_id=pohead_id)\n    LEFT OUTER JOIN usr ON (pohead_agent_username=usr_username)\n  WHERE ((recv_date::date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    AND (recv_posted)\n    AND (recv_order_type = 'PO'))\n  UNION ALL\n  SELECT vend_id, vend_number, vend_name,\n         pohead_agent_username, usr_propername,\n         COALESCE(item_id,-1) AS item_id, COALESCE(item_number,<? value("nonInv") ?>) AS item_number,\n         item_descrip1,\n         coalesce(poreject_value,0) * -1 AS amount,\n         poreject_qty * -1 AS qty\n  FROM poreject\n    JOIN vendinfo ON (vend_id=poreject_vend_id)\n    JOIN itemsite ON (itemsite_id=poreject_itemsite_id)\n    JOIN item ON (item_id=itemsite_item_id)\n    JOIN poitem ON (poreject_poitem_id=poitem_id)\n    JOIN pohead ON (poitem_pohead_id=pohead_id)\n    LEFT OUTER JOIN usr ON (pohead_agent_username=usr_username)\n  WHERE ((poreject_date::date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    AND (poreject_posted))\n) data\nGROUP BY <? literal("group_id") ?>, <? literal("group_number") ?>, <? literal("group_name") ?>\nORDER BY <? literal("group_number") ?>\n;\n<? endif ?>\n   \N      \N      0
106025
 
220     desktop purchOpen        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  purchOpen\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_id, pohead_number, vend_number, vend_name, pohead_shipvia, \n  formatCntctName(pohead_vend_cntct_honorific, \n                  pohead_vend_cntct_first_name, \n                  pohead_vend_cntct_middle, \n                  pohead_vend_cntct_last_name, \n                  pohead_vend_cntct_suffix) AS vend_cntct, \n  pohead_vend_cntct_phone,\n  formatCntctName(pohead_shipto_cntct_honorific, \n                  pohead_shipto_cntct_first_name, \n                  pohead_shipto_cntct_middle, \n                  pohead_shipto_cntct_last_name, \n                  pohead_shipto_cntct_suffix) AS shipto_cntct, \n  pohead_shipto_cntct_phone,\n  min(poitem_duedate)  AS duedate, pohead_status AS status,\n  CASE WHEN (pohead_status = 'O') THEN <? value("open") ?>\n  ELSE <? value("unreleased") ?> END AS status_qtdisplayrole,\n  SUM(round(noNeg(poitem_qty_ordered - poitem_qty_received + poitem_qty_returned) *            \n        currToBase(pohead_curr_id, poitem_unitprice, pohead_orderdate), 2) ) AS amount,\n  CASE WHEN (min(poitem_duedate) <= current_date) THEN 'error' \n  ELSE 'emphasis' END AS duedate_qtforegroundrole,\n  'curr' AS amount_xtnumericrole\nFROM pohead \n  JOIN vendinfo ON (pohead_vend_id=vend_id) \n  JOIN poitem ON (poitem_pohead_id=pohead_id) \nWHERE (poitem_status IN ('U','O'))\nGROUP BY pohead_id, pohead_number, pohead_status, vend_number, vend_name, pohead_shipvia, pohead_vend_cntct_id, \n  pohead_shipto_cntct_id, pohead_vend_cntct_phone, pohead_shipto_cntct_phone, pohead_vend_cntct_honorific,   \n  pohead_vend_cntct_first_name,  pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix,\n  pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, \n  pohead_shipto_cntct_suffix\nORDER BY pohead_number;\t\n      \N      \N      0
106026
 
222     desktop salesAct         Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  salesAct\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT 'Q' AS activity, <? value("quotes") ?> AS activity_qtdisplayrole, 0 AS seq,\n  COUNT(quhead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole   \nFROM \n (SELECT quhead_id,\n    SUM(round((noNeg(quitem_qtyord) * quitem_qty_invuomratio) *            \n        (currToBase(quhead_curr_id, quitem_price, quhead_quotedate) / quitem_price_invuomratio), 2) ) AS amount\n     FROM quitem\n       JOIN quhead ON (quitem_quhead_id=quhead_id)\n     WHERE ( COALESCE(quhead_expire,current_date + 1) > current_date\n       AND   quhead_status != 'C'  )\n   GROUP BY quhead_id) data\nHAVING (COUNT(quhead_id) > 0)\nUNION \nSELECT 'O' AS activity, <? value("open") ?> AS activity_qtdisplayrole,  1 AS seq,   \n  COUNT(cohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n  (SELECT cohead_id,\n    SUM(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *            \n        (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) ) AS amount\n     FROM coitem\n       JOIN cohead ON (coitem_cohead_id=cohead_id)\n     WHERE ( coitem_status = 'O' )\n   GROUP BY cohead_id) data\nHAVING (COUNT(cohead_id) > 0)\nUNION\nSELECT 'P' AS activity, <? value("print") ?> AS activity_qtdisplayrole, 2 AS seq,   \n  COUNT(cohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n  (SELECT cohead_id,\n    SUM(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *            \n        (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) ) AS amount\n     FROM coitem\n       JOIN cohead ON (coitem_cohead_id=cohead_id)\n       JOIN pack ON ((pack_head_type='SO')\n                 AND (pack_head_id=cohead_id))\n     WHERE ( (coitem_status = 'O')\n      AND (NOT pack_printed) )\n   GROUP BY cohead_id) data\nHAVING (COUNT(cohead_id) > 0)\nUNION\nSELECT 'S' AS activity, <? value("ship") ?> AS activity_qtdisplayrole, 3 AS seq,   \n  COUNT(cohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n  (SELECT cohead_id,\n    SUM(round((shipitem_qty * coitem_qty_invuomratio) *            \n        (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) ) AS amount\n     FROM coitem\n       JOIN cohead ON (coitem_cohead_id=cohead_id)\n       JOIN shipitem ON (shipitem_orderitem_id=coitem_id)\n       JOIN shiphead ON ((shiphead_order_type='SO')\n                    AND (shipitem_shiphead_id=shiphead_id))\n     WHERE ( (coitem_status = 'O')\n      AND (NOT shiphead_shipped) )\n   GROUP BY cohead_id) data\nHAVING (COUNT(cohead_id) > 0)\nUNION\nSELECT 'B' AS activity, <? value("bill") ?> AS activity_qtdisplayrole, 4 AS seq,   \n  COUNT(cohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n  (SELECT cohead_id,\n     CASE WHEN ( \n      -- For kits only when entire kit has shipped\n      item_type != 'K' OR NOT coitem_id IN (\n        SELECT sub.coitem_id\n          FROM coitem sub\n         WHERE((sub.coitem_cohead_id=coitem_cohead_id)\n           AND (sub.coitem_linenumber=coitem_linenumber)\n           AND (sub.coitem_subnumber > 0)\n           AND ((sub.coitem_qtyord - sub.coitem_qtyshipped + sub.coitem_qtyreturned) > 0))\n      )) THEN\n      -- Total shipped not invoiced minus any already selected for billing not invoiced\n      SUM(round(((shipitem_qty -\n      COALESCE((SELECT sum(cobill_qty) \n                FROM cobill \n                WHERE ((cobill_coitem_id=coitem_id \n                  AND (cobill_invcitem_id IS NULL)\n                  ))),0) \n       * coitem_qty_invuomratio) *            \n          (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio)),2))\n     ELSE 0\n     END AS amount\n     FROM coitem\n       JOIN itemsite ON (coitem_itemsite_id=itemsite_id)\n       JOIN item ON (itemsite_item_id=item_id)\n       JOIN cohead ON (coitem_cohead_id=cohead_id)\n       JOIN custinfo ON (cust_id=cohead_cust_id)\n       JOIN shipitem ON (shipitem_orderitem_id=coitem_id)\n       JOIN shiphead ON ((shiphead_order_type='SO')\n                 AND (shiphead_id=shipitem_shiphead_id))\n     WHERE ( (coitem_cohead_id=cohead_id)\n      AND (coitem_status = 'O')\n      AND (shiphead_shipped)\n      AND (NOT shipitem_invoiced)\n      AND (shipitem_qty > COALESCE((SELECT sum(cobill_qty)\n                                    FROM cobill\n                                    WHERE cobill_coitem_id=coitem_id AND cobill_invcitem_id IS NULL), 0)) )\n   GROUP BY cohead_id, coitem_id, coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned, \n            cust_partialship, item_type) data\nHAVING (COUNT(cohead_id) > 0)\nUNION\nSELECT 'I' AS activity, <? value("invoice") ?> AS activity_qtdisplayrole, 5 AS seq,   \n  COUNT(cohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n  (SELECT cohead_id,\n    SUM(round((cobill_qty * coitem_qty_invuomratio) *            \n        (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) ) AS amount\n     FROM coitem\n       JOIN cohead ON (coitem_cohead_id=cohead_id)\n       JOIN cobill ON (cobill_coitem_id=coitem_id)\n     WHERE ( (coitem_status = 'O')\n      AND (cobill_invcitem_id IS NULL) )\n   GROUP BY cohead_id) data\nHAVING (COUNT(cohead_id) > 0)\nUNION\nSELECT 'T' AS activity, <? value("post") ?> AS activity_qtdisplayrole, 5 AS seq,   \n  COUNT(invchead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n  (SELECT invchead_id,\n    SUM(round((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / COALESCE(invcitem_price_invuomratio,1)),2)\n ) AS amount\n     FROM invcitem\n       JOIN invchead ON (invcitem_invchead_id=invchead_id)\n     WHERE ( NOT invchead_posted )\n   GROUP BY invchead_id) data\nHAVING (COUNT(invchead_id) > 0)\nORDER BY seq;\n  \N      \N      0
106027
 
224     desktop salesOpen        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  salesOpen\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohead_id, cohead_number, cust_number, cohead_shipvia, \n  cohead_billtoname, \n  formatCntctName(cohead_billto_cntct_honorific, \n                  cohead_billto_cntct_first_name, \n                  cohead_billto_cntct_middle, \n                  cohead_billto_cntct_last_name, \n                  cohead_billto_cntct_suffix) AS billto_cntct, \n  cohead_billto_cntct_phone,\n  cohead_shiptoname, \n  formatCntctName(cohead_shipto_cntct_honorific, \n                  cohead_shipto_cntct_first_name, \n                  cohead_shipto_cntct_middle, \n                  cohead_shipto_cntct_last_name, \n                  cohead_shipto_cntct_suffix) AS shipto_cntct, \n  cohead_shipto_cntct_phone,\n  min(coitem_scheddate) AS scheddate, \n  sum(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *            \n     (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) ) AS amount,\n  CASE WHEN (min(coitem_scheddate) <= current_date) THEN 'error' \n  ELSE 'emphasis' END AS scheddate_qtforegroundrole,\n  'curr' AS amount_xtnumericrole\nFROM cohead \n  JOIN custinfo ON (cohead_cust_id=cust_id) \n  JOIN coitem ON (coitem_cohead_id=cohead_id) \n  JOIN itemsite ON (coitem_itemsite_id=itemsite_id) \n  JOIN whsinfo ON (itemsite_warehous_id=warehous_id) \nWHERE (coitem_status='O')\nGROUP BY cohead_shipvia, cohead_billtoname, cohead_billto_cntct_id, cohead_billto_cntct_phone, \n  cohead_shiptoname, cohead_shipto_cntct_id, cohead_shipto_cntct_phone, cohead_id, cohead_number, \n  cust_number, cohead_billtoname, cohead_shiptoname, \n  cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, \n  cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix,\n  cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, \n  cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix\nORDER BY cohead_number;\n \N      \N      0
106028
 
473     desktop sendMessageToUser       User Message query. Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: desktop\n-- Name:  sendMessageToUser\n-- Notes: User Message query.\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \npostmessage(\n( SELECT usr_username FROM usr WHERE usr_id = <? value("usr_id") ?>),\n <? value("message") ?>\n            );\n       \N      \N      0
106029
 
225     desktop todoDelete       Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  todoDelete\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM todoitem WHERE (todoitem_id=<? value("todoitem_id") ?>);\n  \N      \N      0
106030
 
226     desktop todoList        Select the list of activities that need attention including to-do items, incidents, tasks, and projects. Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  todoList\n-- Notes: Select the list of activities that need attention\n--        including to-do items, incidents, tasks, and projects.\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n------ TO DO ITEMS-------\n  SELECT todoitem_id AS id, 1 AS altId, todoitem_owner_username AS owner, \n         <? value("todo") ?> AS type, incdtpriority_order AS seq,\n         incdtpriority_name AS priority, \n         todoitem_name AS name, \n         firstLine(todoitem_description) AS descrip, \n         todoitem_status AS status, todoitem_start_date as start, \n         todoitem_due_date AS due, \n         todoitem_username AS usr, CAST(incdt_number AS text) AS number,\n         crmacct_number, crmacct_name, \n         cust_number AS cust,\n         CASE WHEN (todoitem_status != 'C'AND \n                    todoitem_due_date < CURRENT_DATE) THEN 'expired'\n              WHEN (todoitem_status != 'C'AND \n                    todoitem_due_date > CURRENT_DATE) THEN 'future'\n         END AS due_qtforegroundrole \n    FROM todoitem LEFT OUTER JOIN incdt ON (incdt_id=todoitem_incdt_id) \n                  LEFT OUTER JOIN crmacct ON (crmacct_id=todoitem_crmacct_id) \n                  LEFT OUTER JOIN custinfo ON (cust_id=crmacct_cust_id) \n                  LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=todoitem_priority_id) \n   WHERE ((todoitem_active)\n      AND (todoitem_status != 'C')\n      AND ((todoitem_owner_username=<? value("owner_username") ?>) \n      OR (todoitem_username=<? value("assigned_username") ?>))) \n  UNION \n------ INCIDENTS ------\n  SELECT incdt_id AS id, 2 AS altId, incdt_owner_username AS owner, \n         <? value("incident") ?> AS type, incdtpriority_order AS seq,\n         incdtpriority_name AS priority, \n         incdt_summary AS name, \n         firstLine(incdt_descrip) AS descrip, \n         incdt_status AS status, CAST(incdt_timestamp AS date) AS start, \n         null AS due, \n         incdt_assigned_username AS usr, CAST(incdt_number AS text) AS number,\n         crmacct_number, crmacct_name,\n         cust_number AS cust, \n         NULL AS due_qtforegroundrole \n    FROM incdt LEFT OUTER JOIN crmacct ON (crmacct_id=incdt_crmacct_id) \n               LEFT OUTER JOIN custinfo ON (cust_id=crmacct_cust_id) \n               LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=incdt_incdtpriority_id) \n   WHERE ((incdt_status != 'L')\n      AND ((incdt_owner_username=<? value("owner_username") ?>) \t  \n      OR (incdt_assigned_username=<? value("assigned_username") ?>)))\n------ TASKS ------\n   UNION \n    SELECT prjtask_id AS id, 3 AS altId, prjtask_owner_username AS owner, \n           <? value("task") ?> AS type, NULL AS seq, NULL AS priority, \n           prjtask_number || '-' || prjtask_name AS name, \n           firstLine(prjtask_descrip) AS descrip, \n           prjtask_status AS status,  prjtask_start_date AS start, \n           prjtask_due_date AS due, \n           prjtask_username AS usr, prj_number,\n           '' AS crmacct_number, '' AS crmacct_name, '' AS cust, \n           CASE WHEN (prjtask_status != 'C'AND \n                      prjtask_due_date < CURRENT_DATE) THEN 'expired'\n                WHEN (prjtask_status != 'C'AND \n                      prjtask_due_date > CURRENT_DATE) THEN 'future'\n           END AS due_qtforegroundrole \n      FROM prj, prjtask \n     WHERE((prj_id=prjtask_prj_id) \n      AND (prjtask_status != 'C')\n      AND ((prjtask_owner_username=<? value("owner_username") ?>) \n      OR (prjtask_username=<? value("assigned_username") ?>))) \n------ PROJECTS ------\n    UNION \n    SELECT prj_id AS id, 4 AS altId, prj_owner_username AS owner, \n           <? value("project") ?> AS type, NULL AS seq, NULL AS priority, \n           prj_number || '-' || prj_name AS name, \n           firstLine(prj_descrip) AS descrip, \n           prj_status AS status,  prj_start_date AS start, \n           prj_due_date AS due, \n           prj_username AS usr, NULL AS number,\n           '' AS crmacct_number, '' AS crmacct_name,'' AS cust, \n           CASE WHEN (prj_status != 'C'AND \n                      prj_due_date < CURRENT_DATE) THEN 'expired'\n                WHEN (prj_status != 'C'AND \n                      prj_due_date > CURRENT_DATE) THEN 'future'\n           END AS due_qtforegroundrole \n      FROM prj \n     WHERE ((prj_status != 'C')\n        AND ((prj_owner_username=<? value("owner_username") ?>) \n        OR (prj_username=<? value("assigned_username") ?>)))\nORDER BY due, seq, usr; \n       \N      \N      0
106031
 
227     desktop userOnline       Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: desktop\n-- Name:  userOnline\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT usersonline.*,\n       0 AS cnt_internal_xttotalrole,\n       0 AS cnt_external_xttotalrole\nFROM xtdesktop.usersonline();\n     \N      \N      0
106032
 
\.
106033
 
 
106034
 
 
106035
 
--
106036
 
--
106037
 
 
106038
 
COPY pkgpriv (priv_id, priv_module, priv_name, priv_descrip, priv_seq) FROM stdin;
106039
 
581     Desktop ViewExtensionsDock      Allows the user to view the Extensions dock widget on the Desktop       \N
106040
 
582     Desktop ViewGLAccountsDock      Allows the user to view Monitored General Ledger Accounts dock widget on the Desktop    \N
106041
 
583     Desktop ViewManufactureActivitiesDock   Allows the user to view the Manufacture Activities dock widget on the Desktop   \N
106042
 
584     Desktop ViewManufactureHistoryDock      Allows the user to view the Manufacture History dock widget on the Desktop      \N
106043
 
585     Desktop ViewMyAccountsDock      Allows the user to view the My (CRM) Accounts dock widget on the Desktop        \N
106044
 
586     Desktop ViewMyContactsDock      Allows the user to view the My Contact dock widget on the Desktop       \N
106045
 
587     Desktop ViewTodoDock    Allows the user to view the To Do dock widget on the Desktop    \N
106046
 
588     Desktop ViewPayablesDock        Allows the user to view the Payables dock widget on the Desktop \N
106047
 
589     Desktop ViewPurchaseActivitiesDock      Allows the user to view the Purchase Activities dock widget on the Desktop      \N
106048
 
590     Desktop ViewPurchaseHistoryDock Allows the user to view the Purchase History dock widget on the Desktop \N
106049
 
591     Desktop ViewPurchaseOrdersDock  Allows the user to view the open purchase orders dock widget on the Desktop     \N
106050
 
592     Desktop ViewReceivablesDock     Allows the user to view the Purchase History dock widget on the Desktop \N
106051
 
593     Desktop ViewSalesActivitiesDock Allows the user to view the Sales Activities dock widget on the Desktop \N
106052
 
594     Desktop ViewSalesHistoryDock    Allows the user to view the Sales History dock widget on the Desktop    \N
106053
 
595     Desktop ViewSalesOrdersDock     Allows the user to view the Sales Orders dock widget on the Desktop     \N
106054
 
596     Desktop ViewWorkOrdersDock      Allows the user to view the Work Orders dock widget on the Desktop      \N
106055
 
597     Desktop ViewUsersOnlineDock     Allows the user to view the Users Online doc    \N
106056
 
598     Desktop ViewCRMDesktop  Allows the user to view the CRM Desktop page    \N
106057
 
599     Desktop ViewSalesDesktop        Allows the user to view the Sales Desktop page  \N
106058
 
600     Desktop ViewPurchaseDesktop     Allows the user to view the Purchase Desktop page       \N
106059
 
601     Desktop ViewManufactureDesktop  Allows the user to view the Manufacture Desktop page    \N
106060
 
602     Desktop ViewAccountingDesktop   Allows the user to view the Accounting Desktop page     \N
106061
 
603     Desktop ViewMaintenanceDesktop  Allows the user to view the Maintenance Desktop page    \N
106062
 
641     Desktop viewSocialDesktop       Allows the user to view the Social Desktop page \N
106063
 
642     Desktop viewMsgHistoryDock      Allows the user to view the Message History dock widget on the Desktop  \N
106064
 
643     Desktop viewSendMsgDock Allows the user to view the Sed Message dock widget on the Desktop      \N
106065
 
640     Desktop AccessAdditionalUser    Controls access to additional Users     \N
106066
 
580     Desktop ViewBankAccountsDock    Allows the user to view the Bank Accounts dock widget on the Desktop    \N
106067
 
\.
106068
 
 
106069
 
 
106070
 
--
106071
 
--
106072
 
 
106073
 
COPY pkgreport (report_id, report_name, report_sys, report_source, report_descrip, report_grade, report_loaddate) FROM stdin;
106074
 
\.
106075
 
 
106076
 
 
106077
 
--
106078
 
--
106079
 
 
106080
 
COPY pkgscript (script_id, script_name, script_order, script_enabled, script_source, script_notes) FROM stdin;
106081
 
68      desktopNotice   0       t       /*\n * This file is part of the xtdesktop package for xTuple ERP: PostBooks edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nmydialog.accepted.connect(save)\n\nfunction save()\n{\n  preferences.set("NoDesktopNotice",!mydialog.findChild("_remind").checked)\n}\n     
106082
 
77      dockMyTodo      0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockMytodo;\nvar _todoList;\n\n/*!\n  Initializes To Do dock widget and places it in the main window.\n*/\nfunction initDockTodo()\n{\n  _dockMytodo = mainwindow.findChild("_dockMytodo");\n  _todoList = mainwindow.findChild("_todoList");\n\n  if (_todoList)\n  {\n    // Set columns on list\n    _todoList.addColumn(qsTr("Type"), XTreeWidget.userColumn, Qt.AlignCenter, true, "type");\n    _todoList.addColumn(qsTr("Priority"), XTreeWidget.userColumn, Qt.AlignLeft, false, "priority");\n    _todoList.addColumn(qsTr("Assigned To"), XTreeWidget.userColumn, Qt.AlignLeft, false, "usr");\n    _todoList.addColumn(qsTr("Name"), -1, Qt.AlignLeft, true, "name");\n    _todoList.addColumn(qsTr("Description"), -1, Qt.AlignLeft,   true, "descrip");\n    _todoList.addColumn(qsTr("Status"), XTreeWidget.statusColumn, Qt.AlignLeft, false, "status");\n    _todoList.addColumn(qsTr("Start Date"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "start");\n    _todoList.addColumn(qsTr("Due Date"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "due");\n    _todoList.addColumn(qsTr("Parent#"), XTreeWidget.orderColumn, Qt.AlignLeft, false, "number");\n    _todoList.addColumn(qsTr("Customer#"), XTreeWidget.orderColumn, Qt.AlignLeft, false, "cust");\n    _todoList.addColumn(qsTr("Account#"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "crmacct_number");\n    _todoList.addColumn(qsTr("Account Name"), 100, Qt.AlignLeft, false, "crmacct_name");\n    _todoList.addColumn(qsTr("Owner"), XTreeWidget.userColumn, Qt.AlignLeft, false,"owner");\n\n    _todoList.itemSelected.connect(openWindowToDo);\n    _todoList["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n      .connect(populateMenuToDo);\n  }\n\n\n  // Connect signals and slots\n  _dtTimer.timeout.connect(fillListSalesAct);\n\n  if (_dockMytodo)\n  {\n    _dockMytodo.visibilityChanged.connect(fillListToDo);\n\n    // Handle privilge control\n    var act = _dockMytodo.toggleViewAction();\n\n    // Don't show if no privs\n    if (!privileges.check("ViewTodoDock"))\n    {\n      _dockMytodo.hide();\n      act.enabled = false;\n    }\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewTodoDock");\n  _menuDesktop.appendAction(act);\n\n  fillListToDo();\n}\n\n/*!\n  Deletes the selected To Do item.\n*/\nfunction deleteToDo()\n{\n  var answer = QMessageBox.question(mainwindow,\n                     qsTr("Delete To Do?"),\n                     qsTr("This will permenantly delete the To Do item.  Are you sure?"),\n                     QMessageBox.Yes | QMessageBox.No,\n                     QMessageBox.Yes);\n  if(answer == QMessageBox.No)\n    return;\n\n  params = new Object;\n  params.todoitem_id = _todoList.id();\n\n  toolbox.executeDbQuery("desktop","todoDelete", params);\n  fillListToDo();\n}\n\n/*!\n  Fills the To Do list with CRM activities owned by or assigned to the current user.\n*/\nfunction fillListToDo()\n{\n  _dockMytodo = mainwindow.findChild("_dockMytodo");\n  _todoList = mainwindow.findChild("_todoList");\n\n  if (!_dockMytodo || !_dockMytodo.visible || !_todoList)\n    return;\n\n  params = new Object;\n  params.todo = qsTr("To-do");\n  params.incident = qsTr("Incident");\n  params.task = qsTr("Task");\n  params.project = qsTr("Project");\n  params.todoList = true;\n  params.incidents = true;\n  params.projects = true;\n  params.assigned_username = mainwindow.username();\n  params.owner_username = mainwindow.username();\n  _todoList = mainwindow.findChild("_todoList");\n  _todoList.populate(toolbox.executeDbQuery("desktop", "todoList", params), true);\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowToDo()\n{\n  params = new Object;\n  actId = _todoList.altId();\n  act = toDoAct(actId);\n\n  // Make sure we can open the window\n  if (!privilegeCheckToDo(act))\n    return;\n\n  // Determine which window to open\n  if (act == "D") // To Do\n  {\n    ui = "todoItem";\n    if (privileges.check("MaintainAllToDoItems") || privileges.check("MaintainPersonalToDoItems"))\n      params.mode = "edit";\n    else\n      params.mode = "view";\n    params.todoitem_id = _todoList.id();\n  }\n  else if (act == "I")\n  {\n    ui = "incident";\n    if (privileges.check("MaintainAllIncidents") || privileges.check("MaintainPersonalIncidents"))\n      params.mode = "edit";\n    else\n      params.mode = "view";\n    params.incdt_id = _todoList.id();\n  }\n  else if (act == "T")\n  {\n    ui = "task";\n    if (privileges.check("MaintainAllProjects") || privileges.check("MaintainPersonalProjects"))\n      params.mode = "edit";\n    else\n      params.mode = "view"\n    params.prjtask_id = _todoList.id();\n  }\n  else if (act == "P")\n  {\n    ui = "project";\n    if (privileges.check("MaintainAllProjects") || privileges.check("MaintainPersonalProjects"))\n      params.mode = "edit";\n    else\n      params.mode = "view";\n    params.prj_id = _todoList.id();\n  }\n\n  // Open the window and perform any special handling required\n  var newdlg = toolbox.openWindow(ui);\n  newdlg.set(params);\n  newdlg.exec()\n}\n\nfunction toDoAct(actId)\n{\n  if (actId == 1)\n    return "D";\n  else if (actId == 2)\n    return "I";\n  else if (actId == 3)\n    return "T";\n  else if (actId == 4)\n    return "P"\n\n  return "";\n}\n\n/*!\n  Adds actions to \\a pMenu, typically from a right click on My Contacts.\n*/\nfunction populateMenuToDo(pMenu)\n{\n  var act = toDoAct(_todoList.altId());\n  var menuItem;\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = privilegeCheckToDo(act);\n  \n  menuItem.triggered.connect(openWindowToDo);\n\n  if (act == "D")\n  {\n    menuItem = pMenu.addAction(qsTr("Delete"));\n    menuItem.enabled = privileges.check("MaintainAllToDoItems") || \n                       privileges.check("MaintainPersonalToDoItems");\n    menuItem.triggered.connect(deleteToDo);\n  }\n}\n\n/*!\n  Returns whether user has privileges to view My Contact detail.\n*/\nfunction privilegeCheckToDo(act)\n{\n  if (act == "D") // To Do list\n    return privileges.check("MaintainAllToDoItems") || privileges.check("MaintainPersonalToDoItems") ||\n           privileges.check("ViewAllToDoItems") || privileges.check("ViewPersonalToDoItems");\n  else if (act == "I") // Incidents\n    return privileges.check("MaintainAllIncidents") || privileges.check("MaintainPersonalIncidents") ||\n           privileges.check("ViewAllIncidents") || privileges.check("ViewPersonalIncidents");\n  else if (act == "P" || act == "T") // Projects and Tasks\n    return privileges.check("MaintainAllProjects") || privileges.check("MaintainPersonalProjects") ||\n           privileges.check("ViewAllProjects") || privileges.check("ViewPersonalProjects");\n\n  return false;\n}\n\n    
106083
 
78      dockPayables    0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockPayables;\nvar _payables;\nvar _payablesIsDirty = true;\n\n/*!\n  Initializes Bank Balance dock widget and places it in the main window.\n*/\nfunction initDockPayables()\n{\n  _dockPayables = mainwindow.findChild("_dockPayables");\n  _ap = mainwindow.findChild("_ap");\n  _ap.rootIsDecorated = false;\n\n  // Set columns on list\n  _ap.addColumn(qsTr("Status"), -1,  Qt.AlignLeft,   true);\n  _ap.addColumn(qsTr("Balance"), -1,  Qt.AlignRight,  true);\n\n  // Connect Signals and Slots\n  _dtTimer.timeout.connect(refreshPayables);\n  mainwindow.checksUpdated.connect(refreshPayables);\n  mainwindow.paymentsUpdated.connect(refreshPayables);\n  mainwindow.vouchersUpdated.connect(refreshPayables);\n\n  _ap.itemSelected.connect(openWindowPayables);\n  _ap["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuPayables);\n\n  _dockPayables.visibilityChanged.connect(fillListPayables);\n\n  // Handle privilge control\n  var act = _dockPayables.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewPayablesDock"))\n  {\n    _dockPayables.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewPayablesDock");\n  _menuDesktop.appendAction(act);\n\n  fillListPayables();\n}\n\n/*!\n  Fills the list with bank account data.\n*/\nfunction fillListPayables()\n{\n  _dockPayables = mainwindow.findChild("_dockPayables");\n  _ap = mainwindow.findChild("_ap");\n\n  if (!_dockPayables.visible || !_payablesIsDirty)\n    return;\n\n  var q = toolbox.executeDbQuery("desktop","payables");\n  q.first();\n  \n  _ap.clear();\n  var item1 = new XTreeWidgetItem(_ap, 0, qsTr("0+ Days"), q.value("cur_val"));\n  var item2 = new XTreeWidgetItem(_ap, 1, qsTr("0-30 Days"), q.value("thirty_val"));\n  var item3 = new XTreeWidgetItem(_ap, 2, qsTr("31-60 Days"), q.value("sixty_val"));\n  var item4 = new XTreeWidgetItem(_ap, 3, qsTr("61-90 Days"), q.value("ninety_val"));\n  var item5 = new XTreeWidgetItem(_ap, 4, qsTr("90+ days"), q.value("plus_val"));\n  var item6 = new XTreeWidgetItem(_ap, 5, qsTr("Total Open"), q.value("total_val"));\n\n  _payablesIsDirty = false;\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowPayables()\n{\n  // Make sure we can open the window\n  if (!privilegeCheckPayables())\n    return;\n\n  var params = new Object;\n  params.run = true;\n\n  var asOfDate = mainwindow.dbDate();\n  var startDate = new Date();\n  var endDate = new Date();\n\n  // Open the window and perform any handling required\n  toolbox.openWindow("dspAPOpenItemsByVendor");\n\n  if (_ap.id() == 0)\n  {\n    startDate.setDate(asOfDate.getDate());\n    toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n  }\n  else if (_ap.id() == 1)\n  {\n    startDate.setDate(asOfDate.getDate() -30);\n    endDate.setDate(asOfDate.getDate() -1);\n    toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n    toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n  }\n  else if (_ap.id() == 2)\n  {\n    startDate.setDate(asOfDate.getDate() -60);\n    endDate.setDate(asOfDate.getDate() -31);\n    toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n    toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n  }\n  else if (_ap.id() == 3)\n  {\n    startDate.setDate(asOfDate.getDate() -90);\n    endDate.setDate(asOfDate.getDate() -61);\n    toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n    toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n  }\n  else if (_ap.id() == 4)\n  {\n    endDate.setDate(asOfDate.getDate() -91);\n    toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n  }\n\n  toolbox.lastWindow().set(params);\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on a bank account item.\n*/\nfunction populateMenuPayables(pMenu, pItem)\n{\n  var menuItem;\n  var enable = privilegeCheckPayables();\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowPayables);\n}\n\n/*!\n  Returns whether user has privileges to view detail.\n*/\nfunction privilegeCheckPayables(act)\n{\n  return privileges.check("ViewAPOpenItems");\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshPayables()\n{\n  _payablesIsDirty = true;\n  fillListPayables();\n}\n      
106084
 
79      dockPurchActive 0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockPurchAct;\nvar _purchAct;\nvar _purchActIsDirty = true;\n\n/*!\n  Initializes Purch Activity dock widget and places it in the main window.\n*/\nfunction initDockPurchAct()\n{\n  _dockPurchAct = mainwindow.findChild("_dockPurchAct");\n  _purchAct = mainwindow.findChild("_purchAct");\n\n  // Set columns on list\n  _purchAct.addColumn(qsTr("Type"), -1,  Qt.AlignLeft,   true, "activity");\n  _purchAct.addColumn(qsTr("#"), 40,  Qt.AlignRight,  true, "count");\n  _purchAct.addColumn(qsTr("Amount"), -1,  Qt.AlignRight,  true, "amount");\n\n  // Connect Signals and Slots\n  _dtTimer.timeout.connect(refreshPurchAct);\n  mainwindow.purchaseOrdersUpdated.connect(refreshPurchAct);\n  mainwindow.purchaseOrderReceiptsUpdated.connect(refreshPurchAct);\n  mainwindow.purchaseRequestsUpdated.connect(refreshPurchAct);\n  mainwindow.vouchersUpdated.connect(refreshPurchAct);\n\n  _purchAct.itemSelected.connect(openWindowPurchAct);\n  _purchAct["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuPurchAct);\n\n  _dockPurchAct.visibilityChanged.connect(fillListPurchAct);\n\n  // Handle privilge control\n  var act = _dockPurchAct.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewPurchaseActivitiesDock"))\n  {\n    _dockPurchAct.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewPurchaseActivitiesDock");\n  _menuDesktop.appendAction(act);\n\n  fillListPurchAct();\n}\n\n/*!\n  Fills the list with active Purch data.\n*/\nfunction fillListPurchAct()\n{\n  _dockPurchAct = mainwindow.findChild("_dockPurchAct");\n  _purchAct = mainwindow.findChild("_purchAct");\n\n  if (!_dockPurchAct.visible || !_purchActIsDirty)\n    return;\n\n  var params = new Object;\n  if (metrics.value("Application") != "PostBooks")\n  {\n    params.planned = qsTr("Planned");\n    params.firmed = qsTr("Firmed");\n  }\n  params.request = qsTr("Requests");\n  params.unreleased = qsTr("Unreleased");\n  params.open = qsTr("Open");\n  params.receiving = qsTr("At Receiving");\n  params.received = qsTr("Received");\n  params.vouchered = qsTr("Vouchered");\n\n  _purchAct.populate(toolbox.executeDbQuery("desktop","purchAct", params));\n\n  _purchActIsDirty = false;\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowPurchAct()\n{\n  var ui;\n  var run = false;\n  var act = _purchAct.currentItem().rawValue("activity");\n  \n  // Make sure we can open the window for this activity\n  if (!privilegeCheckPurchAct(act))\n    return;\n\n  // Determine which window to open\n  if (act == "L")\n    ui = "dspPlannedOrders";\n  else if (act == "Q")\n    ui = "dspPurchaseReqsByPlannerCode";\n  else if (act == "U" || act == "O")\n    ui = "unpostedPurchaseOrders";\n  else if (act == "A")\n    ui = "unpostedPoReceipts";\n  else if (act == "V")\n    ui = "dspUninvoicedReceivings";\n  else if (act == "I")\n    ui = "openVouchers";\n\n  // Open the window and perform any handling required\n  toolbox.openWindow(ui);\n  if (act == "L")\n  {\n//    toolbox.lastWindow().findChild("_purchase").forgetful = true;\n//    toolbox.lastWindow().findChild("_manufacture").forgetful = true;\n//    toolbox.lastWindow().findChild("_transfer").forgetful = true;\n//    toolbox.lastWindow().findChild("_purchase").checked = true;\n//    toolbox.lastWindow().findChild("_manufacture").checked = false;\n//    toolbox.lastWindow().findChild("_transfer").checked = false;\n    var params = new Object();\n    params.type = "P";\n    toolbox.lastWindow().set(params);\n    toolbox.lastWindow().sFillList();\n  }\n  if (act == "U" || act == "O") // Set options for open P/O list\n  {\n    var showUnreleased = toolbox.lastWindow().findChild("_showUnreleased");\n    var showOpen = toolbox.lastWindow().findChild("_showOpen");\n    showUnreleased.forgetful = true;\n    showOpen.forgetful = true;\n    if (act == "U")\n    {\n      showUnreleased.checked = true;\n      showOpen.checked = false;\n    }\n    else\n    {\n      showUnreleased.checked = false;\n      showOpen.checked = true;\n    }\n    toolbox.lastWindow().sFillList();\n  }\n  else if (act == "Q" || act == "V") \n  {\n    toolbox.lastWindow().findChild("_warehouse").setAll();\n    toolbox.lastWindow().sFillList();\n  }\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on a Purch Activity item.\n*/\nfunction populateMenuPurchAct(pMenu, pItem)\n{\n  var menuItem;\n  var act = pItem.rawValue("activity");\n  var enable = privilegeCheckPurchAct(act);\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowPurchAct);\n}\n\n/*!\n  Returns whether user has privileges to view detail on the selected Purch Activity.\n*/\nfunction privilegeCheckPurchAct(act)\n{\n  if (act == "L") // Planned Orders\n    return privileges.check("ViewPlannedOrders");\n  else if (act == "Q") // Purchase Requests\n    return privileges.check("ViewPurchaseRequests");\n  else if (act == "U" || act == "O") // Purchase Orders\n    return privileges.check("ViewPurchaseOrders") || \n           privileges.check("MaintainPurchaseOrders");\n  else if (act == "A") // At Receiving\n    return privileges.check("EnterReceipts");\n  else if (act == "V") // Unvouchered Receipts\n    return privileges.check("ViewUninvoicedReceipts") || \n           privileges.check("MaintainUninvoicedReceipts");\n  else if (act == "I") // Unposted Vouchers\n    return privileges.check("ViewVouchers") || \n           privileges.check("MaintainVouchers");\n\n  return false;\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshPurchAct()\n{\n  _purchActIsDirty = true;\n  fillListPurchAct();\n}\n        
106085
 
80      dockPurchHist   0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _b1PurchHist;\nvar _b2PurchHist;\nvar _dockPurchHist;\nvar _groupByPurchHist;\nvar _timeFramePurchHist;\nvar _typePurchHist;\nvar _labelPurchHist;\nvar _purchHist;\nvar _purchHistIsDirty = true;\n\n/*!\n  Initializes Sales History dock widget and places it in the main window.\n*/\nfunction initDockPurchHist()\n{\n  // Set up objects\n  _dockPurchHist = mainwindow.findChild("_dockPurchHist");\n  _purchHist = mainwindow.findChild("_purchHist");\n\n  _b1PurchHist = _dockPurchHist.findChild("_button1");\n  _b2PurchHist = _dockPurchHist.findChild("_button2");\n  _labelPurchHist = _dockPurchHist.findChild("_label");\n\n  // Set icons\n  var iReload = new QIcon;\n  iReload.addDbImage("reload_16");\n  _b1PurchHist.icon = iReload;\n  _b1PurchHist.text = "";\n  _b1PurchHist.toolTip = qsTr("Reload");\n\n  var iGear = new QIcon();\n  iGear.addDbImage("gear_16");\n  _b2PurchHist.icon = iGear;\n  _b2PurchHist.text = "";\n  _b2PurchHist.toolTip = qsTr("Preferences...");\n\n  // Load local preferences\n  loadPreferencesPurchHist();\n\n  // Set columns on list\n  setColumnsPurchHist();\n\n  // Connect Signals and Slots\n  _b1PurchHist.clicked.connect(refreshPurchHist);\n  _b2PurchHist.clicked.connect(preferencesPurchHist);\n\n  _dtTimer.timeout.connect(refreshPurchHist);\n  mainwindow.purchaseOrderReceiptsUpdated.connect(refreshPurchHist);\n  mainwindow.vouchersUpdated.connect(refreshPurchHist);\n\n  _purchHist.itemSelected.connect(openWindowPurchHist);\n  _purchHist["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuPurchHist);\n\n  _dockPurchHist.visibilityChanged.connect(fillListPurchHist);\n\n  // Handle privilge control\n  var act = _dockPurchHist.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewPurchaseHistoryDock"))\n  {\n    _dockPurchHist.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewPurchaseHistoryDock");\n  _menuDesktop.appendAction(act);\n\n  fillListPurchHist();\n}\n\n/*!\n  Fills the list with sales history data based on parameters determined by\n  sales history preferences.\n\n  @sa preferencesPurchHist()\n*/\nfunction fillListPurchHist()\n{\n  _dockPurchHist = mainwindow.findChild("_dockPurchHist");\n  _purchHist = mainwindow.findChild("_purchHist");\n\n  if (!_dockPurchHist.visible || !_purchHistIsDirty) \n    return;\n\n  var timeFrame;\n  var type;\n  var params = getDatesPurchHist();\n  params.nonInv = qsTr("Non-Inventory");\n\n  if (_typePurchHist == "variances")\n    params.variances = true;\n  else\n    params.receipts = true;\n \n  if (_groupByPurchHist == "vend")\n  {\n    params.group_id = "vend_id";\n    params.group_number = "vend_number";\n    params.group_name = "vend_name";\n  }\n  else if (_groupByPurchHist == "item")\n  {\n    params.group_id = "item_id";\n    params.group_number = "item_number";\n    params.group_name = "item_descrip1";\n  }\n  else if (_groupByPurchHist == "agent")\n  {\n    params.group_id = "1";\n    params.group_number = "pohead_agent_username";\n    params.group_name = "usr_propername";\n  }\n\n  _purchHist.populate(toolbox.executeDbQuery("desktop","purchHist", params));\n\n  if ("variances" in params)\n    type = qsTr("Variances");\n  else\n    type = qsTr("Receipts");\n\n  if (_timeFramePurchHist == "day")\n    timeFrame = qsTr("Today");\n  else if (_timeFramePurchHist == "week")\n    timeFrame = qsTr("this Week");\n  else if (_timeFramePurchHist == "month")\n    timeFrame = qsTr("this Month");\n  else if (_timeFramePurchHist == "year")\n    timeFrame = qsTr("this Year");\n\n  _labelPurchHist.text = type + " " + timeFrame;\n\n  _purchHistIsDirty = false;\n}\n\n/*!\n  Returns an object with a list containing @a startDate and @a endDate\n  that is used for fetching data and opening windows using the date range\n  stored in local preferences.\n \n  @sa preferencesPurchHist()\n  @sa openWindowPurchHist()\n  @sa fillListPurchHist()\n*/\nfunction getDatesPurchHist()\n{\n  var params = new Object;\n\n  params.timeFrame = _timeFramePurchHist;\n  params.interval = "1 " + _timeFramePurchHist;\n\n  var q = toolbox.executeDbQuery("desktop", "getDates", params);\n\n  if (q.first())\n  {\n    params.startDate = q.value("startDate");\n    params.endDate = q.value("endDate");\n  }\n\n  return params;\n}\n\n/*! \n  Loads local Sales History preferences into memory.\n\n  @sa preferencesPurchHist()\n*/\nfunction loadPreferencesPurchHist()\n{\n  // Load preferences\n  _groupByPurchHist = preferences.value("desktop/purchHist/groupBy");\n  _timeFramePurchHist = preferences.value("desktop/purchHist/timeFrame");\n  _typePurchHist = preferences.value("desktop/purchHist/type")\n  \n  // Set to defaults if no values\n  _groupByPurchHist = (_groupByPurchHist.length ? _groupByPurchHist : "vend");\n  _timeFramePurchHist = (_timeFramePurchHist.length ? _timeFramePurchHist : "year");\n  _typePurchHist = (_typePurchHist.length ? _typePurchHist : "receipts");\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowPurchHist()\n{\n  var ui;\n  var params = getDatesPurchHist();\n  params.run = true;\n\n  // TO DO: Work it out so totals launch a window too\n  if (_purchHist.id() == -1)\n    return;\n  \n  // Make sure we can open the window\n  if (!privilegeCheckPurchHist())\n    return;\n\n  // Determine which window to open\n  if (_groupByPurchHist == "vend")\n  {\n    if (_typePurchHist == "variances")\n      ui = "dspPoPriceVariancesByVendor";\n    else\n      ui = "dspPoItemReceivingsByVendor";\n    params.cust_id = _purchHist.id();\n  }\n  else if (_groupByPurchHist == "item")\n  {\n    if (_purchHist.id() == -2)\n    {\n      QMessageBox.warning(mainwindow, qsTr("Unsupported Action"),\n        qsTr("Drill down on Non-Inventory Items is not yet supported"));\n      return;\n    }\n    if (_typePurchHist == "variances")\n      ui = "dspPoPriceVariancesByItem";\n    else\n      ui = "dspPoItemReceivingsByItem";\n    params.prodcat_id = _purchHist.id();\n  }\n  else if (_groupByPurchHist == "agent")\n  {\n    if (_typePurchHist == "variances")\n      ui = "dspPoPriceVariancesByVendor";\n    else\n      ui = "dspPoItemReceivingsByDate";\n    params.salesrep_id = _purchHist.id();\n  }\n\n  // Open the window and perform any special handling required\n  toolbox.openWindow(ui);\n  var warehouse = toolbox.lastWindow().findChild("_warehouse");\n  warehouse.setAll();\n  if (_typePurchHist == "receipts")\n  {\n    toolbox.lastWindow().findChild("_showUnvouchered").forgetful = true;\n    toolbox.lastWindow().findChild("_showUnvouchered").checked = true;   \n  }\n  if (_groupByPurchHist == "vend")\n  {\n    if (_typePurchHist == "variances")\n      toolbox.lastWindow().findChild("_vendorGroup").setVendId(_purchHist.id());\n    else\n      toolbox.lastWindow().findChild("_vendor").setId(_purchHist.id());\n  }\n  else if (_groupByPurchHist == "item")\n    toolbox.lastWindow().findChild("_item").setId(_purchHist.id());  \n  else if (_groupByPurchHist == "agent")\n  {\n    toolbox.lastWindow().findChild("_selectedPurchasingAgent").checked = true;\n    toolbox.lastWindow().findChild("_agent").code = \n      _purchHist.currentItem().rawValue("pohead_agent_username")\n  }\n\n  var dates = toolbox.lastWindow().findChild("_dates");\n  dates.setStartDate(params.startDate);\n  dates.setEndDate(params.endDate);\n  toolbox.lastWindow().sFillList();\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on sales history.\n*/\nfunction populateMenuPurchHist(pMenu)\n{\n  var menuItem;\n  var enable = privilegeCheckPurchHist();\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowPurchHist);\n}\n\n/*!\n  Returns whether user has privileges to view Sales History detail.\n*/\nfunction privilegeCheckPurchHist()\n{\n  if (_typePurchHist == "variances")\n    return privileges.check("ViewVendorPerformance");\n  else if (_typePurchHist == "receipts")\n    return privileges.check("ViewReceiptsReturns");\n   \n  return false;\n}\n\n/*! \n  Set up columns depending on local preferences.\n\n  @sa preferencesPurchHist()\n*/\nfunction setColumnsPurchHist()\n{\n  _purchHist.columnCount = 0;\n\n  if (_groupByPurchHist == "vend")\n  {\n    _purchHist.addColumn(qsTr("Vendor"),  -1, Qt.AlignLeft, true, "vend_number");\n    _purchHist.addColumn(qsTr("Name"), -1, Qt.AlignLeft, false, "vend_name");\n  }\n  else if (_groupByPurchHist == "item")\n  {\n    _purchHist.addColumn(qsTr("Item Number"), -1, Qt.AlignLeft, true, "item_number");\n    _purchHist.addColumn(qsTr("Description"), -1, Qt.AlignLeft, false, "item_descrip1");\n  }\n  else if (_groupByPurchHist == "agent")\n  {\n    _purchHist.addColumn(qsTr("Purch. Agent"),  -1, Qt.AlignLeft, true, "pohead_agent_username");\n    _purchHist.addColumn(qsTr("Name"), -1, Qt.AlignLeft, false, "usr_propername");\n  }\n\n  _purchHist.addColumn(qsTr("Amount"), -1, Qt.AlignRight, true, "amount");\n  _purchHist.addColumn(qsTr("Qty."), -1, Qt.AlignRight, false, "qty");\n}\n\n/*! \n  Launches the preferences window where the user can set sales data output preferences.\n*/\nfunction preferencesPurchHist()\n{\n  params = new Object;\n  params.path = "desktop/purchHist";\n  params.groupBy = _groupByPurchHist;\n  params.timeFrame = _timeFramePurchHist;\n  params.type = _typePurchHist;\n\n  var newdlg = toolbox.openWindow("preferencesHistory", mainwindow,\n                                  Qt.ApplicationModal, Qt.Dialog);\n  toolbox.lastWindow().set(params);\n  if (newdlg.exec())\n  {\n    loadPreferencesPurchHist();\n    setColumnsPurchHist();\n    refreshPurchHist();\n  }\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshPurchHist()\n{\n  _purchHistIsDirty = true;\n  fillListPurchHist();\n}\n   
106086
 
81      dockPurchOpen   0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockPurchOpen;\nvar _purchOpen;\nvar _purchOpenIsDirty = true;\n\n/*!\n  Initializes Open Purchase Order dock widget and places it in the main window.\n*/\nfunction initDockPurchOpen()\n{\n  _dockPurchOpen = mainwindow.findChild("_dockPurchOpen");\n  _purchOpen = mainwindow.findChild("_purchOpen");\n\n  // Set columns on list\n  _purchOpen.addColumn(qsTr("Order#"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "pohead_number");\n  _purchOpen.addColumn(qsTr("Vendor#"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "vend_number");\n  _purchOpen.addColumn(qsTr("Name"), -1,  Qt.AlignLeft, true, "vend_name");\n  _purchOpen.addColumn(qsTr("Contact"), -1,  Qt.AlignLeft, true, "vend_cntct");\n  _purchOpen.addColumn(qsTr("Phone"), -1,  Qt.AlignLeft, true, "pohead_vend_cntct_phone"); \n  _purchOpen.addColumn(qsTr("Status"), -1, Qt.AlignLeft,  true, "status");\n  _purchOpen.addColumn(qsTr("Ship Contact"), -1,  Qt.AlignLeft, false, "shipto_cntct");\n  _purchOpen.addColumn(qsTr("Ship Phone"), -1,  Qt.AlignLeft, false, "pohead_shipto_cntct_phone"); \n  _purchOpen.addColumn(qsTr("Ship Via"), -1,  Qt.AlignLeft, true, "pohead_shipvia"); \n  _purchOpen.addColumn(qsTr("Due Date"), XTreeWidget.dateColumn,  Qt.AlignLeft,  true, "duedate");\n  _purchOpen.addColumn(qsTr("Amount"), XTreeWidget.moneyColumn,  Qt.AlignRight,  true, "amount");\n\n  // Connect Signals and Slots\n  _dtTimer.timeout.connect(refreshPurchOpen);\n  mainwindow.purchaseOrderReceiptsUpdated.connect(refreshPurchOpen);\n  mainwindow.purchaseOrdersUpdated.connect(refreshPurchOpen);\n\n  _purchOpen.itemSelected.connect(openWindowPurchOpen);\n  _purchOpen["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuPurchOpen);\n\n  _dockPurchOpen.visibilityChanged.connect(fillListPurchOpen);\n\n  // Handle privilge control\n  var act = _dockPurchOpen.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewPurchaseOrdersDock"))\n  {\n    _dockPurchOpen.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewPurchaseOrdersDock");\n  _menuDesktop.appendAction(act);\n\n  fillListPurchOpen();\n}\n\n/*!\n  Fills the list with open purchase data.\n*/\nfunction fillListPurchOpen()\n{\n  _dockPurchOpen = mainwindow.findChild("_dockPurchOpen");\n  _purchOpen = mainwindow.findChild("_purchOpen");\n\n  if (!_dockPurchOpen.visible || !_purchOpenIsDirty)\n    return;\n\n  var params = new Object;\n  params.open = qsTr("Open");\n  params.unreleased = qsTr("Unreleased");\n\n  _purchOpen.populate(toolbox.executeDbQuery("desktop","purchOpen",params));\n  _purchOpenIsDirty = false;\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowPurchOpen()\n{ \n  // Make sure we can open the window for this activity\n  if (!privilegeCheckPurchOpen)\n    return;\n\n  params = new Object;\n  params.pohead_id = _purchOpen.id();\n  if (privileges.check("MaintainPurchaseOrders"))\n    params.mode = "edit";\n  else\n    params.mode = "view";\n\n  // Open the window and perform any handling required\n  var po = toolbox.openWindow("purchaseOrder");\n  po.set(params);\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on a Purchase Order item.\n*/\nfunction populateMenuPurchOpen(pMenu, pItem)\n{\n  var menuItem;\n  var enable = privilegeCheckPurchOpen();\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowPurchOpen);\n}\n\n/*!\n  Returns whether user has privileges to view detail on the selected Purchase Order.\n*/\nfunction privilegeCheckPurchOpen()\n{\n  return privileges.check("ViewPurchaseOrders") || \n         privileges.check("MaintainPurchaseOrders");\n\n  return false;\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshPurchOpen()\n{\n  _purchOpenIsDirty = true;\n  fillListPurchOpen();\n}\n 
106087
 
82      dockReceivables 0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockReceivables;\nvar _receivables;\nvar _receivablesIsDirty = true;\n\n/*!\n  Initializes Bank Balance dock widget and places it in the main window.\n*/\nfunction initDockReceivables()\n{\n  _dockReceivables = mainwindow.findChild("_dockReceivables");\n  _ar = mainwindow.findChild("_ar");\n  _ar.rootIsDecorated = false;\n\n  // Set columns on list\n  _ar.addColumn(qsTr("Status"), -1,  Qt.AlignLeft,   true);\n  _ar.addColumn(qsTr("Balance"), -1,  Qt.AlignRight,  true);\n\n  // Connect Signals and Slots\n  _dtTimer.timeout.connect(refreshReceivables);\n  mainwindow.checksUpdated.connect(refreshReceivables);\n  mainwindow.paymentsUpdated.connect(refreshReceivables);\n  mainwindow.vouchersUpdated.connect(refreshReceivables);\n\n  _ar.itemSelected.connect(openWindowReceivables);\n  _ar["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuReceivables);\n\n  _dockReceivables.visibilityChanged.connect(fillListReceivables);\n\n  // Handle privilge control\n  var act = _dockReceivables.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewReceivablesDock"))\n  {\n    _dockReceivables.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewReceivablesDock");\n  _menuDesktop.appendAction(act);\n\n  fillListReceivables();\n}\n\n/*!\n  Fills the list with bank account data.\n*/\nfunction fillListReceivables()\n{\n  _dockReceivables = mainwindow.findChild("_dockReceivables");\n  _ar = mainwindow.findChild("_ar");\n\n  if (!_dockReceivables.visible || !_receivablesIsDirty)\n    return;\n\n  var q = toolbox.executeDbQuery("desktop","receivables");\n  q.first();\n  \n  _ar.clear();\n  var item1 = new XTreeWidgetItem(_ar, 0, qsTr("0+ Days"), q.value("cur_val"));\n  var item2 = new XTreeWidgetItem(_ar, 1, qsTr("0-30 Days"), q.value("thirty_val"));\n  var item3 = new XTreeWidgetItem(_ar, 2, qsTr("31-60 Days"), q.value("sixty_val"));\n  var item4 = new XTreeWidgetItem(_ar, 3, qsTr("61-90 Days"), q.value("ninety_val"));\n  var item5 = new XTreeWidgetItem(_ar, 4, qsTr("90+ days"), q.value("plus_val"));\n  var item6 = new XTreeWidgetItem(_ar, 5, qsTr("Total Open"), q.value("total_val"));\n\n  _receivablesIsDirty = false;\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowReceivables()\n{\n  // Make sure we can open the window\n  if (!privilegeCheckReceivables())\n    return;\n\n  var params = new Object;\n  params.run = true;\n  params.byDueDate = true;\n\n  var asOfDate = mainwindow.dbDate();\n  var startDate = new Date();\n  var endDate = new Date();\n\n  // Open the window and perform any handling required\n  toolbox.openWindow("dspAROpenItems");\n\n  if (_ar.id() == 0)\n  {\n    startDate.setDate(asOfDate.getDate());\n    toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n  }\n  else if (_ar.id() == 1)\n  {\n    startDate.setDate(asOfDate.getDate() -30);\n    endDate.setDate(asOfDate.getDate() -1);\n    toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n    toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n  }\n  else if (_ar.id() == 2)\n  {\n    startDate.setDate(asOfDate.getDate() -60);\n    endDate.setDate(asOfDate.getDate() -31);\n    toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n    toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n  }\n  else if (_ar.id() == 3)\n  {\n    startDate.setDate(asOfDate.getDate() -90);\n    endDate.setDate(asOfDate.getDate() -61);\n    toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n    toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n  }\n  else if (_ar.id() == 4)\n  {\n    endDate.setDate(asOfDate.getDate() -91);\n    toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n  }\n\n  toolbox.lastWindow().set(params);\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on a bank account item.\n*/\nfunction populateMenuReceivables(pMenu, pItem)\n{\n  var menuItem;\n  var enable = privilegeCheckReceivables();\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowReceivables);\n}\n\n/*!\n  Returns whether user has privileges to view detail.\n*/\nfunction privilegeCheckReceivables(act)\n{\n  return privileges.check("ViewAROpenItems");\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshReceivables()\n{\n  _receivablesIsDirty = true;\n  fillListReceivables();\n}\n 
106088
 
83      dockSalesActive 0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockSalesAct;\nvar _salesAct;\nvar _salesActIsDirty = true;\n\n/*!\n  Initializes Sales Activity dock widget and places it in the main window.\n*/\nfunction initDockSalesAct()\n{\n  _dockSalesAct = mainwindow.findChild("_dockSalesAct");\n  _salesAct = mainwindow.findChild("_salesAct");\n\n  // Set columns on list\n  _salesAct.addColumn(qsTr("Type"), -1,  Qt.AlignLeft,   true, "activity");\n  _salesAct.addColumn(qsTr("#"), 40,  Qt.AlignRight,  true, "count");\n  _salesAct.addColumn(qsTr("Amount"), -1,  Qt.AlignRight,  true, "amount");\n\n  // Connect Signals and Slots\n  _dtTimer.timeout.connect(refreshSalesAct);\n  mainwindow.billingSelectionUpdated.connect(refreshSalesAct);\n  mainwindow.invoicesUpdated.connect(refreshSalesAct);\n  mainwindow.quotesUpdated.connect(refreshSalesAct)\n  mainwindow.salesOrdersUpdated.connect(refreshSalesAct);\n\n  _salesAct.itemSelected.connect(openWindowSalesAct);\n  _salesAct["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuSalesAct);\n\n  _dockSalesAct.visibilityChanged.connect(fillListSalesAct);\n\n  // Handle privilge control\n  var act = _dockSalesAct.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewSalesActivitiesDock"))\n  {\n    _dockSalesAct.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewSalesActivitiesDock");\n  _menuDesktop.appendAction(act);\n  fillListSalesAct();\n}\n\n/*!\n  Fills the list with active sales data.\n*/\nfunction fillListSalesAct()\n{\n  _dockSalesAct = mainwindow.findChild("_dockSalesAct");\n  _salesAct = mainwindow.findChild("_salesAct");\n\n  if (!_dockSalesAct.visible || !_salesActIsDirty)\n    return;\n\n  var params = new Object;\n  params.quotes = qsTr("Quotes");\n  params.open = qsTr("Orders");\n  params.print = qsTr("To Print");\n  params.pick = qsTr("Pick");\n  params.ship = qsTr("At Shipping");\n  params.bill = qsTr("Shipped");\n  params.invoice = qsTr("To Bill");\n  params.post = qsTr("Invoiced");\n\n  _salesAct.populate(toolbox.executeDbQuery("desktop","salesAct", params));\n  _salesActIsDirty = false;\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowSalesAct()\n{\n  var ui;\n  var run = false;\n  var act = _salesAct.currentItem().rawValue("activity");\n  \n  // Make sure we can open the window for this activity\n  if (!privilegeCheckSalesAct(act))\n    return;\n\n  // Determine which window to open\n  if (act == "Q")\n  {\n    ui = "quotes";\n    run = true;\n  }\n  else if (act == "O")\n  {\n    ui = "openSalesOrders";\n    run = true;\n  }\n  else if (act == "P")\n    ui = "packingListBatch";\n  else if (act == "S")\n  {\n    ui = "maintainShipping";\n    run = true;\n  }\n  else if (act == "B")\n    ui = "uninvoicedShipments";\n  else if (act == "I")\n    ui = "dspBillingSelections";\n  else if (act == "T")\n    ui = "unpostedInvoices";\n\n  // Open the window and perform any handling required\n  toolbox.openWindow(ui);\n  if (run)\n    toolbox.lastWindow().sFillList();\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on a Sales Activity item.\n*/\nfunction populateMenuSalesAct(pMenu, pItem)\n{\n  var menuItem;\n  var act = pItem.rawValue("activity");\n  var enable = privilegeCheckSalesAct(act);\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowSalesAct);\n}\n\n/*!\n  Returns whether user has privileges to view detail on the selected Sales Activity.\n*/\nfunction privilegeCheckSalesAct(act)\n{\n  if (act == "Q") // Quote\n    return privileges.check("ViewQuotes") || \n           privileges.check("MaintainQuotes")\n  else if (act == "O") // Open Sales Orders\n    return privileges.check("ViewSalesOrders") || \n           privileges.check("MaintainSalesOrders");\n  else if (act == "P") // Packlist Batch\n    return privileges.check("ViewPackingListBatch") || \n           privileges.check("MaintainPackingListBatch");\n  else if (act == "S") // Shipping\n    return privileges.check("ViewShipping");\n  else if (act == "B" || \n           act == "I" || \n           act == "T") // Billing, Invoicing\n    return privileges.check("SelectBilling");\n\n  return false;\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshSalesAct()\n{\n  _salesActIsDirty = true;\n  fillListSalesAct();\n}\n 
106089
 
84      dockSalesHistory        0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _b1SalesHist;\nvar _b2SalesHist;\nvar _dockSalesHist;\nvar _groupBySalesHist;\nvar _timeFrameSalesHist;\nvar _typeSalesHist;\nvar _labelSalesHist;\nvar _salesHist;\nvar _salesHistIsDirty = true;\n\n/*!\n  Initializes Sales History dock widget and places it in the main window.\n*/\nfunction initDockSalesHist()\n{\n  // Set up objects\n  _dockSalesHist = mainwindow.findChild("_dockSalesHist");\n  _salesHist = mainwindow.findChild("_salesHist");\n\n  _b1SalesHist = _dockSalesHist.findChild("_button1");\n  _b2SalesHist = _dockSalesHist.findChild("_button2");\n  _labelSalesHist = _dockSalesHist.findChild("_label");\n\n  // Set icons\n  var iReload = new QIcon;\n  iReload.addDbImage("reload_16");\n  _b1SalesHist.icon = iReload;\n  _b1SalesHist.text = "";\n  _b1SalesHist.toolTip = qsTr("Reload");\n\n  var iGear = new QIcon();\n  iGear.addDbImage("gear_16");\n  _b2SalesHist.icon = iGear;\n  _b2SalesHist.text = "";\n  _b2SalesHist.toolTip = qsTr("Preferences...");\n\n  // Load local preferences\n  loadPreferencesSalesHist();\n\n  // Set columns on list\n  setColumnsSalesHist();\n\n  // Populate the data\n  fillListSalesHist();\n\n  // Connect Signals and Slots\n  _b1SalesHist.clicked.connect(refreshSalesHist);\n  _b2SalesHist.clicked.connect(preferencesSalesHist);\n\n  _dtTimer.timeout.connect(refreshSalesHist);\n  mainwindow.salesOrdersUpdated.connect(refreshSalesHist);\n\n  _salesHist.itemSelected.connect(openWindowSalesHist);\n  _salesHist["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuSalesHist);\n\n  _dockSalesHist.visibilityChanged.connect(fillListSalesHist);\n\n  // Handle privilge control\n  var act = _dockSalesHist.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewSalesHistoryDock"))\n  {\n    _dockSalesHist.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewSalesHistoryDock");\n  _menuDesktop.appendAction(act);\n\n  fillListSalesHist();\n}\n\n/*!\n  Fills the list with sales history data based on parameters determined by\n  sales history preferences.\n\n  @sa preferencesSalesHist()\n*/\nfunction fillListSalesHist()\n{\n  _dockSalesHist = mainwindow.findChild("_dockSalesHist");\n  _salesHist = mainwindow.findChild("_salesHist");\n\n  if (!_dockSalesHist.visible || !_salesHistIsDirty)\n    return;\n\n  var timeFrame;\n  var type;\n  var params = getDatesSalesHist();\n\n  if (_typeSalesHist == "bookings")\n    params.bookings = true;\n  else\n    params.sales = true;\n \n  if (_groupBySalesHist == "cust")\n  {\n    params.group_id = "cust_id";\n    params.group_number = "cust_number";\n    params.group_name = "cust_name";\n  }\n  else if (_groupBySalesHist == "prodcat")\n  {\n    params.group_id = "prodcat_id";\n    params.group_number = "prodcat_code";\n    params.group_name = "prodcat_descrip";\n  }\n  else if (_groupBySalesHist == "salesrep")\n  {\n    params.group_id = "salesrep_id";\n    params.group_number = "salesrep_number";\n    params.group_name = "salesrep_name";\n  }\n\n  _salesHist.populate(toolbox.executeDbQuery("desktop","salesHist", params));\n\n  if ("bookings" in params)\n    type = qsTr("Bookings");\n  else\n    type = qsTr("Sales");\n\n  if (_timeFrameSalesHist == "day")\n    timeFrame = qsTr("Today");\n  else if (_timeFrameSalesHist == "week")\n    timeFrame = qsTr("this Week");\n  else if (_timeFrameSalesHist == "month")\n    timeFrame = qsTr("this Month");\n  else if (_timeFrameSalesHist == "year")\n    timeFrame = qsTr("this Year");\n\n  _labelSalesHist.text = type + " " + timeFrame;\n\n  _salesHistIsDirty = false;\n}\n\n/*!\n  Returns an object with a list containing @a startDate and @a endDate\n  that is used for fetching data and opening windows using the date range\n  stored in local preferences.\n \n  @sa preferencesSalesHist()\n  @sa openWindowSalesHist()\n  @sa fillListSalesHist()\n*/\nfunction getDatesSalesHist()\n{\n  var params = new Object;\n\n  params.timeFrame = _timeFrameSalesHist;\n  params.interval = "1 " + _timeFrameSalesHist;\n\n  var q = toolbox.executeDbQuery("desktop", "getDates", params);\n\n  if (q.first())\n  {\n    params.startDate = q.value("startDate");\n    params.endDate = q.value("endDate");\n  }\n\n  return params;\n}\n\n/*! \n  Loads local Sales History preferences into memory.\n\n  @sa preferencesSalesHist()\n*/\nfunction loadPreferencesSalesHist()\n{\n  // Load preferences\n  _groupBySalesHist = preferences.value("desktop/salesHist/groupBy");\n  _timeFrameSalesHist = preferences.value("desktop/salesHist/timeFrame");\n  _typeSalesHist = preferences.value("desktop/salesHist/type")\n  \n  // Set to defaults if no values\n  _groupBySalesHist = (_groupBySalesHist.length ? _groupBySalesHist : "cust");\n  _timeFrameSalesHist = (_timeFrameSalesHist.length ? _timeFrameSalesHist : "year");\n  _typeSalesHist = (_typeSalesHist.length ? _typeSalesHist : "bookings");\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowSalesHist()\n{\n  var ui;\n  var params = getDatesSalesHist();\n  params.run = true;\n\n  // TO DO: Work it out so totals launch a window too\n  if (_salesHist.id() == -1)\n    return;\n  \n  // Make sure we can open the window\n  if (!privilegeCheckSalesHist())\n    return;\n\n  // Determine which window to open\n  if (_typeSalesHist == "bookings")\n    ui = "dspBookings";\n  else\n    ui = "dspSalesHistory";\n  if (_groupBySalesHist == "cust")\n    params.cust_id = _salesHist.id();\n  else if (_groupBySalesHist == "prodcat")\n    params.prodcat_id = _salesHist.id();\n  else if (_groupBySalesHist == "salesrep")\n    params.salesrep_id = _salesHist.id();\n\n  // Open the window and perform any special handling required\n  toolbox.openWindow(ui);\n  toolbox.lastWindow().set(params);\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on sales history.\n*/\nfunction populateMenuSalesHist(pMenu)\n{\n  var menuItem;\n  var enable = privilegeCheckSalesHist();\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowSalesHist);\n}\n\n/*!\n  Returns whether user has privileges to view Sales History detail.\n*/\nfunction privilegeCheckSalesHist()\n{\n  return privileges.check("ViewSalesHistory");\n}\n\n/*! \n  Set up columns depending on local preferences.\n\n  @sa preferencesSalesHist()\n*/\nfunction setColumnsSalesHist()\n{\n  _salesHist.columnCount = 0;\n\n  if (_groupBySalesHist == "cust")\n  {\n    _salesHist.addColumn(qsTr("Customer"),  -1, Qt.AlignLeft, true, "cust_number");\n    _salesHist.addColumn(qsTr("Name"), -1, Qt.AlignLeft, false, "cust_name");\n  }\n  else if (_groupBySalesHist == "prodcat")\n  {\n    _salesHist.addColumn(qsTr("Product Category"), -1, Qt.AlignLeft, true, "prodcat_code");\n    _salesHist.addColumn(qsTr("Description"), -1, Qt.AlignLeft, false, "prodcat_descrip");\n  }\n  else if (_groupBySalesHist == "salesrep")\n  {\n    _salesHist.addColumn(qsTr("Sales Rep."),  -1, Qt.AlignLeft, true, "salesrep_number");\n    _salesHist.addColumn(qsTr("Name"), -1, Qt.AlignLeft, false, "salesrep_name");\n  }\n\n  _salesHist.addColumn(qsTr("Amount"), -1, Qt.AlignRight, true, "amount");\n  _salesHist.addColumn(qsTr("Qty."), -1, Qt.AlignRight, false, "qty");\n}\n\n/*! \n  Launches the preferences window where the user can set sales data output preferences.\n*/\nfunction preferencesSalesHist()\n{\n  params = new Object;\n  params.path = "desktop/salesHist";\n  params.groupBy = _groupBySalesHist;\n  params.timeFrame = _timeFrameSalesHist;\n  params.type = _typeSalesHist;\n\n  var newdlg = toolbox.openWindow("preferencesHistory", mainwindow,\n                                  Qt.ApplicationModal, Qt.Dialog);\n  toolbox.lastWindow().set(params);\n  if (newdlg.exec())\n  {\n    loadPreferencesSalesHist();\n    setColumnsSalesHist();\n    refreshSalesHist();\n  }\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshSalesHist()\n{\n  _salesHistIsDirty = true;\n  fillListSalesHist();\n}\n        
106090
 
128     dockSendMessage 0       t       var _dockSendMessage;\nvar _usr;\nvar _message;\nvar _send;\nvar _sendMessageIsDirty = true;\nvar _periodId = -1;\nvar _b1CommentConsole;\nvar _b2CommentConsole;\nvar _commentConsole;\nvar _commentConsoleIsDirty = true;\nvar _periodId = -1;\n\nfunction initDockSendMessage()\n{\n  // Set up objects\n  _dockSendMessage = mainwindow.findChild("_dockSendMessage");\n  _usr             = mainwindow.findChild("_usr");\n  _message         = mainwindow.findChild("_message");\n  _send            = mainwindow.findChild("_send");\n\n  _commentConsole   = mainwindow.findChild("_commentConsole");\n\n  _b1CommentConsole = mainwindow.findChild("_button1");\n  _b2CommentConsole = mainwindow.findChild("_button2");\n\n  // Set icons\n  var iReload = new QIcon;\n  iReload.addDbImage("reload_16");\n  _b1CommentConsole.icon = iReload;\n  _b1CommentConsole.text = "";\n  _b1CommentConsole.toolTip = qsTr("Reload");\n\n  var iGear = new QIcon();\n  iGear.addDbImage("gear_16");\n  _b2CommentConsole.icon = iGear;\n  _b2CommentConsole.text = "";\n  _b2CommentConsole.toolTip = qsTr("Preferences...");\n\n  // Set columns on list\n  _commentConsole.addColumn("Date",           75,  1, true, "comment_date");\n  _commentConsole.addColumn("Comment Type",   115, 1, true, "cmnttype_name");\n  _commentConsole.addColumn("Text",           90,  1, true, "comment_text");\n  _commentConsole.addColumn("Source",         115, 1, true, "comment_source")\n  _commentConsole.addColumn("User",           65,  1, true, "comment_user")\n  _commentConsole.addColumn("Detail",         -1,  1, true, "info");\n  _commentConsole.addColumn("Points",         40,  3, true, "points");\n\n  mainwindow.itemsitesUpdated.connect(refreshCommentConsole);\n  mainwindow.warehousesUpdated.connect(refreshCommentConsole);\n  mainwindow.customersUpdated.connect(refreshCommentConsole)\n  mainwindow.employeeUpdated.connect(refreshCommentConsole);\n  mainwindow.vendorsUpdated.connect(refreshCommentConsole);\n  mainwindow.returnAuthorizationsUpdated.connect(refreshCommentConsole);\n  mainwindow.salesOrdersUpdated.connect(refreshCommentConsole)\n  mainwindow.quotesUpdated.connect(refreshCommentConsole);\n  mainwindow.workOrdersUpdated.connect(refreshCommentConsole);\n  mainwindow.purchaseOrdersUpdated.connect(refreshCommentConsole);\n  mainwindow.bomsUpdated.connect(refreshCommentConsole)\n  mainwindow.bbomsUpdated.connect(refreshCommentConsole);\n  mainwindow.boosUpdated.connect(refreshCommentConsole);\n  mainwindow.projectsUpdated.connect(refreshCommentConsole);\n  mainwindow.crmAccountsUpdated.connect(refreshCommentConsole)\n  mainwindow.transferOrdersUpdated.connect(refreshCommentConsole);\n\n  // Connect Signals and Slots\n  _b1CommentConsole.clicked.connect(refreshCommentConsole);\n  _b2CommentConsole.clicked.connect(preferencesCommentConsole);\n\n  _commentConsole["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuCommentConsole);\n\n  mainwindow["tick()"].connect(refreshCommentConsole);\n\n  // Don't show if no privs\n  var act = _dockSendMessage.toggleViewAction();\n  if (!privileges.check("viewSendMsgDock"))\n  {  \n    _dockSendMessage.hide();\n    act.enabled = false;\n  }\n  else\n  {\n    _dockSendMessage.show();\n    act.enabled = true;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("viewSendMsgDock");\n  _menuDesktop.appendAction(act);\n\n  _usr["newId(int)"].connect(sHandleButtons);\n  _send.clicked.connect(send);\n\n  fillListCommentConsole();\n}\n\nfunction getParams()\n{\n  var params = new Object;\n\n  params.message = _message.plainText;\n  if (_usr.id() > 0)\n    params.usr_id = _usr.id();\n\n  return params;\n}\n\nfunction sHandleButtons()\n{\n  var qry = "SELECT usr_id FROM usr WHERE usr_username = current_user;";\n  var data = toolbox.executeQuery(qry, -1);\n  if (data.first())\n    var currenttUsr_id = data.value("usr_id");\n\n  if (currenttUsr_id == _usr.id())\n  {\n    if (QMessageBox.information(mainwindow, qsTr("Send Message?"),\n                            qsTr("You are trying to Send Message to Yourself."\n                              +"\\nAre you sure that you really want to Continue?."),\n           QMessageBox.Yes | QMessageBox.Default, QMessageBox.No | QMessageBox.Escape) == QMessageBox.No)\n    {\n      _usr.clear();\n      return;\n    }\n    else\n      _send.enabled = (_usr.id() >= 0);\n  }\n  else\n    _send.enabled = (_usr.id() >= 0);\n}\n\nfunction send()\n{\n  var params = getParams();\n  var qry = toolbox.executeDbQuery("desktop", "sendMessageToUser", params);\n  QMessageBox.information(mainwindow,'Sent','Message Sent');\n  clear();\n}\n\nfunction set(input)\n{\n  if ("user" in input)\n    _usr.setUsername(input.user);\n  else\n   QMessageBox.warning(mywindow, "Message", "Could not set username");\n}\n\nfunction clear()\n{\n  _usr.clear();\n  _message.clear();\n}\n\nfunction fillListCommentConsole()\n{\n  _commentConsole = mainwindow.findChild("_commentConsole");\n\n  var cmmntTypeList = preferences.value("MonitoredCommentTypes");\n  var cmmntSrcList = preferences.value("MonitoredCommentSrcs");\n  var cmmntUsrList = preferences.value("MonitoredCommentUsrs");\n\n  var params = new Object;\n\n  //Checking whether xtmfg package exists in the database or not\n  var checkxtmfg = "SELECT pkghead_id "\n                 + "FROM pkghead "\n                 + "WHERE (pkghead_name = 'xtmfg');";\n  var datacheckxtmfg = toolbox.executeQuery(checkxtmfg, params);\n  if (datacheckxtmfg.first())\n    params.xtmfg_exist = datacheckxtmfg.value("pkghead_id");\n  else if (datacheckxtmfg.lastError().type != QSqlError.NoError)\n  {\n    QMessageBox.critical(mainwindow, qsTr("Database Error"),\n                         datacheckxtmfg.lastError().text);\n    return;\n  }\n\n  var getDate = "SELECT CURRENT_DATE + CAST(<? literal('offSet') ?> AS INTEGER) AS datevalue;";\n\n  params.offSet = ((preferences.value("MonitoredCommentStrtDate") != '')?preferences.value("MonitoredCommentStrtDate"):-1);\n  var data = toolbox.executeQuery(getDate, params);\n  if (data.first())\n    params.startDate = data.value("datevalue");\n  else if (data.lastError().type != QSqlError.NoError)\n  {\n    QMessageBox.critical(mainwindow, qsTr("Database Error"),\n                         data.lastError().text);\n    return;\n  }\n\n  params.offSet = ((preferences.value("MonitoredCommentEndDate") != '')?preferences.value("MonitoredCommentEndDate"):0);\n  var data = toolbox.executeQuery(getDate, params);\n  if (data.first())\n    params.endDate = data.value("datevalue");\n  else if (data.lastError().type != QSqlError.NoError)\n  {\n    QMessageBox.critical(mainwindow, qsTr("Database Error"),\n                         data.lastError().text);\n    return;\n  }\n\n  _commentConsole.clear();\n  \n  if (cmmntTypeList.length)\n    params.commenttype_id = cmmntTypeList;\n\n  if (cmmntSrcList.length)\n  {\n    params.sourceidlist = cmmntSrcList;\n    var sourceList = new Array();\n    var data = toolbox.executeDbQuery("desktop","cmmntPrefSrc", params);\n    var i = 0;\n    while (data.next())\n      sourceList.push(data.value("cmntsource_name"));\n    params.source = sourceList;\n  }\n\n  if(cmmntUsrList.length)\n    params.usr_id = cmmntUsrList;\n\n  _commentConsole.populate(toolbox.executeDbQuery("desktop","commentConsole", params));\n  _commentConsoleIsDirty = false;\n}\n\nfunction populateMenuCommentConsole(pMenu, pItem, pCol)\n{\n  try\n  {\n    _commentConsole = mainwindow.findChild("_commentConsole");\n\n    if(pMenu == null)\n      pMenu = _commentConsole.findChild("_menu");\n    if(pMenu != null)\n    {\n      var tmpact;\n      if(pItem.text(3) == "ADDR")//Address\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Address..."));\n        tmpact.enabled = privileges.check("MaintainAddresses");\n        tmpact.triggered.connect(editaddr);\n\n        tmpact = pMenu.addAction(qsTr("View Address..."));\n        tmpact.enabled = privileges.check("MaintainAddresses") ||\n                         privileges.check("ViewAddresses");\n        tmpact.triggered.connect(viewaddr);\n      }\n      else if(pItem.text(3) == "BBH")//BBomhead\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Breeder Bill of Material..."));\n        tmpact.enabled = (privileges.check("MaintainBBOMs"));\n        tmpact.triggered.connect(editbbh);\n\n        tmpact = pMenu.addAction(qsTr("View Breeder Bill of Material..."));\n        tmpact.enabled = (privileges.check("MaintainBBOMs") ||\n                          privileges.check("ViewBBOMs"));\n        tmpact.triggered.connect(viewbbh);\n      }\n      else if(pItem.text(3) == "BBI")//BBOMItem\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Breeder Bill of Material Item..."));\n        tmpact.enabled = (privileges.check("MaintainBBOMs"));\n        tmpact.triggered.connect(editbbi);\n\n        tmpact = pMenu.addAction(qsTr("View Breeder Bill of Material Item..."));\n        tmpact.enabled = (privileges.check("MaintainBBOMs") ||\n                          privileges.check("ViewBBOMs"));\n        tmpact.triggered.connect(viewbbi);\n      }\n      else if(pItem.text(3) == "BMH")//BOMHead\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Bill of Material..."));\n        tmpact.enabled = (privileges.check("MaintainBOMs"));\n        tmpact.triggered.connect(editbmh);\n\n        tmpact = pMenu.addAction(qsTr("View Bill of Material..."));\n        tmpact.enabled = (privileges.check("MaintainBOMs") ||\n                          privileges.check("ViewBOMs"));\n        tmpact.triggered.connect(viewbmh);\n      }\n      else if(pItem.text(3) == "BMI")//BOM Item\n      {\n        tmpact = pMenu.addAction(qsTr("Edit BOM Item..."));\n        tmpact.enabled = (privileges.check("MaintainBOMs"));\n        tmpact.triggered.connect(editbomitem);\n\n        tmpact = pMenu.addAction(qsTr("View BOM Item..."));\n        tmpact.enabled = (privileges.check("MaintainBOMs") ||\n                          privileges.check("ViewBOMs"));\n        tmpact.triggered.connect(viewbomitem);\n      }\n      else if(pItem.text(3) == "BOH")//BOO Head\n      {\n        tmpact = pMenu.addAction(qsTr("Edit BOO Head..."));\n        tmpact.enabled = (privileges.check("MaintainBOOs"));\n        tmpact.triggered.connect(editboh);\n\n        tmpact = pMenu.addAction(qsTr("View BOO Head..."));\n        tmpact.enabled = (privileges.check("MaintainBOOs") ||\n                          privileges.check("ViewBOOs"));\n        tmpact.triggered.connect(viewboh);\n      }\n      else if(pItem.text(3) == "BOI")//BOO Item\n      {\n        tmpact = pMenu.addAction(qsTr("Edit BOO Item..."));\n        tmpact.enabled = (privileges.check("MaintainBOOs"));\n        tmpact.triggered.connect(editboi);\n\n        tmpact = pMenu.addAction(qsTr("View BOO Item..."));\n        tmpact.enabled = (privileges.check("MaintainBOOs") ||\n                          privileges.check("ViewBOOs"));\n        tmpact.triggered.connect(viewboi);\n      }\n      else if(pItem.text(3) == "CRMA")//CRMAccount\n      {\n        tmpact = pMenu.addAction(qsTr("Edit CRM Account..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalCRMAccounts") ||\n                          privileges.check("MaintainAllCRMAccounts"));\n        tmpact.triggered.connect(editcrma);\n\n        tmpact = pMenu.addAction(qsTr("View CRM Account..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalCRMAccounts") ||\n                          privileges.check("ViewPersonalCRMAccounts")||\n                          privileges.check("MaintainPersonalCRMAccounts") ||\n                          privileges.check("ViewAllCRMAccounts"));\n        tmpact.triggered.connect(viewcrma);\n      }\n      else if(pItem.text(3) == "T-Contact")//Contact\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Contact..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalContacts") ||\n                          privileges.check("MaintainAllContacts"));\n        tmpact.triggered.connect(editcntct);\n\n        tmpact = pMenu.addAction(qsTr("View Contact..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalContacts") ||\n                          privileges.check("ViewPersonalContacts")||\n                          privileges.check("MaintainAllContacts") ||\n                          privileges.check("ViewAllContacts"));\n        tmpact.triggered.connect(viewcntct);\n      }\n      else if(pItem.text(3) == "C")//Customer\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Customer..."));\n        tmpact.enabled = (privileges.check("MaintainCustomerMasters"));\n        tmpact.triggered.connect(editcustomer);\n\n        tmpact = pMenu.addAction(qsTr("View Customer..."));\n        tmpact.enabled = (privileges.check("MaintainCustomerMasters") ||\n                          privileges.check("ViewCustomerMasters"));\n        tmpact.triggered.connect(viewcustomer);\n      }\n      else if(pItem.text(3) == "EMP")//Employee\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Employee..."));\n        tmpact.enabled = (privileges.check("MaintainEmployees"));\n        tmpact.triggered.connect(editemp);\n\n        tmpact = pMenu.addAction(qsTr("View Employee..."));\n        tmpact.enabled = (privileges.check("MaintainEmployees") ||\n                          privileges.check("ViewEmployees"));\n        tmpact.triggered.connect(viewemp);\n      }\n      else if(pItem.text(3) == "INCDT")//Incident\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Incident..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalIncidents") ||\n                          privileges.check("MaintainAllIncidents"));\n        tmpact.triggered.connect(editincdt);\n\n        tmpact = pMenu.addAction(qsTr("View Incident..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalIncidents") ||\n                          privileges.check("ViewPersonalIncidents")||\n                          privileges.check("MaintainAllIncidents") ||\n                          privileges.check("ViewAllIncidents"));\n        tmpact.triggered.connect(viewincdt);\n      }\n      else if(pItem.text(3) == "I")//Item\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Item..."));\n        tmpact.enabled = (privileges.check("MaintainItemMasters"));\n        tmpact.triggered.connect(edititem);\n\n        tmpact = pMenu.addAction(qsTr("View Item..."));\n        tmpact.enabled = (privileges.check("MaintainItemMasters") ||\n                          privileges.check("ViewItemMasters"));\n        tmpact.triggered.connect(viewitem);\n      }\n      else if(pItem.text(3) == "IS")//ItemSite\n      {\n        tmpact = pMenu.addAction(qsTr("Edit ItemSite..."));\n        tmpact.enabled = (privileges.check("MaintainItemSites"));\n        tmpact.triggered.connect(edititemsite);\n\n        tmpact = pMenu.addAction(qsTr("View ItemSite..."));\n        tmpact.enabled = (privileges.check("MaintainItemSites") ||\n                          privileges.check("ViewItemSites"));\n        tmpact.triggered.connect(viewitemsite);\n      }\n      else if(pItem.text(3) == "IR")//ItemSource\n      {\n        tmpact = pMenu.addAction(qsTr("Edit ItemSource..."));\n        tmpact.enabled = (privileges.check("MaintainItemSources"));\n        tmpact.triggered.connect(edititemsource);\n\n        tmpact = pMenu.addAction(qsTr("View ItemSource..."));\n        tmpact.enabled = (privileges.check("MaintainItemSources") ||\n                          privileges.check("ViewItemSources"));\n        tmpact.triggered.connect(viewitemsource);\n      }\n      else if(pItem.text(3) == "L")//Location\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Location..."));\n        tmpact.enabled = (privileges.check("MaintainLocations"));\n        tmpact.triggered.connect(editlocation);\n\n        tmpact = pMenu.addAction(qsTr("View Location..."));\n        tmpact.enabled = (privileges.check("MaintainLocations") ||\n                          privileges.check("ViewLocations"));\n        tmpact.triggered.connect(viewlocation);\n      }\n      else if(pItem.text(3) == "LS")//LotSerial\n      {\n        tmpact = pMenu.addAction(qsTr("Edit LotSerial..."));\n        tmpact.triggered.connect(editlotserial);\n\n        tmpact = pMenu.addAction(qsTr("View LotSerial..."));\n        tmpact.triggered.connect(viewlotserial);\n      }\n      else if(pItem.text(3) == "OPP-Opportunity")//Opportunity\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Opportunity..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalOpportunities") ||\n                          privileges.check("MaintainAllOpportunities"));\n        tmpact.triggered.connect(editopp);\n\n        tmpact = pMenu.addAction(qsTr("View Opportunity..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalOpportunities") ||\n                          privileges.check("ViewPersonalOpportunities")||\n                          privileges.check("MaintainAllOpportunities") ||\n                          privileges.check("ViewAllOpportunities"));\n        tmpact.triggered.connect(viewopp);\n      }\n      else if(pItem.text(3) == "J")//Project\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Project..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalProjects") ||\n                          privileges.check("MaintainAllProjects"));\n        tmpact.triggered.connect(editprj);\n\n        tmpact = pMenu.addAction(qsTr("View Project..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalProjects") ||\n                          privileges.check("ViewPersonalProjects")||\n                          privileges.check("MaintainAllProjects") ||\n                          privileges.check("ViewAllProjects"));\n        tmpact.triggered.connect(viewprj);\n      }\n      else if(pItem.text(3) == "P")//Purchase Order\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Purchase Order..."));\n        tmpact.enabled = (privileges.check("MaintainPurchaseOrders"));\n        tmpact.triggered.connect(editpo);\n\n        tmpact = pMenu.addAction(qsTr("View Purchase Order..."));\n        tmpact.enabled = (privileges.check("MaintainPurchaseOrders") ||\n                          privileges.check("ViewPurchaseOrders"));\n        tmpact.triggered.connect(viewpo);\n      }\n      else if(pItem.text(3) == "PI")//Purchase Order Item\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Purchase Order Item..."));\n        tmpact.enabled = (privileges.check("MaintainPurchaseOrders"));\n        tmpact.triggered.connect(editpoitem);\n\n        tmpact = pMenu.addAction(qsTr("View Purchase Order Item..."));\n        tmpact.enabled = (privileges.check("MaintainPurchaseOrders") ||\n                          privileges.check("ViewPurchaseOrders"));\n        tmpact.triggered.connect(viewpoitem);\n      }\n      else if(pItem.text(3) == "RA")//Return Authorisation\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Return Authorisation..."));\n        tmpact.enabled = (privileges.check("MaintainReturns"));\n        tmpact.triggered.connect(editreturnauth);\n\n        tmpact = pMenu.addAction(qsTr("View Return Authorisation..."));\n        tmpact.enabled = (privileges.check("MaintainReturns") ||\n                          privileges.check("ViewReturns"));\n        tmpact.triggered.connect(viewreturnauth);\n      }\n      else if(pItem.text(3) == "RI")//Return Authorisation Item\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Return Authorisation Item..."));\n        tmpact.enabled = (privileges.check("MaintainReturns"));\n        tmpact.triggered.connect(editreturnauthitem);\n\n        tmpact = pMenu.addAction(qsTr("View Return Authorisation Item..."));\n        tmpact.enabled = (privileges.check("MaintainReturns") ||\n                          privileges.check("ViewReturns"));\n        tmpact.triggered.connect(viewreturnauthitem);\n      }\n      else if(pItem.text(3) == "Q")//Quote\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Quote..."));\n        tmpact.enabled = (privileges.check("MaintainQuotes"));\n        tmpact.triggered.connect(editquote);\n\n        tmpact = pMenu.addAction(qsTr("View Quote..."));\n        tmpact.enabled = (privileges.check("MaintainQuotes") ||\n                          privileges.check("ViewQuotes"));\n        tmpact.triggered.connect(viewquote);\n      }\n      else if(pItem.text(3) == "QI")//Quote Item\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Quote Item..."));\n        tmpact.enabled = (privileges.check("MaintainQuotes"));\n        tmpact.triggered.connect(editquoteitem);\n\n        tmpact = pMenu.addAction(qsTr("View Quote Item..."));\n        tmpact.enabled = (privileges.check("MaintainQuotes") ||\n                          privileges.check("ViewQuotes"));\n        tmpact.triggered.connect(viewquoteitem);\n      }\n      else if(pItem.text(3) == "S")//Sales Order\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Sales Order..."));\n        tmpact.enabled = (privileges.check("MaintainSalesOrders"));\n        tmpact.triggered.connect(editso);\n\n        tmpact = pMenu.addAction(qsTr("View Sales Order..."));\n        tmpact.enabled = (privileges.check("MaintainSalesOrders") ||\n                          privileges.check("ViewSalesOrders"));\n        tmpact.triggered.connect(viewso);\n      }\n      else if(pItem.text(3) == "SI")//Sales Order Item\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Sales Order Item..."));\n        tmpact.enabled = (privileges.check("MaintainSalesOrders"));\n        tmpact.triggered.connect(editsoitem);\n\n        tmpact = pMenu.addAction(qsTr("View Sales Order Item..."));\n        tmpact.enabled = (privileges.check("MaintainSalesOrders") ||\n                          privileges.check("ViewSalesOrders"));\n        tmpact.triggered.connect(viewsoitem);\n      }\n      else if(pItem.text(3) == "TA")//Task\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Task..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalProjects") ||\n                          privileges.check("MaintainAllProjects"));\n        tmpact.triggered.connect(edittask);\n\n        tmpact = pMenu.addAction(qsTr("View Task..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalProjects") ||\n                          privileges.check("ViewPersonalProjects")||\n                          privileges.check("MaintainAllProjects") ||\n                          privileges.check("ViewAllProjects"));\n        tmpact.triggered.connect(viewtask);\n      }\n      else if(pItem.text(3) == "TD")//TodoItem\n      {\n        tmpact = pMenu.addAction(qsTr("Edit TodoItem..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalToDoItems") ||\n                          privileges.check("MaintainAllToDoItems"));\n        tmpact.triggered.connect(edittodoitem);\n\n        tmpact = pMenu.addAction(qsTr("View TodoItem..."));\n        tmpact.enabled = (privileges.check("MaintainPersonalToDoItems") ||\n                          privileges.check("ViewPersonalToDoItems")||\n                          privileges.check("MaintainAllToDoItems") ||\n                          privileges.check("ViewAllToDoItems"));\n        tmpact.triggered.connect(viewtodoitem);\n      }\n      else if(pItem.text(3) == "TO")//Transfer Order\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Transfer Order..."));\n        tmpact.enabled = (privileges.check("MaintainTransferOrders"));\n        tmpact.triggered.connect(editto);\n\n        tmpact = pMenu.addAction(qsTr("View Transfer Order..."));\n        tmpact.enabled = (privileges.check("MaintainTransferOrders") ||\n                          privileges.check("ViewTransferOrders"));\n        tmpact.triggered.connect(viewto);\n      }\n      else if(pItem.text(3) == "TI")//Transfer Order Item\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Transfer Order Item..."));\n        tmpact.enabled = (privileges.check("MaintainTransferOrders"));\n        tmpact.triggered.connect(edittoitem);\n\n        tmpact = pMenu.addAction(qsTr("View Transfer Order Item..."));\n        tmpact.enabled = (privileges.check("MaintainTransferOrders") ||\n                          privileges.check("ViewTransferOrders"));\n        tmpact.triggered.connect(viewtoitem);\n      }\n      else if(pItem.text(3) == "V")//Vendor\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Vendor..."));\n        tmpact.enabled = (privileges.check("MaintainVendors"));\n        tmpact.triggered.connect(editvend);\n\n        tmpact = pMenu.addAction(qsTr("View Vendor..."));\n        tmpact.enabled = (privileges.check("MaintainVendors") ||\n                          privileges.check("ViewVendors"));\n        tmpact.triggered.connect(viewvend);\n      }\n      else if(pItem.text(3) == "WH")//WareHouse\n      {\n        tmpact = pMenu.addAction(qsTr("Edit WareHouse..."));\n        tmpact.enabled = (privileges.check("MaintainWarehouses"));\n        tmpact.triggered.connect(editwh);\n\n        tmpact = pMenu.addAction(qsTr("View WareHouse..."));\n        tmpact.enabled = (privileges.check("MaintainWarehouses") ||\n                          privileges.check("ViewWarehouses"));\n        tmpact.triggered.connect(viewwh);\n      }\n      else if(pItem.text(3) == "W")//Work Order\n      {\n        tmpact = pMenu.addAction(qsTr("Edit Work Order..."));\n        tmpact.enabled = (privileges.check("MaintainWorkOrders"));\n        tmpact.triggered.connect(editwo);\n\n        tmpact = pMenu.addAction(qsTr("View Work Order..."));\n        tmpact.enabled = (privileges.check("MaintainWorkOrders"));\n        tmpact.triggered.connect(viewwo);\n      }\n    }\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "populateMenuCommentConsole exception: " + e);\n  }\n}\n\nfunction preferencesCommentConsole()\n{\n  try\n  {\n  \tparams = new Object;\n    var newdlg = toolbox.openWindow("preferencesComment", mainwindow,\n                                  Qt.ApplicationModal, Qt.Dialog);\n    toolbox.lastWindow().set(params);\n    if (newdlg.exec())\n      refreshCommentConsole();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "preferencesCommentConsole exception: " + e);\n  }\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshCommentConsole()\n{\n  try\n  {\n  \t_commentConsoleIsDirty = true;\n    fillListCommentConsole();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "refreshCommentConsole exception: " + e);\n  }\n}\n\nfunction editaddr()\n{\n  try\n  {\n    var params =  new Object();\n    params.addr_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("address", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editaddr exception: " + e);\n  }\n}\n\nfunction viewaddr()\n{\n  try\n  {\n    var params =  new Object();\n    params.addr_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("address", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewaddr exception: " + e);\n  }\n}\n\nfunction editbbh()\n{\n  try\n  {\n    var params =  new Object();\n    params.item_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("bbom", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editbbh exception: " + e);\n  }\n}\n\nfunction viewbbh()\n{\n  try\n  {\n    var params =  new Object();\n    params.item_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("bbom", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewbbh exception: " + e);\n  }\n}\n\nfunction editbbi()\n{\n  try\n  {\n    var params =  new Object();\n    params.bbomitem_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("bbomItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editbbi exception: " + e);\n  }\n}\n\nfunction viewbbi()\n{\n  try\n  {\n    var params =  new Object();\n    params.bbomitem_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("bbomItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewbbi exception: " + e);\n  }\n}\n\nfunction editbmh()\n{\n  try\n  {\n    var params =  new Object();\n    params.item_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("bom", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editbmh exception: " + e);\n  }\n}\n\nfunction viewbmh()\n{\n  try\n  {\n    var params =  new Object();\n    params.item_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("bom", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewbmh exception: " + e);\n  }\n}\n\nfunction editbomitem()\n{\n  try\n  {\n    params = new Object;\n    params.bomitem_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("bomItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editbomitem exception: " + e);\n  }\n}\n\nfunction viewbomitem()\n{\n  try\n  {\n    params = new Object;\n    params.bomitem_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("bomItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewbomitem exception: " + e);\n  }\n}\n\nfunction editboh()\n{\n  try\n  {\n    params = new Object;\n    params.item_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("boo", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editboh exception: " + e);\n  }\n}\n\nfunction viewboh()\n{\n  try\n  {\n    params = new Object;\n    params.item_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("boo", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewboh exception: " + e);\n  }\n}\n\nfunction editboi()\n{\n  try\n  {\n    params = new Object;\n    params.booitem_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("booItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editboi exception: " + e);\n  }\n}\n\nfunction viewboi()\n{\n  try\n  {\n    params = new Object;\n    params.booitem_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("booItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewboi exception: " + e);\n  }\n}\n\nfunction editcntct()\n{\n  try\n  {\n    var params =  new Object();\n    params.cntct_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("contact", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editcntct exception: " + e);\n  }\n}\n\nfunction viewcntct()\n{\n  try\n  {\n    var params =  new Object();\n    params.cntct_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("contact", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewcntct exception: " + e);\n  }\n}\n\nfunction editcrma()\n{\n  try\n  {\n    var params =  new Object();\n    params.crmacct_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("crmaccount", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editcrma exception: " + e);\n  }\n}\n\nfunction viewcrma()\n{\n  try\n  {\n    var params =  new Object();\n    params.crmacct_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("crmaccount", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewcrma exception: " + e);\n  }\n}\n\nfunction editcustomer()\n{\n  try\n  {\n    var params =  new Object();\n    params.cust_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("customer", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editcustomer exception: " + e);\n  }\n}\n\nfunction viewcustomer()\n{\n  try\n  {\n    var params =  new Object();\n    params.cust_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("customer", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewcustomer exception: " + e);\n  }\n}\n\nfunction editemp()\n{\n  try\n  {\n    var params =  new Object();\n    params.emp_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("employee", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editemp exception: " + e);\n  }\n}\n\nfunction viewemp()\n{\n  try\n  {\n    var params =  new Object();\n    params.emp_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("employee", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewemp exception: " + e);\n  }\n}\n\nfunction editincdt()\n{\n  try\n  {\n    params = new Object;\n    params.incdt_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("incident", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editincdt exception: " + e);\n  }\n}\n\nfunction viewincdt()\n{\n  try\n  {\n    var params =  new Object();\n    params.incdt_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("incident", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewincdt exception: " + e);\n  }\n}\n\nfunction edititem()\n{\n  try\n  {\n    var params =  new Object();\n    params.item_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("item", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "edititem exception: " + e);\n  }\n}\n\nfunction viewitem()\n{\n  try\n  {\n    var params =  new Object();\n    params.item_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("item", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewitem exception: " + e);\n  }\n}\n\nfunction edititemsite()\n{\n  try\n  {\n    params = new Object;\n    params.itemsite_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("itemSite", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "edititemsite exception: " + e);\n  }\n}\n\nfunction viewitemsite()\n{\n  try\n  {\n    params = new Object;\n    params.itemsite_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("itemSite", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewitemsite exception: " + e);\n  }\n}\n\nfunction edititemsource()\n{\n  try\n  {\n    params = new Object;\n    params.itemsrc_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("itemSource", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "edititemsource exception: " + e);\n  }\n}\n\nfunction viewitemsource()\n{\n  try\n  {\n    params = new Object;\n    params.itemsrc_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("itemSource", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewitemsource exception: " + e);\n  }\n}\n\nfunction editlocation()\n{\n  try\n  {\n    var params =  new Object();\n    params.location_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("location", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editlocation exception: " + e);\n  }\n}\n\nfunction viewlocation()\n{\n  try\n  {\n    var params =  new Object();\n    params.location_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("location", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewlocation exception: " + e);\n  }\n}\n\nfunction editlotserial()\n{\n  try\n  {\n    var params =  new Object();\n    params.ls_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("lotSerial", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editlotserial exception: " + e);\n  }\n}\n\nfunction viewlotserial()\n{\n  try\n  {\n    var params =  new Object();\n    params.ls_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("lotSerial", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewlotserial exception: " + e);\n  }\n}\n\nfunction editopp()\n{\n  try\n  {\n    var params =  new Object();\n    params.ophead_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("opportunity", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editopp exception: " + e);\n  }\n}\n\nfunction viewopp()\n{\n  try\n  {\n    var params =  new Object();\n    params.ophead_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("opportunity", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewopp exception: " + e);\n  }\n}\n\nfunction editprj()\n{\n  try\n  {\n    var params =  new Object();\n    params.prj_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("project", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editprj exception: " + e);\n  }\n}\n\nfunction viewprj()\n{\n  try\n  {\n    var params =  new Object();\n    params.prj_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("project", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewprj exception: " + e);\n  }\n}\n\nfunction editpo()\n{\n  try\n  {\n    var params =  new Object();\n    params.pohead_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("purchaseOrder", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editpo exception: " + e);\n  }\n}\n\nfunction viewpo()\n{\n  try\n  {\n    var params =  new Object();\n    params.pohead_id = _commentConsole.id();\n\n    params.mode = "view";\n    var newdlg = toolbox.openWindow("purchaseOrder", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewpo exception: " + e);\n  }\n}\n\nfunction editpoitem()\n{\n  try\n  {\n    params = new Object;\n    params.poitem_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("purchaseOrderItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editpoitem exception: " + e);\n  }\n}\n\nfunction viewpoitem()\n{\n  try\n  {\n    params = new Object;\n    params.poitem_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("purchaseOrderItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewpoitem exception: " + e);\n  }\n}\n\nfunction editquote()\n{\n  try\n  {\n    var params =  new Object();\n    params.quhead_id = _commentConsole.id();\n\n    params.mode = "editQuote";\n    var newdlg = toolbox.openWindow("salesOrder", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editquote exception: " + e);\n  }\n}\n\nfunction viewquote()\n{\n  try\n  {\n    var params =  new Object();\n    params.quhead_id = _commentConsole.id();\n\n    params.mode = "viewQuote";\n    var newdlg = toolbox.openWindow("salesOrder", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewquote exception: " + e);\n  }\n}\n\nfunction editquoteitem()\n{\n  try\n  {\n    params = new Object;\n    params.soitem_id = _commentConsole.id();\n    params.mode = "editQuote";\n    var newdlg = toolbox.openWindow("salesOrderItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editquoteitem exception: " + e);\n  }\n}\n\nfunction viewquoteitem()\n{\n  try\n  {\n    params = new Object;\n    params.soitem_id = _commentConsole.id();\n    params.mode = "viewQuote";\n\n    var newdlg = toolbox.openWindow("salesOrderItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewquoteitem exception: " + e);\n  }\n}\n\nfunction editreturnauth()\n{\n  try\n  {\n    var params =  new Object();\n    params.rahead_id = _commentConsole.id();\n\n    params.mode = "edit";\n    var newdlg = toolbox.openWindow("returnAuthorization", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editreturnauth exception: " + e);\n  }\n}\n\nfunction viewreturnauth()\n{\n  try\n  {\n    var params =  new Object();\n    params.rahead_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("returnAuthorization", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewreturnauth exception: " + e);\n  }\n}\n\nfunction editreturnauthitem()\n{\n  try\n  {\n    var params =  new Object();\n    params.raitem_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("returnAuthorizationItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editreturnauthitem exception: " + e);\n  }\n}\n\nfunction viewreturnauthitem()\n{\n  try\n  {\n    var params =  new Object();\n    params.raitem_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("returnAuthorizationItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewreturnauthitem exception: " + e);\n  }\n}\n\nfunction editso()\n{\n  try\n  {\n    var params =  new Object();\n    params.sohead_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("salesOrder", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editso exception: " + e);\n  }\n}\n\nfunction viewso()\n{\n  try\n  {\n    var params =  new Object();\n    params.sohead_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("salesOrder", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewso exception: " + e);\n  }\n}\n\nfunction editsoitem()\n{\n  try\n  {\n    params = new Object;\n    params.soitem_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("salesOrderItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editsoitem exception: " + e);\n  }\n}\n\nfunction viewsoitem()\n{\n  try\n  {\n    params = new Object;\n    params.soitem_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("salesOrderItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewsoitem exception: " + e);\n  }\n}\n\nfunction edittask()\n{\n  try\n  {\n    params = new Object;\n    params.prjtask_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("task", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "edittask exception: " + e);\n  }\n}\n\nfunction viewtask()\n{\n  try\n  {\n    params = new Object;\n    params.prjtask_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("task", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewtask exception: " + e);\n  }\n}\n\nfunction edittodoitem()\n{\n  try\n  {\n    params = new Object;\n    params.todoitem_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("todoItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "edittodoitem exception: " + e);\n  }\n}\n\nfunction viewtodoitem()\n{\n  try\n  {\n    params = new Object;\n    params.todoitem_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("todoItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewtodoitem exception: " + e);\n  }\n}\n\nfunction editto()\n{\n  try\n  {\n    var params =  new Object();\n    params.tohead_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("transferOrder", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editto exception: " + e);\n  }\n}\n\nfunction viewto()\n{\n  try\n  {\n    var params =  new Object();\n    params.tohead_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("transferOrder", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewto exception: " + e);\n  }\n}\n\nfunction edittoitem()\n{\n  try\n  {\n    params = new Object;\n    params.toitem_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("transferOrderItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "edittoitem exception: " + e);\n  }\n}\n\nfunction viewtoitem()\n{\n  try\n  {\n    params = new Object;\n    params.toitem_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("transferOrderItem", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewtoitem exception: " + e);\n  }\n}\n\nfunction editvend()\n{\n  try\n  {\n    var params =  new Object();\n    params.vend_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("vendor", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editvend exception: " + e);\n  }\n}\n\nfunction viewvend()\n{\n  try\n  {\n    var params =  new Object();\n    params.vend_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("vendor", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewvend exception: " + e);\n  }\n}\n\nfunction editwh()\n{\n  try\n  {\n    params = new Object;\n    params.warehous_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("warehouse", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editwh exception: " + e);\n  }\n}\n\nfunction viewwh()\n{\n  try\n  {\n    params = new Object;\n    params.warehous_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("warehouse", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    var execval = newdlg.exec();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewwh exception: " + e);\n  }\n}\n\nfunction editwo()\n{\n  try\n  {\n    var params =  new Object();\n    params.wo_id = _commentConsole.id();\n    params.mode = "edit";\n\n    var newdlg = toolbox.openWindow("workOrder", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "editwo exception: " + e);\n  }\n}\n\nfunction viewwo()\n{\n  try\n  {\n    var params =  new Object();\n    params.wo_id = _commentConsole.id();\n    params.mode = "view";\n\n    var newdlg = toolbox.openWindow("workOrder", mainwindow, 0, 1);\n    var tmp = toolbox.lastWindow().set(params);\n    newdlg.exec;\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockSendMessage",\n                         "viewwo exception: " + e);\n  }\n}\n 
106091
 
87      incident        0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("dockMyTodo");\n\n// Connect this window so that the To Do dock list gets updated\nmydialog.finished.connect(fillListToDo);\n     
106092
 
88      initMenu        1       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\n// Import code from related scripts\ninclude("dockBankBal");\ninclude("dockExtensions");\ninclude("dockGLAccounts");\ninclude("dockMessageHistory");\ninclude("dockMfgActive");\ninclude("dockMfgHist");\ninclude("dockMfgOpen");\ninclude("dockMyAccounts");\ninclude("dockMyContacts");\ninclude("dockMyTodo");\ninclude("dockPayables");\ninclude("dockPurchActive");\ninclude("dockPurchHist");\ninclude("dockPurchOpen");\ninclude("dockReceivables");\ninclude("dockSalesActive");\ninclude("dockSalesHistory");\ninclude("dockSalesOpen");\ninclude("dockSendMessage");\ninclude("dockUserOnline");\n\nvar _desktopStack;\nvar _open = qsTr("Open...");\nvar _dtTimer;\nvar _leftAreaDocks = new Array();\nvar _bottomAreaDocks = new Array();\nvar _windows = new Array();\nvar _hasSavedState = settingsValue("hasSavedState").length > 0;\nvar _vToolBar;\nvar _vToolBarActions = new Array();\n\nvar _menuDesktop = new QMenu(qsTr("Desktop"),mainwindow);\nvar _menuToolBar = new QMenu(mainwindow);\nvar _menuWindow = mainwindow.findChild("menu.window");\n\n// Create Menu items for setup windows\nvar _menuSetup = new QMenu(qsTr("Setup"),mainwindow);\n\n// Add desktop to main window\naddAction("sys.currencies","currencies","CreateNewCurrency","CreateNewCurrency");\naddAction("sys.exchangeRates","currencyConversions","MaintainCurrencyRates","ViewCurrencyRates");\n\n// Set up refresh timer\n_dtTimer = new QTimer(mainwindow);\n_dtTimer.setInterval(metrics.value("desktop/timer"));\n_dtTimer.start();\n\n// Set the desktop\n_desktopStack = toolbox.createWidget("QStackedWidget", mainwindow, "_desktopStack");\nvar _desktopParent;\n\n// if this handleNewWindow overload exists then GUIClient is a QMdiArea\nif (mainwindow.showTopLevel())\n  _desktopParent = mainwindow;\n// disable desktop when inside workspace mode\n//else if ("handleNewWindow(QWidget*,Qt::WindowModality,bool)" in mainwindow)\n//  _desktopParent = toolbox.openWindow("desktop", mainwindow);\n\nif (_desktopParent)\n{\n_desktopParent.setCentralWidget(_desktopStack);\n_vToolBar = new QToolBar(_desktopParent);\n_desktopParent.addToolBar(Qt.LeftToolBarArea, _vToolBar);\n\n// Intialize the left toolbar\n_vToolBar.objectName = "_vToolBar";\n_vToolBar.windowTitle = "Desktop Toolbar";\n_vToolBar.floatable = false;\n_vToolBar.movable = false;\n_vToolBar.visible = true;\n_vToolBar.toolButtonStyle = Qt.ToolButtonTextUnderIcon;\n\n// Initialize Desktop\n// Set up browser for home Page\nvar _welcome = new QWebView(mainwindow);\nvar firstURL = metrics.value("desktop/welcome");\nvar databaseURL = mainwindow.databaseURL();\nvar string =  databaseURL.split("/");\nvar databaseName = string[3];\nvar hostName = string[2].substring(0, string[2].indexOf(":"))\nvar serverVersion = metrics.value("ServerVersion");\nvar application = metrics.value("Application");\nvar secondURL = firstURL + \n"?client=desktop" + \n"&hostname=" + hostName +  \n"&organization=" + databaseName +\n"&edition=" + application + \n"&version=" + serverVersion;\n_welcome.objectName = "_welcome";\nvar url = new QUrl(secondURL);\n_welcome["loadFinished(bool)"].connect(loadLocalHtml);\n_welcome["linkClicked(const QUrl &)"].connect(openUrl);\n_welcome.load(url);\n_welcome.page().linkDelegationPolicy = QWebPage.DelegateAllLinks;\n_desktopStack.addWidget(_welcome);\naddToolBarAction(qsTr("Welcome"), "home_32");\n_vToolBarActions[0].checked = true;\n\n// Initialize additional desktop UIs and Dock Widgets\n// (Init functions come from the code pulled in by the include statements)\naddDesktop("desktopCRM", "clients_32", "ViewCRMDesktop");\ninitDockTodo();\ninitDockAccounts();\ninitDockMyCntcts();\n\naddDesktop("desktopSales", "reward_32", "ViewSalesDesktop");\ninitDockSalesAct();\ninitDockSalesHist();\ninitDockSalesOpen();\naddDesktop("desktopAccounting", "accounting_32", "ViewAccountingDesktop");\ninitDockPayables();\ninitDockReceivables();\ninitDockBankBal();\ninitDockGLAccounts();\n\naddDesktop("desktopPurchase", "order_32", "ViewPurchaseDesktop");\ninitDockPurchAct();\ninitDockPurchHist();\ninitDockPurchOpen();\n\naddDesktop("desktopManufacture", "industry_32", "ViewManufactureDesktop");\ninitDockMfgAct();\ninitDockMfgHist();\ninitDockMfgOpen();\n\naddDesktop("desktopSocial", "social", "viewSocialDesktop");\ninitDockUserOnline();\ninitDockMessageHistory();\ninitDockSendMessage();\n\nvar maintWin = addDesktop("desktopMaintenance", "gear_32", "ViewMaintenanceDesktop");\ninitDockExtensions();\n//initDockUserOnline();\n\n// Hack to fix icon size problem until next core release\nvar maintToolbar = maintWin.findChild("_toolbar");\n_vToolBar.iconSize = maintToolbar.iconSize;\nmaintWin.removeToolBar(maintToolbar);\n\n// Handle window actions\n_menuWindow.aboutToShow.connect(prepareWindowMenu);\n\n// Change behavior of item site button if commercial edition\nif (metrics.boolean("MultiWhs"))\n{\n  var button = mainwindow.findChild("_sites");\n  button.label = qsTr("Sites");\n  button.actionName = "im.warehouses";\n}\n}\nelse\n{\n  if (!preferences.boolean("NoDesktopNotice"))\n    toolbox.openWindow("desktopNotice",mainwindow, Qt.WindowModal, Qt.Dialog);\n}\n\n/*!\n  Adds screen with name of @a uiName to the desktop stack so long as the user has\n  been granted the privilege @a privName. The @a windowTitle of the UI object is \n  added to the Desktop Dock so that when it is clicked, the associated window is \n  selected on the Desktop.\n*/\nfunction addDesktop(uiName, imageName, privilege)\n{\n  // Get the UI and add to desktop stack\n  var desktop = toolbox.loadUi(uiName);\n  _desktopStack.addWidget(desktop);\n  _windows[_windows.length] = desktop;\n  addToolBarAction(desktop.windowTitle, imageName, privilege);\n  desktop.restoreState();\n\n  return desktop;\n}\n\n/*!\n  Add a button with @a label and @a imageName to the left desktop toolbar\n*/\nfunction addToolBarAction(label, imageName, privilege)\n{\n  // Get the icon\n  var icn = new QIcon();\n  icn.addDbImage(imageName);\n\n  // Create the action (add to menu not seen to ensure priv rescans work)\n  var act = _menuToolBar.addAction(icn, label);\n  act.checkable = true;\n  if (privilege)\n  {\n    act.setEnabled(privileges.check(privilege));\n    act.setData(privilege);\n  }\n\n  // Add to toolbar\n  _vToolBar.addAction(act);\n  _vToolBarActions[_vToolBarActions.length] = act;\n  _vToolBar["actionTriggered(QAction*)"].connect(toolbarActionTriggered);\n}\n\n/*!\n  Loads a local HTML page from the database if the xTuple weclome page\n  fails to load.\n*/\nfunction loadLocalHtml(ok)\n{\n  if (!ok)\n  {\n    // Page didn't load, so load internal HTML saying we aren't connected\n    var q = toolbox.executeQuery("SELECT xtdesktop.fetchWelcomeHtml() AS html");\n    q.first();\n    _welcome.setHtml(q.value("html"));\n  }\n  // We don't want to deal with loading any more web pages.  Let OS do it\n  _welcome.page().linkDelegationPolicy = QWebPage.DelegateAllLinks;;\n}\n\n\n/*!\n  Launches links clicked on home page into new local browser window\n*/\nfunction openUrl(url)\n{\n  toolbox.openUrl(new QUrl(url).toString());\n}\n\n/*!\n  Adds desktop to the window menu\n*/\nfunction prepareWindowMenu()\n{\n  // TO DO: Make this more modular\n  var idx = _desktopStack.currentIndex;\n  _dockMycontacts.toggleViewAction().visible = (idx == 1);\n  _dockMyaccounts.toggleViewAction().visible = (idx == 1);\n  _dockMytodo.toggleViewAction().visible = (idx == 1);\n  _dockSalesAct.toggleViewAction().visible = (idx == 2);\n  _dockSalesHist.toggleViewAction().visible = (idx == 2);\n  _dockSalesOpen.toggleViewAction().visible = (idx == 2);\n  _dockBankBal.toggleViewAction().visible = (idx == 3);\n  _dockPayables.toggleViewAction().visible = (idx == 3);\n  _dockReceivables.toggleViewAction().visible = (idx == 3);\n  _dockGLAccounts.toggleViewAction().visible = (idx == 3);\n  _dockPurchAct.toggleViewAction().visible = (idx == 4);\n  _dockPurchHist.toggleViewAction().visible = (idx == 4);\n  _dockPurchOpen.toggleViewAction().visible = (idx == 4);\n  _dockMfgAct.toggleViewAction().visible = (idx == 5);\n  _dockMfgHist.toggleViewAction().visible = (idx == 5);\n  _dockMfgOpen.toggleViewAction().visible = (idx == 5);\n  _dockSendMessage.toggleViewAction().visible = (idx == 6);\n  _dockMessageHistory.toggleViewAction().visible = (idx == 6);\n  _dockUserOnline.toggleViewAction().visible = (idx == 6);\n  _dockExtensions.toggleViewAction().visible = (idx == 7);\n//  _dockUserOnline.toggleViewAction().visible = (idx == 7);\n  _menuWindow.addSeparator();\n  _menuWindow.addMenu(_menuDesktop);\n}\n\nfunction toolbarActionTriggered(action)\n{\n  // Move to the desktop page specified\n  for (i in _vToolBarActions)\n  {\n    if (_vToolBarActions[i] == action)\n      _desktopStack.currentIndex = i\n    else\n      _vToolBarActions[i].checked = false;\n  }\n}\n\nfunction addAction(actionName, slotName, editPriv, viewPriv)\n{\n  var tempaction;\n  tmpaction = new QAction(mainwindow);\n  tmpaction.enabled = privileges.value(editPriv) || privileges.value(viewPriv);\n  tmpaction.setData(editPriv + " " + viewPriv);\n  tmpaction.objectName = actionName;\n  tmpaction.triggered.connect(this, slotName);\n  _menuSetup.appendAction(tmpaction);\n}\n\nfunction openSetup(uiName)\n{\n  var params = new Object;\n  params.uiName = uiName;\n  var wnd = toolbox.openWindow("setup", mainwindow);\n  toolbox.lastWindow().set(params);\n  wnd.exec();\n}\n\nfunction currencies()\n{\n  openSetup("currencies");\n}\n\nfunction currencyConversions()\n{\n  openSetup("currencyConversions");\n}\n\n\n  
106093
 
92      task    0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("dockMyTodo");\n\n// Connect this window so that the To Do dock list gets updated\nmydialog.finished.connect(fillListToDo);\n     
106094
 
93      todoItem        0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("dockMyTodo");\n\n// Connect this window so that the To Do dock list gets updated\nmydialog.finished.connect(fillListToDo);\n     
106095
 
94      userPreferences 0       t       /*\n * This file is part of the xtdesktop package for xTuple ERP: PostBooks edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\nvar _interfaceWorkspace = mywindow.findChild("_interfaceWorkspace");\n\n_interfaceWorkspace.toggled.connect(desktopNotice);\n\nfunction desktopNotice()\n{\n  if (_interfaceWorkspace.checked &&\n      !preferences.boolean("NoDesktopNotice"))\n    toolbox.openWindow("desktopNotice", mywindow, Qt.WindowModal, Qt.Dialog);\n}\n  
106096
 
130     preferencesNumber       0       t       try\n{\n  var _limit = mywindow.findChild("_limit");\n  var _path;\n\n  mydialog.accepted.connect(mysave);\n}\ncatch (e)\n{\n  QMessageBox.critical(mainwindow, "preferencesNumber",\n                      "preferencesNumber.js exception: " + e);\n}\n\nfunction set(params)\n{\n  if ("path" in params)\n    _path = params.path;\n\n  if ("limit" in params)\n    _limit.value = params.limit;\n  else\n    _limit.value = 10;\n}\n\nfunction mysave()\n{\n  try\n  {\n    preferences.set(_path + "/limit", _limit.value);\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "preferencesNumber",\n                        "mysave exception: " + e);\n  }\n}\n        
106097
 
131     sendMessageToUser       0       t       //debugger;\n\nvar _usr       = mywindow.findChild("_usr");\nvar _message   = mywindow.findChild("_message");\nvar _send      = mywindow.findChild("_send");\n\nfunction getParams() \n{\n  var params = new Object;\n\n  params.message = _message.plainText;\n  if (_usr.id() > 0)\n    params.usr_id = _usr.id();\n\n  return params;\n}\n\nfunction sHandleButtons()\n{\n  var qry = "SELECT usr_id FROM usr WHERE usr_username = current_user;";\n  var data = toolbox.executeQuery(qry, -1);\n  if (data.first())\n    var currenttUsr_id = data.value("usr_id");\n\n  if (currenttUsr_id == _usr.id())\n  {\n    if (QMessageBox.information(mainwindow, qsTr("Send Message?"),\n                            qsTr("You are trying to Send Reply Message to Yourself."\n                              +"\\nAre you sure that you really want to Continue?."),\n           QMessageBox.Yes | QMessageBox.Default, QMessageBox.No | QMessageBox.Escape) == QMessageBox.No)\n    {\n      _usr.clear();\n      return;\n    }\n    else\n      _send.enabled = (_usr.id() >= 0);\n  }\n  else\n    _send.enabled = (_usr.id() >= 0);\n}\n\nfunction send()\n{\n  var params = getParams();    \n  var qry = toolbox.executeDbQuery("desktop", "sendMessageToUser", params);\n  QMessageBox.information(mywindow,'Sent','Message Sent');\n  mywindow.close();\n}\n\nfunction set(input)\n{\n  if ("user" in input)\n    _usr.setUsername(input.user);\n  else\n   QMessageBox.warning(mywindow, "Message", "Could not set username");\n}\n\n_usr["newId(int)"].connect(sHandleButtons);\n_send.clicked.connect(send);\nmywindow.findChild("_close").clicked.connect(mywindow, "close");\n     
106098
 
67      contact 0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("dockMyContacts");\n\n// Connect this window so that the My Contacts dock list gets updated\nvar _contactList = mainwindow.findChild("_contactList");\n\n// Connect this window so that the My Contacts dock list gets updated\n//new method for buttonbox, added for 3.8\n  var _buttonBox = mywindow.findChild("_buttonBox");\n  toolbox.coreDisconnect(_buttonBox, "accepted()", mywindow, "sSave()");\n  _buttonBox.accepted.connect(save);\n\n//method prior to 3.8 core release\n//var _save = mywindow.findChild("_save");\n//toolbox.coreDisconnect(_save, "clicked()", mydialog, "sSave()");\n//_save.clicked.connect(save);\n\nfunction save()\n{\n  mydialog.sSave();\n  fillListMyCntcts();\n}\n\n    
106099
 
70      dockExtensions  0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockExtensions;\nvar _extensions;\nvar _extensionsIsDirty = true;\n\n/*!\n  Initializes Extensions dock widget and places it in the main window.\n*/\nfunction initDockExtensions()\n{\n  _dockExtensions = mainwindow.findChild("_dockExtensions");\n  _extensions = mainwindow.findChild("_extensions");\n\n  // Set columns on list\n  _extensions.addColumn(qsTr("Name"), -1, Qt.AlignLeft, true, "pkgitem_name");\n  _extensions.addColumn(qsTr("Description"), -1, Qt.AlignLeft, false, "pkgitem_descrip");\n  _extensions.addColumn(qsTr("Type"), -1, Qt.AlignLeft, false, "pkgitem_type");\n\n  // Connect Signals and Slots\n  _dtTimer.timeout.connect(refreshExtensions);\n\n  _extensions.itemSelected.connect(openWindowExtensions);\n  _extensions["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuExtensions);\n\n  _dockExtensions.visibilityChanged.connect(fillListExtensions);\n\n  // Handle privilge control\n  var act = _dockExtensions.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewExtensionsDock"))\n  {\n    _dockExtensions.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewExtensionsDock");\n  _menuDesktop.appendAction(act);\n\n  fillListExtensions();\n}\n\n/*!\n  Fills the list with active sales data.\n*/\nfunction fillListExtensions()\n{\n  _dockExtensions = mainwindow.findChild("_dockExtensions");\n  _extensions = mainwindow.findChild("_extensions");\n\n  if (_dockExtensions.visible && _extensionsIsDirty)\n  {\n    var params = new Object;\n    params.script = qsTr("Scripts");\n    params.cmd = qsTr("Custom Commands");\n    params.procedure = qsTr("Stored Procedures");\n    params.trigger = qsTr("Triggers");\n    params.image = qsTr("Images");\n    params.metasql = qsTr("MetaSQL");\n    params.priv = qsTr("Privileges");\n    params.report = qsTr("Reports");\n    params.schema = qsTr("Schema");\n    params.table = qsTr("Tables");\n    params.uiform = qsTr("Screens");\n    params.view = qsTr("Views");\n    params.folder = qsTr("Folder");\n    params.client = qsTr("Client");\n    params.database = qsTr("Database");\n\n    _extensions.populate(toolbox.executeDbQuery("desktop","pkgItems", params))\n \n    _extensionsIsDirty = false;\n  }\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowExtensions()\n{\n  var ui;\n  var run = false;\n  var type = _extensions.currentItem().rawValue("pkgitem_type");\n  var params = new Object;\n  params.mode = "view";\n  \n  // Make sure we can open the window for this activity\n  if (!privilegeCheckExtensions(type))\n    return;\n\n  // Determine which window to open\n  if (type == "P")\n  {\n    ui = "package";\n    params.pkghead_id = _extensions.id();\n  }\n  else if (type == "C")\n  {\n    ui = "scriptEditor";\n    params.script_id = _extensions.id();\n  }\n  else if (type == "D")\n  {\n    ui = "customCommand";\n    params.cmd_id = _extensions.id();\n  }\n  else if (type == "I")\n  {\n    ui = "image";\n    params.image_id = _extensions.id();\n  }\n  else if (type == "M")\n    ui = "metasqls";\n  else if (type == "R")\n    ui = "reports";\n  else if (type == "U")\n  {\n    ui = "uiform";\n    params.uiform_id = _extensions.id();\n  }\n\n  // Open the window and perform any handling required\n  win = toolbox.openWindow(ui);\n  if (type == "M")\n  {\n    win.hide();\n    win.findChild("_list").setId(_extensions.id());\n    win.sEdit();\n    win.close();\n  }\n  else if (type == "R")\n  {\n    win.hide();\n    win.findChild("_report").setId(_extensions.id());\n    win.sEdit();\n    win.close();\n  }\n  else if (type == "U")\n  {\n    win.hide();\n    toolbox.lastWindow().set(params);\n    win.sEdit();\n  }\n  else\n  {\n    toolbox.lastWindow().set(params);\n    if (toolbox.lastWindow().exec())\n      fillListExtensions();\n  }\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on an Extension item.\n*/\nfunction populateMenuExtensions(pMenu, pItem)\n{\n  var menuItem;\n  var type = pItem.rawValue("pkgitem_type");\n  var enable = privilegeCheckExtensions(type);\n\n  // If not a type we have an editor for get out\n  if ((type != "P") &&\n      (type != "C") &&\n      (type != "D") &&\n      (type != "I") &&\n      (type != "M") &&\n      (type != "R") &&\n      (type != "U"))\n    return;\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowExtensions);\n}\n\n/*!\n  Returns whether user has privileges to view detail on the selected extension type.\n*/\nfunction privilegeCheckExtensions(type)\n{\n  if (type == "P")\n    return privileges.check("ViewPackages+#superuser")\n  else if (type == "C")\n    return privileges.check("MaintainScripts");\n  else if (type == "D") \n    return privileges.check("MaintainCustomCommands");\n  else if (type == "I") \n    return privileges.check("MaintainImages");\n  else if (type == "M")\n    return privileges.check("MaintainMetaSQL") ||\n           privileges.check("ViewMetaSQL");\n  else if (type == "R") \n    return privileges.check("MaintainReports");\n  else if (type == "U")\n    return privileges.check("MaintainScreens");\n\n  return false;\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshExtensions()\n{\n  _extensionsIsDirty = true;\n  fillListExtensions();\n}\n   
106100
 
71      dockGLAccounts  0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _b1GLAccounts;\nvar _b2GLAccounts;\nvar _dockGLAccounts;\nvar _glAccounts;\nvar _glAccountsIsDirty = true;\nvar _periodId = -1;\n\n/*!\n  Initializes Monitored Accounts dock widget and places it in the main window.\n*/\nfunction initDockGLAccounts()\n{\n  // Set up objects\n  _dockGLAccounts = mainwindow.findChild("_dockGLAccounts");\n  _glAccounts = mainwindow.findChild("_glAccounts");\n\n  _b1GLAccounts = _dockGLAccounts.findChild("_button1");\n  _b2GLAccounts = _dockGLAccounts.findChild("_button2");\n  _labelGLAccounts = _dockGLAccounts.findChild("_label");\n\n  // Set icons\n  var iReload = new QIcon;\n  iReload.addDbImage("reload_16");\n  _b1GLAccounts.icon = iReload;\n  _b1GLAccounts.text = "";\n  _b1GLAccounts.toolTip = qsTr("Reload");\n\n  var iGear = new QIcon();\n  iGear.addDbImage("gear_16");\n  _b2GLAccounts.icon = iGear;\n  _b2GLAccounts.text = "";\n  _b2GLAccounts.toolTip = qsTr("Preferences...");\n\n  // Set columns on list\n  _glAccounts.addColumn(qsTr("Number"), -1, Qt.AlignLeft, true, "accnt_id");\n  _glAccounts.addColumn(qsTr("Description"), -1, Qt.AlignLeft, true, "accnt_descrip");\n  _glAccounts.addColumn(qsTr("Type"), -1, Qt.AlignLeft, true, "accnt_type");\n  _glAccounts.addColumn(qsTr("Balance"), -1, Qt.AlignRight, true, "balance");\n\n  // Connect Signals and Slots\n  _b1GLAccounts.clicked.connect(refreshGLAccounts);\n  _b2GLAccounts.clicked.connect(preferencesGLAccounts);\n\n  _dtTimer.timeout.connect(refreshGLAccounts);\n  mainwindow.bankAdjustmentsUpdated.connect(refreshGLAccounts);\n  mainwindow.checksUpdated.connect(refreshGLAccounts);\n  mainwindow.creditMemosUpdated.connect(refreshGLAccounts);\n  mainwindow.cashReceiptsUpdated.connect(refreshGLAccounts);\n  mainwindow.glSeriesUpdated.connect(refreshGLAccounts);\n  mainwindow.invoicesUpdated.connect(refreshGLAccounts);\n  mainwindow.paymentsUpdated.connect(refreshGLAccounts);\n  mainwindow.standardPeriodsUpdated.connect(refreshGLAccounts);\n  mainwindow.vouchersUpdated.connect(refreshGLAccounts);\n  mainwindow.workOrderMaterialsUpdated.connect(refreshGLAccounts);\n  mainwindow.workOrderOperationsUpdated.connect(refreshGLAccounts);\n  mainwindow.workOrdersUpdated.connect(refreshGLAccounts);\n\n  _glAccounts.itemSelected.connect(openWindowGLAccounts);\n  _glAccounts["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuGLAccounts);\n\n  _dockGLAccounts.visibilityChanged.connect(fillListGLAccounts);\n\n  // Handle privilge control\n  var act = _dockGLAccounts.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewGLAccountsDock"))\n  {\n    _dockGLAccounts.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewGLAccountsDock");\n  _menuDesktop.appendAction(act);\n  fillListGLAccounts();\n}\n\n/*!\n  Fills the list with sales history data based on parameters determined by\n  sales history preferences.\n\n  @sa preferencesGLAccounts()\n*/\nfunction fillListGLAccounts()\n{\n  _dockGLAccounts = mainwindow.findChild("_dockGLAccounts");\n  _glAccounts = mainwindow.findChild("_glAccounts");\n\n  if (!_dockGLAccounts.visible || !_glAccountsIsDirty)\n    return;\n\n  _glAccounts.clear();\n  var accntIdList = preferences.value("MonitoredAccounts");\n  if(!accntIdList.length)\n    return;\n\n  var params = new Object;\n  params.asset = qsTr("Asset");\n  params.liability = qsTr("Liability");\n  params.revenue = qsTr("Revenue");\n  params.expense = qsTr("Expense");\n  params.equity = qsTr("Equity");\n  params.accnt_id_list = accntIdList;\n\n  // Forward update if applicable\n  if (!metrics.boolean("ManualForwardUpdate"))\n   toolbox.executeDbQuery("desktop","glforwardupdate", params);\n\n  var qry = toolbox.executeDbQuery("desktop","glaccountBal", params);\n  if (qry.first())\n  {\n    _periodId = qry.value("period_id");\n    _glAccounts.populate(qry);\n  }\n\n    _glAccountsIsDirty = false;\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowGLAccounts()\n{\n  var ui;\n  var params = new Object;\n  params.period_id = _periodId;\n  params.accnt_id = _glAccounts.id();\n  params.run = true;\n\n  // Make sure we can open the window\n  if (!privilegeCheckGLAccounts())\n    return;\n\n  // Open the window and perform any special handling required\n  toolbox.openWindow("dspGLTransactions");\n  toolbox.lastWindow().set(params);\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on sales history.\n*/\nfunction populateMenuGLAccounts(pMenu)\n{\n  var menuItem;\n  var enable = privilegeCheckGLAccounts();\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowGLAccounts);\n}\n\n/*!\n  Returns whether user has privileges to view Sales History detail.\n*/\nfunction privilegeCheckGLAccounts()\n{\n  var returnval = privileges.check("ViewGLTransactions");\n  print("privilegeCheckGLAccounts returning " + returnval);\n  return returnval;\n}\n\n/*! \n  Launches the preferences window where the user can set sales data output preferences.\n*/\nfunction preferencesGLAccounts()\n{\n  params = new Object;\n\n  var newdlg = toolbox.openWindow("preferencesSelections", mainwindow,\n                                  Qt.ApplicationModal, Qt.Dialog);\n  toolbox.lastWindow().set(params);\n  if (newdlg.exec())\n    refreshGLAccounts();\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshGLAccounts()\n{\n  _glAccountsIsDirty = true;\n  fillListGLAccounts();\n}\n   
106101
 
72      dockMfgActive   0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockMfgAct;\nvar _MfgAct;\nvar _mfgActIsDirty = true;\n\n/*!\n  Initializes Mfg. Activity dock widget and places it in the main window.\n*/\nfunction initDockMfgAct()\n{\n  _dockMfgAct = mainwindow.findChild("_dockMfgAct");\n  _mfgAct = mainwindow.findChild("_mfgAct");\n\n  // Set columns on list\n  _mfgAct.addColumn(qsTr("Type"), -1,  Qt.AlignLeft,   true, "activity");\n  _mfgAct.addColumn(qsTr("#"), 40,  Qt.AlignRight,  true, "count");\n  _mfgAct.addColumn(qsTr("Amount"), -1,  Qt.AlignRight,  true, "amount");\n  _mfgAct.addColumn(qsTr("Qty"), -1,  Qt.AlignRight,  false, "qty");\n\n  // Connect Signals and Slots\n  _dtTimer.timeout.connect(refreshMfgAct);\n  mainwindow.workOrdersUpdated.connect(refreshMfgAct);\n  mainwindow.workOrderMaterialsUpdated.connect(refreshMfgAct);\n  mainwindow.workOrderOperationsUpdated.connect(refreshMfgAct);\n\n  _mfgAct.itemSelected.connect(openWindowMfgAct);\n  _mfgAct["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuMfgAct);\n\n  _dockMfgAct.visibilityChanged.connect(fillListMfgAct);\n\n  // Handle privilge control\n  var act = _dockMfgAct.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewManufactureActivitiesDock"))\n  {\n    _dockMfgAct.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewManufactureActivitiesDock");\n  _menuDesktop.appendAction(act);\n\n  fillListMfgAct();\n}\n\n/*!\n  Fills the list with active Purch data.\n*/\nfunction fillListMfgAct()\n{\n  _dockMfgAct = mainwindow.findChild("_dockMfgAct");\n  _mfgAct = mainwindow.findChild("_mfgAct");\n\n  if (_dockMfgAct.visible && _mfgActIsDirty)\n  {\n    var params = new Object;\n    if (metrics.value("Application") != "PostBooks")\n      params.planned = qsTr("Planned");\n    params.open = qsTr("Open");\n    params.exploded = qsTr("Exploded");\n    params.released = qsTr("Released");\n    params.inprocess = qsTr("In Process");\n\n    _mfgAct.populate(toolbox.executeDbQuery("desktop","mfgAct", params));\n  }\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowMfgAct()\n{\n  var ui;\n  var run = false;\n  var act = _mfgAct.currentItem().rawValue("activity");\n  \n  // Make sure we can open the window for this activity\n  if (!privilegeCheckMfgAct(act))\n    return;\n\n  // Determine which window to open\n  if (act == "L")\n    ui = "dspPlannedOrders";\n  else\n    ui = "dspWoSchedule";\n\n  // Open the window and perform any handling required\n  var win = toolbox.openWindow(ui);\n  if (act == "L")\n  {\n//    win.findChild("_purchase").forgetful = true;\n//    win.findChild("_manufacture").forgetful = true;\n//    win.findChild("_transfer").forgetful = true;\n//    win.findChild("_purchase").checked = false;\n//    win.findChild("_manufacture").checked = true;\n//    win.findChild("_transfer").checked = false;\n//    if (act == 'O')\n//      win.findChild("_open").checked = true;\n//    else if (act == 'E')\n//      win.findChild("_exploded").checked = true;\n//    else if (act == 'R')\n//      win.findChild("_released").checked = true;\n//    else if (act == 'I')\n//      win.findChild("_inprocess").checked = true;\n//    win.findChild("_warehouse").setAll();\n    var params = new Object();\n    params.type = "W";\n    toolbox.lastWindow().set(params);\n  }\n  else\n  {\n    var params = new Object();\n    params.status = act;\n    toolbox.lastWindow().set(params);\n  }\n\n\n  win.sFillList();\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on a Purch Activity item.\n*/\nfunction populateMenuMfgAct(pMenu, pItem)\n{\n  var menuItem;\n  var act = pItem.rawValue("activity");\n  var enable = privilegeCheckMfgAct(act);\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowMfgAct);\n}\n\n/*!\n  Returns whether user has privileges to view detail on the selected Manufacture Activity.\n*/\nfunction privilegeCheckMfgAct(act)\n{\n  if (act == "L") // Planned Orders\n    return privileges.check("ViewPlannedOrders");\n  else // Work Orders\n    return (privileges.check("ViewWorkOrders") || \n            privileges.check("EditWorkOrders"));\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshMfgAct()\n{\n  _mfgActIsDirty = true;\n  fillListMfgAct();\n}\n 
106102
 
73      dockMfgHist     0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _b1MfgHist;\nvar _b2MfgHist;\nvar _dockMfgHist;\nvar _groupByMfgHist;\nvar _timeFrameMfgHist;\nvar _typeMfgHist;\nvar _labelMfgHist;\nvar _mfgHist;\nvar _mfgHistIsDirty = true;\n\n/*!\n  Initializes Sales History dock widget and places it in the main window.\n*/\nfunction initDockMfgHist()\n{\n  // Set up objects\n  _dockMfgHist = mainwindow.findChild("_dockMfgHist");\n  _mfgHist = mainwindow.findChild("_mfgHist");\n\n  _b1MfgHist = _dockMfgHist.findChild("_button1");\n  _b2MfgHist = _dockMfgHist.findChild("_button2");\n  _labelMfgHist = _dockMfgHist.findChild("_label");\n\n  // Set icons\n  var iReload = new QIcon;\n  iReload.addDbImage("reload_16");\n  _b1MfgHist.icon = iReload;\n  _b1MfgHist.text = "";\n  _b1MfgHist.toolTip = qsTr("Reload");\n\n  var iGear = new QIcon();\n  iGear.addDbImage("gear_16");\n  _b2MfgHist.icon = iGear;\n  _b2MfgHist.text = "";\n  _b2MfgHist.toolTip = qsTr("Preferences...");\n\n  // Load local preferences\n  loadPreferencesMfgHist();\n\n  // Set columns on list\n  setColumnsMfgHist();\n\n  // Connect Signals and Slots\n  _b1MfgHist.clicked.connect(refreshMfgHist);\n  _b2MfgHist.clicked.connect(preferencesMfgHist);\n\n  _dtTimer.timeout.connect(refreshMfgHist);\n  mainwindow.purchaseOrderReceiptsUpdated.connect(refreshMfgHist);\n  mainwindow.vouchersUpdated.connect(refreshMfgHist);\n\n  _mfgHist.itemSelected.connect(openWindowMfgHist);\n  _mfgHist["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuMfgHist);\n\n  _dockMfgHist.visibilityChanged.connect(fillListMfgHist);\n\n  // Handle privilge control\n  var act = _dockMfgHist.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewManufactureHistoryDock"))\n  {\n    _dockMfgHist.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewManufactureHistoryDock");\n  _menuDesktop.appendAction(act);\n\n  fillListMfgHist();\n}\n\n/*!\n  Fills the list with sales history data based on parameters determined by\n  sales history preferences.\n\n  @sa preferencesMfgHist()\n*/\nfunction fillListMfgHist()\n{\n  _dockMfgHist = mainwindow.findChild("_dockMfgHist");\n  _mfgHist = mainwindow.findChild("_mfgHist");\n\n  if (!_dockMfgHist.visible || !_mfgHistIsDirty) \n    return;\n\n  var timeFrame;\n  var type;\n  var params = getDatesMfgHist();\n \n  if (_groupByMfgHist == "classcode")\n  {\n    params.group_id = "classcode_id";\n    params.group_number = "classcode_code";\n    params.group_name = "classcode_descrip";\n  }\n  else if (_groupByMfgHist == "item")\n  {\n    params.group_id = "item_id";\n    params.group_number = "item_number";\n    params.group_name = "item_descrip1";\n  }\n  else if (_groupByMfgHist == "plancode")\n  {\n    params.group_id = "plancode_id";\n    params.group_number = "plancode_code";\n    params.group_name = "plancode_name";\n  }\n\n  _mfgHist.populate(toolbox.executeDbQuery("desktop","mfgHist", params));\n\n  type = qsTr("Receipts");\n\n  if (_timeFrameMfgHist == "day")\n    timeFrame = qsTr("Today");\n  else if (_timeFrameMfgHist == "week")\n    timeFrame = qsTr("this Week");\n  else if (_timeFrameMfgHist == "month")\n    timeFrame = qsTr("this Month");\n  else if (_timeFrameMfgHist == "year")\n    timeFrame = qsTr("this Year");\n\n  _labelMfgHist.text = type + " " + timeFrame;\n\n  _mfgHistIsDirty = false;\n}\n\n/*!\n  Returns an object with a list containing @a startDate and @a endDate\n  that is used for fetching data and opening windows using the date range\n  stored in local preferences.\n \n  @sa preferencesMfgHist()\n  @sa openWindowMfgHist()\n  @sa fillListMfgHist()\n*/\nfunction getDatesMfgHist()\n{\n  var params = new Object;\n\n  params.timeFrame = _timeFrameMfgHist;\n  params.interval = "1 " + _timeFrameMfgHist;\n\n  var q = toolbox.executeDbQuery("desktop", "getDates", params);\n\n  if (q.first())\n  {\n    params.startDate = q.value("startDate");\n    params.endDate = q.value("endDate");\n  }\n\n  return params;\n}\n\n/*! \n  Loads local Sales History preferences into memory.\n\n  @sa preferencesMfgHist()\n*/\nfunction loadPreferencesMfgHist()\n{\n  // Load preferences\n  _groupByMfgHist = preferences.value("desktop/mfgHist/groupBy");\n  _timeFrameMfgHist = preferences.value("desktop/mfgHist/timeFrame");\n  _typeMfgHist = preferences.value("desktop/mfgHist/type")\n  \n  // Set to defaults if no values\n  _groupByMfgHist = (_groupByMfgHist.length ? _groupByMfgHist : "plancode");\n  _timeFrameMfgHist = (_timeFrameMfgHist.length ? _timeFrameMfgHist : "year");\n  _typeMfgHist = (_typeMfgHist.length ? _typeMfgHist : "receipts");\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowMfgHist()\n{\n  var ui;\n  var params = getDatesMfgHist();\n  params.run = true;\n\n  // TO DO: Work it out so totals launch a window too\n  if (_mfgHist.id() == -1)\n    return;\n  \n  // Make sure we can open the window\n  if (!privilegeCheckMfgHist())\n    return;\n\n  // Determine which window to open\n  if (_groupByMfgHist == "classcode")\n  {\n    ui = "dspInventoryHistory";\n    params.classcode_id = _mfgHist.id();\n  }\n  else if (_groupByMfgHist == "item")\n  {\n    ui = "dspInventoryHistory";\n    params.item_id = _mfgHist.id();\n  }\n  else if (_groupByMfgHist == "plancode")\n  {\n    ui = "dspInventoryHistory";\n    params.plancode_id = _mfgHist.id();\n  }\n  params.transtype = "R";\n  params.ordertype = "WO";\n  params.run = true;\n\n  // Open the window and perform any special handling required\n  toolbox.openWindow(ui);\n  toolbox.lastWindow().set(params);\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on sales history.\n*/\nfunction populateMenuMfgHist(pMenu)\n{\n  var menuItem;\n  var enable = privilegeCheckMfgHist();\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowMfgHist);\n}\n\n/*!\n  Returns whether user has privileges to view Sales History detail.\n*/\nfunction privilegeCheckMfgHist()\n{\n  return privileges.check("ViewInventoryHistory");\n}\n\n/*! \n  Set up columns depending on local preferences.\n\n  @sa preferencesMfgHist()\n*/\nfunction setColumnsMfgHist()\n{\n  _mfgHist.columnCount = 0;\n\n  if (_groupByMfgHist == "classcode")\n  {\n    _mfgHist.addColumn(qsTr("Class Code"),  -1, Qt.AlignLeft, true, "classcode_code");\n    _mfgHist.addColumn(qsTr("Description"), -1, Qt.AlignLeft, false, "classcode_descrip");\n  }\n  else if (_groupByMfgHist == "item")\n  {\n    _mfgHist.addColumn(qsTr("Item Number"), -1, Qt.AlignLeft, true, "item_number");\n    _mfgHist.addColumn(qsTr("Description"), -1, Qt.AlignLeft, false, "item_descrip1");\n  }\n  else if (_groupByMfgHist == "plancode")\n  {\n    _mfgHist.addColumn(qsTr("Planner Code"),  -1, Qt.AlignLeft, true, "plancode_code");\n    _mfgHist.addColumn(qsTr("Description"), -1, Qt.AlignLeft, false, "plancode_descrip");\n  }\n\n  _mfgHist.addColumn(qsTr("Amount"), -1, Qt.AlignRight, true, "amount");\n  _mfgHist.addColumn(qsTr("Qty."), -1, Qt.AlignRight, false, "qty");\n}\n\n/*! \n  Launches the preferences window where the user can set sales data output preferences.\n*/\nfunction preferencesMfgHist()\n{\n  params = new Object;\n  params.path = "desktop/mfgHist";\n  params.groupBy = _groupByMfgHist;\n  params.timeFrame = _timeFrameMfgHist;\n  params.type = _typeMfgHist;\n\n  var newdlg = toolbox.openWindow("preferencesHistory", mainwindow,\n                                  Qt.ApplicationModal, Qt.Dialog);\n  toolbox.lastWindow().set(params);\n  if (newdlg.exec())\n  {\n    loadPreferencesMfgHist();\n    setColumnsMfgHist();\n    refreshMfgHist();\n  }\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshMfgHist()\n{\n  _mfgHistIsDirty = true;\n  fillListMfgHist();\n}\n     
106103
 
74      dockMfgOpen     0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockMfgOpen;\nvar _mfgOpen;\nvar _mfgOpenIsDirty = true;\n\n/*!\n  Initializes Work Order dock widget and places it in the main window.\n*/\nfunction initDockMfgOpen()\n{\n  _dockMfgOpen = mainwindow.findChild("_dockMfgOpen");\n  _mfgOpen = mainwindow.findChild("_mfgOpen");\n\n  // Set columns on list\n  _mfgOpen.addColumn(qsTr("Order#"), XTreeWidget.orderColumn,  Qt.AlignLeft,   true, "wonumber");\n  _mfgOpen.addColumn(qsTr("Item#"), XTreeWidget.itemColumn,  Qt.AlignLeft,  true, "item_number");\n  _mfgOpen.addColumn(qsTr("Description"), -1,  Qt.AlignLeft,  true, "itemdescrip");\n  if (metrics.boolean("MultiWhs"))\n    _mfgOpen.addColumn(qsTr("Whs."), XTreeWidget.whsColumn,  Qt.AlignLeft,  true, "warehous_code");\n  _mfgOpen.addColumn(qsTr("Status"), XTreeWidget.moneyColumn,  Qt.AlignLeft,  true, "wo_status");\n  _mfgOpen.addColumn(qsTr("Ordered"), XTreeWidget.qtyColumn,  Qt.AlignRight,  true, "wo_qtyord"); \n  _mfgOpen.addColumn(qsTr("Received"), XTreeWidget.qtyColumn,  Qt.AlignRight,  true, "wo_qtyrcv");  \n  _mfgOpen.addColumn(qsTr("UOM"), XTreeWidget.uomColumn,  Qt.AlignLeft, true, "uom_name"); \n  _mfgOpen.addColumn(qsTr("Start Date"), XTreeWidget.dateColumn,  Qt.AlignLeft, false, "wo_startdate"); \n  _mfgOpen.addColumn(qsTr("Due Date"), XTreeWidget.dateColumn,  Qt.AlignLeft, true, "wo_duedate"); \n  _mfgOpen.addColumn(qsTr("Condition"), XTreeWidget.statusColumn,  Qt.AlignLeft, false, "condition"); \n  if (privileges.check("ViewCosts"))\n  {\n    _mfgOpen.addColumn(qsTr("Posted Value"), XTreeWidget.moneyColumn,  Qt.AlignRight, false, "wo_postedvalue");\n    _mfgOpen.addColumn(qsTr("WIP Value"), XTreeWidget.moneyColumn,  Qt.AlignRight, true, "wo_wipvalue");\n  }\n\n  // Connect Signals and Slots\n  _dtTimer.timeout.connect(refreshMfgOpen);\n  mainwindow.workOrdersUpdated.connect(refreshMfgOpen);\n  mainwindow.workOrderMaterialsUpdated.connect(refreshMfgOpen);\n  mainwindow.workOrderOperationsUpdated.connect(refreshMfgOpen);\n\n  _mfgOpen.itemSelected.connect(openWindowMfgOpen);\n  _mfgOpen["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuMfgOpen);\n\n  _dockMfgOpen.visibilityChanged.connect(fillListMfgOpen);\n\n  // Handle privilge control\n  var act = _dockMfgOpen.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewWorkOrdersDock"))\n  {\n    _dockMfgOpen.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewWorkOrdersDock");\n  _menuDesktop.appendAction(act);\n\n  fillListMfgOpen();\n}\n\n/*!\n  Fills the list with open sales data.\n*/\nfunction fillListMfgOpen()\n{\n  _dockMfgOpen = mainwindow.findChild("_dockMfgOpen");\n  _mfgOpen = mainwindow.findChild("_mfgOpen");\n\n  if (!_dockMfgOpen.visible || !_mfgOpenIsDirty)\n    return;\n\n  params = new Object;\n  params.open = qsTr("Open");\n  params.exploded = qsTr("Exploded");\n  params.released = qsTr("Released");\n  params.inprocess = qsTr("In Process");\n\n  _mfgOpen.populate(toolbox.executeDbQuery("desktop","mfgOpen",params), true);\n\n  _mfgOpenIsDirty = false;\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowMfgOpen()\n{ \n  // Make sure we can open the window for this activity\n  if (!privilegeCheckMfgOpen)\n    return;\n\n  params = new Object;\n  params.wo_id = _mfgOpen.id();\n  if (privileges.check("MaintainWorkOrders"))\n    params.mode = "edit";\n  else\n    params.mode = "view";\n\n  // Open the window and perform any handling required\n  var wo = toolbox.openWindow("workOrder");\n  wo.set(params);\n\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on a Sales Order item.\n*/\nfunction populateMenuMfgOpen(pMenu, pItem)\n{\n  var menuItem;\n  var enable = privilegeCheckMfgOpen();\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowMfgOpen);\n}\n\n/*!\n  Returns whether user has privileges to view detail on the selected Sales Order.\n*/\nfunction privilegeCheckMfgOpen()\n{\n  return privileges.check("ViewWorkOrders") || \n         privileges.check("MaintainWorkOrders");\n\n  return false;\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshMfgOpen()\n{\n  _mfgOpenIsDirty = true;\n  fillListMfgOpen();\n}\n 
106104
 
75      dockMyAccounts  0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockMyaccounts;\nvar _accountList;\nvar _accountListIsDirty = true;\n\n/*!\n  Initializes the My Accounts dock widget and places it in the main window.\n*/\nfunction initDockAccounts()\n{\n  _dockMyaccounts = mainwindow.findChild("_dockMyaccounts");\n  _accountList = mainwindow.findChild("_accountList");\n\n  // Set columns on list\n  _accountList.addColumn(qsTr("Number"), XTreeWidget.itemColumn, Qt.AlignLeft,  false, "crmacct_number");\n  _accountList.addColumn(qsTr("Name"), -1, Qt.AlignLeft,  true, "crmacct_name");\n  _accountList.addColumn(qsTr("Contact"), -1, Qt.AlignLeft  , false, "cntct_name" );\n  _accountList.addColumn(qsTr("Phone"), -1, Qt.AlignLeft, false, "cntct_phone" );\n  _accountList.addColumn(qsTr("Email"), -1, Qt.AlignLeft, false, "cntct_email" );\n  _accountList.addColumn(qsTr("Address"), -1, Qt.AlignLeft  , false, "addr_line1" );\n  _accountList.addColumn(qsTr("City"), XTreeWidget.docTypeColumn, Qt.AlignLeft  , false, "addr_city" );\n  _accountList.addColumn(qsTr("State"), XTreeWidget.orderColumn, Qt.AlignLeft  , false, "addr_state" );\n  _accountList.addColumn(qsTr("Country"), XTreeWidget.orderColumn, Qt.AlignLeft  , false, "addr_country" );\n  _accountList.addColumn(qsTr("Postal Code"), XTreeWidget.docTypeColumn, Qt.AlignLeft  , false, "addr_postalcode" );\n\n  // Connect signals and slots\n  mainwindow.crmAccountsUpdated.connect(refreshMyAccts);\n  mainwindow.customersUpdated.connect(refreshMyAccts);\n  mainwindow.vendorsUpdated.connect(refreshMyAccts);\n\n  _accountList.itemSelected.connect(openWindowMyAccts);\n  _accountList["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuMyAccts);\n\n  _dockMyaccounts.visibilityChanged.connect(fillListMyAccts);\n\n  // Handle privilge control\n  var act = _dockMyaccounts.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewMyAccountsDock"))\n  {\n    _dockMyaccounts.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewMyAccountsDock");\n  _menuDesktop.appendAction(act);\n\n  fillListMyAccts();\n}\n\n/*!\n  Fills the My Accounts list with CRM Accounts owned by the current user.\n*/\nfunction fillListMyAccts()\n{\n  _dockMyaccounts = mainwindow.findChild("_dockMyaccounts");\n  _accountList = mainwindow.findChild("_accountList");\n\n  if (!_dockMyaccounts.visible || !_accountListIsDirty)\n    return;\n\n  params = new Object;\n  params.owner_username = mainwindow.username();\n  _accountList.populate(toolbox.executeDbQuery("desktop", "crmaccounts", params));\n\n  _accountListIsDirty = false;\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowMyAccts()\n{\n  // Make sure we can open the window\n  if (!privilegeCheckMyAccts())\n    return;\n\n  // Determine which contact to open\n  params = new Object;\n  params.crmacct_id = _accountList.id();\n  if (privileges.check("MaintainAllCRMAccounts") || privileges.check("MaintainPersonalCRMAccounts"))\n    params.mode = "edit"\n  else\n    params.mode = "view"\n\n  // Open the window and perform any special handling required\n  var win = toolbox.openWindow("crmaccount");\n  win.set(params);\n}\n\n/*!\n  Adds actions to \\a pMenu, typically from a right click on My Contacts.\n*/\nfunction populateMenuMyAccts(pMenu)\n{\n  var menuItem;\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = privilegeCheckMyAccts();\n  menuItem.triggered.connect(openWindowMyAccts);\n}\n\n/*!\n  Returns whether user has privileges to view My Contact detail.\n*/\nfunction privilegeCheckMyAccts()\n{\n  return privileges.check("MaintainAllCRMAccounts") || privileges.check("MaintainPersonalAccounts") ||\n         privileges.check("ViewAllCRMAccounts") || privileges.check("ViewPersonalCRMAccounts");\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshMyAccts()\n{\n  _accountListIsDirty = true;\n  fillListMyAccts();\n}\n        
106105
 
69      dockBankBal     0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockBankBal;\nvar _bankBal;\nvar _bankBalIsDirty = true;\n\n/*!\n  Initializes Bank Balance dock widget and places it in the main window.\n*/\nfunction initDockBankBal()\n{\n  _dockBankBal = mainwindow.findChild("_dockBankBal");\n  _bankBal = mainwindow.findChild("_bankBal");\n\n  // Set columns on list\n  _bankBal.addColumn(qsTr("Name"), -1,  Qt.AlignLeft,   true, "bankaccnt_name");\n  _bankBal.addColumn(qsTr("Balance"), -1,  Qt.AlignRight,  true, "balance");\n\n  // Connect Signals and Slots\n  _dtTimer.timeout.connect(refreshBankBal);\n  mainwindow.bankAccountsUpdated.connect(refreshBankBal);\n  mainwindow.bankAdjustmentsUpdated.connect(refreshBankBal);\n  mainwindow.cashReceiptsUpdated.connect(refreshBankBal);\n  mainwindow.checksUpdated.connect(refreshBankBal);\n  mainwindow.glSeriesUpdated.connect(refreshBankBal);\n\n  _bankBal.itemSelected.connect(openWindowBankBal);\n  _bankBal["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuBankBal);\n\n  _dockBankBal.visibilityChanged.connect(fillListBankBal);\n\n  // Handle privilge control\n  var act = _dockBankBal.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewBankAccountsDock"))\n  {\n    _dockBankBal.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewBankAccountsDock");\n  _menuDesktop.appendAction(act);\n\n  fillListBankBal();\n}\n\n/*!\n  Fills the list with bank account data.\n*/\nfunction fillListBankBal()\n{\n  _dockBankBal = mainwindow.findChild("_dockBankBal");\n  _bankBal = mainwindow.findChild("_bankBal");\n\n  if (_dockBankBal.visible && _bankBalIsDirty)\n  {\n    _bankBal.populate(toolbox.executeDbQuery("desktop","bankBal"));\n    _bankBalIsDirty = false;\n  }\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowBankBal()\n{\n  // Make sure we can open the window\n  if (!privilegeCheckBankBal())\n    return;\n\n  // Open the window and perform any handling required\n  toolbox.openWindow("reconcileBankaccount");\n  var w = toolbox.lastWindow().findChild("_bankaccnt").setId(_bankBal.id());\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on a bank account item.\n*/\nfunction populateMenuBankBal(pMenu, pItem)\n{\n  var menuItem;\n  var enable = privilegeCheckBankBal();\n\n  menuItem = pMenu.addAction(qsTr("Reconcile..."));\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowBankBal);\n}\n\n/*!\n  Returns whether user has privileges to view detail.\n*/\nfunction privilegeCheckBankBal(act)\n{\n  return privileges.check("MaintainBankRec");\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshBankBal()\n{\n  _bankBalIsDirty = true;\n  fillListBankBal();\n}\n      
106106
 
127     dockMessageHistory      0       t       var _b1MessageHistory;\nvar _b2MessageHistory;\nvar _dockMessageHistory;\nvar _messageHistory;\nvar _limitmessageHistory;\nvar _messageHistoryIsDirty = true;\nvar _periodId = -1;\n\nfunction initDockMessageHistory()\n{  \n  // Set up objects\n  _dockMessageHistory = mainwindow.findChild("_dockMessageHistory");\n  _messageHistory     = mainwindow.findChild("_messageHistory");\n\n  _b1MessageHistory = _dockMessageHistory.findChild("_button3");\n  _b2MessageHistory = _dockMessageHistory.findChild("_button4");\n\n  // Set icons\n  var iReload = new QIcon;\n  iReload.addDbImage("reload_16");\n  _b1MessageHistory.icon = iReload;\n  _b1MessageHistory.text = "";\n  _b1MessageHistory.toolTip = qsTr("Reload");\n\n  var iGear = new QIcon();\n  iGear.addDbImage("gear_16");\n  _b2MessageHistory.icon = iGear;\n  _b2MessageHistory.text = "";\n  _b2MessageHistory.toolTip = qsTr("Preferences...");\n\n  // Set columns on list\n  _messageHistory.addColumn("Date",    75, 1, true, "sent");\n  _messageHistory.addColumn("From",    75, 1, true, "from");\n  _messageHistory.addColumn("To",      75, 1, true, "to")\n  _messageHistory.addColumn("Message", -1, 1, true, "message");\n\n  // Connect Signals and Slots\n  _b1MessageHistory.clicked.connect(refreshMessageHistory);\n  _b2MessageHistory.clicked.connect(preferencesMessageHistory);\n\n  _messageHistory["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuMessageHistory);\n  _messageHistory["itemDoubleClicked(QTreeWidgetItem*, int)"].connect(myOpen);\n\n  mainwindow["tick()"].connect(refreshMessageHistory);\n  mainwindow.setUpListener("messagePosted");\n  mainwindow["messageNotify()"].connect(refreshMessageHistory);\n\n  // Don't show if no privs\n  var act = _dockMessageHistory.toggleViewAction();\n  if (!privileges.check("viewMsgHistoryDock"))\n  {  \n    _dockMessageHistory.hide();\n    act.enabled = false;\n  }\n  else\n  {\n    _dockMessageHistory.show();\n    act.enabled = true;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("viewMsgHistoryDock");\n  _menuDesktop.appendAction(act);\n\n  fillListMessageHistory();\n}\n\nfunction fillListMessageHistory()\n{\n  _dockMessageHistory = mainwindow.findChild("_dockMessageHistory");\n  _messageHistory     = mainwindow.findChild("_messageHistory");\n\n  _messageHistory.clear();\n\n  var params = new Object;\n  params.limit = _limitmessageHistory;\n\n  _messageHistory.populate(toolbox.executeDbQuery("desktop","messageHistory", params));\n  _messageHistoryIsDirty = false;\n}\n\nfunction populateMenuMessageHistory(pMenu)\n{\n  try\n  {\n    var menuItem = pMenu.addAction(qsTr("Open..."));\n    menuItem.triggered.connect(myOpen);\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockMessageHistory",\n                         "populateMenuMessageHistory exception: " + e);\n  }\n}\n\nfunction preferencesMessageHistory()\n{\n  try\n  {\n    params = new Object;\n    params.path = "desktop/messageHistory";\n    params.limit = _limitmessageHistory;\n    var newdlg = toolbox.openWindow("preferencesNumber", mainwindow,\n                                     Qt.ApplicationModal, Qt.Dialog);\n    toolbox.lastWindow().set(params);\n    if (newdlg.exec())\n    {\n      loadPreferencesMessageHistory();\n      refreshMessageHistory();\n    }\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockMessageHistory",\n                         "preferencesMessageHistory exception: " + e);\n  }\n}\n\nfunction loadPreferencesMessageHistory()\n{\n  // Load preferences\n  _limitmessageHistory = preferences.value("desktop/messageHistory/limit");\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshMessageHistory()\n{\n  try\n  {\n    mainwindow.sSystemMessageAdded();\n    messageHistoryIsDirty = true;\n    fillListMessageHistory();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockMessageHistory",\n                         "refreshMessageHistory exception: " + e);\n  }\n}\n\nfunction myOpen()\n{\n  try\n  {\n    var params = new Object;\n    params.msg_id = _messageHistory.id();\n    var q = "SELECT msguser_id "\n          + "FROM msguser "\n          + "WHERE (msguser_msg_id = <? value(\\"msg_id\\") ?>);";\n    var data = toolbox.executeQuery(q, params);\n    if (data.first())\n      params.msguser_id = data.value("msguser_id");\n    else if (data.lastError().type != QSqlError.NoError)\n    {\n      QMessageBox.critical(mainwindow, qsTr("Database Error"),\n                           data.lastError().text);\n      return;\n    }\n\n    params.mode = "acknowledge";\n    var newwnd = toolbox.openWindow("systemMessage", mainwindow, Qt.ApplicationModal, Qt.Dialog);\n    toolbox.lastWindow().set(params);\n    newwnd.exec();\n    refreshMessageHistory();\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mainwindow, "dockMessageHistory",\n                         "myOpen exception: " + e);\n  }\n}\n  
106107
 
76      dockMyContacts  0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockMycontacts;\nvar _contactList;\n\n/*!\n  Initializes the My Contacts dock widget and places it in the main window.\n*/\nfunction initDockMyCntcts()\n{\n  _dockMycontacts = mainwindow.findChild("_dockMycontacts");\n  _contactList = mainwindow.findChild("_contactList");\n\n  // Set columns on list\n  _contactList.addColumn(qsTr("Name"), -1, Qt.AlignLeft  , true, "cntct_name" );\n  _contactList.addColumn(qsTr("Account#"), XTreeWidget.itemColumn, Qt.AlignLeft, false, "crmacct_number");\n  _contactList.addColumn(qsTr("Account Name"), -1, Qt.AlignLeft,  false, "crmacct_name");\n  _contactList.addColumn(qsTr("Phone"), -1, Qt.AlignLeft, true, "cntct_phone" );\n  _contactList.addColumn(qsTr("Email"), -1, Qt.AlignLeft, false, "cntct_email" );\n  _contactList.addColumn(qsTr("Address"), -1, Qt.AlignLeft  , false, "addr_line1" );\n  _contactList.addColumn(qsTr("City"), XTreeWidget.docTypeColumn, Qt.AlignLeft  , false, "addr_city" );\n  _contactList.addColumn(qsTr("State"), XTreeWidget.orderColumn, Qt.AlignLeft  , false, "addr_state" );\n  _contactList.addColumn(qsTr("Country"), XTreeWidget.orderColumn, Qt.AlignLeft  , false, "addr_country" );\n  _contactList.addColumn(qsTr("Postal Code"), XTreeWidget.docTypeColumn, Qt.AlignLeft  , false, "addr_postalcode" );\n\n  _dtTimer.timeout.connect(fillListMyCntcts);\n\n  _contactList.itemSelected.connect(openWindowMyCntcts);\n  _contactList["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuMyCntcts);\n\n  _dockMycontacts.visibilityChanged.connect(fillListMyCntcts);\n\n  // Handle privilge control\n  var act = _dockMycontacts.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewMyContactsDock"))\n  {\n    _dockMycontacts.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewMyContactsDock");\n  _menuDesktop.appendAction(act);\n\n  fillListMyCntcts();\n}\n\n/*!\n  Fills the My Contacts list with Contacts owned by the current user.\n*/\nfunction fillListMyCntcts()\n{\n  _dockMycontacts = mainwindow.findChild("_dockMycontacts");\n  _contactList = mainwindow.findChild("_contactList");\n\n  if (!_dockMycontacts.visible)\n    return;\n\n  _contactList = mainwindow.findChild("_contactList");\n  _contactList.populate(toolbox.executeDbQuery("desktop", "contacts"));\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowMyCntcts()\n{\n  // Make sure we can open the window\n  if (!privilegeCheckMyCntcts())\n    return;\n\n  // Determine which contact to open\n  params = new Object;\n  if (privileges.check("MaintainAllContacts") || privileges.check("MaintainPersonalContacts"))\n    params.mode = "edit";\n  else\n    params.mode = "view";\n  params.cntct_id = _contactList.id();\n\n  // Open the window and perform any special handling required\n  var newdlg = toolbox.openWindow("contact");\n  newdlg.set(params);\n  newdlg.exec();\n}\n\n/*!\n  Adds actions to \\a pMenu, typically from a right click on My Contacts.\n*/\nfunction populateMenuMyCntcts(pMenu)\n{\n  var menuItem;\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = privilegeCheckMyCntcts();\n  menuItem.triggered.connect(openWindowMyCntcts);\n}\n\n/*!\n  Returns whether user has privileges to view My Contact detail.\n*/\nfunction privilegeCheckMyCntcts()\n{\n  return privileges.check("MaintainAllContacts") || privileges.check("MaintainPersonalContacts") ||\n         privileges.check("ViewAllContacts") || privileges.check("ViewPersonalContacts");\n}\n        
106108
 
85      dockSalesOpen   0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockSalesOpen;\nvar _salesOpen;\nvar _salesOpenIsDirty = true;\n\n/*!\n  Initializes Open Sales Order dock widget and places it in the main window.\n*/\nfunction initDockSalesOpen()\n{\n  _dockSalesOpen = mainwindow.findChild("_dockSalesOpen");\n  _salesOpen = mainwindow.findChild("_salesOpen");\n\n  // Set columns on list\n  _salesOpen.addColumn(qsTr("Order#"), XTreeWidget.orderColumn,  Qt.AlignLeft,   true, "cohead_number");\n  _salesOpen.addColumn(qsTr("Customer#"), XTreeWidget.orderColumn,  Qt.AlignLeft,  true, "cust_number");\n  _salesOpen.addColumn(qsTr("Bill To"), -1,  Qt.AlignLeft,  true, "cohead_billtoname");\n  _salesOpen.addColumn(qsTr("Bill Contact"), -1,  Qt.AlignLeft,  false, "billto_cntct");\n  _salesOpen.addColumn(qsTr("Bill Phone"), -1,  Qt.AlignLeft,  false, "cohead_billto_cntct_phone"); \n  _salesOpen.addColumn(qsTr("Ship To"), -1, Qt.AlignLeft,  true, "cohead_shiptoname");\n  _salesOpen.addColumn(qsTr("Ship Contact"), -1,  Qt.AlignLeft,  false, "shipto_cntct");\n  _salesOpen.addColumn(qsTr("Ship Phone"), -1,  Qt.AlignLeft,  false, "cohead_shipto_cntct_phone");\n  _salesOpen.addColumn(qsTr("Ship Via"), -1,  Qt.AlignLeft,  true, "cohead_shipvia"); \n  _salesOpen.addColumn(qsTr("Sched. Date"), XTreeWidget.dateColumn,  Qt.AlignLeft,  true, "scheddate");\n  _salesOpen.addColumn(qsTr("Amount"), XTreeWidget.moneyColumn,  Qt.AlignRight,  true, "amount");\n\n  // Connect Signals and Slots\n  _dtTimer.timeout.connect(refreshSalesOpen);\n  mainwindow.invoicesUpdated.connect(refreshSalesOpen);\n  mainwindow.salesOrdersUpdated.connect(refreshSalesOpen);\n\n  _salesOpen.itemSelected.connect(openWindowSalesOpen);\n  _salesOpen["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuSalesOpen);\n\n  _dockSalesOpen.visibilityChanged.connect(fillListSalesOpen);\n\n  // Handle privilge control\n  var act = _dockSalesOpen.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewSalesOrdersDock"))\n  {\n    _dockSalesOpen.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewSalesOrdersDock");\n  _menuDesktop.appendAction(act);\n\n  fillListSalesOpen();\n}\n\n/*!\n  Fills the list with open sales data.\n*/\nfunction fillListSalesOpen()\n{\n  _dockSalesOpen = mainwindow.findChild("_dockSalesOpen");\n  _salesOpen = mainwindow.findChild("_salesOpen");\n\n  if (!_dockSalesOpen.visible || !_salesOpenIsDirty)\n    return;\n\n  _salesOpen.populate(toolbox.executeDbQuery("desktop","salesOpen"));\n\n  _salesOpenIsDirty = false;\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowSalesOpen()\n{ \n  // Make sure we can open the window for this activity\n  if (!privilegeCheckSalesOpen)\n    return;\n\n  params = new Object;\n  params.sohead_id = _salesOpen.id();\n  if (privileges.check("MaintainSalesOrders"))\n    params.mode = "edit";\n  else\n    params.mode = "view";\n\n  // Open the window and perform any handling required\n  var so = toolbox.openWindow("salesOrder");\n  so.set(params);\n\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on a Sales Order item.\n*/\nfunction populateMenuSalesOpen(pMenu, pItem)\n{\n  var menuItem;\n  var enable = privilegeCheckSalesOpen();\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowSalesOpen);\n}\n\n/*!\n  Returns whether user has privileges to view detail on the selected Sales Order.\n*/\nfunction privilegeCheckSalesOpen()\n{\n  return privileges.check("ViewSalesOrders") || \n         privileges.check("MaintainSalesOrders");\n\n  return false;\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshSalesOpen()\n{\n  _salesOpenIsDirty = true;\n  fillListSalesOpen();\n}\n  
106109
 
86      dockUserOnline  0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockUserOnline;\nvar _userOnline;\nvar _userOnlineIsDirty = true;\n\n/*!\n  Initializes Open Sales Order dock widget and places it in the main window.\n*/\nfunction initDockUserOnline()\n{\n  _dockUserOnline = mainwindow.findChild("_dockUserOnline");\n  _userOnline = mainwindow.findChild("_userOnline");\n\n  // Set columns on list\n  _userOnline.addColumn(qsTr("Username"), -1,  Qt.AlignLeft, true, "usr_username");\n  _userOnline.addColumn(qsTr("Proper Name"), -1,  Qt.AlignLeft, true, "usr_propername");\n  _userOnline.addColumn(qsTr("Email"), -1,  Qt.AlignLeft, true, "usr_email");\n  _userOnline.addColumn(qsTr("# Internal"), -1,  Qt.AlignLeft, true, "cnt_internal");\n  _userOnline.addColumn(qsTr("# External"), -1,  Qt.AlignLeft, true, "cnt_external");\n  _userOnline.addColumn(qsTr("Client Start"), XTreeWidget.timeDateColumn, Qt.AlignLeft, true, "client_start"); \n  _userOnline.addColumn(qsTr("Query Start"), XTreeWidget.timeDateColumn, Qt.AlignLeft, true, "query_start");\n  _userOnline.addColumn(qsTr("Client Address"), -1,  Qt.AlignLeft, true, "client_addr");\n\n  // Connect Signals and Slots\n  _dtTimer.timeout.connect(refreshUserOnline);\n\n  _userOnline.itemSelected.connect(openWindowUserOnline);\n  _userOnline["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n    .connect(populateMenuUserOnline);\n\n  _dockUserOnline.visibilityChanged.connect(refreshUserOnline);\n\n  // Handle privilge control\n  var act = _dockUserOnline.toggleViewAction();\n\n  // Don't show if no privs\n  if (!privileges.check("ViewUsersOnlineDock"))\n  {\n    _dockUserOnline.hide();\n    act.enabled = false;\n  }\n\n  // Allow rescan to let them show if privs granted\n  act.setData("ViewUsersOnlineDock");\n  _menuDesktop.appendAction(act);\n\n  fillListUserOnline();\n}\n\n/*!\n  Fills the list with open sales data.\n*/\nfunction fillListUserOnline()\n{\n  _dockUserOnline = mainwindow.findChild("_dockUserOnline");\n  _userOnline = mainwindow.findChild("_userOnline");\n\n  if (!_dockUserOnline.visible || !_userOnlineIsDirty)\n    return;\n\n  _userOnline.populate(toolbox.executeDbQuery("desktop","userOnline"));\n  _userOnlineIsDirty = false;\n}\n\n/*! \n  Opens the window associated with the selected item.\n*/\nfunction openWindowUserOnline()\n{ \n  // Make sure we can open the window for this activity\n  if (!privilegeCheckUserOnline() ||\n      !_userOnline.currentItem().rawValue("usr_username").length)\n    return;\n\n  params = new Object;\n  params.username = _userOnline.currentItem().rawValue("usr_username");\n  if (privilegeCheckUserOnline())\n    params.mode="edit";\n\n  // Open the window and perform any handling required\n  var user = toolbox.openWindow("user");\n  user.set(params);\n  if (user.exec())\n    refreshUserOnline();\n}\n\n/*!\n  Adds actions to @a pMenu, typically from a right click on a user record.\n*/\nfunction populateMenuUserOnline(pMenu, pItem)\n{\n  if (!_userOnline.currentItem().rawValue("usr_username").length)\n    return;\n\n  var menuItem;\n  var enable = privilegeCheckUserOnline();\n\n  menuItem = pMenu.addAction(_open);\n  menuItem.enabled = enable;\n  menuItem.triggered.connect(openWindowUserOnline);\n}\n\n/*!\n  Returns whether user has privileges to view detail on the selected User.\n*/\nfunction privilegeCheckUserOnline()\n{\n  return privileges.check("MaintainUsers");\n\n  return false;\n}\n\n/*!\n  Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshUserOnline()\n{\n  _userOnlineIsDirty = true;\n  fillListUserOnline();\n}\n 
106110
 
129     preferencesComment      0       t       try\n{\n  var _usr       = mywindow.findChild("_usr");\n  var _type      = mywindow.findChild("_type");\n  var _source    = mywindow.findChild("_source");\n  var _dates     = mywindow.findChild("_dates");\n  var startdate;\n  var enddate;\n\n  if (!privileges.check("AccessAdditionalUser"))\n    _usr.hide();\n  else if(privileges.check("AccessAdditionalUser"))\n    _usr.show();\n\n  _type.addColumn("Comment Type",  -1,  1, true, "commenttype_name");\n  _source.addColumn("Comment Source",  -1,  1, false, "cmntsource_name");\n  _source.addColumn("Comment Source",  -1,  1, true, "cmntsource_fullname");\n  _usr.addColumn("User Name",  -1,  1, true, "usr_username");\n\n  populate();\n  mydialog.accepted.connect(save);\n}\ncatch (e)\n{\n  QMessageBox.critical(mywindow, "preferencesComment",\n                       "preferencesComment.js exception: " + e);\n}\n\nfunction set(params)\n{\n  var prefusr = preferences.value("MonitoredCommentUsrs");\n  var preftyp = preferences.value("MonitoredCommentTypes");\n  var prefsrc = preferences.value("MonitoredCommentSrcs");\n\n  var getDate = "SELECT CURRENT_DATE + CAST(<? literal(\\"offSet\\") ?> AS INTEGER) AS datevalue;";\n\n  params.offSet = ((preferences.value("MonitoredCommentStrtDate") != '')?preferences.value("MonitoredCommentStrtDate"):-1);\n  var data = toolbox.executeQuery(getDate, params);\n  if (data.first())\n    _dates.setStartDate(data.value("datevalue"));\n  else if (data.lastError().type != QSqlError.NoError)\n  {\n    QMessageBox.critical(mainwindow, qsTr("Database Error"),\n                         data.lastError().text);\n    return;\n  }\n\n  params.offSet = ((preferences.value("MonitoredCommentEndDate") != '')?preferences.value("MonitoredCommentEndDate"):0);\n  var data = toolbox.executeQuery(getDate, params);\n  if (data.first())\n    _dates.setEndDate(data.value("datevalue"));\n  else if (data.lastError().type != QSqlError.NoError)\n  {\n    QMessageBox.critical(mainwindow, qsTr("Database Error"),\n                         data.lastError().text);\n    return;\n  }\n\n  if (prefusr == '')\n  {\n    var qry = "SELECT usr_id FROM usr WHERE (usr_username = current_user);";\n    var data = toolbox.executeQuery(qry, -1);\n    if (data.first())\n      _usr.setId(data.value("usr_id"));\n    else if (data.lastError().type != QSqlError.NoError)\n    {\n      QMessageBox.critical(mainwindow, qsTr("Database Error"),\n                           data.lastError().text);\n      return;\n    }\n  }\n  else\n  {\n    var usrList = new Array();\n    usrList = prefusr.split(",");\n    for (var i in usrList)\n      _usr.setId(usrList[i], false);\n  }\n\n  var typList = new Array();\n  if (preftyp == '')\n    _type.setId(0);\n  else\n  {\n    typList = preftyp.split(",");\n    for (var j in typList)\n      _type.setId(typList[j], false);\n  }\n\n  var srcList = new Array();\n  if (prefsrc == '')\n    _source.setId(1);\n  else\n  {\n    srcList = prefsrc.split(",");\n    for (var k in srcList)\n      _source.setId(srcList[k], false);\n  }\n}\n\nfunction populate()\n{\n  try\n  {\n    _type.clear();\n    _type.populate(toolbox.executeDbQuery("desktop","cmmntPrefType"));\n    _source.clear();\n    _source.populate(toolbox.executeDbQuery("desktop","cmmntPrefSrc"));\n    if (privileges.check("AccessAdditionalUser"))\n    {\n      _usr.clear();\n      _usr.populate(toolbox.executeDbQuery("desktop","cmmntPrefUser"));\n    }\n  }\n  catch (e)\n  {\n    QMessageBox.critical(mywindow, "preferencesComment",\n                         "populateType exception: " + e);\n  }\n}\n\nfunction save()\n{\n  var typList = new Array();\n  var emptyList = new Array();\n  var selectedTyp = _type.selectedItems();\n  for (var i = 0; i < selectedTyp.length; i++)\n  {\n    if (selectedTyp[i].id() != 0)\n    {\n      typList[i] = selectedTyp[i].id();\n      preferences.set("MonitoredCommentTypes",  typList.join(","));\n    }\n    else\n    {\n      preferences.set("MonitoredCommentTypes",  emptyList.join(","));\n      break;\n    }\n  }\n\n  var srcList = new Array();\n  var selectedSrc = _source.selectedItems();\n  for (var i = 0; i < selectedSrc.length; i++)\n  {\n    if (selectedSrc[i].id() != 1)\n    {\n      srcList[i] = selectedSrc[i].id();\n      preferences.set("MonitoredCommentSrcs",  srcList.join(","));\n    }\n    else\n    {\n      preferences.set("MonitoredCommentSrcs",  emptyList.join(","));\n      break;\n    }\n  }\n\n  if (privileges.check("AccessAdditionalUser"))\n  {\n    var usrList = new Array();\n    var selectedUsr = _usr.selectedItems();\n    for (var i = 0; i < selectedUsr.length; i++)\n      usrList[i] = selectedUsr[i].id();\n    preferences.set("MonitoredCommentUsrs",  usrList.join(","));\n  }\n\n  var params = new Object();\n  params.startdate1 = _dates.startDate;\n  var qryStdate = "SELECT (<? value(\\"startdate1\\") ?>::DATE - (current_date)) AS difference1;";\n  var data1 = toolbox.executeQuery(qryStdate,params);\n  if (data1.first())\n    var strtDateoffSet = data1.value("difference1");\n  else if (data1.lastError().type != QSqlError.NoError)\n  {\n    QMessageBox.critical(mywindow, qsTr("Database Error"),\n                         data1.lastError().text);\n    mywindow.reject();\n  }\n\n  params.enddate1 = _dates.endDate;\n  var qryEnddate = "SELECT (<? value(\\"enddate1\\") ?>::DATE - (current_date)) AS difference2;";\n  var data2 = toolbox.executeQuery(qryEnddate,params);\n  if (data2.first())\n    var endDateoffSet = data2.value("difference2");\n  else if (data2.lastError().type != QSqlError.NoError)\n  {\n    QMessageBox.critical(mywindow, qsTr("Database Error"),\n                         data2.lastError().text);\n    mywindow.reject();\n  }\n\n  preferences.set("MonitoredCommentStrtDate", strtDateoffSet);\n  preferences.set("MonitoredCommentEndDate", endDateoffSet);\n}\n  
106111
 
89      preferencesHistory      0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _groupBy = mywindow.findChild("_groupBy");\nvar _timeFrame = mywindow.findChild("_timeFrame");\nvar _type = mywindow.findChild("_type");\n\nvar _path;\n\n// Populate timeFrame combo\n_timeFrame.append(0, qsTr("Today"), "day");\n_timeFrame.append(1, qsTr("This Week"), "week");\n_timeFrame.append(2, qsTr("This Month"), "month");\n_timeFrame.append(3, qsTr("This Year"), "year");\n\nmydialog.accepted.connect(save);\n\n/*!\n  Parameters @a params are passed to set up selection criteria for the window\n*/\nfunction set(params)\n{\n  if ("path" in params)\n  {\n    _path = params.path;\n    if (_path == "desktop/salesHist")\n    {\n      _type.append(0, qsTr("Bookings"), "bookings");\n      _type.append(1, qsTr("Sales"), "sales");\n\n      _groupBy.append(0, qsTr("Customer"), "cust");\n      _groupBy.append(1, qsTr("Product Category"), "prodcat");\n      _groupBy.append(2, qsTr("Sales Rep"), "salesrep");\n\n      mywindow.windowTitle = qsTr("Sales History Preferences");\n    }\n    else if (_path == "desktop/purchHist")\n    {\n      _type.append(0, qsTr("Receipts"), "receipts");\n      _type.append(1, qsTr("Variances"), "variances");\n\n      _groupBy.append(0, qsTr("Vendor"), "vend");\n      _groupBy.append(1, qsTr("Item"), "item");\n      _groupBy.append(2, qsTr("Purchase Agent"), "agent");\n\n      mywindow.windowTitle = qsTr("Purchase History Preferences");\n    }\n    else if (_path == "desktop/mfgHist")\n    {\n      _type.append(0, qsTr("Receipts"), "receipts");\n      _type.enabled = false;\n\n      _groupBy.append(0, qsTr("Class Code"), "classcode");\n      _groupBy.append(1, qsTr("Item"), "item");\n      _groupBy.append(2, qsTr("Planner Code"), "plancode");\n\n      mywindow.windowTitle = qsTr("Manufacture History Preferences");\n    }\n  }\n\n  if ("type" in params)\n    _type.code = params.type;\n\n  if ("groupBy" in params)\n    _groupBy.code = params.groupBy;\n\n  if ("timeFrame" in params)\n    _timeFrame.code = params.timeFrame;\n\n}\n\n/*!\n  Saves selection preferences to the local machine.\n*/\nfunction save()\n{\n  // Save preferences to local machine\n  preferences.set(_path + "/type", _type.code);\n  preferences.set(_path + "/groupBy", _groupBy.code);\n  preferences.set(_path + "/timeFrame", _timeFrame.code);\n}\n\n       
106112
 
90      preferencesSelections   0       t       /*\n * This file is part of the xtdesktop package for xTuple ERP: PostBooks edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\nvar _gl = mywindow.findChild("_gl");\n\n// Set columns on list\n_gl.addColumn(qsTr("Account#"),    -1, Qt.AlignLeft, true, "accnt_id");\n_gl.addColumn(qsTr("Description"), -1, Qt.AlignLeft, true, "accnt_descrip");\n_gl.addColumn(qsTr("Type"),        -1, Qt.AlignLeft, true, "accnt_type" );\n\nparams = new Object;\nparams.asset = qsTr("Asset");\nparams.liability = qsTr("Liability");\nparams.revenue = qsTr("Revenue");\nparams.expense = qsTr("Expense");\nparams.equity = qsTr("Equity");\n\n_gl.populate(toolbox.executeDbQuery("desktop", "glaccounts", params));\n\nfunction set(params)\n{\n  // Select accounts previously selected\n  var pref = preferences.value("MonitoredAccounts");\n  var accntList = new Array();\n  accntList = pref.split(",");\n  for (i in accntList)  \n  {\n    _gl.setId(accntList[i], false);\n  }\n}\n\nfunction save()\n{\n  var accntList = new Array();\n  var selected = _gl.selectedItems();\n  for (var i = 0; i < selected.length; i++)\n    accntList[i] = selected[i].id();\n\n  preferences.set("MonitoredAccounts",  accntList.join(","));\n}\n\n// Connect save on Ok\nmydialog.accepted.connect(save);\n      
106113
 
91      project 0       t       /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL.  By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("dockMyTodo");\n\n// Connect this window so that the To Do dock list gets updated\nmydialog.finished.connect(fillListToDo);\n     
106114
 
132     systemMessage   0       t       //debugger;\n\nvar _save  = mywindow.findChild("_save");\nvar layout = toolbox.widgetGetLayout(_save);\nvar _user  = mywindow.findChild("_user");\n\nvar _reply = toolbox.createWidget("QPushButton", mywindow, "_reply");\n_reply.text = qsTr("Reply");\nlayout.insertWidget(0, _reply);\n\n_reply.clicked.connect(sendReply);\n\nfunction sendReply() \n{\n  var params = new Object;\n  params.user = _user.text;\n\n  var newwnd = toolbox.openWindow("sendMessageToUser", mywindow, Qt.ApplicationModal, Qt.Dialog);\n  toolbox.lastWindow().set(params);\n  newwnd.exec();\n  mydialog.accept();\n}\n     
106115
 
\.
106116
 
 
106117
 
 
106118
 
--
106119
 
--
106120
 
 
106121
 
COPY pkguiform (uiform_id, uiform_name, uiform_order, uiform_enabled, uiform_source, uiform_notes) FROM stdin;
106122
 
35      desktopAccounting       0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>desktopAccounting</class>\n <widget class="QMainWindow" name="desktopAccounting">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>876</width>\n    <height>554</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Accounting</string>\n  </property>\n  <property name="documentMode">\n   <bool>true</bool>\n  </property>\n  <property name="dockOptions">\n   <set>QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks</set>\n  </property>\n  <widget class="QWidget" name="centralwidget">\n   <layout class="QGridLayout" name="gridLayout">\n    <item row="0" column="0">\n     <widget class="QLabel" name="desktopAccountingLit">\n      <property name="font">\n       <font>\n        <pointsize>14</pointsize>\n        <weight>75</weight>\n        <bold>true</bold>\n       </font>\n      </property>\n      <property name="text">\n       <string>Accounting</string>\n      </property>\n     </widget>\n    </item>\n    <item row="1" column="0" rowspan="2">\n     <widget class="QGroupBox" name="_apGroup">\n      <property name="title">\n       <string>Payables</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_7">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_apAging">\n         <property name="image">\n          <string notr="true">taxes_clock_48</string>\n         </property>\n         <property name="label">\n          <string>Aging</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">ap.dspAPAging</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="0">\n        <widget class="MenuButton" name="_apWorkbench">\n         <property name="image">\n          <string notr="true">check_write_48</string>\n         </property>\n         <property name="label">\n          <string>Workbench</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">ap.workbench</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string>dspBillingSelections</string>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="2" column="0">\n        <widget class="MenuButton" name="_vendorWorkbench">\n         <property name="image">\n          <string notr="true">customers_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Vendor</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">po.vendorWorkBench</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="1" column="1" rowspan="2">\n     <widget class="QGroupBox" name="_arGroup">\n      <property name="title">\n       <string>Receivables</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_6">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_arAging">\n         <property name="image">\n          <string notr="true">collection_account_clock_48</string>\n         </property>\n         <property name="label">\n          <string>Aging</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">ar.dspARAging</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="0">\n        <widget class="MenuButton" name="_arWorkbench">\n         <property name="image">\n          <string notr="true">collection_account_write_48</string>\n         </property>\n         <property name="label">\n          <string>Workbench</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">ar.arWorkBench</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string>dspBillingSelections</string>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="2" column="0">\n        <widget class="MenuButton" name="_customerWorkbench">\n         <property name="image">\n          <string notr="true">customers_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Customer</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.customerWorkbench</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="1" column="2">\n     <widget class="QGroupBox" name="_glGroup">\n      <property name="title">\n       <string>General Ledger</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_3">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="2">\n        <widget class="MenuButton" name="_chartOfAccounts">\n         <property name="image">\n          <string notr="true">company_write_48</string>\n         </property>\n         <property name="label">\n          <string>Chart of Accounts</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">gl.accountNumbers</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="4">\n        <widget class="MenuButton" name="_budget">\n         <property name="image">\n          <string notr="true">reward_write_48</string>\n         </property>\n         <property name="label">\n          <string>Budget</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">gl.maintainBudgets</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="4">\n        <widget class="MenuButton" name="_standardJournal">\n         <property name="image">\n          <string notr="true">accounting_write_48</string>\n         </property>\n         <property name="label">\n          <string>Standard Journal</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">gl.listStandardJournals</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="2">\n        <widget class="MenuButton" name="_journalSeries">\n         <property name="image">\n          <string notr="true">accounting_ok_48</string>\n         </property>\n         <property name="label">\n          <string>Journal Series</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">gl.unpostedEntries</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="1" column="3">\n     <widget class="QGroupBox" name="_bankGroup">\n      <property name="title">\n       <string>Bank Accounts</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_4">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_bankAdjustment">\n         <property name="image">\n          <string notr="true">bank_write_48</string>\n         </property>\n         <property name="label">\n          <string>Adjustment</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">gl.adjustmentEditList</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="0">\n        <widget class="MenuButton" name="_bankReconcile">\n         <property name="image">\n          <string notr="true">bank_ok_48</string>\n         </property>\n         <property name="label">\n          <string>Reconcile</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">gl.reconcileBankaccnt</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="2" column="2" colspan="2">\n     <widget class="QGroupBox" name="_reportGroup">\n      <property name="title">\n       <string>Reporting</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_5">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="2">\n        <widget class="MenuButton" name="_financialStatements">\n         <property name="image">\n          <string notr="true">spreadsheet_48</string>\n         </property>\n         <property name="label">\n          <string>Financial Statements</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">gl.viewFinancialReport</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="1">\n        <widget class="MenuButton" name="_trialBalance">\n         <property name="image">\n          <string notr="true">balance_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Trial Balance</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">gl.dspTrialBalances</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_glTransactions">\n         <property name="image">\n          <string notr="true">accounting_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Transactions</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">gl.dspGLTransactions</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n   </layout>\n  </widget>\n  <widget class="QDockWidget" name="_dockBankBal">\n   <property name="windowTitle">\n    <string>Bank Accounts</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="_dockBankBalContents">\n    <layout class="QGridLayout" name="gridLayout_9">\n     <property name="margin">\n      <number>0</number>\n     </property>\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_bankBal">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QDockWidget" name="_dockPayables">\n   <property name="windowTitle">\n    <string>Payables</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="_dockPayablesContents">\n    <layout class="QGridLayout" name="gridLayout_2">\n     <property name="margin">\n      <number>0</number>\n     </property>\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_ap">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QDockWidget" name="_dockReceivables">\n   <property name="windowTitle">\n    <string>Receivables</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="_dockReceivablesContents">\n    <layout class="QGridLayout" name="gridLayout_8">\n     <property name="margin">\n      <number>0</number>\n     </property>\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_ar">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QDockWidget" name="_dockGLAccounts">\n   <property name="windowTitle">\n    <string>Monitored Accounts</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>8</number>\n   </attribute>\n   <widget class="QWidget" name="_dockGlContents">\n    <layout class="QGridLayout" name="gridLayout_10">\n     <property name="leftMargin">\n      <number>0</number>\n     </property>\n     <property name="topMargin">\n      <number>0</number>\n     </property>\n     <property name="rightMargin">\n      <number>0</number>\n     </property>\n     <property name="bottomMargin">\n      <number>3</number>\n     </property>\n     <property name="verticalSpacing">\n      <number>3</number>\n     </property>\n     <item row="0" column="0" colspan="4">\n      <widget class="XTreeWidget" name="_glAccounts">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="2">\n      <widget class="QPushButton" name="_button1">\n       <property name="maximumSize">\n        <size>\n         <width>16</width>\n         <height>16</height>\n        </size>\n       </property>\n       <property name="text">\n        <string>b</string>\n       </property>\n       <property name="flat">\n        <bool>true</bool>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="3">\n      <widget class="QPushButton" name="_button2">\n       <property name="maximumSize">\n        <size>\n         <width>16</width>\n         <height>16</height>\n        </size>\n       </property>\n       <property name="text">\n        <string>b</string>\n       </property>\n       <property name="flat">\n        <bool>true</bool>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="1">\n      <spacer name="horizontalSpacer_2">\n       <property name="orientation">\n        <enum>Qt::Horizontal</enum>\n       </property>\n       <property name="sizeHint" stdset="0">\n        <size>\n         <width>40</width>\n         <height>20</height>\n        </size>\n       </property>\n      </spacer>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>MenuButton</class>\n   <extends>QWidget</extends>\n   <header>menubutton.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>xtreewidget.h</header>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections/>\n</ui>\n 
106123
 
36      desktopCRM      0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>desktopCRM</class>\n <widget class="QMainWindow" name="desktopCRM">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>893</width>\n    <height>554</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>CRM</string>\n  </property>\n  <property name="documentMode">\n   <bool>true</bool>\n  </property>\n  <property name="dockNestingEnabled">\n   <bool>true</bool>\n  </property>\n  <widget class="QWidget" name="centralwidget">\n   <layout class="QGridLayout" name="gridLayout_4">\n    <item row="0" column="0" colspan="3">\n     <widget class="QLabel" name="desktopCollaborateLit">\n      <property name="font">\n       <font>\n        <pointsize>14</pointsize>\n        <weight>75</weight>\n        <bold>true</bold>\n       </font>\n      </property>\n      <property name="text">\n       <string>Corporate Relationship Management</string>\n      </property>\n     </widget>\n    </item>\n    <item row="1" column="0" rowspan="2">\n     <widget class="QGroupBox" name="_personalGroup">\n      <property name="title">\n       <string>Personal</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_6">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="2" column="0">\n        <widget class="MenuButton" name="_eventManager">\n         <property name="image">\n          <string notr="true">lamp_48</string>\n         </property>\n         <property name="label">\n          <string>Event Manager</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sys.eventManager</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="0">\n        <widget class="MenuButton" name="_todoCalendar">\n         <property name="image">\n          <string notr="true">calendar_month_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>To Do Calendar</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">crm.todoListCalendar</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_todo">\n         <property name="image">\n          <string notr="true">notepad_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>To Do List</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">crm.todoList</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="1" column="1" rowspan="2">\n     <widget class="QGroupBox" name="_corporateGroup">\n      <property name="title">\n       <string>Corporate</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_7">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_accounts">\n         <property name="image">\n          <string notr="true">clients_48</string>\n         </property>\n         <property name="label">\n          <string>Accounts</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">crm.crmaccounts</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="0">\n        <widget class="MenuButton" name="_contacts">\n         <property name="image">\n          <string notr="true">execute_48</string>\n         </property>\n         <property name="label">\n          <string>Contacts</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">crm.contacts</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="3" column="0">\n        <widget class="MenuButton" name="_addresses">\n         <property name="image">\n          <string notr="true">book_48</string>\n         </property>\n         <property name="label">\n          <string>Address Book</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">crm.addresses</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="1" column="2">\n     <widget class="QGroupBox" name="_preSalesGroup">\n      <property name="title">\n       <string>Pre-Sales</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_3">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="1" column="2">\n        <widget class="MenuButton" name="_prospects">\n         <property name="image">\n          <string notr="true">customers_help_48</string>\n         </property>\n         <property name="label">\n          <string>Prospects</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.prospects</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="3" column="2">\n        <widget class="MenuButton" name="_quotes">\n         <property name="image">\n          <string notr="true">order_help_48</string>\n         </property>\n         <property name="label">\n          <string>Quotes</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.listQuotes</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="3" column="4">\n        <widget class="MenuButton" name="_quotesByItem">\n         <property name="image">\n          <string notr="true">order_search_48</string>\n         </property>\n         <property name="label">\n          <string>Quotes by Item</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.dspQuoteOrderLookupByItem</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="4">\n        <widget class="MenuButton" name="_opportunities">\n         <property name="image">\n          <string notr="true">money_bag_write_48</string>\n         </property>\n         <property name="label">\n          <string>Opportunities</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">crm.listOpportunity</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string>dspBillingSelections</string>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="1" column="3" rowspan="2">\n     <widget class="QGroupBox" name="_projectGroup">\n      <property name="title">\n       <string>Project</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_projects">\n         <property name="image">\n          <string notr="true">spreadsheet_48</string>\n         </property>\n         <property name="label">\n          <string>Projects</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">pm.projects</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="0">\n        <widget class="MenuButton" name="_timeSheets">\n         <property name="image">\n          <string notr="true">time_sheet_write_48</string>\n         </property>\n         <property name="label">\n          <string>Time &amp; Expense</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">pm.teSheets</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="2" column="0">\n        <widget class="MenuButton" name="_projectOrders">\n         <property name="image">\n          <string notr="true">spreadsheet_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Project Orders</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">pm.dspOrderActivityByProject</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="2" column="2">\n     <widget class="QGroupBox" name="_accountGroup">\n      <property name="title">\n       <string>Account Management</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_2">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="1">\n        <widget class="MenuButton" name="_customer">\n         <property name="image">\n          <string notr="true">customers_48</string>\n         </property>\n         <property name="label">\n          <string>Customer Workbench</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.customerWorkbench</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_incidents">\n         <property name="image">\n          <string notr="true">chat_48</string>\n         </property>\n         <property name="label">\n          <string>Incidents</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">crm.incidentList</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n   </layout>\n  </widget>\n  <widget class="QDockWidget" name="_dockMytodo">\n   <property name="windowTitle">\n    <string>To Do</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>8</number>\n   </attribute>\n   <widget class="QWidget" name="_dockTodoContents">\n    <layout class="QGridLayout" name="gridLayout_10">\n     <property name="margin">\n      <number>0</number>\n     </property>\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_todoList">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QDockWidget" name="_dockMycontacts">\n   <property name="windowTitle">\n    <string>My Contacts</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="_dockMycontactsContents">\n    <layout class="QGridLayout" name="gridLayout_8">\n     <property name="margin">\n      <number>0</number>\n     </property>\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_contactList">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QDockWidget" name="_dockMyaccounts">\n   <property name="windowTitle">\n    <string>My Accounts</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="_dockMyaccountsContent">\n    <layout class="QGridLayout" name="gridLayout_9">\n     <property name="margin">\n      <number>0</number>\n     </property>\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_accountList">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>MenuButton</class>\n   <extends>QWidget</extends>\n   <header>menubutton.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>xtreewidget.h</header>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections/>\n</ui>\n 
106124
 
37      desktopMaintenance      0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>desktopMaintenance</class>\n <widget class="QMainWindow" name="desktopMaintenance">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>905</width>\n    <height>563</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Maintenance</string>\n  </property>\n  <property name="documentMode">\n   <bool>true</bool>\n  </property>\n  <property name="dockOptions">\n   <set>QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks</set>\n  </property>\n  <widget class="QWidget" name="centralwidget">\n   <layout class="QGridLayout" name="gridLayout_3">\n    <item row="0" column="0">\n     <widget class="QLabel" name="desktopAccountingLit">\n      <property name="font">\n       <font>\n        <pointsize>14</pointsize>\n        <weight>75</weight>\n        <bold>true</bold>\n       </font>\n      </property>\n      <property name="text">\n       <string>Maintenance</string>\n      </property>\n     </widget>\n    </item>\n    <item row="1" column="0">\n     <widget class="QGroupBox" name="_productsGroup">\n      <property name="title">\n       <string>Products</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_7">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_items">\n         <property name="image">\n          <string notr="true">inventory_categories_48</string>\n         </property>\n         <property name="label">\n          <string>Items</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">pd.listItems</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="2" column="0">\n        <widget class="MenuButton" name="_bom">\n         <property name="image">\n          <string notr="true">inventory_write_48</string>\n         </property>\n         <property name="label">\n          <string>Bill of Materials</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">pd.listBOMs</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="0">\n        <layout class="QHBoxLayout" name="horizontalLayout_4">\n         <item>\n          <spacer name="horizontalSpacer_7">\n           <property name="orientation">\n            <enum>Qt::Horizontal</enum>\n           </property>\n           <property name="sizeHint" stdset="0">\n            <size>\n             <width>0</width>\n             <height>20</height>\n            </size>\n           </property>\n          </spacer>\n         </item>\n         <item>\n          <widget class="XLabel" name="_arrow_1">\n           <property name="image">\n            <string notr="true">ImgDownArrow</string>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <spacer name="horizontalSpacer_8">\n           <property name="orientation">\n            <enum>Qt::Horizontal</enum>\n           </property>\n           <property name="sizeHint" stdset="0">\n            <size>\n             <width>0</width>\n             <height>20</height>\n            </size>\n           </property>\n          </spacer>\n         </item>\n        </layout>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="1" column="1">\n     <widget class="QGroupBox" name="_inventoryGroup">\n      <property name="title">\n       <string>Inventory</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_6">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_sites">\n         <property name="image">\n          <string notr="true">store_house_48</string>\n         </property>\n         <property name="label">\n          <string>Site</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">im.warehouse</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="2" column="0">\n        <widget class="MenuButton" name="_locations">\n         <property name="image">\n          <string notr="true">cabinet_48</string>\n         </property>\n         <property name="label">\n          <string>Locations</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">im.warehousesLocations</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string>dspBillingSelections</string>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="0">\n        <layout class="QHBoxLayout" name="horizontalLayout_5">\n         <item>\n          <spacer name="horizontalSpacer_9">\n           <property name="orientation">\n            <enum>Qt::Horizontal</enum>\n           </property>\n           <property name="sizeHint" stdset="0">\n            <size>\n             <width>0</width>\n             <height>20</height>\n            </size>\n           </property>\n          </spacer>\n         </item>\n         <item>\n          <widget class="XLabel" name="_arrow_2">\n           <property name="image">\n            <string notr="true">ImgDownArrow</string>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <spacer name="horizontalSpacer_10">\n           <property name="orientation">\n            <enum>Qt::Horizontal</enum>\n           </property>\n           <property name="sizeHint" stdset="0">\n            <size>\n             <width>0</width>\n             <height>20</height>\n            </size>\n           </property>\n          </spacer>\n         </item>\n        </layout>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="1" column="2">\n     <widget class="QGroupBox" name="_pricingGroup">\n      <property name="title">\n       <string>Pricing</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_priceSchedules">\n         <property name="image">\n          <string notr="true">reward_clock_48</string>\n         </property>\n         <property name="label">\n          <string>Schedules</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.pricingSchedules</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="2" column="0">\n        <widget class="MenuButton" name="_priceSchedAssignments">\n         <property name="image">\n          <string notr="true">customers_write_48</string>\n         </property>\n         <property name="label">\n          <string>Assignments</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.pricingScheduleAssignments</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="0">\n        <layout class="QHBoxLayout" name="horizontalLayout">\n         <item>\n          <spacer name="horizontalSpacer_2">\n           <property name="orientation">\n            <enum>Qt::Horizontal</enum>\n           </property>\n           <property name="sizeHint" stdset="0">\n            <size>\n             <width>0</width>\n             <height>20</height>\n            </size>\n           </property>\n          </spacer>\n         </item>\n         <item>\n          <widget class="XLabel" name="_arrow_3">\n           <property name="image">\n            <string notr="true">ImgDownArrow</string>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <spacer name="horizontalSpacer">\n           <property name="orientation">\n            <enum>Qt::Horizontal</enum>\n           </property>\n           <property name="sizeHint" stdset="0">\n            <size>\n             <width>0</width>\n             <height>20</height>\n            </size>\n           </property>\n          </spacer>\n         </item>\n        </layout>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="1" column="3">\n     <widget class="QGroupBox" name="_securityGroup">\n      <property name="title">\n       <string>Security</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_4">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="2" column="0">\n        <widget class="MenuButton" name="_users">\n         <property name="image">\n          <string notr="true">user_48</string>\n         </property>\n         <property name="label">\n          <string>Users</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sys.maintainUsers</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_roles">\n         <property name="image">\n          <string notr="true">group_48</string>\n         </property>\n         <property name="label">\n          <string>Roles</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sys.maintainGroups</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="0">\n        <layout class="QHBoxLayout" name="horizontalLayout_2">\n         <item>\n          <spacer name="horizontalSpacer_3">\n           <property name="orientation">\n            <enum>Qt::Horizontal</enum>\n           </property>\n           <property name="sizeHint" stdset="0">\n            <size>\n             <width>0</width>\n             <height>20</height>\n            </size>\n           </property>\n          </spacer>\n         </item>\n         <item>\n          <widget class="XLabel" name="_arrow_4">\n           <property name="image">\n            <string notr="true">ImgDownArrow</string>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <spacer name="horizontalSpacer_4">\n           <property name="orientation">\n            <enum>Qt::Horizontal</enum>\n           </property>\n           <property name="sizeHint" stdset="0">\n            <size>\n             <width>0</width>\n             <height>20</height>\n            </size>\n           </property>\n          </spacer>\n         </item>\n        </layout>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="1" column="4">\n     <widget class="QGroupBox" name="_currencyGroup">\n      <property name="title">\n       <string>Currency</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_8">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_currencies">\n         <property name="image">\n          <string notr="true">coin_48</string>\n         </property>\n         <property name="label">\n          <string>Currencies</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sys.currencies</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="2" column="0">\n        <widget class="MenuButton" name="_exchangeRates">\n         <property name="image">\n          <string>coin_clock_48</string>\n         </property>\n         <property name="label">\n          <string>Exchange Rates</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sys.exchangeRates</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="0">\n        <layout class="QHBoxLayout" name="horizontalLayout_3">\n         <item>\n          <spacer name="horizontalSpacer_5">\n           <property name="orientation">\n            <enum>Qt::Horizontal</enum>\n           </property>\n           <property name="sizeHint" stdset="0">\n            <size>\n             <width>0</width>\n             <height>20</height>\n            </size>\n           </property>\n          </spacer>\n         </item>\n         <item>\n          <widget class="XLabel" name="_arrow_5">\n           <property name="image">\n            <string notr="true">ImgDownArrow</string>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <spacer name="horizontalSpacer_6">\n           <property name="orientation">\n            <enum>Qt::Horizontal</enum>\n           </property>\n           <property name="sizeHint" stdset="0">\n            <size>\n             <width>0</width>\n             <height>20</height>\n            </size>\n           </property>\n          </spacer>\n         </item>\n        </layout>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="2" column="0" colspan="5">\n     <widget class="QGroupBox" name="_designGroup">\n      <property name="title">\n       <string>Design</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_5">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="5">\n        <widget class="MenuButton" name="_commands">\n         <property name="image">\n          <string notr="true">calculation_write_48</string>\n         </property>\n         <property name="label">\n          <string>Commands</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sys.customCommands</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="4">\n        <widget class="MenuButton" name="_scripts">\n         <property name="image">\n          <string notr="true">script_write_48</string>\n         </property>\n         <property name="label">\n          <string>Scripts</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sys.scripts</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="3">\n        <widget class="MenuButton" name="_screens">\n         <property name="image">\n          <string notr="true">window_write_48</string>\n         </property>\n         <property name="label">\n          <string>Screens</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sys.uiforms</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="1">\n        <widget class="MenuButton" name="_reports">\n         <property name="image">\n          <string notr="true">spreadsheet_write_48</string>\n         </property>\n         <property name="label">\n          <string>Reports</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sys.reports</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_metasql">\n         <property name="image">\n          <string notr="true">export_database_write_48</string>\n         </property>\n         <property name="label">\n          <string>MetaSQL</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sys.metasqls</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n   </layout>\n  </widget>\n  <widget class="QDockWidget" name="_dockExtensions">\n   <property name="windowTitle">\n    <string>Extensions</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="_dockExtensionsContents">\n    <layout class="QGridLayout" name="gridLayout_9">\n     <property name="margin">\n      <number>0</number>\n     </property>\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_extensions">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QToolBar" name="_toolbar">\n   <property name="windowTitle">\n    <string>toolBar</string>\n   </property>\n   <property name="iconSize">\n    <size>\n     <width>32</width>\n     <height>32</height>\n    </size>\n   </property>\n   <attribute name="toolBarArea">\n    <enum>TopToolBarArea</enum>\n   </attribute>\n   <attribute name="toolBarBreak">\n    <bool>false</bool>\n   </attribute>\n  </widget>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>MenuButton</class>\n   <extends>QWidget</extends>\n   <header>menubutton.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XLabel</class>\n   <extends>QLabel</extends>\n   <header>xlabel.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>xtreewidget.h</header>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections/>\n</ui>\n  
106125
 
38      desktopManufacture      0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>desktopManufacture</class>\n <widget class="QMainWindow" name="desktopManufacture">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>882</width>\n    <height>554</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Manufacture</string>\n  </property>\n  <property name="documentMode">\n   <bool>true</bool>\n  </property>\n  <property name="dockNestingEnabled">\n   <bool>true</bool>\n  </property>\n  <widget class="QWidget" name="centralwidget">\n   <layout class="QGridLayout" name="gridLayout">\n    <item row="0" column="0">\n     <widget class="QLabel" name="desktopManufactureLit">\n      <property name="font">\n       <font>\n        <pointsize>14</pointsize>\n        <weight>75</weight>\n        <bold>true</bold>\n       </font>\n      </property>\n      <property name="text">\n       <string>Manufacture</string>\n      </property>\n     </widget>\n    </item>\n    <item row="1" column="0">\n     <widget class="QGroupBox" name="_planGroup">\n      <property name="title">\n       <string>Plan</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_6">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_inventoryAvail">\n         <property name="image">\n          <string notr="true">inventory_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Inventory Availability</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">im.dspInventoryAvailability</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="1">\n        <widget class="XLabel" name="_arrow_1">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="2">\n        <widget class="MenuButton" name="_newWo">\n         <property name="image">\n          <string notr="true">industry_add_48</string>\n         </property>\n         <property name="label">\n          <string>Create Work Order</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.newWorkOrder</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="3">\n        <widget class="XLabel" name="_arrow_2">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="4">\n        <widget class="MenuButton" name="_maintainMaterial">\n         <property name="image">\n          <string notr="true">availability_write_48</string>\n         </property>\n         <property name="label">\n          <string>Material Requirements</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.maintainWoMaterialRequirements</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="5">\n        <widget class="XLabel" name="_arrow_3">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="8">\n        <widget class="MenuButton" name="_releaseWo">\n         <property name="image">\n          <string notr="true">industry_next_48</string>\n         </property>\n         <property name="label">\n          <string>Release</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.releaseWorkOrdersByPlannerCode</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="6">\n        <widget class="MenuButton" name="_printWo">\n         <property name="image">\n          <string notr="true">printer_48</string>\n         </property>\n         <property name="label">\n          <string>Print</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.printTraveler</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="7">\n        <widget class="XLabel" name="_arrow_4">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="2" column="0">\n     <widget class="QGroupBox" name="_processGroup">\n      <property name="title">\n       <string>Process</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_5">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="5">\n        <widget class="XLabel" name="_arrow_6">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="12">\n        <widget class="XLabel" name="_arrow_8">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="4">\n        <widget class="MenuButton" name="_issueMatl">\n         <property name="image">\n          <string notr="true">barcode_ok_48</string>\n         </property>\n         <property name="label">\n          <string>Issue Material</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.issueWoMaterialItem</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="13">\n        <widget class="MenuButton" name="_closeWo">\n         <property name="image">\n          <string notr="true">industry_close_48</string>\n         </property>\n         <property name="label">\n          <string>Close Work Order</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.closeWorkOrder</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="4">\n        <widget class="MenuButton" name="_returnMatl">\n         <property name="image">\n          <string notr="true">barcode_back_48</string>\n         </property>\n         <property name="label">\n          <string>Return Material</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.returnWoMaterialItem</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="2">\n        <widget class="XLabel" name="_arrow_5">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="8">\n        <widget class="XLabel" name="_arrow_7">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="9">\n        <widget class="MenuButton" name="_woCost">\n         <property name="image">\n          <string notr="true">coin_stack_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Costing</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.dspJobCosting</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="13">\n        <widget class="MenuButton" name="_woHistory">\n         <property name="image">\n          <string notr="true">history_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>History</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.dspWoHistoryByClassCode</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="6">\n        <widget class="MenuButton" name="_postProduction">\n         <property name="image">\n          <string notr="true">industry_ok_48</string>\n         </property>\n         <property name="label">\n          <string>Post Production</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.postProduction</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="9">\n        <widget class="MenuButton" name="_scrap">\n         <property name="image">\n          <string notr="true">trash_ok_48</string>\n         </property>\n         <property name="label">\n          <string>Post Scrap</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.scrapWoMaterialFromWo</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="1">\n        <widget class="MenuButton" name="_workOrderSchedule">\n         <property name="image">\n          <string notr="true">industry_clock_48</string>\n         </property>\n         <property name="label">\n          <string>Order Schedule</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.dspWoSchedule</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="1">\n        <widget class="MenuButton" name="_woAvail">\n         <property name="image">\n          <string notr="true">availability_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Material Availability</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.dspInventoryAvailabilityByWorkOrder</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="6">\n        <widget class="MenuButton" name="_correctProdPost">\n         <property name="image">\n          <string notr="true">industry_back_48</string>\n         </property>\n         <property name="label">\n          <string>Correct Production</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">wo.correctProductionPosting</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n   </layout>\n  </widget>\n  <widget class="QDockWidget" name="_dockMfgAct">\n   <property name="allowedAreas">\n    <set>Qt::AllDockWidgetAreas</set>\n   </property>\n   <property name="windowTitle">\n    <string>Manufacture Activities</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="_dockMfgActContents">\n    <layout class="QGridLayout" name="gridLayout_3">\n     <property name="margin">\n      <number>0</number>\n     </property>\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_mfgAct">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QDockWidget" name="_dockMfgHist">\n   <property name="windowTitle">\n    <string>Manufacture History</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="_dockMfgHistContents">\n    <layout class="QGridLayout" name="gridLayout_2">\n     <property name="leftMargin">\n      <number>0</number>\n     </property>\n     <property name="topMargin">\n      <number>0</number>\n     </property>\n     <property name="rightMargin">\n      <number>0</number>\n     </property>\n     <property name="bottomMargin">\n      <number>3</number>\n     </property>\n     <property name="verticalSpacing">\n      <number>3</number>\n     </property>\n     <item row="0" column="0" colspan="3">\n      <widget class="XTreeWidget" name="_mfgHist">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="0">\n      <widget class="QLabel" name="_label">\n       <property name="sizePolicy">\n        <sizepolicy hsizetype="Expanding" vsizetype="Preferred">\n         <horstretch>0</horstretch>\n         <verstretch>0</verstretch>\n        </sizepolicy>\n       </property>\n       <property name="text">\n        <string>label</string>\n       </property>\n       <property name="alignment">\n        <set>Qt::AlignCenter</set>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="1">\n      <widget class="QPushButton" name="_button1">\n       <property name="maximumSize">\n        <size>\n         <width>16</width>\n         <height>16</height>\n        </size>\n       </property>\n       <property name="text">\n        <string>b</string>\n       </property>\n       <property name="flat">\n        <bool>true</bool>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="2">\n      <widget class="QPushButton" name="_button2">\n       <property name="maximumSize">\n        <size>\n         <width>16</width>\n         <height>16</height>\n        </size>\n       </property>\n       <property name="text">\n        <string>b</string>\n       </property>\n       <property name="flat">\n        <bool>true</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QDockWidget" name="_dockMfgOpen">\n   <property name="allowedAreas">\n    <set>Qt::AllDockWidgetAreas</set>\n   </property>\n   <property name="windowTitle">\n    <string>Work Orders</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>8</number>\n   </attribute>\n   <widget class="QWidget" name="_dockMfgOpenContents">\n    <layout class="QGridLayout" name="gridLayout_4">\n     <property name="margin">\n      <number>0</number>\n     </property>\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_mfgOpen">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>MenuButton</class>\n   <extends>QWidget</extends>\n   <header>menubutton.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XLabel</class>\n   <extends>QLabel</extends>\n   <header>xlabel.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>xtreewidget.h</header>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections/>\n</ui>\n   
106126
 
40      desktopPurchase 0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>desktopPurchase</class>\n <widget class="QMainWindow" name="desktopPurchase">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>886</width>\n    <height>554</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Purchase</string>\n  </property>\n  <property name="documentMode">\n   <bool>true</bool>\n  </property>\n  <property name="dockNestingEnabled">\n   <bool>true</bool>\n  </property>\n  <widget class="QWidget" name="centralwidget">\n   <layout class="QGridLayout" name="gridLayout">\n    <item row="0" column="0">\n     <widget class="QLabel" name="desktopPurchaseLit">\n      <property name="font">\n       <font>\n        <pointsize>14</pointsize>\n        <weight>75</weight>\n        <bold>true</bold>\n       </font>\n      </property>\n      <property name="text">\n       <string>Purchase</string>\n      </property>\n     </widget>\n    </item>\n    <item row="1" column="0" colspan="2">\n     <widget class="QGroupBox" name="_purchaseGroup">\n      <property name="title">\n       <string>Order</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_8">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="3">\n        <widget class="MenuButton" name="_purchaseRequests">\n         <property name="image">\n          <string notr="true">order_help_48</string>\n         </property>\n         <property name="label">\n          <string>Purchase Requests</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">po.dspPurchaseRequestsByPlannerCode</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="5">\n        <widget class="MenuButton" name="_purchaseOrders">\n         <property name="image">\n          <string notr="true">order_add_48</string>\n         </property>\n         <property name="label">\n          <string>Create Purchase Order</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">po.newPurchaseOrder</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="9">\n        <widget class="MenuButton" name="_purchaseOrdersItemsByDate">\n         <property name="image">\n          <string notr="true">printer_48</string>\n         </property>\n         <property name="label">\n          <string>Print</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">po.printPurchaseOrder</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="1">\n        <widget class="MenuButton" name="_inventoryAvail">\n         <property name="image">\n          <string notr="true">inventory_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Inventory Availability</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">im.dspInventoryAvailability</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="2">\n        <widget class="XLabel" name="_arrow_2">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="4">\n        <widget class="XLabel" name="_arrow_3">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="6">\n        <widget class="XLabel" name="_arrow_4">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="11">\n        <widget class="MenuButton" name="_releasePlannedOrders">\n         <property name="image">\n          <string notr="true">order_next_48</string>\n         </property>\n         <property name="label">\n          <string>Release</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">po.listUnpostedPurchaseOrders</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="10">\n        <widget class="XLabel" name="_arrow_5">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="2" column="0">\n     <widget class="QGroupBox" name="_receivingGroup">\n      <property name="title">\n       <string>Receive</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_9">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_enterReceipts">\n         <property name="image">\n          <string notr="true">barcode_ok_48</string>\n         </property>\n         <property name="label">\n          <string>Enter Receipts</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sr.enterReceipt</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="0">\n        <widget class="MenuButton" name="_unpostedReceipts">\n         <property name="image">\n          <string notr="true">inventory_48</string>\n         </property>\n         <property name="label">\n          <string>Unposted Receipts</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sr.postReceipts</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="2" column="1">\n     <widget class="QGroupBox" name="_paymentGroup">\n      <property name="title">\n       <string>Payment</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_10">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="1">\n        <widget class="MenuButton" name="_vouchers">\n         <property name="image">\n          <string notr="true">taxes_ok_48</string>\n         </property>\n         <property name="label">\n          <string>Vouchers</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">po.listUnpostedVouchers</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="6">\n        <widget class="MenuButton" name="_selectForPayment">\n         <property name="image">\n          <string notr="true">stamp_48</string>\n         </property>\n         <property name="label">\n          <string>Select for Payment</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">ap.selectPayments</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="6">\n        <widget class="MenuButton" name="_selectedPayments">\n         <property name="image">\n          <string notr="true">stamp_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Selected Payments</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">ap.listSelectPayments</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="9">\n        <widget class="MenuButton" name="_checkRegister">\n         <property name="image">\n          <string notr="true">check_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Check Register</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">ap.dspCheckRegister</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="9">\n        <widget class="MenuButton" name="_viewCheckRun">\n         <property name="image">\n          <string notr="true">check_ok_48</string>\n         </property>\n         <property name="label">\n          <string>Check Run</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">ap.viewCheckRun</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="4">\n        <widget class="MenuButton" name="_apAging">\n         <property name="image">\n          <string notr="true">taxes_clock_48</string>\n         </property>\n         <property name="label">\n          <string>Aging</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">ap.dspAPAging</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string>dspTimePhasedOpenAPItems</string>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string>ViewAPOpenItems</string>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="1">\n        <widget class="MenuButton" name="_uninvoicedReceipts">\n         <property name="image">\n          <string notr="true">inventory_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Uninvoiced Receipts</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">ap.uninvoicedReceipts</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="4">\n        <widget class="MenuButton" name="_apOpenItemsByVendor">\n         <property name="image">\n          <string notr="true">taxes_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Open Items</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">ap.dspOpenAPItemsByVendor</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="3">\n        <widget class="XLabel" name="_arrow_6">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="5">\n        <widget class="XLabel" name="_arrow_7">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="7">\n        <widget class="XLabel" name="_arrow_8">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n   </layout>\n  </widget>\n  <widget class="QDockWidget" name="_dockPurchAct">\n   <property name="allowedAreas">\n    <set>Qt::AllDockWidgetAreas</set>\n   </property>\n   <property name="windowTitle">\n    <string>Purchase Activities</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="_dockPurchActContents">\n    <layout class="QGridLayout" name="gridLayout_3">\n     <property name="margin">\n      <number>0</number>\n     </property>\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_purchAct">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QDockWidget" name="_dockPurchHist">\n   <property name="windowTitle">\n    <string>Purchase History</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="_dockPurchHistContents">\n    <layout class="QGridLayout" name="gridLayout_2">\n     <property name="leftMargin">\n      <number>0</number>\n     </property>\n     <property name="topMargin">\n      <number>0</number>\n     </property>\n     <property name="rightMargin">\n      <number>0</number>\n     </property>\n     <property name="bottomMargin">\n      <number>3</number>\n     </property>\n     <property name="verticalSpacing">\n      <number>3</number>\n     </property>\n     <item row="0" column="0" colspan="3">\n      <widget class="XTreeWidget" name="_purchHist">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="0">\n      <widget class="QLabel" name="_label">\n       <property name="sizePolicy">\n        <sizepolicy hsizetype="Expanding" vsizetype="Preferred">\n         <horstretch>0</horstretch>\n         <verstretch>0</verstretch>\n        </sizepolicy>\n       </property>\n       <property name="text">\n        <string>label</string>\n       </property>\n       <property name="alignment">\n        <set>Qt::AlignCenter</set>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="1">\n      <widget class="QPushButton" name="_button1">\n       <property name="maximumSize">\n        <size>\n         <width>16</width>\n         <height>16</height>\n        </size>\n       </property>\n       <property name="text">\n        <string>b</string>\n       </property>\n       <property name="flat">\n        <bool>true</bool>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="2">\n      <widget class="QPushButton" name="_button2">\n       <property name="maximumSize">\n        <size>\n         <width>16</width>\n         <height>16</height>\n        </size>\n       </property>\n       <property name="text">\n        <string>b</string>\n       </property>\n       <property name="flat">\n        <bool>true</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QDockWidget" name="_dockPurchOpen">\n   <property name="allowedAreas">\n    <set>Qt::AllDockWidgetAreas</set>\n   </property>\n   <property name="windowTitle">\n    <string>Purchase Orders</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>8</number>\n   </attribute>\n   <widget class="QWidget" name="_dockPurchOpenContents">\n    <layout class="QGridLayout" name="gridLayout_4">\n     <property name="margin">\n      <number>0</number>\n     </property>\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_purchOpen">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>MenuButton</class>\n   <extends>QWidget</extends>\n   <header>menubutton.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XLabel</class>\n   <extends>QLabel</extends>\n   <header>xlabel.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>xtreewidget.h</header>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections/>\n</ui>\n        
106127
 
41      desktopSales    0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>desktopSales</class>\n <widget class="QMainWindow" name="desktopSales">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>873</width>\n    <height>554</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Sales</string>\n  </property>\n  <property name="documentMode">\n   <bool>true</bool>\n  </property>\n  <property name="dockOptions">\n   <set>QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks</set>\n  </property>\n  <widget class="QWidget" name="centralwidget">\n   <layout class="QGridLayout" name="gridLayout_2">\n    <item row="0" column="0">\n     <widget class="QLabel" name="desktopSalesLit">\n      <property name="font">\n       <font>\n        <pointsize>14</pointsize>\n        <weight>75</weight>\n        <bold>true</bold>\n       </font>\n      </property>\n      <property name="text">\n       <string>Sales</string>\n      </property>\n     </widget>\n    </item>\n    <item row="1" column="0">\n     <widget class="QGroupBox" name="_orderGroup">\n      <property name="title">\n       <string>Order</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_prospects">\n         <property name="image">\n          <string notr="true">customers_write_48</string>\n         </property>\n         <property name="label">\n          <string>Prospects</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.prospects</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="1">\n        <widget class="XLabel" name="_arrow_1">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="2">\n        <widget class="MenuButton" name="_customers">\n         <property name="image">\n          <string notr="true">customers_add_48</string>\n         </property>\n         <property name="label">\n          <string>New Customer</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.enterNewCustomer</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="0">\n        <widget class="MenuButton" name="_quotes">\n         <property name="image">\n          <string notr="true">order_write_48</string>\n         </property>\n         <property name="label">\n          <string>Quotes</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.listQuotes</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="1">\n        <widget class="XLabel" name="_arrow_2">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="2">\n        <widget class="MenuButton" name="_salesOrders">\n         <property name="image">\n          <string notr="true">order_add_48</string>\n         </property>\n         <property name="label">\n          <string>New Sales Order</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.newSalesOrder</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="1" column="1">\n     <widget class="QGroupBox" name="_shipGroup">\n      <property name="title">\n       <string>Ship</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_3">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="1" column="1">\n        <widget class="MenuButton" name="_printPackingLists">\n         <property name="image">\n          <string notr="true">printer_48</string>\n         </property>\n         <property name="label">\n          <string>Print Packing Lists</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sr.packingListBatch</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="2">\n        <widget class="XLabel" name="_arrow_3">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="4">\n        <widget class="MenuButton" name="_issueToShipping">\n         <property name="image">\n          <string notr="true">barcode_ok_48</string>\n         </property>\n         <property name="label">\n          <string>Issue To Shipping</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sr.issueToShipping</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="5">\n        <widget class="XLabel" name="_arrow_4">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="1" column="6">\n        <widget class="MenuButton" name="_shipOrder">\n         <property name="image">\n          <string notr="true">dispatch_order_ok_48</string>\n         </property>\n         <property name="label">\n          <string>Ship</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sr.shipOrder</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="6">\n        <widget class="MenuButton" name="_maintainShipping">\n         <property name="image">\n          <string notr="true">dispatch_order_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Maintain Shipping</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">sr.maintainShippingContents</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="4">\n        <widget class="MenuButton" name="_invAvailability">\n         <property name="image">\n          <string notr="true">order_zoom_48</string>\n         </property>\n         <property name="label">\n          <string>Inventory Availability</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.dspInventoryAvailabilityByCustomerType</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="1">\n        <widget class="MenuButton" name="_backlog">\n         <property name="image">\n          <string notr="true">order_clock_48</string>\n         </property>\n         <property name="label">\n          <string>Backlog</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.dspSummarizedBacklogByWarehouse</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n    <item row="2" column="0" colspan="2">\n     <widget class="QGroupBox" name="_billGroup">\n      <property name="title">\n       <string>Bill</string>\n      </property>\n      <layout class="QGridLayout" name="gridLayout_4">\n       <property name="margin">\n        <number>6</number>\n       </property>\n       <property name="spacing">\n        <number>0</number>\n       </property>\n       <item row="0" column="0">\n        <widget class="MenuButton" name="_selectForBilling">\n         <property name="image">\n          <string notr="true">stamp_48</string>\n         </property>\n         <property name="label">\n          <string>Select for Billing</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.uninvoicedShipments</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="2">\n        <widget class="MenuButton" name="_createInvoices">\n         <property name="image">\n          <string notr="true">taxes_add_48</string>\n         </property>\n         <property name="label">\n          <string>Create Invoices</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.dspBillingSelections</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string>dspBillingSelections</string>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="4">\n        <widget class="MenuButton" name="_postInvoices">\n         <property name="image">\n          <string notr="true">taxes_ok_48</string>\n         </property>\n         <property name="label">\n          <string>Post Invoices</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">so.listUnpostedInvoices</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="6">\n        <widget class="MenuButton" name="_aging">\n         <property name="image">\n          <string notr="true">taxes_clock_48</string>\n         </property>\n         <property name="label">\n          <string>Aging</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">ar.dspARAging</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="8">\n        <widget class="MenuButton" name="_cashReceipts">\n         <property name="image">\n          <string notr="true">payment_ok_48</string>\n         </property>\n         <property name="label">\n          <string>Cash Receipts</string>\n         </property>\n         <property name="actionName" stdset="0">\n          <string notr="true">ar.cashReceiptEditList</string>\n         </property>\n         <property name="ui" stdset="0">\n          <string/>\n         </property>\n         <property name="editPrivilege" stdset="0">\n          <string/>\n         </property>\n         <property name="viewPrivilege" stdset="0">\n          <string/>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="7">\n        <widget class="XLabel" name="_arrow_8">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="5">\n        <widget class="XLabel" name="_arrow_7">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="3">\n        <widget class="XLabel" name="_arrow_6">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n       <item row="0" column="1">\n        <widget class="XLabel" name="_arrow_5">\n         <property name="sizePolicy">\n          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name="image">\n          <string notr="true">ImgRightArrow</string>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </item>\n   </layout>\n  </widget>\n  <widget class="QDockWidget" name="_dockSalesAct">\n   <property name="windowTitle">\n    <string>Sales Activities</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="_dockActContents">\n    <layout class="QGridLayout" name="gridLayout_7">\n     <property name="margin">\n      <number>0</number>\n     </property>\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_salesAct">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QDockWidget" name="_dockSalesHist">\n   <property name="windowTitle">\n    <string>Sales History</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="_dockHistContents">\n    <layout class="QGridLayout" name="gridLayout_8">\n     <property name="leftMargin">\n      <number>0</number>\n     </property>\n     <property name="topMargin">\n      <number>0</number>\n     </property>\n     <property name="rightMargin">\n      <number>0</number>\n     </property>\n     <property name="bottomMargin">\n      <number>3</number>\n     </property>\n     <property name="verticalSpacing">\n      <number>3</number>\n     </property>\n     <item row="0" column="0" colspan="3">\n      <widget class="XTreeWidget" name="_salesHist">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="0">\n      <widget class="QLabel" name="_label">\n       <property name="sizePolicy">\n        <sizepolicy hsizetype="Expanding" vsizetype="Preferred">\n         <horstretch>0</horstretch>\n         <verstretch>0</verstretch>\n        </sizepolicy>\n       </property>\n       <property name="text">\n        <string>label</string>\n       </property>\n       <property name="alignment">\n        <set>Qt::AlignCenter</set>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="1">\n      <widget class="QPushButton" name="_button1">\n       <property name="maximumSize">\n        <size>\n         <width>16</width>\n         <height>16</height>\n        </size>\n       </property>\n       <property name="text">\n        <string>b</string>\n       </property>\n       <property name="flat">\n        <bool>true</bool>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="2">\n      <widget class="QPushButton" name="_button2">\n       <property name="maximumSize">\n        <size>\n         <width>16</width>\n         <height>16</height>\n        </size>\n       </property>\n       <property name="text">\n        <string>b</string>\n       </property>\n       <property name="flat">\n        <bool>true</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QDockWidget" name="_dockSalesOpen">\n   <property name="windowTitle">\n    <string>Sales Orders</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>8</number>\n   </attribute>\n   <widget class="QWidget" name="_dockSalesOpenContents">\n    <layout class="QGridLayout" name="gridLayout_10">\n     <property name="margin">\n      <number>0</number>\n     </property>\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_salesOpen">\n       <property name="populateLinear">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>MenuButton</class>\n   <extends>QWidget</extends>\n   <header>menubutton.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XLabel</class>\n   <extends>QLabel</extends>\n   <header>xlabel.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>xtreewidget.h</header>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections/>\n</ui>\n 
106128
 
64      desktop 0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>desktop</class>\n <widget class="QWidget" name="desktop">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>24</width>\n    <height>24</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Desktop</string>\n  </property>\n  <layout class="QGridLayout" name="_layout"/>\n </widget>\n <resources/>\n <connections/>\n</ui>\n       container ui for the desktop webview
106129
 
39      desktopNotice   0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>desktopNotice</class>\n <widget class="QDialog" name="desktopNotice">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>211</width>\n    <height>109</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Notice</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout">\n   <item row="0" column="0">\n    <widget class="QLabel" name="_notice">\n     <property name="sizePolicy">\n      <sizepolicy hsizetype="Fixed" vsizetype="Fixed">\n       <horstretch>0</horstretch>\n       <verstretch>0</verstretch>\n      </sizepolicy>\n     </property>\n     <property name="text">\n      <string>Note: The xTuple Desktop is only available when user preferences are set to show windows as free-floating.</string>\n     </property>\n     <property name="wordWrap">\n      <bool>true</bool>\n     </property>\n    </widget>\n   </item>\n   <item row="1" column="0">\n    <widget class="QCheckBox" name="_remind">\n     <property name="text">\n      <string>Remind me about this again.</string>\n     </property>\n     <property name="checked">\n      <bool>true</bool>\n     </property>\n    </widget>\n   </item>\n   <item row="2" column="0">\n    <widget class="QDialogButtonBox" name="_buttonBox">\n     <property name="orientation">\n      <enum>Qt::Horizontal</enum>\n     </property>\n     <property name="standardButtons">\n      <set>QDialogButtonBox::Ok</set>\n     </property>\n     <property name="centerButtons">\n      <bool>true</bool>\n     </property>\n    </widget>\n   </item>\n  </layout>\n </widget>\n <resources/>\n <connections>\n  <connection>\n   <sender>_buttonBox</sender>\n   <signal>accepted()</signal>\n   <receiver>desktopNotice</receiver>\n   <slot>accept()</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>248</x>\n     <y>254</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>157</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n  <connection>\n   <sender>_buttonBox</sender>\n   <signal>rejected()</signal>\n   <receiver>desktopNotice</receiver>\n   <slot>reject()</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>316</x>\n     <y>260</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>286</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n </connections>\n</ui>\n       
106130
 
60      desktopSocial   0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <class>desktopSocial</class>\n <widget class="QMainWindow" name="desktopSocial">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>996</width>\n    <height>666</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Social</string>\n  </property>\n  <widget class="QWidget" name="centralwidget">\n   <layout class="QGridLayout" name="gridLayout_5">\n    <item row="0" column="0">\n     <layout class="QVBoxLayout" name="verticalLayout">\n      <item>\n       <layout class="QHBoxLayout" name="horizontalLayout">\n        <item>\n         <widget class="QLabel" name="desktopSociallit">\n          <property name="font">\n           <font>\n            <pointsize>15</pointsize>\n            <weight>75</weight>\n            <bold>true</bold>\n           </font>\n          </property>\n          <property name="text">\n           <string>Social</string>\n          </property>\n         </widget>\n        </item>\n        <item>\n         <spacer name="horizontalSpacer">\n          <property name="orientation">\n           <enum>Qt::Horizontal</enum>\n          </property>\n          <property name="sizeHint" stdset="0">\n           <size>\n            <width>40</width>\n            <height>20</height>\n           </size>\n          </property>\n         </spacer>\n        </item>\n       </layout>\n      </item>\n      <item>\n       <widget class="QGroupBox" name="_commentConsoleGrp">\n        <property name="title">\n         <string>Comment Console</string>\n        </property>\n        <layout class="QGridLayout" name="gridLayout">\n         <item row="0" column="0">\n          <widget class="XTreeWidget" name="_commentConsole"/>\n         </item>\n         <item row="1" column="0">\n          <layout class="QHBoxLayout" name="horizontalLayout_2">\n           <item>\n            <spacer name="horizontalSpacer_2">\n             <property name="orientation">\n              <enum>Qt::Horizontal</enum>\n             </property>\n             <property name="sizeHint" stdset="0">\n              <size>\n               <width>40</width>\n               <height>20</height>\n              </size>\n             </property>\n            </spacer>\n           </item>\n           <item>\n            <widget class="QPushButton" name="_button1">\n             <property name="maximumSize">\n              <size>\n               <width>16</width>\n               <height>16</height>\n              </size>\n             </property>\n             <property name="text">\n              <string>b</string>\n             </property>\n             <property name="flat">\n              <bool>true</bool>\n             </property>\n            </widget>\n           </item>\n           <item>\n            <widget class="QPushButton" name="_button2">\n             <property name="maximumSize">\n              <size>\n               <width>16</width>\n               <height>16</height>\n              </size>\n             </property>\n             <property name="text">\n              <string>b</string>\n             </property>\n             <property name="flat">\n              <bool>true</bool>\n             </property>\n            </widget>\n           </item>\n          </layout>\n         </item>\n        </layout>\n       </widget>\n      </item>\n     </layout>\n    </item>\n   </layout>\n  </widget>\n  <widget class="QDockWidget" name="_dockSendMessage">\n   <property name="allowedAreas">\n    <set>Qt::BottomDockWidgetArea|Qt::RightDockWidgetArea|Qt::TopDockWidgetArea</set>\n   </property>\n   <property name="windowTitle">\n    <string>Send Message</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="dockWidgetContents">\n    <layout class="QGridLayout" name="gridLayout_2">\n     <item row="0" column="0">\n      <widget class="QLabel" name="label_2">\n       <property name="text">\n        <string>User:</string>\n       </property>\n      </widget>\n     </item>\n     <item row="0" column="2" rowspan="2">\n      <widget class="QPushButton" name="_send">\n       <property name="enabled">\n        <bool>false</bool>\n       </property>\n       <property name="text">\n        <string>Send</string>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="0">\n      <widget class="UsernameCluster" name="_usr" native="true">\n       <property name="descriptionVisible" stdset="0">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="1">\n      <spacer name="horizontalSpacer_3">\n       <property name="orientation">\n        <enum>Qt::Horizontal</enum>\n       </property>\n       <property name="sizeHint" stdset="0">\n        <size>\n         <width>54</width>\n         <height>20</height>\n        </size>\n       </property>\n      </spacer>\n     </item>\n     <item row="2" column="0" colspan="3">\n      <layout class="QVBoxLayout" name="verticalLayout_2">\n       <item>\n        <widget class="QLabel" name="label_3">\n         <property name="text">\n          <string>Message:</string>\n         </property>\n        </widget>\n       </item>\n       <item>\n        <widget class="QPlainTextEdit" name="_message">\n         <property name="plainText">\n          <string/>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QDockWidget" name="_dockMessageHistory">\n   <property name="allowedAreas">\n    <set>Qt::BottomDockWidgetArea|Qt::RightDockWidgetArea|Qt::TopDockWidgetArea</set>\n   </property>\n   <property name="windowTitle">\n    <string>Message History</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="dockWidgetContents_2">\n    <layout class="QGridLayout" name="gridLayout_4">\n     <item row="0" column="0" colspan="3">\n      <widget class="XTreeWidget" name="_messageHistory"/>\n     </item>\n     <item row="1" column="0">\n      <spacer name="horizontalSpacer_4">\n       <property name="orientation">\n        <enum>Qt::Horizontal</enum>\n       </property>\n       <property name="sizeHint" stdset="0">\n        <size>\n         <width>282</width>\n         <height>20</height>\n        </size>\n       </property>\n      </spacer>\n     </item>\n     <item row="1" column="1">\n      <widget class="QPushButton" name="_button3">\n       <property name="maximumSize">\n        <size>\n         <width>16</width>\n         <height>16</height>\n        </size>\n       </property>\n       <property name="text">\n        <string>b</string>\n       </property>\n       <property name="flat">\n        <bool>true</bool>\n       </property>\n      </widget>\n     </item>\n     <item row="1" column="2">\n      <widget class="QPushButton" name="_button4">\n       <property name="maximumSize">\n        <size>\n         <width>16</width>\n         <height>16</height>\n        </size>\n       </property>\n       <property name="text">\n        <string>b</string>\n       </property>\n       <property name="flat">\n        <bool>true</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n  <widget class="QDockWidget" name="_dockUserOnline">\n   <property name="allowedAreas">\n    <set>Qt::BottomDockWidgetArea|Qt::RightDockWidgetArea|Qt::TopDockWidgetArea</set>\n   </property>\n   <property name="windowTitle">\n    <string>Users Online</string>\n   </property>\n   <attribute name="dockWidgetArea">\n    <number>1</number>\n   </attribute>\n   <widget class="QWidget" name="dockWidgetContents_4">\n    <layout class="QGridLayout" name="gridLayout_3">\n     <item row="0" column="0">\n      <widget class="XTreeWidget" name="_userOnline">\n       <property name="populateLinear" stdset="0">\n        <bool>false</bool>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>UsernameCluster</class>\n   <extends>QWidget</extends>\n   <header>usernamecluster.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>xtreewidget.h</header>\n   <container>1</container>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections/>\n</ui>\n    
106131
 
61      preferencesComment      0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <class>preferencesComment</class>\n <widget class="QDialog" name="preferencesComment">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>626</width>\n    <height>342</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Comment Preference</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout_2">\n   <item row="0" column="0">\n    <layout class="QGridLayout" name="gridLayout">\n     <item row="0" column="0">\n      <layout class="QHBoxLayout" name="horizontalLayout_6">\n       <item>\n        <widget class="DateCluster" name="_dates"/>\n       </item>\n       <item>\n        <spacer name="horizontalSpacer_6">\n         <property name="orientation">\n          <enum>Qt::Horizontal</enum>\n         </property>\n         <property name="sizeHint" stdset="0">\n          <size>\n           <width>40</width>\n           <height>20</height>\n          </size>\n         </property>\n        </spacer>\n       </item>\n      </layout>\n     </item>\n     <item row="1" column="0">\n      <layout class="QHBoxLayout" name="horizontalLayout_2">\n       <item>\n        <widget class="XTreeWidget" name="_usr">\n         <property name="selectionMode">\n          <enum>QAbstractItemView::ExtendedSelection</enum>\n         </property>\n        </widget>\n       </item>\n       <item>\n        <widget class="XTreeWidget" name="_type">\n         <property name="selectionMode">\n          <enum>QAbstractItemView::ExtendedSelection</enum>\n         </property>\n        </widget>\n       </item>\n       <item>\n        <widget class="XTreeWidget" name="_source">\n         <property name="selectionMode">\n          <enum>QAbstractItemView::ExtendedSelection</enum>\n         </property>\n        </widget>\n       </item>\n       <item>\n        <spacer name="horizontalSpacer_5">\n         <property name="orientation">\n          <enum>Qt::Horizontal</enum>\n         </property>\n         <property name="sizeHint" stdset="0">\n          <size>\n           <width>40</width>\n           <height>20</height>\n          </size>\n         </property>\n        </spacer>\n       </item>\n      </layout>\n     </item>\n     <item row="2" column="0">\n      <layout class="QHBoxLayout" name="horizontalLayout">\n       <item>\n        <spacer name="horizontalSpacer">\n         <property name="orientation">\n          <enum>Qt::Horizontal</enum>\n         </property>\n         <property name="sizeHint" stdset="0">\n          <size>\n           <width>40</width>\n           <height>20</height>\n          </size>\n         </property>\n        </spacer>\n       </item>\n       <item>\n        <widget class="QDialogButtonBox" name="_buttonBox">\n         <property name="orientation">\n          <enum>Qt::Horizontal</enum>\n         </property>\n         <property name="standardButtons">\n          <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>\n         </property>\n        </widget>\n       </item>\n      </layout>\n     </item>\n    </layout>\n   </item>\n  </layout>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>DateCluster</class>\n   <extends>QWidget</extends>\n   <header>datecluster.h</header>\n  </customwidget>\n  <customwidget>\n   <class>XTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>xtreewidget.h</header>\n   <container>1</container>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections>\n  <connection>\n   <sender>_buttonBox</sender>\n   <signal>accepted()</signal>\n   <receiver>preferencesComment</receiver>\n   <slot>accept()</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>248</x>\n     <y>254</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>157</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n  <connection>\n   <sender>_buttonBox</sender>\n   <signal>rejected()</signal>\n   <receiver>preferencesComment</receiver>\n   <slot>reject()</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>316</x>\n     <y>260</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>286</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n </connections>\n</ui>\n        
106132
 
62      preferencesNumber       0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <class>preferencesNumber</class>\n <widget class="QDialog" name="preferencesNumber">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>257</width>\n    <height>72</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Number Preferences</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout_2">\n   <item row="0" column="0">\n    <layout class="QGridLayout" name="gridLayout">\n     <item row="0" column="0">\n      <layout class="QHBoxLayout" name="horizontalLayout">\n       <item>\n        <widget class="QLabel" name="_limitLit">\n         <property name="text">\n          <string>Messages to display:</string>\n         </property>\n        </widget>\n       </item>\n       <item>\n        <widget class="QSpinBox" name="_limit">\n         <property name="value">\n          <number>10</number>\n         </property>\n        </widget>\n       </item>\n       <item>\n        <spacer name="horizontalSpacer">\n         <property name="orientation">\n          <enum>Qt::Horizontal</enum>\n         </property>\n         <property name="sizeHint" stdset="0">\n          <size>\n           <width>40</width>\n           <height>20</height>\n          </size>\n         </property>\n        </spacer>\n       </item>\n      </layout>\n     </item>\n     <item row="0" column="1">\n      <widget class="QDialogButtonBox" name="buttonBox">\n       <property name="orientation">\n        <enum>Qt::Vertical</enum>\n       </property>\n       <property name="standardButtons">\n        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </item>\n  </layout>\n </widget>\n <resources/>\n <connections>\n  <connection>\n   <sender>buttonBox</sender>\n   <signal>accepted()</signal>\n   <receiver>preferencesNumber</receiver>\n   <slot>accept()</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>209</x>\n     <y>35</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>128</x>\n     <y>35</y>\n    </hint>\n   </hints>\n  </connection>\n  <connection>\n   <sender>buttonBox</sender>\n   <signal>rejected()</signal>\n   <receiver>preferencesNumber</receiver>\n   <slot>reject()</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>209</x>\n     <y>35</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>128</x>\n     <y>35</y>\n    </hint>\n   </hints>\n  </connection>\n </connections>\n</ui>\n        
106133
 
63      sendMessageToUser       0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <class>sendMessageToUser</class>\n <widget class="QDialog" name="sendMessageToUser">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>406</width>\n    <height>300</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Send Message to User</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout">\n   <item row="0" column="0">\n    <widget class="QLabel" name="label">\n     <property name="text">\n      <string>User:</string>\n     </property>\n    </widget>\n   </item>\n   <item row="0" column="1" rowspan="2">\n    <spacer name="horizontalSpacer">\n     <property name="orientation">\n      <enum>Qt::Horizontal</enum>\n     </property>\n     <property name="sizeHint" stdset="0">\n      <size>\n       <width>158</width>\n       <height>56</height>\n      </size>\n     </property>\n    </spacer>\n   </item>\n   <item row="0" column="2" rowspan="2">\n    <layout class="QVBoxLayout" name="verticalLayout">\n     <item>\n      <widget class="QPushButton" name="_close">\n       <property name="text">\n        <string>Close</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <widget class="QPushButton" name="_send">\n       <property name="enabled">\n        <bool>false</bool>\n       </property>\n       <property name="text">\n        <string>Send</string>\n       </property>\n      </widget>\n     </item>\n     <item>\n      <spacer name="verticalSpacer">\n       <property name="orientation">\n        <enum>Qt::Vertical</enum>\n       </property>\n       <property name="sizeHint" stdset="0">\n        <size>\n         <width>38</width>\n         <height>25</height>\n        </size>\n       </property>\n      </spacer>\n     </item>\n    </layout>\n   </item>\n   <item row="1" column="0">\n    <widget class="UsernameCluster" name="_usr" native="true">\n     <property name="descriptionVisible" stdset="0">\n      <bool>false</bool>\n     </property>\n    </widget>\n   </item>\n   <item row="2" column="0">\n    <widget class="QLabel" name="label_2">\n     <property name="text">\n      <string>Message:</string>\n     </property>\n    </widget>\n   </item>\n   <item row="3" column="0" colspan="3">\n    <widget class="QPlainTextEdit" name="_message">\n     <property name="plainText">\n      <string/>\n     </property>\n    </widget>\n   </item>\n  </layout>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>UsernameCluster</class>\n   <extends>QWidget</extends>\n   <header>usernamecluster.h</header>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections/>\n</ui>\n    
106134
 
42      preferencesHistory      0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>preferencesHistory</class>\n <widget class="QDialog" name="preferencesHistory">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>350</width>\n    <height>104</height>\n   </rect>\n  </property>\n  <property name="minimumSize">\n   <size>\n    <width>350</width>\n    <height>0</height>\n   </size>\n  </property>\n  <property name="windowTitle">\n   <string>History Settings</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout">\n   <item row="0" column="0">\n    <widget class="QLabel" name="_typeLit">\n     <property name="text">\n      <string>Type:</string>\n     </property>\n     <property name="alignment">\n      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n     </property>\n    </widget>\n   </item>\n   <item row="0" column="1">\n    <widget class="XComboBox" name="_type">\n     <property name="sizePolicy">\n      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">\n       <horstretch>0</horstretch>\n       <verstretch>0</verstretch>\n      </sizepolicy>\n     </property>\n    </widget>\n   </item>\n   <item row="0" column="2" rowspan="3">\n    <widget class="QDialogButtonBox" name="buttonBox">\n     <property name="orientation">\n      <enum>Qt::Vertical</enum>\n     </property>\n     <property name="standardButtons">\n      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>\n     </property>\n    </widget>\n   </item>\n   <item row="1" column="0">\n    <widget class="QLabel" name="_groupByLit">\n     <property name="text">\n      <string>Group By:</string>\n     </property>\n     <property name="alignment">\n      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n     </property>\n    </widget>\n   </item>\n   <item row="1" column="1">\n    <widget class="XComboBox" name="_groupBy">\n     <property name="sizePolicy">\n      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">\n       <horstretch>0</horstretch>\n       <verstretch>0</verstretch>\n      </sizepolicy>\n     </property>\n    </widget>\n   </item>\n   <item row="2" column="0">\n    <widget class="QLabel" name="_timeFramLit">\n     <property name="text">\n      <string>Time Frame:</string>\n     </property>\n     <property name="alignment">\n      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>\n     </property>\n    </widget>\n   </item>\n   <item row="2" column="1">\n    <widget class="XComboBox" name="_timeFrame">\n     <property name="sizePolicy">\n      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">\n       <horstretch>0</horstretch>\n       <verstretch>0</verstretch>\n      </sizepolicy>\n     </property>\n    </widget>\n   </item>\n  </layout>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>XComboBox</class>\n   <extends>QComboBox</extends>\n   <header>xcombobox.h</header>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections>\n  <connection>\n   <sender>buttonBox</sender>\n   <signal>accepted()</signal>\n   <receiver>preferencesHistory</receiver>\n   <slot>accept()</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>248</x>\n     <y>254</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>157</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n  <connection>\n   <sender>buttonBox</sender>\n   <signal>rejected()</signal>\n   <receiver>preferencesHistory</receiver>\n   <slot>reject()</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>316</x>\n     <y>260</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>286</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n </connections>\n</ui>\n   
106135
 
43      preferencesSelections   0       t       <?xml version="1.0" encoding="UTF-8"?>\n<ui version="4.0">\n <comment>This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL.  By using this software, you agree\nto be bound by its terms.</comment>\n <class>preferencesSelections</class>\n <widget class="QDialog" name="preferencesSelections">\n  <property name="geometry">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>280</width>\n    <height>259</height>\n   </rect>\n  </property>\n  <property name="windowTitle">\n   <string>Selection Preferences</string>\n  </property>\n  <layout class="QGridLayout" name="gridLayout">\n   <item row="1" column="0">\n    <widget class="XTreeWidget" name="_gl">\n     <property name="selectionMode">\n      <enum>QAbstractItemView::ExtendedSelection</enum>\n     </property>\n    </widget>\n   </item>\n   <item row="2" column="0">\n    <widget class="QDialogButtonBox" name="_buttonBox">\n     <property name="orientation">\n      <enum>Qt::Horizontal</enum>\n     </property>\n     <property name="standardButtons">\n      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>\n     </property>\n    </widget>\n   </item>\n   <item row="0" column="0">\n    <widget class="QLabel" name="label">\n     <property name="text">\n      <string>Select Accounts to monitor:</string>\n     </property>\n    </widget>\n   </item>\n  </layout>\n </widget>\n <customwidgets>\n  <customwidget>\n   <class>XTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>xtreewidget.h</header>\n  </customwidget>\n </customwidgets>\n <resources/>\n <connections>\n  <connection>\n   <sender>_buttonBox</sender>\n   <signal>accepted()</signal>\n   <receiver>preferencesSelections</receiver>\n   <slot>accept()</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>248</x>\n     <y>254</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>157</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n  <connection>\n   <sender>_buttonBox</sender>\n   <signal>rejected()</signal>\n   <receiver>preferencesSelections</receiver>\n   <slot>reject()</slot>\n   <hints>\n    <hint type="sourcelabel">\n     <x>316</x>\n     <y>260</y>\n    </hint>\n    <hint type="destinationlabel">\n     <x>286</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n </connections>\n</ui>\n     
106136
 
\.
106137
 
 
106138
 
 
106139
 
SET search_path = fixcountry, pg_catalog;
106140
 
 
106141
 
--
106142
 
--
106143
 
 
106144
 
ALTER TABLE ONLY pkgcmd
106145
 
    ADD CONSTRAINT pkgcmd_pkey PRIMARY KEY (cmd_id);
106146
 
 
106147
 
 
106148
 
--
106149
 
--
106150
 
 
106151
 
ALTER TABLE ONLY pkgcmdarg
106152
 
    ADD CONSTRAINT pkgcmdarg_pkey PRIMARY KEY (cmdarg_id);
106153
 
 
106154
 
 
106155
 
--
106156
 
--
106157
 
 
106158
 
ALTER TABLE ONLY pkgimage
106159
 
    ADD CONSTRAINT pkgimage_pkey PRIMARY KEY (image_id);
106160
 
 
106161
 
 
106162
 
--
106163
 
--
106164
 
 
106165
 
ALTER TABLE ONLY pkgmetasql
106166
 
    ADD CONSTRAINT pkgmetasql_pkey PRIMARY KEY (metasql_id);
106167
 
 
106168
 
 
106169
 
--
106170
 
--
106171
 
 
106172
 
ALTER TABLE ONLY pkgpriv
106173
 
    ADD CONSTRAINT pkgpriv_pkey PRIMARY KEY (priv_id);
106174
 
 
106175
 
 
106176
 
--
106177
 
--
106178
 
 
106179
 
ALTER TABLE ONLY pkgreport
106180
 
    ADD CONSTRAINT pkgreport_pkey PRIMARY KEY (report_id);
106181
 
 
106182
 
 
106183
 
--
106184
 
--
106185
 
 
106186
 
ALTER TABLE ONLY pkgscript
106187
 
    ADD CONSTRAINT pkgscript_pkey PRIMARY KEY (script_id);
106188
 
 
106189
 
 
106190
 
--
106191
 
--
106192
 
 
106193
 
ALTER TABLE ONLY pkguiform
106194
 
    ADD CONSTRAINT pkguiform_pkey PRIMARY KEY (uiform_id);
106195
 
 
106196
 
 
106197
 
SET search_path = public, pg_catalog;
106198
 
 
106199
 
--
106200
 
--
106201
 
 
106202
 
ALTER TABLE ONLY acalitem
106203
 
    ADD CONSTRAINT acalitem_pkey PRIMARY KEY (acalitem_id);
106204
 
 
106205
 
 
106206
 
--
106207
 
--
106208
 
 
106209
 
ALTER TABLE ONLY accnt
106210
 
    ADD CONSTRAINT accnt_pkey PRIMARY KEY (accnt_id);
106211
 
 
106212
 
 
106213
 
--
106214
 
--
106215
 
 
106216
 
ALTER TABLE ONLY addr
106217
 
    ADD CONSTRAINT addr_addr_number_key UNIQUE (addr_number);
106218
 
 
106219
 
 
106220
 
--
106221
 
--
106222
 
 
106223
 
ALTER TABLE ONLY addr
106224
 
    ADD CONSTRAINT addr_pkey PRIMARY KEY (addr_id);
106225
 
 
106226
 
 
106227
 
--
106228
 
--
106229
 
 
106230
 
ALTER TABLE ONLY alarm
106231
 
    ADD CONSTRAINT alarm_pkey PRIMARY KEY (alarm_id);
106232
 
 
106233
 
 
106234
 
--
106235
 
--
106236
 
 
106237
 
ALTER TABLE ONLY apaccnt
106238
 
    ADD CONSTRAINT apaccnt_pkey PRIMARY KEY (apaccnt_id);
106239
 
 
106240
 
 
106241
 
--
106242
 
--
106243
 
 
106244
 
ALTER TABLE ONLY apapply
106245
 
    ADD CONSTRAINT apapply_pkey PRIMARY KEY (apapply_id);
106246
 
 
106247
 
 
106248
 
--
106249
 
--
106250
 
 
106251
 
ALTER TABLE ONLY apcreditapply
106252
 
    ADD CONSTRAINT apcreditapply_pkey PRIMARY KEY (apcreditapply_id);
106253
 
 
106254
 
 
106255
 
--
106256
 
--
106257
 
 
106258
 
ALTER TABLE ONLY apopen
106259
 
    ADD CONSTRAINT apopen_pkey PRIMARY KEY (apopen_id);
106260
 
 
106261
 
 
106262
 
--
106263
 
--
106264
 
 
106265
 
ALTER TABLE ONLY apopentax
106266
 
    ADD CONSTRAINT apopentax_pkey PRIMARY KEY (taxhist_id);
106267
 
 
106268
 
 
106269
 
--
106270
 
--
106271
 
 
106272
 
ALTER TABLE ONLY apselect
106273
 
    ADD CONSTRAINT apselect_apselect_apopen_id_key UNIQUE (apselect_apopen_id);
106274
 
 
106275
 
 
106276
 
--
106277
 
--
106278
 
 
106279
 
ALTER TABLE ONLY apselect
106280
 
    ADD CONSTRAINT apselect_pkey PRIMARY KEY (apselect_id);
106281
 
 
106282
 
 
106283
 
--
106284
 
--
106285
 
 
106286
 
ALTER TABLE ONLY araccnt
106287
 
    ADD CONSTRAINT araccnt_pkey PRIMARY KEY (araccnt_id);
106288
 
 
106289
 
 
106290
 
--
106291
 
--
106292
 
 
106293
 
ALTER TABLE ONLY arapply
106294
 
    ADD CONSTRAINT arapply_pkey PRIMARY KEY (arapply_id);
106295
 
 
106296
 
 
106297
 
--
106298
 
--
106299
 
 
106300
 
ALTER TABLE ONLY arcreditapply
106301
 
    ADD CONSTRAINT arcreditapply_pkey PRIMARY KEY (arcreditapply_id);
106302
 
 
106303
 
 
106304
 
--
106305
 
--
106306
 
 
106307
 
ALTER TABLE ONLY aropen
106308
 
    ADD CONSTRAINT aropen_pkey PRIMARY KEY (aropen_id);
106309
 
 
106310
 
 
106311
 
--
106312
 
--
106313
 
 
106314
 
ALTER TABLE ONLY aropenalloc
106315
 
    ADD CONSTRAINT aropenalloc_pkey PRIMARY KEY (aropenalloc_aropen_id, aropenalloc_doctype, aropenalloc_doc_id);
106316
 
 
106317
 
 
106318
 
--
106319
 
--
106320
 
 
106321
 
ALTER TABLE ONLY aropentax
106322
 
    ADD CONSTRAINT aropentax_pkey PRIMARY KEY (taxhist_id);
106323
 
 
106324
 
 
106325
 
--
106326
 
--
106327
 
 
106328
 
ALTER TABLE ONLY asohist
106329
 
    ADD CONSTRAINT asohist_pkey PRIMARY KEY (asohist_id);
106330
 
 
106331
 
 
106332
 
--
106333
 
--
106334
 
 
106335
 
ALTER TABLE ONLY asohisttax
106336
 
    ADD CONSTRAINT asohisttax_pkey PRIMARY KEY (taxhist_id);
106337
 
 
106338
 
 
106339
 
--
106340
 
--
106341
 
 
106342
 
ALTER TABLE ONLY atlasmap
106343
 
    ADD CONSTRAINT atlasmap_atlasmap_name_key UNIQUE (atlasmap_name);
106344
 
 
106345
 
 
106346
 
--
106347
 
--
106348
 
 
106349
 
ALTER TABLE ONLY atlasmap
106350
 
    ADD CONSTRAINT atlasmap_pkey PRIMARY KEY (atlasmap_id);
106351
 
 
106352
 
 
106353
 
--
106354
 
--
106355
 
 
106356
 
ALTER TABLE ONLY bankaccnt
106357
 
    ADD CONSTRAINT bankaccnt_bankaccnt_name_key UNIQUE (bankaccnt_name);
106358
 
 
106359
 
 
106360
 
--
106361
 
--
106362
 
 
106363
 
ALTER TABLE ONLY bankaccnt
106364
 
    ADD CONSTRAINT bankaccnt_pkey PRIMARY KEY (bankaccnt_id);
106365
 
 
106366
 
 
106367
 
--
106368
 
--
106369
 
 
106370
 
ALTER TABLE ONLY bankadj
106371
 
    ADD CONSTRAINT bankadj_pkey PRIMARY KEY (bankadj_id);
106372
 
 
106373
 
 
106374
 
--
106375
 
--
106376
 
 
106377
 
ALTER TABLE ONLY bankadjtype
106378
 
    ADD CONSTRAINT bankadjtype_bankadjtype_name_key UNIQUE (bankadjtype_name);
106379
 
 
106380
 
 
106381
 
--
106382
 
--
106383
 
 
106384
 
ALTER TABLE ONLY bankadjtype
106385
 
    ADD CONSTRAINT bankadjtype_pkey PRIMARY KEY (bankadjtype_id);
106386
 
 
106387
 
 
106388
 
--
106389
 
--
106390
 
 
106391
 
ALTER TABLE ONLY bankrec
106392
 
    ADD CONSTRAINT bankrec_pkey PRIMARY KEY (bankrec_id);
106393
 
 
106394
 
 
106395
 
--
106396
 
--
106397
 
 
106398
 
ALTER TABLE ONLY bankrecimport
106399
 
    ADD CONSTRAINT bankrecimport_pkey PRIMARY KEY (bankrecimport_id);
106400
 
 
106401
 
 
106402
 
--
106403
 
--
106404
 
 
106405
 
ALTER TABLE ONLY bankrecitem
106406
 
    ADD CONSTRAINT bankrecitem_pkey PRIMARY KEY (bankrecitem_id);
106407
 
 
106408
 
 
106409
 
--
106410
 
--
106411
 
 
106412
 
ALTER TABLE ONLY bomhead
106413
 
    ADD CONSTRAINT bomhead_pkey PRIMARY KEY (bomhead_id);
106414
 
 
106415
 
 
106416
 
--
106417
 
--
106418
 
 
106419
 
ALTER TABLE ONLY bomitem
106420
 
    ADD CONSTRAINT bomitem_pkey PRIMARY KEY (bomitem_id);
106421
 
 
106422
 
 
106423
 
--
106424
 
--
106425
 
 
106426
 
ALTER TABLE ONLY bomitemcost
106427
 
    ADD CONSTRAINT bomitemcost_pkey PRIMARY KEY (bomitemcost_id);
106428
 
 
106429
 
 
106430
 
--
106431
 
--
106432
 
 
106433
 
ALTER TABLE ONLY bomitemsub
106434
 
    ADD CONSTRAINT bomitemsub_pkey PRIMARY KEY (bomitemsub_id);
106435
 
 
106436
 
 
106437
 
--
106438
 
--
106439
 
 
106440
 
ALTER TABLE ONLY bomwork
106441
 
    ADD CONSTRAINT bomwork_pkey PRIMARY KEY (bomwork_id);
106442
 
 
106443
 
 
106444
 
--
106445
 
--
106446
 
 
106447
 
ALTER TABLE ONLY budghead
106448
 
    ADD CONSTRAINT budghead_budghead_name_key UNIQUE (budghead_name);
106449
 
 
106450
 
 
106451
 
--
106452
 
--
106453
 
 
106454
 
ALTER TABLE ONLY budghead
106455
 
    ADD CONSTRAINT budghead_pkey PRIMARY KEY (budghead_id);
106456
 
 
106457
 
 
106458
 
--
106459
 
--
106460
 
 
106461
 
ALTER TABLE ONLY budgitem
106462
 
    ADD CONSTRAINT budgitem_pkey PRIMARY KEY (budgitem_id);
106463
 
 
106464
 
 
106465
 
--
106466
 
--
106467
 
 
106468
 
ALTER TABLE ONLY calhead
106469
 
    ADD CONSTRAINT calhead_pkey PRIMARY KEY (calhead_id);
106470
 
 
106471
 
 
106472
 
--
106473
 
--
106474
 
 
106475
 
ALTER TABLE ONLY cashrcpt
106476
 
    ADD CONSTRAINT cashrcpt_cashrcpt_number_key UNIQUE (cashrcpt_number);
106477
 
 
106478
 
 
106479
 
--
106480
 
--
106481
 
 
106482
 
ALTER TABLE ONLY cashrcpt
106483
 
    ADD CONSTRAINT cashrcpt_pkey PRIMARY KEY (cashrcpt_id);
106484
 
 
106485
 
 
106486
 
--
106487
 
--
106488
 
 
106489
 
ALTER TABLE ONLY cashrcptitem
106490
 
    ADD CONSTRAINT cashrcptitem_pkey PRIMARY KEY (cashrcptitem_id);
106491
 
 
106492
 
 
106493
 
--
106494
 
--
106495
 
 
106496
 
ALTER TABLE ONLY cashrcptmisc
106497
 
    ADD CONSTRAINT cashrcptmisc_pkey PRIMARY KEY (cashrcptmisc_id);
106498
 
 
106499
 
 
106500
 
--
106501
 
--
106502
 
 
106503
 
ALTER TABLE ONLY ccard
106504
 
    ADD CONSTRAINT ccard_pkey PRIMARY KEY (ccard_id);
106505
 
 
106506
 
 
106507
 
--
106508
 
--
106509
 
 
106510
 
ALTER TABLE ONLY ccardaud
106511
 
    ADD CONSTRAINT ccardaud_ccard_pkey PRIMARY KEY (ccardaud_id);
106512
 
 
106513
 
 
106514
 
--
106515
 
--
106516
 
 
106517
 
ALTER TABLE ONLY ccbank
106518
 
    ADD CONSTRAINT ccbank_ccbank_ccard_type_key UNIQUE (ccbank_ccard_type);
106519
 
 
106520
 
 
106521
 
--
106522
 
--
106523
 
 
106524
 
ALTER TABLE ONLY ccbank
106525
 
    ADD CONSTRAINT ccbank_pkey PRIMARY KEY (ccbank_id);
106526
 
 
106527
 
 
106528
 
--
106529
 
--
106530
 
 
106531
 
ALTER TABLE ONLY ccpay
106532
 
    ADD CONSTRAINT ccpay_pkey PRIMARY KEY (ccpay_id);
106533
 
 
106534
 
 
106535
 
--
106536
 
--
106537
 
 
106538
 
ALTER TABLE ONLY "char"
106539
 
    ADD CONSTRAINT char_char_name_key UNIQUE (char_name);
106540
 
 
106541
 
 
106542
 
--
106543
 
--
106544
 
 
106545
 
ALTER TABLE ONLY "char"
106546
 
    ADD CONSTRAINT char_pkey PRIMARY KEY (char_id);
106547
 
 
106548
 
 
106549
 
--
106550
 
--
106551
 
 
106552
 
ALTER TABLE ONLY charass
106553
 
    ADD CONSTRAINT charass_pkey PRIMARY KEY (charass_id);
106554
 
 
106555
 
 
106556
 
--
106557
 
--
106558
 
 
106559
 
ALTER TABLE ONLY charopt
106560
 
    ADD CONSTRAINT charopt_pkey PRIMARY KEY (charopt_id);
106561
 
 
106562
 
 
106563
 
--
106564
 
--
106565
 
 
106566
 
ALTER TABLE ONLY checkhead
106567
 
    ADD CONSTRAINT checkhead_pkey PRIMARY KEY (checkhead_id);
106568
 
 
106569
 
 
106570
 
--
106571
 
--
106572
 
 
106573
 
ALTER TABLE ONLY checkitem
106574
 
    ADD CONSTRAINT checkitem_pkey PRIMARY KEY (checkitem_id);
106575
 
 
106576
 
 
106577
 
--
106578
 
--
106579
 
 
106580
 
ALTER TABLE ONLY classcode
106581
 
    ADD CONSTRAINT classcode_classcode_code_key UNIQUE (classcode_code);
106582
 
 
106583
 
 
106584
 
--
106585
 
--
106586
 
 
106587
 
ALTER TABLE ONLY classcode
106588
 
    ADD CONSTRAINT classcode_pkey PRIMARY KEY (classcode_id);
106589
 
 
106590
 
 
106591
 
--
106592
 
--
106593
 
 
106594
 
ALTER TABLE ONLY cmd
106595
 
    ADD CONSTRAINT cmd_pkey PRIMARY KEY (cmd_id);
106596
 
 
106597
 
 
106598
 
--
106599
 
--
106600
 
 
106601
 
ALTER TABLE ONLY cmdarg
106602
 
    ADD CONSTRAINT cmdarg_pkey PRIMARY KEY (cmdarg_id);
106603
 
 
106604
 
 
106605
 
--
106606
 
--
106607
 
 
106608
 
ALTER TABLE ONLY cmhead
106609
 
    ADD CONSTRAINT cmhead_cmhead_number_key UNIQUE (cmhead_number);
106610
 
 
106611
 
 
106612
 
--
106613
 
--
106614
 
 
106615
 
ALTER TABLE ONLY cmhead
106616
 
    ADD CONSTRAINT cmhead_pkey PRIMARY KEY (cmhead_id);
106617
 
 
106618
 
 
106619
 
--
106620
 
--
106621
 
 
106622
 
ALTER TABLE ONLY cmheadtax
106623
 
    ADD CONSTRAINT cmheadtax_pkey PRIMARY KEY (taxhist_id);
106624
 
 
106625
 
 
106626
 
--
106627
 
--
106628
 
 
106629
 
ALTER TABLE ONLY cmitem
106630
 
    ADD CONSTRAINT cmitem_cmhead_id_linenumber_unique UNIQUE (cmitem_cmhead_id, cmitem_linenumber);
106631
 
 
106632
 
 
106633
 
--
106634
 
--
106635
 
 
106636
 
ALTER TABLE ONLY cmitem
106637
 
    ADD CONSTRAINT cmitem_pkey PRIMARY KEY (cmitem_id);
106638
 
 
106639
 
 
106640
 
--
106641
 
--
106642
 
 
106643
 
ALTER TABLE ONLY cmitemtax
106644
 
    ADD CONSTRAINT cmitemtax_pkey PRIMARY KEY (taxhist_id);
106645
 
 
106646
 
 
106647
 
--
106648
 
--
106649
 
 
106650
 
ALTER TABLE ONLY cmnttype
106651
 
    ADD CONSTRAINT cmnttype_cmnttype_name_key UNIQUE (cmnttype_name);
106652
 
 
106653
 
 
106654
 
--
106655
 
--
106656
 
 
106657
 
ALTER TABLE ONLY cmnttype
106658
 
    ADD CONSTRAINT cmnttype_pkey PRIMARY KEY (cmnttype_id);
106659
 
 
106660
 
 
106661
 
--
106662
 
--
106663
 
 
106664
 
ALTER TABLE ONLY cmnttypesource
106665
 
    ADD CONSTRAINT cmnttypesource_pkey PRIMARY KEY (cmnttypesource_id);
106666
 
 
106667
 
 
106668
 
--
106669
 
--
106670
 
 
106671
 
ALTER TABLE ONLY cntct
106672
 
    ADD CONSTRAINT cntct_cntct_number_key UNIQUE (cntct_number);
106673
 
 
106674
 
 
106675
 
--
106676
 
--
106677
 
 
106678
 
ALTER TABLE ONLY cntct
106679
 
    ADD CONSTRAINT cntct_pkey PRIMARY KEY (cntct_id);
106680
 
 
106681
 
 
106682
 
--
106683
 
--
106684
 
 
106685
 
ALTER TABLE ONLY cntctaddr
106686
 
    ADD CONSTRAINT cntctaddr_pkey PRIMARY KEY (cntctaddr_id);
106687
 
 
106688
 
 
106689
 
--
106690
 
--
106691
 
 
106692
 
ALTER TABLE ONLY cntctdata
106693
 
    ADD CONSTRAINT cntctdata_pkey PRIMARY KEY (cntctdata_id);
106694
 
 
106695
 
 
106696
 
--
106697
 
--
106698
 
 
106699
 
ALTER TABLE ONLY cntcteml
106700
 
    ADD CONSTRAINT cntcteml_pkey PRIMARY KEY (cntcteml_id);
106701
 
 
106702
 
 
106703
 
--
106704
 
--
106705
 
 
106706
 
ALTER TABLE ONLY cntctmrgd
106707
 
    ADD CONSTRAINT cntctmrgd_pkey PRIMARY KEY (cntctmrgd_cntct_id);
106708
 
 
106709
 
 
106710
 
--
106711
 
--
106712
 
 
106713
 
ALTER TABLE ONLY cntctsel
106714
 
    ADD CONSTRAINT cntctsel_pkey PRIMARY KEY (cntctsel_cntct_id);
106715
 
 
106716
 
 
106717
 
--
106718
 
--
106719
 
 
106720
 
ALTER TABLE ONLY cntslip
106721
 
    ADD CONSTRAINT cntslip_pkey PRIMARY KEY (cntslip_id);
106722
 
 
106723
 
 
106724
 
--
106725
 
--
106726
 
 
106727
 
ALTER TABLE ONLY cobill
106728
 
    ADD CONSTRAINT cobill_pkey PRIMARY KEY (cobill_id);
106729
 
 
106730
 
 
106731
 
--
106732
 
--
106733
 
 
106734
 
ALTER TABLE ONLY cobilltax
106735
 
    ADD CONSTRAINT cobilltax_pkey PRIMARY KEY (taxhist_id);
106736
 
 
106737
 
 
106738
 
--
106739
 
--
106740
 
 
106741
 
ALTER TABLE ONLY cobmisc
106742
 
    ADD CONSTRAINT cobmisc_pkey PRIMARY KEY (cobmisc_id);
106743
 
 
106744
 
 
106745
 
--
106746
 
--
106747
 
 
106748
 
ALTER TABLE ONLY cobmisctax
106749
 
    ADD CONSTRAINT cobmisctax_pkey PRIMARY KEY (taxhist_id);
106750
 
 
106751
 
 
106752
 
--
106753
 
--
106754
 
 
106755
 
ALTER TABLE ONLY cohead
106756
 
    ADD CONSTRAINT cohead_cohead_number_key UNIQUE (cohead_number);
106757
 
 
106758
 
 
106759
 
--
106760
 
--
106761
 
 
106762
 
ALTER TABLE ONLY cohead
106763
 
    ADD CONSTRAINT cohead_pkey PRIMARY KEY (cohead_id);
106764
 
 
106765
 
 
106766
 
--
106767
 
--
106768
 
 
106769
 
ALTER TABLE ONLY cohist
106770
 
    ADD CONSTRAINT cohist_pkey PRIMARY KEY (cohist_id);
106771
 
 
106772
 
 
106773
 
--
106774
 
--
106775
 
 
106776
 
ALTER TABLE ONLY cohisttax
106777
 
    ADD CONSTRAINT cohisttax_pkey PRIMARY KEY (taxhist_id);
106778
 
 
106779
 
 
106780
 
--
106781
 
--
106782
 
 
106783
 
ALTER TABLE ONLY coitem
106784
 
    ADD CONSTRAINT coitem_pkey PRIMARY KEY (coitem_id);
106785
 
 
106786
 
 
106787
 
--
106788
 
--
106789
 
 
106790
 
ALTER TABLE ONLY comment
106791
 
    ADD CONSTRAINT comment_pkey PRIMARY KEY (comment_id);
106792
 
 
106793
 
 
106794
 
--
106795
 
--
106796
 
 
106797
 
ALTER TABLE ONLY company
106798
 
    ADD CONSTRAINT company_company_number_key UNIQUE (company_number);
106799
 
 
106800
 
 
106801
 
--
106802
 
--
106803
 
 
106804
 
ALTER TABLE ONLY company
106805
 
    ADD CONSTRAINT company_pkey PRIMARY KEY (company_id);
106806
 
 
106807
 
 
106808
 
--
106809
 
--
106810
 
 
106811
 
ALTER TABLE ONLY contrct
106812
 
    ADD CONSTRAINT contrct_pkey PRIMARY KEY (contrct_id);
106813
 
 
106814
 
 
106815
 
--
106816
 
--
106817
 
 
106818
 
ALTER TABLE ONLY costcat
106819
 
    ADD CONSTRAINT costcat_costcat_code_key UNIQUE (costcat_code);
106820
 
 
106821
 
 
106822
 
--
106823
 
--
106824
 
 
106825
 
ALTER TABLE ONLY costcat
106826
 
    ADD CONSTRAINT costcat_pkey PRIMARY KEY (costcat_id);
106827
 
 
106828
 
 
106829
 
--
106830
 
--
106831
 
 
106832
 
ALTER TABLE ONLY costelem
106833
 
    ADD CONSTRAINT costelem_costelem_type_key UNIQUE (costelem_type);
106834
 
 
106835
 
 
106836
 
--
106837
 
--
106838
 
 
106839
 
ALTER TABLE ONLY costelem
106840
 
    ADD CONSTRAINT costelem_pkey PRIMARY KEY (costelem_id);
106841
 
 
106842
 
 
106843
 
--
106844
 
--
106845
 
 
106846
 
ALTER TABLE ONLY costhist
106847
 
    ADD CONSTRAINT costhist_pkey PRIMARY KEY (costhist_id);
106848
 
 
106849
 
 
106850
 
--
106851
 
--
106852
 
 
106853
 
ALTER TABLE ONLY costupdate
106854
 
    ADD CONSTRAINT costupdate_costupdate_item_id_key UNIQUE (costupdate_item_id);
106855
 
 
106856
 
 
106857
 
--
106858
 
--
106859
 
 
106860
 
ALTER TABLE ONLY country
106861
 
    ADD CONSTRAINT country_country_abbr_key UNIQUE (country_abbr);
106862
 
 
106863
 
 
106864
 
--
106865
 
--
106866
 
 
106867
 
ALTER TABLE ONLY country
106868
 
    ADD CONSTRAINT country_country_name_key UNIQUE (country_name);
106869
 
 
106870
 
 
106871
 
--
106872
 
--
106873
 
 
106874
 
ALTER TABLE ONLY country
106875
 
    ADD CONSTRAINT country_pkey PRIMARY KEY (country_id);
106876
 
 
106877
 
 
106878
 
--
106879
 
--
106880
 
 
106881
 
ALTER TABLE ONLY crmacct
106882
 
    ADD CONSTRAINT crmacct_crmacct_number_key UNIQUE (crmacct_number);
106883
 
 
106884
 
 
106885
 
--
106886
 
--
106887
 
 
106888
 
ALTER TABLE ONLY crmacct
106889
 
    ADD CONSTRAINT crmacct_pkey PRIMARY KEY (crmacct_id);
106890
 
 
106891
 
 
106892
 
--
106893
 
--
106894
 
 
106895
 
ALTER TABLE ONLY crmacctsel
106896
 
    ADD CONSTRAINT crmacctsel_pkey PRIMARY KEY (crmacctsel_src_crmacct_id);
106897
 
 
106898
 
 
106899
 
--
106900
 
--
106901
 
 
106902
 
ALTER TABLE ONLY curr_rate
106903
 
    ADD CONSTRAINT curr_rate_curr_id_key UNIQUE (curr_id, curr_effective);
106904
 
 
106905
 
 
106906
 
--
106907
 
--
106908
 
 
106909
 
ALTER TABLE ONLY curr_rate
106910
 
    ADD CONSTRAINT curr_rate_pkey PRIMARY KEY (curr_rate_id);
106911
 
 
106912
 
 
106913
 
--
106914
 
--
106915
 
 
106916
 
ALTER TABLE ONLY curr_symbol
106917
 
    ADD CONSTRAINT curr_symbol_curr_abbr_key UNIQUE (curr_abbr);
106918
 
 
106919
 
 
106920
 
--
106921
 
--
106922
 
 
106923
 
ALTER TABLE ONLY curr_symbol
106924
 
    ADD CONSTRAINT curr_symbol_curr_name_key UNIQUE (curr_name);
106925
 
 
106926
 
 
106927
 
--
106928
 
--
106929
 
 
106930
 
ALTER TABLE ONLY curr_symbol
106931
 
    ADD CONSTRAINT curr_symbol_pkey PRIMARY KEY (curr_id);
106932
 
 
106933
 
 
106934
 
--
106935
 
--
106936
 
 
106937
 
ALTER TABLE ONLY custinfo
106938
 
    ADD CONSTRAINT cust_pkey PRIMARY KEY (cust_id);
106939
 
 
106940
 
 
106941
 
--
106942
 
--
106943
 
 
106944
 
ALTER TABLE ONLY custform
106945
 
    ADD CONSTRAINT custform_pkey PRIMARY KEY (custform_id);
106946
 
 
106947
 
 
106948
 
--
106949
 
--
106950
 
 
106951
 
ALTER TABLE ONLY custgrp
106952
 
    ADD CONSTRAINT custgrp_pkey PRIMARY KEY (custgrp_id);
106953
 
 
106954
 
 
106955
 
--
106956
 
--
106957
 
 
106958
 
ALTER TABLE ONLY custgrpitem
106959
 
    ADD CONSTRAINT custgrpitem_pkey PRIMARY KEY (custgrpitem_id);
106960
 
 
106961
 
 
106962
 
--
106963
 
--
106964
 
 
106965
 
ALTER TABLE ONLY custinfo
106966
 
    ADD CONSTRAINT custinfo_cust_number_key UNIQUE (cust_number);
106967
 
 
106968
 
 
106969
 
--
106970
 
--
106971
 
 
106972
 
ALTER TABLE ONLY custtype
106973
 
    ADD CONSTRAINT custtype_custtype_code_key UNIQUE (custtype_code);
106974
 
 
106975
 
 
106976
 
--
106977
 
--
106978
 
 
106979
 
ALTER TABLE ONLY custtype
106980
 
    ADD CONSTRAINT custtype_pkey PRIMARY KEY (custtype_id);
106981
 
 
106982
 
 
106983
 
--
106984
 
--
106985
 
 
106986
 
ALTER TABLE ONLY dept
106987
 
    ADD CONSTRAINT dept_dept_number_key UNIQUE (dept_number);
106988
 
 
106989
 
 
106990
 
--
106991
 
--
106992
 
 
106993
 
ALTER TABLE ONLY dept
106994
 
    ADD CONSTRAINT dept_pkey PRIMARY KEY (dept_id);
106995
 
 
106996
 
 
106997
 
--
106998
 
--
106999
 
 
107000
 
ALTER TABLE ONLY destination
107001
 
    ADD CONSTRAINT destination_pkey PRIMARY KEY (destination_id);
107002
 
 
107003
 
 
107004
 
--
107005
 
--
107006
 
 
107007
 
ALTER TABLE ONLY docass
107008
 
    ADD CONSTRAINT docass_pkey PRIMARY KEY (docass_id);
107009
 
 
107010
 
 
107011
 
--
107012
 
--
107013
 
 
107014
 
ALTER TABLE ONLY emp
107015
 
    ADD CONSTRAINT emp_emp_code_key UNIQUE (emp_code);
107016
 
 
107017
 
 
107018
 
--
107019
 
--
107020
 
 
107021
 
ALTER TABLE ONLY emp
107022
 
    ADD CONSTRAINT emp_emp_number_key UNIQUE (emp_number);
107023
 
 
107024
 
 
107025
 
--
107026
 
--
107027
 
 
107028
 
ALTER TABLE ONLY emp
107029
 
    ADD CONSTRAINT emp_pkey PRIMARY KEY (emp_id);
107030
 
 
107031
 
 
107032
 
--
107033
 
--
107034
 
 
107035
 
ALTER TABLE ONLY empgrp
107036
 
    ADD CONSTRAINT empgrp_empgrp_name_key UNIQUE (empgrp_name);
107037
 
 
107038
 
 
107039
 
--
107040
 
--
107041
 
 
107042
 
ALTER TABLE ONLY empgrp
107043
 
    ADD CONSTRAINT empgrp_pkey PRIMARY KEY (empgrp_id);
107044
 
 
107045
 
 
107046
 
--
107047
 
--
107048
 
 
107049
 
ALTER TABLE ONLY empgrpitem
107050
 
    ADD CONSTRAINT empgrpitem_pkey PRIMARY KEY (empgrpitem_id);
107051
 
 
107052
 
 
107053
 
--
107054
 
--
107055
 
 
107056
 
ALTER TABLE ONLY evntlog
107057
 
    ADD CONSTRAINT evntlog_pkey PRIMARY KEY (evntlog_id);
107058
 
 
107059
 
 
107060
 
--
107061
 
--
107062
 
 
107063
 
ALTER TABLE ONLY evntnot
107064
 
    ADD CONSTRAINT evntnot_pkey PRIMARY KEY (evntnot_id);
107065
 
 
107066
 
 
107067
 
--
107068
 
--
107069
 
 
107070
 
ALTER TABLE ONLY evnttype
107071
 
    ADD CONSTRAINT evnttype_evnttype_name_key UNIQUE (evnttype_name);
107072
 
 
107073
 
 
107074
 
--
107075
 
--
107076
 
 
107077
 
ALTER TABLE ONLY evnttype
107078
 
    ADD CONSTRAINT evnttype_pkey PRIMARY KEY (evnttype_id);
107079
 
 
107080
 
 
107081
 
--
107082
 
--
107083
 
 
107084
 
ALTER TABLE ONLY expcat
107085
 
    ADD CONSTRAINT expcat_expcat_code_key UNIQUE (expcat_code);
107086
 
 
107087
 
 
107088
 
--
107089
 
--
107090
 
 
107091
 
ALTER TABLE ONLY expcat
107092
 
    ADD CONSTRAINT expcat_pkey PRIMARY KEY (expcat_id);
107093
 
 
107094
 
 
107095
 
--
107096
 
--
107097
 
 
107098
 
ALTER TABLE ONLY file
107099
 
    ADD CONSTRAINT file_pkey PRIMARY KEY (file_id);
107100
 
 
107101
 
 
107102
 
--
107103
 
--
107104
 
 
107105
 
ALTER TABLE ONLY filter
107106
 
    ADD CONSTRAINT filter_pkey PRIMARY KEY (filter_id);
107107
 
 
107108
 
 
107109
 
--
107110
 
--
107111
 
 
107112
 
ALTER TABLE ONLY fincharg
107113
 
    ADD CONSTRAINT fincharg_pkey PRIMARY KEY (fincharg_id);
107114
 
 
107115
 
 
107116
 
--
107117
 
--
107118
 
 
107119
 
ALTER TABLE ONLY flcol
107120
 
    ADD CONSTRAINT fkey_flcol_key PRIMARY KEY (flcol_id);
107121
 
 
107122
 
 
107123
 
--
107124
 
--
107125
 
 
107126
 
ALTER TABLE ONLY flgrp
107127
 
    ADD CONSTRAINT flgrp_pkey PRIMARY KEY (flgrp_id);
107128
 
 
107129
 
 
107130
 
--
107131
 
--
107132
 
 
107133
 
ALTER TABLE ONLY flhead
107134
 
    ADD CONSTRAINT flhead_flhead_name_key UNIQUE (flhead_name);
107135
 
 
107136
 
 
107137
 
--
107138
 
--
107139
 
 
107140
 
ALTER TABLE ONLY flhead
107141
 
    ADD CONSTRAINT flhead_pkey PRIMARY KEY (flhead_id);
107142
 
 
107143
 
 
107144
 
--
107145
 
--
107146
 
 
107147
 
ALTER TABLE ONLY flitem
107148
 
    ADD CONSTRAINT flitem_pkey PRIMARY KEY (flitem_id);
107149
 
 
107150
 
 
107151
 
--
107152
 
--
107153
 
 
107154
 
ALTER TABLE ONLY flnotes
107155
 
    ADD CONSTRAINT flnotes_flnotes_flhead_id_key UNIQUE (flnotes_flhead_id, flnotes_period_id);
107156
 
 
107157
 
 
107158
 
--
107159
 
--
107160
 
 
107161
 
ALTER TABLE ONLY flrpt
107162
 
    ADD CONSTRAINT flrpt_pkey PRIMARY KEY (flrpt_id);
107163
 
 
107164
 
 
107165
 
--
107166
 
--
107167
 
 
107168
 
ALTER TABLE ONLY flspec
107169
 
    ADD CONSTRAINT flspec_pkey PRIMARY KEY (flspec_id);
107170
 
 
107171
 
 
107172
 
--
107173
 
--
107174
 
 
107175
 
ALTER TABLE ONLY form
107176
 
    ADD CONSTRAINT form_form_name_key UNIQUE (form_name);
107177
 
 
107178
 
 
107179
 
--
107180
 
--
107181
 
 
107182
 
ALTER TABLE ONLY form
107183
 
    ADD CONSTRAINT form_pkey PRIMARY KEY (form_id);
107184
 
 
107185
 
 
107186
 
--
107187
 
--
107188
 
 
107189
 
ALTER TABLE ONLY freightclass
107190
 
    ADD CONSTRAINT freightclass_freightclass_code_key UNIQUE (freightclass_code);
107191
 
 
107192
 
 
107193
 
--
107194
 
--
107195
 
 
107196
 
ALTER TABLE ONLY freightclass
107197
 
    ADD CONSTRAINT freightclass_pkey PRIMARY KEY (freightclass_id);
107198
 
 
107199
 
 
107200
 
--
107201
 
--
107202
 
 
107203
 
ALTER TABLE ONLY glseries
107204
 
    ADD CONSTRAINT glseries_pkey PRIMARY KEY (glseries_id);
107205
 
 
107206
 
 
107207
 
--
107208
 
--
107209
 
 
107210
 
ALTER TABLE ONLY gltrans
107211
 
    ADD CONSTRAINT gltrans_pkey PRIMARY KEY (gltrans_id);
107212
 
 
107213
 
 
107214
 
--
107215
 
--
107216
 
 
107217
 
ALTER TABLE ONLY grp
107218
 
    ADD CONSTRAINT grp_grp_name_key UNIQUE (grp_name);
107219
 
 
107220
 
 
107221
 
--
107222
 
--
107223
 
 
107224
 
ALTER TABLE ONLY grp
107225
 
    ADD CONSTRAINT grp_pkey PRIMARY KEY (grp_id);
107226
 
 
107227
 
 
107228
 
--
107229
 
--
107230
 
 
107231
 
ALTER TABLE ONLY grppriv
107232
 
    ADD CONSTRAINT grppriv_pkey PRIMARY KEY (grppriv_id);
107233
 
 
107234
 
 
107235
 
--
107236
 
--
107237
 
 
107238
 
ALTER TABLE ONLY hnfc
107239
 
    ADD CONSTRAINT hnfc_hnfc_code_key UNIQUE (hnfc_code);
107240
 
 
107241
 
 
107242
 
--
107243
 
--
107244
 
 
107245
 
ALTER TABLE ONLY hnfc
107246
 
    ADD CONSTRAINT hnfc_pkey PRIMARY KEY (hnfc_id);
107247
 
 
107248
 
 
107249
 
--
107250
 
--
107251
 
 
107252
 
ALTER TABLE ONLY image
107253
 
    ADD CONSTRAINT image_pkey PRIMARY KEY (image_id);
107254
 
 
107255
 
 
107256
 
--
107257
 
--
107258
 
 
107259
 
ALTER TABLE ONLY imageass
107260
 
    ADD CONSTRAINT imageass_pkey PRIMARY KEY (imageass_id);
107261
 
 
107262
 
 
107263
 
--
107264
 
--
107265
 
 
107266
 
ALTER TABLE ONLY incdt
107267
 
    ADD CONSTRAINT incdt_incdt_number_key UNIQUE (incdt_number);
107268
 
 
107269
 
 
107270
 
--
107271
 
--
107272
 
 
107273
 
ALTER TABLE ONLY incdt
107274
 
    ADD CONSTRAINT incdt_pkey PRIMARY KEY (incdt_id);
107275
 
 
107276
 
 
107277
 
--
107278
 
--
107279
 
 
107280
 
ALTER TABLE ONLY incdtcat
107281
 
    ADD CONSTRAINT incdtcat_incdtcat_name_key UNIQUE (incdtcat_name);
107282
 
 
107283
 
 
107284
 
--
107285
 
--
107286
 
 
107287
 
ALTER TABLE ONLY incdtcat
107288
 
    ADD CONSTRAINT incdtcat_pkey PRIMARY KEY (incdtcat_id);
107289
 
 
107290
 
 
107291
 
--
107292
 
--
107293
 
 
107294
 
ALTER TABLE ONLY incdthist
107295
 
    ADD CONSTRAINT incdthist_pkey PRIMARY KEY (incdthist_id);
107296
 
 
107297
 
 
107298
 
--
107299
 
--
107300
 
 
107301
 
ALTER TABLE ONLY incdtpriority
107302
 
    ADD CONSTRAINT incdtpriority_incdtpriority_name_key UNIQUE (incdtpriority_name);
107303
 
 
107304
 
 
107305
 
--
107306
 
--
107307
 
 
107308
 
ALTER TABLE ONLY incdtpriority
107309
 
    ADD CONSTRAINT incdtpriority_pkey PRIMARY KEY (incdtpriority_id);
107310
 
 
107311
 
 
107312
 
--
107313
 
--
107314
 
 
107315
 
ALTER TABLE ONLY incdtresolution
107316
 
    ADD CONSTRAINT incdtresolution_incdtresolution_name_key UNIQUE (incdtresolution_name);
107317
 
 
107318
 
 
107319
 
--
107320
 
--
107321
 
 
107322
 
ALTER TABLE ONLY incdtresolution
107323
 
    ADD CONSTRAINT incdtresolution_pkey PRIMARY KEY (incdtresolution_id);
107324
 
 
107325
 
 
107326
 
--
107327
 
--
107328
 
 
107329
 
ALTER TABLE ONLY incdtseverity
107330
 
    ADD CONSTRAINT incdtseverity_incdtseverity_name_key UNIQUE (incdtseverity_name);
107331
 
 
107332
 
 
107333
 
--
107334
 
--
107335
 
 
107336
 
ALTER TABLE ONLY incdtseverity
107337
 
    ADD CONSTRAINT incdtseverity_pkey PRIMARY KEY (incdtseverity_id);
107338
 
 
107339
 
 
107340
 
--
107341
 
--
107342
 
 
107343
 
ALTER TABLE ONLY invbal
107344
 
    ADD CONSTRAINT invbal_pkey PRIMARY KEY (invbal_id);
107345
 
 
107346
 
 
107347
 
--
107348
 
--
107349
 
 
107350
 
ALTER TABLE ONLY invchead
107351
 
    ADD CONSTRAINT invchead_invcnumber_unique UNIQUE (invchead_invcnumber);
107352
 
 
107353
 
 
107354
 
--
107355
 
--
107356
 
 
107357
 
ALTER TABLE ONLY invchead
107358
 
    ADD CONSTRAINT invchead_pkey PRIMARY KEY (invchead_id);
107359
 
 
107360
 
 
107361
 
--
107362
 
--
107363
 
 
107364
 
ALTER TABLE ONLY invcheadtax
107365
 
    ADD CONSTRAINT invcheadtax_pkey PRIMARY KEY (taxhist_id);
107366
 
 
107367
 
 
107368
 
--
107369
 
--
107370
 
 
107371
 
ALTER TABLE ONLY invcitem
107372
 
    ADD CONSTRAINT invcitem_invchead_id_linenumber_unique UNIQUE (invcitem_invchead_id, invcitem_linenumber);
107373
 
 
107374
 
 
107375
 
--
107376
 
--
107377
 
 
107378
 
ALTER TABLE ONLY invcitem
107379
 
    ADD CONSTRAINT invcitem_pkey PRIMARY KEY (invcitem_id);
107380
 
 
107381
 
 
107382
 
--
107383
 
--
107384
 
 
107385
 
ALTER TABLE ONLY invcitemtax
107386
 
    ADD CONSTRAINT invcitemtax_pkey PRIMARY KEY (taxhist_id);
107387
 
 
107388
 
 
107389
 
--
107390
 
--
107391
 
 
107392
 
ALTER TABLE ONLY invcnt
107393
 
    ADD CONSTRAINT invcnt_pkey PRIMARY KEY (invcnt_id);
107394
 
 
107395
 
 
107396
 
--
107397
 
--
107398
 
 
107399
 
ALTER TABLE ONLY invdetail
107400
 
    ADD CONSTRAINT invdetail_pkey PRIMARY KEY (invdetail_id);
107401
 
 
107402
 
 
107403
 
--
107404
 
--
107405
 
 
107406
 
ALTER TABLE ONLY invhist
107407
 
    ADD CONSTRAINT invhist_pkey PRIMARY KEY (invhist_id);
107408
 
 
107409
 
 
107410
 
--
107411
 
--
107412
 
 
107413
 
ALTER TABLE ONLY invhistexpcat
107414
 
    ADD CONSTRAINT invhistexpcat_invhist_id_expcat_id UNIQUE (invhistexpcat_invhist_id, invhistexpcat_expcat_id);
107415
 
 
107416
 
 
107417
 
--
107418
 
--
107419
 
 
107420
 
ALTER TABLE ONLY invhistexpcat
107421
 
    ADD CONSTRAINT invhistexpcat_pkey PRIMARY KEY (invhistexpcat_id);
107422
 
 
107423
 
 
107424
 
--
107425
 
--
107426
 
 
107427
 
ALTER TABLE ONLY ipsass
107428
 
    ADD CONSTRAINT ipsass_ipsass_ipshead_id_key UNIQUE (ipsass_ipshead_id, ipsass_cust_id, ipsass_custtype_id, ipsass_custtype_pattern, ipsass_shipto_id, ipsass_shipto_pattern);
107429
 
 
107430
 
 
107431
 
--
107432
 
--
107433
 
 
107434
 
ALTER TABLE ONLY ipsass
107435
 
    ADD CONSTRAINT ipsass_pkey PRIMARY KEY (ipsass_id);
107436
 
 
107437
 
 
107438
 
--
107439
 
--
107440
 
 
107441
 
ALTER TABLE ONLY ipsfreight
107442
 
    ADD CONSTRAINT ipsfreight_pkey PRIMARY KEY (ipsfreight_id);
107443
 
 
107444
 
 
107445
 
--
107446
 
--
107447
 
 
107448
 
ALTER TABLE ONLY ipshead
107449
 
    ADD CONSTRAINT ipshead_ipshead_name_key UNIQUE (ipshead_name);
107450
 
 
107451
 
 
107452
 
--
107453
 
--
107454
 
 
107455
 
ALTER TABLE ONLY ipshead
107456
 
    ADD CONSTRAINT ipshead_pkey PRIMARY KEY (ipshead_id);
107457
 
 
107458
 
 
107459
 
--
107460
 
--
107461
 
 
107462
 
ALTER TABLE ONLY ipsiteminfo
107463
 
    ADD CONSTRAINT ipsitem_ipsitem_ipshead_id_key UNIQUE (ipsitem_ipshead_id, ipsitem_item_id, ipsitem_prodcat_id, ipsitem_qtybreak, ipsitem_qty_uom_id, ipsitem_price_uom_id);
107464
 
 
107465
 
 
107466
 
--
107467
 
--
107468
 
 
107469
 
ALTER TABLE ONLY ipsiteminfo
107470
 
    ADD CONSTRAINT ipsitem_pkey PRIMARY KEY (ipsitem_id);
107471
 
 
107472
 
 
107473
 
--
107474
 
--
107475
 
 
107476
 
ALTER TABLE ONLY ipsitemchar
107477
 
    ADD CONSTRAINT ipsitemchar_ipsitemchar_ipsitem_id_key UNIQUE (ipsitemchar_ipsitem_id, ipsitemchar_char_id, ipsitemchar_value);
107478
 
 
107479
 
 
107480
 
--
107481
 
--
107482
 
 
107483
 
ALTER TABLE ONLY ipsitemchar
107484
 
    ADD CONSTRAINT ipsitemchar_ipsitemchar_ipsitem_id_key1 UNIQUE (ipsitemchar_ipsitem_id, ipsitemchar_char_id, ipsitemchar_value);
107485
 
 
107486
 
 
107487
 
--
107488
 
--
107489
 
 
107490
 
ALTER TABLE ONLY ipsitemchar
107491
 
    ADD CONSTRAINT ipsitemchar_pkey PRIMARY KEY (ipsitemchar_id);
107492
 
 
107493
 
 
107494
 
--
107495
 
--
107496
 
 
107497
 
ALTER TABLE ONLY ipsprodcat_bak
107498
 
    ADD CONSTRAINT ipsprodcat_pkey PRIMARY KEY (ipsprodcat_id);
107499
 
 
107500
 
 
107501
 
--
107502
 
--
107503
 
 
107504
 
ALTER TABLE ONLY item
107505
 
    ADD CONSTRAINT item_item_number_key UNIQUE (item_number);
107506
 
 
107507
 
 
107508
 
--
107509
 
--
107510
 
 
107511
 
ALTER TABLE ONLY item
107512
 
    ADD CONSTRAINT item_pkey PRIMARY KEY (item_id);
107513
 
 
107514
 
 
107515
 
--
107516
 
--
107517
 
 
107518
 
ALTER TABLE ONLY itemalias
107519
 
    ADD CONSTRAINT itemalias_itemalias_item_id_key UNIQUE (itemalias_item_id, itemalias_number);
107520
 
 
107521
 
 
107522
 
--
107523
 
--
107524
 
 
107525
 
ALTER TABLE ONLY itemalias
107526
 
    ADD CONSTRAINT itemalias_pkey PRIMARY KEY (itemalias_id);
107527
 
 
107528
 
 
107529
 
--
107530
 
--
107531
 
 
107532
 
ALTER TABLE ONLY itemcost
107533
 
    ADD CONSTRAINT itemcost_pkey PRIMARY KEY (itemcost_id);
107534
 
 
107535
 
 
107536
 
--
107537
 
--
107538
 
 
107539
 
ALTER TABLE ONLY itemgrp
107540
 
    ADD CONSTRAINT itemgrp_itemgrp_name_key UNIQUE (itemgrp_name);
107541
 
 
107542
 
 
107543
 
--
107544
 
--
107545
 
 
107546
 
ALTER TABLE ONLY itemgrp
107547
 
    ADD CONSTRAINT itemgrp_pkey PRIMARY KEY (itemgrp_id);
107548
 
 
107549
 
 
107550
 
--
107551
 
--
107552
 
 
107553
 
ALTER TABLE ONLY itemgrpitem
107554
 
    ADD CONSTRAINT itemgrpitem_pkey PRIMARY KEY (itemgrpitem_id);
107555
 
 
107556
 
 
107557
 
--
107558
 
--
107559
 
 
107560
 
ALTER TABLE ONLY itemgrpitem
107561
 
    ADD CONSTRAINT itemgrpitem_unique_key UNIQUE (itemgrpitem_itemgrp_id, itemgrpitem_item_id, itemgrpitem_item_type);
107562
 
 
107563
 
 
107564
 
--
107565
 
--
107566
 
 
107567
 
ALTER TABLE ONLY itemloc
107568
 
    ADD CONSTRAINT itemloc_pkey PRIMARY KEY (itemloc_id);
107569
 
 
107570
 
 
107571
 
--
107572
 
--
107573
 
 
107574
 
ALTER TABLE ONLY itemlocdist
107575
 
    ADD CONSTRAINT itemlocdist_pkey PRIMARY KEY (itemlocdist_id);
107576
 
 
107577
 
 
107578
 
--
107579
 
--
107580
 
 
107581
 
ALTER TABLE ONLY itemlocpost
107582
 
    ADD CONSTRAINT itemlocpost_pkey PRIMARY KEY (itemlocpost_id);
107583
 
 
107584
 
 
107585
 
--
107586
 
--
107587
 
 
107588
 
ALTER TABLE ONLY itemsite
107589
 
    ADD CONSTRAINT itemsite_pkey PRIMARY KEY (itemsite_id);
107590
 
 
107591
 
 
107592
 
--
107593
 
--
107594
 
 
107595
 
ALTER TABLE ONLY itemsrc
107596
 
    ADD CONSTRAINT itemsrc_itemsrc_vend_id_key UNIQUE (itemsrc_vend_id, itemsrc_item_id, itemsrc_effective, itemsrc_expires, itemsrc_vend_item_number, itemsrc_manuf_name, itemsrc_manuf_item_number, itemsrc_contrct_id);
107597
 
 
107598
 
 
107599
 
--
107600
 
--
107601
 
 
107602
 
ALTER TABLE ONLY itemsrc
107603
 
    ADD CONSTRAINT itemsrc_pkey PRIMARY KEY (itemsrc_id);
107604
 
 
107605
 
 
107606
 
--
107607
 
--
107608
 
 
107609
 
ALTER TABLE ONLY itemsrcp
107610
 
    ADD CONSTRAINT itemsrcp_itemsrcp_itemsrc_id_key UNIQUE (itemsrcp_itemsrc_id, itemsrcp_warehous_id, itemsrcp_dropship, itemsrcp_qtybreak);
107611
 
 
107612
 
 
107613
 
--
107614
 
--
107615
 
 
107616
 
ALTER TABLE ONLY itemsrcp
107617
 
    ADD CONSTRAINT itemsrcp_pkey PRIMARY KEY (itemsrcp_id);
107618
 
 
107619
 
 
107620
 
--
107621
 
--
107622
 
 
107623
 
ALTER TABLE ONLY itemsub
107624
 
    ADD CONSTRAINT itemsub_itemsub_parent_item_id_key UNIQUE (itemsub_parent_item_id, itemsub_sub_item_id);
107625
 
 
107626
 
 
107627
 
--
107628
 
--
107629
 
 
107630
 
ALTER TABLE ONLY itemsub
107631
 
    ADD CONSTRAINT itemsub_pkey PRIMARY KEY (itemsub_id);
107632
 
 
107633
 
 
107634
 
--
107635
 
--
107636
 
 
107637
 
ALTER TABLE ONLY itemtax
107638
 
    ADD CONSTRAINT itemtax_pkey PRIMARY KEY (itemtax_id);
107639
 
 
107640
 
 
107641
 
--
107642
 
--
107643
 
 
107644
 
ALTER TABLE ONLY itemtrans
107645
 
    ADD CONSTRAINT itemtrans_itemtrans_source_item_id_key UNIQUE (itemtrans_source_item_id, itemtrans_target_item_id);
107646
 
 
107647
 
 
107648
 
--
107649
 
--
107650
 
 
107651
 
ALTER TABLE ONLY itemtrans
107652
 
    ADD CONSTRAINT itemtrans_pkey PRIMARY KEY (itemtrans_id);
107653
 
 
107654
 
 
107655
 
--
107656
 
--
107657
 
 
107658
 
ALTER TABLE ONLY itemuom
107659
 
    ADD CONSTRAINT itemuom_pkey PRIMARY KEY (itemuom_id);
107660
 
 
107661
 
 
107662
 
--
107663
 
--
107664
 
 
107665
 
ALTER TABLE ONLY itemuomconv
107666
 
    ADD CONSTRAINT itemuomconv_pkey PRIMARY KEY (itemuomconv_id);
107667
 
 
107668
 
 
107669
 
--
107670
 
--
107671
 
 
107672
 
ALTER TABLE ONLY jrnluse
107673
 
    ADD CONSTRAINT jrnluse_pkey PRIMARY KEY (jrnluse_id);
107674
 
 
107675
 
 
107676
 
--
107677
 
--
107678
 
 
107679
 
ALTER TABLE ONLY labeldef
107680
 
    ADD CONSTRAINT labeldef_pkey PRIMARY KEY (labeldef_id);
107681
 
 
107682
 
 
107683
 
--
107684
 
--
107685
 
 
107686
 
ALTER TABLE ONLY labelform
107687
 
    ADD CONSTRAINT labelform_labelform_name_key UNIQUE (labelform_name);
107688
 
 
107689
 
 
107690
 
--
107691
 
--
107692
 
 
107693
 
ALTER TABLE ONLY labelform
107694
 
    ADD CONSTRAINT labelform_pkey PRIMARY KEY (labelform_id);
107695
 
 
107696
 
 
107697
 
--
107698
 
--
107699
 
 
107700
 
ALTER TABLE ONLY lang
107701
 
    ADD CONSTRAINT lang_pkey PRIMARY KEY (lang_id);
107702
 
 
107703
 
 
107704
 
--
107705
 
--
107706
 
 
107707
 
ALTER TABLE ONLY locale
107708
 
    ADD CONSTRAINT locale_locale_code_key UNIQUE (locale_code);
107709
 
 
107710
 
 
107711
 
--
107712
 
--
107713
 
 
107714
 
ALTER TABLE ONLY locale
107715
 
    ADD CONSTRAINT locale_pkey PRIMARY KEY (locale_id);
107716
 
 
107717
 
 
107718
 
--
107719
 
--
107720
 
 
107721
 
ALTER TABLE ONLY location
107722
 
    ADD CONSTRAINT location_pkey PRIMARY KEY (location_id);
107723
 
 
107724
 
 
107725
 
--
107726
 
--
107727
 
 
107728
 
ALTER TABLE ONLY locitem
107729
 
    ADD CONSTRAINT locitem_pkey PRIMARY KEY (locitem_id);
107730
 
 
107731
 
 
107732
 
--
107733
 
--
107734
 
 
107735
 
ALTER TABLE ONLY metasql
107736
 
    ADD CONSTRAINT metasql_metasql_group_name_grade_key UNIQUE (metasql_group, metasql_name, metasql_grade);
107737
 
 
107738
 
 
107739
 
--
107740
 
--
107741
 
 
107742
 
ALTER TABLE ONLY metasql
107743
 
    ADD CONSTRAINT metasql_pkey PRIMARY KEY (metasql_id);
107744
 
 
107745
 
 
107746
 
--
107747
 
--
107748
 
 
107749
 
ALTER TABLE ONLY metric
107750
 
    ADD CONSTRAINT metric_metric_name_key UNIQUE (metric_name);
107751
 
 
107752
 
 
107753
 
--
107754
 
--
107755
 
 
107756
 
ALTER TABLE ONLY metric
107757
 
    ADD CONSTRAINT metric_pkey PRIMARY KEY (metric_id);
107758
 
 
107759
 
 
107760
 
--
107761
 
--
107762
 
 
107763
 
ALTER TABLE ONLY metricenc
107764
 
    ADD CONSTRAINT metricenc_metricenc_name_key UNIQUE (metricenc_name);
107765
 
 
107766
 
 
107767
 
--
107768
 
--
107769
 
 
107770
 
ALTER TABLE ONLY metricenc
107771
 
    ADD CONSTRAINT metricenc_pkey PRIMARY KEY (metricenc_id);
107772
 
 
107773
 
 
107774
 
--
107775
 
--
107776
 
 
107777
 
ALTER TABLE ONLY mrghist
107778
 
    ADD CONSTRAINT mrghist_pkey PRIMARY KEY (mrghist_cntct_id, mrghist_table, mrghist_pkey_col, mrghist_pkey_id, mrghist_cntct_col);
107779
 
 
107780
 
 
107781
 
--
107782
 
--
107783
 
 
107784
 
ALTER TABLE ONLY mrgundo
107785
 
    ADD CONSTRAINT mrgundo_mrgundo_schema_key UNIQUE (mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col);
107786
 
 
107787
 
 
107788
 
--
107789
 
--
107790
 
 
107791
 
ALTER TABLE ONLY msg
107792
 
    ADD CONSTRAINT msg_pkey PRIMARY KEY (msg_id);
107793
 
 
107794
 
 
107795
 
--
107796
 
--
107797
 
 
107798
 
ALTER TABLE ONLY msguser
107799
 
    ADD CONSTRAINT msguser_pkey PRIMARY KEY (msguser_id);
107800
 
 
107801
 
 
107802
 
--
107803
 
--
107804
 
 
107805
 
ALTER TABLE ONLY obsolete_tax
107806
 
    ADD CONSTRAINT obsolete_tax_pkey PRIMARY KEY (tax_id);
107807
 
 
107808
 
 
107809
 
--
107810
 
--
107811
 
 
107812
 
ALTER TABLE ONLY ophead
107813
 
    ADD CONSTRAINT ophead_ophead_number_key UNIQUE (ophead_number);
107814
 
 
107815
 
 
107816
 
--
107817
 
--
107818
 
 
107819
 
ALTER TABLE ONLY ophead
107820
 
    ADD CONSTRAINT ophead_pkey PRIMARY KEY (ophead_id);
107821
 
 
107822
 
 
107823
 
--
107824
 
--
107825
 
 
107826
 
ALTER TABLE ONLY opsource
107827
 
    ADD CONSTRAINT opsource_opsource_name_key UNIQUE (opsource_name);
107828
 
 
107829
 
 
107830
 
--
107831
 
--
107832
 
 
107833
 
ALTER TABLE ONLY opsource
107834
 
    ADD CONSTRAINT opsource_pkey PRIMARY KEY (opsource_id);
107835
 
 
107836
 
 
107837
 
--
107838
 
--
107839
 
 
107840
 
ALTER TABLE ONLY opstage
107841
 
    ADD CONSTRAINT opstage_opstage_name_key UNIQUE (opstage_name);
107842
 
 
107843
 
 
107844
 
--
107845
 
--
107846
 
 
107847
 
ALTER TABLE ONLY opstage
107848
 
    ADD CONSTRAINT opstage_pkey PRIMARY KEY (opstage_id);
107849
 
 
107850
 
 
107851
 
--
107852
 
--
107853
 
 
107854
 
ALTER TABLE ONLY optype
107855
 
    ADD CONSTRAINT optype_optype_name_key UNIQUE (optype_name);
107856
 
 
107857
 
 
107858
 
--
107859
 
--
107860
 
 
107861
 
ALTER TABLE ONLY optype
107862
 
    ADD CONSTRAINT optype_pkey PRIMARY KEY (optype_id);
107863
 
 
107864
 
 
107865
 
--
107866
 
--
107867
 
 
107868
 
ALTER TABLE ONLY orderseq
107869
 
    ADD CONSTRAINT orderseq_orderseq_name_key UNIQUE (orderseq_name);
107870
 
 
107871
 
 
107872
 
--
107873
 
--
107874
 
 
107875
 
ALTER TABLE ONLY orderseq
107876
 
    ADD CONSTRAINT orderseq_pkey PRIMARY KEY (orderseq_id);
107877
 
 
107878
 
 
107879
 
--
107880
 
--
107881
 
 
107882
 
ALTER TABLE ONLY pack
107883
 
    ADD CONSTRAINT pack_pkey PRIMARY KEY (pack_id);
107884
 
 
107885
 
 
107886
 
--
107887
 
--
107888
 
 
107889
 
ALTER TABLE ONLY payaropen
107890
 
    ADD CONSTRAINT payaropen_pkey PRIMARY KEY (payaropen_ccpay_id, payaropen_aropen_id);
107891
 
 
107892
 
 
107893
 
--
107894
 
--
107895
 
 
107896
 
ALTER TABLE ONLY payco
107897
 
    ADD CONSTRAINT payco_pkey PRIMARY KEY (payco_id);
107898
 
 
107899
 
 
107900
 
--
107901
 
--
107902
 
 
107903
 
ALTER TABLE ONLY payco
107904
 
    ADD CONSTRAINT payco_unique_ccpay_id_cohead_id UNIQUE (payco_ccpay_id, payco_cohead_id);
107905
 
 
107906
 
 
107907
 
--
107908
 
--
107909
 
 
107910
 
ALTER TABLE ONLY period
107911
 
    ADD CONSTRAINT period_pkey PRIMARY KEY (period_id);
107912
 
 
107913
 
 
107914
 
--
107915
 
--
107916
 
 
107917
 
ALTER TABLE ONLY prjtype
107918
 
    ADD CONSTRAINT pk_prjtype PRIMARY KEY (prjtype_id);
107919
 
 
107920
 
 
107921
 
--
107922
 
--
107923
 
 
107924
 
ALTER TABLE ONLY pkgdep
107925
 
    ADD CONSTRAINT pkgdep_pkey PRIMARY KEY (pkgdep_id);
107926
 
 
107927
 
 
107928
 
--
107929
 
--
107930
 
 
107931
 
ALTER TABLE ONLY pkghead
107932
 
    ADD CONSTRAINT pkghead_pkey PRIMARY KEY (pkghead_id);
107933
 
 
107934
 
 
107935
 
--
107936
 
--
107937
 
 
107938
 
ALTER TABLE ONLY pkgitem
107939
 
    ADD CONSTRAINT pkgitem_pkey PRIMARY KEY (pkgitem_id);
107940
 
 
107941
 
 
107942
 
--
107943
 
--
107944
 
 
107945
 
ALTER TABLE ONLY pkgitem
107946
 
    ADD CONSTRAINT pkgitem_pkgitem_pkghead_id_key UNIQUE (pkgitem_pkghead_id, pkgitem_type, pkgitem_name);
107947
 
 
107948
 
 
107949
 
--
107950
 
--
107951
 
 
107952
 
ALTER TABLE ONLY pkgitem
107953
 
    ADD CONSTRAINT pkgitem_pkgitem_pkghead_id_key1 UNIQUE (pkgitem_pkghead_id, pkgitem_type, pkgitem_item_id);
107954
 
 
107955
 
 
107956
 
--
107957
 
--
107958
 
 
107959
 
ALTER TABLE ONLY plancode
107960
 
    ADD CONSTRAINT plancode_pkey PRIMARY KEY (plancode_id);
107961
 
 
107962
 
 
107963
 
--
107964
 
--
107965
 
 
107966
 
ALTER TABLE ONLY plancode
107967
 
    ADD CONSTRAINT plancode_plancode_code_key UNIQUE (plancode_code);
107968
 
 
107969
 
 
107970
 
--
107971
 
--
107972
 
 
107973
 
ALTER TABLE ONLY pohead
107974
 
    ADD CONSTRAINT pohead_pkey PRIMARY KEY (pohead_id);
107975
 
 
107976
 
 
107977
 
--
107978
 
--
107979
 
 
107980
 
ALTER TABLE ONLY pohead
107981
 
    ADD CONSTRAINT pohead_pohead_number_key UNIQUE (pohead_number);
107982
 
 
107983
 
 
107984
 
--
107985
 
--
107986
 
 
107987
 
ALTER TABLE ONLY poitem
107988
 
    ADD CONSTRAINT poitem_pkey PRIMARY KEY (poitem_id);
107989
 
 
107990
 
 
107991
 
--
107992
 
--
107993
 
 
107994
 
ALTER TABLE ONLY poitem
107995
 
    ADD CONSTRAINT poitem_poitem_pohead_id_key UNIQUE (poitem_pohead_id, poitem_linenumber);
107996
 
 
107997
 
 
107998
 
--
107999
 
--
108000
 
 
108001
 
ALTER TABLE ONLY poreject
108002
 
    ADD CONSTRAINT poreject_pkey PRIMARY KEY (poreject_id);
108003
 
 
108004
 
 
108005
 
--
108006
 
--
108007
 
 
108008
 
ALTER TABLE ONLY potype
108009
 
    ADD CONSTRAINT potype_pkey PRIMARY KEY (potype_id);
108010
 
 
108011
 
 
108012
 
--
108013
 
--
108014
 
 
108015
 
ALTER TABLE ONLY pr
108016
 
    ADD CONSTRAINT pr_pkey PRIMARY KEY (pr_id);
108017
 
 
108018
 
 
108019
 
--
108020
 
--
108021
 
 
108022
 
ALTER TABLE ONLY prftcntr
108023
 
    ADD CONSTRAINT prftcntr_pkey PRIMARY KEY (prftcntr_id);
108024
 
 
108025
 
 
108026
 
--
108027
 
--
108028
 
 
108029
 
ALTER TABLE ONLY prftcntr
108030
 
    ADD CONSTRAINT prftcntr_prftcntr_number_key UNIQUE (prftcntr_number);
108031
 
 
108032
 
 
108033
 
--
108034
 
--
108035
 
 
108036
 
ALTER TABLE ONLY priv
108037
 
    ADD CONSTRAINT priv_pkey PRIMARY KEY (priv_id);
108038
 
 
108039
 
 
108040
 
--
108041
 
--
108042
 
 
108043
 
ALTER TABLE ONLY prj
108044
 
    ADD CONSTRAINT prj_pkey PRIMARY KEY (prj_id);
108045
 
 
108046
 
 
108047
 
--
108048
 
--
108049
 
 
108050
 
ALTER TABLE ONLY prj
108051
 
    ADD CONSTRAINT prj_prj_number_key UNIQUE (prj_number);
108052
 
 
108053
 
 
108054
 
--
108055
 
--
108056
 
 
108057
 
ALTER TABLE ONLY prjtask
108058
 
    ADD CONSTRAINT prjtask_pkey PRIMARY KEY (prjtask_id);
108059
 
 
108060
 
 
108061
 
--
108062
 
--
108063
 
 
108064
 
ALTER TABLE ONLY prjtask
108065
 
    ADD CONSTRAINT prjtask_prjtask_prj_id_key UNIQUE (prjtask_prj_id, prjtask_number);
108066
 
 
108067
 
 
108068
 
--
108069
 
--
108070
 
 
108071
 
ALTER TABLE ONLY prjtaskuser
108072
 
    ADD CONSTRAINT prjtaskuser_pkey PRIMARY KEY (prjtaskuser_id);
108073
 
 
108074
 
 
108075
 
--
108076
 
--
108077
 
 
108078
 
ALTER TABLE ONLY prodcat
108079
 
    ADD CONSTRAINT prodcat_pkey PRIMARY KEY (prodcat_id);
108080
 
 
108081
 
 
108082
 
--
108083
 
--
108084
 
 
108085
 
ALTER TABLE ONLY prodcat
108086
 
    ADD CONSTRAINT prodcat_prodcat_code_key UNIQUE (prodcat_code);
108087
 
 
108088
 
 
108089
 
--
108090
 
--
108091
 
 
108092
 
ALTER TABLE ONLY prospect
108093
 
    ADD CONSTRAINT prospect_pkey PRIMARY KEY (prospect_id);
108094
 
 
108095
 
 
108096
 
--
108097
 
--
108098
 
 
108099
 
ALTER TABLE ONLY prospect
108100
 
    ADD CONSTRAINT prospect_prospect_number_key UNIQUE (prospect_number);
108101
 
 
108102
 
 
108103
 
--
108104
 
--
108105
 
 
108106
 
ALTER TABLE ONLY qryhead
108107
 
    ADD CONSTRAINT qryhead_pkey PRIMARY KEY (qryhead_id);
108108
 
 
108109
 
 
108110
 
--
108111
 
--
108112
 
 
108113
 
ALTER TABLE ONLY qryhead
108114
 
    ADD CONSTRAINT qryhead_qryhead_name_key UNIQUE (qryhead_name);
108115
 
 
108116
 
 
108117
 
--
108118
 
--
108119
 
 
108120
 
ALTER TABLE ONLY qryitem
108121
 
    ADD CONSTRAINT qryitem_qryitem_qryhead_id_key UNIQUE (qryitem_qryhead_id, qryitem_name);
108122
 
 
108123
 
 
108124
 
--
108125
 
--
108126
 
 
108127
 
ALTER TABLE ONLY qryitem
108128
 
    ADD CONSTRAINT qryitem_qryitem_qryhead_id_key1 UNIQUE (qryitem_qryhead_id, qryitem_order);
108129
 
 
108130
 
 
108131
 
--
108132
 
--
108133
 
 
108134
 
ALTER TABLE ONLY quhead
108135
 
    ADD CONSTRAINT quhead_pkey PRIMARY KEY (quhead_id);
108136
 
 
108137
 
 
108138
 
--
108139
 
--
108140
 
 
108141
 
ALTER TABLE ONLY quhead
108142
 
    ADD CONSTRAINT quhead_quhead_number_key UNIQUE (quhead_number);
108143
 
 
108144
 
 
108145
 
--
108146
 
--
108147
 
 
108148
 
ALTER TABLE ONLY quitem
108149
 
    ADD CONSTRAINT quitem_pkey PRIMARY KEY (quitem_id);
108150
 
 
108151
 
 
108152
 
--
108153
 
--
108154
 
 
108155
 
ALTER TABLE ONLY rcalitem
108156
 
    ADD CONSTRAINT rcalitem_pkey PRIMARY KEY (rcalitem_id);
108157
 
 
108158
 
 
108159
 
--
108160
 
--
108161
 
 
108162
 
ALTER TABLE ONLY recur
108163
 
    ADD CONSTRAINT recur_pkey PRIMARY KEY (recur_id);
108164
 
 
108165
 
 
108166
 
--
108167
 
--
108168
 
 
108169
 
ALTER TABLE ONLY recur
108170
 
    ADD CONSTRAINT recur_recur_parent_id_key UNIQUE (recur_parent_id, recur_parent_type);
108171
 
 
108172
 
 
108173
 
--
108174
 
--
108175
 
 
108176
 
ALTER TABLE ONLY recurtype
108177
 
    ADD CONSTRAINT recurtype_pkey PRIMARY KEY (recurtype_id);
108178
 
 
108179
 
 
108180
 
--
108181
 
--
108182
 
 
108183
 
ALTER TABLE ONLY recurtype
108184
 
    ADD CONSTRAINT recurtype_recurtype_type_key UNIQUE (recurtype_type);
108185
 
 
108186
 
 
108187
 
--
108188
 
--
108189
 
 
108190
 
ALTER TABLE ONLY recv
108191
 
    ADD CONSTRAINT recv_pkey PRIMARY KEY (recv_id);
108192
 
 
108193
 
 
108194
 
--
108195
 
--
108196
 
 
108197
 
ALTER TABLE ONLY report
108198
 
    ADD CONSTRAINT report_pkey PRIMARY KEY (report_id);
108199
 
 
108200
 
 
108201
 
--
108202
 
--
108203
 
 
108204
 
ALTER TABLE ONLY rjctcode
108205
 
    ADD CONSTRAINT rjctcode_pkey PRIMARY KEY (rjctcode_id);
108206
 
 
108207
 
 
108208
 
--
108209
 
--
108210
 
 
108211
 
ALTER TABLE ONLY rjctcode
108212
 
    ADD CONSTRAINT rjctcode_rjctcode_code_key UNIQUE (rjctcode_code);
108213
 
 
108214
 
 
108215
 
--
108216
 
--
108217
 
 
108218
 
ALTER TABLE ONLY rsncode
108219
 
    ADD CONSTRAINT rsncode_pkey PRIMARY KEY (rsncode_id);
108220
 
 
108221
 
 
108222
 
--
108223
 
--
108224
 
 
108225
 
ALTER TABLE ONLY rsncode
108226
 
    ADD CONSTRAINT rsncode_rsncode_code_key UNIQUE (rsncode_code);
108227
 
 
108228
 
 
108229
 
--
108230
 
--
108231
 
 
108232
 
ALTER TABLE ONLY sale
108233
 
    ADD CONSTRAINT sale_pkey PRIMARY KEY (sale_id);
108234
 
 
108235
 
 
108236
 
--
108237
 
--
108238
 
 
108239
 
ALTER TABLE ONLY sale
108240
 
    ADD CONSTRAINT sale_sale_name_key UNIQUE (sale_name);
108241
 
 
108242
 
 
108243
 
--
108244
 
--
108245
 
 
108246
 
ALTER TABLE ONLY salesaccnt
108247
 
    ADD CONSTRAINT salesaccnt_pkey PRIMARY KEY (salesaccnt_id);
108248
 
 
108249
 
 
108250
 
--
108251
 
--
108252
 
 
108253
 
ALTER TABLE ONLY salescat
108254
 
    ADD CONSTRAINT salescat_pkey PRIMARY KEY (salescat_id);
108255
 
 
108256
 
 
108257
 
--
108258
 
--
108259
 
 
108260
 
ALTER TABLE ONLY salescat
108261
 
    ADD CONSTRAINT salescat_salescat_name_key UNIQUE (salescat_name);
108262
 
 
108263
 
 
108264
 
--
108265
 
--
108266
 
 
108267
 
ALTER TABLE ONLY salesrep
108268
 
    ADD CONSTRAINT salesrep_pkey PRIMARY KEY (salesrep_id);
108269
 
 
108270
 
 
108271
 
--
108272
 
--
108273
 
 
108274
 
ALTER TABLE ONLY salesrep
108275
 
    ADD CONSTRAINT salesrep_salesrep_number_key UNIQUE (salesrep_number);
108276
 
 
108277
 
 
108278
 
--
108279
 
--
108280
 
 
108281
 
ALTER TABLE ONLY saletype
108282
 
    ADD CONSTRAINT saletype_pkey PRIMARY KEY (saletype_id);
108283
 
 
108284
 
 
108285
 
--
108286
 
--
108287
 
 
108288
 
ALTER TABLE ONLY schemaord
108289
 
    ADD CONSTRAINT schemaord_pkey PRIMARY KEY (schemaord_id);
108290
 
 
108291
 
 
108292
 
--
108293
 
--
108294
 
 
108295
 
ALTER TABLE ONLY schemaord
108296
 
    ADD CONSTRAINT schemaord_schemaord_name_key UNIQUE (schemaord_name);
108297
 
 
108298
 
 
108299
 
--
108300
 
--
108301
 
 
108302
 
ALTER TABLE ONLY schemaord
108303
 
    ADD CONSTRAINT schemaord_schemaord_order_key UNIQUE (schemaord_order);
108304
 
 
108305
 
 
108306
 
--
108307
 
--
108308
 
 
108309
 
ALTER TABLE ONLY script
108310
 
    ADD CONSTRAINT script_pkey PRIMARY KEY (script_id);
108311
 
 
108312
 
 
108313
 
--
108314
 
--
108315
 
 
108316
 
ALTER TABLE ONLY shift
108317
 
    ADD CONSTRAINT shift_pkey PRIMARY KEY (shift_id);
108318
 
 
108319
 
 
108320
 
--
108321
 
--
108322
 
 
108323
 
ALTER TABLE ONLY shipchrg
108324
 
    ADD CONSTRAINT shipchrg_pkey PRIMARY KEY (shipchrg_id);
108325
 
 
108326
 
 
108327
 
--
108328
 
--
108329
 
 
108330
 
ALTER TABLE ONLY shipdata
108331
 
    ADD CONSTRAINT shipdata_pkey PRIMARY KEY (shipdata_cohead_number, shipdata_cosmisc_tracknum, shipdata_cosmisc_packnum_tracknum, shipdata_void_ind);
108332
 
 
108333
 
 
108334
 
--
108335
 
--
108336
 
 
108337
 
ALTER TABLE ONLY shipdatasum
108338
 
    ADD CONSTRAINT shipdatasum_pkey PRIMARY KEY (shipdatasum_cohead_number, shipdatasum_cosmisc_tracknum, shipdatasum_cosmisc_packnum_tracknum);
108339
 
 
108340
 
 
108341
 
--
108342
 
--
108343
 
 
108344
 
ALTER TABLE ONLY shipform
108345
 
    ADD CONSTRAINT shipform_pkey PRIMARY KEY (shipform_id);
108346
 
 
108347
 
 
108348
 
--
108349
 
--
108350
 
 
108351
 
ALTER TABLE ONLY shipform
108352
 
    ADD CONSTRAINT shipform_shipform_name_key UNIQUE (shipform_name);
108353
 
 
108354
 
 
108355
 
--
108356
 
--
108357
 
 
108358
 
ALTER TABLE ONLY shiphead
108359
 
    ADD CONSTRAINT shiphead_pkey PRIMARY KEY (shiphead_id);
108360
 
 
108361
 
 
108362
 
--
108363
 
--
108364
 
 
108365
 
ALTER TABLE ONLY shiphead
108366
 
    ADD CONSTRAINT shiphead_shiphead_number_key UNIQUE (shiphead_number);
108367
 
 
108368
 
 
108369
 
--
108370
 
--
108371
 
 
108372
 
ALTER TABLE ONLY shipitem
108373
 
    ADD CONSTRAINT shipitem_pkey PRIMARY KEY (shipitem_id);
108374
 
 
108375
 
 
108376
 
--
108377
 
--
108378
 
 
108379
 
ALTER TABLE ONLY shiptoinfo
108380
 
    ADD CONSTRAINT shipto_num_cust_unique UNIQUE (shipto_cust_id, shipto_num);
108381
 
 
108382
 
 
108383
 
--
108384
 
--
108385
 
 
108386
 
ALTER TABLE ONLY shiptoinfo
108387
 
    ADD CONSTRAINT shipto_pkey PRIMARY KEY (shipto_id);
108388
 
 
108389
 
 
108390
 
--
108391
 
--
108392
 
 
108393
 
ALTER TABLE ONLY shipvia
108394
 
    ADD CONSTRAINT shipvia_pkey PRIMARY KEY (shipvia_id);
108395
 
 
108396
 
 
108397
 
--
108398
 
--
108399
 
 
108400
 
ALTER TABLE ONLY shipvia
108401
 
    ADD CONSTRAINT shipvia_shipvia_code_key UNIQUE (shipvia_code);
108402
 
 
108403
 
 
108404
 
--
108405
 
--
108406
 
 
108407
 
ALTER TABLE ONLY shipzone
108408
 
    ADD CONSTRAINT shipzone_pkey PRIMARY KEY (shipzone_id);
108409
 
 
108410
 
 
108411
 
--
108412
 
--
108413
 
 
108414
 
ALTER TABLE ONLY shipzone
108415
 
    ADD CONSTRAINT shipzone_shipzone_name_key UNIQUE (shipzone_name);
108416
 
 
108417
 
 
108418
 
--
108419
 
--
108420
 
 
108421
 
ALTER TABLE ONLY sitetype
108422
 
    ADD CONSTRAINT sitetype_pkey PRIMARY KEY (sitetype_id);
108423
 
 
108424
 
 
108425
 
--
108426
 
--
108427
 
 
108428
 
ALTER TABLE ONLY sitetype
108429
 
    ADD CONSTRAINT sitetype_sitetype_name_key UNIQUE (sitetype_name);
108430
 
 
108431
 
 
108432
 
--
108433
 
--
108434
 
 
108435
 
ALTER TABLE ONLY sltrans
108436
 
    ADD CONSTRAINT sltrans_pkey PRIMARY KEY (sltrans_id);
108437
 
 
108438
 
 
108439
 
--
108440
 
--
108441
 
 
108442
 
ALTER TABLE ONLY source
108443
 
    ADD CONSTRAINT source_pkey PRIMARY KEY (source_id);
108444
 
 
108445
 
 
108446
 
--
108447
 
--
108448
 
 
108449
 
ALTER TABLE ONLY source
108450
 
    ADD CONSTRAINT source_source_name_key UNIQUE (source_name);
108451
 
 
108452
 
 
108453
 
--
108454
 
--
108455
 
 
108456
 
ALTER TABLE ONLY state
108457
 
    ADD CONSTRAINT state_pkey PRIMARY KEY (state_id);
108458
 
 
108459
 
 
108460
 
--
108461
 
--
108462
 
 
108463
 
ALTER TABLE ONLY state
108464
 
    ADD CONSTRAINT state_state_country_id_key UNIQUE (state_country_id, state_name);
108465
 
 
108466
 
 
108467
 
--
108468
 
--
108469
 
 
108470
 
ALTER TABLE ONLY status
108471
 
    ADD CONSTRAINT status_pkey PRIMARY KEY (status_id);
108472
 
 
108473
 
 
108474
 
--
108475
 
--
108476
 
 
108477
 
ALTER TABLE ONLY status
108478
 
    ADD CONSTRAINT status_status_type_key UNIQUE (status_type, status_code);
108479
 
 
108480
 
 
108481
 
--
108482
 
--
108483
 
 
108484
 
ALTER TABLE ONLY stdjrnl
108485
 
    ADD CONSTRAINT stdjrnl_pkey PRIMARY KEY (stdjrnl_id);
108486
 
 
108487
 
 
108488
 
--
108489
 
--
108490
 
 
108491
 
ALTER TABLE ONLY stdjrnl
108492
 
    ADD CONSTRAINT stdjrnl_stdjrnl_name_key UNIQUE (stdjrnl_name);
108493
 
 
108494
 
 
108495
 
--
108496
 
--
108497
 
 
108498
 
ALTER TABLE ONLY stdjrnlgrp
108499
 
    ADD CONSTRAINT stdjrnlgrp_pkey PRIMARY KEY (stdjrnlgrp_id);
108500
 
 
108501
 
 
108502
 
--
108503
 
--
108504
 
 
108505
 
ALTER TABLE ONLY stdjrnlgrp
108506
 
    ADD CONSTRAINT stdjrnlgrp_stdjrnlgrp_name_key UNIQUE (stdjrnlgrp_name);
108507
 
 
108508
 
 
108509
 
--
108510
 
--
108511
 
 
108512
 
ALTER TABLE ONLY stdjrnlgrpitem
108513
 
    ADD CONSTRAINT stdjrnlgrpitem_pkey PRIMARY KEY (stdjrnlgrpitem_id);
108514
 
 
108515
 
 
108516
 
--
108517
 
--
108518
 
 
108519
 
ALTER TABLE ONLY stdjrnlitem
108520
 
    ADD CONSTRAINT stdjrnlitem_pkey PRIMARY KEY (stdjrnlitem_id);
108521
 
 
108522
 
 
108523
 
--
108524
 
--
108525
 
 
108526
 
ALTER TABLE ONLY subaccnt
108527
 
    ADD CONSTRAINT subaccnt_pkey PRIMARY KEY (subaccnt_id);
108528
 
 
108529
 
 
108530
 
--
108531
 
--
108532
 
 
108533
 
ALTER TABLE ONLY subaccnt
108534
 
    ADD CONSTRAINT subaccnt_subaccnt_number_key UNIQUE (subaccnt_number);
108535
 
 
108536
 
 
108537
 
--
108538
 
--
108539
 
 
108540
 
ALTER TABLE ONLY subaccnttype
108541
 
    ADD CONSTRAINT subaccnttype_pkey PRIMARY KEY (subaccnttype_id);
108542
 
 
108543
 
 
108544
 
--
108545
 
--
108546
 
 
108547
 
ALTER TABLE ONLY tax
108548
 
    ADD CONSTRAINT tax_pkey PRIMARY KEY (tax_id);
108549
 
 
108550
 
 
108551
 
--
108552
 
--
108553
 
 
108554
 
ALTER TABLE ONLY taxass
108555
 
    ADD CONSTRAINT taxass_pkey PRIMARY KEY (taxass_id);
108556
 
 
108557
 
 
108558
 
--
108559
 
--
108560
 
 
108561
 
ALTER TABLE ONLY taxass
108562
 
    ADD CONSTRAINT taxass_taxass_taxzone_id_key UNIQUE (taxass_taxzone_id, taxass_taxtype_id, taxass_tax_id);
108563
 
 
108564
 
 
108565
 
--
108566
 
--
108567
 
 
108568
 
ALTER TABLE ONLY taxauth
108569
 
    ADD CONSTRAINT taxauth_pkey PRIMARY KEY (taxauth_id);
108570
 
 
108571
 
 
108572
 
--
108573
 
--
108574
 
 
108575
 
ALTER TABLE ONLY taxauth
108576
 
    ADD CONSTRAINT taxauth_taxauth_code_key UNIQUE (taxauth_code);
108577
 
 
108578
 
 
108579
 
--
108580
 
--
108581
 
 
108582
 
ALTER TABLE ONLY taxclass
108583
 
    ADD CONSTRAINT taxclass_pkey PRIMARY KEY (taxclass_id);
108584
 
 
108585
 
 
108586
 
--
108587
 
--
108588
 
 
108589
 
ALTER TABLE ONLY taxclass
108590
 
    ADD CONSTRAINT taxclass_taxclass_code_key UNIQUE (taxclass_code);
108591
 
 
108592
 
 
108593
 
--
108594
 
--
108595
 
 
108596
 
ALTER TABLE ONLY taxhist
108597
 
    ADD CONSTRAINT taxhist_pkey PRIMARY KEY (taxhist_id);
108598
 
 
108599
 
 
108600
 
--
108601
 
--
108602
 
 
108603
 
ALTER TABLE ONLY taxpay
108604
 
    ADD CONSTRAINT taxpay_pkey PRIMARY KEY (taxpay_id);
108605
 
 
108606
 
 
108607
 
--
108608
 
--
108609
 
 
108610
 
ALTER TABLE ONLY taxrate
108611
 
    ADD CONSTRAINT taxrate_pkey PRIMARY KEY (taxrate_id);
108612
 
 
108613
 
 
108614
 
--
108615
 
--
108616
 
 
108617
 
ALTER TABLE ONLY taxreg
108618
 
    ADD CONSTRAINT taxreg_pkey PRIMARY KEY (taxreg_id);
108619
 
 
108620
 
 
108621
 
--
108622
 
--
108623
 
 
108624
 
ALTER TABLE ONLY taxtype
108625
 
    ADD CONSTRAINT taxtype_pkey PRIMARY KEY (taxtype_id);
108626
 
 
108627
 
 
108628
 
--
108629
 
--
108630
 
 
108631
 
ALTER TABLE ONLY taxtype
108632
 
    ADD CONSTRAINT taxtype_taxtype_name_key UNIQUE (taxtype_name);
108633
 
 
108634
 
 
108635
 
--
108636
 
--
108637
 
 
108638
 
ALTER TABLE ONLY taxzone
108639
 
    ADD CONSTRAINT taxzone_pkey PRIMARY KEY (taxzone_id);
108640
 
 
108641
 
 
108642
 
--
108643
 
--
108644
 
 
108645
 
ALTER TABLE ONLY taxzone
108646
 
    ADD CONSTRAINT taxzone_taxzone_code_key UNIQUE (taxzone_code);
108647
 
 
108648
 
 
108649
 
--
108650
 
--
108651
 
 
108652
 
ALTER TABLE ONLY terms
108653
 
    ADD CONSTRAINT terms_pkey PRIMARY KEY (terms_id);
108654
 
 
108655
 
 
108656
 
--
108657
 
--
108658
 
 
108659
 
ALTER TABLE ONLY terms
108660
 
    ADD CONSTRAINT terms_terms_code_key UNIQUE (terms_code);
108661
 
 
108662
 
 
108663
 
--
108664
 
--
108665
 
 
108666
 
ALTER TABLE ONLY todoitem
108667
 
    ADD CONSTRAINT todoitem_pkey PRIMARY KEY (todoitem_id);
108668
 
 
108669
 
 
108670
 
--
108671
 
--
108672
 
 
108673
 
ALTER TABLE ONLY trialbal
108674
 
    ADD CONSTRAINT trialbal_pkey PRIMARY KEY (trialbal_id);
108675
 
 
108676
 
 
108677
 
--
108678
 
--
108679
 
 
108680
 
ALTER TABLE ONLY uiform
108681
 
    ADD CONSTRAINT uiform_pkey PRIMARY KEY (uiform_id);
108682
 
 
108683
 
 
108684
 
--
108685
 
--
108686
 
 
108687
 
ALTER TABLE ONLY prjtype
108688
 
    ADD CONSTRAINT unq_prjtype_code UNIQUE (prjtype_code);
108689
 
 
108690
 
 
108691
 
--
108692
 
--
108693
 
 
108694
 
ALTER TABLE ONLY uom
108695
 
    ADD CONSTRAINT uom_pkey PRIMARY KEY (uom_id);
108696
 
 
108697
 
 
108698
 
--
108699
 
--
108700
 
 
108701
 
ALTER TABLE ONLY uom
108702
 
    ADD CONSTRAINT uom_uom_name_key UNIQUE (uom_name);
108703
 
 
108704
 
 
108705
 
--
108706
 
--
108707
 
 
108708
 
ALTER TABLE ONLY uomconv
108709
 
    ADD CONSTRAINT uomconv_pkey PRIMARY KEY (uomconv_id);
108710
 
 
108711
 
 
108712
 
--
108713
 
--
108714
 
 
108715
 
ALTER TABLE ONLY uomtype
108716
 
    ADD CONSTRAINT uomtype_pkey PRIMARY KEY (uomtype_id);
108717
 
 
108718
 
 
108719
 
--
108720
 
--
108721
 
 
108722
 
ALTER TABLE ONLY uomtype
108723
 
    ADD CONSTRAINT uomtype_uomtype_name_key UNIQUE (uomtype_name);
108724
 
 
108725
 
 
108726
 
--
108727
 
--
108728
 
 
108729
 
ALTER TABLE ONLY urlinfo
108730
 
    ADD CONSTRAINT urlinfo_pkey PRIMARY KEY (url_id);
108731
 
 
108732
 
 
108733
 
--
108734
 
--
108735
 
 
108736
 
ALTER TABLE ONLY usr_bak
108737
 
    ADD CONSTRAINT usr_pkey PRIMARY KEY (usr_id);
108738
 
 
108739
 
 
108740
 
--
108741
 
--
108742
 
 
108743
 
ALTER TABLE ONLY usr_bak
108744
 
    ADD CONSTRAINT usr_usr_username_key UNIQUE (usr_username);
108745
 
 
108746
 
 
108747
 
--
108748
 
--
108749
 
 
108750
 
ALTER TABLE ONLY usrgrp
108751
 
    ADD CONSTRAINT usrgrp_pkey PRIMARY KEY (usrgrp_id);
108752
 
 
108753
 
 
108754
 
--
108755
 
--
108756
 
 
108757
 
ALTER TABLE ONLY usrpref
108758
 
    ADD CONSTRAINT usrpref_pkey PRIMARY KEY (usrpref_id);
108759
 
 
108760
 
 
108761
 
--
108762
 
--
108763
 
 
108764
 
ALTER TABLE ONLY usrpriv
108765
 
    ADD CONSTRAINT usrpriv_pkey PRIMARY KEY (usrpriv_id);
108766
 
 
108767
 
 
108768
 
--
108769
 
--
108770
 
 
108771
 
ALTER TABLE ONLY vendinfo
108772
 
    ADD CONSTRAINT vend_pkey PRIMARY KEY (vend_id);
108773
 
 
108774
 
 
108775
 
--
108776
 
--
108777
 
 
108778
 
ALTER TABLE ONLY vendaddrinfo
108779
 
    ADD CONSTRAINT vendaddr_pkey PRIMARY KEY (vendaddr_id);
108780
 
 
108781
 
 
108782
 
--
108783
 
--
108784
 
 
108785
 
ALTER TABLE ONLY vendinfo
108786
 
    ADD CONSTRAINT vendinfo_vend_number_key UNIQUE (vend_number);
108787
 
 
108788
 
 
108789
 
--
108790
 
--
108791
 
 
108792
 
ALTER TABLE ONLY vendtype
108793
 
    ADD CONSTRAINT vendtype_pkey PRIMARY KEY (vendtype_id);
108794
 
 
108795
 
 
108796
 
--
108797
 
--
108798
 
 
108799
 
ALTER TABLE ONLY vendtype
108800
 
    ADD CONSTRAINT vendtype_vendtype_code_key UNIQUE (vendtype_code);
108801
 
 
108802
 
 
108803
 
--
108804
 
--
108805
 
 
108806
 
ALTER TABLE ONLY vodist
108807
 
    ADD CONSTRAINT vodist_pkey PRIMARY KEY (vodist_id);
108808
 
 
108809
 
 
108810
 
--
108811
 
--
108812
 
 
108813
 
ALTER TABLE ONLY vohead
108814
 
    ADD CONSTRAINT vohead_pkey PRIMARY KEY (vohead_id);
108815
 
 
108816
 
 
108817
 
--
108818
 
--
108819
 
 
108820
 
ALTER TABLE ONLY vohead
108821
 
    ADD CONSTRAINT vohead_vohead_number_key UNIQUE (vohead_number);
108822
 
 
108823
 
 
108824
 
--
108825
 
--
108826
 
 
108827
 
ALTER TABLE ONLY voheadtax
108828
 
    ADD CONSTRAINT voheadtax_pkey PRIMARY KEY (taxhist_id);
108829
 
 
108830
 
 
108831
 
--
108832
 
--
108833
 
 
108834
 
ALTER TABLE ONLY voitem
108835
 
    ADD CONSTRAINT voitem_pkey PRIMARY KEY (voitem_id);
108836
 
 
108837
 
 
108838
 
--
108839
 
--
108840
 
 
108841
 
ALTER TABLE ONLY voitemtax
108842
 
    ADD CONSTRAINT voitemtax_pkey PRIMARY KEY (taxhist_id);
108843
 
 
108844
 
 
108845
 
--
108846
 
--
108847
 
 
108848
 
ALTER TABLE ONLY whsinfo
108849
 
    ADD CONSTRAINT warehous_pkey PRIMARY KEY (warehous_id);
108850
 
 
108851
 
 
108852
 
--
108853
 
--
108854
 
 
108855
 
ALTER TABLE ONLY whsezone
108856
 
    ADD CONSTRAINT whsezone_pkey PRIMARY KEY (whsezone_id);
108857
 
 
108858
 
 
108859
 
--
108860
 
--
108861
 
 
108862
 
ALTER TABLE ONLY whsinfo
108863
 
    ADD CONSTRAINT whsinfo_warehous_code_key UNIQUE (warehous_code);
108864
 
 
108865
 
 
108866
 
--
108867
 
--
108868
 
 
108869
 
ALTER TABLE ONLY wo
108870
 
    ADD CONSTRAINT wo_pkey PRIMARY KEY (wo_id);
108871
 
 
108872
 
 
108873
 
--
108874
 
--
108875
 
 
108876
 
ALTER TABLE ONLY womatl
108877
 
    ADD CONSTRAINT womatl_pkey PRIMARY KEY (womatl_id);
108878
 
 
108879
 
 
108880
 
--
108881
 
--
108882
 
 
108883
 
ALTER TABLE ONLY womatlpost
108884
 
    ADD CONSTRAINT womatlpost_pkey PRIMARY KEY (womatlpost_id);
108885
 
 
108886
 
 
108887
 
--
108888
 
--
108889
 
 
108890
 
ALTER TABLE ONLY womatlvar
108891
 
    ADD CONSTRAINT womatlvar_pkey PRIMARY KEY (womatlvar_id);
108892
 
 
108893
 
 
108894
 
--
108895
 
--
108896
 
 
108897
 
ALTER TABLE ONLY xsltmap
108898
 
    ADD CONSTRAINT xsltmap_name_key UNIQUE (xsltmap_name);
108899
 
 
108900
 
 
108901
 
--
108902
 
--
108903
 
 
108904
 
ALTER TABLE ONLY xsltmap
108905
 
    ADD CONSTRAINT xsltmap_pkey PRIMARY KEY (xsltmap_id);
108906
 
 
108907
 
 
108908
 
--
108909
 
--
108910
 
 
108911
 
ALTER TABLE ONLY yearperiod
108912
 
    ADD CONSTRAINT yearperiod_pkey PRIMARY KEY (yearperiod_id);
108913
 
 
108914
 
 
108915
 
SET search_path = te, pg_catalog;
108916
 
 
108917
 
--
108918
 
--
108919
 
 
108920
 
ALTER TABLE ONLY pkgcmd
108921
 
    ADD CONSTRAINT pkgcmd_pkey PRIMARY KEY (cmd_id);
108922
 
 
108923
 
 
108924
 
--
108925
 
--
108926
 
 
108927
 
ALTER TABLE ONLY pkgcmdarg
108928
 
    ADD CONSTRAINT pkgcmdarg_pkey PRIMARY KEY (cmdarg_id);
108929
 
 
108930
 
 
108931
 
--
108932
 
--
108933
 
 
108934
 
ALTER TABLE ONLY pkgimage
108935
 
    ADD CONSTRAINT pkgimage_pkey PRIMARY KEY (image_id);
108936
 
 
108937
 
 
108938
 
--
108939
 
--
108940
 
 
108941
 
ALTER TABLE ONLY pkgmetasql
108942
 
    ADD CONSTRAINT pkgmetasql_pkey PRIMARY KEY (metasql_id);
108943
 
 
108944
 
 
108945
 
--
108946
 
--
108947
 
 
108948
 
ALTER TABLE ONLY pkgpriv
108949
 
    ADD CONSTRAINT pkgpriv_pkey PRIMARY KEY (priv_id);
108950
 
 
108951
 
 
108952
 
--
108953
 
--
108954
 
 
108955
 
ALTER TABLE ONLY pkgreport
108956
 
    ADD CONSTRAINT pkgreport_pkey PRIMARY KEY (report_id);
108957
 
 
108958
 
 
108959
 
--
108960
 
--
108961
 
 
108962
 
ALTER TABLE ONLY pkgscript
108963
 
    ADD CONSTRAINT pkgscript_pkey PRIMARY KEY (script_id);
108964
 
 
108965
 
 
108966
 
--
108967
 
--
108968
 
 
108969
 
ALTER TABLE ONLY pkguiform
108970
 
    ADD CONSTRAINT pkguiform_pkey PRIMARY KEY (uiform_id);
108971
 
 
108972
 
 
108973
 
--
108974
 
--
108975
 
 
108976
 
ALTER TABLE ONLY tecustrate
108977
 
    ADD CONSTRAINT tecustrate_pkey PRIMARY KEY (tecustrate_cust_id);
108978
 
 
108979
 
 
108980
 
--
108981
 
--
108982
 
 
108983
 
ALTER TABLE ONLY teexp
108984
 
    ADD CONSTRAINT teexp_pkey PRIMARY KEY (teexp_id);
108985
 
 
108986
 
 
108987
 
--
108988
 
--
108989
 
 
108990
 
ALTER TABLE ONLY tehead
108991
 
    ADD CONSTRAINT tehead_pkey PRIMARY KEY (tehead_id);
108992
 
 
108993
 
 
108994
 
--
108995
 
--
108996
 
 
108997
 
ALTER TABLE ONLY teitem
108998
 
    ADD CONSTRAINT teitem_pkey PRIMARY KEY (teitem_id);
108999
 
 
109000
 
 
109001
 
--
109002
 
--
109003
 
 
109004
 
ALTER TABLE ONLY teprj
109005
 
    ADD CONSTRAINT teprj_pkey PRIMARY KEY (teprj_id);
109006
 
 
109007
 
 
109008
 
--
109009
 
--
109010
 
 
109011
 
ALTER TABLE ONLY teprjtask
109012
 
    ADD CONSTRAINT teprjtask_pkey PRIMARY KEY (teprjtask_id);
109013
 
 
109014
 
 
109015
 
--
109016
 
--
109017
 
 
109018
 
ALTER TABLE ONLY teprjtask
109019
 
    ADD CONSTRAINT teprjtask_teprjtask_prjtask_id_key UNIQUE (teprjtask_prjtask_id);
109020
 
 
109021
 
 
109022
 
SET search_path = xtdesktop, pg_catalog;
109023
 
 
109024
 
--
109025
 
--
109026
 
 
109027
 
ALTER TABLE ONLY pkgcmd
109028
 
    ADD CONSTRAINT pkgcmd_pkey PRIMARY KEY (cmd_id);
109029
 
 
109030
 
 
109031
 
--
109032
 
--
109033
 
 
109034
 
ALTER TABLE ONLY pkgcmdarg
109035
 
    ADD CONSTRAINT pkgcmdarg_pkey PRIMARY KEY (cmdarg_id);
109036
 
 
109037
 
 
109038
 
--
109039
 
--
109040
 
 
109041
 
ALTER TABLE ONLY pkgimage
109042
 
    ADD CONSTRAINT pkgimage_pkey PRIMARY KEY (image_id);
109043
 
 
109044
 
 
109045
 
--
109046
 
--
109047
 
 
109048
 
ALTER TABLE ONLY pkgmetasql
109049
 
    ADD CONSTRAINT pkgmetasql_pkey PRIMARY KEY (metasql_id);
109050
 
 
109051
 
 
109052
 
--
109053
 
--
109054
 
 
109055
 
ALTER TABLE ONLY pkgpriv
109056
 
    ADD CONSTRAINT pkgpriv_pkey PRIMARY KEY (priv_id);
109057
 
 
109058
 
 
109059
 
--
109060
 
--
109061
 
 
109062
 
ALTER TABLE ONLY pkgreport
109063
 
    ADD CONSTRAINT pkgreport_pkey PRIMARY KEY (report_id);
109064
 
 
109065
 
 
109066
 
--
109067
 
--
109068
 
 
109069
 
ALTER TABLE ONLY pkgscript
109070
 
    ADD CONSTRAINT pkgscript_pkey PRIMARY KEY (script_id);
109071
 
 
109072
 
 
109073
 
--
109074
 
--
109075
 
 
109076
 
ALTER TABLE ONLY pkguiform
109077
 
    ADD CONSTRAINT pkguiform_pkey PRIMARY KEY (uiform_id);
109078
 
 
109079
 
 
109080
 
SET search_path = public, pg_catalog;
109081
 
 
109082
 
--
109083
 
--
109084
 
 
109085
 
CREATE UNIQUE INDEX accnt_unique_idx ON accnt USING btree (accnt_number, accnt_profit, accnt_sub, accnt_company);
109086
 
 
109087
 
 
109088
 
--
109089
 
--
109090
 
 
109091
 
CREATE INDEX apopen_apopen_open_idx ON apopen USING btree (apopen_open);
109092
 
 
109093
 
 
109094
 
--
109095
 
--
109096
 
 
109097
 
CREATE INDEX apopen_apopen_vend_id_idx ON apopen USING btree (apopen_vend_id);
109098
 
 
109099
 
 
109100
 
--
109101
 
--
109102
 
 
109103
 
CREATE INDEX apopentax_taxhist_parent_id_idx ON apopentax USING btree (taxhist_parent_id);
109104
 
 
109105
 
 
109106
 
--
109107
 
--
109108
 
 
109109
 
CREATE INDEX apopentax_taxhist_parent_type_idx ON apopentax USING btree (taxhist_parent_id, taxhist_taxtype_id);
109110
 
 
109111
 
 
109112
 
--
109113
 
--
109114
 
 
109115
 
CREATE INDEX apopentax_taxhist_taxtype_id_idx ON apopentax USING btree (taxhist_taxtype_id);
109116
 
 
109117
 
 
109118
 
--
109119
 
--
109120
 
 
109121
 
CREATE INDEX apselect_apselect_apopen_id_idx ON apselect USING btree (apselect_apopen_id);
109122
 
 
109123
 
 
109124
 
--
109125
 
--
109126
 
 
109127
 
CREATE INDEX arapply_arapply_target_docnumber_idx ON arapply USING btree (arapply_target_docnumber);
109128
 
 
109129
 
 
109130
 
--
109131
 
--
109132
 
 
109133
 
CREATE INDEX aropen_aropen_cust_id_idx ON aropen USING btree (aropen_cust_id);
109134
 
 
109135
 
 
109136
 
--
109137
 
--
109138
 
 
109139
 
CREATE INDEX aropen_aropen_docnumber_idx ON aropen USING btree (aropen_docnumber);
109140
 
 
109141
 
 
109142
 
--
109143
 
--
109144
 
 
109145
 
CREATE INDEX aropen_aropen_doctype_idx ON aropen USING btree (aropen_doctype);
109146
 
 
109147
 
 
109148
 
--
109149
 
--
109150
 
 
109151
 
CREATE INDEX aropen_aropen_open_idx ON aropen USING btree (aropen_open);
109152
 
 
109153
 
 
109154
 
--
109155
 
--
109156
 
 
109157
 
CREATE INDEX aropen_posted_idx ON aropen USING btree (aropen_posted);
109158
 
 
109159
 
 
109160
 
--
109161
 
--
109162
 
 
109163
 
CREATE INDEX aropenalloc_aropen_id_idx ON aropenalloc USING btree (aropenalloc_aropen_id);
109164
 
 
109165
 
 
109166
 
--
109167
 
--
109168
 
 
109169
 
CREATE INDEX aropenalloc_doc_id_idx ON aropenalloc USING btree (aropenalloc_doc_id);
109170
 
 
109171
 
 
109172
 
--
109173
 
--
109174
 
 
109175
 
CREATE INDEX aropentax_taxhist_parent_id_idx ON aropentax USING btree (taxhist_parent_id);
109176
 
 
109177
 
 
109178
 
--
109179
 
--
109180
 
 
109181
 
CREATE INDEX aropentax_taxhist_parent_type_idx ON aropentax USING btree (taxhist_parent_id, taxhist_taxtype_id);
109182
 
 
109183
 
 
109184
 
--
109185
 
--
109186
 
 
109187
 
CREATE INDEX aropentax_taxhist_taxtype_id_idx ON aropentax USING btree (taxhist_taxtype_id);
109188
 
 
109189
 
 
109190
 
--
109191
 
--
109192
 
 
109193
 
CREATE INDEX asohisttax_taxhist_parent_id_idx ON asohisttax USING btree (taxhist_parent_id);
109194
 
 
109195
 
 
109196
 
--
109197
 
--
109198
 
 
109199
 
CREATE INDEX asohisttax_taxhist_parent_type_idx ON asohisttax USING btree (taxhist_parent_id, taxhist_taxtype_id);
109200
 
 
109201
 
 
109202
 
--
109203
 
--
109204
 
 
109205
 
CREATE INDEX asohisttax_taxhist_taxtype_id_idx ON asohisttax USING btree (taxhist_taxtype_id);
109206
 
 
109207
 
 
109208
 
--
109209
 
--
109210
 
 
109211
 
CREATE INDEX bomitem_bomitem_item_id_idx ON bomitem USING btree (bomitem_item_id);
109212
 
 
109213
 
 
109214
 
--
109215
 
--
109216
 
 
109217
 
CREATE INDEX bomitem_effective_key ON bomitem USING btree (bomitem_effective);
109218
 
 
109219
 
 
109220
 
--
109221
 
--
109222
 
 
109223
 
CREATE INDEX bomitem_expires_key ON bomitem USING btree (bomitem_expires);
109224
 
 
109225
 
 
109226
 
--
109227
 
--
109228
 
 
109229
 
CREATE INDEX bomitem_parent_item_id ON bomitem USING btree (bomitem_parent_item_id);
109230
 
 
109231
 
 
109232
 
--
109233
 
--
109234
 
 
109235
 
CREATE INDEX bomitemcost_bomitem_id_key ON bomitemcost USING btree (bomitemcost_bomitem_id);
109236
 
 
109237
 
 
109238
 
--
109239
 
--
109240
 
 
109241
 
CREATE UNIQUE INDEX bomitemcost_master_idx ON bomitemcost USING btree (bomitemcost_bomitem_id, bomitemcost_costelem_id, bomitemcost_lowlevel);
109242
 
 
109243
 
 
109244
 
--
109245
 
--
109246
 
 
109247
 
CREATE INDEX cashrcptitem_aropen_idx ON cashrcptitem USING btree (cashrcptitem_aropen_id);
109248
 
 
109249
 
 
109250
 
--
109251
 
--
109252
 
 
109253
 
CREATE INDEX cashrcptitem_cashrcpt_idx ON cashrcptitem USING btree (cashrcptitem_cashrcpt_id);
109254
 
 
109255
 
 
109256
 
--
109257
 
--
109258
 
 
109259
 
CREATE INDEX ccard_cust_id_idx ON ccard USING btree (ccard_cust_id);
109260
 
 
109261
 
 
109262
 
--
109263
 
--
109264
 
 
109265
 
CREATE INDEX ccardaud_ccard_cust_id_idx ON ccardaud USING btree (ccardaud_ccard_cust_id_new);
109266
 
 
109267
 
 
109268
 
--
109269
 
--
109270
 
 
109271
 
CREATE INDEX ccardaud_ccard_id_idx ON ccardaud USING btree (ccardaud_ccard_id);
109272
 
 
109273
 
 
109274
 
--
109275
 
--
109276
 
 
109277
 
CREATE INDEX ccpay_ccard_id_idx ON ccpay USING btree (ccpay_ccard_id);
109278
 
 
109279
 
 
109280
 
--
109281
 
--
109282
 
 
109283
 
CREATE INDEX ccpay_cust_id_idx ON ccpay USING btree (ccpay_cust_id);
109284
 
 
109285
 
 
109286
 
--
109287
 
--
109288
 
 
109289
 
CREATE INDEX ccpay_order_number_idx ON ccpay USING btree (ccpay_order_number);
109290
 
 
109291
 
 
109292
 
--
109293
 
--
109294
 
 
109295
 
CREATE INDEX charass_target_idx ON charass USING btree (charass_target_type, charass_target_id);
109296
 
 
109297
 
 
109298
 
--
109299
 
--
109300
 
 
109301
 
CREATE INDEX checkhead_posted_idx ON checkhead USING btree (checkhead_posted);
109302
 
 
109303
 
 
109304
 
--
109305
 
--
109306
 
 
109307
 
CREATE INDEX checkhead_replaced_idx ON checkhead USING btree (checkhead_replaced);
109308
 
 
109309
 
 
109310
 
--
109311
 
--
109312
 
 
109313
 
CREATE INDEX checkitem_apopenitem_id_idx ON checkitem USING btree (checkitem_apopen_id);
109314
 
 
109315
 
 
109316
 
--
109317
 
--
109318
 
 
109319
 
CREATE INDEX cmhead_invcnumber_idx ON cmhead USING btree (cmhead_invcnumber);
109320
 
 
109321
 
 
109322
 
--
109323
 
--
109324
 
 
109325
 
CREATE INDEX cmheadtax_taxhist_parent_id_idx ON cmheadtax USING btree (taxhist_parent_id);
109326
 
 
109327
 
 
109328
 
--
109329
 
--
109330
 
 
109331
 
CREATE INDEX cmheadtax_taxhist_parent_type_idx ON cmheadtax USING btree (taxhist_parent_id, taxhist_taxtype_id);
109332
 
 
109333
 
 
109334
 
--
109335
 
--
109336
 
 
109337
 
CREATE INDEX cmheadtax_taxhist_taxtype_id_idx ON cmheadtax USING btree (taxhist_taxtype_id);
109338
 
 
109339
 
 
109340
 
--
109341
 
--
109342
 
 
109343
 
CREATE INDEX cmitemtax_taxhist_parent_id_idx ON cmitemtax USING btree (taxhist_parent_id);
109344
 
 
109345
 
 
109346
 
--
109347
 
--
109348
 
 
109349
 
CREATE INDEX cmitemtax_taxhist_parent_type_idx ON cmitemtax USING btree (taxhist_parent_id, taxhist_taxtype_id);
109350
 
 
109351
 
 
109352
 
--
109353
 
--
109354
 
 
109355
 
CREATE INDEX cmitemtax_taxhist_taxtype_id_idx ON cmitemtax USING btree (taxhist_taxtype_id);
109356
 
 
109357
 
 
109358
 
--
109359
 
--
109360
 
 
109361
 
CREATE INDEX cntct_email_idx ON cntct USING btree (cntct_email);
109362
 
 
109363
 
 
109364
 
--
109365
 
--
109366
 
 
109367
 
CREATE INDEX cntct_name_idx ON cntct USING btree (cntct_name);
109368
 
 
109369
 
 
109370
 
--
109371
 
--
109372
 
 
109373
 
CREATE INDEX cobill_cobmisc_id ON cobill USING btree (cobill_cobmisc_id);
109374
 
 
109375
 
 
109376
 
--
109377
 
--
109378
 
 
109379
 
CREATE INDEX cobill_coitem_id ON cobill USING btree (cobill_coitem_id);
109380
 
 
109381
 
 
109382
 
--
109383
 
--
109384
 
 
109385
 
CREATE INDEX cobilltax_taxhist_parent_id_idx ON cobilltax USING btree (taxhist_parent_id);
109386
 
 
109387
 
 
109388
 
--
109389
 
--
109390
 
 
109391
 
CREATE INDEX cobilltax_taxhist_parent_type_idx ON cobilltax USING btree (taxhist_parent_id, taxhist_taxtype_id);
109392
 
 
109393
 
 
109394
 
--
109395
 
--
109396
 
 
109397
 
CREATE INDEX cobilltax_taxhist_taxtype_id_idx ON cobilltax USING btree (taxhist_taxtype_id);
109398
 
 
109399
 
 
109400
 
--
109401
 
--
109402
 
 
109403
 
CREATE INDEX cobmisc_cohead_id ON cobmisc USING btree (cobmisc_cohead_id);
109404
 
 
109405
 
 
109406
 
--
109407
 
--
109408
 
 
109409
 
CREATE INDEX cobmisc_posted ON cobmisc USING btree (cobmisc_posted);
109410
 
 
109411
 
 
109412
 
--
109413
 
--
109414
 
 
109415
 
CREATE INDEX cobmisctax_taxhist_parent_id_idx ON cobmisctax USING btree (taxhist_parent_id);
109416
 
 
109417
 
 
109418
 
--
109419
 
--
109420
 
 
109421
 
CREATE INDEX cobmisctax_taxhist_parent_type_idx ON cobmisctax USING btree (taxhist_parent_id, taxhist_taxtype_id);
109422
 
 
109423
 
 
109424
 
--
109425
 
--
109426
 
 
109427
 
CREATE INDEX cobmisctax_taxhist_taxtype_id_idx ON cobmisctax USING btree (taxhist_taxtype_id);
109428
 
 
109429
 
 
109430
 
--
109431
 
--
109432
 
 
109433
 
CREATE INDEX cohead_cohead_status_idx ON cohead USING btree (cohead_status);
109434
 
 
109435
 
 
109436
 
--
109437
 
--
109438
 
 
109439
 
CREATE INDEX cohead_cust_id_key ON cohead USING btree (cohead_cust_id);
109440
 
 
109441
 
 
109442
 
--
109443
 
--
109444
 
 
109445
 
CREATE INDEX cohead_custponumber_idx ON cohead USING btree (cohead_custponumber);
109446
 
 
109447
 
 
109448
 
--
109449
 
--
109450
 
 
109451
 
CREATE UNIQUE INDEX cohead_number_idx ON cohead USING btree (cohead_number);
109452
 
 
109453
 
 
109454
 
--
109455
 
--
109456
 
 
109457
 
CREATE INDEX cohead_shipto_id ON cohead USING btree (cohead_shipto_id);
109458
 
 
109459
 
 
109460
 
--
109461
 
--
109462
 
 
109463
 
CREATE INDEX cohist_cust_id ON cohist USING btree (cohist_cust_id);
109464
 
 
109465
 
 
109466
 
--
109467
 
--
109468
 
 
109469
 
CREATE INDEX cohist_invcnumber ON cohist USING btree (cohist_invcnumber);
109470
 
 
109471
 
 
109472
 
--
109473
 
--
109474
 
 
109475
 
CREATE INDEX cohist_itemsite_id ON cohist USING btree (cohist_itemsite_id);
109476
 
 
109477
 
 
109478
 
--
109479
 
--
109480
 
 
109481
 
CREATE INDEX cohist_shipdate ON cohist USING btree (cohist_shipdate);
109482
 
 
109483
 
 
109484
 
--
109485
 
--
109486
 
 
109487
 
CREATE INDEX cohist_shipto_id ON cohist USING btree (cohist_shipto_id);
109488
 
 
109489
 
 
109490
 
--
109491
 
--
109492
 
 
109493
 
CREATE INDEX cohisttax_taxhist_parent_id_idx ON cohisttax USING btree (taxhist_parent_id);
109494
 
 
109495
 
 
109496
 
--
109497
 
--
109498
 
 
109499
 
CREATE INDEX cohisttax_taxhist_parent_type_idx ON cohisttax USING btree (taxhist_parent_id, taxhist_taxtype_id);
109500
 
 
109501
 
 
109502
 
--
109503
 
--
109504
 
 
109505
 
CREATE INDEX cohisttax_taxhist_taxtype_id_idx ON cohisttax USING btree (taxhist_taxtype_id);
109506
 
 
109507
 
 
109508
 
--
109509
 
--
109510
 
 
109511
 
CREATE INDEX coitem_cohead_id_key ON coitem USING btree (coitem_cohead_id);
109512
 
 
109513
 
 
109514
 
--
109515
 
--
109516
 
 
109517
 
CREATE UNIQUE INDEX coitem_coitem_cohead_id_key ON coitem USING btree (coitem_cohead_id, coitem_linenumber, coitem_subnumber);
109518
 
 
109519
 
 
109520
 
--
109521
 
--
109522
 
 
109523
 
CREATE INDEX coitem_itemsite_id ON coitem USING btree (coitem_itemsite_id);
109524
 
 
109525
 
 
109526
 
--
109527
 
--
109528
 
 
109529
 
CREATE INDEX coitem_linenumber_key ON coitem USING btree (coitem_linenumber);
109530
 
 
109531
 
 
109532
 
--
109533
 
--
109534
 
 
109535
 
CREATE INDEX coitem_status_key ON coitem USING btree (coitem_status);
109536
 
 
109537
 
 
109538
 
--
109539
 
--
109540
 
 
109541
 
CREATE INDEX comment_comment_source_idx ON comment USING btree (comment_source, comment_source_id);
109542
 
 
109543
 
 
109544
 
--
109545
 
--
109546
 
 
109547
 
CREATE UNIQUE INDEX contrct_master_idx ON contrct USING btree (contrct_number, contrct_vend_id);
109548
 
 
109549
 
 
109550
 
--
109551
 
--
109552
 
 
109553
 
CREATE UNIQUE INDEX cust_number_idx ON custinfo USING btree (cust_number);
109554
 
 
109555
 
 
109556
 
--
109557
 
--
109558
 
 
109559
 
CREATE INDEX evntlog_dispatched_idx ON evntlog USING btree (evntlog_dispatched);
109560
 
 
109561
 
 
109562
 
--
109563
 
--
109564
 
 
109565
 
CREATE INDEX evntlog_evntlog_username_idx ON evntlog USING btree (evntlog_username);
109566
 
 
109567
 
 
109568
 
--
109569
 
--
109570
 
 
109571
 
CREATE INDEX evntnot_evnttype_id_idx ON evntnot USING btree (evntnot_evnttype_id);
109572
 
 
109573
 
 
109574
 
--
109575
 
--
109576
 
 
109577
 
CREATE INDEX evntnot_warehous_id_idx ON evntnot USING btree (evntnot_warehous_id);
109578
 
 
109579
 
 
109580
 
--
109581
 
--
109582
 
 
109583
 
CREATE INDEX filter_idx ON filter USING btree (filter_screen, filter_username, filter_name);
109584
 
 
109585
 
 
109586
 
--
109587
 
--
109588
 
 
109589
 
CREATE INDEX gltrans_gltrans_accnt_id_idx ON gltrans USING btree (gltrans_accnt_id);
109590
 
 
109591
 
 
109592
 
--
109593
 
--
109594
 
 
109595
 
CREATE INDEX gltrans_gltrans_date_idx ON gltrans USING btree (gltrans_date);
109596
 
 
109597
 
 
109598
 
--
109599
 
--
109600
 
 
109601
 
CREATE INDEX gltrans_gltrans_journalnumber_idx ON gltrans USING btree (gltrans_journalnumber);
109602
 
 
109603
 
 
109604
 
--
109605
 
--
109606
 
 
109607
 
CREATE INDEX gltrans_sequence_idx ON gltrans USING btree (gltrans_sequence);
109608
 
 
109609
 
 
109610
 
--
109611
 
--
109612
 
 
109613
 
CREATE INDEX invchead_invchead_cust_id_idx ON invchead USING btree (invchead_cust_id);
109614
 
 
109615
 
 
109616
 
--
109617
 
--
109618
 
 
109619
 
CREATE INDEX invchead_invchead_ordernumber_idx ON invchead USING btree (invchead_ordernumber);
109620
 
 
109621
 
 
109622
 
--
109623
 
--
109624
 
 
109625
 
CREATE INDEX invcheadtax_taxhist_parent_id_idx ON invcheadtax USING btree (taxhist_parent_id);
109626
 
 
109627
 
 
109628
 
--
109629
 
--
109630
 
 
109631
 
CREATE INDEX invcheadtax_taxhist_parent_type_idx ON invcheadtax USING btree (taxhist_parent_id, taxhist_taxtype_id);
109632
 
 
109633
 
 
109634
 
--
109635
 
--
109636
 
 
109637
 
CREATE INDEX invcheadtax_taxhist_taxtype_id_idx ON invcheadtax USING btree (taxhist_taxtype_id);
109638
 
 
109639
 
 
109640
 
--
109641
 
--
109642
 
 
109643
 
CREATE INDEX invcitem_invcitem_invchead_id_idx ON invcitem USING btree (invcitem_invchead_id);
109644
 
 
109645
 
 
109646
 
--
109647
 
--
109648
 
 
109649
 
CREATE INDEX invcitem_invcitem_itemsite_id_idx ON invcitem USING btree (invcitem_item_id, invcitem_warehous_id);
109650
 
 
109651
 
 
109652
 
--
109653
 
--
109654
 
 
109655
 
CREATE INDEX invcitemtax_taxhist_parent_id_idx ON invcitemtax USING btree (taxhist_parent_id);
109656
 
 
109657
 
 
109658
 
--
109659
 
--
109660
 
 
109661
 
CREATE INDEX invcitemtax_taxhist_parent_type_idx ON invcitemtax USING btree (taxhist_parent_id, taxhist_taxtype_id);
109662
 
 
109663
 
 
109664
 
--
109665
 
--
109666
 
 
109667
 
CREATE INDEX invcitemtax_taxhist_taxtype_id_idx ON invcitemtax USING btree (taxhist_taxtype_id);
109668
 
 
109669
 
 
109670
 
--
109671
 
--
109672
 
 
109673
 
CREATE INDEX invdetail_invdetail_invcitem_id_idx ON invdetail USING btree (invdetail_invcitem_id);
109674
 
 
109675
 
 
109676
 
--
109677
 
--
109678
 
 
109679
 
CREATE INDEX invdetail_invdetail_invhist_id_idx ON invdetail USING btree (invdetail_invhist_id);
109680
 
 
109681
 
 
109682
 
--
109683
 
--
109684
 
 
109685
 
CREATE INDEX invhist_hasdetail ON invhist USING btree (invhist_hasdetail);
109686
 
 
109687
 
 
109688
 
--
109689
 
--
109690
 
 
109691
 
CREATE INDEX invhist_invhist_ordnumber_idx ON invhist USING btree (invhist_ordnumber);
109692
 
 
109693
 
 
109694
 
--
109695
 
--
109696
 
 
109697
 
CREATE INDEX invhist_itemsite_id ON invhist USING btree (invhist_itemsite_id);
109698
 
 
109699
 
 
109700
 
--
109701
 
--
109702
 
 
109703
 
CREATE INDEX invhist_series ON invhist USING btree (invhist_series);
109704
 
 
109705
 
 
109706
 
--
109707
 
--
109708
 
 
109709
 
CREATE INDEX invhist_transdate ON invhist USING btree (invhist_transdate);
109710
 
 
109711
 
 
109712
 
--
109713
 
--
109714
 
 
109715
 
CREATE INDEX invhist_transtype ON invhist USING btree (invhist_transtype);
109716
 
 
109717
 
 
109718
 
--
109719
 
--
109720
 
 
109721
 
CREATE INDEX ipsitem_ipshead_id_idx ON ipsiteminfo USING btree (ipsitem_ipshead_id);
109722
 
 
109723
 
 
109724
 
--
109725
 
--
109726
 
 
109727
 
CREATE INDEX item_classcode_id ON item USING btree (item_classcode_id);
109728
 
 
109729
 
 
109730
 
--
109731
 
--
109732
 
 
109733
 
CREATE UNIQUE INDEX item_number_idx ON item USING btree (item_number);
109734
 
 
109735
 
 
109736
 
--
109737
 
--
109738
 
 
109739
 
CREATE INDEX item_prodcat_id_idx ON item USING btree (item_prodcat_id);
109740
 
 
109741
 
 
109742
 
--
109743
 
--
109744
 
 
109745
 
CREATE INDEX item_upccode_idx ON item USING btree (item_upccode);
109746
 
 
109747
 
 
109748
 
--
109749
 
--
109750
 
 
109751
 
CREATE INDEX itemcost_item_id_key ON itemcost USING btree (itemcost_item_id);
109752
 
 
109753
 
 
109754
 
--
109755
 
--
109756
 
 
109757
 
CREATE UNIQUE INDEX itemcost_master_idx ON itemcost USING btree (itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel);
109758
 
 
109759
 
 
109760
 
--
109761
 
--
109762
 
 
109763
 
CREATE INDEX itemloc_itemsite_idx ON itemloc USING btree (itemloc_itemsite_id);
109764
 
 
109765
 
 
109766
 
--
109767
 
--
109768
 
 
109769
 
CREATE INDEX itemloc_location_idx ON itemloc USING btree (itemloc_location_id);
109770
 
 
109771
 
 
109772
 
--
109773
 
--
109774
 
 
109775
 
CREATE INDEX itemsite_active_key ON itemsite USING btree (itemsite_active);
109776
 
 
109777
 
 
109778
 
--
109779
 
--
109780
 
 
109781
 
CREATE INDEX itemsite_item_id_key ON itemsite USING btree (itemsite_item_id);
109782
 
 
109783
 
 
109784
 
--
109785
 
--
109786
 
 
109787
 
CREATE UNIQUE INDEX itemsite_item_warehous_id_key ON itemsite USING btree (itemsite_item_id, itemsite_warehous_id);
109788
 
 
109789
 
 
109790
 
--
109791
 
--
109792
 
 
109793
 
CREATE INDEX itemsite_plancode_id_key ON itemsite USING btree (itemsite_plancode_id);
109794
 
 
109795
 
 
109796
 
--
109797
 
--
109798
 
 
109799
 
CREATE INDEX itemsite_warehous_id_key ON itemsite USING btree (itemsite_warehous_id);
109800
 
 
109801
 
 
109802
 
--
109803
 
--
109804
 
 
109805
 
CREATE INDEX itemsrc_vend_id_idx ON itemsrc USING btree (itemsrc_vend_id);
109806
 
 
109807
 
 
109808
 
--
109809
 
--
109810
 
 
109811
 
CREATE INDEX itemsrcp_itemsrc_id_key ON itemsrcp USING btree (itemsrcp_itemsrc_id);
109812
 
 
109813
 
 
109814
 
--
109815
 
--
109816
 
 
109817
 
CREATE INDEX itemsub_parent_item_id_key ON itemsub USING btree (itemsub_parent_item_id);
109818
 
 
109819
 
 
109820
 
--
109821
 
--
109822
 
 
109823
 
CREATE INDEX itemsub_sub_item_id_key ON itemsub USING btree (itemsub_sub_item_id);
109824
 
 
109825
 
 
109826
 
--
109827
 
--
109828
 
 
109829
 
CREATE INDEX location_location_formatname_idx ON location USING btree (location_formatname);
109830
 
 
109831
 
 
109832
 
--
109833
 
--
109834
 
 
109835
 
CREATE INDEX location_warehous_idx ON location USING btree (location_warehous_id);
109836
 
 
109837
 
 
109838
 
--
109839
 
--
109840
 
 
109841
 
CREATE INDEX payaropen_aropen_id_idx ON payaropen USING btree (payaropen_aropen_id);
109842
 
 
109843
 
 
109844
 
--
109845
 
--
109846
 
 
109847
 
CREATE INDEX payaropen_ccpay_id_idx ON payaropen USING btree (payaropen_ccpay_id);
109848
 
 
109849
 
 
109850
 
--
109851
 
--
109852
 
 
109853
 
CREATE INDEX payco_ccpay_id_idx ON payco USING btree (payco_ccpay_id);
109854
 
 
109855
 
 
109856
 
--
109857
 
--
109858
 
 
109859
 
CREATE INDEX payco_cohead_id_idx ON payco USING btree (payco_cohead_id);
109860
 
 
109861
 
 
109862
 
--
109863
 
--
109864
 
 
109865
 
CREATE INDEX pohead_pohead_status_idx ON pohead USING btree (pohead_status);
109866
 
 
109867
 
 
109868
 
--
109869
 
--
109870
 
 
109871
 
CREATE INDEX poitem_itemsite_id_key ON poitem USING btree (poitem_itemsite_id);
109872
 
 
109873
 
 
109874
 
--
109875
 
--
109876
 
 
109877
 
CREATE INDEX poitem_itemsite_status_duedate_key ON poitem USING btree (poitem_itemsite_id, poitem_status, poitem_duedate);
109878
 
 
109879
 
 
109880
 
--
109881
 
--
109882
 
 
109883
 
CREATE INDEX poitem_pohead_id_key ON poitem USING btree (poitem_pohead_id);
109884
 
 
109885
 
 
109886
 
--
109887
 
--
109888
 
 
109889
 
CREATE INDEX poitem_status_key ON poitem USING btree (poitem_status);
109890
 
 
109891
 
 
109892
 
--
109893
 
--
109894
 
 
109895
 
CREATE UNIQUE INDEX priv_name_idx ON priv USING btree (priv_name);
109896
 
 
109897
 
 
109898
 
--
109899
 
--
109900
 
 
109901
 
CREATE INDEX quitem_quhead_id_key ON quitem USING btree (quitem_quhead_id);
109902
 
 
109903
 
 
109904
 
--
109905
 
--
109906
 
 
109907
 
CREATE INDEX recv_ordertypeid_idx ON recv USING btree (recv_order_type, recv_orderitem_id);
109908
 
 
109909
 
 
109910
 
--
109911
 
--
109912
 
 
109913
 
CREATE UNIQUE INDEX report_name_grade_idx ON report USING btree (report_name, report_grade);
109914
 
 
109915
 
 
109916
 
--
109917
 
--
109918
 
 
109919
 
CREATE INDEX salesaccnt_prodcat_id_idx ON salesaccnt USING btree (salesaccnt_prodcat_id);
109920
 
 
109921
 
 
109922
 
--
109923
 
--
109924
 
 
109925
 
CREATE INDEX salesaccnt_warehous_id_idx ON salesaccnt USING btree (salesaccnt_warehous_id);
109926
 
 
109927
 
 
109928
 
--
109929
 
--
109930
 
 
109931
 
CREATE INDEX shipdata_cohead_number_idx ON shipdata USING btree (shipdata_cohead_number);
109932
 
 
109933
 
 
109934
 
--
109935
 
--
109936
 
 
109937
 
CREATE INDEX shipdatasum_cohead_number_idx ON shipdatasum USING btree (shipdatasum_cohead_number);
109938
 
 
109939
 
 
109940
 
--
109941
 
--
109942
 
 
109943
 
CREATE INDEX shipdatasum_cosmisc_tracknum_idx ON shipdatasum USING btree (shipdatasum_cosmisc_tracknum);
109944
 
 
109945
 
 
109946
 
--
109947
 
--
109948
 
 
109949
 
CREATE INDEX shiphead_order_id_idx ON shiphead USING btree (shiphead_order_id);
109950
 
 
109951
 
 
109952
 
--
109953
 
--
109954
 
 
109955
 
CREATE INDEX shiphead_shipped_idx ON shiphead USING btree (shiphead_shipped);
109956
 
 
109957
 
 
109958
 
--
109959
 
--
109960
 
 
109961
 
CREATE INDEX shipitem_invcitem_id_idx ON shipitem USING btree (shipitem_invcitem_id);
109962
 
 
109963
 
 
109964
 
--
109965
 
--
109966
 
 
109967
 
CREATE INDEX shipitem_orderitem_id_idx ON shipitem USING btree (shipitem_orderitem_id);
109968
 
 
109969
 
 
109970
 
--
109971
 
--
109972
 
 
109973
 
CREATE INDEX shipitem_shiphead_id_idx ON shipitem USING btree (shipitem_shiphead_id);
109974
 
 
109975
 
 
109976
 
--
109977
 
--
109978
 
 
109979
 
CREATE INDEX sltrans_sequence_idx ON sltrans USING btree (sltrans_sequence);
109980
 
 
109981
 
 
109982
 
--
109983
 
--
109984
 
 
109985
 
CREATE INDEX sltrans_sltrans_accnt_id_idx ON sltrans USING btree (sltrans_accnt_id);
109986
 
 
109987
 
 
109988
 
--
109989
 
--
109990
 
 
109991
 
CREATE INDEX sltrans_sltrans_date_idx ON sltrans USING btree (sltrans_date);
109992
 
 
109993
 
 
109994
 
--
109995
 
--
109996
 
 
109997
 
CREATE INDEX sltrans_sltrans_journalnumber_idx ON sltrans USING btree (sltrans_journalnumber);
109998
 
 
109999
 
 
110000
 
--
110001
 
--
110002
 
 
110003
 
CREATE UNIQUE INDEX subaccnttype_code_idx ON subaccnttype USING btree (subaccnttype_code);
110004
 
 
110005
 
 
110006
 
--
110007
 
--
110008
 
 
110009
 
CREATE INDEX taxhist_taxhist_parent_id_idx ON taxhist USING btree (taxhist_parent_id);
110010
 
 
110011
 
 
110012
 
--
110013
 
--
110014
 
 
110015
 
CREATE INDEX taxhist_taxhist_parent_type_idx ON taxhist USING btree (taxhist_parent_id, taxhist_taxtype_id);
110016
 
 
110017
 
 
110018
 
--
110019
 
--
110020
 
 
110021
 
CREATE INDEX taxhist_taxhist_taxtype_id_idx ON taxhist USING btree (taxhist_taxtype_id);
110022
 
 
110023
 
 
110024
 
--
110025
 
--
110026
 
 
110027
 
CREATE INDEX todoitem_todoitem_username_idx ON todoitem USING btree (todoitem_username);
110028
 
 
110029
 
 
110030
 
--
110031
 
--
110032
 
 
110033
 
CREATE UNIQUE INDEX trialbal_accnt_period_idx ON trialbal USING btree (trialbal_accnt_id, trialbal_period_id);
110034
 
 
110035
 
 
110036
 
--
110037
 
--
110038
 
 
110039
 
CREATE INDEX usrpref_userpref_name_idx ON usrpref USING btree (usrpref_name);
110040
 
 
110041
 
 
110042
 
--
110043
 
--
110044
 
 
110045
 
CREATE UNIQUE INDEX vend_number_idx ON vendinfo USING btree (vend_number);
110046
 
 
110047
 
 
110048
 
--
110049
 
--
110050
 
 
110051
 
CREATE INDEX voheadtax_taxhist_parent_id_idx ON voheadtax USING btree (taxhist_parent_id);
110052
 
 
110053
 
 
110054
 
--
110055
 
--
110056
 
 
110057
 
CREATE INDEX voheadtax_taxhist_parent_type_idx ON voheadtax USING btree (taxhist_parent_id, taxhist_taxtype_id);
110058
 
 
110059
 
 
110060
 
--
110061
 
--
110062
 
 
110063
 
CREATE INDEX voheadtax_taxhist_taxtype_id_idx ON voheadtax USING btree (taxhist_taxtype_id);
110064
 
 
110065
 
 
110066
 
--
110067
 
--
110068
 
 
110069
 
CREATE INDEX voitemtax_taxhist_parent_id_idx ON voitemtax USING btree (taxhist_parent_id);
110070
 
 
110071
 
 
110072
 
--
110073
 
--
110074
 
 
110075
 
CREATE INDEX voitemtax_taxhist_parent_type_idx ON voitemtax USING btree (taxhist_parent_id, taxhist_taxtype_id);
110076
 
 
110077
 
 
110078
 
--
110079
 
--
110080
 
 
110081
 
CREATE INDEX voitemtax_taxhist_taxtype_id_idx ON voitemtax USING btree (taxhist_taxtype_id);
110082
 
 
110083
 
 
110084
 
--
110085
 
--
110086
 
 
110087
 
CREATE INDEX warehous_code_key ON whsinfo USING btree (warehous_code bpchar_ops);
110088
 
 
110089
 
 
110090
 
--
110091
 
--
110092
 
 
110093
 
CREATE INDEX wo_duedate ON wo USING btree (wo_duedate);
110094
 
 
110095
 
 
110096
 
--
110097
 
--
110098
 
 
110099
 
CREATE INDEX wo_itemsite_id ON wo USING btree (wo_itemsite_id);
110100
 
 
110101
 
 
110102
 
--
110103
 
--
110104
 
 
110105
 
CREATE INDEX wo_ordtype ON wo USING btree (wo_ordtype);
110106
 
 
110107
 
 
110108
 
--
110109
 
--
110110
 
 
110111
 
CREATE INDEX wo_startdate ON wo USING btree (wo_startdate);
110112
 
 
110113
 
 
110114
 
--
110115
 
--
110116
 
 
110117
 
CREATE INDEX wo_status ON wo USING btree (wo_status);
110118
 
 
110119
 
 
110120
 
--
110121
 
--
110122
 
 
110123
 
CREATE INDEX womatl_itemsite_id_key ON womatl USING btree (womatl_itemsite_id);
110124
 
 
110125
 
 
110126
 
--
110127
 
--
110128
 
 
110129
 
CREATE INDEX womatl_wo_id_key ON womatl USING btree (womatl_wo_id);
110130
 
 
110131
 
 
110132
 
SET search_path = te, pg_catalog;
110133
 
 
110134
 
--
110135
 
--
110136
 
 
110137
 
CREATE INDEX teitem_teitem_tehead_id_idx ON teitem USING btree (teitem_tehead_id);
110138
 
 
110139
 
 
110140
 
SET search_path = api, pg_catalog;
110141
 
 
110142
 
--
110143
 
--
110144
 
 
110145
 
CREATE RULE "_DELETE" AS ON DELETE TO salesline DO INSTEAD DELETE FROM public.coitem WHERE (((coitem.coitem_cohead_id = public.getcoheadid((old.order_number)::text)) AND (((coitem.coitem_linenumber)::character varying)::text = (old.line_number)::text)) AND (coitem.coitem_subnumber = 0));
110146
 
 
110147
 
 
110148
 
--
110149
 
--
110150
 
 
110151
 
CREATE RULE "_DELETE" AS ON DELETE TO apmemo DO INSTEAD NOTHING;
110152
 
 
110153
 
 
110154
 
--
110155
 
--
110156
 
 
110157
 
CREATE RULE "_DELETE" AS ON DELETE TO armemo DO INSTEAD NOTHING;
110158
 
 
110159
 
 
110160
 
--
110161
 
--
110162
 
 
110163
 
CREATE RULE "_DELETE" AS ON DELETE TO physinvcount DO INSTEAD NOTHING;
110164
 
 
110165
 
 
110166
 
--
110167
 
--
110168
 
 
110169
 
CREATE RULE "_DELETE" AS ON DELETE TO account DO INSTEAD DELETE FROM public.crmacct WHERE (crmacct.crmacct_number = (old.account_number)::text);
110170
 
 
110171
 
 
110172
 
--
110173
 
--
110174
 
 
110175
 
CREATE RULE "_DELETE" AS ON DELETE TO accountchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'CRMACCT'::text) AND (charass.charass_target_id = public.getcrmacctid((old.account_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CRMACCT'::text)));
110176
 
 
110177
 
 
110178
 
--
110179
 
--
110180
 
 
110181
 
CREATE RULE "_DELETE" AS ON DELETE TO accountcomment DO INSTEAD NOTHING;
110182
 
 
110183
 
 
110184
 
--
110185
 
--
110186
 
 
110187
 
CREATE RULE "_DELETE" AS ON DELETE TO accountfile DO INSTEAD DELETE FROM public.url WHERE ((((url.url_source_id = public.getcrmacctid(old.account_number)) AND (url.url_source = 'CRMA'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url));
110188
 
 
110189
 
 
110190
 
--
110191
 
--
110192
 
 
110193
 
CREATE RULE "_DELETE" AS ON DELETE TO accountimage DO INSTEAD DELETE FROM public.imageass WHERE (((imageass.imageass_source_id = public.getcrmacctid(old.account_number)) AND (imageass.imageass_source = 'CRMA'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name)));
110194
 
 
110195
 
 
110196
 
--
110197
 
--
110198
 
 
110199
 
CREATE RULE "_DELETE" AS ON DELETE TO address DO INSTEAD SELECT public.deleteaddress(public.getaddrid((old.address_number)::text)) AS deleteaddress;
110200
 
 
110201
 
 
110202
 
--
110203
 
--
110204
 
 
110205
 
CREATE RULE "_DELETE" AS ON DELETE TO addresschar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'ADDR'::text) AND (charass.charass_target_id = public.getaddrid((old.address_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'ADDR'::text)));
110206
 
 
110207
 
 
110208
 
--
110209
 
--
110210
 
 
110211
 
CREATE RULE "_DELETE" AS ON DELETE TO addresscomment DO INSTEAD NOTHING;
110212
 
 
110213
 
 
110214
 
--
110215
 
--
110216
 
 
110217
 
CREATE RULE "_DELETE" AS ON DELETE TO bom DO INSTEAD SELECT public.deletebom(public.getitemid((old.item_number)::text)) AS deletebom;
110218
 
 
110219
 
 
110220
 
--
110221
 
--
110222
 
 
110223
 
CREATE RULE "_DELETE" AS ON DELETE TO bomitem DO INSTEAD DELETE FROM public.bomitem WHERE ((bomitem.bomitem_id = old.id) AND public.fetchmetricbool('AllowBOMItemDelete'::text));
110224
 
 
110225
 
 
110226
 
--
110227
 
--
110228
 
 
110229
 
CREATE RULE "_DELETE" AS ON DELETE TO bomitemcomment DO INSTEAD NOTHING;
110230
 
 
110231
 
 
110232
 
--
110233
 
--
110234
 
 
110235
 
CREATE RULE "_DELETE" AS ON DELETE TO bomitemsubstitute DO INSTEAD DELETE FROM public.bomitemsub WHERE ((bomitemsub.bomitemsub_bomitem_id = old.bomitem_id) AND (bomitemsub.bomitemsub_item_id = public.getitemid((old.substitute_item_number)::text)));
110236
 
 
110237
 
 
110238
 
--
110239
 
--
110240
 
 
110241
 
CREATE RULE "_DELETE" AS ON DELETE TO budget DO INSTEAD DELETE FROM public.budghead WHERE (budghead.budghead_name = old.name);
110242
 
 
110243
 
 
110244
 
--
110245
 
--
110246
 
 
110247
 
CREATE RULE "_DELETE" AS ON DELETE TO budgetentry DO INSTEAD DELETE FROM public.budgitem WHERE (((budgitem.budgitem_budghead_id = public.getbudgheadid(old.name)) AND (budgitem.budgitem_period_id = public.getperiodid(old.period_start))) AND (budgitem.budgitem_accnt_id = public.getglaccntid(old.account)));
110248
 
 
110249
 
 
110250
 
--
110251
 
--
110252
 
 
110253
 
CREATE RULE "_DELETE" AS ON DELETE TO cashreceipt DO INSTEAD SELECT public.deletecashrcpt(cashrcpt.cashrcpt_id) AS deletecashrcpt FROM public.cashrcpt WHERE (cashrcpt.cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text));
110254
 
 
110255
 
 
110256
 
--
110257
 
--
110258
 
 
110259
 
CREATE RULE "_DELETE" AS ON DELETE TO cashreceiptapply DO INSTEAD DELETE FROM public.cashrcptitem WHERE ((cashrcptitem.cashrcptitem_cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)) AND (cashrcptitem.cashrcptitem_aropen_id = public.getaropenid((old.customer_number)::text, (old.doc_type)::bpchar, (old.doc_number)::text)));
110260
 
 
110261
 
 
110262
 
--
110263
 
--
110264
 
 
110265
 
CREATE RULE "_DELETE" AS ON DELETE TO cashreceiptapplymisc DO INSTEAD DELETE FROM public.cashrcptmisc WHERE ((cashrcptmisc.cashrcptmisc_cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)) AND (cashrcptmisc.cashrcptmisc_accnt_id = public.getglaccntid((old.account)::text)));
110266
 
 
110267
 
 
110268
 
--
110269
 
--
110270
 
 
110271
 
CREATE RULE "_DELETE" AS ON DELETE TO contact DO INSTEAD DELETE FROM public.cntct WHERE (cntct.cntct_number = (old.contact_number)::text);
110272
 
 
110273
 
 
110274
 
--
110275
 
--
110276
 
 
110277
 
CREATE RULE "_DELETE" AS ON DELETE TO contactchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'CNTCT'::text) AND (charass.charass_target_id = public.getcntctid(old.contact_number))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CNTCT'::text)));
110278
 
 
110279
 
 
110280
 
--
110281
 
--
110282
 
 
110283
 
CREATE RULE "_DELETE" AS ON DELETE TO contactcomment DO INSTEAD NOTHING;
110284
 
 
110285
 
 
110286
 
--
110287
 
--
110288
 
 
110289
 
CREATE RULE "_DELETE" AS ON DELETE TO creditmemo DO INSTEAD SELECT public.deletecreditmemo(cmhead.cmhead_id) AS deletecreditmemo FROM public.cmhead WHERE ((cmhead.cmhead_number = old.memo_number) AND (cmhead.cmhead_posted = false));
110290
 
 
110291
 
 
110292
 
--
110293
 
--
110294
 
 
110295
 
CREATE RULE "_DELETE" AS ON DELETE TO creditmemoline DO INSTEAD DELETE FROM public.cmitem WHERE ((cmitem.cmitem_cmhead_id = public.getcmheadid(old.memo_number, false)) AND (cmitem.cmitem_linenumber = old.line_number));
110296
 
 
110297
 
 
110298
 
--
110299
 
--
110300
 
 
110301
 
CREATE RULE "_DELETE" AS ON DELETE TO custchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'C'::text) AND (charass.charass_target_id = public.getcustid((old.customer_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'C'::text)));
110302
 
 
110303
 
 
110304
 
--
110305
 
--
110306
 
 
110307
 
CREATE RULE "_DELETE" AS ON DELETE TO custcomment DO INSTEAD NOTHING;
110308
 
 
110309
 
 
110310
 
--
110311
 
--
110312
 
 
110313
 
CREATE RULE "_DELETE" AS ON DELETE TO custcreditcard DO INSTEAD NOTHING;
110314
 
 
110315
 
 
110316
 
--
110317
 
--
110318
 
 
110319
 
CREATE RULE "_DELETE" AS ON DELETE TO customer DO INSTEAD DELETE FROM public.custinfo WHERE (custinfo.cust_number = (old.customer_number)::text);
110320
 
 
110321
 
 
110322
 
--
110323
 
--
110324
 
 
110325
 
CREATE RULE "_DELETE" AS ON DELETE TO customertype DO INSTEAD DELETE FROM public.custtype WHERE (custtype.custtype_code = (old.code)::text);
110326
 
 
110327
 
 
110328
 
--
110329
 
--
110330
 
 
110331
 
CREATE RULE "_DELETE" AS ON DELETE TO customertypechar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'CT'::text) AND (charass.charass_target_id = public.getcusttypeid((old.customer_type)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CT'::text)));
110332
 
 
110333
 
 
110334
 
--
110335
 
--
110336
 
 
110337
 
CREATE RULE "_DELETE" AS ON DELETE TO custshipto DO INSTEAD SELECT public.deleteshipto(public.getshiptoid((old.customer_number)::text, (old.shipto_number)::text)) AS deleteshipto;
110338
 
 
110339
 
 
110340
 
--
110341
 
--
110342
 
 
110343
 
CREATE RULE "_DELETE" AS ON DELETE TO custtax DO INSTEAD DELETE FROM public.taxreg WHERE (((taxreg.taxreg_rel_type = 'C'::bpchar) AND (taxreg.taxreg_rel_id = public.getcustid((old.customer_number)::text))) AND (taxreg.taxreg_taxauth_id = public.gettaxauthid((old.tax_authority)::text)));
110344
 
 
110345
 
 
110346
 
--
110347
 
--
110348
 
 
110349
 
CREATE RULE "_DELETE" AS ON DELETE TO employee DO INSTEAD DELETE FROM public.emp WHERE (emp.emp_code = (old.code)::text);
110350
 
 
110351
 
 
110352
 
--
110353
 
--
110354
 
 
110355
 
CREATE RULE "_DELETE" AS ON DELETE TO employeechar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'EMP'::text) AND (charass.charass_target_id = public.getempid((old.employee_code)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'EMP'::text)));
110356
 
 
110357
 
 
110358
 
--
110359
 
--
110360
 
 
110361
 
CREATE RULE "_DELETE" AS ON DELETE TO employeecomment DO INSTEAD NOTHING;
110362
 
 
110363
 
 
110364
 
--
110365
 
--
110366
 
 
110367
 
CREATE RULE "_DELETE" AS ON DELETE TO extshipmaint DO INSTEAD DELETE FROM public.shipdata WHERE ((((shipdata.shipdata_cohead_number = (old.so_number)::text) AND (shipdata.shipdata_shiphead_number = (old.shipment_number)::text)) AND (shipdata.shipdata_shipper = (old.shipper)::text)) AND (shipdata.shipdata_cosmisc_packnum_tracknum = (old.package_tracking_number)::text));
110368
 
 
110369
 
 
110370
 
--
110371
 
--
110372
 
 
110373
 
CREATE RULE "_DELETE" AS ON DELETE TO freightpricingscheduleitem DO INSTEAD DELETE FROM public.ipsfreight WHERE (((((((((ipsfreight.ipsfreight_ipshead_id = public.getipsheadid((old.pricing_schedule)::text)) AND (ipsfreight.ipsfreight_qtybreak = old.qty_break)) AND (ipsfreight.ipsfreight_price = old.price)) AND ((ipsfreight.ipsfreight_type)::text = CASE WHEN (old.price_type = 'Flat Rate'::text) THEN 'F'::text WHEN (old.price_type = 'Price Per UOM'::text) THEN 'P'::text ELSE NULL::text END)) AND ((ipsfreight.ipsfreight_warehous_id IS NULL) AND (old.from_site = 'Any'::text))) OR ((ipsfreight.ipsfreight_warehous_id = CASE WHEN (old.from_site = 'Any'::text) THEN 0 ELSE public.getwarehousid(old.from_site, 'All'::text) END) AND ((ipsfreight.ipsfreight_shipzone_id IS NULL) AND (old.to_shipzone = 'Any'::text)))) OR ((ipsfreight.ipsfreight_shipzone_id = CASE WHEN (old.to_shipzone = 'Any'::text) THEN 0 ELSE public.getshipzoneid(old.to_shipzone) END) AND ((ipsfreight.ipsfreight_freightclass_id IS NULL) AND (old.freight_class = 'Any'::text)))) OR ((ipsfreight.ipsfreight_freightclass_id = CASE WHEN (old.freight_class = 'Any'::text) THEN 0 ELSE public.getfreightclassid(old.freight_class) END) AND ((ipsfreight.ipsfreight_shipvia IS NULL) AND (old.ship_via = 'Any'::text)))) OR (ipsfreight.ipsfreight_shipvia = old.ship_via));
110374
 
 
110375
 
 
110376
 
--
110377
 
--
110378
 
 
110379
 
CREATE RULE "_DELETE" AS ON DELETE TO incident DO INSTEAD NOTHING;
110380
 
 
110381
 
 
110382
 
--
110383
 
--
110384
 
 
110385
 
CREATE RULE "_DELETE" AS ON DELETE TO incidentchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'INCDT'::text) AND (charass.charass_target_id = public.getincidentid(old.incident_number))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'INCDT'::text)));
110386
 
 
110387
 
 
110388
 
--
110389
 
--
110390
 
 
110391
 
CREATE RULE "_DELETE" AS ON DELETE TO incidentcomment DO INSTEAD NOTHING;
110392
 
 
110393
 
 
110394
 
--
110395
 
--
110396
 
 
110397
 
CREATE RULE "_DELETE" AS ON DELETE TO incidentfile DO INSTEAD DELETE FROM public.url WHERE ((((url.url_source_id = public.getincidentid(old.incident_number)) AND (url.url_source = 'INCDT'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url));
110398
 
 
110399
 
 
110400
 
--
110401
 
--
110402
 
 
110403
 
CREATE RULE "_DELETE" AS ON DELETE TO incidentimage DO INSTEAD DELETE FROM public.imageass WHERE (((imageass.imageass_source_id = public.getincidentid(old.incident_number)) AND (imageass.imageass_source = 'INCDT'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name)));
110404
 
 
110405
 
 
110406
 
--
110407
 
--
110408
 
 
110409
 
CREATE RULE "_DELETE" AS ON DELETE TO invoice DO INSTEAD SELECT public.deleteinvoice(invchead.invchead_id) AS deleteinvoice FROM public.invchead WHERE ((invchead.invchead_invcnumber = old.invoice_number) AND (invchead.invchead_posted = false));
110410
 
 
110411
 
 
110412
 
--
110413
 
--
110414
 
 
110415
 
CREATE RULE "_DELETE" AS ON DELETE TO invoiceline DO INSTEAD DELETE FROM public.invcitem WHERE (invcitem.invcitem_invchead_id = (SELECT invchead.invchead_id FROM public.invchead WHERE ((invchead.invchead_invcnumber = old.invoice_number) AND (invchead.invchead_posted = false))));
110416
 
 
110417
 
 
110418
 
--
110419
 
--
110420
 
 
110421
 
CREATE RULE "_DELETE" AS ON DELETE TO item DO INSTEAD SELECT public.deleteitem(public.getitemid((old.item_number)::text)) AS deleteitem;
110422
 
 
110423
 
 
110424
 
--
110425
 
--
110426
 
 
110427
 
CREATE RULE "_DELETE" AS ON DELETE TO itemalias DO INSTEAD DELETE FROM public.itemalias WHERE ((itemalias.itemalias_item_id = public.getitemid((old.item_number)::text)) AND (itemalias.itemalias_number = old.alias_number));
110428
 
 
110429
 
 
110430
 
--
110431
 
--
110432
 
 
110433
 
CREATE RULE "_DELETE" AS ON DELETE TO itemchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'I'::text) AND (charass.charass_target_id = public.getitemid((old.item_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'I'::text)));
110434
 
 
110435
 
 
110436
 
--
110437
 
--
110438
 
 
110439
 
CREATE RULE "_DELETE" AS ON DELETE TO itemcomment DO INSTEAD NOTHING;
110440
 
 
110441
 
 
110442
 
--
110443
 
--
110444
 
 
110445
 
CREATE RULE "_DELETE" AS ON DELETE TO itemcost DO INSTEAD SELECT public.deleteitemcost(public.getitemid((old.item_number)::text), public.getcostelemid((old.costing_element)::text)) AS deleteitemcost;
110446
 
 
110447
 
 
110448
 
--
110449
 
--
110450
 
 
110451
 
CREATE RULE "_DELETE" AS ON DELETE TO itemfile DO INSTEAD DELETE FROM public.url WHERE ((((url.url_source_id = public.getitemid((old.item_number)::text)) AND (url.url_source = 'I'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url));
110452
 
 
110453
 
 
110454
 
--
110455
 
--
110456
 
 
110457
 
CREATE RULE "_DELETE" AS ON DELETE TO itemimage DO INSTEAD DELETE FROM public.imageass WHERE (((imageass.imageass_source_id = public.getitemid((old.item_number)::text)) AND (imageass.imageass_source = 'I'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name)));
110458
 
 
110459
 
 
110460
 
--
110461
 
--
110462
 
 
110463
 
CREATE RULE "_DELETE" AS ON DELETE TO itemsite DO INSTEAD SELECT public.deleteitemsite(public.getitemsiteid((old.site)::text, (old.item_number)::text)) AS deleteitemsite;
110464
 
 
110465
 
 
110466
 
--
110467
 
--
110468
 
 
110469
 
CREATE RULE "_DELETE" AS ON DELETE TO itemsitecomment DO INSTEAD NOTHING;
110470
 
 
110471
 
 
110472
 
--
110473
 
--
110474
 
 
110475
 
CREATE RULE "_DELETE" AS ON DELETE TO itemsource DO INSTEAD DELETE FROM public.itemsrc WHERE (((((itemsrc.itemsrc_item_id = public.getitemid((old.item_number)::text)) AND (itemsrc.itemsrc_vend_id = public.getvendid((old.vendor)::text))) AND (itemsrc.itemsrc_vend_item_number = old.vendor_item_number)) AND (itemsrc.itemsrc_manuf_name = old.manufacturer_name)) AND (itemsrc.itemsrc_manuf_item_number = old.manufacturer_item_number));
110476
 
 
110477
 
 
110478
 
--
110479
 
--
110480
 
 
110481
 
CREATE RULE "_DELETE" AS ON DELETE TO itemsourceprice DO INSTEAD DELETE FROM public.itemsrcp WHERE ((itemsrcp.itemsrcp_itemsrc_id = public.getitemsrcid((old.item_number)::text, (old.vendor)::text)) AND (itemsrcp.itemsrcp_qtybreak = old.qty_break));
110482
 
 
110483
 
 
110484
 
--
110485
 
--
110486
 
 
110487
 
CREATE RULE "_DELETE" AS ON DELETE TO itemsubstitute DO INSTEAD DELETE FROM public.itemsub WHERE ((itemsub.itemsub_parent_item_id = public.getitemid((old.root_item_number)::text)) AND (itemsub.itemsub_sub_item_id = public.getitemid((old.substitute_item_number)::text)));
110488
 
 
110489
 
 
110490
 
--
110491
 
--
110492
 
 
110493
 
CREATE RULE "_DELETE" AS ON DELETE TO itemtaxtype DO INSTEAD DELETE FROM public.itemtax WHERE (((itemtax.itemtax_item_id = public.getitemid((old.item_number)::text)) AND CASE WHEN ((old.tax_zone)::text = 'Any'::text) THEN (itemtax.itemtax_taxzone_id IS NULL) ELSE (itemtax.itemtax_taxzone_id = public.gettaxzoneid((old.tax_zone)::text)) END) AND (itemtax.itemtax_taxtype_id = public.gettaxtypeid(old.tax_type)));
110494
 
 
110495
 
 
110496
 
--
110497
 
--
110498
 
 
110499
 
CREATE RULE "_DELETE" AS ON DELETE TO itemuomconversion DO INSTEAD SELECT public.deleteitemuomconv(itemuomconv.itemuomconv_id) AS deleteitemuomconv FROM public.itemuomconv WHERE ((itemuomconv.itemuomconv_item_id = public.getitemid((old.item_number)::text)) AND (((itemuomconv.itemuomconv_from_uom_id = public.getuomid((old.uom)::text)) AND (itemuomconv.itemuomconv_to_uom_id = public.getuomid(old.per_uom))) OR ((itemuomconv.itemuomconv_from_uom_id = public.getuomid(old.per_uom)) AND (itemuomconv.itemuomconv_to_uom_id = public.getuomid((old.uom)::text)))));
110500
 
 
110501
 
 
110502
 
--
110503
 
--
110504
 
 
110505
 
CREATE RULE "_DELETE" AS ON DELETE TO journalentry DO INSTEAD NOTHING;
110506
 
 
110507
 
 
110508
 
--
110509
 
--
110510
 
 
110511
 
CREATE RULE "_DELETE" AS ON DELETE TO location DO INSTEAD DELETE FROM public.location WHERE ((location.location_warehous_id = public.getwarehousid((old.site)::text, 'ACTIVE'::text)) AND (location.location_name = (old.location)::text));
110512
 
 
110513
 
 
110514
 
--
110515
 
--
110516
 
 
110517
 
CREATE RULE "_DELETE" AS ON DELETE TO misccounttag DO INSTEAD NOTHING;
110518
 
 
110519
 
 
110520
 
--
110521
 
--
110522
 
 
110523
 
CREATE RULE "_DELETE" AS ON DELETE TO pricingschedule DO INSTEAD DELETE FROM public.ipshead WHERE ((old.name)::text = ipshead.ipshead_name);
110524
 
 
110525
 
 
110526
 
--
110527
 
--
110528
 
 
110529
 
CREATE RULE "_DELETE" AS ON DELETE TO pricingscheduleassign DO INSTEAD DELETE FROM public.ipsass WHERE ((((((ipsass.ipsass_ipshead_id = public.getipsheadid((old.pricing_schedule)::text)) AND (ipsass.ipsass_cust_id = CASE WHEN ((old.customer_number)::text = 'Any'::text) THEN (-1) ELSE public.getcustid((old.customer_number)::text) END)) AND (ipsass.ipsass_custtype_id = CASE WHEN ((old.customer_type)::text = 'N/A'::text) THEN (-1) ELSE public.getcusttypeid((old.customer_type)::text) END)) AND (ipsass.ipsass_custtype_pattern = (old.customer_type_pattern)::text)) AND (ipsass.ipsass_shipto_id = CASE WHEN ((old.customer_shipto)::text = 'Any'::text) THEN (-1) ELSE public.getshiptoid((old.customer_number)::text, (old.customer_shipto)::text) END)) AND (ipsass.ipsass_shipto_pattern = (old.customer_shipto_pattern)::text));
110530
 
 
110531
 
 
110532
 
--
110533
 
--
110534
 
 
110535
 
CREATE RULE "_DELETE" AS ON DELETE TO pricingscheduleitem DO INSTEAD SELECT CASE WHEN ((old.type)::text = 'Item'::text) THEN public.deleteipsitem(public.getipsitemid((old.pricing_schedule)::text, (old.item_number)::text, old.qty_break, (old.qty_uom)::text, (old.price_uom)::text)) WHEN ((old.type)::text = 'Product Category'::text) THEN public.deleteipsprodcat(public.getipsprodcatid((old.pricing_schedule)::text, (old.product_category)::text, old.qty_break)) ELSE NULL::integer END AS result;
110536
 
 
110537
 
 
110538
 
--
110539
 
--
110540
 
 
110541
 
CREATE RULE "_DELETE" AS ON DELETE TO pricingscheduleitemchar DO INSTEAD DELETE FROM public.ipsitemchar WHERE (((ipsitemchar.ipsitemchar_ipsitem_id = public.getipsitemid((old.pricing_schedule)::text, (old.item_number)::text, old.qty_break, (old.qty_uom)::text, (old.price_uom)::text)) AND (ipsitemchar.ipsitemchar_char_id = public.getcharid((old.characteristic)::text, 'I'::text))) AND (ipsitemchar.ipsitemchar_value = (old.value)::text));
110542
 
 
110543
 
 
110544
 
--
110545
 
--
110546
 
 
110547
 
CREATE RULE "_DELETE" AS ON DELETE TO project DO INSTEAD SELECT public.deleteproject(public.getprjid(old.number)) AS deleteproject;
110548
 
 
110549
 
 
110550
 
--
110551
 
--
110552
 
 
110553
 
CREATE RULE "_DELETE" AS ON DELETE TO projectcomment DO INSTEAD NOTHING;
110554
 
 
110555
 
 
110556
 
--
110557
 
--
110558
 
 
110559
 
CREATE RULE "_DELETE" AS ON DELETE TO prospect DO INSTEAD DELETE FROM public.prospect WHERE (prospect.prospect_number = (old.prospect_number)::text);
110560
 
 
110561
 
 
110562
 
--
110563
 
--
110564
 
 
110565
 
CREATE RULE "_DELETE" AS ON DELETE TO purchaseline DO INSTEAD DELETE FROM public.poitem WHERE (poitem.poitem_id = public.getpoitemid((old.order_number)::text, old.line_number));
110566
 
 
110567
 
 
110568
 
--
110569
 
--
110570
 
 
110571
 
CREATE RULE "_DELETE" AS ON DELETE TO purchaselinechar DO INSTEAD NOTHING;
110572
 
 
110573
 
 
110574
 
--
110575
 
--
110576
 
 
110577
 
CREATE RULE "_DELETE" AS ON DELETE TO purchaselinecomment DO INSTEAD NOTHING;
110578
 
 
110579
 
 
110580
 
--
110581
 
--
110582
 
 
110583
 
CREATE RULE "_DELETE" AS ON DELETE TO purchaseorder DO INSTEAD SELECT public.deletepo(pohead.pohead_id) AS deletepo FROM public.pohead WHERE (pohead.pohead_number = (old.order_number)::text);
110584
 
 
110585
 
 
110586
 
--
110587
 
--
110588
 
 
110589
 
CREATE RULE "_DELETE" AS ON DELETE TO purchaseordercomment DO INSTEAD NOTHING;
110590
 
 
110591
 
 
110592
 
--
110593
 
--
110594
 
 
110595
 
CREATE RULE "_DELETE" AS ON DELETE TO quote DO INSTEAD SELECT public.deletequote(quhead.quhead_id, (old.quote_number)::text) AS deletequote FROM public.quhead WHERE (quhead.quhead_number = (old.quote_number)::text);
110596
 
 
110597
 
 
110598
 
--
110599
 
--
110600
 
 
110601
 
CREATE RULE "_DELETE" AS ON DELETE TO quotecomment DO INSTEAD NOTHING;
110602
 
 
110603
 
 
110604
 
--
110605
 
--
110606
 
 
110607
 
CREATE RULE "_DELETE" AS ON DELETE TO quoteline DO INSTEAD DELETE FROM public.quitem WHERE ((quitem.quitem_quhead_id = public.getquoteid(old.quote_number)) AND (quitem.quitem_linenumber = old.line_number));
110608
 
 
110609
 
 
110610
 
--
110611
 
--
110612
 
 
110613
 
CREATE RULE "_DELETE" AS ON DELETE TO quotelinechar DO INSTEAD NOTHING;
110614
 
 
110615
 
 
110616
 
--
110617
 
--
110618
 
 
110619
 
CREATE RULE "_DELETE" AS ON DELETE TO quotelinecomment DO INSTEAD NOTHING;
110620
 
 
110621
 
 
110622
 
--
110623
 
--
110624
 
 
110625
 
CREATE RULE "_DELETE" AS ON DELETE TO saleshistory DO INSTEAD NOTHING;
110626
 
 
110627
 
 
110628
 
--
110629
 
--
110630
 
 
110631
 
CREATE RULE "_DELETE" AS ON DELETE TO saleslinechar DO INSTEAD NOTHING;
110632
 
 
110633
 
 
110634
 
--
110635
 
--
110636
 
 
110637
 
CREATE RULE "_DELETE" AS ON DELETE TO saleslinecomment DO INSTEAD NOTHING;
110638
 
 
110639
 
 
110640
 
--
110641
 
--
110642
 
 
110643
 
CREATE RULE "_DELETE" AS ON DELETE TO salesorder DO INSTEAD SELECT public.deleteso(cohead.cohead_id, (old.order_number)::text) AS deleteso FROM public.cohead WHERE (cohead.cohead_number = (old.order_number)::text);
110644
 
 
110645
 
 
110646
 
--
110647
 
--
110648
 
 
110649
 
CREATE RULE "_DELETE" AS ON DELETE TO salesordercomment DO INSTEAD NOTHING;
110650
 
 
110651
 
 
110652
 
--
110653
 
--
110654
 
 
110655
 
CREATE RULE "_DELETE" AS ON DELETE TO salesrep DO INSTEAD DELETE FROM public.salesrep WHERE (salesrep.salesrep_number = (old.number)::text);
110656
 
 
110657
 
 
110658
 
--
110659
 
--
110660
 
 
110661
 
CREATE RULE "_DELETE" AS ON DELETE TO site DO NOTHING;
110662
 
 
110663
 
 
110664
 
--
110665
 
--
110666
 
 
110667
 
CREATE RULE "_DELETE" AS ON DELETE TO sitezone DO INSTEAD DELETE FROM public.whsezone WHERE ((whsezone.whsezone_warehous_id = public.getwarehousid((old.site)::text, 'ACTIVE'::text)) AND (whsezone.whsezone_name = (old.name)::text));
110668
 
 
110669
 
 
110670
 
--
110671
 
--
110672
 
 
110673
 
CREATE RULE "_DELETE" AS ON DELETE TO task DO INSTEAD DELETE FROM public.prjtask WHERE ((prjtask.prjtask_prj_id = public.getprjid(old.project_number)) AND (prjtask.prjtask_number = old.number));
110674
 
 
110675
 
 
110676
 
--
110677
 
--
110678
 
 
110679
 
CREATE RULE "_DELETE" AS ON DELETE TO taskcomment DO INSTEAD NOTHING;
110680
 
 
110681
 
 
110682
 
--
110683
 
--
110684
 
 
110685
 
CREATE RULE "_DELETE" AS ON DELETE TO todo DO INSTEAD SELECT public.deletetodoitem(old.task_number) AS deletetodoitem;
110686
 
 
110687
 
 
110688
 
--
110689
 
--
110690
 
 
110691
 
CREATE RULE "_DELETE" AS ON DELETE TO vendor DO INSTEAD DELETE FROM public.vendinfo WHERE (vendinfo.vend_number = (old.vendor_number)::text);
110692
 
 
110693
 
 
110694
 
--
110695
 
--
110696
 
 
110697
 
CREATE RULE "_DELETE" AS ON DELETE TO vendoraddress DO INSTEAD SELECT public.deletevendoraddress(public.getvendaddrid((old.vendor_number)::text, (old.vendor_address_number)::text)) AS deletevendoraddress;
110698
 
 
110699
 
 
110700
 
--
110701
 
--
110702
 
 
110703
 
CREATE RULE "_DELETE" AS ON DELETE TO vendortype DO INSTEAD SELECT public.deletevendortype(public.getvendtypeid((old.code)::text)) AS deletevendortype;
110704
 
 
110705
 
 
110706
 
--
110707
 
--
110708
 
 
110709
 
CREATE RULE "_INSERT" AS ON INSERT TO salesline DO INSTEAD SELECT public.insertsalesline(new.*) AS insertsalesline;
110710
 
 
110711
 
 
110712
 
--
110713
 
--
110714
 
 
110715
 
CREATE RULE "_INSERT" AS ON INSERT TO apmemo DO INSTEAD SELECT public.insertapmemo(new.*) AS insertapmemo;
110716
 
 
110717
 
 
110718
 
--
110719
 
--
110720
 
 
110721
 
CREATE RULE "_INSERT" AS ON INSERT TO armemo DO INSTEAD SELECT public.insertarmemo(new.*) AS insertarmemo;
110722
 
 
110723
 
 
110724
 
--
110725
 
--
110726
 
 
110727
 
CREATE RULE "_INSERT" AS ON INSERT TO physinvcount DO INSTEAD SELECT insertphysinvcount(new.*) AS insertphysinvcount;
110728
 
 
110729
 
 
110730
 
--
110731
 
--
110732
 
 
110733
 
CREATE RULE "_INSERT" AS ON INSERT TO account DO INSTEAD INSERT INTO public.crmacct (crmacct_number, crmacct_parent_id, crmacct_name, crmacct_active, crmacct_type, crmacct_cntct_id_1, crmacct_cntct_id_2, crmacct_notes) VALUES (COALESCE(new.account_number, ((public.fetchcrmaccountnumber())::text)::character varying), public.getcrmacctid(new.parent_account), new.account_name, COALESCE(new.active, true), CASE WHEN (new.type = 'Individual'::text) THEN 'I'::text ELSE 'O'::text END, public.savecntct(public.getcntctid(new.primary_contact_number), new.primary_contact_number, public.saveaddr(public.getaddrid(new.primary_contact_address_number), new.primary_contact_address_number, new.primary_contact_address1, new.primary_contact_address2, new.primary_contact_address3, new.primary_contact_city, new.primary_contact_state, new.primary_contact_postalcode, new.primary_contact_country, new.primary_contact_address_change), new.primary_contact_honorific, new.primary_contact_first, new.primary_contact_middle, new.primary_contact_last, new.primary_contact_suffix, new.primary_contact_voice, NULL::text, new.primary_contact_fax, new.primary_contact_email, NULL::text, new.primary_contact_job_title, new.primary_contact_change), public.savecntct(public.getcntctid(new.secondary_contact_number), new.secondary_contact_number, public.saveaddr(public.getaddrid(new.secondary_contact_address_number), new.secondary_contact_address_number, new.secondary_contact_address1, new.secondary_contact_address2, new.secondary_contact_address3, new.secondary_contact_city, new.secondary_contact_state, new.secondary_contact_postalcode, new.secondary_contact_country, new.secondary_contact_address_change), new.secondary_contact_honorific, new.secondary_contact_first, new.secondary_contact_middle, new.secondary_contact_last, new.secondary_contact_suffix, new.secondary_contact_voice, NULL::text, new.secondary_contact_fax, new.secondary_contact_email, NULL::text, new.secondary_contact_job_title, new.secondary_contact_change), new.notes);
110734
 
 
110735
 
 
110736
 
--
110737
 
--
110738
 
 
110739
 
CREATE RULE "_INSERT" AS ON INSERT TO accountchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('CRMACCT'::text, public.getcrmacctid((new.account_number)::text), public.getcharid((new.characteristic)::text, 'CRMACCT'::text), new.value, false);
110740
 
 
110741
 
 
110742
 
--
110743
 
--
110744
 
 
110745
 
CREATE RULE "_INSERT" AS ON INSERT TO accountcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'CRMA'::text, public.getcrmacctid((new.account_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
110746
 
 
110747
 
 
110748
 
--
110749
 
--
110750
 
 
110751
 
CREATE RULE "_INSERT" AS ON INSERT TO accountfile DO INSTEAD INSERT INTO public.url (url_source_id, url_source, url_title, url_url) VALUES (public.getcrmacctid(new.account_number), 'CRMA'::text, new.title, new.url);
110752
 
 
110753
 
 
110754
 
--
110755
 
--
110756
 
 
110757
 
CREATE RULE "_INSERT" AS ON INSERT TO accountimage DO INSTEAD SELECT public.saveimageass('CRMA'::text, public.getcrmacctid(new.account_number), 'M'::bpchar, public.getimageid(new.image_name)) AS saveimageass;
110758
 
 
110759
 
 
110760
 
--
110761
 
--
110762
 
 
110763
 
CREATE RULE "_INSERT" AS ON INSERT TO address DO INSTEAD SELECT public.saveaddr(NULL::integer, (new.address_number)::text, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, COALESCE(new.active, true), new.notes, NULL::text) AS saveaddr;
110764
 
 
110765
 
 
110766
 
--
110767
 
--
110768
 
 
110769
 
CREATE RULE "_INSERT" AS ON INSERT TO addresschar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('ADDR'::text, public.getaddrid((new.address_number)::text), public.getcharid((new.characteristic)::text, 'ADDR'::text), new.value, false);
110770
 
 
110771
 
 
110772
 
--
110773
 
--
110774
 
 
110775
 
CREATE RULE "_INSERT" AS ON INSERT TO addresscomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'ADDR'::text, public.getaddrid((new.address_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
110776
 
 
110777
 
 
110778
 
--
110779
 
--
110780
 
 
110781
 
CREATE RULE "_INSERT" AS ON INSERT TO bom DO INSTEAD SELECT public.savebomhead(public.getitemid((new.item_number)::text), (new.revision)::text, new.revision_date, new.document_number, COALESCE(new.batch_size, (0)::numeric), new.total_qty_per) AS savebomhead;
110782
 
 
110783
 
 
110784
 
--
110785
 
--
110786
 
 
110787
 
CREATE RULE "_INSERT" AS ON INSERT TO bomitem DO INSTEAD SELECT public.createbomitem(COALESCE(new.id, (nextval('public.bomitem_bomitem_id_seq'::regclass))::integer), public.getitemid((new.bom_item_number)::text), public.getitemid(new.item_number), COALESCE(new.sequence_number, (SELECT (max(bomitem.bomitem_seqnumber) + 10) FROM public.bomitem(public.getitemid((new.bom_item_number)::text), COALESCE(public.getrevid('BOM'::text, (new.bom_item_number)::text, (new.bom_revision)::text))) bomitem(bomitem_id, bomitem_parent_item_id, bomitem_seqnumber, bomitem_item_id, bomitem_qtyper, bomitem_scrap, bomitem_status, bomitem_effective, bomitem_expires, bomitem_createwo, bomitem_issuemethod, bomitem_schedatwooper, bomitem_ecn, bomitem_moddate, bomitem_subtype, bomitem_uom_id, bomitem_rev_id, bomitem_booitem_seq_id, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref, bomitem_qtyfxd, bomitem_issuewo)), 10), (CASE WHEN (new.issue_method = 'Mixed'::text) THEN 'M'::text WHEN (new.issue_method = 'Push'::text) THEN 'S'::text WHEN (new.issue_method = 'Pull'::text) THEN 'L'::text ELSE public.fetchmetrictext('DefaultWomatlIssueMethod'::text) END)::bpchar, COALESCE(public.getuomid(new.issue_uom), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid(new.item_number)))), new.qty_per, new.scrap, CASE WHEN (new.effective = 'Always'::text) THEN public.startoftime() ELSE COALESCE((new.effective)::date, public.startoftime()) END, CASE WHEN (new.expires = 'Never'::text) THEN public.endoftime() ELSE COALESCE((new.expires)::date, public.endoftime()) END, COALESCE(new.create_child_wo, false), COALESCE(public.getbooitemseqid((new.bom_item_number)::text, new.used_at), (-1)), COALESCE(new.schedule_at_wo_operation, false), new.ecn_number, (CASE WHEN (new.substitutions = 'No'::text) THEN 'N'::text WHEN (new.substitutions = 'BOM-Defined'::text) THEN 'B'::text ELSE 'I'::text END)::bpchar, COALESCE(public.getrevid('BOM'::text, (new.bom_item_number)::text, (new.bom_revision)::text)), public.getcharid(new.characteristic, 'I'::text), new.value, new.notes, new.reference) AS createbomitem;
110788
 
 
110789
 
 
110790
 
--
110791
 
--
110792
 
 
110793
 
CREATE RULE "_INSERT" AS ON INSERT TO bomitemcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'BMI'::text, new.bomitem_id, COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
110794
 
 
110795
 
 
110796
 
--
110797
 
--
110798
 
 
110799
 
CREATE RULE "_INSERT" AS ON INSERT TO bomitemsubstitute DO INSTEAD INSERT INTO public.bomitemsub (bomitemsub_bomitem_id, bomitemsub_item_id, bomitemsub_uomratio, bomitemsub_rank) VALUES (new.bomitem_id, public.getitemid((new.substitute_item_number)::text), COALESCE(new.sub_parent_uom_ratio, (1)::numeric), COALESCE(new.ranking, 1));
110800
 
 
110801
 
 
110802
 
--
110803
 
--
110804
 
 
110805
 
CREATE RULE "_INSERT" AS ON INSERT TO budget DO INSTEAD INSERT INTO public.budghead (budghead_name, budghead_descrip) VALUES (new.name, new.description);
110806
 
 
110807
 
 
110808
 
--
110809
 
--
110810
 
 
110811
 
CREATE RULE "_INSERT" AS ON INSERT TO budgetentry DO INSTEAD INSERT INTO public.budgitem (budgitem_budghead_id, budgitem_period_id, budgitem_accnt_id, budgitem_amount) VALUES (public.getbudgheadid(new.name), public.getperiodid(new.period_start), public.getglaccntid(new.account), new.amount);
110812
 
 
110813
 
 
110814
 
--
110815
 
--
110816
 
 
110817
 
CREATE RULE "_INSERT" AS ON INSERT TO cashreceipt DO INSTEAD INSERT INTO public.cashrcpt (cashrcpt_cust_id, cashrcpt_number, cashrcpt_amount, cashrcpt_fundstype, cashrcpt_docnumber, cashrcpt_bankaccnt_id, cashrcpt_notes, cashrcpt_distdate, cashrcpt_salescat_id, cashrcpt_curr_id, cashrcpt_usecustdeposit) VALUES (public.getcustid((new.customer_number)::text), (SELECT public.fetchcashrcptnumber() AS fetchcashrcptnumber), COALESCE(new.amount_received, (0)::numeric), CASE WHEN ((new.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((new.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((new.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((new.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((new.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((new.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((new.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((new.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((new.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, COALESCE(new.check_document_number, ''::character varying), public.getbankaccntid(new.post_to), COALESCE(new.notes, ''::text), CASE WHEN (new.distribution_date > ''::text) THEN ((new.distribution_date)::date)::timestamp with time zone ELSE now() END, COALESCE(public.getsalescatid(new.sales_category), (-1)), public.getcurrid((new.currency)::text), CASE WHEN (new.apply_balance_as = 'Customer Deposit'::text) THEN true ELSE false END);
110818
 
 
110819
 
 
110820
 
--
110821
 
--
110822
 
 
110823
 
CREATE RULE "_INSERT" AS ON INSERT TO cashreceiptapply DO INSTEAD INSERT INTO public.cashrcptitem (cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount, cashrcptitem_discount) VALUES (public.getcashrcptid((new.customer_number)::text, CASE WHEN ((new.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((new.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((new.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((new.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((new.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((new.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((new.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((new.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((new.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (new.check_document_number)::text), public.getaropenid((new.customer_number)::text, (new.doc_type)::bpchar, (new.doc_number)::text), COALESCE(new.amount_to_apply, (0)::numeric), COALESCE(new.cashrcptitem_discount, (0)::numeric));
110824
 
 
110825
 
 
110826
 
--
110827
 
--
110828
 
 
110829
 
CREATE RULE "_INSERT" AS ON INSERT TO cashreceiptapplymisc DO INSTEAD INSERT INTO public.cashrcptmisc (cashrcptmisc_cashrcpt_id, cashrcptmisc_accnt_id, cashrcptmisc_amount, cashrcptmisc_notes) VALUES (public.getcashrcptid((new.customer_number)::text, CASE WHEN ((new.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((new.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((new.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((new.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((new.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((new.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((new.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((new.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((new.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (new.check_document_number)::text), public.getglaccntid((new.account)::text), COALESCE(new.amount_to_distribute, (0)::numeric), COALESCE(new.notes, ''::text));
110830
 
 
110831
 
 
110832
 
--
110833
 
--
110834
 
 
110835
 
CREATE RULE "_INSERT" AS ON INSERT TO contact DO INSTEAD SELECT public.savecntct(NULL::integer, (new.contact_number)::text, public.getcrmacctid(new.crm_account), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), new.honorific, new.first, new.middle, new.last, new.suffix, new.initials, COALESCE(new.active, true), new.voice, new.alternate, new.fax, new.email, new.web, new.notes, new.job_title, new.contact_change) AS savecntct;
110836
 
 
110837
 
 
110838
 
--
110839
 
--
110840
 
 
110841
 
CREATE RULE "_INSERT" AS ON INSERT TO contactchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('CNTCT'::text, public.getcntctid(new.contact_number), public.getcharid((new.characteristic)::text, 'CNTCT'::text), new.value, false);
110842
 
 
110843
 
 
110844
 
--
110845
 
--
110846
 
 
110847
 
CREATE RULE "_INSERT" AS ON INSERT TO contactcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'T'::text, public.getcntctid(new.contact_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
110848
 
 
110849
 
 
110850
 
--
110851
 
--
110852
 
 
110853
 
CREATE RULE "_INSERT" AS ON INSERT TO creditmemo DO INSTEAD SELECT public.insertcreditmemo(new.*) AS insertcreditmemo;
110854
 
 
110855
 
 
110856
 
--
110857
 
--
110858
 
 
110859
 
CREATE RULE "_INSERT" AS ON INSERT TO creditmemoline DO INSTEAD SELECT public.insertcreditmemoline(new.*) AS insertcreditmemoline;
110860
 
 
110861
 
 
110862
 
--
110863
 
--
110864
 
 
110865
 
CREATE RULE "_INSERT" AS ON INSERT TO custchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('C'::text, public.getcustid((new.customer_number)::text), public.getcharid((new.characteristic)::text, 'C'::text), new.value, false);
110866
 
 
110867
 
 
110868
 
--
110869
 
--
110870
 
 
110871
 
CREATE RULE "_INSERT" AS ON INSERT TO custcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'C'::text, public.getcustid((new.customer_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
110872
 
 
110873
 
 
110874
 
--
110875
 
--
110876
 
 
110877
 
CREATE RULE "_INSERT" AS ON INSERT TO custcreditcard DO INSTEAD SELECT public.insertccard((new.customer_number)::text, new.active, new.credit_card_type, new.credit_card_number, new.name, new.street_address1, new.street_address2, new.city, new.state, new.postal_code, new.country, new.expiration_month, new.expiration_year, new.key) AS insertccard;
110878
 
 
110879
 
 
110880
 
--
110881
 
--
110882
 
 
110883
 
CREATE RULE "_INSERT" AS ON INSERT TO customer DO INSTEAD INSERT INTO public.custinfo (cust_active, cust_custtype_id, cust_salesrep_id, cust_commprcnt, cust_name, cust_creditlmt, cust_creditrating, cust_backorder, cust_partialship, cust_terms_id, cust_discntprcnt, cust_balmethod, cust_ffshipto, cust_shipform_id, cust_shipvia, cust_blanketpos, cust_shipchrg_id, cust_creditstatus, cust_comments, cust_ffbillto, cust_usespos, cust_number, cust_autoupdatestatus, cust_autoholdorders, cust_preferred_warehous_id, cust_curr_id, cust_creditlmt_curr_id, cust_cntct_id, cust_corrcntct_id, cust_taxzone_id, cust_gracedays) VALUES (COALESCE(new.active, true), COALESCE((public.getcusttypeid(new.customer_type))::numeric, public.fetchmetricvalue('DefaultCustType'::text)), COALESCE((public.getsalesrepid(new.sales_rep))::numeric, public.fetchmetricvalue('DefaultSalesRep'::text)), COALESCE((new.commission * 0.01), (SELECT salesrep.salesrep_commission FROM public.salesrep WHERE (salesrep.salesrep_id = public.getsalesrepid(new.sales_rep)))), COALESCE(new.customer_name, ''::text), COALESCE((new.credit_limit)::numeric, public.fetchmetricvalue('SOCreditLimit'::text)), COALESCE(new.credit_rating, public.fetchmetrictext('SOCreditRate'::text)), COALESCE(new.accepts_backorders, public.fetchmetricbool('DefaultBackOrders'::text), false), COALESCE(new.accepts_partial_shipments, public.fetchmetricbool('DefaultPartialShipments'::text), false), COALESCE((public.gettermsid(new.default_terms))::numeric, public.fetchmetricvalue('DefaultTerms'::text)), COALESCE(new.default_discount, (0)::numeric), CASE WHEN (new.balance_method = 'Balance Forward'::text) THEN 'B'::text WHEN (new.balance_method = 'Open Items'::text) THEN 'O'::text ELSE COALESCE(public.fetchmetrictext('DefaultBalanceMethod'::text), 'B'::text) END, COALESCE(new.allow_free_form_shipto, public.fetchmetricbool('DefaultFreeFormShiptos'::text), false), COALESCE((public.getshipformid(new.ship_form))::numeric, public.fetchmetricvalue('DefaultShipFormId'::text)), COALESCE(new.ship_via, public.fetchdefaultshipvia()), COALESCE(new.uses_blanket_pos, false), COALESCE(public.getshipchrgid(new.shipping_charges), (-1)), CASE WHEN (new.credit_status = 'On Credit Warning'::text) THEN 'W'::text WHEN (new.credit_status = 'On Credit Hold'::text) THEN 'H'::text ELSE 'G'::text END, COALESCE(new.notes, ''::text), COALESCE(new.allow_free_form_billto, false), COALESCE(new.uses_purchase_orders, false), COALESCE(upper((new.customer_number)::text), (public.fetchcrmaccountnumber())::text), COALESCE(new.credit_status_exceed_warn, false), COALESCE(new.credit_status_exceed_hold, false), COALESCE(public.getwarehousid(new.preferred_selling_site, 'ACTIVE'::text), (-1)), COALESCE(public.getcurrid((new.default_currency)::text), public.basecurrid()), COALESCE(public.getcurrid((new.credit_limit_currency)::text), public.basecurrid()), public.savecntct(public.getcntctid(new.billing_contact_number, false), new.billing_contact_number, public.saveaddr(public.getaddrid(new.billing_contact_address_number), new.billing_contact_address_number, new.billing_contact_address1, new.billing_contact_address2, new.billing_contact_address3, new.billing_contact_city, new.billing_contact_state, new.billing_contact_postalcode, new.billing_contact_country, new.billing_contact_address_change), new.billing_contact_honorific, new.billing_contact_first, new.billing_contact_middle, new.billing_contact_last, new.billing_contact_suffix, new.billing_contact_voice, new.billing_contact_alternate, new.billing_contact_fax, new.billing_contact_email, new.billing_contact_web, new.billing_contact_job_title, new.billing_contact_change), public.savecntct(public.getcntctid(new.correspond_contact_number, false), new.correspond_contact_number, public.saveaddr(public.getaddrid(new.correspond_contact_address_number), new.correspond_contact_address_number, new.correspond_contact_address1, new.correspond_contact_address2, new.correspond_contact_address3, new.correspond_contact_city, new.correspond_contact_state, new.correspond_contact_postalcode, new.correspond_contact_country, new.correspond_contact_address_change), new.correspond_contact_honorific, new.correspond_contact_first, new.correspond_contact_middle, new.correspond_contact_last, new.correspond_contact_suffix, new.correspond_contact_voice, new.correspond_contact_alternate, new.correspond_contact_fax, new.correspond_contact_email, new.correspond_contact_web, new.correspond_contact_job_title, new.correspond_contact_change), public.gettaxzoneid(new.default_tax_zone), CASE WHEN (COALESCE(new.alternate_grace_days, 0) > 0) THEN new.alternate_grace_days ELSE NULL::integer END);
110884
 
 
110885
 
 
110886
 
--
110887
 
--
110888
 
 
110889
 
CREATE RULE "_INSERT" AS ON INSERT TO customertaxreg DO INSTEAD INSERT INTO public.taxreg (taxreg_rel_id, taxreg_rel_type, taxreg_taxauth_id, taxreg_taxzone_id, taxreg_number, taxreg_effective, taxreg_expires, taxreg_notes) VALUES (public.getcustid((new.customer_number)::text), 'C'::bpchar, public.gettaxauthid((new.tax_authority)::text), (SELECT custinfo.cust_taxzone_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text))), COALESCE(new.registration_number, ''::text), CASE WHEN (new.start_date = 'Always'::text) THEN public.startoftime() ELSE COALESCE((new.start_date)::date, public.startoftime()) END, CASE WHEN (new.end_date = 'Never'::text) THEN public.endoftime() ELSE COALESCE((new.end_date)::date, public.endoftime()) END, new.notes);
110890
 
 
110891
 
 
110892
 
--
110893
 
--
110894
 
 
110895
 
CREATE RULE "_INSERT" AS ON INSERT TO customertype DO INSTEAD INSERT INTO public.custtype (custtype_code, custtype_descrip, custtype_char) VALUES (new.code, COALESCE(new.description, ''::text), COALESCE(new.enable_characteristics_profile, false));
110896
 
 
110897
 
 
110898
 
--
110899
 
--
110900
 
 
110901
 
CREATE RULE "_INSERT" AS ON INSERT TO customertypechar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('CT'::text, public.getcusttypeid((new.customer_type)::text), public.getcharid((new.characteristic)::text, 'CT'::text), new.value, COALESCE(new.is_default, false));
110902
 
 
110903
 
 
110904
 
--
110905
 
--
110906
 
 
110907
 
CREATE RULE "_INSERT" AS ON INSERT TO custshipto DO INSTEAD INSERT INTO public.shiptoinfo (shipto_cust_id, shipto_name, shipto_salesrep_id, shipto_comments, shipto_shipcomments, shipto_shipzone_id, shipto_shipvia, shipto_commission, shipto_shipform_id, shipto_shipchrg_id, shipto_active, shipto_default, shipto_num, shipto_ediprofile_id, shipto_cntct_id, shipto_addr_id, shipto_taxzone_id) VALUES (public.getcustid((new.customer_number)::text), COALESCE(new.name, ''::text), COALESCE(public.getsalesrepid(new.sales_rep), (SELECT custinfo.cust_salesrep_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text)))), COALESCE(new.general_notes, ''::text), COALESCE(new.shipping_notes, ''::text), public.getshipzoneid(new.zone), COALESCE(new.ship_via, (SELECT custinfo.cust_shipvia FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text)))), COALESCE((new.commission / 100.0), (0)::numeric), COALESCE(public.getshipformid(new.ship_form), (SELECT custinfo.cust_shipform_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text)))), COALESCE(public.getshipchrgid(new.shipping_charges), (SELECT custinfo.cust_shipchrg_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text)))), COALESCE(new.active, true), COALESCE(new.default_flag, false), COALESCE(new.shipto_number, (((SELECT (COALESCE(max((shiptoinfo.shipto_num)::integer), 0) + 1) FROM public.shiptoinfo WHERE ((shiptoinfo.shipto_cust_id = public.getcustid((new.customer_number)::text)) AND (shiptoinfo.shipto_num ~ '^[0-9]*$'::text))))::text)::character varying), CASE WHEN (new.edi_profile = 'No EDI'::text) THEN (-1) WHEN (new.edi_profile = 'Use Customer Master'::text) THEN (-2) ELSE public.getediprofileid(new.edi_profile) END, public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), COALESCE(public.gettaxzoneid(new.tax_zone), (SELECT custinfo.cust_taxzone_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text)))));
110908
 
 
110909
 
 
110910
 
--
110911
 
--
110912
 
 
110913
 
CREATE RULE "_INSERT" AS ON INSERT TO custtax DO INSTEAD INSERT INTO public.taxreg (taxreg_rel_type, taxreg_rel_id, taxreg_taxauth_id, taxreg_number) VALUES ('C'::bpchar, public.getcustid((new.customer_number)::text), public.gettaxauthid((new.tax_authority)::text), new.registration_number);
110914
 
 
110915
 
 
110916
 
--
110917
 
--
110918
 
 
110919
 
CREATE RULE "_INSERT" AS ON INSERT TO employee DO INSTEAD INSERT INTO public.emp (emp_code, emp_number, emp_active, emp_cntct_id, emp_warehous_id, emp_mgr_emp_id, emp_wage_type, emp_wage, emp_wage_curr_id, emp_wage_period, emp_dept_id, emp_shift_id, emp_image_id, emp_extrate, emp_extrate_period, emp_startdate, emp_notes) VALUES (new.code, new.number, COALESCE(new.active, true), public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), new.honorific, new.first, new.middle, new.last, new.suffix, new.voice, new.alternate, new.fax, new.email, new.web, new.job_title, new.contact_change), public.getwarehousid(new.site, 'ALL'::text), (SELECT emp.emp_id FROM public.emp WHERE (emp.emp_code = new.manager_code)), CASE WHEN (new.wage_type = 'Hourly'::text) THEN 'H'::text WHEN (new.wage_type = 'Salaried'::text) THEN 'S'::text ELSE NULL::text END, new.wage, COALESCE(public.getcurrid((new.wage_currency)::text), public.basecurrid()), CASE WHEN (new.wage_period = 'Hour'::text) THEN 'H'::text WHEN (new.wage_period = 'Day'::text) THEN 'D'::text WHEN (new.wage_period = 'Week'::text) THEN 'W'::text WHEN (new.wage_period = 'Biweek'::text) THEN 'BW'::text WHEN (new.wage_period = 'Month'::text) THEN 'M'::text WHEN (new.wage_period = 'Year'::text) THEN 'Y'::text ELSE NULL::text END, public.getdeptid(new.department), public.getshiftid(new.shift), public.getimageid(new.image), new.rate, CASE WHEN (new.billing_period = 'Hour'::text) THEN 'H'::text WHEN (new.billing_period = 'Day'::text) THEN 'D'::text WHEN (new.billing_period = 'Week'::text) THEN 'W'::text WHEN (new.billing_period = 'Biweek'::text) THEN 'BW'::text WHEN (new.billing_period = 'Month'::text) THEN 'M'::text WHEN (new.billing_period = 'Year'::text) THEN 'Y'::text ELSE NULL::text END, new.start_date, COALESCE(new.notes, ''::text));
110920
 
 
110921
 
 
110922
 
--
110923
 
--
110924
 
 
110925
 
CREATE RULE "_INSERT" AS ON INSERT TO employeechar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('EMP'::text, public.getempid((new.employee_code)::text), public.getcharid((new.characteristic)::text, 'EMP'::text), new.value, false);
110926
 
 
110927
 
 
110928
 
--
110929
 
--
110930
 
 
110931
 
CREATE RULE "_INSERT" AS ON INSERT TO employeecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'EMP'::text, public.getempid((new.code)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid((new.type)::text), new.text);
110932
 
 
110933
 
 
110934
 
--
110935
 
--
110936
 
 
110937
 
CREATE RULE "_INSERT" AS ON INSERT TO extshipmaint DO INSTEAD INSERT INTO public.shipdata (shipdata_cohead_number, shipdata_shiphead_number, shipdata_void_ind, shipdata_shipper, shipdata_billing_option, shipdata_weight, shipdata_base_freight, shipdata_base_freight_curr_id, shipdata_total_freight, shipdata_total_freight_curr_id, shipdata_package_type, shipdata_cosmisc_tracknum, shipdata_cosmisc_packnum_tracknum, shipdata_lastupdated) VALUES (new.so_number, new.shipment_number, new.void, new.shipper, new.billing_option, new.weight, new.base_freight, public.getcurrid((new.base_freight_currency)::text), new.total_freight, public.getcurrid((new.total_freight_currency)::text), new.package_type, new.tracking_number, new.package_tracking_number, new.last_updated);
110938
 
 
110939
 
 
110940
 
--
110941
 
--
110942
 
 
110943
 
CREATE RULE "_INSERT" AS ON INSERT TO freightpricingscheduleitem DO INSTEAD INSERT INTO public.ipsfreight (ipsfreight_ipshead_id, ipsfreight_qtybreak, ipsfreight_price, ipsfreight_type, ipsfreight_warehous_id, ipsfreight_shipzone_id, ipsfreight_freightclass_id, ipsfreight_shipvia) VALUES (public.getipsheadid((new.pricing_schedule)::text), new.qty_break, new.price, CASE WHEN (new.price_type = 'Flat Rate'::text) THEN 'F'::text ELSE 'P'::text END, CASE WHEN (new.from_site = 'Any'::text) THEN NULL::integer ELSE public.getwarehousid(new.from_site, 'All'::text) END, CASE WHEN (new.to_shipzone = 'Any'::text) THEN NULL::integer ELSE public.getshipzoneid(new.to_shipzone) END, CASE WHEN (new.freight_class = 'Any'::text) THEN NULL::integer ELSE public.getfreightclassid(new.freight_class) END, CASE WHEN (new.ship_via = 'Any'::text) THEN NULL::text ELSE new.ship_via END);
110944
 
 
110945
 
 
110946
 
--
110947
 
--
110948
 
 
110949
 
CREATE RULE "_INSERT" AS ON INSERT TO glaccount DO INSTEAD INSERT INTO public.accnt (accnt_number, accnt_descrip, accnt_comments, accnt_profit, accnt_sub, accnt_type, accnt_extref, accnt_company, accnt_forwardupdate, accnt_subaccnttype_code) VALUES (COALESCE(new.account_number, ''::character varying), COALESCE(new.description, ''::text), COALESCE(new.notes, ''::text), new.profit_center, new.sub_account, CASE WHEN (new.type = 'Asset'::text) THEN 'A'::text WHEN (new.type = 'Liability'::text) THEN 'L'::text WHEN (new.type = 'Expense'::text) THEN 'E'::text WHEN (new.type = 'Revenue'::text) THEN 'R'::text WHEN (new.type = 'Equity'::text) THEN 'Q'::text ELSE NULL::text END, COALESCE(new.ext_reference, ''::text), new.company, COALESCE(new.forward_update_trial_balances, false), COALESCE(new.sub_type, ''::text));
110950
 
 
110951
 
 
110952
 
--
110953
 
--
110954
 
 
110955
 
CREATE RULE "_INSERT" AS ON INSERT TO incident DO INSTEAD INSERT INTO public.incdt (incdt_number, incdt_crmacct_id, incdt_cntct_id, incdt_summary, incdt_descrip, incdt_item_id, incdt_status, incdt_assigned_username, incdt_incdtcat_id, incdt_incdtseverity_id, incdt_incdtpriority_id, incdt_incdtresolution_id, incdt_lotserial, incdt_ls_id) VALUES (new.incident_number, public.getcrmacctid(new.crm_account), public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), COALESCE(new.description, ''::text), COALESCE(new.notes, ''::text), public.getitemid(new.item_number), CASE WHEN (new.status = 'New'::text) THEN 'N'::text WHEN (new.status = 'Feedback'::text) THEN 'F'::text WHEN (new.status = 'Confirmed'::text) THEN 'C'::text WHEN (new.status = 'Assigned'::text) THEN 'A'::text WHEN (new.status = 'Resolved'::text) THEN 'R'::text WHEN (new.status = 'Closed'::text) THEN 'L'::text ELSE ''::text END, COALESCE(new.assigned_to, ''::text), public.getincdtcatid(new.category), public.getincdtseverityid(new.severity), public.getincdtpriorityid(new.priority), public.getincdtresolutionid(new.resolution), COALESCE(new.lot_serial_number, ''::text), public.getlotserialid(new.item_number, new.lot_serial_number));
110956
 
 
110957
 
 
110958
 
--
110959
 
--
110960
 
 
110961
 
CREATE RULE "_INSERT" AS ON INSERT TO incidentchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('INCDT'::text, public.getincidentid(new.incident_number), public.getcharid((new.characteristic)::text, 'INCDT'::text), new.value, false);
110962
 
 
110963
 
 
110964
 
--
110965
 
--
110966
 
 
110967
 
CREATE RULE "_INSERT" AS ON INSERT TO incidentcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text, comment_public) VALUES (COALESCE(new.date, now()), 'INCDT'::text, public.getincidentid(new.incident_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text, COALESCE(new.public, true));
110968
 
 
110969
 
 
110970
 
--
110971
 
--
110972
 
 
110973
 
CREATE RULE "_INSERT" AS ON INSERT TO incidentfile DO INSTEAD INSERT INTO public.url (url_source_id, url_source, url_title, url_url) VALUES (public.getincidentid(new.incident_number), 'INCDT'::text, new.title, new.url);
110974
 
 
110975
 
 
110976
 
--
110977
 
--
110978
 
 
110979
 
CREATE RULE "_INSERT" AS ON INSERT TO incidentimage DO INSTEAD SELECT public.saveimageass('INCDT'::text, public.getincidentid(new.incident_number), 'M'::bpchar, public.getimageid(new.image_name)) AS saveimageass;
110980
 
 
110981
 
 
110982
 
--
110983
 
--
110984
 
 
110985
 
CREATE RULE "_INSERT" AS ON INSERT TO invoice DO INSTEAD SELECT public.insertinvoice(new.*) AS insertinvoice;
110986
 
 
110987
 
 
110988
 
--
110989
 
--
110990
 
 
110991
 
CREATE RULE "_INSERT" AS ON INSERT TO invoiceline DO INSTEAD SELECT public.insertinvoicelineitem(new.*) AS insertinvoicelineitem;
110992
 
 
110993
 
 
110994
 
--
110995
 
--
110996
 
 
110997
 
CREATE RULE "_INSERT" AS ON INSERT TO item DO INSTEAD INSERT INTO public.item (item_number, item_active, item_descrip1, item_descrip2, item_type, item_maxcost, item_classcode_id, item_inv_uom_id, item_picklist, item_fractional, item_config, item_sold, item_prodcat_id, item_exclusive, item_listprice, item_listcost, item_price_uom_id, item_upccode, item_prodweight, item_packweight, item_comments, item_extdescrip) VALUES (upper((new.item_number)::text), COALESCE(new.active, true), COALESCE(new.description1, ''::text), COALESCE(new.description2, ''::text), CASE WHEN (new.item_type = 'Purchased'::text) THEN 'P'::text WHEN (new.item_type = 'Manufactured'::text) THEN 'M'::text WHEN (new.item_type = 'Job'::text) THEN 'J'::text WHEN (new.item_type = 'Kit'::text) THEN 'K'::text WHEN (new.item_type = 'Phantom'::text) THEN 'F'::text WHEN (new.item_type = 'Reference'::text) THEN 'R'::text WHEN (new.item_type = 'Costing'::text) THEN 'S'::text WHEN (new.item_type = 'Tooling'::text) THEN 'T'::text WHEN (new.item_type = 'Outside Process'::text) THEN 'O'::text WHEN (new.item_type = 'Planning'::text) THEN 'L'::text WHEN (new.item_type = 'Breeder'::text) THEN 'B'::text WHEN (new.item_type = 'Co-Product'::text) THEN 'C'::text WHEN (new.item_type = 'By-Product'::text) THEN 'Y'::text ELSE NULL::text END, COALESCE(new.maximum_desired_cost, (0)::numeric), public.getclasscodeid(new.class_code), public.getuomid(new.inventory_uom), COALESCE(new.pick_list_item, true), COALESCE(new.fractional, false), COALESCE(new.configured, false), COALESCE(new.item_is_sold, true), COALESCE(public.getprodcatid(new.product_category), (-1)), COALESCE(new.exclusive, false), COALESCE(new.list_price, (0)::numeric), COALESCE(new.list_cost, (0)::numeric), COALESCE(public.getuomid(new.list_price_uom), public.getuomid(new.inventory_uom)), new.upc_code, COALESCE(new.product_weight, (0)::numeric), COALESCE(new.packaging_weight, (0)::numeric), new.notes, new.ext_description);
110998
 
 
110999
 
 
111000
 
--
111001
 
--
111002
 
 
111003
 
CREATE RULE "_INSERT" AS ON INSERT TO itemalias DO INSTEAD INSERT INTO public.itemalias (itemalias_item_id, itemalias_number, itemalias_usedescrip, itemalias_descrip1, itemalias_descrip2, itemalias_comments) VALUES (public.getitemid((new.item_number)::text), new.alias_number, COALESCE(new.use_description, false), COALESCE(new.description1, ''::text), COALESCE(new.description2, ''::text), new.comments);
111004
 
 
111005
 
 
111006
 
--
111007
 
--
111008
 
 
111009
 
CREATE RULE "_INSERT" AS ON INSERT TO itemchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('I'::text, public.getitemid((new.item_number)::text), public.getcharid((new.characteristic)::text, 'I'::text), new.value, COALESCE(new.is_default, false));
111010
 
 
111011
 
 
111012
 
--
111013
 
--
111014
 
 
111015
 
CREATE RULE "_INSERT" AS ON INSERT TO itemcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'IS'::text, public.getitemid((new.item_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
111016
 
 
111017
 
 
111018
 
--
111019
 
--
111020
 
 
111021
 
CREATE RULE "_INSERT" AS ON INSERT TO itemcost DO INSTEAD SELECT public.insertitemcost(public.getitemid((new.item_number)::text), public.getcostelemid((new.costing_element)::text), public.getcurrid((new.currency)::text), new.actual_cost, new.post_to_standard) AS insertitemcost;
111022
 
 
111023
 
 
111024
 
--
111025
 
--
111026
 
 
111027
 
CREATE RULE "_INSERT" AS ON INSERT TO itemfile DO INSTEAD INSERT INTO public.url (url_source_id, url_source, url_title, url_url) VALUES (public.getitemid((new.item_number)::text), 'I'::text, new.title, new.url);
111028
 
 
111029
 
 
111030
 
--
111031
 
--
111032
 
 
111033
 
CREATE RULE "_INSERT" AS ON INSERT TO itemimage DO INSTEAD SELECT public.saveimageass('I'::text, public.getitemid((new.item_number)::text), (CASE WHEN (new.purpose = 'Product Description'::text) THEN 'P'::text WHEN (new.purpose = 'Inventory Description'::text) THEN 'I'::text WHEN (new.purpose = 'Engineering Reference'::text) THEN 'E'::text WHEN (new.purpose = 'Miscellaneous'::text) THEN 'M'::text ELSE 'X'::text END)::bpchar, public.getimageid(new.image_name)) AS saveimageass;
111034
 
 
111035
 
 
111036
 
--
111037
 
--
111038
 
 
111039
 
CREATE RULE "_INSERT" AS ON INSERT TO itemsite DO INSTEAD INSERT INTO public.itemsite (itemsite_item_id, itemsite_warehous_id, itemsite_active, itemsite_dropship, itemsite_posupply, itemsite_createpr, itemsite_wosupply, itemsite_createwo, itemsite_createsopr, itemsite_createsopo, itemsite_sold, itemsite_soldranking, itemsite_costmethod, itemsite_controlmethod, itemsite_perishable, itemsite_plancode_id, itemsite_costcat_id, itemsite_loccntrl, itemsite_location_id, itemsite_recvlocation_id, itemsite_issuelocation_id, itemsite_location_dist, itemsite_recvlocation_dist, itemsite_issuelocation_dist, itemsite_location, itemsite_location_comments, itemsite_disallowblankwip, itemsite_stocked, itemsite_abcclass, itemsite_autoabcclass, itemsite_cyclecountfreq, itemsite_eventfence, itemsite_useparams, itemsite_reorderlevel, itemsite_ordertoqty, itemsite_minordqty, itemsite_maxordqty, itemsite_multordqty, itemsite_useparamsmanual, itemsite_ordergroup, itemsite_ordergroup_first, itemsite_mps_timefence, itemsite_leadtime, itemsite_safetystock, itemsite_supply_itemsite_id, itemsite_notes, itemsite_qtyonhand, itemsite_warrpurc, itemsite_autoreg, itemsite_freeze, itemsite_value, itemsite_planning_type) VALUES (public.getitemid((new.item_number)::text), public.getwarehousid((new.site)::text, 'ACTIVE'::text), COALESCE(new.active, true), COALESCE(new.dropship, false), COALESCE(new.po_supplied_at_site, false), COALESCE(new.create_prs, false), COALESCE(new.wo_supplied_at_site, false), COALESCE(new.create_wos, false), COALESCE(new.create_soprs, false), COALESCE(new.create_sopos, false), COALESCE(new.sold_from_site, true), COALESCE(new.ranking, 1), CASE WHEN (new.cost_method = 'None'::text) THEN 'N'::text WHEN (new.cost_method = 'Average'::text) THEN 'A'::text WHEN (new.cost_method = 'Standard'::text) THEN 'S'::text WHEN (new.cost_method = 'Job'::text) THEN 'J'::text ELSE NULL::text END, CASE WHEN (new.control_method = 'None'::text) THEN 'N'::text WHEN (new.control_method = 'Regular'::text) THEN 'R'::text WHEN (new.control_method = 'Serial #'::text) THEN 'S'::text WHEN (new.control_method = 'Lot #'::text) THEN 'L'::text ELSE NULL::text END, COALESCE(new.perishable, false), public.getplancodeid(new.planner_code), public.getcostcatid(new.cost_category), COALESCE(new.multiple_location_control, false), COALESCE(public.getlocationid((new.site)::text, new.location), (-1)), COALESCE(public.getlocationid((new.site)::text, new.receive_location), (-1)), COALESCE(public.getlocationid((new.site)::text, new.issue_location), (-1)), COALESCE(new.auto_distr_location, false), COALESCE(new.auto_distr_receive_location, false), COALESCE(new.auto_distr_issue_location, false), COALESCE(new.user_defined_location, ''::text), COALESCE(new.location_comment, ''::text), COALESCE(new.disallow_blank_wip_locations, false), COALESCE(new.stocked, false), COALESCE(new.abc_class, 'A'::bpchar), COALESCE(new.allow_automatic_updates, false), COALESCE(new.cycl_cnt_freq, 0), COALESCE((new.event_fence)::numeric, public.fetchmetricvalue('DefaultEventFence'::text)), COALESCE(new.enforce_order_parameters, false), COALESCE(new.reorder_level, (0)::numeric), COALESCE(new.order_up_to, (0)::numeric), COALESCE(new.minimum_order, (0)::numeric), COALESCE(new.maximum_order, (0)::numeric), COALESCE(new.order_multiple, (0)::numeric), COALESCE(new.enforce_on_manual_orders, false), COALESCE(new.group_mps_mrp_orders, 0), COALESCE(new.first_group, false), COALESCE(new.mps_time_fence, 0), COALESCE(new.lead_time, 0), COALESCE(new.safety_stock, (0)::numeric), CASE WHEN (new.supplied_from_site = 'None'::text) THEN NULL::integer WHEN (new.supplied_from_site = ''::text) THEN NULL::integer ELSE public.getitemsiteid(new.supplied_from_site, (new.item_number)::text) END, COALESCE(new.notes, ''::text), 0, COALESCE(new.require_warranty, false), COALESCE(new.auto_register, false), false, 0, CASE WHEN (new.planning_system = 'None'::text) THEN 'N'::text WHEN (new.planning_system = 'MPS'::text) THEN 'S'::text ELSE 'M'::text END);
111040
 
 
111041
 
 
111042
 
--
111043
 
--
111044
 
 
111045
 
CREATE RULE "_INSERT" AS ON INSERT TO itemsitecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'IS'::text, public.getitemsiteid((new.site)::text, (new.item_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
111046
 
 
111047
 
 
111048
 
--
111049
 
--
111050
 
 
111051
 
CREATE RULE "_INSERT" AS ON INSERT TO itemsource DO INSTEAD INSERT INTO public.itemsrc (itemsrc_item_id, itemsrc_vend_id, itemsrc_vend_item_number, itemsrc_vend_item_descrip, itemsrc_comments, itemsrc_vend_uom, itemsrc_invvendoruomratio, itemsrc_minordqty, itemsrc_multordqty, itemsrc_leadtime, itemsrc_ranking, itemsrc_active, itemsrc_default, itemsrc_manuf_name, itemsrc_manuf_item_number, itemsrc_manuf_item_descrip, itemsrc_upccode, itemsrc_contrct_id, itemsrc_effective, itemsrc_expires) VALUES (public.getitemid((new.item_number)::text), public.getvendid((new.vendor)::text), new.vendor_item_number, COALESCE(new.vendor_description, ''::text), COALESCE(new.notes, ''::text), new.vendor_uom, new.inventory_vendor_uom_ratio, new.minimum_order, new.order_multiple, new.lead_time, new.vendor_ranking, COALESCE(new.active, true), COALESCE(new.itemsrc_default, true), COALESCE(new.manufacturer_name, ''::text), COALESCE(new.manufacturer_item_number, ''::text), new.manufacturer_description, new.bar_code, public.getcontrctid(new.contract_number), COALESCE(public.getcontrcteffective(new.contract_number), new.effective_date), COALESCE(public.getcontrctexpires(new.contract_number), new.expires_date));
111052
 
 
111053
 
 
111054
 
--
111055
 
--
111056
 
 
111057
 
CREATE RULE "_INSERT" AS ON INSERT TO itemsourceprice DO INSTEAD INSERT INTO public.itemsrcp (itemsrcp_itemsrc_id, itemsrcp_qtybreak, itemsrcp_price, itemsrcp_curr_id, itemsrcp_updated, itemsrcp_dropship, itemsrcp_warehous_id, itemsrcp_type, itemsrcp_discntprcnt, itemsrcp_fixedamtdiscount) VALUES (public.getitemsrcid((new.item_number)::text, (new.vendor)::text), new.qty_break, new.price_per_unit, public.getcurrid((new.currency)::text), now(), COALESCE(new.dropship_only, false), CASE WHEN (new.pricing_site = 'All'::text) THEN (-1) ELSE COALESCE(public.getwarehousid(new.pricing_site, 'ALL'::text), (-1)) END, CASE WHEN (new.pricing_type = 'Discount'::text) THEN 'D'::text ELSE 'N'::text END, (COALESCE(new.discount_percent, 0.0) / 100.0), new.discount_fixed_amount);
111058
 
 
111059
 
 
111060
 
--
111061
 
--
111062
 
 
111063
 
CREATE RULE "_INSERT" AS ON INSERT TO itemsubstitute DO INSTEAD INSERT INTO public.itemsub (itemsub_parent_item_id, itemsub_sub_item_id, itemsub_uomratio, itemsub_rank) VALUES (public.getitemid((new.root_item_number)::text), public.getitemid((new.substitute_item_number)::text), COALESCE(new.sub_parent_uom_ratio, (1)::numeric), COALESCE(new.ranking, 1));
111064
 
 
111065
 
 
111066
 
--
111067
 
--
111068
 
 
111069
 
CREATE RULE "_INSERT" AS ON INSERT TO itemtaxtype DO INSTEAD INSERT INTO public.itemtax (itemtax_item_id, itemtax_taxzone_id, itemtax_taxtype_id) VALUES (public.getitemid((new.item_number)::text), CASE WHEN ((new.tax_zone)::text = 'Any'::text) THEN NULL::integer ELSE public.gettaxzoneid((new.tax_zone)::text) END, public.gettaxtypeid(new.tax_type));
111070
 
 
111071
 
 
111072
 
--
111073
 
--
111074
 
 
111075
 
CREATE RULE "_INSERT" AS ON INSERT TO itemuomconversion DO INSTEAD SELECT public.saveitemuomconv(public.getitemid((new.item_number)::text), COALESCE(public.getuomid((new.uom)::text), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid((new.item_number)::text)))), COALESCE(new.uom_value, (1)::numeric), COALESCE(public.getuomid(new.per_uom), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid((new.item_number)::text)))), COALESCE(new.per_uom_value, (1)::numeric), COALESCE(new.fractional, false), public.getuomtypeid(new.selected_types)) AS saveitemuomconv;
111076
 
 
111077
 
 
111078
 
--
111079
 
--
111080
 
 
111081
 
CREATE RULE "_INSERT" AS ON INSERT TO journalentry DO INSTEAD SELECT public.insertgltransaction('G/L'::text, 'JE'::text, new.doc_number, new.notes, public.getglaccntid(new.credit), public.getglaccntid(new.debit), (-1), public.currtobase(public.getcurrid((new.currency)::text), new.amount, new.dist_date), new.dist_date) AS insertgltransaction;
111082
 
 
111083
 
 
111084
 
--
111085
 
--
111086
 
 
111087
 
CREATE RULE "_INSERT" AS ON INSERT TO location DO INSTEAD INSERT INTO public.location (location_warehous_id, location_name, location_descrip, location_restrict, location_netable, location_whsezone_id, location_aisle, location_rack, location_bin) VALUES (public.getwarehousid((new.site)::text, 'ACTIVE'::text), COALESCE(new.location, ''::character varying), COALESCE(new.description, ''::text), COALESCE(new.restricted, false), COALESCE(new.netable, true), public.getwhsezoneid((new.site)::text, new.zone), COALESCE(new.aisle, ''::character varying), COALESCE(new.rack, ''::character varying), COALESCE(new.bin, ''::character varying));
111088
 
 
111089
 
 
111090
 
--
111091
 
--
111092
 
 
111093
 
CREATE RULE "_INSERT" AS ON INSERT TO misccounttag DO INSTEAD SELECT public.postmisccount(public.getitemsiteid(COALESCE(new.site, (SELECT whsinfo.warehous_code FROM public.usrpref, public.whsinfo WHERE (((usrpref.usrpref_username = public.geteffectivextuser()) AND (usrpref.usrpref_name = 'PreferredWarehouse'::text)) AND (whsinfo.warehous_id = (usrpref.usrpref_value)::integer)))), new.item_number), new.quantity, new.comment) AS postmisccount;
111094
 
 
111095
 
 
111096
 
--
111097
 
--
111098
 
 
111099
 
CREATE RULE "_INSERT" AS ON INSERT TO pricingschedule DO INSTEAD INSERT INTO public.ipshead (ipshead_id, ipshead_name, ipshead_descrip, ipshead_effective, ipshead_expires, ipshead_curr_id, ipshead_updated) VALUES (nextval('public.ipshead_ipshead_id_seq'::regclass), new.name, new.description, CASE WHEN (new.effective = 'Always'::text) THEN '1970-01-01'::date ELSE (COALESCE(new.effective, '1970-01-01'::text))::date END, CASE WHEN (new.expires = 'Never'::text) THEN '2100-01-01'::date ELSE (COALESCE(new.expires, '2100-01-01'::text))::date END, COALESCE(public.getcurrid((new.currency)::text), public.basecurrid()), now());
111100
 
 
111101
 
 
111102
 
--
111103
 
--
111104
 
 
111105
 
CREATE RULE "_INSERT" AS ON INSERT TO pricingscheduleassign DO INSTEAD INSERT INTO public.ipsass (ipsass_ipshead_id, ipsass_cust_id, ipsass_custtype_id, ipsass_custtype_pattern, ipsass_shipto_id, ipsass_shipto_pattern) VALUES (public.getipsheadid((new.pricing_schedule)::text), CASE WHEN ((new.customer_number)::text = 'Any'::text) THEN (-1) ELSE public.getcustid((new.customer_number)::text) END, CASE WHEN ((new.customer_type)::text = 'N/A'::text) THEN (-1) ELSE public.getcusttypeid((new.customer_type)::text) END, new.customer_type_pattern, CASE WHEN (((new.customer_number)::text = 'Any'::text) OR ((new.customer_shipto)::text = 'Any'::text)) THEN (-1) ELSE public.getshiptoid((new.customer_number)::text, (new.customer_shipto)::text) END, new.customer_shipto_pattern);
111106
 
 
111107
 
 
111108
 
--
111109
 
--
111110
 
 
111111
 
CREATE RULE "_INSERT" AS ON INSERT TO pricingscheduleitem DO INSTEAD SELECT CASE WHEN ((new.type)::text = 'Item'::text) THEN public.saveipsitem(NULL::integer, public.getipsheadid((new.pricing_schedule)::text), public.getitemid((new.item_number)::text), COALESCE(new.qty_break, (0)::numeric), COALESCE(new.price, (0)::numeric), public.getuomid((new.qty_uom)::text), public.getuomid((new.price_uom)::text), new.percent, new.fixedamt, CASE new.pricing_type WHEN 'Nominal'::text THEN 'N'::text WHEN 'Discount'::text THEN 'D'::text WHEN 'Markup'::text THEN 'M'::text ELSE '?'::text END) WHEN ((new.type)::text = 'Product Category'::text) THEN public.saveipsprodcat(NULL::integer, public.getipsheadid((new.pricing_schedule)::text), public.getprodcatid((new.product_category)::text), new.qty_break, new.percent, new.fixedamt, CASE new.pricing_type WHEN 'Nominal'::text THEN 'N'::text WHEN 'Discount'::text THEN 'D'::text WHEN 'Markup'::text THEN 'M'::text ELSE '?'::text END) ELSE NULL::integer END AS "case";
111112
 
 
111113
 
 
111114
 
--
111115
 
--
111116
 
 
111117
 
CREATE RULE "_INSERT" AS ON INSERT TO pricingscheduleitemchar DO INSTEAD INSERT INTO public.ipsitemchar (ipsitemchar_ipsitem_id, ipsitemchar_char_id, ipsitemchar_value, ipsitemchar_price) VALUES (public.getipsitemid((new.pricing_schedule)::text, (new.item_number)::text, new.qty_break, (new.qty_uom)::text, (new.price_uom)::text), public.getcharid((new.characteristic)::text, 'I'::text), new.value, COALESCE(new.price, (0)::numeric));
111118
 
 
111119
 
 
111120
 
--
111121
 
--
111122
 
 
111123
 
CREATE RULE "_INSERT" AS ON INSERT TO project DO INSTEAD INSERT INTO public.prj (prj_number, prj_name, prj_descrip, prj_owner_username, prj_username, prj_so, prj_wo, prj_po, prj_status, prj_due_date, prj_assigned_date, prj_start_date, prj_completed_date) VALUES (new.number, COALESCE(new.name, ''::text), COALESCE(new.description, ''::text), COALESCE(new.owner, public.geteffectivextuser()), COALESCE(new.assigned_to, public.geteffectivextuser()), COALESCE(new.sales_orders, true), COALESCE(new.work_orders, true), COALESCE(new.purchase_orders, true), CASE WHEN (new.status = 'In-Process'::text) THEN 'O'::text WHEN (new.status = 'Completed'::text) THEN 'C'::text ELSE 'P'::text END, new.due, new.assigned, new.started, new.completed);
111124
 
 
111125
 
 
111126
 
--
111127
 
--
111128
 
 
111129
 
CREATE RULE "_INSERT" AS ON INSERT TO projectcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'J'::text, public.getprjid((new.project_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
111130
 
 
111131
 
 
111132
 
--
111133
 
--
111134
 
 
111135
 
CREATE RULE "_INSERT" AS ON INSERT TO prospect DO INSTEAD INSERT INTO public.prospect (prospect_number, prospect_name, prospect_active, prospect_cntct_id, prospect_taxzone_id, prospect_salesrep_id, prospect_warehous_id, prospect_comments) VALUES (upper((new.prospect_number)::text), COALESCE(new.prospect_name, ''::text), COALESCE(new.active, true), public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.contact_address_number), new.contact_address_number, new.contact_address1, new.contact_address2, new.contact_address3, new.contact_city, new.contact_state, new.contact_postalcode, new.contact_country, new.contact_address_change), new.contact_honorific, new.contact_first, new.contact_middle, new.contact_last, new.contact_suffix, new.contact_voice, new.contact_alternate, new.contact_fax, new.contact_email, new.contact_web, new.contact_job_title, new.contact_change), public.gettaxzoneid(new.default_tax_zone), public.getsalesrepid(new.sales_rep), public.getwarehousid(new.site_code, 'ACTIVE'::text), COALESCE(new.notes, ''::text));
111136
 
 
111137
 
 
111138
 
--
111139
 
--
111140
 
 
111141
 
CREATE RULE "_INSERT" AS ON INSERT TO purchaseline DO INSTEAD INSERT INTO public.poitem (poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_comments, poitem_expcat_id, poitem_freight, poitem_prj_id, poitem_bom_rev_id, poitem_boo_rev_id) VALUES (public.getpoheadid((new.order_number)::text), new.line_number, new.due_date, public.getitemsiteid(COALESCE(new.site, (SELECT whsinfo.warehous_code FROM (public.pohead JOIN public.whsinfo ON ((whsinfo.warehous_id = pohead.pohead_warehous_id))) WHERE (pohead.pohead_id = public.getpoheadid((new.order_number)::text))), (SELECT whsinfo.warehous_code FROM public.whsinfo WHERE (whsinfo.warehous_id = public.fetchprefwarehousid()))), new.item_number), new.vendor_description, new.qty_ordered, new.unit_price, new.vend_item_number, new.manufacturer_name, new.manufacturer_item_number, new.manufacturer_description, new.notes, public.getexpcatid(new.expense_category), new.freight, public.getprjid(new.project_number), public.getrevid('BOM'::text, new.item_number, new.bill_of_materials_revision), public.getrevid('BOO'::text, new.item_number, new.bill_of_operations_revision));
111142
 
 
111143
 
 
111144
 
--
111145
 
--
111146
 
 
111147
 
CREATE RULE "_INSERT" AS ON INSERT TO purchaselinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('PI'::text, poitem.poitem_id, charass.charass_char_id, new.value) AS updatecharassignment FROM public.pohead, public.poitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((pohead.pohead_number = (new.order_number)::text) AND (pohead.pohead_id = poitem.poitem_pohead_id)) AND (poitem.poitem_linenumber = new.line_number)) AND (poitem.poitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = new.characteristic));
111148
 
 
111149
 
 
111150
 
--
111151
 
--
111152
 
 
111153
 
CREATE RULE "_INSERT" AS ON INSERT TO purchaselinecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) SELECT COALESCE(new.date, (('now'::text)::date)::timestamp with time zone) AS "coalesce", 'PI', poitem.poitem_id, COALESCE(new.username, public.geteffectivextuser()) AS "coalesce", public.getcmnttypeid(new.type) AS getcmnttypeid, new.text FROM public.poitem, public.pohead WHERE (((pohead.pohead_number = (new.order_number)::text) AND (poitem.poitem_pohead_id = pohead.pohead_id)) AND (poitem.poitem_linenumber = new.line_number));
111154
 
 
111155
 
 
111156
 
--
111157
 
--
111158
 
 
111159
 
CREATE RULE "_INSERT" AS ON INSERT TO purchaseorder DO INSTEAD INSERT INTO public.pohead (pohead_number, pohead_orderdate, pohead_status, pohead_terms_id, pohead_taxzone_id, pohead_warehous_id, pohead_agent_username, pohead_vend_id, pohead_vendaddr_id, pohead_fob, pohead_shipvia, pohead_curr_id, pohead_freight, pohead_comments, pohead_dropship, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_cohead_id) SELECT new.order_number, COALESCE(new.order_date, ('now'::text)::date) AS "coalesce", 'U', COALESCE(public.gettermsid(new.terms), vendinfo.vend_terms_id) AS "coalesce", COALESCE(public.gettaxzoneid(new.tax_zone), vendinfo.vend_taxzone_id) AS "coalesce", COALESCE(public.getwarehousid(new.receiving_site, 'ALL'::text), public.fetchprefwarehousid()) AS "coalesce", COALESCE(new.purchasing_agent, public.geteffectivextuser()) AS "coalesce", public.getvendid(new.vendor_number) AS getvendid, CASE WHEN (new.alt_address = 'MAIN'::text) THEN NULL::integer ELSE public.getvendaddrid(new.vendor_number, new.alt_address) END AS getvendaddrid, COALESCE(new.fob, CASE WHEN (vendinfo.vend_fobsource = 'W'::bpchar) THEN (SELECT whsinfo.warehous_fob FROM public.whsinfo WHERE (whsinfo.warehous_id = COALESCE(public.getwarehousid(new.receiving_site, 'ALL'::text), public.fetchprefwarehousid()))) ELSE vendinfo.vend_fob END) AS "coalesce", COALESCE(new.ship_via, vendinfo.vend_shipvia) AS "coalesce", COALESCE(public.getcurrid((new.currency)::text), vendinfo.vend_curr_id) AS "coalesce", COALESCE(new.freight, (0)::numeric) AS "coalesce", new.notes, COALESCE(new.dropship, false) AS "coalesce", public.getcntctid(new.vend_contact_number) AS getcntctid, COALESCE(new.vend_cntct_honorific, ''::text) AS "coalesce", COALESCE(new.vend_cntct_first_name, ''::text) AS "coalesce", COALESCE(new.vend_cntct_middle, ''::text) AS "coalesce", COALESCE(new.vend_cntct_last_name, ''::text) AS "coalesce", COALESCE(new.vend_cntct_suffix, ''::text) AS "coalesce", COALESCE(new.vend_cntct_phone, ''::text) AS "coalesce", COALESCE(new.vend_cntct_title, ''::text) AS "coalesce", COALESCE(new.vend_cntct_fax, ''::text) AS "coalesce", COALESCE(new.vend_cntct_email, ''::text) AS "coalesce", COALESCE(new.vendaddress1, ''::text) AS "coalesce", COALESCE(new.vendaddress2, ''::text) AS "coalesce", COALESCE(new.vendaddress3, ''::text) AS "coalesce", COALESCE(new.vendcity, ''::text) AS "coalesce", COALESCE(new.vendstate, ''::text) AS "coalesce", COALESCE(new.vendzipcode, ''::text) AS "coalesce", COALESCE(new.vendcountry, ''::text) AS "coalesce", public.getcntctid(new.shipto_contact_number) AS getcntctid, COALESCE(new.shipto_cntct_honorific, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_first_name, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_middle, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_last_name, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_suffix, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_phone, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_title, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_fax, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_email, ''::text) AS "coalesce", public.getaddrid(new.shiptoaddress_number) AS getaddrid, COALESCE(new.shiptoaddress1, ''::text) AS "coalesce", COALESCE(new.shiptoaddress2, ''::text) AS "coalesce", COALESCE(new.shiptoaddress3, ''::text) AS "coalesce", COALESCE(new.shiptocity, ''::text) AS "coalesce", COALESCE(new.shiptostate, ''::text) AS "coalesce", COALESCE(new.shiptozipcode, ''::text) AS "coalesce", COALESCE(new.shiptocountry, ''::text) AS "coalesce", public.getcoheadid(new.sales_order_number) AS getcoheadid FROM public.vendinfo WHERE (vendinfo.vend_id = public.getvendid(new.vendor_number));
111160
 
 
111161
 
 
111162
 
--
111163
 
--
111164
 
 
111165
 
CREATE RULE "_INSERT" AS ON INSERT TO purchaseordercomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'P'::text, public.getpoheadid((new.order_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
111166
 
 
111167
 
 
111168
 
--
111169
 
--
111170
 
 
111171
 
CREATE RULE "_INSERT" AS ON INSERT TO quote DO INSTEAD INSERT INTO public.quhead (quhead_number, quhead_cust_id, quhead_custponumber, quhead_quotedate, quhead_warehous_id, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_salesrep_id, quhead_terms_id, quhead_fob, quhead_shipvia, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_freight, quhead_misc, quhead_ordercomments, quhead_shipcomments, quhead_shiptophone, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_misc_accnt_id, quhead_misc_descrip, quhead_commission, quhead_packdate, quhead_prj_id, quhead_billtocountry, quhead_shiptocountry, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_imported, quhead_expire, quhead_status, quhead_saletype_id, quhead_shipzone_id) VALUES (new.quote_number, public.getcustid(new.customer_number, true), new.cust_po_number, new.quote_date, public.getwarehousid(new.site, 'SHIPPING'::text), public.getshiptoid(new.customer_number, new.shipto_number), new.shipto_name, new.shipto_address1, new.shipto_address2, new.shipto_address3, public.getsalesrepid(new.sales_rep), public.gettermsid(new.terms), new.fob, new.ship_via, new.shipto_city, new.shipto_state, new.shipto_postal_code, new.freight, new.misc_charge, new.order_notes, new.shipping_notes, new.shipto_phone, new.billto_name, new.billto_address1, new.billto_address2, new.billto_address3, new.billto_city, new.billto_state, new.billto_postal_code, public.getglaccntid(new.misc_account_number), new.misc_charge_description, new.commission, new.pack_date, public.getprjid(new.project_number), new.billto_country, new.shipto_country, public.getcurrid((new.currency)::text), public.gettaxzoneid(new.tax_zone), public.gettaxtypeid(new.tax_type), true, new.expire_date, CASE WHEN (new.status = 'Converted'::text) THEN 'C'::text ELSE 'O'::text END, public.getsaletypeid(new.sale_type), public.getshipzoneid(new.shipto_shipzone));
111172
 
 
111173
 
 
111174
 
--
111175
 
--
111176
 
 
111177
 
CREATE RULE "_INSERT" AS ON INSERT TO quotecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'Q'::text, public.getquoteid(new.quote_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
111178
 
 
111179
 
 
111180
 
--
111181
 
--
111182
 
 
111183
 
CREATE RULE "_INSERT" AS ON INSERT TO quoteline DO INSTEAD INSERT INTO public.quitem (quitem_quhead_id, quitem_linenumber, quitem_itemsite_id, quitem_scheddate, quitem_qtyord, quitem_unitcost, quitem_price, quitem_custprice, quitem_memo, quitem_imported, quitem_custpn, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_taxtype_id, quitem_qty_uom_id, quitem_qty_invuomratio, quitem_price_uom_id, quitem_price_invuomratio) SELECT public.getquoteid(new.quote_number) AS getquoteid, COALESCE(new.line_number, (SELECT (COALESCE(max(quitem.quitem_linenumber), 0) + 1) FROM public.quitem WHERE (quitem.quitem_quhead_id = public.getquoteid(new.quote_number)))) AS "coalesce", itemsite.itemsite_id, COALESCE(new.scheduled_date, (SELECT min(quitem.quitem_scheddate) AS min FROM public.quitem WHERE (quitem.quitem_quhead_id = public.getquoteid(new.quote_number)))) AS "coalesce", new.qty_ordered, public.stdcost(item.item_id) AS stdcost, COALESCE(new.net_unit_price, public.itemprice(public.getitemid(new.item_number), quhead.quhead_cust_id, quhead.quhead_shipto_id, new.qty_ordered, quhead.quhead_curr_id, quhead.quhead_quotedate)) AS "coalesce", public.itemprice(public.getitemid(new.item_number), quhead.quhead_cust_id, quhead.quhead_shipto_id, new.qty_ordered, quhead.quhead_curr_id, quhead.quhead_quotedate) AS itemprice, COALESCE(new.notes, ''::text) AS "coalesce", true AS bool, new.customer_pn, COALESCE(new.create_order, false) AS "coalesce", COALESCE(public.getwarehousid(new.supplying_site, 'SHIPPING'::text), itemsite.itemsite_warehous_id) AS "coalesce", public.getitemid(new.item_number) AS getitemid, COALESCE(new.overwrite_po_price, (0)::numeric) AS "coalesce", COALESCE(public.gettaxtypeid(new.tax_type), public.getitemtaxtype(itemsite.itemsite_item_id, quhead.quhead_taxzone_id)) AS "coalesce", COALESCE(public.getuomid(new.qty_uom), item.item_inv_uom_id) AS "coalesce", public.itemuomtouomratio(item.item_id, COALESCE(public.getuomid(new.qty_uom), item.item_inv_uom_id), item.item_inv_uom_id) AS itemuomtouomratio, COALESCE(public.getuomid(new.price_uom), item.item_price_uom_id) AS "coalesce", public.itemuomtouomratio(item.item_id, COALESCE(public.getuomid(new.price_uom), item.item_price_uom_id), item.item_price_uom_id) AS itemuomtouomratio FROM public.quhead, public.itemsite, public.item, public.whsinfo WHERE ((quhead.quhead_number = new.quote_number) AND (((((((itemsite.itemsite_warehous_id = whsinfo.warehous_id) AND (itemsite.itemsite_item_id = item.item_id)) AND itemsite.itemsite_active) AND (item.item_number = new.item_number)) AND whsinfo.warehous_active) AND whsinfo.warehous_shipping) AND (whsinfo.warehous_code = COALESCE(new.sold_from_site, (SELECT whsinfo.warehous_code FROM public.usrpref, public.whsinfo WHERE (((usrpref.usrpref_username = public.geteffectivextuser()) AND (usrpref.usrpref_name = 'PreferredWarehouse'::text)) AND (whsinfo.warehous_id = (usrpref.usrpref_value)::integer)))))));
111184
 
 
111185
 
 
111186
 
--
111187
 
--
111188
 
 
111189
 
CREATE RULE "_INSERT" AS ON INSERT TO quotelinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('QI'::text, quitem.quitem_id, charass.charass_char_id, new.value) AS updatecharassignment FROM public.quhead, public.quitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((quhead.quhead_number = new.quote_number) AND (quhead.quhead_id = quitem.quitem_quhead_id)) AND (quitem.quitem_linenumber = new.line_number)) AND (quitem.quitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = new.characteristic));
111190
 
 
111191
 
 
111192
 
--
111193
 
--
111194
 
 
111195
 
CREATE RULE "_INSERT" AS ON INSERT TO quotelinecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'QI'::text, public.getquotelineitemid(new.quote_number, new.line_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
111196
 
 
111197
 
 
111198
 
--
111199
 
--
111200
 
 
111201
 
CREATE RULE "_INSERT" AS ON INSERT TO salescredit DO INSTEAD INSERT INTO public.aropenalloc (aropenalloc_aropen_id, aropenalloc_doctype, aropenalloc_doc_id, aropenalloc_amount, aropenalloc_curr_id) VALUES (public.getaropenid(new.customer_number, 'C'::bpchar, new.cm_number), 'S'::bpchar, public.getcoheadid(new.so_number), new.amount, public.getcurrid((new.currency)::text));
111202
 
 
111203
 
 
111204
 
--
111205
 
--
111206
 
 
111207
 
CREATE RULE "_INSERT" AS ON INSERT TO saleshistory DO INSTEAD INSERT INTO public.cohist (cohist_cust_id, cohist_itemsite_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_orderdate, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_shipto_id, cohist_salesrep_id, cohist_duedate, cohist_imported, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_commission, cohist_commissionpaid, cohist_unitcost, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_doctype, cohist_promisedate, cohist_ponumber, cohist_curr_id, cohist_sequence, cohist_taxzone_id, cohist_taxtype_id) VALUES (public.getcustid(new.customer_number), public.getitemsiteid(new.site_code, new.item_number), new.ship_date, new.ship_via, new.order_number, new.order_date, new.invoice_number, new.invoice_date, new.quantity_shipped, COALESCE(new.unit_price, (0)::numeric), public.getshiptoid(new.customer_number, new.shipto_number), public.getsalesrepid(new.sales_rep), new.due_date, true, new.billto_name, new.billto_address1, new.billto_address2, new.billto_address3, new.billto_city, new.billto_state, new.billto_zip, new.shipto_name, new.shipto_address1, new.shipto_address2, new.shipto_address3, new.shipto_city, new.shipto_state, new.shipto_zip, COALESCE(new.commission, (0)::numeric), COALESCE(new.commission_paid, false), COALESCE(new.unit_cost, (0)::numeric), CASE WHEN (new.misc_type = 'Misc. Charge'::text) THEN 'M'::text WHEN (new.misc_type = 'Freight'::text) THEN 'F'::text ELSE NULL::text END, new.misc_description, CASE WHEN (new.misc_type = 'Misc. Charge'::text) THEN public.getglaccntid(new.misc_info) ELSE NULL::integer END, CASE WHEN (new.document_type = 'Invoice'::text) THEN 'I'::text WHEN (new.document_type = 'Credit Memo'::text) THEN 'C'::text ELSE NULL::text END, new.promise_date, new.purchase_order_number, COALESCE(public.getcurrid((new.currency)::text), public.basecurrid()), new.gl_sequence, public.gettaxzoneid(new.tax_zone), public.gettaxtypeid(new.tax_type));
111208
 
 
111209
 
 
111210
 
--
111211
 
--
111212
 
 
111213
 
CREATE RULE "_INSERT" AS ON INSERT TO saleslinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('SI'::text, coitem.coitem_id, charass.charass_char_id, new.value, public.itemcharprice(item.item_id, "char".char_id, new.value, cohead.cohead_cust_id, cohead.cohead_shipto_id, coitem.coitem_qtyord, cohead.cohead_curr_id, cohead.cohead_orderdate)) AS updatecharassignment FROM public.cohead, public.coitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((cohead.cohead_number = (new.order_number)::text) AND (cohead.cohead_id = coitem.coitem_cohead_id)) AND (coitem.coitem_id = public.getcoitemid((new.order_number)::text, new.line_number))) AND (coitem.coitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = new.characteristic));
111214
 
 
111215
 
 
111216
 
--
111217
 
--
111218
 
 
111219
 
CREATE RULE "_INSERT" AS ON INSERT TO saleslinecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'SI'::text, public.getcoitemid((new.order_number)::text, new.line_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
111220
 
 
111221
 
 
111222
 
--
111223
 
--
111224
 
 
111225
 
CREATE RULE "_INSERT" AS ON INSERT TO salesorder DO INSTEAD INSERT INTO public.cohead (cohead_number, cohead_cust_id, cohead_custponumber, cohead_orderdate, cohead_warehous_id, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_salesrep_id, cohead_terms_id, cohead_fob, cohead_shipvia, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_freight, cohead_calcfreight, cohead_misc, cohead_imported, cohead_ordercomments, cohead_shipcomments, cohead_shiptophone, cohead_shipchrg_id, cohead_shipform_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_misc_accnt_id, cohead_misc_descrip, cohead_commission, cohead_holdtype, cohead_packdate, cohead_prj_id, cohead_shipcomplete, cohead_billtocountry, cohead_shiptocountry, cohead_curr_id, cohead_taxzone_id, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_saletype_id, cohead_shipzone_id) SELECT new.order_number, public.getcustid(new.customer_number) AS getcustid, new.cust_po_number, new.order_date, public.getwarehousid(new.site, 'SHIPPING'::text) AS getwarehousid, public.getshiptoid(new.customer_number, new.shipto_number) AS getshiptoid, new.shipto_name, new.shipto_address1, new.shipto_address2, new.shipto_address3, public.getsalesrepid(new.sales_rep) AS getsalesrepid, public.gettermsid(new.terms) AS gettermsid, new.fob, new.ship_via, new.shipto_city, new.shipto_state, new.shipto_postal_code, CASE WHEN COALESCE(new.calculate_freight, public.fetchmetricbool('CalculateFreight'::text)) THEN (0)::numeric ELSE new.freight END AS freight, COALESCE(new.calculate_freight, public.fetchmetricbool('CalculateFreight'::text)) AS "coalesce", new.misc_charge, true AS bool, new.order_notes, new.shipping_notes, new.shipto_phone, public.getshipchrgid(new.shipping_chgs) AS getshipchrgid, public.getshipformid(new.shipping_form) AS getshipformid, new.billto_name, new.billto_address1, new.billto_address2, new.billto_address3, new.billto_city, new.billto_state, new.billto_postal_code, public.getglaccntid(new.misc_account_number) AS getglaccntid, new.misc_charge_description, new.commission, CASE WHEN (new.hold_type = 'Credit'::text) THEN 'C'::text WHEN (new.hold_type = 'Shipping'::text) THEN 'S'::text WHEN (new.hold_type = 'Packing'::text) THEN 'P'::text ELSE 'N'::text END AS "case", new.pack_date, public.getprjid(new.project_number) AS getprjid, new.ship_complete, new.billto_country, new.shipto_country, public.getcurrid((new.currency)::text) AS getcurrid, CASE WHEN (new.tax_zone = 'None'::text) THEN (-1) ELSE public.gettaxzoneid(new.tax_zone) END AS gettaxzoneid, public.getcntctid(new.shipto_contact_number) AS getcntctid, new.shipto_contact_honorific, new.shipto_contact_first, new.shipto_contact_middle, new.shipto_contact_last, new.shipto_contact_suffix, new.shipto_contact_phone, new.shipto_contact_title, new.shipto_contact_fax, new.shipto_contact_email, public.getcntctid(new.billto_contact_number) AS getcntctid, new.billto_contact_name, new.billto_contact_first, new.billto_contact_middle, new.billto_contact_last, new.billto_contact_suffix, new.billto_contact_phone, new.billto_contact_title, new.billto_contct_fax, new.billto_contact_email, public.getsaletypeid(new.sale_type) AS getsaletypeid, public.getshipzoneid(new.shipto_shipzone) AS getshipzoneid FROM public.custinfo WHERE (custinfo.cust_number = new.customer_number);
111226
 
 
111227
 
 
111228
 
--
111229
 
--
111230
 
 
111231
 
CREATE RULE "_INSERT" AS ON INSERT TO salesordercomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'S'::text, public.getsalesorderid((new.order_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
111232
 
 
111233
 
 
111234
 
--
111235
 
--
111236
 
 
111237
 
CREATE RULE "_INSERT" AS ON INSERT TO salesrep DO INSTEAD INSERT INTO public.salesrep (salesrep_active, salesrep_number, salesrep_name, salesrep_commission, salesrep_method, salesrep_emp_id) VALUES (COALESCE(new.active, true), COALESCE(new.number, ''::character varying), COALESCE(new.name, ''::text), COALESCE((new.commission_percent * 0.01), (0)::numeric), ''::bpchar, public.getempid(new.employee));
111238
 
 
111239
 
 
111240
 
--
111241
 
--
111242
 
 
111243
 
CREATE RULE "_INSERT" AS ON INSERT TO site DO INSTEAD INSERT INTO public.whsinfo (warehous_code, warehous_descrip, warehous_fob, warehous_active, warehous_counttag_prefix, warehous_counttag_number, warehous_bol_prefix, warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, warehous_aislesize, warehous_aislealpha, warehous_racksize, warehous_rackalpha, warehous_binsize, warehous_binalpha, warehous_locationsize, warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, warehous_shipping_commission, warehous_cntct_id, warehous_addr_id, warehous_taxzone_id, warehous_transit, warehous_shipform_id, warehous_shipvia_id, warehous_shipcomments, warehous_costcat_id, warehous_sitetype_id, warehous_sequence) VALUES (COALESCE(new.code, ''::character varying), COALESCE(new.description, ''::text), CASE WHEN new.inventory_type THEN COALESCE(new.default_fob, ''::text) ELSE ''::text END, COALESCE(new.active, true), CASE WHEN new.inventory_type THEN COALESCE(new.next_count_tag_prefix, ''::text) ELSE ''::text END, CASE WHEN new.inventory_type THEN COALESCE(new.next_count_tag_number, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.next_bill_of_lading_prefix, ''::text) ELSE ''::text END, CASE WHEN new.inventory_type THEN COALESCE(new.next_bill_of_lading_number, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.shipping_site, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.force_the_use_of_count_slips, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.force_the_use_of_zones, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.aisle_size, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.aisle_allow_alpha_characters, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.rack_size, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.rack_allow_alpha_characters, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.bin_size, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.bin_allow_alpha_characters, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.location_size, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.location_allow_alpha_characters, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.enforce_arbl_naming_convention, false) ELSE false END, COALESCE(public.getglaccntid(new.post_unassigned_transactions_to), (-1)), CASE WHEN new.inventory_type THEN COALESCE((new.shipping_commission * 0.01), (0)::numeric) ELSE (0)::numeric END, public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), CASE WHEN new.inventory_type THEN COALESCE(public.gettaxzoneid(new.tax_zone), (-1)) ELSE NULL::integer END, CASE WHEN new.inventory_type THEN false WHEN new.transit_type THEN true ELSE false END, CASE WHEN new.transit_type THEN COALESCE((public.getshipformid(new.default_shipping_form))::numeric, public.fetchmetricvalue('DefaultShipFormId'::text)) ELSE NULL::numeric END, CASE WHEN new.transit_type THEN COALESCE((public.getshipviaid(new.default_ship_via))::numeric, public.fetchmetricvalue('DefaultShipViaId'::text)) ELSE NULL::numeric END, CASE WHEN new.transit_type THEN COALESCE(new.shipping_comments, ''::text) ELSE ''::text END, CASE WHEN new.transit_type THEN COALESCE(public.getcostcatid(new.default_cost_category), (-1)) ELSE NULL::integer END, COALESCE(public.getsitetypeid(new.type), (-1)), COALESCE(new.scheduling_sequence, 0));
111244
 
 
111245
 
 
111246
 
--
111247
 
--
111248
 
 
111249
 
CREATE RULE "_INSERT" AS ON INSERT TO sitezone DO INSTEAD INSERT INTO public.whsezone (whsezone_warehous_id, whsezone_name, whsezone_descrip) VALUES (public.getwarehousid((new.site)::text, 'ACTIVE'::text), COALESCE(new.name, ''::character varying), COALESCE(new.description, ''::text));
111250
 
 
111251
 
 
111252
 
--
111253
 
--
111254
 
 
111255
 
CREATE RULE "_INSERT" AS ON INSERT TO task DO INSTEAD INSERT INTO public.prjtask (prjtask_prj_id, prjtask_number, prjtask_name, prjtask_descrip, prjtask_owner_username, prjtask_username, prjtask_hours_budget, prjtask_hours_actual, prjtask_exp_budget, prjtask_exp_actual, prjtask_status, prjtask_due_date, prjtask_assigned_date, prjtask_start_date, prjtask_completed_date) VALUES (public.getprjid(new.project_number), new.number, COALESCE(new.name, ''::text), COALESCE(new.description, ''::text), COALESCE(new.owner, public.geteffectivextuser()), COALESCE(new.assigned_to, public.geteffectivextuser()), COALESCE(new.hours_budgeted, (0)::numeric), COALESCE(new.hours_actual, (0)::numeric), COALESCE(new.expenses_budgeted, (0)::numeric), COALESCE(new.expenses_actual, (0)::numeric), CASE WHEN (new.status = 'In-Process'::text) THEN 'O'::text WHEN (new.status = 'Completed'::text) THEN 'C'::text ELSE 'P'::text END, new.due, new.assigned, new.started, new.completed);
111256
 
 
111257
 
 
111258
 
--
111259
 
--
111260
 
 
111261
 
CREATE RULE "_INSERT" AS ON INSERT TO taskcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'TA'::text, public.getprjtaskid((new.project_number)::text, (new.task_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text);
111262
 
 
111263
 
 
111264
 
--
111265
 
--
111266
 
 
111267
 
CREATE RULE "_INSERT" AS ON INSERT TO todo DO INSTEAD SELECT public.createtodoitem(NULL::integer, new.assigned_to, COALESCE(new.task_name, ''::text), COALESCE(new.description, ''::text), public.getincidentid(new.incident), COALESCE(public.getincdtcrmacctid(new.incident), public.getcrmacctid(new.account)), public.getopheadid(new.opportunity), CASE WHEN (new.date_started > ''::text) THEN (new.date_started)::date ELSE NULL::date END, CASE WHEN (new.date_due > ''::text) THEN (new.date_due)::date ELSE NULL::date END, (CASE WHEN (new.status = 'Pending Input'::text) THEN 'P'::text WHEN (new.status = 'Deferred'::text) THEN 'D'::text ELSE 'N'::text END)::bpchar, CASE WHEN (new.date_assigned > ''::text) THEN (new.date_assigned)::date ELSE NULL::date END, CASE WHEN (new.date_completed > ''::text) THEN (new.date_completed)::date ELSE NULL::date END, public.getincdtpriorityid(new.priority), COALESCE(new.notes, ''::text), new.owner) AS createtodoitem;
111268
 
 
111269
 
 
111270
 
--
111271
 
--
111272
 
 
111273
 
CREATE RULE "_INSERT" AS ON INSERT TO vendor DO INSTEAD INSERT INTO public.vendinfo (vend_name, vend_lastpurchdate, vend_active, vend_po, vend_comments, vend_pocomments, vend_number, vend_1099, vend_exported, vend_fobsource, vend_fob, vend_terms_id, vend_shipvia, vend_vendtype_id, vend_qualified, vend_ediemail, vend_ediemailbody, vend_edisubject, vend_edifilename, vend_accntnum, vend_emailpodelivery, vend_restrictpurch, vend_edicc, vend_curr_id, vend_cntct1_id, vend_cntct2_id, vend_addr_id, vend_match, vend_taxzone_id, vend_ach_routingnumber, vend_ach_accntnumber, vend_accnt_id, vend_expcat_id, vend_tax_id) VALUES (COALESCE(new.vendor_name, ''::text), NULL::date, COALESCE(new.active, true), COALESCE(new.sells_purchase_order_items, false), COALESCE(new.notes, ''::text), COALESCE(new.po_comments, ''::text), COALESCE(new.vendor_number, ''::character varying), COALESCE(new.receives_1099, false), false, CASE WHEN (new.default_fob = 'Receiving Site'::text) THEN 'W'::text ELSE 'V'::text END, CASE WHEN (new.default_fob = 'Receiving Site'::text) THEN ''::text ELSE new.default_fob END, COALESCE((public.gettermsid(new.default_terms))::numeric, public.fetchmetricvalue('DefaultTerms'::text)), COALESCE(new.ship_via, public.fetchdefaultshipvia()), public.getvendtypeid(new.vendor_type), COALESCE(new.qualified, false), COALESCE(new.po_edi_email, ''::text), COALESCE(new.po_edi_emailbody, ''::text), COALESCE(new.po_edi_subject, ''::text), COALESCE(new.po_edi_filename, ''::text), COALESCE(new.account_number, ''::text), COALESCE(new.allow_email_po_delivery, false), COALESCE(new.may_only_sell_item_source, false), COALESCE(new.po_edi_cc, ''::text), COALESCE(public.getcurrid((new.default_currency)::text), public.basecurrid()), public.savecntct(public.getcntctid(new.contact1_number), new.contact1_number, NULL::integer, new.contact1_honorific, new.contact1_first, new.contact1_middle, new.contact1_last, new.contact1_suffix, new.contact1_voice, new.contact1_alternate, new.contact1_fax, new.contact1_email, new.contact1_web, new.contact1_job_title, new.contact1_change), public.savecntct(public.getcntctid(new.contact2_number), new.contact2_number, NULL::integer, new.contact2_honorific, new.contact2_first, new.contact2_middle, new.contact2_last, new.contact2_suffix, new.contact2_voice, new.contact2_alternate, new.contact2_fax, new.contact2_email, new.contact2_web, new.contact2_job_title, new.contact2_change), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), COALESCE(new.matching_vo_po_amounts, false), public.gettaxzoneid(new.default_tax_zone), '\x'::bytea, '\x'::bytea, COALESCE(public.getglaccntid(new.default_dist_gl_account), (-1)), COALESCE(public.getexpcatid(new.default_dist_expense_category), (-1)), COALESCE(public.gettaxid(new.default_dist_tax_code), (-1)));
111274
 
 
111275
 
 
111276
 
--
111277
 
--
111278
 
 
111279
 
CREATE RULE "_INSERT" AS ON INSERT TO vendoraddress DO INSTEAD INSERT INTO public.vendaddrinfo (vendaddr_vend_id, vendaddr_code, vendaddr_name, vendaddr_comments, vendaddr_cntct_id, vendaddr_addr_id) VALUES (public.getvendid((new.vendor_number)::text), COALESCE(new.vendor_address_number, ''::character varying), COALESCE(new.vendor_address_name, ''::text), COALESCE(new.notes, ''::text), public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), new.contact_honorific, new.contact_first, new.contact_middle, new.contact_last, new.contact_suffix, new.contact_voice, new.contact_alternate, new.contact_fax, new.contact_email, new.contact_web, new.contact_job_title, new.contact_change), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change));
111280
 
 
111281
 
 
111282
 
--
111283
 
--
111284
 
 
111285
 
CREATE RULE "_INSERT" AS ON INSERT TO vendortype DO INSTEAD INSERT INTO public.vendtype (vendtype_code, vendtype_descrip) VALUES (new.code, COALESCE(new.description, ''::text));
111286
 
 
111287
 
 
111288
 
--
111289
 
--
111290
 
 
111291
 
CREATE RULE "_INSERT_CHAR" AS ON INSERT TO purchaseline DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT 'PI', poitem.poitem_id, "char".char_id, charass.charass_value FROM public.pohead, public.poitem, public.charass, public."char", public.itemsite, public.item WHERE (((((((((pohead.pohead_number = (new.order_number)::text) AND (poitem.poitem_pohead_id = pohead.pohead_id)) AND (poitem.poitem_linenumber = new.line_number)) AND (itemsite.itemsite_id = poitem.poitem_itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND charass.charass_default) AND ("char".char_id = charass.charass_char_id));
111292
 
 
111293
 
 
111294
 
--
111295
 
--
111296
 
 
111297
 
CREATE RULE "_UPDATE" AS ON UPDATE TO salesline DO INSTEAD UPDATE public.coitem SET coitem_status = new.status, coitem_scheddate = new.scheduled_date, coitem_promdate = new.promise_date, coitem_qtyord = new.qty_ordered, coitem_qty_uom_id = public.getuomid(new.qty_uom), coitem_qty_invuomratio = public.itemuomtouomratio(item.item_id, public.getuomid(new.qty_uom), item.item_inv_uom_id), coitem_price = new.net_unit_price, coitem_price_uom_id = public.getuomid(new.price_uom), coitem_price_invuomratio = public.itemuomtouomratio(item.item_id, public.getuomid(new.price_uom), item.item_price_uom_id), coitem_memo = new.notes, coitem_order_type = CASE WHEN (((NOT old.create_order) AND new.create_order) AND (item.item_type = 'M'::bpchar)) THEN 'W'::text WHEN ((((NOT old.create_order) AND new.create_order) AND (item.item_type = 'P'::bpchar)) AND itemsite.itemsite_createsopo) THEN 'P'::text WHEN (((NOT old.create_order) AND new.create_order) AND (item.item_type = 'P'::bpchar)) THEN 'R'::text ELSE NULL::text END, coitem_substitute_item_id = public.getitemid(new.substitute_for), coitem_prcost = new.overwrite_po_price, coitem_taxtype_id = CASE WHEN (new.tax_type = 'None'::text) THEN NULL::integer ELSE public.gettaxtypeid(new.tax_type) END, coitem_warranty = new.warranty, coitem_cos_accnt_id = public.getglaccntid(new.alternate_cos_account), coitem_rev_accnt_id = public.getglaccntid(new.alternate_rev_account) FROM (public.item JOIN public.itemsite ON ((item.item_id = itemsite.itemsite_item_id))) WHERE ((((item.item_number = old.item_number) AND (coitem.coitem_cohead_id = public.getcoheadid((old.order_number)::text))) AND (coitem.coitem_id = public.getcoitemid((old.order_number)::text, (old.line_number)::text))) AND (coitem.coitem_subnumber = 0));
111298
 
 
111299
 
 
111300
 
--
111301
 
--
111302
 
 
111303
 
CREATE RULE "_UPDATE" AS ON UPDATE TO apmemo DO INSTEAD UPDATE public.apopen SET apopen_duedate = new.due_date, apopen_terms_id = public.gettermsid(new.terms), apopen_amount = new.amount, apopen_notes = new.notes WHERE ((apopen.apopen_docnumber = old.document_number) AND ((apopen.apopen_doctype)::text = CASE WHEN (old.document_type = 'Credit Memo'::text) THEN 'C'::text WHEN (old.document_type = 'Debit Memo'::text) THEN 'D'::text ELSE ''::text END));
111304
 
 
111305
 
 
111306
 
--
111307
 
--
111308
 
 
111309
 
CREATE RULE "_UPDATE" AS ON UPDATE TO armemo DO INSTEAD UPDATE public.aropen SET aropen_duedate = new.due_date, aropen_terms_id = public.gettermsid(new.terms), aropen_salesrep_id = public.getsalesrepid(new.sales_rep), aropen_amount = new.amount, aropen_commission_due = new.commission_due, aropen_notes = new.notes, aropen_rsncode_id = public.getrsnid(new.reason_code) WHERE ((aropen.aropen_docnumber = old.document_number) AND ((aropen.aropen_doctype)::text = CASE WHEN (old.document_type = 'Credit Memo'::text) THEN 'C'::text WHEN (old.document_type = 'Debit Memo'::text) THEN 'D'::text ELSE ''::text END));
111310
 
 
111311
 
 
111312
 
--
111313
 
--
111314
 
 
111315
 
CREATE RULE "_UPDATE" AS ON UPDATE TO physinvcount DO INSTEAD NOTHING;
111316
 
 
111317
 
 
111318
 
--
111319
 
--
111320
 
 
111321
 
CREATE RULE "_UPDATE" AS ON UPDATE TO account DO INSTEAD UPDATE public.crmacct SET crmacct_number = new.account_number, crmacct_parent_id = public.getcrmacctid(new.parent_account), crmacct_name = new.account_name, crmacct_active = new.active, crmacct_type = CASE WHEN (new.type = 'Individual'::text) THEN 'I'::text ELSE 'O'::text END, crmacct_cntct_id_1 = public.getcntctid(new.primary_contact_number), crmacct_cntct_id_2 = public.getcntctid(new.secondary_contact_number), crmacct_notes = new.notes WHERE (crmacct.crmacct_number = (old.account_number)::text);
111322
 
 
111323
 
 
111324
 
--
111325
 
--
111326
 
 
111327
 
CREATE RULE "_UPDATE" AS ON UPDATE TO accountchar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'CRMACCT'::text) AND (charass.charass_target_id = public.getcrmacctid((old.account_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CRMACCT'::text)));
111328
 
 
111329
 
 
111330
 
--
111331
 
--
111332
 
 
111333
 
CREATE RULE "_UPDATE" AS ON UPDATE TO accountcomment DO INSTEAD NOTHING;
111334
 
 
111335
 
 
111336
 
--
111337
 
--
111338
 
 
111339
 
CREATE RULE "_UPDATE" AS ON UPDATE TO accountfile DO INSTEAD UPDATE public.url SET url_title = new.title, url_url = new.url WHERE ((((url.url_source_id = public.getcrmacctid(old.account_number)) AND (url.url_source = 'CRMA'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url));
111340
 
 
111341
 
 
111342
 
--
111343
 
--
111344
 
 
111345
 
CREATE RULE "_UPDATE" AS ON UPDATE TO accountimage DO INSTEAD UPDATE public.imageass SET imageass_image_id = public.getimageid(new.image_name) WHERE (((imageass.imageass_source_id = public.getcrmacctid(old.account_number)) AND (imageass.imageass_source = 'CRMA'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name)));
111346
 
 
111347
 
 
111348
 
--
111349
 
--
111350
 
 
111351
 
CREATE RULE "_UPDATE" AS ON UPDATE TO address DO INSTEAD SELECT public.saveaddr(public.getaddrid((new.address_number)::text), (new.address_number)::text, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.active, new.notes, new.change) AS saveaddr;
111352
 
 
111353
 
 
111354
 
--
111355
 
--
111356
 
 
111357
 
CREATE RULE "_UPDATE" AS ON UPDATE TO addresschar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'ADDR'::text) AND (charass.charass_target_id = public.getaddrid((old.address_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'ADDR'::text)));
111358
 
 
111359
 
 
111360
 
--
111361
 
--
111362
 
 
111363
 
CREATE RULE "_UPDATE" AS ON UPDATE TO addresscomment DO INSTEAD NOTHING;
111364
 
 
111365
 
 
111366
 
--
111367
 
--
111368
 
 
111369
 
CREATE RULE "_UPDATE" AS ON UPDATE TO bom DO INSTEAD SELECT public.savebomhead(public.getitemid((new.item_number)::text), (new.revision)::text, new.revision_date, new.document_number, COALESCE(new.batch_size, (0)::numeric), new.total_qty_per) AS savebomhead;
111370
 
 
111371
 
 
111372
 
--
111373
 
--
111374
 
 
111375
 
CREATE RULE "_UPDATE" AS ON UPDATE TO bomitem DO INSTEAD UPDATE public.bomitem SET bomitem_issuemethod = CASE WHEN (new.issue_method = 'Mixed'::text) THEN 'M'::text WHEN (new.issue_method = 'Push'::text) THEN 'S'::text WHEN (new.issue_method = 'Pull'::text) THEN 'L'::text ELSE NULL::text END, bomitem_uom_id = public.getuomid(new.issue_uom), bomitem_qtyper = new.qty_per, bomitem_scrap = new.scrap, bomitem_effective = CASE WHEN (new.effective = 'Always'::text) THEN public.startoftime() ELSE (new.effective)::date END, bomitem_expires = CASE WHEN (new.expires = 'Never'::text) THEN public.endoftime() ELSE (new.expires)::date END, bomitem_createwo = new.create_child_wo, bomitem_booitem_seq_id = COALESCE(public.getbooitemseqid((new.bom_item_number)::text, new.used_at), (-1)), bomitem_schedatwooper = new.schedule_at_wo_operation, bomitem_ecn = new.ecn_number, bomitem_subtype = CASE WHEN (new.substitutions = 'No'::text) THEN 'N'::text WHEN (new.substitutions = 'Item-Defined'::text) THEN 'I'::text WHEN (new.substitutions = 'BOM-Defined'::text) THEN 'B'::text ELSE NULL::text END, bomitem_rev_id = public.getrevid('BOM'::text, (new.bom_item_number)::text, (new.bom_revision)::text), bomitem_char_id = public.getcharid(new.characteristic, 'I'::text), bomitem_value = new.value, bomitem_notes = new.notes, bomitem_ref = new.reference WHERE (bomitem.bomitem_id = old.id);
111376
 
 
111377
 
 
111378
 
--
111379
 
--
111380
 
 
111381
 
CREATE RULE "_UPDATE" AS ON UPDATE TO bomitemcomment DO INSTEAD NOTHING;
111382
 
 
111383
 
 
111384
 
--
111385
 
--
111386
 
 
111387
 
CREATE RULE "_UPDATE" AS ON UPDATE TO bomitemsubstitute DO INSTEAD UPDATE public.bomitemsub SET bomitemsub_uomratio = new.sub_parent_uom_ratio, bomitemsub_rank = new.ranking WHERE ((bomitemsub.bomitemsub_bomitem_id = old.bomitem_id) AND (bomitemsub.bomitemsub_item_id = public.getitemid((old.substitute_item_number)::text)));
111388
 
 
111389
 
 
111390
 
--
111391
 
--
111392
 
 
111393
 
CREATE RULE "_UPDATE" AS ON UPDATE TO budget DO INSTEAD UPDATE public.budghead SET budghead_name = new.name, budghead_descrip = new.description WHERE (budghead.budghead_name = old.name);
111394
 
 
111395
 
 
111396
 
--
111397
 
--
111398
 
 
111399
 
CREATE RULE "_UPDATE" AS ON UPDATE TO budgetentry DO INSTEAD UPDATE public.budgitem SET budgitem_amount = new.amount WHERE (((budgitem.budgitem_budghead_id = public.getbudgheadid(old.name)) AND (budgitem.budgitem_period_id = public.getperiodid(old.period_start))) AND (budgitem.budgitem_accnt_id = public.getglaccntid(old.account)));
111400
 
 
111401
 
 
111402
 
--
111403
 
--
111404
 
 
111405
 
CREATE RULE "_UPDATE" AS ON UPDATE TO cashreceipt DO INSTEAD UPDATE public.cashrcpt SET cashrcpt_amount = new.amount_received, cashrcpt_number = new.cashreceipt_number, cashrcpt_fundstype = CASE WHEN ((new.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((new.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((new.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((new.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((new.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((new.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((new.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((new.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((new.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, cashrcpt_docnumber = new.check_document_number, cashrcpt_bankaccnt_id = public.getbankaccntid(new.post_to), cashrcpt_notes = new.notes, cashrcpt_distdate = CASE WHEN (new.distribution_date > ''::text) THEN (new.distribution_date)::date ELSE NULL::date END, cashrcpt_salescat_id = public.getsalescatid(new.sales_category), cashrcpt_curr_id = public.getcurrid((new.currency)::text), cashrcpt_usecustdeposit = CASE WHEN (new.apply_balance_as = 'Customer Deposit'::text) THEN true ELSE false END WHERE (cashrcpt.cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text));
111406
 
 
111407
 
 
111408
 
--
111409
 
--
111410
 
 
111411
 
CREATE RULE "_UPDATE" AS ON UPDATE TO cashreceiptapply DO INSTEAD UPDATE public.cashrcptitem SET cashrcptitem_amount = new.amount_to_apply, cashrcptitem_discount = new.cashrcptitem_discount WHERE ((cashrcptitem.cashrcptitem_cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)) AND (cashrcptitem.cashrcptitem_aropen_id = public.getaropenid((old.customer_number)::text, (old.doc_type)::bpchar, (old.doc_number)::text)));
111412
 
 
111413
 
 
111414
 
--
111415
 
--
111416
 
 
111417
 
CREATE RULE "_UPDATE" AS ON UPDATE TO cashreceiptapplymisc DO INSTEAD UPDATE public.cashrcptmisc SET cashrcptmisc_accnt_id = public.getglaccntid((new.account)::text), cashrcptmisc_amount = new.amount_to_distribute, cashrcptmisc_notes = new.notes WHERE ((cashrcptmisc.cashrcptmisc_cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)) AND (cashrcptmisc.cashrcptmisc_accnt_id = public.getglaccntid((old.account)::text)));
111418
 
 
111419
 
 
111420
 
--
111421
 
--
111422
 
 
111423
 
CREATE RULE "_UPDATE" AS ON UPDATE TO contact DO INSTEAD SELECT public.savecntct(public.getcntctid((new.contact_number)::text), (new.contact_number)::text, public.getcrmacctid(new.crm_account), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), new.honorific, new.first, new.middle, new.last, new.suffix, new.initials, new.active, new.voice, new.alternate, new.fax, new.email, new.web, new.notes, new.job_title, new.contact_change) AS savecntct;
111424
 
 
111425
 
 
111426
 
--
111427
 
--
111428
 
 
111429
 
CREATE RULE "_UPDATE" AS ON UPDATE TO contactchar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'CNTCT'::text) AND (charass.charass_target_id = public.getcntctid(old.contact_number))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CNTCT'::text)));
111430
 
 
111431
 
 
111432
 
--
111433
 
--
111434
 
 
111435
 
CREATE RULE "_UPDATE" AS ON UPDATE TO contactcomment DO INSTEAD NOTHING;
111436
 
 
111437
 
 
111438
 
--
111439
 
--
111440
 
 
111441
 
CREATE RULE "_UPDATE" AS ON UPDATE TO creditmemo DO INSTEAD UPDATE public.cmhead SET cmhead_custponumber = new.customer_po_number, cmhead_docdate = new.memo_date, cmhead_shipto_id = COALESCE(public.getshiptoid(new.customer_number, new.shipto_number), (-1)), cmhead_shipto_name = new.shipto_name, cmhead_shipto_address1 = new.shipto_address1, cmhead_shipto_address2 = new.shipto_address2, cmhead_shipto_address3 = new.shipto_address3, cmhead_shipto_city = new.shipto_city, cmhead_shipto_state = new.shipto_state, cmhead_shipto_zipcode = new.shipto_postal_code, cmhead_shipto_country = new.shipto_country, cmhead_salesrep_id = public.getsalesrepid(new.sales_rep), cmhead_freight = COALESCE(new.freight, (0)::numeric), cmhead_misc = COALESCE(new.misc_charge_amount, (0)::numeric), cmhead_comments = new.notes, cmhead_billtoname = new.billto_name, cmhead_billtoaddress1 = new.billto_address1, cmhead_billtoaddress2 = new.billto_address2, cmhead_billtoaddress3 = new.billto_address3, cmhead_billtocity = new.billto_city, cmhead_billtostate = new.billto_state, cmhead_billtozip = new.billto_postal_code, cmhead_billtocountry = new.billto_country, cmhead_hold = COALESCE(new.on_hold, false), cmhead_commission = COALESCE(new.commission, (0)::numeric), cmhead_misc_accnt_id = COALESCE(public.getglaccntid(new.misc_charge_credit_account), (-1)), cmhead_misc_descrip = new.misc_charge_description, cmhead_rsncode_id = (SELECT rsncode.rsncode_id FROM public.rsncode WHERE (rsncode.rsncode_code = new.reason_code)), cmhead_curr_id = COALESCE(public.getcurrid((new.currency)::text), (-1)), cmhead_taxzone_id = public.gettaxzoneid(NULLIF(new.tax_zone, 'None'::text)) WHERE ((cmhead.cmhead_number = old.memo_number) AND (cmhead.cmhead_posted = false));
111442
 
 
111443
 
 
111444
 
--
111445
 
--
111446
 
 
111447
 
CREATE RULE "_UPDATE" AS ON UPDATE TO creditmemoline DO INSTEAD SELECT public.updatecreditmemoline(new.*, old.*) AS updatecreditmemoline;
111448
 
 
111449
 
 
111450
 
--
111451
 
--
111452
 
 
111453
 
CREATE RULE "_UPDATE" AS ON UPDATE TO custchar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'C'::text) AND (charass.charass_target_id = public.getcustid((old.customer_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'C'::text)));
111454
 
 
111455
 
 
111456
 
--
111457
 
--
111458
 
 
111459
 
CREATE RULE "_UPDATE" AS ON UPDATE TO custcomment DO INSTEAD NOTHING;
111460
 
 
111461
 
 
111462
 
--
111463
 
--
111464
 
 
111465
 
CREATE RULE "_UPDATE" AS ON UPDATE TO custcreditcard DO INSTEAD NOTHING;
111466
 
 
111467
 
 
111468
 
--
111469
 
--
111470
 
 
111471
 
CREATE RULE "_UPDATE" AS ON UPDATE TO customer DO INSTEAD UPDATE public.custinfo SET cust_active = new.active, cust_custtype_id = public.getcusttypeid(new.customer_type), cust_salesrep_id = public.getsalesrepid(new.sales_rep), cust_commprcnt = (new.commission * 0.01), cust_name = new.customer_name, cust_creditlmt = new.credit_limit, cust_creditrating = new.credit_rating, cust_backorder = new.accepts_backorders, cust_partialship = new.accepts_partial_shipments, cust_terms_id = public.gettermsid(new.default_terms), cust_discntprcnt = new.default_discount, cust_balmethod = CASE WHEN (new.balance_method = 'Balance Forward'::text) THEN 'B'::text WHEN (new.balance_method = 'Open Items'::text) THEN 'O'::text ELSE NULL::text END, cust_ffshipto = new.allow_free_form_shipto, cust_shipform_id = public.getshipformid(new.ship_form), cust_shipvia = new.ship_via, cust_blanketpos = new.uses_blanket_pos, cust_shipchrg_id = COALESCE(public.getshipchrgid(new.shipping_charges), (-1)), cust_creditstatus = CASE WHEN (new.credit_status = 'On Credit Warning'::text) THEN 'W'::text WHEN (new.credit_status = 'On Credit Hold'::text) THEN 'H'::text ELSE 'G'::text END, cust_comments = new.notes, cust_ffbillto = new.allow_free_form_billto, cust_usespos = new.uses_purchase_orders, cust_number = new.customer_number, cust_autoupdatestatus = new.credit_status_exceed_warn, cust_autoholdorders = new.credit_status_exceed_hold, cust_preferred_warehous_id = COALESCE(public.getwarehousid(new.preferred_selling_site, 'ACTIVE'::text), (-1)), cust_curr_id = public.getcurrid((new.default_currency)::text), cust_creditlmt_curr_id = public.getcurrid((new.credit_limit_currency)::text), cust_cntct_id = public.savecntct(public.getcntctid(new.billing_contact_number, false), new.billing_contact_number, public.saveaddr(public.getaddrid(new.billing_contact_address_number), new.billing_contact_address_number, new.billing_contact_address1, new.billing_contact_address2, new.billing_contact_address3, new.billing_contact_city, new.billing_contact_state, new.billing_contact_postalcode, new.billing_contact_country, new.billing_contact_address_change), new.billing_contact_honorific, new.billing_contact_first, new.billing_contact_middle, new.billing_contact_last, new.billing_contact_suffix, new.billing_contact_voice, new.billing_contact_alternate, new.billing_contact_fax, new.billing_contact_email, new.billing_contact_web, new.billing_contact_job_title, new.billing_contact_change), cust_corrcntct_id = public.savecntct(public.getcntctid(new.correspond_contact_number, false), new.correspond_contact_number, public.saveaddr(public.getaddrid(new.correspond_contact_address_number), new.correspond_contact_address_number, new.correspond_contact_address1, new.correspond_contact_address2, new.correspond_contact_address3, new.correspond_contact_city, new.correspond_contact_state, new.correspond_contact_postalcode, new.correspond_contact_country, new.correspond_contact_address_change), new.correspond_contact_honorific, new.correspond_contact_first, new.correspond_contact_middle, new.correspond_contact_last, new.correspond_contact_suffix, new.correspond_contact_voice, new.correspond_contact_alternate, new.correspond_contact_fax, new.correspond_contact_email, new.correspond_contact_web, new.correspond_contact_job_title, new.correspond_contact_change), cust_taxzone_id = public.gettaxzoneid(new.default_tax_zone), cust_gracedays = CASE WHEN (COALESCE(new.alternate_grace_days, 0) > 0) THEN new.alternate_grace_days ELSE NULL::integer END WHERE (custinfo.cust_id = public.getcustid((old.customer_number)::text));
111472
 
 
111473
 
 
111474
 
--
111475
 
--
111476
 
 
111477
 
CREATE RULE "_UPDATE" AS ON UPDATE TO customertype DO INSTEAD UPDATE public.custtype SET custtype_code = new.code, custtype_descrip = new.description, custtype_char = new.enable_characteristics_profile WHERE (custtype.custtype_code = (old.code)::text);
111478
 
 
111479
 
 
111480
 
--
111481
 
--
111482
 
 
111483
 
CREATE RULE "_UPDATE" AS ON UPDATE TO customertypechar DO INSTEAD UPDATE public.charass SET charass_value = new.value, charass_default = new.is_default WHERE (((charass.charass_target_type = 'CT'::text) AND (charass.charass_target_id = public.getcusttypeid((old.customer_type)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CT'::text)));
111484
 
 
111485
 
 
111486
 
--
111487
 
--
111488
 
 
111489
 
CREATE RULE "_UPDATE" AS ON UPDATE TO custshipto DO INSTEAD UPDATE public.shiptoinfo SET shipto_cust_id = public.getcustid((new.customer_number)::text), shipto_name = new.name, shipto_salesrep_id = public.getsalesrepid(new.sales_rep), shipto_comments = new.general_notes, shipto_shipcomments = new.shipping_notes, shipto_shipzone_id = public.getshipzoneid(new.zone), shipto_shipvia = new.ship_via, shipto_commission = (new.commission / (100)::numeric), shipto_shipform_id = public.getshipformid(new.ship_form), shipto_shipchrg_id = public.getshipchrgid(new.shipping_charges), shipto_active = new.active, shipto_default = new.default_flag, shipto_num = old.shipto_number, shipto_ediprofile_id = CASE WHEN (new.edi_profile = 'No EDI'::text) THEN (-1) WHEN (new.edi_profile = 'Use Customer Master'::text) THEN (-2) ELSE public.getediprofileid(new.edi_profile) END, shipto_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), shipto_addr_id = public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), shipto_taxzone_id = public.gettaxzoneid(new.tax_zone) WHERE (shiptoinfo.shipto_id = public.getshiptoid((old.customer_number)::text, (old.shipto_number)::text));
111490
 
 
111491
 
 
111492
 
--
111493
 
--
111494
 
 
111495
 
CREATE RULE "_UPDATE" AS ON UPDATE TO custtax DO INSTEAD UPDATE public.taxreg SET taxreg_number = new.registration_number WHERE (((taxreg.taxreg_rel_type = 'C'::bpchar) AND (taxreg.taxreg_rel_id = public.getcustid((old.customer_number)::text))) AND (taxreg.taxreg_taxauth_id = public.gettaxauthid((old.tax_authority)::text)));
111496
 
 
111497
 
 
111498
 
--
111499
 
--
111500
 
 
111501
 
CREATE RULE "_UPDATE" AS ON UPDATE TO employee DO INSTEAD UPDATE public.emp SET emp_code = new.code, emp_number = new.number, emp_active = new.active, emp_startdate = new.start_date, emp_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), new.honorific, new.first, new.middle, new.last, new.suffix, new.voice, new.alternate, new.fax, new.email, new.web, new.job_title, new.contact_change), emp_warehous_id = public.getwarehousid(new.site, 'ALL'::text), emp_mgr_emp_id = (SELECT emp.emp_id FROM public.emp WHERE (emp.emp_code = new.manager_code)), emp_wage_type = CASE WHEN (new.wage_type = 'Hourly'::text) THEN 'H'::text WHEN (new.wage_type = 'Salaried'::text) THEN 'S'::text ELSE NULL::text END, emp_wage = new.wage, emp_wage_curr_id = COALESCE(public.getcurrid((new.wage_currency)::text), public.basecurrid()), emp_wage_period = CASE WHEN (new.wage_period = 'Hour'::text) THEN 'H'::text WHEN (new.wage_period = 'Day'::text) THEN 'D'::text WHEN (new.wage_period = 'Week'::text) THEN 'W'::text WHEN (new.wage_period = 'Biweek'::text) THEN 'BW'::text WHEN (new.wage_period = 'Month'::text) THEN 'M'::text WHEN (new.wage_period = 'Year'::text) THEN 'Y'::text ELSE NULL::text END, emp_dept_id = public.getdeptid(new.department), emp_shift_id = public.getshiftid(new.shift), emp_image_id = public.getimageid(new.image), emp_extrate = new.rate, emp_extrate_period = CASE WHEN (new.billing_period = 'Hour'::text) THEN 'H'::text WHEN (new.billing_period = 'Day'::text) THEN 'D'::text WHEN (new.billing_period = 'Week'::text) THEN 'W'::text WHEN (new.billing_period = 'Biweek'::text) THEN 'BW'::text WHEN (new.billing_period = 'Month'::text) THEN 'M'::text WHEN (new.billing_period = 'Year'::text) THEN 'Y'::text ELSE NULL::text END, emp_notes = COALESCE(new.notes, ''::text) WHERE (emp.emp_code = (old.code)::text);
111502
 
 
111503
 
 
111504
 
--
111505
 
--
111506
 
 
111507
 
CREATE RULE "_UPDATE" AS ON UPDATE TO employeechar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'EMP'::text) AND (charass.charass_target_id = public.getempid((old.employee_code)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'EMP'::text)));
111508
 
 
111509
 
 
111510
 
--
111511
 
--
111512
 
 
111513
 
CREATE RULE "_UPDATE" AS ON UPDATE TO employeecomment DO INSTEAD NOTHING;
111514
 
 
111515
 
 
111516
 
--
111517
 
--
111518
 
 
111519
 
CREATE RULE "_UPDATE" AS ON UPDATE TO extshipmaint DO INSTEAD UPDATE public.shipdata SET shipdata_cohead_number = new.so_number, shipdata_shiphead_number = new.shipment_number, shipdata_void_ind = new.void, shipdata_shipper = new.shipper, shipdata_billing_option = new.billing_option, shipdata_weight = new.weight, shipdata_base_freight = new.base_freight, shipdata_base_freight_curr_id = public.getcurrid((new.base_freight_currency)::text), shipdata_total_freight = new.total_freight, shipdata_total_freight_curr_id = public.getcurrid((new.total_freight_currency)::text), shipdata_package_type = new.package_type, shipdata_cosmisc_tracknum = new.tracking_number, shipdata_cosmisc_packnum_tracknum = new.package_tracking_number, shipdata_lastupdated = new.last_updated WHERE ((((shipdata.shipdata_cohead_number = (old.so_number)::text) AND (shipdata.shipdata_shiphead_number = (old.shipment_number)::text)) AND (shipdata.shipdata_shipper = (old.shipper)::text)) AND (shipdata.shipdata_cosmisc_packnum_tracknum = (old.package_tracking_number)::text));
111520
 
 
111521
 
 
111522
 
--
111523
 
--
111524
 
 
111525
 
CREATE RULE "_UPDATE" AS ON UPDATE TO freightpricingscheduleitem DO INSTEAD UPDATE public.ipsfreight SET ipsfreight_ipshead_id = public.getipsheadid((old.pricing_schedule)::text), ipsfreight_qtybreak = new.qty_break, ipsfreight_price = new.price, ipsfreight_type = CASE WHEN (new.price_type = 'Flat Rate'::text) THEN 'F'::text WHEN (new.price_type = 'Price Per UOM'::text) THEN 'P'::text ELSE NULL::text END, ipsfreight_warehous_id = CASE WHEN (new.from_site = 'Any'::text) THEN NULL::integer ELSE public.getwarehousid(new.from_site, 'All'::text) END, ipsfreight_shipzone_id = CASE WHEN (new.to_shipzone = 'Any'::text) THEN NULL::integer ELSE public.getshipzoneid(new.to_shipzone) END, ipsfreight_freightclass_id = CASE WHEN (new.freight_class = 'Any'::text) THEN NULL::integer ELSE public.getfreightclassid(new.freight_class) END, ipsfreight_shipvia = CASE WHEN (new.ship_via = 'Any'::text) THEN NULL::text ELSE new.ship_via END WHERE (((((((((ipsfreight.ipsfreight_ipshead_id = public.getipsheadid((old.pricing_schedule)::text)) AND (ipsfreight.ipsfreight_qtybreak = old.qty_break)) AND (ipsfreight.ipsfreight_price = old.price)) AND ((ipsfreight.ipsfreight_type)::text = CASE WHEN (old.price_type = 'Flat Rate'::text) THEN 'F'::text WHEN (old.price_type = 'Price Per UOM'::text) THEN 'P'::text ELSE NULL::text END)) AND ((ipsfreight.ipsfreight_warehous_id IS NULL) AND (old.from_site = 'Any'::text))) OR ((ipsfreight.ipsfreight_warehous_id = CASE WHEN (old.from_site = 'Any'::text) THEN 0 ELSE public.getwarehousid(old.from_site, 'All'::text) END) AND ((ipsfreight.ipsfreight_shipzone_id IS NULL) AND (old.to_shipzone = 'Any'::text)))) OR ((ipsfreight.ipsfreight_shipzone_id = CASE WHEN (old.to_shipzone = 'Any'::text) THEN 0 ELSE public.getshipzoneid(old.to_shipzone) END) AND ((ipsfreight.ipsfreight_freightclass_id IS NULL) AND (old.freight_class = 'Any'::text)))) OR ((ipsfreight.ipsfreight_freightclass_id = CASE WHEN (old.freight_class = 'Any'::text) THEN 0 ELSE public.getfreightclassid(old.freight_class) END) AND ((ipsfreight.ipsfreight_shipvia IS NULL) AND (old.ship_via = 'Any'::text)))) OR (ipsfreight.ipsfreight_shipvia = old.ship_via));
111526
 
 
111527
 
 
111528
 
--
111529
 
--
111530
 
 
111531
 
CREATE RULE "_UPDATE" AS ON UPDATE TO glaccount DO INSTEAD UPDATE public.accnt SET accnt_number = new.account_number, accnt_descrip = new.description, accnt_comments = new.notes, accnt_profit = new.profit_center, accnt_sub = new.sub_account, accnt_type = CASE WHEN (new.type = 'Asset'::text) THEN 'A'::text WHEN (new.type = 'Liability'::text) THEN 'L'::text WHEN (new.type = 'Expense'::text) THEN 'E'::text WHEN (new.type = 'Revenue'::text) THEN 'R'::text WHEN (new.type = 'Equity'::text) THEN 'Q'::text ELSE NULL::text END, accnt_extref = new.ext_reference, accnt_company = new.company, accnt_forwardupdate = new.forward_update_trial_balances, accnt_subaccnttype_code = new.sub_type WHERE (accnt.accnt_id = public.getglaccntid((old.company)::text, (old.profit_center)::text, (old.account_number)::text, (old.sub_account)::text));
111532
 
 
111533
 
 
111534
 
--
111535
 
--
111536
 
 
111537
 
CREATE RULE "_UPDATE" AS ON UPDATE TO incident DO INSTEAD UPDATE public.incdt SET incdt_crmacct_id = public.getcrmacctid(new.crm_account), incdt_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), incdt_descrip = new.notes, incdt_summary = new.description, incdt_item_id = public.getitemid(new.item_number), incdt_status = CASE WHEN (new.status = 'New'::text) THEN 'N'::text WHEN (new.status = 'Feedback'::text) THEN 'F'::text WHEN (new.status = 'Confirmed'::text) THEN 'C'::text WHEN (new.status = 'Assigned'::text) THEN 'A'::text WHEN (new.status = 'Resolved'::text) THEN 'R'::text WHEN (new.status = 'Closed'::text) THEN 'L'::text ELSE NULL::text END, incdt_assigned_username = new.assigned_to, incdt_incdtcat_id = public.getincdtcatid(new.category), incdt_incdtseverity_id = public.getincdtseverityid(new.severity), incdt_incdtpriority_id = public.getincdtpriorityid(new.priority), incdt_incdtresolution_id = public.getincdtresolutionid(new.resolution), incdt_lotserial = new.lot_serial_number, incdt_ls_id = public.getlotserialid(new.item_number, new.lot_serial_number) WHERE (incdt.incdt_id = public.getincidentid(old.incident_number));
111538
 
 
111539
 
 
111540
 
--
111541
 
--
111542
 
 
111543
 
CREATE RULE "_UPDATE" AS ON UPDATE TO incidentchar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'INCDT'::text) AND (charass.charass_target_id = public.getincidentid(old.incident_number))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'INCDT'::text)));
111544
 
 
111545
 
 
111546
 
--
111547
 
--
111548
 
 
111549
 
CREATE RULE "_UPDATE" AS ON UPDATE TO incidentcomment DO INSTEAD NOTHING;
111550
 
 
111551
 
 
111552
 
--
111553
 
--
111554
 
 
111555
 
CREATE RULE "_UPDATE" AS ON UPDATE TO incidentfile DO INSTEAD UPDATE public.url SET url_title = new.title, url_url = new.url WHERE ((((url.url_source_id = public.getincidentid(old.incident_number)) AND (url.url_source = 'INCDT'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url));
111556
 
 
111557
 
 
111558
 
--
111559
 
--
111560
 
 
111561
 
CREATE RULE "_UPDATE" AS ON UPDATE TO incidentimage DO INSTEAD UPDATE public.imageass SET imageass_image_id = public.getimageid(new.image_name) WHERE (((imageass.imageass_source_id = public.getincidentid(old.incident_number)) AND (imageass.imageass_source = 'INCDT'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name)));
111562
 
 
111563
 
 
111564
 
--
111565
 
--
111566
 
 
111567
 
CREATE RULE "_UPDATE" AS ON UPDATE TO invoice DO INSTEAD UPDATE public.invchead SET invchead_invcnumber = old.invoice_number, invchead_ordernumber = new.order_number, invchead_invcdate = new.invoice_date, invchead_shipdate = new.ship_date, invchead_orderdate = new.order_date, invchead_salesrep_id = public.getsalesrepid(new.sales_rep), invchead_commission = new.commission, invchead_taxzone_id = public.gettaxzoneid(NULLIF(new.tax_zone, 'None'::text)), invchead_terms_id = public.gettermsid(new.terms), invchead_cust_id = (SELECT public.getcustid(new.customer_number) AS getcustid), invchead_billto_name = new.billto_name, invchead_billto_address1 = new.billto_address1, invchead_billto_address2 = new.billto_address2, invchead_billto_address3 = new.billto_address3, invchead_billto_city = new.billto_city, invchead_billto_state = new.billto_state, invchead_billto_zipcode = new.billto_postal_code, invchead_billto_country = new.billto_country, invchead_billto_phone = new.billto_phone, invchead_shipto_id = COALESCE(public.getshiptoid(new.customer_number, new.shipto_number), (-1)), invchead_shipto_name = new.shipto_name, invchead_shipto_address1 = new.shipto_address1, invchead_shipto_address2 = new.shipto_address2, invchead_shipto_address3 = new.shipto_address3, invchead_shipto_city = new.shipto_city, invchead_shipto_state = new.shipto_state, invchead_shipto_zipcode = new.shipto_postal_code, invchead_shipto_country = new.shipto_country, invchead_shipto_phone = new.shipto_phone, invchead_ponumber = new.po_number, invchead_shipvia = new.ship_via, invchead_prj_id = COALESCE(public.getprjid(new.project_number), (-1)), invchead_fob = new.fob, invchead_misc_descrip = new.misc_charge_description, invchead_misc_amount = new.misc_charge, invchead_misc_accnt_id = COALESCE(public.getglaccntid(new.misc_charge_account_number), (-1)), invchead_freight = new.freight, invchead_curr_id = COALESCE(public.getcurrid((new.currency)::text), (-1)), invchead_payment = new.payment, invchead_notes = new.notes, invchead_saletype_id = public.getsaletypeid(new.sale_type), invchead_shipzone_id = public.getshipzoneid(new.shipto_shipzone) WHERE ((invchead.invchead_invcnumber = old.invoice_number) AND (invchead.invchead_posted = false));
111568
 
 
111569
 
 
111570
 
--
111571
 
--
111572
 
 
111573
 
CREATE RULE "_UPDATE" AS ON UPDATE TO invoiceline DO INSTEAD SELECT public.updateinvoicelineitem(new.*, old.*) AS updateinvoicelineitem;
111574
 
 
111575
 
 
111576
 
--
111577
 
--
111578
 
 
111579
 
CREATE RULE "_UPDATE" AS ON UPDATE TO item DO INSTEAD UPDATE public.item SET item_active = new.active, item_descrip1 = new.description1, item_descrip2 = new.description2, item_type = CASE WHEN (new.item_type = 'Purchased'::text) THEN 'P'::text WHEN (new.item_type = 'Manufactured'::text) THEN 'M'::text WHEN (new.item_type = 'Job'::text) THEN 'J'::text WHEN (new.item_type = 'Kit'::text) THEN 'K'::text WHEN (new.item_type = 'Phantom'::text) THEN 'F'::text WHEN (new.item_type = 'Reference'::text) THEN 'R'::text WHEN (new.item_type = 'Costing'::text) THEN 'S'::text WHEN (new.item_type = 'Tooling'::text) THEN 'T'::text WHEN (new.item_type = 'Outside Process'::text) THEN 'O'::text WHEN (new.item_type = 'Planning'::text) THEN 'L'::text WHEN (new.item_type = 'Breeder'::text) THEN 'B'::text WHEN (new.item_type = 'Co-Product'::text) THEN 'C'::text WHEN (new.item_type = 'By-Product'::text) THEN 'Y'::text ELSE NULL::text END, item_maxcost = new.maximum_desired_cost, item_classcode_id = public.getclasscodeid(new.class_code), item_inv_uom_id = public.getuomid(new.inventory_uom), item_picklist = new.pick_list_item, item_fractional = new.fractional, item_config = new.configured, item_sold = new.item_is_sold, item_prodcat_id = COALESCE(public.getprodcatid(new.product_category), (-1)), item_exclusive = new.exclusive, item_listprice = new.list_price, item_listcost = new.list_cost, item_price_uom_id = public.getuomid(new.list_price_uom), item_upccode = new.upc_code, item_prodweight = new.product_weight, item_packweight = new.packaging_weight, item_comments = new.notes, item_extdescrip = new.ext_description WHERE (item.item_id = public.getitemid((old.item_number)::text));
111580
 
 
111581
 
 
111582
 
--
111583
 
--
111584
 
 
111585
 
CREATE RULE "_UPDATE" AS ON UPDATE TO itemalias DO INSTEAD UPDATE public.itemalias SET itemalias_number = new.alias_number, itemalias_usedescrip = new.use_description, itemalias_descrip1 = new.description1, itemalias_descrip2 = new.description2, itemalias_comments = new.comments WHERE ((itemalias.itemalias_item_id = public.getitemid((old.item_number)::text)) AND (itemalias.itemalias_number = old.alias_number));
111586
 
 
111587
 
 
111588
 
--
111589
 
--
111590
 
 
111591
 
CREATE RULE "_UPDATE" AS ON UPDATE TO itemchar DO INSTEAD UPDATE public.charass SET charass_value = new.value, charass_default = new.is_default WHERE (((charass.charass_target_type = 'I'::text) AND (charass.charass_target_id = public.getitemid((old.item_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'I'::text)));
111592
 
 
111593
 
 
111594
 
--
111595
 
--
111596
 
 
111597
 
CREATE RULE "_UPDATE" AS ON UPDATE TO itemcomment DO INSTEAD NOTHING;
111598
 
 
111599
 
 
111600
 
--
111601
 
--
111602
 
 
111603
 
CREATE RULE "_UPDATE" AS ON UPDATE TO itemcost DO INSTEAD SELECT public.updateitemcost(public.getitemid((new.item_number)::text), public.getcostelemid((new.costing_element)::text), public.getcurrid((new.currency)::text), new.actual_cost, new.post_to_standard) AS updateitemcost;
111604
 
 
111605
 
 
111606
 
--
111607
 
--
111608
 
 
111609
 
CREATE RULE "_UPDATE" AS ON UPDATE TO itemfile DO INSTEAD UPDATE public.url SET url_title = new.title, url_url = new.url WHERE ((((url.url_source_id = public.getitemid((old.item_number)::text)) AND (url.url_source = 'I'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url));
111610
 
 
111611
 
 
111612
 
--
111613
 
--
111614
 
 
111615
 
CREATE RULE "_UPDATE" AS ON UPDATE TO itemimage DO INSTEAD SELECT public.saveimageass('I'::text, public.getitemid((new.item_number)::text), (CASE WHEN (new.purpose = 'Product Description'::text) THEN 'P'::text WHEN (new.purpose = 'Inventory Description'::text) THEN 'I'::text WHEN (new.purpose = 'Engineering Reference'::text) THEN 'E'::text WHEN (new.purpose = 'Miscellaneous'::text) THEN 'M'::text ELSE 'X'::text END)::bpchar, public.getimageid(new.image_name)) AS saveimageass;
111616
 
 
111617
 
 
111618
 
--
111619
 
--
111620
 
 
111621
 
CREATE RULE "_UPDATE" AS ON UPDATE TO itemsite DO INSTEAD UPDATE public.itemsite SET itemsite_active = new.active, itemsite_dropship = new.dropship, itemsite_posupply = new.po_supplied_at_site, itemsite_createpr = new.create_prs, itemsite_wosupply = new.wo_supplied_at_site, itemsite_createwo = new.create_wos, itemsite_createsopr = new.create_soprs, itemsite_createsopo = new.create_sopos, itemsite_sold = new.sold_from_site, itemsite_soldranking = new.ranking, itemsite_costmethod = CASE WHEN (new.cost_method = 'None'::text) THEN 'N'::text WHEN (new.cost_method = 'Average'::text) THEN 'A'::text WHEN (new.cost_method = 'Standard'::text) THEN 'S'::text WHEN (new.cost_method = 'Job'::text) THEN 'J'::text ELSE NULL::text END, itemsite_controlmethod = CASE WHEN (new.control_method = 'None'::text) THEN 'N'::text WHEN (new.control_method = 'Regular'::text) THEN 'R'::text WHEN (new.control_method = 'Serial #'::text) THEN 'S'::text WHEN (new.control_method = 'Lot #'::text) THEN 'L'::text ELSE NULL::text END, itemsite_perishable = new.perishable, itemsite_plancode_id = public.getplancodeid(new.planner_code), itemsite_costcat_id = public.getcostcatid(new.cost_category), itemsite_loccntrl = new.multiple_location_control, itemsite_location_id = CASE WHEN (new.location = 'N/A'::text) THEN (-1) ELSE public.getlocationid((new.site)::text, new.location) END, itemsite_recvlocation_id = CASE WHEN (new.receive_location = 'N/A'::text) THEN (-1) ELSE public.getlocationid((new.site)::text, new.receive_location) END, itemsite_issuelocation_id = CASE WHEN (new.issue_location = 'N/A'::text) THEN (-1) ELSE public.getlocationid((new.site)::text, new.issue_location) END, itemsite_location_dist = new.auto_distr_location, itemsite_recvlocation_dist = new.auto_distr_receive_location, itemsite_issuelocation_dist = new.auto_distr_issue_location, itemsite_location = new.user_defined_location, itemsite_location_comments = new.user_defined_location, itemsite_disallowblankwip = new.disallow_blank_wip_locations, itemsite_stocked = new.stocked, itemsite_abcclass = new.abc_class, itemsite_autoabcclass = new.allow_automatic_updates, itemsite_cyclecountfreq = new.cycl_cnt_freq, itemsite_eventfence = new.event_fence, itemsite_useparams = new.enforce_order_parameters, itemsite_reorderlevel = new.reorder_level, itemsite_ordertoqty = new.order_up_to, itemsite_minordqty = new.minimum_order, itemsite_maxordqty = new.maximum_order, itemsite_multordqty = new.order_multiple, itemsite_useparamsmanual = new.enforce_on_manual_orders, itemsite_ordergroup = new.group_mps_mrp_orders, itemsite_ordergroup_first = new.first_group, itemsite_mps_timefence = new.mps_time_fence, itemsite_leadtime = new.lead_time, itemsite_safetystock = new.safety_stock, itemsite_supply_itemsite_id = CASE WHEN (new.supplied_from_site = 'None'::text) THEN NULL::integer WHEN (new.supplied_from_site = ''::text) THEN NULL::integer ELSE public.getitemsiteid(new.supplied_from_site, (new.item_number)::text) END, itemsite_notes = new.notes, itemsite_warrpurc = new.require_warranty, itemsite_autoreg = new.auto_register, itemsite_planning_type = CASE WHEN (new.planning_system = 'None'::text) THEN 'N'::text WHEN (new.planning_system = 'MPS'::text) THEN 'S'::text ELSE 'M'::text END WHERE (itemsite.itemsite_id = public.getitemsiteid((old.site)::text, (old.item_number)::text));
111622
 
 
111623
 
 
111624
 
--
111625
 
--
111626
 
 
111627
 
CREATE RULE "_UPDATE" AS ON UPDATE TO itemsitecomment DO INSTEAD NOTHING;
111628
 
 
111629
 
 
111630
 
--
111631
 
--
111632
 
 
111633
 
CREATE RULE "_UPDATE" AS ON UPDATE TO itemsource DO INSTEAD UPDATE public.itemsrc SET itemsrc_vend_item_number = new.vendor_item_number, itemsrc_vend_item_descrip = new.vendor_description, itemsrc_comments = new.notes, itemsrc_vend_uom = new.vendor_uom, itemsrc_invvendoruomratio = new.inventory_vendor_uom_ratio, itemsrc_minordqty = new.minimum_order, itemsrc_multordqty = new.order_multiple, itemsrc_leadtime = new.lead_time, itemsrc_ranking = new.vendor_ranking, itemsrc_active = new.active, itemsrc_default = new.itemsrc_default, itemsrc_manuf_name = new.manufacturer_name, itemsrc_manuf_item_number = new.manufacturer_item_number, itemsrc_manuf_item_descrip = new.manufacturer_description, itemsrc_upccode = new.bar_code, itemsrc_contrct_id = public.getcontrctid(new.contract_number), itemsrc_effective = COALESCE(public.getcontrcteffective(new.contract_number), new.effective_date), itemsrc_expires = COALESCE(public.getcontrctexpires(new.contract_number), new.expires_date) WHERE (((((itemsrc.itemsrc_item_id = public.getitemid((old.item_number)::text)) AND (itemsrc.itemsrc_vend_id = public.getvendid((old.vendor)::text))) AND (itemsrc.itemsrc_vend_item_number = old.vendor_item_number)) AND (itemsrc.itemsrc_manuf_name = old.manufacturer_name)) AND (itemsrc.itemsrc_manuf_item_number = old.manufacturer_item_number));
111634
 
 
111635
 
 
111636
 
--
111637
 
--
111638
 
 
111639
 
CREATE RULE "_UPDATE" AS ON UPDATE TO itemsourceprice DO INSTEAD UPDATE public.itemsrcp SET itemsrcp_qtybreak = new.qty_break, itemsrcp_price = new.price_per_unit, itemsrcp_updated = now(), itemsrcp_curr_id = public.getcurrid((new.currency)::text), itemsrcp_dropship = COALESCE(new.dropship_only, false), itemsrcp_warehous_id = CASE WHEN (new.pricing_site = 'All'::text) THEN (-1) ELSE COALESCE(public.getwarehousid(new.pricing_site, 'ALL'::text), (-1)) END, itemsrcp_type = CASE WHEN (new.pricing_type = 'Discount'::text) THEN 'D'::text ELSE 'N'::text END, itemsrcp_discntprcnt = (COALESCE(new.discount_percent, 0.0) / 100.0), itemsrcp_fixedamtdiscount = new.discount_fixed_amount WHERE ((itemsrcp.itemsrcp_itemsrc_id = public.getitemsrcid((old.item_number)::text, (new.vendor)::text)) AND (itemsrcp.itemsrcp_qtybreak = old.qty_break));
111640
 
 
111641
 
 
111642
 
--
111643
 
--
111644
 
 
111645
 
CREATE RULE "_UPDATE" AS ON UPDATE TO itemsubstitute DO INSTEAD UPDATE public.itemsub SET itemsub_uomratio = new.sub_parent_uom_ratio, itemsub_rank = new.ranking WHERE ((itemsub.itemsub_parent_item_id = public.getitemid((old.root_item_number)::text)) AND (itemsub.itemsub_sub_item_id = public.getitemid((old.substitute_item_number)::text)));
111646
 
 
111647
 
 
111648
 
--
111649
 
--
111650
 
 
111651
 
CREATE RULE "_UPDATE" AS ON UPDATE TO itemtaxtype DO INSTEAD UPDATE public.itemtax SET itemtax_taxzone_id = CASE WHEN ((new.tax_zone)::text = 'Any'::text) THEN NULL::integer ELSE public.gettaxzoneid((new.tax_zone)::text) END, itemtax_taxtype_id = public.gettaxtypeid(new.tax_type) WHERE (((itemtax.itemtax_item_id = public.getitemid((old.item_number)::text)) AND CASE WHEN ((old.tax_zone)::text = 'Any'::text) THEN (itemtax.itemtax_taxzone_id IS NULL) ELSE (itemtax.itemtax_taxzone_id = public.gettaxzoneid((old.tax_zone)::text)) END) AND (itemtax.itemtax_taxtype_id = public.gettaxtypeid(old.tax_type)));
111652
 
 
111653
 
 
111654
 
--
111655
 
--
111656
 
 
111657
 
CREATE RULE "_UPDATE" AS ON UPDATE TO itemuomconversion DO INSTEAD SELECT public.saveitemuomconv(public.getitemid((new.item_number)::text), COALESCE(public.getuomid((new.uom)::text), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid((new.item_number)::text)))), COALESCE(new.uom_value, (1)::numeric), COALESCE(public.getuomid(new.per_uom), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid((new.item_number)::text)))), COALESCE(new.per_uom_value, (1)::numeric), COALESCE(new.fractional, false), public.getuomtypeid(new.selected_types)) AS saveitemuomconv;
111658
 
 
111659
 
 
111660
 
--
111661
 
--
111662
 
 
111663
 
CREATE RULE "_UPDATE" AS ON UPDATE TO journalentry DO INSTEAD NOTHING;
111664
 
 
111665
 
 
111666
 
--
111667
 
--
111668
 
 
111669
 
CREATE RULE "_UPDATE" AS ON UPDATE TO location DO INSTEAD UPDATE public.location SET location_name = new.location, location_descrip = new.description, location_restrict = new.restricted, location_netable = new.netable, location_whsezone_id = public.getwhsezoneid((new.site)::text, new.zone), location_aisle = new.aisle, location_rack = new.rack, location_bin = new.bin WHERE ((location.location_warehous_id = public.getwarehousid((old.site)::text, 'ACTIVE'::text)) AND (location.location_name = (old.location)::text));
111670
 
 
111671
 
 
111672
 
--
111673
 
--
111674
 
 
111675
 
CREATE RULE "_UPDATE" AS ON UPDATE TO misccounttag DO INSTEAD NOTHING;
111676
 
 
111677
 
 
111678
 
--
111679
 
--
111680
 
 
111681
 
CREATE RULE "_UPDATE" AS ON UPDATE TO pricingschedule DO INSTEAD UPDATE public.ipshead SET ipshead_descrip = new.description, ipshead_effective = CASE WHEN (new.effective = 'Always'::text) THEN '1970-01-01'::date ELSE (new.effective)::date END, ipshead_expires = CASE WHEN (new.expires = 'Never'::text) THEN '2100-01-01'::date ELSE (new.expires)::date END, ipshead_updated = now(), ipshead_curr_id = CASE WHEN (SELECT (count(ipsiteminfo.ipsitem_id) = 0) FROM public.ipsiteminfo WHERE (ipsiteminfo.ipsitem_ipshead_id = public.getipsheadid((old.name)::text))) THEN COALESCE(public.getcurrid((new.currency)::text), public.basecurrid()) ELSE public.getcurrid((old.currency)::text) END WHERE (ipshead.ipshead_name = (old.name)::text);
111682
 
 
111683
 
 
111684
 
--
111685
 
--
111686
 
 
111687
 
CREATE RULE "_UPDATE" AS ON UPDATE TO pricingscheduleassign DO INSTEAD UPDATE public.ipsass SET ipsass_ipshead_id = public.getipsheadid((new.pricing_schedule)::text), ipsass_cust_id = CASE WHEN ((new.customer_number)::text = 'Any'::text) THEN (-1) ELSE public.getcustid((new.customer_number)::text) END, ipsass_custtype_id = CASE WHEN ((new.customer_type)::text = 'N/A'::text) THEN (-1) ELSE public.getcusttypeid((new.customer_type)::text) END, ipsass_custtype_pattern = new.customer_type_pattern, ipsass_shipto_id = CASE WHEN (((new.customer_number)::text = 'Any'::text) OR ((new.customer_shipto)::text = 'Any'::text)) THEN (-1) ELSE public.getshiptoid((new.customer_number)::text, (new.customer_shipto)::text) END, ipsass_shipto_pattern = new.customer_shipto_pattern WHERE ((((((ipsass.ipsass_ipshead_id = public.getipsheadid((old.pricing_schedule)::text)) AND (ipsass.ipsass_cust_id = CASE WHEN ((old.customer_number)::text = 'Any'::text) THEN (-1) ELSE public.getcustid((old.customer_number)::text) END)) AND (ipsass.ipsass_custtype_id = CASE WHEN ((old.customer_type)::text = 'N/A'::text) THEN (-1) ELSE public.getcusttypeid((old.customer_type)::text) END)) AND (ipsass.ipsass_custtype_pattern = (old.customer_type_pattern)::text)) AND (ipsass.ipsass_shipto_id = CASE WHEN ((old.customer_shipto)::text = 'Any'::text) THEN (-1) ELSE public.getshiptoid((old.customer_number)::text, (old.customer_shipto)::text) END)) AND (ipsass.ipsass_shipto_pattern = (old.customer_shipto_pattern)::text));
111688
 
 
111689
 
 
111690
 
--
111691
 
--
111692
 
 
111693
 
CREATE RULE "_UPDATE" AS ON UPDATE TO pricingscheduleitem DO INSTEAD SELECT CASE WHEN ((old.type)::text = 'Item'::text) THEN public.saveipsitem(public.getipsitemid((old.pricing_schedule)::text, (old.item_number)::text, old.qty_break, (old.qty_uom)::text, (old.price_uom)::text), public.getipsheadid((new.pricing_schedule)::text), public.getitemid((new.item_number)::text), new.qty_break, new.price, public.getuomid((new.qty_uom)::text), public.getuomid((new.price_uom)::text), new.percent, new.fixedamt, CASE new.pricing_type WHEN 'Nominal'::text THEN 'N'::text WHEN 'Discount'::text THEN 'D'::text WHEN 'Markup'::text THEN 'M'::text ELSE '?'::text END) WHEN ((old.type)::text = 'Product Category'::text) THEN public.saveipsprodcat(public.getipsprodcatid((old.pricing_schedule)::text, (old.product_category)::text, old.qty_break), public.getipsheadid((new.pricing_schedule)::text), public.getprodcatid((new.product_category)::text), new.qty_break, new.percent, new.fixedamt, CASE new.pricing_type WHEN 'Nominal'::text THEN 'N'::text WHEN 'Discount'::text THEN 'D'::text WHEN 'Markup'::text THEN 'M'::text ELSE '?'::text END) ELSE NULL::integer END AS result;
111694
 
 
111695
 
 
111696
 
--
111697
 
--
111698
 
 
111699
 
CREATE RULE "_UPDATE" AS ON UPDATE TO pricingscheduleitemchar DO INSTEAD UPDATE public.ipsitemchar SET ipsitemchar_price = new.price WHERE (((ipsitemchar.ipsitemchar_ipsitem_id = public.getipsitemid((old.pricing_schedule)::text, (old.item_number)::text, old.qty_break, (old.qty_uom)::text, (old.price_uom)::text)) AND (ipsitemchar.ipsitemchar_char_id = public.getcharid((old.characteristic)::text, 'I'::text))) AND (ipsitemchar.ipsitemchar_value = (old.value)::text));
111700
 
 
111701
 
 
111702
 
--
111703
 
--
111704
 
 
111705
 
CREATE RULE "_UPDATE" AS ON UPDATE TO project DO INSTEAD UPDATE public.prj SET prj_name = new.name, prj_descrip = new.description, prj_owner_username = new.owner, prj_username = new.assigned_to, prj_so = new.sales_orders, prj_wo = new.work_orders, prj_po = new.purchase_orders, prj_status = CASE WHEN (new.status = 'In-Process'::text) THEN 'O'::text WHEN (new.status = 'Completed'::text) THEN 'C'::text ELSE 'P'::text END, prj_due_date = new.due, prj_assigned_date = new.assigned, prj_start_date = new.started, prj_completed_date = new.completed WHERE (prj.prj_number = old.number);
111706
 
 
111707
 
 
111708
 
--
111709
 
--
111710
 
 
111711
 
CREATE RULE "_UPDATE" AS ON UPDATE TO projectcomment DO INSTEAD NOTHING;
111712
 
 
111713
 
 
111714
 
--
111715
 
--
111716
 
 
111717
 
CREATE RULE "_UPDATE" AS ON UPDATE TO prospect DO INSTEAD UPDATE public.prospect SET prospect_number = upper((new.prospect_number)::text), prospect_name = new.prospect_name, prospect_active = new.active, prospect_cntct_id = public.getcntctid(new.contact_number), prospect_taxzone_id = public.gettaxzoneid(new.default_tax_zone), prospect_salesrep_id = public.getsalesrepid(new.sales_rep), prospect_warehous_id = public.getwarehousid(new.site_code, 'ACTIVE'::text), prospect_comments = new.notes WHERE (prospect.prospect_id = public.getprospectid((old.prospect_number)::text));
111718
 
 
111719
 
 
111720
 
--
111721
 
--
111722
 
 
111723
 
CREATE RULE "_UPDATE" AS ON UPDATE TO purchaseline DO INSTEAD UPDATE public.poitem SET poitem_duedate = new.due_date, poitem_qty_ordered = new.qty_ordered, poitem_unitprice = new.unit_price, poitem_vend_item_number = new.vend_item_number, poitem_vend_item_descrip = new.vendor_description, poitem_manuf_name = new.manufacturer_name, poitem_manuf_item_number = new.manufacturer_item_number, poitem_manuf_item_descrip = new.manufacturer_description, poitem_comments = new.notes, poitem_freight = new.freight, poitem_prj_id = public.getprjid(new.project_number), poitem_bom_rev_id = public.getrevid('BOM'::text, old.item_number, new.bill_of_materials_revision), poitem_boo_rev_id = public.getrevid('BOO'::text, old.item_number, new.bill_of_operations_revision) WHERE (poitem.poitem_id = public.getpoitemid((old.order_number)::text, old.line_number));
111724
 
 
111725
 
 
111726
 
--
111727
 
--
111728
 
 
111729
 
CREATE RULE "_UPDATE" AS ON UPDATE TO purchaselinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('PI'::text, poitem.poitem_id, charass.charass_char_id, new.value) AS updatecharassignment FROM public.pohead, public.poitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((pohead.pohead_number = (old.order_number)::text) AND (pohead.pohead_id = poitem.poitem_pohead_id)) AND (poitem.poitem_linenumber = old.line_number)) AND (poitem.poitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = old.characteristic));
111730
 
 
111731
 
 
111732
 
--
111733
 
--
111734
 
 
111735
 
CREATE RULE "_UPDATE" AS ON UPDATE TO purchaselinecomment DO INSTEAD NOTHING;
111736
 
 
111737
 
 
111738
 
--
111739
 
--
111740
 
 
111741
 
CREATE RULE "_UPDATE" AS ON UPDATE TO purchaseorder DO INSTEAD UPDATE public.pohead SET pohead_terms_id = public.gettermsid(new.terms), pohead_taxzone_id = public.gettaxzoneid(new.tax_zone), pohead_warehous_id = public.getwarehousid(new.receiving_site, 'ALL'::text), pohead_agent_username = new.purchasing_agent, pohead_vendaddr_id = CASE WHEN (new.alt_address = 'MAIN'::text) THEN NULL::integer ELSE public.getvendaddrid(old.vendor_number, new.alt_address) END, pohead_fob = new.fob, pohead_shipvia = new.ship_via, pohead_curr_id = public.getcurrid((new.currency)::text), pohead_freight = new.freight, pohead_comments = new.notes, pohead_dropship = new.dropship, pohead_vend_cntct_id = public.getcntctid(new.vend_contact_number), pohead_vend_cntct_honorific = new.vend_cntct_honorific, pohead_vend_cntct_first_name = new.vend_cntct_first_name, pohead_vend_cntct_middle = new.vend_cntct_middle, pohead_vend_cntct_last_name = new.vend_cntct_last_name, pohead_vend_cntct_suffix = new.vend_cntct_suffix, pohead_vend_cntct_phone = new.vend_cntct_phone, pohead_vend_cntct_title = new.vend_cntct_title, pohead_vend_cntct_fax = new.vend_cntct_fax, pohead_vend_cntct_email = new.vend_cntct_email, pohead_vendaddress1 = new.vendaddress1, pohead_vendaddress2 = new.vendaddress2, pohead_vendaddress3 = new.vendaddress3, pohead_vendcity = new.vendcity, pohead_vendstate = new.vendstate, pohead_vendzipcode = new.vendzipcode, pohead_vendcountry = new.vendcountry, pohead_shipto_cntct_id = public.getcntctid(new.shipto_contact_number), pohead_shipto_cntct_honorific = new.shipto_cntct_honorific, pohead_shipto_cntct_first_name = new.shipto_cntct_first_name, pohead_shipto_cntct_middle = new.shipto_cntct_middle, pohead_shipto_cntct_last_name = new.shipto_cntct_last_name, pohead_shipto_cntct_suffix = new.shipto_cntct_suffix, pohead_shipto_cntct_phone = new.shipto_cntct_phone, pohead_shipto_cntct_title = new.shipto_cntct_title, pohead_shipto_cntct_fax = new.shipto_cntct_fax, pohead_shipto_cntct_email = new.shipto_cntct_email, pohead_shiptoaddress_id = public.getaddrid(new.shiptoaddress_number), pohead_shiptoaddress1 = new.shiptoaddress1, pohead_shiptoaddress2 = new.shiptoaddress2, pohead_shiptoaddress3 = new.shiptoaddress3, pohead_shiptocity = new.shiptocity, pohead_shiptostate = new.shiptostate, pohead_shiptozipcode = new.shiptozipcode, pohead_shiptocountry = new.shiptocountry, pohead_cohead_id = public.getcoheadid(new.sales_order_number) WHERE (pohead.pohead_number = (old.order_number)::text);
111742
 
 
111743
 
 
111744
 
--
111745
 
--
111746
 
 
111747
 
CREATE RULE "_UPDATE" AS ON UPDATE TO purchaseordercomment DO INSTEAD NOTHING;
111748
 
 
111749
 
 
111750
 
--
111751
 
--
111752
 
 
111753
 
CREATE RULE "_UPDATE" AS ON UPDATE TO quote DO INSTEAD UPDATE public.quhead SET quhead_number = old.quote_number, quhead_cust_id = public.getcustid(new.customer_number, true), quhead_custponumber = new.cust_po_number, quhead_quotedate = new.quote_date, quhead_warehous_id = public.getwarehousid(new.site, 'SHIPPING'::text), quhead_shipto_id = public.getshiptoid(new.customer_number, new.shipto_number), quhead_shiptoname = new.shipto_name, quhead_shiptoaddress1 = new.shipto_address1, quhead_shiptoaddress2 = new.shipto_address2, quhead_shiptoaddress3 = new.shipto_address3, quhead_salesrep_id = public.getsalesrepid(new.sales_rep), quhead_terms_id = public.gettermsid(new.terms), quhead_fob = new.fob, quhead_shipvia = new.ship_via, quhead_shiptocity = new.shipto_city, quhead_shiptostate = new.shipto_state, quhead_shiptozipcode = new.shipto_postal_code, quhead_freight = new.freight, quhead_misc = new.misc_charge, quhead_ordercomments = new.order_notes, quhead_shipcomments = new.shipping_notes, quhead_shiptophone = new.shipto_phone, quhead_billtoname = new.billto_name, quhead_billtoaddress1 = new.billto_address1, quhead_billtoaddress2 = new.billto_address2, quhead_billtoaddress3 = new.billto_address3, quhead_billtocity = new.billto_city, quhead_billtostate = new.billto_state, quhead_billtozip = new.billto_postal_code, quhead_misc_accnt_id = public.getglaccntid(new.misc_account_number), quhead_misc_descrip = new.misc_charge_description, quhead_commission = new.commission, quhead_packdate = new.pack_date, quhead_prj_id = public.getprjid(new.project_number), quhead_billtocountry = new.billto_country, quhead_shiptocountry = new.shipto_country, quhead_curr_id = public.getcurrid((new.currency)::text), quhead_taxzone_id = public.gettaxzoneid(new.tax_zone), quhead_taxtype_id = public.gettaxtypeid(new.tax_type), quhead_expire = new.expire_date, quhead_saletype_id = public.getsaletypeid(new.sale_type), quhead_shipzone_id = public.getshipzoneid(new.shipto_shipzone) WHERE (quhead.quhead_number = (old.quote_number)::text);
111754
 
 
111755
 
 
111756
 
--
111757
 
--
111758
 
 
111759
 
CREATE RULE "_UPDATE" AS ON UPDATE TO quotecomment DO INSTEAD NOTHING;
111760
 
 
111761
 
 
111762
 
--
111763
 
--
111764
 
 
111765
 
CREATE RULE "_UPDATE" AS ON UPDATE TO quoteline DO INSTEAD UPDATE public.quitem SET quitem_scheddate = new.scheduled_date, quitem_qtyord = new.qty_ordered, quitem_qty_uom_id = public.getuomid(new.qty_uom), quitem_qty_invuomratio = public.itemuomtouomratio(item.item_id, COALESCE(public.getuomid(new.qty_uom), item.item_inv_uom_id), item.item_inv_uom_id), quitem_price = new.net_unit_price, quitem_price_uom_id = public.getuomid(new.price_uom), quitem_price_invuomratio = public.itemuomtouomratio(item.item_id, COALESCE(public.getuomid(new.price_uom), item.item_inv_uom_id), item.item_inv_uom_id), quitem_memo = new.notes, quitem_createorder = new.create_order, quitem_order_warehous_id = public.getwarehousid(new.supplying_site, 'SHIPPING'::text), quitem_prcost = new.overwrite_po_price, quitem_taxtype_id = public.gettaxtypeid(new.tax_type) FROM public.item WHERE ((quitem.quitem_quhead_id = public.getquoteid(old.quote_number)) AND (quitem.quitem_linenumber = old.line_number));
111766
 
 
111767
 
 
111768
 
--
111769
 
--
111770
 
 
111771
 
CREATE RULE "_UPDATE" AS ON UPDATE TO quotelinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('QI'::text, quitem.quitem_id, charass.charass_char_id, new.value) AS updatecharassignment FROM public.quhead, public.quitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((quhead.quhead_number = old.quote_number) AND (quhead.quhead_id = quitem.quitem_quhead_id)) AND (quitem.quitem_linenumber = old.line_number)) AND (quitem.quitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = old.characteristic));
111772
 
 
111773
 
 
111774
 
--
111775
 
--
111776
 
 
111777
 
CREATE RULE "_UPDATE" AS ON UPDATE TO quotelinecomment DO INSTEAD NOTHING;
111778
 
 
111779
 
 
111780
 
--
111781
 
--
111782
 
 
111783
 
CREATE RULE "_UPDATE" AS ON UPDATE TO saleshistory DO INSTEAD NOTHING;
111784
 
 
111785
 
 
111786
 
--
111787
 
--
111788
 
 
111789
 
CREATE RULE "_UPDATE" AS ON UPDATE TO saleslinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('SI'::text, coitem.coitem_id, charass.charass_char_id, new.value, public.itemcharprice(item.item_id, "char".char_id, new.value, cohead.cohead_cust_id, cohead.cohead_shipto_id, coitem.coitem_qtyord, cohead.cohead_curr_id, cohead.cohead_orderdate)) AS updatecharassignment FROM public.cohead, public.coitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((cohead.cohead_number = (old.order_number)::text) AND (cohead.cohead_id = coitem.coitem_cohead_id)) AND (coitem.coitem_id = public.getcoitemid((old.order_number)::text, old.line_number))) AND (coitem.coitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = old.characteristic));
111790
 
 
111791
 
 
111792
 
--
111793
 
--
111794
 
 
111795
 
CREATE RULE "_UPDATE" AS ON UPDATE TO saleslinecomment DO INSTEAD NOTHING;
111796
 
 
111797
 
 
111798
 
--
111799
 
--
111800
 
 
111801
 
CREATE RULE "_UPDATE" AS ON UPDATE TO salesorder DO INSTEAD UPDATE public.cohead SET cohead_number = old.order_number, cohead_cust_id = public.getcustid(new.customer_number), cohead_custponumber = new.cust_po_number, cohead_orderdate = new.order_date, cohead_warehous_id = public.getwarehousid(new.site, 'SHIPPING'::text), cohead_shipto_id = public.getshiptoid(new.customer_number, new.shipto_number), cohead_shiptoname = new.shipto_name, cohead_shiptoaddress1 = new.shipto_address1, cohead_shiptoaddress2 = new.shipto_address2, cohead_shiptoaddress3 = new.shipto_address3, cohead_salesrep_id = public.getsalesrepid(new.sales_rep), cohead_terms_id = public.gettermsid(new.terms), cohead_fob = new.fob, cohead_shipvia = new.ship_via, cohead_shiptocity = new.shipto_city, cohead_shiptostate = new.shipto_state, cohead_shiptozipcode = new.shipto_postal_code, cohead_freight = CASE WHEN new.calculate_freight THEN COALESCE((SELECT sum(freightdetail.freightdata_total) AS sum FROM public.freightdetail('SO'::text, public.getcoheadid((old.order_number)::text), public.getcustid(new.customer_number), public.getshiptoid(new.customer_number, new.shipto_number), new.order_date, new.ship_via, public.getcurrid((new.currency)::text)) freightdetail(freightdata_schedule, freightdata_from, freightdata_to, freightdata_shipvia, freightdata_freightclass, freightdata_weight, freightdata_uom, freightdata_price, freightdata_type, freightdata_total, freightdata_currency)), (0)::numeric) ELSE new.freight END, cohead_calcfreight = new.calculate_freight, cohead_misc = new.misc_charge, cohead_ordercomments = new.order_notes, cohead_shipcomments = new.shipping_notes, cohead_shiptophone = new.shipto_phone, cohead_shipchrg_id = public.getshipchrgid(new.shipping_chgs), cohead_shipform_id = public.getshipformid(new.shipping_form), cohead_billtoname = new.billto_name, cohead_billtoaddress1 = new.billto_address1, cohead_billtoaddress2 = new.billto_address2, cohead_billtoaddress3 = new.billto_address3, cohead_billtocity = new.billto_city, cohead_billtostate = new.billto_state, cohead_billtozipcode = new.billto_postal_code, cohead_misc_accnt_id = public.getglaccntid(new.misc_account_number), cohead_misc_descrip = new.misc_charge_description, cohead_commission = new.commission, cohead_holdtype = CASE WHEN (new.hold_type = 'Credit'::text) THEN 'C'::text WHEN (new.hold_type = 'Shipping'::text) THEN 'S'::text WHEN (new.hold_type = 'Packing'::text) THEN 'P'::text ELSE 'N'::text END, cohead_packdate = new.pack_date, cohead_prj_id = public.getprjid(new.project_number), cohead_shipcomplete = new.ship_complete, cohead_billtocountry = new.billto_country, cohead_shiptocountry = new.shipto_country, cohead_curr_id = public.getcurrid((new.currency)::text), cohead_taxzone_id = public.gettaxzoneid(new.tax_zone), cohead_lastupdated = ('now'::text)::timestamp(6) with time zone, cohead_shipto_cntct_id = public.getcntctid(new.shipto_contact_number), cohead_shipto_cntct_honorific = new.shipto_contact_honorific, cohead_shipto_cntct_first_name = new.shipto_contact_first, cohead_shipto_cntct_middle = new.shipto_contact_middle, cohead_shipto_cntct_last_name = new.shipto_contact_last, cohead_shipto_cntct_suffix = new.shipto_contact_suffix, cohead_shipto_cntct_phone = new.shipto_contact_phone, cohead_shipto_cntct_title = new.shipto_contact_title, cohead_shipto_cntct_fax = new.shipto_contact_fax, cohead_shipto_cntct_email = new.shipto_contact_email, cohead_billto_cntct_id = public.getcntctid(new.billto_contact_number), cohead_billto_cntct_honorific = new.billto_contact_name, cohead_billto_cntct_first_name = new.billto_contact_first, cohead_billto_cntct_middle = new.billto_contact_middle, cohead_billto_cntct_last_name = new.billto_contact_last, cohead_billto_cntct_suffix = new.billto_contact_suffix, cohead_billto_cntct_phone = new.billto_contact_phone, cohead_billto_cntct_title = new.billto_contact_title, cohead_billto_cntct_fax = new.billto_contct_fax, cohead_billto_cntct_email = new.billto_contact_email, cohead_saletype_id = public.getsaletypeid(new.sale_type), cohead_shipzone_id = public.getshipzoneid(new.shipto_shipzone) WHERE (cohead.cohead_number = (old.order_number)::text);
111802
 
 
111803
 
 
111804
 
--
111805
 
--
111806
 
 
111807
 
CREATE RULE "_UPDATE" AS ON UPDATE TO salesordercomment DO INSTEAD NOTHING;
111808
 
 
111809
 
 
111810
 
--
111811
 
--
111812
 
 
111813
 
CREATE RULE "_UPDATE" AS ON UPDATE TO salesrep DO INSTEAD UPDATE public.salesrep SET salesrep_active = new.active, salesrep_number = new.number, salesrep_name = new.name, salesrep_commission = (new.commission_percent * 0.01), salesrep_emp_id = public.getempid(new.employee) WHERE (salesrep.salesrep_number = (old.number)::text);
111814
 
 
111815
 
 
111816
 
--
111817
 
--
111818
 
 
111819
 
CREATE RULE "_UPDATE" AS ON UPDATE TO site DO INSTEAD UPDATE public.whsinfo SET warehous_descrip = new.description, warehous_fob = CASE WHEN new.inventory_type THEN new.default_fob ELSE NULL::text END, warehous_active = new.active, warehous_counttag_prefix = CASE WHEN new.inventory_type THEN new.next_count_tag_prefix ELSE NULL::text END, warehous_counttag_number = CASE WHEN new.inventory_type THEN new.next_count_tag_number ELSE NULL::integer END, warehous_bol_prefix = CASE WHEN new.inventory_type THEN new.next_bill_of_lading_prefix ELSE NULL::text END, warehous_bol_number = CASE WHEN new.inventory_type THEN new.next_bill_of_lading_number ELSE NULL::integer END, warehous_shipping = CASE WHEN new.inventory_type THEN new.shipping_site ELSE NULL::boolean END, warehous_useslips = CASE WHEN new.inventory_type THEN new.force_the_use_of_count_slips ELSE NULL::boolean END, warehous_usezones = CASE WHEN new.inventory_type THEN new.force_the_use_of_zones ELSE NULL::boolean END, warehous_aislesize = CASE WHEN new.inventory_type THEN new.aisle_size ELSE NULL::integer END, warehous_aislealpha = CASE WHEN new.inventory_type THEN new.aisle_allow_alpha_characters ELSE NULL::boolean END, warehous_racksize = CASE WHEN new.inventory_type THEN new.rack_size ELSE NULL::integer END, warehous_rackalpha = CASE WHEN new.inventory_type THEN new.rack_allow_alpha_characters ELSE NULL::boolean END, warehous_binsize = CASE WHEN new.inventory_type THEN new.bin_size ELSE NULL::integer END, warehous_binalpha = CASE WHEN new.inventory_type THEN new.bin_allow_alpha_characters ELSE NULL::boolean END, warehous_locationsize = CASE WHEN new.inventory_type THEN new.location_size ELSE NULL::integer END, warehous_locationalpha = CASE WHEN new.inventory_type THEN new.location_allow_alpha_characters ELSE NULL::boolean END, warehous_enforcearbl = CASE WHEN new.inventory_type THEN new.enforce_arbl_naming_convention ELSE NULL::boolean END, warehous_default_accnt_id = public.getglaccntid(new.post_unassigned_transactions_to), warehous_shipping_commission = CASE WHEN new.inventory_type THEN (new.shipping_commission * 0.01) ELSE NULL::numeric END, warehous_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), warehous_addr_id = public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), warehous_taxzone_id = CASE WHEN new.inventory_type THEN public.gettaxzoneid(new.tax_zone) ELSE NULL::integer END, warehous_transit = CASE WHEN new.inventory_type THEN false WHEN new.transit_type THEN true ELSE NULL::boolean END, warehous_shipform_id = CASE WHEN new.transit_type THEN public.getshipformid(new.default_shipping_form) ELSE NULL::integer END, warehous_shipvia_id = CASE WHEN new.transit_type THEN public.getshipviaid(new.default_ship_via) ELSE NULL::integer END, warehous_shipcomments = CASE WHEN new.transit_type THEN new.shipping_comments ELSE NULL::text END, warehous_costcat_id = CASE WHEN new.transit_type THEN public.getcostcatid(new.default_cost_category) ELSE NULL::integer END, warehous_sitetype_id = public.getsitetypeid(new.type), warehous_sequence = new.scheduling_sequence WHERE (whsinfo.warehous_id = public.getwarehousid((old.code)::text, 'ALL'::text));
111820
 
 
111821
 
 
111822
 
--
111823
 
--
111824
 
 
111825
 
CREATE RULE "_UPDATE" AS ON UPDATE TO sitezone DO INSTEAD UPDATE public.whsezone SET whsezone_descrip = new.description WHERE ((whsezone.whsezone_warehous_id = public.getwarehousid((old.site)::text, 'ACTIVE'::text)) AND (whsezone.whsezone_name = (old.name)::text));
111826
 
 
111827
 
 
111828
 
--
111829
 
--
111830
 
 
111831
 
CREATE RULE "_UPDATE" AS ON UPDATE TO task DO INSTEAD UPDATE public.prjtask SET prjtask_name = new.name, prjtask_descrip = new.description, prjtask_owner_username = new.owner, prjtask_username = new.assigned_to, prjtask_hours_budget = new.hours_budgeted, prjtask_hours_actual = new.hours_actual, prjtask_exp_budget = new.expenses_budgeted, prjtask_exp_actual = new.expenses_actual, prjtask_status = CASE WHEN (new.status = 'In-Process'::text) THEN 'O'::text WHEN (new.status = 'Completed'::text) THEN 'C'::text ELSE 'P'::text END, prjtask_due_date = new.due, prjtask_assigned_date = new.assigned, prjtask_start_date = new.started, prjtask_completed_date = new.completed WHERE ((prjtask.prjtask_prj_id = public.getprjid(old.project_number)) AND (prjtask.prjtask_number = old.number));
111832
 
 
111833
 
 
111834
 
--
111835
 
--
111836
 
 
111837
 
CREATE RULE "_UPDATE" AS ON UPDATE TO taskcomment DO INSTEAD NOTHING;
111838
 
 
111839
 
 
111840
 
--
111841
 
--
111842
 
 
111843
 
CREATE RULE "_UPDATE" AS ON UPDATE TO todo DO INSTEAD SELECT public.updatetodoitem(old.task_number, old.assigned_to, new.task_name, new.description, public.getincidentid(new.incident), COALESCE(public.getincdtcrmacctid(new.incident), public.getcrmacctid(new.account)), public.getopheadid(new.opportunity), CASE WHEN (new.date_started > ''::text) THEN (new.date_started)::date ELSE NULL::date END, CASE WHEN (new.date_due > ''::text) THEN (new.date_due)::date ELSE NULL::date END, (CASE WHEN (new.status = 'Pending Input'::text) THEN 'P'::text WHEN (new.status = 'Deferred'::text) THEN 'D'::text WHEN (new.status = 'Neither'::text) THEN 'N'::text ELSE NULL::text END)::bpchar, CASE WHEN (new.date_assigned > ''::text) THEN (new.date_assigned)::date ELSE NULL::date END, CASE WHEN (new.date_completed > ''::text) THEN (new.date_completed)::date ELSE NULL::date END, public.getincdtpriorityid(new.priority), new.notes, new.active, new.owner) AS updatetodoitem;
111844
 
 
111845
 
 
111846
 
--
111847
 
--
111848
 
 
111849
 
CREATE RULE "_UPDATE" AS ON UPDATE TO vendor DO INSTEAD UPDATE public.vendinfo SET vend_name = new.vendor_name, vend_active = new.active, vend_po = new.sells_purchase_order_items, vend_comments = new.notes, vend_pocomments = new.po_comments, vend_1099 = new.receives_1099, vend_fobsource = CASE WHEN (new.default_fob IS NULL) THEN NULL::text WHEN (new.default_fob = 'Receiving Site'::text) THEN 'W'::text ELSE 'V'::text END, vend_fob = CASE WHEN (new.default_fob IS NULL) THEN NULL::text WHEN (new.default_fob = 'Receiving Site'::text) THEN ''::text ELSE new.default_fob END, vend_terms_id = public.gettermsid(new.default_terms), vend_shipvia = new.ship_via, vend_vendtype_id = public.getvendtypeid(new.vendor_type), vend_qualified = new.qualified, vend_ediemail = new.po_edi_email, vend_ediemailbody = new.po_edi_emailbody, vend_edisubject = new.po_edi_subject, vend_edifilename = new.po_edi_filename, vend_accntnum = new.account_number, vend_emailpodelivery = new.allow_email_po_delivery, vend_restrictpurch = new.may_only_sell_item_source, vend_edicc = new.po_edi_cc, vend_curr_id = public.getcurrid((new.default_currency)::text), vend_cntct1_id = public.savecntct(public.getcntctid(new.contact1_number), new.contact1_number, NULL::integer, new.contact1_honorific, new.contact1_first, new.contact1_middle, new.contact1_last, new.contact1_suffix, new.contact1_voice, new.contact1_alternate, new.contact1_fax, new.contact1_email, new.contact1_web, new.contact1_job_title, new.contact1_change), vend_cntct2_id = public.savecntct(public.getcntctid(new.contact2_number), new.contact2_number, NULL::integer, new.contact2_honorific, new.contact2_first, new.contact2_middle, new.contact2_last, new.contact2_suffix, new.contact2_voice, new.contact2_alternate, new.contact2_fax, new.contact2_email, new.contact2_web, new.contact2_job_title, new.contact2_change), vend_addr_id = public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), vend_match = new.matching_vo_po_amounts, vend_taxzone_id = public.gettaxzoneid(new.default_tax_zone), vend_accnt_id = COALESCE(public.getglaccntid(NULLIF(new.default_dist_gl_account, 'N/A'::text)), (-1)), vend_expcat_id = COALESCE(public.getexpcatid(NULLIF(new.default_dist_expense_category, 'N/A'::text)), (-1)), vend_tax_id = COALESCE(public.gettaxid(NULLIF(new.default_dist_tax_code, 'N/A'::text)), (-1)) WHERE (vendinfo.vend_id = public.getvendid((old.vendor_number)::text));
111850
 
 
111851
 
 
111852
 
--
111853
 
--
111854
 
 
111855
 
CREATE RULE "_UPDATE" AS ON UPDATE TO vendoraddress DO INSTEAD UPDATE public.vendaddrinfo SET vendaddr_vend_id = public.getvendid((new.vendor_number)::text), vendaddr_code = new.vendor_address_number, vendaddr_name = new.vendor_address_name, vendaddr_comments = new.notes, vendaddr_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), new.contact_honorific, new.contact_first, new.contact_middle, new.contact_last, new.contact_suffix, new.contact_voice, new.contact_alternate, new.contact_fax, new.contact_email, new.contact_web, new.contact_job_title, new.contact_change), vendaddr_addr_id = public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change) WHERE (vendaddrinfo.vendaddr_id = public.getvendaddrid((old.vendor_number)::text, (old.vendor_address_number)::text));
111856
 
 
111857
 
 
111858
 
--
111859
 
--
111860
 
 
111861
 
CREATE RULE "_UPDATE" AS ON UPDATE TO vendortype DO INSTEAD UPDATE public.vendtype SET vendtype_code = new.code, vendtype_descrip = new.description WHERE (vendtype.vendtype_code = (old.code)::text);
111862
 
 
111863
 
 
111864
 
SET search_path = public, pg_catalog;
111865
 
 
111866
 
--
111867
 
--
111868
 
 
111869
 
CREATE RULE "_DELETE" AS ON DELETE TO url DO INSTEAD NOTHING;
111870
 
 
111871
 
 
111872
 
--
111873
 
--
111874
 
 
111875
 
CREATE RULE "_DELETE_FILE" AS ON DELETE TO url WHERE (old.url_stream IS NOT NULL) DO INSTEAD SELECT deletefile(old.url_id) AS deletefile;
111876
 
 
111877
 
 
111878
 
--
111879
 
--
111880
 
 
111881
 
CREATE RULE "_DELETE_URL" AS ON DELETE TO url WHERE (old.url_stream IS NULL) DO INSTEAD SELECT deleteurl(old.url_id) AS deleteurl;
111882
 
 
111883
 
 
111884
 
--
111885
 
--
111886
 
 
111887
 
CREATE RULE "_INSERT" AS ON INSERT TO url DO INSTEAD NOTHING;
111888
 
 
111889
 
 
111890
 
--
111891
 
--
111892
 
 
111893
 
CREATE RULE "_INSERT_FILE" AS ON INSERT TO url WHERE (new.url_stream IS NOT NULL) DO INSTEAD INSERT INTO docass (docass_id, docass_source_id, docass_source_type, docass_target_id, docass_target_type, docass_purpose) VALUES (COALESCE((new.url_id)::bigint, nextval('docass_docass_id_seq'::regclass)), new.url_source_id, new.url_source, createfile(new.url_title, new.url_url, new.url_stream), 'FILE'::text, 'S'::bpchar);
111894
 
 
111895
 
 
111896
 
--
111897
 
--
111898
 
 
111899
 
CREATE RULE "_INSERT_URL" AS ON INSERT TO url WHERE (new.url_stream IS NULL) DO INSTEAD INSERT INTO docass (docass_id, docass_source_id, docass_source_type, docass_target_id, docass_target_type, docass_purpose) VALUES (COALESCE((new.url_id)::bigint, nextval('docass_docass_id_seq'::regclass)), new.url_source_id, new.url_source, createurl(new.url_title, new.url_url), 'URL'::text, 'S'::bpchar);
111900
 
 
111901
 
 
111902
 
--
111903
 
--
111904
 
 
111905
 
CREATE RULE "_UPDATE" AS ON UPDATE TO url DO INSTEAD NOTHING;
111906
 
 
111907
 
 
111908
 
--
111909
 
--
111910
 
 
111911
 
CREATE RULE "_UPDATE_FILE" AS ON UPDATE TO url WHERE (new.url_stream IS NOT NULL) DO INSTEAD UPDATE file SET file_title = new.url_title, file_stream = new.url_stream FROM docass WHERE (((docass.docass_id = old.url_id) AND (docass.docass_target_id = file.file_id)) AND (docass.docass_target_type = 'FILE'::text));
111912
 
 
111913
 
 
111914
 
--
111915
 
--
111916
 
 
111917
 
CREATE RULE "_UPDATE_URL" AS ON UPDATE TO url WHERE (new.url_stream IS NULL) DO INSTEAD UPDATE urlinfo SET url_title = new.url_title, url_url = new.url_url FROM docass WHERE (((docass.docass_id = old.url_id) AND (docass.docass_target_id = urlinfo.url_id)) AND (docass.docass_target_type = 'URL'::text));
111918
 
 
111919
 
 
111920
 
SET search_path = fixcountry, pg_catalog;
111921
 
 
111922
 
--
111923
 
--
111924
 
 
111925
 
CREATE TRIGGER pkgcmdaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaftertrigger();
111926
 
 
111927
 
 
111928
 
--
111929
 
--
111930
 
 
111931
 
CREATE TRIGGER pkgcmdaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaltertrigger();
111932
 
 
111933
 
 
111934
 
--
111935
 
--
111936
 
 
111937
 
CREATE TRIGGER pkgcmdargaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaftertrigger();
111938
 
 
111939
 
 
111940
 
--
111941
 
--
111942
 
 
111943
 
CREATE TRIGGER pkgcmdargaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaltertrigger();
111944
 
 
111945
 
 
111946
 
--
111947
 
--
111948
 
 
111949
 
CREATE TRIGGER pkgcmdargbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargbeforetrigger();
111950
 
 
111951
 
 
111952
 
--
111953
 
--
111954
 
 
111955
 
CREATE TRIGGER pkgcmdbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdbeforetrigger();
111956
 
 
111957
 
 
111958
 
--
111959
 
--
111960
 
 
111961
 
CREATE TRIGGER pkgimageaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimageaftertrigger();
111962
 
 
111963
 
 
111964
 
--
111965
 
--
111966
 
 
111967
 
CREATE TRIGGER pkgimagealtertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagealtertrigger();
111968
 
 
111969
 
 
111970
 
--
111971
 
--
111972
 
 
111973
 
CREATE TRIGGER pkgimagebeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagebeforetrigger();
111974
 
 
111975
 
 
111976
 
--
111977
 
--
111978
 
 
111979
 
CREATE TRIGGER pkgmetasqlaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaftertrigger();
111980
 
 
111981
 
 
111982
 
--
111983
 
--
111984
 
 
111985
 
CREATE TRIGGER pkgmetasqlaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaltertrigger();
111986
 
 
111987
 
 
111988
 
--
111989
 
--
111990
 
 
111991
 
CREATE TRIGGER pkgmetasqlbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlbeforetrigger();
111992
 
 
111993
 
 
111994
 
--
111995
 
--
111996
 
 
111997
 
CREATE TRIGGER pkgprivaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaftertrigger();
111998
 
 
111999
 
 
112000
 
--
112001
 
--
112002
 
 
112003
 
CREATE TRIGGER pkgprivaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaltertrigger();
112004
 
 
112005
 
 
112006
 
--
112007
 
--
112008
 
 
112009
 
CREATE TRIGGER pkgprivbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivbeforetrigger();
112010
 
 
112011
 
 
112012
 
--
112013
 
--
112014
 
 
112015
 
CREATE TRIGGER pkgreportaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaftertrigger();
112016
 
 
112017
 
 
112018
 
--
112019
 
--
112020
 
 
112021
 
CREATE TRIGGER pkgreportaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaltertrigger();
112022
 
 
112023
 
 
112024
 
--
112025
 
--
112026
 
 
112027
 
CREATE TRIGGER pkgreportbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportbeforetrigger();
112028
 
 
112029
 
 
112030
 
--
112031
 
--
112032
 
 
112033
 
CREATE TRIGGER pkgscriptaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaftertrigger();
112034
 
 
112035
 
 
112036
 
--
112037
 
--
112038
 
 
112039
 
CREATE TRIGGER pkgscriptaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaltertrigger();
112040
 
 
112041
 
 
112042
 
--
112043
 
--
112044
 
 
112045
 
CREATE TRIGGER pkgscriptbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptbeforetrigger();
112046
 
 
112047
 
 
112048
 
--
112049
 
--
112050
 
 
112051
 
CREATE TRIGGER pkguiformaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaftertrigger();
112052
 
 
112053
 
 
112054
 
--
112055
 
--
112056
 
 
112057
 
CREATE TRIGGER pkguiformaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaltertrigger();
112058
 
 
112059
 
 
112060
 
--
112061
 
--
112062
 
 
112063
 
CREATE TRIGGER pkguiformbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformbeforetrigger();
112064
 
 
112065
 
 
112066
 
SET search_path = public, pg_catalog;
112067
 
 
112068
 
--
112069
 
--
112070
 
 
112071
 
CREATE TRIGGER accntdeletetrigger BEFORE DELETE ON accnt FOR EACH ROW EXECUTE PROCEDURE _accntdeletetrigger();
112072
 
 
112073
 
 
112074
 
--
112075
 
--
112076
 
 
112077
 
CREATE TRIGGER accnttrigger BEFORE INSERT OR UPDATE ON accnt FOR EACH ROW EXECUTE PROCEDURE _accnttrigger();
112078
 
 
112079
 
 
112080
 
--
112081
 
--
112082
 
 
112083
 
CREATE TRIGGER accntuniquetrigger BEFORE INSERT ON accnt FOR EACH ROW EXECUTE PROCEDURE _accntuniquetrigger();
112084
 
 
112085
 
 
112086
 
--
112087
 
--
112088
 
 
112089
 
CREATE TRIGGER addrtrigger BEFORE INSERT OR DELETE OR UPDATE ON addr FOR EACH ROW EXECUTE PROCEDURE _addrtrigger();
112090
 
 
112091
 
 
112092
 
--
112093
 
--
112094
 
 
112095
 
CREATE TRIGGER alarmbeforetrigger BEFORE INSERT ON alarm FOR EACH ROW EXECUTE PROCEDURE _alarmbeforetrigger();
112096
 
 
112097
 
 
112098
 
--
112099
 
--
112100
 
 
112101
 
CREATE TRIGGER apapplytrigger BEFORE INSERT OR UPDATE ON apapply FOR EACH ROW EXECUTE PROCEDURE _apapplytrigger();
112102
 
 
112103
 
 
112104
 
--
112105
 
--
112106
 
 
112107
 
CREATE TRIGGER apopentrigger BEFORE INSERT OR UPDATE ON apopen FOR EACH ROW EXECUTE PROCEDURE _apopentrigger();
112108
 
 
112109
 
 
112110
 
--
112111
 
--
112112
 
 
112113
 
CREATE TRIGGER arapplytrigger BEFORE INSERT OR UPDATE ON arapply FOR EACH ROW EXECUTE PROCEDURE _arapplytrigger();
112114
 
 
112115
 
 
112116
 
--
112117
 
--
112118
 
 
112119
 
CREATE TRIGGER aropenaftertrigger AFTER INSERT OR UPDATE ON aropen FOR EACH ROW EXECUTE PROCEDURE _aropenaftertrigger();
112120
 
 
112121
 
 
112122
 
--
112123
 
--
112124
 
 
112125
 
CREATE TRIGGER aropentrigger BEFORE INSERT OR UPDATE ON aropen FOR EACH ROW EXECUTE PROCEDURE _aropentrigger();
112126
 
 
112127
 
 
112128
 
--
112129
 
--
112130
 
 
112131
 
CREATE TRIGGER bomheadtrigger AFTER INSERT OR DELETE OR UPDATE ON bomhead FOR EACH ROW EXECUTE PROCEDURE _bomheadtrigger();
112132
 
 
112133
 
 
112134
 
--
112135
 
--
112136
 
 
112137
 
CREATE TRIGGER bomitemaftertrigger AFTER INSERT OR UPDATE ON bomitem FOR EACH ROW EXECUTE PROCEDURE _bomitemaftertrigger();
112138
 
 
112139
 
 
112140
 
--
112141
 
--
112142
 
 
112143
 
CREATE TRIGGER bomitembeforedeletetrigger BEFORE DELETE ON bomitem FOR EACH ROW EXECUTE PROCEDURE _bomitembeforedeletetrigger();
112144
 
 
112145
 
 
112146
 
--
112147
 
--
112148
 
 
112149
 
CREATE TRIGGER bomitembeforetrigger BEFORE INSERT OR UPDATE ON bomitem FOR EACH ROW EXECUTE PROCEDURE _bomitembeforetrigger();
112150
 
 
112151
 
 
112152
 
--
112153
 
--
112154
 
 
112155
 
CREATE TRIGGER bomitemsubtrigger BEFORE INSERT OR DELETE OR UPDATE ON bomitemsub FOR EACH ROW EXECUTE PROCEDURE _bomitemsubtrigger();
112156
 
 
112157
 
 
112158
 
--
112159
 
--
112160
 
 
112161
 
CREATE TRIGGER cashrcptitemaftertrigger AFTER INSERT OR UPDATE ON cashrcptitem FOR EACH ROW EXECUTE PROCEDURE _cashrcptitemaftertrigger();
112162
 
 
112163
 
 
112164
 
--
112165
 
--
112166
 
 
112167
 
CREATE TRIGGER cashrcptitemtrigger BEFORE INSERT OR UPDATE ON cashrcptitem FOR EACH ROW EXECUTE PROCEDURE _cashrcptitemtrigger();
112168
 
 
112169
 
 
112170
 
--
112171
 
--
112172
 
 
112173
 
CREATE TRIGGER cashrcptmisctrigger BEFORE INSERT OR UPDATE ON cashrcptmisc FOR EACH ROW EXECUTE PROCEDURE _cashrcptmisctrigger();
112174
 
 
112175
 
 
112176
 
--
112177
 
--
112178
 
 
112179
 
CREATE TRIGGER cashrcpttrigger BEFORE INSERT OR UPDATE ON cashrcpt FOR EACH ROW EXECUTE PROCEDURE _cashrcpttrigger();
112180
 
 
112181
 
 
112182
 
--
112183
 
--
112184
 
 
112185
 
CREATE TRIGGER ccardtrigger BEFORE INSERT OR UPDATE ON ccard FOR EACH ROW EXECUTE PROCEDURE _ccardtrigger();
112186
 
 
112187
 
 
112188
 
--
112189
 
--
112190
 
 
112191
 
CREATE TRIGGER ccpaybeforetrigger BEFORE INSERT OR UPDATE ON ccpay FOR EACH ROW EXECUTE PROCEDURE _ccpaybeforetrigger();
112192
 
 
112193
 
 
112194
 
--
112195
 
--
112196
 
 
112197
 
CREATE TRIGGER charasshistorytrigger BEFORE INSERT OR DELETE OR UPDATE ON charass FOR EACH ROW EXECUTE PROCEDURE _charasshistorytrigger();
112198
 
 
112199
 
 
112200
 
--
112201
 
--
112202
 
 
112203
 
CREATE TRIGGER charasstrigger AFTER INSERT OR UPDATE ON charass FOR EACH ROW EXECUTE PROCEDURE _charasstrigger();
112204
 
 
112205
 
 
112206
 
--
112207
 
--
112208
 
 
112209
 
CREATE TRIGGER charbeforetrigger BEFORE INSERT OR UPDATE ON "char" FOR EACH ROW EXECUTE PROCEDURE _charbeforetrigger();
112210
 
 
112211
 
 
112212
 
--
112213
 
--
112214
 
 
112215
 
CREATE TRIGGER charopttrigger AFTER DELETE OR UPDATE ON charopt FOR EACH ROW EXECUTE PROCEDURE _charopttrigger();
112216
 
 
112217
 
 
112218
 
--
112219
 
--
112220
 
 
112221
 
CREATE TRIGGER checkheadbeforetrigger BEFORE INSERT OR UPDATE ON checkhead FOR EACH ROW EXECUTE PROCEDURE _checkheadbeforetrigger();
112222
 
 
112223
 
 
112224
 
--
112225
 
--
112226
 
 
112227
 
CREATE TRIGGER cmheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON cmhead FOR EACH ROW EXECUTE PROCEDURE _cmheadbeforetrigger();
112228
 
 
112229
 
 
112230
 
--
112231
 
--
112232
 
 
112233
 
CREATE TRIGGER cmheadtrigger AFTER INSERT OR DELETE OR UPDATE ON cmhead FOR EACH ROW EXECUTE PROCEDURE _cmheadtrigger();
112234
 
 
112235
 
 
112236
 
--
112237
 
--
112238
 
 
112239
 
CREATE TRIGGER cmitembeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON cmitem FOR EACH ROW EXECUTE PROCEDURE _cmitembeforetrigger();
112240
 
 
112241
 
 
112242
 
--
112243
 
--
112244
 
 
112245
 
CREATE TRIGGER cmitemtrigger AFTER INSERT OR DELETE OR UPDATE ON cmitem FOR EACH ROW EXECUTE PROCEDURE _cmitemtrigger();
112246
 
 
112247
 
 
112248
 
--
112249
 
--
112250
 
 
112251
 
CREATE TRIGGER cntcttrigger BEFORE INSERT OR UPDATE ON cntct FOR EACH ROW EXECUTE PROCEDURE _cntcttrigger();
112252
 
 
112253
 
 
112254
 
--
112255
 
--
112256
 
 
112257
 
CREATE TRIGGER cntcttriggerafter AFTER INSERT OR DELETE OR UPDATE ON cntct FOR EACH ROW EXECUTE PROCEDURE _cntcttriggerafter();
112258
 
 
112259
 
 
112260
 
--
112261
 
--
112262
 
 
112263
 
CREATE TRIGGER cntcttriggerbeforedelete BEFORE DELETE ON cntct FOR EACH ROW EXECUTE PROCEDURE _cntcttriggerbeforedelete();
112264
 
 
112265
 
 
112266
 
--
112267
 
--
112268
 
 
112269
 
CREATE TRIGGER cntsliptrigger BEFORE INSERT OR DELETE OR UPDATE ON cntslip FOR EACH ROW EXECUTE PROCEDURE _cntsliptrigger();
112270
 
 
112271
 
 
112272
 
--
112273
 
--
112274
 
 
112275
 
CREATE TRIGGER cobillbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON cobill FOR EACH ROW EXECUTE PROCEDURE _cobillbeforetrigger();
112276
 
 
112277
 
 
112278
 
--
112279
 
--
112280
 
 
112281
 
CREATE TRIGGER cobilltrigger AFTER INSERT OR DELETE OR UPDATE ON cobill FOR EACH ROW EXECUTE PROCEDURE _cobilltrigger();
112282
 
 
112283
 
 
112284
 
--
112285
 
--
112286
 
 
112287
 
CREATE TRIGGER cobmiscbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON cobmisc FOR EACH ROW EXECUTE PROCEDURE _cobmiscbeforetrigger();
112288
 
 
112289
 
 
112290
 
--
112291
 
--
112292
 
 
112293
 
CREATE TRIGGER cobmisctrigger AFTER INSERT OR DELETE OR UPDATE ON cobmisc FOR EACH ROW EXECUTE PROCEDURE _cobmisctrigger();
112294
 
 
112295
 
 
112296
 
--
112297
 
--
112298
 
 
112299
 
CREATE TRIGGER commenttrigger AFTER INSERT OR UPDATE ON comment FOR EACH ROW EXECUTE PROCEDURE _commenttrigger();
112300
 
 
112301
 
 
112302
 
--
112303
 
--
112304
 
 
112305
 
CREATE TRIGGER companytrigger BEFORE UPDATE ON company FOR EACH ROW EXECUTE PROCEDURE _companytrigger();
112306
 
 
112307
 
 
112308
 
--
112309
 
--
112310
 
 
112311
 
CREATE TRIGGER contrctaftertrigger AFTER UPDATE ON contrct FOR EACH ROW EXECUTE PROCEDURE _contrctaftertrigger();
112312
 
 
112313
 
 
112314
 
--
112315
 
--
112316
 
 
112317
 
CREATE TRIGGER crmacctaftertrigger AFTER INSERT OR DELETE OR UPDATE ON crmacct FOR EACH ROW EXECUTE PROCEDURE _crmacctaftertrigger();
112318
 
 
112319
 
 
112320
 
--
112321
 
--
112322
 
 
112323
 
CREATE TRIGGER crmacctbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON crmacct FOR EACH ROW EXECUTE PROCEDURE _crmacctbeforetrigger();
112324
 
 
112325
 
 
112326
 
--
112327
 
--
112328
 
 
112329
 
CREATE TRIGGER currexchangecheckoverlap BEFORE INSERT OR UPDATE ON curr_rate FOR EACH ROW EXECUTE PROCEDURE currexchangecheckoverlap();
112330
 
 
112331
 
 
112332
 
--
112333
 
--
112334
 
 
112335
 
CREATE TRIGGER curronebase AFTER INSERT OR UPDATE ON curr_symbol FOR EACH ROW EXECUTE PROCEDURE curronebase();
112336
 
 
112337
 
 
112338
 
--
112339
 
--
112340
 
 
112341
 
CREATE TRIGGER custaftertrigger AFTER INSERT OR UPDATE ON custinfo FOR EACH ROW EXECUTE PROCEDURE _custaftertrigger();
112342
 
 
112343
 
 
112344
 
--
112345
 
--
112346
 
 
112347
 
CREATE TRIGGER custinfoafterdeletetrigger AFTER DELETE ON custinfo FOR EACH ROW EXECUTE PROCEDURE _custinfoafterdeletetrigger();
112348
 
 
112349
 
 
112350
 
--
112351
 
--
112352
 
 
112353
 
CREATE TRIGGER custinfobeforedeletetrigger BEFORE DELETE ON custinfo FOR EACH ROW EXECUTE PROCEDURE _custinfobeforedeletetrigger();
112354
 
 
112355
 
 
112356
 
--
112357
 
--
112358
 
 
112359
 
CREATE TRIGGER custtrigger BEFORE INSERT OR UPDATE ON custinfo FOR EACH ROW EXECUTE PROCEDURE _custtrigger();
112360
 
 
112361
 
 
112362
 
--
112363
 
--
112364
 
 
112365
 
CREATE TRIGGER custtypeafterdeletetrigger AFTER DELETE ON custtype FOR EACH ROW EXECUTE PROCEDURE _custtypeafterdeletetrigger();
112366
 
 
112367
 
 
112368
 
--
112369
 
--
112370
 
 
112371
 
CREATE TRIGGER custtypetrigger BEFORE INSERT OR UPDATE ON custtype FOR EACH ROW EXECUTE PROCEDURE _custtypetrigger();
112372
 
 
112373
 
 
112374
 
--
112375
 
--
112376
 
 
112377
 
CREATE TRIGGER docasstrigger AFTER INSERT OR UPDATE ON docass FOR EACH ROW EXECUTE PROCEDURE _docasstrigger();
112378
 
 
112379
 
 
112380
 
--
112381
 
--
112382
 
 
112383
 
CREATE TRIGGER empafterdeletetrigger AFTER DELETE ON emp FOR EACH ROW EXECUTE PROCEDURE _empafterdeletetrigger();
112384
 
 
112385
 
 
112386
 
--
112387
 
--
112388
 
 
112389
 
CREATE TRIGGER empaftertrigger AFTER INSERT OR UPDATE ON emp FOR EACH ROW EXECUTE PROCEDURE _empaftertrigger();
112390
 
 
112391
 
 
112392
 
--
112393
 
--
112394
 
 
112395
 
CREATE TRIGGER empbeforedeletetrigger BEFORE DELETE ON emp FOR EACH ROW EXECUTE PROCEDURE _empbeforedeletetrigger();
112396
 
 
112397
 
 
112398
 
--
112399
 
--
112400
 
 
112401
 
CREATE TRIGGER empbeforetrigger BEFORE INSERT OR UPDATE ON emp FOR EACH ROW EXECUTE PROCEDURE _empbeforetrigger();
112402
 
 
112403
 
 
112404
 
--
112405
 
--
112406
 
 
112407
 
CREATE TRIGGER evntlogafterinserttrigger AFTER INSERT ON evntlog FOR EACH ROW EXECUTE PROCEDURE _evntlogafterinserttrigger();
112408
 
 
112409
 
 
112410
 
--
112411
 
--
112412
 
 
112413
 
CREATE TRIGGER gltransaltertrigger BEFORE DELETE OR UPDATE ON gltrans FOR EACH ROW EXECUTE PROCEDURE _gltransaltertrigger();
112414
 
 
112415
 
 
112416
 
--
112417
 
--
112418
 
 
112419
 
CREATE TRIGGER gltransinserttrigger BEFORE INSERT ON gltrans FOR EACH ROW EXECUTE PROCEDURE _gltransinserttrigger();
112420
 
 
112421
 
 
112422
 
--
112423
 
--
112424
 
 
112425
 
CREATE TRIGGER grpprivtrigger BEFORE INSERT OR UPDATE ON grppriv FOR EACH ROW EXECUTE PROCEDURE _grpprivtrigger();
112426
 
 
112427
 
 
112428
 
--
112429
 
--
112430
 
 
112431
 
CREATE TRIGGER imageasstrigger AFTER INSERT OR UPDATE ON imageass FOR EACH ROW EXECUTE PROCEDURE _imageasstrigger();
112432
 
 
112433
 
 
112434
 
--
112435
 
--
112436
 
 
112437
 
CREATE TRIGGER incdtbeforedeletetrigger BEFORE DELETE ON incdt FOR EACH ROW EXECUTE PROCEDURE _incdtbeforedeletetrigger();
112438
 
 
112439
 
 
112440
 
--
112441
 
--
112442
 
 
112443
 
CREATE TRIGGER incdtbeforetrigger BEFORE INSERT OR UPDATE ON incdt FOR EACH ROW EXECUTE PROCEDURE _incdtbeforetrigger();
112444
 
 
112445
 
 
112446
 
--
112447
 
--
112448
 
 
112449
 
CREATE TRIGGER incdttrigger AFTER INSERT OR DELETE OR UPDATE ON incdt FOR EACH ROW EXECUTE PROCEDURE _incdttrigger();
112450
 
 
112451
 
 
112452
 
--
112453
 
--
112454
 
 
112455
 
CREATE TRIGGER invcheadaftertrigger AFTER UPDATE ON invchead FOR EACH ROW EXECUTE PROCEDURE _invcheadaftertrigger();
112456
 
 
112457
 
 
112458
 
--
112459
 
--
112460
 
 
112461
 
CREATE TRIGGER invcheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON invchead FOR EACH ROW EXECUTE PROCEDURE _invcheadbeforetrigger();
112462
 
 
112463
 
 
112464
 
--
112465
 
--
112466
 
 
112467
 
CREATE TRIGGER invcheadtrigger AFTER INSERT OR DELETE OR UPDATE ON invchead FOR EACH ROW EXECUTE PROCEDURE _invcheadtrigger();
112468
 
 
112469
 
 
112470
 
--
112471
 
--
112472
 
 
112473
 
CREATE TRIGGER invcitembeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON invcitem FOR EACH ROW EXECUTE PROCEDURE _invcitembeforetrigger();
112474
 
 
112475
 
 
112476
 
--
112477
 
--
112478
 
 
112479
 
CREATE TRIGGER invcitemtrigger AFTER INSERT OR DELETE OR UPDATE ON invcitem FOR EACH ROW EXECUTE PROCEDURE _invcitemtrigger();
112480
 
 
112481
 
 
112482
 
--
112483
 
--
112484
 
 
112485
 
CREATE TRIGGER invhisttrigger BEFORE INSERT OR UPDATE ON invhist FOR EACH ROW EXECUTE PROCEDURE invhisttrig();
112486
 
 
112487
 
 
112488
 
--
112489
 
--
112490
 
 
112491
 
CREATE TRIGGER ipsassbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON ipsass FOR EACH ROW EXECUTE PROCEDURE _ipsassbeforetrigger();
112492
 
 
112493
 
 
112494
 
--
112495
 
--
112496
 
 
112497
 
CREATE TRIGGER ipsheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON ipshead FOR EACH ROW EXECUTE PROCEDURE _ipsheadbeforetrigger();
112498
 
 
112499
 
 
112500
 
--
112501
 
--
112502
 
 
112503
 
CREATE TRIGGER ipsitemcharbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON ipsitemchar FOR EACH ROW EXECUTE PROCEDURE _ipsitemcharbeforetrigger();
112504
 
 
112505
 
 
112506
 
--
112507
 
--
112508
 
 
112509
 
CREATE TRIGGER ipsiteminfobeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON ipsiteminfo FOR EACH ROW EXECUTE PROCEDURE _ipsiteminfobeforetrigger();
112510
 
 
112511
 
 
112512
 
--
112513
 
--
112514
 
 
112515
 
CREATE TRIGGER itemaftertrigger AFTER INSERT OR DELETE OR UPDATE ON item FOR EACH ROW EXECUTE PROCEDURE _itemaftertrigger();
112516
 
 
112517
 
 
112518
 
--
112519
 
--
112520
 
 
112521
 
CREATE TRIGGER itemcostaftertrigger AFTER INSERT OR UPDATE ON itemcost FOR EACH ROW EXECUTE PROCEDURE _itemcostaftertrigger();
112522
 
 
112523
 
 
112524
 
--
112525
 
--
112526
 
 
112527
 
CREATE TRIGGER itemcosttrigger BEFORE INSERT OR DELETE OR UPDATE ON itemcost FOR EACH ROW EXECUTE PROCEDURE _itemcosttrigger();
112528
 
 
112529
 
 
112530
 
--
112531
 
--
112532
 
 
112533
 
CREATE TRIGGER itemsiteaftertrigger AFTER INSERT OR UPDATE ON itemsite FOR EACH ROW EXECUTE PROCEDURE _itemsiteaftertrigger();
112534
 
 
112535
 
 
112536
 
--
112537
 
--
112538
 
 
112539
 
CREATE TRIGGER itemsitetrigger BEFORE INSERT OR UPDATE ON itemsite FOR EACH ROW EXECUTE PROCEDURE _itemsitetrigger();
112540
 
 
112541
 
 
112542
 
--
112543
 
--
112544
 
 
112545
 
CREATE TRIGGER itemsrcaftertrigger AFTER INSERT OR UPDATE ON itemsrc FOR EACH ROW EXECUTE PROCEDURE _itemsrcaftertrigger();
112546
 
 
112547
 
 
112548
 
--
112549
 
--
112550
 
 
112551
 
CREATE TRIGGER itemsrcptrigger BEFORE INSERT OR UPDATE ON itemsrcp FOR EACH ROW EXECUTE PROCEDURE _itemsrcptrigger();
112552
 
 
112553
 
 
112554
 
--
112555
 
--
112556
 
 
112557
 
CREATE TRIGGER itemsrctrigger BEFORE INSERT OR UPDATE ON itemsrc FOR EACH ROW EXECUTE PROCEDURE _itemsrctrigger();
112558
 
 
112559
 
 
112560
 
--
112561
 
--
112562
 
 
112563
 
CREATE TRIGGER itemsubtrigger AFTER INSERT OR UPDATE ON itemsub FOR EACH ROW EXECUTE PROCEDURE _itemsubtrigger();
112564
 
 
112565
 
 
112566
 
--
112567
 
--
112568
 
 
112569
 
CREATE TRIGGER itemtaxtrigger AFTER INSERT OR UPDATE ON itemtax FOR EACH ROW EXECUTE PROCEDURE _itemtaxtrigger();
112570
 
 
112571
 
 
112572
 
--
112573
 
--
112574
 
 
112575
 
CREATE TRIGGER itemtrigger BEFORE INSERT OR UPDATE ON item FOR EACH ROW EXECUTE PROCEDURE _itemtrigger();
112576
 
 
112577
 
 
112578
 
--
112579
 
--
112580
 
 
112581
 
CREATE TRIGGER itemuomconvtrigger AFTER INSERT OR UPDATE ON itemuomconv FOR EACH ROW EXECUTE PROCEDURE _itemuomconvtrigger();
112582
 
 
112583
 
 
112584
 
--
112585
 
--
112586
 
 
112587
 
CREATE TRIGGER locationaftertrigger AFTER INSERT OR UPDATE ON location FOR EACH ROW EXECUTE PROCEDURE _locationaftertrigger();
112588
 
 
112589
 
 
112590
 
--
112591
 
--
112592
 
 
112593
 
CREATE TRIGGER locationtrigger BEFORE INSERT OR UPDATE ON location FOR EACH ROW EXECUTE PROCEDURE _locationtrigger();
112594
 
 
112595
 
 
112596
 
--
112597
 
--
112598
 
 
112599
 
CREATE TRIGGER metasqlaltertrigger BEFORE INSERT OR UPDATE ON metasql FOR EACH ROW EXECUTE PROCEDURE _metasqlaltertrigger();
112600
 
 
112601
 
 
112602
 
--
112603
 
--
112604
 
 
112605
 
CREATE TRIGGER metasqltrigger BEFORE INSERT OR UPDATE ON metasql FOR EACH ROW EXECUTE PROCEDURE _metasqltrigger();
112606
 
 
112607
 
 
112608
 
--
112609
 
--
112610
 
 
112611
 
CREATE TRIGGER opheadaftertrigger AFTER INSERT OR DELETE OR UPDATE ON ophead FOR EACH ROW EXECUTE PROCEDURE _opheadaftertrigger();
112612
 
 
112613
 
 
112614
 
--
112615
 
--
112616
 
 
112617
 
CREATE TRIGGER opheadbeforetrigger BEFORE INSERT OR UPDATE ON ophead FOR EACH ROW EXECUTE PROCEDURE _opheadbeforetrigger();
112618
 
 
112619
 
 
112620
 
--
112621
 
--
112622
 
 
112623
 
CREATE TRIGGER packbeforetrigger BEFORE INSERT OR UPDATE ON pack FOR EACH ROW EXECUTE PROCEDURE _packbeforetrigger();
112624
 
 
112625
 
 
112626
 
--
112627
 
--
112628
 
 
112629
 
CREATE TRIGGER periodaftertrigger AFTER INSERT OR DELETE OR UPDATE ON period FOR EACH STATEMENT EXECUTE PROCEDURE _periodaftertrigger();
112630
 
 
112631
 
 
112632
 
--
112633
 
--
112634
 
 
112635
 
CREATE TRIGGER pkgheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkghead FOR EACH ROW EXECUTE PROCEDURE _pkgheadbeforetrigger();
112636
 
 
112637
 
 
112638
 
--
112639
 
--
112640
 
 
112641
 
CREATE TRIGGER pkgitembeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgitem FOR EACH ROW EXECUTE PROCEDURE _pkgitembeforetrigger();
112642
 
 
112643
 
 
112644
 
--
112645
 
--
112646
 
 
112647
 
CREATE TRIGGER poheadtrigger BEFORE INSERT OR DELETE OR UPDATE ON pohead FOR EACH ROW EXECUTE PROCEDURE _poheadtrigger();
112648
 
 
112649
 
 
112650
 
--
112651
 
--
112652
 
 
112653
 
CREATE TRIGGER poheadtriggerafter AFTER UPDATE ON pohead FOR EACH ROW EXECUTE PROCEDURE _poheadtriggerafter();
112654
 
 
112655
 
 
112656
 
--
112657
 
--
112658
 
 
112659
 
CREATE TRIGGER poitemafterdeletetrigger AFTER DELETE ON poitem FOR EACH ROW EXECUTE PROCEDURE _poitemafterdeletetrigger();
112660
 
 
112661
 
 
112662
 
--
112663
 
--
112664
 
 
112665
 
CREATE TRIGGER poitemaftertrigger AFTER INSERT OR UPDATE ON poitem FOR EACH ROW EXECUTE PROCEDURE _poitemaftertrigger();
112666
 
 
112667
 
 
112668
 
--
112669
 
--
112670
 
 
112671
 
CREATE TRIGGER poitemdeletetrigger BEFORE DELETE ON poitem FOR EACH ROW EXECUTE PROCEDURE _poitemdeletetrigger();
112672
 
 
112673
 
 
112674
 
--
112675
 
--
112676
 
 
112677
 
CREATE TRIGGER poitemtrigger BEFORE INSERT OR UPDATE ON poitem FOR EACH ROW EXECUTE PROCEDURE _poitemtrigger();
112678
 
 
112679
 
 
112680
 
--
112681
 
--
112682
 
 
112683
 
CREATE TRIGGER prjaftertrigger AFTER INSERT OR UPDATE ON prj FOR EACH ROW EXECUTE PROCEDURE _prjaftertrigger();
112684
 
 
112685
 
 
112686
 
--
112687
 
--
112688
 
 
112689
 
CREATE TRIGGER prjbeforedeletetrigger BEFORE DELETE ON prj FOR EACH ROW EXECUTE PROCEDURE _prjbeforedeletetrigger();
112690
 
 
112691
 
 
112692
 
--
112693
 
--
112694
 
 
112695
 
CREATE TRIGGER prjtaskaftertrigger AFTER INSERT OR UPDATE ON prjtask FOR EACH ROW EXECUTE PROCEDURE _prjtaskaftertrigger();
112696
 
 
112697
 
 
112698
 
--
112699
 
--
112700
 
 
112701
 
CREATE TRIGGER prjtasktrigger BEFORE INSERT OR UPDATE ON prjtask FOR EACH ROW EXECUTE PROCEDURE _prjtasktrigger();
112702
 
 
112703
 
 
112704
 
--
112705
 
--
112706
 
 
112707
 
CREATE TRIGGER prospectafterdeletetrigger AFTER DELETE ON prospect FOR EACH ROW EXECUTE PROCEDURE _prospectafterdeletetrigger();
112708
 
 
112709
 
 
112710
 
--
112711
 
--
112712
 
 
112713
 
CREATE TRIGGER prospectaftertrigger AFTER INSERT OR UPDATE ON prospect FOR EACH ROW EXECUTE PROCEDURE _prospectaftertrigger();
112714
 
 
112715
 
 
112716
 
--
112717
 
--
112718
 
 
112719
 
CREATE TRIGGER prospectbeforedeletetrigger BEFORE DELETE ON prospect FOR EACH ROW EXECUTE PROCEDURE _prospectbeforedeletetrigger();
112720
 
 
112721
 
 
112722
 
--
112723
 
--
112724
 
 
112725
 
CREATE TRIGGER prospecttrigger BEFORE INSERT OR UPDATE ON prospect FOR EACH ROW EXECUTE PROCEDURE _prospecttrigger();
112726
 
 
112727
 
 
112728
 
--
112729
 
--
112730
 
 
112731
 
CREATE TRIGGER prtrigger AFTER INSERT ON pr FOR EACH ROW EXECUTE PROCEDURE _prtrigger();
112732
 
 
112733
 
 
112734
 
--
112735
 
--
112736
 
 
112737
 
CREATE TRIGGER quheadtrigger BEFORE INSERT OR DELETE OR UPDATE ON quhead FOR EACH ROW EXECUTE PROCEDURE _quheadtrigger();
112738
 
 
112739
 
 
112740
 
--
112741
 
--
112742
 
 
112743
 
CREATE TRIGGER quitemaftertrigger AFTER INSERT OR UPDATE ON quitem FOR EACH ROW EXECUTE PROCEDURE _quitemaftertrigger();
112744
 
 
112745
 
 
112746
 
--
112747
 
--
112748
 
 
112749
 
CREATE TRIGGER quitembeforetrigger BEFORE INSERT OR UPDATE ON quitem FOR EACH ROW EXECUTE PROCEDURE _quitembeforetrigger();
112750
 
 
112751
 
 
112752
 
--
112753
 
--
112754
 
 
112755
 
CREATE TRIGGER quitemtrigger BEFORE INSERT OR DELETE OR UPDATE ON quitem FOR EACH ROW EXECUTE PROCEDURE _quitemtrigger();
112756
 
 
112757
 
 
112758
 
--
112759
 
--
112760
 
 
112761
 
CREATE TRIGGER recuraftertrigger AFTER DELETE ON recur FOR EACH ROW EXECUTE PROCEDURE _recuraftertrigger();
112762
 
 
112763
 
 
112764
 
--
112765
 
--
112766
 
 
112767
 
CREATE TRIGGER reporttrigger BEFORE INSERT OR UPDATE ON report FOR EACH ROW EXECUTE PROCEDURE _reporttrigger();
112768
 
 
112769
 
 
112770
 
--
112771
 
--
112772
 
 
112773
 
CREATE TRIGGER salesrepafterdeletetrigger AFTER DELETE ON salesrep FOR EACH ROW EXECUTE PROCEDURE _salesrepafterdeletetrigger();
112774
 
 
112775
 
 
112776
 
--
112777
 
--
112778
 
 
112779
 
CREATE TRIGGER salesrepaftertrigger AFTER INSERT OR UPDATE ON salesrep FOR EACH ROW EXECUTE PROCEDURE _salesrepaftertrigger();
112780
 
 
112781
 
 
112782
 
--
112783
 
--
112784
 
 
112785
 
CREATE TRIGGER salesrepbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON salesrep FOR EACH ROW EXECUTE PROCEDURE _salesrepbeforetrigger();
112786
 
 
112787
 
 
112788
 
--
112789
 
--
112790
 
 
112791
 
CREATE TRIGGER saletypebeforedeletetrigger BEFORE DELETE ON saletype FOR EACH ROW EXECUTE PROCEDURE _saletypebeforedeletetrigger();
112792
 
 
112793
 
 
112794
 
--
112795
 
--
112796
 
 
112797
 
CREATE TRIGGER shipdatasumtrigger BEFORE INSERT OR UPDATE ON shipdatasum FOR EACH ROW EXECUTE PROCEDURE _shipdatasumtrigger();
112798
 
 
112799
 
 
112800
 
--
112801
 
--
112802
 
 
112803
 
CREATE TRIGGER shipdatatrigger BEFORE INSERT OR UPDATE ON shipdata FOR EACH ROW EXECUTE PROCEDURE _shipdatatrigger();
112804
 
 
112805
 
 
112806
 
--
112807
 
--
112808
 
 
112809
 
CREATE TRIGGER shipformafterdeletetrigger AFTER DELETE ON shipform FOR EACH ROW EXECUTE PROCEDURE _shipformafterdeletetrigger();
112810
 
 
112811
 
 
112812
 
--
112813
 
--
112814
 
 
112815
 
CREATE TRIGGER shipheadbeforetrigger BEFORE INSERT OR UPDATE ON shiphead FOR EACH ROW EXECUTE PROCEDURE _shipheadbeforetrigger();
112816
 
 
112817
 
 
112818
 
--
112819
 
--
112820
 
 
112821
 
CREATE TRIGGER shiptoinfoaftertrigger AFTER INSERT OR UPDATE ON shiptoinfo FOR EACH ROW EXECUTE PROCEDURE _shiptoinfoaftertrigger();
112822
 
 
112823
 
 
112824
 
--
112825
 
--
112826
 
 
112827
 
CREATE TRIGGER shipviaafterdeletetrigger AFTER DELETE ON shipvia FOR EACH ROW EXECUTE PROCEDURE _shipviaafterdeletetrigger();
112828
 
 
112829
 
 
112830
 
--
112831
 
--
112832
 
 
112833
 
CREATE TRIGGER sltransaltertrigger BEFORE DELETE OR UPDATE ON sltrans FOR EACH ROW EXECUTE PROCEDURE _sltransaltertrigger();
112834
 
 
112835
 
 
112836
 
--
112837
 
--
112838
 
 
112839
 
CREATE TRIGGER sltransinserttrigger BEFORE INSERT ON sltrans FOR EACH ROW EXECUTE PROCEDURE _sltransinserttrigger();
112840
 
 
112841
 
 
112842
 
--
112843
 
--
112844
 
 
112845
 
CREATE TRIGGER soheadtrigger BEFORE INSERT OR DELETE OR UPDATE ON cohead FOR EACH ROW EXECUTE PROCEDURE _soheadtrigger();
112846
 
 
112847
 
 
112848
 
--
112849
 
--
112850
 
 
112851
 
CREATE TRIGGER soheadtriggerafter AFTER UPDATE ON cohead FOR EACH ROW EXECUTE PROCEDURE _soheadtriggerafter();
112852
 
 
112853
 
 
112854
 
--
112855
 
--
112856
 
 
112857
 
CREATE TRIGGER soitemafterdeletetrigger AFTER DELETE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitemafterdeletetrigger();
112858
 
 
112859
 
 
112860
 
--
112861
 
--
112862
 
 
112863
 
CREATE TRIGGER soitemaftertrigger AFTER INSERT OR UPDATE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitemaftertrigger();
112864
 
 
112865
 
 
112866
 
--
112867
 
--
112868
 
 
112869
 
CREATE TRIGGER soitembeforedeletetrigger BEFORE DELETE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitembeforedeletetrigger();
112870
 
 
112871
 
 
112872
 
--
112873
 
--
112874
 
 
112875
 
CREATE TRIGGER soitembeforetrigger BEFORE INSERT OR UPDATE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitembeforetrigger();
112876
 
 
112877
 
 
112878
 
--
112879
 
--
112880
 
 
112881
 
CREATE TRIGGER soitemtrigger BEFORE INSERT OR UPDATE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitemtrigger();
112882
 
 
112883
 
 
112884
 
--
112885
 
--
112886
 
 
112887
 
CREATE TRIGGER taxauthafterdeletetrigger AFTER DELETE ON taxauth FOR EACH ROW EXECUTE PROCEDURE _taxauthafterdeletetrigger();
112888
 
 
112889
 
 
112890
 
--
112891
 
--
112892
 
 
112893
 
CREATE TRIGGER taxauthaftertrigger AFTER INSERT OR UPDATE ON taxauth FOR EACH ROW EXECUTE PROCEDURE _taxauthaftertrigger();
112894
 
 
112895
 
 
112896
 
--
112897
 
--
112898
 
 
112899
 
CREATE TRIGGER taxauthbeforedeletetrigger BEFORE DELETE ON taxauth FOR EACH ROW EXECUTE PROCEDURE _taxauthbeforedeletetrigger();
112900
 
 
112901
 
 
112902
 
--
112903
 
--
112904
 
 
112905
 
CREATE TRIGGER taxauthbeforetrigger BEFORE INSERT OR UPDATE ON taxauth FOR EACH ROW EXECUTE PROCEDURE _taxauthbeforetrigger();
112906
 
 
112907
 
 
112908
 
--
112909
 
--
112910
 
 
112911
 
CREATE TRIGGER termsafterdeletetrigger AFTER DELETE ON terms FOR EACH ROW EXECUTE PROCEDURE _termsafterdeletetrigger();
112912
 
 
112913
 
 
112914
 
--
112915
 
--
112916
 
 
112917
 
CREATE TRIGGER todoitemtrigger BEFORE DELETE ON todoitem FOR EACH ROW EXECUTE PROCEDURE _todoitemtrigger();
112918
 
 
112919
 
 
112920
 
--
112921
 
--
112922
 
 
112923
 
CREATE TRIGGER uomconvupdate BEFORE UPDATE ON uomconv FOR EACH ROW EXECUTE PROCEDURE _uomconvupdate();
112924
 
 
112925
 
 
112926
 
--
112927
 
--
112928
 
 
112929
 
CREATE TRIGGER usrprefaftertrigger AFTER INSERT OR DELETE OR UPDATE ON usrpref FOR EACH ROW EXECUTE PROCEDURE _usrprefaftertrigger();
112930
 
 
112931
 
 
112932
 
--
112933
 
--
112934
 
 
112935
 
CREATE TRIGGER usrprefbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON usrpref FOR EACH ROW EXECUTE PROCEDURE _usrprefbeforetrigger();
112936
 
 
112937
 
 
112938
 
--
112939
 
--
112940
 
 
112941
 
CREATE TRIGGER usrprivtrigger BEFORE INSERT OR UPDATE ON usrpriv FOR EACH ROW EXECUTE PROCEDURE _usrprivtrigger();
112942
 
 
112943
 
 
112944
 
--
112945
 
--
112946
 
 
112947
 
CREATE TRIGGER vendaddrtrigger BEFORE INSERT OR DELETE OR UPDATE ON vendaddrinfo FOR EACH ROW EXECUTE PROCEDURE _vendaddrtrigger();
112948
 
 
112949
 
 
112950
 
--
112951
 
--
112952
 
 
112953
 
CREATE TRIGGER vendaftertrigger AFTER INSERT OR UPDATE ON vendinfo FOR EACH ROW EXECUTE PROCEDURE _vendaftertrigger();
112954
 
 
112955
 
 
112956
 
--
112957
 
--
112958
 
 
112959
 
CREATE TRIGGER vendinfoafterdeletetrigger AFTER DELETE ON vendinfo FOR EACH ROW EXECUTE PROCEDURE _vendinfoafterdeletetrigger();
112960
 
 
112961
 
 
112962
 
--
112963
 
--
112964
 
 
112965
 
CREATE TRIGGER vendinfobeforedeletetrigger BEFORE DELETE ON vendinfo FOR EACH ROW EXECUTE PROCEDURE _vendinfobeforedeletetrigger();
112966
 
 
112967
 
 
112968
 
--
112969
 
--
112970
 
 
112971
 
CREATE TRIGGER vendtrigger BEFORE INSERT OR UPDATE ON vendinfo FOR EACH ROW EXECUTE PROCEDURE _vendtrigger();
112972
 
 
112973
 
 
112974
 
--
112975
 
--
112976
 
 
112977
 
CREATE TRIGGER vodistaftertrigger AFTER INSERT OR DELETE OR UPDATE ON vodist FOR EACH ROW EXECUTE PROCEDURE _vodistaftertrigger();
112978
 
 
112979
 
 
112980
 
--
112981
 
--
112982
 
 
112983
 
CREATE TRIGGER vodistbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON vodist FOR EACH ROW EXECUTE PROCEDURE _vodistbeforetrigger();
112984
 
 
112985
 
 
112986
 
--
112987
 
--
112988
 
 
112989
 
CREATE TRIGGER voheadaftertrigger AFTER INSERT OR DELETE OR UPDATE ON vohead FOR EACH ROW EXECUTE PROCEDURE _voheadaftertrigger();
112990
 
 
112991
 
 
112992
 
--
112993
 
--
112994
 
 
112995
 
CREATE TRIGGER voheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON vohead FOR EACH ROW EXECUTE PROCEDURE _voheadbeforetrigger();
112996
 
 
112997
 
 
112998
 
--
112999
 
--
113000
 
 
113001
 
CREATE TRIGGER voitemaftertrigger AFTER INSERT OR DELETE OR UPDATE ON voitem FOR EACH ROW EXECUTE PROCEDURE _voitemaftertrigger();
113002
 
 
113003
 
 
113004
 
--
113005
 
--
113006
 
 
113007
 
CREATE TRIGGER voitembeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON voitem FOR EACH ROW EXECUTE PROCEDURE _voitembeforetrigger();
113008
 
 
113009
 
 
113010
 
--
113011
 
--
113012
 
 
113013
 
CREATE TRIGGER warehoustrigger BEFORE INSERT OR UPDATE ON whsinfo FOR EACH ROW EXECUTE PROCEDURE _warehoustrigger();
113014
 
 
113015
 
 
113016
 
--
113017
 
--
113018
 
 
113019
 
CREATE TRIGGER whsezonetrigger BEFORE INSERT OR UPDATE ON whsezone FOR EACH ROW EXECUTE PROCEDURE _whsezonetrigger();
113020
 
 
113021
 
 
113022
 
--
113023
 
--
113024
 
 
113025
 
CREATE TRIGGER womatlaftertrigger AFTER INSERT OR DELETE OR UPDATE ON womatl FOR EACH ROW EXECUTE PROCEDURE _womatlaftertrigger();
113026
 
 
113027
 
 
113028
 
--
113029
 
--
113030
 
 
113031
 
CREATE TRIGGER wotrigger BEFORE INSERT OR DELETE OR UPDATE ON wo FOR EACH ROW EXECUTE PROCEDURE _wotrigger();
113032
 
 
113033
 
 
113034
 
SET search_path = te, pg_catalog;
113035
 
 
113036
 
--
113037
 
--
113038
 
 
113039
 
CREATE TRIGGER pkgcmdaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaftertrigger();
113040
 
 
113041
 
 
113042
 
--
113043
 
--
113044
 
 
113045
 
CREATE TRIGGER pkgcmdaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaltertrigger();
113046
 
 
113047
 
 
113048
 
--
113049
 
--
113050
 
 
113051
 
CREATE TRIGGER pkgcmdargaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaftertrigger();
113052
 
 
113053
 
 
113054
 
--
113055
 
--
113056
 
 
113057
 
CREATE TRIGGER pkgcmdargaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaltertrigger();
113058
 
 
113059
 
 
113060
 
--
113061
 
--
113062
 
 
113063
 
CREATE TRIGGER pkgcmdargbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargbeforetrigger();
113064
 
 
113065
 
 
113066
 
--
113067
 
--
113068
 
 
113069
 
CREATE TRIGGER pkgcmdbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdbeforetrigger();
113070
 
 
113071
 
 
113072
 
--
113073
 
--
113074
 
 
113075
 
CREATE TRIGGER pkgimageaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimageaftertrigger();
113076
 
 
113077
 
 
113078
 
--
113079
 
--
113080
 
 
113081
 
CREATE TRIGGER pkgimagealtertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagealtertrigger();
113082
 
 
113083
 
 
113084
 
--
113085
 
--
113086
 
 
113087
 
CREATE TRIGGER pkgimagebeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagebeforetrigger();
113088
 
 
113089
 
 
113090
 
--
113091
 
--
113092
 
 
113093
 
CREATE TRIGGER pkgmetasqlaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaftertrigger();
113094
 
 
113095
 
 
113096
 
--
113097
 
--
113098
 
 
113099
 
CREATE TRIGGER pkgmetasqlaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaltertrigger();
113100
 
 
113101
 
 
113102
 
--
113103
 
--
113104
 
 
113105
 
CREATE TRIGGER pkgmetasqlbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlbeforetrigger();
113106
 
 
113107
 
 
113108
 
--
113109
 
--
113110
 
 
113111
 
CREATE TRIGGER pkgprivaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaftertrigger();
113112
 
 
113113
 
 
113114
 
--
113115
 
--
113116
 
 
113117
 
CREATE TRIGGER pkgprivaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaltertrigger();
113118
 
 
113119
 
 
113120
 
--
113121
 
--
113122
 
 
113123
 
CREATE TRIGGER pkgprivbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivbeforetrigger();
113124
 
 
113125
 
 
113126
 
--
113127
 
--
113128
 
 
113129
 
CREATE TRIGGER pkgreportaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaftertrigger();
113130
 
 
113131
 
 
113132
 
--
113133
 
--
113134
 
 
113135
 
CREATE TRIGGER pkgreportaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaltertrigger();
113136
 
 
113137
 
 
113138
 
--
113139
 
--
113140
 
 
113141
 
CREATE TRIGGER pkgreportbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportbeforetrigger();
113142
 
 
113143
 
 
113144
 
--
113145
 
--
113146
 
 
113147
 
CREATE TRIGGER pkgscriptaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaftertrigger();
113148
 
 
113149
 
 
113150
 
--
113151
 
--
113152
 
 
113153
 
CREATE TRIGGER pkgscriptaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaltertrigger();
113154
 
 
113155
 
 
113156
 
--
113157
 
--
113158
 
 
113159
 
CREATE TRIGGER pkgscriptbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptbeforetrigger();
113160
 
 
113161
 
 
113162
 
--
113163
 
--
113164
 
 
113165
 
CREATE TRIGGER pkguiformaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaftertrigger();
113166
 
 
113167
 
 
113168
 
--
113169
 
--
113170
 
 
113171
 
CREATE TRIGGER pkguiformaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaltertrigger();
113172
 
 
113173
 
 
113174
 
--
113175
 
--
113176
 
 
113177
 
CREATE TRIGGER pkguiformbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformbeforetrigger();
113178
 
 
113179
 
 
113180
 
--
113181
 
--
113182
 
 
113183
 
CREATE TRIGGER teheadtrigger AFTER INSERT OR UPDATE ON tehead FOR EACH ROW EXECUTE PROCEDURE triggertehead();
113184
 
 
113185
 
 
113186
 
--
113187
 
--
113188
 
 
113189
 
CREATE TRIGGER teitemtrigger AFTER INSERT OR DELETE OR UPDATE ON teitem FOR EACH ROW EXECUTE PROCEDURE triggerteitem();
113190
 
 
113191
 
 
113192
 
--
113193
 
--
113194
 
 
113195
 
CREATE TRIGGER teprjtrigger AFTER INSERT OR UPDATE ON teprj FOR EACH ROW EXECUTE PROCEDURE triggerteprj();
113196
 
 
113197
 
 
113198
 
SET search_path = xtdesktop, pg_catalog;
113199
 
 
113200
 
--
113201
 
--
113202
 
 
113203
 
CREATE TRIGGER pkgcmdaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaftertrigger();
113204
 
 
113205
 
 
113206
 
--
113207
 
--
113208
 
 
113209
 
CREATE TRIGGER pkgcmdaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaltertrigger();
113210
 
 
113211
 
 
113212
 
--
113213
 
--
113214
 
 
113215
 
CREATE TRIGGER pkgcmdargaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaftertrigger();
113216
 
 
113217
 
 
113218
 
--
113219
 
--
113220
 
 
113221
 
CREATE TRIGGER pkgcmdargaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaltertrigger();
113222
 
 
113223
 
 
113224
 
--
113225
 
--
113226
 
 
113227
 
CREATE TRIGGER pkgcmdargbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargbeforetrigger();
113228
 
 
113229
 
 
113230
 
--
113231
 
--
113232
 
 
113233
 
CREATE TRIGGER pkgcmdbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdbeforetrigger();
113234
 
 
113235
 
 
113236
 
--
113237
 
--
113238
 
 
113239
 
CREATE TRIGGER pkgimageaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimageaftertrigger();
113240
 
 
113241
 
 
113242
 
--
113243
 
--
113244
 
 
113245
 
CREATE TRIGGER pkgimagealtertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagealtertrigger();
113246
 
 
113247
 
 
113248
 
--
113249
 
--
113250
 
 
113251
 
CREATE TRIGGER pkgimagebeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagebeforetrigger();
113252
 
 
113253
 
 
113254
 
--
113255
 
--
113256
 
 
113257
 
CREATE TRIGGER pkgmetasqlaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaftertrigger();
113258
 
 
113259
 
 
113260
 
--
113261
 
--
113262
 
 
113263
 
CREATE TRIGGER pkgmetasqlaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaltertrigger();
113264
 
 
113265
 
 
113266
 
--
113267
 
--
113268
 
 
113269
 
CREATE TRIGGER pkgmetasqlbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlbeforetrigger();
113270
 
 
113271
 
 
113272
 
--
113273
 
--
113274
 
 
113275
 
CREATE TRIGGER pkgprivaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaftertrigger();
113276
 
 
113277
 
 
113278
 
--
113279
 
--
113280
 
 
113281
 
CREATE TRIGGER pkgprivaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaltertrigger();
113282
 
 
113283
 
 
113284
 
--
113285
 
--
113286
 
 
113287
 
CREATE TRIGGER pkgprivbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivbeforetrigger();
113288
 
 
113289
 
 
113290
 
--
113291
 
--
113292
 
 
113293
 
CREATE TRIGGER pkgreportaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaftertrigger();
113294
 
 
113295
 
 
113296
 
--
113297
 
--
113298
 
 
113299
 
CREATE TRIGGER pkgreportaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaltertrigger();
113300
 
 
113301
 
 
113302
 
--
113303
 
--
113304
 
 
113305
 
CREATE TRIGGER pkgreportbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportbeforetrigger();
113306
 
 
113307
 
 
113308
 
--
113309
 
--
113310
 
 
113311
 
CREATE TRIGGER pkgscriptaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaftertrigger();
113312
 
 
113313
 
 
113314
 
--
113315
 
--
113316
 
 
113317
 
CREATE TRIGGER pkgscriptaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaltertrigger();
113318
 
 
113319
 
 
113320
 
--
113321
 
--
113322
 
 
113323
 
CREATE TRIGGER pkgscriptbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptbeforetrigger();
113324
 
 
113325
 
 
113326
 
--
113327
 
--
113328
 
 
113329
 
CREATE TRIGGER pkguiformaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaftertrigger();
113330
 
 
113331
 
 
113332
 
--
113333
 
--
113334
 
 
113335
 
CREATE TRIGGER pkguiformaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaltertrigger();
113336
 
 
113337
 
 
113338
 
--
113339
 
--
113340
 
 
113341
 
CREATE TRIGGER pkguiformbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformbeforetrigger();
113342
 
 
113343
 
 
113344
 
SET search_path = fixcountry, pg_catalog;
113345
 
 
113346
 
--
113347
 
--
113348
 
 
113349
 
ALTER TABLE ONLY pkgcmdarg
113350
 
    ADD CONSTRAINT pkgcmdarg_cmdarg_cmd_id_fkey FOREIGN KEY (cmdarg_cmd_id) REFERENCES pkgcmd(cmd_id);
113351
 
 
113352
 
 
113353
 
SET search_path = public, pg_catalog;
113354
 
 
113355
 
--
113356
 
--
113357
 
 
113358
 
ALTER TABLE ONLY accnt
113359
 
    ADD CONSTRAINT accnt_accnt_company_fkey FOREIGN KEY (accnt_company) REFERENCES company(company_number) ON UPDATE CASCADE;
113360
 
 
113361
 
 
113362
 
--
113363
 
--
113364
 
 
113365
 
ALTER TABLE ONLY accnt
113366
 
    ADD CONSTRAINT accnt_to_curr_symbol FOREIGN KEY (accnt_curr_id) REFERENCES curr_symbol(curr_id);
113367
 
 
113368
 
 
113369
 
--
113370
 
--
113371
 
 
113372
 
ALTER TABLE ONLY apapply
113373
 
    ADD CONSTRAINT apapply_apapply_checkhead_id_fkey FOREIGN KEY (apapply_checkhead_id) REFERENCES checkhead(checkhead_id);
113374
 
 
113375
 
 
113376
 
--
113377
 
--
113378
 
 
113379
 
ALTER TABLE ONLY apapply
113380
 
    ADD CONSTRAINT apapply_apapply_vend_id_fkey FOREIGN KEY (apapply_vend_id) REFERENCES vendinfo(vend_id);
113381
 
 
113382
 
 
113383
 
--
113384
 
--
113385
 
 
113386
 
ALTER TABLE ONLY apapply
113387
 
    ADD CONSTRAINT apapply_to_curr_symbol FOREIGN KEY (apapply_curr_id) REFERENCES curr_symbol(curr_id);
113388
 
 
113389
 
 
113390
 
--
113391
 
--
113392
 
 
113393
 
ALTER TABLE ONLY apcreditapply
113394
 
    ADD CONSTRAINT apcreditapply_curr_symbol FOREIGN KEY (apcreditapply_curr_id) REFERENCES curr_symbol(curr_id);
113395
 
 
113396
 
 
113397
 
--
113398
 
--
113399
 
 
113400
 
ALTER TABLE ONLY apopen
113401
 
    ADD CONSTRAINT apopen_apopen_vend_id_fkey FOREIGN KEY (apopen_vend_id) REFERENCES vendinfo(vend_id);
113402
 
 
113403
 
 
113404
 
--
113405
 
--
113406
 
 
113407
 
ALTER TABLE ONLY apopen
113408
 
    ADD CONSTRAINT apopen_to_curr_symbol FOREIGN KEY (apopen_curr_id) REFERENCES curr_symbol(curr_id);
113409
 
 
113410
 
 
113411
 
--
113412
 
--
113413
 
 
113414
 
ALTER TABLE ONLY apopentax
113415
 
    ADD CONSTRAINT apopentax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id);
113416
 
 
113417
 
 
113418
 
--
113419
 
--
113420
 
 
113421
 
ALTER TABLE ONLY apopentax
113422
 
    ADD CONSTRAINT apopentax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES apopen(apopen_id) ON DELETE CASCADE;
113423
 
 
113424
 
 
113425
 
--
113426
 
--
113427
 
 
113428
 
ALTER TABLE ONLY apopentax
113429
 
    ADD CONSTRAINT apopentax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id);
113430
 
 
113431
 
 
113432
 
--
113433
 
--
113434
 
 
113435
 
ALTER TABLE ONLY apopentax
113436
 
    ADD CONSTRAINT apopentax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id);
113437
 
 
113438
 
 
113439
 
--
113440
 
--
113441
 
 
113442
 
ALTER TABLE ONLY apselect
113443
 
    ADD CONSTRAINT apselect_to_curr_symbol FOREIGN KEY (apselect_curr_id) REFERENCES curr_symbol(curr_id);
113444
 
 
113445
 
 
113446
 
--
113447
 
--
113448
 
 
113449
 
ALTER TABLE ONLY arapply
113450
 
    ADD CONSTRAINT arapply_to_curr_symbol FOREIGN KEY (arapply_curr_id) REFERENCES curr_symbol(curr_id);
113451
 
 
113452
 
 
113453
 
--
113454
 
--
113455
 
 
113456
 
ALTER TABLE ONLY arcreditapply
113457
 
    ADD CONSTRAINT arcreditapply_curr_symbol FOREIGN KEY (arcreditapply_curr_id) REFERENCES curr_symbol(curr_id);
113458
 
 
113459
 
 
113460
 
--
113461
 
--
113462
 
 
113463
 
ALTER TABLE ONLY aropen
113464
 
    ADD CONSTRAINT aropen_aropen_cust_id_fkey FOREIGN KEY (aropen_cust_id) REFERENCES custinfo(cust_id);
113465
 
 
113466
 
 
113467
 
--
113468
 
--
113469
 
 
113470
 
ALTER TABLE ONLY aropen
113471
 
    ADD CONSTRAINT aropen_aropen_salesrep_id_fkey FOREIGN KEY (aropen_salesrep_id) REFERENCES salesrep(salesrep_id);
113472
 
 
113473
 
 
113474
 
--
113475
 
--
113476
 
 
113477
 
ALTER TABLE ONLY aropen
113478
 
    ADD CONSTRAINT aropen_to_curr_symbol FOREIGN KEY (aropen_curr_id) REFERENCES curr_symbol(curr_id);
113479
 
 
113480
 
 
113481
 
--
113482
 
--
113483
 
 
113484
 
ALTER TABLE ONLY aropentax
113485
 
    ADD CONSTRAINT aropentax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id);
113486
 
 
113487
 
 
113488
 
--
113489
 
--
113490
 
 
113491
 
ALTER TABLE ONLY aropentax
113492
 
    ADD CONSTRAINT aropentax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES aropen(aropen_id) ON DELETE CASCADE;
113493
 
 
113494
 
 
113495
 
--
113496
 
--
113497
 
 
113498
 
ALTER TABLE ONLY aropentax
113499
 
    ADD CONSTRAINT aropentax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id);
113500
 
 
113501
 
 
113502
 
--
113503
 
--
113504
 
 
113505
 
ALTER TABLE ONLY aropentax
113506
 
    ADD CONSTRAINT aropentax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id);
113507
 
 
113508
 
 
113509
 
--
113510
 
--
113511
 
 
113512
 
ALTER TABLE ONLY asohist
113513
 
    ADD CONSTRAINT asohist_asohist_taxtype_id_fkey FOREIGN KEY (asohist_taxtype_id) REFERENCES taxtype(taxtype_id);
113514
 
 
113515
 
 
113516
 
--
113517
 
--
113518
 
 
113519
 
ALTER TABLE ONLY asohist
113520
 
    ADD CONSTRAINT asohist_asohist_taxzone_id_fkey FOREIGN KEY (asohist_taxzone_id) REFERENCES taxzone(taxzone_id);
113521
 
 
113522
 
 
113523
 
--
113524
 
--
113525
 
 
113526
 
ALTER TABLE ONLY asohist
113527
 
    ADD CONSTRAINT asohist_to_curr_symbol FOREIGN KEY (asohist_curr_id) REFERENCES curr_symbol(curr_id);
113528
 
 
113529
 
 
113530
 
--
113531
 
--
113532
 
 
113533
 
ALTER TABLE ONLY asohisttax
113534
 
    ADD CONSTRAINT asohisttax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id);
113535
 
 
113536
 
 
113537
 
--
113538
 
--
113539
 
 
113540
 
ALTER TABLE ONLY asohisttax
113541
 
    ADD CONSTRAINT asohisttax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES asohist(asohist_id) ON DELETE CASCADE;
113542
 
 
113543
 
 
113544
 
--
113545
 
--
113546
 
 
113547
 
ALTER TABLE ONLY asohisttax
113548
 
    ADD CONSTRAINT asohisttax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id);
113549
 
 
113550
 
 
113551
 
--
113552
 
--
113553
 
 
113554
 
ALTER TABLE ONLY asohisttax
113555
 
    ADD CONSTRAINT asohisttax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id);
113556
 
 
113557
 
 
113558
 
--
113559
 
--
113560
 
 
113561
 
ALTER TABLE ONLY bankaccnt
113562
 
    ADD CONSTRAINT bankaccnt_to_curr_symbol FOREIGN KEY (bankaccnt_curr_id) REFERENCES curr_symbol(curr_id);
113563
 
 
113564
 
 
113565
 
--
113566
 
--
113567
 
 
113568
 
ALTER TABLE ONLY bankadj
113569
 
    ADD CONSTRAINT bankadj_to_curr_symbol FOREIGN KEY (bankadj_curr_id) REFERENCES curr_symbol(curr_id);
113570
 
 
113571
 
 
113572
 
--
113573
 
--
113574
 
 
113575
 
ALTER TABLE ONLY bomhead
113576
 
    ADD CONSTRAINT bomhead_bomhead_item_id_fkey FOREIGN KEY (bomhead_item_id) REFERENCES item(item_id) ON UPDATE RESTRICT ON DELETE CASCADE;
113577
 
 
113578
 
 
113579
 
--
113580
 
--
113581
 
 
113582
 
ALTER TABLE ONLY bomitem
113583
 
    ADD CONSTRAINT bomitem_bomitem_char_id_fkey FOREIGN KEY (bomitem_char_id) REFERENCES "char"(char_id);
113584
 
 
113585
 
 
113586
 
--
113587
 
--
113588
 
 
113589
 
ALTER TABLE ONLY bomitem
113590
 
    ADD CONSTRAINT bomitem_bomitem_item_id_fkey FOREIGN KEY (bomitem_item_id) REFERENCES item(item_id);
113591
 
 
113592
 
 
113593
 
--
113594
 
--
113595
 
 
113596
 
ALTER TABLE ONLY bomitem
113597
 
    ADD CONSTRAINT bomitem_bomitem_parent_item_id_fkey FOREIGN KEY (bomitem_parent_item_id) REFERENCES item(item_id) ON UPDATE RESTRICT ON DELETE CASCADE;
113598
 
 
113599
 
 
113600
 
--
113601
 
--
113602
 
 
113603
 
ALTER TABLE ONLY bomitem
113604
 
    ADD CONSTRAINT bomitem_bomitem_uom_id_fkey FOREIGN KEY (bomitem_uom_id) REFERENCES uom(uom_id);
113605
 
 
113606
 
 
113607
 
--
113608
 
--
113609
 
 
113610
 
ALTER TABLE ONLY bomitemcost
113611
 
    ADD CONSTRAINT bomitemcost_bomitemcost_bomitem_id_fkey FOREIGN KEY (bomitemcost_bomitem_id) REFERENCES bomitem(bomitem_id);
113612
 
 
113613
 
 
113614
 
--
113615
 
--
113616
 
 
113617
 
ALTER TABLE ONLY bomitemcost
113618
 
    ADD CONSTRAINT bomitemcost_bomitemcost_costelem_id_fkey FOREIGN KEY (bomitemcost_costelem_id) REFERENCES costelem(costelem_id);
113619
 
 
113620
 
 
113621
 
--
113622
 
--
113623
 
 
113624
 
ALTER TABLE ONLY bomitemcost
113625
 
    ADD CONSTRAINT bomitemcost_bomitemcost_curr_id_fkey FOREIGN KEY (bomitemcost_curr_id) REFERENCES curr_symbol(curr_id);
113626
 
 
113627
 
 
113628
 
--
113629
 
--
113630
 
 
113631
 
ALTER TABLE ONLY bomitemsub
113632
 
    ADD CONSTRAINT bomitemsub_bomitemsub_bomitem_id_fkey FOREIGN KEY (bomitemsub_bomitem_id) REFERENCES bomitem(bomitem_id) ON UPDATE RESTRICT ON DELETE CASCADE;
113633
 
 
113634
 
 
113635
 
--
113636
 
--
113637
 
 
113638
 
ALTER TABLE ONLY bomitemsub
113639
 
    ADD CONSTRAINT bomitemsub_bomitemsub_item_id_fkey FOREIGN KEY (bomitemsub_item_id) REFERENCES item(item_id) ON UPDATE RESTRICT ON DELETE CASCADE;
113640
 
 
113641
 
 
113642
 
--
113643
 
--
113644
 
 
113645
 
ALTER TABLE ONLY bomwork
113646
 
    ADD CONSTRAINT bomwork_bomwork_char_id_fkey FOREIGN KEY (bomwork_char_id) REFERENCES "char"(char_id);
113647
 
 
113648
 
 
113649
 
--
113650
 
--
113651
 
 
113652
 
ALTER TABLE ONLY budgitem
113653
 
    ADD CONSTRAINT budgitem_budgitem_budghead_id_fkey FOREIGN KEY (budgitem_budghead_id) REFERENCES budghead(budghead_id);
113654
 
 
113655
 
 
113656
 
--
113657
 
--
113658
 
 
113659
 
ALTER TABLE ONLY budgitem
113660
 
    ADD CONSTRAINT budgitem_budgitem_period_id_fkey FOREIGN KEY (budgitem_period_id) REFERENCES period(period_id);
113661
 
 
113662
 
 
113663
 
--
113664
 
--
113665
 
 
113666
 
ALTER TABLE ONLY cashrcpt
113667
 
    ADD CONSTRAINT cashrcpt_bankaccnt_bankaccnt_id_fkey FOREIGN KEY (cashrcpt_bankaccnt_id) REFERENCES bankaccnt(bankaccnt_id);
113668
 
 
113669
 
 
113670
 
--
113671
 
--
113672
 
 
113673
 
ALTER TABLE ONLY cashrcpt
113674
 
    ADD CONSTRAINT cashrcpt_cust_cust_id_fkey FOREIGN KEY (cashrcpt_cust_id) REFERENCES custinfo(cust_id);
113675
 
 
113676
 
 
113677
 
--
113678
 
--
113679
 
 
113680
 
ALTER TABLE ONLY cashrcpt
113681
 
    ADD CONSTRAINT cashrcpt_to_curr_symbol FOREIGN KEY (cashrcpt_curr_id) REFERENCES curr_symbol(curr_id);
113682
 
 
113683
 
 
113684
 
--
113685
 
--
113686
 
 
113687
 
ALTER TABLE ONLY cashrcptitem
113688
 
    ADD CONSTRAINT cashrcptitem_aropen_aropen_id_fkey FOREIGN KEY (cashrcptitem_aropen_id) REFERENCES aropen(aropen_id);
113689
 
 
113690
 
 
113691
 
--
113692
 
--
113693
 
 
113694
 
ALTER TABLE ONLY cashrcptitem
113695
 
    ADD CONSTRAINT cashrcptitem_cashrcpt_cashrcpt_id_fkey FOREIGN KEY (cashrcptitem_cashrcpt_id) REFERENCES cashrcpt(cashrcpt_id);
113696
 
 
113697
 
 
113698
 
--
113699
 
--
113700
 
 
113701
 
ALTER TABLE ONLY cashrcptmisc
113702
 
    ADD CONSTRAINT cashrcptmisc_accnt_accnt_id_fkey FOREIGN KEY (cashrcptmisc_accnt_id) REFERENCES accnt(accnt_id);
113703
 
 
113704
 
 
113705
 
--
113706
 
--
113707
 
 
113708
 
ALTER TABLE ONLY cashrcptmisc
113709
 
    ADD CONSTRAINT cashrcptmisc_cashrcpt_cashrcpt_id_fkey FOREIGN KEY (cashrcptmisc_cashrcpt_id) REFERENCES cashrcpt(cashrcpt_id);
113710
 
 
113711
 
 
113712
 
--
113713
 
--
113714
 
 
113715
 
ALTER TABLE ONLY ccard
113716
 
    ADD CONSTRAINT ccard_ccard_cust_id_fkey FOREIGN KEY (ccard_cust_id) REFERENCES custinfo(cust_id);
113717
 
 
113718
 
 
113719
 
--
113720
 
--
113721
 
 
113722
 
ALTER TABLE ONLY ccbank
113723
 
    ADD CONSTRAINT ccbank_ccbank_bankaccnt_id_fkey FOREIGN KEY (ccbank_bankaccnt_id) REFERENCES bankaccnt(bankaccnt_id);
113724
 
 
113725
 
 
113726
 
--
113727
 
--
113728
 
 
113729
 
ALTER TABLE ONLY charopt
113730
 
    ADD CONSTRAINT charopt_charopt_char_id_fkey FOREIGN KEY (charopt_char_id) REFERENCES "char"(char_id) ON DELETE CASCADE;
113731
 
 
113732
 
 
113733
 
--
113734
 
--
113735
 
 
113736
 
ALTER TABLE ONLY checkhead
113737
 
    ADD CONSTRAINT checkhead_checkhead_bankaccnt_id_fkey FOREIGN KEY (checkhead_bankaccnt_id) REFERENCES bankaccnt(bankaccnt_id);
113738
 
 
113739
 
 
113740
 
--
113741
 
--
113742
 
 
113743
 
ALTER TABLE ONLY checkhead
113744
 
    ADD CONSTRAINT checkhead_checkhead_curr_id_fkey FOREIGN KEY (checkhead_curr_id) REFERENCES curr_symbol(curr_id);
113745
 
 
113746
 
 
113747
 
--
113748
 
--
113749
 
 
113750
 
ALTER TABLE ONLY checkhead
113751
 
    ADD CONSTRAINT checkhead_checkhead_expcat_id_fkey FOREIGN KEY (checkhead_expcat_id) REFERENCES expcat(expcat_id);
113752
 
 
113753
 
 
113754
 
--
113755
 
--
113756
 
 
113757
 
ALTER TABLE ONLY checkitem
113758
 
    ADD CONSTRAINT checkitem_checkitem_apopen_id_fkey FOREIGN KEY (checkitem_apopen_id) REFERENCES apopen(apopen_id);
113759
 
 
113760
 
 
113761
 
--
113762
 
--
113763
 
 
113764
 
ALTER TABLE ONLY checkitem
113765
 
    ADD CONSTRAINT checkitem_checkitem_aropen_id_fkey FOREIGN KEY (checkitem_aropen_id) REFERENCES aropen(aropen_id);
113766
 
 
113767
 
 
113768
 
--
113769
 
--
113770
 
 
113771
 
ALTER TABLE ONLY checkitem
113772
 
    ADD CONSTRAINT checkitem_checkitem_checkhead_id_fkey FOREIGN KEY (checkitem_checkhead_id) REFERENCES checkhead(checkhead_id);
113773
 
 
113774
 
 
113775
 
--
113776
 
--
113777
 
 
113778
 
ALTER TABLE ONLY checkitem
113779
 
    ADD CONSTRAINT checkitem_checkitem_curr_id_fkey FOREIGN KEY (checkitem_curr_id) REFERENCES curr_symbol(curr_id);
113780
 
 
113781
 
 
113782
 
--
113783
 
--
113784
 
 
113785
 
ALTER TABLE ONLY cmdarg
113786
 
    ADD CONSTRAINT cmdarg_cmdarg_cmd_id_fkey FOREIGN KEY (cmdarg_cmd_id) REFERENCES cmd(cmd_id) ON DELETE CASCADE;
113787
 
 
113788
 
 
113789
 
--
113790
 
--
113791
 
 
113792
 
ALTER TABLE ONLY cmhead
113793
 
    ADD CONSTRAINT cmhead_cmhead_cust_id_fkey FOREIGN KEY (cmhead_cust_id) REFERENCES custinfo(cust_id);
113794
 
 
113795
 
 
113796
 
--
113797
 
--
113798
 
 
113799
 
ALTER TABLE ONLY cmhead
113800
 
    ADD CONSTRAINT cmhead_cmhead_freighttaxtype_id_fkey FOREIGN KEY (cmhead_freighttaxtype_id) REFERENCES taxtype(taxtype_id);
113801
 
 
113802
 
 
113803
 
--
113804
 
--
113805
 
 
113806
 
ALTER TABLE ONLY cmhead
113807
 
    ADD CONSTRAINT cmhead_cmhead_prj_id_fkey FOREIGN KEY (cmhead_prj_id) REFERENCES prj(prj_id);
113808
 
 
113809
 
 
113810
 
--
113811
 
--
113812
 
 
113813
 
ALTER TABLE ONLY cmhead
113814
 
    ADD CONSTRAINT cmhead_cmhead_salesrep_id_fkey FOREIGN KEY (cmhead_salesrep_id) REFERENCES salesrep(salesrep_id);
113815
 
 
113816
 
 
113817
 
--
113818
 
--
113819
 
 
113820
 
ALTER TABLE ONLY cmhead
113821
 
    ADD CONSTRAINT cmhead_cmhead_saletype_id_fkey FOREIGN KEY (cmhead_saletype_id) REFERENCES saletype(saletype_id);
113822
 
 
113823
 
 
113824
 
--
113825
 
--
113826
 
 
113827
 
ALTER TABLE ONLY cmhead
113828
 
    ADD CONSTRAINT cmhead_cmhead_shipzone_id_fkey FOREIGN KEY (cmhead_shipzone_id) REFERENCES shipzone(shipzone_id);
113829
 
 
113830
 
 
113831
 
--
113832
 
--
113833
 
 
113834
 
ALTER TABLE ONLY cmhead
113835
 
    ADD CONSTRAINT cmhead_cmhead_taxzone_id_fkey FOREIGN KEY (cmhead_taxzone_id) REFERENCES taxzone(taxzone_id);
113836
 
 
113837
 
 
113838
 
--
113839
 
--
113840
 
 
113841
 
ALTER TABLE ONLY cmhead
113842
 
    ADD CONSTRAINT cmhead_to_curr_symbol FOREIGN KEY (cmhead_curr_id) REFERENCES curr_symbol(curr_id);
113843
 
 
113844
 
 
113845
 
--
113846
 
--
113847
 
 
113848
 
ALTER TABLE ONLY cmheadtax
113849
 
    ADD CONSTRAINT cmheadtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id);
113850
 
 
113851
 
 
113852
 
--
113853
 
--
113854
 
 
113855
 
ALTER TABLE ONLY cmheadtax
113856
 
    ADD CONSTRAINT cmheadtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cmhead(cmhead_id) ON DELETE CASCADE;
113857
 
 
113858
 
 
113859
 
--
113860
 
--
113861
 
 
113862
 
ALTER TABLE ONLY cmheadtax
113863
 
    ADD CONSTRAINT cmheadtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id);
113864
 
 
113865
 
 
113866
 
--
113867
 
--
113868
 
 
113869
 
ALTER TABLE ONLY cmheadtax
113870
 
    ADD CONSTRAINT cmheadtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id);
113871
 
 
113872
 
 
113873
 
--
113874
 
--
113875
 
 
113876
 
ALTER TABLE ONLY cmitem
113877
 
    ADD CONSTRAINT cmitem_cmhead_id_fkey FOREIGN KEY (cmitem_cmhead_id) REFERENCES cmhead(cmhead_id) ON UPDATE CASCADE ON DELETE CASCADE;
113878
 
 
113879
 
 
113880
 
--
113881
 
--
113882
 
 
113883
 
ALTER TABLE ONLY cmitem
113884
 
    ADD CONSTRAINT cmitem_cmitem_price_uom_id_fkey FOREIGN KEY (cmitem_price_uom_id) REFERENCES uom(uom_id);
113885
 
 
113886
 
 
113887
 
--
113888
 
--
113889
 
 
113890
 
ALTER TABLE ONLY cmitem
113891
 
    ADD CONSTRAINT cmitem_cmitem_qty_uom_id_fkey FOREIGN KEY (cmitem_qty_uom_id) REFERENCES uom(uom_id);
113892
 
 
113893
 
 
113894
 
--
113895
 
--
113896
 
 
113897
 
ALTER TABLE ONLY cmitem
113898
 
    ADD CONSTRAINT cmitem_cmitem_taxtype_id_fkey FOREIGN KEY (cmitem_taxtype_id) REFERENCES taxtype(taxtype_id);
113899
 
 
113900
 
 
113901
 
--
113902
 
--
113903
 
 
113904
 
ALTER TABLE ONLY cmitemtax
113905
 
    ADD CONSTRAINT cmitemtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id);
113906
 
 
113907
 
 
113908
 
--
113909
 
--
113910
 
 
113911
 
ALTER TABLE ONLY cmitemtax
113912
 
    ADD CONSTRAINT cmitemtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cmitem(cmitem_id) ON DELETE CASCADE;
113913
 
 
113914
 
 
113915
 
--
113916
 
--
113917
 
 
113918
 
ALTER TABLE ONLY cmitemtax
113919
 
    ADD CONSTRAINT cmitemtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id);
113920
 
 
113921
 
 
113922
 
--
113923
 
--
113924
 
 
113925
 
ALTER TABLE ONLY cmitemtax
113926
 
    ADD CONSTRAINT cmitemtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id);
113927
 
 
113928
 
 
113929
 
--
113930
 
--
113931
 
 
113932
 
ALTER TABLE ONLY cntct
113933
 
    ADD CONSTRAINT cntct_cntct_addr_id_fkey FOREIGN KEY (cntct_addr_id) REFERENCES addr(addr_id);
113934
 
 
113935
 
 
113936
 
--
113937
 
--
113938
 
 
113939
 
ALTER TABLE ONLY cntct
113940
 
    ADD CONSTRAINT cntct_cntct_crmacct_id_fkey FOREIGN KEY (cntct_crmacct_id) REFERENCES crmacct(crmacct_id);
113941
 
 
113942
 
 
113943
 
--
113944
 
--
113945
 
 
113946
 
ALTER TABLE ONLY cntctaddr
113947
 
    ADD CONSTRAINT cntctaddr_cntctaddr_addr_id_fkey FOREIGN KEY (cntctaddr_addr_id) REFERENCES addr(addr_id);
113948
 
 
113949
 
 
113950
 
--
113951
 
--
113952
 
 
113953
 
ALTER TABLE ONLY cntctaddr
113954
 
    ADD CONSTRAINT cntctaddr_cntctaddr_cntct_id_fkey FOREIGN KEY (cntctaddr_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE;
113955
 
 
113956
 
 
113957
 
--
113958
 
--
113959
 
 
113960
 
ALTER TABLE ONLY cntctdata
113961
 
    ADD CONSTRAINT cntctdata_cntctdata_cntct_id_fkey FOREIGN KEY (cntctdata_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE;
113962
 
 
113963
 
 
113964
 
--
113965
 
--
113966
 
 
113967
 
ALTER TABLE ONLY cntcteml
113968
 
    ADD CONSTRAINT cntcteml_cntcteml_cntct_id_fkey FOREIGN KEY (cntcteml_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE;
113969
 
 
113970
 
 
113971
 
--
113972
 
--
113973
 
 
113974
 
ALTER TABLE ONLY cntctmrgd
113975
 
    ADD CONSTRAINT cntctmrgd_cntctmrgd_cntct_id_fkey FOREIGN KEY (cntctmrgd_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE;
113976
 
 
113977
 
 
113978
 
--
113979
 
--
113980
 
 
113981
 
ALTER TABLE ONLY cntctsel
113982
 
    ADD CONSTRAINT cntctsel_cntctsel_cntct_id_fkey FOREIGN KEY (cntctsel_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE;
113983
 
 
113984
 
 
113985
 
--
113986
 
--
113987
 
 
113988
 
ALTER TABLE ONLY cobill
113989
 
    ADD CONSTRAINT cobill_cobill_invcitem_id_fkey FOREIGN KEY (cobill_invcitem_id) REFERENCES invcitem(invcitem_id);
113990
 
 
113991
 
 
113992
 
--
113993
 
--
113994
 
 
113995
 
ALTER TABLE ONLY cobill
113996
 
    ADD CONSTRAINT cobill_cobill_taxtype_id_fkey FOREIGN KEY (cobill_taxtype_id) REFERENCES taxtype(taxtype_id);
113997
 
 
113998
 
 
113999
 
--
114000
 
--
114001
 
 
114002
 
ALTER TABLE ONLY cobilltax
114003
 
    ADD CONSTRAINT cobilltax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id);
114004
 
 
114005
 
 
114006
 
--
114007
 
--
114008
 
 
114009
 
ALTER TABLE ONLY cobilltax
114010
 
    ADD CONSTRAINT cobilltax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cobill(cobill_id) ON DELETE CASCADE;
114011
 
 
114012
 
 
114013
 
--
114014
 
--
114015
 
 
114016
 
ALTER TABLE ONLY cobilltax
114017
 
    ADD CONSTRAINT cobilltax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id);
114018
 
 
114019
 
 
114020
 
--
114021
 
--
114022
 
 
114023
 
ALTER TABLE ONLY cobilltax
114024
 
    ADD CONSTRAINT cobilltax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id);
114025
 
 
114026
 
 
114027
 
--
114028
 
--
114029
 
 
114030
 
ALTER TABLE ONLY cobmisc
114031
 
    ADD CONSTRAINT cobmisc_cobmisc_invchead_id_fkey FOREIGN KEY (cobmisc_invchead_id) REFERENCES invchead(invchead_id);
114032
 
 
114033
 
 
114034
 
--
114035
 
--
114036
 
 
114037
 
ALTER TABLE ONLY cobmisc
114038
 
    ADD CONSTRAINT cobmisc_cobmisc_taxtype_id_fkey FOREIGN KEY (cobmisc_taxtype_id) REFERENCES taxtype(taxtype_id);
114039
 
 
114040
 
 
114041
 
--
114042
 
--
114043
 
 
114044
 
ALTER TABLE ONLY cobmisc
114045
 
    ADD CONSTRAINT cobmisc_cobmisc_taxzone_id_fkey FOREIGN KEY (cobmisc_taxzone_id) REFERENCES taxzone(taxzone_id);
114046
 
 
114047
 
 
114048
 
--
114049
 
--
114050
 
 
114051
 
ALTER TABLE ONLY cobmisc
114052
 
    ADD CONSTRAINT cobmisc_to_curr_symbol FOREIGN KEY (cobmisc_curr_id) REFERENCES curr_symbol(curr_id);
114053
 
 
114054
 
 
114055
 
--
114056
 
--
114057
 
 
114058
 
ALTER TABLE ONLY cobmisctax
114059
 
    ADD CONSTRAINT cobmisctax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id);
114060
 
 
114061
 
 
114062
 
--
114063
 
--
114064
 
 
114065
 
ALTER TABLE ONLY cobmisctax
114066
 
    ADD CONSTRAINT cobmisctax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cobmisc(cobmisc_id) ON DELETE CASCADE;
114067
 
 
114068
 
 
114069
 
--
114070
 
--
114071
 
 
114072
 
ALTER TABLE ONLY cobmisctax
114073
 
    ADD CONSTRAINT cobmisctax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id);
114074
 
 
114075
 
 
114076
 
--
114077
 
--
114078
 
 
114079
 
ALTER TABLE ONLY cobmisctax
114080
 
    ADD CONSTRAINT cobmisctax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id);
114081
 
 
114082
 
 
114083
 
--
114084
 
--
114085
 
 
114086
 
ALTER TABLE ONLY cohead
114087
 
    ADD CONSTRAINT cohead_cohead_billto_cntct_id_fkey FOREIGN KEY (cohead_billto_cntct_id) REFERENCES cntct(cntct_id);
114088
 
 
114089
 
 
114090
 
--
114091
 
--
114092
 
 
114093
 
ALTER TABLE ONLY cohead
114094
 
    ADD CONSTRAINT cohead_cohead_cust_id_fkey FOREIGN KEY (cohead_cust_id) REFERENCES custinfo(cust_id);
114095
 
 
114096
 
 
114097
 
--
114098
 
--
114099
 
 
114100
 
ALTER TABLE ONLY cohead
114101
 
    ADD CONSTRAINT cohead_cohead_misc_accnt_id_fkey FOREIGN KEY (cohead_misc_accnt_id) REFERENCES accnt(accnt_id);
114102
 
 
114103
 
 
114104
 
--
114105
 
--
114106
 
 
114107
 
ALTER TABLE ONLY cohead
114108
 
    ADD CONSTRAINT cohead_cohead_ophead_id_fkey FOREIGN KEY (cohead_ophead_id) REFERENCES ophead(ophead_id);
114109
 
 
114110
 
 
114111
 
--
114112
 
--
114113
 
 
114114
 
ALTER TABLE ONLY cohead
114115
 
    ADD CONSTRAINT cohead_cohead_prj_id_fkey FOREIGN KEY (cohead_prj_id) REFERENCES prj(prj_id);
114116
 
 
114117
 
 
114118
 
--
114119
 
--
114120
 
 
114121
 
ALTER TABLE ONLY cohead
114122
 
    ADD CONSTRAINT cohead_cohead_salesrep_id_fkey FOREIGN KEY (cohead_salesrep_id) REFERENCES salesrep(salesrep_id);
114123
 
 
114124
 
 
114125
 
--
114126
 
--
114127
 
 
114128
 
ALTER TABLE ONLY cohead
114129
 
    ADD CONSTRAINT cohead_cohead_saletype_id_fkey FOREIGN KEY (cohead_saletype_id) REFERENCES saletype(saletype_id);
114130
 
 
114131
 
 
114132
 
--
114133
 
--
114134
 
 
114135
 
ALTER TABLE ONLY cohead
114136
 
    ADD CONSTRAINT cohead_cohead_shipform_id_fkey FOREIGN KEY (cohead_shipform_id) REFERENCES shipform(shipform_id);
114137
 
 
114138
 
 
114139
 
--
114140
 
--
114141
 
 
114142
 
ALTER TABLE ONLY cohead
114143
 
    ADD CONSTRAINT cohead_cohead_shipto_cntct_id_fkey FOREIGN KEY (cohead_shipto_cntct_id) REFERENCES cntct(cntct_id);
114144
 
 
114145
 
 
114146
 
--
114147
 
--
114148
 
 
114149
 
ALTER TABLE ONLY cohead
114150
 
    ADD CONSTRAINT cohead_cohead_shipto_id_fkey FOREIGN KEY (cohead_shipto_id) REFERENCES shiptoinfo(shipto_id);
114151
 
 
114152
 
 
114153
 
--
114154
 
--
114155
 
 
114156
 
ALTER TABLE ONLY cohead
114157
 
    ADD CONSTRAINT cohead_cohead_shipzone_id_fkey FOREIGN KEY (cohead_shipzone_id) REFERENCES shipzone(shipzone_id);
114158
 
 
114159
 
 
114160
 
--
114161
 
--
114162
 
 
114163
 
ALTER TABLE ONLY cohead
114164
 
    ADD CONSTRAINT cohead_cohead_taxtype_id_fkey FOREIGN KEY (cohead_taxtype_id) REFERENCES taxtype(taxtype_id);
114165
 
 
114166
 
 
114167
 
--
114168
 
--
114169
 
 
114170
 
ALTER TABLE ONLY cohead
114171
 
    ADD CONSTRAINT cohead_cohead_taxzone_id_fkey FOREIGN KEY (cohead_taxzone_id) REFERENCES taxzone(taxzone_id);
114172
 
 
114173
 
 
114174
 
--
114175
 
--
114176
 
 
114177
 
ALTER TABLE ONLY cohead
114178
 
    ADD CONSTRAINT cohead_cohead_terms_id_fkey FOREIGN KEY (cohead_terms_id) REFERENCES terms(terms_id);
114179
 
 
114180
 
 
114181
 
--
114182
 
--
114183
 
 
114184
 
ALTER TABLE ONLY cohead
114185
 
    ADD CONSTRAINT cohead_cohead_warehous_id_fkey FOREIGN KEY (cohead_warehous_id) REFERENCES whsinfo(warehous_id);
114186
 
 
114187
 
 
114188
 
--
114189
 
--
114190
 
 
114191
 
ALTER TABLE ONLY cohead
114192
 
    ADD CONSTRAINT cohead_to_curr_symbol FOREIGN KEY (cohead_curr_id) REFERENCES curr_symbol(curr_id);
114193
 
 
114194
 
 
114195
 
--
114196
 
--
114197
 
 
114198
 
ALTER TABLE ONLY cohist
114199
 
    ADD CONSTRAINT cohist_cohist_cohead_ccpay_id_fkey FOREIGN KEY (cohist_cohead_ccpay_id) REFERENCES ccpay(ccpay_id);
114200
 
 
114201
 
 
114202
 
--
114203
 
--
114204
 
 
114205
 
ALTER TABLE ONLY cohist
114206
 
    ADD CONSTRAINT cohist_cohist_cust_id_fkey FOREIGN KEY (cohist_cust_id) REFERENCES custinfo(cust_id);
114207
 
 
114208
 
 
114209
 
--
114210
 
--
114211
 
 
114212
 
ALTER TABLE ONLY cohist
114213
 
    ADD CONSTRAINT cohist_cohist_salesrep_id_fkey FOREIGN KEY (cohist_salesrep_id) REFERENCES salesrep(salesrep_id);
114214
 
 
114215
 
 
114216
 
--
114217
 
--
114218
 
 
114219
 
ALTER TABLE ONLY cohist
114220
 
    ADD CONSTRAINT cohist_cohist_taxtype_id_fkey FOREIGN KEY (cohist_taxtype_id) REFERENCES taxtype(taxtype_id);
114221
 
 
114222
 
 
114223
 
--
114224
 
--
114225
 
 
114226
 
ALTER TABLE ONLY cohist
114227
 
    ADD CONSTRAINT cohist_cohist_taxzone_id_fkey FOREIGN KEY (cohist_taxzone_id) REFERENCES taxzone(taxzone_id);
114228
 
 
114229
 
 
114230
 
--
114231
 
--
114232
 
 
114233
 
ALTER TABLE ONLY cohist
114234
 
    ADD CONSTRAINT cohist_to_curr_symbol FOREIGN KEY (cohist_curr_id) REFERENCES curr_symbol(curr_id);
114235
 
 
114236
 
 
114237
 
--
114238
 
--
114239
 
 
114240
 
ALTER TABLE ONLY cohisttax
114241
 
    ADD CONSTRAINT cohisttax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id);
114242
 
 
114243
 
 
114244
 
--
114245
 
--
114246
 
 
114247
 
ALTER TABLE ONLY cohisttax
114248
 
    ADD CONSTRAINT cohisttax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cohist(cohist_id) ON DELETE CASCADE;
114249
 
 
114250
 
 
114251
 
--
114252
 
--
114253
 
 
114254
 
ALTER TABLE ONLY cohisttax
114255
 
    ADD CONSTRAINT cohisttax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id);
114256
 
 
114257
 
 
114258
 
--
114259
 
--
114260
 
 
114261
 
ALTER TABLE ONLY cohisttax
114262
 
    ADD CONSTRAINT cohisttax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id);
114263
 
 
114264
 
 
114265
 
--
114266
 
--
114267
 
 
114268
 
ALTER TABLE ONLY coitem
114269
 
    ADD CONSTRAINT coitem_coitem_cohead_id_fkey FOREIGN KEY (coitem_cohead_id) REFERENCES cohead(cohead_id) ON DELETE CASCADE;
114270
 
 
114271
 
 
114272
 
--
114273
 
--
114274
 
 
114275
 
ALTER TABLE ONLY coitem
114276
 
    ADD CONSTRAINT coitem_coitem_cos_accnt_id_fkey FOREIGN KEY (coitem_cos_accnt_id) REFERENCES accnt(accnt_id);
114277
 
 
114278
 
 
114279
 
--
114280
 
--
114281
 
 
114282
 
ALTER TABLE ONLY coitem
114283
 
    ADD CONSTRAINT coitem_coitem_itemsite_id_fkey FOREIGN KEY (coitem_itemsite_id) REFERENCES itemsite(itemsite_id);
114284
 
 
114285
 
 
114286
 
--
114287
 
--
114288
 
 
114289
 
ALTER TABLE ONLY coitem
114290
 
    ADD CONSTRAINT coitem_coitem_price_uom_id_fkey FOREIGN KEY (coitem_price_uom_id) REFERENCES uom(uom_id);
114291
 
 
114292
 
 
114293
 
--
114294
 
--
114295
 
 
114296
 
ALTER TABLE ONLY coitem
114297
 
    ADD CONSTRAINT coitem_coitem_qty_uom_id_fkey FOREIGN KEY (coitem_qty_uom_id) REFERENCES uom(uom_id);
114298
 
 
114299
 
 
114300
 
--
114301
 
--
114302
 
 
114303
 
ALTER TABLE ONLY coitem
114304
 
    ADD CONSTRAINT coitem_coitem_rev_accnt_id_fkey FOREIGN KEY (coitem_rev_accnt_id) REFERENCES accnt(accnt_id);
114305
 
 
114306
 
 
114307
 
--
114308
 
--
114309
 
 
114310
 
ALTER TABLE ONLY coitem
114311
 
    ADD CONSTRAINT coitem_coitem_substitute_item_id_fkey FOREIGN KEY (coitem_substitute_item_id) REFERENCES item(item_id);
114312
 
 
114313
 
 
114314
 
--
114315
 
--
114316
 
 
114317
 
ALTER TABLE ONLY coitem
114318
 
    ADD CONSTRAINT coitem_coitem_taxtype_id_fkey FOREIGN KEY (coitem_taxtype_id) REFERENCES taxtype(taxtype_id);
114319
 
 
114320
 
 
114321
 
--
114322
 
--
114323
 
 
114324
 
ALTER TABLE ONLY comment
114325
 
    ADD CONSTRAINT comment_comment_cmnttype_id_fkey FOREIGN KEY (comment_cmnttype_id) REFERENCES cmnttype(cmnttype_id);
114326
 
 
114327
 
 
114328
 
--
114329
 
--
114330
 
 
114331
 
ALTER TABLE ONLY company
114332
 
    ADD CONSTRAINT company_company_curr_id_fkey FOREIGN KEY (company_curr_id) REFERENCES curr_symbol(curr_id);
114333
 
 
114334
 
 
114335
 
--
114336
 
--
114337
 
 
114338
 
ALTER TABLE ONLY company
114339
 
    ADD CONSTRAINT company_company_dscrp_accnt_id_fkey FOREIGN KEY (company_dscrp_accnt_id) REFERENCES accnt(accnt_id);
114340
 
 
114341
 
 
114342
 
--
114343
 
--
114344
 
 
114345
 
ALTER TABLE ONLY company
114346
 
    ADD CONSTRAINT company_company_gainloss_accnt_id_fkey FOREIGN KEY (company_gainloss_accnt_id) REFERENCES accnt(accnt_id);
114347
 
 
114348
 
 
114349
 
--
114350
 
--
114351
 
 
114352
 
ALTER TABLE ONLY company
114353
 
    ADD CONSTRAINT company_company_unrlzgainloss_accnt_id_fkey FOREIGN KEY (company_unrlzgainloss_accnt_id) REFERENCES accnt(accnt_id);
114354
 
 
114355
 
 
114356
 
--
114357
 
--
114358
 
 
114359
 
ALTER TABLE ONLY company
114360
 
    ADD CONSTRAINT company_company_yearend_accnt_id_fkey FOREIGN KEY (company_yearend_accnt_id) REFERENCES accnt(accnt_id);
114361
 
 
114362
 
 
114363
 
--
114364
 
--
114365
 
 
114366
 
ALTER TABLE ONLY contrct
114367
 
    ADD CONSTRAINT contrct_contrct_vend_id_fkey FOREIGN KEY (contrct_vend_id) REFERENCES vendinfo(vend_id);
114368
 
 
114369
 
 
114370
 
--
114371
 
--
114372
 
 
114373
 
ALTER TABLE ONLY costhist
114374
 
    ADD CONSTRAINT costhist_new_to_curr_symbol FOREIGN KEY (costhist_newcurr_id) REFERENCES curr_symbol(curr_id);
114375
 
 
114376
 
 
114377
 
--
114378
 
--
114379
 
 
114380
 
ALTER TABLE ONLY costhist
114381
 
    ADD CONSTRAINT costhist_old_to_curr_symbol FOREIGN KEY (costhist_oldcurr_id) REFERENCES curr_symbol(curr_id);
114382
 
 
114383
 
 
114384
 
--
114385
 
--
114386
 
 
114387
 
ALTER TABLE ONLY crmacct
114388
 
    ADD CONSTRAINT crmacct_crmacct_cntct_id_1_fkey FOREIGN KEY (crmacct_cntct_id_1) REFERENCES cntct(cntct_id);
114389
 
 
114390
 
 
114391
 
--
114392
 
--
114393
 
 
114394
 
ALTER TABLE ONLY crmacct
114395
 
    ADD CONSTRAINT crmacct_crmacct_cntct_id_2_fkey FOREIGN KEY (crmacct_cntct_id_2) REFERENCES cntct(cntct_id);
114396
 
 
114397
 
 
114398
 
--
114399
 
--
114400
 
 
114401
 
ALTER TABLE ONLY crmacct
114402
 
    ADD CONSTRAINT crmacct_crmacct_cust_id_fkey FOREIGN KEY (crmacct_cust_id) REFERENCES custinfo(cust_id);
114403
 
 
114404
 
 
114405
 
--
114406
 
--
114407
 
 
114408
 
ALTER TABLE ONLY crmacct
114409
 
    ADD CONSTRAINT crmacct_crmacct_emp_id_fkey FOREIGN KEY (crmacct_emp_id) REFERENCES emp(emp_id);
114410
 
 
114411
 
 
114412
 
--
114413
 
--
114414
 
 
114415
 
ALTER TABLE ONLY crmacct
114416
 
    ADD CONSTRAINT crmacct_crmacct_parent_id_fkey FOREIGN KEY (crmacct_parent_id) REFERENCES crmacct(crmacct_id);
114417
 
 
114418
 
 
114419
 
--
114420
 
--
114421
 
 
114422
 
ALTER TABLE ONLY crmacct
114423
 
    ADD CONSTRAINT crmacct_crmacct_prospect_id_fkey FOREIGN KEY (crmacct_prospect_id) REFERENCES prospect(prospect_id);
114424
 
 
114425
 
 
114426
 
--
114427
 
--
114428
 
 
114429
 
ALTER TABLE ONLY crmacct
114430
 
    ADD CONSTRAINT crmacct_crmacct_salesrep_id_fkey FOREIGN KEY (crmacct_salesrep_id) REFERENCES salesrep(salesrep_id);
114431
 
 
114432
 
 
114433
 
--
114434
 
--
114435
 
 
114436
 
ALTER TABLE ONLY crmacct
114437
 
    ADD CONSTRAINT crmacct_crmacct_taxauth_id_fkey FOREIGN KEY (crmacct_taxauth_id) REFERENCES taxauth(taxauth_id);
114438
 
 
114439
 
 
114440
 
--
114441
 
--
114442
 
 
114443
 
ALTER TABLE ONLY crmacct
114444
 
    ADD CONSTRAINT crmacct_crmacct_vend_id_fkey FOREIGN KEY (crmacct_vend_id) REFERENCES vendinfo(vend_id);
114445
 
 
114446
 
 
114447
 
--
114448
 
--
114449
 
 
114450
 
ALTER TABLE ONLY crmacctsel
114451
 
    ADD CONSTRAINT crmacctsel_crmacctsel_dest_crmacct_id_fkey FOREIGN KEY (crmacctsel_dest_crmacct_id) REFERENCES crmacct(crmacct_id) ON DELETE CASCADE;
114452
 
 
114453
 
 
114454
 
--
114455
 
--
114456
 
 
114457
 
ALTER TABLE ONLY crmacctsel
114458
 
    ADD CONSTRAINT crmacctsel_crmacctsel_src_crmacct_id_fkey FOREIGN KEY (crmacctsel_src_crmacct_id) REFERENCES crmacct(crmacct_id) ON DELETE CASCADE;
114459
 
 
114460
 
 
114461
 
--
114462
 
--
114463
 
 
114464
 
ALTER TABLE ONLY curr_rate
114465
 
    ADD CONSTRAINT curr_rate_to_curr_symbol FOREIGN KEY (curr_id) REFERENCES curr_symbol(curr_id);
114466
 
 
114467
 
 
114468
 
--
114469
 
--
114470
 
 
114471
 
ALTER TABLE ONLY custinfo
114472
 
    ADD CONSTRAINT cust_creditlmt_to_curr_symbol FOREIGN KEY (cust_creditlmt_curr_id) REFERENCES curr_symbol(curr_id);
114473
 
 
114474
 
 
114475
 
--
114476
 
--
114477
 
 
114478
 
ALTER TABLE ONLY custinfo
114479
 
    ADD CONSTRAINT cust_to_curr_symbol FOREIGN KEY (cust_curr_id) REFERENCES curr_symbol(curr_id);
114480
 
 
114481
 
 
114482
 
--
114483
 
--
114484
 
 
114485
 
ALTER TABLE ONLY custinfo
114486
 
    ADD CONSTRAINT custinfo_cust_cntct_id_fkey FOREIGN KEY (cust_cntct_id) REFERENCES cntct(cntct_id);
114487
 
 
114488
 
 
114489
 
--
114490
 
--
114491
 
 
114492
 
ALTER TABLE ONLY custinfo
114493
 
    ADD CONSTRAINT custinfo_cust_corrcntct_id_fkey FOREIGN KEY (cust_corrcntct_id) REFERENCES cntct(cntct_id);
114494
 
 
114495
 
 
114496
 
--
114497
 
--
114498
 
 
114499
 
ALTER TABLE ONLY custinfo
114500
 
    ADD CONSTRAINT custinfo_cust_custtype_fkey FOREIGN KEY (cust_custtype_id) REFERENCES custtype(custtype_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
114501
 
 
114502
 
 
114503
 
--
114504
 
--
114505
 
 
114506
 
ALTER TABLE ONLY custinfo
114507
 
    ADD CONSTRAINT custinfo_cust_salesrep_fkey FOREIGN KEY (cust_salesrep_id) REFERENCES salesrep(salesrep_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
114508
 
 
114509
 
 
114510
 
--
114511
 
--
114512
 
 
114513
 
ALTER TABLE ONLY custinfo
114514
 
    ADD CONSTRAINT custinfo_cust_shipform_fkey FOREIGN KEY (cust_shipform_id) REFERENCES shipform(shipform_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
114515
 
 
114516
 
 
114517
 
--
114518
 
--
114519
 
 
114520
 
ALTER TABLE ONLY custinfo
114521
 
    ADD CONSTRAINT custinfo_cust_taxzone_id_fkey FOREIGN KEY (cust_taxzone_id) REFERENCES taxzone(taxzone_id);
114522
 
 
114523
 
 
114524
 
--
114525
 
--
114526
 
 
114527
 
ALTER TABLE ONLY custinfo
114528
 
    ADD CONSTRAINT custinfo_cust_terms_fkey FOREIGN KEY (cust_terms_id) REFERENCES terms(terms_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
114529
 
 
114530
 
 
114531
 
--
114532
 
--
114533
 
 
114534
 
ALTER TABLE ONLY emp
114535
 
    ADD CONSTRAINT emp_emp_cntct_id_fkey FOREIGN KEY (emp_cntct_id) REFERENCES cntct(cntct_id);
114536
 
 
114537
 
 
114538
 
--
114539
 
--
114540
 
 
114541
 
ALTER TABLE ONLY emp
114542
 
    ADD CONSTRAINT emp_emp_dept_id_fkey FOREIGN KEY (emp_dept_id) REFERENCES dept(dept_id);
114543
 
 
114544
 
 
114545
 
--
114546
 
--
114547
 
 
114548
 
ALTER TABLE ONLY emp
114549
 
    ADD CONSTRAINT emp_emp_image_id_fkey FOREIGN KEY (emp_image_id) REFERENCES image(image_id);
114550
 
 
114551
 
 
114552
 
--
114553
 
--
114554
 
 
114555
 
ALTER TABLE ONLY emp
114556
 
    ADD CONSTRAINT emp_emp_mgr_emp_id_fkey FOREIGN KEY (emp_mgr_emp_id) REFERENCES emp(emp_id);
114557
 
 
114558
 
 
114559
 
--
114560
 
--
114561
 
 
114562
 
ALTER TABLE ONLY emp
114563
 
    ADD CONSTRAINT emp_emp_shift_id_fkey FOREIGN KEY (emp_shift_id) REFERENCES shift(shift_id);
114564
 
 
114565
 
 
114566
 
--
114567
 
--
114568
 
 
114569
 
ALTER TABLE ONLY emp
114570
 
    ADD CONSTRAINT emp_emp_wage_curr_id_fkey FOREIGN KEY (emp_wage_curr_id) REFERENCES curr_symbol(curr_id);
114571
 
 
114572
 
 
114573
 
--
114574
 
--
114575
 
 
114576
 
ALTER TABLE ONLY emp
114577
 
    ADD CONSTRAINT emp_emp_warehous_id_fkey FOREIGN KEY (emp_warehous_id) REFERENCES whsinfo(warehous_id);
114578
 
 
114579
 
 
114580
 
--
114581
 
--
114582
 
 
114583
 
ALTER TABLE ONLY empgrpitem
114584
 
    ADD CONSTRAINT empgrpitem_empgrpitem_emp_id_fkey FOREIGN KEY (empgrpitem_emp_id) REFERENCES emp(emp_id);
114585
 
 
114586
 
 
114587
 
--
114588
 
--
114589
 
 
114590
 
ALTER TABLE ONLY empgrpitem
114591
 
    ADD CONSTRAINT empgrpitem_empgrpitem_empgrp_id_fkey FOREIGN KEY (empgrpitem_empgrp_id) REFERENCES empgrp(empgrp_id);
114592
 
 
114593
 
 
114594
 
--
114595
 
--
114596
 
 
114597
 
ALTER TABLE ONLY flnotes
114598
 
    ADD CONSTRAINT flnotes_flnotes_flhead_id_fkey FOREIGN KEY (flnotes_flhead_id) REFERENCES flhead(flhead_id) ON DELETE CASCADE;
114599
 
 
114600
 
 
114601
 
--
114602
 
--
114603
 
 
114604
 
ALTER TABLE ONLY flnotes
114605
 
    ADD CONSTRAINT flnotes_flnotes_period_id_fkey FOREIGN KEY (flnotes_period_id) REFERENCES period(period_id) ON DELETE CASCADE;
114606
 
 
114607
 
 
114608
 
--
114609
 
--
114610
 
 
114611
 
ALTER TABLE ONLY grppriv
114612
 
    ADD CONSTRAINT grppriv_grppriv_grp_id_fkey FOREIGN KEY (grppriv_grp_id) REFERENCES grp(grp_id);
114613
 
 
114614
 
 
114615
 
--
114616
 
--
114617
 
 
114618
 
ALTER TABLE ONLY incdt
114619
 
    ADD CONSTRAINT incdt_incdt_aropen_id_fkey FOREIGN KEY (incdt_aropen_id) REFERENCES aropen(aropen_id);
114620
 
 
114621
 
 
114622
 
--
114623
 
--
114624
 
 
114625
 
ALTER TABLE ONLY incdt
114626
 
    ADD CONSTRAINT incdt_incdt_cntct_id_fkey FOREIGN KEY (incdt_cntct_id) REFERENCES cntct(cntct_id);
114627
 
 
114628
 
 
114629
 
--
114630
 
--
114631
 
 
114632
 
ALTER TABLE ONLY incdt
114633
 
    ADD CONSTRAINT incdt_incdt_crmacct_id_fkey FOREIGN KEY (incdt_crmacct_id) REFERENCES crmacct(crmacct_id);
114634
 
 
114635
 
 
114636
 
--
114637
 
--
114638
 
 
114639
 
ALTER TABLE ONLY incdt
114640
 
    ADD CONSTRAINT incdt_incdt_incdtcat_id_fkey FOREIGN KEY (incdt_incdtcat_id) REFERENCES incdtcat(incdtcat_id);
114641
 
 
114642
 
 
114643
 
--
114644
 
--
114645
 
 
114646
 
ALTER TABLE ONLY incdt
114647
 
    ADD CONSTRAINT incdt_incdt_incdtpriority_id_fkey FOREIGN KEY (incdt_incdtpriority_id) REFERENCES incdtpriority(incdtpriority_id);
114648
 
 
114649
 
 
114650
 
--
114651
 
--
114652
 
 
114653
 
ALTER TABLE ONLY incdt
114654
 
    ADD CONSTRAINT incdt_incdt_incdtresolution_id_fkey FOREIGN KEY (incdt_incdtresolution_id) REFERENCES incdtresolution(incdtresolution_id);
114655
 
 
114656
 
 
114657
 
--
114658
 
--
114659
 
 
114660
 
ALTER TABLE ONLY incdt
114661
 
    ADD CONSTRAINT incdt_incdt_incdtseverity_id_fkey FOREIGN KEY (incdt_incdtseverity_id) REFERENCES incdtseverity(incdtseverity_id);
114662
 
 
114663
 
 
114664
 
--
114665
 
--
114666
 
 
114667
 
ALTER TABLE ONLY incdt
114668
 
    ADD CONSTRAINT incdt_incdt_item_id_fkey FOREIGN KEY (incdt_item_id) REFERENCES item(item_id);
114669
 
 
114670
 
 
114671
 
--
114672
 
--
114673
 
 
114674
 
ALTER TABLE ONLY incdt
114675
 
    ADD CONSTRAINT incdt_incdt_prj_id_fkey FOREIGN KEY (incdt_prj_id) REFERENCES prj(prj_id);
114676
 
 
114677
 
 
114678
 
--
114679
 
--
114680
 
 
114681
 
ALTER TABLE ONLY incdt
114682
 
    ADD CONSTRAINT incdt_incdt_recurring_incdt_id_fkey FOREIGN KEY (incdt_recurring_incdt_id) REFERENCES incdt(incdt_id);
114683
 
 
114684
 
 
114685
 
--
114686
 
--
114687
 
 
114688
 
ALTER TABLE ONLY incdthist
114689
 
    ADD CONSTRAINT incdthist_incdthist_incdt_id_fkey FOREIGN KEY (incdthist_incdt_id) REFERENCES incdt(incdt_id);
114690
 
 
114691
 
 
114692
 
--
114693
 
--
114694
 
 
114695
 
ALTER TABLE ONLY invbal
114696
 
    ADD CONSTRAINT invbal_invbal_itemsite_id_fkey FOREIGN KEY (invbal_itemsite_id) REFERENCES itemsite(itemsite_id) ON DELETE CASCADE;
114697
 
 
114698
 
 
114699
 
--
114700
 
--
114701
 
 
114702
 
ALTER TABLE ONLY invbal
114703
 
    ADD CONSTRAINT invbal_invbal_period_id_fkey FOREIGN KEY (invbal_period_id) REFERENCES period(period_id) ON DELETE CASCADE;
114704
 
 
114705
 
 
114706
 
--
114707
 
--
114708
 
 
114709
 
ALTER TABLE ONLY invchead
114710
 
    ADD CONSTRAINT invchead_invchead_saletype_id_fkey FOREIGN KEY (invchead_saletype_id) REFERENCES saletype(saletype_id);
114711
 
 
114712
 
 
114713
 
--
114714
 
--
114715
 
 
114716
 
ALTER TABLE ONLY invchead
114717
 
    ADD CONSTRAINT invchead_invchead_shipzone_id_fkey FOREIGN KEY (invchead_shipzone_id) REFERENCES shipzone(shipzone_id);
114718
 
 
114719
 
 
114720
 
--
114721
 
--
114722
 
 
114723
 
ALTER TABLE ONLY invchead
114724
 
    ADD CONSTRAINT invchead_invchead_taxzone_id_fkey FOREIGN KEY (invchead_taxzone_id) REFERENCES taxzone(taxzone_id);
114725
 
 
114726
 
 
114727
 
--
114728
 
--
114729
 
 
114730
 
ALTER TABLE ONLY invchead
114731
 
    ADD CONSTRAINT invchead_to_curr_symbol FOREIGN KEY (invchead_curr_id) REFERENCES curr_symbol(curr_id);
114732
 
 
114733
 
 
114734
 
--
114735
 
--
114736
 
 
114737
 
ALTER TABLE ONLY invcheadtax
114738
 
    ADD CONSTRAINT invcheadtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id);
114739
 
 
114740
 
 
114741
 
--
114742
 
--
114743
 
 
114744
 
ALTER TABLE ONLY invcheadtax
114745
 
    ADD CONSTRAINT invcheadtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES invchead(invchead_id) ON DELETE CASCADE;
114746
 
 
114747
 
 
114748
 
--
114749
 
--
114750
 
 
114751
 
ALTER TABLE ONLY invcheadtax
114752
 
    ADD CONSTRAINT invcheadtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id);
114753
 
 
114754
 
 
114755
 
--
114756
 
--
114757
 
 
114758
 
ALTER TABLE ONLY invcheadtax
114759
 
    ADD CONSTRAINT invcheadtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id);
114760
 
 
114761
 
 
114762
 
--
114763
 
--
114764
 
 
114765
 
ALTER TABLE ONLY invcitem
114766
 
    ADD CONSTRAINT invcitem_invchead_id_fkey FOREIGN KEY (invcitem_invchead_id) REFERENCES invchead(invchead_id) ON UPDATE CASCADE ON DELETE CASCADE;
114767
 
 
114768
 
 
114769
 
--
114770
 
--
114771
 
 
114772
 
ALTER TABLE ONLY invcitem
114773
 
    ADD CONSTRAINT invcitem_invcitem_price_uom_id_fkey FOREIGN KEY (invcitem_price_uom_id) REFERENCES uom(uom_id);
114774
 
 
114775
 
 
114776
 
--
114777
 
--
114778
 
 
114779
 
ALTER TABLE ONLY invcitem
114780
 
    ADD CONSTRAINT invcitem_invcitem_qty_uom_id_fkey FOREIGN KEY (invcitem_qty_uom_id) REFERENCES uom(uom_id);
114781
 
 
114782
 
 
114783
 
--
114784
 
--
114785
 
 
114786
 
ALTER TABLE ONLY invcitem
114787
 
    ADD CONSTRAINT invcitem_invcitem_rev_accnt_id_fkey FOREIGN KEY (invcitem_rev_accnt_id) REFERENCES accnt(accnt_id);
114788
 
 
114789
 
 
114790
 
--
114791
 
--
114792
 
 
114793
 
ALTER TABLE ONLY invcitem
114794
 
    ADD CONSTRAINT invcitem_invcitem_taxtype_id_fkey FOREIGN KEY (invcitem_taxtype_id) REFERENCES taxtype(taxtype_id);
114795
 
 
114796
 
 
114797
 
--
114798
 
--
114799
 
 
114800
 
ALTER TABLE ONLY invcitemtax
114801
 
    ADD CONSTRAINT invcitemtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id);
114802
 
 
114803
 
 
114804
 
--
114805
 
--
114806
 
 
114807
 
ALTER TABLE ONLY invcitemtax
114808
 
    ADD CONSTRAINT invcitemtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES invcitem(invcitem_id) ON DELETE CASCADE;
114809
 
 
114810
 
 
114811
 
--
114812
 
--
114813
 
 
114814
 
ALTER TABLE ONLY invcitemtax
114815
 
    ADD CONSTRAINT invcitemtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id);
114816
 
 
114817
 
 
114818
 
--
114819
 
--
114820
 
 
114821
 
ALTER TABLE ONLY invcitemtax
114822
 
    ADD CONSTRAINT invcitemtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id);
114823
 
 
114824
 
 
114825
 
--
114826
 
--
114827
 
 
114828
 
ALTER TABLE ONLY invhistexpcat
114829
 
    ADD CONSTRAINT invhistexpcat_invhistexpcat_expcat_id_fkey FOREIGN KEY (invhistexpcat_expcat_id) REFERENCES expcat(expcat_id) ON UPDATE CASCADE ON DELETE CASCADE;
114830
 
 
114831
 
 
114832
 
--
114833
 
--
114834
 
 
114835
 
ALTER TABLE ONLY invhistexpcat
114836
 
    ADD CONSTRAINT invhistexpcat_invhistexpcat_invhist_id_fkey FOREIGN KEY (invhistexpcat_invhist_id) REFERENCES invhist(invhist_id) ON UPDATE CASCADE ON DELETE CASCADE;
114837
 
 
114838
 
 
114839
 
--
114840
 
--
114841
 
 
114842
 
ALTER TABLE ONLY ipsass
114843
 
    ADD CONSTRAINT ipsass_ipsass_ipshead_id_fkey FOREIGN KEY (ipsass_ipshead_id) REFERENCES ipshead(ipshead_id);
114844
 
 
114845
 
 
114846
 
--
114847
 
--
114848
 
 
114849
 
ALTER TABLE ONLY ipsfreight
114850
 
    ADD CONSTRAINT ipsfreight_ipsfreight_freightclass_id_fkey FOREIGN KEY (ipsfreight_freightclass_id) REFERENCES freightclass(freightclass_id);
114851
 
 
114852
 
 
114853
 
--
114854
 
--
114855
 
 
114856
 
ALTER TABLE ONLY ipsfreight
114857
 
    ADD CONSTRAINT ipsfreight_ipsfreight_ipshead_id_fkey FOREIGN KEY (ipsfreight_ipshead_id) REFERENCES ipshead(ipshead_id);
114858
 
 
114859
 
 
114860
 
--
114861
 
--
114862
 
 
114863
 
ALTER TABLE ONLY ipsfreight
114864
 
    ADD CONSTRAINT ipsfreight_ipsfreight_shipzone_id_fkey FOREIGN KEY (ipsfreight_shipzone_id) REFERENCES shipzone(shipzone_id);
114865
 
 
114866
 
 
114867
 
--
114868
 
--
114869
 
 
114870
 
ALTER TABLE ONLY ipsfreight
114871
 
    ADD CONSTRAINT ipsfreight_ipsfreight_warehous_id_fkey FOREIGN KEY (ipsfreight_warehous_id) REFERENCES whsinfo(warehous_id);
114872
 
 
114873
 
 
114874
 
--
114875
 
--
114876
 
 
114877
 
ALTER TABLE ONLY ipshead
114878
 
    ADD CONSTRAINT ipshead_to_curr_symbol FOREIGN KEY (ipshead_curr_id) REFERENCES curr_symbol(curr_id);
114879
 
 
114880
 
 
114881
 
--
114882
 
--
114883
 
 
114884
 
ALTER TABLE ONLY ipsiteminfo
114885
 
    ADD CONSTRAINT ipsitem_ipshead_id_fk FOREIGN KEY (ipsitem_ipshead_id) REFERENCES ipshead(ipshead_id) ON DELETE CASCADE;
114886
 
 
114887
 
 
114888
 
--
114889
 
--
114890
 
 
114891
 
ALTER TABLE ONLY ipsiteminfo
114892
 
    ADD CONSTRAINT ipsitem_ipsitem_price_uom_id_fkey FOREIGN KEY (ipsitem_price_uom_id) REFERENCES uom(uom_id);
114893
 
 
114894
 
 
114895
 
--
114896
 
--
114897
 
 
114898
 
ALTER TABLE ONLY ipsiteminfo
114899
 
    ADD CONSTRAINT ipsitem_ipsitem_qty_uom_id_fkey FOREIGN KEY (ipsitem_qty_uom_id) REFERENCES uom(uom_id);
114900
 
 
114901
 
 
114902
 
--
114903
 
--
114904
 
 
114905
 
ALTER TABLE ONLY ipsiteminfo
114906
 
    ADD CONSTRAINT ipsitem_ipsitem_warehous_id_fkey FOREIGN KEY (ipsitem_warehous_id) REFERENCES whsinfo(warehous_id);
114907
 
 
114908
 
 
114909
 
--
114910
 
--
114911
 
 
114912
 
ALTER TABLE ONLY ipsiteminfo
114913
 
    ADD CONSTRAINT ipsitem_item_id_fk FOREIGN KEY (ipsitem_item_id) REFERENCES item(item_id);
114914
 
 
114915
 
 
114916
 
--
114917
 
--
114918
 
 
114919
 
ALTER TABLE ONLY ipsitemchar
114920
 
    ADD CONSTRAINT ipsitemchar_ipsitemchar_char_id_fkey FOREIGN KEY (ipsitemchar_char_id) REFERENCES "char"(char_id);
114921
 
 
114922
 
 
114923
 
--
114924
 
--
114925
 
 
114926
 
ALTER TABLE ONLY ipsitemchar
114927
 
    ADD CONSTRAINT ipsitemchar_ipsitemchar_ipsitem_id_fkey FOREIGN KEY (ipsitemchar_ipsitem_id) REFERENCES ipsiteminfo(ipsitem_id) ON DELETE CASCADE;
114928
 
 
114929
 
 
114930
 
--
114931
 
--
114932
 
 
114933
 
ALTER TABLE ONLY item
114934
 
    ADD CONSTRAINT item_item_classcode_id_fkey FOREIGN KEY (item_classcode_id) REFERENCES classcode(classcode_id);
114935
 
 
114936
 
 
114937
 
--
114938
 
--
114939
 
 
114940
 
ALTER TABLE ONLY item
114941
 
    ADD CONSTRAINT item_item_freightclass_id_fkey FOREIGN KEY (item_freightclass_id) REFERENCES freightclass(freightclass_id);
114942
 
 
114943
 
 
114944
 
--
114945
 
--
114946
 
 
114947
 
ALTER TABLE ONLY item
114948
 
    ADD CONSTRAINT item_item_inv_uom_id_fkey FOREIGN KEY (item_inv_uom_id) REFERENCES uom(uom_id);
114949
 
 
114950
 
 
114951
 
--
114952
 
--
114953
 
 
114954
 
ALTER TABLE ONLY item
114955
 
    ADD CONSTRAINT item_item_price_uom_id_fkey FOREIGN KEY (item_price_uom_id) REFERENCES uom(uom_id);
114956
 
 
114957
 
 
114958
 
--
114959
 
--
114960
 
 
114961
 
ALTER TABLE ONLY itemalias
114962
 
    ADD CONSTRAINT itemalias_itemalias_crmacct_id_fkey FOREIGN KEY (itemalias_crmacct_id) REFERENCES crmacct(crmacct_id);
114963
 
 
114964
 
 
114965
 
--
114966
 
--
114967
 
 
114968
 
ALTER TABLE ONLY itemalias
114969
 
    ADD CONSTRAINT itemalias_itemalias_item_id_fkey FOREIGN KEY (itemalias_item_id) REFERENCES item(item_id);
114970
 
 
114971
 
 
114972
 
--
114973
 
--
114974
 
 
114975
 
ALTER TABLE ONLY itemcost
114976
 
    ADD CONSTRAINT itemcost_itemcost_costelem_id_fkey FOREIGN KEY (itemcost_costelem_id) REFERENCES costelem(costelem_id);
114977
 
 
114978
 
 
114979
 
--
114980
 
--
114981
 
 
114982
 
ALTER TABLE ONLY itemcost
114983
 
    ADD CONSTRAINT itemcost_itemcost_curr_id_fkey FOREIGN KEY (itemcost_curr_id) REFERENCES curr_symbol(curr_id);
114984
 
 
114985
 
 
114986
 
--
114987
 
--
114988
 
 
114989
 
ALTER TABLE ONLY itemcost
114990
 
    ADD CONSTRAINT itemcost_itemcost_item_id_fkey FOREIGN KEY (itemcost_item_id) REFERENCES item(item_id);
114991
 
 
114992
 
 
114993
 
--
114994
 
--
114995
 
 
114996
 
ALTER TABLE ONLY itemcost
114997
 
    ADD CONSTRAINT itemcost_to_curr_symbol FOREIGN KEY (itemcost_curr_id) REFERENCES curr_symbol(curr_id);
114998
 
 
114999
 
 
115000
 
--
115001
 
--
115002
 
 
115003
 
ALTER TABLE ONLY itemsite
115004
 
    ADD CONSTRAINT itemsite_itemsite_costcat_id_fkey FOREIGN KEY (itemsite_costcat_id) REFERENCES costcat(costcat_id);
115005
 
 
115006
 
 
115007
 
--
115008
 
--
115009
 
 
115010
 
ALTER TABLE ONLY itemsite
115011
 
    ADD CONSTRAINT itemsite_itemsite_item_id_fkey FOREIGN KEY (itemsite_item_id) REFERENCES item(item_id);
115012
 
 
115013
 
 
115014
 
--
115015
 
--
115016
 
 
115017
 
ALTER TABLE ONLY itemsite
115018
 
    ADD CONSTRAINT itemsite_itemsite_plancode_id_fkey FOREIGN KEY (itemsite_plancode_id) REFERENCES plancode(plancode_id);
115019
 
 
115020
 
 
115021
 
--
115022
 
--
115023
 
 
115024
 
ALTER TABLE ONLY itemsite
115025
 
    ADD CONSTRAINT itemsite_itemsite_warehous_id_fkey FOREIGN KEY (itemsite_warehous_id) REFERENCES whsinfo(warehous_id);
115026
 
 
115027
 
 
115028
 
--
115029
 
--
115030
 
 
115031
 
ALTER TABLE ONLY itemsrc
115032
 
    ADD CONSTRAINT itemsrc_itemsrc_contrct_id_fkey FOREIGN KEY (itemsrc_contrct_id) REFERENCES contrct(contrct_id);
115033
 
 
115034
 
 
115035
 
--
115036
 
--
115037
 
 
115038
 
ALTER TABLE ONLY itemsrc
115039
 
    ADD CONSTRAINT itemsrc_itemsrc_item_id_fkey FOREIGN KEY (itemsrc_item_id) REFERENCES item(item_id) ON DELETE CASCADE;
115040
 
 
115041
 
 
115042
 
--
115043
 
--
115044
 
 
115045
 
ALTER TABLE ONLY itemsrc
115046
 
    ADD CONSTRAINT itemsrc_itemsrc_vend_id_fkey FOREIGN KEY (itemsrc_vend_id) REFERENCES vendinfo(vend_id) ON DELETE CASCADE;
115047
 
 
115048
 
 
115049
 
--
115050
 
--
115051
 
 
115052
 
ALTER TABLE ONLY itemsrcp
115053
 
    ADD CONSTRAINT itemsrcp_itemsrcp_itemsrc_id_fkey FOREIGN KEY (itemsrcp_itemsrc_id) REFERENCES itemsrc(itemsrc_id) ON DELETE CASCADE;
115054
 
 
115055
 
 
115056
 
--
115057
 
--
115058
 
 
115059
 
ALTER TABLE ONLY itemsrcp
115060
 
    ADD CONSTRAINT itemsrcp_to_curr_symbol FOREIGN KEY (itemsrcp_curr_id) REFERENCES curr_symbol(curr_id);
115061
 
 
115062
 
 
115063
 
--
115064
 
--
115065
 
 
115066
 
ALTER TABLE ONLY itemsub
115067
 
    ADD CONSTRAINT itemsub_itemsub_parent_item_id_fkey FOREIGN KEY (itemsub_parent_item_id) REFERENCES item(item_id);
115068
 
 
115069
 
 
115070
 
--
115071
 
--
115072
 
 
115073
 
ALTER TABLE ONLY itemsub
115074
 
    ADD CONSTRAINT itemsub_itemsub_sub_item_id_fkey FOREIGN KEY (itemsub_sub_item_id) REFERENCES item(item_id);
115075
 
 
115076
 
 
115077
 
--
115078
 
--
115079
 
 
115080
 
ALTER TABLE ONLY itemtax
115081
 
    ADD CONSTRAINT itemtax_itemtax_item_id_fkey FOREIGN KEY (itemtax_item_id) REFERENCES item(item_id);
115082
 
 
115083
 
 
115084
 
--
115085
 
--
115086
 
 
115087
 
ALTER TABLE ONLY itemtax
115088
 
    ADD CONSTRAINT itemtax_itemtax_taxtype_id_fkey FOREIGN KEY (itemtax_taxtype_id) REFERENCES taxtype(taxtype_id);
115089
 
 
115090
 
 
115091
 
--
115092
 
--
115093
 
 
115094
 
ALTER TABLE ONLY itemtax
115095
 
    ADD CONSTRAINT itemtax_itemtax_taxzone_id_fkey FOREIGN KEY (itemtax_taxzone_id) REFERENCES taxzone(taxzone_id);
115096
 
 
115097
 
 
115098
 
--
115099
 
--
115100
 
 
115101
 
ALTER TABLE ONLY itemtrans
115102
 
    ADD CONSTRAINT itemtrans_itemtrans_source_item_id_fkey FOREIGN KEY (itemtrans_source_item_id) REFERENCES item(item_id);
115103
 
 
115104
 
 
115105
 
--
115106
 
--
115107
 
 
115108
 
ALTER TABLE ONLY itemtrans
115109
 
    ADD CONSTRAINT itemtrans_itemtrans_target_item_id_fkey FOREIGN KEY (itemtrans_target_item_id) REFERENCES item(item_id);
115110
 
 
115111
 
 
115112
 
--
115113
 
--
115114
 
 
115115
 
ALTER TABLE ONLY itemuom
115116
 
    ADD CONSTRAINT itemuom_itemuom_itemuomconv_id_fkey FOREIGN KEY (itemuom_itemuomconv_id) REFERENCES itemuomconv(itemuomconv_id);
115117
 
 
115118
 
 
115119
 
--
115120
 
--
115121
 
 
115122
 
ALTER TABLE ONLY itemuom
115123
 
    ADD CONSTRAINT itemuom_itemuom_uomtype_id_fkey FOREIGN KEY (itemuom_uomtype_id) REFERENCES uomtype(uomtype_id);
115124
 
 
115125
 
 
115126
 
--
115127
 
--
115128
 
 
115129
 
ALTER TABLE ONLY itemuomconv
115130
 
    ADD CONSTRAINT itemuomconv_itemuomconv_from_uom_id_fkey FOREIGN KEY (itemuomconv_from_uom_id) REFERENCES uom(uom_id);
115131
 
 
115132
 
 
115133
 
--
115134
 
--
115135
 
 
115136
 
ALTER TABLE ONLY itemuomconv
115137
 
    ADD CONSTRAINT itemuomconv_itemuomconv_item_id_fkey FOREIGN KEY (itemuomconv_item_id) REFERENCES item(item_id);
115138
 
 
115139
 
 
115140
 
--
115141
 
--
115142
 
 
115143
 
ALTER TABLE ONLY itemuomconv
115144
 
    ADD CONSTRAINT itemuomconv_itemuomconv_to_uom_id_fkey FOREIGN KEY (itemuomconv_to_uom_id) REFERENCES uom(uom_id);
115145
 
 
115146
 
 
115147
 
--
115148
 
--
115149
 
 
115150
 
ALTER TABLE ONLY mrghist
115151
 
    ADD CONSTRAINT mrghist_mrghist_cntct_id_fkey FOREIGN KEY (mrghist_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE;
115152
 
 
115153
 
 
115154
 
--
115155
 
--
115156
 
 
115157
 
ALTER TABLE ONLY ophead
115158
 
    ADD CONSTRAINT ophead_ophead_cntct_id_fkey FOREIGN KEY (ophead_cntct_id) REFERENCES cntct(cntct_id);
115159
 
 
115160
 
 
115161
 
--
115162
 
--
115163
 
 
115164
 
ALTER TABLE ONLY ophead
115165
 
    ADD CONSTRAINT ophead_ophead_crmacct_id_fkey FOREIGN KEY (ophead_crmacct_id) REFERENCES crmacct(crmacct_id);
115166
 
 
115167
 
 
115168
 
--
115169
 
--
115170
 
 
115171
 
ALTER TABLE ONLY ophead
115172
 
    ADD CONSTRAINT ophead_ophead_opsource_id_fkey FOREIGN KEY (ophead_opsource_id) REFERENCES opsource(opsource_id);
115173
 
 
115174
 
 
115175
 
--
115176
 
--
115177
 
 
115178
 
ALTER TABLE ONLY ophead
115179
 
    ADD CONSTRAINT ophead_ophead_opstage_id_fkey FOREIGN KEY (ophead_opstage_id) REFERENCES opstage(opstage_id);
115180
 
 
115181
 
 
115182
 
--
115183
 
--
115184
 
 
115185
 
ALTER TABLE ONLY ophead
115186
 
    ADD CONSTRAINT ophead_ophead_optype_id_fkey FOREIGN KEY (ophead_optype_id) REFERENCES optype(optype_id);
115187
 
 
115188
 
 
115189
 
--
115190
 
--
115191
 
 
115192
 
ALTER TABLE ONLY ophead
115193
 
    ADD CONSTRAINT ophead_ophead_priority_id_fkey FOREIGN KEY (ophead_priority_id) REFERENCES incdtpriority(incdtpriority_id);
115194
 
 
115195
 
 
115196
 
--
115197
 
--
115198
 
 
115199
 
ALTER TABLE ONLY pack
115200
 
    ADD CONSTRAINT pack_pack_shiphead_id_fkey FOREIGN KEY (pack_shiphead_id) REFERENCES shiphead(shiphead_id);
115201
 
 
115202
 
 
115203
 
--
115204
 
--
115205
 
 
115206
 
ALTER TABLE ONLY payco
115207
 
    ADD CONSTRAINT payco_payco_ccpay_id_fkey FOREIGN KEY (payco_ccpay_id) REFERENCES ccpay(ccpay_id);
115208
 
 
115209
 
 
115210
 
--
115211
 
--
115212
 
 
115213
 
ALTER TABLE ONLY payco
115214
 
    ADD CONSTRAINT payco_payco_cohead_id_fkey FOREIGN KEY (payco_cohead_id) REFERENCES cohead(cohead_id);
115215
 
 
115216
 
 
115217
 
--
115218
 
--
115219
 
 
115220
 
ALTER TABLE ONLY pkgdep
115221
 
    ADD CONSTRAINT pkgdep_pkgdep_parent_pkghead_id_fkey FOREIGN KEY (pkgdep_parent_pkghead_id) REFERENCES pkghead(pkghead_id);
115222
 
 
115223
 
 
115224
 
--
115225
 
--
115226
 
 
115227
 
ALTER TABLE ONLY pkgdep
115228
 
    ADD CONSTRAINT pkgdep_pkgdep_pkghead_id_fkey FOREIGN KEY (pkgdep_pkghead_id) REFERENCES pkghead(pkghead_id);
115229
 
 
115230
 
 
115231
 
--
115232
 
--
115233
 
 
115234
 
ALTER TABLE ONLY pkgitem
115235
 
    ADD CONSTRAINT pkgitem_pkgitem_pkghead_id_fkey FOREIGN KEY (pkgitem_pkghead_id) REFERENCES pkghead(pkghead_id) ON DELETE CASCADE;
115236
 
 
115237
 
 
115238
 
--
115239
 
--
115240
 
 
115241
 
ALTER TABLE ONLY pohead
115242
 
    ADD CONSTRAINT pohead_pohead_cohead_id_fkey FOREIGN KEY (pohead_cohead_id) REFERENCES cohead(cohead_id) ON DELETE SET NULL;
115243
 
 
115244
 
 
115245
 
--
115246
 
--
115247
 
 
115248
 
ALTER TABLE ONLY pohead
115249
 
    ADD CONSTRAINT pohead_pohead_shipto_cntct_id_fkey FOREIGN KEY (pohead_shipto_cntct_id) REFERENCES cntct(cntct_id);
115250
 
 
115251
 
 
115252
 
--
115253
 
--
115254
 
 
115255
 
ALTER TABLE ONLY pohead
115256
 
    ADD CONSTRAINT pohead_pohead_shiptoddress_id_fkey FOREIGN KEY (pohead_shiptoaddress_id) REFERENCES addr(addr_id);
115257
 
 
115258
 
 
115259
 
--
115260
 
--
115261
 
 
115262
 
ALTER TABLE ONLY pohead
115263
 
    ADD CONSTRAINT pohead_pohead_taxtype_id_fkey FOREIGN KEY (pohead_taxtype_id) REFERENCES taxtype(taxtype_id);
115264
 
 
115265
 
 
115266
 
--
115267
 
--
115268
 
 
115269
 
ALTER TABLE ONLY pohead
115270
 
    ADD CONSTRAINT pohead_pohead_taxzone_id_fkey FOREIGN KEY (pohead_taxzone_id) REFERENCES taxzone(taxzone_id);
115271
 
 
115272
 
 
115273
 
--
115274
 
--
115275
 
 
115276
 
ALTER TABLE ONLY pohead
115277
 
    ADD CONSTRAINT pohead_pohead_terms_id_fkey FOREIGN KEY (pohead_terms_id) REFERENCES terms(terms_id);
115278
 
 
115279
 
 
115280
 
--
115281
 
--
115282
 
 
115283
 
ALTER TABLE ONLY pohead
115284
 
    ADD CONSTRAINT pohead_pohead_vend_cntct_id_fkey FOREIGN KEY (pohead_vend_cntct_id) REFERENCES cntct(cntct_id);
115285
 
 
115286
 
 
115287
 
--
115288
 
--
115289
 
 
115290
 
ALTER TABLE ONLY pohead
115291
 
    ADD CONSTRAINT pohead_pohead_vend_id_fkey FOREIGN KEY (pohead_vend_id) REFERENCES vendinfo(vend_id);
115292
 
 
115293
 
 
115294
 
--
115295
 
--
115296
 
 
115297
 
ALTER TABLE ONLY pohead
115298
 
    ADD CONSTRAINT pohead_pohead_vendaddr_id_fkey FOREIGN KEY (pohead_vendaddr_id) REFERENCES vendaddrinfo(vendaddr_id);
115299
 
 
115300
 
 
115301
 
--
115302
 
--
115303
 
 
115304
 
ALTER TABLE ONLY pohead
115305
 
    ADD CONSTRAINT pohead_pohead_warehous_id_fkey FOREIGN KEY (pohead_warehous_id) REFERENCES whsinfo(warehous_id);
115306
 
 
115307
 
 
115308
 
--
115309
 
--
115310
 
 
115311
 
ALTER TABLE ONLY pohead
115312
 
    ADD CONSTRAINT pohead_to_curr_symbol FOREIGN KEY (pohead_curr_id) REFERENCES curr_symbol(curr_id);
115313
 
 
115314
 
 
115315
 
--
115316
 
--
115317
 
 
115318
 
ALTER TABLE ONLY poitem
115319
 
    ADD CONSTRAINT poitem_poitem_expcat_id_fkey FOREIGN KEY (poitem_expcat_id) REFERENCES expcat(expcat_id);
115320
 
 
115321
 
 
115322
 
--
115323
 
--
115324
 
 
115325
 
ALTER TABLE ONLY poitem
115326
 
    ADD CONSTRAINT poitem_poitem_itemsite_id_fkey FOREIGN KEY (poitem_itemsite_id) REFERENCES itemsite(itemsite_id);
115327
 
 
115328
 
 
115329
 
--
115330
 
--
115331
 
 
115332
 
ALTER TABLE ONLY poitem
115333
 
    ADD CONSTRAINT poitem_poitem_itemsrc_id_fkey FOREIGN KEY (poitem_itemsrc_id) REFERENCES itemsrc(itemsrc_id);
115334
 
 
115335
 
 
115336
 
--
115337
 
--
115338
 
 
115339
 
ALTER TABLE ONLY poitem
115340
 
    ADD CONSTRAINT poitem_poitem_prj_id_fkey FOREIGN KEY (poitem_prj_id) REFERENCES prj(prj_id);
115341
 
 
115342
 
 
115343
 
--
115344
 
--
115345
 
 
115346
 
ALTER TABLE ONLY poitem
115347
 
    ADD CONSTRAINT poitem_poitem_taxtype_id_fkey FOREIGN KEY (poitem_taxtype_id) REFERENCES taxtype(taxtype_id);
115348
 
 
115349
 
 
115350
 
--
115351
 
--
115352
 
 
115353
 
ALTER TABLE ONLY poreject
115354
 
    ADD CONSTRAINT poreject_poreject_recv_id_fkey FOREIGN KEY (poreject_recv_id) REFERENCES recv(recv_id);
115355
 
 
115356
 
 
115357
 
--
115358
 
--
115359
 
 
115360
 
ALTER TABLE ONLY poreject
115361
 
    ADD CONSTRAINT poreject_poreject_vend_id_fkey FOREIGN KEY (poreject_vend_id) REFERENCES vendinfo(vend_id);
115362
 
 
115363
 
 
115364
 
--
115365
 
--
115366
 
 
115367
 
ALTER TABLE ONLY prj
115368
 
    ADD CONSTRAINT prj_prj_cntct_id_fkey FOREIGN KEY (prj_cntct_id) REFERENCES cntct(cntct_id);
115369
 
 
115370
 
 
115371
 
--
115372
 
--
115373
 
 
115374
 
ALTER TABLE ONLY prj
115375
 
    ADD CONSTRAINT prj_prj_crmacct_id_fkey FOREIGN KEY (prj_crmacct_id) REFERENCES crmacct(crmacct_id);
115376
 
 
115377
 
 
115378
 
--
115379
 
--
115380
 
 
115381
 
ALTER TABLE ONLY prj
115382
 
    ADD CONSTRAINT prj_prj_prjtype_id_fkey FOREIGN KEY (prj_prjtype_id) REFERENCES prjtype(prjtype_id);
115383
 
 
115384
 
 
115385
 
--
115386
 
--
115387
 
 
115388
 
ALTER TABLE ONLY prj
115389
 
    ADD CONSTRAINT prj_prj_recurring_prj_id_fkey FOREIGN KEY (prj_recurring_prj_id) REFERENCES prj(prj_id);
115390
 
 
115391
 
 
115392
 
--
115393
 
--
115394
 
 
115395
 
ALTER TABLE ONLY prjtask
115396
 
    ADD CONSTRAINT prjtask_prjtask_prj_id_fkey FOREIGN KEY (prjtask_prj_id) REFERENCES prj(prj_id);
115397
 
 
115398
 
 
115399
 
--
115400
 
--
115401
 
 
115402
 
ALTER TABLE ONLY prospect
115403
 
    ADD CONSTRAINT prospect_prospect_cntct_id_fkey FOREIGN KEY (prospect_cntct_id) REFERENCES cntct(cntct_id);
115404
 
 
115405
 
 
115406
 
--
115407
 
--
115408
 
 
115409
 
ALTER TABLE ONLY prospect
115410
 
    ADD CONSTRAINT prospect_prospect_salesrep_id_fkey FOREIGN KEY (prospect_salesrep_id) REFERENCES salesrep(salesrep_id);
115411
 
 
115412
 
 
115413
 
--
115414
 
--
115415
 
 
115416
 
ALTER TABLE ONLY prospect
115417
 
    ADD CONSTRAINT prospect_prospect_taxzone_id_fkey FOREIGN KEY (prospect_taxzone_id) REFERENCES taxzone(taxzone_id);
115418
 
 
115419
 
 
115420
 
--
115421
 
--
115422
 
 
115423
 
ALTER TABLE ONLY prospect
115424
 
    ADD CONSTRAINT prospect_prospect_warehous_id_fkey FOREIGN KEY (prospect_warehous_id) REFERENCES whsinfo(warehous_id);
115425
 
 
115426
 
 
115427
 
--
115428
 
--
115429
 
 
115430
 
ALTER TABLE ONLY qryitem
115431
 
    ADD CONSTRAINT qryitem_qryitem_qryhead_id_fkey FOREIGN KEY (qryitem_qryhead_id) REFERENCES qryhead(qryhead_id);
115432
 
 
115433
 
 
115434
 
--
115435
 
--
115436
 
 
115437
 
ALTER TABLE ONLY quhead
115438
 
    ADD CONSTRAINT quhead_quhead_billto_cntct_id_fkey FOREIGN KEY (quhead_billto_cntct_id) REFERENCES cntct(cntct_id);
115439
 
 
115440
 
 
115441
 
--
115442
 
--
115443
 
 
115444
 
ALTER TABLE ONLY quhead
115445
 
    ADD CONSTRAINT quhead_quhead_misc_accnt_id_fkey FOREIGN KEY (quhead_misc_accnt_id) REFERENCES accnt(accnt_id);
115446
 
 
115447
 
 
115448
 
--
115449
 
--
115450
 
 
115451
 
ALTER TABLE ONLY quhead
115452
 
    ADD CONSTRAINT quhead_quhead_ophead_id_fkey FOREIGN KEY (quhead_ophead_id) REFERENCES ophead(ophead_id);
115453
 
 
115454
 
 
115455
 
--
115456
 
--
115457
 
 
115458
 
ALTER TABLE ONLY quhead
115459
 
    ADD CONSTRAINT quhead_quhead_prj_id_fkey FOREIGN KEY (quhead_prj_id) REFERENCES prj(prj_id);
115460
 
 
115461
 
 
115462
 
--
115463
 
--
115464
 
 
115465
 
ALTER TABLE ONLY quhead
115466
 
    ADD CONSTRAINT quhead_quhead_salesrep_id_fkey FOREIGN KEY (quhead_salesrep_id) REFERENCES salesrep(salesrep_id);
115467
 
 
115468
 
 
115469
 
--
115470
 
--
115471
 
 
115472
 
ALTER TABLE ONLY quhead
115473
 
    ADD CONSTRAINT quhead_quhead_saletype_id_fkey FOREIGN KEY (quhead_saletype_id) REFERENCES saletype(saletype_id);
115474
 
 
115475
 
 
115476
 
--
115477
 
--
115478
 
 
115479
 
ALTER TABLE ONLY quhead
115480
 
    ADD CONSTRAINT quhead_quhead_shipto_cntct_id_fkey FOREIGN KEY (quhead_shipto_cntct_id) REFERENCES cntct(cntct_id);
115481
 
 
115482
 
 
115483
 
--
115484
 
--
115485
 
 
115486
 
ALTER TABLE ONLY quhead
115487
 
    ADD CONSTRAINT quhead_quhead_shipto_id_fkey FOREIGN KEY (quhead_shipto_id) REFERENCES shiptoinfo(shipto_id);
115488
 
 
115489
 
 
115490
 
--
115491
 
--
115492
 
 
115493
 
ALTER TABLE ONLY quhead
115494
 
    ADD CONSTRAINT quhead_quhead_shipzone_id_fkey FOREIGN KEY (quhead_shipzone_id) REFERENCES shipzone(shipzone_id);
115495
 
 
115496
 
 
115497
 
--
115498
 
--
115499
 
 
115500
 
ALTER TABLE ONLY quhead
115501
 
    ADD CONSTRAINT quhead_quhead_taxtype_id_fkey FOREIGN KEY (quhead_taxtype_id) REFERENCES taxtype(taxtype_id);
115502
 
 
115503
 
 
115504
 
--
115505
 
--
115506
 
 
115507
 
ALTER TABLE ONLY quhead
115508
 
    ADD CONSTRAINT quhead_quhead_taxzone_id_fkey FOREIGN KEY (quhead_taxzone_id) REFERENCES taxzone(taxzone_id);
115509
 
 
115510
 
 
115511
 
--
115512
 
--
115513
 
 
115514
 
ALTER TABLE ONLY quhead
115515
 
    ADD CONSTRAINT quhead_quhead_terms_id_fkey FOREIGN KEY (quhead_terms_id) REFERENCES terms(terms_id);
115516
 
 
115517
 
 
115518
 
--
115519
 
--
115520
 
 
115521
 
ALTER TABLE ONLY quhead
115522
 
    ADD CONSTRAINT quhead_quhead_warehous_id_fkey FOREIGN KEY (quhead_warehous_id) REFERENCES whsinfo(warehous_id);
115523
 
 
115524
 
 
115525
 
--
115526
 
--
115527
 
 
115528
 
ALTER TABLE ONLY quhead
115529
 
    ADD CONSTRAINT quhead_to_curr_symbol FOREIGN KEY (quhead_curr_id) REFERENCES curr_symbol(curr_id);
115530
 
 
115531
 
 
115532
 
--
115533
 
--
115534
 
 
115535
 
ALTER TABLE ONLY quitem
115536
 
    ADD CONSTRAINT quitem_quitem_itemsrc_id_fkey FOREIGN KEY (quitem_itemsrc_id) REFERENCES itemsrc(itemsrc_id);
115537
 
 
115538
 
 
115539
 
--
115540
 
--
115541
 
 
115542
 
ALTER TABLE ONLY quitem
115543
 
    ADD CONSTRAINT quitem_quitem_price_uom_id_fkey FOREIGN KEY (quitem_price_uom_id) REFERENCES uom(uom_id);
115544
 
 
115545
 
 
115546
 
--
115547
 
--
115548
 
 
115549
 
ALTER TABLE ONLY quitem
115550
 
    ADD CONSTRAINT quitem_quitem_qty_uom_id_fkey FOREIGN KEY (quitem_qty_uom_id) REFERENCES uom(uom_id);
115551
 
 
115552
 
 
115553
 
--
115554
 
--
115555
 
 
115556
 
ALTER TABLE ONLY quitem
115557
 
    ADD CONSTRAINT quitem_quitem_taxtype_id_fkey FOREIGN KEY (quitem_taxtype_id) REFERENCES taxtype(taxtype_id);
115558
 
 
115559
 
 
115560
 
--
115561
 
--
115562
 
 
115563
 
ALTER TABLE ONLY recv
115564
 
    ADD CONSTRAINT recv_recv_freight_curr_id_fkey FOREIGN KEY (recv_freight_curr_id) REFERENCES curr_symbol(curr_id);
115565
 
 
115566
 
 
115567
 
--
115568
 
--
115569
 
 
115570
 
ALTER TABLE ONLY recv
115571
 
    ADD CONSTRAINT recv_recv_itemsite_id_fkey FOREIGN KEY (recv_itemsite_id) REFERENCES itemsite(itemsite_id);
115572
 
 
115573
 
 
115574
 
--
115575
 
--
115576
 
 
115577
 
ALTER TABLE ONLY recv
115578
 
    ADD CONSTRAINT recv_recv_purchcost_curr_id_fkey FOREIGN KEY (recv_purchcost_curr_id) REFERENCES curr_symbol(curr_id);
115579
 
 
115580
 
 
115581
 
--
115582
 
--
115583
 
 
115584
 
ALTER TABLE ONLY recv
115585
 
    ADD CONSTRAINT recv_recv_recvcost_curr_id_fkey FOREIGN KEY (recv_recvcost_curr_id) REFERENCES curr_symbol(curr_id);
115586
 
 
115587
 
 
115588
 
--
115589
 
--
115590
 
 
115591
 
ALTER TABLE ONLY recv
115592
 
    ADD CONSTRAINT recv_recv_splitfrom_id_fkey FOREIGN KEY (recv_splitfrom_id) REFERENCES recv(recv_id);
115593
 
 
115594
 
 
115595
 
--
115596
 
--
115597
 
 
115598
 
ALTER TABLE ONLY recv
115599
 
    ADD CONSTRAINT recv_recv_vend_id_fkey FOREIGN KEY (recv_vend_id) REFERENCES vendinfo(vend_id);
115600
 
 
115601
 
 
115602
 
--
115603
 
--
115604
 
 
115605
 
ALTER TABLE ONLY recv
115606
 
    ADD CONSTRAINT recv_recv_vohead_id_fkey FOREIGN KEY (recv_vohead_id) REFERENCES vohead(vohead_id);
115607
 
 
115608
 
 
115609
 
--
115610
 
--
115611
 
 
115612
 
ALTER TABLE ONLY recv
115613
 
    ADD CONSTRAINT recv_recv_voitem_id_fkey FOREIGN KEY (recv_voitem_id) REFERENCES voitem(voitem_id);
115614
 
 
115615
 
 
115616
 
--
115617
 
--
115618
 
 
115619
 
ALTER TABLE ONLY salesrep
115620
 
    ADD CONSTRAINT salesrep_salesrep_emp_id_fkey FOREIGN KEY (salesrep_emp_id) REFERENCES emp(emp_id);
115621
 
 
115622
 
 
115623
 
--
115624
 
--
115625
 
 
115626
 
ALTER TABLE ONLY shipdata
115627
 
    ADD CONSTRAINT shipdata_shipdata_base_freight_curr_id_fkey FOREIGN KEY (shipdata_base_freight_curr_id) REFERENCES curr_symbol(curr_id);
115628
 
 
115629
 
 
115630
 
--
115631
 
--
115632
 
 
115633
 
ALTER TABLE ONLY shipdata
115634
 
    ADD CONSTRAINT shipdata_shipdata_shiphead_number_fkey FOREIGN KEY (shipdata_shiphead_number) REFERENCES shiphead(shiphead_number);
115635
 
 
115636
 
 
115637
 
--
115638
 
--
115639
 
 
115640
 
ALTER TABLE ONLY shipdata
115641
 
    ADD CONSTRAINT shipdata_shipdata_total_freight_curr_id_fkey FOREIGN KEY (shipdata_total_freight_curr_id) REFERENCES curr_symbol(curr_id);
115642
 
 
115643
 
 
115644
 
--
115645
 
--
115646
 
 
115647
 
ALTER TABLE ONLY shipdatasum
115648
 
    ADD CONSTRAINT shipdatasum_shipdatasum_base_freight_curr_id_fkey FOREIGN KEY (shipdatasum_base_freight_curr_id) REFERENCES curr_symbol(curr_id);
115649
 
 
115650
 
 
115651
 
--
115652
 
--
115653
 
 
115654
 
ALTER TABLE ONLY shipdatasum
115655
 
    ADD CONSTRAINT shipdatasum_shipdatasum_shiphead_number_fkey FOREIGN KEY (shipdatasum_shiphead_number) REFERENCES shiphead(shiphead_number);
115656
 
 
115657
 
 
115658
 
--
115659
 
--
115660
 
 
115661
 
ALTER TABLE ONLY shipdatasum
115662
 
    ADD CONSTRAINT shipdatasum_shipdatasum_total_freight_curr_id_fkey FOREIGN KEY (shipdatasum_total_freight_curr_id) REFERENCES curr_symbol(curr_id);
115663
 
 
115664
 
 
115665
 
--
115666
 
--
115667
 
 
115668
 
ALTER TABLE ONLY shiphead
115669
 
    ADD CONSTRAINT shiphead_shiphead_freight_curr_id_fkey FOREIGN KEY (shiphead_freight_curr_id) REFERENCES curr_symbol(curr_id);
115670
 
 
115671
 
 
115672
 
--
115673
 
--
115674
 
 
115675
 
ALTER TABLE ONLY shiphead
115676
 
    ADD CONSTRAINT shiphead_shiphead_shipchrg_id_fkey FOREIGN KEY (shiphead_shipchrg_id) REFERENCES shipchrg(shipchrg_id);
115677
 
 
115678
 
 
115679
 
--
115680
 
--
115681
 
 
115682
 
ALTER TABLE ONLY shiphead
115683
 
    ADD CONSTRAINT shiphead_shiphead_shipform_id_fkey FOREIGN KEY (shiphead_shipform_id) REFERENCES shipform(shipform_id);
115684
 
 
115685
 
 
115686
 
--
115687
 
--
115688
 
 
115689
 
ALTER TABLE ONLY shipitem
115690
 
    ADD CONSTRAINT shipitem_shipitem_invcitem_id_fkey FOREIGN KEY (shipitem_invcitem_id) REFERENCES invcitem(invcitem_id);
115691
 
 
115692
 
 
115693
 
--
115694
 
--
115695
 
 
115696
 
ALTER TABLE ONLY shipitem
115697
 
    ADD CONSTRAINT shipitem_shipitem_invhist_id_fkey FOREIGN KEY (shipitem_invhist_id) REFERENCES invhist(invhist_id);
115698
 
 
115699
 
 
115700
 
--
115701
 
--
115702
 
 
115703
 
ALTER TABLE ONLY shipitem
115704
 
    ADD CONSTRAINT shipitem_shipitem_shiphead_id_fkey FOREIGN KEY (shipitem_shiphead_id) REFERENCES shiphead(shiphead_id);
115705
 
 
115706
 
 
115707
 
--
115708
 
--
115709
 
 
115710
 
ALTER TABLE ONLY shiptoinfo
115711
 
    ADD CONSTRAINT shiptoinfo_shipto_addr_id_fkey FOREIGN KEY (shipto_addr_id) REFERENCES addr(addr_id);
115712
 
 
115713
 
 
115714
 
--
115715
 
--
115716
 
 
115717
 
ALTER TABLE ONLY shiptoinfo
115718
 
    ADD CONSTRAINT shiptoinfo_shipto_cntct_id_fkey FOREIGN KEY (shipto_cntct_id) REFERENCES cntct(cntct_id);
115719
 
 
115720
 
 
115721
 
--
115722
 
--
115723
 
 
115724
 
ALTER TABLE ONLY shiptoinfo
115725
 
    ADD CONSTRAINT shiptoinfo_shipto_cust_id_fkey FOREIGN KEY (shipto_cust_id) REFERENCES custinfo(cust_id);
115726
 
 
115727
 
 
115728
 
--
115729
 
--
115730
 
 
115731
 
ALTER TABLE ONLY shiptoinfo
115732
 
    ADD CONSTRAINT shiptoinfo_shipto_salesrep_fkey FOREIGN KEY (shipto_salesrep_id) REFERENCES salesrep(salesrep_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
115733
 
 
115734
 
 
115735
 
--
115736
 
--
115737
 
 
115738
 
ALTER TABLE ONLY shiptoinfo
115739
 
    ADD CONSTRAINT shiptoinfo_shipto_salesrep_id_fkey FOREIGN KEY (shipto_salesrep_id) REFERENCES salesrep(salesrep_id);
115740
 
 
115741
 
 
115742
 
--
115743
 
--
115744
 
 
115745
 
ALTER TABLE ONLY shiptoinfo
115746
 
    ADD CONSTRAINT shiptoinfo_shipto_shipform_fkey FOREIGN KEY (shipto_shipform_id) REFERENCES shipform(shipform_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
115747
 
 
115748
 
 
115749
 
--
115750
 
--
115751
 
 
115752
 
ALTER TABLE ONLY shiptoinfo
115753
 
    ADD CONSTRAINT shiptoinfo_shipto_shipform_id_fkey FOREIGN KEY (shipto_shipform_id) REFERENCES shipform(shipform_id);
115754
 
 
115755
 
 
115756
 
--
115757
 
--
115758
 
 
115759
 
ALTER TABLE ONLY shiptoinfo
115760
 
    ADD CONSTRAINT shiptoinfo_shipto_shipzone_id_fkey FOREIGN KEY (shipto_shipzone_id) REFERENCES shipzone(shipzone_id);
115761
 
 
115762
 
 
115763
 
--
115764
 
--
115765
 
 
115766
 
ALTER TABLE ONLY shiptoinfo
115767
 
    ADD CONSTRAINT shiptoinfo_shipto_taxzone_id_fkey FOREIGN KEY (shipto_taxzone_id) REFERENCES taxzone(taxzone_id);
115768
 
 
115769
 
 
115770
 
--
115771
 
--
115772
 
 
115773
 
ALTER TABLE ONLY state
115774
 
    ADD CONSTRAINT state_state_country_id_fkey FOREIGN KEY (state_country_id) REFERENCES country(country_id);
115775
 
 
115776
 
 
115777
 
--
115778
 
--
115779
 
 
115780
 
ALTER TABLE ONLY tax
115781
 
    ADD CONSTRAINT tax_tax_basis_tax_id_fkey FOREIGN KEY (tax_basis_tax_id) REFERENCES tax(tax_id) ON DELETE CASCADE;
115782
 
 
115783
 
 
115784
 
--
115785
 
--
115786
 
 
115787
 
ALTER TABLE ONLY tax
115788
 
    ADD CONSTRAINT tax_tax_sales_accnt_id_fkey FOREIGN KEY (tax_sales_accnt_id) REFERENCES accnt(accnt_id);
115789
 
 
115790
 
 
115791
 
--
115792
 
--
115793
 
 
115794
 
ALTER TABLE ONLY tax
115795
 
    ADD CONSTRAINT tax_tax_taxauth_id_fkey FOREIGN KEY (tax_taxauth_id) REFERENCES taxauth(taxauth_id);
115796
 
 
115797
 
 
115798
 
--
115799
 
--
115800
 
 
115801
 
ALTER TABLE ONLY tax
115802
 
    ADD CONSTRAINT tax_tax_taxclass_id_fkey FOREIGN KEY (tax_taxclass_id) REFERENCES taxclass(taxclass_id);
115803
 
 
115804
 
 
115805
 
--
115806
 
--
115807
 
 
115808
 
ALTER TABLE ONLY taxass
115809
 
    ADD CONSTRAINT taxass_taxass_tax_id_fkey FOREIGN KEY (taxass_tax_id) REFERENCES tax(tax_id);
115810
 
 
115811
 
 
115812
 
--
115813
 
--
115814
 
 
115815
 
ALTER TABLE ONLY taxass
115816
 
    ADD CONSTRAINT taxass_taxass_taxtype_id_fkey FOREIGN KEY (taxass_taxtype_id) REFERENCES taxtype(taxtype_id);
115817
 
 
115818
 
 
115819
 
--
115820
 
--
115821
 
 
115822
 
ALTER TABLE ONLY taxass
115823
 
    ADD CONSTRAINT taxass_taxass_taxzone_id_fkey FOREIGN KEY (taxass_taxzone_id) REFERENCES taxzone(taxzone_id);
115824
 
 
115825
 
 
115826
 
--
115827
 
--
115828
 
 
115829
 
ALTER TABLE ONLY taxauth
115830
 
    ADD CONSTRAINT taxauth_taxauth_accnt_id_fkey FOREIGN KEY (taxauth_accnt_id) REFERENCES accnt(accnt_id);
115831
 
 
115832
 
 
115833
 
--
115834
 
--
115835
 
 
115836
 
ALTER TABLE ONLY taxauth
115837
 
    ADD CONSTRAINT taxauth_taxauth_addr_id_fkey FOREIGN KEY (taxauth_addr_id) REFERENCES addr(addr_id);
115838
 
 
115839
 
 
115840
 
--
115841
 
--
115842
 
 
115843
 
ALTER TABLE ONLY taxauth
115844
 
    ADD CONSTRAINT taxauth_taxauth_curr_id_fkey FOREIGN KEY (taxauth_curr_id) REFERENCES curr_symbol(curr_id);
115845
 
 
115846
 
 
115847
 
--
115848
 
--
115849
 
 
115850
 
ALTER TABLE ONLY taxhist
115851
 
    ADD CONSTRAINT taxhist_taxhist_curr_id_fkey FOREIGN KEY (taxhist_curr_id) REFERENCES curr_symbol(curr_id);
115852
 
 
115853
 
 
115854
 
--
115855
 
--
115856
 
 
115857
 
ALTER TABLE ONLY taxhist
115858
 
    ADD CONSTRAINT taxhist_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id);
115859
 
 
115860
 
 
115861
 
--
115862
 
--
115863
 
 
115864
 
ALTER TABLE ONLY taxhist
115865
 
    ADD CONSTRAINT taxhist_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id);
115866
 
 
115867
 
 
115868
 
--
115869
 
--
115870
 
 
115871
 
ALTER TABLE ONLY taxrate
115872
 
    ADD CONSTRAINT taxrate_taxrate_curr_id_fkey FOREIGN KEY (taxrate_curr_id) REFERENCES curr_symbol(curr_id);
115873
 
 
115874
 
 
115875
 
--
115876
 
--
115877
 
 
115878
 
ALTER TABLE ONLY taxrate
115879
 
    ADD CONSTRAINT taxrate_taxrate_tax_id_fkey FOREIGN KEY (taxrate_tax_id) REFERENCES tax(tax_id);
115880
 
 
115881
 
 
115882
 
--
115883
 
--
115884
 
 
115885
 
ALTER TABLE ONLY taxreg
115886
 
    ADD CONSTRAINT taxreg_taxreg_taxauth_id_fkey FOREIGN KEY (taxreg_taxauth_id) REFERENCES taxauth(taxauth_id);
115887
 
 
115888
 
 
115889
 
--
115890
 
--
115891
 
 
115892
 
ALTER TABLE ONLY taxreg
115893
 
    ADD CONSTRAINT taxreg_taxreg_taxzone_id_fkey FOREIGN KEY (taxreg_taxzone_id) REFERENCES taxzone(taxzone_id);
115894
 
 
115895
 
 
115896
 
--
115897
 
--
115898
 
 
115899
 
ALTER TABLE ONLY todoitem
115900
 
    ADD CONSTRAINT todoitem_todoitem_cntct_id_fkey FOREIGN KEY (todoitem_cntct_id) REFERENCES cntct(cntct_id);
115901
 
 
115902
 
 
115903
 
--
115904
 
--
115905
 
 
115906
 
ALTER TABLE ONLY todoitem
115907
 
    ADD CONSTRAINT todoitem_todoitem_crmacct_id_fkey FOREIGN KEY (todoitem_crmacct_id) REFERENCES crmacct(crmacct_id);
115908
 
 
115909
 
 
115910
 
--
115911
 
--
115912
 
 
115913
 
ALTER TABLE ONLY todoitem
115914
 
    ADD CONSTRAINT todoitem_todoitem_incdt_id_fkey FOREIGN KEY (todoitem_incdt_id) REFERENCES incdt(incdt_id);
115915
 
 
115916
 
 
115917
 
--
115918
 
--
115919
 
 
115920
 
ALTER TABLE ONLY todoitem
115921
 
    ADD CONSTRAINT todoitem_todoitem_ophead_id_fkey FOREIGN KEY (todoitem_ophead_id) REFERENCES ophead(ophead_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
115922
 
 
115923
 
 
115924
 
--
115925
 
--
115926
 
 
115927
 
ALTER TABLE ONLY todoitem
115928
 
    ADD CONSTRAINT todoitem_todoitem_recurring_todoitem_id_fkey FOREIGN KEY (todoitem_recurring_todoitem_id) REFERENCES todoitem(todoitem_id);
115929
 
 
115930
 
 
115931
 
--
115932
 
--
115933
 
 
115934
 
ALTER TABLE ONLY trgthist
115935
 
    ADD CONSTRAINT trgthist_trgthist_src_cntct_id_fkey FOREIGN KEY (trgthist_src_cntct_id) REFERENCES cntctmrgd(cntctmrgd_cntct_id) ON DELETE CASCADE;
115936
 
 
115937
 
 
115938
 
--
115939
 
--
115940
 
 
115941
 
ALTER TABLE ONLY trgthist
115942
 
    ADD CONSTRAINT trgthist_trgthist_trgt_cntct_id_fkey FOREIGN KEY (trgthist_trgt_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE;
115943
 
 
115944
 
 
115945
 
--
115946
 
--
115947
 
 
115948
 
ALTER TABLE ONLY uomconv
115949
 
    ADD CONSTRAINT uomconv_uomconv_from_uom_id_fkey FOREIGN KEY (uomconv_from_uom_id) REFERENCES uom(uom_id);
115950
 
 
115951
 
 
115952
 
--
115953
 
--
115954
 
 
115955
 
ALTER TABLE ONLY uomconv
115956
 
    ADD CONSTRAINT uomconv_uomconv_to_uom_id_fkey FOREIGN KEY (uomconv_to_uom_id) REFERENCES uom(uom_id);
115957
 
 
115958
 
 
115959
 
--
115960
 
--
115961
 
 
115962
 
ALTER TABLE ONLY usrgrp
115963
 
    ADD CONSTRAINT usrgrp_usrgrp_grp_id_fkey FOREIGN KEY (usrgrp_grp_id) REFERENCES grp(grp_id);
115964
 
 
115965
 
 
115966
 
--
115967
 
--
115968
 
 
115969
 
ALTER TABLE ONLY vendinfo
115970
 
    ADD CONSTRAINT vend_to_curr_symbol FOREIGN KEY (vend_curr_id) REFERENCES curr_symbol(curr_id);
115971
 
 
115972
 
 
115973
 
--
115974
 
--
115975
 
 
115976
 
ALTER TABLE ONLY vendinfo
115977
 
    ADD CONSTRAINT vend_vend_cntct1_id_fkey FOREIGN KEY (vend_cntct1_id) REFERENCES cntct(cntct_id);
115978
 
 
115979
 
 
115980
 
--
115981
 
--
115982
 
 
115983
 
ALTER TABLE ONLY vendinfo
115984
 
    ADD CONSTRAINT vend_vend_cntct2_id_fkey FOREIGN KEY (vend_cntct2_id) REFERENCES cntct(cntct_id);
115985
 
 
115986
 
 
115987
 
--
115988
 
--
115989
 
 
115990
 
ALTER TABLE ONLY vendaddrinfo
115991
 
    ADD CONSTRAINT vendaddrinfo_vendaddr_addr_id_fkey FOREIGN KEY (vendaddr_addr_id) REFERENCES addr(addr_id);
115992
 
 
115993
 
 
115994
 
--
115995
 
--
115996
 
 
115997
 
ALTER TABLE ONLY vendaddrinfo
115998
 
    ADD CONSTRAINT vendaddrinfo_vendaddr_cntct_id_fkey FOREIGN KEY (vendaddr_cntct_id) REFERENCES cntct(cntct_id);
115999
 
 
116000
 
 
116001
 
--
116002
 
--
116003
 
 
116004
 
ALTER TABLE ONLY vendaddrinfo
116005
 
    ADD CONSTRAINT vendaddrinfo_vendaddr_taxzone_id_fkey FOREIGN KEY (vendaddr_taxzone_id) REFERENCES taxzone(taxzone_id);
116006
 
 
116007
 
 
116008
 
--
116009
 
--
116010
 
 
116011
 
ALTER TABLE ONLY vendinfo
116012
 
    ADD CONSTRAINT vendinfo_vend_addr_id_fkey FOREIGN KEY (vend_addr_id) REFERENCES addr(addr_id);
116013
 
 
116014
 
 
116015
 
--
116016
 
--
116017
 
 
116018
 
ALTER TABLE ONLY vendinfo
116019
 
    ADD CONSTRAINT vendinfo_vend_taxzone_id_fkey FOREIGN KEY (vend_taxzone_id) REFERENCES taxzone(taxzone_id);
116020
 
 
116021
 
 
116022
 
--
116023
 
--
116024
 
 
116025
 
ALTER TABLE ONLY vendinfo
116026
 
    ADD CONSTRAINT vendinfo_vend_vendtype_id_fkey FOREIGN KEY (vend_vendtype_id) REFERENCES vendtype(vendtype_id);
116027
 
 
116028
 
 
116029
 
--
116030
 
--
116031
 
 
116032
 
ALTER TABLE ONLY vohead
116033
 
    ADD CONSTRAINT vohead_to_curr_symbol FOREIGN KEY (vohead_curr_id) REFERENCES curr_symbol(curr_id);
116034
 
 
116035
 
 
116036
 
--
116037
 
--
116038
 
 
116039
 
ALTER TABLE ONLY vohead
116040
 
    ADD CONSTRAINT vohead_vohead_adjtaxtype_id_fkey FOREIGN KEY (vohead_adjtaxtype_id) REFERENCES taxtype(taxtype_id);
116041
 
 
116042
 
 
116043
 
--
116044
 
--
116045
 
 
116046
 
ALTER TABLE ONLY vohead
116047
 
    ADD CONSTRAINT vohead_vohead_freighttaxtype_id_fkey FOREIGN KEY (vohead_freighttaxtype_id) REFERENCES taxtype(taxtype_id);
116048
 
 
116049
 
 
116050
 
--
116051
 
--
116052
 
 
116053
 
ALTER TABLE ONLY vohead
116054
 
    ADD CONSTRAINT vohead_vohead_taxtype_id_fkey FOREIGN KEY (vohead_taxtype_id) REFERENCES taxtype(taxtype_id);
116055
 
 
116056
 
 
116057
 
--
116058
 
--
116059
 
 
116060
 
ALTER TABLE ONLY vohead
116061
 
    ADD CONSTRAINT vohead_vohead_taxzone_id_fkey FOREIGN KEY (vohead_taxzone_id) REFERENCES taxzone(taxzone_id);
116062
 
 
116063
 
 
116064
 
--
116065
 
--
116066
 
 
116067
 
ALTER TABLE ONLY vohead
116068
 
    ADD CONSTRAINT vohead_vohead_vend_id_fkey FOREIGN KEY (vohead_vend_id) REFERENCES vendinfo(vend_id);
116069
 
 
116070
 
 
116071
 
--
116072
 
--
116073
 
 
116074
 
ALTER TABLE ONLY voheadtax
116075
 
    ADD CONSTRAINT voheadtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id);
116076
 
 
116077
 
 
116078
 
--
116079
 
--
116080
 
 
116081
 
ALTER TABLE ONLY voheadtax
116082
 
    ADD CONSTRAINT voheadtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES vohead(vohead_id) ON DELETE CASCADE;
116083
 
 
116084
 
 
116085
 
--
116086
 
--
116087
 
 
116088
 
ALTER TABLE ONLY voheadtax
116089
 
    ADD CONSTRAINT voheadtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id);
116090
 
 
116091
 
 
116092
 
--
116093
 
--
116094
 
 
116095
 
ALTER TABLE ONLY voheadtax
116096
 
    ADD CONSTRAINT voheadtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id);
116097
 
 
116098
 
 
116099
 
--
116100
 
--
116101
 
 
116102
 
ALTER TABLE ONLY voitem
116103
 
    ADD CONSTRAINT voitem_voitem_taxtype_id_fkey FOREIGN KEY (voitem_taxtype_id) REFERENCES taxtype(taxtype_id);
116104
 
 
116105
 
 
116106
 
--
116107
 
--
116108
 
 
116109
 
ALTER TABLE ONLY voitemtax
116110
 
    ADD CONSTRAINT voitemtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id);
116111
 
 
116112
 
 
116113
 
--
116114
 
--
116115
 
 
116116
 
ALTER TABLE ONLY voitemtax
116117
 
    ADD CONSTRAINT voitemtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES voitem(voitem_id) ON DELETE CASCADE;
116118
 
 
116119
 
 
116120
 
--
116121
 
--
116122
 
 
116123
 
ALTER TABLE ONLY voitemtax
116124
 
    ADD CONSTRAINT voitemtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id);
116125
 
 
116126
 
 
116127
 
--
116128
 
--
116129
 
 
116130
 
ALTER TABLE ONLY voitemtax
116131
 
    ADD CONSTRAINT voitemtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id);
116132
 
 
116133
 
 
116134
 
--
116135
 
--
116136
 
 
116137
 
ALTER TABLE ONLY whsinfo
116138
 
    ADD CONSTRAINT whsinfo_warehous_accnt_id_fkey FOREIGN KEY (warehous_default_accnt_id) REFERENCES accnt(accnt_id);
116139
 
 
116140
 
 
116141
 
--
116142
 
--
116143
 
 
116144
 
ALTER TABLE ONLY whsinfo
116145
 
    ADD CONSTRAINT whsinfo_warehous_addr_id_fkey FOREIGN KEY (warehous_addr_id) REFERENCES addr(addr_id);
116146
 
 
116147
 
 
116148
 
--
116149
 
--
116150
 
 
116151
 
ALTER TABLE ONLY whsinfo
116152
 
    ADD CONSTRAINT whsinfo_warehous_cntct_id_fkey FOREIGN KEY (warehous_cntct_id) REFERENCES cntct(cntct_id);
116153
 
 
116154
 
 
116155
 
--
116156
 
--
116157
 
 
116158
 
ALTER TABLE ONLY whsinfo
116159
 
    ADD CONSTRAINT whsinfo_warehous_costcat_id_fkey FOREIGN KEY (warehous_costcat_id) REFERENCES costcat(costcat_id);
116160
 
 
116161
 
 
116162
 
--
116163
 
--
116164
 
 
116165
 
ALTER TABLE ONLY whsinfo
116166
 
    ADD CONSTRAINT whsinfo_warehous_shipform_id_fkey FOREIGN KEY (warehous_shipform_id) REFERENCES shipform(shipform_id);
116167
 
 
116168
 
 
116169
 
--
116170
 
--
116171
 
 
116172
 
ALTER TABLE ONLY whsinfo
116173
 
    ADD CONSTRAINT whsinfo_warehous_shipvia_id_fkey FOREIGN KEY (warehous_shipvia_id) REFERENCES shipvia(shipvia_id);
116174
 
 
116175
 
 
116176
 
--
116177
 
--
116178
 
 
116179
 
ALTER TABLE ONLY whsinfo
116180
 
    ADD CONSTRAINT whsinfo_warehous_sitetype_id_fkey FOREIGN KEY (warehous_sitetype_id) REFERENCES sitetype(sitetype_id);
116181
 
 
116182
 
 
116183
 
--
116184
 
--
116185
 
 
116186
 
ALTER TABLE ONLY whsinfo
116187
 
    ADD CONSTRAINT whsinfo_warehous_taxzone_id_fkey FOREIGN KEY (warehous_taxzone_id) REFERENCES taxzone(taxzone_id);
116188
 
 
116189
 
 
116190
 
--
116191
 
--
116192
 
 
116193
 
ALTER TABLE ONLY wo
116194
 
    ADD CONSTRAINT wo_wo_womatl_id_fkey FOREIGN KEY (wo_womatl_id) REFERENCES womatl(womatl_id) ON DELETE SET NULL;
116195
 
 
116196
 
 
116197
 
--
116198
 
--
116199
 
 
116200
 
ALTER TABLE ONLY womatl
116201
 
    ADD CONSTRAINT womatl_womatl_uom_id_fkey FOREIGN KEY (womatl_uom_id) REFERENCES uom(uom_id);
116202
 
 
116203
 
 
116204
 
--
116205
 
--
116206
 
 
116207
 
ALTER TABLE ONLY womatlpost
116208
 
    ADD CONSTRAINT womatlpost_womatlpost_invhist_id_fkey FOREIGN KEY (womatlpost_invhist_id) REFERENCES invhist(invhist_id);
116209
 
 
116210
 
 
116211
 
--
116212
 
--
116213
 
 
116214
 
ALTER TABLE ONLY womatlpost
116215
 
    ADD CONSTRAINT womatlpost_womatlpost_womatl_id_fkey FOREIGN KEY (womatlpost_womatl_id) REFERENCES womatl(womatl_id) ON DELETE CASCADE;
116216
 
 
116217
 
 
116218
 
SET search_path = te, pg_catalog;
116219
 
 
116220
 
--
116221
 
--
116222
 
 
116223
 
ALTER TABLE ONLY pkgcmdarg
116224
 
    ADD CONSTRAINT pkgcmdarg_cmdarg_cmd_id_fkey FOREIGN KEY (cmdarg_cmd_id) REFERENCES pkgcmd(cmd_id);
116225
 
 
116226
 
 
116227
 
--
116228
 
--
116229
 
 
116230
 
ALTER TABLE ONLY tecustrate
116231
 
    ADD CONSTRAINT tecustrate_tecustrate_curr_id_fkey FOREIGN KEY (tecustrate_curr_id) REFERENCES public.curr_symbol(curr_id) ON DELETE SET DEFAULT;
116232
 
 
116233
 
 
116234
 
--
116235
 
--
116236
 
 
116237
 
ALTER TABLE ONLY tecustrate
116238
 
    ADD CONSTRAINT tecustrate_tecustrate_cust_id_fkey FOREIGN KEY (tecustrate_cust_id) REFERENCES public.custinfo(cust_id) ON DELETE CASCADE;
116239
 
 
116240
 
 
116241
 
--
116242
 
--
116243
 
 
116244
 
ALTER TABLE ONLY teemp
116245
 
    ADD CONSTRAINT teemp_teemp_emp_id_fkey FOREIGN KEY (teemp_emp_id) REFERENCES public.emp(emp_id) ON DELETE CASCADE;
116246
 
 
116247
 
 
116248
 
--
116249
 
--
116250
 
 
116251
 
ALTER TABLE ONLY teitem
116252
 
    ADD CONSTRAINT teitem_teitem_curr_id_fkey FOREIGN KEY (teitem_curr_id) REFERENCES public.curr_symbol(curr_id) ON DELETE SET DEFAULT;
116253
 
 
116254
 
 
116255
 
--
116256
 
--
116257
 
 
116258
 
ALTER TABLE ONLY teitem
116259
 
    ADD CONSTRAINT teitem_teitem_invcitem_id_fkey FOREIGN KEY (teitem_invcitem_id) REFERENCES public.invcitem(invcitem_id) ON DELETE SET NULL;
116260
 
 
116261
 
 
116262
 
--
116263
 
--
116264
 
 
116265
 
ALTER TABLE ONLY teitem
116266
 
    ADD CONSTRAINT teitem_teitem_tehead_id_fkey FOREIGN KEY (teitem_tehead_id) REFERENCES tehead(tehead_id) ON DELETE CASCADE;
116267
 
 
116268
 
 
116269
 
--
116270
 
--
116271
 
 
116272
 
ALTER TABLE ONLY teitem
116273
 
    ADD CONSTRAINT teitem_teitem_vodist_id_fkey FOREIGN KEY (teitem_vodist_id) REFERENCES public.vodist(vodist_id) ON DELETE SET NULL;
116274
 
 
116275
 
 
116276
 
--
116277
 
--
116278
 
 
116279
 
ALTER TABLE ONLY teprj
116280
 
    ADD CONSTRAINT teprj_teprj_curr_id_fkey FOREIGN KEY (teprj_curr_id) REFERENCES public.curr_symbol(curr_id) ON DELETE SET NULL;
116281
 
 
116282
 
 
116283
 
--
116284
 
--
116285
 
 
116286
 
ALTER TABLE ONLY teprj
116287
 
    ADD CONSTRAINT teprj_teprj_cust_id_fkey FOREIGN KEY (teprj_cust_id) REFERENCES public.custinfo(cust_id) ON DELETE SET NULL;
116288
 
 
116289
 
 
116290
 
--
116291
 
--
116292
 
 
116293
 
ALTER TABLE ONLY teprjtask
116294
 
    ADD CONSTRAINT teprjtask_teprjtask_curr_id_fkey FOREIGN KEY (teprjtask_curr_id) REFERENCES public.curr_symbol(curr_id) ON DELETE SET DEFAULT;
116295
 
 
116296
 
 
116297
 
--
116298
 
--
116299
 
 
116300
 
ALTER TABLE ONLY teprjtask
116301
 
    ADD CONSTRAINT teprjtask_teprjtask_item_id_fkey FOREIGN KEY (teprjtask_item_id) REFERENCES public.item(item_id) ON DELETE SET NULL;
116302
 
 
116303
 
 
116304
 
--
116305
 
--
116306
 
 
116307
 
ALTER TABLE ONLY teprjtask
116308
 
    ADD CONSTRAINT teprjtask_teprjtask_prjtask_id_fkey FOREIGN KEY (teprjtask_prjtask_id) REFERENCES public.prjtask(prjtask_id) ON DELETE CASCADE;
116309
 
 
116310
 
 
116311
 
SET search_path = xtdesktop, pg_catalog;
116312
 
 
116313
 
--
116314
 
--
116315
 
 
116316
 
ALTER TABLE ONLY pkgcmdarg
116317
 
    ADD CONSTRAINT pkgcmdarg_cmdarg_cmd_id_fkey FOREIGN KEY (cmdarg_cmd_id) REFERENCES pkgcmd(cmd_id);
116318
 
 
116319
 
 
116320
 
--
116321
 
--
116322
 
 
116323
 
REVOKE ALL ON SCHEMA api FROM PUBLIC;
116324
 
REVOKE ALL ON SCHEMA api FROM admin;
116325
 
GRANT ALL ON SCHEMA api TO admin;
116326
 
GRANT ALL ON SCHEMA api TO xtrole;
116327
 
 
116328
 
 
116329
 
--
116330
 
--
116331
 
 
116332
 
REVOKE ALL ON SCHEMA fixcountry FROM PUBLIC;
116333
 
REVOKE ALL ON SCHEMA fixcountry FROM admin;
116334
 
GRANT ALL ON SCHEMA fixcountry TO admin;
116335
 
GRANT ALL ON SCHEMA fixcountry TO xtrole;
116336
 
 
116337
 
 
116338
 
--
116339
 
--
116340
 
 
116341
 
REVOKE ALL ON SCHEMA public FROM PUBLIC;
116342
 
REVOKE ALL ON SCHEMA public FROM postgres;
116343
 
GRANT ALL ON SCHEMA public TO postgres;
116344
 
GRANT ALL ON SCHEMA public TO PUBLIC;
116345
 
 
116346
 
 
116347
 
--
116348
 
--
116349
 
 
116350
 
REVOKE ALL ON SCHEMA te FROM PUBLIC;
116351
 
REVOKE ALL ON SCHEMA te FROM admin;
116352
 
GRANT ALL ON SCHEMA te TO admin;
116353
 
GRANT ALL ON SCHEMA te TO xtrole;
116354
 
 
116355
 
 
116356
 
--
116357
 
--
116358
 
 
116359
 
REVOKE ALL ON SCHEMA xt FROM PUBLIC;
116360
 
REVOKE ALL ON SCHEMA xt FROM admin;
116361
 
GRANT ALL ON SCHEMA xt TO admin;
116362
 
GRANT ALL ON SCHEMA xt TO xtrole;
116363
 
 
116364
 
 
116365
 
--
116366
 
--
116367
 
 
116368
 
REVOKE ALL ON SCHEMA xtdesktop FROM PUBLIC;
116369
 
REVOKE ALL ON SCHEMA xtdesktop FROM admin;
116370
 
GRANT ALL ON SCHEMA xtdesktop TO admin;
116371
 
GRANT ALL ON SCHEMA xtdesktop TO xtrole;
116372
 
 
116373
 
 
116374
 
SET search_path = public, pg_catalog;
116375
 
 
116376
 
--
116377
 
--
116378
 
 
116379
 
REVOKE ALL ON TABLE cntslip FROM PUBLIC;
116380
 
REVOKE ALL ON TABLE cntslip FROM admin;
116381
 
GRANT ALL ON TABLE cntslip TO admin;
116382
 
GRANT ALL ON TABLE cntslip TO xtrole;
116383
 
 
116384
 
 
116385
 
--
116386
 
--
116387
 
 
116388
 
REVOKE ALL ON TABLE invcnt FROM PUBLIC;
116389
 
REVOKE ALL ON TABLE invcnt FROM admin;
116390
 
GRANT ALL ON TABLE invcnt TO admin;
116391
 
GRANT ALL ON TABLE invcnt TO xtrole;
116392
 
 
116393
 
 
116394
 
--
116395
 
--
116396
 
 
116397
 
REVOKE ALL ON TABLE item FROM PUBLIC;
116398
 
REVOKE ALL ON TABLE item FROM admin;
116399
 
GRANT ALL ON TABLE item TO admin;
116400
 
GRANT ALL ON TABLE item TO xtrole;
116401
 
 
116402
 
 
116403
 
--
116404
 
--
116405
 
 
116406
 
REVOKE ALL ON TABLE itemsite FROM PUBLIC;
116407
 
REVOKE ALL ON TABLE itemsite FROM admin;
116408
 
GRANT ALL ON TABLE itemsite TO admin;
116409
 
GRANT ALL ON TABLE itemsite TO xtrole;
116410
 
 
116411
 
 
116412
 
--
116413
 
--
116414
 
 
116415
 
REVOKE ALL ON TABLE whsinfo FROM PUBLIC;
116416
 
REVOKE ALL ON TABLE whsinfo FROM admin;
116417
 
GRANT ALL ON TABLE whsinfo TO admin;
116418
 
GRANT ALL ON TABLE whsinfo TO xtrole;
116419
 
 
116420
 
 
116421
 
SET search_path = api, pg_catalog;
116422
 
 
116423
 
--
116424
 
--
116425
 
 
116426
 
REVOKE ALL ON TABLE physinvcount FROM PUBLIC;
116427
 
REVOKE ALL ON TABLE physinvcount FROM admin;
116428
 
GRANT ALL ON TABLE physinvcount TO admin;
116429
 
GRANT ALL ON TABLE physinvcount TO xtrole;
116430
 
 
116431
 
 
116432
 
SET search_path = public, pg_catalog;
116433
 
 
116434
 
--
116435
 
--
116436
 
 
116437
 
REVOKE ALL ON TABLE cohead FROM PUBLIC;
116438
 
REVOKE ALL ON TABLE cohead FROM admin;
116439
 
GRANT ALL ON TABLE cohead TO admin;
116440
 
GRANT ALL ON TABLE cohead TO xtrole;
116441
 
 
116442
 
 
116443
 
--
116444
 
--
116445
 
 
116446
 
REVOKE ALL ON TABLE coitem FROM PUBLIC;
116447
 
REVOKE ALL ON TABLE coitem FROM admin;
116448
 
GRANT ALL ON TABLE coitem TO admin;
116449
 
GRANT ALL ON TABLE coitem TO xtrole;
116450
 
 
116451
 
 
116452
 
--
116453
 
--
116454
 
 
116455
 
REVOKE ALL ON TABLE pohead FROM PUBLIC;
116456
 
REVOKE ALL ON TABLE pohead FROM admin;
116457
 
GRANT ALL ON TABLE pohead TO admin;
116458
 
GRANT ALL ON TABLE pohead TO xtrole;
116459
 
 
116460
 
 
116461
 
--
116462
 
--
116463
 
 
116464
 
REVOKE ALL ON TABLE poitem FROM PUBLIC;
116465
 
REVOKE ALL ON TABLE poitem FROM admin;
116466
 
GRANT ALL ON TABLE poitem TO admin;
116467
 
GRANT ALL ON TABLE poitem TO xtrole;
116468
 
 
116469
 
 
116470
 
--
116471
 
--
116472
 
 
116473
 
REVOKE ALL ON TABLE taxtype FROM PUBLIC;
116474
 
REVOKE ALL ON TABLE taxtype FROM admin;
116475
 
GRANT ALL ON TABLE taxtype TO admin;
116476
 
GRANT ALL ON TABLE taxtype TO xtrole;
116477
 
 
116478
 
 
116479
 
--
116480
 
--
116481
 
 
116482
 
REVOKE ALL ON TABLE uom FROM PUBLIC;
116483
 
REVOKE ALL ON TABLE uom FROM admin;
116484
 
GRANT ALL ON TABLE uom TO admin;
116485
 
GRANT ALL ON TABLE uom TO xtrole;
116486
 
 
116487
 
 
116488
 
SET search_path = api, pg_catalog;
116489
 
 
116490
 
--
116491
 
--
116492
 
 
116493
 
REVOKE ALL ON TABLE salesline FROM PUBLIC;
116494
 
REVOKE ALL ON TABLE salesline FROM admin;
116495
 
GRANT ALL ON TABLE salesline TO admin;
116496
 
GRANT ALL ON TABLE salesline TO xtrole;
116497
 
 
116498
 
 
116499
 
SET search_path = public, pg_catalog;
116500
 
 
116501
 
--
116502
 
--
116503
 
 
116504
 
REVOKE ALL ON TABLE invbal FROM PUBLIC;
116505
 
REVOKE ALL ON TABLE invbal FROM admin;
116506
 
GRANT ALL ON TABLE invbal TO admin;
116507
 
GRANT ALL ON TABLE invbal TO xtrole;
116508
 
 
116509
 
 
116510
 
--
116511
 
--
116512
 
 
116513
 
REVOKE ALL ON TABLE bomitem FROM PUBLIC;
116514
 
REVOKE ALL ON TABLE bomitem FROM admin;
116515
 
GRANT ALL ON TABLE bomitem TO admin;
116516
 
GRANT ALL ON TABLE bomitem TO xtrole;
116517
 
 
116518
 
 
116519
 
--
116520
 
--
116521
 
 
116522
 
REVOKE ALL ON TABLE cntct FROM PUBLIC;
116523
 
REVOKE ALL ON TABLE cntct FROM admin;
116524
 
GRANT ALL ON TABLE cntct TO admin;
116525
 
GRANT ALL ON TABLE cntct TO xtrole;
116526
 
 
116527
 
 
116528
 
--
116529
 
--
116530
 
 
116531
 
REVOKE ALL ON TABLE crmacct FROM PUBLIC;
116532
 
REVOKE ALL ON TABLE crmacct FROM admin;
116533
 
GRANT ALL ON TABLE crmacct TO admin;
116534
 
GRANT ALL ON TABLE crmacct TO xtrole;
116535
 
 
116536
 
 
116537
 
--
116538
 
--
116539
 
 
116540
 
REVOKE ALL ON TABLE incdt FROM PUBLIC;
116541
 
REVOKE ALL ON TABLE incdt FROM admin;
116542
 
GRANT ALL ON TABLE incdt TO admin;
116543
 
GRANT ALL ON TABLE incdt TO xtrole;
116544
 
 
116545
 
 
116546
 
--
116547
 
--
116548
 
 
116549
 
REVOKE ALL ON TABLE apopen FROM PUBLIC;
116550
 
REVOKE ALL ON TABLE apopen FROM admin;
116551
 
GRANT ALL ON TABLE apopen TO admin;
116552
 
GRANT ALL ON TABLE apopen TO xtrole;
116553
 
 
116554
 
 
116555
 
--
116556
 
--
116557
 
 
116558
 
REVOKE ALL ON TABLE curr_symbol FROM PUBLIC;
116559
 
REVOKE ALL ON TABLE curr_symbol FROM admin;
116560
 
GRANT ALL ON TABLE curr_symbol TO admin;
116561
 
GRANT ALL ON TABLE curr_symbol TO xtrole;
116562
 
 
116563
 
 
116564
 
--
116565
 
--
116566
 
 
116567
 
REVOKE ALL ON TABLE terms FROM PUBLIC;
116568
 
REVOKE ALL ON TABLE terms FROM admin;
116569
 
GRANT ALL ON TABLE terms TO admin;
116570
 
GRANT ALL ON TABLE terms TO xtrole;
116571
 
 
116572
 
 
116573
 
--
116574
 
--
116575
 
 
116576
 
REVOKE ALL ON TABLE vendinfo FROM PUBLIC;
116577
 
REVOKE ALL ON TABLE vendinfo FROM admin;
116578
 
GRANT ALL ON TABLE vendinfo TO admin;
116579
 
GRANT ALL ON TABLE vendinfo TO xtrole;
116580
 
 
116581
 
 
116582
 
SET search_path = api, pg_catalog;
116583
 
 
116584
 
--
116585
 
--
116586
 
 
116587
 
REVOKE ALL ON TABLE apmemo FROM PUBLIC;
116588
 
REVOKE ALL ON TABLE apmemo FROM admin;
116589
 
GRANT ALL ON TABLE apmemo TO admin;
116590
 
GRANT ALL ON TABLE apmemo TO xtrole;
116591
 
 
116592
 
 
116593
 
SET search_path = public, pg_catalog;
116594
 
 
116595
 
--
116596
 
--
116597
 
 
116598
 
REVOKE ALL ON TABLE aropen FROM PUBLIC;
116599
 
REVOKE ALL ON TABLE aropen FROM admin;
116600
 
GRANT ALL ON TABLE aropen TO admin;
116601
 
GRANT ALL ON TABLE aropen TO xtrole;
116602
 
 
116603
 
 
116604
 
--
116605
 
--
116606
 
 
116607
 
REVOKE ALL ON TABLE custinfo FROM PUBLIC;
116608
 
REVOKE ALL ON TABLE custinfo FROM admin;
116609
 
GRANT ALL ON TABLE custinfo TO admin;
116610
 
GRANT ALL ON TABLE custinfo TO xtrole;
116611
 
 
116612
 
 
116613
 
--
116614
 
--
116615
 
 
116616
 
REVOKE ALL ON TABLE rsncode FROM PUBLIC;
116617
 
REVOKE ALL ON TABLE rsncode FROM admin;
116618
 
GRANT ALL ON TABLE rsncode TO admin;
116619
 
GRANT ALL ON TABLE rsncode TO xtrole;
116620
 
 
116621
 
 
116622
 
--
116623
 
--
116624
 
 
116625
 
REVOKE ALL ON TABLE salescat FROM PUBLIC;
116626
 
REVOKE ALL ON TABLE salescat FROM admin;
116627
 
GRANT ALL ON TABLE salescat TO admin;
116628
 
GRANT ALL ON TABLE salescat TO xtrole;
116629
 
 
116630
 
 
116631
 
--
116632
 
--
116633
 
 
116634
 
REVOKE ALL ON TABLE salesrep FROM PUBLIC;
116635
 
REVOKE ALL ON TABLE salesrep FROM admin;
116636
 
GRANT ALL ON TABLE salesrep TO admin;
116637
 
GRANT ALL ON TABLE salesrep TO xtrole;
116638
 
 
116639
 
 
116640
 
SET search_path = api, pg_catalog;
116641
 
 
116642
 
--
116643
 
--
116644
 
 
116645
 
REVOKE ALL ON TABLE armemo FROM PUBLIC;
116646
 
REVOKE ALL ON TABLE armemo FROM admin;
116647
 
GRANT ALL ON TABLE armemo TO admin;
116648
 
GRANT ALL ON TABLE armemo TO xtrole;
116649
 
 
116650
 
 
116651
 
SET search_path = public, pg_catalog;
116652
 
 
116653
 
--
116654
 
--
116655
 
 
116656
 
REVOKE ALL ON TABLE cmhead FROM PUBLIC;
116657
 
REVOKE ALL ON TABLE cmhead FROM admin;
116658
 
GRANT ALL ON TABLE cmhead TO admin;
116659
 
GRANT ALL ON TABLE cmhead TO xtrole;
116660
 
 
116661
 
 
116662
 
--
116663
 
--
116664
 
 
116665
 
REVOKE ALL ON TABLE shiptoinfo FROM PUBLIC;
116666
 
REVOKE ALL ON TABLE shiptoinfo FROM admin;
116667
 
GRANT ALL ON TABLE shiptoinfo TO admin;
116668
 
GRANT ALL ON TABLE shiptoinfo TO xtrole;
116669
 
 
116670
 
 
116671
 
--
116672
 
--
116673
 
 
116674
 
REVOKE ALL ON TABLE taxzone FROM PUBLIC;
116675
 
REVOKE ALL ON TABLE taxzone FROM admin;
116676
 
GRANT ALL ON TABLE taxzone TO admin;
116677
 
GRANT ALL ON TABLE taxzone TO xtrole;
116678
 
 
116679
 
 
116680
 
SET search_path = api, pg_catalog;
116681
 
 
116682
 
--
116683
 
--
116684
 
 
116685
 
REVOKE ALL ON TABLE creditmemo FROM PUBLIC;
116686
 
REVOKE ALL ON TABLE creditmemo FROM admin;
116687
 
GRANT ALL ON TABLE creditmemo TO admin;
116688
 
GRANT ALL ON TABLE creditmemo TO xtrole;
116689
 
 
116690
 
 
116691
 
SET search_path = public, pg_catalog;
116692
 
 
116693
 
--
116694
 
--
116695
 
 
116696
 
REVOKE ALL ON TABLE cmitem FROM PUBLIC;
116697
 
REVOKE ALL ON TABLE cmitem FROM admin;
116698
 
GRANT ALL ON TABLE cmitem TO admin;
116699
 
GRANT ALL ON TABLE cmitem TO xtrole;
116700
 
 
116701
 
 
116702
 
SET search_path = api, pg_catalog;
116703
 
 
116704
 
--
116705
 
--
116706
 
 
116707
 
REVOKE ALL ON TABLE creditmemoline FROM PUBLIC;
116708
 
REVOKE ALL ON TABLE creditmemoline FROM admin;
116709
 
GRANT ALL ON TABLE creditmemoline TO admin;
116710
 
GRANT ALL ON TABLE creditmemoline TO xtrole;
116711
 
 
116712
 
 
116713
 
SET search_path = public, pg_catalog;
116714
 
 
116715
 
--
116716
 
--
116717
 
 
116718
 
REVOKE ALL ON TABLE invchead FROM PUBLIC;
116719
 
REVOKE ALL ON TABLE invchead FROM admin;
116720
 
GRANT ALL ON TABLE invchead TO admin;
116721
 
GRANT ALL ON TABLE invchead TO xtrole;
116722
 
 
116723
 
 
116724
 
--
116725
 
--
116726
 
 
116727
 
REVOKE ALL ON TABLE prj FROM PUBLIC;
116728
 
REVOKE ALL ON TABLE prj FROM admin;
116729
 
GRANT ALL ON TABLE prj TO admin;
116730
 
GRANT ALL ON TABLE prj TO xtrole;
116731
 
 
116732
 
 
116733
 
--
116734
 
--
116735
 
 
116736
 
REVOKE ALL ON TABLE saletype FROM PUBLIC;
116737
 
REVOKE ALL ON TABLE saletype FROM admin;
116738
 
GRANT ALL ON TABLE saletype TO admin;
116739
 
GRANT ALL ON TABLE saletype TO xtrole;
116740
 
 
116741
 
 
116742
 
--
116743
 
--
116744
 
 
116745
 
REVOKE ALL ON TABLE shipzone FROM PUBLIC;
116746
 
REVOKE ALL ON TABLE shipzone FROM admin;
116747
 
GRANT ALL ON TABLE shipzone TO admin;
116748
 
GRANT ALL ON TABLE shipzone TO xtrole;
116749
 
 
116750
 
 
116751
 
SET search_path = api, pg_catalog;
116752
 
 
116753
 
--
116754
 
--
116755
 
 
116756
 
REVOKE ALL ON TABLE invoice FROM PUBLIC;
116757
 
REVOKE ALL ON TABLE invoice FROM admin;
116758
 
GRANT ALL ON TABLE invoice TO admin;
116759
 
GRANT ALL ON TABLE invoice TO xtrole;
116760
 
 
116761
 
 
116762
 
SET search_path = public, pg_catalog;
116763
 
 
116764
 
--
116765
 
--
116766
 
 
116767
 
REVOKE ALL ON TABLE invcitem FROM PUBLIC;
116768
 
REVOKE ALL ON TABLE invcitem FROM admin;
116769
 
GRANT ALL ON TABLE invcitem TO admin;
116770
 
GRANT ALL ON TABLE invcitem TO xtrole;
116771
 
 
116772
 
 
116773
 
SET search_path = api, pg_catalog;
116774
 
 
116775
 
--
116776
 
--
116777
 
 
116778
 
REVOKE ALL ON TABLE invoiceline FROM PUBLIC;
116779
 
REVOKE ALL ON TABLE invoiceline FROM admin;
116780
 
GRANT ALL ON TABLE invoiceline TO admin;
116781
 
GRANT ALL ON TABLE invoiceline TO xtrole;
116782
 
 
116783
 
 
116784
 
SET search_path = public, pg_catalog;
116785
 
 
116786
 
--
116787
 
--
116788
 
 
116789
 
REVOKE ALL ON TABLE ophead FROM PUBLIC;
116790
 
REVOKE ALL ON TABLE ophead FROM admin;
116791
 
GRANT ALL ON TABLE ophead TO admin;
116792
 
GRANT ALL ON TABLE ophead TO xtrole;
116793
 
 
116794
 
 
116795
 
--
116796
 
--
116797
 
 
116798
 
REVOKE ALL ON TABLE prjtask FROM PUBLIC;
116799
 
REVOKE ALL ON TABLE prjtask FROM admin;
116800
 
GRANT ALL ON TABLE prjtask TO admin;
116801
 
GRANT ALL ON TABLE prjtask TO xtrole;
116802
 
 
116803
 
 
116804
 
--
116805
 
--
116806
 
 
116807
 
REVOKE ALL ON TABLE todoitem FROM PUBLIC;
116808
 
REVOKE ALL ON TABLE todoitem FROM admin;
116809
 
GRANT ALL ON TABLE todoitem TO admin;
116810
 
GRANT ALL ON TABLE todoitem TO xtrole;
116811
 
 
116812
 
 
116813
 
--
116814
 
--
116815
 
 
116816
 
REVOKE ALL ON TABLE addr FROM PUBLIC;
116817
 
REVOKE ALL ON TABLE addr FROM admin;
116818
 
GRANT ALL ON TABLE addr TO admin;
116819
 
GRANT ALL ON TABLE addr TO xtrole;
116820
 
 
116821
 
 
116822
 
SET search_path = api, pg_catalog;
116823
 
 
116824
 
--
116825
 
--
116826
 
 
116827
 
REVOKE ALL ON TABLE account FROM PUBLIC;
116828
 
REVOKE ALL ON TABLE account FROM admin;
116829
 
GRANT ALL ON TABLE account TO admin;
116830
 
GRANT ALL ON TABLE account TO xtrole;
116831
 
 
116832
 
 
116833
 
SET search_path = public, pg_catalog;
116834
 
 
116835
 
--
116836
 
--
116837
 
 
116838
 
REVOKE ALL ON TABLE "char" FROM PUBLIC;
116839
 
REVOKE ALL ON TABLE "char" FROM admin;
116840
 
GRANT ALL ON TABLE "char" TO admin;
116841
 
GRANT ALL ON TABLE "char" TO xtrole;
116842
 
 
116843
 
 
116844
 
--
116845
 
--
116846
 
 
116847
 
REVOKE ALL ON TABLE charass FROM PUBLIC;
116848
 
REVOKE ALL ON TABLE charass FROM admin;
116849
 
GRANT ALL ON TABLE charass TO admin;
116850
 
GRANT ALL ON TABLE charass TO xtrole;
116851
 
 
116852
 
 
116853
 
SET search_path = api, pg_catalog;
116854
 
 
116855
 
--
116856
 
--
116857
 
 
116858
 
REVOKE ALL ON TABLE accountchar FROM PUBLIC;
116859
 
REVOKE ALL ON TABLE accountchar FROM admin;
116860
 
GRANT ALL ON TABLE accountchar TO admin;
116861
 
GRANT ALL ON TABLE accountchar TO xtrole;
116862
 
 
116863
 
 
116864
 
SET search_path = public, pg_catalog;
116865
 
 
116866
 
--
116867
 
--
116868
 
 
116869
 
REVOKE ALL ON TABLE cmnttype FROM PUBLIC;
116870
 
REVOKE ALL ON TABLE cmnttype FROM admin;
116871
 
GRANT ALL ON TABLE cmnttype TO admin;
116872
 
GRANT ALL ON TABLE cmnttype TO xtrole;
116873
 
 
116874
 
 
116875
 
--
116876
 
--
116877
 
 
116878
 
REVOKE ALL ON TABLE comment FROM PUBLIC;
116879
 
REVOKE ALL ON TABLE comment FROM admin;
116880
 
GRANT ALL ON TABLE comment TO admin;
116881
 
GRANT ALL ON TABLE comment TO xtrole;
116882
 
 
116883
 
 
116884
 
SET search_path = api, pg_catalog;
116885
 
 
116886
 
--
116887
 
--
116888
 
 
116889
 
REVOKE ALL ON TABLE accountcomment FROM PUBLIC;
116890
 
REVOKE ALL ON TABLE accountcomment FROM admin;
116891
 
GRANT ALL ON TABLE accountcomment TO admin;
116892
 
GRANT ALL ON TABLE accountcomment TO xtrole;
116893
 
 
116894
 
 
116895
 
SET search_path = public, pg_catalog;
116896
 
 
116897
 
--
116898
 
--
116899
 
 
116900
 
REVOKE ALL ON TABLE docass FROM PUBLIC;
116901
 
REVOKE ALL ON TABLE docass FROM admin;
116902
 
GRANT ALL ON TABLE docass TO admin;
116903
 
GRANT ALL ON TABLE docass TO xtrole;
116904
 
 
116905
 
 
116906
 
--
116907
 
--
116908
 
 
116909
 
REVOKE ALL ON TABLE file FROM PUBLIC;
116910
 
REVOKE ALL ON TABLE file FROM admin;
116911
 
GRANT ALL ON TABLE file TO admin;
116912
 
GRANT ALL ON TABLE file TO xtrole;
116913
 
 
116914
 
 
116915
 
--
116916
 
--
116917
 
 
116918
 
REVOKE ALL ON TABLE urlinfo FROM PUBLIC;
116919
 
REVOKE ALL ON TABLE urlinfo FROM admin;
116920
 
GRANT ALL ON TABLE urlinfo TO admin;
116921
 
GRANT ALL ON TABLE urlinfo TO xtrole;
116922
 
 
116923
 
 
116924
 
--
116925
 
--
116926
 
 
116927
 
REVOKE ALL ON TABLE url FROM PUBLIC;
116928
 
REVOKE ALL ON TABLE url FROM admin;
116929
 
GRANT ALL ON TABLE url TO admin;
116930
 
GRANT ALL ON TABLE url TO xtrole;
116931
 
 
116932
 
 
116933
 
SET search_path = api, pg_catalog;
116934
 
 
116935
 
--
116936
 
--
116937
 
 
116938
 
REVOKE ALL ON TABLE accountfile FROM PUBLIC;
116939
 
REVOKE ALL ON TABLE accountfile FROM admin;
116940
 
GRANT ALL ON TABLE accountfile TO admin;
116941
 
GRANT ALL ON TABLE accountfile TO xtrole;
116942
 
 
116943
 
 
116944
 
SET search_path = public, pg_catalog;
116945
 
 
116946
 
--
116947
 
--
116948
 
 
116949
 
REVOKE ALL ON SEQUENCE docass_docass_id_seq FROM PUBLIC;
116950
 
REVOKE ALL ON SEQUENCE docass_docass_id_seq FROM admin;
116951
 
GRANT ALL ON SEQUENCE docass_docass_id_seq TO admin;
116952
 
GRANT ALL ON SEQUENCE docass_docass_id_seq TO xtrole;
116953
 
 
116954
 
 
116955
 
--
116956
 
--
116957
 
 
116958
 
REVOKE ALL ON TABLE image FROM PUBLIC;
116959
 
REVOKE ALL ON TABLE image FROM admin;
116960
 
GRANT ALL ON TABLE image TO admin;
116961
 
GRANT ALL ON TABLE image TO xtrole;
116962
 
 
116963
 
 
116964
 
--
116965
 
--
116966
 
 
116967
 
REVOKE ALL ON TABLE imageass FROM PUBLIC;
116968
 
REVOKE ALL ON TABLE imageass FROM admin;
116969
 
GRANT ALL ON TABLE imageass TO admin;
116970
 
GRANT ALL ON TABLE imageass TO xtrole;
116971
 
 
116972
 
 
116973
 
SET search_path = api, pg_catalog;
116974
 
 
116975
 
--
116976
 
--
116977
 
 
116978
 
REVOKE ALL ON TABLE accountimage FROM PUBLIC;
116979
 
REVOKE ALL ON TABLE accountimage FROM admin;
116980
 
GRANT ALL ON TABLE accountimage TO admin;
116981
 
GRANT ALL ON TABLE accountimage TO xtrole;
116982
 
 
116983
 
 
116984
 
--
116985
 
--
116986
 
 
116987
 
REVOKE ALL ON TABLE address FROM PUBLIC;
116988
 
REVOKE ALL ON TABLE address FROM admin;
116989
 
GRANT ALL ON TABLE address TO admin;
116990
 
GRANT ALL ON TABLE address TO xtrole;
116991
 
 
116992
 
 
116993
 
--
116994
 
--
116995
 
 
116996
 
REVOKE ALL ON TABLE addresschar FROM PUBLIC;
116997
 
REVOKE ALL ON TABLE addresschar FROM admin;
116998
 
GRANT ALL ON TABLE addresschar TO admin;
116999
 
GRANT ALL ON TABLE addresschar TO xtrole;
117000
 
 
117001
 
 
117002
 
--
117003
 
--
117004
 
 
117005
 
REVOKE ALL ON TABLE addresscomment FROM PUBLIC;
117006
 
REVOKE ALL ON TABLE addresscomment FROM admin;
117007
 
GRANT ALL ON TABLE addresscomment TO admin;
117008
 
GRANT ALL ON TABLE addresscomment TO xtrole;
117009
 
 
117010
 
 
117011
 
SET search_path = public, pg_catalog;
117012
 
 
117013
 
--
117014
 
--
117015
 
 
117016
 
REVOKE ALL ON TABLE bomhead FROM PUBLIC;
117017
 
REVOKE ALL ON TABLE bomhead FROM admin;
117018
 
GRANT ALL ON TABLE bomhead TO admin;
117019
 
GRANT ALL ON TABLE bomhead TO xtrole;
117020
 
 
117021
 
 
117022
 
SET search_path = api, pg_catalog;
117023
 
 
117024
 
--
117025
 
--
117026
 
 
117027
 
REVOKE ALL ON TABLE bom FROM PUBLIC;
117028
 
REVOKE ALL ON TABLE bom FROM admin;
117029
 
GRANT ALL ON TABLE bom TO admin;
117030
 
GRANT ALL ON TABLE bom TO xtrole;
117031
 
 
117032
 
 
117033
 
--
117034
 
--
117035
 
 
117036
 
REVOKE ALL ON TABLE bomitem FROM PUBLIC;
117037
 
REVOKE ALL ON TABLE bomitem FROM admin;
117038
 
GRANT ALL ON TABLE bomitem TO admin;
117039
 
GRANT ALL ON TABLE bomitem TO xtrole;
117040
 
 
117041
 
 
117042
 
--
117043
 
--
117044
 
 
117045
 
REVOKE ALL ON TABLE bomitemcomment FROM PUBLIC;
117046
 
REVOKE ALL ON TABLE bomitemcomment FROM admin;
117047
 
GRANT ALL ON TABLE bomitemcomment TO admin;
117048
 
GRANT ALL ON TABLE bomitemcomment TO xtrole;
117049
 
 
117050
 
 
117051
 
SET search_path = public, pg_catalog;
117052
 
 
117053
 
--
117054
 
--
117055
 
 
117056
 
REVOKE ALL ON TABLE bomitemsub FROM PUBLIC;
117057
 
REVOKE ALL ON TABLE bomitemsub FROM admin;
117058
 
GRANT ALL ON TABLE bomitemsub TO admin;
117059
 
GRANT ALL ON TABLE bomitemsub TO xtrole;
117060
 
 
117061
 
 
117062
 
SET search_path = api, pg_catalog;
117063
 
 
117064
 
--
117065
 
--
117066
 
 
117067
 
REVOKE ALL ON TABLE bomitemsubstitute FROM PUBLIC;
117068
 
REVOKE ALL ON TABLE bomitemsubstitute FROM admin;
117069
 
GRANT ALL ON TABLE bomitemsubstitute TO admin;
117070
 
GRANT ALL ON TABLE bomitemsubstitute TO xtrole;
117071
 
 
117072
 
 
117073
 
SET search_path = public, pg_catalog;
117074
 
 
117075
 
--
117076
 
--
117077
 
 
117078
 
REVOKE ALL ON TABLE budghead FROM PUBLIC;
117079
 
REVOKE ALL ON TABLE budghead FROM admin;
117080
 
GRANT ALL ON TABLE budghead TO admin;
117081
 
GRANT ALL ON TABLE budghead TO xtrole;
117082
 
 
117083
 
 
117084
 
SET search_path = api, pg_catalog;
117085
 
 
117086
 
--
117087
 
--
117088
 
 
117089
 
REVOKE ALL ON TABLE budget FROM PUBLIC;
117090
 
REVOKE ALL ON TABLE budget FROM admin;
117091
 
GRANT ALL ON TABLE budget TO admin;
117092
 
GRANT ALL ON TABLE budget TO xtrole;
117093
 
 
117094
 
 
117095
 
SET search_path = public, pg_catalog;
117096
 
 
117097
 
--
117098
 
--
117099
 
 
117100
 
REVOKE ALL ON TABLE accnt FROM PUBLIC;
117101
 
REVOKE ALL ON TABLE accnt FROM admin;
117102
 
GRANT ALL ON TABLE accnt TO admin;
117103
 
GRANT ALL ON TABLE accnt TO xtrole;
117104
 
 
117105
 
 
117106
 
--
117107
 
--
117108
 
 
117109
 
REVOKE ALL ON TABLE budgitem FROM PUBLIC;
117110
 
REVOKE ALL ON TABLE budgitem FROM admin;
117111
 
GRANT ALL ON TABLE budgitem TO admin;
117112
 
GRANT ALL ON TABLE budgitem TO xtrole;
117113
 
 
117114
 
 
117115
 
--
117116
 
--
117117
 
 
117118
 
REVOKE ALL ON TABLE period FROM PUBLIC;
117119
 
REVOKE ALL ON TABLE period FROM admin;
117120
 
GRANT ALL ON TABLE period TO admin;
117121
 
GRANT ALL ON TABLE period TO xtrole;
117122
 
 
117123
 
 
117124
 
SET search_path = api, pg_catalog;
117125
 
 
117126
 
--
117127
 
--
117128
 
 
117129
 
REVOKE ALL ON TABLE budgetentry FROM PUBLIC;
117130
 
REVOKE ALL ON TABLE budgetentry FROM admin;
117131
 
GRANT ALL ON TABLE budgetentry TO admin;
117132
 
GRANT ALL ON TABLE budgetentry TO xtrole;
117133
 
 
117134
 
 
117135
 
SET search_path = public, pg_catalog;
117136
 
 
117137
 
--
117138
 
--
117139
 
 
117140
 
REVOKE ALL ON TABLE bankaccnt FROM PUBLIC;
117141
 
REVOKE ALL ON TABLE bankaccnt FROM admin;
117142
 
GRANT ALL ON TABLE bankaccnt TO admin;
117143
 
GRANT ALL ON TABLE bankaccnt TO xtrole;
117144
 
 
117145
 
 
117146
 
--
117147
 
--
117148
 
 
117149
 
REVOKE ALL ON TABLE cashrcpt FROM PUBLIC;
117150
 
REVOKE ALL ON TABLE cashrcpt FROM admin;
117151
 
GRANT ALL ON TABLE cashrcpt TO admin;
117152
 
GRANT ALL ON TABLE cashrcpt TO xtrole;
117153
 
 
117154
 
 
117155
 
SET search_path = api, pg_catalog;
117156
 
 
117157
 
--
117158
 
--
117159
 
 
117160
 
REVOKE ALL ON TABLE cashreceipt FROM PUBLIC;
117161
 
REVOKE ALL ON TABLE cashreceipt FROM admin;
117162
 
GRANT ALL ON TABLE cashreceipt TO admin;
117163
 
GRANT ALL ON TABLE cashreceipt TO xtrole;
117164
 
 
117165
 
 
117166
 
SET search_path = public, pg_catalog;
117167
 
 
117168
 
--
117169
 
--
117170
 
 
117171
 
REVOKE ALL ON TABLE cashrcptitem FROM PUBLIC;
117172
 
REVOKE ALL ON TABLE cashrcptitem FROM admin;
117173
 
GRANT ALL ON TABLE cashrcptitem TO admin;
117174
 
GRANT ALL ON TABLE cashrcptitem TO xtrole;
117175
 
 
117176
 
 
117177
 
SET search_path = api, pg_catalog;
117178
 
 
117179
 
--
117180
 
--
117181
 
 
117182
 
REVOKE ALL ON TABLE cashreceiptapply FROM PUBLIC;
117183
 
REVOKE ALL ON TABLE cashreceiptapply FROM admin;
117184
 
GRANT ALL ON TABLE cashreceiptapply TO admin;
117185
 
GRANT ALL ON TABLE cashreceiptapply TO xtrole;
117186
 
 
117187
 
 
117188
 
SET search_path = public, pg_catalog;
117189
 
 
117190
 
--
117191
 
--
117192
 
 
117193
 
REVOKE ALL ON TABLE cashrcptmisc FROM PUBLIC;
117194
 
REVOKE ALL ON TABLE cashrcptmisc FROM admin;
117195
 
GRANT ALL ON TABLE cashrcptmisc TO admin;
117196
 
GRANT ALL ON TABLE cashrcptmisc TO xtrole;
117197
 
 
117198
 
 
117199
 
SET search_path = api, pg_catalog;
117200
 
 
117201
 
--
117202
 
--
117203
 
 
117204
 
REVOKE ALL ON TABLE cashreceiptapplymisc FROM PUBLIC;
117205
 
REVOKE ALL ON TABLE cashreceiptapplymisc FROM admin;
117206
 
GRANT ALL ON TABLE cashreceiptapplymisc TO admin;
117207
 
GRANT ALL ON TABLE cashreceiptapplymisc TO xtrole;
117208
 
 
117209
 
 
117210
 
--
117211
 
--
117212
 
 
117213
 
REVOKE ALL ON TABLE contact FROM PUBLIC;
117214
 
REVOKE ALL ON TABLE contact FROM admin;
117215
 
GRANT ALL ON TABLE contact TO admin;
117216
 
GRANT ALL ON TABLE contact TO xtrole;
117217
 
 
117218
 
 
117219
 
--
117220
 
--
117221
 
 
117222
 
REVOKE ALL ON TABLE contactchar FROM PUBLIC;
117223
 
REVOKE ALL ON TABLE contactchar FROM admin;
117224
 
GRANT ALL ON TABLE contactchar TO admin;
117225
 
GRANT ALL ON TABLE contactchar TO xtrole;
117226
 
 
117227
 
 
117228
 
--
117229
 
--
117230
 
 
117231
 
REVOKE ALL ON TABLE contactcomment FROM PUBLIC;
117232
 
REVOKE ALL ON TABLE contactcomment FROM admin;
117233
 
GRANT ALL ON TABLE contactcomment TO admin;
117234
 
GRANT ALL ON TABLE contactcomment TO xtrole;
117235
 
 
117236
 
 
117237
 
--
117238
 
--
117239
 
 
117240
 
REVOKE ALL ON TABLE custchar FROM PUBLIC;
117241
 
REVOKE ALL ON TABLE custchar FROM admin;
117242
 
GRANT ALL ON TABLE custchar TO admin;
117243
 
GRANT ALL ON TABLE custchar TO xtrole;
117244
 
 
117245
 
 
117246
 
--
117247
 
--
117248
 
 
117249
 
REVOKE ALL ON TABLE custcomment FROM PUBLIC;
117250
 
REVOKE ALL ON TABLE custcomment FROM admin;
117251
 
GRANT ALL ON TABLE custcomment TO admin;
117252
 
GRANT ALL ON TABLE custcomment TO xtrole;
117253
 
 
117254
 
 
117255
 
SET search_path = public, pg_catalog;
117256
 
 
117257
 
--
117258
 
--
117259
 
 
117260
 
REVOKE ALL ON TABLE ccard FROM PUBLIC;
117261
 
REVOKE ALL ON TABLE ccard FROM admin;
117262
 
GRANT ALL ON TABLE ccard TO admin;
117263
 
GRANT ALL ON TABLE ccard TO xtrole;
117264
 
 
117265
 
 
117266
 
SET search_path = api, pg_catalog;
117267
 
 
117268
 
--
117269
 
--
117270
 
 
117271
 
REVOKE ALL ON TABLE custcreditcard FROM PUBLIC;
117272
 
REVOKE ALL ON TABLE custcreditcard FROM admin;
117273
 
GRANT ALL ON TABLE custcreditcard TO admin;
117274
 
GRANT ALL ON TABLE custcreditcard TO xtrole;
117275
 
 
117276
 
 
117277
 
SET search_path = public, pg_catalog;
117278
 
 
117279
 
--
117280
 
--
117281
 
 
117282
 
REVOKE ALL ON TABLE custtype FROM PUBLIC;
117283
 
REVOKE ALL ON TABLE custtype FROM admin;
117284
 
GRANT ALL ON TABLE custtype TO admin;
117285
 
GRANT ALL ON TABLE custtype TO xtrole;
117286
 
 
117287
 
 
117288
 
--
117289
 
--
117290
 
 
117291
 
REVOKE ALL ON TABLE shipchrg FROM PUBLIC;
117292
 
REVOKE ALL ON TABLE shipchrg FROM admin;
117293
 
GRANT ALL ON TABLE shipchrg TO admin;
117294
 
GRANT ALL ON TABLE shipchrg TO xtrole;
117295
 
 
117296
 
 
117297
 
--
117298
 
--
117299
 
 
117300
 
REVOKE ALL ON TABLE shipform FROM PUBLIC;
117301
 
REVOKE ALL ON TABLE shipform FROM admin;
117302
 
GRANT ALL ON TABLE shipform TO admin;
117303
 
GRANT ALL ON TABLE shipform TO xtrole;
117304
 
 
117305
 
 
117306
 
SET search_path = api, pg_catalog;
117307
 
 
117308
 
--
117309
 
--
117310
 
 
117311
 
REVOKE ALL ON TABLE customer FROM PUBLIC;
117312
 
REVOKE ALL ON TABLE customer FROM admin;
117313
 
GRANT ALL ON TABLE customer TO admin;
117314
 
GRANT ALL ON TABLE customer TO xtrole;
117315
 
 
117316
 
 
117317
 
SET search_path = public, pg_catalog;
117318
 
 
117319
 
--
117320
 
--
117321
 
 
117322
 
REVOKE ALL ON TABLE taxauth FROM PUBLIC;
117323
 
REVOKE ALL ON TABLE taxauth FROM admin;
117324
 
GRANT ALL ON TABLE taxauth TO admin;
117325
 
GRANT ALL ON TABLE taxauth TO xtrole;
117326
 
 
117327
 
 
117328
 
--
117329
 
--
117330
 
 
117331
 
REVOKE ALL ON TABLE taxreg FROM PUBLIC;
117332
 
REVOKE ALL ON TABLE taxreg FROM admin;
117333
 
GRANT ALL ON TABLE taxreg TO admin;
117334
 
GRANT ALL ON TABLE taxreg TO xtrole;
117335
 
 
117336
 
 
117337
 
SET search_path = api, pg_catalog;
117338
 
 
117339
 
--
117340
 
--
117341
 
 
117342
 
REVOKE ALL ON TABLE customertaxreg FROM PUBLIC;
117343
 
REVOKE ALL ON TABLE customertaxreg FROM admin;
117344
 
GRANT ALL ON TABLE customertaxreg TO admin;
117345
 
GRANT ALL ON TABLE customertaxreg TO xtrole;
117346
 
 
117347
 
 
117348
 
--
117349
 
--
117350
 
 
117351
 
REVOKE ALL ON TABLE customertype FROM PUBLIC;
117352
 
REVOKE ALL ON TABLE customertype FROM admin;
117353
 
GRANT ALL ON TABLE customertype TO admin;
117354
 
GRANT ALL ON TABLE customertype TO xtrole;
117355
 
 
117356
 
 
117357
 
--
117358
 
--
117359
 
 
117360
 
REVOKE ALL ON TABLE customertypechar FROM PUBLIC;
117361
 
REVOKE ALL ON TABLE customertypechar FROM admin;
117362
 
GRANT ALL ON TABLE customertypechar TO admin;
117363
 
GRANT ALL ON TABLE customertypechar TO xtrole;
117364
 
 
117365
 
 
117366
 
--
117367
 
--
117368
 
 
117369
 
REVOKE ALL ON TABLE custshipto FROM PUBLIC;
117370
 
REVOKE ALL ON TABLE custshipto FROM admin;
117371
 
GRANT ALL ON TABLE custshipto TO admin;
117372
 
GRANT ALL ON TABLE custshipto TO xtrole;
117373
 
 
117374
 
 
117375
 
--
117376
 
--
117377
 
 
117378
 
REVOKE ALL ON TABLE custtax FROM PUBLIC;
117379
 
REVOKE ALL ON TABLE custtax FROM admin;
117380
 
GRANT ALL ON TABLE custtax TO admin;
117381
 
GRANT ALL ON TABLE custtax TO xtrole;
117382
 
 
117383
 
 
117384
 
SET search_path = public, pg_catalog;
117385
 
 
117386
 
--
117387
 
--
117388
 
 
117389
 
REVOKE ALL ON TABLE dept FROM PUBLIC;
117390
 
REVOKE ALL ON TABLE dept FROM admin;
117391
 
GRANT ALL ON TABLE dept TO admin;
117392
 
GRANT ALL ON TABLE dept TO xtrole;
117393
 
 
117394
 
 
117395
 
--
117396
 
--
117397
 
 
117398
 
REVOKE ALL ON TABLE emp FROM PUBLIC;
117399
 
REVOKE ALL ON TABLE emp FROM admin;
117400
 
GRANT ALL ON TABLE emp TO admin;
117401
 
GRANT ALL ON TABLE emp TO xtrole;
117402
 
 
117403
 
 
117404
 
--
117405
 
--
117406
 
 
117407
 
REVOKE ALL ON TABLE shift FROM PUBLIC;
117408
 
REVOKE ALL ON TABLE shift FROM admin;
117409
 
GRANT ALL ON TABLE shift TO admin;
117410
 
GRANT ALL ON TABLE shift TO xtrole;
117411
 
 
117412
 
 
117413
 
SET search_path = api, pg_catalog;
117414
 
 
117415
 
--
117416
 
--
117417
 
 
117418
 
REVOKE ALL ON TABLE employee FROM PUBLIC;
117419
 
REVOKE ALL ON TABLE employee FROM admin;
117420
 
GRANT ALL ON TABLE employee TO admin;
117421
 
GRANT ALL ON TABLE employee TO xtrole;
117422
 
 
117423
 
 
117424
 
--
117425
 
--
117426
 
 
117427
 
REVOKE ALL ON TABLE employeechar FROM PUBLIC;
117428
 
REVOKE ALL ON TABLE employeechar FROM admin;
117429
 
GRANT ALL ON TABLE employeechar TO admin;
117430
 
GRANT ALL ON TABLE employeechar TO xtrole;
117431
 
 
117432
 
 
117433
 
--
117434
 
--
117435
 
 
117436
 
REVOKE ALL ON TABLE employeecomment FROM PUBLIC;
117437
 
REVOKE ALL ON TABLE employeecomment FROM admin;
117438
 
GRANT ALL ON TABLE employeecomment TO admin;
117439
 
GRANT ALL ON TABLE employeecomment TO xtrole;
117440
 
 
117441
 
 
117442
 
SET search_path = public, pg_catalog;
117443
 
 
117444
 
--
117445
 
--
117446
 
 
117447
 
REVOKE ALL ON TABLE shipdata FROM PUBLIC;
117448
 
REVOKE ALL ON TABLE shipdata FROM admin;
117449
 
GRANT ALL ON TABLE shipdata TO admin;
117450
 
GRANT ALL ON TABLE shipdata TO xtrole;
117451
 
 
117452
 
 
117453
 
SET search_path = api, pg_catalog;
117454
 
 
117455
 
--
117456
 
--
117457
 
 
117458
 
REVOKE ALL ON TABLE extshipmaint FROM PUBLIC;
117459
 
REVOKE ALL ON TABLE extshipmaint FROM admin;
117460
 
GRANT ALL ON TABLE extshipmaint TO admin;
117461
 
GRANT ALL ON TABLE extshipmaint TO xtrole;
117462
 
 
117463
 
 
117464
 
SET search_path = public, pg_catalog;
117465
 
 
117466
 
--
117467
 
--
117468
 
 
117469
 
REVOKE ALL ON TABLE freightclass FROM PUBLIC;
117470
 
REVOKE ALL ON TABLE freightclass FROM admin;
117471
 
GRANT ALL ON TABLE freightclass TO admin;
117472
 
GRANT ALL ON TABLE freightclass TO xtrole;
117473
 
 
117474
 
 
117475
 
--
117476
 
--
117477
 
 
117478
 
REVOKE ALL ON TABLE ipsfreight FROM PUBLIC;
117479
 
REVOKE ALL ON TABLE ipsfreight FROM admin;
117480
 
GRANT ALL ON TABLE ipsfreight TO admin;
117481
 
GRANT ALL ON TABLE ipsfreight TO xtrole;
117482
 
 
117483
 
 
117484
 
--
117485
 
--
117486
 
 
117487
 
REVOKE ALL ON TABLE ipshead FROM PUBLIC;
117488
 
REVOKE ALL ON TABLE ipshead FROM admin;
117489
 
GRANT ALL ON TABLE ipshead TO admin;
117490
 
GRANT ALL ON TABLE ipshead TO xtrole;
117491
 
 
117492
 
 
117493
 
SET search_path = api, pg_catalog;
117494
 
 
117495
 
--
117496
 
--
117497
 
 
117498
 
REVOKE ALL ON TABLE freightpricingscheduleitem FROM PUBLIC;
117499
 
REVOKE ALL ON TABLE freightpricingscheduleitem FROM admin;
117500
 
GRANT ALL ON TABLE freightpricingscheduleitem TO admin;
117501
 
GRANT ALL ON TABLE freightpricingscheduleitem TO xtrole;
117502
 
 
117503
 
 
117504
 
--
117505
 
--
117506
 
 
117507
 
REVOKE ALL ON TABLE glaccount FROM PUBLIC;
117508
 
REVOKE ALL ON TABLE glaccount FROM admin;
117509
 
GRANT ALL ON TABLE glaccount TO admin;
117510
 
GRANT ALL ON TABLE glaccount TO xtrole;
117511
 
 
117512
 
 
117513
 
SET search_path = public, pg_catalog;
117514
 
 
117515
 
--
117516
 
--
117517
 
 
117518
 
REVOKE ALL ON TABLE incdtcat FROM PUBLIC;
117519
 
REVOKE ALL ON TABLE incdtcat FROM admin;
117520
 
GRANT ALL ON TABLE incdtcat TO admin;
117521
 
GRANT ALL ON TABLE incdtcat TO xtrole;
117522
 
 
117523
 
 
117524
 
--
117525
 
--
117526
 
 
117527
 
REVOKE ALL ON TABLE incdtpriority FROM PUBLIC;
117528
 
REVOKE ALL ON TABLE incdtpriority FROM admin;
117529
 
GRANT ALL ON TABLE incdtpriority TO admin;
117530
 
GRANT ALL ON TABLE incdtpriority TO xtrole;
117531
 
 
117532
 
 
117533
 
--
117534
 
--
117535
 
 
117536
 
REVOKE ALL ON TABLE incdtresolution FROM PUBLIC;
117537
 
REVOKE ALL ON TABLE incdtresolution FROM admin;
117538
 
GRANT ALL ON TABLE incdtresolution TO admin;
117539
 
GRANT ALL ON TABLE incdtresolution TO xtrole;
117540
 
 
117541
 
 
117542
 
--
117543
 
--
117544
 
 
117545
 
REVOKE ALL ON TABLE incdtseverity FROM PUBLIC;
117546
 
REVOKE ALL ON TABLE incdtseverity FROM admin;
117547
 
GRANT ALL ON TABLE incdtseverity TO admin;
117548
 
GRANT ALL ON TABLE incdtseverity TO xtrole;
117549
 
 
117550
 
 
117551
 
SET search_path = api, pg_catalog;
117552
 
 
117553
 
--
117554
 
--
117555
 
 
117556
 
REVOKE ALL ON TABLE incident FROM PUBLIC;
117557
 
REVOKE ALL ON TABLE incident FROM admin;
117558
 
GRANT ALL ON TABLE incident TO admin;
117559
 
GRANT ALL ON TABLE incident TO xtrole;
117560
 
 
117561
 
 
117562
 
--
117563
 
--
117564
 
 
117565
 
REVOKE ALL ON TABLE incidentchar FROM PUBLIC;
117566
 
REVOKE ALL ON TABLE incidentchar FROM admin;
117567
 
GRANT ALL ON TABLE incidentchar TO admin;
117568
 
GRANT ALL ON TABLE incidentchar TO xtrole;
117569
 
 
117570
 
 
117571
 
--
117572
 
--
117573
 
 
117574
 
REVOKE ALL ON TABLE incidentcomment FROM PUBLIC;
117575
 
REVOKE ALL ON TABLE incidentcomment FROM admin;
117576
 
GRANT ALL ON TABLE incidentcomment TO admin;
117577
 
GRANT ALL ON TABLE incidentcomment TO xtrole;
117578
 
 
117579
 
 
117580
 
--
117581
 
--
117582
 
 
117583
 
REVOKE ALL ON TABLE incidentfile FROM PUBLIC;
117584
 
REVOKE ALL ON TABLE incidentfile FROM admin;
117585
 
GRANT ALL ON TABLE incidentfile TO admin;
117586
 
GRANT ALL ON TABLE incidentfile TO xtrole;
117587
 
 
117588
 
 
117589
 
--
117590
 
--
117591
 
 
117592
 
REVOKE ALL ON TABLE incidentimage FROM PUBLIC;
117593
 
REVOKE ALL ON TABLE incidentimage FROM admin;
117594
 
GRANT ALL ON TABLE incidentimage TO admin;
117595
 
GRANT ALL ON TABLE incidentimage TO xtrole;
117596
 
 
117597
 
 
117598
 
SET search_path = public, pg_catalog;
117599
 
 
117600
 
--
117601
 
--
117602
 
 
117603
 
REVOKE ALL ON TABLE classcode FROM PUBLIC;
117604
 
REVOKE ALL ON TABLE classcode FROM admin;
117605
 
GRANT ALL ON TABLE classcode TO admin;
117606
 
GRANT ALL ON TABLE classcode TO xtrole;
117607
 
 
117608
 
 
117609
 
--
117610
 
--
117611
 
 
117612
 
REVOKE ALL ON TABLE prodcat FROM PUBLIC;
117613
 
REVOKE ALL ON TABLE prodcat FROM admin;
117614
 
GRANT ALL ON TABLE prodcat TO admin;
117615
 
GRANT ALL ON TABLE prodcat TO xtrole;
117616
 
 
117617
 
 
117618
 
SET search_path = api, pg_catalog;
117619
 
 
117620
 
--
117621
 
--
117622
 
 
117623
 
REVOKE ALL ON TABLE item FROM PUBLIC;
117624
 
REVOKE ALL ON TABLE item FROM admin;
117625
 
GRANT ALL ON TABLE item TO admin;
117626
 
GRANT ALL ON TABLE item TO xtrole;
117627
 
 
117628
 
 
117629
 
SET search_path = public, pg_catalog;
117630
 
 
117631
 
--
117632
 
--
117633
 
 
117634
 
REVOKE ALL ON TABLE itemalias FROM PUBLIC;
117635
 
REVOKE ALL ON TABLE itemalias FROM admin;
117636
 
GRANT ALL ON TABLE itemalias TO admin;
117637
 
GRANT ALL ON TABLE itemalias TO xtrole;
117638
 
 
117639
 
 
117640
 
SET search_path = api, pg_catalog;
117641
 
 
117642
 
--
117643
 
--
117644
 
 
117645
 
REVOKE ALL ON TABLE itemalias FROM PUBLIC;
117646
 
REVOKE ALL ON TABLE itemalias FROM admin;
117647
 
GRANT ALL ON TABLE itemalias TO admin;
117648
 
GRANT ALL ON TABLE itemalias TO xtrole;
117649
 
 
117650
 
 
117651
 
--
117652
 
--
117653
 
 
117654
 
REVOKE ALL ON TABLE itemchar FROM PUBLIC;
117655
 
REVOKE ALL ON TABLE itemchar FROM admin;
117656
 
GRANT ALL ON TABLE itemchar TO admin;
117657
 
GRANT ALL ON TABLE itemchar TO xtrole;
117658
 
 
117659
 
 
117660
 
--
117661
 
--
117662
 
 
117663
 
REVOKE ALL ON TABLE itemcomment FROM PUBLIC;
117664
 
REVOKE ALL ON TABLE itemcomment FROM admin;
117665
 
GRANT ALL ON TABLE itemcomment TO admin;
117666
 
GRANT ALL ON TABLE itemcomment TO xtrole;
117667
 
 
117668
 
 
117669
 
SET search_path = public, pg_catalog;
117670
 
 
117671
 
--
117672
 
--
117673
 
 
117674
 
REVOKE ALL ON TABLE costelem FROM PUBLIC;
117675
 
REVOKE ALL ON TABLE costelem FROM admin;
117676
 
GRANT ALL ON TABLE costelem TO admin;
117677
 
GRANT ALL ON TABLE costelem TO xtrole;
117678
 
 
117679
 
 
117680
 
--
117681
 
--
117682
 
 
117683
 
REVOKE ALL ON TABLE itemcost FROM PUBLIC;
117684
 
REVOKE ALL ON TABLE itemcost FROM admin;
117685
 
GRANT ALL ON TABLE itemcost TO admin;
117686
 
GRANT ALL ON TABLE itemcost TO xtrole;
117687
 
 
117688
 
 
117689
 
SET search_path = api, pg_catalog;
117690
 
 
117691
 
--
117692
 
--
117693
 
 
117694
 
REVOKE ALL ON TABLE itemcost FROM PUBLIC;
117695
 
REVOKE ALL ON TABLE itemcost FROM admin;
117696
 
GRANT ALL ON TABLE itemcost TO admin;
117697
 
GRANT ALL ON TABLE itemcost TO xtrole;
117698
 
 
117699
 
 
117700
 
--
117701
 
--
117702
 
 
117703
 
REVOKE ALL ON TABLE itemfile FROM PUBLIC;
117704
 
REVOKE ALL ON TABLE itemfile FROM admin;
117705
 
GRANT ALL ON TABLE itemfile TO admin;
117706
 
GRANT ALL ON TABLE itemfile TO xtrole;
117707
 
 
117708
 
 
117709
 
--
117710
 
--
117711
 
 
117712
 
REVOKE ALL ON TABLE itemimage FROM PUBLIC;
117713
 
REVOKE ALL ON TABLE itemimage FROM admin;
117714
 
GRANT ALL ON TABLE itemimage TO admin;
117715
 
GRANT ALL ON TABLE itemimage TO xtrole;
117716
 
 
117717
 
 
117718
 
SET search_path = public, pg_catalog;
117719
 
 
117720
 
--
117721
 
--
117722
 
 
117723
 
REVOKE ALL ON TABLE costcat FROM PUBLIC;
117724
 
REVOKE ALL ON TABLE costcat FROM admin;
117725
 
GRANT ALL ON TABLE costcat TO admin;
117726
 
GRANT ALL ON TABLE costcat TO xtrole;
117727
 
 
117728
 
 
117729
 
--
117730
 
--
117731
 
 
117732
 
REVOKE ALL ON TABLE plancode FROM PUBLIC;
117733
 
REVOKE ALL ON TABLE plancode FROM admin;
117734
 
GRANT ALL ON TABLE plancode TO admin;
117735
 
GRANT ALL ON TABLE plancode TO xtrole;
117736
 
 
117737
 
 
117738
 
SET search_path = api, pg_catalog;
117739
 
 
117740
 
--
117741
 
--
117742
 
 
117743
 
REVOKE ALL ON TABLE itemsite FROM PUBLIC;
117744
 
REVOKE ALL ON TABLE itemsite FROM admin;
117745
 
GRANT ALL ON TABLE itemsite TO admin;
117746
 
GRANT ALL ON TABLE itemsite TO xtrole;
117747
 
 
117748
 
 
117749
 
--
117750
 
--
117751
 
 
117752
 
REVOKE ALL ON TABLE itemsitecomment FROM PUBLIC;
117753
 
REVOKE ALL ON TABLE itemsitecomment FROM admin;
117754
 
GRANT ALL ON TABLE itemsitecomment TO admin;
117755
 
GRANT ALL ON TABLE itemsitecomment TO xtrole;
117756
 
 
117757
 
 
117758
 
SET search_path = public, pg_catalog;
117759
 
 
117760
 
--
117761
 
--
117762
 
 
117763
 
REVOKE ALL ON TABLE contrct FROM PUBLIC;
117764
 
REVOKE ALL ON TABLE contrct FROM admin;
117765
 
GRANT ALL ON TABLE contrct TO admin;
117766
 
GRANT ALL ON TABLE contrct TO xtrole;
117767
 
 
117768
 
 
117769
 
--
117770
 
--
117771
 
 
117772
 
REVOKE ALL ON TABLE itemsrc FROM PUBLIC;
117773
 
REVOKE ALL ON TABLE itemsrc FROM admin;
117774
 
GRANT ALL ON TABLE itemsrc TO admin;
117775
 
GRANT ALL ON TABLE itemsrc TO xtrole;
117776
 
 
117777
 
 
117778
 
SET search_path = api, pg_catalog;
117779
 
 
117780
 
--
117781
 
--
117782
 
 
117783
 
REVOKE ALL ON TABLE itemsource FROM PUBLIC;
117784
 
REVOKE ALL ON TABLE itemsource FROM admin;
117785
 
GRANT ALL ON TABLE itemsource TO admin;
117786
 
GRANT ALL ON TABLE itemsource TO xtrole;
117787
 
 
117788
 
 
117789
 
SET search_path = public, pg_catalog;
117790
 
 
117791
 
--
117792
 
--
117793
 
 
117794
 
REVOKE ALL ON TABLE itemsrcp FROM PUBLIC;
117795
 
REVOKE ALL ON TABLE itemsrcp FROM admin;
117796
 
GRANT ALL ON TABLE itemsrcp TO admin;
117797
 
GRANT ALL ON TABLE itemsrcp TO xtrole;
117798
 
 
117799
 
 
117800
 
SET search_path = api, pg_catalog;
117801
 
 
117802
 
--
117803
 
--
117804
 
 
117805
 
REVOKE ALL ON TABLE itemsourceprice FROM PUBLIC;
117806
 
REVOKE ALL ON TABLE itemsourceprice FROM admin;
117807
 
GRANT ALL ON TABLE itemsourceprice TO admin;
117808
 
GRANT ALL ON TABLE itemsourceprice TO xtrole;
117809
 
 
117810
 
 
117811
 
SET search_path = public, pg_catalog;
117812
 
 
117813
 
--
117814
 
--
117815
 
 
117816
 
REVOKE ALL ON TABLE itemsub FROM PUBLIC;
117817
 
REVOKE ALL ON TABLE itemsub FROM admin;
117818
 
GRANT ALL ON TABLE itemsub TO admin;
117819
 
GRANT ALL ON TABLE itemsub TO xtrole;
117820
 
 
117821
 
 
117822
 
SET search_path = api, pg_catalog;
117823
 
 
117824
 
--
117825
 
--
117826
 
 
117827
 
REVOKE ALL ON TABLE itemsubstitute FROM PUBLIC;
117828
 
REVOKE ALL ON TABLE itemsubstitute FROM admin;
117829
 
GRANT ALL ON TABLE itemsubstitute TO admin;
117830
 
GRANT ALL ON TABLE itemsubstitute TO xtrole;
117831
 
 
117832
 
 
117833
 
SET search_path = public, pg_catalog;
117834
 
 
117835
 
--
117836
 
--
117837
 
 
117838
 
REVOKE ALL ON TABLE itemtax FROM PUBLIC;
117839
 
REVOKE ALL ON TABLE itemtax FROM admin;
117840
 
GRANT ALL ON TABLE itemtax TO admin;
117841
 
GRANT ALL ON TABLE itemtax TO xtrole;
117842
 
 
117843
 
 
117844
 
SET search_path = api, pg_catalog;
117845
 
 
117846
 
--
117847
 
--
117848
 
 
117849
 
REVOKE ALL ON TABLE itemtaxtype FROM PUBLIC;
117850
 
REVOKE ALL ON TABLE itemtaxtype FROM admin;
117851
 
GRANT ALL ON TABLE itemtaxtype TO admin;
117852
 
GRANT ALL ON TABLE itemtaxtype TO xtrole;
117853
 
 
117854
 
 
117855
 
SET search_path = public, pg_catalog;
117856
 
 
117857
 
--
117858
 
--
117859
 
 
117860
 
REVOKE ALL ON TABLE itemuomconv FROM PUBLIC;
117861
 
REVOKE ALL ON TABLE itemuomconv FROM admin;
117862
 
GRANT ALL ON TABLE itemuomconv TO admin;
117863
 
GRANT ALL ON TABLE itemuomconv TO xtrole;
117864
 
 
117865
 
 
117866
 
SET search_path = api, pg_catalog;
117867
 
 
117868
 
--
117869
 
--
117870
 
 
117871
 
REVOKE ALL ON TABLE itemuomconversion FROM PUBLIC;
117872
 
REVOKE ALL ON TABLE itemuomconversion FROM admin;
117873
 
GRANT ALL ON TABLE itemuomconversion TO admin;
117874
 
GRANT ALL ON TABLE itemuomconversion TO xtrole;
117875
 
 
117876
 
 
117877
 
SET search_path = public, pg_catalog;
117878
 
 
117879
 
--
117880
 
--
117881
 
 
117882
 
REVOKE ALL ON TABLE gltrans FROM PUBLIC;
117883
 
REVOKE ALL ON TABLE gltrans FROM admin;
117884
 
GRANT ALL ON TABLE gltrans TO admin;
117885
 
GRANT ALL ON TABLE gltrans TO xtrole;
117886
 
 
117887
 
 
117888
 
SET search_path = api, pg_catalog;
117889
 
 
117890
 
--
117891
 
--
117892
 
 
117893
 
REVOKE ALL ON TABLE journalentry FROM PUBLIC;
117894
 
REVOKE ALL ON TABLE journalentry FROM admin;
117895
 
GRANT ALL ON TABLE journalentry TO admin;
117896
 
GRANT ALL ON TABLE journalentry TO xtrole;
117897
 
 
117898
 
 
117899
 
SET search_path = public, pg_catalog;
117900
 
 
117901
 
--
117902
 
--
117903
 
 
117904
 
REVOKE ALL ON TABLE location FROM PUBLIC;
117905
 
REVOKE ALL ON TABLE location FROM admin;
117906
 
GRANT ALL ON TABLE location TO admin;
117907
 
GRANT ALL ON TABLE location TO xtrole;
117908
 
 
117909
 
 
117910
 
--
117911
 
--
117912
 
 
117913
 
REVOKE ALL ON TABLE whsezone FROM PUBLIC;
117914
 
REVOKE ALL ON TABLE whsezone FROM admin;
117915
 
GRANT ALL ON TABLE whsezone TO admin;
117916
 
GRANT ALL ON TABLE whsezone TO xtrole;
117917
 
 
117918
 
 
117919
 
SET search_path = api, pg_catalog;
117920
 
 
117921
 
--
117922
 
--
117923
 
 
117924
 
REVOKE ALL ON TABLE location FROM PUBLIC;
117925
 
REVOKE ALL ON TABLE location FROM admin;
117926
 
GRANT ALL ON TABLE location TO admin;
117927
 
GRANT ALL ON TABLE location TO xtrole;
117928
 
 
117929
 
 
117930
 
--
117931
 
--
117932
 
 
117933
 
REVOKE ALL ON TABLE misccounttag FROM PUBLIC;
117934
 
REVOKE ALL ON TABLE misccounttag FROM admin;
117935
 
GRANT ALL ON TABLE misccounttag TO admin;
117936
 
GRANT ALL ON TABLE misccounttag TO xtrole;
117937
 
 
117938
 
 
117939
 
--
117940
 
--
117941
 
 
117942
 
REVOKE ALL ON TABLE pricingschedule FROM PUBLIC;
117943
 
REVOKE ALL ON TABLE pricingschedule FROM admin;
117944
 
GRANT ALL ON TABLE pricingschedule TO admin;
117945
 
GRANT ALL ON TABLE pricingschedule TO xtrole;
117946
 
 
117947
 
 
117948
 
SET search_path = public, pg_catalog;
117949
 
 
117950
 
--
117951
 
--
117952
 
 
117953
 
REVOKE ALL ON TABLE ipsass FROM PUBLIC;
117954
 
REVOKE ALL ON TABLE ipsass FROM admin;
117955
 
GRANT ALL ON TABLE ipsass TO admin;
117956
 
GRANT ALL ON TABLE ipsass TO xtrole;
117957
 
 
117958
 
 
117959
 
SET search_path = api, pg_catalog;
117960
 
 
117961
 
--
117962
 
--
117963
 
 
117964
 
REVOKE ALL ON TABLE pricingscheduleassign FROM PUBLIC;
117965
 
REVOKE ALL ON TABLE pricingscheduleassign FROM admin;
117966
 
GRANT ALL ON TABLE pricingscheduleassign TO admin;
117967
 
GRANT ALL ON TABLE pricingscheduleassign TO xtrole;
117968
 
 
117969
 
 
117970
 
SET search_path = public, pg_catalog;
117971
 
 
117972
 
--
117973
 
--
117974
 
 
117975
 
REVOKE ALL ON TABLE ipsiteminfo FROM PUBLIC;
117976
 
REVOKE ALL ON TABLE ipsiteminfo FROM admin;
117977
 
GRANT ALL ON TABLE ipsiteminfo TO admin;
117978
 
GRANT ALL ON TABLE ipsiteminfo TO xtrole;
117979
 
 
117980
 
 
117981
 
SET search_path = api, pg_catalog;
117982
 
 
117983
 
--
117984
 
--
117985
 
 
117986
 
REVOKE ALL ON TABLE pricingscheduleitem FROM PUBLIC;
117987
 
REVOKE ALL ON TABLE pricingscheduleitem FROM admin;
117988
 
GRANT ALL ON TABLE pricingscheduleitem TO admin;
117989
 
GRANT ALL ON TABLE pricingscheduleitem TO xtrole;
117990
 
 
117991
 
 
117992
 
SET search_path = public, pg_catalog;
117993
 
 
117994
 
--
117995
 
--
117996
 
 
117997
 
REVOKE ALL ON TABLE ipsitemchar FROM PUBLIC;
117998
 
REVOKE ALL ON TABLE ipsitemchar FROM admin;
117999
 
GRANT ALL ON TABLE ipsitemchar TO admin;
118000
 
GRANT ALL ON TABLE ipsitemchar TO xtrole;
118001
 
 
118002
 
 
118003
 
SET search_path = api, pg_catalog;
118004
 
 
118005
 
--
118006
 
--
118007
 
 
118008
 
REVOKE ALL ON TABLE pricingscheduleitemchar FROM PUBLIC;
118009
 
REVOKE ALL ON TABLE pricingscheduleitemchar FROM admin;
118010
 
GRANT ALL ON TABLE pricingscheduleitemchar TO admin;
118011
 
GRANT ALL ON TABLE pricingscheduleitemchar TO xtrole;
118012
 
 
118013
 
 
118014
 
--
118015
 
--
118016
 
 
118017
 
REVOKE ALL ON TABLE project FROM PUBLIC;
118018
 
REVOKE ALL ON TABLE project FROM admin;
118019
 
GRANT ALL ON TABLE project TO admin;
118020
 
GRANT ALL ON TABLE project TO xtrole;
118021
 
 
118022
 
 
118023
 
--
118024
 
--
118025
 
 
118026
 
REVOKE ALL ON TABLE projectcomment FROM PUBLIC;
118027
 
REVOKE ALL ON TABLE projectcomment FROM admin;
118028
 
GRANT ALL ON TABLE projectcomment TO admin;
118029
 
GRANT ALL ON TABLE projectcomment TO xtrole;
118030
 
 
118031
 
 
118032
 
SET search_path = public, pg_catalog;
118033
 
 
118034
 
--
118035
 
--
118036
 
 
118037
 
REVOKE ALL ON SEQUENCE cust_cust_id_seq FROM PUBLIC;
118038
 
REVOKE ALL ON SEQUENCE cust_cust_id_seq FROM admin;
118039
 
GRANT ALL ON SEQUENCE cust_cust_id_seq TO admin;
118040
 
GRANT ALL ON SEQUENCE cust_cust_id_seq TO xtrole;
118041
 
 
118042
 
 
118043
 
--
118044
 
--
118045
 
 
118046
 
REVOKE ALL ON TABLE prospect FROM PUBLIC;
118047
 
REVOKE ALL ON TABLE prospect FROM admin;
118048
 
GRANT ALL ON TABLE prospect TO admin;
118049
 
GRANT ALL ON TABLE prospect TO xtrole;
118050
 
 
118051
 
 
118052
 
SET search_path = api, pg_catalog;
118053
 
 
118054
 
--
118055
 
--
118056
 
 
118057
 
REVOKE ALL ON TABLE prospect FROM PUBLIC;
118058
 
REVOKE ALL ON TABLE prospect FROM admin;
118059
 
GRANT ALL ON TABLE prospect TO admin;
118060
 
GRANT ALL ON TABLE prospect TO xtrole;
118061
 
 
118062
 
 
118063
 
SET search_path = public, pg_catalog;
118064
 
 
118065
 
--
118066
 
--
118067
 
 
118068
 
REVOKE ALL ON TABLE expcat FROM PUBLIC;
118069
 
REVOKE ALL ON TABLE expcat FROM admin;
118070
 
GRANT ALL ON TABLE expcat TO admin;
118071
 
GRANT ALL ON TABLE expcat TO xtrole;
118072
 
 
118073
 
 
118074
 
--
118075
 
--
118076
 
 
118077
 
REVOKE ALL ON TABLE womatl FROM PUBLIC;
118078
 
REVOKE ALL ON TABLE womatl FROM admin;
118079
 
GRANT ALL ON TABLE womatl TO admin;
118080
 
GRANT ALL ON TABLE womatl TO xtrole;
118081
 
 
118082
 
 
118083
 
SET search_path = api, pg_catalog;
118084
 
 
118085
 
--
118086
 
--
118087
 
 
118088
 
REVOKE ALL ON TABLE purchaseline FROM PUBLIC;
118089
 
REVOKE ALL ON TABLE purchaseline FROM admin;
118090
 
GRANT ALL ON TABLE purchaseline TO admin;
118091
 
GRANT ALL ON TABLE purchaseline TO xtrole;
118092
 
 
118093
 
 
118094
 
--
118095
 
--
118096
 
 
118097
 
REVOKE ALL ON TABLE purchaselinechar FROM PUBLIC;
118098
 
REVOKE ALL ON TABLE purchaselinechar FROM admin;
118099
 
GRANT ALL ON TABLE purchaselinechar TO admin;
118100
 
GRANT ALL ON TABLE purchaselinechar TO xtrole;
118101
 
 
118102
 
 
118103
 
--
118104
 
--
118105
 
 
118106
 
REVOKE ALL ON TABLE purchaselinecomment FROM PUBLIC;
118107
 
REVOKE ALL ON TABLE purchaselinecomment FROM admin;
118108
 
GRANT ALL ON TABLE purchaselinecomment TO admin;
118109
 
GRANT ALL ON TABLE purchaselinecomment TO xtrole;
118110
 
 
118111
 
 
118112
 
SET search_path = public, pg_catalog;
118113
 
 
118114
 
--
118115
 
--
118116
 
 
118117
 
REVOKE ALL ON TABLE tax FROM PUBLIC;
118118
 
REVOKE ALL ON TABLE tax FROM admin;
118119
 
GRANT ALL ON TABLE tax TO admin;
118120
 
GRANT ALL ON TABLE tax TO xtrole;
118121
 
 
118122
 
 
118123
 
--
118124
 
--
118125
 
 
118126
 
REVOKE ALL ON TABLE vendaddrinfo FROM PUBLIC;
118127
 
REVOKE ALL ON TABLE vendaddrinfo FROM admin;
118128
 
GRANT ALL ON TABLE vendaddrinfo TO admin;
118129
 
GRANT ALL ON TABLE vendaddrinfo TO xtrole;
118130
 
 
118131
 
 
118132
 
SET search_path = api, pg_catalog;
118133
 
 
118134
 
--
118135
 
--
118136
 
 
118137
 
REVOKE ALL ON TABLE purchaseorder FROM PUBLIC;
118138
 
REVOKE ALL ON TABLE purchaseorder FROM admin;
118139
 
GRANT ALL ON TABLE purchaseorder TO admin;
118140
 
GRANT ALL ON TABLE purchaseorder TO xtrole;
118141
 
 
118142
 
 
118143
 
--
118144
 
--
118145
 
 
118146
 
REVOKE ALL ON TABLE purchaseordercomment FROM PUBLIC;
118147
 
REVOKE ALL ON TABLE purchaseordercomment FROM admin;
118148
 
GRANT ALL ON TABLE purchaseordercomment TO admin;
118149
 
GRANT ALL ON TABLE purchaseordercomment TO xtrole;
118150
 
 
118151
 
 
118152
 
SET search_path = public, pg_catalog;
118153
 
 
118154
 
--
118155
 
--
118156
 
 
118157
 
REVOKE ALL ON TABLE quhead FROM PUBLIC;
118158
 
REVOKE ALL ON TABLE quhead FROM admin;
118159
 
GRANT ALL ON TABLE quhead TO admin;
118160
 
GRANT ALL ON TABLE quhead TO xtrole;
118161
 
 
118162
 
 
118163
 
SET search_path = api, pg_catalog;
118164
 
 
118165
 
--
118166
 
--
118167
 
 
118168
 
REVOKE ALL ON TABLE quote FROM PUBLIC;
118169
 
REVOKE ALL ON TABLE quote FROM admin;
118170
 
GRANT ALL ON TABLE quote TO admin;
118171
 
GRANT ALL ON TABLE quote TO xtrole;
118172
 
 
118173
 
 
118174
 
--
118175
 
--
118176
 
 
118177
 
REVOKE ALL ON TABLE quotecomment FROM PUBLIC;
118178
 
REVOKE ALL ON TABLE quotecomment FROM admin;
118179
 
GRANT ALL ON TABLE quotecomment TO admin;
118180
 
GRANT ALL ON TABLE quotecomment TO xtrole;
118181
 
 
118182
 
 
118183
 
SET search_path = public, pg_catalog;
118184
 
 
118185
 
--
118186
 
--
118187
 
 
118188
 
REVOKE ALL ON TABLE quitem FROM PUBLIC;
118189
 
REVOKE ALL ON TABLE quitem FROM admin;
118190
 
GRANT ALL ON TABLE quitem TO admin;
118191
 
GRANT ALL ON TABLE quitem TO xtrole;
118192
 
 
118193
 
 
118194
 
SET search_path = api, pg_catalog;
118195
 
 
118196
 
--
118197
 
--
118198
 
 
118199
 
REVOKE ALL ON TABLE quoteline FROM PUBLIC;
118200
 
REVOKE ALL ON TABLE quoteline FROM admin;
118201
 
GRANT ALL ON TABLE quoteline TO admin;
118202
 
GRANT ALL ON TABLE quoteline TO xtrole;
118203
 
 
118204
 
 
118205
 
--
118206
 
--
118207
 
 
118208
 
REVOKE ALL ON TABLE quotelinechar FROM PUBLIC;
118209
 
REVOKE ALL ON TABLE quotelinechar FROM admin;
118210
 
GRANT ALL ON TABLE quotelinechar TO admin;
118211
 
GRANT ALL ON TABLE quotelinechar TO xtrole;
118212
 
 
118213
 
 
118214
 
--
118215
 
--
118216
 
 
118217
 
REVOKE ALL ON TABLE quotelinecomment FROM PUBLIC;
118218
 
REVOKE ALL ON TABLE quotelinecomment FROM admin;
118219
 
GRANT ALL ON TABLE quotelinecomment TO admin;
118220
 
GRANT ALL ON TABLE quotelinecomment TO xtrole;
118221
 
 
118222
 
 
118223
 
SET search_path = public, pg_catalog;
118224
 
 
118225
 
--
118226
 
--
118227
 
 
118228
 
REVOKE ALL ON TABLE aropenalloc FROM PUBLIC;
118229
 
REVOKE ALL ON TABLE aropenalloc FROM admin;
118230
 
GRANT ALL ON TABLE aropenalloc TO admin;
118231
 
GRANT ALL ON TABLE aropenalloc TO xtrole;
118232
 
 
118233
 
 
118234
 
SET search_path = api, pg_catalog;
118235
 
 
118236
 
--
118237
 
--
118238
 
 
118239
 
REVOKE ALL ON TABLE salescredit FROM PUBLIC;
118240
 
REVOKE ALL ON TABLE salescredit FROM admin;
118241
 
GRANT ALL ON TABLE salescredit TO admin;
118242
 
GRANT ALL ON TABLE salescredit TO xtrole;
118243
 
 
118244
 
 
118245
 
SET search_path = public, pg_catalog;
118246
 
 
118247
 
--
118248
 
--
118249
 
 
118250
 
REVOKE ALL ON TABLE cohist FROM PUBLIC;
118251
 
REVOKE ALL ON TABLE cohist FROM admin;
118252
 
GRANT ALL ON TABLE cohist TO admin;
118253
 
GRANT ALL ON TABLE cohist TO xtrole;
118254
 
 
118255
 
 
118256
 
--
118257
 
--
118258
 
 
118259
 
REVOKE ALL ON TABLE taxhist FROM PUBLIC;
118260
 
REVOKE ALL ON TABLE taxhist FROM admin;
118261
 
GRANT ALL ON TABLE taxhist TO admin;
118262
 
GRANT ALL ON TABLE taxhist TO xtrole;
118263
 
 
118264
 
 
118265
 
--
118266
 
--
118267
 
 
118268
 
REVOKE ALL ON TABLE cohisttax FROM PUBLIC;
118269
 
REVOKE ALL ON TABLE cohisttax FROM admin;
118270
 
GRANT ALL ON TABLE cohisttax TO admin;
118271
 
GRANT ALL ON TABLE cohisttax TO xtrole;
118272
 
 
118273
 
 
118274
 
SET search_path = api, pg_catalog;
118275
 
 
118276
 
--
118277
 
--
118278
 
 
118279
 
REVOKE ALL ON TABLE saleshistory FROM PUBLIC;
118280
 
REVOKE ALL ON TABLE saleshistory FROM admin;
118281
 
GRANT ALL ON TABLE saleshistory TO admin;
118282
 
GRANT ALL ON TABLE saleshistory TO xtrole;
118283
 
 
118284
 
 
118285
 
--
118286
 
--
118287
 
 
118288
 
REVOKE ALL ON TABLE saleslinechar FROM PUBLIC;
118289
 
REVOKE ALL ON TABLE saleslinechar FROM admin;
118290
 
GRANT ALL ON TABLE saleslinechar TO admin;
118291
 
GRANT ALL ON TABLE saleslinechar TO xtrole;
118292
 
 
118293
 
 
118294
 
--
118295
 
--
118296
 
 
118297
 
REVOKE ALL ON TABLE saleslinecomment FROM PUBLIC;
118298
 
REVOKE ALL ON TABLE saleslinecomment FROM admin;
118299
 
GRANT ALL ON TABLE saleslinecomment TO admin;
118300
 
GRANT ALL ON TABLE saleslinecomment TO xtrole;
118301
 
 
118302
 
 
118303
 
--
118304
 
--
118305
 
 
118306
 
REVOKE ALL ON TABLE salesorder FROM PUBLIC;
118307
 
REVOKE ALL ON TABLE salesorder FROM admin;
118308
 
GRANT ALL ON TABLE salesorder TO admin;
118309
 
GRANT ALL ON TABLE salesorder TO xtrole;
118310
 
 
118311
 
 
118312
 
--
118313
 
--
118314
 
 
118315
 
REVOKE ALL ON TABLE salesordercomment FROM PUBLIC;
118316
 
REVOKE ALL ON TABLE salesordercomment FROM admin;
118317
 
GRANT ALL ON TABLE salesordercomment TO admin;
118318
 
GRANT ALL ON TABLE salesordercomment TO xtrole;
118319
 
 
118320
 
 
118321
 
--
118322
 
--
118323
 
 
118324
 
REVOKE ALL ON TABLE salesrep FROM PUBLIC;
118325
 
REVOKE ALL ON TABLE salesrep FROM admin;
118326
 
GRANT ALL ON TABLE salesrep TO admin;
118327
 
GRANT ALL ON TABLE salesrep TO xtrole;
118328
 
 
118329
 
 
118330
 
SET search_path = public, pg_catalog;
118331
 
 
118332
 
--
118333
 
--
118334
 
 
118335
 
REVOKE ALL ON TABLE shipvia FROM PUBLIC;
118336
 
REVOKE ALL ON TABLE shipvia FROM admin;
118337
 
GRANT ALL ON TABLE shipvia TO admin;
118338
 
GRANT ALL ON TABLE shipvia TO xtrole;
118339
 
 
118340
 
 
118341
 
--
118342
 
--
118343
 
 
118344
 
REVOKE ALL ON TABLE sitetype FROM PUBLIC;
118345
 
REVOKE ALL ON TABLE sitetype FROM admin;
118346
 
GRANT ALL ON TABLE sitetype TO admin;
118347
 
GRANT ALL ON TABLE sitetype TO xtrole;
118348
 
 
118349
 
 
118350
 
SET search_path = api, pg_catalog;
118351
 
 
118352
 
--
118353
 
--
118354
 
 
118355
 
REVOKE ALL ON TABLE site FROM PUBLIC;
118356
 
REVOKE ALL ON TABLE site FROM admin;
118357
 
GRANT ALL ON TABLE site TO admin;
118358
 
GRANT ALL ON TABLE site TO xtrole;
118359
 
 
118360
 
 
118361
 
--
118362
 
--
118363
 
 
118364
 
REVOKE ALL ON TABLE sitezone FROM PUBLIC;
118365
 
REVOKE ALL ON TABLE sitezone FROM admin;
118366
 
GRANT ALL ON TABLE sitezone TO admin;
118367
 
GRANT ALL ON TABLE sitezone TO xtrole;
118368
 
 
118369
 
 
118370
 
--
118371
 
--
118372
 
 
118373
 
REVOKE ALL ON TABLE task FROM PUBLIC;
118374
 
REVOKE ALL ON TABLE task FROM admin;
118375
 
GRANT ALL ON TABLE task TO admin;
118376
 
GRANT ALL ON TABLE task TO xtrole;
118377
 
 
118378
 
 
118379
 
--
118380
 
--
118381
 
 
118382
 
REVOKE ALL ON TABLE taskcomment FROM PUBLIC;
118383
 
REVOKE ALL ON TABLE taskcomment FROM admin;
118384
 
GRANT ALL ON TABLE taskcomment TO admin;
118385
 
GRANT ALL ON TABLE taskcomment TO xtrole;
118386
 
 
118387
 
 
118388
 
--
118389
 
--
118390
 
 
118391
 
REVOKE ALL ON TABLE todo FROM PUBLIC;
118392
 
REVOKE ALL ON TABLE todo FROM admin;
118393
 
GRANT ALL ON TABLE todo TO admin;
118394
 
GRANT ALL ON TABLE todo TO xtrole;
118395
 
 
118396
 
 
118397
 
SET search_path = public, pg_catalog;
118398
 
 
118399
 
--
118400
 
--
118401
 
 
118402
 
REVOKE ALL ON TABLE vendtype FROM PUBLIC;
118403
 
REVOKE ALL ON TABLE vendtype FROM admin;
118404
 
GRANT ALL ON TABLE vendtype TO admin;
118405
 
GRANT ALL ON TABLE vendtype TO xtrole;
118406
 
 
118407
 
 
118408
 
SET search_path = api, pg_catalog;
118409
 
 
118410
 
--
118411
 
--
118412
 
 
118413
 
REVOKE ALL ON TABLE vendor FROM PUBLIC;
118414
 
REVOKE ALL ON TABLE vendor FROM admin;
118415
 
GRANT ALL ON TABLE vendor TO admin;
118416
 
GRANT ALL ON TABLE vendor TO xtrole;
118417
 
 
118418
 
 
118419
 
--
118420
 
--
118421
 
 
118422
 
REVOKE ALL ON TABLE vendoraddress FROM PUBLIC;
118423
 
REVOKE ALL ON TABLE vendoraddress FROM admin;
118424
 
GRANT ALL ON TABLE vendoraddress TO admin;
118425
 
GRANT ALL ON TABLE vendoraddress TO xtrole;
118426
 
 
118427
 
 
118428
 
--
118429
 
--
118430
 
 
118431
 
REVOKE ALL ON TABLE vendortype FROM PUBLIC;
118432
 
REVOKE ALL ON TABLE vendortype FROM admin;
118433
 
GRANT ALL ON TABLE vendortype TO admin;
118434
 
GRANT ALL ON TABLE vendortype TO xtrole;
118435
 
 
118436
 
 
118437
 
SET search_path = public, pg_catalog;
118438
 
 
118439
 
--
118440
 
--
118441
 
 
118442
 
REVOKE ALL ON TABLE cmd FROM PUBLIC;
118443
 
REVOKE ALL ON TABLE cmd FROM admin;
118444
 
GRANT ALL ON TABLE cmd TO admin;
118445
 
GRANT ALL ON TABLE cmd TO xtrole;
118446
 
 
118447
 
 
118448
 
--
118449
 
--
118450
 
 
118451
 
REVOKE ALL ON SEQUENCE cmd_cmd_id_seq FROM PUBLIC;
118452
 
REVOKE ALL ON SEQUENCE cmd_cmd_id_seq FROM admin;
118453
 
GRANT ALL ON SEQUENCE cmd_cmd_id_seq TO admin;
118454
 
GRANT ALL ON SEQUENCE cmd_cmd_id_seq TO xtrole;
118455
 
 
118456
 
 
118457
 
SET search_path = fixcountry, pg_catalog;
118458
 
 
118459
 
--
118460
 
--
118461
 
 
118462
 
REVOKE ALL ON TABLE pkgcmd FROM PUBLIC;
118463
 
REVOKE ALL ON TABLE pkgcmd FROM admin;
118464
 
GRANT ALL ON TABLE pkgcmd TO admin;
118465
 
GRANT ALL ON TABLE pkgcmd TO xtrole;
118466
 
 
118467
 
 
118468
 
SET search_path = public, pg_catalog;
118469
 
 
118470
 
--
118471
 
--
118472
 
 
118473
 
REVOKE ALL ON TABLE cmdarg FROM PUBLIC;
118474
 
REVOKE ALL ON TABLE cmdarg FROM admin;
118475
 
GRANT ALL ON TABLE cmdarg TO admin;
118476
 
GRANT ALL ON TABLE cmdarg TO xtrole;
118477
 
 
118478
 
 
118479
 
--
118480
 
--
118481
 
 
118482
 
REVOKE ALL ON SEQUENCE cmdarg_cmdarg_id_seq FROM PUBLIC;
118483
 
REVOKE ALL ON SEQUENCE cmdarg_cmdarg_id_seq FROM admin;
118484
 
GRANT ALL ON SEQUENCE cmdarg_cmdarg_id_seq TO admin;
118485
 
GRANT ALL ON SEQUENCE cmdarg_cmdarg_id_seq TO xtrole;
118486
 
 
118487
 
 
118488
 
SET search_path = fixcountry, pg_catalog;
118489
 
 
118490
 
--
118491
 
--
118492
 
 
118493
 
REVOKE ALL ON TABLE pkgcmdarg FROM PUBLIC;
118494
 
REVOKE ALL ON TABLE pkgcmdarg FROM admin;
118495
 
GRANT ALL ON TABLE pkgcmdarg TO admin;
118496
 
GRANT ALL ON TABLE pkgcmdarg TO xtrole;
118497
 
 
118498
 
 
118499
 
SET search_path = public, pg_catalog;
118500
 
 
118501
 
--
118502
 
--
118503
 
 
118504
 
REVOKE ALL ON SEQUENCE image_image_id_seq FROM PUBLIC;
118505
 
REVOKE ALL ON SEQUENCE image_image_id_seq FROM admin;
118506
 
GRANT ALL ON SEQUENCE image_image_id_seq TO admin;
118507
 
GRANT ALL ON SEQUENCE image_image_id_seq TO xtrole;
118508
 
 
118509
 
 
118510
 
SET search_path = fixcountry, pg_catalog;
118511
 
 
118512
 
--
118513
 
--
118514
 
 
118515
 
REVOKE ALL ON TABLE pkgimage FROM PUBLIC;
118516
 
REVOKE ALL ON TABLE pkgimage FROM admin;
118517
 
GRANT ALL ON TABLE pkgimage TO admin;
118518
 
GRANT ALL ON TABLE pkgimage TO xtrole;
118519
 
 
118520
 
 
118521
 
SET search_path = public, pg_catalog;
118522
 
 
118523
 
--
118524
 
--
118525
 
 
118526
 
REVOKE ALL ON TABLE metasql FROM PUBLIC;
118527
 
REVOKE ALL ON TABLE metasql FROM admin;
118528
 
GRANT ALL ON TABLE metasql TO admin;
118529
 
GRANT ALL ON TABLE metasql TO xtrole;
118530
 
 
118531
 
 
118532
 
--
118533
 
--
118534
 
 
118535
 
REVOKE ALL ON SEQUENCE metasql_metasql_id_seq FROM PUBLIC;
118536
 
REVOKE ALL ON SEQUENCE metasql_metasql_id_seq FROM admin;
118537
 
GRANT ALL ON SEQUENCE metasql_metasql_id_seq TO admin;
118538
 
GRANT ALL ON SEQUENCE metasql_metasql_id_seq TO xtrole;
118539
 
 
118540
 
 
118541
 
SET search_path = fixcountry, pg_catalog;
118542
 
 
118543
 
--
118544
 
--
118545
 
 
118546
 
REVOKE ALL ON TABLE pkgmetasql FROM PUBLIC;
118547
 
REVOKE ALL ON TABLE pkgmetasql FROM admin;
118548
 
GRANT ALL ON TABLE pkgmetasql TO admin;
118549
 
GRANT ALL ON TABLE pkgmetasql TO xtrole;
118550
 
 
118551
 
 
118552
 
SET search_path = public, pg_catalog;
118553
 
 
118554
 
--
118555
 
--
118556
 
 
118557
 
REVOKE ALL ON TABLE priv FROM PUBLIC;
118558
 
REVOKE ALL ON TABLE priv FROM admin;
118559
 
GRANT ALL ON TABLE priv TO admin;
118560
 
GRANT ALL ON TABLE priv TO xtrole;
118561
 
 
118562
 
 
118563
 
--
118564
 
--
118565
 
 
118566
 
REVOKE ALL ON SEQUENCE priv_priv_id_seq FROM PUBLIC;
118567
 
REVOKE ALL ON SEQUENCE priv_priv_id_seq FROM admin;
118568
 
GRANT ALL ON SEQUENCE priv_priv_id_seq TO admin;
118569
 
GRANT ALL ON SEQUENCE priv_priv_id_seq TO xtrole;
118570
 
 
118571
 
 
118572
 
SET search_path = fixcountry, pg_catalog;
118573
 
 
118574
 
--
118575
 
--
118576
 
 
118577
 
REVOKE ALL ON TABLE pkgpriv FROM PUBLIC;
118578
 
REVOKE ALL ON TABLE pkgpriv FROM admin;
118579
 
GRANT ALL ON TABLE pkgpriv TO admin;
118580
 
GRANT ALL ON TABLE pkgpriv TO xtrole;
118581
 
 
118582
 
 
118583
 
SET search_path = public, pg_catalog;
118584
 
 
118585
 
--
118586
 
--
118587
 
 
118588
 
REVOKE ALL ON TABLE report FROM PUBLIC;
118589
 
REVOKE ALL ON TABLE report FROM admin;
118590
 
GRANT ALL ON TABLE report TO admin;
118591
 
GRANT ALL ON TABLE report TO xtrole;
118592
 
 
118593
 
 
118594
 
--
118595
 
--
118596
 
 
118597
 
REVOKE ALL ON SEQUENCE report_report_id_seq FROM PUBLIC;
118598
 
REVOKE ALL ON SEQUENCE report_report_id_seq FROM admin;
118599
 
GRANT ALL ON SEQUENCE report_report_id_seq TO admin;
118600
 
GRANT ALL ON SEQUENCE report_report_id_seq TO xtrole;
118601
 
 
118602
 
 
118603
 
SET search_path = fixcountry, pg_catalog;
118604
 
 
118605
 
--
118606
 
--
118607
 
 
118608
 
REVOKE ALL ON TABLE pkgreport FROM PUBLIC;
118609
 
REVOKE ALL ON TABLE pkgreport FROM admin;
118610
 
GRANT ALL ON TABLE pkgreport TO admin;
118611
 
GRANT ALL ON TABLE pkgreport TO xtrole;
118612
 
 
118613
 
 
118614
 
SET search_path = public, pg_catalog;
118615
 
 
118616
 
--
118617
 
--
118618
 
 
118619
 
REVOKE ALL ON TABLE script FROM PUBLIC;
118620
 
REVOKE ALL ON TABLE script FROM admin;
118621
 
GRANT ALL ON TABLE script TO admin;
118622
 
GRANT ALL ON TABLE script TO xtrole;
118623
 
 
118624
 
 
118625
 
--
118626
 
--
118627
 
 
118628
 
REVOKE ALL ON SEQUENCE script_script_id_seq FROM PUBLIC;
118629
 
REVOKE ALL ON SEQUENCE script_script_id_seq FROM admin;
118630
 
GRANT ALL ON SEQUENCE script_script_id_seq TO admin;
118631
 
GRANT ALL ON SEQUENCE script_script_id_seq TO xtrole;
118632
 
 
118633
 
 
118634
 
SET search_path = fixcountry, pg_catalog;
118635
 
 
118636
 
--
118637
 
--
118638
 
 
118639
 
REVOKE ALL ON TABLE pkgscript FROM PUBLIC;
118640
 
REVOKE ALL ON TABLE pkgscript FROM admin;
118641
 
GRANT ALL ON TABLE pkgscript TO admin;
118642
 
GRANT ALL ON TABLE pkgscript TO xtrole;
118643
 
 
118644
 
 
118645
 
SET search_path = public, pg_catalog;
118646
 
 
118647
 
--
118648
 
--
118649
 
 
118650
 
REVOKE ALL ON TABLE uiform FROM PUBLIC;
118651
 
REVOKE ALL ON TABLE uiform FROM admin;
118652
 
GRANT ALL ON TABLE uiform TO admin;
118653
 
GRANT ALL ON TABLE uiform TO xtrole;
118654
 
 
118655
 
 
118656
 
--
118657
 
--
118658
 
 
118659
 
REVOKE ALL ON SEQUENCE uiform_uiform_id_seq FROM PUBLIC;
118660
 
REVOKE ALL ON SEQUENCE uiform_uiform_id_seq FROM admin;
118661
 
GRANT ALL ON SEQUENCE uiform_uiform_id_seq TO admin;
118662
 
GRANT ALL ON SEQUENCE uiform_uiform_id_seq TO xtrole;
118663
 
 
118664
 
 
118665
 
SET search_path = fixcountry, pg_catalog;
118666
 
 
118667
 
--
118668
 
--
118669
 
 
118670
 
REVOKE ALL ON TABLE pkguiform FROM PUBLIC;
118671
 
REVOKE ALL ON TABLE pkguiform FROM admin;
118672
 
GRANT ALL ON TABLE pkguiform TO admin;
118673
 
GRANT ALL ON TABLE pkguiform TO xtrole;
118674
 
 
118675
 
 
118676
 
SET search_path = public, pg_catalog;
118677
 
 
118678
 
--
118679
 
--
118680
 
 
118681
 
REVOKE ALL ON TABLE acalitem FROM PUBLIC;
118682
 
REVOKE ALL ON TABLE acalitem FROM admin;
118683
 
GRANT ALL ON TABLE acalitem TO admin;
118684
 
GRANT ALL ON TABLE acalitem TO xtrole;
118685
 
 
118686
 
 
118687
 
--
118688
 
--
118689
 
 
118690
 
REVOKE ALL ON SEQUENCE accnt_accnt_id_seq FROM PUBLIC;
118691
 
REVOKE ALL ON SEQUENCE accnt_accnt_id_seq FROM admin;
118692
 
GRANT ALL ON SEQUENCE accnt_accnt_id_seq TO admin;
118693
 
GRANT ALL ON SEQUENCE accnt_accnt_id_seq TO xtrole;
118694
 
 
118695
 
 
118696
 
--
118697
 
--
118698
 
 
118699
 
REVOKE ALL ON SEQUENCE addr_addr_id_seq FROM PUBLIC;
118700
 
REVOKE ALL ON SEQUENCE addr_addr_id_seq FROM admin;
118701
 
GRANT ALL ON SEQUENCE addr_addr_id_seq TO admin;
118702
 
GRANT ALL ON SEQUENCE addr_addr_id_seq TO xtrole;
118703
 
 
118704
 
 
118705
 
--
118706
 
--
118707
 
 
118708
 
REVOKE ALL ON TABLE address FROM PUBLIC;
118709
 
REVOKE ALL ON TABLE address FROM admin;
118710
 
GRANT ALL ON TABLE address TO admin;
118711
 
GRANT ALL ON TABLE address TO xtrole;
118712
 
 
118713
 
 
118714
 
--
118715
 
--
118716
 
 
118717
 
REVOKE ALL ON TABLE alarm FROM PUBLIC;
118718
 
REVOKE ALL ON TABLE alarm FROM admin;
118719
 
GRANT ALL ON TABLE alarm TO admin;
118720
 
GRANT ALL ON TABLE alarm TO xtrole;
118721
 
 
118722
 
 
118723
 
--
118724
 
--
118725
 
 
118726
 
REVOKE ALL ON SEQUENCE alarm_alarm_id_seq FROM PUBLIC;
118727
 
REVOKE ALL ON SEQUENCE alarm_alarm_id_seq FROM admin;
118728
 
GRANT ALL ON SEQUENCE alarm_alarm_id_seq TO admin;
118729
 
GRANT ALL ON SEQUENCE alarm_alarm_id_seq TO xtrole;
118730
 
 
118731
 
 
118732
 
--
118733
 
--
118734
 
 
118735
 
REVOKE ALL ON TABLE apaccnt FROM PUBLIC;
118736
 
REVOKE ALL ON TABLE apaccnt FROM admin;
118737
 
GRANT ALL ON TABLE apaccnt TO admin;
118738
 
GRANT ALL ON TABLE apaccnt TO xtrole;
118739
 
 
118740
 
 
118741
 
--
118742
 
--
118743
 
 
118744
 
REVOKE ALL ON SEQUENCE apaccnt_apaccnt_id_seq FROM PUBLIC;
118745
 
REVOKE ALL ON SEQUENCE apaccnt_apaccnt_id_seq FROM admin;
118746
 
GRANT ALL ON SEQUENCE apaccnt_apaccnt_id_seq TO admin;
118747
 
GRANT ALL ON SEQUENCE apaccnt_apaccnt_id_seq TO xtrole;
118748
 
 
118749
 
 
118750
 
--
118751
 
--
118752
 
 
118753
 
REVOKE ALL ON TABLE apapply FROM PUBLIC;
118754
 
REVOKE ALL ON TABLE apapply FROM admin;
118755
 
GRANT ALL ON TABLE apapply TO admin;
118756
 
GRANT ALL ON TABLE apapply TO xtrole;
118757
 
 
118758
 
 
118759
 
--
118760
 
--
118761
 
 
118762
 
REVOKE ALL ON SEQUENCE apapply_apapply_id_seq FROM PUBLIC;
118763
 
REVOKE ALL ON SEQUENCE apapply_apapply_id_seq FROM admin;
118764
 
GRANT ALL ON SEQUENCE apapply_apapply_id_seq TO admin;
118765
 
GRANT ALL ON SEQUENCE apapply_apapply_id_seq TO xtrole;
118766
 
 
118767
 
 
118768
 
--
118769
 
--
118770
 
 
118771
 
REVOKE ALL ON TABLE checkhead FROM PUBLIC;
118772
 
REVOKE ALL ON TABLE checkhead FROM admin;
118773
 
GRANT ALL ON TABLE checkhead TO admin;
118774
 
GRANT ALL ON TABLE checkhead TO xtrole;
118775
 
 
118776
 
 
118777
 
--
118778
 
--
118779
 
 
118780
 
REVOKE ALL ON TABLE apchk FROM PUBLIC;
118781
 
REVOKE ALL ON TABLE apchk FROM admin;
118782
 
GRANT ALL ON TABLE apchk TO admin;
118783
 
GRANT ALL ON TABLE apchk TO xtrole;
118784
 
 
118785
 
 
118786
 
--
118787
 
--
118788
 
 
118789
 
REVOKE ALL ON TABLE checkitem FROM PUBLIC;
118790
 
REVOKE ALL ON TABLE checkitem FROM admin;
118791
 
GRANT ALL ON TABLE checkitem TO admin;
118792
 
GRANT ALL ON TABLE checkitem TO xtrole;
118793
 
 
118794
 
 
118795
 
--
118796
 
--
118797
 
 
118798
 
REVOKE ALL ON TABLE apchkitem FROM PUBLIC;
118799
 
REVOKE ALL ON TABLE apchkitem FROM admin;
118800
 
GRANT ALL ON TABLE apchkitem TO admin;
118801
 
GRANT ALL ON TABLE apchkitem TO xtrole;
118802
 
 
118803
 
 
118804
 
--
118805
 
--
118806
 
 
118807
 
REVOKE ALL ON TABLE apcreditapply FROM PUBLIC;
118808
 
REVOKE ALL ON TABLE apcreditapply FROM admin;
118809
 
GRANT ALL ON TABLE apcreditapply TO admin;
118810
 
GRANT ALL ON TABLE apcreditapply TO xtrole;
118811
 
 
118812
 
 
118813
 
--
118814
 
--
118815
 
 
118816
 
REVOKE ALL ON SEQUENCE apcreditapply_apcreditapply_id_seq FROM PUBLIC;
118817
 
REVOKE ALL ON SEQUENCE apcreditapply_apcreditapply_id_seq FROM admin;
118818
 
GRANT ALL ON SEQUENCE apcreditapply_apcreditapply_id_seq TO admin;
118819
 
GRANT ALL ON SEQUENCE apcreditapply_apcreditapply_id_seq TO xtrole;
118820
 
 
118821
 
 
118822
 
--
118823
 
--
118824
 
 
118825
 
REVOKE ALL ON TABLE apmemo FROM PUBLIC;
118826
 
REVOKE ALL ON TABLE apmemo FROM admin;
118827
 
GRANT ALL ON TABLE apmemo TO admin;
118828
 
GRANT ALL ON TABLE apmemo TO xtrole;
118829
 
 
118830
 
 
118831
 
--
118832
 
--
118833
 
 
118834
 
REVOKE ALL ON SEQUENCE apopen_apopen_id_seq FROM PUBLIC;
118835
 
REVOKE ALL ON SEQUENCE apopen_apopen_id_seq FROM admin;
118836
 
GRANT ALL ON SEQUENCE apopen_apopen_id_seq TO admin;
118837
 
GRANT ALL ON SEQUENCE apopen_apopen_id_seq TO xtrole;
118838
 
 
118839
 
 
118840
 
--
118841
 
--
118842
 
 
118843
 
REVOKE ALL ON TABLE apopentax FROM PUBLIC;
118844
 
REVOKE ALL ON TABLE apopentax FROM admin;
118845
 
GRANT ALL ON TABLE apopentax TO admin;
118846
 
GRANT ALL ON TABLE apopentax TO xtrole;
118847
 
 
118848
 
 
118849
 
--
118850
 
--
118851
 
 
118852
 
REVOKE ALL ON TABLE apselect FROM PUBLIC;
118853
 
REVOKE ALL ON TABLE apselect FROM admin;
118854
 
GRANT ALL ON TABLE apselect TO admin;
118855
 
GRANT ALL ON TABLE apselect TO xtrole;
118856
 
 
118857
 
 
118858
 
--
118859
 
--
118860
 
 
118861
 
REVOKE ALL ON SEQUENCE apselect_apselect_id_seq FROM PUBLIC;
118862
 
REVOKE ALL ON SEQUENCE apselect_apselect_id_seq FROM admin;
118863
 
GRANT ALL ON SEQUENCE apselect_apselect_id_seq TO admin;
118864
 
GRANT ALL ON SEQUENCE apselect_apselect_id_seq TO xtrole;
118865
 
 
118866
 
 
118867
 
--
118868
 
--
118869
 
 
118870
 
REVOKE ALL ON TABLE araccnt FROM PUBLIC;
118871
 
REVOKE ALL ON TABLE araccnt FROM admin;
118872
 
GRANT ALL ON TABLE araccnt TO admin;
118873
 
GRANT ALL ON TABLE araccnt TO xtrole;
118874
 
 
118875
 
 
118876
 
--
118877
 
--
118878
 
 
118879
 
REVOKE ALL ON SEQUENCE araccnt_araccnt_id_seq FROM PUBLIC;
118880
 
REVOKE ALL ON SEQUENCE araccnt_araccnt_id_seq FROM admin;
118881
 
GRANT ALL ON SEQUENCE araccnt_araccnt_id_seq TO admin;
118882
 
GRANT ALL ON SEQUENCE araccnt_araccnt_id_seq TO xtrole;
118883
 
 
118884
 
 
118885
 
--
118886
 
--
118887
 
 
118888
 
REVOKE ALL ON TABLE arapply FROM PUBLIC;
118889
 
REVOKE ALL ON TABLE arapply FROM admin;
118890
 
GRANT ALL ON TABLE arapply TO admin;
118891
 
GRANT ALL ON TABLE arapply TO xtrole;
118892
 
 
118893
 
 
118894
 
--
118895
 
--
118896
 
 
118897
 
REVOKE ALL ON SEQUENCE arapply_arapply_id_seq FROM PUBLIC;
118898
 
REVOKE ALL ON SEQUENCE arapply_arapply_id_seq FROM admin;
118899
 
GRANT ALL ON SEQUENCE arapply_arapply_id_seq TO admin;
118900
 
GRANT ALL ON SEQUENCE arapply_arapply_id_seq TO xtrole;
118901
 
 
118902
 
 
118903
 
--
118904
 
--
118905
 
 
118906
 
REVOKE ALL ON SEQUENCE cashrcptitem_cashrcptitem_id_seq FROM PUBLIC;
118907
 
REVOKE ALL ON SEQUENCE cashrcptitem_cashrcptitem_id_seq FROM admin;
118908
 
GRANT ALL ON SEQUENCE cashrcptitem_cashrcptitem_id_seq TO admin;
118909
 
GRANT ALL ON SEQUENCE cashrcptitem_cashrcptitem_id_seq TO xtrole;
118910
 
 
118911
 
 
118912
 
--
118913
 
--
118914
 
 
118915
 
REVOKE ALL ON TABLE arcreditapply FROM PUBLIC;
118916
 
REVOKE ALL ON TABLE arcreditapply FROM admin;
118917
 
GRANT ALL ON TABLE arcreditapply TO admin;
118918
 
GRANT ALL ON TABLE arcreditapply TO xtrole;
118919
 
 
118920
 
 
118921
 
--
118922
 
--
118923
 
 
118924
 
REVOKE ALL ON SEQUENCE arcreditapply_arcreditapply_id_seq FROM PUBLIC;
118925
 
REVOKE ALL ON SEQUENCE arcreditapply_arcreditapply_id_seq FROM admin;
118926
 
GRANT ALL ON SEQUENCE arcreditapply_arcreditapply_id_seq TO admin;
118927
 
GRANT ALL ON SEQUENCE arcreditapply_arcreditapply_id_seq TO xtrole;
118928
 
 
118929
 
 
118930
 
--
118931
 
--
118932
 
 
118933
 
REVOKE ALL ON TABLE armemo FROM PUBLIC;
118934
 
REVOKE ALL ON TABLE armemo FROM admin;
118935
 
GRANT ALL ON TABLE armemo TO admin;
118936
 
GRANT ALL ON TABLE armemo TO xtrole;
118937
 
 
118938
 
 
118939
 
--
118940
 
--
118941
 
 
118942
 
REVOKE ALL ON SEQUENCE aropen_aropen_id_seq FROM PUBLIC;
118943
 
REVOKE ALL ON SEQUENCE aropen_aropen_id_seq FROM admin;
118944
 
GRANT ALL ON SEQUENCE aropen_aropen_id_seq TO admin;
118945
 
GRANT ALL ON SEQUENCE aropen_aropen_id_seq TO xtrole;
118946
 
 
118947
 
 
118948
 
--
118949
 
--
118950
 
 
118951
 
REVOKE ALL ON TABLE aropentax FROM PUBLIC;
118952
 
REVOKE ALL ON TABLE aropentax FROM admin;
118953
 
GRANT ALL ON TABLE aropentax TO admin;
118954
 
GRANT ALL ON TABLE aropentax TO xtrole;
118955
 
 
118956
 
 
118957
 
--
118958
 
--
118959
 
 
118960
 
REVOKE ALL ON TABLE asohist FROM PUBLIC;
118961
 
REVOKE ALL ON TABLE asohist FROM admin;
118962
 
GRANT ALL ON TABLE asohist TO admin;
118963
 
GRANT ALL ON TABLE asohist TO xtrole;
118964
 
 
118965
 
 
118966
 
--
118967
 
--
118968
 
 
118969
 
REVOKE ALL ON SEQUENCE asohist_asohist_id_seq FROM PUBLIC;
118970
 
REVOKE ALL ON SEQUENCE asohist_asohist_id_seq FROM admin;
118971
 
GRANT ALL ON SEQUENCE asohist_asohist_id_seq TO admin;
118972
 
GRANT ALL ON SEQUENCE asohist_asohist_id_seq TO xtrole;
118973
 
 
118974
 
 
118975
 
--
118976
 
--
118977
 
 
118978
 
REVOKE ALL ON TABLE asohisttax FROM PUBLIC;
118979
 
REVOKE ALL ON TABLE asohisttax FROM admin;
118980
 
GRANT ALL ON TABLE asohisttax TO admin;
118981
 
GRANT ALL ON TABLE asohisttax TO xtrole;
118982
 
 
118983
 
 
118984
 
--
118985
 
--
118986
 
 
118987
 
REVOKE ALL ON TABLE atlasmap FROM PUBLIC;
118988
 
REVOKE ALL ON TABLE atlasmap FROM admin;
118989
 
GRANT ALL ON TABLE atlasmap TO admin;
118990
 
GRANT ALL ON TABLE atlasmap TO xtrole;
118991
 
 
118992
 
 
118993
 
--
118994
 
--
118995
 
 
118996
 
REVOKE ALL ON SEQUENCE atlasmap_atlasmap_id_seq FROM PUBLIC;
118997
 
REVOKE ALL ON SEQUENCE atlasmap_atlasmap_id_seq FROM admin;
118998
 
GRANT ALL ON SEQUENCE atlasmap_atlasmap_id_seq TO admin;
118999
 
GRANT ALL ON SEQUENCE atlasmap_atlasmap_id_seq TO xtrole;
119000
 
 
119001
 
 
119002
 
--
119003
 
--
119004
 
 
119005
 
REVOKE ALL ON TABLE backup_usr FROM PUBLIC;
119006
 
REVOKE ALL ON TABLE backup_usr FROM admin;
119007
 
GRANT ALL ON TABLE backup_usr TO admin;
119008
 
GRANT ALL ON TABLE backup_usr TO xtrole;
119009
 
 
119010
 
 
119011
 
--
119012
 
--
119013
 
 
119014
 
REVOKE ALL ON SEQUENCE bankaccnt_bankaccnt_id_seq FROM PUBLIC;
119015
 
REVOKE ALL ON SEQUENCE bankaccnt_bankaccnt_id_seq FROM admin;
119016
 
GRANT ALL ON SEQUENCE bankaccnt_bankaccnt_id_seq TO admin;
119017
 
GRANT ALL ON SEQUENCE bankaccnt_bankaccnt_id_seq TO xtrole;
119018
 
 
119019
 
 
119020
 
--
119021
 
--
119022
 
 
119023
 
REVOKE ALL ON TABLE bankadj FROM PUBLIC;
119024
 
REVOKE ALL ON TABLE bankadj FROM admin;
119025
 
GRANT ALL ON TABLE bankadj TO admin;
119026
 
GRANT ALL ON TABLE bankadj TO xtrole;
119027
 
 
119028
 
 
119029
 
--
119030
 
--
119031
 
 
119032
 
REVOKE ALL ON SEQUENCE bankadj_bankadj_id_seq FROM PUBLIC;
119033
 
REVOKE ALL ON SEQUENCE bankadj_bankadj_id_seq FROM admin;
119034
 
GRANT ALL ON SEQUENCE bankadj_bankadj_id_seq TO admin;
119035
 
GRANT ALL ON SEQUENCE bankadj_bankadj_id_seq TO xtrole;
119036
 
 
119037
 
 
119038
 
--
119039
 
--
119040
 
 
119041
 
REVOKE ALL ON TABLE bankadjtype FROM PUBLIC;
119042
 
REVOKE ALL ON TABLE bankadjtype FROM admin;
119043
 
GRANT ALL ON TABLE bankadjtype TO admin;
119044
 
GRANT ALL ON TABLE bankadjtype TO xtrole;
119045
 
 
119046
 
 
119047
 
--
119048
 
--
119049
 
 
119050
 
REVOKE ALL ON SEQUENCE bankadjtype_bankadjtype_id_seq FROM PUBLIC;
119051
 
REVOKE ALL ON SEQUENCE bankadjtype_bankadjtype_id_seq FROM admin;
119052
 
GRANT ALL ON SEQUENCE bankadjtype_bankadjtype_id_seq TO admin;
119053
 
GRANT ALL ON SEQUENCE bankadjtype_bankadjtype_id_seq TO xtrole;
119054
 
 
119055
 
 
119056
 
--
119057
 
--
119058
 
 
119059
 
REVOKE ALL ON TABLE bankrec FROM PUBLIC;
119060
 
REVOKE ALL ON TABLE bankrec FROM admin;
119061
 
GRANT ALL ON TABLE bankrec TO admin;
119062
 
GRANT ALL ON TABLE bankrec TO xtrole;
119063
 
 
119064
 
 
119065
 
--
119066
 
--
119067
 
 
119068
 
REVOKE ALL ON SEQUENCE bankrec_bankrec_id_seq FROM PUBLIC;
119069
 
REVOKE ALL ON SEQUENCE bankrec_bankrec_id_seq FROM admin;
119070
 
GRANT ALL ON SEQUENCE bankrec_bankrec_id_seq TO admin;
119071
 
GRANT ALL ON SEQUENCE bankrec_bankrec_id_seq TO xtrole;
119072
 
 
119073
 
 
119074
 
--
119075
 
--
119076
 
 
119077
 
REVOKE ALL ON TABLE bankrecimport FROM PUBLIC;
119078
 
REVOKE ALL ON TABLE bankrecimport FROM admin;
119079
 
GRANT ALL ON TABLE bankrecimport TO admin;
119080
 
GRANT ALL ON TABLE bankrecimport TO xtrole;
119081
 
 
119082
 
 
119083
 
--
119084
 
--
119085
 
 
119086
 
REVOKE ALL ON SEQUENCE bankrecimport_bankrecimport_id_seq FROM PUBLIC;
119087
 
REVOKE ALL ON SEQUENCE bankrecimport_bankrecimport_id_seq FROM admin;
119088
 
GRANT ALL ON SEQUENCE bankrecimport_bankrecimport_id_seq TO admin;
119089
 
GRANT ALL ON SEQUENCE bankrecimport_bankrecimport_id_seq TO xtrole;
119090
 
 
119091
 
 
119092
 
--
119093
 
--
119094
 
 
119095
 
REVOKE ALL ON TABLE bankrecitem FROM PUBLIC;
119096
 
REVOKE ALL ON TABLE bankrecitem FROM admin;
119097
 
GRANT ALL ON TABLE bankrecitem TO admin;
119098
 
GRANT ALL ON TABLE bankrecitem TO xtrole;
119099
 
 
119100
 
 
119101
 
--
119102
 
--
119103
 
 
119104
 
REVOKE ALL ON SEQUENCE bankrecitem_bankrecitem_id_seq FROM PUBLIC;
119105
 
REVOKE ALL ON SEQUENCE bankrecitem_bankrecitem_id_seq FROM admin;
119106
 
GRANT ALL ON SEQUENCE bankrecitem_bankrecitem_id_seq TO admin;
119107
 
GRANT ALL ON SEQUENCE bankrecitem_bankrecitem_id_seq TO xtrole;
119108
 
 
119109
 
 
119110
 
--
119111
 
--
119112
 
 
119113
 
REVOKE ALL ON SEQUENCE bomhead_bomhead_id_seq FROM PUBLIC;
119114
 
REVOKE ALL ON SEQUENCE bomhead_bomhead_id_seq FROM admin;
119115
 
GRANT ALL ON SEQUENCE bomhead_bomhead_id_seq TO admin;
119116
 
GRANT ALL ON SEQUENCE bomhead_bomhead_id_seq TO xtrole;
119117
 
 
119118
 
 
119119
 
--
119120
 
--
119121
 
 
119122
 
REVOKE ALL ON SEQUENCE bomitem_bomitem_id_seq FROM PUBLIC;
119123
 
REVOKE ALL ON SEQUENCE bomitem_bomitem_id_seq FROM admin;
119124
 
GRANT ALL ON SEQUENCE bomitem_bomitem_id_seq TO admin;
119125
 
GRANT ALL ON SEQUENCE bomitem_bomitem_id_seq TO xtrole;
119126
 
 
119127
 
 
119128
 
--
119129
 
--
119130
 
 
119131
 
REVOKE ALL ON TABLE bomitemcost FROM PUBLIC;
119132
 
REVOKE ALL ON TABLE bomitemcost FROM admin;
119133
 
GRANT ALL ON TABLE bomitemcost TO admin;
119134
 
GRANT ALL ON TABLE bomitemcost TO xtrole;
119135
 
 
119136
 
 
119137
 
--
119138
 
--
119139
 
 
119140
 
REVOKE ALL ON SEQUENCE bomitemcost_bomitemcost_id_seq FROM PUBLIC;
119141
 
REVOKE ALL ON SEQUENCE bomitemcost_bomitemcost_id_seq FROM admin;
119142
 
GRANT ALL ON SEQUENCE bomitemcost_bomitemcost_id_seq TO admin;
119143
 
GRANT ALL ON SEQUENCE bomitemcost_bomitemcost_id_seq TO xtrole;
119144
 
 
119145
 
 
119146
 
--
119147
 
--
119148
 
 
119149
 
REVOKE ALL ON SEQUENCE bomitemsub_bomitemsub_id_seq FROM PUBLIC;
119150
 
REVOKE ALL ON SEQUENCE bomitemsub_bomitemsub_id_seq FROM admin;
119151
 
GRANT ALL ON SEQUENCE bomitemsub_bomitemsub_id_seq TO admin;
119152
 
GRANT ALL ON SEQUENCE bomitemsub_bomitemsub_id_seq TO xtrole;
119153
 
 
119154
 
 
119155
 
--
119156
 
--
119157
 
 
119158
 
REVOKE ALL ON TABLE bomwork FROM PUBLIC;
119159
 
REVOKE ALL ON TABLE bomwork FROM admin;
119160
 
GRANT ALL ON TABLE bomwork TO admin;
119161
 
GRANT ALL ON TABLE bomwork TO xtrole;
119162
 
 
119163
 
 
119164
 
--
119165
 
--
119166
 
 
119167
 
REVOKE ALL ON SEQUENCE bomwork_bomwork_id_seq FROM PUBLIC;
119168
 
REVOKE ALL ON SEQUENCE bomwork_bomwork_id_seq FROM admin;
119169
 
GRANT ALL ON SEQUENCE bomwork_bomwork_id_seq TO admin;
119170
 
GRANT ALL ON SEQUENCE bomwork_bomwork_id_seq TO xtrole;
119171
 
 
119172
 
 
119173
 
--
119174
 
--
119175
 
 
119176
 
REVOKE ALL ON TABLE budget FROM PUBLIC;
119177
 
REVOKE ALL ON TABLE budget FROM admin;
119178
 
GRANT ALL ON TABLE budget TO admin;
119179
 
GRANT ALL ON TABLE budget TO xtrole;
119180
 
 
119181
 
 
119182
 
--
119183
 
--
119184
 
 
119185
 
REVOKE ALL ON SEQUENCE budghead_budghead_id_seq FROM PUBLIC;
119186
 
REVOKE ALL ON SEQUENCE budghead_budghead_id_seq FROM admin;
119187
 
GRANT ALL ON SEQUENCE budghead_budghead_id_seq TO admin;
119188
 
GRANT ALL ON SEQUENCE budghead_budghead_id_seq TO xtrole;
119189
 
 
119190
 
 
119191
 
--
119192
 
--
119193
 
 
119194
 
REVOKE ALL ON SEQUENCE budgitem_budgitem_id_seq FROM PUBLIC;
119195
 
REVOKE ALL ON SEQUENCE budgitem_budgitem_id_seq FROM admin;
119196
 
GRANT ALL ON SEQUENCE budgitem_budgitem_id_seq TO admin;
119197
 
GRANT ALL ON SEQUENCE budgitem_budgitem_id_seq TO xtrole;
119198
 
 
119199
 
 
119200
 
--
119201
 
--
119202
 
 
119203
 
REVOKE ALL ON TABLE calhead FROM PUBLIC;
119204
 
REVOKE ALL ON TABLE calhead FROM admin;
119205
 
GRANT ALL ON TABLE calhead TO admin;
119206
 
GRANT ALL ON TABLE calhead TO xtrole;
119207
 
 
119208
 
 
119209
 
--
119210
 
--
119211
 
 
119212
 
REVOKE ALL ON SEQUENCE calhead_calhead_id_seq FROM PUBLIC;
119213
 
REVOKE ALL ON SEQUENCE calhead_calhead_id_seq FROM admin;
119214
 
GRANT ALL ON SEQUENCE calhead_calhead_id_seq TO admin;
119215
 
GRANT ALL ON SEQUENCE calhead_calhead_id_seq TO xtrole;
119216
 
 
119217
 
 
119218
 
--
119219
 
--
119220
 
 
119221
 
REVOKE ALL ON SEQUENCE carrier_carrier_id_seq FROM PUBLIC;
119222
 
REVOKE ALL ON SEQUENCE carrier_carrier_id_seq FROM admin;
119223
 
GRANT ALL ON SEQUENCE carrier_carrier_id_seq TO admin;
119224
 
GRANT ALL ON SEQUENCE carrier_carrier_id_seq TO xtrole;
119225
 
 
119226
 
 
119227
 
--
119228
 
--
119229
 
 
119230
 
REVOKE ALL ON SEQUENCE cashrcpt_cashrcpt_id_seq FROM PUBLIC;
119231
 
REVOKE ALL ON SEQUENCE cashrcpt_cashrcpt_id_seq FROM admin;
119232
 
GRANT ALL ON SEQUENCE cashrcpt_cashrcpt_id_seq TO admin;
119233
 
GRANT ALL ON SEQUENCE cashrcpt_cashrcpt_id_seq TO xtrole;
119234
 
 
119235
 
 
119236
 
--
119237
 
--
119238
 
 
119239
 
REVOKE ALL ON SEQUENCE cashrcptmisc_cashrcptmisc_id_seq FROM PUBLIC;
119240
 
REVOKE ALL ON SEQUENCE cashrcptmisc_cashrcptmisc_id_seq FROM admin;
119241
 
GRANT ALL ON SEQUENCE cashrcptmisc_cashrcptmisc_id_seq TO admin;
119242
 
GRANT ALL ON SEQUENCE cashrcptmisc_cashrcptmisc_id_seq TO xtrole;
119243
 
 
119244
 
 
119245
 
--
119246
 
--
119247
 
 
119248
 
REVOKE ALL ON SEQUENCE ccard_ccard_id_seq FROM PUBLIC;
119249
 
REVOKE ALL ON SEQUENCE ccard_ccard_id_seq FROM admin;
119250
 
GRANT ALL ON SEQUENCE ccard_ccard_id_seq TO admin;
119251
 
GRANT ALL ON SEQUENCE ccard_ccard_id_seq TO xtrole;
119252
 
 
119253
 
 
119254
 
--
119255
 
--
119256
 
 
119257
 
REVOKE ALL ON TABLE ccardaud FROM PUBLIC;
119258
 
REVOKE ALL ON TABLE ccardaud FROM admin;
119259
 
GRANT ALL ON TABLE ccardaud TO admin;
119260
 
GRANT ALL ON TABLE ccardaud TO xtrole;
119261
 
 
119262
 
 
119263
 
--
119264
 
--
119265
 
 
119266
 
REVOKE ALL ON SEQUENCE ccardaud_ccardaud_id_seq FROM PUBLIC;
119267
 
REVOKE ALL ON SEQUENCE ccardaud_ccardaud_id_seq FROM admin;
119268
 
GRANT ALL ON SEQUENCE ccardaud_ccardaud_id_seq TO admin;
119269
 
GRANT ALL ON SEQUENCE ccardaud_ccardaud_id_seq TO xtrole;
119270
 
 
119271
 
 
119272
 
--
119273
 
--
119274
 
 
119275
 
REVOKE ALL ON TABLE ccbank FROM PUBLIC;
119276
 
REVOKE ALL ON TABLE ccbank FROM admin;
119277
 
GRANT ALL ON TABLE ccbank TO admin;
119278
 
GRANT ALL ON TABLE ccbank TO xtrole;
119279
 
 
119280
 
 
119281
 
--
119282
 
--
119283
 
 
119284
 
REVOKE ALL ON SEQUENCE ccbank_ccbank_id_seq FROM PUBLIC;
119285
 
REVOKE ALL ON SEQUENCE ccbank_ccbank_id_seq FROM admin;
119286
 
GRANT ALL ON SEQUENCE ccbank_ccbank_id_seq TO admin;
119287
 
GRANT ALL ON SEQUENCE ccbank_ccbank_id_seq TO xtrole;
119288
 
 
119289
 
 
119290
 
--
119291
 
--
119292
 
 
119293
 
REVOKE ALL ON TABLE ccpay FROM PUBLIC;
119294
 
REVOKE ALL ON TABLE ccpay FROM admin;
119295
 
GRANT ALL ON TABLE ccpay TO admin;
119296
 
GRANT ALL ON TABLE ccpay TO xtrole;
119297
 
 
119298
 
 
119299
 
--
119300
 
--
119301
 
 
119302
 
REVOKE ALL ON SEQUENCE ccpay_ccpay_id_seq FROM PUBLIC;
119303
 
REVOKE ALL ON SEQUENCE ccpay_ccpay_id_seq FROM admin;
119304
 
GRANT ALL ON SEQUENCE ccpay_ccpay_id_seq TO admin;
119305
 
GRANT ALL ON SEQUENCE ccpay_ccpay_id_seq TO xtrole;
119306
 
 
119307
 
 
119308
 
--
119309
 
--
119310
 
 
119311
 
REVOKE ALL ON SEQUENCE char_char_id_seq FROM PUBLIC;
119312
 
REVOKE ALL ON SEQUENCE char_char_id_seq FROM admin;
119313
 
GRANT ALL ON SEQUENCE char_char_id_seq TO admin;
119314
 
GRANT ALL ON SEQUENCE char_char_id_seq TO xtrole;
119315
 
 
119316
 
 
119317
 
--
119318
 
--
119319
 
 
119320
 
REVOKE ALL ON SEQUENCE charass_charass_id_seq FROM PUBLIC;
119321
 
REVOKE ALL ON SEQUENCE charass_charass_id_seq FROM admin;
119322
 
GRANT ALL ON SEQUENCE charass_charass_id_seq TO admin;
119323
 
GRANT ALL ON SEQUENCE charass_charass_id_seq TO xtrole;
119324
 
 
119325
 
 
119326
 
--
119327
 
--
119328
 
 
119329
 
REVOKE ALL ON TABLE charopt FROM PUBLIC;
119330
 
REVOKE ALL ON TABLE charopt FROM admin;
119331
 
GRANT ALL ON TABLE charopt TO admin;
119332
 
GRANT ALL ON TABLE charopt TO xtrole;
119333
 
 
119334
 
 
119335
 
--
119336
 
--
119337
 
 
119338
 
REVOKE ALL ON SEQUENCE charopt_charopt_id_seq FROM PUBLIC;
119339
 
REVOKE ALL ON SEQUENCE charopt_charopt_id_seq FROM admin;
119340
 
GRANT ALL ON SEQUENCE charopt_charopt_id_seq TO admin;
119341
 
GRANT ALL ON SEQUENCE charopt_charopt_id_seq TO xtrole;
119342
 
 
119343
 
 
119344
 
--
119345
 
--
119346
 
 
119347
 
REVOKE ALL ON SEQUENCE checkhead_checkhead_id_seq FROM PUBLIC;
119348
 
REVOKE ALL ON SEQUENCE checkhead_checkhead_id_seq FROM admin;
119349
 
GRANT ALL ON SEQUENCE checkhead_checkhead_id_seq TO admin;
119350
 
GRANT ALL ON SEQUENCE checkhead_checkhead_id_seq TO xtrole;
119351
 
 
119352
 
 
119353
 
--
119354
 
--
119355
 
 
119356
 
REVOKE ALL ON SEQUENCE checkitem_checkitem_id_seq FROM PUBLIC;
119357
 
REVOKE ALL ON SEQUENCE checkitem_checkitem_id_seq FROM admin;
119358
 
GRANT ALL ON SEQUENCE checkitem_checkitem_id_seq TO admin;
119359
 
GRANT ALL ON SEQUENCE checkitem_checkitem_id_seq TO xtrole;
119360
 
 
119361
 
 
119362
 
--
119363
 
--
119364
 
 
119365
 
REVOKE ALL ON TABLE checkrecip FROM PUBLIC;
119366
 
REVOKE ALL ON TABLE checkrecip FROM admin;
119367
 
GRANT ALL ON TABLE checkrecip TO admin;
119368
 
GRANT ALL ON TABLE checkrecip TO xtrole;
119369
 
 
119370
 
 
119371
 
--
119372
 
--
119373
 
 
119374
 
REVOKE ALL ON SEQUENCE classcode_classcode_id_seq FROM PUBLIC;
119375
 
REVOKE ALL ON SEQUENCE classcode_classcode_id_seq FROM admin;
119376
 
GRANT ALL ON SEQUENCE classcode_classcode_id_seq TO admin;
119377
 
GRANT ALL ON SEQUENCE classcode_classcode_id_seq TO xtrole;
119378
 
 
119379
 
 
119380
 
--
119381
 
--
119382
 
 
119383
 
REVOKE ALL ON SEQUENCE cmhead_cmhead_id_seq FROM PUBLIC;
119384
 
REVOKE ALL ON SEQUENCE cmhead_cmhead_id_seq FROM admin;
119385
 
GRANT ALL ON SEQUENCE cmhead_cmhead_id_seq TO admin;
119386
 
GRANT ALL ON SEQUENCE cmhead_cmhead_id_seq TO xtrole;
119387
 
 
119388
 
 
119389
 
--
119390
 
--
119391
 
 
119392
 
REVOKE ALL ON TABLE cmheadtax FROM PUBLIC;
119393
 
REVOKE ALL ON TABLE cmheadtax FROM admin;
119394
 
GRANT ALL ON TABLE cmheadtax TO admin;
119395
 
GRANT ALL ON TABLE cmheadtax TO xtrole;
119396
 
 
119397
 
 
119398
 
--
119399
 
--
119400
 
 
119401
 
REVOKE ALL ON SEQUENCE cmitem_cmitem_id_seq FROM PUBLIC;
119402
 
REVOKE ALL ON SEQUENCE cmitem_cmitem_id_seq FROM admin;
119403
 
GRANT ALL ON SEQUENCE cmitem_cmitem_id_seq TO admin;
119404
 
GRANT ALL ON SEQUENCE cmitem_cmitem_id_seq TO xtrole;
119405
 
 
119406
 
 
119407
 
--
119408
 
--
119409
 
 
119410
 
REVOKE ALL ON TABLE cmitemtax FROM PUBLIC;
119411
 
REVOKE ALL ON TABLE cmitemtax FROM admin;
119412
 
GRANT ALL ON TABLE cmitemtax TO admin;
119413
 
GRANT ALL ON TABLE cmitemtax TO xtrole;
119414
 
 
119415
 
 
119416
 
--
119417
 
--
119418
 
 
119419
 
REVOKE ALL ON SEQUENCE cmnttype_cmnttype_id_seq FROM PUBLIC;
119420
 
REVOKE ALL ON SEQUENCE cmnttype_cmnttype_id_seq FROM admin;
119421
 
GRANT ALL ON SEQUENCE cmnttype_cmnttype_id_seq TO admin;
119422
 
GRANT ALL ON SEQUENCE cmnttype_cmnttype_id_seq TO xtrole;
119423
 
 
119424
 
 
119425
 
--
119426
 
--
119427
 
 
119428
 
REVOKE ALL ON TABLE cmnttypesource FROM PUBLIC;
119429
 
REVOKE ALL ON TABLE cmnttypesource FROM admin;
119430
 
GRANT ALL ON TABLE cmnttypesource TO admin;
119431
 
GRANT ALL ON TABLE cmnttypesource TO xtrole;
119432
 
 
119433
 
 
119434
 
--
119435
 
--
119436
 
 
119437
 
REVOKE ALL ON SEQUENCE cmnttypesource_cmnttypesource_id_seq FROM PUBLIC;
119438
 
REVOKE ALL ON SEQUENCE cmnttypesource_cmnttypesource_id_seq FROM admin;
119439
 
GRANT ALL ON SEQUENCE cmnttypesource_cmnttypesource_id_seq TO admin;
119440
 
GRANT ALL ON SEQUENCE cmnttypesource_cmnttypesource_id_seq TO xtrole;
119441
 
 
119442
 
 
119443
 
--
119444
 
--
119445
 
 
119446
 
REVOKE ALL ON SEQUENCE cntct_cntct_id_seq FROM PUBLIC;
119447
 
REVOKE ALL ON SEQUENCE cntct_cntct_id_seq FROM admin;
119448
 
GRANT ALL ON SEQUENCE cntct_cntct_id_seq TO admin;
119449
 
GRANT ALL ON SEQUENCE cntct_cntct_id_seq TO xtrole;
119450
 
 
119451
 
 
119452
 
--
119453
 
--
119454
 
 
119455
 
REVOKE ALL ON TABLE cntctaddr FROM PUBLIC;
119456
 
REVOKE ALL ON TABLE cntctaddr FROM admin;
119457
 
GRANT ALL ON TABLE cntctaddr TO admin;
119458
 
GRANT ALL ON TABLE cntctaddr TO xtrole;
119459
 
 
119460
 
 
119461
 
--
119462
 
--
119463
 
 
119464
 
REVOKE ALL ON SEQUENCE cntctaddr_cntctaddr_id_seq FROM PUBLIC;
119465
 
REVOKE ALL ON SEQUENCE cntctaddr_cntctaddr_id_seq FROM admin;
119466
 
GRANT ALL ON SEQUENCE cntctaddr_cntctaddr_id_seq TO admin;
119467
 
GRANT ALL ON SEQUENCE cntctaddr_cntctaddr_id_seq TO xtrole;
119468
 
 
119469
 
 
119470
 
--
119471
 
--
119472
 
 
119473
 
REVOKE ALL ON TABLE cntctdata FROM PUBLIC;
119474
 
REVOKE ALL ON TABLE cntctdata FROM admin;
119475
 
GRANT ALL ON TABLE cntctdata TO admin;
119476
 
GRANT ALL ON TABLE cntctdata TO xtrole;
119477
 
 
119478
 
 
119479
 
--
119480
 
--
119481
 
 
119482
 
REVOKE ALL ON SEQUENCE cntctdata_cntctdata_id_seq FROM PUBLIC;
119483
 
REVOKE ALL ON SEQUENCE cntctdata_cntctdata_id_seq FROM admin;
119484
 
GRANT ALL ON SEQUENCE cntctdata_cntctdata_id_seq TO admin;
119485
 
GRANT ALL ON SEQUENCE cntctdata_cntctdata_id_seq TO xtrole;
119486
 
 
119487
 
 
119488
 
--
119489
 
--
119490
 
 
119491
 
REVOKE ALL ON TABLE cntcteml FROM PUBLIC;
119492
 
REVOKE ALL ON TABLE cntcteml FROM admin;
119493
 
GRANT ALL ON TABLE cntcteml TO admin;
119494
 
GRANT ALL ON TABLE cntcteml TO xtrole;
119495
 
 
119496
 
 
119497
 
--
119498
 
--
119499
 
 
119500
 
REVOKE ALL ON SEQUENCE cntcteml_cntcteml_id_seq FROM PUBLIC;
119501
 
REVOKE ALL ON SEQUENCE cntcteml_cntcteml_id_seq FROM admin;
119502
 
GRANT ALL ON SEQUENCE cntcteml_cntcteml_id_seq TO admin;
119503
 
GRANT ALL ON SEQUENCE cntcteml_cntcteml_id_seq TO xtrole;
119504
 
 
119505
 
 
119506
 
--
119507
 
--
119508
 
 
119509
 
REVOKE ALL ON TABLE cntctmrgd FROM PUBLIC;
119510
 
REVOKE ALL ON TABLE cntctmrgd FROM admin;
119511
 
GRANT ALL ON TABLE cntctmrgd TO admin;
119512
 
GRANT ALL ON TABLE cntctmrgd TO xtrole;
119513
 
 
119514
 
 
119515
 
--
119516
 
--
119517
 
 
119518
 
REVOKE ALL ON TABLE cntctsel FROM PUBLIC;
119519
 
REVOKE ALL ON TABLE cntctsel FROM admin;
119520
 
GRANT ALL ON TABLE cntctsel TO admin;
119521
 
GRANT ALL ON TABLE cntctsel TO xtrole;
119522
 
 
119523
 
 
119524
 
--
119525
 
--
119526
 
 
119527
 
REVOKE ALL ON SEQUENCE cntslip_cntslip_id_seq FROM PUBLIC;
119528
 
REVOKE ALL ON SEQUENCE cntslip_cntslip_id_seq FROM admin;
119529
 
GRANT ALL ON SEQUENCE cntslip_cntslip_id_seq TO admin;
119530
 
GRANT ALL ON SEQUENCE cntslip_cntslip_id_seq TO xtrole;
119531
 
 
119532
 
 
119533
 
--
119534
 
--
119535
 
 
119536
 
REVOKE ALL ON TABLE cobill FROM PUBLIC;
119537
 
REVOKE ALL ON TABLE cobill FROM admin;
119538
 
GRANT ALL ON TABLE cobill TO admin;
119539
 
GRANT ALL ON TABLE cobill TO xtrole;
119540
 
 
119541
 
 
119542
 
--
119543
 
--
119544
 
 
119545
 
REVOKE ALL ON SEQUENCE cobill_cobill_id_seq FROM PUBLIC;
119546
 
REVOKE ALL ON SEQUENCE cobill_cobill_id_seq FROM admin;
119547
 
GRANT ALL ON SEQUENCE cobill_cobill_id_seq TO admin;
119548
 
GRANT ALL ON SEQUENCE cobill_cobill_id_seq TO xtrole;
119549
 
 
119550
 
 
119551
 
--
119552
 
--
119553
 
 
119554
 
REVOKE ALL ON TABLE cobilltax FROM PUBLIC;
119555
 
REVOKE ALL ON TABLE cobilltax FROM admin;
119556
 
GRANT ALL ON TABLE cobilltax TO admin;
119557
 
GRANT ALL ON TABLE cobilltax TO xtrole;
119558
 
 
119559
 
 
119560
 
--
119561
 
--
119562
 
 
119563
 
REVOKE ALL ON TABLE cobmisc FROM PUBLIC;
119564
 
REVOKE ALL ON TABLE cobmisc FROM admin;
119565
 
GRANT ALL ON TABLE cobmisc TO admin;
119566
 
GRANT ALL ON TABLE cobmisc TO xtrole;
119567
 
 
119568
 
 
119569
 
--
119570
 
--
119571
 
 
119572
 
REVOKE ALL ON SEQUENCE cobmisc_cobmisc_id_seq FROM PUBLIC;
119573
 
REVOKE ALL ON SEQUENCE cobmisc_cobmisc_id_seq FROM admin;
119574
 
GRANT ALL ON SEQUENCE cobmisc_cobmisc_id_seq TO admin;
119575
 
GRANT ALL ON SEQUENCE cobmisc_cobmisc_id_seq TO xtrole;
119576
 
 
119577
 
 
119578
 
--
119579
 
--
119580
 
 
119581
 
REVOKE ALL ON TABLE cobmisctax FROM PUBLIC;
119582
 
REVOKE ALL ON TABLE cobmisctax FROM admin;
119583
 
GRANT ALL ON TABLE cobmisctax TO admin;
119584
 
GRANT ALL ON TABLE cobmisctax TO xtrole;
119585
 
 
119586
 
 
119587
 
--
119588
 
--
119589
 
 
119590
 
REVOKE ALL ON SEQUENCE cohead_cohead_id_seq FROM PUBLIC;
119591
 
REVOKE ALL ON SEQUENCE cohead_cohead_id_seq FROM admin;
119592
 
GRANT ALL ON SEQUENCE cohead_cohead_id_seq TO admin;
119593
 
GRANT ALL ON SEQUENCE cohead_cohead_id_seq TO xtrole;
119594
 
 
119595
 
 
119596
 
--
119597
 
--
119598
 
 
119599
 
REVOKE ALL ON SEQUENCE cohist_cohist_id_seq FROM PUBLIC;
119600
 
REVOKE ALL ON SEQUENCE cohist_cohist_id_seq FROM admin;
119601
 
GRANT ALL ON SEQUENCE cohist_cohist_id_seq TO admin;
119602
 
GRANT ALL ON SEQUENCE cohist_cohist_id_seq TO xtrole;
119603
 
 
119604
 
 
119605
 
--
119606
 
--
119607
 
 
119608
 
REVOKE ALL ON SEQUENCE coitem_coitem_id_seq FROM PUBLIC;
119609
 
REVOKE ALL ON SEQUENCE coitem_coitem_id_seq FROM admin;
119610
 
GRANT ALL ON SEQUENCE coitem_coitem_id_seq TO admin;
119611
 
GRANT ALL ON SEQUENCE coitem_coitem_id_seq TO xtrole;
119612
 
 
119613
 
 
119614
 
--
119615
 
--
119616
 
 
119617
 
REVOKE ALL ON SEQUENCE comment_comment_id_seq FROM PUBLIC;
119618
 
REVOKE ALL ON SEQUENCE comment_comment_id_seq FROM admin;
119619
 
GRANT ALL ON SEQUENCE comment_comment_id_seq TO admin;
119620
 
GRANT ALL ON SEQUENCE comment_comment_id_seq TO xtrole;
119621
 
 
119622
 
 
119623
 
--
119624
 
--
119625
 
 
119626
 
REVOKE ALL ON TABLE company FROM PUBLIC;
119627
 
REVOKE ALL ON TABLE company FROM admin;
119628
 
GRANT ALL ON TABLE company TO admin;
119629
 
GRANT ALL ON TABLE company TO xtrole;
119630
 
 
119631
 
 
119632
 
--
119633
 
--
119634
 
 
119635
 
REVOKE ALL ON SEQUENCE company_company_id_seq FROM PUBLIC;
119636
 
REVOKE ALL ON SEQUENCE company_company_id_seq FROM admin;
119637
 
GRANT ALL ON SEQUENCE company_company_id_seq TO admin;
119638
 
GRANT ALL ON SEQUENCE company_company_id_seq TO xtrole;
119639
 
 
119640
 
 
119641
 
--
119642
 
--
119643
 
 
119644
 
REVOKE ALL ON SEQUENCE contrct_contrct_id_seq FROM PUBLIC;
119645
 
REVOKE ALL ON SEQUENCE contrct_contrct_id_seq FROM admin;
119646
 
GRANT ALL ON SEQUENCE contrct_contrct_id_seq TO admin;
119647
 
GRANT ALL ON SEQUENCE contrct_contrct_id_seq TO xtrole;
119648
 
 
119649
 
 
119650
 
--
119651
 
--
119652
 
 
119653
 
REVOKE ALL ON TABLE shiphead FROM PUBLIC;
119654
 
REVOKE ALL ON TABLE shiphead FROM admin;
119655
 
GRANT ALL ON TABLE shiphead TO admin;
119656
 
GRANT ALL ON TABLE shiphead TO xtrole;
119657
 
 
119658
 
 
119659
 
--
119660
 
--
119661
 
 
119662
 
REVOKE ALL ON TABLE shipitem FROM PUBLIC;
119663
 
REVOKE ALL ON TABLE shipitem FROM admin;
119664
 
GRANT ALL ON TABLE shipitem TO admin;
119665
 
GRANT ALL ON TABLE shipitem TO xtrole;
119666
 
 
119667
 
 
119668
 
--
119669
 
--
119670
 
 
119671
 
REVOKE ALL ON TABLE coship FROM PUBLIC;
119672
 
REVOKE ALL ON TABLE coship FROM admin;
119673
 
GRANT ALL ON TABLE coship TO admin;
119674
 
GRANT ALL ON TABLE coship TO xtrole;
119675
 
 
119676
 
 
119677
 
--
119678
 
--
119679
 
 
119680
 
REVOKE ALL ON SEQUENCE coship_coship_id_seq FROM PUBLIC;
119681
 
REVOKE ALL ON SEQUENCE coship_coship_id_seq FROM admin;
119682
 
GRANT ALL ON SEQUENCE coship_coship_id_seq TO admin;
119683
 
GRANT ALL ON SEQUENCE coship_coship_id_seq TO xtrole;
119684
 
 
119685
 
 
119686
 
--
119687
 
--
119688
 
 
119689
 
REVOKE ALL ON TABLE cosmisc FROM PUBLIC;
119690
 
REVOKE ALL ON TABLE cosmisc FROM admin;
119691
 
GRANT ALL ON TABLE cosmisc TO admin;
119692
 
GRANT ALL ON TABLE cosmisc TO xtrole;
119693
 
 
119694
 
 
119695
 
--
119696
 
--
119697
 
 
119698
 
REVOKE ALL ON SEQUENCE cosmisc_cosmisc_id_seq FROM PUBLIC;
119699
 
REVOKE ALL ON SEQUENCE cosmisc_cosmisc_id_seq FROM admin;
119700
 
GRANT ALL ON SEQUENCE cosmisc_cosmisc_id_seq TO admin;
119701
 
GRANT ALL ON SEQUENCE cosmisc_cosmisc_id_seq TO xtrole;
119702
 
 
119703
 
 
119704
 
--
119705
 
--
119706
 
 
119707
 
REVOKE ALL ON SEQUENCE cosrc_cosrc_id_seq FROM PUBLIC;
119708
 
REVOKE ALL ON SEQUENCE cosrc_cosrc_id_seq FROM admin;
119709
 
GRANT ALL ON SEQUENCE cosrc_cosrc_id_seq TO admin;
119710
 
GRANT ALL ON SEQUENCE cosrc_cosrc_id_seq TO xtrole;
119711
 
 
119712
 
 
119713
 
--
119714
 
--
119715
 
 
119716
 
REVOKE ALL ON SEQUENCE costcat_costcat_id_seq FROM PUBLIC;
119717
 
REVOKE ALL ON SEQUENCE costcat_costcat_id_seq FROM admin;
119718
 
GRANT ALL ON SEQUENCE costcat_costcat_id_seq TO admin;
119719
 
GRANT ALL ON SEQUENCE costcat_costcat_id_seq TO xtrole;
119720
 
 
119721
 
 
119722
 
--
119723
 
--
119724
 
 
119725
 
REVOKE ALL ON SEQUENCE costelem_costelem_id_seq FROM PUBLIC;
119726
 
REVOKE ALL ON SEQUENCE costelem_costelem_id_seq FROM admin;
119727
 
GRANT ALL ON SEQUENCE costelem_costelem_id_seq TO admin;
119728
 
GRANT ALL ON SEQUENCE costelem_costelem_id_seq TO xtrole;
119729
 
 
119730
 
 
119731
 
--
119732
 
--
119733
 
 
119734
 
REVOKE ALL ON TABLE costhist FROM PUBLIC;
119735
 
REVOKE ALL ON TABLE costhist FROM admin;
119736
 
GRANT ALL ON TABLE costhist TO admin;
119737
 
GRANT ALL ON TABLE costhist TO xtrole;
119738
 
 
119739
 
 
119740
 
--
119741
 
--
119742
 
 
119743
 
REVOKE ALL ON SEQUENCE costhist_costhist_id_seq FROM PUBLIC;
119744
 
REVOKE ALL ON SEQUENCE costhist_costhist_id_seq FROM admin;
119745
 
GRANT ALL ON SEQUENCE costhist_costhist_id_seq TO admin;
119746
 
GRANT ALL ON SEQUENCE costhist_costhist_id_seq TO xtrole;
119747
 
 
119748
 
 
119749
 
--
119750
 
--
119751
 
 
119752
 
REVOKE ALL ON TABLE costupdate FROM PUBLIC;
119753
 
REVOKE ALL ON TABLE costupdate FROM admin;
119754
 
GRANT ALL ON TABLE costupdate TO admin;
119755
 
GRANT ALL ON TABLE costupdate TO xtrole;
119756
 
 
119757
 
 
119758
 
--
119759
 
--
119760
 
 
119761
 
REVOKE ALL ON TABLE country FROM PUBLIC;
119762
 
REVOKE ALL ON TABLE country FROM admin;
119763
 
GRANT ALL ON TABLE country TO admin;
119764
 
GRANT ALL ON TABLE country TO xtrole;
119765
 
 
119766
 
 
119767
 
--
119768
 
--
119769
 
 
119770
 
REVOKE ALL ON SEQUENCE country_country_id_seq FROM PUBLIC;
119771
 
REVOKE ALL ON SEQUENCE country_country_id_seq FROM admin;
119772
 
GRANT ALL ON SEQUENCE country_country_id_seq TO admin;
119773
 
GRANT ALL ON SEQUENCE country_country_id_seq TO xtrole;
119774
 
 
119775
 
 
119776
 
--
119777
 
--
119778
 
 
119779
 
REVOKE ALL ON TABLE salesaccnt FROM PUBLIC;
119780
 
REVOKE ALL ON TABLE salesaccnt FROM admin;
119781
 
GRANT ALL ON TABLE salesaccnt TO admin;
119782
 
GRANT ALL ON TABLE salesaccnt TO xtrole;
119783
 
 
119784
 
 
119785
 
--
119786
 
--
119787
 
 
119788
 
REVOKE ALL ON TABLE creditmemoeditlist FROM PUBLIC;
119789
 
REVOKE ALL ON TABLE creditmemoeditlist FROM admin;
119790
 
GRANT ALL ON TABLE creditmemoeditlist TO admin;
119791
 
GRANT ALL ON TABLE creditmemoeditlist TO xtrole;
119792
 
 
119793
 
 
119794
 
--
119795
 
--
119796
 
 
119797
 
REVOKE ALL ON TABLE creditmemoitem FROM PUBLIC;
119798
 
REVOKE ALL ON TABLE creditmemoitem FROM admin;
119799
 
GRANT ALL ON TABLE creditmemoitem TO admin;
119800
 
GRANT ALL ON TABLE creditmemoitem TO xtrole;
119801
 
 
119802
 
 
119803
 
--
119804
 
--
119805
 
 
119806
 
REVOKE ALL ON SEQUENCE crmacct_crmacct_id_seq FROM PUBLIC;
119807
 
REVOKE ALL ON SEQUENCE crmacct_crmacct_id_seq FROM admin;
119808
 
GRANT ALL ON SEQUENCE crmacct_crmacct_id_seq TO admin;
119809
 
GRANT ALL ON SEQUENCE crmacct_crmacct_id_seq TO xtrole;
119810
 
 
119811
 
 
119812
 
--
119813
 
--
119814
 
 
119815
 
REVOKE ALL ON TABLE crmacctsel FROM PUBLIC;
119816
 
REVOKE ALL ON TABLE crmacctsel FROM admin;
119817
 
GRANT ALL ON TABLE crmacctsel TO admin;
119818
 
GRANT ALL ON TABLE crmacctsel TO xtrole;
119819
 
 
119820
 
 
119821
 
--
119822
 
--
119823
 
 
119824
 
REVOKE ALL ON TABLE curr_rate FROM PUBLIC;
119825
 
REVOKE ALL ON TABLE curr_rate FROM admin;
119826
 
GRANT ALL ON TABLE curr_rate TO admin;
119827
 
GRANT ALL ON TABLE curr_rate TO xtrole;
119828
 
 
119829
 
 
119830
 
--
119831
 
--
119832
 
 
119833
 
REVOKE ALL ON SEQUENCE curr_rate_curr_rate_id_seq FROM PUBLIC;
119834
 
REVOKE ALL ON SEQUENCE curr_rate_curr_rate_id_seq FROM admin;
119835
 
GRANT ALL ON SEQUENCE curr_rate_curr_rate_id_seq TO admin;
119836
 
GRANT ALL ON SEQUENCE curr_rate_curr_rate_id_seq TO xtrole;
119837
 
 
119838
 
 
119839
 
--
119840
 
--
119841
 
 
119842
 
REVOKE ALL ON SEQUENCE curr_symbol_curr_id_seq FROM PUBLIC;
119843
 
REVOKE ALL ON SEQUENCE curr_symbol_curr_id_seq FROM admin;
119844
 
GRANT ALL ON SEQUENCE curr_symbol_curr_id_seq TO admin;
119845
 
GRANT ALL ON SEQUENCE curr_symbol_curr_id_seq TO xtrole;
119846
 
 
119847
 
 
119848
 
--
119849
 
--
119850
 
 
119851
 
REVOKE ALL ON TABLE cust FROM PUBLIC;
119852
 
REVOKE ALL ON TABLE cust FROM admin;
119853
 
GRANT ALL ON TABLE cust TO admin;
119854
 
GRANT ALL ON TABLE cust TO xtrole;
119855
 
 
119856
 
 
119857
 
--
119858
 
--
119859
 
 
119860
 
REVOKE ALL ON SEQUENCE cust_serial_seq FROM PUBLIC;
119861
 
REVOKE ALL ON SEQUENCE cust_serial_seq FROM admin;
119862
 
GRANT ALL ON SEQUENCE cust_serial_seq TO admin;
119863
 
GRANT ALL ON SEQUENCE cust_serial_seq TO xtrole;
119864
 
 
119865
 
 
119866
 
--
119867
 
--
119868
 
 
119869
 
REVOKE ALL ON TABLE custform FROM PUBLIC;
119870
 
REVOKE ALL ON TABLE custform FROM admin;
119871
 
GRANT ALL ON TABLE custform TO admin;
119872
 
GRANT ALL ON TABLE custform TO xtrole;
119873
 
 
119874
 
 
119875
 
--
119876
 
--
119877
 
 
119878
 
REVOKE ALL ON SEQUENCE custform_custform_id_seq FROM PUBLIC;
119879
 
REVOKE ALL ON SEQUENCE custform_custform_id_seq FROM admin;
119880
 
GRANT ALL ON SEQUENCE custform_custform_id_seq TO admin;
119881
 
GRANT ALL ON SEQUENCE custform_custform_id_seq TO xtrole;
119882
 
 
119883
 
 
119884
 
--
119885
 
--
119886
 
 
119887
 
REVOKE ALL ON TABLE custgrp FROM PUBLIC;
119888
 
REVOKE ALL ON TABLE custgrp FROM admin;
119889
 
GRANT ALL ON TABLE custgrp TO admin;
119890
 
GRANT ALL ON TABLE custgrp TO xtrole;
119891
 
 
119892
 
 
119893
 
--
119894
 
--
119895
 
 
119896
 
REVOKE ALL ON SEQUENCE custgrp_custgrp_id_seq FROM PUBLIC;
119897
 
REVOKE ALL ON SEQUENCE custgrp_custgrp_id_seq FROM admin;
119898
 
GRANT ALL ON SEQUENCE custgrp_custgrp_id_seq TO admin;
119899
 
GRANT ALL ON SEQUENCE custgrp_custgrp_id_seq TO xtrole;
119900
 
 
119901
 
 
119902
 
--
119903
 
--
119904
 
 
119905
 
REVOKE ALL ON TABLE custgrpitem FROM PUBLIC;
119906
 
REVOKE ALL ON TABLE custgrpitem FROM admin;
119907
 
GRANT ALL ON TABLE custgrpitem TO admin;
119908
 
GRANT ALL ON TABLE custgrpitem TO xtrole;
119909
 
 
119910
 
 
119911
 
--
119912
 
--
119913
 
 
119914
 
REVOKE ALL ON SEQUENCE custgrpitem_custgrpitem_id_seq FROM PUBLIC;
119915
 
REVOKE ALL ON SEQUENCE custgrpitem_custgrpitem_id_seq FROM admin;
119916
 
GRANT ALL ON SEQUENCE custgrpitem_custgrpitem_id_seq TO admin;
119917
 
GRANT ALL ON SEQUENCE custgrpitem_custgrpitem_id_seq TO xtrole;
119918
 
 
119919
 
 
119920
 
--
119921
 
--
119922
 
 
119923
 
REVOKE ALL ON SEQUENCE custtype_custtype_id_seq FROM PUBLIC;
119924
 
REVOKE ALL ON SEQUENCE custtype_custtype_id_seq FROM admin;
119925
 
GRANT ALL ON SEQUENCE custtype_custtype_id_seq TO admin;
119926
 
GRANT ALL ON SEQUENCE custtype_custtype_id_seq TO xtrole;
119927
 
 
119928
 
 
119929
 
--
119930
 
--
119931
 
 
119932
 
REVOKE ALL ON SEQUENCE dept_dept_id_seq FROM PUBLIC;
119933
 
REVOKE ALL ON SEQUENCE dept_dept_id_seq FROM admin;
119934
 
GRANT ALL ON SEQUENCE dept_dept_id_seq TO admin;
119935
 
GRANT ALL ON SEQUENCE dept_dept_id_seq TO xtrole;
119936
 
 
119937
 
 
119938
 
--
119939
 
--
119940
 
 
119941
 
REVOKE ALL ON TABLE destination FROM PUBLIC;
119942
 
REVOKE ALL ON TABLE destination FROM admin;
119943
 
GRANT ALL ON TABLE destination TO admin;
119944
 
GRANT ALL ON TABLE destination TO xtrole;
119945
 
 
119946
 
 
119947
 
--
119948
 
--
119949
 
 
119950
 
REVOKE ALL ON SEQUENCE destination_destination_id_seq FROM PUBLIC;
119951
 
REVOKE ALL ON SEQUENCE destination_destination_id_seq FROM admin;
119952
 
GRANT ALL ON SEQUENCE destination_destination_id_seq TO admin;
119953
 
GRANT ALL ON SEQUENCE destination_destination_id_seq TO xtrole;
119954
 
 
119955
 
 
119956
 
--
119957
 
--
119958
 
 
119959
 
REVOKE ALL ON TABLE wo FROM PUBLIC;
119960
 
REVOKE ALL ON TABLE wo FROM admin;
119961
 
GRANT ALL ON TABLE wo TO admin;
119962
 
GRANT ALL ON TABLE wo TO xtrole;
119963
 
 
119964
 
 
119965
 
--
119966
 
--
119967
 
 
119968
 
REVOKE ALL ON TABLE docinfo FROM PUBLIC;
119969
 
REVOKE ALL ON TABLE docinfo FROM admin;
119970
 
GRANT ALL ON TABLE docinfo TO admin;
119971
 
GRANT ALL ON TABLE docinfo TO xtrole;
119972
 
 
119973
 
 
119974
 
--
119975
 
--
119976
 
 
119977
 
REVOKE ALL ON SEQUENCE emp_emp_id_seq FROM PUBLIC;
119978
 
REVOKE ALL ON SEQUENCE emp_emp_id_seq FROM admin;
119979
 
GRANT ALL ON SEQUENCE emp_emp_id_seq TO admin;
119980
 
GRANT ALL ON SEQUENCE emp_emp_id_seq TO xtrole;
119981
 
 
119982
 
 
119983
 
--
119984
 
--
119985
 
 
119986
 
REVOKE ALL ON TABLE empgrp FROM PUBLIC;
119987
 
REVOKE ALL ON TABLE empgrp FROM admin;
119988
 
GRANT ALL ON TABLE empgrp TO admin;
119989
 
GRANT ALL ON TABLE empgrp TO xtrole;
119990
 
 
119991
 
 
119992
 
--
119993
 
--
119994
 
 
119995
 
REVOKE ALL ON SEQUENCE empgrp_empgrp_id_seq FROM PUBLIC;
119996
 
REVOKE ALL ON SEQUENCE empgrp_empgrp_id_seq FROM admin;
119997
 
GRANT ALL ON SEQUENCE empgrp_empgrp_id_seq TO admin;
119998
 
GRANT ALL ON SEQUENCE empgrp_empgrp_id_seq TO xtrole;
119999
 
 
120000
 
 
120001
 
--
120002
 
--
120003
 
 
120004
 
REVOKE ALL ON TABLE empgrpitem FROM PUBLIC;
120005
 
REVOKE ALL ON TABLE empgrpitem FROM admin;
120006
 
GRANT ALL ON TABLE empgrpitem TO admin;
120007
 
GRANT ALL ON TABLE empgrpitem TO xtrole;
120008
 
 
120009
 
 
120010
 
--
120011
 
--
120012
 
 
120013
 
REVOKE ALL ON SEQUENCE empgrpitem_empgrpitem_id_seq FROM PUBLIC;
120014
 
REVOKE ALL ON SEQUENCE empgrpitem_empgrpitem_id_seq FROM admin;
120015
 
GRANT ALL ON SEQUENCE empgrpitem_empgrpitem_id_seq TO admin;
120016
 
GRANT ALL ON SEQUENCE empgrpitem_empgrpitem_id_seq TO xtrole;
120017
 
 
120018
 
 
120019
 
--
120020
 
--
120021
 
 
120022
 
REVOKE ALL ON TABLE evntlog FROM PUBLIC;
120023
 
REVOKE ALL ON TABLE evntlog FROM admin;
120024
 
GRANT ALL ON TABLE evntlog TO admin;
120025
 
GRANT ALL ON TABLE evntlog TO xtrole;
120026
 
 
120027
 
 
120028
 
--
120029
 
--
120030
 
 
120031
 
REVOKE ALL ON SEQUENCE evntlog_evntlog_id_seq FROM PUBLIC;
120032
 
REVOKE ALL ON SEQUENCE evntlog_evntlog_id_seq FROM admin;
120033
 
GRANT ALL ON SEQUENCE evntlog_evntlog_id_seq TO admin;
120034
 
GRANT ALL ON SEQUENCE evntlog_evntlog_id_seq TO xtrole;
120035
 
 
120036
 
 
120037
 
--
120038
 
--
120039
 
 
120040
 
REVOKE ALL ON TABLE evntnot FROM PUBLIC;
120041
 
REVOKE ALL ON TABLE evntnot FROM admin;
120042
 
GRANT ALL ON TABLE evntnot TO admin;
120043
 
GRANT ALL ON TABLE evntnot TO xtrole;
120044
 
 
120045
 
 
120046
 
--
120047
 
--
120048
 
 
120049
 
REVOKE ALL ON SEQUENCE evntnot_evntnot_id_seq FROM PUBLIC;
120050
 
REVOKE ALL ON SEQUENCE evntnot_evntnot_id_seq FROM admin;
120051
 
GRANT ALL ON SEQUENCE evntnot_evntnot_id_seq TO admin;
120052
 
GRANT ALL ON SEQUENCE evntnot_evntnot_id_seq TO xtrole;
120053
 
 
120054
 
 
120055
 
--
120056
 
--
120057
 
 
120058
 
REVOKE ALL ON TABLE evnttype FROM PUBLIC;
120059
 
REVOKE ALL ON TABLE evnttype FROM admin;
120060
 
GRANT ALL ON TABLE evnttype TO admin;
120061
 
GRANT ALL ON TABLE evnttype TO xtrole;
120062
 
 
120063
 
 
120064
 
--
120065
 
--
120066
 
 
120067
 
REVOKE ALL ON SEQUENCE evnttype_evnttype_id_seq FROM PUBLIC;
120068
 
REVOKE ALL ON SEQUENCE evnttype_evnttype_id_seq FROM admin;
120069
 
GRANT ALL ON SEQUENCE evnttype_evnttype_id_seq TO admin;
120070
 
GRANT ALL ON SEQUENCE evnttype_evnttype_id_seq TO xtrole;
120071
 
 
120072
 
 
120073
 
--
120074
 
--
120075
 
 
120076
 
REVOKE ALL ON SEQUENCE expcat_expcat_id_seq FROM PUBLIC;
120077
 
REVOKE ALL ON SEQUENCE expcat_expcat_id_seq FROM admin;
120078
 
GRANT ALL ON SEQUENCE expcat_expcat_id_seq TO admin;
120079
 
GRANT ALL ON SEQUENCE expcat_expcat_id_seq TO xtrole;
120080
 
 
120081
 
 
120082
 
--
120083
 
--
120084
 
 
120085
 
REVOKE ALL ON SEQUENCE file_file_id_seq FROM PUBLIC;
120086
 
REVOKE ALL ON SEQUENCE file_file_id_seq FROM admin;
120087
 
GRANT ALL ON SEQUENCE file_file_id_seq TO admin;
120088
 
GRANT ALL ON SEQUENCE file_file_id_seq TO xtrole;
120089
 
 
120090
 
 
120091
 
--
120092
 
--
120093
 
 
120094
 
REVOKE ALL ON TABLE filter FROM PUBLIC;
120095
 
REVOKE ALL ON TABLE filter FROM admin;
120096
 
GRANT ALL ON TABLE filter TO admin;
120097
 
GRANT ALL ON TABLE filter TO xtrole;
120098
 
 
120099
 
 
120100
 
--
120101
 
--
120102
 
 
120103
 
REVOKE ALL ON SEQUENCE filter_filter_id_seq FROM PUBLIC;
120104
 
REVOKE ALL ON SEQUENCE filter_filter_id_seq FROM admin;
120105
 
GRANT ALL ON SEQUENCE filter_filter_id_seq TO admin;
120106
 
GRANT ALL ON SEQUENCE filter_filter_id_seq TO xtrole;
120107
 
 
120108
 
 
120109
 
--
120110
 
--
120111
 
 
120112
 
REVOKE ALL ON TABLE fincharg FROM PUBLIC;
120113
 
REVOKE ALL ON TABLE fincharg FROM admin;
120114
 
GRANT ALL ON TABLE fincharg TO admin;
120115
 
GRANT ALL ON TABLE fincharg TO xtrole;
120116
 
 
120117
 
 
120118
 
--
120119
 
--
120120
 
 
120121
 
REVOKE ALL ON SEQUENCE fincharg_fincharg_id_seq FROM PUBLIC;
120122
 
REVOKE ALL ON SEQUENCE fincharg_fincharg_id_seq FROM admin;
120123
 
GRANT ALL ON SEQUENCE fincharg_fincharg_id_seq TO admin;
120124
 
GRANT ALL ON SEQUENCE fincharg_fincharg_id_seq TO xtrole;
120125
 
 
120126
 
 
120127
 
--
120128
 
--
120129
 
 
120130
 
REVOKE ALL ON TABLE flhead FROM PUBLIC;
120131
 
REVOKE ALL ON TABLE flhead FROM admin;
120132
 
GRANT ALL ON TABLE flhead TO admin;
120133
 
GRANT ALL ON TABLE flhead TO xtrole;
120134
 
 
120135
 
 
120136
 
--
120137
 
--
120138
 
 
120139
 
REVOKE ALL ON TABLE flitem FROM PUBLIC;
120140
 
REVOKE ALL ON TABLE flitem FROM admin;
120141
 
GRANT ALL ON TABLE flitem TO admin;
120142
 
GRANT ALL ON TABLE flitem TO xtrole;
120143
 
 
120144
 
 
120145
 
--
120146
 
--
120147
 
 
120148
 
REVOKE ALL ON TABLE flaccnt FROM PUBLIC;
120149
 
REVOKE ALL ON TABLE flaccnt FROM admin;
120150
 
GRANT ALL ON TABLE flaccnt TO admin;
120151
 
GRANT ALL ON TABLE flaccnt TO xtrole;
120152
 
 
120153
 
 
120154
 
--
120155
 
--
120156
 
 
120157
 
REVOKE ALL ON TABLE flcol FROM PUBLIC;
120158
 
REVOKE ALL ON TABLE flcol FROM admin;
120159
 
GRANT ALL ON TABLE flcol TO admin;
120160
 
GRANT ALL ON TABLE flcol TO xtrole;
120161
 
 
120162
 
 
120163
 
--
120164
 
--
120165
 
 
120166
 
REVOKE ALL ON SEQUENCE flcol_flcol_id_seq FROM PUBLIC;
120167
 
REVOKE ALL ON SEQUENCE flcol_flcol_id_seq FROM admin;
120168
 
GRANT ALL ON SEQUENCE flcol_flcol_id_seq TO admin;
120169
 
GRANT ALL ON SEQUENCE flcol_flcol_id_seq TO xtrole;
120170
 
 
120171
 
 
120172
 
--
120173
 
--
120174
 
 
120175
 
REVOKE ALL ON TABLE flgrp FROM PUBLIC;
120176
 
REVOKE ALL ON TABLE flgrp FROM admin;
120177
 
GRANT ALL ON TABLE flgrp TO admin;
120178
 
GRANT ALL ON TABLE flgrp TO xtrole;
120179
 
 
120180
 
 
120181
 
--
120182
 
--
120183
 
 
120184
 
REVOKE ALL ON SEQUENCE flgrp_flgrp_id_seq FROM PUBLIC;
120185
 
REVOKE ALL ON SEQUENCE flgrp_flgrp_id_seq FROM admin;
120186
 
GRANT ALL ON SEQUENCE flgrp_flgrp_id_seq TO admin;
120187
 
GRANT ALL ON SEQUENCE flgrp_flgrp_id_seq TO xtrole;
120188
 
 
120189
 
 
120190
 
--
120191
 
--
120192
 
 
120193
 
REVOKE ALL ON SEQUENCE flhead_flhead_id_seq FROM PUBLIC;
120194
 
REVOKE ALL ON SEQUENCE flhead_flhead_id_seq FROM admin;
120195
 
GRANT ALL ON SEQUENCE flhead_flhead_id_seq TO admin;
120196
 
GRANT ALL ON SEQUENCE flhead_flhead_id_seq TO xtrole;
120197
 
 
120198
 
 
120199
 
--
120200
 
--
120201
 
 
120202
 
REVOKE ALL ON SEQUENCE flitem_flitem_id_seq FROM PUBLIC;
120203
 
REVOKE ALL ON SEQUENCE flitem_flitem_id_seq FROM admin;
120204
 
GRANT ALL ON SEQUENCE flitem_flitem_id_seq TO admin;
120205
 
GRANT ALL ON SEQUENCE flitem_flitem_id_seq TO xtrole;
120206
 
 
120207
 
 
120208
 
--
120209
 
--
120210
 
 
120211
 
REVOKE ALL ON TABLE flnotes FROM PUBLIC;
120212
 
REVOKE ALL ON TABLE flnotes FROM admin;
120213
 
GRANT ALL ON TABLE flnotes TO admin;
120214
 
GRANT ALL ON TABLE flnotes TO xtrole;
120215
 
 
120216
 
 
120217
 
--
120218
 
--
120219
 
 
120220
 
REVOKE ALL ON SEQUENCE flnotes_flnotes_id_seq FROM PUBLIC;
120221
 
REVOKE ALL ON SEQUENCE flnotes_flnotes_id_seq FROM admin;
120222
 
GRANT ALL ON SEQUENCE flnotes_flnotes_id_seq TO admin;
120223
 
GRANT ALL ON SEQUENCE flnotes_flnotes_id_seq TO xtrole;
120224
 
 
120225
 
 
120226
 
--
120227
 
--
120228
 
 
120229
 
REVOKE ALL ON TABLE flrpt FROM PUBLIC;
120230
 
REVOKE ALL ON TABLE flrpt FROM admin;
120231
 
GRANT ALL ON TABLE flrpt TO admin;
120232
 
GRANT ALL ON TABLE flrpt TO xtrole;
120233
 
 
120234
 
 
120235
 
--
120236
 
--
120237
 
 
120238
 
REVOKE ALL ON SEQUENCE flrpt_flrpt_id_seq FROM PUBLIC;
120239
 
REVOKE ALL ON SEQUENCE flrpt_flrpt_id_seq FROM admin;
120240
 
GRANT ALL ON SEQUENCE flrpt_flrpt_id_seq TO admin;
120241
 
GRANT ALL ON SEQUENCE flrpt_flrpt_id_seq TO xtrole;
120242
 
 
120243
 
 
120244
 
--
120245
 
--
120246
 
 
120247
 
REVOKE ALL ON TABLE flspec FROM PUBLIC;
120248
 
REVOKE ALL ON TABLE flspec FROM admin;
120249
 
GRANT ALL ON TABLE flspec TO admin;
120250
 
GRANT ALL ON TABLE flspec TO xtrole;
120251
 
 
120252
 
 
120253
 
--
120254
 
--
120255
 
 
120256
 
REVOKE ALL ON SEQUENCE flspec_flspec_id_seq FROM PUBLIC;
120257
 
REVOKE ALL ON SEQUENCE flspec_flspec_id_seq FROM admin;
120258
 
GRANT ALL ON SEQUENCE flspec_flspec_id_seq TO admin;
120259
 
GRANT ALL ON SEQUENCE flspec_flspec_id_seq TO xtrole;
120260
 
 
120261
 
 
120262
 
--
120263
 
--
120264
 
 
120265
 
REVOKE ALL ON TABLE form FROM PUBLIC;
120266
 
REVOKE ALL ON TABLE form FROM admin;
120267
 
GRANT ALL ON TABLE form TO admin;
120268
 
GRANT ALL ON TABLE form TO xtrole;
120269
 
 
120270
 
 
120271
 
--
120272
 
--
120273
 
 
120274
 
REVOKE ALL ON SEQUENCE form_form_id_seq FROM PUBLIC;
120275
 
REVOKE ALL ON SEQUENCE form_form_id_seq FROM admin;
120276
 
GRANT ALL ON SEQUENCE form_form_id_seq TO admin;
120277
 
GRANT ALL ON SEQUENCE form_form_id_seq TO xtrole;
120278
 
 
120279
 
 
120280
 
--
120281
 
--
120282
 
 
120283
 
REVOKE ALL ON SEQUENCE freightclass_freightclass_id_seq FROM PUBLIC;
120284
 
REVOKE ALL ON SEQUENCE freightclass_freightclass_id_seq FROM admin;
120285
 
GRANT ALL ON SEQUENCE freightclass_freightclass_id_seq TO admin;
120286
 
GRANT ALL ON SEQUENCE freightclass_freightclass_id_seq TO xtrole;
120287
 
 
120288
 
 
120289
 
--
120290
 
--
120291
 
 
120292
 
REVOKE ALL ON TABLE glseries FROM PUBLIC;
120293
 
REVOKE ALL ON TABLE glseries FROM admin;
120294
 
GRANT ALL ON TABLE glseries TO admin;
120295
 
GRANT ALL ON TABLE glseries TO xtrole;
120296
 
 
120297
 
 
120298
 
--
120299
 
--
120300
 
 
120301
 
REVOKE ALL ON SEQUENCE glseries_glseries_id_seq FROM PUBLIC;
120302
 
REVOKE ALL ON SEQUENCE glseries_glseries_id_seq FROM admin;
120303
 
GRANT ALL ON SEQUENCE glseries_glseries_id_seq TO admin;
120304
 
GRANT ALL ON SEQUENCE glseries_glseries_id_seq TO xtrole;
120305
 
 
120306
 
 
120307
 
--
120308
 
--
120309
 
 
120310
 
REVOKE ALL ON SEQUENCE gltrans_gltrans_id_seq FROM PUBLIC;
120311
 
REVOKE ALL ON SEQUENCE gltrans_gltrans_id_seq FROM admin;
120312
 
GRANT ALL ON SEQUENCE gltrans_gltrans_id_seq TO admin;
120313
 
GRANT ALL ON SEQUENCE gltrans_gltrans_id_seq TO xtrole;
120314
 
 
120315
 
 
120316
 
--
120317
 
--
120318
 
 
120319
 
REVOKE ALL ON SEQUENCE gltrans_sequence_seq FROM PUBLIC;
120320
 
REVOKE ALL ON SEQUENCE gltrans_sequence_seq FROM admin;
120321
 
GRANT ALL ON SEQUENCE gltrans_sequence_seq TO admin;
120322
 
GRANT ALL ON SEQUENCE gltrans_sequence_seq TO xtrole;
120323
 
 
120324
 
 
120325
 
--
120326
 
--
120327
 
 
120328
 
REVOKE ALL ON TABLE grp FROM PUBLIC;
120329
 
REVOKE ALL ON TABLE grp FROM admin;
120330
 
GRANT ALL ON TABLE grp TO admin;
120331
 
GRANT ALL ON TABLE grp TO xtrole;
120332
 
 
120333
 
 
120334
 
--
120335
 
--
120336
 
 
120337
 
REVOKE ALL ON SEQUENCE grp_grp_id_seq FROM PUBLIC;
120338
 
REVOKE ALL ON SEQUENCE grp_grp_id_seq FROM admin;
120339
 
GRANT ALL ON SEQUENCE grp_grp_id_seq TO admin;
120340
 
GRANT ALL ON SEQUENCE grp_grp_id_seq TO xtrole;
120341
 
 
120342
 
 
120343
 
--
120344
 
--
120345
 
 
120346
 
REVOKE ALL ON TABLE grppriv FROM PUBLIC;
120347
 
REVOKE ALL ON TABLE grppriv FROM admin;
120348
 
GRANT ALL ON TABLE grppriv TO admin;
120349
 
GRANT ALL ON TABLE grppriv TO xtrole;
120350
 
 
120351
 
 
120352
 
--
120353
 
--
120354
 
 
120355
 
REVOKE ALL ON SEQUENCE grppriv_grppriv_id_seq FROM PUBLIC;
120356
 
REVOKE ALL ON SEQUENCE grppriv_grppriv_id_seq FROM admin;
120357
 
GRANT ALL ON SEQUENCE grppriv_grppriv_id_seq TO admin;
120358
 
GRANT ALL ON SEQUENCE grppriv_grppriv_id_seq TO xtrole;
120359
 
 
120360
 
 
120361
 
--
120362
 
--
120363
 
 
120364
 
REVOKE ALL ON TABLE hnfc FROM PUBLIC;
120365
 
REVOKE ALL ON TABLE hnfc FROM admin;
120366
 
GRANT ALL ON TABLE hnfc TO admin;
120367
 
GRANT ALL ON TABLE hnfc TO xtrole;
120368
 
 
120369
 
 
120370
 
--
120371
 
--
120372
 
 
120373
 
REVOKE ALL ON SEQUENCE hnfc_hnfc_id_seq FROM PUBLIC;
120374
 
REVOKE ALL ON SEQUENCE hnfc_hnfc_id_seq FROM admin;
120375
 
GRANT ALL ON SEQUENCE hnfc_hnfc_id_seq TO admin;
120376
 
GRANT ALL ON SEQUENCE hnfc_hnfc_id_seq TO xtrole;
120377
 
 
120378
 
 
120379
 
--
120380
 
--
120381
 
 
120382
 
REVOKE ALL ON SEQUENCE incdt_incdt_id_seq FROM PUBLIC;
120383
 
REVOKE ALL ON SEQUENCE incdt_incdt_id_seq FROM admin;
120384
 
GRANT ALL ON SEQUENCE incdt_incdt_id_seq TO admin;
120385
 
GRANT ALL ON SEQUENCE incdt_incdt_id_seq TO xtrole;
120386
 
 
120387
 
 
120388
 
--
120389
 
--
120390
 
 
120391
 
REVOKE ALL ON SEQUENCE incdtcat_incdtcat_id_seq FROM PUBLIC;
120392
 
REVOKE ALL ON SEQUENCE incdtcat_incdtcat_id_seq FROM admin;
120393
 
GRANT ALL ON SEQUENCE incdtcat_incdtcat_id_seq TO admin;
120394
 
GRANT ALL ON SEQUENCE incdtcat_incdtcat_id_seq TO xtrole;
120395
 
 
120396
 
 
120397
 
--
120398
 
--
120399
 
 
120400
 
REVOKE ALL ON TABLE incdthist FROM PUBLIC;
120401
 
REVOKE ALL ON TABLE incdthist FROM admin;
120402
 
GRANT ALL ON TABLE incdthist TO admin;
120403
 
GRANT ALL ON TABLE incdthist TO xtrole;
120404
 
 
120405
 
 
120406
 
--
120407
 
--
120408
 
 
120409
 
REVOKE ALL ON SEQUENCE incdthist_incdthist_id_seq FROM PUBLIC;
120410
 
REVOKE ALL ON SEQUENCE incdthist_incdthist_id_seq FROM admin;
120411
 
GRANT ALL ON SEQUENCE incdthist_incdthist_id_seq TO admin;
120412
 
GRANT ALL ON SEQUENCE incdthist_incdthist_id_seq TO xtrole;
120413
 
 
120414
 
 
120415
 
--
120416
 
--
120417
 
 
120418
 
REVOKE ALL ON SEQUENCE incdtpriority_incdtpriority_id_seq FROM PUBLIC;
120419
 
REVOKE ALL ON SEQUENCE incdtpriority_incdtpriority_id_seq FROM admin;
120420
 
GRANT ALL ON SEQUENCE incdtpriority_incdtpriority_id_seq TO admin;
120421
 
GRANT ALL ON SEQUENCE incdtpriority_incdtpriority_id_seq TO xtrole;
120422
 
 
120423
 
 
120424
 
--
120425
 
--
120426
 
 
120427
 
REVOKE ALL ON SEQUENCE incdtresolution_incdtresolution_id_seq FROM PUBLIC;
120428
 
REVOKE ALL ON SEQUENCE incdtresolution_incdtresolution_id_seq FROM admin;
120429
 
GRANT ALL ON SEQUENCE incdtresolution_incdtresolution_id_seq TO admin;
120430
 
GRANT ALL ON SEQUENCE incdtresolution_incdtresolution_id_seq TO xtrole;
120431
 
 
120432
 
 
120433
 
--
120434
 
--
120435
 
 
120436
 
REVOKE ALL ON SEQUENCE incdtseverity_incdtseverity_id_seq FROM PUBLIC;
120437
 
REVOKE ALL ON SEQUENCE incdtseverity_incdtseverity_id_seq FROM admin;
120438
 
GRANT ALL ON SEQUENCE incdtseverity_incdtseverity_id_seq TO admin;
120439
 
GRANT ALL ON SEQUENCE incdtseverity_incdtseverity_id_seq TO xtrole;
120440
 
 
120441
 
 
120442
 
--
120443
 
--
120444
 
 
120445
 
REVOKE ALL ON SEQUENCE invbal_invbal_id_seq FROM PUBLIC;
120446
 
REVOKE ALL ON SEQUENCE invbal_invbal_id_seq FROM admin;
120447
 
GRANT ALL ON SEQUENCE invbal_invbal_id_seq TO admin;
120448
 
GRANT ALL ON SEQUENCE invbal_invbal_id_seq TO xtrole;
120449
 
 
120450
 
 
120451
 
--
120452
 
--
120453
 
 
120454
 
REVOKE ALL ON SEQUENCE invc_invc_id_seq FROM PUBLIC;
120455
 
REVOKE ALL ON SEQUENCE invc_invc_id_seq FROM admin;
120456
 
GRANT ALL ON SEQUENCE invc_invc_id_seq TO admin;
120457
 
GRANT ALL ON SEQUENCE invc_invc_id_seq TO xtrole;
120458
 
 
120459
 
 
120460
 
--
120461
 
--
120462
 
 
120463
 
REVOKE ALL ON SEQUENCE invchead_invchead_id_seq FROM PUBLIC;
120464
 
REVOKE ALL ON SEQUENCE invchead_invchead_id_seq FROM admin;
120465
 
GRANT ALL ON SEQUENCE invchead_invchead_id_seq TO admin;
120466
 
GRANT ALL ON SEQUENCE invchead_invchead_id_seq TO xtrole;
120467
 
 
120468
 
 
120469
 
--
120470
 
--
120471
 
 
120472
 
REVOKE ALL ON TABLE invcheadtax FROM PUBLIC;
120473
 
REVOKE ALL ON TABLE invcheadtax FROM admin;
120474
 
GRANT ALL ON TABLE invcheadtax TO admin;
120475
 
GRANT ALL ON TABLE invcheadtax TO xtrole;
120476
 
 
120477
 
 
120478
 
--
120479
 
--
120480
 
 
120481
 
REVOKE ALL ON SEQUENCE invcitem_invcitem_id_seq FROM PUBLIC;
120482
 
REVOKE ALL ON SEQUENCE invcitem_invcitem_id_seq FROM admin;
120483
 
GRANT ALL ON SEQUENCE invcitem_invcitem_id_seq TO admin;
120484
 
GRANT ALL ON SEQUENCE invcitem_invcitem_id_seq TO xtrole;
120485
 
 
120486
 
 
120487
 
--
120488
 
--
120489
 
 
120490
 
REVOKE ALL ON TABLE invcitemtax FROM PUBLIC;
120491
 
REVOKE ALL ON TABLE invcitemtax FROM admin;
120492
 
GRANT ALL ON TABLE invcitemtax TO admin;
120493
 
GRANT ALL ON TABLE invcitemtax TO xtrole;
120494
 
 
120495
 
 
120496
 
--
120497
 
--
120498
 
 
120499
 
REVOKE ALL ON SEQUENCE invcnt_invcnt_id_seq FROM PUBLIC;
120500
 
REVOKE ALL ON SEQUENCE invcnt_invcnt_id_seq FROM admin;
120501
 
GRANT ALL ON SEQUENCE invcnt_invcnt_id_seq TO admin;
120502
 
GRANT ALL ON SEQUENCE invcnt_invcnt_id_seq TO xtrole;
120503
 
 
120504
 
 
120505
 
--
120506
 
--
120507
 
 
120508
 
REVOKE ALL ON TABLE invdetail FROM PUBLIC;
120509
 
REVOKE ALL ON TABLE invdetail FROM admin;
120510
 
GRANT ALL ON TABLE invdetail TO admin;
120511
 
GRANT ALL ON TABLE invdetail TO xtrole;
120512
 
 
120513
 
 
120514
 
--
120515
 
--
120516
 
 
120517
 
REVOKE ALL ON SEQUENCE invdetail_invdetail_id_seq FROM PUBLIC;
120518
 
REVOKE ALL ON SEQUENCE invdetail_invdetail_id_seq FROM admin;
120519
 
GRANT ALL ON SEQUENCE invdetail_invdetail_id_seq TO admin;
120520
 
GRANT ALL ON SEQUENCE invdetail_invdetail_id_seq TO xtrole;
120521
 
 
120522
 
 
120523
 
--
120524
 
--
120525
 
 
120526
 
REVOKE ALL ON TABLE invhist FROM PUBLIC;
120527
 
REVOKE ALL ON TABLE invhist FROM admin;
120528
 
GRANT ALL ON TABLE invhist TO admin;
120529
 
GRANT ALL ON TABLE invhist TO xtrole;
120530
 
 
120531
 
 
120532
 
--
120533
 
--
120534
 
 
120535
 
REVOKE ALL ON SEQUENCE invhist_invhist_id_seq FROM PUBLIC;
120536
 
REVOKE ALL ON SEQUENCE invhist_invhist_id_seq FROM admin;
120537
 
GRANT ALL ON SEQUENCE invhist_invhist_id_seq TO admin;
120538
 
GRANT ALL ON SEQUENCE invhist_invhist_id_seq TO xtrole;
120539
 
 
120540
 
 
120541
 
--
120542
 
--
120543
 
 
120544
 
REVOKE ALL ON TABLE invhistexpcat FROM PUBLIC;
120545
 
REVOKE ALL ON TABLE invhistexpcat FROM admin;
120546
 
GRANT ALL ON TABLE invhistexpcat TO admin;
120547
 
GRANT ALL ON TABLE invhistexpcat TO xtrole;
120548
 
 
120549
 
 
120550
 
--
120551
 
--
120552
 
 
120553
 
REVOKE ALL ON SEQUENCE invhistexpcat_invhistexpcat_id_seq FROM PUBLIC;
120554
 
REVOKE ALL ON SEQUENCE invhistexpcat_invhistexpcat_id_seq FROM admin;
120555
 
GRANT ALL ON SEQUENCE invhistexpcat_invhistexpcat_id_seq TO admin;
120556
 
GRANT ALL ON SEQUENCE invhistexpcat_invhistexpcat_id_seq TO xtrole;
120557
 
 
120558
 
 
120559
 
--
120560
 
--
120561
 
 
120562
 
REVOKE ALL ON TABLE invoiceitem FROM PUBLIC;
120563
 
REVOKE ALL ON TABLE invoiceitem FROM admin;
120564
 
GRANT ALL ON TABLE invoiceitem TO admin;
120565
 
GRANT ALL ON TABLE invoiceitem TO xtrole;
120566
 
 
120567
 
 
120568
 
--
120569
 
--
120570
 
 
120571
 
REVOKE ALL ON SEQUENCE ipsass_ipsass_id_seq FROM PUBLIC;
120572
 
REVOKE ALL ON SEQUENCE ipsass_ipsass_id_seq FROM admin;
120573
 
GRANT ALL ON SEQUENCE ipsass_ipsass_id_seq TO admin;
120574
 
GRANT ALL ON SEQUENCE ipsass_ipsass_id_seq TO xtrole;
120575
 
 
120576
 
 
120577
 
--
120578
 
--
120579
 
 
120580
 
REVOKE ALL ON SEQUENCE ipsctyp_ipsctyp_id_seq FROM PUBLIC;
120581
 
REVOKE ALL ON SEQUENCE ipsctyp_ipsctyp_id_seq FROM admin;
120582
 
GRANT ALL ON SEQUENCE ipsctyp_ipsctyp_id_seq TO admin;
120583
 
GRANT ALL ON SEQUENCE ipsctyp_ipsctyp_id_seq TO xtrole;
120584
 
 
120585
 
 
120586
 
--
120587
 
--
120588
 
 
120589
 
REVOKE ALL ON SEQUENCE ipscust_ipscust_id_seq FROM PUBLIC;
120590
 
REVOKE ALL ON SEQUENCE ipscust_ipscust_id_seq FROM admin;
120591
 
GRANT ALL ON SEQUENCE ipscust_ipscust_id_seq TO admin;
120592
 
GRANT ALL ON SEQUENCE ipscust_ipscust_id_seq TO xtrole;
120593
 
 
120594
 
 
120595
 
--
120596
 
--
120597
 
 
120598
 
REVOKE ALL ON SEQUENCE ipsfreight_ipsfreight_id_seq FROM PUBLIC;
120599
 
REVOKE ALL ON SEQUENCE ipsfreight_ipsfreight_id_seq FROM admin;
120600
 
GRANT ALL ON SEQUENCE ipsfreight_ipsfreight_id_seq TO admin;
120601
 
GRANT ALL ON SEQUENCE ipsfreight_ipsfreight_id_seq TO xtrole;
120602
 
 
120603
 
 
120604
 
--
120605
 
--
120606
 
 
120607
 
REVOKE ALL ON SEQUENCE ipshead_ipshead_id_seq FROM PUBLIC;
120608
 
REVOKE ALL ON SEQUENCE ipshead_ipshead_id_seq FROM admin;
120609
 
GRANT ALL ON SEQUENCE ipshead_ipshead_id_seq TO admin;
120610
 
GRANT ALL ON SEQUENCE ipshead_ipshead_id_seq TO xtrole;
120611
 
 
120612
 
 
120613
 
--
120614
 
--
120615
 
 
120616
 
REVOKE ALL ON SEQUENCE ipsitem_ipsitem_id_seq FROM PUBLIC;
120617
 
REVOKE ALL ON SEQUENCE ipsitem_ipsitem_id_seq FROM admin;
120618
 
GRANT ALL ON SEQUENCE ipsitem_ipsitem_id_seq TO admin;
120619
 
GRANT ALL ON SEQUENCE ipsitem_ipsitem_id_seq TO xtrole;
120620
 
 
120621
 
 
120622
 
--
120623
 
--
120624
 
 
120625
 
REVOKE ALL ON SEQUENCE ipsitemchar_ipsitemchar_id_seq FROM PUBLIC;
120626
 
REVOKE ALL ON SEQUENCE ipsitemchar_ipsitemchar_id_seq FROM admin;
120627
 
GRANT ALL ON SEQUENCE ipsitemchar_ipsitemchar_id_seq TO admin;
120628
 
GRANT ALL ON SEQUENCE ipsitemchar_ipsitemchar_id_seq TO xtrole;
120629
 
 
120630
 
 
120631
 
--
120632
 
--
120633
 
 
120634
 
REVOKE ALL ON TABLE ipsprice FROM PUBLIC;
120635
 
REVOKE ALL ON TABLE ipsprice FROM admin;
120636
 
GRANT ALL ON TABLE ipsprice TO admin;
120637
 
GRANT ALL ON TABLE ipsprice TO xtrole;
120638
 
 
120639
 
 
120640
 
--
120641
 
--
120642
 
 
120643
 
REVOKE ALL ON TABLE ipsprodcat_bak FROM PUBLIC;
120644
 
REVOKE ALL ON TABLE ipsprodcat_bak FROM admin;
120645
 
GRANT ALL ON TABLE ipsprodcat_bak TO admin;
120646
 
GRANT ALL ON TABLE ipsprodcat_bak TO xtrole;
120647
 
 
120648
 
 
120649
 
--
120650
 
--
120651
 
 
120652
 
REVOKE ALL ON SEQUENCE ipsprodcat_ipsprodcat_id_seq FROM PUBLIC;
120653
 
REVOKE ALL ON SEQUENCE ipsprodcat_ipsprodcat_id_seq FROM admin;
120654
 
GRANT ALL ON SEQUENCE ipsprodcat_ipsprodcat_id_seq TO admin;
120655
 
GRANT ALL ON SEQUENCE ipsprodcat_ipsprodcat_id_seq TO xtrole;
120656
 
 
120657
 
 
120658
 
--
120659
 
--
120660
 
 
120661
 
REVOKE ALL ON SEQUENCE item_item_id_seq FROM PUBLIC;
120662
 
REVOKE ALL ON SEQUENCE item_item_id_seq FROM admin;
120663
 
GRANT ALL ON SEQUENCE item_item_id_seq TO admin;
120664
 
GRANT ALL ON SEQUENCE item_item_id_seq TO xtrole;
120665
 
 
120666
 
 
120667
 
--
120668
 
--
120669
 
 
120670
 
REVOKE ALL ON SEQUENCE itemalias_itemalias_id_seq FROM PUBLIC;
120671
 
REVOKE ALL ON SEQUENCE itemalias_itemalias_id_seq FROM admin;
120672
 
GRANT ALL ON SEQUENCE itemalias_itemalias_id_seq TO admin;
120673
 
GRANT ALL ON SEQUENCE itemalias_itemalias_id_seq TO xtrole;
120674
 
 
120675
 
 
120676
 
--
120677
 
--
120678
 
 
120679
 
REVOKE ALL ON SEQUENCE itematr_itematr_id_seq FROM PUBLIC;
120680
 
REVOKE ALL ON SEQUENCE itematr_itematr_id_seq FROM admin;
120681
 
GRANT ALL ON SEQUENCE itematr_itematr_id_seq TO admin;
120682
 
GRANT ALL ON SEQUENCE itematr_itematr_id_seq TO xtrole;
120683
 
 
120684
 
 
120685
 
--
120686
 
--
120687
 
 
120688
 
REVOKE ALL ON SEQUENCE itemcost_itemcost_id_seq FROM PUBLIC;
120689
 
REVOKE ALL ON SEQUENCE itemcost_itemcost_id_seq FROM admin;
120690
 
GRANT ALL ON SEQUENCE itemcost_itemcost_id_seq TO admin;
120691
 
GRANT ALL ON SEQUENCE itemcost_itemcost_id_seq TO xtrole;
120692
 
 
120693
 
 
120694
 
--
120695
 
--
120696
 
 
120697
 
REVOKE ALL ON SEQUENCE itemfrez_itemfrez_seq FROM PUBLIC;
120698
 
REVOKE ALL ON SEQUENCE itemfrez_itemfrez_seq FROM admin;
120699
 
GRANT ALL ON SEQUENCE itemfrez_itemfrez_seq TO admin;
120700
 
GRANT ALL ON SEQUENCE itemfrez_itemfrez_seq TO xtrole;
120701
 
 
120702
 
 
120703
 
--
120704
 
--
120705
 
 
120706
 
REVOKE ALL ON TABLE itemgrp FROM PUBLIC;
120707
 
REVOKE ALL ON TABLE itemgrp FROM admin;
120708
 
GRANT ALL ON TABLE itemgrp TO admin;
120709
 
GRANT ALL ON TABLE itemgrp TO xtrole;
120710
 
 
120711
 
 
120712
 
--
120713
 
--
120714
 
 
120715
 
REVOKE ALL ON SEQUENCE itemgrp_itemgrp_id_seq FROM PUBLIC;
120716
 
REVOKE ALL ON SEQUENCE itemgrp_itemgrp_id_seq FROM admin;
120717
 
GRANT ALL ON SEQUENCE itemgrp_itemgrp_id_seq TO admin;
120718
 
GRANT ALL ON SEQUENCE itemgrp_itemgrp_id_seq TO xtrole;
120719
 
 
120720
 
 
120721
 
--
120722
 
--
120723
 
 
120724
 
REVOKE ALL ON TABLE itemgrpitem FROM PUBLIC;
120725
 
REVOKE ALL ON TABLE itemgrpitem FROM admin;
120726
 
GRANT ALL ON TABLE itemgrpitem TO admin;
120727
 
GRANT ALL ON TABLE itemgrpitem TO xtrole;
120728
 
 
120729
 
 
120730
 
--
120731
 
--
120732
 
 
120733
 
REVOKE ALL ON SEQUENCE itemgrpitem_itemgrpitem_id_seq FROM PUBLIC;
120734
 
REVOKE ALL ON SEQUENCE itemgrpitem_itemgrpitem_id_seq FROM admin;
120735
 
GRANT ALL ON SEQUENCE itemgrpitem_itemgrpitem_id_seq TO admin;
120736
 
GRANT ALL ON SEQUENCE itemgrpitem_itemgrpitem_id_seq TO xtrole;
120737
 
 
120738
 
 
120739
 
--
120740
 
--
120741
 
 
120742
 
REVOKE ALL ON TABLE itemimage FROM PUBLIC;
120743
 
REVOKE ALL ON TABLE itemimage FROM admin;
120744
 
GRANT ALL ON TABLE itemimage TO admin;
120745
 
GRANT ALL ON TABLE itemimage TO xtrole;
120746
 
 
120747
 
 
120748
 
--
120749
 
--
120750
 
 
120751
 
REVOKE ALL ON SEQUENCE itemimage_itemimage_id_seq FROM PUBLIC;
120752
 
REVOKE ALL ON SEQUENCE itemimage_itemimage_id_seq FROM admin;
120753
 
GRANT ALL ON SEQUENCE itemimage_itemimage_id_seq TO admin;
120754
 
GRANT ALL ON SEQUENCE itemimage_itemimage_id_seq TO xtrole;
120755
 
 
120756
 
 
120757
 
--
120758
 
--
120759
 
 
120760
 
REVOKE ALL ON TABLE itemloc FROM PUBLIC;
120761
 
REVOKE ALL ON TABLE itemloc FROM admin;
120762
 
GRANT ALL ON TABLE itemloc TO admin;
120763
 
GRANT ALL ON TABLE itemloc TO xtrole;
120764
 
 
120765
 
 
120766
 
--
120767
 
--
120768
 
 
120769
 
REVOKE ALL ON SEQUENCE itemloc_itemloc_id_seq FROM PUBLIC;
120770
 
REVOKE ALL ON SEQUENCE itemloc_itemloc_id_seq FROM admin;
120771
 
GRANT ALL ON SEQUENCE itemloc_itemloc_id_seq TO admin;
120772
 
GRANT ALL ON SEQUENCE itemloc_itemloc_id_seq TO xtrole;
120773
 
 
120774
 
 
120775
 
--
120776
 
--
120777
 
 
120778
 
REVOKE ALL ON SEQUENCE itemloc_series_seq FROM PUBLIC;
120779
 
REVOKE ALL ON SEQUENCE itemloc_series_seq FROM admin;
120780
 
GRANT ALL ON SEQUENCE itemloc_series_seq TO admin;
120781
 
GRANT ALL ON SEQUENCE itemloc_series_seq TO xtrole;
120782
 
 
120783
 
 
120784
 
--
120785
 
--
120786
 
 
120787
 
REVOKE ALL ON TABLE itemlocdist FROM PUBLIC;
120788
 
REVOKE ALL ON TABLE itemlocdist FROM admin;
120789
 
GRANT ALL ON TABLE itemlocdist TO admin;
120790
 
GRANT ALL ON TABLE itemlocdist TO xtrole;
120791
 
 
120792
 
 
120793
 
--
120794
 
--
120795
 
 
120796
 
REVOKE ALL ON SEQUENCE itemlocdist_itemlocdist_id_seq FROM PUBLIC;
120797
 
REVOKE ALL ON SEQUENCE itemlocdist_itemlocdist_id_seq FROM admin;
120798
 
GRANT ALL ON SEQUENCE itemlocdist_itemlocdist_id_seq TO admin;
120799
 
GRANT ALL ON SEQUENCE itemlocdist_itemlocdist_id_seq TO xtrole;
120800
 
 
120801
 
 
120802
 
--
120803
 
--
120804
 
 
120805
 
REVOKE ALL ON TABLE itemlocpost FROM PUBLIC;
120806
 
REVOKE ALL ON TABLE itemlocpost FROM admin;
120807
 
GRANT ALL ON TABLE itemlocpost TO admin;
120808
 
GRANT ALL ON TABLE itemlocpost TO xtrole;
120809
 
 
120810
 
 
120811
 
--
120812
 
--
120813
 
 
120814
 
REVOKE ALL ON SEQUENCE itemlocpost_itemlocpost_id_seq FROM PUBLIC;
120815
 
REVOKE ALL ON SEQUENCE itemlocpost_itemlocpost_id_seq FROM admin;
120816
 
GRANT ALL ON SEQUENCE itemlocpost_itemlocpost_id_seq TO admin;
120817
 
GRANT ALL ON SEQUENCE itemlocpost_itemlocpost_id_seq TO xtrole;
120818
 
 
120819
 
 
120820
 
--
120821
 
--
120822
 
 
120823
 
REVOKE ALL ON SEQUENCE itemopn_itemopn_id_seq FROM PUBLIC;
120824
 
REVOKE ALL ON SEQUENCE itemopn_itemopn_id_seq FROM admin;
120825
 
GRANT ALL ON SEQUENCE itemopn_itemopn_id_seq TO admin;
120826
 
GRANT ALL ON SEQUENCE itemopn_itemopn_id_seq TO xtrole;
120827
 
 
120828
 
 
120829
 
--
120830
 
--
120831
 
 
120832
 
REVOKE ALL ON SEQUENCE itemsite_itemsite_id_seq FROM PUBLIC;
120833
 
REVOKE ALL ON SEQUENCE itemsite_itemsite_id_seq FROM admin;
120834
 
GRANT ALL ON SEQUENCE itemsite_itemsite_id_seq TO admin;
120835
 
GRANT ALL ON SEQUENCE itemsite_itemsite_id_seq TO xtrole;
120836
 
 
120837
 
 
120838
 
--
120839
 
--
120840
 
 
120841
 
REVOKE ALL ON SEQUENCE itemsrc_itemsrc_id_seq FROM PUBLIC;
120842
 
REVOKE ALL ON SEQUENCE itemsrc_itemsrc_id_seq FROM admin;
120843
 
GRANT ALL ON SEQUENCE itemsrc_itemsrc_id_seq TO admin;
120844
 
GRANT ALL ON SEQUENCE itemsrc_itemsrc_id_seq TO xtrole;
120845
 
 
120846
 
 
120847
 
--
120848
 
--
120849
 
 
120850
 
REVOKE ALL ON SEQUENCE itemsrcp_itemsrcp_id_seq FROM PUBLIC;
120851
 
REVOKE ALL ON SEQUENCE itemsrcp_itemsrcp_id_seq FROM admin;
120852
 
GRANT ALL ON SEQUENCE itemsrcp_itemsrcp_id_seq TO admin;
120853
 
GRANT ALL ON SEQUENCE itemsrcp_itemsrcp_id_seq TO xtrole;
120854
 
 
120855
 
 
120856
 
--
120857
 
--
120858
 
 
120859
 
REVOKE ALL ON SEQUENCE itemsub_itemsub_id_seq FROM PUBLIC;
120860
 
REVOKE ALL ON SEQUENCE itemsub_itemsub_id_seq FROM admin;
120861
 
GRANT ALL ON SEQUENCE itemsub_itemsub_id_seq TO admin;
120862
 
GRANT ALL ON SEQUENCE itemsub_itemsub_id_seq TO xtrole;
120863
 
 
120864
 
 
120865
 
--
120866
 
--
120867
 
 
120868
 
REVOKE ALL ON SEQUENCE itemtax_itemtax_id_seq FROM PUBLIC;
120869
 
REVOKE ALL ON SEQUENCE itemtax_itemtax_id_seq FROM admin;
120870
 
GRANT ALL ON SEQUENCE itemtax_itemtax_id_seq TO admin;
120871
 
GRANT ALL ON SEQUENCE itemtax_itemtax_id_seq TO xtrole;
120872
 
 
120873
 
 
120874
 
--
120875
 
--
120876
 
 
120877
 
REVOKE ALL ON TABLE itemtrans FROM PUBLIC;
120878
 
REVOKE ALL ON TABLE itemtrans FROM admin;
120879
 
GRANT ALL ON TABLE itemtrans TO admin;
120880
 
GRANT ALL ON TABLE itemtrans TO xtrole;
120881
 
 
120882
 
 
120883
 
--
120884
 
--
120885
 
 
120886
 
REVOKE ALL ON SEQUENCE itemtrans_itemtrans_id_seq FROM PUBLIC;
120887
 
REVOKE ALL ON SEQUENCE itemtrans_itemtrans_id_seq FROM admin;
120888
 
GRANT ALL ON SEQUENCE itemtrans_itemtrans_id_seq TO admin;
120889
 
GRANT ALL ON SEQUENCE itemtrans_itemtrans_id_seq TO xtrole;
120890
 
 
120891
 
 
120892
 
--
120893
 
--
120894
 
 
120895
 
REVOKE ALL ON TABLE itemuom FROM PUBLIC;
120896
 
REVOKE ALL ON TABLE itemuom FROM admin;
120897
 
GRANT ALL ON TABLE itemuom TO admin;
120898
 
GRANT ALL ON TABLE itemuom TO xtrole;
120899
 
 
120900
 
 
120901
 
--
120902
 
--
120903
 
 
120904
 
REVOKE ALL ON SEQUENCE itemuom_itemuom_id_seq FROM PUBLIC;
120905
 
REVOKE ALL ON SEQUENCE itemuom_itemuom_id_seq FROM admin;
120906
 
GRANT ALL ON SEQUENCE itemuom_itemuom_id_seq TO admin;
120907
 
GRANT ALL ON SEQUENCE itemuom_itemuom_id_seq TO xtrole;
120908
 
 
120909
 
 
120910
 
--
120911
 
--
120912
 
 
120913
 
REVOKE ALL ON SEQUENCE itemuomconv_itemuomconv_id_seq FROM PUBLIC;
120914
 
REVOKE ALL ON SEQUENCE itemuomconv_itemuomconv_id_seq FROM admin;
120915
 
GRANT ALL ON SEQUENCE itemuomconv_itemuomconv_id_seq TO admin;
120916
 
GRANT ALL ON SEQUENCE itemuomconv_itemuomconv_id_seq TO xtrole;
120917
 
 
120918
 
 
120919
 
--
120920
 
--
120921
 
 
120922
 
REVOKE ALL ON SEQUENCE journal_number_seq FROM PUBLIC;
120923
 
REVOKE ALL ON SEQUENCE journal_number_seq FROM admin;
120924
 
GRANT ALL ON SEQUENCE journal_number_seq TO admin;
120925
 
GRANT ALL ON SEQUENCE journal_number_seq TO xtrole;
120926
 
 
120927
 
 
120928
 
--
120929
 
--
120930
 
 
120931
 
REVOKE ALL ON TABLE jrnluse FROM PUBLIC;
120932
 
REVOKE ALL ON TABLE jrnluse FROM admin;
120933
 
GRANT ALL ON TABLE jrnluse TO admin;
120934
 
GRANT ALL ON TABLE jrnluse TO xtrole;
120935
 
 
120936
 
 
120937
 
--
120938
 
--
120939
 
 
120940
 
REVOKE ALL ON SEQUENCE jrnluse_jrnluse_id_seq FROM PUBLIC;
120941
 
REVOKE ALL ON SEQUENCE jrnluse_jrnluse_id_seq FROM admin;
120942
 
GRANT ALL ON SEQUENCE jrnluse_jrnluse_id_seq TO admin;
120943
 
GRANT ALL ON SEQUENCE jrnluse_jrnluse_id_seq TO xtrole;
120944
 
 
120945
 
 
120946
 
--
120947
 
--
120948
 
 
120949
 
REVOKE ALL ON TABLE labeldef FROM PUBLIC;
120950
 
REVOKE ALL ON TABLE labeldef FROM admin;
120951
 
GRANT ALL ON TABLE labeldef TO admin;
120952
 
GRANT ALL ON TABLE labeldef TO xtrole;
120953
 
 
120954
 
 
120955
 
--
120956
 
--
120957
 
 
120958
 
REVOKE ALL ON SEQUENCE labeldef_labeldef_id_seq FROM PUBLIC;
120959
 
REVOKE ALL ON SEQUENCE labeldef_labeldef_id_seq FROM admin;
120960
 
GRANT ALL ON SEQUENCE labeldef_labeldef_id_seq TO admin;
120961
 
GRANT ALL ON SEQUENCE labeldef_labeldef_id_seq TO xtrole;
120962
 
 
120963
 
 
120964
 
--
120965
 
--
120966
 
 
120967
 
REVOKE ALL ON TABLE labelform FROM PUBLIC;
120968
 
REVOKE ALL ON TABLE labelform FROM admin;
120969
 
GRANT ALL ON TABLE labelform TO admin;
120970
 
GRANT ALL ON TABLE labelform TO xtrole;
120971
 
 
120972
 
 
120973
 
--
120974
 
--
120975
 
 
120976
 
REVOKE ALL ON SEQUENCE labelform_labelform_id_seq FROM PUBLIC;
120977
 
REVOKE ALL ON SEQUENCE labelform_labelform_id_seq FROM admin;
120978
 
GRANT ALL ON SEQUENCE labelform_labelform_id_seq TO admin;
120979
 
GRANT ALL ON SEQUENCE labelform_labelform_id_seq TO xtrole;
120980
 
 
120981
 
 
120982
 
--
120983
 
--
120984
 
 
120985
 
REVOKE ALL ON TABLE lang FROM PUBLIC;
120986
 
REVOKE ALL ON TABLE lang FROM admin;
120987
 
GRANT ALL ON TABLE lang TO admin;
120988
 
GRANT ALL ON TABLE lang TO xtrole;
120989
 
 
120990
 
 
120991
 
--
120992
 
--
120993
 
 
120994
 
REVOKE ALL ON SEQUENCE lang_lang_id_seq FROM PUBLIC;
120995
 
REVOKE ALL ON SEQUENCE lang_lang_id_seq FROM admin;
120996
 
GRANT ALL ON SEQUENCE lang_lang_id_seq TO admin;
120997
 
GRANT ALL ON SEQUENCE lang_lang_id_seq TO xtrole;
120998
 
 
120999
 
 
121000
 
--
121001
 
--
121002
 
 
121003
 
REVOKE ALL ON TABLE locale FROM PUBLIC;
121004
 
REVOKE ALL ON TABLE locale FROM admin;
121005
 
GRANT ALL ON TABLE locale TO admin;
121006
 
GRANT ALL ON TABLE locale TO xtrole;
121007
 
 
121008
 
 
121009
 
--
121010
 
--
121011
 
 
121012
 
REVOKE ALL ON SEQUENCE locale_locale_id_seq FROM PUBLIC;
121013
 
REVOKE ALL ON SEQUENCE locale_locale_id_seq FROM admin;
121014
 
GRANT ALL ON SEQUENCE locale_locale_id_seq TO admin;
121015
 
GRANT ALL ON SEQUENCE locale_locale_id_seq TO xtrole;
121016
 
 
121017
 
 
121018
 
--
121019
 
--
121020
 
 
121021
 
REVOKE ALL ON SEQUENCE location_location_id_seq FROM PUBLIC;
121022
 
REVOKE ALL ON SEQUENCE location_location_id_seq FROM admin;
121023
 
GRANT ALL ON SEQUENCE location_location_id_seq TO admin;
121024
 
GRANT ALL ON SEQUENCE location_location_id_seq TO xtrole;
121025
 
 
121026
 
 
121027
 
--
121028
 
--
121029
 
 
121030
 
REVOKE ALL ON TABLE locitem FROM PUBLIC;
121031
 
REVOKE ALL ON TABLE locitem FROM admin;
121032
 
GRANT ALL ON TABLE locitem TO admin;
121033
 
GRANT ALL ON TABLE locitem TO xtrole;
121034
 
 
121035
 
 
121036
 
--
121037
 
--
121038
 
 
121039
 
REVOKE ALL ON SEQUENCE locitem_locitem_id_seq FROM PUBLIC;
121040
 
REVOKE ALL ON SEQUENCE locitem_locitem_id_seq FROM admin;
121041
 
GRANT ALL ON SEQUENCE locitem_locitem_id_seq TO admin;
121042
 
GRANT ALL ON SEQUENCE locitem_locitem_id_seq TO xtrole;
121043
 
 
121044
 
 
121045
 
--
121046
 
--
121047
 
 
121048
 
REVOKE ALL ON SEQUENCE log_log_id_seq FROM PUBLIC;
121049
 
REVOKE ALL ON SEQUENCE log_log_id_seq FROM admin;
121050
 
GRANT ALL ON SEQUENCE log_log_id_seq TO admin;
121051
 
GRANT ALL ON SEQUENCE log_log_id_seq TO xtrole;
121052
 
 
121053
 
 
121054
 
--
121055
 
--
121056
 
 
121057
 
REVOKE ALL ON TABLE metric FROM PUBLIC;
121058
 
REVOKE ALL ON TABLE metric FROM admin;
121059
 
GRANT ALL ON TABLE metric TO admin;
121060
 
GRANT ALL ON TABLE metric TO xtrole;
121061
 
 
121062
 
 
121063
 
--
121064
 
--
121065
 
 
121066
 
REVOKE ALL ON SEQUENCE metric_metric_id_seq FROM PUBLIC;
121067
 
REVOKE ALL ON SEQUENCE metric_metric_id_seq FROM admin;
121068
 
GRANT ALL ON SEQUENCE metric_metric_id_seq TO admin;
121069
 
GRANT ALL ON SEQUENCE metric_metric_id_seq TO xtrole;
121070
 
 
121071
 
 
121072
 
--
121073
 
--
121074
 
 
121075
 
REVOKE ALL ON TABLE metricenc FROM PUBLIC;
121076
 
REVOKE ALL ON TABLE metricenc FROM admin;
121077
 
GRANT ALL ON TABLE metricenc TO admin;
121078
 
GRANT ALL ON TABLE metricenc TO xtrole;
121079
 
 
121080
 
 
121081
 
--
121082
 
--
121083
 
 
121084
 
REVOKE ALL ON SEQUENCE metricenc_metricenc_id_seq FROM PUBLIC;
121085
 
REVOKE ALL ON SEQUENCE metricenc_metricenc_id_seq FROM admin;
121086
 
GRANT ALL ON SEQUENCE metricenc_metricenc_id_seq TO admin;
121087
 
GRANT ALL ON SEQUENCE metricenc_metricenc_id_seq TO xtrole;
121088
 
 
121089
 
 
121090
 
--
121091
 
--
121092
 
 
121093
 
REVOKE ALL ON SEQUENCE misc_index_seq FROM PUBLIC;
121094
 
REVOKE ALL ON SEQUENCE misc_index_seq FROM admin;
121095
 
GRANT ALL ON SEQUENCE misc_index_seq TO admin;
121096
 
GRANT ALL ON SEQUENCE misc_index_seq TO xtrole;
121097
 
 
121098
 
 
121099
 
--
121100
 
--
121101
 
 
121102
 
REVOKE ALL ON TABLE mrghist FROM PUBLIC;
121103
 
REVOKE ALL ON TABLE mrghist FROM admin;
121104
 
GRANT ALL ON TABLE mrghist TO admin;
121105
 
GRANT ALL ON TABLE mrghist TO xtrole;
121106
 
 
121107
 
 
121108
 
--
121109
 
--
121110
 
 
121111
 
REVOKE ALL ON TABLE mrgundo FROM PUBLIC;
121112
 
REVOKE ALL ON TABLE mrgundo FROM admin;
121113
 
GRANT ALL ON TABLE mrgundo TO admin;
121114
 
GRANT ALL ON TABLE mrgundo TO xtrole;
121115
 
 
121116
 
 
121117
 
--
121118
 
--
121119
 
 
121120
 
REVOKE ALL ON TABLE msg FROM PUBLIC;
121121
 
REVOKE ALL ON TABLE msg FROM admin;
121122
 
GRANT ALL ON TABLE msg TO admin;
121123
 
GRANT ALL ON TABLE msg TO xtrole;
121124
 
 
121125
 
 
121126
 
--
121127
 
--
121128
 
 
121129
 
REVOKE ALL ON SEQUENCE msg_msg_id_seq FROM PUBLIC;
121130
 
REVOKE ALL ON SEQUENCE msg_msg_id_seq FROM admin;
121131
 
GRANT ALL ON SEQUENCE msg_msg_id_seq TO admin;
121132
 
GRANT ALL ON SEQUENCE msg_msg_id_seq TO xtrole;
121133
 
 
121134
 
 
121135
 
--
121136
 
--
121137
 
 
121138
 
REVOKE ALL ON TABLE msguser FROM PUBLIC;
121139
 
REVOKE ALL ON TABLE msguser FROM admin;
121140
 
GRANT ALL ON TABLE msguser TO admin;
121141
 
GRANT ALL ON TABLE msguser TO xtrole;
121142
 
 
121143
 
 
121144
 
--
121145
 
--
121146
 
 
121147
 
REVOKE ALL ON SEQUENCE msguser_msguser_id_seq FROM PUBLIC;
121148
 
REVOKE ALL ON SEQUENCE msguser_msguser_id_seq FROM admin;
121149
 
GRANT ALL ON SEQUENCE msguser_msguser_id_seq TO admin;
121150
 
GRANT ALL ON SEQUENCE msguser_msguser_id_seq TO xtrole;
121151
 
 
121152
 
 
121153
 
--
121154
 
--
121155
 
 
121156
 
REVOKE ALL ON SEQUENCE nvend_nvend_id_seq FROM PUBLIC;
121157
 
REVOKE ALL ON SEQUENCE nvend_nvend_id_seq FROM admin;
121158
 
GRANT ALL ON SEQUENCE nvend_nvend_id_seq TO admin;
121159
 
GRANT ALL ON SEQUENCE nvend_nvend_id_seq TO xtrole;
121160
 
 
121161
 
 
121162
 
--
121163
 
--
121164
 
 
121165
 
REVOKE ALL ON TABLE obsolete_tax FROM PUBLIC;
121166
 
REVOKE ALL ON TABLE obsolete_tax FROM admin;
121167
 
GRANT ALL ON TABLE obsolete_tax TO admin;
121168
 
GRANT ALL ON TABLE obsolete_tax TO xtrole;
121169
 
 
121170
 
 
121171
 
--
121172
 
--
121173
 
 
121174
 
REVOKE ALL ON SEQUENCE ophead_ophead_id_seq FROM PUBLIC;
121175
 
REVOKE ALL ON SEQUENCE ophead_ophead_id_seq FROM admin;
121176
 
GRANT ALL ON SEQUENCE ophead_ophead_id_seq TO admin;
121177
 
GRANT ALL ON SEQUENCE ophead_ophead_id_seq TO xtrole;
121178
 
 
121179
 
 
121180
 
--
121181
 
--
121182
 
 
121183
 
REVOKE ALL ON TABLE opsource FROM PUBLIC;
121184
 
REVOKE ALL ON TABLE opsource FROM admin;
121185
 
GRANT ALL ON TABLE opsource TO admin;
121186
 
GRANT ALL ON TABLE opsource TO xtrole;
121187
 
 
121188
 
 
121189
 
--
121190
 
--
121191
 
 
121192
 
REVOKE ALL ON SEQUENCE opsource_opsource_id_seq FROM PUBLIC;
121193
 
REVOKE ALL ON SEQUENCE opsource_opsource_id_seq FROM admin;
121194
 
GRANT ALL ON SEQUENCE opsource_opsource_id_seq TO admin;
121195
 
GRANT ALL ON SEQUENCE opsource_opsource_id_seq TO xtrole;
121196
 
 
121197
 
 
121198
 
--
121199
 
--
121200
 
 
121201
 
REVOKE ALL ON TABLE opstage FROM PUBLIC;
121202
 
REVOKE ALL ON TABLE opstage FROM admin;
121203
 
GRANT ALL ON TABLE opstage TO admin;
121204
 
GRANT ALL ON TABLE opstage TO xtrole;
121205
 
 
121206
 
 
121207
 
--
121208
 
--
121209
 
 
121210
 
REVOKE ALL ON SEQUENCE opstage_opstage_id_seq FROM PUBLIC;
121211
 
REVOKE ALL ON SEQUENCE opstage_opstage_id_seq FROM admin;
121212
 
GRANT ALL ON SEQUENCE opstage_opstage_id_seq TO admin;
121213
 
GRANT ALL ON SEQUENCE opstage_opstage_id_seq TO xtrole;
121214
 
 
121215
 
 
121216
 
--
121217
 
--
121218
 
 
121219
 
REVOKE ALL ON TABLE optype FROM PUBLIC;
121220
 
REVOKE ALL ON TABLE optype FROM admin;
121221
 
GRANT ALL ON TABLE optype TO admin;
121222
 
GRANT ALL ON TABLE optype TO xtrole;
121223
 
 
121224
 
 
121225
 
--
121226
 
--
121227
 
 
121228
 
REVOKE ALL ON SEQUENCE optype_optype_id_seq FROM PUBLIC;
121229
 
REVOKE ALL ON SEQUENCE optype_optype_id_seq FROM admin;
121230
 
GRANT ALL ON SEQUENCE optype_optype_id_seq TO admin;
121231
 
GRANT ALL ON SEQUENCE optype_optype_id_seq TO xtrole;
121232
 
 
121233
 
 
121234
 
--
121235
 
--
121236
 
 
121237
 
REVOKE ALL ON TABLE orderhead FROM PUBLIC;
121238
 
REVOKE ALL ON TABLE orderhead FROM admin;
121239
 
GRANT ALL ON TABLE orderhead TO admin;
121240
 
GRANT ALL ON TABLE orderhead TO xtrole;
121241
 
 
121242
 
 
121243
 
--
121244
 
--
121245
 
 
121246
 
REVOKE ALL ON TABLE orderitem FROM PUBLIC;
121247
 
REVOKE ALL ON TABLE orderitem FROM admin;
121248
 
GRANT ALL ON TABLE orderitem TO admin;
121249
 
GRANT ALL ON TABLE orderitem TO xtrole;
121250
 
 
121251
 
 
121252
 
--
121253
 
--
121254
 
 
121255
 
REVOKE ALL ON TABLE orderseq FROM PUBLIC;
121256
 
REVOKE ALL ON TABLE orderseq FROM admin;
121257
 
GRANT ALL ON TABLE orderseq TO admin;
121258
 
GRANT ALL ON TABLE orderseq TO xtrole;
121259
 
 
121260
 
 
121261
 
--
121262
 
--
121263
 
 
121264
 
REVOKE ALL ON SEQUENCE orderseq_orderseq_id_seq FROM PUBLIC;
121265
 
REVOKE ALL ON SEQUENCE orderseq_orderseq_id_seq FROM admin;
121266
 
GRANT ALL ON SEQUENCE orderseq_orderseq_id_seq TO admin;
121267
 
GRANT ALL ON SEQUENCE orderseq_orderseq_id_seq TO xtrole;
121268
 
 
121269
 
 
121270
 
--
121271
 
--
121272
 
 
121273
 
REVOKE ALL ON TABLE pack FROM PUBLIC;
121274
 
REVOKE ALL ON TABLE pack FROM admin;
121275
 
GRANT ALL ON TABLE pack TO admin;
121276
 
GRANT ALL ON TABLE pack TO xtrole;
121277
 
 
121278
 
 
121279
 
--
121280
 
--
121281
 
 
121282
 
REVOKE ALL ON SEQUENCE pack_pack_id_seq FROM PUBLIC;
121283
 
REVOKE ALL ON SEQUENCE pack_pack_id_seq FROM admin;
121284
 
GRANT ALL ON SEQUENCE pack_pack_id_seq TO admin;
121285
 
GRANT ALL ON SEQUENCE pack_pack_id_seq TO xtrole;
121286
 
 
121287
 
 
121288
 
--
121289
 
--
121290
 
 
121291
 
REVOKE ALL ON TABLE payaropen FROM PUBLIC;
121292
 
REVOKE ALL ON TABLE payaropen FROM admin;
121293
 
GRANT ALL ON TABLE payaropen TO admin;
121294
 
GRANT ALL ON TABLE payaropen TO xtrole;
121295
 
 
121296
 
 
121297
 
--
121298
 
--
121299
 
 
121300
 
REVOKE ALL ON TABLE payco FROM PUBLIC;
121301
 
REVOKE ALL ON TABLE payco FROM admin;
121302
 
GRANT ALL ON TABLE payco TO admin;
121303
 
GRANT ALL ON TABLE payco TO xtrole;
121304
 
 
121305
 
 
121306
 
--
121307
 
--
121308
 
 
121309
 
REVOKE ALL ON SEQUENCE payco_payco_id_seq FROM PUBLIC;
121310
 
REVOKE ALL ON SEQUENCE payco_payco_id_seq FROM admin;
121311
 
GRANT ALL ON SEQUENCE payco_payco_id_seq TO admin;
121312
 
GRANT ALL ON SEQUENCE payco_payco_id_seq TO xtrole;
121313
 
 
121314
 
 
121315
 
--
121316
 
--
121317
 
 
121318
 
REVOKE ALL ON SEQUENCE period_period_id_seq FROM PUBLIC;
121319
 
REVOKE ALL ON SEQUENCE period_period_id_seq FROM admin;
121320
 
GRANT ALL ON SEQUENCE period_period_id_seq TO admin;
121321
 
GRANT ALL ON SEQUENCE period_period_id_seq TO xtrole;
121322
 
 
121323
 
 
121324
 
--
121325
 
--
121326
 
 
121327
 
REVOKE ALL ON TABLE pkgdep FROM PUBLIC;
121328
 
REVOKE ALL ON TABLE pkgdep FROM admin;
121329
 
GRANT ALL ON TABLE pkgdep TO admin;
121330
 
GRANT ALL ON TABLE pkgdep TO xtrole;
121331
 
 
121332
 
 
121333
 
--
121334
 
--
121335
 
 
121336
 
REVOKE ALL ON SEQUENCE pkgdep_pkgdep_id_seq FROM PUBLIC;
121337
 
REVOKE ALL ON SEQUENCE pkgdep_pkgdep_id_seq FROM admin;
121338
 
GRANT ALL ON SEQUENCE pkgdep_pkgdep_id_seq TO admin;
121339
 
GRANT ALL ON SEQUENCE pkgdep_pkgdep_id_seq TO xtrole;
121340
 
 
121341
 
 
121342
 
--
121343
 
--
121344
 
 
121345
 
REVOKE ALL ON TABLE pkghead FROM PUBLIC;
121346
 
REVOKE ALL ON TABLE pkghead FROM admin;
121347
 
GRANT ALL ON TABLE pkghead TO admin;
121348
 
GRANT ALL ON TABLE pkghead TO xtrole;
121349
 
 
121350
 
 
121351
 
--
121352
 
--
121353
 
 
121354
 
REVOKE ALL ON SEQUENCE pkghead_pkghead_id_seq FROM PUBLIC;
121355
 
REVOKE ALL ON SEQUENCE pkghead_pkghead_id_seq FROM admin;
121356
 
GRANT ALL ON SEQUENCE pkghead_pkghead_id_seq TO admin;
121357
 
GRANT ALL ON SEQUENCE pkghead_pkghead_id_seq TO xtrole;
121358
 
 
121359
 
 
121360
 
--
121361
 
--
121362
 
 
121363
 
REVOKE ALL ON TABLE pkgitem FROM PUBLIC;
121364
 
REVOKE ALL ON TABLE pkgitem FROM admin;
121365
 
GRANT ALL ON TABLE pkgitem TO admin;
121366
 
GRANT ALL ON TABLE pkgitem TO xtrole;
121367
 
 
121368
 
 
121369
 
--
121370
 
--
121371
 
 
121372
 
REVOKE ALL ON SEQUENCE pkgitem_pkgitem_id_seq FROM PUBLIC;
121373
 
REVOKE ALL ON SEQUENCE pkgitem_pkgitem_id_seq FROM admin;
121374
 
GRANT ALL ON SEQUENCE pkgitem_pkgitem_id_seq TO admin;
121375
 
GRANT ALL ON SEQUENCE pkgitem_pkgitem_id_seq TO xtrole;
121376
 
 
121377
 
 
121378
 
--
121379
 
--
121380
 
 
121381
 
REVOKE ALL ON SEQUENCE plancode_plancode_id_seq FROM PUBLIC;
121382
 
REVOKE ALL ON SEQUENCE plancode_plancode_id_seq FROM admin;
121383
 
GRANT ALL ON SEQUENCE plancode_plancode_id_seq TO admin;
121384
 
GRANT ALL ON SEQUENCE plancode_plancode_id_seq TO xtrole;
121385
 
 
121386
 
 
121387
 
--
121388
 
--
121389
 
 
121390
 
REVOKE ALL ON SEQUENCE planord_planord_id_seq FROM PUBLIC;
121391
 
REVOKE ALL ON SEQUENCE planord_planord_id_seq FROM admin;
121392
 
GRANT ALL ON SEQUENCE planord_planord_id_seq TO admin;
121393
 
GRANT ALL ON SEQUENCE planord_planord_id_seq TO xtrole;
121394
 
 
121395
 
 
121396
 
--
121397
 
--
121398
 
 
121399
 
REVOKE ALL ON SEQUENCE pohead_pohead_id_seq FROM PUBLIC;
121400
 
REVOKE ALL ON SEQUENCE pohead_pohead_id_seq FROM admin;
121401
 
GRANT ALL ON SEQUENCE pohead_pohead_id_seq TO admin;
121402
 
GRANT ALL ON SEQUENCE pohead_pohead_id_seq TO xtrole;
121403
 
 
121404
 
 
121405
 
--
121406
 
--
121407
 
 
121408
 
REVOKE ALL ON SEQUENCE poitem_poitem_id_seq FROM PUBLIC;
121409
 
REVOKE ALL ON SEQUENCE poitem_poitem_id_seq FROM admin;
121410
 
GRANT ALL ON SEQUENCE poitem_poitem_id_seq TO admin;
121411
 
GRANT ALL ON SEQUENCE poitem_poitem_id_seq TO xtrole;
121412
 
 
121413
 
 
121414
 
--
121415
 
--
121416
 
 
121417
 
REVOKE ALL ON TABLE recv FROM PUBLIC;
121418
 
REVOKE ALL ON TABLE recv FROM admin;
121419
 
GRANT ALL ON TABLE recv TO admin;
121420
 
GRANT ALL ON TABLE recv TO xtrole;
121421
 
 
121422
 
 
121423
 
--
121424
 
--
121425
 
 
121426
 
REVOKE ALL ON TABLE porecv FROM PUBLIC;
121427
 
REVOKE ALL ON TABLE porecv FROM admin;
121428
 
GRANT ALL ON TABLE porecv TO admin;
121429
 
GRANT ALL ON TABLE porecv TO xtrole;
121430
 
 
121431
 
 
121432
 
--
121433
 
--
121434
 
 
121435
 
REVOKE ALL ON SEQUENCE porecv_porecv_id_seq FROM PUBLIC;
121436
 
REVOKE ALL ON SEQUENCE porecv_porecv_id_seq FROM admin;
121437
 
GRANT ALL ON SEQUENCE porecv_porecv_id_seq TO admin;
121438
 
GRANT ALL ON SEQUENCE porecv_porecv_id_seq TO xtrole;
121439
 
 
121440
 
 
121441
 
--
121442
 
--
121443
 
 
121444
 
REVOKE ALL ON TABLE poreject FROM PUBLIC;
121445
 
REVOKE ALL ON TABLE poreject FROM admin;
121446
 
GRANT ALL ON TABLE poreject TO admin;
121447
 
GRANT ALL ON TABLE poreject TO xtrole;
121448
 
 
121449
 
 
121450
 
--
121451
 
--
121452
 
 
121453
 
REVOKE ALL ON SEQUENCE poreject_poreject_id_seq FROM PUBLIC;
121454
 
REVOKE ALL ON SEQUENCE poreject_poreject_id_seq FROM admin;
121455
 
GRANT ALL ON SEQUENCE poreject_poreject_id_seq TO admin;
121456
 
GRANT ALL ON SEQUENCE poreject_poreject_id_seq TO xtrole;
121457
 
 
121458
 
 
121459
 
--
121460
 
--
121461
 
 
121462
 
REVOKE ALL ON TABLE potype FROM PUBLIC;
121463
 
REVOKE ALL ON TABLE potype FROM admin;
121464
 
GRANT ALL ON TABLE potype TO admin;
121465
 
GRANT ALL ON TABLE potype TO xtrole;
121466
 
 
121467
 
 
121468
 
--
121469
 
--
121470
 
 
121471
 
REVOKE ALL ON SEQUENCE potype_potype_id_seq FROM PUBLIC;
121472
 
REVOKE ALL ON SEQUENCE potype_potype_id_seq FROM admin;
121473
 
GRANT ALL ON SEQUENCE potype_potype_id_seq TO admin;
121474
 
GRANT ALL ON SEQUENCE potype_potype_id_seq TO xtrole;
121475
 
 
121476
 
 
121477
 
--
121478
 
--
121479
 
 
121480
 
REVOKE ALL ON TABLE pr FROM PUBLIC;
121481
 
REVOKE ALL ON TABLE pr FROM admin;
121482
 
GRANT ALL ON TABLE pr TO admin;
121483
 
GRANT ALL ON TABLE pr TO xtrole;
121484
 
 
121485
 
 
121486
 
--
121487
 
--
121488
 
 
121489
 
REVOKE ALL ON SEQUENCE pr_pr_id_seq FROM PUBLIC;
121490
 
REVOKE ALL ON SEQUENCE pr_pr_id_seq FROM admin;
121491
 
GRANT ALL ON SEQUENCE pr_pr_id_seq TO admin;
121492
 
GRANT ALL ON SEQUENCE pr_pr_id_seq TO xtrole;
121493
 
 
121494
 
 
121495
 
--
121496
 
--
121497
 
 
121498
 
REVOKE ALL ON TABLE prftcntr FROM PUBLIC;
121499
 
REVOKE ALL ON TABLE prftcntr FROM admin;
121500
 
GRANT ALL ON TABLE prftcntr TO admin;
121501
 
GRANT ALL ON TABLE prftcntr TO xtrole;
121502
 
 
121503
 
 
121504
 
--
121505
 
--
121506
 
 
121507
 
REVOKE ALL ON SEQUENCE prftcntr_prftcntr_id_seq FROM PUBLIC;
121508
 
REVOKE ALL ON SEQUENCE prftcntr_prftcntr_id_seq FROM admin;
121509
 
GRANT ALL ON SEQUENCE prftcntr_prftcntr_id_seq TO admin;
121510
 
GRANT ALL ON SEQUENCE prftcntr_prftcntr_id_seq TO xtrole;
121511
 
 
121512
 
 
121513
 
--
121514
 
--
121515
 
 
121516
 
REVOKE ALL ON TABLE usrgrp FROM PUBLIC;
121517
 
REVOKE ALL ON TABLE usrgrp FROM admin;
121518
 
GRANT ALL ON TABLE usrgrp TO admin;
121519
 
GRANT ALL ON TABLE usrgrp TO xtrole;
121520
 
 
121521
 
 
121522
 
--
121523
 
--
121524
 
 
121525
 
REVOKE ALL ON TABLE usrpriv FROM PUBLIC;
121526
 
REVOKE ALL ON TABLE usrpriv FROM admin;
121527
 
GRANT ALL ON TABLE usrpriv TO admin;
121528
 
GRANT ALL ON TABLE usrpriv TO xtrole;
121529
 
 
121530
 
 
121531
 
--
121532
 
--
121533
 
 
121534
 
REVOKE ALL ON TABLE privgranted FROM PUBLIC;
121535
 
REVOKE ALL ON TABLE privgranted FROM admin;
121536
 
GRANT ALL ON TABLE privgranted TO admin;
121537
 
GRANT ALL ON TABLE privgranted TO xtrole;
121538
 
 
121539
 
 
121540
 
--
121541
 
--
121542
 
 
121543
 
REVOKE ALL ON SEQUENCE prj_prj_id_seq FROM PUBLIC;
121544
 
REVOKE ALL ON SEQUENCE prj_prj_id_seq FROM admin;
121545
 
GRANT ALL ON SEQUENCE prj_prj_id_seq TO admin;
121546
 
GRANT ALL ON SEQUENCE prj_prj_id_seq TO xtrole;
121547
 
 
121548
 
 
121549
 
--
121550
 
--
121551
 
 
121552
 
REVOKE ALL ON SEQUENCE prjtask_prjtask_id_seq FROM PUBLIC;
121553
 
REVOKE ALL ON SEQUENCE prjtask_prjtask_id_seq FROM admin;
121554
 
GRANT ALL ON SEQUENCE prjtask_prjtask_id_seq TO admin;
121555
 
GRANT ALL ON SEQUENCE prjtask_prjtask_id_seq TO xtrole;
121556
 
 
121557
 
 
121558
 
--
121559
 
--
121560
 
 
121561
 
REVOKE ALL ON TABLE prjtaskuser FROM PUBLIC;
121562
 
REVOKE ALL ON TABLE prjtaskuser FROM admin;
121563
 
GRANT ALL ON TABLE prjtaskuser TO admin;
121564
 
GRANT ALL ON TABLE prjtaskuser TO xtrole;
121565
 
 
121566
 
 
121567
 
--
121568
 
--
121569
 
 
121570
 
REVOKE ALL ON SEQUENCE prjtaskuser_prjtaskuser_id_seq FROM PUBLIC;
121571
 
REVOKE ALL ON SEQUENCE prjtaskuser_prjtaskuser_id_seq FROM admin;
121572
 
GRANT ALL ON SEQUENCE prjtaskuser_prjtaskuser_id_seq TO admin;
121573
 
GRANT ALL ON SEQUENCE prjtaskuser_prjtaskuser_id_seq TO xtrole;
121574
 
 
121575
 
 
121576
 
--
121577
 
--
121578
 
 
121579
 
REVOKE ALL ON TABLE prjtype FROM PUBLIC;
121580
 
REVOKE ALL ON TABLE prjtype FROM admin;
121581
 
GRANT ALL ON TABLE prjtype TO admin;
121582
 
GRANT ALL ON TABLE prjtype TO xtrole;
121583
 
 
121584
 
 
121585
 
--
121586
 
--
121587
 
 
121588
 
REVOKE ALL ON SEQUENCE prjtype_prjtype_id_seq FROM PUBLIC;
121589
 
REVOKE ALL ON SEQUENCE prjtype_prjtype_id_seq FROM admin;
121590
 
GRANT ALL ON SEQUENCE prjtype_prjtype_id_seq TO admin;
121591
 
GRANT ALL ON SEQUENCE prjtype_prjtype_id_seq TO xtrole;
121592
 
 
121593
 
 
121594
 
--
121595
 
--
121596
 
 
121597
 
REVOKE ALL ON SEQUENCE prodcat_prodcat_id_seq FROM PUBLIC;
121598
 
REVOKE ALL ON SEQUENCE prodcat_prodcat_id_seq FROM admin;
121599
 
GRANT ALL ON SEQUENCE prodcat_prodcat_id_seq TO admin;
121600
 
GRANT ALL ON SEQUENCE prodcat_prodcat_id_seq TO xtrole;
121601
 
 
121602
 
 
121603
 
--
121604
 
--
121605
 
 
121606
 
REVOKE ALL ON TABLE qryhead FROM PUBLIC;
121607
 
REVOKE ALL ON TABLE qryhead FROM admin;
121608
 
GRANT ALL ON TABLE qryhead TO admin;
121609
 
GRANT ALL ON TABLE qryhead TO xtrole;
121610
 
 
121611
 
 
121612
 
--
121613
 
--
121614
 
 
121615
 
REVOKE ALL ON SEQUENCE qryhead_qryhead_id_seq FROM PUBLIC;
121616
 
REVOKE ALL ON SEQUENCE qryhead_qryhead_id_seq FROM admin;
121617
 
GRANT ALL ON SEQUENCE qryhead_qryhead_id_seq TO admin;
121618
 
GRANT ALL ON SEQUENCE qryhead_qryhead_id_seq TO xtrole;
121619
 
 
121620
 
 
121621
 
--
121622
 
--
121623
 
 
121624
 
REVOKE ALL ON TABLE qryitem FROM PUBLIC;
121625
 
REVOKE ALL ON TABLE qryitem FROM admin;
121626
 
GRANT ALL ON TABLE qryitem TO admin;
121627
 
GRANT ALL ON TABLE qryitem TO xtrole;
121628
 
 
121629
 
 
121630
 
--
121631
 
--
121632
 
 
121633
 
REVOKE ALL ON SEQUENCE qryitem_qryitem_id_seq FROM PUBLIC;
121634
 
REVOKE ALL ON SEQUENCE qryitem_qryitem_id_seq FROM admin;
121635
 
GRANT ALL ON SEQUENCE qryitem_qryitem_id_seq TO admin;
121636
 
GRANT ALL ON SEQUENCE qryitem_qryitem_id_seq TO xtrole;
121637
 
 
121638
 
 
121639
 
--
121640
 
--
121641
 
 
121642
 
REVOKE ALL ON SEQUENCE quhead_quhead_id_seq FROM PUBLIC;
121643
 
REVOKE ALL ON SEQUENCE quhead_quhead_id_seq FROM admin;
121644
 
GRANT ALL ON SEQUENCE quhead_quhead_id_seq TO admin;
121645
 
GRANT ALL ON SEQUENCE quhead_quhead_id_seq TO xtrole;
121646
 
 
121647
 
 
121648
 
--
121649
 
--
121650
 
 
121651
 
REVOKE ALL ON SEQUENCE quitem_quitem_id_seq FROM PUBLIC;
121652
 
REVOKE ALL ON SEQUENCE quitem_quitem_id_seq FROM admin;
121653
 
GRANT ALL ON SEQUENCE quitem_quitem_id_seq TO admin;
121654
 
GRANT ALL ON SEQUENCE quitem_quitem_id_seq TO xtrole;
121655
 
 
121656
 
 
121657
 
--
121658
 
--
121659
 
 
121660
 
REVOKE ALL ON TABLE rcalitem FROM PUBLIC;
121661
 
REVOKE ALL ON TABLE rcalitem FROM admin;
121662
 
GRANT ALL ON TABLE rcalitem TO admin;
121663
 
GRANT ALL ON TABLE rcalitem TO xtrole;
121664
 
 
121665
 
 
121666
 
--
121667
 
--
121668
 
 
121669
 
REVOKE ALL ON TABLE recur FROM PUBLIC;
121670
 
REVOKE ALL ON TABLE recur FROM admin;
121671
 
GRANT ALL ON TABLE recur TO admin;
121672
 
GRANT ALL ON TABLE recur TO xtrole;
121673
 
 
121674
 
 
121675
 
--
121676
 
--
121677
 
 
121678
 
REVOKE ALL ON SEQUENCE recur_recur_id_seq FROM PUBLIC;
121679
 
REVOKE ALL ON SEQUENCE recur_recur_id_seq FROM admin;
121680
 
GRANT ALL ON SEQUENCE recur_recur_id_seq TO admin;
121681
 
GRANT ALL ON SEQUENCE recur_recur_id_seq TO xtrole;
121682
 
 
121683
 
 
121684
 
--
121685
 
--
121686
 
 
121687
 
REVOKE ALL ON TABLE recurtype FROM PUBLIC;
121688
 
REVOKE ALL ON TABLE recurtype FROM admin;
121689
 
GRANT ALL ON TABLE recurtype TO admin;
121690
 
GRANT ALL ON TABLE recurtype TO xtrole;
121691
 
 
121692
 
 
121693
 
--
121694
 
--
121695
 
 
121696
 
REVOKE ALL ON SEQUENCE recurtype_recurtype_id_seq FROM PUBLIC;
121697
 
REVOKE ALL ON SEQUENCE recurtype_recurtype_id_seq FROM admin;
121698
 
GRANT ALL ON SEQUENCE recurtype_recurtype_id_seq TO admin;
121699
 
GRANT ALL ON SEQUENCE recurtype_recurtype_id_seq TO xtrole;
121700
 
 
121701
 
 
121702
 
--
121703
 
--
121704
 
 
121705
 
REVOKE ALL ON SEQUENCE recv_recv_id_seq FROM PUBLIC;
121706
 
REVOKE ALL ON SEQUENCE recv_recv_id_seq FROM admin;
121707
 
GRANT ALL ON SEQUENCE recv_recv_id_seq TO admin;
121708
 
GRANT ALL ON SEQUENCE recv_recv_id_seq TO xtrole;
121709
 
 
121710
 
 
121711
 
--
121712
 
--
121713
 
 
121714
 
REVOKE ALL ON TABLE remitto FROM PUBLIC;
121715
 
REVOKE ALL ON TABLE remitto FROM admin;
121716
 
GRANT ALL ON TABLE remitto TO admin;
121717
 
GRANT ALL ON TABLE remitto TO xtrole;
121718
 
 
121719
 
 
121720
 
--
121721
 
--
121722
 
 
121723
 
REVOKE ALL ON TABLE rjctcode FROM PUBLIC;
121724
 
REVOKE ALL ON TABLE rjctcode FROM admin;
121725
 
GRANT ALL ON TABLE rjctcode TO admin;
121726
 
GRANT ALL ON TABLE rjctcode TO xtrole;
121727
 
 
121728
 
 
121729
 
--
121730
 
--
121731
 
 
121732
 
REVOKE ALL ON SEQUENCE rjctcode_rjctcode_id_seq FROM PUBLIC;
121733
 
REVOKE ALL ON SEQUENCE rjctcode_rjctcode_id_seq FROM admin;
121734
 
GRANT ALL ON SEQUENCE rjctcode_rjctcode_id_seq TO admin;
121735
 
GRANT ALL ON SEQUENCE rjctcode_rjctcode_id_seq TO xtrole;
121736
 
 
121737
 
 
121738
 
--
121739
 
--
121740
 
 
121741
 
REVOKE ALL ON SEQUENCE rsncode_rsncode_id_seq FROM PUBLIC;
121742
 
REVOKE ALL ON SEQUENCE rsncode_rsncode_id_seq FROM admin;
121743
 
GRANT ALL ON SEQUENCE rsncode_rsncode_id_seq TO admin;
121744
 
GRANT ALL ON SEQUENCE rsncode_rsncode_id_seq TO xtrole;
121745
 
 
121746
 
 
121747
 
--
121748
 
--
121749
 
 
121750
 
REVOKE ALL ON TABLE sale FROM PUBLIC;
121751
 
REVOKE ALL ON TABLE sale FROM admin;
121752
 
GRANT ALL ON TABLE sale TO admin;
121753
 
GRANT ALL ON TABLE sale TO xtrole;
121754
 
 
121755
 
 
121756
 
--
121757
 
--
121758
 
 
121759
 
REVOKE ALL ON SEQUENCE sale_sale_id_seq FROM PUBLIC;
121760
 
REVOKE ALL ON SEQUENCE sale_sale_id_seq FROM admin;
121761
 
GRANT ALL ON SEQUENCE sale_sale_id_seq TO admin;
121762
 
GRANT ALL ON SEQUENCE sale_sale_id_seq TO xtrole;
121763
 
 
121764
 
 
121765
 
--
121766
 
--
121767
 
 
121768
 
REVOKE ALL ON SEQUENCE salesaccnt_salesaccnt_id_seq FROM PUBLIC;
121769
 
REVOKE ALL ON SEQUENCE salesaccnt_salesaccnt_id_seq FROM admin;
121770
 
GRANT ALL ON SEQUENCE salesaccnt_salesaccnt_id_seq TO admin;
121771
 
GRANT ALL ON SEQUENCE salesaccnt_salesaccnt_id_seq TO xtrole;
121772
 
 
121773
 
 
121774
 
--
121775
 
--
121776
 
 
121777
 
REVOKE ALL ON SEQUENCE salescat_salescat_id_seq FROM PUBLIC;
121778
 
REVOKE ALL ON SEQUENCE salescat_salescat_id_seq FROM admin;
121779
 
GRANT ALL ON SEQUENCE salescat_salescat_id_seq TO admin;
121780
 
GRANT ALL ON SEQUENCE salescat_salescat_id_seq TO xtrole;
121781
 
 
121782
 
 
121783
 
--
121784
 
--
121785
 
 
121786
 
REVOKE ALL ON TABLE saleshistory FROM PUBLIC;
121787
 
REVOKE ALL ON TABLE saleshistory FROM admin;
121788
 
GRANT ALL ON TABLE saleshistory TO admin;
121789
 
GRANT ALL ON TABLE saleshistory TO xtrole;
121790
 
 
121791
 
 
121792
 
--
121793
 
--
121794
 
 
121795
 
REVOKE ALL ON TABLE saleshistorymisc FROM PUBLIC;
121796
 
REVOKE ALL ON TABLE saleshistorymisc FROM admin;
121797
 
GRANT ALL ON TABLE saleshistorymisc TO admin;
121798
 
GRANT ALL ON TABLE saleshistorymisc TO xtrole;
121799
 
 
121800
 
 
121801
 
--
121802
 
--
121803
 
 
121804
 
REVOKE ALL ON SEQUENCE salesrep_salesrep_id_seq FROM PUBLIC;
121805
 
REVOKE ALL ON SEQUENCE salesrep_salesrep_id_seq FROM admin;
121806
 
GRANT ALL ON SEQUENCE salesrep_salesrep_id_seq TO admin;
121807
 
GRANT ALL ON SEQUENCE salesrep_salesrep_id_seq TO xtrole;
121808
 
 
121809
 
 
121810
 
--
121811
 
--
121812
 
 
121813
 
REVOKE ALL ON SEQUENCE saletype_saletype_id_seq FROM PUBLIC;
121814
 
REVOKE ALL ON SEQUENCE saletype_saletype_id_seq FROM admin;
121815
 
GRANT ALL ON SEQUENCE saletype_saletype_id_seq TO admin;
121816
 
GRANT ALL ON SEQUENCE saletype_saletype_id_seq TO xtrole;
121817
 
 
121818
 
 
121819
 
--
121820
 
--
121821
 
 
121822
 
REVOKE ALL ON TABLE schemaord FROM PUBLIC;
121823
 
REVOKE ALL ON TABLE schemaord FROM admin;
121824
 
GRANT ALL ON TABLE schemaord TO admin;
121825
 
GRANT ALL ON TABLE schemaord TO xtrole;
121826
 
 
121827
 
 
121828
 
--
121829
 
--
121830
 
 
121831
 
REVOKE ALL ON SEQUENCE schemaord_schemaord_id_seq FROM PUBLIC;
121832
 
REVOKE ALL ON SEQUENCE schemaord_schemaord_id_seq FROM admin;
121833
 
GRANT ALL ON SEQUENCE schemaord_schemaord_id_seq TO admin;
121834
 
GRANT ALL ON SEQUENCE schemaord_schemaord_id_seq TO xtrole;
121835
 
 
121836
 
 
121837
 
--
121838
 
--
121839
 
 
121840
 
REVOKE ALL ON TABLE sequence FROM PUBLIC;
121841
 
REVOKE ALL ON TABLE sequence FROM admin;
121842
 
GRANT ALL ON TABLE sequence TO admin;
121843
 
GRANT ALL ON TABLE sequence TO xtrole;
121844
 
 
121845
 
 
121846
 
--
121847
 
--
121848
 
 
121849
 
REVOKE ALL ON SEQUENCE shift_shift_id_seq FROM PUBLIC;
121850
 
REVOKE ALL ON SEQUENCE shift_shift_id_seq FROM admin;
121851
 
GRANT ALL ON SEQUENCE shift_shift_id_seq TO admin;
121852
 
GRANT ALL ON SEQUENCE shift_shift_id_seq TO xtrole;
121853
 
 
121854
 
 
121855
 
--
121856
 
--
121857
 
 
121858
 
REVOKE ALL ON SEQUENCE shipchrg_shipchrg_id_seq FROM PUBLIC;
121859
 
REVOKE ALL ON SEQUENCE shipchrg_shipchrg_id_seq FROM admin;
121860
 
GRANT ALL ON SEQUENCE shipchrg_shipchrg_id_seq TO admin;
121861
 
GRANT ALL ON SEQUENCE shipchrg_shipchrg_id_seq TO xtrole;
121862
 
 
121863
 
 
121864
 
--
121865
 
--
121866
 
 
121867
 
REVOKE ALL ON TABLE shipdatasum FROM PUBLIC;
121868
 
REVOKE ALL ON TABLE shipdatasum FROM admin;
121869
 
GRANT ALL ON TABLE shipdatasum TO admin;
121870
 
GRANT ALL ON TABLE shipdatasum TO xtrole;
121871
 
 
121872
 
 
121873
 
--
121874
 
--
121875
 
 
121876
 
REVOKE ALL ON SEQUENCE shipform_shipform_id_seq FROM PUBLIC;
121877
 
REVOKE ALL ON SEQUENCE shipform_shipform_id_seq FROM admin;
121878
 
GRANT ALL ON SEQUENCE shipform_shipform_id_seq TO admin;
121879
 
GRANT ALL ON SEQUENCE shipform_shipform_id_seq TO xtrole;
121880
 
 
121881
 
 
121882
 
--
121883
 
--
121884
 
 
121885
 
REVOKE ALL ON SEQUENCE shiphead_shiphead_id_seq FROM PUBLIC;
121886
 
REVOKE ALL ON SEQUENCE shiphead_shiphead_id_seq FROM admin;
121887
 
GRANT ALL ON SEQUENCE shiphead_shiphead_id_seq TO admin;
121888
 
GRANT ALL ON SEQUENCE shiphead_shiphead_id_seq TO xtrole;
121889
 
 
121890
 
 
121891
 
--
121892
 
--
121893
 
 
121894
 
REVOKE ALL ON SEQUENCE shipitem_shipitem_id_seq FROM PUBLIC;
121895
 
REVOKE ALL ON SEQUENCE shipitem_shipitem_id_seq FROM admin;
121896
 
GRANT ALL ON SEQUENCE shipitem_shipitem_id_seq TO admin;
121897
 
GRANT ALL ON SEQUENCE shipitem_shipitem_id_seq TO xtrole;
121898
 
 
121899
 
 
121900
 
--
121901
 
--
121902
 
 
121903
 
REVOKE ALL ON SEQUENCE shipment_number_seq FROM PUBLIC;
121904
 
REVOKE ALL ON SEQUENCE shipment_number_seq FROM admin;
121905
 
GRANT ALL ON SEQUENCE shipment_number_seq TO admin;
121906
 
GRANT ALL ON SEQUENCE shipment_number_seq TO xtrole;
121907
 
 
121908
 
 
121909
 
--
121910
 
--
121911
 
 
121912
 
REVOKE ALL ON TABLE shipto FROM PUBLIC;
121913
 
REVOKE ALL ON TABLE shipto FROM admin;
121914
 
GRANT ALL ON TABLE shipto TO admin;
121915
 
GRANT ALL ON TABLE shipto TO xtrole;
121916
 
 
121917
 
 
121918
 
--
121919
 
--
121920
 
 
121921
 
REVOKE ALL ON SEQUENCE shipto_shipto_id_seq FROM PUBLIC;
121922
 
REVOKE ALL ON SEQUENCE shipto_shipto_id_seq FROM admin;
121923
 
GRANT ALL ON SEQUENCE shipto_shipto_id_seq TO admin;
121924
 
GRANT ALL ON SEQUENCE shipto_shipto_id_seq TO xtrole;
121925
 
 
121926
 
 
121927
 
--
121928
 
--
121929
 
 
121930
 
REVOKE ALL ON SEQUENCE shipvia_shipvia_id_seq FROM PUBLIC;
121931
 
REVOKE ALL ON SEQUENCE shipvia_shipvia_id_seq FROM admin;
121932
 
GRANT ALL ON SEQUENCE shipvia_shipvia_id_seq TO admin;
121933
 
GRANT ALL ON SEQUENCE shipvia_shipvia_id_seq TO xtrole;
121934
 
 
121935
 
 
121936
 
--
121937
 
--
121938
 
 
121939
 
REVOKE ALL ON SEQUENCE shipzone_shipzone_id_seq FROM PUBLIC;
121940
 
REVOKE ALL ON SEQUENCE shipzone_shipzone_id_seq FROM admin;
121941
 
GRANT ALL ON SEQUENCE shipzone_shipzone_id_seq TO admin;
121942
 
GRANT ALL ON SEQUENCE shipzone_shipzone_id_seq TO xtrole;
121943
 
 
121944
 
 
121945
 
--
121946
 
--
121947
 
 
121948
 
REVOKE ALL ON SEQUENCE sitetype_sitetype_id_seq FROM PUBLIC;
121949
 
REVOKE ALL ON SEQUENCE sitetype_sitetype_id_seq FROM admin;
121950
 
GRANT ALL ON SEQUENCE sitetype_sitetype_id_seq TO admin;
121951
 
GRANT ALL ON SEQUENCE sitetype_sitetype_id_seq TO xtrole;
121952
 
 
121953
 
 
121954
 
--
121955
 
--
121956
 
 
121957
 
REVOKE ALL ON TABLE sltrans FROM PUBLIC;
121958
 
REVOKE ALL ON TABLE sltrans FROM admin;
121959
 
GRANT ALL ON TABLE sltrans TO admin;
121960
 
GRANT ALL ON TABLE sltrans TO xtrole;
121961
 
 
121962
 
 
121963
 
--
121964
 
--
121965
 
 
121966
 
REVOKE ALL ON TABLE sltrans_backup FROM PUBLIC;
121967
 
REVOKE ALL ON TABLE sltrans_backup FROM admin;
121968
 
GRANT ALL ON TABLE sltrans_backup TO admin;
121969
 
GRANT ALL ON TABLE sltrans_backup TO xtrole;
121970
 
 
121971
 
 
121972
 
--
121973
 
--
121974
 
 
121975
 
REVOKE ALL ON TABLE sopack FROM PUBLIC;
121976
 
REVOKE ALL ON TABLE sopack FROM admin;
121977
 
GRANT ALL ON TABLE sopack TO admin;
121978
 
GRANT ALL ON TABLE sopack TO xtrole;
121979
 
 
121980
 
 
121981
 
--
121982
 
--
121983
 
 
121984
 
REVOKE ALL ON SEQUENCE sopack_sopack_id_seq FROM PUBLIC;
121985
 
REVOKE ALL ON SEQUENCE sopack_sopack_id_seq FROM admin;
121986
 
GRANT ALL ON SEQUENCE sopack_sopack_id_seq TO admin;
121987
 
GRANT ALL ON SEQUENCE sopack_sopack_id_seq TO xtrole;
121988
 
 
121989
 
 
121990
 
--
121991
 
--
121992
 
 
121993
 
REVOKE ALL ON TABLE source FROM PUBLIC;
121994
 
REVOKE ALL ON TABLE source FROM admin;
121995
 
GRANT ALL ON TABLE source TO admin;
121996
 
GRANT ALL ON TABLE source TO xtrole;
121997
 
 
121998
 
 
121999
 
--
122000
 
--
122001
 
 
122002
 
REVOKE ALL ON SEQUENCE source_source_id_seq FROM PUBLIC;
122003
 
REVOKE ALL ON SEQUENCE source_source_id_seq FROM admin;
122004
 
GRANT ALL ON SEQUENCE source_source_id_seq TO admin;
122005
 
GRANT ALL ON SEQUENCE source_source_id_seq TO xtrole;
122006
 
 
122007
 
 
122008
 
--
122009
 
--
122010
 
 
122011
 
REVOKE ALL ON TABLE state FROM PUBLIC;
122012
 
REVOKE ALL ON TABLE state FROM admin;
122013
 
GRANT ALL ON TABLE state TO admin;
122014
 
GRANT ALL ON TABLE state TO xtrole;
122015
 
 
122016
 
 
122017
 
--
122018
 
--
122019
 
 
122020
 
REVOKE ALL ON SEQUENCE state_state_id_seq FROM PUBLIC;
122021
 
REVOKE ALL ON SEQUENCE state_state_id_seq FROM admin;
122022
 
GRANT ALL ON SEQUENCE state_state_id_seq TO admin;
122023
 
GRANT ALL ON SEQUENCE state_state_id_seq TO xtrole;
122024
 
 
122025
 
 
122026
 
--
122027
 
--
122028
 
 
122029
 
REVOKE ALL ON TABLE status FROM PUBLIC;
122030
 
REVOKE ALL ON TABLE status FROM admin;
122031
 
GRANT ALL ON TABLE status TO admin;
122032
 
GRANT ALL ON TABLE status TO xtrole;
122033
 
 
122034
 
 
122035
 
--
122036
 
--
122037
 
 
122038
 
REVOKE ALL ON SEQUENCE status_status_id_seq FROM PUBLIC;
122039
 
REVOKE ALL ON SEQUENCE status_status_id_seq FROM admin;
122040
 
GRANT ALL ON SEQUENCE status_status_id_seq TO admin;
122041
 
GRANT ALL ON SEQUENCE status_status_id_seq TO xtrole;
122042
 
 
122043
 
 
122044
 
--
122045
 
--
122046
 
 
122047
 
REVOKE ALL ON TABLE stdjrnl FROM PUBLIC;
122048
 
REVOKE ALL ON TABLE stdjrnl FROM admin;
122049
 
GRANT ALL ON TABLE stdjrnl TO admin;
122050
 
GRANT ALL ON TABLE stdjrnl TO xtrole;
122051
 
 
122052
 
 
122053
 
--
122054
 
--
122055
 
 
122056
 
REVOKE ALL ON SEQUENCE stdjrnl_stdjrnl_id_seq FROM PUBLIC;
122057
 
REVOKE ALL ON SEQUENCE stdjrnl_stdjrnl_id_seq FROM admin;
122058
 
GRANT ALL ON SEQUENCE stdjrnl_stdjrnl_id_seq TO admin;
122059
 
GRANT ALL ON SEQUENCE stdjrnl_stdjrnl_id_seq TO xtrole;
122060
 
 
122061
 
 
122062
 
--
122063
 
--
122064
 
 
122065
 
REVOKE ALL ON TABLE stdjrnlgrp FROM PUBLIC;
122066
 
REVOKE ALL ON TABLE stdjrnlgrp FROM admin;
122067
 
GRANT ALL ON TABLE stdjrnlgrp TO admin;
122068
 
GRANT ALL ON TABLE stdjrnlgrp TO xtrole;
122069
 
 
122070
 
 
122071
 
--
122072
 
--
122073
 
 
122074
 
REVOKE ALL ON SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq FROM PUBLIC;
122075
 
REVOKE ALL ON SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq FROM admin;
122076
 
GRANT ALL ON SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq TO admin;
122077
 
GRANT ALL ON SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq TO xtrole;
122078
 
 
122079
 
 
122080
 
--
122081
 
--
122082
 
 
122083
 
REVOKE ALL ON TABLE stdjrnlgrpitem FROM PUBLIC;
122084
 
REVOKE ALL ON TABLE stdjrnlgrpitem FROM admin;
122085
 
GRANT ALL ON TABLE stdjrnlgrpitem TO admin;
122086
 
GRANT ALL ON TABLE stdjrnlgrpitem TO xtrole;
122087
 
 
122088
 
 
122089
 
--
122090
 
--
122091
 
 
122092
 
REVOKE ALL ON SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq FROM PUBLIC;
122093
 
REVOKE ALL ON SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq FROM admin;
122094
 
GRANT ALL ON SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq TO admin;
122095
 
GRANT ALL ON SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq TO xtrole;
122096
 
 
122097
 
 
122098
 
--
122099
 
--
122100
 
 
122101
 
REVOKE ALL ON TABLE stdjrnlitem FROM PUBLIC;
122102
 
REVOKE ALL ON TABLE stdjrnlitem FROM admin;
122103
 
GRANT ALL ON TABLE stdjrnlitem TO admin;
122104
 
GRANT ALL ON TABLE stdjrnlitem TO xtrole;
122105
 
 
122106
 
 
122107
 
--
122108
 
--
122109
 
 
122110
 
REVOKE ALL ON SEQUENCE stdjrnlitem_stdjrnlitem_id_seq FROM PUBLIC;
122111
 
REVOKE ALL ON SEQUENCE stdjrnlitem_stdjrnlitem_id_seq FROM admin;
122112
 
GRANT ALL ON SEQUENCE stdjrnlitem_stdjrnlitem_id_seq TO admin;
122113
 
GRANT ALL ON SEQUENCE stdjrnlitem_stdjrnlitem_id_seq TO xtrole;
122114
 
 
122115
 
 
122116
 
--
122117
 
--
122118
 
 
122119
 
REVOKE ALL ON TABLE subaccnt FROM PUBLIC;
122120
 
REVOKE ALL ON TABLE subaccnt FROM admin;
122121
 
GRANT ALL ON TABLE subaccnt TO admin;
122122
 
GRANT ALL ON TABLE subaccnt TO xtrole;
122123
 
 
122124
 
 
122125
 
--
122126
 
--
122127
 
 
122128
 
REVOKE ALL ON SEQUENCE subaccnt_subaccnt_id_seq FROM PUBLIC;
122129
 
REVOKE ALL ON SEQUENCE subaccnt_subaccnt_id_seq FROM admin;
122130
 
GRANT ALL ON SEQUENCE subaccnt_subaccnt_id_seq TO admin;
122131
 
GRANT ALL ON SEQUENCE subaccnt_subaccnt_id_seq TO xtrole;
122132
 
 
122133
 
 
122134
 
--
122135
 
--
122136
 
 
122137
 
REVOKE ALL ON TABLE subaccnttype FROM PUBLIC;
122138
 
REVOKE ALL ON TABLE subaccnttype FROM admin;
122139
 
GRANT ALL ON TABLE subaccnttype TO admin;
122140
 
GRANT ALL ON TABLE subaccnttype TO xtrole;
122141
 
 
122142
 
 
122143
 
--
122144
 
--
122145
 
 
122146
 
REVOKE ALL ON SEQUENCE subaccnttype_subaccnttype_id_seq FROM PUBLIC;
122147
 
REVOKE ALL ON SEQUENCE subaccnttype_subaccnttype_id_seq FROM admin;
122148
 
GRANT ALL ON SEQUENCE subaccnttype_subaccnttype_id_seq TO admin;
122149
 
GRANT ALL ON SEQUENCE subaccnttype_subaccnttype_id_seq TO xtrole;
122150
 
 
122151
 
 
122152
 
--
122153
 
--
122154
 
 
122155
 
REVOKE ALL ON SEQUENCE tax_tax_id_seq FROM PUBLIC;
122156
 
REVOKE ALL ON SEQUENCE tax_tax_id_seq FROM admin;
122157
 
GRANT ALL ON SEQUENCE tax_tax_id_seq TO admin;
122158
 
GRANT ALL ON SEQUENCE tax_tax_id_seq TO xtrole;
122159
 
 
122160
 
 
122161
 
--
122162
 
--
122163
 
 
122164
 
REVOKE ALL ON TABLE taxass FROM PUBLIC;
122165
 
REVOKE ALL ON TABLE taxass FROM admin;
122166
 
GRANT ALL ON TABLE taxass TO admin;
122167
 
GRANT ALL ON TABLE taxass TO xtrole;
122168
 
 
122169
 
 
122170
 
--
122171
 
--
122172
 
 
122173
 
REVOKE ALL ON SEQUENCE taxass_taxass_id_seq FROM PUBLIC;
122174
 
REVOKE ALL ON SEQUENCE taxass_taxass_id_seq FROM admin;
122175
 
GRANT ALL ON SEQUENCE taxass_taxass_id_seq TO admin;
122176
 
GRANT ALL ON SEQUENCE taxass_taxass_id_seq TO xtrole;
122177
 
 
122178
 
 
122179
 
--
122180
 
--
122181
 
 
122182
 
REVOKE ALL ON SEQUENCE taxauth_taxauth_id_seq FROM PUBLIC;
122183
 
REVOKE ALL ON SEQUENCE taxauth_taxauth_id_seq FROM admin;
122184
 
GRANT ALL ON SEQUENCE taxauth_taxauth_id_seq TO admin;
122185
 
GRANT ALL ON SEQUENCE taxauth_taxauth_id_seq TO xtrole;
122186
 
 
122187
 
 
122188
 
--
122189
 
--
122190
 
 
122191
 
REVOKE ALL ON TABLE taxclass FROM PUBLIC;
122192
 
REVOKE ALL ON TABLE taxclass FROM admin;
122193
 
GRANT ALL ON TABLE taxclass TO admin;
122194
 
GRANT ALL ON TABLE taxclass TO xtrole;
122195
 
 
122196
 
 
122197
 
--
122198
 
--
122199
 
 
122200
 
REVOKE ALL ON SEQUENCE taxclass_taxclass_id_seq FROM PUBLIC;
122201
 
REVOKE ALL ON SEQUENCE taxclass_taxclass_id_seq FROM admin;
122202
 
GRANT ALL ON SEQUENCE taxclass_taxclass_id_seq TO admin;
122203
 
GRANT ALL ON SEQUENCE taxclass_taxclass_id_seq TO xtrole;
122204
 
 
122205
 
 
122206
 
--
122207
 
--
122208
 
 
122209
 
REVOKE ALL ON SEQUENCE taxhist_taxhist_id_seq FROM PUBLIC;
122210
 
REVOKE ALL ON SEQUENCE taxhist_taxhist_id_seq FROM admin;
122211
 
GRANT ALL ON SEQUENCE taxhist_taxhist_id_seq TO admin;
122212
 
GRANT ALL ON SEQUENCE taxhist_taxhist_id_seq TO xtrole;
122213
 
 
122214
 
 
122215
 
--
122216
 
--
122217
 
 
122218
 
REVOKE ALL ON TABLE taxpay FROM PUBLIC;
122219
 
REVOKE ALL ON TABLE taxpay FROM admin;
122220
 
GRANT ALL ON TABLE taxpay TO admin;
122221
 
GRANT ALL ON TABLE taxpay TO xtrole;
122222
 
 
122223
 
 
122224
 
--
122225
 
--
122226
 
 
122227
 
REVOKE ALL ON SEQUENCE taxpay_taxpay_id_seq FROM PUBLIC;
122228
 
REVOKE ALL ON SEQUENCE taxpay_taxpay_id_seq FROM admin;
122229
 
GRANT ALL ON SEQUENCE taxpay_taxpay_id_seq TO admin;
122230
 
GRANT ALL ON SEQUENCE taxpay_taxpay_id_seq TO xtrole;
122231
 
 
122232
 
 
122233
 
--
122234
 
--
122235
 
 
122236
 
REVOKE ALL ON TABLE taxrate FROM PUBLIC;
122237
 
REVOKE ALL ON TABLE taxrate FROM admin;
122238
 
GRANT ALL ON TABLE taxrate TO admin;
122239
 
GRANT ALL ON TABLE taxrate TO xtrole;
122240
 
 
122241
 
 
122242
 
--
122243
 
--
122244
 
 
122245
 
REVOKE ALL ON SEQUENCE taxrate_taxrate_id_seq FROM PUBLIC;
122246
 
REVOKE ALL ON SEQUENCE taxrate_taxrate_id_seq FROM admin;
122247
 
GRANT ALL ON SEQUENCE taxrate_taxrate_id_seq TO admin;
122248
 
GRANT ALL ON SEQUENCE taxrate_taxrate_id_seq TO xtrole;
122249
 
 
122250
 
 
122251
 
--
122252
 
--
122253
 
 
122254
 
REVOKE ALL ON SEQUENCE taxreg_taxreg_id_seq FROM PUBLIC;
122255
 
REVOKE ALL ON SEQUENCE taxreg_taxreg_id_seq FROM admin;
122256
 
GRANT ALL ON SEQUENCE taxreg_taxreg_id_seq TO admin;
122257
 
GRANT ALL ON SEQUENCE taxreg_taxreg_id_seq TO xtrole;
122258
 
 
122259
 
 
122260
 
--
122261
 
--
122262
 
 
122263
 
REVOKE ALL ON SEQUENCE taxtype_taxtype_id_seq FROM PUBLIC;
122264
 
REVOKE ALL ON SEQUENCE taxtype_taxtype_id_seq FROM admin;
122265
 
GRANT ALL ON SEQUENCE taxtype_taxtype_id_seq TO admin;
122266
 
GRANT ALL ON SEQUENCE taxtype_taxtype_id_seq TO xtrole;
122267
 
 
122268
 
 
122269
 
--
122270
 
--
122271
 
 
122272
 
REVOKE ALL ON SEQUENCE taxzone_taxzone_id_seq FROM PUBLIC;
122273
 
REVOKE ALL ON SEQUENCE taxzone_taxzone_id_seq FROM admin;
122274
 
GRANT ALL ON SEQUENCE taxzone_taxzone_id_seq TO admin;
122275
 
GRANT ALL ON SEQUENCE taxzone_taxzone_id_seq TO xtrole;
122276
 
 
122277
 
 
122278
 
--
122279
 
--
122280
 
 
122281
 
REVOKE ALL ON SEQUENCE terms_terms_id_seq FROM PUBLIC;
122282
 
REVOKE ALL ON SEQUENCE terms_terms_id_seq FROM admin;
122283
 
GRANT ALL ON SEQUENCE terms_terms_id_seq TO admin;
122284
 
GRANT ALL ON SEQUENCE terms_terms_id_seq TO xtrole;
122285
 
 
122286
 
 
122287
 
--
122288
 
--
122289
 
 
122290
 
REVOKE ALL ON SEQUENCE todoitem_todoitem_id_seq FROM PUBLIC;
122291
 
REVOKE ALL ON SEQUENCE todoitem_todoitem_id_seq FROM admin;
122292
 
GRANT ALL ON SEQUENCE todoitem_todoitem_id_seq TO admin;
122293
 
GRANT ALL ON SEQUENCE todoitem_todoitem_id_seq TO xtrole;
122294
 
 
122295
 
 
122296
 
--
122297
 
--
122298
 
 
122299
 
REVOKE ALL ON TABLE trgthist FROM PUBLIC;
122300
 
REVOKE ALL ON TABLE trgthist FROM admin;
122301
 
GRANT ALL ON TABLE trgthist TO admin;
122302
 
GRANT ALL ON TABLE trgthist TO xtrole;
122303
 
 
122304
 
 
122305
 
--
122306
 
--
122307
 
 
122308
 
REVOKE ALL ON TABLE trialbal FROM PUBLIC;
122309
 
REVOKE ALL ON TABLE trialbal FROM admin;
122310
 
GRANT ALL ON TABLE trialbal TO admin;
122311
 
GRANT ALL ON TABLE trialbal TO xtrole;
122312
 
 
122313
 
 
122314
 
--
122315
 
--
122316
 
 
122317
 
REVOKE ALL ON SEQUENCE trialbal_trialbal_id_seq FROM PUBLIC;
122318
 
REVOKE ALL ON SEQUENCE trialbal_trialbal_id_seq FROM admin;
122319
 
GRANT ALL ON SEQUENCE trialbal_trialbal_id_seq TO admin;
122320
 
GRANT ALL ON SEQUENCE trialbal_trialbal_id_seq TO xtrole;
122321
 
 
122322
 
 
122323
 
--
122324
 
--
122325
 
 
122326
 
REVOKE ALL ON SEQUENCE uom_uom_id_seq FROM PUBLIC;
122327
 
REVOKE ALL ON SEQUENCE uom_uom_id_seq FROM admin;
122328
 
GRANT ALL ON SEQUENCE uom_uom_id_seq TO admin;
122329
 
GRANT ALL ON SEQUENCE uom_uom_id_seq TO xtrole;
122330
 
 
122331
 
 
122332
 
--
122333
 
--
122334
 
 
122335
 
REVOKE ALL ON TABLE uomconv FROM PUBLIC;
122336
 
REVOKE ALL ON TABLE uomconv FROM admin;
122337
 
GRANT ALL ON TABLE uomconv TO admin;
122338
 
GRANT ALL ON TABLE uomconv TO xtrole;
122339
 
 
122340
 
 
122341
 
--
122342
 
--
122343
 
 
122344
 
REVOKE ALL ON SEQUENCE uomconv_uomconv_id_seq FROM PUBLIC;
122345
 
REVOKE ALL ON SEQUENCE uomconv_uomconv_id_seq FROM admin;
122346
 
GRANT ALL ON SEQUENCE uomconv_uomconv_id_seq TO admin;
122347
 
GRANT ALL ON SEQUENCE uomconv_uomconv_id_seq TO xtrole;
122348
 
 
122349
 
 
122350
 
--
122351
 
--
122352
 
 
122353
 
REVOKE ALL ON TABLE uomtype FROM PUBLIC;
122354
 
REVOKE ALL ON TABLE uomtype FROM admin;
122355
 
GRANT ALL ON TABLE uomtype TO admin;
122356
 
GRANT ALL ON TABLE uomtype TO xtrole;
122357
 
 
122358
 
 
122359
 
--
122360
 
--
122361
 
 
122362
 
REVOKE ALL ON SEQUENCE uomtype_uomtype_id_seq FROM PUBLIC;
122363
 
REVOKE ALL ON SEQUENCE uomtype_uomtype_id_seq FROM admin;
122364
 
GRANT ALL ON SEQUENCE uomtype_uomtype_id_seq TO admin;
122365
 
GRANT ALL ON SEQUENCE uomtype_uomtype_id_seq TO xtrole;
122366
 
 
122367
 
 
122368
 
--
122369
 
--
122370
 
 
122371
 
REVOKE ALL ON SEQUENCE urlinfo_url_id_seq FROM PUBLIC;
122372
 
REVOKE ALL ON SEQUENCE urlinfo_url_id_seq FROM admin;
122373
 
GRANT ALL ON SEQUENCE urlinfo_url_id_seq TO admin;
122374
 
GRANT ALL ON SEQUENCE urlinfo_url_id_seq TO xtrole;
122375
 
 
122376
 
 
122377
 
--
122378
 
--
122379
 
 
122380
 
REVOKE ALL ON TABLE usrpref FROM PUBLIC;
122381
 
REVOKE ALL ON TABLE usrpref FROM admin;
122382
 
GRANT ALL ON TABLE usrpref TO admin;
122383
 
GRANT ALL ON TABLE usrpref TO xtrole;
122384
 
 
122385
 
 
122386
 
--
122387
 
--
122388
 
 
122389
 
REVOKE ALL ON TABLE usr FROM PUBLIC;
122390
 
REVOKE ALL ON TABLE usr FROM admin;
122391
 
GRANT ALL ON TABLE usr TO admin;
122392
 
GRANT ALL ON TABLE usr TO xtrole;
122393
 
 
122394
 
 
122395
 
--
122396
 
--
122397
 
 
122398
 
REVOKE ALL ON TABLE usr_bak FROM PUBLIC;
122399
 
REVOKE ALL ON TABLE usr_bak FROM admin;
122400
 
GRANT ALL ON TABLE usr_bak TO admin;
122401
 
GRANT ALL ON TABLE usr_bak TO xtrole;
122402
 
 
122403
 
 
122404
 
--
122405
 
--
122406
 
 
122407
 
REVOKE ALL ON SEQUENCE usr_usr_id_seq FROM PUBLIC;
122408
 
REVOKE ALL ON SEQUENCE usr_usr_id_seq FROM admin;
122409
 
GRANT ALL ON SEQUENCE usr_usr_id_seq TO admin;
122410
 
GRANT ALL ON SEQUENCE usr_usr_id_seq TO xtrole;
122411
 
 
122412
 
 
122413
 
--
122414
 
--
122415
 
 
122416
 
REVOKE ALL ON SEQUENCE usrgrp_usrgrp_id_seq FROM PUBLIC;
122417
 
REVOKE ALL ON SEQUENCE usrgrp_usrgrp_id_seq FROM admin;
122418
 
GRANT ALL ON SEQUENCE usrgrp_usrgrp_id_seq TO admin;
122419
 
GRANT ALL ON SEQUENCE usrgrp_usrgrp_id_seq TO xtrole;
122420
 
 
122421
 
 
122422
 
--
122423
 
--
122424
 
 
122425
 
REVOKE ALL ON SEQUENCE usrpref_usrpref_id_seq FROM PUBLIC;
122426
 
REVOKE ALL ON SEQUENCE usrpref_usrpref_id_seq FROM admin;
122427
 
GRANT ALL ON SEQUENCE usrpref_usrpref_id_seq TO admin;
122428
 
GRANT ALL ON SEQUENCE usrpref_usrpref_id_seq TO xtrole;
122429
 
 
122430
 
 
122431
 
--
122432
 
--
122433
 
 
122434
 
REVOKE ALL ON SEQUENCE usrpriv_usrpriv_id_seq FROM PUBLIC;
122435
 
REVOKE ALL ON SEQUENCE usrpriv_usrpriv_id_seq FROM admin;
122436
 
GRANT ALL ON SEQUENCE usrpriv_usrpriv_id_seq TO admin;
122437
 
GRANT ALL ON SEQUENCE usrpriv_usrpriv_id_seq TO xtrole;
122438
 
 
122439
 
 
122440
 
--
122441
 
--
122442
 
 
122443
 
REVOKE ALL ON TABLE vend FROM PUBLIC;
122444
 
REVOKE ALL ON TABLE vend FROM admin;
122445
 
GRANT ALL ON TABLE vend TO admin;
122446
 
GRANT ALL ON TABLE vend TO xtrole;
122447
 
 
122448
 
 
122449
 
--
122450
 
--
122451
 
 
122452
 
REVOKE ALL ON SEQUENCE vend_vend_id_seq FROM PUBLIC;
122453
 
REVOKE ALL ON SEQUENCE vend_vend_id_seq FROM admin;
122454
 
GRANT ALL ON SEQUENCE vend_vend_id_seq TO admin;
122455
 
GRANT ALL ON SEQUENCE vend_vend_id_seq TO xtrole;
122456
 
 
122457
 
 
122458
 
--
122459
 
--
122460
 
 
122461
 
REVOKE ALL ON TABLE vendaddr FROM PUBLIC;
122462
 
REVOKE ALL ON TABLE vendaddr FROM admin;
122463
 
GRANT ALL ON TABLE vendaddr TO admin;
122464
 
GRANT ALL ON TABLE vendaddr TO xtrole;
122465
 
 
122466
 
 
122467
 
--
122468
 
--
122469
 
 
122470
 
REVOKE ALL ON SEQUENCE vendaddr_vendaddr_id_seq FROM PUBLIC;
122471
 
REVOKE ALL ON SEQUENCE vendaddr_vendaddr_id_seq FROM admin;
122472
 
GRANT ALL ON SEQUENCE vendaddr_vendaddr_id_seq TO admin;
122473
 
GRANT ALL ON SEQUENCE vendaddr_vendaddr_id_seq TO xtrole;
122474
 
 
122475
 
 
122476
 
--
122477
 
--
122478
 
 
122479
 
REVOKE ALL ON SEQUENCE vendtype_vendtype_id_seq FROM PUBLIC;
122480
 
REVOKE ALL ON SEQUENCE vendtype_vendtype_id_seq FROM admin;
122481
 
GRANT ALL ON SEQUENCE vendtype_vendtype_id_seq TO admin;
122482
 
GRANT ALL ON SEQUENCE vendtype_vendtype_id_seq TO xtrole;
122483
 
 
122484
 
 
122485
 
--
122486
 
--
122487
 
 
122488
 
REVOKE ALL ON TABLE vodist FROM PUBLIC;
122489
 
REVOKE ALL ON TABLE vodist FROM admin;
122490
 
GRANT ALL ON TABLE vodist TO admin;
122491
 
GRANT ALL ON TABLE vodist TO xtrole;
122492
 
 
122493
 
 
122494
 
--
122495
 
--
122496
 
 
122497
 
REVOKE ALL ON SEQUENCE vodist_vodist_id_seq FROM PUBLIC;
122498
 
REVOKE ALL ON SEQUENCE vodist_vodist_id_seq FROM admin;
122499
 
GRANT ALL ON SEQUENCE vodist_vodist_id_seq TO admin;
122500
 
GRANT ALL ON SEQUENCE vodist_vodist_id_seq TO xtrole;
122501
 
 
122502
 
 
122503
 
--
122504
 
--
122505
 
 
122506
 
REVOKE ALL ON TABLE vohead FROM PUBLIC;
122507
 
REVOKE ALL ON TABLE vohead FROM admin;
122508
 
GRANT ALL ON TABLE vohead TO admin;
122509
 
GRANT ALL ON TABLE vohead TO xtrole;
122510
 
 
122511
 
 
122512
 
--
122513
 
--
122514
 
 
122515
 
REVOKE ALL ON SEQUENCE vohead_vohead_id_seq FROM PUBLIC;
122516
 
REVOKE ALL ON SEQUENCE vohead_vohead_id_seq FROM admin;
122517
 
GRANT ALL ON SEQUENCE vohead_vohead_id_seq TO admin;
122518
 
GRANT ALL ON SEQUENCE vohead_vohead_id_seq TO xtrole;
122519
 
 
122520
 
 
122521
 
--
122522
 
--
122523
 
 
122524
 
REVOKE ALL ON TABLE voheadtax FROM PUBLIC;
122525
 
REVOKE ALL ON TABLE voheadtax FROM admin;
122526
 
GRANT ALL ON TABLE voheadtax TO admin;
122527
 
GRANT ALL ON TABLE voheadtax TO xtrole;
122528
 
 
122529
 
 
122530
 
--
122531
 
--
122532
 
 
122533
 
REVOKE ALL ON TABLE voitem FROM PUBLIC;
122534
 
REVOKE ALL ON TABLE voitem FROM admin;
122535
 
GRANT ALL ON TABLE voitem TO admin;
122536
 
GRANT ALL ON TABLE voitem TO xtrole;
122537
 
 
122538
 
 
122539
 
--
122540
 
--
122541
 
 
122542
 
REVOKE ALL ON SEQUENCE voitem_voitem_id_seq FROM PUBLIC;
122543
 
REVOKE ALL ON SEQUENCE voitem_voitem_id_seq FROM admin;
122544
 
GRANT ALL ON SEQUENCE voitem_voitem_id_seq TO admin;
122545
 
GRANT ALL ON SEQUENCE voitem_voitem_id_seq TO xtrole;
122546
 
 
122547
 
 
122548
 
--
122549
 
--
122550
 
 
122551
 
REVOKE ALL ON TABLE voitemtax FROM PUBLIC;
122552
 
REVOKE ALL ON TABLE voitemtax FROM admin;
122553
 
GRANT ALL ON TABLE voitemtax TO admin;
122554
 
GRANT ALL ON TABLE voitemtax TO xtrole;
122555
 
 
122556
 
 
122557
 
--
122558
 
--
122559
 
 
122560
 
REVOKE ALL ON TABLE warehous FROM PUBLIC;
122561
 
REVOKE ALL ON TABLE warehous FROM admin;
122562
 
GRANT ALL ON TABLE warehous TO admin;
122563
 
GRANT ALL ON TABLE warehous TO xtrole;
122564
 
 
122565
 
 
122566
 
--
122567
 
--
122568
 
 
122569
 
REVOKE ALL ON SEQUENCE warehous_warehous_id_seq FROM PUBLIC;
122570
 
REVOKE ALL ON SEQUENCE warehous_warehous_id_seq FROM admin;
122571
 
GRANT ALL ON SEQUENCE warehous_warehous_id_seq TO admin;
122572
 
GRANT ALL ON SEQUENCE warehous_warehous_id_seq TO xtrole;
122573
 
 
122574
 
 
122575
 
--
122576
 
--
122577
 
 
122578
 
REVOKE ALL ON SEQUENCE whsezone_whsezone_id_seq FROM PUBLIC;
122579
 
REVOKE ALL ON SEQUENCE whsezone_whsezone_id_seq FROM admin;
122580
 
GRANT ALL ON SEQUENCE whsezone_whsezone_id_seq TO admin;
122581
 
GRANT ALL ON SEQUENCE whsezone_whsezone_id_seq TO xtrole;
122582
 
 
122583
 
 
122584
 
--
122585
 
--
122586
 
 
122587
 
REVOKE ALL ON SEQUENCE wo_wo_id_seq FROM PUBLIC;
122588
 
REVOKE ALL ON SEQUENCE wo_wo_id_seq FROM admin;
122589
 
GRANT ALL ON SEQUENCE wo_wo_id_seq TO admin;
122590
 
GRANT ALL ON SEQUENCE wo_wo_id_seq TO xtrole;
122591
 
 
122592
 
 
122593
 
--
122594
 
--
122595
 
 
122596
 
REVOKE ALL ON SEQUENCE womatl_womatl_id_seq FROM PUBLIC;
122597
 
REVOKE ALL ON SEQUENCE womatl_womatl_id_seq FROM admin;
122598
 
GRANT ALL ON SEQUENCE womatl_womatl_id_seq TO admin;
122599
 
GRANT ALL ON SEQUENCE womatl_womatl_id_seq TO xtrole;
122600
 
 
122601
 
 
122602
 
--
122603
 
--
122604
 
 
122605
 
REVOKE ALL ON TABLE womatlpost FROM PUBLIC;
122606
 
REVOKE ALL ON TABLE womatlpost FROM admin;
122607
 
GRANT ALL ON TABLE womatlpost TO admin;
122608
 
GRANT ALL ON TABLE womatlpost TO xtrole;
122609
 
 
122610
 
 
122611
 
--
122612
 
--
122613
 
 
122614
 
REVOKE ALL ON SEQUENCE womatlpost_womatlpost_id_seq FROM PUBLIC;
122615
 
REVOKE ALL ON SEQUENCE womatlpost_womatlpost_id_seq FROM admin;
122616
 
GRANT ALL ON SEQUENCE womatlpost_womatlpost_id_seq TO admin;
122617
 
GRANT ALL ON SEQUENCE womatlpost_womatlpost_id_seq TO xtrole;
122618
 
 
122619
 
 
122620
 
--
122621
 
--
122622
 
 
122623
 
REVOKE ALL ON TABLE womatlvar FROM PUBLIC;
122624
 
REVOKE ALL ON TABLE womatlvar FROM admin;
122625
 
GRANT ALL ON TABLE womatlvar TO admin;
122626
 
GRANT ALL ON TABLE womatlvar TO xtrole;
122627
 
 
122628
 
 
122629
 
--
122630
 
--
122631
 
 
122632
 
REVOKE ALL ON SEQUENCE womatlvar_womatlvar_id_seq FROM PUBLIC;
122633
 
REVOKE ALL ON SEQUENCE womatlvar_womatlvar_id_seq FROM admin;
122634
 
GRANT ALL ON SEQUENCE womatlvar_womatlvar_id_seq TO admin;
122635
 
GRANT ALL ON SEQUENCE womatlvar_womatlvar_id_seq TO xtrole;
122636
 
 
122637
 
 
122638
 
--
122639
 
--
122640
 
 
122641
 
REVOKE ALL ON SEQUENCE xcalitem_xcalitem_id_seq FROM PUBLIC;
122642
 
REVOKE ALL ON SEQUENCE xcalitem_xcalitem_id_seq FROM admin;
122643
 
GRANT ALL ON SEQUENCE xcalitem_xcalitem_id_seq TO admin;
122644
 
GRANT ALL ON SEQUENCE xcalitem_xcalitem_id_seq TO xtrole;
122645
 
 
122646
 
 
122647
 
--
122648
 
--
122649
 
 
122650
 
REVOKE ALL ON TABLE xsltmap FROM PUBLIC;
122651
 
REVOKE ALL ON TABLE xsltmap FROM admin;
122652
 
GRANT ALL ON TABLE xsltmap TO admin;
122653
 
GRANT ALL ON TABLE xsltmap TO xtrole;
122654
 
 
122655
 
 
122656
 
--
122657
 
--
122658
 
 
122659
 
REVOKE ALL ON SEQUENCE xsltmap_xsltmap_id_seq FROM PUBLIC;
122660
 
REVOKE ALL ON SEQUENCE xsltmap_xsltmap_id_seq FROM admin;
122661
 
GRANT ALL ON SEQUENCE xsltmap_xsltmap_id_seq TO admin;
122662
 
GRANT ALL ON SEQUENCE xsltmap_xsltmap_id_seq TO xtrole;
122663
 
 
122664
 
 
122665
 
--
122666
 
--
122667
 
 
122668
 
REVOKE ALL ON TABLE yearperiod FROM PUBLIC;
122669
 
REVOKE ALL ON TABLE yearperiod FROM admin;
122670
 
GRANT ALL ON TABLE yearperiod TO admin;
122671
 
GRANT ALL ON TABLE yearperiod TO xtrole;
122672
 
 
122673
 
 
122674
 
--
122675
 
--
122676
 
 
122677
 
REVOKE ALL ON SEQUENCE yearperiod_yearperiod_id_seq FROM PUBLIC;
122678
 
REVOKE ALL ON SEQUENCE yearperiod_yearperiod_id_seq FROM admin;
122679
 
GRANT ALL ON SEQUENCE yearperiod_yearperiod_id_seq TO admin;
122680
 
GRANT ALL ON SEQUENCE yearperiod_yearperiod_id_seq TO xtrole;
122681
 
 
122682
 
 
122683
 
SET search_path = te, pg_catalog;
122684
 
 
122685
 
--
122686
 
--
122687
 
 
122688
 
REVOKE ALL ON TABLE pkgcmd FROM PUBLIC;
122689
 
REVOKE ALL ON TABLE pkgcmd FROM admin;
122690
 
GRANT ALL ON TABLE pkgcmd TO admin;
122691
 
GRANT ALL ON TABLE pkgcmd TO xtrole;
122692
 
 
122693
 
 
122694
 
--
122695
 
--
122696
 
 
122697
 
REVOKE ALL ON TABLE pkgcmdarg FROM PUBLIC;
122698
 
REVOKE ALL ON TABLE pkgcmdarg FROM admin;
122699
 
GRANT ALL ON TABLE pkgcmdarg TO admin;
122700
 
GRANT ALL ON TABLE pkgcmdarg TO xtrole;
122701
 
 
122702
 
 
122703
 
--
122704
 
--
122705
 
 
122706
 
REVOKE ALL ON TABLE pkgimage FROM PUBLIC;
122707
 
REVOKE ALL ON TABLE pkgimage FROM admin;
122708
 
GRANT ALL ON TABLE pkgimage TO admin;
122709
 
GRANT ALL ON TABLE pkgimage TO xtrole;
122710
 
 
122711
 
 
122712
 
--
122713
 
--
122714
 
 
122715
 
REVOKE ALL ON TABLE pkgmetasql FROM PUBLIC;
122716
 
REVOKE ALL ON TABLE pkgmetasql FROM admin;
122717
 
GRANT ALL ON TABLE pkgmetasql TO admin;
122718
 
GRANT ALL ON TABLE pkgmetasql TO xtrole;
122719
 
 
122720
 
 
122721
 
--
122722
 
--
122723
 
 
122724
 
REVOKE ALL ON TABLE pkgpriv FROM PUBLIC;
122725
 
REVOKE ALL ON TABLE pkgpriv FROM admin;
122726
 
GRANT ALL ON TABLE pkgpriv TO admin;
122727
 
GRANT ALL ON TABLE pkgpriv TO xtrole;
122728
 
 
122729
 
 
122730
 
--
122731
 
--
122732
 
 
122733
 
REVOKE ALL ON TABLE pkgreport FROM PUBLIC;
122734
 
REVOKE ALL ON TABLE pkgreport FROM admin;
122735
 
GRANT ALL ON TABLE pkgreport TO admin;
122736
 
GRANT ALL ON TABLE pkgreport TO xtrole;
122737
 
 
122738
 
 
122739
 
--
122740
 
--
122741
 
 
122742
 
REVOKE ALL ON TABLE pkgscript FROM PUBLIC;
122743
 
REVOKE ALL ON TABLE pkgscript FROM admin;
122744
 
GRANT ALL ON TABLE pkgscript TO admin;
122745
 
GRANT ALL ON TABLE pkgscript TO xtrole;
122746
 
 
122747
 
 
122748
 
--
122749
 
--
122750
 
 
122751
 
REVOKE ALL ON TABLE pkguiform FROM PUBLIC;
122752
 
REVOKE ALL ON TABLE pkguiform FROM admin;
122753
 
GRANT ALL ON TABLE pkguiform TO admin;
122754
 
GRANT ALL ON TABLE pkguiform TO xtrole;
122755
 
 
122756
 
 
122757
 
--
122758
 
--
122759
 
 
122760
 
REVOKE ALL ON TABLE tecustrate FROM PUBLIC;
122761
 
REVOKE ALL ON TABLE tecustrate FROM admin;
122762
 
GRANT ALL ON TABLE tecustrate TO admin;
122763
 
GRANT ALL ON TABLE tecustrate TO xtrole;
122764
 
 
122765
 
 
122766
 
--
122767
 
--
122768
 
 
122769
 
REVOKE ALL ON SEQUENCE tecustrate_tecustrate_id_seq FROM PUBLIC;
122770
 
REVOKE ALL ON SEQUENCE tecustrate_tecustrate_id_seq FROM admin;
122771
 
GRANT ALL ON SEQUENCE tecustrate_tecustrate_id_seq TO admin;
122772
 
GRANT ALL ON SEQUENCE tecustrate_tecustrate_id_seq TO xtrole;
122773
 
 
122774
 
 
122775
 
--
122776
 
--
122777
 
 
122778
 
REVOKE ALL ON TABLE teemp FROM PUBLIC;
122779
 
REVOKE ALL ON TABLE teemp FROM admin;
122780
 
GRANT ALL ON TABLE teemp TO admin;
122781
 
GRANT ALL ON TABLE teemp TO xtrole;
122782
 
 
122783
 
 
122784
 
--
122785
 
--
122786
 
 
122787
 
REVOKE ALL ON SEQUENCE teemp_teemp_id_seq FROM PUBLIC;
122788
 
REVOKE ALL ON SEQUENCE teemp_teemp_id_seq FROM admin;
122789
 
GRANT ALL ON SEQUENCE teemp_teemp_id_seq TO admin;
122790
 
GRANT ALL ON SEQUENCE teemp_teemp_id_seq TO xtrole;
122791
 
 
122792
 
 
122793
 
--
122794
 
--
122795
 
 
122796
 
REVOKE ALL ON TABLE teexp FROM PUBLIC;
122797
 
REVOKE ALL ON TABLE teexp FROM admin;
122798
 
GRANT ALL ON TABLE teexp TO admin;
122799
 
GRANT ALL ON TABLE teexp TO xtrole;
122800
 
 
122801
 
 
122802
 
--
122803
 
--
122804
 
 
122805
 
REVOKE ALL ON SEQUENCE timesheet_seq FROM PUBLIC;
122806
 
REVOKE ALL ON SEQUENCE timesheet_seq FROM admin;
122807
 
GRANT ALL ON SEQUENCE timesheet_seq TO admin;
122808
 
GRANT ALL ON SEQUENCE timesheet_seq TO xtrole;
122809
 
 
122810
 
 
122811
 
--
122812
 
--
122813
 
 
122814
 
REVOKE ALL ON TABLE tehead FROM PUBLIC;
122815
 
REVOKE ALL ON TABLE tehead FROM admin;
122816
 
GRANT ALL ON TABLE tehead TO admin;
122817
 
GRANT ALL ON TABLE tehead TO xtrole;
122818
 
 
122819
 
 
122820
 
--
122821
 
--
122822
 
 
122823
 
REVOKE ALL ON SEQUENCE tehead_tehead_id_seq FROM PUBLIC;
122824
 
REVOKE ALL ON SEQUENCE tehead_tehead_id_seq FROM admin;
122825
 
GRANT ALL ON SEQUENCE tehead_tehead_id_seq TO admin;
122826
 
GRANT ALL ON SEQUENCE tehead_tehead_id_seq TO xtrole;
122827
 
 
122828
 
 
122829
 
--
122830
 
--
122831
 
 
122832
 
REVOKE ALL ON TABLE teitem FROM PUBLIC;
122833
 
REVOKE ALL ON TABLE teitem FROM admin;
122834
 
GRANT ALL ON TABLE teitem TO admin;
122835
 
GRANT ALL ON TABLE teitem TO xtrole;
122836
 
 
122837
 
 
122838
 
--
122839
 
--
122840
 
 
122841
 
REVOKE ALL ON SEQUENCE teitem_teitem_id_seq FROM PUBLIC;
122842
 
REVOKE ALL ON SEQUENCE teitem_teitem_id_seq FROM admin;
122843
 
GRANT ALL ON SEQUENCE teitem_teitem_id_seq TO admin;
122844
 
GRANT ALL ON SEQUENCE teitem_teitem_id_seq TO xtrole;
122845
 
 
122846
 
 
122847
 
--
122848
 
--
122849
 
 
122850
 
REVOKE ALL ON TABLE teprj FROM PUBLIC;
122851
 
REVOKE ALL ON TABLE teprj FROM admin;
122852
 
GRANT ALL ON TABLE teprj TO admin;
122853
 
GRANT ALL ON TABLE teprj TO xtrole;
122854
 
 
122855
 
 
122856
 
--
122857
 
--
122858
 
 
122859
 
REVOKE ALL ON SEQUENCE teprj_teprj_id_seq FROM PUBLIC;
122860
 
REVOKE ALL ON SEQUENCE teprj_teprj_id_seq FROM admin;
122861
 
GRANT ALL ON SEQUENCE teprj_teprj_id_seq TO admin;
122862
 
GRANT ALL ON SEQUENCE teprj_teprj_id_seq TO xtrole;
122863
 
 
122864
 
 
122865
 
--
122866
 
--
122867
 
 
122868
 
REVOKE ALL ON TABLE teprjtask FROM PUBLIC;
122869
 
REVOKE ALL ON TABLE teprjtask FROM admin;
122870
 
GRANT ALL ON TABLE teprjtask TO admin;
122871
 
GRANT ALL ON TABLE teprjtask TO xtrole;
122872
 
 
122873
 
 
122874
 
--
122875
 
--
122876
 
 
122877
 
REVOKE ALL ON SEQUENCE teprjtask_teprjtask_id_seq FROM PUBLIC;
122878
 
REVOKE ALL ON SEQUENCE teprjtask_teprjtask_id_seq FROM admin;
122879
 
GRANT ALL ON SEQUENCE teprjtask_teprjtask_id_seq TO admin;
122880
 
GRANT ALL ON SEQUENCE teprjtask_teprjtask_id_seq TO xtrole;
122881
 
 
122882
 
 
122883
 
SET search_path = xtdesktop, pg_catalog;
122884
 
 
122885
 
--
122886
 
--
122887
 
 
122888
 
REVOKE ALL ON TABLE pkgcmd FROM PUBLIC;
122889
 
REVOKE ALL ON TABLE pkgcmd FROM admin;
122890
 
GRANT ALL ON TABLE pkgcmd TO admin;
122891
 
GRANT ALL ON TABLE pkgcmd TO xtrole;
122892
 
 
122893
 
 
122894
 
--
122895
 
--
122896
 
 
122897
 
REVOKE ALL ON TABLE pkgcmdarg FROM PUBLIC;
122898
 
REVOKE ALL ON TABLE pkgcmdarg FROM admin;
122899
 
GRANT ALL ON TABLE pkgcmdarg TO admin;
122900
 
GRANT ALL ON TABLE pkgcmdarg TO xtrole;
122901
 
 
122902
 
 
122903
 
--
122904
 
--
122905
 
 
122906
 
REVOKE ALL ON TABLE pkgimage FROM PUBLIC;
122907
 
REVOKE ALL ON TABLE pkgimage FROM admin;
122908
 
GRANT ALL ON TABLE pkgimage TO admin;
122909
 
GRANT ALL ON TABLE pkgimage TO xtrole;
122910
 
 
122911
 
 
122912
 
--
122913
 
--
122914
 
 
122915
 
REVOKE ALL ON TABLE pkgmetasql FROM PUBLIC;
122916
 
REVOKE ALL ON TABLE pkgmetasql FROM admin;
122917
 
GRANT ALL ON TABLE pkgmetasql TO admin;
122918
 
GRANT ALL ON TABLE pkgmetasql TO xtrole;
122919
 
 
122920
 
 
122921
 
--
122922
 
--
122923
 
 
122924
 
REVOKE ALL ON TABLE pkgpriv FROM PUBLIC;
122925
 
REVOKE ALL ON TABLE pkgpriv FROM admin;
122926
 
GRANT ALL ON TABLE pkgpriv TO admin;
122927
 
GRANT ALL ON TABLE pkgpriv TO xtrole;
122928
 
 
122929
 
 
122930
 
--
122931
 
--
122932
 
 
122933
 
REVOKE ALL ON TABLE pkgreport FROM PUBLIC;
122934
 
REVOKE ALL ON TABLE pkgreport FROM admin;
122935
 
GRANT ALL ON TABLE pkgreport TO admin;
122936
 
GRANT ALL ON TABLE pkgreport TO xtrole;
122937
 
 
122938
 
 
122939
 
--
122940
 
--
122941
 
 
122942
 
REVOKE ALL ON TABLE pkgscript FROM PUBLIC;
122943
 
REVOKE ALL ON TABLE pkgscript FROM admin;
122944
 
GRANT ALL ON TABLE pkgscript TO admin;
122945
 
GRANT ALL ON TABLE pkgscript TO xtrole;
122946
 
 
122947
 
 
122948
 
--
122949
 
--
122950
 
 
122951
 
REVOKE ALL ON TABLE pkguiform FROM PUBLIC;
122952
 
REVOKE ALL ON TABLE pkguiform FROM admin;
122953
 
GRANT ALL ON TABLE pkguiform TO admin;
122954
 
GRANT ALL ON TABLE pkguiform TO xtrole;
122955
 
 
122956
 
 
122957
 
--
122958
 
--
122959